diff --git a/README.md b/README.md index 2db6bb1c3..1127d0cec 100755 --- a/README.md +++ b/README.md @@ -39,6 +39,7 @@ List of Definitions * [bootstrap.datepicker](https://github.com/eternicode/bootstrap-datepicker) (by [Boris Yankov](https://github.com/borisyankov)) * [Box2DWeb](http://code.google.com/p/box2dweb/) (by [Josh Baldwin](https://github.com/jbaldwin/)) * [Breeze](http://www.breezejs.com/) (by [Boris Yankov](https://github.com/borisyankov)) +* [Browser Harness](https://github.com/scriby/browser-harness) (by [Chris Scribner](https://github.com/scriby)) * [CasperJS](http://casperjs.org) (by [Jed Hunsaker](https://github.com/jedhunsaker)) * [Cheerio](https://github.com/MatthewMueller/cheerio) (by [Bret Little](https://github.com/blittle)) * [Chosen](http://harvesthq.github.com/chosen/) (by [Boris Yankov](https://github.com/borisyankov)) @@ -145,6 +146,7 @@ List of Definitions * [node_zeromq](https://github.com/JustinTulloss/zeromq.node) (by [Dave McKeown](https://github.com/davemckeown)) * [node-sqlserver](https://github.com/WindowsAzure/node-sqlserver) (by [Boris Yankov](https://github.com/borisyankov)) * [Numeral.js](https://github.com/adamwdraper/Numeral-js) (by [Vincent Bortone](https://github.com/vbortone/)) +* [Persona](http://www.mozilla.org/en-US/persona) (by [James Frasca](https://github.com/Nycto)) * [PhantomJS](http://phantomjs.org) (by [Jed Hunsaker](https://github.com/jedhunsaker)) * [PhoneGap](http://phonegap.com) (by [Boris Yankov](https://github.com/borisyankov)) * [Platform](https://github.com/bestiejs/platform.js) (by [Jake Hickman](https://github.com/JakeH)) diff --git a/_infrastructure/tests/runner.js b/_infrastructure/tests/runner.js index 987499354..21e6e2ac1 100644 --- a/_infrastructure/tests/runner.js +++ b/_infrastructure/tests/runner.js @@ -648,7 +648,7 @@ var DefinitelyTyped; Print.prototype.printHeader = function () { this.out('=============================================================================\n'); - this.out(' \33[36m\33[1mDefinitelyTyped test runner 0.2.0\33[0m\n'); + this.out(' \33[36m\33[1mDefinitelyTyped test runner 0.2.1\33[0m\n'); this.out('=============================================================================\n'); this.out(' \33[36m\33[1mTypescript version:\33[0m ' + this.version + '\n'); this.out(' \33[36m\33[1mTypings :\33[0m ' + this.typings + '\n'); @@ -980,7 +980,7 @@ var DefinitelyTyped; this.dtPath = dtPath; this.typings = []; this.fh = new FileHandler(dtPath, /.\.ts/g); - this.out = new Print('0.9.0.0', this.fh.allTypings().length, this.fh.allTS().length); + this.out = new Print('0.9.1.0', this.fh.allTypings().length, this.fh.allTS().length); this.sc = new SyntaxChecking(this.fh, this.out); this.te = new TestEval(this.fh, this.out); diff --git a/_infrastructure/tests/runner.ts b/_infrastructure/tests/runner.ts index 61d0f5b10..0d4225286 100644 --- a/_infrastructure/tests/runner.ts +++ b/_infrastructure/tests/runner.ts @@ -141,7 +141,7 @@ module DefinitelyTyped { public printHeader() { this.out('=============================================================================\n'); - this.out(' \33[36m\33[1mDefinitelyTyped test runner 0.2.0\33[0m\n'); + this.out(' \33[36m\33[1mDefinitelyTyped test runner 0.2.1\33[0m\n'); this.out('=============================================================================\n'); this.out(' \33[36m\33[1mTypescript version:\33[0m ' + this.version + '\n'); this.out(' \33[36m\33[1mTypings :\33[0m ' + this.typings + '\n'); @@ -504,7 +504,7 @@ module DefinitelyTyped { constructor(public dtPath: string) { this.fh = new FileHandler(dtPath, /.\.ts/g); - this.out = new Print('0.9.0.0', this.fh.allTypings().length, this.fh.allTS().length); + this.out = new Print('0.9.1.0', this.fh.allTypings().length, this.fh.allTS().length); this.sc = new SyntaxChecking(this.fh, this.out); this.te = new TestEval(this.fh, this.out); diff --git a/_infrastructure/tests/typescript/lib.d.ts b/_infrastructure/tests/typescript/lib.d.ts index 95d15c1a2..3ae612c11 100644 --- a/_infrastructure/tests/typescript/lib.d.ts +++ b/_infrastructure/tests/typescript/lib.d.ts @@ -1,9074 +1,9178 @@ -/* ***************************************************************************** -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 - -THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED -WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, -MERCHANTABLITY OR NON-INFRINGEMENT. - -See the Apache Version 2.0 License for specific language governing permissions -and limitations under the License. -***************************************************************************** */ - -/// - -//////////////// -/// ECMAScript APIs -//////////////// - -declare var NaN: number; -declare var Infinity: number; - -/** - * Evaluates JavaScript code and executes it. - * @param x A String value that contains valid JavaScript code. - */ -declare function eval(x: string): any; - -/** - * Converts A string to an integer. - * @param s A string to convert into a number. - * @param radix A value between 2 and 36 that specifies the base of the number in numString. - * If this argument is not supplied, strings with a prefix of '0x' are considered hexadecimal. - * All other strings are considered decimal. - */ -declare function parseInt(s: string, radix?: number): number; - -/** - * Converts a string to a floating-point number. - * @param string A string that contains a floating-point number. - */ -declare function parseFloat(string: string): number; - -/** - * Returns a Boolean value that indicates whether a value is the reserved value NaN (not a number). - * @param number A numeric value. - */ -declare function isNaN(number: number): boolean; - -/** - * Determines whether a supplied number is finite. - * @param number Any numeric value. - */ -declare function isFinite(number: number): boolean; - -/** - * Gets the unencoded version of an encoded Uniform Resource Identifier (URI). - * @param encodedURI A value representing an encoded URI. - */ -declare function decodeURI(encodedURI: string): string; - -/** - * Gets the unencoded version of an encoded component of a Uniform Resource Identifier (URI). - * @param encodedURIComponent A value representing an encoded URI component. - */ -declare function decodeURIComponent(encodedURIComponent: string): string; - -/** - * Encodes a text string as a valid Uniform Resource Identifier (URI) - * @param uri A value representing an encoded URI. - */ -declare function encodeURI(uri: string): string; - -/** - * Encodes a text string as a valid component of a Uniform Resource Identifier (URI). - * @param uriComponent A value representing an encoded URI component. - */ -declare function encodeURIComponent(uriComponent: string): string; - -interface PropertyDescriptor { - configurable?: boolean; - enumerable?: boolean; - value?: any; - writable?: boolean; - get?(): any; - set?(v: any): void; -} - -interface PropertyDescriptorMap { - [s: string]: PropertyDescriptor; -} - -interface Object { - /** Returns a string representation of an object. */ - toString(): string; - - /** Returns a date converted to a string using the current locale. */ - toLocaleString(): string; - - /** Returns the primitive value of the specified object. */ - valueOf(): Object; - - /** - * Determines whether an object has a property with the specified name. - * @param v A property name. - */ - hasOwnProperty(v: string): boolean; - - /** - * Determines whether an object exists in another object's prototype chain. - * @param v Another object whose prototype chain is to be checked. - */ - isPrototypeOf(v: Object): boolean; - - /** - * Determines whether a specified property is enumerable. - * @param v A property name. - */ - propertyIsEnumerable(v: string): boolean; - - [s: string]: any; -} - -/** - * Provides functionality common to all JavaScript objects. - */ -declare var Object: { - new (value?: any): Object; - (): any; - (value: any): any; - - /** A reference to the prototype for a class of objects. */ - prototype: Object; - - /** - * Returns the prototype of an object. - * @param o The object that references the prototype. - */ - getPrototypeOf(o: any): any; - - /** - * Gets the own property descriptor of the specified object. - * An own property descriptor is one that is defined directly on the object and is not inherited from the object's prototype. - * @param o Object that contains the property. - * @param p Name of the property. - */ - getOwnPropertyDescriptor(o: any, p: string): PropertyDescriptor; - - /** - * Returns the names of the own properties of an object. The own properties of an object are those that are defined directly - * on that object, and are not inherited from the object's prototype. The properties of an object include both fields (objects) and functions. - * @param o Object that contains the own properties. - */ - getOwnPropertyNames(o: any): string[]; - - /** - * Creates an object that has the specified prototype, and that optionally contains specified properties. - * @param o Object to use as a prototype. May be null - * @param properties JavaScript object that contains one or more property descriptors. - */ - create(o: any, properties?: PropertyDescriptorMap): any; - - /** - * Adds a property to an object, or modifies attributes of an existing property. - * @param o Object on which to add or modify the property. This can be a native JavaScript object (that is, a user-defined object or a built in object) or a DOM object. - * @param p The property name. - * @param attributes Descriptor for the property. It can be for a data property or an accessor property. - */ - defineProperty(o: any, p: string, attributes: PropertyDescriptor): any; - - /** - * Adds one or more properties to an object, and/or modifies attributes of existing properties. - * @param o Object on which to add or modify the properties. This can be a native JavaScript object or a DOM object. - * @param properties JavaScript object that contains one or more descriptor objects. Each descriptor object describes a data property or an accessor property. - */ - defineProperties(o: any, properties: PropertyDescriptorMap): any; - - /** - * Prevents the modification of attributes of existing properties, and prevents the addition of new properties. - * @param o Object on which to lock the attributes. - */ - seal(o: any): any; - - /** - * Prevents the modification of existing property attributes and values, and prevents the addition of new properties. - * @param o Object on which to lock the attributes. - */ - freeze(o: any): any; - - /** - * Prevents the addition of new properties to an object. - * @param o Object to make non-extensible. - */ - preventExtensions(o: any): any; - - /** - * Returns true if existing property attributes cannot be modified in an object and new properties cannot be added to the object. - * @param o Object to test. - */ - isSealed(o: any): boolean; - - /** - * Returns true if existing property attributes and values cannot be modified in an object, and new properties cannot be added to the object. - * @param o Object to test. - */ - isFrozen(o: any): boolean; - - /** - * Returns a value that indicates whether new properties can be added to an object. - * @param o Object to test. - */ - isExtensible(o: any): boolean; - - /** - * Returns the names of the enumerable properties and methods of an object. - * @param o Object that contains the properties and methods. This can be an object that you created or an existing Document Object Model (DOM) object. - */ - keys(o: any): string[]; -} - -/** - * Creates a new function. - */ -interface Function { - /** - * Calls the function, substituting the specified object for the this value of the function, and the specified array for the arguments of the function. - * @param thisArg The object to be used as the this object. - * @param argArray A set of arguments to be passed to the function. - */ - apply(thisArg: any, argArray?: any): any; - - /** - * Calls a method of an object, substituting another object for the current object. - * @param thisArg The object to be used as the current object. - * @param argArray A list of arguments to be passed to the method. - */ - call(thisArg: any, ...argArray: any[]): any; - - /** - * For a given function, creates a bound function that has the same body as the original function. - * The this object of the bound function is associated with the specified object, and has the specified initial parameters. - * @param thisArg An object to which the this keyword can refer inside the new function. - * @param argArray A list of arguments to be passed to the new function. - */ - bind(thisArg: any, ...argArray: any[]): any; - - prototype: any; - length: number; - - // Non-standard extensions - arguments: any; - caller: Function; -} - -declare var Function: { - /** - * Creates a new function. - * @param args A list of arguments the function accepts. - */ - new (...args: string[]): Function; - (...args: string[]): Function; - prototype: Function; -} - -interface IArguments { - [index: number]: any; - length: number; - callee: Function; -} - -interface String { - /** Returns a string representation of a string. */ - toString(): string; - - /** - * Returns the character at the specified index. - * @param pos The zero-based index of the desired character. - */ - charAt(pos: number): string; - - /** - * Returns the Unicode value of the character at the specified location. - * @param index The zero-based index of the desired character. If there is no character at the specified index, NaN is returned. - */ - charCodeAt(index: number): number; - - /** - * Returns a string that contains the concatenation of two or more strings. - * @param strings The strings to append to the end of the string. - */ - concat(...strings: string[]): string; - - /** - * Returns the position of the first occurrence of a substring. - * @param searchString The substring to search for in the string - * @param position The index at which to begin searching the String object. If omitted, search starts at the beginning of the string. - */ - indexOf(searchString: string, position?: number): number; - - /** - * Returns the last occurrence of a substring in the string. - * @param searchString The substring to search for. - * @param position The index at which to begin searching. If omitted, the search begins at the end of the string. - */ - lastIndexOf(searchString: string, position?: number): number; - - /** - * Determines whether two strings are equivalent in the current locale. - * @param that String to compare to target string - */ - localeCompare(that: string): number; - - /** - * Matches a string with a regular expression, and returns an array containing the results of that search. - * @param regexp A variable name or string literal containing the regular expression pattern and flags. - */ - match(regexp: string): string[]; - /** - * Matches a string with a regular expression, and returns an array containing the results of that search. - * @param regexp A regular expression object that contains the regular expression pattern and applicable flags. - */ - match(regexp: RegExp): string[]; - - /** - * Replaces text in a string, using a regular expression or search string. - * @param searchValue A String object or string literal that represents the regular expression - * @param replaceValue A String object or string literal containing the text to replace for every successful match of rgExp in stringObj. - */ - replace(searchValue: string, replaceValue: string): string; - /** - * Replaces text in a string, using a regular expression or search string. - * @param searchValue A String object or string literal that represents the regular expression - * @param replaceValue A function that returns the replacement text. - */ - replace(searchValue: string, replaceValue: (substring: string, ...args: any[]) => string): string; - /** - * Replaces text in a string, using a regular expression or search string. - * @param searchValue A Regular Expression object containing the regular expression pattern and applicable flags - * @param replaceValue A String object or string literal containing the text to replace for every successful match of rgExp in stringObj. - */ - replace(searchValue: RegExp, replaceValue: string): string; - /** - * Replaces text in a string, using a regular expression or search string. - * @param searchValue A Regular Expression object containing the regular expression pattern and applicable flags - * @param replaceValue A function that returns the replacement text. - */ - replace(searchValue: RegExp, replaceValue: (substring: string, ...args: any[]) => string): string; - - /** - * Finds the first substring match in a regular expression search. - * @param regexp The regular expression pattern and applicable flags. - */ - search(regexp: string): number; - /** - * Finds the first substring match in a regular expression search. - * @param regexp The regular expression pattern and applicable flags. - */ - search(regexp: RegExp): number; - - /** - * Returns a section of a string. - * @param start The index to the beginning of the specified portion of stringObj. - * @param end The index to the end of the specified portion of stringObj. The substring includes the characters up to, but not including, the character indicated by end. - * If this value is not specified, the substring continues to the end of stringObj. - */ - slice(start: number, end?: number): string; - - /** - * Split a string into substrings using the specified separator and return them as an array. - * @param separator A string that identifies character or characters to use in separating the string. If omitted, a single-element array containing the entire string is returned. - * @param limit A value used to limit the number of elements returned in the array. - */ - split(separator: string, limit?: number): string[]; - /** - * Split a string into substrings using the specified separator and return them as an array. - * @param separator A Regular Express that identifies character or characters to use in separating the string. If omitted, a single-element array containing the entire string is returned. - * @param limit A value used to limit the number of elements returned in the array. - */ - split(separator: RegExp, limit?: number): string[]; - - /** - * Returns the substring at the specified location within a String object. - * @param start The zero-based index integer indicating the beginning of the substring. - * @param end Zero-based index integer indicating the end of the substring. The substring includes the characters up to, but not including, the character indicated by end. - * If end is omitted, the characters from start through the end of the original string are returned. - */ - substring(start: number, end?: number): string; - - /** Converts all the alphabetic characters in a string to lowercase. */ - toLowerCase(): string; - - /** Converts all alphabetic characters to lowercase, taking into account the host environment's current locale. */ - toLocaleLowerCase(): string; - - /** Converts all the alphabetic characters in a string to uppercase. */ - toUpperCase(): string; - - /** Returns a string where all alphabetic characters have been converted to uppercase, taking into account the host environment's current locale. */ - toLocaleUpperCase(): string; - - /** Removes the leading and trailing white space and line terminator characters from a string. */ - trim(): string; - - /** Returns the length of a String object. */ - length: number; - - // IE extensions - /** - * Gets a substring beginning at the specified location and having the specified length. - * @param from The starting position of the desired substring. The index of the first character in the string is zero. - * @param length The number of characters to include in the returned substring. - */ - substr(from: number, length?: number): string; -} - -/** - * Allows manipulation and formatting of text strings and determination and location of substrings within strings. - */ -declare var String: { - new (value?: any): String; - (value?: any): string; - prototype: String; - fromCharCode(...codes: number[]): string; -} - -interface Boolean { -} -declare var Boolean: { - new (value?: any): Boolean; - (value?: any): boolean; - prototype: Boolean; -} - -interface Number { - toString(radix?: number): string; - toFixed(fractionDigits?: number): string; - toExponential(fractionDigits?: number): string; - toPrecision(precision: number): string; -} -/** An object that represents a number of any kind. All JavaScript numbers are 64-bit floating-point numbers. */ -declare var Number: { - new (value?: any): Number; - (value?: any): number; - prototype: Number; - /** The largest number that can be represented in JavaScript. Equal to approximately 1.79E+308. */ - MAX_VALUE: number; - /** The closest number to zero that can be represented in JavaScript. Equal to approximately 5.00E-324. */ - MIN_VALUE: number; - /** - * A value that is not a number. - * In equality comparisons, NaN does not equal any value, including itself. To test whether a value is equivalent to NaN, use the isNaN function. - */ - NaN: number; - /** - * A value that is less than the largest negative number that can be represented in JavaScript. - * JavaScript displays NEGATIVE_INFINITY values as -infinity. - */ - NEGATIVE_INFINITY: number; - /** - * A value greater than the largest number that can be represented in JavaScript. - * JavaScript displays POSITIVE_INFINITY values as infinity. - */ - POSITIVE_INFINITY: number; -} - -interface Math { - /** The mathematical constant e. This is Euler's number, the base of natural logarithms. */ - E: number; - /** The natural logarithm of 10. */ - LN10: number; - /** The natural logarithm of 2. */ - LN2: number; - /** The base-2 logarithm of e. */ - LOG2E: number; - /** The base-10 logarithm of e. */ - LOG10E: number; - /** Pi. This is the ratio of the circumference of a circle to its diameter. */ - PI: number; - /** The square root of 0.5, or, equivalently, one divided by the square root of 2. */ - SQRT1_2: number; - /** The square root of 2. */ - SQRT2: number; - /** - * Returns the absolute value of a number (the value without regard to whether it is positive or negative). - * For example, the absolute value of -5 is the same as the absolute value of 5. - * @param x A numeric expression for which the absolute value is needed. - */ - abs(x: number): number; - /** - * Returns the arc cosine (or inverse cosine) of a number. - * @param x A numeric expression. - */ - acos(x: number): number; - /** - * Returns the arcsine of a number. - * @param x A numeric expression. - */ - asin(x: number): number; - /** - * Returns the arctangent of a number. - * @param x A numeric expression for which the arctangent is needed. - */ - atan(x: number): number; - /** - * Returns the angle (in radians) from the X axis to a point (y,x). - * @param y A numeric expression representing the cartesian y-coordinate. - * @param x A numeric expression representing the cartesian x-coordinate. - */ - atan2(y: number, x: number): number; - /** - * Returns the smallest integer greater than or equal to its numeric argument. - * @param x A numeric expression. - */ - ceil(x: number): number; - /** - * Returns the cosine of a number. - * @param x A numeric expression that contains an angle measured in radians. - */ - cos(x: number): number; - /** - * Returns e (the base of natural logarithms) raised to a power. - * @param x A numeric expression representing the power of e. - */ - exp(x: number): number; - /** - * Returns the greatest integer less than or equal to its numeric argument. - * @param x A numeric expression. - */ - floor(x: number): number; - /** - * Returns the natural logarithm (base e) of a number. - * @param x A numeric expression. - */ - log(x: number): number; - /** - * Returns the larger of a set of supplied numeric expressions. - * @param values Numeric expressions to be evaluated. - */ - max(...values: number[]): number; - /** - * Returns the smaller of a set of supplied numeric expressions. - * @param values Numeric expressions to be evaluated. - */ - min(...values: number[]): number; - /** - * Returns the value of a base expression taken to a specified power. - * @param x The base value of the expression. - * @param y The exponent value of the expression. - */ - pow(x: number, y: number): number; - /** Returns a pseudorandom number between 0 and 1. */ - random(): number; - /** - * Returns a supplied numeric expression rounded to the nearest integer. - * @param x The value to be rounded to the nearest integer. - */ - round(x: number): number; - /** - * Returns the sine of a number. - * @param x A numeric expression that contains an angle measured in radians. - */ - sin(x: number): number; - /** - * Returns the square root of a number. - * @param x A numeric expression. - */ - sqrt(x: number): number; - /** - * Returns the tangent of a number. - * @param x A numeric expression that contains an angle measured in radians. - */ - tan(x: number): number; -} -/** An intrinsic object that provides basic mathematics functionality and constants. */ -declare var Math: Math; - -/** Enables basic storage and retrieval of dates and times. */ -interface Date { - /** Returns a string representation of a date. The format of the string depends on the locale. */ - toString(): string; - /** Returns a date as a string value. */ - toDateString(): string; - /** Returns a time as a string value. */ - toTimeString(): string; - toLocaleString(): string; - /** Returns a date as a string value appropriate to the host environment's current locale. */ - toLocaleDateString(): string; - /** Returns a time as a string value appropriate to the host environment's current locale. */ - toLocaleTimeString(): string; - /** Returns the stored time value in milliseconds since midnight, January 1, 1970 UTC. */ - valueOf(): number; - /** Gets the time value in milliseconds. */ - getTime(): number; - /** Gets the year, using local time. */ - getFullYear(): number; - /** Gets the year using Universal Coordinated Time (UTC). */ - getUTCFullYear(): number; - /** Gets the month, using local time. */ - getMonth(): number; - /** Gets the month of a Date object using Universal Coordinated Time (UTC). */ - getUTCMonth(): number; - /** Gets the day-of-the-month, using local time. */ - getDate(): number; - /** Gets the day-of-the-month, using Universal Coordinated Time (UTC). */ - getUTCDate(): number; - /** Gets the day of the week, using local time. */ - getDay(): number; - /** Gets the day of the week using Universal Coordinated Time (UTC). */ - getUTCDay(): number; - /** Gets the hours in a date, using local time. */ - getHours(): number; - /** Gets the hours value in a Date object using Universal Coordinated Time (UTC). */ - getUTCHours(): number; - /** Gets the minutes of a Date object, using local time. */ - getMinutes(): number; - /** Gets the minutes of a Date object using Universal Coordinated Time (UTC). */ - getUTCMinutes(): number; - /** Gets the seconds of a Date object, using local time. */ - getSeconds(): number; - /** Gets the seconds of a Date object using Universal Coordinated Time (UTC). */ - getUTCSeconds(): number; - /** Gets the milliseconds of a Date, using local time. */ - getMilliseconds(): number; - /** Gets the milliseconds of a Date object using Universal Coordinated Time (UTC). */ - getUTCMilliseconds(): number; - /** Gets the difference in minutes between the time on the local computer and Universal Coordinated Time (UTC). */ - getTimezoneOffset(): number; - /** - * Sets the date and time value in the Date object. - * @param time A numeric value representing the number of elapsed milliseconds since midnight, January 1, 1970 GMT. - */ - setTime(time: number): void; - /** - * Sets the milliseconds value in the Date object using local time. - * @param ms A numeric value equal to the millisecond value. - */ - setMilliseconds(ms: number): void; - /** - * Sets the milliseconds value in the Date object using Universal Coordinated Time (UTC). - * @param ms A numeric value equal to the millisecond value. - */ - setUTCMilliseconds(ms: number): void; - - /** - * Sets the seconds value in the Date object using local time. - * @param sec A numeric value equal to the seconds value. - * @param ms A numeric value equal to the milliseconds value. - */ - setSeconds(sec: number, ms?: number): void; - /** - * Sets the seconds value in the Date object using Universal Coordinated Time (UTC). - * @param sec A numeric value equal to the seconds value. - * @param ms A numeric value equal to the milliseconds value. - */ - setUTCSeconds(sec: number, ms?: number): void; - /** - * Sets the minutes value in the Date object using local time. - * @param min A numeric value equal to the minutes value. - * @param sec A numeric value equal to the seconds value. - * @param ms A numeric value equal to the milliseconds value. - */ - setMinutes(min: number, sec?: number, ms?: number): void; - /** - * Sets the minutes value in the Date object using Universal Coordinated Time (UTC). - * @param min A numeric value equal to the minutes value. - * @param sec A numeric value equal to the seconds value. - * @param ms A numeric value equal to the milliseconds value. - */ - setUTCMinutes(min: number, sec?: number, ms?: number): void; - /** - * Sets the hour value in the Date object using local time. - * @param hours A numeric value equal to the hours value. - * @param min A numeric value equal to the minutes value. - * @param sec A numeric value equal to the seconds value. - * @param ms A numeric value equal to the milliseconds value. - */ - setHours(hours: number, min?: number, sec?: number, ms?: number): void; - /** - * Sets the hours value in the Date object using Universal Coordinated Time (UTC). - * @param hours A numeric value equal to the hours value. - * @param min A numeric value equal to the minutes value. - * @param sec A numeric value equal to the seconds value. - * @param ms A numeric value equal to the milliseconds value. - */ - setUTCHours(hours: number, min?: number, sec?: number, ms?: number): void; - /** - * Sets the numeric day-of-the-month value of the Date object using local time. - * @param date A numeric value equal to the day of the month. - */ - setDate(date: number): void; - /** - * Sets the numeric day of the month in the Date object using Universal Coordinated Time (UTC). - * @param date A numeric value equal to the day of the month. - */ - setUTCDate(date: number): void; - /** - * Sets the month value in the Date object using local time. - * @param month A numeric value equal to the month. The value for January is 0, and other month values follow consecutively. - * @param date A numeric value representing the day of the month. If this value is not supplied, the value from a call to the getDate method is used. - */ - setMonth(month: number, date?: number): void; - /** - * Sets the month value in the Date object using Universal Coordinated Time (UTC). - * @param month A numeric value equal to the month. The value for January is 0, and other month values follow consecutively. - * @param date A numeric value representing the day of the month. If it is not supplied, the value from a call to the getUTCDate method is used. - */ - setUTCMonth(month: number, date?: number): void; - /** - * Sets the year of the Date object using local time. - * @param year A numeric value for the year. - * @param month A zero-based numeric value for the month (0 for January, 11 for December). Must be specified if numDate is specified. - * @param date A numeric value equal for the day of the month. - */ - setFullYear(year: number, month?: number, date?: number): void; - /** - * Sets the year value in the Date object using Universal Coordinated Time (UTC). - * @param year A numeric value equal to the year. - * @param month A numeric value equal to the month. The value for January is 0, and other month values follow consecutively. Must be supplied if numDate is supplied. - * @param date A numeric value equal to the day of the month. - */ - setUTCFullYear(year: number, month?: number, date?: number): void; - /** Returns a date converted to a string using Universal Coordinated Time (UTC). */ - toUTCString(): string; - /** Returns a date as a string value in ISO format. */ - toISOString(): string; - /** Used by the JSON.stringify method to enable the transformation of an object's data for JavaScript Object Notation (JSON) serialization. */ - toJSON(key?: any): string; -} -/** - * Enables basic storage and retrieval of dates and times. - */ -declare var Date: { - new (): Date; - new (value: number): Date; - new (value: string): Date; - new (year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): Date; - (): string; - prototype: Date; - /** - * Parses a string containing a date, and returns the number of milliseconds between that date and midnight, January 1, 1970. - * @param s A date string - */ - parse(s: string): number; - /** - * Returns the number of milliseconds between midnight, January 1, 1970 Universal Coordinated Time (UTC) (or GMT) and the specified date. - * @param year The full year designation is required for cross-century date accuracy. If year is between 0 and 99 is used, then year is assumed to be 1900 + year. - * @param month The month as an integer between 0 and 11 (January to December). - * @param date The date as an integer between 1 and 31. - * @param hours Must be supplied if minutes is supplied. An integer from 0 to 23 (midnight to 11pm) that specifies the hour. - * @param minutes Must be supplied if seconds is supplied. An integer from 0 to 59 that specifies the minutes. - * @param seconds Must be supplied if milliseconds is supplied. An integer from 0 to 59 that specifies the seconds. - * @param ms An integer from 0 to 999 that specifies the milliseconds. - */ - UTC(year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): number; - now(): number; -} - -interface RegExpExecArray { - [index: number]: string; - length: number; - - index: number; - input: string; - - toString(): string; - toLocaleString(): string; - concat(...items: string[][]): string[]; - join(separator?: string): string; - pop(): string; - push(...items: string[]): number; - reverse(): string[]; - shift(): string; - slice(start: number, end?: number): string[]; - sort(compareFn?: (a: string, b: string) => number): string[]; - splice(start: number): string[]; - splice(start: number, deleteCount: number, ...items: string[]): string[]; - unshift(...items: string[]): number; - - indexOf(searchElement: string, fromIndex?: number): number; - lastIndexOf(searchElement: string, fromIndex?: number): number; - every(callbackfn: (value: string, index: number, array: string[]) => boolean, thisArg?: any): boolean; - some(callbackfn: (value: string, index: number, array: string[]) => boolean, thisArg?: any): boolean; - forEach(callbackfn: (value: string, index: number, array: string[]) => void , thisArg?: any): void; - map(callbackfn: (value: string, index: number, array: string[]) => any, thisArg?: any): any[]; - filter(callbackfn: (value: string, index: number, array: string[]) => boolean, thisArg?: any): string[]; - reduce(callbackfn: (previousValue: any, currentValue: any, currentIndex: number, array: string[]) => any, initialValue?: any): any; - reduceRight(callbackfn: (previousValue: any, currentValue: any, currentIndex: number, array: string[]) => any, initialValue?: any): any; -} - - -interface RegExp { - /** - * Executes a search on a string using a regular expression pattern, and returns an array containing the results of that search. - * @param string The String object or string literal on which to perform the search. - */ - exec(string: string): RegExpExecArray; - /** - * Returns a Boolean value that indicates whether or not a pattern exists in a searched string. - * @param string String on which to perform the search. - */ - test(string: string): boolean; - /** Returns a copy of the text of the regular expression pattern. Read-only. The rgExp argument is a Regular expression object. It can be a variable name or a literal. */ - source: string; - /** Returns a Boolean value indicating the state of the global flag (g) used with a regular expression. Default is false. Read-only. */ - global: boolean; - /** Returns a Boolean value indicating the state of the ignoreCase flag (i) used with a regular expression. Default is false. Read-only. */ - ignoreCase: boolean; - /** Returns a Boolean value indicating the state of the multiline flag (m) used with a regular expression. Default is false. Read-only. */ - multiline: boolean; - - lastIndex: number; - - // Non-standard extensions - compile(): RegExp; -} -declare var RegExp: { - new (pattern: string, flags?: string): RegExp; - (pattern: string, flags?: string): RegExp; - - // Non-standard extensions - $1: string; - $2: string; - $3: string; - $4: string; - $5: string; - $6: string; - $7: string; - $8: string; - $9: string; - lastMatch: string; -} - -interface Error { - name: string; - message: string; -} -declare var Error: { - new (message?: string): Error; - (message?: string): Error; - prototype: Error; -} - -interface EvalError extends Error { -} -declare var EvalError: { - new (message?: string): EvalError; - (message?: string): EvalError; - prototype: EvalError; -} - -interface RangeError extends Error { -} -declare var RangeError: { - new (message?: string): RangeError; - (message?: string): RangeError; - prototype: RangeError; -} - -interface ReferenceError extends Error { -} -declare var ReferenceError: { - new (message?: string): ReferenceError; - (message?: string): ReferenceError; - prototype: ReferenceError; -} - -interface SyntaxError extends Error { -} -declare var SyntaxError: { - new (message?: string): SyntaxError; - (message?: string): SyntaxError; - prototype: SyntaxError; -} - -interface TypeError extends Error { -} -declare var TypeError: { - new (message?: string): TypeError; - (message?: string): TypeError; - prototype: TypeError; -} - -interface URIError extends Error { -} -declare var URIError: { - new (message?: string): URIError; - (message?: string): URIError; - prototype: URIError; -} - -interface JSON { - /** - * Converts a JavaScript Object Notation (JSON) string into an object. - * @param text A valid JSON string. - * @param reviver A function that transforms the results. This function is called for each member of the object. - * If a member contains nested objects, the nested objects are transformed before the parent object is. - */ - parse(text: string, reviver?: (key: any, value: any) => any): any; - /** - * Converts a JavaScript value to a JavaScript Object Notation (JSON) string. - * @param value A JavaScript value, usually an object or array, to be converted. - */ - stringify(value: any): string; - /** - * Converts a JavaScript value to a JavaScript Object Notation (JSON) string. - * @param value A JavaScript value, usually an object or array, to be converted. - * @param replacer A function that transforms the results. - */ - stringify(value: any, replacer: (key: string, value: any) => any): string; - /** - * Converts a JavaScript value to a JavaScript Object Notation (JSON) string. - * @param value A JavaScript value, usually an object or array, to be converted. - * @param replacer Array that transforms the results. - */ - stringify(value: any, replacer: any[]): string; - /** - * Converts a JavaScript value to a JavaScript Object Notation (JSON) string. - * @param value A JavaScript value, usually an object or array, to be converted. - * @param replacer A function that transforms the results. - * @param space Adds indentation, white space, and line break characters to the return-value JSON text to make it easier to read. - */ - stringify(value: any, replacer: (key: string, value: any) => any, space: any): string; - /** - * Converts a JavaScript value to a JavaScript Object Notation (JSON) string. - * @param value A JavaScript value, usually an object or array, to be converted. - * @param replacer Array that transforms the results. - * @param space Adds indentation, white space, and line break characters to the return-value JSON text to make it easier to read. - */ - stringify(value: any, replacer: any[], space: any): string; -} -/** - * An intrinsic object that provides functions to convert JavaScript values to and from the JavaScript Object Notation (JSON) format. - */ -declare var JSON: JSON; - -//////////////// -/// ECMAScript Array API (specially handled by compiler) -//////////////// - -interface Array { - toString(): string; - toLocaleString(): string; - concat(...items: U[]): T[]; - concat(...items: T[]): T[]; - join(separator?: string): string; - pop(): T; - push(...items: T[]): number; - reverse(): T[]; - shift(): T; - slice(start: number, end?: number): T[]; - sort(compareFn?: (a: T, b: T) => number): T[]; - splice(start: number): T[]; - splice(start: number, deleteCount: number, ...items: T[]): T[]; - unshift(...items: T[]): number; - - indexOf(searchElement: T, fromIndex?: number): number; - lastIndexOf(searchElement: T, fromIndex?: number): number; - every(callbackfn: (value: T, index: number, array: T[]) => boolean, thisArg?: any): boolean; - some(callbackfn: (value: T, index: number, array: T[]) => boolean, thisArg?: any): boolean; - forEach(callbackfn: (value: T, index: number, array: T[]) => void , thisArg?: any): void; - map(callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): U[]; - filter(callbackfn: (value: T, index: number, array: T[]) => boolean, thisArg?: any): T[]; - reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T, initialValue?: T): T; - reduce(callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: T[]) => U, initialValue: U): U; - reduceRight(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T, initialValue?: T): T; - reduceRight(callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: T[]) => U, initialValue: U): U; - - length: number; - -} -declare var Array: { - new (arrayLength: number): T[]; - new (...items: T[]): T[]; - (arrayLength: number): T[]; - (...items: T[]): T[]; - isArray(arg: any): boolean; - prototype: Array; -} - - -//////////////// -/// IE10 ECMAScript Extensions -//////////////// - -interface ArrayBuffer { - byteLength: number; -} -declare var ArrayBuffer: { - prototype: ArrayBuffer; - new (byteLength: number); -} - -interface ArrayBufferView { - buffer: ArrayBuffer; - byteOffset: number; - byteLength: number; -} - -interface Int8Array extends ArrayBufferView { - BYTES_PER_ELEMENT: number; - length: number; - [index: number]: number; - get(index: number): number; - set(index: number, value: number): void; - set(array: Int8Array, offset?: number): void; - set(array: number[], offset?: number): void; - subarray(begin: number, end?: number): Int8Array; -} -declare var Int8Array: { - prototype: Int8Array; - new (length: number): Int8Array; - new (array: Int8Array): Int8Array; - new (array: number[]): Int8Array; - new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Int8Array; - BYTES_PER_ELEMENT: number; -} - -interface Uint8Array extends ArrayBufferView { - BYTES_PER_ELEMENT: number; - length: number; - [index: number]: number; - get(index: number): number; - set(index: number, value: number): void; - set(array: Uint8Array, offset?: number): void; - set(array: number[], offset?: number): void; - subarray(begin: number, end?: number): Uint8Array; -} -declare var Uint8Array: { - prototype: Uint8Array; - new (length: number): Uint8Array; - new (array: Uint8Array): Uint8Array; - new (array: number[]): Uint8Array; - new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint8Array; - BYTES_PER_ELEMENT: number; -} - -interface Int16Array extends ArrayBufferView { - BYTES_PER_ELEMENT: number; - length: number; - [index: number]: number; - get(index: number): number; - set(index: number, value: number): void; - set(array: Int16Array, offset?: number): void; - set(array: number[], offset?: number): void; - subarray(begin: number, end?: number): Int16Array; -} -declare var Int16Array: { - prototype: Int16Array; - new (length: number): Int16Array; - new (array: Int16Array): Int16Array; - new (array: number[]): Int16Array; - new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Int16Array; - BYTES_PER_ELEMENT: number; -} - -interface Uint16Array extends ArrayBufferView { - BYTES_PER_ELEMENT: number; - length: number; - [index: number]: number; - get(index: number): number; - set(index: number, value: number): void; - set(array: Uint16Array, offset?: number): void; - set(array: number[], offset?: number): void; - subarray(begin: number, end?: number): Uint16Array; -} -declare var Uint16Array: { - prototype: Uint16Array; - new (length: number): Uint16Array; - new (array: Uint16Array): Uint16Array; - new (array: number[]): Uint16Array; - new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint16Array; - BYTES_PER_ELEMENT: number; -} - -interface Int32Array extends ArrayBufferView { - BYTES_PER_ELEMENT: number; - length: number; - [index: number]: number; - get(index: number): number; - set(index: number, value: number): void; - set(array: Int32Array, offset?: number): void; - set(array: number[], offset?: number): void; - subarray(begin: number, end?: number): Int32Array; -} -declare var Int32Array: { - prototype: Int32Array; - new (length: number): Int32Array; - new (array: Int32Array): Int32Array; - new (array: number[]): Int32Array; - new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Int32Array; - BYTES_PER_ELEMENT: number; -} - -interface Uint32Array extends ArrayBufferView { - BYTES_PER_ELEMENT: number; - length: number; - [index: number]: number; - get(index: number): number; - set(index: number, value: number): void; - set(array: Uint32Array, offset?: number): void; - set(array: number[], offset?: number): void; - subarray(begin: number, end?: number): Uint32Array; -} -declare var Uint32Array: { - prototype: Uint32Array; - new (length: number): Uint32Array; - new (array: Uint32Array): Uint32Array; - new (array: number[]): Uint32Array; - new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint32Array; - BYTES_PER_ELEMENT: number; -} - -interface Float32Array extends ArrayBufferView { - BYTES_PER_ELEMENT: number; - length: number; - [index: number]: number; - get(index: number): number; - set(index: number, value: number): void; - set(array: Float32Array, offset?: number): void; - set(array: number[], offset?: number): void; - subarray(begin: number, end?: number): Float32Array; -} -declare var Float32Array: { - prototype: Float32Array; - new (length: number): Float32Array; - new (array: Float32Array): Float32Array; - new (array: number[]): Float32Array; - new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Float32Array; - BYTES_PER_ELEMENT: number; -} - -interface Float64Array extends ArrayBufferView { - BYTES_PER_ELEMENT: number; - length: number; - [index: number]: number; - get(index: number): number; - set(index: number, value: number): void; - set(array: Float64Array, offset?: number): void; - set(array: number[], offset?: number): void; - subarray(begin: number, end?: number): Float64Array; -} -declare var Float64Array: { - prototype: Float64Array; - new (length: number): Float64Array; - new (array: Float64Array): Float64Array; - new (array: number[]): Float64Array; - new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Float64Array; - BYTES_PER_ELEMENT: number; -} - -interface DataView extends ArrayBufferView { - getInt8(byteOffset: number): number; - getUint8(byteOffset: number): number; - getInt16(byteOffset: number, littleEndian?: boolean): number; - getUint16(byteOffset: number, littleEndian?: boolean): number; - getInt32(byteOffset: number, littleEndian?: boolean): number; - getUint32(byteOffset: number, littleEndian?: boolean): number; - getFloat32(byteOffset: number, littleEndian?: boolean): number; - getFloat64(byteOffset: number, littleEndian?: boolean): number; - - setInt8(byteOffset: number, value: number): void; - setUint8(byteOffset: number, value: number): void; - setInt16(byteOffset: number, value: number, littleEndian?: boolean): void; - setUint16(byteOffset: number, value: number, littleEndian?: boolean): void; - setInt32(byteOffset: number, value: number, littleEndian?: boolean): void; - setUint32(byteOffset: number, value: number, littleEndian?: boolean): void; - setFloat32(byteOffset: number, value: number, littleEndian?: boolean): void; - setFloat64(byteOffset: number, value: number, littleEndian?: boolean): void; -} -declare var DataView: { - prototype: DataView; - new (buffer: ArrayBuffer, byteOffset?: number, length?: number): DataView; -} - -//////////////// -/// IE9 DOM APIs (note that -//////////////// - -interface NavigatorID { - appVersion: string; - appName: string; - userAgent: string; - platform: string; -} - -interface HTMLTableElement extends HTMLElement, DOML2DeprecatedBorderStyle_HTMLTableElement, DOML2DeprecatedAlignmentStyle_HTMLTableElement, MSBorderColorStyle, MSDataBindingExtensions, MSHTMLTableElementExtensions, DOML2DeprecatedBackgroundStyle, MSBorderColorHighlightStyle, MSDataBindingTableExtensions, DOML2DeprecatedBackgroundColorStyle { - tBodies: HTMLCollection; - width: string; - tHead: HTMLTableSectionElement; - cellSpacing: string; - tFoot: HTMLTableSectionElement; - frame: string; - rows: HTMLCollection; - rules: string; - cellPadding: string; - summary: string; - caption: HTMLTableCaptionElement; - deleteRow(index?: number): void; - createTBody(): HTMLElement; - deleteCaption(): void; - insertRow(index?: number): HTMLElement; - deleteTFoot(): void; - createTHead(): HTMLElement; - deleteTHead(): void; - createCaption(): HTMLElement; - createTFoot(): HTMLElement; -} -declare var HTMLTableElement: { - prototype: HTMLTableElement; - new(): HTMLTableElement; -} - -interface TreeWalker { - whatToShow: number; - filter: NodeFilterCallback; - root: Node; - currentNode: Node; - expandEntityReferences: boolean; - previousSibling(): Node; - lastChild(): Node; - nextSibling(): Node; - nextNode(): Node; - parentNode(): Node; - firstChild(): Node; - previousNode(): Node; -} -declare var TreeWalker: { - prototype: TreeWalker; - new(): TreeWalker; -} - -interface GetSVGDocument { - getSVGDocument(): SVGDocument; -} - -interface HTMLHtmlElementDOML2Deprecated { - version: string; -} - -interface SVGPathSegCurvetoQuadraticRel extends SVGPathSeg { - y: number; - y1: number; - x: number; - x1: number; -} -declare var SVGPathSegCurvetoQuadraticRel: { - prototype: SVGPathSegCurvetoQuadraticRel; - new(): SVGPathSegCurvetoQuadraticRel; -} - -interface Performance { - navigation: PerformanceNavigation; - timing: PerformanceTiming; - toJSON(): any; -} -declare var Performance: { - prototype: Performance; - new(): Performance; -} - -interface SVGSVGElementEventHandlers { - onresize: (ev: UIEvent) => any; - addEventListener(type: "resize", listener: (ev: UIEvent) => void, useCapture?: boolean): void; - onunload: (ev: Event) => any; - addEventListener(type: "unload", listener: (ev: Event) => any, useCapture?: boolean): void; - onscroll: (ev: UIEvent) => any; - addEventListener(type: "scroll", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - onerror: (ev: Event) => any; - addEventListener(type: "error", listener: (ev: Event) => any, useCapture?: boolean): void; - onzoom: (ev: any) => any; - addEventListener(type: "zoom", listener: (ev: any) => any, useCapture?: boolean): void; - onabort: (ev: UIEvent) => any; - addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; -} - -interface MSDataBindingTableExtensions { - dataPageSize: number; - nextPage(): void; - firstPage(): void; - refresh(): void; - previousPage(): void; - lastPage(): void; -} - -interface DOML2DeprecatedAlignmentStyle_HTMLParagraphElement { - align: string; -} - -interface CompositionEvent extends UIEvent { - data: string; - locale: string; - initCompositionEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: AbstractView, dataArg: string, locale: string): void; -} -declare var CompositionEvent: { - prototype: CompositionEvent; - new(): CompositionEvent; -} - -interface SVGMarkerElement extends SVGElement, SVGStylable, SVGLangSpace, SVGFitToViewBox { - orientType: SVGAnimatedEnumeration; - markerUnits: SVGAnimatedEnumeration; - markerWidth: SVGAnimatedLength; - markerHeight: SVGAnimatedLength; - orientAngle: SVGAnimatedAngle; - refY: SVGAnimatedLength; - refX: SVGAnimatedLength; - setOrientToAngle(angle: SVGAngle): void; - setOrientToAuto(): void; - SVG_MARKER_ORIENT_UNKNOWN: number; - SVG_MARKER_ORIENT_ANGLE: number; - SVG_MARKERUNITS_UNKNOWN: number; - SVG_MARKERUNITS_STROKEWIDTH: number; - SVG_MARKER_ORIENT_AUTO: number; - SVG_MARKERUNITS_USERSPACEONUSE: number; -} -declare var SVGMarkerElement: { - prototype: SVGMarkerElement; - new(): SVGMarkerElement; - SVG_MARKER_ORIENT_UNKNOWN: number; - SVG_MARKER_ORIENT_ANGLE: number; - SVG_MARKERUNITS_UNKNOWN: number; - SVG_MARKERUNITS_STROKEWIDTH: number; - SVG_MARKER_ORIENT_AUTO: number; - SVG_MARKERUNITS_USERSPACEONUSE: number; -} - -interface WindowTimers { - clearTimeout(handle: number): void; - setTimeout(expression: any, msec?: number, language?: any): number; - clearInterval(handle: number): void; - setInterval(expression: any, msec?: number, language?: any): number; -} - -interface CSSStyleDeclaration extends CSS3Properties, SVG1_1Properties, CSS2Properties { - cssText: string; - length: number; - parentRule: CSSRule; - getPropertyPriority(propertyName: string): string; - getPropertyValue(propertyName: string): string; - removeProperty(propertyName: string): string; - item(index: number): string; - [index: number]: string; - setProperty(propertyName: string, value: string, priority?: string): void; -} -declare var CSSStyleDeclaration: { - prototype: CSSStyleDeclaration; - new(): CSSStyleDeclaration; -} - -interface SVGGElement extends SVGElement, SVGStylable, SVGTransformable, SVGLangSpace, SVGTests { -} -declare var SVGGElement: { - prototype: SVGGElement; - new(): SVGGElement; -} - -interface MSStyleCSSProperties extends MSCSSProperties { - pixelWidth: number; - posHeight: number; - posLeft: number; - pixelTop: number; - pixelBottom: number; - textDecorationNone: boolean; - pixelLeft: number; - posTop: number; - posBottom: number; - textDecorationOverline: boolean; - posWidth: number; - textDecorationLineThrough: boolean; - pixelHeight: number; - textDecorationBlink: boolean; - posRight: number; - pixelRight: number; - textDecorationUnderline: boolean; -} -declare var MSStyleCSSProperties: { - prototype: MSStyleCSSProperties; - new(): MSStyleCSSProperties; -} - -interface MSCSSStyleSheetExtensions { - owningElement: Element; - imports: StyleSheetList; - isAlternate: boolean; - rules: MSCSSRuleList; - isPrefAlternate: boolean; - readOnly: boolean; - cssText: string; - href: string; - id: string; - pages: StyleSheetPageList; - addImport(bstrURL: string, lIndex?: number): number; - addPageRule(bstrSelector: string, bstrStyle: string, lIndex?: number): number; - removeRule(lIndex: number): void; - addRule(bstrSelector: string, bstrStyle?: string, lIndex?: number): number; - removeImport(lIndex: number): void; -} - -interface Navigator extends NavigatorID, NavigatorOnLine, NavigatorDoNotTrack, NavigatorAbilities, NavigatorGeolocation, MSNavigatorAbilities { -} -declare var Navigator: { - prototype: Navigator; - new(): Navigator; -} - -interface SVGPathSegCurvetoCubicSmoothAbs extends SVGPathSeg { - y: number; - x2: number; - x: number; - y2: number; -} -declare var SVGPathSegCurvetoCubicSmoothAbs: { - prototype: SVGPathSegCurvetoCubicSmoothAbs; - new(): SVGPathSegCurvetoCubicSmoothAbs; -} - -interface MSBorderColorStyle_HTMLFrameSetElement { - borderColor: any; -} - -interface SVGZoomEvent extends UIEvent { - zoomRectScreen: SVGRect; - previousScale: number; - newScale: number; - previousTranslate: SVGPoint; - newTranslate: SVGPoint; -} -declare var SVGZoomEvent: { - prototype: SVGZoomEvent; - new(): SVGZoomEvent; -} - -interface NodeSelector { - querySelectorAll(selectors: string): NodeList; - querySelector(selectors: string): Element; -} - -interface HTMLTableDataCellElement extends HTMLTableCellElement, MSHTMLTableDataCellElementExtensions { -} -declare var HTMLTableDataCellElement: { - prototype: HTMLTableDataCellElement; - new(): HTMLTableDataCellElement; -} - -interface MSHTMLDirectoryElementExtensions extends DOML2DeprecatedListNumberingAndBulletStyle { -} - -interface HTMLBaseElement extends HTMLElement { - target: string; - href: string; -} -declare var HTMLBaseElement: { - prototype: HTMLBaseElement; - new(): HTMLBaseElement; -} - -interface ClientRect { - left: number; - width: number; - right: number; - top: number; - bottom: number; - height: number; -} -declare var ClientRect: { - prototype: ClientRect; - new(): ClientRect; -} - -interface PositionErrorCallback { - (error: PositionError): void; -} - -interface DOMImplementation extends DOMHTMLImplementation { - createDocumentType(qualifiedName: string, publicId: string, systemId: string): DocumentType; - createDocument(namespaceURI: string, qualifiedName: string, doctype: DocumentType): Document; - hasFeature(feature: string, version?: string): boolean; -} -declare var DOMImplementation: { - prototype: DOMImplementation; - new(): DOMImplementation; -} - -interface DOML2DeprecatedWidthStyle_HTMLBlockElement { - width: number; -} - -interface SVGUnitTypes { - SVG_UNIT_TYPE_UNKNOWN: number; - SVG_UNIT_TYPE_OBJECTBOUNDINGBOX: number; - SVG_UNIT_TYPE_USERSPACEONUSE: number; -} -declare var SVGUnitTypes: { - prototype: SVGUnitTypes; - new(): SVGUnitTypes; - SVG_UNIT_TYPE_UNKNOWN: number; - SVG_UNIT_TYPE_OBJECTBOUNDINGBOX: number; - SVG_UNIT_TYPE_USERSPACEONUSE: number; -} - -interface DocumentRange { - createRange(): Range; -} - -interface MSHTMLDocumentExtensions { - onrowexit: (ev: MSEventObj) => any; - addEventListener(type: "rowexit", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - compatible: MSCompatibleInfoCollection; - oncontrolselect: (ev: MSEventObj) => any; - addEventListener(type: "controlselect", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - onrowsinserted: (ev: MSEventObj) => any; - addEventListener(type: "rowsinserted", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - onpropertychange: (ev: MSEventObj) => any; - addEventListener(type: "propertychange", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - media: string; - onafterupdate: (ev: MSEventObj) => any; - addEventListener(type: "afterupdate", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - onhelp: (ev: Event) => any; - addEventListener(type: "help", listener: (ev: Event) => any, useCapture?: boolean): void; - uniqueID: string; - onbeforeactivate: (ev: UIEvent) => any; - addEventListener(type: "beforeactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - onstoragecommit: (ev: StorageEvent) => any; - addEventListener(type: "storagecommit", listener: (ev: StorageEvent) => any, useCapture?: boolean): void; - onselectionchange: (ev: Event) => any; - addEventListener(type: "selectionchange", listener: (ev: Event) => any, useCapture?: boolean): void; - documentMode: number; - onfocusout: (ev: FocusEvent) => any; - addEventListener(type: "focusout", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; - ondataavailable: (ev: MSEventObj) => any; - addEventListener(type: "dataavailable", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - onbeforeupdate: (ev: MSEventObj) => any; - addEventListener(type: "beforeupdate", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - onfocusin: (ev: FocusEvent) => any; - addEventListener(type: "focusin", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; - security: string; - namespaces: MSNamespaceInfoCollection; - ondatasetcomplete: (ev: MSEventObj) => any; - addEventListener(type: "datasetcomplete", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - onbeforedeactivate: (ev: UIEvent) => any; - addEventListener(type: "beforedeactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - onstop: (ev: Event) => any; - addEventListener(type: "stop", listener: (ev: Event) => any, useCapture?: boolean): void; - onactivate: (ev: UIEvent) => any; - addEventListener(type: "activate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - onmssitemodejumplistitemremoved: (ev: MSSiteModeEvent) => any; - addEventListener(type: "mssitemodejumplistitemremoved", listener: (ev: MSSiteModeEvent) => any, useCapture?: boolean): void; - frames: Window; - onselectstart: (ev: Event) => any; - addEventListener(type: "selectstart", listener: (ev: Event) => any, useCapture?: boolean): void; - onerrorupdate: (ev: MSEventObj) => any; - addEventListener(type: "errorupdate", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - parentWindow: Window; - ondeactivate: (ev: UIEvent) => any; - addEventListener(type: "deactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - ondatasetchanged: (ev: MSEventObj) => any; - addEventListener(type: "datasetchanged", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - onrowsdelete: (ev: MSEventObj) => any; - addEventListener(type: "rowsdelete", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - onmsthumbnailclick: (ev: MSSiteModeEvent) => any; - addEventListener(type: "msthumbnailclick", listener: (ev: MSSiteModeEvent) => any, useCapture?: boolean): void; - onrowenter: (ev: MSEventObj) => any; - addEventListener(type: "rowenter", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - onbeforeeditfocus: (ev: MSEventObj) => any; - addEventListener(type: "beforeeditfocus", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - Script: MSScriptHost; - oncellchange: (ev: MSEventObj) => any; - addEventListener(type: "cellchange", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - URLUnencoded: string; - updateSettings(): void; - execCommandShowHelp(commandId: string): boolean; - releaseCapture(): void; - focus(): void; - addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; -} - -interface CSS2Properties { - backgroundAttachment: string; - visibility: string; - fontFamily: string; - borderRightStyle: string; - clear: string; - content: string; - counterIncrement: string; - orphans: string; - marginBottom: string; - borderStyle: string; - counterReset: string; - outlineWidth: string; - marginRight: string; - paddingLeft: string; - borderBottom: string; - marginTop: string; - borderTopColor: string; - top: string; - fontWeight: string; - textIndent: string; - borderRight: string; - width: string; - listStyleImage: string; - cursor: string; - listStylePosition: string; - borderTopStyle: string; - direction: string; - maxWidth: string; - color: string; - clip: string; - borderRightWidth: string; - verticalAlign: string; - pageBreakAfter: string; - overflow: string; - borderBottomStyle: string; - borderLeftStyle: string; - fontStretch: string; - emptyCells: string; - padding: string; - paddingRight: string; - background: string; - bottom: string; - height: string; - paddingTop: string; - right: string; - borderLeftWidth: string; - borderLeft: string; - backgroundPosition: string; - backgroundColor: string; - widows: string; - lineHeight: string; - pageBreakInside: string; - borderTopWidth: string; - left: string; - outlineStyle: string; - borderTop: string; - paddingBottom: string; - outlineColor: string; - wordSpacing: string; - outline: string; - font: string; - marginLeft: string; - display: string; - maxHeight: string; - cssFloat: string; - letterSpacing: string; - borderSpacing: string; - backgroundRepeat: string; - fontSizeAdjust: string; - borderLeftColor: string; - borderWidth: string; - backgroundImage: string; - listStyleType: string; - whiteSpace: string; - fontStyle: string; - borderBottomColor: string; - minWidth: string; - position: string; - zIndex: string; - borderColor: string; - listStyle: string; - captionSide: string; - borderCollapse: string; - fontVariant: string; - quotes: string; - tableLayout: string; - unicodeBidi: string; - borderBottomWidth: string; - minHeight: string; - textDecoration: string; - fontSize: string; - border: string; - pageBreakBefore: string; - textAlign: string; - textTransform: string; - margin: string; - borderRightColor: string; -} - -interface MSImageResourceExtensions_HTMLInputElement { - dynsrc: string; - vrml: string; - lowsrc: string; - start: string; - loop: number; -} - -interface MSHTMLEmbedElementExtensions { - palette: string; - hidden: string; - pluginspage: string; - units: string; -} - -interface MSHTMLModElementExtensions { -} - -interface Element extends Node, NodeSelector, ElementTraversal, MSElementExtensions { - scrollTop: number; - clientLeft: number; - scrollLeft: number; - tagName: string; - clientWidth: number; - scrollWidth: number; - clientHeight: number; - clientTop: number; - scrollHeight: number; - getAttribute(name?: string): string; - getElementsByTagNameNS(namespaceURI: string, localName: string): NodeList; - hasAttributeNS(namespaceURI: string, localName: string): boolean; - getBoundingClientRect(): ClientRect; - getAttributeNS(namespaceURI: string, localName: string): string; - getAttributeNodeNS(namespaceURI: string, localName: string): Attr; - setAttributeNodeNS(newAttr: Attr): Attr; - hasAttribute(name: string): boolean; - removeAttribute(name?: string): void; - setAttributeNS(namespaceURI: string, qualifiedName: string, value: string): void; - getAttributeNode(name: string): Attr; - getElementsByTagName(name: string): NodeList; - getElementsByTagName(name: "a"): NodeListOf; - getElementsByTagName(name: "abbr"): NodeListOf; - getElementsByTagName(name: "address"): NodeListOf; - getElementsByTagName(name: "area"): NodeListOf; - getElementsByTagName(name: "article"): NodeListOf; - getElementsByTagName(name: "aside"): NodeListOf; - getElementsByTagName(name: "audio"): NodeListOf; - getElementsByTagName(name: "b"): NodeListOf; - getElementsByTagName(name: "base"): NodeListOf; - getElementsByTagName(name: "bdi"): NodeListOf; - getElementsByTagName(name: "bdo"): NodeListOf; - getElementsByTagName(name: "blockquote"): NodeListOf; - getElementsByTagName(name: "body"): NodeListOf; - getElementsByTagName(name: "br"): NodeListOf; - getElementsByTagName(name: "button"): NodeListOf; - getElementsByTagName(name: "canvas"): NodeListOf; - getElementsByTagName(name: "caption"): NodeListOf; - getElementsByTagName(name: "cite"): NodeListOf; - getElementsByTagName(name: "code"): NodeListOf; - getElementsByTagName(name: "col"): NodeListOf; - getElementsByTagName(name: "colgroup"): NodeListOf; - getElementsByTagName(name: "datalist"): NodeListOf; - getElementsByTagName(name: "dd"): NodeListOf; - getElementsByTagName(name: "del"): NodeListOf; - getElementsByTagName(name: "dfn"): NodeListOf; - getElementsByTagName(name: "div"): NodeListOf; - getElementsByTagName(name: "dl"): NodeListOf; - getElementsByTagName(name: "dt"): NodeListOf; - getElementsByTagName(name: "em"): NodeListOf; - getElementsByTagName(name: "embed"): NodeListOf; - getElementsByTagName(name: "fieldset"): NodeListOf; - getElementsByTagName(name: "figcaption"): NodeListOf; - getElementsByTagName(name: "figure"): NodeListOf; - getElementsByTagName(name: "footer"): NodeListOf; - getElementsByTagName(name: "form"): NodeListOf; - getElementsByTagName(name: "h1"): NodeListOf; - getElementsByTagName(name: "h2"): NodeListOf; - getElementsByTagName(name: "h3"): NodeListOf; - getElementsByTagName(name: "h4"): NodeListOf; - getElementsByTagName(name: "h5"): NodeListOf; - getElementsByTagName(name: "h6"): NodeListOf; - getElementsByTagName(name: "head"): NodeListOf; - getElementsByTagName(name: "header"): NodeListOf; - getElementsByTagName(name: "hgroup"): NodeListOf; - getElementsByTagName(name: "hr"): NodeListOf; - getElementsByTagName(name: "html"): NodeListOf; - getElementsByTagName(name: "i"): NodeListOf; - getElementsByTagName(name: "iframe"): NodeListOf; - getElementsByTagName(name: "img"): NodeListOf; - getElementsByTagName(name: "input"): NodeListOf; - getElementsByTagName(name: "ins"): NodeListOf; - getElementsByTagName(name: "kbd"): NodeListOf; - getElementsByTagName(name: "label"): NodeListOf; - getElementsByTagName(name: "legend"): NodeListOf; - getElementsByTagName(name: "li"): NodeListOf; - getElementsByTagName(name: "link"): NodeListOf; - getElementsByTagName(name: "main"): NodeListOf; - getElementsByTagName(name: "map"): NodeListOf; - getElementsByTagName(name: "mark"): NodeListOf; - getElementsByTagName(name: "menu"): NodeListOf; - getElementsByTagName(name: "meta"): NodeListOf; - getElementsByTagName(name: "nav"): NodeListOf; - getElementsByTagName(name: "noscript"): NodeListOf; - getElementsByTagName(name: "object"): NodeListOf; - getElementsByTagName(name: "ol"): NodeListOf; - getElementsByTagName(name: "optgroup"): NodeListOf; - getElementsByTagName(name: "option"): NodeListOf; - getElementsByTagName(name: "p"): NodeListOf; - getElementsByTagName(name: "param"): NodeListOf; - getElementsByTagName(name: "pre"): NodeListOf; - getElementsByTagName(name: "progress"): NodeListOf; - getElementsByTagName(name: "q"): NodeListOf; - getElementsByTagName(name: "rp"): NodeListOf; - getElementsByTagName(name: "rt"): NodeListOf; - getElementsByTagName(name: "ruby"): NodeListOf; - getElementsByTagName(name: "s"): NodeListOf; - getElementsByTagName(name: "samp"): NodeListOf; - getElementsByTagName(name: "script"): NodeListOf; - getElementsByTagName(name: "section"): NodeListOf; - getElementsByTagName(name: "select"): NodeListOf; - getElementsByTagName(name: "small"): NodeListOf; - getElementsByTagName(name: "source"): NodeListOf; - getElementsByTagName(name: "span"): NodeListOf; - getElementsByTagName(name: "strong"): NodeListOf; - getElementsByTagName(name: "style"): NodeListOf; - getElementsByTagName(name: "sub"): NodeListOf; - getElementsByTagName(name: "summary"): NodeListOf; - getElementsByTagName(name: "sup"): NodeListOf; - getElementsByTagName(name: "table"): NodeListOf; - getElementsByTagName(name: "tbody"): NodeListOf; - getElementsByTagName(name: "td"): NodeListOf; - getElementsByTagName(name: "textarea"): NodeListOf; - getElementsByTagName(name: "tfoot"): NodeListOf; - getElementsByTagName(name: "th"): NodeListOf; - getElementsByTagName(name: "thead"): NodeListOf; - getElementsByTagName(name: "title"): NodeListOf; - getElementsByTagName(name: "tr"): NodeListOf; - getElementsByTagName(name: "track"): NodeListOf; - getElementsByTagName(name: "u"): NodeListOf; - getElementsByTagName(name: "ul"): NodeListOf; - getElementsByTagName(name: "var"): NodeListOf; - getElementsByTagName(name: "video"): NodeListOf; - getElementsByTagName(name: "wbr"): NodeListOf; - setAttributeNode(newAttr: Attr): Attr; - getClientRects(): ClientRectList; - removeAttributeNode(oldAttr: Attr): Attr; - setAttribute(name?: string, value?: string): void; - removeAttributeNS(namespaceURI: string, localName: string): void; -} -declare var Element: { - prototype: Element; - new(): Element; -} - -interface SVGDocument { - rootElement: SVGSVGElement; -} - -interface HTMLNextIdElement extends HTMLElement { - n: string; -} -declare var HTMLNextIdElement: { - prototype: HTMLNextIdElement; - new(): HTMLNextIdElement; -} - -interface SVGPathSegMovetoRel extends SVGPathSeg { - y: number; - x: number; -} -declare var SVGPathSegMovetoRel: { - prototype: SVGPathSegMovetoRel; - new(): SVGPathSegMovetoRel; -} - -interface SVGLineElement extends SVGElement, SVGStylable, SVGTransformable, SVGLangSpace, SVGTests { - y1: SVGAnimatedLength; - x2: SVGAnimatedLength; - x1: SVGAnimatedLength; - y2: SVGAnimatedLength; -} -declare var SVGLineElement: { - prototype: SVGLineElement; - new(): SVGLineElement; -} - -interface HTMLParagraphElement extends HTMLElement, DOML2DeprecatedAlignmentStyle_HTMLParagraphElement, MSHTMLParagraphElementExtensions { -} -declare var HTMLParagraphElement: { - prototype: HTMLParagraphElement; - new(): HTMLParagraphElement; -} - -interface MSHTMLTextAreaElementExtensions { - status: any; - createTextRange(): TextRange; -} - -interface ErrorFunction { - (eventOrMessage: any, source: string, fileno: number): any; -} - -interface HTMLAreasCollection extends HTMLCollection { - remove(index?: number): void; - add(element: HTMLElement, before?: any): void; -} -declare var HTMLAreasCollection: { - prototype: HTMLAreasCollection; - new(): HTMLAreasCollection; -} - -interface SVGDescElement extends SVGElement, SVGStylable, SVGLangSpace { -} -declare var SVGDescElement: { - prototype: SVGDescElement; - new(): SVGDescElement; -} - -interface Node extends EventTarget { - nodeType: number; - previousSibling: Node; - localName: string; - namespaceURI: string; - textContent: string; - parentNode: Node; - nextSibling: Node; - nodeValue: string; - lastChild: Node; - childNodes: NodeList; - nodeName: string; - ownerDocument: Document; - attributes: Attr[]; - firstChild: Node; - prefix: string; - removeChild(oldChild: Node): Node; - appendChild(newChild: Node): Node; - isSupported(feature: string, version: string): boolean; - isEqualNode(arg: Node): boolean; - lookupPrefix(namespaceURI: string): string; - isDefaultNamespace(namespaceURI: string): boolean; - compareDocumentPosition(other: Node): number; - normalize(): void; - isSameNode(other: Node): boolean; - hasAttributes(): boolean; - lookupNamespaceURI(prefix: string): string; - cloneNode(deep?: boolean): Node; - hasChildNodes(): boolean; - replaceChild(newChild: Node, oldChild: Node): Node; - insertBefore(newChild: Node, refChild?: Node): Node; - ENTITY_REFERENCE_NODE: number; - ATTRIBUTE_NODE: number; - DOCUMENT_FRAGMENT_NODE: number; - TEXT_NODE: number; - ELEMENT_NODE: number; - COMMENT_NODE: number; - DOCUMENT_POSITION_DISCONNECTED: number; - DOCUMENT_POSITION_CONTAINED_BY: number; - DOCUMENT_POSITION_CONTAINS: number; - DOCUMENT_TYPE_NODE: number; - DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC: number; - DOCUMENT_NODE: number; - ENTITY_NODE: number; - PROCESSING_INSTRUCTION_NODE: number; - CDATA_SECTION_NODE: number; - NOTATION_NODE: number; - DOCUMENT_POSITION_FOLLOWING: number; - DOCUMENT_POSITION_PRECEDING: number; -} -declare var Node: { - prototype: Node; - new(): Node; - ENTITY_REFERENCE_NODE: number; - ATTRIBUTE_NODE: number; - DOCUMENT_FRAGMENT_NODE: number; - TEXT_NODE: number; - ELEMENT_NODE: number; - COMMENT_NODE: number; - DOCUMENT_POSITION_DISCONNECTED: number; - DOCUMENT_POSITION_CONTAINED_BY: number; - DOCUMENT_POSITION_CONTAINS: number; - DOCUMENT_TYPE_NODE: number; - DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC: number; - DOCUMENT_NODE: number; - ENTITY_NODE: number; - PROCESSING_INSTRUCTION_NODE: number; - CDATA_SECTION_NODE: number; - NOTATION_NODE: number; - DOCUMENT_POSITION_FOLLOWING: number; - DOCUMENT_POSITION_PRECEDING: number; -} - -interface MSHTMLLegendElementExtensions { -} - -interface MSCSSStyleDeclarationExtensions { - getAttribute(attributeName: string, flags?: number): any; - setAttribute(attributeName: string, AttributeValue: any, flags?: number): void; - removeAttribute(attributeName: string, flags?: number): boolean; -} - -interface SVGPathSegCurvetoQuadraticSmoothRel extends SVGPathSeg { - y: number; - x: number; -} -declare var SVGPathSegCurvetoQuadraticSmoothRel: { - prototype: SVGPathSegCurvetoQuadraticSmoothRel; - new(): SVGPathSegCurvetoQuadraticSmoothRel; -} - -interface DOML2DeprecatedAlignmentStyle_HTMLTableRowElement { - align: string; -} - -interface DOML2DeprecatedBorderStyle_HTMLObjectElement { - border: string; -} - -interface MSHTMLSpanElementExtensions { -} - -interface MSHTMLObjectElementExtensions { - object: Object; - alt: string; - classid: string; - altHtml: string; - BaseHref: string; -} - -interface DOML2DeprecatedListSpaceReduction { - compact: boolean; -} - -interface CSS3Properties { - textAlignLast: string; - textUnderlinePosition: string; - wordWrap: string; - borderTopLeftRadius: string; - backgroundClip: string; - msTransformOrigin: string; - opacity: string; - overflowY: string; - boxShadow: string; - backgroundSize: string; - wordBreak: string; - boxSizing: string; - rubyOverhang: string; - rubyAlign: string; - textJustify: string; - borderRadius: string; - overflowX: string; - borderTopRightRadius: string; - msTransform: string; - borderBottomLeftRadius: string; - rubyPosition: string; - borderBottomRightRadius: string; - backgroundOrigin: string; - textOverflow: string; -} - -interface MSScriptHost { -} -declare var MSScriptHost: { - prototype: MSScriptHost; - new(): MSScriptHost; -} - -interface SVGClipPathElement extends SVGElement, SVGUnitTypes, SVGStylable, SVGTransformable, SVGLangSpace, SVGTests { - clipPathUnits: SVGAnimatedEnumeration; -} -declare var SVGClipPathElement: { - prototype: SVGClipPathElement; - new(): SVGClipPathElement; -} - -interface MouseEvent extends UIEvent, MSMouseEventExtensions { - pageX: number; - offsetY: number; - x: number; - y: number; - altKey: boolean; - metaKey: boolean; - ctrlKey: boolean; - offsetX: number; - screenX: number; - clientY: number; - shiftKey: boolean; - screenY: number; - relatedTarget: EventTarget; - button: number; - pageY: number; - buttons: number; - clientX: number; - initMouseEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: AbstractView, detailArg: number, screenXArg: number, screenYArg: number, clientXArg: number, clientYArg: number, ctrlKeyArg: boolean, altKeyArg: boolean, shiftKeyArg: boolean, metaKeyArg: boolean, buttonArg: number, relatedTargetArg: EventTarget): void; - getModifierState(keyArg: string): boolean; -} -declare var MouseEvent: { - prototype: MouseEvent; - new(): MouseEvent; -} - -interface DOML2DeprecatedAlignmentStyle_HTMLTableElement { - align: string; -} - -interface RangeException { - code: number; - message: string; - toString(): string; - INVALID_NODE_TYPE_ERR: number; - BAD_BOUNDARYPOINTS_ERR: number; -} -declare var RangeException: { - prototype: RangeException; - new(): RangeException; - INVALID_NODE_TYPE_ERR: number; - BAD_BOUNDARYPOINTS_ERR: number; -} - -interface DOML2DeprecatedAlignmentStyle_HTMLHRElement { - align: string; -} - -interface SVGTextPositioningElement extends SVGTextContentElement { - y: SVGAnimatedLengthList; - rotate: SVGAnimatedNumberList; - dy: SVGAnimatedLengthList; - x: SVGAnimatedLengthList; - dx: SVGAnimatedLengthList; -} -declare var SVGTextPositioningElement: { - prototype: SVGTextPositioningElement; - new(): SVGTextPositioningElement; -} - -interface HTMLAppletElement extends HTMLElement, DOML2DeprecatedWidthStyle_HTMLAppletElement, DOML2DeprecatedMarginStyle_HTMLObjectElement, MSHTMLAppletElementExtensions, MSDataBindingExtensions, MSDataBindingRecordSetExtensions, DOML2DeprecatedAlignmentStyle_HTMLObjectElement { - object: string; - archive: string; - codeBase: string; - alt: string; - name: string; - height: string; - code: string; -} -declare var HTMLAppletElement: { - prototype: HTMLAppletElement; - new(): HTMLAppletElement; -} - -interface MSHTMLFieldSetElementExtensions extends DOML2DeprecatedAlignmentStyle_HTMLFieldSetElement { -} - -interface DocumentEvent { - createEvent(eventInterface: string): Event; -} - -interface MSHTMLUnknownElementExtensions { -} - -interface TextMetrics { - width: number; -} -declare var TextMetrics: { - prototype: TextMetrics; - new(): TextMetrics; -} - -interface DOML2DeprecatedWordWrapSuppression_HTMLBodyElement { - noWrap: boolean; -} - -interface HTMLOListElement extends HTMLElement, DOML2DeprecatedListNumberingAndBulletStyle, DOML2DeprecatedListSpaceReduction, MSHTMLOListElementExtensions { - start: number; -} -declare var HTMLOListElement: { - prototype: HTMLOListElement; - new(): HTMLOListElement; -} - -interface MSHTMLTableCaptionElementExtensions { - vAlign: string; -} - -interface SVGAnimatedString { - animVal: string; - baseVal: string; -} -declare var SVGAnimatedString: { - prototype: SVGAnimatedString; - new(): SVGAnimatedString; -} - -interface SVGPathSegLinetoVerticalRel extends SVGPathSeg { - y: number; -} -declare var SVGPathSegLinetoVerticalRel: { - prototype: SVGPathSegLinetoVerticalRel; - new(): SVGPathSegLinetoVerticalRel; -} - -interface CDATASection extends Text { -} -declare var CDATASection: { - prototype: CDATASection; - new(): CDATASection; -} - -interface StyleMedia { - type: string; - matchMedium(mediaquery: string): boolean; -} -declare var StyleMedia: { - prototype: StyleMedia; - new(): StyleMedia; -} - -interface TextRange { - boundingLeft: number; - htmlText: string; - offsetLeft: number; - boundingWidth: number; - boundingHeight: number; - boundingTop: number; - text: string; - offsetTop: number; - moveToPoint(x: number, y: number): void; - queryCommandValue(cmdID: string): any; - getBookmark(): string; - move(Unit: string, Count?: number): number; - queryCommandIndeterm(cmdID: string): boolean; - scrollIntoView(fStart?: boolean): void; - findText(string: string, count?: number, flags?: number): boolean; - execCommand(cmdID: string, showUI?: boolean, value?: any): boolean; - getBoundingClientRect(): ClientRect; - moveToBookmark(Bookmark: string): boolean; - isEqual(range: TextRange): boolean; - duplicate(): TextRange; - collapse(Start?: boolean): void; - queryCommandText(cmdID: string): string; - select(): void; - pasteHTML(html: string): void; - inRange(range: TextRange): boolean; - moveEnd(Unit: string, Count?: number): number; - getClientRects(): ClientRectList; - moveStart(Unit: string, Count?: number): number; - parentElement(): Element; - queryCommandState(cmdID: string): boolean; - compareEndPoints(how: string, sourceRange: TextRange): number; - execCommandShowHelp(cmdID: string): boolean; - moveToElementText(element: Element): void; - expand(Unit: string): boolean; - queryCommandSupported(cmdID: string): boolean; - setEndPoint(how: string, SourceRange: TextRange): void; - queryCommandEnabled(cmdID: string): boolean; -} -declare var TextRange: { - prototype: TextRange; - new(): TextRange; -} - -interface HTMLSelectElement extends HTMLElement, MSHTMLCollectionExtensions, MSDataBindingExtensions, MSHTMLSelectElementExtensions { - options: HTMLSelectElement; - value: string; - form: HTMLFormElement; - name: string; - size: number; - length: number; - selectedIndex: number; - multiple: boolean; - type: string; - remove(index?: number): void; - add(element: HTMLElement, before?: any): void; - item(name?: any, index?: any): any; - (name: any, index: any): any; - namedItem(name: string): any; - [name: string]: any; - (name: string): any; -} -declare var HTMLSelectElement: { - prototype: HTMLSelectElement; - new(): HTMLSelectElement; -} - -interface CSSStyleSheet extends StyleSheet, MSCSSStyleSheetExtensions { - ownerRule: CSSRule; - cssRules: CSSRuleList; - insertRule(rule: string, index?: number): number; - deleteRule(index?: number): void; -} -declare var CSSStyleSheet: { - prototype: CSSStyleSheet; - new(): CSSStyleSheet; -} - -interface HTMLBlockElement extends HTMLElement, DOML2DeprecatedTextFlowControl_HTMLBlockElement, DOML2DeprecatedWidthStyle_HTMLBlockElement { - cite: string; -} -declare var HTMLBlockElement: { - prototype: HTMLBlockElement; - new(): HTMLBlockElement; -} - -interface SVGTests { - requiredFeatures: SVGStringList; - requiredExtensions: SVGStringList; - systemLanguage: SVGStringList; - hasExtension(extension: string): boolean; -} - -interface MSSelection { - type: string; - typeDetail: string; - createRange(): TextRange; - clear(): void; - createRangeCollection(): TextRangeCollection; - empty(): void; -} -declare var MSSelection: { - prototype: MSSelection; - new(): MSSelection; -} - -interface MSHTMLDListElementExtensions { -} - -interface HTMLMetaElement extends HTMLElement, MSHTMLMetaElementExtensions { - httpEquiv: string; - name: string; - content: string; - scheme: string; -} -declare var HTMLMetaElement: { - prototype: HTMLMetaElement; - new(): HTMLMetaElement; -} - -interface Selection { - isCollapsed: boolean; - anchorNode: Node; - focusNode: Node; - anchorOffset: number; - focusOffset: number; - rangeCount: number; - addRange(range: Range): void; - collapseToEnd(): void; - toString(): string; - selectAllChildren(parentNode: Node): void; - getRangeAt(index: number): Range; - collapse(parentNode: Node, offset: number): void; - removeAllRanges(): void; - collapseToStart(): void; - deleteFromDocument(): void; - removeRange(range: Range): void; -} -declare var Selection: { - prototype: Selection; - new(): Selection; -} - -interface SVGAnimatedAngle { - animVal: SVGAngle; - baseVal: SVGAngle; -} -declare var SVGAnimatedAngle: { - prototype: SVGAnimatedAngle; - new(): SVGAnimatedAngle; -} - -interface SVGPatternElement extends SVGElement, SVGUnitTypes, SVGStylable, SVGLangSpace, SVGTests, SVGFitToViewBox, SVGURIReference { - patternUnits: SVGAnimatedEnumeration; - y: SVGAnimatedLength; - width: SVGAnimatedLength; - x: SVGAnimatedLength; - patternContentUnits: SVGAnimatedEnumeration; - patternTransform: SVGAnimatedTransformList; - height: SVGAnimatedLength; -} -declare var SVGPatternElement: { - prototype: SVGPatternElement; - new(): SVGPatternElement; -} - -interface SVGScriptElement extends SVGElement, SVGURIReference { - type: string; -} -declare var SVGScriptElement: { - prototype: SVGScriptElement; - new(): SVGScriptElement; -} - -interface HTMLDDElement extends HTMLElement, DOML2DeprecatedWordWrapSuppression_HTMLDDElement { -} -declare var HTMLDDElement: { - prototype: HTMLDDElement; - new(): HTMLDDElement; -} - -interface NodeIterator { - whatToShow: number; - filter: NodeFilterCallback; - root: Node; - expandEntityReferences: boolean; - nextNode(): Node; - detach(): void; - previousNode(): Node; -} -declare var NodeIterator: { - prototype: NodeIterator; - new(): NodeIterator; -} - -interface CSSStyleRule extends CSSRule, MSCSSStyleRuleExtensions { - selectorText: string; - style: MSStyleCSSProperties; -} -declare var CSSStyleRule: { - prototype: CSSStyleRule; - new(): CSSStyleRule; -} - -interface MSDataBindingRecordSetReadonlyExtensions { - recordset: Object; - namedRecordset(dataMember: string, hierarchy?: any): Object; -} - -interface HTMLLinkElement extends HTMLElement, MSLinkStyleExtensions, LinkStyle { - rel: string; - target: string; - href: string; - media: string; - rev: string; - type: string; - charset: string; - hreflang: string; -} -declare var HTMLLinkElement: { - prototype: HTMLLinkElement; - new(): HTMLLinkElement; -} - -interface SVGViewElement extends SVGElement, SVGZoomAndPan, SVGFitToViewBox { - viewTarget: SVGStringList; -} -declare var SVGViewElement: { - prototype: SVGViewElement; - new(): SVGViewElement; -} - -interface MSHTMLAppletElementExtensions extends DOML2DeprecatedBorderStyle_HTMLObjectElement { - codeType: string; - standby: string; - classid: string; - useMap: string; - form: HTMLFormElement; - data: string; - contentDocument: Document; - altHtml: string; - declare: boolean; - type: string; - BaseHref: string; -} - -interface SVGLocatable { - farthestViewportElement: SVGElement; - nearestViewportElement: SVGElement; - getBBox(): SVGRect; - getTransformToElement(element: SVGElement): SVGMatrix; - getCTM(): SVGMatrix; - getScreenCTM(): SVGMatrix; -} - -interface HTMLFontElement extends HTMLElement, DOML2DeprecatedColorProperty, MSHTMLFontElementExtensions, DOML2DeprecatedSizeProperty { - face: string; -} -declare var HTMLFontElement: { - prototype: HTMLFontElement; - new(): HTMLFontElement; -} - -interface MSHTMLTableElementExtensions { - cells: HTMLCollection; - height: any; - cols: number; - moveRow(indexFrom?: number, indexTo?: number): Object; -} - -interface SVGTitleElement extends SVGElement, SVGStylable, SVGLangSpace { -} -declare var SVGTitleElement: { - prototype: SVGTitleElement; - new(): SVGTitleElement; -} - -interface ControlRangeCollection { - length: number; - queryCommandValue(cmdID: string): any; - remove(index: number): void; - add(item: Element): void; - queryCommandIndeterm(cmdID: string): boolean; - scrollIntoView(varargStart?: any): void; - item(index: number): Element; - [index: number]: Element; - execCommand(cmdID: string, showUI?: boolean, value?: any): boolean; - addElement(item: Element): void; - queryCommandState(cmdID: string): boolean; - queryCommandSupported(cmdID: string): boolean; - queryCommandEnabled(cmdID: string): boolean; - queryCommandText(cmdID: string): string; - select(): void; -} -declare var ControlRangeCollection: { - prototype: ControlRangeCollection; - new(): ControlRangeCollection; -} - -interface DOML2DeprecatedAlignmentStyle_HTMLImageElement { - align: string; -} - -interface MSHTMLFrameElementExtensions { - width: any; - contentWindow: Window; - onload: (ev: Event) => any; - addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; - frameBorder: string; - height: any; - border: string; - frameSpacing: any; - addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; -} - -interface MSNamespaceInfo extends MSEventAttachmentTarget { - urn: string; - onreadystatechange: (ev: Event) => any; - addEventListener(type: "readystatechange", listener: (ev: Event) => any, useCapture?: boolean): void; - name: string; - readyState: string; - doImport(implementationUrl: string): void; - addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; -} -declare var MSNamespaceInfo: { - prototype: MSNamespaceInfo; - new(): MSNamespaceInfo; -} - -interface WindowSessionStorage { - sessionStorage: Storage; -} - -interface SVGAnimatedTransformList { - animVal: SVGTransformList; - baseVal: SVGTransformList; -} -declare var SVGAnimatedTransformList: { - prototype: SVGAnimatedTransformList; - new(): SVGAnimatedTransformList; -} - -interface HTMLTableCaptionElement extends HTMLElement, MSHTMLTableCaptionElementExtensions, DOML2DeprecatedAlignmentStyle_HTMLTableCaptionElement { -} -declare var HTMLTableCaptionElement: { - prototype: HTMLTableCaptionElement; - new(): HTMLTableCaptionElement; -} - -interface HTMLOptionElement extends HTMLElement, MSDataBindingExtensions { - index: number; - defaultSelected: boolean; - value: string; - text: string; - form: HTMLFormElement; - label: string; - selected: boolean; -} -declare var HTMLOptionElement: { - prototype: HTMLOptionElement; - new(): HTMLOptionElement; -} - -interface HTMLMapElement extends HTMLElement { - name: string; - areas: HTMLAreasCollection; -} -declare var HTMLMapElement: { - prototype: HTMLMapElement; - new(): HTMLMapElement; -} - -interface HTMLMenuElement extends HTMLElement, DOML2DeprecatedListSpaceReduction, MSHTMLMenuElementExtensions { - type: string; -} -declare var HTMLMenuElement: { - prototype: HTMLMenuElement; - new(): HTMLMenuElement; -} - -interface MouseWheelEvent extends MouseEvent { - wheelDelta: number; - initMouseWheelEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: AbstractView, detailArg: number, screenXArg: number, screenYArg: number, clientXArg: number, clientYArg: number, buttonArg: number, relatedTargetArg: EventTarget, modifiersListArg: string, wheelDeltaArg: number): void; -} -declare var MouseWheelEvent: { - prototype: MouseWheelEvent; - new(): MouseWheelEvent; -} - -interface SVGFitToViewBox { - viewBox: SVGAnimatedRect; - preserveAspectRatio: SVGAnimatedPreserveAspectRatio; -} - -interface MSHTMLAnchorElementExtensions { - nameProp: string; - protocolLong: string; - urn: string; - mimeType: string; - Methods: string; -} - -interface SVGPointList { - numberOfItems: number; - replaceItem(newItem: SVGPoint, index: number): SVGPoint; - getItem(index: number): SVGPoint; - clear(): void; - appendItem(newItem: SVGPoint): SVGPoint; - initialize(newItem: SVGPoint): SVGPoint; - removeItem(index: number): SVGPoint; - insertItemBefore(newItem: SVGPoint, index: number): SVGPoint; -} -declare var SVGPointList: { - prototype: SVGPointList; - new(): SVGPointList; -} - -interface MSElementCSSInlineStyleExtensions { - doScroll(component?: any): void; - componentFromPoint(x: number, y: number): string; -} - -interface SVGAnimatedLengthList { - animVal: SVGLengthList; - baseVal: SVGLengthList; -} -declare var SVGAnimatedLengthList: { - prototype: SVGAnimatedLengthList; - new(): SVGAnimatedLengthList; -} - -interface MSHTMLTableDataCellElementExtensions { -} - -interface Window extends ViewCSS, MSEventAttachmentTarget, MSWindowExtensions, WindowPerformance, ScreenView, EventTarget, WindowLocalStorage, WindowSessionStorage, WindowTimers { - ondragend: (ev: DragEvent) => any; - addEventListener(type: "dragend", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - onkeydown: (ev: KeyboardEvent) => any; - addEventListener(type: "keydown", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; - ondragover: (ev: DragEvent) => any; - addEventListener(type: "dragover", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - onkeyup: (ev: KeyboardEvent) => any; - addEventListener(type: "keyup", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; - onreset: (ev: Event) => any; - addEventListener(type: "reset", listener: (ev: Event) => any, useCapture?: boolean): void; - onmouseup: (ev: MouseEvent) => any; - addEventListener(type: "mouseup", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - ondragstart: (ev: DragEvent) => any; - addEventListener(type: "dragstart", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - ondrag: (ev: DragEvent) => any; - addEventListener(type: "drag", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - onmouseover: (ev: MouseEvent) => any; - addEventListener(type: "mouseover", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - ondragleave: (ev: DragEvent) => any; - addEventListener(type: "dragleave", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - history: History; - name: string; - onafterprint: (ev: Event) => any; - addEventListener(type: "afterprint", listener: (ev: Event) => any, useCapture?: boolean): void; - onpause: (ev: Event) => any; - addEventListener(type: "pause", listener: (ev: Event) => any, useCapture?: boolean): void; - onbeforeprint: (ev: Event) => any; - addEventListener(type: "beforeprint", listener: (ev: Event) => any, useCapture?: boolean): void; - top: Window; - onmousedown: (ev: MouseEvent) => any; - addEventListener(type: "mousedown", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - onseeked: (ev: Event) => any; - addEventListener(type: "seeked", listener: (ev: Event) => any, useCapture?: boolean): void; - opener: Window; - onclick: (ev: MouseEvent) => any; - addEventListener(type: "click", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - onwaiting: (ev: Event) => any; - addEventListener(type: "waiting", listener: (ev: Event) => any, useCapture?: boolean): void; - ononline: (ev: Event) => any; - addEventListener(type: "online", listener: (ev: Event) => any, useCapture?: boolean): void; - ondurationchange: (ev: Event) => any; - addEventListener(type: "durationchange", listener: (ev: Event) => any, useCapture?: boolean): void; - frames: Window; - onblur: (ev: FocusEvent) => any; - addEventListener(type: "blur", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; - onemptied: (ev: Event) => any; - addEventListener(type: "emptied", listener: (ev: Event) => any, useCapture?: boolean): void; - onseeking: (ev: Event) => any; - addEventListener(type: "seeking", listener: (ev: Event) => any, useCapture?: boolean): void; - oncanplay: (ev: Event) => any; - addEventListener(type: "canplay", listener: (ev: Event) => any, useCapture?: boolean): void; - onstalled: (ev: Event) => any; - addEventListener(type: "stalled", listener: (ev: Event) => any, useCapture?: boolean): void; - onmousemove: (ev: MouseEvent) => any; - addEventListener(type: "mousemove", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - onoffline: (ev: Event) => any; - addEventListener(type: "offline", listener: (ev: Event) => any, useCapture?: boolean): void; - length: number; - onbeforeunload: (ev: BeforeUnloadEvent) => any; - addEventListener(type: "beforeunload", listener: (ev: BeforeUnloadEvent) => any, useCapture?: boolean): void; - onratechange: (ev: Event) => any; - addEventListener(type: "ratechange", listener: (ev: Event) => any, useCapture?: boolean): void; - onstorage: (ev: StorageEvent) => any; - addEventListener(type: "storage", listener: (ev: StorageEvent) => any, useCapture?: boolean): void; - onloadstart: (ev: Event) => any; - addEventListener(type: "loadstart", listener: (ev: Event) => any, useCapture?: boolean): void; - ondragenter: (ev: DragEvent) => any; - addEventListener(type: "dragenter", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - onsubmit: (ev: Event) => any; - addEventListener(type: "submit", listener: (ev: Event) => any, useCapture?: boolean): void; - self: Window; - onprogress: (ev: any) => any; - addEventListener(type: "progress", listener: (ev: any) => any, useCapture?: boolean): void; - ondblclick: (ev: MouseEvent) => any; - addEventListener(type: "dblclick", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - oncontextmenu: (ev: MouseEvent) => any; - addEventListener(type: "contextmenu", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - onchange: (ev: Event) => any; - addEventListener(type: "change", listener: (ev: Event) => any, useCapture?: boolean): void; - onloadedmetadata: (ev: Event) => any; - addEventListener(type: "loadedmetadata", listener: (ev: Event) => any, useCapture?: boolean): void; - onplay: (ev: Event) => any; - addEventListener(type: "play", listener: (ev: Event) => any, useCapture?: boolean): void; - onerror: ErrorFunction; - onplaying: (ev: Event) => any; - addEventListener(type: "playing", listener: (ev: Event) => any, useCapture?: boolean): void; - parent: Window; - location: Location; - oncanplaythrough: (ev: Event) => any; - addEventListener(type: "canplaythrough", listener: (ev: Event) => any, useCapture?: boolean): void; - onabort: (ev: UIEvent) => any; - addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - onreadystatechange: (ev: Event) => any; - addEventListener(type: "readystatechange", listener: (ev: Event) => any, useCapture?: boolean): void; - onkeypress: (ev: KeyboardEvent) => any; - addEventListener(type: "keypress", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; - frameElement: Element; - onloadeddata: (ev: Event) => any; - addEventListener(type: "loadeddata", listener: (ev: Event) => any, useCapture?: boolean): void; - onsuspend: (ev: Event) => any; - addEventListener(type: "suspend", listener: (ev: Event) => any, useCapture?: boolean): void; - window: Window; - onfocus: (ev: FocusEvent) => any; - addEventListener(type: "focus", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; - onmessage: (ev: MessageEvent) => any; - addEventListener(type: "message", listener: (ev: MessageEvent) => any, useCapture?: boolean): void; - ontimeupdate: (ev: Event) => any; - addEventListener(type: "timeupdate", listener: (ev: Event) => any, useCapture?: boolean): void; - onresize: (ev: UIEvent) => any; - addEventListener(type: "resize", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - navigator: Navigator; - onselect: (ev: UIEvent) => any; - addEventListener(type: "select", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - ondrop: (ev: DragEvent) => any; - addEventListener(type: "drop", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - onmouseout: (ev: MouseEvent) => any; - addEventListener(type: "mouseout", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - onended: (ev: Event) => any; - addEventListener(type: "ended", listener: (ev: Event) => any, useCapture?: boolean): void; - onhashchange: (ev: Event) => any; - addEventListener(type: "hashchange", listener: (ev: Event) => any, useCapture?: boolean): void; - onunload: (ev: Event) => any; - addEventListener(type: "unload", listener: (ev: Event) => any, useCapture?: boolean): void; - onscroll: (ev: UIEvent) => any; - addEventListener(type: "scroll", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - onmousewheel: (ev: MouseWheelEvent) => any; - addEventListener(type: "mousewheel", listener: (ev: MouseWheelEvent) => any, useCapture?: boolean): void; - onload: (ev: Event) => any; - addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; - onvolumechange: (ev: Event) => any; - addEventListener(type: "volumechange", listener: (ev: Event) => any, useCapture?: boolean): void; - oninput: (ev: Event) => any; - addEventListener(type: "input", listener: (ev: Event) => any, useCapture?: boolean): void; - alert(message?: string): void; - focus(): void; - print(): void; - prompt(message?: string, defaul?: string): string; - toString(): string; - open(url?: string, target?: string, features?: string, replace?: boolean): Window; - close(): void; - confirm(message?: string): boolean; - postMessage(message: any, targetOrigin: string, ports?: any): void; - showModalDialog(url?: string, argument?: any, options?: any): any; - blur(): void; - getSelection(): Selection; - addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; -} -declare var Window: { - prototype: Window; - new(): Window; -} - -interface SVGAnimatedPreserveAspectRatio { - animVal: SVGPreserveAspectRatio; - baseVal: SVGPreserveAspectRatio; -} -declare var SVGAnimatedPreserveAspectRatio: { - prototype: SVGAnimatedPreserveAspectRatio; - new(): SVGAnimatedPreserveAspectRatio; -} - -interface MSSiteModeEvent extends Event { - buttonID: number; - actionURL: string; -} -declare var MSSiteModeEvent: { - prototype: MSSiteModeEvent; - new(): MSSiteModeEvent; -} - -interface MSCSSStyleRuleExtensions { - readOnly: boolean; -} - -interface StyleSheetPageList { - length: number; - item(index: number): StyleSheetPage; - [index: number]: StyleSheetPage; -} -declare var StyleSheetPageList: { - prototype: StyleSheetPageList; - new(): StyleSheetPageList; -} - -interface HTMLCollection extends MSHTMLCollectionExtensions { - length: number; - item(nameOrIndex?: any, optionalIndex?: any): Element; - (nameOrIndex: any, optionalIndex: any): Element; - namedItem(name: string): Element; - [index: number]: Element; - (name: string): Element; -} -declare var HTMLCollection: { - prototype: HTMLCollection; - new(): HTMLCollection; -} - -interface MSCSSProperties extends CSSStyleDeclaration, MSCSSStyleDeclarationExtensions { - scrollbarShadowColor: string; - scrollbarHighlightColor: string; - layoutGridChar: string; - layoutGridType: string; - textAutospace: string; - textKashidaSpace: string; - writingMode: string; - scrollbarFaceColor: string; - backgroundPositionY: string; - lineBreak: string; - imeMode: string; - msBlockProgression: string; - layoutGridLine: string; - scrollbarBaseColor: string; - layoutGrid: string; - layoutFlow: string; - textKashida: string; - filter: string; - zoom: string; - scrollbarArrowColor: string; - behavior: string; - backgroundPositionX: string; - accelerator: string; - layoutGridMode: string; - textJustifyTrim: string; - scrollbar3dLightColor: string; - msInterpolationMode: string; - scrollbarTrackColor: string; - scrollbarDarkShadowColor: string; - styleFloat: string; -} -declare var MSCSSProperties: { - prototype: MSCSSProperties; - new(): MSCSSProperties; -} - -interface HTMLImageElement extends HTMLElement, DOML2DeprecatedMarginStyle, DOML2DeprecatedBorderStyle, DOML2DeprecatedAlignmentStyle_HTMLImageElement, MSImageResourceExtensions, MSHTMLImageElementExtensions, MSDataBindingExtensions, MSResourceMetadata { - width: number; - naturalHeight: number; - alt: string; - src: string; - useMap: string; - naturalWidth: number; - name: string; - height: number; - longDesc: string; - isMap: boolean; - complete: boolean; -} -declare var HTMLImageElement: { - prototype: HTMLImageElement; - new(): HTMLImageElement; -} - -interface HTMLAreaElement extends HTMLElement, MSHTMLAreaElementExtensions { - protocol: string; - search: string; - alt: string; - coords: string; - hostname: string; - port: string; - pathname: string; - host: string; - hash: string; - target: string; - href: string; - noHref: boolean; - shape: string; - toString(): string; -} -declare var HTMLAreaElement: { - prototype: HTMLAreaElement; - new(): HTMLAreaElement; -} - -interface EventTarget { - removeEventListener(type: string, listener: EventListener, useCapture?: boolean): void; - addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; - dispatchEvent(evt: Event): boolean; -} - -interface SVGAngle { - valueAsString: string; - valueInSpecifiedUnits: number; - value: number; - unitType: number; - newValueSpecifiedUnits(unitType: number, valueInSpecifiedUnits: number): void; - convertToSpecifiedUnits(unitType: number): void; - SVG_ANGLETYPE_RAD: number; - SVG_ANGLETYPE_UNKNOWN: number; - SVG_ANGLETYPE_UNSPECIFIED: number; - SVG_ANGLETYPE_DEG: number; - SVG_ANGLETYPE_GRAD: number; -} -declare var SVGAngle: { - prototype: SVGAngle; - new(): SVGAngle; - SVG_ANGLETYPE_RAD: number; - SVG_ANGLETYPE_UNKNOWN: number; - SVG_ANGLETYPE_UNSPECIFIED: number; - SVG_ANGLETYPE_DEG: number; - SVG_ANGLETYPE_GRAD: number; -} - -interface HTMLButtonElement extends HTMLElement, MSHTMLButtonElementExtensions, MSDataBindingExtensions { - value: string; - form: HTMLFormElement; - name: string; - type: string; -} -declare var HTMLButtonElement: { - prototype: HTMLButtonElement; - new(): HTMLButtonElement; -} - -interface MSHTMLLabelElementExtensions { -} - -interface HTMLSourceElement extends HTMLElement { - src: string; - media: string; - type: string; -} -declare var HTMLSourceElement: { - prototype: HTMLSourceElement; - new(): HTMLSourceElement; -} - -interface CanvasGradient { - addColorStop(offset: number, color: string): void; -} -declare var CanvasGradient: { - prototype: CanvasGradient; - new(): CanvasGradient; -} - -interface KeyboardEvent extends UIEvent, KeyboardEventExtensions { - location: number; - shiftKey: boolean; - locale: string; - key: string; - altKey: boolean; - metaKey: boolean; - char: string; - ctrlKey: boolean; - repeat: boolean; - getModifierState(keyArg: string): boolean; - initKeyboardEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: AbstractView, keyArg: string, locationArg: number, modifiersListArg: string, repeat: boolean, locale: string): void; - DOM_KEY_LOCATION_RIGHT: number; - DOM_KEY_LOCATION_STANDARD: number; - DOM_KEY_LOCATION_LEFT: number; - DOM_KEY_LOCATION_NUMPAD: number; - DOM_KEY_LOCATION_JOYSTICK: number; - DOM_KEY_LOCATION_MOBILE: number; -} -declare var KeyboardEvent: { - prototype: KeyboardEvent; - new(): KeyboardEvent; - DOM_KEY_LOCATION_RIGHT: number; - DOM_KEY_LOCATION_STANDARD: number; - DOM_KEY_LOCATION_LEFT: number; - DOM_KEY_LOCATION_NUMPAD: number; - DOM_KEY_LOCATION_JOYSTICK: number; - DOM_KEY_LOCATION_MOBILE: number; -} - -interface Document extends Node, DocumentStyle, DocumentRange, HTMLDocument, NodeSelector, DocumentEvent, DocumentTraversal, DocumentView, SVGDocument { - doctype: DocumentType; - xmlVersion: string; - implementation: DOMImplementation; - xmlEncoding: string; - xmlStandalone: boolean; - documentElement: HTMLElement; - inputEncoding: string; - createElement(tagName: string): HTMLElement; - createElement(tagName: "a"): HTMLAnchorElement; - createElement(tagName: "abbr"): HTMLElement; - createElement(tagName: "address"): HTMLElement; - createElement(tagName: "area"): HTMLAreaElement; - createElement(tagName: "article"): HTMLElement; - createElement(tagName: "aside"): HTMLElement; - createElement(tagName: "audio"): HTMLAudioElement; - createElement(tagName: "b"): HTMLElement; - createElement(tagName: "base"): HTMLBaseElement; - createElement(tagName: "bdi"): HTMLElement; - createElement(tagName: "bdo"): HTMLElement; - createElement(tagName: "blockquote"): HTMLQuoteElement; - createElement(tagName: "body"): HTMLBodyElement; - createElement(tagName: "br"): HTMLBRElement; - createElement(tagName: "button"): HTMLButtonElement; - createElement(tagName: "canvas"): HTMLCanvasElement; - createElement(tagName: "caption"): HTMLTableCaptionElement; - createElement(tagName: "cite"): HTMLElement; - createElement(tagName: "code"): HTMLElement; - createElement(tagName: "col"): HTMLTableColElement; - createElement(tagName: "colgroup"): HTMLTableColElement; - createElement(tagName: "datalist"): HTMLDataListElement; - createElement(tagName: "dd"): HTMLElement; - createElement(tagName: "del"): HTMLModElement; - createElement(tagName: "dfn"): HTMLElement; - createElement(tagName: "div"): HTMLDivElement; - createElement(tagName: "dl"): HTMLDListElement; - createElement(tagName: "dt"): HTMLElement; - createElement(tagName: "em"): HTMLElement; - createElement(tagName: "embed"): HTMLEmbedElement; - createElement(tagName: "fieldset"): HTMLFieldSetElement; - createElement(tagName: "figcaption"): HTMLElement; - createElement(tagName: "figure"): HTMLElement; - createElement(tagName: "footer"): HTMLElement; - createElement(tagName: "form"): HTMLFormElement; - createElement(tagName: "h1"): HTMLHeadingElement; - createElement(tagName: "h2"): HTMLHeadingElement; - createElement(tagName: "h3"): HTMLHeadingElement; - createElement(tagName: "h4"): HTMLHeadingElement; - createElement(tagName: "h5"): HTMLHeadingElement; - createElement(tagName: "h6"): HTMLHeadingElement; - createElement(tagName: "head"): HTMLHeadElement; - createElement(tagName: "header"): HTMLElement; - createElement(tagName: "hgroup"): HTMLElement; - createElement(tagName: "hr"): HTMLHRElement; - createElement(tagName: "html"): HTMLHtmlElement; - createElement(tagName: "i"): HTMLElement; - createElement(tagName: "iframe"): HTMLIFrameElement; - createElement(tagName: "img"): HTMLImageElement; - createElement(tagName: "input"): HTMLInputElement; - createElement(tagName: "ins"): HTMLModElement; - createElement(tagName: "kbd"): HTMLElement; - createElement(tagName: "label"): HTMLLabelElement; - createElement(tagName: "legend"): HTMLLegendElement; - createElement(tagName: "li"): HTMLLIElement; - createElement(tagName: "link"): HTMLLinkElement; - createElement(tagName: "main"): HTMLElement; - createElement(tagName: "map"): HTMLMapElement; - createElement(tagName: "mark"): HTMLElement; - createElement(tagName: "menu"): HTMLMenuElement; - createElement(tagName: "meta"): HTMLMetaElement; - createElement(tagName: "nav"): HTMLElement; - createElement(tagName: "noscript"): HTMLElement; - createElement(tagName: "object"): HTMLObjectElement; - createElement(tagName: "ol"): HTMLOListElement; - createElement(tagName: "optgroup"): HTMLOptGroupElement; - createElement(tagName: "option"): HTMLOptionElement; - createElement(tagName: "p"): HTMLParagraphElement; - createElement(tagName: "param"): HTMLParamElement; - createElement(tagName: "pre"): HTMLPreElement; - createElement(tagName: "progress"): HTMLProgressElement; - createElement(tagName: "q"): HTMLQuoteElement; - createElement(tagName: "rp"): HTMLElement; - createElement(tagName: "rt"): HTMLElement; - createElement(tagName: "ruby"): HTMLElement; - createElement(tagName: "s"): HTMLElement; - createElement(tagName: "samp"): HTMLElement; - createElement(tagName: "script"): HTMLScriptElement; - createElement(tagName: "section"): HTMLElement; - createElement(tagName: "select"): HTMLSelectElement; - createElement(tagName: "small"): HTMLElement; - createElement(tagName: "source"): HTMLSourceElement; - createElement(tagName: "span"): HTMLSpanElement; - createElement(tagName: "strong"): HTMLElement; - createElement(tagName: "style"): HTMLStyleElement; - createElement(tagName: "sub"): HTMLElement; - createElement(tagName: "summary"): HTMLElement; - createElement(tagName: "sup"): HTMLElement; - createElement(tagName: "table"): HTMLTableElement; - createElement(tagName: "tbody"): HTMLTableSectionElement; - createElement(tagName: "td"): HTMLTableDataCellElement; - createElement(tagName: "textarea"): HTMLTextAreaElement; - createElement(tagName: "tfoot"): HTMLTableSectionElement; - createElement(tagName: "th"): HTMLTableHeaderCellElement; - createElement(tagName: "thead"): HTMLTableSectionElement; - createElement(tagName: "title"): HTMLTitleElement; - createElement(tagName: "tr"): HTMLTableRowElement; - createElement(tagName: "track"): HTMLTrackElement; - createElement(tagName: "u"): HTMLElement; - createElement(tagName: "ul"): HTMLUListElement; - createElement(tagName: "var"): HTMLElement; - createElement(tagName: "video"): HTMLVideoElement; - createElement(tagName: "wbr"): HTMLElement; - adoptNode(source: Node): Node; - createComment(data: string): Comment; - createDocumentFragment(): DocumentFragment; - getElementsByTagName(tagname: string): NodeList; - getElementsByTagName(name: "a"): NodeListOf; - getElementsByTagName(name: "abbr"): NodeListOf; - getElementsByTagName(name: "address"): NodeListOf; - getElementsByTagName(name: "area"): NodeListOf; - getElementsByTagName(name: "article"): NodeListOf; - getElementsByTagName(name: "aside"): NodeListOf; - getElementsByTagName(name: "audio"): NodeListOf; - getElementsByTagName(name: "b"): NodeListOf; - getElementsByTagName(name: "base"): NodeListOf; - getElementsByTagName(name: "bdi"): NodeListOf; - getElementsByTagName(name: "bdo"): NodeListOf; - getElementsByTagName(name: "blockquote"): NodeListOf; - getElementsByTagName(name: "body"): NodeListOf; - getElementsByTagName(name: "br"): NodeListOf; - getElementsByTagName(name: "button"): NodeListOf; - getElementsByTagName(name: "canvas"): NodeListOf; - getElementsByTagName(name: "caption"): NodeListOf; - getElementsByTagName(name: "cite"): NodeListOf; - getElementsByTagName(name: "code"): NodeListOf; - getElementsByTagName(name: "col"): NodeListOf; - getElementsByTagName(name: "colgroup"): NodeListOf; - getElementsByTagName(name: "datalist"): NodeListOf; - getElementsByTagName(name: "dd"): NodeListOf; - getElementsByTagName(name: "del"): NodeListOf; - getElementsByTagName(name: "dfn"): NodeListOf; - getElementsByTagName(name: "div"): NodeListOf; - getElementsByTagName(name: "dl"): NodeListOf; - getElementsByTagName(name: "dt"): NodeListOf; - getElementsByTagName(name: "em"): NodeListOf; - getElementsByTagName(name: "embed"): NodeListOf; - getElementsByTagName(name: "fieldset"): NodeListOf; - getElementsByTagName(name: "figcaption"): NodeListOf; - getElementsByTagName(name: "figure"): NodeListOf; - getElementsByTagName(name: "footer"): NodeListOf; - getElementsByTagName(name: "form"): NodeListOf; - getElementsByTagName(name: "h1"): NodeListOf; - getElementsByTagName(name: "h2"): NodeListOf; - getElementsByTagName(name: "h3"): NodeListOf; - getElementsByTagName(name: "h4"): NodeListOf; - getElementsByTagName(name: "h5"): NodeListOf; - getElementsByTagName(name: "h6"): NodeListOf; - getElementsByTagName(name: "head"): NodeListOf; - getElementsByTagName(name: "header"): NodeListOf; - getElementsByTagName(name: "hgroup"): NodeListOf; - getElementsByTagName(name: "hr"): NodeListOf; - getElementsByTagName(name: "html"): NodeListOf; - getElementsByTagName(name: "i"): NodeListOf; - getElementsByTagName(name: "iframe"): NodeListOf; - getElementsByTagName(name: "img"): NodeListOf; - getElementsByTagName(name: "input"): NodeListOf; - getElementsByTagName(name: "ins"): NodeListOf; - getElementsByTagName(name: "kbd"): NodeListOf; - getElementsByTagName(name: "label"): NodeListOf; - getElementsByTagName(name: "legend"): NodeListOf; - getElementsByTagName(name: "li"): NodeListOf; - getElementsByTagName(name: "link"): NodeListOf; - getElementsByTagName(name: "main"): NodeListOf; - getElementsByTagName(name: "map"): NodeListOf; - getElementsByTagName(name: "mark"): NodeListOf; - getElementsByTagName(name: "menu"): NodeListOf; - getElementsByTagName(name: "meta"): NodeListOf; - getElementsByTagName(name: "nav"): NodeListOf; - getElementsByTagName(name: "noscript"): NodeListOf; - getElementsByTagName(name: "object"): NodeListOf; - getElementsByTagName(name: "ol"): NodeListOf; - getElementsByTagName(name: "optgroup"): NodeListOf; - getElementsByTagName(name: "option"): NodeListOf; - getElementsByTagName(name: "p"): NodeListOf; - getElementsByTagName(name: "param"): NodeListOf; - getElementsByTagName(name: "pre"): NodeListOf; - getElementsByTagName(name: "progress"): NodeListOf; - getElementsByTagName(name: "q"): NodeListOf; - getElementsByTagName(name: "rp"): NodeListOf; - getElementsByTagName(name: "rt"): NodeListOf; - getElementsByTagName(name: "ruby"): NodeListOf; - getElementsByTagName(name: "s"): NodeListOf; - getElementsByTagName(name: "samp"): NodeListOf; - getElementsByTagName(name: "script"): NodeListOf; - getElementsByTagName(name: "section"): NodeListOf; - getElementsByTagName(name: "select"): NodeListOf; - getElementsByTagName(name: "small"): NodeListOf; - getElementsByTagName(name: "source"): NodeListOf; - getElementsByTagName(name: "span"): NodeListOf; - getElementsByTagName(name: "strong"): NodeListOf; - getElementsByTagName(name: "style"): NodeListOf; - getElementsByTagName(name: "sub"): NodeListOf; - getElementsByTagName(name: "summary"): NodeListOf; - getElementsByTagName(name: "sup"): NodeListOf; - getElementsByTagName(name: "table"): NodeListOf; - getElementsByTagName(name: "tbody"): NodeListOf; - getElementsByTagName(name: "td"): NodeListOf; - getElementsByTagName(name: "textarea"): NodeListOf; - getElementsByTagName(name: "tfoot"): NodeListOf; - getElementsByTagName(name: "th"): NodeListOf; - getElementsByTagName(name: "thead"): NodeListOf; - getElementsByTagName(name: "title"): NodeListOf; - getElementsByTagName(name: "tr"): NodeListOf; - getElementsByTagName(name: "track"): NodeListOf; - getElementsByTagName(name: "u"): NodeListOf; - getElementsByTagName(name: "ul"): NodeListOf; - getElementsByTagName(name: "var"): NodeListOf; - getElementsByTagName(name: "video"): NodeListOf; - getElementsByTagName(name: "wbr"): NodeListOf; - getElementsByTagNameNS(namespaceURI: string, localName: string): NodeList; - createProcessingInstruction(target: string, data: string): ProcessingInstruction; - createElementNS(namespaceURI: string, qualifiedName: string): Element; - createAttribute(name: string): Attr; - createTextNode(data: string): Text; - importNode(importedNode: Node, deep: boolean): Node; - createCDATASection(data: string): CDATASection; - createAttributeNS(namespaceURI: string, qualifiedName: string): Attr; - getElementById(elementId: string): HTMLElement; -} -declare var Document: { - prototype: Document; - new(): Document; -} - -interface MessageEvent extends Event { - source: Window; - origin: string; - data: any; - initMessageEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, dataArg: any, originArg: string, lastEventIdArg: string, sourceArg: Window): void; -} -declare var MessageEvent: { - prototype: MessageEvent; - new(): MessageEvent; -} - -interface SVGElement extends Element, SVGElementEventHandlers { - xmlbase: string; - viewportElement: SVGElement; - id: string; - ownerSVGElement: SVGSVGElement; -} -declare var SVGElement: { - prototype: SVGElement; - new(): SVGElement; -} - -interface HTMLScriptElement extends HTMLElement { - defer: boolean; - text: string; - src: string; - htmlFor: string; - charset: string; - type: string; - event: string; -} -declare var HTMLScriptElement: { - prototype: HTMLScriptElement; - new(): HTMLScriptElement; -} - -interface MSHTMLBodyElementExtensions extends DOML2DeprecatedWordWrapSuppression_HTMLBodyElement { - scroll: string; - bottomMargin: any; - topMargin: any; - rightMargin: any; - bgProperties: string; - leftMargin: any; - createTextRange(): TextRange; -} - -interface HTMLTableRowElement extends HTMLElement, MSBorderColorHighlightStyle_HTMLTableRowElement, HTMLTableAlignment, MSBorderColorStyle_HTMLTableRowElement, DOML2DeprecatedAlignmentStyle_HTMLTableRowElement, DOML2DeprecatedBackgroundColorStyle, MSHTMLTableRowElementExtensions { - rowIndex: number; - cells: HTMLCollection; - sectionRowIndex: number; - deleteCell(index?: number): void; - insertCell(index?: number): HTMLElement; -} -declare var HTMLTableRowElement: { - prototype: HTMLTableRowElement; - new(): HTMLTableRowElement; -} - -interface MSCommentExtensions { - text: string; -} - -interface DOML2DeprecatedMarginStyle_HTMLMarqueeElement { - vspace: number; - hspace: number; -} - -interface MSCSSRuleList { - length: number; - item(index?: number): CSSStyleRule; - [index: number]: CSSStyleRule; -} -declare var MSCSSRuleList: { - prototype: MSCSSRuleList; - new(): MSCSSRuleList; -} - -interface CanvasRenderingContext2D { - shadowOffsetX: number; - lineWidth: number; - miterLimit: number; - canvas: HTMLCanvasElement; - strokeStyle: any; - font: string; - globalAlpha: number; - globalCompositeOperation: string; - shadowOffsetY: number; - fillStyle: any; - lineCap: string; - shadowBlur: number; - textAlign: string; - textBaseline: string; - shadowColor: string; - lineJoin: string; - restore(): void; - setTransform(m11: number, m12: number, m21: number, m22: number, dx: number, dy: number): void; - save(): void; - arc(x: number, y: number, radius: number, startAngle: number, endAngle: number, anticlockwise?: boolean): void; - measureText(text: string): TextMetrics; - isPointInPath(x: number, y: number): boolean; - quadraticCurveTo(cpx: number, cpy: number, x: number, y: number): void; - putImageData(imagedata: ImageData, dx: number, dy: number, dirtyX?: number, dirtyY?: number, dirtyWidth?: number, dirtyHeight?: number): void; - rotate(angle: number): void; - fillText(text: string, x: number, y: number, maxWidth?: number): void; - translate(x: number, y: number): void; - scale(x: number, y: number): void; - createRadialGradient(x0: number, y0: number, r0: number, x1: number, y1: number, r1: number): CanvasGradient; - lineTo(x: number, y: number): void; - fill(): void; - createPattern(image: HTMLElement, repetition: string): CanvasPattern; - closePath(): void; - rect(x: number, y: number, w: number, h: number): void; - clip(): void; - createImageData(imageDataOrSw: any, sh?: number): ImageData; - clearRect(x: number, y: number, w: number, h: number): void; - moveTo(x: number, y: number): void; - getImageData(sx: number, sy: number, sw: number, sh: number): ImageData; - fillRect(x: number, y: number, w: number, h: number): void; - bezierCurveTo(cp1x: number, cp1y: number, cp2x: number, cp2y: number, x: number, y: number): void; - drawImage(image: HTMLElement, offsetX: number, offsetY: number, width?: number, height?: number, canvasOffsetX?: number, canvasOffsetY?: number, canvasImageWidth?: number, canvasImageHeight?: number): void; - transform(m11: number, m12: number, m21: number, m22: number, dx: number, dy: number): void; - stroke(): void; - strokeRect(x: number, y: number, w: number, h: number): void; - strokeText(text: string, x: number, y: number, maxWidth?: number): void; - beginPath(): void; - arcTo(x1: number, y1: number, x2: number, y2: number, radius: number): void; - createLinearGradient(x0: number, y0: number, x1: number, y1: number): CanvasGradient; -} -declare var CanvasRenderingContext2D: { - prototype: CanvasRenderingContext2D; - new(): CanvasRenderingContext2D; -} - -interface SVGPathSegLinetoHorizontalAbs extends SVGPathSeg { - x: number; -} -declare var SVGPathSegLinetoHorizontalAbs: { - prototype: SVGPathSegLinetoHorizontalAbs; - new(): SVGPathSegLinetoHorizontalAbs; -} - -interface DOML2DeprecatedAlignmentStyle_HTMLObjectElement { - align: string; -} - -interface DOML2DeprecatedBorderStyle_MSHTMLIFrameElementExtensions { - border: string; -} - -interface MSHTMLElementRangeExtensions { - createControlRange(): ControlRangeCollection; -} - -interface SVGPathSegArcAbs extends SVGPathSeg { - y: number; - sweepFlag: boolean; - r2: number; - x: number; - angle: number; - r1: number; - largeArcFlag: boolean; -} -declare var SVGPathSegArcAbs: { - prototype: SVGPathSegArcAbs; - new(): SVGPathSegArcAbs; -} - -interface MSScreenExtensions { - deviceXDPI: number; - fontSmoothingEnabled: boolean; - bufferDepth: number; - logicalXDPI: number; - systemXDPI: number; - logicalYDPI: number; - systemYDPI: number; - updateInterval: number; - deviceYDPI: number; -} - -interface HTMLHtmlElement extends HTMLElement, HTMLHtmlElementDOML2Deprecated { -} -declare var HTMLHtmlElement: { - prototype: HTMLHtmlElement; - new(): HTMLHtmlElement; -} - -interface MSBorderColorStyle { - borderColor: any; -} - -interface SVGTransformList { - numberOfItems: number; - getItem(index: number): SVGTransform; - consolidate(): SVGTransform; - clear(): void; - appendItem(newItem: SVGTransform): SVGTransform; - initialize(newItem: SVGTransform): SVGTransform; - removeItem(index: number): SVGTransform; - insertItemBefore(newItem: SVGTransform, index: number): SVGTransform; - replaceItem(newItem: SVGTransform, index: number): SVGTransform; - createSVGTransformFromMatrix(matrix: SVGMatrix): SVGTransform; -} -declare var SVGTransformList: { - prototype: SVGTransformList; - new(): SVGTransformList; -} - -interface SVGPathSegClosePath extends SVGPathSeg { -} -declare var SVGPathSegClosePath: { - prototype: SVGPathSegClosePath; - new(): SVGPathSegClosePath; -} - -interface DOML2DeprecatedMarginStyle_MSHTMLIFrameElementExtensions { - vspace: number; - hspace: number; -} - -interface HTMLFrameElement extends HTMLElement, GetSVGDocument, MSHTMLFrameElementExtensions, MSDataBindingExtensions, MSBorderColorStyle_HTMLFrameElement { - scrolling: string; - marginHeight: string; - src: string; - name: string; - marginWidth: string; - contentDocument: Document; - longDesc: string; - noResize: boolean; -} -declare var HTMLFrameElement: { - prototype: HTMLFrameElement; - new(): HTMLFrameElement; -} - -interface SVGAnimatedLength { - animVal: SVGLength; - baseVal: SVGLength; -} -declare var SVGAnimatedLength: { - prototype: SVGAnimatedLength; - new(): SVGAnimatedLength; -} - -interface CSSMediaRule extends CSSRule { - media: MediaList; - cssRules: CSSRuleList; - insertRule(rule: string, index?: number): number; - deleteRule(index?: number): void; -} -declare var CSSMediaRule: { - prototype: CSSMediaRule; - new(): CSSMediaRule; -} - -interface HTMLQuoteElement extends HTMLElement, MSHTMLQuoteElementExtensions { - cite: string; -} -declare var HTMLQuoteElement: { - prototype: HTMLQuoteElement; - new(): HTMLQuoteElement; -} - -interface SVGDefsElement extends SVGElement, SVGStylable, SVGTransformable, SVGLangSpace, SVGTests { -} -declare var SVGDefsElement: { - prototype: SVGDefsElement; - new(): SVGDefsElement; -} - -interface SVGAnimatedPoints { - points: SVGPointList; - animatedPoints: SVGPointList; -} - -interface WindowModal { - dialogArguments: any; - returnValue: any; -} - -interface MSHTMLButtonElementExtensions { - status: any; - createTextRange(): TextRange; -} - -interface XMLHttpRequest extends EventTarget, MSXMLHttpRequestExtensions { - onreadystatechange: (ev: Event) => any; - addEventListener(type: "readystatechange", listener: (ev: Event) => any, useCapture?: boolean): void; - status: number; - onload: (ev: Event) => any; - addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; - readyState: number; - responseText: string; - responseXML: Document; - statusText: string; - open(method: string, url: string, async?: boolean, user?: string, password?: string): void; - send(data?: any): void; - abort(): void; - getAllResponseHeaders(): string; - setRequestHeader(header: string, value: string): void; - getResponseHeader(header: string): string; - LOADING: number; - DONE: number; - UNSENT: number; - OPENED: number; - HEADERS_RECEIVED: number; - addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; -} -declare var XMLHttpRequest: { - prototype: XMLHttpRequest; - new (): XMLHttpRequest; - LOADING: number; - DONE: number; - UNSENT: number; - OPENED: number; - HEADERS_RECEIVED: number; -} - -interface HTMLTableHeaderCellElement extends HTMLTableCellElement, HTMLTableHeaderCellScope { -} -declare var HTMLTableHeaderCellElement: { - prototype: HTMLTableHeaderCellElement; - new(): HTMLTableHeaderCellElement; -} - -interface HTMLDListElement extends HTMLElement, DOML2DeprecatedListSpaceReduction, MSHTMLDListElementExtensions { -} -declare var HTMLDListElement: { - prototype: HTMLDListElement; - new(): HTMLDListElement; -} - -interface MSDataBindingExtensions { - dataSrc: string; - dataFormatAs: string; - dataFld: string; -} - -interface SVGEllipseElement extends SVGElement, SVGStylable, SVGTransformable, SVGLangSpace, SVGTests { - ry: SVGAnimatedLength; - cx: SVGAnimatedLength; - rx: SVGAnimatedLength; - cy: SVGAnimatedLength; -} -declare var SVGEllipseElement: { - prototype: SVGEllipseElement; - new(): SVGEllipseElement; -} - -interface SVGPathSegLinetoHorizontalRel extends SVGPathSeg { - x: number; -} -declare var SVGPathSegLinetoHorizontalRel: { - prototype: SVGPathSegLinetoHorizontalRel; - new(): SVGPathSegLinetoHorizontalRel; -} - -interface SVGAElement extends SVGElement, SVGStylable, SVGTransformable, SVGLangSpace, SVGTests, SVGURIReference { - target: SVGAnimatedString; -} -declare var SVGAElement: { - prototype: SVGAElement; - new(): SVGAElement; -} - -interface MSHTMLMetaElementExtensions { - url: string; - charset: string; -} - -interface SVGStylable { - className: SVGAnimatedString; - style: CSSStyleDeclaration; -} - -interface MSHTMLTableCellElementExtensions { -} - -interface HTMLFrameSetElement extends HTMLElement, MSHTMLFrameSetElementExtensions, MSBorderColorStyle_HTMLFrameSetElement { - onresize: (ev: UIEvent) => any; - addEventListener(type: "resize", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - ononline: (ev: Event) => any; - addEventListener(type: "online", listener: (ev: Event) => any, useCapture?: boolean): void; - onafterprint: (ev: Event) => any; - addEventListener(type: "afterprint", listener: (ev: Event) => any, useCapture?: boolean): void; - onbeforeprint: (ev: Event) => any; - addEventListener(type: "beforeprint", listener: (ev: Event) => any, useCapture?: boolean): void; - onoffline: (ev: Event) => any; - addEventListener(type: "offline", listener: (ev: Event) => any, useCapture?: boolean): void; - rows: string; - cols: string; - onblur: (ev: FocusEvent) => any; - addEventListener(type: "blur", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; - onunload: (ev: Event) => any; - addEventListener(type: "unload", listener: (ev: Event) => any, useCapture?: boolean): void; - onhashchange: (ev: Event) => any; - addEventListener(type: "hashchange", listener: (ev: Event) => any, useCapture?: boolean): void; - onfocus: (ev: FocusEvent) => any; - addEventListener(type: "focus", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; - onmessage: (ev: MessageEvent) => any; - addEventListener(type: "message", listener: (ev: MessageEvent) => any, useCapture?: boolean): void; - onload: (ev: Event) => any; - addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; - onerror: (ev: Event) => any; - addEventListener(type: "error", listener: (ev: Event) => any, useCapture?: boolean): void; - onbeforeunload: (ev: BeforeUnloadEvent) => any; - addEventListener(type: "beforeunload", listener: (ev: BeforeUnloadEvent) => any, useCapture?: boolean): void; - onstorage: (ev: StorageEvent) => any; - addEventListener(type: "storage", listener: (ev: StorageEvent) => any, useCapture?: boolean): void; - addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; -} -declare var HTMLFrameSetElement: { - prototype: HTMLFrameSetElement; - new(): HTMLFrameSetElement; -} - -interface SVGTransformable extends SVGLocatable { - transform: SVGAnimatedTransformList; -} - -interface Screen extends MSScreenExtensions { - width: number; - colorDepth: number; - availWidth: number; - pixelDepth: number; - availHeight: number; - height: number; -} -declare var Screen: { - prototype: Screen; - new(): Screen; -} - -interface NavigatorGeolocation { - geolocation: Geolocation; -} - -interface Coordinates { - altitudeAccuracy: number; - longitude: number; - latitude: number; - speed: number; - heading: number; - altitude: number; - accuracy: number; -} -declare var Coordinates: { - prototype: Coordinates; - new(): Coordinates; -} - -interface DOML2DeprecatedAlignmentStyle_HTMLTableColElement { - align: string; -} - -interface EventListener { - (evt: Event): void; -} - -interface SVGLangSpace { - xmllang: string; - xmlspace: string; -} - -interface DataTransfer { - effectAllowed: string; - dropEffect: string; - clearData(format?: string): boolean; - setData(format: string, data: string): boolean; - getData(format: string): string; -} -declare var DataTransfer: { - prototype: DataTransfer; - new(): DataTransfer; -} - -interface FocusEvent extends UIEvent { - relatedTarget: EventTarget; - initFocusEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: AbstractView, detailArg: number, relatedTargetArg: EventTarget): void; -} -declare var FocusEvent: { - prototype: FocusEvent; - new(): FocusEvent; -} - -interface Range { - startOffset: number; - collapsed: boolean; - endOffset: number; - startContainer: Node; - endContainer: Node; - commonAncestorContainer: Node; - setStart(refNode: Node, offset: number): void; - setEndBefore(refNode: Node): void; - setStartBefore(refNode: Node): void; - selectNode(refNode: Node): void; - detach(): void; - getBoundingClientRect(): ClientRect; - toString(): string; - compareBoundaryPoints(how: number, sourceRange: Range): number; - insertNode(newNode: Node): void; - collapse(toStart: boolean): void; - selectNodeContents(refNode: Node): void; - cloneContents(): DocumentFragment; - setEnd(refNode: Node, offset: number): void; - cloneRange(): Range; - getClientRects(): ClientRectList; - surroundContents(newParent: Node): void; - deleteContents(): void; - setStartAfter(refNode: Node): void; - extractContents(): DocumentFragment; - setEndAfter(refNode: Node): void; - END_TO_END: number; - START_TO_START: number; - START_TO_END: number; - END_TO_START: number; -} -declare var Range: { - prototype: Range; - new(): Range; - END_TO_END: number; - START_TO_START: number; - START_TO_END: number; - END_TO_START: number; -} - -interface MSHTMLPreElementExtensions extends DOML2DeprecatedTextFlowControl_HTMLBlockElement { - cite: string; -} - -interface SVGPoint { - y: number; - x: number; - matrixTransform(matrix: SVGMatrix): SVGPoint; -} -declare var SVGPoint: { - prototype: SVGPoint; - new(): SVGPoint; -} - -interface MSPluginsCollection { - length: number; - refresh(reload?: boolean): void; -} -declare var MSPluginsCollection: { - prototype: MSPluginsCollection; - new(): MSPluginsCollection; -} - -interface MSHTMLFontElementExtensions { -} - -interface SVGAnimatedNumberList { - animVal: SVGNumberList; - baseVal: SVGNumberList; -} -declare var SVGAnimatedNumberList: { - prototype: SVGAnimatedNumberList; - new(): SVGAnimatedNumberList; -} - -interface SVGSVGElement extends SVGElement, SVGZoomAndPan, SVGLangSpace, SVGLocatable, SVGTests, SVGFitToViewBox, SVGSVGElementEventHandlers, SVGStylable, DocumentEvent, ViewCSS_SVGSVGElement { - width: SVGAnimatedLength; - x: SVGAnimatedLength; - contentStyleType: string; - screenPixelToMillimeterY: number; - height: SVGAnimatedLength; - contentScriptType: string; - pixelUnitToMillimeterX: number; - currentTranslate: SVGPoint; - y: SVGAnimatedLength; - viewport: SVGRect; - currentScale: number; - screenPixelToMillimeterX: number; - pixelUnitToMillimeterY: number; - setCurrentTime(seconds: number): void; - createSVGLength(): SVGLength; - getIntersectionList(rect: SVGRect, referenceElement: SVGElement): NodeList; - unpauseAnimations(): void; - createSVGRect(): SVGRect; - checkIntersection(element: SVGElement, rect: SVGRect): boolean; - unsuspendRedrawAll(): void; - pauseAnimations(): void; - suspendRedraw(maxWaitMilliseconds: number): number; - deselectAll(): void; - createSVGAngle(): SVGAngle; - getEnclosureList(rect: SVGRect, referenceElement: SVGElement): NodeList; - createSVGTransform(): SVGTransform; - unsuspendRedraw(suspendHandleID: number): void; - forceRedraw(): void; - getCurrentTime(): number; - checkEnclosure(element: SVGElement, rect: SVGRect): boolean; - createSVGMatrix(): SVGMatrix; - createSVGPoint(): SVGPoint; - createSVGNumber(): SVGNumber; - createSVGTransformFromMatrix(matrix: SVGMatrix): SVGTransform; - getElementById(elementId: string): Element; -} -declare var SVGSVGElement: { - prototype: SVGSVGElement; - new(): SVGSVGElement; -} - -interface HTMLLabelElement extends HTMLElement, MSDataBindingExtensions, MSHTMLLabelElementExtensions { - htmlFor: string; - form: HTMLFormElement; -} -declare var HTMLLabelElement: { - prototype: HTMLLabelElement; - new(): HTMLLabelElement; -} - -interface MSResourceMetadata { - protocol: string; - fileSize: string; - fileUpdatedDate: string; - nameProp: string; - fileCreatedDate: string; - fileModifiedDate: string; - mimeType: string; -} - -interface MSHTMLQuoteElementExtensions { - dateTime: string; -} - -interface DOML2DeprecatedAlignmentStyle_HTMLIFrameElement { - align: string; -} - -interface HTMLLegendElement extends HTMLElement, DOML2DeprecatedAlignmentStyle_HTMLLegendElement, MSDataBindingExtensions, MSHTMLLegendElementExtensions { - form: HTMLFormElement; -} -declare var HTMLLegendElement: { - prototype: HTMLLegendElement; - new(): HTMLLegendElement; -} - -interface HTMLDirectoryElement extends HTMLElement, DOML2DeprecatedListSpaceReduction, MSHTMLDirectoryElementExtensions { -} -declare var HTMLDirectoryElement: { - prototype: HTMLDirectoryElement; - new(): HTMLDirectoryElement; -} - -interface NavigatorAbilities { -} - -interface MSHTMLImageElementExtensions { - href: string; -} - -interface SVGAnimatedInteger { - animVal: number; - baseVal: number; -} -declare var SVGAnimatedInteger: { - prototype: SVGAnimatedInteger; - new(): SVGAnimatedInteger; -} - -interface SVGTextElement extends SVGTextPositioningElement, SVGTransformable { -} -declare var SVGTextElement: { - prototype: SVGTextElement; - new(): SVGTextElement; -} - -interface SVGTSpanElement extends SVGTextPositioningElement { -} -declare var SVGTSpanElement: { - prototype: SVGTSpanElement; - new(): SVGTSpanElement; -} - -interface HTMLLIElement extends HTMLElement, DOML2DeprecatedListNumberingAndBulletStyle, MSHTMLLIElementExtensions { - value: number; -} -declare var HTMLLIElement: { - prototype: HTMLLIElement; - new(): HTMLLIElement; -} - -interface SVGPathSegLinetoVerticalAbs extends SVGPathSeg { - y: number; -} -declare var SVGPathSegLinetoVerticalAbs: { - prototype: SVGPathSegLinetoVerticalAbs; - new(): SVGPathSegLinetoVerticalAbs; -} - -interface ViewCSS { - getComputedStyle(elt: Element, pseudoElt?: string): CSSStyleDeclaration; -} - -interface MSAttrExtensions { - expando: boolean; -} - -interface MSStorageExtensions { - remainingSpace: number; -} - -interface SVGStyleElement extends SVGElement, SVGLangSpace { - media: string; - type: string; - title: string; -} -declare var SVGStyleElement: { - prototype: SVGStyleElement; - new(): SVGStyleElement; -} - -interface MSCurrentStyleCSSProperties extends MSCSSProperties { - blockDirection: string; - clipBottom: string; - clipLeft: string; - clipRight: string; - clipTop: string; - hasLayout: string; -} -declare var MSCurrentStyleCSSProperties: { - prototype: MSCurrentStyleCSSProperties; - new(): MSCurrentStyleCSSProperties; -} - -interface MSLinkStyleExtensions { - styleSheet: StyleSheet; -} - -interface MSHTMLCollectionExtensions { - urns(urn: any): Object; - tags(tagName: any): Object; -} - -interface DOML2DeprecatedWordWrapSuppression_HTMLDivElement { - noWrap: boolean; -} - -interface DocumentTraversal { - createNodeIterator(root: Node, whatToShow: number, filter: NodeFilterCallback, entityReferenceExpansion: boolean): NodeIterator; - createTreeWalker(root: Node, whatToShow: number, filter: NodeFilterCallback, entityReferenceExpansion: boolean): TreeWalker; -} - -interface Storage extends MSStorageExtensions { - length: number; - getItem(key: string): any; - [key: string]: any; - setItem(key: string, data: string): void; - clear(): void; - removeItem(key: string): void; - key(index: number): string; - [index: number]: any; -} -declare var Storage: { - prototype: Storage; - new(): Storage; -} - -interface HTMLTableHeaderCellScope { - scope: string; -} - -interface HTMLIFrameElement extends HTMLElement, GetSVGDocument, MSHTMLIFrameElementExtensions, MSDataBindingExtensions, DOML2DeprecatedAlignmentStyle_HTMLIFrameElement { - width: string; - contentWindow: Window; - scrolling: string; - src: string; - marginHeight: string; - name: string; - marginWidth: string; - height: string; - contentDocument: Document; - longDesc: string; - frameBorder: string; -} -declare var HTMLIFrameElement: { - prototype: HTMLIFrameElement; - new(): HTMLIFrameElement; -} - -interface MSNavigatorAbilities { - userLanguage: string; - plugins: MSPluginsCollection; - cookieEnabled: boolean; - appCodeName: string; - cpuClass: string; - appMinorVersion: string; - connectionSpeed: number; - browserLanguage: string; - mimeTypes: MSMimeTypesCollection; - product: string; - systemLanguage: string; - javaEnabled(): boolean; - taintEnabled(): boolean; -} - -interface TextRangeCollection { - length: number; - item(index: number): TextRange; - [index: number]: TextRange; -} -declare var TextRangeCollection: { - prototype: TextRangeCollection; - new(): TextRangeCollection; -} - -interface HTMLBodyElement extends HTMLElement, HTMLBodyElementDOML2Deprecated, MSHTMLBodyElementExtensions, DOML2DeprecatedBackgroundStyle, DOML2DeprecatedBackgroundColorStyle { - onresize: (ev: UIEvent) => any; - addEventListener(type: "resize", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - ononline: (ev: Event) => any; - addEventListener(type: "online", listener: (ev: Event) => any, useCapture?: boolean): void; - onafterprint: (ev: Event) => any; - addEventListener(type: "afterprint", listener: (ev: Event) => any, useCapture?: boolean): void; - onbeforeprint: (ev: Event) => any; - addEventListener(type: "beforeprint", listener: (ev: Event) => any, useCapture?: boolean): void; - onoffline: (ev: Event) => any; - addEventListener(type: "offline", listener: (ev: Event) => any, useCapture?: boolean): void; - onblur: (ev: FocusEvent) => any; - addEventListener(type: "blur", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; - onhashchange: (ev: Event) => any; - addEventListener(type: "hashchange", listener: (ev: Event) => any, useCapture?: boolean): void; - onunload: (ev: Event) => any; - addEventListener(type: "unload", listener: (ev: Event) => any, useCapture?: boolean): void; - onfocus: (ev: FocusEvent) => any; - addEventListener(type: "focus", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; - onmessage: (ev: MessageEvent) => any; - addEventListener(type: "message", listener: (ev: MessageEvent) => any, useCapture?: boolean): void; - onload: (ev: Event) => any; - addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; - onerror: (ev: Event) => any; - addEventListener(type: "error", listener: (ev: Event) => any, useCapture?: boolean): void; - onbeforeunload: (ev: BeforeUnloadEvent) => any; - addEventListener(type: "beforeunload", listener: (ev: BeforeUnloadEvent) => any, useCapture?: boolean): void; - onstorage: (ev: StorageEvent) => any; - addEventListener(type: "storage", listener: (ev: StorageEvent) => any, useCapture?: boolean): void; - addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; -} -declare var HTMLBodyElement: { - prototype: HTMLBodyElement; - new(): HTMLBodyElement; -} - -interface DocumentType extends Node { - name: string; - notations: NamedNodeMap; - systemId: string; - internalSubset: string; - entities: NamedNodeMap; - publicId: string; -} -declare var DocumentType: { - prototype: DocumentType; - new(): DocumentType; -} - -interface MSHTMLInputElementExtensions extends DOML2DeprecatedMarginStyle_HTMLInputElement, DOML2DeprecatedBorderStyle_HTMLInputElement { - status: boolean; - complete: boolean; - createTextRange(): TextRange; -} - -interface DOML2DeprecatedAlignmentStyle_HTMLLegendElement { - align: string; -} - -interface SVGRadialGradientElement extends SVGGradientElement { - cx: SVGAnimatedLength; - r: SVGAnimatedLength; - cy: SVGAnimatedLength; - fx: SVGAnimatedLength; - fy: SVGAnimatedLength; -} -declare var SVGRadialGradientElement: { - prototype: SVGRadialGradientElement; - new(): SVGRadialGradientElement; -} - -interface MutationEvent extends Event { - newValue: string; - attrChange: number; - attrName: string; - prevValue: string; - relatedNode: Node; - initMutationEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, relatedNodeArg: Node, prevValueArg: string, newValueArg: string, attrNameArg: string, attrChangeArg: number): void; - MODIFICATION: number; - REMOVAL: number; - ADDITION: number; -} -declare var MutationEvent: { - prototype: MutationEvent; - new(): MutationEvent; - MODIFICATION: number; - REMOVAL: number; - ADDITION: number; -} - -interface DragEvent extends MouseEvent { - dataTransfer: DataTransfer; - initDragEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: AbstractView, detailArg: number, screenXArg: number, screenYArg: number, clientXArg: number, clientYArg: number, ctrlKeyArg: boolean, altKeyArg: boolean, shiftKeyArg: boolean, metaKeyArg: boolean, buttonArg: number, relatedTargetArg: EventTarget, dataTransferArg: DataTransfer): void; -} -declare var DragEvent: { - prototype: DragEvent; - new(): DragEvent; -} - -interface DOML2DeprecatedWidthStyle_HTMLTableCellElement { - width: number; -} - -interface HTMLTableSectionElement extends HTMLElement, MSHTMLTableSectionElementExtensions, DOML2DeprecatedAlignmentStyle_HTMLTableSectionElement, HTMLTableAlignment { - rows: HTMLCollection; - deleteRow(index?: number): void; - insertRow(index?: number): HTMLElement; -} -declare var HTMLTableSectionElement: { - prototype: HTMLTableSectionElement; - new(): HTMLTableSectionElement; -} - -interface DOML2DeprecatedListNumberingAndBulletStyle { - type: string; -} - -interface HTMLInputElement extends HTMLElement, DOML2DeprecatedAlignmentStyle_HTMLInputElement, MSImageResourceExtensions_HTMLInputElement, MSHTMLInputElementExtensions, MSDataBindingExtensions { - width: string; - defaultChecked: boolean; - alt: string; - accept: string; - value: string; - src: string; - useMap: string; - name: string; - form: HTMLFormElement; - selectionStart: number; - height: string; - indeterminate: boolean; - readOnly: boolean; - size: number; - checked: boolean; - maxLength: number; - selectionEnd: number; - type: string; - defaultValue: string; - setSelectionRange(start: number, end: number): void; - select(): void; -} -declare var HTMLInputElement: { - prototype: HTMLInputElement; - new(): HTMLInputElement; -} - -interface HTMLAnchorElement extends HTMLElement, MSHTMLAnchorElementExtensions, MSDataBindingExtensions { - rel: string; - protocol: string; - search: string; - coords: string; - hostname: string; - pathname: string; - target: string; - href: string; - name: string; - charset: string; - hreflang: string; - port: string; - host: string; - hash: string; - rev: string; - type: string; - shape: string; - toString(): string; -} -declare var HTMLAnchorElement: { - prototype: HTMLAnchorElement; - new(): HTMLAnchorElement; -} - -interface SVGImageElement extends SVGElement, SVGStylable, SVGTransformable, SVGLangSpace, SVGTests, SVGURIReference { - y: SVGAnimatedLength; - width: SVGAnimatedLength; - preserveAspectRatio: SVGAnimatedPreserveAspectRatio; - x: SVGAnimatedLength; - height: SVGAnimatedLength; -} -declare var SVGImageElement: { - prototype: SVGImageElement; - new(): SVGImageElement; -} - -interface MSElementExtensions { - msMatchesSelector(selectors: string): boolean; - fireEvent(eventName: string, eventObj?: any): boolean; -} - -interface HTMLParamElement extends HTMLElement { - value: string; - name: string; - type: string; - valueType: string; -} -declare var HTMLParamElement: { - prototype: HTMLParamElement; - new(): HTMLParamElement; -} - -interface MSHTMLDocumentViewExtensions { - createStyleSheet(href?: string, index?: number): CSSStyleSheet; -} - -interface SVGAnimatedNumber { - animVal: number; - baseVal: number; -} -declare var SVGAnimatedNumber: { - prototype: SVGAnimatedNumber; - new(): SVGAnimatedNumber; -} - -interface PerformanceTiming { - redirectStart: number; - domainLookupEnd: number; - responseStart: number; - domComplete: number; - domainLookupStart: number; - loadEventStart: number; - msFirstPaint: number; - unloadEventEnd: number; - fetchStart: number; - requestStart: number; - domInteractive: number; - navigationStart: number; - connectEnd: number; - loadEventEnd: number; - connectStart: number; - responseEnd: number; - domLoading: number; - redirectEnd: number; - unloadEventStart: number; - domContentLoadedEventStart: number; - domContentLoadedEventEnd: number; - toJSON(): any; -} -declare var PerformanceTiming: { - prototype: PerformanceTiming; - new(): PerformanceTiming; -} - -interface DOML2DeprecatedAlignmentStyle_HTMLInputElement { - align: string; -} - -interface HTMLPreElement extends HTMLElement, DOML2DeprecatedWidthStyle, MSHTMLPreElementExtensions { -} -declare var HTMLPreElement: { - prototype: HTMLPreElement; - new(): HTMLPreElement; -} - -interface EventException { - code: number; - message: string; - toString(): string; - DISPATCH_REQUEST_ERR: number; - UNSPECIFIED_EVENT_TYPE_ERR: number; -} -declare var EventException: { - prototype: EventException; - new(): EventException; - DISPATCH_REQUEST_ERR: number; - UNSPECIFIED_EVENT_TYPE_ERR: number; -} - -interface MSBorderColorHighlightStyle_HTMLTableCellElement { - borderColorLight: any; - borderColorDark: any; -} - -interface DOMHTMLImplementation { - createHTMLDocument(title: string): Document; -} - -interface NavigatorOnLine { - onLine: boolean; -} - -interface SVGElementEventHandlers { - onmouseover: (ev: MouseEvent) => any; - addEventListener(type: "mouseover", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - onmousemove: (ev: MouseEvent) => any; - addEventListener(type: "mousemove", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - onmouseout: (ev: MouseEvent) => any; - addEventListener(type: "mouseout", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - ondblclick: (ev: MouseEvent) => any; - addEventListener(type: "dblclick", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - onfocusout: (ev: FocusEvent) => any; - addEventListener(type: "focusout", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; - onfocusin: (ev: FocusEvent) => any; - addEventListener(type: "focusin", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; - onmousedown: (ev: MouseEvent) => any; - addEventListener(type: "mousedown", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - onmouseup: (ev: MouseEvent) => any; - addEventListener(type: "mouseup", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - onload: (ev: Event) => any; - addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; - onclick: (ev: MouseEvent) => any; - addEventListener(type: "click", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; -} - -interface WindowLocalStorage { - localStorage: Storage; -} - -interface SVGMetadataElement extends SVGElement { -} -declare var SVGMetadataElement: { - prototype: SVGMetadataElement; - new(): SVGMetadataElement; -} - -interface SVGPathSegArcRel extends SVGPathSeg { - y: number; - sweepFlag: boolean; - r2: number; - x: number; - angle: number; - r1: number; - largeArcFlag: boolean; -} -declare var SVGPathSegArcRel: { - prototype: SVGPathSegArcRel; - new(): SVGPathSegArcRel; -} - -interface SVGPathSegMovetoAbs extends SVGPathSeg { - y: number; - x: number; -} -declare var SVGPathSegMovetoAbs: { - prototype: SVGPathSegMovetoAbs; - new(): SVGPathSegMovetoAbs; -} - -interface SVGStringList { - numberOfItems: number; - replaceItem(newItem: string, index: number): string; - getItem(index: number): string; - clear(): void; - appendItem(newItem: string): string; - initialize(newItem: string): string; - removeItem(index: number): string; - insertItemBefore(newItem: string, index: number): string; -} -declare var SVGStringList: { - prototype: SVGStringList; - new(): SVGStringList; -} - -interface XDomainRequest { - timeout: number; - onerror: (ev: Event) => any; - addEventListener(type: "error", listener: (ev: Event) => any, useCapture?: boolean): void; - onload: (ev: Event) => any; - addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; - onprogress: (ev: any) => any; - addEventListener(type: "progress", listener: (ev: any) => any, useCapture?: boolean): void; - ontimeout: (ev: Event) => any; - addEventListener(type: "timeout", listener: (ev: Event) => any, useCapture?: boolean): void; - responseText: string; - contentType: string; - open(method: string, url: string): void; - abort(): void; - send(data?: any): void; - addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; -} -declare var XDomainRequest: { - prototype: XDomainRequest; - new (): XDomainRequest; -} - -interface DOML2DeprecatedBackgroundColorStyle { - bgColor: any; -} - -interface ElementTraversal { - childElementCount: number; - previousElementSibling: Element; - lastElementChild: Element; - nextElementSibling: Element; - firstElementChild: Element; -} - -interface SVGLength { - valueAsString: string; - valueInSpecifiedUnits: number; - value: number; - unitType: number; - newValueSpecifiedUnits(unitType: number, valueInSpecifiedUnits: number): void; - convertToSpecifiedUnits(unitType: number): void; - SVG_LENGTHTYPE_NUMBER: number; - SVG_LENGTHTYPE_CM: number; - SVG_LENGTHTYPE_PC: number; - SVG_LENGTHTYPE_PERCENTAGE: number; - SVG_LENGTHTYPE_MM: number; - SVG_LENGTHTYPE_PT: number; - SVG_LENGTHTYPE_IN: number; - SVG_LENGTHTYPE_EMS: number; - SVG_LENGTHTYPE_PX: number; - SVG_LENGTHTYPE_UNKNOWN: number; - SVG_LENGTHTYPE_EXS: number; -} -declare var SVGLength: { - prototype: SVGLength; - new(): SVGLength; - SVG_LENGTHTYPE_NUMBER: number; - SVG_LENGTHTYPE_CM: number; - SVG_LENGTHTYPE_PC: number; - SVG_LENGTHTYPE_PERCENTAGE: number; - SVG_LENGTHTYPE_MM: number; - SVG_LENGTHTYPE_PT: number; - SVG_LENGTHTYPE_IN: number; - SVG_LENGTHTYPE_EMS: number; - SVG_LENGTHTYPE_PX: number; - SVG_LENGTHTYPE_UNKNOWN: number; - SVG_LENGTHTYPE_EXS: number; -} - -interface SVGPolygonElement extends SVGElement, SVGStylable, SVGTransformable, SVGLangSpace, SVGAnimatedPoints, SVGTests { -} -declare var SVGPolygonElement: { - prototype: SVGPolygonElement; - new(): SVGPolygonElement; -} - -interface HTMLPhraseElement extends HTMLElement { - dateTime: string; - cite: string; -} -declare var HTMLPhraseElement: { - prototype: HTMLPhraseElement; - new(): HTMLPhraseElement; -} - -interface MSHTMLAreaElementExtensions { -} - -interface SVGPathSegCurvetoCubicRel extends SVGPathSeg { - y: number; - y1: number; - x2: number; - x: number; - x1: number; - y2: number; -} -declare var SVGPathSegCurvetoCubicRel: { - prototype: SVGPathSegCurvetoCubicRel; - new(): SVGPathSegCurvetoCubicRel; -} - -interface MSEventObj extends Event { - nextPage: string; - keyCode: number; - toElement: Element; - returnValue: any; - dataFld: string; - y: number; - dataTransfer: DataTransfer; - propertyName: string; - url: string; - offsetX: number; - recordset: Object; - screenX: number; - buttonID: number; - wheelDelta: number; - reason: number; - origin: string; - data: string; - srcFilter: Object; - boundElements: HTMLCollection; - cancelBubble: boolean; - altLeft: boolean; - behaviorCookie: number; - bookmarks: BookmarkCollection; - type: string; - repeat: boolean; - srcElement: Element; - source: Window; - fromElement: Element; - offsetY: number; - x: number; - behaviorPart: number; - qualifier: string; - altKey: boolean; - ctrlKey: boolean; - clientY: number; - shiftKey: boolean; - shiftLeft: boolean; - contentOverflow: boolean; - screenY: number; - ctrlLeft: boolean; - button: number; - srcUrn: string; - clientX: number; - actionURL: string; - getAttribute(strAttributeName: string, lFlags?: number): any; - setAttribute(strAttributeName: string, AttributeValue: any, lFlags?: number): void; - removeAttribute(strAttributeName: string, lFlags?: number): boolean; -} -declare var MSEventObj: { - prototype: MSEventObj; - new(): MSEventObj; -} - -interface SVGTextContentElement extends SVGElement, SVGStylable, SVGLangSpace, SVGTests { - textLength: SVGAnimatedLength; - lengthAdjust: SVGAnimatedEnumeration; - getCharNumAtPosition(point: SVGPoint): number; - getStartPositionOfChar(charnum: number): SVGPoint; - getExtentOfChar(charnum: number): SVGRect; - getComputedTextLength(): number; - getSubStringLength(charnum: number, nchars: number): number; - selectSubString(charnum: number, nchars: number): void; - getNumberOfChars(): number; - getRotationOfChar(charnum: number): number; - getEndPositionOfChar(charnum: number): SVGPoint; - LENGTHADJUST_SPACING: number; - LENGTHADJUST_SPACINGANDGLYPHS: number; - LENGTHADJUST_UNKNOWN: number; -} -declare var SVGTextContentElement: { - prototype: SVGTextContentElement; - new(): SVGTextContentElement; - LENGTHADJUST_SPACING: number; - LENGTHADJUST_SPACINGANDGLYPHS: number; - LENGTHADJUST_UNKNOWN: number; -} - -interface DOML2DeprecatedColorProperty { - color: string; -} - -interface MSHTMLLIElementExtensions { -} - -interface HTMLCanvasElement extends HTMLElement { - width: number; - height: number; - toDataURL(): string; - toDataURL(type: string, ...args: any[]): string; - getContext(contextId: string): any; - getContext(contextId: "2d"): CanvasRenderingContext2D; -} -declare var HTMLCanvasElement: { - prototype: HTMLCanvasElement; - new(): HTMLCanvasElement; -} - -interface HTMLTitleElement extends HTMLElement { - text: string; -} -declare var HTMLTitleElement: { - prototype: HTMLTitleElement; - new(): HTMLTitleElement; -} - -interface Location { - hash: string; - protocol: string; - search: string; - href: string; - hostname: string; - port: string; - pathname: string; - host: string; - reload(flag?: boolean): void; - replace(url: string): void; - assign(url: string): void; - toString(): string; -} -declare var Location: { - prototype: Location; - new(): Location; -} - -interface HTMLStyleElement extends HTMLElement, MSLinkStyleExtensions, LinkStyle { - media: string; - type: string; -} -declare var HTMLStyleElement: { - prototype: HTMLStyleElement; - new(): HTMLStyleElement; -} - -interface MSHTMLOptGroupElementExtensions { - index: number; - defaultSelected: boolean; - text: string; - value: string; - form: HTMLFormElement; - selected: boolean; -} - -interface MSBorderColorHighlightStyle { - borderColorLight: any; - borderColorDark: any; -} - -interface DOML2DeprecatedSizeProperty_HTMLBaseFontElement { - size: number; -} - -interface SVGTransform { - type: number; - angle: number; - matrix: SVGMatrix; - setTranslate(tx: number, ty: number): void; - setScale(sx: number, sy: number): void; - setMatrix(matrix: SVGMatrix): void; - setSkewY(angle: number): void; - setRotate(angle: number, cx: number, cy: number): void; - setSkewX(angle: number): void; - SVG_TRANSFORM_SKEWX: number; - SVG_TRANSFORM_UNKNOWN: number; - SVG_TRANSFORM_SCALE: number; - SVG_TRANSFORM_TRANSLATE: number; - SVG_TRANSFORM_MATRIX: number; - SVG_TRANSFORM_ROTATE: number; - SVG_TRANSFORM_SKEWY: number; -} -declare var SVGTransform: { - prototype: SVGTransform; - new(): SVGTransform; - SVG_TRANSFORM_SKEWX: number; - SVG_TRANSFORM_UNKNOWN: number; - SVG_TRANSFORM_SCALE: number; - SVG_TRANSFORM_TRANSLATE: number; - SVG_TRANSFORM_MATRIX: number; - SVG_TRANSFORM_ROTATE: number; - SVG_TRANSFORM_SKEWY: number; -} - -interface MSCSSFilter { - Percent: number; - Enabled: boolean; - Duration: number; - Play(Duration: number): void; - Apply(): void; - Stop(): void; -} -declare var MSCSSFilter: { - prototype: MSCSSFilter; - new(): MSCSSFilter; -} - -interface UIEvent extends Event { - detail: number; - view: AbstractView; - initUIEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: AbstractView, detailArg: number): void; -} -declare var UIEvent: { - prototype: UIEvent; - new(): UIEvent; -} - -interface ViewCSS_SVGSVGElement { - getComputedStyle(elt: Element, pseudoElt?: string): CSSStyleDeclaration; -} - -interface SVGURIReference { - href: SVGAnimatedString; -} - -interface SVGPathSeg { - pathSegType: number; - pathSegTypeAsLetter: string; - PATHSEG_MOVETO_REL: number; - PATHSEG_LINETO_VERTICAL_REL: number; - PATHSEG_CURVETO_CUBIC_SMOOTH_ABS: number; - PATHSEG_CURVETO_QUADRATIC_REL: number; - PATHSEG_CURVETO_CUBIC_ABS: number; - PATHSEG_LINETO_HORIZONTAL_ABS: number; - PATHSEG_CURVETO_QUADRATIC_ABS: number; - PATHSEG_LINETO_ABS: number; - PATHSEG_CLOSEPATH: number; - PATHSEG_LINETO_HORIZONTAL_REL: number; - PATHSEG_CURVETO_CUBIC_SMOOTH_REL: number; - PATHSEG_LINETO_REL: number; - PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS: number; - PATHSEG_ARC_REL: number; - PATHSEG_CURVETO_CUBIC_REL: number; - PATHSEG_UNKNOWN: number; - PATHSEG_LINETO_VERTICAL_ABS: number; - PATHSEG_ARC_ABS: number; - PATHSEG_MOVETO_ABS: number; - PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL: number; -} -declare var SVGPathSeg: { - PATHSEG_MOVETO_REL: number; - PATHSEG_LINETO_VERTICAL_REL: number; - PATHSEG_CURVETO_CUBIC_SMOOTH_ABS: number; - PATHSEG_CURVETO_QUADRATIC_REL: number; - PATHSEG_CURVETO_CUBIC_ABS: number; - PATHSEG_LINETO_HORIZONTAL_ABS: number; - PATHSEG_CURVETO_QUADRATIC_ABS: number; - PATHSEG_LINETO_ABS: number; - PATHSEG_CLOSEPATH: number; - PATHSEG_LINETO_HORIZONTAL_REL: number; - PATHSEG_CURVETO_CUBIC_SMOOTH_REL: number; - PATHSEG_LINETO_REL: number; - PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS: number; - PATHSEG_ARC_REL: number; - PATHSEG_CURVETO_CUBIC_REL: number; - PATHSEG_UNKNOWN: number; - PATHSEG_LINETO_VERTICAL_ABS: number; - PATHSEG_ARC_ABS: number; - PATHSEG_MOVETO_ABS: number; - PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL: number; -} - -interface WheelEvent extends MouseEvent { - deltaZ: number; - deltaX: number; - deltaMode: number; - deltaY: number; - initWheelEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: AbstractView, detailArg: number, screenXArg: number, screenYArg: number, clientXArg: number, clientYArg: number, buttonArg: number, relatedTargetArg: EventTarget, modifiersListArg: string, deltaXArg: number, deltaYArg: number, deltaZArg: number, deltaMode: number): void; - DOM_DELTA_PIXEL: number; - DOM_DELTA_LINE: number; - DOM_DELTA_PAGE: number; -} -declare var WheelEvent: { - prototype: WheelEvent; - new(): WheelEvent; - DOM_DELTA_PIXEL: number; - DOM_DELTA_LINE: number; - DOM_DELTA_PAGE: number; -} - -interface DOML2DeprecatedAlignmentStyle_HTMLDivElement { - align: string; -} - -interface MSEventAttachmentTarget { - attachEvent(event: string, listener: EventListener): boolean; - detachEvent(event: string, listener: EventListener): void; -} - -interface SVGNumber { - value: number; -} -declare var SVGNumber: { - prototype: SVGNumber; - new(): SVGNumber; -} - -interface SVGPathElement extends SVGElement, SVGStylable, SVGAnimatedPathData, SVGTransformable, SVGLangSpace, SVGTests { - getPathSegAtLength(distance: number): number; - getPointAtLength(distance: number): SVGPoint; - createSVGPathSegCurvetoQuadraticAbs(x: number, y: number, x1: number, y1: number): SVGPathSegCurvetoQuadraticAbs; - createSVGPathSegLinetoRel(x: number, y: number): SVGPathSegLinetoRel; - createSVGPathSegCurvetoQuadraticRel(x: number, y: number, x1: number, y1: number): SVGPathSegCurvetoQuadraticRel; - createSVGPathSegCurvetoCubicAbs(x: number, y: number, x1: number, y1: number, x2: number, y2: number): SVGPathSegCurvetoCubicAbs; - createSVGPathSegLinetoAbs(x: number, y: number): SVGPathSegLinetoAbs; - createSVGPathSegClosePath(): SVGPathSegClosePath; - createSVGPathSegCurvetoCubicRel(x: number, y: number, x1: number, y1: number, x2: number, y2: number): SVGPathSegCurvetoCubicRel; - createSVGPathSegCurvetoQuadraticSmoothRel(x: number, y: number): SVGPathSegCurvetoQuadraticSmoothRel; - createSVGPathSegMovetoRel(x: number, y: number): SVGPathSegMovetoRel; - createSVGPathSegCurvetoCubicSmoothAbs(x: number, y: number, x2: number, y2: number): SVGPathSegCurvetoCubicSmoothAbs; - createSVGPathSegMovetoAbs(x: number, y: number): SVGPathSegMovetoAbs; - createSVGPathSegLinetoVerticalRel(y: number): SVGPathSegLinetoVerticalRel; - createSVGPathSegArcRel(x: number, y: number, r1: number, r2: number, angle: number, largeArcFlag: boolean, sweepFlag: boolean): SVGPathSegArcRel; - createSVGPathSegCurvetoQuadraticSmoothAbs(x: number, y: number): SVGPathSegCurvetoQuadraticSmoothAbs; - createSVGPathSegLinetoHorizontalRel(x: number): SVGPathSegLinetoHorizontalRel; - getTotalLength(): number; - createSVGPathSegCurvetoCubicSmoothRel(x: number, y: number, x2: number, y2: number): SVGPathSegCurvetoCubicSmoothRel; - createSVGPathSegLinetoHorizontalAbs(x: number): SVGPathSegLinetoHorizontalAbs; - createSVGPathSegLinetoVerticalAbs(y: number): SVGPathSegLinetoVerticalAbs; - createSVGPathSegArcAbs(x: number, y: number, r1: number, r2: number, angle: number, largeArcFlag: boolean, sweepFlag: boolean): SVGPathSegArcAbs; -} -declare var SVGPathElement: { - prototype: SVGPathElement; - new(): SVGPathElement; -} - -interface MSCompatibleInfo { - version: string; - userAgent: string; -} -declare var MSCompatibleInfo: { - prototype: MSCompatibleInfo; - new(): MSCompatibleInfo; -} - -interface MSHTMLDocumentEventExtensions { - createEventObject(eventObj?: any): MSEventObj; - fireEvent(eventName: string, eventObj?: any): boolean; -} - -interface Text extends CharacterData, MSNodeExtensions { - wholeText: string; - splitText(offset: number): Text; - replaceWholeText(content: string): Text; -} -declare var Text: { - prototype: Text; - new(): Text; -} - -interface SVGAnimatedRect { - animVal: SVGRect; - baseVal: SVGRect; -} -declare var SVGAnimatedRect: { - prototype: SVGAnimatedRect; - new(): SVGAnimatedRect; -} - -interface CSSNamespaceRule extends CSSRule { - namespaceURI: string; - prefix: string; -} -declare var CSSNamespaceRule: { - prototype: CSSNamespaceRule; - new(): CSSNamespaceRule; -} - -interface HTMLUnknownElement extends HTMLElement, MSDataBindingRecordSetReadonlyExtensions, MSHTMLUnknownElementExtensions { -} -declare var HTMLUnknownElement: { - prototype: HTMLUnknownElement; - new(): HTMLUnknownElement; -} - -interface SVGPathSegList { - numberOfItems: number; - replaceItem(newItem: SVGPathSeg, index: number): SVGPathSeg; - getItem(index: number): SVGPathSeg; - clear(): void; - appendItem(newItem: SVGPathSeg): SVGPathSeg; - initialize(newItem: SVGPathSeg): SVGPathSeg; - removeItem(index: number): SVGPathSeg; - insertItemBefore(newItem: SVGPathSeg, index: number): SVGPathSeg; -} -declare var SVGPathSegList: { - prototype: SVGPathSegList; - new(): SVGPathSegList; -} - -interface HTMLAudioElement extends HTMLMediaElement { -} -declare var HTMLAudioElement: { - prototype: HTMLAudioElement; - new(): HTMLAudioElement; -} - -interface MSImageResourceExtensions { - dynsrc: string; - vrml: string; - lowsrc: string; - start: string; - loop: number; -} - -interface MSBorderColorHighlightStyle_HTMLTableRowElement { - borderColorLight: any; - borderColorDark: any; -} - -interface PositionError { - code: number; - message: string; - toString(): string; - POSITION_UNAVAILABLE: number; - PERMISSION_DENIED: number; - TIMEOUT: number; -} -declare var PositionError: { - POSITION_UNAVAILABLE: number; - PERMISSION_DENIED: number; - TIMEOUT: number; -} - -interface BrowserPublic { -} -declare var BrowserPublic: { - prototype: BrowserPublic; - new(): BrowserPublic; -} - -interface HTMLTableCellElement extends HTMLElement, DOML2DeprecatedTableCellHeight, HTMLTableAlignment, MSBorderColorHighlightStyle_HTMLTableCellElement, DOML2DeprecatedWidthStyle_HTMLTableCellElement, DOML2DeprecatedBackgroundStyle, MSBorderColorStyle_HTMLTableCellElement, MSHTMLTableCellElementExtensions, DOML2DeprecatedAlignmentStyle_HTMLTableCellElement, HTMLTableHeaderCellScope, DOML2DeprecatedWordWrapSuppression, DOML2DeprecatedBackgroundColorStyle { - headers: string; - abbr: string; - rowSpan: number; - cellIndex: number; - colSpan: number; - axis: string; -} -declare var HTMLTableCellElement: { - prototype: HTMLTableCellElement; - new(): HTMLTableCellElement; -} - -interface MSNamespaceInfoCollection { - length: number; - add(namespace?: string, urn?: string, implementationUrl?: any): Object; - item(index: any): Object; - [index: string]: Object; - (index: any): Object; -} -declare var MSNamespaceInfoCollection: { - prototype: MSNamespaceInfoCollection; - new(): MSNamespaceInfoCollection; -} - -interface SVGElementInstance extends EventTarget { - previousSibling: SVGElementInstance; - parentNode: SVGElementInstance; - lastChild: SVGElementInstance; - nextSibling: SVGElementInstance; - childNodes: SVGElementInstanceList; - correspondingUseElement: SVGUseElement; - correspondingElement: SVGElement; - firstChild: SVGElementInstance; -} -declare var SVGElementInstance: { - prototype: SVGElementInstance; - new(): SVGElementInstance; -} - -interface MSHTMLUListElementExtensions { -} - -interface SVGCircleElement extends SVGElement, SVGStylable, SVGTransformable, SVGLangSpace, SVGTests { - cx: SVGAnimatedLength; - r: SVGAnimatedLength; - cy: SVGAnimatedLength; -} -declare var SVGCircleElement: { - prototype: SVGCircleElement; - new(): SVGCircleElement; -} - -interface HTMLBaseFontElement extends HTMLElement, DOML2DeprecatedSizeProperty_HTMLBaseFontElement, DOML2DeprecatedColorProperty { - face: string; -} -declare var HTMLBaseFontElement: { - prototype: HTMLBaseFontElement; - new(): HTMLBaseFontElement; -} - -interface CustomEvent extends Event { - detail: Object; - initCustomEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, detailArg: Object): void; -} -declare var CustomEvent: { - prototype: CustomEvent; - new(): CustomEvent; -} - -interface CSSImportRule extends CSSRule { - styleSheet: CSSStyleSheet; - href: string; - media: MediaList; -} -declare var CSSImportRule: { - prototype: CSSImportRule; - new(): CSSImportRule; -} - -interface StyleSheetList { - length: number; - item(index?: number): StyleSheet; - [index: number]: StyleSheet; -} -declare var StyleSheetList: { - prototype: StyleSheetList; - new(): StyleSheetList; -} - -interface HTMLTextAreaElement extends HTMLElement, MSDataBindingExtensions, MSHTMLTextAreaElementExtensions { - value: string; - form: HTMLFormElement; - name: string; - selectionStart: number; - rows: number; - cols: number; - readOnly: boolean; - wrap: string; - selectionEnd: number; - type: string; - defaultValue: string; - setSelectionRange(start: number, end: number): void; - select(): void; -} -declare var HTMLTextAreaElement: { - prototype: HTMLTextAreaElement; - new(): HTMLTextAreaElement; -} - -interface MSHTMLFormElementExtensions { - encoding: string; -} - -interface DOML2DeprecatedMarginStyle { - vspace: number; - hspace: number; -} - -interface Geolocation { - clearWatch(watchId: number): void; - getCurrentPosition(successCallback: PositionCallback, errorCallback?: PositionErrorCallback, options?: PositionOptions): void; - watchPosition(successCallback: PositionCallback, errorCallback?: PositionErrorCallback, options?: PositionOptions): number; -} -declare var Geolocation: { - prototype: Geolocation; - new(): Geolocation; -} - -interface MSWindowModeless { - dialogTop: any; - dialogLeft: any; - dialogWidth: any; - dialogHeight: any; - menuArguments: any; -} - -interface HTMLMarqueeElement extends HTMLElement, DOML2DeprecatedMarginStyle_HTMLMarqueeElement, MSDataBindingExtensions, MSHTMLMarqueeElementExtensions, DOML2DeprecatedBackgroundColorStyle { - width: string; - onbounce: (ev: Event) => any; - addEventListener(type: "bounce", listener: (ev: Event) => any, useCapture?: boolean): void; - trueSpeed: boolean; - scrollAmount: number; - scrollDelay: number; - behavior: string; - height: string; - loop: number; - direction: string; - onstart: (ev: Event) => any; - addEventListener(type: "start", listener: (ev: Event) => any, useCapture?: boolean): void; - onfinish: (ev: Event) => any; - addEventListener(type: "finish", listener: (ev: Event) => any, useCapture?: boolean): void; - stop(): void; - start(): void; - addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; -} -declare var HTMLMarqueeElement: { - prototype: HTMLMarqueeElement; - new(): HTMLMarqueeElement; -} - -interface SVGRect { - y: number; - width: number; - x: number; - height: number; -} -declare var SVGRect: { - prototype: SVGRect; - new(): SVGRect; -} - -interface MSNodeExtensions { - swapNode(otherNode: Node): Node; - removeNode(deep?: boolean): Node; - replaceNode(replacement: Node): Node; -} - -interface KeyboardEventExtensions { - keyCode: number; - which: number; - charCode: number; -} - -interface History { - length: number; - back(distance?: any): void; - forward(distance?: any): void; - go(delta?: any): void; -} -declare var History: { - prototype: History; - new(): History; -} - -interface DocumentStyle { - styleSheets: StyleSheetList; -} - -interface SVGPathSegCurvetoCubicAbs extends SVGPathSeg { - y: number; - y1: number; - x2: number; - x: number; - x1: number; - y2: number; -} -declare var SVGPathSegCurvetoCubicAbs: { - prototype: SVGPathSegCurvetoCubicAbs; - new(): SVGPathSegCurvetoCubicAbs; -} - -interface TimeRanges { - length: number; - start(index: number): number; - end(index: number): number; -} -declare var TimeRanges: { - prototype: TimeRanges; - new(): TimeRanges; -} - -interface SVGPathSegCurvetoQuadraticAbs extends SVGPathSeg { - y: number; - y1: number; - x: number; - x1: number; -} -declare var SVGPathSegCurvetoQuadraticAbs: { - prototype: SVGPathSegCurvetoQuadraticAbs; - new(): SVGPathSegCurvetoQuadraticAbs; -} - -interface MSHTMLSelectElementExtensions { -} - -interface CSSRule { - cssText: string; - parentStyleSheet: CSSStyleSheet; - parentRule: CSSRule; - type: number; - IMPORT_RULE: number; - MEDIA_RULE: number; - STYLE_RULE: number; - NAMESPACE_RULE: number; - PAGE_RULE: number; - UNKNOWN_RULE: number; - FONT_FACE_RULE: number; - CHARSET_RULE: number; -} -declare var CSSRule: { - prototype: CSSRule; - new(): CSSRule; - IMPORT_RULE: number; - MEDIA_RULE: number; - STYLE_RULE: number; - NAMESPACE_RULE: number; - PAGE_RULE: number; - UNKNOWN_RULE: number; - FONT_FACE_RULE: number; - CHARSET_RULE: number; -} - -interface SVGPathSegLinetoAbs extends SVGPathSeg { - y: number; - x: number; -} -declare var SVGPathSegLinetoAbs: { - prototype: SVGPathSegLinetoAbs; - new(): SVGPathSegLinetoAbs; -} - -interface MSMouseEventExtensions { - toElement: Element; - layerY: number; - fromElement: Element; - which: number; - layerX: number; -} - -interface HTMLModElement extends HTMLElement, MSHTMLModElementExtensions { - dateTime: string; - cite: string; -} -declare var HTMLModElement: { - prototype: HTMLModElement; - new(): HTMLModElement; -} - -interface DOML2DeprecatedWordWrapSuppression { - noWrap: boolean; -} - -interface BeforeUnloadEvent extends Event { - returnValue: string; -} -declare var BeforeUnloadEvent: { - prototype: BeforeUnloadEvent; - new(): BeforeUnloadEvent; -} - -interface MSPopupWindow { - document: HTMLDocument; - isOpen: boolean; - show(x: number, y: number, w: number, h: number, element?: any): void; - hide(): void; -} -declare var MSPopupWindow: { - prototype: MSPopupWindow; - new(): MSPopupWindow; -} - -interface SVGMatrix { - e: number; - c: number; - a: number; - b: number; - d: number; - f: number; - multiply(secondMatrix: SVGMatrix): SVGMatrix; - flipY(): SVGMatrix; - skewY(angle: number): SVGMatrix; - inverse(): SVGMatrix; - scaleNonUniform(scaleFactorX: number, scaleFactorY: number): SVGMatrix; - rotate(angle: number): SVGMatrix; - flipX(): SVGMatrix; - translate(x: number, y: number): SVGMatrix; - scale(scaleFactor: number): SVGMatrix; - rotateFromVector(x: number, y: number): SVGMatrix; - skewX(angle: number): SVGMatrix; -} -declare var SVGMatrix: { - prototype: SVGMatrix; - new(): SVGMatrix; -} - -interface SVGUseElement extends SVGElement, SVGStylable, SVGTransformable, SVGLangSpace, SVGTests, SVGURIReference { - y: SVGAnimatedLength; - width: SVGAnimatedLength; - animatedInstanceRoot: SVGElementInstance; - instanceRoot: SVGElementInstance; - x: SVGAnimatedLength; - height: SVGAnimatedLength; -} -declare var SVGUseElement: { - prototype: SVGUseElement; - new(): SVGUseElement; -} - -interface Event extends MSEventExtensions { - timeStamp: number; - defaultPrevented: boolean; - isTrusted: boolean; - currentTarget: EventTarget; - target: EventTarget; - eventPhase: number; - type: string; - cancelable: boolean; - bubbles: boolean; - initEvent(eventTypeArg: string, canBubbleArg: boolean, cancelableArg: boolean): void; - stopPropagation(): void; - stopImmediatePropagation(): void; - preventDefault(): void; - CAPTURING_PHASE: number; - AT_TARGET: number; - BUBBLING_PHASE: number; -} -declare var Event: { - prototype: Event; - new(): Event; - CAPTURING_PHASE: number; - AT_TARGET: number; - BUBBLING_PHASE: number; -} - -interface ImageData { - width: number; - data: number[]; - height: number; -} -declare var ImageData: { - prototype: ImageData; - new(): ImageData; -} - -interface MSHTMLElementExtensions { - onlosecapture: (ev: MSEventObj) => any; - addEventListener(type: "losecapture", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - onrowexit: (ev: MSEventObj) => any; - addEventListener(type: "rowexit", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - oncontrolselect: (ev: MSEventObj) => any; - addEventListener(type: "controlselect", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - onrowsinserted: (ev: MSEventObj) => any; - addEventListener(type: "rowsinserted", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - onmouseleave: (ev: MouseEvent) => any; - addEventListener(type: "mouseleave", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - document: HTMLDocument; - behaviorUrns: MSBehaviorUrnsCollection; - onpropertychange: (ev: MSEventObj) => any; - addEventListener(type: "propertychange", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - children: HTMLCollection; - filters: Object; - onbeforecut: (ev: DragEvent) => any; - addEventListener(type: "beforecut", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - scopeName: string; - onbeforepaste: (ev: DragEvent) => any; - addEventListener(type: "beforepaste", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - onmove: (ev: MSEventObj) => any; - addEventListener(type: "move", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - onafterupdate: (ev: MSEventObj) => any; - addEventListener(type: "afterupdate", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - onbeforecopy: (ev: DragEvent) => any; - addEventListener(type: "beforecopy", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - onlayoutcomplete: (ev: MSEventObj) => any; - addEventListener(type: "layoutcomplete", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - onresizeend: (ev: MSEventObj) => any; - addEventListener(type: "resizeend", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - uniqueID: string; - onhelp: (ev: Event) => any; - addEventListener(type: "help", listener: (ev: Event) => any, useCapture?: boolean): void; - onbeforeactivate: (ev: UIEvent) => any; - addEventListener(type: "beforeactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - isMultiLine: boolean; - uniqueNumber: number; - tagUrn: string; - onfocusout: (ev: FocusEvent) => any; - addEventListener(type: "focusout", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; - ondataavailable: (ev: MSEventObj) => any; - addEventListener(type: "dataavailable", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - hideFocus: boolean; - onbeforeupdate: (ev: MSEventObj) => any; - addEventListener(type: "beforeupdate", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - onfilterchange: (ev: MSEventObj) => any; - addEventListener(type: "filterchange", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - onfocusin: (ev: FocusEvent) => any; - addEventListener(type: "focusin", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; - recordNumber: any; - parentTextEdit: Element; - ondatasetcomplete: (ev: MSEventObj) => any; - addEventListener(type: "datasetcomplete", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - onbeforedeactivate: (ev: UIEvent) => any; - addEventListener(type: "beforedeactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - outerText: string; - onresizestart: (ev: MSEventObj) => any; - addEventListener(type: "resizestart", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - onactivate: (ev: UIEvent) => any; - addEventListener(type: "activate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - isTextEdit: boolean; - isDisabled: boolean; - readyState: string; - all: HTMLCollection; - onmouseenter: (ev: MouseEvent) => any; - addEventListener(type: "mouseenter", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - onmovestart: (ev: MSEventObj) => any; - addEventListener(type: "movestart", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - onselectstart: (ev: Event) => any; - addEventListener(type: "selectstart", listener: (ev: Event) => any, useCapture?: boolean): void; - onpaste: (ev: DragEvent) => any; - addEventListener(type: "paste", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - canHaveHTML: boolean; - innerText: string; - onerrorupdate: (ev: MSEventObj) => any; - addEventListener(type: "errorupdate", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - ondeactivate: (ev: UIEvent) => any; - addEventListener(type: "deactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - oncut: (ev: DragEvent) => any; - addEventListener(type: "cut", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - onmoveend: (ev: MSEventObj) => any; - addEventListener(type: "moveend", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - onresize: (ev: UIEvent) => any; - addEventListener(type: "resize", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - language: string; - ondatasetchanged: (ev: MSEventObj) => any; - addEventListener(type: "datasetchanged", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - oncopy: (ev: DragEvent) => any; - addEventListener(type: "copy", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - onrowsdelete: (ev: MSEventObj) => any; - addEventListener(type: "rowsdelete", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - parentElement: HTMLElement; - onrowenter: (ev: MSEventObj) => any; - addEventListener(type: "rowenter", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - onbeforeeditfocus: (ev: MSEventObj) => any; - addEventListener(type: "beforeeditfocus", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - canHaveChildren: boolean; - sourceIndex: number; - oncellchange: (ev: MSEventObj) => any; - addEventListener(type: "cellchange", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - dragDrop(): boolean; - releaseCapture(): void; - addFilter(filter: Object): void; - setCapture(containerCapture?: boolean): void; - removeBehavior(cookie: number): boolean; - contains(child: HTMLElement): boolean; - applyElement(apply: Element, where?: string): Element; - replaceAdjacentText(where: string, newText: string): string; - mergeAttributes(source: HTMLElement, preserveIdentity?: boolean): void; - insertAdjacentElement(position: string, insertedElement: Element): Element; - insertAdjacentText(where: string, text: string): void; - getAdjacentText(where: string): string; - removeFilter(filter: Object): void; - setActive(): void; - addBehavior(bstrUrl: string, factory?: any): number; - clearAttributes(): void; - addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; -} - -interface HTMLTableColElement extends HTMLElement, MSHTMLTableColElementExtensions, HTMLTableAlignment, DOML2DeprecatedAlignmentStyle_HTMLTableColElement { - width: any; - span: number; -} -declare var HTMLTableColElement: { - prototype: HTMLTableColElement; - new(): HTMLTableColElement; -} - -interface HTMLDocument extends MSEventAttachmentTarget, MSHTMLDocumentSelection, MSHTMLDocumentExtensions, MSNodeExtensions, MSResourceMetadata, MSHTMLDocumentEventExtensions, MSHTMLDocumentViewExtensions { - ondragend: (ev: DragEvent) => any; - addEventListener(type: "dragend", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - ondragover: (ev: DragEvent) => any; - addEventListener(type: "dragover", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - onkeydown: (ev: KeyboardEvent) => any; - addEventListener(type: "keydown", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; - bgColor: string; - onkeyup: (ev: KeyboardEvent) => any; - addEventListener(type: "keyup", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; - onreset: (ev: Event) => any; - addEventListener(type: "reset", listener: (ev: Event) => any, useCapture?: boolean): void; - onmouseup: (ev: MouseEvent) => any; - addEventListener(type: "mouseup", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - ondragstart: (ev: DragEvent) => any; - addEventListener(type: "dragstart", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - scripts: HTMLCollection; - ondrag: (ev: DragEvent) => any; - addEventListener(type: "drag", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - linkColor: string; - ondragleave: (ev: DragEvent) => any; - addEventListener(type: "dragleave", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - onmouseover: (ev: MouseEvent) => any; - addEventListener(type: "mouseover", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - onpause: (ev: Event) => any; - addEventListener(type: "pause", listener: (ev: Event) => any, useCapture?: boolean): void; - charset: string; - vlinkColor: string; - onmousedown: (ev: MouseEvent) => any; - addEventListener(type: "mousedown", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - onseeked: (ev: Event) => any; - addEventListener(type: "seeked", listener: (ev: Event) => any, useCapture?: boolean): void; - title: string; - onclick: (ev: MouseEvent) => any; - addEventListener(type: "click", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - onwaiting: (ev: Event) => any; - addEventListener(type: "waiting", listener: (ev: Event) => any, useCapture?: boolean): void; - defaultCharset: string; - embeds: HTMLCollection; - ondurationchange: (ev: Event) => any; - addEventListener(type: "durationchange", listener: (ev: Event) => any, useCapture?: boolean): void; - all: HTMLCollection; - applets: HTMLCollection; - forms: HTMLCollection; - onblur: (ev: FocusEvent) => any; - addEventListener(type: "blur", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; - dir: string; - body: HTMLElement; - designMode: string; - onemptied: (ev: Event) => any; - addEventListener(type: "emptied", listener: (ev: Event) => any, useCapture?: boolean): void; - domain: string; - onseeking: (ev: Event) => any; - addEventListener(type: "seeking", listener: (ev: Event) => any, useCapture?: boolean): void; - oncanplay: (ev: Event) => any; - addEventListener(type: "canplay", listener: (ev: Event) => any, useCapture?: boolean): void; - onstalled: (ev: Event) => any; - addEventListener(type: "stalled", listener: (ev: Event) => any, useCapture?: boolean): void; - onmousemove: (ev: MouseEvent) => any; - addEventListener(type: "mousemove", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - onratechange: (ev: Event) => any; - addEventListener(type: "ratechange", listener: (ev: Event) => any, useCapture?: boolean): void; - onloadstart: (ev: Event) => any; - addEventListener(type: "loadstart", listener: (ev: Event) => any, useCapture?: boolean): void; - ondragenter: (ev: DragEvent) => any; - addEventListener(type: "dragenter", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - onsubmit: (ev: Event) => any; - addEventListener(type: "submit", listener: (ev: Event) => any, useCapture?: boolean): void; - onprogress: (ev: any) => any; - addEventListener(type: "progress", listener: (ev: any) => any, useCapture?: boolean): void; - ondblclick: (ev: MouseEvent) => any; - addEventListener(type: "dblclick", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - oncontextmenu: (ev: MouseEvent) => any; - addEventListener(type: "contextmenu", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - activeElement: Element; - onchange: (ev: Event) => any; - addEventListener(type: "change", listener: (ev: Event) => any, useCapture?: boolean): void; - onloadedmetadata: (ev: Event) => any; - addEventListener(type: "loadedmetadata", listener: (ev: Event) => any, useCapture?: boolean): void; - onerror: (ev: Event) => any; - addEventListener(type: "error", listener: (ev: Event) => any, useCapture?: boolean): void; - onplay: (ev: Event) => any; - addEventListener(type: "play", listener: (ev: Event) => any, useCapture?: boolean): void; - links: HTMLCollection; - onplaying: (ev: Event) => any; - addEventListener(type: "playing", listener: (ev: Event) => any, useCapture?: boolean): void; - URL: string; - images: HTMLCollection; - head: HTMLHeadElement; - location: Location; - cookie: string; - oncanplaythrough: (ev: Event) => any; - addEventListener(type: "canplaythrough", listener: (ev: Event) => any, useCapture?: boolean): void; - onabort: (ev: UIEvent) => any; - addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - characterSet: string; - anchors: HTMLCollection; - lastModified: string; - onreadystatechange: (ev: Event) => any; - addEventListener(type: "readystatechange", listener: (ev: Event) => any, useCapture?: boolean): void; - onkeypress: (ev: KeyboardEvent) => any; - addEventListener(type: "keypress", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; - onloadeddata: (ev: Event) => any; - addEventListener(type: "loadeddata", listener: (ev: Event) => any, useCapture?: boolean): void; - plugins: HTMLCollection; - onsuspend: (ev: Event) => any; - addEventListener(type: "suspend", listener: (ev: Event) => any, useCapture?: boolean): void; - referrer: string; - readyState: string; - alinkColor: string; - onfocus: (ev: FocusEvent) => any; - addEventListener(type: "focus", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; - fgColor: string; - ontimeupdate: (ev: Event) => any; - addEventListener(type: "timeupdate", listener: (ev: Event) => any, useCapture?: boolean): void; - onselect: (ev: UIEvent) => any; - addEventListener(type: "select", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - ondrop: (ev: DragEvent) => any; - addEventListener(type: "drop", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - onmouseout: (ev: MouseEvent) => any; - addEventListener(type: "mouseout", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - onended: (ev: Event) => any; - addEventListener(type: "ended", listener: (ev: Event) => any, useCapture?: boolean): void; - compatMode: string; - onscroll: (ev: UIEvent) => any; - addEventListener(type: "scroll", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - onmousewheel: (ev: MouseWheelEvent) => any; - addEventListener(type: "mousewheel", listener: (ev: MouseWheelEvent) => any, useCapture?: boolean): void; - onload: (ev: Event) => any; - addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; - onvolumechange: (ev: Event) => any; - addEventListener(type: "volumechange", listener: (ev: Event) => any, useCapture?: boolean): void; - oninput: (ev: Event) => any; - addEventListener(type: "input", listener: (ev: Event) => any, useCapture?: boolean): void; - queryCommandValue(commandId: string): string; - queryCommandIndeterm(commandId: string): boolean; - execCommand(commandId: string, showUI?: boolean, value?: any): boolean; - getElementsByName(elementName: string): NodeList; - writeln(...content: string[]): void; - open(url?: string, name?: string, features?: string, replace?: boolean): any; - queryCommandState(commandId: string): boolean; - close(): void; - hasFocus(): boolean; - getElementsByClassName(classNames: string): NodeList; - queryCommandSupported(commandId: string): boolean; - getSelection(): Selection; - queryCommandEnabled(commandId: string): boolean; - write(...content: string[]): void; - queryCommandText(commandId: string): string; - addEventListener(type: "DOMContentLoaded", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; -} - -interface SVGException { - code: number; - message: string; - toString(): string; - SVG_MATRIX_NOT_INVERTABLE: number; - SVG_WRONG_TYPE_ERR: number; - SVG_INVALID_VALUE_ERR: number; -} -declare var SVGException: { - prototype: SVGException; - new(): SVGException; - SVG_MATRIX_NOT_INVERTABLE: number; - SVG_WRONG_TYPE_ERR: number; - SVG_INVALID_VALUE_ERR: number; -} - -interface DOML2DeprecatedTableCellHeight { - height: any; -} - -interface HTMLTableAlignment { - ch: string; - vAlign: string; - chOff: string; -} - -interface SVGAnimatedEnumeration { - animVal: number; - baseVal: number; -} -declare var SVGAnimatedEnumeration: { - prototype: SVGAnimatedEnumeration; - new(): SVGAnimatedEnumeration; -} - -interface SVGLinearGradientElement extends SVGGradientElement { - y1: SVGAnimatedLength; - x2: SVGAnimatedLength; - x1: SVGAnimatedLength; - y2: SVGAnimatedLength; -} -declare var SVGLinearGradientElement: { - prototype: SVGLinearGradientElement; - new(): SVGLinearGradientElement; -} - -interface DOML2DeprecatedSizeProperty { - size: number; -} - -interface MSHTMLHeadingElementExtensions extends DOML2DeprecatedTextFlowControl_HTMLBlockElement { -} - -interface MSBorderColorStyle_HTMLTableCellElement { - borderColor: any; -} - -interface DOML2DeprecatedWidthStyle_HTMLHRElement { - width: number; -} - -interface HTMLUListElement extends HTMLElement, DOML2DeprecatedListSpaceReduction, DOML2DeprecatedListNumberingAndBulletStyle, MSHTMLUListElementExtensions { -} -declare var HTMLUListElement: { - prototype: HTMLUListElement; - new(): HTMLUListElement; -} - -interface SVGRectElement extends SVGElement, SVGStylable, SVGTransformable, SVGLangSpace, SVGTests { - y: SVGAnimatedLength; - width: SVGAnimatedLength; - ry: SVGAnimatedLength; - rx: SVGAnimatedLength; - x: SVGAnimatedLength; - height: SVGAnimatedLength; -} -declare var SVGRectElement: { - prototype: SVGRectElement; - new(): SVGRectElement; -} - -interface DOML2DeprecatedBorderStyle { - border: string; -} - -interface HTMLDivElement extends HTMLElement, DOML2DeprecatedAlignmentStyle_HTMLDivElement, MSHTMLDivElementExtensions, MSDataBindingExtensions { -} -declare var HTMLDivElement: { - prototype: HTMLDivElement; - new(): HTMLDivElement; -} - -interface NavigatorDoNotTrack { - msDoNotTrack: string; -} - -interface SVG1_1Properties { - fillRule: string; - strokeLinecap: string; - stopColor: string; - glyphOrientationHorizontal: string; - kerning: string; - alignmentBaseline: string; - dominantBaseline: string; - fill: string; - strokeMiterlimit: string; - marker: string; - glyphOrientationVertical: string; - markerMid: string; - textAnchor: string; - fillOpacity: string; - strokeDasharray: string; - mask: string; - stopOpacity: string; - stroke: string; - strokeDashoffset: string; - strokeOpacity: string; - markerStart: string; - pointerEvents: string; - baselineShift: string; - markerEnd: string; - clipRule: string; - strokeLinejoin: string; - clipPath: string; - strokeWidth: string; -} - -interface NamedNodeMap { - length: number; - removeNamedItemNS(namespaceURI: string, localName: string): Node; - item(index: number): Node; - [index: number]: Node; - removeNamedItem(name: string): Node; - getNamedItem(name: string): Node; - setNamedItem(arg: Node): Node; - getNamedItemNS(namespaceURI: string, localName: string): Node; - setNamedItemNS(arg: Node): Node; -} -declare var NamedNodeMap: { - prototype: NamedNodeMap; - new(): NamedNodeMap; -} - -interface MediaList { - length: number; - mediaText: string; - deleteMedium(oldMedium: string): void; - appendMedium(newMedium: string): void; - item(index: number): string; - [index: number]: string; - toString(): string; -} -declare var MediaList: { - prototype: MediaList; - new(): MediaList; -} - -interface SVGPathSegCurvetoQuadraticSmoothAbs extends SVGPathSeg { - y: number; - x: number; -} -declare var SVGPathSegCurvetoQuadraticSmoothAbs: { - prototype: SVGPathSegCurvetoQuadraticSmoothAbs; - new(): SVGPathSegCurvetoQuadraticSmoothAbs; -} - -interface SVGLengthList { - numberOfItems: number; - replaceItem(newItem: SVGLength, index: number): SVGLength; - getItem(index: number): SVGLength; - clear(): void; - appendItem(newItem: SVGLength): SVGLength; - initialize(newItem: SVGLength): SVGLength; - removeItem(index: number): SVGLength; - insertItemBefore(newItem: SVGLength, index: number): SVGLength; -} -declare var SVGLengthList: { - prototype: SVGLengthList; - new(): SVGLengthList; -} - -interface SVGPathSegCurvetoCubicSmoothRel extends SVGPathSeg { - y: number; - x2: number; - x: number; - y2: number; -} -declare var SVGPathSegCurvetoCubicSmoothRel: { - prototype: SVGPathSegCurvetoCubicSmoothRel; - new(): SVGPathSegCurvetoCubicSmoothRel; -} - -interface MSWindowExtensions { - status: string; - onmouseleave: (ev: MouseEvent) => any; - addEventListener(type: "mouseleave", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - screenLeft: number; - offscreenBuffering: any; - maxConnectionsPerServer: number; - onmouseenter: (ev: MouseEvent) => any; - addEventListener(type: "mouseenter", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - clipboardData: DataTransfer; - defaultStatus: string; - clientInformation: Navigator; - closed: boolean; - onhelp: (ev: Event) => any; - addEventListener(type: "help", listener: (ev: Event) => any, useCapture?: boolean): void; - external: BrowserPublic; - event: MSEventObj; - onfocusout: (ev: FocusEvent) => any; - addEventListener(type: "focusout", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; - screenTop: number; - onfocusin: (ev: FocusEvent) => any; - addEventListener(type: "focusin", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; - showModelessDialog(url?: string, argument?: any, options?: any): Window; - navigate(url: string): void; - resizeBy(x?: number, y?: number): void; - item(index: any): any; - resizeTo(x?: number, y?: number): void; - createPopup(arguments?: any): MSPopupWindow; - toStaticHTML(html: string): string; - execScript(code: string, language?: string): any; - msWriteProfilerMark(profilerMarkName: string): void; - moveTo(x?: number, y?: number): void; - moveBy(x?: number, y?: number): void; - showHelp(url: string, helpArg?: any, features?: string): void; - addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; -} - -interface ProcessingInstruction extends Node { - target: string; - data: string; -} -declare var ProcessingInstruction: { - prototype: ProcessingInstruction; - new(): ProcessingInstruction; -} - -interface MSBehaviorUrnsCollection { - length: number; - item(index: number): string; -} -declare var MSBehaviorUrnsCollection: { - prototype: MSBehaviorUrnsCollection; - new(): MSBehaviorUrnsCollection; -} - -interface CSSFontFaceRule extends CSSRule { - style: CSSStyleDeclaration; -} -declare var CSSFontFaceRule: { - prototype: CSSFontFaceRule; - new(): CSSFontFaceRule; -} - -interface DOML2DeprecatedBackgroundStyle { - background: string; -} - -interface TextEvent extends UIEvent { - inputMethod: number; - data: string; - locale: string; - initTextEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: AbstractView, dataArg: string, inputMethod: number, locale: string): void; - DOM_INPUT_METHOD_KEYBOARD: number; - DOM_INPUT_METHOD_DROP: number; - DOM_INPUT_METHOD_IME: number; - DOM_INPUT_METHOD_SCRIPT: number; - DOM_INPUT_METHOD_VOICE: number; - DOM_INPUT_METHOD_UNKNOWN: number; - DOM_INPUT_METHOD_PASTE: number; - DOM_INPUT_METHOD_HANDWRITING: number; - DOM_INPUT_METHOD_OPTION: number; - DOM_INPUT_METHOD_MULTIMODAL: number; -} -declare var TextEvent: { - prototype: TextEvent; - new(): TextEvent; - DOM_INPUT_METHOD_KEYBOARD: number; - DOM_INPUT_METHOD_DROP: number; - DOM_INPUT_METHOD_IME: number; - DOM_INPUT_METHOD_SCRIPT: number; - DOM_INPUT_METHOD_VOICE: number; - DOM_INPUT_METHOD_UNKNOWN: number; - DOM_INPUT_METHOD_PASTE: number; - DOM_INPUT_METHOD_HANDWRITING: number; - DOM_INPUT_METHOD_OPTION: number; - DOM_INPUT_METHOD_MULTIMODAL: number; -} - -interface MSHTMLHRElementExtensions extends DOML2DeprecatedColorProperty { -} - -interface AbstractView { - styleMedia: StyleMedia; - document: Document; -} - -interface DocumentFragment extends Node, NodeSelector, MSEventAttachmentTarget, MSNodeExtensions { -} -declare var DocumentFragment: { - prototype: DocumentFragment; - new(): DocumentFragment; -} - -interface DOML2DeprecatedAlignmentStyle_HTMLFieldSetElement { - align: string; -} - -interface SVGPolylineElement extends SVGElement, SVGStylable, SVGTransformable, SVGLangSpace, SVGAnimatedPoints, SVGTests { -} -declare var SVGPolylineElement: { - prototype: SVGPolylineElement; - new(): SVGPolylineElement; -} - -interface DOML2DeprecatedWidthStyle { - width: number; -} - -interface DOML2DeprecatedAlignmentStyle_HTMLHeadingElement { - align: string; -} - -interface SVGAnimatedPathData { - pathSegList: SVGPathSegList; -} - -interface Position { - timestamp: number; - coords: Coordinates; -} -declare var Position: { - prototype: Position; - new(): Position; -} - -interface BookmarkCollection { - length: number; - item(index: number): any; - [index: number]: any; -} -declare var BookmarkCollection: { - prototype: BookmarkCollection; - new(): BookmarkCollection; -} - -interface CSSPageRule extends CSSRule, StyleSheetPage { - selectorText: string; - style: CSSStyleDeclaration; -} -declare var CSSPageRule: { - prototype: CSSPageRule; - new(): CSSPageRule; -} - -interface WindowPerformance { - performance: any; -} - -interface HTMLBRElement extends HTMLElement, DOML2DeprecatedTextFlowControl_HTMLBRElement { -} -declare var HTMLBRElement: { - prototype: HTMLBRElement; - new(): HTMLBRElement; -} - -interface MSHTMLDivElementExtensions extends DOML2DeprecatedWordWrapSuppression_HTMLDivElement { -} - -interface DOML2DeprecatedBorderStyle_HTMLInputElement { - border: string; -} - -interface HTMLSpanElement extends HTMLElement, MSHTMLSpanElementExtensions, MSDataBindingExtensions { -} -declare var HTMLSpanElement: { - prototype: HTMLSpanElement; - new(): HTMLSpanElement; -} - -interface HTMLHRElementDOML2Deprecated { - noShade: boolean; -} - -interface HTMLHeadElement extends HTMLElement { - profile: string; -} -declare var HTMLHeadElement: { - prototype: HTMLHeadElement; - new(): HTMLHeadElement; -} - -interface NodeFilterCallback { - (...args: any[]): any; -} - -interface HTMLHeadingElement extends HTMLElement, DOML2DeprecatedAlignmentStyle_HTMLHeadingElement, MSHTMLHeadingElementExtensions { -} -declare var HTMLHeadingElement: { - prototype: HTMLHeadingElement; - new(): HTMLHeadingElement; -} - -interface HTMLFormElement extends HTMLElement, MSHTMLFormElementExtensions, MSHTMLCollectionExtensions { - length: number; - target: string; - acceptCharset: string; - enctype: string; - elements: HTMLCollection; - action: string; - name: string; - method: string; - reset(): void; - item(name?: any, index?: any): any; - (name: any, index: any): any; - submit(): void; - namedItem(name: string): any; - [name: string]: any; - (name: string): any; -} -declare var HTMLFormElement: { - prototype: HTMLFormElement; - new(): HTMLFormElement; -} - -interface SVGZoomAndPan { - zoomAndPan: number; - SVG_ZOOMANDPAN_MAGNIFY: number; - SVG_ZOOMANDPAN_UNKNOWN: number; - SVG_ZOOMANDPAN_DISABLE: number; -} -declare var SVGZoomAndPan: { - prototype: SVGZoomAndPan; - new(): SVGZoomAndPan; - SVG_ZOOMANDPAN_MAGNIFY: number; - SVG_ZOOMANDPAN_UNKNOWN: number; - SVG_ZOOMANDPAN_DISABLE: number; -} - -interface MSEventExtensions { - cancelBubble: boolean; - srcElement: Element; -} - -interface HTMLMediaElement extends HTMLElement { - initialTime: number; - played: TimeRanges; - currentSrc: string; - readyState: string; - autobuffer: boolean; - loop: boolean; - ended: boolean; - buffered: TimeRanges; - error: MediaError; - seekable: TimeRanges; - autoplay: boolean; - controls: boolean; - volume: number; - src: string; - playbackRate: number; - duration: number; - muted: boolean; - defaultPlaybackRate: number; - paused: boolean; - seeking: boolean; - currentTime: number; - preload: string; - networkState: number; - pause(): void; - play(): void; - load(): void; - canPlayType(type: string): string; - HAVE_METADATA: number; - HAVE_CURRENT_DATA: number; - HAVE_NOTHING: number; - NETWORK_NO_SOURCE: number; - HAVE_ENOUGH_DATA: number; - NETWORK_EMPTY: number; - NETWORK_LOADING: number; - NETWORK_IDLE: number; - HAVE_FUTURE_DATA: number; -} -declare var HTMLMediaElement: { - prototype: HTMLMediaElement; - new(): HTMLMediaElement; - HAVE_METADATA: number; - HAVE_CURRENT_DATA: number; - HAVE_NOTHING: number; - NETWORK_NO_SOURCE: number; - HAVE_ENOUGH_DATA: number; - NETWORK_EMPTY: number; - NETWORK_LOADING: number; - NETWORK_IDLE: number; - HAVE_FUTURE_DATA: number; -} - -interface ElementCSSInlineStyle extends MSElementCSSInlineStyleExtensions { - runtimeStyle: MSStyleCSSProperties; - currentStyle: MSCurrentStyleCSSProperties; -} - -interface DOMParser { - parseFromString(source: string, mimeType: string): Document; -} -declare var DOMParser: { - prototype: DOMParser; - new (): DOMParser; -} - -interface MSMimeTypesCollection { - length: number; -} -declare var MSMimeTypesCollection: { - prototype: MSMimeTypesCollection; - new(): MSMimeTypesCollection; -} - -interface StyleSheet { - disabled: boolean; - ownerNode: Node; - parentStyleSheet: StyleSheet; - href: string; - media: MediaList; - type: string; - title: string; -} -declare var StyleSheet: { - prototype: StyleSheet; - new(): StyleSheet; -} - -interface DOML2DeprecatedBorderStyle_HTMLTableElement { - border: string; -} - -interface DOML2DeprecatedWidthStyle_HTMLAppletElement { - width: number; -} - -interface SVGTextPathElement extends SVGTextContentElement, SVGURIReference { - startOffset: SVGAnimatedLength; - method: SVGAnimatedEnumeration; - spacing: SVGAnimatedEnumeration; - TEXTPATH_SPACINGTYPE_EXACT: number; - TEXTPATH_METHODTYPE_STRETCH: number; - TEXTPATH_SPACINGTYPE_AUTO: number; - TEXTPATH_SPACINGTYPE_UNKNOWN: number; - TEXTPATH_METHODTYPE_UNKNOWN: number; - TEXTPATH_METHODTYPE_ALIGN: number; -} -declare var SVGTextPathElement: { - prototype: SVGTextPathElement; - new(): SVGTextPathElement; - TEXTPATH_SPACINGTYPE_EXACT: number; - TEXTPATH_METHODTYPE_STRETCH: number; - TEXTPATH_SPACINGTYPE_AUTO: number; - TEXTPATH_SPACINGTYPE_UNKNOWN: number; - TEXTPATH_METHODTYPE_UNKNOWN: number; - TEXTPATH_METHODTYPE_ALIGN: number; -} - -interface NodeList { - length: number; - item(index: number): Node; - [index: number]: Node; -} -declare var NodeList: { - prototype: NodeList; - new(): NodeList; -} - -interface NodeListOf { - length: number; - item(index: number): TNode; - [index: number]: TNode; -} - -interface HTMLDTElement extends HTMLElement, DOML2DeprecatedWordWrapSuppression_HTMLDTElement { -} -declare var HTMLDTElement: { - prototype: HTMLDTElement; - new(): HTMLDTElement; -} - -interface XMLSerializer { - serializeToString(target: Node): string; -} -declare var XMLSerializer: { - prototype: XMLSerializer; - new (): XMLSerializer; -} - -interface StyleSheetPage { - pseudoClass: string; - selector: string; -} - -interface DOML2DeprecatedWordWrapSuppression_HTMLDDElement { - noWrap: boolean; -} - -interface MSHTMLTableRowElementExtensions { - height: any; -} - -interface SVGGradientElement extends SVGElement, SVGUnitTypes, SVGStylable, SVGURIReference { - spreadMethod: SVGAnimatedEnumeration; - gradientTransform: SVGAnimatedTransformList; - gradientUnits: SVGAnimatedEnumeration; - SVG_SPREADMETHOD_REFLECT: number; - SVG_SPREADMETHOD_PAD: number; - SVG_SPREADMETHOD_UNKNOWN: number; - SVG_SPREADMETHOD_REPEAT: number; -} -declare var SVGGradientElement: { - prototype: SVGGradientElement; - new(): SVGGradientElement; - SVG_SPREADMETHOD_REFLECT: number; - SVG_SPREADMETHOD_PAD: number; - SVG_SPREADMETHOD_UNKNOWN: number; - SVG_SPREADMETHOD_REPEAT: number; -} - -interface DOML2DeprecatedTextFlowControl_HTMLBRElement { - clear: string; -} - -interface MSHTMLParagraphElementExtensions extends DOML2DeprecatedTextFlowControl_HTMLBlockElement { -} - -interface NodeFilter { - acceptNode(n: Node): number; - SHOW_ENTITY_REFERENCE: number; - SHOW_NOTATION: number; - SHOW_ENTITY: number; - SHOW_DOCUMENT: number; - SHOW_PROCESSING_INSTRUCTION: number; - FILTER_REJECT: number; - SHOW_CDATA_SECTION: number; - FILTER_ACCEPT: number; - SHOW_ALL: number; - SHOW_DOCUMENT_TYPE: number; - SHOW_TEXT: number; - SHOW_ELEMENT: number; - SHOW_COMMENT: number; - FILTER_SKIP: number; - SHOW_ATTRIBUTE: number; - SHOW_DOCUMENT_FRAGMENT: number; -} -declare var NodeFilter: { - prototype: NodeFilter; - new(): NodeFilter; - SHOW_ENTITY_REFERENCE: number; - SHOW_NOTATION: number; - SHOW_ENTITY: number; - SHOW_DOCUMENT: number; - SHOW_PROCESSING_INSTRUCTION: number; - FILTER_REJECT: number; - SHOW_CDATA_SECTION: number; - FILTER_ACCEPT: number; - SHOW_ALL: number; - SHOW_DOCUMENT_TYPE: number; - SHOW_TEXT: number; - SHOW_ELEMENT: number; - SHOW_COMMENT: number; - FILTER_SKIP: number; - SHOW_ATTRIBUTE: number; - SHOW_DOCUMENT_FRAGMENT: number; -} - -interface MSBorderColorStyle_HTMLFrameElement { - borderColor: any; -} - -interface MSHTMLOListElementExtensions { -} - -interface DOML2DeprecatedWordWrapSuppression_HTMLDTElement { - noWrap: boolean; -} - -interface ScreenView extends AbstractView { - outerWidth: number; - pageXOffset: number; - innerWidth: number; - pageYOffset: number; - screenY: number; - outerHeight: number; - screen: Screen; - innerHeight: number; - screenX: number; - scroll(x?: number, y?: number): void; - scrollBy(x?: number, y?: number): void; - scrollTo(x?: number, y?: number): void; -} - -interface DOML2DeprecatedMarginStyle_HTMLObjectElement { - vspace: number; - hspace: number; -} - -interface DOML2DeprecatedMarginStyle_HTMLInputElement { - vspace: number; - hspace: number; -} - -interface MSHTMLTableSectionElementExtensions extends DOML2DeprecatedBackgroundColorStyle { - moveRow(indexFrom?: number, indexTo?: number): Object; -} - -interface HTMLFieldSetElement extends HTMLElement, MSHTMLFieldSetElementExtensions { - form: HTMLFormElement; -} -declare var HTMLFieldSetElement: { - prototype: HTMLFieldSetElement; - new(): HTMLFieldSetElement; -} - -interface MediaError { - code: number; - MEDIA_ERR_ABORTED: number; - MEDIA_ERR_NETWORK: number; - MEDIA_ERR_SRC_NOT_SUPPORTED: number; - MEDIA_ERR_DECODE: number; -} -declare var MediaError: { - prototype: MediaError; - new(): MediaError; - MEDIA_ERR_ABORTED: number; - MEDIA_ERR_NETWORK: number; - MEDIA_ERR_SRC_NOT_SUPPORTED: number; - MEDIA_ERR_DECODE: number; -} - -interface SVGNumberList { - numberOfItems: number; - replaceItem(newItem: SVGNumber, index: number): SVGNumber; - getItem(index: number): SVGNumber; - clear(): void; - appendItem(newItem: SVGNumber): SVGNumber; - initialize(newItem: SVGNumber): SVGNumber; - removeItem(index: number): SVGNumber; - insertItemBefore(newItem: SVGNumber, index: number): SVGNumber; -} -declare var SVGNumberList: { - prototype: SVGNumberList; - new(): SVGNumberList; -} - -interface HTMLBGSoundElement extends HTMLElement { - balance: any; - volume: any; - src: string; - loop: number; -} -declare var HTMLBGSoundElement: { - prototype: HTMLBGSoundElement; - new(): HTMLBGSoundElement; -} - -interface HTMLElement extends Element, MSHTMLElementRangeExtensions, ElementCSSInlineStyle, MSEventAttachmentTarget, MSHTMLElementExtensions, MSNodeExtensions { - ondragend: (ev: DragEvent) => any; - addEventListener(type: "dragend", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - onkeydown: (ev: KeyboardEvent) => any; - addEventListener(type: "keydown", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; - ondragover: (ev: DragEvent) => any; - addEventListener(type: "dragover", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - onkeyup: (ev: KeyboardEvent) => any; - addEventListener(type: "keyup", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; - offsetTop: number; - onreset: (ev: Event) => any; - addEventListener(type: "reset", listener: (ev: Event) => any, useCapture?: boolean): void; - onmouseup: (ev: MouseEvent) => any; - addEventListener(type: "mouseup", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - ondragstart: (ev: DragEvent) => any; - addEventListener(type: "dragstart", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - ondrag: (ev: DragEvent) => any; - addEventListener(type: "drag", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - innerHTML: string; - onmouseover: (ev: MouseEvent) => any; - addEventListener(type: "mouseover", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - ondragleave: (ev: DragEvent) => any; - addEventListener(type: "dragleave", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - lang: string; - onpause: (ev: Event) => any; - addEventListener(type: "pause", listener: (ev: Event) => any, useCapture?: boolean): void; - className: string; - onseeked: (ev: Event) => any; - addEventListener(type: "seeked", listener: (ev: Event) => any, useCapture?: boolean): void; - onmousedown: (ev: MouseEvent) => any; - addEventListener(type: "mousedown", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - title: string; - onclick: (ev: MouseEvent) => any; - addEventListener(type: "click", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - onwaiting: (ev: Event) => any; - addEventListener(type: "waiting", listener: (ev: Event) => any, useCapture?: boolean): void; - outerHTML: string; - offsetLeft: number; - ondurationchange: (ev: Event) => any; - addEventListener(type: "durationchange", listener: (ev: Event) => any, useCapture?: boolean): void; - offsetHeight: number; - dir: string; - onblur: (ev: FocusEvent) => any; - addEventListener(type: "blur", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; - onemptied: (ev: Event) => any; - addEventListener(type: "emptied", listener: (ev: Event) => any, useCapture?: boolean): void; - onseeking: (ev: Event) => any; - addEventListener(type: "seeking", listener: (ev: Event) => any, useCapture?: boolean): void; - oncanplay: (ev: Event) => any; - addEventListener(type: "canplay", listener: (ev: Event) => any, useCapture?: boolean): void; - onstalled: (ev: Event) => any; - addEventListener(type: "stalled", listener: (ev: Event) => any, useCapture?: boolean): void; - onmousemove: (ev: MouseEvent) => any; - addEventListener(type: "mousemove", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - style: MSStyleCSSProperties; - isContentEditable: boolean; - onratechange: (ev: Event) => any; - addEventListener(type: "ratechange", listener: (ev: Event) => any, useCapture?: boolean): void; - onloadstart: (ev: Event) => any; - addEventListener(type: "loadstart", listener: (ev: Event) => any, useCapture?: boolean): void; - ondragenter: (ev: DragEvent) => any; - addEventListener(type: "dragenter", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - contentEditable: string; - onsubmit: (ev: Event) => any; - addEventListener(type: "submit", listener: (ev: Event) => any, useCapture?: boolean): void; - tabIndex: number; - onprogress: (ev: any) => any; - addEventListener(type: "progress", listener: (ev: any) => any, useCapture?: boolean): void; - ondblclick: (ev: MouseEvent) => any; - addEventListener(type: "dblclick", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - oncontextmenu: (ev: MouseEvent) => any; - addEventListener(type: "contextmenu", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - onchange: (ev: Event) => any; - addEventListener(type: "change", listener: (ev: Event) => any, useCapture?: boolean): void; - onloadedmetadata: (ev: Event) => any; - addEventListener(type: "loadedmetadata", listener: (ev: Event) => any, useCapture?: boolean): void; - onerror: (ev: Event) => any; - addEventListener(type: "error", listener: (ev: Event) => any, useCapture?: boolean): void; - onplay: (ev: Event) => any; - addEventListener(type: "play", listener: (ev: Event) => any, useCapture?: boolean): void; - id: string; - onplaying: (ev: Event) => any; - addEventListener(type: "playing", listener: (ev: Event) => any, useCapture?: boolean): void; - oncanplaythrough: (ev: Event) => any; - addEventListener(type: "canplaythrough", listener: (ev: Event) => any, useCapture?: boolean): void; - onabort: (ev: UIEvent) => any; - addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - onreadystatechange: (ev: Event) => any; - addEventListener(type: "readystatechange", listener: (ev: Event) => any, useCapture?: boolean): void; - onkeypress: (ev: KeyboardEvent) => any; - addEventListener(type: "keypress", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; - offsetParent: Element; - onloadeddata: (ev: Event) => any; - addEventListener(type: "loadeddata", listener: (ev: Event) => any, useCapture?: boolean): void; - disabled: boolean; - onsuspend: (ev: Event) => any; - addEventListener(type: "suspend", listener: (ev: Event) => any, useCapture?: boolean): void; - accessKey: string; - onfocus: (ev: FocusEvent) => any; - addEventListener(type: "focus", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; - ontimeupdate: (ev: Event) => any; - addEventListener(type: "timeupdate", listener: (ev: Event) => any, useCapture?: boolean): void; - onselect: (ev: UIEvent) => any; - addEventListener(type: "select", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - ondrop: (ev: DragEvent) => any; - addEventListener(type: "drop", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - offsetWidth: number; - onmouseout: (ev: MouseEvent) => any; - addEventListener(type: "mouseout", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - onended: (ev: Event) => any; - addEventListener(type: "ended", listener: (ev: Event) => any, useCapture?: boolean): void; - onscroll: (ev: UIEvent) => any; - addEventListener(type: "scroll", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - onmousewheel: (ev: MouseWheelEvent) => any; - addEventListener(type: "mousewheel", listener: (ev: MouseWheelEvent) => any, useCapture?: boolean): void; - onvolumechange: (ev: Event) => any; - addEventListener(type: "volumechange", listener: (ev: Event) => any, useCapture?: boolean): void; - onload: (ev: Event) => any; - addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; - oninput: (ev: Event) => any; - addEventListener(type: "input", listener: (ev: Event) => any, useCapture?: boolean): void; - click(): void; - getElementsByClassName(classNames: string): NodeList; - scrollIntoView(top?: boolean): void; - focus(): void; - blur(): void; - insertAdjacentHTML(where: string, html: string): void; - addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; -} -declare var HTMLElement: { - prototype: HTMLElement; - new(): HTMLElement; -} - -interface Comment extends CharacterData, MSCommentExtensions { -} -declare var Comment: { - prototype: Comment; - new(): Comment; -} - -interface CanvasPattern { -} -declare var CanvasPattern: { - prototype: CanvasPattern; - new(): CanvasPattern; -} - -interface HTMLHRElement extends HTMLElement, DOML2DeprecatedWidthStyle_HTMLHRElement, MSHTMLHRElementExtensions, HTMLHRElementDOML2Deprecated, DOML2DeprecatedAlignmentStyle_HTMLHRElement, DOML2DeprecatedSizeProperty { -} -declare var HTMLHRElement: { - prototype: HTMLHRElement; - new(): HTMLHRElement; -} - -interface MSHTMLFrameSetElementExtensions { - name: string; - frameBorder: string; - border: string; - frameSpacing: any; -} - -interface DOML2DeprecatedTextFlowControl_HTMLBlockElement { - clear: string; -} - -interface PositionOptions { - enableHighAccuracy?: boolean; - timeout?: number; - maximumAge?: number; -} - -interface HTMLObjectElement extends HTMLElement, MSHTMLObjectElementExtensions, GetSVGDocument, DOML2DeprecatedMarginStyle_HTMLObjectElement, MSDataBindingExtensions, MSDataBindingRecordSetExtensions, DOML2DeprecatedAlignmentStyle_HTMLObjectElement, DOML2DeprecatedBorderStyle_HTMLObjectElement { - width: string; - codeType: string; - archive: string; - standby: string; - name: string; - useMap: string; - form: HTMLFormElement; - data: string; - height: string; - contentDocument: Document; - codeBase: string; - declare: boolean; - type: string; - code: string; -} -declare var HTMLObjectElement: { - prototype: HTMLObjectElement; - new(): HTMLObjectElement; -} - -interface MSHTMLMenuElementExtensions { -} - -interface DocumentView { - defaultView: AbstractView; - elementFromPoint(x: number, y: number): Element; -} - -interface StorageEvent extends Event { - oldValue: any; - newValue: any; - url: string; - storageArea: Storage; - key: string; - initStorageEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, keyArg: string, oldValueArg: any, newValueArg: any, urlArg: string, storageAreaArg: Storage): void; -} -declare var StorageEvent: { - prototype: StorageEvent; - new(): StorageEvent; -} - -interface HTMLEmbedElement extends HTMLElement, GetSVGDocument, MSHTMLEmbedElementExtensions { - width: string; - src: string; - name: string; - height: string; -} -declare var HTMLEmbedElement: { - prototype: HTMLEmbedElement; - new(): HTMLEmbedElement; -} - -interface CharacterData extends Node { - length: number; - data: string; - deleteData(offset: number, count: number): void; - replaceData(offset: number, count: number, arg: string): void; - appendData(arg: string): void; - insertData(offset: number, arg: string): void; - substringData(offset: number, count: number): string; -} -declare var CharacterData: { - prototype: CharacterData; - new(): CharacterData; -} - -interface DOML2DeprecatedAlignmentStyle_HTMLTableSectionElement { - align: string; -} - -interface HTMLOptGroupElement extends HTMLElement, MSDataBindingExtensions, MSHTMLOptGroupElementExtensions { - label: string; -} -declare var HTMLOptGroupElement: { - prototype: HTMLOptGroupElement; - new(): HTMLOptGroupElement; -} - -interface HTMLIsIndexElement extends HTMLElement, MSHTMLIsIndexElementExtensions { - form: HTMLFormElement; - prompt: string; -} -declare var HTMLIsIndexElement: { - prototype: HTMLIsIndexElement; - new(): HTMLIsIndexElement; -} - -interface SVGPathSegLinetoRel extends SVGPathSeg { - y: number; - x: number; -} -declare var SVGPathSegLinetoRel: { - prototype: SVGPathSegLinetoRel; - new(): SVGPathSegLinetoRel; -} - -interface MSHTMLDocumentSelection { - selection: MSSelection; -} - -interface DOMException { - code: number; - message: string; - toString(): string; - HIERARCHY_REQUEST_ERR: number; - NO_MODIFICATION_ALLOWED_ERR: number; - INVALID_MODIFICATION_ERR: number; - NAMESPACE_ERR: number; - INVALID_CHARACTER_ERR: number; - TYPE_MISMATCH_ERR: number; - ABORT_ERR: number; - INVALID_STATE_ERR: number; - SECURITY_ERR: number; - NETWORK_ERR: number; - WRONG_DOCUMENT_ERR: number; - QUOTA_EXCEEDED_ERR: number; - INDEX_SIZE_ERR: number; - DOMSTRING_SIZE_ERR: number; - SYNTAX_ERR: number; - SERIALIZE_ERR: number; - VALIDATION_ERR: number; - NOT_FOUND_ERR: number; - URL_MISMATCH_ERR: number; - PARSE_ERR: number; - NO_DATA_ALLOWED_ERR: number; - NOT_SUPPORTED_ERR: number; - INVALID_ACCESS_ERR: number; - INUSE_ATTRIBUTE_ERR: number; -} -declare var DOMException: { - prototype: DOMException; - new(): DOMException; - HIERARCHY_REQUEST_ERR: number; - NO_MODIFICATION_ALLOWED_ERR: number; - INVALID_MODIFICATION_ERR: number; - NAMESPACE_ERR: number; - INVALID_CHARACTER_ERR: number; - TYPE_MISMATCH_ERR: number; - ABORT_ERR: number; - INVALID_STATE_ERR: number; - SECURITY_ERR: number; - NETWORK_ERR: number; - WRONG_DOCUMENT_ERR: number; - QUOTA_EXCEEDED_ERR: number; - INDEX_SIZE_ERR: number; - DOMSTRING_SIZE_ERR: number; - SYNTAX_ERR: number; - SERIALIZE_ERR: number; - VALIDATION_ERR: number; - NOT_FOUND_ERR: number; - URL_MISMATCH_ERR: number; - PARSE_ERR: number; - NO_DATA_ALLOWED_ERR: number; - NOT_SUPPORTED_ERR: number; - INVALID_ACCESS_ERR: number; - INUSE_ATTRIBUTE_ERR: number; -} - -interface MSCompatibleInfoCollection { - length: number; - item(index: number): MSCompatibleInfo; -} -declare var MSCompatibleInfoCollection: { - prototype: MSCompatibleInfoCollection; - new(): MSCompatibleInfoCollection; -} - -interface MSHTMLIsIndexElementExtensions { - action: string; -} - -interface SVGAnimatedBoolean { - animVal: boolean; - baseVal: boolean; -} -declare var SVGAnimatedBoolean: { - prototype: SVGAnimatedBoolean; - new(): SVGAnimatedBoolean; -} - -interface SVGSwitchElement extends SVGElement, SVGStylable, SVGTransformable, SVGLangSpace, SVGTests { -} -declare var SVGSwitchElement: { - prototype: SVGSwitchElement; - new(): SVGSwitchElement; -} - -interface MSHTMLIFrameElementExtensions extends DOML2DeprecatedMarginStyle_MSHTMLIFrameElementExtensions, DOML2DeprecatedBorderStyle_MSHTMLIFrameElementExtensions { - onload: (ev: Event) => any; - addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; - frameSpacing: any; - noResize: boolean; - addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; -} - -interface SVGPreserveAspectRatio { - align: number; - meetOrSlice: number; - SVG_PRESERVEASPECTRATIO_NONE: number; - SVG_PRESERVEASPECTRATIO_XMINYMID: number; - SVG_PRESERVEASPECTRATIO_XMAXYMIN: number; - SVG_PRESERVEASPECTRATIO_XMINYMAX: number; - SVG_PRESERVEASPECTRATIO_XMAXYMAX: number; - SVG_MEETORSLICE_UNKNOWN: number; - SVG_PRESERVEASPECTRATIO_XMAXYMID: number; - SVG_PRESERVEASPECTRATIO_XMIDYMAX: number; - SVG_PRESERVEASPECTRATIO_XMINYMIN: number; - SVG_MEETORSLICE_MEET: number; - SVG_PRESERVEASPECTRATIO_XMIDYMID: number; - SVG_PRESERVEASPECTRATIO_XMIDYMIN: number; - SVG_MEETORSLICE_SLICE: number; - SVG_PRESERVEASPECTRATIO_UNKNOWN: number; -} -declare var SVGPreserveAspectRatio: { - prototype: SVGPreserveAspectRatio; - new(): SVGPreserveAspectRatio; - SVG_PRESERVEASPECTRATIO_NONE: number; - SVG_PRESERVEASPECTRATIO_XMINYMID: number; - SVG_PRESERVEASPECTRATIO_XMAXYMIN: number; - SVG_PRESERVEASPECTRATIO_XMINYMAX: number; - SVG_PRESERVEASPECTRATIO_XMAXYMAX: number; - SVG_MEETORSLICE_UNKNOWN: number; - SVG_PRESERVEASPECTRATIO_XMAXYMID: number; - SVG_PRESERVEASPECTRATIO_XMIDYMAX: number; - SVG_PRESERVEASPECTRATIO_XMINYMIN: number; - SVG_MEETORSLICE_MEET: number; - SVG_PRESERVEASPECTRATIO_XMIDYMID: number; - SVG_PRESERVEASPECTRATIO_XMIDYMIN: number; - SVG_MEETORSLICE_SLICE: number; - SVG_PRESERVEASPECTRATIO_UNKNOWN: number; -} - -interface Attr extends Node, MSAttrExtensions { - specified: boolean; - ownerElement: Element; - value: string; - name: string; -} -declare var Attr: { - prototype: Attr; - new(): Attr; -} - -interface MSBorderColorStyle_HTMLTableRowElement { - borderColor: any; -} - -interface DOML2DeprecatedAlignmentStyle_HTMLTableCaptionElement { - align: string; -} - -interface PerformanceNavigation { - redirectCount: number; - type: number; - toJSON(): any; - TYPE_RELOAD: number; - TYPE_RESERVED: number; - TYPE_BACK_FORWARD: number; - TYPE_NAVIGATE: number; -} -declare var PerformanceNavigation: { - prototype: PerformanceNavigation; - new(): PerformanceNavigation; - TYPE_RELOAD: number; - TYPE_RESERVED: number; - TYPE_BACK_FORWARD: number; - TYPE_NAVIGATE: number; -} - -interface HTMLBodyElementDOML2Deprecated { - link: any; - aLink: any; - text: any; - vLink: any; -} - -interface SVGStopElement extends SVGElement, SVGStylable { - offset: SVGAnimatedNumber; -} -declare var SVGStopElement: { - prototype: SVGStopElement; - new(): SVGStopElement; -} - -interface PositionCallback { - (position: Position): void; -} - -interface SVGSymbolElement extends SVGElement, SVGStylable, SVGLangSpace, SVGFitToViewBox { -} -declare var SVGSymbolElement: { - prototype: SVGSymbolElement; - new(): SVGSymbolElement; -} - -interface SVGElementInstanceList { - length: number; - item(index: number): SVGElementInstance; -} -declare var SVGElementInstanceList: { - prototype: SVGElementInstanceList; - new(): SVGElementInstanceList; -} - -interface MSDataBindingRecordSetExtensions { - recordset: Object; - namedRecordset(dataMember: string, hierarchy?: any): Object; -} - -interface CSSRuleList { - length: number; - item(index: number): CSSRule; - [index: number]: CSSRule; -} -declare var CSSRuleList: { - prototype: CSSRuleList; - new(): CSSRuleList; -} - -interface MSHTMLTableColElementExtensions { -} - -interface LinkStyle { - sheet: StyleSheet; -} - -interface MSHTMLMarqueeElementExtensions { -} - -interface HTMLVideoElement extends HTMLMediaElement { - width: number; - videoWidth: number; - videoHeight: number; - height: number; - poster: string; -} -declare var HTMLVideoElement: { - prototype: HTMLVideoElement; - new(): HTMLVideoElement; -} - -interface MSXMLHttpRequestExtensions { - responseBody: any; - timeout: number; - ontimeout: (ev: Event) => any; -} - -interface ClientRectList { - length: number; - item(index: number): ClientRect; - [index: number]: ClientRect; -} -declare var ClientRectList: { - prototype: ClientRectList; - new(): ClientRectList; -} - -interface DOML2DeprecatedAlignmentStyle_HTMLTableCellElement { - align: string; -} - -interface SVGMaskElement extends SVGElement, SVGUnitTypes, SVGStylable, SVGLangSpace, SVGTests { - y: SVGAnimatedLength; - width: SVGAnimatedLength; - maskUnits: SVGAnimatedEnumeration; - maskContentUnits: SVGAnimatedEnumeration; - x: SVGAnimatedLength; - height: SVGAnimatedLength; -} -declare var SVGMaskElement: { - prototype: SVGMaskElement; - new(): SVGMaskElement; -} - -declare var Audio: { new (src?: string): HTMLAudioElement; }; -declare var Option: { new (text?: string, value?: string, defaultSelected?: boolean, selected?: boolean): HTMLOptionElement; }; -declare var Image: { new (width?: number, height?: number): HTMLImageElement; }; - -declare var ondragend: (ev: DragEvent) => any; -declare function addEventListener(type: "dragend", listener: (ev: DragEvent) => any, useCapture?: boolean): void; -declare var onkeydown: (ev: KeyboardEvent) => any; -declare function addEventListener(type: "keydown", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; -declare var ondragover: (ev: DragEvent) => any; -declare function addEventListener(type: "dragover", listener: (ev: DragEvent) => any, useCapture?: boolean): void; -declare var onkeyup: (ev: KeyboardEvent) => any; -declare function addEventListener(type: "keyup", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; -declare var onreset: (ev: Event) => any; -declare function addEventListener(type: "reset", listener: (ev: Event) => any, useCapture?: boolean): void; -declare var onmouseup: (ev: MouseEvent) => any; -declare function addEventListener(type: "mouseup", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; -declare var ondragstart: (ev: DragEvent) => any; -declare function addEventListener(type: "dragstart", listener: (ev: DragEvent) => any, useCapture?: boolean): void; -declare var ondrag: (ev: DragEvent) => any; -declare function addEventListener(type: "drag", listener: (ev: DragEvent) => any, useCapture?: boolean): void; -declare var onmouseover: (ev: MouseEvent) => any; -declare function addEventListener(type: "mouseover", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; -declare var ondragleave: (ev: DragEvent) => any; -declare function addEventListener(type: "dragleave", listener: (ev: DragEvent) => any, useCapture?: boolean): void; -declare var history: History; -declare var name: string; -declare var onafterprint: (ev: Event) => any; -declare function addEventListener(type: "afterprint", listener: (ev: Event) => any, useCapture?: boolean): void; -declare var onpause: (ev: Event) => any; -declare function addEventListener(type: "pause", listener: (ev: Event) => any, useCapture?: boolean): void; -declare var onbeforeprint: (ev: Event) => any; -declare function addEventListener(type: "beforeprint", listener: (ev: Event) => any, useCapture?: boolean): void; -declare var top: Window; -declare var onmousedown: (ev: MouseEvent) => any; -declare function addEventListener(type: "mousedown", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; -declare var onseeked: (ev: Event) => any; -declare function addEventListener(type: "seeked", listener: (ev: Event) => any, useCapture?: boolean): void; -declare var opener: Window; -declare var onclick: (ev: MouseEvent) => any; -declare function addEventListener(type: "click", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; -declare var onwaiting: (ev: Event) => any; -declare function addEventListener(type: "waiting", listener: (ev: Event) => any, useCapture?: boolean): void; -declare var ononline: (ev: Event) => any; -declare function addEventListener(type: "online", listener: (ev: Event) => any, useCapture?: boolean): void; -declare var ondurationchange: (ev: Event) => any; -declare function addEventListener(type: "durationchange", listener: (ev: Event) => any, useCapture?: boolean): void; -declare var frames: Window; -declare var onblur: (ev: FocusEvent) => any; -declare function addEventListener(type: "blur", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; -declare var onemptied: (ev: Event) => any; -declare function addEventListener(type: "emptied", listener: (ev: Event) => any, useCapture?: boolean): void; -declare var onseeking: (ev: Event) => any; -declare function addEventListener(type: "seeking", listener: (ev: Event) => any, useCapture?: boolean): void; -declare var oncanplay: (ev: Event) => any; -declare function addEventListener(type: "canplay", listener: (ev: Event) => any, useCapture?: boolean): void; -declare var onstalled: (ev: Event) => any; -declare function addEventListener(type: "stalled", listener: (ev: Event) => any, useCapture?: boolean): void; -declare var onmousemove: (ev: MouseEvent) => any; -declare function addEventListener(type: "mousemove", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; -declare var onoffline: (ev: Event) => any; -declare function addEventListener(type: "offline", listener: (ev: Event) => any, useCapture?: boolean): void; -declare var length: number; -declare var onbeforeunload: (ev: BeforeUnloadEvent) => any; -declare function addEventListener(type: "beforeunload", listener: (ev: BeforeUnloadEvent) => any, useCapture?: boolean): void; -declare var onratechange: (ev: Event) => any; -declare function addEventListener(type: "ratechange", listener: (ev: Event) => any, useCapture?: boolean): void; -declare var onstorage: (ev: StorageEvent) => any; -declare function addEventListener(type: "storage", listener: (ev: StorageEvent) => any, useCapture?: boolean): void; -declare var onloadstart: (ev: Event) => any; -declare function addEventListener(type: "loadstart", listener: (ev: Event) => any, useCapture?: boolean): void; -declare var ondragenter: (ev: DragEvent) => any; -declare function addEventListener(type: "dragenter", listener: (ev: DragEvent) => any, useCapture?: boolean): void; -declare var onsubmit: (ev: Event) => any; -declare function addEventListener(type: "submit", listener: (ev: Event) => any, useCapture?: boolean): void; -declare var self: Window; -declare var onprogress: (ev: any) => any; -declare function addEventListener(type: "progress", listener: (ev: any) => any, useCapture?: boolean): void; -declare var ondblclick: (ev: MouseEvent) => any; -declare function addEventListener(type: "dblclick", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; -declare var oncontextmenu: (ev: MouseEvent) => any; -declare function addEventListener(type: "contextmenu", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; -declare var onchange: (ev: Event) => any; -declare function addEventListener(type: "change", listener: (ev: Event) => any, useCapture?: boolean): void; -declare var onloadedmetadata: (ev: Event) => any; -declare function addEventListener(type: "loadedmetadata", listener: (ev: Event) => any, useCapture?: boolean): void; -declare var onplay: (ev: Event) => any; -declare function addEventListener(type: "play", listener: (ev: Event) => any, useCapture?: boolean): void; -declare var onerror: ErrorFunction; -declare var onplaying: (ev: Event) => any; -declare function addEventListener(type: "playing", listener: (ev: Event) => any, useCapture?: boolean): void; -declare var parent: Window; -declare var location: Location; -declare var oncanplaythrough: (ev: Event) => any; -declare function addEventListener(type: "canplaythrough", listener: (ev: Event) => any, useCapture?: boolean): void; -declare var onabort: (ev: UIEvent) => any; -declare function addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; -declare var onreadystatechange: (ev: Event) => any; -declare function addEventListener(type: "readystatechange", listener: (ev: Event) => any, useCapture?: boolean): void; -declare var onkeypress: (ev: KeyboardEvent) => any; -declare function addEventListener(type: "keypress", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; -declare var frameElement: Element; -declare var onloadeddata: (ev: Event) => any; -declare function addEventListener(type: "loadeddata", listener: (ev: Event) => any, useCapture?: boolean): void; -declare var onsuspend: (ev: Event) => any; -declare function addEventListener(type: "suspend", listener: (ev: Event) => any, useCapture?: boolean): void; -declare var window: Window; -declare var onfocus: (ev: FocusEvent) => any; -declare function addEventListener(type: "focus", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; -declare var onmessage: (ev: MessageEvent) => any; -declare function addEventListener(type: "message", listener: (ev: MessageEvent) => any, useCapture?: boolean): void; -declare var ontimeupdate: (ev: Event) => any; -declare function addEventListener(type: "timeupdate", listener: (ev: Event) => any, useCapture?: boolean): void; -declare var onresize: (ev: UIEvent) => any; -declare function addEventListener(type: "resize", listener: (ev: UIEvent) => any, useCapture?: boolean): void; -declare var navigator: Navigator; -declare var onselect: (ev: UIEvent) => any; -declare function addEventListener(type: "select", listener: (ev: UIEvent) => any, useCapture?: boolean): void; -declare var ondrop: (ev: DragEvent) => any; -declare function addEventListener(type: "drop", listener: (ev: DragEvent) => any, useCapture?: boolean): void; -declare var onmouseout: (ev: MouseEvent) => any; -declare function addEventListener(type: "mouseout", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; -declare var onended: (ev: Event) => any; -declare function addEventListener(type: "ended", listener: (ev: Event) => any, useCapture?: boolean): void; -declare var onhashchange: (ev: Event) => any; -declare function addEventListener(type: "hashchange", listener: (ev: Event) => any, useCapture?: boolean): void; -declare var onunload: (ev: Event) => any; -declare function addEventListener(type: "unload", listener: (ev: Event) => any, useCapture?: boolean): void; -declare var onscroll: (ev: UIEvent) => any; -declare function addEventListener(type: "scroll", listener: (ev: UIEvent) => any, useCapture?: boolean): void; -declare var onmousewheel: (ev: MouseWheelEvent) => any; -declare function addEventListener(type: "mousewheel", listener: (ev: MouseWheelEvent) => any, useCapture?: boolean): void; -declare var onload: (ev: Event) => any; -declare function addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; -declare var onvolumechange: (ev: Event) => any; -declare function addEventListener(type: "volumechange", listener: (ev: Event) => any, useCapture?: boolean): void; -declare var oninput: (ev: Event) => any; -declare function addEventListener(type: "input", listener: (ev: Event) => any, useCapture?: boolean): void; -declare function alert(message?: string): void; -declare function focus(): void; -declare function print(): void; -declare function prompt(message?: string, defaul?: string): string; -declare function toString(): string; -declare function open(url?: string, target?: string, features?: string, replace?: boolean): Window; -declare function close(): void; -declare function confirm(message?: string): boolean; -declare function postMessage(message: any, targetOrigin: string, ports?: any): void; -declare function showModalDialog(url?: string, argument?: any, options?: any): any; -declare function blur(): void; -declare function getSelection(): Selection; -declare function getComputedStyle(elt: Element, pseudoElt?: string): CSSStyleDeclaration; -declare function attachEvent(event: string, listener: EventListener): boolean; -declare function detachEvent(event: string, listener: EventListener): void; -declare var status: string; -declare var onmouseleave: (ev: MouseEvent) => any; -declare function addEventListener(type: "mouseleave", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; -declare var screenLeft: number; -declare var offscreenBuffering: any; -declare var maxConnectionsPerServer: number; -declare var onmouseenter: (ev: MouseEvent) => any; -declare function addEventListener(type: "mouseenter", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; -declare var clipboardData: DataTransfer; -declare var defaultStatus: string; -declare var clientInformation: Navigator; -declare var closed: boolean; -declare var onhelp: (ev: Event) => any; -declare function addEventListener(type: "help", listener: (ev: Event) => any, useCapture?: boolean): void; -declare var external: BrowserPublic; -declare var event: MSEventObj; -declare var onfocusout: (ev: FocusEvent) => any; -declare function addEventListener(type: "focusout", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; -declare var screenTop: number; -declare var onfocusin: (ev: FocusEvent) => any; -declare function addEventListener(type: "focusin", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; -declare function showModelessDialog(url?: string, argument?: any, options?: any): Window; -declare function navigate(url: string): void; -declare function resizeBy(x?: number, y?: number): void; -declare function item(index: any): any; -declare function resizeTo(x?: number, y?: number): void; -declare function createPopup(arguments?: any): MSPopupWindow; -declare function toStaticHTML(html: string): string; -declare function execScript(code: string, language?: string): any; -declare function msWriteProfilerMark(profilerMarkName: string): void; -declare function moveTo(x?: number, y?: number): void; -declare function moveBy(x?: number, y?: number): void; -declare function showHelp(url: string, helpArg?: any, features?: string): void; -declare var performance: any; -declare var outerWidth: number; -declare var pageXOffset: number; -declare var innerWidth: number; -declare var pageYOffset: number; -declare var screenY: number; -declare var outerHeight: number; -declare var screen: Screen; -declare var innerHeight: number; -declare var screenX: number; -declare function scroll(x?: number, y?: number): void; -declare function scrollBy(x?: number, y?: number): void; -declare function scrollTo(x?: number, y?: number): void; -declare var styleMedia: StyleMedia; -declare var document: Document; -declare function removeEventListener(type: string, listener: EventListener, useCapture?: boolean): void; -declare function addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; -declare function dispatchEvent(evt: Event): boolean; -declare var localStorage: Storage; -declare var sessionStorage: Storage; -declare function clearTimeout(handle: number): void; -declare function setTimeout(expression: any, msec?: number, language?: any): number; -declare function clearInterval(handle: number): void; -declare function setInterval(expression: any, msec?: number, language?: any): number; - - -///////////////////////////// -/// IE10 DOM APIs -///////////////////////////// - -interface HTMLBodyElement { - onpopstate: (ev: PopStateEvent) => any; - addEventListener(type: "popstate", listener: (ev: PopStateEvent) => any, useCapture?: boolean): void; -} - -interface MSGestureEvent extends UIEvent { - offsetY: number; - translationY: number; - velocityExpansion: number; - velocityY: number; - velocityAngular: number; - translationX: number; - velocityX: number; - hwTimestamp: number; - offsetX: number; - screenX: number; - rotation: number; - expansion: number; - clientY: number; - screenY: number; - scale: number; - gestureObject: any; - clientX: number; - initGestureEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: AbstractView, detailArg: number, screenXArg: number, screenYArg: number, clientXArg: number, clientYArg: number, offsetXArg: number, offsetYArg: number, translationXArg: number, translationYArg: number, scaleArg: number, expansionArg: number, rotationArg: number, velocityXArg: number, velocityYArg: number, velocityExpansionArg: number, velocityAngularArg: number, hwTimestampArg: number): void; - MSGESTURE_FLAG_BEGIN: number; - MSGESTURE_FLAG_END: number; - MSGESTURE_FLAG_CANCEL: number; - MSGESTURE_FLAG_INERTIA: number; - MSGESTURE_FLAG_NONE: number; -} -declare var MSGestureEvent: { - prototype: MSGestureEvent; - new(): MSGestureEvent; - MSGESTURE_FLAG_BEGIN: number; - MSGESTURE_FLAG_END: number; - MSGESTURE_FLAG_CANCEL: number; - MSGESTURE_FLAG_INERTIA: number; - MSGESTURE_FLAG_NONE: number; -} - -interface HTMLAnchorElement { - text: string; -} - -interface HTMLInputElement { - validationMessage: string; - files: FileList; - max: string; - formTarget: string; - willValidate: boolean; - step: string; - autofocus: boolean; - required: boolean; - formEnctype: string; - valueAsNumber: number; - placeholder: string; - formMethod: string; - list: HTMLElement; - autocomplete: string; - min: string; - formAction: string; - pattern: string; - validity: ValidityState; - formNoValidate: string; - multiple: boolean; - checkValidity(): boolean; - stepDown(n?: number): void; - stepUp(n?: number): void; - setCustomValidity(error: string): void; -} - -interface ErrorEvent extends Event { - colno: number; - filename: string; - lineno: number; - message: string; - initErrorEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, messageArg: string, filenameArg: string, linenoArg: number): void; -} -declare var ErrorEvent: { - prototype: ErrorEvent; - new(): ErrorEvent; -} - -interface SVGFilterElement extends SVGElement, SVGUnitTypes, SVGStylable, SVGLangSpace, SVGURIReference { - y: SVGAnimatedLength; - width: SVGAnimatedLength; - filterResX: SVGAnimatedInteger; - filterUnits: SVGAnimatedEnumeration; - primitiveUnits: SVGAnimatedEnumeration; - x: SVGAnimatedLength; - height: SVGAnimatedLength; - filterResY: SVGAnimatedInteger; - setFilterRes(filterResX: number, filterResY: number): void; -} -declare var SVGFilterElement: { - prototype: SVGFilterElement; - new(): SVGFilterElement; -} - -interface TrackEvent extends Event { - track: any; -} -declare var TrackEvent: { - prototype: TrackEvent; - new(): TrackEvent; -} - -interface SVGFEMergeNodeElement extends SVGElement { - in1: SVGAnimatedString; -} -declare var SVGFEMergeNodeElement: { - prototype: SVGFEMergeNodeElement; - new(): SVGFEMergeNodeElement; -} - -interface SVGFEFloodElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { -} -declare var SVGFEFloodElement: { - prototype: SVGFEFloodElement; - new(): SVGFEFloodElement; -} - -interface MSElementExtensions { - msRegionOverflow: string; - onmspointerdown: (ev: any) => any; - addEventListener(type: "mspointerdown", listener: (ev: any) => any, useCapture?: boolean): void; - onmsgotpointercapture: (ev: any) => any; - addEventListener(type: "msgotpointercapture", listener: (ev: any) => any, useCapture?: boolean): void; - onmsgesturedoubletap: (ev: any) => any; - addEventListener(type: "msgesturedoubletap", listener: (ev: any) => any, useCapture?: boolean): void; - onmspointerhover: (ev: any) => any; - addEventListener(type: "mspointerhover", listener: (ev: any) => any, useCapture?: boolean): void; - onmsgesturehold: (ev: any) => any; - addEventListener(type: "msgesturehold", listener: (ev: any) => any, useCapture?: boolean): void; - onmspointermove: (ev: any) => any; - addEventListener(type: "mspointermove", listener: (ev: any) => any, useCapture?: boolean): void; - onmsgesturechange: (ev: any) => any; - addEventListener(type: "msgesturechange", listener: (ev: any) => any, useCapture?: boolean): void; - onmsgesturestart: (ev: any) => any; - addEventListener(type: "msgesturestart", listener: (ev: any) => any, useCapture?: boolean): void; - onmspointercancel: (ev: any) => any; - addEventListener(type: "mspointercancel", listener: (ev: any) => any, useCapture?: boolean): void; - onmsgestureend: (ev: any) => any; - addEventListener(type: "msgestureend", listener: (ev: any) => any, useCapture?: boolean): void; - onmsgesturetap: (ev: any) => any; - addEventListener(type: "msgesturetap", listener: (ev: any) => any, useCapture?: boolean): void; - onmspointerout: (ev: any) => any; - addEventListener(type: "mspointerout", listener: (ev: any) => any, useCapture?: boolean): void; - onmsinertiastart: (ev: any) => any; - addEventListener(type: "msinertiastart", listener: (ev: any) => any, useCapture?: boolean): void; - onmslostpointercapture: (ev: any) => any; - addEventListener(type: "mslostpointercapture", listener: (ev: any) => any, useCapture?: boolean): void; - onmspointerover: (ev: any) => any; - addEventListener(type: "mspointerover", listener: (ev: any) => any, useCapture?: boolean): void; - msContentZoomFactor: number; - onmspointerup: (ev: any) => any; - addEventListener(type: "mspointerup", listener: (ev: any) => any, useCapture?: boolean): void; - msGetRegionContent(): MSRangeCollection; - msReleasePointerCapture(pointerId: number): void; - msSetPointerCapture(pointerId: number): void; - addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; -} -declare var MSElementExtensions: { - prototype: MSElementExtensions; - new(): MSElementExtensions; -} - -interface MSCSSScrollTranslationProperties { - msScrollTranslation: string; -} - -interface MSGesture { - target: Element; - addPointer(pointerId: number): void; - stop(): void; -} -declare var MSGesture: { - prototype: MSGesture; - new (): MSGesture; -} - -interface TextTrackCue extends EventTarget { - onenter: (ev: Event) => any; - addEventListener(type: "enter", listener: (ev: Event) => any, useCapture?: boolean): void; - track: TextTrack; - endTime: number; - text: string; - pauseOnExit: boolean; - id: string; - startTime: number; - onexit: (ev: Event) => any; - addEventListener(type: "exit", listener: (ev: Event) => any, useCapture?: boolean): void; - getCueAsHTML(): DocumentFragment; - addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; -} -declare var TextTrackCue: { - prototype: TextTrackCue; - new(): TextTrackCue; -} - -interface MSHTMLDocumentViewExtensions { - msCSSOMElementFloatMetrics: boolean; - msElementsFromPoint(x: number, y: number): NodeList; - msElementsFromRect(left: number, top: number, width: number, height: number): NodeList; -} -declare var MSHTMLDocumentViewExtensions: { - prototype: MSHTMLDocumentViewExtensions; - new(): MSHTMLDocumentViewExtensions; -} - -interface MSStreamReader extends MSBaseReader { - error: DOMError; - readAsArrayBuffer(stream: MSStream, size?: number): void; - readAsBlob(stream: MSStream, size?: number): void; - readAsDataURL(stream: MSStream, size?: number): void; - readAsText(stream: MSStream, encoding?: string, size?: number): void; -} -declare var MSStreamReader: { - prototype: MSStreamReader; - new (): MSStreamReader; -} - -interface CSSFlexibleBoxProperties { - msFlex: string; - msFlexDirection: string; - msFlexNegative: string; - msFlexPack: string; - msFlexWrap: string; - msFlexItemAlign: string; - msFlexOrder: string; - msFlexPositive: string; - msFlexAlign: string; - msFlexFlow: string; - msFlexPreferredSize: string; - msFlexLinePack: string; -} - -interface DOMTokenList { - length: number; - contains(token: string): boolean; - remove(token: string): void; - toggle(token: string): boolean; - add(token: string): void; - item(index: number): string; - [index: number]: string; - toString(): string; -} -declare var DOMTokenList: { - prototype: DOMTokenList; - new(): DOMTokenList; -} - -interface EventException { - name: string; -} - -interface SVGFEFuncAElement extends SVGComponentTransferFunctionElement { -} -declare var SVGFEFuncAElement: { - prototype: SVGFEFuncAElement; - new(): SVGFEFuncAElement; -} - -interface Performance { - now(): number; -} - -interface SVGFETileElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { - in1: SVGAnimatedString; -} -declare var SVGFETileElement: { - prototype: SVGFETileElement; - new(): SVGFETileElement; -} - -interface SVGFEBlendElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { - in2: SVGAnimatedString; - mode: SVGAnimatedEnumeration; - in1: SVGAnimatedString; - SVG_FEBLEND_MODE_DARKEN: number; - SVG_FEBLEND_MODE_UNKNOWN: number; - SVG_FEBLEND_MODE_MULTIPLY: number; - SVG_FEBLEND_MODE_NORMAL: number; - SVG_FEBLEND_MODE_SCREEN: number; - SVG_FEBLEND_MODE_LIGHTEN: number; -} -declare var SVGFEBlendElement: { - prototype: SVGFEBlendElement; - new(): SVGFEBlendElement; - SVG_FEBLEND_MODE_DARKEN: number; - SVG_FEBLEND_MODE_UNKNOWN: number; - SVG_FEBLEND_MODE_MULTIPLY: number; - SVG_FEBLEND_MODE_NORMAL: number; - SVG_FEBLEND_MODE_SCREEN: number; - SVG_FEBLEND_MODE_LIGHTEN: number; -} - -interface WindowTimers extends WindowTimersExtension { -} -declare var WindowTimers: { - prototype: WindowTimers; - new(): WindowTimers; -} - -interface CSSStyleDeclaration extends CSS2DTransformsProperties, CSSTransitionsProperties, CSSFontsProperties, MSCSSHighContrastProperties, CSSGridProperties, CSSAnimationsProperties, MSCSSContentZoomProperties, MSCSSScrollTranslationProperties, MSCSSTouchManipulationProperties, CSSFlexibleBoxProperties, MSCSSPositionedFloatsProperties, MSCSSRegionProperties, MSCSSSelectionBoundaryProperties, CSSMultiColumnProperties, CSSTextProperties, CSS3DTransformsProperties { -} - -interface MessageChannel { - port2: MessagePort; - port1: MessagePort; -} -declare var MessageChannel: { - prototype: MessageChannel; - new (): MessageChannel; -} - -interface SVGFEMergeElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { -} -declare var SVGFEMergeElement: { - prototype: SVGFEMergeElement; - new(): SVGFEMergeElement; -} - -interface Navigator extends MSFileSaver { -} - -interface TransitionEvent extends Event { - propertyName: string; - elapsedTime: number; - initTransitionEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, propertyNameArg: string, elapsedTimeArg: number): void; -} -declare var TransitionEvent: { - prototype: TransitionEvent; - new(): TransitionEvent; -} - -interface MediaQueryList { - matches: boolean; - media: string; - addListener(listener: MediaQueryListListener): void; - removeListener(listener: MediaQueryListListener): void; -} -declare var MediaQueryList: { - prototype: MediaQueryList; - new(): MediaQueryList; -} - -interface DOMError { - name: string; - toString(): string; -} -declare var DOMError: { - prototype: DOMError; - new(): DOMError; -} - -interface SVGFEPointLightElement extends SVGElement { - y: SVGAnimatedNumber; - x: SVGAnimatedNumber; - z: SVGAnimatedNumber; -} -declare var SVGFEPointLightElement: { - prototype: SVGFEPointLightElement; - new(): SVGFEPointLightElement; -} - -interface CSSFontsProperties { - msFontFeatureSettings: string; - fontFeatureSettings: string; -} - -interface CloseEvent extends Event { - wasClean: boolean; - reason: string; - code: number; - initCloseEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, wasCleanArg: boolean, codeArg: number, reasonArg: string): void; -} -declare var CloseEvent: { - prototype: CloseEvent; - new(): CloseEvent; -} - -interface WebSocket extends EventTarget { - protocol: string; - readyState: number; - bufferedAmount: number; - onopen: (ev: Event) => any; - addEventListener(type: "open", listener: (ev: Event) => any, useCapture?: boolean): void; - extensions: string; - onmessage: (ev: any) => any; - addEventListener(type: "message", listener: (ev: any) => any, useCapture?: boolean): void; - onclose: (ev: CloseEvent) => any; - addEventListener(type: "close", listener: (ev: CloseEvent) => any, useCapture?: boolean): void; - onerror: (ev: ErrorEvent) => any; - addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; - binaryType: string; - url: string; - close(code?: number, reason?: string): void; - send(data: any): void; - OPEN: number; - CLOSING: number; - CONNECTING: number; - CLOSED: number; - addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; -} -declare var WebSocket: { - prototype: WebSocket; - new (url: string): WebSocket; - new (url: string, prototcol: string): WebSocket; - new (url: string, prototcol: string[]): WebSocket; - OPEN: number; - CLOSING: number; - CONNECTING: number; - CLOSED: number; -} - -interface ProgressEvent extends Event { - loaded: number; - lengthComputable: boolean; - total: number; - initProgressEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, lengthComputableArg: boolean, loadedArg: number, totalArg: number): void; -} -declare var ProgressEvent: { - prototype: ProgressEvent; - new(): ProgressEvent; -} - -interface HTMLCanvasElement { - msToBlob(): Blob; -} - -interface IDBObjectStore { - indexNames: DOMStringList; - name: string; - transaction: IDBTransaction; - keyPath: string; - count(key?: any): IDBRequest; - add(value: any, key?: any): IDBRequest; - clear(): IDBRequest; - createIndex(name: string, keyPath: string, optionalParameters?: any): IDBIndex; - put(value: any, key?: any): IDBRequest; - openCursor(range?: any, direction?: string): IDBRequest; - deleteIndex(indexName: string): void; - index(name: string): IDBIndex; - get(key: any): IDBRequest; - delete(key: any): IDBRequest; -} -declare var IDBObjectStore: { - prototype: IDBObjectStore; - new(): IDBObjectStore; -} - -interface ObjectURLOptions { - oneTimeOnly?: boolean; -} - -interface SVGFEGaussianBlurElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { - stdDeviationX: SVGAnimatedNumber; - in1: SVGAnimatedString; - stdDeviationY: SVGAnimatedNumber; - setStdDeviation(stdDeviationX: number, stdDeviationY: number): void; -} -declare var SVGFEGaussianBlurElement: { - prototype: SVGFEGaussianBlurElement; - new(): SVGFEGaussianBlurElement; -} - -interface MSHTMLDocumentExtensions { - onmspointerdown: (ev: any) => any; - addEventListener(type: "mspointerdown", listener: (ev: any) => any, useCapture?: boolean): void; - onmspointercancel: (ev: any) => any; - addEventListener(type: "mspointercancel", listener: (ev: any) => any, useCapture?: boolean): void; - onmsgesturedoubletap: (ev: any) => any; - addEventListener(type: "msgesturedoubletap", listener: (ev: any) => any, useCapture?: boolean): void; - onmsgesturetap: (ev: any) => any; - addEventListener(type: "msgesturetap", listener: (ev: any) => any, useCapture?: boolean): void; - onmsgestureend: (ev: any) => any; - addEventListener(type: "msgestureend", listener: (ev: any) => any, useCapture?: boolean): void; - onmspointerout: (ev: any) => any; - addEventListener(type: "mspointerout", listener: (ev: any) => any, useCapture?: boolean): void; - onmsmanipulationstatechanged: (ev: any) => any; - addEventListener(type: "msmanipulationstatechanged", listener: (ev: any) => any, useCapture?: boolean): void; - onmsinertiastart: (ev: any) => any; - addEventListener(type: "msinertiastart", listener: (ev: any) => any, useCapture?: boolean): void; - onmspointerhover: (ev: any) => any; - addEventListener(type: "mspointerhover", listener: (ev: any) => any, useCapture?: boolean): void; - onmscontentzoom: (ev: any) => any; - addEventListener(type: "mscontentzoom", listener: (ev: any) => any, useCapture?: boolean): void; - onmsgesturehold: (ev: any) => any; - addEventListener(type: "msgesturehold", listener: (ev: any) => any, useCapture?: boolean): void; - onmspointermove: (ev: any) => any; - addEventListener(type: "mspointermove", listener: (ev: any) => any, useCapture?: boolean): void; - onmspointerover: (ev: any) => any; - addEventListener(type: "mspointerover", listener: (ev: any) => any, useCapture?: boolean): void; - onmsgesturechange: (ev: any) => any; - addEventListener(type: "msgesturechange", listener: (ev: any) => any, useCapture?: boolean): void; - onmsgesturestart: (ev: any) => any; - addEventListener(type: "msgesturestart", listener: (ev: any) => any, useCapture?: boolean): void; - onmspointerup: (ev: any) => any; - addEventListener(type: "mspointerup", listener: (ev: any) => any, useCapture?: boolean): void; -} -declare var MSHTMLDocumentExtensions: { - prototype: MSHTMLDocumentExtensions; - new(): MSHTMLDocumentExtensions; -} - -interface MSCSSSelectionBoundaryProperties { - msUserSelect: string; -} - -interface SVGFilterPrimitiveStandardAttributes extends SVGStylable { - y: SVGAnimatedLength; - width: SVGAnimatedLength; - x: SVGAnimatedLength; - height: SVGAnimatedLength; - result: SVGAnimatedString; -} - -interface IDBVersionChangeEvent extends Event { - newVersion: number; - oldVersion: number; -} -declare var IDBVersionChangeEvent: { - prototype: IDBVersionChangeEvent; - new(): IDBVersionChangeEvent; -} - -interface IDBIndex { - unique: boolean; - name: string; - keyPath: string; - objectStore: IDBObjectStore; - count(key?: any): IDBRequest; - getKey(key: any): IDBRequest; - openKeyCursor(range?: IDBKeyRange, direction?: string): IDBRequest; - get(key: any): IDBRequest; - openCursor(range?: IDBKeyRange, direction?: string): IDBRequest; -} -declare var IDBIndex: { - prototype: IDBIndex; - new(): IDBIndex; -} - -interface FileList { - length: number; - item(index: number): File; - [index: number]: File; -} -declare var FileList: { - prototype: FileList; - new(): FileList; -} - -interface IDBCursor { - source: any; - direction: string; - key: any; - primaryKey: any; - advance(count: number): void; - delete(): IDBRequest; - continue(key?: any): void; - update(value: any): IDBRequest; -} -declare var IDBCursor: { - prototype: IDBCursor; - new(): IDBCursor; -} - -interface CSSAnimationsProperties { - animationFillMode: string; - msAnimationDirection: string; - msAnimationDelay: string; - msAnimationFillMode: string; - animationIterationCount: string; - msAnimationPlayState: string; - msAnimationIterationCount: string; - animationDelay: string; - animationTimingFunction: string; - msAnimation: string; - animation: string; - animationDirection: string; - animationDuration: string; - animationName: string; - animationPlayState: string; - msAnimationTimingFunction: string; - msAnimationName: string; - msAnimationDuration: string; -} - -interface SVGFESpecularLightingElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { - kernelUnitLengthY: SVGAnimatedNumber; - surfaceScale: SVGAnimatedNumber; - specularExponent: SVGAnimatedNumber; - in1: SVGAnimatedString; - kernelUnitLengthX: SVGAnimatedNumber; - specularConstant: SVGAnimatedNumber; -} -declare var SVGFESpecularLightingElement: { - prototype: SVGFESpecularLightingElement; - new(): SVGFESpecularLightingElement; -} - -interface File extends Blob { - lastModifiedDate: any; - name: string; -} -declare var File: { - prototype: File; - new(): File; -} - -interface URL { - revokeObjectURL(url: string): void; - createObjectURL(object: any, options?: ObjectURLOptions): string; -} -declare var URL: URL; - -interface RangeException { - name: string; -} - -interface IDBCursorWithValue extends IDBCursor { - value: any; -} -declare var IDBCursorWithValue: { - prototype: IDBCursorWithValue; - new(): IDBCursorWithValue; -} - -interface HTMLTextAreaElement { - validationMessage: string; - autofocus: boolean; - validity: ValidityState; - required: boolean; - maxLength: number; - willValidate: boolean; - placeholder: string; - checkValidity(): boolean; - setCustomValidity(error: string): void; -} - -interface XMLHttpRequestEventTarget extends EventTarget { - onprogress: (ev: ProgressEvent) => any; - addEventListener(type: "progress", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; - onerror: (ev: ErrorEvent) => any; - addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; - onload: (ev: any) => any; - addEventListener(type: "load", listener: (ev: any) => any, useCapture?: boolean): void; - ontimeout: (ev: any) => any; - addEventListener(type: "timeout", listener: (ev: any) => any, useCapture?: boolean): void; - onabort: (ev: any) => any; - addEventListener(type: "abort", listener: (ev: any) => any, useCapture?: boolean): void; - onloadstart: (ev: any) => any; - addEventListener(type: "loadstart", listener: (ev: any) => any, useCapture?: boolean): void; - onloadend: (ev: ProgressEvent) => any; - addEventListener(type: "loadend", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; - addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; -} -declare var XMLHttpRequestEventTarget: { - prototype: XMLHttpRequestEventTarget; - new(): XMLHttpRequestEventTarget; -} - -interface IDBEnvironment { - msIndexedDB: IDBFactory; - indexedDB: IDBFactory; -} - -interface AudioTrackList extends EventTarget { - length: number; - onchange: (ev: any) => any; - addEventListener(type: "change", listener: (ev: any) => any, useCapture?: boolean): void; - onaddtrack: (ev: TrackEvent) => any; - addEventListener(type: "addtrack", listener: (ev: TrackEvent) => any, useCapture?: boolean): void; - getTrackById(id: string): AudioTrack; - item(index: number): AudioTrack; - [index: number]: AudioTrack; - addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; -} -declare var AudioTrackList: { - prototype: AudioTrackList; - new(): AudioTrackList; -} - -interface MSBaseReader extends EventTarget { - onprogress: (ev: ProgressEvent) => any; - addEventListener(type: "progress", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; - readyState: number; - onabort: (ev: any) => any; - addEventListener(type: "abort", listener: (ev: any) => any, useCapture?: boolean): void; - onloadend: (ev: ProgressEvent) => any; - addEventListener(type: "loadend", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; - onerror: (ev: ErrorEvent) => any; - addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; - onload: (ev: any) => any; - addEventListener(type: "load", listener: (ev: any) => any, useCapture?: boolean): void; - onloadstart: (ev: any) => any; - addEventListener(type: "loadstart", listener: (ev: any) => any, useCapture?: boolean): void; - result: any; - abort(): void; - LOADING: number; - EMPTY: number; - DONE: number; - addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; -} - -interface History { - state: any; - replaceState(statedata: any, title: string, url?: string): void; - pushState(statedata: any, title: string, url?: string): void; -} - -interface MSProtocol { - protocol: string; -} -declare var MSProtocol: { - prototype: MSProtocol; - new(): MSProtocol; -} - -interface SVGFEMorphologyElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { - operator: SVGAnimatedEnumeration; - radiusX: SVGAnimatedNumber; - radiusY: SVGAnimatedNumber; - in1: SVGAnimatedString; - SVG_MORPHOLOGY_OPERATOR_UNKNOWN: number; - SVG_MORPHOLOGY_OPERATOR_ERODE: number; - SVG_MORPHOLOGY_OPERATOR_DILATE: number; -} -declare var SVGFEMorphologyElement: { - prototype: SVGFEMorphologyElement; - new(): SVGFEMorphologyElement; - SVG_MORPHOLOGY_OPERATOR_UNKNOWN: number; - SVG_MORPHOLOGY_OPERATOR_ERODE: number; - SVG_MORPHOLOGY_OPERATOR_DILATE: number; -} - -interface HTMLSelectElement { - validationMessage: string; - autofocus: boolean; - validity: ValidityState; - required: boolean; - willValidate: boolean; - checkValidity(): boolean; - setCustomValidity(error: string): void; -} - -interface CSSTransitionsProperties { - transition: string; - transitionDelay: string; - transitionDuration: string; - msTransitionTimingFunction: string; - msTransition: string; - msTransitionDuration: string; - transitionTimingFunction: string; - msTransitionDelay: string; - transitionProperty: string; - msTransitionProperty: string; -} - -interface SVGFEFuncRElement extends SVGComponentTransferFunctionElement { -} -declare var SVGFEFuncRElement: { - prototype: SVGFEFuncRElement; - new(): SVGFEFuncRElement; -} - -interface CSSRule { - KEYFRAMES_RULE: number; - KEYFRAME_RULE: number; - VIEWPORT_RULE: number; -} -//declare var CSSRule: { -// KEYFRAMES_RULE: number; -// KEYFRAME_RULE: number; -// VIEWPORT_RULE: number; -//} - -interface WindowTimersExtension { - msSetImmediate(expression: any, ...args: any[]): number; - clearImmediate(handle: number): void; - msClearImmediate(handle: number): void; - setImmediate(expression: any, ...args: any[]): number; -} - -interface SVGFEDisplacementMapElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { - in2: SVGAnimatedString; - xChannelSelector: SVGAnimatedEnumeration; - yChannelSelector: SVGAnimatedEnumeration; - scale: SVGAnimatedNumber; - in1: SVGAnimatedString; - SVG_CHANNEL_B: number; - SVG_CHANNEL_R: number; - SVG_CHANNEL_G: number; - SVG_CHANNEL_UNKNOWN: number; - SVG_CHANNEL_A: number; -} -declare var SVGFEDisplacementMapElement: { - prototype: SVGFEDisplacementMapElement; - new(): SVGFEDisplacementMapElement; - SVG_CHANNEL_B: number; - SVG_CHANNEL_R: number; - SVG_CHANNEL_G: number; - SVG_CHANNEL_UNKNOWN: number; - SVG_CHANNEL_A: number; -} - -interface MSCSSContentZoomProperties { - msContentZoomLimit: string; - msContentZooming: string; - msContentZoomSnapType: string; - msContentZoomLimitMax: any; - msContentZoomSnapPoints: string; - msContentZoomSnap: string; - msContentZoomLimitMin: any; - msContentZoomChaining: string; -} - -interface AnimationEvent extends Event { - animationName: string; - elapsedTime: number; - initAnimationEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, animationNameArg: string, elapsedTimeArg: number): void; -} -declare var AnimationEvent: { - prototype: AnimationEvent; - new(): AnimationEvent; -} - -interface SVGComponentTransferFunctionElement extends SVGElement { - tableValues: SVGAnimatedNumberList; - slope: SVGAnimatedNumber; - type: SVGAnimatedEnumeration; - exponent: SVGAnimatedNumber; - amplitude: SVGAnimatedNumber; - intercept: SVGAnimatedNumber; - offset: SVGAnimatedNumber; - SVG_FECOMPONENTTRANSFER_TYPE_UNKNOWN: number; - SVG_FECOMPONENTTRANSFER_TYPE_TABLE: number; - SVG_FECOMPONENTTRANSFER_TYPE_IDENTITY: number; - SVG_FECOMPONENTTRANSFER_TYPE_GAMMA: number; - SVG_FECOMPONENTTRANSFER_TYPE_DISCRETE: number; - SVG_FECOMPONENTTRANSFER_TYPE_LINEAR: number; -} -declare var SVGComponentTransferFunctionElement: { - prototype: SVGComponentTransferFunctionElement; - new(): SVGComponentTransferFunctionElement; - SVG_FECOMPONENTTRANSFER_TYPE_UNKNOWN: number; - SVG_FECOMPONENTTRANSFER_TYPE_TABLE: number; - SVG_FECOMPONENTTRANSFER_TYPE_IDENTITY: number; - SVG_FECOMPONENTTRANSFER_TYPE_GAMMA: number; - SVG_FECOMPONENTTRANSFER_TYPE_DISCRETE: number; - SVG_FECOMPONENTTRANSFER_TYPE_LINEAR: number; -} - -interface MSRangeCollection { - length: number; - item(index: number): Range; - [index: number]: Range; -} -declare var MSRangeCollection: { - prototype: MSRangeCollection; - new(): MSRangeCollection; -} - -interface MSHTMLElementExtensions { - onmscontentzoom: (ev: any) => any; - addEventListener(type: "mscontentzoom", listener: (ev: any) => any, useCapture?: boolean): void; - onmsmanipulationstatechanged: (ev: any) => any; - addEventListener(type: "msmanipulationstatechanged", listener: (ev: any) => any, useCapture?: boolean): void; -} -declare var MSHTMLElementExtensions: { - prototype: MSHTMLElementExtensions; - new(): MSHTMLElementExtensions; -} - -interface MSCSSPositionedFloatsProperties { - msWrapMargin: any; - msWrapFlow: string; -} - -interface SVGException { - name: string; -} - -interface SVGFEDistantLightElement extends SVGElement { - azimuth: SVGAnimatedNumber; - elevation: SVGAnimatedNumber; -} -declare var SVGFEDistantLightElement: { - prototype: SVGFEDistantLightElement; - new(): SVGFEDistantLightElement; -} - -interface MSCSSRegionProperties { - msFlowFrom: string; - msFlowInto: string; - msWrapThrough: string; -} - -interface SVGFEFuncBElement extends SVGComponentTransferFunctionElement { -} -declare var SVGFEFuncBElement: { - prototype: SVGFEFuncBElement; - new(): SVGFEFuncBElement; -} - -interface IDBKeyRange { - upper: any; - upperOpen: boolean; - lower: any; - lowerOpen: boolean; - bound(lower: any, upper: any, lowerOpen?: boolean, upperOpen?: boolean): IDBKeyRange; - only(value: any): IDBKeyRange; - lowerBound(bound: any, open?: boolean): IDBKeyRange; - upperBound(bound: any, open?: boolean): IDBKeyRange; -} -declare var IDBKeyRange: { - prototype: IDBKeyRange; - new (): IDBKeyRange; -} - -interface WindowConsole { - console: Console; -} - -interface SVG1_1Properties { - floodOpacity: string; - floodColor: string; - filter: string; - lightingColor: string; - enableBackground: string; - colorInterpolationFilters: string; -} -declare var SVG1_1Properties: { - prototype: SVG1_1Properties; - new(): SVG1_1Properties; -} - -interface IDBTransaction extends EventTarget { - oncomplete: (ev: Event) => any; - addEventListener(type: "complete", listener: (ev: Event) => any, useCapture?: boolean): void; - db: IDBDatabase; - mode: string; - error: DOMError; - onerror: (ev: ErrorEvent) => any; - addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; - onabort: (ev: any) => any; - addEventListener(type: "abort", listener: (ev: any) => any, useCapture?: boolean): void; - abort(): void; - objectStore(name: string): IDBObjectStore; - addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; -} -declare var IDBTransaction: { - prototype: IDBTransaction; - new(): IDBTransaction; -} - -interface MSWindowExtensions { - onmspointerdown: (ev: any) => any; - addEventListener(type: "mspointerdown", listener: (ev: any) => any, useCapture?: boolean): void; - onmspointercancel: (ev: any) => any; - addEventListener(type: "mspointercancel", listener: (ev: any) => any, useCapture?: boolean): void; - onmsgesturedoubletap: (ev: any) => any; - addEventListener(type: "msgesturedoubletap", listener: (ev: any) => any, useCapture?: boolean): void; - onmsgestureend: (ev: any) => any; - addEventListener(type: "msgestureend", listener: (ev: any) => any, useCapture?: boolean): void; - onmsgesturetap: (ev: any) => any; - addEventListener(type: "msgesturetap", listener: (ev: any) => any, useCapture?: boolean): void; - onmspointerout: (ev: any) => any; - addEventListener(type: "mspointerout", listener: (ev: any) => any, useCapture?: boolean): void; - onmspointerhover: (ev: any) => any; - addEventListener(type: "mspointerhover", listener: (ev: any) => any, useCapture?: boolean): void; - onmsinertiastart: (ev: any) => any; - addEventListener(type: "msinertiastart", listener: (ev: any) => any, useCapture?: boolean): void; - onmspointermove: (ev: any) => any; - addEventListener(type: "mspointermove", listener: (ev: any) => any, useCapture?: boolean): void; - onmsgesturehold: (ev: any) => any; - addEventListener(type: "msgesturehold", listener: (ev: any) => any, useCapture?: boolean): void; - onmspointerover: (ev: any) => any; - addEventListener(type: "mspointerover", listener: (ev: any) => any, useCapture?: boolean): void; - onmsgesturechange: (ev: any) => any; - addEventListener(type: "msgesturechange", listener: (ev: any) => any, useCapture?: boolean): void; - onmsgesturestart: (ev: any) => any; - addEventListener(type: "msgesturestart", listener: (ev: any) => any, useCapture?: boolean): void; - onmspointerup: (ev: any) => any; - addEventListener(type: "mspointerup", listener: (ev: any) => any, useCapture?: boolean): void; - msIsStaticHTML(html: string): boolean; -} -declare var MSWindowExtensions: { - prototype: MSWindowExtensions; - new(): MSWindowExtensions; -} - -interface AudioTrack { - kind: string; - language: string; - id: string; - label: string; - enabled: boolean; -} -declare var AudioTrack: { - prototype: AudioTrack; - new(): AudioTrack; -} - -interface SVGFEConvolveMatrixElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { - orderY: SVGAnimatedInteger; - kernelUnitLengthY: SVGAnimatedNumber; - orderX: SVGAnimatedInteger; - preserveAlpha: SVGAnimatedBoolean; - kernelMatrix: SVGAnimatedNumberList; - edgeMode: SVGAnimatedEnumeration; - kernelUnitLengthX: SVGAnimatedNumber; - bias: SVGAnimatedNumber; - targetX: SVGAnimatedInteger; - targetY: SVGAnimatedInteger; - divisor: SVGAnimatedNumber; - in1: SVGAnimatedString; - SVG_EDGEMODE_WRAP: number; - SVG_EDGEMODE_DUPLICATE: number; - SVG_EDGEMODE_UNKNOWN: number; - SVG_EDGEMODE_NONE: number; -} -declare var SVGFEConvolveMatrixElement: { - prototype: SVGFEConvolveMatrixElement; - new(): SVGFEConvolveMatrixElement; - SVG_EDGEMODE_WRAP: number; - SVG_EDGEMODE_DUPLICATE: number; - SVG_EDGEMODE_UNKNOWN: number; - SVG_EDGEMODE_NONE: number; -} - -interface TextTrackCueList { - length: number; - item(index: number): TextTrackCue; - [index: number]: TextTrackCue; - getCueById(id: string): TextTrackCue; -} -declare var TextTrackCueList: { - prototype: TextTrackCueList; - new(): TextTrackCueList; -} - -interface CSSKeyframesRule extends CSSRule { - name: string; - cssRules: CSSRuleList; - findRule(rule: string): CSSKeyframeRule; - deleteRule(rule: string): void; - appendRule(rule: string): void; -} -declare var CSSKeyframesRule: { - prototype: CSSKeyframesRule; - new(): CSSKeyframesRule; -} - -interface MSCSSTouchManipulationProperties { - msScrollSnapPointsY: string; - msOverflowStyle: string; - msScrollLimitXMax: any; - msScrollSnapType: string; - msScrollSnapPointsX: string; - msScrollLimitYMax: any; - msScrollSnapY: string; - msScrollLimitXMin: any; - msScrollLimitYMin: any; - msScrollChaining: string; - msTouchAction: string; - msScrollSnapX: string; - msScrollLimit: string; - msScrollRails: string; - msTouchSelect: string; -} - -interface Window extends WindowAnimationTiming, WindowBase64, IDBEnvironment, WindowConsole { - onpopstate: (ev: PopStateEvent) => any; - addEventListener(type: "popstate", listener: (ev: PopStateEvent) => any, useCapture?: boolean): void; - applicationCache: ApplicationCache; - matchMedia(mediaQuery: string): MediaQueryList; - msMatchMedia(mediaQuery: string): MediaQueryList; -} - -interface SVGFETurbulenceElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { - baseFrequencyX: SVGAnimatedNumber; - numOctaves: SVGAnimatedInteger; - type: SVGAnimatedEnumeration; - baseFrequencyY: SVGAnimatedNumber; - stitchTiles: SVGAnimatedEnumeration; - seed: SVGAnimatedNumber; - SVG_STITCHTYPE_UNKNOWN: number; - SVG_STITCHTYPE_NOSTITCH: number; - SVG_TURBULENCE_TYPE_UNKNOWN: number; - SVG_TURBULENCE_TYPE_TURBULENCE: number; - SVG_TURBULENCE_TYPE_FRACTALNOISE: number; - SVG_STITCHTYPE_STITCH: number; -} -declare var SVGFETurbulenceElement: { - prototype: SVGFETurbulenceElement; - new(): SVGFETurbulenceElement; - SVG_STITCHTYPE_UNKNOWN: number; - SVG_STITCHTYPE_NOSTITCH: number; - SVG_TURBULENCE_TYPE_UNKNOWN: number; - SVG_TURBULENCE_TYPE_TURBULENCE: number; - SVG_TURBULENCE_TYPE_FRACTALNOISE: number; - SVG_STITCHTYPE_STITCH: number; -} - -interface TextTrackList { - length: number; - item(index: number): TextTrack; - [index: number]: TextTrack; -} -declare var TextTrackList: { - prototype: TextTrackList; - new(): TextTrackList; -} - -interface WindowAnimationTiming { - animationStartTime: number; - msAnimationStartTime: number; - msCancelRequestAnimationFrame(handle: number): void; - cancelAnimationFrame(handle: number): void; - requestAnimationFrame(callback: FrameRequestCallback): number; - msRequestAnimationFrame(callback: FrameRequestCallback): number; -} - -interface SVGFEFuncGElement extends SVGComponentTransferFunctionElement { -} -declare var SVGFEFuncGElement: { - prototype: SVGFEFuncGElement; - new(): SVGFEFuncGElement; -} - -interface SVGFEColorMatrixElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { - in1: SVGAnimatedString; - type: SVGAnimatedEnumeration; - values: SVGAnimatedNumberList; - SVG_FECOLORMATRIX_TYPE_SATURATE: number; - SVG_FECOLORMATRIX_TYPE_UNKNOWN: number; - SVG_FECOLORMATRIX_TYPE_MATRIX: number; - SVG_FECOLORMATRIX_TYPE_HUEROTATE: number; - SVG_FECOLORMATRIX_TYPE_LUMINANCETOALPHA: number; -} -declare var SVGFEColorMatrixElement: { - prototype: SVGFEColorMatrixElement; - new(): SVGFEColorMatrixElement; - SVG_FECOLORMATRIX_TYPE_SATURATE: number; - SVG_FECOLORMATRIX_TYPE_UNKNOWN: number; - SVG_FECOLORMATRIX_TYPE_MATRIX: number; - SVG_FECOLORMATRIX_TYPE_HUEROTATE: number; - SVG_FECOLORMATRIX_TYPE_LUMINANCETOALPHA: number; -} - -interface Console { - info(): void; - info(message: any, ...optionalParams: any[]): void; - profile(reportName?: string): boolean; - assert(): void; - assert(test: boolean): void; - assert(test: boolean, message: any, ...optionalParams: any[]): void; - msIsIndependentlyComposed(element: Element): boolean; - clear(): boolean; - dir(): boolean; - dir(value: any, ...optionalParams: any[]): boolean; - warn(): void; - warn(message: any, ...optionalParams: any[]): void; - error(): void; - error(message: any, ...optionalParams: any[]): void; - log(): void; - log(message: any, ...optionalParams: any[]): void; - profileEnd(): boolean; -} -declare var Console: { - prototype: Console; - new(): Console; -} - -interface SVGFESpotLightElement extends SVGElement { - pointsAtY: SVGAnimatedNumber; - y: SVGAnimatedNumber; - limitingConeAngle: SVGAnimatedNumber; - specularExponent: SVGAnimatedNumber; - x: SVGAnimatedNumber; - pointsAtZ: SVGAnimatedNumber; - z: SVGAnimatedNumber; - pointsAtX: SVGAnimatedNumber; -} -declare var SVGFESpotLightElement: { - prototype: SVGFESpotLightElement; - new(): SVGFESpotLightElement; -} - -interface DocumentVisibility { - msHidden: boolean; - msVisibilityState: string; - visibilityState: string; - hidden: boolean; -} - -interface WindowBase64 { - btoa(rawString: string): string; - atob(encodedString: string): string; -} - -interface IDBDatabase extends EventTarget { - version: string; - name: string; - objectStoreNames: DOMStringList; - onerror: (ev: ErrorEvent) => any; - addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; - onabort: (ev: any) => any; - addEventListener(type: "abort", listener: (ev: any) => any, useCapture?: boolean): void; - createObjectStore(name: string, optionalParameters?: any): IDBObjectStore; - close(): void; - transaction(storeNames: any, mode?: string): IDBTransaction; - deleteObjectStore(name: string): void; - addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; -} -declare var IDBDatabase: { - prototype: IDBDatabase; - new(): IDBDatabase; -} - -interface MSProtocolsCollection { -} -declare var MSProtocolsCollection: { - prototype: MSProtocolsCollection; - new(): MSProtocolsCollection; -} - -interface DOMStringList { - length: number; - contains(str: string): boolean; - item(index: number): string; - [index: number]: string; -} -declare var DOMStringList: { - prototype: DOMStringList; - new(): DOMStringList; -} - -interface CSSMultiColumnProperties { - breakAfter: string; - columnSpan: string; - columnRule: string; - columnFill: string; - columnRuleStyle: string; - breakBefore: string; - columnCount: any; - breakInside: string; - columnWidth: any; - columns: string; - columnRuleColor: any; - columnGap: any; - columnRuleWidth: any; -} - -interface IDBOpenDBRequest extends IDBRequest { - onupgradeneeded: (ev: IDBVersionChangeEvent) => any; - addEventListener(type: "upgradeneeded", listener: (ev: IDBVersionChangeEvent) => any, useCapture?: boolean): void; - onblocked: (ev: Event) => any; - addEventListener(type: "blocked", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; -} -declare var IDBOpenDBRequest: { - prototype: IDBOpenDBRequest; - new(): IDBOpenDBRequest; -} - -interface HTMLButtonElement { - validationMessage: string; - formTarget: string; - willValidate: boolean; - formAction: string; - autofocus: boolean; - validity: ValidityState; - formNoValidate: string; - formEnctype: string; - formMethod: string; - checkValidity(): boolean; - setCustomValidity(error: string): void; -} - -interface HTMLProgressElement extends HTMLElement { - value: number; - max: number; - position: number; - form: HTMLFormElement; -} -declare var HTMLProgressElement: { - prototype: HTMLProgressElement; - new(): HTMLProgressElement; -} - -interface SVGFEOffsetElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { - dy: SVGAnimatedNumber; - in1: SVGAnimatedString; - dx: SVGAnimatedNumber; -} -declare var SVGFEOffsetElement: { - prototype: SVGFEOffsetElement; - new(): SVGFEOffsetElement; -} - -interface HTMLFormElement { - autocomplete: string; - noValidate: boolean; - checkValidity(): boolean; -} - -interface MSUnsafeFunctionCallback { - (): any; -} - -interface Document extends DocumentVisibility { -} - -interface MessageEvent extends Event { - ports: any; -} - -interface HTMLScriptElement { - async: boolean; -} - -interface HTMLMediaElement extends MSHTMLMediaElementExtensions { - textTracks: TextTrackList; - audioTracks: AudioTrackList; -} - -interface TextTrack extends EventTarget { - language: string; - mode: number; - readyState: string; - activeCues: TextTrackCueList; - cues: TextTrackCueList; - oncuechange: (ev: Event) => any; - addEventListener(type: "cuechange", listener: (ev: Event) => any, useCapture?: boolean): void; - kind: string; - onload: (ev: any) => any; - addEventListener(type: "load", listener: (ev: any) => any, useCapture?: boolean): void; - onerror: (ev: ErrorEvent) => any; - addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; - label: string; - ERROR: number; - SHOWING: number; - LOADING: number; - LOADED: number; - NONE: number; - HIDDEN: number; - DISABLED: number; - addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; -} -declare var TextTrack: { - prototype: TextTrack; - new(): TextTrack; - ERROR: number; - SHOWING: number; - LOADING: number; - LOADED: number; - NONE: number; - HIDDEN: number; - DISABLED: number; -} - -interface MediaQueryListListener { - (mql: MediaQueryList): void; -} - -interface IDBRequest extends EventTarget { - source: any; - onsuccess: (ev: Event) => any; - addEventListener(type: "success", listener: (ev: Event) => any, useCapture?: boolean): void; - error: DOMError; - transaction: IDBTransaction; - onerror: (ev: ErrorEvent) => any; - addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; - readyState: string; - result: any; - addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; -} -declare var IDBRequest: { - prototype: IDBRequest; - new(): IDBRequest; -} - -interface MessagePort extends EventTarget { - onmessage: (ev: any) => any; - addEventListener(type: "message", listener: (ev: any) => any, useCapture?: boolean): void; - close(): void; - postMessage(message: any, ports?: any): void; - start(): void; - addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; -} -declare var MessagePort: { - prototype: MessagePort; - new(): MessagePort; -} - -interface FileReader extends MSBaseReader { - error: DOMError; - readAsArrayBuffer(blob: Blob): void; - readAsDataURL(blob: Blob): void; - readAsText(blob: Blob, encoding?: string): void; -} -declare var FileReader: { - prototype: FileReader; - new (): FileReader; -} - -interface Blob { - type: string; - size: number; - msDetachStream(): any; - slice(start?: number, end?: number, contentType?: string): Blob; - close(): void; - msClose(): void; -} -interface BlobPropertyBag { - /** Corresponds to the 'type' property of the Blob object */ - type?: string; - /** Either 'transparent' or 'native' */ - endings?: string; -} -declare var Blob: { - prototype: Blob; - new (blobParts?: any[], options?: BlobPropertyBag): Blob; -} - -interface ApplicationCache extends EventTarget { - status: number; - ondownloading: (ev: Event) => any; - addEventListener(type: "downloading", listener: (ev: Event) => any, useCapture?: boolean): void; - onprogress: (ev: ProgressEvent) => any; - addEventListener(type: "progress", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; - onupdateready: (ev: Event) => any; - addEventListener(type: "updateready", listener: (ev: Event) => any, useCapture?: boolean): void; - oncached: (ev: Event) => any; - addEventListener(type: "cached", listener: (ev: Event) => any, useCapture?: boolean): void; - onobsolete: (ev: Event) => any; - addEventListener(type: "obsolete", listener: (ev: Event) => any, useCapture?: boolean): void; - onerror: (ev: ErrorEvent) => any; - addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; - onchecking: (ev: Event) => any; - addEventListener(type: "checking", listener: (ev: Event) => any, useCapture?: boolean): void; - onnoupdate: (ev: Event) => any; - addEventListener(type: "noupdate", listener: (ev: Event) => any, useCapture?: boolean): void; - swapCache(): void; - abort(): void; - update(): void; - CHECKING: number; - UNCACHED: number; - UPDATEREADY: number; - DOWNLOADING: number; - IDLE: number; - OBSOLETE: number; - addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; -} -declare var ApplicationCache: { - prototype: ApplicationCache; - new(): ApplicationCache; - CHECKING: number; - UNCACHED: number; - UPDATEREADY: number; - DOWNLOADING: number; - IDLE: number; - OBSOLETE: number; -} - -interface MSHTMLVideoElementExtensions { - msIsStereo3D: boolean; - msStereo3DPackingMode: string; - onMSVideoOptimalLayoutChanged: (ev: any) => any; - addEventListener(type: "MSVideoOptimalLayoutChanged", listener: (ev: any) => any, useCapture?: boolean): void; - onMSVideoFrameStepCompleted: (ev: any) => any; - addEventListener(type: "MSVideoFrameStepCompleted", listener: (ev: any) => any, useCapture?: boolean): void; - msStereo3DRenderMode: string; - msIsLayoutOptimalForPlayback: boolean; - msHorizontalMirror: boolean; - onMSVideoFormatChanged: (ev: any) => any; - addEventListener(type: "MSVideoFormatChanged", listener: (ev: any) => any, useCapture?: boolean): void; - msZoom: boolean; - msInsertVideoEffect(activatableClassId: string, effectRequired: boolean, config?: any): void; - msSetVideoRectangle(left: number, top: number, right: number, bottom: number): void; - msFrameStep(forward: boolean): void; - addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; -} - -interface FrameRequestCallback { - (time: number): void; -} - -interface CSS3DTransformsProperties { - perspective: string; - msBackfaceVisibility: string; - perspectiveOrigin: string; - transformStyle: string; - backfaceVisibility: string; - msPerspectiveOrigin: string; - msTransformStyle: string; - msPerspective: string; -} - -interface XMLHttpRequest { - withCredentials: boolean; -} - -interface PopStateEvent extends Event { - state: any; - initPopStateEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, stateArg: any): void; -} -declare var PopStateEvent: { - prototype: PopStateEvent; - new(): PopStateEvent; -} - -interface CSSKeyframeRule extends CSSRule { - keyText: string; - style: CSSStyleDeclaration; -} -declare var CSSKeyframeRule: { - prototype: CSSKeyframeRule; - new(): CSSKeyframeRule; -} - -interface CSSGridProperties { - msGridRows: string; - msGridColumnSpan: any; - msGridRow: any; - msGridRowSpan: any; - msGridColumns: string; - msGridColumnAlign: string; - msGridRowAlign: string; - msGridColumn: any; -} - -interface MSFileSaver { - msSaveBlob(blob: any, defaultName?: string): boolean; - msSaveOrOpenBlob(blob: any, defaultName?: string): boolean; -} - -interface MSStream { - type: string; - msDetachStream(): any; - msClose(): void; -} -declare var MSStream: { - prototype: MSStream; - new(): MSStream; -} - -interface MediaError extends MSMediaErrorExtensions { -} - -interface HTMLFieldSetElement { - validationMessage: string; - validity: ValidityState; - willValidate: boolean; - checkValidity(): boolean; - setCustomValidity(error: string): void; -} - -interface MSBlobBuilder { - append(data: any, endings?: string): void; - getBlob(contentType?: string): Blob; -} -declare var MSBlobBuilder: { - prototype: MSBlobBuilder; - new (): MSBlobBuilder; -} - -interface MSRangeExtensions { - createContextualFragment(fragment: string): DocumentFragment; -} - -interface HTMLElement { - oncuechange: (ev: Event) => any; - addEventListener(type: "cuechange", listener: (ev: Event) => any, useCapture?: boolean): void; - spellcheck: boolean; - classList: DOMTokenList; - draggable: boolean; -} - -interface DataTransfer { - types: DOMStringList; - files: FileList; -} - -interface DOMSettableTokenList extends DOMTokenList { - value: string; -} -declare var DOMSettableTokenList: { - prototype: DOMSettableTokenList; - new(): DOMSettableTokenList; -} - -interface IDBFactory { - open(name: string, version?: number): IDBOpenDBRequest; - cmp(first: any, second: any): number; - deleteDatabase(name: string): IDBOpenDBRequest; -} -declare var IDBFactory: { - prototype: IDBFactory; - new(): IDBFactory; -} - -interface Range extends MSRangeExtensions { -} - -interface HTMLObjectElement { - validationMessage: string; - validity: ValidityState; - willValidate: boolean; - checkValidity(): boolean; - setCustomValidity(error: string): void; -} - -interface MSPointerEvent extends MouseEvent { - width: number; - rotation: number; - pressure: number; - pointerType: number; - isPrimary: boolean; - tiltY: number; - height: number; - intermediatePoints: any; - currentPoint: any; - tiltX: number; - hwTimestamp: number; - pointerId: number; - initPointerEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: AbstractView, detailArg: number, screenXArg: number, screenYArg: number, clientXArg: number, clientYArg: number, ctrlKeyArg: boolean, altKeyArg: boolean, shiftKeyArg: boolean, metaKeyArg: boolean, buttonArg: number, relatedTargetArg: EventTarget, offsetXArg: number, offsetYArg: number, widthArg: number, heightArg: number, pressure: number, rotation: number, tiltX: number, tiltY: number, pointerIdArg: number, pointerType: number, hwTimestampArg: number, isPrimary: boolean): void; - getCurrentPoint(element: Element): void; - getIntermediatePoints(element: Element): void; - MSPOINTER_TYPE_PEN: number; - MSPOINTER_TYPE_MOUSE: number; - MSPOINTER_TYPE_TOUCH: number; -} -declare var MSPointerEvent: { - prototype: MSPointerEvent; - new(): MSPointerEvent; - MSPOINTER_TYPE_PEN: number; - MSPOINTER_TYPE_MOUSE: number; - MSPOINTER_TYPE_TOUCH: number; -} - -interface CSSTextProperties { - textShadow: string; - msHyphenateLimitLines: any; - msHyphens: string; - msHyphenateLimitChars: string; - msHyphenateLimitZone: any; -} - -interface CSS2DTransformsProperties { - transform: string; - transformOrigin: string; -} - -interface DOMException { - name: string; - INVALID_NODE_TYPE_ERR: number; - DATA_CLONE_ERR: number; - TIMEOUT_ERR: number; -} -//declare var DOMException: { -// INVALID_NODE_TYPE_ERR: number; -// DATA_CLONE_ERR: number; -// TIMEOUT_ERR: number; -//} - -interface MSCSSHighContrastProperties { - msHighContrastAdjust: string; -} - -interface MSManipulationEvent extends UIEvent { - lastState: number; - currentState: number; - initMSManipulationEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: AbstractView, detailArg: number, lastState: number, currentState: number): void; - MS_MANIPULATION_STATE_STOPPED: number; - MS_MANIPULATION_STATE_ACTIVE: number; - MS_MANIPULATION_STATE_INERTIA: number; -} -declare var MSManipulationEvent: { - prototype: MSManipulationEvent; - new(): MSManipulationEvent; - MS_MANIPULATION_STATE_STOPPED: number; - MS_MANIPULATION_STATE_ACTIVE: number; - MS_MANIPULATION_STATE_INERTIA: number; -} - -interface FormData { - append(name: any, value: any, blobName?: string): void; -} -declare var FormData: { - prototype: FormData; - new (form?: HTMLFormElement): FormData; -} - -interface MSHTMLImageElementExtensions { - msPlayToPrimary: boolean; - msPlayToDisabled: boolean; - msPlayToSource: any; -} -declare var MSHTMLImageElementExtensions: { - prototype: MSHTMLImageElementExtensions; - new(): MSHTMLImageElementExtensions; -} - -interface MSHTMLMediaElementExtensions { - msAudioCategory: string; - msRealTime: boolean; - msPlayToPrimary: boolean; - msPlayToDisabled: boolean; - msPlayToSource: any; - msAudioDeviceType: string; - msClearEffects(): void; - msSetMediaProtectionManager(mediaProtectionManager?: any): void; - msInsertAudioEffect(activatableClassId: string, effectRequired: boolean, config?: any): void; -} - -interface SVGFEImageElement extends SVGElement, SVGLangSpace, SVGFilterPrimitiveStandardAttributes, SVGURIReference { - preserveAspectRatio: SVGAnimatedPreserveAspectRatio; -} -declare var SVGFEImageElement: { - prototype: SVGFEImageElement; - new(): SVGFEImageElement; -} - -interface HTMLDataListElement extends HTMLElement { - options: HTMLCollection; -} -declare var HTMLDataListElement: { - prototype: HTMLDataListElement; - new(): HTMLDataListElement; -} - -interface AbstractWorker extends EventTarget { - onerror: (ev: ErrorEvent) => any; - addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; - addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; -} - -interface SVGFECompositeElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { - operator: SVGAnimatedEnumeration; - in2: SVGAnimatedString; - k2: SVGAnimatedNumber; - k1: SVGAnimatedNumber; - k3: SVGAnimatedNumber; - in1: SVGAnimatedString; - k4: SVGAnimatedNumber; - SVG_FECOMPOSITE_OPERATOR_OUT: number; - SVG_FECOMPOSITE_OPERATOR_OVER: number; - SVG_FECOMPOSITE_OPERATOR_XOR: number; - SVG_FECOMPOSITE_OPERATOR_ARITHMETIC: number; - SVG_FECOMPOSITE_OPERATOR_UNKNOWN: number; - SVG_FECOMPOSITE_OPERATOR_IN: number; - SVG_FECOMPOSITE_OPERATOR_ATOP: number; -} -declare var SVGFECompositeElement: { - prototype: SVGFECompositeElement; - new(): SVGFECompositeElement; - SVG_FECOMPOSITE_OPERATOR_OUT: number; - SVG_FECOMPOSITE_OPERATOR_OVER: number; - SVG_FECOMPOSITE_OPERATOR_XOR: number; - SVG_FECOMPOSITE_OPERATOR_ARITHMETIC: number; - SVG_FECOMPOSITE_OPERATOR_UNKNOWN: number; - SVG_FECOMPOSITE_OPERATOR_IN: number; - SVG_FECOMPOSITE_OPERATOR_ATOP: number; -} - -interface ValidityState { - customError: boolean; - valueMissing: boolean; - stepMismatch: boolean; - rangeUnderflow: boolean; - rangeOverflow: boolean; - typeMismatch: boolean; - patternMismatch: boolean; - tooLong: boolean; - valid: boolean; -} -declare var ValidityState: { - prototype: ValidityState; - new(): ValidityState; -} - -interface HTMLVideoElement extends MSHTMLVideoElementExtensions { -} - -interface HTMLTrackElement extends HTMLElement { - kind: string; - src: string; - srclang: string; - track: TextTrack; - label: string; - defaul: boolean; -} -declare var HTMLTrackElement: { - prototype: HTMLTrackElement; - new(): HTMLTrackElement; -} - -interface MSApp { - createFileFromStorageFile(storageFile: any): File; - createBlobFromRandomAccessStream(type: string, seeker: any): Blob; - createStreamFromInputStream(type: string, inputStream: any): MSStream; - terminateApp(exceptionObject: any): void; - createDataPackage(object: any): any; - execUnsafeLocalFunction(unsafeFunction: MSUnsafeFunctionCallback): any; - getHtmlPrintDocumentSource(htmlDoc: any, printTemplate?: string): any; - addPublicLocalApplicationUri(uri: string): void; - createDataPackageFromSelection(): any; -} -declare var MSApp: MSApp; - -interface MSXMLHttpRequestExtensions { - response: any; - onprogress: (ev: ProgressEvent) => any; - addEventListener(type: "progress", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; - onabort: (ev: any) => any; - addEventListener(type: "abort", listener: (ev: any) => any, useCapture?: boolean): void; - responseType: string; - onloadend: (ev: ProgressEvent) => any; - addEventListener(type: "loadend", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; - upload: XMLHttpRequestEventTarget; - onerror: (ev: ErrorEvent) => any; - addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; - onloadstart: (ev: any) => any; - addEventListener(type: "loadstart", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; -} -declare var MSXMLHttpRequestExtensions: { - prototype: MSXMLHttpRequestExtensions; - new(): MSXMLHttpRequestExtensions; -} - -interface SVGFEDiffuseLightingElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { - kernelUnitLengthY: SVGAnimatedNumber; - surfaceScale: SVGAnimatedNumber; - in1: SVGAnimatedString; - kernelUnitLengthX: SVGAnimatedNumber; - diffuseConstant: SVGAnimatedNumber; -} -declare var SVGFEDiffuseLightingElement: { - prototype: SVGFEDiffuseLightingElement; - new(): SVGFEDiffuseLightingElement; -} - -interface SVGFEComponentTransferElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { - in1: SVGAnimatedString; -} -declare var SVGFEComponentTransferElement: { - prototype: SVGFEComponentTransferElement; - new(): SVGFEComponentTransferElement; -} - -interface MSCSSMatrix { - m24: number; - m34: number; - a: number; - d: number; - m32: number; - m41: number; - m11: number; - f: number; - e: number; - m23: number; - m14: number; - m33: number; - m22: number; - m21: number; - c: number; - m12: number; - b: number; - m42: number; - m31: number; - m43: number; - m13: number; - m44: number; - multiply(secondMatrix: MSCSSMatrix): MSCSSMatrix; - skewY(angle: number): MSCSSMatrix; - setMatrixValue(value: string): void; - inverse(): MSCSSMatrix; - rotateAxisAngle(x: number, y: number, z: number, angle: number): MSCSSMatrix; - toString(): string; - rotate(angleX: number, angleY?: number, angleZ?: number): MSCSSMatrix; - translate(x: number, y: number, z?: number): MSCSSMatrix; - scale(scaleX: number, scaleY?: number, scaleZ?: number): MSCSSMatrix; - skewX(angle: number): MSCSSMatrix; -} -declare var MSCSSMatrix: { - prototype: MSCSSMatrix; - new (text?: string): MSCSSMatrix; -} - -interface Worker extends AbstractWorker { - onmessage: (ev: any) => any; - addEventListener(type: "message", listener: (ev: any) => any, useCapture?: boolean): void; - postMessage(message: any, ports?: any): void; - terminate(): void; - addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; -} -declare var Worker: { - prototype: Worker; - new (stringUrl: string): Worker; -} - -interface HTMLIFrameElement { - sandbox: DOMSettableTokenList; -} - -interface MSMediaErrorExtensions { - msExtendedCode: number; -} - -interface MSNavigatorAbilities { - msProtocols: MSProtocolsCollection; - msMaxTouchPoints: number; - msPointerEnabled: boolean; - msManipulationViewsEnabled: boolean; -} -declare var MSNavigatorAbilities: { - prototype: MSNavigatorAbilities; - new(): MSNavigatorAbilities; -} - -declare var onpopstate: (ev: PopStateEvent) => any; -declare function addEventListener(type: "popstate", listener: (ev: PopStateEvent) => any, useCapture?: boolean): void; -declare var applicationCache: ApplicationCache; -declare function matchMedia(mediaQuery: string): MediaQueryList; -declare function msMatchMedia(mediaQuery: string): MediaQueryList; -declare var animationStartTime: number; -declare var msAnimationStartTime: number; -declare function msCancelRequestAnimationFrame(handle: number): void; -declare function cancelAnimationFrame(handle: number): void; -declare function requestAnimationFrame(callback: FrameRequestCallback): number; -declare function msRequestAnimationFrame(callback: FrameRequestCallback): number; -declare function btoa(rawString: string): string; -declare function atob(encodedString: string): string; -declare var msIndexedDB: IDBFactory; -declare var indexedDB: IDBFactory; -declare var console: Console; - - -///////////////////////////// -/// WorkerGlobalScope APIs -///////////////////////////// -// TODO: These are only available in a Web Worker - should be in a separate lib file -declare function importScripts(...urls: string[]): void; - - -///////////////////////////// -/// Windows Script Host APIS -///////////////////////////// -declare var ActiveXObject: { new (s: string): any; }; - -interface ITextWriter { - Write(s: string): void; - WriteLine(s: string): void; - Close(): void; -} - -declare var WScript : { - Echo(s: any); - StdErr: ITextWriter; - StdOut: ITextWriter; - Arguments: { length: number; Item(n: number): string; }; - ScriptFullName: string; - Quit(exitCode?: number); -} +/* ***************************************************************************** +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 + +THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED +WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, +MERCHANTABLITY OR NON-INFRINGEMENT. + +See the Apache Version 2.0 License for specific language governing permissions +and limitations under the License. +***************************************************************************** */ + +/// + +///////////////////////////// +/// ECMAScript APIs +///////////////////////////// + +declare var NaN: number; +declare var Infinity: number; + +declare function eval(x: string): any; +declare function parseInt(s: string, radix?: number): number; +declare function parseFloat(string: string): number; +declare function isNaN(number: number): boolean; +declare function isFinite(number: number): boolean; +declare function decodeURI(encodedURI: string): string; +declare function decodeURIComponent(encodedURIComponent: string): string; +declare function encodeURI(uri: string): string; +declare function encodeURIComponent(uriComponent: string): string; + +interface PropertyDescriptor { + configurable?: boolean; + enumerable?: boolean; + value?: any; + writable?: boolean; + get? (): any; + set? (v: any): void; +} + +interface PropertyDescriptorMap { + [s: string]: PropertyDescriptor; +} + +interface Object { + toString(): string; + toLocaleString(): string; + valueOf(): Object; + hasOwnProperty(v: string): boolean; + isPrototypeOf(v: Object): boolean; + propertyIsEnumerable(v: string): boolean; + + [s: string]: any; +} + +declare var Object: { + new (value?: any): Object; + (): any; + (value: any): any; + + prototype: Object; + + getPrototypeOf(o: any): any; + getOwnPropertyDescriptor(o: any, p: string): PropertyDescriptor; + getOwnPropertyNames(o: any): string[]; + create(o: any, properties?: PropertyDescriptorMap): any; + defineProperty(o: any, p: string, attributes: PropertyDescriptor): any; + defineProperties(o: any, properties: PropertyDescriptorMap): any; + seal(o: any): any; + freeze(o: any): any; + preventExtensions(o: any): any; + isSealed(o: any): boolean; + isFrozen(o: any): boolean; + isExtensible(o: any): boolean; + keys(o: any): string[]; +} + +interface Function { + apply(thisArg: any, argArray?: any): any; + call(thisArg: any, ...argArray: any[]): any; + bind(thisArg: any, ...argArray: any[]): any; + + prototype: any; + length: number; + + // Non-standard extensions + arguments: any; + caller: Function; +} + +declare var Function: { + new (...args: string[]): Function; + (...args: string[]): Function; + prototype: Function; +} + +interface IArguments { + [index: number]: any; + length: number; + callee: Function; +} + +interface String { + toString(): string; + charAt(pos: number): string; + charCodeAt(index: number): number; + concat(...strings: string[]): string; + indexOf(searchString: string, position?: number): number; + lastIndexOf(searchString: string, position?: number): number; + localeCompare(that: string): number; + match(regexp: string): string[]; + match(regexp: RegExp): string[]; + replace(searchValue: string, replaceValue: string): string; + replace(searchValue: string, replaceValue: (substring: string, ...args: any[]) => string): string; + replace(searchValue: RegExp, replaceValue: string): string; + replace(searchValue: RegExp, replaceValue: (substring: string, ...args: any[]) => string): string; + search(regexp: string): number; + search(regexp: RegExp): number; + slice(start: number, end?: number): string; + split(separator: string, limit?: number): string[]; + split(separator: RegExp, limit?: number): string[]; + substring(start: number, end?: number): string; + toLowerCase(): string; + toLocaleLowerCase(): string; + toUpperCase(): string; + toLocaleUpperCase(): string; + trim(): string; + + length: number; + + substr(from: number, length?: number): string; +} + +declare var String: { + new (value?: any): String; + (value?: any): string; + prototype: String; + fromCharCode(...codes: number[]): string; +} + +interface Boolean { +} +declare var Boolean: { + new (value?: any): Boolean; + (value?: any): boolean; + prototype: Boolean; +} + +interface Number { + toString(radix?: number): string; + toFixed(fractionDigits?: number): string; + toExponential(fractionDigits?: number): string; + toPrecision(precision: number): string; +} + +declare var Number: { + new (value?: any): Number; + (value?: any): number; + prototype: Number; + MAX_VALUE: number; + MIN_VALUE: number; + NaN: number; + NEGATIVE_INFINITY: number; + POSITIVE_INFINITY: number; +} + +interface Math { + E: number; + LN10: number; + LN2: number; + LOG2E: number; + LOG10E: number; + PI: number; + SQRT1_2: number; + SQRT2: number; + abs(x: number): number; + acos(x: number): number; + asin(x: number): number; + atan(x: number): number; + atan2(y: number, x: number): number; + ceil(x: number): number; + cos(x: number): number; + exp(x: number): number; + floor(x: number): number; + log(x: number): number; + max(...values: number[]): number; + min(...values: number[]): number; + pow(x: number, y: number): number; + random(): number; + round(x: number): number; + sin(x: number): number; + sqrt(x: number): number; + tan(x: number): number; +} + +declare var Math: Math; + +interface Date { + toString(): string; + toDateString(): string; + toTimeString(): string; + toLocaleString(): string; + toLocaleDateString(): string; + toLocaleTimeString(): string; + valueOf(): number; + getTime(): number; + getFullYear(): number; + getUTCFullYear(): number; + getMonth(): number; + getUTCMonth(): number; + getDate(): number; + getUTCDate(): number; + getDay(): number; + getUTCDay(): number; + getHours(): number; + getUTCHours(): number; + getMinutes(): number; + getUTCMinutes(): number; + getSeconds(): number; + getUTCSeconds(): number; + getMilliseconds(): number; + getUTCMilliseconds(): number; + getTimezoneOffset(): number; + setTime(time: number): void; + setMilliseconds(ms: number): void; + setUTCMilliseconds(ms: number): void; + setSeconds(sec: number, ms?: number): void; + setUTCSeconds(sec: number, ms?: number): void; + setMinutes(min: number, sec?: number, ms?: number): void; + setUTCMinutes(min: number, sec?: number, ms?: number): void; + setHours(hours: number, min?: number, sec?: number, ms?: number): void; + setUTCHours(hours: number, min?: number, sec?: number, ms?: number): void; + setDate(date: number): void; + setUTCDate(date: number): void; + setMonth(month: number, date?: number): void; + setUTCMonth(month: number, date?: number): void; + setFullYear(year: number, month?: number, date?: number): void; + setUTCFullYear(year: number, month?: number, date?: number): void; + toUTCString(): string; + toISOString(): string; + toJSON(key?: any): string; +} + +declare var Date: { + new (): Date; + new (value: number): Date; + new (value: string): Date; + new (year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): Date; + (): string; + prototype: Date; + parse(s: string): number; + UTC(year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): number; + now(): number; +} + +interface RegExpExecArray { + [index: number]: string; + length: number; + + index: number; + input: string; + + toString(): string; + toLocaleString(): string; + concat(...items: string[][]): string[]; + join(separator?: string): string; + pop(): string; + push(...items: string[]): number; + reverse(): string[]; + shift(): string; + slice(start: number, end?: number): string[]; + sort(compareFn?: (a: string, b: string) => number): string[]; + splice(start: number): string[]; + splice(start: number, deleteCount: number, ...items: string[]): string[]; + unshift(...items: string[]): number; + + indexOf(searchElement: string, fromIndex?: number): number; + lastIndexOf(searchElement: string, fromIndex?: number): number; + every(callbackfn: (value: string, index: number, array: string[]) => boolean, thisArg?: any): boolean; + some(callbackfn: (value: string, index: number, array: string[]) => boolean, thisArg?: any): boolean; + forEach(callbackfn: (value: string, index: number, array: string[]) => void, thisArg?: any): void; + map(callbackfn: (value: string, index: number, array: string[]) => any, thisArg?: any): any[]; + filter(callbackfn: (value: string, index: number, array: string[]) => boolean, thisArg?: any): string[]; + reduce(callbackfn: (previousValue: any, currentValue: any, currentIndex: number, array: string[]) => any, initialValue?: any): any; + reduceRight(callbackfn: (previousValue: any, currentValue: any, currentIndex: number, array: string[]) => any, initialValue?: any): any; +} + + +interface RegExp { + exec(string: string): RegExpExecArray; + test(string: string): boolean; + source: string; + global: boolean; + ignoreCase: boolean; + multiline: boolean; + + lastIndex: number; + + // Non-standard extensions + compile(): RegExp; +} +declare var RegExp: { + new (pattern: string, flags?: string): RegExp; + (pattern: string, flags?: string): RegExp; + + // Non-standard extensions + $1: string; + $2: string; + $3: string; + $4: string; + $5: string; + $6: string; + $7: string; + $8: string; + $9: string; + lastMatch: string; +} + +interface Error { + name: string; + message: string; +} +declare var Error: { + new (message?: string): Error; + (message?: string): Error; + prototype: Error; +} + +interface EvalError extends Error { +} +declare var EvalError: { + new (message?: string): EvalError; + (message?: string): EvalError; + prototype: EvalError; +} + +interface RangeError extends Error { +} +declare var RangeError: { + new (message?: string): RangeError; + (message?: string): RangeError; + prototype: RangeError; +} + +interface ReferenceError extends Error { +} +declare var ReferenceError: { + new (message?: string): ReferenceError; + (message?: string): ReferenceError; + prototype: ReferenceError; +} + +interface SyntaxError extends Error { +} +declare var SyntaxError: { + new (message?: string): SyntaxError; + (message?: string): SyntaxError; + prototype: SyntaxError; +} + +interface TypeError extends Error { +} +declare var TypeError: { + new (message?: string): TypeError; + (message?: string): TypeError; + prototype: TypeError; +} + +interface URIError extends Error { +} +declare var URIError: { + new (message?: string): URIError; + (message?: string): URIError; + prototype: URIError; +} + +interface JSON { + parse(text: string, reviver?: (key: any, value: any) => any): any; + stringify(value: any): string; + stringify(value: any, replacer: (key: string, value: any) => any): string; + stringify(value: any, replacer: any[]): string; + stringify(value: any, replacer: (key: string, value: any) => any, space: any): string; + stringify(value: any, replacer: any[], space: any): string; +} +declare var JSON: JSON; + +///////////////////////////// +/// ECMAScript Array API (specially handled by compiler) +///////////////////////////// + +interface Array { + toString(): string; + toLocaleString(): string; + concat(...items: U[]): T[]; + concat(...items: T[]): T[]; + join(separator?: string): string; + pop(): T; + push(...items: T[]): number; + reverse(): T[]; + shift(): T; + slice(start: number, end?: number): T[]; + sort(compareFn?: (a: T, b: T) => number): T[]; + splice(start: number): T[]; + splice(start: number, deleteCount: number, ...items: T[]): T[]; + unshift(...items: T[]): number; + + indexOf(searchElement: T, fromIndex?: number): number; + lastIndexOf(searchElement: T, fromIndex?: number): number; + every(callbackfn: (value: T, index: number, array: T[]) => boolean, thisArg?: any): boolean; + some(callbackfn: (value: T, index: number, array: T[]) => boolean, thisArg?: any): boolean; + forEach(callbackfn: (value: T, index: number, array: T[]) => void, thisArg?: any): void; + map(callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): U[]; + filter(callbackfn: (value: T, index: number, array: T[]) => boolean, thisArg?: any): T[]; + reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T, initialValue?: T): T; + reduce(callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: T[]) => U, initialValue: U): U; + reduceRight(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T, initialValue?: T): T; + reduceRight(callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: T[]) => U, initialValue: U): U; + + length: number; + + [n: number]: T; +} +declare var Array: { + new (arrayLength: number): T[]; + new (...items: T[]): T[]; + (arrayLength: number): T[]; + (...items: T[]): T[]; + isArray(arg: any): boolean; + prototype: Array; +} + + +///////////////////////////// +/// IE10 ECMAScript Extensions +///////////////////////////// + +interface ArrayBuffer { + byteLength: number; +} +declare var ArrayBuffer: { + prototype: ArrayBuffer; + new (byteLength: number): ArrayBuffer; +} + +interface ArrayBufferView { + buffer: ArrayBuffer; + byteOffset: number; + byteLength: number; +} + +interface Int8Array extends ArrayBufferView { + BYTES_PER_ELEMENT: number; + length: number; + [index: number]: number; + get(index: number): number; + set(index: number, value: number): void; + set(array: Int8Array, offset?: number): void; + set(array: number[], offset?: number): void; + subarray(begin: number, end?: number): Int8Array; +} +declare var Int8Array: { + prototype: Int8Array; + new (length: number): Int8Array; + new (array: Int8Array): Int8Array; + new (array: number[]): Int8Array; + new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Int8Array; + BYTES_PER_ELEMENT: number; +} + +interface Uint8Array extends ArrayBufferView { + BYTES_PER_ELEMENT: number; + length: number; + [index: number]: number; + get(index: number): number; + set(index: number, value: number): void; + set(array: Uint8Array, offset?: number): void; + set(array: number[], offset?: number): void; + subarray(begin: number, end?: number): Uint8Array; +} +declare var Uint8Array: { + prototype: Uint8Array; + new (length: number): Uint8Array; + new (array: Uint8Array): Uint8Array; + new (array: number[]): Uint8Array; + new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint8Array; + BYTES_PER_ELEMENT: number; +} + +interface Int16Array extends ArrayBufferView { + BYTES_PER_ELEMENT: number; + length: number; + [index: number]: number; + get(index: number): number; + set(index: number, value: number): void; + set(array: Int16Array, offset?: number): void; + set(array: number[], offset?: number): void; + subarray(begin: number, end?: number): Int16Array; +} +declare var Int16Array: { + prototype: Int16Array; + new (length: number): Int16Array; + new (array: Int16Array): Int16Array; + new (array: number[]): Int16Array; + new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Int16Array; + BYTES_PER_ELEMENT: number; +} + +interface Uint16Array extends ArrayBufferView { + BYTES_PER_ELEMENT: number; + length: number; + [index: number]: number; + get(index: number): number; + set(index: number, value: number): void; + set(array: Uint16Array, offset?: number): void; + set(array: number[], offset?: number): void; + subarray(begin: number, end?: number): Uint16Array; +} +declare var Uint16Array: { + prototype: Uint16Array; + new (length: number): Uint16Array; + new (array: Uint16Array): Uint16Array; + new (array: number[]): Uint16Array; + new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint16Array; + BYTES_PER_ELEMENT: number; +} + +interface Int32Array extends ArrayBufferView { + BYTES_PER_ELEMENT: number; + length: number; + [index: number]: number; + get(index: number): number; + set(index: number, value: number): void; + set(array: Int32Array, offset?: number): void; + set(array: number[], offset?: number): void; + subarray(begin: number, end?: number): Int32Array; +} +declare var Int32Array: { + prototype: Int32Array; + new (length: number): Int32Array; + new (array: Int32Array): Int32Array; + new (array: number[]): Int32Array; + new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Int32Array; + BYTES_PER_ELEMENT: number; +} + +interface Uint32Array extends ArrayBufferView { + BYTES_PER_ELEMENT: number; + length: number; + [index: number]: number; + get(index: number): number; + set(index: number, value: number): void; + set(array: Uint32Array, offset?: number): void; + set(array: number[], offset?: number): void; + subarray(begin: number, end?: number): Uint32Array; +} +declare var Uint32Array: { + prototype: Uint32Array; + new (length: number): Uint32Array; + new (array: Uint32Array): Uint32Array; + new (array: number[]): Uint32Array; + new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint32Array; + BYTES_PER_ELEMENT: number; +} + +interface Float32Array extends ArrayBufferView { + BYTES_PER_ELEMENT: number; + length: number; + [index: number]: number; + get(index: number): number; + set(index: number, value: number): void; + set(array: Float32Array, offset?: number): void; + set(array: number[], offset?: number): void; + subarray(begin: number, end?: number): Float32Array; +} +declare var Float32Array: { + prototype: Float32Array; + new (length: number): Float32Array; + new (array: Float32Array): Float32Array; + new (array: number[]): Float32Array; + new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Float32Array; + BYTES_PER_ELEMENT: number; +} + +interface Float64Array extends ArrayBufferView { + BYTES_PER_ELEMENT: number; + length: number; + [index: number]: number; + get(index: number): number; + set(index: number, value: number): void; + set(array: Float64Array, offset?: number): void; + set(array: number[], offset?: number): void; + subarray(begin: number, end?: number): Float64Array; +} +declare var Float64Array: { + prototype: Float64Array; + new (length: number): Float64Array; + new (array: Float64Array): Float64Array; + new (array: number[]): Float64Array; + new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Float64Array; + BYTES_PER_ELEMENT: number; +} + +interface DataView extends ArrayBufferView { + getInt8(byteOffset: number): number; + getUint8(byteOffset: number): number; + getInt16(byteOffset: number, littleEndian?: boolean): number; + getUint16(byteOffset: number, littleEndian?: boolean): number; + getInt32(byteOffset: number, littleEndian?: boolean): number; + getUint32(byteOffset: number, littleEndian?: boolean): number; + getFloat32(byteOffset: number, littleEndian?: boolean): number; + getFloat64(byteOffset: number, littleEndian?: boolean): number; + + setInt8(byteOffset: number, value: number): void; + setUint8(byteOffset: number, value: number): void; + setInt16(byteOffset: number, value: number, littleEndian?: boolean): void; + setUint16(byteOffset: number, value: number, littleEndian?: boolean): void; + setInt32(byteOffset: number, value: number, littleEndian?: boolean): void; + setUint32(byteOffset: number, value: number, littleEndian?: boolean): void; + setFloat32(byteOffset: number, value: number, littleEndian?: boolean): void; + setFloat64(byteOffset: number, value: number, littleEndian?: boolean): void; +} +declare var DataView: { + prototype: DataView; + new (buffer: ArrayBuffer, byteOffset?: number, length?: number): DataView; +} + +///////////////////////////// +/// IE11 ECMAScript Extensions +///////////////////////////// + +interface Map { + clear(): void; + delete(key: K): boolean; + forEach(callbackfn: (value: V, index: K, map: Map) => void, thisArg?: any): void; + get(key: K): V; + has(key: K): boolean; + set(key: K, value: V): Map; + size: number; +} +declare var Map: { + new (): Map; +} + +interface WeakMap { + clear(): void; + delete(key: K): boolean; + get(key: K): V; + has(key: K): boolean; + set(key: K, value: V): WeakMap; +} +declare var WeakMap: { + new (): WeakMap; +} + +interface Set { + add(value: T): Set; + clear(): void; + delete(value: T): boolean; + forEach(callbackfn: (value: T, index: T, set: Set) => void, thisArg?: any): void; + has(value: T): boolean; + size: number; +} +declare var Set: { + new (): Set; +} + +declare module Intl { + + interface CollatorOptions { + usage?: string; + localeMatcher?: string; + numeric?: boolean; + caseFirst?: string; + sensitivity?: string; + ignorePunctuation?: boolean; + } + + interface ResolvedCollatorOptions { + locale: string; + usage: string; + sensitivity: string; + ignorePunctuation: boolean; + collation: string; + caseFirst: string; + numeric: boolean; + } + + interface Collator { + compare(x: string, y: string): number; + resolvedOptions(): ResolvedCollatorOptions; + } + var Collator: { + new (locales?: string[], options?: CollatorOptions): Collator; + new (locale?: string, options?: CollatorOptions): Collator; + (locales?: string[], options?: CollatorOptions): Collator; + (locale?: string, options?: CollatorOptions): Collator; + supportedLocalesOf(locales: string[], options?: CollatorOptions): string[]; + supportedLocalesOf(locale: string, options?: CollatorOptions): string[]; + } + + interface NumberFormatOptions { + localeMatcher?: string; + style?: string; + currency?: string; + currencyDisplay?: string; + useGrouping?: boolean; + } + + interface ResolvedNumberFormatOptions { + locale: string; + numberingSystem: string; + style: string; + currency?: string; + currencyDisplay?: string; + minimumintegerDigits: number; + minimumFractionDigits: number; + maximumFractionDigits: number; + minimumSignificantDigits?: number; + maximumSignificantDigits?: number; + useGrouping: boolean; + } + + interface NumberFormat { + format(value: number): string; + resolvedOptions(): ResolvedNumberFormatOptions; + } + var NumberFormat: { + new (locales?: string[], options?: NumberFormatOptions): Collator; + new (locale?: string, options?: NumberFormatOptions): Collator; + (locales?: string[], options?: NumberFormatOptions): Collator; + (locale?: string, options?: NumberFormatOptions): Collator; + supportedLocalesOf(locales: string[], options?: NumberFormatOptions): string[]; + supportedLocalesOf(locale: string, options?: NumberFormatOptions): string[]; + } + + interface DateTimeFormatOptions { + localeMatcher?: string; + weekday?: string; + era?: string; + year?: string; + month?: string; + day?: string; + hour?: string; + minute?: string; + second?: string; + timeZoneName?: string; + formatMatcher?: string; + hour12: boolean; + } + + interface ResolvedDateTimeFormatOptions { + locale: string; + calendar: string; + numberingSystem: string; + timeZone: string; + hour12?: boolean; + weekday?: string; + era?: string; + year?: string; + month?: string; + day?: string; + hour?: string; + minute?: string; + second?: string; + timeZoneName?: string; + } + + interface DateTimeFormat { + format(date: number): string; + resolvedOptions(): ResolvedDateTimeFormatOptions; + } + var DateTimeFormat: { + new (locales?: string[], options?: DateTimeFormatOptions): Collator; + new (locale?: string, options?: DateTimeFormatOptions): Collator; + (locales?: string[], options?: DateTimeFormatOptions): Collator; + (locale?: string, options?: DateTimeFormatOptions): Collator; + supportedLocalesOf(locales: string[], options?: DateTimeFormatOptions): string[]; + supportedLocalesOf(locale: string, options?: DateTimeFormatOptions): string[]; + } +} + +interface String { + localeCompare(that: string, locales: string[], options?: Intl.CollatorOptions): number; + localeCompare(that: string, locale: string, options?: Intl.CollatorOptions): number; +} + +interface Numer { + toLocaleString(locales: string[], options?: Intl.NumberFormatOptions): string; + toLocaleString(locale: string, options?: Intl.NumberFormatOptions): string; +} + +interface Date { + toLocaleString(locales: string[], options?: Intl.DateTimeFormatOptions): string; + toLocaleString(locale: string, options?: Intl.DateTimeFormatOptions): string; +} + + +///////////////////////////// +/// IE9 DOM APIs +///////////////////////////// + +interface PositionOptions { + enableHighAccuracy?: boolean; + timeout?: number; + maximumAge?: number; +} + +interface NavigatorID { + appVersion: string; + appName: string; + userAgent: string; + platform: string; +} + +interface HTMLTableElement extends HTMLElement, MSDataBindingTableExtensions, MSDataBindingExtensions, DOML2DeprecatedBackgroundStyle, DOML2DeprecatedBackgroundColorStyle { + width: string; + borderColorLight: any; + cellSpacing: string; + tFoot: HTMLTableSectionElement; + frame: string; + borderColor: any; + rows: HTMLCollection; + rules: string; + cols: number; + summary: string; + caption: HTMLTableCaptionElement; + tBodies: HTMLCollection; + tHead: HTMLTableSectionElement; + align: string; + cells: HTMLCollection; + height: any; + cellPadding: string; + border: string; + borderColorDark: any; + deleteRow(index?: number): void; + createTBody(): HTMLElement; + deleteCaption(): void; + insertRow(index?: number): HTMLElement; + deleteTFoot(): void; + createTHead(): HTMLElement; + deleteTHead(): void; + createCaption(): HTMLElement; + moveRow(indexFrom?: number, indexTo?: number): Object; + createTFoot(): HTMLElement; +} +declare var HTMLTableElement: { + prototype: HTMLTableElement; + new (): HTMLTableElement; +} + +interface TreeWalker { + whatToShow: number; + filter: NodeFilter; + root: Node; + currentNode: Node; + expandEntityReferences: boolean; + previousSibling(): Node; + lastChild(): Node; + nextSibling(): Node; + nextNode(): Node; + parentNode(): Node; + firstChild(): Node; + previousNode(): Node; +} +declare var TreeWalker: { + prototype: TreeWalker; + new (): TreeWalker; +} + +interface GetSVGDocument { + getSVGDocument(): Document; +} + +interface SVGPathSegCurvetoQuadraticRel extends SVGPathSeg { + y: number; + y1: number; + x: number; + x1: number; +} +declare var SVGPathSegCurvetoQuadraticRel: { + prototype: SVGPathSegCurvetoQuadraticRel; + new (): SVGPathSegCurvetoQuadraticRel; +} + +interface Performance { + navigation: PerformanceNavigation; + timing: PerformanceTiming; + getEntriesByType(entryType: string): any; + toJSON(): any; + getMeasures(measureName?: string): any; + clearMarks(markName?: string): void; + getMarks(markName?: string): any; + clearResourceTimings(): void; + mark(markName: string): void; + measure(measureName: string, startMarkName?: string, endMarkName?: string): void; + getEntriesByName(name: string, entryType?: string): any; + getEntries(): any; + clearMeasures(measureName?: string): void; + setResourceTimingBufferSize(maxSize: number): void; +} +declare var Performance: { + prototype: Performance; + new (): Performance; +} + +interface MSDataBindingTableExtensions { + dataPageSize: number; + nextPage(): void; + firstPage(): void; + refresh(): void; + previousPage(): void; + lastPage(): void; +} + +interface CompositionEvent extends UIEvent { + data: string; + locale: string; + initCompositionEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: Window, dataArg: string, locale: string): void; +} +declare var CompositionEvent: { + prototype: CompositionEvent; + new (): CompositionEvent; +} + +interface WindowTimers { + clearTimeout(handle: number): void; + setTimeout(handler: any, timeout?: any, ...args: any[]): number; + clearInterval(handle: number): void; + setInterval(handler: any, timeout?: any, ...args: any[]): number; +} + +interface SVGMarkerElement extends SVGElement, SVGStylable, SVGLangSpace, SVGFitToViewBox, SVGExternalResourcesRequired { + orientType: SVGAnimatedEnumeration; + markerUnits: SVGAnimatedEnumeration; + markerWidth: SVGAnimatedLength; + markerHeight: SVGAnimatedLength; + orientAngle: SVGAnimatedAngle; + refY: SVGAnimatedLength; + refX: SVGAnimatedLength; + setOrientToAngle(angle: SVGAngle): void; + setOrientToAuto(): void; + SVG_MARKER_ORIENT_UNKNOWN: number; + SVG_MARKER_ORIENT_ANGLE: number; + SVG_MARKERUNITS_UNKNOWN: number; + SVG_MARKERUNITS_STROKEWIDTH: number; + SVG_MARKER_ORIENT_AUTO: number; + SVG_MARKERUNITS_USERSPACEONUSE: number; +} +declare var SVGMarkerElement: { + prototype: SVGMarkerElement; + new (): SVGMarkerElement; + SVG_MARKER_ORIENT_UNKNOWN: number; + SVG_MARKER_ORIENT_ANGLE: number; + SVG_MARKERUNITS_UNKNOWN: number; + SVG_MARKERUNITS_STROKEWIDTH: number; + SVG_MARKER_ORIENT_AUTO: number; + SVG_MARKERUNITS_USERSPACEONUSE: number; +} + +interface CSSStyleDeclaration { + backgroundAttachment: string; + visibility: string; + textAlignLast: string; + borderRightStyle: string; + counterIncrement: string; + orphans: string; + cssText: string; + borderStyle: string; + pointerEvents: string; + borderTopColor: string; + markerEnd: string; + textIndent: string; + listStyleImage: string; + cursor: string; + listStylePosition: string; + wordWrap: string; + borderTopStyle: string; + alignmentBaseline: string; + opacity: string; + direction: string; + strokeMiterlimit: string; + maxWidth: string; + color: string; + clip: string; + borderRightWidth: string; + verticalAlign: string; + overflow: string; + mask: string; + borderLeftStyle: string; + emptyCells: string; + stopOpacity: string; + paddingRight: string; + parentRule: CSSRule; + background: string; + boxSizing: string; + textJustify: string; + height: string; + paddingTop: string; + length: number; + right: string; + baselineShift: string; + borderLeft: string; + widows: string; + lineHeight: string; + left: string; + textUnderlinePosition: string; + glyphOrientationHorizontal: string; + display: string; + textAnchor: string; + cssFloat: string; + strokeDasharray: string; + rubyAlign: string; + fontSizeAdjust: string; + borderLeftColor: string; + backgroundImage: string; + listStyleType: string; + strokeWidth: string; + textOverflow: string; + fillRule: string; + borderBottomColor: string; + zIndex: string; + position: string; + listStyle: string; + msTransformOrigin: string; + dominantBaseline: string; + overflowY: string; + fill: string; + captionSide: string; + borderCollapse: string; + boxShadow: string; + quotes: string; + tableLayout: string; + unicodeBidi: string; + borderBottomWidth: string; + backgroundSize: string; + textDecoration: string; + strokeDashoffset: string; + fontSize: string; + border: string; + pageBreakBefore: string; + borderTopRightRadius: string; + msTransform: string; + borderBottomLeftRadius: string; + textTransform: string; + rubyPosition: string; + strokeLinejoin: string; + clipPath: string; + borderRightColor: string; + fontFamily: string; + clear: string; + content: string; + backgroundClip: string; + marginBottom: string; + counterReset: string; + outlineWidth: string; + marginRight: string; + paddingLeft: string; + borderBottom: string; + wordBreak: string; + marginTop: string; + top: string; + fontWeight: string; + borderRight: string; + width: string; + kerning: string; + pageBreakAfter: string; + borderBottomStyle: string; + fontStretch: string; + padding: string; + strokeOpacity: string; + markerStart: string; + bottom: string; + borderLeftWidth: string; + clipRule: string; + backgroundPosition: string; + backgroundColor: string; + pageBreakInside: string; + backgroundOrigin: string; + strokeLinecap: string; + borderTopWidth: string; + outlineStyle: string; + borderTop: string; + outlineColor: string; + paddingBottom: string; + marginLeft: string; + font: string; + outline: string; + wordSpacing: string; + maxHeight: string; + fillOpacity: string; + letterSpacing: string; + borderSpacing: string; + backgroundRepeat: string; + borderRadius: string; + borderWidth: string; + borderBottomRightRadius: string; + whiteSpace: string; + fontStyle: string; + minWidth: string; + stopColor: string; + borderTopLeftRadius: string; + borderColor: string; + marker: string; + glyphOrientationVertical: string; + markerMid: string; + fontVariant: string; + minHeight: string; + stroke: string; + rubyOverhang: string; + overflowX: string; + textAlign: string; + margin: string; + getPropertyPriority(propertyName: string): string; + getPropertyValue(propertyName: string): string; + removeProperty(propertyName: string): string; + item(index: number): string; + [index: number]: string; + setProperty(propertyName: string, value: string, priority?: string): void; +} +declare var CSSStyleDeclaration: { + prototype: CSSStyleDeclaration; + new (): CSSStyleDeclaration; +} + +interface SVGGElement extends SVGElement, SVGStylable, SVGTransformable, SVGLangSpace, SVGTests, SVGExternalResourcesRequired { +} +declare var SVGGElement: { + prototype: SVGGElement; + new (): SVGGElement; +} + +interface MSStyleCSSProperties extends MSCSSProperties { + pixelWidth: number; + posHeight: number; + posLeft: number; + pixelTop: number; + pixelBottom: number; + textDecorationNone: boolean; + pixelLeft: number; + posTop: number; + posBottom: number; + textDecorationOverline: boolean; + posWidth: number; + textDecorationLineThrough: boolean; + pixelHeight: number; + textDecorationBlink: boolean; + posRight: number; + pixelRight: number; + textDecorationUnderline: boolean; +} +declare var MSStyleCSSProperties: { + prototype: MSStyleCSSProperties; + new (): MSStyleCSSProperties; +} + +interface Navigator extends NavigatorID, NavigatorOnLine, NavigatorContentUtils, MSNavigatorExtensions, NavigatorGeolocation, MSNavigatorDoNotTrack, NavigatorStorageUtils { +} +declare var Navigator: { + prototype: Navigator; + new (): Navigator; +} + +interface SVGPathSegCurvetoCubicSmoothAbs extends SVGPathSeg { + y: number; + x2: number; + x: number; + y2: number; +} +declare var SVGPathSegCurvetoCubicSmoothAbs: { + prototype: SVGPathSegCurvetoCubicSmoothAbs; + new (): SVGPathSegCurvetoCubicSmoothAbs; +} + +interface SVGZoomEvent extends UIEvent { + zoomRectScreen: SVGRect; + previousScale: number; + newScale: number; + previousTranslate: SVGPoint; + newTranslate: SVGPoint; +} +declare var SVGZoomEvent: { + prototype: SVGZoomEvent; + new (): SVGZoomEvent; +} + +interface NodeSelector { + querySelectorAll(selectors: string): NodeList; + querySelector(selectors: string): Element; +} + +interface HTMLTableDataCellElement extends HTMLTableCellElement { +} +declare var HTMLTableDataCellElement: { + prototype: HTMLTableDataCellElement; + new (): HTMLTableDataCellElement; +} + +interface HTMLBaseElement extends HTMLElement { + target: string; + href: string; +} +declare var HTMLBaseElement: { + prototype: HTMLBaseElement; + new (): HTMLBaseElement; +} + +interface ClientRect { + left: number; + width: number; + right: number; + top: number; + bottom: number; + height: number; +} +declare var ClientRect: { + prototype: ClientRect; + new (): ClientRect; +} + +interface PositionErrorCallback { + (error: PositionError): void; +} + +interface DOMImplementation { + createDocumentType(qualifiedName: string, publicId: string, systemId: string): DocumentType; + createDocument(namespaceURI: string, qualifiedName: string, doctype: DocumentType): Document; + hasFeature(feature: string, version?: string): boolean; + createHTMLDocument(title: string): Document; +} +declare var DOMImplementation: { + prototype: DOMImplementation; + new (): DOMImplementation; +} + +interface SVGUnitTypes { + SVG_UNIT_TYPE_UNKNOWN: number; + SVG_UNIT_TYPE_OBJECTBOUNDINGBOX: number; + SVG_UNIT_TYPE_USERSPACEONUSE: number; +} +declare var SVGUnitTypes: { + prototype: SVGUnitTypes; + new (): SVGUnitTypes; + SVG_UNIT_TYPE_UNKNOWN: number; + SVG_UNIT_TYPE_OBJECTBOUNDINGBOX: number; + SVG_UNIT_TYPE_USERSPACEONUSE: number; +} + +interface Element extends Node, NodeSelector, ElementTraversal { + scrollTop: number; + clientLeft: number; + scrollLeft: number; + tagName: string; + clientWidth: number; + scrollWidth: number; + clientHeight: number; + clientTop: number; + scrollHeight: number; + getAttribute(name?: string): string; + getElementsByTagNameNS(namespaceURI: string, localName: string): NodeList; + hasAttributeNS(namespaceURI: string, localName: string): boolean; + getBoundingClientRect(): ClientRect; + getAttributeNS(namespaceURI: string, localName: string): string; + getAttributeNodeNS(namespaceURI: string, localName: string): Attr; + setAttributeNodeNS(newAttr: Attr): Attr; + msMatchesSelector(selectors: string): boolean; + hasAttribute(name: string): boolean; + removeAttribute(name?: string): void; + setAttributeNS(namespaceURI: string, qualifiedName: string, value: string): void; + getAttributeNode(name: string): Attr; + fireEvent(eventName: string, eventObj?: any): boolean; + getElementsByTagName(name: string): NodeList; + getElementsByTagName(name: "a"): NodeListOf; + getElementsByTagName(name: "abbr"): NodeListOf; + getElementsByTagName(name: "address"): NodeListOf; + getElementsByTagName(name: "area"): NodeListOf; + getElementsByTagName(name: "article"): NodeListOf; + getElementsByTagName(name: "aside"): NodeListOf; + getElementsByTagName(name: "audio"): NodeListOf; + getElementsByTagName(name: "b"): NodeListOf; + getElementsByTagName(name: "base"): NodeListOf; + getElementsByTagName(name: "bdi"): NodeListOf; + getElementsByTagName(name: "bdo"): NodeListOf; + getElementsByTagName(name: "blockquote"): NodeListOf; + getElementsByTagName(name: "body"): NodeListOf; + getElementsByTagName(name: "br"): NodeListOf; + getElementsByTagName(name: "button"): NodeListOf; + getElementsByTagName(name: "canvas"): NodeListOf; + getElementsByTagName(name: "caption"): NodeListOf; + getElementsByTagName(name: "cite"): NodeListOf; + getElementsByTagName(name: "code"): NodeListOf; + getElementsByTagName(name: "col"): NodeListOf; + getElementsByTagName(name: "colgroup"): NodeListOf; + getElementsByTagName(name: "datalist"): NodeListOf; + getElementsByTagName(name: "dd"): NodeListOf; + getElementsByTagName(name: "del"): NodeListOf; + getElementsByTagName(name: "dfn"): NodeListOf; + getElementsByTagName(name: "div"): NodeListOf; + getElementsByTagName(name: "dl"): NodeListOf; + getElementsByTagName(name: "dt"): NodeListOf; + getElementsByTagName(name: "em"): NodeListOf; + getElementsByTagName(name: "embed"): NodeListOf; + getElementsByTagName(name: "fieldset"): NodeListOf; + getElementsByTagName(name: "figcaption"): NodeListOf; + getElementsByTagName(name: "figure"): NodeListOf; + getElementsByTagName(name: "footer"): NodeListOf; + getElementsByTagName(name: "form"): NodeListOf; + getElementsByTagName(name: "h1"): NodeListOf; + getElementsByTagName(name: "h2"): NodeListOf; + getElementsByTagName(name: "h3"): NodeListOf; + getElementsByTagName(name: "h4"): NodeListOf; + getElementsByTagName(name: "h5"): NodeListOf; + getElementsByTagName(name: "h6"): NodeListOf; + getElementsByTagName(name: "head"): NodeListOf; + getElementsByTagName(name: "header"): NodeListOf; + getElementsByTagName(name: "hgroup"): NodeListOf; + getElementsByTagName(name: "hr"): NodeListOf; + getElementsByTagName(name: "html"): NodeListOf; + getElementsByTagName(name: "i"): NodeListOf; + getElementsByTagName(name: "iframe"): NodeListOf; + getElementsByTagName(name: "img"): NodeListOf; + getElementsByTagName(name: "input"): NodeListOf; + getElementsByTagName(name: "ins"): NodeListOf; + getElementsByTagName(name: "kbd"): NodeListOf; + getElementsByTagName(name: "label"): NodeListOf; + getElementsByTagName(name: "legend"): NodeListOf; + getElementsByTagName(name: "li"): NodeListOf; + getElementsByTagName(name: "link"): NodeListOf; + getElementsByTagName(name: "main"): NodeListOf; + getElementsByTagName(name: "map"): NodeListOf; + getElementsByTagName(name: "mark"): NodeListOf; + getElementsByTagName(name: "menu"): NodeListOf; + getElementsByTagName(name: "meta"): NodeListOf; + getElementsByTagName(name: "nav"): NodeListOf; + getElementsByTagName(name: "noscript"): NodeListOf; + getElementsByTagName(name: "object"): NodeListOf; + getElementsByTagName(name: "ol"): NodeListOf; + getElementsByTagName(name: "optgroup"): NodeListOf; + getElementsByTagName(name: "option"): NodeListOf; + getElementsByTagName(name: "p"): NodeListOf; + getElementsByTagName(name: "param"): NodeListOf; + getElementsByTagName(name: "pre"): NodeListOf; + getElementsByTagName(name: "progress"): NodeListOf; + getElementsByTagName(name: "q"): NodeListOf; + getElementsByTagName(name: "rp"): NodeListOf; + getElementsByTagName(name: "rt"): NodeListOf; + getElementsByTagName(name: "ruby"): NodeListOf; + getElementsByTagName(name: "s"): NodeListOf; + getElementsByTagName(name: "samp"): NodeListOf; + getElementsByTagName(name: "script"): NodeListOf; + getElementsByTagName(name: "section"): NodeListOf; + getElementsByTagName(name: "select"): NodeListOf; + getElementsByTagName(name: "small"): NodeListOf; + getElementsByTagName(name: "source"): NodeListOf; + getElementsByTagName(name: "span"): NodeListOf; + getElementsByTagName(name: "strong"): NodeListOf; + getElementsByTagName(name: "style"): NodeListOf; + getElementsByTagName(name: "sub"): NodeListOf; + getElementsByTagName(name: "summary"): NodeListOf; + getElementsByTagName(name: "sup"): NodeListOf; + getElementsByTagName(name: "table"): NodeListOf; + getElementsByTagName(name: "tbody"): NodeListOf; + getElementsByTagName(name: "td"): NodeListOf; + getElementsByTagName(name: "textarea"): NodeListOf; + getElementsByTagName(name: "tfoot"): NodeListOf; + getElementsByTagName(name: "th"): NodeListOf; + getElementsByTagName(name: "thead"): NodeListOf; + getElementsByTagName(name: "title"): NodeListOf; + getElementsByTagName(name: "tr"): NodeListOf; + getElementsByTagName(name: "track"): NodeListOf; + getElementsByTagName(name: "u"): NodeListOf; + getElementsByTagName(name: "ul"): NodeListOf; + getElementsByTagName(name: "var"): NodeListOf; + getElementsByTagName(name: "video"): NodeListOf; + getElementsByTagName(name: "wbr"): NodeListOf; + getClientRects(): ClientRectList; + setAttributeNode(newAttr: Attr): Attr; + removeAttributeNode(oldAttr: Attr): Attr; + setAttribute(name?: string, value?: string): void; + removeAttributeNS(namespaceURI: string, localName: string): void; +} +declare var Element: { + prototype: Element; + new (): Element; +} + +interface HTMLNextIdElement extends HTMLElement { + n: string; +} +declare var HTMLNextIdElement: { + prototype: HTMLNextIdElement; + new (): HTMLNextIdElement; +} + +interface SVGPathSegMovetoRel extends SVGPathSeg { + y: number; + x: number; +} +declare var SVGPathSegMovetoRel: { + prototype: SVGPathSegMovetoRel; + new (): SVGPathSegMovetoRel; +} + +interface SVGLineElement extends SVGElement, SVGStylable, SVGTransformable, SVGLangSpace, SVGTests, SVGExternalResourcesRequired { + y1: SVGAnimatedLength; + x2: SVGAnimatedLength; + x1: SVGAnimatedLength; + y2: SVGAnimatedLength; +} +declare var SVGLineElement: { + prototype: SVGLineElement; + new (): SVGLineElement; +} + +interface HTMLParagraphElement extends HTMLElement, DOML2DeprecatedTextFlowControl { + align: string; +} +declare var HTMLParagraphElement: { + prototype: HTMLParagraphElement; + new (): HTMLParagraphElement; +} + +interface HTMLAreasCollection extends HTMLCollection { + remove(index?: number): void; + add(element: HTMLElement, before?: any): void; +} +declare var HTMLAreasCollection: { + prototype: HTMLAreasCollection; + new (): HTMLAreasCollection; +} + +interface SVGDescElement extends SVGElement, SVGStylable, SVGLangSpace { +} +declare var SVGDescElement: { + prototype: SVGDescElement; + new (): SVGDescElement; +} + +interface Node extends EventTarget { + nodeType: number; + previousSibling: Node; + localName: string; + namespaceURI: string; + textContent: string; + parentNode: Node; + nextSibling: Node; + nodeValue: string; + lastChild: Node; + childNodes: NodeList; + nodeName: string; + ownerDocument: Document; + attributes: NamedNodeMap; + firstChild: Node; + prefix: string; + removeChild(oldChild: Node): Node; + appendChild(newChild: Node): Node; + isSupported(feature: string, version: string): boolean; + isEqualNode(arg: Node): boolean; + lookupPrefix(namespaceURI: string): string; + isDefaultNamespace(namespaceURI: string): boolean; + compareDocumentPosition(other: Node): number; + normalize(): void; + isSameNode(other: Node): boolean; + hasAttributes(): boolean; + lookupNamespaceURI(prefix: string): string; + cloneNode(deep?: boolean): Node; + hasChildNodes(): boolean; + replaceChild(newChild: Node, oldChild: Node): Node; + insertBefore(newChild: Node, refChild?: Node): Node; + ENTITY_REFERENCE_NODE: number; + ATTRIBUTE_NODE: number; + DOCUMENT_FRAGMENT_NODE: number; + TEXT_NODE: number; + ELEMENT_NODE: number; + COMMENT_NODE: number; + DOCUMENT_POSITION_DISCONNECTED: number; + DOCUMENT_POSITION_CONTAINED_BY: number; + DOCUMENT_POSITION_CONTAINS: number; + DOCUMENT_TYPE_NODE: number; + DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC: number; + DOCUMENT_NODE: number; + ENTITY_NODE: number; + PROCESSING_INSTRUCTION_NODE: number; + CDATA_SECTION_NODE: number; + NOTATION_NODE: number; + DOCUMENT_POSITION_FOLLOWING: number; + DOCUMENT_POSITION_PRECEDING: number; +} +declare var Node: { + prototype: Node; + new (): Node; + ENTITY_REFERENCE_NODE: number; + ATTRIBUTE_NODE: number; + DOCUMENT_FRAGMENT_NODE: number; + TEXT_NODE: number; + ELEMENT_NODE: number; + COMMENT_NODE: number; + DOCUMENT_POSITION_DISCONNECTED: number; + DOCUMENT_POSITION_CONTAINED_BY: number; + DOCUMENT_POSITION_CONTAINS: number; + DOCUMENT_TYPE_NODE: number; + DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC: number; + DOCUMENT_NODE: number; + ENTITY_NODE: number; + PROCESSING_INSTRUCTION_NODE: number; + CDATA_SECTION_NODE: number; + NOTATION_NODE: number; + DOCUMENT_POSITION_FOLLOWING: number; + DOCUMENT_POSITION_PRECEDING: number; +} + +interface SVGPathSegCurvetoQuadraticSmoothRel extends SVGPathSeg { + y: number; + x: number; +} +declare var SVGPathSegCurvetoQuadraticSmoothRel: { + prototype: SVGPathSegCurvetoQuadraticSmoothRel; + new (): SVGPathSegCurvetoQuadraticSmoothRel; +} + +interface DOML2DeprecatedListSpaceReduction { + compact: boolean; +} + +interface MSScriptHost { +} +declare var MSScriptHost: { + prototype: MSScriptHost; + new (): MSScriptHost; +} + +interface SVGClipPathElement extends SVGElement, SVGUnitTypes, SVGStylable, SVGTransformable, SVGLangSpace, SVGTests, SVGExternalResourcesRequired { + clipPathUnits: SVGAnimatedEnumeration; +} +declare var SVGClipPathElement: { + prototype: SVGClipPathElement; + new (): SVGClipPathElement; +} + +interface MouseEvent extends UIEvent { + toElement: Element; + layerY: number; + fromElement: Element; + which: number; + pageX: number; + offsetY: number; + x: number; + y: number; + metaKey: boolean; + altKey: boolean; + ctrlKey: boolean; + offsetX: number; + screenX: number; + clientY: number; + shiftKey: boolean; + layerX: number; + screenY: number; + relatedTarget: EventTarget; + button: number; + pageY: number; + buttons: number; + clientX: number; + initMouseEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: Window, detailArg: number, screenXArg: number, screenYArg: number, clientXArg: number, clientYArg: number, ctrlKeyArg: boolean, altKeyArg: boolean, shiftKeyArg: boolean, metaKeyArg: boolean, buttonArg: number, relatedTargetArg: EventTarget): void; + getModifierState(keyArg: string): boolean; +} +declare var MouseEvent: { + prototype: MouseEvent; + new (): MouseEvent; +} + +interface RangeException { + code: number; + message: string; + toString(): string; + INVALID_NODE_TYPE_ERR: number; + BAD_BOUNDARYPOINTS_ERR: number; +} +declare var RangeException: { + prototype: RangeException; + new (): RangeException; + INVALID_NODE_TYPE_ERR: number; + BAD_BOUNDARYPOINTS_ERR: number; +} + +interface SVGTextPositioningElement extends SVGTextContentElement { + y: SVGAnimatedLengthList; + rotate: SVGAnimatedNumberList; + dy: SVGAnimatedLengthList; + x: SVGAnimatedLengthList; + dx: SVGAnimatedLengthList; +} +declare var SVGTextPositioningElement: { + prototype: SVGTextPositioningElement; + new (): SVGTextPositioningElement; +} + +interface HTMLAppletElement extends HTMLElement, DOML2DeprecatedMarginStyle, DOML2DeprecatedBorderStyle, DOML2DeprecatedAlignmentStyle, MSDataBindingExtensions, MSDataBindingRecordSetExtensions { + width: number; + codeType: string; + object: string; + form: HTMLFormElement; + code: string; + archive: string; + alt: string; + standby: string; + classid: string; + name: string; + useMap: string; + data: string; + height: string; + altHtml: string; + contentDocument: Document; + codeBase: string; + declare: boolean; + type: string; + BaseHref: string; +} +declare var HTMLAppletElement: { + prototype: HTMLAppletElement; + new (): HTMLAppletElement; +} + +interface TextMetrics { + width: number; +} +declare var TextMetrics: { + prototype: TextMetrics; + new (): TextMetrics; +} + +interface DocumentEvent { + createEvent(eventInterface: string): Event; +} + +interface HTMLOListElement extends HTMLElement, DOML2DeprecatedListSpaceReduction, DOML2DeprecatedListNumberingAndBulletStyle { + start: number; +} +declare var HTMLOListElement: { + prototype: HTMLOListElement; + new (): HTMLOListElement; +} + +interface SVGPathSegLinetoVerticalRel extends SVGPathSeg { + y: number; +} +declare var SVGPathSegLinetoVerticalRel: { + prototype: SVGPathSegLinetoVerticalRel; + new (): SVGPathSegLinetoVerticalRel; +} + +interface SVGAnimatedString { + animVal: string; + baseVal: string; +} +declare var SVGAnimatedString: { + prototype: SVGAnimatedString; + new (): SVGAnimatedString; +} + +interface CDATASection extends Text { +} +declare var CDATASection: { + prototype: CDATASection; + new (): CDATASection; +} + +interface StyleMedia { + type: string; + matchMedium(mediaquery: string): boolean; +} +declare var StyleMedia: { + prototype: StyleMedia; + new (): StyleMedia; +} + +interface HTMLSelectElement extends HTMLElement, MSHTMLCollectionExtensions, MSDataBindingExtensions { + options: HTMLSelectElement; + value: string; + form: HTMLFormElement; + name: string; + size: number; + length: number; + selectedIndex: number; + multiple: boolean; + type: string; + remove(index?: number): void; + add(element: HTMLElement, before?: any): void; + item(name?: any, index?: any): any; + namedItem(name: string): any; + [name: string]: any; +} +declare var HTMLSelectElement: { + prototype: HTMLSelectElement; + new (): HTMLSelectElement; +} + +interface TextRange { + boundingLeft: number; + htmlText: string; + offsetLeft: number; + boundingWidth: number; + boundingHeight: number; + boundingTop: number; + text: string; + offsetTop: number; + moveToPoint(x: number, y: number): void; + queryCommandValue(cmdID: string): any; + getBookmark(): string; + move(unit: string, count?: number): number; + queryCommandIndeterm(cmdID: string): boolean; + scrollIntoView(fStart?: boolean): void; + findText(string: string, count?: number, flags?: number): boolean; + execCommand(cmdID: string, showUI?: boolean, value?: any): boolean; + getBoundingClientRect(): ClientRect; + moveToBookmark(bookmark: string): boolean; + isEqual(range: TextRange): boolean; + duplicate(): TextRange; + collapse(start?: boolean): void; + queryCommandText(cmdID: string): string; + select(): void; + pasteHTML(html: string): void; + inRange(range: TextRange): boolean; + moveEnd(unit: string, count?: number): number; + getClientRects(): ClientRectList; + moveStart(unit: string, count?: number): number; + parentElement(): Element; + queryCommandState(cmdID: string): boolean; + compareEndPoints(how: string, sourceRange: TextRange): number; + execCommandShowHelp(cmdID: string): boolean; + moveToElementText(element: Element): void; + expand(Unit: string): boolean; + queryCommandSupported(cmdID: string): boolean; + setEndPoint(how: string, SourceRange: TextRange): void; + queryCommandEnabled(cmdID: string): boolean; +} +declare var TextRange: { + prototype: TextRange; + new (): TextRange; +} + +interface SVGTests { + requiredFeatures: SVGStringList; + requiredExtensions: SVGStringList; + systemLanguage: SVGStringList; + hasExtension(extension: string): boolean; +} + +interface HTMLBlockElement extends HTMLElement, DOML2DeprecatedTextFlowControl { + width: number; + cite: string; +} +declare var HTMLBlockElement: { + prototype: HTMLBlockElement; + new (): HTMLBlockElement; +} + +interface CSSStyleSheet extends StyleSheet { + owningElement: Element; + imports: StyleSheetList; + isAlternate: boolean; + rules: MSCSSRuleList; + isPrefAlternate: boolean; + readOnly: boolean; + cssText: string; + ownerRule: CSSRule; + href: string; + cssRules: CSSRuleList; + id: string; + pages: StyleSheetPageList; + addImport(bstrURL: string, lIndex?: number): number; + addPageRule(bstrSelector: string, bstrStyle: string, lIndex?: number): number; + insertRule(rule: string, index?: number): number; + removeRule(lIndex: number): void; + deleteRule(index?: number): void; + addRule(bstrSelector: string, bstrStyle?: string, lIndex?: number): number; + removeImport(lIndex: number): void; +} +declare var CSSStyleSheet: { + prototype: CSSStyleSheet; + new (): CSSStyleSheet; +} + +interface MSSelection { + type: string; + typeDetail: string; + createRange(): TextRange; + clear(): void; + createRangeCollection(): TextRangeCollection; + empty(): void; +} +declare var MSSelection: { + prototype: MSSelection; + new (): MSSelection; +} + +interface HTMLMetaElement extends HTMLElement { + httpEquiv: string; + name: string; + content: string; + url: string; + scheme: string; + charset: string; +} +declare var HTMLMetaElement: { + prototype: HTMLMetaElement; + new (): HTMLMetaElement; +} + +interface SVGPatternElement extends SVGElement, SVGUnitTypes, SVGStylable, SVGLangSpace, SVGTests, SVGFitToViewBox, SVGExternalResourcesRequired, SVGURIReference { + patternUnits: SVGAnimatedEnumeration; + y: SVGAnimatedLength; + width: SVGAnimatedLength; + x: SVGAnimatedLength; + patternContentUnits: SVGAnimatedEnumeration; + patternTransform: SVGAnimatedTransformList; + height: SVGAnimatedLength; +} +declare var SVGPatternElement: { + prototype: SVGPatternElement; + new (): SVGPatternElement; +} + +interface SVGAnimatedAngle { + animVal: SVGAngle; + baseVal: SVGAngle; +} +declare var SVGAnimatedAngle: { + prototype: SVGAnimatedAngle; + new (): SVGAnimatedAngle; +} + +interface Selection { + isCollapsed: boolean; + anchorNode: Node; + focusNode: Node; + anchorOffset: number; + focusOffset: number; + rangeCount: number; + addRange(range: Range): void; + collapseToEnd(): void; + toString(): string; + selectAllChildren(parentNode: Node): void; + getRangeAt(index: number): Range; + collapse(parentNode: Node, offset: number): void; + removeAllRanges(): void; + collapseToStart(): void; + deleteFromDocument(): void; + removeRange(range: Range): void; +} +declare var Selection: { + prototype: Selection; + new (): Selection; +} + +interface SVGScriptElement extends SVGElement, SVGExternalResourcesRequired, SVGURIReference { + type: string; +} +declare var SVGScriptElement: { + prototype: SVGScriptElement; + new (): SVGScriptElement; +} + +interface HTMLDDElement extends HTMLElement { + noWrap: boolean; +} +declare var HTMLDDElement: { + prototype: HTMLDDElement; + new (): HTMLDDElement; +} + +interface MSDataBindingRecordSetReadonlyExtensions { + recordset: Object; + namedRecordset(dataMember: string, hierarchy?: any): Object; +} + +interface CSSStyleRule extends CSSRule { + selectorText: string; + style: MSStyleCSSProperties; + readOnly: boolean; +} +declare var CSSStyleRule: { + prototype: CSSStyleRule; + new (): CSSStyleRule; +} + +interface NodeIterator { + whatToShow: number; + filter: NodeFilter; + root: Node; + expandEntityReferences: boolean; + nextNode(): Node; + detach(): void; + previousNode(): Node; +} +declare var NodeIterator: { + prototype: NodeIterator; + new (): NodeIterator; +} + +interface SVGViewElement extends SVGElement, SVGZoomAndPan, SVGFitToViewBox, SVGExternalResourcesRequired { + viewTarget: SVGStringList; +} +declare var SVGViewElement: { + prototype: SVGViewElement; + new (): SVGViewElement; +} + +interface HTMLLinkElement extends HTMLElement, LinkStyle { + rel: string; + target: string; + href: string; + media: string; + rev: string; + type: string; + charset: string; + hreflang: string; +} +declare var HTMLLinkElement: { + prototype: HTMLLinkElement; + new (): HTMLLinkElement; +} + +interface SVGLocatable { + farthestViewportElement: SVGElement; + nearestViewportElement: SVGElement; + getBBox(): SVGRect; + getTransformToElement(element: SVGElement): SVGMatrix; + getCTM(): SVGMatrix; + getScreenCTM(): SVGMatrix; +} + +interface HTMLFontElement extends HTMLElement, DOML2DeprecatedColorProperty, DOML2DeprecatedSizeProperty { + face: string; +} +declare var HTMLFontElement: { + prototype: HTMLFontElement; + new (): HTMLFontElement; +} + +interface SVGTitleElement extends SVGElement, SVGStylable, SVGLangSpace { +} +declare var SVGTitleElement: { + prototype: SVGTitleElement; + new (): SVGTitleElement; +} + +interface ControlRangeCollection { + length: number; + queryCommandValue(cmdID: string): any; + remove(index: number): void; + add(item: Element): void; + queryCommandIndeterm(cmdID: string): boolean; + scrollIntoView(varargStart?: any): void; + item(index: number): Element; + [index: number]: Element; + execCommand(cmdID: string, showUI?: boolean, value?: any): boolean; + addElement(item: Element): void; + queryCommandState(cmdID: string): boolean; + queryCommandSupported(cmdID: string): boolean; + queryCommandEnabled(cmdID: string): boolean; + queryCommandText(cmdID: string): string; + select(): void; +} +declare var ControlRangeCollection: { + prototype: ControlRangeCollection; + new (): ControlRangeCollection; +} + +interface MSNamespaceInfo extends MSEventAttachmentTarget { + urn: string; + onreadystatechange: (ev: Event) => any; + addEventListener(type: "readystatechange", listener: (ev: Event) => any, useCapture?: boolean): void; + name: string; + readyState: string; + doImport(implementationUrl: string): void; + addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; +} +declare var MSNamespaceInfo: { + prototype: MSNamespaceInfo; + new (): MSNamespaceInfo; +} + +interface WindowSessionStorage { + sessionStorage: Storage; +} + +interface SVGAnimatedTransformList { + animVal: SVGTransformList; + baseVal: SVGTransformList; +} +declare var SVGAnimatedTransformList: { + prototype: SVGAnimatedTransformList; + new (): SVGAnimatedTransformList; +} + +interface HTMLTableCaptionElement extends HTMLElement { + align: string; + vAlign: string; +} +declare var HTMLTableCaptionElement: { + prototype: HTMLTableCaptionElement; + new (): HTMLTableCaptionElement; +} + +interface HTMLOptionElement extends HTMLElement, MSDataBindingExtensions { + index: number; + defaultSelected: boolean; + value: string; + text: string; + form: HTMLFormElement; + label: string; + selected: boolean; + create(): HTMLOptionElement; +} +declare var HTMLOptionElement: { + prototype: HTMLOptionElement; + new (): HTMLOptionElement; +} + +interface HTMLMapElement extends HTMLElement { + name: string; + areas: HTMLAreasCollection; +} +declare var HTMLMapElement: { + prototype: HTMLMapElement; + new (): HTMLMapElement; +} + +interface HTMLMenuElement extends HTMLElement, DOML2DeprecatedListSpaceReduction { + type: string; +} +declare var HTMLMenuElement: { + prototype: HTMLMenuElement; + new (): HTMLMenuElement; +} + +interface MouseWheelEvent extends MouseEvent { + wheelDelta: number; + initMouseWheelEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: Window, detailArg: number, screenXArg: number, screenYArg: number, clientXArg: number, clientYArg: number, buttonArg: number, relatedTargetArg: EventTarget, modifiersListArg: string, wheelDeltaArg: number): void; +} +declare var MouseWheelEvent: { + prototype: MouseWheelEvent; + new (): MouseWheelEvent; +} + +interface SVGFitToViewBox { + viewBox: SVGAnimatedRect; + preserveAspectRatio: SVGAnimatedPreserveAspectRatio; +} + +interface SVGPointList { + numberOfItems: number; + replaceItem(newItem: SVGPoint, index: number): SVGPoint; + getItem(index: number): SVGPoint; + clear(): void; + appendItem(newItem: SVGPoint): SVGPoint; + initialize(newItem: SVGPoint): SVGPoint; + removeItem(index: number): SVGPoint; + insertItemBefore(newItem: SVGPoint, index: number): SVGPoint; +} +declare var SVGPointList: { + prototype: SVGPointList; + new (): SVGPointList; +} + +interface SVGAnimatedLengthList { + animVal: SVGLengthList; + baseVal: SVGLengthList; +} +declare var SVGAnimatedLengthList: { + prototype: SVGAnimatedLengthList; + new (): SVGAnimatedLengthList; +} + +interface Window extends EventTarget, MSEventAttachmentTarget, WindowLocalStorage, MSWindowExtensions, WindowSessionStorage, WindowTimers { + ondragend: (ev: DragEvent) => any; + addEventListener(type: "dragend", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + onkeydown: (ev: KeyboardEvent) => any; + addEventListener(type: "keydown", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; + ondragover: (ev: DragEvent) => any; + addEventListener(type: "dragover", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + onkeyup: (ev: KeyboardEvent) => any; + addEventListener(type: "keyup", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; + onreset: (ev: Event) => any; + addEventListener(type: "reset", listener: (ev: Event) => any, useCapture?: boolean): void; + onmouseup: (ev: MouseEvent) => any; + addEventListener(type: "mouseup", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + ondragstart: (ev: DragEvent) => any; + addEventListener(type: "dragstart", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + ondrag: (ev: DragEvent) => any; + addEventListener(type: "drag", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + screenX: number; + onmouseover: (ev: MouseEvent) => any; + addEventListener(type: "mouseover", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + ondragleave: (ev: DragEvent) => any; + addEventListener(type: "dragleave", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + history: History; + pageXOffset: number; + name: string; + onafterprint: (ev: Event) => any; + addEventListener(type: "afterprint", listener: (ev: Event) => any, useCapture?: boolean): void; + onpause: (ev: Event) => any; + addEventListener(type: "pause", listener: (ev: Event) => any, useCapture?: boolean): void; + onbeforeprint: (ev: Event) => any; + addEventListener(type: "beforeprint", listener: (ev: Event) => any, useCapture?: boolean): void; + top: Window; + onmousedown: (ev: MouseEvent) => any; + addEventListener(type: "mousedown", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + onseeked: (ev: Event) => any; + addEventListener(type: "seeked", listener: (ev: Event) => any, useCapture?: boolean): void; + opener: Window; + onclick: (ev: MouseEvent) => any; + addEventListener(type: "click", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + innerHeight: number; + onwaiting: (ev: Event) => any; + addEventListener(type: "waiting", listener: (ev: Event) => any, useCapture?: boolean): void; + ononline: (ev: Event) => any; + addEventListener(type: "online", listener: (ev: Event) => any, useCapture?: boolean): void; + ondurationchange: (ev: Event) => any; + addEventListener(type: "durationchange", listener: (ev: Event) => any, useCapture?: boolean): void; + frames: Window; + onblur: (ev: FocusEvent) => any; + addEventListener(type: "blur", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + onemptied: (ev: Event) => any; + addEventListener(type: "emptied", listener: (ev: Event) => any, useCapture?: boolean): void; + onseeking: (ev: Event) => any; + addEventListener(type: "seeking", listener: (ev: Event) => any, useCapture?: boolean): void; + oncanplay: (ev: Event) => any; + addEventListener(type: "canplay", listener: (ev: Event) => any, useCapture?: boolean): void; + outerWidth: number; + onstalled: (ev: Event) => any; + addEventListener(type: "stalled", listener: (ev: Event) => any, useCapture?: boolean): void; + onmousemove: (ev: MouseEvent) => any; + addEventListener(type: "mousemove", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + innerWidth: number; + onoffline: (ev: Event) => any; + addEventListener(type: "offline", listener: (ev: Event) => any, useCapture?: boolean): void; + length: number; + screen: Screen; + onbeforeunload: (ev: BeforeUnloadEvent) => any; + addEventListener(type: "beforeunload", listener: (ev: BeforeUnloadEvent) => any, useCapture?: boolean): void; + onratechange: (ev: Event) => any; + addEventListener(type: "ratechange", listener: (ev: Event) => any, useCapture?: boolean): void; + onstorage: (ev: StorageEvent) => any; + addEventListener(type: "storage", listener: (ev: StorageEvent) => any, useCapture?: boolean): void; + onloadstart: (ev: Event) => any; + addEventListener(type: "loadstart", listener: (ev: Event) => any, useCapture?: boolean): void; + ondragenter: (ev: DragEvent) => any; + addEventListener(type: "dragenter", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + onsubmit: (ev: Event) => any; + addEventListener(type: "submit", listener: (ev: Event) => any, useCapture?: boolean): void; + self: Window; + document: Document; + onprogress: (ev: any) => any; + addEventListener(type: "progress", listener: (ev: any) => any, useCapture?: boolean): void; + ondblclick: (ev: MouseEvent) => any; + addEventListener(type: "dblclick", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + pageYOffset: number; + oncontextmenu: (ev: MouseEvent) => any; + addEventListener(type: "contextmenu", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + onchange: (ev: Event) => any; + addEventListener(type: "change", listener: (ev: Event) => any, useCapture?: boolean): void; + onloadedmetadata: (ev: Event) => any; + addEventListener(type: "loadedmetadata", listener: (ev: Event) => any, useCapture?: boolean): void; + onplay: (ev: Event) => any; + addEventListener(type: "play", listener: (ev: Event) => any, useCapture?: boolean): void; + onerror: ErrorEventHandler; + onplaying: (ev: Event) => any; + addEventListener(type: "playing", listener: (ev: Event) => any, useCapture?: boolean): void; + parent: Window; + location: Location; + oncanplaythrough: (ev: Event) => any; + addEventListener(type: "canplaythrough", listener: (ev: Event) => any, useCapture?: boolean): void; + onabort: (ev: UIEvent) => any; + addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + onreadystatechange: (ev: Event) => any; + addEventListener(type: "readystatechange", listener: (ev: Event) => any, useCapture?: boolean): void; + outerHeight: number; + onkeypress: (ev: KeyboardEvent) => any; + addEventListener(type: "keypress", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; + frameElement: Element; + onloadeddata: (ev: Event) => any; + addEventListener(type: "loadeddata", listener: (ev: Event) => any, useCapture?: boolean): void; + onsuspend: (ev: Event) => any; + addEventListener(type: "suspend", listener: (ev: Event) => any, useCapture?: boolean): void; + window: Window; + onfocus: (ev: FocusEvent) => any; + addEventListener(type: "focus", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + onmessage: (ev: MessageEvent) => any; + addEventListener(type: "message", listener: (ev: MessageEvent) => any, useCapture?: boolean): void; + ontimeupdate: (ev: Event) => any; + addEventListener(type: "timeupdate", listener: (ev: Event) => any, useCapture?: boolean): void; + onresize: (ev: UIEvent) => any; + addEventListener(type: "resize", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + onselect: (ev: UIEvent) => any; + addEventListener(type: "select", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + navigator: Navigator; + styleMedia: StyleMedia; + ondrop: (ev: DragEvent) => any; + addEventListener(type: "drop", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + onmouseout: (ev: MouseEvent) => any; + addEventListener(type: "mouseout", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + onended: (ev: Event) => any; + addEventListener(type: "ended", listener: (ev: Event) => any, useCapture?: boolean): void; + onhashchange: (ev: Event) => any; + addEventListener(type: "hashchange", listener: (ev: Event) => any, useCapture?: boolean): void; + onunload: (ev: Event) => any; + addEventListener(type: "unload", listener: (ev: Event) => any, useCapture?: boolean): void; + onscroll: (ev: UIEvent) => any; + addEventListener(type: "scroll", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + screenY: number; + onmousewheel: (ev: MouseWheelEvent) => any; + addEventListener(type: "mousewheel", listener: (ev: MouseWheelEvent) => any, useCapture?: boolean): void; + onload: (ev: Event) => any; + addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; + onvolumechange: (ev: Event) => any; + addEventListener(type: "volumechange", listener: (ev: Event) => any, useCapture?: boolean): void; + oninput: (ev: Event) => any; + addEventListener(type: "input", listener: (ev: Event) => any, useCapture?: boolean): void; + performance: Performance; + alert(message?: string): void; + scroll(x?: number, y?: number): void; + focus(): void; + scrollTo(x?: number, y?: number): void; + print(): void; + prompt(message?: string, defaul?: string): string; + toString(): string; + open(url?: string, target?: string, features?: string, replace?: boolean): Window; + scrollBy(x?: number, y?: number): void; + confirm(message?: string): boolean; + close(): void; + postMessage(message: any, targetOrigin: string, ports?: any): void; + showModalDialog(url?: string, argument?: any, options?: any): any; + blur(): void; + getSelection(): Selection; + getComputedStyle(elt: Element, pseudoElt?: string): CSSStyleDeclaration; + addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; +} +declare var Window: { + prototype: Window; + new (): Window; +} + +interface SVGAnimatedPreserveAspectRatio { + animVal: SVGPreserveAspectRatio; + baseVal: SVGPreserveAspectRatio; +} +declare var SVGAnimatedPreserveAspectRatio: { + prototype: SVGAnimatedPreserveAspectRatio; + new (): SVGAnimatedPreserveAspectRatio; +} + +interface MSSiteModeEvent extends Event { + buttonID: number; + actionURL: string; +} +declare var MSSiteModeEvent: { + prototype: MSSiteModeEvent; + new (): MSSiteModeEvent; +} + +interface DOML2DeprecatedTextFlowControl { + clear: string; +} + +interface StyleSheetPageList { + length: number; + item(index: number): CSSPageRule; + [index: number]: CSSPageRule; +} +declare var StyleSheetPageList: { + prototype: StyleSheetPageList; + new (): StyleSheetPageList; +} + +interface MSCSSProperties extends CSSStyleDeclaration { + scrollbarShadowColor: string; + scrollbarHighlightColor: string; + layoutGridChar: string; + layoutGridType: string; + textAutospace: string; + textKashidaSpace: string; + writingMode: string; + scrollbarFaceColor: string; + backgroundPositionY: string; + lineBreak: string; + imeMode: string; + msBlockProgression: string; + layoutGridLine: string; + scrollbarBaseColor: string; + layoutGrid: string; + layoutFlow: string; + textKashida: string; + filter: string; + zoom: string; + scrollbarArrowColor: string; + behavior: string; + backgroundPositionX: string; + accelerator: string; + layoutGridMode: string; + textJustifyTrim: string; + scrollbar3dLightColor: string; + msInterpolationMode: string; + scrollbarTrackColor: string; + scrollbarDarkShadowColor: string; + styleFloat: string; + getAttribute(attributeName: string, flags?: number): any; + setAttribute(attributeName: string, AttributeValue: any, flags?: number): void; + removeAttribute(attributeName: string, flags?: number): boolean; +} +declare var MSCSSProperties: { + prototype: MSCSSProperties; + new (): MSCSSProperties; +} + +interface HTMLCollection extends MSHTMLCollectionExtensions { + length: number; + item(nameOrIndex?: any, optionalIndex?: any): Element; + namedItem(name: string): Element; + [name: number]: Element; +} +declare var HTMLCollection: { + prototype: HTMLCollection; + new (): HTMLCollection; +} + +interface SVGExternalResourcesRequired { + externalResourcesRequired: SVGAnimatedBoolean; +} + +interface HTMLImageElement extends HTMLElement, MSImageResourceExtensions, MSDataBindingExtensions, MSResourceMetadata { + width: number; + vspace: number; + naturalHeight: number; + alt: string; + align: string; + src: string; + useMap: string; + naturalWidth: number; + name: string; + height: number; + border: string; + hspace: number; + longDesc: string; + href: string; + isMap: boolean; + complete: boolean; + create(): HTMLImageElement; +} +declare var HTMLImageElement: { + prototype: HTMLImageElement; + new (): HTMLImageElement; +} + +interface HTMLAreaElement extends HTMLElement { + protocol: string; + search: string; + alt: string; + coords: string; + hostname: string; + port: string; + pathname: string; + host: string; + hash: string; + target: string; + href: string; + noHref: boolean; + shape: string; + toString(): string; +} +declare var HTMLAreaElement: { + prototype: HTMLAreaElement; + new (): HTMLAreaElement; +} + +interface EventTarget { + removeEventListener(type: string, listener: EventListener, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; + dispatchEvent(evt: Event): boolean; +} + +interface SVGAngle { + valueAsString: string; + valueInSpecifiedUnits: number; + value: number; + unitType: number; + newValueSpecifiedUnits(unitType: number, valueInSpecifiedUnits: number): void; + convertToSpecifiedUnits(unitType: number): void; + SVG_ANGLETYPE_RAD: number; + SVG_ANGLETYPE_UNKNOWN: number; + SVG_ANGLETYPE_UNSPECIFIED: number; + SVG_ANGLETYPE_DEG: number; + SVG_ANGLETYPE_GRAD: number; +} +declare var SVGAngle: { + prototype: SVGAngle; + new (): SVGAngle; + SVG_ANGLETYPE_RAD: number; + SVG_ANGLETYPE_UNKNOWN: number; + SVG_ANGLETYPE_UNSPECIFIED: number; + SVG_ANGLETYPE_DEG: number; + SVG_ANGLETYPE_GRAD: number; +} + +interface HTMLButtonElement extends HTMLElement, MSDataBindingExtensions { + value: string; + status: any; + form: HTMLFormElement; + name: string; + type: string; + createTextRange(): TextRange; +} +declare var HTMLButtonElement: { + prototype: HTMLButtonElement; + new (): HTMLButtonElement; +} + +interface HTMLSourceElement extends HTMLElement { + src: string; + media: string; + type: string; +} +declare var HTMLSourceElement: { + prototype: HTMLSourceElement; + new (): HTMLSourceElement; +} + +interface CanvasGradient { + addColorStop(offset: number, color: string): void; +} +declare var CanvasGradient: { + prototype: CanvasGradient; + new (): CanvasGradient; +} + +interface KeyboardEvent extends UIEvent { + location: number; + keyCode: number; + shiftKey: boolean; + which: number; + locale: string; + key: string; + altKey: boolean; + metaKey: boolean; + char: string; + ctrlKey: boolean; + repeat: boolean; + charCode: number; + getModifierState(keyArg: string): boolean; + initKeyboardEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: Window, keyArg: string, locationArg: number, modifiersListArg: string, repeat: boolean, locale: string): void; + DOM_KEY_LOCATION_RIGHT: number; + DOM_KEY_LOCATION_STANDARD: number; + DOM_KEY_LOCATION_LEFT: number; + DOM_KEY_LOCATION_NUMPAD: number; + DOM_KEY_LOCATION_JOYSTICK: number; + DOM_KEY_LOCATION_MOBILE: number; +} +declare var KeyboardEvent: { + prototype: KeyboardEvent; + new (): KeyboardEvent; + DOM_KEY_LOCATION_RIGHT: number; + DOM_KEY_LOCATION_STANDARD: number; + DOM_KEY_LOCATION_LEFT: number; + DOM_KEY_LOCATION_NUMPAD: number; + DOM_KEY_LOCATION_JOYSTICK: number; + DOM_KEY_LOCATION_MOBILE: number; +} + +interface Document extends Node, NodeSelector, MSEventAttachmentTarget, DocumentEvent, MSResourceMetadata, MSNodeExtensions { + compatible: MSCompatibleInfoCollection; + onkeydown: (ev: KeyboardEvent) => any; + addEventListener(type: "keydown", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; + onkeyup: (ev: KeyboardEvent) => any; + addEventListener(type: "keyup", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; + implementation: DOMImplementation; + onreset: (ev: Event) => any; + addEventListener(type: "reset", listener: (ev: Event) => any, useCapture?: boolean): void; + scripts: HTMLCollection; + onhelp: (ev: Event) => any; + addEventListener(type: "help", listener: (ev: Event) => any, useCapture?: boolean): void; + ondragleave: (ev: DragEvent) => any; + addEventListener(type: "dragleave", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + charset: string; + onfocusin: (ev: FocusEvent) => any; + addEventListener(type: "focusin", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + vlinkColor: string; + onseeked: (ev: Event) => any; + addEventListener(type: "seeked", listener: (ev: Event) => any, useCapture?: boolean): void; + security: string; + title: string; + namespaces: MSNamespaceInfoCollection; + defaultCharset: string; + embeds: HTMLCollection; + styleSheets: StyleSheetList; + frames: Window; + ondurationchange: (ev: Event) => any; + addEventListener(type: "durationchange", listener: (ev: Event) => any, useCapture?: boolean): void; + all: HTMLCollection; + forms: HTMLCollection; + onblur: (ev: FocusEvent) => any; + addEventListener(type: "blur", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + dir: string; + onemptied: (ev: Event) => any; + addEventListener(type: "emptied", listener: (ev: Event) => any, useCapture?: boolean): void; + designMode: string; + onseeking: (ev: Event) => any; + addEventListener(type: "seeking", listener: (ev: Event) => any, useCapture?: boolean): void; + ondeactivate: (ev: UIEvent) => any; + addEventListener(type: "deactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + oncanplay: (ev: Event) => any; + addEventListener(type: "canplay", listener: (ev: Event) => any, useCapture?: boolean): void; + ondatasetchanged: (ev: MSEventObj) => any; + addEventListener(type: "datasetchanged", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + onrowsdelete: (ev: MSEventObj) => any; + addEventListener(type: "rowsdelete", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + Script: MSScriptHost; + onloadstart: (ev: Event) => any; + addEventListener(type: "loadstart", listener: (ev: Event) => any, useCapture?: boolean): void; + URLUnencoded: string; + defaultView: Window; + oncontrolselect: (ev: MSEventObj) => any; + addEventListener(type: "controlselect", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + ondragenter: (ev: DragEvent) => any; + addEventListener(type: "dragenter", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + onsubmit: (ev: Event) => any; + addEventListener(type: "submit", listener: (ev: Event) => any, useCapture?: boolean): void; + inputEncoding: string; + activeElement: Element; + onchange: (ev: Event) => any; + addEventListener(type: "change", listener: (ev: Event) => any, useCapture?: boolean): void; + links: HTMLCollection; + uniqueID: string; + URL: string; + onbeforeactivate: (ev: UIEvent) => any; + addEventListener(type: "beforeactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + head: HTMLHeadElement; + cookie: string; + xmlEncoding: string; + oncanplaythrough: (ev: Event) => any; + addEventListener(type: "canplaythrough", listener: (ev: Event) => any, useCapture?: boolean): void; + documentMode: number; + characterSet: string; + anchors: HTMLCollection; + onbeforeupdate: (ev: MSEventObj) => any; + addEventListener(type: "beforeupdate", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + ondatasetcomplete: (ev: MSEventObj) => any; + addEventListener(type: "datasetcomplete", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + plugins: HTMLCollection; + onsuspend: (ev: Event) => any; + addEventListener(type: "suspend", listener: (ev: Event) => any, useCapture?: boolean): void; + rootElement: SVGSVGElement; + readyState: string; + referrer: string; + alinkColor: string; + onerrorupdate: (ev: MSEventObj) => any; + addEventListener(type: "errorupdate", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + parentWindow: Window; + onmouseout: (ev: MouseEvent) => any; + addEventListener(type: "mouseout", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + onmsthumbnailclick: (ev: MSSiteModeEvent) => any; + addEventListener(type: "msthumbnailclick", listener: (ev: MSSiteModeEvent) => any, useCapture?: boolean): void; + onmousewheel: (ev: MouseWheelEvent) => any; + addEventListener(type: "mousewheel", listener: (ev: MouseWheelEvent) => any, useCapture?: boolean): void; + onvolumechange: (ev: Event) => any; + addEventListener(type: "volumechange", listener: (ev: Event) => any, useCapture?: boolean): void; + oncellchange: (ev: MSEventObj) => any; + addEventListener(type: "cellchange", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + onrowexit: (ev: MSEventObj) => any; + addEventListener(type: "rowexit", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + onrowsinserted: (ev: MSEventObj) => any; + addEventListener(type: "rowsinserted", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + xmlVersion: string; + msCapsLockWarningOff: boolean; + onpropertychange: (ev: MSEventObj) => any; + addEventListener(type: "propertychange", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + ondragend: (ev: DragEvent) => any; + addEventListener(type: "dragend", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + doctype: DocumentType; + ondragover: (ev: DragEvent) => any; + addEventListener(type: "dragover", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + bgColor: string; + ondragstart: (ev: DragEvent) => any; + addEventListener(type: "dragstart", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + onmouseup: (ev: MouseEvent) => any; + addEventListener(type: "mouseup", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + ondrag: (ev: DragEvent) => any; + addEventListener(type: "drag", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + onmouseover: (ev: MouseEvent) => any; + addEventListener(type: "mouseover", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + linkColor: string; + onpause: (ev: Event) => any; + addEventListener(type: "pause", listener: (ev: Event) => any, useCapture?: boolean): void; + onmousedown: (ev: MouseEvent) => any; + addEventListener(type: "mousedown", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + onclick: (ev: MouseEvent) => any; + addEventListener(type: "click", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + onwaiting: (ev: Event) => any; + addEventListener(type: "waiting", listener: (ev: Event) => any, useCapture?: boolean): void; + onstop: (ev: Event) => any; + addEventListener(type: "stop", listener: (ev: Event) => any, useCapture?: boolean): void; + onmssitemodejumplistitemremoved: (ev: MSSiteModeEvent) => any; + addEventListener(type: "mssitemodejumplistitemremoved", listener: (ev: MSSiteModeEvent) => any, useCapture?: boolean): void; + applets: HTMLCollection; + body: HTMLElement; + domain: string; + xmlStandalone: boolean; + selection: MSSelection; + onstalled: (ev: Event) => any; + addEventListener(type: "stalled", listener: (ev: Event) => any, useCapture?: boolean): void; + onmousemove: (ev: MouseEvent) => any; + addEventListener(type: "mousemove", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + documentElement: Element; + onbeforeeditfocus: (ev: MSEventObj) => any; + addEventListener(type: "beforeeditfocus", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + onratechange: (ev: Event) => any; + addEventListener(type: "ratechange", listener: (ev: Event) => any, useCapture?: boolean): void; + onprogress: (ev: any) => any; + addEventListener(type: "progress", listener: (ev: any) => any, useCapture?: boolean): void; + ondblclick: (ev: MouseEvent) => any; + addEventListener(type: "dblclick", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + oncontextmenu: (ev: MouseEvent) => any; + addEventListener(type: "contextmenu", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + onloadedmetadata: (ev: Event) => any; + addEventListener(type: "loadedmetadata", listener: (ev: Event) => any, useCapture?: boolean): void; + media: string; + onerror: (ev: Event) => any; + addEventListener(type: "error", listener: (ev: Event) => any, useCapture?: boolean): void; + onplay: (ev: Event) => any; + addEventListener(type: "play", listener: (ev: Event) => any, useCapture?: boolean): void; + onafterupdate: (ev: MSEventObj) => any; + addEventListener(type: "afterupdate", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + onplaying: (ev: Event) => any; + addEventListener(type: "playing", listener: (ev: Event) => any, useCapture?: boolean): void; + images: HTMLCollection; + location: Location; + onabort: (ev: UIEvent) => any; + addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + onfocusout: (ev: FocusEvent) => any; + addEventListener(type: "focusout", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + onselectionchange: (ev: Event) => any; + addEventListener(type: "selectionchange", listener: (ev: Event) => any, useCapture?: boolean): void; + onstoragecommit: (ev: StorageEvent) => any; + addEventListener(type: "storagecommit", listener: (ev: StorageEvent) => any, useCapture?: boolean): void; + ondataavailable: (ev: MSEventObj) => any; + addEventListener(type: "dataavailable", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + onreadystatechange: (ev: Event) => any; + addEventListener(type: "readystatechange", listener: (ev: Event) => any, useCapture?: boolean): void; + lastModified: string; + onkeypress: (ev: KeyboardEvent) => any; + addEventListener(type: "keypress", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; + onloadeddata: (ev: Event) => any; + addEventListener(type: "loadeddata", listener: (ev: Event) => any, useCapture?: boolean): void; + onbeforedeactivate: (ev: UIEvent) => any; + addEventListener(type: "beforedeactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + onactivate: (ev: UIEvent) => any; + addEventListener(type: "activate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + onselectstart: (ev: Event) => any; + addEventListener(type: "selectstart", listener: (ev: Event) => any, useCapture?: boolean): void; + onfocus: (ev: FocusEvent) => any; + addEventListener(type: "focus", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + fgColor: string; + ontimeupdate: (ev: Event) => any; + addEventListener(type: "timeupdate", listener: (ev: Event) => any, useCapture?: boolean): void; + onselect: (ev: UIEvent) => any; + addEventListener(type: "select", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + ondrop: (ev: DragEvent) => any; + addEventListener(type: "drop", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + onended: (ev: Event) => any; + addEventListener(type: "ended", listener: (ev: Event) => any, useCapture?: boolean): void; + compatMode: string; + onscroll: (ev: UIEvent) => any; + addEventListener(type: "scroll", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + onrowenter: (ev: MSEventObj) => any; + addEventListener(type: "rowenter", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + onload: (ev: Event) => any; + addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; + oninput: (ev: Event) => any; + addEventListener(type: "input", listener: (ev: Event) => any, useCapture?: boolean): void; + queryCommandValue(commandId: string): string; + adoptNode(source: Node): Node; + queryCommandIndeterm(commandId: string): boolean; + getElementsByTagNameNS(namespaceURI: string, localName: string): NodeList; + createProcessingInstruction(target: string, data: string): ProcessingInstruction; + execCommand(commandId: string, showUI?: boolean, value?: any): boolean; + elementFromPoint(x: number, y: number): Element; + createCDATASection(data: string): CDATASection; + queryCommandText(commandId: string): string; + write(...content: string[]): void; + updateSettings(): void; + createElement(tagName: string): HTMLElement; + createElement(tagName: "a"): HTMLAnchorElement; + createElement(tagName: "abbr"): HTMLElement; + createElement(tagName: "address"): HTMLElement; + createElement(tagName: "area"): HTMLAreaElement; + createElement(tagName: "article"): HTMLElement; + createElement(tagName: "aside"): HTMLElement; + createElement(tagName: "audio"): HTMLAudioElement; + createElement(tagName: "b"): HTMLElement; + createElement(tagName: "base"): HTMLBaseElement; + createElement(tagName: "bdi"): HTMLElement; + createElement(tagName: "bdo"): HTMLElement; + createElement(tagName: "blockquote"): HTMLQuoteElement; + createElement(tagName: "body"): HTMLBodyElement; + createElement(tagName: "br"): HTMLBRElement; + createElement(tagName: "button"): HTMLButtonElement; + createElement(tagName: "canvas"): HTMLCanvasElement; + createElement(tagName: "caption"): HTMLTableCaptionElement; + createElement(tagName: "cite"): HTMLElement; + createElement(tagName: "code"): HTMLElement; + createElement(tagName: "col"): HTMLTableColElement; + createElement(tagName: "colgroup"): HTMLTableColElement; + createElement(tagName: "datalist"): HTMLDataListElement; + createElement(tagName: "dd"): HTMLElement; + createElement(tagName: "del"): HTMLModElement; + createElement(tagName: "dfn"): HTMLElement; + createElement(tagName: "div"): HTMLDivElement; + createElement(tagName: "dl"): HTMLDListElement; + createElement(tagName: "dt"): HTMLElement; + createElement(tagName: "em"): HTMLElement; + createElement(tagName: "embed"): HTMLEmbedElement; + createElement(tagName: "fieldset"): HTMLFieldSetElement; + createElement(tagName: "figcaption"): HTMLElement; + createElement(tagName: "figure"): HTMLElement; + createElement(tagName: "footer"): HTMLElement; + createElement(tagName: "form"): HTMLFormElement; + createElement(tagName: "h1"): HTMLHeadingElement; + createElement(tagName: "h2"): HTMLHeadingElement; + createElement(tagName: "h3"): HTMLHeadingElement; + createElement(tagName: "h4"): HTMLHeadingElement; + createElement(tagName: "h5"): HTMLHeadingElement; + createElement(tagName: "h6"): HTMLHeadingElement; + createElement(tagName: "head"): HTMLHeadElement; + createElement(tagName: "header"): HTMLElement; + createElement(tagName: "hgroup"): HTMLElement; + createElement(tagName: "hr"): HTMLHRElement; + createElement(tagName: "html"): HTMLHtmlElement; + createElement(tagName: "i"): HTMLElement; + createElement(tagName: "iframe"): HTMLIFrameElement; + createElement(tagName: "img"): HTMLImageElement; + createElement(tagName: "input"): HTMLInputElement; + createElement(tagName: "ins"): HTMLModElement; + createElement(tagName: "kbd"): HTMLElement; + createElement(tagName: "label"): HTMLLabelElement; + createElement(tagName: "legend"): HTMLLegendElement; + createElement(tagName: "li"): HTMLLIElement; + createElement(tagName: "link"): HTMLLinkElement; + createElement(tagName: "main"): HTMLElement; + createElement(tagName: "map"): HTMLMapElement; + createElement(tagName: "mark"): HTMLElement; + createElement(tagName: "menu"): HTMLMenuElement; + createElement(tagName: "meta"): HTMLMetaElement; + createElement(tagName: "nav"): HTMLElement; + createElement(tagName: "noscript"): HTMLElement; + createElement(tagName: "object"): HTMLObjectElement; + createElement(tagName: "ol"): HTMLOListElement; + createElement(tagName: "optgroup"): HTMLOptGroupElement; + createElement(tagName: "option"): HTMLOptionElement; + createElement(tagName: "p"): HTMLParagraphElement; + createElement(tagName: "param"): HTMLParamElement; + createElement(tagName: "pre"): HTMLPreElement; + createElement(tagName: "progress"): HTMLProgressElement; + createElement(tagName: "q"): HTMLQuoteElement; + createElement(tagName: "rp"): HTMLElement; + createElement(tagName: "rt"): HTMLElement; + createElement(tagName: "ruby"): HTMLElement; + createElement(tagName: "s"): HTMLElement; + createElement(tagName: "samp"): HTMLElement; + createElement(tagName: "script"): HTMLScriptElement; + createElement(tagName: "section"): HTMLElement; + createElement(tagName: "select"): HTMLSelectElement; + createElement(tagName: "small"): HTMLElement; + createElement(tagName: "source"): HTMLSourceElement; + createElement(tagName: "span"): HTMLSpanElement; + createElement(tagName: "strong"): HTMLElement; + createElement(tagName: "style"): HTMLStyleElement; + createElement(tagName: "sub"): HTMLElement; + createElement(tagName: "summary"): HTMLElement; + createElement(tagName: "sup"): HTMLElement; + createElement(tagName: "table"): HTMLTableElement; + createElement(tagName: "tbody"): HTMLTableSectionElement; + createElement(tagName: "td"): HTMLTableDataCellElement; + createElement(tagName: "textarea"): HTMLTextAreaElement; + createElement(tagName: "tfoot"): HTMLTableSectionElement; + createElement(tagName: "th"): HTMLTableHeaderCellElement; + createElement(tagName: "thead"): HTMLTableSectionElement; + createElement(tagName: "title"): HTMLTitleElement; + createElement(tagName: "tr"): HTMLTableRowElement; + createElement(tagName: "track"): HTMLTrackElement; + createElement(tagName: "u"): HTMLElement; + createElement(tagName: "ul"): HTMLUListElement; + createElement(tagName: "var"): HTMLElement; + createElement(tagName: "video"): HTMLVideoElement; + createElement(tagName: "wbr"): HTMLElement; + releaseCapture(): void; + writeln(...content: string[]): void; + createElementNS(namespaceURI: string, qualifiedName: string): Element; + open(url?: string, name?: string, features?: string, replace?: boolean): any; + queryCommandSupported(commandId: string): boolean; + createTreeWalker(root: Node, whatToShow: number, filter: NodeFilter, entityReferenceExpansion: boolean): TreeWalker; + createAttributeNS(namespaceURI: string, qualifiedName: string): Attr; + queryCommandEnabled(commandId: string): boolean; + focus(): void; + close(): void; + getElementsByClassName(classNames: string): NodeList; + importNode(importedNode: Node, deep: boolean): Node; + createRange(): Range; + fireEvent(eventName: string, eventObj?: any): boolean; + createComment(data: string): Comment; + getElementsByTagName(tagname: string): NodeList; + getElementsByTagName(name: "a"): NodeListOf; + getElementsByTagName(name: "abbr"): NodeListOf; + getElementsByTagName(name: "address"): NodeListOf; + getElementsByTagName(name: "area"): NodeListOf; + getElementsByTagName(name: "article"): NodeListOf; + getElementsByTagName(name: "aside"): NodeListOf; + getElementsByTagName(name: "audio"): NodeListOf; + getElementsByTagName(name: "b"): NodeListOf; + getElementsByTagName(name: "base"): NodeListOf; + getElementsByTagName(name: "bdi"): NodeListOf; + getElementsByTagName(name: "bdo"): NodeListOf; + getElementsByTagName(name: "blockquote"): NodeListOf; + getElementsByTagName(name: "body"): NodeListOf; + getElementsByTagName(name: "br"): NodeListOf; + getElementsByTagName(name: "button"): NodeListOf; + getElementsByTagName(name: "canvas"): NodeListOf; + getElementsByTagName(name: "caption"): NodeListOf; + getElementsByTagName(name: "cite"): NodeListOf; + getElementsByTagName(name: "code"): NodeListOf; + getElementsByTagName(name: "col"): NodeListOf; + getElementsByTagName(name: "colgroup"): NodeListOf; + getElementsByTagName(name: "datalist"): NodeListOf; + getElementsByTagName(name: "dd"): NodeListOf; + getElementsByTagName(name: "del"): NodeListOf; + getElementsByTagName(name: "dfn"): NodeListOf; + getElementsByTagName(name: "div"): NodeListOf; + getElementsByTagName(name: "dl"): NodeListOf; + getElementsByTagName(name: "dt"): NodeListOf; + getElementsByTagName(name: "em"): NodeListOf; + getElementsByTagName(name: "embed"): NodeListOf; + getElementsByTagName(name: "fieldset"): NodeListOf; + getElementsByTagName(name: "figcaption"): NodeListOf; + getElementsByTagName(name: "figure"): NodeListOf; + getElementsByTagName(name: "footer"): NodeListOf; + getElementsByTagName(name: "form"): NodeListOf; + getElementsByTagName(name: "h1"): NodeListOf; + getElementsByTagName(name: "h2"): NodeListOf; + getElementsByTagName(name: "h3"): NodeListOf; + getElementsByTagName(name: "h4"): NodeListOf; + getElementsByTagName(name: "h5"): NodeListOf; + getElementsByTagName(name: "h6"): NodeListOf; + getElementsByTagName(name: "head"): NodeListOf; + getElementsByTagName(name: "header"): NodeListOf; + getElementsByTagName(name: "hgroup"): NodeListOf; + getElementsByTagName(name: "hr"): NodeListOf; + getElementsByTagName(name: "html"): NodeListOf; + getElementsByTagName(name: "i"): NodeListOf; + getElementsByTagName(name: "iframe"): NodeListOf; + getElementsByTagName(name: "img"): NodeListOf; + getElementsByTagName(name: "input"): NodeListOf; + getElementsByTagName(name: "ins"): NodeListOf; + getElementsByTagName(name: "kbd"): NodeListOf; + getElementsByTagName(name: "label"): NodeListOf; + getElementsByTagName(name: "legend"): NodeListOf; + getElementsByTagName(name: "li"): NodeListOf; + getElementsByTagName(name: "link"): NodeListOf; + getElementsByTagName(name: "main"): NodeListOf; + getElementsByTagName(name: "map"): NodeListOf; + getElementsByTagName(name: "mark"): NodeListOf; + getElementsByTagName(name: "menu"): NodeListOf; + getElementsByTagName(name: "meta"): NodeListOf; + getElementsByTagName(name: "nav"): NodeListOf; + getElementsByTagName(name: "noscript"): NodeListOf; + getElementsByTagName(name: "object"): NodeListOf; + getElementsByTagName(name: "ol"): NodeListOf; + getElementsByTagName(name: "optgroup"): NodeListOf; + getElementsByTagName(name: "option"): NodeListOf; + getElementsByTagName(name: "p"): NodeListOf; + getElementsByTagName(name: "param"): NodeListOf; + getElementsByTagName(name: "pre"): NodeListOf; + getElementsByTagName(name: "progress"): NodeListOf; + getElementsByTagName(name: "q"): NodeListOf; + getElementsByTagName(name: "rp"): NodeListOf; + getElementsByTagName(name: "rt"): NodeListOf; + getElementsByTagName(name: "ruby"): NodeListOf; + getElementsByTagName(name: "s"): NodeListOf; + getElementsByTagName(name: "samp"): NodeListOf; + getElementsByTagName(name: "script"): NodeListOf; + getElementsByTagName(name: "section"): NodeListOf; + getElementsByTagName(name: "select"): NodeListOf; + getElementsByTagName(name: "small"): NodeListOf; + getElementsByTagName(name: "source"): NodeListOf; + getElementsByTagName(name: "span"): NodeListOf; + getElementsByTagName(name: "strong"): NodeListOf; + getElementsByTagName(name: "style"): NodeListOf; + getElementsByTagName(name: "sub"): NodeListOf; + getElementsByTagName(name: "summary"): NodeListOf; + getElementsByTagName(name: "sup"): NodeListOf; + getElementsByTagName(name: "table"): NodeListOf; + getElementsByTagName(name: "tbody"): NodeListOf; + getElementsByTagName(name: "td"): NodeListOf; + getElementsByTagName(name: "textarea"): NodeListOf; + getElementsByTagName(name: "tfoot"): NodeListOf; + getElementsByTagName(name: "th"): NodeListOf; + getElementsByTagName(name: "thead"): NodeListOf; + getElementsByTagName(name: "title"): NodeListOf; + getElementsByTagName(name: "tr"): NodeListOf; + getElementsByTagName(name: "track"): NodeListOf; + getElementsByTagName(name: "u"): NodeListOf; + getElementsByTagName(name: "ul"): NodeListOf; + getElementsByTagName(name: "var"): NodeListOf; + getElementsByTagName(name: "video"): NodeListOf; + getElementsByTagName(name: "wbr"): NodeListOf; + createDocumentFragment(): DocumentFragment; + createStyleSheet(href?: string, index?: number): CSSStyleSheet; + getElementsByName(elementName: string): NodeList; + queryCommandState(commandId: string): boolean; + hasFocus(): boolean; + execCommandShowHelp(commandId: string): boolean; + createAttribute(name: string): Attr; + createTextNode(data: string): Text; + createNodeIterator(root: Node, whatToShow: number, filter: NodeFilter, entityReferenceExpansion: boolean): NodeIterator; + createEventObject(eventObj?: any): MSEventObj; + getSelection(): Selection; + getElementById(elementId: string): HTMLElement; + addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; + addEventListener(type: "DOMContentLoaded", listener: (ev: Event) => any, useCapture?: boolean): void; +} +declare var Document: { + prototype: Document; + new (): Document; +} + +interface MessageEvent extends Event { + source: Window; + origin: string; + data: any; + initMessageEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, dataArg: any, originArg: string, lastEventIdArg: string, sourceArg: Window): void; +} +declare var MessageEvent: { + prototype: MessageEvent; + new (): MessageEvent; +} + +interface SVGElement extends Element { + onmouseover: (ev: MouseEvent) => any; + addEventListener(type: "mouseover", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + viewportElement: SVGElement; + onmousemove: (ev: MouseEvent) => any; + addEventListener(type: "mousemove", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + onmouseout: (ev: MouseEvent) => any; + addEventListener(type: "mouseout", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + ondblclick: (ev: MouseEvent) => any; + addEventListener(type: "dblclick", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + onfocusout: (ev: FocusEvent) => any; + addEventListener(type: "focusout", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + onfocusin: (ev: FocusEvent) => any; + addEventListener(type: "focusin", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + xmlbase: string; + onmousedown: (ev: MouseEvent) => any; + addEventListener(type: "mousedown", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + onload: (ev: Event) => any; + addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; + onmouseup: (ev: MouseEvent) => any; + addEventListener(type: "mouseup", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + onclick: (ev: MouseEvent) => any; + addEventListener(type: "click", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + ownerSVGElement: SVGSVGElement; + id: string; + addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; +} +declare var SVGElement: { + prototype: SVGElement; + new (): SVGElement; +} + +interface HTMLScriptElement extends HTMLElement { + defer: boolean; + text: string; + src: string; + htmlFor: string; + charset: string; + type: string; + event: string; +} +declare var HTMLScriptElement: { + prototype: HTMLScriptElement; + new (): HTMLScriptElement; +} + +interface HTMLTableRowElement extends HTMLElement, HTMLTableAlignment, DOML2DeprecatedBackgroundColorStyle { + rowIndex: number; + cells: HTMLCollection; + align: string; + borderColorLight: any; + sectionRowIndex: number; + borderColor: any; + height: any; + borderColorDark: any; + deleteCell(index?: number): void; + insertCell(index?: number): HTMLElement; +} +declare var HTMLTableRowElement: { + prototype: HTMLTableRowElement; + new (): HTMLTableRowElement; +} + +interface CanvasRenderingContext2D { + miterLimit: number; + font: string; + globalCompositeOperation: string; + msFillRule: string; + lineCap: string; + msImageSmoothingEnabled: boolean; + lineDashOffset: number; + shadowColor: string; + lineJoin: string; + shadowOffsetX: number; + lineWidth: number; + canvas: HTMLCanvasElement; + strokeStyle: any; + globalAlpha: number; + shadowOffsetY: number; + fillStyle: any; + shadowBlur: number; + textAlign: string; + textBaseline: string; + restore(): void; + setTransform(m11: number, m12: number, m21: number, m22: number, dx: number, dy: number): void; + save(): void; + arc(x: number, y: number, radius: number, startAngle: number, endAngle: number, anticlockwise?: boolean): void; + measureText(text: string): TextMetrics; + isPointInPath(x: number, y: number, fillRule?: string): boolean; + quadraticCurveTo(cpx: number, cpy: number, x: number, y: number): void; + putImageData(imagedata: ImageData, dx: number, dy: number, dirtyX?: number, dirtyY?: number, dirtyWidth?: number, dirtyHeight?: number): void; + rotate(angle: number): void; + fillText(text: string, x: number, y: number, maxWidth?: number): void; + translate(x: number, y: number): void; + scale(x: number, y: number): void; + createRadialGradient(x0: number, y0: number, r0: number, x1: number, y1: number, r1: number): CanvasGradient; + lineTo(x: number, y: number): void; + getLineDash(): Array; + fill(fillRule?: string): void; + createImageData(imageDataOrSw: any, sh?: number): ImageData; + createPattern(image: HTMLElement, repetition: string): CanvasPattern; + closePath(): void; + rect(x: number, y: number, w: number, h: number): void; + clip(fillRule?: string): void; + clearRect(x: number, y: number, w: number, h: number): void; + moveTo(x: number, y: number): void; + getImageData(sx: number, sy: number, sw: number, sh: number): ImageData; + fillRect(x: number, y: number, w: number, h: number): void; + bezierCurveTo(cp1x: number, cp1y: number, cp2x: number, cp2y: number, x: number, y: number): void; + drawImage(image: HTMLElement, offsetX: number, offsetY: number, width?: number, height?: number, canvasOffsetX?: number, canvasOffsetY?: number, canvasImageWidth?: number, canvasImageHeight?: number): void; + transform(m11: number, m12: number, m21: number, m22: number, dx: number, dy: number): void; + stroke(): void; + strokeRect(x: number, y: number, w: number, h: number): void; + setLineDash(segments: Array): void; + strokeText(text: string, x: number, y: number, maxWidth?: number): void; + beginPath(): void; + arcTo(x1: number, y1: number, x2: number, y2: number, radius: number): void; + createLinearGradient(x0: number, y0: number, x1: number, y1: number): CanvasGradient; +} +declare var CanvasRenderingContext2D: { + prototype: CanvasRenderingContext2D; + new (): CanvasRenderingContext2D; +} + +interface MSCSSRuleList { + length: number; + item(index?: number): CSSStyleRule; + [index: number]: CSSStyleRule; +} +declare var MSCSSRuleList: { + prototype: MSCSSRuleList; + new (): MSCSSRuleList; +} + +interface SVGPathSegLinetoHorizontalAbs extends SVGPathSeg { + x: number; +} +declare var SVGPathSegLinetoHorizontalAbs: { + prototype: SVGPathSegLinetoHorizontalAbs; + new (): SVGPathSegLinetoHorizontalAbs; +} + +interface SVGPathSegArcAbs extends SVGPathSeg { + y: number; + sweepFlag: boolean; + r2: number; + x: number; + angle: number; + r1: number; + largeArcFlag: boolean; +} +declare var SVGPathSegArcAbs: { + prototype: SVGPathSegArcAbs; + new (): SVGPathSegArcAbs; +} + +interface SVGTransformList { + numberOfItems: number; + getItem(index: number): SVGTransform; + consolidate(): SVGTransform; + clear(): void; + appendItem(newItem: SVGTransform): SVGTransform; + initialize(newItem: SVGTransform): SVGTransform; + removeItem(index: number): SVGTransform; + insertItemBefore(newItem: SVGTransform, index: number): SVGTransform; + replaceItem(newItem: SVGTransform, index: number): SVGTransform; + createSVGTransformFromMatrix(matrix: SVGMatrix): SVGTransform; +} +declare var SVGTransformList: { + prototype: SVGTransformList; + new (): SVGTransformList; +} + +interface HTMLHtmlElement extends HTMLElement { + version: string; +} +declare var HTMLHtmlElement: { + prototype: HTMLHtmlElement; + new (): HTMLHtmlElement; +} + +interface SVGPathSegClosePath extends SVGPathSeg { +} +declare var SVGPathSegClosePath: { + prototype: SVGPathSegClosePath; + new (): SVGPathSegClosePath; +} + +interface HTMLFrameElement extends HTMLElement, GetSVGDocument, MSDataBindingExtensions { + width: any; + scrolling: string; + marginHeight: string; + marginWidth: string; + borderColor: any; + frameSpacing: any; + frameBorder: string; + noResize: boolean; + contentWindow: Window; + src: string; + name: string; + height: any; + contentDocument: Document; + border: string; + longDesc: string; + onload: (ev: Event) => any; + addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; + security: any; + addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; +} +declare var HTMLFrameElement: { + prototype: HTMLFrameElement; + new (): HTMLFrameElement; +} + +interface SVGAnimatedLength { + animVal: SVGLength; + baseVal: SVGLength; +} +declare var SVGAnimatedLength: { + prototype: SVGAnimatedLength; + new (): SVGAnimatedLength; +} + +interface SVGAnimatedPoints { + points: SVGPointList; + animatedPoints: SVGPointList; +} + +interface SVGDefsElement extends SVGElement, SVGStylable, SVGTransformable, SVGLangSpace, SVGTests, SVGExternalResourcesRequired { +} +declare var SVGDefsElement: { + prototype: SVGDefsElement; + new (): SVGDefsElement; +} + +interface HTMLQuoteElement extends HTMLElement { + dateTime: string; + cite: string; +} +declare var HTMLQuoteElement: { + prototype: HTMLQuoteElement; + new (): HTMLQuoteElement; +} + +interface CSSMediaRule extends CSSRule { + media: MediaList; + cssRules: CSSRuleList; + insertRule(rule: string, index?: number): number; + deleteRule(index?: number): void; +} +declare var CSSMediaRule: { + prototype: CSSMediaRule; + new (): CSSMediaRule; +} + +interface WindowModal { + dialogArguments: any; + returnValue: any; +} + +interface XMLHttpRequest extends EventTarget { + responseBody: any; + status: number; + readyState: number; + responseText: string; + responseXML: Document; + ontimeout: (ev: Event) => any; + addEventListener(type: "timeout", listener: (ev: Event) => any, useCapture?: boolean): void; + statusText: string; + onreadystatechange: (ev: Event) => any; + addEventListener(type: "readystatechange", listener: (ev: Event) => any, useCapture?: boolean): void; + timeout: number; + onload: (ev: Event) => any; + addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; + open(method: string, url: string, async?: boolean, user?: string, password?: string): void; + create(): XMLHttpRequest; + send(data?: any): void; + abort(): void; + getAllResponseHeaders(): string; + setRequestHeader(header: string, value: string): void; + getResponseHeader(header: string): string; + addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; + LOADING: number; + DONE: number; + UNSENT: number; + OPENED: number; + HEADERS_RECEIVED: number; +} +declare var XMLHttpRequest: { + prototype: XMLHttpRequest; + new (): XMLHttpRequest; + LOADING: number; + DONE: number; + UNSENT: number; + OPENED: number; + HEADERS_RECEIVED: number; +} + +interface HTMLTableHeaderCellElement extends HTMLTableCellElement { + scope: string; +} +declare var HTMLTableHeaderCellElement: { + prototype: HTMLTableHeaderCellElement; + new (): HTMLTableHeaderCellElement; +} + +interface HTMLDListElement extends HTMLElement, DOML2DeprecatedListSpaceReduction { +} +declare var HTMLDListElement: { + prototype: HTMLDListElement; + new (): HTMLDListElement; +} + +interface MSDataBindingExtensions { + dataSrc: string; + dataFormatAs: string; + dataFld: string; +} + +interface SVGPathSegLinetoHorizontalRel extends SVGPathSeg { + x: number; +} +declare var SVGPathSegLinetoHorizontalRel: { + prototype: SVGPathSegLinetoHorizontalRel; + new (): SVGPathSegLinetoHorizontalRel; +} + +interface SVGEllipseElement extends SVGElement, SVGStylable, SVGTransformable, SVGLangSpace, SVGTests, SVGExternalResourcesRequired { + ry: SVGAnimatedLength; + cx: SVGAnimatedLength; + rx: SVGAnimatedLength; + cy: SVGAnimatedLength; +} +declare var SVGEllipseElement: { + prototype: SVGEllipseElement; + new (): SVGEllipseElement; +} + +interface SVGAElement extends SVGElement, SVGStylable, SVGTransformable, SVGLangSpace, SVGTests, SVGExternalResourcesRequired, SVGURIReference { + target: SVGAnimatedString; +} +declare var SVGAElement: { + prototype: SVGAElement; + new (): SVGAElement; +} + +interface SVGStylable { + className: SVGAnimatedString; + style: CSSStyleDeclaration; +} + +interface SVGTransformable extends SVGLocatable { + transform: SVGAnimatedTransformList; +} + +interface HTMLFrameSetElement extends HTMLElement { + ononline: (ev: Event) => any; + addEventListener(type: "online", listener: (ev: Event) => any, useCapture?: boolean): void; + borderColor: any; + rows: string; + cols: string; + onblur: (ev: FocusEvent) => any; + addEventListener(type: "blur", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + frameSpacing: any; + onfocus: (ev: FocusEvent) => any; + addEventListener(type: "focus", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + onmessage: (ev: MessageEvent) => any; + addEventListener(type: "message", listener: (ev: MessageEvent) => any, useCapture?: boolean): void; + onerror: (ev: Event) => any; + addEventListener(type: "error", listener: (ev: Event) => any, useCapture?: boolean): void; + frameBorder: string; + onresize: (ev: UIEvent) => any; + addEventListener(type: "resize", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + name: string; + onafterprint: (ev: Event) => any; + addEventListener(type: "afterprint", listener: (ev: Event) => any, useCapture?: boolean): void; + onbeforeprint: (ev: Event) => any; + addEventListener(type: "beforeprint", listener: (ev: Event) => any, useCapture?: boolean): void; + onoffline: (ev: Event) => any; + addEventListener(type: "offline", listener: (ev: Event) => any, useCapture?: boolean): void; + border: string; + onunload: (ev: Event) => any; + addEventListener(type: "unload", listener: (ev: Event) => any, useCapture?: boolean): void; + onhashchange: (ev: Event) => any; + addEventListener(type: "hashchange", listener: (ev: Event) => any, useCapture?: boolean): void; + onload: (ev: Event) => any; + addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; + onbeforeunload: (ev: BeforeUnloadEvent) => any; + addEventListener(type: "beforeunload", listener: (ev: BeforeUnloadEvent) => any, useCapture?: boolean): void; + onstorage: (ev: StorageEvent) => any; + addEventListener(type: "storage", listener: (ev: StorageEvent) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; +} +declare var HTMLFrameSetElement: { + prototype: HTMLFrameSetElement; + new (): HTMLFrameSetElement; +} + +interface Screen { + width: number; + deviceXDPI: number; + fontSmoothingEnabled: boolean; + bufferDepth: number; + logicalXDPI: number; + systemXDPI: number; + availHeight: number; + height: number; + logicalYDPI: number; + systemYDPI: number; + updateInterval: number; + colorDepth: number; + availWidth: number; + deviceYDPI: number; + pixelDepth: number; +} +declare var Screen: { + prototype: Screen; + new (): Screen; +} + +interface Coordinates { + altitudeAccuracy: number; + longitude: number; + latitude: number; + speed: number; + heading: number; + altitude: number; + accuracy: number; +} +declare var Coordinates: { + prototype: Coordinates; + new (): Coordinates; +} + +interface NavigatorGeolocation { + geolocation: Geolocation; +} + +interface NavigatorContentUtils { +} + +interface EventListener { + (evt: Event): void; +} + +interface SVGLangSpace { + xmllang: string; + xmlspace: string; +} + +interface DataTransfer { + effectAllowed: string; + dropEffect: string; + clearData(format?: string): boolean; + setData(format: string, data: string): boolean; + getData(format: string): string; +} +declare var DataTransfer: { + prototype: DataTransfer; + new (): DataTransfer; +} + +interface FocusEvent extends UIEvent { + relatedTarget: EventTarget; + initFocusEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: Window, detailArg: number, relatedTargetArg: EventTarget): void; +} +declare var FocusEvent: { + prototype: FocusEvent; + new (): FocusEvent; +} + +interface Range { + startOffset: number; + collapsed: boolean; + endOffset: number; + startContainer: Node; + endContainer: Node; + commonAncestorContainer: Node; + setStart(refNode: Node, offset: number): void; + setEndBefore(refNode: Node): void; + setStartBefore(refNode: Node): void; + selectNode(refNode: Node): void; + detach(): void; + getBoundingClientRect(): ClientRect; + toString(): string; + compareBoundaryPoints(how: number, sourceRange: Range): number; + insertNode(newNode: Node): void; + collapse(toStart: boolean): void; + selectNodeContents(refNode: Node): void; + cloneContents(): DocumentFragment; + setEnd(refNode: Node, offset: number): void; + cloneRange(): Range; + getClientRects(): ClientRectList; + surroundContents(newParent: Node): void; + deleteContents(): void; + setStartAfter(refNode: Node): void; + extractContents(): DocumentFragment; + setEndAfter(refNode: Node): void; + END_TO_END: number; + START_TO_START: number; + START_TO_END: number; + END_TO_START: number; +} +declare var Range: { + prototype: Range; + new (): Range; + END_TO_END: number; + START_TO_START: number; + START_TO_END: number; + END_TO_START: number; +} + +interface SVGPoint { + y: number; + x: number; + matrixTransform(matrix: SVGMatrix): SVGPoint; +} +declare var SVGPoint: { + prototype: SVGPoint; + new (): SVGPoint; +} + +interface MSPluginsCollection { + length: number; + refresh(reload?: boolean): void; +} +declare var MSPluginsCollection: { + prototype: MSPluginsCollection; + new (): MSPluginsCollection; +} + +interface SVGAnimatedNumberList { + animVal: SVGNumberList; + baseVal: SVGNumberList; +} +declare var SVGAnimatedNumberList: { + prototype: SVGAnimatedNumberList; + new (): SVGAnimatedNumberList; +} + +interface SVGSVGElement extends SVGElement, SVGStylable, SVGZoomAndPan, DocumentEvent, SVGLangSpace, SVGLocatable, SVGTests, SVGFitToViewBox, SVGExternalResourcesRequired { + width: SVGAnimatedLength; + x: SVGAnimatedLength; + contentStyleType: string; + onzoom: (ev: any) => any; + addEventListener(type: "zoom", listener: (ev: any) => any, useCapture?: boolean): void; + y: SVGAnimatedLength; + viewport: SVGRect; + onerror: (ev: Event) => any; + addEventListener(type: "error", listener: (ev: Event) => any, useCapture?: boolean): void; + pixelUnitToMillimeterY: number; + onresize: (ev: UIEvent) => any; + addEventListener(type: "resize", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + screenPixelToMillimeterY: number; + height: SVGAnimatedLength; + onabort: (ev: UIEvent) => any; + addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + contentScriptType: string; + pixelUnitToMillimeterX: number; + currentTranslate: SVGPoint; + onunload: (ev: Event) => any; + addEventListener(type: "unload", listener: (ev: Event) => any, useCapture?: boolean): void; + currentScale: number; + onscroll: (ev: UIEvent) => any; + addEventListener(type: "scroll", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + screenPixelToMillimeterX: number; + setCurrentTime(seconds: number): void; + createSVGLength(): SVGLength; + getIntersectionList(rect: SVGRect, referenceElement: SVGElement): NodeList; + unpauseAnimations(): void; + createSVGRect(): SVGRect; + checkIntersection(element: SVGElement, rect: SVGRect): boolean; + unsuspendRedrawAll(): void; + pauseAnimations(): void; + suspendRedraw(maxWaitMilliseconds: number): number; + deselectAll(): void; + createSVGAngle(): SVGAngle; + getEnclosureList(rect: SVGRect, referenceElement: SVGElement): NodeList; + createSVGTransform(): SVGTransform; + unsuspendRedraw(suspendHandleID: number): void; + forceRedraw(): void; + getCurrentTime(): number; + checkEnclosure(element: SVGElement, rect: SVGRect): boolean; + createSVGMatrix(): SVGMatrix; + createSVGPoint(): SVGPoint; + createSVGNumber(): SVGNumber; + createSVGTransformFromMatrix(matrix: SVGMatrix): SVGTransform; + getComputedStyle(elt: Element, pseudoElt?: string): CSSStyleDeclaration; + getElementById(elementId: string): Element; + addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; +} +declare var SVGSVGElement: { + prototype: SVGSVGElement; + new (): SVGSVGElement; +} + +interface HTMLLabelElement extends HTMLElement, MSDataBindingExtensions { + htmlFor: string; + form: HTMLFormElement; +} +declare var HTMLLabelElement: { + prototype: HTMLLabelElement; + new (): HTMLLabelElement; +} + +interface MSResourceMetadata { + protocol: string; + fileSize: string; + fileUpdatedDate: string; + nameProp: string; + fileCreatedDate: string; + fileModifiedDate: string; + mimeType: string; +} + +interface HTMLLegendElement extends HTMLElement, MSDataBindingExtensions { + align: string; + form: HTMLFormElement; +} +declare var HTMLLegendElement: { + prototype: HTMLLegendElement; + new (): HTMLLegendElement; +} + +interface HTMLDirectoryElement extends HTMLElement, DOML2DeprecatedListSpaceReduction, DOML2DeprecatedListNumberingAndBulletStyle { +} +declare var HTMLDirectoryElement: { + prototype: HTMLDirectoryElement; + new (): HTMLDirectoryElement; +} + +interface SVGAnimatedInteger { + animVal: number; + baseVal: number; +} +declare var SVGAnimatedInteger: { + prototype: SVGAnimatedInteger; + new (): SVGAnimatedInteger; +} + +interface SVGTextElement extends SVGTextPositioningElement, SVGTransformable { +} +declare var SVGTextElement: { + prototype: SVGTextElement; + new (): SVGTextElement; +} + +interface SVGTSpanElement extends SVGTextPositioningElement { +} +declare var SVGTSpanElement: { + prototype: SVGTSpanElement; + new (): SVGTSpanElement; +} + +interface HTMLLIElement extends HTMLElement, DOML2DeprecatedListNumberingAndBulletStyle { + value: number; +} +declare var HTMLLIElement: { + prototype: HTMLLIElement; + new (): HTMLLIElement; +} + +interface SVGPathSegLinetoVerticalAbs extends SVGPathSeg { + y: number; +} +declare var SVGPathSegLinetoVerticalAbs: { + prototype: SVGPathSegLinetoVerticalAbs; + new (): SVGPathSegLinetoVerticalAbs; +} + +interface MSStorageExtensions { + remainingSpace: number; +} + +interface SVGStyleElement extends SVGElement, SVGLangSpace { + media: string; + type: string; + title: string; +} +declare var SVGStyleElement: { + prototype: SVGStyleElement; + new (): SVGStyleElement; +} + +interface MSCurrentStyleCSSProperties extends MSCSSProperties { + blockDirection: string; + clipBottom: string; + clipLeft: string; + clipRight: string; + clipTop: string; + hasLayout: string; +} +declare var MSCurrentStyleCSSProperties: { + prototype: MSCurrentStyleCSSProperties; + new (): MSCurrentStyleCSSProperties; +} + +interface MSHTMLCollectionExtensions { + urns(urn: any): Object; + tags(tagName: any): Object; +} + +interface Storage extends MSStorageExtensions { + length: number; + getItem(key: string): any; + [key: string]: any; + setItem(key: string, data: string): void; + clear(): void; + removeItem(key: string): void; + key(index: number): string; + [index: number]: any; +} +declare var Storage: { + prototype: Storage; + new (): Storage; +} + +interface HTMLIFrameElement extends HTMLElement, GetSVGDocument, MSDataBindingExtensions { + width: string; + scrolling: string; + marginHeight: string; + marginWidth: string; + frameSpacing: any; + frameBorder: string; + noResize: boolean; + vspace: number; + contentWindow: Window; + align: string; + src: string; + name: string; + height: string; + border: string; + contentDocument: Document; + hspace: number; + longDesc: string; + security: any; + onload: (ev: Event) => any; + addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; +} +declare var HTMLIFrameElement: { + prototype: HTMLIFrameElement; + new (): HTMLIFrameElement; +} + +interface TextRangeCollection { + length: number; + item(index: number): TextRange; + [index: number]: TextRange; +} +declare var TextRangeCollection: { + prototype: TextRangeCollection; + new (): TextRangeCollection; +} + +interface HTMLBodyElement extends HTMLElement, DOML2DeprecatedBackgroundStyle, DOML2DeprecatedBackgroundColorStyle { + scroll: string; + ononline: (ev: Event) => any; + addEventListener(type: "online", listener: (ev: Event) => any, useCapture?: boolean): void; + onblur: (ev: FocusEvent) => any; + addEventListener(type: "blur", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + noWrap: boolean; + onfocus: (ev: FocusEvent) => any; + addEventListener(type: "focus", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + onmessage: (ev: MessageEvent) => any; + addEventListener(type: "message", listener: (ev: MessageEvent) => any, useCapture?: boolean): void; + text: any; + onerror: (ev: Event) => any; + addEventListener(type: "error", listener: (ev: Event) => any, useCapture?: boolean): void; + bgProperties: string; + onresize: (ev: UIEvent) => any; + addEventListener(type: "resize", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + link: any; + aLink: any; + bottomMargin: any; + topMargin: any; + onafterprint: (ev: Event) => any; + addEventListener(type: "afterprint", listener: (ev: Event) => any, useCapture?: boolean): void; + vLink: any; + onbeforeprint: (ev: Event) => any; + addEventListener(type: "beforeprint", listener: (ev: Event) => any, useCapture?: boolean): void; + onoffline: (ev: Event) => any; + addEventListener(type: "offline", listener: (ev: Event) => any, useCapture?: boolean): void; + onunload: (ev: Event) => any; + addEventListener(type: "unload", listener: (ev: Event) => any, useCapture?: boolean): void; + onhashchange: (ev: Event) => any; + addEventListener(type: "hashchange", listener: (ev: Event) => any, useCapture?: boolean): void; + onload: (ev: Event) => any; + addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; + rightMargin: any; + onbeforeunload: (ev: BeforeUnloadEvent) => any; + addEventListener(type: "beforeunload", listener: (ev: BeforeUnloadEvent) => any, useCapture?: boolean): void; + leftMargin: any; + onstorage: (ev: StorageEvent) => any; + addEventListener(type: "storage", listener: (ev: StorageEvent) => any, useCapture?: boolean): void; + createTextRange(): TextRange; + addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; +} +declare var HTMLBodyElement: { + prototype: HTMLBodyElement; + new (): HTMLBodyElement; +} + +interface DocumentType extends Node { + name: string; + notations: NamedNodeMap; + systemId: string; + internalSubset: string; + entities: NamedNodeMap; + publicId: string; +} +declare var DocumentType: { + prototype: DocumentType; + new (): DocumentType; +} + +interface SVGRadialGradientElement extends SVGGradientElement { + cx: SVGAnimatedLength; + r: SVGAnimatedLength; + cy: SVGAnimatedLength; + fx: SVGAnimatedLength; + fy: SVGAnimatedLength; +} +declare var SVGRadialGradientElement: { + prototype: SVGRadialGradientElement; + new (): SVGRadialGradientElement; +} + +interface MutationEvent extends Event { + newValue: string; + attrChange: number; + attrName: string; + prevValue: string; + relatedNode: Node; + initMutationEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, relatedNodeArg: Node, prevValueArg: string, newValueArg: string, attrNameArg: string, attrChangeArg: number): void; + MODIFICATION: number; + REMOVAL: number; + ADDITION: number; +} +declare var MutationEvent: { + prototype: MutationEvent; + new (): MutationEvent; + MODIFICATION: number; + REMOVAL: number; + ADDITION: number; +} + +interface DragEvent extends MouseEvent { + dataTransfer: DataTransfer; + initDragEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: Window, detailArg: number, screenXArg: number, screenYArg: number, clientXArg: number, clientYArg: number, ctrlKeyArg: boolean, altKeyArg: boolean, shiftKeyArg: boolean, metaKeyArg: boolean, buttonArg: number, relatedTargetArg: EventTarget, dataTransferArg: DataTransfer): void; +} +declare var DragEvent: { + prototype: DragEvent; + new (): DragEvent; +} + +interface HTMLTableSectionElement extends HTMLElement, HTMLTableAlignment, DOML2DeprecatedBackgroundColorStyle { + align: string; + rows: HTMLCollection; + deleteRow(index?: number): void; + moveRow(indexFrom?: number, indexTo?: number): Object; + insertRow(index?: number): HTMLElement; +} +declare var HTMLTableSectionElement: { + prototype: HTMLTableSectionElement; + new (): HTMLTableSectionElement; +} + +interface DOML2DeprecatedListNumberingAndBulletStyle { + type: string; +} + +interface HTMLInputElement extends HTMLElement, MSDataBindingExtensions { + width: string; + status: boolean; + form: HTMLFormElement; + selectionStart: number; + indeterminate: boolean; + readOnly: boolean; + size: number; + loop: number; + selectionEnd: number; + vrml: string; + lowsrc: string; + vspace: number; + accept: string; + alt: string; + defaultChecked: boolean; + align: string; + value: string; + src: string; + name: string; + useMap: string; + height: string; + border: string; + dynsrc: string; + checked: boolean; + hspace: number; + maxLength: number; + type: string; + defaultValue: string; + complete: boolean; + start: string; + createTextRange(): TextRange; + setSelectionRange(start: number, end: number): void; + select(): void; +} +declare var HTMLInputElement: { + prototype: HTMLInputElement; + new (): HTMLInputElement; +} + +interface HTMLAnchorElement extends HTMLElement, MSDataBindingExtensions { + rel: string; + protocol: string; + search: string; + coords: string; + hostname: string; + pathname: string; + Methods: string; + target: string; + protocolLong: string; + href: string; + name: string; + charset: string; + hreflang: string; + port: string; + host: string; + hash: string; + nameProp: string; + urn: string; + rev: string; + shape: string; + type: string; + mimeType: string; + toString(): string; +} +declare var HTMLAnchorElement: { + prototype: HTMLAnchorElement; + new (): HTMLAnchorElement; +} + +interface HTMLParamElement extends HTMLElement { + value: string; + name: string; + type: string; + valueType: string; +} +declare var HTMLParamElement: { + prototype: HTMLParamElement; + new (): HTMLParamElement; +} + +interface SVGImageElement extends SVGElement, SVGStylable, SVGTransformable, SVGLangSpace, SVGTests, SVGExternalResourcesRequired, SVGURIReference { + y: SVGAnimatedLength; + width: SVGAnimatedLength; + preserveAspectRatio: SVGAnimatedPreserveAspectRatio; + x: SVGAnimatedLength; + height: SVGAnimatedLength; +} +declare var SVGImageElement: { + prototype: SVGImageElement; + new (): SVGImageElement; +} + +interface SVGAnimatedNumber { + animVal: number; + baseVal: number; +} +declare var SVGAnimatedNumber: { + prototype: SVGAnimatedNumber; + new (): SVGAnimatedNumber; +} + +interface PerformanceTiming { + redirectStart: number; + domainLookupEnd: number; + responseStart: number; + domComplete: number; + domainLookupStart: number; + loadEventStart: number; + msFirstPaint: number; + unloadEventEnd: number; + fetchStart: number; + requestStart: number; + domInteractive: number; + navigationStart: number; + connectEnd: number; + loadEventEnd: number; + connectStart: number; + responseEnd: number; + domLoading: number; + redirectEnd: number; + unloadEventStart: number; + domContentLoadedEventStart: number; + domContentLoadedEventEnd: number; + toJSON(): any; +} +declare var PerformanceTiming: { + prototype: PerformanceTiming; + new (): PerformanceTiming; +} + +interface HTMLPreElement extends HTMLElement, DOML2DeprecatedTextFlowControl { + width: number; + cite: string; +} +declare var HTMLPreElement: { + prototype: HTMLPreElement; + new (): HTMLPreElement; +} + +interface EventException { + code: number; + message: string; + toString(): string; + DISPATCH_REQUEST_ERR: number; + UNSPECIFIED_EVENT_TYPE_ERR: number; +} +declare var EventException: { + prototype: EventException; + new (): EventException; + DISPATCH_REQUEST_ERR: number; + UNSPECIFIED_EVENT_TYPE_ERR: number; +} + +interface MSNavigatorDoNotTrack { + msDoNotTrack: string; +} + +interface NavigatorOnLine { + onLine: boolean; +} + +interface WindowLocalStorage { + localStorage: Storage; +} + +interface SVGMetadataElement extends SVGElement { +} +declare var SVGMetadataElement: { + prototype: SVGMetadataElement; + new (): SVGMetadataElement; +} + +interface SVGPathSegArcRel extends SVGPathSeg { + y: number; + sweepFlag: boolean; + r2: number; + x: number; + angle: number; + r1: number; + largeArcFlag: boolean; +} +declare var SVGPathSegArcRel: { + prototype: SVGPathSegArcRel; + new (): SVGPathSegArcRel; +} + +interface SVGPathSegMovetoAbs extends SVGPathSeg { + y: number; + x: number; +} +declare var SVGPathSegMovetoAbs: { + prototype: SVGPathSegMovetoAbs; + new (): SVGPathSegMovetoAbs; +} + +interface SVGStringList { + numberOfItems: number; + replaceItem(newItem: string, index: number): string; + getItem(index: number): string; + clear(): void; + appendItem(newItem: string): string; + initialize(newItem: string): string; + removeItem(index: number): string; + insertItemBefore(newItem: string, index: number): string; +} +declare var SVGStringList: { + prototype: SVGStringList; + new (): SVGStringList; +} + +interface XDomainRequest { + timeout: number; + onerror: (ev: Event) => any; + addEventListener(type: "error", listener: (ev: Event) => any, useCapture?: boolean): void; + onload: (ev: Event) => any; + addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; + onprogress: (ev: any) => any; + addEventListener(type: "progress", listener: (ev: any) => any, useCapture?: boolean): void; + ontimeout: (ev: Event) => any; + addEventListener(type: "timeout", listener: (ev: Event) => any, useCapture?: boolean): void; + responseText: string; + contentType: string; + open(method: string, url: string): void; + create(): XDomainRequest; + abort(): void; + send(data?: any): void; + addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; +} +declare var XDomainRequest: { + prototype: XDomainRequest; + new (): XDomainRequest; +} + +interface DOML2DeprecatedBackgroundColorStyle { + bgColor: any; +} + +interface ElementTraversal { + childElementCount: number; + previousElementSibling: Element; + lastElementChild: Element; + nextElementSibling: Element; + firstElementChild: Element; +} + +interface SVGLength { + valueAsString: string; + valueInSpecifiedUnits: number; + value: number; + unitType: number; + newValueSpecifiedUnits(unitType: number, valueInSpecifiedUnits: number): void; + convertToSpecifiedUnits(unitType: number): void; + SVG_LENGTHTYPE_NUMBER: number; + SVG_LENGTHTYPE_CM: number; + SVG_LENGTHTYPE_PC: number; + SVG_LENGTHTYPE_PERCENTAGE: number; + SVG_LENGTHTYPE_MM: number; + SVG_LENGTHTYPE_PT: number; + SVG_LENGTHTYPE_IN: number; + SVG_LENGTHTYPE_EMS: number; + SVG_LENGTHTYPE_PX: number; + SVG_LENGTHTYPE_UNKNOWN: number; + SVG_LENGTHTYPE_EXS: number; +} +declare var SVGLength: { + prototype: SVGLength; + new (): SVGLength; + SVG_LENGTHTYPE_NUMBER: number; + SVG_LENGTHTYPE_CM: number; + SVG_LENGTHTYPE_PC: number; + SVG_LENGTHTYPE_PERCENTAGE: number; + SVG_LENGTHTYPE_MM: number; + SVG_LENGTHTYPE_PT: number; + SVG_LENGTHTYPE_IN: number; + SVG_LENGTHTYPE_EMS: number; + SVG_LENGTHTYPE_PX: number; + SVG_LENGTHTYPE_UNKNOWN: number; + SVG_LENGTHTYPE_EXS: number; +} + +interface SVGPolygonElement extends SVGElement, SVGStylable, SVGTransformable, SVGLangSpace, SVGAnimatedPoints, SVGTests, SVGExternalResourcesRequired { +} +declare var SVGPolygonElement: { + prototype: SVGPolygonElement; + new (): SVGPolygonElement; +} + +interface HTMLPhraseElement extends HTMLElement { + dateTime: string; + cite: string; +} +declare var HTMLPhraseElement: { + prototype: HTMLPhraseElement; + new (): HTMLPhraseElement; +} + +interface NavigatorStorageUtils { +} + +interface SVGPathSegCurvetoCubicRel extends SVGPathSeg { + y: number; + y1: number; + x2: number; + x: number; + x1: number; + y2: number; +} +declare var SVGPathSegCurvetoCubicRel: { + prototype: SVGPathSegCurvetoCubicRel; + new (): SVGPathSegCurvetoCubicRel; +} + +interface MSEventObj extends Event { + nextPage: string; + keyCode: number; + toElement: Element; + returnValue: any; + dataFld: string; + y: number; + dataTransfer: DataTransfer; + propertyName: string; + url: string; + offsetX: number; + recordset: Object; + screenX: number; + buttonID: number; + wheelDelta: number; + reason: number; + origin: string; + data: string; + srcFilter: Object; + boundElements: HTMLCollection; + cancelBubble: boolean; + altLeft: boolean; + behaviorCookie: number; + bookmarks: BookmarkCollection; + type: string; + repeat: boolean; + srcElement: Element; + source: Window; + fromElement: Element; + offsetY: number; + x: number; + behaviorPart: number; + qualifier: string; + altKey: boolean; + ctrlKey: boolean; + clientY: number; + shiftKey: boolean; + shiftLeft: boolean; + contentOverflow: boolean; + screenY: number; + ctrlLeft: boolean; + button: number; + srcUrn: string; + clientX: number; + actionURL: string; + getAttribute(strAttributeName: string, lFlags?: number): any; + setAttribute(strAttributeName: string, AttributeValue: any, lFlags?: number): void; + removeAttribute(strAttributeName: string, lFlags?: number): boolean; +} +declare var MSEventObj: { + prototype: MSEventObj; + new (): MSEventObj; +} + +interface SVGTextContentElement extends SVGElement, SVGStylable, SVGLangSpace, SVGTests, SVGExternalResourcesRequired { + textLength: SVGAnimatedLength; + lengthAdjust: SVGAnimatedEnumeration; + getCharNumAtPosition(point: SVGPoint): number; + getStartPositionOfChar(charnum: number): SVGPoint; + getExtentOfChar(charnum: number): SVGRect; + getComputedTextLength(): number; + getSubStringLength(charnum: number, nchars: number): number; + selectSubString(charnum: number, nchars: number): void; + getNumberOfChars(): number; + getRotationOfChar(charnum: number): number; + getEndPositionOfChar(charnum: number): SVGPoint; + LENGTHADJUST_SPACING: number; + LENGTHADJUST_SPACINGANDGLYPHS: number; + LENGTHADJUST_UNKNOWN: number; +} +declare var SVGTextContentElement: { + prototype: SVGTextContentElement; + new (): SVGTextContentElement; + LENGTHADJUST_SPACING: number; + LENGTHADJUST_SPACINGANDGLYPHS: number; + LENGTHADJUST_UNKNOWN: number; +} + +interface DOML2DeprecatedColorProperty { + color: string; +} + +interface HTMLCanvasElement extends HTMLElement { + width: number; + height: number; + toDataURL(type?: string, ...args: any[]): string; + getContext(contextId: string, ...args: any[]): any; + getContext(contextId: "2d"): CanvasRenderingContext2D; +} +declare var HTMLCanvasElement: { + prototype: HTMLCanvasElement; + new (): HTMLCanvasElement; +} + +interface Location { + hash: string; + protocol: string; + search: string; + href: string; + hostname: string; + port: string; + pathname: string; + host: string; + reload(flag?: boolean): void; + replace(url: string): void; + assign(url: string): void; + toString(): string; +} +declare var Location: { + prototype: Location; + new (): Location; +} + +interface HTMLTitleElement extends HTMLElement { + text: string; +} +declare var HTMLTitleElement: { + prototype: HTMLTitleElement; + new (): HTMLTitleElement; +} + +interface HTMLStyleElement extends HTMLElement, LinkStyle { + media: string; + type: string; +} +declare var HTMLStyleElement: { + prototype: HTMLStyleElement; + new (): HTMLStyleElement; +} + +interface PerformanceEntry { + name: string; + startTime: number; + duration: number; + entryType: string; +} +declare var PerformanceEntry: { + prototype: PerformanceEntry; + new (): PerformanceEntry; +} + +interface SVGTransform { + type: number; + angle: number; + matrix: SVGMatrix; + setTranslate(tx: number, ty: number): void; + setScale(sx: number, sy: number): void; + setMatrix(matrix: SVGMatrix): void; + setSkewY(angle: number): void; + setRotate(angle: number, cx: number, cy: number): void; + setSkewX(angle: number): void; + SVG_TRANSFORM_SKEWX: number; + SVG_TRANSFORM_UNKNOWN: number; + SVG_TRANSFORM_SCALE: number; + SVG_TRANSFORM_TRANSLATE: number; + SVG_TRANSFORM_MATRIX: number; + SVG_TRANSFORM_ROTATE: number; + SVG_TRANSFORM_SKEWY: number; +} +declare var SVGTransform: { + prototype: SVGTransform; + new (): SVGTransform; + SVG_TRANSFORM_SKEWX: number; + SVG_TRANSFORM_UNKNOWN: number; + SVG_TRANSFORM_SCALE: number; + SVG_TRANSFORM_TRANSLATE: number; + SVG_TRANSFORM_MATRIX: number; + SVG_TRANSFORM_ROTATE: number; + SVG_TRANSFORM_SKEWY: number; +} + +interface UIEvent extends Event { + detail: number; + view: Window; + initUIEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: Window, detailArg: number): void; +} +declare var UIEvent: { + prototype: UIEvent; + new (): UIEvent; +} + +interface SVGURIReference { + href: SVGAnimatedString; +} + +interface SVGPathSeg { + pathSegType: number; + pathSegTypeAsLetter: string; + PATHSEG_MOVETO_REL: number; + PATHSEG_LINETO_VERTICAL_REL: number; + PATHSEG_CURVETO_CUBIC_SMOOTH_ABS: number; + PATHSEG_CURVETO_QUADRATIC_REL: number; + PATHSEG_CURVETO_CUBIC_ABS: number; + PATHSEG_LINETO_HORIZONTAL_ABS: number; + PATHSEG_CURVETO_QUADRATIC_ABS: number; + PATHSEG_LINETO_ABS: number; + PATHSEG_CLOSEPATH: number; + PATHSEG_LINETO_HORIZONTAL_REL: number; + PATHSEG_CURVETO_CUBIC_SMOOTH_REL: number; + PATHSEG_LINETO_REL: number; + PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS: number; + PATHSEG_ARC_REL: number; + PATHSEG_CURVETO_CUBIC_REL: number; + PATHSEG_UNKNOWN: number; + PATHSEG_LINETO_VERTICAL_ABS: number; + PATHSEG_ARC_ABS: number; + PATHSEG_MOVETO_ABS: number; + PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL: number; +} +declare var SVGPathSeg: { + prototype: SVGPathSeg; + new (): SVGPathSeg; + PATHSEG_MOVETO_REL: number; + PATHSEG_LINETO_VERTICAL_REL: number; + PATHSEG_CURVETO_CUBIC_SMOOTH_ABS: number; + PATHSEG_CURVETO_QUADRATIC_REL: number; + PATHSEG_CURVETO_CUBIC_ABS: number; + PATHSEG_LINETO_HORIZONTAL_ABS: number; + PATHSEG_CURVETO_QUADRATIC_ABS: number; + PATHSEG_LINETO_ABS: number; + PATHSEG_CLOSEPATH: number; + PATHSEG_LINETO_HORIZONTAL_REL: number; + PATHSEG_CURVETO_CUBIC_SMOOTH_REL: number; + PATHSEG_LINETO_REL: number; + PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS: number; + PATHSEG_ARC_REL: number; + PATHSEG_CURVETO_CUBIC_REL: number; + PATHSEG_UNKNOWN: number; + PATHSEG_LINETO_VERTICAL_ABS: number; + PATHSEG_ARC_ABS: number; + PATHSEG_MOVETO_ABS: number; + PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL: number; +} + +interface WheelEvent extends MouseEvent { + deltaZ: number; + deltaX: number; + deltaMode: number; + deltaY: number; + initWheelEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: Window, detailArg: number, screenXArg: number, screenYArg: number, clientXArg: number, clientYArg: number, buttonArg: number, relatedTargetArg: EventTarget, modifiersListArg: string, deltaXArg: number, deltaYArg: number, deltaZArg: number, deltaMode: number): void; + DOM_DELTA_PIXEL: number; + DOM_DELTA_LINE: number; + DOM_DELTA_PAGE: number; +} +declare var WheelEvent: { + prototype: WheelEvent; + new (): WheelEvent; + DOM_DELTA_PIXEL: number; + DOM_DELTA_LINE: number; + DOM_DELTA_PAGE: number; +} + +interface MSEventAttachmentTarget { + attachEvent(event: string, listener: EventListener): boolean; + detachEvent(event: string, listener: EventListener): void; +} + +interface SVGNumber { + value: number; +} +declare var SVGNumber: { + prototype: SVGNumber; + new (): SVGNumber; +} + +interface SVGPathElement extends SVGElement, SVGStylable, SVGAnimatedPathData, SVGTransformable, SVGLangSpace, SVGTests, SVGExternalResourcesRequired { + getPathSegAtLength(distance: number): number; + getPointAtLength(distance: number): SVGPoint; + createSVGPathSegCurvetoQuadraticAbs(x: number, y: number, x1: number, y1: number): SVGPathSegCurvetoQuadraticAbs; + createSVGPathSegLinetoRel(x: number, y: number): SVGPathSegLinetoRel; + createSVGPathSegCurvetoQuadraticRel(x: number, y: number, x1: number, y1: number): SVGPathSegCurvetoQuadraticRel; + createSVGPathSegCurvetoCubicAbs(x: number, y: number, x1: number, y1: number, x2: number, y2: number): SVGPathSegCurvetoCubicAbs; + createSVGPathSegLinetoAbs(x: number, y: number): SVGPathSegLinetoAbs; + createSVGPathSegClosePath(): SVGPathSegClosePath; + createSVGPathSegCurvetoCubicRel(x: number, y: number, x1: number, y1: number, x2: number, y2: number): SVGPathSegCurvetoCubicRel; + createSVGPathSegCurvetoQuadraticSmoothRel(x: number, y: number): SVGPathSegCurvetoQuadraticSmoothRel; + createSVGPathSegMovetoRel(x: number, y: number): SVGPathSegMovetoRel; + createSVGPathSegCurvetoCubicSmoothAbs(x: number, y: number, x2: number, y2: number): SVGPathSegCurvetoCubicSmoothAbs; + createSVGPathSegMovetoAbs(x: number, y: number): SVGPathSegMovetoAbs; + createSVGPathSegLinetoVerticalRel(y: number): SVGPathSegLinetoVerticalRel; + createSVGPathSegArcRel(x: number, y: number, r1: number, r2: number, angle: number, largeArcFlag: boolean, sweepFlag: boolean): SVGPathSegArcRel; + createSVGPathSegCurvetoQuadraticSmoothAbs(x: number, y: number): SVGPathSegCurvetoQuadraticSmoothAbs; + createSVGPathSegLinetoHorizontalRel(x: number): SVGPathSegLinetoHorizontalRel; + getTotalLength(): number; + createSVGPathSegCurvetoCubicSmoothRel(x: number, y: number, x2: number, y2: number): SVGPathSegCurvetoCubicSmoothRel; + createSVGPathSegLinetoHorizontalAbs(x: number): SVGPathSegLinetoHorizontalAbs; + createSVGPathSegLinetoVerticalAbs(y: number): SVGPathSegLinetoVerticalAbs; + createSVGPathSegArcAbs(x: number, y: number, r1: number, r2: number, angle: number, largeArcFlag: boolean, sweepFlag: boolean): SVGPathSegArcAbs; +} +declare var SVGPathElement: { + prototype: SVGPathElement; + new (): SVGPathElement; +} + +interface MSCompatibleInfo { + version: string; + userAgent: string; +} +declare var MSCompatibleInfo: { + prototype: MSCompatibleInfo; + new (): MSCompatibleInfo; +} + +interface Text extends CharacterData, MSNodeExtensions { + wholeText: string; + splitText(offset: number): Text; + replaceWholeText(content: string): Text; +} +declare var Text: { + prototype: Text; + new (): Text; +} + +interface SVGAnimatedRect { + animVal: SVGRect; + baseVal: SVGRect; +} +declare var SVGAnimatedRect: { + prototype: SVGAnimatedRect; + new (): SVGAnimatedRect; +} + +interface CSSNamespaceRule extends CSSRule { + namespaceURI: string; + prefix: string; +} +declare var CSSNamespaceRule: { + prototype: CSSNamespaceRule; + new (): CSSNamespaceRule; +} + +interface SVGPathSegList { + numberOfItems: number; + replaceItem(newItem: SVGPathSeg, index: number): SVGPathSeg; + getItem(index: number): SVGPathSeg; + clear(): void; + appendItem(newItem: SVGPathSeg): SVGPathSeg; + initialize(newItem: SVGPathSeg): SVGPathSeg; + removeItem(index: number): SVGPathSeg; + insertItemBefore(newItem: SVGPathSeg, index: number): SVGPathSeg; +} +declare var SVGPathSegList: { + prototype: SVGPathSegList; + new (): SVGPathSegList; +} + +interface HTMLUnknownElement extends HTMLElement, MSDataBindingRecordSetReadonlyExtensions { +} +declare var HTMLUnknownElement: { + prototype: HTMLUnknownElement; + new (): HTMLUnknownElement; +} + +interface HTMLAudioElement extends HTMLMediaElement { +} +declare var HTMLAudioElement: { + prototype: HTMLAudioElement; + new (): HTMLAudioElement; +} + +interface MSImageResourceExtensions { + dynsrc: string; + vrml: string; + lowsrc: string; + start: string; + loop: number; +} + +interface PositionError { + code: number; + message: string; + toString(): string; + POSITION_UNAVAILABLE: number; + PERMISSION_DENIED: number; + TIMEOUT: number; +} +declare var PositionError: { + prototype: PositionError; + new (): PositionError; + POSITION_UNAVAILABLE: number; + PERMISSION_DENIED: number; + TIMEOUT: number; +} + +interface HTMLTableCellElement extends HTMLElement, HTMLTableAlignment, DOML2DeprecatedBackgroundStyle, DOML2DeprecatedBackgroundColorStyle { + width: number; + headers: string; + cellIndex: number; + align: string; + borderColorLight: any; + colSpan: number; + borderColor: any; + axis: string; + height: any; + noWrap: boolean; + abbr: string; + rowSpan: number; + scope: string; + borderColorDark: any; +} +declare var HTMLTableCellElement: { + prototype: HTMLTableCellElement; + new (): HTMLTableCellElement; +} + +interface SVGElementInstance extends EventTarget { + previousSibling: SVGElementInstance; + parentNode: SVGElementInstance; + lastChild: SVGElementInstance; + nextSibling: SVGElementInstance; + childNodes: SVGElementInstanceList; + correspondingUseElement: SVGUseElement; + correspondingElement: SVGElement; + firstChild: SVGElementInstance; +} +declare var SVGElementInstance: { + prototype: SVGElementInstance; + new (): SVGElementInstance; +} + +interface MSNamespaceInfoCollection { + length: number; + add(namespace?: string, urn?: string, implementationUrl?: any): Object; + item(index: any): Object; + [index: string]: Object; +} +declare var MSNamespaceInfoCollection: { + prototype: MSNamespaceInfoCollection; + new (): MSNamespaceInfoCollection; +} + +interface SVGCircleElement extends SVGElement, SVGStylable, SVGTransformable, SVGLangSpace, SVGTests, SVGExternalResourcesRequired { + cx: SVGAnimatedLength; + r: SVGAnimatedLength; + cy: SVGAnimatedLength; +} +declare var SVGCircleElement: { + prototype: SVGCircleElement; + new (): SVGCircleElement; +} + +interface StyleSheetList { + length: number; + item(index?: number): StyleSheet; + [index: number]: StyleSheet; +} +declare var StyleSheetList: { + prototype: StyleSheetList; + new (): StyleSheetList; +} + +interface CSSImportRule extends CSSRule { + styleSheet: CSSStyleSheet; + href: string; + media: MediaList; +} +declare var CSSImportRule: { + prototype: CSSImportRule; + new (): CSSImportRule; +} + +interface CustomEvent extends Event { + detail: Object; + initCustomEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, detailArg: Object): void; +} +declare var CustomEvent: { + prototype: CustomEvent; + new (): CustomEvent; +} + +interface HTMLBaseFontElement extends HTMLElement, DOML2DeprecatedColorProperty { + face: string; + size: number; +} +declare var HTMLBaseFontElement: { + prototype: HTMLBaseFontElement; + new (): HTMLBaseFontElement; +} + +interface HTMLTextAreaElement extends HTMLElement, MSDataBindingExtensions { + value: string; + status: any; + form: HTMLFormElement; + name: string; + selectionStart: number; + rows: number; + cols: number; + readOnly: boolean; + wrap: string; + selectionEnd: number; + type: string; + defaultValue: string; + createTextRange(): TextRange; + setSelectionRange(start: number, end: number): void; + select(): void; +} +declare var HTMLTextAreaElement: { + prototype: HTMLTextAreaElement; + new (): HTMLTextAreaElement; +} + +interface Geolocation { + clearWatch(watchId: number): void; + getCurrentPosition(successCallback: PositionCallback, errorCallback?: PositionErrorCallback, options?: PositionOptions): void; + watchPosition(successCallback: PositionCallback, errorCallback?: PositionErrorCallback, options?: PositionOptions): number; +} +declare var Geolocation: { + prototype: Geolocation; + new (): Geolocation; +} + +interface DOML2DeprecatedMarginStyle { + vspace: number; + hspace: number; +} + +interface MSWindowModeless { + dialogTop: any; + dialogLeft: any; + dialogWidth: any; + dialogHeight: any; + menuArguments: any; +} + +interface DOML2DeprecatedAlignmentStyle { + align: string; +} + +interface HTMLMarqueeElement extends HTMLElement, MSDataBindingExtensions, DOML2DeprecatedBackgroundColorStyle { + width: string; + onbounce: (ev: Event) => any; + addEventListener(type: "bounce", listener: (ev: Event) => any, useCapture?: boolean): void; + vspace: number; + trueSpeed: boolean; + scrollAmount: number; + scrollDelay: number; + behavior: string; + height: string; + loop: number; + direction: string; + hspace: number; + onstart: (ev: Event) => any; + addEventListener(type: "start", listener: (ev: Event) => any, useCapture?: boolean): void; + onfinish: (ev: Event) => any; + addEventListener(type: "finish", listener: (ev: Event) => any, useCapture?: boolean): void; + stop(): void; + start(): void; + addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; +} +declare var HTMLMarqueeElement: { + prototype: HTMLMarqueeElement; + new (): HTMLMarqueeElement; +} + +interface SVGRect { + y: number; + width: number; + x: number; + height: number; +} +declare var SVGRect: { + prototype: SVGRect; + new (): SVGRect; +} + +interface MSNodeExtensions { + swapNode(otherNode: Node): Node; + removeNode(deep?: boolean): Node; + replaceNode(replacement: Node): Node; +} + +interface History { + length: number; + back(distance?: any): void; + forward(distance?: any): void; + go(delta?: any): void; +} +declare var History: { + prototype: History; + new (): History; +} + +interface SVGPathSegCurvetoCubicAbs extends SVGPathSeg { + y: number; + y1: number; + x2: number; + x: number; + x1: number; + y2: number; +} +declare var SVGPathSegCurvetoCubicAbs: { + prototype: SVGPathSegCurvetoCubicAbs; + new (): SVGPathSegCurvetoCubicAbs; +} + +interface SVGPathSegCurvetoQuadraticAbs extends SVGPathSeg { + y: number; + y1: number; + x: number; + x1: number; +} +declare var SVGPathSegCurvetoQuadraticAbs: { + prototype: SVGPathSegCurvetoQuadraticAbs; + new (): SVGPathSegCurvetoQuadraticAbs; +} + +interface TimeRanges { + length: number; + start(index: number): number; + end(index: number): number; +} +declare var TimeRanges: { + prototype: TimeRanges; + new (): TimeRanges; +} + +interface CSSRule { + cssText: string; + parentStyleSheet: CSSStyleSheet; + parentRule: CSSRule; + type: number; + IMPORT_RULE: number; + MEDIA_RULE: number; + STYLE_RULE: number; + NAMESPACE_RULE: number; + PAGE_RULE: number; + UNKNOWN_RULE: number; + FONT_FACE_RULE: number; + CHARSET_RULE: number; +} +declare var CSSRule: { + prototype: CSSRule; + new (): CSSRule; + IMPORT_RULE: number; + MEDIA_RULE: number; + STYLE_RULE: number; + NAMESPACE_RULE: number; + PAGE_RULE: number; + UNKNOWN_RULE: number; + FONT_FACE_RULE: number; + CHARSET_RULE: number; +} + +interface SVGPathSegLinetoAbs extends SVGPathSeg { + y: number; + x: number; +} +declare var SVGPathSegLinetoAbs: { + prototype: SVGPathSegLinetoAbs; + new (): SVGPathSegLinetoAbs; +} + +interface HTMLModElement extends HTMLElement { + dateTime: string; + cite: string; +} +declare var HTMLModElement: { + prototype: HTMLModElement; + new (): HTMLModElement; +} + +interface SVGMatrix { + e: number; + c: number; + a: number; + b: number; + d: number; + f: number; + multiply(secondMatrix: SVGMatrix): SVGMatrix; + flipY(): SVGMatrix; + skewY(angle: number): SVGMatrix; + inverse(): SVGMatrix; + scaleNonUniform(scaleFactorX: number, scaleFactorY: number): SVGMatrix; + rotate(angle: number): SVGMatrix; + flipX(): SVGMatrix; + translate(x: number, y: number): SVGMatrix; + scale(scaleFactor: number): SVGMatrix; + rotateFromVector(x: number, y: number): SVGMatrix; + skewX(angle: number): SVGMatrix; +} +declare var SVGMatrix: { + prototype: SVGMatrix; + new (): SVGMatrix; +} + +interface MSPopupWindow { + document: Document; + isOpen: boolean; + show(x: number, y: number, w: number, h: number, element?: any): void; + hide(): void; +} +declare var MSPopupWindow: { + prototype: MSPopupWindow; + new (): MSPopupWindow; +} + +interface BeforeUnloadEvent extends Event { + returnValue: string; +} +declare var BeforeUnloadEvent: { + prototype: BeforeUnloadEvent; + new (): BeforeUnloadEvent; +} + +interface SVGUseElement extends SVGElement, SVGStylable, SVGTransformable, SVGLangSpace, SVGTests, SVGExternalResourcesRequired, SVGURIReference { + y: SVGAnimatedLength; + width: SVGAnimatedLength; + animatedInstanceRoot: SVGElementInstance; + instanceRoot: SVGElementInstance; + x: SVGAnimatedLength; + height: SVGAnimatedLength; +} +declare var SVGUseElement: { + prototype: SVGUseElement; + new (): SVGUseElement; +} + +interface Event { + timeStamp: number; + defaultPrevented: boolean; + isTrusted: boolean; + currentTarget: EventTarget; + cancelBubble: boolean; + target: EventTarget; + eventPhase: number; + cancelable: boolean; + type: string; + srcElement: Element; + bubbles: boolean; + initEvent(eventTypeArg: string, canBubbleArg: boolean, cancelableArg: boolean): void; + stopPropagation(): void; + stopImmediatePropagation(): void; + preventDefault(): void; + CAPTURING_PHASE: number; + AT_TARGET: number; + BUBBLING_PHASE: number; +} +declare var Event: { + prototype: Event; + new (): Event; + CAPTURING_PHASE: number; + AT_TARGET: number; + BUBBLING_PHASE: number; +} + +interface ImageData { + width: number; + data: number[]; + height: number; +} +declare var ImageData: { + prototype: ImageData; + new (): ImageData; +} + +interface HTMLTableColElement extends HTMLElement, HTMLTableAlignment { + width: any; + align: string; + span: number; +} +declare var HTMLTableColElement: { + prototype: HTMLTableColElement; + new (): HTMLTableColElement; +} + +interface SVGException { + code: number; + message: string; + toString(): string; + SVG_MATRIX_NOT_INVERTABLE: number; + SVG_WRONG_TYPE_ERR: number; + SVG_INVALID_VALUE_ERR: number; +} +declare var SVGException: { + prototype: SVGException; + new (): SVGException; + SVG_MATRIX_NOT_INVERTABLE: number; + SVG_WRONG_TYPE_ERR: number; + SVG_INVALID_VALUE_ERR: number; +} + +interface SVGLinearGradientElement extends SVGGradientElement { + y1: SVGAnimatedLength; + x2: SVGAnimatedLength; + x1: SVGAnimatedLength; + y2: SVGAnimatedLength; +} +declare var SVGLinearGradientElement: { + prototype: SVGLinearGradientElement; + new (): SVGLinearGradientElement; +} + +interface HTMLTableAlignment { + ch: string; + vAlign: string; + chOff: string; +} + +interface SVGAnimatedEnumeration { + animVal: number; + baseVal: number; +} +declare var SVGAnimatedEnumeration: { + prototype: SVGAnimatedEnumeration; + new (): SVGAnimatedEnumeration; +} + +interface DOML2DeprecatedSizeProperty { + size: number; +} + +interface HTMLUListElement extends HTMLElement, DOML2DeprecatedListSpaceReduction, DOML2DeprecatedListNumberingAndBulletStyle { +} +declare var HTMLUListElement: { + prototype: HTMLUListElement; + new (): HTMLUListElement; +} + +interface SVGRectElement extends SVGElement, SVGStylable, SVGTransformable, SVGLangSpace, SVGTests, SVGExternalResourcesRequired { + y: SVGAnimatedLength; + width: SVGAnimatedLength; + ry: SVGAnimatedLength; + rx: SVGAnimatedLength; + x: SVGAnimatedLength; + height: SVGAnimatedLength; +} +declare var SVGRectElement: { + prototype: SVGRectElement; + new (): SVGRectElement; +} + +interface ErrorEventHandler { + (event: Event, source: string, fileno: number, columnNumber: number): void; +} + +interface HTMLDivElement extends HTMLElement, MSDataBindingExtensions { + align: string; + noWrap: boolean; +} +declare var HTMLDivElement: { + prototype: HTMLDivElement; + new (): HTMLDivElement; +} + +interface DOML2DeprecatedBorderStyle { + border: string; +} + +interface NamedNodeMap { + length: number; + removeNamedItemNS(namespaceURI: string, localName: string): Attr; + item(index: number): Attr; + [index: number]: Attr; + removeNamedItem(name: string): Attr; + getNamedItem(name: string): Attr; + setNamedItem(arg: Attr): Attr; + getNamedItemNS(namespaceURI: string, localName: string): Attr; + setNamedItemNS(arg: Attr): Attr; +} +declare var NamedNodeMap: { + prototype: NamedNodeMap; + new (): NamedNodeMap; +} + +interface MediaList { + length: number; + mediaText: string; + deleteMedium(oldMedium: string): void; + appendMedium(newMedium: string): void; + item(index: number): string; + [index: number]: string; + toString(): string; +} +declare var MediaList: { + prototype: MediaList; + new (): MediaList; +} + +interface SVGPathSegCurvetoQuadraticSmoothAbs extends SVGPathSeg { + y: number; + x: number; +} +declare var SVGPathSegCurvetoQuadraticSmoothAbs: { + prototype: SVGPathSegCurvetoQuadraticSmoothAbs; + new (): SVGPathSegCurvetoQuadraticSmoothAbs; +} + +interface SVGPathSegCurvetoCubicSmoothRel extends SVGPathSeg { + y: number; + x2: number; + x: number; + y2: number; +} +declare var SVGPathSegCurvetoCubicSmoothRel: { + prototype: SVGPathSegCurvetoCubicSmoothRel; + new (): SVGPathSegCurvetoCubicSmoothRel; +} + +interface SVGLengthList { + numberOfItems: number; + replaceItem(newItem: SVGLength, index: number): SVGLength; + getItem(index: number): SVGLength; + clear(): void; + appendItem(newItem: SVGLength): SVGLength; + initialize(newItem: SVGLength): SVGLength; + removeItem(index: number): SVGLength; + insertItemBefore(newItem: SVGLength, index: number): SVGLength; +} +declare var SVGLengthList: { + prototype: SVGLengthList; + new (): SVGLengthList; +} + +interface ProcessingInstruction extends Node { + target: string; + data: string; +} +declare var ProcessingInstruction: { + prototype: ProcessingInstruction; + new (): ProcessingInstruction; +} + +interface MSWindowExtensions { + status: string; + onmouseleave: (ev: MouseEvent) => any; + addEventListener(type: "mouseleave", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + screenLeft: number; + offscreenBuffering: any; + maxConnectionsPerServer: number; + onmouseenter: (ev: MouseEvent) => any; + addEventListener(type: "mouseenter", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + clipboardData: DataTransfer; + defaultStatus: string; + clientInformation: Navigator; + closed: boolean; + onhelp: (ev: Event) => any; + addEventListener(type: "help", listener: (ev: Event) => any, useCapture?: boolean): void; + external: External; + event: MSEventObj; + onfocusout: (ev: FocusEvent) => any; + addEventListener(type: "focusout", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + screenTop: number; + onfocusin: (ev: FocusEvent) => any; + addEventListener(type: "focusin", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + showModelessDialog(url?: string, argument?: any, options?: any): Window; + navigate(url: string): void; + resizeBy(x?: number, y?: number): void; + item(index: any): any; + resizeTo(x?: number, y?: number): void; + createPopup(arguments?: any): MSPopupWindow; + toStaticHTML(html: string): string; + execScript(code: string, language?: string): any; + msWriteProfilerMark(profilerMarkName: string): void; + moveTo(x?: number, y?: number): void; + moveBy(x?: number, y?: number): void; + showHelp(url: string, helpArg?: any, features?: string): void; + addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; +} + +interface MSBehaviorUrnsCollection { + length: number; + item(index: number): string; +} +declare var MSBehaviorUrnsCollection: { + prototype: MSBehaviorUrnsCollection; + new (): MSBehaviorUrnsCollection; +} + +interface CSSFontFaceRule extends CSSRule { + style: CSSStyleDeclaration; +} +declare var CSSFontFaceRule: { + prototype: CSSFontFaceRule; + new (): CSSFontFaceRule; +} + +interface DOML2DeprecatedBackgroundStyle { + background: string; +} + +interface TextEvent extends UIEvent { + inputMethod: number; + data: string; + locale: string; + initTextEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: Window, dataArg: string, inputMethod: number, locale: string): void; + DOM_INPUT_METHOD_KEYBOARD: number; + DOM_INPUT_METHOD_DROP: number; + DOM_INPUT_METHOD_IME: number; + DOM_INPUT_METHOD_SCRIPT: number; + DOM_INPUT_METHOD_VOICE: number; + DOM_INPUT_METHOD_UNKNOWN: number; + DOM_INPUT_METHOD_PASTE: number; + DOM_INPUT_METHOD_HANDWRITING: number; + DOM_INPUT_METHOD_OPTION: number; + DOM_INPUT_METHOD_MULTIMODAL: number; +} +declare var TextEvent: { + prototype: TextEvent; + new (): TextEvent; + DOM_INPUT_METHOD_KEYBOARD: number; + DOM_INPUT_METHOD_DROP: number; + DOM_INPUT_METHOD_IME: number; + DOM_INPUT_METHOD_SCRIPT: number; + DOM_INPUT_METHOD_VOICE: number; + DOM_INPUT_METHOD_UNKNOWN: number; + DOM_INPUT_METHOD_PASTE: number; + DOM_INPUT_METHOD_HANDWRITING: number; + DOM_INPUT_METHOD_OPTION: number; + DOM_INPUT_METHOD_MULTIMODAL: number; +} + +interface DocumentFragment extends Node, NodeSelector, MSEventAttachmentTarget, MSNodeExtensions { +} +declare var DocumentFragment: { + prototype: DocumentFragment; + new (): DocumentFragment; +} + +interface SVGPolylineElement extends SVGElement, SVGStylable, SVGTransformable, SVGLangSpace, SVGAnimatedPoints, SVGTests, SVGExternalResourcesRequired { +} +declare var SVGPolylineElement: { + prototype: SVGPolylineElement; + new (): SVGPolylineElement; +} + +interface SVGAnimatedPathData { + pathSegList: SVGPathSegList; +} + +interface Position { + timestamp: number; + coords: Coordinates; +} +declare var Position: { + prototype: Position; + new (): Position; +} + +interface BookmarkCollection { + length: number; + item(index: number): any; + [index: number]: any; +} +declare var BookmarkCollection: { + prototype: BookmarkCollection; + new (): BookmarkCollection; +} + +interface PerformanceMark extends PerformanceEntry { +} +declare var PerformanceMark: { + prototype: PerformanceMark; + new (): PerformanceMark; +} + +interface CSSPageRule extends CSSRule { + pseudoClass: string; + selectorText: string; + selector: string; + style: CSSStyleDeclaration; +} +declare var CSSPageRule: { + prototype: CSSPageRule; + new (): CSSPageRule; +} + +interface HTMLBRElement extends HTMLElement { + clear: string; +} +declare var HTMLBRElement: { + prototype: HTMLBRElement; + new (): HTMLBRElement; +} + +interface MSNavigatorExtensions { + userLanguage: string; + plugins: MSPluginsCollection; + cookieEnabled: boolean; + appCodeName: string; + cpuClass: string; + appMinorVersion: string; + connectionSpeed: number; + browserLanguage: string; + mimeTypes: MSMimeTypesCollection; + systemLanguage: string; + javaEnabled(): boolean; + taintEnabled(): boolean; +} + +interface HTMLSpanElement extends HTMLElement, MSDataBindingExtensions { +} +declare var HTMLSpanElement: { + prototype: HTMLSpanElement; + new (): HTMLSpanElement; +} + +interface HTMLHeadElement extends HTMLElement { + profile: string; +} +declare var HTMLHeadElement: { + prototype: HTMLHeadElement; + new (): HTMLHeadElement; +} + +interface HTMLHeadingElement extends HTMLElement, DOML2DeprecatedTextFlowControl { + align: string; +} +declare var HTMLHeadingElement: { + prototype: HTMLHeadingElement; + new (): HTMLHeadingElement; +} + +interface HTMLFormElement extends HTMLElement, MSHTMLCollectionExtensions { + length: number; + target: string; + acceptCharset: string; + enctype: string; + elements: HTMLCollection; + action: string; + name: string; + method: string; + encoding: string; + reset(): void; + item(name?: any, index?: any): any; + submit(): void; + namedItem(name: string): any; + [name: string]: any; +} +declare var HTMLFormElement: { + prototype: HTMLFormElement; + new (): HTMLFormElement; +} + +interface SVGZoomAndPan { + zoomAndPan: number; + SVG_ZOOMANDPAN_MAGNIFY: number; + SVG_ZOOMANDPAN_UNKNOWN: number; + SVG_ZOOMANDPAN_DISABLE: number; +} +declare var SVGZoomAndPan: { + prototype: SVGZoomAndPan; + new (): SVGZoomAndPan; + SVG_ZOOMANDPAN_MAGNIFY: number; + SVG_ZOOMANDPAN_UNKNOWN: number; + SVG_ZOOMANDPAN_DISABLE: number; +} + +interface HTMLMediaElement extends HTMLElement { + initialTime: number; + played: TimeRanges; + currentSrc: string; + readyState: any; + autobuffer: boolean; + loop: boolean; + ended: boolean; + buffered: TimeRanges; + error: MediaError; + seekable: TimeRanges; + autoplay: boolean; + controls: boolean; + volume: number; + src: string; + playbackRate: number; + duration: number; + muted: boolean; + defaultPlaybackRate: number; + paused: boolean; + seeking: boolean; + currentTime: number; + preload: string; + networkState: number; + pause(): void; + play(): void; + load(): void; + canPlayType(type: string): string; + HAVE_METADATA: number; + HAVE_CURRENT_DATA: number; + HAVE_NOTHING: number; + NETWORK_NO_SOURCE: number; + HAVE_ENOUGH_DATA: number; + NETWORK_EMPTY: number; + NETWORK_LOADING: number; + NETWORK_IDLE: number; + HAVE_FUTURE_DATA: number; +} +declare var HTMLMediaElement: { + prototype: HTMLMediaElement; + new (): HTMLMediaElement; + HAVE_METADATA: number; + HAVE_CURRENT_DATA: number; + HAVE_NOTHING: number; + NETWORK_NO_SOURCE: number; + HAVE_ENOUGH_DATA: number; + NETWORK_EMPTY: number; + NETWORK_LOADING: number; + NETWORK_IDLE: number; + HAVE_FUTURE_DATA: number; +} + +interface ElementCSSInlineStyle { + runtimeStyle: MSStyleCSSProperties; + currentStyle: MSCurrentStyleCSSProperties; + doScroll(component?: any): void; + componentFromPoint(x: number, y: number): string; +} + +interface DOMParser { + parseFromString(source: string, mimeType: string): Document; +} +declare var DOMParser: { + prototype: DOMParser; + new (): DOMParser; +} + +interface MSMimeTypesCollection { + length: number; +} +declare var MSMimeTypesCollection: { + prototype: MSMimeTypesCollection; + new (): MSMimeTypesCollection; +} + +interface StyleSheet { + disabled: boolean; + ownerNode: Node; + parentStyleSheet: StyleSheet; + href: string; + media: MediaList; + type: string; + title: string; +} +declare var StyleSheet: { + prototype: StyleSheet; + new (): StyleSheet; +} + +interface SVGTextPathElement extends SVGTextContentElement, SVGURIReference { + startOffset: SVGAnimatedLength; + method: SVGAnimatedEnumeration; + spacing: SVGAnimatedEnumeration; + TEXTPATH_SPACINGTYPE_EXACT: number; + TEXTPATH_METHODTYPE_STRETCH: number; + TEXTPATH_SPACINGTYPE_AUTO: number; + TEXTPATH_SPACINGTYPE_UNKNOWN: number; + TEXTPATH_METHODTYPE_UNKNOWN: number; + TEXTPATH_METHODTYPE_ALIGN: number; +} +declare var SVGTextPathElement: { + prototype: SVGTextPathElement; + new (): SVGTextPathElement; + TEXTPATH_SPACINGTYPE_EXACT: number; + TEXTPATH_METHODTYPE_STRETCH: number; + TEXTPATH_SPACINGTYPE_AUTO: number; + TEXTPATH_SPACINGTYPE_UNKNOWN: number; + TEXTPATH_METHODTYPE_UNKNOWN: number; + TEXTPATH_METHODTYPE_ALIGN: number; +} + +interface HTMLDTElement extends HTMLElement { + noWrap: boolean; +} +declare var HTMLDTElement: { + prototype: HTMLDTElement; + new (): HTMLDTElement; +} + +interface NodeList { + length: number; + item(index: number): Node; + [index: number]: Node; +} +declare var NodeList: { + prototype: NodeList; + new (): NodeList; +} + +interface NodeListOf extends NodeList { + length: number; + item(index: number): TNode; + [index: number]: TNode; +} + +interface XMLSerializer { + serializeToString(target: Node): string; +} +declare var XMLSerializer: { + prototype: XMLSerializer; + new (): XMLSerializer; +} + +interface PerformanceMeasure extends PerformanceEntry { +} +declare var PerformanceMeasure: { + prototype: PerformanceMeasure; + new (): PerformanceMeasure; +} + +interface SVGGradientElement extends SVGElement, SVGUnitTypes, SVGStylable, SVGExternalResourcesRequired, SVGURIReference { + spreadMethod: SVGAnimatedEnumeration; + gradientTransform: SVGAnimatedTransformList; + gradientUnits: SVGAnimatedEnumeration; + SVG_SPREADMETHOD_REFLECT: number; + SVG_SPREADMETHOD_PAD: number; + SVG_SPREADMETHOD_UNKNOWN: number; + SVG_SPREADMETHOD_REPEAT: number; +} +declare var SVGGradientElement: { + prototype: SVGGradientElement; + new (): SVGGradientElement; + SVG_SPREADMETHOD_REFLECT: number; + SVG_SPREADMETHOD_PAD: number; + SVG_SPREADMETHOD_UNKNOWN: number; + SVG_SPREADMETHOD_REPEAT: number; +} + +interface NodeFilter { + acceptNode(n: Node): number; + SHOW_ENTITY_REFERENCE: number; + SHOW_NOTATION: number; + SHOW_ENTITY: number; + SHOW_DOCUMENT: number; + SHOW_PROCESSING_INSTRUCTION: number; + FILTER_REJECT: number; + SHOW_CDATA_SECTION: number; + FILTER_ACCEPT: number; + SHOW_ALL: number; + SHOW_DOCUMENT_TYPE: number; + SHOW_TEXT: number; + SHOW_ELEMENT: number; + SHOW_COMMENT: number; + FILTER_SKIP: number; + SHOW_ATTRIBUTE: number; + SHOW_DOCUMENT_FRAGMENT: number; +} +declare var NodeFilter: { + prototype: NodeFilter; + new (): NodeFilter; + SHOW_ENTITY_REFERENCE: number; + SHOW_NOTATION: number; + SHOW_ENTITY: number; + SHOW_DOCUMENT: number; + SHOW_PROCESSING_INSTRUCTION: number; + FILTER_REJECT: number; + SHOW_CDATA_SECTION: number; + FILTER_ACCEPT: number; + SHOW_ALL: number; + SHOW_DOCUMENT_TYPE: number; + SHOW_TEXT: number; + SHOW_ELEMENT: number; + SHOW_COMMENT: number; + FILTER_SKIP: number; + SHOW_ATTRIBUTE: number; + SHOW_DOCUMENT_FRAGMENT: number; +} + +interface SVGNumberList { + numberOfItems: number; + replaceItem(newItem: SVGNumber, index: number): SVGNumber; + getItem(index: number): SVGNumber; + clear(): void; + appendItem(newItem: SVGNumber): SVGNumber; + initialize(newItem: SVGNumber): SVGNumber; + removeItem(index: number): SVGNumber; + insertItemBefore(newItem: SVGNumber, index: number): SVGNumber; +} +declare var SVGNumberList: { + prototype: SVGNumberList; + new (): SVGNumberList; +} + +interface MediaError { + code: number; + MEDIA_ERR_ABORTED: number; + MEDIA_ERR_NETWORK: number; + MEDIA_ERR_SRC_NOT_SUPPORTED: number; + MEDIA_ERR_DECODE: number; +} +declare var MediaError: { + prototype: MediaError; + new (): MediaError; + MEDIA_ERR_ABORTED: number; + MEDIA_ERR_NETWORK: number; + MEDIA_ERR_SRC_NOT_SUPPORTED: number; + MEDIA_ERR_DECODE: number; +} + +interface HTMLFieldSetElement extends HTMLElement { + align: string; + form: HTMLFormElement; +} +declare var HTMLFieldSetElement: { + prototype: HTMLFieldSetElement; + new (): HTMLFieldSetElement; +} + +interface HTMLBGSoundElement extends HTMLElement { + balance: any; + volume: any; + src: string; + loop: number; +} +declare var HTMLBGSoundElement: { + prototype: HTMLBGSoundElement; + new (): HTMLBGSoundElement; +} + +interface HTMLElement extends Element, ElementCSSInlineStyle, MSEventAttachmentTarget, MSNodeExtensions { + onmouseleave: (ev: MouseEvent) => any; + addEventListener(type: "mouseleave", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + onbeforecut: (ev: DragEvent) => any; + addEventListener(type: "beforecut", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + onkeydown: (ev: KeyboardEvent) => any; + addEventListener(type: "keydown", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; + onmove: (ev: MSEventObj) => any; + addEventListener(type: "move", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + onkeyup: (ev: KeyboardEvent) => any; + addEventListener(type: "keyup", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; + onreset: (ev: Event) => any; + addEventListener(type: "reset", listener: (ev: Event) => any, useCapture?: boolean): void; + onhelp: (ev: Event) => any; + addEventListener(type: "help", listener: (ev: Event) => any, useCapture?: boolean): void; + ondragleave: (ev: DragEvent) => any; + addEventListener(type: "dragleave", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + className: string; + onfocusin: (ev: FocusEvent) => any; + addEventListener(type: "focusin", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + onseeked: (ev: Event) => any; + addEventListener(type: "seeked", listener: (ev: Event) => any, useCapture?: boolean): void; + recordNumber: any; + title: string; + parentTextEdit: Element; + outerHTML: string; + ondurationchange: (ev: Event) => any; + addEventListener(type: "durationchange", listener: (ev: Event) => any, useCapture?: boolean): void; + offsetHeight: number; + all: HTMLCollection; + onblur: (ev: FocusEvent) => any; + addEventListener(type: "blur", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + dir: string; + onemptied: (ev: Event) => any; + addEventListener(type: "emptied", listener: (ev: Event) => any, useCapture?: boolean): void; + onseeking: (ev: Event) => any; + addEventListener(type: "seeking", listener: (ev: Event) => any, useCapture?: boolean): void; + oncanplay: (ev: Event) => any; + addEventListener(type: "canplay", listener: (ev: Event) => any, useCapture?: boolean): void; + ondeactivate: (ev: UIEvent) => any; + addEventListener(type: "deactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + ondatasetchanged: (ev: MSEventObj) => any; + addEventListener(type: "datasetchanged", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + onrowsdelete: (ev: MSEventObj) => any; + addEventListener(type: "rowsdelete", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + sourceIndex: number; + onloadstart: (ev: Event) => any; + addEventListener(type: "loadstart", listener: (ev: Event) => any, useCapture?: boolean): void; + onlosecapture: (ev: MSEventObj) => any; + addEventListener(type: "losecapture", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + ondragenter: (ev: DragEvent) => any; + addEventListener(type: "dragenter", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + oncontrolselect: (ev: MSEventObj) => any; + addEventListener(type: "controlselect", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + onsubmit: (ev: Event) => any; + addEventListener(type: "submit", listener: (ev: Event) => any, useCapture?: boolean): void; + behaviorUrns: MSBehaviorUrnsCollection; + scopeName: string; + onchange: (ev: Event) => any; + addEventListener(type: "change", listener: (ev: Event) => any, useCapture?: boolean): void; + id: string; + onlayoutcomplete: (ev: MSEventObj) => any; + addEventListener(type: "layoutcomplete", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + uniqueID: string; + onbeforeactivate: (ev: UIEvent) => any; + addEventListener(type: "beforeactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + oncanplaythrough: (ev: Event) => any; + addEventListener(type: "canplaythrough", listener: (ev: Event) => any, useCapture?: boolean): void; + onbeforeupdate: (ev: MSEventObj) => any; + addEventListener(type: "beforeupdate", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + onfilterchange: (ev: MSEventObj) => any; + addEventListener(type: "filterchange", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + offsetParent: Element; + ondatasetcomplete: (ev: MSEventObj) => any; + addEventListener(type: "datasetcomplete", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + onsuspend: (ev: Event) => any; + addEventListener(type: "suspend", listener: (ev: Event) => any, useCapture?: boolean): void; + readyState: any; + onmouseenter: (ev: MouseEvent) => any; + addEventListener(type: "mouseenter", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + innerText: string; + onerrorupdate: (ev: MSEventObj) => any; + addEventListener(type: "errorupdate", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + onmouseout: (ev: MouseEvent) => any; + addEventListener(type: "mouseout", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + parentElement: HTMLElement; + onmousewheel: (ev: MouseWheelEvent) => any; + addEventListener(type: "mousewheel", listener: (ev: MouseWheelEvent) => any, useCapture?: boolean): void; + onvolumechange: (ev: Event) => any; + addEventListener(type: "volumechange", listener: (ev: Event) => any, useCapture?: boolean): void; + oncellchange: (ev: MSEventObj) => any; + addEventListener(type: "cellchange", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + onrowexit: (ev: MSEventObj) => any; + addEventListener(type: "rowexit", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + onrowsinserted: (ev: MSEventObj) => any; + addEventListener(type: "rowsinserted", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + onpropertychange: (ev: MSEventObj) => any; + addEventListener(type: "propertychange", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + filters: Object; + children: HTMLCollection; + ondragend: (ev: DragEvent) => any; + addEventListener(type: "dragend", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + onbeforepaste: (ev: DragEvent) => any; + addEventListener(type: "beforepaste", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + ondragover: (ev: DragEvent) => any; + addEventListener(type: "dragover", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + offsetTop: number; + onmouseup: (ev: MouseEvent) => any; + addEventListener(type: "mouseup", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + ondragstart: (ev: DragEvent) => any; + addEventListener(type: "dragstart", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + onbeforecopy: (ev: DragEvent) => any; + addEventListener(type: "beforecopy", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + ondrag: (ev: DragEvent) => any; + addEventListener(type: "drag", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + innerHTML: string; + onmouseover: (ev: MouseEvent) => any; + addEventListener(type: "mouseover", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + lang: string; + uniqueNumber: number; + onpause: (ev: Event) => any; + addEventListener(type: "pause", listener: (ev: Event) => any, useCapture?: boolean): void; + tagUrn: string; + onmousedown: (ev: MouseEvent) => any; + addEventListener(type: "mousedown", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + onclick: (ev: MouseEvent) => any; + addEventListener(type: "click", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + onwaiting: (ev: Event) => any; + addEventListener(type: "waiting", listener: (ev: Event) => any, useCapture?: boolean): void; + onresizestart: (ev: MSEventObj) => any; + addEventListener(type: "resizestart", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + offsetLeft: number; + isTextEdit: boolean; + isDisabled: boolean; + onpaste: (ev: DragEvent) => any; + addEventListener(type: "paste", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + canHaveHTML: boolean; + onmoveend: (ev: MSEventObj) => any; + addEventListener(type: "moveend", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + language: string; + onstalled: (ev: Event) => any; + addEventListener(type: "stalled", listener: (ev: Event) => any, useCapture?: boolean): void; + onmousemove: (ev: MouseEvent) => any; + addEventListener(type: "mousemove", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + style: MSStyleCSSProperties; + isContentEditable: boolean; + onbeforeeditfocus: (ev: MSEventObj) => any; + addEventListener(type: "beforeeditfocus", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + onratechange: (ev: Event) => any; + addEventListener(type: "ratechange", listener: (ev: Event) => any, useCapture?: boolean): void; + contentEditable: string; + tabIndex: number; + document: Document; + onprogress: (ev: any) => any; + addEventListener(type: "progress", listener: (ev: any) => any, useCapture?: boolean): void; + ondblclick: (ev: MouseEvent) => any; + addEventListener(type: "dblclick", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + oncontextmenu: (ev: MouseEvent) => any; + addEventListener(type: "contextmenu", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + onloadedmetadata: (ev: Event) => any; + addEventListener(type: "loadedmetadata", listener: (ev: Event) => any, useCapture?: boolean): void; + onafterupdate: (ev: MSEventObj) => any; + addEventListener(type: "afterupdate", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + onerror: (ev: Event) => any; + addEventListener(type: "error", listener: (ev: Event) => any, useCapture?: boolean): void; + onplay: (ev: Event) => any; + addEventListener(type: "play", listener: (ev: Event) => any, useCapture?: boolean): void; + onresizeend: (ev: MSEventObj) => any; + addEventListener(type: "resizeend", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + onplaying: (ev: Event) => any; + addEventListener(type: "playing", listener: (ev: Event) => any, useCapture?: boolean): void; + isMultiLine: boolean; + onfocusout: (ev: FocusEvent) => any; + addEventListener(type: "focusout", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + onabort: (ev: UIEvent) => any; + addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + ondataavailable: (ev: MSEventObj) => any; + addEventListener(type: "dataavailable", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + hideFocus: boolean; + onreadystatechange: (ev: Event) => any; + addEventListener(type: "readystatechange", listener: (ev: Event) => any, useCapture?: boolean): void; + onkeypress: (ev: KeyboardEvent) => any; + addEventListener(type: "keypress", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; + onloadeddata: (ev: Event) => any; + addEventListener(type: "loadeddata", listener: (ev: Event) => any, useCapture?: boolean): void; + onbeforedeactivate: (ev: UIEvent) => any; + addEventListener(type: "beforedeactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + outerText: string; + disabled: boolean; + onactivate: (ev: UIEvent) => any; + addEventListener(type: "activate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + accessKey: string; + onmovestart: (ev: MSEventObj) => any; + addEventListener(type: "movestart", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + onselectstart: (ev: Event) => any; + addEventListener(type: "selectstart", listener: (ev: Event) => any, useCapture?: boolean): void; + onfocus: (ev: FocusEvent) => any; + addEventListener(type: "focus", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + ontimeupdate: (ev: Event) => any; + addEventListener(type: "timeupdate", listener: (ev: Event) => any, useCapture?: boolean): void; + onresize: (ev: UIEvent) => any; + addEventListener(type: "resize", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + oncut: (ev: DragEvent) => any; + addEventListener(type: "cut", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + onselect: (ev: UIEvent) => any; + addEventListener(type: "select", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + ondrop: (ev: DragEvent) => any; + addEventListener(type: "drop", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + offsetWidth: number; + oncopy: (ev: DragEvent) => any; + addEventListener(type: "copy", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + onended: (ev: Event) => any; + addEventListener(type: "ended", listener: (ev: Event) => any, useCapture?: boolean): void; + onscroll: (ev: UIEvent) => any; + addEventListener(type: "scroll", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + onrowenter: (ev: MSEventObj) => any; + addEventListener(type: "rowenter", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + onload: (ev: Event) => any; + addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; + canHaveChildren: boolean; + oninput: (ev: Event) => any; + addEventListener(type: "input", listener: (ev: Event) => any, useCapture?: boolean): void; + dragDrop(): boolean; + scrollIntoView(top?: boolean): void; + addFilter(filter: Object): void; + setCapture(containerCapture?: boolean): void; + focus(): void; + getAdjacentText(where: string): string; + insertAdjacentText(where: string, text: string): void; + getElementsByClassName(classNames: string): NodeList; + setActive(): void; + removeFilter(filter: Object): void; + blur(): void; + clearAttributes(): void; + releaseCapture(): void; + createControlRange(): ControlRangeCollection; + removeBehavior(cookie: number): boolean; + contains(child: HTMLElement): boolean; + click(): void; + insertAdjacentElement(position: string, insertedElement: Element): Element; + mergeAttributes(source: HTMLElement, preserveIdentity?: boolean): void; + replaceAdjacentText(where: string, newText: string): string; + applyElement(apply: Element, where?: string): Element; + addBehavior(bstrUrl: string, factory?: any): number; + insertAdjacentHTML(where: string, html: string): void; + addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; +} +declare var HTMLElement: { + prototype: HTMLElement; + new (): HTMLElement; +} + +interface Comment extends CharacterData { + text: string; +} +declare var Comment: { + prototype: Comment; + new (): Comment; +} + +interface PerformanceResourceTiming extends PerformanceEntry { + redirectStart: number; + redirectEnd: number; + domainLookupEnd: number; + responseStart: number; + domainLookupStart: number; + fetchStart: number; + requestStart: number; + connectEnd: number; + connectStart: number; + initiatorType: string; + responseEnd: number; +} +declare var PerformanceResourceTiming: { + prototype: PerformanceResourceTiming; + new (): PerformanceResourceTiming; +} + +interface CanvasPattern { +} +declare var CanvasPattern: { + prototype: CanvasPattern; + new (): CanvasPattern; +} + +interface HTMLHRElement extends HTMLElement, DOML2DeprecatedColorProperty, DOML2DeprecatedSizeProperty { + width: number; + align: string; + noShade: boolean; +} +declare var HTMLHRElement: { + prototype: HTMLHRElement; + new (): HTMLHRElement; +} + +interface HTMLObjectElement extends HTMLElement, GetSVGDocument, DOML2DeprecatedMarginStyle, DOML2DeprecatedBorderStyle, DOML2DeprecatedAlignmentStyle, MSDataBindingExtensions, MSDataBindingRecordSetExtensions { + width: string; + codeType: string; + object: Object; + form: HTMLFormElement; + code: string; + archive: string; + standby: string; + alt: string; + classid: string; + name: string; + useMap: string; + data: string; + height: string; + contentDocument: Document; + altHtml: string; + codeBase: string; + declare: boolean; + type: string; + BaseHref: string; +} +declare var HTMLObjectElement: { + prototype: HTMLObjectElement; + new (): HTMLObjectElement; +} + +interface HTMLEmbedElement extends HTMLElement, GetSVGDocument { + width: string; + palette: string; + src: string; + name: string; + pluginspage: string; + height: string; + units: string; +} +declare var HTMLEmbedElement: { + prototype: HTMLEmbedElement; + new (): HTMLEmbedElement; +} + +interface StorageEvent extends Event { + oldValue: any; + newValue: any; + url: string; + storageArea: Storage; + key: string; + initStorageEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, keyArg: string, oldValueArg: any, newValueArg: any, urlArg: string, storageAreaArg: Storage): void; +} +declare var StorageEvent: { + prototype: StorageEvent; + new (): StorageEvent; +} + +interface CharacterData extends Node { + length: number; + data: string; + deleteData(offset: number, count: number): void; + replaceData(offset: number, count: number, arg: string): void; + appendData(arg: string): void; + insertData(offset: number, arg: string): void; + substringData(offset: number, count: number): string; +} +declare var CharacterData: { + prototype: CharacterData; + new (): CharacterData; +} + +interface HTMLOptGroupElement extends HTMLElement, MSDataBindingExtensions { + index: number; + defaultSelected: boolean; + text: string; + value: string; + form: HTMLFormElement; + label: string; + selected: boolean; +} +declare var HTMLOptGroupElement: { + prototype: HTMLOptGroupElement; + new (): HTMLOptGroupElement; +} + +interface HTMLIsIndexElement extends HTMLElement { + form: HTMLFormElement; + action: string; + prompt: string; +} +declare var HTMLIsIndexElement: { + prototype: HTMLIsIndexElement; + new (): HTMLIsIndexElement; +} + +interface SVGPathSegLinetoRel extends SVGPathSeg { + y: number; + x: number; +} +declare var SVGPathSegLinetoRel: { + prototype: SVGPathSegLinetoRel; + new (): SVGPathSegLinetoRel; +} + +interface DOMException { + code: number; + message: string; + toString(): string; + HIERARCHY_REQUEST_ERR: number; + NO_MODIFICATION_ALLOWED_ERR: number; + INVALID_MODIFICATION_ERR: number; + NAMESPACE_ERR: number; + INVALID_CHARACTER_ERR: number; + TYPE_MISMATCH_ERR: number; + ABORT_ERR: number; + INVALID_STATE_ERR: number; + SECURITY_ERR: number; + NETWORK_ERR: number; + WRONG_DOCUMENT_ERR: number; + QUOTA_EXCEEDED_ERR: number; + INDEX_SIZE_ERR: number; + DOMSTRING_SIZE_ERR: number; + SYNTAX_ERR: number; + SERIALIZE_ERR: number; + VALIDATION_ERR: number; + NOT_FOUND_ERR: number; + URL_MISMATCH_ERR: number; + PARSE_ERR: number; + NO_DATA_ALLOWED_ERR: number; + NOT_SUPPORTED_ERR: number; + INVALID_ACCESS_ERR: number; + INUSE_ATTRIBUTE_ERR: number; +} +declare var DOMException: { + prototype: DOMException; + new (): DOMException; + HIERARCHY_REQUEST_ERR: number; + NO_MODIFICATION_ALLOWED_ERR: number; + INVALID_MODIFICATION_ERR: number; + NAMESPACE_ERR: number; + INVALID_CHARACTER_ERR: number; + TYPE_MISMATCH_ERR: number; + ABORT_ERR: number; + INVALID_STATE_ERR: number; + SECURITY_ERR: number; + NETWORK_ERR: number; + WRONG_DOCUMENT_ERR: number; + QUOTA_EXCEEDED_ERR: number; + INDEX_SIZE_ERR: number; + DOMSTRING_SIZE_ERR: number; + SYNTAX_ERR: number; + SERIALIZE_ERR: number; + VALIDATION_ERR: number; + NOT_FOUND_ERR: number; + URL_MISMATCH_ERR: number; + PARSE_ERR: number; + NO_DATA_ALLOWED_ERR: number; + NOT_SUPPORTED_ERR: number; + INVALID_ACCESS_ERR: number; + INUSE_ATTRIBUTE_ERR: number; +} + +interface SVGAnimatedBoolean { + animVal: boolean; + baseVal: boolean; +} +declare var SVGAnimatedBoolean: { + prototype: SVGAnimatedBoolean; + new (): SVGAnimatedBoolean; +} + +interface MSCompatibleInfoCollection { + length: number; + item(index: number): MSCompatibleInfo; +} +declare var MSCompatibleInfoCollection: { + prototype: MSCompatibleInfoCollection; + new (): MSCompatibleInfoCollection; +} + +interface SVGSwitchElement extends SVGElement, SVGStylable, SVGTransformable, SVGLangSpace, SVGTests, SVGExternalResourcesRequired { +} +declare var SVGSwitchElement: { + prototype: SVGSwitchElement; + new (): SVGSwitchElement; +} + +interface SVGPreserveAspectRatio { + align: number; + meetOrSlice: number; + SVG_PRESERVEASPECTRATIO_NONE: number; + SVG_PRESERVEASPECTRATIO_XMINYMID: number; + SVG_PRESERVEASPECTRATIO_XMAXYMIN: number; + SVG_PRESERVEASPECTRATIO_XMINYMAX: number; + SVG_PRESERVEASPECTRATIO_XMAXYMAX: number; + SVG_MEETORSLICE_UNKNOWN: number; + SVG_PRESERVEASPECTRATIO_XMAXYMID: number; + SVG_PRESERVEASPECTRATIO_XMIDYMAX: number; + SVG_PRESERVEASPECTRATIO_XMINYMIN: number; + SVG_MEETORSLICE_MEET: number; + SVG_PRESERVEASPECTRATIO_XMIDYMID: number; + SVG_PRESERVEASPECTRATIO_XMIDYMIN: number; + SVG_MEETORSLICE_SLICE: number; + SVG_PRESERVEASPECTRATIO_UNKNOWN: number; +} +declare var SVGPreserveAspectRatio: { + prototype: SVGPreserveAspectRatio; + new (): SVGPreserveAspectRatio; + SVG_PRESERVEASPECTRATIO_NONE: number; + SVG_PRESERVEASPECTRATIO_XMINYMID: number; + SVG_PRESERVEASPECTRATIO_XMAXYMIN: number; + SVG_PRESERVEASPECTRATIO_XMINYMAX: number; + SVG_PRESERVEASPECTRATIO_XMAXYMAX: number; + SVG_MEETORSLICE_UNKNOWN: number; + SVG_PRESERVEASPECTRATIO_XMAXYMID: number; + SVG_PRESERVEASPECTRATIO_XMIDYMAX: number; + SVG_PRESERVEASPECTRATIO_XMINYMIN: number; + SVG_MEETORSLICE_MEET: number; + SVG_PRESERVEASPECTRATIO_XMIDYMID: number; + SVG_PRESERVEASPECTRATIO_XMIDYMIN: number; + SVG_MEETORSLICE_SLICE: number; + SVG_PRESERVEASPECTRATIO_UNKNOWN: number; +} + +interface Attr extends Node { + expando: boolean; + specified: boolean; + ownerElement: Element; + value: string; + name: string; +} +declare var Attr: { + prototype: Attr; + new (): Attr; +} + +interface PerformanceNavigation { + redirectCount: number; + type: number; + toJSON(): any; + TYPE_RELOAD: number; + TYPE_RESERVED: number; + TYPE_BACK_FORWARD: number; + TYPE_NAVIGATE: number; +} +declare var PerformanceNavigation: { + prototype: PerformanceNavigation; + new (): PerformanceNavigation; + TYPE_RELOAD: number; + TYPE_RESERVED: number; + TYPE_BACK_FORWARD: number; + TYPE_NAVIGATE: number; +} + +interface SVGStopElement extends SVGElement, SVGStylable { + offset: SVGAnimatedNumber; +} +declare var SVGStopElement: { + prototype: SVGStopElement; + new (): SVGStopElement; +} + +interface PositionCallback { + (position: Position): void; +} + +interface SVGSymbolElement extends SVGElement, SVGStylable, SVGLangSpace, SVGFitToViewBox, SVGExternalResourcesRequired { +} +declare var SVGSymbolElement: { + prototype: SVGSymbolElement; + new (): SVGSymbolElement; +} + +interface SVGElementInstanceList { + length: number; + item(index: number): SVGElementInstance; +} +declare var SVGElementInstanceList: { + prototype: SVGElementInstanceList; + new (): SVGElementInstanceList; +} + +interface CSSRuleList { + length: number; + item(index: number): CSSRule; + [index: number]: CSSRule; +} +declare var CSSRuleList: { + prototype: CSSRuleList; + new (): CSSRuleList; +} + +interface MSDataBindingRecordSetExtensions { + recordset: Object; + namedRecordset(dataMember: string, hierarchy?: any): Object; +} + +interface LinkStyle { + styleSheet: StyleSheet; + sheet: StyleSheet; +} + +interface HTMLVideoElement extends HTMLMediaElement { + width: number; + videoWidth: number; + videoHeight: number; + height: number; + poster: string; +} +declare var HTMLVideoElement: { + prototype: HTMLVideoElement; + new (): HTMLVideoElement; +} + +interface ClientRectList { + length: number; + item(index: number): ClientRect; + [index: number]: ClientRect; +} +declare var ClientRectList: { + prototype: ClientRectList; + new (): ClientRectList; +} + +interface SVGMaskElement extends SVGElement, SVGUnitTypes, SVGStylable, SVGLangSpace, SVGTests, SVGExternalResourcesRequired { + y: SVGAnimatedLength; + width: SVGAnimatedLength; + maskUnits: SVGAnimatedEnumeration; + maskContentUnits: SVGAnimatedEnumeration; + x: SVGAnimatedLength; + height: SVGAnimatedLength; +} +declare var SVGMaskElement: { + prototype: SVGMaskElement; + new (): SVGMaskElement; +} + +interface External { +} +declare var External: { + prototype: External; + new (): External; +} + +declare var Audio: { new (src?: string): HTMLAudioElement; }; +declare var Option: { new (text?: string, value?: string, defaultSelected?: boolean, selected?: boolean): HTMLOptionElement; }; +declare var Image: { new (width?: number, height?: number): HTMLImageElement; }; + +declare var ondragend: (ev: DragEvent) => any; +declare function addEventListener(type: "dragend", listener: (ev: DragEvent) => any, useCapture?: boolean): void; +declare var onkeydown: (ev: KeyboardEvent) => any; +declare function addEventListener(type: "keydown", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; +declare var ondragover: (ev: DragEvent) => any; +declare function addEventListener(type: "dragover", listener: (ev: DragEvent) => any, useCapture?: boolean): void; +declare var onkeyup: (ev: KeyboardEvent) => any; +declare function addEventListener(type: "keyup", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; +declare var onreset: (ev: Event) => any; +declare function addEventListener(type: "reset", listener: (ev: Event) => any, useCapture?: boolean): void; +declare var onmouseup: (ev: MouseEvent) => any; +declare function addEventListener(type: "mouseup", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; +declare var ondragstart: (ev: DragEvent) => any; +declare function addEventListener(type: "dragstart", listener: (ev: DragEvent) => any, useCapture?: boolean): void; +declare var ondrag: (ev: DragEvent) => any; +declare function addEventListener(type: "drag", listener: (ev: DragEvent) => any, useCapture?: boolean): void; +declare var screenX: number; +declare var onmouseover: (ev: MouseEvent) => any; +declare function addEventListener(type: "mouseover", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; +declare var ondragleave: (ev: DragEvent) => any; +declare function addEventListener(type: "dragleave", listener: (ev: DragEvent) => any, useCapture?: boolean): void; +declare var history: History; +declare var pageXOffset: number; +declare var name: string; +declare var onafterprint: (ev: Event) => any; +declare function addEventListener(type: "afterprint", listener: (ev: Event) => any, useCapture?: boolean): void; +declare var onpause: (ev: Event) => any; +declare function addEventListener(type: "pause", listener: (ev: Event) => any, useCapture?: boolean): void; +declare var onbeforeprint: (ev: Event) => any; +declare function addEventListener(type: "beforeprint", listener: (ev: Event) => any, useCapture?: boolean): void; +declare var top: Window; +declare var onmousedown: (ev: MouseEvent) => any; +declare function addEventListener(type: "mousedown", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; +declare var onseeked: (ev: Event) => any; +declare function addEventListener(type: "seeked", listener: (ev: Event) => any, useCapture?: boolean): void; +declare var opener: Window; +declare var onclick: (ev: MouseEvent) => any; +declare function addEventListener(type: "click", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; +declare var innerHeight: number; +declare var onwaiting: (ev: Event) => any; +declare function addEventListener(type: "waiting", listener: (ev: Event) => any, useCapture?: boolean): void; +declare var ononline: (ev: Event) => any; +declare function addEventListener(type: "online", listener: (ev: Event) => any, useCapture?: boolean): void; +declare var ondurationchange: (ev: Event) => any; +declare function addEventListener(type: "durationchange", listener: (ev: Event) => any, useCapture?: boolean): void; +declare var frames: Window; +declare var onblur: (ev: FocusEvent) => any; +declare function addEventListener(type: "blur", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; +declare var onemptied: (ev: Event) => any; +declare function addEventListener(type: "emptied", listener: (ev: Event) => any, useCapture?: boolean): void; +declare var onseeking: (ev: Event) => any; +declare function addEventListener(type: "seeking", listener: (ev: Event) => any, useCapture?: boolean): void; +declare var oncanplay: (ev: Event) => any; +declare function addEventListener(type: "canplay", listener: (ev: Event) => any, useCapture?: boolean): void; +declare var outerWidth: number; +declare var onstalled: (ev: Event) => any; +declare function addEventListener(type: "stalled", listener: (ev: Event) => any, useCapture?: boolean): void; +declare var onmousemove: (ev: MouseEvent) => any; +declare function addEventListener(type: "mousemove", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; +declare var innerWidth: number; +declare var onoffline: (ev: Event) => any; +declare function addEventListener(type: "offline", listener: (ev: Event) => any, useCapture?: boolean): void; +declare var length: number; +declare var screen: Screen; +declare var onbeforeunload: (ev: BeforeUnloadEvent) => any; +declare function addEventListener(type: "beforeunload", listener: (ev: BeforeUnloadEvent) => any, useCapture?: boolean): void; +declare var onratechange: (ev: Event) => any; +declare function addEventListener(type: "ratechange", listener: (ev: Event) => any, useCapture?: boolean): void; +declare var onstorage: (ev: StorageEvent) => any; +declare function addEventListener(type: "storage", listener: (ev: StorageEvent) => any, useCapture?: boolean): void; +declare var onloadstart: (ev: Event) => any; +declare function addEventListener(type: "loadstart", listener: (ev: Event) => any, useCapture?: boolean): void; +declare var ondragenter: (ev: DragEvent) => any; +declare function addEventListener(type: "dragenter", listener: (ev: DragEvent) => any, useCapture?: boolean): void; +declare var onsubmit: (ev: Event) => any; +declare function addEventListener(type: "submit", listener: (ev: Event) => any, useCapture?: boolean): void; +declare var self: Window; +declare var document: Document; +declare var onprogress: (ev: any) => any; +declare function addEventListener(type: "progress", listener: (ev: any) => any, useCapture?: boolean): void; +declare var ondblclick: (ev: MouseEvent) => any; +declare function addEventListener(type: "dblclick", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; +declare var pageYOffset: number; +declare var oncontextmenu: (ev: MouseEvent) => any; +declare function addEventListener(type: "contextmenu", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; +declare var onchange: (ev: Event) => any; +declare function addEventListener(type: "change", listener: (ev: Event) => any, useCapture?: boolean): void; +declare var onloadedmetadata: (ev: Event) => any; +declare function addEventListener(type: "loadedmetadata", listener: (ev: Event) => any, useCapture?: boolean): void; +declare var onplay: (ev: Event) => any; +declare function addEventListener(type: "play", listener: (ev: Event) => any, useCapture?: boolean): void; +declare var onerror: ErrorEventHandler; +declare var onplaying: (ev: Event) => any; +declare function addEventListener(type: "playing", listener: (ev: Event) => any, useCapture?: boolean): void; +declare var parent: Window; +declare var location: Location; +declare var oncanplaythrough: (ev: Event) => any; +declare function addEventListener(type: "canplaythrough", listener: (ev: Event) => any, useCapture?: boolean): void; +declare var onabort: (ev: UIEvent) => any; +declare function addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; +declare var onreadystatechange: (ev: Event) => any; +declare function addEventListener(type: "readystatechange", listener: (ev: Event) => any, useCapture?: boolean): void; +declare var outerHeight: number; +declare var onkeypress: (ev: KeyboardEvent) => any; +declare function addEventListener(type: "keypress", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; +declare var frameElement: Element; +declare var onloadeddata: (ev: Event) => any; +declare function addEventListener(type: "loadeddata", listener: (ev: Event) => any, useCapture?: boolean): void; +declare var onsuspend: (ev: Event) => any; +declare function addEventListener(type: "suspend", listener: (ev: Event) => any, useCapture?: boolean): void; +declare var window: Window; +declare var onfocus: (ev: FocusEvent) => any; +declare function addEventListener(type: "focus", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; +declare var onmessage: (ev: MessageEvent) => any; +declare function addEventListener(type: "message", listener: (ev: MessageEvent) => any, useCapture?: boolean): void; +declare var ontimeupdate: (ev: Event) => any; +declare function addEventListener(type: "timeupdate", listener: (ev: Event) => any, useCapture?: boolean): void; +declare var onresize: (ev: UIEvent) => any; +declare function addEventListener(type: "resize", listener: (ev: UIEvent) => any, useCapture?: boolean): void; +declare var onselect: (ev: UIEvent) => any; +declare function addEventListener(type: "select", listener: (ev: UIEvent) => any, useCapture?: boolean): void; +declare var navigator: Navigator; +declare var styleMedia: StyleMedia; +declare var ondrop: (ev: DragEvent) => any; +declare function addEventListener(type: "drop", listener: (ev: DragEvent) => any, useCapture?: boolean): void; +declare var onmouseout: (ev: MouseEvent) => any; +declare function addEventListener(type: "mouseout", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; +declare var onended: (ev: Event) => any; +declare function addEventListener(type: "ended", listener: (ev: Event) => any, useCapture?: boolean): void; +declare var onhashchange: (ev: Event) => any; +declare function addEventListener(type: "hashchange", listener: (ev: Event) => any, useCapture?: boolean): void; +declare var onunload: (ev: Event) => any; +declare function addEventListener(type: "unload", listener: (ev: Event) => any, useCapture?: boolean): void; +declare var onscroll: (ev: UIEvent) => any; +declare function addEventListener(type: "scroll", listener: (ev: UIEvent) => any, useCapture?: boolean): void; +declare var screenY: number; +declare var onmousewheel: (ev: MouseWheelEvent) => any; +declare function addEventListener(type: "mousewheel", listener: (ev: MouseWheelEvent) => any, useCapture?: boolean): void; +declare var onload: (ev: Event) => any; +declare function addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; +declare var onvolumechange: (ev: Event) => any; +declare function addEventListener(type: "volumechange", listener: (ev: Event) => any, useCapture?: boolean): void; +declare var oninput: (ev: Event) => any; +declare function addEventListener(type: "input", listener: (ev: Event) => any, useCapture?: boolean): void; +declare var performance: Performance; +declare function alert(message?: string): void; +declare function scroll(x?: number, y?: number): void; +declare function focus(): void; +declare function scrollTo(x?: number, y?: number): void; +declare function print(): void; +declare function prompt(message?: string, defaul?: string): string; +declare function toString(): string; +declare function open(url?: string, target?: string, features?: string, replace?: boolean): Window; +declare function scrollBy(x?: number, y?: number): void; +declare function confirm(message?: string): boolean; +declare function close(): void; +declare function postMessage(message: any, targetOrigin: string, ports?: any): void; +declare function showModalDialog(url?: string, argument?: any, options?: any): any; +declare function blur(): void; +declare function getSelection(): Selection; +declare function getComputedStyle(elt: Element, pseudoElt?: string): CSSStyleDeclaration; +declare function addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; +declare function removeEventListener(type: string, listener: EventListener, useCapture?: boolean): void; +declare function dispatchEvent(evt: Event): boolean; +declare function attachEvent(event: string, listener: EventListener): boolean; +declare function detachEvent(event: string, listener: EventListener): void; +declare var localStorage: Storage; +declare var status: string; +declare var onmouseleave: (ev: MouseEvent) => any; +declare function addEventListener(type: "mouseleave", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; +declare var screenLeft: number; +declare var offscreenBuffering: any; +declare var maxConnectionsPerServer: number; +declare var onmouseenter: (ev: MouseEvent) => any; +declare function addEventListener(type: "mouseenter", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; +declare var clipboardData: DataTransfer; +declare var defaultStatus: string; +declare var clientInformation: Navigator; +declare var closed: boolean; +declare var onhelp: (ev: Event) => any; +declare function addEventListener(type: "help", listener: (ev: Event) => any, useCapture?: boolean): void; +declare var external: External; +declare var event: MSEventObj; +declare var onfocusout: (ev: FocusEvent) => any; +declare function addEventListener(type: "focusout", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; +declare var screenTop: number; +declare var onfocusin: (ev: FocusEvent) => any; +declare function addEventListener(type: "focusin", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; +declare function showModelessDialog(url?: string, argument?: any, options?: any): Window; +declare function navigate(url: string): void; +declare function resizeBy(x?: number, y?: number): void; +declare function item(index: any): any; +declare function resizeTo(x?: number, y?: number): void; +declare function createPopup(arguments?: any): MSPopupWindow; +declare function toStaticHTML(html: string): string; +declare function execScript(code: string, language?: string): any; +declare function msWriteProfilerMark(profilerMarkName: string): void; +declare function moveTo(x?: number, y?: number): void; +declare function moveBy(x?: number, y?: number): void; +declare function showHelp(url: string, helpArg?: any, features?: string): void; +declare var sessionStorage: Storage; +declare function clearTimeout(handle: number): void; +declare function setTimeout(handler: any, timeout?: any, ...args: any[]): number; +declare function clearInterval(handle: number): void; +declare function setInterval(handler: any, timeout?: any, ...args: any[]): number; + + +///////////////////////////// +/// IE10 DOM APIs +///////////////////////////// + + + +interface ObjectURLOptions { + oneTimeOnly?: boolean; +} + +interface HTMLBodyElement { + onpopstate: (ev: PopStateEvent) => any; + addEventListener(type: "popstate", listener: (ev: PopStateEvent) => any, useCapture?: boolean): void; +} + +interface MSGestureEvent extends UIEvent { + offsetY: number; + translationY: number; + velocityExpansion: number; + velocityY: number; + velocityAngular: number; + translationX: number; + velocityX: number; + hwTimestamp: number; + offsetX: number; + screenX: number; + rotation: number; + expansion: number; + clientY: number; + screenY: number; + scale: number; + gestureObject: any; + clientX: number; + initGestureEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: Window, detailArg: number, screenXArg: number, screenYArg: number, clientXArg: number, clientYArg: number, offsetXArg: number, offsetYArg: number, translationXArg: number, translationYArg: number, scaleArg: number, expansionArg: number, rotationArg: number, velocityXArg: number, velocityYArg: number, velocityExpansionArg: number, velocityAngularArg: number, hwTimestampArg: number): void; + MSGESTURE_FLAG_BEGIN: number; + MSGESTURE_FLAG_END: number; + MSGESTURE_FLAG_CANCEL: number; + MSGESTURE_FLAG_INERTIA: number; + MSGESTURE_FLAG_NONE: number; +} +declare var MSGestureEvent: { + prototype: MSGestureEvent; + new (): MSGestureEvent; + MSGESTURE_FLAG_BEGIN: number; + MSGESTURE_FLAG_END: number; + MSGESTURE_FLAG_CANCEL: number; + MSGESTURE_FLAG_INERTIA: number; + MSGESTURE_FLAG_NONE: number; +} + +interface HTMLAnchorElement { + text: string; +} + +interface HTMLInputElement { + validationMessage: string; + files: FileList; + max: string; + formTarget: string; + willValidate: boolean; + step: string; + autofocus: boolean; + required: boolean; + formEnctype: string; + valueAsNumber: number; + placeholder: string; + formMethod: string; + list: HTMLElement; + autocomplete: string; + min: string; + formAction: string; + pattern: string; + validity: ValidityState; + formNoValidate: string; + multiple: boolean; + checkValidity(): boolean; + stepDown(n?: number): void; + stepUp(n?: number): void; + setCustomValidity(error: string): void; +} + +interface ErrorEvent extends Event { + colno: number; + filename: string; + lineno: number; + message: string; + initErrorEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, messageArg: string, filenameArg: string, linenoArg: number): void; +} +declare var ErrorEvent: { + prototype: ErrorEvent; + new (): ErrorEvent; +} + +interface SVGFilterElement extends SVGElement, SVGUnitTypes, SVGStylable, SVGLangSpace, SVGURIReference, SVGExternalResourcesRequired { + y: SVGAnimatedLength; + width: SVGAnimatedLength; + filterResX: SVGAnimatedInteger; + filterUnits: SVGAnimatedEnumeration; + primitiveUnits: SVGAnimatedEnumeration; + x: SVGAnimatedLength; + height: SVGAnimatedLength; + filterResY: SVGAnimatedInteger; + setFilterRes(filterResX: number, filterResY: number): void; +} +declare var SVGFilterElement: { + prototype: SVGFilterElement; + new (): SVGFilterElement; +} + +interface TrackEvent extends Event { + track: any; +} +declare var TrackEvent: { + prototype: TrackEvent; + new (): TrackEvent; +} + +interface SVGFEMergeNodeElement extends SVGElement { + in1: SVGAnimatedString; +} +declare var SVGFEMergeNodeElement: { + prototype: SVGFEMergeNodeElement; + new (): SVGFEMergeNodeElement; +} + +interface SVGFEFloodElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { +} +declare var SVGFEFloodElement: { + prototype: SVGFEFloodElement; + new (): SVGFEFloodElement; +} + +interface MSGesture { + target: Element; + addPointer(pointerId: number): void; + stop(): void; +} +declare var MSGesture: { + prototype: MSGesture; + new (): MSGesture; +} + +interface TextTrackCue extends EventTarget { + onenter: (ev: Event) => any; + addEventListener(type: "enter", listener: (ev: Event) => any, useCapture?: boolean): void; + track: TextTrack; + endTime: number; + text: string; + pauseOnExit: boolean; + id: string; + startTime: number; + onexit: (ev: Event) => any; + addEventListener(type: "exit", listener: (ev: Event) => any, useCapture?: boolean): void; + getCueAsHTML(): DocumentFragment; + addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; +} +declare var TextTrackCue: { + prototype: TextTrackCue; + new (): TextTrackCue; +} + +interface MSStreamReader extends MSBaseReader { + error: DOMError; + readAsArrayBuffer(stream: MSStream, size?: number): void; + readAsBlob(stream: MSStream, size?: number): void; + readAsDataURL(stream: MSStream, size?: number): void; + readAsText(stream: MSStream, encoding?: string, size?: number): void; +} +declare var MSStreamReader: { + prototype: MSStreamReader; + new (): MSStreamReader; +} + +interface DOMTokenList { + length: number; + contains(token: string): boolean; + remove(token: string): void; + toggle(token: string): boolean; + add(token: string): void; + item(index: number): string; + [index: number]: string; + toString(): string; +} +declare var DOMTokenList: { + prototype: DOMTokenList; + new (): DOMTokenList; +} + +interface EventException { + name: string; +} + +interface Performance { + now(): number; +} + +interface SVGFEFuncAElement extends SVGComponentTransferFunctionElement { +} +declare var SVGFEFuncAElement: { + prototype: SVGFEFuncAElement; + new (): SVGFEFuncAElement; +} + +interface SVGFETileElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { + in1: SVGAnimatedString; +} +declare var SVGFETileElement: { + prototype: SVGFETileElement; + new (): SVGFETileElement; +} + +interface SVGFEBlendElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { + in2: SVGAnimatedString; + mode: SVGAnimatedEnumeration; + in1: SVGAnimatedString; + SVG_FEBLEND_MODE_DARKEN: number; + SVG_FEBLEND_MODE_UNKNOWN: number; + SVG_FEBLEND_MODE_MULTIPLY: number; + SVG_FEBLEND_MODE_NORMAL: number; + SVG_FEBLEND_MODE_SCREEN: number; + SVG_FEBLEND_MODE_LIGHTEN: number; +} +declare var SVGFEBlendElement: { + prototype: SVGFEBlendElement; + new (): SVGFEBlendElement; + SVG_FEBLEND_MODE_DARKEN: number; + SVG_FEBLEND_MODE_UNKNOWN: number; + SVG_FEBLEND_MODE_MULTIPLY: number; + SVG_FEBLEND_MODE_NORMAL: number; + SVG_FEBLEND_MODE_SCREEN: number; + SVG_FEBLEND_MODE_LIGHTEN: number; +} + +interface WindowTimers extends WindowTimersExtension { +} +declare var WindowTimers: { + prototype: WindowTimers; + new (): WindowTimers; +} + +interface CSSStyleDeclaration { + animationFillMode: string; + floodColor: string; + animationIterationCount: string; + textShadow: string; + backfaceVisibility: string; + msAnimationIterationCount: string; + animationDelay: string; + animationTimingFunction: string; + columnWidth: any; + msScrollSnapX: string; + columnRuleColor: any; + columnRuleWidth: any; + transitionDelay: string; + transition: string; + msFlowFrom: string; + msScrollSnapType: string; + msContentZoomSnapType: string; + msGridColumns: string; + msAnimationName: string; + msGridRowAlign: string; + msContentZoomChaining: string; + msGridColumn: any; + msHyphenateLimitZone: any; + msScrollRails: string; + msAnimationDelay: string; + enableBackground: string; + msWrapThrough: string; + columnRuleStyle: string; + msAnimation: string; + msFlexFlow: string; + msScrollSnapY: string; + msHyphenateLimitLines: any; + msTouchAction: string; + msScrollLimit: string; + animation: string; + transform: string; + filter: string; + colorInterpolationFilters: string; + transitionTimingFunction: string; + msBackfaceVisibility: string; + animationPlayState: string; + transformOrigin: string; + msScrollLimitYMin: any; + msFontFeatureSettings: string; + msContentZoomLimitMin: any; + columnGap: any; + transitionProperty: string; + msAnimationDuration: string; + msAnimationFillMode: string; + msFlexDirection: string; + msTransitionDuration: string; + fontFeatureSettings: string; + breakBefore: string; + msFlexWrap: string; + perspective: string; + msFlowInto: string; + msTransformStyle: string; + msScrollTranslation: string; + msTransitionProperty: string; + msUserSelect: string; + msOverflowStyle: string; + msScrollSnapPointsY: string; + animationDirection: string; + animationDuration: string; + msFlex: string; + msTransitionTimingFunction: string; + animationName: string; + columnRule: string; + msGridColumnSpan: any; + msFlexNegative: string; + columnFill: string; + msGridRow: any; + msFlexOrder: string; + msFlexItemAlign: string; + msFlexPositive: string; + msContentZoomLimitMax: any; + msScrollLimitYMax: any; + msGridColumnAlign: string; + perspectiveOrigin: string; + lightingColor: string; + columns: string; + msScrollChaining: string; + msHyphenateLimitChars: string; + msTouchSelect: string; + floodOpacity: string; + msAnimationDirection: string; + msAnimationPlayState: string; + columnSpan: string; + msContentZooming: string; + msPerspective: string; + msFlexPack: string; + msScrollSnapPointsX: string; + msContentZoomSnapPoints: string; + msGridRowSpan: any; + msContentZoomSnap: string; + msScrollLimitXMin: any; + breakInside: string; + msHighContrastAdjust: string; + msFlexLinePack: string; + msGridRows: string; + transitionDuration: string; + msHyphens: string; + breakAfter: string; + msTransition: string; + msPerspectiveOrigin: string; + msContentZoomLimit: string; + msScrollLimitXMax: any; + msFlexAlign: string; + msWrapMargin: any; + columnCount: any; + msAnimationTimingFunction: string; + msTransitionDelay: string; + transformStyle: string; + msWrapFlow: string; + msFlexPreferredSize: string; +} + +interface MessageChannel { + port2: MessagePort; + port1: MessagePort; +} +declare var MessageChannel: { + prototype: MessageChannel; + new (): MessageChannel; +} + +interface SVGFEMergeElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { +} +declare var SVGFEMergeElement: { + prototype: SVGFEMergeElement; + new (): SVGFEMergeElement; +} + +interface Navigator extends MSFileSaver { + msMaxTouchPoints: number; + msPointerEnabled: boolean; + msManipulationViewsEnabled: boolean; + msLaunchUri(uri: string, successCallback?: MSLaunchUriCallback, noHandlerCallback?: MSLaunchUriCallback): void; +} + +interface TransitionEvent extends Event { + propertyName: string; + elapsedTime: number; + initTransitionEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, propertyNameArg: string, elapsedTimeArg: number): void; +} +declare var TransitionEvent: { + prototype: TransitionEvent; + new (): TransitionEvent; +} + +interface MediaQueryList { + matches: boolean; + media: string; + addListener(listener: MediaQueryListListener): void; + removeListener(listener: MediaQueryListListener): void; +} +declare var MediaQueryList: { + prototype: MediaQueryList; + new (): MediaQueryList; +} + +interface DOMError { + name: string; + toString(): string; +} +declare var DOMError: { + prototype: DOMError; + new (): DOMError; +} + +interface CloseEvent extends Event { + wasClean: boolean; + reason: string; + code: number; + initCloseEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, wasCleanArg: boolean, codeArg: number, reasonArg: string): void; +} +declare var CloseEvent: { + prototype: CloseEvent; + new (): CloseEvent; +} + +interface WebSocket extends EventTarget { + protocol: string; + readyState: number; + bufferedAmount: number; + onopen: (ev: Event) => any; + addEventListener(type: "open", listener: (ev: Event) => any, useCapture?: boolean): void; + extensions: string; + onmessage: (ev: any) => any; + addEventListener(type: "message", listener: (ev: any) => any, useCapture?: boolean): void; + onclose: (ev: CloseEvent) => any; + addEventListener(type: "close", listener: (ev: CloseEvent) => any, useCapture?: boolean): void; + onerror: (ev: ErrorEvent) => any; + addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; + binaryType: string; + url: string; + close(code?: number, reason?: string): void; + send(data: any): void; + addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; + OPEN: number; + CLOSING: number; + CONNECTING: number; + CLOSED: number; +} +declare var WebSocket: { + prototype: WebSocket; + new (url: string): WebSocket; + new (url: string, prototcol: string): WebSocket; + new (url: string, prototcol: string[]): WebSocket; + OPEN: number; + CLOSING: number; + CONNECTING: number; + CLOSED: number; +} + +interface SVGFEPointLightElement extends SVGElement { + y: SVGAnimatedNumber; + x: SVGAnimatedNumber; + z: SVGAnimatedNumber; +} +declare var SVGFEPointLightElement: { + prototype: SVGFEPointLightElement; + new (): SVGFEPointLightElement; +} + +interface ProgressEvent extends Event { + loaded: number; + lengthComputable: boolean; + total: number; + initProgressEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, lengthComputableArg: boolean, loadedArg: number, totalArg: number): void; +} +declare var ProgressEvent: { + prototype: ProgressEvent; + new (): ProgressEvent; +} + +interface IDBObjectStore { + indexNames: DOMStringList; + name: string; + transaction: IDBTransaction; + keyPath: string; + count(key?: any): IDBRequest; + add(value: any, key?: any): IDBRequest; + clear(): IDBRequest; + createIndex(name: string, keyPath: string, optionalParameters?: any): IDBIndex; + put(value: any, key?: any): IDBRequest; + openCursor(range?: any, direction?: string): IDBRequest; + deleteIndex(indexName: string): void; + index(name: string): IDBIndex; + get(key: any): IDBRequest; + delete(key: any): IDBRequest; +} +declare var IDBObjectStore: { + prototype: IDBObjectStore; + new (): IDBObjectStore; +} + +interface HTMLCanvasElement { + msToBlob(): Blob; +} + +interface SVGFEGaussianBlurElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { + stdDeviationX: SVGAnimatedNumber; + in1: SVGAnimatedString; + stdDeviationY: SVGAnimatedNumber; + setStdDeviation(stdDeviationX: number, stdDeviationY: number): void; +} +declare var SVGFEGaussianBlurElement: { + prototype: SVGFEGaussianBlurElement; + new (): SVGFEGaussianBlurElement; +} + +interface SVGFilterPrimitiveStandardAttributes extends SVGStylable { + y: SVGAnimatedLength; + width: SVGAnimatedLength; + x: SVGAnimatedLength; + height: SVGAnimatedLength; + result: SVGAnimatedString; +} + +interface Element { + msRegionOverflow: string; + onmspointerdown: (ev: any) => any; + addEventListener(type: "mspointerdown", listener: (ev: any) => any, useCapture?: boolean): void; + onmsgotpointercapture: (ev: any) => any; + addEventListener(type: "msgotpointercapture", listener: (ev: any) => any, useCapture?: boolean): void; + onmsgesturedoubletap: (ev: any) => any; + addEventListener(type: "msgesturedoubletap", listener: (ev: any) => any, useCapture?: boolean): void; + onmspointerhover: (ev: any) => any; + addEventListener(type: "mspointerhover", listener: (ev: any) => any, useCapture?: boolean): void; + onmsgesturehold: (ev: any) => any; + addEventListener(type: "msgesturehold", listener: (ev: any) => any, useCapture?: boolean): void; + onmspointermove: (ev: any) => any; + addEventListener(type: "mspointermove", listener: (ev: any) => any, useCapture?: boolean): void; + onmsgesturechange: (ev: any) => any; + addEventListener(type: "msgesturechange", listener: (ev: any) => any, useCapture?: boolean): void; + onmsgesturestart: (ev: any) => any; + addEventListener(type: "msgesturestart", listener: (ev: any) => any, useCapture?: boolean): void; + onmspointercancel: (ev: any) => any; + addEventListener(type: "mspointercancel", listener: (ev: any) => any, useCapture?: boolean): void; + onmsgestureend: (ev: any) => any; + addEventListener(type: "msgestureend", listener: (ev: any) => any, useCapture?: boolean): void; + onmsgesturetap: (ev: any) => any; + addEventListener(type: "msgesturetap", listener: (ev: any) => any, useCapture?: boolean): void; + onmspointerout: (ev: any) => any; + addEventListener(type: "mspointerout", listener: (ev: any) => any, useCapture?: boolean): void; + onmsinertiastart: (ev: any) => any; + addEventListener(type: "msinertiastart", listener: (ev: any) => any, useCapture?: boolean): void; + onmslostpointercapture: (ev: any) => any; + addEventListener(type: "mslostpointercapture", listener: (ev: any) => any, useCapture?: boolean): void; + onmspointerover: (ev: any) => any; + addEventListener(type: "mspointerover", listener: (ev: any) => any, useCapture?: boolean): void; + msContentZoomFactor: number; + onmspointerup: (ev: any) => any; + addEventListener(type: "mspointerup", listener: (ev: any) => any, useCapture?: boolean): void; + msGetRegionContent(): MSRangeCollection; + msReleasePointerCapture(pointerId: number): void; + msSetPointerCapture(pointerId: number): void; + addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; +} + +interface IDBVersionChangeEvent extends Event { + newVersion: number; + oldVersion: number; +} +declare var IDBVersionChangeEvent: { + prototype: IDBVersionChangeEvent; + new (): IDBVersionChangeEvent; +} + +interface IDBIndex { + unique: boolean; + name: string; + keyPath: string; + objectStore: IDBObjectStore; + count(key?: any): IDBRequest; + getKey(key: any): IDBRequest; + openKeyCursor(range?: IDBKeyRange, direction?: string): IDBRequest; + get(key: any): IDBRequest; + openCursor(range?: IDBKeyRange, direction?: string): IDBRequest; +} +declare var IDBIndex: { + prototype: IDBIndex; + new (): IDBIndex; +} + +interface WheelEvent { + getCurrentPoint(element: Element): void; +} + +interface FileList { + length: number; + item(index: number): File; + [index: number]: File; +} +declare var FileList: { + prototype: FileList; + new (): FileList; +} + +interface IDBCursor { + source: any; + direction: string; + key: any; + primaryKey: any; + advance(count: number): void; + delete(): IDBRequest; + continue(key?: any): void; + update(value: any): IDBRequest; + PREV: string; + PREV_NO_DUPLICATE: string; + NEXT: string; + NEXT_NO_DUPLICATE: string; +} +declare var IDBCursor: { + prototype: IDBCursor; + new (): IDBCursor; + PREV: string; + PREV_NO_DUPLICATE: string; + NEXT: string; + NEXT_NO_DUPLICATE: string; +} + +interface SVGFESpecularLightingElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { + kernelUnitLengthY: SVGAnimatedNumber; + surfaceScale: SVGAnimatedNumber; + specularExponent: SVGAnimatedNumber; + in1: SVGAnimatedString; + kernelUnitLengthX: SVGAnimatedNumber; + specularConstant: SVGAnimatedNumber; +} +declare var SVGFESpecularLightingElement: { + prototype: SVGFESpecularLightingElement; + new (): SVGFESpecularLightingElement; +} + +interface File extends Blob { + lastModifiedDate: any; + name: string; +} +declare var File: { + prototype: File; + new (): File; +} + +interface URL { + revokeObjectURL(url: string): void; + createObjectURL(object: any, options?: ObjectURLOptions): string; +} +declare var URL: URL; + +interface RangeException { + name: string; +} + +interface IDBCursorWithValue extends IDBCursor { + value: any; +} +declare var IDBCursorWithValue: { + prototype: IDBCursorWithValue; + new (): IDBCursorWithValue; +} + +interface HTMLTextAreaElement { + validationMessage: string; + autofocus: boolean; + validity: ValidityState; + required: boolean; + maxLength: number; + willValidate: boolean; + placeholder: string; + checkValidity(): boolean; + setCustomValidity(error: string): void; +} + +interface XMLHttpRequestEventTarget extends EventTarget { + onprogress: (ev: ProgressEvent) => any; + addEventListener(type: "progress", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; + onerror: (ev: ErrorEvent) => any; + addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; + onload: (ev: any) => any; + addEventListener(type: "load", listener: (ev: any) => any, useCapture?: boolean): void; + ontimeout: (ev: any) => any; + addEventListener(type: "timeout", listener: (ev: any) => any, useCapture?: boolean): void; + onabort: (ev: any) => any; + addEventListener(type: "abort", listener: (ev: any) => any, useCapture?: boolean): void; + onloadstart: (ev: any) => any; + addEventListener(type: "loadstart", listener: (ev: any) => any, useCapture?: boolean): void; + onloadend: (ev: ProgressEvent) => any; + addEventListener(type: "loadend", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; +} +declare var XMLHttpRequestEventTarget: { + prototype: XMLHttpRequestEventTarget; + new (): XMLHttpRequestEventTarget; +} + +interface IDBEnvironment { + msIndexedDB: IDBFactory; + indexedDB: IDBFactory; +} + +interface AudioTrackList extends EventTarget { + length: number; + onchange: (ev: any) => any; + addEventListener(type: "change", listener: (ev: any) => any, useCapture?: boolean): void; + onaddtrack: (ev: TrackEvent) => any; + addEventListener(type: "addtrack", listener: (ev: TrackEvent) => any, useCapture?: boolean): void; + getTrackById(id: string): AudioTrack; + item(index: number): AudioTrack; + [index: number]: AudioTrack; + addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; +} +declare var AudioTrackList: { + prototype: AudioTrackList; + new (): AudioTrackList; +} + +interface MSBaseReader extends EventTarget { + onprogress: (ev: ProgressEvent) => any; + addEventListener(type: "progress", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; + readyState: number; + onabort: (ev: any) => any; + addEventListener(type: "abort", listener: (ev: any) => any, useCapture?: boolean): void; + onloadend: (ev: ProgressEvent) => any; + addEventListener(type: "loadend", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; + onerror: (ev: ErrorEvent) => any; + addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; + onload: (ev: any) => any; + addEventListener(type: "load", listener: (ev: any) => any, useCapture?: boolean): void; + onloadstart: (ev: any) => any; + addEventListener(type: "loadstart", listener: (ev: any) => any, useCapture?: boolean): void; + result: any; + abort(): void; + addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; + LOADING: number; + EMPTY: number; + DONE: number; +} + +interface History { + state: any; + replaceState(statedata: any, title: string, url?: string): void; + pushState(statedata: any, title: string, url?: string): void; +} + +interface SVGFEMorphologyElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { + operator: SVGAnimatedEnumeration; + radiusX: SVGAnimatedNumber; + radiusY: SVGAnimatedNumber; + in1: SVGAnimatedString; + SVG_MORPHOLOGY_OPERATOR_UNKNOWN: number; + SVG_MORPHOLOGY_OPERATOR_ERODE: number; + SVG_MORPHOLOGY_OPERATOR_DILATE: number; +} +declare var SVGFEMorphologyElement: { + prototype: SVGFEMorphologyElement; + new (): SVGFEMorphologyElement; + SVG_MORPHOLOGY_OPERATOR_UNKNOWN: number; + SVG_MORPHOLOGY_OPERATOR_ERODE: number; + SVG_MORPHOLOGY_OPERATOR_DILATE: number; +} + +interface HTMLSelectElement { + validationMessage: string; + autofocus: boolean; + validity: ValidityState; + required: boolean; + willValidate: boolean; + checkValidity(): boolean; + setCustomValidity(error: string): void; +} + +interface CSSRule { + KEYFRAMES_RULE: number; + KEYFRAME_RULE: number; + VIEWPORT_RULE: number; +} +//declare var CSSRule: { +// prototype: CSSRule; +// KEYFRAMES_RULE: number; +// KEYFRAME_RULE: number; +// VIEWPORT_RULE: number; +//} + +interface SVGFEFuncRElement extends SVGComponentTransferFunctionElement { +} +declare var SVGFEFuncRElement: { + prototype: SVGFEFuncRElement; + new (): SVGFEFuncRElement; +} + +interface WindowTimersExtension { + msSetImmediate(expression: any, ...args: any[]): number; + clearImmediate(handle: number): void; + msClearImmediate(handle: number): void; + setImmediate(expression: any, ...args: any[]): number; +} + +interface SVGFEDisplacementMapElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { + in2: SVGAnimatedString; + xChannelSelector: SVGAnimatedEnumeration; + yChannelSelector: SVGAnimatedEnumeration; + scale: SVGAnimatedNumber; + in1: SVGAnimatedString; + SVG_CHANNEL_B: number; + SVG_CHANNEL_R: number; + SVG_CHANNEL_G: number; + SVG_CHANNEL_UNKNOWN: number; + SVG_CHANNEL_A: number; +} +declare var SVGFEDisplacementMapElement: { + prototype: SVGFEDisplacementMapElement; + new (): SVGFEDisplacementMapElement; + SVG_CHANNEL_B: number; + SVG_CHANNEL_R: number; + SVG_CHANNEL_G: number; + SVG_CHANNEL_UNKNOWN: number; + SVG_CHANNEL_A: number; +} + +interface AnimationEvent extends Event { + animationName: string; + elapsedTime: number; + initAnimationEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, animationNameArg: string, elapsedTimeArg: number): void; +} +declare var AnimationEvent: { + prototype: AnimationEvent; + new (): AnimationEvent; +} + +interface SVGComponentTransferFunctionElement extends SVGElement { + tableValues: SVGAnimatedNumberList; + slope: SVGAnimatedNumber; + type: SVGAnimatedEnumeration; + exponent: SVGAnimatedNumber; + amplitude: SVGAnimatedNumber; + intercept: SVGAnimatedNumber; + offset: SVGAnimatedNumber; + SVG_FECOMPONENTTRANSFER_TYPE_UNKNOWN: number; + SVG_FECOMPONENTTRANSFER_TYPE_TABLE: number; + SVG_FECOMPONENTTRANSFER_TYPE_IDENTITY: number; + SVG_FECOMPONENTTRANSFER_TYPE_GAMMA: number; + SVG_FECOMPONENTTRANSFER_TYPE_DISCRETE: number; + SVG_FECOMPONENTTRANSFER_TYPE_LINEAR: number; +} +declare var SVGComponentTransferFunctionElement: { + prototype: SVGComponentTransferFunctionElement; + new (): SVGComponentTransferFunctionElement; + SVG_FECOMPONENTTRANSFER_TYPE_UNKNOWN: number; + SVG_FECOMPONENTTRANSFER_TYPE_TABLE: number; + SVG_FECOMPONENTTRANSFER_TYPE_IDENTITY: number; + SVG_FECOMPONENTTRANSFER_TYPE_GAMMA: number; + SVG_FECOMPONENTTRANSFER_TYPE_DISCRETE: number; + SVG_FECOMPONENTTRANSFER_TYPE_LINEAR: number; +} + +interface MSRangeCollection { + length: number; + item(index: number): Range; + [index: number]: Range; +} +declare var MSRangeCollection: { + prototype: MSRangeCollection; + new (): MSRangeCollection; +} + +interface SVGFEDistantLightElement extends SVGElement { + azimuth: SVGAnimatedNumber; + elevation: SVGAnimatedNumber; +} +declare var SVGFEDistantLightElement: { + prototype: SVGFEDistantLightElement; + new (): SVGFEDistantLightElement; +} + +interface SVGException { + name: string; +} + +interface SVGFEFuncBElement extends SVGComponentTransferFunctionElement { +} +declare var SVGFEFuncBElement: { + prototype: SVGFEFuncBElement; + new (): SVGFEFuncBElement; +} + +interface IDBKeyRange { + upper: any; + upperOpen: boolean; + lower: any; + lowerOpen: boolean; + bound(lower: any, upper: any, lowerOpen?: boolean, upperOpen?: boolean): IDBKeyRange; + only(value: any): IDBKeyRange; + lowerBound(bound: any, open?: boolean): IDBKeyRange; + upperBound(bound: any, open?: boolean): IDBKeyRange; +} +declare var IDBKeyRange: { + prototype: IDBKeyRange; + new (): IDBKeyRange; +} + +interface WindowConsole { + console: Console; +} + +interface IDBTransaction extends EventTarget { + oncomplete: (ev: Event) => any; + addEventListener(type: "complete", listener: (ev: Event) => any, useCapture?: boolean): void; + db: IDBDatabase; + mode: string; + error: DOMError; + onerror: (ev: ErrorEvent) => any; + addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; + onabort: (ev: any) => any; + addEventListener(type: "abort", listener: (ev: any) => any, useCapture?: boolean): void; + abort(): void; + objectStore(name: string): IDBObjectStore; + addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; + READ_ONLY: string; + VERSION_CHANGE: string; + READ_WRITE: string; +} +declare var IDBTransaction: { + prototype: IDBTransaction; + new (): IDBTransaction; + READ_ONLY: string; + VERSION_CHANGE: string; + READ_WRITE: string; +} + +interface AudioTrack { + kind: string; + language: string; + id: string; + label: string; + enabled: boolean; +} +declare var AudioTrack: { + prototype: AudioTrack; + new (): AudioTrack; +} + +interface SVGFEConvolveMatrixElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { + orderY: SVGAnimatedInteger; + kernelUnitLengthY: SVGAnimatedNumber; + orderX: SVGAnimatedInteger; + preserveAlpha: SVGAnimatedBoolean; + kernelMatrix: SVGAnimatedNumberList; + edgeMode: SVGAnimatedEnumeration; + kernelUnitLengthX: SVGAnimatedNumber; + bias: SVGAnimatedNumber; + targetX: SVGAnimatedInteger; + targetY: SVGAnimatedInteger; + divisor: SVGAnimatedNumber; + in1: SVGAnimatedString; + SVG_EDGEMODE_WRAP: number; + SVG_EDGEMODE_DUPLICATE: number; + SVG_EDGEMODE_UNKNOWN: number; + SVG_EDGEMODE_NONE: number; +} +declare var SVGFEConvolveMatrixElement: { + prototype: SVGFEConvolveMatrixElement; + new (): SVGFEConvolveMatrixElement; + SVG_EDGEMODE_WRAP: number; + SVG_EDGEMODE_DUPLICATE: number; + SVG_EDGEMODE_UNKNOWN: number; + SVG_EDGEMODE_NONE: number; +} + +interface TextTrackCueList { + length: number; + item(index: number): TextTrackCue; + [index: number]: TextTrackCue; + getCueById(id: string): TextTrackCue; +} +declare var TextTrackCueList: { + prototype: TextTrackCueList; + new (): TextTrackCueList; +} + +interface CSSKeyframesRule extends CSSRule { + name: string; + cssRules: CSSRuleList; + findRule(rule: string): CSSKeyframeRule; + deleteRule(rule: string): void; + appendRule(rule: string): void; +} +declare var CSSKeyframesRule: { + prototype: CSSKeyframesRule; + new (): CSSKeyframesRule; +} + +interface Window extends WindowBase64, IDBEnvironment, WindowConsole { + onmspointerdown: (ev: any) => any; + addEventListener(type: "mspointerdown", listener: (ev: any) => any, useCapture?: boolean): void; + animationStartTime: number; + onmsgesturedoubletap: (ev: any) => any; + addEventListener(type: "msgesturedoubletap", listener: (ev: any) => any, useCapture?: boolean): void; + onmspointerhover: (ev: any) => any; + addEventListener(type: "mspointerhover", listener: (ev: any) => any, useCapture?: boolean): void; + onmsgesturehold: (ev: any) => any; + addEventListener(type: "msgesturehold", listener: (ev: any) => any, useCapture?: boolean): void; + onmspointermove: (ev: any) => any; + addEventListener(type: "mspointermove", listener: (ev: any) => any, useCapture?: boolean): void; + onmsgesturechange: (ev: any) => any; + addEventListener(type: "msgesturechange", listener: (ev: any) => any, useCapture?: boolean): void; + onmsgesturestart: (ev: any) => any; + addEventListener(type: "msgesturestart", listener: (ev: any) => any, useCapture?: boolean): void; + onmspointercancel: (ev: any) => any; + addEventListener(type: "mspointercancel", listener: (ev: any) => any, useCapture?: boolean): void; + onmsgestureend: (ev: any) => any; + addEventListener(type: "msgestureend", listener: (ev: any) => any, useCapture?: boolean): void; + onmsgesturetap: (ev: any) => any; + addEventListener(type: "msgesturetap", listener: (ev: any) => any, useCapture?: boolean): void; + onmspointerout: (ev: any) => any; + addEventListener(type: "mspointerout", listener: (ev: any) => any, useCapture?: boolean): void; + msAnimationStartTime: number; + applicationCache: ApplicationCache; + onmsinertiastart: (ev: any) => any; + addEventListener(type: "msinertiastart", listener: (ev: any) => any, useCapture?: boolean): void; + onmspointerover: (ev: any) => any; + addEventListener(type: "mspointerover", listener: (ev: any) => any, useCapture?: boolean): void; + onpopstate: (ev: PopStateEvent) => any; + addEventListener(type: "popstate", listener: (ev: PopStateEvent) => any, useCapture?: boolean): void; + onmspointerup: (ev: any) => any; + addEventListener(type: "mspointerup", listener: (ev: any) => any, useCapture?: boolean): void; + msCancelRequestAnimationFrame(handle: number): void; + matchMedia(mediaQuery: string): MediaQueryList; + cancelAnimationFrame(handle: number): void; + msIsStaticHTML(html: string): boolean; + msMatchMedia(mediaQuery: string): MediaQueryList; + requestAnimationFrame(callback: FrameRequestCallback): number; + msRequestAnimationFrame(callback: FrameRequestCallback): number; +} + +interface SVGFETurbulenceElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { + baseFrequencyX: SVGAnimatedNumber; + numOctaves: SVGAnimatedInteger; + type: SVGAnimatedEnumeration; + baseFrequencyY: SVGAnimatedNumber; + stitchTiles: SVGAnimatedEnumeration; + seed: SVGAnimatedNumber; + SVG_STITCHTYPE_UNKNOWN: number; + SVG_STITCHTYPE_NOSTITCH: number; + SVG_TURBULENCE_TYPE_UNKNOWN: number; + SVG_TURBULENCE_TYPE_TURBULENCE: number; + SVG_TURBULENCE_TYPE_FRACTALNOISE: number; + SVG_STITCHTYPE_STITCH: number; +} +declare var SVGFETurbulenceElement: { + prototype: SVGFETurbulenceElement; + new (): SVGFETurbulenceElement; + SVG_STITCHTYPE_UNKNOWN: number; + SVG_STITCHTYPE_NOSTITCH: number; + SVG_TURBULENCE_TYPE_UNKNOWN: number; + SVG_TURBULENCE_TYPE_TURBULENCE: number; + SVG_TURBULENCE_TYPE_FRACTALNOISE: number; + SVG_STITCHTYPE_STITCH: number; +} + +interface TextTrackList { + length: number; + item(index: number): TextTrack; + [index: number]: TextTrack; +} +declare var TextTrackList: { + prototype: TextTrackList; + new (): TextTrackList; +} + +interface SVGFEFuncGElement extends SVGComponentTransferFunctionElement { +} +declare var SVGFEFuncGElement: { + prototype: SVGFEFuncGElement; + new (): SVGFEFuncGElement; +} + +interface SVGFEColorMatrixElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { + in1: SVGAnimatedString; + type: SVGAnimatedEnumeration; + values: SVGAnimatedNumberList; + SVG_FECOLORMATRIX_TYPE_SATURATE: number; + SVG_FECOLORMATRIX_TYPE_UNKNOWN: number; + SVG_FECOLORMATRIX_TYPE_MATRIX: number; + SVG_FECOLORMATRIX_TYPE_HUEROTATE: number; + SVG_FECOLORMATRIX_TYPE_LUMINANCETOALPHA: number; +} +declare var SVGFEColorMatrixElement: { + prototype: SVGFEColorMatrixElement; + new (): SVGFEColorMatrixElement; + SVG_FECOLORMATRIX_TYPE_SATURATE: number; + SVG_FECOLORMATRIX_TYPE_UNKNOWN: number; + SVG_FECOLORMATRIX_TYPE_MATRIX: number; + SVG_FECOLORMATRIX_TYPE_HUEROTATE: number; + SVG_FECOLORMATRIX_TYPE_LUMINANCETOALPHA: number; +} + +interface Console { + info(message?: any, ...optionalParams: any[]): void; + profile(reportName?: string): void; + assert(test?: boolean, message?: string, ...optionalParams: any[]): void; + msIsIndependentlyComposed(element: Element): boolean; + clear(): void; + dir(value?: any, ...optionalParams: any[]): void; + warn(message?: any, ...optionalParams: any[]): void; + error(message?: any, ...optionalParams: any[]): void; + log(message?: any, ...optionalParams: any[]): void; + profileEnd(): void; +} +declare var Console: { + prototype: Console; + new (): Console; +} + +interface SVGFESpotLightElement extends SVGElement { + pointsAtY: SVGAnimatedNumber; + y: SVGAnimatedNumber; + limitingConeAngle: SVGAnimatedNumber; + specularExponent: SVGAnimatedNumber; + x: SVGAnimatedNumber; + pointsAtZ: SVGAnimatedNumber; + z: SVGAnimatedNumber; + pointsAtX: SVGAnimatedNumber; +} +declare var SVGFESpotLightElement: { + prototype: SVGFESpotLightElement; + new (): SVGFESpotLightElement; +} + +interface HTMLImageElement { + msPlayToPrimary: boolean; + msPlayToDisabled: boolean; + msPlayToSource: any; +} + +interface WindowBase64 { + btoa(rawString: string): string; + atob(encodedString: string): string; +} + +interface IDBDatabase extends EventTarget { + version: string; + name: string; + objectStoreNames: DOMStringList; + onerror: (ev: ErrorEvent) => any; + addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; + onabort: (ev: any) => any; + addEventListener(type: "abort", listener: (ev: any) => any, useCapture?: boolean): void; + createObjectStore(name: string, optionalParameters?: any): IDBObjectStore; + close(): void; + transaction(storeNames: any, mode?: string): IDBTransaction; + deleteObjectStore(name: string): void; + addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; +} +declare var IDBDatabase: { + prototype: IDBDatabase; + new (): IDBDatabase; +} + +interface DOMStringList { + length: number; + contains(str: string): boolean; + item(index: number): string; + [index: number]: string; +} +declare var DOMStringList: { + prototype: DOMStringList; + new (): DOMStringList; +} + +interface HTMLButtonElement { + validationMessage: string; + formTarget: string; + willValidate: boolean; + formAction: string; + autofocus: boolean; + validity: ValidityState; + formNoValidate: string; + formEnctype: string; + formMethod: string; + checkValidity(): boolean; + setCustomValidity(error: string): void; +} + +interface IDBOpenDBRequest extends IDBRequest { + onupgradeneeded: (ev: IDBVersionChangeEvent) => any; + addEventListener(type: "upgradeneeded", listener: (ev: IDBVersionChangeEvent) => any, useCapture?: boolean): void; + onblocked: (ev: Event) => any; + addEventListener(type: "blocked", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; +} +declare var IDBOpenDBRequest: { + prototype: IDBOpenDBRequest; + new (): IDBOpenDBRequest; +} + +interface HTMLProgressElement extends HTMLElement { + value: number; + max: number; + position: number; + form: HTMLFormElement; +} +declare var HTMLProgressElement: { + prototype: HTMLProgressElement; + new (): HTMLProgressElement; +} + +interface MSLaunchUriCallback { + (): void; +} + +interface SVGFEOffsetElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { + dy: SVGAnimatedNumber; + in1: SVGAnimatedString; + dx: SVGAnimatedNumber; +} +declare var SVGFEOffsetElement: { + prototype: SVGFEOffsetElement; + new (): SVGFEOffsetElement; +} + +interface HTMLFormElement { + autocomplete: string; + noValidate: boolean; + checkValidity(): boolean; +} + +interface MSUnsafeFunctionCallback { + (): any; +} + +interface Document { + onmspointerdown: (ev: any) => any; + addEventListener(type: "mspointerdown", listener: (ev: any) => any, useCapture?: boolean): void; + msHidden: boolean; + msVisibilityState: string; + onmsgesturedoubletap: (ev: any) => any; + addEventListener(type: "msgesturedoubletap", listener: (ev: any) => any, useCapture?: boolean): void; + visibilityState: string; + onmsmanipulationstatechanged: (ev: any) => any; + addEventListener(type: "msmanipulationstatechanged", listener: (ev: any) => any, useCapture?: boolean): void; + onmspointerhover: (ev: any) => any; + addEventListener(type: "mspointerhover", listener: (ev: any) => any, useCapture?: boolean): void; + onmscontentzoom: (ev: any) => any; + addEventListener(type: "mscontentzoom", listener: (ev: any) => any, useCapture?: boolean): void; + onmspointermove: (ev: any) => any; + addEventListener(type: "mspointermove", listener: (ev: any) => any, useCapture?: boolean): void; + onmsgesturehold: (ev: any) => any; + addEventListener(type: "msgesturehold", listener: (ev: any) => any, useCapture?: boolean): void; + onmsgesturechange: (ev: any) => any; + addEventListener(type: "msgesturechange", listener: (ev: any) => any, useCapture?: boolean): void; + onmsgesturestart: (ev: any) => any; + addEventListener(type: "msgesturestart", listener: (ev: any) => any, useCapture?: boolean): void; + onmspointercancel: (ev: any) => any; + addEventListener(type: "mspointercancel", listener: (ev: any) => any, useCapture?: boolean): void; + onmsgestureend: (ev: any) => any; + addEventListener(type: "msgestureend", listener: (ev: any) => any, useCapture?: boolean): void; + onmsgesturetap: (ev: any) => any; + addEventListener(type: "msgesturetap", listener: (ev: any) => any, useCapture?: boolean): void; + onmspointerout: (ev: any) => any; + addEventListener(type: "mspointerout", listener: (ev: any) => any, useCapture?: boolean): void; + onmsinertiastart: (ev: any) => any; + addEventListener(type: "msinertiastart", listener: (ev: any) => any, useCapture?: boolean): void; + msCSSOMElementFloatMetrics: boolean; + onmspointerover: (ev: any) => any; + addEventListener(type: "mspointerover", listener: (ev: any) => any, useCapture?: boolean): void; + hidden: boolean; + onmspointerup: (ev: any) => any; + addEventListener(type: "mspointerup", listener: (ev: any) => any, useCapture?: boolean): void; + msElementsFromPoint(x: number, y: number): NodeList; + msElementsFromRect(left: number, top: number, width: number, height: number): NodeList; + clear(): void; +} + +interface MessageEvent extends Event { + ports: any; +} + +interface HTMLScriptElement { + async: boolean; +} + +interface HTMLMediaElement { + msAudioCategory: string; + msRealTime: boolean; + msPlayToPrimary: boolean; + textTracks: TextTrackList; + msPlayToDisabled: boolean; + audioTracks: AudioTrackList; + msPlayToSource: any; + msAudioDeviceType: string; + msClearEffects(): void; + msSetMediaProtectionManager(mediaProtectionManager?: any): void; + msInsertAudioEffect(activatableClassId: string, effectRequired: boolean, config?: any): void; +} + +interface TextTrack extends EventTarget { + language: string; + mode: any; + readyState: number; + activeCues: TextTrackCueList; + cues: TextTrackCueList; + oncuechange: (ev: Event) => any; + addEventListener(type: "cuechange", listener: (ev: Event) => any, useCapture?: boolean): void; + kind: string; + onload: (ev: any) => any; + addEventListener(type: "load", listener: (ev: any) => any, useCapture?: boolean): void; + onerror: (ev: ErrorEvent) => any; + addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; + label: string; + addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; + ERROR: number; + SHOWING: number; + LOADING: number; + LOADED: number; + NONE: number; + HIDDEN: number; + DISABLED: number; +} +declare var TextTrack: { + prototype: TextTrack; + new (): TextTrack; + ERROR: number; + SHOWING: number; + LOADING: number; + LOADED: number; + NONE: number; + HIDDEN: number; + DISABLED: number; +} + +interface MediaQueryListListener { + (mql: MediaQueryList): void; +} + +interface IDBRequest extends EventTarget { + source: any; + onsuccess: (ev: Event) => any; + addEventListener(type: "success", listener: (ev: Event) => any, useCapture?: boolean): void; + error: DOMError; + transaction: IDBTransaction; + onerror: (ev: ErrorEvent) => any; + addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; + readyState: string; + result: any; + addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; +} +declare var IDBRequest: { + prototype: IDBRequest; + new (): IDBRequest; +} + +interface MessagePort extends EventTarget { + onmessage: (ev: any) => any; + addEventListener(type: "message", listener: (ev: any) => any, useCapture?: boolean): void; + close(): void; + postMessage(message: any, ports?: any): void; + start(): void; + addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; +} +declare var MessagePort: { + prototype: MessagePort; + new (): MessagePort; +} + +interface FileReader extends MSBaseReader { + error: DOMError; + readAsArrayBuffer(blob: Blob): void; + readAsDataURL(blob: Blob): void; + readAsText(blob: Blob, encoding?: string): void; +} +declare var FileReader: { + prototype: FileReader; + new (): FileReader; +} + +interface BlobPropertyBag { + type?: string; + endings?: string; +} + +interface Blob { + type: string; + size: number; + msDetachStream(): any; + slice(start?: number, end?: number, contentType?: string): Blob; + close(): void; + msClose(): void; +} +declare var Blob: { + prototype: Blob; + new (blobParts?: any[], options?: BlobPropertyBag): Blob; +} + +interface ApplicationCache extends EventTarget { + status: number; + ondownloading: (ev: Event) => any; + addEventListener(type: "downloading", listener: (ev: Event) => any, useCapture?: boolean): void; + onprogress: (ev: ProgressEvent) => any; + addEventListener(type: "progress", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; + onupdateready: (ev: Event) => any; + addEventListener(type: "updateready", listener: (ev: Event) => any, useCapture?: boolean): void; + oncached: (ev: Event) => any; + addEventListener(type: "cached", listener: (ev: Event) => any, useCapture?: boolean): void; + onobsolete: (ev: Event) => any; + addEventListener(type: "obsolete", listener: (ev: Event) => any, useCapture?: boolean): void; + onerror: (ev: ErrorEvent) => any; + addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; + onchecking: (ev: Event) => any; + addEventListener(type: "checking", listener: (ev: Event) => any, useCapture?: boolean): void; + onnoupdate: (ev: Event) => any; + addEventListener(type: "noupdate", listener: (ev: Event) => any, useCapture?: boolean): void; + swapCache(): void; + abort(): void; + update(): void; + addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; + CHECKING: number; + UNCACHED: number; + UPDATEREADY: number; + DOWNLOADING: number; + IDLE: number; + OBSOLETE: number; +} +declare var ApplicationCache: { + prototype: ApplicationCache; + new (): ApplicationCache; + CHECKING: number; + UNCACHED: number; + UPDATEREADY: number; + DOWNLOADING: number; + IDLE: number; + OBSOLETE: number; +} + +interface FrameRequestCallback { + (time: number): void; +} + +interface XMLHttpRequest { + response: any; + withCredentials: boolean; + onprogress: (ev: ProgressEvent) => any; + addEventListener(type: "progress", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; + onabort: (ev: any) => any; + addEventListener(type: "abort", listener: (ev: any) => any, useCapture?: boolean): void; + responseType: string; + onloadend: (ev: ProgressEvent) => any; + addEventListener(type: "loadend", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; + upload: XMLHttpRequestEventTarget; + onerror: (ev: ErrorEvent) => any; + addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; + onloadstart: (ev: any) => any; + addEventListener(type: "loadstart", listener: (ev: any) => any, useCapture?: boolean): void; +} + +interface PopStateEvent extends Event { + state: any; + initPopStateEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, stateArg: any): void; +} +declare var PopStateEvent: { + prototype: PopStateEvent; + new (): PopStateEvent; +} + +interface CSSKeyframeRule extends CSSRule { + keyText: string; + style: CSSStyleDeclaration; +} +declare var CSSKeyframeRule: { + prototype: CSSKeyframeRule; + new (): CSSKeyframeRule; +} + +interface MSFileSaver { + msSaveBlob(blob: any, defaultName?: string): boolean; + msSaveOrOpenBlob(blob: any, defaultName?: string): boolean; +} + +interface MSStream { + type: string; + msDetachStream(): any; + msClose(): void; +} +declare var MSStream: { + prototype: MSStream; + new (): MSStream; +} + +interface MediaError { + msExtendedCode: number; +} + +interface HTMLFieldSetElement { + validationMessage: string; + validity: ValidityState; + willValidate: boolean; + checkValidity(): boolean; + setCustomValidity(error: string): void; +} + +interface MSBlobBuilder { + append(data: any, endings?: string): void; + getBlob(contentType?: string): Blob; +} +declare var MSBlobBuilder: { + prototype: MSBlobBuilder; + new (): MSBlobBuilder; +} + +interface HTMLElement { + onmscontentzoom: (ev: any) => any; + addEventListener(type: "mscontentzoom", listener: (ev: any) => any, useCapture?: boolean): void; + oncuechange: (ev: Event) => any; + addEventListener(type: "cuechange", listener: (ev: Event) => any, useCapture?: boolean): void; + spellcheck: boolean; + classList: DOMTokenList; + onmsmanipulationstatechanged: (ev: any) => any; + addEventListener(type: "msmanipulationstatechanged", listener: (ev: any) => any, useCapture?: boolean): void; + draggable: boolean; +} + +interface DataTransfer { + types: DOMStringList; + files: FileList; +} + +interface DOMSettableTokenList extends DOMTokenList { + value: string; +} +declare var DOMSettableTokenList: { + prototype: DOMSettableTokenList; + new (): DOMSettableTokenList; +} + +interface IDBFactory { + open(name: string, version?: number): IDBOpenDBRequest; + cmp(first: any, second: any): number; + deleteDatabase(name: string): IDBOpenDBRequest; +} +declare var IDBFactory: { + prototype: IDBFactory; + new (): IDBFactory; +} + +interface Range { + createContextualFragment(fragment: string): DocumentFragment; +} + +interface HTMLObjectElement { + validationMessage: string; + validity: ValidityState; + willValidate: boolean; + checkValidity(): boolean; + setCustomValidity(error: string): void; +} + +interface MSPointerEvent extends MouseEvent { + width: number; + rotation: number; + pressure: number; + pointerType: any; + isPrimary: boolean; + tiltY: number; + height: number; + intermediatePoints: any; + currentPoint: any; + tiltX: number; + hwTimestamp: number; + pointerId: number; + initPointerEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: Window, detailArg: number, screenXArg: number, screenYArg: number, clientXArg: number, clientYArg: number, ctrlKeyArg: boolean, altKeyArg: boolean, shiftKeyArg: boolean, metaKeyArg: boolean, buttonArg: number, relatedTargetArg: EventTarget, offsetXArg: number, offsetYArg: number, widthArg: number, heightArg: number, pressure: number, rotation: number, tiltX: number, tiltY: number, pointerIdArg: number, pointerType: any, hwTimestampArg: number, isPrimary: boolean): void; + getCurrentPoint(element: Element): void; + getIntermediatePoints(element: Element): void; + MSPOINTER_TYPE_PEN: number; + MSPOINTER_TYPE_MOUSE: number; + MSPOINTER_TYPE_TOUCH: number; +} +declare var MSPointerEvent: { + prototype: MSPointerEvent; + new (): MSPointerEvent; + MSPOINTER_TYPE_PEN: number; + MSPOINTER_TYPE_MOUSE: number; + MSPOINTER_TYPE_TOUCH: number; +} + +interface DOMException { + name: string; + INVALID_NODE_TYPE_ERR: number; + DATA_CLONE_ERR: number; + TIMEOUT_ERR: number; +} +//declare var DOMException: { +// prototype: DOMException; +// INVALID_NODE_TYPE_ERR: number; +// DATA_CLONE_ERR: number; +// TIMEOUT_ERR: number; +//} + +interface MSManipulationEvent extends UIEvent { + lastState: number; + currentState: number; + initMSManipulationEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: Window, detailArg: number, lastState: number, currentState: number): void; + MS_MANIPULATION_STATE_STOPPED: number; + MS_MANIPULATION_STATE_ACTIVE: number; + MS_MANIPULATION_STATE_INERTIA: number; +} +declare var MSManipulationEvent: { + prototype: MSManipulationEvent; + new (): MSManipulationEvent; + MS_MANIPULATION_STATE_STOPPED: number; + MS_MANIPULATION_STATE_ACTIVE: number; + MS_MANIPULATION_STATE_INERTIA: number; +} + +interface FormData { + append(name: any, value: any, blobName?: string): void; +} +declare var FormData: { + prototype: FormData; + new (form?: HTMLFormElement): FormData; +} + +interface HTMLDataListElement extends HTMLElement { + options: HTMLCollection; +} +declare var HTMLDataListElement: { + prototype: HTMLDataListElement; + new (): HTMLDataListElement; +} + +interface SVGFEImageElement extends SVGElement, SVGLangSpace, SVGFilterPrimitiveStandardAttributes, SVGURIReference, SVGExternalResourcesRequired { + preserveAspectRatio: SVGAnimatedPreserveAspectRatio; +} +declare var SVGFEImageElement: { + prototype: SVGFEImageElement; + new (): SVGFEImageElement; +} + +interface AbstractWorker extends EventTarget { + onerror: (ev: ErrorEvent) => any; + addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; +} + +interface SVGFECompositeElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { + operator: SVGAnimatedEnumeration; + in2: SVGAnimatedString; + k2: SVGAnimatedNumber; + k1: SVGAnimatedNumber; + k3: SVGAnimatedNumber; + in1: SVGAnimatedString; + k4: SVGAnimatedNumber; + SVG_FECOMPOSITE_OPERATOR_OUT: number; + SVG_FECOMPOSITE_OPERATOR_OVER: number; + SVG_FECOMPOSITE_OPERATOR_XOR: number; + SVG_FECOMPOSITE_OPERATOR_ARITHMETIC: number; + SVG_FECOMPOSITE_OPERATOR_UNKNOWN: number; + SVG_FECOMPOSITE_OPERATOR_IN: number; + SVG_FECOMPOSITE_OPERATOR_ATOP: number; +} +declare var SVGFECompositeElement: { + prototype: SVGFECompositeElement; + new (): SVGFECompositeElement; + SVG_FECOMPOSITE_OPERATOR_OUT: number; + SVG_FECOMPOSITE_OPERATOR_OVER: number; + SVG_FECOMPOSITE_OPERATOR_XOR: number; + SVG_FECOMPOSITE_OPERATOR_ARITHMETIC: number; + SVG_FECOMPOSITE_OPERATOR_UNKNOWN: number; + SVG_FECOMPOSITE_OPERATOR_IN: number; + SVG_FECOMPOSITE_OPERATOR_ATOP: number; +} + +interface ValidityState { + customError: boolean; + valueMissing: boolean; + stepMismatch: boolean; + rangeUnderflow: boolean; + rangeOverflow: boolean; + typeMismatch: boolean; + patternMismatch: boolean; + tooLong: boolean; + valid: boolean; +} +declare var ValidityState: { + prototype: ValidityState; + new (): ValidityState; +} + +interface HTMLTrackElement extends HTMLElement { + kind: string; + src: string; + srclang: string; + track: TextTrack; + label: string; + default: boolean; +} +declare var HTMLTrackElement: { + prototype: HTMLTrackElement; + new (): HTMLTrackElement; +} + +interface MSApp { + createFileFromStorageFile(storageFile: any): File; + createBlobFromRandomAccessStream(type: string, seeker: any): Blob; + createStreamFromInputStream(type: string, inputStream: any): MSStream; + terminateApp(exceptionObject: any): void; + createDataPackage(object: any): any; + execUnsafeLocalFunction(unsafeFunction: MSUnsafeFunctionCallback): any; + getHtmlPrintDocumentSource(htmlDoc: any): any; + addPublicLocalApplicationUri(uri: string): void; + createDataPackageFromSelection(): any; +} +declare var MSApp: MSApp; + +interface HTMLVideoElement { + msIsStereo3D: boolean; + msStereo3DPackingMode: string; + onMSVideoOptimalLayoutChanged: (ev: any) => any; + addEventListener(type: "MSVideoOptimalLayoutChanged", listener: (ev: any) => any, useCapture?: boolean): void; + onMSVideoFrameStepCompleted: (ev: any) => any; + addEventListener(type: "MSVideoFrameStepCompleted", listener: (ev: any) => any, useCapture?: boolean): void; + msStereo3DRenderMode: string; + msIsLayoutOptimalForPlayback: boolean; + msHorizontalMirror: boolean; + onMSVideoFormatChanged: (ev: any) => any; + addEventListener(type: "MSVideoFormatChanged", listener: (ev: any) => any, useCapture?: boolean): void; + msZoom: boolean; + msInsertVideoEffect(activatableClassId: string, effectRequired: boolean, config?: any): void; + msSetVideoRectangle(left: number, top: number, right: number, bottom: number): void; + msFrameStep(forward: boolean): void; + addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; +} + +interface SVGFEComponentTransferElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { + in1: SVGAnimatedString; +} +declare var SVGFEComponentTransferElement: { + prototype: SVGFEComponentTransferElement; + new (): SVGFEComponentTransferElement; +} + +interface SVGFEDiffuseLightingElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { + kernelUnitLengthY: SVGAnimatedNumber; + surfaceScale: SVGAnimatedNumber; + in1: SVGAnimatedString; + kernelUnitLengthX: SVGAnimatedNumber; + diffuseConstant: SVGAnimatedNumber; +} +declare var SVGFEDiffuseLightingElement: { + prototype: SVGFEDiffuseLightingElement; + new (): SVGFEDiffuseLightingElement; +} + +interface MSCSSMatrix { + m24: number; + m34: number; + a: number; + d: number; + m32: number; + m41: number; + m11: number; + f: number; + e: number; + m23: number; + m14: number; + m33: number; + m22: number; + m21: number; + c: number; + m12: number; + b: number; + m42: number; + m31: number; + m43: number; + m13: number; + m44: number; + multiply(secondMatrix: MSCSSMatrix): MSCSSMatrix; + skewY(angle: number): MSCSSMatrix; + setMatrixValue(value: string): void; + inverse(): MSCSSMatrix; + rotateAxisAngle(x: number, y: number, z: number, angle: number): MSCSSMatrix; + toString(): string; + rotate(angleX: number, angleY?: number, angleZ?: number): MSCSSMatrix; + translate(x: number, y: number, z?: number): MSCSSMatrix; + scale(scaleX: number, scaleY?: number, scaleZ?: number): MSCSSMatrix; + skewX(angle: number): MSCSSMatrix; +} +declare var MSCSSMatrix: { + prototype: MSCSSMatrix; + new (text?: string): MSCSSMatrix; +} + +interface Worker extends AbstractWorker { + onmessage: (ev: any) => any; + addEventListener(type: "message", listener: (ev: any) => any, useCapture?: boolean): void; + postMessage(message: any, ports?: any): void; + terminate(): void; + addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; +} +declare var Worker: { + prototype: Worker; + new (stringUrl: string): Worker; +} + +interface HTMLIFrameElement { + sandbox: DOMSettableTokenList; +} + +declare var onmspointerdown: (ev: any) => any; +declare function addEventListener(type: "mspointerdown", listener: (ev: any) => any, useCapture?: boolean): void; +declare var animationStartTime: number; +declare var onmsgesturedoubletap: (ev: any) => any; +declare function addEventListener(type: "msgesturedoubletap", listener: (ev: any) => any, useCapture?: boolean): void; +declare var onmspointerhover: (ev: any) => any; +declare function addEventListener(type: "mspointerhover", listener: (ev: any) => any, useCapture?: boolean): void; +declare var onmsgesturehold: (ev: any) => any; +declare function addEventListener(type: "msgesturehold", listener: (ev: any) => any, useCapture?: boolean): void; +declare var onmspointermove: (ev: any) => any; +declare function addEventListener(type: "mspointermove", listener: (ev: any) => any, useCapture?: boolean): void; +declare var onmsgesturechange: (ev: any) => any; +declare function addEventListener(type: "msgesturechange", listener: (ev: any) => any, useCapture?: boolean): void; +declare var onmsgesturestart: (ev: any) => any; +declare function addEventListener(type: "msgesturestart", listener: (ev: any) => any, useCapture?: boolean): void; +declare var onmspointercancel: (ev: any) => any; +declare function addEventListener(type: "mspointercancel", listener: (ev: any) => any, useCapture?: boolean): void; +declare var onmsgestureend: (ev: any) => any; +declare function addEventListener(type: "msgestureend", listener: (ev: any) => any, useCapture?: boolean): void; +declare var onmsgesturetap: (ev: any) => any; +declare function addEventListener(type: "msgesturetap", listener: (ev: any) => any, useCapture?: boolean): void; +declare var onmspointerout: (ev: any) => any; +declare function addEventListener(type: "mspointerout", listener: (ev: any) => any, useCapture?: boolean): void; +declare var msAnimationStartTime: number; +declare var applicationCache: ApplicationCache; +declare var onmsinertiastart: (ev: any) => any; +declare function addEventListener(type: "msinertiastart", listener: (ev: any) => any, useCapture?: boolean): void; +declare var onmspointerover: (ev: any) => any; +declare function addEventListener(type: "mspointerover", listener: (ev: any) => any, useCapture?: boolean): void; +declare var onpopstate: (ev: PopStateEvent) => any; +declare function addEventListener(type: "popstate", listener: (ev: PopStateEvent) => any, useCapture?: boolean): void; +declare var onmspointerup: (ev: any) => any; +declare function addEventListener(type: "mspointerup", listener: (ev: any) => any, useCapture?: boolean): void; +declare function msCancelRequestAnimationFrame(handle: number): void; +declare function matchMedia(mediaQuery: string): MediaQueryList; +declare function cancelAnimationFrame(handle: number): void; +declare function msIsStaticHTML(html: string): boolean; +declare function msMatchMedia(mediaQuery: string): MediaQueryList; +declare function requestAnimationFrame(callback: FrameRequestCallback): number; +declare function msRequestAnimationFrame(callback: FrameRequestCallback): number; +declare function btoa(rawString: string): string; +declare function atob(encodedString: string): string; +declare var msIndexedDB: IDBFactory; +declare var indexedDB: IDBFactory; +declare var console: Console; + +///////////////////////////// +/// IE11 APIs +///////////////////////////// + + + +interface StoreExceptionsInformation extends ExceptionInformation { + siteName?: string; + explanationString?: string; + detailURI?: string; +} + +interface StoreSiteSpecificExceptionsInformation extends StoreExceptionsInformation { + arrayOfDomainStrings?: Array; +} + +interface ConfirmSiteSpecificExceptionsInformation extends ExceptionInformation { + arrayOfDomainStrings?: Array; +} + +interface AlgorithmParameters { +} + +interface MutationObserverInit { + childList?: boolean; + attributes?: boolean; + characterData?: boolean; + subtree?: boolean; + attributeOldValue?: boolean; + characterDataOldValue?: boolean; + attributeFilter?: Array; +} + +interface ExceptionInformation { + domain?: string; +} + +interface MsZoomToOptions { + contentX?: number; + contentY?: number; + viewportX?: string; + viewportY?: string; + scaleFactor?: number; + animate?: string; +} + +interface DeviceAccelerationDict { + x?: number; + y?: number; + z?: number; +} + +interface DeviceRotationRateDict { + alpha?: number; + beta?: number; + gamma?: number; +} + +interface Algorithm { + name?: string; + params?: AlgorithmParameters; +} + +interface NavigatorID { + product: string; + vendor: string; +} +declare var NavigatorID: { + prototype: NavigatorID; + new (): NavigatorID; +} + +interface HTMLBodyElement { + onpageshow: (ev: PageTransitionEvent) => any; + addEventListener(type: "pageshow", listener: (ev: PageTransitionEvent) => any, useCapture?: boolean): void; + onpagehide: (ev: PageTransitionEvent) => any; + addEventListener(type: "pagehide", listener: (ev: PageTransitionEvent) => any, useCapture?: boolean): void; +} + +interface MSExecAtPriorityFunctionCallback { + (...args: any[]): any; +} + +interface MSWindowExtensions { + captureEvents(): void; + releaseEvents(): void; +} +declare var MSWindowExtensions: { + prototype: MSWindowExtensions; + new (): MSWindowExtensions; +} + +interface MSGraphicsTrust { + status: string; + constrictionActive: boolean; +} +declare var MSGraphicsTrust: { + prototype: MSGraphicsTrust; + new (): MSGraphicsTrust; +} + +interface AudioTrack { + sourceBuffer: SourceBuffer; +} + +interface DragEvent { + msConvertURL(file: File, targetType: string, targetURL?: string): boolean; +} + +interface SubtleCrypto { + unwrapKey(wrappedKey: ArrayBufferView, keyAlgorithm: any, keyEncryptionKey: Key, extractable?: boolean, keyUsages?: string[]): KeyOperation; + encrypt(algorithm: any, key: Key, buffer?: ArrayBufferView): CryptoOperation; + importKey(format: string, keyData: ArrayBufferView, algorithm: any, extractable?: boolean, keyUsages?: string[]): KeyOperation; + wrapKey(key: Key, keyEncryptionKey: Key, keyWrappingAlgorithm: any): KeyOperation; + verify(algorithm: any, key: Key, signature: ArrayBufferView, buffer?: ArrayBufferView): CryptoOperation; + deriveKey(algorithm: any, baseKey: Key, derivedKeyType: any, extractable?: boolean, keyUsages?: string[]): KeyOperation; + digest(algorithm: any, buffer?: ArrayBufferView): CryptoOperation; + exportKey(format: string, key: Key): KeyOperation; + generateKey(algorithm: any, extractable?: boolean, keyUsages?: string[]): KeyOperation; + sign(algorithm: any, key: Key, buffer?: ArrayBufferView): CryptoOperation; + decrypt(algorithm: any, key: Key, buffer?: ArrayBufferView): CryptoOperation; +} +declare var SubtleCrypto: { + prototype: SubtleCrypto; + new (): SubtleCrypto; +} + +interface Crypto extends RandomSource { + subtle: SubtleCrypto; +} +declare var Crypto: { + prototype: Crypto; + new (): Crypto; +} + +interface VideoPlaybackQuality { + creationTime: number; + totalVideoFrames: number; + droppedVideoFrames: number; +} +declare var VideoPlaybackQuality: { + prototype: VideoPlaybackQuality; + new (): VideoPlaybackQuality; +} + +interface Window { + onpageshow: (ev: PageTransitionEvent) => any; + addEventListener(type: "pageshow", listener: (ev: PageTransitionEvent) => any, useCapture?: boolean): void; + ondevicemotion: (ev: DeviceMotionEvent) => any; + addEventListener(type: "devicemotion", listener: (ev: DeviceMotionEvent) => any, useCapture?: boolean): void; + devicePixelRatio: number; + msCrypto: Crypto; + ondeviceorientation: (ev: DeviceOrientationEvent) => any; + addEventListener(type: "deviceorientation", listener: (ev: DeviceOrientationEvent) => any, useCapture?: boolean): void; + onmspointerenter: (ev: any) => any; + addEventListener(type: "mspointerenter", listener: (ev: any) => any, useCapture?: boolean): void; + onpagehide: (ev: PageTransitionEvent) => any; + addEventListener(type: "pagehide", listener: (ev: PageTransitionEvent) => any, useCapture?: boolean): void; + onmspointerleave: (ev: any) => any; + addEventListener(type: "mspointerleave", listener: (ev: any) => any, useCapture?: boolean): void; +} + +interface Key { + algorithm: Algorithm; + type: string; + extractable: boolean; + keyUsage: string[]; +} +declare var Key: { + prototype: Key; + new (): Key; +} + +interface TextTrackList extends EventTarget { + onaddtrack: (ev: any) => any; + addEventListener(type: "addtrack", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; +} + +interface DeviceAcceleration { + y: number; + x: number; + z: number; +} +declare var DeviceAcceleration: { + prototype: DeviceAcceleration; + new (): DeviceAcceleration; +} + +interface Console { + count(countTitle?: string): void; + groupEnd(): void; + time(timerName?: string): void; + timeEnd(timerName?: string): void; + trace(): void; + group(groupTitle?: string): void; + dirxml(value: any): void; + debug(message?: string, ...optionalParams: any[]): void; + groupCollapsed(groupTitle?: string): void; + select(element: Element): void; +} + +interface MSNavigatorDoNotTrack { + removeSiteSpecificTrackingException(args: ExceptionInformation): boolean; + removeWebWideTrackingException(args: ExceptionInformation): boolean; + storeWebWideTrackingException(args: StoreExceptionsInformation): void; + storeSiteSpecificTrackingException(args: StoreSiteSpecificExceptionsInformation): void; + confirmSiteSpecificTrackingException(args: ConfirmSiteSpecificExceptionsInformation): boolean; + confirmWebWideTrackingException(args: ExceptionInformation): boolean; +} +declare var MSNavigatorDoNotTrack: { + prototype: MSNavigatorDoNotTrack; + new (): MSNavigatorDoNotTrack; +} + +interface HTMLImageElement { + crossOrigin: string; +} + +interface HTMLAllCollection extends HTMLCollection { + namedItem(name: string): Element; +} +declare var HTMLAllCollection: { + prototype: HTMLAllCollection; + new (): HTMLAllCollection; +} + +interface MSNavigatorExtensions { + language: string; +} +declare var MSNavigatorExtensions: { + prototype: MSNavigatorExtensions; + new (): MSNavigatorExtensions; +} + +interface AesGcmEncryptResult { + ciphertext: ArrayBuffer; + tag: ArrayBuffer; +} +declare var AesGcmEncryptResult: { + prototype: AesGcmEncryptResult; + new (): AesGcmEncryptResult; +} + +interface CSSStyleDeclaration { + alignItems: string; + borderImageSource: string; + flexBasis: string; + borderImageWidth: string; + borderImageRepeat: string; + order: string; + flex: string; + alignContent: string; + msImeAlign: string; + flexShrink: string; + flexGrow: string; + borderImageSlice: string; + flexWrap: string; + borderImageOutset: string; + flexDirection: string; + flexFlow: string; + borderImage: string; + justifyContent: string; + alignSelf: string; + msTextCombineHorizontal: string; +} + +interface HTMLSourceElement { + msKeySystem: string; +} + +interface NavigationCompletedEvent extends NavigationEvent { + webErrorStatus: number; + isSuccess: boolean; +} +declare var NavigationCompletedEvent: { + prototype: NavigationCompletedEvent; + new (): NavigationCompletedEvent; +} + +interface MutationRecord { + oldValue: string; + previousSibling: Node; + addedNodes: NodeList; + attributeName: string; + removedNodes: NodeList; + target: Node; + nextSibling: Node; + attributeNamespace: string; + type: string; +} +declare var MutationRecord: { + prototype: MutationRecord; + new (): MutationRecord; +} + +interface Document extends MSDocumentExtensions { + msFullscreenEnabled: boolean; + onmsfullscreenerror: (ev: any) => any; + addEventListener(type: "msfullscreenerror", listener: (ev: any) => any, useCapture?: boolean): void; + onmspointerenter: (ev: any) => any; + addEventListener(type: "mspointerenter", listener: (ev: any) => any, useCapture?: boolean): void; + msFullscreenElement: Element; + onmsfullscreenchange: (ev: any) => any; + addEventListener(type: "msfullscreenchange", listener: (ev: any) => any, useCapture?: boolean): void; + onmspointerleave: (ev: any) => any; + addEventListener(type: "mspointerleave", listener: (ev: any) => any, useCapture?: boolean): void; + msExitFullscreen(): void; +} + +interface MimeTypeArray { + length: number; + item(index: number): Plugin; + [index: number]: Plugin; + namedItem(type: string): Plugin; +} +declare var MimeTypeArray: { + prototype: MimeTypeArray; + new (): MimeTypeArray; +} + +interface HTMLMediaElement { + msPlayToPreferredSourceUri: string; + onmsneedkey: (ev: MSMediaKeyNeededEvent) => any; + addEventListener(type: "msneedkey", listener: (ev: MSMediaKeyNeededEvent) => any, useCapture?: boolean): void; + msKeys: MSMediaKeys; + msGraphicsTrustStatus: MSGraphicsTrust; + msSetMediaKeys(mediaKeys: MSMediaKeys): void; + addTextTrack(kind: string, label?: string, language?: string): TextTrack; + addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; +} + +interface TextTrack { + addCue(cue: TextTrackCue): void; + removeCue(cue: TextTrackCue): void; +} + +interface KeyOperation extends EventTarget { + oncomplete: (ev: any) => any; + addEventListener(type: "complete", listener: (ev: any) => any, useCapture?: boolean): void; + onerror: (ev: any) => any; + addEventListener(type: "error", listener: (ev: any) => any, useCapture?: boolean): void; + result: any; + addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; +} +declare var KeyOperation: { + prototype: KeyOperation; + new (): KeyOperation; +} + +interface DOMStringMap { +} +declare var DOMStringMap: { + prototype: DOMStringMap; + new (): DOMStringMap; +} + +interface DeviceOrientationEvent extends Event { + gamma: number; + alpha: number; + absolute: boolean; + beta: number; + initDeviceOrientationEvent(type: string, bubbles: boolean, cancelable: boolean, alpha: number, beta: number, gamma: number, absolute: boolean): void; +} +declare var DeviceOrientationEvent: { + prototype: DeviceOrientationEvent; + new (): DeviceOrientationEvent; +} + +interface MSMediaKeyMessageEvent extends Event { + destinationURL: string; + message: Uint8Array; +} +declare var MSMediaKeyMessageEvent: { + prototype: MSMediaKeyMessageEvent; + new (): MSMediaKeyMessageEvent; +} + +interface MSMediaKeys { + keySystem: string; + createSession(type: string, initData: Uint8Array, cdmData?: Uint8Array): MSMediaKeySession; + isTypeSupported(keySystem: string, type?: string): boolean; +} +declare var MSMediaKeys: { + prototype: MSMediaKeys; + new (): MSMediaKeys; +} + +interface MSHTMLWebViewElement extends HTMLElement { + documentTitle: string; + width: number; + src: string; + canGoForward: boolean; + height: number; + canGoBack: boolean; + navigateWithHttpRequestMessage(requestMessage: any): void; + goBack(): void; + navigate(uri: string): void; + stop(): void; + navigateToString(contents: string): void; + captureSelectedContentToDataPackageAsync(): MSWebViewAsyncOperation; + capturePreviewToBlobAsync(): MSWebViewAsyncOperation; + refresh(): void; + goForward(): void; + navigateToLocalStreamUri(source: string, streamResolver: any): void; + invokeScriptAsync(scriptName: string, ...args: any[]): MSWebViewAsyncOperation; + buildLocalStreamUri(contentIdentifier: string, relativePath: string): string; +} +declare var MSHTMLWebViewElement: { + prototype: MSHTMLWebViewElement; + new (): MSHTMLWebViewElement; +} + +interface NavigationEvent extends Event { + uri: string; +} +declare var NavigationEvent: { + prototype: NavigationEvent; + new (): NavigationEvent; +} + +interface Element { + onmspointerenter: (ev: any) => any; + addEventListener(type: "mspointerenter", listener: (ev: any) => any, useCapture?: boolean): void; + onmspointerleave: (ev: any) => any; + addEventListener(type: "mspointerleave", listener: (ev: any) => any, useCapture?: boolean): void; + msZoomTo(args: MsZoomToOptions): void; + msGetUntransformedBounds(): ClientRect; + msRequestFullscreen(): void; +} + +interface RandomSource { + getRandomValues(array: ArrayBufferView): ArrayBufferView; +} + +interface XMLHttpRequest { + msCaching: string; + msCachingEnabled(): boolean; + overrideMimeType(mime: string): void; +} + +interface SourceBuffer extends EventTarget { + updating: boolean; + appendWindowStart: number; + appendWindowEnd: number; + buffered: TimeRanges; + timestampOffset: number; + audioTracks: AudioTrackList; + appendBuffer(data: ArrayBuffer): void; + remove(start: number, end: number): void; + abort(): void; + appendStream(stream: MSStream, maxSize?: number): void; +} +declare var SourceBuffer: { + prototype: SourceBuffer; + new (): SourceBuffer; +} + +interface MSInputMethodContext extends EventTarget { + oncandidatewindowshow: (ev: any) => any; + addEventListener(type: "candidatewindowshow", listener: (ev: any) => any, useCapture?: boolean): void; + target: HTMLElement; + compositionStartOffset: number; + oncandidatewindowhide: (ev: any) => any; + addEventListener(type: "candidatewindowhide", listener: (ev: any) => any, useCapture?: boolean): void; + oncandidatewindowupdate: (ev: any) => any; + addEventListener(type: "candidatewindowupdate", listener: (ev: any) => any, useCapture?: boolean): void; + compositionEndOffset: number; + getCompositionAlternatives(): string[]; + getCandidateWindowClientRect(): ClientRect; + hasComposition(): boolean; + isCandidateWindowVisible(): boolean; + addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; +} +declare var MSInputMethodContext: { + prototype: MSInputMethodContext; + new (): MSInputMethodContext; +} + +interface DeviceRotationRate { + gamma: number; + alpha: number; + beta: number; +} +declare var DeviceRotationRate: { + prototype: DeviceRotationRate; + new (): DeviceRotationRate; +} + +interface PluginArray { + length: number; + refresh(reload?: boolean): void; + item(index: number): Plugin; + [index: number]: Plugin; + namedItem(name: string): Plugin; +} +declare var PluginArray: { + prototype: PluginArray; + new (): PluginArray; +} + +interface MSMediaKeyError { + systemCode: number; + code: number; + MS_MEDIA_KEYERR_SERVICE: number; + MS_MEDIA_KEYERR_HARDWARECHANGE: number; + MS_MEDIA_KEYERR_OUTPUT: number; + MS_MEDIA_KEYERR_DOMAIN: number; + MS_MEDIA_KEYERR_UNKNOWN: number; + MS_MEDIA_KEYERR_CLIENT: number; +} +declare var MSMediaKeyError: { + prototype: MSMediaKeyError; + new (): MSMediaKeyError; + MS_MEDIA_KEYERR_SERVICE: number; + MS_MEDIA_KEYERR_HARDWARECHANGE: number; + MS_MEDIA_KEYERR_OUTPUT: number; + MS_MEDIA_KEYERR_DOMAIN: number; + MS_MEDIA_KEYERR_UNKNOWN: number; + MS_MEDIA_KEYERR_CLIENT: number; +} + +interface Plugin { + length: number; + filename: string; + version: string; + name: string; + description: string; + item(index: number): MimeType; + [index: number]: MimeType; + namedItem(type: string): MimeType; +} +declare var Plugin: { + prototype: Plugin; + new (): Plugin; +} + +interface HTMLFrameSetElement { + onpageshow: (ev: PageTransitionEvent) => any; + addEventListener(type: "pageshow", listener: (ev: PageTransitionEvent) => any, useCapture?: boolean): void; + onpagehide: (ev: PageTransitionEvent) => any; + addEventListener(type: "pagehide", listener: (ev: PageTransitionEvent) => any, useCapture?: boolean): void; +} + +interface Screen extends EventTarget { + msOrientation: string; + onmsorientationchange: (ev: any) => any; + addEventListener(type: "msorientationchange", listener: (ev: any) => any, useCapture?: boolean): void; + msLockOrientation(orientations: string[]): boolean; + msUnlockOrientation(): void; + addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; +} + +interface MediaSource extends EventTarget { + sourceBuffers: SourceBufferList; + duration: string; + readyState: any; + activeSourceBuffers: SourceBufferList; + addSourceBuffer(type: string): SourceBuffer; + endOfStream(error?: string): void; + isTypeSupported(type: string): boolean; + removeSourceBuffer(sourceBuffer: SourceBuffer): void; +} +declare var MediaSource: { + prototype: MediaSource; + new (): MediaSource; +} + +interface MediaError { + MS_MEDIA_ERR_ENCRYPTED: number; +} +//declare var MediaError: { +// prototype: MediaError; +// MS_MEDIA_ERR_ENCRYPTED: number; +//} + +interface SourceBufferList extends EventTarget { + length: number; + item(index: number): SourceBuffer; + [index: number]: SourceBuffer; +} +declare var SourceBufferList: { + prototype: SourceBufferList; + new (): SourceBufferList; +} + +interface XMLDocument extends Document { +} +declare var XMLDocument: { + prototype: XMLDocument; + new (): XMLDocument; +} + +interface DeviceMotionEvent extends Event { + rotationRate: DeviceRotationRate; + acceleration: DeviceAcceleration; + interval: number; + accelerationIncludingGravity: DeviceAcceleration; + initDeviceMotionEvent(type: string, bubbles: boolean, cancelable: boolean, acceleration: DeviceAccelerationDict, accelerationIncludingGravity: DeviceAccelerationDict, rotationRate: DeviceRotationRateDict, interval: number): void; +} +declare var DeviceMotionEvent: { + prototype: DeviceMotionEvent; + new (): DeviceMotionEvent; +} + +interface MimeType { + enabledPlugin: Plugin; + suffixes: string; + type: string; + description: string; +} +declare var MimeType: { + prototype: MimeType; + new (): MimeType; +} + +interface MSDocumentExtensions { + captureEvents(): void; + releaseEvents(): void; +} + +interface HTMLElement { + dataset: DOMStringMap; + hidden: boolean; + msGetInputContext(): MSInputMethodContext; +} + +interface MutationObserver { + observe(target: Node, options: MutationObserverInit): void; + takeRecords(): MutationRecord[]; + disconnect(): void; +} +declare var MutationObserver: { + prototype: MutationObserver; + new (): MutationObserver; +} + +interface AudioTrackList { + onremovetrack: (ev: PluginArray) => any; + //addEventListener(type: "removetrack", listener: (ev: PluginArray) => any, useCapture?: boolean): void; +} + +interface HTMLObjectElement { + msPlayToPreferredSourceUri: string; + msPlayToPrimary: boolean; + msPlayToDisabled: boolean; + msPlayToSource: any; +} + +interface HTMLEmbedElement { + msPlayToPreferredSourceUri: string; + msPlayToPrimary: boolean; + msPlayToDisabled: boolean; + msPlayToSource: any; +} + +interface MSWebViewAsyncOperation extends EventTarget { + target: MSHTMLWebViewElement; + oncomplete: (ev: any) => any; + addEventListener(type: "complete", listener: (ev: any) => any, useCapture?: boolean): void; + error: DOMError; + onerror: (ev: any) => any; + addEventListener(type: "error", listener: (ev: any) => any, useCapture?: boolean): void; + readyState: number; + type: number; + result: any; + start(): void; + addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; + ERROR: number; + TYPE_CREATE_DATA_PACKAGE_FROM_SELECTION: number; + TYPE_INVOKE_SCRIPT: number; + COMPLETED: number; + TYPE_CAPTURE_PREVIEW_TO_RANDOM_ACCESS_STREAM: number; + STARTED: number; +} +declare var MSWebViewAsyncOperation: { + prototype: MSWebViewAsyncOperation; + new (): MSWebViewAsyncOperation; + ERROR: number; + TYPE_CREATE_DATA_PACKAGE_FROM_SELECTION: number; + TYPE_INVOKE_SCRIPT: number; + COMPLETED: number; + TYPE_CAPTURE_PREVIEW_TO_RANDOM_ACCESS_STREAM: number; + STARTED: number; +} + +interface ScriptNotifyEvent extends Event { + value: string; + callingUri: string; +} +declare var ScriptNotifyEvent: { + prototype: ScriptNotifyEvent; + new (): ScriptNotifyEvent; +} + +interface PerformanceNavigationTiming extends PerformanceEntry { + redirectStart: number; + domainLookupEnd: number; + responseStart: number; + domComplete: number; + domainLookupStart: number; + loadEventStart: number; + unloadEventEnd: number; + fetchStart: number; + requestStart: number; + domInteractive: number; + navigationStart: number; + connectEnd: number; + loadEventEnd: number; + connectStart: number; + responseEnd: number; + domLoading: number; + redirectEnd: number; + redirectCount: number; + unloadEventStart: number; + domContentLoadedEventStart: number; + domContentLoadedEventEnd: number; + type: string; +} +declare var PerformanceNavigationTiming: { + prototype: PerformanceNavigationTiming; + new (): PerformanceNavigationTiming; +} + +interface MSMediaKeyNeededEvent extends Event { + initData: Uint8Array; +} +declare var MSMediaKeyNeededEvent: { + prototype: MSMediaKeyNeededEvent; + new (): MSMediaKeyNeededEvent; +} + +interface MSManipulationEvent { + MS_MANIPULATION_STATE_SELECTING: number; + MS_MANIPULATION_STATE_COMMITTED: number; + MS_MANIPULATION_STATE_PRESELECT: number; + MS_MANIPULATION_STATE_DRAGGING: number; + MS_MANIPULATION_STATE_CANCELLED: number; +} +//declare var MSManipulationEvent: { +// prototype: MSManipulationEvent; +// MS_MANIPULATION_STATE_SELECTING: number; +// MS_MANIPULATION_STATE_COMMITTED: number; +// MS_MANIPULATION_STATE_PRESELECT: number; +// MS_MANIPULATION_STATE_DRAGGING: number; +// MS_MANIPULATION_STATE_CANCELLED: number; +//} + +interface LongRunningScriptDetectedEvent extends Event { + stopPageScriptExecution: boolean; + executionTime: number; +} +declare var LongRunningScriptDetectedEvent: { + prototype: LongRunningScriptDetectedEvent; + new (): LongRunningScriptDetectedEvent; +} + +interface MSAppView { + viewId: number; + close(): void; + postMessage(message: any, targetOrigin: string, ports?: any): void; +} +declare var MSAppView: { + prototype: MSAppView; + new (): MSAppView; +} + +interface PerfWidgetExternal { + maxCpuSpeed: number; + performanceCounterFrequency: number; + performanceCounter: number; + averagePaintTime: number; + activeNetworkRequestCount: number; + paintRequestsPerSecond: number; + repositionWindow(x: number, y: number): void; + getRecentMemoryUsage(last: number): any; + getMemoryUsage(): number; + resizeWindow(width: number, height: number): void; + getProcessCpuUsage(): number; + removeEventListener(eventType: string, callback: (ev: any) => any): void; + getRecentCpuUsage(last: number): any; + addEventListener(eventType: string, callback: (ev: any) => any): void; + getRecentPaintRequests(last: number): any; +} +declare var PerfWidgetExternal: { + prototype: PerfWidgetExternal; + new (): PerfWidgetExternal; +} + +interface PageTransitionEvent extends Event { + persisted: boolean; +} +declare var PageTransitionEvent: { + prototype: PageTransitionEvent; + new (): PageTransitionEvent; +} + +interface MutationCallback { + (mutations: MutationRecord[], observer: MutationObserver): void; +} + +interface HTMLDocument extends Document { +} +declare var HTMLDocument: { + prototype: HTMLDocument; + new (): HTMLDocument; +} + +interface KeyPair { + privateKey: Key; + publicKey: Key; +} +declare var KeyPair: { + prototype: KeyPair; + new (): KeyPair; +} + +interface MSApp { + getViewOpener(): MSAppView; + suppressSubdownloadCredentialPrompts(suppress: boolean): void; + execAsyncAtPriority(asynchronousCallback: MSExecAtPriorityFunctionCallback, priority: string, ...args: any[]): void; + isTaskScheduledAtPriorityOrHigher(priority: string): boolean; + execAtPriority(synchronousCallback: MSExecAtPriorityFunctionCallback, priority: string, ...args: any[]): any; + createNewView(uri: string): MSAppView; + getCurrentPriority(): string; + NORMAL: string; + HIGH: string; + IDLE: string; + CURRENT: string; +} +//declare var MSApp: { +// prototype: MSApp; +// NORMAL: string; +// HIGH: string; +// IDLE: string; +// CURRENT: string; +//} + +interface HTMLTrackElement { + readyState: number; + ERROR: number; + LOADING: number; + LOADED: number; + NONE: number; +} +//declare var HTMLTrackElement: { +// prototype: HTMLTrackElement; +// ERROR: number; +// LOADING: number; +// LOADED: number; +// NONE: number; +//} + +interface MSMediaKeySession extends EventTarget { + sessionId: string; + error: MSMediaKeyError; + keySystem: string; + close(): void; + update(key: Uint8Array): void; +} +declare var MSMediaKeySession: { + prototype: MSMediaKeySession; + new (): MSMediaKeySession; +} + +interface HTMLVideoElement { + videoPlaybackQuality: VideoPlaybackQuality; +} + +interface UnviewableContentIdentifiedEvent extends NavigationEvent { + referrer: string; +} +declare var UnviewableContentIdentifiedEvent: { + prototype: UnviewableContentIdentifiedEvent; + new (): UnviewableContentIdentifiedEvent; +} + +interface CryptoOperation extends EventTarget { + algorithm: Algorithm; + oncomplete: (ev: any) => any; + addEventListener(type: "complete", listener: (ev: any) => any, useCapture?: boolean): void; + onerror: (ev: any) => any; + addEventListener(type: "error", listener: (ev: any) => any, useCapture?: boolean): void; + onprogress: (ev: any) => any; + addEventListener(type: "progress", listener: (ev: any) => any, useCapture?: boolean): void; + onabort: (ev: any) => any; + addEventListener(type: "abort", listener: (ev: any) => any, useCapture?: boolean): void; + key: Key; + result: any; + abort(): void; + finish(): void; + process(buffer: ArrayBufferView): void; + addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; +} +declare var CryptoOperation: { + prototype: CryptoOperation; + new (): CryptoOperation; +} + +declare var onpageshow: (ev: PageTransitionEvent) => any; +declare function addEventListener(type: "pageshow", listener: (ev: PageTransitionEvent) => any, useCapture?: boolean): void; +declare var ondevicemotion: (ev: DeviceMotionEvent) => any; +declare function addEventListener(type: "devicemotion", listener: (ev: DeviceMotionEvent) => any, useCapture?: boolean): void; +declare var devicePixelRatio: number; +declare var msCrypto: Crypto; +declare var ondeviceorientation: (ev: DeviceOrientationEvent) => any; +declare function addEventListener(type: "deviceorientation", listener: (ev: DeviceOrientationEvent) => any, useCapture?: boolean): void; +declare var onmspointerenter: (ev: any) => any; +declare function addEventListener(type: "mspointerenter", listener: (ev: any) => any, useCapture?: boolean): void; +declare var onpagehide: (ev: PageTransitionEvent) => any; +declare function addEventListener(type: "pagehide", listener: (ev: PageTransitionEvent) => any, useCapture?: boolean): void; +declare var onmspointerleave: (ev: any) => any; +declare function addEventListener(type: "mspointerleave", listener: (ev: any) => any, useCapture?: boolean): void; + + +///////////////////////////// +/// WorkerGlobalScope APIs +///////////////////////////// +// TODO: These are only available in a Web Worker - should be in a separate lib file +declare function importScripts(...urls: string[]): void; + + +///////////////////////////// +/// Windows Script Host APIS +///////////////////////////// +declare var ActiveXObject: { new (s: string): any; }; + +interface ITextWriter { + Write(s: string): void; + WriteLine(s: string): void; + Close(): void; +} + +declare var WScript: { + Echo(s: any): void; + StdErr: ITextWriter; + StdOut: ITextWriter; + Arguments: { length: number; Item(n: number): string; }; + ScriptFullName: string; + Quit(exitCode?: number): number; +} diff --git a/_infrastructure/tests/typescript/tsc.js b/_infrastructure/tests/typescript/tsc.js index be3f9efb7..f366d7171 100644 --- a/_infrastructure/tests/typescript/tsc.js +++ b/_infrastructure/tests/typescript/tsc.js @@ -1,56803 +1,56015 @@ -/* ***************************************************************************** -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 - -THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED -WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, -MERCHANTABLITY OR NON-INFRINGEMENT. - -See the Apache Version 2.0 License for specific language governing permissions -and limitations under the License. -***************************************************************************** */ - -var TypeScript; -(function (TypeScript) { - var ArrayUtilities = (function () { - function ArrayUtilities() { - } - ArrayUtilities.isArray = function (value) { - return Object.prototype.toString.apply(value, []) === '[object Array]'; - }; - - ArrayUtilities.sequenceEquals = function (array1, array2, equals) { - if (array1 === array2) { - return true; - } - - if (array1 === null || array2 === null) { - 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; - }; - - ArrayUtilities.contains = function (array, value) { - for (var i = 0; i < array.length; i++) { - if (array[i] === value) { - return true; - } - } - - return false; - }; - - ArrayUtilities.groupBy = function (array, func) { - var result = {}; - - for (var i = 0, n = array.length; i < n; i++) { - var v = array[i]; - var k = func(v); - - var list = result[k] || []; - list.push(v); - result[k] = list; - } - - return result; - }; - - ArrayUtilities.min = function (array, func) { - var min = func(array[0]); - - for (var i = 1; i < array.length; i++) { - var next = func(array[i]); - if (next < min) { - min = next; - } - } - - return min; - }; - - ArrayUtilities.max = function (array, func) { - var max = func(array[0]); - - for (var i = 1; i < array.length; i++) { - var next = func(array[i]); - if (next > max) { - max = next; - } - } - - return max; - }; - - ArrayUtilities.last = function (array) { - if (array.length === 0) { - throw TypeScript.Errors.argumentOutOfRange('array'); - } - - return array[array.length - 1]; - }; - - ArrayUtilities.firstOrDefault = function (array, func) { - for (var i = 0, n = array.length; i < n; i++) { - var value = array[i]; - if (func(value)) { - return value; - } - } - - return null; - }; - - ArrayUtilities.sum = function (array, func) { - var result = 0; - - for (var i = 0, n = array.length; i < n; i++) { - result += func(array[i]); - } - - return result; - }; - - ArrayUtilities.whereNotNull = function (array) { - var result = []; - for (var i = 0; i < array.length; i++) { - var value = array[i]; - if (value !== null) { - result.push(value); - } - } - - return result; - }; - - ArrayUtilities.select = function (values, func) { - var result = []; - - for (var i = 0; i < values.length; i++) { - result.push(func(values[i])); - } - - return result; - }; - - ArrayUtilities.where = function (values, func) { - var result = []; - - for (var i = 0; i < values.length; i++) { - if (func(values[i])) { - result.push(values[i]); - } - } - - return result; - }; - - ArrayUtilities.any = function (array, func) { - for (var i = 0, n = array.length; i < n; i++) { - if (func(array[i])) { - return true; - } - } - - return false; - }; - - ArrayUtilities.all = function (array, func) { - for (var i = 0, n = array.length; i < n; i++) { - if (!func(array[i])) { - return false; - } - } - - return true; - }; - - ArrayUtilities.binarySearch = function (array, value) { - 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; - }; - - ArrayUtilities.createArray = function (length, defaultvalue) { - var result = []; - for (var i = 0; i < length; i++) { - result.push(defaultvalue); - } - - return result; - }; - - ArrayUtilities.grow = function (array, length, defaultValue) { - var count = length - array.length; - for (var i = 0; i < count; i++) { - array.push(defaultValue); - } - }; - - ArrayUtilities.copy = function (sourceArray, sourceIndex, destinationArray, destinationIndex, length) { - for (var i = 0; i < length; i++) { - destinationArray[destinationIndex + i] = sourceArray[sourceIndex + i]; - } - }; - return ArrayUtilities; - })(); - TypeScript.ArrayUtilities = ArrayUtilities; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (Constants) { - Constants[Constants["Max31BitInteger"] = 1073741823] = "Max31BitInteger"; - Constants[Constants["Min31BitInteger"] = -1073741824] = "Min31BitInteger"; - })(TypeScript.Constants || (TypeScript.Constants = {})); - var Constants = TypeScript.Constants; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var Contract = (function () { - function Contract() { - } - Contract.requires = function (expression) { - if (!expression) { - throw new Error("Contract violated. False expression."); - } - }; - - Contract.throwIfFalse = function (expression) { - if (!expression) { - throw new Error("Contract violated. False expression."); - } - }; - - Contract.throwIfNull = function (value) { - if (value === null) { - throw new Error("Contract violated. Null value."); - } - }; - return Contract; - })(); - TypeScript.Contract = Contract; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var Debug = (function () { - function Debug() { - } - Debug.assert = function (expression, message) { - if (!expression) { - throw new Error("Debug Failure. False expression: " + (message ? message : "")); - } - }; - return Debug; - })(); - TypeScript.Debug = Debug; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (DiagnosticCategory) { - DiagnosticCategory[DiagnosticCategory["Warning"] = 0] = "Warning"; - DiagnosticCategory[DiagnosticCategory["Error"] = 1] = "Error"; - DiagnosticCategory[DiagnosticCategory["Message"] = 2] = "Message"; - DiagnosticCategory[DiagnosticCategory["NoPrefix"] = 3] = "NoPrefix"; - })(TypeScript.DiagnosticCategory || (TypeScript.DiagnosticCategory = {})); - var DiagnosticCategory = TypeScript.DiagnosticCategory; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (DiagnosticCode) { - DiagnosticCode[DiagnosticCode["error_TS_0__1"] = 0] = "error_TS_0__1"; - DiagnosticCode[DiagnosticCode["warning_TS_0__1"] = 1] = "warning_TS_0__1"; - - DiagnosticCode[DiagnosticCode["_0__NL__1_TB__2"] = 2] = "_0__NL__1_TB__2"; - DiagnosticCode[DiagnosticCode["_0_TB__1"] = 3] = "_0_TB__1"; - - DiagnosticCode[DiagnosticCode["Unrecognized_escape_sequence"] = 4] = "Unrecognized_escape_sequence"; - DiagnosticCode[DiagnosticCode["Unexpected_character_0"] = 5] = "Unexpected_character_0"; - DiagnosticCode[DiagnosticCode["Missing_closing_quote_character"] = 6] = "Missing_closing_quote_character"; - DiagnosticCode[DiagnosticCode["Identifier_expected"] = 7] = "Identifier_expected"; - DiagnosticCode[DiagnosticCode["_0_keyword_expected"] = 8] = "_0_keyword_expected"; - DiagnosticCode[DiagnosticCode["_0_expected"] = 9] = "_0_expected"; - DiagnosticCode[DiagnosticCode["Identifier_expected__0__is_a_keyword"] = 10] = "Identifier_expected__0__is_a_keyword"; - DiagnosticCode[DiagnosticCode["Automatic_semicolon_insertion_not_allowed"] = 11] = "Automatic_semicolon_insertion_not_allowed"; - DiagnosticCode[DiagnosticCode["Unexpected_token__0_expected"] = 12] = "Unexpected_token__0_expected"; - DiagnosticCode[DiagnosticCode["Trailing_separator_not_allowed"] = 13] = "Trailing_separator_not_allowed"; - DiagnosticCode[DiagnosticCode["_StarSlash__expected"] = 14] = "_StarSlash__expected"; - DiagnosticCode[DiagnosticCode["_public_or_private_modifier_must_precede__static_"] = 15] = "_public_or_private_modifier_must_precede__static_"; - DiagnosticCode[DiagnosticCode["Unexpected_token_"] = 16] = "Unexpected_token_"; - DiagnosticCode[DiagnosticCode["A_catch_clause_variable_cannot_have_a_type_annotation"] = 17] = "A_catch_clause_variable_cannot_have_a_type_annotation"; - DiagnosticCode[DiagnosticCode["Rest_parameter_must_be_last_in_list"] = 18] = "Rest_parameter_must_be_last_in_list"; - DiagnosticCode[DiagnosticCode["Parameter_cannot_have_question_mark_and_initializer"] = 19] = "Parameter_cannot_have_question_mark_and_initializer"; - DiagnosticCode[DiagnosticCode["Required_parameter_cannot_follow_optional_parameter"] = 20] = "Required_parameter_cannot_follow_optional_parameter"; - DiagnosticCode[DiagnosticCode["Index_signatures_cannot_have_rest_parameters"] = 21] = "Index_signatures_cannot_have_rest_parameters"; - DiagnosticCode[DiagnosticCode["Index_signature_parameter_cannot_have_accessibility_modifiers"] = 22] = "Index_signature_parameter_cannot_have_accessibility_modifiers"; - DiagnosticCode[DiagnosticCode["Index_signature_parameter_cannot_have_a_question_mark"] = 23] = "Index_signature_parameter_cannot_have_a_question_mark"; - DiagnosticCode[DiagnosticCode["Index_signature_parameter_cannot_have_an_initializer"] = 24] = "Index_signature_parameter_cannot_have_an_initializer"; - DiagnosticCode[DiagnosticCode["Index_signature_must_have_a_type_annotation"] = 25] = "Index_signature_must_have_a_type_annotation"; - DiagnosticCode[DiagnosticCode["Index_signature_parameter_must_have_a_type_annotation"] = 26] = "Index_signature_parameter_must_have_a_type_annotation"; - DiagnosticCode[DiagnosticCode["Index_signature_parameter_type_must_be__string__or__number_"] = 27] = "Index_signature_parameter_type_must_be__string__or__number_"; - DiagnosticCode[DiagnosticCode["_extends__clause_already_seen"] = 28] = "_extends__clause_already_seen"; - DiagnosticCode[DiagnosticCode["_extends__clause_must_precede__implements__clause"] = 29] = "_extends__clause_must_precede__implements__clause"; - DiagnosticCode[DiagnosticCode["Class_can_only_extend_single_type"] = 30] = "Class_can_only_extend_single_type"; - DiagnosticCode[DiagnosticCode["_implements__clause_already_seen"] = 31] = "_implements__clause_already_seen"; - DiagnosticCode[DiagnosticCode["Accessibility_modifier_already_seen"] = 32] = "Accessibility_modifier_already_seen"; - DiagnosticCode[DiagnosticCode["_0__modifier_must_precede__1__modifier"] = 33] = "_0__modifier_must_precede__1__modifier"; - DiagnosticCode[DiagnosticCode["_0__modifier_already_seen"] = 34] = "_0__modifier_already_seen"; - DiagnosticCode[DiagnosticCode["_0__modifier_cannot_appear_on_a_class_element"] = 35] = "_0__modifier_cannot_appear_on_a_class_element"; - DiagnosticCode[DiagnosticCode["Interface_declaration_cannot_have__implements__clause"] = 36] = "Interface_declaration_cannot_have__implements__clause"; - DiagnosticCode[DiagnosticCode["_super__invocation_cannot_have_type_arguments"] = 37] = "_super__invocation_cannot_have_type_arguments"; - DiagnosticCode[DiagnosticCode["Non_ambient_modules_cannot_use_quoted_names"] = 38] = "Non_ambient_modules_cannot_use_quoted_names"; - DiagnosticCode[DiagnosticCode["Statements_are_not_allowed_in_ambient_contexts"] = 39] = "Statements_are_not_allowed_in_ambient_contexts"; - DiagnosticCode[DiagnosticCode["Implementations_are_not_allowed_in_ambient_contexts"] = 40] = "Implementations_are_not_allowed_in_ambient_contexts"; - DiagnosticCode[DiagnosticCode["_declare__modifier_not_allowed_for_code_already_in_an_ambient_context"] = 41] = "_declare__modifier_not_allowed_for_code_already_in_an_ambient_context"; - DiagnosticCode[DiagnosticCode["Initializers_are_not_allowed_in_ambient_contexts"] = 42] = "Initializers_are_not_allowed_in_ambient_contexts"; - DiagnosticCode[DiagnosticCode["Overload_and_ambient_signatures_cannot_specify_parameter_properties"] = 43] = "Overload_and_ambient_signatures_cannot_specify_parameter_properties"; - DiagnosticCode[DiagnosticCode["Function_implementation_expected"] = 44] = "Function_implementation_expected"; - DiagnosticCode[DiagnosticCode["Constructor_implementation_expected"] = 45] = "Constructor_implementation_expected"; - DiagnosticCode[DiagnosticCode["Function_overload_name_must_be__0_"] = 46] = "Function_overload_name_must_be__0_"; - DiagnosticCode[DiagnosticCode["_0__modifier_cannot_appear_on_a_module_element"] = 47] = "_0__modifier_cannot_appear_on_a_module_element"; - DiagnosticCode[DiagnosticCode["_declare__modifier_cannot_appear_on_an_interface_declaration"] = 48] = "_declare__modifier_cannot_appear_on_an_interface_declaration"; - DiagnosticCode[DiagnosticCode["_declare__modifier_required_for_top_level_element"] = 49] = "_declare__modifier_required_for_top_level_element"; - DiagnosticCode[DiagnosticCode["_set__accessor_must_have_only_one_parameter"] = 50] = "_set__accessor_must_have_only_one_parameter"; - DiagnosticCode[DiagnosticCode["_set__accessor_parameter_cannot_have_accessibility_modifier"] = 51] = "_set__accessor_parameter_cannot_have_accessibility_modifier"; - DiagnosticCode[DiagnosticCode["_set__accessor_parameter_cannot_be_optional"] = 52] = "_set__accessor_parameter_cannot_be_optional"; - DiagnosticCode[DiagnosticCode["_set__accessor_parameter_cannot_have_initializer"] = 53] = "_set__accessor_parameter_cannot_have_initializer"; - DiagnosticCode[DiagnosticCode["_set__accessor_cannot_have_rest_parameter"] = 54] = "_set__accessor_cannot_have_rest_parameter"; - DiagnosticCode[DiagnosticCode["_get__accessor_cannot_have_parameters"] = 55] = "_get__accessor_cannot_have_parameters"; - DiagnosticCode[DiagnosticCode["Rest_parameter_cannot_be_optional"] = 56] = "Rest_parameter_cannot_be_optional"; - DiagnosticCode[DiagnosticCode["Rest_parameter_cannot_have_initializer"] = 57] = "Rest_parameter_cannot_have_initializer"; - DiagnosticCode[DiagnosticCode["Modifiers_cannot_appear_here"] = 58] = "Modifiers_cannot_appear_here"; - DiagnosticCode[DiagnosticCode["Accessors_are_only_available_when_targeting_EcmaScript5_and_higher"] = 59] = "Accessors_are_only_available_when_targeting_EcmaScript5_and_higher"; - DiagnosticCode[DiagnosticCode["Class_name_cannot_be__0_"] = 60] = "Class_name_cannot_be__0_"; - DiagnosticCode[DiagnosticCode["Interface_name_cannot_be__0_"] = 61] = "Interface_name_cannot_be__0_"; - DiagnosticCode[DiagnosticCode["Enum_name_cannot_be__0_"] = 62] = "Enum_name_cannot_be__0_"; - DiagnosticCode[DiagnosticCode["Module_name_cannot_be__0_"] = 63] = "Module_name_cannot_be__0_"; - DiagnosticCode[DiagnosticCode["Enum_member_must_have_initializer"] = 64] = "Enum_member_must_have_initializer"; - DiagnosticCode[DiagnosticCode["_module_______is_deprecated__Use__require_______instead"] = 65] = "_module_______is_deprecated__Use__require_______instead"; - DiagnosticCode[DiagnosticCode["Export_assignments_cannot_be_used_in_internal_modules"] = 66] = "Export_assignments_cannot_be_used_in_internal_modules"; - DiagnosticCode[DiagnosticCode["Export_assignment_not_allowed_in_module_with_exported_element"] = 67] = "Export_assignment_not_allowed_in_module_with_exported_element"; - DiagnosticCode[DiagnosticCode["Module_cannot_have_multiple_export_assignments"] = 68] = "Module_cannot_have_multiple_export_assignments"; - - DiagnosticCode[DiagnosticCode["Duplicate_identifier__0_"] = 69] = "Duplicate_identifier__0_"; - DiagnosticCode[DiagnosticCode["The_name__0__does_not_exist_in_the_current_scope"] = 70] = "The_name__0__does_not_exist_in_the_current_scope"; - DiagnosticCode[DiagnosticCode["The_name__0__does_not_refer_to_a_value"] = 71] = "The_name__0__does_not_refer_to_a_value"; - DiagnosticCode[DiagnosticCode["Keyword__super__can_only_be_used_inside_a_class_instance_method"] = 72] = "Keyword__super__can_only_be_used_inside_a_class_instance_method"; - DiagnosticCode[DiagnosticCode["The_left_hand_side_of_an_assignment_expression_must_be_a_variable__property_or_indexer"] = 73] = "The_left_hand_side_of_an_assignment_expression_must_be_a_variable__property_or_indexer"; - DiagnosticCode[DiagnosticCode["Value_of_type__0__is_not_callable__Did_you_mean_to_include__new__"] = 74] = "Value_of_type__0__is_not_callable__Did_you_mean_to_include__new__"; - DiagnosticCode[DiagnosticCode["Value_of_type__0__is_not_callable"] = 75] = "Value_of_type__0__is_not_callable"; - DiagnosticCode[DiagnosticCode["Value_of_type__0__is_not_newable"] = 76] = "Value_of_type__0__is_not_newable"; - DiagnosticCode[DiagnosticCode["Value_of_type__0__is_not_indexable_by_type__1_"] = 77] = "Value_of_type__0__is_not_indexable_by_type__1_"; - DiagnosticCode[DiagnosticCode["Operator__0__cannot_be_applied_to_types__1__and__2_"] = 78] = "Operator__0__cannot_be_applied_to_types__1__and__2_"; - DiagnosticCode[DiagnosticCode["Operator__0__cannot_be_applied_to_types__1__and__2__3"] = 79] = "Operator__0__cannot_be_applied_to_types__1__and__2__3"; - DiagnosticCode[DiagnosticCode["Cannot_convert__0__to__1_"] = 80] = "Cannot_convert__0__to__1_"; - DiagnosticCode[DiagnosticCode["Cannot_convert__0__to__1__NL__2"] = 81] = "Cannot_convert__0__to__1__NL__2"; - DiagnosticCode[DiagnosticCode["Expected_var__class__interface__or_module"] = 82] = "Expected_var__class__interface__or_module"; - DiagnosticCode[DiagnosticCode["Operator__0__cannot_be_applied_to_type__1_"] = 83] = "Operator__0__cannot_be_applied_to_type__1_"; - DiagnosticCode[DiagnosticCode["Getter__0__already_declared"] = 84] = "Getter__0__already_declared"; - DiagnosticCode[DiagnosticCode["Setter__0__already_declared"] = 85] = "Setter__0__already_declared"; - DiagnosticCode[DiagnosticCode["Accessor_cannot_have_type_parameters"] = 86] = "Accessor_cannot_have_type_parameters"; - DiagnosticCode[DiagnosticCode["Exported_class__0__extends_private_class__1_"] = 87] = "Exported_class__0__extends_private_class__1_"; - DiagnosticCode[DiagnosticCode["Exported_class__0__implements_private_interface__1_"] = 88] = "Exported_class__0__implements_private_interface__1_"; - DiagnosticCode[DiagnosticCode["Exported_interface__0__extends_private_interface__1_"] = 89] = "Exported_interface__0__extends_private_interface__1_"; - DiagnosticCode[DiagnosticCode["Exported_class__0__extends_class_from_inaccessible_module__1_"] = 90] = "Exported_class__0__extends_class_from_inaccessible_module__1_"; - DiagnosticCode[DiagnosticCode["Exported_class__0__implements_interface_from_inaccessible_module__1_"] = 91] = "Exported_class__0__implements_interface_from_inaccessible_module__1_"; - DiagnosticCode[DiagnosticCode["Exported_interface__0__extends_interface_from_inaccessible_module__1_"] = 92] = "Exported_interface__0__extends_interface_from_inaccessible_module__1_"; - DiagnosticCode[DiagnosticCode["Public_static_property__0__of__exported_class_has_or_is_using_private_type__1_"] = 93] = "Public_static_property__0__of__exported_class_has_or_is_using_private_type__1_"; - DiagnosticCode[DiagnosticCode["Public_property__0__of__exported_class_has_or_is_using_private_type__1_"] = 94] = "Public_property__0__of__exported_class_has_or_is_using_private_type__1_"; - DiagnosticCode[DiagnosticCode["Property__0__of__exported_interface_has_or_is_using_private_type__1_"] = 95] = "Property__0__of__exported_interface_has_or_is_using_private_type__1_"; - DiagnosticCode[DiagnosticCode["Exported_variable__0__has_or_is_using_private_type__1_"] = 96] = "Exported_variable__0__has_or_is_using_private_type__1_"; - DiagnosticCode[DiagnosticCode["Public_static_property__0__of__exported_class_is_using_inaccessible_module__1_"] = 97] = "Public_static_property__0__of__exported_class_is_using_inaccessible_module__1_"; - DiagnosticCode[DiagnosticCode["Public_property__0__of__exported_class_is_using_inaccessible_module__1_"] = 98] = "Public_property__0__of__exported_class_is_using_inaccessible_module__1_"; - DiagnosticCode[DiagnosticCode["Property__0__of__exported_interface_is_using_inaccessible_module__1_"] = 99] = "Property__0__of__exported_interface_is_using_inaccessible_module__1_"; - DiagnosticCode[DiagnosticCode["Exported_variable__0__is_using_inaccessible_module__1_"] = 100] = "Exported_variable__0__is_using_inaccessible_module__1_"; - DiagnosticCode[DiagnosticCode["Parameter__0__of_constructor_from_exported_class_has_or_is_using_private_type__1_"] = 101] = "Parameter__0__of_constructor_from_exported_class_has_or_is_using_private_type__1_"; - DiagnosticCode[DiagnosticCode["Parameter__0__of_public_static_property_setter_from_exported_class_has_or_is_using_private_type__1_"] = 102] = "Parameter__0__of_public_static_property_setter_from_exported_class_has_or_is_using_private_type__1_"; - DiagnosticCode[DiagnosticCode["Parameter__0__of_public_property_setter_from_exported_class_has_or_is_using_private_type__1_"] = 103] = "Parameter__0__of_public_property_setter_from_exported_class_has_or_is_using_private_type__1_"; - DiagnosticCode[DiagnosticCode["Parameter__0__of_constructor_signature_from_exported_interface_has_or_is_using_private_type__1_"] = 104] = "Parameter__0__of_constructor_signature_from_exported_interface_has_or_is_using_private_type__1_"; - DiagnosticCode[DiagnosticCode["Parameter__0__of_call_signature_from_exported_interface_has_or_is_using_private_type__1_"] = 105] = "Parameter__0__of_call_signature_from_exported_interface_has_or_is_using_private_type__1_"; - DiagnosticCode[DiagnosticCode["Parameter__0__of_public_static_method_from_exported_class_has_or_is_using_private_type__1_"] = 106] = "Parameter__0__of_public_static_method_from_exported_class_has_or_is_using_private_type__1_"; - DiagnosticCode[DiagnosticCode["Parameter__0__of_public_method_from_exported_class_has_or_is_using_private_type__1_"] = 107] = "Parameter__0__of_public_method_from_exported_class_has_or_is_using_private_type__1_"; - DiagnosticCode[DiagnosticCode["Parameter__0__of_method_from_exported_interface_has_or_is_using_private_type__1_"] = 108] = "Parameter__0__of_method_from_exported_interface_has_or_is_using_private_type__1_"; - DiagnosticCode[DiagnosticCode["Parameter__0__of_exported_function_has_or_is_using_private_type__1_"] = 109] = "Parameter__0__of_exported_function_has_or_is_using_private_type__1_"; - DiagnosticCode[DiagnosticCode["Parameter__0__of_constructor_from_exported_class_is_using_inaccessible_module__1_"] = 110] = "Parameter__0__of_constructor_from_exported_class_is_using_inaccessible_module__1_"; - DiagnosticCode[DiagnosticCode["Parameter__0__of_public_static_property_setter_from_exported_class_is_using_inaccessible_module__1_"] = 111] = "Parameter__0__of_public_static_property_setter_from_exported_class_is_using_inaccessible_module__1_"; - DiagnosticCode[DiagnosticCode["Parameter__0__of_public_property_setter_from_exported_class_is_using_inaccessible_module__1_"] = 112] = "Parameter__0__of_public_property_setter_from_exported_class_is_using_inaccessible_module__1_"; - DiagnosticCode[DiagnosticCode["Parameter__0__of_constructor_signature_from_exported_interface_is_using_inaccessible_module__1_"] = 113] = "Parameter__0__of_constructor_signature_from_exported_interface_is_using_inaccessible_module__1_"; - DiagnosticCode[DiagnosticCode["Parameter__0__of_call_signature_from_exported_interface_is_using_inaccessible_module__1_"] = 114] = "Parameter__0__of_call_signature_from_exported_interface_is_using_inaccessible_module__1_"; - DiagnosticCode[DiagnosticCode["Parameter__0__of_public_static_method_from_exported_class_is_using_inaccessible_module__1_"] = 115] = "Parameter__0__of_public_static_method_from_exported_class_is_using_inaccessible_module__1_"; - DiagnosticCode[DiagnosticCode["Parameter__0__of_public_method_from_exported_class_is_using_inaccessible_module__1_"] = 116] = "Parameter__0__of_public_method_from_exported_class_is_using_inaccessible_module__1_"; - DiagnosticCode[DiagnosticCode["Parameter__0__of_method_from_exported_interface_is_using_inaccessible_module__1_"] = 117] = "Parameter__0__of_method_from_exported_interface_is_using_inaccessible_module__1_"; - DiagnosticCode[DiagnosticCode["Parameter__0__of_exported_function_is_using_inaccessible_module__1_"] = 118] = "Parameter__0__of_exported_function_is_using_inaccessible_module__1_"; - DiagnosticCode[DiagnosticCode["Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_private_type__0_"] = 119] = "Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_private_type__0_"; - DiagnosticCode[DiagnosticCode["Return_type_of_public_property_getter_from_exported_class_has_or_is_using_private_type__0_"] = 120] = "Return_type_of_public_property_getter_from_exported_class_has_or_is_using_private_type__0_"; - DiagnosticCode[DiagnosticCode["Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_private_type__0_"] = 121] = "Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_private_type__0_"; - DiagnosticCode[DiagnosticCode["Return_type_of_call_signature_from_exported_interface_has_or_is_using_private_type__0_"] = 122] = "Return_type_of_call_signature_from_exported_interface_has_or_is_using_private_type__0_"; - DiagnosticCode[DiagnosticCode["Return_type_of_index_signature_from_exported_interface_has_or_is_using_private_type__0_"] = 123] = "Return_type_of_index_signature_from_exported_interface_has_or_is_using_private_type__0_"; - DiagnosticCode[DiagnosticCode["Return_type_of_public_static_method_from_exported_class_has_or_is_using_private_type__0_"] = 124] = "Return_type_of_public_static_method_from_exported_class_has_or_is_using_private_type__0_"; - DiagnosticCode[DiagnosticCode["Return_type_of_public_method_from_exported_class_has_or_is_using_private_type__0_"] = 125] = "Return_type_of_public_method_from_exported_class_has_or_is_using_private_type__0_"; - DiagnosticCode[DiagnosticCode["Return_type_of_method_from_exported_interface_has_or_is_using_private_type__0_"] = 126] = "Return_type_of_method_from_exported_interface_has_or_is_using_private_type__0_"; - DiagnosticCode[DiagnosticCode["Return_type_of_exported_function_has_or_is_using_private_type__0_"] = 127] = "Return_type_of_exported_function_has_or_is_using_private_type__0_"; - DiagnosticCode[DiagnosticCode["Return_type_of_public_static_property_getter_from_exported_class_is_using_inaccessible_module__0_"] = 128] = "Return_type_of_public_static_property_getter_from_exported_class_is_using_inaccessible_module__0_"; - DiagnosticCode[DiagnosticCode["Return_type_of_public_property_getter_from_exported_class_is_using_inaccessible_module__0_"] = 129] = "Return_type_of_public_property_getter_from_exported_class_is_using_inaccessible_module__0_"; - DiagnosticCode[DiagnosticCode["Return_type_of_constructor_signature_from_exported_interface_is_using_inaccessible_module__0_"] = 130] = "Return_type_of_constructor_signature_from_exported_interface_is_using_inaccessible_module__0_"; - DiagnosticCode[DiagnosticCode["Return_type_of_call_signature_from_exported_interface_is_using_inaccessible_module__0_"] = 131] = "Return_type_of_call_signature_from_exported_interface_is_using_inaccessible_module__0_"; - DiagnosticCode[DiagnosticCode["Return_type_of_index_signature_from_exported_interface_is_using_inaccessible_module__0_"] = 132] = "Return_type_of_index_signature_from_exported_interface_is_using_inaccessible_module__0_"; - DiagnosticCode[DiagnosticCode["Return_type_of_public_static_method_from_exported_class_is_using_inaccessible_module__0_"] = 133] = "Return_type_of_public_static_method_from_exported_class_is_using_inaccessible_module__0_"; - DiagnosticCode[DiagnosticCode["Return_type_of_public_method_from_exported_class_is_using_inaccessible_module__0_"] = 134] = "Return_type_of_public_method_from_exported_class_is_using_inaccessible_module__0_"; - DiagnosticCode[DiagnosticCode["Return_type_of_method_from_exported_interface_is_using_inaccessible_module__0_"] = 135] = "Return_type_of_method_from_exported_interface_is_using_inaccessible_module__0_"; - DiagnosticCode[DiagnosticCode["Return_type_of_exported_function_is_using_inaccessible_module__0_"] = 136] = "Return_type_of_exported_function_is_using_inaccessible_module__0_"; - DiagnosticCode[DiagnosticCode["_new_T____cannot_be_used_to_create_an_array__Use__new_Array_T_____instead"] = 137] = "_new_T____cannot_be_used_to_create_an_array__Use__new_Array_T_____instead"; - DiagnosticCode[DiagnosticCode["A_parameter_list_must_follow_a_generic_type_argument_list______expected"] = 138] = "A_parameter_list_must_follow_a_generic_type_argument_list______expected"; - DiagnosticCode[DiagnosticCode["Multiple_constructor_implementations_are_not_allowed"] = 139] = "Multiple_constructor_implementations_are_not_allowed"; - DiagnosticCode[DiagnosticCode["Unable_to_resolve_external_module__0_"] = 140] = "Unable_to_resolve_external_module__0_"; - DiagnosticCode[DiagnosticCode["Module_cannot_be_aliased_to_a_non_module_type"] = 141] = "Module_cannot_be_aliased_to_a_non_module_type"; - DiagnosticCode[DiagnosticCode["A_class_may_only_extend_another_class"] = 142] = "A_class_may_only_extend_another_class"; - DiagnosticCode[DiagnosticCode["A_class_may_only_implement_another_class_or_interface"] = 143] = "A_class_may_only_implement_another_class_or_interface"; - DiagnosticCode[DiagnosticCode["An_interface_may_only_extend_another_class_or_interface"] = 144] = "An_interface_may_only_extend_another_class_or_interface"; - DiagnosticCode[DiagnosticCode["An_interface_cannot_implement_another_type"] = 145] = "An_interface_cannot_implement_another_type"; - DiagnosticCode[DiagnosticCode["Unable_to_resolve_type"] = 146] = "Unable_to_resolve_type"; - DiagnosticCode[DiagnosticCode["Unable_to_resolve_type_of__0_"] = 147] = "Unable_to_resolve_type_of__0_"; - DiagnosticCode[DiagnosticCode["Unable_to_resolve_type_parameter_constraint"] = 148] = "Unable_to_resolve_type_parameter_constraint"; - DiagnosticCode[DiagnosticCode["Type_parameter_constraint_cannot_be_a_primitive_type"] = 149] = "Type_parameter_constraint_cannot_be_a_primitive_type"; - DiagnosticCode[DiagnosticCode["Supplied_parameters_do_not_match_any_signature_of_call_target"] = 150] = "Supplied_parameters_do_not_match_any_signature_of_call_target"; - DiagnosticCode[DiagnosticCode["Supplied_parameters_do_not_match_any_signature_of_call_target__NL__0"] = 151] = "Supplied_parameters_do_not_match_any_signature_of_call_target__NL__0"; - DiagnosticCode[DiagnosticCode["Invalid__new__expression"] = 152] = "Invalid__new__expression"; - DiagnosticCode[DiagnosticCode["Call_signatures_used_in_a__new__expression_must_have_a__void__return_type"] = 153] = "Call_signatures_used_in_a__new__expression_must_have_a__void__return_type"; - DiagnosticCode[DiagnosticCode["Could_not_select_overload_for__new__expression"] = 154] = "Could_not_select_overload_for__new__expression"; - DiagnosticCode[DiagnosticCode["Type__0__does_not_satisfy_the_constraint__1__for_type_parameter__2_"] = 155] = "Type__0__does_not_satisfy_the_constraint__1__for_type_parameter__2_"; - DiagnosticCode[DiagnosticCode["Could_not_select_overload_for__call__expression"] = 156] = "Could_not_select_overload_for__call__expression"; - DiagnosticCode[DiagnosticCode["Unable_to_invoke_type_with_no_call_signatures"] = 157] = "Unable_to_invoke_type_with_no_call_signatures"; - DiagnosticCode[DiagnosticCode["Calls_to__super__are_only_valid_inside_a_class"] = 158] = "Calls_to__super__are_only_valid_inside_a_class"; - DiagnosticCode[DiagnosticCode["Generic_type__0__requires_1_type_argument_s_"] = 159] = "Generic_type__0__requires_1_type_argument_s_"; - DiagnosticCode[DiagnosticCode["Type_of_conditional_expression_cannot_be_determined__Best_common_type_could_not_be_found_between__0__and__1_"] = 160] = "Type_of_conditional_expression_cannot_be_determined__Best_common_type_could_not_be_found_between__0__and__1_"; - DiagnosticCode[DiagnosticCode["Type_of_array_literal_cannot_be_determined__Best_common_type_could_not_be_found_for_array_elements"] = 161] = "Type_of_array_literal_cannot_be_determined__Best_common_type_could_not_be_found_for_array_elements"; - DiagnosticCode[DiagnosticCode["Could_not_find_enclosing_symbol_for_dotted_name__0_"] = 162] = "Could_not_find_enclosing_symbol_for_dotted_name__0_"; - DiagnosticCode[DiagnosticCode["The_property__0__does_not_exist_on_value_of_type__1__"] = 163] = "The_property__0__does_not_exist_on_value_of_type__1__"; - DiagnosticCode[DiagnosticCode["Could_not_find_symbol__0_"] = 164] = "Could_not_find_symbol__0_"; - DiagnosticCode[DiagnosticCode["_get__and__set__accessor_must_have_the_same_type"] = 165] = "_get__and__set__accessor_must_have_the_same_type"; - DiagnosticCode[DiagnosticCode["_this__cannot_be_referenced_in_current_location"] = 166] = "_this__cannot_be_referenced_in_current_location"; - DiagnosticCode[DiagnosticCode["Use_of_deprecated__bool__type__Use__boolean__instead"] = 167] = "Use_of_deprecated__bool__type__Use__boolean__instead"; - - DiagnosticCode[DiagnosticCode["Class__0__is_recursively_referenced_as_a_base_type_of_itself"] = 168] = "Class__0__is_recursively_referenced_as_a_base_type_of_itself"; - DiagnosticCode[DiagnosticCode["Interface__0__is_recursively_referenced_as_a_base_type_of_itself"] = 169] = "Interface__0__is_recursively_referenced_as_a_base_type_of_itself"; - DiagnosticCode[DiagnosticCode["_super__property_access_is_permitted_only_in_a_constructor__instance_member_function__or_instance_member_accessor_of_a_derived_class"] = 170] = "_super__property_access_is_permitted_only_in_a_constructor__instance_member_function__or_instance_member_accessor_of_a_derived_class"; - DiagnosticCode[DiagnosticCode["_super__cannot_be_referenced_in_non_derived_classes"] = 171] = "_super__cannot_be_referenced_in_non_derived_classes"; - DiagnosticCode[DiagnosticCode["A__super__call_must_be_the_first_statement_in_the_constructor_when_a_class_contains_intialized_properties_or_has_parameter_properties"] = 172] = "A__super__call_must_be_the_first_statement_in_the_constructor_when_a_class_contains_intialized_properties_or_has_parameter_properties"; - DiagnosticCode[DiagnosticCode["Constructors_for_derived_classes_must_contain_a__super__call"] = 173] = "Constructors_for_derived_classes_must_contain_a__super__call"; - DiagnosticCode[DiagnosticCode["Super_calls_are_not_permitted_outside_constructors_or_in_local_functions_inside_constructors"] = 174] = "Super_calls_are_not_permitted_outside_constructors_or_in_local_functions_inside_constructors"; - DiagnosticCode[DiagnosticCode["_0_1__is_inaccessible"] = 175] = "_0_1__is_inaccessible"; - DiagnosticCode[DiagnosticCode["_this__cannot_be_referenced_within_module_bodies"] = 176] = "_this__cannot_be_referenced_within_module_bodies"; - DiagnosticCode[DiagnosticCode["_this__must_only_be_used_inside_a_function_or_script_context"] = 177] = "_this__must_only_be_used_inside_a_function_or_script_context"; - DiagnosticCode[DiagnosticCode["Invalid__addition__expression___types_do_not_agree"] = 178] = "Invalid__addition__expression___types_do_not_agree"; - DiagnosticCode[DiagnosticCode["The_right_hand_side_of_an_arithmetic_operation_must_be_of_type__any____number__or_an_enum_type"] = 179] = "The_right_hand_side_of_an_arithmetic_operation_must_be_of_type__any____number__or_an_enum_type"; - DiagnosticCode[DiagnosticCode["The_left_hand_side_of_an_arithmetic_operation_must_be_of_type__any____number__or_an_enum_type"] = 180] = "The_left_hand_side_of_an_arithmetic_operation_must_be_of_type__any____number__or_an_enum_type"; - DiagnosticCode[DiagnosticCode["The_type_of_a_unary_arithmetic_operation_operand_must_be_of_type__any____number__or_an_enum_type"] = 181] = "The_type_of_a_unary_arithmetic_operation_operand_must_be_of_type__any____number__or_an_enum_type"; - DiagnosticCode[DiagnosticCode["Variable_declarations_for_for_in_expressions_cannot_contain_a_type_annotation"] = 182] = "Variable_declarations_for_for_in_expressions_cannot_contain_a_type_annotation"; - DiagnosticCode[DiagnosticCode["Variable_declarations_for_for_in_expressions_must_be_of_types__string__or__any_"] = 183] = "Variable_declarations_for_for_in_expressions_must_be_of_types__string__or__any_"; - DiagnosticCode[DiagnosticCode["The_right_operand_of_a_for_in_expression_must_be_of_type__any____an_object_type_or_a_type_parameter"] = 184] = "The_right_operand_of_a_for_in_expression_must_be_of_type__any____an_object_type_or_a_type_parameter"; - DiagnosticCode[DiagnosticCode["The_left_hand_side_of_an__in__expression_must_be_of_types__string__or__any_"] = 185] = "The_left_hand_side_of_an__in__expression_must_be_of_types__string__or__any_"; - DiagnosticCode[DiagnosticCode["The_right_hand_side_of_an__in__expression_must_be_of_type__any___an_object_type_or_a_type_parameter"] = 186] = "The_right_hand_side_of_an__in__expression_must_be_of_type__any___an_object_type_or_a_type_parameter"; - DiagnosticCode[DiagnosticCode["The_left_hand_side_of_an__instanceOf__expression_must_be_of_type__any___an_object_type_or_a_type_parameter"] = 187] = "The_left_hand_side_of_an__instanceOf__expression_must_be_of_type__any___an_object_type_or_a_type_parameter"; - DiagnosticCode[DiagnosticCode["The_right_hand_side_of_an__instanceOf__expression_must_be_of_type__any__or_a_subtype_of_the__Function__interface_type"] = 188] = "The_right_hand_side_of_an__instanceOf__expression_must_be_of_type__any__or_a_subtype_of_the__Function__interface_type"; - DiagnosticCode[DiagnosticCode["Setters_cannot_return_a_value"] = 189] = "Setters_cannot_return_a_value"; - DiagnosticCode[DiagnosticCode["Tried_to_set_variable_type_to_module_type__0__"] = 190] = "Tried_to_set_variable_type_to_module_type__0__"; - DiagnosticCode[DiagnosticCode["Tried_to_set_variable_type_to_uninitialized_module_type__0__"] = 191] = "Tried_to_set_variable_type_to_uninitialized_module_type__0__"; - DiagnosticCode[DiagnosticCode["Function__0__declared_a_non_void_return_type__but_has_no_return_expression"] = 192] = "Function__0__declared_a_non_void_return_type__but_has_no_return_expression"; - DiagnosticCode[DiagnosticCode["Getters_must_return_a_value"] = 193] = "Getters_must_return_a_value"; - DiagnosticCode[DiagnosticCode["Getter_and_setter_accessors_do_not_agree_in_visibility"] = 194] = "Getter_and_setter_accessors_do_not_agree_in_visibility"; - DiagnosticCode[DiagnosticCode["Invalid_left_hand_side_of_assignment_expression"] = 195] = "Invalid_left_hand_side_of_assignment_expression"; - DiagnosticCode[DiagnosticCode["Function_declared_a_non_void_return_type__but_has_no_return_expression"] = 196] = "Function_declared_a_non_void_return_type__but_has_no_return_expression"; - DiagnosticCode[DiagnosticCode["Cannot_resolve_return_type_reference"] = 197] = "Cannot_resolve_return_type_reference"; - DiagnosticCode[DiagnosticCode["Constructors_cannot_have_a_return_type_of__void_"] = 198] = "Constructors_cannot_have_a_return_type_of__void_"; - DiagnosticCode[DiagnosticCode["Subsequent_variable_declarations_must_have_the_same_type___Variable__0__must_be_of_type__1___but_here_has_type___2_"] = 199] = "Subsequent_variable_declarations_must_have_the_same_type___Variable__0__must_be_of_type__1___but_here_has_type___2_"; - DiagnosticCode[DiagnosticCode["All_symbols_within_a__with__block_will_be_resolved_to__any__"] = 200] = "All_symbols_within_a__with__block_will_be_resolved_to__any__"; - DiagnosticCode[DiagnosticCode["Import_declarations_in_an_internal_module_cannot_reference_an_external_module"] = 201] = "Import_declarations_in_an_internal_module_cannot_reference_an_external_module"; - DiagnosticCode[DiagnosticCode["Class__0__declares_interface__1__but_does_not_implement_it__NL__2"] = 202] = "Class__0__declares_interface__1__but_does_not_implement_it__NL__2"; - DiagnosticCode[DiagnosticCode["Class__0__declares_class__1__but_does_not_implement_it__NL__2"] = 203] = "Class__0__declares_class__1__but_does_not_implement_it__NL__2"; - DiagnosticCode[DiagnosticCode["The_operand_of_an_increment_or_decrement_operator_must_be_a_variable__property_or_indexer"] = 204] = "The_operand_of_an_increment_or_decrement_operator_must_be_a_variable__property_or_indexer"; - DiagnosticCode[DiagnosticCode["_this__cannot_be_referenced_in_initializers_in_a_class_body"] = 205] = "_this__cannot_be_referenced_in_initializers_in_a_class_body"; - DiagnosticCode[DiagnosticCode["Class__0__cannot_extend_class__1__NL__2"] = 206] = "Class__0__cannot_extend_class__1__NL__2"; - DiagnosticCode[DiagnosticCode["Interface__0__cannot_extend_class__1__NL__2"] = 207] = "Interface__0__cannot_extend_class__1__NL__2"; - DiagnosticCode[DiagnosticCode["Interface__0__cannot_extend_interface__1__NL__2"] = 208] = "Interface__0__cannot_extend_interface__1__NL__2"; - DiagnosticCode[DiagnosticCode["Duplicate_overload_signature_for__0_"] = 209] = "Duplicate_overload_signature_for__0_"; - DiagnosticCode[DiagnosticCode["Duplicate_constructor_overload_signature"] = 210] = "Duplicate_constructor_overload_signature"; - DiagnosticCode[DiagnosticCode["Duplicate_overload_call_signature"] = 211] = "Duplicate_overload_call_signature"; - DiagnosticCode[DiagnosticCode["Duplicate_overload_construct_signature"] = 212] = "Duplicate_overload_construct_signature"; - DiagnosticCode[DiagnosticCode["Overload_signature_is_not_compatible_with_function_definition"] = 213] = "Overload_signature_is_not_compatible_with_function_definition"; - DiagnosticCode[DiagnosticCode["Overload_signature_is_not_compatible_with_function_definition__NL__0"] = 214] = "Overload_signature_is_not_compatible_with_function_definition__NL__0"; - DiagnosticCode[DiagnosticCode["Overload_signatures_must_all_be_public_or_private"] = 215] = "Overload_signatures_must_all_be_public_or_private"; - DiagnosticCode[DiagnosticCode["Overload_signatures_must_all_be_exported_or_local"] = 216] = "Overload_signatures_must_all_be_exported_or_local"; - DiagnosticCode[DiagnosticCode["Overload_signatures_must_all_be_ambient_or_non_ambient"] = 217] = "Overload_signatures_must_all_be_ambient_or_non_ambient"; - DiagnosticCode[DiagnosticCode["Overload_signatures_must_all_be_optional_or_required"] = 218] = "Overload_signatures_must_all_be_optional_or_required"; - DiagnosticCode[DiagnosticCode["Specialized_overload_signature_is_not_subtype_of_any_non_specialized_signature"] = 219] = "Specialized_overload_signature_is_not_subtype_of_any_non_specialized_signature"; - DiagnosticCode[DiagnosticCode["_this__cannot_be_referenced_in_constructor_arguments"] = 220] = "_this__cannot_be_referenced_in_constructor_arguments"; - DiagnosticCode[DiagnosticCode["Static_member_cannot_be_accessed_off_an_instance_variable"] = 221] = "Static_member_cannot_be_accessed_off_an_instance_variable"; - DiagnosticCode[DiagnosticCode["Instance_member_cannot_be_accessed_off_a_class"] = 222] = "Instance_member_cannot_be_accessed_off_a_class"; - DiagnosticCode[DiagnosticCode["Untyped_function_calls_may_not_accept_type_arguments"] = 223] = "Untyped_function_calls_may_not_accept_type_arguments"; - DiagnosticCode[DiagnosticCode["Non_generic_functions_may_not_accept_type_arguments"] = 224] = "Non_generic_functions_may_not_accept_type_arguments"; - DiagnosticCode[DiagnosticCode["A_generic_type_may_not_reference_itself_with_its_own_type_parameters"] = 225] = "A_generic_type_may_not_reference_itself_with_its_own_type_parameters"; - DiagnosticCode[DiagnosticCode["Static_methods_cannot_reference_class_type_parameters"] = 226] = "Static_methods_cannot_reference_class_type_parameters"; - DiagnosticCode[DiagnosticCode["Value_of_type__0__is_not_callable__Did_you_mean_to_include__new___"] = 227] = "Value_of_type__0__is_not_callable__Did_you_mean_to_include__new___"; - DiagnosticCode[DiagnosticCode["Rest_parameters_must_be_array_types"] = 228] = "Rest_parameters_must_be_array_types"; - DiagnosticCode[DiagnosticCode["Overload_signature_implementation_cannot_use_specialized_type"] = 229] = "Overload_signature_implementation_cannot_use_specialized_type"; - DiagnosticCode[DiagnosticCode["Export_assignments_may_only_be_used_in_External_modules"] = 230] = "Export_assignments_may_only_be_used_in_External_modules"; - DiagnosticCode[DiagnosticCode["Export_assignments_may_only_be_made_with_acceptable_kinds"] = 231] = "Export_assignments_may_only_be_made_with_acceptable_kinds"; - DiagnosticCode[DiagnosticCode["Only_public_instance_methods_of_the_base_class_are_accessible_via_the_super_keyword"] = 232] = "Only_public_instance_methods_of_the_base_class_are_accessible_via_the_super_keyword"; - DiagnosticCode[DiagnosticCode["Numeric_indexer_type___0___must_be_a_subtype_of_string_indexer_type___1__"] = 233] = "Numeric_indexer_type___0___must_be_a_subtype_of_string_indexer_type___1__"; - DiagnosticCode[DiagnosticCode["Numeric_indexer_type___0___must_be_a_subtype_of_string_indexer_type___1____NL__2"] = 234] = "Numeric_indexer_type___0___must_be_a_subtype_of_string_indexer_type___1____NL__2"; - DiagnosticCode[DiagnosticCode["All_numerically_named_properties_must_be_subtypes_of_numeric_indexer_type___0__"] = 235] = "All_numerically_named_properties_must_be_subtypes_of_numeric_indexer_type___0__"; - DiagnosticCode[DiagnosticCode["All_numerically_named_properties_must_be_subtypes_of_numeric_indexer_type___0____NL__1"] = 236] = "All_numerically_named_properties_must_be_subtypes_of_numeric_indexer_type___0____NL__1"; - DiagnosticCode[DiagnosticCode["All_named_properties_must_be_subtypes_of_string_indexer_type___0__"] = 237] = "All_named_properties_must_be_subtypes_of_string_indexer_type___0__"; - DiagnosticCode[DiagnosticCode["All_named_properties_must_be_subtypes_of_string_indexer_type___0____NL__1"] = 238] = "All_named_properties_must_be_subtypes_of_string_indexer_type___0____NL__1"; - DiagnosticCode[DiagnosticCode["Generic_type_references_must_include_all_type_arguments"] = 239] = "Generic_type_references_must_include_all_type_arguments"; - - DiagnosticCode[DiagnosticCode["Type__0__is_missing_property__1__from_type__2_"] = 240] = "Type__0__is_missing_property__1__from_type__2_"; - DiagnosticCode[DiagnosticCode["Types_of_property__0__of_types__1__and__2__are_incompatible"] = 241] = "Types_of_property__0__of_types__1__and__2__are_incompatible"; - DiagnosticCode[DiagnosticCode["Types_of_property__0__of_types__1__and__2__are_incompatible__NL__3"] = 242] = "Types_of_property__0__of_types__1__and__2__are_incompatible__NL__3"; - DiagnosticCode[DiagnosticCode["Property__0__defined_as_private_in_type__1__is_defined_as_public_in_type__2_"] = 243] = "Property__0__defined_as_private_in_type__1__is_defined_as_public_in_type__2_"; - DiagnosticCode[DiagnosticCode["Property__0__defined_as_public_in_type__1__is_defined_as_private_in_type__2_"] = 244] = "Property__0__defined_as_public_in_type__1__is_defined_as_private_in_type__2_"; - DiagnosticCode[DiagnosticCode["Types__0__and__1__define_property__2__as_private"] = 245] = "Types__0__and__1__define_property__2__as_private"; - DiagnosticCode[DiagnosticCode["Call_signatures_of_types__0__and__1__are_incompatible"] = 246] = "Call_signatures_of_types__0__and__1__are_incompatible"; - DiagnosticCode[DiagnosticCode["Call_signatures_of_types__0__and__1__are_incompatible__NL__2"] = 247] = "Call_signatures_of_types__0__and__1__are_incompatible__NL__2"; - DiagnosticCode[DiagnosticCode["Type__0__requires_a_call_signature__but_Type__1__lacks_one"] = 248] = "Type__0__requires_a_call_signature__but_Type__1__lacks_one"; - DiagnosticCode[DiagnosticCode["Construct_signatures_of_types__0__and__1__are_incompatible"] = 249] = "Construct_signatures_of_types__0__and__1__are_incompatible"; - DiagnosticCode[DiagnosticCode["Construct_signatures_of_types__0__and__1__are_incompatible__NL__2"] = 250] = "Construct_signatures_of_types__0__and__1__are_incompatible__NL__2"; - DiagnosticCode[DiagnosticCode["Type__0__requires_a_construct_signature__but_Type__1__lacks_one"] = 251] = "Type__0__requires_a_construct_signature__but_Type__1__lacks_one"; - DiagnosticCode[DiagnosticCode["Index_signatures_of_types__0__and__1__are_incompatible"] = 252] = "Index_signatures_of_types__0__and__1__are_incompatible"; - DiagnosticCode[DiagnosticCode["Index_signatures_of_types__0__and__1__are_incompatible__NL__2"] = 253] = "Index_signatures_of_types__0__and__1__are_incompatible__NL__2"; - DiagnosticCode[DiagnosticCode["Call_signature_expects__0__or_fewer_parameters"] = 254] = "Call_signature_expects__0__or_fewer_parameters"; - DiagnosticCode[DiagnosticCode["Could_not_apply_type__0__to_argument__1__which_is_of_type__2_"] = 255] = "Could_not_apply_type__0__to_argument__1__which_is_of_type__2_"; - DiagnosticCode[DiagnosticCode["Class__0__defines_instance_member_accessor__1___but_extended_class__2__defines_it_as_instance_member_function"] = 256] = "Class__0__defines_instance_member_accessor__1___but_extended_class__2__defines_it_as_instance_member_function"; - DiagnosticCode[DiagnosticCode["Class__0__defines_instance_member_property__1___but_extended_class__2__defines_it_as_instance_member_function"] = 257] = "Class__0__defines_instance_member_property__1___but_extended_class__2__defines_it_as_instance_member_function"; - DiagnosticCode[DiagnosticCode["Class__0__defines_instance_member_function__1___but_extended_class__2__defines_it_as_instance_member_accessor"] = 258] = "Class__0__defines_instance_member_function__1___but_extended_class__2__defines_it_as_instance_member_accessor"; - DiagnosticCode[DiagnosticCode["Class__0__defines_instance_member_function__1___but_extended_class__2__defines_it_as_instance_member_property"] = 259] = "Class__0__defines_instance_member_function__1___but_extended_class__2__defines_it_as_instance_member_property"; - DiagnosticCode[DiagnosticCode["Types_of_static_property__0__of_class__1__and_class__2__are_incompatible"] = 260] = "Types_of_static_property__0__of_class__1__and_class__2__are_incompatible"; - DiagnosticCode[DiagnosticCode["Types_of_static_property__0__of_class__1__and_class__2__are_incompatible__NL__3"] = 261] = "Types_of_static_property__0__of_class__1__and_class__2__are_incompatible__NL__3"; - DiagnosticCode[DiagnosticCode["Type_reference_cannot_refer_to_container__0_"] = 262] = "Type_reference_cannot_refer_to_container__0_"; - DiagnosticCode[DiagnosticCode["Type_reference_must_refer_to_type"] = 263] = "Type_reference_must_refer_to_type"; - DiagnosticCode[DiagnosticCode["Enums_with_multiple_declarations_must_provide_an_initializer_for_the_first_enum_element"] = 264] = "Enums_with_multiple_declarations_must_provide_an_initializer_for_the_first_enum_element"; - - DiagnosticCode[DiagnosticCode["Current_host_does_not_support__w_atch_option"] = 265] = "Current_host_does_not_support__w_atch_option"; - DiagnosticCode[DiagnosticCode["ECMAScript_target_version__0__not_supported___Using_default__1__code_generation"] = 266] = "ECMAScript_target_version__0__not_supported___Using_default__1__code_generation"; - DiagnosticCode[DiagnosticCode["Module_code_generation__0__not_supported___Using_default__1__code_generation"] = 267] = "Module_code_generation__0__not_supported___Using_default__1__code_generation"; - DiagnosticCode[DiagnosticCode["Could_not_find_file___0_"] = 268] = "Could_not_find_file___0_"; - DiagnosticCode[DiagnosticCode["Unknown_extension_for_file___0__Only__ts_and_d_ts_extensions_are_allowed"] = 269] = "Unknown_extension_for_file___0__Only__ts_and_d_ts_extensions_are_allowed"; - DiagnosticCode[DiagnosticCode["A_file_cannot_have_a_reference_itself"] = 270] = "A_file_cannot_have_a_reference_itself"; - DiagnosticCode[DiagnosticCode["Cannot_resolve_referenced_file___0_"] = 271] = "Cannot_resolve_referenced_file___0_"; - DiagnosticCode[DiagnosticCode["Cannot_resolve_imported_file___0_"] = 272] = "Cannot_resolve_imported_file___0_"; - DiagnosticCode[DiagnosticCode["Cannot_find_the_common_subdirectory_path_for_the_input_files"] = 273] = "Cannot_find_the_common_subdirectory_path_for_the_input_files"; - DiagnosticCode[DiagnosticCode["Cannot_compile_dynamic_modules_when_emitting_into_single_file"] = 274] = "Cannot_compile_dynamic_modules_when_emitting_into_single_file"; - DiagnosticCode[DiagnosticCode["Emit_Error__0"] = 275] = "Emit_Error__0"; - })(TypeScript.DiagnosticCode || (TypeScript.DiagnosticCode = {})); - var DiagnosticCode = TypeScript.DiagnosticCode; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - TypeScript.diagnosticMessages = { - error_TS_0__1: { - category: 3 /* NoPrefix */, - message: "error TS{0}: {1}", - code: 0 - }, - warning_TS_0__1: { - category: 3 /* NoPrefix */, - message: "warning TS{0}: {1}", - code: 1 - }, - _0__NL__1_TB__2: { - category: 3 /* NoPrefix */, - message: "{0}{NL}{{1}TB}{2}", - code: 21 - }, - _0_TB__1: { - category: 3 /* NoPrefix */, - message: "{{0}TB}{1}", - code: 22 - }, - Unrecognized_escape_sequence: { - category: 1 /* Error */, - message: "Unrecognized escape sequence.", - code: 1000 - }, - Unexpected_character_0: { - category: 1 /* Error */, - message: "Unexpected character {0}.", - code: 1001 - }, - Missing_closing_quote_character: { - category: 1 /* Error */, - message: "Missing close quote character.", - code: 1002 - }, - Identifier_expected: { - category: 1 /* Error */, - message: "Identifier expected.", - code: 1003 - }, - _0_keyword_expected: { - category: 1 /* Error */, - message: "'{0}' keyword expected.", - code: 1004 - }, - _0_expected: { - category: 1 /* Error */, - message: "'{0}' expected.", - code: 1005 - }, - Identifier_expected__0__is_a_keyword: { - category: 1 /* Error */, - message: "Identifier expected; '{0}' is a keyword.", - code: 1006 - }, - Automatic_semicolon_insertion_not_allowed: { - category: 1 /* Error */, - message: "Automatic semicolon insertion not allowed.", - code: 1007 - }, - Unexpected_token__0_expected: { - category: 1 /* Error */, - message: "Unexpected token; '{0}' expected.", - code: 1008 - }, - Trailing_separator_not_allowed: { - category: 1 /* Error */, - message: "Trailing separator not allowed.", - code: 1009 - }, - _StarSlash__expected: { - category: 1 /* Error */, - message: "'*/' expected.", - code: 1010 - }, - _public_or_private_modifier_must_precede__static_: { - category: 1 /* Error */, - message: "'public' or 'private' modifier must precede 'static'.", - code: 1011 - }, - Unexpected_token_: { - category: 1 /* Error */, - message: "Unexpected token.", - code: 1012 - }, - A_catch_clause_variable_cannot_have_a_type_annotation: { - category: 1 /* Error */, - message: "A catch clause variable cannot have a type annotation.", - code: 1013 - }, - Rest_parameter_must_be_last_in_list: { - category: 1 /* Error */, - message: "Rest parameter must be last in list.", - code: 1014 - }, - Parameter_cannot_have_question_mark_and_initializer: { - category: 1 /* Error */, - message: "Parameter cannot have question mark and initializer.", - code: 1015 - }, - Required_parameter_cannot_follow_optional_parameter: { - category: 1 /* Error */, - message: "Required parameter cannot follow optional parameter.", - code: 1016 - }, - Index_signatures_cannot_have_rest_parameters: { - category: 1 /* Error */, - message: "Index signatures cannot have rest parameters.", - code: 1017 - }, - Index_signature_parameter_cannot_have_accessibility_modifiers: { - category: 1 /* Error */, - message: "Index signature parameter cannot have accessibility modifiers.", - code: 1018 - }, - Index_signature_parameter_cannot_have_a_question_mark: { - category: 1 /* Error */, - message: "Index signature parameter cannot have a question mark.", - code: 1019 - }, - Index_signature_parameter_cannot_have_an_initializer: { - category: 1 /* Error */, - message: "Index signature parameter cannot have an initializer.", - code: 1020 - }, - Index_signature_must_have_a_type_annotation: { - category: 1 /* Error */, - message: "Index signature must have a type annotation.", - code: 1021 - }, - Index_signature_parameter_must_have_a_type_annotation: { - category: 1 /* Error */, - message: "Index signature parameter must have a type annotation.", - code: 1022 - }, - Index_signature_parameter_type_must_be__string__or__number_: { - category: 1 /* Error */, - message: "Index signature parameter type must be 'string' or 'number'.", - code: 1023 - }, - _extends__clause_already_seen: { - category: 1 /* Error */, - message: "'extends' clause already seen.", - code: 1024 - }, - _extends__clause_must_precede__implements__clause: { - category: 1 /* Error */, - message: "'extends' clause must precede 'implements' clause.", - code: 1025 - }, - Class_can_only_extend_single_type: { - category: 1 /* Error */, - message: "Class can only extend single type.", - code: 1026 - }, - _implements__clause_already_seen: { - category: 1 /* Error */, - message: "'implements' clause already seen.", - code: 1027 - }, - Accessibility_modifier_already_seen: { - category: 1 /* Error */, - message: "Accessibility modifier already seen.", - code: 1028 - }, - _0__modifier_must_precede__1__modifier: { - category: 1 /* Error */, - message: "'{0}' modifier must precede '{1}' modifier.", - code: 1029 - }, - _0__modifier_already_seen: { - category: 1 /* Error */, - message: "'{0}' modifier already seen.", - code: 1030 - }, - _0__modifier_cannot_appear_on_a_class_element: { - category: 1 /* Error */, - message: "'{0}' modifier cannot appear on a class element.", - code: 1031 - }, - Interface_declaration_cannot_have__implements__clause: { - category: 1 /* Error */, - message: "Interface declaration cannot have 'implements' clause.", - code: 1032 - }, - _super__invocation_cannot_have_type_arguments: { - category: 1 /* Error */, - message: "'super' invocation cannot have type arguments.", - code: 1034 - }, - Non_ambient_modules_cannot_use_quoted_names: { - category: 1 /* Error */, - message: "Non ambient modules cannot use quoted names.", - code: 1035 - }, - Statements_are_not_allowed_in_ambient_contexts: { - category: 1 /* Error */, - message: "Statements are not allowed in ambient contexts.", - code: 1036 - }, - Implementations_are_not_allowed_in_ambient_contexts: { - category: 1 /* Error */, - message: "Implementations are not allowed in ambient contexts.", - code: 1037 - }, - _declare__modifier_not_allowed_for_code_already_in_an_ambient_context: { - category: 1 /* Error */, - message: "'declare' modifier not allowed for code already in an ambient context.", - code: 1038 - }, - Initializers_are_not_allowed_in_ambient_contexts: { - category: 1 /* Error */, - message: "Initializers are not allowed in ambient contexts.", - code: 1039 - }, - Overload_and_ambient_signatures_cannot_specify_parameter_properties: { - category: 1 /* Error */, - message: "Overload and ambient signatures cannot specify parameter properties.", - code: 1040 - }, - Function_implementation_expected: { - category: 1 /* Error */, - message: "Function implementation expected.", - code: 1041 - }, - Constructor_implementation_expected: { - category: 1 /* Error */, - message: "Constructor implementation expected.", - code: 1042 - }, - Function_overload_name_must_be__0_: { - category: 1 /* Error */, - message: "Function overload name must be '{0}'.", - code: 1043 - }, - _0__modifier_cannot_appear_on_a_module_element: { - category: 1 /* Error */, - message: "'{0}' modifier cannot appear on a module element.", - code: 1044 - }, - _declare__modifier_cannot_appear_on_an_interface_declaration: { - category: 1 /* Error */, - message: "'declare' modifier cannot appear on an interface declaration.", - code: 1045 - }, - _declare__modifier_required_for_top_level_element: { - category: 1 /* Error */, - message: "'declare' modifier required for top level element.", - code: 1046 - }, - Rest_parameter_cannot_be_optional: { - category: 1 /* Error */, - message: "Rest parameter cannot be optional.", - code: 1047 - }, - Rest_parameter_cannot_have_initializer: { - category: 1 /* Error */, - message: "Rest parameter cannot have initializer.", - code: 1048 - }, - _set__accessor_must_have_only_one_parameter: { - category: 1 /* Error */, - message: "'set' accessor must have one and only one parameter.", - code: 1049 - }, - _set__accessor_parameter_cannot_have_accessibility_modifier: { - category: 1 /* Error */, - message: "'set' accessor parameter cannot have accessibility modifier.", - code: 1050 - }, - _set__accessor_parameter_cannot_be_optional: { - category: 1 /* Error */, - message: "'set' accessor parameter cannot be optional.", - code: 1051 - }, - _set__accessor_parameter_cannot_have_initializer: { - category: 1 /* Error */, - message: "'set' accessor parameter cannot have initializer.", - code: 1052 - }, - _set__accessor_cannot_have_rest_parameter: { - category: 1 /* Error */, - message: "'set' accessor cannot have rest parameter.", - code: 1053 - }, - _get__accessor_cannot_have_parameters: { - category: 1 /* Error */, - message: "'get' accessor cannot have parameters.", - code: 1054 - }, - Modifiers_cannot_appear_here: { - category: 1 /* Error */, - message: "Modifiers cannot appear here.", - code: 1055 - }, - Accessors_are_only_available_when_targeting_EcmaScript5_and_higher: { - category: 1 /* Error */, - message: "Accessors are only when targeting EcmaScript5 and higher.", - code: 1056 - }, - Class_name_cannot_be__0_: { - category: 1 /* Error */, - message: "Class name cannot be '{0}'.", - code: 1057 - }, - Interface_name_cannot_be__0_: { - category: 1 /* Error */, - message: "Interface name cannot be '{0}'.", - code: 1058 - }, - Enum_name_cannot_be__0_: { - category: 1 /* Error */, - message: "Enum name cannot be '{0}'.", - code: 1059 - }, - Module_name_cannot_be__0_: { - category: 1 /* Error */, - message: "Module name cannot be '{0}'.", - code: 1060 - }, - Enum_member_must_have_initializer: { - category: 1 /* Error */, - message: "Enum member must have initializer.", - code: 1061 - }, - _module_______is_deprecated__Use__require_______instead: { - category: 0 /* Warning */, - message: "'module(...)' is deprecated. Use 'require(...)' instead.", - code: 1062 - }, - Export_assignments_cannot_be_used_in_internal_modules: { - category: 1 /* Error */, - message: "Export assignments cannot be used in internal modules.", - code: 1063 - }, - Export_assignment_not_allowed_in_module_with_exported_element: { - category: 1 /* Error */, - message: "Export assignment not allowed in module with exported element.", - code: 1064 - }, - Module_cannot_have_multiple_export_assignments: { - category: 1 /* Error */, - message: "Module cannot have multiple export assignments.", - code: 1065 - }, - Duplicate_identifier__0_: { - category: 1 /* Error */, - message: "Duplicate identifier '{0}'.", - code: 2000 - }, - The_name__0__does_not_exist_in_the_current_scope: { - category: 1 /* Error */, - message: "The name '{0}' does not exist in the current scope.", - code: 2001 - }, - The_name__0__does_not_refer_to_a_value: { - category: 1 /* Error */, - message: "The name '{0}' does not refer to a value.", - code: 2002 - }, - Keyword__super__can_only_be_used_inside_a_class_instance_method: { - category: 1 /* Error */, - message: "Keyword 'super' can only be used inside a class instance method.", - code: 2003 - }, - The_left_hand_side_of_an_assignment_expression_must_be_a_variable__property_or_indexer: { - category: 1 /* Error */, - message: "The left-hand side of an assignment expression must be a variable, property or indexer.", - code: 2004 - }, - Value_of_type__0__is_not_callable__Did_you_mean_to_include__new__: { - category: 1 /* Error */, - message: "Value of type '{0}' is not callable. Did you mean to include 'new'?", - code: 2005 - }, - Value_of_type__0__is_not_callable: { - category: 1 /* Error */, - message: "Value of type '{0}' is not callable.", - code: 2006 - }, - Value_of_type__0__is_not_newable: { - category: 1 /* Error */, - message: "Value of type '{0}' is not newable.", - code: 2007 - }, - Value_of_type__0__is_not_indexable_by_type__1_: { - category: 1 /* Error */, - message: "Value of type '{0}' is not indexable by type '{1}'.", - code: 2008 - }, - Operator__0__cannot_be_applied_to_types__1__and__2_: { - category: 1 /* Error */, - message: "Operator '{0}' cannot be applied to types '{1}' and '{2}'.", - code: 2009 - }, - Operator__0__cannot_be_applied_to_types__1__and__2__3: { - category: 1 /* Error */, - message: "Operator '{0}' cannot be applied to types '{1}' and '{2}': {3}", - code: 2010 - }, - Cannot_convert__0__to__1_: { - category: 1 /* Error */, - message: "Cannot convert '{0}' to '{1}'.", - code: 2011 - }, - Cannot_convert__0__to__1__NL__2: { - category: 1 /* Error */, - message: "Cannot convert '{0}' to '{1}':{NL}{2}", - code: 2012 - }, - Expected_var__class__interface__or_module: { - category: 1 /* Error */, - message: "Expected var, class, interface, or module.", - code: 2013 - }, - Operator__0__cannot_be_applied_to_type__1_: { - category: 1 /* Error */, - message: "Operator '{0}' cannot be applied to type '{1}'.", - code: 2014 - }, - Getter__0__already_declared: { - category: 1 /* Error */, - message: "Getter '{0}' already declared.", - code: 2015 - }, - Setter__0__already_declared: { - category: 1 /* Error */, - message: "Setter '{0}' already declared.", - code: 2016 - }, - Accessor_cannot_have_type_parameters: { - category: 1 /* Error */, - message: "Accessors cannot have type parameters.", - code: 2017 - }, - Exported_class__0__extends_private_class__1_: { - category: 1 /* Error */, - message: "Exported class '{0}' extends private class '{1}'.", - code: 2018 - }, - Exported_class__0__implements_private_interface__1_: { - category: 1 /* Error */, - message: "Exported class '{0}' implements private interface '{1}'.", - code: 2019 - }, - Exported_interface__0__extends_private_interface__1_: { - category: 1 /* Error */, - message: "Exported interface '{0}' extends private interface '{1}'.", - code: 2020 - }, - Exported_class__0__extends_class_from_inaccessible_module__1_: { - category: 1 /* Error */, - message: "Exported class '{0}' extends class from inaccessible module {1}.", - code: 2021 - }, - Exported_class__0__implements_interface_from_inaccessible_module__1_: { - category: 1 /* Error */, - message: "Exported class '{0}' implements interface from inaccessible module {1}.", - code: 2022 - }, - Exported_interface__0__extends_interface_from_inaccessible_module__1_: { - category: 1 /* Error */, - message: "Exported interface '{0}' extends interface from inaccessible module {1}.", - code: 2023 - }, - Public_static_property__0__of__exported_class_has_or_is_using_private_type__1_: { - category: 1 /* Error */, - message: "Public static property '{0}' of exported class has or is using private type '{1}'.", - code: 2024 - }, - Public_property__0__of__exported_class_has_or_is_using_private_type__1_: { - category: 1 /* Error */, - message: "Public property '{0}' of exported class has or is using private type '{1}'.", - code: 2025 - }, - Property__0__of__exported_interface_has_or_is_using_private_type__1_: { - category: 1 /* Error */, - message: "Property '{0}' of exported interface has or is using private type '{1}'.", - code: 2026 - }, - Exported_variable__0__has_or_is_using_private_type__1_: { - category: 1 /* Error */, - message: "Exported variable '{0}' has or is using private type '{1}'.", - code: 2027 - }, - Public_static_property__0__of__exported_class_is_using_inaccessible_module__1_: { - category: 1 /* Error */, - message: "Public static property '{0}' of exported class is using inaccessible module {1}.", - code: 2028 - }, - Public_property__0__of__exported_class_is_using_inaccessible_module__1_: { - category: 1 /* Error */, - message: "Public property '{0}' of exported class is using inaccessible module {1}.", - code: 2029 - }, - Property__0__of__exported_interface_is_using_inaccessible_module__1_: { - category: 1 /* Error */, - message: "Property '{0}' of exported interface is using inaccessible module {1}.", - code: 2030 - }, - Exported_variable__0__is_using_inaccessible_module__1_: { - category: 1 /* Error */, - message: "Exported variable '{0}' is using inaccessible module {1}.", - code: 2031 - }, - Parameter__0__of_constructor_from_exported_class_has_or_is_using_private_type__1_: { - category: 1 /* Error */, - message: "Parameter '{0}' of constructor from exported class has or is using private type '{1}'.", - code: 2032 - }, - Parameter__0__of_public_static_property_setter_from_exported_class_has_or_is_using_private_type__1_: { - category: 1 /* Error */, - message: "Parameter '{0}' of public static property setter from exported class has or is using private type '{1}'.", - code: 2033 - }, - Parameter__0__of_public_property_setter_from_exported_class_has_or_is_using_private_type__1_: { - category: 1 /* Error */, - message: "Parameter '{0}' of public property setter from exported class has or is using private type '{1}'.", - code: 2034 - }, - Parameter__0__of_constructor_signature_from_exported_interface_has_or_is_using_private_type__1_: { - category: 1 /* Error */, - message: "Parameter '{0}' of constructor signature from exported interface has or is using private type '{1}'.", - code: 2035 - }, - Parameter__0__of_call_signature_from_exported_interface_has_or_is_using_private_type__1_: { - category: 1 /* Error */, - message: "Parameter '{0}' of call signature from exported interface has or is using private type '{1}'.", - code: 2036 - }, - Parameter__0__of_public_static_method_from_exported_class_has_or_is_using_private_type__1_: { - category: 1 /* Error */, - message: "Parameter '{0}' of public static method from exported class has or is using private type '{1}'.", - code: 2037 - }, - Parameter__0__of_public_method_from_exported_class_has_or_is_using_private_type__1_: { - category: 1 /* Error */, - message: "Parameter '{0}' of public method from exported class has or is using private type '{1}'.", - code: 2038 - }, - Parameter__0__of_method_from_exported_interface_has_or_is_using_private_type__1_: { - category: 1 /* Error */, - message: "Parameter '{0}' of method from exported interface has or is using private type '{1}'.", - code: 2039 - }, - Parameter__0__of_exported_function_has_or_is_using_private_type__1_: { - category: 1 /* Error */, - message: "Parameter '{0}' of exported function has or is using private type '{1}'.", - code: 2040 - }, - Parameter__0__of_constructor_from_exported_class_is_using_inaccessible_module__1_: { - category: 1 /* Error */, - message: "Parameter '{0}' of constructor from exported class is using inaccessible module {1}.", - code: 2041 - }, - Parameter__0__of_public_static_property_setter_from_exported_class_is_using_inaccessible_module__1_: { - category: 1 /* Error */, - message: "Parameter '{0}' of public static property setter from exported class is using inaccessible module {1}.", - code: 2042 - }, - Parameter__0__of_public_property_setter_from_exported_class_is_using_inaccessible_module__1_: { - category: 1 /* Error */, - message: "Parameter '{0}' of public property setter from exported class is using inaccessible module {1}.", - code: 2043 - }, - Parameter__0__of_constructor_signature_from_exported_interface_is_using_inaccessible_module__1_: { - category: 1 /* Error */, - message: "Parameter '{0}' of constructor signature from exported interface is using inaccessible module {1}.", - code: 2044 - }, - Parameter__0__of_call_signature_from_exported_interface_is_using_inaccessible_module__1_: { - category: 1 /* Error */, - message: "Parameter '{0}' of call signature from exported interface is using inaccessible module {1}", - code: 2045 - }, - Parameter__0__of_public_static_method_from_exported_class_is_using_inaccessible_module__1_: { - category: 1 /* Error */, - message: "Parameter '{0}' of public static method from exported class is using inaccessible module {1}.", - code: 2046 - }, - Parameter__0__of_public_method_from_exported_class_is_using_inaccessible_module__1_: { - category: 1 /* Error */, - message: "Parameter '{0}' of public method from exported class is using inaccessible module {1}.", - code: 2047 - }, - Parameter__0__of_method_from_exported_interface_is_using_inaccessible_module__1_: { - category: 1 /* Error */, - message: "Parameter '{0}' of method from exported interface is using inaccessible module {1}.", - code: 2048 - }, - Parameter__0__of_exported_function_is_using_inaccessible_module__1_: { - category: 1 /* Error */, - message: "Parameter '{0}' of exported function is using inaccessible module {1}.", - code: 2049 - }, - Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_private_type__0_: { - category: 1 /* Error */, - message: "Return type of public static property getter from exported class has or is using private type '{0}'.", - code: 2050 - }, - Return_type_of_public_property_getter_from_exported_class_has_or_is_using_private_type__0_: { - category: 1 /* Error */, - message: "Return type of public property getter from exported class has or is using private type '{0}'.", - code: 2051 - }, - Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_private_type__0_: { - category: 1 /* Error */, - message: "Return type of constructor signature from exported interface has or is using private type '{0}'.", - code: 2052 - }, - Return_type_of_call_signature_from_exported_interface_has_or_is_using_private_type__0_: { - category: 1 /* Error */, - message: "Return type of call signature from exported interface has or is using private type '{0}'.", - code: 2053 - }, - Return_type_of_index_signature_from_exported_interface_has_or_is_using_private_type__0_: { - category: 1 /* Error */, - message: "Return type of index signature from exported interface has or is using private type '{0}'.", - code: 2054 - }, - Return_type_of_public_static_method_from_exported_class_has_or_is_using_private_type__0_: { - category: 1 /* Error */, - message: "Return type of public static method from exported class has or is using private type '{0}'.", - code: 2055 - }, - Return_type_of_public_method_from_exported_class_has_or_is_using_private_type__0_: { - category: 1 /* Error */, - message: "Return type of public method from exported class has or is using private type '{0}'.", - code: 2056 - }, - Return_type_of_method_from_exported_interface_has_or_is_using_private_type__0_: { - category: 1 /* Error */, - message: "Return type of method from exported interface has or is using private type '{0}'.", - code: 2057 - }, - Return_type_of_exported_function_has_or_is_using_private_type__0_: { - category: 1 /* Error */, - message: "Return type of exported function has or is using private type '{0}'.", - code: 2058 - }, - Return_type_of_public_static_property_getter_from_exported_class_is_using_inaccessible_module__0_: { - category: 1 /* Error */, - message: "Return type of public static property getter from exported class is using inaccessible module {0}.", - code: 2059 - }, - Return_type_of_public_property_getter_from_exported_class_is_using_inaccessible_module__0_: { - category: 1 /* Error */, - message: "Return type of public property getter from exported class is using inaccessible module {0}.", - code: 2060 - }, - Return_type_of_constructor_signature_from_exported_interface_is_using_inaccessible_module__0_: { - category: 1 /* Error */, - message: "Return type of constructor signature from exported interface is using inaccessible module {0}.", - code: 2061 - }, - Return_type_of_call_signature_from_exported_interface_is_using_inaccessible_module__0_: { - category: 1 /* Error */, - message: "Return type of call signature from exported interface is using inaccessible module {0}.", - code: 2062 - }, - Return_type_of_index_signature_from_exported_interface_is_using_inaccessible_module__0_: { - category: 1 /* Error */, - message: "Return type of index signature from exported interface is using inaccessible module {0}.", - code: 2063 - }, - Return_type_of_public_static_method_from_exported_class_is_using_inaccessible_module__0_: { - category: 1 /* Error */, - message: "Return type of public static method from exported class is using inaccessible module {0}.", - code: 2064 - }, - Return_type_of_public_method_from_exported_class_is_using_inaccessible_module__0_: { - category: 1 /* Error */, - message: "Return type of public method from exported class is using inaccessible module {0}.", - code: 2065 - }, - Return_type_of_method_from_exported_interface_is_using_inaccessible_module__0_: { - category: 1 /* Error */, - message: "Return type of method from exported interface is using inaccessible module {0}.", - code: 2066 - }, - Return_type_of_exported_function_is_using_inaccessible_module__0_: { - category: 1 /* Error */, - message: "Return type of exported function is using inaccessible module {0}.", - code: 2067 - }, - _new_T____cannot_be_used_to_create_an_array__Use__new_Array_T_____instead: { - category: 1 /* Error */, - message: "'new T[]' cannot be used to create an array. Use 'new Array()' instead.", - code: 2068 - }, - A_parameter_list_must_follow_a_generic_type_argument_list______expected: { - category: 1 /* Error */, - message: "A parameter list must follow a generic type argument list. '(' expected.", - code: 2069 - }, - Multiple_constructor_implementations_are_not_allowed: { - category: 1 /* Error */, - message: "Multiple constructor implementations are not allowed.", - code: 2070 - }, - Unable_to_resolve_external_module__0_: { - category: 1 /* Error */, - message: "Unable to resolve external module '{0}'.", - code: 2071 - }, - Module_cannot_be_aliased_to_a_non_module_type: { - category: 1 /* Error */, - message: "Module cannot be aliased to a non-module type.", - code: 2072 - }, - A_class_may_only_extend_another_class: { - category: 1 /* Error */, - message: "A class may only extend another class.", - code: 2073 - }, - A_class_may_only_implement_another_class_or_interface: { - category: 1 /* Error */, - message: "A class may only implement another class or interface.", - code: 2074 - }, - An_interface_may_only_extend_another_class_or_interface: { - category: 1 /* Error */, - message: "An interface may only extend another class or interface.", - code: 2075 - }, - An_interface_cannot_implement_another_type: { - category: 1 /* Error */, - message: "An interface cannot implement another type.", - code: 2076 - }, - Unable_to_resolve_type: { - category: 1 /* Error */, - message: "Unable to resolve type.", - code: 2077 - }, - Unable_to_resolve_type_of__0_: { - category: 1 /* Error */, - message: "Unable to resolve type of '{0}'.", - code: 2078 - }, - Unable_to_resolve_type_parameter_constraint: { - category: 1 /* Error */, - message: "Unable to resolve type parameter constraint.", - code: 2079 - }, - Type_parameter_constraint_cannot_be_a_primitive_type: { - category: 1 /* Error */, - message: "Type parameter constraint cannot be a primitive type.", - code: 2080 - }, - Supplied_parameters_do_not_match_any_signature_of_call_target: { - category: 1 /* Error */, - message: "Supplied parameters do not match any signature of call target.", - code: 2081 - }, - Supplied_parameters_do_not_match_any_signature_of_call_target__NL__0: { - category: 1 /* Error */, - message: "Supplied parameters do not match any signature of call target:{NL}{0}", - code: 2082 - }, - Invalid__new__expression: { - category: 1 /* Error */, - message: "Invalid 'new' expression.", - code: 2083 - }, - Call_signatures_used_in_a__new__expression_must_have_a__void__return_type: { - category: 1 /* Error */, - message: "Call signatures used in a 'new' expression must have a 'void' return type.", - code: 2084 - }, - Could_not_select_overload_for__new__expression: { - category: 1 /* Error */, - message: "Could not select overload for 'new' expression.", - code: 2085 - }, - Type__0__does_not_satisfy_the_constraint__1__for_type_parameter__2_: { - category: 1 /* Error */, - message: "Type '{0}' does not satisfy the constraint '{1}' for type parameter '{2}'.", - code: 2086 - }, - Could_not_select_overload_for__call__expression: { - category: 1 /* Error */, - message: "Could not select overload for 'call' expression.", - code: 2087 - }, - Unable_to_invoke_type_with_no_call_signatures: { - category: 1 /* Error */, - message: "Unable to invoke type with no call signatures.", - code: 2088 - }, - Calls_to__super__are_only_valid_inside_a_class: { - category: 1 /* Error */, - message: "Calls to 'super' are only valid inside a class.", - code: 2089 - }, - Generic_type__0__requires_1_type_argument_s_: { - category: 1 /* Error */, - message: "Generic type '{0}' requires {1} type argument(s).", - code: 2090 - }, - Type_of_conditional_expression_cannot_be_determined__Best_common_type_could_not_be_found_between__0__and__1_: { - category: 1 /* Error */, - message: "Type of conditional expression cannot be determined. Best common type could not be found between '{0}' and '{1}'.", - code: 2091 - }, - Type_of_array_literal_cannot_be_determined__Best_common_type_could_not_be_found_for_array_elements: { - category: 1 /* Error */, - message: "Type of array literal cannot be determined. Best common type could not be found for array elements.", - code: 2092 - }, - Could_not_find_enclosing_symbol_for_dotted_name__0_: { - category: 1 /* Error */, - message: "Could not find enclosing symbol for dotted name '{0}'.", - code: 2093 - }, - The_property__0__does_not_exist_on_value_of_type__1__: { - category: 1 /* Error */, - message: "The property '{0}' does not exist on value of type '{1}'.", - code: 2094 - }, - Could_not_find_symbol__0_: { - category: 1 /* Error */, - message: "Could not find symbol '{0}'.", - code: 2095 - }, - _get__and__set__accessor_must_have_the_same_type: { - category: 1 /* Error */, - message: "'get' and 'set' accessor must have the same type.", - code: 2096 - }, - _this__cannot_be_referenced_in_current_location: { - category: 1 /* Error */, - message: "'this' cannot be referenced in current location.", - code: 2097 - }, - Use_of_deprecated__bool__type__Use__boolean__instead: { - category: 0 /* Warning */, - message: "Use of deprecated type 'bool'. Use 'boolean' instead.", - code: 2098 - }, - Static_methods_cannot_reference_class_type_parameters: { - category: 1 /* Error */, - message: "Static methods cannot reference class type parameters.", - code: 2099 - }, - Class__0__is_recursively_referenced_as_a_base_type_of_itself: { - category: 1 /* Error */, - message: "Class '{0}' is recursively referenced as a base type of itself.", - code: 2100 - }, - Interface__0__is_recursively_referenced_as_a_base_type_of_itself: { - category: 1 /* Error */, - message: "Interface '{0}' is recursively referenced as a base type of itself.", - code: 2101 - }, - _super__property_access_is_permitted_only_in_a_constructor__instance_member_function__or_instance_member_accessor_of_a_derived_class: { - category: 1 /* Error */, - message: "'super' property access is permitted only in a constructor, instance member function, or instance member accessor of a derived class.", - code: 2102 - }, - _super__cannot_be_referenced_in_non_derived_classes: { - category: 1 /* Error */, - message: "'super' cannot be referenced in non-derived classes.", - code: 2103 - }, - A__super__call_must_be_the_first_statement_in_the_constructor_when_a_class_contains_intialized_properties_or_has_parameter_properties: { - category: 1 /* Error */, - message: "A 'super' call must be the first statement in the constructor when a class contains initialized properties or has parameter properties.", - code: 2104 - }, - Constructors_for_derived_classes_must_contain_a__super__call: { - category: 1 /* Error */, - message: "Constructors for derived classes must contain a 'super' call.", - code: 2105 - }, - Super_calls_are_not_permitted_outside_constructors_or_in_local_functions_inside_constructors: { - category: 1 /* Error */, - message: "Super calls are not permitted outside constructors or in local functions inside constructors.", - code: 2106 - }, - _0_1__is_inaccessible: { - category: 1 /* Error */, - message: "'{0}.{1}' is inaccessible.", - code: 2107 - }, - _this__cannot_be_referenced_within_module_bodies: { - category: 1 /* Error */, - message: "'this' cannot be referenced within module bodies.", - code: 2108 - }, - _this__must_only_be_used_inside_a_function_or_script_context: { - category: 1 /* Error */, - message: "'this' must only be used inside a function or script context.", - code: 2109 - }, - Invalid__addition__expression___types_do_not_agree: { - category: 1 /* Error */, - message: "Invalid '+' expression - types not known to support the addition operator.", - code: 2111 - }, - The_right_hand_side_of_an_arithmetic_operation_must_be_of_type__any____number__or_an_enum_type: { - category: 1 /* Error */, - message: "The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.", - code: 2112 - }, - The_left_hand_side_of_an_arithmetic_operation_must_be_of_type__any____number__or_an_enum_type: { - category: 1 /* Error */, - message: "The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.", - code: 2113 - }, - The_type_of_a_unary_arithmetic_operation_operand_must_be_of_type__any____number__or_an_enum_type: { - category: 1 /* Error */, - message: "The type of a unary arithmetic operation operand must be of type 'any', 'number' or an enum type.", - code: 2114 - }, - Variable_declarations_for_for_in_expressions_cannot_contain_a_type_annotation: { - category: 1 /* Error */, - message: "Variable declarations for for/in expressions cannot contain a type annotation.", - code: 2115 - }, - Variable_declarations_for_for_in_expressions_must_be_of_types__string__or__any_: { - category: 1 /* Error */, - message: "Variable declarations for for/in expressions must be of types 'string' or 'any'.", - code: 2116 - }, - The_right_operand_of_a_for_in_expression_must_be_of_type__any____an_object_type_or_a_type_parameter: { - category: 1 /* Error */, - message: "The right operand of a for/in expression must be of type 'any', an object type or a type parameter.", - code: 2117 - }, - The_left_hand_side_of_an__in__expression_must_be_of_types__string__or__any_: { - category: 1 /* Error */, - message: "The left-hand side of an 'in' expression must be of types 'string' or 'any'.", - code: 2118 - }, - The_right_hand_side_of_an__in__expression_must_be_of_type__any___an_object_type_or_a_type_parameter: { - category: 1 /* Error */, - message: "The right-hand side of an 'in' expression must be of type 'any', an object type or a type parameter.", - code: 2119 - }, - The_left_hand_side_of_an__instanceOf__expression_must_be_of_type__any___an_object_type_or_a_type_parameter: { - category: 1 /* Error */, - message: "The left-hand side of an 'instanceOf' expression must be of type 'any', an object type or a type parameter.", - code: 2120 - }, - The_right_hand_side_of_an__instanceOf__expression_must_be_of_type__any__or_a_subtype_of_the__Function__interface_type: { - category: 1 /* Error */, - message: "The right-hand side of an 'instanceOf' expression must be of type 'any' or a subtype of the 'Function' interface type.", - code: 2121 - }, - Setters_cannot_return_a_value: { - category: 1 /* Error */, - message: "Setters cannot return a value.", - code: 2122 - }, - Tried_to_set_variable_type_to_module_type__0__: { - category: 1 /* Error */, - message: "Tried to set variable type to container type '{0}'.", - code: 2123 - }, - Tried_to_set_variable_type_to_uninitialized_module_type__0__: { - category: 1 /* Error */, - message: "Tried to set variable type to uninitialized module type '{0}'.", - code: 2124 - }, - Function__0__declared_a_non_void_return_type__but_has_no_return_expression: { - category: 1 /* Error */, - message: "Function {0} declared a non-void return type, but has no return expression.", - code: 2125 - }, - Getters_must_return_a_value: { - category: 1 /* Error */, - message: "Getters must return a value.", - code: 2126 - }, - Getter_and_setter_accessors_do_not_agree_in_visibility: { - category: 1 /* Error */, - message: "Getter and setter accessors do not agree in visibility.", - code: 2127 - }, - Invalid_left_hand_side_of_assignment_expression: { - category: 1 /* Error */, - message: "Invalid left-hand side of assignment expression.", - code: 2130 - }, - Function_declared_a_non_void_return_type__but_has_no_return_expression: { - category: 1 /* Error */, - message: "Function declared a non-void return type, but has no return expression.", - code: 2131 - }, - Cannot_resolve_return_type_reference: { - category: 1 /* Error */, - message: "Cannot resolve return type reference.", - code: 2132 - }, - Constructors_cannot_have_a_return_type_of__void_: { - category: 1 /* Error */, - message: "Constructors cannot have a return type of 'void'.", - code: 2133 - }, - Subsequent_variable_declarations_must_have_the_same_type___Variable__0__must_be_of_type__1___but_here_has_type___2_: { - category: 1 /* Error */, - message: "Subsequent variable declarations must have the same type. Variable '{0}' must be of type '{1}', but here has type '{2}'", - code: 2134 - }, - All_symbols_within_a__with__block_will_be_resolved_to__any__: { - category: 1 /* Error */, - message: "All symbols within a with block will be resolved to 'any'.", - code: 2135 - }, - Import_declarations_in_an_internal_module_cannot_reference_an_external_module: { - category: 1 /* Error */, - message: "Import declarations in an internal module cannot reference an external module.", - code: 2136 - }, - Class__0__declares_interface__1__but_does_not_implement_it__NL__2: { - category: 1 /* Error */, - message: "Class {0} declares interface {1} but does not implement it:{NL}{2}", - code: 2137 - }, - Class__0__declares_class__1__but_does_not_implement_it__NL__2: { - category: 1 /* Error */, - message: "Class {0} declares class {1} as an implemented interface but does not implement it:{NL}{2}", - code: 2138 - }, - The_operand_of_an_increment_or_decrement_operator_must_be_a_variable__property_or_indexer: { - category: 1 /* Error */, - message: "The operand of an increment or decrement operator must be a variable, property or indexer.", - code: 2139 - }, - _this__cannot_be_referenced_in_initializers_in_a_class_body: { - category: 1 /* Error */, - message: "'this' cannot be referenced in initializers in a class body.", - code: 2140 - }, - Class__0__cannot_extend_class__1__NL__2: { - category: 1 /* Error */, - message: "Class '{0}' cannot extend class '{1}':{NL}{2}", - code: 2141 - }, - Interface__0__cannot_extend_class__1__NL__2: { - category: 1 /* Error */, - message: "Interface '{0}' cannot extend class '{1}':{NL}{2}", - code: 2142 - }, - Interface__0__cannot_extend_interface__1__NL__2: { - category: 1 /* Error */, - message: "Interface '{0}' cannot extend interface '{1}':{NL}{2}", - code: 2143 - }, - Duplicate_overload_signature_for__0_: { - category: 1 /* Error */, - message: "Duplicate overload signature for '{0}'.", - code: 2144 - }, - Duplicate_constructor_overload_signature: { - category: 1 /* Error */, - message: "Duplicate constructor overload signature.", - code: 2145 - }, - Duplicate_overload_call_signature: { - category: 1 /* Error */, - message: "Duplicate overload call signature.", - code: 2146 - }, - Duplicate_overload_construct_signature: { - category: 1 /* Error */, - message: "Duplicate overload construct signature.", - code: 2147 - }, - Overload_signature_is_not_compatible_with_function_definition: { - category: 1 /* Error */, - message: "Overload signature is not compatible with function definition.", - code: 2148 - }, - Overload_signature_is_not_compatible_with_function_definition__NL__0: { - category: 1 /* Error */, - message: "Overload signature is not compatible with function definition:{NL}{0}", - code: 2149 - }, - Overload_signatures_must_all_be_public_or_private: { - category: 1 /* Error */, - message: "Overload signatures must all be public or private.", - code: 2150 - }, - Overload_signatures_must_all_be_exported_or_local: { - category: 1 /* Error */, - message: "Overload signatures must all be exported or local.", - code: 2151 - }, - Overload_signatures_must_all_be_ambient_or_non_ambient: { - category: 1 /* Error */, - message: "Overload signatures must all be ambient or non-ambient.", - code: 2152 - }, - Overload_signatures_must_all_be_optional_or_required: { - category: 1 /* Error */, - message: "Overload signatures must all be optional or required.", - code: 2153 - }, - Specialized_overload_signature_is_not_subtype_of_any_non_specialized_signature: { - category: 1 /* Error */, - message: "Specialized overload signature is not subtype of any non-specialized signature.", - code: 2154 - }, - _this__cannot_be_referenced_in_constructor_arguments: { - category: 1 /* Error */, - message: "'this' cannot be referenced in constructor arguments.", - code: 2155 - }, - Static_member_cannot_be_accessed_off_an_instance_variable: { - category: 1 /* Error */, - message: "Static member cannot be accessed off an instance variable.", - code: 2156 - }, - Instance_member_cannot_be_accessed_off_a_class: { - category: 1 /* Error */, - message: "Instance member cannot be accessed off a class.", - code: 2157 - }, - Untyped_function_calls_may_not_accept_type_arguments: { - category: 1 /* Error */, - message: "Untyped function calls may not accept type arguments.", - code: 2158 - }, - Non_generic_functions_may_not_accept_type_arguments: { - category: 1 /* Error */, - message: "Non-generic functions may not accept type arguments.", - code: 2159 - }, - A_generic_type_may_not_reference_itself_with_its_own_type_parameters: { - category: 1 /* Error */, - message: "A generic type may not reference itself with a wrapped form of its own type parameters.", - code: 2160 - }, - Value_of_type__0__is_not_callable__Did_you_mean_to_include__new___: { - category: 1 /* Error */, - message: "Value of type '{0}' is not callable. Did you mean to include 'new'?", - code: 2161 - }, - Rest_parameters_must_be_array_types: { - category: 1 /* Error */, - message: "Rest parameters must be array types.", - code: 2162 - }, - Overload_signature_implementation_cannot_use_specialized_type: { - category: 1 /* Error */, - message: "Overload signature implementation cannot use specialized type.", - code: 2163 - }, - Export_assignments_may_only_be_used_in_External_modules: { - category: 1 /* Error */, - message: "Export assignments may only be used at the top-level of external modules", - code: 2164 - }, - Export_assignments_may_only_be_made_with_acceptable_kinds: { - category: 1 /* Error */, - message: "Export assignments may only be made with variables, functions, classes, interfaces, enums and internal modules", - code: 2165 - }, - Only_public_instance_methods_of_the_base_class_are_accessible_via_the_super_keyword: { - category: 1 /* Error */, - message: "Only public instance methods of the base class are accessible via the super keyword", - code: 2166 - }, - Numeric_indexer_type___0___must_be_a_subtype_of_string_indexer_type___1__: { - category: 1 /* Error */, - message: "Numeric indexer type '{0}' must be a subtype of string indexer type '{1}'", - code: 2167 - }, - Numeric_indexer_type___0___must_be_a_subtype_of_string_indexer_type___1____NL__2: { - category: 1 /* Error */, - message: "Numeric indexer type '{0}' must be a subtype of string indexer type '{1}':{NL}{2}", - code: 2168 - }, - All_numerically_named_properties_must_be_subtypes_of_numeric_indexer_type___0__: { - category: 1 /* Error */, - message: "All numerically named properties must be subtypes of numeric indexer type '{0}'", - code: 2169 - }, - All_numerically_named_properties_must_be_subtypes_of_numeric_indexer_type___0____NL__1: { - category: 1 /* Error */, - message: "All numerically named properties must be subtypes of numeric indexer type '{0}':{NL}{1}", - code: 2170 - }, - All_named_properties_must_be_subtypes_of_string_indexer_type___0__: { - category: 1 /* Error */, - message: "All named properties must be subtypes of string indexer type '{0}'", - code: 2171 - }, - All_named_properties_must_be_subtypes_of_string_indexer_type___0____NL__1: { - category: 1 /* Error */, - message: "All named properties must be subtypes of string indexer type '{0}':{NL}{1}", - code: 2172 - }, - Generic_type_references_must_include_all_type_arguments: { - category: 1 /* Error */, - message: "Generic type references must include all type arguments", - code: 2173 - }, - Type__0__is_missing_property__1__from_type__2_: { - category: 3 /* NoPrefix */, - message: "Type '{0}' is missing property '{1}' from type '{2}'.", - code: 4000 - }, - Types_of_property__0__of_types__1__and__2__are_incompatible: { - category: 3 /* NoPrefix */, - message: "Types of property '{0}' of types '{1}' and '{2}' are incompatible.", - code: 4001 - }, - Types_of_property__0__of_types__1__and__2__are_incompatible__NL__3: { - category: 3 /* NoPrefix */, - message: "Types of property '{0}' of types '{1}' and '{2}' are incompatible:{NL}{3}", - code: 4002 - }, - Property__0__defined_as_private_in_type__1__is_defined_as_public_in_type__2_: { - category: 3 /* NoPrefix */, - message: "Property '{0}' defined as private in type '{1}' is defined as public in type '{2}'.", - code: 4003 - }, - Property__0__defined_as_public_in_type__1__is_defined_as_private_in_type__2_: { - category: 3 /* NoPrefix */, - message: "Property '{0}' defined as public in type '{1}' is defined as private in type '{2}'.", - code: 4004 - }, - Types__0__and__1__define_property__2__as_private: { - category: 3 /* NoPrefix */, - message: "Types '{0}' and '{1}' define property '{2}' as private.", - code: 4005 - }, - Call_signatures_of_types__0__and__1__are_incompatible: { - category: 3 /* NoPrefix */, - message: "Call signatures of types '{0}' and '{1}' are incompatible.", - code: 4006 - }, - Call_signatures_of_types__0__and__1__are_incompatible__NL__2: { - category: 3 /* NoPrefix */, - message: "Call signatures of types '{0}' and '{1}' are incompatible:{NL}{2}", - code: 4007 - }, - Type__0__requires_a_call_signature__but_Type__1__lacks_one: { - category: 3 /* NoPrefix */, - message: "Type '{0}' requires a call signature, but type '{1}' lacks one.", - code: 4008 - }, - Construct_signatures_of_types__0__and__1__are_incompatible: { - category: 3 /* NoPrefix */, - message: "Construct signatures of types '{0}' and '{1}' are incompatible.", - code: 4009 - }, - Construct_signatures_of_types__0__and__1__are_incompatible__NL__2: { - category: 3 /* NoPrefix */, - message: "Construct signatures of types '{0}' and '{1}' are incompatible:{NL}{2}", - code: 40010 - }, - Type__0__requires_a_construct_signature__but_Type__1__lacks_one: { - category: 3 /* NoPrefix */, - message: "Type '{0}' requires a construct signature, but type '{1}' lacks one.", - code: 4011 - }, - Index_signatures_of_types__0__and__1__are_incompatible: { - category: 3 /* NoPrefix */, - message: "Index signatures of types '{0}' and '{1}' are incompatible.", - code: 4012 - }, - Index_signatures_of_types__0__and__1__are_incompatible__NL__2: { - category: 3 /* NoPrefix */, - message: "Index signatures of types '{0}' and '{1}' are incompatible:{NL}{2}", - code: 4013 - }, - Call_signature_expects__0__or_fewer_parameters: { - category: 3 /* NoPrefix */, - message: "Call signature expects {0} or fewer parameters.", - code: 4014 - }, - Could_not_apply_type__0__to_argument__1__which_is_of_type__2_: { - category: 3 /* NoPrefix */, - message: "Could not apply type'{0}' to argument {1} which is of type '{2}'.", - code: 4015 - }, - Class__0__defines_instance_member_accessor__1___but_extended_class__2__defines_it_as_instance_member_function: { - category: 3 /* NoPrefix */, - message: "Class '{0}' defines instance member accessor '{1}', but extended class '{2}' defines it as instance member function.", - code: 4016 - }, - Class__0__defines_instance_member_property__1___but_extended_class__2__defines_it_as_instance_member_function: { - category: 3 /* NoPrefix */, - message: "Class '{0}' defines instance member property '{1}', but extended class '{2}' defines it as instance member function.", - code: 4017 - }, - Class__0__defines_instance_member_function__1___but_extended_class__2__defines_it_as_instance_member_accessor: { - category: 3 /* NoPrefix */, - message: "Class '{0}' defines instance member function '{1}', but extended class '{2}' defines it as instance member accessor.", - code: 4018 - }, - Class__0__defines_instance_member_function__1___but_extended_class__2__defines_it_as_instance_member_property: { - category: 3 /* NoPrefix */, - message: "Class '{0}' defines instance member function '{1}', but extended class '{2}' defines it as instance member property.", - code: 4019 - }, - Types_of_static_property__0__of_class__1__and_class__2__are_incompatible: { - category: 3 /* NoPrefix */, - message: "Types of static property '{0}' of class '{1}' and class '{2}' are incompatible.", - code: 4020 - }, - Types_of_static_property__0__of_class__1__and_class__2__are_incompatible__NL__3: { - category: 3 /* NoPrefix */, - message: "Types of static property '{0}' of class '{1}' and class '{2}' are incompatible:{NL}{3}", - code: 4021 - }, - Type_reference_cannot_refer_to_container__0_: { - category: 1 /* Error */, - message: "Type reference cannot refer to container '{0}'.", - code: 4022 - }, - Type_reference_must_refer_to_type: { - category: 1 /* Error */, - message: "Type reference cannot must refer to type.", - code: 4023 - }, - Enums_with_multiple_declarations_must_provide_an_initializer_for_the_first_enum_element: { - category: 1 /* Error */, - message: "Enums with multiple declarations must provide an initializer for the first enum element.", - code: 4024 - }, - Current_host_does_not_support__w_atch_option: { - category: 1 /* Error */, - message: "Current host does not support -w[atch] option.", - code: 5001 - }, - ECMAScript_target_version__0__not_supported___Using_default__1__code_generation: { - category: 0 /* Warning */, - message: "ECMAScript target version '{0}' not supported. Using default '{1}' code generation.", - code: 5002 - }, - Module_code_generation__0__not_supported___Using_default__1__code_generation: { - category: 0 /* Warning */, - message: "Module code generation '{0}' not supported. Using default '{1}' code generation.", - code: 5003 - }, - Could_not_find_file___0_: { - category: 1 /* Error */, - message: "Could not find file: '{0}'.", - code: 5004 - }, - Unknown_extension_for_file___0__Only__ts_and_d_ts_extensions_are_allowed: { - category: 1 /* Error */, - message: "Unknown extension for file: '{0}'. Only .ts and .d.ts extensions are allowed.", - code: 5005 - }, - A_file_cannot_have_a_reference_itself: { - category: 1 /* Error */, - message: "A file cannot have a reference itself.", - code: 5006 - }, - Cannot_resolve_referenced_file___0_: { - category: 1 /* Error */, - message: "Cannot resolve referenced file: '{0}'.", - code: 5007 - }, - Cannot_resolve_imported_file___0_: { - category: 1 /* Error */, - message: "Cannot resolve imported file: '{0}'.", - code: 5008 - }, - Cannot_find_the_common_subdirectory_path_for_the_input_files: { - category: 1 /* Error */, - message: "Cannot find the common subdirectory path for the input files", - code: 5009 - }, - Cannot_compile_dynamic_modules_when_emitting_into_single_file: { - category: 1 /* Error */, - message: "Cannot compile dynamic modules when emitting into single file", - code: 5010 - }, - Emit_Error__0: { - category: 1 /* Error */, - message: "Emit Error: {0}.", - code: 5011 - } - }; - - var seenCodes = []; - for (var name in TypeScript.diagnosticMessages) { - if (TypeScript.diagnosticMessages.hasOwnProperty(name)) { - var diagnosticMessage = TypeScript.diagnosticMessages[name]; - var value = seenCodes[diagnosticMessage.code]; - if (value) { - throw new Error("Duplicate diagnostic code: " + diagnosticMessage.code); - } - - seenCodes[diagnosticMessage.code] = diagnosticMessage; - } - } -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var Errors = (function () { - function Errors() { - } - Errors.argument = function (argument, message) { - return new Error("Invalid argument: " + argument + "." + (message ? (" " + message) : "")); - }; - - Errors.argumentOutOfRange = function (argument) { - return new Error("Argument out of range: " + argument + "."); - }; - - Errors.argumentNull = function (argument) { - return new Error("Argument null: " + argument + "."); - }; - - Errors.abstract = function () { - return new Error("Operation not implemented properly by subclass."); - }; - - Errors.notYetImplemented = function () { - return new Error("Not yet implemented."); - }; - - Errors.invalidOperation = function (message) { - return new Error(message ? ("Invalid operation: " + message) : "Invalid operation."); - }; - return Errors; - })(); - TypeScript.Errors = Errors; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var Hash = (function () { - function Hash() { - } - Hash.computeFnv1aCharArrayHashCode = function (text, start, len) { - var hashCode = Hash.FNV_BASE; - var end = start + len; - - for (var i = start; i < end; i++) { - hashCode = (hashCode ^ text[i]) * Hash.FNV_PRIME; - } - - return hashCode; - }; - - Hash.computeSimple31BitCharArrayHashCode = function (key, start, len) { - var hash = 0; - - for (var i = 0; i < len; i++) { - var ch = key[start + i]; - - hash = (((hash << 5) + hash) + ch) | 0; - } - - return hash & 0x7FFFFFFF; - }; - - Hash.computeSimple31BitStringHashCode = function (key) { - var hash = 0; - - var start = 0; - var len = key.length; - - for (var i = 0; i < len; i++) { - var ch = key.charCodeAt(start + i); - - hash = (((hash << 5) + hash) + ch) | 0; - } - - return hash & 0x7FFFFFFF; - }; - - Hash.computeMurmur2CharArrayHashCode = function (key, start, len) { - var m = 0x5bd1e995; - var r = 24; - - var numberOfCharsLeft = len; - var h = (0 ^ numberOfCharsLeft); - - var index = start; - while (numberOfCharsLeft >= 2) { - var c1 = key[index]; - var c2 = key[index + 1]; - - var k = c1 | (c2 << 16); - - k *= m; - k ^= k >> r; - k *= m; - - h *= m; - h ^= k; - - index += 2; - numberOfCharsLeft -= 2; - } - - if (numberOfCharsLeft === 1) { - h ^= key[index]; - h *= m; - } - - h ^= h >> 13; - h *= m; - h ^= h >> 15; - - return h; - }; - - Hash.computeMurmur2StringHashCode = function (key) { - var m = 0x5bd1e995; - var r = 24; - - var start = 0; - var len = key.length; - var numberOfCharsLeft = len; - - var h = (0 ^ numberOfCharsLeft); - - var index = start; - while (numberOfCharsLeft >= 2) { - var c1 = key.charCodeAt(index); - var c2 = key.charCodeAt(index + 1); - - var k = c1 | (c2 << 16); - - k *= m; - k ^= k >> r; - k *= m; - - h *= m; - h ^= k; - - index += 2; - numberOfCharsLeft -= 2; - } - - if (numberOfCharsLeft === 1) { - h ^= key.charCodeAt(index); - h *= m; - } - - h ^= h >> 13; - h *= m; - h ^= h >> 15; - - return h; - }; - - Hash.getPrime = function (min) { - for (var i = 0; i < Hash.primes.length; i++) { - var num = Hash.primes[i]; - if (num >= min) { - return num; - } - } - - throw TypeScript.Errors.notYetImplemented(); - }; - - Hash.expandPrime = function (oldSize) { - var num = oldSize << 1; - if (num > 2146435069 && 2146435069 > oldSize) { - return 2146435069; - } - return Hash.getPrime(num); - }; - - Hash.combine = function (value, currentHash) { - return (((currentHash << 5) + currentHash) + value) & 0x7FFFFFFF; - }; - Hash.FNV_BASE = 2166136261; - Hash.FNV_PRIME = 16777619; - - Hash.primes = [ - 3, - 7, - 11, - 17, - 23, - 29, - 37, - 47, - 59, - 71, - 89, - 107, - 131, - 163, - 197, - 239, - 293, - 353, - 431, - 521, - 631, - 761, - 919, - 1103, - 1327, - 1597, - 1931, - 2333, - 2801, - 3371, - 4049, - 4861, - 5839, - 7013, - 8419, - 10103, - 12143, - 14591, - 17519, - 21023, - 25229, - 30293, - 36353, - 43627, - 52361, - 62851, - 75431, - 90523, - 108631, - 130363, - 156437, - 187751, - 225307, - 270371, - 324449, - 389357, - 467237, - 560689, - 672827, - 807403, - 968897, - 1162687, - 1395263, - 1674319, - 2009191, - 2411033, - 2893249, - 3471899, - 4166287, - 4999559, - 5999471, - 7199369 - ]; - return Hash; - })(); - TypeScript.Hash = Hash; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (Collections) { - Collections.DefaultHashTableCapacity = 256; - - var HashTableEntry = (function () { - function HashTableEntry(Key, Value, HashCode, Next) { - this.Key = Key; - this.Value = Value; - this.HashCode = HashCode; - this.Next = Next; - } - return HashTableEntry; - })(); - - var HashTable = (function () { - function HashTable(capacity, hash, equals) { - this.hash = hash; - this.equals = equals; - this.entries = []; - this.count = 0; - var size = TypeScript.Hash.getPrime(capacity); - this.hash = hash; - this.equals = equals; - this.entries = TypeScript.ArrayUtilities.createArray(size, null); - } - HashTable.prototype.set = function (key, value) { - this.addOrSet(key, value, false); - }; - - HashTable.prototype.add = function (key, value) { - this.addOrSet(key, value, true); - }; - - HashTable.prototype.containsKey = function (key) { - var hashCode = this.computeHashCode(key); - var entry = this.findEntry(key, hashCode); - return entry !== null; - }; - - HashTable.prototype.get = function (key) { - var hashCode = this.computeHashCode(key); - var entry = this.findEntry(key, hashCode); - - return entry === null ? null : entry.Value; - }; - - HashTable.prototype.computeHashCode = function (key) { - var hashCode = this.hash === null ? key.hashCode() : this.hash(key); - - hashCode = hashCode & 0x7FFFFFFF; - TypeScript.Debug.assert(hashCode > 0); - - return hashCode; - }; - - HashTable.prototype.addOrSet = function (key, value, throwOnExistingEntry) { - var hashCode = this.computeHashCode(key); - - var entry = this.findEntry(key, hashCode); - if (entry !== null) { - if (throwOnExistingEntry) { - throw TypeScript.Errors.argument('key', 'Key was already in table.'); - } - - entry.Key = key; - entry.Value = value; - return; - } - - return this.addEntry(key, value, hashCode); - }; - - HashTable.prototype.findEntry = function (key, hashCode) { - for (var e = this.entries[hashCode % this.entries.length]; e !== null; e = e.Next) { - if (e.HashCode === hashCode) { - var equals = this.equals === null ? key === e.Key : this.equals(key, e.Key); - - if (equals) { - return e; - } - } - } - - return null; - }; - - HashTable.prototype.addEntry = function (key, value, hashCode) { - var index = hashCode % this.entries.length; - - var e = new HashTableEntry(key, value, hashCode, this.entries[index]); - - this.entries[index] = e; - - if (this.count === this.entries.length) { - this.grow(); - } - - this.count++; - return e.Key; - }; - - HashTable.prototype.grow = function () { - var newSize = TypeScript.Hash.expandPrime(this.entries.length); - - var oldEntries = this.entries; - var newEntries = TypeScript.ArrayUtilities.createArray(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; - } - } - }; - return HashTable; - })(); - Collections.HashTable = HashTable; - - function createHashTable(capacity, hash, equals) { - if (typeof capacity === "undefined") { capacity = Collections.DefaultHashTableCapacity; } - if (typeof hash === "undefined") { hash = null; } - if (typeof equals === "undefined") { equals = null; } - return new HashTable(capacity, hash, equals); - } - Collections.createHashTable = createHashTable; - - var currentHashCode = 1; - function identityHashCode(value) { - if (value.__hash === undefined) { - value.__hash = currentHashCode; - currentHashCode++; - } - - return value.__hash; - } - Collections.identityHashCode = identityHashCode; - })(TypeScript.Collections || (TypeScript.Collections = {})); - var Collections = TypeScript.Collections; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var Diagnostic = (function () { - function Diagnostic(fileName, start, length, diagnosticCode, arguments) { - if (typeof arguments === "undefined") { arguments = null; } - this._diagnosticCode = diagnosticCode; - this._arguments = (arguments && arguments.length > 0) ? arguments : null; - this._fileName = fileName; - this._originalStart = this._start = start; - this._length = length; - } - Diagnostic.prototype.toJSON = function (key) { - var result = {}; - result.start = this.start(); - result.length = this.length(); - - result.diagnosticCode = TypeScript.DiagnosticCode[this.diagnosticCode()]; - - var arguments = (this).arguments(); - if (arguments && arguments.length > 0) { - result.arguments = arguments; - } - - return result; - }; - - Diagnostic.prototype.fileName = function () { - return this._fileName; - }; - - Diagnostic.prototype.start = function () { - return this._start; - }; - - Diagnostic.prototype.length = function () { - return this._length; - }; - - Diagnostic.prototype.diagnosticCode = function () { - return this._diagnosticCode; - }; - - Diagnostic.prototype.arguments = function () { - return this._arguments; - }; - - Diagnostic.prototype.text = function () { - return TypeScript.getDiagnosticText(this._diagnosticCode, this._arguments); - }; - - Diagnostic.prototype.message = function () { - return TypeScript.getDiagnosticMessage(this._diagnosticCode, this._arguments); - }; - - Diagnostic.prototype.adjustOffset = function (pos) { - this._start = this._originalStart + pos; - }; - - Diagnostic.prototype.additionalLocations = function () { - return []; - }; - - Diagnostic.equals = function (diagnostic1, diagnostic2) { - return diagnostic1._fileName === diagnostic2._fileName && diagnostic1._start === diagnostic2._start && diagnostic1._length === diagnostic2._length && diagnostic1._diagnosticCode === diagnostic2._diagnosticCode && TypeScript.ArrayUtilities.sequenceEquals(diagnostic1._arguments, diagnostic2._arguments, function (v1, v2) { - return v1 === v2; - }); - }; - return Diagnostic; - })(); - TypeScript.Diagnostic = Diagnostic; - - function getLargestIndex(diagnostic) { - var largest = -1; - var stringComponents = diagnostic.split("_"); - - for (var i = 0; i < stringComponents.length; i++) { - var val = parseInt(stringComponents[i]); - if (!isNaN(val) && val > largest) { - largest = val; - } - } - - return largest; - } - - function getDiagnosticInfoFromCode(diagnosticCode) { - var diagnosticName = TypeScript.DiagnosticCode[diagnosticCode]; - return TypeScript.diagnosticMessages[diagnosticName]; - } - TypeScript.getDiagnosticInfoFromCode = getDiagnosticInfoFromCode; - - function getDiagnosticText(diagnosticCode, args) { - var diagnosticName = TypeScript.DiagnosticCode[diagnosticCode]; - - var diagnostic = TypeScript.diagnosticMessages[diagnosticName]; - - var actualCount = args ? args.length : 0; - if (!diagnostic) { - throw new Error("Invalid diagnostic"); - } else { - var expectedCount = 1 + getLargestIndex(diagnosticName); - - if (expectedCount !== actualCount) { - throw new Error("Expected " + expectedCount + " arguments to diagnostic, got " + actualCount + " instead"); - } - } - - var diagnosticMessageText = diagnostic.message.replace(/{({(\d+)})?TB}/g, function (match, p1, num) { - var tabChar = "\t"; - var result = tabChar; - if (num && args[num]) { - for (var i = 1; i < args[num]; i++) { - result += tabChar; - } - } - - return result; - }); - - diagnosticMessageText = diagnosticMessageText.replace(/{(\d+)}/g, function (match, num) { - return typeof args[num] !== 'undefined' ? args[num] : match; - }); - - diagnosticMessageText = diagnosticMessageText.replace(/{(NL)}/g, function (match) { - return "\r\n"; - }); - - return diagnosticMessageText; - } - TypeScript.getDiagnosticText = getDiagnosticText; - - function getDiagnosticMessage(diagnosticCode, args) { - var diagnostic = getDiagnosticInfoFromCode(diagnosticCode); - var diagnosticMessageText = getDiagnosticText(diagnosticCode, args); - - var message; - if (diagnostic.category === 1 /* Error */) { - message = getDiagnosticText(0 /* error_TS_0__1 */, [diagnostic.code, diagnosticMessageText]); - } else if (diagnostic.category === 0 /* Warning */) { - message = getDiagnosticText(1 /* warning_TS_0__1 */, [diagnostic.code, diagnosticMessageText]); - } else { - message = diagnosticMessageText; - } - - return message; - } - TypeScript.getDiagnosticMessage = getDiagnosticMessage; -})(TypeScript || (TypeScript = {})); -var ByteOrderMark; -(function (ByteOrderMark) { - ByteOrderMark[ByteOrderMark["None"] = 0] = "None"; - ByteOrderMark[ByteOrderMark["Utf8"] = 1] = "Utf8"; - ByteOrderMark[ByteOrderMark["Utf16BigEndian"] = 2] = "Utf16BigEndian"; - ByteOrderMark[ByteOrderMark["Utf16LittleEndian"] = 3] = "Utf16LittleEndian"; -})(ByteOrderMark || (ByteOrderMark = {})); - -var FileInformation = (function () { - function FileInformation(contents, byteOrderMark) { - this._contents = contents; - this._byteOrderMark = byteOrderMark; - } - FileInformation.prototype.contents = function () { - return this._contents; - }; - - FileInformation.prototype.byteOrderMark = function () { - return this._byteOrderMark; - }; - return FileInformation; -})(); - -var Environment = (function () { - function getWindowsScriptHostEnvironment() { - try { - var fso = new ActiveXObject("Scripting.FileSystemObject"); - } catch (e) { - return null; - } - - var streamObjectPool = []; - - function getStreamObject() { - if (streamObjectPool.length > 0) { - return streamObjectPool.pop(); - } else { - return new ActiveXObject("ADODB.Stream"); - } - } - - function releaseStreamObject(obj) { - streamObjectPool.push(obj); - } - - var args = []; - for (var i = 0; i < WScript.Arguments.length; i++) { - args[i] = WScript.Arguments.Item(i); - } - - return { - currentDirectory: function () { - return (WScript).CreateObject("WScript.Shell").CurrentDirectory; - }, - readFile: function (path) { - try { - var streamObj = getStreamObject(); - streamObj.Open(); - streamObj.Type = 2; - - streamObj.Charset = 'x-ansi'; - - streamObj.LoadFromFile(path); - var bomChar = streamObj.ReadText(2); - - streamObj.Position = 0; - - var byteOrderMark = 0 /* None */; - - if (bomChar.charCodeAt(0) === 0xFE && bomChar.charCodeAt(1) === 0xFF) { - streamObj.Charset = 'unicode'; - byteOrderMark = 2 /* Utf16BigEndian */; - } else if (bomChar.charCodeAt(0) === 0xFF && bomChar.charCodeAt(1) === 0xFE) { - streamObj.Charset = 'unicode'; - byteOrderMark = 3 /* Utf16LittleEndian */; - } else if (bomChar.charCodeAt(0) === 0xEF && bomChar.charCodeAt(1) === 0xBB) { - streamObj.Charset = 'utf-8'; - byteOrderMark = 1 /* Utf8 */; - } else { - streamObj.Charset = 'utf-8'; - } - - var contents = streamObj.ReadText(-1); - streamObj.Close(); - releaseStreamObject(streamObj); - return new FileInformation(contents, byteOrderMark); - } catch (err) { - throw new Error("Error reading file \"" + path + "\": " + err.message); - } - }, - writeFile: function (path, contents, writeByteOrderMark) { - var textStream = getStreamObject(); - textStream.Charset = 'utf-8'; - textStream.Open(); - textStream.WriteText(contents, 0); - - if (!writeByteOrderMark) { - textStream.Position = 3; - } else { - textStream.Position = 0; - } - - var fileStream = getStreamObject(); - fileStream.Type = 1; - fileStream.Open(); - - textStream.CopyTo(fileStream); - - fileStream.Flush(); - fileStream.SaveToFile(path, 2); - fileStream.Close(); - - textStream.Flush(); - textStream.Close(); - }, - fileExists: function (path) { - return fso.FileExists(path); - }, - deleteFile: function (path) { - if (fso.FileExists(path)) { - fso.DeleteFile(path, true); - } - }, - directoryExists: function (path) { - return fso.FolderExists(path); - }, - listFiles: function (path, spec, options) { - options = options || {}; - function filesInFolder(folder, root) { - var paths = []; - var fc; - - if (options.recursive) { - fc = new Enumerator(folder.subfolders); - - for (; !fc.atEnd(); fc.moveNext()) { - paths = paths.concat(filesInFolder(fc.item(), root + "\\" + fc.item().Name)); - } - } - - fc = new Enumerator(folder.files); - - for (; !fc.atEnd(); fc.moveNext()) { - if (!spec || fc.item().Name.match(spec)) { - paths.push(root + "\\" + fc.item().Name); - } - } - - return paths; - } - - var folder = fso.GetFolder(path); - var paths = []; - - return filesInFolder(folder, path); - }, - arguments: args, - standardOut: WScript.StdOut - }; - } - ; - - function getNodeEnvironment() { - var _fs = require('fs'); - var _path = require('path'); - var _module = require('module'); - - return { - currentDirectory: function () { - return (process).cwd(); - }, - readFile: function (file) { - var buffer = _fs.readFileSync(file); - switch (buffer[0]) { - case 0xFE: - if (buffer[1] === 0xFF) { - var i = 0; - while ((i + 1) < buffer.length) { - var temp = buffer[i]; - buffer[i] = buffer[i + 1]; - buffer[i + 1] = temp; - i += 2; - } - return new FileInformation(buffer.toString("ucs2", 2), 2 /* Utf16BigEndian */); - } - break; - case 0xFF: - if (buffer[1] === 0xFE) { - return new FileInformation(buffer.toString("ucs2", 2), 3 /* Utf16LittleEndian */); - } - break; - case 0xEF: - if (buffer[1] === 0xBB) { - return new FileInformation(buffer.toString("utf8", 3), 1 /* Utf8 */); - } - } - - return new FileInformation(buffer.toString("utf8", 0), 0 /* None */); - }, - writeFile: function (path, contents, writeByteOrderMark) { - function mkdirRecursiveSync(path) { - var stats = _fs.statSync(path); - if (stats.isFile()) { - throw "\"" + path + "\" exists but isn't a directory."; - } else if (stats.isDirectory()) { - return; - } else { - mkdirRecursiveSync(_path.dirname(path)); - _fs.mkdirSync(path, 0775); - } - } - mkdirRecursiveSync(_path.dirname(path)); - - if (writeByteOrderMark) { - contents = '\uFEFF' + contents; - } - _fs.writeFileSync(path, contents, "utf8"); - }, - fileExists: function (path) { - return _fs.existsSync(path); - }, - deleteFile: function (path) { - try { - _fs.unlinkSync(path); - } catch (e) { - } - }, - directoryExists: function (path) { - return _fs.existsSync(path) && _fs.statSync(path).isDirectory(); - }, - listFiles: function dir(path, spec, options) { - options = options || {}; - - function filesInFolder(folder) { - var paths = []; - - var files = _fs.readdirSync(folder); - for (var i = 0; i < files.length; i++) { - var stat = _fs.statSync(folder + "\\" + files[i]); - if (options.recursive && stat.isDirectory()) { - paths = paths.concat(filesInFolder(folder + "\\" + files[i])); - } else if (stat.isFile() && (!spec || files[i].match(spec))) { - paths.push(folder + "\\" + files[i]); - } - } - - return paths; - } - - return filesInFolder(path); - }, - arguments: process.argv.slice(2), - standardOut: { - Write: function (str) { - process.stdout.write(str); - }, - WriteLine: function (str) { - process.stdout.write(str + '\n'); - }, - Close: function () { - } - } - }; - } - ; - - if (typeof WScript !== "undefined" && typeof ActiveXObject === "function") { - return getWindowsScriptHostEnvironment(); - } else if (typeof module !== 'undefined' && module.exports) { - return getNodeEnvironment(); - } else { - return null; - } -})(); -var TypeScript; -(function (TypeScript) { - var IntegerUtilities = (function () { - function IntegerUtilities() { - } - IntegerUtilities.integerDivide = function (numerator, denominator) { - return (numerator / denominator) >> 0; - }; - - IntegerUtilities.integerMultiplyLow32Bits = function (n1, n2) { - var n1Low16 = n1 & 0x0000ffff; - var n1High16 = n1 >>> 16; - - var n2Low16 = n2 & 0x0000ffff; - var n2High16 = n2 >>> 16; - - var resultLow32 = (((n1 & 0xffff0000) * n2) >>> 0) + (((n1 & 0x0000ffff) * n2) >>> 0) >>> 0; - return resultLow32; - }; - - IntegerUtilities.integerMultiplyHigh32Bits = function (n1, n2) { - var n1Low16 = n1 & 0x0000ffff; - var n1High16 = n1 >>> 16; - - var n2Low16 = n2 & 0x0000ffff; - var n2High16 = n2 >>> 16; - - var resultHigh32 = n1High16 * n2High16 + ((((n1Low16 * n2Low16) >>> 17) + n1Low16 * n2High16) >>> 15); - return resultHigh32; - }; - return IntegerUtilities; - })(); - TypeScript.IntegerUtilities = IntegerUtilities; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var MathPrototype = (function () { - function MathPrototype() { - } - MathPrototype.max = function (a, b) { - return a >= b ? a : b; - }; - - MathPrototype.min = function (a, b) { - return a <= b ? a : b; - }; - return MathPrototype; - })(); - TypeScript.MathPrototype = MathPrototype; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (Collections) { - Collections.DefaultStringTableCapacity = 256; - - var StringTableEntry = (function () { - function StringTableEntry(Text, HashCode, Next) { - this.Text = Text; - this.HashCode = HashCode; - this.Next = Next; - } - return StringTableEntry; - })(); - - var StringTable = (function () { - function StringTable(capacity) { - this.entries = []; - this.count = 0; - var size = TypeScript.Hash.getPrime(capacity); - this.entries = TypeScript.ArrayUtilities.createArray(size, null); - } - StringTable.prototype.addCharArray = function (key, start, len) { - var hashCode = TypeScript.Hash.computeSimple31BitCharArrayHashCode(key, start, len) & 0x7FFFFFFF; - - var entry = this.findCharArrayEntry(key, start, len, hashCode); - if (entry !== null) { - return entry.Text; - } - - var slice = key.slice(start, start + len); - return this.addEntry(TypeScript.StringUtilities.fromCharCodeArray(slice), hashCode); - }; - - StringTable.prototype.findCharArrayEntry = function (key, start, len, hashCode) { - 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; - }; - - StringTable.prototype.addEntry = function (text, hashCode) { - var index = hashCode % this.entries.length; - - var e = new StringTableEntry(text, hashCode, this.entries[index]); - - this.entries[index] = e; - - if (this.count === this.entries.length) { - this.grow(); - } - - this.count++; - return e.Text; - }; - - StringTable.prototype.grow = function () { - var newSize = TypeScript.Hash.expandPrime(this.entries.length); - - var oldEntries = this.entries; - var newEntries = TypeScript.ArrayUtilities.createArray(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; - } - } - }; - - StringTable.textCharArrayEquals = function (text, array, start, length) { - 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; - }; - return StringTable; - })(); - Collections.StringTable = StringTable; - - Collections.DefaultStringTable = new StringTable(Collections.DefaultStringTableCapacity); - })(TypeScript.Collections || (TypeScript.Collections = {})); - var Collections = TypeScript.Collections; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var StringUtilities = (function () { - function StringUtilities() { - } - StringUtilities.isString = function (value) { - return Object.prototype.toString.apply(value, []) === '[object String]'; - }; - - StringUtilities.fromCharCodeArray = function (array) { - return String.fromCharCode.apply(null, array); - }; - - StringUtilities.endsWith = function (string, value) { - return string.substring(string.length - value.length, string.length) === value; - }; - - StringUtilities.startsWith = function (string, value) { - return string.substr(0, value.length) === value; - }; - - StringUtilities.copyTo = function (source, sourceIndex, destination, destinationIndex, count) { - for (var i = 0; i < count; i++) { - destination[destinationIndex + i] = source.charCodeAt(sourceIndex + i); - } - }; - - StringUtilities.repeat = function (value, count) { - return Array(count + 1).join(value); - }; - - StringUtilities.stringEquals = function (val1, val2) { - return val1 === val2; - }; - return StringUtilities; - })(); - TypeScript.StringUtilities = StringUtilities; -})(TypeScript || (TypeScript = {})); -var global = Function("return this").call(null); - -var TypeScript; -(function (TypeScript) { - var Clock; - (function (Clock) { - Clock.now; - Clock.resolution; - - if (typeof WScript !== "undefined" && typeof global['WScript'].InitializeProjection !== "undefined") { - global['WScript'].InitializeProjection(); - - Clock.now = function () { - return TestUtilities.QueryPerformanceCounter(); - }; - - Clock.resolution = TestUtilities.QueryPerformanceFrequency(); - } else { - Clock.now = function () { - return Date.now(); - }; - - Clock.resolution = 1000; - } - })(Clock || (Clock = {})); - - var Timer = (function () { - function Timer() { - this.time = 0; - } - Timer.prototype.start = function () { - this.time = 0; - this.startTime = Clock.now(); - }; - - Timer.prototype.end = function () { - this.time = (Clock.now() - this.startTime); - }; - return Timer; - })(); - TypeScript.Timer = Timer; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (CharacterCodes) { - CharacterCodes[CharacterCodes["nullCharacter"] = 0] = "nullCharacter"; - CharacterCodes[CharacterCodes["maxAsciiCharacter"] = 127] = "maxAsciiCharacter"; - - CharacterCodes[CharacterCodes["lineFeed"] = 10] = "lineFeed"; - CharacterCodes[CharacterCodes["carriageReturn"] = 13] = "carriageReturn"; - CharacterCodes[CharacterCodes["lineSeparator"] = 0x2028] = "lineSeparator"; - CharacterCodes[CharacterCodes["paragraphSeparator"] = 0x2029] = "paragraphSeparator"; - - CharacterCodes[CharacterCodes["nextLine"] = 0x0085] = "nextLine"; - - CharacterCodes[CharacterCodes["space"] = 0x0020] = "space"; - CharacterCodes[CharacterCodes["nonBreakingSpace"] = 0x00A0] = "nonBreakingSpace"; - CharacterCodes[CharacterCodes["enQuad"] = 0x2000] = "enQuad"; - CharacterCodes[CharacterCodes["emQuad"] = 0x2001] = "emQuad"; - CharacterCodes[CharacterCodes["enSpace"] = 0x2002] = "enSpace"; - CharacterCodes[CharacterCodes["emSpace"] = 0x2003] = "emSpace"; - CharacterCodes[CharacterCodes["threePerEmSpace"] = 0x2004] = "threePerEmSpace"; - CharacterCodes[CharacterCodes["fourPerEmSpace"] = 0x2005] = "fourPerEmSpace"; - CharacterCodes[CharacterCodes["sixPerEmSpace"] = 0x2006] = "sixPerEmSpace"; - CharacterCodes[CharacterCodes["figureSpace"] = 0x2007] = "figureSpace"; - CharacterCodes[CharacterCodes["punctuationSpace"] = 0x2008] = "punctuationSpace"; - CharacterCodes[CharacterCodes["thinSpace"] = 0x2009] = "thinSpace"; - CharacterCodes[CharacterCodes["hairSpace"] = 0x200A] = "hairSpace"; - CharacterCodes[CharacterCodes["zeroWidthSpace"] = 0x200B] = "zeroWidthSpace"; - CharacterCodes[CharacterCodes["narrowNoBreakSpace"] = 0x202F] = "narrowNoBreakSpace"; - CharacterCodes[CharacterCodes["ideographicSpace"] = 0x3000] = "ideographicSpace"; - - CharacterCodes[CharacterCodes["_"] = 95] = "_"; - CharacterCodes[CharacterCodes["$"] = 36] = "$"; - - CharacterCodes[CharacterCodes["_0"] = 48] = "_0"; - CharacterCodes[CharacterCodes["_9"] = 57] = "_9"; - - CharacterCodes[CharacterCodes["a"] = 97] = "a"; - CharacterCodes[CharacterCodes["b"] = 98] = "b"; - CharacterCodes[CharacterCodes["c"] = 99] = "c"; - CharacterCodes[CharacterCodes["d"] = 100] = "d"; - CharacterCodes[CharacterCodes["e"] = 101] = "e"; - CharacterCodes[CharacterCodes["f"] = 102] = "f"; - CharacterCodes[CharacterCodes["g"] = 103] = "g"; - CharacterCodes[CharacterCodes["h"] = 104] = "h"; - CharacterCodes[CharacterCodes["i"] = 105] = "i"; - CharacterCodes[CharacterCodes["k"] = 107] = "k"; - CharacterCodes[CharacterCodes["l"] = 108] = "l"; - CharacterCodes[CharacterCodes["m"] = 109] = "m"; - CharacterCodes[CharacterCodes["n"] = 110] = "n"; - CharacterCodes[CharacterCodes["o"] = 111] = "o"; - CharacterCodes[CharacterCodes["p"] = 112] = "p"; - CharacterCodes[CharacterCodes["q"] = 113] = "q"; - CharacterCodes[CharacterCodes["r"] = 114] = "r"; - CharacterCodes[CharacterCodes["s"] = 115] = "s"; - CharacterCodes[CharacterCodes["t"] = 116] = "t"; - CharacterCodes[CharacterCodes["u"] = 117] = "u"; - CharacterCodes[CharacterCodes["v"] = 118] = "v"; - CharacterCodes[CharacterCodes["w"] = 119] = "w"; - CharacterCodes[CharacterCodes["x"] = 120] = "x"; - CharacterCodes[CharacterCodes["y"] = 121] = "y"; - CharacterCodes[CharacterCodes["z"] = 122] = "z"; - - CharacterCodes[CharacterCodes["A"] = 65] = "A"; - CharacterCodes[CharacterCodes["E"] = 69] = "E"; - CharacterCodes[CharacterCodes["F"] = 70] = "F"; - CharacterCodes[CharacterCodes["X"] = 88] = "X"; - CharacterCodes[CharacterCodes["Z"] = 90] = "Z"; - - CharacterCodes[CharacterCodes["ampersand"] = 38] = "ampersand"; - CharacterCodes[CharacterCodes["asterisk"] = 42] = "asterisk"; - CharacterCodes[CharacterCodes["at"] = 64] = "at"; - CharacterCodes[CharacterCodes["backslash"] = 92] = "backslash"; - CharacterCodes[CharacterCodes["bar"] = 124] = "bar"; - CharacterCodes[CharacterCodes["caret"] = 94] = "caret"; - CharacterCodes[CharacterCodes["closeBrace"] = 125] = "closeBrace"; - CharacterCodes[CharacterCodes["closeBracket"] = 93] = "closeBracket"; - CharacterCodes[CharacterCodes["closeParen"] = 41] = "closeParen"; - CharacterCodes[CharacterCodes["colon"] = 58] = "colon"; - CharacterCodes[CharacterCodes["comma"] = 44] = "comma"; - CharacterCodes[CharacterCodes["dot"] = 46] = "dot"; - CharacterCodes[CharacterCodes["doubleQuote"] = 34] = "doubleQuote"; - CharacterCodes[CharacterCodes["equals"] = 61] = "equals"; - CharacterCodes[CharacterCodes["exclamation"] = 33] = "exclamation"; - CharacterCodes[CharacterCodes["greaterThan"] = 62] = "greaterThan"; - CharacterCodes[CharacterCodes["lessThan"] = 60] = "lessThan"; - CharacterCodes[CharacterCodes["minus"] = 45] = "minus"; - CharacterCodes[CharacterCodes["openBrace"] = 123] = "openBrace"; - CharacterCodes[CharacterCodes["openBracket"] = 91] = "openBracket"; - CharacterCodes[CharacterCodes["openParen"] = 40] = "openParen"; - CharacterCodes[CharacterCodes["percent"] = 37] = "percent"; - CharacterCodes[CharacterCodes["plus"] = 43] = "plus"; - CharacterCodes[CharacterCodes["question"] = 63] = "question"; - CharacterCodes[CharacterCodes["semicolon"] = 59] = "semicolon"; - CharacterCodes[CharacterCodes["singleQuote"] = 39] = "singleQuote"; - CharacterCodes[CharacterCodes["slash"] = 47] = "slash"; - CharacterCodes[CharacterCodes["tilde"] = 126] = "tilde"; - - CharacterCodes[CharacterCodes["backspace"] = 8] = "backspace"; - CharacterCodes[CharacterCodes["formFeed"] = 12] = "formFeed"; - CharacterCodes[CharacterCodes["byteOrderMark"] = 0xFEFF] = "byteOrderMark"; - CharacterCodes[CharacterCodes["tab"] = 9] = "tab"; - CharacterCodes[CharacterCodes["verticalTab"] = 11] = "verticalTab"; - })(TypeScript.CharacterCodes || (TypeScript.CharacterCodes = {})); - var CharacterCodes = TypeScript.CharacterCodes; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (ScriptSnapshot) { - var StringScriptSnapshot = (function () { - function StringScriptSnapshot(text) { - this.text = text; - } - StringScriptSnapshot.prototype.getText = function (start, end) { - return this.text.substring(start, end); - }; - - StringScriptSnapshot.prototype.getLength = function () { - return this.text.length; - }; - - StringScriptSnapshot.prototype.getLineStartPositions = function () { - return TypeScript.TextUtilities.parseLineStarts(TypeScript.SimpleText.fromString(this.text)); - }; - - StringScriptSnapshot.prototype.getTextChangeRangeSinceVersion = function (scriptVersion) { - throw TypeScript.Errors.notYetImplemented(); - }; - return StringScriptSnapshot; - })(); - - function fromString(text) { - return new StringScriptSnapshot(text); - } - ScriptSnapshot.fromString = fromString; - })(TypeScript.ScriptSnapshot || (TypeScript.ScriptSnapshot = {})); - var ScriptSnapshot = TypeScript.ScriptSnapshot; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var LineMap = (function () { - function LineMap(_lineStarts, length) { - this._lineStarts = _lineStarts; - this.length = length; - } - LineMap.prototype.toJSON = function (key) { - return { lineStarts: this._lineStarts, length: this.length }; - }; - - LineMap.prototype.equals = function (other) { - return this.length === other.length && TypeScript.ArrayUtilities.sequenceEquals(this.lineStarts(), other.lineStarts(), function (v1, v2) { - return v1 === v2; - }); - }; - - LineMap.prototype.lineStarts = function () { - return this._lineStarts; - }; - - LineMap.prototype.lineCount = function () { - return this.lineStarts().length; - }; - - LineMap.prototype.getPosition = function (line, character) { - return this.lineStarts()[line] + character; - }; - - LineMap.prototype.getLineNumberFromPosition = function (position) { - if (position < 0 || position > this.length) { - throw TypeScript.Errors.argumentOutOfRange("position"); - } - - if (position === this.length) { - return this.lineCount() - 1; - } - - var lineNumber = TypeScript.ArrayUtilities.binarySearch(this.lineStarts(), position); - if (lineNumber < 0) { - lineNumber = (~lineNumber) - 1; - } - - return lineNumber; - }; - - LineMap.prototype.getLineStartPosition = function (lineNumber) { - return this.lineStarts()[lineNumber]; - }; - - LineMap.prototype.fillLineAndCharacterFromPosition = function (position, lineAndCharacter) { - if (position < 0 || position > this.length) { - throw TypeScript.Errors.argumentOutOfRange("position"); - } - - var lineNumber = this.getLineNumberFromPosition(position); - lineAndCharacter.line = lineNumber; - lineAndCharacter.character = position - this.lineStarts()[lineNumber]; - }; - - LineMap.prototype.getLineAndCharacterFromPosition = function (position) { - if (position < 0 || position > this.length) { - throw TypeScript.Errors.argumentOutOfRange("position"); - } - - var lineNumber = this.getLineNumberFromPosition(position); - - return new TypeScript.LineAndCharacter(lineNumber, position - this.lineStarts()[lineNumber]); - }; - - LineMap.fromSimpleText = function (text) { - var lineStarts = TypeScript.TextUtilities.parseLineStarts(text); - - return new LineMap(lineStarts, text.length()); - }; - - LineMap.fromScriptSnapshot = function (scriptSnapshot) { - return new LineMap(scriptSnapshot.getLineStartPositions(), scriptSnapshot.getLength()); - }; - - LineMap.fromString = function (text) { - return LineMap.fromSimpleText(TypeScript.SimpleText.fromString(text)); - }; - LineMap.empty = new LineMap([0], 0); - return LineMap; - })(); - TypeScript.LineMap = LineMap; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var LineAndCharacter = (function () { - function LineAndCharacter(line, character) { - this._line = 0; - this._character = 0; - if (line < 0) { - throw TypeScript.Errors.argumentOutOfRange("line"); - } - - if (character < 0) { - throw TypeScript.Errors.argumentOutOfRange("character"); - } - - this._line = line; - this._character = character; - } - LineAndCharacter.prototype.line = function () { - return this._line; - }; - - LineAndCharacter.prototype.character = function () { - return this._character; - }; - return LineAndCharacter; - })(); - TypeScript.LineAndCharacter = LineAndCharacter; -})(TypeScript || (TypeScript = {})); -var __extends = this.__extends || function (d, b) { - for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; - function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); -}; -var TypeScript; -(function (TypeScript) { - (function (TextFactory) { - function getStartAndLengthOfLineBreakEndingAt(text, index, info) { - var c = text.charCodeAt(index); - if (c === 10 /* lineFeed */) { - if (index > 0 && text.charCodeAt(index - 1) === 13 /* carriageReturn */) { - info.startPosition = index - 1; - info.length = 2; - } else { - info.startPosition = index; - info.length = 1; - } - } else if (TypeScript.TextUtilities.isAnyLineBreakCharacter(c)) { - info.startPosition = index; - info.length = 1; - } else { - info.startPosition = index + 1; - info.length = 0; - } - } - - var LinebreakInfo = (function () { - function LinebreakInfo(startPosition, length) { - this.startPosition = startPosition; - this.length = length; - } - return LinebreakInfo; - })(); - - var TextLine = (function () { - function TextLine(text, body, lineBreakLength, lineNumber) { - this._text = null; - this._textSpan = null; - TypeScript.Contract.throwIfNull(text); - TypeScript.Contract.throwIfFalse(lineBreakLength >= 0); - TypeScript.Contract.requires(lineNumber >= 0); - this._text = text; - this._textSpan = body; - this._lineBreakLength = lineBreakLength; - this._lineNumber = lineNumber; - } - TextLine.prototype.start = function () { - return this._textSpan.start(); - }; - - TextLine.prototype.end = function () { - return this._textSpan.end(); - }; - - TextLine.prototype.endIncludingLineBreak = function () { - return this.end() + this._lineBreakLength; - }; - - TextLine.prototype.extent = function () { - return this._textSpan; - }; - - TextLine.prototype.extentIncludingLineBreak = function () { - return TypeScript.TextSpan.fromBounds(this.start(), this.endIncludingLineBreak()); - }; - - TextLine.prototype.toString = function () { - return this._text.toString(this._textSpan); - }; - - TextLine.prototype.lineNumber = function () { - return this._lineNumber; - }; - return TextLine; - })(); - - var TextBase = (function () { - function TextBase() { - this.lazyLineStarts = null; - this.linebreakInfo = new LinebreakInfo(0, 0); - this.lastLineFoundForPosition = null; - } - TextBase.prototype.length = function () { - throw TypeScript.Errors.abstract(); - }; - - TextBase.prototype.charCodeAt = function (position) { - throw TypeScript.Errors.abstract(); - }; - - TextBase.prototype.checkSubSpan = function (span) { - if (span.start() < 0 || span.start() > this.length() || span.end() > this.length()) { - throw TypeScript.Errors.argumentOutOfRange("span"); - } - }; - - TextBase.prototype.toString = function (span) { - if (typeof span === "undefined") { span = null; } - throw TypeScript.Errors.abstract(); - }; - - TextBase.prototype.subText = function (span) { - this.checkSubSpan(span); - - return new SubText(this, span); - }; - - TextBase.prototype.substr = function (start, length, intern) { - throw TypeScript.Errors.abstract(); - }; - - TextBase.prototype.copyTo = function (sourceIndex, destination, destinationIndex, count) { - throw TypeScript.Errors.abstract(); - }; - - TextBase.prototype.lineCount = function () { - return this.lineStarts().length; - }; - - TextBase.prototype.lines = function () { - var lines = []; - - var length = this.lineCount(); - for (var i = 0; i < length; ++i) { - lines[i] = this.getLineFromLineNumber(i); - } - - return lines; - }; - - TextBase.prototype.lineMap = function () { - return new TypeScript.LineMap(this.lineStarts(), this.length()); - }; - - TextBase.prototype.lineStarts = function () { - if (this.lazyLineStarts === null) { - this.lazyLineStarts = TypeScript.TextUtilities.parseLineStarts(this); - } - - return this.lazyLineStarts; - }; - - TextBase.prototype.getLineFromLineNumber = function (lineNumber) { - var lineStarts = this.lineStarts(); - - if (lineNumber < 0 || lineNumber >= lineStarts.length) { - throw TypeScript.Errors.argumentOutOfRange("lineNumber"); - } - - var first = lineStarts[lineNumber]; - if (lineNumber === lineStarts.length - 1) { - return new TextLine(this, new TypeScript.TextSpan(first, this.length() - first), 0, lineNumber); - } else { - getStartAndLengthOfLineBreakEndingAt(this, lineStarts[lineNumber + 1] - 1, this.linebreakInfo); - return new TextLine(this, new TypeScript.TextSpan(first, this.linebreakInfo.startPosition - first), this.linebreakInfo.length, lineNumber); - } - }; - - TextBase.prototype.getLineFromPosition = function (position) { - var lastFound = this.lastLineFoundForPosition; - if (lastFound !== null && lastFound.start() <= position && lastFound.endIncludingLineBreak() > position) { - return lastFound; - } - - var lineNumber = this.getLineNumberFromPosition(position); - - var result = this.getLineFromLineNumber(lineNumber); - this.lastLineFoundForPosition = result; - return result; - }; - - TextBase.prototype.getLineNumberFromPosition = function (position) { - if (position < 0 || position > this.length()) { - throw TypeScript.Errors.argumentOutOfRange("position"); - } - - if (position === this.length()) { - return this.lineCount() - 1; - } - - var lineNumber = TypeScript.ArrayUtilities.binarySearch(this.lineStarts(), position); - if (lineNumber < 0) { - lineNumber = (~lineNumber) - 1; - } - - return lineNumber; - }; - - TextBase.prototype.getLinePosition = function (position) { - if (position < 0 || position > this.length()) { - throw TypeScript.Errors.argumentOutOfRange("position"); - } - - var lineNumber = this.getLineNumberFromPosition(position); - - return new TypeScript.LineAndCharacter(lineNumber, position - this.lineStarts()[lineNumber]); - }; - return TextBase; - })(); - - var SubText = (function (_super) { - __extends(SubText, _super); - function SubText(text, span) { - _super.call(this); - - if (text === null) { - throw TypeScript.Errors.argumentNull("text"); - } - - if (span.start() < 0 || span.start() >= text.length() || span.end() < 0 || span.end() > text.length()) { - throw TypeScript.Errors.argument("span"); - } - - this.text = text; - this.span = span; - } - SubText.prototype.length = function () { - return this.span.length(); - }; - - SubText.prototype.charCodeAt = function (position) { - if (position < 0 || position > this.length()) { - throw TypeScript.Errors.argumentOutOfRange("position"); - } - - return this.text.charCodeAt(this.span.start() + position); - }; - - SubText.prototype.subText = function (span) { - this.checkSubSpan(span); - - return new SubText(this.text, this.getCompositeSpan(span.start(), span.length())); - }; - - SubText.prototype.copyTo = function (sourceIndex, destination, destinationIndex, count) { - var span = this.getCompositeSpan(sourceIndex, count); - this.text.copyTo(span.start(), destination, destinationIndex, span.length()); - }; - - SubText.prototype.getCompositeSpan = function (start, length) { - var compositeStart = TypeScript.MathPrototype.min(this.text.length(), this.span.start() + start); - var compositeEnd = TypeScript.MathPrototype.min(this.text.length(), compositeStart + length); - return new TypeScript.TextSpan(compositeStart, compositeEnd - compositeStart); - }; - return SubText; - })(TextBase); - - var StringText = (function (_super) { - __extends(StringText, _super); - function StringText(data) { - _super.call(this); - this.source = null; - - if (data === null) { - throw TypeScript.Errors.argumentNull("data"); - } - - this.source = data; - } - StringText.prototype.length = function () { - return this.source.length; - }; - - StringText.prototype.charCodeAt = function (position) { - if (position < 0 || position >= this.source.length) { - throw TypeScript.Errors.argumentOutOfRange("position"); - } - - return this.source.charCodeAt(position); - }; - - StringText.prototype.substr = function (start, length, intern) { - return this.source.substr(start, length); - }; - - StringText.prototype.toString = function (span) { - if (typeof span === "undefined") { span = null; } - if (span === null) { - span = new TypeScript.TextSpan(0, this.length()); - } - - this.checkSubSpan(span); - - if (span.start() === 0 && span.length() === this.length()) { - return this.source; - } - - return this.source.substr(span.start(), span.length()); - }; - - StringText.prototype.copyTo = function (sourceIndex, destination, destinationIndex, count) { - TypeScript.StringUtilities.copyTo(this.source, sourceIndex, destination, destinationIndex, count); - }; - return StringText; - })(TextBase); - - function createText(value) { - return new StringText(value); - } - TextFactory.createText = createText; - })(TypeScript.TextFactory || (TypeScript.TextFactory = {})); - var TextFactory = TypeScript.TextFactory; -})(TypeScript || (TypeScript = {})); - -var TypeScript; -(function (TypeScript) { - (function (SimpleText) { - var SimpleSubText = (function () { - function SimpleSubText(text, span) { - this.text = null; - this.span = null; - if (text === null) { - throw TypeScript.Errors.argumentNull("text"); - } - - if (span.start() < 0 || span.start() >= text.length() || span.end() < 0 || span.end() > text.length()) { - throw TypeScript.Errors.argument("span"); - } - - this.text = text; - this.span = span; - } - SimpleSubText.prototype.checkSubSpan = function (span) { - if (span.start() < 0 || span.start() > this.length() || span.end() > this.length()) { - throw TypeScript.Errors.argumentOutOfRange("span"); - } - }; - - SimpleSubText.prototype.checkSubPosition = function (position) { - if (position < 0 || position >= this.length()) { - throw TypeScript.Errors.argumentOutOfRange("position"); - } - }; - - SimpleSubText.prototype.length = function () { - return this.span.length(); - }; - - SimpleSubText.prototype.subText = function (span) { - this.checkSubSpan(span); - - return new SimpleSubText(this.text, this.getCompositeSpan(span.start(), span.length())); - }; - - SimpleSubText.prototype.copyTo = function (sourceIndex, destination, destinationIndex, count) { - var span = this.getCompositeSpan(sourceIndex, count); - this.text.copyTo(span.start(), destination, destinationIndex, span.length()); - }; - - SimpleSubText.prototype.substr = function (start, length, intern) { - var span = this.getCompositeSpan(start, length); - return this.text.substr(span.start(), span.length(), intern); - }; - - SimpleSubText.prototype.getCompositeSpan = function (start, length) { - var compositeStart = TypeScript.MathPrototype.min(this.text.length(), this.span.start() + start); - var compositeEnd = TypeScript.MathPrototype.min(this.text.length(), compositeStart + length); - return new TypeScript.TextSpan(compositeStart, compositeEnd - compositeStart); - }; - - SimpleSubText.prototype.charCodeAt = function (index) { - this.checkSubPosition(index); - return this.text.charCodeAt(this.span.start() + index); - }; - - SimpleSubText.prototype.lineMap = function () { - return TypeScript.LineMap.fromSimpleText(this); - }; - return SimpleSubText; - })(); - - var SimpleStringText = (function () { - function SimpleStringText(value) { - this.value = value; - } - SimpleStringText.prototype.length = function () { - return this.value.length; - }; - - SimpleStringText.prototype.copyTo = function (sourceIndex, destination, destinationIndex, count) { - TypeScript.StringUtilities.copyTo(this.value, sourceIndex, destination, destinationIndex, count); - }; - - SimpleStringText.prototype.substr = function (start, length, intern) { - if (intern) { - var array = length <= SimpleStringText.charArray.length ? SimpleStringText.charArray : TypeScript.ArrayUtilities.createArray(length, 0); - this.copyTo(start, array, 0, length); - return TypeScript.Collections.DefaultStringTable.addCharArray(array, 0, length); - } - - return this.value.substr(start, length); - }; - - SimpleStringText.prototype.subText = function (span) { - return new SimpleSubText(this, span); - }; - - SimpleStringText.prototype.charCodeAt = function (index) { - return this.value.charCodeAt(index); - }; - - SimpleStringText.prototype.lineMap = function () { - return TypeScript.LineMap.fromSimpleText(this); - }; - SimpleStringText.charArray = TypeScript.ArrayUtilities.createArray(1024, 0); - return SimpleStringText; - })(); - - var SimpleScriptSnapshotText = (function () { - function SimpleScriptSnapshotText(scriptSnapshot) { - this.scriptSnapshot = scriptSnapshot; - } - SimpleScriptSnapshotText.prototype.charCodeAt = function (index) { - return this.scriptSnapshot.getText(index, index + 1).charCodeAt(0); - }; - - SimpleScriptSnapshotText.prototype.length = function () { - return this.scriptSnapshot.getLength(); - }; - - SimpleScriptSnapshotText.prototype.copyTo = function (sourceIndex, destination, destinationIndex, count) { - var text = this.scriptSnapshot.getText(sourceIndex, sourceIndex + count); - TypeScript.StringUtilities.copyTo(text, 0, destination, destinationIndex, count); - }; - - SimpleScriptSnapshotText.prototype.substr = function (start, length, intern) { - return this.scriptSnapshot.getText(start, start + length); - }; - - SimpleScriptSnapshotText.prototype.subText = function (span) { - return new SimpleSubText(this, span); - }; - - SimpleScriptSnapshotText.prototype.lineMap = function () { - var lineStartPositions = this.scriptSnapshot.getLineStartPositions(); - return new TypeScript.LineMap(lineStartPositions, this.length()); - }; - return SimpleScriptSnapshotText; - })(); - - function fromString(value) { - return new SimpleStringText(value); - } - SimpleText.fromString = fromString; - - function fromScriptSnapshot(scriptSnapshot) { - return new SimpleScriptSnapshotText(scriptSnapshot); - } - SimpleText.fromScriptSnapshot = fromScriptSnapshot; - })(TypeScript.SimpleText || (TypeScript.SimpleText = {})); - var SimpleText = TypeScript.SimpleText; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (TextUtilities) { - function parseLineStarts(text) { - var length = text.length(); - - if (0 === length) { - var result = []; - result.push(0); - return result; - } - - var position = 0; - var index = 0; - var arrayBuilder = []; - var lineNumber = 0; - - while (index < length) { - var c = text.charCodeAt(index); - var lineBreakLength; - - if (c > 13 /* carriageReturn */ && c <= 127) { - index++; - continue; - } else if (c === 13 /* carriageReturn */ && index + 1 < length && text.charCodeAt(index + 1) === 10 /* lineFeed */) { - lineBreakLength = 2; - } else if (c === 10 /* lineFeed */) { - lineBreakLength = 1; - } else { - lineBreakLength = TextUtilities.getLengthOfLineBreak(text, index); - } - - if (0 === lineBreakLength) { - index++; - } else { - arrayBuilder.push(position); - index += lineBreakLength; - position = index; - lineNumber++; - } - } - - arrayBuilder.push(position); - - return arrayBuilder; - } - TextUtilities.parseLineStarts = parseLineStarts; - - function getLengthOfLineBreakSlow(text, index, c) { - if (c === 13 /* carriageReturn */) { - var next = index + 1; - return (next < text.length()) && 10 /* lineFeed */ === text.charCodeAt(next) ? 2 : 1; - } else if (isAnyLineBreakCharacter(c)) { - return 1; - } else { - return 0; - } - } - TextUtilities.getLengthOfLineBreakSlow = getLengthOfLineBreakSlow; - - function getLengthOfLineBreak(text, index) { - var c = text.charCodeAt(index); - - if (c > 13 /* carriageReturn */ && c <= 127) { - return 0; - } - - return getLengthOfLineBreakSlow(text, index, c); - } - TextUtilities.getLengthOfLineBreak = getLengthOfLineBreak; - - function isAnyLineBreakCharacter(c) { - return c === 10 /* lineFeed */ || c === 13 /* carriageReturn */ || c === 133 /* nextLine */ || c === 8232 /* lineSeparator */ || c === 8233 /* paragraphSeparator */; - } - TextUtilities.isAnyLineBreakCharacter = isAnyLineBreakCharacter; - })(TypeScript.TextUtilities || (TypeScript.TextUtilities = {})); - var TextUtilities = TypeScript.TextUtilities; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var TextSpan = (function () { - function TextSpan(start, length) { - if (start < 0) { - TypeScript.Errors.argument("start"); - } - - if (start + length < start) { - throw new Error("length"); - } - - this._start = start; - this._length = length; - } - TextSpan.prototype.start = function () { - return this._start; - }; - - TextSpan.prototype.length = function () { - return this._length; - }; - - TextSpan.prototype.end = function () { - return this._start + this._length; - }; - - TextSpan.prototype.isEmpty = function () { - return this._length === 0; - }; - - TextSpan.prototype.containsPosition = function (position) { - return position >= this._start && position < this.end(); - }; - - TextSpan.prototype.containsTextSpan = function (span) { - return span._start >= this._start && span.end() <= this.end(); - }; - - TextSpan.prototype.overlapsWith = function (span) { - var overlapStart = TypeScript.MathPrototype.max(this._start, span._start); - var overlapEnd = TypeScript.MathPrototype.min(this.end(), span.end()); - - return overlapStart < overlapEnd; - }; - - TextSpan.prototype.overlap = function (span) { - var overlapStart = TypeScript.MathPrototype.max(this._start, span._start); - var overlapEnd = TypeScript.MathPrototype.min(this.end(), span.end()); - - if (overlapStart < overlapEnd) { - return TextSpan.fromBounds(overlapStart, overlapEnd); - } - - return null; - }; - - TextSpan.prototype.intersectsWithTextSpan = function (span) { - return span._start <= this.end() && span.end() >= this._start; - }; - - TextSpan.prototype.intersectsWith = function (start, length) { - var end = start + length; - return start <= this.end() && end >= this._start; - }; - - TextSpan.prototype.intersectsWithPosition = function (position) { - return position <= this.end() && position >= this._start; - }; - - TextSpan.prototype.intersection = function (span) { - var intersectStart = TypeScript.MathPrototype.max(this._start, span._start); - var intersectEnd = TypeScript.MathPrototype.min(this.end(), span.end()); - - if (intersectStart <= intersectEnd) { - return TextSpan.fromBounds(intersectStart, intersectEnd); - } - - return null; - }; - - TextSpan.fromBounds = function (start, end) { - TypeScript.Contract.requires(start >= 0); - TypeScript.Contract.requires(end - start >= 0); - return new TextSpan(start, end - start); - }; - return TextSpan; - })(); - TypeScript.TextSpan = TextSpan; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var TextChangeRange = (function () { - function TextChangeRange(span, newLength) { - if (newLength < 0) { - throw TypeScript.Errors.argumentOutOfRange("newLength"); - } - - this._span = span; - this._newLength = newLength; - } - TextChangeRange.prototype.span = function () { - return this._span; - }; - - TextChangeRange.prototype.newLength = function () { - return this._newLength; - }; - - TextChangeRange.prototype.newSpan = function () { - return new TypeScript.TextSpan(this.span().start(), this.newLength()); - }; - - TextChangeRange.prototype.isUnchanged = function () { - return this.span().isEmpty() && this.newLength() === 0; - }; - - TextChangeRange.collapseChangesFromSingleVersion = function (changes) { - var diff = 0; - var start = 1073741823 /* Max31BitInteger */; - var end = 0; - - for (var i = 0; i < changes.length; i++) { - var change = changes[i]; - diff += change.newLength() - change.span().length(); - - if (change.span().start() < start) { - start = change.span().start(); - } - - if (change.span().end() > end) { - end = change.span().end(); - } - } - - if (start > end) { - return null; - } - - var combined = TypeScript.TextSpan.fromBounds(start, end); - var newLen = combined.length() + diff; - - return new TextChangeRange(combined, newLen); - }; - - TextChangeRange.collapseChangesAcrossMultipleVersions = function (changes) { - if (changes.length === 0) { - return TextChangeRange.unchanged; - } - - if (changes.length === 1) { - return changes[0]; - } - - 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]; - - 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 = TypeScript.MathPrototype.min(oldStart1, oldStart2); - oldEndN = TypeScript.MathPrototype.max(oldEnd1, oldEnd1 + (oldEnd2 - newEnd1)); - newEndN = TypeScript.MathPrototype.max(newEnd2, newEnd2 + (newEnd1 - oldEnd2)); - } - - return new TextChangeRange(TypeScript.TextSpan.fromBounds(oldStartN, oldEndN), newEndN - oldStartN); - }; - TextChangeRange.unchanged = new TextChangeRange(new TypeScript.TextSpan(0, 0), 0); - return TextChangeRange; - })(); - TypeScript.TextChangeRange = TextChangeRange; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var CharacterInfo = (function () { - function CharacterInfo() { - } - CharacterInfo.isDecimalDigit = function (c) { - return c >= 48 /* _0 */ && c <= 57 /* _9 */; - }; - - CharacterInfo.isHexDigit = function (c) { - return CharacterInfo.isDecimalDigit(c) || (c >= 65 /* A */ && c <= 70 /* F */) || (c >= 97 /* a */ && c <= 102 /* f */); - }; - - CharacterInfo.hexValue = function (c) { - return CharacterInfo.isDecimalDigit(c) ? (c - 48 /* _0 */) : (c >= 65 /* A */ && c <= 70 /* F */) ? c - 65 /* A */ + 10 : c - 97 /* a */ + 10; - }; - - CharacterInfo.isWhitespace = function (ch) { - switch (ch) { - case 32 /* space */: - case 160 /* nonBreakingSpace */: - case 8192 /* enQuad */: - case 8193 /* emQuad */: - case 8194 /* enSpace */: - case 8195 /* emSpace */: - case 8196 /* threePerEmSpace */: - case 8197 /* fourPerEmSpace */: - case 8198 /* sixPerEmSpace */: - case 8199 /* figureSpace */: - case 8200 /* punctuationSpace */: - case 8201 /* thinSpace */: - case 8202 /* hairSpace */: - case 8203 /* zeroWidthSpace */: - case 8239 /* narrowNoBreakSpace */: - case 12288 /* ideographicSpace */: - - case 9 /* tab */: - case 11 /* verticalTab */: - case 12 /* formFeed */: - case 65279 /* byteOrderMark */: - return true; - } - - return false; - }; - - CharacterInfo.isLineTerminator = function (ch) { - switch (ch) { - case 13 /* carriageReturn */: - case 10 /* lineFeed */: - case 8233 /* paragraphSeparator */: - case 8232 /* lineSeparator */: - return true; - } - - return false; - }; - return CharacterInfo; - })(); - TypeScript.CharacterInfo = CharacterInfo; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (SyntaxConstants) { - SyntaxConstants[SyntaxConstants["TriviaNewLineMask"] = 0x00000001] = "TriviaNewLineMask"; - SyntaxConstants[SyntaxConstants["TriviaCommentMask"] = 0x00000002] = "TriviaCommentMask"; - SyntaxConstants[SyntaxConstants["TriviaFullWidthShift"] = 2] = "TriviaFullWidthShift"; - - SyntaxConstants[SyntaxConstants["NodeDataComputed"] = 0x00000001] = "NodeDataComputed"; - SyntaxConstants[SyntaxConstants["NodeIncrementallyUnusableMask"] = 0x00000002] = "NodeIncrementallyUnusableMask"; - SyntaxConstants[SyntaxConstants["NodeParsedInStrictModeMask"] = 0x00000004] = "NodeParsedInStrictModeMask"; - SyntaxConstants[SyntaxConstants["NodeFullWidthShift"] = 3] = "NodeFullWidthShift"; - })(TypeScript.SyntaxConstants || (TypeScript.SyntaxConstants = {})); - var SyntaxConstants = TypeScript.SyntaxConstants; -})(TypeScript || (TypeScript = {})); -var FormattingOptions = (function () { - function FormattingOptions(useTabs, spacesPerTab, indentSpaces, newLineCharacter) { - this.useTabs = useTabs; - this.spacesPerTab = spacesPerTab; - this.indentSpaces = indentSpaces; - this.newLineCharacter = newLineCharacter; - } - FormattingOptions.defaultOptions = new FormattingOptions(false, 4, 4, "\r\n"); - return FormattingOptions; -})(); -var TypeScript; -(function (TypeScript) { - (function (Indentation) { - function columnForEndOfToken(token, syntaxInformationMap, options) { - return columnForStartOfToken(token, syntaxInformationMap, options) + token.width(); - } - Indentation.columnForEndOfToken = columnForEndOfToken; - - function columnForStartOfToken(token, syntaxInformationMap, options) { - var firstTokenInLine = syntaxInformationMap.firstTokenInLineContainingToken(token); - var leadingTextInReverse = []; - - var current = token; - while (current !== firstTokenInLine) { - current = syntaxInformationMap.previousToken(current); - - if (current === firstTokenInLine) { - leadingTextInReverse.push(current.trailingTrivia().fullText()); - leadingTextInReverse.push(current.text()); - } else { - leadingTextInReverse.push(current.fullText()); - } - } - - collectLeadingTriviaTextToStartOfLine(firstTokenInLine, leadingTextInReverse); - - return columnForLeadingTextInReverse(leadingTextInReverse, options); - } - Indentation.columnForStartOfToken = columnForStartOfToken; - - function columnForStartOfFirstTokenInLineContainingToken(token, syntaxInformationMap, options) { - var firstTokenInLine = syntaxInformationMap.firstTokenInLineContainingToken(token); - var leadingTextInReverse = []; - - collectLeadingTriviaTextToStartOfLine(firstTokenInLine, leadingTextInReverse); - - return columnForLeadingTextInReverse(leadingTextInReverse, options); - } - Indentation.columnForStartOfFirstTokenInLineContainingToken = columnForStartOfFirstTokenInLineContainingToken; - - function collectLeadingTriviaTextToStartOfLine(firstTokenInLine, leadingTextInReverse) { - var leadingTrivia = firstTokenInLine.leadingTrivia(); - - for (var i = leadingTrivia.count() - 1; i >= 0; i--) { - var trivia = leadingTrivia.syntaxTriviaAt(i); - if (trivia.kind() === 5 /* NewLineTrivia */) { - break; - } - - if (trivia.kind() === 6 /* MultiLineCommentTrivia */) { - var lineSegments = TypeScript.Syntax.splitMultiLineCommentTriviaIntoMultipleLines(trivia); - leadingTextInReverse.push(TypeScript.ArrayUtilities.last(lineSegments)); - - if (lineSegments.length > 0) { - break; - } - } - - leadingTextInReverse.push(trivia.fullText()); - } - } - - function columnForLeadingTextInReverse(leadingTextInReverse, options) { - var column = 0; - - for (var i = leadingTextInReverse.length - 1; i >= 0; i--) { - var text = leadingTextInReverse[i]; - column = columnForPositionInStringWorker(text, text.length, column, options); - } - - return column; - } - - function columnForPositionInString(input, position, options) { - return columnForPositionInStringWorker(input, position, 0, options); - } - Indentation.columnForPositionInString = columnForPositionInString; - - function columnForPositionInStringWorker(input, position, startColumn, options) { - var column = startColumn; - var spacesPerTab = options.spacesPerTab; - - for (var j = 0; j < position; j++) { - var ch = input.charCodeAt(j); - - if (ch === 9 /* tab */) { - column += spacesPerTab - column % spacesPerTab; - } else { - column++; - } - } - - return column; - } - - function indentationString(column, options) { - var numberOfTabs = 0; - var numberOfSpaces = TypeScript.MathPrototype.max(0, column); - - if (options.useTabs) { - numberOfTabs = Math.floor(column / options.spacesPerTab); - numberOfSpaces -= numberOfTabs * options.spacesPerTab; - } - - return TypeScript.StringUtilities.repeat('\t', numberOfTabs) + TypeScript.StringUtilities.repeat(' ', numberOfSpaces); - } - Indentation.indentationString = indentationString; - - function indentationTrivia(column, options) { - return TypeScript.Syntax.whitespace(this.indentationString(column, options)); - } - Indentation.indentationTrivia = indentationTrivia; - - function firstNonWhitespacePosition(value) { - for (var i = 0; i < value.length; i++) { - var ch = value.charCodeAt(i); - if (!TypeScript.CharacterInfo.isWhitespace(ch)) { - return i; - } - } - - return value.length; - } - Indentation.firstNonWhitespacePosition = firstNonWhitespacePosition; - })(TypeScript.Indentation || (TypeScript.Indentation = {})); - var Indentation = TypeScript.Indentation; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (LanguageVersion) { - LanguageVersion[LanguageVersion["EcmaScript3"] = 0] = "EcmaScript3"; - LanguageVersion[LanguageVersion["EcmaScript5"] = 1] = "EcmaScript5"; - })(TypeScript.LanguageVersion || (TypeScript.LanguageVersion = {})); - var LanguageVersion = TypeScript.LanguageVersion; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var ParseOptions = (function () { - function ParseOptions(allowAutomaticSemicolonInsertion, allowModuleKeywordInExternalModuleReference) { - this._allowAutomaticSemicolonInsertion = allowAutomaticSemicolonInsertion; - this._allowModuleKeywordInExternalModuleReference = allowModuleKeywordInExternalModuleReference; - } - ParseOptions.prototype.toJSON = function (key) { - return { - allowAutomaticSemicolonInsertion: this._allowAutomaticSemicolonInsertion, - allowModuleKeywordInExternalModuleReference: this._allowModuleKeywordInExternalModuleReference - }; - }; - - ParseOptions.prototype.allowAutomaticSemicolonInsertion = function () { - return this._allowAutomaticSemicolonInsertion; - }; - - ParseOptions.prototype.allowModuleKeywordInExternalModuleReference = function () { - return this._allowModuleKeywordInExternalModuleReference; - }; - return ParseOptions; - })(); - TypeScript.ParseOptions = ParseOptions; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var PositionedElement = (function () { - function PositionedElement(parent, element, fullStart) { - this._parent = parent; - this._element = element; - this._fullStart = fullStart; - } - PositionedElement.create = function (parent, element, fullStart) { - if (element === null) { - return null; - } - - if (element.isNode()) { - return new PositionedNode(parent, element, fullStart); - } else if (element.isToken()) { - return new PositionedToken(parent, element, fullStart); - } else if (element.isList()) { - return new PositionedList(parent, element, fullStart); - } else if (element.isSeparatedList()) { - return new PositionedSeparatedList(parent, element, fullStart); - } else { - throw TypeScript.Errors.invalidOperation(); - } - }; - - PositionedElement.prototype.parent = function () { - return this._parent; - }; - - PositionedElement.prototype.parentElement = function () { - return this._parent && this._parent._element; - }; - - PositionedElement.prototype.element = function () { - return this._element; - }; - - PositionedElement.prototype.kind = function () { - return this.element().kind(); - }; - - PositionedElement.prototype.childIndex = function (child) { - return TypeScript.Syntax.childIndex(this.element(), child); - }; - - PositionedElement.prototype.childCount = function () { - return this.element().childCount(); - }; - - PositionedElement.prototype.childAt = function (index) { - var offset = TypeScript.Syntax.childOffsetAt(this.element(), index); - return PositionedElement.create(this, this.element().childAt(index), this.fullStart() + offset); - }; - - PositionedElement.prototype.childStart = function (child) { - var offset = TypeScript.Syntax.childOffset(this.element(), child); - return this.fullStart() + offset + child.leadingTriviaWidth(); - }; - - PositionedElement.prototype.childEnd = function (child) { - var offset = TypeScript.Syntax.childOffset(this.element(), child); - return this.fullStart() + offset + child.leadingTriviaWidth() + child.width(); - }; - - PositionedElement.prototype.childStartAt = function (index) { - var offset = TypeScript.Syntax.childOffsetAt(this.element(), index); - var child = this.element().childAt(index); - return this.fullStart() + offset + child.leadingTriviaWidth(); - }; - - PositionedElement.prototype.childEndAt = function (index) { - var offset = TypeScript.Syntax.childOffsetAt(this.element(), index); - var child = this.element().childAt(index); - return this.fullStart() + offset + child.leadingTriviaWidth() + child.width(); - }; - - PositionedElement.prototype.getPositionedChild = function (child) { - var offset = TypeScript.Syntax.childOffset(this.element(), child); - return PositionedElement.create(this, child, this.fullStart() + offset); - }; - - PositionedElement.prototype.fullStart = function () { - return this._fullStart; - }; - - PositionedElement.prototype.fullEnd = function () { - return this.fullStart() + this.element().fullWidth(); - }; - - PositionedElement.prototype.fullWidth = function () { - return this.element().fullWidth(); - }; - - PositionedElement.prototype.start = function () { - return this.fullStart() + this.element().leadingTriviaWidth(); - }; - - PositionedElement.prototype.end = function () { - return this.fullStart() + this.element().leadingTriviaWidth() + this.element().width(); - }; - - PositionedElement.prototype.root = function () { - var current = this; - while (current.parent() !== null) { - current = current.parent(); - } - - return current; - }; - - PositionedElement.prototype.containingNode = function () { - var current = this.parent(); - - while (current !== null && !current.element().isNode()) { - current = current.parent(); - } - - return current; - }; - return PositionedElement; - })(); - TypeScript.PositionedElement = PositionedElement; - - var PositionedNodeOrToken = (function (_super) { - __extends(PositionedNodeOrToken, _super); - function PositionedNodeOrToken(parent, nodeOrToken, fullStart) { - _super.call(this, parent, nodeOrToken, fullStart); - } - PositionedNodeOrToken.prototype.nodeOrToken = function () { - return this.element(); - }; - return PositionedNodeOrToken; - })(PositionedElement); - TypeScript.PositionedNodeOrToken = PositionedNodeOrToken; - - var PositionedNode = (function (_super) { - __extends(PositionedNode, _super); - function PositionedNode(parent, node, fullStart) { - _super.call(this, parent, node, fullStart); - } - PositionedNode.prototype.node = function () { - return this.element(); - }; - return PositionedNode; - })(PositionedNodeOrToken); - TypeScript.PositionedNode = PositionedNode; - - var PositionedToken = (function (_super) { - __extends(PositionedToken, _super); - function PositionedToken(parent, token, fullStart) { - _super.call(this, parent, token, fullStart); - } - PositionedToken.prototype.token = function () { - return this.element(); - }; - - PositionedToken.prototype.previousToken = function (includeSkippedTokens) { - if (typeof includeSkippedTokens === "undefined") { includeSkippedTokens = false; } - var triviaList = this.token().leadingTrivia(); - if (includeSkippedTokens && triviaList && triviaList.hasSkippedToken()) { - var currentTriviaEndPosition = this.start(); - for (var i = triviaList.count() - 1; i >= 0; i--) { - var trivia = triviaList.syntaxTriviaAt(i); - if (trivia.isSkippedToken()) { - return new PositionedSkippedToken(this, trivia.skippedToken(), currentTriviaEndPosition - trivia.fullWidth()); - } - - currentTriviaEndPosition -= trivia.fullWidth(); - } - } - - var start = this.fullStart(); - if (start === 0) { - return null; - } - - return this.root().node().findToken(start - 1, includeSkippedTokens); - }; - - PositionedToken.prototype.nextToken = function (includeSkippedTokens) { - if (typeof includeSkippedTokens === "undefined") { includeSkippedTokens = false; } - if (this.token().tokenKind === 10 /* EndOfFileToken */) { - return null; - } - - var triviaList = this.token().trailingTrivia(); - if (includeSkippedTokens && triviaList && triviaList.hasSkippedToken()) { - var fullStart = this.end(); - for (var i = 0, n = triviaList.count(); i < n; i++) { - var trivia = triviaList.syntaxTriviaAt(i); - if (trivia.isSkippedToken()) { - return new PositionedSkippedToken(this, trivia.skippedToken(), fullStart); - } - - fullStart += trivia.fullWidth(); - } - } - - return this.root().node().findToken(this.fullEnd(), includeSkippedTokens); - }; - return PositionedToken; - })(PositionedNodeOrToken); - TypeScript.PositionedToken = PositionedToken; - - var PositionedList = (function (_super) { - __extends(PositionedList, _super); - function PositionedList(parent, list, fullStart) { - _super.call(this, parent, list, fullStart); - } - PositionedList.prototype.list = function () { - return this.element(); - }; - return PositionedList; - })(PositionedElement); - TypeScript.PositionedList = PositionedList; - - var PositionedSeparatedList = (function (_super) { - __extends(PositionedSeparatedList, _super); - function PositionedSeparatedList(parent, list, fullStart) { - _super.call(this, parent, list, fullStart); - } - PositionedSeparatedList.prototype.list = function () { - return this.element(); - }; - return PositionedSeparatedList; - })(PositionedElement); - TypeScript.PositionedSeparatedList = PositionedSeparatedList; - - var PositionedSkippedToken = (function (_super) { - __extends(PositionedSkippedToken, _super); - function PositionedSkippedToken(parentToken, token, fullStart) { - _super.call(this, parentToken.parent(), token, fullStart); - this._parentToken = parentToken; - } - PositionedSkippedToken.prototype.parentToken = function () { - return this._parentToken; - }; - - PositionedSkippedToken.prototype.previousToken = function (includeSkippedTokens) { - if (typeof includeSkippedTokens === "undefined") { includeSkippedTokens = false; } - var start = this.fullStart(); - - if (includeSkippedTokens) { - var previousToken; - - if (start >= this.parentToken().end()) { - previousToken = TypeScript.Syntax.findSkippedTokenInTrailingTriviaList(this.parentToken(), start - 1); - - if (previousToken) { - return previousToken; - } - - return this.parentToken(); - } else { - previousToken = TypeScript.Syntax.findSkippedTokenInLeadingTriviaList(this.parentToken(), start - 1); - - if (previousToken) { - return previousToken; - } - } - } - - var start = this.parentToken().fullStart(); - if (start === 0) { - return null; - } - - return this.root().node().findToken(start - 1, includeSkippedTokens); - }; - - PositionedSkippedToken.prototype.nextToken = function (includeSkippedTokens) { - if (typeof includeSkippedTokens === "undefined") { includeSkippedTokens = false; } - if (this.token().tokenKind === 10 /* EndOfFileToken */) { - return null; - } - - if (includeSkippedTokens) { - var end = this.end(); - var nextToken; - - if (end <= this.parentToken().start()) { - nextToken = TypeScript.Syntax.findSkippedTokenInLeadingTriviaList(this.parentToken(), end); - - if (nextToken) { - return nextToken; - } - - return this.parentToken(); - } else { - nextToken = TypeScript.Syntax.findSkippedTokenInTrailingTriviaList(this.parentToken(), end); - - if (nextToken) { - return nextToken; - } - } - } - - return this.root().node().findToken(this.parentToken().fullEnd(), includeSkippedTokens); - }; - return PositionedSkippedToken; - })(PositionedToken); - TypeScript.PositionedSkippedToken = PositionedSkippedToken; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var Scanner = (function () { - function Scanner(fileName, text, languageVersion, window) { - if (typeof window === "undefined") { window = TypeScript.ArrayUtilities.createArray(2048, 0); } - Scanner.initializeStaticData(); - - this.slidingWindow = new TypeScript.SlidingWindow(this, window, 0, text.length()); - this.fileName = fileName; - this.text = text; - this._languageVersion = languageVersion; - } - Scanner.initializeStaticData = function () { - if (Scanner.isKeywordStartCharacter.length === 0) { - Scanner.isKeywordStartCharacter = TypeScript.ArrayUtilities.createArray(127 /* maxAsciiCharacter */, false); - Scanner.isIdentifierStartCharacter = TypeScript.ArrayUtilities.createArray(127 /* maxAsciiCharacter */, false); - Scanner.isIdentifierPartCharacter = TypeScript.ArrayUtilities.createArray(127 /* maxAsciiCharacter */, false); - Scanner.isNumericLiteralStart = TypeScript.ArrayUtilities.createArray(127 /* maxAsciiCharacter */, false); - - for (var character = 0; character < 127 /* maxAsciiCharacter */; character++) { - if (character >= 97 /* a */ && character <= 122 /* z */) { - Scanner.isIdentifierStartCharacter[character] = true; - Scanner.isIdentifierPartCharacter[character] = true; - } else if ((character >= 65 /* A */ && character <= 90 /* Z */) || character === 95 /* _ */ || character === 36 /* $ */) { - Scanner.isIdentifierStartCharacter[character] = true; - Scanner.isIdentifierPartCharacter[character] = true; - } else if (character >= 48 /* _0 */ && character <= 57 /* _9 */) { - Scanner.isIdentifierPartCharacter[character] = true; - Scanner.isNumericLiteralStart[character] = true; - } - } - - Scanner.isNumericLiteralStart[46 /* dot */] = true; - - for (var keywordKind = TypeScript.SyntaxKind.FirstKeyword; keywordKind <= TypeScript.SyntaxKind.LastKeyword; keywordKind++) { - var keyword = TypeScript.SyntaxFacts.getText(keywordKind); - Scanner.isKeywordStartCharacter[keyword.charCodeAt(0)] = true; - } - } - }; - - Scanner.prototype.languageVersion = function () { - return this._languageVersion; - }; - - Scanner.prototype.fetchMoreItems = function (argument, sourceIndex, window, destinationIndex, spaceAvailable) { - var charactersRemaining = this.text.length() - sourceIndex; - var amountToRead = TypeScript.MathPrototype.min(charactersRemaining, spaceAvailable); - this.text.copyTo(sourceIndex, window, destinationIndex, amountToRead); - return amountToRead; - }; - - Scanner.prototype.currentCharCode = function () { - return this.slidingWindow.currentItem(null); - }; - - Scanner.prototype.absoluteIndex = function () { - return this.slidingWindow.absoluteIndex(); - }; - - Scanner.prototype.setAbsoluteIndex = function (index) { - this.slidingWindow.setAbsoluteIndex(index); - }; - - Scanner.prototype.scan = function (diagnostics, allowRegularExpression) { - var diagnosticsLength = diagnostics.length; - var fullStart = this.slidingWindow.absoluteIndex(); - var leadingTriviaInfo = this.scanTriviaInfo(diagnostics, false); - - var start = this.slidingWindow.absoluteIndex(); - var kind = this.scanSyntaxToken(diagnostics, allowRegularExpression); - var end = this.slidingWindow.absoluteIndex(); - - var trailingTriviaInfo = this.scanTriviaInfo(diagnostics, true); - - var token = this.createToken(fullStart, leadingTriviaInfo, start, kind, end, trailingTriviaInfo); - - return diagnosticsLength !== diagnostics.length ? TypeScript.Syntax.realizeToken(token) : token; - }; - - Scanner.prototype.createToken = function (fullStart, leadingTriviaInfo, start, kind, end, trailingTriviaInfo) { - if (kind >= TypeScript.SyntaxKind.FirstFixedWidth) { - if (leadingTriviaInfo === 0) { - if (trailingTriviaInfo === 0) { - return new TypeScript.Syntax.FixedWidthTokenWithNoTrivia(kind); - } else { - return new TypeScript.Syntax.FixedWidthTokenWithTrailingTrivia(this.text, fullStart, kind, trailingTriviaInfo); - } - } else if (trailingTriviaInfo === 0) { - return new TypeScript.Syntax.FixedWidthTokenWithLeadingTrivia(this.text, fullStart, kind, leadingTriviaInfo); - } else { - return new TypeScript.Syntax.FixedWidthTokenWithLeadingAndTrailingTrivia(this.text, fullStart, kind, leadingTriviaInfo, trailingTriviaInfo); - } - } else { - var width = end - start; - if (leadingTriviaInfo === 0) { - if (trailingTriviaInfo === 0) { - return new TypeScript.Syntax.VariableWidthTokenWithNoTrivia(this.text, fullStart, kind, width); - } else { - return new TypeScript.Syntax.VariableWidthTokenWithTrailingTrivia(this.text, fullStart, kind, width, trailingTriviaInfo); - } - } else if (trailingTriviaInfo === 0) { - return new TypeScript.Syntax.VariableWidthTokenWithLeadingTrivia(this.text, fullStart, kind, leadingTriviaInfo, width); - } else { - return new TypeScript.Syntax.VariableWidthTokenWithLeadingAndTrailingTrivia(this.text, fullStart, kind, leadingTriviaInfo, width, trailingTriviaInfo); - } - } - }; - - Scanner.scanTrivia = function (text, start, length, isTrailing) { - var scanner = new Scanner(null, text.subText(new TypeScript.TextSpan(start, length)), 1 /* EcmaScript5 */, Scanner.triviaWindow); - return scanner.scanTrivia(isTrailing); - }; - - Scanner.prototype.scanTrivia = function (isTrailing) { - var trivia = []; - - while (true) { - if (!this.slidingWindow.isAtEndOfSource()) { - var ch = this.currentCharCode(); - - switch (ch) { - case 32 /* space */: - case 160 /* nonBreakingSpace */: - case 8192 /* enQuad */: - case 8193 /* emQuad */: - case 8194 /* enSpace */: - case 8195 /* emSpace */: - case 8196 /* threePerEmSpace */: - case 8197 /* fourPerEmSpace */: - case 8198 /* sixPerEmSpace */: - case 8199 /* figureSpace */: - case 8200 /* punctuationSpace */: - case 8201 /* thinSpace */: - case 8202 /* hairSpace */: - case 8203 /* zeroWidthSpace */: - case 8239 /* narrowNoBreakSpace */: - case 12288 /* ideographicSpace */: - - case 9 /* tab */: - case 11 /* verticalTab */: - case 12 /* formFeed */: - case 65279 /* byteOrderMark */: - trivia.push(this.scanWhitespaceTrivia()); - continue; - - case 47 /* slash */: - var ch2 = this.slidingWindow.peekItemN(1); - if (ch2 === 47 /* slash */) { - trivia.push(this.scanSingleLineCommentTrivia()); - continue; - } - - if (ch2 === 42 /* asterisk */) { - trivia.push(this.scanMultiLineCommentTrivia()); - continue; - } - - throw TypeScript.Errors.invalidOperation(); - - case 13 /* carriageReturn */: - case 10 /* lineFeed */: - case 8233 /* paragraphSeparator */: - case 8232 /* lineSeparator */: - trivia.push(this.scanLineTerminatorSequenceTrivia(ch)); - - if (!isTrailing) { - continue; - } - - break; - - default: - throw TypeScript.Errors.invalidOperation(); - } - } - - return TypeScript.Syntax.triviaList(trivia); - } - }; - - Scanner.prototype.scanTriviaInfo = function (diagnostics, isTrailing) { - var width = 0; - var hasCommentOrNewLine = 0; - - while (true) { - var ch = this.currentCharCode(); - - switch (ch) { - case 32 /* space */: - case 160 /* nonBreakingSpace */: - case 8192 /* enQuad */: - case 8193 /* emQuad */: - case 8194 /* enSpace */: - case 8195 /* emSpace */: - case 8196 /* threePerEmSpace */: - case 8197 /* fourPerEmSpace */: - case 8198 /* sixPerEmSpace */: - case 8199 /* figureSpace */: - case 8200 /* punctuationSpace */: - case 8201 /* thinSpace */: - case 8202 /* hairSpace */: - case 8203 /* zeroWidthSpace */: - case 8239 /* narrowNoBreakSpace */: - case 12288 /* ideographicSpace */: - - case 9 /* tab */: - case 11 /* verticalTab */: - case 12 /* formFeed */: - case 65279 /* byteOrderMark */: - this.slidingWindow.moveToNextItem(); - width++; - continue; - - case 47 /* slash */: - var ch2 = this.slidingWindow.peekItemN(1); - if (ch2 === 47 /* slash */) { - hasCommentOrNewLine |= 2 /* TriviaCommentMask */; - width += this.scanSingleLineCommentTriviaLength(); - continue; - } - - if (ch2 === 42 /* asterisk */) { - hasCommentOrNewLine |= 2 /* TriviaCommentMask */; - width += this.scanMultiLineCommentTriviaLength(diagnostics); - continue; - } - - break; - - case 13 /* carriageReturn */: - case 10 /* lineFeed */: - case 8233 /* paragraphSeparator */: - case 8232 /* lineSeparator */: - hasCommentOrNewLine |= 1 /* TriviaNewLineMask */; - width += this.scanLineTerminatorSequenceLength(ch); - - if (!isTrailing) { - continue; - } - - break; - } - - return (width << 2 /* TriviaFullWidthShift */) | hasCommentOrNewLine; - } - }; - - Scanner.prototype.isNewLineCharacter = function (ch) { - switch (ch) { - case 13 /* carriageReturn */: - case 10 /* lineFeed */: - case 8233 /* paragraphSeparator */: - case 8232 /* lineSeparator */: - return true; - default: - return false; - } - }; - - Scanner.prototype.scanWhitespaceTrivia = function () { - var absoluteStartIndex = this.slidingWindow.getAndPinAbsoluteIndex(); - - var width = 0; - while (true) { - var ch = this.currentCharCode(); - - switch (ch) { - case 32 /* space */: - case 160 /* nonBreakingSpace */: - case 8192 /* enQuad */: - case 8193 /* emQuad */: - case 8194 /* enSpace */: - case 8195 /* emSpace */: - case 8196 /* threePerEmSpace */: - case 8197 /* fourPerEmSpace */: - case 8198 /* sixPerEmSpace */: - case 8199 /* figureSpace */: - case 8200 /* punctuationSpace */: - case 8201 /* thinSpace */: - case 8202 /* hairSpace */: - case 8203 /* zeroWidthSpace */: - case 8239 /* narrowNoBreakSpace */: - case 12288 /* ideographicSpace */: - - case 9 /* tab */: - case 11 /* verticalTab */: - case 12 /* formFeed */: - case 65279 /* byteOrderMark */: - this.slidingWindow.moveToNextItem(); - width++; - continue; - } - - break; - } - - var text = this.substring(absoluteStartIndex, absoluteStartIndex + width, false); - this.slidingWindow.releaseAndUnpinAbsoluteIndex(absoluteStartIndex); - - return TypeScript.Syntax.whitespace(text); - }; - - Scanner.prototype.scanSingleLineCommentTrivia = function () { - var absoluteStartIndex = this.slidingWindow.getAndPinAbsoluteIndex(); - var width = this.scanSingleLineCommentTriviaLength(); - - var text = this.substring(absoluteStartIndex, absoluteStartIndex + width, false); - this.slidingWindow.releaseAndUnpinAbsoluteIndex(absoluteStartIndex); - - return TypeScript.Syntax.singleLineComment(text); - }; - - Scanner.prototype.scanSingleLineCommentTriviaLength = function () { - this.slidingWindow.moveToNextItem(); - this.slidingWindow.moveToNextItem(); - - var width = 2; - while (true) { - if (this.slidingWindow.isAtEndOfSource() || this.isNewLineCharacter(this.currentCharCode())) { - return width; - } - - this.slidingWindow.moveToNextItem(); - width++; - } - }; - - Scanner.prototype.scanMultiLineCommentTrivia = function () { - var absoluteStartIndex = this.slidingWindow.getAndPinAbsoluteIndex(); - var width = this.scanMultiLineCommentTriviaLength(null); - - var text = this.substring(absoluteStartIndex, absoluteStartIndex + width, false); - this.slidingWindow.releaseAndUnpinAbsoluteIndex(absoluteStartIndex); - - return TypeScript.Syntax.multiLineComment(text); - }; - - Scanner.prototype.scanMultiLineCommentTriviaLength = function (diagnostics) { - this.slidingWindow.moveToNextItem(); - this.slidingWindow.moveToNextItem(); - - var width = 2; - while (true) { - if (this.slidingWindow.isAtEndOfSource()) { - if (diagnostics !== null) { - diagnostics.push(new TypeScript.SyntaxDiagnostic(this.fileName, this.slidingWindow.absoluteIndex(), 0, 14 /* _StarSlash__expected */, null)); - } - - return width; - } - - var ch = this.currentCharCode(); - if (ch === 42 /* asterisk */ && this.slidingWindow.peekItemN(1) === 47 /* slash */) { - this.slidingWindow.moveToNextItem(); - this.slidingWindow.moveToNextItem(); - width += 2; - return width; - } - - this.slidingWindow.moveToNextItem(); - width++; - } - }; - - Scanner.prototype.scanLineTerminatorSequenceTrivia = function (ch) { - var absoluteStartIndex = this.slidingWindow.getAndPinAbsoluteIndex(); - var width = this.scanLineTerminatorSequenceLength(ch); - - var text = this.substring(absoluteStartIndex, absoluteStartIndex + width, false); - this.slidingWindow.releaseAndUnpinAbsoluteIndex(absoluteStartIndex); - - return TypeScript.Syntax.trivia(5 /* NewLineTrivia */, text); - }; - - Scanner.prototype.scanLineTerminatorSequenceLength = function (ch) { - this.slidingWindow.moveToNextItem(); - - if (ch === 13 /* carriageReturn */ && this.currentCharCode() === 10 /* lineFeed */) { - this.slidingWindow.moveToNextItem(); - return 2; - } else { - return 1; - } - }; - - Scanner.prototype.scanSyntaxToken = function (diagnostics, allowRegularExpression) { - if (this.slidingWindow.isAtEndOfSource()) { - return 10 /* EndOfFileToken */; - } - - var character = this.currentCharCode(); - - switch (character) { - case 34 /* doubleQuote */: - case 39 /* singleQuote */: - return this.scanStringLiteral(diagnostics); - - case 47 /* slash */: - return this.scanSlashToken(allowRegularExpression); - - case 46 /* dot */: - return this.scanDotToken(); - - case 45 /* minus */: - return this.scanMinusToken(); - - case 33 /* exclamation */: - return this.scanExclamationToken(); - - case 61 /* equals */: - return this.scanEqualsToken(); - - case 124 /* bar */: - return this.scanBarToken(); - - case 42 /* asterisk */: - return this.scanAsteriskToken(); - - case 43 /* plus */: - return this.scanPlusToken(); - - case 37 /* percent */: - return this.scanPercentToken(); - - case 38 /* ampersand */: - return this.scanAmpersandToken(); - - case 94 /* caret */: - return this.scanCaretToken(); - - case 60 /* lessThan */: - return this.scanLessThanToken(); - - case 62 /* greaterThan */: - return this.advanceAndSetTokenKind(82 /* GreaterThanToken */); - - case 44 /* comma */: - return this.advanceAndSetTokenKind(80 /* CommaToken */); - - case 58 /* colon */: - return this.advanceAndSetTokenKind(107 /* ColonToken */); - - case 59 /* semicolon */: - return this.advanceAndSetTokenKind(79 /* SemicolonToken */); - - case 126 /* tilde */: - return this.advanceAndSetTokenKind(103 /* TildeToken */); - - case 40 /* openParen */: - return this.advanceAndSetTokenKind(73 /* OpenParenToken */); - - case 41 /* closeParen */: - return this.advanceAndSetTokenKind(74 /* CloseParenToken */); - - case 123 /* openBrace */: - return this.advanceAndSetTokenKind(71 /* OpenBraceToken */); - - case 125 /* closeBrace */: - return this.advanceAndSetTokenKind(72 /* CloseBraceToken */); - - case 91 /* openBracket */: - return this.advanceAndSetTokenKind(75 /* OpenBracketToken */); - - case 93 /* closeBracket */: - return this.advanceAndSetTokenKind(76 /* CloseBracketToken */); - - case 63 /* question */: - return this.advanceAndSetTokenKind(106 /* QuestionToken */); - } - - if (Scanner.isNumericLiteralStart[character]) { - return this.scanNumericLiteral(); - } - - if (Scanner.isIdentifierStartCharacter[character]) { - var result = this.tryFastScanIdentifierOrKeyword(character); - if (result !== 0 /* None */) { - return result; - } - } - - if (this.isIdentifierStart(this.peekCharOrUnicodeEscape())) { - return this.slowScanIdentifier(diagnostics); - } - - return this.scanDefaultCharacter(character, diagnostics); - }; - - Scanner.prototype.isIdentifierStart = function (interpretedChar) { - if (Scanner.isIdentifierStartCharacter[interpretedChar]) { - return true; - } - - return interpretedChar > 127 /* maxAsciiCharacter */ && TypeScript.Unicode.isIdentifierStart(interpretedChar, this._languageVersion); - }; - - Scanner.prototype.isIdentifierPart = function (interpretedChar) { - if (Scanner.isIdentifierPartCharacter[interpretedChar]) { - return true; - } - - return interpretedChar > 127 /* maxAsciiCharacter */ && TypeScript.Unicode.isIdentifierPart(interpretedChar, this._languageVersion); - }; - - Scanner.prototype.tryFastScanIdentifierOrKeyword = function (firstCharacter) { - var startIndex = this.slidingWindow.getAndPinAbsoluteIndex(); - - while (true) { - var character = this.currentCharCode(); - if (Scanner.isIdentifierPartCharacter[character]) { - this.slidingWindow.moveToNextItem(); - } else if (character === 92 /* backslash */ || character > 127 /* maxAsciiCharacter */) { - this.slidingWindow.rewindToPinnedIndex(startIndex); - this.slidingWindow.releaseAndUnpinAbsoluteIndex(startIndex); - return 0 /* None */; - } else { - var endIndex = this.slidingWindow.absoluteIndex(); - - var kind; - if (Scanner.isKeywordStartCharacter[firstCharacter]) { - var offset = startIndex - this.slidingWindow.windowAbsoluteStartIndex; - kind = TypeScript.ScannerUtilities.identifierKind(this.slidingWindow.window, offset, endIndex - startIndex); - } else { - kind = 11 /* IdentifierName */; - } - - this.slidingWindow.releaseAndUnpinAbsoluteIndex(startIndex); - return kind; - } - } - }; - - Scanner.prototype.slowScanIdentifier = function (diagnostics) { - var startIndex = this.slidingWindow.absoluteIndex(); - - do { - this.scanCharOrUnicodeEscape(diagnostics); - } while(this.isIdentifierPart(this.peekCharOrUnicodeEscape())); - - return 11 /* IdentifierName */; - }; - - Scanner.prototype.scanNumericLiteral = function () { - if (this.isHexNumericLiteral()) { - return this.scanHexNumericLiteral(); - } else { - return this.scanDecimalNumericLiteral(); - } - }; - - Scanner.prototype.scanDecimalNumericLiteral = function () { - while (TypeScript.CharacterInfo.isDecimalDigit(this.currentCharCode())) { - this.slidingWindow.moveToNextItem(); - } - - if (this.currentCharCode() === 46 /* dot */) { - this.slidingWindow.moveToNextItem(); - } - - while (TypeScript.CharacterInfo.isDecimalDigit(this.currentCharCode())) { - this.slidingWindow.moveToNextItem(); - } - - var ch = this.currentCharCode(); - if (ch === 101 /* e */ || ch === 69 /* E */) { - this.slidingWindow.moveToNextItem(); - - ch = this.currentCharCode(); - if (ch === 45 /* minus */ || ch === 43 /* plus */) { - if (TypeScript.CharacterInfo.isDecimalDigit(this.slidingWindow.peekItemN(1))) { - this.slidingWindow.moveToNextItem(); - } - } - } - - while (TypeScript.CharacterInfo.isDecimalDigit(this.currentCharCode())) { - this.slidingWindow.moveToNextItem(); - } - - return 13 /* NumericLiteral */; - }; - - Scanner.prototype.scanHexNumericLiteral = function () { - this.slidingWindow.moveToNextItem(); - this.slidingWindow.moveToNextItem(); - - while (TypeScript.CharacterInfo.isHexDigit(this.currentCharCode())) { - this.slidingWindow.moveToNextItem(); - } - - return 13 /* NumericLiteral */; - }; - - Scanner.prototype.isHexNumericLiteral = function () { - if (this.currentCharCode() === 48 /* _0 */) { - var ch = this.slidingWindow.peekItemN(1); - - if (ch === 120 /* x */ || ch === 88 /* X */) { - ch = this.slidingWindow.peekItemN(2); - - return TypeScript.CharacterInfo.isHexDigit(ch); - } - } - - return false; - }; - - Scanner.prototype.advanceAndSetTokenKind = function (kind) { - this.slidingWindow.moveToNextItem(); - return kind; - }; - - Scanner.prototype.scanLessThanToken = function () { - this.slidingWindow.moveToNextItem(); - if (this.currentCharCode() === 61 /* equals */) { - this.slidingWindow.moveToNextItem(); - return 83 /* LessThanEqualsToken */; - } else if (this.currentCharCode() === 60 /* lessThan */) { - this.slidingWindow.moveToNextItem(); - if (this.currentCharCode() === 61 /* equals */) { - this.slidingWindow.moveToNextItem(); - return 113 /* LessThanLessThanEqualsToken */; - } else { - return 96 /* LessThanLessThanToken */; - } - } else { - return 81 /* LessThanToken */; - } - }; - - Scanner.prototype.scanBarToken = function () { - this.slidingWindow.moveToNextItem(); - if (this.currentCharCode() === 61 /* equals */) { - this.slidingWindow.moveToNextItem(); - return 117 /* BarEqualsToken */; - } else if (this.currentCharCode() === 124 /* bar */) { - this.slidingWindow.moveToNextItem(); - return 105 /* BarBarToken */; - } else { - return 100 /* BarToken */; - } - }; - - Scanner.prototype.scanCaretToken = function () { - this.slidingWindow.moveToNextItem(); - if (this.currentCharCode() === 61 /* equals */) { - this.slidingWindow.moveToNextItem(); - return 118 /* CaretEqualsToken */; - } else { - return 101 /* CaretToken */; - } - }; - - Scanner.prototype.scanAmpersandToken = function () { - this.slidingWindow.moveToNextItem(); - var character = this.currentCharCode(); - if (character === 61 /* equals */) { - this.slidingWindow.moveToNextItem(); - return 116 /* AmpersandEqualsToken */; - } else if (this.currentCharCode() === 38 /* ampersand */) { - this.slidingWindow.moveToNextItem(); - return 104 /* AmpersandAmpersandToken */; - } else { - return 99 /* AmpersandToken */; - } - }; - - Scanner.prototype.scanPercentToken = function () { - this.slidingWindow.moveToNextItem(); - if (this.currentCharCode() === 61 /* equals */) { - this.slidingWindow.moveToNextItem(); - return 112 /* PercentEqualsToken */; - } else { - return 93 /* PercentToken */; - } - }; - - Scanner.prototype.scanMinusToken = function () { - this.slidingWindow.moveToNextItem(); - var character = this.currentCharCode(); - - if (character === 61 /* equals */) { - this.slidingWindow.moveToNextItem(); - return 110 /* MinusEqualsToken */; - } else if (character === 45 /* minus */) { - this.slidingWindow.moveToNextItem(); - return 95 /* MinusMinusToken */; - } else { - return 91 /* MinusToken */; - } - }; - - Scanner.prototype.scanPlusToken = function () { - this.slidingWindow.moveToNextItem(); - var character = this.currentCharCode(); - if (character === 61 /* equals */) { - this.slidingWindow.moveToNextItem(); - return 109 /* PlusEqualsToken */; - } else if (character === 43 /* plus */) { - this.slidingWindow.moveToNextItem(); - return 94 /* PlusPlusToken */; - } else { - return 90 /* PlusToken */; - } - }; - - Scanner.prototype.scanAsteriskToken = function () { - this.slidingWindow.moveToNextItem(); - if (this.currentCharCode() === 61 /* equals */) { - this.slidingWindow.moveToNextItem(); - return 111 /* AsteriskEqualsToken */; - } else { - return 92 /* AsteriskToken */; - } - }; - - Scanner.prototype.scanEqualsToken = function () { - this.slidingWindow.moveToNextItem(); - var character = this.currentCharCode(); - if (character === 61 /* equals */) { - this.slidingWindow.moveToNextItem(); - - if (this.currentCharCode() === 61 /* equals */) { - this.slidingWindow.moveToNextItem(); - - return 88 /* EqualsEqualsEqualsToken */; - } else { - return 85 /* EqualsEqualsToken */; - } - } else if (character === 62 /* greaterThan */) { - this.slidingWindow.moveToNextItem(); - return 86 /* EqualsGreaterThanToken */; - } else { - return 108 /* EqualsToken */; - } - }; - - Scanner.prototype.isDotPrefixedNumericLiteral = function () { - if (this.currentCharCode() === 46 /* dot */) { - var ch = this.slidingWindow.peekItemN(1); - return TypeScript.CharacterInfo.isDecimalDigit(ch); - } - - return false; - }; - - Scanner.prototype.scanDotToken = function () { - if (this.isDotPrefixedNumericLiteral()) { - return this.scanNumericLiteral(); - } - - this.slidingWindow.moveToNextItem(); - if (this.currentCharCode() === 46 /* dot */ && this.slidingWindow.peekItemN(1) === 46 /* dot */) { - this.slidingWindow.moveToNextItem(); - this.slidingWindow.moveToNextItem(); - return 78 /* DotDotDotToken */; - } else { - return 77 /* DotToken */; - } - }; - - Scanner.prototype.scanSlashToken = function (allowRegularExpression) { - if (allowRegularExpression) { - var result = this.tryScanRegularExpressionToken(); - if (result !== 0 /* None */) { - return result; - } - } - - this.slidingWindow.moveToNextItem(); - if (this.currentCharCode() === 61 /* equals */) { - this.slidingWindow.moveToNextItem(); - return 120 /* SlashEqualsToken */; - } else { - return 119 /* SlashToken */; - } - }; - - Scanner.prototype.tryScanRegularExpressionToken = function () { - var startIndex = this.slidingWindow.getAndPinAbsoluteIndex(); - try { - this.slidingWindow.moveToNextItem(); - - var inEscape = false; - var inCharacterClass = false; - while (true) { - var ch = this.currentCharCode(); - if (this.isNewLineCharacter(ch) || this.slidingWindow.isAtEndOfSource()) { - this.slidingWindow.rewindToPinnedIndex(startIndex); - return 0 /* None */; - } - - this.slidingWindow.moveToNextItem(); - if (inEscape) { - inEscape = false; - continue; - } - - switch (ch) { - case 92 /* backslash */: - inEscape = true; - continue; - - case 91 /* openBracket */: - inCharacterClass = true; - continue; - - case 93 /* closeBracket */: - inCharacterClass = false; - continue; - - case 47 /* slash */: - if (inCharacterClass) { - continue; - } - - break; - - default: - continue; - } - - break; - } - - while (Scanner.isIdentifierPartCharacter[this.currentCharCode()]) { - this.slidingWindow.moveToNextItem(); - } - - return 12 /* RegularExpressionLiteral */; - } finally { - this.slidingWindow.releaseAndUnpinAbsoluteIndex(startIndex); - } - }; - - Scanner.prototype.scanExclamationToken = function () { - this.slidingWindow.moveToNextItem(); - if (this.currentCharCode() === 61 /* equals */) { - this.slidingWindow.moveToNextItem(); - - if (this.currentCharCode() === 61 /* equals */) { - this.slidingWindow.moveToNextItem(); - - return 89 /* ExclamationEqualsEqualsToken */; - } else { - return 87 /* ExclamationEqualsToken */; - } - } else { - return 102 /* ExclamationToken */; - } - }; - - Scanner.prototype.scanDefaultCharacter = function (character, diagnostics) { - var position = this.slidingWindow.absoluteIndex(); - this.slidingWindow.moveToNextItem(); - - var text = String.fromCharCode(character); - var messageText = this.getErrorMessageText(text); - diagnostics.push(new TypeScript.SyntaxDiagnostic(this.fileName, position, 1, 5 /* Unexpected_character_0 */, [messageText])); - - return 9 /* ErrorToken */; - }; - - Scanner.prototype.getErrorMessageText = function (text) { - if (text === "\\") { - return '"\\"'; - } - - return JSON.stringify(text); - }; - - Scanner.prototype.skipEscapeSequence = function (diagnostics) { - var rewindPoint = this.slidingWindow.getAndPinAbsoluteIndex(); - try { - this.slidingWindow.moveToNextItem(); - - var ch = this.currentCharCode(); - this.slidingWindow.moveToNextItem(); - switch (ch) { - case 120 /* x */: - case 117 /* u */: - this.slidingWindow.rewindToPinnedIndex(rewindPoint); - var value = this.scanUnicodeOrHexEscape(diagnostics); - return; - - case 13 /* carriageReturn */: - if (this.currentCharCode() === 10 /* lineFeed */) { - this.slidingWindow.moveToNextItem(); - } - return; - - default: - return; - } - } finally { - this.slidingWindow.releaseAndUnpinAbsoluteIndex(rewindPoint); - } - }; - - Scanner.prototype.scanStringLiteral = function (diagnostics) { - var quoteCharacter = this.currentCharCode(); - - this.slidingWindow.moveToNextItem(); - - while (true) { - var ch = this.currentCharCode(); - if (ch === 92 /* backslash */) { - this.skipEscapeSequence(diagnostics); - } else if (ch === quoteCharacter) { - this.slidingWindow.moveToNextItem(); - break; - } else if (this.isNewLineCharacter(ch) || this.slidingWindow.isAtEndOfSource()) { - diagnostics.push(new TypeScript.SyntaxDiagnostic(this.fileName, this.slidingWindow.absoluteIndex(), 1, 6 /* Missing_closing_quote_character */, null)); - break; - } else { - this.slidingWindow.moveToNextItem(); - } - } - - return 14 /* StringLiteral */; - }; - - Scanner.prototype.isUnicodeOrHexEscape = function (character) { - return this.isUnicodeEscape(character) || this.isHexEscape(character); - }; - - Scanner.prototype.isUnicodeEscape = function (character) { - if (character === 92 /* backslash */) { - var ch2 = this.slidingWindow.peekItemN(1); - if (ch2 === 117 /* u */) { - return true; - } - } - - return false; - }; - - Scanner.prototype.isHexEscape = function (character) { - if (character === 92 /* backslash */) { - var ch2 = this.slidingWindow.peekItemN(1); - if (ch2 === 120 /* x */) { - return true; - } - } - - return false; - }; - - Scanner.prototype.peekCharOrUnicodeOrHexEscape = function () { - var character = this.currentCharCode(); - if (this.isUnicodeOrHexEscape(character)) { - return this.peekUnicodeOrHexEscape(); - } else { - return character; - } - }; - - Scanner.prototype.peekCharOrUnicodeEscape = function () { - var character = this.currentCharCode(); - if (this.isUnicodeEscape(character)) { - return this.peekUnicodeOrHexEscape(); - } else { - return character; - } - }; - - Scanner.prototype.peekUnicodeOrHexEscape = function () { - var startIndex = this.slidingWindow.getAndPinAbsoluteIndex(); - - var ch = this.scanUnicodeOrHexEscape(null); - - this.slidingWindow.rewindToPinnedIndex(startIndex); - this.slidingWindow.releaseAndUnpinAbsoluteIndex(startIndex); - - return ch; - }; - - Scanner.prototype.scanCharOrUnicodeEscape = function (errors) { - var ch = this.currentCharCode(); - if (ch === 92 /* backslash */) { - var ch2 = this.slidingWindow.peekItemN(1); - if (ch2 === 117 /* u */) { - return this.scanUnicodeOrHexEscape(errors); - } - } - - this.slidingWindow.moveToNextItem(); - return ch; - }; - - Scanner.prototype.scanCharOrUnicodeOrHexEscape = function (errors) { - var ch = this.currentCharCode(); - if (ch === 92 /* backslash */) { - var ch2 = this.slidingWindow.peekItemN(1); - if (ch2 === 117 /* u */ || ch2 === 120 /* x */) { - return this.scanUnicodeOrHexEscape(errors); - } - } - - this.slidingWindow.moveToNextItem(); - return ch; - }; - - Scanner.prototype.scanUnicodeOrHexEscape = function (errors) { - var start = this.slidingWindow.absoluteIndex(); - var character = this.currentCharCode(); - - this.slidingWindow.moveToNextItem(); - - character = this.currentCharCode(); - - var intChar = 0; - this.slidingWindow.moveToNextItem(); - - var count = character === 117 /* u */ ? 4 : 2; - - for (var i = 0; i < count; i++) { - var ch2 = this.currentCharCode(); - if (!TypeScript.CharacterInfo.isHexDigit(ch2)) { - if (errors !== null) { - var end = this.slidingWindow.absoluteIndex(); - var info = this.createIllegalEscapeDiagnostic(start, end); - errors.push(info); - } - - break; - } - - intChar = (intChar << 4) + TypeScript.CharacterInfo.hexValue(ch2); - this.slidingWindow.moveToNextItem(); - } - - return intChar; - }; - - Scanner.prototype.substring = function (start, end, intern) { - var length = end - start; - var offset = start - this.slidingWindow.windowAbsoluteStartIndex; - - if (intern) { - return TypeScript.Collections.DefaultStringTable.addCharArray(this.slidingWindow.window, offset, length); - } else { - return TypeScript.StringUtilities.fromCharCodeArray(this.slidingWindow.window.slice(offset, offset + length)); - } - }; - - Scanner.prototype.createIllegalEscapeDiagnostic = function (start, end) { - return new TypeScript.SyntaxDiagnostic(this.fileName, start, end - start, 4 /* Unrecognized_escape_sequence */, null); - }; - - Scanner.isValidIdentifier = function (text, languageVersion) { - var scanner = new Scanner(null, text, TypeScript.LanguageVersion, Scanner.triviaWindow); - var errors = []; - var token = scanner.scan(errors, false); - - return errors.length === 0 && TypeScript.SyntaxFacts.isIdentifierNameOrAnyKeyword(token) && token.width() === text.length(); - }; - Scanner.isKeywordStartCharacter = []; - Scanner.isIdentifierStartCharacter = []; - Scanner.isIdentifierPartCharacter = []; - Scanner.isNumericLiteralStart = []; - - Scanner.triviaWindow = TypeScript.ArrayUtilities.createArray(2048, 0); - return Scanner; - })(); - TypeScript.Scanner = Scanner; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var ScannerUtilities = (function () { - function ScannerUtilities() { - } - ScannerUtilities.identifierKind = function (array, startIndex, length) { - switch (length) { - case 2: - switch (array[startIndex]) { - case 100 /* d */: - return (array[startIndex + 1] === 111 /* o */) ? 22 /* DoKeyword */ : 11 /* IdentifierName */; - case 105 /* i */: - switch (array[startIndex + 1]) { - case 102 /* f */: - return 28 /* IfKeyword */; - case 110 /* n */: - return 29 /* InKeyword */; - default: - return 11 /* IdentifierName */; - } - - default: - return 11 /* IdentifierName */; - } - - case 3: - switch (array[startIndex]) { - case 102 /* f */: - return (array[startIndex + 1] === 111 /* o */ && array[startIndex + 2] === 114 /* r */) ? 26 /* ForKeyword */ : 11 /* IdentifierName */; - case 110 /* n */: - return (array[startIndex + 1] === 101 /* e */ && array[startIndex + 2] === 119 /* w */) ? 31 /* NewKeyword */ : 11 /* IdentifierName */; - case 116 /* t */: - return (array[startIndex + 1] === 114 /* r */ && array[startIndex + 2] === 121 /* y */) ? 38 /* TryKeyword */ : 11 /* IdentifierName */; - case 118 /* v */: - return (array[startIndex + 1] === 97 /* a */ && array[startIndex + 2] === 114 /* r */) ? 40 /* VarKeyword */ : 11 /* IdentifierName */; - case 108 /* l */: - return (array[startIndex + 1] === 101 /* e */ && array[startIndex + 2] === 116 /* t */) ? 53 /* LetKeyword */ : 11 /* IdentifierName */; - case 97 /* a */: - return (array[startIndex + 1] === 110 /* n */ && array[startIndex + 2] === 121 /* y */) ? 60 /* AnyKeyword */ : 11 /* IdentifierName */; - case 103 /* g */: - return (array[startIndex + 1] === 101 /* e */ && array[startIndex + 2] === 116 /* t */) ? 65 /* GetKeyword */ : 11 /* IdentifierName */; - case 115 /* s */: - return (array[startIndex + 1] === 101 /* e */ && array[startIndex + 2] === 116 /* t */) ? 69 /* SetKeyword */ : 11 /* IdentifierName */; - default: - return 11 /* IdentifierName */; - } - - case 4: - switch (array[startIndex]) { - case 99 /* c */: - return (array[startIndex + 1] === 97 /* a */ && array[startIndex + 2] === 115 /* s */ && array[startIndex + 3] === 101 /* e */) ? 16 /* CaseKeyword */ : 11 /* IdentifierName */; - case 101 /* e */: - switch (array[startIndex + 1]) { - case 108 /* l */: - return (array[startIndex + 2] === 115 /* s */ && array[startIndex + 3] === 101 /* e */) ? 23 /* ElseKeyword */ : 11 /* IdentifierName */; - case 110 /* n */: - return (array[startIndex + 2] === 117 /* u */ && array[startIndex + 3] === 109 /* m */) ? 46 /* EnumKeyword */ : 11 /* IdentifierName */; - default: - return 11 /* IdentifierName */; - } - - case 110 /* n */: - return (array[startIndex + 1] === 117 /* u */ && array[startIndex + 2] === 108 /* l */ && array[startIndex + 3] === 108 /* l */) ? 32 /* NullKeyword */ : 11 /* IdentifierName */; - case 116 /* t */: - switch (array[startIndex + 1]) { - case 104 /* h */: - return (array[startIndex + 2] === 105 /* i */ && array[startIndex + 3] === 115 /* s */) ? 35 /* ThisKeyword */ : 11 /* IdentifierName */; - case 114 /* r */: - return (array[startIndex + 2] === 117 /* u */ && array[startIndex + 3] === 101 /* e */) ? 37 /* TrueKeyword */ : 11 /* IdentifierName */; - default: - return 11 /* IdentifierName */; - } - - case 118 /* v */: - return (array[startIndex + 1] === 111 /* o */ && array[startIndex + 2] === 105 /* i */ && array[startIndex + 3] === 100 /* d */) ? 41 /* VoidKeyword */ : 11 /* IdentifierName */; - case 119 /* w */: - return (array[startIndex + 1] === 105 /* i */ && array[startIndex + 2] === 116 /* t */ && array[startIndex + 3] === 104 /* h */) ? 43 /* WithKeyword */ : 11 /* IdentifierName */; - case 98 /* b */: - return (array[startIndex + 1] === 111 /* o */ && array[startIndex + 2] === 111 /* o */ && array[startIndex + 3] === 108 /* l */) ? 62 /* BoolKeyword */ : 11 /* IdentifierName */; - default: - return 11 /* IdentifierName */; - } - - case 5: - switch (array[startIndex]) { - case 98 /* b */: - return (array[startIndex + 1] === 114 /* r */ && array[startIndex + 2] === 101 /* e */ && array[startIndex + 3] === 97 /* a */ && array[startIndex + 4] === 107 /* k */) ? 15 /* BreakKeyword */ : 11 /* IdentifierName */; - case 99 /* c */: - switch (array[startIndex + 1]) { - case 97 /* a */: - return (array[startIndex + 2] === 116 /* t */ && array[startIndex + 3] === 99 /* c */ && array[startIndex + 4] === 104 /* h */) ? 17 /* CatchKeyword */ : 11 /* IdentifierName */; - case 108 /* l */: - return (array[startIndex + 2] === 97 /* a */ && array[startIndex + 3] === 115 /* s */ && array[startIndex + 4] === 115 /* s */) ? 44 /* ClassKeyword */ : 11 /* IdentifierName */; - case 111 /* o */: - return (array[startIndex + 2] === 110 /* n */ && array[startIndex + 3] === 115 /* s */ && array[startIndex + 4] === 116 /* t */) ? 45 /* ConstKeyword */ : 11 /* IdentifierName */; - default: - return 11 /* IdentifierName */; - } - - case 102 /* f */: - return (array[startIndex + 1] === 97 /* a */ && array[startIndex + 2] === 108 /* l */ && array[startIndex + 3] === 115 /* s */ && array[startIndex + 4] === 101 /* e */) ? 24 /* FalseKeyword */ : 11 /* IdentifierName */; - case 116 /* t */: - return (array[startIndex + 1] === 104 /* h */ && array[startIndex + 2] === 114 /* r */ && array[startIndex + 3] === 111 /* o */ && array[startIndex + 4] === 119 /* w */) ? 36 /* ThrowKeyword */ : 11 /* IdentifierName */; - case 119 /* w */: - return (array[startIndex + 1] === 104 /* h */ && array[startIndex + 2] === 105 /* i */ && array[startIndex + 3] === 108 /* l */ && array[startIndex + 4] === 101 /* e */) ? 42 /* WhileKeyword */ : 11 /* IdentifierName */; - case 115 /* s */: - return (array[startIndex + 1] === 117 /* u */ && array[startIndex + 2] === 112 /* p */ && array[startIndex + 3] === 101 /* e */ && array[startIndex + 4] === 114 /* r */) ? 50 /* SuperKeyword */ : 11 /* IdentifierName */; - case 121 /* y */: - return (array[startIndex + 1] === 105 /* i */ && array[startIndex + 2] === 101 /* e */ && array[startIndex + 3] === 108 /* l */ && array[startIndex + 4] === 100 /* d */) ? 59 /* YieldKeyword */ : 11 /* IdentifierName */; - default: - return 11 /* IdentifierName */; - } - - case 6: - switch (array[startIndex]) { - case 100 /* d */: - return (array[startIndex + 1] === 101 /* e */ && array[startIndex + 2] === 108 /* l */ && array[startIndex + 3] === 101 /* e */ && array[startIndex + 4] === 116 /* t */ && array[startIndex + 5] === 101 /* e */) ? 21 /* DeleteKeyword */ : 11 /* IdentifierName */; - case 114 /* r */: - return (array[startIndex + 1] === 101 /* e */ && array[startIndex + 2] === 116 /* t */ && array[startIndex + 3] === 117 /* u */ && array[startIndex + 4] === 114 /* r */ && array[startIndex + 5] === 110 /* n */) ? 33 /* ReturnKeyword */ : 11 /* IdentifierName */; - case 115 /* s */: - switch (array[startIndex + 1]) { - case 119 /* w */: - return (array[startIndex + 2] === 105 /* i */ && array[startIndex + 3] === 116 /* t */ && array[startIndex + 4] === 99 /* c */ && array[startIndex + 5] === 104 /* h */) ? 34 /* SwitchKeyword */ : 11 /* IdentifierName */; - case 116 /* t */: - switch (array[startIndex + 2]) { - case 97 /* a */: - return (array[startIndex + 3] === 116 /* t */ && array[startIndex + 4] === 105 /* i */ && array[startIndex + 5] === 99 /* c */) ? 58 /* StaticKeyword */ : 11 /* IdentifierName */; - case 114 /* r */: - return (array[startIndex + 3] === 105 /* i */ && array[startIndex + 4] === 110 /* n */ && array[startIndex + 5] === 103 /* g */) ? 70 /* StringKeyword */ : 11 /* IdentifierName */; - default: - return 11 /* IdentifierName */; - } - - default: - return 11 /* IdentifierName */; - } - - case 116 /* t */: - return (array[startIndex + 1] === 121 /* y */ && array[startIndex + 2] === 112 /* p */ && array[startIndex + 3] === 101 /* e */ && array[startIndex + 4] === 111 /* o */ && array[startIndex + 5] === 102 /* f */) ? 39 /* TypeOfKeyword */ : 11 /* IdentifierName */; - case 101 /* e */: - return (array[startIndex + 1] === 120 /* x */ && array[startIndex + 2] === 112 /* p */ && array[startIndex + 3] === 111 /* o */ && array[startIndex + 4] === 114 /* r */ && array[startIndex + 5] === 116 /* t */) ? 47 /* ExportKeyword */ : 11 /* IdentifierName */; - case 105 /* i */: - return (array[startIndex + 1] === 109 /* m */ && array[startIndex + 2] === 112 /* p */ && array[startIndex + 3] === 111 /* o */ && array[startIndex + 4] === 114 /* r */ && array[startIndex + 5] === 116 /* t */) ? 49 /* ImportKeyword */ : 11 /* IdentifierName */; - case 112 /* p */: - return (array[startIndex + 1] === 117 /* u */ && array[startIndex + 2] === 98 /* b */ && array[startIndex + 3] === 108 /* l */ && array[startIndex + 4] === 105 /* i */ && array[startIndex + 5] === 99 /* c */) ? 57 /* PublicKeyword */ : 11 /* IdentifierName */; - case 109 /* m */: - return (array[startIndex + 1] === 111 /* o */ && array[startIndex + 2] === 100 /* d */ && array[startIndex + 3] === 117 /* u */ && array[startIndex + 4] === 108 /* l */ && array[startIndex + 5] === 101 /* e */) ? 66 /* ModuleKeyword */ : 11 /* IdentifierName */; - case 110 /* n */: - return (array[startIndex + 1] === 117 /* u */ && array[startIndex + 2] === 109 /* m */ && array[startIndex + 3] === 98 /* b */ && array[startIndex + 4] === 101 /* e */ && array[startIndex + 5] === 114 /* r */) ? 68 /* NumberKeyword */ : 11 /* IdentifierName */; - default: - return 11 /* IdentifierName */; - } - - case 7: - switch (array[startIndex]) { - case 100 /* d */: - switch (array[startIndex + 1]) { - case 101 /* e */: - switch (array[startIndex + 2]) { - case 102 /* f */: - return (array[startIndex + 3] === 97 /* a */ && array[startIndex + 4] === 117 /* u */ && array[startIndex + 5] === 108 /* l */ && array[startIndex + 6] === 116 /* t */) ? 20 /* DefaultKeyword */ : 11 /* IdentifierName */; - case 99 /* c */: - return (array[startIndex + 3] === 108 /* l */ && array[startIndex + 4] === 97 /* a */ && array[startIndex + 5] === 114 /* r */ && array[startIndex + 6] === 101 /* e */) ? 64 /* DeclareKeyword */ : 11 /* IdentifierName */; - default: - return 11 /* IdentifierName */; - } - - default: - return 11 /* IdentifierName */; - } - - case 102 /* f */: - return (array[startIndex + 1] === 105 /* i */ && array[startIndex + 2] === 110 /* n */ && array[startIndex + 3] === 97 /* a */ && array[startIndex + 4] === 108 /* l */ && array[startIndex + 5] === 108 /* l */ && array[startIndex + 6] === 121 /* y */) ? 25 /* FinallyKeyword */ : 11 /* IdentifierName */; - case 101 /* e */: - return (array[startIndex + 1] === 120 /* x */ && array[startIndex + 2] === 116 /* t */ && array[startIndex + 3] === 101 /* e */ && array[startIndex + 4] === 110 /* n */ && array[startIndex + 5] === 100 /* d */ && array[startIndex + 6] === 115 /* s */) ? 48 /* ExtendsKeyword */ : 11 /* IdentifierName */; - case 112 /* p */: - switch (array[startIndex + 1]) { - case 97 /* a */: - return (array[startIndex + 2] === 99 /* c */ && array[startIndex + 3] === 107 /* k */ && array[startIndex + 4] === 97 /* a */ && array[startIndex + 5] === 103 /* g */ && array[startIndex + 6] === 101 /* e */) ? 54 /* PackageKeyword */ : 11 /* IdentifierName */; - case 114 /* r */: - return (array[startIndex + 2] === 105 /* i */ && array[startIndex + 3] === 118 /* v */ && array[startIndex + 4] === 97 /* a */ && array[startIndex + 5] === 116 /* t */ && array[startIndex + 6] === 101 /* e */) ? 55 /* PrivateKeyword */ : 11 /* IdentifierName */; - default: - return 11 /* IdentifierName */; - } - - case 98 /* b */: - return (array[startIndex + 1] === 111 /* o */ && array[startIndex + 2] === 111 /* o */ && array[startIndex + 3] === 108 /* l */ && array[startIndex + 4] === 101 /* e */ && array[startIndex + 5] === 97 /* a */ && array[startIndex + 6] === 110 /* n */) ? 61 /* BooleanKeyword */ : 11 /* IdentifierName */; - case 114 /* r */: - return (array[startIndex + 1] === 101 /* e */ && array[startIndex + 2] === 113 /* q */ && array[startIndex + 3] === 117 /* u */ && array[startIndex + 4] === 105 /* i */ && array[startIndex + 5] === 114 /* r */ && array[startIndex + 6] === 101 /* e */) ? 67 /* RequireKeyword */ : 11 /* IdentifierName */; - default: - return 11 /* IdentifierName */; - } - - case 8: - switch (array[startIndex]) { - case 99 /* c */: - return (array[startIndex + 1] === 111 /* o */ && array[startIndex + 2] === 110 /* n */ && array[startIndex + 3] === 116 /* t */ && array[startIndex + 4] === 105 /* i */ && array[startIndex + 5] === 110 /* n */ && array[startIndex + 6] === 117 /* u */ && array[startIndex + 7] === 101 /* e */) ? 18 /* ContinueKeyword */ : 11 /* IdentifierName */; - case 100 /* d */: - return (array[startIndex + 1] === 101 /* e */ && array[startIndex + 2] === 98 /* b */ && array[startIndex + 3] === 117 /* u */ && array[startIndex + 4] === 103 /* g */ && array[startIndex + 5] === 103 /* g */ && array[startIndex + 6] === 101 /* e */ && array[startIndex + 7] === 114 /* r */) ? 19 /* DebuggerKeyword */ : 11 /* IdentifierName */; - case 102 /* f */: - return (array[startIndex + 1] === 117 /* u */ && array[startIndex + 2] === 110 /* n */ && array[startIndex + 3] === 99 /* c */ && array[startIndex + 4] === 116 /* t */ && array[startIndex + 5] === 105 /* i */ && array[startIndex + 6] === 111 /* o */ && array[startIndex + 7] === 110 /* n */) ? 27 /* FunctionKeyword */ : 11 /* IdentifierName */; - default: - return 11 /* IdentifierName */; - } - - case 9: - switch (array[startIndex]) { - case 105 /* i */: - return (array[startIndex + 1] === 110 /* n */ && array[startIndex + 2] === 116 /* t */ && array[startIndex + 3] === 101 /* e */ && array[startIndex + 4] === 114 /* r */ && array[startIndex + 5] === 102 /* f */ && array[startIndex + 6] === 97 /* a */ && array[startIndex + 7] === 99 /* c */ && array[startIndex + 8] === 101 /* e */) ? 52 /* InterfaceKeyword */ : 11 /* IdentifierName */; - case 112 /* p */: - return (array[startIndex + 1] === 114 /* r */ && array[startIndex + 2] === 111 /* o */ && array[startIndex + 3] === 116 /* t */ && array[startIndex + 4] === 101 /* e */ && array[startIndex + 5] === 99 /* c */ && array[startIndex + 6] === 116 /* t */ && array[startIndex + 7] === 101 /* e */ && array[startIndex + 8] === 100 /* d */) ? 56 /* ProtectedKeyword */ : 11 /* IdentifierName */; - default: - return 11 /* IdentifierName */; - } - - case 10: - switch (array[startIndex]) { - case 105 /* i */: - switch (array[startIndex + 1]) { - case 110 /* n */: - return (array[startIndex + 2] === 115 /* s */ && array[startIndex + 3] === 116 /* t */ && array[startIndex + 4] === 97 /* a */ && array[startIndex + 5] === 110 /* n */ && array[startIndex + 6] === 99 /* c */ && array[startIndex + 7] === 101 /* e */ && array[startIndex + 8] === 111 /* o */ && array[startIndex + 9] === 102 /* f */) ? 30 /* InstanceOfKeyword */ : 11 /* IdentifierName */; - case 109 /* m */: - return (array[startIndex + 2] === 112 /* p */ && array[startIndex + 3] === 108 /* l */ && array[startIndex + 4] === 101 /* e */ && array[startIndex + 5] === 109 /* m */ && array[startIndex + 6] === 101 /* e */ && array[startIndex + 7] === 110 /* n */ && array[startIndex + 8] === 116 /* t */ && array[startIndex + 9] === 115 /* s */) ? 51 /* ImplementsKeyword */ : 11 /* IdentifierName */; - default: - return 11 /* IdentifierName */; - } - - default: - return 11 /* IdentifierName */; - } - - case 11: - return (array[startIndex] === 99 /* c */ && array[startIndex + 1] === 111 /* o */ && array[startIndex + 2] === 110 /* n */ && array[startIndex + 3] === 115 /* s */ && array[startIndex + 4] === 116 /* t */ && array[startIndex + 5] === 114 /* r */ && array[startIndex + 6] === 117 /* u */ && array[startIndex + 7] === 99 /* c */ && array[startIndex + 8] === 116 /* t */ && array[startIndex + 9] === 111 /* o */ && array[startIndex + 10] === 114 /* r */) ? 63 /* ConstructorKeyword */ : 11 /* IdentifierName */; - default: - return 11 /* IdentifierName */; - } - }; - return ScannerUtilities; - })(); - TypeScript.ScannerUtilities = ScannerUtilities; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (Syntax) { - var EmptySeparatedSyntaxList = (function () { - function EmptySeparatedSyntaxList() { - } - EmptySeparatedSyntaxList.prototype.kind = function () { - return 2 /* SeparatedList */; - }; - - EmptySeparatedSyntaxList.prototype.isNode = function () { - return false; - }; - - EmptySeparatedSyntaxList.prototype.isToken = function () { - return false; - }; - - EmptySeparatedSyntaxList.prototype.isList = function () { - return false; - }; - - EmptySeparatedSyntaxList.prototype.isSeparatedList = function () { - return true; - }; - - EmptySeparatedSyntaxList.prototype.toJSON = function (key) { - return []; - }; - - EmptySeparatedSyntaxList.prototype.childCount = function () { - return 0; - }; - - EmptySeparatedSyntaxList.prototype.nonSeparatorCount = function () { - return 0; - }; - - EmptySeparatedSyntaxList.prototype.separatorCount = function () { - return 0; - }; - - EmptySeparatedSyntaxList.prototype.toArray = function () { - return []; - }; - - EmptySeparatedSyntaxList.prototype.toNonSeparatorArray = function () { - return []; - }; - - EmptySeparatedSyntaxList.prototype.childAt = function (index) { - throw TypeScript.Errors.argumentOutOfRange("index"); - }; - - EmptySeparatedSyntaxList.prototype.nonSeparatorAt = function (index) { - throw TypeScript.Errors.argumentOutOfRange("index"); - }; - - EmptySeparatedSyntaxList.prototype.separatorAt = function (index) { - throw TypeScript.Errors.argumentOutOfRange("index"); - }; - - EmptySeparatedSyntaxList.prototype.collectTextElements = function (elements) { - }; - - EmptySeparatedSyntaxList.prototype.firstToken = function () { - return null; - }; - - EmptySeparatedSyntaxList.prototype.lastToken = function () { - return null; - }; - - EmptySeparatedSyntaxList.prototype.fullWidth = function () { - return 0; - }; - - EmptySeparatedSyntaxList.prototype.fullText = function () { - return ""; - }; - - EmptySeparatedSyntaxList.prototype.width = function () { - return 0; - }; - - EmptySeparatedSyntaxList.prototype.isTypeScriptSpecific = function () { - return false; - }; - - EmptySeparatedSyntaxList.prototype.isIncrementallyUnusable = function () { - return false; - }; - - EmptySeparatedSyntaxList.prototype.findTokenInternal = function (parent, position, fullStart) { - throw TypeScript.Errors.invalidOperation(); - }; - - EmptySeparatedSyntaxList.prototype.insertChildrenInto = function (array, index) { - }; - - EmptySeparatedSyntaxList.prototype.leadingTrivia = function () { - return Syntax.emptyTriviaList; - }; - - EmptySeparatedSyntaxList.prototype.trailingTrivia = function () { - return Syntax.emptyTriviaList; - }; - - EmptySeparatedSyntaxList.prototype.leadingTriviaWidth = function () { - return 0; - }; - - EmptySeparatedSyntaxList.prototype.trailingTriviaWidth = function () { - return 0; - }; - return EmptySeparatedSyntaxList; - })(); - - Syntax.emptySeparatedList = new EmptySeparatedSyntaxList(); - - var SingletonSeparatedSyntaxList = (function () { - function SingletonSeparatedSyntaxList(item) { - this.item = item; - } - SingletonSeparatedSyntaxList.prototype.toJSON = function (key) { - return [this.item]; - }; - - SingletonSeparatedSyntaxList.prototype.kind = function () { - return 2 /* SeparatedList */; - }; - - SingletonSeparatedSyntaxList.prototype.isNode = function () { - return false; - }; - SingletonSeparatedSyntaxList.prototype.isToken = function () { - return false; - }; - SingletonSeparatedSyntaxList.prototype.isList = function () { - return false; - }; - SingletonSeparatedSyntaxList.prototype.isSeparatedList = function () { - return true; - }; - - SingletonSeparatedSyntaxList.prototype.childCount = function () { - return 1; - }; - SingletonSeparatedSyntaxList.prototype.nonSeparatorCount = function () { - return 1; - }; - SingletonSeparatedSyntaxList.prototype.separatorCount = function () { - return 0; - }; - - SingletonSeparatedSyntaxList.prototype.toArray = function () { - return [this.item]; - }; - SingletonSeparatedSyntaxList.prototype.toNonSeparatorArray = function () { - return [this.item]; - }; - - SingletonSeparatedSyntaxList.prototype.childAt = function (index) { - if (index !== 0) { - throw TypeScript.Errors.argumentOutOfRange("index"); - } - - return this.item; - }; - - SingletonSeparatedSyntaxList.prototype.nonSeparatorAt = function (index) { - if (index !== 0) { - throw TypeScript.Errors.argumentOutOfRange("index"); - } - - return this.item; - }; - - SingletonSeparatedSyntaxList.prototype.separatorAt = function (index) { - throw TypeScript.Errors.argumentOutOfRange("index"); - }; - - SingletonSeparatedSyntaxList.prototype.collectTextElements = function (elements) { - this.item.collectTextElements(elements); - }; - - SingletonSeparatedSyntaxList.prototype.firstToken = function () { - return this.item.firstToken(); - }; - - SingletonSeparatedSyntaxList.prototype.lastToken = function () { - return this.item.lastToken(); - }; - - SingletonSeparatedSyntaxList.prototype.fullWidth = function () { - return this.item.fullWidth(); - }; - - SingletonSeparatedSyntaxList.prototype.width = function () { - return this.item.width(); - }; - - SingletonSeparatedSyntaxList.prototype.fullText = function () { - return this.item.fullText(); - }; - - SingletonSeparatedSyntaxList.prototype.leadingTrivia = function () { - return this.item.leadingTrivia(); - }; - - SingletonSeparatedSyntaxList.prototype.trailingTrivia = function () { - return this.item.trailingTrivia(); - }; - - SingletonSeparatedSyntaxList.prototype.leadingTriviaWidth = function () { - return this.item.leadingTriviaWidth(); - }; - - SingletonSeparatedSyntaxList.prototype.trailingTriviaWidth = function () { - return this.item.trailingTriviaWidth(); - }; - - SingletonSeparatedSyntaxList.prototype.isTypeScriptSpecific = function () { - return this.item.isTypeScriptSpecific(); - }; - - SingletonSeparatedSyntaxList.prototype.isIncrementallyUnusable = function () { - return this.item.isIncrementallyUnusable(); - }; - - SingletonSeparatedSyntaxList.prototype.findTokenInternal = function (parent, position, fullStart) { - return (this.item).findTokenInternal(new TypeScript.PositionedSeparatedList(parent, this, fullStart), position, fullStart); - }; - - SingletonSeparatedSyntaxList.prototype.insertChildrenInto = function (array, index) { - array.splice(index, 0, this.item); - }; - return SingletonSeparatedSyntaxList; - })(); - - var NormalSeparatedSyntaxList = (function () { - function NormalSeparatedSyntaxList(elements) { - this._data = 0; - this.elements = elements; - } - NormalSeparatedSyntaxList.prototype.kind = function () { - return 2 /* SeparatedList */; - }; - - NormalSeparatedSyntaxList.prototype.isToken = function () { - return false; - }; - NormalSeparatedSyntaxList.prototype.isNode = function () { - return false; - }; - NormalSeparatedSyntaxList.prototype.isList = function () { - return false; - }; - NormalSeparatedSyntaxList.prototype.isSeparatedList = function () { - return true; - }; - NormalSeparatedSyntaxList.prototype.toJSON = function (key) { - return this.elements; - }; - - NormalSeparatedSyntaxList.prototype.childCount = function () { - return this.elements.length; - }; - NormalSeparatedSyntaxList.prototype.nonSeparatorCount = function () { - return TypeScript.IntegerUtilities.integerDivide(this.elements.length + 1, 2); - }; - NormalSeparatedSyntaxList.prototype.separatorCount = function () { - return TypeScript.IntegerUtilities.integerDivide(this.elements.length, 2); - }; - - NormalSeparatedSyntaxList.prototype.toArray = function () { - return this.elements.slice(0); - }; - - NormalSeparatedSyntaxList.prototype.toNonSeparatorArray = function () { - var result = []; - for (var i = 0, n = this.nonSeparatorCount(); i < n; i++) { - result.push(this.nonSeparatorAt(i)); - } - - return result; - }; - - NormalSeparatedSyntaxList.prototype.childAt = function (index) { - if (index < 0 || index >= this.elements.length) { - throw TypeScript.Errors.argumentOutOfRange("index"); - } - - return this.elements[index]; - }; - - NormalSeparatedSyntaxList.prototype.nonSeparatorAt = function (index) { - var value = index * 2; - if (value < 0 || value >= this.elements.length) { - throw TypeScript.Errors.argumentOutOfRange("index"); - } - - return this.elements[value]; - }; - - NormalSeparatedSyntaxList.prototype.separatorAt = function (index) { - var value = index * 2 + 1; - if (value < 0 || value >= this.elements.length) { - throw TypeScript.Errors.argumentOutOfRange("index"); - } - - return this.elements[value]; - }; - - NormalSeparatedSyntaxList.prototype.firstToken = function () { - var token; - for (var i = 0, n = this.elements.length; i < n; i++) { - if (i % 2 === 0) { - var nodeOrToken = this.elements[i]; - token = nodeOrToken.firstToken(); - if (token !== null) { - return token; - } - } else { - token = this.elements[i]; - if (token.width() > 0) { - return token; - } - } - } - - return null; - }; - - NormalSeparatedSyntaxList.prototype.lastToken = function () { - var token; - for (var i = this.elements.length - 1; i >= 0; i--) { - if (i % 2 === 0) { - var nodeOrToken = this.elements[i]; - token = nodeOrToken.lastToken(); - if (token !== null) { - return token; - } - } else { - token = this.elements[i]; - if (token.width() > 0) { - return token; - } - } - } - - return null; - }; - - NormalSeparatedSyntaxList.prototype.fullText = function () { - var elements = []; - this.collectTextElements(elements); - return elements.join(""); - }; - - NormalSeparatedSyntaxList.prototype.isTypeScriptSpecific = function () { - for (var i = 0, n = this.nonSeparatorCount(); i < n; i++) { - if (this.nonSeparatorAt(i).isTypeScriptSpecific()) { - return true; - } - } - - return false; - }; - - NormalSeparatedSyntaxList.prototype.isIncrementallyUnusable = function () { - return (this.data() & 2 /* NodeIncrementallyUnusableMask */) !== 0; - }; - - NormalSeparatedSyntaxList.prototype.fullWidth = function () { - return this.data() >>> 3 /* NodeFullWidthShift */; - }; - - NormalSeparatedSyntaxList.prototype.width = function () { - var fullWidth = this.fullWidth(); - return fullWidth - this.leadingTriviaWidth() - this.trailingTriviaWidth(); - }; - - NormalSeparatedSyntaxList.prototype.leadingTrivia = function () { - return this.firstToken().leadingTrivia(); - }; - - NormalSeparatedSyntaxList.prototype.trailingTrivia = function () { - return this.lastToken().trailingTrivia(); - }; - - NormalSeparatedSyntaxList.prototype.leadingTriviaWidth = function () { - return this.firstToken().leadingTriviaWidth(); - }; - - NormalSeparatedSyntaxList.prototype.trailingTriviaWidth = function () { - return this.lastToken().trailingTriviaWidth(); - }; - - NormalSeparatedSyntaxList.prototype.computeData = function () { - var fullWidth = 0; - var isIncrementallyUnusable = false; - - for (var i = 0, n = this.elements.length; i < n; i++) { - var element = this.elements[i]; - - var childWidth = element.fullWidth(); - fullWidth += childWidth; - - isIncrementallyUnusable = isIncrementallyUnusable || element.isIncrementallyUnusable(); - } - - return (fullWidth << 3 /* NodeFullWidthShift */) | (isIncrementallyUnusable ? 2 /* NodeIncrementallyUnusableMask */ : 0) | 1 /* NodeDataComputed */; - }; - - NormalSeparatedSyntaxList.prototype.data = function () { - if ((this._data & 1 /* NodeDataComputed */) === 0) { - this._data = this.computeData(); - } - - return this._data; - }; - - NormalSeparatedSyntaxList.prototype.findTokenInternal = function (parent, position, fullStart) { - parent = new TypeScript.PositionedSeparatedList(parent, this, fullStart); - for (var i = 0, n = this.elements.length; i < n; i++) { - var element = this.elements[i]; - - var childWidth = element.fullWidth(); - if (position < childWidth) { - return (element).findTokenInternal(parent, position, fullStart); - } - - position -= childWidth; - fullStart += childWidth; - } - - throw TypeScript.Errors.invalidOperation(); - }; - - NormalSeparatedSyntaxList.prototype.collectTextElements = function (elements) { - for (var i = 0, n = this.elements.length; i < n; i++) { - var element = this.elements[i]; - element.collectTextElements(elements); - } - }; - - NormalSeparatedSyntaxList.prototype.insertChildrenInto = function (array, index) { - if (index === 0) { - array.unshift.apply(array, this.elements); - } else { - array.splice.apply(array, [index, 0].concat(this.elements)); - } - }; - return NormalSeparatedSyntaxList; - })(); - - function separatedList(nodes) { - return separatedListAndValidate(nodes, false); - } - Syntax.separatedList = separatedList; - - function separatedListAndValidate(nodes, validate) { - if (nodes === undefined || nodes === null || nodes.length === 0) { - return Syntax.emptySeparatedList; - } - - if (validate) { - for (var i = 0; i < nodes.length; i++) { - var item = nodes[i]; - - if (i % 2 === 1) { - } - } - } - - if (nodes.length === 1) { - return new SingletonSeparatedSyntaxList(nodes[0]); - } - - return new NormalSeparatedSyntaxList(nodes); - } - })(TypeScript.Syntax || (TypeScript.Syntax = {})); - var Syntax = TypeScript.Syntax; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var SlidingWindow = (function () { - function SlidingWindow(source, window, defaultValue, sourceLength) { - if (typeof sourceLength === "undefined") { sourceLength = -1; } - this.source = source; - this.window = window; - this.defaultValue = defaultValue; - this.sourceLength = sourceLength; - this.windowCount = 0; - this.windowAbsoluteStartIndex = 0; - this.currentRelativeItemIndex = 0; - this._pinCount = 0; - this.firstPinnedAbsoluteIndex = -1; - } - SlidingWindow.prototype.windowAbsoluteEndIndex = function () { - return this.windowAbsoluteStartIndex + this.windowCount; - }; - - SlidingWindow.prototype.addMoreItemsToWindow = function (argument) { - if (this.sourceLength >= 0 && this.absoluteIndex() >= this.sourceLength) { - return false; - } - - if (this.windowCount >= this.window.length) { - this.tryShiftOrGrowWindow(); - } - - var spaceAvailable = this.window.length - this.windowCount; - var amountFetched = this.source.fetchMoreItems(argument, this.windowAbsoluteEndIndex(), this.window, this.windowCount, spaceAvailable); - - this.windowCount += amountFetched; - return amountFetched > 0; - }; - - SlidingWindow.prototype.tryShiftOrGrowWindow = function () { - var currentIndexIsPastWindowHalfwayPoint = this.currentRelativeItemIndex > (this.window.length >>> 1); - - var isAllowedToShift = this.firstPinnedAbsoluteIndex === -1 || this.firstPinnedAbsoluteIndex > this.windowAbsoluteStartIndex; - - if (currentIndexIsPastWindowHalfwayPoint && isAllowedToShift) { - var shiftStartIndex = this.firstPinnedAbsoluteIndex === -1 ? this.currentRelativeItemIndex : this.firstPinnedAbsoluteIndex - this.windowAbsoluteStartIndex; - - var shiftCount = this.windowCount - shiftStartIndex; - - if (shiftCount > 0) { - TypeScript.ArrayUtilities.copy(this.window, shiftStartIndex, this.window, 0, shiftCount); - } - - this.windowAbsoluteStartIndex += shiftStartIndex; - - this.windowCount -= shiftStartIndex; - - this.currentRelativeItemIndex -= shiftStartIndex; - } else { - TypeScript.ArrayUtilities.grow(this.window, this.window.length * 2, this.defaultValue); - } - }; - - SlidingWindow.prototype.absoluteIndex = function () { - return this.windowAbsoluteStartIndex + this.currentRelativeItemIndex; - }; - - SlidingWindow.prototype.isAtEndOfSource = function () { - return this.absoluteIndex() >= this.sourceLength; - }; - - SlidingWindow.prototype.getAndPinAbsoluteIndex = function () { - var absoluteIndex = this.absoluteIndex(); - var pinCount = this._pinCount++; - if (pinCount === 0) { - this.firstPinnedAbsoluteIndex = absoluteIndex; - } - - return absoluteIndex; - }; - - SlidingWindow.prototype.releaseAndUnpinAbsoluteIndex = function (absoluteIndex) { - this._pinCount--; - if (this._pinCount === 0) { - this.firstPinnedAbsoluteIndex = -1; - } - }; - - SlidingWindow.prototype.rewindToPinnedIndex = function (absoluteIndex) { - var relativeIndex = absoluteIndex - this.windowAbsoluteStartIndex; - - this.currentRelativeItemIndex = relativeIndex; - }; - - SlidingWindow.prototype.currentItem = function (argument) { - if (this.currentRelativeItemIndex >= this.windowCount) { - if (!this.addMoreItemsToWindow(argument)) { - return this.defaultValue; - } - } - - return this.window[this.currentRelativeItemIndex]; - }; - - SlidingWindow.prototype.peekItemN = function (n) { - while (this.currentRelativeItemIndex + n >= this.windowCount) { - if (!this.addMoreItemsToWindow(null)) { - return this.defaultValue; - } - } - - return this.window[this.currentRelativeItemIndex + n]; - }; - - SlidingWindow.prototype.moveToNextItem = function () { - this.currentRelativeItemIndex++; - }; - - SlidingWindow.prototype.disgardAllItemsFromCurrentIndexOnwards = function () { - this.windowCount = this.currentRelativeItemIndex; - }; - - SlidingWindow.prototype.setAbsoluteIndex = function (absoluteIndex) { - if (this.absoluteIndex() === absoluteIndex) { - return; - } - - if (this._pinCount > 0) { - } - - if (absoluteIndex >= this.windowAbsoluteStartIndex && absoluteIndex < this.windowAbsoluteEndIndex()) { - this.currentRelativeItemIndex = (absoluteIndex - this.windowAbsoluteStartIndex); - } else { - this.windowAbsoluteStartIndex = absoluteIndex; - - this.windowCount = 0; - - this.currentRelativeItemIndex = 0; - } - }; - - SlidingWindow.prototype.pinCount = function () { - return this._pinCount; - }; - return SlidingWindow; - })(); - TypeScript.SlidingWindow = SlidingWindow; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var Strings = (function () { - function Strings() { - } - Strings.module__class__interface__enum__import_or_statement = "module, class, interface, enum, import or statement"; - Strings.constructor__function__accessor_or_variable = "constructor, function, accessor or variable"; - Strings.statement = "statement"; - Strings.case_or_default_clause = "case or default clause"; - Strings.identifier = "identifier"; - Strings.call__construct__index__property_or_function_signature = "call, construct, index, property or function signature"; - Strings.expression = "expression"; - Strings.type_name = "type name"; - Strings.property_or_accessor = "property or accessor"; - Strings.parameter = "parameter"; - Strings.type = "type"; - Strings.type_parameter = "type parameter"; - return Strings; - })(); - TypeScript.Strings = Strings; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (Syntax) { - function emptySourceUnit() { - return TypeScript.Syntax.normalModeFactory.sourceUnit(TypeScript.Syntax.emptyList, TypeScript.Syntax.token(10 /* EndOfFileToken */, { text: "" })); - } - Syntax.emptySourceUnit = emptySourceUnit; - - function getStandaloneExpression(positionedToken) { - var token = positionedToken.token(); - if (positionedToken !== null && positionedToken.kind() === 11 /* IdentifierName */) { - var parentPositionedNode = positionedToken.containingNode(); - var parentNode = parentPositionedNode.node(); - - if (parentNode.kind() === 122 /* QualifiedName */ && (parentNode).right === token) { - return parentPositionedNode; - } else if (parentNode.kind() === 211 /* MemberAccessExpression */ && (parentNode).name === token) { - return parentPositionedNode; - } - } - - return positionedToken; - } - Syntax.getStandaloneExpression = getStandaloneExpression; - - function isInModuleOrTypeContext(positionedToken) { - if (positionedToken !== null) { - var positionedNodeOrToken = TypeScript.Syntax.getStandaloneExpression(positionedToken); - var parent = positionedNodeOrToken.containingNode(); - - if (parent !== null) { - switch (parent.kind()) { - case 246 /* ModuleNameModuleReference */: - return true; - case 122 /* QualifiedName */: - return true; - default: - return isInTypeOnlyContext(positionedToken); - } - } - } - - return false; - } - Syntax.isInModuleOrTypeContext = isInModuleOrTypeContext; - - function isInTypeOnlyContext(positionedToken) { - var positionedNodeOrToken = TypeScript.Syntax.getStandaloneExpression(positionedToken); - var positionedParent = positionedNodeOrToken.containingNode(); - - var parent = positionedParent.node(); - var nodeOrToken = positionedNodeOrToken.nodeOrToken(); - - if (parent !== null) { - switch (parent.kind()) { - case 125 /* ArrayType */: - return (parent).type === nodeOrToken; - case 219 /* CastExpression */: - return (parent).type === nodeOrToken; - case 244 /* TypeAnnotation */: - case 229 /* HeritageClause */: - case 227 /* TypeArgumentList */: - return true; - } - } - - return false; - } - Syntax.isInTypeOnlyContext = isInTypeOnlyContext; - - function childOffset(parent, child) { - var offset = 0; - for (var i = 0, n = parent.childCount(); i < n; i++) { - var current = parent.childAt(i); - if (current === child) { - return offset; - } - - if (current !== null) { - offset += current.fullWidth(); - } - } - - throw TypeScript.Errors.invalidOperation(); - } - Syntax.childOffset = childOffset; - - function childOffsetAt(parent, index) { - var offset = 0; - for (var i = 0; i < index; i++) { - var current = parent.childAt(i); - if (current !== null) { - offset += current.fullWidth(); - } - } - - return offset; - } - Syntax.childOffsetAt = childOffsetAt; - - function childIndex(parent, child) { - for (var i = 0, n = parent.childCount(); i < n; i++) { - var current = parent.childAt(i); - if (current === child) { - return i; - } - } - - throw TypeScript.Errors.invalidOperation(); - } - Syntax.childIndex = childIndex; - - function nodeStructuralEquals(node1, node2) { - if (node1 === null) { - return node2 === null; - } - - return node1.structuralEquals(node2); - } - Syntax.nodeStructuralEquals = nodeStructuralEquals; - - function nodeOrTokenStructuralEquals(node1, node2) { - if (node1 === node2) { - return true; - } - - if (node1 === null || node2 === null) { - return false; - } - - if (node1.isToken()) { - return node2.isToken() ? tokenStructuralEquals(node1, node2) : false; - } - - return node2.isNode() ? nodeStructuralEquals(node1, node2) : false; - } - Syntax.nodeOrTokenStructuralEquals = nodeOrTokenStructuralEquals; - - function tokenStructuralEquals(token1, token2) { - if (token1 === token2) { - return true; - } - - if (token1 === null || token2 === null) { - return false; - } - - return token1.kind() === token2.kind() && token1.width() === token2.width() && token1.fullWidth() === token2.fullWidth() && token1.text() === token2.text() && TypeScript.Syntax.triviaListStructuralEquals(token1.leadingTrivia(), token2.leadingTrivia()) && TypeScript.Syntax.triviaListStructuralEquals(token1.trailingTrivia(), token2.trailingTrivia()); - } - Syntax.tokenStructuralEquals = tokenStructuralEquals; - - function triviaListStructuralEquals(triviaList1, triviaList2) { - if (triviaList1.count() !== triviaList2.count()) { - return false; - } - - for (var i = 0, n = triviaList1.count(); i < n; i++) { - if (!TypeScript.Syntax.triviaStructuralEquals(triviaList1.syntaxTriviaAt(i), triviaList2.syntaxTriviaAt(i))) { - return false; - } - } - - return true; - } - Syntax.triviaListStructuralEquals = triviaListStructuralEquals; - - function triviaStructuralEquals(trivia1, trivia2) { - return trivia1.kind() === trivia2.kind() && trivia1.fullWidth() === trivia2.fullWidth() && trivia1.fullText() === trivia2.fullText(); - } - Syntax.triviaStructuralEquals = triviaStructuralEquals; - - function listStructuralEquals(list1, list2) { - if (list1.childCount() !== list2.childCount()) { - return false; - } - - for (var i = 0, n = list1.childCount(); i < n; i++) { - var child1 = list1.childAt(i); - var child2 = list2.childAt(i); - - if (!TypeScript.Syntax.nodeOrTokenStructuralEquals(child1, child2)) { - return false; - } - } - - return true; - } - Syntax.listStructuralEquals = listStructuralEquals; - - function separatedListStructuralEquals(list1, list2) { - if (list1.childCount() !== list2.childCount()) { - return false; - } - - for (var i = 0, n = list1.childCount(); i < n; i++) { - var element1 = list1.childAt(i); - var element2 = list2.childAt(i); - if (!TypeScript.Syntax.nodeOrTokenStructuralEquals(element1, element2)) { - return false; - } - } - - return true; - } - Syntax.separatedListStructuralEquals = separatedListStructuralEquals; - - function elementStructuralEquals(element1, element2) { - if (element1 === element2) { - return true; - } - - if (element1 === null || element2 === null) { - return false; - } - - if (element2.kind() !== element2.kind()) { - return false; - } - - if (element1.isToken()) { - return tokenStructuralEquals(element1, element2); - } else if (element1.isNode()) { - return nodeStructuralEquals(element1, element2); - } else if (element1.isList()) { - return listStructuralEquals(element1, element2); - } else if (element1.isSeparatedList()) { - return separatedListStructuralEquals(element1, element2); - } - - throw TypeScript.Errors.invalidOperation(); - } - Syntax.elementStructuralEquals = elementStructuralEquals; - - function identifierName(text, info) { - if (typeof info === "undefined") { info = null; } - return Syntax.identifier(text); - } - Syntax.identifierName = identifierName; - - function trueExpression() { - return TypeScript.Syntax.token(37 /* TrueKeyword */); - } - Syntax.trueExpression = trueExpression; - - function falseExpression() { - return TypeScript.Syntax.token(24 /* FalseKeyword */); - } - Syntax.falseExpression = falseExpression; - - function numericLiteralExpression(text) { - return TypeScript.Syntax.token(13 /* NumericLiteral */, { text: text }); - } - Syntax.numericLiteralExpression = numericLiteralExpression; - - function stringLiteralExpression(text) { - return TypeScript.Syntax.token(14 /* StringLiteral */, { text: text }); - } - Syntax.stringLiteralExpression = stringLiteralExpression; - - function isSuperInvocationExpression(node) { - return node.kind() === 212 /* InvocationExpression */ && (node).expression.kind() === 50 /* SuperKeyword */; - } - Syntax.isSuperInvocationExpression = isSuperInvocationExpression; - - function isSuperInvocationExpressionStatement(node) { - return node.kind() === 148 /* ExpressionStatement */ && isSuperInvocationExpression((node).expression); - } - Syntax.isSuperInvocationExpressionStatement = isSuperInvocationExpressionStatement; - - function isSuperMemberAccessExpression(node) { - return node.kind() === 211 /* MemberAccessExpression */ && (node).expression.kind() === 50 /* SuperKeyword */; - } - Syntax.isSuperMemberAccessExpression = isSuperMemberAccessExpression; - - function isSuperMemberAccessInvocationExpression(node) { - return node.kind() === 212 /* InvocationExpression */ && isSuperMemberAccessExpression((node).expression); - } - Syntax.isSuperMemberAccessInvocationExpression = isSuperMemberAccessInvocationExpression; - - function assignmentExpression(left, token, right) { - return TypeScript.Syntax.normalModeFactory.binaryExpression(173 /* AssignmentExpression */, left, token, right); - } - Syntax.assignmentExpression = assignmentExpression; - - function nodeHasSkippedOrMissingTokens(node) { - for (var i = 0; i < node.childCount(); i++) { - var child = node.childAt(i); - if (child !== null && child.isToken()) { - var token = child; - - if (token.hasSkippedToken() || (token.width() === 0 && token.kind() !== 10 /* EndOfFileToken */)) { - return true; - } - } - } - return false; - } - Syntax.nodeHasSkippedOrMissingTokens = nodeHasSkippedOrMissingTokens; - - function isUnterminatedStringLiteral(token) { - if (token && token.kind() === 14 /* StringLiteral */) { - var text = token.text(); - return text.length < 2 || text.charCodeAt(text.length - 1) !== text.charCodeAt(0); - } - - return false; - } - Syntax.isUnterminatedStringLiteral = isUnterminatedStringLiteral; - - function isUnterminatedMultilineCommentTrivia(trivia) { - if (trivia && trivia.kind() === 6 /* MultiLineCommentTrivia */) { - var text = trivia.fullText(); - return text.length < 4 || text.substring(text.length - 2) !== "*/"; - } - return false; - } - Syntax.isUnterminatedMultilineCommentTrivia = isUnterminatedMultilineCommentTrivia; - - function isEntirelyInsideCommentTrivia(trivia, fullStart, position) { - if (trivia && trivia.isComment() && position > fullStart) { - var end = fullStart + trivia.fullWidth(); - if (position < end) { - return true; - } else if (position === end) { - return trivia.kind() === 7 /* SingleLineCommentTrivia */ || isUnterminatedMultilineCommentTrivia(trivia); - } - } - - return false; - } - Syntax.isEntirelyInsideCommentTrivia = isEntirelyInsideCommentTrivia; - - function isEntirelyInsideComment(sourceUnit, position) { - var positionedToken = sourceUnit.findToken(position); - var fullStart = positionedToken.fullStart(); - var triviaList = null; - var lastTriviaBeforeToken = null; - - if (positionedToken.kind() === 10 /* EndOfFileToken */) { - if (positionedToken.token().hasLeadingTrivia()) { - triviaList = positionedToken.token().leadingTrivia(); - } else { - positionedToken = positionedToken.previousToken(); - if (positionedToken) { - if (positionedToken && positionedToken.token().hasTrailingTrivia()) { - triviaList = positionedToken.token().trailingTrivia(); - fullStart = positionedToken.end(); - } - } - } - } else { - if (position <= (fullStart + positionedToken.token().leadingTriviaWidth())) { - triviaList = positionedToken.token().leadingTrivia(); - } else if (position >= (fullStart + positionedToken.token().width())) { - triviaList = positionedToken.token().trailingTrivia(); - fullStart = positionedToken.end(); - } - } - - if (triviaList) { - for (var i = 0, n = triviaList.count(); i < n; i++) { - var trivia = triviaList.syntaxTriviaAt(i); - if (position <= fullStart) { - break; - } else if (position <= fullStart + trivia.fullWidth() && trivia.isComment()) { - lastTriviaBeforeToken = trivia; - break; - } - - fullStart += trivia.fullWidth(); - } - } - - return lastTriviaBeforeToken && isEntirelyInsideCommentTrivia(lastTriviaBeforeToken, fullStart, position); - } - Syntax.isEntirelyInsideComment = isEntirelyInsideComment; - - function isEntirelyInStringOrRegularExpressionLiteral(sourceUnit, position) { - var positionedToken = sourceUnit.findToken(position); - - if (positionedToken) { - if (positionedToken.kind() === 10 /* EndOfFileToken */) { - positionedToken = positionedToken.previousToken(); - return positionedToken && positionedToken.token().trailingTriviaWidth() === 0 && isUnterminatedStringLiteral(positionedToken.token()); - } else if (position > positionedToken.start()) { - return (position < positionedToken.end() && (positionedToken.kind() === 14 /* StringLiteral */ || positionedToken.kind() === 12 /* RegularExpressionLiteral */)) || (position <= positionedToken.end() && isUnterminatedStringLiteral(positionedToken.token())); - } - } - - return false; - } - Syntax.isEntirelyInStringOrRegularExpressionLiteral = isEntirelyInStringOrRegularExpressionLiteral; - - function findSkippedTokenInTriviaList(positionedToken, position, lookInLeadingTriviaList) { - var triviaList = null; - var fullStart; - - if (lookInLeadingTriviaList) { - triviaList = positionedToken.token().leadingTrivia(); - fullStart = positionedToken.fullStart(); - } else { - triviaList = positionedToken.token().trailingTrivia(); - fullStart = positionedToken.end(); - } - - if (triviaList && triviaList.hasSkippedToken()) { - for (var i = 0, n = triviaList.count(); i < n; i++) { - var trivia = triviaList.syntaxTriviaAt(i); - var triviaWidth = trivia.fullWidth(); - - if (trivia.isSkippedToken() && position >= fullStart && position <= fullStart + triviaWidth) { - return new TypeScript.PositionedSkippedToken(positionedToken, trivia.skippedToken(), fullStart); - } - - fullStart += triviaWidth; - } - } - - return null; - } - - function findSkippedTokenInLeadingTriviaList(positionedToken, position) { - return findSkippedTokenInTriviaList(positionedToken, position, true); - } - Syntax.findSkippedTokenInLeadingTriviaList = findSkippedTokenInLeadingTriviaList; - - function findSkippedTokenInTrailingTriviaList(positionedToken, position) { - return findSkippedTokenInTriviaList(positionedToken, position, false); - } - Syntax.findSkippedTokenInTrailingTriviaList = findSkippedTokenInTrailingTriviaList; - - function findSkippedTokenInPositionedToken(positionedToken, position) { - var positionInLeadingTriviaList = (position < positionedToken.start()); - return findSkippedTokenInTriviaList(positionedToken, position, positionInLeadingTriviaList); - } - Syntax.findSkippedTokenInPositionedToken = findSkippedTokenInPositionedToken; - - function getAncestorOfKind(positionedToken, kind) { - while (positionedToken && positionedToken.parent()) { - if (positionedToken.parent().kind() === kind) { - return positionedToken.parent(); - } - - positionedToken = positionedToken.parent(); - } - - return null; - } - Syntax.getAncestorOfKind = getAncestorOfKind; - - function hasAncestorOfKind(positionedToken, kind) { - return TypeScript.Syntax.getAncestorOfKind(positionedToken, kind) !== null; - } - Syntax.hasAncestorOfKind = hasAncestorOfKind; - })(TypeScript.Syntax || (TypeScript.Syntax = {})); - var Syntax = TypeScript.Syntax; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var SyntaxDiagnostic = (function (_super) { - __extends(SyntaxDiagnostic, _super); - function SyntaxDiagnostic() { - _super.apply(this, arguments); - } - SyntaxDiagnostic.equals = function (diagnostic1, diagnostic2) { - return TypeScript.Diagnostic.equals(diagnostic1, diagnostic2); - }; - return SyntaxDiagnostic; - })(TypeScript.Diagnostic); - TypeScript.SyntaxDiagnostic = SyntaxDiagnostic; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (Syntax) { - var NormalModeFactory = (function () { - function NormalModeFactory() { - } - NormalModeFactory.prototype.sourceUnit = function (moduleElements, endOfFileToken) { - return new TypeScript.SourceUnitSyntax(moduleElements, endOfFileToken, false); - }; - NormalModeFactory.prototype.externalModuleReference = function (moduleOrRequireKeyword, openParenToken, stringLiteral, closeParenToken) { - return new TypeScript.ExternalModuleReferenceSyntax(moduleOrRequireKeyword, openParenToken, stringLiteral, closeParenToken, false); - }; - NormalModeFactory.prototype.moduleNameModuleReference = function (moduleName) { - return new TypeScript.ModuleNameModuleReferenceSyntax(moduleName, false); - }; - NormalModeFactory.prototype.importDeclaration = function (importKeyword, identifier, equalsToken, moduleReference, semicolonToken) { - return new TypeScript.ImportDeclarationSyntax(importKeyword, identifier, equalsToken, moduleReference, semicolonToken, false); - }; - NormalModeFactory.prototype.exportAssignment = function (exportKeyword, equalsToken, identifier, semicolonToken) { - return new TypeScript.ExportAssignmentSyntax(exportKeyword, equalsToken, identifier, semicolonToken, false); - }; - NormalModeFactory.prototype.classDeclaration = function (modifiers, classKeyword, identifier, typeParameterList, heritageClauses, openBraceToken, classElements, closeBraceToken) { - return new TypeScript.ClassDeclarationSyntax(modifiers, classKeyword, identifier, typeParameterList, heritageClauses, openBraceToken, classElements, closeBraceToken, false); - }; - NormalModeFactory.prototype.interfaceDeclaration = function (modifiers, interfaceKeyword, identifier, typeParameterList, heritageClauses, body) { - return new TypeScript.InterfaceDeclarationSyntax(modifiers, interfaceKeyword, identifier, typeParameterList, heritageClauses, body, false); - }; - NormalModeFactory.prototype.heritageClause = function (extendsOrImplementsKeyword, typeNames) { - return new TypeScript.HeritageClauseSyntax(extendsOrImplementsKeyword, typeNames, false); - }; - NormalModeFactory.prototype.moduleDeclaration = function (modifiers, moduleKeyword, moduleName, stringLiteral, openBraceToken, moduleElements, closeBraceToken) { - return new TypeScript.ModuleDeclarationSyntax(modifiers, moduleKeyword, moduleName, stringLiteral, openBraceToken, moduleElements, closeBraceToken, false); - }; - NormalModeFactory.prototype.functionDeclaration = function (modifiers, functionKeyword, identifier, callSignature, block, semicolonToken) { - return new TypeScript.FunctionDeclarationSyntax(modifiers, functionKeyword, identifier, callSignature, block, semicolonToken, false); - }; - NormalModeFactory.prototype.variableStatement = function (modifiers, variableDeclaration, semicolonToken) { - return new TypeScript.VariableStatementSyntax(modifiers, variableDeclaration, semicolonToken, false); - }; - NormalModeFactory.prototype.variableDeclaration = function (varKeyword, variableDeclarators) { - return new TypeScript.VariableDeclarationSyntax(varKeyword, variableDeclarators, false); - }; - NormalModeFactory.prototype.variableDeclarator = function (identifier, typeAnnotation, equalsValueClause) { - return new TypeScript.VariableDeclaratorSyntax(identifier, typeAnnotation, equalsValueClause, false); - }; - NormalModeFactory.prototype.equalsValueClause = function (equalsToken, value) { - return new TypeScript.EqualsValueClauseSyntax(equalsToken, value, false); - }; - NormalModeFactory.prototype.prefixUnaryExpression = function (kind, operatorToken, operand) { - return new TypeScript.PrefixUnaryExpressionSyntax(kind, operatorToken, operand, false); - }; - NormalModeFactory.prototype.arrayLiteralExpression = function (openBracketToken, expressions, closeBracketToken) { - return new TypeScript.ArrayLiteralExpressionSyntax(openBracketToken, expressions, closeBracketToken, false); - }; - NormalModeFactory.prototype.omittedExpression = function () { - return new TypeScript.OmittedExpressionSyntax(false); - }; - NormalModeFactory.prototype.parenthesizedExpression = function (openParenToken, expression, closeParenToken) { - return new TypeScript.ParenthesizedExpressionSyntax(openParenToken, expression, closeParenToken, false); - }; - NormalModeFactory.prototype.simpleArrowFunctionExpression = function (identifier, equalsGreaterThanToken, body) { - return new TypeScript.SimpleArrowFunctionExpressionSyntax(identifier, equalsGreaterThanToken, body, false); - }; - NormalModeFactory.prototype.parenthesizedArrowFunctionExpression = function (callSignature, equalsGreaterThanToken, body) { - return new TypeScript.ParenthesizedArrowFunctionExpressionSyntax(callSignature, equalsGreaterThanToken, body, false); - }; - NormalModeFactory.prototype.qualifiedName = function (left, dotToken, right) { - return new TypeScript.QualifiedNameSyntax(left, dotToken, right, false); - }; - NormalModeFactory.prototype.typeArgumentList = function (lessThanToken, typeArguments, greaterThanToken) { - return new TypeScript.TypeArgumentListSyntax(lessThanToken, typeArguments, greaterThanToken, false); - }; - NormalModeFactory.prototype.constructorType = function (newKeyword, typeParameterList, parameterList, equalsGreaterThanToken, type) { - return new TypeScript.ConstructorTypeSyntax(newKeyword, typeParameterList, parameterList, equalsGreaterThanToken, type, false); - }; - NormalModeFactory.prototype.functionType = function (typeParameterList, parameterList, equalsGreaterThanToken, type) { - return new TypeScript.FunctionTypeSyntax(typeParameterList, parameterList, equalsGreaterThanToken, type, false); - }; - NormalModeFactory.prototype.objectType = function (openBraceToken, typeMembers, closeBraceToken) { - return new TypeScript.ObjectTypeSyntax(openBraceToken, typeMembers, closeBraceToken, false); - }; - NormalModeFactory.prototype.arrayType = function (type, openBracketToken, closeBracketToken) { - return new TypeScript.ArrayTypeSyntax(type, openBracketToken, closeBracketToken, false); - }; - NormalModeFactory.prototype.genericType = function (name, typeArgumentList) { - return new TypeScript.GenericTypeSyntax(name, typeArgumentList, false); - }; - NormalModeFactory.prototype.typeAnnotation = function (colonToken, type) { - return new TypeScript.TypeAnnotationSyntax(colonToken, type, false); - }; - NormalModeFactory.prototype.block = function (openBraceToken, statements, closeBraceToken) { - return new TypeScript.BlockSyntax(openBraceToken, statements, closeBraceToken, false); - }; - NormalModeFactory.prototype.parameter = function (dotDotDotToken, publicOrPrivateKeyword, identifier, questionToken, typeAnnotation, equalsValueClause) { - return new TypeScript.ParameterSyntax(dotDotDotToken, publicOrPrivateKeyword, identifier, questionToken, typeAnnotation, equalsValueClause, false); - }; - NormalModeFactory.prototype.memberAccessExpression = function (expression, dotToken, name) { - return new TypeScript.MemberAccessExpressionSyntax(expression, dotToken, name, false); - }; - NormalModeFactory.prototype.postfixUnaryExpression = function (kind, operand, operatorToken) { - return new TypeScript.PostfixUnaryExpressionSyntax(kind, operand, operatorToken, false); - }; - NormalModeFactory.prototype.elementAccessExpression = function (expression, openBracketToken, argumentExpression, closeBracketToken) { - return new TypeScript.ElementAccessExpressionSyntax(expression, openBracketToken, argumentExpression, closeBracketToken, false); - }; - NormalModeFactory.prototype.invocationExpression = function (expression, argumentList) { - return new TypeScript.InvocationExpressionSyntax(expression, argumentList, false); - }; - NormalModeFactory.prototype.argumentList = function (typeArgumentList, openParenToken, _arguments, closeParenToken) { - return new TypeScript.ArgumentListSyntax(typeArgumentList, openParenToken, _arguments, closeParenToken, false); - }; - NormalModeFactory.prototype.binaryExpression = function (kind, left, operatorToken, right) { - return new TypeScript.BinaryExpressionSyntax(kind, left, operatorToken, right, false); - }; - NormalModeFactory.prototype.conditionalExpression = function (condition, questionToken, whenTrue, colonToken, whenFalse) { - return new TypeScript.ConditionalExpressionSyntax(condition, questionToken, whenTrue, colonToken, whenFalse, false); - }; - NormalModeFactory.prototype.constructSignature = function (newKeyword, callSignature) { - return new TypeScript.ConstructSignatureSyntax(newKeyword, callSignature, false); - }; - NormalModeFactory.prototype.methodSignature = function (propertyName, questionToken, callSignature) { - return new TypeScript.MethodSignatureSyntax(propertyName, questionToken, callSignature, false); - }; - NormalModeFactory.prototype.indexSignature = function (openBracketToken, parameter, closeBracketToken, typeAnnotation) { - return new TypeScript.IndexSignatureSyntax(openBracketToken, parameter, closeBracketToken, typeAnnotation, false); - }; - NormalModeFactory.prototype.propertySignature = function (propertyName, questionToken, typeAnnotation) { - return new TypeScript.PropertySignatureSyntax(propertyName, questionToken, typeAnnotation, false); - }; - NormalModeFactory.prototype.callSignature = function (typeParameterList, parameterList, typeAnnotation) { - return new TypeScript.CallSignatureSyntax(typeParameterList, parameterList, typeAnnotation, false); - }; - NormalModeFactory.prototype.parameterList = function (openParenToken, parameters, closeParenToken) { - return new TypeScript.ParameterListSyntax(openParenToken, parameters, closeParenToken, false); - }; - NormalModeFactory.prototype.typeParameterList = function (lessThanToken, typeParameters, greaterThanToken) { - return new TypeScript.TypeParameterListSyntax(lessThanToken, typeParameters, greaterThanToken, false); - }; - NormalModeFactory.prototype.typeParameter = function (identifier, constraint) { - return new TypeScript.TypeParameterSyntax(identifier, constraint, false); - }; - NormalModeFactory.prototype.constraint = function (extendsKeyword, type) { - return new TypeScript.ConstraintSyntax(extendsKeyword, type, false); - }; - NormalModeFactory.prototype.elseClause = function (elseKeyword, statement) { - return new TypeScript.ElseClauseSyntax(elseKeyword, statement, false); - }; - NormalModeFactory.prototype.ifStatement = function (ifKeyword, openParenToken, condition, closeParenToken, statement, elseClause) { - return new TypeScript.IfStatementSyntax(ifKeyword, openParenToken, condition, closeParenToken, statement, elseClause, false); - }; - NormalModeFactory.prototype.expressionStatement = function (expression, semicolonToken) { - return new TypeScript.ExpressionStatementSyntax(expression, semicolonToken, false); - }; - NormalModeFactory.prototype.constructorDeclaration = function (constructorKeyword, parameterList, block, semicolonToken) { - return new TypeScript.ConstructorDeclarationSyntax(constructorKeyword, parameterList, block, semicolonToken, false); - }; - NormalModeFactory.prototype.memberFunctionDeclaration = function (modifiers, propertyName, callSignature, block, semicolonToken) { - return new TypeScript.MemberFunctionDeclarationSyntax(modifiers, propertyName, callSignature, block, semicolonToken, false); - }; - NormalModeFactory.prototype.getMemberAccessorDeclaration = function (modifiers, getKeyword, propertyName, parameterList, typeAnnotation, block) { - return new TypeScript.GetMemberAccessorDeclarationSyntax(modifiers, getKeyword, propertyName, parameterList, typeAnnotation, block, false); - }; - NormalModeFactory.prototype.setMemberAccessorDeclaration = function (modifiers, setKeyword, propertyName, parameterList, block) { - return new TypeScript.SetMemberAccessorDeclarationSyntax(modifiers, setKeyword, propertyName, parameterList, block, false); - }; - NormalModeFactory.prototype.memberVariableDeclaration = function (modifiers, variableDeclarator, semicolonToken) { - return new TypeScript.MemberVariableDeclarationSyntax(modifiers, variableDeclarator, semicolonToken, false); - }; - NormalModeFactory.prototype.throwStatement = function (throwKeyword, expression, semicolonToken) { - return new TypeScript.ThrowStatementSyntax(throwKeyword, expression, semicolonToken, false); - }; - NormalModeFactory.prototype.returnStatement = function (returnKeyword, expression, semicolonToken) { - return new TypeScript.ReturnStatementSyntax(returnKeyword, expression, semicolonToken, false); - }; - NormalModeFactory.prototype.objectCreationExpression = function (newKeyword, expression, argumentList) { - return new TypeScript.ObjectCreationExpressionSyntax(newKeyword, expression, argumentList, false); - }; - NormalModeFactory.prototype.switchStatement = function (switchKeyword, openParenToken, expression, closeParenToken, openBraceToken, switchClauses, closeBraceToken) { - return new TypeScript.SwitchStatementSyntax(switchKeyword, openParenToken, expression, closeParenToken, openBraceToken, switchClauses, closeBraceToken, false); - }; - NormalModeFactory.prototype.caseSwitchClause = function (caseKeyword, expression, colonToken, statements) { - return new TypeScript.CaseSwitchClauseSyntax(caseKeyword, expression, colonToken, statements, false); - }; - NormalModeFactory.prototype.defaultSwitchClause = function (defaultKeyword, colonToken, statements) { - return new TypeScript.DefaultSwitchClauseSyntax(defaultKeyword, colonToken, statements, false); - }; - NormalModeFactory.prototype.breakStatement = function (breakKeyword, identifier, semicolonToken) { - return new TypeScript.BreakStatementSyntax(breakKeyword, identifier, semicolonToken, false); - }; - NormalModeFactory.prototype.continueStatement = function (continueKeyword, identifier, semicolonToken) { - return new TypeScript.ContinueStatementSyntax(continueKeyword, identifier, semicolonToken, false); - }; - NormalModeFactory.prototype.forStatement = function (forKeyword, openParenToken, variableDeclaration, initializer, firstSemicolonToken, condition, secondSemicolonToken, incrementor, closeParenToken, statement) { - return new TypeScript.ForStatementSyntax(forKeyword, openParenToken, variableDeclaration, initializer, firstSemicolonToken, condition, secondSemicolonToken, incrementor, closeParenToken, statement, false); - }; - NormalModeFactory.prototype.forInStatement = function (forKeyword, openParenToken, variableDeclaration, left, inKeyword, expression, closeParenToken, statement) { - return new TypeScript.ForInStatementSyntax(forKeyword, openParenToken, variableDeclaration, left, inKeyword, expression, closeParenToken, statement, false); - }; - NormalModeFactory.prototype.whileStatement = function (whileKeyword, openParenToken, condition, closeParenToken, statement) { - return new TypeScript.WhileStatementSyntax(whileKeyword, openParenToken, condition, closeParenToken, statement, false); - }; - NormalModeFactory.prototype.withStatement = function (withKeyword, openParenToken, condition, closeParenToken, statement) { - return new TypeScript.WithStatementSyntax(withKeyword, openParenToken, condition, closeParenToken, statement, false); - }; - NormalModeFactory.prototype.enumDeclaration = function (modifiers, enumKeyword, identifier, openBraceToken, enumElements, closeBraceToken) { - return new TypeScript.EnumDeclarationSyntax(modifiers, enumKeyword, identifier, openBraceToken, enumElements, closeBraceToken, false); - }; - NormalModeFactory.prototype.enumElement = function (propertyName, equalsValueClause) { - return new TypeScript.EnumElementSyntax(propertyName, equalsValueClause, false); - }; - NormalModeFactory.prototype.castExpression = function (lessThanToken, type, greaterThanToken, expression) { - return new TypeScript.CastExpressionSyntax(lessThanToken, type, greaterThanToken, expression, false); - }; - NormalModeFactory.prototype.objectLiteralExpression = function (openBraceToken, propertyAssignments, closeBraceToken) { - return new TypeScript.ObjectLiteralExpressionSyntax(openBraceToken, propertyAssignments, closeBraceToken, false); - }; - NormalModeFactory.prototype.simplePropertyAssignment = function (propertyName, colonToken, expression) { - return new TypeScript.SimplePropertyAssignmentSyntax(propertyName, colonToken, expression, false); - }; - NormalModeFactory.prototype.functionPropertyAssignment = function (propertyName, callSignature, block) { - return new TypeScript.FunctionPropertyAssignmentSyntax(propertyName, callSignature, block, false); - }; - NormalModeFactory.prototype.getAccessorPropertyAssignment = function (getKeyword, propertyName, openParenToken, closeParenToken, typeAnnotation, block) { - return new TypeScript.GetAccessorPropertyAssignmentSyntax(getKeyword, propertyName, openParenToken, closeParenToken, typeAnnotation, block, false); - }; - NormalModeFactory.prototype.setAccessorPropertyAssignment = function (setKeyword, propertyName, openParenToken, parameter, closeParenToken, block) { - return new TypeScript.SetAccessorPropertyAssignmentSyntax(setKeyword, propertyName, openParenToken, parameter, closeParenToken, block, false); - }; - NormalModeFactory.prototype.functionExpression = function (functionKeyword, identifier, callSignature, block) { - return new TypeScript.FunctionExpressionSyntax(functionKeyword, identifier, callSignature, block, false); - }; - NormalModeFactory.prototype.emptyStatement = function (semicolonToken) { - return new TypeScript.EmptyStatementSyntax(semicolonToken, false); - }; - NormalModeFactory.prototype.tryStatement = function (tryKeyword, block, catchClause, finallyClause) { - return new TypeScript.TryStatementSyntax(tryKeyword, block, catchClause, finallyClause, false); - }; - NormalModeFactory.prototype.catchClause = function (catchKeyword, openParenToken, identifier, typeAnnotation, closeParenToken, block) { - return new TypeScript.CatchClauseSyntax(catchKeyword, openParenToken, identifier, typeAnnotation, closeParenToken, block, false); - }; - NormalModeFactory.prototype.finallyClause = function (finallyKeyword, block) { - return new TypeScript.FinallyClauseSyntax(finallyKeyword, block, false); - }; - NormalModeFactory.prototype.labeledStatement = function (identifier, colonToken, statement) { - return new TypeScript.LabeledStatementSyntax(identifier, colonToken, statement, false); - }; - NormalModeFactory.prototype.doStatement = function (doKeyword, statement, whileKeyword, openParenToken, condition, closeParenToken, semicolonToken) { - return new TypeScript.DoStatementSyntax(doKeyword, statement, whileKeyword, openParenToken, condition, closeParenToken, semicolonToken, false); - }; - NormalModeFactory.prototype.typeOfExpression = function (typeOfKeyword, expression) { - return new TypeScript.TypeOfExpressionSyntax(typeOfKeyword, expression, false); - }; - NormalModeFactory.prototype.deleteExpression = function (deleteKeyword, expression) { - return new TypeScript.DeleteExpressionSyntax(deleteKeyword, expression, false); - }; - NormalModeFactory.prototype.voidExpression = function (voidKeyword, expression) { - return new TypeScript.VoidExpressionSyntax(voidKeyword, expression, false); - }; - NormalModeFactory.prototype.debuggerStatement = function (debuggerKeyword, semicolonToken) { - return new TypeScript.DebuggerStatementSyntax(debuggerKeyword, semicolonToken, false); - }; - return NormalModeFactory; - })(); - Syntax.NormalModeFactory = NormalModeFactory; - - var StrictModeFactory = (function () { - function StrictModeFactory() { - } - StrictModeFactory.prototype.sourceUnit = function (moduleElements, endOfFileToken) { - return new TypeScript.SourceUnitSyntax(moduleElements, endOfFileToken, true); - }; - StrictModeFactory.prototype.externalModuleReference = function (moduleOrRequireKeyword, openParenToken, stringLiteral, closeParenToken) { - return new TypeScript.ExternalModuleReferenceSyntax(moduleOrRequireKeyword, openParenToken, stringLiteral, closeParenToken, true); - }; - StrictModeFactory.prototype.moduleNameModuleReference = function (moduleName) { - return new TypeScript.ModuleNameModuleReferenceSyntax(moduleName, true); - }; - StrictModeFactory.prototype.importDeclaration = function (importKeyword, identifier, equalsToken, moduleReference, semicolonToken) { - return new TypeScript.ImportDeclarationSyntax(importKeyword, identifier, equalsToken, moduleReference, semicolonToken, true); - }; - StrictModeFactory.prototype.exportAssignment = function (exportKeyword, equalsToken, identifier, semicolonToken) { - return new TypeScript.ExportAssignmentSyntax(exportKeyword, equalsToken, identifier, semicolonToken, true); - }; - StrictModeFactory.prototype.classDeclaration = function (modifiers, classKeyword, identifier, typeParameterList, heritageClauses, openBraceToken, classElements, closeBraceToken) { - return new TypeScript.ClassDeclarationSyntax(modifiers, classKeyword, identifier, typeParameterList, heritageClauses, openBraceToken, classElements, closeBraceToken, true); - }; - StrictModeFactory.prototype.interfaceDeclaration = function (modifiers, interfaceKeyword, identifier, typeParameterList, heritageClauses, body) { - return new TypeScript.InterfaceDeclarationSyntax(modifiers, interfaceKeyword, identifier, typeParameterList, heritageClauses, body, true); - }; - StrictModeFactory.prototype.heritageClause = function (extendsOrImplementsKeyword, typeNames) { - return new TypeScript.HeritageClauseSyntax(extendsOrImplementsKeyword, typeNames, true); - }; - StrictModeFactory.prototype.moduleDeclaration = function (modifiers, moduleKeyword, moduleName, stringLiteral, openBraceToken, moduleElements, closeBraceToken) { - return new TypeScript.ModuleDeclarationSyntax(modifiers, moduleKeyword, moduleName, stringLiteral, openBraceToken, moduleElements, closeBraceToken, true); - }; - StrictModeFactory.prototype.functionDeclaration = function (modifiers, functionKeyword, identifier, callSignature, block, semicolonToken) { - return new TypeScript.FunctionDeclarationSyntax(modifiers, functionKeyword, identifier, callSignature, block, semicolonToken, true); - }; - StrictModeFactory.prototype.variableStatement = function (modifiers, variableDeclaration, semicolonToken) { - return new TypeScript.VariableStatementSyntax(modifiers, variableDeclaration, semicolonToken, true); - }; - StrictModeFactory.prototype.variableDeclaration = function (varKeyword, variableDeclarators) { - return new TypeScript.VariableDeclarationSyntax(varKeyword, variableDeclarators, true); - }; - StrictModeFactory.prototype.variableDeclarator = function (identifier, typeAnnotation, equalsValueClause) { - return new TypeScript.VariableDeclaratorSyntax(identifier, typeAnnotation, equalsValueClause, true); - }; - StrictModeFactory.prototype.equalsValueClause = function (equalsToken, value) { - return new TypeScript.EqualsValueClauseSyntax(equalsToken, value, true); - }; - StrictModeFactory.prototype.prefixUnaryExpression = function (kind, operatorToken, operand) { - return new TypeScript.PrefixUnaryExpressionSyntax(kind, operatorToken, operand, true); - }; - StrictModeFactory.prototype.arrayLiteralExpression = function (openBracketToken, expressions, closeBracketToken) { - return new TypeScript.ArrayLiteralExpressionSyntax(openBracketToken, expressions, closeBracketToken, true); - }; - StrictModeFactory.prototype.omittedExpression = function () { - return new TypeScript.OmittedExpressionSyntax(true); - }; - StrictModeFactory.prototype.parenthesizedExpression = function (openParenToken, expression, closeParenToken) { - return new TypeScript.ParenthesizedExpressionSyntax(openParenToken, expression, closeParenToken, true); - }; - StrictModeFactory.prototype.simpleArrowFunctionExpression = function (identifier, equalsGreaterThanToken, body) { - return new TypeScript.SimpleArrowFunctionExpressionSyntax(identifier, equalsGreaterThanToken, body, true); - }; - StrictModeFactory.prototype.parenthesizedArrowFunctionExpression = function (callSignature, equalsGreaterThanToken, body) { - return new TypeScript.ParenthesizedArrowFunctionExpressionSyntax(callSignature, equalsGreaterThanToken, body, true); - }; - StrictModeFactory.prototype.qualifiedName = function (left, dotToken, right) { - return new TypeScript.QualifiedNameSyntax(left, dotToken, right, true); - }; - StrictModeFactory.prototype.typeArgumentList = function (lessThanToken, typeArguments, greaterThanToken) { - return new TypeScript.TypeArgumentListSyntax(lessThanToken, typeArguments, greaterThanToken, true); - }; - StrictModeFactory.prototype.constructorType = function (newKeyword, typeParameterList, parameterList, equalsGreaterThanToken, type) { - return new TypeScript.ConstructorTypeSyntax(newKeyword, typeParameterList, parameterList, equalsGreaterThanToken, type, true); - }; - StrictModeFactory.prototype.functionType = function (typeParameterList, parameterList, equalsGreaterThanToken, type) { - return new TypeScript.FunctionTypeSyntax(typeParameterList, parameterList, equalsGreaterThanToken, type, true); - }; - StrictModeFactory.prototype.objectType = function (openBraceToken, typeMembers, closeBraceToken) { - return new TypeScript.ObjectTypeSyntax(openBraceToken, typeMembers, closeBraceToken, true); - }; - StrictModeFactory.prototype.arrayType = function (type, openBracketToken, closeBracketToken) { - return new TypeScript.ArrayTypeSyntax(type, openBracketToken, closeBracketToken, true); - }; - StrictModeFactory.prototype.genericType = function (name, typeArgumentList) { - return new TypeScript.GenericTypeSyntax(name, typeArgumentList, true); - }; - StrictModeFactory.prototype.typeAnnotation = function (colonToken, type) { - return new TypeScript.TypeAnnotationSyntax(colonToken, type, true); - }; - StrictModeFactory.prototype.block = function (openBraceToken, statements, closeBraceToken) { - return new TypeScript.BlockSyntax(openBraceToken, statements, closeBraceToken, true); - }; - StrictModeFactory.prototype.parameter = function (dotDotDotToken, publicOrPrivateKeyword, identifier, questionToken, typeAnnotation, equalsValueClause) { - return new TypeScript.ParameterSyntax(dotDotDotToken, publicOrPrivateKeyword, identifier, questionToken, typeAnnotation, equalsValueClause, true); - }; - StrictModeFactory.prototype.memberAccessExpression = function (expression, dotToken, name) { - return new TypeScript.MemberAccessExpressionSyntax(expression, dotToken, name, true); - }; - StrictModeFactory.prototype.postfixUnaryExpression = function (kind, operand, operatorToken) { - return new TypeScript.PostfixUnaryExpressionSyntax(kind, operand, operatorToken, true); - }; - StrictModeFactory.prototype.elementAccessExpression = function (expression, openBracketToken, argumentExpression, closeBracketToken) { - return new TypeScript.ElementAccessExpressionSyntax(expression, openBracketToken, argumentExpression, closeBracketToken, true); - }; - StrictModeFactory.prototype.invocationExpression = function (expression, argumentList) { - return new TypeScript.InvocationExpressionSyntax(expression, argumentList, true); - }; - StrictModeFactory.prototype.argumentList = function (typeArgumentList, openParenToken, _arguments, closeParenToken) { - return new TypeScript.ArgumentListSyntax(typeArgumentList, openParenToken, _arguments, closeParenToken, true); - }; - StrictModeFactory.prototype.binaryExpression = function (kind, left, operatorToken, right) { - return new TypeScript.BinaryExpressionSyntax(kind, left, operatorToken, right, true); - }; - StrictModeFactory.prototype.conditionalExpression = function (condition, questionToken, whenTrue, colonToken, whenFalse) { - return new TypeScript.ConditionalExpressionSyntax(condition, questionToken, whenTrue, colonToken, whenFalse, true); - }; - StrictModeFactory.prototype.constructSignature = function (newKeyword, callSignature) { - return new TypeScript.ConstructSignatureSyntax(newKeyword, callSignature, true); - }; - StrictModeFactory.prototype.methodSignature = function (propertyName, questionToken, callSignature) { - return new TypeScript.MethodSignatureSyntax(propertyName, questionToken, callSignature, true); - }; - StrictModeFactory.prototype.indexSignature = function (openBracketToken, parameter, closeBracketToken, typeAnnotation) { - return new TypeScript.IndexSignatureSyntax(openBracketToken, parameter, closeBracketToken, typeAnnotation, true); - }; - StrictModeFactory.prototype.propertySignature = function (propertyName, questionToken, typeAnnotation) { - return new TypeScript.PropertySignatureSyntax(propertyName, questionToken, typeAnnotation, true); - }; - StrictModeFactory.prototype.callSignature = function (typeParameterList, parameterList, typeAnnotation) { - return new TypeScript.CallSignatureSyntax(typeParameterList, parameterList, typeAnnotation, true); - }; - StrictModeFactory.prototype.parameterList = function (openParenToken, parameters, closeParenToken) { - return new TypeScript.ParameterListSyntax(openParenToken, parameters, closeParenToken, true); - }; - StrictModeFactory.prototype.typeParameterList = function (lessThanToken, typeParameters, greaterThanToken) { - return new TypeScript.TypeParameterListSyntax(lessThanToken, typeParameters, greaterThanToken, true); - }; - StrictModeFactory.prototype.typeParameter = function (identifier, constraint) { - return new TypeScript.TypeParameterSyntax(identifier, constraint, true); - }; - StrictModeFactory.prototype.constraint = function (extendsKeyword, type) { - return new TypeScript.ConstraintSyntax(extendsKeyword, type, true); - }; - StrictModeFactory.prototype.elseClause = function (elseKeyword, statement) { - return new TypeScript.ElseClauseSyntax(elseKeyword, statement, true); - }; - StrictModeFactory.prototype.ifStatement = function (ifKeyword, openParenToken, condition, closeParenToken, statement, elseClause) { - return new TypeScript.IfStatementSyntax(ifKeyword, openParenToken, condition, closeParenToken, statement, elseClause, true); - }; - StrictModeFactory.prototype.expressionStatement = function (expression, semicolonToken) { - return new TypeScript.ExpressionStatementSyntax(expression, semicolonToken, true); - }; - StrictModeFactory.prototype.constructorDeclaration = function (constructorKeyword, parameterList, block, semicolonToken) { - return new TypeScript.ConstructorDeclarationSyntax(constructorKeyword, parameterList, block, semicolonToken, true); - }; - StrictModeFactory.prototype.memberFunctionDeclaration = function (modifiers, propertyName, callSignature, block, semicolonToken) { - return new TypeScript.MemberFunctionDeclarationSyntax(modifiers, propertyName, callSignature, block, semicolonToken, true); - }; - StrictModeFactory.prototype.getMemberAccessorDeclaration = function (modifiers, getKeyword, propertyName, parameterList, typeAnnotation, block) { - return new TypeScript.GetMemberAccessorDeclarationSyntax(modifiers, getKeyword, propertyName, parameterList, typeAnnotation, block, true); - }; - StrictModeFactory.prototype.setMemberAccessorDeclaration = function (modifiers, setKeyword, propertyName, parameterList, block) { - return new TypeScript.SetMemberAccessorDeclarationSyntax(modifiers, setKeyword, propertyName, parameterList, block, true); - }; - StrictModeFactory.prototype.memberVariableDeclaration = function (modifiers, variableDeclarator, semicolonToken) { - return new TypeScript.MemberVariableDeclarationSyntax(modifiers, variableDeclarator, semicolonToken, true); - }; - StrictModeFactory.prototype.throwStatement = function (throwKeyword, expression, semicolonToken) { - return new TypeScript.ThrowStatementSyntax(throwKeyword, expression, semicolonToken, true); - }; - StrictModeFactory.prototype.returnStatement = function (returnKeyword, expression, semicolonToken) { - return new TypeScript.ReturnStatementSyntax(returnKeyword, expression, semicolonToken, true); - }; - StrictModeFactory.prototype.objectCreationExpression = function (newKeyword, expression, argumentList) { - return new TypeScript.ObjectCreationExpressionSyntax(newKeyword, expression, argumentList, true); - }; - StrictModeFactory.prototype.switchStatement = function (switchKeyword, openParenToken, expression, closeParenToken, openBraceToken, switchClauses, closeBraceToken) { - return new TypeScript.SwitchStatementSyntax(switchKeyword, openParenToken, expression, closeParenToken, openBraceToken, switchClauses, closeBraceToken, true); - }; - StrictModeFactory.prototype.caseSwitchClause = function (caseKeyword, expression, colonToken, statements) { - return new TypeScript.CaseSwitchClauseSyntax(caseKeyword, expression, colonToken, statements, true); - }; - StrictModeFactory.prototype.defaultSwitchClause = function (defaultKeyword, colonToken, statements) { - return new TypeScript.DefaultSwitchClauseSyntax(defaultKeyword, colonToken, statements, true); - }; - StrictModeFactory.prototype.breakStatement = function (breakKeyword, identifier, semicolonToken) { - return new TypeScript.BreakStatementSyntax(breakKeyword, identifier, semicolonToken, true); - }; - StrictModeFactory.prototype.continueStatement = function (continueKeyword, identifier, semicolonToken) { - return new TypeScript.ContinueStatementSyntax(continueKeyword, identifier, semicolonToken, true); - }; - StrictModeFactory.prototype.forStatement = function (forKeyword, openParenToken, variableDeclaration, initializer, firstSemicolonToken, condition, secondSemicolonToken, incrementor, closeParenToken, statement) { - return new TypeScript.ForStatementSyntax(forKeyword, openParenToken, variableDeclaration, initializer, firstSemicolonToken, condition, secondSemicolonToken, incrementor, closeParenToken, statement, true); - }; - StrictModeFactory.prototype.forInStatement = function (forKeyword, openParenToken, variableDeclaration, left, inKeyword, expression, closeParenToken, statement) { - return new TypeScript.ForInStatementSyntax(forKeyword, openParenToken, variableDeclaration, left, inKeyword, expression, closeParenToken, statement, true); - }; - StrictModeFactory.prototype.whileStatement = function (whileKeyword, openParenToken, condition, closeParenToken, statement) { - return new TypeScript.WhileStatementSyntax(whileKeyword, openParenToken, condition, closeParenToken, statement, true); - }; - StrictModeFactory.prototype.withStatement = function (withKeyword, openParenToken, condition, closeParenToken, statement) { - return new TypeScript.WithStatementSyntax(withKeyword, openParenToken, condition, closeParenToken, statement, true); - }; - StrictModeFactory.prototype.enumDeclaration = function (modifiers, enumKeyword, identifier, openBraceToken, enumElements, closeBraceToken) { - return new TypeScript.EnumDeclarationSyntax(modifiers, enumKeyword, identifier, openBraceToken, enumElements, closeBraceToken, true); - }; - StrictModeFactory.prototype.enumElement = function (propertyName, equalsValueClause) { - return new TypeScript.EnumElementSyntax(propertyName, equalsValueClause, true); - }; - StrictModeFactory.prototype.castExpression = function (lessThanToken, type, greaterThanToken, expression) { - return new TypeScript.CastExpressionSyntax(lessThanToken, type, greaterThanToken, expression, true); - }; - StrictModeFactory.prototype.objectLiteralExpression = function (openBraceToken, propertyAssignments, closeBraceToken) { - return new TypeScript.ObjectLiteralExpressionSyntax(openBraceToken, propertyAssignments, closeBraceToken, true); - }; - StrictModeFactory.prototype.simplePropertyAssignment = function (propertyName, colonToken, expression) { - return new TypeScript.SimplePropertyAssignmentSyntax(propertyName, colonToken, expression, true); - }; - StrictModeFactory.prototype.functionPropertyAssignment = function (propertyName, callSignature, block) { - return new TypeScript.FunctionPropertyAssignmentSyntax(propertyName, callSignature, block, true); - }; - StrictModeFactory.prototype.getAccessorPropertyAssignment = function (getKeyword, propertyName, openParenToken, closeParenToken, typeAnnotation, block) { - return new TypeScript.GetAccessorPropertyAssignmentSyntax(getKeyword, propertyName, openParenToken, closeParenToken, typeAnnotation, block, true); - }; - StrictModeFactory.prototype.setAccessorPropertyAssignment = function (setKeyword, propertyName, openParenToken, parameter, closeParenToken, block) { - return new TypeScript.SetAccessorPropertyAssignmentSyntax(setKeyword, propertyName, openParenToken, parameter, closeParenToken, block, true); - }; - StrictModeFactory.prototype.functionExpression = function (functionKeyword, identifier, callSignature, block) { - return new TypeScript.FunctionExpressionSyntax(functionKeyword, identifier, callSignature, block, true); - }; - StrictModeFactory.prototype.emptyStatement = function (semicolonToken) { - return new TypeScript.EmptyStatementSyntax(semicolonToken, true); - }; - StrictModeFactory.prototype.tryStatement = function (tryKeyword, block, catchClause, finallyClause) { - return new TypeScript.TryStatementSyntax(tryKeyword, block, catchClause, finallyClause, true); - }; - StrictModeFactory.prototype.catchClause = function (catchKeyword, openParenToken, identifier, typeAnnotation, closeParenToken, block) { - return new TypeScript.CatchClauseSyntax(catchKeyword, openParenToken, identifier, typeAnnotation, closeParenToken, block, true); - }; - StrictModeFactory.prototype.finallyClause = function (finallyKeyword, block) { - return new TypeScript.FinallyClauseSyntax(finallyKeyword, block, true); - }; - StrictModeFactory.prototype.labeledStatement = function (identifier, colonToken, statement) { - return new TypeScript.LabeledStatementSyntax(identifier, colonToken, statement, true); - }; - StrictModeFactory.prototype.doStatement = function (doKeyword, statement, whileKeyword, openParenToken, condition, closeParenToken, semicolonToken) { - return new TypeScript.DoStatementSyntax(doKeyword, statement, whileKeyword, openParenToken, condition, closeParenToken, semicolonToken, true); - }; - StrictModeFactory.prototype.typeOfExpression = function (typeOfKeyword, expression) { - return new TypeScript.TypeOfExpressionSyntax(typeOfKeyword, expression, true); - }; - StrictModeFactory.prototype.deleteExpression = function (deleteKeyword, expression) { - return new TypeScript.DeleteExpressionSyntax(deleteKeyword, expression, true); - }; - StrictModeFactory.prototype.voidExpression = function (voidKeyword, expression) { - return new TypeScript.VoidExpressionSyntax(voidKeyword, expression, true); - }; - StrictModeFactory.prototype.debuggerStatement = function (debuggerKeyword, semicolonToken) { - return new TypeScript.DebuggerStatementSyntax(debuggerKeyword, semicolonToken, true); - }; - return StrictModeFactory; - })(); - Syntax.StrictModeFactory = StrictModeFactory; - - Syntax.normalModeFactory = new NormalModeFactory(); - Syntax.strictModeFactory = new StrictModeFactory(); - })(TypeScript.Syntax || (TypeScript.Syntax = {})); - var Syntax = TypeScript.Syntax; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (SyntaxKind) { - SyntaxKind[SyntaxKind["None"] = 0] = "None"; - SyntaxKind[SyntaxKind["List"] = 1] = "List"; - SyntaxKind[SyntaxKind["SeparatedList"] = 2] = "SeparatedList"; - SyntaxKind[SyntaxKind["TriviaList"] = 3] = "TriviaList"; - - SyntaxKind[SyntaxKind["WhitespaceTrivia"] = 4] = "WhitespaceTrivia"; - SyntaxKind[SyntaxKind["NewLineTrivia"] = 5] = "NewLineTrivia"; - SyntaxKind[SyntaxKind["MultiLineCommentTrivia"] = 6] = "MultiLineCommentTrivia"; - SyntaxKind[SyntaxKind["SingleLineCommentTrivia"] = 7] = "SingleLineCommentTrivia"; - SyntaxKind[SyntaxKind["SkippedTokenTrivia"] = 8] = "SkippedTokenTrivia"; - - SyntaxKind[SyntaxKind["ErrorToken"] = 9] = "ErrorToken"; - SyntaxKind[SyntaxKind["EndOfFileToken"] = 10] = "EndOfFileToken"; - - SyntaxKind[SyntaxKind["IdentifierName"] = 11] = "IdentifierName"; - - SyntaxKind[SyntaxKind["RegularExpressionLiteral"] = 12] = "RegularExpressionLiteral"; - SyntaxKind[SyntaxKind["NumericLiteral"] = 13] = "NumericLiteral"; - SyntaxKind[SyntaxKind["StringLiteral"] = 14] = "StringLiteral"; - - SyntaxKind[SyntaxKind["BreakKeyword"] = 15] = "BreakKeyword"; - SyntaxKind[SyntaxKind["CaseKeyword"] = 16] = "CaseKeyword"; - SyntaxKind[SyntaxKind["CatchKeyword"] = 17] = "CatchKeyword"; - SyntaxKind[SyntaxKind["ContinueKeyword"] = 18] = "ContinueKeyword"; - SyntaxKind[SyntaxKind["DebuggerKeyword"] = 19] = "DebuggerKeyword"; - SyntaxKind[SyntaxKind["DefaultKeyword"] = 20] = "DefaultKeyword"; - SyntaxKind[SyntaxKind["DeleteKeyword"] = 21] = "DeleteKeyword"; - SyntaxKind[SyntaxKind["DoKeyword"] = 22] = "DoKeyword"; - SyntaxKind[SyntaxKind["ElseKeyword"] = 23] = "ElseKeyword"; - SyntaxKind[SyntaxKind["FalseKeyword"] = 24] = "FalseKeyword"; - SyntaxKind[SyntaxKind["FinallyKeyword"] = 25] = "FinallyKeyword"; - SyntaxKind[SyntaxKind["ForKeyword"] = 26] = "ForKeyword"; - SyntaxKind[SyntaxKind["FunctionKeyword"] = 27] = "FunctionKeyword"; - SyntaxKind[SyntaxKind["IfKeyword"] = 28] = "IfKeyword"; - SyntaxKind[SyntaxKind["InKeyword"] = 29] = "InKeyword"; - SyntaxKind[SyntaxKind["InstanceOfKeyword"] = 30] = "InstanceOfKeyword"; - SyntaxKind[SyntaxKind["NewKeyword"] = 31] = "NewKeyword"; - SyntaxKind[SyntaxKind["NullKeyword"] = 32] = "NullKeyword"; - SyntaxKind[SyntaxKind["ReturnKeyword"] = 33] = "ReturnKeyword"; - SyntaxKind[SyntaxKind["SwitchKeyword"] = 34] = "SwitchKeyword"; - SyntaxKind[SyntaxKind["ThisKeyword"] = 35] = "ThisKeyword"; - SyntaxKind[SyntaxKind["ThrowKeyword"] = 36] = "ThrowKeyword"; - SyntaxKind[SyntaxKind["TrueKeyword"] = 37] = "TrueKeyword"; - SyntaxKind[SyntaxKind["TryKeyword"] = 38] = "TryKeyword"; - SyntaxKind[SyntaxKind["TypeOfKeyword"] = 39] = "TypeOfKeyword"; - SyntaxKind[SyntaxKind["VarKeyword"] = 40] = "VarKeyword"; - SyntaxKind[SyntaxKind["VoidKeyword"] = 41] = "VoidKeyword"; - SyntaxKind[SyntaxKind["WhileKeyword"] = 42] = "WhileKeyword"; - SyntaxKind[SyntaxKind["WithKeyword"] = 43] = "WithKeyword"; - - SyntaxKind[SyntaxKind["ClassKeyword"] = 44] = "ClassKeyword"; - SyntaxKind[SyntaxKind["ConstKeyword"] = 45] = "ConstKeyword"; - SyntaxKind[SyntaxKind["EnumKeyword"] = 46] = "EnumKeyword"; - SyntaxKind[SyntaxKind["ExportKeyword"] = 47] = "ExportKeyword"; - SyntaxKind[SyntaxKind["ExtendsKeyword"] = 48] = "ExtendsKeyword"; - SyntaxKind[SyntaxKind["ImportKeyword"] = 49] = "ImportKeyword"; - SyntaxKind[SyntaxKind["SuperKeyword"] = 50] = "SuperKeyword"; - - SyntaxKind[SyntaxKind["ImplementsKeyword"] = 51] = "ImplementsKeyword"; - SyntaxKind[SyntaxKind["InterfaceKeyword"] = 52] = "InterfaceKeyword"; - SyntaxKind[SyntaxKind["LetKeyword"] = 53] = "LetKeyword"; - SyntaxKind[SyntaxKind["PackageKeyword"] = 54] = "PackageKeyword"; - SyntaxKind[SyntaxKind["PrivateKeyword"] = 55] = "PrivateKeyword"; - SyntaxKind[SyntaxKind["ProtectedKeyword"] = 56] = "ProtectedKeyword"; - SyntaxKind[SyntaxKind["PublicKeyword"] = 57] = "PublicKeyword"; - SyntaxKind[SyntaxKind["StaticKeyword"] = 58] = "StaticKeyword"; - SyntaxKind[SyntaxKind["YieldKeyword"] = 59] = "YieldKeyword"; - - SyntaxKind[SyntaxKind["AnyKeyword"] = 60] = "AnyKeyword"; - SyntaxKind[SyntaxKind["BooleanKeyword"] = 61] = "BooleanKeyword"; - SyntaxKind[SyntaxKind["BoolKeyword"] = 62] = "BoolKeyword"; - SyntaxKind[SyntaxKind["ConstructorKeyword"] = 63] = "ConstructorKeyword"; - SyntaxKind[SyntaxKind["DeclareKeyword"] = 64] = "DeclareKeyword"; - SyntaxKind[SyntaxKind["GetKeyword"] = 65] = "GetKeyword"; - SyntaxKind[SyntaxKind["ModuleKeyword"] = 66] = "ModuleKeyword"; - SyntaxKind[SyntaxKind["RequireKeyword"] = 67] = "RequireKeyword"; - SyntaxKind[SyntaxKind["NumberKeyword"] = 68] = "NumberKeyword"; - SyntaxKind[SyntaxKind["SetKeyword"] = 69] = "SetKeyword"; - SyntaxKind[SyntaxKind["StringKeyword"] = 70] = "StringKeyword"; - - SyntaxKind[SyntaxKind["OpenBraceToken"] = 71] = "OpenBraceToken"; - SyntaxKind[SyntaxKind["CloseBraceToken"] = 72] = "CloseBraceToken"; - SyntaxKind[SyntaxKind["OpenParenToken"] = 73] = "OpenParenToken"; - SyntaxKind[SyntaxKind["CloseParenToken"] = 74] = "CloseParenToken"; - SyntaxKind[SyntaxKind["OpenBracketToken"] = 75] = "OpenBracketToken"; - SyntaxKind[SyntaxKind["CloseBracketToken"] = 76] = "CloseBracketToken"; - SyntaxKind[SyntaxKind["DotToken"] = 77] = "DotToken"; - SyntaxKind[SyntaxKind["DotDotDotToken"] = 78] = "DotDotDotToken"; - SyntaxKind[SyntaxKind["SemicolonToken"] = 79] = "SemicolonToken"; - SyntaxKind[SyntaxKind["CommaToken"] = 80] = "CommaToken"; - SyntaxKind[SyntaxKind["LessThanToken"] = 81] = "LessThanToken"; - SyntaxKind[SyntaxKind["GreaterThanToken"] = 82] = "GreaterThanToken"; - SyntaxKind[SyntaxKind["LessThanEqualsToken"] = 83] = "LessThanEqualsToken"; - SyntaxKind[SyntaxKind["GreaterThanEqualsToken"] = 84] = "GreaterThanEqualsToken"; - SyntaxKind[SyntaxKind["EqualsEqualsToken"] = 85] = "EqualsEqualsToken"; - SyntaxKind[SyntaxKind["EqualsGreaterThanToken"] = 86] = "EqualsGreaterThanToken"; - SyntaxKind[SyntaxKind["ExclamationEqualsToken"] = 87] = "ExclamationEqualsToken"; - SyntaxKind[SyntaxKind["EqualsEqualsEqualsToken"] = 88] = "EqualsEqualsEqualsToken"; - SyntaxKind[SyntaxKind["ExclamationEqualsEqualsToken"] = 89] = "ExclamationEqualsEqualsToken"; - SyntaxKind[SyntaxKind["PlusToken"] = 90] = "PlusToken"; - SyntaxKind[SyntaxKind["MinusToken"] = 91] = "MinusToken"; - SyntaxKind[SyntaxKind["AsteriskToken"] = 92] = "AsteriskToken"; - SyntaxKind[SyntaxKind["PercentToken"] = 93] = "PercentToken"; - SyntaxKind[SyntaxKind["PlusPlusToken"] = 94] = "PlusPlusToken"; - SyntaxKind[SyntaxKind["MinusMinusToken"] = 95] = "MinusMinusToken"; - SyntaxKind[SyntaxKind["LessThanLessThanToken"] = 96] = "LessThanLessThanToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanToken"] = 97] = "GreaterThanGreaterThanToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanToken"] = 98] = "GreaterThanGreaterThanGreaterThanToken"; - SyntaxKind[SyntaxKind["AmpersandToken"] = 99] = "AmpersandToken"; - SyntaxKind[SyntaxKind["BarToken"] = 100] = "BarToken"; - SyntaxKind[SyntaxKind["CaretToken"] = 101] = "CaretToken"; - SyntaxKind[SyntaxKind["ExclamationToken"] = 102] = "ExclamationToken"; - SyntaxKind[SyntaxKind["TildeToken"] = 103] = "TildeToken"; - SyntaxKind[SyntaxKind["AmpersandAmpersandToken"] = 104] = "AmpersandAmpersandToken"; - SyntaxKind[SyntaxKind["BarBarToken"] = 105] = "BarBarToken"; - SyntaxKind[SyntaxKind["QuestionToken"] = 106] = "QuestionToken"; - SyntaxKind[SyntaxKind["ColonToken"] = 107] = "ColonToken"; - SyntaxKind[SyntaxKind["EqualsToken"] = 108] = "EqualsToken"; - SyntaxKind[SyntaxKind["PlusEqualsToken"] = 109] = "PlusEqualsToken"; - SyntaxKind[SyntaxKind["MinusEqualsToken"] = 110] = "MinusEqualsToken"; - SyntaxKind[SyntaxKind["AsteriskEqualsToken"] = 111] = "AsteriskEqualsToken"; - SyntaxKind[SyntaxKind["PercentEqualsToken"] = 112] = "PercentEqualsToken"; - SyntaxKind[SyntaxKind["LessThanLessThanEqualsToken"] = 113] = "LessThanLessThanEqualsToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanEqualsToken"] = 114] = "GreaterThanGreaterThanEqualsToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanEqualsToken"] = 115] = "GreaterThanGreaterThanGreaterThanEqualsToken"; - SyntaxKind[SyntaxKind["AmpersandEqualsToken"] = 116] = "AmpersandEqualsToken"; - SyntaxKind[SyntaxKind["BarEqualsToken"] = 117] = "BarEqualsToken"; - SyntaxKind[SyntaxKind["CaretEqualsToken"] = 118] = "CaretEqualsToken"; - SyntaxKind[SyntaxKind["SlashToken"] = 119] = "SlashToken"; - SyntaxKind[SyntaxKind["SlashEqualsToken"] = 120] = "SlashEqualsToken"; - - SyntaxKind[SyntaxKind["SourceUnit"] = 121] = "SourceUnit"; - - SyntaxKind[SyntaxKind["QualifiedName"] = 122] = "QualifiedName"; - - SyntaxKind[SyntaxKind["ObjectType"] = 123] = "ObjectType"; - SyntaxKind[SyntaxKind["FunctionType"] = 124] = "FunctionType"; - SyntaxKind[SyntaxKind["ArrayType"] = 125] = "ArrayType"; - SyntaxKind[SyntaxKind["ConstructorType"] = 126] = "ConstructorType"; - SyntaxKind[SyntaxKind["GenericType"] = 127] = "GenericType"; - - SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 128] = "InterfaceDeclaration"; - SyntaxKind[SyntaxKind["FunctionDeclaration"] = 129] = "FunctionDeclaration"; - SyntaxKind[SyntaxKind["ModuleDeclaration"] = 130] = "ModuleDeclaration"; - SyntaxKind[SyntaxKind["ClassDeclaration"] = 131] = "ClassDeclaration"; - SyntaxKind[SyntaxKind["EnumDeclaration"] = 132] = "EnumDeclaration"; - SyntaxKind[SyntaxKind["ImportDeclaration"] = 133] = "ImportDeclaration"; - SyntaxKind[SyntaxKind["ExportAssignment"] = 134] = "ExportAssignment"; - - SyntaxKind[SyntaxKind["MemberFunctionDeclaration"] = 135] = "MemberFunctionDeclaration"; - SyntaxKind[SyntaxKind["MemberVariableDeclaration"] = 136] = "MemberVariableDeclaration"; - SyntaxKind[SyntaxKind["ConstructorDeclaration"] = 137] = "ConstructorDeclaration"; - SyntaxKind[SyntaxKind["GetMemberAccessorDeclaration"] = 138] = "GetMemberAccessorDeclaration"; - SyntaxKind[SyntaxKind["SetMemberAccessorDeclaration"] = 139] = "SetMemberAccessorDeclaration"; - - SyntaxKind[SyntaxKind["PropertySignature"] = 140] = "PropertySignature"; - SyntaxKind[SyntaxKind["CallSignature"] = 141] = "CallSignature"; - SyntaxKind[SyntaxKind["ConstructSignature"] = 142] = "ConstructSignature"; - SyntaxKind[SyntaxKind["IndexSignature"] = 143] = "IndexSignature"; - SyntaxKind[SyntaxKind["MethodSignature"] = 144] = "MethodSignature"; - - SyntaxKind[SyntaxKind["Block"] = 145] = "Block"; - SyntaxKind[SyntaxKind["IfStatement"] = 146] = "IfStatement"; - SyntaxKind[SyntaxKind["VariableStatement"] = 147] = "VariableStatement"; - SyntaxKind[SyntaxKind["ExpressionStatement"] = 148] = "ExpressionStatement"; - SyntaxKind[SyntaxKind["ReturnStatement"] = 149] = "ReturnStatement"; - SyntaxKind[SyntaxKind["SwitchStatement"] = 150] = "SwitchStatement"; - SyntaxKind[SyntaxKind["BreakStatement"] = 151] = "BreakStatement"; - SyntaxKind[SyntaxKind["ContinueStatement"] = 152] = "ContinueStatement"; - SyntaxKind[SyntaxKind["ForStatement"] = 153] = "ForStatement"; - SyntaxKind[SyntaxKind["ForInStatement"] = 154] = "ForInStatement"; - SyntaxKind[SyntaxKind["EmptyStatement"] = 155] = "EmptyStatement"; - SyntaxKind[SyntaxKind["ThrowStatement"] = 156] = "ThrowStatement"; - SyntaxKind[SyntaxKind["WhileStatement"] = 157] = "WhileStatement"; - SyntaxKind[SyntaxKind["TryStatement"] = 158] = "TryStatement"; - SyntaxKind[SyntaxKind["LabeledStatement"] = 159] = "LabeledStatement"; - SyntaxKind[SyntaxKind["DoStatement"] = 160] = "DoStatement"; - SyntaxKind[SyntaxKind["DebuggerStatement"] = 161] = "DebuggerStatement"; - SyntaxKind[SyntaxKind["WithStatement"] = 162] = "WithStatement"; - - SyntaxKind[SyntaxKind["PlusExpression"] = 163] = "PlusExpression"; - SyntaxKind[SyntaxKind["NegateExpression"] = 164] = "NegateExpression"; - SyntaxKind[SyntaxKind["BitwiseNotExpression"] = 165] = "BitwiseNotExpression"; - SyntaxKind[SyntaxKind["LogicalNotExpression"] = 166] = "LogicalNotExpression"; - SyntaxKind[SyntaxKind["PreIncrementExpression"] = 167] = "PreIncrementExpression"; - SyntaxKind[SyntaxKind["PreDecrementExpression"] = 168] = "PreDecrementExpression"; - SyntaxKind[SyntaxKind["DeleteExpression"] = 169] = "DeleteExpression"; - SyntaxKind[SyntaxKind["TypeOfExpression"] = 170] = "TypeOfExpression"; - SyntaxKind[SyntaxKind["VoidExpression"] = 171] = "VoidExpression"; - SyntaxKind[SyntaxKind["CommaExpression"] = 172] = "CommaExpression"; - SyntaxKind[SyntaxKind["AssignmentExpression"] = 173] = "AssignmentExpression"; - SyntaxKind[SyntaxKind["AddAssignmentExpression"] = 174] = "AddAssignmentExpression"; - SyntaxKind[SyntaxKind["SubtractAssignmentExpression"] = 175] = "SubtractAssignmentExpression"; - SyntaxKind[SyntaxKind["MultiplyAssignmentExpression"] = 176] = "MultiplyAssignmentExpression"; - SyntaxKind[SyntaxKind["DivideAssignmentExpression"] = 177] = "DivideAssignmentExpression"; - SyntaxKind[SyntaxKind["ModuloAssignmentExpression"] = 178] = "ModuloAssignmentExpression"; - SyntaxKind[SyntaxKind["AndAssignmentExpression"] = 179] = "AndAssignmentExpression"; - SyntaxKind[SyntaxKind["ExclusiveOrAssignmentExpression"] = 180] = "ExclusiveOrAssignmentExpression"; - SyntaxKind[SyntaxKind["OrAssignmentExpression"] = 181] = "OrAssignmentExpression"; - SyntaxKind[SyntaxKind["LeftShiftAssignmentExpression"] = 182] = "LeftShiftAssignmentExpression"; - SyntaxKind[SyntaxKind["SignedRightShiftAssignmentExpression"] = 183] = "SignedRightShiftAssignmentExpression"; - SyntaxKind[SyntaxKind["UnsignedRightShiftAssignmentExpression"] = 184] = "UnsignedRightShiftAssignmentExpression"; - SyntaxKind[SyntaxKind["ConditionalExpression"] = 185] = "ConditionalExpression"; - SyntaxKind[SyntaxKind["LogicalOrExpression"] = 186] = "LogicalOrExpression"; - SyntaxKind[SyntaxKind["LogicalAndExpression"] = 187] = "LogicalAndExpression"; - SyntaxKind[SyntaxKind["BitwiseOrExpression"] = 188] = "BitwiseOrExpression"; - SyntaxKind[SyntaxKind["BitwiseExclusiveOrExpression"] = 189] = "BitwiseExclusiveOrExpression"; - SyntaxKind[SyntaxKind["BitwiseAndExpression"] = 190] = "BitwiseAndExpression"; - SyntaxKind[SyntaxKind["EqualsWithTypeConversionExpression"] = 191] = "EqualsWithTypeConversionExpression"; - SyntaxKind[SyntaxKind["NotEqualsWithTypeConversionExpression"] = 192] = "NotEqualsWithTypeConversionExpression"; - SyntaxKind[SyntaxKind["EqualsExpression"] = 193] = "EqualsExpression"; - SyntaxKind[SyntaxKind["NotEqualsExpression"] = 194] = "NotEqualsExpression"; - SyntaxKind[SyntaxKind["LessThanExpression"] = 195] = "LessThanExpression"; - SyntaxKind[SyntaxKind["GreaterThanExpression"] = 196] = "GreaterThanExpression"; - SyntaxKind[SyntaxKind["LessThanOrEqualExpression"] = 197] = "LessThanOrEqualExpression"; - SyntaxKind[SyntaxKind["GreaterThanOrEqualExpression"] = 198] = "GreaterThanOrEqualExpression"; - SyntaxKind[SyntaxKind["InstanceOfExpression"] = 199] = "InstanceOfExpression"; - SyntaxKind[SyntaxKind["InExpression"] = 200] = "InExpression"; - SyntaxKind[SyntaxKind["LeftShiftExpression"] = 201] = "LeftShiftExpression"; - SyntaxKind[SyntaxKind["SignedRightShiftExpression"] = 202] = "SignedRightShiftExpression"; - SyntaxKind[SyntaxKind["UnsignedRightShiftExpression"] = 203] = "UnsignedRightShiftExpression"; - SyntaxKind[SyntaxKind["MultiplyExpression"] = 204] = "MultiplyExpression"; - SyntaxKind[SyntaxKind["DivideExpression"] = 205] = "DivideExpression"; - SyntaxKind[SyntaxKind["ModuloExpression"] = 206] = "ModuloExpression"; - SyntaxKind[SyntaxKind["AddExpression"] = 207] = "AddExpression"; - SyntaxKind[SyntaxKind["SubtractExpression"] = 208] = "SubtractExpression"; - SyntaxKind[SyntaxKind["PostIncrementExpression"] = 209] = "PostIncrementExpression"; - SyntaxKind[SyntaxKind["PostDecrementExpression"] = 210] = "PostDecrementExpression"; - SyntaxKind[SyntaxKind["MemberAccessExpression"] = 211] = "MemberAccessExpression"; - SyntaxKind[SyntaxKind["InvocationExpression"] = 212] = "InvocationExpression"; - SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 213] = "ArrayLiteralExpression"; - SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 214] = "ObjectLiteralExpression"; - SyntaxKind[SyntaxKind["ObjectCreationExpression"] = 215] = "ObjectCreationExpression"; - SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 216] = "ParenthesizedExpression"; - SyntaxKind[SyntaxKind["ParenthesizedArrowFunctionExpression"] = 217] = "ParenthesizedArrowFunctionExpression"; - SyntaxKind[SyntaxKind["SimpleArrowFunctionExpression"] = 218] = "SimpleArrowFunctionExpression"; - SyntaxKind[SyntaxKind["CastExpression"] = 219] = "CastExpression"; - SyntaxKind[SyntaxKind["ElementAccessExpression"] = 220] = "ElementAccessExpression"; - SyntaxKind[SyntaxKind["FunctionExpression"] = 221] = "FunctionExpression"; - SyntaxKind[SyntaxKind["OmittedExpression"] = 222] = "OmittedExpression"; - - SyntaxKind[SyntaxKind["VariableDeclaration"] = 223] = "VariableDeclaration"; - SyntaxKind[SyntaxKind["VariableDeclarator"] = 224] = "VariableDeclarator"; - - SyntaxKind[SyntaxKind["ArgumentList"] = 225] = "ArgumentList"; - SyntaxKind[SyntaxKind["ParameterList"] = 226] = "ParameterList"; - SyntaxKind[SyntaxKind["TypeArgumentList"] = 227] = "TypeArgumentList"; - SyntaxKind[SyntaxKind["TypeParameterList"] = 228] = "TypeParameterList"; - - SyntaxKind[SyntaxKind["HeritageClause"] = 229] = "HeritageClause"; - SyntaxKind[SyntaxKind["EqualsValueClause"] = 230] = "EqualsValueClause"; - SyntaxKind[SyntaxKind["CaseSwitchClause"] = 231] = "CaseSwitchClause"; - SyntaxKind[SyntaxKind["DefaultSwitchClause"] = 232] = "DefaultSwitchClause"; - SyntaxKind[SyntaxKind["ElseClause"] = 233] = "ElseClause"; - SyntaxKind[SyntaxKind["CatchClause"] = 234] = "CatchClause"; - SyntaxKind[SyntaxKind["FinallyClause"] = 235] = "FinallyClause"; - - SyntaxKind[SyntaxKind["TypeParameter"] = 236] = "TypeParameter"; - SyntaxKind[SyntaxKind["Constraint"] = 237] = "Constraint"; - - SyntaxKind[SyntaxKind["SimplePropertyAssignment"] = 238] = "SimplePropertyAssignment"; - SyntaxKind[SyntaxKind["GetAccessorPropertyAssignment"] = 239] = "GetAccessorPropertyAssignment"; - SyntaxKind[SyntaxKind["SetAccessorPropertyAssignment"] = 240] = "SetAccessorPropertyAssignment"; - SyntaxKind[SyntaxKind["FunctionPropertyAssignment"] = 241] = "FunctionPropertyAssignment"; - - SyntaxKind[SyntaxKind["Parameter"] = 242] = "Parameter"; - SyntaxKind[SyntaxKind["EnumElement"] = 243] = "EnumElement"; - SyntaxKind[SyntaxKind["TypeAnnotation"] = 244] = "TypeAnnotation"; - SyntaxKind[SyntaxKind["ExternalModuleReference"] = 245] = "ExternalModuleReference"; - SyntaxKind[SyntaxKind["ModuleNameModuleReference"] = 246] = "ModuleNameModuleReference"; - - SyntaxKind[SyntaxKind["FirstStandardKeyword"] = SyntaxKind.BreakKeyword] = "FirstStandardKeyword"; - SyntaxKind[SyntaxKind["LastStandardKeyword"] = SyntaxKind.WithKeyword] = "LastStandardKeyword"; - - SyntaxKind[SyntaxKind["FirstFutureReservedKeyword"] = SyntaxKind.ClassKeyword] = "FirstFutureReservedKeyword"; - SyntaxKind[SyntaxKind["LastFutureReservedKeyword"] = SyntaxKind.SuperKeyword] = "LastFutureReservedKeyword"; - - SyntaxKind[SyntaxKind["FirstFutureReservedStrictKeyword"] = SyntaxKind.ImplementsKeyword] = "FirstFutureReservedStrictKeyword"; - SyntaxKind[SyntaxKind["LastFutureReservedStrictKeyword"] = SyntaxKind.YieldKeyword] = "LastFutureReservedStrictKeyword"; - - SyntaxKind[SyntaxKind["FirstTypeScriptKeyword"] = SyntaxKind.AnyKeyword] = "FirstTypeScriptKeyword"; - SyntaxKind[SyntaxKind["LastTypeScriptKeyword"] = SyntaxKind.StringKeyword] = "LastTypeScriptKeyword"; - - SyntaxKind[SyntaxKind["FirstKeyword"] = SyntaxKind.FirstStandardKeyword] = "FirstKeyword"; - SyntaxKind[SyntaxKind["LastKeyword"] = SyntaxKind.LastTypeScriptKeyword] = "LastKeyword"; - - SyntaxKind[SyntaxKind["FirstToken"] = SyntaxKind.ErrorToken] = "FirstToken"; - SyntaxKind[SyntaxKind["LastToken"] = SyntaxKind.SlashEqualsToken] = "LastToken"; - - SyntaxKind[SyntaxKind["FirstPunctuation"] = SyntaxKind.OpenBraceToken] = "FirstPunctuation"; - SyntaxKind[SyntaxKind["LastPunctuation"] = SyntaxKind.SlashEqualsToken] = "LastPunctuation"; - - SyntaxKind[SyntaxKind["FirstFixedWidth"] = SyntaxKind.FirstKeyword] = "FirstFixedWidth"; - SyntaxKind[SyntaxKind["LastFixedWidth"] = SyntaxKind.LastPunctuation] = "LastFixedWidth"; - })(TypeScript.SyntaxKind || (TypeScript.SyntaxKind = {})); - var SyntaxKind = TypeScript.SyntaxKind; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (SyntaxFacts) { - var textToKeywordKind = { - "any": 60 /* AnyKeyword */, - "bool": 62 /* BoolKeyword */, - "boolean": 61 /* BooleanKeyword */, - "break": 15 /* BreakKeyword */, - "case": 16 /* CaseKeyword */, - "catch": 17 /* CatchKeyword */, - "class": 44 /* ClassKeyword */, - "continue": 18 /* ContinueKeyword */, - "const": 45 /* ConstKeyword */, - "constructor": 63 /* ConstructorKeyword */, - "debugger": 19 /* DebuggerKeyword */, - "declare": 64 /* DeclareKeyword */, - "default": 20 /* DefaultKeyword */, - "delete": 21 /* DeleteKeyword */, - "do": 22 /* DoKeyword */, - "else": 23 /* ElseKeyword */, - "enum": 46 /* EnumKeyword */, - "export": 47 /* ExportKeyword */, - "extends": 48 /* ExtendsKeyword */, - "false": 24 /* FalseKeyword */, - "finally": 25 /* FinallyKeyword */, - "for": 26 /* ForKeyword */, - "function": 27 /* FunctionKeyword */, - "get": 65 /* GetKeyword */, - "if": 28 /* IfKeyword */, - "implements": 51 /* ImplementsKeyword */, - "import": 49 /* ImportKeyword */, - "in": 29 /* InKeyword */, - "instanceof": 30 /* InstanceOfKeyword */, - "interface": 52 /* InterfaceKeyword */, - "let": 53 /* LetKeyword */, - "module": 66 /* ModuleKeyword */, - "new": 31 /* NewKeyword */, - "null": 32 /* NullKeyword */, - "number": 68 /* NumberKeyword */, - "package": 54 /* PackageKeyword */, - "private": 55 /* PrivateKeyword */, - "protected": 56 /* ProtectedKeyword */, - "public": 57 /* PublicKeyword */, - "require": 67 /* RequireKeyword */, - "return": 33 /* ReturnKeyword */, - "set": 69 /* SetKeyword */, - "static": 58 /* StaticKeyword */, - "string": 70 /* StringKeyword */, - "super": 50 /* SuperKeyword */, - "switch": 34 /* SwitchKeyword */, - "this": 35 /* ThisKeyword */, - "throw": 36 /* ThrowKeyword */, - "true": 37 /* TrueKeyword */, - "try": 38 /* TryKeyword */, - "typeof": 39 /* TypeOfKeyword */, - "var": 40 /* VarKeyword */, - "void": 41 /* VoidKeyword */, - "while": 42 /* WhileKeyword */, - "with": 43 /* WithKeyword */, - "yield": 59 /* YieldKeyword */, - "{": 71 /* OpenBraceToken */, - "}": 72 /* CloseBraceToken */, - "(": 73 /* OpenParenToken */, - ")": 74 /* CloseParenToken */, - "[": 75 /* OpenBracketToken */, - "]": 76 /* CloseBracketToken */, - ".": 77 /* DotToken */, - "...": 78 /* DotDotDotToken */, - ";": 79 /* SemicolonToken */, - ",": 80 /* CommaToken */, - "<": 81 /* LessThanToken */, - ">": 82 /* GreaterThanToken */, - "<=": 83 /* LessThanEqualsToken */, - ">=": 84 /* GreaterThanEqualsToken */, - "==": 85 /* EqualsEqualsToken */, - "=>": 86 /* EqualsGreaterThanToken */, - "!=": 87 /* ExclamationEqualsToken */, - "===": 88 /* EqualsEqualsEqualsToken */, - "!==": 89 /* ExclamationEqualsEqualsToken */, - "+": 90 /* PlusToken */, - "-": 91 /* MinusToken */, - "*": 92 /* AsteriskToken */, - "%": 93 /* PercentToken */, - "++": 94 /* PlusPlusToken */, - "--": 95 /* MinusMinusToken */, - "<<": 96 /* LessThanLessThanToken */, - ">>": 97 /* GreaterThanGreaterThanToken */, - ">>>": 98 /* GreaterThanGreaterThanGreaterThanToken */, - "&": 99 /* AmpersandToken */, - "|": 100 /* BarToken */, - "^": 101 /* CaretToken */, - "!": 102 /* ExclamationToken */, - "~": 103 /* TildeToken */, - "&&": 104 /* AmpersandAmpersandToken */, - "||": 105 /* BarBarToken */, - "?": 106 /* QuestionToken */, - ":": 107 /* ColonToken */, - "=": 108 /* EqualsToken */, - "+=": 109 /* PlusEqualsToken */, - "-=": 110 /* MinusEqualsToken */, - "*=": 111 /* AsteriskEqualsToken */, - "%=": 112 /* PercentEqualsToken */, - "<<=": 113 /* LessThanLessThanEqualsToken */, - ">>=": 114 /* GreaterThanGreaterThanEqualsToken */, - ">>>=": 115 /* GreaterThanGreaterThanGreaterThanEqualsToken */, - "&=": 116 /* AmpersandEqualsToken */, - "|=": 117 /* BarEqualsToken */, - "^=": 118 /* CaretEqualsToken */, - "/": 119 /* SlashToken */, - "/=": 120 /* SlashEqualsToken */ - }; - - var kindToText = []; - - for (var name in textToKeywordKind) { - if (textToKeywordKind.hasOwnProperty(name)) { - kindToText[textToKeywordKind[name]] = name; - } - } - - kindToText[63 /* ConstructorKeyword */] = "constructor"; - - function getTokenKind(text) { - if (textToKeywordKind.hasOwnProperty(text)) { - return textToKeywordKind[text]; - } - - return 0 /* None */; - } - SyntaxFacts.getTokenKind = getTokenKind; - - function getText(kind) { - var result = kindToText[kind]; - return result !== undefined ? result : null; - } - SyntaxFacts.getText = getText; - - function isTokenKind(kind) { - return kind >= 9 /* FirstToken */ && kind <= 120 /* LastToken */; - } - SyntaxFacts.isTokenKind = isTokenKind; - - function isAnyKeyword(kind) { - return kind >= TypeScript.SyntaxKind.FirstKeyword && kind <= TypeScript.SyntaxKind.LastKeyword; - } - SyntaxFacts.isAnyKeyword = isAnyKeyword; - - function isStandardKeyword(kind) { - return kind >= 15 /* FirstStandardKeyword */ && kind <= 43 /* LastStandardKeyword */; - } - SyntaxFacts.isStandardKeyword = isStandardKeyword; - - function isFutureReservedKeyword(kind) { - return kind >= 44 /* FirstFutureReservedKeyword */ && kind <= 50 /* LastFutureReservedKeyword */; - } - SyntaxFacts.isFutureReservedKeyword = isFutureReservedKeyword; - - function isFutureReservedStrictKeyword(kind) { - return kind >= 51 /* FirstFutureReservedStrictKeyword */ && kind <= 59 /* LastFutureReservedStrictKeyword */; - } - SyntaxFacts.isFutureReservedStrictKeyword = isFutureReservedStrictKeyword; - - function isAnyPunctuation(kind) { - return kind >= 71 /* FirstPunctuation */ && kind <= 120 /* LastPunctuation */; - } - SyntaxFacts.isAnyPunctuation = isAnyPunctuation; - - function isPrefixUnaryExpressionOperatorToken(tokenKind) { - return getPrefixUnaryExpressionFromOperatorToken(tokenKind) !== 0 /* None */; - } - SyntaxFacts.isPrefixUnaryExpressionOperatorToken = isPrefixUnaryExpressionOperatorToken; - - function isBinaryExpressionOperatorToken(tokenKind) { - return getBinaryExpressionFromOperatorToken(tokenKind) !== 0 /* None */; - } - SyntaxFacts.isBinaryExpressionOperatorToken = isBinaryExpressionOperatorToken; - - function getPrefixUnaryExpressionFromOperatorToken(tokenKind) { - switch (tokenKind) { - case 90 /* PlusToken */: - return 163 /* PlusExpression */; - case 91 /* MinusToken */: - return 164 /* NegateExpression */; - case 103 /* TildeToken */: - return 165 /* BitwiseNotExpression */; - case 102 /* ExclamationToken */: - return 166 /* LogicalNotExpression */; - case 94 /* PlusPlusToken */: - return 167 /* PreIncrementExpression */; - case 95 /* MinusMinusToken */: - return 168 /* PreDecrementExpression */; - - default: - return 0 /* None */; - } - } - SyntaxFacts.getPrefixUnaryExpressionFromOperatorToken = getPrefixUnaryExpressionFromOperatorToken; - - function getPostfixUnaryExpressionFromOperatorToken(tokenKind) { - switch (tokenKind) { - case 94 /* PlusPlusToken */: - return 209 /* PostIncrementExpression */; - case 95 /* MinusMinusToken */: - return 210 /* PostDecrementExpression */; - default: - return 0 /* None */; - } - } - SyntaxFacts.getPostfixUnaryExpressionFromOperatorToken = getPostfixUnaryExpressionFromOperatorToken; - - function getBinaryExpressionFromOperatorToken(tokenKind) { - switch (tokenKind) { - case 92 /* AsteriskToken */: - return 204 /* MultiplyExpression */; - - case 119 /* SlashToken */: - return 205 /* DivideExpression */; - - case 93 /* PercentToken */: - return 206 /* ModuloExpression */; - - case 90 /* PlusToken */: - return 207 /* AddExpression */; - - case 91 /* MinusToken */: - return 208 /* SubtractExpression */; - - case 96 /* LessThanLessThanToken */: - return 201 /* LeftShiftExpression */; - - case 97 /* GreaterThanGreaterThanToken */: - return 202 /* SignedRightShiftExpression */; - - case 98 /* GreaterThanGreaterThanGreaterThanToken */: - return 203 /* UnsignedRightShiftExpression */; - - case 81 /* LessThanToken */: - return 195 /* LessThanExpression */; - - case 82 /* GreaterThanToken */: - return 196 /* GreaterThanExpression */; - - case 83 /* LessThanEqualsToken */: - return 197 /* LessThanOrEqualExpression */; - - case 84 /* GreaterThanEqualsToken */: - return 198 /* GreaterThanOrEqualExpression */; - - case 30 /* InstanceOfKeyword */: - return 199 /* InstanceOfExpression */; - - case 29 /* InKeyword */: - return 200 /* InExpression */; - - case 85 /* EqualsEqualsToken */: - return 191 /* EqualsWithTypeConversionExpression */; - - case 87 /* ExclamationEqualsToken */: - return 192 /* NotEqualsWithTypeConversionExpression */; - - case 88 /* EqualsEqualsEqualsToken */: - return 193 /* EqualsExpression */; - - case 89 /* ExclamationEqualsEqualsToken */: - return 194 /* NotEqualsExpression */; - - case 99 /* AmpersandToken */: - return 190 /* BitwiseAndExpression */; - - case 101 /* CaretToken */: - return 189 /* BitwiseExclusiveOrExpression */; - - case 100 /* BarToken */: - return 188 /* BitwiseOrExpression */; - - case 104 /* AmpersandAmpersandToken */: - return 187 /* LogicalAndExpression */; - - case 105 /* BarBarToken */: - return 186 /* LogicalOrExpression */; - - case 117 /* BarEqualsToken */: - return 181 /* OrAssignmentExpression */; - - case 116 /* AmpersandEqualsToken */: - return 179 /* AndAssignmentExpression */; - - case 118 /* CaretEqualsToken */: - return 180 /* ExclusiveOrAssignmentExpression */; - - case 113 /* LessThanLessThanEqualsToken */: - return 182 /* LeftShiftAssignmentExpression */; - - case 114 /* GreaterThanGreaterThanEqualsToken */: - return 183 /* SignedRightShiftAssignmentExpression */; - - case 115 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - return 184 /* UnsignedRightShiftAssignmentExpression */; - - case 109 /* PlusEqualsToken */: - return 174 /* AddAssignmentExpression */; - - case 110 /* MinusEqualsToken */: - return 175 /* SubtractAssignmentExpression */; - - case 111 /* AsteriskEqualsToken */: - return 176 /* MultiplyAssignmentExpression */; - - case 120 /* SlashEqualsToken */: - return 177 /* DivideAssignmentExpression */; - - case 112 /* PercentEqualsToken */: - return 178 /* ModuloAssignmentExpression */; - - case 108 /* EqualsToken */: - return 173 /* AssignmentExpression */; - - case 80 /* CommaToken */: - return 172 /* CommaExpression */; - - default: - return 0 /* None */; - } - } - SyntaxFacts.getBinaryExpressionFromOperatorToken = getBinaryExpressionFromOperatorToken; - - function isAnyDivideToken(kind) { - switch (kind) { - case 119 /* SlashToken */: - case 120 /* SlashEqualsToken */: - return true; - default: - return false; - } - } - SyntaxFacts.isAnyDivideToken = isAnyDivideToken; - - function isAnyDivideOrRegularExpressionToken(kind) { - switch (kind) { - case 119 /* SlashToken */: - case 120 /* SlashEqualsToken */: - case 12 /* RegularExpressionLiteral */: - return true; - default: - return false; - } - } - SyntaxFacts.isAnyDivideOrRegularExpressionToken = isAnyDivideOrRegularExpressionToken; - - function isParserGenerated(kind) { - switch (kind) { - case 97 /* GreaterThanGreaterThanToken */: - case 98 /* GreaterThanGreaterThanGreaterThanToken */: - case 84 /* GreaterThanEqualsToken */: - case 114 /* GreaterThanGreaterThanEqualsToken */: - case 115 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - return true; - default: - return false; - } - } - SyntaxFacts.isParserGenerated = isParserGenerated; - - function isAnyBinaryExpression(kind) { - switch (kind) { - case 172 /* CommaExpression */: - case 173 /* AssignmentExpression */: - case 174 /* AddAssignmentExpression */: - case 175 /* SubtractAssignmentExpression */: - case 176 /* MultiplyAssignmentExpression */: - case 177 /* DivideAssignmentExpression */: - case 178 /* ModuloAssignmentExpression */: - case 179 /* AndAssignmentExpression */: - case 180 /* ExclusiveOrAssignmentExpression */: - case 181 /* OrAssignmentExpression */: - case 182 /* LeftShiftAssignmentExpression */: - case 183 /* SignedRightShiftAssignmentExpression */: - case 184 /* UnsignedRightShiftAssignmentExpression */: - case 186 /* LogicalOrExpression */: - case 187 /* LogicalAndExpression */: - case 188 /* BitwiseOrExpression */: - case 189 /* BitwiseExclusiveOrExpression */: - case 190 /* BitwiseAndExpression */: - case 191 /* EqualsWithTypeConversionExpression */: - case 192 /* NotEqualsWithTypeConversionExpression */: - case 193 /* EqualsExpression */: - case 194 /* NotEqualsExpression */: - case 195 /* LessThanExpression */: - case 196 /* GreaterThanExpression */: - case 197 /* LessThanOrEqualExpression */: - case 198 /* GreaterThanOrEqualExpression */: - case 199 /* InstanceOfExpression */: - case 200 /* InExpression */: - case 201 /* LeftShiftExpression */: - case 202 /* SignedRightShiftExpression */: - case 203 /* UnsignedRightShiftExpression */: - case 204 /* MultiplyExpression */: - case 205 /* DivideExpression */: - case 206 /* ModuloExpression */: - case 207 /* AddExpression */: - case 208 /* SubtractExpression */: - return true; - } - - return false; - } - SyntaxFacts.isAnyBinaryExpression = isAnyBinaryExpression; - })(TypeScript.SyntaxFacts || (TypeScript.SyntaxFacts = {})); - var SyntaxFacts = TypeScript.SyntaxFacts; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (SyntaxFacts) { - function isDirectivePrologueElement(node) { - if (node.kind() === 148 /* ExpressionStatement */) { - var expressionStatement = node; - var expression = expressionStatement.expression; - - if (expression.kind() === 14 /* StringLiteral */) { - return true; - } - } - - return false; - } - SyntaxFacts.isDirectivePrologueElement = isDirectivePrologueElement; - - function isUseStrictDirective(node) { - var expressionStatement = node; - var stringLiteral = expressionStatement.expression; - - var text = stringLiteral.text(); - return text === '"use strict"' || text === "'use strict'"; - } - SyntaxFacts.isUseStrictDirective = isUseStrictDirective; - - function isIdentifierNameOrAnyKeyword(token) { - var tokenKind = token.tokenKind; - return tokenKind === 11 /* IdentifierName */ || TypeScript.SyntaxFacts.isAnyKeyword(tokenKind); - } - SyntaxFacts.isIdentifierNameOrAnyKeyword = isIdentifierNameOrAnyKeyword; - })(TypeScript.SyntaxFacts || (TypeScript.SyntaxFacts = {})); - var SyntaxFacts = TypeScript.SyntaxFacts; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (Syntax) { - var EmptySyntaxList = (function () { - function EmptySyntaxList() { - } - EmptySyntaxList.prototype.kind = function () { - return 1 /* List */; - }; - - EmptySyntaxList.prototype.isNode = function () { - return false; - }; - EmptySyntaxList.prototype.isToken = function () { - return false; - }; - EmptySyntaxList.prototype.isList = function () { - return true; - }; - EmptySyntaxList.prototype.isSeparatedList = function () { - return false; - }; - - EmptySyntaxList.prototype.toJSON = function (key) { - return []; - }; - - EmptySyntaxList.prototype.childCount = function () { - return 0; - }; - - EmptySyntaxList.prototype.childAt = function (index) { - throw TypeScript.Errors.argumentOutOfRange("index"); - }; - - EmptySyntaxList.prototype.toArray = function () { - return []; - }; - - EmptySyntaxList.prototype.collectTextElements = function (elements) { - }; - - EmptySyntaxList.prototype.firstToken = function () { - return null; - }; - - EmptySyntaxList.prototype.lastToken = function () { - return null; - }; - - EmptySyntaxList.prototype.fullWidth = function () { - return 0; - }; - - EmptySyntaxList.prototype.width = function () { - return 0; - }; - - EmptySyntaxList.prototype.leadingTrivia = function () { - return TypeScript.Syntax.emptyTriviaList; - }; - - EmptySyntaxList.prototype.trailingTrivia = function () { - return TypeScript.Syntax.emptyTriviaList; - }; - - EmptySyntaxList.prototype.leadingTriviaWidth = function () { - return 0; - }; - - EmptySyntaxList.prototype.trailingTriviaWidth = function () { - return 0; - }; - - EmptySyntaxList.prototype.fullText = function () { - return ""; - }; - - EmptySyntaxList.prototype.isTypeScriptSpecific = function () { - return false; - }; - - EmptySyntaxList.prototype.isIncrementallyUnusable = function () { - return false; - }; - - EmptySyntaxList.prototype.findTokenInternal = function (parent, position, fullStart) { - throw TypeScript.Errors.invalidOperation(); - }; - - EmptySyntaxList.prototype.insertChildrenInto = function (array, index) { - }; - return EmptySyntaxList; - })(); - Syntax.EmptySyntaxList = EmptySyntaxList; - - Syntax.emptyList = new EmptySyntaxList(); - - var SingletonSyntaxList = (function () { - function SingletonSyntaxList(item) { - this.item = item; - } - SingletonSyntaxList.prototype.kind = function () { - return 1 /* List */; - }; - - SingletonSyntaxList.prototype.isToken = function () { - return false; - }; - SingletonSyntaxList.prototype.isNode = function () { - return false; - }; - SingletonSyntaxList.prototype.isList = function () { - return true; - }; - SingletonSyntaxList.prototype.isSeparatedList = function () { - return false; - }; - - SingletonSyntaxList.prototype.toJSON = function (key) { - return [this.item]; - }; - - SingletonSyntaxList.prototype.childCount = function () { - return 1; - }; - - SingletonSyntaxList.prototype.childAt = function (index) { - if (index !== 0) { - throw TypeScript.Errors.argumentOutOfRange("index"); - } - - return this.item; - }; - - SingletonSyntaxList.prototype.toArray = function () { - return [this.item]; - }; - - SingletonSyntaxList.prototype.collectTextElements = function (elements) { - this.item.collectTextElements(elements); - }; - - SingletonSyntaxList.prototype.firstToken = function () { - return this.item.firstToken(); - }; - - SingletonSyntaxList.prototype.lastToken = function () { - return this.item.lastToken(); - }; - - SingletonSyntaxList.prototype.fullWidth = function () { - return this.item.fullWidth(); - }; - - SingletonSyntaxList.prototype.width = function () { - return this.item.width(); - }; - - SingletonSyntaxList.prototype.leadingTrivia = function () { - return this.item.leadingTrivia(); - }; - - SingletonSyntaxList.prototype.trailingTrivia = function () { - return this.item.trailingTrivia(); - }; - - SingletonSyntaxList.prototype.leadingTriviaWidth = function () { - return this.item.leadingTriviaWidth(); - }; - - SingletonSyntaxList.prototype.trailingTriviaWidth = function () { - return this.item.trailingTriviaWidth(); - }; - - SingletonSyntaxList.prototype.fullText = function () { - return this.item.fullText(); - }; - - SingletonSyntaxList.prototype.isTypeScriptSpecific = function () { - return this.item.isTypeScriptSpecific(); - }; - - SingletonSyntaxList.prototype.isIncrementallyUnusable = function () { - return this.item.isIncrementallyUnusable(); - }; - - SingletonSyntaxList.prototype.findTokenInternal = function (parent, position, fullStart) { - return (this.item).findTokenInternal(new TypeScript.PositionedList(parent, this, fullStart), position, fullStart); - }; - - SingletonSyntaxList.prototype.insertChildrenInto = function (array, index) { - array.splice(index, 0, this.item); - }; - return SingletonSyntaxList; - })(); - - var NormalSyntaxList = (function () { - function NormalSyntaxList(nodeOrTokens) { - this._data = 0; - this.nodeOrTokens = nodeOrTokens; - } - NormalSyntaxList.prototype.kind = function () { - return 1 /* List */; - }; - - NormalSyntaxList.prototype.isNode = function () { - return false; - }; - NormalSyntaxList.prototype.isToken = function () { - return false; - }; - NormalSyntaxList.prototype.isList = function () { - return true; - }; - NormalSyntaxList.prototype.isSeparatedList = function () { - return false; - }; - - NormalSyntaxList.prototype.toJSON = function (key) { - return this.nodeOrTokens; - }; - - NormalSyntaxList.prototype.childCount = function () { - return this.nodeOrTokens.length; - }; - - NormalSyntaxList.prototype.childAt = function (index) { - if (index < 0 || index >= this.nodeOrTokens.length) { - throw TypeScript.Errors.argumentOutOfRange("index"); - } - - return this.nodeOrTokens[index]; - }; - - NormalSyntaxList.prototype.toArray = function () { - return this.nodeOrTokens.slice(0); - }; - - NormalSyntaxList.prototype.collectTextElements = function (elements) { - for (var i = 0, n = this.nodeOrTokens.length; i < n; i++) { - var element = this.nodeOrTokens[i]; - element.collectTextElements(elements); - } - }; - - NormalSyntaxList.prototype.firstToken = function () { - for (var i = 0, n = this.nodeOrTokens.length; i < n; i++) { - var token = this.nodeOrTokens[i].firstToken(); - if (token !== null) { - return token; - } - } - - return null; - }; - - NormalSyntaxList.prototype.lastToken = function () { - for (var i = this.nodeOrTokens.length - 1; i >= 0; i--) { - var token = this.nodeOrTokens[i].lastToken(); - if (token !== null) { - return token; - } - } - - return null; - }; - - NormalSyntaxList.prototype.fullText = function () { - var elements = []; - this.collectTextElements(elements); - return elements.join(""); - }; - - NormalSyntaxList.prototype.isTypeScriptSpecific = function () { - for (var i = 0, n = this.nodeOrTokens.length; i < n; i++) { - if (this.nodeOrTokens[i].isTypeScriptSpecific()) { - return true; - } - } - - return false; - }; - - NormalSyntaxList.prototype.isIncrementallyUnusable = function () { - return (this.data() & 2 /* NodeIncrementallyUnusableMask */) !== 0; - }; - - NormalSyntaxList.prototype.fullWidth = function () { - return this.data() >>> 3 /* NodeFullWidthShift */; - }; - - NormalSyntaxList.prototype.width = function () { - var fullWidth = this.fullWidth(); - return fullWidth - this.leadingTriviaWidth() - this.trailingTriviaWidth(); - }; - - NormalSyntaxList.prototype.leadingTrivia = function () { - return this.firstToken().leadingTrivia(); - }; - - NormalSyntaxList.prototype.trailingTrivia = function () { - return this.lastToken().trailingTrivia(); - }; - - NormalSyntaxList.prototype.leadingTriviaWidth = function () { - return this.firstToken().leadingTriviaWidth(); - }; - - NormalSyntaxList.prototype.trailingTriviaWidth = function () { - return this.lastToken().trailingTriviaWidth(); - }; - - NormalSyntaxList.prototype.computeData = function () { - var fullWidth = 0; - var isIncrementallyUnusable = false; - - for (var i = 0, n = this.nodeOrTokens.length; i < n; i++) { - var node = this.nodeOrTokens[i]; - fullWidth += node.fullWidth(); - isIncrementallyUnusable = isIncrementallyUnusable || node.isIncrementallyUnusable(); - } - - return (fullWidth << 3 /* NodeFullWidthShift */) | (isIncrementallyUnusable ? 2 /* NodeIncrementallyUnusableMask */ : 0) | 1 /* NodeDataComputed */; - }; - - NormalSyntaxList.prototype.data = function () { - if ((this._data & 1 /* NodeDataComputed */) === 0) { - this._data = this.computeData(); - } - - return this._data; - }; - - NormalSyntaxList.prototype.findTokenInternal = function (parent, position, fullStart) { - parent = new TypeScript.PositionedList(parent, this, fullStart); - for (var i = 0, n = this.nodeOrTokens.length; i < n; i++) { - var nodeOrToken = this.nodeOrTokens[i]; - - var childWidth = nodeOrToken.fullWidth(); - if (position < childWidth) { - return (nodeOrToken).findTokenInternal(parent, position, fullStart); - } - - position -= childWidth; - fullStart += childWidth; - } - - throw TypeScript.Errors.invalidOperation(); - }; - - NormalSyntaxList.prototype.insertChildrenInto = function (array, index) { - if (index === 0) { - array.unshift.apply(array, this.nodeOrTokens); - } else { - array.splice.apply(array, [index, 0].concat(this.nodeOrTokens)); - } - }; - return NormalSyntaxList; - })(); - - function list(nodes) { - if (nodes === undefined || nodes === null || nodes.length === 0) { - return Syntax.emptyList; - } - - if (nodes.length === 1) { - var item = nodes[0]; - return new SingletonSyntaxList(item); - } - - return new NormalSyntaxList(nodes); - } - Syntax.list = list; - })(TypeScript.Syntax || (TypeScript.Syntax = {})); - var Syntax = TypeScript.Syntax; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var SyntaxNode = (function () { - function SyntaxNode(parsedInStrictMode) { - this._data = parsedInStrictMode ? 4 /* NodeParsedInStrictModeMask */ : 0; - } - SyntaxNode.prototype.isNode = function () { - return true; - }; - SyntaxNode.prototype.isToken = function () { - return false; - }; - SyntaxNode.prototype.isList = function () { - return false; - }; - SyntaxNode.prototype.isSeparatedList = function () { - return false; - }; - - SyntaxNode.prototype.kind = function () { - throw TypeScript.Errors.abstract(); - }; - - SyntaxNode.prototype.childCount = function () { - throw TypeScript.Errors.abstract(); - }; - - SyntaxNode.prototype.childAt = function (slot) { - throw TypeScript.Errors.abstract(); - }; - - SyntaxNode.prototype.firstToken = function () { - for (var i = 0, n = this.childCount(); i < n; i++) { - var element = this.childAt(i); - - if (element !== null) { - if (element.fullWidth() > 0 || element.kind() === 10 /* EndOfFileToken */) { - return element.firstToken(); - } - } - } - - return null; - }; - - SyntaxNode.prototype.lastToken = function () { - for (var i = this.childCount() - 1; i >= 0; i--) { - var element = this.childAt(i); - - if (element !== null) { - if (element.fullWidth() > 0 || element.kind() === 10 /* EndOfFileToken */) { - return element.lastToken(); - } - } - } - - return null; - }; - - SyntaxNode.prototype.insertChildrenInto = function (array, index) { - for (var i = this.childCount() - 1; i >= 0; i--) { - var element = this.childAt(i); - - if (element !== null) { - if (element.isNode() || element.isToken()) { - array.splice(index, 0, element); - } else if (element.isList()) { - (element).insertChildrenInto(array, index); - } else if (element.isSeparatedList()) { - (element).insertChildrenInto(array, index); - } else { - throw TypeScript.Errors.invalidOperation(); - } - } - } - }; - - SyntaxNode.prototype.leadingTrivia = function () { - return this.firstToken().leadingTrivia(); - }; - - SyntaxNode.prototype.trailingTrivia = function () { - return this.lastToken().trailingTrivia(); - }; - - SyntaxNode.prototype.toJSON = function (key) { - var result = { - kind: TypeScript.SyntaxKind[this.kind()], - fullWidth: this.fullWidth() - }; - - if (this.isIncrementallyUnusable()) { - result.isIncrementallyUnusable = true; - } - - if (this.parsedInStrictMode()) { - result.parsedInStrictMode = true; - } - - for (var i = 0, n = this.childCount(); i < n; i++) { - var value = this.childAt(i); - - if (value) { - for (var name in this) { - if (value === this[name]) { - result[name] = value; - break; - } - } - } - } - - return result; - }; - - SyntaxNode.prototype.accept = function (visitor) { - throw TypeScript.Errors.abstract(); - }; - - SyntaxNode.prototype.fullText = function () { - var elements = []; - this.collectTextElements(elements); - return elements.join(""); - }; - - SyntaxNode.prototype.collectTextElements = function (elements) { - for (var i = 0, n = this.childCount(); i < n; i++) { - var element = this.childAt(i); - - if (element !== null) { - element.collectTextElements(elements); - } - } - }; - - SyntaxNode.prototype.replaceToken = function (token1, token2) { - if (token1 === token2) { - return this; - } - - return this.accept(new TypeScript.SyntaxTokenReplacer(token1, token2)); - }; - - SyntaxNode.prototype.withLeadingTrivia = function (trivia) { - return this.replaceToken(this.firstToken(), this.firstToken().withLeadingTrivia(trivia)); - }; - - SyntaxNode.prototype.withTrailingTrivia = function (trivia) { - return this.replaceToken(this.lastToken(), this.lastToken().withTrailingTrivia(trivia)); - }; - - SyntaxNode.prototype.hasLeadingTrivia = function () { - return this.lastToken().hasLeadingTrivia(); - }; - - SyntaxNode.prototype.hasTrailingTrivia = function () { - return this.lastToken().hasTrailingTrivia(); - }; - - SyntaxNode.prototype.isTypeScriptSpecific = function () { - return false; - }; - - SyntaxNode.prototype.isIncrementallyUnusable = function () { - return (this.data() & 2 /* NodeIncrementallyUnusableMask */) !== 0; - }; - - SyntaxNode.prototype.parsedInStrictMode = function () { - return (this.data() & 4 /* NodeParsedInStrictModeMask */) !== 0; - }; - - SyntaxNode.prototype.fullWidth = function () { - return this.data() >>> 3 /* NodeFullWidthShift */; - }; - - SyntaxNode.prototype.computeData = function () { - var slotCount = this.childCount(); - - var fullWidth = 0; - var childWidth = 0; - - var isIncrementallyUnusable = ((this._data & 2 /* NodeIncrementallyUnusableMask */) !== 0) || slotCount === 0; - - for (var i = 0, n = slotCount; i < n; i++) { - var element = this.childAt(i); - - if (element !== null) { - childWidth = element.fullWidth(); - fullWidth += childWidth; - - if (!isIncrementallyUnusable) { - isIncrementallyUnusable = element.isIncrementallyUnusable(); - } - } - } - - return (fullWidth << 3 /* NodeFullWidthShift */) | (isIncrementallyUnusable ? 2 /* NodeIncrementallyUnusableMask */ : 0) | 1 /* NodeDataComputed */; - }; - - SyntaxNode.prototype.data = function () { - if ((this._data & 1 /* NodeDataComputed */) === 0) { - this._data |= this.computeData(); - } - - return this._data; - }; - - SyntaxNode.prototype.findToken = function (position, includeSkippedTokens) { - if (typeof includeSkippedTokens === "undefined") { includeSkippedTokens = false; } - var endOfFileToken = this.tryGetEndOfFileAt(position); - if (endOfFileToken !== null) { - return endOfFileToken; - } - - if (position < 0 || position >= this.fullWidth()) { - throw TypeScript.Errors.argumentOutOfRange("position"); - } - - var positionedToken = this.findTokenInternal(null, position, 0); - - if (includeSkippedTokens) { - return TypeScript.Syntax.findSkippedTokenInPositionedToken(positionedToken, position) || positionedToken; - } - - return positionedToken; - }; - - SyntaxNode.prototype.tryGetEndOfFileAt = function (position) { - if (this.kind() === 121 /* SourceUnit */ && position === this.fullWidth()) { - var sourceUnit = this; - return new TypeScript.PositionedToken(new TypeScript.PositionedNode(null, sourceUnit, 0), sourceUnit.endOfFileToken, sourceUnit.moduleElements.fullWidth()); - } - - return null; - }; - - SyntaxNode.prototype.findTokenInternal = function (parent, position, fullStart) { - parent = new TypeScript.PositionedNode(parent, this, fullStart); - for (var i = 0, n = this.childCount(); i < n; i++) { - var element = this.childAt(i); - - if (element !== null) { - var childWidth = element.fullWidth(); - - if (position < childWidth) { - return (element).findTokenInternal(parent, position, fullStart); - } - - position -= childWidth; - fullStart += childWidth; - } - } - - throw TypeScript.Errors.invalidOperation(); - }; - - SyntaxNode.prototype.findTokenOnLeft = function (position, includeSkippedTokens) { - if (typeof includeSkippedTokens === "undefined") { includeSkippedTokens = false; } - var positionedToken = this.findToken(position, includeSkippedTokens); - var start = positionedToken.start(); - - if (position > start) { - return positionedToken; - } - - if (positionedToken.fullStart() === 0) { - return null; - } - - return positionedToken.previousToken(includeSkippedTokens); - }; - - SyntaxNode.prototype.findCompleteTokenOnLeft = function (position, includeSkippedTokens) { - if (typeof includeSkippedTokens === "undefined") { includeSkippedTokens = false; } - var positionedToken = this.findToken(position, includeSkippedTokens); - - if (positionedToken.token().width() > 0 && position >= positionedToken.end()) { - return positionedToken; - } - - return positionedToken.previousToken(includeSkippedTokens); - }; - - SyntaxNode.prototype.isModuleElement = function () { - return false; - }; - - SyntaxNode.prototype.isClassElement = function () { - return false; - }; - - SyntaxNode.prototype.isTypeMember = function () { - return false; - }; - - SyntaxNode.prototype.isStatement = function () { - return false; - }; - - SyntaxNode.prototype.isSwitchClause = function () { - return false; - }; - - SyntaxNode.prototype.structuralEquals = function (node) { - if (this === node) { - return true; - } - if (node === null) { - return false; - } - if (this.kind() !== node.kind()) { - return false; - } - - for (var i = 0, n = this.childCount(); i < n; i++) { - var element1 = this.childAt(i); - var element2 = node.childAt(i); - - if (!TypeScript.Syntax.elementStructuralEquals(element1, element2)) { - return false; - } - } - - return true; - }; - - SyntaxNode.prototype.width = function () { - return this.fullWidth() - this.leadingTriviaWidth() - this.trailingTriviaWidth(); - }; - - SyntaxNode.prototype.leadingTriviaWidth = function () { - var firstToken = this.firstToken(); - return firstToken === null ? 0 : firstToken.leadingTriviaWidth(); - }; - - SyntaxNode.prototype.trailingTriviaWidth = function () { - var lastToken = this.lastToken(); - return lastToken === null ? 0 : lastToken.trailingTriviaWidth(); - }; - return SyntaxNode; - })(); - TypeScript.SyntaxNode = SyntaxNode; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var SourceUnitSyntax = (function (_super) { - __extends(SourceUnitSyntax, _super); - function SourceUnitSyntax(moduleElements, endOfFileToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.moduleElements = moduleElements; - this.endOfFileToken = endOfFileToken; - } - SourceUnitSyntax.prototype.accept = function (visitor) { - return visitor.visitSourceUnit(this); - }; - - SourceUnitSyntax.prototype.kind = function () { - return 121 /* SourceUnit */; - }; - - SourceUnitSyntax.prototype.childCount = function () { - return 2; - }; - - SourceUnitSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.moduleElements; - case 1: - return this.endOfFileToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - SourceUnitSyntax.prototype.update = function (moduleElements, endOfFileToken) { - if (this.moduleElements === moduleElements && this.endOfFileToken === endOfFileToken) { - return this; - } - - return new SourceUnitSyntax(moduleElements, endOfFileToken, this.parsedInStrictMode()); - }; - - SourceUnitSyntax.create = function (endOfFileToken) { - return new SourceUnitSyntax(TypeScript.Syntax.emptyList, endOfFileToken, false); - }; - - SourceUnitSyntax.create1 = function (endOfFileToken) { - return new SourceUnitSyntax(TypeScript.Syntax.emptyList, endOfFileToken, false); - }; - - SourceUnitSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - SourceUnitSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - SourceUnitSyntax.prototype.withModuleElements = function (moduleElements) { - return this.update(moduleElements, this.endOfFileToken); - }; - - SourceUnitSyntax.prototype.withModuleElement = function (moduleElement) { - return this.withModuleElements(TypeScript.Syntax.list([moduleElement])); - }; - - SourceUnitSyntax.prototype.withEndOfFileToken = function (endOfFileToken) { - return this.update(this.moduleElements, endOfFileToken); - }; - - SourceUnitSyntax.prototype.isTypeScriptSpecific = function () { - if (this.moduleElements.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return SourceUnitSyntax; - })(TypeScript.SyntaxNode); - TypeScript.SourceUnitSyntax = SourceUnitSyntax; - - var ModuleReferenceSyntax = (function (_super) { - __extends(ModuleReferenceSyntax, _super); - function ModuleReferenceSyntax(parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - } - ModuleReferenceSyntax.prototype.isModuleReference = function () { - return true; - }; - - ModuleReferenceSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ModuleReferenceSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ModuleReferenceSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return ModuleReferenceSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ModuleReferenceSyntax = ModuleReferenceSyntax; - - var ExternalModuleReferenceSyntax = (function (_super) { - __extends(ExternalModuleReferenceSyntax, _super); - function ExternalModuleReferenceSyntax(moduleOrRequireKeyword, openParenToken, stringLiteral, closeParenToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.moduleOrRequireKeyword = moduleOrRequireKeyword; - this.openParenToken = openParenToken; - this.stringLiteral = stringLiteral; - this.closeParenToken = closeParenToken; - } - ExternalModuleReferenceSyntax.prototype.accept = function (visitor) { - return visitor.visitExternalModuleReference(this); - }; - - ExternalModuleReferenceSyntax.prototype.kind = function () { - return 245 /* ExternalModuleReference */; - }; - - ExternalModuleReferenceSyntax.prototype.childCount = function () { - return 4; - }; - - ExternalModuleReferenceSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.moduleOrRequireKeyword; - case 1: - return this.openParenToken; - case 2: - return this.stringLiteral; - case 3: - return this.closeParenToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ExternalModuleReferenceSyntax.prototype.update = function (moduleOrRequireKeyword, openParenToken, stringLiteral, closeParenToken) { - if (this.moduleOrRequireKeyword === moduleOrRequireKeyword && this.openParenToken === openParenToken && this.stringLiteral === stringLiteral && this.closeParenToken === closeParenToken) { - return this; - } - - return new ExternalModuleReferenceSyntax(moduleOrRequireKeyword, openParenToken, stringLiteral, closeParenToken, this.parsedInStrictMode()); - }; - - ExternalModuleReferenceSyntax.create1 = function (moduleOrRequireKeyword, stringLiteral) { - return new ExternalModuleReferenceSyntax(moduleOrRequireKeyword, TypeScript.Syntax.token(73 /* OpenParenToken */), stringLiteral, TypeScript.Syntax.token(74 /* CloseParenToken */), false); - }; - - ExternalModuleReferenceSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ExternalModuleReferenceSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ExternalModuleReferenceSyntax.prototype.withModuleOrRequireKeyword = function (moduleOrRequireKeyword) { - return this.update(moduleOrRequireKeyword, this.openParenToken, this.stringLiteral, this.closeParenToken); - }; - - ExternalModuleReferenceSyntax.prototype.withOpenParenToken = function (openParenToken) { - return this.update(this.moduleOrRequireKeyword, openParenToken, this.stringLiteral, this.closeParenToken); - }; - - ExternalModuleReferenceSyntax.prototype.withStringLiteral = function (stringLiteral) { - return this.update(this.moduleOrRequireKeyword, this.openParenToken, stringLiteral, this.closeParenToken); - }; - - ExternalModuleReferenceSyntax.prototype.withCloseParenToken = function (closeParenToken) { - return this.update(this.moduleOrRequireKeyword, this.openParenToken, this.stringLiteral, closeParenToken); - }; - - ExternalModuleReferenceSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return ExternalModuleReferenceSyntax; - })(ModuleReferenceSyntax); - TypeScript.ExternalModuleReferenceSyntax = ExternalModuleReferenceSyntax; - - var ModuleNameModuleReferenceSyntax = (function (_super) { - __extends(ModuleNameModuleReferenceSyntax, _super); - function ModuleNameModuleReferenceSyntax(moduleName, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.moduleName = moduleName; - } - ModuleNameModuleReferenceSyntax.prototype.accept = function (visitor) { - return visitor.visitModuleNameModuleReference(this); - }; - - ModuleNameModuleReferenceSyntax.prototype.kind = function () { - return 246 /* ModuleNameModuleReference */; - }; - - ModuleNameModuleReferenceSyntax.prototype.childCount = function () { - return 1; - }; - - ModuleNameModuleReferenceSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.moduleName; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ModuleNameModuleReferenceSyntax.prototype.update = function (moduleName) { - if (this.moduleName === moduleName) { - return this; - } - - return new ModuleNameModuleReferenceSyntax(moduleName, this.parsedInStrictMode()); - }; - - ModuleNameModuleReferenceSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ModuleNameModuleReferenceSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ModuleNameModuleReferenceSyntax.prototype.withModuleName = function (moduleName) { - return this.update(moduleName); - }; - - ModuleNameModuleReferenceSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return ModuleNameModuleReferenceSyntax; - })(ModuleReferenceSyntax); - TypeScript.ModuleNameModuleReferenceSyntax = ModuleNameModuleReferenceSyntax; - - var ImportDeclarationSyntax = (function (_super) { - __extends(ImportDeclarationSyntax, _super); - function ImportDeclarationSyntax(importKeyword, identifier, equalsToken, moduleReference, semicolonToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.importKeyword = importKeyword; - this.identifier = identifier; - this.equalsToken = equalsToken; - this.moduleReference = moduleReference; - this.semicolonToken = semicolonToken; - } - ImportDeclarationSyntax.prototype.accept = function (visitor) { - return visitor.visitImportDeclaration(this); - }; - - ImportDeclarationSyntax.prototype.kind = function () { - return 133 /* ImportDeclaration */; - }; - - ImportDeclarationSyntax.prototype.childCount = function () { - return 5; - }; - - ImportDeclarationSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.importKeyword; - case 1: - return this.identifier; - case 2: - return this.equalsToken; - case 3: - return this.moduleReference; - case 4: - return this.semicolonToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ImportDeclarationSyntax.prototype.isModuleElement = function () { - return true; - }; - - ImportDeclarationSyntax.prototype.update = function (importKeyword, identifier, equalsToken, moduleReference, semicolonToken) { - if (this.importKeyword === importKeyword && this.identifier === identifier && this.equalsToken === equalsToken && this.moduleReference === moduleReference && this.semicolonToken === semicolonToken) { - return this; - } - - return new ImportDeclarationSyntax(importKeyword, identifier, equalsToken, moduleReference, semicolonToken, this.parsedInStrictMode()); - }; - - ImportDeclarationSyntax.create1 = function (identifier, moduleReference) { - return new ImportDeclarationSyntax(TypeScript.Syntax.token(49 /* ImportKeyword */), identifier, TypeScript.Syntax.token(108 /* EqualsToken */), moduleReference, TypeScript.Syntax.token(79 /* SemicolonToken */), false); - }; - - ImportDeclarationSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ImportDeclarationSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ImportDeclarationSyntax.prototype.withImportKeyword = function (importKeyword) { - return this.update(importKeyword, this.identifier, this.equalsToken, this.moduleReference, this.semicolonToken); - }; - - ImportDeclarationSyntax.prototype.withIdentifier = function (identifier) { - return this.update(this.importKeyword, identifier, this.equalsToken, this.moduleReference, this.semicolonToken); - }; - - ImportDeclarationSyntax.prototype.withEqualsToken = function (equalsToken) { - return this.update(this.importKeyword, this.identifier, equalsToken, this.moduleReference, this.semicolonToken); - }; - - ImportDeclarationSyntax.prototype.withModuleReference = function (moduleReference) { - return this.update(this.importKeyword, this.identifier, this.equalsToken, moduleReference, this.semicolonToken); - }; - - ImportDeclarationSyntax.prototype.withSemicolonToken = function (semicolonToken) { - return this.update(this.importKeyword, this.identifier, this.equalsToken, this.moduleReference, semicolonToken); - }; - - ImportDeclarationSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return ImportDeclarationSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ImportDeclarationSyntax = ImportDeclarationSyntax; - - var ExportAssignmentSyntax = (function (_super) { - __extends(ExportAssignmentSyntax, _super); - function ExportAssignmentSyntax(exportKeyword, equalsToken, identifier, semicolonToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.exportKeyword = exportKeyword; - this.equalsToken = equalsToken; - this.identifier = identifier; - this.semicolonToken = semicolonToken; - } - ExportAssignmentSyntax.prototype.accept = function (visitor) { - return visitor.visitExportAssignment(this); - }; - - ExportAssignmentSyntax.prototype.kind = function () { - return 134 /* ExportAssignment */; - }; - - ExportAssignmentSyntax.prototype.childCount = function () { - return 4; - }; - - ExportAssignmentSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.exportKeyword; - case 1: - return this.equalsToken; - case 2: - return this.identifier; - case 3: - return this.semicolonToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ExportAssignmentSyntax.prototype.isModuleElement = function () { - return true; - }; - - ExportAssignmentSyntax.prototype.update = function (exportKeyword, equalsToken, identifier, semicolonToken) { - if (this.exportKeyword === exportKeyword && this.equalsToken === equalsToken && this.identifier === identifier && this.semicolonToken === semicolonToken) { - return this; - } - - return new ExportAssignmentSyntax(exportKeyword, equalsToken, identifier, semicolonToken, this.parsedInStrictMode()); - }; - - ExportAssignmentSyntax.create1 = function (identifier) { - return new ExportAssignmentSyntax(TypeScript.Syntax.token(47 /* ExportKeyword */), TypeScript.Syntax.token(108 /* EqualsToken */), identifier, TypeScript.Syntax.token(79 /* SemicolonToken */), false); - }; - - ExportAssignmentSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ExportAssignmentSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ExportAssignmentSyntax.prototype.withExportKeyword = function (exportKeyword) { - return this.update(exportKeyword, this.equalsToken, this.identifier, this.semicolonToken); - }; - - ExportAssignmentSyntax.prototype.withEqualsToken = function (equalsToken) { - return this.update(this.exportKeyword, equalsToken, this.identifier, this.semicolonToken); - }; - - ExportAssignmentSyntax.prototype.withIdentifier = function (identifier) { - return this.update(this.exportKeyword, this.equalsToken, identifier, this.semicolonToken); - }; - - ExportAssignmentSyntax.prototype.withSemicolonToken = function (semicolonToken) { - return this.update(this.exportKeyword, this.equalsToken, this.identifier, semicolonToken); - }; - - ExportAssignmentSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return ExportAssignmentSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ExportAssignmentSyntax = ExportAssignmentSyntax; - - var ClassDeclarationSyntax = (function (_super) { - __extends(ClassDeclarationSyntax, _super); - function ClassDeclarationSyntax(modifiers, classKeyword, identifier, typeParameterList, heritageClauses, openBraceToken, classElements, closeBraceToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.modifiers = modifiers; - this.classKeyword = classKeyword; - this.identifier = identifier; - this.typeParameterList = typeParameterList; - this.heritageClauses = heritageClauses; - this.openBraceToken = openBraceToken; - this.classElements = classElements; - this.closeBraceToken = closeBraceToken; - } - ClassDeclarationSyntax.prototype.accept = function (visitor) { - return visitor.visitClassDeclaration(this); - }; - - ClassDeclarationSyntax.prototype.kind = function () { - return 131 /* ClassDeclaration */; - }; - - ClassDeclarationSyntax.prototype.childCount = function () { - return 8; - }; - - ClassDeclarationSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.modifiers; - case 1: - return this.classKeyword; - case 2: - return this.identifier; - case 3: - return this.typeParameterList; - case 4: - return this.heritageClauses; - case 5: - return this.openBraceToken; - case 6: - return this.classElements; - case 7: - return this.closeBraceToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ClassDeclarationSyntax.prototype.isModuleElement = function () { - return true; - }; - - ClassDeclarationSyntax.prototype.update = function (modifiers, classKeyword, identifier, typeParameterList, heritageClauses, openBraceToken, classElements, closeBraceToken) { - if (this.modifiers === modifiers && this.classKeyword === classKeyword && this.identifier === identifier && this.typeParameterList === typeParameterList && this.heritageClauses === heritageClauses && this.openBraceToken === openBraceToken && this.classElements === classElements && this.closeBraceToken === closeBraceToken) { - return this; - } - - return new ClassDeclarationSyntax(modifiers, classKeyword, identifier, typeParameterList, heritageClauses, openBraceToken, classElements, closeBraceToken, this.parsedInStrictMode()); - }; - - ClassDeclarationSyntax.create = function (classKeyword, identifier, openBraceToken, closeBraceToken) { - return new ClassDeclarationSyntax(TypeScript.Syntax.emptyList, classKeyword, identifier, null, TypeScript.Syntax.emptyList, openBraceToken, TypeScript.Syntax.emptyList, closeBraceToken, false); - }; - - ClassDeclarationSyntax.create1 = function (identifier) { - return new ClassDeclarationSyntax(TypeScript.Syntax.emptyList, TypeScript.Syntax.token(44 /* ClassKeyword */), identifier, null, TypeScript.Syntax.emptyList, TypeScript.Syntax.token(71 /* OpenBraceToken */), TypeScript.Syntax.emptyList, TypeScript.Syntax.token(72 /* CloseBraceToken */), false); - }; - - ClassDeclarationSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ClassDeclarationSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ClassDeclarationSyntax.prototype.withModifiers = function (modifiers) { - return this.update(modifiers, this.classKeyword, this.identifier, this.typeParameterList, this.heritageClauses, this.openBraceToken, this.classElements, this.closeBraceToken); - }; - - ClassDeclarationSyntax.prototype.withModifier = function (modifier) { - return this.withModifiers(TypeScript.Syntax.list([modifier])); - }; - - ClassDeclarationSyntax.prototype.withClassKeyword = function (classKeyword) { - return this.update(this.modifiers, classKeyword, this.identifier, this.typeParameterList, this.heritageClauses, this.openBraceToken, this.classElements, this.closeBraceToken); - }; - - ClassDeclarationSyntax.prototype.withIdentifier = function (identifier) { - return this.update(this.modifiers, this.classKeyword, identifier, this.typeParameterList, this.heritageClauses, this.openBraceToken, this.classElements, this.closeBraceToken); - }; - - ClassDeclarationSyntax.prototype.withTypeParameterList = function (typeParameterList) { - return this.update(this.modifiers, this.classKeyword, this.identifier, typeParameterList, this.heritageClauses, this.openBraceToken, this.classElements, this.closeBraceToken); - }; - - ClassDeclarationSyntax.prototype.withHeritageClauses = function (heritageClauses) { - return this.update(this.modifiers, this.classKeyword, this.identifier, this.typeParameterList, heritageClauses, this.openBraceToken, this.classElements, this.closeBraceToken); - }; - - ClassDeclarationSyntax.prototype.withHeritageClause = function (heritageClause) { - return this.withHeritageClauses(TypeScript.Syntax.list([heritageClause])); - }; - - ClassDeclarationSyntax.prototype.withOpenBraceToken = function (openBraceToken) { - return this.update(this.modifiers, this.classKeyword, this.identifier, this.typeParameterList, this.heritageClauses, openBraceToken, this.classElements, this.closeBraceToken); - }; - - ClassDeclarationSyntax.prototype.withClassElements = function (classElements) { - return this.update(this.modifiers, this.classKeyword, this.identifier, this.typeParameterList, this.heritageClauses, this.openBraceToken, classElements, this.closeBraceToken); - }; - - ClassDeclarationSyntax.prototype.withClassElement = function (classElement) { - return this.withClassElements(TypeScript.Syntax.list([classElement])); - }; - - ClassDeclarationSyntax.prototype.withCloseBraceToken = function (closeBraceToken) { - return this.update(this.modifiers, this.classKeyword, this.identifier, this.typeParameterList, this.heritageClauses, this.openBraceToken, this.classElements, closeBraceToken); - }; - - ClassDeclarationSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return ClassDeclarationSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ClassDeclarationSyntax = ClassDeclarationSyntax; - - var InterfaceDeclarationSyntax = (function (_super) { - __extends(InterfaceDeclarationSyntax, _super); - function InterfaceDeclarationSyntax(modifiers, interfaceKeyword, identifier, typeParameterList, heritageClauses, body, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.modifiers = modifiers; - this.interfaceKeyword = interfaceKeyword; - this.identifier = identifier; - this.typeParameterList = typeParameterList; - this.heritageClauses = heritageClauses; - this.body = body; - } - InterfaceDeclarationSyntax.prototype.accept = function (visitor) { - return visitor.visitInterfaceDeclaration(this); - }; - - InterfaceDeclarationSyntax.prototype.kind = function () { - return 128 /* InterfaceDeclaration */; - }; - - InterfaceDeclarationSyntax.prototype.childCount = function () { - return 6; - }; - - InterfaceDeclarationSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.modifiers; - case 1: - return this.interfaceKeyword; - case 2: - return this.identifier; - case 3: - return this.typeParameterList; - case 4: - return this.heritageClauses; - case 5: - return this.body; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - InterfaceDeclarationSyntax.prototype.isModuleElement = function () { - return true; - }; - - InterfaceDeclarationSyntax.prototype.update = function (modifiers, interfaceKeyword, identifier, typeParameterList, heritageClauses, body) { - if (this.modifiers === modifiers && this.interfaceKeyword === interfaceKeyword && this.identifier === identifier && this.typeParameterList === typeParameterList && this.heritageClauses === heritageClauses && this.body === body) { - return this; - } - - return new InterfaceDeclarationSyntax(modifiers, interfaceKeyword, identifier, typeParameterList, heritageClauses, body, this.parsedInStrictMode()); - }; - - InterfaceDeclarationSyntax.create = function (interfaceKeyword, identifier, body) { - return new InterfaceDeclarationSyntax(TypeScript.Syntax.emptyList, interfaceKeyword, identifier, null, TypeScript.Syntax.emptyList, body, false); - }; - - InterfaceDeclarationSyntax.create1 = function (identifier) { - return new InterfaceDeclarationSyntax(TypeScript.Syntax.emptyList, TypeScript.Syntax.token(52 /* InterfaceKeyword */), identifier, null, TypeScript.Syntax.emptyList, ObjectTypeSyntax.create1(), false); - }; - - InterfaceDeclarationSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - InterfaceDeclarationSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - InterfaceDeclarationSyntax.prototype.withModifiers = function (modifiers) { - return this.update(modifiers, this.interfaceKeyword, this.identifier, this.typeParameterList, this.heritageClauses, this.body); - }; - - InterfaceDeclarationSyntax.prototype.withModifier = function (modifier) { - return this.withModifiers(TypeScript.Syntax.list([modifier])); - }; - - InterfaceDeclarationSyntax.prototype.withInterfaceKeyword = function (interfaceKeyword) { - return this.update(this.modifiers, interfaceKeyword, this.identifier, this.typeParameterList, this.heritageClauses, this.body); - }; - - InterfaceDeclarationSyntax.prototype.withIdentifier = function (identifier) { - return this.update(this.modifiers, this.interfaceKeyword, identifier, this.typeParameterList, this.heritageClauses, this.body); - }; - - InterfaceDeclarationSyntax.prototype.withTypeParameterList = function (typeParameterList) { - return this.update(this.modifiers, this.interfaceKeyword, this.identifier, typeParameterList, this.heritageClauses, this.body); - }; - - InterfaceDeclarationSyntax.prototype.withHeritageClauses = function (heritageClauses) { - return this.update(this.modifiers, this.interfaceKeyword, this.identifier, this.typeParameterList, heritageClauses, this.body); - }; - - InterfaceDeclarationSyntax.prototype.withHeritageClause = function (heritageClause) { - return this.withHeritageClauses(TypeScript.Syntax.list([heritageClause])); - }; - - InterfaceDeclarationSyntax.prototype.withBody = function (body) { - return this.update(this.modifiers, this.interfaceKeyword, this.identifier, this.typeParameterList, this.heritageClauses, body); - }; - - InterfaceDeclarationSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return InterfaceDeclarationSyntax; - })(TypeScript.SyntaxNode); - TypeScript.InterfaceDeclarationSyntax = InterfaceDeclarationSyntax; - - var HeritageClauseSyntax = (function (_super) { - __extends(HeritageClauseSyntax, _super); - function HeritageClauseSyntax(extendsOrImplementsKeyword, typeNames, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.extendsOrImplementsKeyword = extendsOrImplementsKeyword; - this.typeNames = typeNames; - } - HeritageClauseSyntax.prototype.accept = function (visitor) { - return visitor.visitHeritageClause(this); - }; - - HeritageClauseSyntax.prototype.kind = function () { - return 229 /* HeritageClause */; - }; - - HeritageClauseSyntax.prototype.childCount = function () { - return 2; - }; - - HeritageClauseSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.extendsOrImplementsKeyword; - case 1: - return this.typeNames; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - HeritageClauseSyntax.prototype.update = function (extendsOrImplementsKeyword, typeNames) { - if (this.extendsOrImplementsKeyword === extendsOrImplementsKeyword && this.typeNames === typeNames) { - return this; - } - - return new HeritageClauseSyntax(extendsOrImplementsKeyword, typeNames, this.parsedInStrictMode()); - }; - - HeritageClauseSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - HeritageClauseSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - HeritageClauseSyntax.prototype.withExtendsOrImplementsKeyword = function (extendsOrImplementsKeyword) { - return this.update(extendsOrImplementsKeyword, this.typeNames); - }; - - HeritageClauseSyntax.prototype.withTypeNames = function (typeNames) { - return this.update(this.extendsOrImplementsKeyword, typeNames); - }; - - HeritageClauseSyntax.prototype.withTypeName = function (typeName) { - return this.withTypeNames(TypeScript.Syntax.separatedList([typeName])); - }; - - HeritageClauseSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return HeritageClauseSyntax; - })(TypeScript.SyntaxNode); - TypeScript.HeritageClauseSyntax = HeritageClauseSyntax; - - var ModuleDeclarationSyntax = (function (_super) { - __extends(ModuleDeclarationSyntax, _super); - function ModuleDeclarationSyntax(modifiers, moduleKeyword, moduleName, stringLiteral, openBraceToken, moduleElements, closeBraceToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.modifiers = modifiers; - this.moduleKeyword = moduleKeyword; - this.moduleName = moduleName; - this.stringLiteral = stringLiteral; - this.openBraceToken = openBraceToken; - this.moduleElements = moduleElements; - this.closeBraceToken = closeBraceToken; - } - ModuleDeclarationSyntax.prototype.accept = function (visitor) { - return visitor.visitModuleDeclaration(this); - }; - - ModuleDeclarationSyntax.prototype.kind = function () { - return 130 /* ModuleDeclaration */; - }; - - ModuleDeclarationSyntax.prototype.childCount = function () { - return 7; - }; - - ModuleDeclarationSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.modifiers; - case 1: - return this.moduleKeyword; - case 2: - return this.moduleName; - case 3: - return this.stringLiteral; - case 4: - return this.openBraceToken; - case 5: - return this.moduleElements; - case 6: - return this.closeBraceToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ModuleDeclarationSyntax.prototype.isModuleElement = function () { - return true; - }; - - ModuleDeclarationSyntax.prototype.update = function (modifiers, moduleKeyword, moduleName, stringLiteral, openBraceToken, moduleElements, closeBraceToken) { - if (this.modifiers === modifiers && this.moduleKeyword === moduleKeyword && this.moduleName === moduleName && this.stringLiteral === stringLiteral && this.openBraceToken === openBraceToken && this.moduleElements === moduleElements && this.closeBraceToken === closeBraceToken) { - return this; - } - - return new ModuleDeclarationSyntax(modifiers, moduleKeyword, moduleName, stringLiteral, openBraceToken, moduleElements, closeBraceToken, this.parsedInStrictMode()); - }; - - ModuleDeclarationSyntax.create = function (moduleKeyword, openBraceToken, closeBraceToken) { - return new ModuleDeclarationSyntax(TypeScript.Syntax.emptyList, moduleKeyword, null, null, openBraceToken, TypeScript.Syntax.emptyList, closeBraceToken, false); - }; - - ModuleDeclarationSyntax.create1 = function () { - return new ModuleDeclarationSyntax(TypeScript.Syntax.emptyList, TypeScript.Syntax.token(66 /* ModuleKeyword */), null, null, TypeScript.Syntax.token(71 /* OpenBraceToken */), TypeScript.Syntax.emptyList, TypeScript.Syntax.token(72 /* CloseBraceToken */), false); - }; - - ModuleDeclarationSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ModuleDeclarationSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ModuleDeclarationSyntax.prototype.withModifiers = function (modifiers) { - return this.update(modifiers, this.moduleKeyword, this.moduleName, this.stringLiteral, this.openBraceToken, this.moduleElements, this.closeBraceToken); - }; - - ModuleDeclarationSyntax.prototype.withModifier = function (modifier) { - return this.withModifiers(TypeScript.Syntax.list([modifier])); - }; - - ModuleDeclarationSyntax.prototype.withModuleKeyword = function (moduleKeyword) { - return this.update(this.modifiers, moduleKeyword, this.moduleName, this.stringLiteral, this.openBraceToken, this.moduleElements, this.closeBraceToken); - }; - - ModuleDeclarationSyntax.prototype.withModuleName = function (moduleName) { - return this.update(this.modifiers, this.moduleKeyword, moduleName, this.stringLiteral, this.openBraceToken, this.moduleElements, this.closeBraceToken); - }; - - ModuleDeclarationSyntax.prototype.withStringLiteral = function (stringLiteral) { - return this.update(this.modifiers, this.moduleKeyword, this.moduleName, stringLiteral, this.openBraceToken, this.moduleElements, this.closeBraceToken); - }; - - ModuleDeclarationSyntax.prototype.withOpenBraceToken = function (openBraceToken) { - return this.update(this.modifiers, this.moduleKeyword, this.moduleName, this.stringLiteral, openBraceToken, this.moduleElements, this.closeBraceToken); - }; - - ModuleDeclarationSyntax.prototype.withModuleElements = function (moduleElements) { - return this.update(this.modifiers, this.moduleKeyword, this.moduleName, this.stringLiteral, this.openBraceToken, moduleElements, this.closeBraceToken); - }; - - ModuleDeclarationSyntax.prototype.withModuleElement = function (moduleElement) { - return this.withModuleElements(TypeScript.Syntax.list([moduleElement])); - }; - - ModuleDeclarationSyntax.prototype.withCloseBraceToken = function (closeBraceToken) { - return this.update(this.modifiers, this.moduleKeyword, this.moduleName, this.stringLiteral, this.openBraceToken, this.moduleElements, closeBraceToken); - }; - - ModuleDeclarationSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return ModuleDeclarationSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ModuleDeclarationSyntax = ModuleDeclarationSyntax; - - var FunctionDeclarationSyntax = (function (_super) { - __extends(FunctionDeclarationSyntax, _super); - function FunctionDeclarationSyntax(modifiers, functionKeyword, identifier, callSignature, block, semicolonToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.modifiers = modifiers; - this.functionKeyword = functionKeyword; - this.identifier = identifier; - this.callSignature = callSignature; - this.block = block; - this.semicolonToken = semicolonToken; - } - FunctionDeclarationSyntax.prototype.accept = function (visitor) { - return visitor.visitFunctionDeclaration(this); - }; - - FunctionDeclarationSyntax.prototype.kind = function () { - return 129 /* FunctionDeclaration */; - }; - - FunctionDeclarationSyntax.prototype.childCount = function () { - return 6; - }; - - FunctionDeclarationSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.modifiers; - case 1: - return this.functionKeyword; - case 2: - return this.identifier; - case 3: - return this.callSignature; - case 4: - return this.block; - case 5: - return this.semicolonToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - FunctionDeclarationSyntax.prototype.isStatement = function () { - return true; - }; - - FunctionDeclarationSyntax.prototype.isModuleElement = function () { - return true; - }; - - FunctionDeclarationSyntax.prototype.update = function (modifiers, functionKeyword, identifier, callSignature, block, semicolonToken) { - if (this.modifiers === modifiers && this.functionKeyword === functionKeyword && this.identifier === identifier && this.callSignature === callSignature && this.block === block && this.semicolonToken === semicolonToken) { - return this; - } - - return new FunctionDeclarationSyntax(modifiers, functionKeyword, identifier, callSignature, block, semicolonToken, this.parsedInStrictMode()); - }; - - FunctionDeclarationSyntax.create = function (functionKeyword, identifier, callSignature) { - return new FunctionDeclarationSyntax(TypeScript.Syntax.emptyList, functionKeyword, identifier, callSignature, null, null, false); - }; - - FunctionDeclarationSyntax.create1 = function (identifier) { - return new FunctionDeclarationSyntax(TypeScript.Syntax.emptyList, TypeScript.Syntax.token(27 /* FunctionKeyword */), identifier, CallSignatureSyntax.create1(), null, null, false); - }; - - FunctionDeclarationSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - FunctionDeclarationSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - FunctionDeclarationSyntax.prototype.withModifiers = function (modifiers) { - return this.update(modifiers, this.functionKeyword, this.identifier, this.callSignature, this.block, this.semicolonToken); - }; - - FunctionDeclarationSyntax.prototype.withModifier = function (modifier) { - return this.withModifiers(TypeScript.Syntax.list([modifier])); - }; - - FunctionDeclarationSyntax.prototype.withFunctionKeyword = function (functionKeyword) { - return this.update(this.modifiers, functionKeyword, this.identifier, this.callSignature, this.block, this.semicolonToken); - }; - - FunctionDeclarationSyntax.prototype.withIdentifier = function (identifier) { - return this.update(this.modifiers, this.functionKeyword, identifier, this.callSignature, this.block, this.semicolonToken); - }; - - FunctionDeclarationSyntax.prototype.withCallSignature = function (callSignature) { - return this.update(this.modifiers, this.functionKeyword, this.identifier, callSignature, this.block, this.semicolonToken); - }; - - FunctionDeclarationSyntax.prototype.withBlock = function (block) { - return this.update(this.modifiers, this.functionKeyword, this.identifier, this.callSignature, block, this.semicolonToken); - }; - - FunctionDeclarationSyntax.prototype.withSemicolonToken = function (semicolonToken) { - return this.update(this.modifiers, this.functionKeyword, this.identifier, this.callSignature, this.block, semicolonToken); - }; - - FunctionDeclarationSyntax.prototype.isTypeScriptSpecific = function () { - if (this.modifiers.isTypeScriptSpecific()) { - return true; - } - if (this.callSignature.isTypeScriptSpecific()) { - return true; - } - if (this.block !== null && this.block.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return FunctionDeclarationSyntax; - })(TypeScript.SyntaxNode); - TypeScript.FunctionDeclarationSyntax = FunctionDeclarationSyntax; - - var VariableStatementSyntax = (function (_super) { - __extends(VariableStatementSyntax, _super); - function VariableStatementSyntax(modifiers, variableDeclaration, semicolonToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.modifiers = modifiers; - this.variableDeclaration = variableDeclaration; - this.semicolonToken = semicolonToken; - } - VariableStatementSyntax.prototype.accept = function (visitor) { - return visitor.visitVariableStatement(this); - }; - - VariableStatementSyntax.prototype.kind = function () { - return 147 /* VariableStatement */; - }; - - VariableStatementSyntax.prototype.childCount = function () { - return 3; - }; - - VariableStatementSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.modifiers; - case 1: - return this.variableDeclaration; - case 2: - return this.semicolonToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - VariableStatementSyntax.prototype.isStatement = function () { - return true; - }; - - VariableStatementSyntax.prototype.isModuleElement = function () { - return true; - }; - - VariableStatementSyntax.prototype.update = function (modifiers, variableDeclaration, semicolonToken) { - if (this.modifiers === modifiers && this.variableDeclaration === variableDeclaration && this.semicolonToken === semicolonToken) { - return this; - } - - return new VariableStatementSyntax(modifiers, variableDeclaration, semicolonToken, this.parsedInStrictMode()); - }; - - VariableStatementSyntax.create = function (variableDeclaration, semicolonToken) { - return new VariableStatementSyntax(TypeScript.Syntax.emptyList, variableDeclaration, semicolonToken, false); - }; - - VariableStatementSyntax.create1 = function (variableDeclaration) { - return new VariableStatementSyntax(TypeScript.Syntax.emptyList, variableDeclaration, TypeScript.Syntax.token(79 /* SemicolonToken */), false); - }; - - VariableStatementSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - VariableStatementSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - VariableStatementSyntax.prototype.withModifiers = function (modifiers) { - return this.update(modifiers, this.variableDeclaration, this.semicolonToken); - }; - - VariableStatementSyntax.prototype.withModifier = function (modifier) { - return this.withModifiers(TypeScript.Syntax.list([modifier])); - }; - - VariableStatementSyntax.prototype.withVariableDeclaration = function (variableDeclaration) { - return this.update(this.modifiers, variableDeclaration, this.semicolonToken); - }; - - VariableStatementSyntax.prototype.withSemicolonToken = function (semicolonToken) { - return this.update(this.modifiers, this.variableDeclaration, semicolonToken); - }; - - VariableStatementSyntax.prototype.isTypeScriptSpecific = function () { - if (this.modifiers.isTypeScriptSpecific()) { - return true; - } - if (this.variableDeclaration.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return VariableStatementSyntax; - })(TypeScript.SyntaxNode); - TypeScript.VariableStatementSyntax = VariableStatementSyntax; - - var VariableDeclarationSyntax = (function (_super) { - __extends(VariableDeclarationSyntax, _super); - function VariableDeclarationSyntax(varKeyword, variableDeclarators, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.varKeyword = varKeyword; - this.variableDeclarators = variableDeclarators; - } - VariableDeclarationSyntax.prototype.accept = function (visitor) { - return visitor.visitVariableDeclaration(this); - }; - - VariableDeclarationSyntax.prototype.kind = function () { - return 223 /* VariableDeclaration */; - }; - - VariableDeclarationSyntax.prototype.childCount = function () { - return 2; - }; - - VariableDeclarationSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.varKeyword; - case 1: - return this.variableDeclarators; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - VariableDeclarationSyntax.prototype.update = function (varKeyword, variableDeclarators) { - if (this.varKeyword === varKeyword && this.variableDeclarators === variableDeclarators) { - return this; - } - - return new VariableDeclarationSyntax(varKeyword, variableDeclarators, this.parsedInStrictMode()); - }; - - VariableDeclarationSyntax.create1 = function (variableDeclarators) { - return new VariableDeclarationSyntax(TypeScript.Syntax.token(40 /* VarKeyword */), variableDeclarators, false); - }; - - VariableDeclarationSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - VariableDeclarationSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - VariableDeclarationSyntax.prototype.withVarKeyword = function (varKeyword) { - return this.update(varKeyword, this.variableDeclarators); - }; - - VariableDeclarationSyntax.prototype.withVariableDeclarators = function (variableDeclarators) { - return this.update(this.varKeyword, variableDeclarators); - }; - - VariableDeclarationSyntax.prototype.withVariableDeclarator = function (variableDeclarator) { - return this.withVariableDeclarators(TypeScript.Syntax.separatedList([variableDeclarator])); - }; - - VariableDeclarationSyntax.prototype.isTypeScriptSpecific = function () { - if (this.variableDeclarators.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return VariableDeclarationSyntax; - })(TypeScript.SyntaxNode); - TypeScript.VariableDeclarationSyntax = VariableDeclarationSyntax; - - var VariableDeclaratorSyntax = (function (_super) { - __extends(VariableDeclaratorSyntax, _super); - function VariableDeclaratorSyntax(identifier, typeAnnotation, equalsValueClause, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.identifier = identifier; - this.typeAnnotation = typeAnnotation; - this.equalsValueClause = equalsValueClause; - } - VariableDeclaratorSyntax.prototype.accept = function (visitor) { - return visitor.visitVariableDeclarator(this); - }; - - VariableDeclaratorSyntax.prototype.kind = function () { - return 224 /* VariableDeclarator */; - }; - - VariableDeclaratorSyntax.prototype.childCount = function () { - return 3; - }; - - VariableDeclaratorSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.identifier; - case 1: - return this.typeAnnotation; - case 2: - return this.equalsValueClause; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - VariableDeclaratorSyntax.prototype.update = function (identifier, typeAnnotation, equalsValueClause) { - if (this.identifier === identifier && this.typeAnnotation === typeAnnotation && this.equalsValueClause === equalsValueClause) { - return this; - } - - return new VariableDeclaratorSyntax(identifier, typeAnnotation, equalsValueClause, this.parsedInStrictMode()); - }; - - VariableDeclaratorSyntax.create = function (identifier) { - return new VariableDeclaratorSyntax(identifier, null, null, false); - }; - - VariableDeclaratorSyntax.create1 = function (identifier) { - return new VariableDeclaratorSyntax(identifier, null, null, false); - }; - - VariableDeclaratorSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - VariableDeclaratorSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - VariableDeclaratorSyntax.prototype.withIdentifier = function (identifier) { - return this.update(identifier, this.typeAnnotation, this.equalsValueClause); - }; - - VariableDeclaratorSyntax.prototype.withTypeAnnotation = function (typeAnnotation) { - return this.update(this.identifier, typeAnnotation, this.equalsValueClause); - }; - - VariableDeclaratorSyntax.prototype.withEqualsValueClause = function (equalsValueClause) { - return this.update(this.identifier, this.typeAnnotation, equalsValueClause); - }; - - VariableDeclaratorSyntax.prototype.isTypeScriptSpecific = function () { - if (this.typeAnnotation !== null) { - return true; - } - if (this.equalsValueClause !== null && this.equalsValueClause.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return VariableDeclaratorSyntax; - })(TypeScript.SyntaxNode); - TypeScript.VariableDeclaratorSyntax = VariableDeclaratorSyntax; - - var EqualsValueClauseSyntax = (function (_super) { - __extends(EqualsValueClauseSyntax, _super); - function EqualsValueClauseSyntax(equalsToken, value, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.equalsToken = equalsToken; - this.value = value; - } - EqualsValueClauseSyntax.prototype.accept = function (visitor) { - return visitor.visitEqualsValueClause(this); - }; - - EqualsValueClauseSyntax.prototype.kind = function () { - return 230 /* EqualsValueClause */; - }; - - EqualsValueClauseSyntax.prototype.childCount = function () { - return 2; - }; - - EqualsValueClauseSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.equalsToken; - case 1: - return this.value; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - EqualsValueClauseSyntax.prototype.update = function (equalsToken, value) { - if (this.equalsToken === equalsToken && this.value === value) { - return this; - } - - return new EqualsValueClauseSyntax(equalsToken, value, this.parsedInStrictMode()); - }; - - EqualsValueClauseSyntax.create1 = function (value) { - return new EqualsValueClauseSyntax(TypeScript.Syntax.token(108 /* EqualsToken */), value, false); - }; - - EqualsValueClauseSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - EqualsValueClauseSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - EqualsValueClauseSyntax.prototype.withEqualsToken = function (equalsToken) { - return this.update(equalsToken, this.value); - }; - - EqualsValueClauseSyntax.prototype.withValue = function (value) { - return this.update(this.equalsToken, value); - }; - - EqualsValueClauseSyntax.prototype.isTypeScriptSpecific = function () { - if (this.value.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return EqualsValueClauseSyntax; - })(TypeScript.SyntaxNode); - TypeScript.EqualsValueClauseSyntax = EqualsValueClauseSyntax; - - var PrefixUnaryExpressionSyntax = (function (_super) { - __extends(PrefixUnaryExpressionSyntax, _super); - function PrefixUnaryExpressionSyntax(kind, operatorToken, operand, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.operatorToken = operatorToken; - this.operand = operand; - - this._kind = kind; - } - PrefixUnaryExpressionSyntax.prototype.accept = function (visitor) { - return visitor.visitPrefixUnaryExpression(this); - }; - - PrefixUnaryExpressionSyntax.prototype.childCount = function () { - return 2; - }; - - PrefixUnaryExpressionSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.operatorToken; - case 1: - return this.operand; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - PrefixUnaryExpressionSyntax.prototype.isUnaryExpression = function () { - return true; - }; - - PrefixUnaryExpressionSyntax.prototype.isExpression = function () { - return true; - }; - - PrefixUnaryExpressionSyntax.prototype.kind = function () { - return this._kind; - }; - - PrefixUnaryExpressionSyntax.prototype.update = function (kind, operatorToken, operand) { - if (this._kind === kind && this.operatorToken === operatorToken && this.operand === operand) { - return this; - } - - return new PrefixUnaryExpressionSyntax(kind, operatorToken, operand, this.parsedInStrictMode()); - }; - - PrefixUnaryExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - PrefixUnaryExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - PrefixUnaryExpressionSyntax.prototype.withKind = function (kind) { - return this.update(kind, this.operatorToken, this.operand); - }; - - PrefixUnaryExpressionSyntax.prototype.withOperatorToken = function (operatorToken) { - return this.update(this._kind, operatorToken, this.operand); - }; - - PrefixUnaryExpressionSyntax.prototype.withOperand = function (operand) { - return this.update(this._kind, this.operatorToken, operand); - }; - - PrefixUnaryExpressionSyntax.prototype.isTypeScriptSpecific = function () { - if (this.operand.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return PrefixUnaryExpressionSyntax; - })(TypeScript.SyntaxNode); - TypeScript.PrefixUnaryExpressionSyntax = PrefixUnaryExpressionSyntax; - - var ArrayLiteralExpressionSyntax = (function (_super) { - __extends(ArrayLiteralExpressionSyntax, _super); - function ArrayLiteralExpressionSyntax(openBracketToken, expressions, closeBracketToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.openBracketToken = openBracketToken; - this.expressions = expressions; - this.closeBracketToken = closeBracketToken; - } - ArrayLiteralExpressionSyntax.prototype.accept = function (visitor) { - return visitor.visitArrayLiteralExpression(this); - }; - - ArrayLiteralExpressionSyntax.prototype.kind = function () { - return 213 /* ArrayLiteralExpression */; - }; - - ArrayLiteralExpressionSyntax.prototype.childCount = function () { - return 3; - }; - - ArrayLiteralExpressionSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.openBracketToken; - case 1: - return this.expressions; - case 2: - return this.closeBracketToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ArrayLiteralExpressionSyntax.prototype.isUnaryExpression = function () { - return true; - }; - - ArrayLiteralExpressionSyntax.prototype.isExpression = function () { - return true; - }; - - ArrayLiteralExpressionSyntax.prototype.update = function (openBracketToken, expressions, closeBracketToken) { - if (this.openBracketToken === openBracketToken && this.expressions === expressions && this.closeBracketToken === closeBracketToken) { - return this; - } - - return new ArrayLiteralExpressionSyntax(openBracketToken, expressions, closeBracketToken, this.parsedInStrictMode()); - }; - - ArrayLiteralExpressionSyntax.create = function (openBracketToken, closeBracketToken) { - return new ArrayLiteralExpressionSyntax(openBracketToken, TypeScript.Syntax.emptySeparatedList, closeBracketToken, false); - }; - - ArrayLiteralExpressionSyntax.create1 = function () { - return new ArrayLiteralExpressionSyntax(TypeScript.Syntax.token(75 /* OpenBracketToken */), TypeScript.Syntax.emptySeparatedList, TypeScript.Syntax.token(76 /* CloseBracketToken */), false); - }; - - ArrayLiteralExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ArrayLiteralExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ArrayLiteralExpressionSyntax.prototype.withOpenBracketToken = function (openBracketToken) { - return this.update(openBracketToken, this.expressions, this.closeBracketToken); - }; - - ArrayLiteralExpressionSyntax.prototype.withExpressions = function (expressions) { - return this.update(this.openBracketToken, expressions, this.closeBracketToken); - }; - - ArrayLiteralExpressionSyntax.prototype.withExpression = function (expression) { - return this.withExpressions(TypeScript.Syntax.separatedList([expression])); - }; - - ArrayLiteralExpressionSyntax.prototype.withCloseBracketToken = function (closeBracketToken) { - return this.update(this.openBracketToken, this.expressions, closeBracketToken); - }; - - ArrayLiteralExpressionSyntax.prototype.isTypeScriptSpecific = function () { - if (this.expressions.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return ArrayLiteralExpressionSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ArrayLiteralExpressionSyntax = ArrayLiteralExpressionSyntax; - - var OmittedExpressionSyntax = (function (_super) { - __extends(OmittedExpressionSyntax, _super); - function OmittedExpressionSyntax(parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - } - OmittedExpressionSyntax.prototype.accept = function (visitor) { - return visitor.visitOmittedExpression(this); - }; - - OmittedExpressionSyntax.prototype.kind = function () { - return 222 /* OmittedExpression */; - }; - - OmittedExpressionSyntax.prototype.childCount = function () { - return 0; - }; - - OmittedExpressionSyntax.prototype.childAt = function (slot) { - throw TypeScript.Errors.invalidOperation(); - }; - - OmittedExpressionSyntax.prototype.isExpression = function () { - return true; - }; - - OmittedExpressionSyntax.prototype.update = function () { - return this; - }; - - OmittedExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - OmittedExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - OmittedExpressionSyntax.prototype.isTypeScriptSpecific = function () { - return false; - }; - return OmittedExpressionSyntax; - })(TypeScript.SyntaxNode); - TypeScript.OmittedExpressionSyntax = OmittedExpressionSyntax; - - var ParenthesizedExpressionSyntax = (function (_super) { - __extends(ParenthesizedExpressionSyntax, _super); - function ParenthesizedExpressionSyntax(openParenToken, expression, closeParenToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.openParenToken = openParenToken; - this.expression = expression; - this.closeParenToken = closeParenToken; - } - ParenthesizedExpressionSyntax.prototype.accept = function (visitor) { - return visitor.visitParenthesizedExpression(this); - }; - - ParenthesizedExpressionSyntax.prototype.kind = function () { - return 216 /* ParenthesizedExpression */; - }; - - ParenthesizedExpressionSyntax.prototype.childCount = function () { - return 3; - }; - - ParenthesizedExpressionSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.openParenToken; - case 1: - return this.expression; - case 2: - return this.closeParenToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ParenthesizedExpressionSyntax.prototype.isUnaryExpression = function () { - return true; - }; - - ParenthesizedExpressionSyntax.prototype.isExpression = function () { - return true; - }; - - ParenthesizedExpressionSyntax.prototype.update = function (openParenToken, expression, closeParenToken) { - if (this.openParenToken === openParenToken && this.expression === expression && this.closeParenToken === closeParenToken) { - return this; - } - - return new ParenthesizedExpressionSyntax(openParenToken, expression, closeParenToken, this.parsedInStrictMode()); - }; - - ParenthesizedExpressionSyntax.create1 = function (expression) { - return new ParenthesizedExpressionSyntax(TypeScript.Syntax.token(73 /* OpenParenToken */), expression, TypeScript.Syntax.token(74 /* CloseParenToken */), false); - }; - - ParenthesizedExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ParenthesizedExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ParenthesizedExpressionSyntax.prototype.withOpenParenToken = function (openParenToken) { - return this.update(openParenToken, this.expression, this.closeParenToken); - }; - - ParenthesizedExpressionSyntax.prototype.withExpression = function (expression) { - return this.update(this.openParenToken, expression, this.closeParenToken); - }; - - ParenthesizedExpressionSyntax.prototype.withCloseParenToken = function (closeParenToken) { - return this.update(this.openParenToken, this.expression, closeParenToken); - }; - - ParenthesizedExpressionSyntax.prototype.isTypeScriptSpecific = function () { - if (this.expression.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return ParenthesizedExpressionSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ParenthesizedExpressionSyntax = ParenthesizedExpressionSyntax; - - var ArrowFunctionExpressionSyntax = (function (_super) { - __extends(ArrowFunctionExpressionSyntax, _super); - function ArrowFunctionExpressionSyntax(equalsGreaterThanToken, body, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.equalsGreaterThanToken = equalsGreaterThanToken; - this.body = body; - } - ArrowFunctionExpressionSyntax.prototype.isUnaryExpression = function () { - return true; - }; - - ArrowFunctionExpressionSyntax.prototype.isExpression = function () { - return true; - }; - - ArrowFunctionExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ArrowFunctionExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ArrowFunctionExpressionSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return ArrowFunctionExpressionSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ArrowFunctionExpressionSyntax = ArrowFunctionExpressionSyntax; - - var SimpleArrowFunctionExpressionSyntax = (function (_super) { - __extends(SimpleArrowFunctionExpressionSyntax, _super); - function SimpleArrowFunctionExpressionSyntax(identifier, equalsGreaterThanToken, body, parsedInStrictMode) { - _super.call(this, equalsGreaterThanToken, body, parsedInStrictMode); - this.identifier = identifier; - } - SimpleArrowFunctionExpressionSyntax.prototype.accept = function (visitor) { - return visitor.visitSimpleArrowFunctionExpression(this); - }; - - SimpleArrowFunctionExpressionSyntax.prototype.kind = function () { - return 218 /* SimpleArrowFunctionExpression */; - }; - - SimpleArrowFunctionExpressionSyntax.prototype.childCount = function () { - return 3; - }; - - SimpleArrowFunctionExpressionSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.identifier; - case 1: - return this.equalsGreaterThanToken; - case 2: - return this.body; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - SimpleArrowFunctionExpressionSyntax.prototype.update = function (identifier, equalsGreaterThanToken, body) { - if (this.identifier === identifier && this.equalsGreaterThanToken === equalsGreaterThanToken && this.body === body) { - return this; - } - - return new SimpleArrowFunctionExpressionSyntax(identifier, equalsGreaterThanToken, body, this.parsedInStrictMode()); - }; - - SimpleArrowFunctionExpressionSyntax.create1 = function (identifier, body) { - return new SimpleArrowFunctionExpressionSyntax(identifier, TypeScript.Syntax.token(86 /* EqualsGreaterThanToken */), body, false); - }; - - SimpleArrowFunctionExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - SimpleArrowFunctionExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - SimpleArrowFunctionExpressionSyntax.prototype.withIdentifier = function (identifier) { - return this.update(identifier, this.equalsGreaterThanToken, this.body); - }; - - SimpleArrowFunctionExpressionSyntax.prototype.withEqualsGreaterThanToken = function (equalsGreaterThanToken) { - return this.update(this.identifier, equalsGreaterThanToken, this.body); - }; - - SimpleArrowFunctionExpressionSyntax.prototype.withBody = function (body) { - return this.update(this.identifier, this.equalsGreaterThanToken, body); - }; - - SimpleArrowFunctionExpressionSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return SimpleArrowFunctionExpressionSyntax; - })(ArrowFunctionExpressionSyntax); - TypeScript.SimpleArrowFunctionExpressionSyntax = SimpleArrowFunctionExpressionSyntax; - - var ParenthesizedArrowFunctionExpressionSyntax = (function (_super) { - __extends(ParenthesizedArrowFunctionExpressionSyntax, _super); - function ParenthesizedArrowFunctionExpressionSyntax(callSignature, equalsGreaterThanToken, body, parsedInStrictMode) { - _super.call(this, equalsGreaterThanToken, body, parsedInStrictMode); - this.callSignature = callSignature; - } - ParenthesizedArrowFunctionExpressionSyntax.prototype.accept = function (visitor) { - return visitor.visitParenthesizedArrowFunctionExpression(this); - }; - - ParenthesizedArrowFunctionExpressionSyntax.prototype.kind = function () { - return 217 /* ParenthesizedArrowFunctionExpression */; - }; - - ParenthesizedArrowFunctionExpressionSyntax.prototype.childCount = function () { - return 3; - }; - - ParenthesizedArrowFunctionExpressionSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.callSignature; - case 1: - return this.equalsGreaterThanToken; - case 2: - return this.body; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ParenthesizedArrowFunctionExpressionSyntax.prototype.update = function (callSignature, equalsGreaterThanToken, body) { - if (this.callSignature === callSignature && this.equalsGreaterThanToken === equalsGreaterThanToken && this.body === body) { - return this; - } - - return new ParenthesizedArrowFunctionExpressionSyntax(callSignature, equalsGreaterThanToken, body, this.parsedInStrictMode()); - }; - - ParenthesizedArrowFunctionExpressionSyntax.create1 = function (body) { - return new ParenthesizedArrowFunctionExpressionSyntax(CallSignatureSyntax.create1(), TypeScript.Syntax.token(86 /* EqualsGreaterThanToken */), body, false); - }; - - ParenthesizedArrowFunctionExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ParenthesizedArrowFunctionExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ParenthesizedArrowFunctionExpressionSyntax.prototype.withCallSignature = function (callSignature) { - return this.update(callSignature, this.equalsGreaterThanToken, this.body); - }; - - ParenthesizedArrowFunctionExpressionSyntax.prototype.withEqualsGreaterThanToken = function (equalsGreaterThanToken) { - return this.update(this.callSignature, equalsGreaterThanToken, this.body); - }; - - ParenthesizedArrowFunctionExpressionSyntax.prototype.withBody = function (body) { - return this.update(this.callSignature, this.equalsGreaterThanToken, body); - }; - - ParenthesizedArrowFunctionExpressionSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return ParenthesizedArrowFunctionExpressionSyntax; - })(ArrowFunctionExpressionSyntax); - TypeScript.ParenthesizedArrowFunctionExpressionSyntax = ParenthesizedArrowFunctionExpressionSyntax; - - var QualifiedNameSyntax = (function (_super) { - __extends(QualifiedNameSyntax, _super); - function QualifiedNameSyntax(left, dotToken, right, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.left = left; - this.dotToken = dotToken; - this.right = right; - } - QualifiedNameSyntax.prototype.accept = function (visitor) { - return visitor.visitQualifiedName(this); - }; - - QualifiedNameSyntax.prototype.kind = function () { - return 122 /* QualifiedName */; - }; - - QualifiedNameSyntax.prototype.childCount = function () { - return 3; - }; - - QualifiedNameSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.left; - case 1: - return this.dotToken; - case 2: - return this.right; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - QualifiedNameSyntax.prototype.isName = function () { - return true; - }; - - QualifiedNameSyntax.prototype.isType = function () { - return true; - }; - - QualifiedNameSyntax.prototype.isUnaryExpression = function () { - return true; - }; - - QualifiedNameSyntax.prototype.isExpression = function () { - return true; - }; - - QualifiedNameSyntax.prototype.update = function (left, dotToken, right) { - if (this.left === left && this.dotToken === dotToken && this.right === right) { - return this; - } - - return new QualifiedNameSyntax(left, dotToken, right, this.parsedInStrictMode()); - }; - - QualifiedNameSyntax.create1 = function (left, right) { - return new QualifiedNameSyntax(left, TypeScript.Syntax.token(77 /* DotToken */), right, false); - }; - - QualifiedNameSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - QualifiedNameSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - QualifiedNameSyntax.prototype.withLeft = function (left) { - return this.update(left, this.dotToken, this.right); - }; - - QualifiedNameSyntax.prototype.withDotToken = function (dotToken) { - return this.update(this.left, dotToken, this.right); - }; - - QualifiedNameSyntax.prototype.withRight = function (right) { - return this.update(this.left, this.dotToken, right); - }; - - QualifiedNameSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return QualifiedNameSyntax; - })(TypeScript.SyntaxNode); - TypeScript.QualifiedNameSyntax = QualifiedNameSyntax; - - var TypeArgumentListSyntax = (function (_super) { - __extends(TypeArgumentListSyntax, _super); - function TypeArgumentListSyntax(lessThanToken, typeArguments, greaterThanToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.lessThanToken = lessThanToken; - this.typeArguments = typeArguments; - this.greaterThanToken = greaterThanToken; - } - TypeArgumentListSyntax.prototype.accept = function (visitor) { - return visitor.visitTypeArgumentList(this); - }; - - TypeArgumentListSyntax.prototype.kind = function () { - return 227 /* TypeArgumentList */; - }; - - TypeArgumentListSyntax.prototype.childCount = function () { - return 3; - }; - - TypeArgumentListSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.lessThanToken; - case 1: - return this.typeArguments; - case 2: - return this.greaterThanToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - TypeArgumentListSyntax.prototype.update = function (lessThanToken, typeArguments, greaterThanToken) { - if (this.lessThanToken === lessThanToken && this.typeArguments === typeArguments && this.greaterThanToken === greaterThanToken) { - return this; - } - - return new TypeArgumentListSyntax(lessThanToken, typeArguments, greaterThanToken, this.parsedInStrictMode()); - }; - - TypeArgumentListSyntax.create = function (lessThanToken, greaterThanToken) { - return new TypeArgumentListSyntax(lessThanToken, TypeScript.Syntax.emptySeparatedList, greaterThanToken, false); - }; - - TypeArgumentListSyntax.create1 = function () { - return new TypeArgumentListSyntax(TypeScript.Syntax.token(81 /* LessThanToken */), TypeScript.Syntax.emptySeparatedList, TypeScript.Syntax.token(82 /* GreaterThanToken */), false); - }; - - TypeArgumentListSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - TypeArgumentListSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - TypeArgumentListSyntax.prototype.withLessThanToken = function (lessThanToken) { - return this.update(lessThanToken, this.typeArguments, this.greaterThanToken); - }; - - TypeArgumentListSyntax.prototype.withTypeArguments = function (typeArguments) { - return this.update(this.lessThanToken, typeArguments, this.greaterThanToken); - }; - - TypeArgumentListSyntax.prototype.withTypeArgument = function (typeArgument) { - return this.withTypeArguments(TypeScript.Syntax.separatedList([typeArgument])); - }; - - TypeArgumentListSyntax.prototype.withGreaterThanToken = function (greaterThanToken) { - return this.update(this.lessThanToken, this.typeArguments, greaterThanToken); - }; - - TypeArgumentListSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return TypeArgumentListSyntax; - })(TypeScript.SyntaxNode); - TypeScript.TypeArgumentListSyntax = TypeArgumentListSyntax; - - var ConstructorTypeSyntax = (function (_super) { - __extends(ConstructorTypeSyntax, _super); - function ConstructorTypeSyntax(newKeyword, typeParameterList, parameterList, equalsGreaterThanToken, type, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.newKeyword = newKeyword; - this.typeParameterList = typeParameterList; - this.parameterList = parameterList; - this.equalsGreaterThanToken = equalsGreaterThanToken; - this.type = type; - } - ConstructorTypeSyntax.prototype.accept = function (visitor) { - return visitor.visitConstructorType(this); - }; - - ConstructorTypeSyntax.prototype.kind = function () { - return 126 /* ConstructorType */; - }; - - ConstructorTypeSyntax.prototype.childCount = function () { - return 5; - }; - - ConstructorTypeSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.newKeyword; - case 1: - return this.typeParameterList; - case 2: - return this.parameterList; - case 3: - return this.equalsGreaterThanToken; - case 4: - return this.type; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ConstructorTypeSyntax.prototype.isType = function () { - return true; - }; - - ConstructorTypeSyntax.prototype.isUnaryExpression = function () { - return true; - }; - - ConstructorTypeSyntax.prototype.isExpression = function () { - return true; - }; - - ConstructorTypeSyntax.prototype.update = function (newKeyword, typeParameterList, parameterList, equalsGreaterThanToken, type) { - if (this.newKeyword === newKeyword && this.typeParameterList === typeParameterList && this.parameterList === parameterList && this.equalsGreaterThanToken === equalsGreaterThanToken && this.type === type) { - return this; - } - - return new ConstructorTypeSyntax(newKeyword, typeParameterList, parameterList, equalsGreaterThanToken, type, this.parsedInStrictMode()); - }; - - ConstructorTypeSyntax.create = function (newKeyword, parameterList, equalsGreaterThanToken, type) { - return new ConstructorTypeSyntax(newKeyword, null, parameterList, equalsGreaterThanToken, type, false); - }; - - ConstructorTypeSyntax.create1 = function (type) { - return new ConstructorTypeSyntax(TypeScript.Syntax.token(31 /* NewKeyword */), null, ParameterListSyntax.create1(), TypeScript.Syntax.token(86 /* EqualsGreaterThanToken */), type, false); - }; - - ConstructorTypeSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ConstructorTypeSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ConstructorTypeSyntax.prototype.withNewKeyword = function (newKeyword) { - return this.update(newKeyword, this.typeParameterList, this.parameterList, this.equalsGreaterThanToken, this.type); - }; - - ConstructorTypeSyntax.prototype.withTypeParameterList = function (typeParameterList) { - return this.update(this.newKeyword, typeParameterList, this.parameterList, this.equalsGreaterThanToken, this.type); - }; - - ConstructorTypeSyntax.prototype.withParameterList = function (parameterList) { - return this.update(this.newKeyword, this.typeParameterList, parameterList, this.equalsGreaterThanToken, this.type); - }; - - ConstructorTypeSyntax.prototype.withEqualsGreaterThanToken = function (equalsGreaterThanToken) { - return this.update(this.newKeyword, this.typeParameterList, this.parameterList, equalsGreaterThanToken, this.type); - }; - - ConstructorTypeSyntax.prototype.withType = function (type) { - return this.update(this.newKeyword, this.typeParameterList, this.parameterList, this.equalsGreaterThanToken, type); - }; - - ConstructorTypeSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return ConstructorTypeSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ConstructorTypeSyntax = ConstructorTypeSyntax; - - var FunctionTypeSyntax = (function (_super) { - __extends(FunctionTypeSyntax, _super); - function FunctionTypeSyntax(typeParameterList, parameterList, equalsGreaterThanToken, type, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.typeParameterList = typeParameterList; - this.parameterList = parameterList; - this.equalsGreaterThanToken = equalsGreaterThanToken; - this.type = type; - } - FunctionTypeSyntax.prototype.accept = function (visitor) { - return visitor.visitFunctionType(this); - }; - - FunctionTypeSyntax.prototype.kind = function () { - return 124 /* FunctionType */; - }; - - FunctionTypeSyntax.prototype.childCount = function () { - return 4; - }; - - FunctionTypeSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.typeParameterList; - case 1: - return this.parameterList; - case 2: - return this.equalsGreaterThanToken; - case 3: - return this.type; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - FunctionTypeSyntax.prototype.isType = function () { - return true; - }; - - FunctionTypeSyntax.prototype.isUnaryExpression = function () { - return true; - }; - - FunctionTypeSyntax.prototype.isExpression = function () { - return true; - }; - - FunctionTypeSyntax.prototype.update = function (typeParameterList, parameterList, equalsGreaterThanToken, type) { - if (this.typeParameterList === typeParameterList && this.parameterList === parameterList && this.equalsGreaterThanToken === equalsGreaterThanToken && this.type === type) { - return this; - } - - return new FunctionTypeSyntax(typeParameterList, parameterList, equalsGreaterThanToken, type, this.parsedInStrictMode()); - }; - - FunctionTypeSyntax.create = function (parameterList, equalsGreaterThanToken, type) { - return new FunctionTypeSyntax(null, parameterList, equalsGreaterThanToken, type, false); - }; - - FunctionTypeSyntax.create1 = function (type) { - return new FunctionTypeSyntax(null, ParameterListSyntax.create1(), TypeScript.Syntax.token(86 /* EqualsGreaterThanToken */), type, false); - }; - - FunctionTypeSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - FunctionTypeSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - FunctionTypeSyntax.prototype.withTypeParameterList = function (typeParameterList) { - return this.update(typeParameterList, this.parameterList, this.equalsGreaterThanToken, this.type); - }; - - FunctionTypeSyntax.prototype.withParameterList = function (parameterList) { - return this.update(this.typeParameterList, parameterList, this.equalsGreaterThanToken, this.type); - }; - - FunctionTypeSyntax.prototype.withEqualsGreaterThanToken = function (equalsGreaterThanToken) { - return this.update(this.typeParameterList, this.parameterList, equalsGreaterThanToken, this.type); - }; - - FunctionTypeSyntax.prototype.withType = function (type) { - return this.update(this.typeParameterList, this.parameterList, this.equalsGreaterThanToken, type); - }; - - FunctionTypeSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return FunctionTypeSyntax; - })(TypeScript.SyntaxNode); - TypeScript.FunctionTypeSyntax = FunctionTypeSyntax; - - var ObjectTypeSyntax = (function (_super) { - __extends(ObjectTypeSyntax, _super); - function ObjectTypeSyntax(openBraceToken, typeMembers, closeBraceToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.openBraceToken = openBraceToken; - this.typeMembers = typeMembers; - this.closeBraceToken = closeBraceToken; - } - ObjectTypeSyntax.prototype.accept = function (visitor) { - return visitor.visitObjectType(this); - }; - - ObjectTypeSyntax.prototype.kind = function () { - return 123 /* ObjectType */; - }; - - ObjectTypeSyntax.prototype.childCount = function () { - return 3; - }; - - ObjectTypeSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.openBraceToken; - case 1: - return this.typeMembers; - case 2: - return this.closeBraceToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ObjectTypeSyntax.prototype.isType = function () { - return true; - }; - - ObjectTypeSyntax.prototype.isUnaryExpression = function () { - return true; - }; - - ObjectTypeSyntax.prototype.isExpression = function () { - return true; - }; - - ObjectTypeSyntax.prototype.update = function (openBraceToken, typeMembers, closeBraceToken) { - if (this.openBraceToken === openBraceToken && this.typeMembers === typeMembers && this.closeBraceToken === closeBraceToken) { - return this; - } - - return new ObjectTypeSyntax(openBraceToken, typeMembers, closeBraceToken, this.parsedInStrictMode()); - }; - - ObjectTypeSyntax.create = function (openBraceToken, closeBraceToken) { - return new ObjectTypeSyntax(openBraceToken, TypeScript.Syntax.emptySeparatedList, closeBraceToken, false); - }; - - ObjectTypeSyntax.create1 = function () { - return new ObjectTypeSyntax(TypeScript.Syntax.token(71 /* OpenBraceToken */), TypeScript.Syntax.emptySeparatedList, TypeScript.Syntax.token(72 /* CloseBraceToken */), false); - }; - - ObjectTypeSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ObjectTypeSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ObjectTypeSyntax.prototype.withOpenBraceToken = function (openBraceToken) { - return this.update(openBraceToken, this.typeMembers, this.closeBraceToken); - }; - - ObjectTypeSyntax.prototype.withTypeMembers = function (typeMembers) { - return this.update(this.openBraceToken, typeMembers, this.closeBraceToken); - }; - - ObjectTypeSyntax.prototype.withTypeMember = function (typeMember) { - return this.withTypeMembers(TypeScript.Syntax.separatedList([typeMember])); - }; - - ObjectTypeSyntax.prototype.withCloseBraceToken = function (closeBraceToken) { - return this.update(this.openBraceToken, this.typeMembers, closeBraceToken); - }; - - ObjectTypeSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return ObjectTypeSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ObjectTypeSyntax = ObjectTypeSyntax; - - var ArrayTypeSyntax = (function (_super) { - __extends(ArrayTypeSyntax, _super); - function ArrayTypeSyntax(type, openBracketToken, closeBracketToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.type = type; - this.openBracketToken = openBracketToken; - this.closeBracketToken = closeBracketToken; - } - ArrayTypeSyntax.prototype.accept = function (visitor) { - return visitor.visitArrayType(this); - }; - - ArrayTypeSyntax.prototype.kind = function () { - return 125 /* ArrayType */; - }; - - ArrayTypeSyntax.prototype.childCount = function () { - return 3; - }; - - ArrayTypeSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.type; - case 1: - return this.openBracketToken; - case 2: - return this.closeBracketToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ArrayTypeSyntax.prototype.isType = function () { - return true; - }; - - ArrayTypeSyntax.prototype.isUnaryExpression = function () { - return true; - }; - - ArrayTypeSyntax.prototype.isExpression = function () { - return true; - }; - - ArrayTypeSyntax.prototype.update = function (type, openBracketToken, closeBracketToken) { - if (this.type === type && this.openBracketToken === openBracketToken && this.closeBracketToken === closeBracketToken) { - return this; - } - - return new ArrayTypeSyntax(type, openBracketToken, closeBracketToken, this.parsedInStrictMode()); - }; - - ArrayTypeSyntax.create1 = function (type) { - return new ArrayTypeSyntax(type, TypeScript.Syntax.token(75 /* OpenBracketToken */), TypeScript.Syntax.token(76 /* CloseBracketToken */), false); - }; - - ArrayTypeSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ArrayTypeSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ArrayTypeSyntax.prototype.withType = function (type) { - return this.update(type, this.openBracketToken, this.closeBracketToken); - }; - - ArrayTypeSyntax.prototype.withOpenBracketToken = function (openBracketToken) { - return this.update(this.type, openBracketToken, this.closeBracketToken); - }; - - ArrayTypeSyntax.prototype.withCloseBracketToken = function (closeBracketToken) { - return this.update(this.type, this.openBracketToken, closeBracketToken); - }; - - ArrayTypeSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return ArrayTypeSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ArrayTypeSyntax = ArrayTypeSyntax; - - var GenericTypeSyntax = (function (_super) { - __extends(GenericTypeSyntax, _super); - function GenericTypeSyntax(name, typeArgumentList, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.name = name; - this.typeArgumentList = typeArgumentList; - } - GenericTypeSyntax.prototype.accept = function (visitor) { - return visitor.visitGenericType(this); - }; - - GenericTypeSyntax.prototype.kind = function () { - return 127 /* GenericType */; - }; - - GenericTypeSyntax.prototype.childCount = function () { - return 2; - }; - - GenericTypeSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.name; - case 1: - return this.typeArgumentList; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - GenericTypeSyntax.prototype.isType = function () { - return true; - }; - - GenericTypeSyntax.prototype.isUnaryExpression = function () { - return true; - }; - - GenericTypeSyntax.prototype.isExpression = function () { - return true; - }; - - GenericTypeSyntax.prototype.update = function (name, typeArgumentList) { - if (this.name === name && this.typeArgumentList === typeArgumentList) { - return this; - } - - return new GenericTypeSyntax(name, typeArgumentList, this.parsedInStrictMode()); - }; - - GenericTypeSyntax.create1 = function (name) { - return new GenericTypeSyntax(name, TypeArgumentListSyntax.create1(), false); - }; - - GenericTypeSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - GenericTypeSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - GenericTypeSyntax.prototype.withName = function (name) { - return this.update(name, this.typeArgumentList); - }; - - GenericTypeSyntax.prototype.withTypeArgumentList = function (typeArgumentList) { - return this.update(this.name, typeArgumentList); - }; - - GenericTypeSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return GenericTypeSyntax; - })(TypeScript.SyntaxNode); - TypeScript.GenericTypeSyntax = GenericTypeSyntax; - - var TypeAnnotationSyntax = (function (_super) { - __extends(TypeAnnotationSyntax, _super); - function TypeAnnotationSyntax(colonToken, type, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.colonToken = colonToken; - this.type = type; - } - TypeAnnotationSyntax.prototype.accept = function (visitor) { - return visitor.visitTypeAnnotation(this); - }; - - TypeAnnotationSyntax.prototype.kind = function () { - return 244 /* TypeAnnotation */; - }; - - TypeAnnotationSyntax.prototype.childCount = function () { - return 2; - }; - - TypeAnnotationSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.colonToken; - case 1: - return this.type; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - TypeAnnotationSyntax.prototype.update = function (colonToken, type) { - if (this.colonToken === colonToken && this.type === type) { - return this; - } - - return new TypeAnnotationSyntax(colonToken, type, this.parsedInStrictMode()); - }; - - TypeAnnotationSyntax.create1 = function (type) { - return new TypeAnnotationSyntax(TypeScript.Syntax.token(107 /* ColonToken */), type, false); - }; - - TypeAnnotationSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - TypeAnnotationSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - TypeAnnotationSyntax.prototype.withColonToken = function (colonToken) { - return this.update(colonToken, this.type); - }; - - TypeAnnotationSyntax.prototype.withType = function (type) { - return this.update(this.colonToken, type); - }; - - TypeAnnotationSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return TypeAnnotationSyntax; - })(TypeScript.SyntaxNode); - TypeScript.TypeAnnotationSyntax = TypeAnnotationSyntax; - - var BlockSyntax = (function (_super) { - __extends(BlockSyntax, _super); - function BlockSyntax(openBraceToken, statements, closeBraceToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.openBraceToken = openBraceToken; - this.statements = statements; - this.closeBraceToken = closeBraceToken; - } - BlockSyntax.prototype.accept = function (visitor) { - return visitor.visitBlock(this); - }; - - BlockSyntax.prototype.kind = function () { - return 145 /* Block */; - }; - - BlockSyntax.prototype.childCount = function () { - return 3; - }; - - BlockSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.openBraceToken; - case 1: - return this.statements; - case 2: - return this.closeBraceToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - BlockSyntax.prototype.isStatement = function () { - return true; - }; - - BlockSyntax.prototype.isModuleElement = function () { - return true; - }; - - BlockSyntax.prototype.update = function (openBraceToken, statements, closeBraceToken) { - if (this.openBraceToken === openBraceToken && this.statements === statements && this.closeBraceToken === closeBraceToken) { - return this; - } - - return new BlockSyntax(openBraceToken, statements, closeBraceToken, this.parsedInStrictMode()); - }; - - BlockSyntax.create = function (openBraceToken, closeBraceToken) { - return new BlockSyntax(openBraceToken, TypeScript.Syntax.emptyList, closeBraceToken, false); - }; - - BlockSyntax.create1 = function () { - return new BlockSyntax(TypeScript.Syntax.token(71 /* OpenBraceToken */), TypeScript.Syntax.emptyList, TypeScript.Syntax.token(72 /* CloseBraceToken */), false); - }; - - BlockSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - BlockSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - BlockSyntax.prototype.withOpenBraceToken = function (openBraceToken) { - return this.update(openBraceToken, this.statements, this.closeBraceToken); - }; - - BlockSyntax.prototype.withStatements = function (statements) { - return this.update(this.openBraceToken, statements, this.closeBraceToken); - }; - - BlockSyntax.prototype.withStatement = function (statement) { - return this.withStatements(TypeScript.Syntax.list([statement])); - }; - - BlockSyntax.prototype.withCloseBraceToken = function (closeBraceToken) { - return this.update(this.openBraceToken, this.statements, closeBraceToken); - }; - - BlockSyntax.prototype.isTypeScriptSpecific = function () { - if (this.statements.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return BlockSyntax; - })(TypeScript.SyntaxNode); - TypeScript.BlockSyntax = BlockSyntax; - - var ParameterSyntax = (function (_super) { - __extends(ParameterSyntax, _super); - function ParameterSyntax(dotDotDotToken, publicOrPrivateKeyword, identifier, questionToken, typeAnnotation, equalsValueClause, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.dotDotDotToken = dotDotDotToken; - this.publicOrPrivateKeyword = publicOrPrivateKeyword; - this.identifier = identifier; - this.questionToken = questionToken; - this.typeAnnotation = typeAnnotation; - this.equalsValueClause = equalsValueClause; - } - ParameterSyntax.prototype.accept = function (visitor) { - return visitor.visitParameter(this); - }; - - ParameterSyntax.prototype.kind = function () { - return 242 /* Parameter */; - }; - - ParameterSyntax.prototype.childCount = function () { - return 6; - }; - - ParameterSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.dotDotDotToken; - case 1: - return this.publicOrPrivateKeyword; - case 2: - return this.identifier; - case 3: - return this.questionToken; - case 4: - return this.typeAnnotation; - case 5: - return this.equalsValueClause; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ParameterSyntax.prototype.update = function (dotDotDotToken, publicOrPrivateKeyword, identifier, questionToken, typeAnnotation, equalsValueClause) { - if (this.dotDotDotToken === dotDotDotToken && this.publicOrPrivateKeyword === publicOrPrivateKeyword && this.identifier === identifier && this.questionToken === questionToken && this.typeAnnotation === typeAnnotation && this.equalsValueClause === equalsValueClause) { - return this; - } - - return new ParameterSyntax(dotDotDotToken, publicOrPrivateKeyword, identifier, questionToken, typeAnnotation, equalsValueClause, this.parsedInStrictMode()); - }; - - ParameterSyntax.create = function (identifier) { - return new ParameterSyntax(null, null, identifier, null, null, null, false); - }; - - ParameterSyntax.create1 = function (identifier) { - return new ParameterSyntax(null, null, identifier, null, null, null, false); - }; - - ParameterSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ParameterSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ParameterSyntax.prototype.withDotDotDotToken = function (dotDotDotToken) { - return this.update(dotDotDotToken, this.publicOrPrivateKeyword, this.identifier, this.questionToken, this.typeAnnotation, this.equalsValueClause); - }; - - ParameterSyntax.prototype.withPublicOrPrivateKeyword = function (publicOrPrivateKeyword) { - return this.update(this.dotDotDotToken, publicOrPrivateKeyword, this.identifier, this.questionToken, this.typeAnnotation, this.equalsValueClause); - }; - - ParameterSyntax.prototype.withIdentifier = function (identifier) { - return this.update(this.dotDotDotToken, this.publicOrPrivateKeyword, identifier, this.questionToken, this.typeAnnotation, this.equalsValueClause); - }; - - ParameterSyntax.prototype.withQuestionToken = function (questionToken) { - return this.update(this.dotDotDotToken, this.publicOrPrivateKeyword, this.identifier, questionToken, this.typeAnnotation, this.equalsValueClause); - }; - - ParameterSyntax.prototype.withTypeAnnotation = function (typeAnnotation) { - return this.update(this.dotDotDotToken, this.publicOrPrivateKeyword, this.identifier, this.questionToken, typeAnnotation, this.equalsValueClause); - }; - - ParameterSyntax.prototype.withEqualsValueClause = function (equalsValueClause) { - return this.update(this.dotDotDotToken, this.publicOrPrivateKeyword, this.identifier, this.questionToken, this.typeAnnotation, equalsValueClause); - }; - - ParameterSyntax.prototype.isTypeScriptSpecific = function () { - if (this.dotDotDotToken !== null) { - return true; - } - if (this.publicOrPrivateKeyword !== null) { - return true; - } - if (this.questionToken !== null) { - return true; - } - if (this.typeAnnotation !== null) { - return true; - } - if (this.equalsValueClause !== null) { - return true; - } - return false; - }; - return ParameterSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ParameterSyntax = ParameterSyntax; - - var MemberAccessExpressionSyntax = (function (_super) { - __extends(MemberAccessExpressionSyntax, _super); - function MemberAccessExpressionSyntax(expression, dotToken, name, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.expression = expression; - this.dotToken = dotToken; - this.name = name; - } - MemberAccessExpressionSyntax.prototype.accept = function (visitor) { - return visitor.visitMemberAccessExpression(this); - }; - - MemberAccessExpressionSyntax.prototype.kind = function () { - return 211 /* MemberAccessExpression */; - }; - - MemberAccessExpressionSyntax.prototype.childCount = function () { - return 3; - }; - - MemberAccessExpressionSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.expression; - case 1: - return this.dotToken; - case 2: - return this.name; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - MemberAccessExpressionSyntax.prototype.isUnaryExpression = function () { - return true; - }; - - MemberAccessExpressionSyntax.prototype.isExpression = function () { - return true; - }; - - MemberAccessExpressionSyntax.prototype.update = function (expression, dotToken, name) { - if (this.expression === expression && this.dotToken === dotToken && this.name === name) { - return this; - } - - return new MemberAccessExpressionSyntax(expression, dotToken, name, this.parsedInStrictMode()); - }; - - MemberAccessExpressionSyntax.create1 = function (expression, name) { - return new MemberAccessExpressionSyntax(expression, TypeScript.Syntax.token(77 /* DotToken */), name, false); - }; - - MemberAccessExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - MemberAccessExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - MemberAccessExpressionSyntax.prototype.withExpression = function (expression) { - return this.update(expression, this.dotToken, this.name); - }; - - MemberAccessExpressionSyntax.prototype.withDotToken = function (dotToken) { - return this.update(this.expression, dotToken, this.name); - }; - - MemberAccessExpressionSyntax.prototype.withName = function (name) { - return this.update(this.expression, this.dotToken, name); - }; - - MemberAccessExpressionSyntax.prototype.isTypeScriptSpecific = function () { - if (this.expression.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return MemberAccessExpressionSyntax; - })(TypeScript.SyntaxNode); - TypeScript.MemberAccessExpressionSyntax = MemberAccessExpressionSyntax; - - var PostfixUnaryExpressionSyntax = (function (_super) { - __extends(PostfixUnaryExpressionSyntax, _super); - function PostfixUnaryExpressionSyntax(kind, operand, operatorToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.operand = operand; - this.operatorToken = operatorToken; - - this._kind = kind; - } - PostfixUnaryExpressionSyntax.prototype.accept = function (visitor) { - return visitor.visitPostfixUnaryExpression(this); - }; - - PostfixUnaryExpressionSyntax.prototype.childCount = function () { - return 2; - }; - - PostfixUnaryExpressionSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.operand; - case 1: - return this.operatorToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - PostfixUnaryExpressionSyntax.prototype.isUnaryExpression = function () { - return true; - }; - - PostfixUnaryExpressionSyntax.prototype.isExpression = function () { - return true; - }; - - PostfixUnaryExpressionSyntax.prototype.kind = function () { - return this._kind; - }; - - PostfixUnaryExpressionSyntax.prototype.update = function (kind, operand, operatorToken) { - if (this._kind === kind && this.operand === operand && this.operatorToken === operatorToken) { - return this; - } - - return new PostfixUnaryExpressionSyntax(kind, operand, operatorToken, this.parsedInStrictMode()); - }; - - PostfixUnaryExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - PostfixUnaryExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - PostfixUnaryExpressionSyntax.prototype.withKind = function (kind) { - return this.update(kind, this.operand, this.operatorToken); - }; - - PostfixUnaryExpressionSyntax.prototype.withOperand = function (operand) { - return this.update(this._kind, operand, this.operatorToken); - }; - - PostfixUnaryExpressionSyntax.prototype.withOperatorToken = function (operatorToken) { - return this.update(this._kind, this.operand, operatorToken); - }; - - PostfixUnaryExpressionSyntax.prototype.isTypeScriptSpecific = function () { - if (this.operand.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return PostfixUnaryExpressionSyntax; - })(TypeScript.SyntaxNode); - TypeScript.PostfixUnaryExpressionSyntax = PostfixUnaryExpressionSyntax; - - var ElementAccessExpressionSyntax = (function (_super) { - __extends(ElementAccessExpressionSyntax, _super); - function ElementAccessExpressionSyntax(expression, openBracketToken, argumentExpression, closeBracketToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.expression = expression; - this.openBracketToken = openBracketToken; - this.argumentExpression = argumentExpression; - this.closeBracketToken = closeBracketToken; - } - ElementAccessExpressionSyntax.prototype.accept = function (visitor) { - return visitor.visitElementAccessExpression(this); - }; - - ElementAccessExpressionSyntax.prototype.kind = function () { - return 220 /* ElementAccessExpression */; - }; - - ElementAccessExpressionSyntax.prototype.childCount = function () { - return 4; - }; - - ElementAccessExpressionSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.expression; - case 1: - return this.openBracketToken; - case 2: - return this.argumentExpression; - case 3: - return this.closeBracketToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ElementAccessExpressionSyntax.prototype.isUnaryExpression = function () { - return true; - }; - - ElementAccessExpressionSyntax.prototype.isExpression = function () { - return true; - }; - - ElementAccessExpressionSyntax.prototype.update = function (expression, openBracketToken, argumentExpression, closeBracketToken) { - if (this.expression === expression && this.openBracketToken === openBracketToken && this.argumentExpression === argumentExpression && this.closeBracketToken === closeBracketToken) { - return this; - } - - return new ElementAccessExpressionSyntax(expression, openBracketToken, argumentExpression, closeBracketToken, this.parsedInStrictMode()); - }; - - ElementAccessExpressionSyntax.create1 = function (expression, argumentExpression) { - return new ElementAccessExpressionSyntax(expression, TypeScript.Syntax.token(75 /* OpenBracketToken */), argumentExpression, TypeScript.Syntax.token(76 /* CloseBracketToken */), false); - }; - - ElementAccessExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ElementAccessExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ElementAccessExpressionSyntax.prototype.withExpression = function (expression) { - return this.update(expression, this.openBracketToken, this.argumentExpression, this.closeBracketToken); - }; - - ElementAccessExpressionSyntax.prototype.withOpenBracketToken = function (openBracketToken) { - return this.update(this.expression, openBracketToken, this.argumentExpression, this.closeBracketToken); - }; - - ElementAccessExpressionSyntax.prototype.withArgumentExpression = function (argumentExpression) { - return this.update(this.expression, this.openBracketToken, argumentExpression, this.closeBracketToken); - }; - - ElementAccessExpressionSyntax.prototype.withCloseBracketToken = function (closeBracketToken) { - return this.update(this.expression, this.openBracketToken, this.argumentExpression, closeBracketToken); - }; - - ElementAccessExpressionSyntax.prototype.isTypeScriptSpecific = function () { - if (this.expression.isTypeScriptSpecific()) { - return true; - } - if (this.argumentExpression.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return ElementAccessExpressionSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ElementAccessExpressionSyntax = ElementAccessExpressionSyntax; - - var InvocationExpressionSyntax = (function (_super) { - __extends(InvocationExpressionSyntax, _super); - function InvocationExpressionSyntax(expression, argumentList, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.expression = expression; - this.argumentList = argumentList; - } - InvocationExpressionSyntax.prototype.accept = function (visitor) { - return visitor.visitInvocationExpression(this); - }; - - InvocationExpressionSyntax.prototype.kind = function () { - return 212 /* InvocationExpression */; - }; - - InvocationExpressionSyntax.prototype.childCount = function () { - return 2; - }; - - InvocationExpressionSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.expression; - case 1: - return this.argumentList; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - InvocationExpressionSyntax.prototype.isUnaryExpression = function () { - return true; - }; - - InvocationExpressionSyntax.prototype.isExpression = function () { - return true; - }; - - InvocationExpressionSyntax.prototype.update = function (expression, argumentList) { - if (this.expression === expression && this.argumentList === argumentList) { - return this; - } - - return new InvocationExpressionSyntax(expression, argumentList, this.parsedInStrictMode()); - }; - - InvocationExpressionSyntax.create1 = function (expression) { - return new InvocationExpressionSyntax(expression, ArgumentListSyntax.create1(), false); - }; - - InvocationExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - InvocationExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - InvocationExpressionSyntax.prototype.withExpression = function (expression) { - return this.update(expression, this.argumentList); - }; - - InvocationExpressionSyntax.prototype.withArgumentList = function (argumentList) { - return this.update(this.expression, argumentList); - }; - - InvocationExpressionSyntax.prototype.isTypeScriptSpecific = function () { - if (this.expression.isTypeScriptSpecific()) { - return true; - } - if (this.argumentList.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return InvocationExpressionSyntax; - })(TypeScript.SyntaxNode); - TypeScript.InvocationExpressionSyntax = InvocationExpressionSyntax; - - var ArgumentListSyntax = (function (_super) { - __extends(ArgumentListSyntax, _super); - function ArgumentListSyntax(typeArgumentList, openParenToken, arguments, closeParenToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.typeArgumentList = typeArgumentList; - this.openParenToken = openParenToken; - this.arguments = arguments; - this.closeParenToken = closeParenToken; - } - ArgumentListSyntax.prototype.accept = function (visitor) { - return visitor.visitArgumentList(this); - }; - - ArgumentListSyntax.prototype.kind = function () { - return 225 /* ArgumentList */; - }; - - ArgumentListSyntax.prototype.childCount = function () { - return 4; - }; - - ArgumentListSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.typeArgumentList; - case 1: - return this.openParenToken; - case 2: - return this.arguments; - case 3: - return this.closeParenToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ArgumentListSyntax.prototype.update = function (typeArgumentList, openParenToken, _arguments, closeParenToken) { - if (this.typeArgumentList === typeArgumentList && this.openParenToken === openParenToken && this.arguments === _arguments && this.closeParenToken === closeParenToken) { - return this; - } - - return new ArgumentListSyntax(typeArgumentList, openParenToken, _arguments, closeParenToken, this.parsedInStrictMode()); - }; - - ArgumentListSyntax.create = function (openParenToken, closeParenToken) { - return new ArgumentListSyntax(null, openParenToken, TypeScript.Syntax.emptySeparatedList, closeParenToken, false); - }; - - ArgumentListSyntax.create1 = function () { - return new ArgumentListSyntax(null, TypeScript.Syntax.token(73 /* OpenParenToken */), TypeScript.Syntax.emptySeparatedList, TypeScript.Syntax.token(74 /* CloseParenToken */), false); - }; - - ArgumentListSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ArgumentListSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ArgumentListSyntax.prototype.withTypeArgumentList = function (typeArgumentList) { - return this.update(typeArgumentList, this.openParenToken, this.arguments, this.closeParenToken); - }; - - ArgumentListSyntax.prototype.withOpenParenToken = function (openParenToken) { - return this.update(this.typeArgumentList, openParenToken, this.arguments, this.closeParenToken); - }; - - ArgumentListSyntax.prototype.withArguments = function (_arguments) { - return this.update(this.typeArgumentList, this.openParenToken, _arguments, this.closeParenToken); - }; - - ArgumentListSyntax.prototype.withArgument = function (_argument) { - return this.withArguments(TypeScript.Syntax.separatedList([_argument])); - }; - - ArgumentListSyntax.prototype.withCloseParenToken = function (closeParenToken) { - return this.update(this.typeArgumentList, this.openParenToken, this.arguments, closeParenToken); - }; - - ArgumentListSyntax.prototype.isTypeScriptSpecific = function () { - if (this.typeArgumentList !== null && this.typeArgumentList.isTypeScriptSpecific()) { - return true; - } - if (this.arguments.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return ArgumentListSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ArgumentListSyntax = ArgumentListSyntax; - - var BinaryExpressionSyntax = (function (_super) { - __extends(BinaryExpressionSyntax, _super); - function BinaryExpressionSyntax(kind, left, operatorToken, right, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.left = left; - this.operatorToken = operatorToken; - this.right = right; - - this._kind = kind; - } - BinaryExpressionSyntax.prototype.accept = function (visitor) { - return visitor.visitBinaryExpression(this); - }; - - BinaryExpressionSyntax.prototype.childCount = function () { - return 3; - }; - - BinaryExpressionSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.left; - case 1: - return this.operatorToken; - case 2: - return this.right; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - BinaryExpressionSyntax.prototype.isExpression = function () { - return true; - }; - - BinaryExpressionSyntax.prototype.kind = function () { - return this._kind; - }; - - BinaryExpressionSyntax.prototype.update = function (kind, left, operatorToken, right) { - if (this._kind === kind && this.left === left && this.operatorToken === operatorToken && this.right === right) { - return this; - } - - return new BinaryExpressionSyntax(kind, left, operatorToken, right, this.parsedInStrictMode()); - }; - - BinaryExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - BinaryExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - BinaryExpressionSyntax.prototype.withKind = function (kind) { - return this.update(kind, this.left, this.operatorToken, this.right); - }; - - BinaryExpressionSyntax.prototype.withLeft = function (left) { - return this.update(this._kind, left, this.operatorToken, this.right); - }; - - BinaryExpressionSyntax.prototype.withOperatorToken = function (operatorToken) { - return this.update(this._kind, this.left, operatorToken, this.right); - }; - - BinaryExpressionSyntax.prototype.withRight = function (right) { - return this.update(this._kind, this.left, this.operatorToken, right); - }; - - BinaryExpressionSyntax.prototype.isTypeScriptSpecific = function () { - if (this.left.isTypeScriptSpecific()) { - return true; - } - if (this.right.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return BinaryExpressionSyntax; - })(TypeScript.SyntaxNode); - TypeScript.BinaryExpressionSyntax = BinaryExpressionSyntax; - - var ConditionalExpressionSyntax = (function (_super) { - __extends(ConditionalExpressionSyntax, _super); - function ConditionalExpressionSyntax(condition, questionToken, whenTrue, colonToken, whenFalse, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.condition = condition; - this.questionToken = questionToken; - this.whenTrue = whenTrue; - this.colonToken = colonToken; - this.whenFalse = whenFalse; - } - ConditionalExpressionSyntax.prototype.accept = function (visitor) { - return visitor.visitConditionalExpression(this); - }; - - ConditionalExpressionSyntax.prototype.kind = function () { - return 185 /* ConditionalExpression */; - }; - - ConditionalExpressionSyntax.prototype.childCount = function () { - return 5; - }; - - ConditionalExpressionSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.condition; - case 1: - return this.questionToken; - case 2: - return this.whenTrue; - case 3: - return this.colonToken; - case 4: - return this.whenFalse; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ConditionalExpressionSyntax.prototype.isExpression = function () { - return true; - }; - - ConditionalExpressionSyntax.prototype.update = function (condition, questionToken, whenTrue, colonToken, whenFalse) { - if (this.condition === condition && this.questionToken === questionToken && this.whenTrue === whenTrue && this.colonToken === colonToken && this.whenFalse === whenFalse) { - return this; - } - - return new ConditionalExpressionSyntax(condition, questionToken, whenTrue, colonToken, whenFalse, this.parsedInStrictMode()); - }; - - ConditionalExpressionSyntax.create1 = function (condition, whenTrue, whenFalse) { - return new ConditionalExpressionSyntax(condition, TypeScript.Syntax.token(106 /* QuestionToken */), whenTrue, TypeScript.Syntax.token(107 /* ColonToken */), whenFalse, false); - }; - - ConditionalExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ConditionalExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ConditionalExpressionSyntax.prototype.withCondition = function (condition) { - return this.update(condition, this.questionToken, this.whenTrue, this.colonToken, this.whenFalse); - }; - - ConditionalExpressionSyntax.prototype.withQuestionToken = function (questionToken) { - return this.update(this.condition, questionToken, this.whenTrue, this.colonToken, this.whenFalse); - }; - - ConditionalExpressionSyntax.prototype.withWhenTrue = function (whenTrue) { - return this.update(this.condition, this.questionToken, whenTrue, this.colonToken, this.whenFalse); - }; - - ConditionalExpressionSyntax.prototype.withColonToken = function (colonToken) { - return this.update(this.condition, this.questionToken, this.whenTrue, colonToken, this.whenFalse); - }; - - ConditionalExpressionSyntax.prototype.withWhenFalse = function (whenFalse) { - return this.update(this.condition, this.questionToken, this.whenTrue, this.colonToken, whenFalse); - }; - - ConditionalExpressionSyntax.prototype.isTypeScriptSpecific = function () { - if (this.condition.isTypeScriptSpecific()) { - return true; - } - if (this.whenTrue.isTypeScriptSpecific()) { - return true; - } - if (this.whenFalse.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return ConditionalExpressionSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ConditionalExpressionSyntax = ConditionalExpressionSyntax; - - var ConstructSignatureSyntax = (function (_super) { - __extends(ConstructSignatureSyntax, _super); - function ConstructSignatureSyntax(newKeyword, callSignature, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.newKeyword = newKeyword; - this.callSignature = callSignature; - } - ConstructSignatureSyntax.prototype.accept = function (visitor) { - return visitor.visitConstructSignature(this); - }; - - ConstructSignatureSyntax.prototype.kind = function () { - return 142 /* ConstructSignature */; - }; - - ConstructSignatureSyntax.prototype.childCount = function () { - return 2; - }; - - ConstructSignatureSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.newKeyword; - case 1: - return this.callSignature; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ConstructSignatureSyntax.prototype.isTypeMember = function () { - return true; - }; - - ConstructSignatureSyntax.prototype.update = function (newKeyword, callSignature) { - if (this.newKeyword === newKeyword && this.callSignature === callSignature) { - return this; - } - - return new ConstructSignatureSyntax(newKeyword, callSignature, this.parsedInStrictMode()); - }; - - ConstructSignatureSyntax.create1 = function () { - return new ConstructSignatureSyntax(TypeScript.Syntax.token(31 /* NewKeyword */), CallSignatureSyntax.create1(), false); - }; - - ConstructSignatureSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ConstructSignatureSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ConstructSignatureSyntax.prototype.withNewKeyword = function (newKeyword) { - return this.update(newKeyword, this.callSignature); - }; - - ConstructSignatureSyntax.prototype.withCallSignature = function (callSignature) { - return this.update(this.newKeyword, callSignature); - }; - - ConstructSignatureSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return ConstructSignatureSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ConstructSignatureSyntax = ConstructSignatureSyntax; - - var MethodSignatureSyntax = (function (_super) { - __extends(MethodSignatureSyntax, _super); - function MethodSignatureSyntax(propertyName, questionToken, callSignature, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.propertyName = propertyName; - this.questionToken = questionToken; - this.callSignature = callSignature; - } - MethodSignatureSyntax.prototype.accept = function (visitor) { - return visitor.visitMethodSignature(this); - }; - - MethodSignatureSyntax.prototype.kind = function () { - return 144 /* MethodSignature */; - }; - - MethodSignatureSyntax.prototype.childCount = function () { - return 3; - }; - - MethodSignatureSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.propertyName; - case 1: - return this.questionToken; - case 2: - return this.callSignature; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - MethodSignatureSyntax.prototype.isTypeMember = function () { - return true; - }; - - MethodSignatureSyntax.prototype.update = function (propertyName, questionToken, callSignature) { - if (this.propertyName === propertyName && this.questionToken === questionToken && this.callSignature === callSignature) { - return this; - } - - return new MethodSignatureSyntax(propertyName, questionToken, callSignature, this.parsedInStrictMode()); - }; - - MethodSignatureSyntax.create = function (propertyName, callSignature) { - return new MethodSignatureSyntax(propertyName, null, callSignature, false); - }; - - MethodSignatureSyntax.create1 = function (propertyName) { - return new MethodSignatureSyntax(propertyName, null, CallSignatureSyntax.create1(), false); - }; - - MethodSignatureSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - MethodSignatureSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - MethodSignatureSyntax.prototype.withPropertyName = function (propertyName) { - return this.update(propertyName, this.questionToken, this.callSignature); - }; - - MethodSignatureSyntax.prototype.withQuestionToken = function (questionToken) { - return this.update(this.propertyName, questionToken, this.callSignature); - }; - - MethodSignatureSyntax.prototype.withCallSignature = function (callSignature) { - return this.update(this.propertyName, this.questionToken, callSignature); - }; - - MethodSignatureSyntax.prototype.isTypeScriptSpecific = function () { - if (this.callSignature.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return MethodSignatureSyntax; - })(TypeScript.SyntaxNode); - TypeScript.MethodSignatureSyntax = MethodSignatureSyntax; - - var IndexSignatureSyntax = (function (_super) { - __extends(IndexSignatureSyntax, _super); - function IndexSignatureSyntax(openBracketToken, parameter, closeBracketToken, typeAnnotation, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.openBracketToken = openBracketToken; - this.parameter = parameter; - this.closeBracketToken = closeBracketToken; - this.typeAnnotation = typeAnnotation; - } - IndexSignatureSyntax.prototype.accept = function (visitor) { - return visitor.visitIndexSignature(this); - }; - - IndexSignatureSyntax.prototype.kind = function () { - return 143 /* IndexSignature */; - }; - - IndexSignatureSyntax.prototype.childCount = function () { - return 4; - }; - - IndexSignatureSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.openBracketToken; - case 1: - return this.parameter; - case 2: - return this.closeBracketToken; - case 3: - return this.typeAnnotation; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - IndexSignatureSyntax.prototype.isTypeMember = function () { - return true; - }; - - IndexSignatureSyntax.prototype.isClassElement = function () { - return true; - }; - - IndexSignatureSyntax.prototype.update = function (openBracketToken, parameter, closeBracketToken, typeAnnotation) { - if (this.openBracketToken === openBracketToken && this.parameter === parameter && this.closeBracketToken === closeBracketToken && this.typeAnnotation === typeAnnotation) { - return this; - } - - return new IndexSignatureSyntax(openBracketToken, parameter, closeBracketToken, typeAnnotation, this.parsedInStrictMode()); - }; - - IndexSignatureSyntax.create = function (openBracketToken, parameter, closeBracketToken) { - return new IndexSignatureSyntax(openBracketToken, parameter, closeBracketToken, null, false); - }; - - IndexSignatureSyntax.create1 = function (parameter) { - return new IndexSignatureSyntax(TypeScript.Syntax.token(75 /* OpenBracketToken */), parameter, TypeScript.Syntax.token(76 /* CloseBracketToken */), null, false); - }; - - IndexSignatureSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - IndexSignatureSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - IndexSignatureSyntax.prototype.withOpenBracketToken = function (openBracketToken) { - return this.update(openBracketToken, this.parameter, this.closeBracketToken, this.typeAnnotation); - }; - - IndexSignatureSyntax.prototype.withParameter = function (parameter) { - return this.update(this.openBracketToken, parameter, this.closeBracketToken, this.typeAnnotation); - }; - - IndexSignatureSyntax.prototype.withCloseBracketToken = function (closeBracketToken) { - return this.update(this.openBracketToken, this.parameter, closeBracketToken, this.typeAnnotation); - }; - - IndexSignatureSyntax.prototype.withTypeAnnotation = function (typeAnnotation) { - return this.update(this.openBracketToken, this.parameter, this.closeBracketToken, typeAnnotation); - }; - - IndexSignatureSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return IndexSignatureSyntax; - })(TypeScript.SyntaxNode); - TypeScript.IndexSignatureSyntax = IndexSignatureSyntax; - - var PropertySignatureSyntax = (function (_super) { - __extends(PropertySignatureSyntax, _super); - function PropertySignatureSyntax(propertyName, questionToken, typeAnnotation, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.propertyName = propertyName; - this.questionToken = questionToken; - this.typeAnnotation = typeAnnotation; - } - PropertySignatureSyntax.prototype.accept = function (visitor) { - return visitor.visitPropertySignature(this); - }; - - PropertySignatureSyntax.prototype.kind = function () { - return 140 /* PropertySignature */; - }; - - PropertySignatureSyntax.prototype.childCount = function () { - return 3; - }; - - PropertySignatureSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.propertyName; - case 1: - return this.questionToken; - case 2: - return this.typeAnnotation; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - PropertySignatureSyntax.prototype.isTypeMember = function () { - return true; - }; - - PropertySignatureSyntax.prototype.update = function (propertyName, questionToken, typeAnnotation) { - if (this.propertyName === propertyName && this.questionToken === questionToken && this.typeAnnotation === typeAnnotation) { - return this; - } - - return new PropertySignatureSyntax(propertyName, questionToken, typeAnnotation, this.parsedInStrictMode()); - }; - - PropertySignatureSyntax.create = function (propertyName) { - return new PropertySignatureSyntax(propertyName, null, null, false); - }; - - PropertySignatureSyntax.create1 = function (propertyName) { - return new PropertySignatureSyntax(propertyName, null, null, false); - }; - - PropertySignatureSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - PropertySignatureSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - PropertySignatureSyntax.prototype.withPropertyName = function (propertyName) { - return this.update(propertyName, this.questionToken, this.typeAnnotation); - }; - - PropertySignatureSyntax.prototype.withQuestionToken = function (questionToken) { - return this.update(this.propertyName, questionToken, this.typeAnnotation); - }; - - PropertySignatureSyntax.prototype.withTypeAnnotation = function (typeAnnotation) { - return this.update(this.propertyName, this.questionToken, typeAnnotation); - }; - - PropertySignatureSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return PropertySignatureSyntax; - })(TypeScript.SyntaxNode); - TypeScript.PropertySignatureSyntax = PropertySignatureSyntax; - - var CallSignatureSyntax = (function (_super) { - __extends(CallSignatureSyntax, _super); - function CallSignatureSyntax(typeParameterList, parameterList, typeAnnotation, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.typeParameterList = typeParameterList; - this.parameterList = parameterList; - this.typeAnnotation = typeAnnotation; - } - CallSignatureSyntax.prototype.accept = function (visitor) { - return visitor.visitCallSignature(this); - }; - - CallSignatureSyntax.prototype.kind = function () { - return 141 /* CallSignature */; - }; - - CallSignatureSyntax.prototype.childCount = function () { - return 3; - }; - - CallSignatureSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.typeParameterList; - case 1: - return this.parameterList; - case 2: - return this.typeAnnotation; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - CallSignatureSyntax.prototype.isTypeMember = function () { - return true; - }; - - CallSignatureSyntax.prototype.update = function (typeParameterList, parameterList, typeAnnotation) { - if (this.typeParameterList === typeParameterList && this.parameterList === parameterList && this.typeAnnotation === typeAnnotation) { - return this; - } - - return new CallSignatureSyntax(typeParameterList, parameterList, typeAnnotation, this.parsedInStrictMode()); - }; - - CallSignatureSyntax.create = function (parameterList) { - return new CallSignatureSyntax(null, parameterList, null, false); - }; - - CallSignatureSyntax.create1 = function () { - return new CallSignatureSyntax(null, ParameterListSyntax.create1(), null, false); - }; - - CallSignatureSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - CallSignatureSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - CallSignatureSyntax.prototype.withTypeParameterList = function (typeParameterList) { - return this.update(typeParameterList, this.parameterList, this.typeAnnotation); - }; - - CallSignatureSyntax.prototype.withParameterList = function (parameterList) { - return this.update(this.typeParameterList, parameterList, this.typeAnnotation); - }; - - CallSignatureSyntax.prototype.withTypeAnnotation = function (typeAnnotation) { - return this.update(this.typeParameterList, this.parameterList, typeAnnotation); - }; - - CallSignatureSyntax.prototype.isTypeScriptSpecific = function () { - if (this.typeParameterList !== null) { - return true; - } - if (this.parameterList.isTypeScriptSpecific()) { - return true; - } - if (this.typeAnnotation !== null) { - return true; - } - return false; - }; - return CallSignatureSyntax; - })(TypeScript.SyntaxNode); - TypeScript.CallSignatureSyntax = CallSignatureSyntax; - - var ParameterListSyntax = (function (_super) { - __extends(ParameterListSyntax, _super); - function ParameterListSyntax(openParenToken, parameters, closeParenToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.openParenToken = openParenToken; - this.parameters = parameters; - this.closeParenToken = closeParenToken; - } - ParameterListSyntax.prototype.accept = function (visitor) { - return visitor.visitParameterList(this); - }; - - ParameterListSyntax.prototype.kind = function () { - return 226 /* ParameterList */; - }; - - ParameterListSyntax.prototype.childCount = function () { - return 3; - }; - - ParameterListSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.openParenToken; - case 1: - return this.parameters; - case 2: - return this.closeParenToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ParameterListSyntax.prototype.update = function (openParenToken, parameters, closeParenToken) { - if (this.openParenToken === openParenToken && this.parameters === parameters && this.closeParenToken === closeParenToken) { - return this; - } - - return new ParameterListSyntax(openParenToken, parameters, closeParenToken, this.parsedInStrictMode()); - }; - - ParameterListSyntax.create = function (openParenToken, closeParenToken) { - return new ParameterListSyntax(openParenToken, TypeScript.Syntax.emptySeparatedList, closeParenToken, false); - }; - - ParameterListSyntax.create1 = function () { - return new ParameterListSyntax(TypeScript.Syntax.token(73 /* OpenParenToken */), TypeScript.Syntax.emptySeparatedList, TypeScript.Syntax.token(74 /* CloseParenToken */), false); - }; - - ParameterListSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ParameterListSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ParameterListSyntax.prototype.withOpenParenToken = function (openParenToken) { - return this.update(openParenToken, this.parameters, this.closeParenToken); - }; - - ParameterListSyntax.prototype.withParameters = function (parameters) { - return this.update(this.openParenToken, parameters, this.closeParenToken); - }; - - ParameterListSyntax.prototype.withParameter = function (parameter) { - return this.withParameters(TypeScript.Syntax.separatedList([parameter])); - }; - - ParameterListSyntax.prototype.withCloseParenToken = function (closeParenToken) { - return this.update(this.openParenToken, this.parameters, closeParenToken); - }; - - ParameterListSyntax.prototype.isTypeScriptSpecific = function () { - if (this.parameters.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return ParameterListSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ParameterListSyntax = ParameterListSyntax; - - var TypeParameterListSyntax = (function (_super) { - __extends(TypeParameterListSyntax, _super); - function TypeParameterListSyntax(lessThanToken, typeParameters, greaterThanToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.lessThanToken = lessThanToken; - this.typeParameters = typeParameters; - this.greaterThanToken = greaterThanToken; - } - TypeParameterListSyntax.prototype.accept = function (visitor) { - return visitor.visitTypeParameterList(this); - }; - - TypeParameterListSyntax.prototype.kind = function () { - return 228 /* TypeParameterList */; - }; - - TypeParameterListSyntax.prototype.childCount = function () { - return 3; - }; - - TypeParameterListSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.lessThanToken; - case 1: - return this.typeParameters; - case 2: - return this.greaterThanToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - TypeParameterListSyntax.prototype.update = function (lessThanToken, typeParameters, greaterThanToken) { - if (this.lessThanToken === lessThanToken && this.typeParameters === typeParameters && this.greaterThanToken === greaterThanToken) { - return this; - } - - return new TypeParameterListSyntax(lessThanToken, typeParameters, greaterThanToken, this.parsedInStrictMode()); - }; - - TypeParameterListSyntax.create = function (lessThanToken, greaterThanToken) { - return new TypeParameterListSyntax(lessThanToken, TypeScript.Syntax.emptySeparatedList, greaterThanToken, false); - }; - - TypeParameterListSyntax.create1 = function () { - return new TypeParameterListSyntax(TypeScript.Syntax.token(81 /* LessThanToken */), TypeScript.Syntax.emptySeparatedList, TypeScript.Syntax.token(82 /* GreaterThanToken */), false); - }; - - TypeParameterListSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - TypeParameterListSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - TypeParameterListSyntax.prototype.withLessThanToken = function (lessThanToken) { - return this.update(lessThanToken, this.typeParameters, this.greaterThanToken); - }; - - TypeParameterListSyntax.prototype.withTypeParameters = function (typeParameters) { - return this.update(this.lessThanToken, typeParameters, this.greaterThanToken); - }; - - TypeParameterListSyntax.prototype.withTypeParameter = function (typeParameter) { - return this.withTypeParameters(TypeScript.Syntax.separatedList([typeParameter])); - }; - - TypeParameterListSyntax.prototype.withGreaterThanToken = function (greaterThanToken) { - return this.update(this.lessThanToken, this.typeParameters, greaterThanToken); - }; - - TypeParameterListSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return TypeParameterListSyntax; - })(TypeScript.SyntaxNode); - TypeScript.TypeParameterListSyntax = TypeParameterListSyntax; - - var TypeParameterSyntax = (function (_super) { - __extends(TypeParameterSyntax, _super); - function TypeParameterSyntax(identifier, constraint, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.identifier = identifier; - this.constraint = constraint; - } - TypeParameterSyntax.prototype.accept = function (visitor) { - return visitor.visitTypeParameter(this); - }; - - TypeParameterSyntax.prototype.kind = function () { - return 236 /* TypeParameter */; - }; - - TypeParameterSyntax.prototype.childCount = function () { - return 2; - }; - - TypeParameterSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.identifier; - case 1: - return this.constraint; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - TypeParameterSyntax.prototype.update = function (identifier, constraint) { - if (this.identifier === identifier && this.constraint === constraint) { - return this; - } - - return new TypeParameterSyntax(identifier, constraint, this.parsedInStrictMode()); - }; - - TypeParameterSyntax.create = function (identifier) { - return new TypeParameterSyntax(identifier, null, false); - }; - - TypeParameterSyntax.create1 = function (identifier) { - return new TypeParameterSyntax(identifier, null, false); - }; - - TypeParameterSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - TypeParameterSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - TypeParameterSyntax.prototype.withIdentifier = function (identifier) { - return this.update(identifier, this.constraint); - }; - - TypeParameterSyntax.prototype.withConstraint = function (constraint) { - return this.update(this.identifier, constraint); - }; - - TypeParameterSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return TypeParameterSyntax; - })(TypeScript.SyntaxNode); - TypeScript.TypeParameterSyntax = TypeParameterSyntax; - - var ConstraintSyntax = (function (_super) { - __extends(ConstraintSyntax, _super); - function ConstraintSyntax(extendsKeyword, type, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.extendsKeyword = extendsKeyword; - this.type = type; - } - ConstraintSyntax.prototype.accept = function (visitor) { - return visitor.visitConstraint(this); - }; - - ConstraintSyntax.prototype.kind = function () { - return 237 /* Constraint */; - }; - - ConstraintSyntax.prototype.childCount = function () { - return 2; - }; - - ConstraintSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.extendsKeyword; - case 1: - return this.type; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ConstraintSyntax.prototype.update = function (extendsKeyword, type) { - if (this.extendsKeyword === extendsKeyword && this.type === type) { - return this; - } - - return new ConstraintSyntax(extendsKeyword, type, this.parsedInStrictMode()); - }; - - ConstraintSyntax.create1 = function (type) { - return new ConstraintSyntax(TypeScript.Syntax.token(48 /* ExtendsKeyword */), type, false); - }; - - ConstraintSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ConstraintSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ConstraintSyntax.prototype.withExtendsKeyword = function (extendsKeyword) { - return this.update(extendsKeyword, this.type); - }; - - ConstraintSyntax.prototype.withType = function (type) { - return this.update(this.extendsKeyword, type); - }; - - ConstraintSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return ConstraintSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ConstraintSyntax = ConstraintSyntax; - - var ElseClauseSyntax = (function (_super) { - __extends(ElseClauseSyntax, _super); - function ElseClauseSyntax(elseKeyword, statement, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.elseKeyword = elseKeyword; - this.statement = statement; - } - ElseClauseSyntax.prototype.accept = function (visitor) { - return visitor.visitElseClause(this); - }; - - ElseClauseSyntax.prototype.kind = function () { - return 233 /* ElseClause */; - }; - - ElseClauseSyntax.prototype.childCount = function () { - return 2; - }; - - ElseClauseSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.elseKeyword; - case 1: - return this.statement; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ElseClauseSyntax.prototype.update = function (elseKeyword, statement) { - if (this.elseKeyword === elseKeyword && this.statement === statement) { - return this; - } - - return new ElseClauseSyntax(elseKeyword, statement, this.parsedInStrictMode()); - }; - - ElseClauseSyntax.create1 = function (statement) { - return new ElseClauseSyntax(TypeScript.Syntax.token(23 /* ElseKeyword */), statement, false); - }; - - ElseClauseSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ElseClauseSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ElseClauseSyntax.prototype.withElseKeyword = function (elseKeyword) { - return this.update(elseKeyword, this.statement); - }; - - ElseClauseSyntax.prototype.withStatement = function (statement) { - return this.update(this.elseKeyword, statement); - }; - - ElseClauseSyntax.prototype.isTypeScriptSpecific = function () { - if (this.statement.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return ElseClauseSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ElseClauseSyntax = ElseClauseSyntax; - - var IfStatementSyntax = (function (_super) { - __extends(IfStatementSyntax, _super); - function IfStatementSyntax(ifKeyword, openParenToken, condition, closeParenToken, statement, elseClause, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.ifKeyword = ifKeyword; - this.openParenToken = openParenToken; - this.condition = condition; - this.closeParenToken = closeParenToken; - this.statement = statement; - this.elseClause = elseClause; - } - IfStatementSyntax.prototype.accept = function (visitor) { - return visitor.visitIfStatement(this); - }; - - IfStatementSyntax.prototype.kind = function () { - return 146 /* IfStatement */; - }; - - IfStatementSyntax.prototype.childCount = function () { - return 6; - }; - - IfStatementSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.ifKeyword; - case 1: - return this.openParenToken; - case 2: - return this.condition; - case 3: - return this.closeParenToken; - case 4: - return this.statement; - case 5: - return this.elseClause; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - IfStatementSyntax.prototype.isStatement = function () { - return true; - }; - - IfStatementSyntax.prototype.isModuleElement = function () { - return true; - }; - - IfStatementSyntax.prototype.update = function (ifKeyword, openParenToken, condition, closeParenToken, statement, elseClause) { - if (this.ifKeyword === ifKeyword && this.openParenToken === openParenToken && this.condition === condition && this.closeParenToken === closeParenToken && this.statement === statement && this.elseClause === elseClause) { - return this; - } - - return new IfStatementSyntax(ifKeyword, openParenToken, condition, closeParenToken, statement, elseClause, this.parsedInStrictMode()); - }; - - IfStatementSyntax.create = function (ifKeyword, openParenToken, condition, closeParenToken, statement) { - return new IfStatementSyntax(ifKeyword, openParenToken, condition, closeParenToken, statement, null, false); - }; - - IfStatementSyntax.create1 = function (condition, statement) { - return new IfStatementSyntax(TypeScript.Syntax.token(28 /* IfKeyword */), TypeScript.Syntax.token(73 /* OpenParenToken */), condition, TypeScript.Syntax.token(74 /* CloseParenToken */), statement, null, false); - }; - - IfStatementSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - IfStatementSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - IfStatementSyntax.prototype.withIfKeyword = function (ifKeyword) { - return this.update(ifKeyword, this.openParenToken, this.condition, this.closeParenToken, this.statement, this.elseClause); - }; - - IfStatementSyntax.prototype.withOpenParenToken = function (openParenToken) { - return this.update(this.ifKeyword, openParenToken, this.condition, this.closeParenToken, this.statement, this.elseClause); - }; - - IfStatementSyntax.prototype.withCondition = function (condition) { - return this.update(this.ifKeyword, this.openParenToken, condition, this.closeParenToken, this.statement, this.elseClause); - }; - - IfStatementSyntax.prototype.withCloseParenToken = function (closeParenToken) { - return this.update(this.ifKeyword, this.openParenToken, this.condition, closeParenToken, this.statement, this.elseClause); - }; - - IfStatementSyntax.prototype.withStatement = function (statement) { - return this.update(this.ifKeyword, this.openParenToken, this.condition, this.closeParenToken, statement, this.elseClause); - }; - - IfStatementSyntax.prototype.withElseClause = function (elseClause) { - return this.update(this.ifKeyword, this.openParenToken, this.condition, this.closeParenToken, this.statement, elseClause); - }; - - IfStatementSyntax.prototype.isTypeScriptSpecific = function () { - if (this.condition.isTypeScriptSpecific()) { - return true; - } - if (this.statement.isTypeScriptSpecific()) { - return true; - } - if (this.elseClause !== null && this.elseClause.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return IfStatementSyntax; - })(TypeScript.SyntaxNode); - TypeScript.IfStatementSyntax = IfStatementSyntax; - - var ExpressionStatementSyntax = (function (_super) { - __extends(ExpressionStatementSyntax, _super); - function ExpressionStatementSyntax(expression, semicolonToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.expression = expression; - this.semicolonToken = semicolonToken; - } - ExpressionStatementSyntax.prototype.accept = function (visitor) { - return visitor.visitExpressionStatement(this); - }; - - ExpressionStatementSyntax.prototype.kind = function () { - return 148 /* ExpressionStatement */; - }; - - ExpressionStatementSyntax.prototype.childCount = function () { - return 2; - }; - - ExpressionStatementSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.expression; - case 1: - return this.semicolonToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ExpressionStatementSyntax.prototype.isStatement = function () { - return true; - }; - - ExpressionStatementSyntax.prototype.isModuleElement = function () { - return true; - }; - - ExpressionStatementSyntax.prototype.update = function (expression, semicolonToken) { - if (this.expression === expression && this.semicolonToken === semicolonToken) { - return this; - } - - return new ExpressionStatementSyntax(expression, semicolonToken, this.parsedInStrictMode()); - }; - - ExpressionStatementSyntax.create1 = function (expression) { - return new ExpressionStatementSyntax(expression, TypeScript.Syntax.token(79 /* SemicolonToken */), false); - }; - - ExpressionStatementSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ExpressionStatementSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ExpressionStatementSyntax.prototype.withExpression = function (expression) { - return this.update(expression, this.semicolonToken); - }; - - ExpressionStatementSyntax.prototype.withSemicolonToken = function (semicolonToken) { - return this.update(this.expression, semicolonToken); - }; - - ExpressionStatementSyntax.prototype.isTypeScriptSpecific = function () { - if (this.expression.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return ExpressionStatementSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ExpressionStatementSyntax = ExpressionStatementSyntax; - - var ConstructorDeclarationSyntax = (function (_super) { - __extends(ConstructorDeclarationSyntax, _super); - function ConstructorDeclarationSyntax(constructorKeyword, parameterList, block, semicolonToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.constructorKeyword = constructorKeyword; - this.parameterList = parameterList; - this.block = block; - this.semicolonToken = semicolonToken; - } - ConstructorDeclarationSyntax.prototype.accept = function (visitor) { - return visitor.visitConstructorDeclaration(this); - }; - - ConstructorDeclarationSyntax.prototype.kind = function () { - return 137 /* ConstructorDeclaration */; - }; - - ConstructorDeclarationSyntax.prototype.childCount = function () { - return 4; - }; - - ConstructorDeclarationSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.constructorKeyword; - case 1: - return this.parameterList; - case 2: - return this.block; - case 3: - return this.semicolonToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ConstructorDeclarationSyntax.prototype.isClassElement = function () { - return true; - }; - - ConstructorDeclarationSyntax.prototype.update = function (constructorKeyword, parameterList, block, semicolonToken) { - if (this.constructorKeyword === constructorKeyword && this.parameterList === parameterList && this.block === block && this.semicolonToken === semicolonToken) { - return this; - } - - return new ConstructorDeclarationSyntax(constructorKeyword, parameterList, block, semicolonToken, this.parsedInStrictMode()); - }; - - ConstructorDeclarationSyntax.create = function (constructorKeyword, parameterList) { - return new ConstructorDeclarationSyntax(constructorKeyword, parameterList, null, null, false); - }; - - ConstructorDeclarationSyntax.create1 = function () { - return new ConstructorDeclarationSyntax(TypeScript.Syntax.token(63 /* ConstructorKeyword */), ParameterListSyntax.create1(), null, null, false); - }; - - ConstructorDeclarationSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ConstructorDeclarationSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ConstructorDeclarationSyntax.prototype.withConstructorKeyword = function (constructorKeyword) { - return this.update(constructorKeyword, this.parameterList, this.block, this.semicolonToken); - }; - - ConstructorDeclarationSyntax.prototype.withParameterList = function (parameterList) { - return this.update(this.constructorKeyword, parameterList, this.block, this.semicolonToken); - }; - - ConstructorDeclarationSyntax.prototype.withBlock = function (block) { - return this.update(this.constructorKeyword, this.parameterList, block, this.semicolonToken); - }; - - ConstructorDeclarationSyntax.prototype.withSemicolonToken = function (semicolonToken) { - return this.update(this.constructorKeyword, this.parameterList, this.block, semicolonToken); - }; - - ConstructorDeclarationSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return ConstructorDeclarationSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ConstructorDeclarationSyntax = ConstructorDeclarationSyntax; - - var MemberFunctionDeclarationSyntax = (function (_super) { - __extends(MemberFunctionDeclarationSyntax, _super); - function MemberFunctionDeclarationSyntax(modifiers, propertyName, callSignature, block, semicolonToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.modifiers = modifiers; - this.propertyName = propertyName; - this.callSignature = callSignature; - this.block = block; - this.semicolonToken = semicolonToken; - } - MemberFunctionDeclarationSyntax.prototype.accept = function (visitor) { - return visitor.visitMemberFunctionDeclaration(this); - }; - - MemberFunctionDeclarationSyntax.prototype.kind = function () { - return 135 /* MemberFunctionDeclaration */; - }; - - MemberFunctionDeclarationSyntax.prototype.childCount = function () { - return 5; - }; - - MemberFunctionDeclarationSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.modifiers; - case 1: - return this.propertyName; - case 2: - return this.callSignature; - case 3: - return this.block; - case 4: - return this.semicolonToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - MemberFunctionDeclarationSyntax.prototype.isMemberDeclaration = function () { - return true; - }; - - MemberFunctionDeclarationSyntax.prototype.isClassElement = function () { - return true; - }; - - MemberFunctionDeclarationSyntax.prototype.update = function (modifiers, propertyName, callSignature, block, semicolonToken) { - if (this.modifiers === modifiers && this.propertyName === propertyName && this.callSignature === callSignature && this.block === block && this.semicolonToken === semicolonToken) { - return this; - } - - return new MemberFunctionDeclarationSyntax(modifiers, propertyName, callSignature, block, semicolonToken, this.parsedInStrictMode()); - }; - - MemberFunctionDeclarationSyntax.create = function (propertyName, callSignature) { - return new MemberFunctionDeclarationSyntax(TypeScript.Syntax.emptyList, propertyName, callSignature, null, null, false); - }; - - MemberFunctionDeclarationSyntax.create1 = function (propertyName) { - return new MemberFunctionDeclarationSyntax(TypeScript.Syntax.emptyList, propertyName, CallSignatureSyntax.create1(), null, null, false); - }; - - MemberFunctionDeclarationSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - MemberFunctionDeclarationSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - MemberFunctionDeclarationSyntax.prototype.withModifiers = function (modifiers) { - return this.update(modifiers, this.propertyName, this.callSignature, this.block, this.semicolonToken); - }; - - MemberFunctionDeclarationSyntax.prototype.withModifier = function (modifier) { - return this.withModifiers(TypeScript.Syntax.list([modifier])); - }; - - MemberFunctionDeclarationSyntax.prototype.withPropertyName = function (propertyName) { - return this.update(this.modifiers, propertyName, this.callSignature, this.block, this.semicolonToken); - }; - - MemberFunctionDeclarationSyntax.prototype.withCallSignature = function (callSignature) { - return this.update(this.modifiers, this.propertyName, callSignature, this.block, this.semicolonToken); - }; - - MemberFunctionDeclarationSyntax.prototype.withBlock = function (block) { - return this.update(this.modifiers, this.propertyName, this.callSignature, block, this.semicolonToken); - }; - - MemberFunctionDeclarationSyntax.prototype.withSemicolonToken = function (semicolonToken) { - return this.update(this.modifiers, this.propertyName, this.callSignature, this.block, semicolonToken); - }; - - MemberFunctionDeclarationSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return MemberFunctionDeclarationSyntax; - })(TypeScript.SyntaxNode); - TypeScript.MemberFunctionDeclarationSyntax = MemberFunctionDeclarationSyntax; - - var MemberAccessorDeclarationSyntax = (function (_super) { - __extends(MemberAccessorDeclarationSyntax, _super); - function MemberAccessorDeclarationSyntax(modifiers, propertyName, parameterList, block, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.modifiers = modifiers; - this.propertyName = propertyName; - this.parameterList = parameterList; - this.block = block; - } - MemberAccessorDeclarationSyntax.prototype.isMemberDeclaration = function () { - return true; - }; - - MemberAccessorDeclarationSyntax.prototype.isClassElement = function () { - return true; - }; - - MemberAccessorDeclarationSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - MemberAccessorDeclarationSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - MemberAccessorDeclarationSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return MemberAccessorDeclarationSyntax; - })(TypeScript.SyntaxNode); - TypeScript.MemberAccessorDeclarationSyntax = MemberAccessorDeclarationSyntax; - - var GetMemberAccessorDeclarationSyntax = (function (_super) { - __extends(GetMemberAccessorDeclarationSyntax, _super); - function GetMemberAccessorDeclarationSyntax(modifiers, getKeyword, propertyName, parameterList, typeAnnotation, block, parsedInStrictMode) { - _super.call(this, modifiers, propertyName, parameterList, block, parsedInStrictMode); - this.getKeyword = getKeyword; - this.typeAnnotation = typeAnnotation; - } - GetMemberAccessorDeclarationSyntax.prototype.accept = function (visitor) { - return visitor.visitGetMemberAccessorDeclaration(this); - }; - - GetMemberAccessorDeclarationSyntax.prototype.kind = function () { - return 138 /* GetMemberAccessorDeclaration */; - }; - - GetMemberAccessorDeclarationSyntax.prototype.childCount = function () { - return 6; - }; - - GetMemberAccessorDeclarationSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.modifiers; - case 1: - return this.getKeyword; - case 2: - return this.propertyName; - case 3: - return this.parameterList; - case 4: - return this.typeAnnotation; - case 5: - return this.block; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - GetMemberAccessorDeclarationSyntax.prototype.update = function (modifiers, getKeyword, propertyName, parameterList, typeAnnotation, block) { - if (this.modifiers === modifiers && this.getKeyword === getKeyword && this.propertyName === propertyName && this.parameterList === parameterList && this.typeAnnotation === typeAnnotation && this.block === block) { - return this; - } - - return new GetMemberAccessorDeclarationSyntax(modifiers, getKeyword, propertyName, parameterList, typeAnnotation, block, this.parsedInStrictMode()); - }; - - GetMemberAccessorDeclarationSyntax.create = function (getKeyword, propertyName, parameterList, block) { - return new GetMemberAccessorDeclarationSyntax(TypeScript.Syntax.emptyList, getKeyword, propertyName, parameterList, null, block, false); - }; - - GetMemberAccessorDeclarationSyntax.create1 = function (propertyName) { - return new GetMemberAccessorDeclarationSyntax(TypeScript.Syntax.emptyList, TypeScript.Syntax.token(65 /* GetKeyword */), propertyName, ParameterListSyntax.create1(), null, BlockSyntax.create1(), false); - }; - - GetMemberAccessorDeclarationSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - GetMemberAccessorDeclarationSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - GetMemberAccessorDeclarationSyntax.prototype.withModifiers = function (modifiers) { - return this.update(modifiers, this.getKeyword, this.propertyName, this.parameterList, this.typeAnnotation, this.block); - }; - - GetMemberAccessorDeclarationSyntax.prototype.withModifier = function (modifier) { - return this.withModifiers(TypeScript.Syntax.list([modifier])); - }; - - GetMemberAccessorDeclarationSyntax.prototype.withGetKeyword = function (getKeyword) { - return this.update(this.modifiers, getKeyword, this.propertyName, this.parameterList, this.typeAnnotation, this.block); - }; - - GetMemberAccessorDeclarationSyntax.prototype.withPropertyName = function (propertyName) { - return this.update(this.modifiers, this.getKeyword, propertyName, this.parameterList, this.typeAnnotation, this.block); - }; - - GetMemberAccessorDeclarationSyntax.prototype.withParameterList = function (parameterList) { - return this.update(this.modifiers, this.getKeyword, this.propertyName, parameterList, this.typeAnnotation, this.block); - }; - - GetMemberAccessorDeclarationSyntax.prototype.withTypeAnnotation = function (typeAnnotation) { - return this.update(this.modifiers, this.getKeyword, this.propertyName, this.parameterList, typeAnnotation, this.block); - }; - - GetMemberAccessorDeclarationSyntax.prototype.withBlock = function (block) { - return this.update(this.modifiers, this.getKeyword, this.propertyName, this.parameterList, this.typeAnnotation, block); - }; - - GetMemberAccessorDeclarationSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return GetMemberAccessorDeclarationSyntax; - })(MemberAccessorDeclarationSyntax); - TypeScript.GetMemberAccessorDeclarationSyntax = GetMemberAccessorDeclarationSyntax; - - var SetMemberAccessorDeclarationSyntax = (function (_super) { - __extends(SetMemberAccessorDeclarationSyntax, _super); - function SetMemberAccessorDeclarationSyntax(modifiers, setKeyword, propertyName, parameterList, block, parsedInStrictMode) { - _super.call(this, modifiers, propertyName, parameterList, block, parsedInStrictMode); - this.setKeyword = setKeyword; - } - SetMemberAccessorDeclarationSyntax.prototype.accept = function (visitor) { - return visitor.visitSetMemberAccessorDeclaration(this); - }; - - SetMemberAccessorDeclarationSyntax.prototype.kind = function () { - return 139 /* SetMemberAccessorDeclaration */; - }; - - SetMemberAccessorDeclarationSyntax.prototype.childCount = function () { - return 5; - }; - - SetMemberAccessorDeclarationSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.modifiers; - case 1: - return this.setKeyword; - case 2: - return this.propertyName; - case 3: - return this.parameterList; - case 4: - return this.block; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - SetMemberAccessorDeclarationSyntax.prototype.update = function (modifiers, setKeyword, propertyName, parameterList, block) { - if (this.modifiers === modifiers && this.setKeyword === setKeyword && this.propertyName === propertyName && this.parameterList === parameterList && this.block === block) { - return this; - } - - return new SetMemberAccessorDeclarationSyntax(modifiers, setKeyword, propertyName, parameterList, block, this.parsedInStrictMode()); - }; - - SetMemberAccessorDeclarationSyntax.create = function (setKeyword, propertyName, parameterList, block) { - return new SetMemberAccessorDeclarationSyntax(TypeScript.Syntax.emptyList, setKeyword, propertyName, parameterList, block, false); - }; - - SetMemberAccessorDeclarationSyntax.create1 = function (propertyName) { - return new SetMemberAccessorDeclarationSyntax(TypeScript.Syntax.emptyList, TypeScript.Syntax.token(69 /* SetKeyword */), propertyName, ParameterListSyntax.create1(), BlockSyntax.create1(), false); - }; - - SetMemberAccessorDeclarationSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - SetMemberAccessorDeclarationSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - SetMemberAccessorDeclarationSyntax.prototype.withModifiers = function (modifiers) { - return this.update(modifiers, this.setKeyword, this.propertyName, this.parameterList, this.block); - }; - - SetMemberAccessorDeclarationSyntax.prototype.withModifier = function (modifier) { - return this.withModifiers(TypeScript.Syntax.list([modifier])); - }; - - SetMemberAccessorDeclarationSyntax.prototype.withSetKeyword = function (setKeyword) { - return this.update(this.modifiers, setKeyword, this.propertyName, this.parameterList, this.block); - }; - - SetMemberAccessorDeclarationSyntax.prototype.withPropertyName = function (propertyName) { - return this.update(this.modifiers, this.setKeyword, propertyName, this.parameterList, this.block); - }; - - SetMemberAccessorDeclarationSyntax.prototype.withParameterList = function (parameterList) { - return this.update(this.modifiers, this.setKeyword, this.propertyName, parameterList, this.block); - }; - - SetMemberAccessorDeclarationSyntax.prototype.withBlock = function (block) { - return this.update(this.modifiers, this.setKeyword, this.propertyName, this.parameterList, block); - }; - - SetMemberAccessorDeclarationSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return SetMemberAccessorDeclarationSyntax; - })(MemberAccessorDeclarationSyntax); - TypeScript.SetMemberAccessorDeclarationSyntax = SetMemberAccessorDeclarationSyntax; - - var MemberVariableDeclarationSyntax = (function (_super) { - __extends(MemberVariableDeclarationSyntax, _super); - function MemberVariableDeclarationSyntax(modifiers, variableDeclarator, semicolonToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.modifiers = modifiers; - this.variableDeclarator = variableDeclarator; - this.semicolonToken = semicolonToken; - } - MemberVariableDeclarationSyntax.prototype.accept = function (visitor) { - return visitor.visitMemberVariableDeclaration(this); - }; - - MemberVariableDeclarationSyntax.prototype.kind = function () { - return 136 /* MemberVariableDeclaration */; - }; - - MemberVariableDeclarationSyntax.prototype.childCount = function () { - return 3; - }; - - MemberVariableDeclarationSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.modifiers; - case 1: - return this.variableDeclarator; - case 2: - return this.semicolonToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - MemberVariableDeclarationSyntax.prototype.isMemberDeclaration = function () { - return true; - }; - - MemberVariableDeclarationSyntax.prototype.isClassElement = function () { - return true; - }; - - MemberVariableDeclarationSyntax.prototype.update = function (modifiers, variableDeclarator, semicolonToken) { - if (this.modifiers === modifiers && this.variableDeclarator === variableDeclarator && this.semicolonToken === semicolonToken) { - return this; - } - - return new MemberVariableDeclarationSyntax(modifiers, variableDeclarator, semicolonToken, this.parsedInStrictMode()); - }; - - MemberVariableDeclarationSyntax.create = function (variableDeclarator, semicolonToken) { - return new MemberVariableDeclarationSyntax(TypeScript.Syntax.emptyList, variableDeclarator, semicolonToken, false); - }; - - MemberVariableDeclarationSyntax.create1 = function (variableDeclarator) { - return new MemberVariableDeclarationSyntax(TypeScript.Syntax.emptyList, variableDeclarator, TypeScript.Syntax.token(79 /* SemicolonToken */), false); - }; - - MemberVariableDeclarationSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - MemberVariableDeclarationSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - MemberVariableDeclarationSyntax.prototype.withModifiers = function (modifiers) { - return this.update(modifiers, this.variableDeclarator, this.semicolonToken); - }; - - MemberVariableDeclarationSyntax.prototype.withModifier = function (modifier) { - return this.withModifiers(TypeScript.Syntax.list([modifier])); - }; - - MemberVariableDeclarationSyntax.prototype.withVariableDeclarator = function (variableDeclarator) { - return this.update(this.modifiers, variableDeclarator, this.semicolonToken); - }; - - MemberVariableDeclarationSyntax.prototype.withSemicolonToken = function (semicolonToken) { - return this.update(this.modifiers, this.variableDeclarator, semicolonToken); - }; - - MemberVariableDeclarationSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return MemberVariableDeclarationSyntax; - })(TypeScript.SyntaxNode); - TypeScript.MemberVariableDeclarationSyntax = MemberVariableDeclarationSyntax; - - var ThrowStatementSyntax = (function (_super) { - __extends(ThrowStatementSyntax, _super); - function ThrowStatementSyntax(throwKeyword, expression, semicolonToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.throwKeyword = throwKeyword; - this.expression = expression; - this.semicolonToken = semicolonToken; - } - ThrowStatementSyntax.prototype.accept = function (visitor) { - return visitor.visitThrowStatement(this); - }; - - ThrowStatementSyntax.prototype.kind = function () { - return 156 /* ThrowStatement */; - }; - - ThrowStatementSyntax.prototype.childCount = function () { - return 3; - }; - - ThrowStatementSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.throwKeyword; - case 1: - return this.expression; - case 2: - return this.semicolonToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ThrowStatementSyntax.prototype.isStatement = function () { - return true; - }; - - ThrowStatementSyntax.prototype.isModuleElement = function () { - return true; - }; - - ThrowStatementSyntax.prototype.update = function (throwKeyword, expression, semicolonToken) { - if (this.throwKeyword === throwKeyword && this.expression === expression && this.semicolonToken === semicolonToken) { - return this; - } - - return new ThrowStatementSyntax(throwKeyword, expression, semicolonToken, this.parsedInStrictMode()); - }; - - ThrowStatementSyntax.create1 = function (expression) { - return new ThrowStatementSyntax(TypeScript.Syntax.token(36 /* ThrowKeyword */), expression, TypeScript.Syntax.token(79 /* SemicolonToken */), false); - }; - - ThrowStatementSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ThrowStatementSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ThrowStatementSyntax.prototype.withThrowKeyword = function (throwKeyword) { - return this.update(throwKeyword, this.expression, this.semicolonToken); - }; - - ThrowStatementSyntax.prototype.withExpression = function (expression) { - return this.update(this.throwKeyword, expression, this.semicolonToken); - }; - - ThrowStatementSyntax.prototype.withSemicolonToken = function (semicolonToken) { - return this.update(this.throwKeyword, this.expression, semicolonToken); - }; - - ThrowStatementSyntax.prototype.isTypeScriptSpecific = function () { - if (this.expression.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return ThrowStatementSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ThrowStatementSyntax = ThrowStatementSyntax; - - var ReturnStatementSyntax = (function (_super) { - __extends(ReturnStatementSyntax, _super); - function ReturnStatementSyntax(returnKeyword, expression, semicolonToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.returnKeyword = returnKeyword; - this.expression = expression; - this.semicolonToken = semicolonToken; - } - ReturnStatementSyntax.prototype.accept = function (visitor) { - return visitor.visitReturnStatement(this); - }; - - ReturnStatementSyntax.prototype.kind = function () { - return 149 /* ReturnStatement */; - }; - - ReturnStatementSyntax.prototype.childCount = function () { - return 3; - }; - - ReturnStatementSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.returnKeyword; - case 1: - return this.expression; - case 2: - return this.semicolonToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ReturnStatementSyntax.prototype.isStatement = function () { - return true; - }; - - ReturnStatementSyntax.prototype.isModuleElement = function () { - return true; - }; - - ReturnStatementSyntax.prototype.update = function (returnKeyword, expression, semicolonToken) { - if (this.returnKeyword === returnKeyword && this.expression === expression && this.semicolonToken === semicolonToken) { - return this; - } - - return new ReturnStatementSyntax(returnKeyword, expression, semicolonToken, this.parsedInStrictMode()); - }; - - ReturnStatementSyntax.create = function (returnKeyword, semicolonToken) { - return new ReturnStatementSyntax(returnKeyword, null, semicolonToken, false); - }; - - ReturnStatementSyntax.create1 = function () { - return new ReturnStatementSyntax(TypeScript.Syntax.token(33 /* ReturnKeyword */), null, TypeScript.Syntax.token(79 /* SemicolonToken */), false); - }; - - ReturnStatementSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ReturnStatementSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ReturnStatementSyntax.prototype.withReturnKeyword = function (returnKeyword) { - return this.update(returnKeyword, this.expression, this.semicolonToken); - }; - - ReturnStatementSyntax.prototype.withExpression = function (expression) { - return this.update(this.returnKeyword, expression, this.semicolonToken); - }; - - ReturnStatementSyntax.prototype.withSemicolonToken = function (semicolonToken) { - return this.update(this.returnKeyword, this.expression, semicolonToken); - }; - - ReturnStatementSyntax.prototype.isTypeScriptSpecific = function () { - if (this.expression !== null && this.expression.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return ReturnStatementSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ReturnStatementSyntax = ReturnStatementSyntax; - - var ObjectCreationExpressionSyntax = (function (_super) { - __extends(ObjectCreationExpressionSyntax, _super); - function ObjectCreationExpressionSyntax(newKeyword, expression, argumentList, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.newKeyword = newKeyword; - this.expression = expression; - this.argumentList = argumentList; - } - ObjectCreationExpressionSyntax.prototype.accept = function (visitor) { - return visitor.visitObjectCreationExpression(this); - }; - - ObjectCreationExpressionSyntax.prototype.kind = function () { - return 215 /* ObjectCreationExpression */; - }; - - ObjectCreationExpressionSyntax.prototype.childCount = function () { - return 3; - }; - - ObjectCreationExpressionSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.newKeyword; - case 1: - return this.expression; - case 2: - return this.argumentList; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ObjectCreationExpressionSyntax.prototype.isUnaryExpression = function () { - return true; - }; - - ObjectCreationExpressionSyntax.prototype.isExpression = function () { - return true; - }; - - ObjectCreationExpressionSyntax.prototype.update = function (newKeyword, expression, argumentList) { - if (this.newKeyword === newKeyword && this.expression === expression && this.argumentList === argumentList) { - return this; - } - - return new ObjectCreationExpressionSyntax(newKeyword, expression, argumentList, this.parsedInStrictMode()); - }; - - ObjectCreationExpressionSyntax.create = function (newKeyword, expression) { - return new ObjectCreationExpressionSyntax(newKeyword, expression, null, false); - }; - - ObjectCreationExpressionSyntax.create1 = function (expression) { - return new ObjectCreationExpressionSyntax(TypeScript.Syntax.token(31 /* NewKeyword */), expression, null, false); - }; - - ObjectCreationExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ObjectCreationExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ObjectCreationExpressionSyntax.prototype.withNewKeyword = function (newKeyword) { - return this.update(newKeyword, this.expression, this.argumentList); - }; - - ObjectCreationExpressionSyntax.prototype.withExpression = function (expression) { - return this.update(this.newKeyword, expression, this.argumentList); - }; - - ObjectCreationExpressionSyntax.prototype.withArgumentList = function (argumentList) { - return this.update(this.newKeyword, this.expression, argumentList); - }; - - ObjectCreationExpressionSyntax.prototype.isTypeScriptSpecific = function () { - if (this.expression.isTypeScriptSpecific()) { - return true; - } - if (this.argumentList !== null && this.argumentList.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return ObjectCreationExpressionSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ObjectCreationExpressionSyntax = ObjectCreationExpressionSyntax; - - var SwitchStatementSyntax = (function (_super) { - __extends(SwitchStatementSyntax, _super); - function SwitchStatementSyntax(switchKeyword, openParenToken, expression, closeParenToken, openBraceToken, switchClauses, closeBraceToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.switchKeyword = switchKeyword; - this.openParenToken = openParenToken; - this.expression = expression; - this.closeParenToken = closeParenToken; - this.openBraceToken = openBraceToken; - this.switchClauses = switchClauses; - this.closeBraceToken = closeBraceToken; - } - SwitchStatementSyntax.prototype.accept = function (visitor) { - return visitor.visitSwitchStatement(this); - }; - - SwitchStatementSyntax.prototype.kind = function () { - return 150 /* SwitchStatement */; - }; - - SwitchStatementSyntax.prototype.childCount = function () { - return 7; - }; - - SwitchStatementSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.switchKeyword; - case 1: - return this.openParenToken; - case 2: - return this.expression; - case 3: - return this.closeParenToken; - case 4: - return this.openBraceToken; - case 5: - return this.switchClauses; - case 6: - return this.closeBraceToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - SwitchStatementSyntax.prototype.isStatement = function () { - return true; - }; - - SwitchStatementSyntax.prototype.isModuleElement = function () { - return true; - }; - - SwitchStatementSyntax.prototype.update = function (switchKeyword, openParenToken, expression, closeParenToken, openBraceToken, switchClauses, closeBraceToken) { - if (this.switchKeyword === switchKeyword && this.openParenToken === openParenToken && this.expression === expression && this.closeParenToken === closeParenToken && this.openBraceToken === openBraceToken && this.switchClauses === switchClauses && this.closeBraceToken === closeBraceToken) { - return this; - } - - return new SwitchStatementSyntax(switchKeyword, openParenToken, expression, closeParenToken, openBraceToken, switchClauses, closeBraceToken, this.parsedInStrictMode()); - }; - - SwitchStatementSyntax.create = function (switchKeyword, openParenToken, expression, closeParenToken, openBraceToken, closeBraceToken) { - return new SwitchStatementSyntax(switchKeyword, openParenToken, expression, closeParenToken, openBraceToken, TypeScript.Syntax.emptyList, closeBraceToken, false); - }; - - SwitchStatementSyntax.create1 = function (expression) { - return new SwitchStatementSyntax(TypeScript.Syntax.token(34 /* SwitchKeyword */), TypeScript.Syntax.token(73 /* OpenParenToken */), expression, TypeScript.Syntax.token(74 /* CloseParenToken */), TypeScript.Syntax.token(71 /* OpenBraceToken */), TypeScript.Syntax.emptyList, TypeScript.Syntax.token(72 /* CloseBraceToken */), false); - }; - - SwitchStatementSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - SwitchStatementSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - SwitchStatementSyntax.prototype.withSwitchKeyword = function (switchKeyword) { - return this.update(switchKeyword, this.openParenToken, this.expression, this.closeParenToken, this.openBraceToken, this.switchClauses, this.closeBraceToken); - }; - - SwitchStatementSyntax.prototype.withOpenParenToken = function (openParenToken) { - return this.update(this.switchKeyword, openParenToken, this.expression, this.closeParenToken, this.openBraceToken, this.switchClauses, this.closeBraceToken); - }; - - SwitchStatementSyntax.prototype.withExpression = function (expression) { - return this.update(this.switchKeyword, this.openParenToken, expression, this.closeParenToken, this.openBraceToken, this.switchClauses, this.closeBraceToken); - }; - - SwitchStatementSyntax.prototype.withCloseParenToken = function (closeParenToken) { - return this.update(this.switchKeyword, this.openParenToken, this.expression, closeParenToken, this.openBraceToken, this.switchClauses, this.closeBraceToken); - }; - - SwitchStatementSyntax.prototype.withOpenBraceToken = function (openBraceToken) { - return this.update(this.switchKeyword, this.openParenToken, this.expression, this.closeParenToken, openBraceToken, this.switchClauses, this.closeBraceToken); - }; - - SwitchStatementSyntax.prototype.withSwitchClauses = function (switchClauses) { - return this.update(this.switchKeyword, this.openParenToken, this.expression, this.closeParenToken, this.openBraceToken, switchClauses, this.closeBraceToken); - }; - - SwitchStatementSyntax.prototype.withSwitchClause = function (switchClause) { - return this.withSwitchClauses(TypeScript.Syntax.list([switchClause])); - }; - - SwitchStatementSyntax.prototype.withCloseBraceToken = function (closeBraceToken) { - return this.update(this.switchKeyword, this.openParenToken, this.expression, this.closeParenToken, this.openBraceToken, this.switchClauses, closeBraceToken); - }; - - SwitchStatementSyntax.prototype.isTypeScriptSpecific = function () { - if (this.expression.isTypeScriptSpecific()) { - return true; - } - if (this.switchClauses.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return SwitchStatementSyntax; - })(TypeScript.SyntaxNode); - TypeScript.SwitchStatementSyntax = SwitchStatementSyntax; - - var SwitchClauseSyntax = (function (_super) { - __extends(SwitchClauseSyntax, _super); - function SwitchClauseSyntax(colonToken, statements, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.colonToken = colonToken; - this.statements = statements; - } - SwitchClauseSyntax.prototype.isSwitchClause = function () { - return true; - }; - - SwitchClauseSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - SwitchClauseSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - SwitchClauseSyntax.prototype.isTypeScriptSpecific = function () { - return false; - }; - return SwitchClauseSyntax; - })(TypeScript.SyntaxNode); - TypeScript.SwitchClauseSyntax = SwitchClauseSyntax; - - var CaseSwitchClauseSyntax = (function (_super) { - __extends(CaseSwitchClauseSyntax, _super); - function CaseSwitchClauseSyntax(caseKeyword, expression, colonToken, statements, parsedInStrictMode) { - _super.call(this, colonToken, statements, parsedInStrictMode); - this.caseKeyword = caseKeyword; - this.expression = expression; - } - CaseSwitchClauseSyntax.prototype.accept = function (visitor) { - return visitor.visitCaseSwitchClause(this); - }; - - CaseSwitchClauseSyntax.prototype.kind = function () { - return 231 /* CaseSwitchClause */; - }; - - CaseSwitchClauseSyntax.prototype.childCount = function () { - return 4; - }; - - CaseSwitchClauseSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.caseKeyword; - case 1: - return this.expression; - case 2: - return this.colonToken; - case 3: - return this.statements; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - CaseSwitchClauseSyntax.prototype.update = function (caseKeyword, expression, colonToken, statements) { - if (this.caseKeyword === caseKeyword && this.expression === expression && this.colonToken === colonToken && this.statements === statements) { - return this; - } - - return new CaseSwitchClauseSyntax(caseKeyword, expression, colonToken, statements, this.parsedInStrictMode()); - }; - - CaseSwitchClauseSyntax.create = function (caseKeyword, expression, colonToken) { - return new CaseSwitchClauseSyntax(caseKeyword, expression, colonToken, TypeScript.Syntax.emptyList, false); - }; - - CaseSwitchClauseSyntax.create1 = function (expression) { - return new CaseSwitchClauseSyntax(TypeScript.Syntax.token(16 /* CaseKeyword */), expression, TypeScript.Syntax.token(107 /* ColonToken */), TypeScript.Syntax.emptyList, false); - }; - - CaseSwitchClauseSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - CaseSwitchClauseSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - CaseSwitchClauseSyntax.prototype.withCaseKeyword = function (caseKeyword) { - return this.update(caseKeyword, this.expression, this.colonToken, this.statements); - }; - - CaseSwitchClauseSyntax.prototype.withExpression = function (expression) { - return this.update(this.caseKeyword, expression, this.colonToken, this.statements); - }; - - CaseSwitchClauseSyntax.prototype.withColonToken = function (colonToken) { - return this.update(this.caseKeyword, this.expression, colonToken, this.statements); - }; - - CaseSwitchClauseSyntax.prototype.withStatements = function (statements) { - return this.update(this.caseKeyword, this.expression, this.colonToken, statements); - }; - - CaseSwitchClauseSyntax.prototype.withStatement = function (statement) { - return this.withStatements(TypeScript.Syntax.list([statement])); - }; - - CaseSwitchClauseSyntax.prototype.isTypeScriptSpecific = function () { - if (this.expression.isTypeScriptSpecific()) { - return true; - } - if (this.statements.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return CaseSwitchClauseSyntax; - })(SwitchClauseSyntax); - TypeScript.CaseSwitchClauseSyntax = CaseSwitchClauseSyntax; - - var DefaultSwitchClauseSyntax = (function (_super) { - __extends(DefaultSwitchClauseSyntax, _super); - function DefaultSwitchClauseSyntax(defaultKeyword, colonToken, statements, parsedInStrictMode) { - _super.call(this, colonToken, statements, parsedInStrictMode); - this.defaultKeyword = defaultKeyword; - } - DefaultSwitchClauseSyntax.prototype.accept = function (visitor) { - return visitor.visitDefaultSwitchClause(this); - }; - - DefaultSwitchClauseSyntax.prototype.kind = function () { - return 232 /* DefaultSwitchClause */; - }; - - DefaultSwitchClauseSyntax.prototype.childCount = function () { - return 3; - }; - - DefaultSwitchClauseSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.defaultKeyword; - case 1: - return this.colonToken; - case 2: - return this.statements; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - DefaultSwitchClauseSyntax.prototype.update = function (defaultKeyword, colonToken, statements) { - if (this.defaultKeyword === defaultKeyword && this.colonToken === colonToken && this.statements === statements) { - return this; - } - - return new DefaultSwitchClauseSyntax(defaultKeyword, colonToken, statements, this.parsedInStrictMode()); - }; - - DefaultSwitchClauseSyntax.create = function (defaultKeyword, colonToken) { - return new DefaultSwitchClauseSyntax(defaultKeyword, colonToken, TypeScript.Syntax.emptyList, false); - }; - - DefaultSwitchClauseSyntax.create1 = function () { - return new DefaultSwitchClauseSyntax(TypeScript.Syntax.token(20 /* DefaultKeyword */), TypeScript.Syntax.token(107 /* ColonToken */), TypeScript.Syntax.emptyList, false); - }; - - DefaultSwitchClauseSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - DefaultSwitchClauseSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - DefaultSwitchClauseSyntax.prototype.withDefaultKeyword = function (defaultKeyword) { - return this.update(defaultKeyword, this.colonToken, this.statements); - }; - - DefaultSwitchClauseSyntax.prototype.withColonToken = function (colonToken) { - return this.update(this.defaultKeyword, colonToken, this.statements); - }; - - DefaultSwitchClauseSyntax.prototype.withStatements = function (statements) { - return this.update(this.defaultKeyword, this.colonToken, statements); - }; - - DefaultSwitchClauseSyntax.prototype.withStatement = function (statement) { - return this.withStatements(TypeScript.Syntax.list([statement])); - }; - - DefaultSwitchClauseSyntax.prototype.isTypeScriptSpecific = function () { - if (this.statements.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return DefaultSwitchClauseSyntax; - })(SwitchClauseSyntax); - TypeScript.DefaultSwitchClauseSyntax = DefaultSwitchClauseSyntax; - - var BreakStatementSyntax = (function (_super) { - __extends(BreakStatementSyntax, _super); - function BreakStatementSyntax(breakKeyword, identifier, semicolonToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.breakKeyword = breakKeyword; - this.identifier = identifier; - this.semicolonToken = semicolonToken; - } - BreakStatementSyntax.prototype.accept = function (visitor) { - return visitor.visitBreakStatement(this); - }; - - BreakStatementSyntax.prototype.kind = function () { - return 151 /* BreakStatement */; - }; - - BreakStatementSyntax.prototype.childCount = function () { - return 3; - }; - - BreakStatementSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.breakKeyword; - case 1: - return this.identifier; - case 2: - return this.semicolonToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - BreakStatementSyntax.prototype.isStatement = function () { - return true; - }; - - BreakStatementSyntax.prototype.isModuleElement = function () { - return true; - }; - - BreakStatementSyntax.prototype.update = function (breakKeyword, identifier, semicolonToken) { - if (this.breakKeyword === breakKeyword && this.identifier === identifier && this.semicolonToken === semicolonToken) { - return this; - } - - return new BreakStatementSyntax(breakKeyword, identifier, semicolonToken, this.parsedInStrictMode()); - }; - - BreakStatementSyntax.create = function (breakKeyword, semicolonToken) { - return new BreakStatementSyntax(breakKeyword, null, semicolonToken, false); - }; - - BreakStatementSyntax.create1 = function () { - return new BreakStatementSyntax(TypeScript.Syntax.token(15 /* BreakKeyword */), null, TypeScript.Syntax.token(79 /* SemicolonToken */), false); - }; - - BreakStatementSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - BreakStatementSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - BreakStatementSyntax.prototype.withBreakKeyword = function (breakKeyword) { - return this.update(breakKeyword, this.identifier, this.semicolonToken); - }; - - BreakStatementSyntax.prototype.withIdentifier = function (identifier) { - return this.update(this.breakKeyword, identifier, this.semicolonToken); - }; - - BreakStatementSyntax.prototype.withSemicolonToken = function (semicolonToken) { - return this.update(this.breakKeyword, this.identifier, semicolonToken); - }; - - BreakStatementSyntax.prototype.isTypeScriptSpecific = function () { - return false; - }; - return BreakStatementSyntax; - })(TypeScript.SyntaxNode); - TypeScript.BreakStatementSyntax = BreakStatementSyntax; - - var ContinueStatementSyntax = (function (_super) { - __extends(ContinueStatementSyntax, _super); - function ContinueStatementSyntax(continueKeyword, identifier, semicolonToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.continueKeyword = continueKeyword; - this.identifier = identifier; - this.semicolonToken = semicolonToken; - } - ContinueStatementSyntax.prototype.accept = function (visitor) { - return visitor.visitContinueStatement(this); - }; - - ContinueStatementSyntax.prototype.kind = function () { - return 152 /* ContinueStatement */; - }; - - ContinueStatementSyntax.prototype.childCount = function () { - return 3; - }; - - ContinueStatementSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.continueKeyword; - case 1: - return this.identifier; - case 2: - return this.semicolonToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ContinueStatementSyntax.prototype.isStatement = function () { - return true; - }; - - ContinueStatementSyntax.prototype.isModuleElement = function () { - return true; - }; - - ContinueStatementSyntax.prototype.update = function (continueKeyword, identifier, semicolonToken) { - if (this.continueKeyword === continueKeyword && this.identifier === identifier && this.semicolonToken === semicolonToken) { - return this; - } - - return new ContinueStatementSyntax(continueKeyword, identifier, semicolonToken, this.parsedInStrictMode()); - }; - - ContinueStatementSyntax.create = function (continueKeyword, semicolonToken) { - return new ContinueStatementSyntax(continueKeyword, null, semicolonToken, false); - }; - - ContinueStatementSyntax.create1 = function () { - return new ContinueStatementSyntax(TypeScript.Syntax.token(18 /* ContinueKeyword */), null, TypeScript.Syntax.token(79 /* SemicolonToken */), false); - }; - - ContinueStatementSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ContinueStatementSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ContinueStatementSyntax.prototype.withContinueKeyword = function (continueKeyword) { - return this.update(continueKeyword, this.identifier, this.semicolonToken); - }; - - ContinueStatementSyntax.prototype.withIdentifier = function (identifier) { - return this.update(this.continueKeyword, identifier, this.semicolonToken); - }; - - ContinueStatementSyntax.prototype.withSemicolonToken = function (semicolonToken) { - return this.update(this.continueKeyword, this.identifier, semicolonToken); - }; - - ContinueStatementSyntax.prototype.isTypeScriptSpecific = function () { - return false; - }; - return ContinueStatementSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ContinueStatementSyntax = ContinueStatementSyntax; - - var IterationStatementSyntax = (function (_super) { - __extends(IterationStatementSyntax, _super); - function IterationStatementSyntax(openParenToken, closeParenToken, statement, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.openParenToken = openParenToken; - this.closeParenToken = closeParenToken; - this.statement = statement; - } - IterationStatementSyntax.prototype.isStatement = function () { - return true; - }; - - IterationStatementSyntax.prototype.isModuleElement = function () { - return true; - }; - - IterationStatementSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - IterationStatementSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - IterationStatementSyntax.prototype.isTypeScriptSpecific = function () { - return false; - }; - return IterationStatementSyntax; - })(TypeScript.SyntaxNode); - TypeScript.IterationStatementSyntax = IterationStatementSyntax; - - var BaseForStatementSyntax = (function (_super) { - __extends(BaseForStatementSyntax, _super); - function BaseForStatementSyntax(forKeyword, openParenToken, variableDeclaration, closeParenToken, statement, parsedInStrictMode) { - _super.call(this, openParenToken, closeParenToken, statement, parsedInStrictMode); - this.forKeyword = forKeyword; - this.variableDeclaration = variableDeclaration; - } - BaseForStatementSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - BaseForStatementSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - BaseForStatementSyntax.prototype.isTypeScriptSpecific = function () { - return false; - }; - return BaseForStatementSyntax; - })(IterationStatementSyntax); - TypeScript.BaseForStatementSyntax = BaseForStatementSyntax; - - var ForStatementSyntax = (function (_super) { - __extends(ForStatementSyntax, _super); - function ForStatementSyntax(forKeyword, openParenToken, variableDeclaration, initializer, firstSemicolonToken, condition, secondSemicolonToken, incrementor, closeParenToken, statement, parsedInStrictMode) { - _super.call(this, forKeyword, openParenToken, variableDeclaration, closeParenToken, statement, parsedInStrictMode); - this.initializer = initializer; - this.firstSemicolonToken = firstSemicolonToken; - this.condition = condition; - this.secondSemicolonToken = secondSemicolonToken; - this.incrementor = incrementor; - } - ForStatementSyntax.prototype.accept = function (visitor) { - return visitor.visitForStatement(this); - }; - - ForStatementSyntax.prototype.kind = function () { - return 153 /* ForStatement */; - }; - - ForStatementSyntax.prototype.childCount = function () { - return 10; - }; - - ForStatementSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.forKeyword; - case 1: - return this.openParenToken; - case 2: - return this.variableDeclaration; - case 3: - return this.initializer; - case 4: - return this.firstSemicolonToken; - case 5: - return this.condition; - case 6: - return this.secondSemicolonToken; - case 7: - return this.incrementor; - case 8: - return this.closeParenToken; - case 9: - return this.statement; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ForStatementSyntax.prototype.update = function (forKeyword, openParenToken, variableDeclaration, initializer, firstSemicolonToken, condition, secondSemicolonToken, incrementor, closeParenToken, statement) { - if (this.forKeyword === forKeyword && this.openParenToken === openParenToken && this.variableDeclaration === variableDeclaration && this.initializer === initializer && this.firstSemicolonToken === firstSemicolonToken && this.condition === condition && this.secondSemicolonToken === secondSemicolonToken && this.incrementor === incrementor && this.closeParenToken === closeParenToken && this.statement === statement) { - return this; - } - - return new ForStatementSyntax(forKeyword, openParenToken, variableDeclaration, initializer, firstSemicolonToken, condition, secondSemicolonToken, incrementor, closeParenToken, statement, this.parsedInStrictMode()); - }; - - ForStatementSyntax.create = function (forKeyword, openParenToken, firstSemicolonToken, secondSemicolonToken, closeParenToken, statement) { - return new ForStatementSyntax(forKeyword, openParenToken, null, null, firstSemicolonToken, null, secondSemicolonToken, null, closeParenToken, statement, false); - }; - - ForStatementSyntax.create1 = function (statement) { - return new ForStatementSyntax(TypeScript.Syntax.token(26 /* ForKeyword */), TypeScript.Syntax.token(73 /* OpenParenToken */), null, null, TypeScript.Syntax.token(79 /* SemicolonToken */), null, TypeScript.Syntax.token(79 /* SemicolonToken */), null, TypeScript.Syntax.token(74 /* CloseParenToken */), statement, false); - }; - - ForStatementSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ForStatementSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ForStatementSyntax.prototype.withForKeyword = function (forKeyword) { - return this.update(forKeyword, this.openParenToken, this.variableDeclaration, this.initializer, this.firstSemicolonToken, this.condition, this.secondSemicolonToken, this.incrementor, this.closeParenToken, this.statement); - }; - - ForStatementSyntax.prototype.withOpenParenToken = function (openParenToken) { - return this.update(this.forKeyword, openParenToken, this.variableDeclaration, this.initializer, this.firstSemicolonToken, this.condition, this.secondSemicolonToken, this.incrementor, this.closeParenToken, this.statement); - }; - - ForStatementSyntax.prototype.withVariableDeclaration = function (variableDeclaration) { - return this.update(this.forKeyword, this.openParenToken, variableDeclaration, this.initializer, this.firstSemicolonToken, this.condition, this.secondSemicolonToken, this.incrementor, this.closeParenToken, this.statement); - }; - - ForStatementSyntax.prototype.withInitializer = function (initializer) { - return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, initializer, this.firstSemicolonToken, this.condition, this.secondSemicolonToken, this.incrementor, this.closeParenToken, this.statement); - }; - - ForStatementSyntax.prototype.withFirstSemicolonToken = function (firstSemicolonToken) { - return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, this.initializer, firstSemicolonToken, this.condition, this.secondSemicolonToken, this.incrementor, this.closeParenToken, this.statement); - }; - - ForStatementSyntax.prototype.withCondition = function (condition) { - return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, this.initializer, this.firstSemicolonToken, condition, this.secondSemicolonToken, this.incrementor, this.closeParenToken, this.statement); - }; - - ForStatementSyntax.prototype.withSecondSemicolonToken = function (secondSemicolonToken) { - return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, this.initializer, this.firstSemicolonToken, this.condition, secondSemicolonToken, this.incrementor, this.closeParenToken, this.statement); - }; - - ForStatementSyntax.prototype.withIncrementor = function (incrementor) { - return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, this.initializer, this.firstSemicolonToken, this.condition, this.secondSemicolonToken, incrementor, this.closeParenToken, this.statement); - }; - - ForStatementSyntax.prototype.withCloseParenToken = function (closeParenToken) { - return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, this.initializer, this.firstSemicolonToken, this.condition, this.secondSemicolonToken, this.incrementor, closeParenToken, this.statement); - }; - - ForStatementSyntax.prototype.withStatement = function (statement) { - return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, this.initializer, this.firstSemicolonToken, this.condition, this.secondSemicolonToken, this.incrementor, this.closeParenToken, statement); - }; - - ForStatementSyntax.prototype.isTypeScriptSpecific = function () { - if (this.variableDeclaration !== null && this.variableDeclaration.isTypeScriptSpecific()) { - return true; - } - if (this.initializer !== null && this.initializer.isTypeScriptSpecific()) { - return true; - } - if (this.condition !== null && this.condition.isTypeScriptSpecific()) { - return true; - } - if (this.incrementor !== null && this.incrementor.isTypeScriptSpecific()) { - return true; - } - if (this.statement.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return ForStatementSyntax; - })(BaseForStatementSyntax); - TypeScript.ForStatementSyntax = ForStatementSyntax; - - var ForInStatementSyntax = (function (_super) { - __extends(ForInStatementSyntax, _super); - function ForInStatementSyntax(forKeyword, openParenToken, variableDeclaration, left, inKeyword, expression, closeParenToken, statement, parsedInStrictMode) { - _super.call(this, forKeyword, openParenToken, variableDeclaration, closeParenToken, statement, parsedInStrictMode); - this.left = left; - this.inKeyword = inKeyword; - this.expression = expression; - } - ForInStatementSyntax.prototype.accept = function (visitor) { - return visitor.visitForInStatement(this); - }; - - ForInStatementSyntax.prototype.kind = function () { - return 154 /* ForInStatement */; - }; - - ForInStatementSyntax.prototype.childCount = function () { - return 8; - }; - - ForInStatementSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.forKeyword; - case 1: - return this.openParenToken; - case 2: - return this.variableDeclaration; - case 3: - return this.left; - case 4: - return this.inKeyword; - case 5: - return this.expression; - case 6: - return this.closeParenToken; - case 7: - return this.statement; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ForInStatementSyntax.prototype.update = function (forKeyword, openParenToken, variableDeclaration, left, inKeyword, expression, closeParenToken, statement) { - if (this.forKeyword === forKeyword && this.openParenToken === openParenToken && this.variableDeclaration === variableDeclaration && this.left === left && this.inKeyword === inKeyword && this.expression === expression && this.closeParenToken === closeParenToken && this.statement === statement) { - return this; - } - - return new ForInStatementSyntax(forKeyword, openParenToken, variableDeclaration, left, inKeyword, expression, closeParenToken, statement, this.parsedInStrictMode()); - }; - - ForInStatementSyntax.create = function (forKeyword, openParenToken, inKeyword, expression, closeParenToken, statement) { - return new ForInStatementSyntax(forKeyword, openParenToken, null, null, inKeyword, expression, closeParenToken, statement, false); - }; - - ForInStatementSyntax.create1 = function (expression, statement) { - return new ForInStatementSyntax(TypeScript.Syntax.token(26 /* ForKeyword */), TypeScript.Syntax.token(73 /* OpenParenToken */), null, null, TypeScript.Syntax.token(29 /* InKeyword */), expression, TypeScript.Syntax.token(74 /* CloseParenToken */), statement, false); - }; - - ForInStatementSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ForInStatementSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ForInStatementSyntax.prototype.withForKeyword = function (forKeyword) { - return this.update(forKeyword, this.openParenToken, this.variableDeclaration, this.left, this.inKeyword, this.expression, this.closeParenToken, this.statement); - }; - - ForInStatementSyntax.prototype.withOpenParenToken = function (openParenToken) { - return this.update(this.forKeyword, openParenToken, this.variableDeclaration, this.left, this.inKeyword, this.expression, this.closeParenToken, this.statement); - }; - - ForInStatementSyntax.prototype.withVariableDeclaration = function (variableDeclaration) { - return this.update(this.forKeyword, this.openParenToken, variableDeclaration, this.left, this.inKeyword, this.expression, this.closeParenToken, this.statement); - }; - - ForInStatementSyntax.prototype.withLeft = function (left) { - return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, left, this.inKeyword, this.expression, this.closeParenToken, this.statement); - }; - - ForInStatementSyntax.prototype.withInKeyword = function (inKeyword) { - return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, this.left, inKeyword, this.expression, this.closeParenToken, this.statement); - }; - - ForInStatementSyntax.prototype.withExpression = function (expression) { - return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, this.left, this.inKeyword, expression, this.closeParenToken, this.statement); - }; - - ForInStatementSyntax.prototype.withCloseParenToken = function (closeParenToken) { - return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, this.left, this.inKeyword, this.expression, closeParenToken, this.statement); - }; - - ForInStatementSyntax.prototype.withStatement = function (statement) { - return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, this.left, this.inKeyword, this.expression, this.closeParenToken, statement); - }; - - ForInStatementSyntax.prototype.isTypeScriptSpecific = function () { - if (this.variableDeclaration !== null && this.variableDeclaration.isTypeScriptSpecific()) { - return true; - } - if (this.left !== null && this.left.isTypeScriptSpecific()) { - return true; - } - if (this.expression.isTypeScriptSpecific()) { - return true; - } - if (this.statement.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return ForInStatementSyntax; - })(BaseForStatementSyntax); - TypeScript.ForInStatementSyntax = ForInStatementSyntax; - - var WhileStatementSyntax = (function (_super) { - __extends(WhileStatementSyntax, _super); - function WhileStatementSyntax(whileKeyword, openParenToken, condition, closeParenToken, statement, parsedInStrictMode) { - _super.call(this, openParenToken, closeParenToken, statement, parsedInStrictMode); - this.whileKeyword = whileKeyword; - this.condition = condition; - } - WhileStatementSyntax.prototype.accept = function (visitor) { - return visitor.visitWhileStatement(this); - }; - - WhileStatementSyntax.prototype.kind = function () { - return 157 /* WhileStatement */; - }; - - WhileStatementSyntax.prototype.childCount = function () { - return 5; - }; - - WhileStatementSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.whileKeyword; - case 1: - return this.openParenToken; - case 2: - return this.condition; - case 3: - return this.closeParenToken; - case 4: - return this.statement; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - WhileStatementSyntax.prototype.update = function (whileKeyword, openParenToken, condition, closeParenToken, statement) { - if (this.whileKeyword === whileKeyword && this.openParenToken === openParenToken && this.condition === condition && this.closeParenToken === closeParenToken && this.statement === statement) { - return this; - } - - return new WhileStatementSyntax(whileKeyword, openParenToken, condition, closeParenToken, statement, this.parsedInStrictMode()); - }; - - WhileStatementSyntax.create1 = function (condition, statement) { - return new WhileStatementSyntax(TypeScript.Syntax.token(42 /* WhileKeyword */), TypeScript.Syntax.token(73 /* OpenParenToken */), condition, TypeScript.Syntax.token(74 /* CloseParenToken */), statement, false); - }; - - WhileStatementSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - WhileStatementSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - WhileStatementSyntax.prototype.withWhileKeyword = function (whileKeyword) { - return this.update(whileKeyword, this.openParenToken, this.condition, this.closeParenToken, this.statement); - }; - - WhileStatementSyntax.prototype.withOpenParenToken = function (openParenToken) { - return this.update(this.whileKeyword, openParenToken, this.condition, this.closeParenToken, this.statement); - }; - - WhileStatementSyntax.prototype.withCondition = function (condition) { - return this.update(this.whileKeyword, this.openParenToken, condition, this.closeParenToken, this.statement); - }; - - WhileStatementSyntax.prototype.withCloseParenToken = function (closeParenToken) { - return this.update(this.whileKeyword, this.openParenToken, this.condition, closeParenToken, this.statement); - }; - - WhileStatementSyntax.prototype.withStatement = function (statement) { - return this.update(this.whileKeyword, this.openParenToken, this.condition, this.closeParenToken, statement); - }; - - WhileStatementSyntax.prototype.isTypeScriptSpecific = function () { - if (this.condition.isTypeScriptSpecific()) { - return true; - } - if (this.statement.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return WhileStatementSyntax; - })(IterationStatementSyntax); - TypeScript.WhileStatementSyntax = WhileStatementSyntax; - - var WithStatementSyntax = (function (_super) { - __extends(WithStatementSyntax, _super); - function WithStatementSyntax(withKeyword, openParenToken, condition, closeParenToken, statement, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.withKeyword = withKeyword; - this.openParenToken = openParenToken; - this.condition = condition; - this.closeParenToken = closeParenToken; - this.statement = statement; - } - WithStatementSyntax.prototype.accept = function (visitor) { - return visitor.visitWithStatement(this); - }; - - WithStatementSyntax.prototype.kind = function () { - return 162 /* WithStatement */; - }; - - WithStatementSyntax.prototype.childCount = function () { - return 5; - }; - - WithStatementSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.withKeyword; - case 1: - return this.openParenToken; - case 2: - return this.condition; - case 3: - return this.closeParenToken; - case 4: - return this.statement; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - WithStatementSyntax.prototype.isStatement = function () { - return true; - }; - - WithStatementSyntax.prototype.isModuleElement = function () { - return true; - }; - - WithStatementSyntax.prototype.update = function (withKeyword, openParenToken, condition, closeParenToken, statement) { - if (this.withKeyword === withKeyword && this.openParenToken === openParenToken && this.condition === condition && this.closeParenToken === closeParenToken && this.statement === statement) { - return this; - } - - return new WithStatementSyntax(withKeyword, openParenToken, condition, closeParenToken, statement, this.parsedInStrictMode()); - }; - - WithStatementSyntax.create1 = function (condition, statement) { - return new WithStatementSyntax(TypeScript.Syntax.token(43 /* WithKeyword */), TypeScript.Syntax.token(73 /* OpenParenToken */), condition, TypeScript.Syntax.token(74 /* CloseParenToken */), statement, false); - }; - - WithStatementSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - WithStatementSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - WithStatementSyntax.prototype.withWithKeyword = function (withKeyword) { - return this.update(withKeyword, this.openParenToken, this.condition, this.closeParenToken, this.statement); - }; - - WithStatementSyntax.prototype.withOpenParenToken = function (openParenToken) { - return this.update(this.withKeyword, openParenToken, this.condition, this.closeParenToken, this.statement); - }; - - WithStatementSyntax.prototype.withCondition = function (condition) { - return this.update(this.withKeyword, this.openParenToken, condition, this.closeParenToken, this.statement); - }; - - WithStatementSyntax.prototype.withCloseParenToken = function (closeParenToken) { - return this.update(this.withKeyword, this.openParenToken, this.condition, closeParenToken, this.statement); - }; - - WithStatementSyntax.prototype.withStatement = function (statement) { - return this.update(this.withKeyword, this.openParenToken, this.condition, this.closeParenToken, statement); - }; - - WithStatementSyntax.prototype.isTypeScriptSpecific = function () { - if (this.condition.isTypeScriptSpecific()) { - return true; - } - if (this.statement.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return WithStatementSyntax; - })(TypeScript.SyntaxNode); - TypeScript.WithStatementSyntax = WithStatementSyntax; - - var EnumDeclarationSyntax = (function (_super) { - __extends(EnumDeclarationSyntax, _super); - function EnumDeclarationSyntax(modifiers, enumKeyword, identifier, openBraceToken, enumElements, closeBraceToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.modifiers = modifiers; - this.enumKeyword = enumKeyword; - this.identifier = identifier; - this.openBraceToken = openBraceToken; - this.enumElements = enumElements; - this.closeBraceToken = closeBraceToken; - } - EnumDeclarationSyntax.prototype.accept = function (visitor) { - return visitor.visitEnumDeclaration(this); - }; - - EnumDeclarationSyntax.prototype.kind = function () { - return 132 /* EnumDeclaration */; - }; - - EnumDeclarationSyntax.prototype.childCount = function () { - return 6; - }; - - EnumDeclarationSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.modifiers; - case 1: - return this.enumKeyword; - case 2: - return this.identifier; - case 3: - return this.openBraceToken; - case 4: - return this.enumElements; - case 5: - return this.closeBraceToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - EnumDeclarationSyntax.prototype.isModuleElement = function () { - return true; - }; - - EnumDeclarationSyntax.prototype.update = function (modifiers, enumKeyword, identifier, openBraceToken, enumElements, closeBraceToken) { - if (this.modifiers === modifiers && this.enumKeyword === enumKeyword && this.identifier === identifier && this.openBraceToken === openBraceToken && this.enumElements === enumElements && this.closeBraceToken === closeBraceToken) { - return this; - } - - return new EnumDeclarationSyntax(modifiers, enumKeyword, identifier, openBraceToken, enumElements, closeBraceToken, this.parsedInStrictMode()); - }; - - EnumDeclarationSyntax.create = function (enumKeyword, identifier, openBraceToken, closeBraceToken) { - return new EnumDeclarationSyntax(TypeScript.Syntax.emptyList, enumKeyword, identifier, openBraceToken, TypeScript.Syntax.emptySeparatedList, closeBraceToken, false); - }; - - EnumDeclarationSyntax.create1 = function (identifier) { - return new EnumDeclarationSyntax(TypeScript.Syntax.emptyList, TypeScript.Syntax.token(46 /* EnumKeyword */), identifier, TypeScript.Syntax.token(71 /* OpenBraceToken */), TypeScript.Syntax.emptySeparatedList, TypeScript.Syntax.token(72 /* CloseBraceToken */), false); - }; - - EnumDeclarationSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - EnumDeclarationSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - EnumDeclarationSyntax.prototype.withModifiers = function (modifiers) { - return this.update(modifiers, this.enumKeyword, this.identifier, this.openBraceToken, this.enumElements, this.closeBraceToken); - }; - - EnumDeclarationSyntax.prototype.withModifier = function (modifier) { - return this.withModifiers(TypeScript.Syntax.list([modifier])); - }; - - EnumDeclarationSyntax.prototype.withEnumKeyword = function (enumKeyword) { - return this.update(this.modifiers, enumKeyword, this.identifier, this.openBraceToken, this.enumElements, this.closeBraceToken); - }; - - EnumDeclarationSyntax.prototype.withIdentifier = function (identifier) { - return this.update(this.modifiers, this.enumKeyword, identifier, this.openBraceToken, this.enumElements, this.closeBraceToken); - }; - - EnumDeclarationSyntax.prototype.withOpenBraceToken = function (openBraceToken) { - return this.update(this.modifiers, this.enumKeyword, this.identifier, openBraceToken, this.enumElements, this.closeBraceToken); - }; - - EnumDeclarationSyntax.prototype.withEnumElements = function (enumElements) { - return this.update(this.modifiers, this.enumKeyword, this.identifier, this.openBraceToken, enumElements, this.closeBraceToken); - }; - - EnumDeclarationSyntax.prototype.withEnumElement = function (enumElement) { - return this.withEnumElements(TypeScript.Syntax.separatedList([enumElement])); - }; - - EnumDeclarationSyntax.prototype.withCloseBraceToken = function (closeBraceToken) { - return this.update(this.modifiers, this.enumKeyword, this.identifier, this.openBraceToken, this.enumElements, closeBraceToken); - }; - - EnumDeclarationSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return EnumDeclarationSyntax; - })(TypeScript.SyntaxNode); - TypeScript.EnumDeclarationSyntax = EnumDeclarationSyntax; - - var EnumElementSyntax = (function (_super) { - __extends(EnumElementSyntax, _super); - function EnumElementSyntax(propertyName, equalsValueClause, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.propertyName = propertyName; - this.equalsValueClause = equalsValueClause; - } - EnumElementSyntax.prototype.accept = function (visitor) { - return visitor.visitEnumElement(this); - }; - - EnumElementSyntax.prototype.kind = function () { - return 243 /* EnumElement */; - }; - - EnumElementSyntax.prototype.childCount = function () { - return 2; - }; - - EnumElementSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.propertyName; - case 1: - return this.equalsValueClause; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - EnumElementSyntax.prototype.update = function (propertyName, equalsValueClause) { - if (this.propertyName === propertyName && this.equalsValueClause === equalsValueClause) { - return this; - } - - return new EnumElementSyntax(propertyName, equalsValueClause, this.parsedInStrictMode()); - }; - - EnumElementSyntax.create = function (propertyName) { - return new EnumElementSyntax(propertyName, null, false); - }; - - EnumElementSyntax.create1 = function (propertyName) { - return new EnumElementSyntax(propertyName, null, false); - }; - - EnumElementSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - EnumElementSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - EnumElementSyntax.prototype.withPropertyName = function (propertyName) { - return this.update(propertyName, this.equalsValueClause); - }; - - EnumElementSyntax.prototype.withEqualsValueClause = function (equalsValueClause) { - return this.update(this.propertyName, equalsValueClause); - }; - - EnumElementSyntax.prototype.isTypeScriptSpecific = function () { - if (this.equalsValueClause !== null && this.equalsValueClause.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return EnumElementSyntax; - })(TypeScript.SyntaxNode); - TypeScript.EnumElementSyntax = EnumElementSyntax; - - var CastExpressionSyntax = (function (_super) { - __extends(CastExpressionSyntax, _super); - function CastExpressionSyntax(lessThanToken, type, greaterThanToken, expression, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.lessThanToken = lessThanToken; - this.type = type; - this.greaterThanToken = greaterThanToken; - this.expression = expression; - } - CastExpressionSyntax.prototype.accept = function (visitor) { - return visitor.visitCastExpression(this); - }; - - CastExpressionSyntax.prototype.kind = function () { - return 219 /* CastExpression */; - }; - - CastExpressionSyntax.prototype.childCount = function () { - return 4; - }; - - CastExpressionSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.lessThanToken; - case 1: - return this.type; - case 2: - return this.greaterThanToken; - case 3: - return this.expression; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - CastExpressionSyntax.prototype.isUnaryExpression = function () { - return true; - }; - - CastExpressionSyntax.prototype.isExpression = function () { - return true; - }; - - CastExpressionSyntax.prototype.update = function (lessThanToken, type, greaterThanToken, expression) { - if (this.lessThanToken === lessThanToken && this.type === type && this.greaterThanToken === greaterThanToken && this.expression === expression) { - return this; - } - - return new CastExpressionSyntax(lessThanToken, type, greaterThanToken, expression, this.parsedInStrictMode()); - }; - - CastExpressionSyntax.create1 = function (type, expression) { - return new CastExpressionSyntax(TypeScript.Syntax.token(81 /* LessThanToken */), type, TypeScript.Syntax.token(82 /* GreaterThanToken */), expression, false); - }; - - CastExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - CastExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - CastExpressionSyntax.prototype.withLessThanToken = function (lessThanToken) { - return this.update(lessThanToken, this.type, this.greaterThanToken, this.expression); - }; - - CastExpressionSyntax.prototype.withType = function (type) { - return this.update(this.lessThanToken, type, this.greaterThanToken, this.expression); - }; - - CastExpressionSyntax.prototype.withGreaterThanToken = function (greaterThanToken) { - return this.update(this.lessThanToken, this.type, greaterThanToken, this.expression); - }; - - CastExpressionSyntax.prototype.withExpression = function (expression) { - return this.update(this.lessThanToken, this.type, this.greaterThanToken, expression); - }; - - CastExpressionSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return CastExpressionSyntax; - })(TypeScript.SyntaxNode); - TypeScript.CastExpressionSyntax = CastExpressionSyntax; - - var ObjectLiteralExpressionSyntax = (function (_super) { - __extends(ObjectLiteralExpressionSyntax, _super); - function ObjectLiteralExpressionSyntax(openBraceToken, propertyAssignments, closeBraceToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.openBraceToken = openBraceToken; - this.propertyAssignments = propertyAssignments; - this.closeBraceToken = closeBraceToken; - } - ObjectLiteralExpressionSyntax.prototype.accept = function (visitor) { - return visitor.visitObjectLiteralExpression(this); - }; - - ObjectLiteralExpressionSyntax.prototype.kind = function () { - return 214 /* ObjectLiteralExpression */; - }; - - ObjectLiteralExpressionSyntax.prototype.childCount = function () { - return 3; - }; - - ObjectLiteralExpressionSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.openBraceToken; - case 1: - return this.propertyAssignments; - case 2: - return this.closeBraceToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ObjectLiteralExpressionSyntax.prototype.isUnaryExpression = function () { - return true; - }; - - ObjectLiteralExpressionSyntax.prototype.isExpression = function () { - return true; - }; - - ObjectLiteralExpressionSyntax.prototype.update = function (openBraceToken, propertyAssignments, closeBraceToken) { - if (this.openBraceToken === openBraceToken && this.propertyAssignments === propertyAssignments && this.closeBraceToken === closeBraceToken) { - return this; - } - - return new ObjectLiteralExpressionSyntax(openBraceToken, propertyAssignments, closeBraceToken, this.parsedInStrictMode()); - }; - - ObjectLiteralExpressionSyntax.create = function (openBraceToken, closeBraceToken) { - return new ObjectLiteralExpressionSyntax(openBraceToken, TypeScript.Syntax.emptySeparatedList, closeBraceToken, false); - }; - - ObjectLiteralExpressionSyntax.create1 = function () { - return new ObjectLiteralExpressionSyntax(TypeScript.Syntax.token(71 /* OpenBraceToken */), TypeScript.Syntax.emptySeparatedList, TypeScript.Syntax.token(72 /* CloseBraceToken */), false); - }; - - ObjectLiteralExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ObjectLiteralExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ObjectLiteralExpressionSyntax.prototype.withOpenBraceToken = function (openBraceToken) { - return this.update(openBraceToken, this.propertyAssignments, this.closeBraceToken); - }; - - ObjectLiteralExpressionSyntax.prototype.withPropertyAssignments = function (propertyAssignments) { - return this.update(this.openBraceToken, propertyAssignments, this.closeBraceToken); - }; - - ObjectLiteralExpressionSyntax.prototype.withPropertyAssignment = function (propertyAssignment) { - return this.withPropertyAssignments(TypeScript.Syntax.separatedList([propertyAssignment])); - }; - - ObjectLiteralExpressionSyntax.prototype.withCloseBraceToken = function (closeBraceToken) { - return this.update(this.openBraceToken, this.propertyAssignments, closeBraceToken); - }; - - ObjectLiteralExpressionSyntax.prototype.isTypeScriptSpecific = function () { - if (this.propertyAssignments.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return ObjectLiteralExpressionSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ObjectLiteralExpressionSyntax = ObjectLiteralExpressionSyntax; - - var PropertyAssignmentSyntax = (function (_super) { - __extends(PropertyAssignmentSyntax, _super); - function PropertyAssignmentSyntax(propertyName, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.propertyName = propertyName; - } - PropertyAssignmentSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - PropertyAssignmentSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - PropertyAssignmentSyntax.prototype.isTypeScriptSpecific = function () { - return false; - }; - return PropertyAssignmentSyntax; - })(TypeScript.SyntaxNode); - TypeScript.PropertyAssignmentSyntax = PropertyAssignmentSyntax; - - var SimplePropertyAssignmentSyntax = (function (_super) { - __extends(SimplePropertyAssignmentSyntax, _super); - function SimplePropertyAssignmentSyntax(propertyName, colonToken, expression, parsedInStrictMode) { - _super.call(this, propertyName, parsedInStrictMode); - this.colonToken = colonToken; - this.expression = expression; - } - SimplePropertyAssignmentSyntax.prototype.accept = function (visitor) { - return visitor.visitSimplePropertyAssignment(this); - }; - - SimplePropertyAssignmentSyntax.prototype.kind = function () { - return 238 /* SimplePropertyAssignment */; - }; - - SimplePropertyAssignmentSyntax.prototype.childCount = function () { - return 3; - }; - - SimplePropertyAssignmentSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.propertyName; - case 1: - return this.colonToken; - case 2: - return this.expression; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - SimplePropertyAssignmentSyntax.prototype.update = function (propertyName, colonToken, expression) { - if (this.propertyName === propertyName && this.colonToken === colonToken && this.expression === expression) { - return this; - } - - return new SimplePropertyAssignmentSyntax(propertyName, colonToken, expression, this.parsedInStrictMode()); - }; - - SimplePropertyAssignmentSyntax.create1 = function (propertyName, expression) { - return new SimplePropertyAssignmentSyntax(propertyName, TypeScript.Syntax.token(107 /* ColonToken */), expression, false); - }; - - SimplePropertyAssignmentSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - SimplePropertyAssignmentSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - SimplePropertyAssignmentSyntax.prototype.withPropertyName = function (propertyName) { - return this.update(propertyName, this.colonToken, this.expression); - }; - - SimplePropertyAssignmentSyntax.prototype.withColonToken = function (colonToken) { - return this.update(this.propertyName, colonToken, this.expression); - }; - - SimplePropertyAssignmentSyntax.prototype.withExpression = function (expression) { - return this.update(this.propertyName, this.colonToken, expression); - }; - - SimplePropertyAssignmentSyntax.prototype.isTypeScriptSpecific = function () { - if (this.expression.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return SimplePropertyAssignmentSyntax; - })(PropertyAssignmentSyntax); - TypeScript.SimplePropertyAssignmentSyntax = SimplePropertyAssignmentSyntax; - - var FunctionPropertyAssignmentSyntax = (function (_super) { - __extends(FunctionPropertyAssignmentSyntax, _super); - function FunctionPropertyAssignmentSyntax(propertyName, callSignature, block, parsedInStrictMode) { - _super.call(this, propertyName, parsedInStrictMode); - this.callSignature = callSignature; - this.block = block; - } - FunctionPropertyAssignmentSyntax.prototype.accept = function (visitor) { - return visitor.visitFunctionPropertyAssignment(this); - }; - - FunctionPropertyAssignmentSyntax.prototype.kind = function () { - return 241 /* FunctionPropertyAssignment */; - }; - - FunctionPropertyAssignmentSyntax.prototype.childCount = function () { - return 3; - }; - - FunctionPropertyAssignmentSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.propertyName; - case 1: - return this.callSignature; - case 2: - return this.block; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - FunctionPropertyAssignmentSyntax.prototype.update = function (propertyName, callSignature, block) { - if (this.propertyName === propertyName && this.callSignature === callSignature && this.block === block) { - return this; - } - - return new FunctionPropertyAssignmentSyntax(propertyName, callSignature, block, this.parsedInStrictMode()); - }; - - FunctionPropertyAssignmentSyntax.create1 = function (propertyName) { - return new FunctionPropertyAssignmentSyntax(propertyName, CallSignatureSyntax.create1(), BlockSyntax.create1(), false); - }; - - FunctionPropertyAssignmentSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - FunctionPropertyAssignmentSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - FunctionPropertyAssignmentSyntax.prototype.withPropertyName = function (propertyName) { - return this.update(propertyName, this.callSignature, this.block); - }; - - FunctionPropertyAssignmentSyntax.prototype.withCallSignature = function (callSignature) { - return this.update(this.propertyName, callSignature, this.block); - }; - - FunctionPropertyAssignmentSyntax.prototype.withBlock = function (block) { - return this.update(this.propertyName, this.callSignature, block); - }; - - FunctionPropertyAssignmentSyntax.prototype.isTypeScriptSpecific = function () { - if (this.callSignature.isTypeScriptSpecific()) { - return true; - } - if (this.block.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return FunctionPropertyAssignmentSyntax; - })(PropertyAssignmentSyntax); - TypeScript.FunctionPropertyAssignmentSyntax = FunctionPropertyAssignmentSyntax; - - var AccessorPropertyAssignmentSyntax = (function (_super) { - __extends(AccessorPropertyAssignmentSyntax, _super); - function AccessorPropertyAssignmentSyntax(propertyName, openParenToken, closeParenToken, block, parsedInStrictMode) { - _super.call(this, propertyName, parsedInStrictMode); - this.openParenToken = openParenToken; - this.closeParenToken = closeParenToken; - this.block = block; - } - AccessorPropertyAssignmentSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - AccessorPropertyAssignmentSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - AccessorPropertyAssignmentSyntax.prototype.isTypeScriptSpecific = function () { - return false; - }; - return AccessorPropertyAssignmentSyntax; - })(PropertyAssignmentSyntax); - TypeScript.AccessorPropertyAssignmentSyntax = AccessorPropertyAssignmentSyntax; - - var GetAccessorPropertyAssignmentSyntax = (function (_super) { - __extends(GetAccessorPropertyAssignmentSyntax, _super); - function GetAccessorPropertyAssignmentSyntax(getKeyword, propertyName, openParenToken, closeParenToken, typeAnnotation, block, parsedInStrictMode) { - _super.call(this, propertyName, openParenToken, closeParenToken, block, parsedInStrictMode); - this.getKeyword = getKeyword; - this.typeAnnotation = typeAnnotation; - } - GetAccessorPropertyAssignmentSyntax.prototype.accept = function (visitor) { - return visitor.visitGetAccessorPropertyAssignment(this); - }; - - GetAccessorPropertyAssignmentSyntax.prototype.kind = function () { - return 239 /* GetAccessorPropertyAssignment */; - }; - - GetAccessorPropertyAssignmentSyntax.prototype.childCount = function () { - return 6; - }; - - GetAccessorPropertyAssignmentSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.getKeyword; - case 1: - return this.propertyName; - case 2: - return this.openParenToken; - case 3: - return this.closeParenToken; - case 4: - return this.typeAnnotation; - case 5: - return this.block; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - GetAccessorPropertyAssignmentSyntax.prototype.update = function (getKeyword, propertyName, openParenToken, closeParenToken, typeAnnotation, block) { - if (this.getKeyword === getKeyword && this.propertyName === propertyName && this.openParenToken === openParenToken && this.closeParenToken === closeParenToken && this.typeAnnotation === typeAnnotation && this.block === block) { - return this; - } - - return new GetAccessorPropertyAssignmentSyntax(getKeyword, propertyName, openParenToken, closeParenToken, typeAnnotation, block, this.parsedInStrictMode()); - }; - - GetAccessorPropertyAssignmentSyntax.create = function (getKeyword, propertyName, openParenToken, closeParenToken, block) { - return new GetAccessorPropertyAssignmentSyntax(getKeyword, propertyName, openParenToken, closeParenToken, null, block, false); - }; - - GetAccessorPropertyAssignmentSyntax.create1 = function (propertyName) { - return new GetAccessorPropertyAssignmentSyntax(TypeScript.Syntax.token(65 /* GetKeyword */), propertyName, TypeScript.Syntax.token(73 /* OpenParenToken */), TypeScript.Syntax.token(74 /* CloseParenToken */), null, BlockSyntax.create1(), false); - }; - - GetAccessorPropertyAssignmentSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - GetAccessorPropertyAssignmentSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - GetAccessorPropertyAssignmentSyntax.prototype.withGetKeyword = function (getKeyword) { - return this.update(getKeyword, this.propertyName, this.openParenToken, this.closeParenToken, this.typeAnnotation, this.block); - }; - - GetAccessorPropertyAssignmentSyntax.prototype.withPropertyName = function (propertyName) { - return this.update(this.getKeyword, propertyName, this.openParenToken, this.closeParenToken, this.typeAnnotation, this.block); - }; - - GetAccessorPropertyAssignmentSyntax.prototype.withOpenParenToken = function (openParenToken) { - return this.update(this.getKeyword, this.propertyName, openParenToken, this.closeParenToken, this.typeAnnotation, this.block); - }; - - GetAccessorPropertyAssignmentSyntax.prototype.withCloseParenToken = function (closeParenToken) { - return this.update(this.getKeyword, this.propertyName, this.openParenToken, closeParenToken, this.typeAnnotation, this.block); - }; - - GetAccessorPropertyAssignmentSyntax.prototype.withTypeAnnotation = function (typeAnnotation) { - return this.update(this.getKeyword, this.propertyName, this.openParenToken, this.closeParenToken, typeAnnotation, this.block); - }; - - GetAccessorPropertyAssignmentSyntax.prototype.withBlock = function (block) { - return this.update(this.getKeyword, this.propertyName, this.openParenToken, this.closeParenToken, this.typeAnnotation, block); - }; - - GetAccessorPropertyAssignmentSyntax.prototype.isTypeScriptSpecific = function () { - if (this.typeAnnotation !== null && this.typeAnnotation.isTypeScriptSpecific()) { - return true; - } - if (this.block.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return GetAccessorPropertyAssignmentSyntax; - })(AccessorPropertyAssignmentSyntax); - TypeScript.GetAccessorPropertyAssignmentSyntax = GetAccessorPropertyAssignmentSyntax; - - var SetAccessorPropertyAssignmentSyntax = (function (_super) { - __extends(SetAccessorPropertyAssignmentSyntax, _super); - function SetAccessorPropertyAssignmentSyntax(setKeyword, propertyName, openParenToken, parameter, closeParenToken, block, parsedInStrictMode) { - _super.call(this, propertyName, openParenToken, closeParenToken, block, parsedInStrictMode); - this.setKeyword = setKeyword; - this.parameter = parameter; - } - SetAccessorPropertyAssignmentSyntax.prototype.accept = function (visitor) { - return visitor.visitSetAccessorPropertyAssignment(this); - }; - - SetAccessorPropertyAssignmentSyntax.prototype.kind = function () { - return 240 /* SetAccessorPropertyAssignment */; - }; - - SetAccessorPropertyAssignmentSyntax.prototype.childCount = function () { - return 6; - }; - - SetAccessorPropertyAssignmentSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.setKeyword; - case 1: - return this.propertyName; - case 2: - return this.openParenToken; - case 3: - return this.parameter; - case 4: - return this.closeParenToken; - case 5: - return this.block; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - SetAccessorPropertyAssignmentSyntax.prototype.update = function (setKeyword, propertyName, openParenToken, parameter, closeParenToken, block) { - if (this.setKeyword === setKeyword && this.propertyName === propertyName && this.openParenToken === openParenToken && this.parameter === parameter && this.closeParenToken === closeParenToken && this.block === block) { - return this; - } - - return new SetAccessorPropertyAssignmentSyntax(setKeyword, propertyName, openParenToken, parameter, closeParenToken, block, this.parsedInStrictMode()); - }; - - SetAccessorPropertyAssignmentSyntax.create1 = function (propertyName, parameter) { - return new SetAccessorPropertyAssignmentSyntax(TypeScript.Syntax.token(69 /* SetKeyword */), propertyName, TypeScript.Syntax.token(73 /* OpenParenToken */), parameter, TypeScript.Syntax.token(74 /* CloseParenToken */), BlockSyntax.create1(), false); - }; - - SetAccessorPropertyAssignmentSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - SetAccessorPropertyAssignmentSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - SetAccessorPropertyAssignmentSyntax.prototype.withSetKeyword = function (setKeyword) { - return this.update(setKeyword, this.propertyName, this.openParenToken, this.parameter, this.closeParenToken, this.block); - }; - - SetAccessorPropertyAssignmentSyntax.prototype.withPropertyName = function (propertyName) { - return this.update(this.setKeyword, propertyName, this.openParenToken, this.parameter, this.closeParenToken, this.block); - }; - - SetAccessorPropertyAssignmentSyntax.prototype.withOpenParenToken = function (openParenToken) { - return this.update(this.setKeyword, this.propertyName, openParenToken, this.parameter, this.closeParenToken, this.block); - }; - - SetAccessorPropertyAssignmentSyntax.prototype.withParameter = function (parameter) { - return this.update(this.setKeyword, this.propertyName, this.openParenToken, parameter, this.closeParenToken, this.block); - }; - - SetAccessorPropertyAssignmentSyntax.prototype.withCloseParenToken = function (closeParenToken) { - return this.update(this.setKeyword, this.propertyName, this.openParenToken, this.parameter, closeParenToken, this.block); - }; - - SetAccessorPropertyAssignmentSyntax.prototype.withBlock = function (block) { - return this.update(this.setKeyword, this.propertyName, this.openParenToken, this.parameter, this.closeParenToken, block); - }; - - SetAccessorPropertyAssignmentSyntax.prototype.isTypeScriptSpecific = function () { - if (this.parameter.isTypeScriptSpecific()) { - return true; - } - if (this.block.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return SetAccessorPropertyAssignmentSyntax; - })(AccessorPropertyAssignmentSyntax); - TypeScript.SetAccessorPropertyAssignmentSyntax = SetAccessorPropertyAssignmentSyntax; - - var FunctionExpressionSyntax = (function (_super) { - __extends(FunctionExpressionSyntax, _super); - function FunctionExpressionSyntax(functionKeyword, identifier, callSignature, block, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.functionKeyword = functionKeyword; - this.identifier = identifier; - this.callSignature = callSignature; - this.block = block; - } - FunctionExpressionSyntax.prototype.accept = function (visitor) { - return visitor.visitFunctionExpression(this); - }; - - FunctionExpressionSyntax.prototype.kind = function () { - return 221 /* FunctionExpression */; - }; - - FunctionExpressionSyntax.prototype.childCount = function () { - return 4; - }; - - FunctionExpressionSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.functionKeyword; - case 1: - return this.identifier; - case 2: - return this.callSignature; - case 3: - return this.block; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - FunctionExpressionSyntax.prototype.isUnaryExpression = function () { - return true; - }; - - FunctionExpressionSyntax.prototype.isExpression = function () { - return true; - }; - - FunctionExpressionSyntax.prototype.update = function (functionKeyword, identifier, callSignature, block) { - if (this.functionKeyword === functionKeyword && this.identifier === identifier && this.callSignature === callSignature && this.block === block) { - return this; - } - - return new FunctionExpressionSyntax(functionKeyword, identifier, callSignature, block, this.parsedInStrictMode()); - }; - - FunctionExpressionSyntax.create = function (functionKeyword, callSignature, block) { - return new FunctionExpressionSyntax(functionKeyword, null, callSignature, block, false); - }; - - FunctionExpressionSyntax.create1 = function () { - return new FunctionExpressionSyntax(TypeScript.Syntax.token(27 /* FunctionKeyword */), null, CallSignatureSyntax.create1(), BlockSyntax.create1(), false); - }; - - FunctionExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - FunctionExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - FunctionExpressionSyntax.prototype.withFunctionKeyword = function (functionKeyword) { - return this.update(functionKeyword, this.identifier, this.callSignature, this.block); - }; - - FunctionExpressionSyntax.prototype.withIdentifier = function (identifier) { - return this.update(this.functionKeyword, identifier, this.callSignature, this.block); - }; - - FunctionExpressionSyntax.prototype.withCallSignature = function (callSignature) { - return this.update(this.functionKeyword, this.identifier, callSignature, this.block); - }; - - FunctionExpressionSyntax.prototype.withBlock = function (block) { - return this.update(this.functionKeyword, this.identifier, this.callSignature, block); - }; - - FunctionExpressionSyntax.prototype.isTypeScriptSpecific = function () { - if (this.callSignature.isTypeScriptSpecific()) { - return true; - } - if (this.block.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return FunctionExpressionSyntax; - })(TypeScript.SyntaxNode); - TypeScript.FunctionExpressionSyntax = FunctionExpressionSyntax; - - var EmptyStatementSyntax = (function (_super) { - __extends(EmptyStatementSyntax, _super); - function EmptyStatementSyntax(semicolonToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.semicolonToken = semicolonToken; - } - EmptyStatementSyntax.prototype.accept = function (visitor) { - return visitor.visitEmptyStatement(this); - }; - - EmptyStatementSyntax.prototype.kind = function () { - return 155 /* EmptyStatement */; - }; - - EmptyStatementSyntax.prototype.childCount = function () { - return 1; - }; - - EmptyStatementSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.semicolonToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - EmptyStatementSyntax.prototype.isStatement = function () { - return true; - }; - - EmptyStatementSyntax.prototype.isModuleElement = function () { - return true; - }; - - EmptyStatementSyntax.prototype.update = function (semicolonToken) { - if (this.semicolonToken === semicolonToken) { - return this; - } - - return new EmptyStatementSyntax(semicolonToken, this.parsedInStrictMode()); - }; - - EmptyStatementSyntax.create1 = function () { - return new EmptyStatementSyntax(TypeScript.Syntax.token(79 /* SemicolonToken */), false); - }; - - EmptyStatementSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - EmptyStatementSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - EmptyStatementSyntax.prototype.withSemicolonToken = function (semicolonToken) { - return this.update(semicolonToken); - }; - - EmptyStatementSyntax.prototype.isTypeScriptSpecific = function () { - return false; - }; - return EmptyStatementSyntax; - })(TypeScript.SyntaxNode); - TypeScript.EmptyStatementSyntax = EmptyStatementSyntax; - - var TryStatementSyntax = (function (_super) { - __extends(TryStatementSyntax, _super); - function TryStatementSyntax(tryKeyword, block, catchClause, finallyClause, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.tryKeyword = tryKeyword; - this.block = block; - this.catchClause = catchClause; - this.finallyClause = finallyClause; - } - TryStatementSyntax.prototype.accept = function (visitor) { - return visitor.visitTryStatement(this); - }; - - TryStatementSyntax.prototype.kind = function () { - return 158 /* TryStatement */; - }; - - TryStatementSyntax.prototype.childCount = function () { - return 4; - }; - - TryStatementSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.tryKeyword; - case 1: - return this.block; - case 2: - return this.catchClause; - case 3: - return this.finallyClause; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - TryStatementSyntax.prototype.isStatement = function () { - return true; - }; - - TryStatementSyntax.prototype.isModuleElement = function () { - return true; - }; - - TryStatementSyntax.prototype.update = function (tryKeyword, block, catchClause, finallyClause) { - if (this.tryKeyword === tryKeyword && this.block === block && this.catchClause === catchClause && this.finallyClause === finallyClause) { - return this; - } - - return new TryStatementSyntax(tryKeyword, block, catchClause, finallyClause, this.parsedInStrictMode()); - }; - - TryStatementSyntax.create = function (tryKeyword, block) { - return new TryStatementSyntax(tryKeyword, block, null, null, false); - }; - - TryStatementSyntax.create1 = function () { - return new TryStatementSyntax(TypeScript.Syntax.token(38 /* TryKeyword */), BlockSyntax.create1(), null, null, false); - }; - - TryStatementSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - TryStatementSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - TryStatementSyntax.prototype.withTryKeyword = function (tryKeyword) { - return this.update(tryKeyword, this.block, this.catchClause, this.finallyClause); - }; - - TryStatementSyntax.prototype.withBlock = function (block) { - return this.update(this.tryKeyword, block, this.catchClause, this.finallyClause); - }; - - TryStatementSyntax.prototype.withCatchClause = function (catchClause) { - return this.update(this.tryKeyword, this.block, catchClause, this.finallyClause); - }; - - TryStatementSyntax.prototype.withFinallyClause = function (finallyClause) { - return this.update(this.tryKeyword, this.block, this.catchClause, finallyClause); - }; - - TryStatementSyntax.prototype.isTypeScriptSpecific = function () { - if (this.block.isTypeScriptSpecific()) { - return true; - } - if (this.catchClause !== null && this.catchClause.isTypeScriptSpecific()) { - return true; - } - if (this.finallyClause !== null && this.finallyClause.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return TryStatementSyntax; - })(TypeScript.SyntaxNode); - TypeScript.TryStatementSyntax = TryStatementSyntax; - - var CatchClauseSyntax = (function (_super) { - __extends(CatchClauseSyntax, _super); - function CatchClauseSyntax(catchKeyword, openParenToken, identifier, typeAnnotation, closeParenToken, block, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.catchKeyword = catchKeyword; - this.openParenToken = openParenToken; - this.identifier = identifier; - this.typeAnnotation = typeAnnotation; - this.closeParenToken = closeParenToken; - this.block = block; - } - CatchClauseSyntax.prototype.accept = function (visitor) { - return visitor.visitCatchClause(this); - }; - - CatchClauseSyntax.prototype.kind = function () { - return 234 /* CatchClause */; - }; - - CatchClauseSyntax.prototype.childCount = function () { - return 6; - }; - - CatchClauseSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.catchKeyword; - case 1: - return this.openParenToken; - case 2: - return this.identifier; - case 3: - return this.typeAnnotation; - case 4: - return this.closeParenToken; - case 5: - return this.block; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - CatchClauseSyntax.prototype.update = function (catchKeyword, openParenToken, identifier, typeAnnotation, closeParenToken, block) { - if (this.catchKeyword === catchKeyword && this.openParenToken === openParenToken && this.identifier === identifier && this.typeAnnotation === typeAnnotation && this.closeParenToken === closeParenToken && this.block === block) { - return this; - } - - return new CatchClauseSyntax(catchKeyword, openParenToken, identifier, typeAnnotation, closeParenToken, block, this.parsedInStrictMode()); - }; - - CatchClauseSyntax.create = function (catchKeyword, openParenToken, identifier, closeParenToken, block) { - return new CatchClauseSyntax(catchKeyword, openParenToken, identifier, null, closeParenToken, block, false); - }; - - CatchClauseSyntax.create1 = function (identifier) { - return new CatchClauseSyntax(TypeScript.Syntax.token(17 /* CatchKeyword */), TypeScript.Syntax.token(73 /* OpenParenToken */), identifier, null, TypeScript.Syntax.token(74 /* CloseParenToken */), BlockSyntax.create1(), false); - }; - - CatchClauseSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - CatchClauseSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - CatchClauseSyntax.prototype.withCatchKeyword = function (catchKeyword) { - return this.update(catchKeyword, this.openParenToken, this.identifier, this.typeAnnotation, this.closeParenToken, this.block); - }; - - CatchClauseSyntax.prototype.withOpenParenToken = function (openParenToken) { - return this.update(this.catchKeyword, openParenToken, this.identifier, this.typeAnnotation, this.closeParenToken, this.block); - }; - - CatchClauseSyntax.prototype.withIdentifier = function (identifier) { - return this.update(this.catchKeyword, this.openParenToken, identifier, this.typeAnnotation, this.closeParenToken, this.block); - }; - - CatchClauseSyntax.prototype.withTypeAnnotation = function (typeAnnotation) { - return this.update(this.catchKeyword, this.openParenToken, this.identifier, typeAnnotation, this.closeParenToken, this.block); - }; - - CatchClauseSyntax.prototype.withCloseParenToken = function (closeParenToken) { - return this.update(this.catchKeyword, this.openParenToken, this.identifier, this.typeAnnotation, closeParenToken, this.block); - }; - - CatchClauseSyntax.prototype.withBlock = function (block) { - return this.update(this.catchKeyword, this.openParenToken, this.identifier, this.typeAnnotation, this.closeParenToken, block); - }; - - CatchClauseSyntax.prototype.isTypeScriptSpecific = function () { - if (this.typeAnnotation !== null && this.typeAnnotation.isTypeScriptSpecific()) { - return true; - } - if (this.block.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return CatchClauseSyntax; - })(TypeScript.SyntaxNode); - TypeScript.CatchClauseSyntax = CatchClauseSyntax; - - var FinallyClauseSyntax = (function (_super) { - __extends(FinallyClauseSyntax, _super); - function FinallyClauseSyntax(finallyKeyword, block, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.finallyKeyword = finallyKeyword; - this.block = block; - } - FinallyClauseSyntax.prototype.accept = function (visitor) { - return visitor.visitFinallyClause(this); - }; - - FinallyClauseSyntax.prototype.kind = function () { - return 235 /* FinallyClause */; - }; - - FinallyClauseSyntax.prototype.childCount = function () { - return 2; - }; - - FinallyClauseSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.finallyKeyword; - case 1: - return this.block; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - FinallyClauseSyntax.prototype.update = function (finallyKeyword, block) { - if (this.finallyKeyword === finallyKeyword && this.block === block) { - return this; - } - - return new FinallyClauseSyntax(finallyKeyword, block, this.parsedInStrictMode()); - }; - - FinallyClauseSyntax.create1 = function () { - return new FinallyClauseSyntax(TypeScript.Syntax.token(25 /* FinallyKeyword */), BlockSyntax.create1(), false); - }; - - FinallyClauseSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - FinallyClauseSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - FinallyClauseSyntax.prototype.withFinallyKeyword = function (finallyKeyword) { - return this.update(finallyKeyword, this.block); - }; - - FinallyClauseSyntax.prototype.withBlock = function (block) { - return this.update(this.finallyKeyword, block); - }; - - FinallyClauseSyntax.prototype.isTypeScriptSpecific = function () { - if (this.block.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return FinallyClauseSyntax; - })(TypeScript.SyntaxNode); - TypeScript.FinallyClauseSyntax = FinallyClauseSyntax; - - var LabeledStatementSyntax = (function (_super) { - __extends(LabeledStatementSyntax, _super); - function LabeledStatementSyntax(identifier, colonToken, statement, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.identifier = identifier; - this.colonToken = colonToken; - this.statement = statement; - } - LabeledStatementSyntax.prototype.accept = function (visitor) { - return visitor.visitLabeledStatement(this); - }; - - LabeledStatementSyntax.prototype.kind = function () { - return 159 /* LabeledStatement */; - }; - - LabeledStatementSyntax.prototype.childCount = function () { - return 3; - }; - - LabeledStatementSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.identifier; - case 1: - return this.colonToken; - case 2: - return this.statement; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - LabeledStatementSyntax.prototype.isStatement = function () { - return true; - }; - - LabeledStatementSyntax.prototype.isModuleElement = function () { - return true; - }; - - LabeledStatementSyntax.prototype.update = function (identifier, colonToken, statement) { - if (this.identifier === identifier && this.colonToken === colonToken && this.statement === statement) { - return this; - } - - return new LabeledStatementSyntax(identifier, colonToken, statement, this.parsedInStrictMode()); - }; - - LabeledStatementSyntax.create1 = function (identifier, statement) { - return new LabeledStatementSyntax(identifier, TypeScript.Syntax.token(107 /* ColonToken */), statement, false); - }; - - LabeledStatementSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - LabeledStatementSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - LabeledStatementSyntax.prototype.withIdentifier = function (identifier) { - return this.update(identifier, this.colonToken, this.statement); - }; - - LabeledStatementSyntax.prototype.withColonToken = function (colonToken) { - return this.update(this.identifier, colonToken, this.statement); - }; - - LabeledStatementSyntax.prototype.withStatement = function (statement) { - return this.update(this.identifier, this.colonToken, statement); - }; - - LabeledStatementSyntax.prototype.isTypeScriptSpecific = function () { - if (this.statement.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return LabeledStatementSyntax; - })(TypeScript.SyntaxNode); - TypeScript.LabeledStatementSyntax = LabeledStatementSyntax; - - var DoStatementSyntax = (function (_super) { - __extends(DoStatementSyntax, _super); - function DoStatementSyntax(doKeyword, statement, whileKeyword, openParenToken, condition, closeParenToken, semicolonToken, parsedInStrictMode) { - _super.call(this, openParenToken, closeParenToken, statement, parsedInStrictMode); - this.doKeyword = doKeyword; - this.whileKeyword = whileKeyword; - this.condition = condition; - this.semicolonToken = semicolonToken; - } - DoStatementSyntax.prototype.accept = function (visitor) { - return visitor.visitDoStatement(this); - }; - - DoStatementSyntax.prototype.kind = function () { - return 160 /* DoStatement */; - }; - - DoStatementSyntax.prototype.childCount = function () { - return 7; - }; - - DoStatementSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.doKeyword; - case 1: - return this.statement; - case 2: - return this.whileKeyword; - case 3: - return this.openParenToken; - case 4: - return this.condition; - case 5: - return this.closeParenToken; - case 6: - return this.semicolonToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - DoStatementSyntax.prototype.update = function (doKeyword, statement, whileKeyword, openParenToken, condition, closeParenToken, semicolonToken) { - if (this.doKeyword === doKeyword && this.statement === statement && this.whileKeyword === whileKeyword && this.openParenToken === openParenToken && this.condition === condition && this.closeParenToken === closeParenToken && this.semicolonToken === semicolonToken) { - return this; - } - - return new DoStatementSyntax(doKeyword, statement, whileKeyword, openParenToken, condition, closeParenToken, semicolonToken, this.parsedInStrictMode()); - }; - - DoStatementSyntax.create1 = function (statement, condition) { - return new DoStatementSyntax(TypeScript.Syntax.token(22 /* DoKeyword */), statement, TypeScript.Syntax.token(42 /* WhileKeyword */), TypeScript.Syntax.token(73 /* OpenParenToken */), condition, TypeScript.Syntax.token(74 /* CloseParenToken */), TypeScript.Syntax.token(79 /* SemicolonToken */), false); - }; - - DoStatementSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - DoStatementSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - DoStatementSyntax.prototype.withDoKeyword = function (doKeyword) { - return this.update(doKeyword, this.statement, this.whileKeyword, this.openParenToken, this.condition, this.closeParenToken, this.semicolonToken); - }; - - DoStatementSyntax.prototype.withStatement = function (statement) { - return this.update(this.doKeyword, statement, this.whileKeyword, this.openParenToken, this.condition, this.closeParenToken, this.semicolonToken); - }; - - DoStatementSyntax.prototype.withWhileKeyword = function (whileKeyword) { - return this.update(this.doKeyword, this.statement, whileKeyword, this.openParenToken, this.condition, this.closeParenToken, this.semicolonToken); - }; - - DoStatementSyntax.prototype.withOpenParenToken = function (openParenToken) { - return this.update(this.doKeyword, this.statement, this.whileKeyword, openParenToken, this.condition, this.closeParenToken, this.semicolonToken); - }; - - DoStatementSyntax.prototype.withCondition = function (condition) { - return this.update(this.doKeyword, this.statement, this.whileKeyword, this.openParenToken, condition, this.closeParenToken, this.semicolonToken); - }; - - DoStatementSyntax.prototype.withCloseParenToken = function (closeParenToken) { - return this.update(this.doKeyword, this.statement, this.whileKeyword, this.openParenToken, this.condition, closeParenToken, this.semicolonToken); - }; - - DoStatementSyntax.prototype.withSemicolonToken = function (semicolonToken) { - return this.update(this.doKeyword, this.statement, this.whileKeyword, this.openParenToken, this.condition, this.closeParenToken, semicolonToken); - }; - - DoStatementSyntax.prototype.isTypeScriptSpecific = function () { - if (this.statement.isTypeScriptSpecific()) { - return true; - } - if (this.condition.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return DoStatementSyntax; - })(IterationStatementSyntax); - TypeScript.DoStatementSyntax = DoStatementSyntax; - - var TypeOfExpressionSyntax = (function (_super) { - __extends(TypeOfExpressionSyntax, _super); - function TypeOfExpressionSyntax(typeOfKeyword, expression, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.typeOfKeyword = typeOfKeyword; - this.expression = expression; - } - TypeOfExpressionSyntax.prototype.accept = function (visitor) { - return visitor.visitTypeOfExpression(this); - }; - - TypeOfExpressionSyntax.prototype.kind = function () { - return 170 /* TypeOfExpression */; - }; - - TypeOfExpressionSyntax.prototype.childCount = function () { - return 2; - }; - - TypeOfExpressionSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.typeOfKeyword; - case 1: - return this.expression; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - TypeOfExpressionSyntax.prototype.isUnaryExpression = function () { - return true; - }; - - TypeOfExpressionSyntax.prototype.isExpression = function () { - return true; - }; - - TypeOfExpressionSyntax.prototype.update = function (typeOfKeyword, expression) { - if (this.typeOfKeyword === typeOfKeyword && this.expression === expression) { - return this; - } - - return new TypeOfExpressionSyntax(typeOfKeyword, expression, this.parsedInStrictMode()); - }; - - TypeOfExpressionSyntax.create1 = function (expression) { - return new TypeOfExpressionSyntax(TypeScript.Syntax.token(39 /* TypeOfKeyword */), expression, false); - }; - - TypeOfExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - TypeOfExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - TypeOfExpressionSyntax.prototype.withTypeOfKeyword = function (typeOfKeyword) { - return this.update(typeOfKeyword, this.expression); - }; - - TypeOfExpressionSyntax.prototype.withExpression = function (expression) { - return this.update(this.typeOfKeyword, expression); - }; - - TypeOfExpressionSyntax.prototype.isTypeScriptSpecific = function () { - if (this.expression.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return TypeOfExpressionSyntax; - })(TypeScript.SyntaxNode); - TypeScript.TypeOfExpressionSyntax = TypeOfExpressionSyntax; - - var DeleteExpressionSyntax = (function (_super) { - __extends(DeleteExpressionSyntax, _super); - function DeleteExpressionSyntax(deleteKeyword, expression, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.deleteKeyword = deleteKeyword; - this.expression = expression; - } - DeleteExpressionSyntax.prototype.accept = function (visitor) { - return visitor.visitDeleteExpression(this); - }; - - DeleteExpressionSyntax.prototype.kind = function () { - return 169 /* DeleteExpression */; - }; - - DeleteExpressionSyntax.prototype.childCount = function () { - return 2; - }; - - DeleteExpressionSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.deleteKeyword; - case 1: - return this.expression; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - DeleteExpressionSyntax.prototype.isUnaryExpression = function () { - return true; - }; - - DeleteExpressionSyntax.prototype.isExpression = function () { - return true; - }; - - DeleteExpressionSyntax.prototype.update = function (deleteKeyword, expression) { - if (this.deleteKeyword === deleteKeyword && this.expression === expression) { - return this; - } - - return new DeleteExpressionSyntax(deleteKeyword, expression, this.parsedInStrictMode()); - }; - - DeleteExpressionSyntax.create1 = function (expression) { - return new DeleteExpressionSyntax(TypeScript.Syntax.token(21 /* DeleteKeyword */), expression, false); - }; - - DeleteExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - DeleteExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - DeleteExpressionSyntax.prototype.withDeleteKeyword = function (deleteKeyword) { - return this.update(deleteKeyword, this.expression); - }; - - DeleteExpressionSyntax.prototype.withExpression = function (expression) { - return this.update(this.deleteKeyword, expression); - }; - - DeleteExpressionSyntax.prototype.isTypeScriptSpecific = function () { - if (this.expression.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return DeleteExpressionSyntax; - })(TypeScript.SyntaxNode); - TypeScript.DeleteExpressionSyntax = DeleteExpressionSyntax; - - var VoidExpressionSyntax = (function (_super) { - __extends(VoidExpressionSyntax, _super); - function VoidExpressionSyntax(voidKeyword, expression, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.voidKeyword = voidKeyword; - this.expression = expression; - } - VoidExpressionSyntax.prototype.accept = function (visitor) { - return visitor.visitVoidExpression(this); - }; - - VoidExpressionSyntax.prototype.kind = function () { - return 171 /* VoidExpression */; - }; - - VoidExpressionSyntax.prototype.childCount = function () { - return 2; - }; - - VoidExpressionSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.voidKeyword; - case 1: - return this.expression; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - VoidExpressionSyntax.prototype.isUnaryExpression = function () { - return true; - }; - - VoidExpressionSyntax.prototype.isExpression = function () { - return true; - }; - - VoidExpressionSyntax.prototype.update = function (voidKeyword, expression) { - if (this.voidKeyword === voidKeyword && this.expression === expression) { - return this; - } - - return new VoidExpressionSyntax(voidKeyword, expression, this.parsedInStrictMode()); - }; - - VoidExpressionSyntax.create1 = function (expression) { - return new VoidExpressionSyntax(TypeScript.Syntax.token(41 /* VoidKeyword */), expression, false); - }; - - VoidExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - VoidExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - VoidExpressionSyntax.prototype.withVoidKeyword = function (voidKeyword) { - return this.update(voidKeyword, this.expression); - }; - - VoidExpressionSyntax.prototype.withExpression = function (expression) { - return this.update(this.voidKeyword, expression); - }; - - VoidExpressionSyntax.prototype.isTypeScriptSpecific = function () { - if (this.expression.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return VoidExpressionSyntax; - })(TypeScript.SyntaxNode); - TypeScript.VoidExpressionSyntax = VoidExpressionSyntax; - - var DebuggerStatementSyntax = (function (_super) { - __extends(DebuggerStatementSyntax, _super); - function DebuggerStatementSyntax(debuggerKeyword, semicolonToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.debuggerKeyword = debuggerKeyword; - this.semicolonToken = semicolonToken; - } - DebuggerStatementSyntax.prototype.accept = function (visitor) { - return visitor.visitDebuggerStatement(this); - }; - - DebuggerStatementSyntax.prototype.kind = function () { - return 161 /* DebuggerStatement */; - }; - - DebuggerStatementSyntax.prototype.childCount = function () { - return 2; - }; - - DebuggerStatementSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.debuggerKeyword; - case 1: - return this.semicolonToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - DebuggerStatementSyntax.prototype.isStatement = function () { - return true; - }; - - DebuggerStatementSyntax.prototype.isModuleElement = function () { - return true; - }; - - DebuggerStatementSyntax.prototype.update = function (debuggerKeyword, semicolonToken) { - if (this.debuggerKeyword === debuggerKeyword && this.semicolonToken === semicolonToken) { - return this; - } - - return new DebuggerStatementSyntax(debuggerKeyword, semicolonToken, this.parsedInStrictMode()); - }; - - DebuggerStatementSyntax.create1 = function () { - return new DebuggerStatementSyntax(TypeScript.Syntax.token(19 /* DebuggerKeyword */), TypeScript.Syntax.token(79 /* SemicolonToken */), false); - }; - - DebuggerStatementSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - DebuggerStatementSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - DebuggerStatementSyntax.prototype.withDebuggerKeyword = function (debuggerKeyword) { - return this.update(debuggerKeyword, this.semicolonToken); - }; - - DebuggerStatementSyntax.prototype.withSemicolonToken = function (semicolonToken) { - return this.update(this.debuggerKeyword, semicolonToken); - }; - - DebuggerStatementSyntax.prototype.isTypeScriptSpecific = function () { - return false; - }; - return DebuggerStatementSyntax; - })(TypeScript.SyntaxNode); - TypeScript.DebuggerStatementSyntax = DebuggerStatementSyntax; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var SyntaxRewriter = (function () { - function SyntaxRewriter() { - } - SyntaxRewriter.prototype.visitToken = function (token) { - return token; - }; - - SyntaxRewriter.prototype.visitNode = function (node) { - return node.accept(this); - }; - - SyntaxRewriter.prototype.visitNodeOrToken = function (node) { - return node.isToken() ? this.visitToken(node) : this.visitNode(node); - }; - - SyntaxRewriter.prototype.visitList = function (list) { - var newItems = null; - - for (var i = 0, n = list.childCount(); i < n; i++) { - var item = list.childAt(i); - var newItem = this.visitNodeOrToken(item); - - if (item !== newItem && newItems === null) { - newItems = []; - for (var j = 0; j < i; j++) { - newItems.push(list.childAt(j)); - } - } - - if (newItems) { - newItems.push(newItem); - } - } - - return newItems === null ? list : TypeScript.Syntax.list(newItems); - }; - - SyntaxRewriter.prototype.visitSeparatedList = function (list) { - var newItems = null; - - for (var i = 0, n = list.childCount(); i < n; i++) { - var item = list.childAt(i); - var newItem = item.isToken() ? this.visitToken(item) : this.visitNode(item); - - if (item !== newItem && newItems === null) { - newItems = []; - for (var j = 0; j < i; j++) { - newItems.push(list.childAt(j)); - } - } - - if (newItems) { - newItems.push(newItem); - } - } - - return newItems === null ? list : TypeScript.Syntax.separatedList(newItems); - }; - - SyntaxRewriter.prototype.visitSourceUnit = function (node) { - return node.update(this.visitList(node.moduleElements), this.visitToken(node.endOfFileToken)); - }; - - SyntaxRewriter.prototype.visitExternalModuleReference = function (node) { - return node.update(this.visitToken(node.moduleOrRequireKeyword), this.visitToken(node.openParenToken), this.visitToken(node.stringLiteral), this.visitToken(node.closeParenToken)); - }; - - SyntaxRewriter.prototype.visitModuleNameModuleReference = function (node) { - return node.update(this.visitNodeOrToken(node.moduleName)); - }; - - SyntaxRewriter.prototype.visitImportDeclaration = function (node) { - return node.update(this.visitToken(node.importKeyword), this.visitToken(node.identifier), this.visitToken(node.equalsToken), this.visitNode(node.moduleReference), this.visitToken(node.semicolonToken)); - }; - - SyntaxRewriter.prototype.visitExportAssignment = function (node) { - return node.update(this.visitToken(node.exportKeyword), this.visitToken(node.equalsToken), this.visitToken(node.identifier), this.visitToken(node.semicolonToken)); - }; - - SyntaxRewriter.prototype.visitClassDeclaration = function (node) { - return node.update(this.visitList(node.modifiers), this.visitToken(node.classKeyword), this.visitToken(node.identifier), node.typeParameterList === null ? null : this.visitNode(node.typeParameterList), this.visitList(node.heritageClauses), this.visitToken(node.openBraceToken), this.visitList(node.classElements), this.visitToken(node.closeBraceToken)); - }; - - SyntaxRewriter.prototype.visitInterfaceDeclaration = function (node) { - return node.update(this.visitList(node.modifiers), this.visitToken(node.interfaceKeyword), this.visitToken(node.identifier), node.typeParameterList === null ? null : this.visitNode(node.typeParameterList), this.visitList(node.heritageClauses), this.visitNode(node.body)); - }; - - SyntaxRewriter.prototype.visitHeritageClause = function (node) { - return node.update(this.visitToken(node.extendsOrImplementsKeyword), this.visitSeparatedList(node.typeNames)); - }; - - SyntaxRewriter.prototype.visitModuleDeclaration = function (node) { - return node.update(this.visitList(node.modifiers), this.visitToken(node.moduleKeyword), node.moduleName === null ? null : this.visitNodeOrToken(node.moduleName), node.stringLiteral === null ? null : this.visitToken(node.stringLiteral), this.visitToken(node.openBraceToken), this.visitList(node.moduleElements), this.visitToken(node.closeBraceToken)); - }; - - SyntaxRewriter.prototype.visitFunctionDeclaration = function (node) { - return node.update(this.visitList(node.modifiers), this.visitToken(node.functionKeyword), this.visitToken(node.identifier), this.visitNode(node.callSignature), node.block === null ? null : this.visitNode(node.block), node.semicolonToken === null ? null : this.visitToken(node.semicolonToken)); - }; - - SyntaxRewriter.prototype.visitVariableStatement = function (node) { - return node.update(this.visitList(node.modifiers), this.visitNode(node.variableDeclaration), this.visitToken(node.semicolonToken)); - }; - - SyntaxRewriter.prototype.visitVariableDeclaration = function (node) { - return node.update(this.visitToken(node.varKeyword), this.visitSeparatedList(node.variableDeclarators)); - }; - - SyntaxRewriter.prototype.visitVariableDeclarator = function (node) { - return node.update(this.visitToken(node.identifier), node.typeAnnotation === null ? null : this.visitNode(node.typeAnnotation), node.equalsValueClause === null ? null : this.visitNode(node.equalsValueClause)); - }; - - SyntaxRewriter.prototype.visitEqualsValueClause = function (node) { - return node.update(this.visitToken(node.equalsToken), this.visitNodeOrToken(node.value)); - }; - - SyntaxRewriter.prototype.visitPrefixUnaryExpression = function (node) { - return node.update(node.kind(), this.visitToken(node.operatorToken), this.visitNodeOrToken(node.operand)); - }; - - SyntaxRewriter.prototype.visitArrayLiteralExpression = function (node) { - return node.update(this.visitToken(node.openBracketToken), this.visitSeparatedList(node.expressions), this.visitToken(node.closeBracketToken)); - }; - - SyntaxRewriter.prototype.visitOmittedExpression = function (node) { - return node; - }; - - SyntaxRewriter.prototype.visitParenthesizedExpression = function (node) { - return node.update(this.visitToken(node.openParenToken), this.visitNodeOrToken(node.expression), this.visitToken(node.closeParenToken)); - }; - - SyntaxRewriter.prototype.visitSimpleArrowFunctionExpression = function (node) { - return node.update(this.visitToken(node.identifier), this.visitToken(node.equalsGreaterThanToken), this.visitNodeOrToken(node.body)); - }; - - SyntaxRewriter.prototype.visitParenthesizedArrowFunctionExpression = function (node) { - return node.update(this.visitNode(node.callSignature), this.visitToken(node.equalsGreaterThanToken), this.visitNodeOrToken(node.body)); - }; - - SyntaxRewriter.prototype.visitQualifiedName = function (node) { - return node.update(this.visitNodeOrToken(node.left), this.visitToken(node.dotToken), this.visitToken(node.right)); - }; - - SyntaxRewriter.prototype.visitTypeArgumentList = function (node) { - return node.update(this.visitToken(node.lessThanToken), this.visitSeparatedList(node.typeArguments), this.visitToken(node.greaterThanToken)); - }; - - SyntaxRewriter.prototype.visitConstructorType = function (node) { - return node.update(this.visitToken(node.newKeyword), node.typeParameterList === null ? null : this.visitNode(node.typeParameterList), this.visitNode(node.parameterList), this.visitToken(node.equalsGreaterThanToken), this.visitNodeOrToken(node.type)); - }; - - SyntaxRewriter.prototype.visitFunctionType = function (node) { - return node.update(node.typeParameterList === null ? null : this.visitNode(node.typeParameterList), this.visitNode(node.parameterList), this.visitToken(node.equalsGreaterThanToken), this.visitNodeOrToken(node.type)); - }; - - SyntaxRewriter.prototype.visitObjectType = function (node) { - return node.update(this.visitToken(node.openBraceToken), this.visitSeparatedList(node.typeMembers), this.visitToken(node.closeBraceToken)); - }; - - SyntaxRewriter.prototype.visitArrayType = function (node) { - return node.update(this.visitNodeOrToken(node.type), this.visitToken(node.openBracketToken), this.visitToken(node.closeBracketToken)); - }; - - SyntaxRewriter.prototype.visitGenericType = function (node) { - return node.update(this.visitNodeOrToken(node.name), this.visitNode(node.typeArgumentList)); - }; - - SyntaxRewriter.prototype.visitTypeAnnotation = function (node) { - return node.update(this.visitToken(node.colonToken), this.visitNodeOrToken(node.type)); - }; - - SyntaxRewriter.prototype.visitBlock = function (node) { - return node.update(this.visitToken(node.openBraceToken), this.visitList(node.statements), this.visitToken(node.closeBraceToken)); - }; - - SyntaxRewriter.prototype.visitParameter = function (node) { - return node.update(node.dotDotDotToken === null ? null : this.visitToken(node.dotDotDotToken), node.publicOrPrivateKeyword === null ? null : this.visitToken(node.publicOrPrivateKeyword), this.visitToken(node.identifier), node.questionToken === null ? null : this.visitToken(node.questionToken), node.typeAnnotation === null ? null : this.visitNode(node.typeAnnotation), node.equalsValueClause === null ? null : this.visitNode(node.equalsValueClause)); - }; - - SyntaxRewriter.prototype.visitMemberAccessExpression = function (node) { - return node.update(this.visitNodeOrToken(node.expression), this.visitToken(node.dotToken), this.visitToken(node.name)); - }; - - SyntaxRewriter.prototype.visitPostfixUnaryExpression = function (node) { - return node.update(node.kind(), this.visitNodeOrToken(node.operand), this.visitToken(node.operatorToken)); - }; - - SyntaxRewriter.prototype.visitElementAccessExpression = function (node) { - return node.update(this.visitNodeOrToken(node.expression), this.visitToken(node.openBracketToken), this.visitNodeOrToken(node.argumentExpression), this.visitToken(node.closeBracketToken)); - }; - - SyntaxRewriter.prototype.visitInvocationExpression = function (node) { - return node.update(this.visitNodeOrToken(node.expression), this.visitNode(node.argumentList)); - }; - - SyntaxRewriter.prototype.visitArgumentList = function (node) { - return node.update(node.typeArgumentList === null ? null : this.visitNode(node.typeArgumentList), this.visitToken(node.openParenToken), this.visitSeparatedList(node.arguments), this.visitToken(node.closeParenToken)); - }; - - SyntaxRewriter.prototype.visitBinaryExpression = function (node) { - return node.update(node.kind(), this.visitNodeOrToken(node.left), this.visitToken(node.operatorToken), this.visitNodeOrToken(node.right)); - }; - - SyntaxRewriter.prototype.visitConditionalExpression = function (node) { - return node.update(this.visitNodeOrToken(node.condition), this.visitToken(node.questionToken), this.visitNodeOrToken(node.whenTrue), this.visitToken(node.colonToken), this.visitNodeOrToken(node.whenFalse)); - }; - - SyntaxRewriter.prototype.visitConstructSignature = function (node) { - return node.update(this.visitToken(node.newKeyword), this.visitNode(node.callSignature)); - }; - - SyntaxRewriter.prototype.visitMethodSignature = function (node) { - return node.update(this.visitToken(node.propertyName), node.questionToken === null ? null : this.visitToken(node.questionToken), this.visitNode(node.callSignature)); - }; - - SyntaxRewriter.prototype.visitIndexSignature = function (node) { - return node.update(this.visitToken(node.openBracketToken), this.visitNode(node.parameter), this.visitToken(node.closeBracketToken), node.typeAnnotation === null ? null : this.visitNode(node.typeAnnotation)); - }; - - SyntaxRewriter.prototype.visitPropertySignature = function (node) { - return node.update(this.visitToken(node.propertyName), node.questionToken === null ? null : this.visitToken(node.questionToken), node.typeAnnotation === null ? null : this.visitNode(node.typeAnnotation)); - }; - - SyntaxRewriter.prototype.visitCallSignature = function (node) { - return node.update(node.typeParameterList === null ? null : this.visitNode(node.typeParameterList), this.visitNode(node.parameterList), node.typeAnnotation === null ? null : this.visitNode(node.typeAnnotation)); - }; - - SyntaxRewriter.prototype.visitParameterList = function (node) { - return node.update(this.visitToken(node.openParenToken), this.visitSeparatedList(node.parameters), this.visitToken(node.closeParenToken)); - }; - - SyntaxRewriter.prototype.visitTypeParameterList = function (node) { - return node.update(this.visitToken(node.lessThanToken), this.visitSeparatedList(node.typeParameters), this.visitToken(node.greaterThanToken)); - }; - - SyntaxRewriter.prototype.visitTypeParameter = function (node) { - return node.update(this.visitToken(node.identifier), node.constraint === null ? null : this.visitNode(node.constraint)); - }; - - SyntaxRewriter.prototype.visitConstraint = function (node) { - return node.update(this.visitToken(node.extendsKeyword), this.visitNodeOrToken(node.type)); - }; - - SyntaxRewriter.prototype.visitElseClause = function (node) { - return node.update(this.visitToken(node.elseKeyword), this.visitNodeOrToken(node.statement)); - }; - - SyntaxRewriter.prototype.visitIfStatement = function (node) { - return node.update(this.visitToken(node.ifKeyword), this.visitToken(node.openParenToken), this.visitNodeOrToken(node.condition), this.visitToken(node.closeParenToken), this.visitNodeOrToken(node.statement), node.elseClause === null ? null : this.visitNode(node.elseClause)); - }; - - SyntaxRewriter.prototype.visitExpressionStatement = function (node) { - return node.update(this.visitNodeOrToken(node.expression), this.visitToken(node.semicolonToken)); - }; - - SyntaxRewriter.prototype.visitConstructorDeclaration = function (node) { - return node.update(this.visitToken(node.constructorKeyword), this.visitNode(node.parameterList), node.block === null ? null : this.visitNode(node.block), node.semicolonToken === null ? null : this.visitToken(node.semicolonToken)); - }; - - SyntaxRewriter.prototype.visitMemberFunctionDeclaration = function (node) { - return node.update(this.visitList(node.modifiers), this.visitToken(node.propertyName), this.visitNode(node.callSignature), node.block === null ? null : this.visitNode(node.block), node.semicolonToken === null ? null : this.visitToken(node.semicolonToken)); - }; - - SyntaxRewriter.prototype.visitGetMemberAccessorDeclaration = function (node) { - return node.update(this.visitList(node.modifiers), this.visitToken(node.getKeyword), this.visitToken(node.propertyName), this.visitNode(node.parameterList), node.typeAnnotation === null ? null : this.visitNode(node.typeAnnotation), this.visitNode(node.block)); - }; - - SyntaxRewriter.prototype.visitSetMemberAccessorDeclaration = function (node) { - return node.update(this.visitList(node.modifiers), this.visitToken(node.setKeyword), this.visitToken(node.propertyName), this.visitNode(node.parameterList), this.visitNode(node.block)); - }; - - SyntaxRewriter.prototype.visitMemberVariableDeclaration = function (node) { - return node.update(this.visitList(node.modifiers), this.visitNode(node.variableDeclarator), this.visitToken(node.semicolonToken)); - }; - - SyntaxRewriter.prototype.visitThrowStatement = function (node) { - return node.update(this.visitToken(node.throwKeyword), this.visitNodeOrToken(node.expression), this.visitToken(node.semicolonToken)); - }; - - SyntaxRewriter.prototype.visitReturnStatement = function (node) { - return node.update(this.visitToken(node.returnKeyword), node.expression === null ? null : this.visitNodeOrToken(node.expression), this.visitToken(node.semicolonToken)); - }; - - SyntaxRewriter.prototype.visitObjectCreationExpression = function (node) { - return node.update(this.visitToken(node.newKeyword), this.visitNodeOrToken(node.expression), node.argumentList === null ? null : this.visitNode(node.argumentList)); - }; - - SyntaxRewriter.prototype.visitSwitchStatement = function (node) { - return node.update(this.visitToken(node.switchKeyword), this.visitToken(node.openParenToken), this.visitNodeOrToken(node.expression), this.visitToken(node.closeParenToken), this.visitToken(node.openBraceToken), this.visitList(node.switchClauses), this.visitToken(node.closeBraceToken)); - }; - - SyntaxRewriter.prototype.visitCaseSwitchClause = function (node) { - return node.update(this.visitToken(node.caseKeyword), this.visitNodeOrToken(node.expression), this.visitToken(node.colonToken), this.visitList(node.statements)); - }; - - SyntaxRewriter.prototype.visitDefaultSwitchClause = function (node) { - return node.update(this.visitToken(node.defaultKeyword), this.visitToken(node.colonToken), this.visitList(node.statements)); - }; - - SyntaxRewriter.prototype.visitBreakStatement = function (node) { - return node.update(this.visitToken(node.breakKeyword), node.identifier === null ? null : this.visitToken(node.identifier), this.visitToken(node.semicolonToken)); - }; - - SyntaxRewriter.prototype.visitContinueStatement = function (node) { - return node.update(this.visitToken(node.continueKeyword), node.identifier === null ? null : this.visitToken(node.identifier), this.visitToken(node.semicolonToken)); - }; - - SyntaxRewriter.prototype.visitForStatement = function (node) { - return node.update(this.visitToken(node.forKeyword), this.visitToken(node.openParenToken), node.variableDeclaration === null ? null : this.visitNode(node.variableDeclaration), node.initializer === null ? null : this.visitNodeOrToken(node.initializer), this.visitToken(node.firstSemicolonToken), node.condition === null ? null : this.visitNodeOrToken(node.condition), this.visitToken(node.secondSemicolonToken), node.incrementor === null ? null : this.visitNodeOrToken(node.incrementor), this.visitToken(node.closeParenToken), this.visitNodeOrToken(node.statement)); - }; - - SyntaxRewriter.prototype.visitForInStatement = function (node) { - return node.update(this.visitToken(node.forKeyword), this.visitToken(node.openParenToken), node.variableDeclaration === null ? null : this.visitNode(node.variableDeclaration), node.left === null ? null : this.visitNodeOrToken(node.left), this.visitToken(node.inKeyword), this.visitNodeOrToken(node.expression), this.visitToken(node.closeParenToken), this.visitNodeOrToken(node.statement)); - }; - - SyntaxRewriter.prototype.visitWhileStatement = function (node) { - return node.update(this.visitToken(node.whileKeyword), this.visitToken(node.openParenToken), this.visitNodeOrToken(node.condition), this.visitToken(node.closeParenToken), this.visitNodeOrToken(node.statement)); - }; - - SyntaxRewriter.prototype.visitWithStatement = function (node) { - return node.update(this.visitToken(node.withKeyword), this.visitToken(node.openParenToken), this.visitNodeOrToken(node.condition), this.visitToken(node.closeParenToken), this.visitNodeOrToken(node.statement)); - }; - - SyntaxRewriter.prototype.visitEnumDeclaration = function (node) { - return node.update(this.visitList(node.modifiers), this.visitToken(node.enumKeyword), this.visitToken(node.identifier), this.visitToken(node.openBraceToken), this.visitSeparatedList(node.enumElements), this.visitToken(node.closeBraceToken)); - }; - - SyntaxRewriter.prototype.visitEnumElement = function (node) { - return node.update(this.visitToken(node.propertyName), node.equalsValueClause === null ? null : this.visitNode(node.equalsValueClause)); - }; - - SyntaxRewriter.prototype.visitCastExpression = function (node) { - return node.update(this.visitToken(node.lessThanToken), this.visitNodeOrToken(node.type), this.visitToken(node.greaterThanToken), this.visitNodeOrToken(node.expression)); - }; - - SyntaxRewriter.prototype.visitObjectLiteralExpression = function (node) { - return node.update(this.visitToken(node.openBraceToken), this.visitSeparatedList(node.propertyAssignments), this.visitToken(node.closeBraceToken)); - }; - - SyntaxRewriter.prototype.visitSimplePropertyAssignment = function (node) { - return node.update(this.visitToken(node.propertyName), this.visitToken(node.colonToken), this.visitNodeOrToken(node.expression)); - }; - - SyntaxRewriter.prototype.visitFunctionPropertyAssignment = function (node) { - return node.update(this.visitToken(node.propertyName), this.visitNode(node.callSignature), this.visitNode(node.block)); - }; - - SyntaxRewriter.prototype.visitGetAccessorPropertyAssignment = function (node) { - return node.update(this.visitToken(node.getKeyword), this.visitToken(node.propertyName), this.visitToken(node.openParenToken), this.visitToken(node.closeParenToken), node.typeAnnotation === null ? null : this.visitNode(node.typeAnnotation), this.visitNode(node.block)); - }; - - SyntaxRewriter.prototype.visitSetAccessorPropertyAssignment = function (node) { - return node.update(this.visitToken(node.setKeyword), this.visitToken(node.propertyName), this.visitToken(node.openParenToken), this.visitNode(node.parameter), this.visitToken(node.closeParenToken), this.visitNode(node.block)); - }; - - SyntaxRewriter.prototype.visitFunctionExpression = function (node) { - return node.update(this.visitToken(node.functionKeyword), node.identifier === null ? null : this.visitToken(node.identifier), this.visitNode(node.callSignature), this.visitNode(node.block)); - }; - - SyntaxRewriter.prototype.visitEmptyStatement = function (node) { - return node.update(this.visitToken(node.semicolonToken)); - }; - - SyntaxRewriter.prototype.visitTryStatement = function (node) { - return node.update(this.visitToken(node.tryKeyword), this.visitNode(node.block), node.catchClause === null ? null : this.visitNode(node.catchClause), node.finallyClause === null ? null : this.visitNode(node.finallyClause)); - }; - - SyntaxRewriter.prototype.visitCatchClause = function (node) { - return node.update(this.visitToken(node.catchKeyword), this.visitToken(node.openParenToken), this.visitToken(node.identifier), node.typeAnnotation === null ? null : this.visitNode(node.typeAnnotation), this.visitToken(node.closeParenToken), this.visitNode(node.block)); - }; - - SyntaxRewriter.prototype.visitFinallyClause = function (node) { - return node.update(this.visitToken(node.finallyKeyword), this.visitNode(node.block)); - }; - - SyntaxRewriter.prototype.visitLabeledStatement = function (node) { - return node.update(this.visitToken(node.identifier), this.visitToken(node.colonToken), this.visitNodeOrToken(node.statement)); - }; - - SyntaxRewriter.prototype.visitDoStatement = function (node) { - return node.update(this.visitToken(node.doKeyword), this.visitNodeOrToken(node.statement), this.visitToken(node.whileKeyword), this.visitToken(node.openParenToken), this.visitNodeOrToken(node.condition), this.visitToken(node.closeParenToken), this.visitToken(node.semicolonToken)); - }; - - SyntaxRewriter.prototype.visitTypeOfExpression = function (node) { - return node.update(this.visitToken(node.typeOfKeyword), this.visitNodeOrToken(node.expression)); - }; - - SyntaxRewriter.prototype.visitDeleteExpression = function (node) { - return node.update(this.visitToken(node.deleteKeyword), this.visitNodeOrToken(node.expression)); - }; - - SyntaxRewriter.prototype.visitVoidExpression = function (node) { - return node.update(this.visitToken(node.voidKeyword), this.visitNodeOrToken(node.expression)); - }; - - SyntaxRewriter.prototype.visitDebuggerStatement = function (node) { - return node.update(this.visitToken(node.debuggerKeyword), this.visitToken(node.semicolonToken)); - }; - return SyntaxRewriter; - })(); - TypeScript.SyntaxRewriter = SyntaxRewriter; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var SyntaxDedenter = (function (_super) { - __extends(SyntaxDedenter, _super); - function SyntaxDedenter(dedentFirstToken, dedentationAmount, minimumIndent, options) { - _super.call(this); - this.dedentationAmount = dedentationAmount; - this.minimumIndent = minimumIndent; - this.options = options; - this.lastTriviaWasNewLine = dedentFirstToken; - } - SyntaxDedenter.prototype.abort = function () { - this.lastTriviaWasNewLine = false; - this.dedentationAmount = 0; - }; - - SyntaxDedenter.prototype.isAborted = function () { - return this.dedentationAmount === 0; - }; - - SyntaxDedenter.prototype.visitToken = function (token) { - if (token.width() === 0) { - return token; - } - - var result = token; - if (this.lastTriviaWasNewLine) { - result = token.withLeadingTrivia(this.dedentTriviaList(token.leadingTrivia())); - } - - if (this.isAborted()) { - return token; - } - - this.lastTriviaWasNewLine = token.hasTrailingNewLine(); - return result; - }; - - SyntaxDedenter.prototype.dedentTriviaList = function (triviaList) { - var result = []; - var dedentNextWhitespace = true; - - 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() === 4 /* WhitespaceTrivia */) { - var hasFollowingNewLine = (i < triviaList.count() - 1) && triviaList.syntaxTriviaAt(i + 1).kind() === 5 /* NewLineTrivia */; - result.push(this.dedentWhitespace(trivia, hasFollowingNewLine)); - continue; - } else if (trivia.kind() !== 5 /* NewLineTrivia */) { - this.abort(); - break; - } - } - - if (trivia.kind() === 6 /* MultiLineCommentTrivia */) { - result.push(this.dedentMultiLineComment(trivia)); - continue; - } - - result.push(trivia); - if (trivia.kind() === 5 /* NewLineTrivia */) { - dedentNextWhitespace = true; - } - } - - if (dedentNextWhitespace) { - this.abort(); - } - - if (this.isAborted()) { - return triviaList; - } - - return TypeScript.Syntax.triviaList(result); - }; - - SyntaxDedenter.prototype.dedentSegment = function (segment, hasFollowingNewLineTrivia) { - var firstNonWhitespacePosition = TypeScript.Indentation.firstNonWhitespacePosition(segment); - - if (firstNonWhitespacePosition === segment.length) { - if (hasFollowingNewLineTrivia) { - return ""; - } - } else if (TypeScript.CharacterInfo.isLineTerminator(segment.charCodeAt(firstNonWhitespacePosition))) { - return segment.substring(firstNonWhitespacePosition); - } - - var firstNonWhitespaceColumn = TypeScript.Indentation.columnForPositionInString(segment, firstNonWhitespacePosition, this.options); - - var newFirstNonWhitespaceColumn = TypeScript.MathPrototype.min(firstNonWhitespaceColumn, TypeScript.MathPrototype.max(firstNonWhitespaceColumn - this.dedentationAmount, this.minimumIndent)); - - if (newFirstNonWhitespaceColumn === firstNonWhitespaceColumn) { - this.abort(); - return segment; - } - - this.dedentationAmount = firstNonWhitespaceColumn - newFirstNonWhitespaceColumn; - TypeScript.Debug.assert(this.dedentationAmount >= 0); - - var indentationString = TypeScript.Indentation.indentationString(newFirstNonWhitespaceColumn, this.options); - - return indentationString + segment.substring(firstNonWhitespacePosition); - }; - - SyntaxDedenter.prototype.dedentWhitespace = function (trivia, hasFollowingNewLineTrivia) { - var newIndentation = this.dedentSegment(trivia.fullText(), hasFollowingNewLineTrivia); - return TypeScript.Syntax.whitespace(newIndentation); - }; - - SyntaxDedenter.prototype.dedentMultiLineComment = function (trivia) { - var segments = TypeScript.Syntax.splitMultiLineCommentTriviaIntoMultipleLines(trivia); - if (segments.length === 1) { - return trivia; - } - - for (var i = 1; i < segments.length; i++) { - var segment = segments[i]; - segments[i] = this.dedentSegment(segment, false); - } - - var result = segments.join(""); - - return TypeScript.Syntax.multiLineComment(result); - }; - - SyntaxDedenter.dedentNode = function (node, dedentFirstToken, dedentAmount, minimumIndent, options) { - var dedenter = new SyntaxDedenter(dedentFirstToken, dedentAmount, minimumIndent, options); - var result = node.accept(dedenter); - - if (dedenter.isAborted()) { - return node; - } - - return result; - }; - return SyntaxDedenter; - })(TypeScript.SyntaxRewriter); - TypeScript.SyntaxDedenter = SyntaxDedenter; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var SyntaxIndenter = (function (_super) { - __extends(SyntaxIndenter, _super); - function SyntaxIndenter(indentFirstToken, indentationAmount, options) { - _super.call(this); - this.indentationAmount = indentationAmount; - this.options = options; - this.lastTriviaWasNewLine = indentFirstToken; - this.indentationTrivia = TypeScript.Indentation.indentationTrivia(this.indentationAmount, this.options); - } - SyntaxIndenter.prototype.visitToken = function (token) { - if (token.width() === 0) { - return token; - } - - var result = token; - if (this.lastTriviaWasNewLine) { - result = token.withLeadingTrivia(this.indentTriviaList(token.leadingTrivia())); - } - - this.lastTriviaWasNewLine = token.hasTrailingNewLine(); - return result; - }; - - SyntaxIndenter.prototype.indentTriviaList = function (triviaList) { - var result = []; - - 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 6 /* MultiLineCommentTrivia */: - this.indentMultiLineComment(trivia, indentThisTrivia, result); - continue; - - case 7 /* SingleLineCommentTrivia */: - case 8 /* SkippedTokenTrivia */: - this.indentSingleLineOrSkippedText(trivia, indentThisTrivia, result); - continue; - - case 4 /* WhitespaceTrivia */: - this.indentWhitespace(trivia, indentThisTrivia, result); - continue; - - case 5 /* NewLineTrivia */: - result.push(trivia); - indentNextTrivia = true; - continue; - - default: - throw TypeScript.Errors.invalidOperation(); - } - } - - if (indentNextTrivia) { - result.push(this.indentationTrivia); - } - - return TypeScript.Syntax.triviaList(result); - }; - - SyntaxIndenter.prototype.indentSegment = function (segment) { - var firstNonWhitespacePosition = TypeScript.Indentation.firstNonWhitespacePosition(segment); - - if (firstNonWhitespacePosition < segment.length && TypeScript.CharacterInfo.isLineTerminator(segment.charCodeAt(firstNonWhitespacePosition))) { - return segment; - } - - var firstNonWhitespaceColumn = TypeScript.Indentation.columnForPositionInString(segment, firstNonWhitespacePosition, this.options); - - var newFirstNonWhitespaceColumn = firstNonWhitespaceColumn + this.indentationAmount; - - var indentationString = TypeScript.Indentation.indentationString(newFirstNonWhitespaceColumn, this.options); - - return indentationString + segment.substring(firstNonWhitespacePosition); - }; - - SyntaxIndenter.prototype.indentWhitespace = function (trivia, indentThisTrivia, result) { - if (!indentThisTrivia) { - result.push(trivia); - return; - } - - var newIndentation = this.indentSegment(trivia.fullText()); - result.push(TypeScript.Syntax.whitespace(newIndentation)); - }; - - SyntaxIndenter.prototype.indentSingleLineOrSkippedText = function (trivia, indentThisTrivia, result) { - if (indentThisTrivia) { - result.push(this.indentationTrivia); - } - - result.push(trivia); - }; - - SyntaxIndenter.prototype.indentMultiLineComment = function (trivia, indentThisTrivia, result) { - if (indentThisTrivia) { - result.push(this.indentationTrivia); - } - - var segments = TypeScript.Syntax.splitMultiLineCommentTriviaIntoMultipleLines(trivia); - - for (var i = 1; i < segments.length; i++) { - segments[i] = this.indentSegment(segments[i]); - } - - var newText = segments.join(""); - result.push(TypeScript.Syntax.multiLineComment(newText)); - }; - - SyntaxIndenter.indentNode = function (node, indentFirstToken, indentAmount, options) { - var indenter = new SyntaxIndenter(indentFirstToken, indentAmount, options); - return node.accept(indenter); - }; - - SyntaxIndenter.indentNodes = function (nodes, indentFirstToken, indentAmount, options) { - var indenter = new SyntaxIndenter(indentFirstToken, indentAmount, options); - var result = TypeScript.ArrayUtilities.select(nodes, function (n) { - return n.accept(indenter); - }); - - return result; - }; - return SyntaxIndenter; - })(TypeScript.SyntaxRewriter); - TypeScript.SyntaxIndenter = SyntaxIndenter; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (Syntax) { - var VariableWidthTokenWithNoTrivia = (function () { - function VariableWidthTokenWithNoTrivia(sourceText, fullStart, kind, textOrWidth) { - this._sourceText = sourceText; - this._fullStart = fullStart; - this.tokenKind = kind; - this._textOrWidth = textOrWidth; - } - VariableWidthTokenWithNoTrivia.prototype.clone = function () { - return new VariableWidthTokenWithNoTrivia(this._sourceText, this._fullStart, this.tokenKind, this._textOrWidth); - }; - - VariableWidthTokenWithNoTrivia.prototype.isNode = function () { - return false; - }; - VariableWidthTokenWithNoTrivia.prototype.isToken = function () { - return true; - }; - VariableWidthTokenWithNoTrivia.prototype.isList = function () { - return false; - }; - VariableWidthTokenWithNoTrivia.prototype.isSeparatedList = function () { - return false; - }; - - VariableWidthTokenWithNoTrivia.prototype.kind = function () { - return this.tokenKind; - }; - - VariableWidthTokenWithNoTrivia.prototype.childCount = function () { - return 0; - }; - VariableWidthTokenWithNoTrivia.prototype.childAt = function (index) { - throw TypeScript.Errors.argumentOutOfRange('index'); - }; - - VariableWidthTokenWithNoTrivia.prototype.fullWidth = function () { - return this.width(); - }; - VariableWidthTokenWithNoTrivia.prototype.start = function () { - return this._fullStart; - }; - VariableWidthTokenWithNoTrivia.prototype.end = function () { - return this.start() + this.width(); - }; - - VariableWidthTokenWithNoTrivia.prototype.width = function () { - return typeof this._textOrWidth === 'number' ? this._textOrWidth : this._textOrWidth.length; - }; - - VariableWidthTokenWithNoTrivia.prototype.text = function () { - if (typeof this._textOrWidth === 'number') { - this._textOrWidth = this._sourceText.substr(this.start(), this._textOrWidth, this.tokenKind === 11 /* IdentifierName */); - } - - return this._textOrWidth; - }; - - VariableWidthTokenWithNoTrivia.prototype.fullText = function () { - return this._sourceText.substr(this._fullStart, this.fullWidth(), false); - }; - - VariableWidthTokenWithNoTrivia.prototype.value = function () { - if ((this)._value === undefined) { - (this)._value = Syntax.value(this); - } - - return (this)._value; - }; - - VariableWidthTokenWithNoTrivia.prototype.valueText = function () { - if ((this)._valueText === undefined) { - (this)._valueText = Syntax.valueText(this); - } - - return (this)._valueText; - }; - - VariableWidthTokenWithNoTrivia.prototype.hasLeadingTrivia = function () { - return false; - }; - VariableWidthTokenWithNoTrivia.prototype.hasLeadingComment = function () { - return false; - }; - VariableWidthTokenWithNoTrivia.prototype.hasLeadingNewLine = function () { - return false; - }; - VariableWidthTokenWithNoTrivia.prototype.hasLeadingSkippedText = function () { - return false; - }; - VariableWidthTokenWithNoTrivia.prototype.leadingTriviaWidth = function () { - return 0; - }; - VariableWidthTokenWithNoTrivia.prototype.leadingTrivia = function () { - return TypeScript.Syntax.emptyTriviaList; - }; - - VariableWidthTokenWithNoTrivia.prototype.hasTrailingTrivia = function () { - return false; - }; - VariableWidthTokenWithNoTrivia.prototype.hasTrailingComment = function () { - return false; - }; - VariableWidthTokenWithNoTrivia.prototype.hasTrailingNewLine = function () { - return false; - }; - VariableWidthTokenWithNoTrivia.prototype.hasTrailingSkippedText = function () { - return false; - }; - VariableWidthTokenWithNoTrivia.prototype.trailingTriviaWidth = function () { - return 0; - }; - VariableWidthTokenWithNoTrivia.prototype.trailingTrivia = function () { - return TypeScript.Syntax.emptyTriviaList; - }; - - VariableWidthTokenWithNoTrivia.prototype.hasSkippedToken = function () { - return false; - }; - VariableWidthTokenWithNoTrivia.prototype.toJSON = function (key) { - return Syntax.tokenToJSON(this); - }; - VariableWidthTokenWithNoTrivia.prototype.firstToken = function () { - return this; - }; - VariableWidthTokenWithNoTrivia.prototype.lastToken = function () { - return this; - }; - VariableWidthTokenWithNoTrivia.prototype.isTypeScriptSpecific = function () { - return false; - }; - VariableWidthTokenWithNoTrivia.prototype.isIncrementallyUnusable = function () { - return this.fullWidth() === 0 || TypeScript.SyntaxFacts.isAnyDivideOrRegularExpressionToken(this.tokenKind); - }; - VariableWidthTokenWithNoTrivia.prototype.accept = function (visitor) { - return visitor.visitToken(this); - }; - VariableWidthTokenWithNoTrivia.prototype.realize = function () { - return Syntax.realizeToken(this); - }; - VariableWidthTokenWithNoTrivia.prototype.collectTextElements = function (elements) { - collectTokenTextElements(this, elements); - }; - - VariableWidthTokenWithNoTrivia.prototype.findTokenInternal = function (parent, position, fullStart) { - return new TypeScript.PositionedToken(parent, this, fullStart); - }; - - VariableWidthTokenWithNoTrivia.prototype.withLeadingTrivia = function (leadingTrivia) { - return this.realize().withLeadingTrivia(leadingTrivia); - }; - - VariableWidthTokenWithNoTrivia.prototype.withTrailingTrivia = function (trailingTrivia) { - return this.realize().withTrailingTrivia(trailingTrivia); - }; - return VariableWidthTokenWithNoTrivia; - })(); - Syntax.VariableWidthTokenWithNoTrivia = VariableWidthTokenWithNoTrivia; - - var VariableWidthTokenWithLeadingTrivia = (function () { - function VariableWidthTokenWithLeadingTrivia(sourceText, fullStart, kind, leadingTriviaInfo, textOrWidth) { - this._sourceText = sourceText; - this._fullStart = fullStart; - this.tokenKind = kind; - this._leadingTriviaInfo = leadingTriviaInfo; - this._textOrWidth = textOrWidth; - } - VariableWidthTokenWithLeadingTrivia.prototype.clone = function () { - return new VariableWidthTokenWithLeadingTrivia(this._sourceText, this._fullStart, this.tokenKind, this._leadingTriviaInfo, this._textOrWidth); - }; - - VariableWidthTokenWithLeadingTrivia.prototype.isNode = function () { - return false; - }; - VariableWidthTokenWithLeadingTrivia.prototype.isToken = function () { - return true; - }; - VariableWidthTokenWithLeadingTrivia.prototype.isList = function () { - return false; - }; - VariableWidthTokenWithLeadingTrivia.prototype.isSeparatedList = function () { - return false; - }; - - VariableWidthTokenWithLeadingTrivia.prototype.kind = function () { - return this.tokenKind; - }; - - VariableWidthTokenWithLeadingTrivia.prototype.childCount = function () { - return 0; - }; - VariableWidthTokenWithLeadingTrivia.prototype.childAt = function (index) { - throw TypeScript.Errors.argumentOutOfRange('index'); - }; - - VariableWidthTokenWithLeadingTrivia.prototype.fullWidth = function () { - return getTriviaWidth(this._leadingTriviaInfo) + this.width(); - }; - VariableWidthTokenWithLeadingTrivia.prototype.start = function () { - return this._fullStart + getTriviaWidth(this._leadingTriviaInfo); - }; - VariableWidthTokenWithLeadingTrivia.prototype.end = function () { - return this.start() + this.width(); - }; - - VariableWidthTokenWithLeadingTrivia.prototype.width = function () { - return typeof this._textOrWidth === 'number' ? this._textOrWidth : this._textOrWidth.length; - }; - - VariableWidthTokenWithLeadingTrivia.prototype.text = function () { - if (typeof this._textOrWidth === 'number') { - this._textOrWidth = this._sourceText.substr(this.start(), this._textOrWidth, this.tokenKind === 11 /* IdentifierName */); - } - - return this._textOrWidth; - }; - - VariableWidthTokenWithLeadingTrivia.prototype.fullText = function () { - return this._sourceText.substr(this._fullStart, this.fullWidth(), false); - }; - - VariableWidthTokenWithLeadingTrivia.prototype.value = function () { - if ((this)._value === undefined) { - (this)._value = Syntax.value(this); - } - - return (this)._value; - }; - - VariableWidthTokenWithLeadingTrivia.prototype.valueText = function () { - if ((this)._valueText === undefined) { - (this)._valueText = Syntax.valueText(this); - } - - return (this)._valueText; - }; - - VariableWidthTokenWithLeadingTrivia.prototype.hasLeadingTrivia = function () { - return true; - }; - VariableWidthTokenWithLeadingTrivia.prototype.hasLeadingComment = function () { - return hasTriviaComment(this._leadingTriviaInfo); - }; - VariableWidthTokenWithLeadingTrivia.prototype.hasLeadingNewLine = function () { - return hasTriviaNewLine(this._leadingTriviaInfo); - }; - VariableWidthTokenWithLeadingTrivia.prototype.hasLeadingSkippedText = function () { - return false; - }; - VariableWidthTokenWithLeadingTrivia.prototype.leadingTriviaWidth = function () { - return getTriviaWidth(this._leadingTriviaInfo); - }; - VariableWidthTokenWithLeadingTrivia.prototype.leadingTrivia = function () { - return TypeScript.Scanner.scanTrivia(this._sourceText, this._fullStart, getTriviaWidth(this._leadingTriviaInfo), false); - }; - - VariableWidthTokenWithLeadingTrivia.prototype.hasTrailingTrivia = function () { - return false; - }; - VariableWidthTokenWithLeadingTrivia.prototype.hasTrailingComment = function () { - return false; - }; - VariableWidthTokenWithLeadingTrivia.prototype.hasTrailingNewLine = function () { - return false; - }; - VariableWidthTokenWithLeadingTrivia.prototype.hasTrailingSkippedText = function () { - return false; - }; - VariableWidthTokenWithLeadingTrivia.prototype.trailingTriviaWidth = function () { - return 0; - }; - VariableWidthTokenWithLeadingTrivia.prototype.trailingTrivia = function () { - return TypeScript.Syntax.emptyTriviaList; - }; - - VariableWidthTokenWithLeadingTrivia.prototype.hasSkippedToken = function () { - return false; - }; - VariableWidthTokenWithLeadingTrivia.prototype.toJSON = function (key) { - return Syntax.tokenToJSON(this); - }; - VariableWidthTokenWithLeadingTrivia.prototype.firstToken = function () { - return this; - }; - VariableWidthTokenWithLeadingTrivia.prototype.lastToken = function () { - return this; - }; - VariableWidthTokenWithLeadingTrivia.prototype.isTypeScriptSpecific = function () { - return false; - }; - VariableWidthTokenWithLeadingTrivia.prototype.isIncrementallyUnusable = function () { - return this.fullWidth() === 0 || TypeScript.SyntaxFacts.isAnyDivideOrRegularExpressionToken(this.tokenKind); - }; - VariableWidthTokenWithLeadingTrivia.prototype.accept = function (visitor) { - return visitor.visitToken(this); - }; - VariableWidthTokenWithLeadingTrivia.prototype.realize = function () { - return Syntax.realizeToken(this); - }; - VariableWidthTokenWithLeadingTrivia.prototype.collectTextElements = function (elements) { - collectTokenTextElements(this, elements); - }; - - VariableWidthTokenWithLeadingTrivia.prototype.findTokenInternal = function (parent, position, fullStart) { - return new TypeScript.PositionedToken(parent, this, fullStart); - }; - - VariableWidthTokenWithLeadingTrivia.prototype.withLeadingTrivia = function (leadingTrivia) { - return this.realize().withLeadingTrivia(leadingTrivia); - }; - - VariableWidthTokenWithLeadingTrivia.prototype.withTrailingTrivia = function (trailingTrivia) { - return this.realize().withTrailingTrivia(trailingTrivia); - }; - return VariableWidthTokenWithLeadingTrivia; - })(); - Syntax.VariableWidthTokenWithLeadingTrivia = VariableWidthTokenWithLeadingTrivia; - - var VariableWidthTokenWithTrailingTrivia = (function () { - function VariableWidthTokenWithTrailingTrivia(sourceText, fullStart, kind, textOrWidth, trailingTriviaInfo) { - this._sourceText = sourceText; - this._fullStart = fullStart; - this.tokenKind = kind; - this._textOrWidth = textOrWidth; - this._trailingTriviaInfo = trailingTriviaInfo; - } - VariableWidthTokenWithTrailingTrivia.prototype.clone = function () { - return new VariableWidthTokenWithTrailingTrivia(this._sourceText, this._fullStart, this.tokenKind, this._textOrWidth, this._trailingTriviaInfo); - }; - - VariableWidthTokenWithTrailingTrivia.prototype.isNode = function () { - return false; - }; - VariableWidthTokenWithTrailingTrivia.prototype.isToken = function () { - return true; - }; - VariableWidthTokenWithTrailingTrivia.prototype.isList = function () { - return false; - }; - VariableWidthTokenWithTrailingTrivia.prototype.isSeparatedList = function () { - return false; - }; - - VariableWidthTokenWithTrailingTrivia.prototype.kind = function () { - return this.tokenKind; - }; - - VariableWidthTokenWithTrailingTrivia.prototype.childCount = function () { - return 0; - }; - VariableWidthTokenWithTrailingTrivia.prototype.childAt = function (index) { - throw TypeScript.Errors.argumentOutOfRange('index'); - }; - - VariableWidthTokenWithTrailingTrivia.prototype.fullWidth = function () { - return this.width() + getTriviaWidth(this._trailingTriviaInfo); - }; - VariableWidthTokenWithTrailingTrivia.prototype.start = function () { - return this._fullStart; - }; - VariableWidthTokenWithTrailingTrivia.prototype.end = function () { - return this.start() + this.width(); - }; - - VariableWidthTokenWithTrailingTrivia.prototype.width = function () { - return typeof this._textOrWidth === 'number' ? this._textOrWidth : this._textOrWidth.length; - }; - - VariableWidthTokenWithTrailingTrivia.prototype.text = function () { - if (typeof this._textOrWidth === 'number') { - this._textOrWidth = this._sourceText.substr(this.start(), this._textOrWidth, this.tokenKind === 11 /* IdentifierName */); - } - - return this._textOrWidth; - }; - - VariableWidthTokenWithTrailingTrivia.prototype.fullText = function () { - return this._sourceText.substr(this._fullStart, this.fullWidth(), false); - }; - - VariableWidthTokenWithTrailingTrivia.prototype.value = function () { - if ((this)._value === undefined) { - (this)._value = Syntax.value(this); - } - - return (this)._value; - }; - - VariableWidthTokenWithTrailingTrivia.prototype.valueText = function () { - if ((this)._valueText === undefined) { - (this)._valueText = Syntax.valueText(this); - } - - return (this)._valueText; - }; - - VariableWidthTokenWithTrailingTrivia.prototype.hasLeadingTrivia = function () { - return false; - }; - VariableWidthTokenWithTrailingTrivia.prototype.hasLeadingComment = function () { - return false; - }; - VariableWidthTokenWithTrailingTrivia.prototype.hasLeadingNewLine = function () { - return false; - }; - VariableWidthTokenWithTrailingTrivia.prototype.hasLeadingSkippedText = function () { - return false; - }; - VariableWidthTokenWithTrailingTrivia.prototype.leadingTriviaWidth = function () { - return 0; - }; - VariableWidthTokenWithTrailingTrivia.prototype.leadingTrivia = function () { - return TypeScript.Syntax.emptyTriviaList; - }; - - VariableWidthTokenWithTrailingTrivia.prototype.hasTrailingTrivia = function () { - return true; - }; - VariableWidthTokenWithTrailingTrivia.prototype.hasTrailingComment = function () { - return hasTriviaComment(this._trailingTriviaInfo); - }; - VariableWidthTokenWithTrailingTrivia.prototype.hasTrailingNewLine = function () { - return hasTriviaNewLine(this._trailingTriviaInfo); - }; - VariableWidthTokenWithTrailingTrivia.prototype.hasTrailingSkippedText = function () { - return false; - }; - VariableWidthTokenWithTrailingTrivia.prototype.trailingTriviaWidth = function () { - return getTriviaWidth(this._trailingTriviaInfo); - }; - VariableWidthTokenWithTrailingTrivia.prototype.trailingTrivia = function () { - return TypeScript.Scanner.scanTrivia(this._sourceText, this.end(), getTriviaWidth(this._trailingTriviaInfo), true); - }; - - VariableWidthTokenWithTrailingTrivia.prototype.hasSkippedToken = function () { - return false; - }; - VariableWidthTokenWithTrailingTrivia.prototype.toJSON = function (key) { - return Syntax.tokenToJSON(this); - }; - VariableWidthTokenWithTrailingTrivia.prototype.firstToken = function () { - return this; - }; - VariableWidthTokenWithTrailingTrivia.prototype.lastToken = function () { - return this; - }; - VariableWidthTokenWithTrailingTrivia.prototype.isTypeScriptSpecific = function () { - return false; - }; - VariableWidthTokenWithTrailingTrivia.prototype.isIncrementallyUnusable = function () { - return this.fullWidth() === 0 || TypeScript.SyntaxFacts.isAnyDivideOrRegularExpressionToken(this.tokenKind); - }; - VariableWidthTokenWithTrailingTrivia.prototype.accept = function (visitor) { - return visitor.visitToken(this); - }; - VariableWidthTokenWithTrailingTrivia.prototype.realize = function () { - return Syntax.realizeToken(this); - }; - VariableWidthTokenWithTrailingTrivia.prototype.collectTextElements = function (elements) { - collectTokenTextElements(this, elements); - }; - - VariableWidthTokenWithTrailingTrivia.prototype.findTokenInternal = function (parent, position, fullStart) { - return new TypeScript.PositionedToken(parent, this, fullStart); - }; - - VariableWidthTokenWithTrailingTrivia.prototype.withLeadingTrivia = function (leadingTrivia) { - return this.realize().withLeadingTrivia(leadingTrivia); - }; - - VariableWidthTokenWithTrailingTrivia.prototype.withTrailingTrivia = function (trailingTrivia) { - return this.realize().withTrailingTrivia(trailingTrivia); - }; - return VariableWidthTokenWithTrailingTrivia; - })(); - Syntax.VariableWidthTokenWithTrailingTrivia = VariableWidthTokenWithTrailingTrivia; - - var VariableWidthTokenWithLeadingAndTrailingTrivia = (function () { - function VariableWidthTokenWithLeadingAndTrailingTrivia(sourceText, fullStart, kind, leadingTriviaInfo, textOrWidth, trailingTriviaInfo) { - this._sourceText = sourceText; - this._fullStart = fullStart; - this.tokenKind = kind; - this._leadingTriviaInfo = leadingTriviaInfo; - this._textOrWidth = textOrWidth; - this._trailingTriviaInfo = trailingTriviaInfo; - } - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.clone = function () { - return new VariableWidthTokenWithLeadingAndTrailingTrivia(this._sourceText, this._fullStart, this.tokenKind, this._leadingTriviaInfo, this._textOrWidth, this._trailingTriviaInfo); - }; - - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.isNode = function () { - return false; - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.isToken = function () { - return true; - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.isList = function () { - return false; - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.isSeparatedList = function () { - return false; - }; - - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.kind = function () { - return this.tokenKind; - }; - - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.childCount = function () { - return 0; - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.childAt = function (index) { - throw TypeScript.Errors.argumentOutOfRange('index'); - }; - - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.fullWidth = function () { - return getTriviaWidth(this._leadingTriviaInfo) + this.width() + getTriviaWidth(this._trailingTriviaInfo); - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.start = function () { - return this._fullStart + getTriviaWidth(this._leadingTriviaInfo); - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.end = function () { - return this.start() + this.width(); - }; - - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.width = function () { - return typeof this._textOrWidth === 'number' ? this._textOrWidth : this._textOrWidth.length; - }; - - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.text = function () { - if (typeof this._textOrWidth === 'number') { - this._textOrWidth = this._sourceText.substr(this.start(), this._textOrWidth, this.tokenKind === 11 /* IdentifierName */); - } - - return this._textOrWidth; - }; - - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.fullText = function () { - return this._sourceText.substr(this._fullStart, this.fullWidth(), false); - }; - - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.value = function () { - if ((this)._value === undefined) { - (this)._value = Syntax.value(this); - } - - return (this)._value; - }; - - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.valueText = function () { - if ((this)._valueText === undefined) { - (this)._valueText = Syntax.valueText(this); - } - - return (this)._valueText; - }; - - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.hasLeadingTrivia = function () { - return true; - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.hasLeadingComment = function () { - return hasTriviaComment(this._leadingTriviaInfo); - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.hasLeadingNewLine = function () { - return hasTriviaNewLine(this._leadingTriviaInfo); - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.hasLeadingSkippedText = function () { - return false; - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.leadingTriviaWidth = function () { - return getTriviaWidth(this._leadingTriviaInfo); - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.leadingTrivia = function () { - return TypeScript.Scanner.scanTrivia(this._sourceText, this._fullStart, getTriviaWidth(this._leadingTriviaInfo), false); - }; - - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.hasTrailingTrivia = function () { - return true; - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.hasTrailingComment = function () { - return hasTriviaComment(this._trailingTriviaInfo); - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.hasTrailingNewLine = function () { - return hasTriviaNewLine(this._trailingTriviaInfo); - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.hasTrailingSkippedText = function () { - return false; - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.trailingTriviaWidth = function () { - return getTriviaWidth(this._trailingTriviaInfo); - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.trailingTrivia = function () { - return TypeScript.Scanner.scanTrivia(this._sourceText, this.end(), getTriviaWidth(this._trailingTriviaInfo), true); - }; - - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.hasSkippedToken = function () { - return false; - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.toJSON = function (key) { - return Syntax.tokenToJSON(this); - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.firstToken = function () { - return this; - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.lastToken = function () { - return this; - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.isTypeScriptSpecific = function () { - return false; - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.isIncrementallyUnusable = function () { - return this.fullWidth() === 0 || TypeScript.SyntaxFacts.isAnyDivideOrRegularExpressionToken(this.tokenKind); - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.accept = function (visitor) { - return visitor.visitToken(this); - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.realize = function () { - return Syntax.realizeToken(this); - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.collectTextElements = function (elements) { - collectTokenTextElements(this, elements); - }; - - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.findTokenInternal = function (parent, position, fullStart) { - return new TypeScript.PositionedToken(parent, this, fullStart); - }; - - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.withLeadingTrivia = function (leadingTrivia) { - return this.realize().withLeadingTrivia(leadingTrivia); - }; - - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.withTrailingTrivia = function (trailingTrivia) { - return this.realize().withTrailingTrivia(trailingTrivia); - }; - return VariableWidthTokenWithLeadingAndTrailingTrivia; - })(); - Syntax.VariableWidthTokenWithLeadingAndTrailingTrivia = VariableWidthTokenWithLeadingAndTrailingTrivia; - - var FixedWidthTokenWithNoTrivia = (function () { - function FixedWidthTokenWithNoTrivia(kind) { - this.tokenKind = kind; - } - FixedWidthTokenWithNoTrivia.prototype.clone = function () { - return new FixedWidthTokenWithNoTrivia(this.tokenKind); - }; - - FixedWidthTokenWithNoTrivia.prototype.isNode = function () { - return false; - }; - FixedWidthTokenWithNoTrivia.prototype.isToken = function () { - return true; - }; - FixedWidthTokenWithNoTrivia.prototype.isList = function () { - return false; - }; - FixedWidthTokenWithNoTrivia.prototype.isSeparatedList = function () { - return false; - }; - - FixedWidthTokenWithNoTrivia.prototype.kind = function () { - return this.tokenKind; - }; - - FixedWidthTokenWithNoTrivia.prototype.childCount = function () { - return 0; - }; - FixedWidthTokenWithNoTrivia.prototype.childAt = function (index) { - throw TypeScript.Errors.argumentOutOfRange('index'); - }; - - FixedWidthTokenWithNoTrivia.prototype.fullWidth = function () { - return this.width(); - }; - FixedWidthTokenWithNoTrivia.prototype.width = function () { - return this.text().length; - }; - FixedWidthTokenWithNoTrivia.prototype.text = function () { - return TypeScript.SyntaxFacts.getText(this.tokenKind); - }; - FixedWidthTokenWithNoTrivia.prototype.fullText = function () { - return this.text(); - }; - - FixedWidthTokenWithNoTrivia.prototype.value = function () { - return Syntax.value(this); - }; - FixedWidthTokenWithNoTrivia.prototype.valueText = function () { - return Syntax.valueText(this); - }; - FixedWidthTokenWithNoTrivia.prototype.hasLeadingTrivia = function () { - return false; - }; - FixedWidthTokenWithNoTrivia.prototype.hasLeadingComment = function () { - return false; - }; - FixedWidthTokenWithNoTrivia.prototype.hasLeadingNewLine = function () { - return false; - }; - FixedWidthTokenWithNoTrivia.prototype.hasLeadingSkippedText = function () { - return false; - }; - FixedWidthTokenWithNoTrivia.prototype.leadingTriviaWidth = function () { - return 0; - }; - FixedWidthTokenWithNoTrivia.prototype.leadingTrivia = function () { - return TypeScript.Syntax.emptyTriviaList; - }; - - FixedWidthTokenWithNoTrivia.prototype.hasTrailingTrivia = function () { - return false; - }; - FixedWidthTokenWithNoTrivia.prototype.hasTrailingComment = function () { - return false; - }; - FixedWidthTokenWithNoTrivia.prototype.hasTrailingNewLine = function () { - return false; - }; - FixedWidthTokenWithNoTrivia.prototype.hasTrailingSkippedText = function () { - return false; - }; - FixedWidthTokenWithNoTrivia.prototype.trailingTriviaWidth = function () { - return 0; - }; - FixedWidthTokenWithNoTrivia.prototype.trailingTrivia = function () { - return TypeScript.Syntax.emptyTriviaList; - }; - - FixedWidthTokenWithNoTrivia.prototype.hasSkippedToken = function () { - return false; - }; - FixedWidthTokenWithNoTrivia.prototype.toJSON = function (key) { - return Syntax.tokenToJSON(this); - }; - FixedWidthTokenWithNoTrivia.prototype.firstToken = function () { - return this; - }; - FixedWidthTokenWithNoTrivia.prototype.lastToken = function () { - return this; - }; - FixedWidthTokenWithNoTrivia.prototype.isTypeScriptSpecific = function () { - return false; - }; - FixedWidthTokenWithNoTrivia.prototype.isIncrementallyUnusable = function () { - return this.fullWidth() === 0 || TypeScript.SyntaxFacts.isAnyDivideOrRegularExpressionToken(this.tokenKind); - }; - FixedWidthTokenWithNoTrivia.prototype.accept = function (visitor) { - return visitor.visitToken(this); - }; - FixedWidthTokenWithNoTrivia.prototype.realize = function () { - return Syntax.realizeToken(this); - }; - FixedWidthTokenWithNoTrivia.prototype.collectTextElements = function (elements) { - collectTokenTextElements(this, elements); - }; - - FixedWidthTokenWithNoTrivia.prototype.findTokenInternal = function (parent, position, fullStart) { - return new TypeScript.PositionedToken(parent, this, fullStart); - }; - - FixedWidthTokenWithNoTrivia.prototype.withLeadingTrivia = function (leadingTrivia) { - return this.realize().withLeadingTrivia(leadingTrivia); - }; - - FixedWidthTokenWithNoTrivia.prototype.withTrailingTrivia = function (trailingTrivia) { - return this.realize().withTrailingTrivia(trailingTrivia); - }; - return FixedWidthTokenWithNoTrivia; - })(); - Syntax.FixedWidthTokenWithNoTrivia = FixedWidthTokenWithNoTrivia; - - var FixedWidthTokenWithLeadingTrivia = (function () { - function FixedWidthTokenWithLeadingTrivia(sourceText, fullStart, kind, leadingTriviaInfo) { - this._sourceText = sourceText; - this._fullStart = fullStart; - this.tokenKind = kind; - this._leadingTriviaInfo = leadingTriviaInfo; - } - FixedWidthTokenWithLeadingTrivia.prototype.clone = function () { - return new FixedWidthTokenWithLeadingTrivia(this._sourceText, this._fullStart, this.tokenKind, this._leadingTriviaInfo); - }; - - FixedWidthTokenWithLeadingTrivia.prototype.isNode = function () { - return false; - }; - FixedWidthTokenWithLeadingTrivia.prototype.isToken = function () { - return true; - }; - FixedWidthTokenWithLeadingTrivia.prototype.isList = function () { - return false; - }; - FixedWidthTokenWithLeadingTrivia.prototype.isSeparatedList = function () { - return false; - }; - - FixedWidthTokenWithLeadingTrivia.prototype.kind = function () { - return this.tokenKind; - }; - - FixedWidthTokenWithLeadingTrivia.prototype.childCount = function () { - return 0; - }; - FixedWidthTokenWithLeadingTrivia.prototype.childAt = function (index) { - throw TypeScript.Errors.argumentOutOfRange('index'); - }; - - FixedWidthTokenWithLeadingTrivia.prototype.fullWidth = function () { - return getTriviaWidth(this._leadingTriviaInfo) + this.width(); - }; - FixedWidthTokenWithLeadingTrivia.prototype.start = function () { - return this._fullStart + getTriviaWidth(this._leadingTriviaInfo); - }; - FixedWidthTokenWithLeadingTrivia.prototype.end = function () { - return this.start() + this.width(); - }; - - FixedWidthTokenWithLeadingTrivia.prototype.width = function () { - return this.text().length; - }; - FixedWidthTokenWithLeadingTrivia.prototype.text = function () { - return TypeScript.SyntaxFacts.getText(this.tokenKind); - }; - FixedWidthTokenWithLeadingTrivia.prototype.fullText = function () { - return this._sourceText.substr(this._fullStart, this.fullWidth(), false); - }; - - FixedWidthTokenWithLeadingTrivia.prototype.value = function () { - return Syntax.value(this); - }; - FixedWidthTokenWithLeadingTrivia.prototype.valueText = function () { - return Syntax.valueText(this); - }; - FixedWidthTokenWithLeadingTrivia.prototype.hasLeadingTrivia = function () { - return true; - }; - FixedWidthTokenWithLeadingTrivia.prototype.hasLeadingComment = function () { - return hasTriviaComment(this._leadingTriviaInfo); - }; - FixedWidthTokenWithLeadingTrivia.prototype.hasLeadingNewLine = function () { - return hasTriviaNewLine(this._leadingTriviaInfo); - }; - FixedWidthTokenWithLeadingTrivia.prototype.hasLeadingSkippedText = function () { - return false; - }; - FixedWidthTokenWithLeadingTrivia.prototype.leadingTriviaWidth = function () { - return getTriviaWidth(this._leadingTriviaInfo); - }; - FixedWidthTokenWithLeadingTrivia.prototype.leadingTrivia = function () { - return TypeScript.Scanner.scanTrivia(this._sourceText, this._fullStart, getTriviaWidth(this._leadingTriviaInfo), false); - }; - - FixedWidthTokenWithLeadingTrivia.prototype.hasTrailingTrivia = function () { - return false; - }; - FixedWidthTokenWithLeadingTrivia.prototype.hasTrailingComment = function () { - return false; - }; - FixedWidthTokenWithLeadingTrivia.prototype.hasTrailingNewLine = function () { - return false; - }; - FixedWidthTokenWithLeadingTrivia.prototype.hasTrailingSkippedText = function () { - return false; - }; - FixedWidthTokenWithLeadingTrivia.prototype.trailingTriviaWidth = function () { - return 0; - }; - FixedWidthTokenWithLeadingTrivia.prototype.trailingTrivia = function () { - return TypeScript.Syntax.emptyTriviaList; - }; - - FixedWidthTokenWithLeadingTrivia.prototype.hasSkippedToken = function () { - return false; - }; - FixedWidthTokenWithLeadingTrivia.prototype.toJSON = function (key) { - return Syntax.tokenToJSON(this); - }; - FixedWidthTokenWithLeadingTrivia.prototype.firstToken = function () { - return this; - }; - FixedWidthTokenWithLeadingTrivia.prototype.lastToken = function () { - return this; - }; - FixedWidthTokenWithLeadingTrivia.prototype.isTypeScriptSpecific = function () { - return false; - }; - FixedWidthTokenWithLeadingTrivia.prototype.isIncrementallyUnusable = function () { - return this.fullWidth() === 0 || TypeScript.SyntaxFacts.isAnyDivideOrRegularExpressionToken(this.tokenKind); - }; - FixedWidthTokenWithLeadingTrivia.prototype.accept = function (visitor) { - return visitor.visitToken(this); - }; - FixedWidthTokenWithLeadingTrivia.prototype.realize = function () { - return Syntax.realizeToken(this); - }; - FixedWidthTokenWithLeadingTrivia.prototype.collectTextElements = function (elements) { - collectTokenTextElements(this, elements); - }; - - FixedWidthTokenWithLeadingTrivia.prototype.findTokenInternal = function (parent, position, fullStart) { - return new TypeScript.PositionedToken(parent, this, fullStart); - }; - - FixedWidthTokenWithLeadingTrivia.prototype.withLeadingTrivia = function (leadingTrivia) { - return this.realize().withLeadingTrivia(leadingTrivia); - }; - - FixedWidthTokenWithLeadingTrivia.prototype.withTrailingTrivia = function (trailingTrivia) { - return this.realize().withTrailingTrivia(trailingTrivia); - }; - return FixedWidthTokenWithLeadingTrivia; - })(); - Syntax.FixedWidthTokenWithLeadingTrivia = FixedWidthTokenWithLeadingTrivia; - - var FixedWidthTokenWithTrailingTrivia = (function () { - function FixedWidthTokenWithTrailingTrivia(sourceText, fullStart, kind, trailingTriviaInfo) { - this._sourceText = sourceText; - this._fullStart = fullStart; - this.tokenKind = kind; - this._trailingTriviaInfo = trailingTriviaInfo; - } - FixedWidthTokenWithTrailingTrivia.prototype.clone = function () { - return new FixedWidthTokenWithTrailingTrivia(this._sourceText, this._fullStart, this.tokenKind, this._trailingTriviaInfo); - }; - - FixedWidthTokenWithTrailingTrivia.prototype.isNode = function () { - return false; - }; - FixedWidthTokenWithTrailingTrivia.prototype.isToken = function () { - return true; - }; - FixedWidthTokenWithTrailingTrivia.prototype.isList = function () { - return false; - }; - FixedWidthTokenWithTrailingTrivia.prototype.isSeparatedList = function () { - return false; - }; - - FixedWidthTokenWithTrailingTrivia.prototype.kind = function () { - return this.tokenKind; - }; - - FixedWidthTokenWithTrailingTrivia.prototype.childCount = function () { - return 0; - }; - FixedWidthTokenWithTrailingTrivia.prototype.childAt = function (index) { - throw TypeScript.Errors.argumentOutOfRange('index'); - }; - - FixedWidthTokenWithTrailingTrivia.prototype.fullWidth = function () { - return this.width() + getTriviaWidth(this._trailingTriviaInfo); - }; - FixedWidthTokenWithTrailingTrivia.prototype.start = function () { - return this._fullStart; - }; - FixedWidthTokenWithTrailingTrivia.prototype.end = function () { - return this.start() + this.width(); - }; - - FixedWidthTokenWithTrailingTrivia.prototype.width = function () { - return this.text().length; - }; - FixedWidthTokenWithTrailingTrivia.prototype.text = function () { - return TypeScript.SyntaxFacts.getText(this.tokenKind); - }; - FixedWidthTokenWithTrailingTrivia.prototype.fullText = function () { - return this._sourceText.substr(this._fullStart, this.fullWidth(), false); - }; - - FixedWidthTokenWithTrailingTrivia.prototype.value = function () { - return Syntax.value(this); - }; - FixedWidthTokenWithTrailingTrivia.prototype.valueText = function () { - return Syntax.valueText(this); - }; - FixedWidthTokenWithTrailingTrivia.prototype.hasLeadingTrivia = function () { - return false; - }; - FixedWidthTokenWithTrailingTrivia.prototype.hasLeadingComment = function () { - return false; - }; - FixedWidthTokenWithTrailingTrivia.prototype.hasLeadingNewLine = function () { - return false; - }; - FixedWidthTokenWithTrailingTrivia.prototype.hasLeadingSkippedText = function () { - return false; - }; - FixedWidthTokenWithTrailingTrivia.prototype.leadingTriviaWidth = function () { - return 0; - }; - FixedWidthTokenWithTrailingTrivia.prototype.leadingTrivia = function () { - return TypeScript.Syntax.emptyTriviaList; - }; - - FixedWidthTokenWithTrailingTrivia.prototype.hasTrailingTrivia = function () { - return true; - }; - FixedWidthTokenWithTrailingTrivia.prototype.hasTrailingComment = function () { - return hasTriviaComment(this._trailingTriviaInfo); - }; - FixedWidthTokenWithTrailingTrivia.prototype.hasTrailingNewLine = function () { - return hasTriviaNewLine(this._trailingTriviaInfo); - }; - FixedWidthTokenWithTrailingTrivia.prototype.hasTrailingSkippedText = function () { - return false; - }; - FixedWidthTokenWithTrailingTrivia.prototype.trailingTriviaWidth = function () { - return getTriviaWidth(this._trailingTriviaInfo); - }; - FixedWidthTokenWithTrailingTrivia.prototype.trailingTrivia = function () { - return TypeScript.Scanner.scanTrivia(this._sourceText, this.end(), getTriviaWidth(this._trailingTriviaInfo), true); - }; - - FixedWidthTokenWithTrailingTrivia.prototype.hasSkippedToken = function () { - return false; - }; - FixedWidthTokenWithTrailingTrivia.prototype.toJSON = function (key) { - return Syntax.tokenToJSON(this); - }; - FixedWidthTokenWithTrailingTrivia.prototype.firstToken = function () { - return this; - }; - FixedWidthTokenWithTrailingTrivia.prototype.lastToken = function () { - return this; - }; - FixedWidthTokenWithTrailingTrivia.prototype.isTypeScriptSpecific = function () { - return false; - }; - FixedWidthTokenWithTrailingTrivia.prototype.isIncrementallyUnusable = function () { - return this.fullWidth() === 0 || TypeScript.SyntaxFacts.isAnyDivideOrRegularExpressionToken(this.tokenKind); - }; - FixedWidthTokenWithTrailingTrivia.prototype.accept = function (visitor) { - return visitor.visitToken(this); - }; - FixedWidthTokenWithTrailingTrivia.prototype.realize = function () { - return Syntax.realizeToken(this); - }; - FixedWidthTokenWithTrailingTrivia.prototype.collectTextElements = function (elements) { - collectTokenTextElements(this, elements); - }; - - FixedWidthTokenWithTrailingTrivia.prototype.findTokenInternal = function (parent, position, fullStart) { - return new TypeScript.PositionedToken(parent, this, fullStart); - }; - - FixedWidthTokenWithTrailingTrivia.prototype.withLeadingTrivia = function (leadingTrivia) { - return this.realize().withLeadingTrivia(leadingTrivia); - }; - - FixedWidthTokenWithTrailingTrivia.prototype.withTrailingTrivia = function (trailingTrivia) { - return this.realize().withTrailingTrivia(trailingTrivia); - }; - return FixedWidthTokenWithTrailingTrivia; - })(); - Syntax.FixedWidthTokenWithTrailingTrivia = FixedWidthTokenWithTrailingTrivia; - - var FixedWidthTokenWithLeadingAndTrailingTrivia = (function () { - function FixedWidthTokenWithLeadingAndTrailingTrivia(sourceText, fullStart, kind, leadingTriviaInfo, trailingTriviaInfo) { - this._sourceText = sourceText; - this._fullStart = fullStart; - this.tokenKind = kind; - this._leadingTriviaInfo = leadingTriviaInfo; - this._trailingTriviaInfo = trailingTriviaInfo; - } - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.clone = function () { - return new FixedWidthTokenWithLeadingAndTrailingTrivia(this._sourceText, this._fullStart, this.tokenKind, this._leadingTriviaInfo, this._trailingTriviaInfo); - }; - - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.isNode = function () { - return false; - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.isToken = function () { - return true; - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.isList = function () { - return false; - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.isSeparatedList = function () { - return false; - }; - - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.kind = function () { - return this.tokenKind; - }; - - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.childCount = function () { - return 0; - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.childAt = function (index) { - throw TypeScript.Errors.argumentOutOfRange('index'); - }; - - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.fullWidth = function () { - return getTriviaWidth(this._leadingTriviaInfo) + this.width() + getTriviaWidth(this._trailingTriviaInfo); - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.start = function () { - return this._fullStart + getTriviaWidth(this._leadingTriviaInfo); - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.end = function () { - return this.start() + this.width(); - }; - - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.width = function () { - return this.text().length; - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.text = function () { - return TypeScript.SyntaxFacts.getText(this.tokenKind); - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.fullText = function () { - return this._sourceText.substr(this._fullStart, this.fullWidth(), false); - }; - - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.value = function () { - return Syntax.value(this); - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.valueText = function () { - return Syntax.valueText(this); - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.hasLeadingTrivia = function () { - return true; - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.hasLeadingComment = function () { - return hasTriviaComment(this._leadingTriviaInfo); - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.hasLeadingNewLine = function () { - return hasTriviaNewLine(this._leadingTriviaInfo); - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.hasLeadingSkippedText = function () { - return false; - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.leadingTriviaWidth = function () { - return getTriviaWidth(this._leadingTriviaInfo); - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.leadingTrivia = function () { - return TypeScript.Scanner.scanTrivia(this._sourceText, this._fullStart, getTriviaWidth(this._leadingTriviaInfo), false); - }; - - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.hasTrailingTrivia = function () { - return true; - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.hasTrailingComment = function () { - return hasTriviaComment(this._trailingTriviaInfo); - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.hasTrailingNewLine = function () { - return hasTriviaNewLine(this._trailingTriviaInfo); - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.hasTrailingSkippedText = function () { - return false; - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.trailingTriviaWidth = function () { - return getTriviaWidth(this._trailingTriviaInfo); - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.trailingTrivia = function () { - return TypeScript.Scanner.scanTrivia(this._sourceText, this.end(), getTriviaWidth(this._trailingTriviaInfo), true); - }; - - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.hasSkippedToken = function () { - return false; - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.toJSON = function (key) { - return Syntax.tokenToJSON(this); - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.firstToken = function () { - return this; - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.lastToken = function () { - return this; - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.isTypeScriptSpecific = function () { - return false; - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.isIncrementallyUnusable = function () { - return this.fullWidth() === 0 || TypeScript.SyntaxFacts.isAnyDivideOrRegularExpressionToken(this.tokenKind); - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.accept = function (visitor) { - return visitor.visitToken(this); - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.realize = function () { - return Syntax.realizeToken(this); - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.collectTextElements = function (elements) { - collectTokenTextElements(this, elements); - }; - - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.findTokenInternal = function (parent, position, fullStart) { - return new TypeScript.PositionedToken(parent, this, fullStart); - }; - - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.withLeadingTrivia = function (leadingTrivia) { - return this.realize().withLeadingTrivia(leadingTrivia); - }; - - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.withTrailingTrivia = function (trailingTrivia) { - return this.realize().withTrailingTrivia(trailingTrivia); - }; - return FixedWidthTokenWithLeadingAndTrailingTrivia; - })(); - Syntax.FixedWidthTokenWithLeadingAndTrailingTrivia = FixedWidthTokenWithLeadingAndTrailingTrivia; - - function collectTokenTextElements(token, elements) { - token.leadingTrivia().collectTextElements(elements); - elements.push(token.text()); - token.trailingTrivia().collectTextElements(elements); - } - - function fixedWidthToken(sourceText, fullStart, kind, leadingTriviaInfo, trailingTriviaInfo) { - if (leadingTriviaInfo === 0) { - if (trailingTriviaInfo === 0) { - return new FixedWidthTokenWithNoTrivia(kind); - } else { - return new FixedWidthTokenWithTrailingTrivia(sourceText, fullStart, kind, trailingTriviaInfo); - } - } else if (trailingTriviaInfo === 0) { - return new FixedWidthTokenWithLeadingTrivia(sourceText, fullStart, kind, leadingTriviaInfo); - } else { - return new FixedWidthTokenWithLeadingAndTrailingTrivia(sourceText, fullStart, kind, leadingTriviaInfo, trailingTriviaInfo); - } - } - Syntax.fixedWidthToken = fixedWidthToken; - - function variableWidthToken(sourceText, fullStart, kind, leadingTriviaInfo, width, trailingTriviaInfo) { - if (leadingTriviaInfo === 0) { - if (trailingTriviaInfo === 0) { - return new VariableWidthTokenWithNoTrivia(sourceText, fullStart, kind, width); - } else { - return new VariableWidthTokenWithTrailingTrivia(sourceText, fullStart, kind, width, trailingTriviaInfo); - } - } else if (trailingTriviaInfo === 0) { - return new VariableWidthTokenWithLeadingTrivia(sourceText, fullStart, kind, leadingTriviaInfo, width); - } else { - return new VariableWidthTokenWithLeadingAndTrailingTrivia(sourceText, fullStart, kind, leadingTriviaInfo, width, trailingTriviaInfo); - } - } - Syntax.variableWidthToken = variableWidthToken; - - function getTriviaWidth(value) { - return value >>> 2 /* TriviaFullWidthShift */; - } - - function hasTriviaComment(value) { - return (value & 2 /* TriviaCommentMask */) !== 0; - } - - function hasTriviaNewLine(value) { - return (value & 1 /* TriviaNewLineMask */) !== 0; - } - })(TypeScript.Syntax || (TypeScript.Syntax = {})); - var Syntax = TypeScript.Syntax; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (Syntax) { - function realizeToken(token) { - return new RealizedToken(token.tokenKind, token.leadingTrivia(), token.text(), token.value(), token.valueText(), token.trailingTrivia()); - } - Syntax.realizeToken = realizeToken; - - function convertToIdentifierName(token) { - TypeScript.Debug.assert(TypeScript.SyntaxFacts.isAnyKeyword(token.tokenKind)); - return new RealizedToken(11 /* IdentifierName */, token.leadingTrivia(), token.text(), token.text(), token.text(), token.trailingTrivia()); - } - Syntax.convertToIdentifierName = convertToIdentifierName; - - function tokenToJSON(token) { - var result = {}; - - for (var name in TypeScript.SyntaxKind) { - if (TypeScript.SyntaxKind[name] === token.kind()) { - result.kind = name; - break; - } - } - - result.width = token.width(); - if (token.fullWidth() !== token.width()) { - result.fullWidth = token.fullWidth(); - } - - result.text = token.text(); - - var value = token.value(); - if (value !== null) { - result.value = value; - result.valueText = token.valueText(); - } - - if (token.hasLeadingTrivia()) { - result.hasLeadingTrivia = true; - } - - if (token.hasLeadingComment()) { - result.hasLeadingComment = true; - } - - if (token.hasLeadingNewLine()) { - result.hasLeadingNewLine = true; - } - - if (token.hasLeadingSkippedText()) { - result.hasLeadingSkippedText = true; - } - - if (token.hasTrailingTrivia()) { - result.hasTrailingTrivia = true; - } - - if (token.hasTrailingComment()) { - result.hasTrailingComment = true; - } - - if (token.hasTrailingNewLine()) { - result.hasTrailingNewLine = true; - } - - if (token.hasTrailingSkippedText()) { - result.hasTrailingSkippedText = true; - } - - var trivia = token.leadingTrivia(); - if (trivia.count() > 0) { - result.leadingTrivia = trivia; - } - - trivia = token.trailingTrivia(); - if (trivia.count() > 0) { - result.trailingTrivia = trivia; - } - - return result; - } - Syntax.tokenToJSON = tokenToJSON; - - function value(token) { - return value1(token.tokenKind, token.text()); - } - Syntax.value = value; - - function hexValue(text, start, length) { - var intChar = 0; - for (var i = 0; i < length; i++) { - var ch2 = text.charCodeAt(start + i); - if (!TypeScript.CharacterInfo.isHexDigit(ch2)) { - break; - } - - intChar = (intChar << 4) + TypeScript.CharacterInfo.hexValue(ch2); - } - - return intChar; - } - - var characterArray = []; - - function convertEscapes(text) { - characterArray.length = 0; - var result = ""; - - for (var i = 0, n = text.length; i < n; i++) { - var ch = text.charCodeAt(i); - - if (ch === 92 /* backslash */) { - i++; - if (i < n) { - ch = text.charCodeAt(i); - switch (ch) { - case 48 /* _0 */: - characterArray.push(0 /* nullCharacter */); - continue; - - case 98 /* b */: - characterArray.push(8 /* backspace */); - continue; - - case 102 /* f */: - characterArray.push(12 /* formFeed */); - continue; - - case 110 /* n */: - characterArray.push(10 /* lineFeed */); - continue; - - case 114 /* r */: - characterArray.push(13 /* carriageReturn */); - continue; - - case 116 /* t */: - characterArray.push(9 /* tab */); - continue; - - case 118 /* v */: - characterArray.push(11 /* verticalTab */); - continue; - - case 120 /* x */: - characterArray.push(hexValue(text, i + 1, 2)); - i += 2; - continue; - - case 117 /* u */: - characterArray.push(hexValue(text, i + 1, 4)); - i += 4; - continue; - - default: - } - } - } - - characterArray.push(ch); - - if (i && !(i % 1024)) { - result = result.concat(String.fromCharCode.apply(null, characterArray)); - characterArray.length = 0; - } - } - - if (characterArray.length) { - result = result.concat(String.fromCharCode.apply(null, characterArray)); - } - - return result; - } - - function massageEscapes(text) { - return text.indexOf("\\") >= 0 ? convertEscapes(text) : text; - } - - function value1(kind, text) { - if (kind === 11 /* IdentifierName */) { - return massageEscapes(text); - } - - switch (kind) { - case 37 /* TrueKeyword */: - return true; - case 24 /* FalseKeyword */: - return false; - case 32 /* NullKeyword */: - return null; - } - - if (TypeScript.SyntaxFacts.isAnyKeyword(kind) || TypeScript.SyntaxFacts.isAnyPunctuation(kind)) { - return TypeScript.SyntaxFacts.getText(kind); - } - - if (kind === 13 /* NumericLiteral */) { - return parseFloat(text); - } else if (kind === 14 /* StringLiteral */) { - if (text.length > 1 && text.charCodeAt(text.length - 1) === text.charCodeAt(0)) { - return massageEscapes(text.substr(1, text.length - 2)); - } else { - return massageEscapes(text.substr(1)); - } - } else if (kind === 12 /* RegularExpressionLiteral */) { - 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 null; - } - } else if (kind === 10 /* EndOfFileToken */ || kind === 9 /* ErrorToken */) { - return null; - } else { - throw TypeScript.Errors.invalidOperation(); - } - } - - function valueText1(kind, text) { - var value = value1(kind, text); - return value === null ? "" : value.toString(); - } - - function valueText(token) { - var value = token.value(); - return value === null ? "" : value.toString(); - } - Syntax.valueText = valueText; - - var EmptyToken = (function () { - function EmptyToken(kind) { - this.tokenKind = kind; - } - EmptyToken.prototype.clone = function () { - return new EmptyToken(this.tokenKind); - }; - - EmptyToken.prototype.kind = function () { - return this.tokenKind; - }; - - EmptyToken.prototype.isToken = function () { - return true; - }; - EmptyToken.prototype.isNode = function () { - return false; - }; - EmptyToken.prototype.isList = function () { - return false; - }; - EmptyToken.prototype.isSeparatedList = function () { - return false; - }; - - EmptyToken.prototype.childCount = function () { - return 0; - }; - - EmptyToken.prototype.childAt = function (index) { - throw TypeScript.Errors.argumentOutOfRange("index"); - }; - - EmptyToken.prototype.toJSON = function (key) { - return tokenToJSON(this); - }; - EmptyToken.prototype.accept = function (visitor) { - return visitor.visitToken(this); - }; - - EmptyToken.prototype.findTokenInternal = function (parent, position, fullStart) { - return new TypeScript.PositionedToken(parent, this, fullStart); - }; - - EmptyToken.prototype.firstToken = function () { - return this; - }; - EmptyToken.prototype.lastToken = function () { - return this; - }; - EmptyToken.prototype.isTypeScriptSpecific = function () { - return false; - }; - - EmptyToken.prototype.isIncrementallyUnusable = function () { - return true; - }; - - EmptyToken.prototype.fullWidth = function () { - return 0; - }; - EmptyToken.prototype.width = function () { - return 0; - }; - EmptyToken.prototype.text = function () { - return ""; - }; - EmptyToken.prototype.fullText = function () { - return ""; - }; - EmptyToken.prototype.value = function () { - return null; - }; - EmptyToken.prototype.valueText = function () { - return ""; - }; - - EmptyToken.prototype.hasLeadingTrivia = function () { - return false; - }; - EmptyToken.prototype.hasLeadingComment = function () { - return false; - }; - EmptyToken.prototype.hasLeadingNewLine = function () { - return false; - }; - EmptyToken.prototype.hasLeadingSkippedText = function () { - return false; - }; - EmptyToken.prototype.leadingTriviaWidth = function () { - return 0; - }; - EmptyToken.prototype.hasTrailingTrivia = function () { - return false; - }; - EmptyToken.prototype.hasTrailingComment = function () { - return false; - }; - EmptyToken.prototype.hasTrailingNewLine = function () { - return false; - }; - EmptyToken.prototype.hasTrailingSkippedText = function () { - return false; - }; - EmptyToken.prototype.hasSkippedToken = function () { - return false; - }; - - EmptyToken.prototype.trailingTriviaWidth = function () { - return 0; - }; - EmptyToken.prototype.leadingTrivia = function () { - return TypeScript.Syntax.emptyTriviaList; - }; - EmptyToken.prototype.trailingTrivia = function () { - return TypeScript.Syntax.emptyTriviaList; - }; - EmptyToken.prototype.realize = function () { - return realizeToken(this); - }; - EmptyToken.prototype.collectTextElements = function (elements) { - }; - - EmptyToken.prototype.withLeadingTrivia = function (leadingTrivia) { - return this.realize().withLeadingTrivia(leadingTrivia); - }; - - EmptyToken.prototype.withTrailingTrivia = function (trailingTrivia) { - return this.realize().withTrailingTrivia(trailingTrivia); - }; - return EmptyToken; - })(); - - function emptyToken(kind) { - return new EmptyToken(kind); - } - Syntax.emptyToken = emptyToken; - - var RealizedToken = (function () { - function RealizedToken(tokenKind, leadingTrivia, text, value, valueText, trailingTrivia) { - this.tokenKind = tokenKind; - this._leadingTrivia = leadingTrivia; - this._text = text; - this._value = value; - this._valueText = valueText; - this._trailingTrivia = trailingTrivia; - } - RealizedToken.prototype.clone = function () { - return new RealizedToken(this.tokenKind, this._leadingTrivia, this._text, this._value, this._valueText, this._trailingTrivia); - }; - - RealizedToken.prototype.kind = function () { - return this.tokenKind; - }; - RealizedToken.prototype.toJSON = function (key) { - return tokenToJSON(this); - }; - RealizedToken.prototype.firstToken = function () { - return this; - }; - RealizedToken.prototype.lastToken = function () { - return this; - }; - RealizedToken.prototype.isTypeScriptSpecific = function () { - return false; - }; - - RealizedToken.prototype.isIncrementallyUnusable = function () { - return true; - }; - - RealizedToken.prototype.accept = function (visitor) { - return visitor.visitToken(this); - }; - - RealizedToken.prototype.childCount = function () { - return 0; - }; - - RealizedToken.prototype.childAt = function (index) { - throw TypeScript.Errors.argumentOutOfRange("index"); - }; - - RealizedToken.prototype.isToken = function () { - return true; - }; - RealizedToken.prototype.isNode = function () { - return false; - }; - RealizedToken.prototype.isList = function () { - return false; - }; - RealizedToken.prototype.isSeparatedList = function () { - return false; - }; - RealizedToken.prototype.isTrivia = function () { - return false; - }; - RealizedToken.prototype.isTriviaList = function () { - return false; - }; - - RealizedToken.prototype.fullWidth = function () { - return this._leadingTrivia.fullWidth() + this.width() + this._trailingTrivia.fullWidth(); - }; - RealizedToken.prototype.width = function () { - return this.text().length; - }; - - RealizedToken.prototype.text = function () { - return this._text; - }; - RealizedToken.prototype.fullText = function () { - return this._leadingTrivia.fullText() + this.text() + this._trailingTrivia.fullText(); - }; - - RealizedToken.prototype.value = function () { - return this._value; - }; - RealizedToken.prototype.valueText = function () { - return this._valueText; - }; - - RealizedToken.prototype.hasLeadingTrivia = function () { - return this._leadingTrivia.count() > 0; - }; - RealizedToken.prototype.hasLeadingComment = function () { - return this._leadingTrivia.hasComment(); - }; - RealizedToken.prototype.hasLeadingNewLine = function () { - return this._leadingTrivia.hasNewLine(); - }; - RealizedToken.prototype.hasLeadingSkippedText = function () { - return this._leadingTrivia.hasSkippedToken(); - }; - RealizedToken.prototype.leadingTriviaWidth = function () { - return this._leadingTrivia.fullWidth(); - }; - - RealizedToken.prototype.hasTrailingTrivia = function () { - return this._trailingTrivia.count() > 0; - }; - RealizedToken.prototype.hasTrailingComment = function () { - return this._trailingTrivia.hasComment(); - }; - RealizedToken.prototype.hasTrailingNewLine = function () { - return this._trailingTrivia.hasNewLine(); - }; - RealizedToken.prototype.hasTrailingSkippedText = function () { - return this._trailingTrivia.hasSkippedToken(); - }; - RealizedToken.prototype.trailingTriviaWidth = function () { - return this._trailingTrivia.fullWidth(); - }; - - RealizedToken.prototype.hasSkippedToken = function () { - return this.hasLeadingSkippedText() || this.hasTrailingSkippedText(); - }; - - RealizedToken.prototype.leadingTrivia = function () { - return this._leadingTrivia; - }; - RealizedToken.prototype.trailingTrivia = function () { - return this._trailingTrivia; - }; - - RealizedToken.prototype.findTokenInternal = function (parent, position, fullStart) { - return new TypeScript.PositionedToken(parent, this, fullStart); - }; - - RealizedToken.prototype.collectTextElements = function (elements) { - this.leadingTrivia().collectTextElements(elements); - elements.push(this.text()); - this.trailingTrivia().collectTextElements(elements); - }; - - RealizedToken.prototype.withLeadingTrivia = function (leadingTrivia) { - return new RealizedToken(this.tokenKind, leadingTrivia, this._text, this._value, this._valueText, this._trailingTrivia); - }; - - RealizedToken.prototype.withTrailingTrivia = function (trailingTrivia) { - return new RealizedToken(this.tokenKind, this._leadingTrivia, this._text, this._value, this._valueText, trailingTrivia); - }; - return RealizedToken; - })(); - - function token(kind, info) { - if (typeof info === "undefined") { info = null; } - var text = (info !== null && info.text !== undefined) ? info.text : TypeScript.SyntaxFacts.getText(kind); - - return new RealizedToken(kind, TypeScript.Syntax.triviaList(info === null ? null : info.leadingTrivia), text, value1(kind, text), valueText1(kind, text), TypeScript.Syntax.triviaList(info === null ? null : info.trailingTrivia)); - } - Syntax.token = token; - - function identifier(text, info) { - if (typeof info === "undefined") { info = null; } - info = info || {}; - info.text = text; - return token(11 /* IdentifierName */, info); - } - Syntax.identifier = identifier; - })(TypeScript.Syntax || (TypeScript.Syntax = {})); - var Syntax = TypeScript.Syntax; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var SyntaxTokenReplacer = (function (_super) { - __extends(SyntaxTokenReplacer, _super); - function SyntaxTokenReplacer(token1, token2) { - _super.call(this); - this.token1 = token1; - this.token2 = token2; - } - SyntaxTokenReplacer.prototype.visitToken = function (token) { - if (token === this.token1) { - var result = this.token2; - this.token1 = null; - this.token2 = null; - - return result; - } - - return token; - }; - - SyntaxTokenReplacer.prototype.visitNode = function (node) { - if (this.token1 === null) { - return node; - } - - return _super.prototype.visitNode.call(this, node); - }; - - SyntaxTokenReplacer.prototype.visitList = function (list) { - if (this.token1 === null) { - return list; - } - - return _super.prototype.visitList.call(this, list); - }; - - SyntaxTokenReplacer.prototype.visitSeparatedList = function (list) { - if (this.token1 === null) { - return list; - } - - return _super.prototype.visitSeparatedList.call(this, list); - }; - return SyntaxTokenReplacer; - })(TypeScript.SyntaxRewriter); - TypeScript.SyntaxTokenReplacer = SyntaxTokenReplacer; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (Syntax) { - var SyntaxTrivia = (function () { - function SyntaxTrivia(kind, textOrToken) { - this._kind = kind; - this._textOrToken = textOrToken; - } - SyntaxTrivia.prototype.toJSON = function (key) { - var result = {}; - result.kind = TypeScript.SyntaxKind[this._kind]; - - if (this.isSkippedToken()) { - result.skippedToken = this._textOrToken; - } else { - result.text = this._textOrToken; - } - return result; - }; - - SyntaxTrivia.prototype.kind = function () { - return this._kind; - }; - - SyntaxTrivia.prototype.fullWidth = function () { - return this.fullText().length; - }; - - SyntaxTrivia.prototype.fullText = function () { - return this.isSkippedToken() ? this.skippedToken().fullText() : this._textOrToken; - }; - - SyntaxTrivia.prototype.isWhitespace = function () { - return this.kind() === 4 /* WhitespaceTrivia */; - }; - - SyntaxTrivia.prototype.isComment = function () { - return this.kind() === 7 /* SingleLineCommentTrivia */ || this.kind() === 6 /* MultiLineCommentTrivia */; - }; - - SyntaxTrivia.prototype.isNewLine = function () { - return this.kind() === 5 /* NewLineTrivia */; - }; - - SyntaxTrivia.prototype.isSkippedToken = function () { - return this.kind() === 8 /* SkippedTokenTrivia */; - }; - - SyntaxTrivia.prototype.skippedToken = function () { - TypeScript.Debug.assert(this.isSkippedToken()); - return this._textOrToken; - }; - - SyntaxTrivia.prototype.collectTextElements = function (elements) { - elements.push(this.fullText()); - }; - return SyntaxTrivia; - })(); - - function trivia(kind, text) { - return new SyntaxTrivia(kind, text); - } - Syntax.trivia = trivia; - - function skippedTokenTrivia(token) { - TypeScript.Debug.assert(!token.hasLeadingTrivia()); - TypeScript.Debug.assert(!token.hasTrailingTrivia()); - TypeScript.Debug.assert(token.fullWidth() > 0); - return new SyntaxTrivia(8 /* SkippedTokenTrivia */, token); - } - Syntax.skippedTokenTrivia = skippedTokenTrivia; - - function spaces(count) { - return trivia(4 /* WhitespaceTrivia */, TypeScript.StringUtilities.repeat(" ", count)); - } - Syntax.spaces = spaces; - - function whitespace(text) { - return trivia(4 /* WhitespaceTrivia */, text); - } - Syntax.whitespace = whitespace; - - function multiLineComment(text) { - return trivia(6 /* MultiLineCommentTrivia */, text); - } - Syntax.multiLineComment = multiLineComment; - - function singleLineComment(text) { - return trivia(7 /* SingleLineCommentTrivia */, text); - } - Syntax.singleLineComment = singleLineComment; - - Syntax.spaceTrivia = spaces(1); - Syntax.lineFeedTrivia = trivia(5 /* NewLineTrivia */, "\n"); - Syntax.carriageReturnTrivia = trivia(5 /* NewLineTrivia */, "\r"); - Syntax.carriageReturnLineFeedTrivia = trivia(5 /* NewLineTrivia */, "\r\n"); - - function splitMultiLineCommentTriviaIntoMultipleLines(trivia) { - var result = []; - - var triviaText = trivia.fullText(); - var currentIndex = 0; - - for (var i = 0; i < triviaText.length; i++) { - var ch = triviaText.charCodeAt(i); - - var isCarriageReturnLineFeed = false; - switch (ch) { - case 13 /* carriageReturn */: - if (i < triviaText.length - 1 && triviaText.charCodeAt(i + 1) === 10 /* lineFeed */) { - i++; - } - - case 10 /* lineFeed */: - case 8233 /* paragraphSeparator */: - case 8232 /* lineSeparator */: - result.push(triviaText.substring(currentIndex, i + 1)); - - currentIndex = i + 1; - continue; - } - } - - result.push(triviaText.substring(currentIndex)); - return result; - } - Syntax.splitMultiLineCommentTriviaIntoMultipleLines = splitMultiLineCommentTriviaIntoMultipleLines; - })(TypeScript.Syntax || (TypeScript.Syntax = {})); - var Syntax = TypeScript.Syntax; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (Syntax) { - Syntax.emptyTriviaList = { - kind: function () { - return 3 /* TriviaList */; - }, - count: function () { - return 0; - }, - syntaxTriviaAt: function (index) { - throw TypeScript.Errors.argumentOutOfRange("index"); - }, - last: function () { - throw TypeScript.Errors.argumentOutOfRange("index"); - }, - fullWidth: function () { - return 0; - }, - fullText: function () { - return ""; - }, - hasComment: function () { - return false; - }, - hasNewLine: function () { - return false; - }, - hasSkippedToken: function () { - return false; - }, - toJSON: function (key) { - return []; - }, - collectTextElements: function (elements) { - }, - toArray: function () { - return []; - }, - concat: function (trivia) { - return trivia; - } - }; - - function concatTrivia(list1, list2) { - if (list1.count() === 0) { - return list2; - } - - if (list2.count() === 0) { - return list1; - } - - var trivia = list1.toArray(); - trivia.push.apply(trivia, list2.toArray()); - - return triviaList(trivia); - } - - function isComment(trivia) { - return trivia.kind() === 6 /* MultiLineCommentTrivia */ || trivia.kind() === 7 /* SingleLineCommentTrivia */; - } - - var SingletonSyntaxTriviaList = (function () { - function SingletonSyntaxTriviaList(item) { - this.item = item; - } - SingletonSyntaxTriviaList.prototype.kind = function () { - return 3 /* TriviaList */; - }; - - SingletonSyntaxTriviaList.prototype.count = function () { - return 1; - }; - - SingletonSyntaxTriviaList.prototype.syntaxTriviaAt = function (index) { - if (index !== 0) { - throw TypeScript.Errors.argumentOutOfRange("index"); - } - - return this.item; - }; - - SingletonSyntaxTriviaList.prototype.last = function () { - return this.item; - }; - - SingletonSyntaxTriviaList.prototype.fullWidth = function () { - return this.item.fullWidth(); - }; - - SingletonSyntaxTriviaList.prototype.fullText = function () { - return this.item.fullText(); - }; - - SingletonSyntaxTriviaList.prototype.hasComment = function () { - return isComment(this.item); - }; - - SingletonSyntaxTriviaList.prototype.hasNewLine = function () { - return this.item.kind() === 5 /* NewLineTrivia */; - }; - - SingletonSyntaxTriviaList.prototype.hasSkippedToken = function () { - return this.item.kind() === 8 /* SkippedTokenTrivia */; - }; - - SingletonSyntaxTriviaList.prototype.toJSON = function (key) { - return [this.item]; - }; - - SingletonSyntaxTriviaList.prototype.collectTextElements = function (elements) { - (this.item).collectTextElements(elements); - }; - - SingletonSyntaxTriviaList.prototype.toArray = function () { - return [this.item]; - }; - - SingletonSyntaxTriviaList.prototype.concat = function (trivia) { - return concatTrivia(this, trivia); - }; - return SingletonSyntaxTriviaList; - })(); - - var NormalSyntaxTriviaList = (function () { - function NormalSyntaxTriviaList(trivia) { - this.trivia = trivia; - } - NormalSyntaxTriviaList.prototype.kind = function () { - return 3 /* TriviaList */; - }; - - NormalSyntaxTriviaList.prototype.count = function () { - return this.trivia.length; - }; - - NormalSyntaxTriviaList.prototype.syntaxTriviaAt = function (index) { - if (index < 0 || index >= this.trivia.length) { - throw TypeScript.Errors.argumentOutOfRange("index"); - } - - return this.trivia[index]; - }; - - NormalSyntaxTriviaList.prototype.last = function () { - return this.trivia[this.trivia.length - 1]; - }; - - NormalSyntaxTriviaList.prototype.fullWidth = function () { - return TypeScript.ArrayUtilities.sum(this.trivia, function (t) { - return t.fullWidth(); - }); - }; - - NormalSyntaxTriviaList.prototype.fullText = function () { - var result = ""; - - for (var i = 0, n = this.trivia.length; i < n; i++) { - result += this.trivia[i].fullText(); - } - - return result; - }; - - NormalSyntaxTriviaList.prototype.hasComment = function () { - for (var i = 0; i < this.trivia.length; i++) { - if (isComment(this.trivia[i])) { - return true; - } - } - - return false; - }; - - NormalSyntaxTriviaList.prototype.hasNewLine = function () { - for (var i = 0; i < this.trivia.length; i++) { - if (this.trivia[i].kind() === 5 /* NewLineTrivia */) { - return true; - } - } - - return false; - }; - - NormalSyntaxTriviaList.prototype.hasSkippedToken = function () { - for (var i = 0; i < this.trivia.length; i++) { - if (this.trivia[i].kind() === 8 /* SkippedTokenTrivia */) { - return true; - } - } - - return false; - }; - - NormalSyntaxTriviaList.prototype.toJSON = function (key) { - return this.trivia; - }; - - NormalSyntaxTriviaList.prototype.collectTextElements = function (elements) { - for (var i = 0; i < this.trivia.length; i++) { - (this.trivia[i]).collectTextElements(elements); - } - }; - - NormalSyntaxTriviaList.prototype.toArray = function () { - return this.trivia.slice(0); - }; - - NormalSyntaxTriviaList.prototype.concat = function (trivia) { - return concatTrivia(this, trivia); - }; - return NormalSyntaxTriviaList; - })(); - - function triviaList(trivia) { - if (trivia === undefined || trivia === null || trivia.length === 0) { - return TypeScript.Syntax.emptyTriviaList; - } - - if (trivia.length === 1) { - return new SingletonSyntaxTriviaList(trivia[0]); - } - - return new NormalSyntaxTriviaList(trivia); - } - Syntax.triviaList = triviaList; - - Syntax.spaceTriviaList = triviaList([TypeScript.Syntax.spaceTrivia]); - })(TypeScript.Syntax || (TypeScript.Syntax = {})); - var Syntax = TypeScript.Syntax; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var SyntaxUtilities = (function () { - function SyntaxUtilities() { - } - SyntaxUtilities.isAngleBracket = function (positionedElement) { - var element = positionedElement.element(); - var parent = positionedElement.parentElement(); - if (parent !== null && (element.kind() === 81 /* LessThanToken */ || element.kind() === 82 /* GreaterThanToken */)) { - switch (parent.kind()) { - case 227 /* TypeArgumentList */: - case 228 /* TypeParameterList */: - case 219 /* CastExpression */: - return true; - } - } - - return false; - }; - - SyntaxUtilities.getToken = function (list, kind) { - for (var i = 0, n = list.childCount(); i < n; i++) { - var token = list.childAt(i); - if (token.tokenKind === kind) { - return token; - } - } - - return null; - }; - - SyntaxUtilities.containsToken = function (list, kind) { - return SyntaxUtilities.getToken(list, kind) !== null; - }; - - SyntaxUtilities.hasExportKeyword = function (moduleElement) { - switch (moduleElement.kind()) { - case 130 /* ModuleDeclaration */: - case 131 /* ClassDeclaration */: - case 129 /* FunctionDeclaration */: - case 147 /* VariableStatement */: - case 132 /* EnumDeclaration */: - case 128 /* InterfaceDeclaration */: - return SyntaxUtilities.containsToken((moduleElement).modifiers, 47 /* ExportKeyword */); - } - - return false; - }; - - SyntaxUtilities.isAmbientDeclarationSyntax = function (positionNode) { - if (!positionNode) { - return false; - } - - var node = positionNode.node(); - switch (node.kind()) { - case 130 /* ModuleDeclaration */: - case 131 /* ClassDeclaration */: - case 129 /* FunctionDeclaration */: - case 147 /* VariableStatement */: - case 132 /* EnumDeclaration */: - if (SyntaxUtilities.containsToken((node).modifiers, 64 /* DeclareKeyword */)) { - return true; - } - - case 133 /* ImportDeclaration */: - case 137 /* ConstructorDeclaration */: - case 135 /* MemberFunctionDeclaration */: - case 138 /* GetMemberAccessorDeclaration */: - case 139 /* SetMemberAccessorDeclaration */: - case 136 /* MemberVariableDeclaration */: - if (node.isClassElement() || node.isModuleElement()) { - return SyntaxUtilities.isAmbientDeclarationSyntax(positionNode.containingNode()); - } - - case 243 /* EnumElement */: - return SyntaxUtilities.isAmbientDeclarationSyntax(positionNode.containingNode().containingNode()); - - default: - return SyntaxUtilities.isAmbientDeclarationSyntax(positionNode.containingNode()); - } - }; - return SyntaxUtilities; - })(); - TypeScript.SyntaxUtilities = SyntaxUtilities; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var SyntaxVisitor = (function () { - function SyntaxVisitor() { - } - SyntaxVisitor.prototype.defaultVisit = function (node) { - return null; - }; - - SyntaxVisitor.prototype.visitToken = function (token) { - return this.defaultVisit(token); - }; - - SyntaxVisitor.prototype.visitSourceUnit = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitExternalModuleReference = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitModuleNameModuleReference = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitImportDeclaration = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitExportAssignment = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitClassDeclaration = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitInterfaceDeclaration = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitHeritageClause = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitModuleDeclaration = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitFunctionDeclaration = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitVariableStatement = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitVariableDeclaration = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitVariableDeclarator = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitEqualsValueClause = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitPrefixUnaryExpression = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitArrayLiteralExpression = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitOmittedExpression = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitParenthesizedExpression = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitSimpleArrowFunctionExpression = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitParenthesizedArrowFunctionExpression = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitQualifiedName = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitTypeArgumentList = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitConstructorType = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitFunctionType = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitObjectType = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitArrayType = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitGenericType = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitTypeAnnotation = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitBlock = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitParameter = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitMemberAccessExpression = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitPostfixUnaryExpression = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitElementAccessExpression = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitInvocationExpression = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitArgumentList = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitBinaryExpression = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitConditionalExpression = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitConstructSignature = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitMethodSignature = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitIndexSignature = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitPropertySignature = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitCallSignature = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitParameterList = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitTypeParameterList = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitTypeParameter = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitConstraint = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitElseClause = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitIfStatement = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitExpressionStatement = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitConstructorDeclaration = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitMemberFunctionDeclaration = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitGetMemberAccessorDeclaration = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitSetMemberAccessorDeclaration = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitMemberVariableDeclaration = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitThrowStatement = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitReturnStatement = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitObjectCreationExpression = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitSwitchStatement = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitCaseSwitchClause = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitDefaultSwitchClause = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitBreakStatement = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitContinueStatement = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitForStatement = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitForInStatement = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitWhileStatement = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitWithStatement = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitEnumDeclaration = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitEnumElement = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitCastExpression = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitObjectLiteralExpression = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitSimplePropertyAssignment = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitFunctionPropertyAssignment = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitGetAccessorPropertyAssignment = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitSetAccessorPropertyAssignment = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitFunctionExpression = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitEmptyStatement = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitTryStatement = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitCatchClause = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitFinallyClause = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitLabeledStatement = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitDoStatement = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitTypeOfExpression = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitDeleteExpression = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitVoidExpression = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitDebuggerStatement = function (node) { - return this.defaultVisit(node); - }; - return SyntaxVisitor; - })(); - TypeScript.SyntaxVisitor = SyntaxVisitor; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var SyntaxWalker = (function () { - function SyntaxWalker() { - } - SyntaxWalker.prototype.visitToken = function (token) { - }; - - SyntaxWalker.prototype.visitNode = function (node) { - node.accept(this); - }; - - SyntaxWalker.prototype.visitNodeOrToken = function (nodeOrToken) { - if (nodeOrToken.isToken()) { - this.visitToken(nodeOrToken); - } else { - this.visitNode(nodeOrToken); - } - }; - - SyntaxWalker.prototype.visitOptionalToken = function (token) { - if (token === null) { - return; - } - - this.visitToken(token); - }; - - SyntaxWalker.prototype.visitOptionalNode = function (node) { - if (node === null) { - return; - } - - this.visitNode(node); - }; - - SyntaxWalker.prototype.visitOptionalNodeOrToken = function (nodeOrToken) { - if (nodeOrToken === null) { - return; - } - - this.visitNodeOrToken(nodeOrToken); - }; - - SyntaxWalker.prototype.visitList = function (list) { - for (var i = 0, n = list.childCount(); i < n; i++) { - this.visitNodeOrToken(list.childAt(i)); - } - }; - - SyntaxWalker.prototype.visitSeparatedList = function (list) { - for (var i = 0, n = list.childCount(); i < n; i++) { - var item = list.childAt(i); - this.visitNodeOrToken(item); - } - }; - - SyntaxWalker.prototype.visitSourceUnit = function (node) { - this.visitList(node.moduleElements); - this.visitToken(node.endOfFileToken); - }; - - SyntaxWalker.prototype.visitExternalModuleReference = function (node) { - this.visitToken(node.moduleOrRequireKeyword); - this.visitToken(node.openParenToken); - this.visitToken(node.stringLiteral); - this.visitToken(node.closeParenToken); - }; - - SyntaxWalker.prototype.visitModuleNameModuleReference = function (node) { - this.visitNodeOrToken(node.moduleName); - }; - - SyntaxWalker.prototype.visitImportDeclaration = function (node) { - this.visitToken(node.importKeyword); - this.visitToken(node.identifier); - this.visitToken(node.equalsToken); - this.visitNode(node.moduleReference); - this.visitToken(node.semicolonToken); - }; - - SyntaxWalker.prototype.visitExportAssignment = function (node) { - this.visitToken(node.exportKeyword); - this.visitToken(node.equalsToken); - this.visitToken(node.identifier); - this.visitToken(node.semicolonToken); - }; - - SyntaxWalker.prototype.visitClassDeclaration = function (node) { - this.visitList(node.modifiers); - this.visitToken(node.classKeyword); - this.visitToken(node.identifier); - this.visitOptionalNode(node.typeParameterList); - this.visitList(node.heritageClauses); - this.visitToken(node.openBraceToken); - this.visitList(node.classElements); - this.visitToken(node.closeBraceToken); - }; - - SyntaxWalker.prototype.visitInterfaceDeclaration = function (node) { - this.visitList(node.modifiers); - this.visitToken(node.interfaceKeyword); - this.visitToken(node.identifier); - this.visitOptionalNode(node.typeParameterList); - this.visitList(node.heritageClauses); - this.visitNode(node.body); - }; - - SyntaxWalker.prototype.visitHeritageClause = function (node) { - this.visitToken(node.extendsOrImplementsKeyword); - this.visitSeparatedList(node.typeNames); - }; - - SyntaxWalker.prototype.visitModuleDeclaration = function (node) { - this.visitList(node.modifiers); - this.visitToken(node.moduleKeyword); - this.visitOptionalNodeOrToken(node.moduleName); - this.visitOptionalToken(node.stringLiteral); - this.visitToken(node.openBraceToken); - this.visitList(node.moduleElements); - this.visitToken(node.closeBraceToken); - }; - - SyntaxWalker.prototype.visitFunctionDeclaration = function (node) { - this.visitList(node.modifiers); - this.visitToken(node.functionKeyword); - this.visitToken(node.identifier); - this.visitNode(node.callSignature); - this.visitOptionalNode(node.block); - this.visitOptionalToken(node.semicolonToken); - }; - - SyntaxWalker.prototype.visitVariableStatement = function (node) { - this.visitList(node.modifiers); - this.visitNode(node.variableDeclaration); - this.visitToken(node.semicolonToken); - }; - - SyntaxWalker.prototype.visitVariableDeclaration = function (node) { - this.visitToken(node.varKeyword); - this.visitSeparatedList(node.variableDeclarators); - }; - - SyntaxWalker.prototype.visitVariableDeclarator = function (node) { - this.visitToken(node.identifier); - this.visitOptionalNode(node.typeAnnotation); - this.visitOptionalNode(node.equalsValueClause); - }; - - SyntaxWalker.prototype.visitEqualsValueClause = function (node) { - this.visitToken(node.equalsToken); - this.visitNodeOrToken(node.value); - }; - - SyntaxWalker.prototype.visitPrefixUnaryExpression = function (node) { - this.visitToken(node.operatorToken); - this.visitNodeOrToken(node.operand); - }; - - SyntaxWalker.prototype.visitArrayLiteralExpression = function (node) { - this.visitToken(node.openBracketToken); - this.visitSeparatedList(node.expressions); - this.visitToken(node.closeBracketToken); - }; - - SyntaxWalker.prototype.visitOmittedExpression = function (node) { - }; - - SyntaxWalker.prototype.visitParenthesizedExpression = function (node) { - this.visitToken(node.openParenToken); - this.visitNodeOrToken(node.expression); - this.visitToken(node.closeParenToken); - }; - - SyntaxWalker.prototype.visitSimpleArrowFunctionExpression = function (node) { - this.visitToken(node.identifier); - this.visitToken(node.equalsGreaterThanToken); - this.visitNodeOrToken(node.body); - }; - - SyntaxWalker.prototype.visitParenthesizedArrowFunctionExpression = function (node) { - this.visitNode(node.callSignature); - this.visitToken(node.equalsGreaterThanToken); - this.visitNodeOrToken(node.body); - }; - - SyntaxWalker.prototype.visitQualifiedName = function (node) { - this.visitNodeOrToken(node.left); - this.visitToken(node.dotToken); - this.visitToken(node.right); - }; - - SyntaxWalker.prototype.visitTypeArgumentList = function (node) { - this.visitToken(node.lessThanToken); - this.visitSeparatedList(node.typeArguments); - this.visitToken(node.greaterThanToken); - }; - - SyntaxWalker.prototype.visitConstructorType = function (node) { - this.visitToken(node.newKeyword); - this.visitOptionalNode(node.typeParameterList); - this.visitNode(node.parameterList); - this.visitToken(node.equalsGreaterThanToken); - this.visitNodeOrToken(node.type); - }; - - SyntaxWalker.prototype.visitFunctionType = function (node) { - this.visitOptionalNode(node.typeParameterList); - this.visitNode(node.parameterList); - this.visitToken(node.equalsGreaterThanToken); - this.visitNodeOrToken(node.type); - }; - - SyntaxWalker.prototype.visitObjectType = function (node) { - this.visitToken(node.openBraceToken); - this.visitSeparatedList(node.typeMembers); - this.visitToken(node.closeBraceToken); - }; - - SyntaxWalker.prototype.visitArrayType = function (node) { - this.visitNodeOrToken(node.type); - this.visitToken(node.openBracketToken); - this.visitToken(node.closeBracketToken); - }; - - SyntaxWalker.prototype.visitGenericType = function (node) { - this.visitNodeOrToken(node.name); - this.visitNode(node.typeArgumentList); - }; - - SyntaxWalker.prototype.visitTypeAnnotation = function (node) { - this.visitToken(node.colonToken); - this.visitNodeOrToken(node.type); - }; - - SyntaxWalker.prototype.visitBlock = function (node) { - this.visitToken(node.openBraceToken); - this.visitList(node.statements); - this.visitToken(node.closeBraceToken); - }; - - SyntaxWalker.prototype.visitParameter = function (node) { - this.visitOptionalToken(node.dotDotDotToken); - this.visitOptionalToken(node.publicOrPrivateKeyword); - this.visitToken(node.identifier); - this.visitOptionalToken(node.questionToken); - this.visitOptionalNode(node.typeAnnotation); - this.visitOptionalNode(node.equalsValueClause); - }; - - SyntaxWalker.prototype.visitMemberAccessExpression = function (node) { - this.visitNodeOrToken(node.expression); - this.visitToken(node.dotToken); - this.visitToken(node.name); - }; - - SyntaxWalker.prototype.visitPostfixUnaryExpression = function (node) { - this.visitNodeOrToken(node.operand); - this.visitToken(node.operatorToken); - }; - - SyntaxWalker.prototype.visitElementAccessExpression = function (node) { - this.visitNodeOrToken(node.expression); - this.visitToken(node.openBracketToken); - this.visitNodeOrToken(node.argumentExpression); - this.visitToken(node.closeBracketToken); - }; - - SyntaxWalker.prototype.visitInvocationExpression = function (node) { - this.visitNodeOrToken(node.expression); - this.visitNode(node.argumentList); - }; - - SyntaxWalker.prototype.visitArgumentList = function (node) { - this.visitOptionalNode(node.typeArgumentList); - this.visitToken(node.openParenToken); - this.visitSeparatedList(node.arguments); - this.visitToken(node.closeParenToken); - }; - - SyntaxWalker.prototype.visitBinaryExpression = function (node) { - this.visitNodeOrToken(node.left); - this.visitToken(node.operatorToken); - this.visitNodeOrToken(node.right); - }; - - SyntaxWalker.prototype.visitConditionalExpression = function (node) { - this.visitNodeOrToken(node.condition); - this.visitToken(node.questionToken); - this.visitNodeOrToken(node.whenTrue); - this.visitToken(node.colonToken); - this.visitNodeOrToken(node.whenFalse); - }; - - SyntaxWalker.prototype.visitConstructSignature = function (node) { - this.visitToken(node.newKeyword); - this.visitNode(node.callSignature); - }; - - SyntaxWalker.prototype.visitMethodSignature = function (node) { - this.visitToken(node.propertyName); - this.visitOptionalToken(node.questionToken); - this.visitNode(node.callSignature); - }; - - SyntaxWalker.prototype.visitIndexSignature = function (node) { - this.visitToken(node.openBracketToken); - this.visitNode(node.parameter); - this.visitToken(node.closeBracketToken); - this.visitOptionalNode(node.typeAnnotation); - }; - - SyntaxWalker.prototype.visitPropertySignature = function (node) { - this.visitToken(node.propertyName); - this.visitOptionalToken(node.questionToken); - this.visitOptionalNode(node.typeAnnotation); - }; - - SyntaxWalker.prototype.visitCallSignature = function (node) { - this.visitOptionalNode(node.typeParameterList); - this.visitNode(node.parameterList); - this.visitOptionalNode(node.typeAnnotation); - }; - - SyntaxWalker.prototype.visitParameterList = function (node) { - this.visitToken(node.openParenToken); - this.visitSeparatedList(node.parameters); - this.visitToken(node.closeParenToken); - }; - - SyntaxWalker.prototype.visitTypeParameterList = function (node) { - this.visitToken(node.lessThanToken); - this.visitSeparatedList(node.typeParameters); - this.visitToken(node.greaterThanToken); - }; - - SyntaxWalker.prototype.visitTypeParameter = function (node) { - this.visitToken(node.identifier); - this.visitOptionalNode(node.constraint); - }; - - SyntaxWalker.prototype.visitConstraint = function (node) { - this.visitToken(node.extendsKeyword); - this.visitNodeOrToken(node.type); - }; - - SyntaxWalker.prototype.visitElseClause = function (node) { - this.visitToken(node.elseKeyword); - this.visitNodeOrToken(node.statement); - }; - - SyntaxWalker.prototype.visitIfStatement = function (node) { - this.visitToken(node.ifKeyword); - this.visitToken(node.openParenToken); - this.visitNodeOrToken(node.condition); - this.visitToken(node.closeParenToken); - this.visitNodeOrToken(node.statement); - this.visitOptionalNode(node.elseClause); - }; - - SyntaxWalker.prototype.visitExpressionStatement = function (node) { - this.visitNodeOrToken(node.expression); - this.visitToken(node.semicolonToken); - }; - - SyntaxWalker.prototype.visitConstructorDeclaration = function (node) { - this.visitToken(node.constructorKeyword); - this.visitNode(node.parameterList); - this.visitOptionalNode(node.block); - this.visitOptionalToken(node.semicolonToken); - }; - - SyntaxWalker.prototype.visitMemberFunctionDeclaration = function (node) { - this.visitList(node.modifiers); - this.visitToken(node.propertyName); - this.visitNode(node.callSignature); - this.visitOptionalNode(node.block); - this.visitOptionalToken(node.semicolonToken); - }; - - SyntaxWalker.prototype.visitGetMemberAccessorDeclaration = function (node) { - this.visitList(node.modifiers); - this.visitToken(node.getKeyword); - this.visitToken(node.propertyName); - this.visitNode(node.parameterList); - this.visitOptionalNode(node.typeAnnotation); - this.visitNode(node.block); - }; - - SyntaxWalker.prototype.visitSetMemberAccessorDeclaration = function (node) { - this.visitList(node.modifiers); - this.visitToken(node.setKeyword); - this.visitToken(node.propertyName); - this.visitNode(node.parameterList); - this.visitNode(node.block); - }; - - SyntaxWalker.prototype.visitMemberVariableDeclaration = function (node) { - this.visitList(node.modifiers); - this.visitNode(node.variableDeclarator); - this.visitToken(node.semicolonToken); - }; - - SyntaxWalker.prototype.visitThrowStatement = function (node) { - this.visitToken(node.throwKeyword); - this.visitNodeOrToken(node.expression); - this.visitToken(node.semicolonToken); - }; - - SyntaxWalker.prototype.visitReturnStatement = function (node) { - this.visitToken(node.returnKeyword); - this.visitOptionalNodeOrToken(node.expression); - this.visitToken(node.semicolonToken); - }; - - SyntaxWalker.prototype.visitObjectCreationExpression = function (node) { - this.visitToken(node.newKeyword); - this.visitNodeOrToken(node.expression); - this.visitOptionalNode(node.argumentList); - }; - - SyntaxWalker.prototype.visitSwitchStatement = function (node) { - this.visitToken(node.switchKeyword); - this.visitToken(node.openParenToken); - this.visitNodeOrToken(node.expression); - this.visitToken(node.closeParenToken); - this.visitToken(node.openBraceToken); - this.visitList(node.switchClauses); - this.visitToken(node.closeBraceToken); - }; - - SyntaxWalker.prototype.visitCaseSwitchClause = function (node) { - this.visitToken(node.caseKeyword); - this.visitNodeOrToken(node.expression); - this.visitToken(node.colonToken); - this.visitList(node.statements); - }; - - SyntaxWalker.prototype.visitDefaultSwitchClause = function (node) { - this.visitToken(node.defaultKeyword); - this.visitToken(node.colonToken); - this.visitList(node.statements); - }; - - SyntaxWalker.prototype.visitBreakStatement = function (node) { - this.visitToken(node.breakKeyword); - this.visitOptionalToken(node.identifier); - this.visitToken(node.semicolonToken); - }; - - SyntaxWalker.prototype.visitContinueStatement = function (node) { - this.visitToken(node.continueKeyword); - this.visitOptionalToken(node.identifier); - this.visitToken(node.semicolonToken); - }; - - SyntaxWalker.prototype.visitForStatement = function (node) { - this.visitToken(node.forKeyword); - this.visitToken(node.openParenToken); - this.visitOptionalNode(node.variableDeclaration); - this.visitOptionalNodeOrToken(node.initializer); - this.visitToken(node.firstSemicolonToken); - this.visitOptionalNodeOrToken(node.condition); - this.visitToken(node.secondSemicolonToken); - this.visitOptionalNodeOrToken(node.incrementor); - this.visitToken(node.closeParenToken); - this.visitNodeOrToken(node.statement); - }; - - SyntaxWalker.prototype.visitForInStatement = function (node) { - this.visitToken(node.forKeyword); - this.visitToken(node.openParenToken); - this.visitOptionalNode(node.variableDeclaration); - this.visitOptionalNodeOrToken(node.left); - this.visitToken(node.inKeyword); - this.visitNodeOrToken(node.expression); - this.visitToken(node.closeParenToken); - this.visitNodeOrToken(node.statement); - }; - - SyntaxWalker.prototype.visitWhileStatement = function (node) { - this.visitToken(node.whileKeyword); - this.visitToken(node.openParenToken); - this.visitNodeOrToken(node.condition); - this.visitToken(node.closeParenToken); - this.visitNodeOrToken(node.statement); - }; - - SyntaxWalker.prototype.visitWithStatement = function (node) { - this.visitToken(node.withKeyword); - this.visitToken(node.openParenToken); - this.visitNodeOrToken(node.condition); - this.visitToken(node.closeParenToken); - this.visitNodeOrToken(node.statement); - }; - - SyntaxWalker.prototype.visitEnumDeclaration = function (node) { - this.visitList(node.modifiers); - this.visitToken(node.enumKeyword); - this.visitToken(node.identifier); - this.visitToken(node.openBraceToken); - this.visitSeparatedList(node.enumElements); - this.visitToken(node.closeBraceToken); - }; - - SyntaxWalker.prototype.visitEnumElement = function (node) { - this.visitToken(node.propertyName); - this.visitOptionalNode(node.equalsValueClause); - }; - - SyntaxWalker.prototype.visitCastExpression = function (node) { - this.visitToken(node.lessThanToken); - this.visitNodeOrToken(node.type); - this.visitToken(node.greaterThanToken); - this.visitNodeOrToken(node.expression); - }; - - SyntaxWalker.prototype.visitObjectLiteralExpression = function (node) { - this.visitToken(node.openBraceToken); - this.visitSeparatedList(node.propertyAssignments); - this.visitToken(node.closeBraceToken); - }; - - SyntaxWalker.prototype.visitSimplePropertyAssignment = function (node) { - this.visitToken(node.propertyName); - this.visitToken(node.colonToken); - this.visitNodeOrToken(node.expression); - }; - - SyntaxWalker.prototype.visitFunctionPropertyAssignment = function (node) { - this.visitToken(node.propertyName); - this.visitNode(node.callSignature); - this.visitNode(node.block); - }; - - SyntaxWalker.prototype.visitGetAccessorPropertyAssignment = function (node) { - this.visitToken(node.getKeyword); - this.visitToken(node.propertyName); - this.visitToken(node.openParenToken); - this.visitToken(node.closeParenToken); - this.visitOptionalNode(node.typeAnnotation); - this.visitNode(node.block); - }; - - SyntaxWalker.prototype.visitSetAccessorPropertyAssignment = function (node) { - this.visitToken(node.setKeyword); - this.visitToken(node.propertyName); - this.visitToken(node.openParenToken); - this.visitNode(node.parameter); - this.visitToken(node.closeParenToken); - this.visitNode(node.block); - }; - - SyntaxWalker.prototype.visitFunctionExpression = function (node) { - this.visitToken(node.functionKeyword); - this.visitOptionalToken(node.identifier); - this.visitNode(node.callSignature); - this.visitNode(node.block); - }; - - SyntaxWalker.prototype.visitEmptyStatement = function (node) { - this.visitToken(node.semicolonToken); - }; - - SyntaxWalker.prototype.visitTryStatement = function (node) { - this.visitToken(node.tryKeyword); - this.visitNode(node.block); - this.visitOptionalNode(node.catchClause); - this.visitOptionalNode(node.finallyClause); - }; - - SyntaxWalker.prototype.visitCatchClause = function (node) { - this.visitToken(node.catchKeyword); - this.visitToken(node.openParenToken); - this.visitToken(node.identifier); - this.visitOptionalNode(node.typeAnnotation); - this.visitToken(node.closeParenToken); - this.visitNode(node.block); - }; - - SyntaxWalker.prototype.visitFinallyClause = function (node) { - this.visitToken(node.finallyKeyword); - this.visitNode(node.block); - }; - - SyntaxWalker.prototype.visitLabeledStatement = function (node) { - this.visitToken(node.identifier); - this.visitToken(node.colonToken); - this.visitNodeOrToken(node.statement); - }; - - SyntaxWalker.prototype.visitDoStatement = function (node) { - this.visitToken(node.doKeyword); - this.visitNodeOrToken(node.statement); - this.visitToken(node.whileKeyword); - this.visitToken(node.openParenToken); - this.visitNodeOrToken(node.condition); - this.visitToken(node.closeParenToken); - this.visitToken(node.semicolonToken); - }; - - SyntaxWalker.prototype.visitTypeOfExpression = function (node) { - this.visitToken(node.typeOfKeyword); - this.visitNodeOrToken(node.expression); - }; - - SyntaxWalker.prototype.visitDeleteExpression = function (node) { - this.visitToken(node.deleteKeyword); - this.visitNodeOrToken(node.expression); - }; - - SyntaxWalker.prototype.visitVoidExpression = function (node) { - this.visitToken(node.voidKeyword); - this.visitNodeOrToken(node.expression); - }; - - SyntaxWalker.prototype.visitDebuggerStatement = function (node) { - this.visitToken(node.debuggerKeyword); - this.visitToken(node.semicolonToken); - }; - return SyntaxWalker; - })(); - TypeScript.SyntaxWalker = SyntaxWalker; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var PositionTrackingWalker = (function (_super) { - __extends(PositionTrackingWalker, _super); - function PositionTrackingWalker() { - _super.apply(this, arguments); - this._position = 0; - } - PositionTrackingWalker.prototype.visitToken = function (token) { - this._position += token.fullWidth(); - }; - - PositionTrackingWalker.prototype.position = function () { - return this._position; - }; - - PositionTrackingWalker.prototype.skip = function (element) { - this._position += element.fullWidth(); - }; - return PositionTrackingWalker; - })(TypeScript.SyntaxWalker); - TypeScript.PositionTrackingWalker = PositionTrackingWalker; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var SyntaxInformationMap = (function (_super) { - __extends(SyntaxInformationMap, _super); - function SyntaxInformationMap(trackParents, trackPreviousToken) { - _super.call(this); - this.trackParents = trackParents; - this.trackPreviousToken = trackPreviousToken; - this.tokenToInformation = TypeScript.Collections.createHashTable(TypeScript.Collections.DefaultHashTableCapacity, TypeScript.Collections.identityHashCode); - this.elementToPosition = TypeScript.Collections.createHashTable(TypeScript.Collections.DefaultHashTableCapacity, TypeScript.Collections.identityHashCode); - this._previousToken = null; - this._previousTokenInformation = null; - this._currentPosition = 0; - this._elementToParent = TypeScript.Collections.createHashTable(TypeScript.Collections.DefaultHashTableCapacity, TypeScript.Collections.identityHashCode); - this._parentStack = []; - this._parentStack.push(null); - } - SyntaxInformationMap.create = function (node, trackParents, trackPreviousToken) { - var map = new SyntaxInformationMap(trackParents, trackPreviousToken); - map.visitNode(node); - return map; - }; - - SyntaxInformationMap.prototype.visitNode = function (node) { - this.trackParents && this._elementToParent.add(node, TypeScript.ArrayUtilities.last(this._parentStack)); - this.elementToPosition.add(node, this._currentPosition); - - this.trackParents && this._parentStack.push(node); - _super.prototype.visitNode.call(this, node); - this.trackParents && this._parentStack.pop(); - }; - - SyntaxInformationMap.prototype.visitToken = function (token) { - this.trackParents && this._elementToParent.add(token, TypeScript.ArrayUtilities.last(this._parentStack)); - - if (this.trackPreviousToken) { - var tokenInformation = { - previousToken: this._previousToken, - nextToken: null - }; - - if (this._previousTokenInformation !== null) { - this._previousTokenInformation.nextToken = token; - } - - this._previousToken = token; - this._previousTokenInformation = tokenInformation; - - this.tokenToInformation.add(token, tokenInformation); - } - - this.elementToPosition.add(token, this._currentPosition); - this._currentPosition += token.fullWidth(); - }; - - SyntaxInformationMap.prototype.parent = function (element) { - return this._elementToParent.get(element); - }; - - SyntaxInformationMap.prototype.fullStart = function (element) { - return this.elementToPosition.get(element); - }; - - SyntaxInformationMap.prototype.start = function (element) { - return this.fullStart(element) + element.leadingTriviaWidth(); - }; - - SyntaxInformationMap.prototype.end = function (element) { - return this.start(element) + element.width(); - }; - - SyntaxInformationMap.prototype.previousToken = function (token) { - return this.tokenInformation(token).previousToken; - }; - - SyntaxInformationMap.prototype.tokenInformation = function (token) { - return this.tokenToInformation.get(token); - }; - - SyntaxInformationMap.prototype.firstTokenInLineContainingToken = function (token) { - var current = token; - while (true) { - var information = this.tokenInformation(current); - if (this.isFirstTokenInLineWorker(information)) { - break; - } - - current = information.previousToken; - } - - return current; - }; - - SyntaxInformationMap.prototype.isFirstTokenInLine = function (token) { - var information = this.tokenInformation(token); - return this.isFirstTokenInLineWorker(information); - }; - - SyntaxInformationMap.prototype.isFirstTokenInLineWorker = function (information) { - return information.previousToken === null || information.previousToken.hasTrailingNewLine(); - }; - return SyntaxInformationMap; - })(TypeScript.SyntaxWalker); - TypeScript.SyntaxInformationMap = SyntaxInformationMap; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var SyntaxNodeInvariantsChecker = (function (_super) { - __extends(SyntaxNodeInvariantsChecker, _super); - function SyntaxNodeInvariantsChecker() { - _super.apply(this, arguments); - this.tokenTable = TypeScript.Collections.createHashTable(TypeScript.Collections.DefaultHashTableCapacity, TypeScript.Collections.identityHashCode); - } - SyntaxNodeInvariantsChecker.checkInvariants = function (node) { - node.accept(new SyntaxNodeInvariantsChecker()); - }; - - SyntaxNodeInvariantsChecker.prototype.visitToken = function (token) { - this.tokenTable.add(token, token); - }; - return SyntaxNodeInvariantsChecker; - })(TypeScript.SyntaxWalker); - TypeScript.SyntaxNodeInvariantsChecker = SyntaxNodeInvariantsChecker; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var DepthLimitedWalker = (function (_super) { - __extends(DepthLimitedWalker, _super); - function DepthLimitedWalker(maximumDepth) { - _super.call(this); - this._depth = 0; - this._maximumDepth = 0; - this._maximumDepth = maximumDepth; - } - DepthLimitedWalker.prototype.visitNode = function (node) { - if (this._depth < this._maximumDepth) { - this._depth++; - _super.prototype.visitNode.call(this, node); - this._depth--; - } else { - this.skip(node); - } - }; - return DepthLimitedWalker; - })(TypeScript.PositionTrackingWalker); - TypeScript.DepthLimitedWalker = DepthLimitedWalker; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (Parser) { - var ExpressionPrecedence; - (function (ExpressionPrecedence) { - ExpressionPrecedence[ExpressionPrecedence["CommaExpressionPrecedence"] = 1] = "CommaExpressionPrecedence"; - - ExpressionPrecedence[ExpressionPrecedence["AssignmentExpressionPrecedence"] = 2] = "AssignmentExpressionPrecedence"; - - ExpressionPrecedence[ExpressionPrecedence["ConditionalExpressionPrecedence"] = 3] = "ConditionalExpressionPrecedence"; - - ExpressionPrecedence[ExpressionPrecedence["ArrowFunctionPrecedence"] = 4] = "ArrowFunctionPrecedence"; - - ExpressionPrecedence[ExpressionPrecedence["LogicalOrExpressionPrecedence"] = 5] = "LogicalOrExpressionPrecedence"; - ExpressionPrecedence[ExpressionPrecedence["LogicalAndExpressionPrecedence"] = 6] = "LogicalAndExpressionPrecedence"; - ExpressionPrecedence[ExpressionPrecedence["BitwiseOrExpressionPrecedence"] = 7] = "BitwiseOrExpressionPrecedence"; - ExpressionPrecedence[ExpressionPrecedence["BitwiseExclusiveOrExpressionPrecedence"] = 8] = "BitwiseExclusiveOrExpressionPrecedence"; - ExpressionPrecedence[ExpressionPrecedence["BitwiseAndExpressionPrecedence"] = 9] = "BitwiseAndExpressionPrecedence"; - ExpressionPrecedence[ExpressionPrecedence["EqualityExpressionPrecedence"] = 10] = "EqualityExpressionPrecedence"; - ExpressionPrecedence[ExpressionPrecedence["RelationalExpressionPrecedence"] = 11] = "RelationalExpressionPrecedence"; - ExpressionPrecedence[ExpressionPrecedence["ShiftExpressionPrecdence"] = 12] = "ShiftExpressionPrecdence"; - ExpressionPrecedence[ExpressionPrecedence["AdditiveExpressionPrecedence"] = 13] = "AdditiveExpressionPrecedence"; - ExpressionPrecedence[ExpressionPrecedence["MultiplicativeExpressionPrecedence"] = 14] = "MultiplicativeExpressionPrecedence"; - - ExpressionPrecedence[ExpressionPrecedence["UnaryExpressionPrecedence"] = 15] = "UnaryExpressionPrecedence"; - })(ExpressionPrecedence || (ExpressionPrecedence = {})); - - var ListParsingState; - (function (ListParsingState) { - ListParsingState[ListParsingState["SourceUnit_ModuleElements"] = 1 << 0] = "SourceUnit_ModuleElements"; - ListParsingState[ListParsingState["ClassDeclaration_ClassElements"] = 1 << 1] = "ClassDeclaration_ClassElements"; - ListParsingState[ListParsingState["ModuleDeclaration_ModuleElements"] = 1 << 2] = "ModuleDeclaration_ModuleElements"; - ListParsingState[ListParsingState["SwitchStatement_SwitchClauses"] = 1 << 3] = "SwitchStatement_SwitchClauses"; - ListParsingState[ListParsingState["SwitchClause_Statements"] = 1 << 4] = "SwitchClause_Statements"; - ListParsingState[ListParsingState["Block_Statements"] = 1 << 5] = "Block_Statements"; - ListParsingState[ListParsingState["TryBlock_Statements"] = 1 << 6] = "TryBlock_Statements"; - ListParsingState[ListParsingState["CatchBlock_Statements"] = 1 << 7] = "CatchBlock_Statements"; - ListParsingState[ListParsingState["EnumDeclaration_EnumElements"] = 1 << 8] = "EnumDeclaration_EnumElements"; - ListParsingState[ListParsingState["ObjectType_TypeMembers"] = 1 << 9] = "ObjectType_TypeMembers"; - ListParsingState[ListParsingState["ClassOrInterfaceDeclaration_HeritageClauses"] = 1 << 10] = "ClassOrInterfaceDeclaration_HeritageClauses"; - ListParsingState[ListParsingState["HeritageClause_TypeNameList"] = 1 << 11] = "HeritageClause_TypeNameList"; - ListParsingState[ListParsingState["VariableDeclaration_VariableDeclarators_AllowIn"] = 1 << 12] = "VariableDeclaration_VariableDeclarators_AllowIn"; - ListParsingState[ListParsingState["VariableDeclaration_VariableDeclarators_DisallowIn"] = 1 << 13] = "VariableDeclaration_VariableDeclarators_DisallowIn"; - ListParsingState[ListParsingState["ArgumentList_AssignmentExpressions"] = 1 << 14] = "ArgumentList_AssignmentExpressions"; - ListParsingState[ListParsingState["ObjectLiteralExpression_PropertyAssignments"] = 1 << 15] = "ObjectLiteralExpression_PropertyAssignments"; - ListParsingState[ListParsingState["ArrayLiteralExpression_AssignmentExpressions"] = 1 << 16] = "ArrayLiteralExpression_AssignmentExpressions"; - ListParsingState[ListParsingState["ParameterList_Parameters"] = 1 << 17] = "ParameterList_Parameters"; - ListParsingState[ListParsingState["TypeArgumentList_Types"] = 1 << 18] = "TypeArgumentList_Types"; - ListParsingState[ListParsingState["TypeParameterList_TypeParameters"] = 1 << 19] = "TypeParameterList_TypeParameters"; - - ListParsingState[ListParsingState["FirstListParsingState"] = ListParsingState.SourceUnit_ModuleElements] = "FirstListParsingState"; - ListParsingState[ListParsingState["LastListParsingState"] = ListParsingState.TypeArgumentList_Types] = "LastListParsingState"; - })(ListParsingState || (ListParsingState = {})); - - var SyntaxCursor = (function () { - function SyntaxCursor(sourceUnit) { - this._elements = []; - this._index = 0; - this._pinCount = 0; - sourceUnit.insertChildrenInto(this._elements, 0); - } - SyntaxCursor.prototype.isFinished = function () { - return this._index === this._elements.length; - }; - - SyntaxCursor.prototype.currentElement = function () { - if (this.isFinished()) { - return null; - } - - return this._elements[this._index]; - }; - - SyntaxCursor.prototype.currentNode = function () { - var element = this.currentElement(); - return element !== null && element.isNode() ? element : null; - }; - - SyntaxCursor.prototype.moveToFirstChild = function () { - if (this.isFinished()) { - return; - } - - var element = this._elements[this._index]; - if (element.isToken()) { - return; - } - - var node = element; - - this._elements.splice(this._index, 1); - - node.insertChildrenInto(this._elements, this._index); - }; - - SyntaxCursor.prototype.moveToNextSibling = function () { - if (this.isFinished()) { - return; - } - - if (this._pinCount > 0) { - this._index++; - return; - } - - this._elements.shift(); - }; - - SyntaxCursor.prototype.getAndPinCursorIndex = function () { - this._pinCount++; - return this._index; - }; - - SyntaxCursor.prototype.releaseAndUnpinCursorIndex = function (index) { - this._pinCount--; - if (this._pinCount === 0) { - } - }; - - SyntaxCursor.prototype.rewindToPinnedCursorIndex = function (index) { - this._index = index; - }; - - SyntaxCursor.prototype.pinCount = function () { - return this._pinCount; - }; - - SyntaxCursor.prototype.moveToFirstToken = function () { - var element; - - while (!this.isFinished()) { - element = this.currentElement(); - if (element.isNode()) { - this.moveToFirstChild(); - continue; - } - - return; - } - }; - - SyntaxCursor.prototype.currentToken = function () { - this.moveToFirstToken(); - if (this.isFinished()) { - return null; - } - - var element = this.currentElement(); - - return element; - }; - - SyntaxCursor.prototype.peekToken = function (n) { - this.moveToFirstToken(); - var pin = this.getAndPinCursorIndex(); - try { - for (var i = 0; i < n; i++) { - this.moveToNextSibling(); - this.moveToFirstToken(); - } - - return this.currentToken(); - } finally { - this.rewindToPinnedCursorIndex(pin); - this.releaseAndUnpinCursorIndex(pin); - } - }; - return SyntaxCursor; - })(); - - var NormalParserSource = (function () { - function NormalParserSource(fileName, text, languageVersion) { - this._previousToken = null; - this._absolutePosition = 0; - this._tokenDiagnostics = []; - this.rewindPointPool = []; - this.rewindPointPoolCount = 0; - this.slidingWindow = new TypeScript.SlidingWindow(this, TypeScript.ArrayUtilities.createArray(32, null), null); - this.scanner = new TypeScript.Scanner(fileName, text, languageVersion); - } - NormalParserSource.prototype.languageVersion = function () { - return this.scanner.languageVersion(); - }; - - NormalParserSource.prototype.currentNode = function () { - return null; - }; - - NormalParserSource.prototype.moveToNextNode = function () { - throw TypeScript.Errors.invalidOperation(); - }; - - NormalParserSource.prototype.absolutePosition = function () { - return this._absolutePosition; - }; - - NormalParserSource.prototype.previousToken = function () { - return this._previousToken; - }; - - NormalParserSource.prototype.tokenDiagnostics = function () { - return this._tokenDiagnostics; - }; - - NormalParserSource.prototype.getOrCreateRewindPoint = function () { - if (this.rewindPointPoolCount === 0) { - return {}; - } - - this.rewindPointPoolCount--; - var result = this.rewindPointPool[this.rewindPointPoolCount]; - this.rewindPointPool[this.rewindPointPoolCount] = null; - return result; - }; - - NormalParserSource.prototype.getRewindPoint = function () { - var slidingWindowIndex = this.slidingWindow.getAndPinAbsoluteIndex(); - - var rewindPoint = this.getOrCreateRewindPoint(); - - rewindPoint.slidingWindowIndex = slidingWindowIndex; - rewindPoint.previousToken = this._previousToken; - rewindPoint.absolutePosition = this._absolutePosition; - - rewindPoint.pinCount = this.slidingWindow.pinCount(); - - return rewindPoint; - }; - - NormalParserSource.prototype.isPinned = function () { - return this.slidingWindow.pinCount() > 0; - }; - - NormalParserSource.prototype.rewind = function (rewindPoint) { - this.slidingWindow.rewindToPinnedIndex(rewindPoint.slidingWindowIndex); - - this._previousToken = rewindPoint.previousToken; - this._absolutePosition = rewindPoint.absolutePosition; - }; - - NormalParserSource.prototype.releaseRewindPoint = function (rewindPoint) { - this.slidingWindow.releaseAndUnpinAbsoluteIndex((rewindPoint).absoluteIndex); - - this.rewindPointPool[this.rewindPointPoolCount] = rewindPoint; - this.rewindPointPoolCount++; - }; - - NormalParserSource.prototype.fetchMoreItems = function (allowRegularExpression, sourceIndex, window, destinationIndex, spaceAvailable) { - window[destinationIndex] = this.scanner.scan(this._tokenDiagnostics, allowRegularExpression); - return 1; - }; - - NormalParserSource.prototype.peekToken = function (n) { - return this.slidingWindow.peekItemN(n); - }; - - NormalParserSource.prototype.moveToNextToken = function () { - var currentToken = this.currentToken(); - this._absolutePosition += currentToken.fullWidth(); - this._previousToken = currentToken; - - this.slidingWindow.moveToNextItem(); - }; - - NormalParserSource.prototype.currentToken = function () { - return this.slidingWindow.currentItem(false); - }; - - NormalParserSource.prototype.removeDiagnosticsOnOrAfterPosition = function (position) { - var tokenDiagnosticsLength = this._tokenDiagnostics.length; - while (tokenDiagnosticsLength > 0) { - var diagnostic = this._tokenDiagnostics[tokenDiagnosticsLength - 1]; - if (diagnostic.start() >= position) { - tokenDiagnosticsLength--; - } else { - break; - } - } - - this._tokenDiagnostics.length = tokenDiagnosticsLength; - }; - - NormalParserSource.prototype.resetToPosition = function (absolutePosition, previousToken) { - this._absolutePosition = absolutePosition; - this._previousToken = previousToken; - - this.removeDiagnosticsOnOrAfterPosition(absolutePosition); - - this.slidingWindow.disgardAllItemsFromCurrentIndexOnwards(); - - this.scanner.setAbsoluteIndex(absolutePosition); - }; - - NormalParserSource.prototype.currentTokenAllowingRegularExpression = function () { - this.resetToPosition(this._absolutePosition, this._previousToken); - - var token = this.slidingWindow.currentItem(true); - - return token; - }; - return NormalParserSource; - })(); - - var IncrementalParserSource = (function () { - function IncrementalParserSource(oldSyntaxTree, textChangeRange, newText) { - this._changeDelta = 0; - var oldSourceUnit = oldSyntaxTree.sourceUnit(); - this._oldSourceUnitCursor = new SyntaxCursor(oldSourceUnit); - - this._changeRange = IncrementalParserSource.extendToAffectedRange(textChangeRange, oldSourceUnit); - - this._normalParserSource = new NormalParserSource(oldSyntaxTree.fileName(), newText, oldSyntaxTree.languageVersion()); - } - IncrementalParserSource.extendToAffectedRange = function (changeRange, sourceUnit) { - var maxLookahead = 1; - - var start = changeRange.span().start(); - - for (var i = 0; start > 0 && i <= maxLookahead; i++) { - var token = sourceUnit.findToken(start); - - var position = token.fullStart(); - - start = TypeScript.MathPrototype.max(0, position - 1); - } - - var finalSpan = TypeScript.TextSpan.fromBounds(start, changeRange.span().end()); - var finalLength = changeRange.newLength() + (changeRange.span().start() - start); - - return new TypeScript.TextChangeRange(finalSpan, finalLength); - }; - - IncrementalParserSource.prototype.languageVersion = function () { - return this._normalParserSource.languageVersion(); - }; - - IncrementalParserSource.prototype.absolutePosition = function () { - return this._normalParserSource.absolutePosition(); - }; - - IncrementalParserSource.prototype.previousToken = function () { - return this._normalParserSource.previousToken(); - }; - - IncrementalParserSource.prototype.tokenDiagnostics = function () { - return this._normalParserSource.tokenDiagnostics(); - }; - - IncrementalParserSource.prototype.getRewindPoint = function () { - var rewindPoint = this._normalParserSource.getRewindPoint(); - var oldSourceUnitCursorIndex = this._oldSourceUnitCursor.getAndPinCursorIndex(); - - rewindPoint.changeDelta = this._changeDelta; - rewindPoint.changeRange = this._changeRange; - rewindPoint.oldSourceUnitCursorIndex = oldSourceUnitCursorIndex; - - return rewindPoint; - }; - - IncrementalParserSource.prototype.rewind = function (rewindPoint) { - this._changeRange = rewindPoint.changeRange; - this._changeDelta = rewindPoint.changeDelta; - this._oldSourceUnitCursor.rewindToPinnedCursorIndex(rewindPoint.oldSourceUnitCursorIndex); - - this._normalParserSource.rewind(rewindPoint); - }; - - IncrementalParserSource.prototype.releaseRewindPoint = function (rewindPoint) { - this._oldSourceUnitCursor.releaseAndUnpinCursorIndex(rewindPoint.oldSourceUnitCursorIndex); - this._normalParserSource.releaseRewindPoint(rewindPoint); - }; - - IncrementalParserSource.prototype.canReadFromOldSourceUnit = function () { - if (this._normalParserSource.isPinned()) { - return false; - } - - if (this._changeRange !== null && this._changeRange.newSpan().intersectsWithPosition(this.absolutePosition())) { - return false; - } - - this.syncCursorToNewTextIfBehind(); - - return this._changeDelta === 0 && !this._oldSourceUnitCursor.isFinished(); - }; - - IncrementalParserSource.prototype.currentNode = function () { - if (this.canReadFromOldSourceUnit()) { - return this.tryGetNodeFromOldSourceUnit(); - } - - return null; - }; - - IncrementalParserSource.prototype.currentToken = function () { - if (this.canReadFromOldSourceUnit()) { - var token = this.tryGetTokenFromOldSourceUnit(); - if (token !== null) { - return token; - } - } - - return this._normalParserSource.currentToken(); - }; - - IncrementalParserSource.prototype.currentTokenAllowingRegularExpression = function () { - return this._normalParserSource.currentTokenAllowingRegularExpression(); - }; - - IncrementalParserSource.prototype.syncCursorToNewTextIfBehind = function () { - while (true) { - if (this._oldSourceUnitCursor.isFinished()) { - break; - } - - if (this._changeDelta >= 0) { - break; - } - - var currentElement = this._oldSourceUnitCursor.currentElement(); - - if (currentElement.isNode() && (currentElement.fullWidth() > Math.abs(this._changeDelta))) { - this._oldSourceUnitCursor.moveToFirstChild(); - } else { - this._oldSourceUnitCursor.moveToNextSibling(); - - this._changeDelta += currentElement.fullWidth(); - } - } - }; - - IncrementalParserSource.prototype.intersectsWithChangeRangeSpanInOriginalText = function (start, length) { - return this._changeRange !== null && this._changeRange.span().intersectsWith(start, length); - }; - - IncrementalParserSource.prototype.tryGetNodeFromOldSourceUnit = function () { - while (true) { - var node = this._oldSourceUnitCursor.currentNode(); - if (node === null) { - return null; - } - - if (!this.intersectsWithChangeRangeSpanInOriginalText(this.absolutePosition(), node.fullWidth())) { - if (!node.isIncrementallyUnusable()) { - return node; - } - } - - this._oldSourceUnitCursor.moveToFirstChild(); - } - }; - - IncrementalParserSource.prototype.canReuseTokenFromOldSourceUnit = function (position, token) { - if (token !== null) { - if (!this.intersectsWithChangeRangeSpanInOriginalText(position, token.fullWidth())) { - if (!token.isIncrementallyUnusable()) { - return true; - } - } - } - - return false; - }; - - IncrementalParserSource.prototype.tryGetTokenFromOldSourceUnit = function () { - var token = this._oldSourceUnitCursor.currentToken(); - - return this.canReuseTokenFromOldSourceUnit(this.absolutePosition(), token) ? token : null; - }; - - IncrementalParserSource.prototype.peekToken = function (n) { - if (this.canReadFromOldSourceUnit()) { - var token = this.tryPeekTokenFromOldSourceUnit(n); - if (token !== null) { - return token; - } - } - - return this._normalParserSource.peekToken(n); - }; - - IncrementalParserSource.prototype.tryPeekTokenFromOldSourceUnit = function (n) { - var currentPosition = this.absolutePosition(); - for (var i = 0; i < n; i++) { - var interimToken = this._oldSourceUnitCursor.peekToken(i); - if (!this.canReuseTokenFromOldSourceUnit(currentPosition, interimToken)) { - return null; - } - - currentPosition += interimToken.fullWidth(); - } - - var token = this._oldSourceUnitCursor.peekToken(n); - return this.canReuseTokenFromOldSourceUnit(currentPosition, token) ? token : null; - }; - - IncrementalParserSource.prototype.moveToNextNode = function () { - var currentElement = this._oldSourceUnitCursor.currentElement(); - var currentNode = this._oldSourceUnitCursor.currentNode(); - - this._oldSourceUnitCursor.moveToNextSibling(); - - var absolutePosition = this.absolutePosition() + currentNode.fullWidth(); - var previousToken = currentNode.lastToken(); - this._normalParserSource.resetToPosition(absolutePosition, previousToken); - - if (this._changeRange !== null) { - } - }; - - IncrementalParserSource.prototype.moveToNextToken = function () { - var currentToken = this.currentToken(); - - if (this._oldSourceUnitCursor.currentToken() === currentToken) { - this._oldSourceUnitCursor.moveToNextSibling(); - - var absolutePosition = this.absolutePosition() + currentToken.fullWidth(); - var previousToken = currentToken; - this._normalParserSource.resetToPosition(absolutePosition, previousToken); - - if (this._changeRange !== null) { - } - } else { - this._changeDelta -= currentToken.fullWidth(); - - this._normalParserSource.moveToNextToken(); - - if (this._changeRange !== null) { - var changeRangeSpanInNewText = this._changeRange.newSpan(); - if (this.absolutePosition() >= changeRangeSpanInNewText.end()) { - this._changeDelta += this._changeRange.newLength() - this._changeRange.span().length(); - this._changeRange = null; - } - } - } - }; - return IncrementalParserSource; - })(); - - var ParserImpl = (function () { - function ParserImpl(fileName, lineMap, source, parseOptions) { - this.listParsingState = 0; - this.isInStrictMode = false; - this.diagnostics = []; - this.factory = TypeScript.Syntax.normalModeFactory; - this.mergeTokensStorage = []; - this.arrayPool = []; - this.fileName = fileName; - this.lineMap = lineMap; - this.source = source; - this.parseOptions = parseOptions; - } - ParserImpl.prototype.getRewindPoint = function () { - var rewindPoint = this.source.getRewindPoint(); - - rewindPoint.diagnosticsCount = this.diagnostics.length; - - rewindPoint.isInStrictMode = this.isInStrictMode; - rewindPoint.listParsingState = this.listParsingState; - - return rewindPoint; - }; - - ParserImpl.prototype.rewind = function (rewindPoint) { - this.source.rewind(rewindPoint); - - this.diagnostics.length = rewindPoint.diagnosticsCount; - }; - - ParserImpl.prototype.releaseRewindPoint = function (rewindPoint) { - this.source.releaseRewindPoint(rewindPoint); - }; - - ParserImpl.prototype.currentTokenStart = function () { - return this.source.absolutePosition() + this.currentToken().leadingTriviaWidth(); - }; - - ParserImpl.prototype.previousTokenStart = function () { - if (this.previousToken() === null) { - return 0; - } - - return this.source.absolutePosition() - this.previousToken().fullWidth() + this.previousToken().leadingTriviaWidth(); - }; - - ParserImpl.prototype.previousTokenEnd = function () { - if (this.previousToken() === null) { - return 0; - } - - return this.previousTokenStart() + this.previousToken().width(); - }; - - ParserImpl.prototype.currentNode = function () { - var node = this.source.currentNode(); - - if (node === null || node.parsedInStrictMode() !== this.isInStrictMode) { - return null; - } - - return node; - }; - - ParserImpl.prototype.currentToken = function () { - return this.source.currentToken(); - }; - - ParserImpl.prototype.currentTokenAllowingRegularExpression = function () { - return this.source.currentTokenAllowingRegularExpression(); - }; - - ParserImpl.prototype.peekToken = function (n) { - return this.source.peekToken(n); - }; - - ParserImpl.prototype.eatAnyToken = function () { - var token = this.currentToken(); - this.moveToNextToken(); - return token; - }; - - ParserImpl.prototype.moveToNextToken = function () { - this.source.moveToNextToken(); - }; - - ParserImpl.prototype.previousToken = function () { - return this.source.previousToken(); - }; - - ParserImpl.prototype.eatNode = function () { - var node = this.source.currentNode(); - this.source.moveToNextNode(); - return node; - }; - - ParserImpl.prototype.eatToken = function (kind) { - var token = this.currentToken(); - if (token.tokenKind === kind) { - this.moveToNextToken(); - return token; - } - - return this.createMissingToken(kind, token); - }; - - ParserImpl.prototype.tryEatToken = function (kind) { - if (this.currentToken().tokenKind === kind) { - return this.eatToken(kind); - } - - return null; - }; - - ParserImpl.prototype.tryEatKeyword = function (kind) { - if (this.currentToken().tokenKind === kind) { - return this.eatKeyword(kind); - } - - return null; - }; - - ParserImpl.prototype.eatKeyword = function (kind) { - var token = this.currentToken(); - if (token.tokenKind === kind) { - this.moveToNextToken(); - return token; - } - - return this.createMissingToken(kind, token); - }; - - ParserImpl.prototype.isIdentifier = function (token) { - var tokenKind = token.tokenKind; - - if (tokenKind === 11 /* IdentifierName */) { - return true; - } - - if (tokenKind >= 51 /* FirstFutureReservedStrictKeyword */) { - if (tokenKind <= 59 /* LastFutureReservedStrictKeyword */) { - return !this.isInStrictMode; - } - - return tokenKind <= 70 /* LastTypeScriptKeyword */; - } - - return false; - }; - - ParserImpl.prototype.eatIdentifierNameToken = function () { - var token = this.currentToken(); - - if (token.tokenKind === 11 /* IdentifierName */) { - this.moveToNextToken(); - return token; - } - - if (TypeScript.SyntaxFacts.isAnyKeyword(token.tokenKind)) { - this.moveToNextToken(); - return TypeScript.Syntax.convertToIdentifierName(token); - } - - return this.createMissingToken(11 /* IdentifierName */, token); - }; - - ParserImpl.prototype.eatIdentifierToken = function () { - var token = this.currentToken(); - if (this.isIdentifier(token)) { - this.moveToNextToken(); - - if (token.tokenKind === 11 /* IdentifierName */) { - return token; - } - - return TypeScript.Syntax.convertToIdentifierName(token); - } - - return this.createMissingToken(11 /* IdentifierName */, token); - }; - - ParserImpl.prototype.canEatAutomaticSemicolon = function (allowWithoutNewLine) { - var token = this.currentToken(); - - if (token.tokenKind === 10 /* EndOfFileToken */) { - return true; - } - - if (token.tokenKind === 72 /* CloseBraceToken */) { - return true; - } - - if (allowWithoutNewLine) { - return true; - } - - if (this.previousToken() !== null && this.previousToken().hasTrailingNewLine()) { - return true; - } - - return false; - }; - - ParserImpl.prototype.canEatExplicitOrAutomaticSemicolon = function (allowWithoutNewline) { - var token = this.currentToken(); - - if (token.tokenKind === 79 /* SemicolonToken */) { - return true; - } - - return this.canEatAutomaticSemicolon(allowWithoutNewline); - }; - - ParserImpl.prototype.eatExplicitOrAutomaticSemicolon = function (allowWithoutNewline) { - var token = this.currentToken(); - - if (token.tokenKind === 79 /* SemicolonToken */) { - return this.eatToken(79 /* SemicolonToken */); - } - - if (this.canEatAutomaticSemicolon(allowWithoutNewline)) { - var semicolonToken = TypeScript.Syntax.emptyToken(79 /* SemicolonToken */); - - if (!this.parseOptions.allowAutomaticSemicolonInsertion()) { - this.addDiagnostic(new TypeScript.SyntaxDiagnostic(this.fileName, this.previousTokenEnd(), 0, 11 /* Automatic_semicolon_insertion_not_allowed */, null)); - } - - return semicolonToken; - } - - return this.eatToken(79 /* SemicolonToken */); - }; - - ParserImpl.prototype.isKeyword = function (kind) { - if (kind >= TypeScript.SyntaxKind.FirstKeyword) { - if (kind <= 50 /* LastFutureReservedKeyword */) { - return true; - } - - if (this.isInStrictMode) { - return kind <= 59 /* LastFutureReservedStrictKeyword */; - } - } - - return false; - }; - - ParserImpl.prototype.createMissingToken = function (expectedKind, actual) { - var diagnostic = this.getExpectedTokenDiagnostic(expectedKind, actual); - this.addDiagnostic(diagnostic); - - return TypeScript.Syntax.emptyToken(expectedKind); - }; - - ParserImpl.prototype.getExpectedTokenDiagnostic = function (expectedKind, actual) { - var token = this.currentToken(); - - if (TypeScript.SyntaxFacts.isAnyKeyword(expectedKind) || TypeScript.SyntaxFacts.isAnyPunctuation(expectedKind)) { - return new TypeScript.SyntaxDiagnostic(this.fileName, this.currentTokenStart(), token.width(), 9 /* _0_expected */, [TypeScript.SyntaxFacts.getText(expectedKind)]); - } else { - if (actual !== null && TypeScript.SyntaxFacts.isAnyKeyword(actual.tokenKind)) { - return new TypeScript.SyntaxDiagnostic(this.fileName, this.currentTokenStart(), token.width(), 10 /* Identifier_expected__0__is_a_keyword */, [TypeScript.SyntaxFacts.getText(actual.tokenKind)]); - } else { - return new TypeScript.SyntaxDiagnostic(this.fileName, this.currentTokenStart(), token.width(), 7 /* Identifier_expected */, null); - } - } - }; - - ParserImpl.getPrecedence = function (expressionKind) { - switch (expressionKind) { - case 172 /* CommaExpression */: - return 1 /* CommaExpressionPrecedence */; - - case 173 /* AssignmentExpression */: - case 174 /* AddAssignmentExpression */: - case 175 /* SubtractAssignmentExpression */: - case 176 /* MultiplyAssignmentExpression */: - case 177 /* DivideAssignmentExpression */: - case 178 /* ModuloAssignmentExpression */: - case 179 /* AndAssignmentExpression */: - case 180 /* ExclusiveOrAssignmentExpression */: - case 181 /* OrAssignmentExpression */: - case 182 /* LeftShiftAssignmentExpression */: - case 183 /* SignedRightShiftAssignmentExpression */: - case 184 /* UnsignedRightShiftAssignmentExpression */: - return 2 /* AssignmentExpressionPrecedence */; - - case 185 /* ConditionalExpression */: - return 3 /* ConditionalExpressionPrecedence */; - - case 186 /* LogicalOrExpression */: - return 5 /* LogicalOrExpressionPrecedence */; - - case 187 /* LogicalAndExpression */: - return 6 /* LogicalAndExpressionPrecedence */; - - case 188 /* BitwiseOrExpression */: - return 7 /* BitwiseOrExpressionPrecedence */; - - case 189 /* BitwiseExclusiveOrExpression */: - return 8 /* BitwiseExclusiveOrExpressionPrecedence */; - - case 190 /* BitwiseAndExpression */: - return 9 /* BitwiseAndExpressionPrecedence */; - - case 191 /* EqualsWithTypeConversionExpression */: - case 192 /* NotEqualsWithTypeConversionExpression */: - case 193 /* EqualsExpression */: - case 194 /* NotEqualsExpression */: - return 10 /* EqualityExpressionPrecedence */; - - case 195 /* LessThanExpression */: - case 196 /* GreaterThanExpression */: - case 197 /* LessThanOrEqualExpression */: - case 198 /* GreaterThanOrEqualExpression */: - case 199 /* InstanceOfExpression */: - case 200 /* InExpression */: - return 11 /* RelationalExpressionPrecedence */; - - case 201 /* LeftShiftExpression */: - case 202 /* SignedRightShiftExpression */: - case 203 /* UnsignedRightShiftExpression */: - return 12 /* ShiftExpressionPrecdence */; - - case 207 /* AddExpression */: - case 208 /* SubtractExpression */: - return 13 /* AdditiveExpressionPrecedence */; - - case 204 /* MultiplyExpression */: - case 205 /* DivideExpression */: - case 206 /* ModuloExpression */: - return 14 /* MultiplicativeExpressionPrecedence */; - - case 163 /* PlusExpression */: - case 164 /* NegateExpression */: - case 165 /* BitwiseNotExpression */: - case 166 /* LogicalNotExpression */: - case 169 /* DeleteExpression */: - case 170 /* TypeOfExpression */: - case 171 /* VoidExpression */: - case 167 /* PreIncrementExpression */: - case 168 /* PreDecrementExpression */: - return 15 /* UnaryExpressionPrecedence */; - } - - throw TypeScript.Errors.invalidOperation(); - }; - - ParserImpl.prototype.addSkippedTokenAfterNodeOrToken = function (nodeOrToken, skippedToken) { - if (nodeOrToken.isToken()) { - return this.addSkippedTokenAfterToken(nodeOrToken, skippedToken); - } else if (nodeOrToken.isNode()) { - return this.addSkippedTokenAfterNode(nodeOrToken, skippedToken); - } else { - throw TypeScript.Errors.invalidOperation(); - } - }; - - ParserImpl.prototype.addSkippedTokenAfterNode = function (node, skippedToken) { - var oldToken = node.lastToken(); - var newToken = this.addSkippedTokenAfterToken(oldToken, skippedToken); - - return node.replaceToken(oldToken, newToken); - }; - - ParserImpl.prototype.addSkippedTokensBeforeNode = function (node, skippedTokens) { - if (skippedTokens.length > 0) { - var oldToken = node.firstToken(); - var newToken = this.addSkippedTokensBeforeToken(oldToken, skippedTokens); - - return node.replaceToken(oldToken, newToken); - } - - return node; - }; - - ParserImpl.prototype.addSkippedTokensBeforeToken = function (token, skippedTokens) { - var leadingTrivia = []; - for (var i = 0, n = skippedTokens.length; i < n; i++) { - this.addSkippedTokenToTriviaArray(leadingTrivia, skippedTokens[i]); - } - - this.addTriviaTo(token.leadingTrivia(), leadingTrivia); - - this.returnArray(skippedTokens); - return token.withLeadingTrivia(TypeScript.Syntax.triviaList(leadingTrivia)); - }; - - ParserImpl.prototype.addSkippedTokensAfterToken = function (token, skippedTokens) { - if (skippedTokens.length === 0) { - this.returnArray(skippedTokens); - return token; - } - - var trailingTrivia = token.trailingTrivia().toArray(); - - for (var i = 0, n = skippedTokens.length; i < n; i++) { - this.addSkippedTokenToTriviaArray(trailingTrivia, skippedTokens[i]); - } - - this.returnArray(skippedTokens); - return token.withTrailingTrivia(TypeScript.Syntax.triviaList(trailingTrivia)); - }; - - ParserImpl.prototype.addSkippedTokenAfterToken = function (token, skippedToken) { - var trailingTrivia = token.trailingTrivia().toArray(); - this.addSkippedTokenToTriviaArray(trailingTrivia, skippedToken); - - return token.withTrailingTrivia(TypeScript.Syntax.triviaList(trailingTrivia)); - }; - - ParserImpl.prototype.addSkippedTokenToTriviaArray = function (array, skippedToken) { - this.addTriviaTo(skippedToken.leadingTrivia(), array); - - var trimmedToken = skippedToken.withLeadingTrivia(TypeScript.Syntax.emptyTriviaList).withTrailingTrivia(TypeScript.Syntax.emptyTriviaList); - array.push(TypeScript.Syntax.skippedTokenTrivia(trimmedToken)); - - this.addTriviaTo(skippedToken.trailingTrivia(), array); - }; - - ParserImpl.prototype.addTriviaTo = function (list, array) { - for (var i = 0, n = list.count(); i < n; i++) { - array.push(list.syntaxTriviaAt(i)); - } - }; - - ParserImpl.prototype.parseSyntaxTree = function (isDeclaration) { - var sourceUnit = this.parseSourceUnit(); - - var allDiagnostics = this.source.tokenDiagnostics().concat(this.diagnostics); - allDiagnostics.sort(function (a, b) { - return a.start() - b.start(); - }); - - return new TypeScript.SyntaxTree(sourceUnit, isDeclaration, allDiagnostics, this.fileName, this.lineMap, this.source.languageVersion(), this.parseOptions); - }; - - ParserImpl.prototype.setStrictMode = function (isInStrictMode) { - this.isInStrictMode = isInStrictMode; - this.factory = isInStrictMode ? TypeScript.Syntax.strictModeFactory : TypeScript.Syntax.normalModeFactory; - }; - - ParserImpl.prototype.parseSourceUnit = function () { - var savedIsInStrictMode = this.isInStrictMode; - - var result = this.parseSyntaxList(1 /* SourceUnit_ModuleElements */, ParserImpl.updateStrictModeState); - var moduleElements = result.list; - - this.setStrictMode(savedIsInStrictMode); - - var sourceUnit = this.factory.sourceUnit(moduleElements, this.currentToken()); - sourceUnit = this.addSkippedTokensBeforeNode(sourceUnit, result.skippedTokens); - - return sourceUnit; - }; - - ParserImpl.updateStrictModeState = function (parser, items) { - if (!parser.isInStrictMode) { - for (var i = 0; i < items.length; i++) { - var item = items[i]; - if (!TypeScript.SyntaxFacts.isDirectivePrologueElement(item)) { - return; - } - } - - parser.setStrictMode(TypeScript.SyntaxFacts.isUseStrictDirective(items[items.length - 1])); - } - }; - - ParserImpl.prototype.isModuleElement = function (inErrorRecovery) { - if (this.currentNode() !== null && this.currentNode().isModuleElement()) { - return true; - } - - return this.isImportDeclaration() || this.isExportAssignment() || this.isModuleDeclaration() || this.isInterfaceDeclaration() || this.isClassDeclaration() || this.isEnumDeclaration() || this.isStatement(inErrorRecovery); - }; - - ParserImpl.prototype.parseModuleElement = function () { - if (this.currentNode() !== null && this.currentNode().isModuleElement()) { - return this.eatNode(); - } - - if (this.isImportDeclaration()) { - return this.parseImportDeclaration(); - } else if (this.isExportAssignment()) { - return this.parseExportAssignment(); - } else if (this.isModuleDeclaration()) { - return this.parseModuleDeclaration(); - } else if (this.isInterfaceDeclaration()) { - return this.parseInterfaceDeclaration(); - } else if (this.isClassDeclaration()) { - return this.parseClassDeclaration(); - } else if (this.isEnumDeclaration()) { - return this.parseEnumDeclaration(); - } else if (this.isStatement(false)) { - return this.parseStatement(); - } else { - throw TypeScript.Errors.invalidOperation(); - } - }; - - ParserImpl.prototype.isImportDeclaration = function () { - return this.currentToken().tokenKind === 49 /* ImportKeyword */; - }; - - ParserImpl.prototype.parseImportDeclaration = function () { - var importKeyword = this.eatKeyword(49 /* ImportKeyword */); - var identifier = this.eatIdentifierToken(); - var equalsToken = this.eatToken(108 /* EqualsToken */); - var moduleReference = this.parseModuleReference(); - var semicolonToken = this.eatExplicitOrAutomaticSemicolon(false); - - return this.factory.importDeclaration(importKeyword, identifier, equalsToken, moduleReference, semicolonToken); - }; - - ParserImpl.prototype.isExportAssignment = function () { - return this.currentToken().tokenKind === 47 /* ExportKeyword */ && this.peekToken(1).tokenKind === 108 /* EqualsToken */; - }; - - ParserImpl.prototype.parseExportAssignment = function () { - var exportKeyword = this.eatKeyword(47 /* ExportKeyword */); - var equalsToken = this.eatToken(108 /* EqualsToken */); - var identifier = this.eatIdentifierToken(); - var semicolonToken = this.eatExplicitOrAutomaticSemicolon(false); - - return this.factory.exportAssignment(exportKeyword, equalsToken, identifier, semicolonToken); - }; - - ParserImpl.prototype.parseModuleReference = function () { - if (this.isExternalModuleReference()) { - return this.parseExternalModuleReference(); - } else { - return this.parseModuleNameModuleReference(); - } - }; - - ParserImpl.prototype.isExternalModuleReference = function () { - var token0 = this.currentToken(); - if (token0.tokenKind === 66 /* ModuleKeyword */ || token0.tokenKind === 67 /* RequireKeyword */) { - return this.peekToken(1).tokenKind === 73 /* OpenParenToken */; - } - - return false; - }; - - ParserImpl.prototype.parseExternalModuleReference = function () { - var moduleOrRequireKeyword = this.eatAnyToken(); - var openParenToken = this.eatToken(73 /* OpenParenToken */); - var stringLiteral = this.eatToken(14 /* StringLiteral */); - var closeParenToken = this.eatToken(74 /* CloseParenToken */); - - return this.factory.externalModuleReference(moduleOrRequireKeyword, openParenToken, stringLiteral, closeParenToken); - }; - - ParserImpl.prototype.parseModuleNameModuleReference = function () { - var name = this.parseName(); - return this.factory.moduleNameModuleReference(name); - }; - - ParserImpl.prototype.parseIdentifierName = function () { - var identifierName = this.eatIdentifierNameToken(); - return identifierName; - }; - - ParserImpl.prototype.isName = function () { - return this.isIdentifier(this.currentToken()); - }; - - ParserImpl.prototype.tryParseTypeArgumentList = function (inExpression) { - if (this.currentToken().kind() !== 81 /* LessThanToken */) { - return null; - } - - var lessThanToken; - var greaterThanToken; - var result; - var typeArguments; - - if (!inExpression) { - lessThanToken = this.eatToken(81 /* LessThanToken */); - - result = this.parseSeparatedSyntaxList(262144 /* TypeArgumentList_Types */); - typeArguments = result.list; - lessThanToken = this.addSkippedTokensAfterToken(lessThanToken, result.skippedTokens); - - greaterThanToken = this.eatToken(82 /* GreaterThanToken */); - - return this.factory.typeArgumentList(lessThanToken, typeArguments, greaterThanToken); - } - - var rewindPoint = this.getRewindPoint(); - try { - lessThanToken = this.eatToken(81 /* LessThanToken */); - - result = this.parseSeparatedSyntaxList(262144 /* TypeArgumentList_Types */); - typeArguments = result.list; - lessThanToken = this.addSkippedTokensAfterToken(lessThanToken, result.skippedTokens); - - greaterThanToken = this.eatToken(82 /* GreaterThanToken */); - - if (greaterThanToken.fullWidth() === 0 || !this.canFollowTypeArgumentListInExpression(this.currentToken().kind())) { - this.rewind(rewindPoint); - return null; - } - - return this.factory.typeArgumentList(lessThanToken, typeArguments, greaterThanToken); - } finally { - this.releaseRewindPoint(rewindPoint); - } - }; - - ParserImpl.prototype.canFollowTypeArgumentListInExpression = function (kind) { - switch (kind) { - case 73 /* OpenParenToken */: - case 77 /* DotToken */: - - case 74 /* CloseParenToken */: - case 76 /* CloseBracketToken */: - case 107 /* ColonToken */: - case 79 /* SemicolonToken */: - case 80 /* CommaToken */: - case 106 /* QuestionToken */: - case 85 /* EqualsEqualsToken */: - case 88 /* EqualsEqualsEqualsToken */: - case 87 /* ExclamationEqualsToken */: - case 89 /* ExclamationEqualsEqualsToken */: - case 104 /* AmpersandAmpersandToken */: - case 105 /* BarBarToken */: - case 101 /* CaretToken */: - case 99 /* AmpersandToken */: - case 100 /* BarToken */: - case 72 /* CloseBraceToken */: - case 10 /* EndOfFileToken */: - return true; - - default: - return false; - } - }; - - ParserImpl.prototype.parseName = function () { - var shouldContinue = this.isIdentifier(this.currentToken()); - var current = this.eatIdentifierToken(); - - while (shouldContinue && this.currentToken().tokenKind === 77 /* DotToken */) { - var dotToken = this.eatToken(77 /* DotToken */); - - var currentToken = this.currentToken(); - var identifierName; - - if (TypeScript.SyntaxFacts.isAnyKeyword(currentToken.tokenKind) && this.previousToken().hasTrailingNewLine() && !currentToken.hasTrailingNewLine() && TypeScript.SyntaxFacts.isIdentifierNameOrAnyKeyword(this.peekToken(1))) { - identifierName = this.createMissingToken(11 /* IdentifierName */, currentToken); - } else { - identifierName = this.eatIdentifierNameToken(); - } - - current = this.factory.qualifiedName(current, dotToken, identifierName); - - shouldContinue = identifierName.fullWidth() > 0; - } - - return current; - }; - - ParserImpl.prototype.isEnumDeclaration = function () { - var index = this.modifierCount(); - - if (index > 0 && this.peekToken(index).tokenKind === 46 /* EnumKeyword */) { - return true; - } - - return this.currentToken().tokenKind === 46 /* EnumKeyword */ && this.isIdentifier(this.peekToken(1)); - }; - - ParserImpl.prototype.parseEnumDeclaration = function () { - var modifiers = this.parseModifiers(); - var enumKeyword = this.eatKeyword(46 /* EnumKeyword */); - var identifier = this.eatIdentifierToken(); - - var openBraceToken = this.eatToken(71 /* OpenBraceToken */); - var enumElements = TypeScript.Syntax.emptySeparatedList; - - if (openBraceToken.width() > 0) { - var result = this.parseSeparatedSyntaxList(256 /* EnumDeclaration_EnumElements */); - enumElements = result.list; - openBraceToken = this.addSkippedTokensAfterToken(openBraceToken, result.skippedTokens); - } - - var closeBraceToken = this.eatToken(72 /* CloseBraceToken */); - - return this.factory.enumDeclaration(modifiers, enumKeyword, identifier, openBraceToken, enumElements, closeBraceToken); - }; - - ParserImpl.prototype.isEnumElement = function (inErrorRecovery) { - if (this.currentNode() !== null && this.currentNode().kind() === 243 /* EnumElement */) { - return true; - } - - return this.isPropertyName(this.currentToken(), inErrorRecovery); - }; - - ParserImpl.prototype.parseEnumElement = function () { - if (this.currentNode() !== null && this.currentNode().kind() === 243 /* EnumElement */) { - return this.eatNode(); - } - - var propertyName = this.eatPropertyName(); - var equalsValueClause = null; - if (this.isEqualsValueClause(false)) { - equalsValueClause = this.parseEqualsValueClause(true); - } - - return this.factory.enumElement(propertyName, equalsValueClause); - }; - - ParserImpl.isModifier = function (token) { - switch (token.tokenKind) { - case 57 /* PublicKeyword */: - case 55 /* PrivateKeyword */: - case 58 /* StaticKeyword */: - case 47 /* ExportKeyword */: - case 64 /* DeclareKeyword */: - return true; - - default: - return false; - } - }; - - ParserImpl.prototype.modifierCount = function () { - var modifierCount = 0; - while (true) { - if (ParserImpl.isModifier(this.peekToken(modifierCount))) { - modifierCount++; - continue; - } - - break; - } - - return modifierCount; - }; - - ParserImpl.prototype.parseModifiers = function () { - var tokens = this.getArray(); - - while (true) { - if (ParserImpl.isModifier(this.currentToken())) { - tokens.push(this.eatAnyToken()); - continue; - } - - break; - } - - var result = TypeScript.Syntax.list(tokens); - - this.returnZeroOrOneLengthArray(tokens); - - return result; - }; - - ParserImpl.prototype.isClassDeclaration = function () { - var index = this.modifierCount(); - - if (index > 0 && this.peekToken(index).tokenKind === 44 /* ClassKeyword */) { - return true; - } - - return this.currentToken().tokenKind === 44 /* ClassKeyword */ && this.isIdentifier(this.peekToken(1)); - }; - - ParserImpl.prototype.parseHeritageClauses = function () { - var heritageClauses = TypeScript.Syntax.emptyList; - - if (this.isHeritageClause()) { - var result = this.parseSyntaxList(1024 /* ClassOrInterfaceDeclaration_HeritageClauses */); - heritageClauses = result.list; - TypeScript.Debug.assert(result.skippedTokens.length === 0); - } - - return heritageClauses; - }; - - ParserImpl.prototype.parseClassDeclaration = function () { - var modifiers = this.parseModifiers(); - - var classKeyword = this.eatKeyword(44 /* ClassKeyword */); - var identifier = this.eatIdentifierToken(); - var typeParameterList = this.parseOptionalTypeParameterList(false); - var heritageClauses = this.parseHeritageClauses(); - var openBraceToken = this.eatToken(71 /* OpenBraceToken */); - var classElements = TypeScript.Syntax.emptyList; - - if (openBraceToken.width() > 0) { - var result = this.parseSyntaxList(2 /* ClassDeclaration_ClassElements */); - - classElements = result.list; - openBraceToken = this.addSkippedTokensAfterToken(openBraceToken, result.skippedTokens); - } - - var closeBraceToken = this.eatToken(72 /* CloseBraceToken */); - return this.factory.classDeclaration(modifiers, classKeyword, identifier, typeParameterList, heritageClauses, openBraceToken, classElements, closeBraceToken); - }; - - ParserImpl.prototype.isConstructorDeclaration = function () { - return this.currentToken().tokenKind === 63 /* ConstructorKeyword */; - }; - - ParserImpl.isPublicOrPrivateKeyword = function (token) { - return token.tokenKind === 57 /* PublicKeyword */ || token.tokenKind === 55 /* PrivateKeyword */; - }; - - ParserImpl.prototype.isMemberAccessorDeclaration = function (inErrorRecovery) { - var index = this.modifierCount(); - - if (this.peekToken(index).tokenKind !== 65 /* GetKeyword */ && this.peekToken(index).tokenKind !== 69 /* SetKeyword */) { - return false; - } - - index++; - return this.isPropertyName(this.peekToken(index), inErrorRecovery); - }; - - ParserImpl.prototype.parseMemberAccessorDeclaration = function () { - var modifiers = this.parseModifiers(); - - if (this.currentToken().tokenKind === 65 /* GetKeyword */) { - return this.parseGetMemberAccessorDeclaration(modifiers); - } else if (this.currentToken().tokenKind === 69 /* SetKeyword */) { - return this.parseSetMemberAccessorDeclaration(modifiers); - } else { - throw TypeScript.Errors.invalidOperation(); - } - }; - - ParserImpl.prototype.parseGetMemberAccessorDeclaration = function (modifiers) { - var getKeyword = this.eatKeyword(65 /* GetKeyword */); - var propertyName = this.eatPropertyName(); - var parameterList = this.parseParameterList(); - var typeAnnotation = this.parseOptionalTypeAnnotation(false); - var block = this.parseBlock(false, false); - - return this.factory.getMemberAccessorDeclaration(modifiers, getKeyword, propertyName, parameterList, typeAnnotation, block); - }; - - ParserImpl.prototype.parseSetMemberAccessorDeclaration = function (modifiers) { - var setKeyword = this.eatKeyword(69 /* SetKeyword */); - var propertyName = this.eatPropertyName(); - var parameterList = this.parseParameterList(); - var block = this.parseBlock(false, false); - - return this.factory.setMemberAccessorDeclaration(modifiers, setKeyword, propertyName, parameterList, block); - }; - - ParserImpl.prototype.isClassElement = function (inErrorRecovery) { - if (this.currentNode() !== null && this.currentNode().isClassElement()) { - return true; - } - - return this.isConstructorDeclaration() || this.isMemberFunctionDeclaration(inErrorRecovery) || this.isMemberAccessorDeclaration(inErrorRecovery) || this.isMemberVariableDeclaration(inErrorRecovery) || this.isIndexSignature(); - }; - - ParserImpl.prototype.parseConstructorDeclaration = function () { - var constructorKeyword = this.eatKeyword(63 /* ConstructorKeyword */); - var parameterList = this.parseParameterList(); - - var semicolonToken = null; - var block = null; - - if (this.isBlock()) { - block = this.parseBlock(false, true); - } else { - semicolonToken = this.eatExplicitOrAutomaticSemicolon(false); - } - - return this.factory.constructorDeclaration(constructorKeyword, parameterList, block, semicolonToken); - }; - - ParserImpl.prototype.isMemberFunctionDeclaration = function (inErrorRecovery) { - var index = 0; - - while (true) { - var token = this.peekToken(index); - if (this.isPropertyName(token, inErrorRecovery) && this.isCallSignature(index + 1)) { - return true; - } - - if (ParserImpl.isModifier(token)) { - index++; - continue; - } - - return false; - } - }; - - ParserImpl.prototype.parseMemberFunctionDeclaration = function () { - var modifierArray = this.getArray(); - - while (true) { - var currentToken = this.currentToken(); - if (this.isPropertyName(currentToken, false) && this.isCallSignature(1)) { - break; - } - - TypeScript.Debug.assert(ParserImpl.isModifier(currentToken)); - modifierArray.push(this.eatAnyToken()); - } - - var modifiers = TypeScript.Syntax.list(modifierArray); - this.returnZeroOrOneLengthArray(modifierArray); - - var propertyName = this.eatPropertyName(); - var callSignature = this.parseCallSignature(false); - - var newCallSignature = this.tryAddUnexpectedEqualsGreaterThanToken(callSignature); - var parseBlockEvenWithNoOpenBrace = callSignature !== newCallSignature; - callSignature = newCallSignature; - - var block = null; - var semicolon = null; - - if (parseBlockEvenWithNoOpenBrace || this.isBlock()) { - block = this.parseBlock(parseBlockEvenWithNoOpenBrace, true); - } else { - semicolon = this.eatExplicitOrAutomaticSemicolon(false); - } - - return this.factory.memberFunctionDeclaration(modifiers, propertyName, callSignature, block, semicolon); - }; - - ParserImpl.prototype.isDefinitelyMemberVariablePropertyName = function (index) { - if (TypeScript.SyntaxFacts.isAnyKeyword(this.peekToken(index).tokenKind)) { - switch (this.peekToken(index + 1).tokenKind) { - case 79 /* SemicolonToken */: - case 108 /* EqualsToken */: - case 107 /* ColonToken */: - case 72 /* CloseBraceToken */: - case 10 /* EndOfFileToken */: - return true; - default: - return false; - } - } else { - return true; - } - }; - - ParserImpl.prototype.isMemberVariableDeclaration = function (inErrorRecovery) { - var index = 0; - - while (true) { - var token = this.peekToken(index); - if (this.isPropertyName(token, inErrorRecovery) && this.isDefinitelyMemberVariablePropertyName(index)) { - return true; - } - - if (ParserImpl.isModifier(this.peekToken(index))) { - index++; - continue; - } - - return false; - } - }; - - ParserImpl.prototype.parseMemberVariableDeclaration = function () { - var modifierArray = this.getArray(); - - while (true) { - var currentToken = this.currentToken(); - if (this.isPropertyName(currentToken, false) && this.isDefinitelyMemberVariablePropertyName(0)) { - break; - } - - TypeScript.Debug.assert(ParserImpl.isModifier(currentToken)); - modifierArray.push(this.eatAnyToken()); - } - - var modifiers = TypeScript.Syntax.list(modifierArray); - this.returnZeroOrOneLengthArray(modifierArray); - - var variableDeclarator = this.parseVariableDeclarator(true, true); - var semicolon = this.eatExplicitOrAutomaticSemicolon(false); - - return this.factory.memberVariableDeclaration(modifiers, variableDeclarator, semicolon); - }; - - ParserImpl.prototype.parseClassElement = function (inErrorRecovery) { - if (this.currentNode() !== null && this.currentNode().isClassElement()) { - return this.eatNode(); - } - - if (this.isConstructorDeclaration()) { - return this.parseConstructorDeclaration(); - } else if (this.isMemberFunctionDeclaration(inErrorRecovery)) { - return this.parseMemberFunctionDeclaration(); - } else if (this.isMemberAccessorDeclaration(inErrorRecovery)) { - return this.parseMemberAccessorDeclaration(); - } else if (this.isMemberVariableDeclaration(inErrorRecovery)) { - return this.parseMemberVariableDeclaration(); - } else if (this.isIndexSignature()) { - return this.parseIndexSignature(); - } else { - throw TypeScript.Errors.invalidOperation(); - } - }; - - ParserImpl.prototype.tryAddUnexpectedEqualsGreaterThanToken = function (callSignature) { - var token0 = this.currentToken(); - - var hasEqualsGreaterThanToken = token0.tokenKind === 86 /* EqualsGreaterThanToken */; - if (hasEqualsGreaterThanToken) { - var diagnostic = new TypeScript.SyntaxDiagnostic(this.fileName, this.currentTokenStart(), token0.width(), 16 /* Unexpected_token_ */, []); - this.addDiagnostic(diagnostic); - - var token = this.eatAnyToken(); - return this.addSkippedTokenAfterNode(callSignature, token0); - } - - return callSignature; - }; - - ParserImpl.prototype.isFunctionDeclaration = function () { - var index = this.modifierCount(); - return this.peekToken(index).tokenKind === 27 /* FunctionKeyword */; - }; - - ParserImpl.prototype.parseFunctionDeclaration = function () { - var modifiers = this.parseModifiers(); - var functionKeyword = this.eatKeyword(27 /* FunctionKeyword */); - var identifier = this.eatIdentifierToken(); - var callSignature = this.parseCallSignature(false); - - var newCallSignature = this.tryAddUnexpectedEqualsGreaterThanToken(callSignature); - var parseBlockEvenWithNoOpenBrace = callSignature !== newCallSignature; - callSignature = newCallSignature; - - var semicolonToken = null; - var block = null; - - if (parseBlockEvenWithNoOpenBrace || this.isBlock()) { - block = this.parseBlock(parseBlockEvenWithNoOpenBrace, true); - } else { - semicolonToken = this.eatExplicitOrAutomaticSemicolon(false); - } - - return this.factory.functionDeclaration(modifiers, functionKeyword, identifier, callSignature, block, semicolonToken); - }; - - ParserImpl.prototype.isModuleDeclaration = function () { - var index = this.modifierCount(); - - if (index > 0 && this.peekToken(index).tokenKind === 66 /* ModuleKeyword */) { - return true; - } - - if (this.currentToken().tokenKind === 66 /* ModuleKeyword */) { - var token1 = this.peekToken(1); - return this.isIdentifier(token1) || token1.tokenKind === 14 /* StringLiteral */; - } - - return false; - }; - - ParserImpl.prototype.parseModuleDeclaration = function () { - var modifiers = this.parseModifiers(); - var moduleKeyword = this.eatKeyword(66 /* ModuleKeyword */); - - var moduleName = null; - var stringLiteral = null; - - if (this.currentToken().tokenKind === 14 /* StringLiteral */) { - stringLiteral = this.eatToken(14 /* StringLiteral */); - } else { - moduleName = this.parseName(); - } - - var openBraceToken = this.eatToken(71 /* OpenBraceToken */); - - var moduleElements = TypeScript.Syntax.emptyList; - if (openBraceToken.width() > 0) { - var result = this.parseSyntaxList(4 /* ModuleDeclaration_ModuleElements */); - moduleElements = result.list; - openBraceToken = this.addSkippedTokensAfterToken(openBraceToken, result.skippedTokens); - } - - var closeBraceToken = this.eatToken(72 /* CloseBraceToken */); - - return this.factory.moduleDeclaration(modifiers, moduleKeyword, moduleName, stringLiteral, openBraceToken, moduleElements, closeBraceToken); - }; - - ParserImpl.prototype.isInterfaceDeclaration = function () { - var index = this.modifierCount(); - - if (index > 0 && this.peekToken(index).tokenKind === 52 /* InterfaceKeyword */) { - return true; - } - - return this.currentToken().tokenKind === 52 /* InterfaceKeyword */ && this.isIdentifier(this.peekToken(1)); - }; - - ParserImpl.prototype.parseInterfaceDeclaration = function () { - var modifiers = this.parseModifiers(); - var interfaceKeyword = this.eatKeyword(52 /* InterfaceKeyword */); - var identifier = this.eatIdentifierToken(); - var typeParameterList = this.parseOptionalTypeParameterList(false); - var heritageClauses = this.parseHeritageClauses(); - - var objectType = this.parseObjectType(); - return this.factory.interfaceDeclaration(modifiers, interfaceKeyword, identifier, typeParameterList, heritageClauses, objectType); - }; - - ParserImpl.prototype.parseObjectType = function () { - var openBraceToken = this.eatToken(71 /* OpenBraceToken */); - - var typeMembers = TypeScript.Syntax.emptySeparatedList; - if (openBraceToken.width() > 0) { - var result = this.parseSeparatedSyntaxList(512 /* ObjectType_TypeMembers */); - typeMembers = result.list; - openBraceToken = this.addSkippedTokensAfterToken(openBraceToken, result.skippedTokens); - } - - var closeBraceToken = this.eatToken(72 /* CloseBraceToken */); - return this.factory.objectType(openBraceToken, typeMembers, closeBraceToken); - }; - - ParserImpl.prototype.isTypeMember = function (inErrorRecovery) { - if (this.currentNode() !== null && this.currentNode().isTypeMember()) { - return true; - } - - return this.isCallSignature(0) || this.isConstructSignature() || this.isIndexSignature() || this.isMethodSignature(inErrorRecovery) || this.isPropertySignature(inErrorRecovery); - }; - - ParserImpl.prototype.parseTypeMember = function () { - if (this.currentNode() !== null && this.currentNode().isTypeMember()) { - return this.eatNode(); - } - - if (this.isCallSignature(0)) { - return this.parseCallSignature(false); - } else if (this.isConstructSignature()) { - return this.parseConstructSignature(); - } else if (this.isIndexSignature()) { - return this.parseIndexSignature(); - } else if (this.isMethodSignature(false)) { - return this.parseMethodSignature(); - } else if (this.isPropertySignature(false)) { - return this.parsePropertySignature(); - } else { - throw TypeScript.Errors.invalidOperation(); - } - }; - - ParserImpl.prototype.parseConstructSignature = function () { - var newKeyword = this.eatKeyword(31 /* NewKeyword */); - var callSignature = this.parseCallSignature(false); - - return this.factory.constructSignature(newKeyword, callSignature); - }; - - ParserImpl.prototype.parseIndexSignature = function () { - var openBracketToken = this.eatToken(75 /* OpenBracketToken */); - var parameter = this.parseParameter(); - var closeBracketToken = this.eatToken(76 /* CloseBracketToken */); - var typeAnnotation = this.parseOptionalTypeAnnotation(false); - - return this.factory.indexSignature(openBracketToken, parameter, closeBracketToken, typeAnnotation); - }; - - ParserImpl.prototype.parseMethodSignature = function () { - var propertyName = this.eatPropertyName(); - var questionToken = this.tryEatToken(106 /* QuestionToken */); - var callSignature = this.parseCallSignature(false); - - return this.factory.methodSignature(propertyName, questionToken, callSignature); - }; - - ParserImpl.prototype.parsePropertySignature = function () { - var propertyName = this.eatPropertyName(); - var questionToken = this.tryEatToken(106 /* QuestionToken */); - var typeAnnotation = this.parseOptionalTypeAnnotation(false); - - return this.factory.propertySignature(propertyName, questionToken, typeAnnotation); - }; - - ParserImpl.prototype.isCallSignature = function (tokenIndex) { - var tokenKind = this.peekToken(tokenIndex).tokenKind; - return tokenKind === 73 /* OpenParenToken */ || tokenKind === 81 /* LessThanToken */; - }; - - ParserImpl.prototype.isConstructSignature = function () { - if (this.currentToken().tokenKind !== 31 /* NewKeyword */) { - return false; - } - - var token1 = this.peekToken(1); - return token1.tokenKind === 81 /* LessThanToken */ || token1.tokenKind === 73 /* OpenParenToken */; - }; - - ParserImpl.prototype.isIndexSignature = function () { - return this.currentToken().tokenKind === 75 /* OpenBracketToken */; - }; - - ParserImpl.prototype.isMethodSignature = function (inErrorRecovery) { - if (this.isPropertyName(this.currentToken(), inErrorRecovery)) { - if (this.isCallSignature(1)) { - return true; - } - - if (this.peekToken(1).tokenKind === 106 /* QuestionToken */ && this.isCallSignature(2)) { - return true; - } - } - - return false; - }; - - ParserImpl.prototype.isPropertySignature = function (inErrorRecovery) { - var currentToken = this.currentToken(); - - if (ParserImpl.isModifier(currentToken) && !currentToken.hasTrailingNewLine() && this.isPropertyName(this.peekToken(1), inErrorRecovery)) { - return false; - } - - return this.isPropertyName(currentToken, inErrorRecovery); - }; - - ParserImpl.prototype.isHeritageClause = function () { - var token0 = this.currentToken(); - return token0.tokenKind === 48 /* ExtendsKeyword */ || token0.tokenKind === 51 /* ImplementsKeyword */; - }; - - ParserImpl.prototype.isNotHeritageClauseTypeName = function () { - if (this.currentToken().tokenKind === 51 /* ImplementsKeyword */ || this.currentToken().tokenKind === 48 /* ExtendsKeyword */) { - return this.isIdentifier(this.peekToken(1)); - } - - return false; - }; - - ParserImpl.prototype.isHeritageClauseTypeName = function () { - if (this.isName()) { - return !this.isNotHeritageClauseTypeName(); - } - - return false; - }; - - ParserImpl.prototype.parseHeritageClause = function () { - var extendsOrImplementsKeyword = this.eatAnyToken(); - TypeScript.Debug.assert(extendsOrImplementsKeyword.tokenKind === 48 /* ExtendsKeyword */ || extendsOrImplementsKeyword.tokenKind === 51 /* ImplementsKeyword */); - - var result = this.parseSeparatedSyntaxList(2048 /* HeritageClause_TypeNameList */); - var typeNames = result.list; - extendsOrImplementsKeyword = this.addSkippedTokensAfterToken(extendsOrImplementsKeyword, result.skippedTokens); - - return this.factory.heritageClause(extendsOrImplementsKeyword, typeNames); - }; - - ParserImpl.prototype.isStatement = function (inErrorRecovery) { - if (this.currentNode() !== null && this.currentNode().isStatement()) { - return true; - } - - switch (this.currentToken().tokenKind) { - case 57 /* PublicKeyword */: - case 55 /* PrivateKeyword */: - case 58 /* StaticKeyword */: - var token1 = this.peekToken(1); - if (TypeScript.SyntaxFacts.isIdentifierNameOrAnyKeyword(token1)) { - return false; - } - } - - return this.isVariableStatement() || this.isLabeledStatement() || this.isFunctionDeclaration() || this.isIfStatement() || this.isBlock() || this.isExpressionStatement() || this.isReturnStatement() || this.isSwitchStatement() || this.isThrowStatement() || this.isBreakStatement() || this.isContinueStatement() || this.isForOrForInStatement() || this.isEmptyStatement(inErrorRecovery) || this.isWhileStatement() || this.isWithStatement() || this.isDoStatement() || this.isTryStatement() || this.isDebuggerStatement(); - }; - - ParserImpl.prototype.parseStatement = function () { - if (this.currentNode() !== null && this.currentNode().isStatement()) { - return this.eatNode(); - } - - if (this.isVariableStatement()) { - return this.parseVariableStatement(); - } else if (this.isLabeledStatement()) { - return this.parseLabeledStatement(); - } else if (this.isFunctionDeclaration()) { - return this.parseFunctionDeclaration(); - } else if (this.isIfStatement()) { - return this.parseIfStatement(); - } else if (this.isBlock()) { - return this.parseBlock(false, false); - } else if (this.isReturnStatement()) { - return this.parseReturnStatement(); - } else if (this.isSwitchStatement()) { - return this.parseSwitchStatement(); - } else if (this.isThrowStatement()) { - return this.parseThrowStatement(); - } else if (this.isBreakStatement()) { - return this.parseBreakStatement(); - } else if (this.isContinueStatement()) { - return this.parseContinueStatement(); - } else if (this.isForOrForInStatement()) { - return this.parseForOrForInStatement(); - } else if (this.isEmptyStatement(false)) { - return this.parseEmptyStatement(); - } else if (this.isWhileStatement()) { - return this.parseWhileStatement(); - } else if (this.isWithStatement()) { - return this.parseWithStatement(); - } else if (this.isDoStatement()) { - return this.parseDoStatement(); - } else if (this.isTryStatement()) { - return this.parseTryStatement(); - } else if (this.isDebuggerStatement()) { - return this.parseDebuggerStatement(); - } else { - return this.parseExpressionStatement(); - } - }; - - ParserImpl.prototype.isDebuggerStatement = function () { - return this.currentToken().tokenKind === 19 /* DebuggerKeyword */; - }; - - ParserImpl.prototype.parseDebuggerStatement = function () { - var debuggerKeyword = this.eatKeyword(19 /* DebuggerKeyword */); - var semicolonToken = this.eatExplicitOrAutomaticSemicolon(false); - - return this.factory.debuggerStatement(debuggerKeyword, semicolonToken); - }; - - ParserImpl.prototype.isDoStatement = function () { - return this.currentToken().tokenKind === 22 /* DoKeyword */; - }; - - ParserImpl.prototype.parseDoStatement = function () { - var doKeyword = this.eatKeyword(22 /* DoKeyword */); - var statement = this.parseStatement(); - var whileKeyword = this.eatKeyword(42 /* WhileKeyword */); - var openParenToken = this.eatToken(73 /* OpenParenToken */); - var condition = this.parseExpression(true); - var closeParenToken = this.eatToken(74 /* CloseParenToken */); - - var semicolonToken = this.eatExplicitOrAutomaticSemicolon(true); - - return this.factory.doStatement(doKeyword, statement, whileKeyword, openParenToken, condition, closeParenToken, semicolonToken); - }; - - ParserImpl.prototype.isLabeledStatement = function () { - return this.isIdentifier(this.currentToken()) && this.peekToken(1).tokenKind === 107 /* ColonToken */; - }; - - ParserImpl.prototype.parseLabeledStatement = function () { - var identifier = this.eatIdentifierToken(); - var colonToken = this.eatToken(107 /* ColonToken */); - var statement = this.parseStatement(); - - return this.factory.labeledStatement(identifier, colonToken, statement); - }; - - ParserImpl.prototype.isTryStatement = function () { - return this.currentToken().tokenKind === 38 /* TryKeyword */; - }; - - ParserImpl.prototype.parseTryStatement = function () { - var tryKeyword = this.eatKeyword(38 /* TryKeyword */); - - var savedListParsingState = this.listParsingState; - this.listParsingState |= 64 /* TryBlock_Statements */; - var block = this.parseBlock(false, false); - this.listParsingState = savedListParsingState; - - var catchClause = null; - if (this.isCatchClause()) { - catchClause = this.parseCatchClause(); - } - - var finallyClause = null; - if (catchClause === null || this.isFinallyClause()) { - finallyClause = this.parseFinallyClause(); - } - - return this.factory.tryStatement(tryKeyword, block, catchClause, finallyClause); - }; - - ParserImpl.prototype.isCatchClause = function () { - return this.currentToken().tokenKind === 17 /* CatchKeyword */; - }; - - ParserImpl.prototype.parseCatchClause = function () { - var catchKeyword = this.eatKeyword(17 /* CatchKeyword */); - var openParenToken = this.eatToken(73 /* OpenParenToken */); - var identifier = this.eatIdentifierToken(); - var typeAnnotation = this.parseOptionalTypeAnnotation(false); - var closeParenToken = this.eatToken(74 /* CloseParenToken */); - - var savedListParsingState = this.listParsingState; - this.listParsingState |= 128 /* CatchBlock_Statements */; - var block = this.parseBlock(false, false); - this.listParsingState = savedListParsingState; - - return this.factory.catchClause(catchKeyword, openParenToken, identifier, typeAnnotation, closeParenToken, block); - }; - - ParserImpl.prototype.isFinallyClause = function () { - return this.currentToken().tokenKind === 25 /* FinallyKeyword */; - }; - - ParserImpl.prototype.parseFinallyClause = function () { - var finallyKeyword = this.eatKeyword(25 /* FinallyKeyword */); - var block = this.parseBlock(false, false); - - return this.factory.finallyClause(finallyKeyword, block); - }; - - ParserImpl.prototype.isWithStatement = function () { - return this.currentToken().tokenKind === 43 /* WithKeyword */; - }; - - ParserImpl.prototype.parseWithStatement = function () { - var withKeyword = this.eatKeyword(43 /* WithKeyword */); - var openParenToken = this.eatToken(73 /* OpenParenToken */); - var condition = this.parseExpression(true); - var closeParenToken = this.eatToken(74 /* CloseParenToken */); - var statement = this.parseStatement(); - - return this.factory.withStatement(withKeyword, openParenToken, condition, closeParenToken, statement); - }; - - ParserImpl.prototype.isWhileStatement = function () { - return this.currentToken().tokenKind === 42 /* WhileKeyword */; - }; - - ParserImpl.prototype.parseWhileStatement = function () { - var whileKeyword = this.eatKeyword(42 /* WhileKeyword */); - var openParenToken = this.eatToken(73 /* OpenParenToken */); - var condition = this.parseExpression(true); - var closeParenToken = this.eatToken(74 /* CloseParenToken */); - var statement = this.parseStatement(); - - return this.factory.whileStatement(whileKeyword, openParenToken, condition, closeParenToken, statement); - }; - - ParserImpl.prototype.isEmptyStatement = function (inErrorRecovery) { - if (inErrorRecovery) { - return false; - } - - return this.currentToken().tokenKind === 79 /* SemicolonToken */; - }; - - ParserImpl.prototype.parseEmptyStatement = function () { - var semicolonToken = this.eatToken(79 /* SemicolonToken */); - return this.factory.emptyStatement(semicolonToken); - }; - - ParserImpl.prototype.isForOrForInStatement = function () { - return this.currentToken().tokenKind === 26 /* ForKeyword */; - }; - - ParserImpl.prototype.parseForOrForInStatement = function () { - var forKeyword = this.eatKeyword(26 /* ForKeyword */); - var openParenToken = this.eatToken(73 /* OpenParenToken */); - - var currentToken = this.currentToken(); - if (currentToken.tokenKind === 40 /* VarKeyword */) { - return this.parseForOrForInStatementWithVariableDeclaration(forKeyword, openParenToken); - } else if (currentToken.tokenKind === 79 /* SemicolonToken */) { - return this.parseForStatement(forKeyword, openParenToken); - } else { - return this.parseForOrForInStatementWithInitializer(forKeyword, openParenToken); - } - }; - - ParserImpl.prototype.parseForOrForInStatementWithVariableDeclaration = function (forKeyword, openParenToken) { - var variableDeclaration = this.parseVariableDeclaration(false); - - if (this.currentToken().tokenKind === 29 /* InKeyword */) { - return this.parseForInStatementWithVariableDeclarationOrInitializer(forKeyword, openParenToken, variableDeclaration, null); - } - - return this.parseForStatementWithVariableDeclarationOrInitializer(forKeyword, openParenToken, variableDeclaration, null); - }; - - ParserImpl.prototype.parseForInStatementWithVariableDeclarationOrInitializer = function (forKeyword, openParenToken, variableDeclaration, initializer) { - var inKeyword = this.eatKeyword(29 /* InKeyword */); - var expression = this.parseExpression(true); - var closeParenToken = this.eatToken(74 /* CloseParenToken */); - var statement = this.parseStatement(); - - return this.factory.forInStatement(forKeyword, openParenToken, variableDeclaration, initializer, inKeyword, expression, closeParenToken, statement); - }; - - ParserImpl.prototype.parseForOrForInStatementWithInitializer = function (forKeyword, openParenToken) { - var initializer = this.parseExpression(false); - if (this.currentToken().tokenKind === 29 /* InKeyword */) { - return this.parseForInStatementWithVariableDeclarationOrInitializer(forKeyword, openParenToken, null, initializer); - } else { - return this.parseForStatementWithVariableDeclarationOrInitializer(forKeyword, openParenToken, null, initializer); - } - }; - - ParserImpl.prototype.parseForStatement = function (forKeyword, openParenToken) { - var initializer = null; - - if (this.currentToken().tokenKind !== 79 /* SemicolonToken */ && this.currentToken().tokenKind !== 74 /* CloseParenToken */ && this.currentToken().tokenKind !== 10 /* EndOfFileToken */) { - initializer = this.parseExpression(false); - } - - return this.parseForStatementWithVariableDeclarationOrInitializer(forKeyword, openParenToken, null, initializer); - }; - - ParserImpl.prototype.parseForStatementWithVariableDeclarationOrInitializer = function (forKeyword, openParenToken, variableDeclaration, initializer) { - var firstSemicolonToken = this.eatToken(79 /* SemicolonToken */); - - var condition = null; - if (this.currentToken().tokenKind !== 79 /* SemicolonToken */ && this.currentToken().tokenKind !== 74 /* CloseParenToken */ && this.currentToken().tokenKind !== 10 /* EndOfFileToken */) { - condition = this.parseExpression(true); - } - - var secondSemicolonToken = this.eatToken(79 /* SemicolonToken */); - - var incrementor = null; - if (this.currentToken().tokenKind !== 74 /* CloseParenToken */ && this.currentToken().tokenKind !== 10 /* EndOfFileToken */) { - incrementor = this.parseExpression(true); - } - - var closeParenToken = this.eatToken(74 /* CloseParenToken */); - var statement = this.parseStatement(); - - return this.factory.forStatement(forKeyword, openParenToken, variableDeclaration, initializer, firstSemicolonToken, condition, secondSemicolonToken, incrementor, closeParenToken, statement); - }; - - ParserImpl.prototype.isBreakStatement = function () { - return this.currentToken().tokenKind === 15 /* BreakKeyword */; - }; - - ParserImpl.prototype.parseBreakStatement = function () { - var breakKeyword = this.eatKeyword(15 /* BreakKeyword */); - - var identifier = null; - if (!this.canEatExplicitOrAutomaticSemicolon(false)) { - if (this.isIdentifier(this.currentToken())) { - identifier = this.eatIdentifierToken(); - } - } - - var semicolon = this.eatExplicitOrAutomaticSemicolon(false); - return this.factory.breakStatement(breakKeyword, identifier, semicolon); - }; - - ParserImpl.prototype.isContinueStatement = function () { - return this.currentToken().tokenKind === 18 /* ContinueKeyword */; - }; - - ParserImpl.prototype.parseContinueStatement = function () { - var continueKeyword = this.eatKeyword(18 /* ContinueKeyword */); - - var identifier = null; - if (!this.canEatExplicitOrAutomaticSemicolon(false)) { - if (this.isIdentifier(this.currentToken())) { - identifier = this.eatIdentifierToken(); - } - } - - var semicolon = this.eatExplicitOrAutomaticSemicolon(false); - return this.factory.continueStatement(continueKeyword, identifier, semicolon); - }; - - ParserImpl.prototype.isSwitchStatement = function () { - return this.currentToken().tokenKind === 34 /* SwitchKeyword */; - }; - - ParserImpl.prototype.parseSwitchStatement = function () { - var switchKeyword = this.eatKeyword(34 /* SwitchKeyword */); - var openParenToken = this.eatToken(73 /* OpenParenToken */); - var expression = this.parseExpression(true); - var closeParenToken = this.eatToken(74 /* CloseParenToken */); - - var openBraceToken = this.eatToken(71 /* OpenBraceToken */); - - var switchClauses = TypeScript.Syntax.emptyList; - if (openBraceToken.width() > 0) { - var result = this.parseSyntaxList(8 /* SwitchStatement_SwitchClauses */); - switchClauses = result.list; - openBraceToken = this.addSkippedTokensAfterToken(openBraceToken, result.skippedTokens); - } - - var closeBraceToken = this.eatToken(72 /* CloseBraceToken */); - return this.factory.switchStatement(switchKeyword, openParenToken, expression, closeParenToken, openBraceToken, switchClauses, closeBraceToken); - }; - - ParserImpl.prototype.isCaseSwitchClause = function () { - return this.currentToken().tokenKind === 16 /* CaseKeyword */; - }; - - ParserImpl.prototype.isDefaultSwitchClause = function () { - return this.currentToken().tokenKind === 20 /* DefaultKeyword */; - }; - - ParserImpl.prototype.isSwitchClause = function () { - if (this.currentNode() !== null && this.currentNode().isSwitchClause()) { - return true; - } - - return this.isCaseSwitchClause() || this.isDefaultSwitchClause(); - }; - - ParserImpl.prototype.parseSwitchClause = function () { - if (this.currentNode() !== null && this.currentNode().isSwitchClause()) { - return this.eatNode(); - } - - if (this.isCaseSwitchClause()) { - return this.parseCaseSwitchClause(); - } else if (this.isDefaultSwitchClause()) { - return this.parseDefaultSwitchClause(); - } else { - throw TypeScript.Errors.invalidOperation(); - } - }; - - ParserImpl.prototype.parseCaseSwitchClause = function () { - var caseKeyword = this.eatKeyword(16 /* CaseKeyword */); - var expression = this.parseExpression(true); - var colonToken = this.eatToken(107 /* ColonToken */); - var statements = TypeScript.Syntax.emptyList; - - if (colonToken.fullWidth() > 0) { - var result = this.parseSyntaxList(16 /* SwitchClause_Statements */); - statements = result.list; - colonToken = this.addSkippedTokensAfterToken(colonToken, result.skippedTokens); - } - - return this.factory.caseSwitchClause(caseKeyword, expression, colonToken, statements); - }; - - ParserImpl.prototype.parseDefaultSwitchClause = function () { - var defaultKeyword = this.eatKeyword(20 /* DefaultKeyword */); - var colonToken = this.eatToken(107 /* ColonToken */); - var statements = TypeScript.Syntax.emptyList; - - if (colonToken.fullWidth() > 0) { - var result = this.parseSyntaxList(16 /* SwitchClause_Statements */); - statements = result.list; - colonToken = this.addSkippedTokensAfterToken(colonToken, result.skippedTokens); - } - - return this.factory.defaultSwitchClause(defaultKeyword, colonToken, statements); - }; - - ParserImpl.prototype.isThrowStatement = function () { - return this.currentToken().tokenKind === 36 /* ThrowKeyword */; - }; - - ParserImpl.prototype.parseThrowStatement = function () { - var throwKeyword = this.eatKeyword(36 /* ThrowKeyword */); - - var expression = null; - if (this.canEatExplicitOrAutomaticSemicolon(false)) { - var token = this.createMissingToken(11 /* IdentifierName */, null); - expression = token; - } else { - expression = this.parseExpression(true); - } - - var semicolonToken = this.eatExplicitOrAutomaticSemicolon(false); - - return this.factory.throwStatement(throwKeyword, expression, semicolonToken); - }; - - ParserImpl.prototype.isReturnStatement = function () { - return this.currentToken().tokenKind === 33 /* ReturnKeyword */; - }; - - ParserImpl.prototype.parseReturnStatement = function () { - var returnKeyword = this.eatKeyword(33 /* ReturnKeyword */); - - var expression = null; - if (!this.canEatExplicitOrAutomaticSemicolon(false)) { - expression = this.parseExpression(true); - } - - var semicolonToken = this.eatExplicitOrAutomaticSemicolon(false); - - return this.factory.returnStatement(returnKeyword, expression, semicolonToken); - }; - - ParserImpl.prototype.isExpressionStatement = function () { - var currentToken = this.currentToken(); - - var kind = currentToken.tokenKind; - if (kind === 71 /* OpenBraceToken */ || kind === 27 /* FunctionKeyword */) { - return false; - } - - return this.isExpression(); - }; - - ParserImpl.prototype.isAssignmentOrOmittedExpression = function () { - if (this.currentToken().tokenKind === 80 /* CommaToken */) { - return true; - } - - return this.isExpression(); - }; - - ParserImpl.prototype.parseAssignmentOrOmittedExpression = function () { - if (this.currentToken().tokenKind === 80 /* CommaToken */) { - return this.factory.omittedExpression(); - } - - return this.parseAssignmentExpression(true); - }; - - ParserImpl.prototype.isExpression = function () { - var currentToken = this.currentToken(); - var kind = currentToken.tokenKind; - - switch (kind) { - case 13 /* NumericLiteral */: - case 14 /* StringLiteral */: - case 12 /* RegularExpressionLiteral */: - return true; - - case 75 /* OpenBracketToken */: - case 73 /* OpenParenToken */: - return true; - - case 81 /* LessThanToken */: - return true; - - case 94 /* PlusPlusToken */: - case 95 /* MinusMinusToken */: - case 90 /* PlusToken */: - case 91 /* MinusToken */: - case 103 /* TildeToken */: - case 102 /* ExclamationToken */: - return true; - - case 71 /* OpenBraceToken */: - return true; - - case 86 /* EqualsGreaterThanToken */: - return true; - - case 119 /* SlashToken */: - case 120 /* SlashEqualsToken */: - return true; - - case 50 /* SuperKeyword */: - case 35 /* ThisKeyword */: - case 37 /* TrueKeyword */: - case 24 /* FalseKeyword */: - case 32 /* NullKeyword */: - return true; - - case 31 /* NewKeyword */: - return true; - - case 21 /* DeleteKeyword */: - case 41 /* VoidKeyword */: - case 39 /* TypeOfKeyword */: - return true; - - case 27 /* FunctionKeyword */: - return true; - } - - if (this.isIdentifier(this.currentToken())) { - return true; - } - - return false; - }; - - ParserImpl.prototype.parseExpressionStatement = function () { - var expression = this.parseExpression(true); - - var semicolon = this.eatExplicitOrAutomaticSemicolon(false); - - return this.factory.expressionStatement(expression, semicolon); - }; - - ParserImpl.prototype.isIfStatement = function () { - return this.currentToken().tokenKind === 28 /* IfKeyword */; - }; - - ParserImpl.prototype.parseIfStatement = function () { - var ifKeyword = this.eatKeyword(28 /* IfKeyword */); - var openParenToken = this.eatToken(73 /* OpenParenToken */); - var condition = this.parseExpression(true); - var closeParenToken = this.eatToken(74 /* CloseParenToken */); - var statement = this.parseStatement(); - - var elseClause = null; - if (this.isElseClause()) { - elseClause = this.parseElseClause(); - } - - return this.factory.ifStatement(ifKeyword, openParenToken, condition, closeParenToken, statement, elseClause); - }; - - ParserImpl.prototype.isElseClause = function () { - return this.currentToken().tokenKind === 23 /* ElseKeyword */; - }; - - ParserImpl.prototype.parseElseClause = function () { - var elseKeyword = this.eatKeyword(23 /* ElseKeyword */); - var statement = this.parseStatement(); - - return this.factory.elseClause(elseKeyword, statement); - }; - - ParserImpl.prototype.isVariableStatement = function () { - var index = this.modifierCount(); - return this.peekToken(index).tokenKind === 40 /* VarKeyword */; - }; - - ParserImpl.prototype.parseVariableStatement = function () { - var modifiers = this.parseModifiers(); - var variableDeclaration = this.parseVariableDeclaration(true); - var semicolonToken = this.eatExplicitOrAutomaticSemicolon(false); - - return this.factory.variableStatement(modifiers, variableDeclaration, semicolonToken); - }; - - ParserImpl.prototype.parseVariableDeclaration = function (allowIn) { - var varKeyword = this.eatKeyword(40 /* VarKeyword */); - - var listParsingState = allowIn ? 4096 /* VariableDeclaration_VariableDeclarators_AllowIn */ : 8192 /* VariableDeclaration_VariableDeclarators_DisallowIn */; - - var result = this.parseSeparatedSyntaxList(listParsingState); - var variableDeclarators = result.list; - varKeyword = this.addSkippedTokensAfterToken(varKeyword, result.skippedTokens); - - return this.factory.variableDeclaration(varKeyword, variableDeclarators); - }; - - ParserImpl.prototype.isVariableDeclarator = function () { - if (this.currentNode() !== null && this.currentNode().kind() === 224 /* VariableDeclarator */) { - return true; - } - - return this.isIdentifier(this.currentToken()); - }; - - ParserImpl.prototype.canReuseVariableDeclaratorNode = function (node) { - if (node === null || node.kind() !== 224 /* VariableDeclarator */) { - return false; - } - - var variableDeclarator = node; - return variableDeclarator.equalsValueClause === null; - }; - - ParserImpl.prototype.parseVariableDeclarator = function (allowIn, allowPropertyName) { - if (this.canReuseVariableDeclaratorNode(this.currentNode())) { - return this.eatNode(); - } - - var propertyName = allowPropertyName ? this.eatPropertyName() : this.eatIdentifierToken(); - var equalsValueClause = null; - var typeAnnotation = null; - - if (propertyName.width() > 0) { - typeAnnotation = this.parseOptionalTypeAnnotation(false); - - if (this.isEqualsValueClause(false)) { - equalsValueClause = this.parseEqualsValueClause(allowIn); - } - } - - return this.factory.variableDeclarator(propertyName, typeAnnotation, equalsValueClause); - }; - - ParserImpl.prototype.isColonValueClause = function () { - return this.currentToken().tokenKind === 107 /* ColonToken */; - }; - - ParserImpl.prototype.isEqualsValueClause = function (inParameter) { - var token0 = this.currentToken(); - if (token0.tokenKind === 108 /* EqualsToken */) { - return true; - } - - if (!this.previousToken().hasTrailingNewLine()) { - if (token0.tokenKind === 86 /* EqualsGreaterThanToken */) { - return false; - } - - if (token0.tokenKind === 71 /* OpenBraceToken */ && inParameter) { - return false; - } - - return this.isExpression(); - } - - return false; - }; - - ParserImpl.prototype.parseEqualsValueClause = function (allowIn) { - var equalsToken = this.eatToken(108 /* EqualsToken */); - var value = this.parseAssignmentExpression(allowIn); - - return this.factory.equalsValueClause(equalsToken, value); - }; - - ParserImpl.prototype.parseExpression = function (allowIn) { - return this.parseSubExpression(0, allowIn); - }; - - ParserImpl.prototype.parseAssignmentExpression = function (allowIn) { - return this.parseSubExpression(2 /* AssignmentExpressionPrecedence */, allowIn); - }; - - ParserImpl.prototype.parseUnaryExpression = function () { - var currentTokenKind = this.currentToken().tokenKind; - if (TypeScript.SyntaxFacts.isPrefixUnaryExpressionOperatorToken(currentTokenKind)) { - var operatorKind = TypeScript.SyntaxFacts.getPrefixUnaryExpressionFromOperatorToken(currentTokenKind); - - var operatorToken = this.eatAnyToken(); - - var operand = this.parseUnaryExpression(); - return this.factory.prefixUnaryExpression(operatorKind, operatorToken, operand); - } else { - return this.parseTerm(false); - } - }; - - ParserImpl.prototype.parseSubExpression = function (precedence, allowIn) { - var leftOperand = this.parseUnaryExpression(); - leftOperand = this.parseBinaryOrConditionalExpressions(precedence, allowIn, leftOperand); - - return leftOperand; - }; - - ParserImpl.prototype.parseBinaryOrConditionalExpressions = function (precedence, allowIn, leftOperand) { - while (true) { - var token0 = this.currentToken(); - var token0Kind = token0.tokenKind; - - if (TypeScript.SyntaxFacts.isBinaryExpressionOperatorToken(token0Kind)) { - if (token0Kind === 29 /* InKeyword */ && !allowIn) { - break; - } - - var mergedToken = this.tryMergeBinaryExpressionTokens(); - var tokenKind = mergedToken === null ? token0Kind : mergedToken.syntaxKind; - - var binaryExpressionKind = TypeScript.SyntaxFacts.getBinaryExpressionFromOperatorToken(tokenKind); - var newPrecedence = ParserImpl.getPrecedence(binaryExpressionKind); - - if (newPrecedence < precedence) { - break; - } - - if (newPrecedence === precedence && !this.isRightAssociative(binaryExpressionKind)) { - break; - } - - var operatorToken = mergedToken === null ? token0 : TypeScript.Syntax.token(mergedToken.syntaxKind).withLeadingTrivia(token0.leadingTrivia()).withTrailingTrivia(this.peekToken(mergedToken.tokenCount - 1).trailingTrivia()); - - var skipCount = mergedToken === null ? 1 : mergedToken.tokenCount; - for (var i = 0; i < skipCount; i++) { - this.eatAnyToken(); - } - - leftOperand = this.factory.binaryExpression(binaryExpressionKind, leftOperand, operatorToken, this.parseSubExpression(newPrecedence, allowIn)); - continue; - } - - if (token0Kind === 106 /* QuestionToken */ && precedence <= 3 /* ConditionalExpressionPrecedence */) { - var questionToken = this.eatToken(106 /* QuestionToken */); - - var whenTrueExpression = this.parseAssignmentExpression(allowIn); - var colon = this.eatToken(107 /* ColonToken */); - - var whenFalseExpression = this.parseAssignmentExpression(allowIn); - leftOperand = this.factory.conditionalExpression(leftOperand, questionToken, whenTrueExpression, colon, whenFalseExpression); - continue; - } - - break; - } - - return leftOperand; - }; - - ParserImpl.prototype.tryMergeBinaryExpressionTokens = function () { - var token0 = this.currentToken(); - - if (token0.tokenKind === 82 /* GreaterThanToken */ && !token0.hasTrailingTrivia()) { - var storage = this.mergeTokensStorage; - storage[0] = 0 /* None */; - storage[1] = 0 /* None */; - storage[2] = 0 /* None */; - - for (var i = 0; i < storage.length; i++) { - var nextToken = this.peekToken(i + 1); - - if (!nextToken.hasLeadingTrivia()) { - storage[i] = nextToken.tokenKind; - } - - if (nextToken.hasTrailingTrivia()) { - break; - } - } - - if (storage[0] === 82 /* GreaterThanToken */) { - if (storage[1] === 82 /* GreaterThanToken */) { - if (storage[2] === 108 /* EqualsToken */) { - return { tokenCount: 4, syntaxKind: 115 /* GreaterThanGreaterThanGreaterThanEqualsToken */ }; - } else { - return { tokenCount: 3, syntaxKind: 98 /* GreaterThanGreaterThanGreaterThanToken */ }; - } - } else if (storage[1] === 108 /* EqualsToken */) { - return { tokenCount: 3, syntaxKind: 114 /* GreaterThanGreaterThanEqualsToken */ }; - } else { - return { tokenCount: 2, syntaxKind: 97 /* GreaterThanGreaterThanToken */ }; - } - } else if (storage[0] === 108 /* EqualsToken */) { - return { tokenCount: 2, syntaxKind: 84 /* GreaterThanEqualsToken */ }; - } - } - - return null; - }; - - ParserImpl.prototype.isRightAssociative = function (expressionKind) { - switch (expressionKind) { - case 173 /* AssignmentExpression */: - case 174 /* AddAssignmentExpression */: - case 175 /* SubtractAssignmentExpression */: - case 176 /* MultiplyAssignmentExpression */: - case 177 /* DivideAssignmentExpression */: - case 178 /* ModuloAssignmentExpression */: - case 179 /* AndAssignmentExpression */: - case 180 /* ExclusiveOrAssignmentExpression */: - case 181 /* OrAssignmentExpression */: - case 182 /* LeftShiftAssignmentExpression */: - case 183 /* SignedRightShiftAssignmentExpression */: - case 184 /* UnsignedRightShiftAssignmentExpression */: - return true; - default: - return false; - } - }; - - ParserImpl.prototype.parseTerm = function (inObjectCreation) { - var term = this.parseTermWorker(); - if (term === null) { - return this.eatIdentifierToken(); - } - - return this.parsePostFixExpression(term, inObjectCreation); - }; - - ParserImpl.prototype.parsePostFixExpression = function (expression, inObjectCreation) { - while (true) { - var currentTokenKind = this.currentToken().tokenKind; - switch (currentTokenKind) { - case 73 /* OpenParenToken */: - if (inObjectCreation) { - return expression; - } - - expression = this.factory.invocationExpression(expression, this.parseArgumentList(null)); - continue; - - case 81 /* LessThanToken */: - if (inObjectCreation) { - return expression; - } - - var argumentList = this.tryParseArgumentList(); - if (argumentList !== null) { - expression = this.factory.invocationExpression(expression, argumentList); - continue; - } - - break; - - case 75 /* OpenBracketToken */: - expression = this.parseElementAccessExpression(expression, inObjectCreation); - continue; - - case 94 /* PlusPlusToken */: - case 95 /* MinusMinusToken */: - if (this.previousToken() !== null && this.previousToken().hasTrailingNewLine()) { - break; - } - - expression = this.factory.postfixUnaryExpression(TypeScript.SyntaxFacts.getPostfixUnaryExpressionFromOperatorToken(currentTokenKind), expression, this.eatAnyToken()); - continue; - - case 77 /* DotToken */: - expression = this.factory.memberAccessExpression(expression, this.eatToken(77 /* DotToken */), this.eatIdentifierNameToken()); - continue; - } - - return expression; - } - }; - - ParserImpl.prototype.tryParseArgumentList = function () { - var typeArgumentList = null; - - if (this.currentToken().tokenKind === 81 /* LessThanToken */) { - var rewindPoint = this.getRewindPoint(); - try { - typeArgumentList = this.tryParseTypeArgumentList(true); - var token0 = this.currentToken(); - - var isOpenParen = token0.tokenKind === 73 /* OpenParenToken */; - var isDot = token0.tokenKind === 77 /* DotToken */; - var isOpenParenOrDot = isOpenParen || isDot; - if (typeArgumentList === null || !isOpenParenOrDot) { - this.rewind(rewindPoint); - return null; - } - - if (isDot) { - var diagnostic = new TypeScript.SyntaxDiagnostic(this.fileName, this.currentTokenStart(), token0.width(), 138 /* A_parameter_list_must_follow_a_generic_type_argument_list______expected */, null); - this.addDiagnostic(diagnostic); - - return this.factory.argumentList(typeArgumentList, TypeScript.Syntax.emptyToken(73 /* OpenParenToken */), TypeScript.Syntax.emptySeparatedList, TypeScript.Syntax.emptyToken(74 /* CloseParenToken */)); - } - } finally { - this.releaseRewindPoint(rewindPoint); - } - } - - if (this.currentToken().tokenKind === 73 /* OpenParenToken */) { - return this.parseArgumentList(typeArgumentList); - } - - return null; - }; - - ParserImpl.prototype.parseArgumentList = function (typeArgumentList) { - var openParenToken = this.eatToken(73 /* OpenParenToken */); - var arguments = TypeScript.Syntax.emptySeparatedList; - - if (openParenToken.fullWidth() > 0) { - var result = this.parseSeparatedSyntaxList(16384 /* ArgumentList_AssignmentExpressions */); - arguments = result.list; - openParenToken = this.addSkippedTokensAfterToken(openParenToken, result.skippedTokens); - } - - var closeParenToken = this.eatToken(74 /* CloseParenToken */); - - return this.factory.argumentList(typeArgumentList, openParenToken, arguments, closeParenToken); - }; - - ParserImpl.prototype.parseElementAccessExpression = function (expression, inObjectCreation) { - var start = this.currentTokenStart(); - var openBracketToken = this.eatToken(75 /* OpenBracketToken */); - var argumentExpression; - - if (this.currentToken().tokenKind === 76 /* CloseBracketToken */ && inObjectCreation) { - var end = this.currentTokenStart() + this.currentToken().width(); - var diagnostic = new TypeScript.SyntaxDiagnostic(this.fileName, start, end - start, 137 /* _new_T____cannot_be_used_to_create_an_array__Use__new_Array_T_____instead */, null); - this.addDiagnostic(diagnostic); - - argumentExpression = TypeScript.Syntax.emptyToken(11 /* IdentifierName */); - } else { - argumentExpression = this.parseExpression(true); - } - - var closeBracketToken = this.eatToken(76 /* CloseBracketToken */); - - return this.factory.elementAccessExpression(expression, openBracketToken, argumentExpression, closeBracketToken); - }; - - ParserImpl.prototype.parseTermWorker = function () { - var currentToken = this.currentToken(); - - if (currentToken.tokenKind === 86 /* EqualsGreaterThanToken */) { - return this.parseSimpleArrowFunctionExpression(); - } - - if (this.isIdentifier(currentToken)) { - if (this.isSimpleArrowFunctionExpression()) { - return this.parseSimpleArrowFunctionExpression(); - } else { - var identifier = this.eatIdentifierToken(); - return identifier; - } - } - - var currentTokenKind = currentToken.tokenKind; - switch (currentTokenKind) { - case 35 /* ThisKeyword */: - return this.parseThisExpression(); - - case 37 /* TrueKeyword */: - case 24 /* FalseKeyword */: - return this.parseLiteralExpression(); - - case 32 /* NullKeyword */: - return this.parseLiteralExpression(); - - case 31 /* NewKeyword */: - return this.parseObjectCreationExpression(); - - case 27 /* FunctionKeyword */: - return this.parseFunctionExpression(); - - case 50 /* SuperKeyword */: - return this.parseSuperExpression(); - - case 39 /* TypeOfKeyword */: - return this.parseTypeOfExpression(); - - case 21 /* DeleteKeyword */: - return this.parseDeleteExpression(); - - case 41 /* VoidKeyword */: - return this.parseVoidExpression(); - - case 13 /* NumericLiteral */: - return this.parseLiteralExpression(); - - case 12 /* RegularExpressionLiteral */: - return this.parseLiteralExpression(); - - case 14 /* StringLiteral */: - return this.parseLiteralExpression(); - - case 75 /* OpenBracketToken */: - return this.parseArrayLiteralExpression(); - - case 71 /* OpenBraceToken */: - return this.parseObjectLiteralExpression(); - - case 73 /* OpenParenToken */: - return this.parseParenthesizedOrArrowFunctionExpression(); - - case 81 /* LessThanToken */: - return this.parseCastOrArrowFunctionExpression(); - - case 119 /* SlashToken */: - case 120 /* SlashEqualsToken */: - var result = this.tryReparseDivideAsRegularExpression(); - if (result !== null) { - return result; - } - break; - } - - return null; - }; - - ParserImpl.prototype.tryReparseDivideAsRegularExpression = function () { - var currentToken = this.currentToken(); - - if (this.previousToken() !== null) { - var previousTokenKind = this.previousToken().tokenKind; - switch (previousTokenKind) { - case 11 /* IdentifierName */: - return null; - - case 35 /* ThisKeyword */: - case 37 /* TrueKeyword */: - case 24 /* FalseKeyword */: - return null; - - case 14 /* StringLiteral */: - case 13 /* NumericLiteral */: - case 12 /* RegularExpressionLiteral */: - case 94 /* PlusPlusToken */: - case 95 /* MinusMinusToken */: - case 76 /* CloseBracketToken */: - case 72 /* CloseBraceToken */: - return null; - } - } - - currentToken = this.currentTokenAllowingRegularExpression(); - - if (currentToken.tokenKind === 119 /* SlashToken */ || currentToken.tokenKind === 120 /* SlashEqualsToken */) { - return null; - } else if (currentToken.tokenKind === 12 /* RegularExpressionLiteral */) { - return this.parseLiteralExpression(); - } else { - throw TypeScript.Errors.invalidOperation(); - } - }; - - ParserImpl.prototype.parseTypeOfExpression = function () { - var typeOfKeyword = this.eatKeyword(39 /* TypeOfKeyword */); - var expression = this.parseUnaryExpression(); - - return this.factory.typeOfExpression(typeOfKeyword, expression); - }; - - ParserImpl.prototype.parseDeleteExpression = function () { - var deleteKeyword = this.eatKeyword(21 /* DeleteKeyword */); - var expression = this.parseUnaryExpression(); - - return this.factory.deleteExpression(deleteKeyword, expression); - }; - - ParserImpl.prototype.parseVoidExpression = function () { - var voidKeyword = this.eatKeyword(41 /* VoidKeyword */); - var expression = this.parseUnaryExpression(); - - return this.factory.voidExpression(voidKeyword, expression); - }; - - ParserImpl.prototype.parseSuperExpression = function () { - var superKeyword = this.eatKeyword(50 /* SuperKeyword */); - return superKeyword; - }; - - ParserImpl.prototype.parseFunctionExpression = function () { - var functionKeyword = this.eatKeyword(27 /* FunctionKeyword */); - var identifier = null; - - if (this.isIdentifier(this.currentToken())) { - identifier = this.eatIdentifierToken(); - } - - var callSignature = this.parseCallSignature(false); - var block = this.parseBlock(false, true); - - return this.factory.functionExpression(functionKeyword, identifier, callSignature, block); - }; - - ParserImpl.prototype.parseObjectCreationExpression = function () { - var newKeyword = this.eatKeyword(31 /* NewKeyword */); - - var expression = this.parseTerm(true); - var argumentList = this.tryParseArgumentList(); - - return this.factory.objectCreationExpression(newKeyword, expression, argumentList); - }; - - ParserImpl.prototype.parseCastOrArrowFunctionExpression = function () { - var rewindPoint = this.getRewindPoint(); - try { - var arrowFunction = this.tryParseArrowFunctionExpression(); - if (arrowFunction !== null) { - return arrowFunction; - } - - this.rewind(rewindPoint); - return this.parseCastExpression(); - } finally { - this.releaseRewindPoint(rewindPoint); - } - }; - - ParserImpl.prototype.parseCastExpression = function () { - var lessThanToken = this.eatToken(81 /* LessThanToken */); - var type = this.parseType(); - var greaterThanToken = this.eatToken(82 /* GreaterThanToken */); - var expression = this.parseUnaryExpression(); - - return this.factory.castExpression(lessThanToken, type, greaterThanToken, expression); - }; - - ParserImpl.prototype.parseParenthesizedOrArrowFunctionExpression = function () { - var result = this.tryParseArrowFunctionExpression(); - if (result !== null) { - return result; - } - - var openParenToken = this.eatToken(73 /* OpenParenToken */); - var expression = this.parseExpression(true); - var closeParenToken = this.eatToken(74 /* CloseParenToken */); - - return this.factory.parenthesizedExpression(openParenToken, expression, closeParenToken); - }; - - ParserImpl.prototype.tryParseArrowFunctionExpression = function () { - var tokenKind = this.currentToken().tokenKind; - - if (this.isDefinitelyArrowFunctionExpression()) { - return this.parseParenthesizedArrowFunctionExpression(false); - } - - if (!this.isPossiblyArrowFunctionExpression()) { - return null; - } - - var rewindPoint = this.getRewindPoint(); - try { - var arrowFunction = this.parseParenthesizedArrowFunctionExpression(true); - if (arrowFunction === null) { - this.rewind(rewindPoint); - } - return arrowFunction; - } finally { - this.releaseRewindPoint(rewindPoint); - } - }; - - ParserImpl.prototype.parseParenthesizedArrowFunctionExpression = function (requireArrow) { - var currentToken = this.currentToken(); - - var callSignature = this.parseCallSignature(true); - - if (requireArrow && this.currentToken().tokenKind !== 86 /* EqualsGreaterThanToken */) { - return null; - } - - var equalsGreaterThanToken = this.eatToken(86 /* EqualsGreaterThanToken */); - var body = this.parseArrowFunctionBody(); - - return this.factory.parenthesizedArrowFunctionExpression(callSignature, equalsGreaterThanToken, body); - }; - - ParserImpl.prototype.parseArrowFunctionBody = function () { - if (this.isBlock()) { - return this.parseBlock(false, false); - } else { - return this.parseAssignmentExpression(true); - } - }; - - ParserImpl.prototype.isSimpleArrowFunctionExpression = function () { - if (this.currentToken().tokenKind === 86 /* EqualsGreaterThanToken */) { - return true; - } - - return this.isIdentifier(this.currentToken()) && this.peekToken(1).tokenKind === 86 /* EqualsGreaterThanToken */; - }; - - ParserImpl.prototype.parseSimpleArrowFunctionExpression = function () { - var identifier = this.eatIdentifierToken(); - var equalsGreaterThanToken = this.eatToken(86 /* EqualsGreaterThanToken */); - var body = this.parseArrowFunctionBody(); - - return this.factory.simpleArrowFunctionExpression(identifier, equalsGreaterThanToken, body); - }; - - ParserImpl.prototype.isBlock = function () { - return this.currentToken().tokenKind === 71 /* OpenBraceToken */; - }; - - ParserImpl.prototype.isDefinitelyArrowFunctionExpression = function () { - var token0 = this.currentToken(); - if (token0.tokenKind !== 73 /* OpenParenToken */) { - return false; - } - - var token1 = this.peekToken(1); - var token2; - - if (token1.tokenKind === 74 /* CloseParenToken */) { - token2 = this.peekToken(2); - return token2.tokenKind === 107 /* ColonToken */ || token2.tokenKind === 86 /* EqualsGreaterThanToken */ || token2.tokenKind === 71 /* OpenBraceToken */; - } - - if (token1.tokenKind === 78 /* DotDotDotToken */) { - return true; - } - - if (!this.isIdentifier(token1)) { - return false; - } - - token2 = this.peekToken(2); - if (token2.tokenKind === 107 /* ColonToken */) { - return true; - } - - var token3 = this.peekToken(3); - if (token2.tokenKind === 106 /* QuestionToken */) { - if (token3.tokenKind === 107 /* ColonToken */ || token3.tokenKind === 74 /* CloseParenToken */ || token3.tokenKind === 80 /* CommaToken */) { - return true; - } - } - - if (token2.tokenKind === 74 /* CloseParenToken */) { - if (token3.tokenKind === 86 /* EqualsGreaterThanToken */) { - return true; - } - } - - return false; - }; - - ParserImpl.prototype.isPossiblyArrowFunctionExpression = function () { - var token0 = this.currentToken(); - if (token0.tokenKind !== 73 /* OpenParenToken */) { - return true; - } - - var token1 = this.peekToken(1); - - if (!this.isIdentifier(token1)) { - return false; - } - - var token2 = this.peekToken(2); - if (token2.tokenKind === 108 /* EqualsToken */) { - return true; - } - - if (token2.tokenKind === 80 /* CommaToken */) { - return true; - } - - if (token2.tokenKind === 74 /* CloseParenToken */) { - var token3 = this.peekToken(3); - if (token3.tokenKind === 107 /* ColonToken */) { - return true; - } - } - - return false; - }; - - ParserImpl.prototype.parseObjectLiteralExpression = function () { - var openBraceToken = this.eatToken(71 /* OpenBraceToken */); - - var result = this.parseSeparatedSyntaxList(32768 /* ObjectLiteralExpression_PropertyAssignments */); - var propertyAssignments = result.list; - openBraceToken = this.addSkippedTokensAfterToken(openBraceToken, result.skippedTokens); - - var closeBraceToken = this.eatToken(72 /* CloseBraceToken */); - - return this.factory.objectLiteralExpression(openBraceToken, propertyAssignments, closeBraceToken); - }; - - ParserImpl.prototype.parsePropertyAssignment = function () { - if (this.isGetAccessorPropertyAssignment(false)) { - return this.parseGetAccessorPropertyAssignment(); - } else if (this.isSetAccessorPropertyAssignment(false)) { - return this.parseSetAccessorPropertyAssignment(); - } else if (this.isFunctionPropertyAssignment(false)) { - return this.parseFunctionPropertyAssignment(); - } else if (this.isSimplePropertyAssignment(false)) { - return this.parseSimplePropertyAssignment(); - } else { - throw TypeScript.Errors.invalidOperation(); - } - }; - - ParserImpl.prototype.isPropertyAssignment = function (inErrorRecovery) { - return this.isGetAccessorPropertyAssignment(inErrorRecovery) || this.isSetAccessorPropertyAssignment(inErrorRecovery) || this.isFunctionPropertyAssignment(inErrorRecovery) || this.isSimplePropertyAssignment(inErrorRecovery); - }; - - ParserImpl.prototype.isGetAccessorPropertyAssignment = function (inErrorRecovery) { - return this.currentToken().tokenKind === 65 /* GetKeyword */ && this.isPropertyName(this.peekToken(1), inErrorRecovery); - }; - - ParserImpl.prototype.parseGetAccessorPropertyAssignment = function () { - var getKeyword = this.eatKeyword(65 /* GetKeyword */); - var propertyName = this.eatPropertyName(); - var openParenToken = this.eatToken(73 /* OpenParenToken */); - var closeParenToken = this.eatToken(74 /* CloseParenToken */); - var typeAnnotation = this.parseOptionalTypeAnnotation(false); - var block = this.parseBlock(false, true); - - return this.factory.getAccessorPropertyAssignment(getKeyword, propertyName, openParenToken, closeParenToken, typeAnnotation, block); - }; - - ParserImpl.prototype.isSetAccessorPropertyAssignment = function (inErrorRecovery) { - return this.currentToken().tokenKind === 69 /* SetKeyword */ && this.isPropertyName(this.peekToken(1), inErrorRecovery); - }; - - ParserImpl.prototype.parseSetAccessorPropertyAssignment = function () { - var setKeyword = this.eatKeyword(69 /* SetKeyword */); - var propertyName = this.eatPropertyName(); - var openParenToken = this.eatToken(73 /* OpenParenToken */); - var parameter = this.parseParameter(); - var closeParenToken = this.eatToken(74 /* CloseParenToken */); - var block = this.parseBlock(false, true); - - return this.factory.setAccessorPropertyAssignment(setKeyword, propertyName, openParenToken, parameter, closeParenToken, block); - }; - - ParserImpl.prototype.eatPropertyName = function () { - return TypeScript.SyntaxFacts.isIdentifierNameOrAnyKeyword(this.currentToken()) ? this.eatIdentifierNameToken() : this.eatAnyToken(); - }; - - ParserImpl.prototype.isFunctionPropertyAssignment = function (inErrorRecovery) { - return this.isPropertyName(this.currentToken(), inErrorRecovery) && this.isCallSignature(1); - }; - - ParserImpl.prototype.parseFunctionPropertyAssignment = function () { - var propertyName = this.eatPropertyName(); - var callSignature = this.parseCallSignature(false); - var block = this.parseBlock(false, true); - - return this.factory.functionPropertyAssignment(propertyName, callSignature, block); - }; - - ParserImpl.prototype.isSimplePropertyAssignment = function (inErrorRecovery) { - return this.isPropertyName(this.currentToken(), inErrorRecovery); - }; - - ParserImpl.prototype.parseSimplePropertyAssignment = function () { - var propertyName = this.eatPropertyName(); - var colonToken = this.eatToken(107 /* ColonToken */); - var expression = this.parseAssignmentExpression(true); - - return this.factory.simplePropertyAssignment(propertyName, colonToken, expression); - }; - - ParserImpl.prototype.isPropertyName = function (token, inErrorRecovery) { - if (TypeScript.SyntaxFacts.isIdentifierNameOrAnyKeyword(token)) { - if (inErrorRecovery) { - return this.isIdentifier(token); - } else { - return true; - } - } - - switch (token.tokenKind) { - case 14 /* StringLiteral */: - case 13 /* NumericLiteral */: - return true; - - default: - return false; - } - }; - - ParserImpl.prototype.parseArrayLiteralExpression = function () { - var openBracketToken = this.eatToken(75 /* OpenBracketToken */); - - var result = this.parseSeparatedSyntaxList(65536 /* ArrayLiteralExpression_AssignmentExpressions */); - var expressions = result.list; - openBracketToken = this.addSkippedTokensAfterToken(openBracketToken, result.skippedTokens); - - var closeBracketToken = this.eatToken(76 /* CloseBracketToken */); - - return this.factory.arrayLiteralExpression(openBracketToken, expressions, closeBracketToken); - }; - - ParserImpl.prototype.parseLiteralExpression = function () { - return this.eatAnyToken(); - }; - - ParserImpl.prototype.parseThisExpression = function () { - var thisKeyword = this.eatKeyword(35 /* ThisKeyword */); - return thisKeyword; - }; - - ParserImpl.prototype.parseBlock = function (parseBlockEvenWithNoOpenBrace, checkForStrictMode) { - var openBraceToken = this.eatToken(71 /* OpenBraceToken */); - - var statements = TypeScript.Syntax.emptyList; - - if (parseBlockEvenWithNoOpenBrace || openBraceToken.width() > 0) { - var savedIsInStrictMode = this.isInStrictMode; - - var processItems = checkForStrictMode ? ParserImpl.updateStrictModeState : null; - var result = this.parseSyntaxList(32 /* Block_Statements */, processItems); - statements = result.list; - openBraceToken = this.addSkippedTokensAfterToken(openBraceToken, result.skippedTokens); - - this.setStrictMode(savedIsInStrictMode); - } - - var closeBraceToken = this.eatToken(72 /* CloseBraceToken */); - - return this.factory.block(openBraceToken, statements, closeBraceToken); - }; - - ParserImpl.prototype.parseCallSignature = function (requireCompleteTypeParameterList) { - var typeParameterList = this.parseOptionalTypeParameterList(requireCompleteTypeParameterList); - var parameterList = this.parseParameterList(); - var typeAnnotation = this.parseOptionalTypeAnnotation(false); - - return this.factory.callSignature(typeParameterList, parameterList, typeAnnotation); - }; - - ParserImpl.prototype.parseOptionalTypeParameterList = function (requireCompleteTypeParameterList) { - if (this.currentToken().tokenKind !== 81 /* LessThanToken */) { - return null; - } - - var rewindPoint = this.getRewindPoint(); - try { - var lessThanToken = this.eatToken(81 /* LessThanToken */); - - var result = this.parseSeparatedSyntaxList(524288 /* TypeParameterList_TypeParameters */); - var typeParameterList = result.list; - lessThanToken = this.addSkippedTokensAfterToken(lessThanToken, result.skippedTokens); - - var greaterThanToken = this.eatToken(82 /* GreaterThanToken */); - - if (requireCompleteTypeParameterList && greaterThanToken.fullWidth() === 0) { - this.rewind(rewindPoint); - return null; - } - - return this.factory.typeParameterList(lessThanToken, typeParameterList, greaterThanToken); - } finally { - this.releaseRewindPoint(rewindPoint); - } - }; - - ParserImpl.prototype.isTypeParameter = function () { - return this.isIdentifier(this.currentToken()); - }; - - ParserImpl.prototype.parseTypeParameter = function () { - var identifier = this.eatIdentifierToken(); - var constraint = this.parseOptionalConstraint(); - - return this.factory.typeParameter(identifier, constraint); - }; - - ParserImpl.prototype.parseOptionalConstraint = function () { - if (this.currentToken().kind() !== 48 /* ExtendsKeyword */) { - return null; - } - - var extendsKeyword = this.eatKeyword(48 /* ExtendsKeyword */); - var type = this.parseType(); - - return this.factory.constraint(extendsKeyword, type); - }; - - ParserImpl.prototype.parseParameterList = function () { - var openParenToken = this.eatToken(73 /* OpenParenToken */); - var parameters = TypeScript.Syntax.emptySeparatedList; - - if (openParenToken.width() > 0) { - var result = this.parseSeparatedSyntaxList(131072 /* ParameterList_Parameters */); - parameters = result.list; - openParenToken = this.addSkippedTokensAfterToken(openParenToken, result.skippedTokens); - } - - var closeParenToken = this.eatToken(74 /* CloseParenToken */); - return this.factory.parameterList(openParenToken, parameters, closeParenToken); - }; - - ParserImpl.prototype.isTypeAnnotation = function () { - return this.currentToken().tokenKind === 107 /* ColonToken */; - }; - - ParserImpl.prototype.parseOptionalTypeAnnotation = function (allowStringLiteral) { - return this.isTypeAnnotation() ? this.parseTypeAnnotation(allowStringLiteral) : null; - }; - - ParserImpl.prototype.parseTypeAnnotation = function (allowStringLiteral) { - var colonToken = this.eatToken(107 /* ColonToken */); - var type = allowStringLiteral && this.currentToken().tokenKind === 14 /* StringLiteral */ ? this.eatToken(14 /* StringLiteral */) : this.parseType(); - - return this.factory.typeAnnotation(colonToken, type); - }; - - ParserImpl.prototype.isType = function () { - return this.isPredefinedType() || this.isTypeLiteral() || this.isName(); - }; - - ParserImpl.prototype.parseType = function () { - var type = this.parseNonArrayType(); - - while (this.currentToken().tokenKind === 75 /* OpenBracketToken */) { - var openBracketToken = this.eatToken(75 /* OpenBracketToken */); - var closeBracketToken = this.eatToken(76 /* CloseBracketToken */); - - type = this.factory.arrayType(type, openBracketToken, closeBracketToken); - } - - return type; - }; - - ParserImpl.prototype.parseNonArrayType = function () { - if (this.isPredefinedType()) { - return this.parsePredefinedType(); - } else if (this.isTypeLiteral()) { - return this.parseTypeLiteral(); - } else { - return this.parseNameOrGenericType(); - } - }; - - ParserImpl.prototype.parseNameOrGenericType = function () { - var name = this.parseName(); - var typeArgumentList = this.tryParseTypeArgumentList(false); - - return typeArgumentList === null ? name : this.factory.genericType(name, typeArgumentList); - }; - - ParserImpl.prototype.parseTypeLiteral = function () { - if (this.isObjectType()) { - return this.parseObjectType(); - } else if (this.isFunctionType()) { - return this.parseFunctionType(); - } else if (this.isConstructorType()) { - return this.parseConstructorType(); - } else { - throw TypeScript.Errors.invalidOperation(); - } - }; - - ParserImpl.prototype.parseFunctionType = function () { - var typeParameterList = this.parseOptionalTypeParameterList(false); - var parameterList = this.parseParameterList(); - var equalsGreaterThanToken = this.eatToken(86 /* EqualsGreaterThanToken */); - var returnType = this.parseType(); - - return this.factory.functionType(typeParameterList, parameterList, equalsGreaterThanToken, returnType); - }; - - ParserImpl.prototype.parseConstructorType = function () { - var newKeyword = this.eatKeyword(31 /* NewKeyword */); - var parameterList = this.parseParameterList(); - var equalsGreaterThanToken = this.eatToken(86 /* EqualsGreaterThanToken */); - var type = this.parseType(); - - return this.factory.constructorType(newKeyword, null, parameterList, equalsGreaterThanToken, type); - }; - - ParserImpl.prototype.isTypeLiteral = function () { - return this.isObjectType() || this.isFunctionType() || this.isConstructorType(); - }; - - ParserImpl.prototype.isObjectType = function () { - return this.currentToken().tokenKind === 71 /* OpenBraceToken */; - }; - - ParserImpl.prototype.isFunctionType = function () { - var tokenKind = this.currentToken().tokenKind; - return tokenKind === 73 /* OpenParenToken */ || tokenKind === 81 /* LessThanToken */; - }; - - ParserImpl.prototype.isConstructorType = function () { - return this.currentToken().tokenKind === 31 /* NewKeyword */; - }; - - ParserImpl.prototype.parsePredefinedType = function () { - return this.eatAnyToken(); - }; - - ParserImpl.prototype.isPredefinedType = function () { - switch (this.currentToken().tokenKind) { - case 60 /* AnyKeyword */: - case 68 /* NumberKeyword */: - case 61 /* BooleanKeyword */: - case 62 /* BoolKeyword */: - case 70 /* StringKeyword */: - case 41 /* VoidKeyword */: - return true; - } - - return false; - }; - - ParserImpl.prototype.isParameter = function () { - if (this.currentNode() !== null && this.currentNode().kind() === 242 /* Parameter */) { - return true; - } - - var token = this.currentToken(); - if (token.tokenKind === 78 /* DotDotDotToken */) { - return true; - } - - if (ParserImpl.isPublicOrPrivateKeyword(token)) { - return true; - } - - return this.isIdentifier(token); - }; - - ParserImpl.prototype.parseParameter = function () { - if (this.currentNode() !== null && this.currentNode().kind() === 242 /* Parameter */) { - return this.eatNode(); - } - - var dotDotDotToken = this.tryEatToken(78 /* DotDotDotToken */); - - var publicOrPrivateToken = null; - if (ParserImpl.isPublicOrPrivateKeyword(this.currentToken())) { - publicOrPrivateToken = this.eatAnyToken(); - } - - var identifier = this.eatIdentifierToken(); - var questionToken = this.tryEatToken(106 /* QuestionToken */); - var typeAnnotation = this.parseOptionalTypeAnnotation(true); - - var equalsValueClause = null; - if (this.isEqualsValueClause(true)) { - equalsValueClause = this.parseEqualsValueClause(true); - } - - return this.factory.parameter(dotDotDotToken, publicOrPrivateToken, identifier, questionToken, typeAnnotation, equalsValueClause); - }; - - ParserImpl.prototype.parseSyntaxList = function (currentListType, processItems) { - if (typeof processItems === "undefined") { processItems = null; } - var savedListParsingState = this.listParsingState; - this.listParsingState |= currentListType; - - var result = this.parseSyntaxListWorker(currentListType, processItems); - - this.listParsingState = savedListParsingState; - - return result; - }; - - ParserImpl.prototype.parseSeparatedSyntaxList = function (currentListType) { - var savedListParsingState = this.listParsingState; - this.listParsingState |= currentListType; - - var result = this.parseSeparatedSyntaxListWorker(currentListType); - - this.listParsingState = savedListParsingState; - - return result; - }; - - ParserImpl.prototype.abortParsingListOrMoveToNextToken = function (currentListType, items, skippedTokens) { - this.reportUnexpectedTokenDiagnostic(currentListType); - - for (var state = 262144 /* LastListParsingState */; state >= 1 /* FirstListParsingState */; state >>= 1) { - if ((this.listParsingState & state) !== 0) { - if (this.isExpectedListTerminator(state) || this.isExpectedListItem(state, true)) { - return true; - } - } - } - - var skippedToken = this.currentToken(); - - this.moveToNextToken(); - - this.addSkippedTokenToList(items, skippedTokens, skippedToken); - - return false; - }; - - ParserImpl.prototype.addSkippedTokenToList = function (items, skippedTokens, skippedToken) { - for (var i = items.length - 1; i >= 0; i--) { - var item = items[i]; - var lastToken = item.lastToken(); - if (lastToken.fullWidth() > 0) { - items[i] = this.addSkippedTokenAfterNodeOrToken(item, skippedToken); - return; - } - } - - skippedTokens.push(skippedToken); - }; - - ParserImpl.prototype.tryParseExpectedListItem = function (currentListType, inErrorRecovery, items, processItems) { - if (this.isExpectedListItem(currentListType, inErrorRecovery)) { - var item = this.parseExpectedListItem(currentListType); - - items.push(item); - - if (processItems !== null) { - processItems(this, items); - } - } - }; - - ParserImpl.prototype.listIsTerminated = function (currentListType) { - return this.isExpectedListTerminator(currentListType) || this.currentToken().tokenKind === 10 /* EndOfFileToken */; - }; - - ParserImpl.prototype.getArray = function () { - if (this.arrayPool.length > 0) { - return this.arrayPool.pop(); - } - - return []; - }; - - ParserImpl.prototype.returnZeroOrOneLengthArray = function (array) { - if (array.length <= 1) { - this.returnArray(array); - } - }; - - ParserImpl.prototype.returnArray = function (array) { - array.length = 0; - this.arrayPool.push(array); - }; - - ParserImpl.prototype.parseSyntaxListWorker = function (currentListType, processItems) { - var items = this.getArray(); - var skippedTokens = this.getArray(); - - while (true) { - var oldItemsCount = items.length; - this.tryParseExpectedListItem(currentListType, false, items, processItems); - - var newItemsCount = items.length; - if (newItemsCount === oldItemsCount) { - if (this.listIsTerminated(currentListType)) { - break; - } - - var abort = this.abortParsingListOrMoveToNextToken(currentListType, items, skippedTokens); - if (abort) { - break; - } - } - } - - var result = TypeScript.Syntax.list(items); - - this.returnZeroOrOneLengthArray(items); - - return { skippedTokens: skippedTokens, list: result }; - }; - - ParserImpl.prototype.parseSeparatedSyntaxListWorker = function (currentListType) { - var items = this.getArray(); - var skippedTokens = this.getArray(); - TypeScript.Debug.assert(items.length === 0); - TypeScript.Debug.assert(skippedTokens.length === 0); - TypeScript.Debug.assert(skippedTokens !== items); - - var separatorKind = this.separatorKind(currentListType); - var allowAutomaticSemicolonInsertion = separatorKind === 79 /* SemicolonToken */; - - var inErrorRecovery = false; - var listWasTerminated = false; - while (true) { - var oldItemsCount = items.length; - - this.tryParseExpectedListItem(currentListType, inErrorRecovery, items, null); - - var newItemsCount = items.length; - if (newItemsCount === oldItemsCount) { - if (this.listIsTerminated(currentListType)) { - listWasTerminated = true; - break; - } - - var abort = this.abortParsingListOrMoveToNextToken(currentListType, items, skippedTokens); - if (abort) { - break; - } else { - inErrorRecovery = true; - continue; - } - } - - inErrorRecovery = false; - - var currentToken = this.currentToken(); - if (currentToken.tokenKind === separatorKind || currentToken.tokenKind === 80 /* CommaToken */) { - items.push(this.eatAnyToken()); - continue; - } - - if (this.listIsTerminated(currentListType)) { - listWasTerminated = true; - break; - } - - if (allowAutomaticSemicolonInsertion && this.canEatAutomaticSemicolon(false)) { - items.push(this.eatExplicitOrAutomaticSemicolon(false)); - - continue; - } - - items.push(this.eatToken(separatorKind)); - - inErrorRecovery = true; - } - - var result = TypeScript.Syntax.separatedList(items); - - this.returnZeroOrOneLengthArray(items); - - return { skippedTokens: skippedTokens, list: result }; - }; - - ParserImpl.prototype.separatorKind = function (currentListType) { - switch (currentListType) { - case 2048 /* HeritageClause_TypeNameList */: - case 16384 /* ArgumentList_AssignmentExpressions */: - case 256 /* EnumDeclaration_EnumElements */: - case 4096 /* VariableDeclaration_VariableDeclarators_AllowIn */: - case 8192 /* VariableDeclaration_VariableDeclarators_DisallowIn */: - case 32768 /* ObjectLiteralExpression_PropertyAssignments */: - case 131072 /* ParameterList_Parameters */: - case 65536 /* ArrayLiteralExpression_AssignmentExpressions */: - case 262144 /* TypeArgumentList_Types */: - case 524288 /* TypeParameterList_TypeParameters */: - return 80 /* CommaToken */; - - case 512 /* ObjectType_TypeMembers */: - return 79 /* SemicolonToken */; - - case 1 /* SourceUnit_ModuleElements */: - case 1024 /* ClassOrInterfaceDeclaration_HeritageClauses */: - case 2 /* ClassDeclaration_ClassElements */: - case 4 /* ModuleDeclaration_ModuleElements */: - case 8 /* SwitchStatement_SwitchClauses */: - case 16 /* SwitchClause_Statements */: - case 32 /* Block_Statements */: - default: - throw TypeScript.Errors.notYetImplemented(); - } - }; - - ParserImpl.prototype.reportUnexpectedTokenDiagnostic = function (listType) { - var token = this.currentToken(); - - var diagnostic = new TypeScript.SyntaxDiagnostic(this.fileName, this.currentTokenStart(), token.width(), 12 /* Unexpected_token__0_expected */, [this.getExpectedListElementType(listType)]); - this.addDiagnostic(diagnostic); - }; - - ParserImpl.prototype.addDiagnostic = function (diagnostic) { - if (this.diagnostics.length > 0 && this.diagnostics[this.diagnostics.length - 1].start() === diagnostic.start()) { - return; - } - - this.diagnostics.push(diagnostic); - }; - - ParserImpl.prototype.isExpectedListTerminator = function (currentListType) { - switch (currentListType) { - case 1 /* SourceUnit_ModuleElements */: - return this.isExpectedSourceUnit_ModuleElementsTerminator(); - - case 1024 /* ClassOrInterfaceDeclaration_HeritageClauses */: - return this.isExpectedClassOrInterfaceDeclaration_HeritageClausesTerminator(); - - case 2 /* ClassDeclaration_ClassElements */: - return this.isExpectedClassDeclaration_ClassElementsTerminator(); - - case 4 /* ModuleDeclaration_ModuleElements */: - return this.isExpectedModuleDeclaration_ModuleElementsTerminator(); - - case 8 /* SwitchStatement_SwitchClauses */: - return this.isExpectedSwitchStatement_SwitchClausesTerminator(); - - case 16 /* SwitchClause_Statements */: - return this.isExpectedSwitchClause_StatementsTerminator(); - - case 32 /* Block_Statements */: - return this.isExpectedBlock_StatementsTerminator(); - - case 64 /* TryBlock_Statements */: - return this.isExpectedTryBlock_StatementsTerminator(); - - case 128 /* CatchBlock_Statements */: - return this.isExpectedCatchBlock_StatementsTerminator(); - - case 256 /* EnumDeclaration_EnumElements */: - return this.isExpectedEnumDeclaration_EnumElementsTerminator(); - - case 512 /* ObjectType_TypeMembers */: - return this.isExpectedObjectType_TypeMembersTerminator(); - - case 16384 /* ArgumentList_AssignmentExpressions */: - return this.isExpectedArgumentList_AssignmentExpressionsTerminator(); - - case 2048 /* HeritageClause_TypeNameList */: - return this.isExpectedHeritageClause_TypeNameListTerminator(); - - case 4096 /* VariableDeclaration_VariableDeclarators_AllowIn */: - return this.isExpectedVariableDeclaration_VariableDeclarators_AllowInTerminator(); - - case 8192 /* VariableDeclaration_VariableDeclarators_DisallowIn */: - return this.isExpectedVariableDeclaration_VariableDeclarators_DisallowInTerminator(); - - case 32768 /* ObjectLiteralExpression_PropertyAssignments */: - return this.isExpectedObjectLiteralExpression_PropertyAssignmentsTerminator(); - - case 131072 /* ParameterList_Parameters */: - return this.isExpectedParameterList_ParametersTerminator(); - - case 262144 /* TypeArgumentList_Types */: - return this.isExpectedTypeArgumentList_TypesTerminator(); - - case 524288 /* TypeParameterList_TypeParameters */: - return this.isExpectedTypeParameterList_TypeParametersTerminator(); - - case 65536 /* ArrayLiteralExpression_AssignmentExpressions */: - return this.isExpectedLiteralExpression_AssignmentExpressionsTerminator(); - - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ParserImpl.prototype.isExpectedSourceUnit_ModuleElementsTerminator = function () { - return this.currentToken().tokenKind === 10 /* EndOfFileToken */; - }; - - ParserImpl.prototype.isExpectedEnumDeclaration_EnumElementsTerminator = function () { - return this.currentToken().tokenKind === 72 /* CloseBraceToken */; - }; - - ParserImpl.prototype.isExpectedModuleDeclaration_ModuleElementsTerminator = function () { - return this.currentToken().tokenKind === 72 /* CloseBraceToken */; - }; - - ParserImpl.prototype.isExpectedObjectType_TypeMembersTerminator = function () { - return this.currentToken().tokenKind === 72 /* CloseBraceToken */; - }; - - ParserImpl.prototype.isExpectedObjectLiteralExpression_PropertyAssignmentsTerminator = function () { - return this.currentToken().tokenKind === 72 /* CloseBraceToken */; - }; - - ParserImpl.prototype.isExpectedLiteralExpression_AssignmentExpressionsTerminator = function () { - return this.currentToken().tokenKind === 76 /* CloseBracketToken */; - }; - - ParserImpl.prototype.isExpectedTypeArgumentList_TypesTerminator = function () { - var token = this.currentToken(); - if (token.tokenKind === 82 /* GreaterThanToken */) { - return true; - } - - if (this.canFollowTypeArgumentListInExpression(token.tokenKind)) { - return true; - } - - return false; - }; - - ParserImpl.prototype.isExpectedTypeParameterList_TypeParametersTerminator = function () { - var token = this.currentToken(); - if (token.tokenKind === 82 /* GreaterThanToken */) { - return true; - } - - if (token.tokenKind === 73 /* OpenParenToken */ || token.tokenKind === 71 /* OpenBraceToken */ || token.tokenKind === 48 /* ExtendsKeyword */ || token.tokenKind === 51 /* ImplementsKeyword */) { - return true; - } - - return false; - }; - - ParserImpl.prototype.isExpectedParameterList_ParametersTerminator = function () { - var token = this.currentToken(); - if (token.tokenKind === 74 /* CloseParenToken */) { - return true; - } - - if (token.tokenKind === 71 /* OpenBraceToken */) { - return true; - } - - if (token.tokenKind === 86 /* EqualsGreaterThanToken */) { - return true; - } - - return false; - }; - - ParserImpl.prototype.isExpectedVariableDeclaration_VariableDeclarators_DisallowInTerminator = function () { - if (this.currentToken().tokenKind === 79 /* SemicolonToken */ || this.currentToken().tokenKind === 74 /* CloseParenToken */) { - return true; - } - - if (this.currentToken().tokenKind === 29 /* InKeyword */) { - return true; - } - - return false; - }; - - ParserImpl.prototype.isExpectedVariableDeclaration_VariableDeclarators_AllowInTerminator = function () { - if (this.previousToken().tokenKind === 80 /* CommaToken */) { - return false; - } - - if (this.currentToken().tokenKind === 86 /* EqualsGreaterThanToken */) { - return true; - } - - return this.canEatExplicitOrAutomaticSemicolon(false); - }; - - ParserImpl.prototype.isExpectedClassOrInterfaceDeclaration_HeritageClausesTerminator = function () { - var token0 = this.currentToken(); - if (token0.tokenKind === 71 /* OpenBraceToken */ || token0.tokenKind === 72 /* CloseBraceToken */) { - return true; - } - - return false; - }; - - ParserImpl.prototype.isExpectedHeritageClause_TypeNameListTerminator = function () { - var token0 = this.currentToken(); - if (token0.tokenKind === 48 /* ExtendsKeyword */ || token0.tokenKind === 51 /* ImplementsKeyword */) { - return true; - } - - if (this.isExpectedClassOrInterfaceDeclaration_HeritageClausesTerminator()) { - return true; - } - - return false; - }; - - ParserImpl.prototype.isExpectedArgumentList_AssignmentExpressionsTerminator = function () { - var token0 = this.currentToken(); - return token0.tokenKind === 74 /* CloseParenToken */ || token0.tokenKind === 79 /* SemicolonToken */; - }; - - ParserImpl.prototype.isExpectedClassDeclaration_ClassElementsTerminator = function () { - return this.currentToken().tokenKind === 72 /* CloseBraceToken */; - }; - - ParserImpl.prototype.isExpectedSwitchStatement_SwitchClausesTerminator = function () { - return this.currentToken().tokenKind === 72 /* CloseBraceToken */; - }; - - ParserImpl.prototype.isExpectedSwitchClause_StatementsTerminator = function () { - return this.currentToken().tokenKind === 72 /* CloseBraceToken */ || this.isSwitchClause(); - }; - - ParserImpl.prototype.isExpectedBlock_StatementsTerminator = function () { - return this.currentToken().tokenKind === 72 /* CloseBraceToken */; - }; - - ParserImpl.prototype.isExpectedTryBlock_StatementsTerminator = function () { - return this.currentToken().tokenKind === 17 /* CatchKeyword */ || this.currentToken().tokenKind === 25 /* FinallyKeyword */; - }; - - ParserImpl.prototype.isExpectedCatchBlock_StatementsTerminator = function () { - return this.currentToken().tokenKind === 25 /* FinallyKeyword */; - }; - - ParserImpl.prototype.isExpectedListItem = function (currentListType, inErrorRecovery) { - switch (currentListType) { - case 1 /* SourceUnit_ModuleElements */: - return this.isModuleElement(inErrorRecovery); - - case 1024 /* ClassOrInterfaceDeclaration_HeritageClauses */: - return this.isHeritageClause(); - - case 2 /* ClassDeclaration_ClassElements */: - return this.isClassElement(inErrorRecovery); - - case 4 /* ModuleDeclaration_ModuleElements */: - return this.isModuleElement(inErrorRecovery); - - case 8 /* SwitchStatement_SwitchClauses */: - return this.isSwitchClause(); - - case 16 /* SwitchClause_Statements */: - return this.isStatement(inErrorRecovery); - - case 32 /* Block_Statements */: - return this.isStatement(inErrorRecovery); - - case 64 /* TryBlock_Statements */: - case 128 /* CatchBlock_Statements */: - return false; - - case 256 /* EnumDeclaration_EnumElements */: - return this.isEnumElement(inErrorRecovery); - - case 4096 /* VariableDeclaration_VariableDeclarators_AllowIn */: - case 8192 /* VariableDeclaration_VariableDeclarators_DisallowIn */: - return this.isVariableDeclarator(); - - case 512 /* ObjectType_TypeMembers */: - return this.isTypeMember(inErrorRecovery); - - case 16384 /* ArgumentList_AssignmentExpressions */: - return this.isExpectedArgumentList_AssignmentExpression(); - - case 2048 /* HeritageClause_TypeNameList */: - return this.isHeritageClauseTypeName(); - - case 32768 /* ObjectLiteralExpression_PropertyAssignments */: - return this.isPropertyAssignment(inErrorRecovery); - - case 131072 /* ParameterList_Parameters */: - return this.isParameter(); - - case 262144 /* TypeArgumentList_Types */: - return this.isType(); - - case 524288 /* TypeParameterList_TypeParameters */: - return this.isTypeParameter(); - - case 65536 /* ArrayLiteralExpression_AssignmentExpressions */: - return this.isAssignmentOrOmittedExpression(); - - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ParserImpl.prototype.isExpectedArgumentList_AssignmentExpression = function () { - if (this.isExpression()) { - return true; - } - - if (this.currentToken().tokenKind === 80 /* CommaToken */) { - return true; - } - - return false; - }; - - ParserImpl.prototype.parseExpectedListItem = function (currentListType) { - switch (currentListType) { - case 1 /* SourceUnit_ModuleElements */: - return this.parseModuleElement(); - - case 1024 /* ClassOrInterfaceDeclaration_HeritageClauses */: - return this.parseHeritageClause(); - - case 2 /* ClassDeclaration_ClassElements */: - return this.parseClassElement(false); - - case 4 /* ModuleDeclaration_ModuleElements */: - return this.parseModuleElement(); - - case 8 /* SwitchStatement_SwitchClauses */: - return this.parseSwitchClause(); - - case 16 /* SwitchClause_Statements */: - return this.parseStatement(); - - case 32 /* Block_Statements */: - return this.parseStatement(); - - case 256 /* EnumDeclaration_EnumElements */: - return this.parseEnumElement(); - - case 512 /* ObjectType_TypeMembers */: - return this.parseTypeMember(); - - case 16384 /* ArgumentList_AssignmentExpressions */: - return this.parseAssignmentExpression(true); - - case 2048 /* HeritageClause_TypeNameList */: - return this.parseNameOrGenericType(); - - case 4096 /* VariableDeclaration_VariableDeclarators_AllowIn */: - return this.parseVariableDeclarator(true, false); - - case 8192 /* VariableDeclaration_VariableDeclarators_DisallowIn */: - return this.parseVariableDeclarator(false, false); - - case 32768 /* ObjectLiteralExpression_PropertyAssignments */: - return this.parsePropertyAssignment(); - - case 65536 /* ArrayLiteralExpression_AssignmentExpressions */: - return this.parseAssignmentOrOmittedExpression(); - - case 131072 /* ParameterList_Parameters */: - return this.parseParameter(); - - case 262144 /* TypeArgumentList_Types */: - return this.parseType(); - - case 524288 /* TypeParameterList_TypeParameters */: - return this.parseTypeParameter(); - - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ParserImpl.prototype.getExpectedListElementType = function (currentListType) { - switch (currentListType) { - case 1 /* SourceUnit_ModuleElements */: - return TypeScript.Strings.module__class__interface__enum__import_or_statement; - - case 1024 /* ClassOrInterfaceDeclaration_HeritageClauses */: - return '{'; - - case 2 /* ClassDeclaration_ClassElements */: - return TypeScript.Strings.constructor__function__accessor_or_variable; - - case 4 /* ModuleDeclaration_ModuleElements */: - return TypeScript.Strings.module__class__interface__enum__import_or_statement; - - case 8 /* SwitchStatement_SwitchClauses */: - return TypeScript.Strings.case_or_default_clause; - - case 16 /* SwitchClause_Statements */: - return TypeScript.Strings.statement; - - case 32 /* Block_Statements */: - return TypeScript.Strings.statement; - - case 4096 /* VariableDeclaration_VariableDeclarators_AllowIn */: - case 8192 /* VariableDeclaration_VariableDeclarators_DisallowIn */: - return TypeScript.Strings.identifier; - - case 256 /* EnumDeclaration_EnumElements */: - return TypeScript.Strings.identifier; - - case 512 /* ObjectType_TypeMembers */: - return TypeScript.Strings.call__construct__index__property_or_function_signature; - - case 16384 /* ArgumentList_AssignmentExpressions */: - return TypeScript.Strings.expression; - - case 2048 /* HeritageClause_TypeNameList */: - return TypeScript.Strings.type_name; - - case 32768 /* ObjectLiteralExpression_PropertyAssignments */: - return TypeScript.Strings.property_or_accessor; - - case 131072 /* ParameterList_Parameters */: - return TypeScript.Strings.parameter; - - case 262144 /* TypeArgumentList_Types */: - return TypeScript.Strings.type; - - case 524288 /* TypeParameterList_TypeParameters */: - return TypeScript.Strings.type_parameter; - - case 65536 /* ArrayLiteralExpression_AssignmentExpressions */: - return TypeScript.Strings.expression; - - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - return ParserImpl; - })(); - - function parse(fileName, text, isDeclaration, languageVersion, options) { - var source = new NormalParserSource(fileName, text, languageVersion); - - return new ParserImpl(fileName, text.lineMap(), source, options).parseSyntaxTree(isDeclaration); - } - Parser.parse = parse; - - function incrementalParse(oldSyntaxTree, textChangeRange, newText) { - if (textChangeRange.isUnchanged()) { - return oldSyntaxTree; - } - - var source = new IncrementalParserSource(oldSyntaxTree, textChangeRange, newText); - - return new ParserImpl(oldSyntaxTree.fileName(), newText.lineMap(), source, oldSyntaxTree.parseOptions()).parseSyntaxTree(oldSyntaxTree.isDeclaration()); - } - Parser.incrementalParse = incrementalParse; - })(TypeScript.Parser || (TypeScript.Parser = {})); - var Parser = TypeScript.Parser; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var SyntaxTree = (function () { - function SyntaxTree(sourceUnit, isDeclaration, diagnostics, fileName, lineMap, languageVersion, parseOtions) { - this._allDiagnostics = null; - this._sourceUnit = sourceUnit; - this._isDeclaration = isDeclaration; - this._parserDiagnostics = diagnostics; - this._fileName = fileName; - this._lineMap = lineMap; - this._languageVersion = languageVersion; - this._parseOptions = parseOtions; - } - SyntaxTree.prototype.toJSON = function (key) { - var result = {}; - - result.isDeclaration = this._isDeclaration; - result.languageVersion = TypeScript.LanguageVersion[this._languageVersion]; - result.parseOptions = this._parseOptions; - - if (this.diagnostics().length > 0) { - result.diagnostics = this.diagnostics(); - } - - result.sourceUnit = this._sourceUnit; - result.lineMap = this._lineMap; - - return result; - }; - - SyntaxTree.prototype.sourceUnit = function () { - return this._sourceUnit; - }; - - SyntaxTree.prototype.isDeclaration = function () { - return this._isDeclaration; - }; - - SyntaxTree.prototype.computeDiagnostics = function () { - if (this._parserDiagnostics.length > 0) { - return this._parserDiagnostics; - } - - var diagnostics = []; - this.sourceUnit().accept(new GrammarCheckerWalker(this, diagnostics)); - - return diagnostics; - }; - - SyntaxTree.prototype.diagnostics = function () { - if (this._allDiagnostics === null) { - this._allDiagnostics = this.computeDiagnostics(); - } - - return this._allDiagnostics; - }; - - SyntaxTree.prototype.fileName = function () { - return this._fileName; - }; - - SyntaxTree.prototype.lineMap = function () { - return this._lineMap; - }; - - SyntaxTree.prototype.languageVersion = function () { - return this._languageVersion; - }; - - SyntaxTree.prototype.parseOptions = function () { - return this._parseOptions; - }; - - SyntaxTree.prototype.structuralEquals = function (tree) { - return TypeScript.ArrayUtilities.sequenceEquals(this.diagnostics(), tree.diagnostics(), TypeScript.SyntaxDiagnostic.equals) && this.sourceUnit().structuralEquals(tree.sourceUnit()); - }; - return SyntaxTree; - })(); - TypeScript.SyntaxTree = SyntaxTree; - - var GrammarCheckerWalker = (function (_super) { - __extends(GrammarCheckerWalker, _super); - function GrammarCheckerWalker(syntaxTree, diagnostics) { - _super.call(this); - this.syntaxTree = syntaxTree; - this.diagnostics = diagnostics; - this.inAmbientDeclaration = false; - this.inBlock = false; - this.currentConstructor = null; - } - GrammarCheckerWalker.prototype.childFullStart = function (parent, child) { - return this.position() + TypeScript.Syntax.childOffset(parent, child); - }; - - GrammarCheckerWalker.prototype.childStart = function (parent, child) { - return this.childFullStart(parent, child) + child.leadingTriviaWidth(); - }; - - GrammarCheckerWalker.prototype.pushDiagnostic = function (start, length, diagnosticCode, args) { - if (typeof args === "undefined") { args = null; } - this.diagnostics.push(new TypeScript.SyntaxDiagnostic(this.syntaxTree.fileName(), start, length, diagnosticCode, args)); - }; - - GrammarCheckerWalker.prototype.pushDiagnostic1 = function (elementFullStart, element, diagnosticCode, args) { - if (typeof args === "undefined") { args = null; } - this.diagnostics.push(new TypeScript.SyntaxDiagnostic(this.syntaxTree.fileName(), elementFullStart + element.leadingTriviaWidth(), element.width(), diagnosticCode, args)); - }; - - GrammarCheckerWalker.prototype.visitCatchClause = function (node) { - if (node.typeAnnotation) { - this.pushDiagnostic(this.childStart(node, node.typeAnnotation), node.typeAnnotation.width(), 17 /* A_catch_clause_variable_cannot_have_a_type_annotation */); - } - - _super.prototype.visitCatchClause.call(this, node); - }; - - GrammarCheckerWalker.prototype.checkParameterListOrder = function (node) { - var parameterFullStart = this.childFullStart(node, node.parameters); - - var seenOptionalParameter = false; - var parameterCount = node.parameters.nonSeparatorCount(); - - for (var i = 0, n = node.parameters.childCount(); i < n; i++) { - var nodeOrToken = node.parameters.childAt(i); - if (i % 2 === 0) { - var parameterIndex = i / 2; - var parameter = node.parameters.childAt(i); - - if (parameter.dotDotDotToken) { - if (parameterIndex !== (parameterCount - 1)) { - this.pushDiagnostic1(parameterFullStart, parameter, 18 /* Rest_parameter_must_be_last_in_list */); - return true; - } - - if (parameter.questionToken) { - this.pushDiagnostic1(parameterFullStart, parameter, 56 /* Rest_parameter_cannot_be_optional */); - return true; - } - - if (parameter.equalsValueClause) { - this.pushDiagnostic1(parameterFullStart, parameter, 57 /* Rest_parameter_cannot_have_initializer */); - return true; - } - } else if (parameter.questionToken || parameter.equalsValueClause) { - seenOptionalParameter = true; - - if (parameter.questionToken && parameter.equalsValueClause) { - this.pushDiagnostic1(parameterFullStart, parameter, 19 /* Parameter_cannot_have_question_mark_and_initializer */); - return true; - } - } else { - if (seenOptionalParameter) { - this.pushDiagnostic1(parameterFullStart, parameter, 20 /* Required_parameter_cannot_follow_optional_parameter */); - return true; - } - } - } - - parameterFullStart += nodeOrToken.fullWidth(); - } - - return false; - }; - - GrammarCheckerWalker.prototype.checkParameterListAcessibilityModifiers = function (node) { - if (this.currentConstructor !== null && this.currentConstructor.parameterList === node && this.currentConstructor.block && !this.inAmbientDeclaration) { - return false; - } - - var parameterFullStart = this.childFullStart(node, node.parameters); - - for (var i = 0, n = node.parameters.childCount(); i < n; i++) { - var nodeOrToken = node.parameters.childAt(i); - if (i % 2 === 0) { - var parameter = node.parameters.childAt(i); - - if (parameter.publicOrPrivateKeyword) { - var keywordFullStart = parameterFullStart + TypeScript.Syntax.childOffset(parameter, parameter.publicOrPrivateKeyword); - this.pushDiagnostic1(keywordFullStart, parameter.publicOrPrivateKeyword, 43 /* Overload_and_ambient_signatures_cannot_specify_parameter_properties */); - } - } - - parameterFullStart += nodeOrToken.fullWidth(); - } - - return false; - }; - - GrammarCheckerWalker.prototype.checkForTrailingSeparator = function (parent, list) { - if (list.childCount() === 0 || list.childCount() % 2 === 1) { - return false; - } - - var currentElementFullStart = this.childFullStart(parent, list); - - for (var i = 0, n = list.childCount(); i < n; i++) { - var child = list.childAt(i); - if (i === n - 1) { - this.pushDiagnostic1(currentElementFullStart, child, 13 /* Trailing_separator_not_allowed */); - } - - currentElementFullStart += child.fullWidth(); - } - - return true; - }; - - GrammarCheckerWalker.prototype.checkForAtLeastOneElement = function (parent, list, expected) { - if (list.childCount() > 0) { - return false; - } - - var listFullStart = this.childFullStart(parent, list); - var tokenAtStart = this.syntaxTree.sourceUnit().findToken(listFullStart); - - this.pushDiagnostic1(listFullStart, tokenAtStart.token(), 12 /* Unexpected_token__0_expected */, [expected]); - - return true; - }; - - GrammarCheckerWalker.prototype.visitParameterList = function (node) { - if (this.checkParameterListAcessibilityModifiers(node) || this.checkParameterListOrder(node) || this.checkForTrailingSeparator(node, node.parameters)) { - this.skip(node); - return; - } - - _super.prototype.visitParameterList.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitHeritageClause = function (node) { - if (this.checkForTrailingSeparator(node, node.typeNames) || this.checkForAtLeastOneElement(node, node.typeNames, TypeScript.Strings.type_name)) { - this.skip(node); - return; - } - - _super.prototype.visitHeritageClause.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitArgumentList = function (node) { - if (this.checkForTrailingSeparator(node, node.arguments)) { - this.skip(node); - return; - } - - _super.prototype.visitArgumentList.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitVariableDeclaration = function (node) { - if (this.checkForTrailingSeparator(node, node.variableDeclarators) || this.checkForAtLeastOneElement(node, node.variableDeclarators, TypeScript.Strings.identifier)) { - this.skip(node); - return; - } - - _super.prototype.visitVariableDeclaration.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitTypeArgumentList = function (node) { - if (this.checkForTrailingSeparator(node, node.typeArguments) || this.checkForAtLeastOneElement(node, node.typeArguments, TypeScript.Strings.identifier)) { - this.skip(node); - return; - } - - _super.prototype.visitTypeArgumentList.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitTypeParameterList = function (node) { - if (this.checkForTrailingSeparator(node, node.typeParameters) || this.checkForAtLeastOneElement(node, node.typeParameters, TypeScript.Strings.identifier)) { - this.skip(node); - return; - } - - _super.prototype.visitTypeParameterList.call(this, node); - }; - - GrammarCheckerWalker.prototype.checkIndexSignatureParameter = function (node) { - var parameterFullStart = this.childFullStart(node, node.parameter); - var parameter = node.parameter; - - if (parameter.dotDotDotToken) { - this.pushDiagnostic1(parameterFullStart, parameter, 21 /* Index_signatures_cannot_have_rest_parameters */); - return true; - } else if (parameter.publicOrPrivateKeyword) { - this.pushDiagnostic1(parameterFullStart, parameter, 22 /* Index_signature_parameter_cannot_have_accessibility_modifiers */); - return true; - } else if (parameter.questionToken) { - this.pushDiagnostic1(parameterFullStart, parameter, 23 /* Index_signature_parameter_cannot_have_a_question_mark */); - return true; - } else if (parameter.equalsValueClause) { - this.pushDiagnostic1(parameterFullStart, parameter, 24 /* Index_signature_parameter_cannot_have_an_initializer */); - return true; - } else if (!parameter.typeAnnotation) { - this.pushDiagnostic1(parameterFullStart, parameter, 26 /* Index_signature_parameter_must_have_a_type_annotation */); - return true; - } else if (parameter.typeAnnotation.type.kind() !== 70 /* StringKeyword */ && parameter.typeAnnotation.type.kind() !== 68 /* NumberKeyword */) { - this.pushDiagnostic1(parameterFullStart, parameter, 27 /* Index_signature_parameter_type_must_be__string__or__number_ */); - return true; - } - - return false; - }; - - GrammarCheckerWalker.prototype.visitIndexSignature = function (node) { - if (this.checkIndexSignatureParameter(node)) { - this.skip(node); - return; - } - - if (!node.typeAnnotation) { - this.pushDiagnostic1(this.position(), node, 25 /* Index_signature_must_have_a_type_annotation */); - this.skip(node); - return; - } - - _super.prototype.visitIndexSignature.call(this, node); - }; - - GrammarCheckerWalker.prototype.checkClassDeclarationHeritageClauses = function (node) { - var heritageClauseFullStart = this.childFullStart(node, node.heritageClauses); - - var seenExtendsClause = false; - var seenImplementsClause = false; - - for (var i = 0, n = node.heritageClauses.childCount(); i < n; i++) { - TypeScript.Debug.assert(i <= 2); - var heritageClause = node.heritageClauses.childAt(i); - - if (heritageClause.extendsOrImplementsKeyword.tokenKind === 48 /* ExtendsKeyword */) { - if (seenExtendsClause) { - this.pushDiagnostic1(heritageClauseFullStart, heritageClause, 28 /* _extends__clause_already_seen */); - return true; - } - - if (seenImplementsClause) { - this.pushDiagnostic1(heritageClauseFullStart, heritageClause, 29 /* _extends__clause_must_precede__implements__clause */); - return true; - } - - if (heritageClause.typeNames.nonSeparatorCount() > 1) { - this.pushDiagnostic1(heritageClauseFullStart, heritageClause, 30 /* Class_can_only_extend_single_type */); - return true; - } - - seenExtendsClause = true; - } else { - TypeScript.Debug.assert(heritageClause.extendsOrImplementsKeyword.tokenKind === 51 /* ImplementsKeyword */); - if (seenImplementsClause) { - this.pushDiagnostic1(heritageClauseFullStart, heritageClause, 31 /* _implements__clause_already_seen */); - return true; - } - - seenImplementsClause = true; - } - - heritageClauseFullStart += heritageClause.fullWidth(); - } - - return false; - }; - - GrammarCheckerWalker.prototype.checkForDisallowedDeclareModifier = function (modifiers) { - if (this.inAmbientDeclaration) { - var declareToken = TypeScript.SyntaxUtilities.getToken(modifiers, 64 /* DeclareKeyword */); - - if (declareToken) { - this.pushDiagnostic1(this.childFullStart(modifiers, declareToken), declareToken, 41 /* _declare__modifier_not_allowed_for_code_already_in_an_ambient_context */); - return true; - } - } - - return false; - }; - - GrammarCheckerWalker.prototype.checkForRequiredDeclareModifier = function (moduleElement, typeKeyword, modifiers) { - if (!this.inAmbientDeclaration && this.syntaxTree.isDeclaration()) { - if (!TypeScript.SyntaxUtilities.containsToken(modifiers, 64 /* DeclareKeyword */)) { - this.pushDiagnostic1(this.childFullStart(moduleElement, typeKeyword), typeKeyword.firstToken(), 49 /* _declare__modifier_required_for_top_level_element */); - return true; - } - } - }; - - GrammarCheckerWalker.prototype.checkFunctionOverloads = function (node, moduleElements) { - if (!this.inAmbientDeclaration && !this.syntaxTree.isDeclaration()) { - var moduleElementFullStart = this.childFullStart(node, moduleElements); - - var inFunctionOverloadChain = false; - var functionOverloadChainName = null; - - for (var i = 0, n = moduleElements.childCount(); i < n; i++) { - var moduleElement = moduleElements.childAt(i); - var lastElement = i === (n - 1); - - if (inFunctionOverloadChain) { - if (moduleElement.kind() !== 129 /* FunctionDeclaration */) { - this.pushDiagnostic1(moduleElementFullStart, moduleElement.firstToken(), 44 /* Function_implementation_expected */); - return true; - } - - var functionDeclaration = moduleElement; - if (functionDeclaration.identifier.valueText() !== functionOverloadChainName) { - var identifierFullStart = moduleElementFullStart + TypeScript.Syntax.childOffset(moduleElement, functionDeclaration.identifier); - this.pushDiagnostic1(identifierFullStart, functionDeclaration.identifier, 46 /* Function_overload_name_must_be__0_ */, [functionOverloadChainName]); - return true; - } - } - - if (moduleElement.kind() === 129 /* FunctionDeclaration */) { - functionDeclaration = moduleElement; - if (!TypeScript.SyntaxUtilities.containsToken(functionDeclaration.modifiers, 64 /* DeclareKeyword */)) { - inFunctionOverloadChain = functionDeclaration.block === null; - functionOverloadChainName = functionDeclaration.identifier.valueText(); - - if (lastElement && inFunctionOverloadChain) { - this.pushDiagnostic1(moduleElementFullStart, moduleElement.firstToken(), 44 /* Function_implementation_expected */); - return true; - } - } else { - inFunctionOverloadChain = false; - functionOverloadChainName = ""; - } - } - - moduleElementFullStart += moduleElement.fullWidth(); - } - } - - return false; - }; - - GrammarCheckerWalker.prototype.checkClassOverloads = function (node) { - if (!this.inAmbientDeclaration && !TypeScript.SyntaxUtilities.containsToken(node.modifiers, 64 /* DeclareKeyword */)) { - var classElementFullStart = this.childFullStart(node, node.classElements); - - var inFunctionOverloadChain = false; - var inConstructorOverloadChain = false; - - var functionOverloadChainName = null; - var memberFunctionDeclaration = null; - - for (var i = 0, n = node.classElements.childCount(); i < n; i++) { - var classElement = node.classElements.childAt(i); - var lastElement = i === (n - 1); - - if (inFunctionOverloadChain) { - if (classElement.kind() !== 135 /* MemberFunctionDeclaration */) { - this.pushDiagnostic1(classElementFullStart, classElement.firstToken(), 44 /* Function_implementation_expected */); - return true; - } - - memberFunctionDeclaration = classElement; - if (memberFunctionDeclaration.propertyName.valueText() !== functionOverloadChainName) { - var propertyNameFullStart = classElementFullStart + TypeScript.Syntax.childOffset(classElement, memberFunctionDeclaration.propertyName); - this.pushDiagnostic1(propertyNameFullStart, memberFunctionDeclaration.propertyName, 46 /* Function_overload_name_must_be__0_ */, [functionOverloadChainName]); - return true; - } - } else if (inConstructorOverloadChain) { - if (classElement.kind() !== 137 /* ConstructorDeclaration */) { - this.pushDiagnostic1(classElementFullStart, classElement.firstToken(), 45 /* Constructor_implementation_expected */); - return true; - } - } - - if (classElement.kind() === 135 /* MemberFunctionDeclaration */) { - memberFunctionDeclaration = classElement; - - inFunctionOverloadChain = memberFunctionDeclaration.block === null; - functionOverloadChainName = memberFunctionDeclaration.propertyName.valueText(); - - if (lastElement && inFunctionOverloadChain) { - this.pushDiagnostic1(classElementFullStart, classElement.firstToken(), 44 /* Function_implementation_expected */); - return true; - } - } else if (classElement.kind() === 137 /* ConstructorDeclaration */) { - var constructorDeclaration = classElement; - - inConstructorOverloadChain = constructorDeclaration.block === null; - if (lastElement && inConstructorOverloadChain) { - this.pushDiagnostic1(classElementFullStart, classElement.firstToken(), 45 /* Constructor_implementation_expected */); - return true; - } - } - - classElementFullStart += classElement.fullWidth(); - } - } - - return false; - }; - - GrammarCheckerWalker.prototype.checkForReservedName = function (parent, name, code) { - var nameFullStart = this.childFullStart(parent, name); - var token; - var tokenFullStart; - - var current = name; - while (current !== null) { - if (current.kind() === 122 /* QualifiedName */) { - var qualifiedName = current; - token = qualifiedName.right; - tokenFullStart = nameFullStart + this.childFullStart(qualifiedName, token); - current = qualifiedName.left; - } else { - TypeScript.Debug.assert(current.kind() === 11 /* IdentifierName */); - token = current; - tokenFullStart = nameFullStart; - current = null; - } - - switch (token.valueText()) { - case "any": - case "number": - case "bool": - case "string": - case "void": - this.pushDiagnostic(tokenFullStart + token.leadingTriviaWidth(), token.width(), code, [token.valueText()]); - return true; - } - } - - return false; - }; - - GrammarCheckerWalker.prototype.visitClassDeclaration = function (node) { - if (this.checkForReservedName(node, node.identifier, 60 /* Class_name_cannot_be__0_ */) || this.checkForDisallowedDeclareModifier(node.modifiers) || this.checkForRequiredDeclareModifier(node, node.classKeyword, node.modifiers) || this.checkModuleElementModifiers(node.modifiers) || this.checkClassDeclarationHeritageClauses(node) || this.checkClassOverloads(node)) { - this.skip(node); - return; - } - - var savedInAmbientDeclaration = this.inAmbientDeclaration; - this.inAmbientDeclaration = this.inAmbientDeclaration || this.syntaxTree.isDeclaration() || TypeScript.SyntaxUtilities.containsToken(node.modifiers, 64 /* DeclareKeyword */); - _super.prototype.visitClassDeclaration.call(this, node); - this.inAmbientDeclaration = savedInAmbientDeclaration; - }; - - GrammarCheckerWalker.prototype.checkInterfaceDeclarationHeritageClauses = function (node) { - var heritageClauseFullStart = this.childFullStart(node, node.heritageClauses); - - var seenExtendsClause = false; - - for (var i = 0, n = node.heritageClauses.childCount(); i < n; i++) { - TypeScript.Debug.assert(i <= 1); - var heritageClause = node.heritageClauses.childAt(i); - - if (heritageClause.extendsOrImplementsKeyword.tokenKind === 48 /* ExtendsKeyword */) { - if (seenExtendsClause) { - this.pushDiagnostic1(heritageClauseFullStart, heritageClause, 28 /* _extends__clause_already_seen */); - return true; - } - - seenExtendsClause = true; - } else { - TypeScript.Debug.assert(heritageClause.extendsOrImplementsKeyword.tokenKind === 51 /* ImplementsKeyword */); - this.pushDiagnostic1(heritageClauseFullStart, heritageClause, 36 /* Interface_declaration_cannot_have__implements__clause */); - return true; - } - - heritageClauseFullStart += heritageClause.fullWidth(); - } - - return false; - }; - - GrammarCheckerWalker.prototype.checkInterfaceModifiers = function (modifiers) { - var modifierFullStart = this.position(); - - for (var i = 0, n = modifiers.childCount(); i < n; i++) { - var modifier = modifiers.childAt(i); - if (modifier.tokenKind === 64 /* DeclareKeyword */) { - this.pushDiagnostic1(modifierFullStart, modifier, 48 /* _declare__modifier_cannot_appear_on_an_interface_declaration */); - return true; - } - - modifierFullStart += modifier.fullWidth(); - } - - return false; - }; - - GrammarCheckerWalker.prototype.visitInterfaceDeclaration = function (node) { - if (this.checkForReservedName(node, node.identifier, 61 /* Interface_name_cannot_be__0_ */) || this.checkInterfaceModifiers(node.modifiers) || this.checkModuleElementModifiers(node.modifiers) || this.checkInterfaceDeclarationHeritageClauses(node)) { - this.skip(node); - return; - } - - _super.prototype.visitInterfaceDeclaration.call(this, node); - }; - - GrammarCheckerWalker.prototype.checkClassElementModifiers = function (list) { - var modifierFullStart = this.position(); - - var seenAccessibilityModifier = false; - var seenStaticModifier = false; - - for (var i = 0, n = list.childCount(); i < n; i++) { - var modifier = list.childAt(i); - if (modifier.tokenKind === 57 /* PublicKeyword */ || modifier.tokenKind === 55 /* PrivateKeyword */) { - if (seenAccessibilityModifier) { - this.pushDiagnostic1(modifierFullStart, modifier, 32 /* Accessibility_modifier_already_seen */); - return true; - } - - if (seenStaticModifier) { - var previousToken = list.childAt(i - 1); - this.pushDiagnostic1(modifierFullStart, modifier, 33 /* _0__modifier_must_precede__1__modifier */, [modifier.text(), previousToken.text()]); - return true; - } - - seenAccessibilityModifier = true; - } else if (modifier.tokenKind === 58 /* StaticKeyword */) { - if (seenStaticModifier) { - this.pushDiagnostic1(modifierFullStart, modifier, 34 /* _0__modifier_already_seen */, [modifier.text()]); - return true; - } - - seenStaticModifier = true; - } else { - this.pushDiagnostic1(modifierFullStart, modifier, 35 /* _0__modifier_cannot_appear_on_a_class_element */, [modifier.text()]); - return true; - } - - modifierFullStart += modifier.fullWidth(); - } - - return false; - }; - - GrammarCheckerWalker.prototype.visitMemberVariableDeclaration = function (node) { - if (this.checkClassElementModifiers(node.modifiers)) { - this.skip(node); - return; - } - - _super.prototype.visitMemberVariableDeclaration.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitMemberFunctionDeclaration = function (node) { - if (this.checkClassElementModifiers(node.modifiers)) { - this.skip(node); - return; - } - - _super.prototype.visitMemberFunctionDeclaration.call(this, node); - }; - - GrammarCheckerWalker.prototype.checkGetMemberAccessorParameter = function (node) { - var getKeywordFullStart = this.childFullStart(node, node.getKeyword); - if (node.parameterList.parameters.childCount() !== 0) { - this.pushDiagnostic1(getKeywordFullStart, node.getKeyword, 55 /* _get__accessor_cannot_have_parameters */); - return true; - } - - return false; - }; - - GrammarCheckerWalker.prototype.checkEcmaScriptVersionIsAtLeast = function (parent, node, languageVersion, code) { - if (this.syntaxTree.languageVersion() < languageVersion) { - var nodeFullStart = this.childFullStart(parent, node); - this.pushDiagnostic1(nodeFullStart, node, code); - return true; - } - - return false; - }; - - GrammarCheckerWalker.prototype.visitGetMemberAccessorDeclaration = function (node) { - if (this.checkEcmaScriptVersionIsAtLeast(node, node.getKeyword, 1 /* EcmaScript5 */, 59 /* Accessors_are_only_available_when_targeting_EcmaScript5_and_higher */) || this.checkClassElementModifiers(node.modifiers) || this.checkGetMemberAccessorParameter(node)) { - this.skip(node); - return; - } - - _super.prototype.visitGetMemberAccessorDeclaration.call(this, node); - }; - - GrammarCheckerWalker.prototype.checkSetMemberAccessorParameter = function (node) { - var setKeywordFullStart = this.childFullStart(node, node.setKeyword); - if (node.parameterList.parameters.childCount() !== 1) { - this.pushDiagnostic1(setKeywordFullStart, node.setKeyword, 50 /* _set__accessor_must_have_only_one_parameter */); - return true; - } - - var parameterListFullStart = this.childFullStart(node, node.parameterList); - var parameterFullStart = parameterListFullStart + TypeScript.Syntax.childOffset(node.parameterList, node.parameterList.openParenToken); - var parameter = node.parameterList.parameters.childAt(0); - - if (parameter.publicOrPrivateKeyword) { - this.pushDiagnostic1(parameterFullStart, parameter, 51 /* _set__accessor_parameter_cannot_have_accessibility_modifier */); - return true; - } - - if (parameter.questionToken) { - this.pushDiagnostic1(parameterFullStart, parameter, 52 /* _set__accessor_parameter_cannot_be_optional */); - return true; - } - - if (parameter.equalsValueClause) { - this.pushDiagnostic1(parameterFullStart, parameter, 53 /* _set__accessor_parameter_cannot_have_initializer */); - return true; - } - - if (parameter.dotDotDotToken) { - this.pushDiagnostic1(parameterFullStart, parameter, 54 /* _set__accessor_cannot_have_rest_parameter */); - return true; - } - - return false; - }; - - GrammarCheckerWalker.prototype.visitSetMemberAccessorDeclaration = function (node) { - if (this.checkEcmaScriptVersionIsAtLeast(node, node.setKeyword, 1 /* EcmaScript5 */, 59 /* Accessors_are_only_available_when_targeting_EcmaScript5_and_higher */) || this.checkClassElementModifiers(node.modifiers) || this.checkSetMemberAccessorParameter(node)) { - this.skip(node); - return; - } - - _super.prototype.visitSetMemberAccessorDeclaration.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitGetAccessorPropertyAssignment = function (node) { - if (this.checkEcmaScriptVersionIsAtLeast(node, node.getKeyword, 1 /* EcmaScript5 */, 59 /* Accessors_are_only_available_when_targeting_EcmaScript5_and_higher */)) { - this.skip(node); - return; - } - - _super.prototype.visitGetAccessorPropertyAssignment.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitSetAccessorPropertyAssignment = function (node) { - if (this.checkEcmaScriptVersionIsAtLeast(node, node.setKeyword, 1 /* EcmaScript5 */, 59 /* Accessors_are_only_available_when_targeting_EcmaScript5_and_higher */)) { - this.skip(node); - return; - } - - _super.prototype.visitSetAccessorPropertyAssignment.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitEnumDeclaration = function (node) { - if (this.checkForReservedName(node, node.identifier, 62 /* Enum_name_cannot_be__0_ */) || this.checkForDisallowedDeclareModifier(node.modifiers) || this.checkForRequiredDeclareModifier(node, node.enumKeyword, node.modifiers) || this.checkModuleElementModifiers(node.modifiers), this.checkEnumElements(node)) { - this.skip(node); - return; - } - - var savedInAmbientDeclaration = this.inAmbientDeclaration; - this.inAmbientDeclaration = this.inAmbientDeclaration || this.syntaxTree.isDeclaration() || TypeScript.SyntaxUtilities.containsToken(node.modifiers, 64 /* DeclareKeyword */); - _super.prototype.visitEnumDeclaration.call(this, node); - this.inAmbientDeclaration = savedInAmbientDeclaration; - }; - - GrammarCheckerWalker.prototype.checkEnumElements = function (node) { - var enumElementFullStart = this.childFullStart(node, node.enumElements); - - var seenComputedValue = false; - for (var i = 0, n = node.enumElements.childCount(); i < n; i++) { - var child = node.enumElements.childAt(i); - - if (i % 2 === 0) { - var enumElement = child; - - if (!enumElement.equalsValueClause && seenComputedValue) { - this.pushDiagnostic1(enumElementFullStart, enumElement, 64 /* Enum_member_must_have_initializer */, null); - return true; - } - - if (enumElement.equalsValueClause) { - var value = enumElement.equalsValueClause.value; - if (value.kind() !== 13 /* NumericLiteral */) { - seenComputedValue = true; - } - } - } - - enumElementFullStart += child.fullWidth(); - } - - return false; - }; - - GrammarCheckerWalker.prototype.visitInvocationExpression = function (node) { - if (node.expression.kind() === 50 /* SuperKeyword */ && node.argumentList.typeArgumentList !== null) { - this.pushDiagnostic1(this.position(), node, 37 /* _super__invocation_cannot_have_type_arguments */); - } - - _super.prototype.visitInvocationExpression.call(this, node); - }; - - GrammarCheckerWalker.prototype.checkModuleElementModifiers = function (modifiers) { - var modifierFullStart = this.position(); - var seenExportModifier = false; - var seenDeclareModifier = false; - - for (var i = 0, n = modifiers.childCount(); i < n; i++) { - var modifier = modifiers.childAt(i); - if (modifier.tokenKind === 57 /* PublicKeyword */ || modifier.tokenKind === 55 /* PrivateKeyword */ || modifier.tokenKind === 58 /* StaticKeyword */) { - this.pushDiagnostic1(modifierFullStart, modifier, 47 /* _0__modifier_cannot_appear_on_a_module_element */, [modifier.text()]); - return true; - } - - if (modifier.tokenKind === 64 /* DeclareKeyword */) { - if (seenDeclareModifier) { - this.pushDiagnostic1(modifierFullStart, modifier, 32 /* Accessibility_modifier_already_seen */); - return; - } - - seenDeclareModifier = true; - } else if (modifier.tokenKind === 47 /* ExportKeyword */) { - if (seenExportModifier) { - this.pushDiagnostic1(modifierFullStart, modifier, 34 /* _0__modifier_already_seen */, [modifier.text()]); - return; - } - - if (seenDeclareModifier) { - this.pushDiagnostic1(modifierFullStart, modifier, 33 /* _0__modifier_must_precede__1__modifier */, [TypeScript.SyntaxFacts.getText(47 /* ExportKeyword */), TypeScript.SyntaxFacts.getText(64 /* DeclareKeyword */)]); - return; - } - - seenExportModifier = true; - } - - modifierFullStart += modifier.fullWidth(); - } - - return false; - }; - - GrammarCheckerWalker.prototype.checkForDisallowedImportDeclaration = function (node) { - if (node.stringLiteral === null) { - var currentElementFullStart = this.childFullStart(node, node.moduleElements); - - for (var i = 0, n = node.moduleElements.childCount(); i < n; i++) { - var child = node.moduleElements.childAt(i); - if (child.kind() === 133 /* ImportDeclaration */) { - var importDeclaration = child; - if (importDeclaration.moduleReference.kind() === 245 /* ExternalModuleReference */) { - this.pushDiagnostic1(currentElementFullStart, importDeclaration, 201 /* Import_declarations_in_an_internal_module_cannot_reference_an_external_module */, null); - } - } - - currentElementFullStart += child.fullWidth(); - } - } - - return false; - }; - - GrammarCheckerWalker.prototype.visitModuleDeclaration = function (node) { - if (this.checkForReservedName(node, node.moduleName, 63 /* Module_name_cannot_be__0_ */) || this.checkForDisallowedDeclareModifier(node.modifiers) || this.checkForRequiredDeclareModifier(node, node.moduleKeyword, node.modifiers) || this.checkModuleElementModifiers(node.modifiers) || this.checkForDisallowedImportDeclaration(node) || this.checkForDisallowedExports(node, node.moduleElements) || this.checkForMultipleExportAssignments(node, node.moduleElements)) { - this.skip(node); - return; - } - - if (!TypeScript.SyntaxUtilities.containsToken(node.modifiers, 64 /* DeclareKeyword */) && this.checkFunctionOverloads(node, node.moduleElements)) { - this.skip(node); - return; - } - - if (node.stringLiteral && !this.inAmbientDeclaration && !TypeScript.SyntaxUtilities.containsToken(node.modifiers, 64 /* DeclareKeyword */)) { - var stringLiteralFullStart = this.childFullStart(node, node.stringLiteral); - this.pushDiagnostic1(stringLiteralFullStart, node.stringLiteral, 38 /* Non_ambient_modules_cannot_use_quoted_names */); - this.skip(node); - return; - } - - if (!node.stringLiteral && this.checkForDisallowedExportAssignment(node)) { - this.skip(node); - return; - } - - var savedInAmbientDeclaration = this.inAmbientDeclaration; - this.inAmbientDeclaration = this.inAmbientDeclaration || this.syntaxTree.isDeclaration() || TypeScript.SyntaxUtilities.containsToken(node.modifiers, 64 /* DeclareKeyword */); - _super.prototype.visitModuleDeclaration.call(this, node); - this.inAmbientDeclaration = savedInAmbientDeclaration; - }; - - GrammarCheckerWalker.prototype.checkForDisallowedExports = function (node, moduleElements) { - var seenExportedElement = false; - for (var i = 0, n = moduleElements.childCount(); i < n; i++) { - var child = moduleElements.childAt(i); - - if (TypeScript.SyntaxUtilities.hasExportKeyword(child)) { - seenExportedElement = true; - break; - } - } - - var moduleElementFullStart = this.childFullStart(node, moduleElements); - if (seenExportedElement) { - for (var i = 0, n = moduleElements.childCount(); i < n; i++) { - var child = moduleElements.childAt(i); - - if (child.kind() === 134 /* ExportAssignment */) { - this.pushDiagnostic1(moduleElementFullStart, child, 67 /* Export_assignment_not_allowed_in_module_with_exported_element */); - return true; - } - - moduleElementFullStart += child.fullWidth(); - } - } - - return false; - }; - - GrammarCheckerWalker.prototype.checkForMultipleExportAssignments = function (node, moduleElements) { - var moduleElementFullStart = this.childFullStart(node, moduleElements); - var seenExportAssignment = false; - var errorFound = false; - for (var i = 0, n = moduleElements.childCount(); i < n; i++) { - var child = moduleElements.childAt(i); - if (child.kind() === 134 /* ExportAssignment */) { - if (seenExportAssignment) { - this.pushDiagnostic1(moduleElementFullStart, child, 68 /* Module_cannot_have_multiple_export_assignments */); - errorFound = true; - } - seenExportAssignment = true; - } - - moduleElementFullStart += child.fullWidth(); - } - - return errorFound; - }; - - GrammarCheckerWalker.prototype.checkForDisallowedExportAssignment = function (node) { - var moduleElementFullStart = this.childFullStart(node, node.moduleElements); - - for (var i = 0, n = node.moduleElements.childCount(); i < n; i++) { - var child = node.moduleElements.childAt(i); - - if (child.kind() === 134 /* ExportAssignment */) { - this.pushDiagnostic1(moduleElementFullStart, child, 66 /* Export_assignments_cannot_be_used_in_internal_modules */); - - return true; - } - - moduleElementFullStart += child.fullWidth(); - } - - return false; - }; - - GrammarCheckerWalker.prototype.visitBlock = function (node) { - if (this.inAmbientDeclaration || this.syntaxTree.isDeclaration()) { - this.pushDiagnostic1(this.position(), node.firstToken(), 40 /* Implementations_are_not_allowed_in_ambient_contexts */); - this.skip(node); - return; - } - - if (this.checkFunctionOverloads(node, node.statements)) { - this.skip(node); - return; - } - - var savedInBlock = this.inBlock; - this.inBlock = true; - _super.prototype.visitBlock.call(this, node); - this.inBlock = savedInBlock; - }; - - GrammarCheckerWalker.prototype.checkForStatementInAmbientContxt = function (node) { - if (this.inAmbientDeclaration || this.syntaxTree.isDeclaration()) { - this.pushDiagnostic1(this.position(), node.firstToken(), 39 /* Statements_are_not_allowed_in_ambient_contexts */); - return true; - } - - return false; - }; - - GrammarCheckerWalker.prototype.visitBreakStatement = function (node) { - if (this.checkForStatementInAmbientContxt(node)) { - this.skip(node); - return; - } - - _super.prototype.visitBreakStatement.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitContinueStatement = function (node) { - if (this.checkForStatementInAmbientContxt(node)) { - this.skip(node); - return; - } - - _super.prototype.visitContinueStatement.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitDebuggerStatement = function (node) { - if (this.checkForStatementInAmbientContxt(node)) { - this.skip(node); - return; - } - - _super.prototype.visitDebuggerStatement.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitDoStatement = function (node) { - if (this.checkForStatementInAmbientContxt(node)) { - this.skip(node); - return; - } - - _super.prototype.visitDoStatement.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitEmptyStatement = function (node) { - if (this.checkForStatementInAmbientContxt(node)) { - this.skip(node); - return; - } - - _super.prototype.visitEmptyStatement.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitExpressionStatement = function (node) { - if (this.checkForStatementInAmbientContxt(node)) { - this.skip(node); - return; - } - - _super.prototype.visitExpressionStatement.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitForInStatement = function (node) { - if (this.checkForStatementInAmbientContxt(node)) { - this.skip(node); - return; - } - - _super.prototype.visitForInStatement.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitForStatement = function (node) { - if (this.checkForStatementInAmbientContxt(node)) { - this.skip(node); - return; - } - - _super.prototype.visitForStatement.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitIfStatement = function (node) { - if (this.checkForStatementInAmbientContxt(node)) { - this.skip(node); - return; - } - - _super.prototype.visitIfStatement.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitLabeledStatement = function (node) { - if (this.checkForStatementInAmbientContxt(node)) { - this.skip(node); - return; - } - - _super.prototype.visitLabeledStatement.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitReturnStatement = function (node) { - if (this.checkForStatementInAmbientContxt(node)) { - this.skip(node); - return; - } - - _super.prototype.visitReturnStatement.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitSwitchStatement = function (node) { - if (this.checkForStatementInAmbientContxt(node)) { - this.skip(node); - return; - } - - _super.prototype.visitSwitchStatement.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitThrowStatement = function (node) { - if (this.checkForStatementInAmbientContxt(node)) { - this.skip(node); - return; - } - - _super.prototype.visitThrowStatement.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitTryStatement = function (node) { - if (this.checkForStatementInAmbientContxt(node)) { - this.skip(node); - return; - } - - _super.prototype.visitTryStatement.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitWhileStatement = function (node) { - if (this.checkForStatementInAmbientContxt(node)) { - this.skip(node); - return; - } - - _super.prototype.visitWhileStatement.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitWithStatement = function (node) { - if (this.checkForStatementInAmbientContxt(node)) { - this.skip(node); - return; - } - - _super.prototype.visitWithStatement.call(this, node); - }; - - GrammarCheckerWalker.prototype.checkForDisallowedModifiers = function (parent, modifiers) { - if (this.inBlock && modifiers.childCount() > 0) { - var modifierFullStart = this.childFullStart(parent, modifiers); - this.pushDiagnostic1(modifierFullStart, modifiers.childAt(0), 58 /* Modifiers_cannot_appear_here */); - return true; - } - - return false; - }; - - GrammarCheckerWalker.prototype.visitFunctionDeclaration = function (node) { - if (this.checkForDisallowedDeclareModifier(node.modifiers) || this.checkForDisallowedModifiers(node, node.modifiers) || this.checkForRequiredDeclareModifier(node, node.functionKeyword, node.modifiers) || this.checkModuleElementModifiers(node.modifiers)) { - this.skip(node); - return; - } - - var savedInAmbientDeclaration = this.inAmbientDeclaration; - this.inAmbientDeclaration = this.inAmbientDeclaration || this.syntaxTree.isDeclaration() || TypeScript.SyntaxUtilities.containsToken(node.modifiers, 64 /* DeclareKeyword */); - _super.prototype.visitFunctionDeclaration.call(this, node); - this.inAmbientDeclaration = savedInAmbientDeclaration; - }; - - GrammarCheckerWalker.prototype.visitVariableStatement = function (node) { - if (this.checkForDisallowedDeclareModifier(node.modifiers) || this.checkForDisallowedModifiers(node, node.modifiers) || this.checkForRequiredDeclareModifier(node, node.variableDeclaration, node.modifiers) || this.checkModuleElementModifiers(node.modifiers)) { - this.skip(node); - return; - } - - var savedInAmbientDeclaration = this.inAmbientDeclaration; - this.inAmbientDeclaration = this.inAmbientDeclaration || this.syntaxTree.isDeclaration() || TypeScript.SyntaxUtilities.containsToken(node.modifiers, 64 /* DeclareKeyword */); - _super.prototype.visitVariableStatement.call(this, node); - this.inAmbientDeclaration = savedInAmbientDeclaration; - }; - - GrammarCheckerWalker.prototype.checkListSeparators = function (parent, list, kind) { - var currentElementFullStart = this.childFullStart(parent, list); - - for (var i = 0, n = list.childCount(); i < n; i++) { - var child = list.childAt(i); - if (i % 2 === 1 && child.kind() !== kind) { - this.pushDiagnostic1(currentElementFullStart, child, 9 /* _0_expected */, [TypeScript.SyntaxFacts.getText(kind)]); - } - - currentElementFullStart += child.fullWidth(); - } - - return false; - }; - - GrammarCheckerWalker.prototype.visitObjectType = function (node) { - if (this.checkListSeparators(node, node.typeMembers, 79 /* SemicolonToken */)) { - this.skip(node); - return; - } - - var savedInAmbientDeclaration = this.inAmbientDeclaration; - this.inAmbientDeclaration = true; - _super.prototype.visitObjectType.call(this, node); - this.inAmbientDeclaration = savedInAmbientDeclaration; - }; - - GrammarCheckerWalker.prototype.visitArrayType = function (node) { - var savedInAmbientDeclaration = this.inAmbientDeclaration; - this.inAmbientDeclaration = true; - _super.prototype.visitArrayType.call(this, node); - this.inAmbientDeclaration = savedInAmbientDeclaration; - }; - - GrammarCheckerWalker.prototype.visitFunctionType = function (node) { - var savedInAmbientDeclaration = this.inAmbientDeclaration; - this.inAmbientDeclaration = true; - _super.prototype.visitFunctionType.call(this, node); - this.inAmbientDeclaration = savedInAmbientDeclaration; - }; - - GrammarCheckerWalker.prototype.visitConstructorType = function (node) { - var savedInAmbientDeclaration = this.inAmbientDeclaration; - this.inAmbientDeclaration = true; - _super.prototype.visitConstructorType.call(this, node); - this.inAmbientDeclaration = savedInAmbientDeclaration; - }; - - GrammarCheckerWalker.prototype.visitEqualsValueClause = function (node) { - if (this.inAmbientDeclaration) { - this.pushDiagnostic1(this.position(), node.firstToken(), 42 /* Initializers_are_not_allowed_in_ambient_contexts */); - this.skip(node); - return; - } - - _super.prototype.visitEqualsValueClause.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitConstructorDeclaration = function (node) { - var savedCurrentConstructor = this.currentConstructor; - this.currentConstructor = node; - _super.prototype.visitConstructorDeclaration.call(this, node); - this.currentConstructor = savedCurrentConstructor; - }; - - GrammarCheckerWalker.prototype.visitSourceUnit = function (node) { - if (this.checkFunctionOverloads(node, node.moduleElements) || this.checkForDisallowedExports(node, node.moduleElements) || this.checkForMultipleExportAssignments(node, node.moduleElements)) { - this.skip(node); - return; - } - - _super.prototype.visitSourceUnit.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitExternalModuleReference = function (node) { - if (node.moduleOrRequireKeyword.tokenKind === 66 /* ModuleKeyword */ && !this.syntaxTree.parseOptions().allowModuleKeywordInExternalModuleReference()) { - this.pushDiagnostic1(this.position(), node.moduleOrRequireKeyword, 65 /* _module_______is_deprecated__Use__require_______instead */); - this.skip(node); - return; - } - - _super.prototype.visitExternalModuleReference.call(this, node); - }; - return GrammarCheckerWalker; - })(TypeScript.PositionTrackingWalker); -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var TextSpanWalker = (function (_super) { - __extends(TextSpanWalker, _super); - function TextSpanWalker(textSpan) { - _super.call(this); - this.textSpan = textSpan; - this._position = 0; - } - TextSpanWalker.prototype.visitToken = function (token) { - this._position += token.fullWidth(); - }; - - TextSpanWalker.prototype.visitNode = function (node) { - var nodeSpan = new TypeScript.TextSpan(this.position(), node.fullWidth()); - - if (nodeSpan.intersectsWithTextSpan(this.textSpan)) { - node.accept(this); - } else { - this._position += node.fullWidth(); - } - }; - - TextSpanWalker.prototype.position = function () { - return this._position; - }; - return TextSpanWalker; - })(TypeScript.SyntaxWalker); -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var Unicode = (function () { - function Unicode() { - } - Unicode.lookupInUnicodeMap = function (code, map) { - if (code < map[0]) { - return false; - } - - var lo = 0; - var hi = map.length; - var mid; - - while (lo + 1 < hi) { - mid = lo + (hi - lo) / 2; - - mid -= mid % 2; - if (map[mid] <= code && code <= map[mid + 1]) { - return true; - } - - if (code < map[mid]) { - hi = mid; - } else { - lo = mid + 2; - } - } - - return false; - }; - - Unicode.isIdentifierStart = function (code, languageVersion) { - if (languageVersion === 0 /* EcmaScript3 */) { - return Unicode.lookupInUnicodeMap(code, Unicode.unicodeES3IdentifierStart); - } else if (languageVersion === 1 /* EcmaScript5 */) { - return Unicode.lookupInUnicodeMap(code, Unicode.unicodeES5IdentifierStart); - } else { - throw TypeScript.Errors.argumentOutOfRange("languageVersion"); - } - }; - - Unicode.isIdentifierPart = function (code, languageVersion) { - if (languageVersion === 0 /* EcmaScript3 */) { - return Unicode.lookupInUnicodeMap(code, Unicode.unicodeES3IdentifierPart); - } else if (languageVersion === 1 /* EcmaScript5 */) { - return Unicode.lookupInUnicodeMap(code, Unicode.unicodeES5IdentifierPart); - } else { - throw TypeScript.Errors.argumentOutOfRange("languageVersion"); - } - }; - Unicode.unicodeES3IdentifierStart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 543, 546, 563, 592, 685, 688, 696, 699, 705, 720, 721, 736, 740, 750, 750, 890, 890, 902, 902, 904, 906, 908, 908, 910, 929, 931, 974, 976, 983, 986, 1011, 1024, 1153, 1164, 1220, 1223, 1224, 1227, 1228, 1232, 1269, 1272, 1273, 1329, 1366, 1369, 1369, 1377, 1415, 1488, 1514, 1520, 1522, 1569, 1594, 1600, 1610, 1649, 1747, 1749, 1749, 1765, 1766, 1786, 1788, 1808, 1808, 1810, 1836, 1920, 1957, 2309, 2361, 2365, 2365, 2384, 2384, 2392, 2401, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2524, 2525, 2527, 2529, 2544, 2545, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2649, 2652, 2654, 2654, 2674, 2676, 2693, 2699, 2701, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2749, 2749, 2768, 2768, 2784, 2784, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2870, 2873, 2877, 2877, 2908, 2909, 2911, 2913, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 2997, 2999, 3001, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3168, 3169, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3294, 3294, 3296, 3297, 3333, 3340, 3342, 3344, 3346, 3368, 3370, 3385, 3424, 3425, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3585, 3632, 3634, 3635, 3648, 3654, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3760, 3762, 3763, 3773, 3773, 3776, 3780, 3782, 3782, 3804, 3805, 3840, 3840, 3904, 3911, 3913, 3946, 3976, 3979, 4096, 4129, 4131, 4135, 4137, 4138, 4176, 4181, 4256, 4293, 4304, 4342, 4352, 4441, 4447, 4514, 4520, 4601, 4608, 4614, 4616, 4678, 4680, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4742, 4744, 4744, 4746, 4749, 4752, 4782, 4784, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4814, 4816, 4822, 4824, 4846, 4848, 4878, 4880, 4880, 4882, 4885, 4888, 4894, 4896, 4934, 4936, 4954, 5024, 5108, 5121, 5740, 5743, 5750, 5761, 5786, 5792, 5866, 6016, 6067, 6176, 6263, 6272, 6312, 7680, 7835, 7840, 7929, 7936, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8319, 8319, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8497, 8499, 8505, 8544, 8579, 12293, 12295, 12321, 12329, 12337, 12341, 12344, 12346, 12353, 12436, 12445, 12446, 12449, 12538, 12540, 12542, 12549, 12588, 12593, 12686, 12704, 12727, 13312, 19893, 19968, 40869, 40960, 42124, 44032, 55203, 63744, 64045, 64256, 64262, 64275, 64279, 64285, 64285, 64287, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65136, 65138, 65140, 65140, 65142, 65276, 65313, 65338, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500]; - Unicode.unicodeES3IdentifierPart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 543, 546, 563, 592, 685, 688, 696, 699, 705, 720, 721, 736, 740, 750, 750, 768, 846, 864, 866, 890, 890, 902, 902, 904, 906, 908, 908, 910, 929, 931, 974, 976, 983, 986, 1011, 1024, 1153, 1155, 1158, 1164, 1220, 1223, 1224, 1227, 1228, 1232, 1269, 1272, 1273, 1329, 1366, 1369, 1369, 1377, 1415, 1425, 1441, 1443, 1465, 1467, 1469, 1471, 1471, 1473, 1474, 1476, 1476, 1488, 1514, 1520, 1522, 1569, 1594, 1600, 1621, 1632, 1641, 1648, 1747, 1749, 1756, 1759, 1768, 1770, 1773, 1776, 1788, 1808, 1836, 1840, 1866, 1920, 1968, 2305, 2307, 2309, 2361, 2364, 2381, 2384, 2388, 2392, 2403, 2406, 2415, 2433, 2435, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2492, 2492, 2494, 2500, 2503, 2504, 2507, 2509, 2519, 2519, 2524, 2525, 2527, 2531, 2534, 2545, 2562, 2562, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2620, 2620, 2622, 2626, 2631, 2632, 2635, 2637, 2649, 2652, 2654, 2654, 2662, 2676, 2689, 2691, 2693, 2699, 2701, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2748, 2757, 2759, 2761, 2763, 2765, 2768, 2768, 2784, 2784, 2790, 2799, 2817, 2819, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2870, 2873, 2876, 2883, 2887, 2888, 2891, 2893, 2902, 2903, 2908, 2909, 2911, 2913, 2918, 2927, 2946, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 2997, 2999, 3001, 3006, 3010, 3014, 3016, 3018, 3021, 3031, 3031, 3047, 3055, 3073, 3075, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3134, 3140, 3142, 3144, 3146, 3149, 3157, 3158, 3168, 3169, 3174, 3183, 3202, 3203, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3262, 3268, 3270, 3272, 3274, 3277, 3285, 3286, 3294, 3294, 3296, 3297, 3302, 3311, 3330, 3331, 3333, 3340, 3342, 3344, 3346, 3368, 3370, 3385, 3390, 3395, 3398, 3400, 3402, 3405, 3415, 3415, 3424, 3425, 3430, 3439, 3458, 3459, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3530, 3530, 3535, 3540, 3542, 3542, 3544, 3551, 3570, 3571, 3585, 3642, 3648, 3662, 3664, 3673, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3769, 3771, 3773, 3776, 3780, 3782, 3782, 3784, 3789, 3792, 3801, 3804, 3805, 3840, 3840, 3864, 3865, 3872, 3881, 3893, 3893, 3895, 3895, 3897, 3897, 3902, 3911, 3913, 3946, 3953, 3972, 3974, 3979, 3984, 3991, 3993, 4028, 4038, 4038, 4096, 4129, 4131, 4135, 4137, 4138, 4140, 4146, 4150, 4153, 4160, 4169, 4176, 4185, 4256, 4293, 4304, 4342, 4352, 4441, 4447, 4514, 4520, 4601, 4608, 4614, 4616, 4678, 4680, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4742, 4744, 4744, 4746, 4749, 4752, 4782, 4784, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4814, 4816, 4822, 4824, 4846, 4848, 4878, 4880, 4880, 4882, 4885, 4888, 4894, 4896, 4934, 4936, 4954, 4969, 4977, 5024, 5108, 5121, 5740, 5743, 5750, 5761, 5786, 5792, 5866, 6016, 6099, 6112, 6121, 6160, 6169, 6176, 6263, 6272, 6313, 7680, 7835, 7840, 7929, 7936, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8255, 8256, 8319, 8319, 8400, 8412, 8417, 8417, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8497, 8499, 8505, 8544, 8579, 12293, 12295, 12321, 12335, 12337, 12341, 12344, 12346, 12353, 12436, 12441, 12442, 12445, 12446, 12449, 12542, 12549, 12588, 12593, 12686, 12704, 12727, 13312, 19893, 19968, 40869, 40960, 42124, 44032, 55203, 63744, 64045, 64256, 64262, 64275, 64279, 64285, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65056, 65059, 65075, 65076, 65101, 65103, 65136, 65138, 65140, 65140, 65142, 65276, 65296, 65305, 65313, 65338, 65343, 65343, 65345, 65370, 65381, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500]; - - Unicode.unicodeES5IdentifierStart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 705, 710, 721, 736, 740, 748, 748, 750, 750, 880, 884, 886, 887, 890, 893, 902, 902, 904, 906, 908, 908, 910, 929, 931, 1013, 1015, 1153, 1162, 1319, 1329, 1366, 1369, 1369, 1377, 1415, 1488, 1514, 1520, 1522, 1568, 1610, 1646, 1647, 1649, 1747, 1749, 1749, 1765, 1766, 1774, 1775, 1786, 1788, 1791, 1791, 1808, 1808, 1810, 1839, 1869, 1957, 1969, 1969, 1994, 2026, 2036, 2037, 2042, 2042, 2048, 2069, 2074, 2074, 2084, 2084, 2088, 2088, 2112, 2136, 2208, 2208, 2210, 2220, 2308, 2361, 2365, 2365, 2384, 2384, 2392, 2401, 2417, 2423, 2425, 2431, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2493, 2493, 2510, 2510, 2524, 2525, 2527, 2529, 2544, 2545, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2649, 2652, 2654, 2654, 2674, 2676, 2693, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2749, 2749, 2768, 2768, 2784, 2785, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2869, 2873, 2877, 2877, 2908, 2909, 2911, 2913, 2929, 2929, 2947, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 3001, 3024, 3024, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3133, 3133, 3160, 3161, 3168, 3169, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3261, 3261, 3294, 3294, 3296, 3297, 3313, 3314, 3333, 3340, 3342, 3344, 3346, 3386, 3389, 3389, 3406, 3406, 3424, 3425, 3450, 3455, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3585, 3632, 3634, 3635, 3648, 3654, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3760, 3762, 3763, 3773, 3773, 3776, 3780, 3782, 3782, 3804, 3807, 3840, 3840, 3904, 3911, 3913, 3948, 3976, 3980, 4096, 4138, 4159, 4159, 4176, 4181, 4186, 4189, 4193, 4193, 4197, 4198, 4206, 4208, 4213, 4225, 4238, 4238, 4256, 4293, 4295, 4295, 4301, 4301, 4304, 4346, 4348, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4744, 4746, 4749, 4752, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4822, 4824, 4880, 4882, 4885, 4888, 4954, 4992, 5007, 5024, 5108, 5121, 5740, 5743, 5759, 5761, 5786, 5792, 5866, 5870, 5872, 5888, 5900, 5902, 5905, 5920, 5937, 5952, 5969, 5984, 5996, 5998, 6000, 6016, 6067, 6103, 6103, 6108, 6108, 6176, 6263, 6272, 6312, 6314, 6314, 6320, 6389, 6400, 6428, 6480, 6509, 6512, 6516, 6528, 6571, 6593, 6599, 6656, 6678, 6688, 6740, 6823, 6823, 6917, 6963, 6981, 6987, 7043, 7072, 7086, 7087, 7098, 7141, 7168, 7203, 7245, 7247, 7258, 7293, 7401, 7404, 7406, 7409, 7413, 7414, 7424, 7615, 7680, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8305, 8305, 8319, 8319, 8336, 8348, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8505, 8508, 8511, 8517, 8521, 8526, 8526, 8544, 8584, 11264, 11310, 11312, 11358, 11360, 11492, 11499, 11502, 11506, 11507, 11520, 11557, 11559, 11559, 11565, 11565, 11568, 11623, 11631, 11631, 11648, 11670, 11680, 11686, 11688, 11694, 11696, 11702, 11704, 11710, 11712, 11718, 11720, 11726, 11728, 11734, 11736, 11742, 11823, 11823, 12293, 12295, 12321, 12329, 12337, 12341, 12344, 12348, 12353, 12438, 12445, 12447, 12449, 12538, 12540, 12543, 12549, 12589, 12593, 12686, 12704, 12730, 12784, 12799, 13312, 19893, 19968, 40908, 40960, 42124, 42192, 42237, 42240, 42508, 42512, 42527, 42538, 42539, 42560, 42606, 42623, 42647, 42656, 42735, 42775, 42783, 42786, 42888, 42891, 42894, 42896, 42899, 42912, 42922, 43000, 43009, 43011, 43013, 43015, 43018, 43020, 43042, 43072, 43123, 43138, 43187, 43250, 43255, 43259, 43259, 43274, 43301, 43312, 43334, 43360, 43388, 43396, 43442, 43471, 43471, 43520, 43560, 43584, 43586, 43588, 43595, 43616, 43638, 43642, 43642, 43648, 43695, 43697, 43697, 43701, 43702, 43705, 43709, 43712, 43712, 43714, 43714, 43739, 43741, 43744, 43754, 43762, 43764, 43777, 43782, 43785, 43790, 43793, 43798, 43808, 43814, 43816, 43822, 43968, 44002, 44032, 55203, 55216, 55238, 55243, 55291, 63744, 64109, 64112, 64217, 64256, 64262, 64275, 64279, 64285, 64285, 64287, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65136, 65140, 65142, 65276, 65313, 65338, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500]; - Unicode.unicodeES5IdentifierPart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 705, 710, 721, 736, 740, 748, 748, 750, 750, 768, 884, 886, 887, 890, 893, 902, 902, 904, 906, 908, 908, 910, 929, 931, 1013, 1015, 1153, 1155, 1159, 1162, 1319, 1329, 1366, 1369, 1369, 1377, 1415, 1425, 1469, 1471, 1471, 1473, 1474, 1476, 1477, 1479, 1479, 1488, 1514, 1520, 1522, 1552, 1562, 1568, 1641, 1646, 1747, 1749, 1756, 1759, 1768, 1770, 1788, 1791, 1791, 1808, 1866, 1869, 1969, 1984, 2037, 2042, 2042, 2048, 2093, 2112, 2139, 2208, 2208, 2210, 2220, 2276, 2302, 2304, 2403, 2406, 2415, 2417, 2423, 2425, 2431, 2433, 2435, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2492, 2500, 2503, 2504, 2507, 2510, 2519, 2519, 2524, 2525, 2527, 2531, 2534, 2545, 2561, 2563, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2620, 2620, 2622, 2626, 2631, 2632, 2635, 2637, 2641, 2641, 2649, 2652, 2654, 2654, 2662, 2677, 2689, 2691, 2693, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2748, 2757, 2759, 2761, 2763, 2765, 2768, 2768, 2784, 2787, 2790, 2799, 2817, 2819, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2869, 2873, 2876, 2884, 2887, 2888, 2891, 2893, 2902, 2903, 2908, 2909, 2911, 2915, 2918, 2927, 2929, 2929, 2946, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 3001, 3006, 3010, 3014, 3016, 3018, 3021, 3024, 3024, 3031, 3031, 3046, 3055, 3073, 3075, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3133, 3140, 3142, 3144, 3146, 3149, 3157, 3158, 3160, 3161, 3168, 3171, 3174, 3183, 3202, 3203, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3260, 3268, 3270, 3272, 3274, 3277, 3285, 3286, 3294, 3294, 3296, 3299, 3302, 3311, 3313, 3314, 3330, 3331, 3333, 3340, 3342, 3344, 3346, 3386, 3389, 3396, 3398, 3400, 3402, 3406, 3415, 3415, 3424, 3427, 3430, 3439, 3450, 3455, 3458, 3459, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3530, 3530, 3535, 3540, 3542, 3542, 3544, 3551, 3570, 3571, 3585, 3642, 3648, 3662, 3664, 3673, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3769, 3771, 3773, 3776, 3780, 3782, 3782, 3784, 3789, 3792, 3801, 3804, 3807, 3840, 3840, 3864, 3865, 3872, 3881, 3893, 3893, 3895, 3895, 3897, 3897, 3902, 3911, 3913, 3948, 3953, 3972, 3974, 3991, 3993, 4028, 4038, 4038, 4096, 4169, 4176, 4253, 4256, 4293, 4295, 4295, 4301, 4301, 4304, 4346, 4348, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4744, 4746, 4749, 4752, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4822, 4824, 4880, 4882, 4885, 4888, 4954, 4957, 4959, 4992, 5007, 5024, 5108, 5121, 5740, 5743, 5759, 5761, 5786, 5792, 5866, 5870, 5872, 5888, 5900, 5902, 5908, 5920, 5940, 5952, 5971, 5984, 5996, 5998, 6000, 6002, 6003, 6016, 6099, 6103, 6103, 6108, 6109, 6112, 6121, 6155, 6157, 6160, 6169, 6176, 6263, 6272, 6314, 6320, 6389, 6400, 6428, 6432, 6443, 6448, 6459, 6470, 6509, 6512, 6516, 6528, 6571, 6576, 6601, 6608, 6617, 6656, 6683, 6688, 6750, 6752, 6780, 6783, 6793, 6800, 6809, 6823, 6823, 6912, 6987, 6992, 7001, 7019, 7027, 7040, 7155, 7168, 7223, 7232, 7241, 7245, 7293, 7376, 7378, 7380, 7414, 7424, 7654, 7676, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8204, 8205, 8255, 8256, 8276, 8276, 8305, 8305, 8319, 8319, 8336, 8348, 8400, 8412, 8417, 8417, 8421, 8432, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8505, 8508, 8511, 8517, 8521, 8526, 8526, 8544, 8584, 11264, 11310, 11312, 11358, 11360, 11492, 11499, 11507, 11520, 11557, 11559, 11559, 11565, 11565, 11568, 11623, 11631, 11631, 11647, 11670, 11680, 11686, 11688, 11694, 11696, 11702, 11704, 11710, 11712, 11718, 11720, 11726, 11728, 11734, 11736, 11742, 11744, 11775, 11823, 11823, 12293, 12295, 12321, 12335, 12337, 12341, 12344, 12348, 12353, 12438, 12441, 12442, 12445, 12447, 12449, 12538, 12540, 12543, 12549, 12589, 12593, 12686, 12704, 12730, 12784, 12799, 13312, 19893, 19968, 40908, 40960, 42124, 42192, 42237, 42240, 42508, 42512, 42539, 42560, 42607, 42612, 42621, 42623, 42647, 42655, 42737, 42775, 42783, 42786, 42888, 42891, 42894, 42896, 42899, 42912, 42922, 43000, 43047, 43072, 43123, 43136, 43204, 43216, 43225, 43232, 43255, 43259, 43259, 43264, 43309, 43312, 43347, 43360, 43388, 43392, 43456, 43471, 43481, 43520, 43574, 43584, 43597, 43600, 43609, 43616, 43638, 43642, 43643, 43648, 43714, 43739, 43741, 43744, 43759, 43762, 43766, 43777, 43782, 43785, 43790, 43793, 43798, 43808, 43814, 43816, 43822, 43968, 44010, 44012, 44013, 44016, 44025, 44032, 55203, 55216, 55238, 55243, 55291, 63744, 64109, 64112, 64217, 64256, 64262, 64275, 64279, 64285, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65024, 65039, 65056, 65062, 65075, 65076, 65101, 65103, 65136, 65140, 65142, 65276, 65296, 65305, 65313, 65338, 65343, 65343, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500]; - return Unicode; - })(); - TypeScript.Unicode = Unicode; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - function hasFlag(val, flag) { - return (val & flag) !== 0; - } - TypeScript.hasFlag = hasFlag; - - function withoutFlag(val, flag) { - return val & ~flag; - } - TypeScript.withoutFlag = withoutFlag; - - (function (ASTFlags) { - ASTFlags[ASTFlags["None"] = 0] = "None"; - ASTFlags[ASTFlags["SingleLine"] = 1 << 1] = "SingleLine"; - ASTFlags[ASTFlags["OptionalName"] = 1 << 2] = "OptionalName"; - ASTFlags[ASTFlags["TypeReference"] = 1 << 3] = "TypeReference"; - ASTFlags[ASTFlags["EnumElement"] = 1 << 4] = "EnumElement"; - ASTFlags[ASTFlags["EnumMapElement"] = 1 << 5] = "EnumMapElement"; - })(TypeScript.ASTFlags || (TypeScript.ASTFlags = {})); - var ASTFlags = TypeScript.ASTFlags; - - (function (DeclFlags) { - DeclFlags[DeclFlags["None"] = 0] = "None"; - DeclFlags[DeclFlags["Exported"] = 1] = "Exported"; - DeclFlags[DeclFlags["Private"] = 1 << 1] = "Private"; - DeclFlags[DeclFlags["Public"] = 1 << 2] = "Public"; - DeclFlags[DeclFlags["Ambient"] = 1 << 3] = "Ambient"; - DeclFlags[DeclFlags["Static"] = 1 << 4] = "Static"; - })(TypeScript.DeclFlags || (TypeScript.DeclFlags = {})); - var DeclFlags = TypeScript.DeclFlags; - - (function (ModuleFlags) { - ModuleFlags[ModuleFlags["None"] = 0] = "None"; - ModuleFlags[ModuleFlags["Exported"] = 1] = "Exported"; - ModuleFlags[ModuleFlags["Private"] = 1 << 1] = "Private"; - ModuleFlags[ModuleFlags["Public"] = 1 << 2] = "Public"; - ModuleFlags[ModuleFlags["Ambient"] = 1 << 3] = "Ambient"; - ModuleFlags[ModuleFlags["Static"] = 1 << 4] = "Static"; - ModuleFlags[ModuleFlags["IsEnum"] = 1 << 7] = "IsEnum"; - ModuleFlags[ModuleFlags["IsWholeFile"] = 1 << 8] = "IsWholeFile"; - ModuleFlags[ModuleFlags["IsDynamic"] = 1 << 9] = "IsDynamic"; - })(TypeScript.ModuleFlags || (TypeScript.ModuleFlags = {})); - var ModuleFlags = TypeScript.ModuleFlags; - - (function (VariableFlags) { - VariableFlags[VariableFlags["None"] = 0] = "None"; - VariableFlags[VariableFlags["Exported"] = 1] = "Exported"; - VariableFlags[VariableFlags["Private"] = 1 << 1] = "Private"; - VariableFlags[VariableFlags["Public"] = 1 << 2] = "Public"; - VariableFlags[VariableFlags["Ambient"] = 1 << 3] = "Ambient"; - VariableFlags[VariableFlags["Static"] = 1 << 4] = "Static"; - VariableFlags[VariableFlags["Property"] = 1 << 8] = "Property"; - VariableFlags[VariableFlags["ClassProperty"] = 1 << 11] = "ClassProperty"; - VariableFlags[VariableFlags["Constant"] = 1 << 12] = "Constant"; - - VariableFlags[VariableFlags["EnumElement"] = 1 << 13] = "EnumElement"; - })(TypeScript.VariableFlags || (TypeScript.VariableFlags = {})); - var VariableFlags = TypeScript.VariableFlags; - - (function (FunctionFlags) { - FunctionFlags[FunctionFlags["None"] = 0] = "None"; - FunctionFlags[FunctionFlags["Exported"] = 1] = "Exported"; - FunctionFlags[FunctionFlags["Private"] = 1 << 1] = "Private"; - FunctionFlags[FunctionFlags["Public"] = 1 << 2] = "Public"; - FunctionFlags[FunctionFlags["Ambient"] = 1 << 3] = "Ambient"; - FunctionFlags[FunctionFlags["Static"] = 1 << 4] = "Static"; - FunctionFlags[FunctionFlags["GetAccessor"] = 1 << 5] = "GetAccessor"; - FunctionFlags[FunctionFlags["SetAccessor"] = 1 << 6] = "SetAccessor"; - FunctionFlags[FunctionFlags["Signature"] = 1 << 7] = "Signature"; - FunctionFlags[FunctionFlags["Method"] = 1 << 8] = "Method"; - FunctionFlags[FunctionFlags["CallMember"] = 1 << 9] = "CallMember"; - FunctionFlags[FunctionFlags["ConstructMember"] = 1 << 10] = "ConstructMember"; - FunctionFlags[FunctionFlags["IsFatArrowFunction"] = 1 << 11] = "IsFatArrowFunction"; - FunctionFlags[FunctionFlags["IndexerMember"] = 1 << 12] = "IndexerMember"; - FunctionFlags[FunctionFlags["IsFunctionExpression"] = 1 << 13] = "IsFunctionExpression"; - FunctionFlags[FunctionFlags["IsFunctionProperty"] = 1 << 14] = "IsFunctionProperty"; - })(TypeScript.FunctionFlags || (TypeScript.FunctionFlags = {})); - var FunctionFlags = TypeScript.FunctionFlags; - - function ToDeclFlags(fncOrVarOrModuleFlags) { - return fncOrVarOrModuleFlags; - } - TypeScript.ToDeclFlags = ToDeclFlags; - - (function (TypeRelationshipFlags) { - TypeRelationshipFlags[TypeRelationshipFlags["SuccessfulComparison"] = 0] = "SuccessfulComparison"; - TypeRelationshipFlags[TypeRelationshipFlags["RequiredPropertyIsMissing"] = 1 << 1] = "RequiredPropertyIsMissing"; - TypeRelationshipFlags[TypeRelationshipFlags["IncompatibleSignatures"] = 1 << 2] = "IncompatibleSignatures"; - TypeRelationshipFlags[TypeRelationshipFlags["SourceSignatureHasTooManyParameters"] = 3] = "SourceSignatureHasTooManyParameters"; - TypeRelationshipFlags[TypeRelationshipFlags["IncompatibleReturnTypes"] = 1 << 4] = "IncompatibleReturnTypes"; - TypeRelationshipFlags[TypeRelationshipFlags["IncompatiblePropertyTypes"] = 1 << 5] = "IncompatiblePropertyTypes"; - TypeRelationshipFlags[TypeRelationshipFlags["IncompatibleParameterTypes"] = 1 << 6] = "IncompatibleParameterTypes"; - TypeRelationshipFlags[TypeRelationshipFlags["InconsistantPropertyAccesibility"] = 1 << 7] = "InconsistantPropertyAccesibility"; - })(TypeScript.TypeRelationshipFlags || (TypeScript.TypeRelationshipFlags = {})); - var TypeRelationshipFlags = TypeScript.TypeRelationshipFlags; - - (function (ModuleGenTarget) { - ModuleGenTarget[ModuleGenTarget["Synchronous"] = 0] = "Synchronous"; - ModuleGenTarget[ModuleGenTarget["Asynchronous"] = 1] = "Asynchronous"; - })(TypeScript.ModuleGenTarget || (TypeScript.ModuleGenTarget = {})); - var ModuleGenTarget = TypeScript.ModuleGenTarget; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (NodeType) { - NodeType[NodeType["None"] = 0] = "None"; - NodeType[NodeType["List"] = 1] = "List"; - NodeType[NodeType["Script"] = 2] = "Script"; - - NodeType[NodeType["TrueLiteral"] = 3] = "TrueLiteral"; - NodeType[NodeType["FalseLiteral"] = 4] = "FalseLiteral"; - NodeType[NodeType["StringLiteral"] = 5] = "StringLiteral"; - NodeType[NodeType["RegularExpressionLiteral"] = 6] = "RegularExpressionLiteral"; - NodeType[NodeType["NumericLiteral"] = 7] = "NumericLiteral"; - NodeType[NodeType["NullLiteral"] = 8] = "NullLiteral"; - - NodeType[NodeType["TypeParameter"] = 9] = "TypeParameter"; - NodeType[NodeType["GenericType"] = 10] = "GenericType"; - NodeType[NodeType["TypeRef"] = 11] = "TypeRef"; - - NodeType[NodeType["FunctionDeclaration"] = 12] = "FunctionDeclaration"; - NodeType[NodeType["ClassDeclaration"] = 13] = "ClassDeclaration"; - NodeType[NodeType["InterfaceDeclaration"] = 14] = "InterfaceDeclaration"; - NodeType[NodeType["ModuleDeclaration"] = 15] = "ModuleDeclaration"; - NodeType[NodeType["ImportDeclaration"] = 16] = "ImportDeclaration"; - NodeType[NodeType["VariableDeclarator"] = 17] = "VariableDeclarator"; - NodeType[NodeType["VariableDeclaration"] = 18] = "VariableDeclaration"; - NodeType[NodeType["Parameter"] = 19] = "Parameter"; - - NodeType[NodeType["Name"] = 20] = "Name"; - NodeType[NodeType["ArrayLiteralExpression"] = 21] = "ArrayLiteralExpression"; - NodeType[NodeType["ObjectLiteralExpression"] = 22] = "ObjectLiteralExpression"; - NodeType[NodeType["OmittedExpression"] = 23] = "OmittedExpression"; - NodeType[NodeType["VoidExpression"] = 24] = "VoidExpression"; - NodeType[NodeType["CommaExpression"] = 25] = "CommaExpression"; - NodeType[NodeType["PlusExpression"] = 26] = "PlusExpression"; - NodeType[NodeType["NegateExpression"] = 27] = "NegateExpression"; - NodeType[NodeType["DeleteExpression"] = 28] = "DeleteExpression"; - NodeType[NodeType["ThisExpression"] = 29] = "ThisExpression"; - NodeType[NodeType["SuperExpression"] = 30] = "SuperExpression"; - NodeType[NodeType["InExpression"] = 31] = "InExpression"; - NodeType[NodeType["MemberAccessExpression"] = 32] = "MemberAccessExpression"; - NodeType[NodeType["InstanceOfExpression"] = 33] = "InstanceOfExpression"; - NodeType[NodeType["TypeOfExpression"] = 34] = "TypeOfExpression"; - NodeType[NodeType["ElementAccessExpression"] = 35] = "ElementAccessExpression"; - NodeType[NodeType["InvocationExpression"] = 36] = "InvocationExpression"; - NodeType[NodeType["ObjectCreationExpression"] = 37] = "ObjectCreationExpression"; - NodeType[NodeType["AssignmentExpression"] = 38] = "AssignmentExpression"; - NodeType[NodeType["AddAssignmentExpression"] = 39] = "AddAssignmentExpression"; - NodeType[NodeType["SubtractAssignmentExpression"] = 40] = "SubtractAssignmentExpression"; - NodeType[NodeType["DivideAssignmentExpression"] = 41] = "DivideAssignmentExpression"; - NodeType[NodeType["MultiplyAssignmentExpression"] = 42] = "MultiplyAssignmentExpression"; - NodeType[NodeType["ModuloAssignmentExpression"] = 43] = "ModuloAssignmentExpression"; - NodeType[NodeType["AndAssignmentExpression"] = 44] = "AndAssignmentExpression"; - NodeType[NodeType["ExclusiveOrAssignmentExpression"] = 45] = "ExclusiveOrAssignmentExpression"; - NodeType[NodeType["OrAssignmentExpression"] = 46] = "OrAssignmentExpression"; - NodeType[NodeType["LeftShiftAssignmentExpression"] = 47] = "LeftShiftAssignmentExpression"; - NodeType[NodeType["SignedRightShiftAssignmentExpression"] = 48] = "SignedRightShiftAssignmentExpression"; - NodeType[NodeType["UnsignedRightShiftAssignmentExpression"] = 49] = "UnsignedRightShiftAssignmentExpression"; - NodeType[NodeType["ConditionalExpression"] = 50] = "ConditionalExpression"; - NodeType[NodeType["LogicalOrExpression"] = 51] = "LogicalOrExpression"; - NodeType[NodeType["LogicalAndExpression"] = 52] = "LogicalAndExpression"; - NodeType[NodeType["BitwiseOrExpression"] = 53] = "BitwiseOrExpression"; - NodeType[NodeType["BitwiseExclusiveOrExpression"] = 54] = "BitwiseExclusiveOrExpression"; - NodeType[NodeType["BitwiseAndExpression"] = 55] = "BitwiseAndExpression"; - NodeType[NodeType["EqualsWithTypeConversionExpression"] = 56] = "EqualsWithTypeConversionExpression"; - NodeType[NodeType["NotEqualsWithTypeConversionExpression"] = 57] = "NotEqualsWithTypeConversionExpression"; - NodeType[NodeType["EqualsExpression"] = 58] = "EqualsExpression"; - NodeType[NodeType["NotEqualsExpression"] = 59] = "NotEqualsExpression"; - NodeType[NodeType["LessThanExpression"] = 60] = "LessThanExpression"; - NodeType[NodeType["LessThanOrEqualExpression"] = 61] = "LessThanOrEqualExpression"; - NodeType[NodeType["GreaterThanExpression"] = 62] = "GreaterThanExpression"; - NodeType[NodeType["GreaterThanOrEqualExpression"] = 63] = "GreaterThanOrEqualExpression"; - NodeType[NodeType["AddExpression"] = 64] = "AddExpression"; - NodeType[NodeType["SubtractExpression"] = 65] = "SubtractExpression"; - NodeType[NodeType["MultiplyExpression"] = 66] = "MultiplyExpression"; - NodeType[NodeType["DivideExpression"] = 67] = "DivideExpression"; - NodeType[NodeType["ModuloExpression"] = 68] = "ModuloExpression"; - NodeType[NodeType["LeftShiftExpression"] = 69] = "LeftShiftExpression"; - NodeType[NodeType["SignedRightShiftExpression"] = 70] = "SignedRightShiftExpression"; - NodeType[NodeType["UnsignedRightShiftExpression"] = 71] = "UnsignedRightShiftExpression"; - NodeType[NodeType["BitwiseNotExpression"] = 72] = "BitwiseNotExpression"; - NodeType[NodeType["LogicalNotExpression"] = 73] = "LogicalNotExpression"; - NodeType[NodeType["PreIncrementExpression"] = 74] = "PreIncrementExpression"; - NodeType[NodeType["PreDecrementExpression"] = 75] = "PreDecrementExpression"; - NodeType[NodeType["PostIncrementExpression"] = 76] = "PostIncrementExpression"; - NodeType[NodeType["PostDecrementExpression"] = 77] = "PostDecrementExpression"; - NodeType[NodeType["CastExpression"] = 78] = "CastExpression"; - NodeType[NodeType["ParenthesizedExpression"] = 79] = "ParenthesizedExpression"; - NodeType[NodeType["Member"] = 80] = "Member"; - - NodeType[NodeType["Block"] = 81] = "Block"; - NodeType[NodeType["BreakStatement"] = 82] = "BreakStatement"; - NodeType[NodeType["ContinueStatement"] = 83] = "ContinueStatement"; - NodeType[NodeType["DebuggerStatement"] = 84] = "DebuggerStatement"; - NodeType[NodeType["DoStatement"] = 85] = "DoStatement"; - NodeType[NodeType["EmptyStatement"] = 86] = "EmptyStatement"; - NodeType[NodeType["ExportAssignment"] = 87] = "ExportAssignment"; - NodeType[NodeType["ExpressionStatement"] = 88] = "ExpressionStatement"; - NodeType[NodeType["ForInStatement"] = 89] = "ForInStatement"; - NodeType[NodeType["ForStatement"] = 90] = "ForStatement"; - NodeType[NodeType["IfStatement"] = 91] = "IfStatement"; - NodeType[NodeType["LabeledStatement"] = 92] = "LabeledStatement"; - NodeType[NodeType["ReturnStatement"] = 93] = "ReturnStatement"; - NodeType[NodeType["SwitchStatement"] = 94] = "SwitchStatement"; - NodeType[NodeType["ThrowStatement"] = 95] = "ThrowStatement"; - NodeType[NodeType["TryStatement"] = 96] = "TryStatement"; - NodeType[NodeType["VariableStatement"] = 97] = "VariableStatement"; - NodeType[NodeType["WhileStatement"] = 98] = "WhileStatement"; - NodeType[NodeType["WithStatement"] = 99] = "WithStatement"; - - NodeType[NodeType["CaseClause"] = 100] = "CaseClause"; - NodeType[NodeType["CatchClause"] = 101] = "CatchClause"; - - NodeType[NodeType["Comment"] = 102] = "Comment"; - })(TypeScript.NodeType || (TypeScript.NodeType = {})); - var NodeType = TypeScript.NodeType; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var BlockIntrinsics = (function () { - function BlockIntrinsics() { - this.prototype = undefined; - this.toString = undefined; - this.toLocaleString = undefined; - this.valueOf = undefined; - this.hasOwnProperty = undefined; - this.propertyIsEnumerable = undefined; - this.isPrototypeOf = undefined; - this["constructor"] = undefined; - } - return BlockIntrinsics; - })(); - TypeScript.BlockIntrinsics = BlockIntrinsics; - - var StringHashTable = (function () { - function StringHashTable() { - this.itemCount = 0; - this.table = (new BlockIntrinsics()); - } - StringHashTable.prototype.getAllKeys = function () { - var result = []; - - for (var k in this.table) { - if (this.table[k] !== undefined) { - result.push(k); - } - } - - return result; - }; - - StringHashTable.prototype.add = function (key, data) { - if (this.table[key] !== undefined) { - return false; - } - - this.table[key] = data; - this.itemCount++; - return true; - }; - - StringHashTable.prototype.addOrUpdate = function (key, data) { - if (this.table[key] !== undefined) { - this.table[key] = data; - return false; - } - - this.table[key] = data; - this.itemCount++; - return true; - }; - - StringHashTable.prototype.map = function (fn, context) { - for (var k in this.table) { - var data = this.table[k]; - - if (data !== undefined) { - fn(k, this.table[k], context); - } - } - }; - - StringHashTable.prototype.every = function (fn, context) { - 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; - }; - - StringHashTable.prototype.some = function (fn, context) { - 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; - }; - - StringHashTable.prototype.count = function () { - return this.itemCount; - }; - - StringHashTable.prototype.lookup = function (key) { - var data = this.table[key]; - return data === undefined ? null : data; - }; - return StringHashTable; - })(); - TypeScript.StringHashTable = StringHashTable; - - var IdentiferNameHashTable = (function (_super) { - __extends(IdentiferNameHashTable, _super); - function IdentiferNameHashTable() { - _super.apply(this, arguments); - } - IdentiferNameHashTable.prototype.getAllKeys = function () { - var result = []; - - _super.prototype.map.call(this, function (k, v, c) { - if (v !== undefined) { - result.push(k.substring(1)); - } - }, null); - - return result; - }; - - IdentiferNameHashTable.prototype.add = function (key, data) { - return _super.prototype.add.call(this, "#" + key, data); - }; - - IdentiferNameHashTable.prototype.addOrUpdate = function (key, data) { - return _super.prototype.addOrUpdate.call(this, "#" + key, data); - }; - - IdentiferNameHashTable.prototype.map = function (fn, context) { - return _super.prototype.map.call(this, function (k, v, c) { - return fn(k.substring(1), v, c); - }, context); - }; - - IdentiferNameHashTable.prototype.every = function (fn, context) { - return _super.prototype.every.call(this, function (k, v, c) { - return fn(k.substring(1), v, c); - }, context); - }; - - IdentiferNameHashTable.prototype.some = function (fn, context) { - return _super.prototype.some.call(this, function (k, v, c) { - return fn(k.substring(1), v, c); - }, context); - }; - - IdentiferNameHashTable.prototype.lookup = function (key) { - return _super.prototype.lookup.call(this, "#" + key); - }; - return IdentiferNameHashTable; - })(StringHashTable); - TypeScript.IdentiferNameHashTable = IdentiferNameHashTable; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var ASTSpan = (function () { - function ASTSpan() { - this.minChar = -1; - this.limChar = -1; - this.trailingTriviaWidth = 0; - } - return ASTSpan; - })(); - TypeScript.ASTSpan = ASTSpan; - - TypeScript.astID = 0; - - function structuralEqualsNotIncludingPosition(ast1, ast2) { - return structuralEquals(ast1, ast2, false); - } - TypeScript.structuralEqualsNotIncludingPosition = structuralEqualsNotIncludingPosition; - - function structuralEqualsIncludingPosition(ast1, ast2) { - return structuralEquals(ast1, ast2, true); - } - TypeScript.structuralEqualsIncludingPosition = structuralEqualsIncludingPosition; - - function structuralEquals(ast1, ast2, includingPosition) { - if (ast1 === ast2) { - return true; - } - - return ast1 !== null && ast2 !== null && ast1.nodeType === ast2.nodeType && ast1.structuralEquals(ast2, includingPosition); - } - - function astArrayStructuralEquals(array1, array2, includingPosition) { - return TypeScript.ArrayUtilities.sequenceEquals(array1, array2, includingPosition ? structuralEqualsIncludingPosition : structuralEqualsNotIncludingPosition); - } - - var AST = (function () { - function AST(nodeType) { - this.nodeType = nodeType; - this.minChar = -1; - this.limChar = -1; - this.trailingTriviaWidth = 0; - this._flags = 0 /* None */; - this.typeCheckPhase = -1; - this.astID = TypeScript.astID++; - this.passCreated = TypeScript.CompilerDiagnostics.analysisPass; - this.preComments = null; - this.postComments = null; - this.docComments = null; - } - AST.prototype.shouldEmit = function () { - return true; - }; - - AST.prototype.isExpression = function () { - return false; - }; - AST.prototype.isStatementOrExpression = function () { - return false; - }; - - AST.prototype.getFlags = function () { - return this._flags; - }; - - AST.prototype.setFlags = function (flags) { - this._flags = flags; - }; - - AST.prototype.getLength = function () { - return this.limChar - this.minChar; - }; - - AST.prototype.getID = function () { - return this.astID; - }; - - AST.prototype.isDeclaration = function () { - return false; - }; - - AST.prototype.isStatement = function () { - return false; - }; - - AST.prototype.emit = function (emitter) { - emitter.emitComments(this, true); - emitter.recordSourceMappingStart(this); - this.emitWorker(emitter); - emitter.recordSourceMappingEnd(this); - emitter.emitComments(this, false); - }; - - AST.prototype.emitWorker = function (emitter) { - throw new Error("please implement in derived class"); - }; - - AST.prototype.getDocComments = function () { - if (!this.isDeclaration() || !this.preComments || this.preComments.length === 0) { - return []; - } - - if (!this.docComments) { - var preCommentsLength = this.preComments.length; - var docComments = []; - for (var i = preCommentsLength - 1; i >= 0; i--) { - if (this.preComments[i].isDocComment()) { - var prevDocComment = docComments.length > 0 ? docComments[docComments.length - 1] : null; - if (prevDocComment === null || (this.preComments[i].limLine === prevDocComment.minLine || this.preComments[i].limLine + 1 === prevDocComment.minLine)) { - docComments.push(this.preComments[i]); - continue; - } - } - break; - } - - this.docComments = docComments.reverse(); - } - - return this.docComments; - }; - - AST.prototype.structuralEquals = function (ast, includingPosition) { - if (includingPosition) { - if (this.minChar !== ast.minChar || this.limChar !== ast.limChar) { - return false; - } - } - - return this._flags === ast._flags && astArrayStructuralEquals(this.preComments, ast.preComments, includingPosition) && astArrayStructuralEquals(this.postComments, ast.postComments, includingPosition); - }; - return AST; - })(); - TypeScript.AST = AST; - - var ASTList = (function (_super) { - __extends(ASTList, _super); - function ASTList() { - _super.call(this, 1 /* List */); - this.members = []; - } - ASTList.prototype.append = function (ast) { - this.members[this.members.length] = ast; - return this; - }; - - ASTList.prototype.emit = function (emitter) { - emitter.recordSourceMappingStart(this); - emitter.emitModuleElements(this); - emitter.recordSourceMappingEnd(this); - }; - - ASTList.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && astArrayStructuralEquals(this.members, ast.members, includingPosition); - }; - return ASTList; - })(AST); - TypeScript.ASTList = ASTList; - - var Expression = (function (_super) { - __extends(Expression, _super); - function Expression(nodeType) { - _super.call(this, nodeType); - } - return Expression; - })(AST); - TypeScript.Expression = Expression; - - var Identifier = (function (_super) { - __extends(Identifier, _super); - function Identifier(actualText) { - _super.call(this, 20 /* Name */); - this.actualText = actualText; - this.setText(actualText); - } - Identifier.prototype.setText = function (actualText) { - this.actualText = actualText; - this.text = actualText; - }; - - Identifier.prototype.isMissing = function () { - return false; - }; - - Identifier.prototype.emit = function (emitter) { - emitter.emitName(this, true); - }; - - Identifier.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && this.text === ast.text && this.actualText === ast.actualText && this.isMissing() === ast.isMissing(); - }; - return Identifier; - })(Expression); - TypeScript.Identifier = Identifier; - - var MissingIdentifier = (function (_super) { - __extends(MissingIdentifier, _super); - function MissingIdentifier() { - _super.call(this, "__missing"); - } - MissingIdentifier.prototype.isMissing = function () { - return true; - }; - - MissingIdentifier.prototype.emit = function (emitter) { - }; - return MissingIdentifier; - })(Identifier); - TypeScript.MissingIdentifier = MissingIdentifier; - - var LiteralExpression = (function (_super) { - __extends(LiteralExpression, _super); - function LiteralExpression(nodeType) { - _super.call(this, nodeType); - } - LiteralExpression.prototype.emitWorker = function (emitter) { - switch (this.nodeType) { - case 8 /* NullLiteral */: - emitter.writeToOutput("null"); - break; - case 4 /* FalseLiteral */: - emitter.writeToOutput("false"); - break; - case 3 /* TrueLiteral */: - emitter.writeToOutput("true"); - break; - default: - throw new Error("please implement in derived class"); - } - }; - - LiteralExpression.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition); - }; - return LiteralExpression; - })(Expression); - TypeScript.LiteralExpression = LiteralExpression; - - var ThisExpression = (function (_super) { - __extends(ThisExpression, _super); - function ThisExpression() { - _super.call(this, 29 /* ThisExpression */); - } - ThisExpression.prototype.emitWorker = function (emitter) { - if (emitter.thisFunctionDeclaration && (TypeScript.hasFlag(emitter.thisFunctionDeclaration.getFunctionFlags(), 2048 /* IsFatArrowFunction */))) { - emitter.writeToOutput("_this"); - } else { - emitter.writeToOutput("this"); - } - }; - - ThisExpression.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition); - }; - return ThisExpression; - })(Expression); - TypeScript.ThisExpression = ThisExpression; - - var SuperExpression = (function (_super) { - __extends(SuperExpression, _super); - function SuperExpression() { - _super.call(this, 30 /* SuperExpression */); - } - SuperExpression.prototype.emitWorker = function (emitter) { - emitter.emitSuperReference(); - }; - - SuperExpression.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition); - }; - return SuperExpression; - })(Expression); - TypeScript.SuperExpression = SuperExpression; - - var ParenthesizedExpression = (function (_super) { - __extends(ParenthesizedExpression, _super); - function ParenthesizedExpression(expression) { - _super.call(this, 79 /* ParenthesizedExpression */); - this.expression = expression; - } - ParenthesizedExpression.prototype.emitWorker = function (emitter) { - emitter.writeToOutput("("); - this.expression.emit(emitter); - emitter.writeToOutput(")"); - }; - - ParenthesizedExpression.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.expression, ast.expression, includingPosition); - }; - return ParenthesizedExpression; - })(Expression); - TypeScript.ParenthesizedExpression = ParenthesizedExpression; - - var UnaryExpression = (function (_super) { - __extends(UnaryExpression, _super); - function UnaryExpression(nodeType, operand) { - _super.call(this, nodeType); - this.operand = operand; - this.castTerm = null; - } - UnaryExpression.prototype.emitWorker = function (emitter) { - switch (this.nodeType) { - case 76 /* PostIncrementExpression */: - this.operand.emit(emitter); - emitter.writeToOutput("++"); - break; - case 73 /* LogicalNotExpression */: - emitter.writeToOutput("!"); - this.operand.emit(emitter); - break; - case 77 /* PostDecrementExpression */: - this.operand.emit(emitter); - emitter.writeToOutput("--"); - break; - case 22 /* ObjectLiteralExpression */: - emitter.emitObjectLiteral(this); - break; - case 21 /* ArrayLiteralExpression */: - emitter.emitArrayLiteral(this); - break; - case 72 /* BitwiseNotExpression */: - emitter.writeToOutput("~"); - this.operand.emit(emitter); - break; - case 27 /* NegateExpression */: - emitter.writeToOutput("-"); - if (this.operand.nodeType === 27 /* NegateExpression */ || this.operand.nodeType === 75 /* PreDecrementExpression */) { - emitter.writeToOutput(" "); - } - this.operand.emit(emitter); - break; - case 26 /* PlusExpression */: - emitter.writeToOutput("+"); - if (this.operand.nodeType === 26 /* PlusExpression */ || this.operand.nodeType === 74 /* PreIncrementExpression */) { - emitter.writeToOutput(" "); - } - this.operand.emit(emitter); - break; - case 74 /* PreIncrementExpression */: - emitter.writeToOutput("++"); - this.operand.emit(emitter); - break; - case 75 /* PreDecrementExpression */: - emitter.writeToOutput("--"); - this.operand.emit(emitter); - break; - case 34 /* TypeOfExpression */: - emitter.writeToOutput("typeof "); - this.operand.emit(emitter); - break; - case 28 /* DeleteExpression */: - emitter.writeToOutput("delete "); - this.operand.emit(emitter); - break; - case 24 /* VoidExpression */: - emitter.writeToOutput("void "); - this.operand.emit(emitter); - break; - case 78 /* CastExpression */: - this.operand.emit(emitter); - break; - default: - throw new Error("please implement in derived class"); - } - }; - - UnaryExpression.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.castTerm, ast.castTerm, includingPosition) && structuralEquals(this.operand, ast.operand, includingPosition); - }; - return UnaryExpression; - })(Expression); - TypeScript.UnaryExpression = UnaryExpression; - - var CallExpression = (function (_super) { - __extends(CallExpression, _super); - function CallExpression(nodeType, target, typeArguments, arguments) { - _super.call(this, nodeType); - this.target = target; - this.typeArguments = typeArguments; - this.arguments = arguments; - } - CallExpression.prototype.emitWorker = function (emitter) { - if (this.nodeType === 37 /* ObjectCreationExpression */) { - emitter.emitNew(this.target, this.arguments); - } else { - emitter.emitCall(this, this.target, this.arguments); - } - }; - - CallExpression.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.target, ast.target, includingPosition) && structuralEquals(this.typeArguments, ast.typeArguments, includingPosition) && structuralEquals(this.arguments, ast.arguments, includingPosition); - }; - return CallExpression; - })(Expression); - TypeScript.CallExpression = CallExpression; - - var BinaryExpression = (function (_super) { - __extends(BinaryExpression, _super); - function BinaryExpression(nodeType, operand1, operand2) { - _super.call(this, nodeType); - this.operand1 = operand1; - this.operand2 = operand2; - } - BinaryExpression.getTextForBinaryToken = function (nodeType) { - switch (nodeType) { - case 25 /* CommaExpression */: - return ","; - case 38 /* AssignmentExpression */: - return "="; - case 39 /* AddAssignmentExpression */: - return "+="; - case 40 /* SubtractAssignmentExpression */: - return "-="; - case 42 /* MultiplyAssignmentExpression */: - return "*="; - case 41 /* DivideAssignmentExpression */: - return "/="; - case 43 /* ModuloAssignmentExpression */: - return "%="; - case 44 /* AndAssignmentExpression */: - return "&="; - case 45 /* ExclusiveOrAssignmentExpression */: - return "^="; - case 46 /* OrAssignmentExpression */: - return "|="; - case 47 /* LeftShiftAssignmentExpression */: - return "<<="; - case 48 /* SignedRightShiftAssignmentExpression */: - return ">>="; - case 49 /* UnsignedRightShiftAssignmentExpression */: - return ">>>="; - case 51 /* LogicalOrExpression */: - return "||"; - case 52 /* LogicalAndExpression */: - return "&&"; - case 53 /* BitwiseOrExpression */: - return "|"; - case 54 /* BitwiseExclusiveOrExpression */: - return "^"; - case 55 /* BitwiseAndExpression */: - return "&"; - case 56 /* EqualsWithTypeConversionExpression */: - return "=="; - case 57 /* NotEqualsWithTypeConversionExpression */: - return "!="; - case 58 /* EqualsExpression */: - return "==="; - case 59 /* NotEqualsExpression */: - return "!=="; - case 60 /* LessThanExpression */: - return "<"; - case 62 /* GreaterThanExpression */: - return ">"; - case 61 /* LessThanOrEqualExpression */: - return "<="; - case 63 /* GreaterThanOrEqualExpression */: - return ">="; - case 33 /* InstanceOfExpression */: - return "instanceof"; - case 31 /* InExpression */: - return "in"; - case 69 /* LeftShiftExpression */: - return "<<"; - case 70 /* SignedRightShiftExpression */: - return ">>"; - case 71 /* UnsignedRightShiftExpression */: - return ">>>"; - case 66 /* MultiplyExpression */: - return "*"; - case 67 /* DivideExpression */: - return "/"; - case 68 /* ModuloExpression */: - return "%"; - case 64 /* AddExpression */: - return "+"; - case 65 /* SubtractExpression */: - return "-"; - } - - throw TypeScript.Errors.invalidOperation(); - }; - - BinaryExpression.prototype.emitWorker = function (emitter) { - switch (this.nodeType) { - case 32 /* MemberAccessExpression */: - if (!emitter.tryEmitConstant(this)) { - this.operand1.emit(emitter); - emitter.writeToOutput("."); - emitter.emitName(this.operand2, false); - } - break; - case 35 /* ElementAccessExpression */: - emitter.emitIndex(this.operand1, this.operand2); - break; - - case 80 /* Member */: - if (this.operand2.nodeType === 12 /* FunctionDeclaration */ && (this.operand2).isAccessor()) { - var funcDecl = this.operand2; - if (TypeScript.hasFlag(funcDecl.getFunctionFlags(), 32 /* GetAccessor */)) { - emitter.writeToOutput("get "); - } else { - emitter.writeToOutput("set "); - } - this.operand1.emit(emitter); - } else { - this.operand1.emit(emitter); - emitter.writeToOutputTrimmable(": "); - } - this.operand2.emit(emitter); - break; - case 25 /* CommaExpression */: - this.operand1.emit(emitter); - emitter.writeToOutput(", "); - this.operand2.emit(emitter); - break; - default: { - this.operand1.emit(emitter); - var binOp = BinaryExpression.getTextForBinaryToken(this.nodeType); - if (binOp === "instanceof") { - emitter.writeToOutput(" instanceof "); - } else if (binOp === "in") { - emitter.writeToOutput(" in "); - } else { - emitter.writeToOutputTrimmable(" " + binOp + " "); - } - this.operand2.emit(emitter); - } - } - }; - - BinaryExpression.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.operand1, ast.operand1, includingPosition) && structuralEquals(this.operand2, ast.operand2, includingPosition); - }; - return BinaryExpression; - })(Expression); - TypeScript.BinaryExpression = BinaryExpression; - - var ConditionalExpression = (function (_super) { - __extends(ConditionalExpression, _super); - function ConditionalExpression(operand1, operand2, operand3) { - _super.call(this, 50 /* ConditionalExpression */); - this.operand1 = operand1; - this.operand2 = operand2; - this.operand3 = operand3; - } - ConditionalExpression.prototype.emitWorker = function (emitter) { - this.operand1.emit(emitter); - emitter.writeToOutput(" ? "); - this.operand2.emit(emitter); - emitter.writeToOutput(" : "); - this.operand3.emit(emitter); - }; - - ConditionalExpression.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.operand1, ast.operand1, includingPosition) && structuralEquals(this.operand2, ast.operand2, includingPosition) && structuralEquals(this.operand3, ast.operand3, includingPosition); - }; - return ConditionalExpression; - })(Expression); - TypeScript.ConditionalExpression = ConditionalExpression; - - var NumberLiteral = (function (_super) { - __extends(NumberLiteral, _super); - function NumberLiteral(value, text) { - _super.call(this, 7 /* NumericLiteral */); - this.value = value; - this.text = text; - } - NumberLiteral.prototype.emitWorker = function (emitter) { - emitter.writeToOutput(this.text); - }; - - NumberLiteral.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && this.value === ast.value && this.text === ast.text; - }; - return NumberLiteral; - })(Expression); - TypeScript.NumberLiteral = NumberLiteral; - - var RegexLiteral = (function (_super) { - __extends(RegexLiteral, _super); - function RegexLiteral(text) { - _super.call(this, 6 /* RegularExpressionLiteral */); - this.text = text; - } - RegexLiteral.prototype.emitWorker = function (emitter) { - emitter.writeToOutput(this.text); - }; - - RegexLiteral.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && this.text === ast.text; - }; - return RegexLiteral; - })(Expression); - TypeScript.RegexLiteral = RegexLiteral; - - var StringLiteral = (function (_super) { - __extends(StringLiteral, _super); - function StringLiteral(actualText, text) { - _super.call(this, 5 /* StringLiteral */); - this.actualText = actualText; - this.text = text; - } - StringLiteral.prototype.emitWorker = function (emitter) { - emitter.writeToOutput(this.actualText); - }; - - StringLiteral.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && this.actualText === ast.actualText; - }; - return StringLiteral; - })(Expression); - TypeScript.StringLiteral = StringLiteral; - - var ImportDeclaration = (function (_super) { - __extends(ImportDeclaration, _super); - function ImportDeclaration(id, alias) { - _super.call(this, 16 /* ImportDeclaration */); - this.id = id; - this.alias = alias; - this.isDynamicImport = false; - } - ImportDeclaration.prototype.isStatementOrExpression = function () { - return true; - }; - - ImportDeclaration.prototype.isDeclaration = function () { - return true; - }; - - ImportDeclaration.prototype.emit = function (emitter) { - if (emitter.importStatementShouldBeEmitted(this)) { - var prevModAliasId = emitter.modAliasId; - var prevFirstModAlias = emitter.firstModAlias; - - emitter.recordSourceMappingStart(this); - emitter.emitComments(this, true); - emitter.writeToOutput("var " + this.id.actualText + " = "); - emitter.modAliasId = this.id.actualText; - emitter.firstModAlias = this.firstAliasedModToString(); - var aliasAST = this.alias.nodeType === 11 /* TypeRef */ ? (this.alias).term : this.alias; - - emitter.emitJavascript(aliasAST, false); - emitter.writeToOutput(";"); - - emitter.emitComments(this, false); - emitter.recordSourceMappingEnd(this); - - emitter.modAliasId = prevModAliasId; - emitter.firstModAlias = prevFirstModAlias; - } - }; - - ImportDeclaration.prototype.getAliasName = function (aliasAST) { - if (typeof aliasAST === "undefined") { aliasAST = this.alias; } - if (aliasAST.nodeType === 20 /* Name */) { - return (aliasAST).actualText; - } else { - var dotExpr = aliasAST; - return this.getAliasName(dotExpr.operand1) + "." + this.getAliasName(dotExpr.operand2); - } - }; - - ImportDeclaration.prototype.firstAliasedModToString = function () { - if (this.alias.nodeType === 20 /* Name */) { - return (this.alias).actualText; - } else { - var dotExpr = this.alias; - var firstMod = (dotExpr.term).operand1; - return firstMod.actualText; - } - }; - - ImportDeclaration.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.id, ast.id, includingPosition) && structuralEquals(this.alias, ast.alias, includingPosition); - }; - return ImportDeclaration; - })(AST); - TypeScript.ImportDeclaration = ImportDeclaration; - - var ExportAssignment = (function (_super) { - __extends(ExportAssignment, _super); - function ExportAssignment(id) { - _super.call(this, 87 /* ExportAssignment */); - this.id = id; - } - ExportAssignment.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.id, ast.id, includingPosition); - }; - - ExportAssignment.prototype.emit = function (emitter) { - emitter.setExportAssignmentIdentifier(this.id.actualText); - }; - return ExportAssignment; - })(AST); - TypeScript.ExportAssignment = ExportAssignment; - - var BoundDecl = (function (_super) { - __extends(BoundDecl, _super); - function BoundDecl(id, nodeType) { - _super.call(this, nodeType); - this.id = id; - this.init = null; - this.isImplicitlyInitialized = false; - this.typeExpr = null; - this._varFlags = 0 /* None */; - } - BoundDecl.prototype.isDeclaration = function () { - return true; - }; - BoundDecl.prototype.isStatementOrExpression = function () { - return true; - }; - - BoundDecl.prototype.getVarFlags = function () { - return this._varFlags; - }; - - BoundDecl.prototype.setVarFlags = function (flags) { - this._varFlags = flags; - }; - - BoundDecl.prototype.isProperty = function () { - return TypeScript.hasFlag(this.getVarFlags(), 256 /* Property */); - }; - - BoundDecl.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && this._varFlags === ast._varFlags && structuralEquals(this.init, ast.init, includingPosition) && structuralEquals(this.typeExpr, ast.typeExpr, includingPosition) && structuralEquals(this.id, ast.id, includingPosition); - }; - return BoundDecl; - })(AST); - TypeScript.BoundDecl = BoundDecl; - - var VariableDeclarator = (function (_super) { - __extends(VariableDeclarator, _super); - function VariableDeclarator(id) { - _super.call(this, id, 17 /* VariableDeclarator */); - } - VariableDeclarator.prototype.isExported = function () { - return TypeScript.hasFlag(this.getVarFlags(), 1 /* Exported */); - }; - - VariableDeclarator.prototype.isStatic = function () { - return TypeScript.hasFlag(this.getVarFlags(), 16 /* Static */); - }; - - VariableDeclarator.prototype.emit = function (emitter) { - emitter.emitVariableDeclarator(this); - }; - return VariableDeclarator; - })(BoundDecl); - TypeScript.VariableDeclarator = VariableDeclarator; - - var Parameter = (function (_super) { - __extends(Parameter, _super); - function Parameter(id) { - _super.call(this, id, 19 /* Parameter */); - this.isOptional = false; - } - Parameter.prototype.isOptionalArg = function () { - return this.isOptional || this.init; - }; - - Parameter.prototype.emitWorker = function (emitter) { - emitter.writeToOutput(this.id.actualText); - }; - - Parameter.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && this.isOptional === ast.isOptional; - }; - return Parameter; - })(BoundDecl); - TypeScript.Parameter = Parameter; - - var FunctionDeclaration = (function (_super) { - __extends(FunctionDeclaration, _super); - function FunctionDeclaration(name, block, isConstructor, typeArguments, arguments, nodeType) { - _super.call(this, nodeType); - this.name = name; - this.block = block; - this.isConstructor = isConstructor; - this.typeArguments = typeArguments; - this.arguments = arguments; - this.hint = null; - this._functionFlags = 0 /* None */; - this.returnTypeAnnotation = null; - this.variableArgList = false; - this.classDecl = null; - } - FunctionDeclaration.prototype.isDeclaration = function () { - return true; - }; - - FunctionDeclaration.prototype.getFunctionFlags = function () { - return this._functionFlags; - }; - - FunctionDeclaration.prototype.setFunctionFlags = function (flags) { - this._functionFlags = flags; - }; - - FunctionDeclaration.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && this._functionFlags === ast._functionFlags && this.hint === ast.hint && this.variableArgList === ast.variableArgList && structuralEquals(this.name, ast.name, includingPosition) && structuralEquals(this.block, ast.block, includingPosition) && this.isConstructor === ast.isConstructor && structuralEquals(this.typeArguments, ast.typeArguments, includingPosition) && structuralEquals(this.arguments, ast.arguments, includingPosition); - }; - - FunctionDeclaration.prototype.shouldEmit = function () { - return !TypeScript.hasFlag(this.getFunctionFlags(), 128 /* Signature */) && !TypeScript.hasFlag(this.getFunctionFlags(), 8 /* Ambient */); - }; - - FunctionDeclaration.prototype.emit = function (emitter) { - emitter.emitFunction(this); - }; - - FunctionDeclaration.prototype.getNameText = function () { - if (this.name) { - return this.name.actualText; - } else { - return this.hint; - } - }; - - FunctionDeclaration.prototype.isMethod = function () { - return (this.getFunctionFlags() & 256 /* Method */) !== 0 /* None */; - }; - - FunctionDeclaration.prototype.isCallMember = function () { - return TypeScript.hasFlag(this.getFunctionFlags(), 512 /* CallMember */); - }; - FunctionDeclaration.prototype.isConstructMember = function () { - return TypeScript.hasFlag(this.getFunctionFlags(), 1024 /* ConstructMember */); - }; - FunctionDeclaration.prototype.isIndexerMember = function () { - return TypeScript.hasFlag(this.getFunctionFlags(), 4096 /* IndexerMember */); - }; - FunctionDeclaration.prototype.isSpecialFn = function () { - return this.isCallMember() || this.isIndexerMember() || this.isConstructMember(); - }; - FunctionDeclaration.prototype.isAccessor = function () { - return TypeScript.hasFlag(this.getFunctionFlags(), 32 /* GetAccessor */) || TypeScript.hasFlag(this.getFunctionFlags(), 64 /* SetAccessor */); - }; - FunctionDeclaration.prototype.isGetAccessor = function () { - return TypeScript.hasFlag(this.getFunctionFlags(), 32 /* GetAccessor */); - }; - FunctionDeclaration.prototype.isSetAccessor = function () { - return TypeScript.hasFlag(this.getFunctionFlags(), 64 /* SetAccessor */); - }; - FunctionDeclaration.prototype.isStatic = function () { - return TypeScript.hasFlag(this.getFunctionFlags(), 16 /* Static */); - }; - - FunctionDeclaration.prototype.isSignature = function () { - return (this.getFunctionFlags() & 128 /* Signature */) !== 0 /* None */; - }; - return FunctionDeclaration; - })(AST); - TypeScript.FunctionDeclaration = FunctionDeclaration; - - var Script = (function (_super) { - __extends(Script, _super); - function Script() { - _super.call(this, 2 /* Script */); - this.moduleElements = null; - this.referencedFiles = []; - this.requiresExtendsBlock = false; - this.isDeclareFile = false; - this.topLevelMod = null; - this.containsUnicodeChar = false; - this.containsUnicodeCharInComment = false; - } - Script.prototype.emit = function (emitter) { - if (!this.isDeclareFile) { - emitter.emitScriptElements(this, this.requiresExtendsBlock); - } - }; - - Script.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.moduleElements, ast.moduleElements, includingPosition); - }; - return Script; - })(AST); - TypeScript.Script = Script; - - var NamedDeclaration = (function (_super) { - __extends(NamedDeclaration, _super); - function NamedDeclaration(nodeType, name, members) { - _super.call(this, nodeType); - this.name = name; - this.members = members; - } - NamedDeclaration.prototype.isDeclaration = function () { - return true; - }; - - NamedDeclaration.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.name, ast.name, includingPosition) && structuralEquals(this.members, ast.members, includingPosition); - }; - return NamedDeclaration; - })(AST); - TypeScript.NamedDeclaration = NamedDeclaration; - - var ModuleDeclaration = (function (_super) { - __extends(ModuleDeclaration, _super); - function ModuleDeclaration(name, members, endingToken) { - _super.call(this, 15 /* ModuleDeclaration */, name, members); - this.endingToken = endingToken; - this._moduleFlags = 0 /* None */; - this.amdDependencies = []; - this.containsUnicodeChar = false; - this.containsUnicodeCharInComment = false; - - this.prettyName = this.name.actualText; - } - ModuleDeclaration.prototype.getModuleFlags = function () { - return this._moduleFlags; - }; - - ModuleDeclaration.prototype.setModuleFlags = function (flags) { - this._moduleFlags = flags; - }; - - ModuleDeclaration.prototype.structuralEquals = function (ast, includePosition) { - if (_super.prototype.structuralEquals.call(this, ast, includePosition)) { - return this._moduleFlags === ast._moduleFlags; - } - - return false; - }; - - ModuleDeclaration.prototype.isEnum = function () { - return TypeScript.hasFlag(this.getModuleFlags(), 128 /* IsEnum */); - }; - ModuleDeclaration.prototype.isWholeFile = function () { - return TypeScript.hasFlag(this.getModuleFlags(), 256 /* IsWholeFile */); - }; - - ModuleDeclaration.prototype.shouldEmit = function () { - if (TypeScript.hasFlag(this.getModuleFlags(), 8 /* Ambient */)) { - return false; - } - - if (TypeScript.hasFlag(this.getModuleFlags(), 128 /* IsEnum */)) { - return true; - } - - for (var i = 0, n = this.members.members.length; i < n; i++) { - var member = this.members.members[i]; - - if (member.nodeType === 15 /* ModuleDeclaration */) { - if ((member).shouldEmit()) { - return true; - } - } else if (member.nodeType !== 14 /* InterfaceDeclaration */) { - return true; - } - } - - return false; - }; - - ModuleDeclaration.prototype.emit = function (emitter) { - if (this.shouldEmit()) { - emitter.emitComments(this, true); - emitter.emitModule(this); - emitter.emitComments(this, false); - } - }; - return ModuleDeclaration; - })(NamedDeclaration); - TypeScript.ModuleDeclaration = ModuleDeclaration; - - var TypeDeclaration = (function (_super) { - __extends(TypeDeclaration, _super); - function TypeDeclaration(nodeType, name, typeParameters, extendsList, implementsList, members) { - _super.call(this, nodeType, name, members); - this.typeParameters = typeParameters; - this.extendsList = extendsList; - this.implementsList = implementsList; - this._varFlags = 0 /* None */; - } - TypeDeclaration.prototype.getVarFlags = function () { - return this._varFlags; - }; - - TypeDeclaration.prototype.setVarFlags = function (flags) { - this._varFlags = flags; - }; - - TypeDeclaration.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && this._varFlags === ast._varFlags && structuralEquals(this.typeParameters, ast.typeParameters, includingPosition) && structuralEquals(this.extendsList, ast.extendsList, includingPosition) && structuralEquals(this.implementsList, ast.implementsList, includingPosition); - }; - return TypeDeclaration; - })(NamedDeclaration); - TypeScript.TypeDeclaration = TypeDeclaration; - - var ClassDeclaration = (function (_super) { - __extends(ClassDeclaration, _super); - function ClassDeclaration(name, typeParameters, members, extendsList, implementsList) { - _super.call(this, 13 /* ClassDeclaration */, name, typeParameters, extendsList, implementsList, members); - this.constructorDecl = null; - this.endingToken = null; - } - ClassDeclaration.prototype.shouldEmit = function () { - return !TypeScript.hasFlag(this.getVarFlags(), 8 /* Ambient */); - }; - - ClassDeclaration.prototype.emit = function (emitter) { - emitter.emitClass(this); - }; - return ClassDeclaration; - })(TypeDeclaration); - TypeScript.ClassDeclaration = ClassDeclaration; - - var InterfaceDeclaration = (function (_super) { - __extends(InterfaceDeclaration, _super); - function InterfaceDeclaration(name, typeParameters, members, extendsList, implementsList) { - _super.call(this, 14 /* InterfaceDeclaration */, name, typeParameters, extendsList, implementsList, members); - } - InterfaceDeclaration.prototype.shouldEmit = function () { - return false; - }; - return InterfaceDeclaration; - })(TypeDeclaration); - TypeScript.InterfaceDeclaration = InterfaceDeclaration; - - var Statement = (function (_super) { - __extends(Statement, _super); - function Statement(nodeType) { - _super.call(this, nodeType); - } - Statement.prototype.isStatement = function () { - return true; - }; - - Statement.prototype.isStatementOrExpression = function () { - return true; - }; - return Statement; - })(AST); - TypeScript.Statement = Statement; - - var ThrowStatement = (function (_super) { - __extends(ThrowStatement, _super); - function ThrowStatement(expression) { - _super.call(this, 95 /* ThrowStatement */); - this.expression = expression; - } - ThrowStatement.prototype.emitWorker = function (emitter) { - emitter.writeToOutput("throw "); - this.expression.emit(emitter); - emitter.writeToOutput(";"); - }; - - ThrowStatement.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.expression, ast.expression, includingPosition); - }; - return ThrowStatement; - })(Statement); - TypeScript.ThrowStatement = ThrowStatement; - - var ExpressionStatement = (function (_super) { - __extends(ExpressionStatement, _super); - function ExpressionStatement(expression) { - _super.call(this, 88 /* ExpressionStatement */); - this.expression = expression; - } - ExpressionStatement.prototype.emitWorker = function (emitter) { - this.expression.emit(emitter); - emitter.writeToOutput(";"); - }; - - ExpressionStatement.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.expression, ast.expression, includingPosition); - }; - return ExpressionStatement; - })(Statement); - TypeScript.ExpressionStatement = ExpressionStatement; - - var LabeledStatement = (function (_super) { - __extends(LabeledStatement, _super); - function LabeledStatement(identifier, statement) { - _super.call(this, 92 /* LabeledStatement */); - this.identifier = identifier; - this.statement = statement; - } - LabeledStatement.prototype.emitWorker = function (emitter) { - emitter.recordSourceMappingStart(this.identifier); - emitter.writeToOutput(this.identifier.actualText); - emitter.recordSourceMappingEnd(this.identifier); - emitter.writeLineToOutput(":"); - emitter.emitJavascript(this.statement, true); - }; - - LabeledStatement.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.identifier, ast.identifier, includingPosition) && structuralEquals(this.statement, ast.statement, includingPosition); - }; - return LabeledStatement; - })(Statement); - TypeScript.LabeledStatement = LabeledStatement; - - var VariableDeclaration = (function (_super) { - __extends(VariableDeclaration, _super); - function VariableDeclaration(declarators) { - _super.call(this, 18 /* VariableDeclaration */); - this.declarators = declarators; - } - VariableDeclaration.prototype.emit = function (emitter) { - emitter.emitVariableDeclaration(this); - }; - - VariableDeclaration.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.declarators, ast.declarators, includingPosition); - }; - return VariableDeclaration; - })(AST); - TypeScript.VariableDeclaration = VariableDeclaration; - - var VariableStatement = (function (_super) { - __extends(VariableStatement, _super); - function VariableStatement(declaration) { - _super.call(this, 97 /* VariableStatement */); - this.declaration = declaration; - } - VariableStatement.prototype.shouldEmit = function () { - if (TypeScript.hasFlag(this.getFlags(), 32 /* EnumMapElement */)) { - return false; - } - - var varDecl = this.declaration.declarators.members[0]; - return !TypeScript.hasFlag(varDecl.getVarFlags(), 8 /* Ambient */) || varDecl.init !== null; - }; - - VariableStatement.prototype.emitWorker = function (emitter) { - if (TypeScript.hasFlag(this.getFlags(), 16 /* EnumElement */)) { - emitter.emitEnumElement(this.declaration.declarators.members[0]); - } else { - this.declaration.emit(emitter); - emitter.writeToOutput(";"); - } - }; - - VariableStatement.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.declaration, ast.declaration, includingPosition); - }; - return VariableStatement; - })(Statement); - TypeScript.VariableStatement = VariableStatement; - - var Block = (function (_super) { - __extends(Block, _super); - function Block(statements) { - _super.call(this, 81 /* Block */); - this.statements = statements; - this.closeBraceSpan = null; - } - Block.prototype.emitWorker = function (emitter) { - emitter.writeLineToOutput(" {"); - emitter.indenter.increaseIndent(); - if (this.statements) { - emitter.emitModuleElements(this.statements); - } - emitter.indenter.decreaseIndent(); - emitter.emitIndent(); - emitter.writeToOutput("}"); - }; - - Block.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.statements, ast.statements, includingPosition); - }; - return Block; - })(Statement); - TypeScript.Block = Block; - - var Jump = (function (_super) { - __extends(Jump, _super); - function Jump(nodeType) { - _super.call(this, nodeType); - this.target = null; - this.resolvedTarget = null; - } - Jump.prototype.hasExplicitTarget = function () { - return (this.target); - }; - - Jump.prototype.emitWorker = function (emitter) { - if (this.nodeType === 82 /* BreakStatement */) { - emitter.writeToOutput("break"); - } else { - emitter.writeToOutput("continue"); - } - if (this.hasExplicitTarget()) { - emitter.writeToOutput(" " + this.target); - } - emitter.writeToOutput(";"); - }; - - Jump.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && this.target === ast.target; - }; - return Jump; - })(Statement); - TypeScript.Jump = Jump; - - var WhileStatement = (function (_super) { - __extends(WhileStatement, _super); - function WhileStatement(cond, body) { - _super.call(this, 98 /* WhileStatement */); - this.cond = cond; - this.body = body; - } - WhileStatement.prototype.emitWorker = function (emitter) { - emitter.writeToOutput("while ("); - this.cond.emit(emitter); - emitter.writeToOutput(")"); - emitter.emitBlockOrStatement(this.body); - }; - - WhileStatement.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.cond, ast.cond, includingPosition) && structuralEquals(this.body, ast.body, includingPosition); - }; - return WhileStatement; - })(Statement); - TypeScript.WhileStatement = WhileStatement; - - var DoStatement = (function (_super) { - __extends(DoStatement, _super); - function DoStatement(body, cond) { - _super.call(this, 85 /* DoStatement */); - this.body = body; - this.cond = cond; - this.whileSpan = null; - } - DoStatement.prototype.emitWorker = function (emitter) { - emitter.writeToOutput("do"); - emitter.emitBlockOrStatement(this.body); - emitter.recordSourceMappingStart(this.whileSpan); - emitter.writeToOutput(" while"); - emitter.recordSourceMappingEnd(this.whileSpan); - emitter.writeToOutput('('); - this.cond.emit(emitter); - emitter.writeToOutput(")"); - emitter.writeToOutput(";"); - }; - - DoStatement.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.body, ast.body, includingPosition) && structuralEquals(this.cond, ast.cond, includingPosition); - }; - return DoStatement; - })(Statement); - TypeScript.DoStatement = DoStatement; - - var IfStatement = (function (_super) { - __extends(IfStatement, _super); - function IfStatement(cond, thenBod, elseBod) { - _super.call(this, 91 /* IfStatement */); - this.cond = cond; - this.thenBod = thenBod; - this.elseBod = elseBod; - this.statement = new ASTSpan(); - } - IfStatement.prototype.emitWorker = function (emitter) { - emitter.recordSourceMappingStart(this.statement); - emitter.writeToOutput("if ("); - this.cond.emit(emitter); - emitter.writeToOutput(")"); - emitter.recordSourceMappingEnd(this.statement); - - emitter.emitBlockOrStatement(this.thenBod); - - if (this.elseBod) { - if (this.elseBod.nodeType === 91 /* IfStatement */) { - emitter.writeToOutput(" else "); - this.elseBod.emit(emitter); - } else { - emitter.writeToOutput(" else"); - emitter.emitBlockOrStatement(this.elseBod); - } - } - }; - - IfStatement.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.cond, ast.cond, includingPosition) && structuralEquals(this.thenBod, ast.thenBod, includingPosition) && structuralEquals(this.elseBod, ast.elseBod, includingPosition); - }; - return IfStatement; - })(Statement); - TypeScript.IfStatement = IfStatement; - - var ReturnStatement = (function (_super) { - __extends(ReturnStatement, _super); - function ReturnStatement(returnExpression) { - _super.call(this, 93 /* ReturnStatement */); - this.returnExpression = returnExpression; - } - ReturnStatement.prototype.emitWorker = function (emitter) { - if (this.returnExpression) { - emitter.writeToOutput("return "); - this.returnExpression.emit(emitter); - emitter.writeToOutput(";"); - } else { - emitter.writeToOutput("return;"); - } - }; - - ReturnStatement.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.returnExpression, ast.returnExpression, includingPosition); - }; - return ReturnStatement; - })(Statement); - TypeScript.ReturnStatement = ReturnStatement; - - var ForInStatement = (function (_super) { - __extends(ForInStatement, _super); - function ForInStatement(lval, obj, body) { - _super.call(this, 89 /* ForInStatement */); - this.lval = lval; - this.obj = obj; - this.body = body; - this.statement = new ASTSpan(); - } - ForInStatement.prototype.emitWorker = function (emitter) { - emitter.recordSourceMappingStart(this.statement); - emitter.writeToOutput("for ("); - this.lval.emit(emitter); - emitter.writeToOutput(" in "); - this.obj.emit(emitter); - emitter.writeToOutput(")"); - emitter.recordSourceMappingEnd(this.statement); - emitter.emitBlockOrStatement(this.body); - }; - - ForInStatement.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.lval, ast.lval, includingPosition) && structuralEquals(this.obj, ast.obj, includingPosition) && structuralEquals(this.body, ast.body, includingPosition); - }; - return ForInStatement; - })(Statement); - TypeScript.ForInStatement = ForInStatement; - - var ForStatement = (function (_super) { - __extends(ForStatement, _super); - function ForStatement(init, cond, incr, body) { - _super.call(this, 90 /* ForStatement */); - this.init = init; - this.cond = cond; - this.incr = incr; - this.body = body; - } - ForStatement.prototype.emitWorker = function (emitter) { - emitter.writeToOutput("for ("); - if (this.init) { - if (this.init.nodeType !== 1 /* List */) { - this.init.emit(emitter); - } else { - emitter.setInVarBlock((this.init).members.length); - emitter.emitCommaSeparatedList(this.init); - } - } - - emitter.writeToOutput("; "); - emitter.emitJavascript(this.cond, false); - emitter.writeToOutput("; "); - emitter.emitJavascript(this.incr, false); - emitter.writeToOutput(")"); - emitter.emitBlockOrStatement(this.body); - }; - - ForStatement.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.init, ast.init, includingPosition) && structuralEquals(this.cond, ast.cond, includingPosition) && structuralEquals(this.incr, ast.incr, includingPosition) && structuralEquals(this.body, ast.body, includingPosition); - }; - return ForStatement; - })(Statement); - TypeScript.ForStatement = ForStatement; - - var WithStatement = (function (_super) { - __extends(WithStatement, _super); - function WithStatement(expr, body) { - _super.call(this, 99 /* WithStatement */); - this.expr = expr; - this.body = body; - } - WithStatement.prototype.emitWorker = function (emitter) { - emitter.writeToOutput("with ("); - if (this.expr) { - this.expr.emit(emitter); - } - - emitter.writeToOutput(")"); - emitter.emitBlockOrStatement(this.body); - }; - - WithStatement.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.expr, ast.expr, includingPosition) && structuralEquals(this.body, ast.body, includingPosition); - }; - return WithStatement; - })(Statement); - TypeScript.WithStatement = WithStatement; - - var SwitchStatement = (function (_super) { - __extends(SwitchStatement, _super); - function SwitchStatement(val) { - _super.call(this, 94 /* SwitchStatement */); - this.val = val; - this.defaultCase = null; - this.statement = new ASTSpan(); - } - SwitchStatement.prototype.emitWorker = function (emitter) { - emitter.recordSourceMappingStart(this.statement); - emitter.writeToOutput("switch ("); - this.val.emit(emitter); - emitter.writeToOutput(")"); - emitter.recordSourceMappingEnd(this.statement); - emitter.writeLineToOutput(" {"); - emitter.indenter.increaseIndent(); - - var lastEmittedNode = null; - for (var i = 0, n = this.caseList.members.length; i < n; i++) { - var caseExpr = this.caseList.members[i]; - - emitter.emitSpaceBetweenConstructs(lastEmittedNode, caseExpr); - emitter.emitJavascript(caseExpr, true); - - lastEmittedNode = caseExpr; - } - emitter.indenter.decreaseIndent(); - emitter.emitIndent(); - emitter.writeToOutput("}"); - }; - - SwitchStatement.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.caseList, ast.caseList, includingPosition) && structuralEquals(this.val, ast.val, includingPosition); - }; - return SwitchStatement; - })(Statement); - TypeScript.SwitchStatement = SwitchStatement; - - var CaseClause = (function (_super) { - __extends(CaseClause, _super); - function CaseClause() { - _super.call(this, 100 /* CaseClause */); - this.expr = null; - this.colonSpan = new ASTSpan(); - } - CaseClause.prototype.emitWorker = function (emitter) { - if (this.expr) { - emitter.writeToOutput("case "); - this.expr.emit(emitter); - } else { - emitter.writeToOutput("default"); - } - emitter.recordSourceMappingStart(this.colonSpan); - emitter.writeToOutput(":"); - emitter.recordSourceMappingEnd(this.colonSpan); - - if (this.body.members.length === 1 && this.body.members[0].nodeType === 81 /* Block */) { - this.body.members[0].emit(emitter); - emitter.writeLineToOutput(""); - } else { - emitter.writeLineToOutput(""); - emitter.indenter.increaseIndent(); - this.body.emit(emitter); - emitter.indenter.decreaseIndent(); - } - }; - - CaseClause.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.expr, ast.expr, includingPosition) && structuralEquals(this.body, ast.body, includingPosition); - }; - return CaseClause; - })(AST); - TypeScript.CaseClause = CaseClause; - - var TypeParameter = (function (_super) { - __extends(TypeParameter, _super); - function TypeParameter(name, constraint) { - _super.call(this, 9 /* TypeParameter */); - this.name = name; - this.constraint = constraint; - } - TypeParameter.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.name, ast.name, includingPosition) && structuralEquals(this.constraint, ast.constraint, includingPosition); - }; - return TypeParameter; - })(AST); - TypeScript.TypeParameter = TypeParameter; - - var GenericType = (function (_super) { - __extends(GenericType, _super); - function GenericType(name, typeArguments) { - _super.call(this, 10 /* GenericType */); - this.name = name; - this.typeArguments = typeArguments; - } - GenericType.prototype.emit = function (emitter) { - this.name.emit(emitter); - }; - - GenericType.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.name, ast.name, includingPosition) && structuralEquals(this.typeArguments, ast.typeArguments, includingPosition); - }; - return GenericType; - })(AST); - TypeScript.GenericType = GenericType; - - var TypeReference = (function (_super) { - __extends(TypeReference, _super); - function TypeReference(term, arrayCount) { - _super.call(this, 11 /* TypeRef */); - this.term = term; - this.arrayCount = arrayCount; - } - TypeReference.prototype.emit = function (emitter) { - throw new Error("should not emit a type ref"); - }; - - TypeReference.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.term, ast.term, includingPosition) && this.arrayCount === ast.arrayCount; - }; - return TypeReference; - })(AST); - TypeScript.TypeReference = TypeReference; - - var TryStatement = (function (_super) { - __extends(TryStatement, _super); - function TryStatement(tryBody, catchClause, finallyBody) { - _super.call(this, 96 /* TryStatement */); - this.tryBody = tryBody; - this.catchClause = catchClause; - this.finallyBody = finallyBody; - } - TryStatement.prototype.emitWorker = function (emitter) { - emitter.writeToOutput("try "); - this.tryBody.emit(emitter); - emitter.emitJavascript(this.catchClause, false); - - if (this.finallyBody) { - emitter.writeToOutput(" finally"); - this.finallyBody.emit(emitter); - } - }; - - TryStatement.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.tryBody, ast.tryBody, includingPosition) && structuralEquals(this.catchClause, ast.catchClause, includingPosition) && structuralEquals(this.finallyBody, ast.finallyBody, includingPosition); - }; - return TryStatement; - })(Statement); - TypeScript.TryStatement = TryStatement; - - var CatchClause = (function (_super) { - __extends(CatchClause, _super); - function CatchClause(param, body) { - _super.call(this, 101 /* CatchClause */); - this.param = param; - this.body = body; - this.statement = new ASTSpan(); - } - CatchClause.prototype.emitWorker = function (emitter) { - emitter.writeToOutput(" "); - emitter.recordSourceMappingStart(this.statement); - emitter.writeToOutput("catch ("); - this.param.id.emit(emitter); - emitter.writeToOutput(")"); - emitter.recordSourceMappingEnd(this.statement); - this.body.emit(emitter); - }; - - CatchClause.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.param, ast.param, includingPosition) && structuralEquals(this.body, ast.body, includingPosition); - }; - return CatchClause; - })(AST); - TypeScript.CatchClause = CatchClause; - - var DebuggerStatement = (function (_super) { - __extends(DebuggerStatement, _super); - function DebuggerStatement() { - _super.call(this, 84 /* DebuggerStatement */); - } - DebuggerStatement.prototype.emitWorker = function (emitter) { - emitter.writeToOutput("debugger;"); - }; - return DebuggerStatement; - })(Statement); - TypeScript.DebuggerStatement = DebuggerStatement; - - var OmittedExpression = (function (_super) { - __extends(OmittedExpression, _super); - function OmittedExpression() { - _super.call(this, 23 /* OmittedExpression */); - } - OmittedExpression.prototype.emitWorker = function (emitter) { - }; - - OmittedExpression.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition); - }; - return OmittedExpression; - })(Expression); - TypeScript.OmittedExpression = OmittedExpression; - - var EmptyStatement = (function (_super) { - __extends(EmptyStatement, _super); - function EmptyStatement() { - _super.call(this, 86 /* EmptyStatement */); - } - EmptyStatement.prototype.emitWorker = function (emitter) { - emitter.writeToOutput(";"); - }; - - EmptyStatement.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition); - }; - return EmptyStatement; - })(Statement); - TypeScript.EmptyStatement = EmptyStatement; - - var Comment = (function (_super) { - __extends(Comment, _super); - function Comment(content, isBlockComment, endsLine) { - _super.call(this, 102 /* Comment */); - this.content = content; - this.isBlockComment = isBlockComment; - this.endsLine = endsLine; - this.text = null; - this.docCommentText = null; - } - Comment.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && this.minLine === ast.minLine && this.content === ast.content && this.isBlockComment === ast.isBlockComment && this.endsLine === ast.endsLine; - }; - - Comment.prototype.getText = function () { - if (this.text === null) { - if (this.isBlockComment) { - this.text = this.content.split("\n"); - for (var i = 0; i < this.text.length; i++) { - this.text[i] = this.text[i].replace(/^\s+|\s+$/g, ''); - } - } else { - this.text = [(this.content.replace(/^\s+|\s+$/g, ''))]; - } - } - - return this.text; - }; - - Comment.prototype.isDocComment = function () { - if (this.isBlockComment) { - return this.content.charAt(2) === "*" && this.content.charAt(3) !== "/"; - } - - return false; - }; - - Comment.prototype.getDocCommentTextValue = function () { - if (this.docCommentText === null) { - this.docCommentText = Comment.cleanJSDocComment(this.content); - } - - return this.docCommentText; - }; - - Comment.consumeLeadingSpace = function (line, startIndex, maxSpacesToRemove) { - var endIndex = line.length; - if (maxSpacesToRemove !== undefined) { - endIndex = TypeScript.min(startIndex + maxSpacesToRemove, endIndex); - } - - for (; startIndex < endIndex; startIndex++) { - var charCode = line.charCodeAt(startIndex); - if (charCode !== 32 /* space */ && charCode !== 9 /* tab */) { - return startIndex; - } - } - - if (endIndex !== line.length) { - return endIndex; - } - - return -1; - }; - - Comment.isSpaceChar = function (line, index) { - var length = line.length; - if (index < length) { - var charCode = line.charCodeAt(index); - - return charCode === 32 /* space */ || charCode === 9 /* tab */; - } - - return index === length; - }; - - Comment.cleanDocCommentLine = function (line, jsDocStyleComment, jsDocLineSpaceToRemove) { - var nonSpaceIndex = Comment.consumeLeadingSpace(line, 0); - if (nonSpaceIndex !== -1) { - var jsDocSpacesRemoved = nonSpaceIndex; - if (jsDocStyleComment && line.charAt(nonSpaceIndex) === '*') { - var startIndex = nonSpaceIndex + 1; - nonSpaceIndex = Comment.consumeLeadingSpace(line, startIndex, jsDocLineSpaceToRemove); - - if (nonSpaceIndex !== -1) { - jsDocSpacesRemoved = nonSpaceIndex - startIndex; - } else { - return null; - } - } - - return { - minChar: nonSpaceIndex, - limChar: line.charAt(line.length - 1) === "\r" ? line.length - 1 : line.length, - jsDocSpacesRemoved: jsDocSpacesRemoved - }; - } - - return null; - }; - - Comment.cleanJSDocComment = function (content, spacesToRemove) { - var docCommentLines = []; - content = content.replace("/**", ""); - if (content.length >= 2 && content.charAt(content.length - 1) === "/" && content.charAt(content.length - 2) === "*") { - content = content.substring(0, content.length - 2); - } - var lines = content.split("\n"); - var inParamTag = false; - for (var l = 0; l < lines.length; l++) { - var line = lines[l]; - var cleanLinePos = Comment.cleanDocCommentLine(line, true, spacesToRemove); - if (!cleanLinePos) { - continue; - } - - var docCommentText = ""; - var prevPos = cleanLinePos.minChar; - for (var i = line.indexOf("@", cleanLinePos.minChar); 0 <= i && i < cleanLinePos.limChar; i = line.indexOf("@", i + 1)) { - var wasInParamtag = inParamTag; - - if (line.indexOf("param", i + 1) === i + 1 && Comment.isSpaceChar(line, i + 6)) { - if (!wasInParamtag) { - docCommentText += line.substring(prevPos, i); - } - - prevPos = i; - inParamTag = true; - } else if (wasInParamtag) { - prevPos = i; - inParamTag = false; - } - } - - if (!inParamTag) { - docCommentText += line.substring(prevPos, cleanLinePos.limChar); - } - - var newCleanPos = Comment.cleanDocCommentLine(docCommentText, false); - if (newCleanPos) { - if (spacesToRemove === undefined) { - spacesToRemove = cleanLinePos.jsDocSpacesRemoved; - } - docCommentLines.push(docCommentText); - } - } - - return docCommentLines.join("\n"); - }; - - Comment.getDocCommentText = function (comments) { - var docCommentText = []; - for (var c = 0; c < comments.length; c++) { - var commentText = comments[c].getDocCommentTextValue(); - if (commentText !== "") { - docCommentText.push(commentText); - } - } - return docCommentText.join("\n"); - }; - - Comment.getParameterDocCommentText = function (param, fncDocComments) { - if (fncDocComments.length === 0 || !fncDocComments[0].isBlockComment) { - return ""; - } - - for (var i = 0; i < fncDocComments.length; i++) { - var commentContents = fncDocComments[i].content; - for (var j = commentContents.indexOf("@param", 0); 0 <= j; j = commentContents.indexOf("@param", j)) { - j += 6; - if (!Comment.isSpaceChar(commentContents, j)) { - continue; - } - - j = Comment.consumeLeadingSpace(commentContents, j); - if (j === -1) { - break; - } - - if (commentContents.charCodeAt(j) === 123 /* openBrace */) { - j++; - - var charCode = 0; - for (var curlies = 1; j < commentContents.length; j++) { - charCode = commentContents.charCodeAt(j); - - if (charCode === 123 /* openBrace */) { - curlies++; - continue; - } - - if (charCode === 125 /* closeBrace */) { - curlies--; - if (curlies === 0) { - break; - } else { - continue; - } - } - - if (charCode === 64 /* at */) { - break; - } - } - - if (j === commentContents.length) { - break; - } - - if (charCode === 64 /* at */) { - continue; - } - - j = Comment.consumeLeadingSpace(commentContents, j + 1); - if (j === -1) { - break; - } - } - - if (param !== commentContents.substr(j, param.length) || !Comment.isSpaceChar(commentContents, j + param.length)) { - continue; - } - - j = Comment.consumeLeadingSpace(commentContents, j + param.length); - if (j === -1) { - return ""; - } - - var endOfParam = commentContents.indexOf("@", j); - var paramHelpString = commentContents.substring(j, endOfParam < 0 ? commentContents.length : endOfParam); - - var paramSpacesToRemove = undefined; - var paramLineIndex = commentContents.substring(0, j).lastIndexOf("\n") + 1; - if (paramLineIndex !== 0) { - if (paramLineIndex < j && commentContents.charAt(paramLineIndex + 1) === "\r") { - paramLineIndex++; - } - } - var startSpaceRemovalIndex = Comment.consumeLeadingSpace(commentContents, paramLineIndex); - if (startSpaceRemovalIndex !== j && commentContents.charAt(startSpaceRemovalIndex) === "*") { - paramSpacesToRemove = j - startSpaceRemovalIndex - 1; - } - - return Comment.cleanJSDocComment(paramHelpString, paramSpacesToRemove); - } - } - - return ""; - }; - return Comment; - })(AST); - TypeScript.Comment = Comment; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var AstWalkOptions = (function () { - function AstWalkOptions() { - this.goChildren = true; - } - return AstWalkOptions; - })(); - TypeScript.AstWalkOptions = AstWalkOptions; - - var AstWalker = (function () { - function AstWalker(childrenWalkers, pre, post, options, state) { - this.childrenWalkers = childrenWalkers; - this.pre = pre; - this.post = post; - this.options = options; - this.state = state; - } - AstWalker.prototype.walk = function (ast, parent) { - var preAst = this.pre(ast, parent, this); - if (preAst === undefined) { - preAst = ast; - } - if (this.options.goChildren) { - this.childrenWalkers[ast.nodeType](ast, parent, this); - } else { - this.options.goChildren = true; - } - - if (this.post) { - var postAst = this.post(preAst, parent, this); - if (postAst === undefined) { - postAst = preAst; - } - return postAst; - } else { - return preAst; - } - }; - return AstWalker; - })(); - - var AstWalkerFactory = (function () { - function AstWalkerFactory() { - this.childrenWalkers = []; - this.initChildrenWalkers(); - } - AstWalkerFactory.prototype.walk = function (ast, pre, post, options, state) { - return this.getWalker(pre, post, options, state).walk(ast, null); - }; - - AstWalkerFactory.prototype.getWalker = function (pre, post, options, state) { - return this.getSlowWalker(pre, post, options, state); - }; - - AstWalkerFactory.prototype.getSlowWalker = function (pre, post, options, state) { - if (!options) { - options = new AstWalkOptions(); - } - - return new AstWalker(this.childrenWalkers, pre, post, options, state); - }; - - AstWalkerFactory.prototype.initChildrenWalkers = function () { - this.childrenWalkers[0 /* None */] = ChildrenWalkers.walkNone; - this.childrenWalkers[86 /* EmptyStatement */] = ChildrenWalkers.walkNone; - this.childrenWalkers[23 /* OmittedExpression */] = ChildrenWalkers.walkNone; - this.childrenWalkers[3 /* TrueLiteral */] = ChildrenWalkers.walkNone; - this.childrenWalkers[4 /* FalseLiteral */] = ChildrenWalkers.walkNone; - this.childrenWalkers[29 /* ThisExpression */] = ChildrenWalkers.walkNone; - this.childrenWalkers[30 /* SuperExpression */] = ChildrenWalkers.walkNone; - this.childrenWalkers[5 /* StringLiteral */] = ChildrenWalkers.walkNone; - this.childrenWalkers[6 /* RegularExpressionLiteral */] = ChildrenWalkers.walkNone; - this.childrenWalkers[8 /* NullLiteral */] = ChildrenWalkers.walkNone; - this.childrenWalkers[21 /* ArrayLiteralExpression */] = ChildrenWalkers.walkUnaryExpressionChildren; - this.childrenWalkers[22 /* ObjectLiteralExpression */] = ChildrenWalkers.walkUnaryExpressionChildren; - this.childrenWalkers[24 /* VoidExpression */] = ChildrenWalkers.walkUnaryExpressionChildren; - this.childrenWalkers[25 /* CommaExpression */] = ChildrenWalkers.walkBinaryExpressionChildren; - this.childrenWalkers[26 /* PlusExpression */] = ChildrenWalkers.walkUnaryExpressionChildren; - this.childrenWalkers[27 /* NegateExpression */] = ChildrenWalkers.walkUnaryExpressionChildren; - this.childrenWalkers[28 /* DeleteExpression */] = ChildrenWalkers.walkUnaryExpressionChildren; - this.childrenWalkers[31 /* InExpression */] = ChildrenWalkers.walkBinaryExpressionChildren; - this.childrenWalkers[32 /* MemberAccessExpression */] = ChildrenWalkers.walkBinaryExpressionChildren; - this.childrenWalkers[33 /* InstanceOfExpression */] = ChildrenWalkers.walkBinaryExpressionChildren; - this.childrenWalkers[34 /* TypeOfExpression */] = ChildrenWalkers.walkUnaryExpressionChildren; - this.childrenWalkers[7 /* NumericLiteral */] = ChildrenWalkers.walkNone; - this.childrenWalkers[20 /* Name */] = ChildrenWalkers.walkNone; - this.childrenWalkers[9 /* TypeParameter */] = ChildrenWalkers.walkTypeParameterChildren; - this.childrenWalkers[10 /* GenericType */] = ChildrenWalkers.walkGenericTypeChildren; - this.childrenWalkers[11 /* TypeRef */] = ChildrenWalkers.walkTypeReferenceChildren; - this.childrenWalkers[35 /* ElementAccessExpression */] = ChildrenWalkers.walkBinaryExpressionChildren; - this.childrenWalkers[36 /* InvocationExpression */] = ChildrenWalkers.walkCallExpressionChildren; - this.childrenWalkers[37 /* ObjectCreationExpression */] = ChildrenWalkers.walkCallExpressionChildren; - this.childrenWalkers[38 /* AssignmentExpression */] = ChildrenWalkers.walkBinaryExpressionChildren; - this.childrenWalkers[39 /* AddAssignmentExpression */] = ChildrenWalkers.walkBinaryExpressionChildren; - this.childrenWalkers[40 /* SubtractAssignmentExpression */] = ChildrenWalkers.walkBinaryExpressionChildren; - this.childrenWalkers[41 /* DivideAssignmentExpression */] = ChildrenWalkers.walkBinaryExpressionChildren; - this.childrenWalkers[42 /* MultiplyAssignmentExpression */] = ChildrenWalkers.walkBinaryExpressionChildren; - this.childrenWalkers[43 /* ModuloAssignmentExpression */] = ChildrenWalkers.walkBinaryExpressionChildren; - this.childrenWalkers[44 /* AndAssignmentExpression */] = ChildrenWalkers.walkBinaryExpressionChildren; - this.childrenWalkers[45 /* ExclusiveOrAssignmentExpression */] = ChildrenWalkers.walkBinaryExpressionChildren; - this.childrenWalkers[46 /* OrAssignmentExpression */] = ChildrenWalkers.walkBinaryExpressionChildren; - this.childrenWalkers[47 /* LeftShiftAssignmentExpression */] = ChildrenWalkers.walkBinaryExpressionChildren; - this.childrenWalkers[48 /* SignedRightShiftAssignmentExpression */] = ChildrenWalkers.walkBinaryExpressionChildren; - this.childrenWalkers[49 /* UnsignedRightShiftAssignmentExpression */] = ChildrenWalkers.walkBinaryExpressionChildren; - this.childrenWalkers[50 /* ConditionalExpression */] = ChildrenWalkers.walkTrinaryExpressionChildren; - this.childrenWalkers[51 /* LogicalOrExpression */] = ChildrenWalkers.walkBinaryExpressionChildren; - this.childrenWalkers[52 /* LogicalAndExpression */] = ChildrenWalkers.walkBinaryExpressionChildren; - this.childrenWalkers[53 /* BitwiseOrExpression */] = ChildrenWalkers.walkBinaryExpressionChildren; - this.childrenWalkers[54 /* BitwiseExclusiveOrExpression */] = ChildrenWalkers.walkBinaryExpressionChildren; - this.childrenWalkers[55 /* BitwiseAndExpression */] = ChildrenWalkers.walkBinaryExpressionChildren; - this.childrenWalkers[56 /* EqualsWithTypeConversionExpression */] = ChildrenWalkers.walkBinaryExpressionChildren; - this.childrenWalkers[57 /* NotEqualsWithTypeConversionExpression */] = ChildrenWalkers.walkBinaryExpressionChildren; - this.childrenWalkers[58 /* EqualsExpression */] = ChildrenWalkers.walkBinaryExpressionChildren; - this.childrenWalkers[59 /* NotEqualsExpression */] = ChildrenWalkers.walkBinaryExpressionChildren; - this.childrenWalkers[60 /* LessThanExpression */] = ChildrenWalkers.walkBinaryExpressionChildren; - this.childrenWalkers[61 /* LessThanOrEqualExpression */] = ChildrenWalkers.walkBinaryExpressionChildren; - this.childrenWalkers[62 /* GreaterThanExpression */] = ChildrenWalkers.walkBinaryExpressionChildren; - this.childrenWalkers[63 /* GreaterThanOrEqualExpression */] = ChildrenWalkers.walkBinaryExpressionChildren; - this.childrenWalkers[64 /* AddExpression */] = ChildrenWalkers.walkBinaryExpressionChildren; - this.childrenWalkers[65 /* SubtractExpression */] = ChildrenWalkers.walkBinaryExpressionChildren; - this.childrenWalkers[66 /* MultiplyExpression */] = ChildrenWalkers.walkBinaryExpressionChildren; - this.childrenWalkers[67 /* DivideExpression */] = ChildrenWalkers.walkBinaryExpressionChildren; - this.childrenWalkers[68 /* ModuloExpression */] = ChildrenWalkers.walkBinaryExpressionChildren; - this.childrenWalkers[69 /* LeftShiftExpression */] = ChildrenWalkers.walkBinaryExpressionChildren; - this.childrenWalkers[70 /* SignedRightShiftExpression */] = ChildrenWalkers.walkBinaryExpressionChildren; - this.childrenWalkers[71 /* UnsignedRightShiftExpression */] = ChildrenWalkers.walkBinaryExpressionChildren; - this.childrenWalkers[72 /* BitwiseNotExpression */] = ChildrenWalkers.walkUnaryExpressionChildren; - this.childrenWalkers[73 /* LogicalNotExpression */] = ChildrenWalkers.walkUnaryExpressionChildren; - this.childrenWalkers[74 /* PreIncrementExpression */] = ChildrenWalkers.walkUnaryExpressionChildren; - this.childrenWalkers[75 /* PreDecrementExpression */] = ChildrenWalkers.walkUnaryExpressionChildren; - this.childrenWalkers[76 /* PostIncrementExpression */] = ChildrenWalkers.walkUnaryExpressionChildren; - this.childrenWalkers[77 /* PostDecrementExpression */] = ChildrenWalkers.walkUnaryExpressionChildren; - this.childrenWalkers[78 /* CastExpression */] = ChildrenWalkers.walkUnaryExpressionChildren; - this.childrenWalkers[79 /* ParenthesizedExpression */] = ChildrenWalkers.walkParenthesizedExpressionChildren; - this.childrenWalkers[12 /* FunctionDeclaration */] = ChildrenWalkers.walkFuncDeclChildren; - this.childrenWalkers[80 /* Member */] = ChildrenWalkers.walkBinaryExpressionChildren; - this.childrenWalkers[17 /* VariableDeclarator */] = ChildrenWalkers.walkBoundDeclChildren; - this.childrenWalkers[18 /* VariableDeclaration */] = ChildrenWalkers.walkVariableDeclarationChildren; - this.childrenWalkers[19 /* Parameter */] = ChildrenWalkers.walkBoundDeclChildren; - this.childrenWalkers[93 /* ReturnStatement */] = ChildrenWalkers.walkReturnStatementChildren; - this.childrenWalkers[82 /* BreakStatement */] = ChildrenWalkers.walkNone; - this.childrenWalkers[83 /* ContinueStatement */] = ChildrenWalkers.walkNone; - this.childrenWalkers[95 /* ThrowStatement */] = ChildrenWalkers.walkThrowStatementChildren; - this.childrenWalkers[90 /* ForStatement */] = ChildrenWalkers.walkForStatementChildren; - this.childrenWalkers[89 /* ForInStatement */] = ChildrenWalkers.walkForInStatementChildren; - this.childrenWalkers[91 /* IfStatement */] = ChildrenWalkers.walkIfStatementChildren; - this.childrenWalkers[98 /* WhileStatement */] = ChildrenWalkers.walkWhileStatementChildren; - this.childrenWalkers[85 /* DoStatement */] = ChildrenWalkers.walkDoStatementChildren; - this.childrenWalkers[81 /* Block */] = ChildrenWalkers.walkBlockChildren; - this.childrenWalkers[100 /* CaseClause */] = ChildrenWalkers.walkCaseClauseChildren; - this.childrenWalkers[94 /* SwitchStatement */] = ChildrenWalkers.walkSwitchStatementChildren; - this.childrenWalkers[96 /* TryStatement */] = ChildrenWalkers.walkTryStatementChildren; - this.childrenWalkers[101 /* CatchClause */] = ChildrenWalkers.walkCatchClauseChildren; - this.childrenWalkers[1 /* List */] = ChildrenWalkers.walkListChildren; - this.childrenWalkers[2 /* Script */] = ChildrenWalkers.walkScriptChildren; - this.childrenWalkers[13 /* ClassDeclaration */] = ChildrenWalkers.walkClassDeclChildren; - this.childrenWalkers[14 /* InterfaceDeclaration */] = ChildrenWalkers.walkTypeDeclChildren; - this.childrenWalkers[15 /* ModuleDeclaration */] = ChildrenWalkers.walkModuleDeclChildren; - this.childrenWalkers[16 /* ImportDeclaration */] = ChildrenWalkers.walkImportDeclChildren; - this.childrenWalkers[87 /* ExportAssignment */] = ChildrenWalkers.walkExportAssignmentChildren; - this.childrenWalkers[99 /* WithStatement */] = ChildrenWalkers.walkWithStatementChildren; - this.childrenWalkers[88 /* ExpressionStatement */] = ChildrenWalkers.walkExpressionStatementChildren; - this.childrenWalkers[92 /* LabeledStatement */] = ChildrenWalkers.walkLabeledStatementChildren; - this.childrenWalkers[97 /* VariableStatement */] = ChildrenWalkers.walkVariableStatementChildren; - this.childrenWalkers[102 /* Comment */] = ChildrenWalkers.walkNone; - this.childrenWalkers[84 /* DebuggerStatement */] = ChildrenWalkers.walkNone; - - for (var e in TypeScript.NodeType) { - if (TypeScript.NodeType.hasOwnProperty(e) && TypeScript.StringUtilities.isString(TypeScript.NodeType[e])) { - if (this.childrenWalkers[e] === undefined) { - throw new Error("initWalkers function is not up to date with enum content!"); - } - } - } - }; - return AstWalkerFactory; - })(); - TypeScript.AstWalkerFactory = AstWalkerFactory; - - var globalAstWalkerFactory; - - function getAstWalkerFactory() { - if (!globalAstWalkerFactory) { - globalAstWalkerFactory = new AstWalkerFactory(); - } - return globalAstWalkerFactory; - } - TypeScript.getAstWalkerFactory = getAstWalkerFactory; - - var ChildrenWalkers; - (function (ChildrenWalkers) { - function walkNone(preAst, parent, walker) { - } - ChildrenWalkers.walkNone = walkNone; - - function walkListChildren(preAst, parent, walker) { - var len = preAst.members.length; - - for (var i = 0; i < len; i++) { - preAst.members[i] = walker.walk(preAst.members[i], preAst); - } - } - ChildrenWalkers.walkListChildren = walkListChildren; - - function walkThrowStatementChildren(preAst, parent, walker) { - if (preAst.expression) { - preAst.expression = walker.walk(preAst.expression, preAst); - } - } - ChildrenWalkers.walkThrowStatementChildren = walkThrowStatementChildren; - - function walkUnaryExpressionChildren(preAst, parent, walker) { - if (preAst.castTerm) { - preAst.castTerm = walker.walk(preAst.castTerm, preAst); - } - if (preAst.operand) { - preAst.operand = walker.walk(preAst.operand, preAst); - } - } - ChildrenWalkers.walkUnaryExpressionChildren = walkUnaryExpressionChildren; - - function walkParenthesizedExpressionChildren(preAst, parent, walker) { - if (preAst.expression) { - preAst.expression = walker.walk(preAst.expression, preAst); - } - } - ChildrenWalkers.walkParenthesizedExpressionChildren = walkParenthesizedExpressionChildren; - - function walkBinaryExpressionChildren(preAst, parent, walker) { - if (preAst.operand1) { - preAst.operand1 = walker.walk(preAst.operand1, preAst); - } - if (preAst.operand2) { - preAst.operand2 = walker.walk(preAst.operand2, preAst); - } - } - ChildrenWalkers.walkBinaryExpressionChildren = walkBinaryExpressionChildren; - - function walkTypeParameterChildren(preAst, parent, walker) { - if (preAst.name) { - preAst.name = walker.walk(preAst.name, preAst); - } - - if (preAst.constraint) { - preAst.constraint = walker.walk(preAst.constraint, preAst); - } - } - ChildrenWalkers.walkTypeParameterChildren = walkTypeParameterChildren; - - function walkGenericTypeChildren(preAst, parent, walker) { - if (preAst.name) { - preAst.name = walker.walk(preAst.name, preAst); - } - - if (preAst.typeArguments) { - preAst.typeArguments = walker.walk(preAst.typeArguments, preAst); - } - } - ChildrenWalkers.walkGenericTypeChildren = walkGenericTypeChildren; - - function walkTypeReferenceChildren(preAst, parent, walker) { - if (preAst.term) { - preAst.term = walker.walk(preAst.term, preAst); - } - } - ChildrenWalkers.walkTypeReferenceChildren = walkTypeReferenceChildren; - - function walkCallExpressionChildren(preAst, parent, walker) { - preAst.target = walker.walk(preAst.target, preAst); - - if (preAst.typeArguments) { - preAst.typeArguments = walker.walk(preAst.typeArguments, preAst); - } - - if (preAst.arguments) { - preAst.arguments = walker.walk(preAst.arguments, preAst); - } - } - ChildrenWalkers.walkCallExpressionChildren = walkCallExpressionChildren; - - function walkTrinaryExpressionChildren(preAst, parent, walker) { - if (preAst.operand1) { - preAst.operand1 = walker.walk(preAst.operand1, preAst); - } - if (preAst.operand2) { - preAst.operand2 = walker.walk(preAst.operand2, preAst); - } - if (preAst.operand3) { - preAst.operand3 = walker.walk(preAst.operand3, preAst); - } - } - ChildrenWalkers.walkTrinaryExpressionChildren = walkTrinaryExpressionChildren; - - function walkFuncDeclChildren(preAst, parent, walker) { - if (preAst.name) { - preAst.name = walker.walk(preAst.name, preAst); - } - if (preAst.typeArguments) { - preAst.typeArguments = walker.walk(preAst.typeArguments, preAst); - } - if (preAst.arguments) { - preAst.arguments = walker.walk(preAst.arguments, preAst); - } - if (preAst.returnTypeAnnotation) { - preAst.returnTypeAnnotation = walker.walk(preAst.returnTypeAnnotation, preAst); - } - if (preAst.block) { - preAst.block = walker.walk(preAst.block, preAst); - } - } - ChildrenWalkers.walkFuncDeclChildren = walkFuncDeclChildren; - - function walkBoundDeclChildren(preAst, parent, walker) { - if (preAst.id) { - preAst.id = walker.walk(preAst.id, preAst); - } - if (preAst.init) { - preAst.init = walker.walk(preAst.init, preAst); - } - if (preAst.typeExpr) { - preAst.typeExpr = walker.walk(preAst.typeExpr, preAst); - } - } - ChildrenWalkers.walkBoundDeclChildren = walkBoundDeclChildren; - - function walkReturnStatementChildren(preAst, parent, walker) { - if (preAst.returnExpression) { - preAst.returnExpression = walker.walk(preAst.returnExpression, preAst); - } - } - ChildrenWalkers.walkReturnStatementChildren = walkReturnStatementChildren; - - function walkForStatementChildren(preAst, parent, walker) { - if (preAst.init) { - preAst.init = walker.walk(preAst.init, preAst); - } - - if (preAst.cond) { - preAst.cond = walker.walk(preAst.cond, preAst); - } - - if (preAst.incr) { - preAst.incr = walker.walk(preAst.incr, preAst); - } - - if (preAst.body) { - preAst.body = walker.walk(preAst.body, preAst); - } - } - ChildrenWalkers.walkForStatementChildren = walkForStatementChildren; - - function walkForInStatementChildren(preAst, parent, walker) { - preAst.lval = walker.walk(preAst.lval, preAst); - preAst.obj = walker.walk(preAst.obj, preAst); - - if (preAst.body) { - preAst.body = walker.walk(preAst.body, preAst); - } - } - ChildrenWalkers.walkForInStatementChildren = walkForInStatementChildren; - - function walkIfStatementChildren(preAst, parent, walker) { - preAst.cond = walker.walk(preAst.cond, preAst); - if (preAst.thenBod) { - preAst.thenBod = walker.walk(preAst.thenBod, preAst); - } - if (preAst.elseBod) { - preAst.elseBod = walker.walk(preAst.elseBod, preAst); - } - } - ChildrenWalkers.walkIfStatementChildren = walkIfStatementChildren; - - function walkWhileStatementChildren(preAst, parent, walker) { - preAst.cond = walker.walk(preAst.cond, preAst); - if (preAst.body) { - preAst.body = walker.walk(preAst.body, preAst); - } - } - ChildrenWalkers.walkWhileStatementChildren = walkWhileStatementChildren; - - function walkDoStatementChildren(preAst, parent, walker) { - preAst.cond = walker.walk(preAst.cond, preAst); - if (preAst.body) { - preAst.body = walker.walk(preAst.body, preAst); - } - } - ChildrenWalkers.walkDoStatementChildren = walkDoStatementChildren; - - function walkBlockChildren(preAst, parent, walker) { - if (preAst.statements) { - preAst.statements = walker.walk(preAst.statements, preAst); - } - } - ChildrenWalkers.walkBlockChildren = walkBlockChildren; - - function walkVariableDeclarationChildren(preAst, parent, walker) { - if (preAst.declarators) { - preAst.declarators = walker.walk(preAst.declarators, preAst); - } - } - ChildrenWalkers.walkVariableDeclarationChildren = walkVariableDeclarationChildren; - - function walkCaseClauseChildren(preAst, parent, walker) { - if (preAst.expr) { - preAst.expr = walker.walk(preAst.expr, preAst); - } - - if (preAst.body) { - preAst.body = walker.walk(preAst.body, preAst); - } - } - ChildrenWalkers.walkCaseClauseChildren = walkCaseClauseChildren; - - function walkSwitchStatementChildren(preAst, parent, walker) { - if (preAst.val) { - preAst.val = walker.walk(preAst.val, preAst); - } - - if (preAst.caseList) { - preAst.caseList = walker.walk(preAst.caseList, preAst); - } - } - ChildrenWalkers.walkSwitchStatementChildren = walkSwitchStatementChildren; - - function walkTryStatementChildren(preAst, parent, walker) { - if (preAst.tryBody) { - preAst.tryBody = walker.walk(preAst.tryBody, preAst); - } - if (preAst.catchClause) { - preAst.catchClause = walker.walk(preAst.catchClause, preAst); - } - if (preAst.finallyBody) { - preAst.finallyBody = walker.walk(preAst.finallyBody, preAst); - } - } - ChildrenWalkers.walkTryStatementChildren = walkTryStatementChildren; - - function walkCatchClauseChildren(preAst, parent, walker) { - if (preAst.param) { - preAst.param = walker.walk(preAst.param, preAst); - } - - if (preAst.body) { - preAst.body = walker.walk(preAst.body, preAst); - } - } - ChildrenWalkers.walkCatchClauseChildren = walkCatchClauseChildren; - - function walkRecordChildren(preAst, parent, walker) { - preAst.name = walker.walk(preAst.name, preAst); - if (preAst.members) { - preAst.members = walker.walk(preAst.members, preAst); - } - } - ChildrenWalkers.walkRecordChildren = walkRecordChildren; - - function walkNamedTypeChildren(preAst, parent, walker) { - walkRecordChildren(preAst, parent, walker); - } - ChildrenWalkers.walkNamedTypeChildren = walkNamedTypeChildren; - - function walkClassDeclChildren(preAst, parent, walker) { - walkNamedTypeChildren(preAst, parent, walker); - - if (preAst.typeParameters) { - preAst.typeParameters = walker.walk(preAst.typeParameters, preAst); - } - - if (preAst.extendsList) { - preAst.extendsList = walker.walk(preAst.extendsList, preAst); - } - - if (preAst.implementsList) { - preAst.implementsList = walker.walk(preAst.implementsList, preAst); - } - } - ChildrenWalkers.walkClassDeclChildren = walkClassDeclChildren; - - function walkScriptChildren(preAst, parent, walker) { - if (preAst.moduleElements) { - preAst.moduleElements = walker.walk(preAst.moduleElements, preAst); - } - } - ChildrenWalkers.walkScriptChildren = walkScriptChildren; - - function walkTypeDeclChildren(preAst, parent, walker) { - walkNamedTypeChildren(preAst, parent, walker); - - if (preAst.typeParameters) { - preAst.typeParameters = walker.walk(preAst.typeParameters, preAst); - } - - if (preAst.extendsList) { - preAst.extendsList = walker.walk(preAst.extendsList, preAst); - } - - if (preAst.implementsList) { - preAst.implementsList = walker.walk(preAst.implementsList, preAst); - } - } - ChildrenWalkers.walkTypeDeclChildren = walkTypeDeclChildren; - - function walkModuleDeclChildren(preAst, parent, walker) { - walkRecordChildren(preAst, parent, walker); - } - ChildrenWalkers.walkModuleDeclChildren = walkModuleDeclChildren; - - function walkImportDeclChildren(preAst, parent, walker) { - if (preAst.id) { - preAst.id = walker.walk(preAst.id, preAst); - } - if (preAst.alias) { - preAst.alias = walker.walk(preAst.alias, preAst); - } - } - ChildrenWalkers.walkImportDeclChildren = walkImportDeclChildren; - - function walkExportAssignmentChildren(preAst, parent, walker) { - if (preAst.id) { - preAst.id = walker.walk(preAst.id, preAst); - } - } - ChildrenWalkers.walkExportAssignmentChildren = walkExportAssignmentChildren; - - function walkWithStatementChildren(preAst, parent, walker) { - if (preAst.expr) { - preAst.expr = walker.walk(preAst.expr, preAst); - } - - if (preAst.body) { - preAst.body = walker.walk(preAst.body, preAst); - } - } - ChildrenWalkers.walkWithStatementChildren = walkWithStatementChildren; - - function walkExpressionStatementChildren(preAst, parent, walker) { - preAst.expression = walker.walk(preAst.expression, preAst); - } - ChildrenWalkers.walkExpressionStatementChildren = walkExpressionStatementChildren; - - function walkLabeledStatementChildren(preAst, parent, walker) { - preAst.identifier = walker.walk(preAst.identifier, preAst); - preAst.statement = walker.walk(preAst.statement, preAst); - } - ChildrenWalkers.walkLabeledStatementChildren = walkLabeledStatementChildren; - - function walkVariableStatementChildren(preAst, parent, walker) { - preAst.declaration = walker.walk(preAst.declaration, preAst); - } - ChildrenWalkers.walkVariableStatementChildren = walkVariableStatementChildren; - })(ChildrenWalkers || (ChildrenWalkers = {})); -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (AstWalkerWithDetailCallback) { - function walk(script, callback) { - var pre = function (cur, parent) { - walker.options.goChildren = AstWalkerCallback(true, cur, callback); - return cur; - }; - - var post = function (cur, parent) { - AstWalkerCallback(false, cur, callback); - return cur; - }; - - var walker = TypeScript.getAstWalkerFactory().getWalker(pre, post); - walker.walk(script, null); - } - AstWalkerWithDetailCallback.walk = walk; - - function AstWalkerCallback(pre, ast, callback) { - var nodeType = ast.nodeType; - var callbackString = TypeScript.NodeType[nodeType] + "Callback"; - if (callback[callbackString]) { - return callback[callbackString](pre, ast); - } - - if (callback.DefaultCallback) { - return callback.DefaultCallback(pre, ast); - } - - return true; - } - })(TypeScript.AstWalkerWithDetailCallback || (TypeScript.AstWalkerWithDetailCallback = {})); - var AstWalkerWithDetailCallback = TypeScript.AstWalkerWithDetailCallback; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - function max(a, b) { - return a >= b ? a : b; - } - TypeScript.max = max; - - function min(a, b) { - return a <= b ? a : b; - } - TypeScript.min = min; - - var AstPath = (function () { - function AstPath() { - this.asts = []; - this.top = -1; - } - AstPath.reverseIndexOf = function (items, index) { - return (items === null || items.length <= index) ? null : items[items.length - index - 1]; - }; - - AstPath.prototype.clone = function () { - var clone = new AstPath(); - clone.asts = this.asts.map(function (value) { - return value; - }); - clone.top = this.top; - return clone; - }; - - AstPath.prototype.pop = function () { - var head = this.ast(); - this.up(); - - while (this.asts.length > this.count()) { - this.asts.pop(); - } - return head; - }; - - AstPath.prototype.push = function (ast) { - while (this.asts.length > this.count()) { - this.asts.pop(); - } - this.top = this.asts.length; - this.asts.push(ast); - }; - - AstPath.prototype.up = function () { - if (this.top <= -1) - throw new Error("Invalid call to 'up'"); - this.top--; - }; - - AstPath.prototype.down = function () { - if (this.top === this.ast.length - 1) - throw new Error("Invalid call to 'down'"); - this.top++; - }; - - AstPath.prototype.nodeType = function () { - if (this.ast() === null) - return 0 /* None */; - return this.ast().nodeType; - }; - - AstPath.prototype.ast = function () { - return AstPath.reverseIndexOf(this.asts, this.asts.length - (this.top + 1)); - }; - - AstPath.prototype.parent = function () { - return AstPath.reverseIndexOf(this.asts, this.asts.length - this.top); - }; - - AstPath.prototype.count = function () { - return this.top + 1; - }; - - AstPath.prototype.get = function (index) { - return this.asts[index]; - }; - - AstPath.prototype.isNameOfClass = function () { - if (this.ast() === null || this.parent() === null) - return false; - - return (this.ast().nodeType === 20 /* Name */) && (this.parent().nodeType === 13 /* ClassDeclaration */) && ((this.parent()).name === this.ast()); - }; - - AstPath.prototype.isNameOfInterface = function () { - if (this.ast() === null || this.parent() === null) - return false; - - return (this.ast().nodeType === 20 /* Name */) && (this.parent().nodeType === 14 /* InterfaceDeclaration */) && ((this.parent()).name === this.ast()); - }; - - AstPath.prototype.isNameOfArgument = function () { - if (this.ast() === null || this.parent() === null) - return false; - - return (this.ast().nodeType === 20 /* Name */) && (this.parent().nodeType === 19 /* Parameter */) && ((this.parent()).id === this.ast()); - }; - - AstPath.prototype.isNameOfVariable = function () { - if (this.ast() === null || this.parent() === null) - return false; - - return (this.ast().nodeType === 20 /* Name */) && (this.parent().nodeType === 17 /* VariableDeclarator */) && ((this.parent()).id === this.ast()); - }; - - AstPath.prototype.isNameOfModule = function () { - if (this.ast() === null || this.parent() === null) - return false; - - return (this.ast().nodeType === 20 /* Name */) && (this.parent().nodeType === 15 /* ModuleDeclaration */) && ((this.parent()).name === this.ast()); - }; - - AstPath.prototype.isNameOfFunction = function () { - if (this.ast() === null || this.parent() === null) - return false; - - return (this.ast().nodeType === 20 /* Name */) && (this.parent().nodeType === 12 /* FunctionDeclaration */) && ((this.parent()).name === this.ast()); - }; - - AstPath.prototype.isBodyOfFunction = function () { - return this.count() >= 2 && this.asts[this.top - 1].nodeType === 12 /* FunctionDeclaration */ && (this.asts[this.top - 1]).block === this.asts[this.top - 0]; - }; - - AstPath.prototype.isArgumentListOfFunction = function () { - return this.count() >= 2 && this.asts[this.top - 0].nodeType === 1 /* List */ && this.asts[this.top - 1].nodeType === 12 /* FunctionDeclaration */ && (this.asts[this.top - 1]).arguments === this.asts[this.top - 0]; - }; - - AstPath.prototype.isTargetOfCall = function () { - return this.count() >= 2 && this.asts[this.top - 1].nodeType === 36 /* InvocationExpression */ && (this.asts[this.top - 1]).target === this.asts[this.top]; - }; - - AstPath.prototype.isTargetOfNew = function () { - return this.count() >= 2 && this.asts[this.top - 1].nodeType === 37 /* ObjectCreationExpression */ && (this.asts[this.top - 1]).target === this.asts[this.top]; - }; - - AstPath.prototype.isInClassImplementsList = function () { - if (this.ast() === null || this.parent() === null) - return false; - - return (this.parent().nodeType === 13 /* ClassDeclaration */) && (this.isMemberOfList((this.parent()).implementsList, this.ast())); - }; - - AstPath.prototype.isInInterfaceExtendsList = function () { - if (this.ast() === null || this.parent() === null) - return false; - - return (this.parent().nodeType === 14 /* InterfaceDeclaration */) && (this.isMemberOfList((this.parent()).extendsList, this.ast())); - }; - - AstPath.prototype.isMemberOfMemberAccessExpression = function () { - if (this.count() > 1 && this.parent().nodeType === 32 /* MemberAccessExpression */ && (this.parent()).operand2 === this.asts[this.top]) { - return true; - } - - return false; - }; - - AstPath.prototype.isCallExpression = function () { - return this.count() >= 1 && (this.asts[this.top - 0].nodeType === 36 /* InvocationExpression */ || this.asts[this.top - 0].nodeType === 37 /* ObjectCreationExpression */); - }; - - AstPath.prototype.isCallExpressionTarget = function () { - if (this.count() < 2) { - return false; - } - - var current = this.top; - - var nodeType = this.asts[current].nodeType; - if (nodeType === 29 /* ThisExpression */ || nodeType === 30 /* SuperExpression */ || nodeType === 20 /* Name */) { - current--; - } - - while (current >= 0) { - if (current < this.top && this.asts[current].nodeType === 32 /* MemberAccessExpression */ && (this.asts[current]).operand2 === this.asts[current + 1]) { - current--; - continue; - } - - break; - } - - return current < this.top && (this.asts[current].nodeType === 36 /* InvocationExpression */ || this.asts[current].nodeType === 37 /* ObjectCreationExpression */) && this.asts[current + 1] === (this.asts[current]).target; - }; - - AstPath.prototype.isDeclaration = function () { - if (this.ast() !== null) { - switch (this.ast().nodeType) { - case 13 /* ClassDeclaration */: - case 14 /* InterfaceDeclaration */: - case 15 /* ModuleDeclaration */: - case 12 /* FunctionDeclaration */: - case 17 /* VariableDeclarator */: - return true; - } - } - - return false; - }; - - AstPath.prototype.isMemberOfList = function (list, item) { - if (list && list.members) { - for (var i = 0, n = list.members.length; i < n; i++) { - if (list.members[i] === item) { - return true; - } - } - } - - return false; - }; - return AstPath; - })(); - TypeScript.AstPath = AstPath; - - function isValidAstNode(ast) { - if (ast === null) - return false; - - if (ast.minChar === -1 || ast.limChar === -1) - return false; - - return true; - } - TypeScript.isValidAstNode = isValidAstNode; - - var AstPathContext = (function () { - function AstPathContext() { - this.path = new TypeScript.AstPath(); - } - return AstPathContext; - })(); - TypeScript.AstPathContext = AstPathContext; - - (function (GetAstPathOptions) { - GetAstPathOptions[GetAstPathOptions["Default"] = 0] = "Default"; - GetAstPathOptions[GetAstPathOptions["EdgeInclusive"] = 1] = "EdgeInclusive"; - - GetAstPathOptions[GetAstPathOptions["DontPruneSearchBasedOnPosition"] = 1 << 1] = "DontPruneSearchBasedOnPosition"; - })(TypeScript.GetAstPathOptions || (TypeScript.GetAstPathOptions = {})); - var GetAstPathOptions = TypeScript.GetAstPathOptions; - - function getAstPathToPosition(script, pos, useTrailingTriviaAsLimChar, options) { - if (typeof useTrailingTriviaAsLimChar === "undefined") { useTrailingTriviaAsLimChar = true; } - if (typeof options === "undefined") { options = 0 /* Default */; } - var lookInComments = function (comments) { - if (comments && comments.length > 0) { - for (var i = 0; i < comments.length; i++) { - var minChar = comments[i].minChar; - var limChar = comments[i].limChar + (useTrailingTriviaAsLimChar ? comments[i].trailingTriviaWidth : 0); - if (!comments[i].isBlockComment) { - limChar++; - } - if (pos >= minChar && pos < limChar) { - ctx.path.push(comments[i]); - } - } - } - }; - - var pre = function (cur, parent, walker) { - if (isValidAstNode(cur)) { - var inclusive = TypeScript.hasFlag(options, 1 /* EdgeInclusive */) || cur.nodeType === 20 /* Name */ || cur.nodeType === 32 /* MemberAccessExpression */ || cur.nodeType === 11 /* TypeRef */ || pos === script.limChar + script.trailingTriviaWidth; - - var minChar = cur.minChar; - var limChar = cur.limChar + (useTrailingTriviaAsLimChar ? cur.trailingTriviaWidth : 0) + (inclusive ? 1 : 0); - if (pos >= minChar && pos < limChar) { - var previous = ctx.path.ast(); - if (previous === null || (cur.minChar >= previous.minChar && (cur.limChar + (useTrailingTriviaAsLimChar ? cur.trailingTriviaWidth : 0)) <= (previous.limChar + (useTrailingTriviaAsLimChar ? previous.trailingTriviaWidth : 0)))) { - ctx.path.push(cur); - } else { - } - } - - if (pos < limChar) { - lookInComments(cur.preComments); - } - if (pos >= minChar) { - lookInComments(cur.postComments); - } - - if (!TypeScript.hasFlag(options, 2 /* DontPruneSearchBasedOnPosition */)) { - walker.options.goChildren = (minChar <= pos && pos <= limChar); - } - } - return cur; - }; - - var ctx = new AstPathContext(); - TypeScript.getAstWalkerFactory().walk(script, pre, null, null, ctx); - return ctx.path; - } - TypeScript.getAstPathToPosition = getAstPathToPosition; - - function walkAST(ast, callback) { - var pre = function (cur, parent, walker) { - var path = walker.state; - path.push(cur); - callback(path, walker); - return cur; - }; - var post = function (cur, parent, walker) { - var path = walker.state; - path.pop(); - return cur; - }; - - var path = new AstPath(); - TypeScript.getAstWalkerFactory().walk(ast, pre, post, null, path); - } - TypeScript.walkAST = walkAST; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var Base64Format = (function () { - function Base64Format() { - } - Base64Format.encode = function (inValue) { - if (inValue < 64) { - return Base64Format.encodedValues.charAt(inValue); - } - throw TypeError(inValue + ": not a 64 based value"); - }; - - Base64Format.decodeChar = function (inChar) { - if (inChar.length === 1) { - return Base64Format.encodedValues.indexOf(inChar); - } else { - throw TypeError('"' + inChar + '" must have length 1'); - } - }; - Base64Format.encodedValues = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'; - return Base64Format; - })(); - - var Base64VLQFormat = (function () { - function Base64VLQFormat() { - } - Base64VLQFormat.encode = function (inValue) { - if (inValue < 0) { - inValue = ((-inValue) << 1) + 1; - } else { - inValue = inValue << 1; - } - - var encodedStr = ""; - do { - var currentDigit = inValue & 31; - inValue = inValue >> 5; - if (inValue > 0) { - currentDigit = currentDigit | 32; - } - encodedStr = encodedStr + Base64Format.encode(currentDigit); - } while(inValue > 0); - - return encodedStr; - }; - - Base64VLQFormat.decode = function (inString) { - var result = 0; - var negative = false; - - var shift = 0; - for (var i = 0; i < inString.length; i++) { - var byte = Base64Format.decodeChar(inString[i]); - if (i === 0) { - if ((byte & 1) === 1) { - negative = true; - } - result = (byte >> 1) & 15; - } else { - result = result | ((byte & 31) << shift); - } - - shift += (i === 0) ? 4 : 5; - - if ((byte & 32) === 32) { - } else { - return { value: negative ? -(result) : result, rest: inString.substr(i + 1) }; - } - } - - throw new Error('Base64 value "' + inString + '" finished with a continuation bit'); - }; - return Base64VLQFormat; - })(); - TypeScript.Base64VLQFormat = Base64VLQFormat; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var SourceMapPosition = (function () { - function SourceMapPosition() { - } - return SourceMapPosition; - })(); - TypeScript.SourceMapPosition = SourceMapPosition; - - var SourceMapping = (function () { - function SourceMapping() { - this.start = new SourceMapPosition(); - this.end = new SourceMapPosition(); - this.nameIndex = -1; - this.childMappings = []; - } - return SourceMapping; - })(); - TypeScript.SourceMapping = SourceMapping; - - var SourceMapper = (function () { - function SourceMapper(tsFileName, jsFileName, sourceMapFileName, jsFile, sourceMapOut, emitFullPathOfSourceMap) { - this.sourceMapFileName = sourceMapFileName; - this.jsFile = jsFile; - this.sourceMapOut = sourceMapOut; - this.sourceMappings = []; - this.currentMappings = []; - this.names = []; - this.currentNameIndex = []; - this.currentMappings.push(this.sourceMappings); - - jsFileName = TypeScript.switchToForwardSlashes(jsFileName); - this.jsFileName = TypeScript.getPrettyName(jsFileName, false, true); - - var removalIndex = jsFileName.lastIndexOf(this.jsFileName); - var fixedPath = jsFileName.substring(0, removalIndex); - - if (emitFullPathOfSourceMap) { - if (jsFileName.indexOf("://") === -1) { - jsFileName = "file:///" + jsFileName; - } - this.jsFileName = jsFileName; - } - - this.tsFileName = TypeScript.getRelativePathToFixedPath(fixedPath, tsFileName); - } - SourceMapper.emitSourceMapping = function (allSourceMappers) { - var sourceMapper = allSourceMappers[0]; - sourceMapper.jsFile.WriteLine("//@ sourceMappingURL=" + sourceMapper.jsFileName + SourceMapper.MapFileExtension); - - var sourceMapOut = sourceMapper.sourceMapOut; - var mappingsString = ""; - var tsFiles = []; - - var prevEmittedColumn = 0; - var prevEmittedLine = 0; - var prevSourceColumn = 0; - var prevSourceLine = 0; - var prevSourceIndex = 0; - var prevNameIndex = 0; - var namesList = []; - var namesCount = 0; - var emitComma = false; - - var recordedPosition = null; - for (var sourceMapperIndex = 0; sourceMapperIndex < allSourceMappers.length; sourceMapperIndex++) { - sourceMapper = allSourceMappers[sourceMapperIndex]; - - var currentSourceIndex = tsFiles.length; - tsFiles.push(sourceMapper.tsFileName); - - if (sourceMapper.names.length > 0) { - namesList.push.apply(namesList, sourceMapper.names); - } - - var recordSourceMapping = function (mappedPosition, nameIndex) { - if (recordedPosition !== null && recordedPosition.emittedColumn === mappedPosition.emittedColumn && recordedPosition.emittedLine === mappedPosition.emittedLine) { - return; - } - - if (prevEmittedLine !== mappedPosition.emittedLine) { - while (prevEmittedLine < mappedPosition.emittedLine) { - prevEmittedColumn = 0; - mappingsString = mappingsString + ";"; - prevEmittedLine++; - } - emitComma = false; - } else if (emitComma) { - mappingsString = mappingsString + ","; - } - - mappingsString = mappingsString + TypeScript.Base64VLQFormat.encode(mappedPosition.emittedColumn - prevEmittedColumn); - prevEmittedColumn = mappedPosition.emittedColumn; - - mappingsString = mappingsString + TypeScript.Base64VLQFormat.encode(currentSourceIndex - prevSourceIndex); - prevSourceIndex = currentSourceIndex; - - mappingsString = mappingsString + TypeScript.Base64VLQFormat.encode(mappedPosition.sourceLine - 1 - prevSourceLine); - prevSourceLine = mappedPosition.sourceLine - 1; - - mappingsString = mappingsString + TypeScript.Base64VLQFormat.encode(mappedPosition.sourceColumn - prevSourceColumn); - prevSourceColumn = mappedPosition.sourceColumn; - - if (nameIndex >= 0) { - mappingsString = mappingsString + TypeScript.Base64VLQFormat.encode(namesCount + nameIndex - prevNameIndex); - prevNameIndex = namesCount + nameIndex; - } - - emitComma = true; - recordedPosition = mappedPosition; - }; - - var recordSourceMappingSiblings = function (sourceMappings) { - 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(sourceMapper.sourceMappings); - namesCount = namesCount + sourceMapper.names.length; - } - - sourceMapOut.Write(JSON.stringify({ - version: 3, - file: sourceMapper.jsFileName, - sources: tsFiles, - names: namesList, - mappings: mappingsString - })); - - sourceMapOut.Close(); - }; - SourceMapper.MapFileExtension = ".map"; - return SourceMapper; - })(); - TypeScript.SourceMapper = SourceMapper; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (EmitContainer) { - EmitContainer[EmitContainer["Prog"] = 0] = "Prog"; - EmitContainer[EmitContainer["Module"] = 1] = "Module"; - EmitContainer[EmitContainer["DynamicModule"] = 2] = "DynamicModule"; - EmitContainer[EmitContainer["Class"] = 3] = "Class"; - EmitContainer[EmitContainer["Constructor"] = 4] = "Constructor"; - EmitContainer[EmitContainer["Function"] = 5] = "Function"; - EmitContainer[EmitContainer["Args"] = 6] = "Args"; - EmitContainer[EmitContainer["Interface"] = 7] = "Interface"; - })(TypeScript.EmitContainer || (TypeScript.EmitContainer = {})); - var EmitContainer = TypeScript.EmitContainer; - - var EmitState = (function () { - function EmitState() { - this.column = 0; - this.line = 0; - this.container = 0 /* Prog */; - } - return EmitState; - })(); - TypeScript.EmitState = EmitState; - - var EmitOptions = (function () { - function EmitOptions(compilationSettings) { - this.compilationSettings = compilationSettings; - this.ioHost = null; - this.outputMany = true; - this.commonDirectoryPath = ""; - } - EmitOptions.prototype.mapOutputFileName = function (fileName, extensionChanger) { - if (this.outputMany) { - var updatedFileName = fileName; - if (this.compilationSettings.outputOption !== "") { - updatedFileName = fileName.replace(this.commonDirectoryPath, ""); - updatedFileName = this.compilationSettings.outputOption + updatedFileName; - } - return extensionChanger(updatedFileName, false); - } else { - return extensionChanger(this.compilationSettings.outputOption, true); - } - }; - return EmitOptions; - })(); - TypeScript.EmitOptions = EmitOptions; - - var Indenter = (function () { - function Indenter() { - this.indentAmt = 0; - } - Indenter.prototype.increaseIndent = function () { - this.indentAmt += Indenter.indentStep; - }; - - Indenter.prototype.decreaseIndent = function () { - this.indentAmt -= Indenter.indentStep; - }; - - Indenter.prototype.getIndent = function () { - var indentString = Indenter.indentStrings[this.indentAmt]; - if (indentString === undefined) { - indentString = ""; - for (var i = 0; i < this.indentAmt; i = i + Indenter.indentStep) { - indentString += Indenter.indentStepString; - } - Indenter.indentStrings[this.indentAmt] = indentString; - } - return indentString; - }; - Indenter.indentStep = 4; - Indenter.indentStepString = " "; - Indenter.indentStrings = []; - return Indenter; - })(); - TypeScript.Indenter = Indenter; - - var Emitter = (function () { - function Emitter(emittingFileName, outfile, emitOptions, semanticInfoChain) { - this.emittingFileName = emittingFileName; - this.outfile = outfile; - this.emitOptions = emitOptions; - this.semanticInfoChain = semanticInfoChain; - this.globalThisCapturePrologueEmitted = false; - this.extendsPrologueEmitted = false; - this.thisClassNode = null; - this.thisFunctionDeclaration = null; - this.moduleName = ""; - this.emitState = new EmitState(); - this.indenter = new Indenter(); - this.modAliasId = null; - this.firstModAlias = null; - this.allSourceMappers = []; - this.sourceMapper = null; - this.captureThisStmtString = "var _this = this;"; - this.varListCountStack = [0]; - this.pullTypeChecker = null; - this.declStack = []; - this.resolvingContext = new TypeScript.PullTypeResolutionContext(); - this.exportAssignmentIdentifier = null; - this.document = null; - TypeScript.globalSemanticInfoChain = semanticInfoChain; - TypeScript.globalBinder.semanticInfoChain = semanticInfoChain; - this.pullTypeChecker = new TypeScript.PullTypeChecker(emitOptions.compilationSettings, semanticInfoChain); - } - Emitter.prototype.pushDecl = function (decl) { - if (decl) { - this.declStack[this.declStack.length] = decl; - } - }; - - Emitter.prototype.popDecl = function (decl) { - if (decl) { - this.declStack.length--; - } - }; - - Emitter.prototype.getEnclosingDecl = function () { - var declStackLen = this.declStack.length; - var enclosingDecl = declStackLen > 0 ? this.declStack[declStackLen - 1] : null; - return enclosingDecl; - }; - - Emitter.prototype.setTypeCheckerUnit = function (fileName) { - if (!this.pullTypeChecker.resolver) { - this.pullTypeChecker.setUnit(fileName); - return; - } - - this.pullTypeChecker.resolver.setUnitPath(fileName); - }; - - Emitter.prototype.setExportAssignmentIdentifier = function (id) { - this.exportAssignmentIdentifier = id; - }; - - Emitter.prototype.getExportAssignmentIdentifier = function () { - return this.exportAssignmentIdentifier; - }; - - Emitter.prototype.setDocument = function (document) { - this.document = document; - }; - - Emitter.prototype.importStatementShouldBeEmitted = function (importDeclAST, unitPath) { - if (!importDeclAST.isDynamicImport) { - return true; - } - - var importDecl = this.semanticInfoChain.getDeclForAST(importDeclAST, this.document.fileName); - var pullSymbol = importDecl.getSymbol(); - return pullSymbol.getIsUsedAsValue(); - }; - - Emitter.prototype.setSourceMappings = function (mapper) { - this.allSourceMappers.push(mapper); - this.sourceMapper = mapper; - }; - - Emitter.prototype.writeToOutput = function (s) { - this.outfile.Write(s); - - this.emitState.column += s.length; - }; - - Emitter.prototype.writeToOutputTrimmable = function (s) { - if (this.emitOptions.compilationSettings.minWhitespace) { - s = s.replace(/[\s]*/g, ''); - } - this.writeToOutput(s); - }; - - Emitter.prototype.writeLineToOutput = function (s) { - if (this.emitOptions.compilationSettings.minWhitespace) { - this.writeToOutput(s); - var c = s.charCodeAt(s.length - 1); - if (!((c === 32 /* space */) || (c === 59 /* semicolon */) || (c === 91 /* openBracket */))) { - this.writeToOutput(' '); - } - } else { - this.outfile.WriteLine(s); - this.emitState.column = 0; - this.emitState.line++; - } - }; - - Emitter.prototype.writeCaptureThisStatement = function (ast) { - this.emitIndent(); - this.recordSourceMappingStart(ast); - this.writeToOutput(this.captureThisStmtString); - this.recordSourceMappingEnd(ast); - this.writeLineToOutput(""); - }; - - Emitter.prototype.setInVarBlock = function (count) { - this.varListCountStack[this.varListCountStack.length - 1] = count; - }; - - Emitter.prototype.setContainer = function (c) { - var temp = this.emitState.container; - this.emitState.container = c; - return temp; - }; - - Emitter.prototype.getIndentString = function () { - if (this.emitOptions.compilationSettings.minWhitespace) { - return ""; - } else { - return this.indenter.getIndent(); - } - }; - - Emitter.prototype.emitIndent = function () { - this.writeToOutput(this.getIndentString()); - }; - - Emitter.prototype.emitCommentInPlace = function (comment) { - var text = comment.getText(); - var hadNewLine = false; - - if (comment.isBlockComment) { - if (this.emitState.column === 0) { - this.emitIndent(); - } - this.recordSourceMappingStart(comment); - this.writeToOutput(text[0]); - - if (text.length > 1 || comment.endsLine) { - for (var i = 1; i < text.length; i++) { - this.writeLineToOutput(""); - this.emitIndent(); - this.writeToOutput(text[i]); - } - this.recordSourceMappingEnd(comment); - this.writeLineToOutput(""); - hadNewLine = true; - } else { - this.recordSourceMappingEnd(comment); - } - } else { - if (this.emitState.column === 0) { - this.emitIndent(); - } - this.recordSourceMappingStart(comment); - this.writeToOutput(text[0]); - this.recordSourceMappingEnd(comment); - this.writeLineToOutput(""); - hadNewLine = true; - } - - if (hadNewLine) { - this.emitIndent(); - } else { - this.writeToOutput(" "); - } - }; - - Emitter.prototype.emitComments = function (ast, pre) { - var comments = pre ? ast.preComments : ast.postComments; - - if (this.emitOptions.compilationSettings.emitComments && comments && comments.length !== 0) { - for (var i = 0; i < comments.length; i++) { - this.emitCommentInPlace(comments[i]); - } - } - }; - - Emitter.prototype.emitObjectLiteral = function (objectLiteral) { - var useNewLines = !TypeScript.hasFlag(objectLiteral.getFlags(), 2 /* SingleLine */); - - this.writeToOutput("{"); - var list = objectLiteral.operand; - if (list.members.length > 0) { - if (useNewLines) { - this.writeLineToOutput(""); - } else { - this.writeToOutput(" "); - } - - this.indenter.increaseIndent(); - this.emitCommaSeparatedList(list, useNewLines); - this.indenter.decreaseIndent(); - if (useNewLines) { - this.emitIndent(); - } else { - this.writeToOutput(" "); - } - } - this.writeToOutput("}"); - }; - - Emitter.prototype.emitArrayLiteral = function (arrayLiteral) { - var useNewLines = !TypeScript.hasFlag(arrayLiteral.getFlags(), 2 /* SingleLine */); - - this.writeToOutput("["); - var list = arrayLiteral.operand; - if (list.members.length > 0) { - if (useNewLines) { - this.writeLineToOutput(""); - } - - this.indenter.increaseIndent(); - this.emitCommaSeparatedList(list, useNewLines); - this.indenter.decreaseIndent(); - if (useNewLines) { - this.emitIndent(); - } - } - this.writeToOutput("]"); - }; - - Emitter.prototype.emitNew = function (target, args) { - this.writeToOutput("new "); - if (target.nodeType === 11 /* TypeRef */) { - var typeRef = target; - if (typeRef.arrayCount) { - this.writeToOutput("Array()"); - } else { - typeRef.term.emit(this); - this.writeToOutput("()"); - } - } else { - target.emit(this); - this.recordSourceMappingStart(args); - this.writeToOutput("("); - this.emitCommaSeparatedList(args); - this.writeToOutput(")"); - this.recordSourceMappingEnd(args); - } - }; - - Emitter.prototype.getVarDeclFromIdentifier = function (boundDeclInfo) { - TypeScript.CompilerDiagnostics.assert(boundDeclInfo.boundDecl && boundDeclInfo.boundDecl.init && boundDeclInfo.boundDecl.init.nodeType === 20 /* Name */, "The init expression of bound declaration when emitting as constant has to be indentifier"); - - var init = boundDeclInfo.boundDecl.init; - var ident = init; - - this.setTypeCheckerUnit(this.document.fileName); - var pullSymbol = this.resolvingContext.resolvingTypeReference ? this.pullTypeChecker.resolver.resolveTypeNameExpression(ident, boundDeclInfo.pullDecl.getParentDecl(), this.resolvingContext).symbol : this.pullTypeChecker.resolver.resolveNameExpression(ident, boundDeclInfo.pullDecl.getParentDecl(), this.resolvingContext).symbol; - if (pullSymbol) { - var pullDecls = pullSymbol.getDeclarations(); - if (pullDecls.length === 1) { - var pullDecl = pullDecls[0]; - var ast = this.semanticInfoChain.getASTForDecl(pullDecl); - if (ast && ast.nodeType === 17 /* VariableDeclarator */) { - return { boundDecl: ast, pullDecl: pullDecl }; - } - } - } - - return null; - }; - - Emitter.prototype.getConstantValue = function (boundDeclInfo) { - var init = boundDeclInfo.boundDecl.init; - if (init) { - if (init.nodeType === 7 /* NumericLiteral */) { - var numLit = init; - return numLit.value; - } else if (init.nodeType === 69 /* LeftShiftExpression */) { - var binop = init; - if (binop.operand1.nodeType === 7 /* NumericLiteral */ && binop.operand2.nodeType === 7 /* NumericLiteral */) { - return (binop.operand1).value << (binop.operand2).value; - } - } else if (init.nodeType === 20 /* Name */) { - var varDeclInfo = this.getVarDeclFromIdentifier(boundDeclInfo); - if (varDeclInfo) { - return this.getConstantValue(varDeclInfo); - } - } - } - - return null; - }; - - Emitter.prototype.getConstantDecl = function (dotExpr) { - this.setTypeCheckerUnit(this.document.fileName); - var pullSymbol = this.pullTypeChecker.resolver.resolveDottedNameExpression(dotExpr, this.getEnclosingDecl(), this.resolvingContext).symbol; - if (pullSymbol && pullSymbol.hasFlag(524288 /* Constant */)) { - var pullDecls = pullSymbol.getDeclarations(); - if (pullDecls.length === 1) { - var pullDecl = pullDecls[0]; - var ast = this.semanticInfoChain.getASTForDecl(pullDecl); - if (ast && ast.nodeType === 17 /* VariableDeclarator */) { - return { boundDecl: ast, pullDecl: pullDecl }; - } - } - } - - return null; - }; - - Emitter.prototype.tryEmitConstant = function (dotExpr) { - if (!this.emitOptions.compilationSettings.propagateConstants) { - return false; - } - var propertyName = dotExpr.operand2; - var boundDeclInfo = this.getConstantDecl(dotExpr); - if (boundDeclInfo) { - var value = this.getConstantValue(boundDeclInfo); - if (value !== null) { - this.writeToOutput(value.toString()); - var comment = " /* "; - comment += propertyName.actualText; - comment += " */"; - this.writeToOutput(comment); - return true; - } - } - - return false; - }; - - Emitter.prototype.emitCall = function (callNode, target, args) { - if (!this.emitSuperCall(callNode)) { - if (target.nodeType === 12 /* FunctionDeclaration */) { - this.writeToOutput("("); - } - if (callNode.target.nodeType === 30 /* SuperExpression */ && this.emitState.container === 4 /* Constructor */) { - this.writeToOutput("_super.call"); - } else { - this.emitJavascript(target, false); - } - if (target.nodeType === 12 /* FunctionDeclaration */) { - this.writeToOutput(")"); - } - this.recordSourceMappingStart(args); - this.writeToOutput("("); - if (callNode.target.nodeType === 30 /* SuperExpression */ && this.emitState.container === 4 /* Constructor */) { - this.writeToOutput("this"); - if (args && args.members.length) { - this.writeToOutput(", "); - } - } - this.emitCommaSeparatedList(args); - this.writeToOutput(")"); - this.recordSourceMappingEnd(args); - } - }; - - Emitter.prototype.emitInnerFunction = function (funcDecl, printName, includePreComments) { - if (typeof includePreComments === "undefined") { includePreComments = true; } - var pullDecl = this.semanticInfoChain.getDeclForAST(funcDecl, this.document.fileName); - this.pushDecl(pullDecl); - - var shouldParenthesize = false; - - if (includePreComments) { - this.emitComments(funcDecl, true); - } - - if (shouldParenthesize) { - this.writeToOutput("("); - } - this.recordSourceMappingStart(funcDecl); - var accessorSymbol = funcDecl.isAccessor() ? TypeScript.PullHelpers.getAccessorSymbol(funcDecl, this.semanticInfoChain, this.document.fileName) : null; - var container = accessorSymbol ? accessorSymbol.getContainer() : null; - var containerKind = container ? container.getKind() : 0 /* None */; - if (!(funcDecl.isAccessor() && containerKind !== 8 /* Class */ && containerKind !== 33554432 /* ConstructorType */)) { - this.writeToOutput("function "); - } - - if (funcDecl.isConstructor) { - this.writeToOutput(this.thisClassNode.name.actualText); - } - - if (printName) { - var id = funcDecl.getNameText(); - if (id && !funcDecl.isAccessor()) { - if (funcDecl.name) { - this.recordSourceMappingStart(funcDecl.name); - } - this.writeToOutput(id); - if (funcDecl.name) { - this.recordSourceMappingEnd(funcDecl.name); - } - } - } - - this.writeToOutput("("); - var argsLen = 0; - if (funcDecl.arguments) { - this.emitComments(funcDecl.arguments, true); - - var tempContainer = this.setContainer(6 /* Args */); - argsLen = funcDecl.arguments.members.length; - var printLen = argsLen; - if (funcDecl.variableArgList) { - printLen--; - } - for (var i = 0; i < printLen; i++) { - var arg = funcDecl.arguments.members[i]; - arg.emit(this); - - if (i < (printLen - 1)) { - this.writeToOutput(", "); - } - } - this.setContainer(tempContainer); - - this.emitComments(funcDecl.arguments, false); - } - this.writeLineToOutput(") {"); - - if (funcDecl.isConstructor) { - this.recordSourceMappingNameStart("constructor"); - } else if (funcDecl.isGetAccessor()) { - this.recordSourceMappingNameStart("get_" + funcDecl.getNameText()); - } else if (funcDecl.isSetAccessor()) { - this.recordSourceMappingNameStart("set_" + funcDecl.getNameText()); - } else { - this.recordSourceMappingNameStart(funcDecl.getNameText()); - } - this.indenter.increaseIndent(); - - this.emitDefaultValueAssignments(funcDecl); - this.emitRestParameterInitializer(funcDecl); - - if (this.shouldCaptureThis(funcDecl)) { - this.writeCaptureThisStatement(funcDecl); - } - - if (funcDecl.isConstructor) { - this.emitConstructorStatements(funcDecl); - } else { - this.emitModuleElements(funcDecl.block.statements); - } - - this.indenter.decreaseIndent(); - this.emitIndent(); - this.recordSourceMappingStart(funcDecl.block.closeBraceSpan); - this.writeToOutput("}"); - - this.recordSourceMappingNameEnd(); - this.recordSourceMappingEnd(funcDecl.block.closeBraceSpan); - this.recordSourceMappingEnd(funcDecl); - - if (shouldParenthesize) { - this.writeToOutput(")"); - } - - this.recordSourceMappingEnd(funcDecl); - - this.emitComments(funcDecl, false); - - this.popDecl(pullDecl); - }; - - Emitter.prototype.emitDefaultValueAssignments = function (funcDecl) { - var n = funcDecl.arguments.members.length; - if (funcDecl.variableArgList) { - n--; - } - - for (var i = 0; i < n; i++) { - var arg = funcDecl.arguments.members[i]; - if (arg.init) { - this.emitIndent(); - this.recordSourceMappingStart(arg); - this.writeToOutput("if (typeof " + arg.id.actualText + " === \"undefined\") { "); - this.recordSourceMappingStart(arg.id); - this.writeToOutput(arg.id.actualText); - this.recordSourceMappingEnd(arg.id); - this.writeToOutput(" = "); - this.emitJavascript(arg.init, false); - this.writeLineToOutput("; }"); - this.recordSourceMappingEnd(arg); - } - } - }; - - Emitter.prototype.emitRestParameterInitializer = function (funcDecl) { - if (funcDecl.variableArgList) { - var n = funcDecl.arguments.members.length; - var lastArg = funcDecl.arguments.members[n - 1]; - this.emitIndent(); - this.recordSourceMappingStart(lastArg); - this.writeToOutput("var "); - this.recordSourceMappingStart(lastArg.id); - this.writeToOutput(lastArg.id.actualText); - this.recordSourceMappingEnd(lastArg.id); - this.writeLineToOutput(" = [];"); - this.recordSourceMappingEnd(lastArg); - this.emitIndent(); - this.writeToOutput("for ("); - this.recordSourceMappingStart(lastArg); - this.writeToOutput("var _i = 0;"); - this.recordSourceMappingEnd(lastArg); - this.writeToOutput(" "); - this.recordSourceMappingStart(lastArg); - this.writeToOutput("_i < (arguments.length - " + (n - 1) + ")"); - this.recordSourceMappingEnd(lastArg); - this.writeToOutput("; "); - this.recordSourceMappingStart(lastArg); - this.writeToOutput("_i++"); - this.recordSourceMappingEnd(lastArg); - this.writeLineToOutput(") {"); - this.indenter.increaseIndent(); - this.emitIndent(); - - this.recordSourceMappingStart(lastArg); - this.writeToOutput(lastArg.id.actualText + "[_i] = arguments[_i + " + (n - 1) + "];"); - this.recordSourceMappingEnd(lastArg); - this.writeLineToOutput(""); - this.indenter.decreaseIndent(); - this.emitIndent(); - this.writeLineToOutput("}"); - } - }; - - Emitter.prototype.getImportDecls = function (fileName) { - var semanticInfo = this.semanticInfoChain.getUnit(this.document.fileName); - var result = []; - - var queue = semanticInfo.getTopLevelDecls(); - - while (queue.length > 0) { - var decl = queue.shift(); - - if (decl.getKind() & 256 /* TypeAlias */) { - var importStatementAST = semanticInfo.getASTForDecl(decl); - if (importStatementAST.alias.nodeType === 20 /* Name */) { - var text = (importStatementAST.alias).actualText; - if (TypeScript.isQuoted(text)) { - var symbol = decl.getSymbol(); - var typeSymbol = symbol && symbol.getType(); - if (typeSymbol && typeSymbol !== this.semanticInfoChain.anyTypeSymbol && !typeSymbol.isError()) { - result.push(decl); - } - } - } - } - - queue = queue.concat(decl.getChildDecls()); - } - - return result; - }; - - Emitter.prototype.getModuleImportAndDependencyList = function (moduleDecl) { - var importList = ""; - var dependencyList = ""; - - var semanticInfo = this.semanticInfoChain.getUnit(this.document.fileName); - var importDecls = this.getImportDecls(this.document.fileName); - - if (importDecls.length) { - for (var i = 0; i < importDecls.length; i++) { - var importStatementDecl = importDecls[i]; - var importStatementSymbol = importStatementDecl.getSymbol(); - var importStatementAST = semanticInfo.getASTForDecl(importStatementDecl); - - if (importStatementSymbol.getIsUsedAsValue()) { - if (i <= importDecls.length - 1) { - dependencyList += ", "; - importList += ", "; - } - - importList += "__" + importStatementDecl.getName() + "__"; - dependencyList += importStatementAST.firstAliasedModToString(); - } - } - } - - for (var i = 0; i < moduleDecl.amdDependencies.length; i++) { - dependencyList += ", \"" + moduleDecl.amdDependencies[i] + "\""; - } - - return { - importList: importList, - dependencyList: dependencyList - }; - }; - - Emitter.prototype.shouldCaptureThis = function (ast) { - if (ast.nodeType === 2 /* Script */) { - var scriptDecl = this.semanticInfoChain.getUnit(this.document.fileName).getTopLevelDecls()[0]; - return (scriptDecl.getFlags() & 262144 /* MustCaptureThis */) === 262144 /* MustCaptureThis */; - } - - var decl = this.semanticInfoChain.getDeclForAST(ast, this.document.fileName); - if (decl) { - return (decl.getFlags() & 262144 /* MustCaptureThis */) === 262144 /* MustCaptureThis */; - } - - return false; - }; - - Emitter.prototype.emitModule = function (moduleDecl) { - var pullDecl = this.semanticInfoChain.getDeclForAST(moduleDecl, this.document.fileName); - this.pushDecl(pullDecl); - - var modName = moduleDecl.name.actualText; - if (TypeScript.isTSFile(modName)) { - moduleDecl.name.setText(modName.substring(0, modName.length - 3)); - } - - var isDynamicMod = TypeScript.hasFlag(moduleDecl.getModuleFlags(), 512 /* IsDynamic */); - var prevOutFile = this.outfile; - var prevOutFileName = this.emittingFileName; - var prevAllSourceMappers = this.allSourceMappers; - var prevSourceMapper = this.sourceMapper; - var prevColumn = this.emitState.column; - var prevLine = this.emitState.line; - var temp = this.setContainer(1 /* Module */); - var svModuleName = this.moduleName; - var isExported = TypeScript.hasFlag(moduleDecl.getModuleFlags(), 1 /* Exported */); - var isWholeFile = TypeScript.hasFlag(moduleDecl.getModuleFlags(), 256 /* IsWholeFile */); - this.moduleName = moduleDecl.name.actualText; - - if (isDynamicMod) { - this.setExportAssignmentIdentifier(null); - this.setContainer(2 /* DynamicModule */); - - this.recordSourceMappingStart(moduleDecl); - if (this.emitOptions.compilationSettings.moduleGenTarget === 1 /* Asynchronous */) { - var dependencyList = "[\"require\", \"exports\""; - var importList = "require, exports"; - - var importAndDependencyList = this.getModuleImportAndDependencyList(moduleDecl); - importList += importAndDependencyList.importList; - dependencyList += importAndDependencyList.dependencyList + "]"; - - this.writeLineToOutput("define(" + dependencyList + "," + " function(" + importList + ") {"); - } - } else { - if (!isExported) { - this.recordSourceMappingStart(moduleDecl); - this.writeToOutput("var "); - this.recordSourceMappingStart(moduleDecl.name); - this.writeToOutput(this.moduleName); - this.recordSourceMappingEnd(moduleDecl.name); - this.writeLineToOutput(";"); - this.recordSourceMappingEnd(moduleDecl); - this.emitIndent(); - } - - this.writeToOutput("("); - this.recordSourceMappingStart(moduleDecl); - this.writeToOutput("function ("); - this.recordSourceMappingStart(moduleDecl.name); - this.writeToOutput(this.moduleName); - this.recordSourceMappingEnd(moduleDecl.name); - this.writeLineToOutput(") {"); - } - - if (!isWholeFile) { - this.recordSourceMappingNameStart(this.moduleName); - } - - if (!isDynamicMod || this.emitOptions.compilationSettings.moduleGenTarget === 1 /* Asynchronous */) { - this.indenter.increaseIndent(); - } - - if (this.shouldCaptureThis(moduleDecl)) { - this.writeCaptureThisStatement(moduleDecl); - } - - this.emitModuleElements(moduleDecl.members); - if (!isDynamicMod || this.emitOptions.compilationSettings.moduleGenTarget === 1 /* Asynchronous */) { - this.indenter.decreaseIndent(); - } - this.emitIndent(); - - if (isDynamicMod) { - var exportAssignmentIdentifier = this.getExportAssignmentIdentifier(); - var exportAssignmentValueSymbol = (pullDecl.getSymbol()).getExportAssignedValueSymbol(); - - if (this.emitOptions.compilationSettings.moduleGenTarget === 1 /* Asynchronous */) { - if (exportAssignmentIdentifier && exportAssignmentValueSymbol && !(exportAssignmentValueSymbol.getKind() & TypeScript.PullElementKind.SomeTypeReference)) { - this.indenter.increaseIndent(); - this.emitIndent(); - this.writeLineToOutput("return " + exportAssignmentIdentifier + ";"); - this.indenter.decreaseIndent(); - } - this.writeToOutput("});"); - } else if (exportAssignmentIdentifier && exportAssignmentValueSymbol && !(exportAssignmentValueSymbol.getKind() & TypeScript.PullElementKind.SomeTypeReference)) { - this.emitIndent(); - this.writeLineToOutput("module.exports = " + exportAssignmentIdentifier + ";"); - } - - if (!isWholeFile) { - this.recordSourceMappingNameEnd(); - } - this.recordSourceMappingEnd(moduleDecl); - - if (this.outfile !== prevOutFile) { - this.emitSourceMapsAndClose(); - if (prevSourceMapper !== null) { - this.allSourceMappers = prevAllSourceMappers; - this.sourceMapper = prevSourceMapper; - this.emitState.column = prevColumn; - this.emitState.line = prevLine; - } - this.outfile = prevOutFile; - this.emittingFileName = prevOutFileName; - } - } else { - var parentIsDynamic = temp === 2 /* DynamicModule */; - this.recordSourceMappingStart(moduleDecl.endingToken); - if (temp === 0 /* Prog */ && isExported) { - this.writeToOutput("}"); - if (!isWholeFile) { - this.recordSourceMappingNameEnd(); - } - this.recordSourceMappingEnd(moduleDecl.endingToken); - this.writeToOutput(")(this." + this.moduleName + " || (this." + this.moduleName + " = {}));"); - } else if (isExported || temp === 0 /* Prog */) { - var dotMod = svModuleName !== "" ? (parentIsDynamic ? "exports" : svModuleName) + "." : svModuleName; - this.writeToOutput("}"); - if (!isWholeFile) { - this.recordSourceMappingNameEnd(); - } - this.recordSourceMappingEnd(moduleDecl.endingToken); - this.writeToOutput(")(" + dotMod + this.moduleName + " || (" + dotMod + this.moduleName + " = {}));"); - } else if (!isExported && temp !== 0 /* Prog */) { - this.writeToOutput("}"); - if (!isWholeFile) { - this.recordSourceMappingNameEnd(); - } - this.recordSourceMappingEnd(moduleDecl.endingToken); - this.writeToOutput(")(" + this.moduleName + " || (" + this.moduleName + " = {}));"); - } else { - this.writeToOutput("}"); - if (!isWholeFile) { - this.recordSourceMappingNameEnd(); - } - this.recordSourceMappingEnd(moduleDecl.endingToken); - this.writeToOutput(")();"); - } - - this.recordSourceMappingEnd(moduleDecl); - if (temp !== 0 /* Prog */ && isExported) { - this.recordSourceMappingStart(moduleDecl); - if (parentIsDynamic) { - this.writeLineToOutput(""); - this.emitIndent(); - this.writeToOutput("var " + this.moduleName + " = exports." + this.moduleName + ";"); - } else { - this.writeLineToOutput(""); - this.emitIndent(); - this.writeToOutput("var " + this.moduleName + " = " + svModuleName + "." + this.moduleName + ";"); - } - this.recordSourceMappingEnd(moduleDecl); - } - } - - this.setContainer(temp); - this.moduleName = svModuleName; - - this.popDecl(pullDecl); - }; - - Emitter.prototype.emitEnumElement = function (varDecl) { - this.writeToOutput(this.moduleName); - this.writeToOutput('['); - this.writeToOutput(this.moduleName); - this.writeToOutput('["'); - this.writeToOutput(varDecl.id.text); - this.writeToOutput('"] = '); - varDecl.init.emit(this); - this.writeToOutput('] = "'); - this.writeToOutput(varDecl.id.text); - this.writeToOutput('";'); - }; - - Emitter.prototype.emitIndex = function (operand1, operand2) { - operand1.emit(this); - this.writeToOutput("["); - operand2.emit(this); - this.writeToOutput("]"); - }; - - Emitter.prototype.emitFunction = function (funcDecl) { - if (TypeScript.hasFlag(funcDecl.getFunctionFlags(), 128 /* Signature */)) { - return; - } - var temp; - var tempFnc = this.thisFunctionDeclaration; - this.thisFunctionDeclaration = funcDecl; - - if (funcDecl.isConstructor) { - temp = this.setContainer(4 /* Constructor */); - } else { - temp = this.setContainer(5 /* Function */); - } - - var funcName = funcDecl.getNameText(); - - if (((temp !== 4 /* Constructor */) || ((funcDecl.getFunctionFlags() & 256 /* Method */) === 0 /* None */))) { - this.recordSourceMappingStart(funcDecl); - this.emitInnerFunction(funcDecl, (funcDecl.name && !funcDecl.name.isMissing())); - } - this.setContainer(temp); - this.thisFunctionDeclaration = tempFnc; - - if (!TypeScript.hasFlag(funcDecl.getFunctionFlags(), 128 /* Signature */)) { - if (TypeScript.hasFlag(funcDecl.getFunctionFlags(), 16 /* Static */)) { - if (this.thisClassNode) { - this.writeLineToOutput(""); - if (funcDecl.isAccessor()) { - this.emitPropertyAccessor(funcDecl, this.thisClassNode.name.actualText, false); - } else { - this.emitIndent(); - this.recordSourceMappingStart(funcDecl); - this.writeToOutput(this.thisClassNode.name.actualText + "." + funcName + " = " + funcName + ";"); - this.recordSourceMappingEnd(funcDecl); - } - } - } else if ((this.emitState.container === 1 /* Module */ || this.emitState.container === 2 /* DynamicModule */) && TypeScript.hasFlag(funcDecl.getFunctionFlags(), 1 /* Exported */)) { - this.writeLineToOutput(""); - this.emitIndent(); - var modName = this.emitState.container === 1 /* Module */ ? this.moduleName : "exports"; - this.recordSourceMappingStart(funcDecl); - this.writeToOutput(modName + "." + funcName + " = " + funcName + ";"); - this.recordSourceMappingEnd(funcDecl); - } - } - }; - - Emitter.prototype.emitAmbientVarDecl = function (varDecl) { - if (varDecl.init) { - this.emitComments(varDecl, true); - this.recordSourceMappingStart(varDecl); - this.recordSourceMappingStart(varDecl.id); - this.writeToOutput(varDecl.id.actualText); - this.recordSourceMappingEnd(varDecl.id); - this.writeToOutput(" = "); - this.emitJavascript(varDecl.init, false); - this.recordSourceMappingEnd(varDecl); - this.emitComments(varDecl, false); - } - }; - - Emitter.prototype.varListCount = function () { - return this.varListCountStack[this.varListCountStack.length - 1]; - }; - - Emitter.prototype.emitVarDeclVar = function () { - if (this.varListCount() >= 0) { - this.writeToOutput("var "); - this.setInVarBlock(-this.varListCount()); - } - return true; - }; - - Emitter.prototype.onEmitVar = function () { - if (this.varListCount() > 0) { - this.setInVarBlock(this.varListCount() - 1); - } else if (this.varListCount() < 0) { - this.setInVarBlock(this.varListCount() + 1); - } - }; - - Emitter.prototype.emitVariableDeclaration = function (declaration) { - var varDecl = declaration.declarators.members[0]; - - var symbolAndDiagnostics = this.semanticInfoChain.getSymbolAndDiagnosticsForAST(varDecl, this.document.fileName); - var symbol = symbolAndDiagnostics && symbolAndDiagnostics.symbol; - - var parentSymbol = symbol ? symbol.getContainer() : null; - var parentKind = parentSymbol ? parentSymbol.getKind() : 0 /* None */; - var inClass = parentKind === 8 /* Class */; - - this.emitComments(declaration, true); - this.recordSourceMappingStart(declaration); - this.setInVarBlock(declaration.declarators.members.length); - - var isAmbientWithoutInit = TypeScript.hasFlag(varDecl.getVarFlags(), 8 /* Ambient */) && varDecl.init === null; - if (!isAmbientWithoutInit) { - for (var i = 0, n = declaration.declarators.members.length; i < n; i++) { - var declarator = declaration.declarators.members[i]; - - if (i > 0) { - if (inClass) { - this.writeToOutputTrimmable(";"); - } else { - this.writeToOutputTrimmable(", "); - } - } - - declarator.emit(this); - } - } - - this.recordSourceMappingEnd(declaration); - this.emitComments(declaration, false); - }; - - Emitter.prototype.emitVariableDeclarator = function (varDecl) { - var pullDecl = this.semanticInfoChain.getDeclForAST(varDecl, this.document.fileName); - this.pushDecl(pullDecl); - if ((varDecl.getVarFlags() & 8 /* Ambient */) === 8 /* Ambient */) { - this.emitAmbientVarDecl(varDecl); - this.onEmitVar(); - } else { - this.emitComments(varDecl, true); - this.recordSourceMappingStart(varDecl); - - var symbolAndDiagnostics = this.semanticInfoChain.getSymbolAndDiagnosticsForAST(varDecl, this.document.fileName); - var symbol = symbolAndDiagnostics && symbolAndDiagnostics.symbol; - var parentSymbol = symbol ? symbol.getContainer() : null; - var parentKind = parentSymbol ? parentSymbol.getKind() : 0 /* None */; - var associatedParentSymbol = parentSymbol ? parentSymbol.getAssociatedContainerType() : null; - var associatedParentSymbolKind = associatedParentSymbol ? associatedParentSymbol.getKind() : 0 /* None */; - if (parentKind === 8 /* Class */) { - if (this.emitState.container !== 6 /* Args */) { - if (varDecl.isStatic()) { - this.writeToOutput(parentSymbol.getName() + "."); - } else { - this.writeToOutput("this."); - } - } - } else if (parentKind === 64 /* Enum */ || parentKind === 32 /* DynamicModule */ || associatedParentSymbolKind === 4 /* Container */ || associatedParentSymbolKind === 32 /* DynamicModule */ || associatedParentSymbolKind === 64 /* Enum */) { - if (!varDecl.isExported() && !varDecl.isProperty()) { - this.emitVarDeclVar(); - } else { - if (this.emitState.container === 2 /* DynamicModule */) { - this.writeToOutput("exports."); - } else { - this.writeToOutput(this.moduleName + "."); - } - } - } else { - this.emitVarDeclVar(); - } - - this.recordSourceMappingStart(varDecl.id); - this.writeToOutput(varDecl.id.actualText); - this.recordSourceMappingEnd(varDecl.id); - var hasInitializer = (varDecl.init !== null); - if (hasInitializer) { - this.writeToOutputTrimmable(" = "); - - this.varListCountStack.push(0); - varDecl.init.emit(this); - this.varListCountStack.pop(); - } - - if (parentKind === 8 /* Class */) { - if (this.emitState.container !== 6 /* Args */) { - this.writeToOutput(";"); - } - } - - this.onEmitVar(); - - this.recordSourceMappingEnd(varDecl); - this.emitComments(varDecl, false); - } - this.popDecl(pullDecl); - }; - - Emitter.prototype.symbolIsUsedInItsEnclosingContainer = function (symbol, dynamic) { - if (typeof dynamic === "undefined") { dynamic = false; } - var symDecls = symbol.getDeclarations(); - - if (symDecls.length) { - var enclosingDecl = this.getEnclosingDecl(); - if (enclosingDecl) { - var parentDecl = symDecls[0].getParentDecl(); - if (parentDecl) { - var symbolDeclarationEnclosingContainer = parentDecl; - var enclosingContainer = enclosingDecl; - - while (symbolDeclarationEnclosingContainer) { - if (symbolDeclarationEnclosingContainer.getKind() === (dynamic ? 32 /* DynamicModule */ : 4 /* Container */)) { - break; - } - symbolDeclarationEnclosingContainer = symbolDeclarationEnclosingContainer.getParentDecl(); - } - - if (symbolDeclarationEnclosingContainer) { - while (enclosingContainer) { - if (enclosingContainer.getKind() === (dynamic ? 32 /* DynamicModule */ : 4 /* Container */)) { - break; - } - - enclosingContainer = enclosingContainer.getParentDecl(); - } - } - - if (symbolDeclarationEnclosingContainer && enclosingContainer) { - var same = symbolDeclarationEnclosingContainer === enclosingContainer; - - if (!same && symbol.hasFlag(32768 /* InitializedModule */)) { - same = symbolDeclarationEnclosingContainer === enclosingContainer.getParentDecl(); - } - - return same; - } - } - } - } - - return false; - }; - - Emitter.prototype.emitName = function (name, addThis) { - this.emitComments(name, true); - this.recordSourceMappingStart(name); - if (!name.isMissing()) { - this.setTypeCheckerUnit(this.document.fileName); - var pullSymbolAndDiagnostics = this.resolvingContext.resolvingTypeReference ? this.pullTypeChecker.resolver.resolveTypeNameExpression(name, this.getEnclosingDecl(), this.resolvingContext) : this.pullTypeChecker.resolver.resolveNameExpression(name, this.getEnclosingDecl(), this.resolvingContext); - var pullSymbol = pullSymbolAndDiagnostics.symbol; - var pullSymbolAlias = pullSymbolAndDiagnostics.symbolAlias; - var pullSymbolKind = pullSymbol.getKind(); - var isLocalAlias = pullSymbolAlias && (pullSymbolAlias.getDeclarations()[0].getParentDecl() == this.getEnclosingDecl()); - if (addThis && (this.emitState.container !== 6 /* Args */) && pullSymbol) { - var pullSymbolContainer = pullSymbol.getContainer(); - - if (pullSymbolContainer) { - var pullSymbolContainerKind = pullSymbolContainer.getKind(); - - if (pullSymbolContainerKind === 8 /* Class */) { - if (pullSymbol.hasFlag(16 /* Static */)) { - this.writeToOutput(pullSymbolContainer.getName() + "."); - } else if (pullSymbolKind === 4096 /* Property */) { - this.emitThis(); - this.writeToOutput("."); - } - } else if (pullSymbolContainerKind === 4 /* Container */ || pullSymbolContainerKind === 64 /* Enum */ || pullSymbolContainer.hasFlag(32768 /* InitializedModule */ | 131072 /* InitializedEnum */)) { - if (pullSymbolKind === 4096 /* Property */ || pullSymbolKind === 67108864 /* EnumMember */) { - this.writeToOutput(pullSymbolContainer.getName() + "."); - } else if (pullSymbol.hasFlag(1 /* Exported */) && pullSymbolKind === 1024 /* Variable */ && !pullSymbol.hasFlag(32768 /* InitializedModule */ | 131072 /* InitializedEnum */)) { - this.writeToOutput(pullSymbolContainer.getName() + "."); - } else if (pullSymbol.hasFlag(1 /* Exported */) && !this.symbolIsUsedInItsEnclosingContainer(pullSymbol)) { - this.writeToOutput(pullSymbolContainer.getName() + "."); - } - } else if (pullSymbolContainerKind === 32 /* DynamicModule */ || pullSymbolContainer.hasFlag(65536 /* InitializedDynamicModule */)) { - if (pullSymbolKind === 4096 /* Property */) { - this.writeToOutput("exports."); - } else if (pullSymbol.hasFlag(1 /* Exported */) && !isLocalAlias && !pullSymbol.hasFlag(TypeScript.PullElementFlags.ImplicitVariable) && pullSymbol.getKind() !== 32768 /* ConstructorMethod */ && pullSymbol.getKind() !== 8 /* Class */ && pullSymbol.getKind() !== 64 /* Enum */) { - this.writeToOutput("exports."); - } - } else if (pullSymbolKind === 4096 /* Property */) { - if (pullSymbolContainer.getKind() === 8 /* Class */) { - this.emitThis(); - this.writeToOutput("."); - } - } else { - var pullDecls = pullSymbol.getDeclarations(); - var emitContainerName = true; - for (var i = 0; i < pullDecls.length; i++) { - if (pullDecls[i].getScriptName() === this.document.fileName) { - emitContainerName = false; - } - } - if (emitContainerName) { - this.writeToOutput(pullSymbolContainer.getName() + "."); - } - } - } - } - - if (pullSymbol && pullSymbolKind === 32 /* DynamicModule */) { - if (this.emitOptions.compilationSettings.moduleGenTarget === 1 /* Asynchronous */) { - this.writeToOutput("__" + this.modAliasId + "__"); - } else { - var moduleDecl = this.semanticInfoChain.getASTForSymbol(pullSymbol, this.document.fileName); - var modPath = name.actualText; - var isAmbient = pullSymbol.hasFlag(8 /* Ambient */); - modPath = isAmbient ? modPath : this.firstModAlias ? this.firstModAlias : TypeScript.quoteBaseName(modPath); - modPath = isAmbient ? modPath : (!TypeScript.isRelative(TypeScript.stripQuotes(modPath)) ? TypeScript.quoteStr("./" + TypeScript.stripQuotes(modPath)) : modPath); - this.writeToOutput("require(" + modPath + ")"); - } - } else { - this.writeToOutput(name.actualText); - } - } - - this.recordSourceMappingEnd(name); - this.emitComments(name, false); - }; - - Emitter.prototype.recordSourceMappingNameStart = function (name) { - if (this.sourceMapper) { - var finalName = name; - if (!name) { - finalName = ""; - } else if (this.sourceMapper.currentNameIndex.length > 0) { - finalName = this.sourceMapper.names[this.sourceMapper.currentNameIndex[this.sourceMapper.currentNameIndex.length - 1]] + "." + name; - } - - this.sourceMapper.names.push(finalName); - this.sourceMapper.currentNameIndex.push(this.sourceMapper.names.length - 1); - } - }; - - Emitter.prototype.recordSourceMappingNameEnd = function () { - if (this.sourceMapper) { - this.sourceMapper.currentNameIndex.pop(); - } - }; - - Emitter.prototype.recordSourceMappingStart = function (ast) { - if (this.sourceMapper && TypeScript.isValidAstNode(ast)) { - var lineCol = { line: -1, character: -1 }; - var sourceMapping = new TypeScript.SourceMapping(); - sourceMapping.start.emittedColumn = this.emitState.column; - sourceMapping.start.emittedLine = this.emitState.line; - - var lineMap = this.document.lineMap; - lineMap.fillLineAndCharacterFromPosition(ast.minChar, lineCol); - sourceMapping.start.sourceColumn = lineCol.character; - sourceMapping.start.sourceLine = lineCol.line + 1; - lineMap.fillLineAndCharacterFromPosition(ast.limChar, lineCol); - sourceMapping.end.sourceColumn = lineCol.character; - sourceMapping.end.sourceLine = lineCol.line + 1; - if (this.sourceMapper.currentNameIndex.length > 0) { - sourceMapping.nameIndex = this.sourceMapper.currentNameIndex[this.sourceMapper.currentNameIndex.length - 1]; - } - - var siblings = this.sourceMapper.currentMappings[this.sourceMapper.currentMappings.length - 1]; - siblings.push(sourceMapping); - this.sourceMapper.currentMappings.push(sourceMapping.childMappings); - } - }; - - Emitter.prototype.recordSourceMappingEnd = function (ast) { - if (this.sourceMapper && TypeScript.isValidAstNode(ast)) { - this.sourceMapper.currentMappings.pop(); - - var siblings = this.sourceMapper.currentMappings[this.sourceMapper.currentMappings.length - 1]; - var sourceMapping = siblings[siblings.length - 1]; - - sourceMapping.end.emittedColumn = this.emitState.column; - sourceMapping.end.emittedLine = this.emitState.line; - } - }; - - Emitter.prototype.emitSourceMapsAndClose = function () { - if (this.sourceMapper !== null) { - TypeScript.SourceMapper.emitSourceMapping(this.allSourceMappers); - } - - try { - this.outfile.Close(); - } catch (e) { - Emitter.throwEmitterError(e); - } - }; - - Emitter.prototype.emitParameterPropertyAndMemberVariableAssignments = function () { - var constructorDecl = this.thisClassNode.constructorDecl; - - if (constructorDecl && constructorDecl.arguments) { - for (var i = 0, n = constructorDecl.arguments.members.length; i < n; i++) { - var arg = constructorDecl.arguments.members[i]; - if ((arg.getVarFlags() & 256 /* Property */) !== 0 /* None */) { - this.emitIndent(); - this.recordSourceMappingStart(arg); - this.recordSourceMappingStart(arg.id); - this.writeToOutput("this." + arg.id.actualText); - this.recordSourceMappingEnd(arg.id); - this.writeToOutput(" = "); - this.recordSourceMappingStart(arg.id); - this.writeToOutput(arg.id.actualText); - this.recordSourceMappingEnd(arg.id); - this.writeLineToOutput(";"); - this.recordSourceMappingEnd(arg); - } - } - } - - for (var i = 0, n = this.thisClassNode.members.members.length; i < n; i++) { - if (this.thisClassNode.members.members[i].nodeType === 17 /* VariableDeclarator */) { - var varDecl = this.thisClassNode.members.members[i]; - if (!TypeScript.hasFlag(varDecl.getVarFlags(), 16 /* Static */) && varDecl.init) { - this.emitIndent(); - this.emitVariableDeclarator(varDecl); - this.writeLineToOutput(""); - } - } - } - }; - - Emitter.prototype.emitCommaSeparatedList = function (list, startLine) { - if (typeof startLine === "undefined") { startLine = false; } - if (list === null) { - return; - } else { - for (var i = 0, n = list.members.length; i < n; i++) { - var emitNode = list.members[i]; - this.emitJavascript(emitNode, startLine); - - if (i < (n - 1)) { - this.writeToOutput(startLine ? "," : ", "); - } - - if (startLine) { - this.writeLineToOutput(""); - } - } - } - }; - - Emitter.prototype.emitModuleElements = function (list) { - if (list === null) { - return; - } - - this.emitComments(list, true); - var lastEmittedNode = null; - - for (var i = 0, n = list.members.length; i < n; i++) { - var node = list.members[i]; - - if (node.shouldEmit()) { - this.emitSpaceBetweenConstructs(lastEmittedNode, node); - - this.emitJavascript(node, true); - this.writeLineToOutput(""); - - lastEmittedNode = node; - } - } - - this.emitComments(list, false); - }; - - Emitter.prototype.isDirectivePrologueElement = function (node) { - if (node.nodeType === 88 /* ExpressionStatement */) { - var exprStatement = node; - return exprStatement.expression.nodeType === 5 /* StringLiteral */; - } - - return false; - }; - - Emitter.prototype.emitSpaceBetweenConstructs = function (node1, node2) { - if (node1 === null || node2 === null) { - return; - } - - if (node1.minChar === -1 || node1.limChar === -1 || node2.minChar === -1 || node2.limChar === -1) { - return; - } - - var lineMap = this.document.lineMap; - var node1EndLine = lineMap.getLineNumberFromPosition(node1.limChar); - var node2StartLine = lineMap.getLineNumberFromPosition(node2.minChar); - - if ((node2StartLine - node1EndLine) > 1) { - this.writeLineToOutput(""); - } - }; - - Emitter.prototype.emitScriptElements = function (script, requiresExtendsBlock) { - var list = script.moduleElements; - this.emitComments(list, true); - - for (var i = 0, n = list.members.length; i < n; i++) { - var node = list.members[i]; - - if (!this.isDirectivePrologueElement(node)) { - break; - } - - this.emitJavascript(node, true); - this.writeLineToOutput(""); - } - - this.emitPrologue(script, requiresExtendsBlock); - var lastEmittedNode = null; - - for (; i < n; i++) { - var node = list.members[i]; - - if (node.shouldEmit()) { - this.emitSpaceBetweenConstructs(lastEmittedNode, node); - - this.emitJavascript(node, true); - this.writeLineToOutput(""); - - lastEmittedNode = node; - } - } - - this.emitComments(list, false); - }; - - Emitter.prototype.emitConstructorStatements = function (funcDecl) { - var list = funcDecl.block.statements; - - if (list === null) { - return; - } - - this.emitComments(list, true); - - var emitPropertyAssignmentsAfterSuperCall = this.thisClassNode.extendsList && this.thisClassNode.extendsList.members.length > 0; - var propertyAssignmentIndex = emitPropertyAssignmentsAfterSuperCall ? 1 : 0; - var lastEmittedNode = null; - - for (var i = 0, n = list.members.length; i < n; i++) { - if (i === propertyAssignmentIndex) { - this.emitParameterPropertyAndMemberVariableAssignments(); - } - - var node = list.members[i]; - - if (node.shouldEmit()) { - this.emitSpaceBetweenConstructs(lastEmittedNode, node); - - this.emitJavascript(node, true); - this.writeLineToOutput(""); - - lastEmittedNode = node; - } - } - - if (i === propertyAssignmentIndex) { - this.emitParameterPropertyAndMemberVariableAssignments(); - } - - this.emitComments(list, false); - }; - - Emitter.prototype.emitJavascript = function (ast, startLine) { - if (ast === null) { - return; - } - - if (startLine && this.indenter.indentAmt > 0) { - this.emitIndent(); - } - - ast.emit(this); - }; - - Emitter.prototype.emitPropertyAccessor = function (funcDecl, className, isProto) { - if (!TypeScript.hasFlag(funcDecl.getFunctionFlags(), 32 /* GetAccessor */)) { - var accessorSymbol = TypeScript.PullHelpers.getAccessorSymbol(funcDecl, this.semanticInfoChain, this.document.fileName); - if (accessorSymbol.getGetter()) { - return; - } - } - - this.emitIndent(); - this.recordSourceMappingStart(funcDecl); - this.writeLineToOutput("Object.defineProperty(" + className + (isProto ? ".prototype, \"" : ", \"") + funcDecl.name.actualText + "\"" + ", {"); - this.indenter.increaseIndent(); - - var accessors = TypeScript.PullHelpers.getGetterAndSetterFunction(funcDecl, this.semanticInfoChain, this.document.fileName); - if (accessors.getter) { - this.emitIndent(); - this.recordSourceMappingStart(accessors.getter); - this.writeToOutput("get: "); - this.emitInnerFunction(accessors.getter, false); - this.writeLineToOutput(","); - } - - if (accessors.setter) { - this.emitIndent(); - this.recordSourceMappingStart(accessors.setter); - this.writeToOutput("set: "); - this.emitInnerFunction(accessors.setter, false); - this.writeLineToOutput(","); - } - - this.emitIndent(); - this.writeLineToOutput("enumerable: true,"); - this.emitIndent(); - this.writeLineToOutput("configurable: true"); - this.indenter.decreaseIndent(); - this.emitIndent(); - this.writeLineToOutput("});"); - this.recordSourceMappingEnd(funcDecl); - }; - - Emitter.prototype.emitPrototypeMember = function (funcDecl, className) { - if (funcDecl.isAccessor()) { - this.emitPropertyAccessor(funcDecl, className, true); - } else { - this.emitIndent(); - this.recordSourceMappingStart(funcDecl); - this.emitComments(funcDecl, true); - this.writeToOutput(className + ".prototype." + funcDecl.getNameText() + " = "); - this.emitInnerFunction(funcDecl, false, false); - this.writeLineToOutput(";"); - } - }; - - Emitter.prototype.emitClass = function (classDecl) { - var pullDecl = this.semanticInfoChain.getDeclForAST(classDecl, this.document.fileName); - this.pushDecl(pullDecl); - - var svClassNode = this.thisClassNode; - this.thisClassNode = classDecl; - var className = classDecl.name.actualText; - this.emitComments(classDecl, true); - var temp = this.setContainer(3 /* Class */); - - this.recordSourceMappingStart(classDecl); - this.writeToOutput("var " + className); - - var hasBaseClass = classDecl.extendsList && classDecl.extendsList.members.length; - var baseNameDecl = null; - var baseName = null; - var varDecl = null; - - if (hasBaseClass) { - this.writeLineToOutput(" = (function (_super) {"); - } else { - this.writeLineToOutput(" = (function () {"); - } - - this.recordSourceMappingNameStart(className); - this.indenter.increaseIndent(); - - if (hasBaseClass) { - baseNameDecl = classDecl.extendsList.members[0]; - baseName = baseNameDecl.nodeType === 36 /* InvocationExpression */ ? (baseNameDecl).target : baseNameDecl; - this.emitIndent(); - this.writeLineToOutput("__extends(" + className + ", _super);"); - } - - this.emitIndent(); - - var constrDecl = classDecl.constructorDecl; - - if (constrDecl) { - constrDecl.emit(this); - this.writeLineToOutput(""); - } else { - this.recordSourceMappingStart(classDecl); - - this.indenter.increaseIndent(); - this.writeLineToOutput("function " + classDecl.name.actualText + "() {"); - this.recordSourceMappingNameStart("constructor"); - if (hasBaseClass) { - this.emitIndent(); - this.writeLineToOutput("_super.apply(this, arguments);"); - } - - this.emitParameterPropertyAndMemberVariableAssignments(); - - this.indenter.decreaseIndent(); - this.emitIndent(); - this.writeLineToOutput("}"); - - this.recordSourceMappingNameEnd(); - this.recordSourceMappingEnd(classDecl); - } - - this.emitClassMembers(classDecl); - - this.emitIndent(); - this.recordSourceMappingStart(classDecl.endingToken); - this.writeLineToOutput("return " + className + ";"); - this.recordSourceMappingEnd(classDecl.endingToken); - this.indenter.decreaseIndent(); - this.emitIndent(); - this.recordSourceMappingStart(classDecl.endingToken); - this.writeToOutput("}"); - this.recordSourceMappingNameEnd(); - this.recordSourceMappingEnd(classDecl.endingToken); - this.recordSourceMappingStart(classDecl); - this.writeToOutput(")("); - if (hasBaseClass) { - this.resolvingContext.resolvingTypeReference = true; - this.emitJavascript(baseName, false); - this.resolvingContext.resolvingTypeReference = false; - } - this.writeToOutput(");"); - this.recordSourceMappingEnd(classDecl); - - if ((temp === 1 /* Module */ || temp === 2 /* DynamicModule */) && TypeScript.hasFlag(classDecl.getVarFlags(), 1 /* Exported */)) { - this.writeLineToOutput(""); - this.emitIndent(); - var modName = temp === 1 /* Module */ ? this.moduleName : "exports"; - this.recordSourceMappingStart(classDecl); - this.writeToOutput(modName + "." + className + " = " + className + ";"); - this.recordSourceMappingEnd(classDecl); - } - - this.recordSourceMappingEnd(classDecl); - this.emitComments(classDecl, false); - this.setContainer(temp); - this.thisClassNode = svClassNode; - - this.popDecl(pullDecl); - }; - - Emitter.prototype.emitClassMembers = function (classDecl) { - var lastEmittedMember = null; - - for (var i = 0, n = classDecl.members.members.length; i < n; i++) { - var memberDecl = classDecl.members.members[i]; - - if (memberDecl.nodeType === 12 /* FunctionDeclaration */) { - var fn = memberDecl; - - if (TypeScript.hasFlag(fn.getFunctionFlags(), 256 /* Method */) && !fn.isSignature()) { - this.emitSpaceBetweenConstructs(lastEmittedMember, fn); - - if (!TypeScript.hasFlag(fn.getFunctionFlags(), 16 /* Static */)) { - this.emitPrototypeMember(fn, classDecl.name.actualText); - } else { - if (fn.isAccessor()) { - this.emitPropertyAccessor(fn, this.thisClassNode.name.actualText, false); - } else { - this.emitIndent(); - this.recordSourceMappingStart(fn); - this.writeToOutput(classDecl.name.actualText + "." + fn.name.actualText + " = "); - this.emitInnerFunction(fn, false); - this.writeLineToOutput(";"); - } - } - - lastEmittedMember = fn; - } - } - } - - for (var i = 0, n = classDecl.members.members.length; i < n; i++) { - var memberDecl = classDecl.members.members[i]; - - if (memberDecl.nodeType === 17 /* VariableDeclarator */) { - var varDecl = memberDecl; - - if (TypeScript.hasFlag(varDecl.getVarFlags(), 16 /* Static */) && varDecl.init) { - this.emitSpaceBetweenConstructs(lastEmittedMember, varDecl); - - this.emitIndent(); - this.recordSourceMappingStart(varDecl); - this.writeToOutput(classDecl.name.actualText + "." + varDecl.id.actualText + " = "); - varDecl.init.emit(this); - - this.writeLineToOutput(";"); - this.recordSourceMappingEnd(varDecl); - - lastEmittedMember = varDecl; - } - } - } - }; - - Emitter.prototype.emitPrologue = function (script, requiresExtendsBlock) { - if (!this.extendsPrologueEmitted) { - if (requiresExtendsBlock) { - this.extendsPrologueEmitted = true; - this.writeLineToOutput("var __extends = this.__extends || function (d, b) {"); - this.writeLineToOutput(" for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];"); - this.writeLineToOutput(" function __() { this.constructor = d; }"); - this.writeLineToOutput(" __.prototype = b.prototype;"); - this.writeLineToOutput(" d.prototype = new __();"); - this.writeLineToOutput("};"); - } - } - - if (!this.globalThisCapturePrologueEmitted) { - if (this.shouldCaptureThis(script)) { - this.globalThisCapturePrologueEmitted = true; - this.writeLineToOutput(this.captureThisStmtString); - } - } - }; - - Emitter.prototype.emitSuperReference = function () { - this.writeToOutput("_super.prototype"); - }; - - Emitter.prototype.emitSuperCall = function (callEx) { - if (callEx.target.nodeType === 32 /* MemberAccessExpression */) { - var dotNode = callEx.target; - if (dotNode.operand1.nodeType === 30 /* SuperExpression */) { - dotNode.emit(this); - this.writeToOutput(".call("); - this.emitThis(); - if (callEx.arguments && callEx.arguments.members.length > 0) { - this.writeToOutput(", "); - this.emitCommaSeparatedList(callEx.arguments); - } - this.writeToOutput(")"); - return true; - } - } - return false; - }; - - Emitter.prototype.emitThis = function () { - if (this.thisFunctionDeclaration && !this.thisFunctionDeclaration.isMethod() && (!this.thisFunctionDeclaration.isConstructor)) { - this.writeToOutput("_this"); - } else { - this.writeToOutput("this"); - } - }; - - Emitter.prototype.emitBlockOrStatement = function (node) { - if (node.nodeType === 81 /* Block */) { - node.emit(this); - } else { - this.writeLineToOutput(""); - this.indenter.increaseIndent(); - this.emitJavascript(node, true); - this.indenter.decreaseIndent(); - } - }; - - Emitter.throwEmitterError = function (e) { - var error = new Error(e.message); - error.isEmitterError = true; - throw error; - }; - - Emitter.handleEmitterError = function (fileName, e) { - if ((e).isEmitterError === true) { - return [new TypeScript.Diagnostic(fileName, 0, 0, 275 /* Emit_Error__0 */, [e.message])]; - } - - throw e; - }; - return Emitter; - })(); - TypeScript.Emitter = Emitter; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var MemberName = (function () { - function MemberName() { - this.prefix = ""; - this.suffix = ""; - } - MemberName.prototype.isString = function () { - return false; - }; - MemberName.prototype.isArray = function () { - return false; - }; - MemberName.prototype.isMarker = function () { - return !this.isString() && !this.isArray(); - }; - - MemberName.prototype.toString = function () { - return MemberName.memberNameToString(this); - }; - - MemberName.memberNameToString = function (memberName, markerInfo, markerBaseLength) { - if (typeof markerBaseLength === "undefined") { markerBaseLength = 0; } - var result = memberName.prefix; - - if (memberName.isString()) { - result += (memberName).text; - } else if (memberName.isArray()) { - var ar = memberName; - for (var index = 0; index < ar.entries.length; index++) { - if (ar.entries[index].isMarker()) { - if (markerInfo) { - markerInfo.push(markerBaseLength + result.length); - } - continue; - } - - result += MemberName.memberNameToString(ar.entries[index], markerInfo, markerBaseLength + result.length); - result += ar.delim; - } - } - - result += memberName.suffix; - return result; - }; - - MemberName.create = function (arg1, arg2, arg3) { - if (typeof arg1 === "string") { - return new MemberNameString(arg1); - } else { - var result = new MemberNameArray(); - if (arg2) - result.prefix = arg2; - if (arg3) - result.suffix = arg3; - result.entries.push(arg1); - return result; - } - }; - return MemberName; - })(); - TypeScript.MemberName = MemberName; - - var MemberNameString = (function (_super) { - __extends(MemberNameString, _super); - function MemberNameString(text) { - _super.call(this); - this.text = text; - } - MemberNameString.prototype.isString = function () { - return true; - }; - return MemberNameString; - })(MemberName); - TypeScript.MemberNameString = MemberNameString; - - var MemberNameArray = (function (_super) { - __extends(MemberNameArray, _super); - function MemberNameArray() { - _super.call(this); - this.delim = ""; - this.entries = []; - } - MemberNameArray.prototype.isArray = function () { - return true; - }; - - MemberNameArray.prototype.add = function (entry) { - this.entries.push(entry); - }; - - MemberNameArray.prototype.addAll = function (entries) { - for (var i = 0; i < entries.length; i++) { - this.entries.push(entries[i]); - } - }; - return MemberNameArray; - })(MemberName); - TypeScript.MemberNameArray = MemberNameArray; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - function stripQuotes(str) { - return str.replace(/"/g, "").replace(/'/g, ""); - } - TypeScript.stripQuotes = stripQuotes; - - function isSingleQuoted(str) { - return str.indexOf("'") !== -1; - } - TypeScript.isSingleQuoted = isSingleQuoted; - - function isQuoted(str) { - return str.indexOf("\"") !== -1 || isSingleQuoted(str); - } - TypeScript.isQuoted = isQuoted; - - function quoteStr(str) { - return "\"" + str + "\""; - } - TypeScript.quoteStr = quoteStr; - - function swapQuotes(str) { - if (str.indexOf("\"") !== -1) { - str = str.replace("\"", "'"); - str = str.replace("\"", "'"); - } else { - str = str.replace("'", "\""); - str = str.replace("'", "\""); - } - - return str; - } - TypeScript.swapQuotes = swapQuotes; - - function switchToForwardSlashes(path) { - return path.replace(/\\/g, "/"); - } - TypeScript.switchToForwardSlashes = switchToForwardSlashes; - - function trimModName(modName) { - if (modName.length > 5 && modName.substring(modName.length - 5, modName.length) === ".d.ts") { - return modName.substring(0, modName.length - 5); - } - if (modName.length > 3 && modName.substring(modName.length - 3, modName.length) === ".ts") { - return modName.substring(0, modName.length - 3); - } - - if (modName.length > 3 && modName.substring(modName.length - 3, modName.length) === ".js") { - return modName.substring(0, modName.length - 3); - } - - return modName; - } - TypeScript.trimModName = trimModName; - - function getDeclareFilePath(fname) { - return isTSFile(fname) ? changePathToDTS(fname) : changePathToDTS(fname); - } - TypeScript.getDeclareFilePath = getDeclareFilePath; - - function isFileOfExtension(fname, ext) { - var invariantFname = fname.toLocaleUpperCase(); - var invariantExt = ext.toLocaleUpperCase(); - var extLength = invariantExt.length; - return invariantFname.length > extLength && invariantFname.substring(invariantFname.length - extLength, invariantFname.length) === invariantExt; - } - - function isJSFile(fname) { - return isFileOfExtension(fname, ".js"); - } - TypeScript.isJSFile = isJSFile; - - function isTSFile(fname) { - return isFileOfExtension(fname, ".ts"); - } - TypeScript.isTSFile = isTSFile; - - function isDTSFile(fname) { - return isFileOfExtension(fname, ".d.ts"); - } - TypeScript.isDTSFile = isDTSFile; - - function getPrettyName(modPath, quote, treatAsFileName) { - if (typeof quote === "undefined") { quote = true; } - if (typeof treatAsFileName === "undefined") { treatAsFileName = false; } - var modName = treatAsFileName ? switchToForwardSlashes(modPath) : trimModName(stripQuotes(modPath)); - var components = this.getPathComponents(modName); - return components.length ? (quote ? quoteStr(components[components.length - 1]) : components[components.length - 1]) : modPath; - } - TypeScript.getPrettyName = getPrettyName; - - function getPathComponents(path) { - return path.split("/"); - } - TypeScript.getPathComponents = getPathComponents; - - function getRelativePathToFixedPath(fixedModFilePath, absoluteModPath) { - absoluteModPath = switchToForwardSlashes(absoluteModPath); - - var modComponents = this.getPathComponents(absoluteModPath); - var fixedModComponents = this.getPathComponents(fixedModFilePath); - - var joinStartIndex = 0; - for (; joinStartIndex < modComponents.length && joinStartIndex < fixedModComponents.length; joinStartIndex++) { - if (fixedModComponents[joinStartIndex] !== modComponents[joinStartIndex]) { - break; - } - } - - if (joinStartIndex !== 0) { - var relativePath = ""; - var relativePathComponents = modComponents.slice(joinStartIndex, modComponents.length); - for (; joinStartIndex < fixedModComponents.length; joinStartIndex++) { - if (fixedModComponents[joinStartIndex] !== "") { - relativePath = relativePath + "../"; - } - } - - return relativePath + relativePathComponents.join("/"); - } - - return absoluteModPath; - } - TypeScript.getRelativePathToFixedPath = getRelativePathToFixedPath; - - function quoteBaseName(modPath) { - var modName = trimModName(stripQuotes(modPath)); - var path = getRootFilePath(modName); - if (path === "") { - return modPath; - } else { - var components = modName.split(path); - var fileIndex = components.length > 1 ? 1 : 0; - return quoteStr(components[fileIndex]); - } - } - TypeScript.quoteBaseName = quoteBaseName; - - function changePathToDTS(modPath) { - return trimModName(stripQuotes(modPath)) + ".d.ts"; - } - TypeScript.changePathToDTS = changePathToDTS; - - function isRelative(path) { - return path.charAt(0) === "."; - } - TypeScript.isRelative = isRelative; - function isRooted(path) { - return path.charAt(0) === "\\" || path.charAt(0) === "/" || (path.indexOf(":\\") !== -1) || (path.indexOf(":/") !== -1); - } - TypeScript.isRooted = isRooted; - - function getRootFilePath(outFname) { - if (outFname === "") { - return outFname; - } else { - var isPath = outFname.indexOf("/") !== -1; - return isPath ? filePath(outFname) : ""; - } - } - TypeScript.getRootFilePath = getRootFilePath; - - function filePathComponents(fullPath) { - fullPath = switchToForwardSlashes(fullPath); - var components = getPathComponents(fullPath); - return components.slice(0, components.length - 1); - } - TypeScript.filePathComponents = filePathComponents; - - function filePath(fullPath) { - var path = filePathComponents(fullPath); - return path.join("/") + "/"; - } - TypeScript.filePath = filePath; - - function normalizePath(path) { - if (/^\\\\[^\\]/.test(path)) { - path = "file:" + path; - } - var parts = this.getPathComponents(switchToForwardSlashes(path)); - var normalizedParts = []; - - for (var i = 0; i < parts.length; i++) { - var part = parts[i]; - if (part === ".") { - continue; - } - - if (normalizedParts.length > 0 && TypeScript.ArrayUtilities.last(normalizedParts) !== ".." && part === "..") { - normalizedParts.pop(); - continue; - } - - normalizedParts.push(part); - } - - return normalizedParts.join("/"); - } - TypeScript.normalizePath = normalizePath; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var SourceUnit = (function () { - function SourceUnit(path, fileInformation) { - this.path = path; - this.fileInformation = fileInformation; - this.referencedFiles = null; - this.lineStarts = null; - } - SourceUnit.prototype.getText = function (start, end) { - return this.fileInformation.contents().substring(start, end); - }; - - SourceUnit.prototype.getLength = function () { - return this.fileInformation.contents().length; - }; - - SourceUnit.prototype.getLineStartPositions = function () { - if (this.lineStarts === null) { - this.lineStarts = TypeScript.LineMap.fromString(this.fileInformation.contents()).lineStarts(); - } - - return this.lineStarts; - }; - - SourceUnit.prototype.getTextChangeRangeSinceVersion = function (scriptVersion) { - throw TypeScript.Errors.notYetImplemented(); - }; - return SourceUnit; - })(); - TypeScript.SourceUnit = SourceUnit; - - var CompilationEnvironment = (function () { - function CompilationEnvironment(compilationSettings, ioHost) { - this.compilationSettings = compilationSettings; - this.ioHost = ioHost; - this.code = []; - this.inputFileNameToOutputFileName = new TypeScript.StringHashTable(); - } - CompilationEnvironment.prototype.getSourceUnit = function (path) { - var normalizedPath = TypeScript.switchToForwardSlashes(path.toUpperCase()); - for (var i = 0, n = this.code.length; i < n; i++) { - var sourceUnit = this.code[i]; - var soruceUnitNormalizedPath = TypeScript.switchToForwardSlashes(sourceUnit.path.toUpperCase()); - if (normalizedPath === soruceUnitNormalizedPath) { - return sourceUnit; - } - } - - return null; - }; - return CompilationEnvironment; - })(); - TypeScript.CompilationEnvironment = CompilationEnvironment; - - var CodeResolver = (function () { - function CodeResolver(environment) { - this.environment = environment; - this.visited = {}; - } - CodeResolver.prototype.resolveCode = function (referencePath, parentPath, performSearch, resolutionDispatcher) { - var resolvedFile = { fileInformation: null, path: referencePath }; - - var ioHost = this.environment.ioHost; - - var isRelativePath = TypeScript.isRelative(referencePath); - var isRootedPath = isRelativePath ? false : TypeScript.isRooted(referencePath); - var normalizedPath = isRelativePath ? ioHost.resolvePath(parentPath + "/" + referencePath) : (isRootedPath || !parentPath || performSearch ? referencePath : parentPath + "/" + referencePath); - - if (!TypeScript.isTSFile(normalizedPath)) { - normalizedPath += ".ts"; - } - - normalizedPath = TypeScript.switchToForwardSlashes(TypeScript.stripQuotes(normalizedPath)); - var absoluteModuleID = this.environment.compilationSettings.useCaseSensitiveFileResolution ? normalizedPath : normalizedPath.toLocaleUpperCase(); - - if (!this.visited[absoluteModuleID]) { - if (isRelativePath || isRootedPath || !performSearch) { - try { - TypeScript.CompilerDiagnostics.debugPrint(" Reading code from " + normalizedPath); - - try { - resolvedFile.fileInformation = ioHost.readFile(normalizedPath); - } catch (err1) { - if (TypeScript.isTSFile(normalizedPath)) { - normalizedPath = TypeScript.changePathToDTS(normalizedPath); - TypeScript.CompilerDiagnostics.debugPrint(" Reading code from " + normalizedPath); - resolvedFile.fileInformation = ioHost.readFile(normalizedPath); - } - } - TypeScript.CompilerDiagnostics.debugPrint(" Found code at " + normalizedPath); - - resolvedFile.path = normalizedPath; - this.visited[absoluteModuleID] = true; - } catch (err4) { - TypeScript.CompilerDiagnostics.debugPrint(" Did not find code for " + referencePath); - - return false; - } - } else { - try { - resolvedFile = ioHost.findFile(parentPath, normalizedPath); - - if (!resolvedFile) { - if (TypeScript.isTSFile(normalizedPath)) { - normalizedPath = TypeScript.changePathToDTS(normalizedPath); - resolvedFile = ioHost.findFile(parentPath, normalizedPath); - } - } - } catch (e) { - TypeScript.CompilerDiagnostics.debugPrint(" Did not find code for " + normalizedPath); - - return false; - } - - if (resolvedFile) { - resolvedFile.path = TypeScript.switchToForwardSlashes(TypeScript.stripQuotes(resolvedFile.path)); - TypeScript.CompilerDiagnostics.debugPrint(referencePath + " resolved to: " + resolvedFile.path); - resolvedFile.fileInformation = resolvedFile.fileInformation; - this.visited[absoluteModuleID] = true; - } else { - TypeScript.CompilerDiagnostics.debugPrint("Could not find " + referencePath); - } - } - - if (resolvedFile && resolvedFile.fileInformation !== null) { - var rootDir = ioHost.dirName(resolvedFile.path); - var sourceUnit = new SourceUnit(resolvedFile.path, resolvedFile.fileInformation); - var preProcessedFileInfo = TypeScript.preProcessFile(resolvedFile.path, sourceUnit, this.environment.compilationSettings); - var resolvedFilePath = ioHost.resolvePath(resolvedFile.path); - var resolutionResult; - - sourceUnit.referencedFiles = preProcessedFileInfo.referencedFiles; - - for (var i = 0; i < preProcessedFileInfo.referencedFiles.length; i++) { - var fileReference = preProcessedFileInfo.referencedFiles[i]; - - normalizedPath = TypeScript.isRooted(fileReference.path) ? fileReference.path : rootDir + "/" + fileReference.path; - normalizedPath = ioHost.resolvePath(normalizedPath); - - if (resolvedFilePath === normalizedPath) { - resolutionDispatcher.errorReporter.addDiagnostic(new TypeScript.Diagnostic(normalizedPath, fileReference.position, fileReference.length, 270 /* A_file_cannot_have_a_reference_itself */, null)); - continue; - } - - resolutionResult = this.resolveCode(fileReference.path, rootDir, false, resolutionDispatcher); - - if (!resolutionResult) { - resolutionDispatcher.errorReporter.addDiagnostic(new TypeScript.Diagnostic(resolvedFilePath, fileReference.position, fileReference.length, 271 /* Cannot_resolve_referenced_file___0_ */, [fileReference.path])); - } - } - - for (var i = 0; i < preProcessedFileInfo.importedFiles.length; i++) { - var fileImport = preProcessedFileInfo.importedFiles[i]; - - resolutionResult = this.resolveCode(fileImport.path, rootDir, true, resolutionDispatcher); - - if (!resolutionResult) { - resolutionDispatcher.errorReporter.addDiagnostic(new TypeScript.Diagnostic(resolvedFilePath, fileImport.position, fileImport.length, 272 /* Cannot_resolve_imported_file___0_ */, [fileImport.path])); - } - } - - resolutionDispatcher.postResolution(sourceUnit.path, sourceUnit); - } - } - return true; - }; - return CodeResolver; - })(); - TypeScript.CodeResolver = CodeResolver; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var CompilationSettings = (function () { - function CompilationSettings() { - this.propagateConstants = false; - this.minWhitespace = false; - this.emitComments = false; - this.watch = false; - this.exec = false; - this.resolve = true; - this.disallowBool = false; - this.allowAutomaticSemicolonInsertion = true; - this.allowModuleKeywordInExternalModuleReference = true; - this.useDefaultLib = true; - this.codeGenTarget = 0 /* EcmaScript3 */; - this.moduleGenTarget = 0 /* Synchronous */; - this.outputOption = ""; - this.mapSourceFiles = false; - this.emitFullSourceMapPath = false; - this.generateDeclarationFiles = false; - this.useCaseSensitiveFileResolution = false; - this.gatherDiagnostics = false; - this.updateTC = false; - this.implicitAny = false; - } - return CompilationSettings; - })(); - TypeScript.CompilationSettings = CompilationSettings; - - function getFileReferenceFromReferencePath(comment) { - var referencesRegEx = /^(\/\/\/\s*/gim; - var match = referencesRegEx.exec(comment); - - if (match) { - var path = TypeScript.normalizePath(match[3]); - var adjustedPath = TypeScript.normalizePath(path); - - var isResident = match.length >= 7 && match[6] === "true"; - if (isResident) { - TypeScript.CompilerDiagnostics.debugPrint(path + " is resident"); - } - return { - line: 0, - character: 0, - position: 0, - length: 0, - path: TypeScript.switchToForwardSlashes(adjustedPath), - isResident: isResident - }; - } else { - return null; - } - } - - function getImplicitImport(comment) { - var implicitImportRegEx = /^(\/\/\/\s*/gim; - var match = implicitImportRegEx.exec(comment); - - if (match) { - return true; - } - - return false; - } - TypeScript.getImplicitImport = getImplicitImport; - - function getReferencedFiles(fileName, sourceText) { - var preProcessInfo = preProcessFile(fileName, sourceText, null, false); - return preProcessInfo.referencedFiles; - } - TypeScript.getReferencedFiles = getReferencedFiles; - - var scannerWindow = TypeScript.ArrayUtilities.createArray(2048, 0); - var scannerDiagnostics = []; - - function processImports(lineMap, scanner, token, importedFiles) { - var position = 0; - var lineChar = { line: -1, character: -1 }; - - while (token.tokenKind !== 10 /* EndOfFileToken */) { - if (token.tokenKind === 49 /* ImportKeyword */) { - var importStart = position + token.leadingTriviaWidth(); - token = scanner.scan(scannerDiagnostics, false); - - if (TypeScript.SyntaxFacts.isIdentifierNameOrAnyKeyword(token)) { - token = scanner.scan(scannerDiagnostics, false); - - if (token.tokenKind === 108 /* EqualsToken */) { - token = scanner.scan(scannerDiagnostics, false); - - if (token.tokenKind === 66 /* ModuleKeyword */ || token.tokenKind === 67 /* RequireKeyword */) { - token = scanner.scan(scannerDiagnostics, false); - - if (token.tokenKind === 73 /* OpenParenToken */) { - var afterOpenParenPosition = scanner.absoluteIndex(); - token = scanner.scan(scannerDiagnostics, false); - - lineMap.fillLineAndCharacterFromPosition(importStart, lineChar); - - if (token.tokenKind === 14 /* StringLiteral */) { - var ref = { - line: lineChar.line, - character: lineChar.character, - position: afterOpenParenPosition + token.leadingTriviaWidth(), - length: token.width(), - path: TypeScript.stripQuotes(TypeScript.switchToForwardSlashes(token.text())), - isResident: false - }; - importedFiles.push(ref); - } - } - } - } - } - } - - position = scanner.absoluteIndex(); - token = scanner.scan(scannerDiagnostics, false); - } - } - - function processTripleSlashDirectives(lineMap, firstToken, settings, referencedFiles) { - var leadingTrivia = firstToken.leadingTrivia(); - - var position = 0; - var lineChar = { line: -1, character: -1 }; - var noDefaultLib = false; - - for (var i = 0, n = leadingTrivia.count(); i < n; i++) { - var trivia = leadingTrivia.syntaxTriviaAt(i); - - if (trivia.kind() === 7 /* SingleLineCommentTrivia */) { - var triviaText = trivia.fullText(); - var referencedCode = getFileReferenceFromReferencePath(triviaText); - - if (referencedCode) { - lineMap.fillLineAndCharacterFromPosition(position, lineChar); - referencedCode.position = position; - referencedCode.length = trivia.fullWidth(); - referencedCode.line = lineChar.line; - referencedCode.character = lineChar.character; - - referencedFiles.push(referencedCode); - } - - if (settings) { - var isNoDefaultLibRegex = /^(\/\/\/\s*/gim; - var isNoDefaultLibMatch = isNoDefaultLibRegex.exec(triviaText); - if (isNoDefaultLibMatch) { - noDefaultLib = (isNoDefaultLibMatch[3] === "true"); - } - } - } - - position += trivia.fullWidth(); - } - - return { noDefaultLib: noDefaultLib }; - } - - function preProcessFile(fileName, sourceText, settings, readImportFiles) { - if (typeof readImportFiles === "undefined") { readImportFiles = true; } - settings = settings || new CompilationSettings(); - var text = TypeScript.SimpleText.fromScriptSnapshot(sourceText); - var scanner = new TypeScript.Scanner(fileName, text, settings.codeGenTarget, scannerWindow); - - var firstToken = scanner.scan(scannerDiagnostics, false); - - var importedFiles = []; - if (readImportFiles) { - processImports(text.lineMap(), scanner, firstToken, importedFiles); - } - - var referencedFiles = []; - var properties = processTripleSlashDirectives(text.lineMap(), firstToken, settings, referencedFiles); - - scannerDiagnostics.length = 0; - return { settings: settings, referencedFiles: referencedFiles, importedFiles: importedFiles, isLibFile: properties.noDefaultLib }; - } - TypeScript.preProcessFile = preProcessFile; - - function getParseOptions(settings) { - return new TypeScript.ParseOptions(settings.allowAutomaticSemicolonInsertion, settings.allowModuleKeywordInExternalModuleReference); - } - TypeScript.getParseOptions = getParseOptions; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var TextWriter = (function () { - function TextWriter(ioHost, path, writeByteOrderMark) { - this.ioHost = ioHost; - this.path = path; - this.writeByteOrderMark = writeByteOrderMark; - this.contents = ""; - this.onNewLine = true; - } - TextWriter.prototype.Write = function (s) { - this.contents += s; - this.onNewLine = false; - }; - - TextWriter.prototype.WriteLine = function (s) { - this.contents += s; - this.contents += "\r\n"; - this.onNewLine = true; - }; - - TextWriter.prototype.Close = function () { - try { - this.ioHost.writeFile(this.path, this.contents, this.writeByteOrderMark); - } catch (e) { - TypeScript.Emitter.throwEmitterError(e); - } - }; - return TextWriter; - })(); - TypeScript.TextWriter = TextWriter; - - var DeclarationEmitter = (function () { - function DeclarationEmitter(emittingFileName, semanticInfoChain, emitOptions, writeByteOrderMark) { - this.emittingFileName = emittingFileName; - this.semanticInfoChain = semanticInfoChain; - this.emitOptions = emitOptions; - this.writeByteOrderMark = writeByteOrderMark; - this.fileName = null; - this.declFile = null; - this.indenter = new TypeScript.Indenter(); - this.declarationContainerStack = []; - this.isDottedModuleName = []; - this.ignoreCallbackAst = null; - this.singleDeclFile = null; - this.varListCount = 0; - this.declFile = new TextWriter(emitOptions.ioHost, emittingFileName, writeByteOrderMark); - } - DeclarationEmitter.prototype.widenType = function (type) { - if (type === this.semanticInfoChain.undefinedTypeSymbol || type === this.semanticInfoChain.nullTypeSymbol) { - return this.semanticInfoChain.anyTypeSymbol; - } - - return type; - }; - - DeclarationEmitter.prototype.close = function () { - try { - this.declFile.Close(); - } catch (e) { - TypeScript.Emitter.throwEmitterError(e); - } - }; - - DeclarationEmitter.prototype.emitDeclarations = function (script) { - TypeScript.AstWalkerWithDetailCallback.walk(script, this); - }; - - DeclarationEmitter.prototype.getAstDeclarationContainer = function () { - return this.declarationContainerStack[this.declarationContainerStack.length - 1]; - }; - - DeclarationEmitter.prototype.emitDottedModuleName = function () { - return (this.isDottedModuleName.length === 0) ? false : this.isDottedModuleName[this.isDottedModuleName.length - 1]; - }; - - DeclarationEmitter.prototype.getIndentString = function (declIndent) { - if (typeof declIndent === "undefined") { declIndent = false; } - if (this.emitOptions.compilationSettings.minWhitespace) { - return ""; - } else { - return this.indenter.getIndent(); - } - }; - - DeclarationEmitter.prototype.emitIndent = function () { - this.declFile.Write(this.getIndentString()); - }; - - DeclarationEmitter.prototype.canEmitSignature = function (declFlags, declAST, canEmitGlobalAmbientDecl, useDeclarationContainerTop) { - if (typeof canEmitGlobalAmbientDecl === "undefined") { canEmitGlobalAmbientDecl = true; } - if (typeof useDeclarationContainerTop === "undefined") { useDeclarationContainerTop = true; } - var container; - if (useDeclarationContainerTop) { - container = this.getAstDeclarationContainer(); - } else { - container = this.declarationContainerStack[this.declarationContainerStack.length - 2]; - } - - if (container.nodeType === 15 /* ModuleDeclaration */ && !TypeScript.hasFlag(declFlags, 1 /* Exported */)) { - var declSymbol = this.semanticInfoChain.getSymbolAndDiagnosticsForAST(declAST, this.fileName).symbol; - return declSymbol && declSymbol.isExternallyVisible(); - } - - if (!canEmitGlobalAmbientDecl && container.nodeType === 2 /* Script */ && TypeScript.hasFlag(declFlags, 8 /* Ambient */)) { - return false; - } - - return true; - }; - - DeclarationEmitter.prototype.canEmitPrePostAstSignature = function (declFlags, astWithPrePostCallback, preCallback) { - if (this.ignoreCallbackAst) { - TypeScript.CompilerDiagnostics.assert(this.ignoreCallbackAst !== astWithPrePostCallback, "Ignore Callback AST mismatch"); - this.ignoreCallbackAst = null; - return false; - } else if (preCallback && !this.canEmitSignature(declFlags, astWithPrePostCallback, true, preCallback)) { - this.ignoreCallbackAst = astWithPrePostCallback; - return false; - } - - return true; - }; - - DeclarationEmitter.prototype.getDeclFlagsString = function (declFlags, typeString) { - var result = this.getIndentString(); - - if (TypeScript.hasFlag(declFlags, 16 /* Static */)) { - if (TypeScript.hasFlag(declFlags, 2 /* Private */)) { - result += "private "; - } - result += "static "; - } else { - if (TypeScript.hasFlag(declFlags, 2 /* Private */)) { - result += "private "; - } else if (TypeScript.hasFlag(declFlags, 4 /* Public */)) { - result += "public "; - } else { - var emitDeclare = !TypeScript.hasFlag(declFlags, 1 /* Exported */); - - var container = this.getAstDeclarationContainer(); - if (container.nodeType === 15 /* ModuleDeclaration */ && TypeScript.hasFlag((container).getModuleFlags(), 256 /* IsWholeFile */) && TypeScript.hasFlag(declFlags, 1 /* Exported */)) { - result += "export "; - emitDeclare = true; - } - - if (emitDeclare && typeString !== "interface") { - result += "declare "; - } - - result += typeString + " "; - } - } - - return result; - }; - - DeclarationEmitter.prototype.emitDeclFlags = function (declFlags, typeString) { - this.declFile.Write(this.getDeclFlagsString(declFlags, typeString)); - }; - - DeclarationEmitter.prototype.canEmitTypeAnnotationSignature = function (declFlag) { - if (typeof declFlag === "undefined") { declFlag = 0 /* None */; } - return !TypeScript.hasFlag(declFlag, 2 /* Private */); - }; - - DeclarationEmitter.prototype.pushDeclarationContainer = function (ast) { - this.declarationContainerStack.push(ast); - }; - - DeclarationEmitter.prototype.popDeclarationContainer = function (ast) { - TypeScript.CompilerDiagnostics.assert(ast !== this.getAstDeclarationContainer(), 'Declaration container mismatch'); - this.declarationContainerStack.pop(); - }; - - DeclarationEmitter.prototype.emitTypeNamesMember = function (memberName, emitIndent) { - if (typeof emitIndent === "undefined") { emitIndent = false; } - if (memberName.prefix === "{ ") { - if (emitIndent) { - this.emitIndent(); - } - - this.declFile.WriteLine("{"); - this.indenter.increaseIndent(); - emitIndent = true; - } else if (memberName.prefix !== "") { - if (emitIndent) { - this.emitIndent(); - } - - this.declFile.Write(memberName.prefix); - emitIndent = false; - } - - if (memberName.isString()) { - if (emitIndent) { - this.emitIndent(); - } - - this.declFile.Write((memberName).text); - } else if (memberName.isArray()) { - var ar = memberName; - for (var index = 0; index < ar.entries.length; index++) { - this.emitTypeNamesMember(ar.entries[index], emitIndent); - if (ar.delim === "; ") { - this.declFile.WriteLine(";"); - } - } - } - - if (memberName.suffix === "}") { - this.indenter.decreaseIndent(); - this.emitIndent(); - this.declFile.Write(memberName.suffix); - } else { - this.declFile.Write(memberName.suffix); - } - }; - - DeclarationEmitter.prototype.emitTypeSignature = function (type) { - var declarationContainerAst = this.getAstDeclarationContainer(); - var declarationContainerDecl = this.semanticInfoChain.getDeclForAST(declarationContainerAst, this.fileName); - var declarationPullSymbol = declarationContainerDecl.getSymbol(); - var typeNameMembers = type.getScopedNameEx(declarationPullSymbol); - this.emitTypeNamesMember(typeNameMembers); - }; - - DeclarationEmitter.prototype.emitComment = function (comment) { - var text = comment.getText(); - if (this.declFile.onNewLine) { - this.emitIndent(); - } else if (!comment.isBlockComment) { - this.declFile.WriteLine(""); - this.emitIndent(); - } - - this.declFile.Write(text[0]); - - for (var i = 1; i < text.length; i++) { - this.declFile.WriteLine(""); - this.emitIndent(); - this.declFile.Write(text[i]); - } - - if (comment.endsLine || !comment.isBlockComment) { - this.declFile.WriteLine(""); - } else { - this.declFile.Write(" "); - } - }; - - DeclarationEmitter.prototype.emitDeclarationComments = function (astOrSymbol, endLine) { - if (typeof endLine === "undefined") { endLine = true; } - if (!this.emitOptions.compilationSettings.emitComments) { - return; - } - - var declComments = astOrSymbol.getDocComments(); - this.writeDeclarationComments(declComments, endLine); - }; - - DeclarationEmitter.prototype.writeDeclarationComments = function (declComments, endLine) { - if (typeof endLine === "undefined") { endLine = true; } - if (declComments.length > 0) { - for (var i = 0; i < declComments.length; i++) { - this.emitComment(declComments[i]); - } - - if (endLine) { - if (!this.declFile.onNewLine) { - this.declFile.WriteLine(""); - } - } else { - if (this.declFile.onNewLine) { - this.emitIndent(); - } - } - } - }; - - DeclarationEmitter.prototype.emitTypeOfBoundDecl = function (boundDecl) { - var decl = this.semanticInfoChain.getDeclForAST(boundDecl, this.fileName); - var pullSymbol = decl.getSymbol(); - var type = this.widenType(pullSymbol.getType()); - if (!type) { - return; - } - - if (boundDecl.typeExpr || (boundDecl.init && type !== this.semanticInfoChain.anyTypeSymbol)) { - this.declFile.Write(": "); - this.emitTypeSignature(type); - } - }; - - DeclarationEmitter.prototype.VariableDeclaratorCallback = function (pre, varDecl) { - if (pre && this.canEmitSignature(TypeScript.ToDeclFlags(varDecl.getVarFlags()), varDecl, false)) { - var interfaceMember = (this.getAstDeclarationContainer().nodeType === 14 /* InterfaceDeclaration */); - this.emitDeclarationComments(varDecl); - if (!interfaceMember) { - if (this.varListCount >= 0) { - this.emitDeclFlags(TypeScript.ToDeclFlags(varDecl.getVarFlags()), "var"); - this.varListCount = -this.varListCount; - } - - this.declFile.Write(varDecl.id.actualText); - } else { - this.emitIndent(); - this.declFile.Write(varDecl.id.actualText); - if (TypeScript.hasFlag(varDecl.id.getFlags(), 4 /* OptionalName */)) { - this.declFile.Write("?"); - } - } - - if (this.canEmitTypeAnnotationSignature(TypeScript.ToDeclFlags(varDecl.getVarFlags()))) { - this.emitTypeOfBoundDecl(varDecl); - } - - if (this.varListCount > 0) { - this.varListCount--; - } else if (this.varListCount < 0) { - this.varListCount++; - } - - if (this.varListCount < 0) { - this.declFile.Write(", "); - } else { - this.declFile.WriteLine(";"); - } - } - return false; - }; - - DeclarationEmitter.prototype.BlockCallback = function (pre, block) { - return false; - }; - - DeclarationEmitter.prototype.VariableStatementCallback = function (pre, variableDeclaration) { - return true; - }; - - DeclarationEmitter.prototype.VariableDeclarationCallback = function (pre, variableDeclaration) { - if (pre) { - this.varListCount = variableDeclaration.declarators.members.length; - } else { - this.varListCount = 0; - } - return true; - }; - - DeclarationEmitter.prototype.emitArgDecl = function (argDecl, funcDecl) { - this.indenter.increaseIndent(); - - this.emitDeclarationComments(argDecl, false); - this.declFile.Write(argDecl.id.actualText); - if (argDecl.isOptionalArg()) { - this.declFile.Write("?"); - } - - this.indenter.decreaseIndent(); - - if (this.canEmitTypeAnnotationSignature(TypeScript.ToDeclFlags(funcDecl.getFunctionFlags()))) { - this.emitTypeOfBoundDecl(argDecl); - } - }; - - DeclarationEmitter.prototype.isOverloadedCallSignature = function (funcDecl) { - var functionDecl = this.semanticInfoChain.getDeclForAST(funcDecl, this.fileName); - var funcSymbol = functionDecl.getSymbol(); - var funcTypeSymbol = funcSymbol.getType(); - var signatures = funcTypeSymbol.getCallSignatures(); - return signatures && signatures.length > 1; - }; - - DeclarationEmitter.prototype.FunctionDeclarationCallback = function (pre, funcDecl) { - if (!pre) { - return false; - } - - if (funcDecl.isAccessor()) { - return this.emitPropertyAccessorSignature(funcDecl); - } - - var isInterfaceMember = (this.getAstDeclarationContainer().nodeType === 14 /* InterfaceDeclaration */); - - var funcSymbol = this.semanticInfoChain.getSymbolAndDiagnosticsForAST(funcDecl, this.fileName).symbol; - var funcTypeSymbol = funcSymbol.getType(); - if (funcDecl.block) { - var constructSignatures = funcTypeSymbol.getConstructSignatures(); - if (constructSignatures && constructSignatures.length > 1) { - return false; - } else if (this.isOverloadedCallSignature(funcDecl)) { - return false; - } - } else if (!isInterfaceMember && TypeScript.hasFlag(funcDecl.getFunctionFlags(), 2 /* Private */) && this.isOverloadedCallSignature(funcDecl)) { - var callSignatures = funcTypeSymbol.getCallSignatures(); - TypeScript.Debug.assert(callSignatures && callSignatures.length > 1); - var firstSignature = callSignatures[0].isDefinition() ? callSignatures[1] : callSignatures[0]; - var firstSignatureDecl = firstSignature.getDeclarations()[0]; - var firstFuncDecl = this.semanticInfoChain.getASTForDecl(firstSignatureDecl); - if (firstFuncDecl !== funcDecl) { - return false; - } - } - - if (!this.canEmitSignature(TypeScript.ToDeclFlags(funcDecl.getFunctionFlags()), funcDecl, false)) { - return false; - } - - var funcSignature = this.semanticInfoChain.getDeclForAST(funcDecl, this.fileName).getSignatureSymbol(); - this.emitDeclarationComments(funcDecl); - if (funcDecl.isConstructor) { - this.emitIndent(); - this.declFile.Write("constructor"); - this.emitTypeParameters(funcDecl.typeArguments, funcSignature); - } else { - var id = funcDecl.getNameText(); - if (!isInterfaceMember) { - this.emitDeclFlags(TypeScript.ToDeclFlags(funcDecl.getFunctionFlags()), "function"); - if (id !== "__missing" || !funcDecl.name || !funcDecl.name.isMissing()) { - this.declFile.Write(id); - } else if (funcDecl.isConstructMember()) { - this.declFile.Write("new"); - } - - this.emitTypeParameters(funcDecl.typeArguments, funcSignature); - } else { - this.emitIndent(); - if (funcDecl.isConstructMember()) { - this.declFile.Write("new"); - this.emitTypeParameters(funcDecl.typeArguments, funcSignature); - } else if (!funcDecl.isCallMember() && !funcDecl.isIndexerMember()) { - this.declFile.Write(id); - this.emitTypeParameters(funcDecl.typeArguments, funcSignature); - if (TypeScript.hasFlag(funcDecl.name.getFlags(), 4 /* OptionalName */)) { - this.declFile.Write("? "); - } - } else { - this.emitTypeParameters(funcDecl.typeArguments, funcSignature); - } - } - } - - if (!funcDecl.isIndexerMember()) { - this.declFile.Write("("); - } else { - this.declFile.Write("["); - } - - if (funcDecl.arguments) { - var argsLen = funcDecl.arguments.members.length; - if (funcDecl.variableArgList) { - argsLen--; - } - - for (var i = 0; i < argsLen; i++) { - var argDecl = funcDecl.arguments.members[i]; - this.emitArgDecl(argDecl, funcDecl); - if (i < (argsLen - 1)) { - this.declFile.Write(", "); - } - } - } - - if (funcDecl.variableArgList) { - var lastArg = funcDecl.arguments.members[funcDecl.arguments.members.length - 1]; - if (funcDecl.arguments.members.length > 1) { - this.declFile.Write(", ..."); - } else { - this.declFile.Write("..."); - } - - this.emitArgDecl(lastArg, funcDecl); - } - - if (!funcDecl.isIndexerMember()) { - this.declFile.Write(")"); - } else { - this.declFile.Write("]"); - } - - if (!funcDecl.isConstructor && this.canEmitTypeAnnotationSignature(TypeScript.ToDeclFlags(funcDecl.getFunctionFlags()))) { - var returnType = funcSignature.getReturnType(); - if (funcDecl.returnTypeAnnotation || (returnType && returnType !== this.semanticInfoChain.anyTypeSymbol)) { - this.declFile.Write(": "); - this.emitTypeSignature(returnType); - } - } - - this.declFile.WriteLine(";"); - - return false; - }; - - DeclarationEmitter.prototype.emitBaseExpression = function (bases, index) { - var baseTypeAndDiagnostics = this.semanticInfoChain.getSymbolAndDiagnosticsForAST(bases.members[index], this.fileName); - var baseType = baseTypeAndDiagnostics && baseTypeAndDiagnostics.symbol; - this.emitTypeSignature(baseType); - }; - - DeclarationEmitter.prototype.emitBaseList = function (typeDecl, useExtendsList) { - var bases = useExtendsList ? typeDecl.extendsList : typeDecl.implementsList; - if (bases && (bases.members.length > 0)) { - var qual = useExtendsList ? "extends" : "implements"; - this.declFile.Write(" " + qual + " "); - var basesLen = bases.members.length; - for (var i = 0; i < basesLen; i++) { - if (i > 0) { - this.declFile.Write(", "); - } - this.emitBaseExpression(bases, i); - } - } - }; - - DeclarationEmitter.prototype.emitAccessorDeclarationComments = function (funcDecl) { - if (!this.emitOptions.compilationSettings.emitComments) { - return; - } - - var accessors = TypeScript.PullHelpers.getGetterAndSetterFunction(funcDecl, this.semanticInfoChain, this.fileName); - var comments = []; - if (accessors.getter) { - comments = comments.concat(accessors.getter.getDocComments()); - } - if (accessors.setter) { - comments = comments.concat(accessors.setter.getDocComments()); - } - this.writeDeclarationComments(comments); - }; - - DeclarationEmitter.prototype.emitPropertyAccessorSignature = function (funcDecl) { - var accessorSymbol = TypeScript.PullHelpers.getAccessorSymbol(funcDecl, this.semanticInfoChain, this.fileName); - if (!TypeScript.hasFlag(funcDecl.getFunctionFlags(), 32 /* GetAccessor */) && accessorSymbol.getGetter()) { - return false; - } - - this.emitAccessorDeclarationComments(funcDecl); - this.emitDeclFlags(TypeScript.ToDeclFlags(funcDecl.getFunctionFlags()), "var"); - this.declFile.Write(funcDecl.name.actualText); - if (this.canEmitTypeAnnotationSignature(TypeScript.ToDeclFlags(funcDecl.getFunctionFlags()))) { - this.declFile.Write(" : "); - var type = accessorSymbol.getType(); - this.emitTypeSignature(type); - } - this.declFile.WriteLine(";"); - - return false; - }; - - DeclarationEmitter.prototype.emitClassMembersFromConstructorDefinition = function (funcDecl) { - if (funcDecl.arguments) { - var argsLen = funcDecl.arguments.members.length; - if (funcDecl.variableArgList) { - argsLen--; - } - - for (var i = 0; i < argsLen; i++) { - var argDecl = funcDecl.arguments.members[i]; - if (TypeScript.hasFlag(argDecl.getVarFlags(), 256 /* Property */)) { - this.emitDeclarationComments(argDecl); - this.emitDeclFlags(TypeScript.ToDeclFlags(argDecl.getVarFlags()), "var"); - this.declFile.Write(argDecl.id.actualText); - - if (this.canEmitTypeAnnotationSignature(TypeScript.ToDeclFlags(argDecl.getVarFlags()))) { - this.emitTypeOfBoundDecl(argDecl); - } - this.declFile.WriteLine(";"); - } - } - } - }; - - DeclarationEmitter.prototype.ClassDeclarationCallback = function (pre, classDecl) { - if (!this.canEmitPrePostAstSignature(TypeScript.ToDeclFlags(classDecl.getVarFlags()), classDecl, pre)) { - return false; - } - - if (pre) { - var className = classDecl.name.actualText; - this.emitDeclarationComments(classDecl); - this.emitDeclFlags(TypeScript.ToDeclFlags(classDecl.getVarFlags()), "class"); - this.declFile.Write(className); - this.pushDeclarationContainer(classDecl); - this.emitTypeParameters(classDecl.typeParameters); - this.emitBaseList(classDecl, true); - this.emitBaseList(classDecl, false); - this.declFile.WriteLine(" {"); - - this.indenter.increaseIndent(); - if (classDecl.constructorDecl) { - this.emitClassMembersFromConstructorDefinition(classDecl.constructorDecl); - } - } else { - this.indenter.decreaseIndent(); - this.popDeclarationContainer(classDecl); - - this.emitIndent(); - this.declFile.WriteLine("}"); - } - - return true; - }; - - DeclarationEmitter.prototype.emitTypeParameters = function (typeParams, funcSignature) { - if (!typeParams || !typeParams.members.length) { - return; - } - - this.declFile.Write("<"); - var containerAst = this.getAstDeclarationContainer(); - var containerDecl = this.semanticInfoChain.getDeclForAST(containerAst, this.fileName); - var containerSymbol = containerDecl.getSymbol(); - var typars; - if (funcSignature) { - typars = funcSignature.getTypeParameters(); - } else { - typars = containerSymbol.getTypeArguments(); - if (!typars || !typars.length) { - typars = containerSymbol.getTypeParameters(); - } - } - - for (var i = 0; i < typars.length; i++) { - if (i) { - this.declFile.Write(", "); - } - - var memberName = typars[i].getScopedNameEx(containerSymbol, true); - this.emitTypeNamesMember(memberName); - } - - this.declFile.Write(">"); - }; - - DeclarationEmitter.prototype.InterfaceDeclarationCallback = function (pre, interfaceDecl) { - if (!this.canEmitPrePostAstSignature(TypeScript.ToDeclFlags(interfaceDecl.getVarFlags()), interfaceDecl, pre)) { - return false; - } - - if (pre) { - var interfaceName = interfaceDecl.name.actualText; - this.emitDeclarationComments(interfaceDecl); - this.emitDeclFlags(TypeScript.ToDeclFlags(interfaceDecl.getVarFlags()), "interface"); - this.declFile.Write(interfaceName); - this.pushDeclarationContainer(interfaceDecl); - this.emitTypeParameters(interfaceDecl.typeParameters); - this.emitBaseList(interfaceDecl, true); - this.declFile.WriteLine(" {"); - - this.indenter.increaseIndent(); - } else { - this.indenter.decreaseIndent(); - this.popDeclarationContainer(interfaceDecl); - - this.emitIndent(); - this.declFile.WriteLine("}"); - } - - return true; - }; - - DeclarationEmitter.prototype.ImportDeclarationCallback = function (pre, importDeclAST) { - if (pre) { - var importDecl = this.semanticInfoChain.getDeclForAST(importDeclAST, this.fileName); - var importSymbol = importDecl.getSymbol(); - if (importSymbol.getTypeUsedExternally() || TypeScript.PullContainerTypeSymbol.usedAsSymbol(importSymbol.getContainer(), importSymbol)) { - this.emitDeclarationComments(importDeclAST); - this.emitIndent(); - this.declFile.Write("import "); - - this.declFile.Write(importDeclAST.id.actualText + " = "); - if (importDeclAST.isDynamicImport) { - this.declFile.WriteLine("require(" + importDeclAST.getAliasName() + ");"); - } else { - this.declFile.WriteLine(importDeclAST.getAliasName() + ";"); - } - } - } - - return false; - }; - - DeclarationEmitter.prototype.emitEnumSignature = function (moduleDecl) { - if (!this.canEmitSignature(TypeScript.ToDeclFlags(moduleDecl.getModuleFlags()), moduleDecl)) { - return false; - } - - this.emitDeclarationComments(moduleDecl); - this.emitDeclFlags(TypeScript.ToDeclFlags(moduleDecl.getModuleFlags()), "enum"); - this.declFile.WriteLine(moduleDecl.name.actualText + " {"); - - this.indenter.increaseIndent(); - var membersLen = moduleDecl.members.members.length; - for (var j = 0; j < membersLen; j++) { - var memberDecl = moduleDecl.members.members[j]; - if (memberDecl.nodeType === 97 /* VariableStatement */ && !TypeScript.hasFlag(memberDecl.getFlags(), 32 /* EnumMapElement */)) { - var variableStatement = memberDecl; - this.emitDeclarationComments(memberDecl); - this.emitIndent(); - this.declFile.WriteLine((variableStatement.declaration.declarators.members[0]).id.actualText + ","); - } - } - this.indenter.decreaseIndent(); - - this.emitIndent(); - this.declFile.WriteLine("}"); - - return false; - }; - - DeclarationEmitter.prototype.ModuleDeclarationCallback = function (pre, moduleDecl) { - if (TypeScript.hasFlag(moduleDecl.getModuleFlags(), 256 /* IsWholeFile */)) { - if (TypeScript.hasFlag(moduleDecl.getModuleFlags(), 512 /* IsDynamic */)) { - if (pre) { - if (!this.emitOptions.outputMany) { - this.singleDeclFile = this.declFile; - TypeScript.CompilerDiagnostics.assert(this.indenter.indentAmt === 0, "Indent has to be 0 when outputing new file"); - - var declareFileName = this.emitOptions.mapOutputFileName(this.fileName, TypeScript.TypeScriptCompiler.mapToDTSFileName); - var useUTF8InOutputfile = moduleDecl.containsUnicodeChar || (this.emitOptions.compilationSettings.emitComments && moduleDecl.containsUnicodeCharInComment); - - this.declFile = new TextWriter(this.emitOptions.ioHost, declareFileName, this.writeByteOrderMark); - } - this.pushDeclarationContainer(moduleDecl); - } else { - if (!this.emitOptions.outputMany) { - TypeScript.CompilerDiagnostics.assert(this.singleDeclFile !== this.declFile, "singleDeclFile cannot be null as we are going to revert back to it"); - TypeScript.CompilerDiagnostics.assert(this.indenter.indentAmt === 0, "Indent has to be 0 when outputing new file"); - - try { - this.declFile.Close(); - } catch (e) { - TypeScript.Emitter.throwEmitterError(e); - } - - this.declFile = this.singleDeclFile; - } - - this.popDeclarationContainer(moduleDecl); - } - } - - return true; - } - - if (moduleDecl.isEnum()) { - if (pre) { - this.emitEnumSignature(moduleDecl); - } - return false; - } - - if (!this.canEmitPrePostAstSignature(TypeScript.ToDeclFlags(moduleDecl.getModuleFlags()), moduleDecl, pre)) { - return false; - } - - if (pre) { - if (this.emitDottedModuleName()) { - this.dottedModuleEmit += "."; - } else { - this.dottedModuleEmit = this.getDeclFlagsString(TypeScript.ToDeclFlags(moduleDecl.getModuleFlags()), "module"); - } - - this.dottedModuleEmit += moduleDecl.name.actualText; - - var isCurrentModuleDotted = (moduleDecl.members.members.length === 1 && moduleDecl.members.members[0].nodeType === 15 /* ModuleDeclaration */ && !(moduleDecl.members.members[0]).isEnum() && TypeScript.hasFlag((moduleDecl.members.members[0]).getModuleFlags(), 1 /* Exported */)); - - var moduleDeclComments = moduleDecl.getDocComments(); - isCurrentModuleDotted = isCurrentModuleDotted && (moduleDeclComments === null || moduleDeclComments.length === 0); - - this.isDottedModuleName.push(isCurrentModuleDotted); - this.pushDeclarationContainer(moduleDecl); - - if (!isCurrentModuleDotted) { - this.emitDeclarationComments(moduleDecl); - this.declFile.Write(this.dottedModuleEmit); - this.declFile.WriteLine(" {"); - this.indenter.increaseIndent(); - } - } else { - if (!this.emitDottedModuleName()) { - this.indenter.decreaseIndent(); - this.emitIndent(); - this.declFile.WriteLine("}"); - } - - this.popDeclarationContainer(moduleDecl); - this.isDottedModuleName.pop(); - } - - return true; - }; - - DeclarationEmitter.prototype.ExportAssignmentCallback = function (pre, ast) { - if (pre) { - this.emitIndent(); - this.declFile.Write("export = "); - this.declFile.Write((ast).id.actualText); - this.declFile.WriteLine(";"); - } - - return false; - }; - - DeclarationEmitter.prototype.ScriptCallback = function (pre, script) { - if (pre) { - if (this.emitOptions.outputMany) { - for (var i = 0; i < script.referencedFiles.length; i++) { - var referencePath = script.referencedFiles[i].path; - var declareFileName; - if (TypeScript.isRooted(referencePath)) { - declareFileName = this.emitOptions.mapOutputFileName(referencePath, TypeScript.TypeScriptCompiler.mapToDTSFileName); - } else { - declareFileName = TypeScript.getDeclareFilePath(script.referencedFiles[i].path); - } - this.declFile.WriteLine('/// '); - } - } - this.pushDeclarationContainer(script); - } else { - this.popDeclarationContainer(script); - } - return true; - }; - - DeclarationEmitter.prototype.DefaultCallback = function (pre, ast) { - return !ast.isStatement(); - }; - return DeclarationEmitter; - })(); - TypeScript.DeclarationEmitter = DeclarationEmitter; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var BloomFilter = (function () { - function BloomFilter(expectedCount) { - var m = Math.max(1, BloomFilter.computeM(expectedCount)); - var k = Math.max(1, BloomFilter.computeK(expectedCount)); - ; - - var sizeInEvenBytes = (m + 7) & ~7; - - this.bitArray = []; - for (var i = 0, len = sizeInEvenBytes; i < len; i++) { - this.bitArray[i] = false; - } - this.hashFunctionCount = k; - } - BloomFilter.computeM = function (expectedCount) { - var p = BloomFilter.falsePositiveProbability; - var n = expectedCount; - - var numerator = n * Math.log(p); - var denominator = Math.log(1.0 / Math.pow(2.0, Math.log(2.0))); - return Math.ceil(numerator / denominator); - }; - - BloomFilter.computeK = function (expectedCount) { - var n = expectedCount; - var m = BloomFilter.computeM(expectedCount); - - var temp = Math.log(2.0) * m / n; - return Math.round(temp); - }; - - BloomFilter.prototype.computeHash = function (key, seed) { - var m = 0x5bd1e995; - var r = 24; - - var numberOfCharsLeft = key.length; - var h = Math.abs(seed ^ numberOfCharsLeft); - - var index = 0; - while (numberOfCharsLeft >= 2) { - var c1 = this.getCharacter(key, index); - var c2 = this.getCharacter(key, index + 1); - - var k = Math.abs(c1 | (c2 << 16)); - - k = TypeScript.IntegerUtilities.integerMultiplyLow32Bits(k, m); - k ^= k >> r; - k = TypeScript.IntegerUtilities.integerMultiplyLow32Bits(k, m); - - h = TypeScript.IntegerUtilities.integerMultiplyLow32Bits(h, m); - h ^= k; - - index += 2; - numberOfCharsLeft -= 2; - } - - if (numberOfCharsLeft == 1) { - h ^= this.getCharacter(key, index); - h = TypeScript.IntegerUtilities.integerMultiplyLow32Bits(h, m); - } - - h ^= h >> 13; - h = TypeScript.IntegerUtilities.integerMultiplyLow32Bits(h, m); - h ^= h >> 15; - - return Math.round(h); - }; - - BloomFilter.prototype.getCharacter = function (key, index) { - return key.charCodeAt(index); - }; - - BloomFilter.prototype.addKeys = function (keys) { - for (var name in keys) { - this.add(name); - } - }; - - BloomFilter.prototype.add = function (value) { - for (var i = 0; i < this.hashFunctionCount; i++) { - var hash = this.computeHash(value, i); - hash = hash % this.bitArray.length; - this.bitArray[Math.abs(hash)] = true; - } - }; - - BloomFilter.prototype.probablyContains = function (value) { - for (var i = 0; i < this.hashFunctionCount; i++) { - var hash = this.computeHash(value, i); - hash = hash % this.bitArray.length; - if (!this.bitArray[Math.abs(hash)]) { - return false; - } - } - - return true; - }; - - BloomFilter.prototype.isEquivalent = function (filter) { - return BloomFilter.isEquivalent(this.bitArray, filter.bitArray) && this.hashFunctionCount == filter.hashFunctionCount; - }; - - BloomFilter.isEquivalent = function (array1, array2) { - if (array1.length != array2.length) { - return false; - } - - for (var i = 0; i < array1.length; i++) { - if (array1[i] != array2[i]) { - return false; - } - } - - return true; - }; - BloomFilter.falsePositiveProbability = 0.0001; - return BloomFilter; - })(); - TypeScript.BloomFilter = BloomFilter; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var IdentifierWalker = (function (_super) { - __extends(IdentifierWalker, _super); - function IdentifierWalker(list) { - _super.call(this); - this.list = list; - } - IdentifierWalker.prototype.visitToken = function (token) { - this.list[token.text()] = true; - }; - return IdentifierWalker; - })(TypeScript.SyntaxWalker); - TypeScript.IdentifierWalker = IdentifierWalker; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var DataMap = (function () { - function DataMap() { - this.map = {}; - } - DataMap.prototype.link = function (id, data) { - this.map[id] = data; - }; - - DataMap.prototype.unlink = function (id) { - this.map[id] = undefined; - }; - - DataMap.prototype.read = function (id) { - return this.map[id]; - }; - - DataMap.prototype.flush = function () { - this.map = {}; - }; - - DataMap.prototype.unpatch = function () { - return null; - }; - return DataMap; - })(); - TypeScript.DataMap = DataMap; - - var PatchedDataMap = (function (_super) { - __extends(PatchedDataMap, _super); - function PatchedDataMap(parent) { - _super.call(this); - this.parent = parent; - this.diffs = {}; - } - PatchedDataMap.prototype.link = function (id, data) { - this.diffs[id] = data; - }; - - PatchedDataMap.prototype.unlink = function (id) { - this.diffs[id] = undefined; - }; - - PatchedDataMap.prototype.read = function (id) { - var data = this.diffs[id]; - - if (data) { - return data; - } - - return this.parent.read(id); - }; - - PatchedDataMap.prototype.flush = function () { - this.diffs = {}; - }; - - PatchedDataMap.prototype.unpatch = function () { - this.flush(); - return this.parent; - }; - return PatchedDataMap; - })(DataMap); - TypeScript.PatchedDataMap = PatchedDataMap; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (PullElementFlags) { - PullElementFlags[PullElementFlags["None"] = 0] = "None"; - PullElementFlags[PullElementFlags["Exported"] = 1] = "Exported"; - PullElementFlags[PullElementFlags["Private"] = 1 << 1] = "Private"; - PullElementFlags[PullElementFlags["Public"] = 1 << 2] = "Public"; - PullElementFlags[PullElementFlags["Ambient"] = 1 << 3] = "Ambient"; - PullElementFlags[PullElementFlags["Static"] = 1 << 4] = "Static"; - PullElementFlags[PullElementFlags["GetAccessor"] = 1 << 5] = "GetAccessor"; - PullElementFlags[PullElementFlags["SetAccessor"] = 1 << 6] = "SetAccessor"; - PullElementFlags[PullElementFlags["Optional"] = 1 << 7] = "Optional"; - PullElementFlags[PullElementFlags["Call"] = 1 << 8] = "Call"; - PullElementFlags[PullElementFlags["Constructor"] = 1 << 9] = "Constructor"; - PullElementFlags[PullElementFlags["Index"] = 1 << 10] = "Index"; - PullElementFlags[PullElementFlags["Signature"] = 1 << 11] = "Signature"; - PullElementFlags[PullElementFlags["Enum"] = 1 << 12] = "Enum"; - PullElementFlags[PullElementFlags["FatArrow"] = 1 << 13] = "FatArrow"; - - PullElementFlags[PullElementFlags["ClassConstructorVariable"] = 1 << 14] = "ClassConstructorVariable"; - PullElementFlags[PullElementFlags["InitializedModule"] = 1 << 15] = "InitializedModule"; - PullElementFlags[PullElementFlags["InitializedDynamicModule"] = 1 << 16] = "InitializedDynamicModule"; - PullElementFlags[PullElementFlags["InitializedEnum"] = 1 << 17] = "InitializedEnum"; - - PullElementFlags[PullElementFlags["MustCaptureThis"] = 1 << 18] = "MustCaptureThis"; - PullElementFlags[PullElementFlags["Constant"] = 1 << 19] = "Constant"; - - PullElementFlags[PullElementFlags["ExpressionElement"] = 1 << 20] = "ExpressionElement"; - - PullElementFlags[PullElementFlags["DeclaredInAWithBlock"] = 1 << 21] = "DeclaredInAWithBlock"; - - PullElementFlags[PullElementFlags["ImplicitVariable"] = PullElementFlags.ClassConstructorVariable | PullElementFlags.InitializedModule | PullElementFlags.InitializedDynamicModule | PullElementFlags.InitializedEnum] = "ImplicitVariable"; - PullElementFlags[PullElementFlags["SomeInitializedModule"] = PullElementFlags.InitializedModule | PullElementFlags.InitializedDynamicModule | PullElementFlags.InitializedEnum] = "SomeInitializedModule"; - })(TypeScript.PullElementFlags || (TypeScript.PullElementFlags = {})); - var PullElementFlags = TypeScript.PullElementFlags; - - (function (PullElementKind) { - PullElementKind[PullElementKind["None"] = 0] = "None"; - PullElementKind[PullElementKind["Global"] = 0] = "Global"; - - PullElementKind[PullElementKind["Script"] = 1] = "Script"; - PullElementKind[PullElementKind["Primitive"] = 1 << 1] = "Primitive"; - - PullElementKind[PullElementKind["Container"] = 1 << 2] = "Container"; - PullElementKind[PullElementKind["Class"] = 1 << 3] = "Class"; - PullElementKind[PullElementKind["Interface"] = 1 << 4] = "Interface"; - PullElementKind[PullElementKind["DynamicModule"] = 1 << 5] = "DynamicModule"; - PullElementKind[PullElementKind["Enum"] = 1 << 6] = "Enum"; - PullElementKind[PullElementKind["Array"] = 1 << 7] = "Array"; - PullElementKind[PullElementKind["TypeAlias"] = 1 << 8] = "TypeAlias"; - PullElementKind[PullElementKind["ObjectLiteral"] = 1 << 9] = "ObjectLiteral"; - - PullElementKind[PullElementKind["Variable"] = 1 << 10] = "Variable"; - PullElementKind[PullElementKind["Parameter"] = 1 << 11] = "Parameter"; - PullElementKind[PullElementKind["Property"] = 1 << 12] = "Property"; - PullElementKind[PullElementKind["TypeParameter"] = 1 << 13] = "TypeParameter"; - - PullElementKind[PullElementKind["Function"] = 1 << 14] = "Function"; - PullElementKind[PullElementKind["ConstructorMethod"] = 1 << 15] = "ConstructorMethod"; - PullElementKind[PullElementKind["Method"] = 1 << 16] = "Method"; - PullElementKind[PullElementKind["FunctionExpression"] = 1 << 17] = "FunctionExpression"; - - PullElementKind[PullElementKind["GetAccessor"] = 1 << 18] = "GetAccessor"; - PullElementKind[PullElementKind["SetAccessor"] = 1 << 19] = "SetAccessor"; - - PullElementKind[PullElementKind["CallSignature"] = 1 << 20] = "CallSignature"; - PullElementKind[PullElementKind["ConstructSignature"] = 1 << 21] = "ConstructSignature"; - PullElementKind[PullElementKind["IndexSignature"] = 1 << 22] = "IndexSignature"; - - PullElementKind[PullElementKind["ObjectType"] = 1 << 23] = "ObjectType"; - PullElementKind[PullElementKind["FunctionType"] = 1 << 24] = "FunctionType"; - PullElementKind[PullElementKind["ConstructorType"] = 1 << 25] = "ConstructorType"; - - PullElementKind[PullElementKind["EnumMember"] = 1 << 26] = "EnumMember"; - PullElementKind[PullElementKind["ErrorType"] = 1 << 27] = "ErrorType"; - - PullElementKind[PullElementKind["Expression"] = 1 << 28] = "Expression"; - - PullElementKind[PullElementKind["WithBlock"] = 1 << 29] = "WithBlock"; - PullElementKind[PullElementKind["CatchBlock"] = 1 << 30] = "CatchBlock"; - - PullElementKind[PullElementKind["All"] = PullElementKind.Script | PullElementKind.Global | PullElementKind.Primitive | PullElementKind.Container | PullElementKind.Class | PullElementKind.Interface | PullElementKind.DynamicModule | PullElementKind.Enum | PullElementKind.Array | PullElementKind.TypeAlias | PullElementKind.ObjectLiteral | PullElementKind.Variable | PullElementKind.Parameter | PullElementKind.Property | PullElementKind.TypeParameter | PullElementKind.Function | PullElementKind.ConstructorMethod | PullElementKind.Method | PullElementKind.FunctionExpression | PullElementKind.GetAccessor | PullElementKind.SetAccessor | PullElementKind.CallSignature | PullElementKind.ConstructSignature | PullElementKind.IndexSignature | PullElementKind.ObjectType | PullElementKind.FunctionType | PullElementKind.ConstructorType | PullElementKind.EnumMember | PullElementKind.ErrorType | PullElementKind.Expression | PullElementKind.WithBlock | PullElementKind.CatchBlock] = "All"; - - PullElementKind[PullElementKind["SomeFunction"] = PullElementKind.Function | PullElementKind.ConstructorMethod | PullElementKind.Method | PullElementKind.FunctionExpression | PullElementKind.GetAccessor | PullElementKind.SetAccessor | PullElementKind.CallSignature | PullElementKind.ConstructSignature | PullElementKind.IndexSignature] = "SomeFunction"; - - PullElementKind[PullElementKind["SomeValue"] = PullElementKind.Variable | PullElementKind.Parameter | PullElementKind.Property | PullElementKind.EnumMember | PullElementKind.SomeFunction] = "SomeValue"; - - PullElementKind[PullElementKind["SomeType"] = PullElementKind.Script | PullElementKind.Global | PullElementKind.Primitive | PullElementKind.Class | PullElementKind.Interface | PullElementKind.Enum | PullElementKind.Array | PullElementKind.ObjectType | PullElementKind.FunctionType | PullElementKind.ConstructorType | PullElementKind.TypeParameter | PullElementKind.ErrorType] = "SomeType"; - - PullElementKind[PullElementKind["AcceptableAlias"] = PullElementKind.Variable | PullElementKind.SomeFunction | PullElementKind.Class | PullElementKind.Interface | PullElementKind.Enum | PullElementKind.Container | PullElementKind.ObjectType | PullElementKind.FunctionType | PullElementKind.ConstructorType] = "AcceptableAlias"; - - PullElementKind[PullElementKind["SomeContainer"] = PullElementKind.Container | PullElementKind.DynamicModule | PullElementKind.TypeAlias] = "SomeContainer"; - - PullElementKind[PullElementKind["SomeBlock"] = PullElementKind.WithBlock | PullElementKind.CatchBlock] = "SomeBlock"; - - PullElementKind[PullElementKind["SomeSignature"] = PullElementKind.CallSignature | PullElementKind.ConstructSignature | PullElementKind.IndexSignature] = "SomeSignature"; - - PullElementKind[PullElementKind["SomeAccessor"] = PullElementKind.GetAccessor | PullElementKind.SetAccessor] = "SomeAccessor"; - - PullElementKind[PullElementKind["SomeTypeReference"] = PullElementKind.Interface | PullElementKind.ObjectType | PullElementKind.FunctionType | PullElementKind.ConstructorType] = "SomeTypeReference"; - - PullElementKind[PullElementKind["SomeLHS"] = PullElementKind.Variable | PullElementKind.Property | PullElementKind.Parameter | PullElementKind.SetAccessor | PullElementKind.Method] = "SomeLHS"; - - PullElementKind[PullElementKind["InterfaceTypeExtension"] = PullElementKind.Interface | PullElementKind.Class | PullElementKind.Enum] = "InterfaceTypeExtension"; - PullElementKind[PullElementKind["ClassTypeExtension"] = PullElementKind.Interface | PullElementKind.Class] = "ClassTypeExtension"; - PullElementKind[PullElementKind["EnumTypeExtension"] = PullElementKind.Interface | PullElementKind.Enum] = "EnumTypeExtension"; - })(TypeScript.PullElementKind || (TypeScript.PullElementKind = {})); - var PullElementKind = TypeScript.PullElementKind; - - (function (SymbolLinkKind) { - SymbolLinkKind[SymbolLinkKind["TypedAs"] = 0] = "TypedAs"; - SymbolLinkKind[SymbolLinkKind["ContextuallyTypedAs"] = 1] = "ContextuallyTypedAs"; - SymbolLinkKind[SymbolLinkKind["ProvidesInferredType"] = 2] = "ProvidesInferredType"; - SymbolLinkKind[SymbolLinkKind["ArrayType"] = 3] = "ArrayType"; - - SymbolLinkKind[SymbolLinkKind["ArrayOf"] = 4] = "ArrayOf"; - - SymbolLinkKind[SymbolLinkKind["PublicMember"] = 5] = "PublicMember"; - SymbolLinkKind[SymbolLinkKind["PrivateMember"] = 6] = "PrivateMember"; - - SymbolLinkKind[SymbolLinkKind["ConstructorMethod"] = 7] = "ConstructorMethod"; - - SymbolLinkKind[SymbolLinkKind["Aliases"] = 8] = "Aliases"; - SymbolLinkKind[SymbolLinkKind["ExportAliases"] = 9] = "ExportAliases"; - - SymbolLinkKind[SymbolLinkKind["ContainedBy"] = 10] = "ContainedBy"; - - SymbolLinkKind[SymbolLinkKind["Extends"] = 11] = "Extends"; - SymbolLinkKind[SymbolLinkKind["Implements"] = 12] = "Implements"; - - SymbolLinkKind[SymbolLinkKind["Parameter"] = 13] = "Parameter"; - SymbolLinkKind[SymbolLinkKind["ReturnType"] = 14] = "ReturnType"; - - SymbolLinkKind[SymbolLinkKind["CallSignature"] = 15] = "CallSignature"; - SymbolLinkKind[SymbolLinkKind["ConstructSignature"] = 16] = "ConstructSignature"; - SymbolLinkKind[SymbolLinkKind["IndexSignature"] = 17] = "IndexSignature"; - - SymbolLinkKind[SymbolLinkKind["TypeParameter"] = 18] = "TypeParameter"; - SymbolLinkKind[SymbolLinkKind["TypeArgument"] = 19] = "TypeArgument"; - SymbolLinkKind[SymbolLinkKind["TypeParameterSpecializedTo"] = 20] = "TypeParameterSpecializedTo"; - SymbolLinkKind[SymbolLinkKind["SpecializedTo"] = 21] = "SpecializedTo"; - - SymbolLinkKind[SymbolLinkKind["TypeConstraint"] = 22] = "TypeConstraint"; - - SymbolLinkKind[SymbolLinkKind["ContributesToExpression"] = 23] = "ContributesToExpression"; - - SymbolLinkKind[SymbolLinkKind["GetterFunction"] = 24] = "GetterFunction"; - SymbolLinkKind[SymbolLinkKind["SetterFunction"] = 25] = "SetterFunction"; - })(TypeScript.SymbolLinkKind || (TypeScript.SymbolLinkKind = {})); - var SymbolLinkKind = TypeScript.SymbolLinkKind; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - TypeScript.pullDeclID = 0; - TypeScript.lastBoundPullDeclId = 0; - - var PullDecl = (function () { - function PullDecl(declName, displayName, declType, declFlags, span, scriptName) { - this.symbol = null; - this.declGroups = new TypeScript.BlockIntrinsics(); - this.signatureSymbol = null; - this.specializingSignatureSymbol = null; - this.childDecls = []; - this.typeParameters = []; - this.childDeclTypeCache = new TypeScript.BlockIntrinsics(); - this.childDeclValueCache = new TypeScript.BlockIntrinsics(); - this.childDeclNamespaceCache = new TypeScript.BlockIntrinsics(); - this.childDeclTypeParameterCache = new TypeScript.BlockIntrinsics(); - this.declID = TypeScript.pullDeclID++; - this.declFlags = 0 /* None */; - this.diagnostics = null; - this.parentDecl = null; - this._parentPath = null; - this._isBound = false; - this.synthesizedValDecl = null; - this.declName = declName; - this.declType = declType; - this.declFlags = declFlags; - this.span = span; - this.scriptName = scriptName; - - if (displayName !== this.declName) { - this.declDisplayName = displayName; - } - } - PullDecl.prototype.getDeclID = function () { - return this.declID; - }; - - PullDecl.prototype.getName = function () { - return this.declName; - }; - PullDecl.prototype.getKind = function () { - return this.declType; - }; - - PullDecl.prototype.getDisplayName = function () { - return this.declDisplayName === undefined ? this.declName : this.declDisplayName; - }; - - PullDecl.prototype.setSymbol = function (symbol) { - this.symbol = symbol; - }; - - PullDecl.prototype.ensureSymbolIsBound = function (bindSignatureSymbol) { - if (typeof bindSignatureSymbol === "undefined") { bindSignatureSymbol = false; } - if (!((bindSignatureSymbol && this.signatureSymbol) || this.symbol) && !this._isBound && this.declType != 1 /* Script */) { - var prevUnit = TypeScript.globalBinder.semanticInfo; - TypeScript.globalBinder.setUnit(this.scriptName); - TypeScript.globalBinder.bindDeclToPullSymbol(this); - if (prevUnit) { - TypeScript.globalBinder.setUnit(prevUnit.getPath()); - } - } - }; - - PullDecl.prototype.getSymbol = function () { - if (this.declType == 1 /* Script */) { - return null; - } - - this.ensureSymbolIsBound(); - - return this.symbol; - }; - - PullDecl.prototype.hasSymbol = function () { - return this.symbol != null; - }; - - PullDecl.prototype.setSignatureSymbol = function (signature) { - this.signatureSymbol = signature; - }; - PullDecl.prototype.getSignatureSymbol = function () { - this.ensureSymbolIsBound(true); - - return this.signatureSymbol; - }; - - PullDecl.prototype.hasSignature = function () { - return this.signatureSymbol != null; - }; - - PullDecl.prototype.setSpecializingSignatureSymbol = function (signature) { - this.specializingSignatureSymbol = signature; - }; - PullDecl.prototype.getSpecializingSignatureSymbol = function () { - if (this.specializingSignatureSymbol) { - return this.specializingSignatureSymbol; - } - - return this.signatureSymbol; - }; - - PullDecl.prototype.getFlags = function () { - return this.declFlags; - }; - PullDecl.prototype.setFlags = function (flags) { - this.declFlags = flags; - }; - - PullDecl.prototype.getSpan = function () { - return this.span; - }; - PullDecl.prototype.setSpan = function (span) { - this.span = span; - }; - - PullDecl.prototype.getScriptName = function () { - return this.scriptName; - }; - - PullDecl.prototype.setValueDecl = function (valDecl) { - this.synthesizedValDecl = valDecl; - }; - PullDecl.prototype.getValueDecl = function () { - return this.synthesizedValDecl; - }; - - PullDecl.prototype.isEqual = function (other) { - return (this.declName === other.declName) && (this.declType === other.declType) && (this.declFlags === other.declFlags) && (this.scriptName === other.scriptName) && (this.span.start() === other.span.start()) && (this.span.end() === other.span.end()); - }; - - PullDecl.prototype.getParentDecl = function () { - return this.parentDecl; - }; - - PullDecl.prototype.setParentDecl = function (parentDecl) { - this.parentDecl = parentDecl; - }; - - PullDecl.prototype.addDiagnostic = function (diagnostic) { - if (diagnostic) { - if (!this.diagnostics) { - this.diagnostics = []; - } - - this.diagnostics[this.diagnostics.length] = diagnostic; - } - }; - - PullDecl.prototype.getDiagnostics = function () { - return this.diagnostics; - }; - - PullDecl.prototype.setErrors = function (diagnostics) { - if (diagnostics) { - this.diagnostics = []; - - for (var i = 0; i < diagnostics.length; i++) { - diagnostics[i].adjustOffset(this.span.start()); - this.diagnostics[this.diagnostics.length] = diagnostics[i]; - } - } - }; - - PullDecl.prototype.resetErrors = function () { - this.diagnostics = []; - }; - - PullDecl.prototype.getChildDeclCache = function (declKind) { - return declKind === 8192 /* TypeParameter */ ? this.childDeclTypeParameterCache : TypeScript.hasFlag(declKind, TypeScript.PullElementKind.SomeContainer) ? this.childDeclNamespaceCache : TypeScript.hasFlag(declKind, TypeScript.PullElementKind.SomeType) ? this.childDeclTypeCache : this.childDeclValueCache; - }; - - PullDecl.prototype.addChildDecl = function (childDecl) { - if (childDecl.getKind() === 8192 /* TypeParameter */) { - this.typeParameters[this.typeParameters.length] = childDecl; - } else { - this.childDecls[this.childDecls.length] = childDecl; - } - - var declName = childDecl.getName(); - var cache = this.getChildDeclCache(childDecl.getKind()); - var childrenOfName = cache[declName]; - if (!childrenOfName) { - childrenOfName = []; - } - - childrenOfName.push(childDecl); - cache[declName] = childrenOfName; - }; - - PullDecl.prototype.searchChildDecls = function (declName, searchKind) { - var cache = (searchKind & TypeScript.PullElementKind.SomeType) ? this.childDeclTypeCache : (searchKind & TypeScript.PullElementKind.SomeContainer) ? this.childDeclNamespaceCache : this.childDeclValueCache; - - var cacheVal = cache[declName]; - - if (cacheVal) { - return cacheVal; - } else { - if (searchKind & TypeScript.PullElementKind.SomeType) { - cacheVal = this.childDeclTypeParameterCache[declName]; - - if (cacheVal) { - return cacheVal; - } - } - - return []; - } - }; - - PullDecl.prototype.getChildDecls = function () { - return this.childDecls; - }; - PullDecl.prototype.getTypeParameters = function () { - return this.typeParameters; - }; - - PullDecl.prototype.addVariableDeclToGroup = function (decl) { - var declGroup = this.declGroups[decl.getName()]; - if (declGroup) { - declGroup.addDecl(decl); - } else { - declGroup = new PullDeclGroup(decl.getName()); - declGroup.addDecl(decl); - this.declGroups[decl.getName()] = declGroup; - } - }; - - PullDecl.prototype.getVariableDeclGroups = function () { - var declGroups = []; - - for (var declName in this.declGroups) { - if (this.declGroups[declName]) { - declGroups[declGroups.length] = this.declGroups[declName].getDecls(); - } - } - - return declGroups; - }; - - PullDecl.prototype.getParentPath = function () { - return this._parentPath; - }; - - PullDecl.prototype.setParentPath = function (path) { - this._parentPath = path; - }; - - PullDecl.prototype.setIsBound = function (isBinding) { - this._isBound = isBinding; - }; - - PullDecl.prototype.isBound = function () { - return this._isBound; - }; - return PullDecl; - })(); - TypeScript.PullDecl = PullDecl; - - var PullFunctionExpressionDecl = (function (_super) { - __extends(PullFunctionExpressionDecl, _super); - function PullFunctionExpressionDecl(expressionName, declFlags, span, scriptName) { - _super.call(this, "", "", 131072 /* FunctionExpression */, declFlags, span, scriptName); - this.functionExpressionName = expressionName; - } - PullFunctionExpressionDecl.prototype.getFunctionExpressionName = function () { - return this.functionExpressionName; - }; - return PullFunctionExpressionDecl; - })(PullDecl); - TypeScript.PullFunctionExpressionDecl = PullFunctionExpressionDecl; - - var PullDeclGroup = (function () { - function PullDeclGroup(name) { - this.name = name; - this._decls = []; - } - PullDeclGroup.prototype.addDecl = function (decl) { - if (decl.getName() === this.name) { - this._decls[this._decls.length] = decl; - } - }; - - PullDeclGroup.prototype.getDecls = function () { - return this._decls; - }; - return PullDeclGroup; - })(); - TypeScript.PullDeclGroup = PullDeclGroup; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - TypeScript.pullSymbolID = 0; - TypeScript.lastBoundPullSymbolID = 0; - TypeScript.globalTyvarID = 0; - - var PullSymbol = (function () { - function PullSymbol(name, declKind) { - this.pullSymbolID = TypeScript.pullSymbolID++; - this.outgoingLinks = new TypeScript.LinkList(); - this.incomingLinks = new TypeScript.LinkList(); - this.declarations = new TypeScript.LinkList(); - this.cachedPathIDs = {}; - this.cachedContainerLink = null; - this.cachedTypeLink = null; - this.cachedDeclarations = null; - this.hasBeenResolved = false; - this.isOptional = false; - this.inResolution = false; - this.isSynthesized = false; - this.isBound = false; - this.rebindingID = 0; - this.isVarArg = false; - this.isSpecialized = false; - this.isBeingSpecialized = false; - this.rootSymbol = null; - this.typeChangeUpdateVersion = -1; - this.addUpdateVersion = -1; - this.removeUpdateVersion = -1; - this.docComments = null; - this.isPrinting = false; - this.name = name; - this.declKind = declKind; - } - PullSymbol.prototype.getSymbolID = function () { - return this.pullSymbolID; - }; - - PullSymbol.prototype.isType = function () { - return (this.declKind & TypeScript.PullElementKind.SomeType) != 0; - }; - - PullSymbol.prototype.isSignature = function () { - return (this.declKind & TypeScript.PullElementKind.SomeSignature) != 0; - }; - - PullSymbol.prototype.isArray = function () { - return (this.declKind & 128 /* Array */) != 0; - }; - - PullSymbol.prototype.isPrimitive = function () { - return this.declKind === 2 /* Primitive */; - }; - - PullSymbol.prototype.isAccessor = function () { - return false; - }; - - PullSymbol.prototype.isError = function () { - return false; - }; - - PullSymbol.prototype.isAlias = function () { - return false; - }; - PullSymbol.prototype.isContainer = function () { - return false; - }; - - PullSymbol.prototype.findAliasedType = function (decls) { - for (var i = 0; i < decls.length; i++) { - var childDecls = decls[i].getChildDecls(); - for (var j = 0; j < childDecls.length; j++) { - if (childDecls[j].getKind() === 256 /* TypeAlias */) { - var symbol = childDecls[j].getSymbol(); - if (PullContainerTypeSymbol.usedAsSymbol(symbol, this)) { - return symbol; - } - } - } - } - - return null; - }; - - PullSymbol.prototype.getAliasedSymbol = function (scopeSymbol) { - if (!scopeSymbol) { - return null; - } - - var scopePath = scopeSymbol.pathToRoot(); - if (scopePath.length && scopePath[scopePath.length - 1].getKind() === 32 /* DynamicModule */) { - var decls = scopePath[scopePath.length - 1].getDeclarations(); - var symbol = this.findAliasedType(decls); - return symbol; - } - - return null; - }; - - PullSymbol.prototype.getName = function (scopeSymbol, useConstraintInName) { - var symbol = this.getAliasedSymbol(scopeSymbol); - if (symbol) { - return symbol.getName(); - } - - return this.name; - }; - - PullSymbol.prototype.getDisplayName = function (scopeSymbol, useConstraintInName) { - var symbol = this.getAliasedSymbol(scopeSymbol); - if (symbol) { - return symbol.getDisplayName(); - } - - return this.getDeclarations()[0].getDisplayName(); - }; - - PullSymbol.prototype.getKind = function () { - return this.declKind; - }; - PullSymbol.prototype.setKind = function (declType) { - this.declKind = declType; - }; - - PullSymbol.prototype.setIsOptional = function () { - this.isOptional = true; - }; - PullSymbol.prototype.getIsOptional = function () { - return this.isOptional; - }; - - PullSymbol.prototype.getIsVarArg = function () { - return this.isVarArg; - }; - PullSymbol.prototype.setIsVarArg = function () { - this.isVarArg = true; - }; - - PullSymbol.prototype.setIsSynthesized = function () { - this.isSynthesized = true; - }; - PullSymbol.prototype.getIsSynthesized = function () { - return this.isSynthesized; - }; - - PullSymbol.prototype.setIsSpecialized = function () { - this.isSpecialized = true; - this.isBeingSpecialized = false; - }; - PullSymbol.prototype.getIsSpecialized = function () { - return this.isSpecialized; - }; - PullSymbol.prototype.currentlyBeingSpecialized = function () { - return this.isBeingSpecialized; - }; - PullSymbol.prototype.setIsBeingSpecialized = function () { - this.isBeingSpecialized = true; - }; - PullSymbol.prototype.setValueIsBeingSpecialized = function (val) { - this.isBeingSpecialized = val; - }; - - PullSymbol.prototype.getRootSymbol = function () { - if (!this.rootSymbol) { - return this; - } - return this.rootSymbol; - }; - PullSymbol.prototype.setRootSymbol = function (symbol) { - this.rootSymbol = symbol; - }; - - PullSymbol.prototype.setIsBound = function (rebindingID) { - this.isBound = true; - this.rebindingID = rebindingID; - }; - - PullSymbol.prototype.getRebindingID = function () { - return this.rebindingID; - }; - - PullSymbol.prototype.getIsBound = function () { - return this.isBound; - }; - - PullSymbol.prototype.addCacheID = function (cacheID) { - if (!this.cachedPathIDs[cacheID]) { - this.cachedPathIDs[cacheID] = true; - } - }; - - PullSymbol.prototype.invalidateCachedIDs = function (cache) { - for (var id in this.cachedPathIDs) { - if (cache[id]) { - cache[id] = undefined; - } - } - }; - - PullSymbol.prototype.addDeclaration = function (decl) { - TypeScript.Debug.assert(!!decl); - - if (this.rootSymbol) { - return; - } - - this.declarations.addItem(decl); - - if (!this.cachedDeclarations) { - this.cachedDeclarations = [decl]; - } else { - this.cachedDeclarations[this.cachedDeclarations.length] = decl; - } - }; - - PullSymbol.prototype.getDeclarations = function () { - if (this.rootSymbol) { - return this.rootSymbol.getDeclarations(); - } - - if (!this.cachedDeclarations) { - this.cachedDeclarations = []; - } - - return this.cachedDeclarations; - }; - - PullSymbol.prototype.removeDeclaration = function (decl) { - if (this.rootSymbol) { - return; - } - - this.declarations.remove(function (d) { - return d === decl; - }); - this.cachedDeclarations = this.declarations.find(function (d) { - return d; - }); - }; - - PullSymbol.prototype.updateDeclarations = function (map, context) { - if (this.rootSymbol) { - return; - } - - this.declarations.update(map, context); - }; - - PullSymbol.prototype.addOutgoingLink = function (linkTo, kind) { - var link = new TypeScript.PullSymbolLink(this, linkTo, kind); - this.outgoingLinks.addItem(link); - linkTo.incomingLinks.addItem(link); - - return link; - }; - - PullSymbol.prototype.findOutgoingLinks = function (p) { - return this.outgoingLinks.find(p); - }; - - PullSymbol.prototype.findIncomingLinks = function (p) { - return this.incomingLinks.find(p); - }; - - PullSymbol.prototype.removeOutgoingLink = function (link) { - if (link) { - this.outgoingLinks.remove(function (p) { - return p === link; - }); - - if (link.end.incomingLinks) { - link.end.incomingLinks.remove(function (p) { - return p === link; - }); - } - } - }; - - PullSymbol.prototype.updateOutgoingLinks = function (map, context) { - if (this.outgoingLinks) { - this.outgoingLinks.update(map, context); - } - }; - - PullSymbol.prototype.updateIncomingLinks = function (map, context) { - if (this.incomingLinks) { - this.incomingLinks.update(map, context); - } - }; - - PullSymbol.prototype.removeAllLinks = function () { - var _this = this; - this.updateOutgoingLinks(function (item) { - return _this.removeOutgoingLink(item); - }, null); - this.updateIncomingLinks(function (item) { - return item.start.removeOutgoingLink(item); - }, null); - }; - - PullSymbol.prototype.setContainer = function (containerSymbol) { - var link = this.addOutgoingLink(containerSymbol, 10 /* ContainedBy */); - this.cachedContainerLink = link; - - containerSymbol.addContainedByLink(link); - }; - - PullSymbol.prototype.getContainer = function () { - if (this.cachedContainerLink) { - return this.cachedContainerLink.end; - } - - if (this.getIsSpecialized()) { - var specializations = this.findIncomingLinks(function (symbolLink) { - return symbolLink.kind == 21 /* SpecializedTo */; - }); - if (specializations.length == 1) { - return specializations[0].start.getContainer(); - } - } - - return null; - }; - - PullSymbol.prototype.unsetContainer = function () { - if (this.cachedContainerLink) { - this.removeOutgoingLink(this.cachedContainerLink); - } - - this.invalidate(); - }; - - PullSymbol.prototype.setType = function (typeRef) { - if (this.cachedTypeLink) { - this.unsetType(); - } - - this.cachedTypeLink = this.addOutgoingLink(typeRef, 0 /* TypedAs */); - }; - - PullSymbol.prototype.getType = function () { - if (this.cachedTypeLink) { - return this.cachedTypeLink.end; - } - - return null; - }; - - PullSymbol.prototype.unsetType = function () { - var foundType = false; - - if (this.cachedTypeLink) { - this.removeOutgoingLink(this.cachedTypeLink); - foundType = true; - } - - if (foundType) { - this.invalidate(); - } - }; - - PullSymbol.prototype.isTyped = function () { - return this.getType() != null; - }; - - PullSymbol.prototype.setResolved = function () { - this.hasBeenResolved = true; - this.inResolution = false; - }; - PullSymbol.prototype.isResolved = function () { - return this.hasBeenResolved; - }; - - PullSymbol.prototype.startResolving = function () { - this.inResolution = true; - }; - PullSymbol.prototype.isResolving = function () { - return this.inResolution; - }; - - PullSymbol.prototype.setUnresolved = function () { - this.hasBeenResolved = false; - this.isBound = false; - this.inResolution = false; - }; - - PullSymbol.prototype.invalidate = function () { - this.docComments = null; - - this.hasBeenResolved = false; - this.isBound = false; - - this.declarations.update(function (pullDecl) { - return pullDecl.resetErrors(); - }, null); - }; - - PullSymbol.prototype.hasFlag = function (flag) { - var declarations = this.getDeclarations(); - for (var i = 0, n = declarations.length; i < n; i++) { - if ((declarations[i].getFlags() & flag) !== 0 /* None */) { - return true; - } - } - return false; - }; - - PullSymbol.prototype.allDeclsHaveFlag = function (flag) { - var declarations = this.getDeclarations(); - for (var i = 0, n = declarations.length; i < n; i++) { - if (!((declarations[i].getFlags() & flag) !== 0 /* None */)) { - return false; - } - } - return true; - }; - - PullSymbol.prototype.pathToRoot = function () { - var path = []; - var node = this; - while (node) { - if (node.isType()) { - var associatedContainerSymbol = (node).getAssociatedContainerType(); - if (associatedContainerSymbol) { - node = associatedContainerSymbol; - } - } - path[path.length] = node; - node = node.getContainer(); - } - return path; - }; - - PullSymbol.prototype.findCommonAncestorPath = function (b) { - var aPath = this.pathToRoot(); - if (aPath.length === 1) { - return aPath; - } - - var bPath; - if (b) { - bPath = b.pathToRoot(); - } else { - return aPath; - } - - var commonNodeIndex = -1; - for (var i = 0, aLen = aPath.length; i < aLen; i++) { - var aNode = aPath[i]; - for (var j = 0, bLen = bPath.length; j < bLen; j++) { - var bNode = bPath[j]; - if (aNode === bNode) { - var aDecl = null; - if (i > 0) { - var decls = aPath[i - 1].getDeclarations(); - if (decls.length) { - aDecl = decls[0].getParentDecl(); - } - } - var bDecl = null; - if (j > 0) { - var decls = bPath[j - 1].getDeclarations(); - if (decls.length) { - bDecl = decls[0].getParentDecl(); - } - } - if (!aDecl || !bDecl || aDecl == bDecl) { - commonNodeIndex = i; - break; - } - } - } - if (commonNodeIndex >= 0) { - break; - } - } - - if (commonNodeIndex >= 0) { - return aPath.slice(0, commonNodeIndex); - } else { - return aPath; - } - }; - - PullSymbol.prototype.toString = function (useConstraintInName) { - var str = this.getNameAndTypeName(); - return str; - }; - - PullSymbol.prototype.getNamePartForFullName = function () { - return this.getDisplayName(null, true); - }; - - PullSymbol.prototype.fullName = function (scopeSymbol) { - var path = this.pathToRoot(); - var fullName = ""; - var aliasedSymbol = this.getAliasedSymbol(scopeSymbol); - if (aliasedSymbol) { - return aliasedSymbol.getDisplayName(); - } - - for (var i = 1; i < path.length; i++) { - aliasedSymbol = path[i].getAliasedSymbol(scopeSymbol); - if (aliasedSymbol) { - fullName = aliasedSymbol.getDisplayName() + "." + fullName; - break; - } else { - var scopedName = path[i].getNamePartForFullName(); - if (path[i].getKind() == 32 /* DynamicModule */ && !TypeScript.isQuoted(scopedName)) { - break; - } - - if (scopedName === "") { - break; - } - - fullName = scopedName + "." + fullName; - } - } - - fullName = fullName + this.getNamePartForFullName(); - return fullName; - }; - - PullSymbol.prototype.getScopedName = function (scopeSymbol, useConstraintInName) { - var path = this.findCommonAncestorPath(scopeSymbol); - var fullName = ""; - var aliasedSymbol = this.getAliasedSymbol(scopeSymbol); - if (aliasedSymbol) { - return aliasedSymbol.getDisplayName(); - } - - for (var i = 1; i < path.length; i++) { - var kind = path[i].getKind(); - if (kind === 4 /* Container */ || kind === 32 /* DynamicModule */) { - aliasedSymbol = path[i].getAliasedSymbol(scopeSymbol); - if (aliasedSymbol) { - fullName = aliasedSymbol.getDisplayName() + "." + fullName; - break; - } else if (kind === 4 /* Container */) { - fullName = path[i].getDisplayName() + "." + fullName; - } else { - var displayName = path[i].getDisplayName(); - if (TypeScript.isQuoted(displayName)) { - fullName = displayName + "." + fullName; - } - break; - } - } else { - break; - } - } - fullName = fullName + this.getDisplayName(scopeSymbol, useConstraintInName); - return fullName; - }; - - PullSymbol.prototype.getScopedNameEx = function (scopeSymbol, useConstraintInName, getPrettyTypeName, getTypeParamMarkerInfo) { - var name = this.getScopedName(scopeSymbol, useConstraintInName); - return TypeScript.MemberName.create(name); - }; - - PullSymbol.prototype.getTypeName = function (scopeSymbol, getPrettyTypeName) { - var memberName = this.getTypeNameEx(scopeSymbol, getPrettyTypeName); - return memberName.toString(); - }; - - PullSymbol.prototype.getTypeNameEx = function (scopeSymbol, getPrettyTypeName) { - var type = this.getType(); - if (type) { - var memberName = getPrettyTypeName ? this.getTypeNameForFunctionSignature("", scopeSymbol, getPrettyTypeName) : null; - if (!memberName) { - memberName = type.getScopedNameEx(scopeSymbol, true, getPrettyTypeName); - } - - return memberName; - } - return TypeScript.MemberName.create(""); - }; - - PullSymbol.prototype.getTypeNameForFunctionSignature = function (prefix, scopeSymbol, getPrettyTypeName) { - var type = this.getType(); - if (type && !type.isNamedTypeSymbol() && this.declKind != 4096 /* Property */ && this.declKind != 1024 /* Variable */ && this.declKind != 2048 /* Parameter */) { - var signatures = type.getCallSignatures(); - var typeName = new TypeScript.MemberNameArray(); - var signatureName = PullSignatureSymbol.getSignaturesTypeNameEx(signatures, prefix, false, false, scopeSymbol, getPrettyTypeName); - typeName.addAll(signatureName); - return typeName; - } - - return null; - }; - - PullSymbol.prototype.getNameAndTypeName = function (scopeSymbol) { - var nameAndTypeName = this.getNameAndTypeNameEx(scopeSymbol); - return nameAndTypeName.toString(); - }; - - PullSymbol.prototype.getNameAndTypeNameEx = function (scopeSymbol) { - var type = this.getType(); - var nameEx = this.getScopedNameEx(scopeSymbol); - if (type) { - var nameStr = nameEx.toString() + (this.getIsOptional() ? "?" : ""); - var memberName = this.getTypeNameForFunctionSignature(nameStr, scopeSymbol); - if (!memberName) { - var typeNameEx = type.getScopedNameEx(scopeSymbol); - memberName = TypeScript.MemberName.create(typeNameEx, nameStr + ": ", ""); - } - return memberName; - } - return nameEx; - }; - - PullSymbol.getTypeParameterString = function (typars, scopeSymbol, useContraintInName) { - return PullSymbol.getTypeParameterStringEx(typars, scopeSymbol, undefined, useContraintInName).toString(); - }; - - PullSymbol.getTypeParameterStringEx = function (typeParameters, scopeSymbol, getTypeParamMarkerInfo, useContraintInName) { - var builder = new TypeScript.MemberNameArray(); - builder.prefix = ""; - - if (typeParameters && typeParameters.length) { - builder.add(TypeScript.MemberName.create("<")); - - for (var i = 0; i < typeParameters.length; i++) { - if (i) { - builder.add(TypeScript.MemberName.create(", ")); - } - - if (getTypeParamMarkerInfo) { - builder.add(new TypeScript.MemberName()); - } - - builder.add(typeParameters[i].getScopedNameEx(scopeSymbol, useContraintInName)); - - if (getTypeParamMarkerInfo) { - builder.add(new TypeScript.MemberName()); - } - } - - builder.add(TypeScript.MemberName.create(">")); - } - - return builder; - }; - - PullSymbol.getIsExternallyVisible = function (symbol, fromIsExternallyVisibleSymbol, inIsExternallyVisibleSymbols) { - if (inIsExternallyVisibleSymbols) { - for (var i = 0; i < inIsExternallyVisibleSymbols.length; i++) { - if (inIsExternallyVisibleSymbols[i] === symbol) { - return true; - } - } - } else { - inIsExternallyVisibleSymbols = []; - } - - if (fromIsExternallyVisibleSymbol === symbol) { - return true; - } - inIsExternallyVisibleSymbols = inIsExternallyVisibleSymbols.concat(fromIsExternallyVisibleSymbol); - - return symbol.isExternallyVisible(inIsExternallyVisibleSymbols); - }; - - PullSymbol.prototype.isExternallyVisible = function (inIsExternallyVisibleSymbols) { - var kind = this.getKind(); - if (kind === 2 /* Primitive */) { - return true; - } - - if (this.isType()) { - var associatedContainerSymbol = (this).getAssociatedContainerType(); - if (associatedContainerSymbol) { - return PullSymbol.getIsExternallyVisible(associatedContainerSymbol, this, inIsExternallyVisibleSymbols); - } - } - - if (this.hasFlag(2 /* Private */)) { - return false; - } - - var container = this.getContainer(); - if (container === null) { - return true; - } - - if (container.getKind() == 32 /* DynamicModule */ || (container.getAssociatedContainerType() && container.getAssociatedContainerType().getKind() == 32 /* DynamicModule */)) { - var containerTypeSymbol = container.getKind() == 32 /* DynamicModule */ ? container : container.getAssociatedContainerType(); - if (PullContainerTypeSymbol.usedAsSymbol(containerTypeSymbol, this)) { - return true; - } - } - - if (!this.hasFlag(1 /* Exported */) && kind != 4096 /* Property */ && kind != 65536 /* Method */) { - return false; - } - - return PullSymbol.getIsExternallyVisible(container, this, inIsExternallyVisibleSymbols); - }; - return PullSymbol; - })(); - TypeScript.PullSymbol = PullSymbol; - - var PullExpressionSymbol = (function (_super) { - __extends(PullExpressionSymbol, _super); - function PullExpressionSymbol() { - _super.call(this, "", 268435456 /* Expression */); - this.contributingSymbols = []; - } - PullExpressionSymbol.prototype.addContributingSymbol = function (symbol) { - var link = this.addOutgoingLink(symbol, 23 /* ContributesToExpression */); - - this.contributingSymbols[this.contributingSymbols.length] = symbol; - }; - - PullExpressionSymbol.prototype.getContributingSymbols = function () { - return this.contributingSymbols; - }; - return PullExpressionSymbol; - })(PullSymbol); - TypeScript.PullExpressionSymbol = PullExpressionSymbol; - - var PullSignatureSymbol = (function (_super) { - __extends(PullSignatureSymbol, _super); - function PullSignatureSymbol(kind) { - _super.call(this, "", kind); - this.parameterLinks = null; - this.typeParameterLinks = null; - this.returnTypeLink = null; - this.hasOptionalParam = false; - this.nonOptionalParamCount = 0; - this.hasVarArgs = false; - this.specializationCache = {}; - this.memberTypeParameterNameCache = null; - this.hasAGenericParameter = false; - this.stringConstantOverload = undefined; - } - PullSignatureSymbol.prototype.isDefinition = function () { - return false; - }; - - PullSignatureSymbol.prototype.hasVariableParamList = function () { - return this.hasVarArgs; - }; - PullSignatureSymbol.prototype.setHasVariableParamList = function () { - this.hasVarArgs = true; - }; - - PullSignatureSymbol.prototype.setHasGenericParameter = function () { - this.hasAGenericParameter = true; - }; - PullSignatureSymbol.prototype.hasGenericParameter = function () { - return this.hasAGenericParameter; - }; - - PullSignatureSymbol.prototype.isGeneric = function () { - return this.hasAGenericParameter || (this.typeParameterLinks && this.typeParameterLinks.length != 0); - }; - - PullSignatureSymbol.prototype.addParameter = function (parameter, isOptional) { - if (typeof isOptional === "undefined") { isOptional = false; } - if (!this.parameterLinks) { - this.parameterLinks = []; - } - - var link = this.addOutgoingLink(parameter, 13 /* Parameter */); - this.parameterLinks[this.parameterLinks.length] = link; - this.hasOptionalParam = isOptional; - - if (!isOptional) { - this.nonOptionalParamCount++; - } - }; - - PullSignatureSymbol.prototype.addSpecialization = function (signature, typeArguments) { - if (typeArguments && typeArguments.length) { - this.specializationCache[getIDForTypeSubstitutions(typeArguments)] = signature; - } - }; - - PullSignatureSymbol.prototype.getSpecialization = function (typeArguments) { - if (typeArguments) { - var sig = this.specializationCache[getIDForTypeSubstitutions(typeArguments)]; - - if (sig) { - return sig; - } - } - - return null; - }; - - PullSignatureSymbol.prototype.addTypeParameter = function (parameter) { - if (!this.typeParameterLinks) { - this.typeParameterLinks = []; - } - - if (!this.memberTypeParameterNameCache) { - this.memberTypeParameterNameCache = new TypeScript.BlockIntrinsics(); - } - - var link = this.addOutgoingLink(parameter, 18 /* TypeParameter */); - this.typeParameterLinks[this.typeParameterLinks.length] = link; - - this.memberTypeParameterNameCache[link.end.getName()] = link.end; - }; - - PullSignatureSymbol.prototype.getNonOptionalParameterCount = function () { - return this.nonOptionalParamCount; - }; - - PullSignatureSymbol.prototype.setReturnType = function (returnType) { - if (returnType) { - if (this.returnTypeLink) { - this.removeOutgoingLink(this.returnTypeLink); - } - this.returnTypeLink = this.addOutgoingLink(returnType, 14 /* ReturnType */); - } - }; - - PullSignatureSymbol.prototype.getParameters = function () { - var params = []; - - if (this.parameterLinks) { - for (var i = 0; i < this.parameterLinks.length; i++) { - params[params.length] = this.parameterLinks[i].end; - } - } - - return params; - }; - - PullSignatureSymbol.prototype.getTypeParameters = function () { - var params = []; - - if (this.typeParameterLinks) { - for (var i = 0; i < this.typeParameterLinks.length; i++) { - params[params.length] = this.typeParameterLinks[i].end; - } - } - - return params; - }; - - PullSignatureSymbol.prototype.findTypeParameter = function (name) { - var memberSymbol; - - if (!this.memberTypeParameterNameCache) { - this.memberTypeParameterNameCache = new TypeScript.BlockIntrinsics(); - - if (this.typeParameterLinks) { - for (var i = 0; i < this.typeParameterLinks.length; i++) { - this.memberTypeParameterNameCache[this.typeParameterLinks[i].end.getName()] = this.typeParameterLinks[i].end; - } - } - } - - memberSymbol = this.memberTypeParameterNameCache[name]; - - return memberSymbol; - }; - - PullSignatureSymbol.prototype.removeParameter = function (parameterSymbol) { - var paramLink; - - if (this.parameterLinks) { - for (var i = 0; i < this.parameterLinks.length; i++) { - if (parameterSymbol === this.parameterLinks[i].end) { - paramLink = this.parameterLinks[i]; - this.removeOutgoingLink(paramLink); - break; - } - } - } - - this.invalidate(); - }; - - PullSignatureSymbol.prototype.mimicSignature = function (signature, resolver) { - var typeParameters = signature.getTypeParameters(); - var typeParameter; - - if (typeParameters) { - for (var i = 0; i < typeParameters.length; i++) { - this.addTypeParameter(typeParameters[i]); - } - } - - var parameters = signature.getParameters(); - var parameter; - - if (parameters) { - for (var j = 0; j < parameters.length; j++) { - parameter = new PullSymbol(parameters[j].getName(), 2048 /* Parameter */); - parameter.setRootSymbol(parameters[j]); - - if (parameters[j].getIsOptional()) { - parameter.setIsOptional(); - } - if (parameters[j].getIsVarArg()) { - parameter.setIsVarArg(); - this.setHasVariableParamList(); - } - this.addParameter(parameter); - } - } - - var returnType = signature.getReturnType(); - - if (!resolver.isTypeArgumentOrWrapper(returnType)) { - this.setReturnType(returnType); - } - }; - - PullSignatureSymbol.prototype.getReturnType = function () { - if (this.returnTypeLink) { - return this.returnTypeLink.end; - } else { - var rtl = this.findOutgoingLinks(function (p) { - return p.kind === 14 /* ReturnType */; - }); - - if (rtl.length) { - this.returnTypeLink = rtl[0]; - return this.returnTypeLink.end; - } - - return null; - } - }; - - PullSignatureSymbol.prototype.parametersAreFixed = function () { - if (!this.isGeneric()) { - return true; - } - - if (this.parameterLinks) { - var paramType; - for (var i = 0; i < this.parameterLinks.length; i++) { - paramType = this.parameterLinks[i].end.getType(); - - if (paramType && !paramType.isFixed()) { - return false; - } - } - } - - return true; - }; - - PullSignatureSymbol.prototype.isFixed = function () { - if (!this.isGeneric()) { - return true; - } - - if (this.parameterLinks) { - var parameterType = null; - - for (var i = 0; i < this.parameterLinks.length; i++) { - parameterType = this.parameterLinks[i].end.getType(); - - if (parameterType && !parameterType.isFixed()) { - return false; - } - } - } - - if (this.returnTypeLink) { - var returnType = this.returnTypeLink.end; - - return returnType.isFixed(); - } - - return true; - }; - - PullSignatureSymbol.prototype.invalidate = function () { - this.parameterLinks = this.findOutgoingLinks(function (psl) { - return psl.kind === 13 /* Parameter */; - }); - this.nonOptionalParamCount = 0; - this.hasOptionalParam = false; - this.hasAGenericParameter = false; - this.stringConstantOverload = undefined; - - if (this.parameterLinks) { - for (var i = 0; i < this.parameterLinks.length; i++) { - this.parameterLinks[i].end.invalidate(); - - if (!this.parameterLinks[i].end.getIsOptional()) { - this.nonOptionalParamCount++; - } else { - this.hasOptionalParam; - break; - } - } - } - - _super.prototype.invalidate.call(this); - }; - - PullSignatureSymbol.prototype.isStringConstantOverloadSignature = function () { - if (this.stringConstantOverload === undefined) { - var params = this.getParameters(); - this.stringConstantOverload = false; - for (var i = 0; i < params.length; i++) { - var paramType = params[i].getType(); - if (paramType && paramType.isPrimitive() && (paramType).isStringConstant()) { - this.stringConstantOverload = true; - } - } - } - - return this.stringConstantOverload; - }; - - PullSignatureSymbol.getSignatureTypeMemberName = function (candidateSignature, signatures, scopeSymbol) { - var allMemberNames = new TypeScript.MemberNameArray(); - var signatureMemberName = PullSignatureSymbol.getSignaturesTypeNameEx(signatures, "", false, false, scopeSymbol, true, candidateSignature); - allMemberNames.addAll(signatureMemberName); - return allMemberNames; - }; - - PullSignatureSymbol.getSignaturesTypeNameEx = function (signatures, prefix, shortform, brackets, scopeSymbol, getPrettyTypeName, candidateSignature) { - var result = []; - var len = signatures.length; - if (!getPrettyTypeName && len > 1) { - shortform = false; - } - - var foundDefinition = false; - if (candidateSignature && candidateSignature.isDefinition() && len > 1) { - candidateSignature = null; - } - - for (var i = 0; i < len; i++) { - if (len > 1 && signatures[i].isDefinition()) { - foundDefinition = true; - continue; - } - - var signature = signatures[i]; - if (getPrettyTypeName && candidateSignature) { - signature = candidateSignature; - } - - result.push(signature.getSignatureTypeNameEx(prefix, shortform, brackets, scopeSymbol)); - if (getPrettyTypeName) { - break; - } - } - - if (getPrettyTypeName && result.length && len > 1) { - var lastMemberName = result[result.length - 1]; - for (var i = i + 1; i < len; i++) { - if (signatures[i].isDefinition()) { - foundDefinition = true; - break; - } - } - var overloadString = " (+ " + (foundDefinition ? len - 2 : len - 1) + " overload(s))"; - lastMemberName.add(TypeScript.MemberName.create(overloadString)); - } - - return result; - }; - - PullSignatureSymbol.prototype.toString = function (useConstraintInName) { - var s = this.getSignatureTypeNameEx(this.getScopedNameEx().toString(), false, false, undefined, undefined, useConstraintInName).toString(); - return s; - }; - - PullSignatureSymbol.prototype.getSignatureTypeNameEx = function (prefix, shortform, brackets, scopeSymbol, getParamMarkerInfo, getTypeParamMarkerInfo) { - var typeParamterBuilder = new TypeScript.MemberNameArray(); - - typeParamterBuilder.add(PullSymbol.getTypeParameterStringEx(this.getTypeParameters(), scopeSymbol, getTypeParamMarkerInfo, true)); - - if (brackets) { - typeParamterBuilder.add(TypeScript.MemberName.create("[")); - } else { - typeParamterBuilder.add(TypeScript.MemberName.create("(")); - } - - var builder = new TypeScript.MemberNameArray(); - builder.prefix = prefix; - - if (getTypeParamMarkerInfo) { - builder.prefix = prefix; - builder.addAll(typeParamterBuilder.entries); - } else { - builder.prefix = prefix + typeParamterBuilder.toString(); - } - - var params = this.getParameters(); - var paramLen = params.length; - for (var i = 0; i < paramLen; i++) { - var paramType = params[i].getType(); - var typeString = paramType ? ": " : ""; - var paramIsVarArg = params[i].getIsVarArg(); - var varArgPrefix = paramIsVarArg ? "..." : ""; - var optionalString = (!paramIsVarArg && params[i].getIsOptional()) ? "?" : ""; - if (getParamMarkerInfo) { - builder.add(new TypeScript.MemberName()); - } - builder.add(TypeScript.MemberName.create(varArgPrefix + params[i].getScopedNameEx(scopeSymbol).toString() + optionalString + typeString)); - if (paramType) { - builder.add(paramType.getScopedNameEx(scopeSymbol)); - } - if (getParamMarkerInfo) { - builder.add(new TypeScript.MemberName()); - } - if (i < paramLen - 1) { - builder.add(TypeScript.MemberName.create(", ")); - } - } - - if (shortform) { - if (brackets) { - builder.add(TypeScript.MemberName.create("] => ")); - } else { - builder.add(TypeScript.MemberName.create(") => ")); - } - } else { - if (brackets) { - builder.add(TypeScript.MemberName.create("]: ")); - } else { - builder.add(TypeScript.MemberName.create("): ")); - } - } - - var returnType = this.getReturnType(); - - if (returnType) { - builder.add(returnType.getScopedNameEx(scopeSymbol)); - } else { - builder.add(TypeScript.MemberName.create("any")); - } - - return builder; - }; - return PullSignatureSymbol; - })(PullSymbol); - TypeScript.PullSignatureSymbol = PullSignatureSymbol; - - var PullTypeSymbol = (function (_super) { - __extends(PullTypeSymbol, _super); - function PullTypeSymbol() { - _super.apply(this, arguments); - this.memberLinks = null; - this.typeParameterLinks = null; - this.specializationLinks = null; - this.containedByLinks = null; - this.memberNameCache = null; - this.memberTypeNameCache = null; - this.memberTypeParameterNameCache = null; - this.containedMemberCache = null; - this.typeArguments = null; - this.specializedTypeCache = null; - this.memberCache = null; - this.implementedTypeLinks = null; - this.extendedTypeLinks = null; - this.callSignatureLinks = null; - this.constructSignatureLinks = null; - this.indexSignatureLinks = null; - this.arrayType = null; - this.hasGenericSignature = false; - this.hasGenericMember = false; - this.knownBaseTypeCount = 0; - this._hasBaseTypeConflict = false; - this.invalidatedSpecializations = false; - this.associatedContainerTypeSymbol = null; - this.constructorMethod = null; - this.hasDefaultConstructor = false; - } - PullTypeSymbol.prototype.getKnownBaseTypeCount = function () { - return this.knownBaseTypeCount; - }; - PullTypeSymbol.prototype.resetKnownBaseTypeCount = function () { - this.knownBaseTypeCount = 0; - }; - PullTypeSymbol.prototype.incrementKnownBaseCount = function () { - this.knownBaseTypeCount++; - }; - PullTypeSymbol.prototype.setHasBaseTypeConflict = function () { - this._hasBaseTypeConflict = true; - }; - PullTypeSymbol.prototype.hasBaseTypeConflict = function () { - return this._hasBaseTypeConflict; - }; - - PullTypeSymbol.prototype.setUnresolved = function () { - _super.prototype.setUnresolved.call(this); - - var specializations = this.getKnownSpecializations(); - - for (var i = 0; i < specializations.length; i++) { - specializations[i].setUnresolved(); - } - }; - - PullTypeSymbol.prototype.isType = function () { - return true; - }; - PullTypeSymbol.prototype.isClass = function () { - return this.getKind() == 8 /* Class */ || (this.constructorMethod != null); - }; - - PullTypeSymbol.prototype.hasMembers = function () { - var thisHasMembers = this.memberLinks && this.memberLinks.length != 0; - - if (thisHasMembers) { - return true; - } - - var parents = this.getExtendedTypes(); - - for (var i = 0; i < parents.length; i++) { - if (parents[i].hasMembers()) { - return true; - } - } - - return false; - }; - PullTypeSymbol.prototype.isFunction = function () { - return false; - }; - PullTypeSymbol.prototype.isConstructor = function () { - return false; - }; - PullTypeSymbol.prototype.isTypeParameter = function () { - return false; - }; - PullTypeSymbol.prototype.isTypeVariable = function () { - return false; - }; - PullTypeSymbol.prototype.isError = function () { - return false; - }; - - PullTypeSymbol.prototype.setHasGenericSignature = function () { - this.hasGenericSignature = true; - }; - PullTypeSymbol.prototype.getHasGenericSignature = function () { - return this.hasGenericSignature; - }; - - PullTypeSymbol.prototype.setHasGenericMember = function () { - this.hasGenericMember = true; - }; - PullTypeSymbol.prototype.getHasGenericMember = function () { - return this.hasGenericMember; - }; - - PullTypeSymbol.prototype.setAssociatedContainerType = function (type) { - this.associatedContainerTypeSymbol = type; - }; - - PullTypeSymbol.prototype.getAssociatedContainerType = function () { - return this.associatedContainerTypeSymbol; - }; - - PullTypeSymbol.prototype.getType = function () { - return this; - }; - - PullTypeSymbol.prototype.getArrayType = function () { - return this.arrayType; - }; - - PullTypeSymbol.prototype.getElementType = function () { - var arrayOfLinks = this.findOutgoingLinks(function (link) { - return link.kind === 4 /* ArrayOf */; - }); - - if (arrayOfLinks.length) { - return arrayOfLinks[0].end; - } - - return null; - }; - PullTypeSymbol.prototype.setArrayType = function (arrayType) { - this.arrayType = arrayType; - - arrayType.addOutgoingLink(this, 4 /* ArrayOf */); - }; - - PullTypeSymbol.prototype.addContainedByLink = function (containedByLink) { - if (!this.containedByLinks) { - this.containedByLinks = []; - } - - if (!this.containedMemberCache) { - this.containedMemberCache = new TypeScript.BlockIntrinsics(); - } - - this.containedByLinks[this.containedByLinks.length] = containedByLink; - this.containedMemberCache[containedByLink.start.getName()] = containedByLink.start; - }; - - PullTypeSymbol.prototype.findContainedMember = function (name) { - if (!this.containedByLinks) { - this.containedByLinks = this.findIncomingLinks(function (psl) { - return psl.kind === 10 /* ContainedBy */; - }); - this.containedMemberCache = new TypeScript.BlockIntrinsics(); - - for (var i = 0; i < this.containedByLinks.length; i++) { - this.containedMemberCache[this.containedByLinks[i].start.getName()] = this.containedByLinks[i].start; - } - } - - return this.containedMemberCache[name]; - }; - - PullTypeSymbol.prototype.addMember = function (memberSymbol, linkKind, doNotChangeContainer) { - var link = this.addOutgoingLink(memberSymbol, linkKind); - - if (!doNotChangeContainer) { - memberSymbol.setContainer(this); - } - - if (!this.memberLinks) { - this.memberLinks = []; - } - - if (!this.memberCache || !this.memberNameCache) { - this.populateMemberCache(); - } - - if (!memberSymbol.isType()) { - this.memberLinks[this.memberLinks.length] = link; - - this.memberCache[this.memberCache.length] = memberSymbol; - - if (!this.memberNameCache) { - this.populateMemberCache(); - } - this.memberNameCache[memberSymbol.getName()] = memberSymbol; - } else { - if ((memberSymbol).isTypeParameter()) { - if (!this.typeParameterLinks) { - this.typeParameterLinks = []; - } - if (!this.memberTypeParameterNameCache) { - this.memberTypeParameterNameCache = new TypeScript.BlockIntrinsics(); - } - this.typeParameterLinks[this.typeParameterLinks.length] = link; - this.memberTypeParameterNameCache[memberSymbol.getName()] = memberSymbol; - } else { - if (!this.memberTypeNameCache) { - this.memberTypeNameCache = new TypeScript.BlockIntrinsics(); - } - this.memberLinks[this.memberLinks.length] = link; - this.memberTypeNameCache[memberSymbol.getName()] = memberSymbol; - this.memberCache[this.memberCache.length] = memberSymbol; - } - } - }; - - PullTypeSymbol.prototype.removeMember = function (memberSymbol) { - var memberLink; - var child; - - var links = (memberSymbol.isType() && (memberSymbol).isTypeParameter()) ? this.typeParameterLinks : this.memberLinks; - - if (links) { - for (var i = 0; i < links.length; i++) { - if (memberSymbol === links[i].end) { - memberLink = links[i]; - child = memberLink.end; - child.unsetContainer(); - this.removeOutgoingLink(memberLink); - break; - } - } - } - - this.invalidate(); - }; - - PullTypeSymbol.prototype.getMembers = function () { - if (this.memberCache) { - return this.memberCache; - } else { - var members = []; - - if (this.memberLinks) { - for (var i = 0; i < this.memberLinks.length; i++) { - members[members.length] = this.memberLinks[i].end; - } - } - - if (members.length) { - this.memberCache = members; - } - - return members; - } - }; - - PullTypeSymbol.prototype.setHasDefaultConstructor = function (hasOne) { - if (typeof hasOne === "undefined") { hasOne = true; } - this.hasDefaultConstructor = hasOne; - }; - - PullTypeSymbol.prototype.getHasDefaultConstructor = function () { - return this.hasDefaultConstructor; - }; - - PullTypeSymbol.prototype.getConstructorMethod = function () { - return this.constructorMethod; - }; - - PullTypeSymbol.prototype.setConstructorMethod = function (constructorMethod) { - this.constructorMethod = constructorMethod; - }; - - PullTypeSymbol.prototype.getTypeParameters = function () { - var members = []; - - if (this.typeParameterLinks) { - for (var i = 0; i < this.typeParameterLinks.length; i++) { - members[members.length] = this.typeParameterLinks[i].end; - } - } - - return members; - }; - - PullTypeSymbol.prototype.isGeneric = function () { - return (this.typeParameterLinks && this.typeParameterLinks.length != 0) || this.hasGenericSignature || this.hasGenericMember || (this.typeArguments && this.typeArguments.length); - }; - - PullTypeSymbol.prototype.isFixed = function () { - if (!this.isGeneric()) { - return true; - } - - if (this.typeParameterLinks && this.typeArguments) { - if (!this.typeArguments.length || this.typeArguments.length < this.typeParameterLinks.length) { - return false; - } - - for (var i = 0; i < this.typeArguments.length; i++) { - if (!this.typeArguments[i].isFixed()) { - return false; - } - } - - return true; - } - - return false; - }; - - PullTypeSymbol.prototype.addSpecialization = function (specializedVersionOfThisType, substitutingTypes) { - if (!substitutingTypes || !substitutingTypes.length) { - return; - } - - if (!this.specializedTypeCache) { - this.specializedTypeCache = new TypeScript.BlockIntrinsics(); - } - - if (!this.specializationLinks) { - this.specializationLinks = []; - } - - this.specializationLinks[this.specializationLinks.length] = this.addOutgoingLink(specializedVersionOfThisType, 21 /* SpecializedTo */); - - this.specializedTypeCache[getIDForTypeSubstitutions(substitutingTypes)] = specializedVersionOfThisType; - }; - - PullTypeSymbol.prototype.getSpecialization = function (substitutingTypes) { - if (!substitutingTypes || !substitutingTypes.length) { - return null; - } - - if (!this.specializedTypeCache) { - this.specializedTypeCache = new TypeScript.BlockIntrinsics(); - - return null; - } - - var specialization = this.specializedTypeCache[getIDForTypeSubstitutions(substitutingTypes)]; - - if (!specialization) { - return null; - } - - return specialization; - }; - - PullTypeSymbol.prototype.getKnownSpecializations = function () { - var specializations = []; - - if (this.specializedTypeCache) { - for (var specializationID in this.specializedTypeCache) { - if (this.specializedTypeCache[specializationID]) { - specializations[specializations.length] = this.specializedTypeCache[specializationID]; - } - } - } - - return specializations; - }; - - PullTypeSymbol.prototype.invalidateSpecializations = function () { - if (this.invalidatedSpecializations) { - return; - } - - var specializations = this.getKnownSpecializations(); - - for (var i = 0; i < specializations.length; i++) { - specializations[i].invalidate(); - } - - if (this.specializationLinks && this.specializationLinks.length) { - for (var i = 0; i < this.specializationLinks.length; i++) { - this.removeOutgoingLink(this.specializationLinks[i]); - } - } - - this.specializationLinks = null; - - this.specializedTypeCache = null; - - this.invalidatedSpecializations = true; - }; - - PullTypeSymbol.prototype.removeSpecialization = function (specializationType) { - if (this.specializationLinks && this.specializationLinks.length) { - for (var i = 0; i < this.specializationLinks.length; i++) { - if (this.specializationLinks[i].end === specializationType) { - this.removeOutgoingLink(this.specializationLinks[i]); - break; - } - } - } - - if (this.specializedTypeCache) { - for (var specializationID in this.specializedTypeCache) { - if (this.specializedTypeCache[specializationID] === specializationType) { - this.specializedTypeCache[specializationID] = undefined; - } - } - } - }; - - PullTypeSymbol.prototype.getTypeArguments = function () { - return this.typeArguments; - }; - PullTypeSymbol.prototype.setTypeArguments = function (typeArgs) { - this.typeArguments = typeArgs; - }; - - PullTypeSymbol.prototype.addCallSignature = function (callSignature) { - if (!this.callSignatureLinks) { - this.callSignatureLinks = []; - } - - var link = this.addOutgoingLink(callSignature, 15 /* CallSignature */); - this.callSignatureLinks[this.callSignatureLinks.length] = link; - - if (callSignature.isGeneric()) { - this.hasGenericSignature = true; - } - }; - - PullTypeSymbol.prototype.addCallSignatures = function (callSignatures) { - if (!this.callSignatureLinks) { - this.callSignatureLinks = []; - } - - for (var i = 0; i < callSignatures.length; i++) { - this.addCallSignature(callSignatures[i]); - } - }; - - PullTypeSymbol.prototype.addConstructSignature = function (constructSignature) { - if (!this.constructSignatureLinks) { - this.constructSignatureLinks = []; - } - - var link = this.addOutgoingLink(constructSignature, 16 /* ConstructSignature */); - this.constructSignatureLinks[this.constructSignatureLinks.length] = link; - - if (constructSignature.isGeneric()) { - this.hasGenericSignature = true; - } - }; - - PullTypeSymbol.prototype.addConstructSignatures = function (constructSignatures) { - if (!this.constructSignatureLinks) { - this.constructSignatureLinks = []; - } - - for (var i = 0; i < constructSignatures.length; i++) { - this.addConstructSignature(constructSignatures[i]); - } - }; - - PullTypeSymbol.prototype.addIndexSignature = function (indexSignature) { - if (!this.indexSignatureLinks) { - this.indexSignatureLinks = []; - } - - var link = this.addOutgoingLink(indexSignature, 17 /* IndexSignature */); - this.indexSignatureLinks[this.indexSignatureLinks.length] = link; - - if (indexSignature.isGeneric()) { - this.hasGenericSignature = true; - } - }; - - PullTypeSymbol.prototype.addIndexSignatures = function (indexSignatures) { - if (!this.indexSignatureLinks) { - this.indexSignatureLinks = []; - } - - for (var i = 0; i < indexSignatures.length; i++) { - this.addIndexSignature(indexSignatures[i]); - } - }; - - PullTypeSymbol.prototype.hasOwnCallSignatures = function () { - return !!this.callSignatureLinks; - }; - - PullTypeSymbol.prototype.getCallSignatures = function (collectBaseSignatures) { - if (typeof collectBaseSignatures === "undefined") { collectBaseSignatures = true; } - var members = []; - - if (this.callSignatureLinks) { - for (var i = 0; i < this.callSignatureLinks.length; i++) { - members[members.length] = this.callSignatureLinks[i].end; - } - } - - if (collectBaseSignatures) { - var extendedTypes = this.getExtendedTypes(); - - for (var i = 0; i < extendedTypes.length; i++) { - if (extendedTypes[i].hasBase(this)) { - continue; - } - members = members.concat(extendedTypes[i].getCallSignatures()); - } - } - - return members; - }; - - PullTypeSymbol.prototype.hasOwnConstructSignatures = function () { - return !!this.constructSignatureLinks; - }; - - PullTypeSymbol.prototype.getConstructSignatures = function (collectBaseSignatures) { - if (typeof collectBaseSignatures === "undefined") { collectBaseSignatures = true; } - var members = []; - - if (this.constructSignatureLinks) { - for (var i = 0; i < this.constructSignatureLinks.length; i++) { - members[members.length] = this.constructSignatureLinks[i].end; - } - } - - if (collectBaseSignatures) { - if (!(this.getKind() == 33554432 /* ConstructorType */)) { - var extendedTypes = this.getExtendedTypes(); - - for (var i = 0; i < extendedTypes.length; i++) { - if (extendedTypes[i].hasBase(this)) { - continue; - } - members = members.concat(extendedTypes[i].getConstructSignatures()); - } - } - } - - return members; - }; - - PullTypeSymbol.prototype.hasOwnIndexSignatures = function () { - return !!this.indexSignatureLinks; - }; - - PullTypeSymbol.prototype.getIndexSignatures = function (collectBaseSignatures) { - if (typeof collectBaseSignatures === "undefined") { collectBaseSignatures = true; } - var members = []; - - if (this.indexSignatureLinks) { - for (var i = 0; i < this.indexSignatureLinks.length; i++) { - members[members.length] = this.indexSignatureLinks[i].end; - } - } - - if (collectBaseSignatures) { - var extendedTypes = this.getExtendedTypes(); - - for (var i = 0; i < extendedTypes.length; i++) { - if (extendedTypes[i].hasBase(this)) { - continue; - } - members = members.concat(extendedTypes[i].getIndexSignatures()); - } - } - - return members; - }; - - PullTypeSymbol.prototype.removeCallSignature = function (signature, invalidate) { - if (typeof invalidate === "undefined") { invalidate = true; } - var signatureLink; - - if (this.callSignatureLinks) { - for (var i = 0; i < this.callSignatureLinks.length; i++) { - if (signature === this.callSignatureLinks[i].end) { - signatureLink = this.callSignatureLinks[i]; - this.removeOutgoingLink(signatureLink); - break; - } - } - } - - if (invalidate) { - this.invalidate(); - } - }; - - PullTypeSymbol.prototype.recomputeCallSignatures = function () { - this.callSignatureLinks = this.findOutgoingLinks(function (psl) { - return psl.kind === 15 /* CallSignature */; - }); - }; - - PullTypeSymbol.prototype.removeConstructSignature = function (signature, invalidate) { - if (typeof invalidate === "undefined") { invalidate = true; } - var signatureLink; - - if (this.constructSignatureLinks) { - for (var i = 0; i < this.constructSignatureLinks.length; i++) { - if (signature === this.constructSignatureLinks[i].end) { - signatureLink = this.constructSignatureLinks[i]; - this.removeOutgoingLink(signatureLink); - break; - } - } - } - - if (invalidate) { - this.invalidate(); - } - }; - - PullTypeSymbol.prototype.recomputeConstructSignatures = function () { - this.constructSignatureLinks = this.findOutgoingLinks(function (psl) { - return psl.kind === 16 /* ConstructSignature */; - }); - }; - - PullTypeSymbol.prototype.removeIndexSignature = function (signature, invalidate) { - if (typeof invalidate === "undefined") { invalidate = true; } - var signatureLink; - - if (this.indexSignatureLinks) { - for (var i = 0; i < this.indexSignatureLinks.length; i++) { - if (signature === this.indexSignatureLinks[i].end) { - signatureLink = this.indexSignatureLinks[i]; - this.removeOutgoingLink(signatureLink); - break; - } - } - } - - if (invalidate) { - this.invalidate(); - } - }; - - PullTypeSymbol.prototype.recomputeIndexSignatures = function () { - this.indexSignatureLinks = this.findOutgoingLinks(function (psl) { - return psl.kind === 17 /* IndexSignature */; - }); - }; - - PullTypeSymbol.prototype.addImplementedType = function (interfaceType) { - if (!this.implementedTypeLinks) { - this.implementedTypeLinks = []; - } - - var link = this.addOutgoingLink(interfaceType, 12 /* Implements */); - this.implementedTypeLinks[this.implementedTypeLinks.length] = link; - }; - - PullTypeSymbol.prototype.getImplementedTypes = function () { - var members = []; - - if (this.implementedTypeLinks) { - for (var i = 0; i < this.implementedTypeLinks.length; i++) { - members[members.length] = this.implementedTypeLinks[i].end; - } - } - - return members; - }; - - PullTypeSymbol.prototype.removeImplementedType = function (implementedType) { - var typeLink; - - if (this.implementedTypeLinks) { - for (var i = 0; i < this.implementedTypeLinks.length; i++) { - if (implementedType === this.implementedTypeLinks[i].end) { - typeLink = this.implementedTypeLinks[i]; - this.removeOutgoingLink(typeLink); - break; - } - } - } - - this.invalidate(); - }; - - PullTypeSymbol.prototype.addExtendedType = function (extendedType) { - if (!this.extendedTypeLinks) { - this.extendedTypeLinks = []; - } - - var link = this.addOutgoingLink(extendedType, 11 /* Extends */); - this.extendedTypeLinks[this.extendedTypeLinks.length] = link; - }; - - PullTypeSymbol.prototype.getExtendedTypes = function () { - var members = []; - - if (this.extendedTypeLinks) { - for (var i = 0; i < this.extendedTypeLinks.length; i++) { - members[members.length] = this.extendedTypeLinks[i].end; - } - } - - return members; - }; - - PullTypeSymbol.prototype.hasBase = function (potentialBase, origin) { - if (typeof origin === "undefined") { origin = null; } - if (this === potentialBase) { - return true; - } - - if (origin && (this === origin || this.getRootSymbol() === origin)) { - return true; - } - - if (!origin) { - origin = this; - } - - var extendedTypes = this.getExtendedTypes(); - - for (var i = 0; i < extendedTypes.length; i++) { - if (extendedTypes[i].hasBase(potentialBase, origin)) { - return true; - } - } - - var implementedTypes = this.getImplementedTypes(); - - for (var i = 0; i < implementedTypes.length; i++) { - if (implementedTypes[i].hasBase(potentialBase, origin)) { - return true; - } - } - - return false; - }; - - PullTypeSymbol.prototype.isValidBaseKind = function (baseType, isExtendedType) { - if (baseType.isError()) { - return false; - } - - var thisIsClass = this.isClass(); - if (isExtendedType) { - if (thisIsClass) { - return baseType.getKind() === 8 /* Class */; - } - } else { - if (!thisIsClass) { - return false; - } - } - - return !!(baseType.getKind() & (16 /* Interface */ | 8 /* Class */ | 128 /* Array */)); - }; - - PullTypeSymbol.prototype.removeExtendedType = function (extendedType) { - var typeLink; - - if (this.extendedTypeLinks) { - for (var i = 0; i < this.extendedTypeLinks.length; i++) { - if (extendedType === this.extendedTypeLinks[i].end) { - typeLink = this.extendedTypeLinks[i]; - this.removeOutgoingLink(typeLink); - break; - } - } - } - - this.invalidate(); - }; - - PullTypeSymbol.prototype.findMember = function (name, lookInParent) { - if (typeof lookInParent === "undefined") { lookInParent = true; } - var memberSymbol; - - if (!this.memberNameCache) { - this.populateMemberCache(); - } - - memberSymbol = this.memberNameCache[name]; - - if (!lookInParent) { - return memberSymbol; - } else if (memberSymbol) { - return memberSymbol; - } - - if (!memberSymbol && this.extendedTypeLinks) { - for (var i = 0; i < this.extendedTypeLinks.length; i++) { - memberSymbol = (this.extendedTypeLinks[i].end).findMember(name); - - if (memberSymbol) { - return memberSymbol; - } - } - } - - return this.findNestedType(name); - }; - - PullTypeSymbol.prototype.findNestedType = function (name, kind) { - if (typeof kind === "undefined") { kind = 0 /* None */; } - var memberSymbol; - - if (!this.memberTypeNameCache) { - this.populateMemberTypeCache(); - } - - memberSymbol = this.memberTypeNameCache[name]; - - if (memberSymbol && kind != 0 /* None */) { - memberSymbol = ((memberSymbol.getKind() & kind) != 0) ? memberSymbol : null; - } - - return memberSymbol; - }; - - PullTypeSymbol.prototype.populateMemberCache = function () { - if (!this.memberNameCache || !this.memberCache) { - this.memberNameCache = new TypeScript.BlockIntrinsics(); - this.memberCache = []; - - if (this.memberLinks) { - for (var i = 0; i < this.memberLinks.length; i++) { - this.memberNameCache[this.memberLinks[i].end.getName()] = this.memberLinks[i].end; - this.memberCache[this.memberCache.length] = this.memberLinks[i].end; - } - } - } - }; - - PullTypeSymbol.prototype.populateMemberTypeCache = function () { - if (!this.memberTypeNameCache) { - this.memberTypeNameCache = new TypeScript.BlockIntrinsics(); - - var setAll = false; - - if (!this.memberCache) { - this.memberCache = []; - this.memberNameCache = new TypeScript.BlockIntrinsics(); - setAll = true; - } - - if (this.memberLinks) { - for (var i = 0; i < this.memberLinks.length; i++) { - if (this.memberLinks[i].end.isType()) { - this.memberTypeNameCache[this.memberLinks[i].end.getName()] = this.memberLinks[i].end; - this.memberCache[this.memberCache.length] = this.memberLinks[i].end; - } else if (setAll) { - this.memberNameCache[this.memberLinks[i].end.getName()] = this.memberLinks[i].end; - this.memberCache[this.memberCache.length] = this.memberLinks[i].end; - } - } - } - } - }; - - PullTypeSymbol.prototype.getAllMembers = function (searchDeclKind, includePrivate) { - var allMembers = []; - var i = 0; - var j = 0; - var m = 0; - var n = 0; - - if (!this.memberCache) { - this.populateMemberCache(); - } - - if (!this.memberTypeNameCache) { - this.populateMemberTypeCache(); - } - - if (!this.memberNameCache) { - this.populateMemberCache(); - } - - for (var i = 0, n = this.memberCache.length; i < n; i++) { - var member = this.memberCache[i]; - if ((member.getKind() & searchDeclKind) && (includePrivate || !member.hasFlag(2 /* Private */))) { - allMembers[allMembers.length] = member; - } - } - - if (this.extendedTypeLinks) { - for (var i = 0, n = this.extendedTypeLinks.length; i < n; i++) { - var extendedMembers = (this.extendedTypeLinks[i].end).getAllMembers(searchDeclKind, includePrivate); - - for (var j = 0, m = extendedMembers.length; j < m; j++) { - var extendedMember = extendedMembers[j]; - if (!this.memberNameCache[extendedMember.getName()]) { - allMembers[allMembers.length] = extendedMember; - } - } - } - } - - return allMembers; - }; - - PullTypeSymbol.prototype.findTypeParameter = function (name) { - var memberSymbol; - - if (!this.memberTypeParameterNameCache) { - this.memberTypeParameterNameCache = new TypeScript.BlockIntrinsics(); - - if (this.typeParameterLinks) { - for (var i = 0; i < this.typeParameterLinks.length; i++) { - this.memberTypeParameterNameCache[this.typeParameterLinks[i].end.getName()] = this.typeParameterLinks[i].end; - } - } - } - - memberSymbol = this.memberTypeParameterNameCache[name]; - - return memberSymbol; - }; - - PullTypeSymbol.prototype.cleanTypeParameters = function () { - if (this.typeParameterLinks) { - for (var i = 0; i < this.typeParameterLinks.length; i++) { - this.removeOutgoingLink(this.typeParameterLinks[i]); - } - } - - this.typeParameterLinks = null; - this.memberTypeParameterNameCache = null; - }; - - PullTypeSymbol.prototype.setResolved = function () { - this.invalidatedSpecializations = true; - _super.prototype.setResolved.call(this); - }; - - PullTypeSymbol.prototype.invalidate = function () { - if (this.constructorMethod) { - this.constructorMethod.invalidate(); - } - - this.memberNameCache = null; - this.memberCache = null; - this.memberTypeNameCache = null; - this.containedMemberCache = null; - - this.invalidatedSpecializations = false; - - this.containedByLinks = null; - - this.memberLinks = this.findOutgoingLinks(function (psl) { - return psl.kind === 6 /* PrivateMember */ || psl.kind === 5 /* PublicMember */; - }); - - this.typeParameterLinks = this.findOutgoingLinks(function (psl) { - return psl.kind === 18 /* TypeParameter */; - }); - - this.callSignatureLinks = this.findOutgoingLinks(function (psl) { - return psl.kind === 15 /* CallSignature */; - }); - - this.constructSignatureLinks = this.findOutgoingLinks(function (psl) { - return psl.kind === 16 /* ConstructSignature */; - }); - - this.indexSignatureLinks = this.findOutgoingLinks(function (psl) { - return psl.kind === 17 /* IndexSignature */; - }); - - this.implementedTypeLinks = this.findOutgoingLinks(function (psl) { - return psl.kind === 12 /* Implements */; - }); - - this.extendedTypeLinks = this.findOutgoingLinks(function (psl) { - return psl.kind === 11 /* Extends */; - }); - - this.knownBaseTypeCount = 0; - - _super.prototype.invalidate.call(this); - }; - - PullTypeSymbol.prototype.getNamePartForFullName = function () { - var name = _super.prototype.getNamePartForFullName.call(this); - - var typars = this.getTypeArguments(); - if (!typars || !typars.length) { - typars = this.getTypeParameters(); - } - - var typarString = PullSymbol.getTypeParameterString(typars, this, true); - return name + typarString; - }; - - PullTypeSymbol.prototype.getScopedName = function (scopeSymbol, useConstraintInName) { - return this.getScopedNameEx(scopeSymbol, useConstraintInName).toString(); - }; - - PullTypeSymbol.prototype.isNamedTypeSymbol = function () { - var kind = this.getKind(); - if (kind === 2 /* Primitive */ || kind === 8 /* Class */ || kind === 4 /* Container */ || kind === 32 /* DynamicModule */ || kind === 256 /* TypeAlias */ || kind === 64 /* Enum */ || kind === 8192 /* TypeParameter */ || ((kind === 16 /* Interface */ || kind === 8388608 /* ObjectType */) && this.getName() != "")) { - return true; - } - - return false; - }; - - PullTypeSymbol.prototype.toString = function (useConstraintInName) { - var s = this.getScopedNameEx(null, useConstraintInName).toString(); - return s; - }; - - PullTypeSymbol.prototype.getScopedNameEx = function (scopeSymbol, useConstraintInName, getPrettyTypeName, getTypeParamMarkerInfo) { - if (!this.isNamedTypeSymbol()) { - return this.getMemberTypeNameEx(true, scopeSymbol, getPrettyTypeName); - } - - var builder = new TypeScript.MemberNameArray(); - builder.prefix = _super.prototype.getScopedName.call(this, scopeSymbol, useConstraintInName); - - var typars = this.getTypeArguments(); - if (!typars || !typars.length) { - typars = this.getTypeParameters(); - } - - builder.add(PullSymbol.getTypeParameterStringEx(typars, this, getTypeParamMarkerInfo, useConstraintInName)); - - return builder; - }; - - PullTypeSymbol.prototype.hasOnlyOverloadCallSignatures = function () { - var members = this.getMembers(); - var callSignatures = this.getCallSignatures(); - var constructSignatures = this.getConstructSignatures(); - return members.length === 0 && constructSignatures.length === 0 && callSignatures.length > 1; - }; - - PullTypeSymbol.prototype.getMemberTypeNameEx = function (topLevel, scopeSymbol, getPrettyTypeName) { - var members = this.getMembers(); - var callSignatures = this.getCallSignatures(); - var constructSignatures = this.getConstructSignatures(); - var indexSignatures = this.getIndexSignatures(); - - if (members.length > 0 || callSignatures.length > 0 || constructSignatures.length > 0 || indexSignatures.length > 0) { - var allMemberNames = new TypeScript.MemberNameArray(); - var curlies = !topLevel || indexSignatures.length != 0; - var delim = "; "; - for (var i = 0; i < members.length; i++) { - var memberTypeName = members[i].getNameAndTypeNameEx(scopeSymbol); - - if (memberTypeName.isArray() && (memberTypeName).delim === delim) { - allMemberNames.addAll((memberTypeName).entries); - } else { - allMemberNames.add(memberTypeName); - } - curlies = true; - } - - var getPrettyFunctionOverload = getPrettyTypeName && !curlies && this.hasOnlyOverloadCallSignatures(); - - var signatureCount = callSignatures.length + constructSignatures.length + indexSignatures.length; - if (signatureCount != 0 || members.length != 0) { - var useShortFormSignature = !curlies && (signatureCount === 1); - var signatureMemberName; - - if (callSignatures.length > 0) { - signatureMemberName = PullSignatureSymbol.getSignaturesTypeNameEx(callSignatures, "", useShortFormSignature, false, scopeSymbol, getPrettyFunctionOverload); - allMemberNames.addAll(signatureMemberName); - } - - if (constructSignatures.length > 0) { - signatureMemberName = PullSignatureSymbol.getSignaturesTypeNameEx(constructSignatures, "new", useShortFormSignature, false, scopeSymbol); - allMemberNames.addAll(signatureMemberName); - } - - if (indexSignatures.length > 0) { - signatureMemberName = PullSignatureSymbol.getSignaturesTypeNameEx(indexSignatures, "", useShortFormSignature, true, scopeSymbol); - allMemberNames.addAll(signatureMemberName); - } - - if ((curlies) || (!getPrettyFunctionOverload && (signatureCount > 1) && topLevel)) { - allMemberNames.prefix = "{ "; - allMemberNames.suffix = "}"; - allMemberNames.delim = delim; - } else if (allMemberNames.entries.length > 1) { - allMemberNames.delim = delim; - } - - return allMemberNames; - } - } - - return TypeScript.MemberName.create("{}"); - }; - - PullTypeSymbol.prototype.isExternallyVisible = function (inIsExternallyVisibleSymbols) { - var isVisible = _super.prototype.isExternallyVisible.call(this, inIsExternallyVisibleSymbols); - if (isVisible) { - var typars = this.getTypeArguments(); - if (!typars || !typars.length) { - typars = this.getTypeParameters(); - } - - if (typars) { - for (var i = 0; i < typars.length; i++) { - isVisible = PullSymbol.getIsExternallyVisible(typars[i], this, inIsExternallyVisibleSymbols); - if (!isVisible) { - break; - } - } - } - } - - return isVisible; - }; - - PullTypeSymbol.prototype.setType = function (type) { - TypeScript.Debug.assert(false, "tried to set type of type"); - }; - return PullTypeSymbol; - })(PullSymbol); - TypeScript.PullTypeSymbol = PullTypeSymbol; - - var PullPrimitiveTypeSymbol = (function (_super) { - __extends(PullPrimitiveTypeSymbol, _super); - function PullPrimitiveTypeSymbol(name) { - _super.call(this, name, 2 /* Primitive */); - } - PullPrimitiveTypeSymbol.prototype.isResolved = function () { - return true; - }; - - PullPrimitiveTypeSymbol.prototype.isStringConstant = function () { - return false; - }; - - PullPrimitiveTypeSymbol.prototype.isFixed = function () { - return true; - }; - - PullPrimitiveTypeSymbol.prototype.invalidate = function () { - }; - return PullPrimitiveTypeSymbol; - })(PullTypeSymbol); - TypeScript.PullPrimitiveTypeSymbol = PullPrimitiveTypeSymbol; - - var PullStringConstantTypeSymbol = (function (_super) { - __extends(PullStringConstantTypeSymbol, _super); - function PullStringConstantTypeSymbol(name) { - _super.call(this, name); - } - PullStringConstantTypeSymbol.prototype.isStringConstant = function () { - return true; - }; - return PullStringConstantTypeSymbol; - })(PullPrimitiveTypeSymbol); - TypeScript.PullStringConstantTypeSymbol = PullStringConstantTypeSymbol; - - var PullErrorTypeSymbol = (function (_super) { - __extends(PullErrorTypeSymbol, _super); - function PullErrorTypeSymbol(diagnostic, delegateType, _data) { - if (typeof _data === "undefined") { _data = null; } - _super.call(this, "error"); - this.diagnostic = diagnostic; - this.delegateType = delegateType; - this._data = _data; - } - PullErrorTypeSymbol.prototype.isError = function () { - return true; - }; - - PullErrorTypeSymbol.prototype.getDiagnostic = function () { - return this.diagnostic; - }; - - PullErrorTypeSymbol.prototype.getName = function (scopeSymbol, useConstraintInName) { - return this.delegateType.getName(scopeSymbol, useConstraintInName); - }; - - PullErrorTypeSymbol.prototype.getDisplayName = function (scopeSymbol, useConstraintInName) { - return this.delegateType.getDisplayName(scopeSymbol, useConstraintInName); - }; - - PullErrorTypeSymbol.prototype.toString = function () { - return this.delegateType.toString(); - }; - - PullErrorTypeSymbol.prototype.isResolved = function () { - return false; - }; - - PullErrorTypeSymbol.prototype.setData = function (data) { - this._data = data; - }; - - PullErrorTypeSymbol.prototype.getData = function () { - return this._data; - }; - return PullErrorTypeSymbol; - })(PullPrimitiveTypeSymbol); - TypeScript.PullErrorTypeSymbol = PullErrorTypeSymbol; - - var PullClassTypeSymbol = (function (_super) { - __extends(PullClassTypeSymbol, _super); - function PullClassTypeSymbol(name) { - _super.call(this, name, 8 /* Class */); - } - return PullClassTypeSymbol; - })(PullTypeSymbol); - TypeScript.PullClassTypeSymbol = PullClassTypeSymbol; - - var PullContainerTypeSymbol = (function (_super) { - __extends(PullContainerTypeSymbol, _super); - function PullContainerTypeSymbol(name, kind) { - if (typeof kind === "undefined") { kind = 4 /* Container */; } - _super.call(this, name, kind); - this.instanceSymbol = null; - this._exportAssignedValueSymbol = null; - this._exportAssignedTypeSymbol = null; - this._exportAssignedContainerSymbol = null; - } - PullContainerTypeSymbol.prototype.isContainer = function () { - return true; - }; - - PullContainerTypeSymbol.prototype.setInstanceSymbol = function (symbol) { - this.instanceSymbol = symbol; - }; - - PullContainerTypeSymbol.prototype.getInstanceSymbol = function () { - return this.instanceSymbol; - }; - - PullContainerTypeSymbol.prototype.invalidate = function () { - if (this.instanceSymbol) { - this.instanceSymbol.invalidate(); - } - - _super.prototype.invalidate.call(this); - }; - - PullContainerTypeSymbol.prototype.setExportAssignedValueSymbol = function (symbol) { - this._exportAssignedValueSymbol = symbol; - }; - PullContainerTypeSymbol.prototype.getExportAssignedValueSymbol = function () { - return this._exportAssignedValueSymbol; - }; - - PullContainerTypeSymbol.prototype.setExportAssignedTypeSymbol = function (type) { - this._exportAssignedTypeSymbol = type; - }; - PullContainerTypeSymbol.prototype.getExportAssignedTypeSymbol = function () { - return this._exportAssignedTypeSymbol; - }; - - PullContainerTypeSymbol.prototype.setExportAssignedContainerSymbol = function (container) { - this._exportAssignedContainerSymbol = container; - }; - PullContainerTypeSymbol.prototype.getExportAssignedContainerSymbol = function () { - return this._exportAssignedContainerSymbol; - }; - - PullContainerTypeSymbol.prototype.resetExportAssignedSymbols = function () { - this._exportAssignedContainerSymbol = null; - this._exportAssignedTypeSymbol = null; - this._exportAssignedValueSymbol = null; - }; - - PullContainerTypeSymbol.usedAsSymbol = function (containerSymbol, symbol) { - if (!containerSymbol || !containerSymbol.isContainer()) { - return false; - } - - if (containerSymbol.getType() == symbol) { - return true; - } - - var containerTypeSymbol = containerSymbol; - var valueExportSymbol = containerTypeSymbol.getExportAssignedValueSymbol(); - var typeExportSymbol = containerTypeSymbol.getExportAssignedTypeSymbol(); - var containerExportSymbol = containerTypeSymbol.getExportAssignedContainerSymbol(); - if (valueExportSymbol || typeExportSymbol || containerExportSymbol) { - return valueExportSymbol == symbol || typeExportSymbol == symbol || containerExportSymbol == symbol || PullContainerTypeSymbol.usedAsSymbol(containerExportSymbol, symbol); - } - - return false; - }; - return PullContainerTypeSymbol; - })(PullTypeSymbol); - TypeScript.PullContainerTypeSymbol = PullContainerTypeSymbol; - - var PullTypeAliasSymbol = (function (_super) { - __extends(PullTypeAliasSymbol, _super); - function PullTypeAliasSymbol(name) { - _super.call(this, name, 256 /* TypeAlias */); - this.typeAliasLink = null; - this.isUsedAsValue = false; - this.typeUsedExternally = false; - this.retrievingExportAssignment = false; - } - PullTypeAliasSymbol.prototype.isAlias = function () { - return true; - }; - PullTypeAliasSymbol.prototype.isContainer = function () { - return true; - }; - - PullTypeAliasSymbol.prototype.setAliasedType = function (type) { - TypeScript.Debug.assert(!type.isError(), "Attempted to alias an error"); - if (this.typeAliasLink) { - this.removeOutgoingLink(this.typeAliasLink); - } - - this.typeAliasLink = this.addOutgoingLink(type, 8 /* Aliases */); - }; - - PullTypeAliasSymbol.prototype.getExportAssignedValueSymbol = function () { - if (!this.typeAliasLink) { - return null; - } - - if (this.retrievingExportAssignment) { - return null; - } - - if (this.typeAliasLink.end.isContainer()) { - this.retrievingExportAssignment = true; - var sym = (this.typeAliasLink.end).getExportAssignedValueSymbol(); - this.retrievingExportAssignment = false; - return sym; - } - - return null; - }; - - PullTypeAliasSymbol.prototype.getExportAssignedTypeSymbol = function () { - if (!this.typeAliasLink) { - return null; - } - - if (this.retrievingExportAssignment) { - return null; - } - - if (this.typeAliasLink.end.isContainer()) { - this.retrievingExportAssignment = true; - var sym = (this.typeAliasLink.end).getExportAssignedTypeSymbol(); - this.retrievingExportAssignment = false; - return sym; - } - - return null; - }; - - PullTypeAliasSymbol.prototype.getExportAssignedContainerSymbol = function () { - if (!this.typeAliasLink) { - return null; - } - - if (this.retrievingExportAssignment) { - return null; - } - - if (this.typeAliasLink.end.isContainer()) { - this.retrievingExportAssignment = true; - var sym = (this.typeAliasLink.end).getExportAssignedContainerSymbol(); - this.retrievingExportAssignment = false; - return sym; - } - - return null; - }; - - PullTypeAliasSymbol.prototype.getType = function () { - if (this.typeAliasLink) { - return this.typeAliasLink.end; - } - - return null; - }; - - PullTypeAliasSymbol.prototype.setType = function (type) { - this.setAliasedType(type); - }; - - PullTypeAliasSymbol.prototype.setIsUsedAsValue = function () { - this.isUsedAsValue = true; - }; - - PullTypeAliasSymbol.prototype.getIsUsedAsValue = function () { - return this.isUsedAsValue; - }; - - PullTypeAliasSymbol.prototype.setIsTypeUsedExternally = function () { - this.typeUsedExternally = true; - }; - - PullTypeAliasSymbol.prototype.getTypeUsedExternally = function () { - return this.typeUsedExternally; - }; - - PullTypeAliasSymbol.prototype.getMembers = function () { - if (this.typeAliasLink) { - return (this.typeAliasLink.end).getMembers(); - } - - return []; - }; - - PullTypeAliasSymbol.prototype.getCallSignatures = function () { - if (this.typeAliasLink) { - return (this.typeAliasLink.end).getCallSignatures(); - } - - return []; - }; - - PullTypeAliasSymbol.prototype.getConstructSignatures = function () { - if (this.typeAliasLink) { - return (this.typeAliasLink.end).getConstructSignatures(); - } - - return []; - }; - - PullTypeAliasSymbol.prototype.getIndexSignatures = function () { - if (this.typeAliasLink) { - return (this.typeAliasLink.end).getIndexSignatures(); - } - - return []; - }; - - PullTypeAliasSymbol.prototype.findMember = function (name) { - if (this.typeAliasLink) { - return (this.typeAliasLink.end).findMember(name); - } - - return null; - }; - - PullTypeAliasSymbol.prototype.findNestedType = function (name) { - if (this.typeAliasLink) { - return (this.typeAliasLink.end).findNestedType(name); - } - - return null; - }; - - PullTypeAliasSymbol.prototype.getAllMembers = function (searchDeclKind, includePrivate) { - if (this.typeAliasLink) { - return (this.typeAliasLink.end).getAllMembers(searchDeclKind, includePrivate); - } - - return []; - }; - - PullTypeAliasSymbol.prototype.invalidate = function () { - this.isUsedAsValue = false; - - _super.prototype.invalidate.call(this); - }; - return PullTypeAliasSymbol; - })(PullTypeSymbol); - TypeScript.PullTypeAliasSymbol = PullTypeAliasSymbol; - - var PullDefinitionSignatureSymbol = (function (_super) { - __extends(PullDefinitionSignatureSymbol, _super); - function PullDefinitionSignatureSymbol() { - _super.apply(this, arguments); - } - PullDefinitionSignatureSymbol.prototype.isDefinition = function () { - return true; - }; - return PullDefinitionSignatureSymbol; - })(PullSignatureSymbol); - TypeScript.PullDefinitionSignatureSymbol = PullDefinitionSignatureSymbol; - - var PullFunctionTypeSymbol = (function (_super) { - __extends(PullFunctionTypeSymbol, _super); - function PullFunctionTypeSymbol() { - _super.call(this, "", 16777216 /* FunctionType */); - this.definitionSignature = null; - } - PullFunctionTypeSymbol.prototype.isFunction = function () { - return true; - }; - - PullFunctionTypeSymbol.prototype.invalidate = function () { - var callSignatures = this.getCallSignatures(); - - if (callSignatures.length) { - for (var i = 0; i < callSignatures.length; i++) { - callSignatures[i].invalidate(); - } - } - - this.definitionSignature = null; - - _super.prototype.invalidate.call(this); - }; - - PullFunctionTypeSymbol.prototype.addSignature = function (signature) { - this.addCallSignature(signature); - - if (signature.isDefinition()) { - this.definitionSignature = signature; - } - }; - - PullFunctionTypeSymbol.prototype.getDefinitionSignature = function () { - return this.definitionSignature; - }; - return PullFunctionTypeSymbol; - })(PullTypeSymbol); - TypeScript.PullFunctionTypeSymbol = PullFunctionTypeSymbol; - - var PullConstructorTypeSymbol = (function (_super) { - __extends(PullConstructorTypeSymbol, _super); - function PullConstructorTypeSymbol() { - _super.call(this, "", 33554432 /* ConstructorType */); - this.definitionSignature = null; - } - PullConstructorTypeSymbol.prototype.isFunction = function () { - return true; - }; - PullConstructorTypeSymbol.prototype.isConstructor = function () { - return true; - }; - - PullConstructorTypeSymbol.prototype.invalidate = function () { - this.definitionSignature = null; - - _super.prototype.invalidate.call(this); - }; - - PullConstructorTypeSymbol.prototype.addSignature = function (signature) { - this.addConstructSignature(signature); - - if (signature.isDefinition()) { - this.definitionSignature = signature; - } - }; - - PullConstructorTypeSymbol.prototype.addTypeParameter = function (typeParameter, doNotChangeContainer) { - this.addMember(typeParameter, 18 /* TypeParameter */, doNotChangeContainer); - - var constructSignatures = this.getConstructSignatures(); - - for (var i = 0; i < constructSignatures.length; i++) { - constructSignatures[i].addTypeParameter(typeParameter); - } - }; - - PullConstructorTypeSymbol.prototype.getDefinitionSignature = function () { - return this.definitionSignature; - }; - return PullConstructorTypeSymbol; - })(PullTypeSymbol); - TypeScript.PullConstructorTypeSymbol = PullConstructorTypeSymbol; - - var PullTypeParameterSymbol = (function (_super) { - __extends(PullTypeParameterSymbol, _super); - function PullTypeParameterSymbol(name, _isFunctionTypeParameter) { - _super.call(this, name, 8192 /* TypeParameter */); - this._isFunctionTypeParameter = _isFunctionTypeParameter; - this.constraintLink = null; - } - PullTypeParameterSymbol.prototype.isTypeParameter = function () { - return true; - }; - PullTypeParameterSymbol.prototype.isFunctionTypeParameter = function () { - return this._isFunctionTypeParameter; - }; - - PullTypeParameterSymbol.prototype.isFixed = function () { - return false; - }; - - PullTypeParameterSymbol.prototype.setConstraint = function (constraintType) { - if (this.constraintLink) { - this.removeOutgoingLink(this.constraintLink); - } - - this.constraintLink = this.addOutgoingLink(constraintType, 22 /* TypeConstraint */); - }; - - PullTypeParameterSymbol.prototype.getConstraint = function () { - if (this.constraintLink) { - return this.constraintLink.end; - } - - return null; - }; - - PullTypeParameterSymbol.prototype.isGeneric = function () { - return true; - }; - - PullTypeParameterSymbol.prototype.fullName = function (scopeSymbol) { - var name = this.getDisplayName(scopeSymbol); - var container = this.getContainer(); - if (container) { - var containerName = container.fullName(scopeSymbol); - name = name + " in " + containerName; - } - - return name; - }; - - PullTypeParameterSymbol.prototype.getName = function (scopeSymbol, useConstraintInName) { - var name = _super.prototype.getName.call(this, scopeSymbol); - - if (this.isPrinting) { - return name; - } - - this.isPrinting = true; - - if (useConstraintInName && this.constraintLink) { - name += " extends " + this.constraintLink.end.toString(); - } - - this.isPrinting = false; - - return name; - }; - - PullTypeParameterSymbol.prototype.getDisplayName = function (scopeSymbol, useConstraintInName) { - var name = _super.prototype.getDisplayName.call(this, scopeSymbol, useConstraintInName); - - if (this.isPrinting) { - return name; - } - - this.isPrinting = true; - - if (useConstraintInName && this.constraintLink) { - name += " extends " + this.constraintLink.end.toString(); - } - - this.isPrinting = false; - - return name; - }; - - PullTypeParameterSymbol.prototype.isExternallyVisible = function (inIsExternallyVisibleSymbols) { - var constraint = this.getConstraint(); - if (constraint) { - return PullSymbol.getIsExternallyVisible(constraint, this, inIsExternallyVisibleSymbols); - } - - return true; - }; - return PullTypeParameterSymbol; - })(PullTypeSymbol); - TypeScript.PullTypeParameterSymbol = PullTypeParameterSymbol; - - var PullTypeVariableSymbol = (function (_super) { - __extends(PullTypeVariableSymbol, _super); - function PullTypeVariableSymbol(name, isFunctionTypeParameter) { - _super.call(this, name, isFunctionTypeParameter); - this.tyvarID = TypeScript.globalTyvarID++; - } - PullTypeVariableSymbol.prototype.isTypeParameter = function () { - return true; - }; - PullTypeVariableSymbol.prototype.isTypeVariable = function () { - return true; - }; - return PullTypeVariableSymbol; - })(PullTypeParameterSymbol); - TypeScript.PullTypeVariableSymbol = PullTypeVariableSymbol; - - var PullAccessorSymbol = (function (_super) { - __extends(PullAccessorSymbol, _super); - function PullAccessorSymbol(name) { - _super.call(this, name, 4096 /* Property */); - this.getterSymbolLink = null; - this.setterSymbolLink = null; - } - PullAccessorSymbol.prototype.isAccessor = function () { - return true; - }; - - PullAccessorSymbol.prototype.setSetter = function (setter) { - this.setterSymbolLink = this.addOutgoingLink(setter, 25 /* SetterFunction */); - }; - - PullAccessorSymbol.prototype.getSetter = function () { - var setter = null; - - if (this.setterSymbolLink) { - setter = this.setterSymbolLink.end; - } - - return setter; - }; - - PullAccessorSymbol.prototype.removeSetter = function () { - if (this.setterSymbolLink) { - this.removeOutgoingLink(this.setterSymbolLink); - } - }; - - PullAccessorSymbol.prototype.setGetter = function (getter) { - this.getterSymbolLink = this.addOutgoingLink(getter, 24 /* GetterFunction */); - }; - - PullAccessorSymbol.prototype.getGetter = function () { - var getter = null; - - if (this.getterSymbolLink) { - getter = this.getterSymbolLink.end; - } - - return getter; - }; - - PullAccessorSymbol.prototype.removeGetter = function () { - if (this.getterSymbolLink) { - this.removeOutgoingLink(this.getterSymbolLink); - } - }; - - PullAccessorSymbol.prototype.invalidate = function () { - if (this.getterSymbolLink) { - this.getterSymbolLink.end.invalidate(); - } - - if (this.setterSymbolLink) { - this.setterSymbolLink.end.invalidate(); - } - - _super.prototype.invalidate.call(this); - }; - return PullAccessorSymbol; - })(PullSymbol); - TypeScript.PullAccessorSymbol = PullAccessorSymbol; - - var PullArrayTypeSymbol = (function (_super) { - __extends(PullArrayTypeSymbol, _super); - function PullArrayTypeSymbol() { - _super.call(this, "Array", 128 /* Array */); - this.elementType = null; - } - PullArrayTypeSymbol.prototype.isArray = function () { - return true; - }; - PullArrayTypeSymbol.prototype.getElementType = function () { - return this.elementType; - }; - PullArrayTypeSymbol.prototype.isGeneric = function () { - return true; - }; - - PullArrayTypeSymbol.prototype.setElementType = function (type) { - this.elementType = type; - }; - - PullArrayTypeSymbol.prototype.getScopedNameEx = function (scopeSymbol, useConstraintInName, getPrettyTypeName, getTypeParamMarkerInfo) { - var elementMemberName = this.elementType ? (this.elementType.isArray() || this.elementType.isNamedTypeSymbol() ? this.elementType.getScopedNameEx(scopeSymbol, false, getPrettyTypeName, getTypeParamMarkerInfo) : this.elementType.getMemberTypeNameEx(false, scopeSymbol, getPrettyTypeName)) : TypeScript.MemberName.create("any"); - return TypeScript.MemberName.create(elementMemberName, "", "[]"); - }; - - PullArrayTypeSymbol.prototype.getMemberTypeNameEx = function (topLevel, scopeSymbol, getPrettyTypeName) { - var elementMemberName = this.elementType ? this.elementType.getMemberTypeNameEx(false, scopeSymbol, getPrettyTypeName) : TypeScript.MemberName.create("any"); - return TypeScript.MemberName.create(elementMemberName, "", "[]"); - }; - return PullArrayTypeSymbol; - })(PullTypeSymbol); - TypeScript.PullArrayTypeSymbol = PullArrayTypeSymbol; - - function specializeToArrayType(typeToReplace, typeToSpecializeTo, resolver, context) { - var arrayInterfaceType = resolver.getCachedArrayType(); - - if (!arrayInterfaceType || (arrayInterfaceType.getKind() & 16 /* Interface */) === 0) { - return null; - } - - if (arrayInterfaceType.isGeneric()) { - var enclosingDecl = arrayInterfaceType.getDeclarations()[0]; - return specializeType(arrayInterfaceType, [typeToSpecializeTo], resolver, enclosingDecl, context); - } - - if (typeToSpecializeTo.getArrayType()) { - return typeToSpecializeTo.getArrayType(); - } - - var newArrayType = new PullArrayTypeSymbol(); - newArrayType.addDeclaration(arrayInterfaceType.getDeclarations()[0]); - - typeToSpecializeTo.setArrayType(newArrayType); - newArrayType.addOutgoingLink(typeToSpecializeTo, 4 /* ArrayOf */); - - var field = null; - var newField = null; - var fieldType = null; - - var method = null; - var methodType = null; - var newMethod = null; - var newMethodType = null; - - var signatures = null; - var newSignature = null; - - var parameters = null; - var newParameter = null; - var parameterType = null; - - var returnType = null; - var newReturnType = null; - - var members = arrayInterfaceType.getMembers(); - - for (var i = 0; i < members.length; i++) { - resolver.resolveDeclaredSymbol(members[i], null, context); - - if (members[i].getKind() === 65536 /* Method */) { - method = members[i]; - - resolver.resolveDeclaredSymbol(method, null, context); - - methodType = method.getType(); - - newMethod = new PullSymbol(method.getName(), 65536 /* Method */); - newMethodType = new PullFunctionTypeSymbol(); - newMethod.setType(newMethodType); - - newMethod.addDeclaration(method.getDeclarations()[0]); - - signatures = methodType.getCallSignatures(); - - for (var j = 0; j < signatures.length; j++) { - newSignature = new PullSignatureSymbol(1048576 /* CallSignature */); - newSignature.addDeclaration(signatures[j].getDeclarations()[0]); - - parameters = signatures[j].getParameters(); - returnType = signatures[j].getReturnType(); - - if (returnType === typeToReplace) { - newSignature.setReturnType(typeToSpecializeTo); - } else { - newSignature.setReturnType(returnType); - } - - for (var k = 0; k < parameters.length; k++) { - newParameter = new PullSymbol(parameters[k].getName(), parameters[k].getKind()); - - parameterType = parameters[k].getType(); - - if (parameterType === null) { - continue; - } - - if (parameterType === typeToReplace) { - newParameter.setType(typeToSpecializeTo); - } else { - newParameter.setType(parameterType); - } - - newSignature.addParameter(newParameter); - } - - newMethodType.addSignature(newSignature); - } - - newArrayType.addMember(newMethod, 5 /* PublicMember */); - } else { - field = members[i]; - - newField = new PullSymbol(field.getName(), field.getKind()); - newField.addDeclaration(field.getDeclarations()[0]); - - fieldType = field.getType(); - - if (fieldType === typeToReplace) { - newField.setType(typeToSpecializeTo); - } else { - newField.setType(fieldType); - } - - newArrayType.addMember(newField, 5 /* PublicMember */); - } - } - newArrayType.addOutgoingLink(arrayInterfaceType, 3 /* ArrayType */); - return newArrayType; - } - TypeScript.specializeToArrayType = specializeToArrayType; - - function typeWrapsTypeParameter(type, typeParameter) { - if (type.isTypeParameter()) { - return type == typeParameter; - } - - var typeArguments = type.getTypeArguments(); - - if (typeArguments) { - for (var i = 0; i < typeArguments.length; i++) { - if (typeWrapsTypeParameter(typeArguments[i], typeParameter)) { - return true; - } - } - } - - return false; - } - TypeScript.typeWrapsTypeParameter = typeWrapsTypeParameter; - - function getRootType(typeToSpecialize) { - var decl = typeToSpecialize.getDeclarations()[0]; - - if (!typeToSpecialize.isGeneric()) { - return typeToSpecialize; - } - - return (typeToSpecialize.getKind() & (8 /* Class */ | 16 /* Interface */)) ? decl.getSymbol().getType() : typeToSpecialize; - } - TypeScript.getRootType = getRootType; - - TypeScript.nSpecializationsCreated = 0; - TypeScript.nSpecializedSignaturesCreated = 0; - - function shouldSpecializeTypeParameterForTypeParameter(specialization, typeToSpecialize) { - if (specialization == typeToSpecialize) { - return false; - } - - if (!(specialization.isTypeParameter() && typeToSpecialize.isTypeParameter())) { - return true; - } - - var parent = specialization.getDeclarations()[0].getParentDecl(); - var targetParent = typeToSpecialize.getDeclarations()[0].getParentDecl(); - - if (parent == targetParent) { - return true; - } - - while (parent) { - if (parent.getFlags() & 16 /* Static */) { - return true; - } - - if (parent == targetParent) { - return false; - } - - parent = parent.getParentDecl(); - } - - return true; - } - TypeScript.shouldSpecializeTypeParameterForTypeParameter = shouldSpecializeTypeParameterForTypeParameter; - - function specializeType(typeToSpecialize, typeArguments, resolver, enclosingDecl, context, ast) { - if (typeToSpecialize.isPrimitive() || !typeToSpecialize.isGeneric()) { - return typeToSpecialize; - } - - var searchForExistingSpecialization = typeArguments != null; - - if (typeArguments === null || (context.specializingToAny && typeArguments.length)) { - typeArguments = []; - } - - if (typeToSpecialize.isTypeParameter()) { - if (context.specializingToAny) { - return resolver.semanticInfoChain.anyTypeSymbol; - } - - var substitution = context.findSpecializationForType(typeToSpecialize); - - if (substitution != typeToSpecialize) { - if (shouldSpecializeTypeParameterForTypeParameter(substitution, typeToSpecialize)) { - return substitution; - } - } - - if (typeArguments && typeArguments.length) { - if (shouldSpecializeTypeParameterForTypeParameter(typeArguments[0], typeToSpecialize)) { - return typeArguments[0]; - } - } - - return typeToSpecialize; - } - - if (typeToSpecialize.isArray()) { - if (typeToSpecialize.currentlyBeingSpecialized()) { - return typeToSpecialize; - } - - var newElementType = null; - - if (!context.specializingToAny) { - var elementType = (typeToSpecialize).getElementType(); - - newElementType = specializeType(elementType, typeArguments, resolver, enclosingDecl, context, ast); - } else { - newElementType = resolver.semanticInfoChain.anyTypeSymbol; - } - - var newArrayType = specializeType(resolver.getCachedArrayType(), [newElementType], resolver, enclosingDecl, context); - - return newArrayType; - } - - var typeParameters = typeToSpecialize.getTypeParameters(); - - if (!context.specializingToAny && searchForExistingSpecialization && (typeParameters.length > typeArguments.length)) { - searchForExistingSpecialization = false; - } - - var newType = null; - - var newTypeDecl = typeToSpecialize.getDeclarations()[0]; - - var rootType = getRootType(typeToSpecialize); - - var isArray = typeToSpecialize === resolver.getCachedArrayType() || typeToSpecialize.isArray(); - - if (searchForExistingSpecialization || context.specializingToAny) { - if (!typeArguments.length || context.specializingToAny) { - for (var i = 0; i < typeParameters.length; i++) { - typeArguments[typeArguments.length] = resolver.semanticInfoChain.anyTypeSymbol; - } - } - - if (isArray) { - newType = typeArguments[0].getArrayType(); - } else if (typeArguments.length) { - newType = rootType.getSpecialization(typeArguments); - } - - if (!newType && !typeParameters.length && context.specializingToAny) { - newType = rootType.getSpecialization([resolver.semanticInfoChain.anyTypeSymbol]); - } - - for (var i = 0; i < typeArguments.length; i++) { - if (!typeArguments[i].isTypeParameter() && (typeArguments[i] == rootType || typeWrapsTypeParameter(typeArguments[i], typeParameters[i]))) { - declAST = resolver.semanticInfoChain.getASTForDecl(newTypeDecl); - if (declAST && typeArguments[i] != resolver.getCachedArrayType()) { - diagnostic = context.postError(enclosingDecl.getScriptName(), declAST.minChar, declAST.getLength(), 225 /* A_generic_type_may_not_reference_itself_with_its_own_type_parameters */, null, enclosingDecl, true); - return resolver.getNewErrorTypeSymbol(diagnostic); - } else { - return resolver.semanticInfoChain.anyTypeSymbol; - } - } - } - } else { - var knownTypeArguments = typeToSpecialize.getTypeArguments(); - var typesToReplace = knownTypeArguments ? knownTypeArguments : typeParameters; - var diagnostic; - var declAST; - - for (var i = 0; i < typesToReplace.length; i++) { - if (!typesToReplace[i].isTypeParameter() && (typeArguments[i] == rootType || typeWrapsTypeParameter(typesToReplace[i], typeParameters[i]))) { - declAST = resolver.semanticInfoChain.getASTForDecl(newTypeDecl); - if (declAST && typeArguments[i] != resolver.getCachedArrayType()) { - diagnostic = context.postError(enclosingDecl.getScriptName(), declAST.minChar, declAST.getLength(), 225 /* A_generic_type_may_not_reference_itself_with_its_own_type_parameters */, null, enclosingDecl, true); - return resolver.getNewErrorTypeSymbol(diagnostic); - } else { - return resolver.semanticInfoChain.anyTypeSymbol; - } - } - - substitution = specializeType(typesToReplace[i], null, resolver, enclosingDecl, context, ast); - - typeArguments[i] = substitution != null ? substitution : typesToReplace[i]; - } - - newType = rootType.getSpecialization(typeArguments); - } - - var rootTypeParameters = rootType.getTypeParameters(); - - if (rootTypeParameters.length && (rootTypeParameters.length == typeArguments.length)) { - for (var i = 0; i < typeArguments.length; i++) { - if (typeArguments[i] != rootTypeParameters[i]) { - break; - } - } - - if (i == rootTypeParameters.length) { - return rootType; - } - } - - if (newType) { - if (!newType.isResolved() && !newType.currentlyBeingSpecialized()) { - typeToSpecialize.invalidateSpecializations(); - } else { - return newType; - } - } - - var prevInSpecialization = context.inSpecialization; - context.inSpecialization = true; - - TypeScript.nSpecializationsCreated++; - - newType = typeToSpecialize.isClass() ? new PullClassTypeSymbol(typeToSpecialize.getName()) : isArray ? new PullArrayTypeSymbol() : typeToSpecialize.isTypeParameter() ? new PullTypeVariableSymbol(typeToSpecialize.getName(), (typeToSpecialize).isFunctionTypeParameter()) : new PullTypeSymbol(typeToSpecialize.getName(), typeToSpecialize.getKind()); - newType.setRootSymbol(rootType); - - newType.setIsBeingSpecialized(); - - newType.setTypeArguments(typeArguments); - - rootType.addSpecialization(newType, typeArguments); - - if (isArray) { - (newType).setElementType(typeArguments[0]); - typeArguments[0].setArrayType(newType); - } - - if (typeToSpecialize.currentlyBeingSpecialized()) { - return newType; - } - - var prevCurrentlyBeingSpecialized = typeToSpecialize.currentlyBeingSpecialized(); - if (typeToSpecialize.getKind() == 33554432 /* ConstructorType */) { - typeToSpecialize.setIsBeingSpecialized(); - } - - var typeReplacementMap = {}; - - for (var i = 0; i < typeParameters.length; i++) { - if (typeParameters[i] != typeArguments[i]) { - typeReplacementMap[typeParameters[i].getSymbolID().toString()] = typeArguments[i]; - } - newType.addMember(typeParameters[i], 18 /* TypeParameter */, true); - } - - var extendedTypesToSpecialize = typeToSpecialize.getExtendedTypes(); - var typeDecl; - var typeAST; - var unitPath; - var decls = typeToSpecialize.getDeclarations(); - - if (extendedTypesToSpecialize.length) { - for (var i = 0; i < decls.length; i++) { - typeDecl = decls[i]; - typeAST = resolver.semanticInfoChain.getASTForDecl(typeDecl); - - if (typeAST.extendsList) { - unitPath = resolver.getUnitPath(); - resolver.setUnitPath(typeDecl.getScriptName()); - context.pushTypeSpecializationCache(typeReplacementMap); - var extendTypeSymbol = resolver.resolveTypeReference(new TypeScript.TypeReference(typeAST.extendsList.members[0], 0), typeDecl, context).symbol; - resolver.setUnitPath(unitPath); - context.popTypeSpecializationCache(); - - newType.addExtendedType(extendTypeSymbol); - } - } - } - - var implementedTypesToSpecialize = typeToSpecialize.getImplementedTypes(); - - if (implementedTypesToSpecialize.length) { - for (var i = 0; i < decls.length; i++) { - typeDecl = decls[i]; - typeAST = resolver.semanticInfoChain.getASTForDecl(typeDecl); - - if (typeAST.implementsList) { - unitPath = resolver.getUnitPath(); - resolver.setUnitPath(typeDecl.getScriptName()); - context.pushTypeSpecializationCache(typeReplacementMap); - var implementedTypeSymbol = resolver.resolveTypeReference(new TypeScript.TypeReference(typeAST.implementsList.members[0], 0), typeDecl, context).symbol; - resolver.setUnitPath(unitPath); - context.popTypeSpecializationCache(); - - newType.addImplementedType(implementedTypeSymbol); - } - } - } - - var callSignatures = typeToSpecialize.getCallSignatures(false); - var constructSignatures = typeToSpecialize.getConstructSignatures(false); - var indexSignatures = typeToSpecialize.getIndexSignatures(false); - var members = typeToSpecialize.getMembers(); - - var newSignature; - var signature; - - var decl = null; - var declAST = null; - var parameters; - var newParameters; - var returnType = null; - var prevSpecializationSignature = null; - - for (var i = 0; i < callSignatures.length; i++) { - signature = callSignatures[i]; - - if (!signature.currentlyBeingSpecialized()) { - context.pushTypeSpecializationCache(typeReplacementMap); - - decl = signature.getDeclarations()[0]; - unitPath = resolver.getUnitPath(); - resolver.setUnitPath(decl.getScriptName()); - - newSignature = new PullSignatureSymbol(signature.getKind()); - TypeScript.nSpecializedSignaturesCreated++; - newSignature.mimicSignature(signature, resolver); - declAST = resolver.semanticInfoChain.getASTForDecl(decl); - - TypeScript.Debug.assert(declAST != null, "Call signature for type '" + typeToSpecialize.toString() + "' could not be specialized because of a stale declaration"); - - prevSpecializationSignature = decl.getSpecializingSignatureSymbol(); - decl.setSpecializingSignatureSymbol(newSignature); - resolver.resolveAST(declAST, false, newTypeDecl, context); - decl.setSpecializingSignatureSymbol(prevSpecializationSignature); - - parameters = signature.getParameters(); - newParameters = newSignature.getParameters(); - - for (var p = 0; p < parameters.length; p++) { - newParameters[p].setType(parameters[p].getType()); - } - newSignature.setResolved(); - - resolver.setUnitPath(unitPath); - - returnType = newSignature.getReturnType(); - - if (!returnType) { - newSignature.setReturnType(signature.getReturnType()); - } - - signature.setIsBeingSpecialized(); - newSignature.setRootSymbol(signature); - newSignature = specializeSignature(newSignature, true, typeReplacementMap, null, resolver, newTypeDecl, context); - signature.setIsSpecialized(); - - context.popTypeSpecializationCache(); - - if (!newSignature) { - context.inSpecialization = prevInSpecialization; - typeToSpecialize.setValueIsBeingSpecialized(prevCurrentlyBeingSpecialized); - TypeScript.Debug.assert(false, "returning from call"); - return resolver.semanticInfoChain.anyTypeSymbol; - } - } else { - newSignature = signature; - } - - newType.addCallSignature(newSignature); - - if (newSignature.hasGenericParameter()) { - newType.setHasGenericSignature(); - } - } - - for (var i = 0; i < constructSignatures.length; i++) { - signature = constructSignatures[i]; - - if (!signature.currentlyBeingSpecialized()) { - context.pushTypeSpecializationCache(typeReplacementMap); - - decl = signature.getDeclarations()[0]; - unitPath = resolver.getUnitPath(); - resolver.setUnitPath(decl.getScriptName()); - - newSignature = new PullSignatureSymbol(signature.getKind()); - TypeScript.nSpecializedSignaturesCreated++; - newSignature.mimicSignature(signature, resolver); - declAST = resolver.semanticInfoChain.getASTForDecl(decl); - - TypeScript.Debug.assert(declAST != null, "Construct signature for type '" + typeToSpecialize.toString() + "' could not be specialized because of a stale declaration"); - - prevSpecializationSignature = decl.getSpecializingSignatureSymbol(); - decl.setSpecializingSignatureSymbol(newSignature); - resolver.resolveAST(declAST, false, newTypeDecl, context); - decl.setSpecializingSignatureSymbol(prevSpecializationSignature); - - parameters = signature.getParameters(); - newParameters = newSignature.getParameters(); - - for (var p = 0; p < parameters.length; p++) { - newParameters[p].setType(parameters[p].getType()); - } - newSignature.setResolved(); - - resolver.setUnitPath(unitPath); - - returnType = newSignature.getReturnType(); - - if (!returnType) { - newSignature.setReturnType(signature.getReturnType()); - } - - signature.setIsBeingSpecialized(); - newSignature.setRootSymbol(signature); - newSignature = specializeSignature(newSignature, true, typeReplacementMap, null, resolver, newTypeDecl, context); - signature.setIsSpecialized(); - - context.popTypeSpecializationCache(); - - if (!newSignature) { - context.inSpecialization = prevInSpecialization; - typeToSpecialize.setValueIsBeingSpecialized(prevCurrentlyBeingSpecialized); - TypeScript.Debug.assert(false, "returning from construct"); - return resolver.semanticInfoChain.anyTypeSymbol; - } - } else { - newSignature = signature; - } - - newType.addConstructSignature(newSignature); - - if (newSignature.hasGenericParameter()) { - newType.setHasGenericSignature(); - } - } - - for (var i = 0; i < indexSignatures.length; i++) { - signature = indexSignatures[i]; - - if (!signature.currentlyBeingSpecialized()) { - context.pushTypeSpecializationCache(typeReplacementMap); - - decl = signature.getDeclarations()[0]; - unitPath = resolver.getUnitPath(); - resolver.setUnitPath(decl.getScriptName()); - - newSignature = new PullSignatureSymbol(signature.getKind()); - TypeScript.nSpecializedSignaturesCreated++; - newSignature.mimicSignature(signature, resolver); - declAST = resolver.semanticInfoChain.getASTForDecl(decl); - - TypeScript.Debug.assert(declAST != null, "Index signature for type '" + typeToSpecialize.toString() + "' could not be specialized because of a stale declaration"); - - prevSpecializationSignature = decl.getSpecializingSignatureSymbol(); - decl.setSpecializingSignatureSymbol(newSignature); - resolver.resolveAST(declAST, false, newTypeDecl, context); - decl.setSpecializingSignatureSymbol(prevSpecializationSignature); - - parameters = signature.getParameters(); - newParameters = newSignature.getParameters(); - - for (var p = 0; p < parameters.length; p++) { - newParameters[p].setType(parameters[p].getType()); - } - newSignature.setResolved(); - - resolver.setUnitPath(unitPath); - - returnType = newSignature.getReturnType(); - - if (!returnType) { - newSignature.setReturnType(signature.getReturnType()); - } - - signature.setIsBeingSpecialized(); - newSignature.setRootSymbol(signature); - newSignature = specializeSignature(newSignature, true, typeReplacementMap, null, resolver, newTypeDecl, context); - signature.setIsSpecialized(); - - context.popTypeSpecializationCache(); - - if (!newSignature) { - context.inSpecialization = prevInSpecialization; - typeToSpecialize.setValueIsBeingSpecialized(prevCurrentlyBeingSpecialized); - TypeScript.Debug.assert(false, "returning from index"); - return resolver.semanticInfoChain.anyTypeSymbol; - } - } else { - newSignature = signature; - } - - newType.addIndexSignature(newSignature); - - if (newSignature.hasGenericParameter()) { - newType.setHasGenericSignature(); - } - } - - var field = null; - var newField = null; - - var fieldType = null; - var newFieldType = null; - var replacementType = null; - - var fieldSignatureSymbol = null; - - for (var i = 0; i < members.length; i++) { - field = members[i]; - field.setIsBeingSpecialized(); - - decls = field.getDeclarations(); - - newField = new PullSymbol(field.getName(), field.getKind()); - - newField.setRootSymbol(field); - - if (field.getIsOptional()) { - newField.setIsOptional(); - } - - if (!field.isResolved()) { - resolver.resolveDeclaredSymbol(field, newTypeDecl, context); - } - - fieldType = field.getType(); - - if (!fieldType) { - fieldType = newType; - } - - replacementType = typeReplacementMap[fieldType.getSymbolID().toString()]; - - if (replacementType) { - newField.setType(replacementType); - } else { - if (fieldType.isGeneric() && !fieldType.isFixed()) { - unitPath = resolver.getUnitPath(); - resolver.setUnitPath(decls[0].getScriptName()); - - context.pushTypeSpecializationCache(typeReplacementMap); - - newFieldType = specializeType(fieldType, !fieldType.getIsSpecialized() ? typeArguments : null, resolver, newTypeDecl, context, ast); - - resolver.setUnitPath(unitPath); - - context.popTypeSpecializationCache(); - - newField.setType(newFieldType); - } else { - newField.setType(fieldType); - } - } - field.setIsSpecialized(); - newType.addMember(newField, (field.hasFlag(2 /* Private */)) ? 6 /* PrivateMember */ : 5 /* PublicMember */); - } - - if (typeToSpecialize.isClass()) { - var constructorMethod = (typeToSpecialize).getConstructorMethod(); - - if (!constructorMethod.isResolved()) { - var prevIsSpecializingConstructorMethod = context.isSpecializingConstructorMethod; - context.isSpecializingConstructorMethod = true; - resolver.resolveDeclaredSymbol(constructorMethod, enclosingDecl, context); - context.isSpecializingConstructorMethod = prevIsSpecializingConstructorMethod; - } - - var newConstructorMethod = new PullSymbol(constructorMethod.getName(), 32768 /* ConstructorMethod */); - var newConstructorType = specializeType(constructorMethod.getType(), typeArguments, resolver, newTypeDecl, context, ast); - - newConstructorMethod.setType(newConstructorType); - - var constructorDecls = constructorMethod.getDeclarations(); - - newConstructorMethod.setRootSymbol(constructorMethod); - - (newType).setConstructorMethod(newConstructorMethod); - } - - newType.setIsSpecialized(); - - newType.setResolved(); - typeToSpecialize.setValueIsBeingSpecialized(prevCurrentlyBeingSpecialized); - context.inSpecialization = prevInSpecialization; - return newType; - } - TypeScript.specializeType = specializeType; - - function specializeSignature(signature, skipLocalTypeParameters, typeReplacementMap, typeArguments, resolver, enclosingDecl, context, ast) { - if (signature.currentlyBeingSpecialized()) { - return signature; - } - - if (!signature.isResolved() && !signature.isResolving()) { - resolver.resolveDeclaredSymbol(signature, enclosingDecl, context); - } - - var newSignature = signature.getSpecialization(typeArguments); - - if (newSignature) { - return newSignature; - } - - signature.setIsBeingSpecialized(); - - var prevInSpecialization = context.inSpecialization; - context.inSpecialization = true; - - newSignature = new PullSignatureSymbol(signature.getKind()); - TypeScript.nSpecializedSignaturesCreated++; - newSignature.setRootSymbol(signature); - - if (signature.hasVariableParamList()) { - newSignature.setHasVariableParamList(); - } - - if (signature.hasGenericParameter()) { - newSignature.setHasGenericParameter(); - } - - signature.addSpecialization(newSignature, typeArguments); - - var parameters = signature.getParameters(); - var typeParameters = signature.getTypeParameters(); - var returnType = signature.getReturnType(); - - for (var i = 0; i < typeParameters.length; i++) { - newSignature.addTypeParameter(typeParameters[i]); - } - - if (signature.hasGenericParameter()) { - newSignature.setHasGenericParameter(); - } - - var newParameter; - var newParameterType; - var newParameterElementType; - var parameterType; - var replacementParameterType; - var localTypeParameters = new TypeScript.BlockIntrinsics(); - var localSkipMap = null; - - if (skipLocalTypeParameters) { - for (var i = 0; i < typeParameters.length; i++) { - localTypeParameters[typeParameters[i].getName()] = true; - if (!localSkipMap) { - localSkipMap = {}; - } - localSkipMap[typeParameters[i].getSymbolID().toString()] = typeParameters[i]; - } - } - - context.pushTypeSpecializationCache(typeReplacementMap); - - if (skipLocalTypeParameters && localSkipMap) { - context.pushTypeSpecializationCache(localSkipMap); - } - var newReturnType = (!localTypeParameters[returnType.getName()]) ? specializeType(returnType, null, resolver, enclosingDecl, context, ast) : returnType; - if (skipLocalTypeParameters && localSkipMap) { - context.popTypeSpecializationCache(); - } - context.popTypeSpecializationCache(); - - newSignature.setReturnType(newReturnType); - - for (var k = 0; k < parameters.length; k++) { - newParameter = new PullSymbol(parameters[k].getName(), parameters[k].getKind()); - newParameter.setRootSymbol(parameters[k]); - - parameterType = parameters[k].getType(); - - context.pushTypeSpecializationCache(typeReplacementMap); - if (skipLocalTypeParameters && localSkipMap) { - context.pushTypeSpecializationCache(localSkipMap); - } - newParameterType = !localTypeParameters[parameterType.getName()] ? specializeType(parameterType, null, resolver, enclosingDecl, context, ast) : parameterType; - if (skipLocalTypeParameters && localSkipMap) { - context.popTypeSpecializationCache(); - } - context.popTypeSpecializationCache(); - - if (parameters[k].getIsOptional()) { - newParameter.setIsOptional(); - } - - if (parameters[k].getIsVarArg()) { - newParameter.setIsVarArg(); - newSignature.setHasVariableParamList(); - } - - if (resolver.isTypeArgumentOrWrapper(newParameterType)) { - newSignature.setHasGenericParameter(); - } - - newParameter.setType(newParameterType); - newSignature.addParameter(newParameter, newParameter.getIsOptional()); - } - - signature.setIsSpecialized(); - - context.inSpecialization = prevInSpecialization; - - return newSignature; - } - TypeScript.specializeSignature = specializeSignature; - - function getIDForTypeSubstitutions(types) { - var substitution = ""; - - for (var i = 0; i < types.length; i++) { - substitution += types[i].getSymbolID().toString() + "#"; - } - - return substitution; - } - TypeScript.getIDForTypeSubstitutions = getIDForTypeSubstitutions; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var PullSymbolBindingContext = (function () { - function PullSymbolBindingContext(semanticInfoChain, scriptName) { - this.semanticInfoChain = semanticInfoChain; - this.scriptName = scriptName; - this.parentChain = []; - this.declPath = []; - this.reBindingAfterChange = false; - this.startingDeclForRebind = TypeScript.pullDeclID; - this.semanticInfo = this.semanticInfoChain.getUnit(this.scriptName); - } - PullSymbolBindingContext.prototype.getParent = function (n) { - if (typeof n === "undefined") { n = 0; } - return this.parentChain ? this.parentChain[this.parentChain.length - 1 - n] : null; - }; - PullSymbolBindingContext.prototype.getDeclPath = function () { - return this.declPath; - }; - - PullSymbolBindingContext.prototype.pushParent = function (parentDecl) { - if (parentDecl) { - this.parentChain[this.parentChain.length] = parentDecl; - this.declPath[this.declPath.length] = parentDecl.getName(); - } - }; - - PullSymbolBindingContext.prototype.popParent = function () { - if (this.parentChain.length) { - this.parentChain.length--; - this.declPath.length--; - } - }; - return PullSymbolBindingContext; - })(); - TypeScript.PullSymbolBindingContext = PullSymbolBindingContext; - - TypeScript.time_in_findSymbol = 0; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var CandidateInferenceInfo = (function () { - function CandidateInferenceInfo() { - this.typeParameter = null; - this.isFixed = false; - this.inferenceCandidates = []; - } - CandidateInferenceInfo.prototype.addCandidate = function (candidate) { - if (!this.isFixed) { - this.inferenceCandidates[this.inferenceCandidates.length] = candidate; - } - }; - return CandidateInferenceInfo; - })(); - TypeScript.CandidateInferenceInfo = CandidateInferenceInfo; - - var ArgumentInferenceContext = (function () { - function ArgumentInferenceContext() { - this.inferenceCache = {}; - this.candidateCache = {}; - } - ArgumentInferenceContext.prototype.alreadyRelatingTypes = function (objectType, parameterType) { - var comboID = objectType.getSymbolID().toString() + "#" + parameterType.getSymbolID().toString(); - - if (this.inferenceCache[comboID]) { - return true; - } else { - this.inferenceCache[comboID] = true; - return false; - } - }; - - ArgumentInferenceContext.prototype.resetRelationshipCache = function () { - this.inferenceCache = {}; - }; - - ArgumentInferenceContext.prototype.addInferenceRoot = function (param) { - var info = this.candidateCache[param.getSymbolID().toString()]; - - if (!info) { - info = new CandidateInferenceInfo(); - info.typeParameter = param; - this.candidateCache[param.getSymbolID().toString()] = info; - } - }; - - ArgumentInferenceContext.prototype.getInferenceInfo = function (param) { - return this.candidateCache[param.getSymbolID().toString()]; - }; - - ArgumentInferenceContext.prototype.addCandidateForInference = function (param, candidate, fix) { - var info = this.getInferenceInfo(param); - - if (info) { - if (candidate) { - info.addCandidate(candidate); - } - - if (!info.isFixed) { - info.isFixed = fix; - } - } - }; - - ArgumentInferenceContext.prototype.getInferenceCandidates = function () { - var inferenceCandidates = []; - var info; - var val; - - for (var infoKey in this.candidateCache) { - info = this.candidateCache[infoKey]; - - for (var i = 0; i < info.inferenceCandidates.length; i++) { - val = {}; - val[info.typeParameter.getSymbolID().toString()] = info.inferenceCandidates[i]; - inferenceCandidates[inferenceCandidates.length] = val; - } - } - - return inferenceCandidates; - }; - - ArgumentInferenceContext.prototype.inferArgumentTypes = function (resolver, context) { - var info = null; - - var collection; - - var bestCommonType; - - var results = []; - - var unfit = false; - - for (var infoKey in this.candidateCache) { - info = this.candidateCache[infoKey]; - - if (!info.inferenceCandidates.length) { - results[results.length] = { param: info.typeParameter, type: resolver.semanticInfoChain.anyTypeSymbol }; - continue; - } - - collection = { - getLength: function () { - return info.inferenceCandidates.length; - }, - setTypeAtIndex: function (index, type) { - }, - getTypeAtIndex: function (index) { - return info.inferenceCandidates[index].getType(); - } - }; - - bestCommonType = resolver.widenType(resolver.findBestCommonType(info.inferenceCandidates[0], null, collection, context, new TypeScript.TypeComparisonInfo())); - - if (!bestCommonType) { - unfit = true; - } else { - for (var i = 0; i < results.length; i++) { - if (results[i].type == info.typeParameter) { - results[i].type = bestCommonType; - } - } - } - - results[results.length] = { param: info.typeParameter, type: bestCommonType }; - } - - return { results: results, unfit: unfit }; - }; - return ArgumentInferenceContext; - })(); - TypeScript.ArgumentInferenceContext = ArgumentInferenceContext; - - var PullContextualTypeContext = (function () { - function PullContextualTypeContext(contextualType, provisional, substitutions) { - this.contextualType = contextualType; - this.provisional = provisional; - this.substitutions = substitutions; - this.provisionallyTypedSymbols = []; - this.provisionalDiagnostic = []; - } - PullContextualTypeContext.prototype.recordProvisionallyTypedSymbol = function (symbol) { - this.provisionallyTypedSymbols[this.provisionallyTypedSymbols.length] = symbol; - }; - - PullContextualTypeContext.prototype.invalidateProvisionallyTypedSymbols = function () { - for (var i = 0; i < this.provisionallyTypedSymbols.length; i++) { - this.provisionallyTypedSymbols[i].invalidate(); - } - }; - - PullContextualTypeContext.prototype.postDiagnostic = function (error) { - this.provisionalDiagnostic[this.provisionalDiagnostic.length] = error; - }; - - PullContextualTypeContext.prototype.hadProvisionalErrors = function () { - return this.provisionalDiagnostic.length > 0; - }; - return PullContextualTypeContext; - })(); - TypeScript.PullContextualTypeContext = PullContextualTypeContext; - - var PullTypeResolutionContext = (function () { - function PullTypeResolutionContext() { - this.contextStack = []; - this.typeSpecializationStack = []; - this.genericASTResolutionStack = []; - this.resolvingTypeReference = false; - this.resolvingNamespaceMemberAccess = false; - this.resolveAggressively = false; - this.canUseTypeSymbol = false; - this.specializingToAny = false; - this.specializingToObject = false; - this.isResolvingClassExtendedType = false; - this.isSpecializingSignatureAtCallSite = false; - this.isSpecializingConstructorMethod = false; - this.isComparingSpecializedSignatures = false; - this.inSpecialization = false; - this.suppressErrors = false; - this.inBaseTypeResolution = false; - } - PullTypeResolutionContext.prototype.pushContextualType = function (type, provisional, substitutions) { - this.contextStack.push(new PullContextualTypeContext(type, provisional, substitutions)); - }; - - PullTypeResolutionContext.prototype.popContextualType = function () { - var tc = this.contextStack.pop(); - - tc.invalidateProvisionallyTypedSymbols(); - - return tc; - }; - - PullTypeResolutionContext.prototype.findSubstitution = function (type) { - var substitution = null; - - if (this.contextStack.length) { - for (var i = this.contextStack.length - 1; i >= 0; i--) { - if (this.contextStack[i].substitutions) { - substitution = this.contextStack[i].substitutions[type.getSymbolID().toString()]; - - if (substitution) { - break; - } - } - } - } - - return substitution; - }; - - PullTypeResolutionContext.prototype.getContextualType = function () { - var context = !this.contextStack.length ? null : this.contextStack[this.contextStack.length - 1]; - - if (context) { - var type = context.contextualType; - - if (!type) { - return null; - } - - if (type.isTypeParameter() && (type).getConstraint()) { - type = (type).getConstraint(); - } - - var substitution = this.findSubstitution(type); - - return substitution ? substitution : type; - } - - return null; - }; - - PullTypeResolutionContext.prototype.inProvisionalResolution = function () { - return (!this.contextStack.length ? false : this.contextStack[this.contextStack.length - 1].provisional); - }; - - PullTypeResolutionContext.prototype.isInBaseTypeResolution = function () { - return this.inBaseTypeResolution; - }; - - PullTypeResolutionContext.prototype.startBaseTypeResolution = function () { - var wasInBaseTypeResoltion = this.inBaseTypeResolution; - this.inBaseTypeResolution = true; - return wasInBaseTypeResoltion; - }; - - PullTypeResolutionContext.prototype.doneBaseTypeResolution = function (wasInBaseTypeResolution) { - this.inBaseTypeResolution = wasInBaseTypeResolution; - }; - - PullTypeResolutionContext.prototype.setTypeInContext = function (symbol, type) { - var substitution = this.findSubstitution(type); - - symbol.setType(substitution ? substitution : type); - - if (this.contextStack.length && this.inProvisionalResolution()) { - this.contextStack[this.contextStack.length - 1].recordProvisionallyTypedSymbol(symbol); - } - }; - - PullTypeResolutionContext.prototype.pushTypeSpecializationCache = function (cache) { - this.typeSpecializationStack[this.typeSpecializationStack.length] = cache; - }; - - PullTypeResolutionContext.prototype.popTypeSpecializationCache = function () { - if (this.typeSpecializationStack.length) { - this.typeSpecializationStack.length--; - } - }; - - PullTypeResolutionContext.prototype.findSpecializationForType = function (type) { - var specialization = null; - - for (var i = this.typeSpecializationStack.length - 1; i >= 0; i--) { - specialization = (this.typeSpecializationStack[i])[type.getSymbolID().toString()]; - - if (specialization) { - return specialization; - } - } - - return type; - }; - - PullTypeResolutionContext.prototype.postError = function (fileName, offset, length, diagnosticCode, arguments, enclosingDecl, addToDecl) { - if (typeof arguments === "undefined") { arguments = null; } - if (typeof enclosingDecl === "undefined") { enclosingDecl = null; } - if (typeof addToDecl === "undefined") { addToDecl = false; } - var diagnostic = new TypeScript.SemanticDiagnostic(fileName, offset, length, diagnosticCode, arguments); - this.postDiagnostic(diagnostic, enclosingDecl, addToDecl); - - return diagnostic; - }; - - PullTypeResolutionContext.prototype.postDiagnostic = function (diagnostic, enclosingDecl, addToDecl) { - if (this.inProvisionalResolution()) { - (this.contextStack[this.contextStack.length - 1]).postDiagnostic(diagnostic); - } else if (!this.suppressErrors && enclosingDecl && addToDecl) { - enclosingDecl.addDiagnostic(diagnostic); - } - }; - - PullTypeResolutionContext.prototype.startResolvingTypeArguments = function (ast) { - this.genericASTResolutionStack[this.genericASTResolutionStack.length] = ast; - }; - - PullTypeResolutionContext.prototype.isResolvingTypeArguments = function (ast) { - for (var i = 0; i < this.genericASTResolutionStack.length; i++) { - if (this.genericASTResolutionStack[i].getID() === ast.getID()) { - return true; - } - } - - return false; - }; - - PullTypeResolutionContext.prototype.doneResolvingTypeArguments = function () { - this.genericASTResolutionStack.length--; - }; - return PullTypeResolutionContext; - })(); - TypeScript.PullTypeResolutionContext = PullTypeResolutionContext; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var SymbolAndDiagnostics = (function () { - function SymbolAndDiagnostics(symbol, symbolAlias, diagnostics) { - this.symbol = symbol; - this.symbolAlias = symbolAlias; - this.diagnostics = diagnostics; - } - SymbolAndDiagnostics.create = function (symbol, diagnostics) { - return new SymbolAndDiagnostics(symbol, null, diagnostics); - }; - - SymbolAndDiagnostics.empty = function () { - return SymbolAndDiagnostics._empty; - }; - - SymbolAndDiagnostics.fromSymbol = function (symbol) { - return new SymbolAndDiagnostics(symbol, null, null); - }; - - SymbolAndDiagnostics.fromAlias = function (symbol, alias) { - return new SymbolAndDiagnostics(symbol, alias, null); - }; - - SymbolAndDiagnostics.prototype.addDiagnostic = function (diagnostic) { - TypeScript.Debug.assert(this !== SymbolAndDiagnostics._empty); - - if (this.diagnostics === null) { - this.diagnostics = []; - } - - this.diagnostics.push(diagnostic); - }; - - SymbolAndDiagnostics.prototype.withoutDiagnostics = function () { - if (!this.diagnostics) { - return this; - } - - return SymbolAndDiagnostics.fromSymbol(this.symbol); - }; - SymbolAndDiagnostics._empty = new SymbolAndDiagnostics(null, null, null); - return SymbolAndDiagnostics; - })(); - TypeScript.SymbolAndDiagnostics = SymbolAndDiagnostics; - - var PullResolutionDataCache = (function () { - function PullResolutionDataCache() { - this.cacheSize = 16; - this.rdCache = []; - this.nextUp = 0; - for (var i = 0; i < this.cacheSize; i++) { - this.rdCache[i] = { - actuals: [], - exactCandidates: [], - conversionCandidates: [], - id: i - }; - } - } - PullResolutionDataCache.prototype.getResolutionData = function () { - var rd = null; - - if (this.nextUp < this.cacheSize) { - rd = this.rdCache[this.nextUp]; - } - - if (rd === null) { - this.cacheSize++; - rd = { - actuals: [], - exactCandidates: [], - conversionCandidates: [], - id: this.cacheSize - }; - this.rdCache[this.cacheSize] = rd; - } - - this.nextUp++; - - return rd; - }; - - PullResolutionDataCache.prototype.returnResolutionData = function (rd) { - rd.actuals.length = 0; - rd.exactCandidates.length = 0; - rd.conversionCandidates.length = 0; - - this.nextUp = rd.id; - }; - return PullResolutionDataCache; - })(); - TypeScript.PullResolutionDataCache = PullResolutionDataCache; - - var PullAdditionalCallResolutionData = (function () { - function PullAdditionalCallResolutionData() { - this.targetSymbol = null; - this.targetTypeSymbol = null; - this.resolvedSignatures = null; - this.candidateSignature = null; - this.actualParametersContextTypeSymbols = null; - } - return PullAdditionalCallResolutionData; - })(); - TypeScript.PullAdditionalCallResolutionData = PullAdditionalCallResolutionData; - - var PullAdditionalObjectLiteralResolutionData = (function () { - function PullAdditionalObjectLiteralResolutionData() { - this.membersContextTypeSymbols = null; - } - return PullAdditionalObjectLiteralResolutionData; - })(); - TypeScript.PullAdditionalObjectLiteralResolutionData = PullAdditionalObjectLiteralResolutionData; - - var PullTypeResolver = (function () { - function PullTypeResolver(compilationSettings, semanticInfoChain, unitPath) { - this.compilationSettings = compilationSettings; - this.semanticInfoChain = semanticInfoChain; - this.unitPath = unitPath; - this._cachedArrayInterfaceType = null; - this._cachedNumberInterfaceType = null; - this._cachedStringInterfaceType = null; - this._cachedBooleanInterfaceType = null; - this._cachedObjectInterfaceType = null; - this._cachedFunctionInterfaceType = null; - this._cachedIArgumentsInterfaceType = null; - this._cachedRegExpInterfaceType = null; - this.cachedFunctionArgumentsSymbol = null; - this.assignableCache = {}; - this.subtypeCache = {}; - this.identicalCache = {}; - this.resolutionDataCache = new PullResolutionDataCache(); - this.currentUnit = null; - this.cachedFunctionArgumentsSymbol = new TypeScript.PullSymbol("arguments", 1024 /* Variable */); - this.cachedFunctionArgumentsSymbol.setType(this.cachedIArgumentsInterfaceType() ? this.cachedIArgumentsInterfaceType() : this.semanticInfoChain.anyTypeSymbol); - this.cachedFunctionArgumentsSymbol.setResolved(); - - var functionArgumentsDecl = new TypeScript.PullDecl("arguments", "arguments", 2048 /* Parameter */, 0 /* None */, new TypeScript.TextSpan(0, 0), unitPath); - functionArgumentsDecl.setSymbol(this.cachedFunctionArgumentsSymbol); - this.cachedFunctionArgumentsSymbol.addDeclaration(functionArgumentsDecl); - - this.currentUnit = this.semanticInfoChain.getUnit(unitPath); - } - PullTypeResolver.prototype.cleanCachedGlobals = function () { - this._cachedArrayInterfaceType = null; - this._cachedNumberInterfaceType = null; - this._cachedStringInterfaceType = null; - this._cachedBooleanInterfaceType = null; - this._cachedObjectInterfaceType = null; - this._cachedFunctionInterfaceType = null; - this._cachedIArgumentsInterfaceType = null; - this._cachedRegExpInterfaceType = null; - this.cachedFunctionArgumentsSymbol = null; - - this.identicalCache = {}; - this.subtypeCache = {}; - this.assignableCache = {}; - }; - - PullTypeResolver.prototype.cachedArrayInterfaceType = function () { - if (!this._cachedArrayInterfaceType) { - this._cachedArrayInterfaceType = this.getSymbolFromDeclPath("Array", [], 16 /* Interface */); - } - - if (!this._cachedArrayInterfaceType) { - this._cachedArrayInterfaceType = this.semanticInfoChain.anyTypeSymbol; - } - - if (!this._cachedArrayInterfaceType.isResolved()) { - this.resolveDeclaredSymbol(this._cachedArrayInterfaceType, null, new TypeScript.PullTypeResolutionContext()); - } - - return this._cachedArrayInterfaceType; - }; - - PullTypeResolver.prototype.getCachedArrayType = function () { - return this.cachedArrayInterfaceType(); - }; - - PullTypeResolver.prototype.cachedNumberInterfaceType = function () { - if (!this._cachedNumberInterfaceType) { - this._cachedNumberInterfaceType = this.getSymbolFromDeclPath("Number", [], 16 /* Interface */); - } - - if (this._cachedNumberInterfaceType && !this._cachedNumberInterfaceType.isResolved()) { - this.resolveDeclaredSymbol(this._cachedNumberInterfaceType, null, new TypeScript.PullTypeResolutionContext()); - } - - return this._cachedNumberInterfaceType; - }; - - PullTypeResolver.prototype.cachedStringInterfaceType = function () { - if (!this._cachedStringInterfaceType) { - this._cachedStringInterfaceType = this.getSymbolFromDeclPath("String", [], 16 /* Interface */); - } - - if (this._cachedStringInterfaceType && !this._cachedStringInterfaceType.isResolved()) { - this.resolveDeclaredSymbol(this._cachedStringInterfaceType, null, new TypeScript.PullTypeResolutionContext()); - } - - return this._cachedStringInterfaceType; - }; - - PullTypeResolver.prototype.cachedBooleanInterfaceType = function () { - if (!this._cachedBooleanInterfaceType) { - this._cachedBooleanInterfaceType = this.getSymbolFromDeclPath("Boolean", [], 16 /* Interface */); - } - - if (this._cachedBooleanInterfaceType && !this._cachedBooleanInterfaceType.isResolved()) { - this.resolveDeclaredSymbol(this._cachedBooleanInterfaceType, null, new TypeScript.PullTypeResolutionContext()); - } - - return this._cachedBooleanInterfaceType; - }; - - PullTypeResolver.prototype.cachedObjectInterfaceType = function () { - if (!this._cachedObjectInterfaceType) { - this._cachedObjectInterfaceType = this.getSymbolFromDeclPath("Object", [], 16 /* Interface */); - } - - if (!this._cachedObjectInterfaceType) { - this._cachedObjectInterfaceType = this.semanticInfoChain.anyTypeSymbol; - } - - if (!this._cachedObjectInterfaceType.isResolved()) { - this.resolveDeclaredSymbol(this._cachedObjectInterfaceType, null, new TypeScript.PullTypeResolutionContext()); - } - - return this._cachedObjectInterfaceType; - }; - - PullTypeResolver.prototype.cachedFunctionInterfaceType = function () { - if (!this._cachedFunctionInterfaceType) { - this._cachedFunctionInterfaceType = this.getSymbolFromDeclPath("Function", [], 16 /* Interface */); - } - - if (this._cachedFunctionInterfaceType && !this._cachedFunctionInterfaceType.isResolved()) { - this.resolveDeclaredSymbol(this._cachedFunctionInterfaceType, null, new TypeScript.PullTypeResolutionContext()); - } - - return this._cachedFunctionInterfaceType; - }; - - PullTypeResolver.prototype.cachedIArgumentsInterfaceType = function () { - if (!this._cachedIArgumentsInterfaceType) { - this._cachedIArgumentsInterfaceType = this.getSymbolFromDeclPath("IArguments", [], 16 /* Interface */); - } - - if (this._cachedIArgumentsInterfaceType && !this._cachedIArgumentsInterfaceType.isResolved()) { - this.resolveDeclaredSymbol(this._cachedIArgumentsInterfaceType, null, new TypeScript.PullTypeResolutionContext()); - } - - return this._cachedIArgumentsInterfaceType; - }; - - PullTypeResolver.prototype.cachedRegExpInterfaceType = function () { - if (!this._cachedRegExpInterfaceType) { - this._cachedRegExpInterfaceType = this.getSymbolFromDeclPath("RegExp", [], 16 /* Interface */); - } - - if (!this._cachedRegExpInterfaceType.isResolved()) { - this.resolveDeclaredSymbol(this._cachedRegExpInterfaceType, null, new TypeScript.PullTypeResolutionContext()); - } - - return this._cachedRegExpInterfaceType; - }; - - PullTypeResolver.prototype.getUnitPath = function () { - return this.unitPath; - }; - - PullTypeResolver.prototype.setUnitPath = function (unitPath) { - this.unitPath = unitPath; - - this.currentUnit = this.semanticInfoChain.getUnit(unitPath); - }; - - PullTypeResolver.prototype.getDeclForAST = function (ast) { - return this.semanticInfoChain.getDeclForAST(ast, this.unitPath); - }; - - PullTypeResolver.prototype.getSymbolAndDiagnosticsForAST = function (ast) { - return this.semanticInfoChain.getSymbolAndDiagnosticsForAST(ast, this.unitPath); - }; - - PullTypeResolver.prototype.setSymbolAndDiagnosticsForAST = function (ast, symbolAndDiagnostics, context) { - if (context && (context.inProvisionalResolution() || context.inSpecialization)) { - return; - } - - this.semanticInfoChain.setSymbolAndDiagnosticsForAST(ast, symbolAndDiagnostics, this.unitPath); - }; - - PullTypeResolver.prototype.getASTForSymbol = function (symbol) { - return this.semanticInfoChain.getASTForSymbol(symbol, this.unitPath); - }; - - PullTypeResolver.prototype.getASTForDecl = function (decl) { - return this.semanticInfoChain.getASTForDecl(decl); - }; - - PullTypeResolver.prototype.getNewErrorTypeSymbol = function (diagnostic, data) { - return new TypeScript.PullErrorTypeSymbol(diagnostic, this.semanticInfoChain.anyTypeSymbol, data); - }; - - PullTypeResolver.prototype.getEnclosingDecl = function (decl) { - var declPath = TypeScript.getPathToDecl(decl); - - if (!declPath.length) { - return null; - } else if (declPath.length > 1 && declPath[declPath.length - 1] === decl) { - return declPath[declPath.length - 2]; - } else { - return declPath[declPath.length - 1]; - } - }; - - PullTypeResolver.prototype.getExportedMemberSymbol = function (symbol, parent) { - if (!(symbol.getKind() & (65536 /* Method */ | 4096 /* Property */))) { - var containerType = !parent.isContainer() ? parent.getAssociatedContainerType() : parent; - - if (containerType && containerType.isContainer() && !TypeScript.PullHelpers.symbolIsEnum(parent)) { - if (symbol.hasFlag(1 /* Exported */)) { - return symbol; - } - - return null; - } - } - - return symbol; - }; - - PullTypeResolver.prototype.getMemberSymbol = function (symbolName, declSearchKind, parent, searchContainedMembers) { - if (typeof searchContainedMembers === "undefined") { searchContainedMembers = false; } - var member = null; - - if (declSearchKind & TypeScript.PullElementKind.SomeValue) { - member = parent.findMember(symbolName); - } else { - member = parent.findNestedType(symbolName); - } - - if (member) { - return this.getExportedMemberSymbol(member, parent); - } - - var containerType = parent.getAssociatedContainerType(); - - if (containerType) { - if (containerType.isClass()) { - return null; - } - - parent = containerType; - } - - if (declSearchKind & TypeScript.PullElementKind.SomeValue) { - member = parent.findMember(symbolName); - } else { - member = parent.findNestedType(symbolName); - } - - if (member) { - return this.getExportedMemberSymbol(member, parent); - } - - var typeDeclarations = parent.getDeclarations(); - var childDecls = null; - - for (var j = 0; j < typeDeclarations.length; j++) { - childDecls = typeDeclarations[j].searchChildDecls(symbolName, declSearchKind); - - if (childDecls.length) { - return this.getExportedMemberSymbol(childDecls[0].getSymbol(), parent); - } - } - }; - - PullTypeResolver.prototype.getSymbolFromDeclPath = function (symbolName, declPath, declSearchKind) { - var symbol = null; - - var decl = null; - var childDecls; - var declSymbol = null; - var declMembers; - var pathDeclKind; - var valDecl = null; - var kind; - var instanceSymbol = null; - var instanceType = null; - var childSymbol = null; - - for (var i = declPath.length - 1; i >= 0; i--) { - decl = declPath[i]; - pathDeclKind = decl.getKind(); - - if (decl.getFlags() & 2097152 /* DeclaredInAWithBlock */) { - return this.semanticInfoChain.anyTypeSymbol; - } - - if (pathDeclKind & (4 /* Container */ | 32 /* DynamicModule */)) { - childDecls = decl.searchChildDecls(symbolName, declSearchKind); - - if (childDecls.length) { - return childDecls[0].getSymbol(); - } - - if (declSearchKind & TypeScript.PullElementKind.SomeValue) { - childDecls = decl.searchChildDecls(symbolName, declSearchKind); - - if (childDecls.length) { - valDecl = childDecls[0]; - - if (valDecl) { - return valDecl.getSymbol(); - } - } - - instanceSymbol = (decl.getSymbol()).getInstanceSymbol(); - - if (instanceSymbol) { - instanceType = instanceSymbol.getType(); - - childSymbol = this.getMemberSymbol(symbolName, declSearchKind, instanceType); - - if (childSymbol && (childSymbol.getKind() & declSearchKind)) { - return childSymbol; - } - } - - childDecls = decl.searchChildDecls(symbolName, 256 /* TypeAlias */); - - if (childDecls.length) { - var sym = childDecls[0].getSymbol(); - - if (sym.isAlias()) { - return sym; - } - } - - valDecl = decl.getValueDecl(); - - if (valDecl) { - decl = valDecl; - } - } - - declSymbol = decl.getSymbol().getType(); - - var childSymbol = this.getMemberSymbol(symbolName, declSearchKind, declSymbol); - - if (childSymbol) { - return childSymbol; - } - } else if ((declSearchKind & (TypeScript.PullElementKind.SomeType | TypeScript.PullElementKind.SomeContainer)) || !(pathDeclKind & 8 /* Class */)) { - var candidateSymbol = null; - - if (pathDeclKind === 131072 /* FunctionExpression */ && symbolName === (decl).getFunctionExpressionName()) { - candidateSymbol = decl.getSymbol(); - } - - childDecls = decl.searchChildDecls(symbolName, declSearchKind); - - if (childDecls.length) { - if (decl.getKind() & TypeScript.PullElementKind.SomeFunction) { - decl.ensureSymbolIsBound(); - } - return childDecls[0].getSymbol(); - } - - if (candidateSymbol) { - return candidateSymbol; - } - - if (declSearchKind & TypeScript.PullElementKind.SomeValue) { - childDecls = decl.searchChildDecls(symbolName, 256 /* TypeAlias */); - - if (childDecls.length) { - var sym = childDecls[0].getSymbol(); - - if (sym.isAlias()) { - return sym; - } - } - } - } - } - - symbol = this.semanticInfoChain.findSymbol([symbolName], declSearchKind); - - return symbol; - }; - - PullTypeResolver.prototype.getVisibleDeclsFromDeclPath = function (declPath, declSearchKind) { - var result = []; - var decl = null; - var childDecls; - var pathDeclKind; - var parameters; - - for (var i = declPath.length - 1; i >= 0; i--) { - decl = declPath[i]; - pathDeclKind = decl.getKind(); - var declSymbol = decl.getSymbol(); - var declKind = decl.getKind(); - - if (declKind !== 8 /* Class */ && declKind !== 16 /* Interface */) { - this.addFilteredDecls(decl.getChildDecls(), declSearchKind, result); - } - - switch (declKind) { - case 4 /* Container */: - case 32 /* DynamicModule */: - if (declSymbol) { - var otherDecls = declSymbol.getDeclarations(); - for (var j = 0, m = otherDecls.length; j < m; j++) { - var otherDecl = otherDecls[j]; - if (otherDecl === decl) { - continue; - } - - var otherDeclChildren = otherDecl.getChildDecls(); - for (var k = 0, s = otherDeclChildren.length; k < s; k++) { - var otherDeclChild = otherDeclChildren[k]; - if ((otherDeclChild.getFlags() & 1 /* Exported */) && (otherDeclChild.getKind() & declSearchKind)) { - result.push(otherDeclChild); - } - } - } - } - - break; - - case 8 /* Class */: - case 16 /* Interface */: - if (declSymbol && declSymbol.isGeneric()) { - parameters = declSymbol.getTypeParameters(); - for (var k = 0; k < parameters.length; k++) { - result.push(parameters[k].getDeclarations()[0]); - } - } - - break; - - case 131072 /* FunctionExpression */: - var functionExpressionName = (decl).getFunctionExpressionName(); - if (declSymbol && functionExpressionName) { - result.push(declSymbol.getDeclarations()[0]); - } - - case 16384 /* Function */: - case 32768 /* ConstructorMethod */: - case 65536 /* Method */: - if (declSymbol) { - var functionType = declSymbol.getType(); - if (functionType.getHasGenericSignature()) { - var signatures = (pathDeclKind === 32768 /* ConstructorMethod */) ? functionType.getConstructSignatures() : functionType.getCallSignatures(); - if (signatures && signatures.length) { - for (var j = 0; j < signatures.length; j++) { - var signature = signatures[j]; - if (signature.isGeneric()) { - parameters = signature.getTypeParameters(); - for (var k = 0; k < parameters.length; k++) { - result.push(parameters[k].getDeclarations()[0]); - } - } - } - } - } - } - - break; - } - } - - var units = this.semanticInfoChain.units; - for (var i = 0, n = units.length; i < n; i++) { - var unit = units[i]; - if (unit === this.currentUnit && declPath.length != 0) { - continue; - } - var topLevelDecls = unit.getTopLevelDecls(); - if (topLevelDecls.length) { - for (var j = 0, m = topLevelDecls.length; j < m; j++) { - var topLevelDecl = topLevelDecls[j]; - if (topLevelDecl.getKind() === 1 /* Script */ || topLevelDecl.getKind() === 0 /* Global */) { - this.addFilteredDecls(topLevelDecl.getChildDecls(), declSearchKind, result); - } - } - } - } - - return result; - }; - - PullTypeResolver.prototype.addFilteredDecls = function (decls, declSearchKind, result) { - if (decls.length) { - for (var i = 0, n = decls.length; i < n; i++) { - var decl = decls[i]; - if (decl.getKind() & declSearchKind) { - result.push(decl); - } - } - } - }; - - PullTypeResolver.prototype.getVisibleDecls = function (enclosingDecl, context) { - var declPath = enclosingDecl !== null ? TypeScript.getPathToDecl(enclosingDecl) : []; - - if (enclosingDecl && !declPath.length) { - declPath = [enclosingDecl]; - } - - var declSearchKind = TypeScript.PullElementKind.SomeType | TypeScript.PullElementKind.SomeContainer | TypeScript.PullElementKind.SomeValue; - - return this.getVisibleDeclsFromDeclPath(declPath, declSearchKind); - }; - - PullTypeResolver.prototype.getVisibleContextSymbols = function (enclosingDecl, context) { - var contextualTypeSymbol = context.getContextualType(); - if (!contextualTypeSymbol || this.isAnyOrEquivalent(contextualTypeSymbol)) { - return null; - } - - var declSearchKind = TypeScript.PullElementKind.SomeType | TypeScript.PullElementKind.SomeContainer | TypeScript.PullElementKind.SomeValue; - var members = contextualTypeSymbol.getAllMembers(declSearchKind, false); - - for (var i = 0; i < members.length; i++) { - members[i].setUnresolved(); - } - - return members; - }; - - PullTypeResolver.prototype.getVisibleMembersFromExpression = function (expression, enclosingDecl, context) { - var prevCanUseTypeSymbol = context.canUseTypeSymbol; - context.canUseTypeSymbol = true; - var lhs = this.resolveAST(expression, false, enclosingDecl, context).symbol; - context.canUseTypeSymbol = prevCanUseTypeSymbol; - var lhsType = lhs.getType(); - - if (!lhsType) { - return null; - } - - if (this.isAnyOrEquivalent(lhsType)) { - return null; - } - - if (!lhsType.isResolved()) { - this.resolveDeclaredSymbol(lhsType, enclosingDecl, context); - } - - var includePrivate = false; - var containerSymbol = lhsType; - if (containerSymbol.getKind() === 33554432 /* ConstructorType */) { - containerSymbol = containerSymbol.getConstructSignatures()[0].getReturnType(); - } - - if (containerSymbol && containerSymbol.isClass()) { - var declPath = TypeScript.getPathToDecl(enclosingDecl); - if (declPath && declPath.length) { - var declarations = containerSymbol.getDeclarations(); - for (var i = 0, n = declarations.length; i < n; i++) { - var declaration = declarations[i]; - if (declPath.indexOf(declaration) >= 0) { - includePrivate = true; - break; - } - } - } - } - - var declSearchKind = TypeScript.PullElementKind.SomeType | TypeScript.PullElementKind.SomeContainer | TypeScript.PullElementKind.SomeValue; - - var members = []; - - if (lhsType.isContainer()) { - if ((lhsType).getExportAssignedContainerSymbol()) { - lhsType = (lhsType).getExportAssignedContainerSymbol(); - } - } - - if (lhsType.isTypeParameter()) { - var constraint = (lhsType).getConstraint(); - - if (constraint) { - lhsType = constraint; - members = lhsType.getAllMembers(declSearchKind, false); - } - } else { - if (lhs.getKind() == 67108864 /* EnumMember */) { - lhsType = this.semanticInfoChain.numberTypeSymbol; - } - - if (lhsType === this.semanticInfoChain.numberTypeSymbol && this.cachedNumberInterfaceType()) { - lhsType = this.cachedNumberInterfaceType(); - } else if (lhsType === this.semanticInfoChain.stringTypeSymbol && this.cachedStringInterfaceType()) { - lhsType = this.cachedStringInterfaceType(); - } else if (lhsType === this.semanticInfoChain.booleanTypeSymbol && this.cachedBooleanInterfaceType()) { - lhsType = this.cachedBooleanInterfaceType(); - } - - if (!lhsType.isResolved()) { - var potentiallySpecializedType = this.resolveDeclaredSymbol(lhsType, enclosingDecl, context); - - if (potentiallySpecializedType != lhsType) { - if (!lhs.isType()) { - context.setTypeInContext(lhs, potentiallySpecializedType); - } - - lhsType = potentiallySpecializedType; - } - } - - members = lhsType.getAllMembers(declSearchKind, includePrivate); - - if (lhsType.isContainer()) { - var associatedInstance = (lhsType).getInstanceSymbol(); - if (associatedInstance) { - var instanceType = associatedInstance.getType(); - if (!instanceType.isResolved()) { - this.resolveDeclaredSymbol(instanceType, enclosingDecl, context); - } - var instanceMembers = instanceType.getAllMembers(declSearchKind, includePrivate); - members = members.concat(instanceMembers); - } - } else if (lhsType.isConstructor()) { - var prototypeStr = "prototype"; - var prototypeSymbol = new TypeScript.PullSymbol(prototypeStr, 4096 /* Property */); - var parentDecl = lhsType.getDeclarations()[0]; - var prototypeDecl = new TypeScript.PullDecl(prototypeStr, prototypeStr, parentDecl.getKind(), parentDecl.getFlags(), parentDecl.getSpan(), parentDecl.getScriptName()); - this.currentUnit.addSynthesizedDecl(prototypeDecl); - prototypeDecl.setParentDecl(parentDecl); - prototypeSymbol.addDeclaration(prototypeDecl); - - members.push(prototypeSymbol); - } else { - var associatedContainerSymbol = lhsType.getAssociatedContainerType(); - if (associatedContainerSymbol) { - var containerType = associatedContainerSymbol.getType(); - if (!containerType.isResolved()) { - this.resolveDeclaredSymbol(containerType, enclosingDecl, context); - } - var containerMembers = containerType.getAllMembers(declSearchKind, includePrivate); - members = members.concat(containerMembers); - } - } - } - - if (lhsType.getCallSignatures().length && this.cachedFunctionInterfaceType()) { - members = members.concat(this.cachedFunctionInterfaceType().getAllMembers(declSearchKind, false)); - } - - for (var i = 0; i < members.length; i++) { - if (!members[i].isResolved()) { - this.resolveDeclaredSymbol(members[i], enclosingDecl, context); - } - members[i].setUnresolved(); - } - - return members; - }; - - PullTypeResolver.prototype.isAnyOrEquivalent = function (type) { - return (type === this.semanticInfoChain.anyTypeSymbol) || type.isError(); - }; - - PullTypeResolver.prototype.isNumberOrEquivalent = function (type) { - return (type === this.semanticInfoChain.numberTypeSymbol) || (this.cachedNumberInterfaceType() && type === this.cachedNumberInterfaceType()); - }; - - PullTypeResolver.prototype.isTypeArgumentOrWrapper = function (type) { - if (!type) { - return false; - } - - if (!type.isGeneric()) { - return false; - } - - if (type.isTypeParameter()) { - return true; - } - - if (type.isArray()) { - return this.isTypeArgumentOrWrapper((type).getElementType()); - } - - var typeArguments = type.getTypeArguments(); - - if (typeArguments) { - for (var i = 0; i < typeArguments.length; i++) { - if (this.isTypeArgumentOrWrapper(typeArguments[i])) { - return true; - } - } - } else { - return true; - } - - return false; - }; - - PullTypeResolver.prototype.isArrayOrEquivalent = function (type) { - return (type.isArray() && (type).getElementType()) || type == this.cachedArrayInterfaceType(); - }; - - PullTypeResolver.prototype.findTypeSymbolForDynamicModule = function (idText, currentFileName, search) { - var originalIdText = idText; - var symbol = search(idText); - - if (symbol === null) { - if (!symbol) { - idText = TypeScript.swapQuotes(originalIdText); - symbol = search(idText); - } - - if (!symbol) { - idText = TypeScript.stripQuotes(originalIdText) + ".ts"; - symbol = search(idText); - } - - if (!symbol) { - idText = TypeScript.stripQuotes(originalIdText) + ".d.ts"; - symbol = search(idText); - } - - if (!symbol && !TypeScript.isRelative(originalIdText)) { - idText = originalIdText; - - var strippedIdText = TypeScript.stripQuotes(idText); - - var path = TypeScript.getRootFilePath(TypeScript.switchToForwardSlashes(currentFileName)); - - while (symbol === null && path != "") { - idText = TypeScript.normalizePath(path + strippedIdText + ".ts"); - symbol = search(idText); - - if (symbol === null) { - idText = TypeScript.changePathToDTS(idText); - symbol = search(idText); - } - - if (symbol === null) { - if (path === '/') { - path = ''; - } else { - path = TypeScript.normalizePath(path + ".."); - path = path && path != '/' ? path + '/' : path; - } - } - } - } - } - - return symbol; - }; - - PullTypeResolver.prototype.resolveDeclaredSymbol = function (symbol, enclosingDecl, context) { - var savedResolvingTypeReference = context.resolvingTypeReference; - context.resolvingTypeReference = false; - - var result = this.resolveDeclaredSymbolWorker(symbol, enclosingDecl, context); - context.resolvingTypeReference = savedResolvingTypeReference; - - return result; - }; - - PullTypeResolver.prototype.resolveDeclaredSymbolWorker = function (symbol, enclosingDecl, context) { - if (!symbol || symbol.isResolved()) { - return symbol; - } - - if (symbol.isResolving()) { - if (!symbol.currentlyBeingSpecialized()) { - if (!symbol.isType()) { - symbol.setType(this.semanticInfoChain.anyTypeSymbol); - } - - return symbol; - } - } - - var thisUnit = this.unitPath; - - var decls = symbol.getDeclarations(); - - var ast = null; - - for (var i = 0; i < decls.length; i++) { - var decl = decls[i]; - - ast = this.semanticInfoChain.getASTForDecl(decl); - - if (!ast || ast.nodeType === 80 /* Member */) { - this.setUnitPath(thisUnit); - return symbol; - } - - this.setUnitPath(decl.getScriptName()); - this.resolveAST(ast, false, enclosingDecl, context); - } - - var typeArgs = symbol.isType() ? (symbol).getTypeArguments() : null; - - if (typeArgs && typeArgs.length) { - var typeParameters = (symbol).getTypeParameters(); - var typeCache = {}; - - for (var i = 0; i < typeParameters.length; i++) { - typeCache[typeParameters[i].getSymbolID().toString()] = typeArgs[i]; - } - - context.pushTypeSpecializationCache(typeCache); - var rootType = TypeScript.getRootType(symbol.getType()); - - var specializedSymbol = TypeScript.specializeType(rootType, typeArgs, this, enclosingDecl, context, ast); - - context.popTypeSpecializationCache(); - - symbol = specializedSymbol; - } - - this.setUnitPath(thisUnit); - - return symbol; - }; - - PullTypeResolver.prototype.resolveModuleDeclaration = function (ast, context) { - var containerDecl = this.getDeclForAST(ast); - var containerSymbol = containerDecl.getSymbol(); - - if (containerSymbol.isResolved()) { - return containerSymbol; - } - - containerSymbol.setResolved(); - - var containerDecls = containerSymbol.getDeclarations(); - - for (var i = 0; i < containerDecls.length; i++) { - var childDecls = containerDecls[i].getChildDecls(); - - for (var j = 0; j < childDecls.length; j++) { - childDecls[j].ensureSymbolIsBound(); - } - } - - if (containerDecl.getKind() != 64 /* Enum */) { - var instanceSymbol = containerSymbol.getInstanceSymbol(); - - if (instanceSymbol) { - this.resolveDeclaredSymbol(instanceSymbol, containerDecl.getParentDecl(), context); - } - - var members = ast.members.members; - - for (var i = 0; i < members.length; i++) { - if (members[i].nodeType == 87 /* ExportAssignment */) { - this.resolveExportAssignmentStatement(members[i], containerDecl, context); - break; - } - } - } - - return containerSymbol; - }; - - PullTypeResolver.prototype.isTypeRefWithoutTypeArgs = function (typeRef) { - if (typeRef.nodeType != 11 /* TypeRef */) { - return false; - } - - if (typeRef.term.nodeType == 20 /* Name */) { - return true; - } else if (typeRef.term.nodeType == 32 /* MemberAccessExpression */) { - var binex = typeRef.term; - - if (binex.operand2.nodeType == 20 /* Name */) { - return true; - } - } - - return false; - }; - - PullTypeResolver.prototype.resolveReferenceTypeDeclaration = function (typeDeclAST, context) { - var typeDecl = this.getDeclForAST(typeDeclAST); - var enclosingDecl = this.getEnclosingDecl(typeDecl); - var typeDeclSymbol = typeDecl.getSymbol(); - var typeDeclIsClass = typeDeclAST.nodeType === 13 /* ClassDeclaration */; - var hasVisited = this.getSymbolAndDiagnosticsForAST(typeDeclAST) != null; - var extendedTypes = []; - var implementedTypes = []; - - if ((typeDeclSymbol.isResolved() && hasVisited) || (typeDeclSymbol.isResolving() && !context.isInBaseTypeResolution())) { - return typeDeclSymbol; - } - - var wasResolving = typeDeclSymbol.isResolving(); - typeDeclSymbol.startResolving(); - - if (!typeDeclSymbol.isResolved()) { - var typeDeclTypeParameters = typeDeclSymbol.getTypeParameters(); - for (var i = 0; i < typeDeclTypeParameters.length; i++) { - this.resolveDeclaredSymbol(typeDeclTypeParameters[i], typeDecl, context); - } - } - - var typeRefDecls = typeDeclSymbol.getDeclarations(); - - for (var i = 0; i < typeRefDecls.length; i++) { - var childDecls = typeRefDecls[i].getChildDecls(); - - for (var j = 0; j < childDecls.length; j++) { - childDecls[j].ensureSymbolIsBound(); - } - } - - var wasInBaseTypeResolution = context.startBaseTypeResolution(); - - if (!typeDeclIsClass && !hasVisited) { - typeDeclSymbol.resetKnownBaseTypeCount(); - } - - if (typeDeclAST.extendsList) { - var savedIsResolvingClassExtendedType = context.isResolvingClassExtendedType; - if (typeDeclIsClass) { - context.isResolvingClassExtendedType = true; - } - - for (var i = typeDeclSymbol.getKnownBaseTypeCount(); i < typeDeclAST.extendsList.members.length; i = typeDeclSymbol.getKnownBaseTypeCount()) { - typeDeclSymbol.incrementKnownBaseCount(); - var parentType = this.resolveTypeReference(new TypeScript.TypeReference(typeDeclAST.extendsList.members[i], 0), typeDecl, context).symbol; - - if (typeDeclSymbol.isValidBaseKind(parentType, true)) { - var resolvedParentType = parentType; - extendedTypes[extendedTypes.length] = parentType; - if (parentType.isGeneric() && parentType.isResolved() && !parentType.getIsSpecialized()) { - parentType = this.specializeTypeToAny(parentType, enclosingDecl, context); - typeDecl.addDiagnostic(new TypeScript.Diagnostic(typeDecl.getScriptName(), typeDeclAST.minChar, typeDeclAST.getLength(), 239 /* Generic_type_references_must_include_all_type_arguments */)); - } - if (!typeDeclSymbol.hasBase(parentType)) { - this.setSymbolAndDiagnosticsForAST(typeDeclAST.extendsList.members[i], SymbolAndDiagnostics.fromSymbol(resolvedParentType), context); - typeDeclSymbol.addExtendedType(parentType); - - var specializations = typeDeclSymbol.getKnownSpecializations(); - - for (var j = 0; j < specializations.length; j++) { - specializations[j].addExtendedType(parentType); - } - } - } - } - - context.isResolvingClassExtendedType = savedIsResolvingClassExtendedType; - } - - if (!typeDeclSymbol.isResolved() && !wasResolving) { - var baseTypeSymbols = typeDeclSymbol.getExtendedTypes(); - for (var i = 0; i < baseTypeSymbols.length; i++) { - var baseType = baseTypeSymbols[i]; - - for (var j = 0; j < extendedTypes.length; j++) { - if (baseType == extendedTypes[j]) { - break; - } - } - - if (j == extendedTypes.length) { - typeDeclSymbol.removeExtendedType(baseType); - } - } - } - - if (typeDeclAST.implementsList && typeDeclIsClass) { - var extendsCount = typeDeclAST.extendsList ? typeDeclAST.extendsList.members.length : 0; - for (var i = typeDeclSymbol.getKnownBaseTypeCount(); ((i - extendsCount) >= 0) && ((i - extendsCount) < typeDeclAST.implementsList.members.length); i = typeDeclSymbol.getKnownBaseTypeCount()) { - typeDeclSymbol.incrementKnownBaseCount(); - var implementedType = this.resolveTypeReference(new TypeScript.TypeReference(typeDeclAST.implementsList.members[i - extendsCount], 0), typeDecl, context).symbol; - - if (typeDeclSymbol.isValidBaseKind(implementedType, false)) { - var resolvedImplementedType = implementedType; - implementedTypes[implementedTypes.length] = implementedType; - if (implementedType.isGeneric() && implementedType.isResolved() && !implementedType.getIsSpecialized()) { - implementedType = this.specializeTypeToAny(implementedType, enclosingDecl, context); - typeDecl.addDiagnostic(new TypeScript.Diagnostic(typeDecl.getScriptName(), typeDeclAST.minChar, typeDeclAST.getLength(), 239 /* Generic_type_references_must_include_all_type_arguments */)); - this.setSymbolAndDiagnosticsForAST(typeDeclAST.implementsList.members[i - extendsCount], SymbolAndDiagnostics.fromSymbol(implementedType), context); - typeDeclSymbol.addImplementedType(implementedType); - } else if (!typeDeclSymbol.hasBase(implementedType)) { - this.setSymbolAndDiagnosticsForAST(typeDeclAST.implementsList.members[i - extendsCount], SymbolAndDiagnostics.fromSymbol(resolvedImplementedType), context); - typeDeclSymbol.addImplementedType(implementedType); - } - } - } - } - - if (!typeDeclSymbol.isResolved() && !wasResolving) { - var baseTypeSymbols = typeDeclSymbol.getImplementedTypes(); - for (var i = 0; i < baseTypeSymbols.length; i++) { - var baseType = baseTypeSymbols[i]; - - for (var j = 0; j < implementedTypes.length; j++) { - if (baseType == implementedTypes[j]) { - break; - } - } - - if (j == implementedTypes.length) { - typeDeclSymbol.removeImplementedType(baseType); - } - } - } - - context.doneBaseTypeResolution(wasInBaseTypeResolution); - if (wasInBaseTypeResolution && (typeDeclAST.implementsList || typeDeclAST.extendsList)) { - return typeDeclSymbol; - } - - if (!typeDeclSymbol.isResolved()) { - var typeDeclMembers = typeDeclSymbol.getMembers(); - for (var i = 0; i < typeDeclMembers.length; i++) { - this.resolveDeclaredSymbol(typeDeclMembers[i], typeDecl, context); - } - - if (!typeDeclIsClass) { - var callSignatures = typeDeclSymbol.getCallSignatures(); - for (var i = 0; i < callSignatures.length; i++) { - this.resolveDeclaredSymbol(callSignatures[i], typeDecl, context); - } - - var constructSignatures = typeDeclSymbol.getConstructSignatures(); - for (var i = 0; i < constructSignatures.length; i++) { - this.resolveDeclaredSymbol(constructSignatures[i], typeDecl, context); - } - - var indexSignatures = typeDeclSymbol.getIndexSignatures(); - for (var i = 0; i < indexSignatures.length; i++) { - this.resolveDeclaredSymbol(indexSignatures[i], typeDecl, context); - } - } - } - - this.setSymbolAndDiagnosticsForAST(typeDeclAST.name, SymbolAndDiagnostics.fromSymbol(typeDeclSymbol), context); - this.setSymbolAndDiagnosticsForAST(typeDeclAST, SymbolAndDiagnostics.fromSymbol(typeDeclSymbol), context); - - typeDeclSymbol.setResolved(); - - return typeDeclSymbol; - }; - - PullTypeResolver.prototype.resolveClassDeclaration = function (classDeclAST, context) { - var classDecl = this.getDeclForAST(classDeclAST); - var classDeclSymbol = classDecl.getSymbol(); - if (classDeclSymbol.isResolved()) { - return classDeclSymbol; - } - - this.resolveReferenceTypeDeclaration(classDeclAST, context); - - var constructorMethod = classDeclSymbol.getConstructorMethod(); - var extendedTypes = classDeclSymbol.getExtendedTypes(); - var parentType = extendedTypes.length ? extendedTypes[0] : null; - - if (constructorMethod) { - var constructorTypeSymbol = constructorMethod.getType(); - - var constructSignatures = constructorTypeSymbol.getConstructSignatures(); - - if (!constructSignatures.length) { - var constructorSignature; - - if (parentType) { - var parentClass = parentType; - var parentConstructor = parentClass.getConstructorMethod(); - var parentConstructorType = parentConstructor.getType(); - var parentConstructSignatures = parentConstructorType.getConstructSignatures(); - - var parentConstructSignature; - var parentParameters; - for (var i = 0; i < parentConstructSignatures.length; i++) { - parentConstructSignature = parentConstructSignatures[i]; - parentParameters = parentConstructSignature.getParameters(); - - constructorSignature = parentConstructSignature.isDefinition() ? new TypeScript.PullDefinitionSignatureSymbol(2097152 /* ConstructSignature */) : new TypeScript.PullSignatureSymbol(2097152 /* ConstructSignature */); - constructorSignature.setReturnType(classDeclSymbol); - - for (var j = 0; j < parentParameters.length; j++) { - constructorSignature.addParameter(parentParameters[j], parentParameters[j].getIsOptional()); - } - - var typeParameters = constructorTypeSymbol.getTypeParameters(); - - for (var j = 0; j < typeParameters.length; j++) { - constructorSignature.addTypeParameter(typeParameters[j]); - } - - constructorTypeSymbol.addConstructSignature(constructorSignature); - constructorSignature.addDeclaration(classDecl); - } - } else { - constructorSignature = new TypeScript.PullSignatureSymbol(2097152 /* ConstructSignature */); - constructorSignature.setReturnType(classDeclSymbol); - constructorTypeSymbol.addConstructSignature(constructorSignature); - constructorSignature.addDeclaration(classDecl); - - var typeParameters = constructorTypeSymbol.getTypeParameters(); - - for (var i = 0; i < typeParameters.length; i++) { - constructorSignature.addTypeParameter(typeParameters[i]); - } - } - } - - if (!classDeclSymbol.isResolved()) { - return classDeclSymbol; - } - - var constructorMembers = constructorTypeSymbol.getMembers(); - - this.resolveDeclaredSymbol(constructorMethod, classDecl, context); - - for (var i = 0; i < constructorMembers.length; i++) { - this.resolveDeclaredSymbol(constructorMembers[i], classDecl, context); - } - - if (parentType) { - var parentConstructorSymbol = (parentType).getConstructorMethod(); - var parentConstructorTypeSymbol = parentConstructorSymbol.getType(); - - if (!constructorTypeSymbol.hasBase(parentConstructorTypeSymbol)) { - constructorTypeSymbol.addExtendedType(parentConstructorTypeSymbol); - } - } - } - - return classDeclSymbol; - }; - - PullTypeResolver.prototype.resolveInterfaceDeclaration = function (interfaceDeclAST, context) { - var interfaceDecl = this.getDeclForAST(interfaceDeclAST); - var interfaceDeclSymbol = interfaceDecl.getSymbol(); - - this.resolveReferenceTypeDeclaration(interfaceDeclAST, context); - return interfaceDeclSymbol; - }; - - PullTypeResolver.prototype.resolveImportDeclaration = function (importStatementAST, context) { - var _this = this; - var importDecl = this.getDeclForAST(importStatementAST); - var enclosingDecl = this.getEnclosingDecl(importDecl); - var importDeclSymbol = importDecl.getSymbol(); - - var aliasName = importStatementAST.id.text; - var aliasedType = null; - - if (importDeclSymbol.isResolved()) { - return importDeclSymbol; - } - - importDeclSymbol.startResolving(); - - if (importStatementAST.alias.nodeType === 11 /* TypeRef */) { - aliasedType = this.resolveTypeReference(importStatementAST.alias, enclosingDecl, context).symbol; - } else if (importStatementAST.alias.nodeType === 20 /* Name */) { - var text = (importStatementAST.alias).actualText; - - if (!TypeScript.isQuoted(text)) { - aliasedType = this.resolveTypeReference(new TypeScript.TypeReference(importStatementAST.alias, 0), enclosingDecl, context).symbol; - } else { - var modPath = (importStatementAST.alias).actualText; - var declPath = TypeScript.getPathToDecl(enclosingDecl); - - importStatementAST.isDynamicImport = true; - - aliasedType = this.findTypeSymbolForDynamicModule(modPath, importDecl.getScriptName(), function (s) { - return _this.getSymbolFromDeclPath(s, declPath, TypeScript.PullElementKind.SomeContainer); - }); - - if (!aliasedType) { - importDecl.addDiagnostic(new TypeScript.SemanticDiagnostic(this.currentUnit.getPath(), importStatementAST.minChar, importStatementAST.getLength(), 140 /* Unable_to_resolve_external_module__0_ */, [text])); - aliasedType = this.semanticInfoChain.anyTypeSymbol; - } - } - } - - if (aliasedType) { - if (!aliasedType.isContainer()) { - importDecl.addDiagnostic(new TypeScript.Diagnostic(this.currentUnit.getPath(), importStatementAST.minChar, importStatementAST.getLength(), 141 /* Module_cannot_be_aliased_to_a_non_module_type */)); - aliasedType = this.semanticInfoChain.anyTypeSymbol; - } else if ((aliasedType).getExportAssignedValueSymbol()) { - importDeclSymbol.setIsUsedAsValue(); - } - - importDeclSymbol.setAliasedType(aliasedType); - importDeclSymbol.setResolved(); - - this.semanticInfoChain.setSymbolAndDiagnosticsForAST(importStatementAST.alias, SymbolAndDiagnostics.fromSymbol(aliasedType), this.unitPath); - } - - return importDeclSymbol; - }; - - PullTypeResolver.prototype.resolveExportAssignmentStatement = function (exportAssignmentAST, enclosingDecl, context) { - var id = exportAssignmentAST.id.text; - var valueSymbol = null; - var typeSymbol = null; - var containerSymbol = null; - - var parentSymbol = enclosingDecl.getSymbol(); - - if (!parentSymbol.isType() && (parentSymbol).isContainer()) { - enclosingDecl.addDiagnostic(new TypeScript.Diagnostic(enclosingDecl.getScriptName(), exportAssignmentAST.minChar, exportAssignmentAST.getLength(), 230 /* Export_assignments_may_only_be_used_in_External_modules */)); - return SymbolAndDiagnostics.fromSymbol(this.semanticInfoChain.anyTypeSymbol); - } - - var declPath = enclosingDecl !== null ? [enclosingDecl] : []; - - containerSymbol = this.getSymbolFromDeclPath(id, declPath, TypeScript.PullElementKind.SomeContainer); - - var acceptableAlias = true; - - if (containerSymbol) { - acceptableAlias = (containerSymbol.getKind() & TypeScript.PullElementKind.AcceptableAlias) != 0; - } - - if (!acceptableAlias && containerSymbol && containerSymbol.getKind() == 256 /* TypeAlias */) { - if (!containerSymbol.isResolved()) { - this.resolveDeclaredSymbol(containerSymbol, enclosingDecl, context); - } - var aliasedType = (containerSymbol).getType(); - - if (aliasedType.getKind() != 32 /* DynamicModule */) { - acceptableAlias = true; - } else { - var aliasedAssignedValue = (containerSymbol).getExportAssignedValueSymbol(); - var aliasedAssignedType = (containerSymbol).getExportAssignedTypeSymbol(); - var aliasedAssignedContainer = (containerSymbol).getExportAssignedContainerSymbol(); - - if (aliasedAssignedValue || aliasedAssignedType || aliasedAssignedContainer) { - if (aliasedAssignedValue) { - valueSymbol = aliasedAssignedValue; - } - if (aliasedAssignedType) { - typeSymbol = aliasedAssignedType; - } - if (aliasedAssignedContainer) { - containerSymbol = aliasedAssignedContainer; - } - acceptableAlias = true; - } - } - } - - if (!acceptableAlias) { - enclosingDecl.addDiagnostic(new TypeScript.Diagnostic(enclosingDecl.getScriptName(), exportAssignmentAST.minChar, exportAssignmentAST.getLength(), 231 /* Export_assignments_may_only_be_made_with_acceptable_kinds */)); - return SymbolAndDiagnostics.fromSymbol(this.semanticInfoChain.voidTypeSymbol); - } - - if (!valueSymbol) { - valueSymbol = this.getSymbolFromDeclPath(id, declPath, TypeScript.PullElementKind.SomeValue); - } - if (!typeSymbol) { - typeSymbol = this.getSymbolFromDeclPath(id, declPath, TypeScript.PullElementKind.SomeType); - } - - if (!valueSymbol && !typeSymbol && !containerSymbol) { - return SymbolAndDiagnostics.create(this.semanticInfoChain.voidTypeSymbol, [context.postError(enclosingDecl.getScriptName(), exportAssignmentAST.minChar, exportAssignmentAST.getLength(), 164 /* Could_not_find_symbol__0_ */, [id])]); - } - - if (valueSymbol) { - if (!valueSymbol.isResolved()) { - this.resolveDeclaredSymbol(valueSymbol, enclosingDecl, context); - } - (parentSymbol).setExportAssignedValueSymbol(valueSymbol); - } - if (typeSymbol) { - if (!typeSymbol.isResolved()) { - this.resolveDeclaredSymbol(typeSymbol, enclosingDecl, context); - } - - (parentSymbol).setExportAssignedTypeSymbol(typeSymbol); - } - if (containerSymbol) { - if (!containerSymbol.isResolved()) { - this.resolveDeclaredSymbol(containerSymbol, enclosingDecl, context); - } - - (parentSymbol).setExportAssignedContainerSymbol(containerSymbol); - } - - return SymbolAndDiagnostics.fromSymbol(this.semanticInfoChain.voidTypeSymbol); - }; - - PullTypeResolver.prototype.resolveFunctionTypeSignature = function (funcDeclAST, enclosingDecl, context) { - var funcDeclSymbol = null; - - var functionDecl = this.getDeclForAST(funcDeclAST); - - if (!functionDecl || !functionDecl.hasSymbol()) { - var semanticInfo = this.semanticInfoChain.getUnit(this.unitPath); - var declCollectionContext = new TypeScript.DeclCollectionContext(semanticInfo); - - declCollectionContext.scriptName = this.unitPath; - - if (enclosingDecl) { - declCollectionContext.pushParent(enclosingDecl); - } - - TypeScript.getAstWalkerFactory().walk(funcDeclAST, TypeScript.preCollectDecls, TypeScript.postCollectDecls, null, declCollectionContext); - - functionDecl = this.getDeclForAST(funcDeclAST); - this.currentUnit.addSynthesizedDecl(functionDecl); - - var binder = new TypeScript.PullSymbolBinder(this.semanticInfoChain); - binder.setUnit(this.unitPath); - if (functionDecl.getKind() === 33554432 /* ConstructorType */) { - binder.bindConstructorTypeDeclarationToPullSymbol(functionDecl); - } else { - binder.bindFunctionTypeDeclarationToPullSymbol(functionDecl); - } - } - - funcDeclSymbol = functionDecl.getSymbol(); - - var signature = funcDeclSymbol.getKind() === 33554432 /* ConstructorType */ ? funcDeclSymbol.getConstructSignatures()[0] : funcDeclSymbol.getCallSignatures()[0]; - - if (funcDeclAST.returnTypeAnnotation) { - var returnTypeSymbol = this.resolveTypeReference(funcDeclAST.returnTypeAnnotation, enclosingDecl, context).symbol; - - signature.setReturnType(returnTypeSymbol); - - if (this.isTypeArgumentOrWrapper(returnTypeSymbol)) { - signature.setHasGenericParameter(); - - if (funcDeclSymbol) { - funcDeclSymbol.getType().setHasGenericSignature(); - } - } - } else { - signature.setReturnType(this.semanticInfoChain.anyTypeSymbol); - } - - if (funcDeclAST.arguments) { - for (var i = 0; i < funcDeclAST.arguments.members.length; i++) { - this.resolveFunctionTypeSignatureParameter(funcDeclAST.arguments.members[i], signature, enclosingDecl, context); - } - } - - if (funcDeclSymbol && signature.hasGenericParameter()) { - funcDeclSymbol.getType().setHasGenericSignature(); - } - - if (signature.hasGenericParameter()) { - if (funcDeclSymbol) { - funcDeclSymbol.getType().setHasGenericSignature(); - } - } - - funcDeclSymbol.setResolved(); - - return funcDeclSymbol; - }; - - PullTypeResolver.prototype.resolveFunctionTypeSignatureParameter = function (argDeclAST, signature, enclosingDecl, context) { - var paramDecl = this.getDeclForAST(argDeclAST); - var paramSymbol = paramDecl.getSymbol(); - - if (argDeclAST.typeExpr) { - var typeRef = this.resolveTypeReference(argDeclAST.typeExpr, enclosingDecl, context).symbol; - - if (paramSymbol.getIsVarArg() && !(typeRef.isArray() || typeRef == this.cachedArrayInterfaceType())) { - var diagnostic = context.postError(this.unitPath, argDeclAST.minChar, argDeclAST.getLength(), 228 /* Rest_parameters_must_be_array_types */, null, enclosingDecl); - typeRef = this.getNewErrorTypeSymbol(diagnostic); - } - - context.setTypeInContext(paramSymbol, typeRef); - - if (this.isTypeArgumentOrWrapper(typeRef)) { - signature.setHasGenericParameter(); - } - } else { - if (paramSymbol.getIsVarArg() && paramSymbol.getType()) { - if (this.cachedArrayInterfaceType()) { - context.setTypeInContext(paramSymbol, TypeScript.specializeToArrayType(this.cachedArrayInterfaceType(), paramSymbol.getType(), this, context)); - } else { - context.setTypeInContext(paramSymbol, paramSymbol.getType()); - } - } else { - context.setTypeInContext(paramSymbol, this.semanticInfoChain.anyTypeSymbol); - } - } - - paramSymbol.setResolved(); - }; - - PullTypeResolver.prototype.resolveFunctionExpressionParameter = function (argDeclAST, contextParam, enclosingDecl, context) { - var paramDecl = this.getDeclForAST(argDeclAST); - var paramSymbol = paramDecl.getSymbol(); - - if (argDeclAST.typeExpr) { - var typeRef = this.resolveTypeReference(argDeclAST.typeExpr, enclosingDecl, context).symbol; - - if (paramSymbol.getIsVarArg() && !(typeRef.isArray() || typeRef == this.cachedArrayInterfaceType())) { - var diagnostic = context.postError(this.unitPath, argDeclAST.minChar, argDeclAST.getLength(), 228 /* Rest_parameters_must_be_array_types */, null, enclosingDecl); - typeRef = this.getNewErrorTypeSymbol(diagnostic); - } - - context.setTypeInContext(paramSymbol, typeRef); - } else { - if (paramSymbol.getIsVarArg() && paramSymbol.getType()) { - if (this.cachedArrayInterfaceType()) { - context.setTypeInContext(paramSymbol, TypeScript.specializeToArrayType(this.cachedArrayInterfaceType(), paramSymbol.getType(), this, context)); - } else { - context.setTypeInContext(paramSymbol, paramSymbol.getType()); - } - } else if (contextParam) { - context.setTypeInContext(paramSymbol, contextParam.getType()); - } else { - context.setTypeInContext(paramSymbol, this.semanticInfoChain.anyTypeSymbol); - } - } - - paramSymbol.setResolved(); - }; - - PullTypeResolver.prototype.resolveInterfaceTypeReference = function (interfaceDeclAST, enclosingDecl, context) { - var interfaceSymbol = null; - - var interfaceDecl = this.getDeclForAST(interfaceDeclAST); - - if (!interfaceDecl) { - var semanticInfo = this.semanticInfoChain.getUnit(this.unitPath); - var declCollectionContext = new TypeScript.DeclCollectionContext(semanticInfo); - - declCollectionContext.scriptName = this.unitPath; - - if (enclosingDecl) { - declCollectionContext.pushParent(enclosingDecl); - } - - TypeScript.getAstWalkerFactory().walk(interfaceDeclAST, TypeScript.preCollectDecls, TypeScript.postCollectDecls, null, declCollectionContext); - - var interfaceDecl = this.getDeclForAST(interfaceDeclAST); - this.currentUnit.addSynthesizedDecl(interfaceDecl); - - var binder = new TypeScript.PullSymbolBinder(this.semanticInfoChain); - - binder.setUnit(this.unitPath); - binder.bindObjectTypeDeclarationToPullSymbol(interfaceDecl); - } - - interfaceSymbol = interfaceDecl.getSymbol(); - - if (interfaceDeclAST.members) { - var memberDecl = null; - var memberSymbol = null; - var memberType = null; - var typeMembers = interfaceDeclAST.members; - - for (var i = 0; i < typeMembers.members.length; i++) { - memberDecl = this.getDeclForAST(typeMembers.members[i]); - memberSymbol = (memberDecl.getKind() & TypeScript.PullElementKind.SomeSignature) ? memberDecl.getSignatureSymbol() : memberDecl.getSymbol(); - - this.resolveDeclaredSymbol(memberSymbol, enclosingDecl, context); - - memberType = memberSymbol.getType(); - - if ((memberType && memberType.isGeneric()) || (memberSymbol.isSignature() && (memberSymbol).isGeneric())) { - interfaceSymbol.setHasGenericMember(); - } - } - } - - interfaceSymbol.setResolved(); - - return interfaceSymbol; - }; - - PullTypeResolver.prototype.resolveTypeReference = function (typeRef, enclosingDecl, context) { - if (typeRef === null) { - return null; - } - - var symbolAndDiagnostics = this.getSymbolAndDiagnosticsForAST(typeRef); - if (!symbolAndDiagnostics) { - symbolAndDiagnostics = this.computeTypeReferenceSymbol(typeRef, enclosingDecl, context); - - if (!symbolAndDiagnostics.symbol.isGeneric()) { - this.setSymbolAndDiagnosticsForAST(typeRef, symbolAndDiagnostics, context); - } - } - - return symbolAndDiagnostics; - }; - - PullTypeResolver.prototype.computeTypeReferenceSymbol = function (typeRef, enclosingDecl, context) { - var typeDeclSymbol = null; - var diagnostic = null; - var symbolAndDiagnostic = null; - - if (typeRef.term.nodeType === 20 /* Name */) { - var prevResolvingTypeReference = context.resolvingTypeReference; - context.resolvingTypeReference = true; - symbolAndDiagnostic = this.resolveTypeNameExpression(typeRef.term, enclosingDecl, context); - typeDeclSymbol = symbolAndDiagnostic.symbol; - - context.resolvingTypeReference = prevResolvingTypeReference; - } else if (typeRef.term.nodeType === 12 /* FunctionDeclaration */) { - typeDeclSymbol = this.resolveFunctionTypeSignature(typeRef.term, enclosingDecl, context); - } else if (typeRef.term.nodeType === 14 /* InterfaceDeclaration */) { - typeDeclSymbol = this.resolveInterfaceTypeReference(typeRef.term, enclosingDecl, context); - } else if (typeRef.term.nodeType === 10 /* GenericType */) { - symbolAndDiagnostic = this.resolveGenericTypeReference(typeRef.term, enclosingDecl, context); - typeDeclSymbol = symbolAndDiagnostic.symbol; - } else if (typeRef.term.nodeType === 32 /* MemberAccessExpression */) { - var dottedName = typeRef.term; - - prevResolvingTypeReference = context.resolvingTypeReference; - symbolAndDiagnostic = this.resolveDottedTypeNameExpression(dottedName, enclosingDecl, context); - typeDeclSymbol = symbolAndDiagnostic.symbol; - context.resolvingTypeReference = prevResolvingTypeReference; - } else if (typeRef.term.nodeType === 5 /* StringLiteral */) { - var stringConstantAST = typeRef.term; - typeDeclSymbol = new TypeScript.PullStringConstantTypeSymbol(stringConstantAST.actualText); - var decl = new TypeScript.PullDecl(stringConstantAST.actualText, stringConstantAST.actualText, typeDeclSymbol.getKind(), null, new TypeScript.TextSpan(stringConstantAST.minChar, stringConstantAST.getLength()), enclosingDecl.getScriptName()); - this.currentUnit.addSynthesizedDecl(decl); - typeDeclSymbol.addDeclaration(decl); - } - - if (!typeDeclSymbol) { - return SymbolAndDiagnostics.create(this.getNewErrorTypeSymbol(null), [context.postError(this.unitPath, typeRef.term.minChar, typeRef.term.getLength(), 146 /* Unable_to_resolve_type */)]); - } - - if (typeDeclSymbol.isError()) { - return SymbolAndDiagnostics.fromSymbol(typeDeclSymbol); - } - - if (typeRef.arrayCount) { - var arraySymbol = typeDeclSymbol.getArrayType(); - - if (!arraySymbol) { - if (!this.cachedArrayInterfaceType().isResolved()) { - this.resolveDeclaredSymbol(this.cachedArrayInterfaceType(), enclosingDecl, context); - } - - if (typeDeclSymbol.isNamedTypeSymbol() && typeDeclSymbol.isGeneric() && !typeDeclSymbol.isTypeParameter() && typeDeclSymbol.isResolved() && !typeDeclSymbol.getIsSpecialized() && typeDeclSymbol.getTypeParameters().length && (typeDeclSymbol.getTypeArguments() == null && !this.isArrayOrEquivalent(typeDeclSymbol)) && this.isTypeRefWithoutTypeArgs(typeRef)) { - context.postError(this.unitPath, typeRef.minChar, typeRef.getLength(), 239 /* Generic_type_references_must_include_all_type_arguments */, null, enclosingDecl, true); - typeDeclSymbol = this.specializeTypeToAny(typeDeclSymbol, enclosingDecl, context); - } - - arraySymbol = TypeScript.specializeToArrayType(this.semanticInfoChain.elementTypeSymbol, typeDeclSymbol, this, context); - - if (!arraySymbol) { - arraySymbol = this.semanticInfoChain.anyTypeSymbol; - } - } - - if (typeRef.arrayCount > 1) { - for (var arity = typeRef.arrayCount - 1; arity > 0; arity--) { - var existingArraySymbol = arraySymbol.getArrayType(); - - if (!existingArraySymbol) { - arraySymbol = TypeScript.specializeToArrayType(this.semanticInfoChain.elementTypeSymbol, arraySymbol, this, context); - } else { - arraySymbol = existingArraySymbol; - } - } - } - - typeDeclSymbol = arraySymbol; - } - - return SymbolAndDiagnostics.fromSymbol(typeDeclSymbol); - }; - - PullTypeResolver.prototype.resolveVariableDeclaration = function (varDecl, context, enclosingDecl) { - var decl = this.getDeclForAST(varDecl); - - if (enclosingDecl && decl.getKind() == 2048 /* Parameter */) { - enclosingDecl.ensureSymbolIsBound(); - } - - var declSymbol = decl.getSymbol(); - var declParameterSymbol = decl.getValueDecl() ? decl.getValueDecl().getSymbol() : null; - - if (declSymbol.isResolved()) { - var declType = declSymbol.getType(); - var valDecl = decl.getValueDecl(); - - if (valDecl) { - var valSymbol = valDecl.getSymbol(); - - if (valSymbol && !valSymbol.isResolved()) { - valSymbol.setType(declType); - valSymbol.setResolved(); - } - } - - return declType; - } - - if (declSymbol.isResolving()) { - if (!context.inSpecialization) { - declSymbol.setType(this.semanticInfoChain.anyTypeSymbol); - declSymbol.setResolved(); - return declSymbol; - } - } - - declSymbol.startResolving(); - - var wrapperDecl = this.getEnclosingDecl(decl); - wrapperDecl = wrapperDecl ? wrapperDecl : enclosingDecl; - - var diagnostic = null; - - if (varDecl.typeExpr) { - var typeExprSymbol = this.resolveTypeReference(varDecl.typeExpr, wrapperDecl, context).symbol; - - if (!typeExprSymbol) { - diagnostic = context.postError(this.unitPath, varDecl.minChar, varDecl.getLength(), 147 /* Unable_to_resolve_type_of__0_ */, [varDecl.id.actualText], decl); - declSymbol.setType(this.getNewErrorTypeSymbol(diagnostic)); - - if (declParameterSymbol) { - context.setTypeInContext(declParameterSymbol, this.semanticInfoChain.anyTypeSymbol); - } - } else if (typeExprSymbol.isError()) { - context.setTypeInContext(declSymbol, typeExprSymbol); - } else { - if (typeExprSymbol.isNamedTypeSymbol() && typeExprSymbol.isGeneric() && !typeExprSymbol.isTypeParameter() && typeExprSymbol.isResolved() && !typeExprSymbol.getIsSpecialized() && typeExprSymbol.getTypeParameters().length && (typeExprSymbol.getTypeArguments() == null && !this.isArrayOrEquivalent(typeExprSymbol)) && this.isTypeRefWithoutTypeArgs(varDecl.typeExpr)) { - context.postError(this.unitPath, varDecl.typeExpr.minChar, varDecl.typeExpr.getLength(), 239 /* Generic_type_references_must_include_all_type_arguments */, null, enclosingDecl, true); - typeExprSymbol = this.specializeTypeToAny(typeExprSymbol, enclosingDecl, context); - } - - if (typeExprSymbol.isContainer()) { - var exportedTypeSymbol = (typeExprSymbol).getExportAssignedTypeSymbol(); - - if (exportedTypeSymbol) { - typeExprSymbol = exportedTypeSymbol; - } else { - var instanceSymbol = (typeExprSymbol.getType()).getInstanceSymbol(); - - if (!instanceSymbol || !TypeScript.PullHelpers.symbolIsEnum(instanceSymbol)) { - typeExprSymbol = this.getNewErrorTypeSymbol(diagnostic); - } else { - typeExprSymbol = instanceSymbol.getType(); - } - } - } else if (declSymbol.getIsVarArg() && !(typeExprSymbol.isArray() || typeExprSymbol == this.cachedArrayInterfaceType())) { - var diagnostic = context.postError(this.unitPath, varDecl.minChar, varDecl.getLength(), 228 /* Rest_parameters_must_be_array_types */, null, enclosingDecl); - typeExprSymbol = this.getNewErrorTypeSymbol(diagnostic); - } - - context.setTypeInContext(declSymbol, typeExprSymbol); - - if (declParameterSymbol) { - declParameterSymbol.setType(typeExprSymbol); - } - - if ((varDecl.nodeType === 19 /* Parameter */) && enclosingDecl && ((typeExprSymbol.isGeneric() && !typeExprSymbol.isArray()) || this.isTypeArgumentOrWrapper(typeExprSymbol))) { - var signature = enclosingDecl.getSpecializingSignatureSymbol(); - - if (signature) { - signature.setHasGenericParameter(); - } - } - } - } else if (varDecl.init) { - var initExprSymbolAndDiagnostics = this.resolveAST(varDecl.init, false, wrapperDecl, context); - var initExprSymbol = initExprSymbolAndDiagnostics && initExprSymbolAndDiagnostics.symbol; - - if (!initExprSymbol) { - diagnostic = context.postError(this.unitPath, varDecl.minChar, varDecl.getLength(), 147 /* Unable_to_resolve_type_of__0_ */, [varDecl.id.actualText], decl); - - context.setTypeInContext(declSymbol, this.getNewErrorTypeSymbol(diagnostic)); - - if (declParameterSymbol) { - context.setTypeInContext(declParameterSymbol, this.semanticInfoChain.anyTypeSymbol); - } - } else { - context.setTypeInContext(declSymbol, this.widenType(initExprSymbol.getType())); - initExprSymbol.addOutgoingLink(declSymbol, 2 /* ProvidesInferredType */); - - if (declParameterSymbol) { - context.setTypeInContext(declParameterSymbol, initExprSymbol.getType()); - initExprSymbol.addOutgoingLink(declParameterSymbol, 2 /* ProvidesInferredType */); - } - } - } else if (declSymbol.getKind() === 4 /* Container */) { - instanceSymbol = (declSymbol).getInstanceSymbol(); - var instanceType = instanceSymbol.getType(); - - if (instanceType) { - context.setTypeInContext(declSymbol, instanceType); - } else { - context.setTypeInContext(declSymbol, this.semanticInfoChain.anyTypeSymbol); - } - } else { - var defaultType = this.semanticInfoChain.anyTypeSymbol; - - if (declSymbol.getIsVarArg()) { - defaultType = TypeScript.specializeToArrayType(this.cachedArrayInterfaceType(), defaultType, this, context); - } - - context.setTypeInContext(declSymbol, defaultType); - - if (declParameterSymbol) { - declParameterSymbol.setType(defaultType); - } - } - - declSymbol.setResolved(); - - if (declParameterSymbol) { - declParameterSymbol.setResolved(); - } - - return declSymbol; - }; - - PullTypeResolver.prototype.resolveTypeParameterDeclaration = function (typeParameterAST, context) { - var typeParameterDecl = this.getDeclForAST(typeParameterAST); - var typeParameterSymbol = typeParameterDecl.getSymbol(); - - if (typeParameterSymbol.isResolved() || typeParameterSymbol.isResolving()) { - return typeParameterSymbol; - } - - typeParameterSymbol.startResolving(); - - if (typeParameterAST.constraint) { - var enclosingDecl = this.getEnclosingDecl(typeParameterDecl); - var constraintTypeSymbol = this.resolveTypeReference(typeParameterAST.constraint, enclosingDecl, context).symbol; - - if (constraintTypeSymbol.isNamedTypeSymbol() && constraintTypeSymbol.isGeneric() && !constraintTypeSymbol.isTypeParameter() && constraintTypeSymbol.getTypeParameters().length && (constraintTypeSymbol.getTypeArguments() == null && !this.isArrayOrEquivalent(constraintTypeSymbol)) && constraintTypeSymbol.isResolved() && this.isTypeRefWithoutTypeArgs(typeParameterAST.constraint)) { - context.postError(this.unitPath, typeParameterAST.constraint.minChar, typeParameterAST.constraint.getLength(), 239 /* Generic_type_references_must_include_all_type_arguments */, null, enclosingDecl, true); - constraintTypeSymbol = this.specializeTypeToAny(constraintTypeSymbol, enclosingDecl, context); - } - - if (constraintTypeSymbol) { - typeParameterSymbol.setConstraint(constraintTypeSymbol); - } - } - - typeParameterSymbol.setResolved(); - - return typeParameterSymbol; - }; - - PullTypeResolver.prototype.resolveFunctionBodyReturnTypes = function (funcDeclAST, signature, useContextualType, enclosingDecl, context) { - var _this = this; - var returnStatements = []; - - var enclosingDeclStack = [enclosingDecl]; - - var preFindReturnExpressionTypes = function (ast, parent, walker) { - var go = true; - - switch (ast.nodeType) { - case 12 /* FunctionDeclaration */: - go = false; - break; - - case 93 /* ReturnStatement */: - var returnStatement = ast; - returnStatements[returnStatements.length] = { returnStatement: returnStatement, enclosingDecl: enclosingDeclStack[enclosingDeclStack.length - 1] }; - go = false; - break; - - case 101 /* CatchClause */: - case 99 /* WithStatement */: - enclosingDeclStack[enclosingDeclStack.length] = _this.getDeclForAST(ast); - break; - - default: - break; - } - - walker.options.goChildren = go; - - return ast; - }; - - var postFindReturnExpressionEnclosingDecls = function (ast, parent, walker) { - switch (ast.nodeType) { - case 101 /* CatchClause */: - case 99 /* WithStatement */: - enclosingDeclStack.length--; - break; - default: - break; - } - - walker.options.goChildren = true; - - return ast; - }; - - TypeScript.getAstWalkerFactory().walk(funcDeclAST.block, preFindReturnExpressionTypes, postFindReturnExpressionEnclosingDecls); - - if (!returnStatements.length) { - signature.setReturnType(this.semanticInfoChain.voidTypeSymbol); - } else { - var returnExpressionSymbols = []; - var returnType; - - for (var i = 0; i < returnStatements.length; i++) { - if (returnStatements[i].returnStatement.returnExpression) { - returnType = this.resolveAST(returnStatements[i].returnStatement.returnExpression, useContextualType, returnStatements[i].enclosingDecl, context).symbol.getType(); - - if (returnType.isError()) { - signature.setReturnType(returnType); - return; - } - - returnExpressionSymbols[returnExpressionSymbols.length] = returnType; - } - } - - if (!returnExpressionSymbols.length) { - signature.setReturnType(this.semanticInfoChain.voidTypeSymbol); - } else { - var collection = { - getLength: function () { - return returnExpressionSymbols.length; - }, - setTypeAtIndex: function (index, type) { - }, - getTypeAtIndex: function (index) { - return returnExpressionSymbols[index].getType(); - } - }; - - returnType = this.findBestCommonType(returnExpressionSymbols[0], null, collection, context, new TypeScript.TypeComparisonInfo()); - - if (useContextualType && returnType == this.semanticInfoChain.anyTypeSymbol) { - var contextualType = context.getContextualType(); - - if (contextualType) { - returnType = contextualType; - } - } - - signature.setReturnType(returnType ? this.widenType(returnType) : this.semanticInfoChain.anyTypeSymbol); - - if (this.isTypeArgumentOrWrapper(returnType)) { - var functionDecl = this.getDeclForAST(funcDeclAST); - var functionSymbol = functionDecl.getSymbol(); - - if (functionSymbol) { - functionSymbol.getType().setHasGenericSignature(); - } - } - - for (var i = 0; i < returnExpressionSymbols.length; i++) { - returnExpressionSymbols[i].addOutgoingLink(signature, 2 /* ProvidesInferredType */); - } - } - } - }; - - PullTypeResolver.prototype.resolveFunctionDeclaration = function (funcDeclAST, context) { - var funcDecl = this.getDeclForAST(funcDeclAST); - - var funcSymbol = funcDecl.getSymbol(); - - var signature = funcDecl.getSpecializingSignatureSymbol(); - - var hadError = false; - - var isConstructor = funcDeclAST.isConstructor || TypeScript.hasFlag(funcDeclAST.getFunctionFlags(), 1024 /* ConstructMember */); - - if (signature) { - if (signature.isResolved()) { - return funcSymbol; - } - - if (isConstructor && !signature.isResolving()) { - var classAST = funcDeclAST.classDecl; - - if (classAST) { - var classDecl = this.getDeclForAST(classAST); - var classSymbol = classDecl.getSymbol(); - - if (!classSymbol.isResolved() && !classSymbol.isResolving()) { - this.resolveDeclaredSymbol(classSymbol, this.getEnclosingDecl(classDecl), context); - } - } - } - - var diagnostic; - - if (signature.isResolving()) { - if (funcDeclAST.returnTypeAnnotation) { - var returnTypeSymbol = this.resolveTypeReference(funcDeclAST.returnTypeAnnotation, funcDecl, context).symbol; - if (!returnTypeSymbol) { - diagnostic = context.postError(this.unitPath, funcDeclAST.returnTypeAnnotation.minChar, funcDeclAST.returnTypeAnnotation.getLength(), 197 /* Cannot_resolve_return_type_reference */, null, funcDecl); - signature.setReturnType(this.getNewErrorTypeSymbol(diagnostic)); - hadError = true; - } else { - if (this.isTypeArgumentOrWrapper(returnTypeSymbol)) { - signature.setHasGenericParameter(); - if (funcSymbol) { - funcSymbol.getType().setHasGenericSignature(); - } - } - signature.setReturnType(returnTypeSymbol); - - if (isConstructor && returnTypeSymbol === this.semanticInfoChain.voidTypeSymbol) { - context.postError(this.unitPath, funcDeclAST.minChar, funcDeclAST.getLength(), 198 /* Constructors_cannot_have_a_return_type_of__void_ */, null, funcDecl, true); - } - } - } else { - signature.setReturnType(this.semanticInfoChain.anyTypeSymbol); - } - - signature.setResolved(); - return funcSymbol; - } - - signature.startResolving(); - - if (funcDeclAST.typeArguments) { - for (var i = 0; i < funcDeclAST.typeArguments.members.length; i++) { - this.resolveTypeParameterDeclaration(funcDeclAST.typeArguments.members[i], context); - } - } - - if (funcDeclAST.arguments) { - for (var i = 0; i < funcDeclAST.arguments.members.length; i++) { - this.resolveVariableDeclaration(funcDeclAST.arguments.members[i], context, funcDecl); - } - } - - if (signature.isGeneric()) { - if (funcSymbol) { - funcSymbol.getType().setHasGenericSignature(); - } - } - - if (funcDeclAST.returnTypeAnnotation) { - var prevReturnTypeSymbol = signature.getReturnType(); - - returnTypeSymbol = this.resolveTypeReference(funcDeclAST.returnTypeAnnotation, funcDecl, context).symbol; - - if (!returnTypeSymbol) { - diagnostic = context.postError(this.unitPath, funcDeclAST.returnTypeAnnotation.minChar, funcDeclAST.returnTypeAnnotation.getLength(), 197 /* Cannot_resolve_return_type_reference */, null, funcDecl); - signature.setReturnType(this.getNewErrorTypeSymbol(diagnostic)); - - hadError = true; - } else if (!(this.isTypeArgumentOrWrapper(returnTypeSymbol) && prevReturnTypeSymbol && !this.isTypeArgumentOrWrapper(prevReturnTypeSymbol))) { - if (this.isTypeArgumentOrWrapper(returnTypeSymbol)) { - signature.setHasGenericParameter(); - - if (funcSymbol) { - funcSymbol.getType().setHasGenericSignature(); - } - } - - signature.setReturnType(returnTypeSymbol); - - if (isConstructor && returnTypeSymbol === this.semanticInfoChain.voidTypeSymbol) { - context.postError(this.unitPath, funcDeclAST.minChar, funcDeclAST.getLength(), 198 /* Constructors_cannot_have_a_return_type_of__void_ */, null, funcDecl, true); - } - } - } else if (!funcDeclAST.isConstructor) { - if (funcDeclAST.isSignature()) { - signature.setReturnType(this.semanticInfoChain.anyTypeSymbol); - } else { - this.resolveFunctionBodyReturnTypes(funcDeclAST, signature, false, funcDecl, context); - } - } - - if (!hadError) { - signature.setResolved(); - } - } - - return funcSymbol; - }; - - PullTypeResolver.prototype.resolveGetAccessorDeclaration = function (funcDeclAST, context) { - var funcDecl = this.getDeclForAST(funcDeclAST); - var accessorSymbol = funcDecl.getSymbol(); - - var getterSymbol = accessorSymbol.getGetter(); - var getterTypeSymbol = getterSymbol.getType(); - - var signature = getterTypeSymbol.getCallSignatures()[0]; - - var hadError = false; - var diagnostic; - - if (signature) { - if (signature.isResolved()) { - return accessorSymbol; - } - - if (signature.isResolving()) { - signature.setReturnType(this.semanticInfoChain.anyTypeSymbol); - signature.setResolved(); - - return accessorSymbol; - } - - signature.startResolving(); - - if (funcDeclAST.arguments) { - for (var i = 0; i < funcDeclAST.arguments.members.length; i++) { - this.resolveVariableDeclaration(funcDeclAST.arguments.members[i], context, funcDecl); - } - } - - if (signature.hasGenericParameter()) { - if (getterSymbol) { - getterTypeSymbol.setHasGenericSignature(); - } - } - - if (funcDeclAST.returnTypeAnnotation) { - var returnTypeSymbol = this.resolveTypeReference(funcDeclAST.returnTypeAnnotation, funcDecl, context).symbol; - - if (!returnTypeSymbol) { - diagnostic = context.postError(this.unitPath, funcDeclAST.returnTypeAnnotation.minChar, funcDeclAST.returnTypeAnnotation.getLength(), 197 /* Cannot_resolve_return_type_reference */, null, funcDecl); - signature.setReturnType(this.getNewErrorTypeSymbol(diagnostic)); - - hadError = true; - } else { - if (this.isTypeArgumentOrWrapper(returnTypeSymbol)) { - signature.setHasGenericParameter(); - - if (getterSymbol) { - getterTypeSymbol.setHasGenericSignature(); - } - } - - signature.setReturnType(returnTypeSymbol); - } - } else { - if (funcDeclAST.isSignature()) { - signature.setReturnType(this.semanticInfoChain.anyTypeSymbol); - } else { - this.resolveFunctionBodyReturnTypes(funcDeclAST, signature, false, funcDecl, context); - } - } - - if (!hadError) { - signature.setResolved(); - } - } - - var accessorType = signature.getReturnType(); - - var setter = accessorSymbol.getSetter(); - - if (setter) { - var setterType = setter.getType(); - var setterSig = setterType.getCallSignatures()[0]; - - if (setterSig.isResolved()) { - var setterParameters = setterSig.getParameters(); - - if (setterParameters.length) { - var setterParameter = setterParameters[0]; - var setterParameterType = setterParameter.getType(); - - if (!this.typesAreIdentical(accessorType, setterParameterType)) { - diagnostic = context.postError(this.unitPath, funcDeclAST.minChar, funcDeclAST.getLength(), 165 /* _get__and__set__accessor_must_have_the_same_type */, null, this.getEnclosingDecl(funcDecl)); - accessorSymbol.setType(this.getNewErrorTypeSymbol(diagnostic)); - } - } - } else { - accessorSymbol.setType(accessorType); - } - } else { - accessorSymbol.setType(accessorType); - } - - return accessorSymbol; - }; - - PullTypeResolver.prototype.resolveSetAccessorDeclaration = function (funcDeclAST, context) { - var funcDecl = this.getDeclForAST(funcDeclAST); - var accessorSymbol = funcDecl.getSymbol(); - - var setterSymbol = accessorSymbol.getSetter(); - var setterTypeSymbol = setterSymbol.getType(); - - var signature = setterTypeSymbol.getCallSignatures()[0]; - - var hadError = false; - - if (signature) { - if (signature.isResolved()) { - return accessorSymbol; - } - - if (signature.isResolving()) { - signature.setReturnType(this.semanticInfoChain.anyTypeSymbol); - signature.setResolved(); - - return accessorSymbol; - } - - signature.startResolving(); - - if (funcDeclAST.arguments) { - for (var i = 0; i < funcDeclAST.arguments.members.length; i++) { - this.resolveVariableDeclaration(funcDeclAST.arguments.members[i], context, funcDecl); - } - } - - if (signature.hasGenericParameter()) { - if (setterSymbol) { - setterTypeSymbol.setHasGenericSignature(); - } - } - - if (!hadError) { - signature.setResolved(); - } - } - - var parameters = signature.getParameters(); - - var getter = accessorSymbol.getGetter(); - - var accessorType = parameters.length ? parameters[0].getType() : getter ? getter.getType() : this.semanticInfoChain.undefinedTypeSymbol; - - if (getter) { - var getterType = getter.getType(); - var getterSig = getterType.getCallSignatures()[0]; - - if (accessorType == this.semanticInfoChain.undefinedTypeSymbol) { - accessorType = getterType; - } - - if (getterSig.isResolved()) { - var getterReturnType = getterSig.getReturnType(); - - if (!this.typesAreIdentical(accessorType, getterReturnType)) { - if (this.isAnyOrEquivalent(accessorType)) { - accessorSymbol.setType(getterReturnType); - if (!accessorType.isError()) { - parameters[0].setType(getterReturnType); - } - } else { - var diagnostic = context.postError(this.unitPath, funcDeclAST.minChar, funcDeclAST.getLength(), 165 /* _get__and__set__accessor_must_have_the_same_type */, null, this.getEnclosingDecl(funcDecl)); - accessorSymbol.setType(this.getNewErrorTypeSymbol(diagnostic)); - } - } - } else { - accessorSymbol.setType(accessorType); - } - } else { - accessorSymbol.setType(accessorType); - } - - return accessorSymbol; - }; - - PullTypeResolver.prototype.resolveAST = function (ast, inContextuallyTypedAssignment, enclosingDecl, context) { - TypeScript.globalSemanticInfoChain = this.semanticInfoChain; - - if (TypeScript.globalBinder) { - TypeScript.globalBinder.semanticInfoChain = this.semanticInfoChain; - } - - switch (ast.nodeType) { - case 101 /* CatchClause */: - case 99 /* WithStatement */: - case 2 /* Script */: - return SymbolAndDiagnostics.fromSymbol(null); - - case 15 /* ModuleDeclaration */: - return SymbolAndDiagnostics.fromSymbol(this.resolveModuleDeclaration(ast, context)); - - case 14 /* InterfaceDeclaration */: - return SymbolAndDiagnostics.fromSymbol(this.resolveInterfaceDeclaration(ast, context)); - - case 13 /* ClassDeclaration */: - return SymbolAndDiagnostics.fromSymbol(this.resolveClassDeclaration(ast, context)); - - case 17 /* VariableDeclarator */: - case 19 /* Parameter */: - return SymbolAndDiagnostics.fromSymbol(this.resolveVariableDeclaration(ast, context, enclosingDecl)); - - case 9 /* TypeParameter */: - return SymbolAndDiagnostics.fromSymbol(this.resolveTypeParameterDeclaration(ast, context)); - - case 16 /* ImportDeclaration */: - return SymbolAndDiagnostics.fromSymbol(this.resolveImportDeclaration(ast, context)); - - case 22 /* ObjectLiteralExpression */: - return this.resolveObjectLiteralExpression(ast, inContextuallyTypedAssignment, enclosingDecl, context); - - case 10 /* GenericType */: - return this.resolveGenericTypeReference(ast, enclosingDecl, context); - - case 20 /* Name */: - if (context.resolvingTypeReference) { - return this.resolveTypeNameExpression(ast, enclosingDecl, context); - } else { - return this.resolveNameExpression(ast, enclosingDecl, context); - } - - case 32 /* MemberAccessExpression */: - if (context.resolvingTypeReference) { - return this.resolveDottedTypeNameExpression(ast, enclosingDecl, context); - } else { - return this.resolveDottedNameExpression(ast, enclosingDecl, context); - } - - case 10 /* GenericType */: - return this.resolveGenericTypeReference(ast, enclosingDecl, context); - - case 12 /* FunctionDeclaration */: { - var funcDecl = ast; - - if (funcDecl.isGetAccessor()) { - return SymbolAndDiagnostics.fromSymbol(this.resolveGetAccessorDeclaration(funcDecl, context)); - } else if (funcDecl.isSetAccessor()) { - return SymbolAndDiagnostics.fromSymbol(this.resolveSetAccessorDeclaration(funcDecl, context)); - } else if (inContextuallyTypedAssignment || (funcDecl.getFunctionFlags() & 8192 /* IsFunctionExpression */) || (funcDecl.getFunctionFlags() & 2048 /* IsFatArrowFunction */) || (funcDecl.getFunctionFlags() & 16384 /* IsFunctionProperty */)) { - return SymbolAndDiagnostics.fromSymbol(this.resolveFunctionExpression(funcDecl, inContextuallyTypedAssignment, enclosingDecl, context)); - } else { - return SymbolAndDiagnostics.fromSymbol(this.resolveFunctionDeclaration(funcDecl, context)); - } - } - - case 21 /* ArrayLiteralExpression */: - return this.resolveArrayLiteralExpression(ast, inContextuallyTypedAssignment, enclosingDecl, context); - - case 29 /* ThisExpression */: - return this.resolveThisExpression(ast, enclosingDecl, context); - - case 30 /* SuperExpression */: - return this.resolveSuperExpression(ast, enclosingDecl, context); - - case 36 /* InvocationExpression */: - return this.resolveCallExpression(ast, inContextuallyTypedAssignment, enclosingDecl, context); - - case 37 /* ObjectCreationExpression */: - return this.resolveNewExpression(ast, inContextuallyTypedAssignment, enclosingDecl, context); - - case 78 /* CastExpression */: - return this.resolveTypeAssertionExpression(ast, inContextuallyTypedAssignment, enclosingDecl, context); - - case 11 /* TypeRef */: - return this.resolveTypeReference(ast, enclosingDecl, context); - - case 87 /* ExportAssignment */: - return this.resolveExportAssignmentStatement(ast, enclosingDecl, context); - - case 7 /* NumericLiteral */: - return SymbolAndDiagnostics.fromSymbol(this.semanticInfoChain.numberTypeSymbol); - case 5 /* StringLiteral */: - return SymbolAndDiagnostics.fromSymbol(this.semanticInfoChain.stringTypeSymbol); - case 8 /* NullLiteral */: - return SymbolAndDiagnostics.fromSymbol(this.semanticInfoChain.nullTypeSymbol); - case 3 /* TrueLiteral */: - case 4 /* FalseLiteral */: - return SymbolAndDiagnostics.fromSymbol(this.semanticInfoChain.booleanTypeSymbol); - case 24 /* VoidExpression */: - return SymbolAndDiagnostics.fromSymbol(this.semanticInfoChain.voidTypeSymbol); - - case 38 /* AssignmentExpression */: - return this.resolveAssignmentStatement(ast, inContextuallyTypedAssignment, enclosingDecl, context); - - case 73 /* LogicalNotExpression */: - case 57 /* NotEqualsWithTypeConversionExpression */: - case 56 /* EqualsWithTypeConversionExpression */: - case 58 /* EqualsExpression */: - case 59 /* NotEqualsExpression */: - case 60 /* LessThanExpression */: - case 61 /* LessThanOrEqualExpression */: - case 63 /* GreaterThanOrEqualExpression */: - case 62 /* GreaterThanExpression */: - return SymbolAndDiagnostics.fromSymbol(this.semanticInfoChain.booleanTypeSymbol); - - case 64 /* AddExpression */: - case 39 /* AddAssignmentExpression */: - return this.resolveArithmeticExpression(ast, inContextuallyTypedAssignment, enclosingDecl, context); - - case 40 /* SubtractAssignmentExpression */: - case 42 /* MultiplyAssignmentExpression */: - case 41 /* DivideAssignmentExpression */: - case 43 /* ModuloAssignmentExpression */: - case 46 /* OrAssignmentExpression */: - case 44 /* AndAssignmentExpression */: - - case 72 /* BitwiseNotExpression */: - case 65 /* SubtractExpression */: - case 66 /* MultiplyExpression */: - case 67 /* DivideExpression */: - case 68 /* ModuloExpression */: - case 53 /* BitwiseOrExpression */: - case 55 /* BitwiseAndExpression */: - case 26 /* PlusExpression */: - case 27 /* NegateExpression */: - case 76 /* PostIncrementExpression */: - case 74 /* PreIncrementExpression */: - case 77 /* PostDecrementExpression */: - case 75 /* PreDecrementExpression */: - return SymbolAndDiagnostics.fromSymbol(this.semanticInfoChain.numberTypeSymbol); - - case 69 /* LeftShiftExpression */: - case 70 /* SignedRightShiftExpression */: - case 71 /* UnsignedRightShiftExpression */: - case 47 /* LeftShiftAssignmentExpression */: - case 48 /* SignedRightShiftAssignmentExpression */: - case 49 /* UnsignedRightShiftAssignmentExpression */: - return SymbolAndDiagnostics.fromSymbol(this.semanticInfoChain.numberTypeSymbol); - - case 35 /* ElementAccessExpression */: - return this.resolveIndexExpression(ast, inContextuallyTypedAssignment, enclosingDecl, context); - - case 51 /* LogicalOrExpression */: - return this.resolveLogicalOrExpression(ast, inContextuallyTypedAssignment, enclosingDecl, context); - - case 52 /* LogicalAndExpression */: - return this.resolveLogicalAndExpression(ast, inContextuallyTypedAssignment, enclosingDecl, context); - - case 34 /* TypeOfExpression */: - return SymbolAndDiagnostics.fromSymbol(this.semanticInfoChain.stringTypeSymbol); - - case 95 /* ThrowStatement */: - return SymbolAndDiagnostics.fromSymbol(this.semanticInfoChain.voidTypeSymbol); - - case 28 /* DeleteExpression */: - return SymbolAndDiagnostics.fromSymbol(this.semanticInfoChain.booleanTypeSymbol); - - case 50 /* ConditionalExpression */: - return this.resolveConditionalExpression(ast, enclosingDecl, context); - - case 6 /* RegularExpressionLiteral */: - return this.resolveRegularExpressionLiteral(); - - case 79 /* ParenthesizedExpression */: - return this.resolveParenthesizedExpression(ast, enclosingDecl, context); - - case 88 /* ExpressionStatement */: - return this.resolveExpressionStatement(ast, inContextuallyTypedAssignment, enclosingDecl, context); - - case 33 /* InstanceOfExpression */: - return SymbolAndDiagnostics.fromSymbol(this.semanticInfoChain.booleanTypeSymbol); - } - - return SymbolAndDiagnostics.fromSymbol(this.semanticInfoChain.anyTypeSymbol); - }; - - PullTypeResolver.prototype.resolveRegularExpressionLiteral = function () { - if (this.cachedRegExpInterfaceType()) { - return SymbolAndDiagnostics.fromSymbol(this.cachedRegExpInterfaceType()); - } else { - return SymbolAndDiagnostics.fromSymbol(this.semanticInfoChain.anyTypeSymbol); - } - }; - - PullTypeResolver.prototype.isNameOrMemberAccessExpression = function (ast) { - var checkAST = ast; - - while (checkAST) { - if (checkAST.nodeType === 88 /* ExpressionStatement */) { - checkAST = (checkAST).expression; - } else if (checkAST.nodeType === 79 /* ParenthesizedExpression */) { - checkAST = (checkAST).expression; - } else if (checkAST.nodeType === 20 /* Name */) { - return true; - } else if (checkAST.nodeType === 32 /* MemberAccessExpression */) { - return true; - } else { - return false; - } - } - }; - - PullTypeResolver.prototype.resolveNameSymbol = function (nameSymbol, context) { - if (nameSymbol && !context.canUseTypeSymbol && nameSymbol != this.semanticInfoChain.undefinedTypeSymbol && nameSymbol != this.semanticInfoChain.nullTypeSymbol && (nameSymbol.isPrimitive() || !(nameSymbol.getKind() & TypeScript.PullElementKind.SomeValue))) { - nameSymbol = null; - } - - return nameSymbol; - }; - - PullTypeResolver.prototype.resolveNameExpression = function (nameAST, enclosingDecl, context) { - var nameSymbolAndDiagnostics = this.getSymbolAndDiagnosticsForAST(nameAST); - var foundCached = nameSymbolAndDiagnostics != null; - - if (!foundCached) { - nameSymbolAndDiagnostics = this.computeNameExpression(nameAST, enclosingDecl, context); - } - - var nameSymbol = nameSymbolAndDiagnostics.symbol; - if (!nameSymbol.isResolved()) { - this.resolveDeclaredSymbol(nameSymbol, enclosingDecl, context); - } - - if (!foundCached && !this.isAnyOrEquivalent(nameSymbol.getType())) { - this.setSymbolAndDiagnosticsForAST(nameAST, nameSymbolAndDiagnostics, context); - } - - return nameSymbolAndDiagnostics; - }; - - PullTypeResolver.prototype.computeNameExpression = function (nameAST, enclosingDecl, context) { - if (nameAST.isMissing()) { - return SymbolAndDiagnostics.fromSymbol(this.semanticInfoChain.anyTypeSymbol); - } - - var id = nameAST.text; - - var declPath = enclosingDecl !== null ? TypeScript.getPathToDecl(enclosingDecl) : []; - - if (enclosingDecl && !declPath.length) { - declPath = [enclosingDecl]; - } - - var aliasSymbol = null; - var nameSymbol = this.getSymbolFromDeclPath(id, declPath, TypeScript.PullElementKind.SomeValue); - - if (!nameSymbol && id === "arguments" && enclosingDecl && (enclosingDecl.getKind() & TypeScript.PullElementKind.SomeFunction)) { - nameSymbol = this.cachedFunctionArgumentsSymbol; - - if (this.cachedIArgumentsInterfaceType() && !this.cachedIArgumentsInterfaceType().isResolved()) { - this.resolveDeclaredSymbol(this.cachedIArgumentsInterfaceType(), enclosingDecl, context); - } - } - - if (!nameSymbol) { - return SymbolAndDiagnostics.create(this.getNewErrorTypeSymbol(null, id), [context.postError(this.unitPath, nameAST.minChar, nameAST.getLength(), 164 /* Could_not_find_symbol__0_ */, [nameAST.actualText])]); - } - - if (nameSymbol.isType() && nameSymbol.isAlias()) { - aliasSymbol = nameSymbol; - - (aliasSymbol).setIsUsedAsValue(); - - if (!nameSymbol.isResolved()) { - this.resolveDeclaredSymbol(nameSymbol, enclosingDecl, context); - } - - var exportAssignmentSymbol = (nameSymbol).getExportAssignedValueSymbol(); - - if (exportAssignmentSymbol) { - nameSymbol = exportAssignmentSymbol; - } else { - aliasSymbol = null; - } - } - - return SymbolAndDiagnostics.fromAlias(nameSymbol, aliasSymbol); - }; - - PullTypeResolver.prototype.resolveDottedNameExpression = function (dottedNameAST, enclosingDecl, context) { - var symbolAndDiagnostics = this.getSymbolAndDiagnosticsForAST(dottedNameAST); - var foundCached = symbolAndDiagnostics != null; - - if (!foundCached) { - symbolAndDiagnostics = this.computeDottedNameExpressionSymbol(dottedNameAST, enclosingDecl, context); - } - - var symbol = symbolAndDiagnostics && symbolAndDiagnostics.symbol; - if (symbol && !symbol.isResolved()) { - this.resolveDeclaredSymbol(symbol, enclosingDecl, context); - } - - if (!foundCached && !this.isAnyOrEquivalent(symbol.getType())) { - this.setSymbolAndDiagnosticsForAST(dottedNameAST, symbolAndDiagnostics, context); - this.setSymbolAndDiagnosticsForAST(dottedNameAST.operand2, symbolAndDiagnostics, context); - } - - return symbolAndDiagnostics; - }; - - PullTypeResolver.prototype.isPrototypeMember = function (dottedNameAST, enclosingDecl, context) { - var rhsName = (dottedNameAST.operand2).text; - if (rhsName === "prototype") { - var prevCanUseTypeSymbol = context.canUseTypeSymbol; - context.canUseTypeSymbol = true; - var lhsType = this.resolveAST(dottedNameAST.operand1, false, enclosingDecl, context).symbol.getType(); - context.canUseTypeSymbol = prevCanUseTypeSymbol; - - if (lhsType) { - if (lhsType.isClass() || lhsType.isConstructor()) { - return true; - } else { - var classInstanceType = lhsType.getAssociatedContainerType(); - - if (classInstanceType && classInstanceType.isClass()) { - return true; - } - } - } - } - - return false; - }; - - PullTypeResolver.prototype.computeDottedNameExpressionSymbol = function (dottedNameAST, enclosingDecl, context) { - if ((dottedNameAST.operand2).isMissing()) { - return SymbolAndDiagnostics.fromSymbol(this.semanticInfoChain.anyTypeSymbol); - } - - var rhsName = (dottedNameAST.operand2).text; - var prevCanUseTypeSymbol = context.canUseTypeSymbol; - context.canUseTypeSymbol = true; - var lhs = this.resolveAST(dottedNameAST.operand1, false, enclosingDecl, context).symbol; - context.canUseTypeSymbol = prevCanUseTypeSymbol; - var lhsType = lhs.getType(); - - if (lhs.isAlias()) { - (lhs).setIsUsedAsValue(); - } - - if (this.isAnyOrEquivalent(lhsType)) { - return SymbolAndDiagnostics.fromSymbol(lhsType); - } - - if (!lhsType) { - return SymbolAndDiagnostics.create(this.getNewErrorTypeSymbol(null), [context.postError(this.unitPath, dottedNameAST.operand2.minChar, dottedNameAST.operand2.getLength(), 162 /* Could_not_find_enclosing_symbol_for_dotted_name__0_ */, [(dottedNameAST.operand2).actualText])]); - } - - if ((lhsType === this.semanticInfoChain.numberTypeSymbol || (lhs.getKind() == 67108864 /* EnumMember */)) && this.cachedNumberInterfaceType()) { - lhsType = this.cachedNumberInterfaceType(); - } else if (lhsType === this.semanticInfoChain.stringTypeSymbol && this.cachedStringInterfaceType()) { - lhsType = this.cachedStringInterfaceType(); - } else if (lhsType === this.semanticInfoChain.booleanTypeSymbol && this.cachedBooleanInterfaceType()) { - lhsType = this.cachedBooleanInterfaceType(); - } - - if (!lhsType.isResolved()) { - var potentiallySpecializedType = this.resolveDeclaredSymbol(lhsType, enclosingDecl, context); - - if (potentiallySpecializedType != lhsType) { - if (!lhs.isType()) { - context.setTypeInContext(lhs, potentiallySpecializedType); - } - - lhsType = potentiallySpecializedType; - } - } - - if (lhsType.isContainer() && !lhsType.isAlias()) { - var instanceSymbol = (lhsType).getInstanceSymbol(); - - if (instanceSymbol) { - lhsType = instanceSymbol.getType(); - } - } - - if (this.isPrototypeMember(dottedNameAST, enclosingDecl, context)) { - if (lhsType.isClass()) { - return SymbolAndDiagnostics.fromSymbol(lhsType); - } else { - var classInstanceType = lhsType.getAssociatedContainerType(); - - if (classInstanceType && classInstanceType.isClass()) { - return SymbolAndDiagnostics.fromSymbol(classInstanceType); - } - } - } - - if (lhsType.isTypeParameter()) { - lhsType = this.substituteUpperBoundForType(lhsType); - } - - var nameSymbol = null; - if (!(lhs.isType() && (lhs).isClass() && this.isNameOrMemberAccessExpression(dottedNameAST.operand1)) && !nameSymbol) { - nameSymbol = this.getMemberSymbol(rhsName, TypeScript.PullElementKind.SomeValue, lhsType); - nameSymbol = this.resolveNameSymbol(nameSymbol, context); - } - - if (!nameSymbol) { - if (lhsType.isClass()) { - var staticType = (lhsType).getConstructorMethod().getType(); - - nameSymbol = this.getMemberSymbol(rhsName, TypeScript.PullElementKind.SomeValue, staticType); - - if (!nameSymbol) { - nameSymbol = this.getMemberSymbol(rhsName, TypeScript.PullElementKind.SomeValue, lhsType); - } - } else if ((lhsType.getCallSignatures().length || lhsType.getConstructSignatures().length) && this.cachedFunctionInterfaceType()) { - nameSymbol = this.getMemberSymbol(rhsName, TypeScript.PullElementKind.SomeValue, this.cachedFunctionInterfaceType()); - } else if (lhsType.isContainer()) { - var containerType = (lhsType.isAlias() ? (lhsType).getType() : lhsType); - var associatedInstance = containerType.getInstanceSymbol(); - - if (associatedInstance) { - var instanceType = associatedInstance.getType(); - - nameSymbol = this.getMemberSymbol(rhsName, TypeScript.PullElementKind.SomeValue, instanceType); - } - } else { - var associatedType = lhsType.getAssociatedContainerType(); - - if (associatedType && !associatedType.isClass()) { - nameSymbol = this.getMemberSymbol(rhsName, TypeScript.PullElementKind.SomeValue, associatedType); - } - } - - nameSymbol = this.resolveNameSymbol(nameSymbol, context); - - if (!nameSymbol && !lhsType.isPrimitive() && this.cachedObjectInterfaceType()) { - nameSymbol = this.getMemberSymbol(rhsName, TypeScript.PullElementKind.SomeValue, this.cachedObjectInterfaceType()); - } - - if (!nameSymbol) { - return SymbolAndDiagnostics.create(this.getNewErrorTypeSymbol(null, rhsName), [context.postError(this.unitPath, dottedNameAST.operand2.minChar, dottedNameAST.operand2.getLength(), 163 /* The_property__0__does_not_exist_on_value_of_type__1__ */, [(dottedNameAST.operand2).actualText, lhsType.getDisplayName()])]); - } - } - - return SymbolAndDiagnostics.fromSymbol(nameSymbol); - }; - - PullTypeResolver.prototype.resolveTypeNameExpression = function (nameAST, enclosingDecl, context) { - var typeNameSymbolAndDiagnostics = this.getSymbolAndDiagnosticsForAST(nameAST); - - if (!typeNameSymbolAndDiagnostics || !typeNameSymbolAndDiagnostics.symbol.isType()) { - typeNameSymbolAndDiagnostics = this.computeTypeNameExpression(nameAST, enclosingDecl, context); - this.setSymbolAndDiagnosticsForAST(nameAST, typeNameSymbolAndDiagnostics, context); - } - - var typeNameSymbol = typeNameSymbolAndDiagnostics && typeNameSymbolAndDiagnostics.symbol; - if (!typeNameSymbol.isResolved()) { - var savedResolvingNamespaceMemberAccess = context.resolvingNamespaceMemberAccess; - context.resolvingNamespaceMemberAccess = false; - this.resolveDeclaredSymbol(typeNameSymbol, enclosingDecl, context); - context.resolvingNamespaceMemberAccess = savedResolvingNamespaceMemberAccess; - } - - if (typeNameSymbol && !(typeNameSymbol.isTypeParameter() && (typeNameSymbol).isFunctionTypeParameter() && context.isSpecializingSignatureAtCallSite && !context.isSpecializingConstructorMethod)) { - var substitution = context.findSpecializationForType(typeNameSymbol); - - if (typeNameSymbol.isTypeParameter() && (substitution != typeNameSymbol)) { - if (TypeScript.shouldSpecializeTypeParameterForTypeParameter(substitution, typeNameSymbol)) { - typeNameSymbol = substitution; - } - } - - if (typeNameSymbol != typeNameSymbolAndDiagnostics.symbol) { - return SymbolAndDiagnostics.fromSymbol(typeNameSymbol); - } - } - - return typeNameSymbolAndDiagnostics; - }; - - PullTypeResolver.prototype.computeTypeNameExpression = function (nameAST, enclosingDecl, context) { - if (nameAST.isMissing()) { - return SymbolAndDiagnostics.fromSymbol(this.semanticInfoChain.anyTypeSymbol); - } - - var id = nameAST.text; - - if (id === "any") { - return SymbolAndDiagnostics.fromSymbol(this.semanticInfoChain.anyTypeSymbol); - } else if (id === "string") { - return SymbolAndDiagnostics.fromSymbol(this.semanticInfoChain.stringTypeSymbol); - } else if (id === "number") { - return SymbolAndDiagnostics.fromSymbol(this.semanticInfoChain.numberTypeSymbol); - } else if (id === "bool") { - if (this.compilationSettings.disallowBool && !this.currentUnit.getProperties().unitContainsBool) { - this.currentUnit.getProperties().unitContainsBool = true; - return SymbolAndDiagnostics.create(this.semanticInfoChain.booleanTypeSymbol, [context.postError(this.unitPath, nameAST.minChar, nameAST.getLength(), 167 /* Use_of_deprecated__bool__type__Use__boolean__instead */)]); - } else { - return SymbolAndDiagnostics.fromSymbol(this.semanticInfoChain.booleanTypeSymbol); - } - } else if (id === "boolean") { - return SymbolAndDiagnostics.fromSymbol(this.semanticInfoChain.booleanTypeSymbol); - } else if (id === "void") { - return SymbolAndDiagnostics.fromSymbol(this.semanticInfoChain.voidTypeSymbol); - } else { - var declPath = enclosingDecl !== null ? TypeScript.getPathToDecl(enclosingDecl) : []; - - if (enclosingDecl && !declPath.length) { - declPath = [enclosingDecl]; - } - - var kindToCheckFirst = context.resolvingNamespaceMemberAccess ? TypeScript.PullElementKind.SomeContainer : TypeScript.PullElementKind.SomeType; - var kindToCheckSecond = context.resolvingNamespaceMemberAccess ? TypeScript.PullElementKind.SomeType : TypeScript.PullElementKind.SomeContainer; - - var typeNameSymbol = this.getSymbolFromDeclPath(id, declPath, kindToCheckFirst); - - if (!typeNameSymbol) { - typeNameSymbol = this.getSymbolFromDeclPath(id, declPath, kindToCheckSecond); - } - - if (!typeNameSymbol) { - return SymbolAndDiagnostics.create(this.getNewErrorTypeSymbol(null, id), [context.postError(this.unitPath, nameAST.minChar, nameAST.getLength(), 164 /* Could_not_find_symbol__0_ */, [nameAST.actualText])]); - } - - if (typeNameSymbol.isAlias()) { - if (!typeNameSymbol.isResolved()) { - var savedResolvingNamespaceMemberAccess = context.resolvingNamespaceMemberAccess; - context.resolvingNamespaceMemberAccess = false; - this.resolveDeclaredSymbol(typeNameSymbol, enclosingDecl, context); - context.resolvingNamespaceMemberAccess = savedResolvingNamespaceMemberAccess; - } - - var aliasedType = (typeNameSymbol).getType(); - - if (aliasedType && !aliasedType.isResolved()) { - this.resolveDeclaredSymbol(aliasedType, enclosingDecl, context); - } - - var exportAssignmentSymbol = (typeNameSymbol).getExportAssignedTypeSymbol(); - - if (exportAssignmentSymbol) { - typeNameSymbol = exportAssignmentSymbol; - } - } - - if (typeNameSymbol.isTypeParameter()) { - if (enclosingDecl && (enclosingDecl.getKind() & TypeScript.PullElementKind.SomeFunction) && (enclosingDecl.getFlags() & 16 /* Static */)) { - var parentDecl = typeNameSymbol.getDeclarations()[0].getParentDecl(); - - if (parentDecl.getKind() == 8 /* Class */) { - return SymbolAndDiagnostics.create(this.getNewErrorTypeSymbol(null), [context.postError(this.unitPath, nameAST.minChar, nameAST.getLength(), 226 /* Static_methods_cannot_reference_class_type_parameters */)]); - } - } - } - } - - return SymbolAndDiagnostics.fromSymbol(typeNameSymbol); - }; - - PullTypeResolver.prototype.addDiagnostic = function (diagnostics, diagnostic) { - if (!diagnostics) { - diagnostics = []; - } - - diagnostics.push(diagnostic); - return diagnostics; - }; - - PullTypeResolver.prototype.resolveGenericTypeReference = function (genericTypeAST, enclosingDecl, context) { - var savedResolvingTypeReference = context.resolvingTypeReference; - context.resolvingTypeReference = true; - var genericTypeSymbol = this.resolveAST(genericTypeAST.name, false, enclosingDecl, context).symbol.getType(); - context.resolvingTypeReference = savedResolvingTypeReference; - - if (genericTypeSymbol.isError()) { - return SymbolAndDiagnostics.fromSymbol(genericTypeSymbol); - } - - if (!genericTypeSymbol.isResolving() && !genericTypeSymbol.isResolved()) { - this.resolveDeclaredSymbol(genericTypeSymbol, enclosingDecl, context); - } - - var typeArgs = []; - - if (!context.isResolvingTypeArguments(genericTypeAST)) { - context.startResolvingTypeArguments(genericTypeAST); - - if (genericTypeAST.typeArguments && genericTypeAST.typeArguments.members.length) { - for (var i = 0; i < genericTypeAST.typeArguments.members.length; i++) { - var typeArg = this.resolveTypeReference(genericTypeAST.typeArguments.members[i], enclosingDecl, context).symbol; - - if (typeArg.isNamedTypeSymbol() && typeArg.isGeneric() && !typeArg.isTypeParameter() && typeArg.isResolved() && !typeArg.getIsSpecialized() && typeArg.getTypeParameters().length && (typeArg.getTypeArguments() == null && !this.isArrayOrEquivalent(typeArg)) && this.isTypeRefWithoutTypeArgs(genericTypeAST.typeArguments.members[i])) { - context.postError(this.unitPath, genericTypeAST.typeArguments.members[i].minChar, genericTypeAST.typeArguments.members[i].getLength(), 239 /* Generic_type_references_must_include_all_type_arguments */, null, enclosingDecl, true); - typeArg = this.specializeTypeToAny(typeArg, enclosingDecl, context); - } - - typeArgs[i] = context.findSpecializationForType(typeArg); - } - } - - context.doneResolvingTypeArguments(); - } - - var typeParameters = genericTypeSymbol.getTypeParameters(); - - if (typeArgs.length && typeArgs.length != typeParameters.length) { - return SymbolAndDiagnostics.create(this.getNewErrorTypeSymbol(null), [context.postError(this.unitPath, genericTypeAST.minChar, genericTypeAST.getLength(), 159 /* Generic_type__0__requires_1_type_argument_s_ */, [genericTypeSymbol.toString(), genericTypeSymbol.getTypeParameters().length])]); - } - - var specializedSymbol = TypeScript.specializeType(genericTypeSymbol, typeArgs, this, enclosingDecl, context, genericTypeAST); - - var typeConstraint = null; - var upperBound = null; - var diagnostics = null; - - for (var iArg = 0; (iArg < typeArgs.length) && (iArg < typeParameters.length); iArg++) { - typeArg = typeArgs[iArg]; - typeConstraint = typeParameters[iArg].getConstraint(); - - if (typeConstraint) { - if (typeConstraint.isTypeParameter()) { - for (var j = 0; j < typeParameters.length && j < typeArgs.length; j++) { - if (typeParameters[j] == typeConstraint) { - typeConstraint = typeArgs[j]; - } - } - } - - if (typeArg.isTypeParameter()) { - upperBound = (typeArg).getConstraint(); - - if (upperBound) { - typeArg = upperBound; - } - } - - if (typeArg.isResolving()) { - return SymbolAndDiagnostics.fromSymbol(specializedSymbol); - } - if (!this.sourceIsAssignableToTarget(typeArg, typeConstraint, context)) { - diagnostics = this.addDiagnostic(diagnostics, context.postError(this.unitPath, genericTypeAST.minChar, genericTypeAST.getLength(), 155 /* Type__0__does_not_satisfy_the_constraint__1__for_type_parameter__2_ */, [typeArg.toString(true), typeConstraint.toString(true), typeParameters[iArg].toString(true)])); - } - } - } - - return SymbolAndDiagnostics.create(specializedSymbol, diagnostics); - }; - - PullTypeResolver.prototype.resolveDottedTypeNameExpression = function (dottedNameAST, enclosingDecl, context) { - var symbolAndDiagnostics = this.getSymbolAndDiagnosticsForAST(dottedNameAST); - if (!symbolAndDiagnostics) { - symbolAndDiagnostics = this.computeDottedTypeNameExpression(dottedNameAST, enclosingDecl, context); - this.setSymbolAndDiagnosticsForAST(dottedNameAST, symbolAndDiagnostics, context); - } - - var symbol = symbolAndDiagnostics.symbol; - if (!symbol.isResolved()) { - this.resolveDeclaredSymbol(symbol, enclosingDecl, context); - } - - return symbolAndDiagnostics; - }; - - PullTypeResolver.prototype.computeDottedTypeNameExpression = function (dottedNameAST, enclosingDecl, context) { - if ((dottedNameAST.operand2).isMissing()) { - return SymbolAndDiagnostics.fromSymbol(this.semanticInfoChain.anyTypeSymbol); - } - - var rhsName = (dottedNameAST.operand2).text; - - var savedResolvingTypeReference = context.resolvingTypeReference; - var savedResolvingNamespaceMemberAccess = context.resolvingNamespaceMemberAccess; - context.resolvingNamespaceMemberAccess = true; - context.resolvingTypeReference = true; - var lhs = this.resolveAST(dottedNameAST.operand1, false, enclosingDecl, context).symbol; - context.resolvingTypeReference = savedResolvingTypeReference; - context.resolvingNamespaceMemberAccess = savedResolvingNamespaceMemberAccess; - - var lhsType = lhs.getType(); - - if (context.isResolvingClassExtendedType) { - if (lhs.isAlias()) { - (lhs).setIsUsedAsValue(); - } - } - - if (this.isAnyOrEquivalent(lhsType)) { - return SymbolAndDiagnostics.fromSymbol(lhsType); - } - - if (!lhsType) { - return SymbolAndDiagnostics.create(this.getNewErrorTypeSymbol(null), [context.postError(this.unitPath, dottedNameAST.operand2.minChar, dottedNameAST.operand2.getLength(), 162 /* Could_not_find_enclosing_symbol_for_dotted_name__0_ */, [(dottedNameAST.operand2).actualText])]); - } - - var childTypeSymbol = this.getMemberSymbol(rhsName, TypeScript.PullElementKind.SomeType, lhsType); - - if (!childTypeSymbol && lhsType.isContainer()) { - var exportedContainer = (lhsType).getExportAssignedContainerSymbol(); - - if (exportedContainer) { - childTypeSymbol = this.getMemberSymbol(rhsName, TypeScript.PullElementKind.SomeType, exportedContainer); - } - } - - if (!childTypeSymbol && enclosingDecl) { - var parentDecl = enclosingDecl; - - while (parentDecl) { - if (parentDecl.getKind() & TypeScript.PullElementKind.SomeContainer) { - break; - } - - parentDecl = parentDecl.getParentDecl(); - } - - if (parentDecl) { - var enclosingSymbolType = parentDecl.getSymbol().getType(); - - if (enclosingSymbolType === lhsType) { - childTypeSymbol = this.getMemberSymbol(rhsName, TypeScript.PullElementKind.SomeType, lhsType); - } - } - } - - if (!childTypeSymbol) { - return SymbolAndDiagnostics.create(this.getNewErrorTypeSymbol(null, rhsName), [context.postError(this.unitPath, dottedNameAST.operand2.minChar, dottedNameAST.operand2.getLength(), 163 /* The_property__0__does_not_exist_on_value_of_type__1__ */, [(dottedNameAST.operand2).actualText, lhsType.getName()])]); - } - - return SymbolAndDiagnostics.fromSymbol(childTypeSymbol); - }; - - PullTypeResolver.prototype.resolveFunctionExpression = function (funcDeclAST, inContextuallyTypedAssignment, enclosingDecl, context) { - var funcDeclSymbol = null; - var functionDecl = this.getDeclForAST(funcDeclAST); - - if (functionDecl && functionDecl.hasSymbol()) { - funcDeclSymbol = functionDecl.getSymbol(); - if (funcDeclSymbol.isResolved()) { - return funcDeclSymbol; - } - } - - var shouldContextuallyType = inContextuallyTypedAssignment; - - var assigningFunctionTypeSymbol = null; - var assigningFunctionSignature = null; - - if (funcDeclAST.returnTypeAnnotation) { - shouldContextuallyType = false; - } - - if (shouldContextuallyType && funcDeclAST.arguments) { - for (var i = 0; i < funcDeclAST.arguments.members.length; i++) { - if ((funcDeclAST.arguments.members[i]).typeExpr) { - shouldContextuallyType = false; - break; - } - } - } - - if (shouldContextuallyType) { - assigningFunctionTypeSymbol = context.getContextualType(); - - if (assigningFunctionTypeSymbol) { - this.resolveDeclaredSymbol(assigningFunctionTypeSymbol, enclosingDecl, context); - - if (assigningFunctionTypeSymbol) { - assigningFunctionSignature = assigningFunctionTypeSymbol.getCallSignatures()[0]; - } - } - } - - var semanticInfo = this.semanticInfoChain.getUnit(this.unitPath); - var declCollectionContext = new TypeScript.DeclCollectionContext(semanticInfo); - - declCollectionContext.scriptName = this.unitPath; - - if (enclosingDecl) { - declCollectionContext.pushParent(enclosingDecl); - } - - TypeScript.getAstWalkerFactory().walk(funcDeclAST, TypeScript.preCollectDecls, TypeScript.postCollectDecls, null, declCollectionContext); - - var functionDecl = this.getDeclForAST(funcDeclAST); - this.currentUnit.addSynthesizedDecl(functionDecl); - - var binder = new TypeScript.PullSymbolBinder(this.semanticInfoChain); - binder.setUnit(this.unitPath); - binder.bindFunctionExpressionToPullSymbol(functionDecl); - - funcDeclSymbol = functionDecl.getSymbol(); - - var signature = funcDeclSymbol.getType().getCallSignatures()[0]; - - if (funcDeclAST.arguments) { - var contextParams = []; - var contextParam = null; - - if (assigningFunctionSignature) { - contextParams = assigningFunctionSignature.getParameters(); - } - - for (var i = 0; i < funcDeclAST.arguments.members.length; i++) { - if ((i < contextParams.length) && !contextParams[i].getIsVarArg()) { - contextParam = contextParams[i]; - } else if (contextParams.length && contextParams[contextParams.length - 1].getIsVarArg()) { - contextParam = (contextParams[contextParams.length - 1].getType()).getElementType(); - } - - this.resolveFunctionExpressionParameter(funcDeclAST.arguments.members[i], contextParam, functionDecl, context); - } - } - - if (funcDeclAST.returnTypeAnnotation) { - var returnTypeSymbol = this.resolveTypeReference(funcDeclAST.returnTypeAnnotation, functionDecl, context).symbol; - - signature.setReturnType(returnTypeSymbol); - } else { - if (assigningFunctionSignature) { - var returnType = assigningFunctionSignature.getReturnType(); - - if (returnType) { - context.pushContextualType(returnType, context.inProvisionalResolution(), null); - - this.resolveFunctionBodyReturnTypes(funcDeclAST, signature, true, functionDecl, context); - context.popContextualType(); - } else { - signature.setReturnType(this.semanticInfoChain.anyTypeSymbol); - } - } else { - this.resolveFunctionBodyReturnTypes(funcDeclAST, signature, false, functionDecl, context); - } - } - - if (assigningFunctionTypeSymbol) { - funcDeclSymbol.addOutgoingLink(assigningFunctionTypeSymbol, 1 /* ContextuallyTypedAs */); - } - - funcDeclSymbol.setResolved(); - - return funcDeclSymbol; - }; - - PullTypeResolver.prototype.resolveThisExpression = function (ast, enclosingDecl, context) { - var symbolAndDiagnostics = this.getSymbolAndDiagnosticsForAST(ast); - - if (!symbolAndDiagnostics) { - symbolAndDiagnostics = this.computeThisExpressionSymbol(ast, enclosingDecl, context); - this.setSymbolAndDiagnosticsForAST(ast, symbolAndDiagnostics, context); - } - - return symbolAndDiagnostics; - }; - - PullTypeResolver.prototype.computeThisExpressionSymbol = function (ast, enclosingDecl, context) { - if (enclosingDecl) { - var enclosingDeclKind = enclosingDecl.getKind(); - var diagnostics; - - if (enclosingDeclKind === 4 /* Container */) { - return SymbolAndDiagnostics.create(this.getNewErrorTypeSymbol(null), [context.postError(this.currentUnit.getPath(), ast.minChar, ast.getLength(), 176 /* _this__cannot_be_referenced_within_module_bodies */)]); - } else if (!(enclosingDeclKind & (TypeScript.PullElementKind.SomeFunction | 1 /* Script */ | TypeScript.PullElementKind.SomeBlock))) { - return SymbolAndDiagnostics.create(this.getNewErrorTypeSymbol(null), [context.postError(this.currentUnit.getPath(), ast.minChar, ast.getLength(), 177 /* _this__must_only_be_used_inside_a_function_or_script_context */)]); - } else { - var declPath = TypeScript.getPathToDecl(enclosingDecl); - - if (declPath.length) { - for (var i = declPath.length - 1; i >= 0; i--) { - var decl = declPath[i]; - var declKind = decl.getKind(); - var declFlags = decl.getFlags(); - - if (declFlags & 16 /* Static */) { - break; - } else if (declKind === 131072 /* FunctionExpression */ && !TypeScript.hasFlag(declFlags, 8192 /* FatArrow */)) { - break; - } else if (declKind === 16384 /* Function */) { - break; - } else if (declKind === 8 /* Class */) { - var classSymbol = decl.getSymbol(); - return SymbolAndDiagnostics.fromSymbol(classSymbol); - } - } - } - } - } - - return SymbolAndDiagnostics.fromSymbol(this.semanticInfoChain.anyTypeSymbol); - }; - - PullTypeResolver.prototype.resolveSuperExpression = function (ast, enclosingDecl, context) { - if (!enclosingDecl) { - return SymbolAndDiagnostics.fromSymbol(this.semanticInfoChain.anyTypeSymbol); - } - - var declPath = enclosingDecl !== null ? TypeScript.getPathToDecl(enclosingDecl) : []; - var classSymbol = null; - - if (declPath.length) { - for (var i = declPath.length - 1; i >= 0; i--) { - var decl = declPath[i]; - var declFlags = decl.getFlags(); - - if (decl.getKind() === 131072 /* FunctionExpression */ && !(declFlags & 8192 /* FatArrow */)) { - break; - } else if (declFlags & 16 /* Static */) { - break; - } else if (decl.getKind() === 8 /* Class */) { - classSymbol = decl.getSymbol(); - - break; - } - } - } - - if (classSymbol) { - if (!classSymbol.isResolved()) { - this.resolveDeclaredSymbol(classSymbol, enclosingDecl, context); - } - - var parents = classSymbol.getExtendedTypes(); - - if (parents.length) { - return SymbolAndDiagnostics.fromSymbol(parents[0]); - } - } - - return SymbolAndDiagnostics.fromSymbol(this.semanticInfoChain.anyTypeSymbol); - }; - - PullTypeResolver.prototype.resolveObjectLiteralExpression = function (expressionAST, inContextuallyTypedAssignment, enclosingDecl, context, additionalResults) { - var symbolAndDiagnostics = this.getSymbolAndDiagnosticsForAST(expressionAST); - - if (!symbolAndDiagnostics || additionalResults) { - symbolAndDiagnostics = this.computeObjectLiteralExpression(expressionAST, inContextuallyTypedAssignment, enclosingDecl, context, additionalResults); - this.setSymbolAndDiagnosticsForAST(expressionAST, symbolAndDiagnostics, context); - } - - return symbolAndDiagnostics; - }; - - PullTypeResolver.prototype.computeObjectLiteralExpression = function (expressionAST, inContextuallyTypedAssignment, enclosingDecl, context, additionalResults) { - var objectLitAST = expressionAST; - var span = TypeScript.TextSpan.fromBounds(objectLitAST.minChar, objectLitAST.limChar); - - var objectLitDecl = new TypeScript.PullDecl("", "", 512 /* ObjectLiteral */, 0 /* None */, span, this.unitPath); - this.currentUnit.addSynthesizedDecl(objectLitDecl); - - if (enclosingDecl) { - objectLitDecl.setParentDecl(enclosingDecl); - } - - this.currentUnit.setDeclForAST(objectLitAST, objectLitDecl); - this.currentUnit.setASTForDecl(objectLitDecl, objectLitAST); - - var typeSymbol = new TypeScript.PullTypeSymbol("", 16 /* Interface */); - typeSymbol.addDeclaration(objectLitDecl); - objectLitDecl.setSymbol(typeSymbol); - - var memberDecls = objectLitAST.operand; - - var contextualType = null; - - if (inContextuallyTypedAssignment) { - contextualType = context.getContextualType(); - - this.resolveDeclaredSymbol(contextualType, enclosingDecl, context); - } - - if (memberDecls) { - var binex; - var memberSymbol; - var assigningSymbol = null; - var acceptedContextualType = false; - - if (additionalResults) { - additionalResults.membersContextTypeSymbols = []; - } - - for (var i = 0, len = memberDecls.members.length; i < len; i++) { - binex = memberDecls.members[i]; - - var id = binex.operand1; - var text; - var actualText; - - if (id.nodeType === 20 /* Name */) { - actualText = (id).actualText; - text = (id).text; - } else if (id.nodeType === 5 /* StringLiteral */) { - actualText = (id).actualText; - text = (id).text; - } else { - return SymbolAndDiagnostics.fromSymbol(this.semanticInfoChain.anyTypeSymbol); - } - - span = TypeScript.TextSpan.fromBounds(binex.minChar, binex.limChar); - - var decl = new TypeScript.PullDecl(text, actualText, 4096 /* Property */, 4 /* Public */, span, this.unitPath); - this.currentUnit.addSynthesizedDecl(decl); - - objectLitDecl.addChildDecl(decl); - decl.setParentDecl(objectLitDecl); - - this.semanticInfoChain.getUnit(this.unitPath).setDeclForAST(binex, decl); - this.semanticInfoChain.getUnit(this.unitPath).setASTForDecl(decl, binex); - - memberSymbol = new TypeScript.PullSymbol(text, 4096 /* Property */); - - memberSymbol.addDeclaration(decl); - decl.setSymbol(memberSymbol); - - if (contextualType) { - assigningSymbol = this.getMemberSymbol(text, TypeScript.PullElementKind.SomeValue, contextualType); - - if (assigningSymbol) { - this.resolveDeclaredSymbol(assigningSymbol, enclosingDecl, context); - - context.pushContextualType(assigningSymbol.getType(), context.inProvisionalResolution(), null); - - acceptedContextualType = true; - - if (additionalResults) { - additionalResults.membersContextTypeSymbols[i] = assigningSymbol.getType(); - } - } - } - - if (binex.operand2.nodeType === 12 /* FunctionDeclaration */) { - var funcDeclAST = binex.operand2; - - if (funcDeclAST.isAccessor()) { - var semanticInfo = this.semanticInfoChain.getUnit(this.unitPath); - var declCollectionContext = new TypeScript.DeclCollectionContext(semanticInfo); - - declCollectionContext.scriptName = this.unitPath; - - declCollectionContext.pushParent(objectLitDecl); - - TypeScript.getAstWalkerFactory().walk(funcDeclAST, TypeScript.preCollectDecls, TypeScript.postCollectDecls, null, declCollectionContext); - - var functionDecl = this.getDeclForAST(funcDeclAST); - this.currentUnit.addSynthesizedDecl(functionDecl); - - var binder = new TypeScript.PullSymbolBinder(this.semanticInfoChain); - binder.setUnit(this.unitPath); - - if (funcDeclAST.isGetAccessor()) { - binder.bindGetAccessorDeclarationToPullSymbol(functionDecl); - } else { - binder.bindSetAccessorDeclarationToPullSymbol(functionDecl); - } - } - } - - var memberExprType = this.resolveAST(binex.operand2, assigningSymbol != null, enclosingDecl, context).symbol; - - if (acceptedContextualType) { - context.popContextualType(); - acceptedContextualType = false; - } - - context.setTypeInContext(memberSymbol, memberExprType.getType()); - - memberSymbol.setResolved(); - - this.setSymbolAndDiagnosticsForAST(binex.operand1, SymbolAndDiagnostics.fromSymbol(memberSymbol), context); - - typeSymbol.addMember(memberSymbol, 5 /* PublicMember */); - } - } - - typeSymbol.setResolved(); - return SymbolAndDiagnostics.fromSymbol(typeSymbol); - }; - - PullTypeResolver.prototype.resolveArrayLiteralExpression = function (arrayLit, inContextuallyTypedAssignment, enclosingDecl, context) { - var symbolAndDiagnostics = this.getSymbolAndDiagnosticsForAST(arrayLit); - if (!symbolAndDiagnostics) { - symbolAndDiagnostics = this.computeArrayLiteralExpressionSymbol(arrayLit, inContextuallyTypedAssignment, enclosingDecl, context); - this.setSymbolAndDiagnosticsForAST(arrayLit, symbolAndDiagnostics, context); - } - - return symbolAndDiagnostics; - }; - - PullTypeResolver.prototype.computeArrayLiteralExpressionSymbol = function (arrayLit, inContextuallyTypedAssignment, enclosingDecl, context) { - var elements = arrayLit.operand; - var elementType = this.semanticInfoChain.anyTypeSymbol; - var elementTypes = []; - var comparisonInfo = new TypeScript.TypeComparisonInfo(); - var contextualElementType = null; - comparisonInfo.onlyCaptureFirstError = true; - - if (inContextuallyTypedAssignment) { - var contextualType = context.getContextualType(); - - this.resolveDeclaredSymbol(contextualType, enclosingDecl, context); - - if (contextualType && contextualType.isArray()) { - contextualElementType = contextualType.getElementType(); - } - } - - if (elements) { - if (inContextuallyTypedAssignment) { - context.pushContextualType(contextualElementType, context.inProvisionalResolution(), null); - } - - for (var i = 0; i < elements.members.length; i++) { - elementTypes[elementTypes.length] = this.resolveAST(elements.members[i], inContextuallyTypedAssignment, enclosingDecl, context).symbol.getType(); - } - - if (inContextuallyTypedAssignment) { - context.popContextualType(); - } - } - - if (contextualElementType && !contextualElementType.isTypeParameter()) { - elementType = contextualElementType; - - for (var i = 0; i < elementTypes.length; i++) { - var comparisonInfo = new TypeScript.TypeComparisonInfo(); - var currentElementType = elementTypes[i]; - var currentElementAST = elements.members[i]; - if (!this.sourceIsAssignableToTarget(currentElementType, contextualElementType, context, comparisonInfo)) { - var message; - if (comparisonInfo.message) { - message = context.postError(this.getUnitPath(), currentElementAST.minChar, currentElementAST.getLength(), 81 /* Cannot_convert__0__to__1__NL__2 */, [currentElementType.toString(), contextualElementType.toString(), comparisonInfo.message]); - } else { - message = context.postError(this.getUnitPath(), currentElementAST.minChar, currentElementAST.getLength(), 80 /* Cannot_convert__0__to__1_ */, [currentElementType.toString(), contextualElementType.toString()]); - } - - return SymbolAndDiagnostics.create(this.getNewErrorTypeSymbol(null), [message]); - } - } - } else { - if (elementTypes.length) { - elementType = elementTypes[0]; - } else if (contextualElementType) { - elementType = contextualElementType; - } - - var collection = { - getLength: function () { - return elements.members.length; - }, - setTypeAtIndex: function (index, type) { - elementTypes[index] = type; - }, - getTypeAtIndex: function (index) { - return elementTypes[index]; - } - }; - - elementType = this.findBestCommonType(elementType, null, collection, context, comparisonInfo); - - if (elementType === this.semanticInfoChain.undefinedTypeSymbol || elementType === this.semanticInfoChain.nullTypeSymbol) { - elementType = this.semanticInfoChain.anyTypeSymbol; - } - - if (!elementType) { - elementType = this.semanticInfoChain.anyTypeSymbol; - } else if (contextualType && !contextualType.isTypeParameter()) { - if (this.sourceIsAssignableToTarget(elementType, contextualType, context)) { - elementType = contextualType; - } - } - } - - var arraySymbol = elementType.getArrayType(); - - if (!arraySymbol) { - if (!this.cachedArrayInterfaceType().isResolved()) { - this.resolveDeclaredSymbol(this.cachedArrayInterfaceType(), enclosingDecl, context); - } - - arraySymbol = TypeScript.specializeToArrayType(this.semanticInfoChain.elementTypeSymbol, elementType, this, context); - - if (!arraySymbol) { - arraySymbol = this.semanticInfoChain.anyTypeSymbol; - } - } - - return SymbolAndDiagnostics.fromSymbol(arraySymbol); - }; - - PullTypeResolver.prototype.resolveIndexExpression = function (callEx, inContextuallyTypedAssignment, enclosingDecl, context) { - var symbolAndDiagnostics = this.getSymbolAndDiagnosticsForAST(callEx); - if (!symbolAndDiagnostics) { - symbolAndDiagnostics = this.computeIndexExpressionSymbol(callEx, inContextuallyTypedAssignment, enclosingDecl, context); - this.setSymbolAndDiagnosticsForAST(callEx, symbolAndDiagnostics, context); - } - - return symbolAndDiagnostics; - }; - - PullTypeResolver.prototype.computeIndexExpressionSymbol = function (callEx, inContextuallyTypedAssignment, enclosingDecl, context) { - var targetSymbol = this.resolveAST(callEx.operand1, inContextuallyTypedAssignment, enclosingDecl, context).symbol; - - var targetTypeSymbol = targetSymbol.getType(); - - if (this.isAnyOrEquivalent(targetTypeSymbol)) { - return SymbolAndDiagnostics.fromSymbol(targetTypeSymbol); - } - - var elementType = targetTypeSymbol.getElementType(); - - var indexType = this.resolveAST(callEx.operand2, inContextuallyTypedAssignment, enclosingDecl, context).symbol.getType(); - - var isNumberIndex = indexType === this.semanticInfoChain.numberTypeSymbol || TypeScript.PullHelpers.symbolIsEnum(indexType); - - if (elementType && isNumberIndex) { - return SymbolAndDiagnostics.fromSymbol(elementType); - } - - if (callEx.operand2.nodeType === 5 /* StringLiteral */ || callEx.operand2.nodeType === 7 /* NumericLiteral */) { - var memberName = callEx.operand2.nodeType === 5 /* StringLiteral */ ? TypeScript.stripQuotes((callEx.operand2).actualText) : TypeScript.quoteStr((callEx.operand2).value.toString()); - - var member = this.getMemberSymbol(memberName, TypeScript.PullElementKind.SomeValue, targetTypeSymbol); - - if (member) { - return SymbolAndDiagnostics.fromSymbol(member.getType()); - } - } - - var signatures = targetTypeSymbol.getIndexSignatures(); - - var stringSignature = null; - var numberSignature = null; - var signature = null; - var paramSymbols; - var paramType; - - for (var i = 0; i < signatures.length; i++) { - if (stringSignature && numberSignature) { - break; - } - - signature = signatures[i]; - - paramSymbols = signature.getParameters(); - - if (paramSymbols.length) { - paramType = paramSymbols[0].getType(); - - if (paramType === this.semanticInfoChain.stringTypeSymbol) { - stringSignature = signatures[i]; - continue; - } else if (paramType === this.semanticInfoChain.numberTypeSymbol || paramType.getKind() === 64 /* Enum */) { - numberSignature = signatures[i]; - continue; - } - } - } - - if (numberSignature && (isNumberIndex || indexType === this.semanticInfoChain.anyTypeSymbol)) { - var returnType = numberSignature.getReturnType(); - - if (!returnType) { - returnType = this.semanticInfoChain.anyTypeSymbol; - } - - return SymbolAndDiagnostics.fromSymbol(returnType); - } else if (stringSignature && (isNumberIndex || indexType === this.semanticInfoChain.anyTypeSymbol || indexType === this.semanticInfoChain.stringTypeSymbol)) { - var returnType = stringSignature.getReturnType(); - - if (!returnType) { - returnType = this.semanticInfoChain.anyTypeSymbol; - } - - return SymbolAndDiagnostics.fromSymbol(returnType); - } else if (isNumberIndex || indexType === this.semanticInfoChain.anyTypeSymbol || indexType === this.semanticInfoChain.stringTypeSymbol) { - var returnType = this.semanticInfoChain.anyTypeSymbol; - return SymbolAndDiagnostics.fromSymbol(returnType); - } else { - return SymbolAndDiagnostics.create(this.getNewErrorTypeSymbol(null), [context.postError(this.getUnitPath(), callEx.minChar, callEx.getLength(), 77 /* Value_of_type__0__is_not_indexable_by_type__1_ */, [targetTypeSymbol.toString(false), indexType.toString(false)])]); - } - }; - - PullTypeResolver.prototype.resolveBitwiseOperator = function (expressionAST, inContextuallyTypedAssignment, enclosingDecl, context) { - var binex = expressionAST; - - var leftType = this.resolveAST(binex.operand1, inContextuallyTypedAssignment, enclosingDecl, context).symbol.getType(); - var rightType = this.resolveAST(binex.operand2, inContextuallyTypedAssignment, enclosingDecl, context).symbol.getType(); - - if (this.sourceIsSubtypeOfTarget(leftType, this.semanticInfoChain.numberTypeSymbol, context) && this.sourceIsSubtypeOfTarget(rightType, this.semanticInfoChain.numberTypeSymbol, context)) { - return this.semanticInfoChain.numberTypeSymbol; - } else if ((leftType === this.semanticInfoChain.booleanTypeSymbol) && (rightType === this.semanticInfoChain.booleanTypeSymbol)) { - return this.semanticInfoChain.booleanTypeSymbol; - } else if (this.isAnyOrEquivalent(leftType)) { - if ((this.isAnyOrEquivalent(rightType) || (rightType === this.semanticInfoChain.numberTypeSymbol) || (rightType === this.semanticInfoChain.booleanTypeSymbol))) { - return this.semanticInfoChain.anyTypeSymbol; - } - } else if (this.isAnyOrEquivalent(rightType)) { - if ((leftType === this.semanticInfoChain.numberTypeSymbol) || (leftType === this.semanticInfoChain.booleanTypeSymbol)) { - return this.semanticInfoChain.anyTypeSymbol; - } - } - - return this.semanticInfoChain.anyTypeSymbol; - }; - - PullTypeResolver.prototype.resolveArithmeticExpression = function (binex, inContextuallyTypedAssignment, enclosingDecl, context) { - var leftType = this.resolveAST(binex.operand1, inContextuallyTypedAssignment, enclosingDecl, context).symbol.getType(); - var rightType = this.resolveAST(binex.operand2, inContextuallyTypedAssignment, enclosingDecl, context).symbol.getType(); - - if (this.isNullOrUndefinedType(leftType)) { - leftType = rightType; - } - if (this.isNullOrUndefinedType(rightType)) { - rightType = leftType; - } - - leftType = this.widenType(leftType); - rightType = this.widenType(rightType); - - if (binex.nodeType === 64 /* AddExpression */ || binex.nodeType === 39 /* AddAssignmentExpression */) { - if (leftType === this.semanticInfoChain.stringTypeSymbol || rightType === this.semanticInfoChain.stringTypeSymbol) { - return SymbolAndDiagnostics.fromSymbol(this.semanticInfoChain.stringTypeSymbol); - } else if (leftType === this.semanticInfoChain.numberTypeSymbol && rightType === this.semanticInfoChain.numberTypeSymbol) { - return SymbolAndDiagnostics.fromSymbol(this.semanticInfoChain.numberTypeSymbol); - } else if (this.sourceIsSubtypeOfTarget(leftType, this.semanticInfoChain.numberTypeSymbol, context) && this.sourceIsSubtypeOfTarget(rightType, this.semanticInfoChain.numberTypeSymbol, context)) { - return SymbolAndDiagnostics.fromSymbol(this.semanticInfoChain.numberTypeSymbol); - } else { - return SymbolAndDiagnostics.fromSymbol(this.semanticInfoChain.anyTypeSymbol); - } - } else { - if (leftType === this.semanticInfoChain.numberTypeSymbol && rightType === this.semanticInfoChain.numberTypeSymbol) { - return SymbolAndDiagnostics.fromSymbol(this.semanticInfoChain.numberTypeSymbol); - } else if (this.sourceIsSubtypeOfTarget(leftType, this.semanticInfoChain.numberTypeSymbol, context) && this.sourceIsSubtypeOfTarget(rightType, this.semanticInfoChain.numberTypeSymbol, context)) { - return SymbolAndDiagnostics.fromSymbol(this.semanticInfoChain.numberTypeSymbol); - } else if (this.isAnyOrEquivalent(leftType) || this.isAnyOrEquivalent(rightType)) { - return SymbolAndDiagnostics.fromSymbol(this.semanticInfoChain.numberTypeSymbol); - } else { - return SymbolAndDiagnostics.fromSymbol(this.semanticInfoChain.anyTypeSymbol); - } - } - }; - - PullTypeResolver.prototype.resolveLogicalOrExpression = function (binex, inContextuallyTypedAssignment, enclosingDecl, context) { - var symbolAndDiagnostics = this.getSymbolAndDiagnosticsForAST(binex); - if (!symbolAndDiagnostics) { - symbolAndDiagnostics = this.computeLogicalOrExpressionSymbol(binex, inContextuallyTypedAssignment, enclosingDecl, context); - this.setSymbolAndDiagnosticsForAST(binex, symbolAndDiagnostics, context); - } - - return symbolAndDiagnostics; - }; - - PullTypeResolver.prototype.computeLogicalOrExpressionSymbol = function (binex, inContextuallyTypedAssignment, enclosingDecl, context) { - var leftType = this.resolveAST(binex.operand1, inContextuallyTypedAssignment, enclosingDecl, context).symbol.getType(); - var rightType = this.resolveAST(binex.operand2, inContextuallyTypedAssignment, enclosingDecl, context).symbol.getType(); - - if (this.isAnyOrEquivalent(leftType) || this.isAnyOrEquivalent(rightType)) { - return SymbolAndDiagnostics.fromSymbol(this.semanticInfoChain.anyTypeSymbol); - } else if (leftType === this.semanticInfoChain.booleanTypeSymbol) { - if (rightType === this.semanticInfoChain.booleanTypeSymbol) { - return SymbolAndDiagnostics.fromSymbol(this.semanticInfoChain.booleanTypeSymbol); - } else { - return SymbolAndDiagnostics.fromSymbol(this.semanticInfoChain.anyTypeSymbol); - } - } else if (leftType === this.semanticInfoChain.numberTypeSymbol) { - if (rightType === this.semanticInfoChain.numberTypeSymbol) { - return SymbolAndDiagnostics.fromSymbol(this.semanticInfoChain.numberTypeSymbol); - } else { - return SymbolAndDiagnostics.fromSymbol(this.semanticInfoChain.anyTypeSymbol); - } - } else if (leftType === this.semanticInfoChain.stringTypeSymbol) { - if (rightType === this.semanticInfoChain.stringTypeSymbol) { - return SymbolAndDiagnostics.fromSymbol(this.semanticInfoChain.stringTypeSymbol); - } else { - return SymbolAndDiagnostics.fromSymbol(this.semanticInfoChain.anyTypeSymbol); - } - } else if (this.sourceIsSubtypeOfTarget(leftType, rightType, context)) { - return SymbolAndDiagnostics.fromSymbol(rightType); - } else if (this.sourceIsSubtypeOfTarget(rightType, leftType, context)) { - return SymbolAndDiagnostics.fromSymbol(leftType); - } - - return SymbolAndDiagnostics.fromSymbol(this.semanticInfoChain.anyTypeSymbol); - }; - - PullTypeResolver.prototype.resolveLogicalAndExpression = function (binex, inContextuallyTypedAssignment, enclosingDecl, context) { - return SymbolAndDiagnostics.fromSymbol(this.resolveAST(binex.operand2, inContextuallyTypedAssignment, enclosingDecl, context).symbol.getType()); - }; - - PullTypeResolver.prototype.resolveConditionalExpression = function (trinex, enclosingDecl, context) { - var symbolAndDiagnostics = this.getSymbolAndDiagnosticsForAST(trinex); - if (!symbolAndDiagnostics) { - symbolAndDiagnostics = this.computeConditionalExpressionSymbol(trinex, enclosingDecl, context); - this.setSymbolAndDiagnosticsForAST(trinex, symbolAndDiagnostics, context); - } - - return symbolAndDiagnostics; - }; - - PullTypeResolver.prototype.computeConditionalExpressionSymbol = function (trinex, enclosingDecl, context) { - var leftType = this.resolveAST(trinex.operand2, false, enclosingDecl, context).symbol.getType(); - var rightType = this.resolveAST(trinex.operand3, false, enclosingDecl, context).symbol.getType(); - - var symbol = null; - if (this.typesAreIdentical(leftType, rightType)) { - symbol = leftType; - } else if (this.sourceIsSubtypeOfTarget(leftType, rightType, context) || this.sourceIsSubtypeOfTarget(rightType, leftType, context)) { - var collection = { - getLength: function () { - return 2; - }, - setTypeAtIndex: function (index, type) { - }, - getTypeAtIndex: function (index) { - return rightType; - } - }; - - var bestCommonType = this.findBestCommonType(leftType, null, collection, context); - - if (bestCommonType) { - symbol = bestCommonType; - } - } - - if (!symbol) { - return SymbolAndDiagnostics.create(this.getNewErrorTypeSymbol(null), [context.postError(this.getUnitPath(), trinex.minChar, trinex.getLength(), 160 /* Type_of_conditional_expression_cannot_be_determined__Best_common_type_could_not_be_found_between__0__and__1_ */, [leftType.toString(false), rightType.toString(false)])]); - } - - return SymbolAndDiagnostics.fromSymbol(symbol); - }; - - PullTypeResolver.prototype.resolveParenthesizedExpression = function (ast, enclosingDecl, context) { - return this.resolveAST(ast.expression, false, enclosingDecl, context).withoutDiagnostics(); - }; - - PullTypeResolver.prototype.resolveExpressionStatement = function (ast, inContextuallyTypedAssignment, enclosingDecl, context) { - return this.resolveAST(ast.expression, inContextuallyTypedAssignment, enclosingDecl, context).withoutDiagnostics(); - }; - - PullTypeResolver.prototype.resolveCallExpression = function (callEx, inContextuallyTypedAssignment, enclosingDecl, context, additionalResults) { - if (additionalResults) { - return this.computeCallExpressionSymbol(callEx, inContextuallyTypedAssignment, enclosingDecl, context, additionalResults); - } - - var symbolAndDiagnostics = this.getSymbolAndDiagnosticsForAST(callEx); - if (!symbolAndDiagnostics || !symbolAndDiagnostics.symbol.isResolved()) { - symbolAndDiagnostics = this.computeCallExpressionSymbol(callEx, inContextuallyTypedAssignment, enclosingDecl, context, null); - this.setSymbolAndDiagnosticsForAST(callEx, symbolAndDiagnostics, context); - } - - return symbolAndDiagnostics; - }; - - PullTypeResolver.prototype.computeCallExpressionSymbol = function (callEx, inContextuallyTypedAssignment, enclosingDecl, context, additionalResults) { - var targetSymbol = this.resolveAST(callEx.target, inContextuallyTypedAssignment, enclosingDecl, context).symbol; - var targetAST = this.getLastIdentifierInTarget(callEx); - - var targetTypeSymbol = targetSymbol.getType(); - if (this.isAnyOrEquivalent(targetTypeSymbol)) { - if (callEx.typeArguments) { - return SymbolAndDiagnostics.create(this.getNewErrorTypeSymbol(null), [context.postError(this.unitPath, targetAST.minChar, targetAST.getLength(), 223 /* Untyped_function_calls_may_not_accept_type_arguments */)]); - } - - return SymbolAndDiagnostics.fromSymbol(this.semanticInfoChain.anyTypeSymbol); - } - - var diagnostics = []; - var isSuperCall = false; - - if (callEx.target.nodeType === 30 /* SuperExpression */) { - isSuperCall = true; - - if (targetTypeSymbol.isClass()) { - targetSymbol = (targetTypeSymbol).getConstructorMethod(); - targetTypeSymbol = targetSymbol.getType(); - } else { - diagnostics = this.addDiagnostic(diagnostics, context.postError(this.unitPath, targetAST.minChar, targetAST.getLength(), 158 /* Calls_to__super__are_only_valid_inside_a_class */)); - return SymbolAndDiagnostics.create(this.getNewErrorTypeSymbol(null), diagnostics); - } - } - - var signatures = isSuperCall ? (targetTypeSymbol).getConstructSignatures() : (targetTypeSymbol).getCallSignatures(); - - if (!signatures.length && (targetTypeSymbol.getKind() == 33554432 /* ConstructorType */)) { - diagnostics = this.addDiagnostic(diagnostics, context.postError(this.unitPath, targetAST.minChar, targetAST.getLength(), 227 /* Value_of_type__0__is_not_callable__Did_you_mean_to_include__new___ */, [targetTypeSymbol.toString()])); - } - - var typeArgs = null; - var typeReplacementMap = null; - var couldNotFindGenericOverload = false; - var couldNotAssignToConstraint; - - if (callEx.typeArguments) { - typeArgs = []; - - if (callEx.typeArguments && callEx.typeArguments.members.length) { - for (var i = 0; i < callEx.typeArguments.members.length; i++) { - var typeArg = this.resolveTypeReference(callEx.typeArguments.members[i], enclosingDecl, context).symbol; - typeArgs[i] = context.findSpecializationForType(typeArg); - } - } - } else if (isSuperCall && targetTypeSymbol.isGeneric()) { - typeArgs = targetTypeSymbol.getTypeArguments(); - } - - if (targetTypeSymbol.isGeneric()) { - var resolvedSignatures = []; - var inferredTypeArgs; - var specializedSignature; - var typeParameters; - var typeConstraint = null; - var prevSpecializingToAny = context.specializingToAny; - var prevSpecializing = context.isSpecializingSignatureAtCallSite; - var beforeResolutionSignatures = signatures; - var triedToInferTypeArgs; - - for (var i = 0; i < signatures.length; i++) { - typeParameters = signatures[i].getTypeParameters(); - couldNotAssignToConstraint = false; - triedToInferTypeArgs = false; - - if (signatures[i].isGeneric() && typeParameters.length && !signatures[i].isFixed()) { - if (typeArgs) { - inferredTypeArgs = typeArgs; - } else if (callEx.arguments) { - inferredTypeArgs = this.inferArgumentTypesForSignature(signatures[i], callEx.arguments, new TypeScript.TypeComparisonInfo(), enclosingDecl, context); - triedToInferTypeArgs = true; - } - - if (inferredTypeArgs) { - typeReplacementMap = {}; - - if (inferredTypeArgs.length) { - if (inferredTypeArgs.length != typeParameters.length) { - continue; - } - - for (var j = 0; j < typeParameters.length; j++) { - typeReplacementMap[typeParameters[j].getSymbolID().toString()] = inferredTypeArgs[j]; - } - for (var j = 0; j < typeParameters.length; j++) { - typeConstraint = typeParameters[j].getConstraint(); - - if (typeConstraint) { - if (typeConstraint.isTypeParameter()) { - for (var k = 0; k < typeParameters.length && k < inferredTypeArgs.length; k++) { - if (typeParameters[k] == typeConstraint) { - typeConstraint = inferredTypeArgs[k]; - } - } - } - if (typeConstraint.isTypeParameter()) { - context.pushTypeSpecializationCache(typeReplacementMap); - typeConstraint = TypeScript.specializeType(typeConstraint, null, this, enclosingDecl, context); - context.popTypeSpecializationCache(); - } - context.isComparingSpecializedSignatures = true; - if (!this.sourceIsAssignableToTarget(inferredTypeArgs[j], typeConstraint, context)) { - diagnostics = this.addDiagnostic(diagnostics, context.postError(this.unitPath, targetAST.minChar, targetAST.getLength(), 155 /* Type__0__does_not_satisfy_the_constraint__1__for_type_parameter__2_ */, [inferredTypeArgs[j].toString(true), typeConstraint.toString(true), typeParameters[j].toString(true)])); - couldNotAssignToConstraint = true; - } - context.isComparingSpecializedSignatures = false; - - if (couldNotAssignToConstraint) { - break; - } - } - } - } else { - if (triedToInferTypeArgs) { - if (signatures[i].parametersAreFixed()) { - if (signatures[i].hasGenericParameter()) { - context.specializingToAny = true; - } else { - resolvedSignatures[resolvedSignatures.length] = signatures[i]; - } - } else { - continue; - } - } - - context.specializingToAny = true; - } - - if (couldNotAssignToConstraint) { - continue; - } - - context.isSpecializingSignatureAtCallSite = true; - specializedSignature = TypeScript.specializeSignature(signatures[i], false, typeReplacementMap, inferredTypeArgs, this, enclosingDecl, context); - - context.isSpecializingSignatureAtCallSite = prevSpecializing; - context.specializingToAny = prevSpecializingToAny; - - if (specializedSignature) { - resolvedSignatures[resolvedSignatures.length] = specializedSignature; - } - } - } else { - if (!(callEx.typeArguments && callEx.typeArguments.members.length)) { - resolvedSignatures[resolvedSignatures.length] = signatures[i]; - } - } - } - - if (signatures.length && !resolvedSignatures.length) { - couldNotFindGenericOverload = true; - } - - signatures = resolvedSignatures; - } - - var errorCondition = null; - - if (!signatures.length) { - if (additionalResults) { - additionalResults.targetSymbol = targetSymbol; - additionalResults.targetTypeSymbol = targetTypeSymbol; - additionalResults.resolvedSignatures = beforeResolutionSignatures; - additionalResults.candidateSignature = beforeResolutionSignatures && beforeResolutionSignatures.length ? beforeResolutionSignatures[0] : null; - - additionalResults.actualParametersContextTypeSymbols = actualParametersContextTypeSymbols; - } - - if (!couldNotFindGenericOverload) { - if (this.cachedFunctionInterfaceType() && this.sourceIsSubtypeOfTarget(targetTypeSymbol, this.cachedFunctionInterfaceType(), context)) { - return SymbolAndDiagnostics.create(this.semanticInfoChain.anyTypeSymbol, diagnostics); - } - - diagnostics = this.addDiagnostic(diagnostics, context.postError(this.unitPath, callEx.minChar, callEx.getLength(), 157 /* Unable_to_invoke_type_with_no_call_signatures */)); - errorCondition = this.getNewErrorTypeSymbol(null); - } else { - diagnostics = this.addDiagnostic(diagnostics, context.postError(this.unitPath, callEx.minChar, callEx.getLength(), 156 /* Could_not_select_overload_for__call__expression */)); - errorCondition = this.getNewErrorTypeSymbol(null); - } - - return SymbolAndDiagnostics.create(errorCondition, diagnostics); - } - - var signature = this.resolveOverloads(callEx, signatures, enclosingDecl, callEx.typeArguments != null, context, diagnostics); - var useBeforeResolutionSignatures = signature == null; - - if (!signature) { - diagnostics = this.addDiagnostic(diagnostics, context.postError(this.unitPath, targetAST.minChar, targetAST.getLength(), 156 /* Could_not_select_overload_for__call__expression */)); - - errorCondition = this.getNewErrorTypeSymbol(null); - - if (!signatures.length) { - return SymbolAndDiagnostics.create(errorCondition, diagnostics); - } - - signature = signatures[0]; - - if (callEx.arguments) { - for (var k = 0, n = callEx.arguments.members.length; k < n; k++) { - var arg = callEx.arguments.members[k]; - var argSymbolAndDiagnostics = this.getSymbolAndDiagnosticsForAST(arg); - var argSymbol = argSymbolAndDiagnostics && argSymbolAndDiagnostics.symbol; - - if (argSymbol) { - var argType = argSymbol.getType(); - if (arg.nodeType === 12 /* FunctionDeclaration */) { - if (!this.canApplyContextualTypeToFunction(argType, arg, true)) { - continue; - } - } - - argSymbol.invalidate(); - } - } - } - } - - if (!signature.isGeneric() && callEx.typeArguments) { - diagnostics = this.addDiagnostic(diagnostics, context.postError(this.unitPath, targetAST.minChar, targetAST.getLength(), 224 /* Non_generic_functions_may_not_accept_type_arguments */)); - } - - var returnType = signature.getReturnType(); - - var actualParametersContextTypeSymbols = []; - if (callEx.arguments) { - var len = callEx.arguments.members.length; - var params = signature.getParameters(); - var contextualType = null; - var signatureDecl = signature.getDeclarations()[0]; - - for (var i = 0; i < len; i++) { - if (params.length) { - if (i < params.length - 1 || (i < params.length && !signature.hasVariableParamList())) { - if (typeReplacementMap) { - context.pushTypeSpecializationCache(typeReplacementMap); - } - this.resolveDeclaredSymbol(params[i], signatureDecl, context); - if (typeReplacementMap) { - context.popTypeSpecializationCache(); - } - contextualType = params[i].getType(); - } else if (signature.hasVariableParamList()) { - contextualType = params[params.length - 1].getType(); - if (contextualType.isArray()) { - contextualType = contextualType.getElementType(); - } - } - } - - if (contextualType) { - context.pushContextualType(contextualType, context.inProvisionalResolution(), null); - actualParametersContextTypeSymbols[i] = contextualType; - } - - this.resolveAST(callEx.arguments.members[i], contextualType != null, enclosingDecl, context); - - if (contextualType) { - context.popContextualType(); - contextualType = null; - } - } - } - - if (additionalResults) { - additionalResults.targetSymbol = targetSymbol; - additionalResults.targetTypeSymbol = targetTypeSymbol; - if (useBeforeResolutionSignatures && beforeResolutionSignatures) { - additionalResults.resolvedSignatures = beforeResolutionSignatures; - additionalResults.candidateSignature = beforeResolutionSignatures[0]; - } else { - additionalResults.resolvedSignatures = signatures; - additionalResults.candidateSignature = signature; - } - additionalResults.actualParametersContextTypeSymbols = actualParametersContextTypeSymbols; - } - - if (errorCondition) { - return SymbolAndDiagnostics.create(errorCondition, diagnostics); - } - - if (!returnType) { - returnType = this.semanticInfoChain.anyTypeSymbol; - } - - return SymbolAndDiagnostics.fromSymbol(returnType); - }; - - PullTypeResolver.prototype.resolveNewExpression = function (callEx, inContextuallyTypedAssignment, enclosingDecl, context, additionalResults) { - if (additionalResults) { - return this.computeNewExpressionSymbol(callEx, inContextuallyTypedAssignment, enclosingDecl, context, additionalResults); - } - - var symbolAndDiagnostics = this.getSymbolAndDiagnosticsForAST(callEx); - if (!symbolAndDiagnostics || !symbolAndDiagnostics.symbol.isResolved()) { - symbolAndDiagnostics = this.computeNewExpressionSymbol(callEx, inContextuallyTypedAssignment, enclosingDecl, context, null); - this.setSymbolAndDiagnosticsForAST(callEx, symbolAndDiagnostics, context); - } - - return symbolAndDiagnostics; - }; - - PullTypeResolver.prototype.computeNewExpressionSymbol = function (callEx, inContextuallyTypedAssignment, enclosingDecl, context, additionalResults) { - var returnType = null; - - var targetSymbol = this.resolveAST(callEx.target, inContextuallyTypedAssignment, enclosingDecl, context).symbol; - var targetTypeSymbol = targetSymbol.isType() ? targetSymbol : targetSymbol.getType(); - - var targetAST = this.getLastIdentifierInTarget(callEx); - - if (targetTypeSymbol.isClass()) { - targetTypeSymbol = (targetTypeSymbol).getConstructorMethod().getType(); - } - - var constructSignatures = targetTypeSymbol.getConstructSignatures(); - - var typeArgs = null; - var typeReplacementMap = null; - var usedCallSignaturesInstead = false; - var couldNotAssignToConstraint; - - if (this.isAnyOrEquivalent(targetTypeSymbol)) { - return SymbolAndDiagnostics.fromSymbol(targetTypeSymbol); - } - - if (!constructSignatures.length) { - constructSignatures = targetTypeSymbol.getCallSignatures(); - usedCallSignaturesInstead = true; - } - - var diagnostics = []; - if (constructSignatures.length) { - if (callEx.typeArguments) { - typeArgs = []; - - if (callEx.typeArguments && callEx.typeArguments.members.length) { - for (var i = 0; i < callEx.typeArguments.members.length; i++) { - var typeArg = this.resolveTypeReference(callEx.typeArguments.members[i], enclosingDecl, context).symbol; - typeArgs[i] = context.findSpecializationForType(typeArg); - } - } - } - - if (targetTypeSymbol.isGeneric()) { - var resolvedSignatures = []; - var inferredTypeArgs; - var specializedSignature; - var typeParameters; - var typeConstraint = null; - var prevSpecializingToAny = context.specializingToAny; - var prevIsSpecializing = context.isSpecializingSignatureAtCallSite = true; - var triedToInferTypeArgs; - - for (var i = 0; i < constructSignatures.length; i++) { - couldNotAssignToConstraint = false; - - if (constructSignatures[i].isGeneric() && !constructSignatures[i].isFixed()) { - if (typeArgs) { - inferredTypeArgs = typeArgs; - } else if (callEx.arguments) { - inferredTypeArgs = this.inferArgumentTypesForSignature(constructSignatures[i], callEx.arguments, new TypeScript.TypeComparisonInfo(), enclosingDecl, context); - triedToInferTypeArgs = true; - } - - if (inferredTypeArgs) { - typeParameters = constructSignatures[i].getTypeParameters(); - - typeReplacementMap = {}; - - if (inferredTypeArgs.length) { - if (inferredTypeArgs.length < typeParameters.length) { - continue; - } - - for (var j = 0; j < typeParameters.length; j++) { - typeReplacementMap[typeParameters[j].getSymbolID().toString()] = inferredTypeArgs[j]; - } - for (var j = 0; j < typeParameters.length; j++) { - typeConstraint = typeParameters[j].getConstraint(); - - if (typeConstraint) { - if (typeConstraint.isTypeParameter()) { - for (var k = 0; k < typeParameters.length && k < inferredTypeArgs.length; k++) { - if (typeParameters[k] == typeConstraint) { - typeConstraint = inferredTypeArgs[k]; - } - } - } - if (typeConstraint.isTypeParameter()) { - context.pushTypeSpecializationCache(typeReplacementMap); - typeConstraint = TypeScript.specializeType(typeConstraint, null, this, enclosingDecl, context); - context.popTypeSpecializationCache(); - } - - context.isComparingSpecializedSignatures = true; - if (!this.sourceIsAssignableToTarget(inferredTypeArgs[j], typeConstraint, context)) { - diagnostics = this.addDiagnostic(diagnostics, context.postError(this.unitPath, targetAST.minChar, targetAST.getLength(), 155 /* Type__0__does_not_satisfy_the_constraint__1__for_type_parameter__2_ */, [inferredTypeArgs[j].toString(true), typeConstraint.toString(true), typeParameters[j].toString(true)])); - couldNotAssignToConstraint = true; - } - context.isComparingSpecializedSignatures = false; - - if (couldNotAssignToConstraint) { - break; - } - } - } - } else { - if (triedToInferTypeArgs) { - if (constructSignatures[i].parametersAreFixed()) { - if (constructSignatures[i].hasGenericParameter()) { - context.specializingToAny = true; - } else { - resolvedSignatures[resolvedSignatures.length] = constructSignatures[i]; - } - } else { - continue; - } - } - - context.specializingToAny = true; - } - - if (couldNotAssignToConstraint) { - continue; - } - - context.isSpecializingSignatureAtCallSite = true; - specializedSignature = TypeScript.specializeSignature(constructSignatures[i], false, typeReplacementMap, inferredTypeArgs, this, enclosingDecl, context); - - context.specializingToAny = prevSpecializingToAny; - context.isSpecializingSignatureAtCallSite = prevIsSpecializing; - - if (specializedSignature) { - resolvedSignatures[resolvedSignatures.length] = specializedSignature; - } - } - } else { - if (!(callEx.typeArguments && callEx.typeArguments.members.length)) { - resolvedSignatures[resolvedSignatures.length] = constructSignatures[i]; - } - } - } - - constructSignatures = resolvedSignatures; - } - - var signature = this.resolveOverloads(callEx, constructSignatures, enclosingDecl, callEx.typeArguments != null, context, diagnostics); - - if (additionalResults) { - additionalResults.targetSymbol = targetSymbol; - additionalResults.targetTypeSymbol = targetTypeSymbol; - additionalResults.resolvedSignatures = constructSignatures; - additionalResults.candidateSignature = signature; - additionalResults.actualParametersContextTypeSymbols = []; - } - - if (!constructSignatures.length && diagnostics) { - var result = this.getNewErrorTypeSymbol(null); - return SymbolAndDiagnostics.create(result, diagnostics); - } - - var errorCondition = null; - - if (!signature) { - diagnostics = this.addDiagnostic(diagnostics, context.postError(this.unitPath, targetAST.minChar, targetAST.getLength(), 154 /* Could_not_select_overload_for__new__expression */)); - - errorCondition = this.getNewErrorTypeSymbol(null); - - if (!constructSignatures.length) { - return SymbolAndDiagnostics.create(errorCondition, diagnostics); - } - - signature = constructSignatures[0]; - - if (callEx.arguments) { - for (var k = 0, n = callEx.arguments.members.length; k < n; k++) { - var arg = callEx.arguments.members[k]; - var argSymbolAndDiagnostics = this.getSymbolAndDiagnosticsForAST(arg); - var argSymbol = argSymbolAndDiagnostics && argSymbolAndDiagnostics.symbol; - - if (argSymbol) { - var argType = argSymbol.getType(); - if (arg.nodeType === 12 /* FunctionDeclaration */) { - if (!this.canApplyContextualTypeToFunction(argType, arg, true)) { - continue; - } - } - - argSymbol.invalidate(); - } - } - } - } - - returnType = signature.getReturnType(); - - if (returnType && !signature.isGeneric() && returnType.isGeneric() && !returnType.getIsSpecialized()) { - if (typeArgs && typeArgs.length) { - returnType = TypeScript.specializeType(returnType, typeArgs, this, enclosingDecl, context, callEx); - } else { - returnType = this.specializeTypeToAny(returnType, enclosingDecl, context); - } - } - - if (usedCallSignaturesInstead) { - if (returnType != this.semanticInfoChain.voidTypeSymbol) { - diagnostics = this.addDiagnostic(diagnostics, context.postError(this.unitPath, targetAST.minChar, targetAST.getLength(), 153 /* Call_signatures_used_in_a__new__expression_must_have_a__void__return_type */)); - return SymbolAndDiagnostics.create(this.getNewErrorTypeSymbol(null), diagnostics); - } else { - returnType = this.semanticInfoChain.anyTypeSymbol; - } - } - - if (!returnType) { - returnType = signature.getReturnType(); - - if (!returnType) { - returnType = targetTypeSymbol; - } - } - - var actualParametersContextTypeSymbols = []; - if (callEx.arguments) { - var len = callEx.arguments.members.length; - var params = signature.getParameters(); - var contextualType = null; - var signatureDecl = signature.getDeclarations()[0]; - - for (var i = 0; i < len; i++) { - if (params.length) { - if (i < params.length - 1 || (i < params.length && !signature.hasVariableParamList())) { - if (typeReplacementMap) { - context.pushTypeSpecializationCache(typeReplacementMap); - } - this.resolveDeclaredSymbol(params[i], signatureDecl, context); - if (typeReplacementMap) { - context.popTypeSpecializationCache(); - } - contextualType = params[i].getType(); - } else if (signature.hasVariableParamList()) { - contextualType = params[params.length - 1].getType(); - if (contextualType.isArray()) { - contextualType = contextualType.getElementType(); - } - } - } - - if (contextualType) { - context.pushContextualType(contextualType, context.inProvisionalResolution(), null); - actualParametersContextTypeSymbols[i] = contextualType; - } - - this.resolveAST(callEx.arguments.members[i], contextualType != null, enclosingDecl, context); - - if (contextualType) { - context.popContextualType(); - contextualType = null; - } - } - } - - if (additionalResults) { - additionalResults.targetSymbol = targetSymbol; - additionalResults.targetTypeSymbol = targetTypeSymbol; - additionalResults.resolvedSignatures = constructSignatures; - additionalResults.candidateSignature = signature; - additionalResults.actualParametersContextTypeSymbols = actualParametersContextTypeSymbols; - } - - if (errorCondition) { - return SymbolAndDiagnostics.create(errorCondition, diagnostics); - } - - if (!returnType) { - returnType = this.semanticInfoChain.anyTypeSymbol; - } - - return SymbolAndDiagnostics.fromSymbol(returnType); - } else if (targetTypeSymbol.isClass()) { - return SymbolAndDiagnostics.fromSymbol(returnType); - } - - diagnostics = this.addDiagnostic(diagnostics, context.postError(this.unitPath, targetAST.minChar, targetAST.getLength(), 152 /* Invalid__new__expression */)); - - return SymbolAndDiagnostics.create(this.getNewErrorTypeSymbol(null), diagnostics); - }; - - PullTypeResolver.prototype.resolveTypeAssertionExpression = function (assertionExpression, inContextuallyTypedAssignment, enclosingDecl, context) { - return this.resolveTypeReference(assertionExpression.castTerm, enclosingDecl, context); - }; - - PullTypeResolver.prototype.resolveAssignmentStatement = function (binex, inContextuallyTypedAssignment, enclosingDecl, context) { - var symbolAndDiagnostics = this.getSymbolAndDiagnosticsForAST(binex); - - if (!symbolAndDiagnostics) { - symbolAndDiagnostics = this.computeAssignmentStatementSymbol(binex, inContextuallyTypedAssignment, enclosingDecl, context); - this.setSymbolAndDiagnosticsForAST(binex, symbolAndDiagnostics, context); - } - - return symbolAndDiagnostics; - }; - - PullTypeResolver.prototype.computeAssignmentStatementSymbol = function (binex, inContextuallyTypedAssignment, enclosingDecl, context) { - var leftType = this.resolveAST(binex.operand1, inContextuallyTypedAssignment, enclosingDecl, context).symbol.getType(); - - context.pushContextualType(leftType, context.inProvisionalResolution(), null); - this.resolveAST(binex.operand2, true, enclosingDecl, context); - context.popContextualType(); - - return SymbolAndDiagnostics.fromSymbol(leftType); - }; - - PullTypeResolver.prototype.resolveBoundDecls = function (decl, context) { - if (!decl) { - return; - } - - switch (decl.getKind()) { - case 1 /* Script */: - var childDecls = decl.getChildDecls(); - for (var i = 0; i < childDecls.length; i++) { - this.resolveBoundDecls(childDecls[i], context); - } - break; - case 32 /* DynamicModule */: - case 4 /* Container */: - case 64 /* Enum */: - var moduleDecl = this.semanticInfoChain.getASTForDecl(decl); - this.resolveModuleDeclaration(moduleDecl, context); - break; - case 16 /* Interface */: - var interfaceDecl = this.semanticInfoChain.getASTForDecl(decl); - this.resolveInterfaceDeclaration(interfaceDecl, context); - break; - case 8 /* Class */: - var classDecl = this.semanticInfoChain.getASTForDecl(decl); - this.resolveClassDeclaration(classDecl, context); - break; - case 65536 /* Method */: - case 16384 /* Function */: - var funcDecl = this.semanticInfoChain.getASTForDecl(decl); - this.resolveFunctionDeclaration(funcDecl, context); - break; - case 262144 /* GetAccessor */: - funcDecl = this.semanticInfoChain.getASTForDecl(decl); - this.resolveGetAccessorDeclaration(funcDecl, context); - break; - case 524288 /* SetAccessor */: - funcDecl = this.semanticInfoChain.getASTForDecl(decl); - this.resolveSetAccessorDeclaration(funcDecl, context); - break; - case 4096 /* Property */: - case 1024 /* Variable */: - case 2048 /* Parameter */: - var varDecl = this.semanticInfoChain.getASTForDecl(decl); - - if (varDecl) { - this.resolveVariableDeclaration(varDecl, context); - } - break; - } - }; - - PullTypeResolver.prototype.mergeOrdered = function (a, b, context, comparisonInfo) { - if (this.isAnyOrEquivalent(a) || this.isAnyOrEquivalent(b)) { - return this.semanticInfoChain.anyTypeSymbol; - } else if (a === b) { - return a; - } else if ((b === this.semanticInfoChain.nullTypeSymbol) && a != this.semanticInfoChain.nullTypeSymbol) { - return a; - } else if ((a === this.semanticInfoChain.nullTypeSymbol) && (b != this.semanticInfoChain.nullTypeSymbol)) { - return b; - } else if ((a === this.semanticInfoChain.voidTypeSymbol) && (b === this.semanticInfoChain.voidTypeSymbol || b === this.semanticInfoChain.undefinedTypeSymbol || b === this.semanticInfoChain.nullTypeSymbol)) { - return a; - } else if ((a === this.semanticInfoChain.voidTypeSymbol) && (b === this.semanticInfoChain.anyTypeSymbol)) { - return b; - } else if ((b === this.semanticInfoChain.undefinedTypeSymbol) && a != this.semanticInfoChain.voidTypeSymbol) { - return a; - } else if ((a === this.semanticInfoChain.undefinedTypeSymbol) && (b != this.semanticInfoChain.undefinedTypeSymbol)) { - return b; - } else if (a.isTypeParameter() && !b.isTypeParameter()) { - return b; - } else if (!a.isTypeParameter() && b.isTypeParameter()) { - return a; - } else if (a.isArray() && b.isArray()) { - if (a.getElementType() === b.getElementType()) { - return a; - } else { - var mergedET = this.mergeOrdered(a.getElementType(), b.getElementType(), context, comparisonInfo); - if (mergedET) { - var mergedArrayType = mergedET.getArrayType(); - - if (!mergedArrayType) { - mergedArrayType = TypeScript.specializeToArrayType(this.semanticInfoChain.elementTypeSymbol, mergedET, this, context); - } - - return mergedArrayType; - } - } - } else if (this.sourceIsSubtypeOfTarget(a, b, context, comparisonInfo)) { - return b; - } else if (this.sourceIsSubtypeOfTarget(b, a, context, comparisonInfo)) { - return a; - } - - return null; - }; - - PullTypeResolver.prototype.widenType = function (type) { - if (type === this.semanticInfoChain.undefinedTypeSymbol || type === this.semanticInfoChain.nullTypeSymbol || type.isError()) { - return this.semanticInfoChain.anyTypeSymbol; - } - - return type; - }; - - PullTypeResolver.prototype.isNullOrUndefinedType = function (type) { - return type === this.semanticInfoChain.nullTypeSymbol || type === this.semanticInfoChain.undefinedTypeSymbol; - }; - - PullTypeResolver.prototype.canApplyContextualType = function (type) { - if (!type) { - return true; - } - - var kind = type.getKind(); - - if ((kind & 8388608 /* ObjectType */) != 0) { - return true; - } - if ((kind & 16 /* Interface */) != 0) { - return true; - } else if ((kind & TypeScript.PullElementKind.SomeFunction) != 0) { - return this.canApplyContextualTypeToFunction(type, this.semanticInfoChain.getASTForDecl(type.getDeclarations[0]), true); - } else if ((kind & 128 /* Array */) != 0) { - return true; - } else if (type == this.semanticInfoChain.anyTypeSymbol || kind != 2 /* Primitive */) { - return true; - } - - return false; - }; - - PullTypeResolver.prototype.findBestCommonType = function (initialType, targetType, collection, context, comparisonInfo) { - var len = collection.getLength(); - var nlastChecked = 0; - var bestCommonType = initialType; - - if (targetType && this.canApplyContextualType(bestCommonType)) { - if (bestCommonType) { - bestCommonType = this.mergeOrdered(bestCommonType, targetType, context); - } else { - bestCommonType = targetType; - } - } - - var convergenceType = bestCommonType; - - while (nlastChecked < len) { - for (var i = 0; i < len; i++) { - if (i === nlastChecked) { - continue; - } - - if (convergenceType && (bestCommonType = this.mergeOrdered(convergenceType, collection.getTypeAtIndex(i), context, comparisonInfo))) { - convergenceType = bestCommonType; - } - - if (bestCommonType === null || this.isAnyOrEquivalent(bestCommonType)) { - break; - } else if (targetType && !(bestCommonType.isTypeParameter() || targetType.isTypeParameter())) { - collection.setTypeAtIndex(i, targetType); - } - } - - if (convergenceType && bestCommonType) { - break; - } - - nlastChecked++; - if (nlastChecked < len) { - convergenceType = collection.getTypeAtIndex(nlastChecked); - } - } - - if (!bestCommonType) { - var emptyTypeDecl = new TypeScript.PullDecl("{}", "{}", 8388608 /* ObjectType */, 0 /* None */, new TypeScript.TextSpan(0, 0), this.currentUnit.getPath()); - var emptyType = new TypeScript.PullTypeSymbol("{}", 8388608 /* ObjectType */); - - emptyTypeDecl.setSymbol(emptyType); - emptyType.addDeclaration(emptyTypeDecl); - - bestCommonType = emptyType; - } - - return bestCommonType; - }; - - PullTypeResolver.prototype.typesAreIdentical = function (t1, t2, val) { - if (t1 === t2) { - return true; - } - - if (!t1 || !t2) { - return false; - } - - if (val && t1.isPrimitive() && (t1).isStringConstant() && t2 === this.semanticInfoChain.stringTypeSymbol) { - return (val.nodeType === 5 /* StringLiteral */) && (TypeScript.stripQuotes((val).actualText) === TypeScript.stripQuotes(t1.getName())); - } - - if (val && t2.isPrimitive() && (t2).isStringConstant() && t2 === this.semanticInfoChain.stringTypeSymbol) { - return (val.nodeType === 5 /* StringLiteral */) && (TypeScript.stripQuotes((val).actualText) === TypeScript.stripQuotes(t2.getName())); - } - - if (t1.isPrimitive() && (t1).isStringConstant() && t2.isPrimitive() && (t2).isStringConstant()) { - return TypeScript.stripQuotes(t1.getName()) === TypeScript.stripQuotes(t2.getName()); - } - - if (t1.isPrimitive() || t2.isPrimitive()) { - return false; - } - - if (t1.isClass()) { - return false; - } - - if (t1.isError() && t2.isError()) { - return true; - } - - if (t1.isTypeParameter()) { - if (!t2.isTypeParameter()) { - return false; - } - - var t1ParentDeclaration = t1.getDeclarations()[0].getParentDecl(); - var t2ParentDeclaration = t2.getDeclarations()[0].getParentDecl(); - - if (t1ParentDeclaration === t2ParentDeclaration) { - return this.symbolsShareDeclaration(t1, t2); - } else { - return true; - } - } - - var comboId = t2.getSymbolID().toString() + "#" + t1.getSymbolID().toString(); - - if (this.identicalCache[comboId] != undefined) { - return true; - } - - if ((t1.getKind() & 64 /* Enum */) || (t2.getKind() & 64 /* Enum */)) { - return t1.getAssociatedContainerType() === t2 || t2.getAssociatedContainerType() === t1; - } - - if (t1.isArray() || t2.isArray()) { - if (!(t1.isArray() && t2.isArray())) { - return false; - } - this.identicalCache[comboId] = false; - var ret = this.typesAreIdentical(t1.getElementType(), t2.getElementType()); - if (ret) { - this.identicalCache[comboId] = true; - } else { - this.identicalCache[comboId] = undefined; - } - - return ret; - } - - if (t1.isPrimitive() != t2.isPrimitive()) { - return false; - } - - this.identicalCache[comboId] = false; - - if (t1.hasMembers() && t2.hasMembers()) { - var t1Members = t1.getMembers(); - var t2Members = t2.getMembers(); - - if (t1Members.length != t2Members.length) { - this.identicalCache[comboId] = undefined; - return false; - } - - var t1MemberSymbol = null; - var t2MemberSymbol = null; - - var t1MemberType = null; - var t2MemberType = null; - - for (var iMember = 0; iMember < t1Members.length; iMember++) { - t1MemberSymbol = t1Members[iMember]; - t2MemberSymbol = this.getMemberSymbol(t1MemberSymbol.getName(), TypeScript.PullElementKind.SomeValue, t2); - - if (!t2MemberSymbol || (t1MemberSymbol.getIsOptional() != t2MemberSymbol.getIsOptional())) { - this.identicalCache[comboId] = undefined; - return false; - } - - t1MemberType = t1MemberSymbol.getType(); - t2MemberType = t2MemberSymbol.getType(); - - if (t1MemberType && t2MemberType && (this.identicalCache[t2MemberType.getSymbolID().toString() + "#" + t1MemberType.getSymbolID().toString()] != undefined)) { - continue; - } - - if (!this.typesAreIdentical(t1MemberType, t2MemberType)) { - this.identicalCache[comboId] = undefined; - return false; - } - } - } else if (t1.hasMembers() || t2.hasMembers()) { - this.identicalCache[comboId] = undefined; - return false; - } - - var t1CallSigs = t1.getCallSignatures(); - var t2CallSigs = t2.getCallSignatures(); - - var t1ConstructSigs = t1.getConstructSignatures(); - var t2ConstructSigs = t2.getConstructSignatures(); - - var t1IndexSigs = t1.getIndexSignatures(); - var t2IndexSigs = t2.getIndexSignatures(); - - if (!this.signatureGroupsAreIdentical(t1CallSigs, t2CallSigs)) { - this.identicalCache[comboId] = undefined; - return false; - } - - if (!this.signatureGroupsAreIdentical(t1ConstructSigs, t2ConstructSigs)) { - this.identicalCache[comboId] = undefined; - return false; - } - - if (!this.signatureGroupsAreIdentical(t1IndexSigs, t2IndexSigs)) { - this.identicalCache[comboId] = undefined; - return false; - } - - this.identicalCache[comboId] = true; - return true; - }; - - PullTypeResolver.prototype.signatureGroupsAreIdentical = function (sg1, sg2) { - if (sg1 === sg2) { - return true; - } - - if (!sg1 || !sg2) { - return false; - } - - if (sg1.length != sg2.length) { - return false; - } - - var sig1 = null; - var sig2 = null; - var sigsMatch = false; - - for (var iSig1 = 0; iSig1 < sg1.length; iSig1++) { - sig1 = sg1[iSig1]; - - for (var iSig2 = 0; iSig2 < sg2.length; iSig2++) { - sig2 = sg2[iSig2]; - - if (this.signaturesAreIdentical(sig1, sig2)) { - sigsMatch = true; - break; - } - } - - if (sigsMatch) { - sigsMatch = false; - continue; - } - - return false; - } - - return true; - }; - - PullTypeResolver.prototype.signaturesAreIdentical = function (s1, s2) { - if (s1.hasVariableParamList() != s2.hasVariableParamList()) { - return false; - } - - if (s1.getNonOptionalParameterCount() != s2.getNonOptionalParameterCount()) { - return false; - } - - var s1Params = s1.getParameters(); - var s2Params = s2.getParameters(); - - if (s1Params.length != s2Params.length) { - return false; - } - - if (!this.typesAreIdentical(s1.getReturnType(), s2.getReturnType())) { - return false; - } - - for (var iParam = 0; iParam < s1Params.length; iParam++) { - if (!this.typesAreIdentical(s1Params[iParam].getType(), s2Params[iParam].getType())) { - return false; - } - } - - return true; - }; - - PullTypeResolver.prototype.substituteUpperBoundForType = function (type) { - if (!type || !type.isTypeParameter()) { - return type; - } - - var constraint = (type).getConstraint(); - - if (constraint) { - return this.substituteUpperBoundForType(constraint); - } - - if (this.cachedObjectInterfaceType()) { - return this.cachedObjectInterfaceType(); - } - - return type; - }; - - PullTypeResolver.prototype.symbolsShareDeclaration = function (symbol1, symbol2) { - var decls1 = symbol1.getDeclarations(); - var decls2 = symbol2.getDeclarations(); - - if (decls1.length && decls2.length) { - return decls1[0].isEqual(decls2[0]); - } - - return false; - }; - - PullTypeResolver.prototype.sourceIsSubtypeOfTarget = function (source, target, context, comparisonInfo) { - return this.sourceIsRelatableToTarget(source, target, false, this.subtypeCache, context, comparisonInfo); - }; - - PullTypeResolver.prototype.sourceMembersAreSubtypeOfTargetMembers = function (source, target, context, comparisonInfo) { - return this.sourceMembersAreRelatableToTargetMembers(source, target, false, this.subtypeCache, context, comparisonInfo); - }; - - PullTypeResolver.prototype.sourcePropertyIsSubtypeOfTargetProperty = function (source, target, sourceProp, targetProp, context, comparisonInfo) { - return this.sourcePropertyIsRelatableToTargetProperty(source, target, sourceProp, targetProp, false, this.subtypeCache, context, comparisonInfo); - }; - - PullTypeResolver.prototype.sourceCallSignaturesAreSubtypeOfTargetCallSignatures = function (source, target, context, comparisonInfo) { - return this.sourceCallSignaturesAreRelatableToTargetCallSignatures(source, target, false, this.subtypeCache, context, comparisonInfo); - }; - - PullTypeResolver.prototype.sourceConstructSignaturesAreSubtypeOfTargetConstructSignatures = function (source, target, context, comparisonInfo) { - return this.sourceConstructSignaturesAreRelatableToTargetConstructSignatures(source, target, false, this.subtypeCache, context, comparisonInfo); - }; - - PullTypeResolver.prototype.sourceIndexSignaturesAreSubtypeOfTargetIndexSignatures = function (source, target, context, comparisonInfo) { - return this.sourceIndexSignaturesAreRelatableToTargetIndexSignatures(source, target, false, this.subtypeCache, context, comparisonInfo); - }; - - PullTypeResolver.prototype.typeIsSubtypeOfFunction = function (source, context) { - var callSignatures = source.getCallSignatures(); - - if (callSignatures.length) { - return true; - } - - var constructSignatures = source.getConstructSignatures(); - - if (constructSignatures.length) { - return true; - } - - if (this.cachedFunctionInterfaceType()) { - return this.sourceIsSubtypeOfTarget(source, this.cachedFunctionInterfaceType(), context); - } - - return false; - }; - - PullTypeResolver.prototype.signatureGroupIsSubtypeOfTarget = function (sg1, sg2, context, comparisonInfo) { - return this.signatureGroupIsRelatableToTarget(sg1, sg2, false, this.subtypeCache, context, comparisonInfo); - }; - - PullTypeResolver.prototype.signatureIsSubtypeOfTarget = function (s1, s2, context, comparisonInfo) { - return this.signatureIsRelatableToTarget(s1, s2, false, this.subtypeCache, context, comparisonInfo); - }; - - PullTypeResolver.prototype.sourceIsAssignableToTarget = function (source, target, context, comparisonInfo, isInProvisionalResolution) { - if (typeof isInProvisionalResolution === "undefined") { isInProvisionalResolution = false; } - var cache = isInProvisionalResolution ? {} : this.assignableCache; - return this.sourceIsRelatableToTarget(source, target, true, cache, context, comparisonInfo); - }; - - PullTypeResolver.prototype.signatureGroupIsAssignableToTarget = function (sg1, sg2, context, comparisonInfo) { - return this.signatureGroupIsRelatableToTarget(sg1, sg2, true, this.assignableCache, context, comparisonInfo); - }; - - PullTypeResolver.prototype.signatureIsAssignableToTarget = function (s1, s2, context, comparisonInfo) { - return this.signatureIsRelatableToTarget(s1, s2, true, this.assignableCache, context, comparisonInfo); - }; - - PullTypeResolver.prototype.sourceIsRelatableToTarget = function (source, target, assignableTo, comparisonCache, context, comparisonInfo) { - if (source === target) { - return true; - } - - if (!(source && target)) { - return true; - } - - if (context.specializingToAny && (target.isTypeParameter() || source.isTypeParameter())) { - return true; - } - - if (context.specializingToObject) { - if (target.isTypeParameter()) { - target = this.cachedObjectInterfaceType(); - } - if (source.isTypeParameter()) { - target = this.cachedObjectInterfaceType(); - } - } - - var sourceSubstitution = source; - - if (source == this.semanticInfoChain.stringTypeSymbol && this.cachedStringInterfaceType()) { - if (!this.cachedStringInterfaceType().isResolved()) { - this.resolveDeclaredSymbol(this.cachedStringInterfaceType(), null, context); - } - sourceSubstitution = this.cachedStringInterfaceType(); - } else if (source == this.semanticInfoChain.numberTypeSymbol && this.cachedNumberInterfaceType()) { - if (!this.cachedNumberInterfaceType().isResolved()) { - this.resolveDeclaredSymbol(this.cachedNumberInterfaceType(), null, context); - } - sourceSubstitution = this.cachedNumberInterfaceType(); - } else if (source == this.semanticInfoChain.booleanTypeSymbol && this.cachedBooleanInterfaceType()) { - if (!this.cachedBooleanInterfaceType().isResolved()) { - this.resolveDeclaredSymbol(this.cachedBooleanInterfaceType(), null, context); - } - sourceSubstitution = this.cachedBooleanInterfaceType(); - } else if (TypeScript.PullHelpers.symbolIsEnum(source) && this.cachedNumberInterfaceType()) { - sourceSubstitution = this.cachedNumberInterfaceType(); - } else if (source.isTypeParameter()) { - sourceSubstitution = this.substituteUpperBoundForType(source); - } - - var comboId = source.getSymbolID().toString() + "#" + target.getSymbolID().toString(); - - if (comparisonCache[comboId] != undefined) { - return true; - } - - if (assignableTo) { - if (this.isAnyOrEquivalent(source) || this.isAnyOrEquivalent(target)) { - return true; - } - - if (source === this.semanticInfoChain.stringTypeSymbol && target.isPrimitive() && (target).isStringConstant()) { - return comparisonInfo && comparisonInfo.stringConstantVal && (comparisonInfo.stringConstantVal.nodeType === 5 /* StringLiteral */) && (TypeScript.stripQuotes((comparisonInfo.stringConstantVal).actualText) === TypeScript.stripQuotes(target.getName())); - } - } else { - if (this.isAnyOrEquivalent(target)) { - return true; - } - - if (target === this.semanticInfoChain.stringTypeSymbol && source.isPrimitive() && (source).isStringConstant()) { - return true; - } - } - - if (source.isPrimitive() && (source).isStringConstant() && target.isPrimitive() && (target).isStringConstant()) { - return TypeScript.stripQuotes(source.getName()) === TypeScript.stripQuotes(target.getName()); - } - - if (source === this.semanticInfoChain.undefinedTypeSymbol) { - return true; - } - - if ((source === this.semanticInfoChain.nullTypeSymbol) && (target != this.semanticInfoChain.undefinedTypeSymbol && target != this.semanticInfoChain.voidTypeSymbol)) { - return true; - } - - if (target == this.semanticInfoChain.voidTypeSymbol) { - if (source == this.semanticInfoChain.anyTypeSymbol || source == this.semanticInfoChain.undefinedTypeSymbol || source == this.semanticInfoChain.nullTypeSymbol) { - return true; - } - - return false; - } else if (source == this.semanticInfoChain.voidTypeSymbol) { - if (target == this.semanticInfoChain.anyTypeSymbol) { - return true; - } - - return false; - } - - if (target === this.semanticInfoChain.numberTypeSymbol && TypeScript.PullHelpers.symbolIsEnum(source)) { - return true; - } - - if (source === this.semanticInfoChain.numberTypeSymbol && TypeScript.PullHelpers.symbolIsEnum(target)) { - return true; - } - - if (TypeScript.PullHelpers.symbolIsEnum(target) && TypeScript.PullHelpers.symbolIsEnum(source)) { - return this.symbolsShareDeclaration(target, source); - } - - if ((source.getKind() & 64 /* Enum */) || (target.getKind() & 64 /* Enum */)) { - return false; - } - - if (source.isArray() && target.isArray()) { - comparisonCache[comboId] = false; - var ret = this.sourceIsRelatableToTarget(source.getElementType(), target.getElementType(), assignableTo, comparisonCache, context, comparisonInfo); - if (ret) { - comparisonCache[comboId] = true; - } else { - comparisonCache[comboId] = undefined; - } - - return ret; - } else if (source.isArray() && target == this.cachedArrayInterfaceType()) { - return true; - } else if (target.isArray() && source == this.cachedArrayInterfaceType()) { - return true; - } - - if (source.isPrimitive() && target.isPrimitive()) { - return false; - } else if (source.isPrimitive() != target.isPrimitive()) { - if (target.isPrimitive()) { - return false; - } - } - - if (target.isTypeParameter()) { - if (source.isTypeParameter() && (source == sourceSubstitution)) { - var targetParentDeclaration = target.getDeclarations()[0].getParentDecl(); - var sourceParentDeclaration = source.getDeclarations()[0].getParentDecl(); - - if (targetParentDeclaration !== sourceParentDeclaration) { - return this.symbolsShareDeclaration(target, source); - } else { - return true; - } - } else { - if (context.isComparingSpecializedSignatures) { - target = this.substituteUpperBoundForType(target); - } else { - return false; - } - } - } - - comparisonCache[comboId] = false; - - if (sourceSubstitution.hasBase(target)) { - comparisonCache[comboId] = true; - return true; - } - - if (this.cachedObjectInterfaceType() && target === this.cachedObjectInterfaceType()) { - return true; - } - - if (this.cachedFunctionInterfaceType() && (sourceSubstitution.getCallSignatures().length || sourceSubstitution.getConstructSignatures().length) && target === this.cachedFunctionInterfaceType()) { - return true; - } - - if (target.hasMembers() && !this.sourceMembersAreRelatableToTargetMembers(sourceSubstitution, target, assignableTo, comparisonCache, context, comparisonInfo)) { - comparisonCache[comboId] = undefined; - return false; - } - - if (!this.sourceCallSignaturesAreRelatableToTargetCallSignatures(sourceSubstitution, target, assignableTo, comparisonCache, context, comparisonInfo)) { - comparisonCache[comboId] = undefined; - return false; - } - - if (!this.sourceConstructSignaturesAreRelatableToTargetConstructSignatures(sourceSubstitution, target, assignableTo, comparisonCache, context, comparisonInfo)) { - comparisonCache[comboId] = undefined; - return false; - } - - if (!this.sourceIndexSignaturesAreRelatableToTargetIndexSignatures(sourceSubstitution, target, assignableTo, comparisonCache, context, comparisonInfo)) { - comparisonCache[comboId] = undefined; - return false; - } - - comparisonCache[comboId] = true; - return true; - }; - - PullTypeResolver.prototype.sourceMembersAreRelatableToTargetMembers = function (source, target, assignableTo, comparisonCache, context, comparisonInfo) { - var targetProps = target.getAllMembers(TypeScript.PullElementKind.SomeValue, true); - - for (var itargetProp = 0; itargetProp < targetProps.length; itargetProp++) { - var targetProp = targetProps[itargetProp]; - var sourceProp = this.getMemberSymbol(targetProp.getName(), TypeScript.PullElementKind.SomeValue, source); - - if (!targetProp.isResolved()) { - this.resolveDeclaredSymbol(targetProp, null, context); - } - - var targetPropType = targetProp.getType(); - - if (!sourceProp) { - if (this.cachedObjectInterfaceType()) { - sourceProp = this.getMemberSymbol(targetProp.getName(), TypeScript.PullElementKind.SomeValue, this.cachedObjectInterfaceType()); - } - - if (!sourceProp) { - if (this.cachedFunctionInterfaceType() && (targetPropType.getCallSignatures().length || targetPropType.getConstructSignatures().length)) { - sourceProp = this.getMemberSymbol(targetProp.getName(), TypeScript.PullElementKind.SomeValue, this.cachedFunctionInterfaceType()); - } - - if (!sourceProp) { - if (!(targetProp.getIsOptional())) { - if (comparisonInfo) { - comparisonInfo.flags |= 2 /* RequiredPropertyIsMissing */; - comparisonInfo.addMessage(TypeScript.getDiagnosticMessage(240 /* Type__0__is_missing_property__1__from_type__2_ */, [source.toString(), targetProp.getScopedNameEx().toString(), target.toString()])); - } - return false; - } - continue; - } - } - } - - if (!this.sourcePropertyIsRelatableToTargetProperty(source, target, sourceProp, targetProp, assignableTo, comparisonCache, context, comparisonInfo)) { - return false; - } - } - - return true; - }; - - PullTypeResolver.prototype.sourcePropertyIsRelatableToTargetProperty = function (source, target, sourceProp, targetProp, assignableTo, comparisonCache, context, comparisonInfo) { - var targetPropIsPrivate = targetProp.hasFlag(2 /* Private */); - var sourcePropIsPrivate = sourceProp.hasFlag(2 /* Private */); - - if (targetPropIsPrivate != sourcePropIsPrivate) { - if (comparisonInfo) { - if (targetPropIsPrivate) { - comparisonInfo.addMessage(TypeScript.getDiagnosticMessage(244 /* Property__0__defined_as_public_in_type__1__is_defined_as_private_in_type__2_ */, [targetProp.getScopedNameEx().toString(), sourceProp.getContainer().toString(), targetProp.getContainer().toString()])); - } else { - comparisonInfo.addMessage(TypeScript.getDiagnosticMessage(243 /* Property__0__defined_as_private_in_type__1__is_defined_as_public_in_type__2_ */, [targetProp.getScopedNameEx().toString(), sourceProp.getContainer().toString(), targetProp.getContainer().toString()])); - } - comparisonInfo.flags |= 128 /* InconsistantPropertyAccesibility */; - } - return false; - } else if (sourcePropIsPrivate && targetPropIsPrivate) { - var targetDecl = targetProp.getDeclarations()[0]; - var sourceDecl = sourceProp.getDeclarations()[0]; - - if (!targetDecl.isEqual(sourceDecl)) { - if (comparisonInfo) { - comparisonInfo.flags |= 128 /* InconsistantPropertyAccesibility */; - comparisonInfo.addMessage(TypeScript.getDiagnosticMessage(245 /* Types__0__and__1__define_property__2__as_private */, [sourceProp.getContainer().toString(), targetProp.getContainer().toString(), targetProp.getScopedNameEx().toString()])); - } - return false; - } - } - - if (!sourceProp.isResolved()) { - this.resolveDeclaredSymbol(sourceProp, null, context); - } - - var sourcePropType = sourceProp.getType(); - var targetPropType = targetProp.getType(); - - if (targetPropType && sourcePropType && (comparisonCache[sourcePropType.getSymbolID().toString() + "#" + targetPropType.getSymbolID().toString()] != undefined)) { - return true; - } - - var comparisonInfoPropertyTypeCheck = null; - if (comparisonInfo && !comparisonInfo.onlyCaptureFirstError) { - comparisonInfoPropertyTypeCheck = new TypeScript.TypeComparisonInfo(comparisonInfo); - } - if (!this.sourceIsRelatableToTarget(sourcePropType, targetPropType, assignableTo, comparisonCache, context, comparisonInfoPropertyTypeCheck)) { - if (comparisonInfo) { - comparisonInfo.flags |= 32 /* IncompatiblePropertyTypes */; - var message; - if (comparisonInfoPropertyTypeCheck && comparisonInfoPropertyTypeCheck.message) { - message = TypeScript.getDiagnosticMessage(242 /* Types_of_property__0__of_types__1__and__2__are_incompatible__NL__3 */, [targetProp.getScopedNameEx().toString(), source.toString(), target.toString(), comparisonInfoPropertyTypeCheck.message]); - } else { - message = TypeScript.getDiagnosticMessage(241 /* Types_of_property__0__of_types__1__and__2__are_incompatible */, [targetProp.getScopedNameEx().toString(), source.toString(), target.toString()]); - } - comparisonInfo.addMessage(message); - } - - return false; - } - - return true; - }; - - PullTypeResolver.prototype.sourceCallSignaturesAreRelatableToTargetCallSignatures = function (source, target, assignableTo, comparisonCache, context, comparisonInfo) { - var targetCallSigs = target.getCallSignatures(); - - if (targetCallSigs.length) { - var comparisonInfoSignatuesTypeCheck = null; - if (comparisonInfo && !comparisonInfo.onlyCaptureFirstError) { - comparisonInfoSignatuesTypeCheck = new TypeScript.TypeComparisonInfo(comparisonInfo); - } - - var sourceCallSigs = source.getCallSignatures(); - if (!this.signatureGroupIsRelatableToTarget(sourceCallSigs, targetCallSigs, assignableTo, comparisonCache, context, comparisonInfoSignatuesTypeCheck)) { - if (comparisonInfo) { - var message; - if (sourceCallSigs.length && targetCallSigs.length) { - if (comparisonInfoSignatuesTypeCheck && comparisonInfoSignatuesTypeCheck.message) { - message = TypeScript.getDiagnosticMessage(247 /* Call_signatures_of_types__0__and__1__are_incompatible__NL__2 */, [source.toString(), target.toString(), comparisonInfoSignatuesTypeCheck.message]); - } else { - message = TypeScript.getDiagnosticMessage(246 /* Call_signatures_of_types__0__and__1__are_incompatible */, [source.toString(), target.toString()]); - } - } else { - var hasSig = targetCallSigs.length ? target.toString() : source.toString(); - var lacksSig = !targetCallSigs.length ? target.toString() : source.toString(); - message = TypeScript.getDiagnosticMessage(248 /* Type__0__requires_a_call_signature__but_Type__1__lacks_one */, [hasSig, lacksSig]); - } - comparisonInfo.flags |= 4 /* IncompatibleSignatures */; - comparisonInfo.addMessage(message); - } - return false; - } - } - - return true; - }; - - PullTypeResolver.prototype.sourceConstructSignaturesAreRelatableToTargetConstructSignatures = function (source, target, assignableTo, comparisonCache, context, comparisonInfo) { - var targetConstructSigs = target.getConstructSignatures(); - if (targetConstructSigs.length) { - var comparisonInfoSignatuesTypeCheck = null; - if (comparisonInfo && !comparisonInfo.onlyCaptureFirstError) { - comparisonInfoSignatuesTypeCheck = new TypeScript.TypeComparisonInfo(comparisonInfo); - } - - var sourceConstructSigs = source.getConstructSignatures(); - if (!this.signatureGroupIsRelatableToTarget(sourceConstructSigs, targetConstructSigs, assignableTo, comparisonCache, context, comparisonInfoSignatuesTypeCheck)) { - if (comparisonInfo) { - var message; - if (sourceConstructSigs.length && targetConstructSigs.length) { - if (comparisonInfoSignatuesTypeCheck && comparisonInfoSignatuesTypeCheck.message) { - message = TypeScript.getDiagnosticMessage(250 /* Construct_signatures_of_types__0__and__1__are_incompatible__NL__2 */, [source.toString(), target.toString(), comparisonInfoSignatuesTypeCheck.message]); - } else { - message = TypeScript.getDiagnosticMessage(249 /* Construct_signatures_of_types__0__and__1__are_incompatible */, [source.toString(), target.toString()]); - } - } else { - var hasSig = targetConstructSigs.length ? target.toString() : source.toString(); - var lacksSig = !targetConstructSigs.length ? target.toString() : source.toString(); - message = TypeScript.getDiagnosticMessage(251 /* Type__0__requires_a_construct_signature__but_Type__1__lacks_one */, [hasSig, lacksSig]); - } - comparisonInfo.flags |= 4 /* IncompatibleSignatures */; - comparisonInfo.addMessage(message); - } - return false; - } - } - - return true; - }; - - PullTypeResolver.prototype.sourceIndexSignaturesAreRelatableToTargetIndexSignatures = function (source, target, assignableTo, comparisonCache, context, comparisonInfo) { - var targetIndexSigs = target.getIndexSignatures(); - - if (targetIndexSigs.length) { - var sourceIndexSigs = source.getIndexSignatures(); - - var targetIndex = !targetIndexSigs.length && this.cachedObjectInterfaceType() ? this.cachedObjectInterfaceType().getIndexSignatures() : targetIndexSigs; - var sourceIndex = !sourceIndexSigs.length && this.cachedObjectInterfaceType() ? this.cachedObjectInterfaceType().getIndexSignatures() : sourceIndexSigs; - - var sourceStringSig = null; - var sourceNumberSig = null; - - var targetStringSig = null; - var targetNumberSig = null; - - var params; - - for (var i = 0; i < targetIndex.length; i++) { - if (targetStringSig && targetNumberSig) { - break; - } - - params = targetIndex[i].getParameters(); - - if (params.length) { - if (!targetStringSig && params[0].getType() === this.semanticInfoChain.stringTypeSymbol) { - targetStringSig = targetIndex[i]; - continue; - } else if (!targetNumberSig && params[0].getType() === this.semanticInfoChain.numberTypeSymbol) { - targetNumberSig = targetIndex[i]; - continue; - } - } - } - - for (var i = 0; i < sourceIndex.length; i++) { - if (sourceStringSig && sourceNumberSig) { - break; - } - - params = sourceIndex[i].getParameters(); - - if (params.length) { - if (!sourceStringSig && params[0].getType() === this.semanticInfoChain.stringTypeSymbol) { - sourceStringSig = sourceIndex[i]; - continue; - } else if (!sourceNumberSig && params[0].getType() === this.semanticInfoChain.numberTypeSymbol) { - sourceNumberSig = sourceIndex[i]; - continue; - } - } - } - - var comparable = true; - var comparisonInfoSignatuesTypeCheck = null; - if (comparisonInfo && !comparisonInfo.onlyCaptureFirstError) { - comparisonInfoSignatuesTypeCheck = new TypeScript.TypeComparisonInfo(comparisonInfo); - } - - if (targetStringSig) { - if (sourceStringSig) { - comparable = this.signatureIsAssignableToTarget(sourceStringSig, targetStringSig, context, comparisonInfoSignatuesTypeCheck); - } else { - comparable = false; - } - } - - if (comparable && targetNumberSig) { - if (sourceNumberSig) { - comparable = this.signatureIsAssignableToTarget(sourceNumberSig, targetNumberSig, context, comparisonInfoSignatuesTypeCheck); - } else if (sourceStringSig) { - comparable = this.sourceIsAssignableToTarget(sourceStringSig.getReturnType(), targetNumberSig.getReturnType(), context, comparisonInfoSignatuesTypeCheck); - } else { - comparable = false; - } - } - - if (!comparable) { - if (comparisonInfo) { - var message; - if (comparisonInfoSignatuesTypeCheck && comparisonInfoSignatuesTypeCheck.message) { - message = TypeScript.getDiagnosticMessage(253 /* Index_signatures_of_types__0__and__1__are_incompatible__NL__2 */, [source.toString(), target.toString(), comparisonInfoSignatuesTypeCheck.message]); - } else { - message = TypeScript.getDiagnosticMessage(252 /* Index_signatures_of_types__0__and__1__are_incompatible */, [source.toString(), target.toString()]); - } - comparisonInfo.flags |= 4 /* IncompatibleSignatures */; - comparisonInfo.addMessage(message); - } - return false; - } - } - - if (targetStringSig && !source.isNamedTypeSymbol() && source.hasMembers()) { - var targetReturnType = targetStringSig.getReturnType(); - var sourceMembers = source.getMembers(); - - for (var i = 0; i < sourceMembers.length; i++) { - if (!this.sourceIsRelatableToTarget(sourceMembers[i].getType(), targetReturnType, assignableTo, comparisonCache, context, comparisonInfo)) { - return false; - } - } - } - - return true; - }; - - PullTypeResolver.prototype.signatureGroupIsRelatableToTarget = function (sourceSG, targetSG, assignableTo, comparisonCache, context, comparisonInfo) { - if (sourceSG === targetSG) { - return true; - } - - if (!(sourceSG.length && targetSG.length)) { - return false; - } - - var mSig = null; - var nSig = null; - var foundMatch = false; - - for (var iMSig = 0; iMSig < targetSG.length; iMSig++) { - mSig = targetSG[iMSig]; - - if (mSig.isStringConstantOverloadSignature()) { - continue; - } - - for (var iNSig = 0; iNSig < sourceSG.length; iNSig++) { - nSig = sourceSG[iNSig]; - - if (nSig.isStringConstantOverloadSignature()) { - continue; - } - - if (this.signatureIsRelatableToTarget(nSig, mSig, assignableTo, comparisonCache, context, comparisonInfo)) { - foundMatch = true; - break; - } - } - - if (foundMatch) { - foundMatch = false; - continue; - } - return false; - } - - return true; - }; - - PullTypeResolver.prototype.signatureIsRelatableToTarget = function (sourceSig, targetSig, assignableTo, comparisonCache, context, comparisonInfo) { - var sourceParameters = sourceSig.getParameters(); - var targetParameters = targetSig.getParameters(); - - if (!sourceParameters || !targetParameters) { - return false; - } - - var targetVarArgCount = targetSig.getNonOptionalParameterCount(); - var sourceVarArgCount = sourceSig.getNonOptionalParameterCount(); - - if (sourceVarArgCount > targetVarArgCount && !targetSig.hasVariableParamList()) { - if (comparisonInfo) { - comparisonInfo.flags |= 3 /* SourceSignatureHasTooManyParameters */; - comparisonInfo.addMessage(TypeScript.getDiagnosticMessage(254 /* Call_signature_expects__0__or_fewer_parameters */, [targetVarArgCount])); - } - return false; - } - - var sourceReturnType = sourceSig.getReturnType(); - var targetReturnType = targetSig.getReturnType(); - - var prevSpecializingToObject = context.specializingToObject; - context.specializingToObject = true; - - if (targetReturnType != this.semanticInfoChain.voidTypeSymbol) { - if (!this.sourceIsRelatableToTarget(sourceReturnType, targetReturnType, assignableTo, comparisonCache, context, comparisonInfo)) { - if (comparisonInfo) { - comparisonInfo.flags |= 16 /* IncompatibleReturnTypes */; - } - context.specializingToObject = prevSpecializingToObject; - return false; - } - } - - var len = (sourceVarArgCount < targetVarArgCount && (sourceSig.hasVariableParamList() || (sourceParameters.length > sourceVarArgCount))) ? targetVarArgCount : sourceVarArgCount; - var sourceParamType = null; - var targetParamType = null; - var sourceParamName = ""; - var targetParamName = ""; - - for (var iSource = 0, iTarget = 0; iSource < len; iSource++, iTarget++) { - if (iSource < sourceParameters.length && (!sourceSig.hasVariableParamList() || iSource < sourceVarArgCount)) { - sourceParamType = sourceParameters[iSource].getType(); - sourceParamName = sourceParameters[iSource].getName(); - } else if (iSource === sourceVarArgCount) { - sourceParamType = sourceParameters[iSource].getType(); - if (sourceParamType.isArray()) { - sourceParamType = sourceParamType.getElementType(); - } - sourceParamName = sourceParameters[iSource].getName(); - } - - if (iTarget < targetParameters.length && iTarget < targetVarArgCount) { - targetParamType = targetParameters[iTarget].getType(); - targetParamName = targetParameters[iTarget].getName(); - } else if (targetSig.hasVariableParamList() && iTarget === targetVarArgCount) { - targetParamType = targetParameters[iTarget].getType(); - - if (targetParamType.isArray()) { - targetParamType = targetParamType.getElementType(); - } - targetParamName = targetParameters[iTarget].getName(); - } - - if (sourceParamType && sourceParamType.isTypeParameter() && this.cachedObjectInterfaceType()) { - sourceParamType = this.cachedObjectInterfaceType(); - } - if (targetParamType && targetParamType.isTypeParameter() && this.cachedObjectInterfaceType()) { - targetParamType = this.cachedObjectInterfaceType(); - } - - if (!(this.sourceIsRelatableToTarget(sourceParamType, targetParamType, assignableTo, comparisonCache, context, comparisonInfo) || this.sourceIsRelatableToTarget(targetParamType, sourceParamType, assignableTo, comparisonCache, context, comparisonInfo))) { - if (comparisonInfo) { - comparisonInfo.flags |= 64 /* IncompatibleParameterTypes */; - } - context.specializingToObject = prevSpecializingToObject; - return false; - } - } - context.specializingToObject = prevSpecializingToObject; - return true; - }; - - PullTypeResolver.prototype.resolveOverloads = function (application, group, enclosingDecl, haveTypeArgumentsAtCallSite, context, diagnostics) { - var rd = this.resolutionDataCache.getResolutionData(); - var actuals = rd.actuals; - var exactCandidates = rd.exactCandidates; - var conversionCandidates = rd.conversionCandidates; - var candidate = null; - var hasOverloads = group.length > 1; - var comparisonInfo = new TypeScript.TypeComparisonInfo(); - var args = null; - var target = null; - - if (application.nodeType === 36 /* InvocationExpression */ || application.nodeType === 37 /* ObjectCreationExpression */) { - var callEx = application; - - args = callEx.arguments; - target = this.getLastIdentifierInTarget(callEx); - - if (callEx.arguments) { - var len = callEx.arguments.members.length; - - for (var i = 0; i < len; i++) { - var argSym = this.resolveAST(callEx.arguments.members[i], false, enclosingDecl, context).symbol; - actuals[i] = argSym.getType(); - } - } - } else if (application.nodeType === 35 /* ElementAccessExpression */) { - var binExp = application; - target = binExp.operand1; - args = new TypeScript.ASTList(); - args.members[0] = binExp.operand2; - var argSym = this.resolveAST(args.members[0], false, enclosingDecl, context).symbol; - actuals[0] = argSym.getType(); - } - - var signature; - var returnType; - var candidateInfo; - - for (var j = 0, groupLen = group.length; j < groupLen; j++) { - signature = group[j]; - if ((hasOverloads && signature.isDefinition()) || (haveTypeArgumentsAtCallSite && !signature.isGeneric())) { - continue; - } - - returnType = signature.getReturnType(); - - this.getCandidateSignatures(signature, actuals, args, exactCandidates, conversionCandidates, enclosingDecl, context, comparisonInfo); - } - if (exactCandidates.length === 0) { - var applicableCandidates = this.getApplicableSignaturesFromCandidates(conversionCandidates, args, comparisonInfo, enclosingDecl, context); - if (applicableCandidates.length > 0) { - candidateInfo = this.findMostApplicableSignature(applicableCandidates, args, enclosingDecl, context); - - candidate = candidateInfo.sig; - } else { - if (comparisonInfo.message) { - diagnostics.push(context.postError(this.unitPath, target.minChar, target.getLength(), 151 /* Supplied_parameters_do_not_match_any_signature_of_call_target__NL__0 */, [comparisonInfo.message])); - } else { - diagnostics.push(context.postError(this.unitPath, target.minChar, target.getLength(), 150 /* Supplied_parameters_do_not_match_any_signature_of_call_target */, null)); - } - } - } else { - if (exactCandidates.length > 1) { - var applicableSigs = []; - for (var i = 0; i < exactCandidates.length; i++) { - applicableSigs[i] = { signature: exactCandidates[i], hadProvisionalErrors: false }; - } - candidateInfo = this.findMostApplicableSignature(applicableSigs, args, enclosingDecl, context); - - candidate = candidateInfo.sig; - } else { - candidate = exactCandidates[0]; - } - } - - this.resolutionDataCache.returnResolutionData(rd); - return candidate; - }; - - PullTypeResolver.prototype.getLastIdentifierInTarget = function (callEx) { - return (callEx.target.nodeType === 32 /* MemberAccessExpression */) ? (callEx.target).operand2 : callEx.target; - }; - - PullTypeResolver.prototype.getCandidateSignatures = function (signature, actuals, args, exactCandidates, conversionCandidates, enclosingDecl, context, comparisonInfo) { - var parameters = signature.getParameters(); - var lowerBound = signature.getNonOptionalParameterCount(); - var upperBound = parameters.length; - var formalLen = lowerBound; - var acceptable = false; - - if ((actuals.length >= lowerBound) && (signature.hasVariableParamList() || actuals.length <= upperBound)) { - formalLen = (signature.hasVariableParamList() ? parameters.length : actuals.length); - acceptable = true; - } - - var repeatType = null; - - if (acceptable) { - if (signature.hasVariableParamList()) { - formalLen -= 1; - repeatType = parameters[formalLen].getType(); - repeatType = repeatType.getElementType(); - acceptable = actuals.length >= (formalLen < lowerBound ? formalLen : lowerBound); - } - var len = actuals.length; - - var exact = acceptable; - var convert = acceptable; - - var typeA; - var typeB; - - for (var i = 0; i < len; i++) { - if (i < formalLen) { - typeA = parameters[i].getType(); - } else { - typeA = repeatType; - } - - typeB = actuals[i]; - - if (typeA && !typeA.isResolved()) { - this.resolveDeclaredSymbol(typeA, enclosingDecl, context); - } - - if (typeB && !typeB.isResolved()) { - this.resolveDeclaredSymbol(typeB, enclosingDecl, context); - } - - if (!typeA || !typeB || !(this.typesAreIdentical(typeA, typeB, args.members[i]))) { - exact = false; - } - - comparisonInfo.stringConstantVal = args.members[i]; - - if (!this.sourceIsAssignableToTarget(typeB, typeA, context, comparisonInfo)) { - convert = false; - } - - comparisonInfo.stringConstantVal = null; - - if (!(exact || convert)) { - break; - } - } - if (exact) { - exactCandidates[exactCandidates.length] = signature; - } else if (convert && (exactCandidates.length === 0)) { - conversionCandidates[conversionCandidates.length] = signature; - } - } - }; - - PullTypeResolver.prototype.getApplicableSignaturesFromCandidates = function (candidateSignatures, args, comparisonInfo, enclosingDecl, context) { - var applicableSigs = []; - var memberType = null; - var miss = false; - var cxt = null; - var hadProvisionalErrors = false; - - var parameters; - var signature; - var argSym; - - for (var i = 0; i < candidateSignatures.length; i++) { - miss = false; - - signature = candidateSignatures[i]; - parameters = signature.getParameters(); - - for (var j = 0; j < args.members.length; j++) { - if (j >= parameters.length) { - continue; - } - - if (!parameters[j].isResolved()) { - this.resolveDeclaredSymbol(parameters[j], enclosingDecl, context); - } - - memberType = parameters[j].getType(); - - if (signature.hasVariableParamList() && (j >= signature.getNonOptionalParameterCount()) && memberType.isArray()) { - memberType = memberType.getElementType(); - } - - if (this.isAnyOrEquivalent(memberType)) { - continue; - } else if (args.members[j].nodeType === 12 /* FunctionDeclaration */) { - if (this.cachedFunctionInterfaceType() && memberType === this.cachedFunctionInterfaceType()) { - continue; - } - - argSym = this.resolveFunctionExpression(args.members[j], false, enclosingDecl, context); - - if (!this.canApplyContextualTypeToFunction(memberType, args.members[j], true)) { - if (this.canApplyContextualTypeToFunction(memberType, args.members[j], false)) { - if (!this.sourceIsAssignableToTarget(argSym.getType(), memberType, context, comparisonInfo, true)) { - break; - } - } else { - break; - } - } else { - argSym.invalidate(); - context.pushContextualType(memberType, true, null); - - argSym = this.resolveFunctionExpression(args.members[j], true, enclosingDecl, context); - - if (!this.sourceIsAssignableToTarget(argSym.getType(), memberType, context, comparisonInfo, true)) { - if (comparisonInfo) { - comparisonInfo.setMessage(TypeScript.getDiagnosticMessage(255 /* Could_not_apply_type__0__to_argument__1__which_is_of_type__2_ */, [memberType.toString(), (j + 1), argSym.getTypeName()])); - } - miss = true; - } - argSym.invalidate(); - cxt = context.popContextualType(); - hadProvisionalErrors = cxt.hadProvisionalErrors(); - - if (miss) { - break; - } - } - } else if (args.members[j].nodeType === 22 /* ObjectLiteralExpression */) { - if (this.cachedObjectInterfaceType() && memberType === this.cachedObjectInterfaceType()) { - continue; - } - - context.pushContextualType(memberType, true, null); - argSym = this.resolveObjectLiteralExpression(args.members[j], true, enclosingDecl, context).symbol; - - if (!this.sourceIsAssignableToTarget(argSym.getType(), memberType, context, comparisonInfo, true)) { - if (comparisonInfo) { - comparisonInfo.setMessage(TypeScript.getDiagnosticMessage(255 /* Could_not_apply_type__0__to_argument__1__which_is_of_type__2_ */, [memberType.toString(), (j + 1), argSym.getTypeName()])); - } - - miss = true; - } - - argSym.invalidate(); - cxt = context.popContextualType(); - hadProvisionalErrors = cxt.hadProvisionalErrors(); - - if (miss) { - break; - } - } else if (args.members[j].nodeType === 21 /* ArrayLiteralExpression */) { - if (memberType === this.cachedArrayInterfaceType()) { - continue; - } - - context.pushContextualType(memberType, true, null); - var argSym = this.resolveArrayLiteralExpression(args.members[j], true, enclosingDecl, context).symbol; - - if (!this.sourceIsAssignableToTarget(argSym.getType(), memberType, context, comparisonInfo, true)) { - if (comparisonInfo) { - comparisonInfo.setMessage(TypeScript.getDiagnosticMessage(255 /* Could_not_apply_type__0__to_argument__1__which_is_of_type__2_ */, [memberType.toString(), (j + 1), argSym.getTypeName()])); - } - break; - } - - argSym.invalidate(); - cxt = context.popContextualType(); - - hadProvisionalErrors = cxt.hadProvisionalErrors(); - - if (miss) { - break; - } - } - } - - if (j === args.members.length) { - applicableSigs[applicableSigs.length] = { signature: candidateSignatures[i], hadProvisionalErrors: hadProvisionalErrors }; - } - - hadProvisionalErrors = false; - } - - return applicableSigs; - }; - - PullTypeResolver.prototype.findMostApplicableSignature = function (signatures, args, enclosingDecl, context) { - if (signatures.length === 1) { - return { sig: signatures[0].signature, ambiguous: false }; - } - - var best = signatures[0]; - var Q = null; - - var AType = null; - var PType = null; - var QType = null; - - var ambiguous = false; - - var bestParams; - var qParams; - - for (var qSig = 1; qSig < signatures.length; qSig++) { - Q = signatures[qSig]; - - for (var i = 0; args && i < args.members.length; i++) { - var argSym = this.resolveAST(args.members[i], false, enclosingDecl, context).symbol; - - AType = argSym.getType(); - - argSym.invalidate(); - - bestParams = best.signature.getParameters(); - qParams = Q.signature.getParameters(); - - PType = i < bestParams.length ? bestParams[i].getType() : bestParams[bestParams.length - 1].getType().getElementType(); - QType = i < qParams.length ? qParams[i].getType() : qParams[qParams.length - 1].getType().getElementType(); - - if (this.typesAreIdentical(PType, QType) && !(QType.isPrimitive() && (QType).isStringConstant())) { - continue; - } else if (PType.isPrimitive() && (PType).isStringConstant() && args.members[i].nodeType === 5 /* StringLiteral */ && TypeScript.stripQuotes((args.members[i]).actualText) === TypeScript.stripQuotes((PType).getName())) { - break; - } else if (QType.isPrimitive() && (QType).isStringConstant() && args.members[i].nodeType === 5 /* StringLiteral */ && TypeScript.stripQuotes((args.members[i]).actualText) === TypeScript.stripQuotes((QType).getName())) { - best = Q; - } else if (this.typesAreIdentical(AType, PType)) { - break; - } else if (this.typesAreIdentical(AType, QType)) { - best = Q; - break; - } else if (this.sourceIsSubtypeOfTarget(PType, QType, context)) { - break; - } else if (this.sourceIsSubtypeOfTarget(QType, PType, context)) { - best = Q; - break; - } else if (Q.hadProvisionalErrors) { - break; - } else if (best.hadProvisionalErrors) { - best = Q; - break; - } - } - - if (!args || i === args.members.length) { - var collection = { - getLength: function () { - return 2; - }, - setTypeAtIndex: function (index, type) { - }, - getTypeAtIndex: function (index) { - return index ? Q.signature.getReturnType() : best.signature.getReturnType(); - } - }; - var bct = this.findBestCommonType(best.signature.getReturnType(), null, collection, context); - ambiguous = !bct; - } else { - ambiguous = false; - } - } - - return { sig: best.signature, ambiguous: ambiguous }; - }; - - PullTypeResolver.prototype.canApplyContextualTypeToFunction = function (candidateType, funcDecl, beStringent) { - if (funcDecl.isMethod() || beStringent && funcDecl.returnTypeAnnotation) { - return false; - } - - beStringent = beStringent || (this.cachedFunctionInterfaceType() === candidateType); - - if (!beStringent) { - return true; - } - var functionSymbol = this.getDeclForAST(funcDecl).getSymbol(); - var signature = functionSymbol.getType().getCallSignatures()[0]; - var parameters = signature.getParameters(); - var paramLen = parameters.length; - - for (var i = 0; i < paramLen; i++) { - var param = parameters[i]; - var argDecl = this.getASTForDecl(param.getDeclarations()[0]); - - if (beStringent && argDecl.typeExpr) { - return false; - } - } - - if (candidateType.getConstructSignatures().length && candidateType.getCallSignatures().length) { - return false; - } - - var candidateSigs = candidateType.getConstructSignatures().length ? candidateType.getConstructSignatures() : candidateType.getCallSignatures(); - - if (!candidateSigs || candidateSigs.length > 1) { - return false; - } - - return true; - }; - - PullTypeResolver.prototype.inferArgumentTypesForSignature = function (signature, args, comparisonInfo, enclosingDecl, context) { - var cxt = null; - var hadProvisionalErrors = false; - - var parameters = signature.getParameters(); - var typeParameters = signature.getTypeParameters(); - var argContext = new TypeScript.ArgumentInferenceContext(); - - var parameterType = null; - - for (var i = 0; i < typeParameters.length; i++) { - argContext.addInferenceRoot(typeParameters[i]); - } - - var substitutions; - var inferenceCandidates; - var inferenceCandidate; - - for (var i = 0; i < args.members.length; i++) { - if (i >= parameters.length) { - break; - } - - parameterType = parameters[i].getType(); - - if (signature.hasVariableParamList() && (i >= signature.getNonOptionalParameterCount() - 1) && parameterType.isArray()) { - parameterType = parameterType.getElementType(); - } - - inferenceCandidates = argContext.getInferenceCandidates(); - substitutions = {}; - - if (inferenceCandidates.length) { - for (var j = 0; j < inferenceCandidates.length; j++) { - argContext.resetRelationshipCache(); - - inferenceCandidate = inferenceCandidates[j]; - - substitutions = inferenceCandidates[j]; - - context.pushContextualType(parameterType, true, substitutions); - - var argSym = this.resolveAST(args.members[i], true, enclosingDecl, context).symbol; - - this.relateTypeToTypeParameters(argSym.getType(), parameterType, false, argContext, enclosingDecl, context); - - cxt = context.popContextualType(); - - argSym.invalidate(); - - hadProvisionalErrors = cxt.hadProvisionalErrors(); - } - } else { - context.pushContextualType(parameterType, true, {}); - var argSym = this.resolveAST(args.members[i], true, enclosingDecl, context).symbol; - - this.relateTypeToTypeParameters(argSym.getType(), parameterType, false, argContext, enclosingDecl, context); - - cxt = context.popContextualType(); - - argSym.invalidate(); - - hadProvisionalErrors = cxt.hadProvisionalErrors(); - } - } - - hadProvisionalErrors = false; - - var inferenceResults = argContext.inferArgumentTypes(this, context); - - if (inferenceResults.unfit) { - return null; - } - - var resultTypes = []; - - for (var i = 0; i < typeParameters.length; i++) { - for (var j = 0; j < inferenceResults.results.length; j++) { - if (inferenceResults.results[j].param == typeParameters[i]) { - resultTypes[resultTypes.length] = inferenceResults.results[j].type; - break; - } - } - } - - if (!args.members.length && !resultTypes.length && typeParameters.length) { - for (var i = 0; i < typeParameters.length; i++) { - resultTypes[resultTypes.length] = this.semanticInfoChain.anyTypeSymbol; - } - } else if (resultTypes.length && resultTypes.length < typeParameters.length) { - for (var i = resultTypes.length; i < typeParameters.length; i++) { - resultTypes[i] = this.semanticInfoChain.anyTypeSymbol; - } - } - - return resultTypes; - }; - - PullTypeResolver.prototype.relateTypeToTypeParameters = function (expressionType, parameterType, shouldFix, argContext, enclosingDecl, context) { - if (!expressionType || !parameterType) { - return; - } - - if (expressionType.isError()) { - expressionType = this.semanticInfoChain.anyTypeSymbol; - } - - if (parameterType === expressionType) { - return; - } - - if (parameterType.isTypeParameter()) { - if (expressionType.isGeneric() && !expressionType.isFixed()) { - expressionType = this.specializeTypeToAny(expressionType, enclosingDecl, context); - } - argContext.addCandidateForInference(parameterType, expressionType, shouldFix); - return; - } - var parameterDeclarations = parameterType.getDeclarations(); - var expressionDeclarations = expressionType.getDeclarations(); - if (!parameterType.isArray() && parameterDeclarations.length && expressionDeclarations.length && (parameterDeclarations[0].isEqual(expressionDeclarations[0]) || (expressionType.isGeneric() && parameterType.isGeneric() && this.sourceIsSubtypeOfTarget(expressionType, parameterType, context, null))) && expressionType.isGeneric()) { - var typeParameters = parameterType.getIsSpecialized() ? parameterType.getTypeArguments() : parameterType.getTypeParameters(); - var typeArguments = expressionType.getTypeArguments(); - - if (!typeArguments) { - typeParameters = parameterType.getTypeArguments(); - typeArguments = expressionType.getIsSpecialized() ? expressionType.getTypeArguments() : expressionType.getTypeParameters(); - } - - if (typeParameters && typeArguments && typeParameters.length === typeArguments.length) { - for (var i = 0; i < typeParameters.length; i++) { - if (typeArguments[i] != typeParameters[i]) { - this.relateTypeToTypeParameters(typeArguments[i], typeParameters[i], true, argContext, enclosingDecl, context); - } - } - } - } - - var prevSpecializingToAny = context.specializingToAny; - context.specializingToAny = true; - - if (!this.sourceIsAssignableToTarget(expressionType, parameterType, context)) { - context.specializingToAny = prevSpecializingToAny; - return; - } - context.specializingToAny = prevSpecializingToAny; - - if (expressionType.isArray() && parameterType.isArray()) { - this.relateArrayTypeToTypeParameters(expressionType, parameterType, shouldFix, argContext, enclosingDecl, context); - - return; - } - - this.relateObjectTypeToTypeParameters(expressionType, parameterType, shouldFix, argContext, enclosingDecl, context); - }; - - PullTypeResolver.prototype.relateFunctionSignatureToTypeParameters = function (expressionSignature, parameterSignature, argContext, enclosingDecl, context) { - var expressionParams = expressionSignature.getParameters(); - var expressionReturnType = expressionSignature.getReturnType(); - - var parameterParams = parameterSignature.getParameters(); - var parameterReturnType = parameterSignature.getReturnType(); - - var len = parameterParams.length < expressionParams.length ? parameterParams.length : expressionParams.length; - - for (var i = 0; i < len; i++) { - this.relateTypeToTypeParameters(expressionParams[i].getType(), parameterParams[i].getType(), true, argContext, enclosingDecl, context); - } - - this.relateTypeToTypeParameters(expressionReturnType, parameterReturnType, false, argContext, enclosingDecl, context); - }; - - PullTypeResolver.prototype.relateObjectTypeToTypeParameters = function (objectType, parameterType, shouldFix, argContext, enclosingDecl, context) { - var parameterTypeMembers = parameterType.getMembers(); - var parameterSignatures; - var parameterSignature; - - var objectMember; - var objectSignatures; - - if (argContext.alreadyRelatingTypes(objectType, parameterType)) { - return; - } - - var objectTypeArguments = objectType.getTypeArguments(); - var parameterTypeParameters = parameterType.getTypeParameters(); - - if (objectTypeArguments && (objectTypeArguments.length === parameterTypeParameters.length)) { - for (var i = 0; i < objectTypeArguments.length; i++) { - argContext.addCandidateForInference(parameterTypeParameters[i], objectTypeArguments[i], shouldFix); - } - } - - for (var i = 0; i < parameterTypeMembers.length; i++) { - objectMember = this.getMemberSymbol(parameterTypeMembers[i].getName(), TypeScript.PullElementKind.SomeValue, objectType); - - if (objectMember) { - this.relateTypeToTypeParameters(objectMember.getType(), parameterTypeMembers[i].getType(), shouldFix, argContext, enclosingDecl, context); - } - } - - parameterSignatures = parameterType.getCallSignatures(); - objectSignatures = objectType.getCallSignatures(); - - for (var i = 0; i < parameterSignatures.length; i++) { - parameterSignature = parameterSignatures[i]; - - for (var j = 0; j < objectSignatures.length; j++) { - this.relateFunctionSignatureToTypeParameters(objectSignatures[j], parameterSignature, argContext, enclosingDecl, context); - } - } - - parameterSignatures = parameterType.getConstructSignatures(); - objectSignatures = objectType.getConstructSignatures(); - - for (var i = 0; i < parameterSignatures.length; i++) { - parameterSignature = parameterSignatures[i]; - - for (var j = 0; j < objectSignatures.length; j++) { - this.relateFunctionSignatureToTypeParameters(objectSignatures[j], parameterSignature, argContext, enclosingDecl, context); - } - } - - parameterSignatures = parameterType.getIndexSignatures(); - objectSignatures = objectType.getIndexSignatures(); - - for (var i = 0; i < parameterSignatures.length; i++) { - parameterSignature = parameterSignatures[i]; - - for (var j = 0; j < objectSignatures.length; j++) { - this.relateFunctionSignatureToTypeParameters(objectSignatures[j], parameterSignature, argContext, enclosingDecl, context); - } - } - }; - - PullTypeResolver.prototype.relateArrayTypeToTypeParameters = function (argArrayType, parameterArrayType, shouldFix, argContext, enclosingDecl, context) { - var argElement = argArrayType.getElementType(); - var paramElement = parameterArrayType.getElementType(); - - this.relateTypeToTypeParameters(argElement, paramElement, shouldFix, argContext, enclosingDecl, context); - }; - - PullTypeResolver.prototype.specializeTypeToAny = function (typeToSpecialize, enclosingDecl, context) { - var prevSpecialize = context.specializingToAny; - - context.specializingToAny = true; - - var rootType = TypeScript.getRootType(typeToSpecialize); - - var type = TypeScript.specializeType(rootType, [], this, enclosingDecl, context); - - context.specializingToAny = prevSpecialize; - - return type; - }; - - PullTypeResolver.prototype.specializeSignatureToAny = function (signatureToSpecialize, enclosingDecl, context) { - var typeParameters = signatureToSpecialize.getTypeParameters(); - var typeReplacementMap = {}; - var typeArguments = []; - - for (var i = 0; i < typeParameters.length; i++) { - typeArguments[i] = this.semanticInfoChain.anyTypeSymbol; - typeReplacementMap[typeParameters[i].getSymbolID().toString()] = typeArguments[i]; - } - if (!typeArguments.length) { - typeArguments[0] = this.semanticInfoChain.anyTypeSymbol; - } - - var prevSpecialize = context.specializingToAny; - - context.specializingToAny = true; - - var sig = TypeScript.specializeSignature(signatureToSpecialize, false, typeReplacementMap, typeArguments, this, enclosingDecl, context); - context.specializingToAny = prevSpecialize; - - return sig; - }; - return PullTypeResolver; - })(); - TypeScript.PullTypeResolver = PullTypeResolver; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var PullTypeResolver2 = (function () { - function PullTypeResolver2() { - } - return PullTypeResolver2; - })(); - TypeScript.PullTypeResolver2 = PullTypeResolver2; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var TypeComparisonInfo = (function () { - function TypeComparisonInfo(sourceComparisonInfo) { - this.onlyCaptureFirstError = false; - this.flags = 0 /* SuccessfulComparison */; - this.message = ""; - this.stringConstantVal = null; - this.indent = 1; - if (sourceComparisonInfo) { - this.flags = sourceComparisonInfo.flags; - this.onlyCaptureFirstError = sourceComparisonInfo.onlyCaptureFirstError; - this.stringConstantVal = sourceComparisonInfo.stringConstantVal; - this.indent = sourceComparisonInfo.indent + 1; - } - } - TypeComparisonInfo.prototype.addMessage = function (message) { - if (!this.onlyCaptureFirstError && this.message) { - this.message = TypeScript.getDiagnosticMessage(2 /* _0__NL__1_TB__2 */, [this.message, this.indent, message]); - } else { - this.message = TypeScript.getDiagnosticMessage(3 /* _0_TB__1 */, [this.indent, message]); - } - }; - - TypeComparisonInfo.prototype.setMessage = function (message) { - this.message = TypeScript.getDiagnosticMessage(3 /* _0_TB__1 */, [this.indent, message]); - }; - return TypeComparisonInfo; - })(); - TypeScript.TypeComparisonInfo = TypeComparisonInfo; - - var PullTypeCheckContext = (function () { - function PullTypeCheckContext(compiler, script, scriptName) { - this.compiler = compiler; - this.script = script; - this.scriptName = scriptName; - this.enclosingDeclStack = []; - this.enclosingDeclReturnStack = []; - this.semanticInfo = null; - this.inSuperConstructorCall = false; - this.inSuperConstructorTarget = false; - this.seenSuperConstructorCall = false; - this.inConstructorArguments = false; - this.inImportDeclaration = false; - } - PullTypeCheckContext.prototype.pushEnclosingDecl = function (decl) { - this.enclosingDeclStack[this.enclosingDeclStack.length] = decl; - this.enclosingDeclReturnStack[this.enclosingDeclReturnStack.length] = false; - }; - - PullTypeCheckContext.prototype.popEnclosingDecl = function () { - this.enclosingDeclStack.length--; - this.enclosingDeclReturnStack.length--; - }; - - PullTypeCheckContext.prototype.getEnclosingDecl = function (kind) { - if (typeof kind === "undefined") { kind = TypeScript.PullElementKind.All; } - for (var i = this.enclosingDeclStack.length - 1; i >= 0; i--) { - var decl = this.enclosingDeclStack[i]; - if (decl.getKind() & kind) { - return decl; - } - } - - return null; - }; - - PullTypeCheckContext.prototype.getEnclosingNonLambdaDecl = function () { - for (var i = this.enclosingDeclStack.length - 1; i >= 0; i--) { - var decl = this.enclosingDeclStack[i]; - if (!(decl.getKind() === 131072 /* FunctionExpression */ && (decl.getFlags() & 8192 /* FatArrow */))) { - return decl; - } - } - - return null; - }; - - PullTypeCheckContext.prototype.getEnclosingClassDecl = function () { - return this.getEnclosingDecl(8 /* Class */); - }; - - PullTypeCheckContext.prototype.getEnclosingDeclHasReturn = function () { - return this.enclosingDeclReturnStack[this.enclosingDeclReturnStack.length - 1]; - }; - - PullTypeCheckContext.prototype.setEnclosingDeclHasReturn = function () { - return this.enclosingDeclReturnStack[this.enclosingDeclReturnStack.length - 1] = true; - }; - return PullTypeCheckContext; - })(); - TypeScript.PullTypeCheckContext = PullTypeCheckContext; - - var PullTypeChecker = (function () { - function PullTypeChecker(compilationSettings, semanticInfoChain) { - this.compilationSettings = compilationSettings; - this.semanticInfoChain = semanticInfoChain; - this.resolver = null; - this.context = new TypeScript.PullTypeResolutionContext(); - } - PullTypeChecker.prototype.setUnit = function (unitPath) { - this.resolver = new TypeScript.PullTypeResolver(this.compilationSettings, this.semanticInfoChain, unitPath); - }; - - PullTypeChecker.prototype.getScriptDecl = function (fileName) { - return this.semanticInfoChain.getUnit(fileName).getTopLevelDecls()[0]; - }; - - PullTypeChecker.prototype.checkForResolutionError = function (typeSymbol, decl) { - if (typeSymbol && typeSymbol.isError()) { - decl.addDiagnostic((typeSymbol).getDiagnostic()); - } - }; - - PullTypeChecker.prototype.postError = function (offset, length, fileName, diagnosticCode, arguments, enclosingDecl) { - enclosingDecl.addDiagnostic(new TypeScript.SemanticDiagnostic(fileName, offset, length, diagnosticCode, arguments)); - }; - - PullTypeChecker.prototype.validateVariableDeclarationGroups = function (enclosingDecl, typeCheckContext) { - var declGroups = enclosingDecl.getVariableDeclGroups(); - var decl; - var firstSymbol; - var symbol; - var boundDeclAST; - - for (var i = 0; i < declGroups.length; i++) { - for (var j = 0; j < declGroups[i].length; j++) { - decl = declGroups[i][j]; - symbol = decl.getSymbol(); - boundDeclAST = this.semanticInfoChain.getASTForDecl(decl); - this.resolver.resolveAST(boundDeclAST, false, enclosingDecl, this.context); - if (!j) { - firstSymbol = decl.getSymbol(); - - if (this.resolver.isAnyOrEquivalent(this.resolver.widenType(firstSymbol.getType()))) { - return; - } - continue; - } - - if (!this.resolver.typesAreIdentical(symbol.getType(), firstSymbol.getType())) { - this.postError(boundDeclAST.minChar, boundDeclAST.getLength(), typeCheckContext.scriptName, 199 /* Subsequent_variable_declarations_must_have_the_same_type___Variable__0__must_be_of_type__1___but_here_has_type___2_ */, [symbol.getDisplayName(), firstSymbol.getType().toString(), symbol.getType().toString()], enclosingDecl); - } - } - } - }; - - PullTypeChecker.prototype.typeCheckAST = function (ast, typeCheckContext, inContextuallyTypedAssignment) { - if (!ast) { - return null; - } - - if (ast.typeCheckPhase >= PullTypeChecker.globalPullTypeCheckPhase) { - return null; - } else { - ast.typeCheckPhase = PullTypeChecker.globalPullTypeCheckPhase; - } - - switch (ast.nodeType) { - case 1 /* List */: - return this.typeCheckList(ast, typeCheckContext); - - case 17 /* VariableDeclarator */: - case 19 /* Parameter */: - return this.typeCheckBoundDecl(ast, typeCheckContext); - - case 12 /* FunctionDeclaration */: - return this.typeCheckFunction(ast, typeCheckContext, inContextuallyTypedAssignment); - - case 13 /* ClassDeclaration */: - return this.typeCheckClass(ast, typeCheckContext); - - case 14 /* InterfaceDeclaration */: - return this.typeCheckInterface(ast, typeCheckContext); - - case 15 /* ModuleDeclaration */: - return this.typeCheckModule(ast, typeCheckContext); - - case 9 /* TypeParameter */: - return this.typeCheckTypeParameter(ast, typeCheckContext); - - case 16 /* ImportDeclaration */: - return this.typeCheckImportDeclaration(ast, typeCheckContext); - - case 38 /* AssignmentExpression */: - return this.typeCheckAssignment(ast, typeCheckContext); - - case 10 /* GenericType */: - return this.typeCheckGenericType(ast, typeCheckContext); - - case 22 /* ObjectLiteralExpression */: - return this.typeCheckObjectLiteral(ast, typeCheckContext, inContextuallyTypedAssignment); - - case 21 /* ArrayLiteralExpression */: - return this.typeCheckArrayLiteral(ast, typeCheckContext, inContextuallyTypedAssignment); - - case 29 /* ThisExpression */: - return this.typeCheckThisExpression(ast, typeCheckContext); - - case 30 /* SuperExpression */: - return this.typeCheckSuperExpression(ast, typeCheckContext); - - case 36 /* InvocationExpression */: - return this.typeCheckCallExpression(ast, typeCheckContext); - - case 37 /* ObjectCreationExpression */: - return this.typeCheckObjectCreationExpression(ast, typeCheckContext); - - case 78 /* CastExpression */: - return this.typeCheckTypeAssertion(ast, typeCheckContext); - - case 11 /* TypeRef */: - return this.typeCheckTypeReference(ast, typeCheckContext); - - case 87 /* ExportAssignment */: - return this.typeCheckExportAssignment(ast, typeCheckContext); - - case 57 /* NotEqualsWithTypeConversionExpression */: - case 56 /* EqualsWithTypeConversionExpression */: - case 58 /* EqualsExpression */: - case 59 /* NotEqualsExpression */: - case 60 /* LessThanExpression */: - case 61 /* LessThanOrEqualExpression */: - case 63 /* GreaterThanOrEqualExpression */: - case 62 /* GreaterThanExpression */: - return this.typeCheckLogicalOperation(ast, typeCheckContext); - - case 25 /* CommaExpression */: - return this.typeCheckCommaExpression(ast, typeCheckContext); - - case 64 /* AddExpression */: - case 39 /* AddAssignmentExpression */: - return this.typeCheckBinaryAdditionOperation(ast, typeCheckContext); - - case 65 /* SubtractExpression */: - case 66 /* MultiplyExpression */: - case 67 /* DivideExpression */: - case 68 /* ModuloExpression */: - case 53 /* BitwiseOrExpression */: - case 55 /* BitwiseAndExpression */: - case 69 /* LeftShiftExpression */: - case 70 /* SignedRightShiftExpression */: - case 71 /* UnsignedRightShiftExpression */: - case 54 /* BitwiseExclusiveOrExpression */: - case 45 /* ExclusiveOrAssignmentExpression */: - case 47 /* LeftShiftAssignmentExpression */: - case 48 /* SignedRightShiftAssignmentExpression */: - case 49 /* UnsignedRightShiftAssignmentExpression */: - case 40 /* SubtractAssignmentExpression */: - case 42 /* MultiplyAssignmentExpression */: - case 41 /* DivideAssignmentExpression */: - case 43 /* ModuloAssignmentExpression */: - case 46 /* OrAssignmentExpression */: - case 44 /* AndAssignmentExpression */: - return this.typeCheckBinaryArithmeticOperation(ast, typeCheckContext); - - case 26 /* PlusExpression */: - case 27 /* NegateExpression */: - case 72 /* BitwiseNotExpression */: - case 76 /* PostIncrementExpression */: - case 74 /* PreIncrementExpression */: - case 77 /* PostDecrementExpression */: - case 75 /* PreDecrementExpression */: - return this.typeCheckUnaryArithmeticOperation(ast, typeCheckContext, inContextuallyTypedAssignment); - - case 35 /* ElementAccessExpression */: - return this.typeCheckElementAccessExpression(ast, typeCheckContext); - - case 73 /* LogicalNotExpression */: - return this.typeCheckLogicalNotExpression(ast, typeCheckContext, inContextuallyTypedAssignment); - - case 51 /* LogicalOrExpression */: - case 52 /* LogicalAndExpression */: - return this.typeCheckLogicalAndOrExpression(ast, typeCheckContext); - - case 34 /* TypeOfExpression */: - return this.typeCheckTypeOf(ast, typeCheckContext); - - case 50 /* ConditionalExpression */: - return this.typeCheckConditionalExpression(ast, typeCheckContext); - - case 24 /* VoidExpression */: - return this.typeCheckVoidExpression(ast, typeCheckContext); - - case 95 /* ThrowStatement */: - return this.typeCheckThrowStatement(ast, typeCheckContext); - - case 28 /* DeleteExpression */: - return this.typeCheckDeleteExpression(ast, typeCheckContext); - - case 6 /* RegularExpressionLiteral */: - return this.typeCheckRegExpExpression(ast, typeCheckContext); - - case 31 /* InExpression */: - return this.typeCheckInExpression(ast, typeCheckContext); - - case 33 /* InstanceOfExpression */: - return this.typeCheckInstanceOfExpression(ast, typeCheckContext); - - case 79 /* ParenthesizedExpression */: - return this.typeCheckParenthesizedExpression(ast, typeCheckContext); - - case 90 /* ForStatement */: - return this.typeCheckForStatement(ast, typeCheckContext); - - case 89 /* ForInStatement */: - return this.typeCheckForInStatement(ast, typeCheckContext); - - case 98 /* WhileStatement */: - return this.typeCheckWhileStatement(ast, typeCheckContext); - - case 85 /* DoStatement */: - return this.typeCheckDoStatement(ast, typeCheckContext); - - case 91 /* IfStatement */: - return this.typeCheckIfStatement(ast, typeCheckContext); - - case 81 /* Block */: - return this.typeCheckBlock(ast, typeCheckContext); - - case 18 /* VariableDeclaration */: - return this.typeCheckVariableDeclaration(ast, typeCheckContext); - - case 97 /* VariableStatement */: - return this.typeCheckVariableStatement(ast, typeCheckContext); - - case 99 /* WithStatement */: - return this.typeCheckWithStatement(ast, typeCheckContext); - - case 96 /* TryStatement */: - return this.typeCheckTryStatement(ast, typeCheckContext); - - case 101 /* CatchClause */: - return this.typeCheckCatchClause(ast, typeCheckContext); - - case 93 /* ReturnStatement */: - return this.typeCheckReturnStatement(ast, typeCheckContext); - - case 20 /* Name */: - return this.typeCheckNameExpression(ast, typeCheckContext); - - case 32 /* MemberAccessExpression */: - return this.typeCheckMemberAccessExpression(ast, typeCheckContext); - - case 94 /* SwitchStatement */: - return this.typeCheckSwitchStatement(ast, typeCheckContext); - - case 88 /* ExpressionStatement */: - return this.typeCheckExpressionStatement(ast, typeCheckContext, inContextuallyTypedAssignment); - - case 100 /* CaseClause */: - return this.typeCheckCaseClause(ast, typeCheckContext); - - case 92 /* LabeledStatement */: - return this.typeCheckLabeledStatement(ast, typeCheckContext); - - case 7 /* NumericLiteral */: - return this.semanticInfoChain.numberTypeSymbol; - - case 5 /* StringLiteral */: - return this.semanticInfoChain.stringTypeSymbol; - - case 8 /* NullLiteral */: - return this.semanticInfoChain.nullTypeSymbol; - - case 3 /* TrueLiteral */: - case 4 /* FalseLiteral */: - return this.semanticInfoChain.booleanTypeSymbol; - - case 9 /* TypeParameter */: - return this.typeCheckTypeParameter(ast, typeCheckContext); - - default: - break; - } - - return null; - }; - - PullTypeChecker.prototype.typeCheckScript = function (script, scriptName, compiler) { - var unit = this.semanticInfoChain.getUnit(scriptName); - - if (unit.getTypeChecked()) { - return; - } - - var typeCheckContext = new PullTypeCheckContext(compiler, script, scriptName); - - this.setUnit(scriptName); - - typeCheckContext.semanticInfo = typeCheckContext.compiler.semanticInfoChain.getUnit(typeCheckContext.scriptName); - var scriptDecl = typeCheckContext.semanticInfo.getTopLevelDecls()[0]; - typeCheckContext.pushEnclosingDecl(scriptDecl); - - PullTypeChecker.globalPullTypeCheckPhase++; - - this.typeCheckAST(script.moduleElements, typeCheckContext, false); - - this.validateVariableDeclarationGroups(scriptDecl, typeCheckContext); - - typeCheckContext.popEnclosingDecl(); - - unit.setTypeChecked(); - }; - - PullTypeChecker.prototype.typeCheckList = function (list, typeCheckContext) { - if (!list) { - return null; - } - - for (var i = 0; i < list.members.length; i++) { - this.typeCheckAST(list.members[i], typeCheckContext, false); - } - }; - - PullTypeChecker.prototype.reportDiagnostics = function (symbolAndDiagnostics, enclosingDecl) { - if (symbolAndDiagnostics && symbolAndDiagnostics.diagnostics) { - for (var i = 0, n = symbolAndDiagnostics.diagnostics.length; i < n; i++) { - this.context.postDiagnostic(symbolAndDiagnostics.diagnostics[i], enclosingDecl, true); - } - } - }; - - PullTypeChecker.prototype.resolveSymbolAndReportDiagnostics = function (ast, inContextuallyTypedAssignment, enclosingDecl) { - var symbolAndDiagnostics = this.resolver.resolveAST(ast, inContextuallyTypedAssignment, enclosingDecl, this.context); - - this.reportDiagnostics(symbolAndDiagnostics, enclosingDecl); - return symbolAndDiagnostics && symbolAndDiagnostics.symbol; - }; - - PullTypeChecker.prototype.typeCheckBoundDecl = function (ast, typeCheckContext) { - var _this = this; - var boundDeclAST = ast; - - var enclosingDecl = typeCheckContext.getEnclosingDecl(); - - var typeExprSymbol = null; - - if (boundDeclAST.typeExpr) { - typeExprSymbol = this.typeCheckAST(boundDeclAST.typeExpr, typeCheckContext, false); - - if (typeExprSymbol.isNamedTypeSymbol() && typeExprSymbol.isGeneric() && !typeExprSymbol.isTypeParameter() && !this.resolver.isArrayOrEquivalent(typeExprSymbol) && typeExprSymbol.isResolved() && typeExprSymbol.getTypeParameters().length && typeExprSymbol.getTypeArguments() == null && !typeExprSymbol.getIsSpecialized() && this.resolver.isTypeRefWithoutTypeArgs(boundDeclAST.typeExpr)) { - this.postError(boundDeclAST.typeExpr.minChar, boundDeclAST.typeExpr.getLength(), typeCheckContext.scriptName, 239 /* Generic_type_references_must_include_all_type_arguments */, null, enclosingDecl); - typeExprSymbol = this.resolver.specializeTypeToAny(typeExprSymbol, enclosingDecl, this.context); - } - } - - if (boundDeclAST.init) { - if (typeExprSymbol) { - this.context.pushContextualType(typeExprSymbol, this.context.inProvisionalResolution(), null); - } - - var initTypeSymbol = this.typeCheckAST(boundDeclAST.init, typeCheckContext, !!typeExprSymbol); - - if (typeExprSymbol) { - this.context.popContextualType(); - } - - if (typeExprSymbol && typeExprSymbol.isContainer()) { - var exportedTypeSymbol = (typeExprSymbol).getExportAssignedTypeSymbol(); - - if (exportedTypeSymbol) { - typeExprSymbol = exportedTypeSymbol; - } else { - var instanceTypeSymbol = (typeExprSymbol.getType()).getInstanceSymbol().getType(); - - if (!instanceTypeSymbol || !TypeScript.PullHelpers.symbolIsEnum(instanceTypeSymbol)) { - this.postError(boundDeclAST.minChar, boundDeclAST.getLength(), typeCheckContext.scriptName, 190 /* Tried_to_set_variable_type_to_module_type__0__ */, [typeExprSymbol.toString()], enclosingDecl); - typeExprSymbol = null; - } else { - typeExprSymbol = instanceTypeSymbol.getType(); - } - } - } - - if (initTypeSymbol && initTypeSymbol.isContainer()) { - instanceTypeSymbol = (initTypeSymbol.getType()).getInstanceSymbol().getType(); - - if (!instanceTypeSymbol) { - this.postError(boundDeclAST.minChar, boundDeclAST.getLength(), typeCheckContext.scriptName, 191 /* Tried_to_set_variable_type_to_uninitialized_module_type__0__ */, [initTypeSymbol.toString()], enclosingDecl); - initTypeSymbol = null; - } else { - initTypeSymbol = instanceTypeSymbol.getType(); - } - } - - if (initTypeSymbol && typeExprSymbol) { - var comparisonInfo = new TypeComparisonInfo(); - - var isAssignable = this.resolver.sourceIsAssignableToTarget(initTypeSymbol, typeExprSymbol, this.context, comparisonInfo); - - if (!isAssignable) { - if (comparisonInfo.message) { - this.postError(boundDeclAST.minChar, boundDeclAST.getLength(), typeCheckContext.scriptName, 81 /* Cannot_convert__0__to__1__NL__2 */, [initTypeSymbol.toString(), typeExprSymbol.toString(), comparisonInfo.message], enclosingDecl); - } else { - this.postError(boundDeclAST.minChar, boundDeclAST.getLength(), typeCheckContext.scriptName, 80 /* Cannot_convert__0__to__1_ */, [initTypeSymbol.toString(), typeExprSymbol.toString()], enclosingDecl); - } - } - } - } - - var prevSupressErrors = this.context.suppressErrors; - this.context.suppressErrors = true; - var decl = this.resolver.getDeclForAST(boundDeclAST); - - var varTypeSymbol = this.resolveSymbolAndReportDiagnostics(boundDeclAST, false, enclosingDecl).getType(); - - if (typeExprSymbol && typeExprSymbol.isContainer() && varTypeSymbol.isError()) { - this.checkForResolutionError(varTypeSymbol, decl); - } - - this.context.suppressErrors = prevSupressErrors; - - var declSymbol = decl.getSymbol(); - - if (declSymbol.getKind() != 2048 /* Parameter */ && (declSymbol.getKind() != 4096 /* Property */ || declSymbol.getContainer().isNamedTypeSymbol())) { - this.checkTypePrivacy(declSymbol, varTypeSymbol, typeCheckContext, function (typeSymbol) { - return _this.variablePrivacyErrorReporter(declSymbol, typeSymbol, typeCheckContext); - }); - } - - return varTypeSymbol; - }; - - PullTypeChecker.prototype.typeCheckImportDeclaration = function (importDeclaration, typeCheckContext) { - var result = this.resolveSymbolAndReportDiagnostics(importDeclaration, false, typeCheckContext.getEnclosingDecl()); - - var savedInImportDeclaration = typeCheckContext.inImportDeclaration; - typeCheckContext.inImportDeclaration = true; - this.typeCheckAST(importDeclaration.alias, typeCheckContext, false); - typeCheckContext.inImportDeclaration = savedInImportDeclaration; - - return result; - }; - - PullTypeChecker.prototype.typeCheckFunction = function (funcDeclAST, typeCheckContext, inContextuallyTypedAssignment) { - if (funcDeclAST.isConstructor || TypeScript.hasFlag(funcDeclAST.getFunctionFlags(), 1024 /* ConstructMember */)) { - return this.typeCheckConstructor(funcDeclAST, typeCheckContext, inContextuallyTypedAssignment); - } else if (TypeScript.hasFlag(funcDeclAST.getFunctionFlags(), 4096 /* IndexerMember */)) { - return this.typeCheckIndexer(funcDeclAST, typeCheckContext, inContextuallyTypedAssignment); - } else if (funcDeclAST.isAccessor()) { - return this.typeCheckAccessor(funcDeclAST, typeCheckContext, inContextuallyTypedAssignment); - } - - var enclosingDecl = typeCheckContext.getEnclosingDecl(); - - var functionSymbol = this.resolveSymbolAndReportDiagnostics(funcDeclAST, inContextuallyTypedAssignment, enclosingDecl); - var functionDecl = typeCheckContext.semanticInfo.getDeclForAST(funcDeclAST); - - typeCheckContext.pushEnclosingDecl(functionDecl); - - this.typeCheckAST(funcDeclAST.typeArguments, typeCheckContext, inContextuallyTypedAssignment); - this.typeCheckAST(funcDeclAST.arguments, typeCheckContext, inContextuallyTypedAssignment); - this.typeCheckAST(funcDeclAST.returnTypeAnnotation, typeCheckContext, false); - this.typeCheckAST(funcDeclAST.block, typeCheckContext, false); - - var hasReturn = typeCheckContext.getEnclosingDeclHasReturn(); - - this.validateVariableDeclarationGroups(functionDecl, typeCheckContext); - - typeCheckContext.popEnclosingDecl(); - - var functionSignature = functionDecl.getSignatureSymbol(); - - var parameters = functionSignature.getParameters(); - - if (parameters.length) { - for (var i = 0; i < parameters.length; i++) { - this.checkForResolutionError(parameters[i].getType(), enclosingDecl); - } - } - - var returnType = functionSignature.getReturnType(); - - this.checkForResolutionError(returnType, enclosingDecl); - - if (funcDeclAST.block && funcDeclAST.returnTypeAnnotation != null && !hasReturn) { - var isVoidOrAny = this.resolver.isAnyOrEquivalent(returnType) || returnType === this.semanticInfoChain.voidTypeSymbol; - - if (!isVoidOrAny && !(funcDeclAST.block.statements.members.length > 0 && funcDeclAST.block.statements.members[0].nodeType === 95 /* ThrowStatement */)) { - var funcName = functionDecl.getDisplayName(); - funcName = funcName ? "'" + funcName + "'" : "expression"; - - this.postError(funcDeclAST.returnTypeAnnotation.minChar, funcDeclAST.returnTypeAnnotation.getLength(), typeCheckContext.scriptName, 192 /* Function__0__declared_a_non_void_return_type__but_has_no_return_expression */, [funcName], typeCheckContext.getEnclosingDecl()); - } - } - - this.typeCheckFunctionOverloads(funcDeclAST, typeCheckContext); - this.checkFunctionTypePrivacy(funcDeclAST, inContextuallyTypedAssignment, typeCheckContext); - - return functionSymbol ? functionSymbol.getType() : null; - }; - - PullTypeChecker.prototype.typeCheckFunctionOverloads = function (funcDecl, typeCheckContext, signature, allSignatures) { - if (!signature) { - var functionSignatureInfo = TypeScript.PullHelpers.getSignatureForFuncDecl(funcDecl, typeCheckContext.semanticInfo); - signature = functionSignatureInfo.signature; - allSignatures = functionSignatureInfo.allSignatures; - } - var functionDeclaration = typeCheckContext.semanticInfo.getDeclForAST(funcDecl); - var funcSymbol = functionDeclaration.getSymbol(); - - var definitionSignature = null; - for (var i = allSignatures.length - 1; i >= 0; i--) { - if (allSignatures[i].isDefinition()) { - definitionSignature = allSignatures[i]; - break; - } - } - - if (!signature.isDefinition()) { - for (var i = 0; i < allSignatures.length; i++) { - if (allSignatures[i] === signature) { - break; - } - - if (this.resolver.signaturesAreIdentical(allSignatures[i], signature)) { - if (funcDecl.isConstructor) { - this.postError(funcDecl.minChar, funcDecl.getLength(), typeCheckContext.scriptName, 210 /* Duplicate_constructor_overload_signature */, null, typeCheckContext.getEnclosingDecl()); - } else if (funcDecl.isConstructMember()) { - this.postError(funcDecl.minChar, funcDecl.getLength(), typeCheckContext.scriptName, 212 /* Duplicate_overload_construct_signature */, null, typeCheckContext.getEnclosingDecl()); - } else if (funcDecl.isCallMember()) { - this.postError(funcDecl.minChar, funcDecl.getLength(), typeCheckContext.scriptName, 211 /* Duplicate_overload_call_signature */, null, typeCheckContext.getEnclosingDecl()); - } else { - this.postError(funcDecl.minChar, funcDecl.getLength(), typeCheckContext.scriptName, 209 /* Duplicate_overload_signature_for__0_ */, [funcSymbol.getScopedNameEx().toString()], typeCheckContext.getEnclosingDecl()); - } - - break; - } - } - } - - var isConstantOverloadSignature = signature.isStringConstantOverloadSignature(); - if (isConstantOverloadSignature) { - if (signature.isDefinition()) { - this.postError(funcDecl.minChar, funcDecl.getLength(), typeCheckContext.scriptName, 229 /* Overload_signature_implementation_cannot_use_specialized_type */, null, typeCheckContext.getEnclosingDecl()); - } else { - var resolutionContext = new TypeScript.PullTypeResolutionContext(); - var foundSubtypeSignature = false; - for (var i = 0; i < allSignatures.length; i++) { - if (allSignatures[i].isDefinition() || allSignatures[i] === signature) { - continue; - } - - if (!allSignatures[i].isResolved()) { - this.resolver.resolveDeclaredSymbol(allSignatures[i], typeCheckContext.getEnclosingDecl(), resolutionContext); - } - - if (allSignatures[i].isStringConstantOverloadSignature()) { - continue; - } - - if (this.resolver.signatureIsSubtypeOfTarget(signature, allSignatures[i], resolutionContext)) { - foundSubtypeSignature = true; - break; - } - } - - if (!foundSubtypeSignature) { - this.postError(funcDecl.minChar, funcDecl.getLength(), typeCheckContext.scriptName, 219 /* Specialized_overload_signature_is_not_subtype_of_any_non_specialized_signature */, null, typeCheckContext.getEnclosingDecl()); - } - } - } else if (definitionSignature && definitionSignature != signature) { - var comparisonInfo = new TypeComparisonInfo(); - var resolutionContext = new TypeScript.PullTypeResolutionContext(); - if (!definitionSignature.isResolved()) { - this.resolver.resolveDeclaredSymbol(definitionSignature, typeCheckContext.getEnclosingDecl(), resolutionContext); - } - - if (!this.resolver.signatureIsAssignableToTarget(definitionSignature, signature, resolutionContext, comparisonInfo)) { - if (comparisonInfo.message) { - this.postError(funcDecl.minChar, funcDecl.getLength(), typeCheckContext.scriptName, 214 /* Overload_signature_is_not_compatible_with_function_definition__NL__0 */, [comparisonInfo.message], typeCheckContext.getEnclosingDecl()); - } else { - this.postError(funcDecl.minChar, funcDecl.getLength(), typeCheckContext.scriptName, 213 /* Overload_signature_is_not_compatible_with_function_definition */, null, typeCheckContext.getEnclosingDecl()); - } - } - } - - var signatureForVisibilityCheck = definitionSignature; - if (!definitionSignature) { - if (allSignatures[0] === signature) { - return; - } - signatureForVisibilityCheck = allSignatures[0]; - } - - if (!funcDecl.isConstructor && !funcDecl.isConstructMember() && signature != signatureForVisibilityCheck) { - var errorCode; - - if (signatureForVisibilityCheck.hasFlag(2 /* Private */) != signature.hasFlag(2 /* Private */)) { - errorCode = 215 /* Overload_signatures_must_all_be_public_or_private */; - } else if (signatureForVisibilityCheck.hasFlag(1 /* Exported */) != signature.hasFlag(1 /* Exported */)) { - errorCode = 216 /* Overload_signatures_must_all_be_exported_or_local */; - } else if (signatureForVisibilityCheck.hasFlag(8 /* Ambient */) != signature.hasFlag(8 /* Ambient */)) { - errorCode = 217 /* Overload_signatures_must_all_be_ambient_or_non_ambient */; - } else if (signatureForVisibilityCheck.hasFlag(128 /* Optional */) != signature.hasFlag(128 /* Optional */)) { - errorCode = 218 /* Overload_signatures_must_all_be_optional_or_required */; - } - - if (errorCode) { - this.postError(funcDecl.minChar, funcDecl.getLength(), typeCheckContext.scriptName, errorCode, null, typeCheckContext.getEnclosingDecl()); - } - } - }; - - PullTypeChecker.prototype.typeCheckTypeParameter = function (typeParameter, typeCheckContext) { - if (typeParameter.constraint) { - var constraintType = this.typeCheckAST(typeParameter.constraint, typeCheckContext, false); - - if (constraintType && !constraintType.isError() && constraintType.isPrimitive()) { - this.postError(typeParameter.constraint.minChar, typeParameter.constraint.getLength(), typeCheckContext.scriptName, 149 /* Type_parameter_constraint_cannot_be_a_primitive_type */, null, typeCheckContext.getEnclosingDecl()); - } - } - - return this.resolveSymbolAndReportDiagnostics(typeParameter, false, typeCheckContext.getEnclosingDecl()); - }; - - PullTypeChecker.prototype.typeCheckAccessor = function (ast, typeCheckContext, inContextuallyTypedAssignment) { - var funcDeclAST = ast; - - var enclosingDecl = typeCheckContext.getEnclosingDecl(); - - var accessorSymbol = this.resolveSymbolAndReportDiagnostics(ast, inContextuallyTypedAssignment, enclosingDecl); - this.checkForResolutionError(accessorSymbol.getType(), enclosingDecl); - - var isGetter = TypeScript.hasFlag(funcDeclAST.getFunctionFlags(), 32 /* GetAccessor */); - var isSetter = !isGetter; - - var getter = accessorSymbol.getGetter(); - var setter = accessorSymbol.getSetter(); - - var functionDecl = typeCheckContext.semanticInfo.getDeclForAST(funcDeclAST); - typeCheckContext.pushEnclosingDecl(functionDecl); - - this.typeCheckAST(funcDeclAST.arguments, typeCheckContext, inContextuallyTypedAssignment); - - this.typeCheckAST(funcDeclAST.block, typeCheckContext, false); - - var hasReturn = typeCheckContext.getEnclosingDeclHasReturn(); - - this.validateVariableDeclarationGroups(functionDecl, typeCheckContext); - - typeCheckContext.popEnclosingDecl(); - - var functionSignature = functionDecl.getSignatureSymbol(); - - var parameters = functionSignature.getParameters(); - - var returnType = functionSignature.getReturnType(); - - this.checkForResolutionError(returnType, enclosingDecl); - - var funcNameAST = funcDeclAST.name; - - if (isGetter && !hasReturn) { - if (!(funcDeclAST.block.statements.members.length > 0 && funcDeclAST.block.statements.members[0].nodeType === 95 /* ThrowStatement */)) { - this.postError(funcNameAST.minChar, funcNameAST.getLength(), typeCheckContext.scriptName, 193 /* Getters_must_return_a_value */, null, typeCheckContext.getEnclosingDecl()); - } - } - - if (getter && setter) { - var getterDecl = getter.getDeclarations()[0]; - var setterDecl = setter.getDeclarations()[0]; - - var getterIsPrivate = getterDecl.getFlags() & 2 /* Private */; - var setterIsPrivate = setterDecl.getFlags() & 2 /* Private */; - - if (getterIsPrivate != setterIsPrivate) { - this.postError(funcNameAST.minChar, funcNameAST.getLength(), typeCheckContext.scriptName, 194 /* Getter_and_setter_accessors_do_not_agree_in_visibility */, null, typeCheckContext.getEnclosingDecl()); - } - } - - this.checkFunctionTypePrivacy(funcDeclAST, inContextuallyTypedAssignment, typeCheckContext); - - return null; - }; - - PullTypeChecker.prototype.typeCheckConstructor = function (funcDeclAST, typeCheckContext, inContextuallyTypedAssignment) { - var enclosingDecl = typeCheckContext.getEnclosingDecl(); - - var functionSymbol = this.resolveSymbolAndReportDiagnostics(funcDeclAST, inContextuallyTypedAssignment, enclosingDecl); - - var functionDecl = typeCheckContext.semanticInfo.getDeclForAST(funcDeclAST); - typeCheckContext.pushEnclosingDecl(functionDecl); - - this.typeCheckAST(funcDeclAST.typeArguments, typeCheckContext, inContextuallyTypedAssignment); - - typeCheckContext.inConstructorArguments = true; - this.typeCheckAST(funcDeclAST.arguments, typeCheckContext, inContextuallyTypedAssignment); - typeCheckContext.inConstructorArguments = false; - - typeCheckContext.seenSuperConstructorCall = false; - - this.typeCheckAST(funcDeclAST.returnTypeAnnotation, typeCheckContext, false); - - this.typeCheckAST(funcDeclAST.block, typeCheckContext, false); - - this.validateVariableDeclarationGroups(functionDecl, typeCheckContext); - - typeCheckContext.popEnclosingDecl(); - - var constructorSignature = functionDecl.getSignatureSymbol(); - - var parameters = constructorSignature.getParameters(); - - if (parameters.length) { - for (var i = 0, n = parameters.length; i < n; i++) { - this.checkForResolutionError(parameters[i].getType(), enclosingDecl); - } - } - - this.checkForResolutionError(constructorSignature.getReturnType(), enclosingDecl); - - if (functionDecl.getSignatureSymbol() && functionDecl.getSignatureSymbol().isDefinition() && this.enclosingClassIsDerived(typeCheckContext)) { - if (!typeCheckContext.seenSuperConstructorCall) { - this.postError(funcDeclAST.minChar, 11, typeCheckContext.scriptName, 173 /* Constructors_for_derived_classes_must_contain_a__super__call */, null, enclosingDecl); - } else if (this.superCallMustBeFirstStatementInConstructor(functionDecl, enclosingDecl)) { - var firstStatement = this.getFirstStatementFromFunctionDeclAST(funcDeclAST); - if (!firstStatement || !this.isSuperCallNode(firstStatement)) { - this.postError(funcDeclAST.minChar, 11, typeCheckContext.scriptName, 172 /* A__super__call_must_be_the_first_statement_in_the_constructor_when_a_class_contains_intialized_properties_or_has_parameter_properties */, null, enclosingDecl); - } - } - } - - this.typeCheckFunctionOverloads(funcDeclAST, typeCheckContext); - this.checkFunctionTypePrivacy(funcDeclAST, inContextuallyTypedAssignment, typeCheckContext); - return functionSymbol ? functionSymbol.getType() : null; - }; - - PullTypeChecker.prototype.typeCheckIndexer = function (ast, typeCheckContext, inContextuallyTypedAssignment) { - var enclosingDecl = typeCheckContext.getEnclosingDecl(); - - this.resolver.resolveAST(ast, inContextuallyTypedAssignment, enclosingDecl, this.context); - - var funcDeclAST = ast; - - var functionDecl = typeCheckContext.semanticInfo.getDeclForAST(funcDeclAST); - typeCheckContext.pushEnclosingDecl(functionDecl); - - this.typeCheckAST(funcDeclAST.arguments, typeCheckContext, false); - - this.typeCheckAST(funcDeclAST.returnTypeAnnotation, typeCheckContext, false); - - typeCheckContext.popEnclosingDecl(); - - var indexSignature = functionDecl.getSignatureSymbol(); - var parameters = indexSignature.getParameters(); - - if (parameters.length) { - var parameterType = null; - - for (var i = 0; i < parameters.length; i++) { - this.checkForResolutionError(parameters[i].getType(), enclosingDecl); - } - } - - this.checkForResolutionError(indexSignature.getReturnType(), enclosingDecl); - this.checkFunctionTypePrivacy(funcDeclAST, inContextuallyTypedAssignment, typeCheckContext); - - var isNumericIndexer = parameters[0].getType() === this.semanticInfoChain.numberTypeSymbol; - - var allIndexSignatures = enclosingDecl.getSymbol().getType().getIndexSignatures(); - for (var i = 0; i < allIndexSignatures.length; i++) { - if (!allIndexSignatures[i].isResolved()) { - this.resolver.resolveDeclaredSymbol(allIndexSignatures[i], allIndexSignatures[i].getDeclarations()[0].getParentDecl(), this.context); - } - if (allIndexSignatures[i].getParameters()[0].getType() !== parameters[0].getType()) { - var stringIndexSignature; - var numberIndexSignature; - if (isNumericIndexer) { - numberIndexSignature = indexSignature; - stringIndexSignature = allIndexSignatures[i]; - } else { - numberIndexSignature = allIndexSignatures[i]; - stringIndexSignature = indexSignature; - - if (enclosingDecl.getSymbol() === numberIndexSignature.getDeclarations()[0].getParentDecl().getSymbol()) { - break; - } - } - var comparisonInfo = new TypeComparisonInfo(); - var resolutionContext = new TypeScript.PullTypeResolutionContext(); - if (!this.resolver.sourceIsSubtypeOfTarget(numberIndexSignature.getReturnType(), stringIndexSignature.getReturnType(), resolutionContext, comparisonInfo)) { - if (comparisonInfo.message) { - this.postError(funcDeclAST.minChar, funcDeclAST.getLength(), typeCheckContext.scriptName, 234 /* Numeric_indexer_type___0___must_be_a_subtype_of_string_indexer_type___1____NL__2 */, [numberIndexSignature.getReturnType().toString(), stringIndexSignature.getReturnType().toString(), comparisonInfo.message], typeCheckContext.getEnclosingDecl()); - } else { - this.postError(funcDeclAST.minChar, funcDeclAST.getLength(), typeCheckContext.scriptName, 233 /* Numeric_indexer_type___0___must_be_a_subtype_of_string_indexer_type___1__ */, [numberIndexSignature.getReturnType().toString(), stringIndexSignature.getReturnType().toString()], typeCheckContext.getEnclosingDecl()); - } - } - break; - } - } - - var allMembers = enclosingDecl.getSymbol().getType().getAllMembers(TypeScript.PullElementKind.All, true); - for (var i = 0; i < allMembers.length; i++) { - var name = allMembers[i].getName(); - if (name) { - if (!allMembers[i].isResolved()) { - this.resolver.resolveDeclaredSymbol(allMembers[i], allMembers[i].getDeclarations()[0].getParentDecl(), this.context); - } - - if (enclosingDecl.getSymbol() !== allMembers[i].getContainer()) { - var isMemberNumeric = isFinite(+name); - if (isNumericIndexer === isMemberNumeric) { - this.checkThatMemberIsSubtypeOfIndexer(allMembers[i], indexSignature, funcDeclAST, typeCheckContext, isNumericIndexer); - } - } - } - } - - return null; - }; - - PullTypeChecker.prototype.typeCheckMembersAgainstIndexer = function (containerType, typeCheckContext) { - var indexSignatures = containerType.getIndexSignatures(); - if (indexSignatures.length > 0) { - var members = typeCheckContext.getEnclosingDecl().getChildDecls(); - for (var i = 0; i < members.length; i++) { - var member = members[i]; - if (!member.getName() || member.getKind() & TypeScript.PullElementKind.SomeSignature) { - continue; - } - - var isMemberNumeric = isFinite(+member.getName()); - for (var j = 0; j < indexSignatures.length; j++) { - if (!indexSignatures[j].isResolved()) { - this.resolver.resolveDeclaredSymbol(indexSignatures[j], indexSignatures[j].getDeclarations()[0].getParentDecl(), this.context); - } - if ((indexSignatures[j].getParameters()[0].getType() === this.semanticInfoChain.numberTypeSymbol) === isMemberNumeric) { - this.checkThatMemberIsSubtypeOfIndexer(member.getSymbol(), indexSignatures[j], this.semanticInfoChain.getASTForDecl(member), typeCheckContext, isMemberNumeric); - break; - } - } - } - } - }; - - PullTypeChecker.prototype.checkThatMemberIsSubtypeOfIndexer = function (member, indexSignature, astForError, typeCheckContext, isNumeric) { - var comparisonInfo = new TypeComparisonInfo(); - var resolutionContext = new TypeScript.PullTypeResolutionContext(); - if (!this.resolver.sourceIsSubtypeOfTarget(member.getType(), indexSignature.getReturnType(), resolutionContext, comparisonInfo)) { - if (isNumeric) { - if (comparisonInfo.message) { - this.postError(astForError.minChar, astForError.getLength(), typeCheckContext.scriptName, 236 /* All_numerically_named_properties_must_be_subtypes_of_numeric_indexer_type___0____NL__1 */, [indexSignature.getReturnType().toString(), comparisonInfo.message], typeCheckContext.getEnclosingDecl()); - } else { - this.postError(astForError.minChar, astForError.getLength(), typeCheckContext.scriptName, 235 /* All_numerically_named_properties_must_be_subtypes_of_numeric_indexer_type___0__ */, [indexSignature.getReturnType().toString()], typeCheckContext.getEnclosingDecl()); - } - } else { - if (comparisonInfo.message) { - this.postError(astForError.minChar, astForError.getLength(), typeCheckContext.scriptName, 238 /* All_named_properties_must_be_subtypes_of_string_indexer_type___0____NL__1 */, [indexSignature.getReturnType().toString(), comparisonInfo.message], typeCheckContext.getEnclosingDecl()); - } else { - this.postError(astForError.minChar, astForError.getLength(), typeCheckContext.scriptName, 237 /* All_named_properties_must_be_subtypes_of_string_indexer_type___0__ */, [indexSignature.getReturnType().toString()], typeCheckContext.getEnclosingDecl()); - } - } - } - }; - - PullTypeChecker.prototype.typeCheckIfTypeMemberPropertyOkToOverride = function (typeSymbol, extendedType, typeMember, extendedTypeMember, comparisonInfo) { - if (!typeSymbol.isClass()) { - return true; - } - - var typeMemberKind = typeMember.getKind(); - var extendedMemberKind = extendedTypeMember.getKind(); - - if (typeMemberKind === extendedMemberKind) { - return true; - } - - var errorCode; - if (typeMemberKind === 4096 /* Property */) { - if (typeMember.isAccessor()) { - errorCode = 256 /* Class__0__defines_instance_member_accessor__1___but_extended_class__2__defines_it_as_instance_member_function */; - } else { - errorCode = 257 /* Class__0__defines_instance_member_property__1___but_extended_class__2__defines_it_as_instance_member_function */; - } - } else if (typeMemberKind === 65536 /* Method */) { - if (extendedTypeMember.isAccessor()) { - errorCode = 258 /* Class__0__defines_instance_member_function__1___but_extended_class__2__defines_it_as_instance_member_accessor */; - } else { - errorCode = 259 /* Class__0__defines_instance_member_function__1___but_extended_class__2__defines_it_as_instance_member_property */; - } - } - - var message = TypeScript.getDiagnosticMessage(errorCode, [typeSymbol.toString(), typeMember.getScopedNameEx().toString(), extendedType.toString()]); - comparisonInfo.addMessage(message); - return false; - }; - - PullTypeChecker.prototype.typeCheckIfTypeExtendsType = function (typeDecl, typeSymbol, extendedType, typeCheckContext) { - var typeMembers = typeSymbol.getMembers(); - - var resolutionContext = new TypeScript.PullTypeResolutionContext(); - var comparisonInfo = new TypeComparisonInfo(); - var foundError = false; - - for (var i = 0; i < typeMembers.length; i++) { - var propName = typeMembers[i].getName(); - var extendedTypeProp = extendedType.findMember(propName); - if (extendedTypeProp) { - foundError = !this.typeCheckIfTypeMemberPropertyOkToOverride(typeSymbol, extendedType, typeMembers[i], extendedTypeProp, comparisonInfo); - - if (!foundError) { - foundError = !this.resolver.sourcePropertyIsSubtypeOfTargetProperty(typeSymbol, extendedType, typeMembers[i], extendedTypeProp, resolutionContext, comparisonInfo); - } - - if (foundError) { - break; - } - } - } - - if (!foundError && typeSymbol.hasOwnCallSignatures()) { - foundError = !this.resolver.sourceCallSignaturesAreSubtypeOfTargetCallSignatures(typeSymbol, extendedType, resolutionContext, comparisonInfo); - } - - if (!foundError && typeSymbol.hasOwnConstructSignatures()) { - foundError = !this.resolver.sourceConstructSignaturesAreSubtypeOfTargetConstructSignatures(typeSymbol, extendedType, resolutionContext, comparisonInfo); - } - - if (!foundError && typeSymbol.hasOwnIndexSignatures()) { - foundError = !this.resolver.sourceIndexSignaturesAreSubtypeOfTargetIndexSignatures(typeSymbol, extendedType, resolutionContext, comparisonInfo); - } - - if (!foundError && typeSymbol.isClass()) { - var typeConstructorType = (typeSymbol).getConstructorMethod().getType(); - var typeConstructorTypeMembers = typeConstructorType.getMembers(); - if (typeConstructorTypeMembers.length) { - var extendedConstructorType = (extendedType).getConstructorMethod().getType(); - var comparisonInfoForPropTypeCheck = new TypeComparisonInfo(comparisonInfo); - - for (var i = 0; i < typeConstructorTypeMembers.length; i++) { - var propName = typeConstructorTypeMembers[i].getName(); - var extendedConstructorTypeProp = extendedConstructorType.findMember(propName); - if (extendedConstructorTypeProp) { - if (!extendedConstructorTypeProp.isResolved()) { - var extendedClassAst = typeCheckContext.semanticInfo.getASTForSymbol(extendedType); - var extendedClassDecl = typeCheckContext.semanticInfo.getDeclForAST(extendedClassAst); - this.resolver.resolveDeclaredSymbol(extendedConstructorTypeProp, extendedClassDecl, resolutionContext); - } - - var typeConstructorTypePropType = typeConstructorTypeMembers[i].getType(); - var extendedConstructorTypePropType = extendedConstructorTypeProp.getType(); - if (!this.resolver.sourceIsSubtypeOfTarget(typeConstructorTypePropType, extendedConstructorTypePropType, resolutionContext, comparisonInfoForPropTypeCheck)) { - var propMessage; - if (comparisonInfoForPropTypeCheck.message) { - propMessage = TypeScript.getDiagnosticMessage(261 /* Types_of_static_property__0__of_class__1__and_class__2__are_incompatible__NL__3 */, [extendedConstructorTypeProp.getScopedNameEx().toString(), typeSymbol.toString(), extendedType.toString(), comparisonInfoForPropTypeCheck.message]); - } else { - propMessage = TypeScript.getDiagnosticMessage(260 /* Types_of_static_property__0__of_class__1__and_class__2__are_incompatible */, [extendedConstructorTypeProp.getScopedNameEx().toString(), typeSymbol.toString(), extendedType.toString()]); - } - comparisonInfo.addMessage(propMessage); - foundError = true; - break; - } - } - } - } - } - - if (foundError) { - var errorCode; - if (typeSymbol.isClass()) { - errorCode = 206 /* Class__0__cannot_extend_class__1__NL__2 */; - } else { - if (extendedType.isClass()) { - errorCode = 207 /* Interface__0__cannot_extend_class__1__NL__2 */; - } else { - errorCode = 208 /* Interface__0__cannot_extend_interface__1__NL__2 */; - } - } - - this.postError(typeDecl.name.minChar, typeDecl.name.getLength(), typeCheckContext.scriptName, errorCode, [typeSymbol.getScopedName(), extendedType.getScopedName(), comparisonInfo.message], typeCheckContext.getEnclosingDecl()); - } - }; - - PullTypeChecker.prototype.typeCheckIfClassImplementsType = function (classDecl, classSymbol, implementedType, typeCheckContext) { - var resolutionContext = new TypeScript.PullTypeResolutionContext(); - var comparisonInfo = new TypeComparisonInfo(); - var foundError = !this.resolver.sourceMembersAreSubtypeOfTargetMembers(classSymbol, implementedType, resolutionContext, comparisonInfo); - if (!foundError) { - foundError = !this.resolver.sourceCallSignaturesAreSubtypeOfTargetCallSignatures(classSymbol, implementedType, resolutionContext, comparisonInfo); - if (!foundError) { - foundError = !this.resolver.sourceConstructSignaturesAreSubtypeOfTargetConstructSignatures(classSymbol, implementedType, resolutionContext, comparisonInfo); - if (!foundError) { - foundError = !this.resolver.sourceIndexSignaturesAreSubtypeOfTargetIndexSignatures(classSymbol, implementedType, resolutionContext, comparisonInfo); - } - } - } - - if (foundError) { - var errorCode = implementedType.isClass() ? 203 /* Class__0__declares_class__1__but_does_not_implement_it__NL__2 */ : 202 /* Class__0__declares_interface__1__but_does_not_implement_it__NL__2 */; - - this.postError(classDecl.name.minChar, classDecl.name.getLength(), typeCheckContext.scriptName, errorCode, [classSymbol.getScopedName(), implementedType.getScopedName(), comparisonInfo.message], typeCheckContext.getEnclosingDecl()); - } - }; - - PullTypeChecker.prototype.typeCheckBase = function (typeDeclAst, typeSymbol, baseDeclAST, isExtendedType, typeCheckContext) { - var _this = this; - var typeDecl = typeCheckContext.semanticInfo.getDeclForAST(typeDeclAst); - var contextForBaseTypeResolution = new TypeScript.PullTypeResolutionContext(); - contextForBaseTypeResolution.isResolvingClassExtendedType = true; - - var baseType = this.typeCheckAST(new TypeScript.TypeReference(baseDeclAST, 0), typeCheckContext, false); - contextForBaseTypeResolution.isResolvingClassExtendedType = false; - - var typeDeclIsClass = typeSymbol.isClass(); - - if (!typeSymbol.isValidBaseKind(baseType, isExtendedType)) { - if (baseType.isError()) { - var error = (baseType).getDiagnostic(); - if (error) { - this.postError(baseDeclAST.minChar, baseDeclAST.getLength(), typeCheckContext.scriptName, error.diagnosticCode(), error.arguments(), typeCheckContext.getEnclosingDecl()); - } - } else if (isExtendedType) { - if (typeDeclIsClass) { - this.postError(baseDeclAST.minChar, baseDeclAST.getLength(), typeCheckContext.scriptName, 142 /* A_class_may_only_extend_another_class */, null, typeCheckContext.getEnclosingDecl()); - } else { - this.postError(baseDeclAST.minChar, baseDeclAST.getLength(), typeCheckContext.scriptName, 144 /* An_interface_may_only_extend_another_class_or_interface */, null, typeCheckContext.getEnclosingDecl()); - } - } else { - this.postError(baseDeclAST.minChar, baseDeclAST.getLength(), typeCheckContext.scriptName, 143 /* A_class_may_only_implement_another_class_or_interface */, null, typeCheckContext.getEnclosingDecl()); - } - return; - } - - if ((baseType.getRootSymbol()).hasBase(typeSymbol.getRootSymbol())) { - typeSymbol.setHasBaseTypeConflict(); - baseType.setHasBaseTypeConflict(); - - this.postError(typeDeclAst.name.minChar, typeDeclAst.name.getLength(), typeCheckContext.scriptName, typeDeclIsClass ? 168 /* Class__0__is_recursively_referenced_as_a_base_type_of_itself */ : 169 /* Interface__0__is_recursively_referenced_as_a_base_type_of_itself */, [typeSymbol.getScopedName()], typeCheckContext.getEnclosingDecl()); - return; - } - - if (isExtendedType) { - this.typeCheckIfTypeExtendsType(typeDeclAst, typeSymbol, baseType, typeCheckContext); - } else { - this.typeCheckIfClassImplementsType(typeDeclAst, typeSymbol, baseType, typeCheckContext); - } - - this.checkTypePrivacy(typeSymbol, baseType, typeCheckContext, function (errorTypeSymbol) { - return _this.baseListPrivacyErrorReporter(typeDeclAst, typeSymbol, baseDeclAST, isExtendedType, errorTypeSymbol, typeCheckContext); - }); - }; - - PullTypeChecker.prototype.typeCheckBases = function (typeDeclAst, typeSymbol, typeCheckContext) { - if (!typeDeclAst.extendsList && !typeDeclAst.implementsList) { - return; - } - - for (var i = 0; i < typeDeclAst.extendsList.members.length; i++) { - this.typeCheckBase(typeDeclAst, typeSymbol, typeDeclAst.extendsList.members[i], true, typeCheckContext); - } - - if (typeSymbol.isClass()) { - for (var i = 0; i < typeDeclAst.implementsList.members.length; i++) { - this.typeCheckBase(typeDeclAst, typeSymbol, typeDeclAst.implementsList.members[i], false, typeCheckContext); - } - } else if (typeDeclAst.implementsList) { - this.postError(typeDeclAst.implementsList.minChar, typeDeclAst.implementsList.getLength(), typeCheckContext.scriptName, 145 /* An_interface_cannot_implement_another_type */, null, typeCheckContext.getEnclosingDecl()); - } - }; - - PullTypeChecker.prototype.typeCheckClass = function (ast, typeCheckContext) { - var classAST = ast; - - var classSymbol = this.resolveSymbolAndReportDiagnostics(ast, false, typeCheckContext.getEnclosingDecl()).getType(); - this.checkForResolutionError(classSymbol, typeCheckContext.getEnclosingDecl()); - - this.typeCheckAST(classAST.typeParameters, typeCheckContext, false); - - var classDecl = typeCheckContext.semanticInfo.getDeclForAST(classAST); - typeCheckContext.pushEnclosingDecl(classDecl); - - this.typeCheckAST(classAST.typeParameters, typeCheckContext, false); - - this.typeCheckBases(classAST, classSymbol, typeCheckContext); - - this.typeCheckAST(classAST.members, typeCheckContext, false); - - if (!classSymbol.hasBaseTypeConflict()) { - this.typeCheckMembersAgainstIndexer(classSymbol, typeCheckContext); - } - - typeCheckContext.popEnclosingDecl(); - - return classSymbol; - }; - - PullTypeChecker.prototype.typeCheckInterface = function (ast, typeCheckContext) { - var interfaceAST = ast; - - var interfaceType = this.resolveSymbolAndReportDiagnostics(ast, false, typeCheckContext.getEnclosingDecl()).getType(); - this.checkForResolutionError(interfaceType, typeCheckContext.getEnclosingDecl()); - - var interfaceDecl = typeCheckContext.semanticInfo.getDeclForAST(interfaceAST); - typeCheckContext.pushEnclosingDecl(interfaceDecl); - - this.typeCheckAST(interfaceAST.typeParameters, typeCheckContext, false); - - this.typeCheckBases(ast, interfaceType, typeCheckContext); - - this.typeCheckAST(interfaceAST.members, typeCheckContext, false); - - if (!interfaceType.hasBaseTypeConflict()) { - this.typeCheckMembersAgainstIndexer(interfaceType, typeCheckContext); - } - - typeCheckContext.popEnclosingDecl(); - - return interfaceType; - }; - - PullTypeChecker.prototype.typeCheckModule = function (ast, typeCheckContext) { - var moduleDeclAST = ast; - var moduleType = this.resolveSymbolAndReportDiagnostics(ast, false, typeCheckContext.getEnclosingDecl()); - - this.checkForResolutionError(moduleType, typeCheckContext.getEnclosingDecl()); - - var moduleDecl = typeCheckContext.semanticInfo.getDeclForAST(moduleDeclAST); - typeCheckContext.pushEnclosingDecl(moduleDecl); - - var modName = (moduleDeclAST.name).text; - var isDynamic = TypeScript.isQuoted(modName) || TypeScript.hasFlag(moduleDeclAST.getModuleFlags(), 512 /* IsDynamic */); - - if (isDynamic && moduleDeclAST.members && moduleDeclAST.members.members) { - for (var i = moduleDeclAST.members.members.length - 1; i >= 0; i--) { - if (moduleDeclAST.members.members[i] && moduleDeclAST.members.members[i].nodeType == 87 /* ExportAssignment */) { - this.typeCheckAST(moduleDeclAST.members.members[i], typeCheckContext, false); - break; - } - } - } - this.typeCheckAST(moduleDeclAST.members, typeCheckContext, false); - - this.validateVariableDeclarationGroups(moduleDecl, typeCheckContext); - - typeCheckContext.popEnclosingDecl(); - - return moduleType; - }; - - PullTypeChecker.prototype.checkAssignability = function (ast, source, target, typeCheckContext) { - var comparisonInfo = new TypeComparisonInfo(); - - var isAssignable = this.resolver.sourceIsAssignableToTarget(source, target, this.context, comparisonInfo); - - if (!isAssignable) { - var enclosingDecl = typeCheckContext.getEnclosingDecl(); - if (comparisonInfo.message) { - this.postError(ast.minChar, ast.getLength(), typeCheckContext.scriptName, 81 /* Cannot_convert__0__to__1__NL__2 */, [source.toString(), target.toString(), comparisonInfo.message], enclosingDecl); - } else { - this.postError(ast.minChar, ast.getLength(), typeCheckContext.scriptName, 80 /* Cannot_convert__0__to__1_ */, [source.toString(), target.toString()], enclosingDecl); - } - } - }; - - PullTypeChecker.prototype.isValidLHS = function (ast, expressionSymbol) { - var expressionTypeSymbol = expressionSymbol.getType(); - - if (ast.nodeType === 35 /* ElementAccessExpression */ || this.resolver.isAnyOrEquivalent(expressionTypeSymbol)) { - return true; - } else if (!expressionSymbol.isType() || expressionTypeSymbol.isArray()) { - return ((expressionSymbol.getKind() & TypeScript.PullElementKind.SomeLHS) != 0) && !expressionSymbol.hasFlag(4096 /* Enum */); - } - - return false; - }; - - PullTypeChecker.prototype.typeCheckAssignment = function (binaryExpression, typeCheckContext) { - var enclosingDecl = typeCheckContext.getEnclosingDecl(); - - this.typeCheckAST(binaryExpression.operand1, typeCheckContext, false); - - var leftExpr = this.resolveSymbolAndReportDiagnostics(binaryExpression.operand1, false, typeCheckContext.getEnclosingDecl()); - var leftType = leftExpr.getType(); - this.checkForResolutionError(leftType, enclosingDecl); - leftType = this.resolver.widenType(leftExpr.getType()); - - this.context.pushContextualType(leftType, this.context.inProvisionalResolution(), null); - var rightType = this.resolver.widenType(this.typeCheckAST(binaryExpression.operand2, typeCheckContext, true)); - this.context.popContextualType(); - - if (!this.isValidLHS(binaryExpression.operand1, leftExpr)) { - this.postError(binaryExpression.operand1.minChar, binaryExpression.operand1.getLength(), typeCheckContext.scriptName, 195 /* Invalid_left_hand_side_of_assignment_expression */, null, enclosingDecl); - } - - this.checkAssignability(binaryExpression.operand1, rightType, leftType, typeCheckContext); - return rightType; - }; - - PullTypeChecker.prototype.typeCheckGenericType = function (genericType, typeCheckContext) { - var savedResolvingTypeReference = this.context.resolvingTypeReference; - this.context.resolvingTypeReference = true; - this.typeCheckAST(genericType.name, typeCheckContext, false); - this.context.resolvingTypeReference = savedResolvingTypeReference; - - this.typeCheckAST(genericType.typeArguments, typeCheckContext, false); - - return this.resolveSymbolAndReportDiagnostics(genericType, false, typeCheckContext.getEnclosingDecl()).getType(); - }; - - PullTypeChecker.prototype.typeCheckObjectLiteral = function (ast, typeCheckContext, inContextuallyTypedAssignment) { - var objectLitAST = ast; - var enclosingDecl = typeCheckContext.getEnclosingDecl(); - - var objectLitType = this.resolveSymbolAndReportDiagnostics(ast, inContextuallyTypedAssignment, enclosingDecl).getType(); - var memberDecls = objectLitAST.operand; - - var contextualType = this.context.getContextualType(); - var memberType; - - if (memberDecls) { - var member = null; - - for (var i = 0; i < memberDecls.members.length; i++) { - var binex = memberDecls.members[i]; - - if (contextualType) { - var text; - if (binex.operand1.nodeType === 20 /* Name */) { - text = (binex.operand1).text; - } else if (binex.operand1.nodeType === 5 /* StringLiteral */) { - text = (binex.operand1).text; - } - - member = contextualType.findMember(text); - - if (member) { - this.context.pushContextualType(member.getType(), this.context.inProvisionalResolution(), null); - } - } - - this.typeCheckAST(binex.operand2, typeCheckContext, member != null); - - if (member) { - this.context.popContextualType(); - member = null; - } - } - } - - this.checkForResolutionError(objectLitType, enclosingDecl); - - return objectLitType; - }; - - PullTypeChecker.prototype.typeCheckArrayLiteral = function (ast, typeCheckContext, inContextuallyTypedAssignment) { - var arrayLiteralAST = ast; - var enclosingDecl = typeCheckContext.getEnclosingDecl(); - - var type = this.resolveSymbolAndReportDiagnostics(ast, inContextuallyTypedAssignment, enclosingDecl).getType(); - var memberASTs = arrayLiteralAST.operand; - - var contextualType = this.context.getContextualType(); - var contextualMemberType = null; - if (contextualType && contextualType.isArray()) { - contextualMemberType = contextualType.getElementType(); - } - - if (memberASTs && memberASTs.members && memberASTs.members.length) { - var elementTypes = []; - - if (contextualMemberType) { - this.context.pushContextualType(contextualMemberType, this.context.inProvisionalResolution(), null); - } - - for (var i = 0; i < memberASTs.members.length; i++) { - elementTypes[elementTypes.length] = this.typeCheckAST(memberASTs.members[i], typeCheckContext, false); - } - - if (contextualMemberType) { - this.context.popContextualType(); - } - } - - this.checkForResolutionError(type, enclosingDecl); - - return type; - }; - - PullTypeChecker.prototype.enclosingClassIsDerived = function (typeCheckContext) { - var enclosingClass = typeCheckContext.getEnclosingDecl(8 /* Class */); - - if (enclosingClass) { - var classSymbol = enclosingClass.getSymbol(); - if (classSymbol.getExtendedTypes().length > 0) { - return true; - } - } - - return false; - }; - - PullTypeChecker.prototype.isSuperCallNode = function (node) { - if (node && node.nodeType === 88 /* ExpressionStatement */) { - var expressionStatement = node; - if (expressionStatement.expression && expressionStatement.expression.nodeType === 36 /* InvocationExpression */) { - var callExpression = expressionStatement.expression; - if (callExpression.target && callExpression.target.nodeType === 30 /* SuperExpression */) { - return true; - } - } - } - return false; - }; - - PullTypeChecker.prototype.getFirstStatementFromFunctionDeclAST = function (funcDeclAST) { - if (funcDeclAST.block && funcDeclAST.block.statements && funcDeclAST.block.statements.members) { - return funcDeclAST.block.statements.members[0]; - } - - return null; - }; - - PullTypeChecker.prototype.superCallMustBeFirstStatementInConstructor = function (enclosingConstructor, enclosingClass) { - if (enclosingConstructor && enclosingClass) { - var classSymbol = enclosingClass.getSymbol(); - if (classSymbol.getExtendedTypes().length === 0) { - return false; - } - - var classMembers = classSymbol.getMembers(); - for (var i = 0, n1 = classMembers.length; i < n1; i++) { - var member = classMembers[i]; - - if (member.getKind() === 4096 /* Property */) { - var declarations = member.getDeclarations(); - for (var j = 0, n2 = declarations.length; j < n2; j++) { - var declaration = declarations[j]; - var ast = this.semanticInfoChain.getASTForDecl(declaration); - if (ast.nodeType === 19 /* Parameter */) { - return true; - } - - if (ast.nodeType === 17 /* VariableDeclarator */) { - var variableDeclarator = ast; - if (variableDeclarator.init) { - return true; - } - } - } - } - } - } - - return false; - }; - - PullTypeChecker.prototype.checkForThisOrSuperCaptureInArrowFunction = function (expression, typeCheckContext) { - var enclosingDecl = typeCheckContext.getEnclosingDecl(); - - var declPath = typeCheckContext.enclosingDeclStack; - - if (declPath.length) { - var inFatArrow = false; - for (var i = declPath.length - 1; i >= 0; i--) { - var decl = declPath[i]; - var declKind = decl.getKind(); - var declFlags = decl.getFlags(); - - if (declKind === 131072 /* FunctionExpression */ && TypeScript.hasFlag(declFlags, 8192 /* FatArrow */)) { - inFatArrow = true; - continue; - } - - if (inFatArrow) { - if (declKind === 16384 /* Function */ || declKind === 65536 /* Method */ || declKind === 32768 /* ConstructorMethod */ || declKind === 262144 /* GetAccessor */ || declKind === 524288 /* SetAccessor */ || declKind === 131072 /* FunctionExpression */ || declKind === 8 /* Class */ || declKind === 4 /* Container */ || declKind === 32 /* DynamicModule */ || declKind === 1 /* Script */) { - decl.setFlags(decl.getFlags() | 262144 /* MustCaptureThis */); - - if (declKind === 8 /* Class */) { - decl.getChildDecls().filter(function (d) { - return d.getKind() === 32768 /* ConstructorMethod */; - }).map(function (d) { - return d.setFlags(d.getFlags() | 262144 /* MustCaptureThis */); - }); - } - break; - } - } - } - } - }; - - PullTypeChecker.prototype.typeCheckThisExpression = function (thisExpressionAST, typeCheckContext) { - var enclosingDecl = typeCheckContext.getEnclosingDecl(); - var enclosingNonLambdaDecl = typeCheckContext.getEnclosingNonLambdaDecl(); - - if (typeCheckContext.inSuperConstructorCall && this.superCallMustBeFirstStatementInConstructor(typeCheckContext.getEnclosingDecl(32768 /* ConstructorMethod */), typeCheckContext.getEnclosingDecl(8 /* Class */))) { - this.postError(thisExpressionAST.minChar, thisExpressionAST.getLength(), typeCheckContext.scriptName, 166 /* _this__cannot_be_referenced_in_current_location */, null, enclosingDecl); - } else if (enclosingNonLambdaDecl) { - if (enclosingNonLambdaDecl.getKind() === 8 /* Class */) { - this.postError(thisExpressionAST.minChar, thisExpressionAST.getLength(), typeCheckContext.scriptName, 205 /* _this__cannot_be_referenced_in_initializers_in_a_class_body */, null, enclosingDecl); - } else if (enclosingNonLambdaDecl.getKind() === 4 /* Container */ || enclosingNonLambdaDecl.getKind() === 32 /* DynamicModule */) { - this.postError(thisExpressionAST.minChar, thisExpressionAST.getLength(), typeCheckContext.scriptName, 176 /* _this__cannot_be_referenced_within_module_bodies */, null, enclosingDecl); - } else if (typeCheckContext.inConstructorArguments) { - this.postError(thisExpressionAST.minChar, thisExpressionAST.getLength(), typeCheckContext.scriptName, 220 /* _this__cannot_be_referenced_in_constructor_arguments */, null, enclosingDecl); - } - } - - this.checkForThisOrSuperCaptureInArrowFunction(thisExpressionAST, typeCheckContext); - - return this.resolveSymbolAndReportDiagnostics(thisExpressionAST, false, enclosingDecl).getType(); - }; - - PullTypeChecker.prototype.typeCheckSuperExpression = function (ast, typeCheckContext) { - var enclosingDecl = typeCheckContext.getEnclosingDecl(); - var nonLambdaEnclosingDecl = typeCheckContext.getEnclosingNonLambdaDecl(); - var nonLambdaEnclosingDeclKind = nonLambdaEnclosingDecl.getKind(); - var inSuperConstructorTarget = typeCheckContext.inSuperConstructorTarget; - - if (inSuperConstructorTarget && enclosingDecl.getKind() !== 32768 /* ConstructorMethod */) { - this.postError(ast.minChar, ast.getLength(), typeCheckContext.scriptName, 174 /* Super_calls_are_not_permitted_outside_constructors_or_in_local_functions_inside_constructors */, null, enclosingDecl); - } else if ((nonLambdaEnclosingDeclKind !== 65536 /* Method */ && nonLambdaEnclosingDeclKind !== 262144 /* GetAccessor */ && nonLambdaEnclosingDeclKind !== 524288 /* SetAccessor */ && nonLambdaEnclosingDeclKind !== 32768 /* ConstructorMethod */) || ((nonLambdaEnclosingDecl.getFlags() & 16 /* Static */) !== 0)) { - this.postError(ast.minChar, ast.getLength(), typeCheckContext.scriptName, 170 /* _super__property_access_is_permitted_only_in_a_constructor__instance_member_function__or_instance_member_accessor_of_a_derived_class */, null, enclosingDecl); - } else if (!this.enclosingClassIsDerived(typeCheckContext)) { - this.postError(ast.minChar, ast.getLength(), typeCheckContext.scriptName, 171 /* _super__cannot_be_referenced_in_non_derived_classes */, null, enclosingDecl); - } - - this.checkForThisOrSuperCaptureInArrowFunction(ast, typeCheckContext); - - return this.resolveSymbolAndReportDiagnostics(ast, false, enclosingDecl).getType(); - }; - - PullTypeChecker.prototype.typeCheckCallExpression = function (callExpression, typeCheckContext) { - var enclosingDecl = typeCheckContext.getEnclosingDecl(); - var inSuperConstructorCall = (callExpression.target.nodeType === 30 /* SuperExpression */); - - var callResolutionData = new TypeScript.PullAdditionalCallResolutionData(); - var resultTypeAndDiagnostics = this.resolver.resolveCallExpression(callExpression, false, enclosingDecl, this.context, callResolutionData); - this.reportDiagnostics(resultTypeAndDiagnostics, enclosingDecl); - var resultType = resultTypeAndDiagnostics.symbol.getType(); - - this.typeCheckAST(callExpression.typeArguments, typeCheckContext, false); - - if (!resultType.isError()) { - var savedInSuperConstructorTarget = typeCheckContext.inSuperConstructorTarget; - if (inSuperConstructorCall) { - typeCheckContext.inSuperConstructorTarget = true; - } - - this.typeCheckAST(callExpression.target, typeCheckContext, false); - - typeCheckContext.inSuperConstructorTarget = savedInSuperConstructorTarget; - } - - if (inSuperConstructorCall && enclosingDecl.getKind() === 32768 /* ConstructorMethod */) { - typeCheckContext.seenSuperConstructorCall = true; - } - - var savedInSuperConstructorCall = typeCheckContext.inSuperConstructorCall; - if (inSuperConstructorCall) { - typeCheckContext.inSuperConstructorCall = true; - } - - var contextTypes = callResolutionData.actualParametersContextTypeSymbols; - if (callExpression.arguments) { - var argumentASTs = callExpression.arguments.members; - for (var i = 0, n = argumentASTs.length; i < n; i++) { - var argumentAST = argumentASTs[i]; - - if (contextTypes && contextTypes[i]) { - this.context.pushContextualType(contextTypes[i], this.context.inProvisionalResolution(), null); - } - - this.typeCheckAST(argumentAST, typeCheckContext, false); - - if (contextTypes && contextTypes[i]) { - this.context.popContextualType(); - } - } - } - - typeCheckContext.inSuperConstructorCall = savedInSuperConstructorCall; - - return resultType; - }; - - PullTypeChecker.prototype.typeCheckObjectCreationExpression = function (callExpression, typeCheckContext) { - var enclosingDecl = typeCheckContext.getEnclosingDecl(); - - var callResolutionData = new TypeScript.PullAdditionalCallResolutionData(); - var resultAndDiagnostics = this.resolver.resolveNewExpression(callExpression, false, enclosingDecl, this.context, callResolutionData); - this.reportDiagnostics(resultAndDiagnostics, typeCheckContext.getEnclosingDecl()); - - var result = resultAndDiagnostics.symbol.getType(); - - this.typeCheckAST(callExpression.target, typeCheckContext, false); - - this.typeCheckAST(callExpression.typeArguments, typeCheckContext, false); - - var contextTypes = callResolutionData.actualParametersContextTypeSymbols; - if (callExpression.arguments) { - var argumentASTs = callExpression.arguments.members; - for (var i = 0, n = argumentASTs.length; i < n; i++) { - var argumentAST = argumentASTs[i]; - - if (contextTypes && contextTypes[i]) { - this.context.pushContextualType(contextTypes[i], this.context.inProvisionalResolution(), null); - } - - this.typeCheckAST(argumentAST, typeCheckContext, false); - - if (contextTypes && contextTypes[i]) { - this.context.popContextualType(); - } - } - } - - return result; - }; - - PullTypeChecker.prototype.typeCheckTypeAssertion = function (ast, typeCheckContext) { - var enclosingDecl = typeCheckContext.getEnclosingDecl(); - - var returnType = this.resolveSymbolAndReportDiagnostics(ast, false, enclosingDecl).getType(); - - if (returnType.isError()) { - var symbolName = (returnType).getData(); - this.postError(ast.minChar, ast.getLength(), typeCheckContext.scriptName, 164 /* Could_not_find_symbol__0_ */, [symbolName], typeCheckContext.getEnclosingDecl()); - } - - this.context.pushContextualType(returnType, this.context.inProvisionalResolution(), null); - var exprType = this.typeCheckAST(ast.operand, typeCheckContext, true); - this.context.popContextualType(); - - var comparisonInfo = new TypeComparisonInfo(); - - var isAssignable = this.resolver.sourceIsAssignableToTarget(returnType, exprType, this.context, comparisonInfo) || this.resolver.sourceIsAssignableToTarget(exprType, returnType, this.context, comparisonInfo); - - if (!isAssignable) { - var message; - if (comparisonInfo.message) { - this.postError(ast.minChar, ast.getLength(), typeCheckContext.scriptName, 81 /* Cannot_convert__0__to__1__NL__2 */, [exprType.toString(), returnType.toString(), comparisonInfo.message], typeCheckContext.getEnclosingDecl()); - } else { - this.postError(ast.minChar, ast.getLength(), typeCheckContext.scriptName, 80 /* Cannot_convert__0__to__1_ */, [exprType.toString(), returnType.toString()], typeCheckContext.getEnclosingDecl()); - } - } - - return returnType; - }; - - PullTypeChecker.prototype.typeCheckLogicalOperation = function (binex, typeCheckContext) { - var leftType = this.typeCheckAST(binex.operand1, typeCheckContext, false); - var rightType = this.typeCheckAST(binex.operand2, typeCheckContext, false); - - var comparisonInfo = new TypeComparisonInfo(); - if (!this.resolver.sourceIsAssignableToTarget(leftType, rightType, this.context, comparisonInfo) && !this.resolver.sourceIsAssignableToTarget(rightType, leftType, this.context, comparisonInfo)) { - this.postError(binex.minChar, binex.getLength(), typeCheckContext.scriptName, 78 /* Operator__0__cannot_be_applied_to_types__1__and__2_ */, [TypeScript.BinaryExpression.getTextForBinaryToken(binex.nodeType), leftType.toString(), rightType.toString()], typeCheckContext.getEnclosingDecl()); - } - - return this.resolveSymbolAndReportDiagnostics(binex, false, typeCheckContext.getEnclosingDecl()).getType(); - }; - - PullTypeChecker.prototype.typeCheckLogicalAndOrExpression = function (binex, typeCheckContext) { - this.typeCheckAST(binex.operand1, typeCheckContext, false); - this.typeCheckAST(binex.operand2, typeCheckContext, false); - - return this.resolveSymbolAndReportDiagnostics(binex, false, typeCheckContext.getEnclosingDecl()).getType(); - }; - - PullTypeChecker.prototype.typeCheckCommaExpression = function (binex, typeCheckContext) { - this.typeCheckAST(binex.operand1, typeCheckContext, false); - this.typeCheckAST(binex.operand2, typeCheckContext, false); - - return this.resolveSymbolAndReportDiagnostics(binex, false, typeCheckContext.getEnclosingDecl()).getType(); - }; - - PullTypeChecker.prototype.typeCheckBinaryAdditionOperation = function (binaryExpression, typeCheckContext) { - var enclosingDecl = typeCheckContext.getEnclosingDecl(); - - this.resolveSymbolAndReportDiagnostics(binaryExpression, false, enclosingDecl).getType(); - - var lhsType = this.typeCheckAST(binaryExpression.operand1, typeCheckContext, false); - var rhsType = this.typeCheckAST(binaryExpression.operand2, typeCheckContext, false); - - if (TypeScript.PullHelpers.symbolIsEnum(lhsType)) { - lhsType = this.semanticInfoChain.numberTypeSymbol; - } else if (lhsType === this.semanticInfoChain.nullTypeSymbol || lhsType === this.semanticInfoChain.undefinedTypeSymbol) { - if (rhsType != this.semanticInfoChain.nullTypeSymbol && rhsType != this.semanticInfoChain.undefinedTypeSymbol) { - lhsType = rhsType; - } else { - lhsType = this.semanticInfoChain.anyTypeSymbol; - } - } - - if (TypeScript.PullHelpers.symbolIsEnum(rhsType)) { - rhsType = this.semanticInfoChain.numberTypeSymbol; - } else if (rhsType === this.semanticInfoChain.nullTypeSymbol || rhsType === this.semanticInfoChain.undefinedTypeSymbol) { - if (lhsType != this.semanticInfoChain.nullTypeSymbol && lhsType != this.semanticInfoChain.undefinedTypeSymbol) { - rhsType = lhsType; - } else { - rhsType = this.semanticInfoChain.anyTypeSymbol; - } - } - - var exprType = null; - - if (lhsType === this.semanticInfoChain.stringTypeSymbol || rhsType === this.semanticInfoChain.stringTypeSymbol) { - exprType = this.semanticInfoChain.stringTypeSymbol; - } else if (this.resolver.isAnyOrEquivalent(lhsType) || this.resolver.isAnyOrEquivalent(rhsType)) { - exprType = this.semanticInfoChain.anyTypeSymbol; - } else if (rhsType === this.semanticInfoChain.numberTypeSymbol && lhsType === this.semanticInfoChain.numberTypeSymbol) { - exprType = this.semanticInfoChain.numberTypeSymbol; - } - - if (exprType) { - if (binaryExpression.nodeType === 39 /* AddAssignmentExpression */) { - var lhsExpression = this.resolveSymbolAndReportDiagnostics(binaryExpression.operand1, false, typeCheckContext.getEnclosingDecl()); - if (!this.isValidLHS(binaryExpression.operand1, lhsExpression)) { - this.postError(binaryExpression.operand1.minChar, binaryExpression.operand1.getLength(), typeCheckContext.scriptName, 195 /* Invalid_left_hand_side_of_assignment_expression */, null, enclosingDecl); - } - - this.checkAssignability(binaryExpression.operand1, exprType, lhsType, typeCheckContext); - } - } else { - this.postError(binaryExpression.operand1.minChar, binaryExpression.operand1.getLength(), typeCheckContext.scriptName, 178 /* Invalid__addition__expression___types_do_not_agree */, null, typeCheckContext.getEnclosingDecl()); - exprType = this.semanticInfoChain.anyTypeSymbol; - } - - return exprType; - }; - - PullTypeChecker.prototype.typeCheckBinaryArithmeticOperation = function (binaryExpression, typeCheckContext) { - var enclosingDecl = typeCheckContext.getEnclosingDecl(); - - this.resolveSymbolAndReportDiagnostics(binaryExpression, false, enclosingDecl).getType(); - - var lhsType = this.typeCheckAST(binaryExpression.operand1, typeCheckContext, false); - var rhsType = this.typeCheckAST(binaryExpression.operand2, typeCheckContext, false); - - var lhsIsFit = this.resolver.isAnyOrEquivalent(lhsType) || lhsType === this.semanticInfoChain.numberTypeSymbol || TypeScript.PullHelpers.symbolIsEnum(lhsType); - var rhsIsFit = this.resolver.isAnyOrEquivalent(rhsType) || rhsType === this.semanticInfoChain.numberTypeSymbol || TypeScript.PullHelpers.symbolIsEnum(rhsType); - - if (!rhsIsFit) { - this.postError(binaryExpression.operand1.minChar, binaryExpression.operand1.getLength(), typeCheckContext.scriptName, 179 /* The_right_hand_side_of_an_arithmetic_operation_must_be_of_type__any____number__or_an_enum_type */, null, typeCheckContext.getEnclosingDecl()); - } - - if (!lhsIsFit) { - this.postError(binaryExpression.operand2.minChar, binaryExpression.operand2.getLength(), typeCheckContext.scriptName, 180 /* The_left_hand_side_of_an_arithmetic_operation_must_be_of_type__any____number__or_an_enum_type */, null, typeCheckContext.getEnclosingDecl()); - } - - if (rhsIsFit && lhsIsFit) { - switch (binaryExpression.nodeType) { - case 47 /* LeftShiftAssignmentExpression */: - case 48 /* SignedRightShiftAssignmentExpression */: - case 49 /* UnsignedRightShiftAssignmentExpression */: - case 40 /* SubtractAssignmentExpression */: - case 42 /* MultiplyAssignmentExpression */: - case 41 /* DivideAssignmentExpression */: - case 43 /* ModuloAssignmentExpression */: - case 46 /* OrAssignmentExpression */: - case 44 /* AndAssignmentExpression */: - case 45 /* ExclusiveOrAssignmentExpression */: - var lhsExpression = this.resolveSymbolAndReportDiagnostics(binaryExpression.operand1, false, typeCheckContext.getEnclosingDecl()); - if (!this.isValidLHS(binaryExpression.operand1, lhsExpression)) { - this.postError(binaryExpression.operand1.minChar, binaryExpression.operand1.getLength(), typeCheckContext.scriptName, 195 /* Invalid_left_hand_side_of_assignment_expression */, null, enclosingDecl); - } - - this.checkAssignability(binaryExpression.operand1, rhsType, lhsType, typeCheckContext); - break; - } - } - - return this.semanticInfoChain.numberTypeSymbol; - }; - - PullTypeChecker.prototype.typeCheckLogicalNotExpression = function (unaryExpression, typeCheckContext, inContextuallyTypedAssignment) { - this.typeCheckAST(unaryExpression.operand, typeCheckContext, inContextuallyTypedAssignment); - return this.semanticInfoChain.booleanTypeSymbol; - }; - - PullTypeChecker.prototype.typeCheckUnaryArithmeticOperation = function (unaryExpression, typeCheckContext, inContextuallyTypedAssignment) { - var operandType = this.typeCheckAST(unaryExpression.operand, typeCheckContext, inContextuallyTypedAssignment); - - switch (unaryExpression.nodeType) { - case 26 /* PlusExpression */: - case 27 /* NegateExpression */: - case 72 /* BitwiseNotExpression */: - return this.semanticInfoChain.numberTypeSymbol; - } - - var operandIsFit = this.resolver.isAnyOrEquivalent(operandType) || operandType === this.semanticInfoChain.numberTypeSymbol || TypeScript.PullHelpers.symbolIsEnum(operandType); - - if (!operandIsFit) { - this.postError(unaryExpression.operand.minChar, unaryExpression.operand.getLength(), typeCheckContext.scriptName, 181 /* The_type_of_a_unary_arithmetic_operation_operand_must_be_of_type__any____number__or_an_enum_type */, null, typeCheckContext.getEnclosingDecl()); - } - - switch (unaryExpression.nodeType) { - case 76 /* PostIncrementExpression */: - case 74 /* PreIncrementExpression */: - case 77 /* PostDecrementExpression */: - case 75 /* PreDecrementExpression */: - var expression = this.resolveSymbolAndReportDiagnostics(unaryExpression.operand, false, typeCheckContext.getEnclosingDecl()); - if (!this.isValidLHS(unaryExpression.operand, expression)) { - this.postError(unaryExpression.operand.minChar, unaryExpression.operand.getLength(), typeCheckContext.scriptName, 204 /* The_operand_of_an_increment_or_decrement_operator_must_be_a_variable__property_or_indexer */, null, typeCheckContext.getEnclosingDecl()); - } - - break; - } - - return operandType; - }; - - PullTypeChecker.prototype.typeCheckElementAccessExpression = function (binaryExpression, typeCheckContext) { - this.typeCheckAST(binaryExpression.operand1, typeCheckContext, false); - this.typeCheckAST(binaryExpression.operand2, typeCheckContext, false); - - return this.resolveSymbolAndReportDiagnostics(binaryExpression, false, typeCheckContext.getEnclosingDecl()).getType(); - }; - - PullTypeChecker.prototype.typeCheckTypeOf = function (ast, typeCheckContext) { - this.typeCheckAST((ast).operand, typeCheckContext, false); - - return this.semanticInfoChain.stringTypeSymbol; - }; - - PullTypeChecker.prototype.typeCheckTypeReference = function (typeRef, typeCheckContext) { - if (typeRef.term.nodeType === 12 /* FunctionDeclaration */) { - this.typeCheckFunctionTypeSignature(typeRef.term, typeCheckContext.getEnclosingDecl(), typeCheckContext); - } else if (typeRef.term.nodeType === 14 /* InterfaceDeclaration */) { - this.typeCheckInterfaceTypeReference(typeRef.term, typeCheckContext.getEnclosingDecl(), typeCheckContext); - } else { - var savedResolvingTypeReference = this.context.resolvingTypeReference; - this.context.resolvingTypeReference = true; - var type = this.typeCheckAST(typeRef.term, typeCheckContext, false); - - if (type && !type.isError() && !typeCheckContext.inImportDeclaration) { - if ((type.getKind() & TypeScript.PullElementKind.SomeType) === 0) { - if (type.getKind() & TypeScript.PullElementKind.SomeContainer) { - this.postError(typeRef.minChar, typeRef.getLength(), typeCheckContext.scriptName, 262 /* Type_reference_cannot_refer_to_container__0_ */, [type.toString()], typeCheckContext.getEnclosingDecl()); - } else { - this.postError(typeRef.minChar, typeRef.getLength(), typeCheckContext.scriptName, 263 /* Type_reference_must_refer_to_type */, null, typeCheckContext.getEnclosingDecl()); - } - } - } - - this.context.resolvingTypeReference = savedResolvingTypeReference; - } - - return this.resolveSymbolAndReportDiagnostics(typeRef, false, typeCheckContext.getEnclosingDecl()).getType(); - }; - - PullTypeChecker.prototype.typeCheckExportAssignment = function (ast, typeCheckContext) { - return this.resolveSymbolAndReportDiagnostics(ast, false, typeCheckContext.getEnclosingDecl()).getType(); - }; - - PullTypeChecker.prototype.typeCheckFunctionTypeSignature = function (funcDeclAST, enclosingDecl, typeCheckContext) { - var funcDeclSymbolAndDiagnostics = this.resolver.getSymbolAndDiagnosticsForAST(funcDeclAST); - var funcDeclSymbol = funcDeclSymbolAndDiagnostics && funcDeclSymbolAndDiagnostics.symbol; - if (!funcDeclSymbol) { - funcDeclSymbol = this.resolver.resolveFunctionTypeSignature(funcDeclAST, enclosingDecl, this.context); - } - var functionDecl = typeCheckContext.semanticInfo.getDeclForAST(funcDeclAST); - - typeCheckContext.pushEnclosingDecl(functionDecl); - this.typeCheckAST(funcDeclAST.arguments, typeCheckContext, false); - typeCheckContext.popEnclosingDecl(); - - var functionSignature = funcDeclSymbol.getKind() === 33554432 /* ConstructorType */ ? funcDeclSymbol.getConstructSignatures()[0] : funcDeclSymbol.getCallSignatures()[0]; - var parameters = functionSignature.getParameters(); - for (var i = 0; i < parameters.length; i++) { - this.checkForResolutionError(parameters[i].getType(), enclosingDecl); - } - - if (funcDeclAST.returnTypeAnnotation) { - var returnType = functionSignature.getReturnType(); - this.checkForResolutionError(returnType, enclosingDecl); - } - - this.typeCheckFunctionOverloads(funcDeclAST, typeCheckContext, functionSignature, [functionSignature]); - return funcDeclSymbol; - }; - - PullTypeChecker.prototype.typeCheckInterfaceTypeReference = function (interfaceAST, enclosingDecl, typeCheckContext) { - var interfaceSymbolAndDiagnostics = this.resolver.getSymbolAndDiagnosticsForAST(interfaceAST); - var interfaceSymbol = interfaceSymbolAndDiagnostics && interfaceSymbolAndDiagnostics.symbol; - if (!interfaceSymbol) { - interfaceSymbol = this.resolver.resolveInterfaceTypeReference(interfaceAST, enclosingDecl, this.context); - } - - var interfaceDecl = typeCheckContext.semanticInfo.getDeclForAST(interfaceAST); - typeCheckContext.pushEnclosingDecl(interfaceDecl); - this.typeCheckAST(interfaceAST.members, typeCheckContext, false); - this.typeCheckMembersAgainstIndexer(interfaceSymbol, typeCheckContext); - typeCheckContext.popEnclosingDecl(); - - return interfaceSymbol; - }; - - PullTypeChecker.prototype.typeCheckConditionalExpression = function (conditionalExpression, typeCheckContext) { - this.typeCheckAST(conditionalExpression.operand1, typeCheckContext, false); - this.typeCheckAST(conditionalExpression.operand2, typeCheckContext, false); - this.typeCheckAST(conditionalExpression.operand3, typeCheckContext, false); - - return this.resolveSymbolAndReportDiagnostics(conditionalExpression, false, typeCheckContext.getEnclosingDecl()).getType(); - }; - - PullTypeChecker.prototype.typeCheckThrowStatement = function (throwStatement, typeCheckContext) { - this.typeCheckAST(throwStatement.expression, typeCheckContext, false); - - var type = this.resolveSymbolAndReportDiagnostics(throwStatement.expression, false, typeCheckContext.getEnclosingDecl()).getType(); - this.checkForResolutionError(type, typeCheckContext.getEnclosingDecl()); - return this.semanticInfoChain.voidTypeSymbol; - }; - - PullTypeChecker.prototype.typeCheckDeleteExpression = function (unaryExpression, typeCheckContext) { - this.typeCheckAST(unaryExpression.operand, typeCheckContext, false); - - var enclosingDecl = typeCheckContext.getEnclosingDecl(); - var type = this.resolveSymbolAndReportDiagnostics(unaryExpression, false, enclosingDecl).getType(); - this.checkForResolutionError(type, enclosingDecl); - - return type; - }; - - PullTypeChecker.prototype.typeCheckVoidExpression = function (unaryExpression, typeCheckContext) { - this.typeCheckAST(unaryExpression.operand, typeCheckContext, false); - - var enclosingDecl = typeCheckContext.getEnclosingDecl(); - var type = this.resolveSymbolAndReportDiagnostics(unaryExpression, false, enclosingDecl).getType(); - this.checkForResolutionError(type, enclosingDecl); - - return type; - }; - - PullTypeChecker.prototype.typeCheckRegExpExpression = function (ast, typeCheckContext) { - var type = this.resolveSymbolAndReportDiagnostics(ast, false, typeCheckContext.getEnclosingDecl()).getType(); - this.checkForResolutionError(type, typeCheckContext.getEnclosingDecl()); - return type; - }; - - PullTypeChecker.prototype.typeCheckForStatement = function (forStatement, typeCheckContext) { - this.typeCheckAST(forStatement.init, typeCheckContext, false); - this.typeCheckAST(forStatement.cond, typeCheckContext, false); - this.typeCheckAST(forStatement.body, typeCheckContext, false); - - return this.semanticInfoChain.voidTypeSymbol; - }; - - PullTypeChecker.prototype.typeCheckForInStatement = function (ast, typeCheckContext) { - var forInStatement = ast; - - var rhsType = this.resolver.widenType(this.typeCheckAST(forInStatement.obj, typeCheckContext, false)); - var lval = forInStatement.lval; - - if (lval.nodeType === 18 /* VariableDeclaration */) { - var declaration = forInStatement.lval; - var varDecl = declaration.declarators.members[0]; - - if (varDecl.typeExpr) { - this.postError(lval.minChar, lval.getLength(), typeCheckContext.scriptName, 182 /* Variable_declarations_for_for_in_expressions_cannot_contain_a_type_annotation */, null, typeCheckContext.getEnclosingDecl()); - } - } - - var varSym = this.resolveSymbolAndReportDiagnostics(forInStatement.lval, false, typeCheckContext.getEnclosingDecl()); - this.checkForResolutionError(varSym.getType(), typeCheckContext.getEnclosingDecl()); - - var isStringOrNumber = varSym.getType() === this.semanticInfoChain.stringTypeSymbol || this.resolver.isAnyOrEquivalent(varSym.getType()); - - var isValidRHS = rhsType && (this.resolver.isAnyOrEquivalent(rhsType) || !rhsType.isPrimitive()); - - if (!isStringOrNumber) { - this.postError(lval.minChar, lval.getLength(), typeCheckContext.scriptName, 183 /* Variable_declarations_for_for_in_expressions_must_be_of_types__string__or__any_ */, null, typeCheckContext.getEnclosingDecl()); - } - - if (!isValidRHS) { - this.postError(forInStatement.obj.minChar, forInStatement.obj.getLength(), typeCheckContext.scriptName, 184 /* The_right_operand_of_a_for_in_expression_must_be_of_type__any____an_object_type_or_a_type_parameter */, null, typeCheckContext.getEnclosingDecl()); - } - - this.typeCheckAST(forInStatement.body, typeCheckContext, false); - - return this.semanticInfoChain.voidTypeSymbol; - }; - - PullTypeChecker.prototype.typeCheckInExpression = function (binaryExpression, typeCheckContext) { - var lhsType = this.resolver.widenType(this.typeCheckAST(binaryExpression.operand1, typeCheckContext, false)); - var rhsType = this.resolver.widenType(this.typeCheckAST(binaryExpression.operand2, typeCheckContext, false)); - - var isStringAnyOrNumber = lhsType.getType() === this.semanticInfoChain.stringTypeSymbol || this.resolver.isAnyOrEquivalent(lhsType.getType()) || this.resolver.isNumberOrEquivalent(lhsType.getType()); - var isValidRHS = rhsType && (this.resolver.isAnyOrEquivalent(rhsType) || !rhsType.isPrimitive()); - - if (!isStringAnyOrNumber) { - this.postError(binaryExpression.operand1.minChar, binaryExpression.operand1.getLength(), typeCheckContext.scriptName, 185 /* The_left_hand_side_of_an__in__expression_must_be_of_types__string__or__any_ */, null, typeCheckContext.getEnclosingDecl()); - } - - if (!isValidRHS) { - this.postError(binaryExpression.operand1.minChar, binaryExpression.operand1.getLength(), typeCheckContext.scriptName, 186 /* The_right_hand_side_of_an__in__expression_must_be_of_type__any___an_object_type_or_a_type_parameter */, null, typeCheckContext.getEnclosingDecl()); - } - - return this.semanticInfoChain.booleanTypeSymbol; - }; - - PullTypeChecker.prototype.typeCheckInstanceOfExpression = function (binaryExpression, typeCheckContext) { - var lhsType = this.resolver.widenType(this.typeCheckAST(binaryExpression.operand1, typeCheckContext, false)); - var rhsType = this.typeCheckAST(binaryExpression.operand2, typeCheckContext, false); - - var isValidLHS = lhsType && (this.resolver.isAnyOrEquivalent(lhsType) || !lhsType.isPrimitive()); - var isValidRHS = rhsType && (this.resolver.isAnyOrEquivalent(rhsType) || rhsType.isClass() || this.resolver.typeIsSubtypeOfFunction(rhsType, this.context)); - - if (!isValidLHS) { - this.postError(binaryExpression.operand1.minChar, binaryExpression.operand1.getLength(), typeCheckContext.scriptName, 187 /* The_left_hand_side_of_an__instanceOf__expression_must_be_of_type__any___an_object_type_or_a_type_parameter */, null, typeCheckContext.getEnclosingDecl()); - } - - if (!isValidRHS) { - this.postError(binaryExpression.operand1.minChar, binaryExpression.operand1.getLength(), typeCheckContext.scriptName, 188 /* The_right_hand_side_of_an__instanceOf__expression_must_be_of_type__any__or_a_subtype_of_the__Function__interface_type */, null, typeCheckContext.getEnclosingDecl()); - } - - return this.semanticInfoChain.booleanTypeSymbol; - }; - - PullTypeChecker.prototype.typeCheckParenthesizedExpression = function (parenthesizedExpression, typeCheckContext) { - return this.typeCheckAST(parenthesizedExpression.expression, typeCheckContext, false); - }; - - PullTypeChecker.prototype.typeCheckWhileStatement = function (whileStatement, typeCheckContext) { - this.typeCheckAST(whileStatement.cond, typeCheckContext, false); - this.typeCheckAST(whileStatement.body, typeCheckContext, false); - - return this.semanticInfoChain.voidTypeSymbol; - }; - - PullTypeChecker.prototype.typeCheckDoStatement = function (doStatement, typeCheckContext) { - this.typeCheckAST(doStatement.cond, typeCheckContext, false); - this.typeCheckAST(doStatement.body, typeCheckContext, false); - - return this.semanticInfoChain.voidTypeSymbol; - }; - - PullTypeChecker.prototype.typeCheckIfStatement = function (ifStatement, typeCheckContext) { - this.typeCheckAST(ifStatement.cond, typeCheckContext, false); - this.typeCheckAST(ifStatement.thenBod, typeCheckContext, false); - this.typeCheckAST(ifStatement.elseBod, typeCheckContext, false); - - return this.semanticInfoChain.voidTypeSymbol; - }; - - PullTypeChecker.prototype.typeCheckBlock = function (block, typeCheckContext) { - this.typeCheckAST(block.statements, typeCheckContext, false); - - return this.semanticInfoChain.voidTypeSymbol; - }; - - PullTypeChecker.prototype.typeCheckVariableDeclaration = function (variableDeclaration, typeCheckContext) { - this.typeCheckAST(variableDeclaration.declarators, typeCheckContext, false); - - return this.semanticInfoChain.voidTypeSymbol; - }; - - PullTypeChecker.prototype.typeCheckVariableStatement = function (variableStatement, typeCheckContext) { - this.typeCheckAST(variableStatement.declaration, typeCheckContext, false); - - return this.semanticInfoChain.voidTypeSymbol; - }; - - PullTypeChecker.prototype.typeCheckWithStatement = function (withStatement, typeCheckContext) { - this.postError(withStatement.expr.minChar, withStatement.expr.getLength(), typeCheckContext.scriptName, 200 /* All_symbols_within_a__with__block_will_be_resolved_to__any__ */, null, typeCheckContext.getEnclosingDecl()); - - return this.semanticInfoChain.voidTypeSymbol; - }; - - PullTypeChecker.prototype.typeCheckTryStatement = function (tryStatement, typeCheckContext) { - this.typeCheckAST(tryStatement.tryBody, typeCheckContext, false); - this.typeCheckAST(tryStatement.catchClause, typeCheckContext, false); - this.typeCheckAST(tryStatement.finallyBody, typeCheckContext, false); - - return this.semanticInfoChain.voidTypeSymbol; - }; - - PullTypeChecker.prototype.typeCheckCatchClause = function (catchClause, typeCheckContext) { - var catchDecl = this.resolver.getDeclForAST(catchClause); - - typeCheckContext.pushEnclosingDecl(catchDecl); - this.typeCheckAST(catchClause.body, typeCheckContext, false); - typeCheckContext.popEnclosingDecl(); - - return this.semanticInfoChain.voidTypeSymbol; - }; - - PullTypeChecker.prototype.typeCheckReturnStatement = function (returnAST, typeCheckContext) { - typeCheckContext.setEnclosingDeclHasReturn(); - - var returnExpr = returnAST.returnExpression; - var enclosingDecl = typeCheckContext.getEnclosingDecl(); - - var inContextuallyTypedAssignment = false; - var enclosingDeclAST; - - if (enclosingDecl.getKind() & TypeScript.PullElementKind.SomeFunction) { - enclosingDeclAST = this.resolver.getASTForDecl(enclosingDecl); - if (enclosingDeclAST.returnTypeAnnotation) { - var returnTypeAnnotationSymbol = this.resolver.resolveTypeReference(enclosingDeclAST.returnTypeAnnotation, enclosingDecl, this.context).symbol; - if (returnTypeAnnotationSymbol) { - inContextuallyTypedAssignment = true; - this.context.pushContextualType(returnTypeAnnotationSymbol, this.context.inProvisionalResolution(), null); - } - } else { - var currentContextualType = this.context.getContextualType(); - if (currentContextualType && currentContextualType.isFunction()) { - var currentContextualTypeSignatureSymbol = currentContextualType.getDeclarations()[0].getSignatureSymbol(); - var currentContextualTypeReturnTypeSymbol = currentContextualTypeSignatureSymbol.getReturnType(); - if (currentContextualTypeReturnTypeSymbol) { - inContextuallyTypedAssignment = true; - this.context.pushContextualType(currentContextualTypeReturnTypeSymbol, this.context.inProvisionalResolution(), null); - } - } - } - } - - var returnType = this.typeCheckAST(returnExpr, typeCheckContext, inContextuallyTypedAssignment); - - if (inContextuallyTypedAssignment) { - this.context.popContextualType(); - } - - if (enclosingDecl.getKind() === 524288 /* SetAccessor */ && returnExpr) { - this.postError(returnExpr.minChar, returnExpr.getLength(), typeCheckContext.scriptName, 189 /* Setters_cannot_return_a_value */, null, typeCheckContext.getEnclosingDecl()); - } - - if (enclosingDecl.getKind() & TypeScript.PullElementKind.SomeFunction) { - enclosingDeclAST = this.resolver.getASTForDecl(enclosingDecl); - - if (enclosingDeclAST.returnTypeAnnotation) { - var signatureSymbol = enclosingDecl.getSignatureSymbol(); - var sigReturnType = signatureSymbol.getReturnType(); - - if (returnType && sigReturnType) { - var comparisonInfo = new TypeComparisonInfo(); - var upperBound = null; - - if (returnType.isTypeParameter()) { - upperBound = (returnType).getConstraint(); - - if (upperBound) { - returnType = upperBound; - } - } - - if (sigReturnType.isTypeParameter()) { - upperBound = (sigReturnType).getConstraint(); - - if (upperBound) { - sigReturnType = upperBound; - } - } - - if (!returnType.isResolved()) { - this.resolver.resolveDeclaredSymbol(returnType, enclosingDecl, this.context); - } - - if (!sigReturnType.isResolved()) { - this.resolver.resolveDeclaredSymbol(sigReturnType, enclosingDecl, this.context); - } - - var isAssignable = this.resolver.sourceIsAssignableToTarget(returnType, sigReturnType, this.context, comparisonInfo); - - if (!isAssignable) { - if (comparisonInfo.message) { - this.postError(returnExpr.minChar, returnExpr.getLength(), typeCheckContext.scriptName, 81 /* Cannot_convert__0__to__1__NL__2 */, [returnType.toString(), sigReturnType.toString(), comparisonInfo.message], enclosingDecl); - } else { - this.postError(returnExpr.minChar, returnExpr.getLength(), typeCheckContext.scriptName, 80 /* Cannot_convert__0__to__1_ */, [returnType.toString(), sigReturnType.toString()], enclosingDecl); - } - } - } - } - } - - return returnType; - }; - - PullTypeChecker.prototype.typeCheckNameExpression = function (ast, typeCheckContext) { - var enclosingDecl = typeCheckContext.getEnclosingDecl(); - var type = this.resolveSymbolAndReportDiagnostics(ast, false, enclosingDecl).getType(); - this.checkForResolutionError(type, enclosingDecl); - return type; - }; - - PullTypeChecker.prototype.checkForSuperMemberAccess = function (memberAccessExpression, typeCheckContext, resolvedName) { - var enclosingDecl = typeCheckContext.getEnclosingDecl(); - if (resolvedName) { - if (memberAccessExpression.operand1.nodeType === 30 /* SuperExpression */ && !resolvedName.isError() && resolvedName.getKind() !== 65536 /* Method */) { - this.postError(memberAccessExpression.operand2.minChar, memberAccessExpression.operand2.getLength(), typeCheckContext.scriptName, 232 /* Only_public_instance_methods_of_the_base_class_are_accessible_via_the_super_keyword */, [], enclosingDecl); - return true; - } - } - - return false; - }; - - PullTypeChecker.prototype.checkForPrivateMemberAccess = function (memberAccessExpression, typeCheckContext, expressionType, resolvedName) { - var enclosingDecl = typeCheckContext.getEnclosingDecl(); - if (resolvedName) { - if (resolvedName.hasFlag(2 /* Private */)) { - var memberContainer = resolvedName.getContainer(); - if (memberContainer && memberContainer.getKind() === 33554432 /* ConstructorType */) { - memberContainer = memberContainer.getAssociatedContainerType(); - } - - if (memberContainer && memberContainer.isClass()) { - var containingClass = typeCheckContext.getEnclosingClassDecl(); - if (!containingClass || containingClass.getSymbol() !== memberContainer) { - var name = memberAccessExpression.operand2; - this.postError(name.minChar, name.getLength(), typeCheckContext.scriptName, 175 /* _0_1__is_inaccessible */, [memberContainer.toString(false), name.actualText], enclosingDecl); - return true; - } - } - } - } - - return false; - }; - - PullTypeChecker.prototype.checkForStaticMemberAccess = function (memberAccessExpression, typeCheckContext, expressionType, resolvedName) { - if (expressionType && resolvedName && !resolvedName.isError()) { - if (expressionType.isClass() || expressionType.getKind() === 33554432 /* ConstructorType */) { - var name = memberAccessExpression.operand2; - var enclosingDecl = typeCheckContext.getEnclosingDecl(); - - if (resolvedName.hasFlag(16 /* Static */) || this.resolver.isPrototypeMember(memberAccessExpression, enclosingDecl, this.context)) { - if (expressionType.getKind() !== 33554432 /* ConstructorType */) { - var enclosingDecl = typeCheckContext.getEnclosingDecl(); - this.postError(name.minChar, name.getLength(), typeCheckContext.scriptName, 221 /* Static_member_cannot_be_accessed_off_an_instance_variable */, null, enclosingDecl); - return true; - } - } - } - } - - return false; - }; - - PullTypeChecker.prototype.typeCheckMemberAccessExpression = function (memberAccessExpression, typeCheckContext) { - var enclosingDecl = typeCheckContext.getEnclosingDecl(); - var resolvedName = this.resolveSymbolAndReportDiagnostics(memberAccessExpression, false, enclosingDecl); - var type = resolvedName.getType(); - - this.checkForResolutionError(type, enclosingDecl); - var prevCanUseTypeSymbol = this.context.canUseTypeSymbol; - this.context.canUseTypeSymbol = true; - var expressionType = this.typeCheckAST(memberAccessExpression.operand1, typeCheckContext, false); - this.context.canUseTypeSymbol = prevCanUseTypeSymbol; - - this.checkForSuperMemberAccess(memberAccessExpression, typeCheckContext, resolvedName) || this.checkForPrivateMemberAccess(memberAccessExpression, typeCheckContext, expressionType, resolvedName) || this.checkForStaticMemberAccess(memberAccessExpression, typeCheckContext, expressionType, resolvedName); - - return type; - }; - - PullTypeChecker.prototype.typeCheckSwitchStatement = function (switchStatement, typeCheckContext) { - this.typeCheckAST(switchStatement.val, typeCheckContext, false); - this.typeCheckAST(switchStatement.caseList, typeCheckContext, false); - this.typeCheckAST(switchStatement.defaultCase, typeCheckContext, false); - - return this.semanticInfoChain.voidTypeSymbol; - }; - - PullTypeChecker.prototype.typeCheckExpressionStatement = function (ast, typeCheckContext, inContextuallyTypedAssignment) { - return this.typeCheckAST(ast.expression, typeCheckContext, inContextuallyTypedAssignment); - }; - - PullTypeChecker.prototype.typeCheckCaseClause = function (caseClause, typeCheckContext) { - this.typeCheckAST(caseClause.expr, typeCheckContext, false); - this.typeCheckAST(caseClause.body, typeCheckContext, false); - - return this.semanticInfoChain.voidTypeSymbol; - }; - - PullTypeChecker.prototype.typeCheckLabeledStatement = function (labeledStatement, typeCheckContext) { - return this.typeCheckAST(labeledStatement.statement, typeCheckContext, false); - }; - - PullTypeChecker.prototype.checkTypePrivacy = function (declSymbol, typeSymbol, typeCheckContext, privacyErrorReporter) { - if (!typeSymbol || typeSymbol.getKind() === 2 /* Primitive */) { - return; - } - - if (typeSymbol.isArray()) { - this.checkTypePrivacy(declSymbol, (typeSymbol).getElementType(), typeCheckContext, privacyErrorReporter); - return; - } - - if (!typeSymbol.isNamedTypeSymbol()) { - var members = typeSymbol.getMembers(); - for (var i = 0; i < members.length; i++) { - this.checkTypePrivacy(declSymbol, members[i].getType(), typeCheckContext, privacyErrorReporter); - } - - this.checkTypePrivacyOfSignatures(declSymbol, typeSymbol.getCallSignatures(), typeCheckContext, privacyErrorReporter); - this.checkTypePrivacyOfSignatures(declSymbol, typeSymbol.getConstructSignatures(), typeCheckContext, privacyErrorReporter); - this.checkTypePrivacyOfSignatures(declSymbol, typeSymbol.getIndexSignatures(), typeCheckContext, privacyErrorReporter); - - return; - } - - if (declSymbol.isExternallyVisible()) { - var typeSymbolIsVisible = typeSymbol.isExternallyVisible(); - - if (typeSymbolIsVisible) { - var typeSymbolPath = typeSymbol.pathToRoot(); - if (typeSymbolPath.length && typeSymbolPath[typeSymbolPath.length - 1].getKind() === 32 /* DynamicModule */) { - var declSymbolPath = declSymbol.pathToRoot(); - if (declSymbolPath.length && declSymbolPath[declSymbolPath.length - 1] != typeSymbolPath[typeSymbolPath.length - 1]) { - typeSymbolIsVisible = false; - for (var i = typeSymbolPath.length - 1; i >= 0; i--) { - var aliasSymbol = typeSymbolPath[i].getAliasedSymbol(declSymbol); - if (aliasSymbol) { - TypeScript.CompilerDiagnostics.assert(aliasSymbol.getKind() === 256 /* TypeAlias */, "dynamic module need to be referenced by type alias"); - (aliasSymbol).setIsTypeUsedExternally(); - typeSymbolIsVisible = true; - break; - } - } - } - } - } - - if (!typeSymbolIsVisible) { - privacyErrorReporter(typeSymbol); - } - } - }; - - PullTypeChecker.prototype.checkTypePrivacyOfSignatures = function (declSymbol, signatures, typeCheckContext, privacyErrorReporter) { - for (var i = 0; i < signatures.length; i++) { - var signature = signatures[i]; - if (signatures.length && signature.isDefinition()) { - continue; - } - - var typeParams = signature.getTypeParameters(); - for (var j = 0; j < typeParams.length; j++) { - this.checkTypePrivacy(declSymbol, typeParams[j], typeCheckContext, privacyErrorReporter); - } - - var params = signature.getParameters(); - for (var j = 0; j < params.length; j++) { - var paramType = params[j].getType(); - this.checkTypePrivacy(declSymbol, paramType, typeCheckContext, privacyErrorReporter); - } - - var returnType = signature.getReturnType(); - this.checkTypePrivacy(declSymbol, returnType, typeCheckContext, privacyErrorReporter); - } - }; - - PullTypeChecker.prototype.baseListPrivacyErrorReporter = function (declAST, declSymbol, baseAst, isExtendedType, typeSymbol, typeCheckContext) { - var decl = this.resolver.getDeclForAST(declAST); - var enclosingDecl = typeCheckContext.getEnclosingDecl(); - var messageCode; - var messageArguments; - - var typeSymbolName = typeSymbol.getScopedName(); - if (typeSymbol.isContainer()) { - if (!TypeScript.isQuoted(typeSymbolName)) { - typeSymbolName = "'" + typeSymbolName + "'"; - } - if (declAST.nodeType === 13 /* ClassDeclaration */) { - if (isExtendedType) { - messageCode = 90 /* Exported_class__0__extends_class_from_inaccessible_module__1_ */; - messageArguments = [declSymbol.getScopedName(), typeSymbolName]; - } else { - messageCode = 91 /* Exported_class__0__implements_interface_from_inaccessible_module__1_ */; - messageArguments = [declSymbol.getScopedName(), typeSymbolName]; - } - } else { - messageCode = 92 /* Exported_interface__0__extends_interface_from_inaccessible_module__1_ */; - messageArguments = [declSymbol.getDisplayName(), typeSymbolName]; - } - } else { - if (declAST.nodeType === 13 /* ClassDeclaration */) { - if (isExtendedType) { - messageCode = 87 /* Exported_class__0__extends_private_class__1_ */; - messageArguments = [declSymbol.getScopedName(), typeSymbolName]; - } else { - messageCode = 88 /* Exported_class__0__implements_private_interface__1_ */; - messageArguments = [declSymbol.getScopedName(), typeSymbolName]; - } - } else { - messageCode = 89 /* Exported_interface__0__extends_private_interface__1_ */; - messageArguments = [declSymbol.getDisplayName(), typeSymbolName]; - } - } - - this.context.postError(typeCheckContext.scriptName, baseAst.minChar, baseAst.getLength(), messageCode, messageArguments, enclosingDecl, true); - }; - - PullTypeChecker.prototype.variablePrivacyErrorReporter = function (declSymbol, typeSymbol, typeCheckContext) { - var declAST = this.resolver.getASTForSymbol(declSymbol); - var enclosingDecl = typeCheckContext.getEnclosingDecl(); - - var isProperty = declSymbol.getKind() === 4096 /* Property */; - var isPropertyOfClass = false; - var declParent = declSymbol.getContainer(); - if (declParent && (declParent.getKind() === 8 /* Class */ || declParent.getKind() === 32768 /* ConstructorMethod */)) { - isPropertyOfClass = true; - } - - var messageCode; - var messageArguments; - var typeSymbolName = typeSymbol.getScopedName(); - if (typeSymbol.isContainer()) { - if (!TypeScript.isQuoted(typeSymbolName)) { - typeSymbolName = "'" + typeSymbolName + "'"; - } - - if (declSymbol.hasFlag(16 /* Static */)) { - messageCode = 97 /* Public_static_property__0__of__exported_class_is_using_inaccessible_module__1_ */; - messageArguments = [declSymbol.getScopedName(), typeSymbolName]; - } else if (isProperty) { - if (isPropertyOfClass) { - messageCode = 98 /* Public_property__0__of__exported_class_is_using_inaccessible_module__1_ */; - messageArguments = [declSymbol.getScopedName(), typeSymbolName]; - } else { - messageCode = 99 /* Property__0__of__exported_interface_is_using_inaccessible_module__1_ */; - messageArguments = [declSymbol.getScopedName(), typeSymbolName]; - } - } else { - messageCode = 100 /* Exported_variable__0__is_using_inaccessible_module__1_ */; - messageArguments = [declSymbol.getScopedName(), typeSymbolName]; - } - } else { - if (declSymbol.hasFlag(16 /* Static */)) { - messageCode = 93 /* Public_static_property__0__of__exported_class_has_or_is_using_private_type__1_ */; - messageArguments = [declSymbol.getScopedName(), typeSymbolName]; - } else if (isProperty) { - if (isPropertyOfClass) { - messageCode = 94 /* Public_property__0__of__exported_class_has_or_is_using_private_type__1_ */; - messageArguments = [declSymbol.getScopedName(), typeSymbolName]; - } else { - messageCode = 95 /* Property__0__of__exported_interface_has_or_is_using_private_type__1_ */; - messageArguments = [declSymbol.getScopedName(), typeSymbolName]; - } - } else { - messageCode = 96 /* Exported_variable__0__has_or_is_using_private_type__1_ */; - messageArguments = [declSymbol.getScopedName(), typeSymbolName]; - } - } - - this.context.postError(typeCheckContext.scriptName, declAST.minChar, declAST.getLength(), messageCode, messageArguments, enclosingDecl, true); - }; - - PullTypeChecker.prototype.checkFunctionTypePrivacy = function (funcDeclAST, inContextuallyTypedAssignment, typeCheckContext) { - var _this = this; - if (inContextuallyTypedAssignment || (funcDeclAST.getFunctionFlags() & 8192 /* IsFunctionExpression */) || (funcDeclAST.getFunctionFlags() & 16384 /* IsFunctionProperty */)) { - return; - } - - var functionDecl = typeCheckContext.semanticInfo.getDeclForAST(funcDeclAST); - var functionSymbol = functionDecl.getSymbol(); - ; - var functionSignature; - - var isGetter = funcDeclAST.isGetAccessor(); - var isSetter = funcDeclAST.isSetAccessor(); - - if (isGetter || isSetter) { - var accessorSymbol = functionSymbol; - functionSignature = (isGetter ? accessorSymbol.getGetter() : accessorSymbol.getSetter()).getType().getCallSignatures()[0]; - } else { - if (!functionSymbol) { - var parentDecl = functionDecl.getParentDecl(); - functionSymbol = parentDecl.getSymbol(); - if (functionSymbol && functionSymbol.isType() && !(functionSymbol).isNamedTypeSymbol()) { - return; - } - } else if (functionSymbol.getKind() == 65536 /* Method */ && !functionSymbol.getContainer().isNamedTypeSymbol()) { - return; - } - functionSignature = functionDecl.getSignatureSymbol(); - } - - if (!isGetter) { - var funcParams = functionSignature.getParameters(); - for (var i = 0; i < funcParams.length; i++) { - this.checkTypePrivacy(functionSymbol, funcParams[i].getType(), typeCheckContext, function (typeSymbol) { - return _this.functionArgumentTypePrivacyErrorReporter(funcDeclAST, i, funcParams[i], typeSymbol, typeCheckContext); - }); - } - } - - if (!isSetter) { - this.checkTypePrivacy(functionSymbol, functionSignature.getReturnType(), typeCheckContext, function (typeSymbol) { - return _this.functionReturnTypePrivacyErrorReporter(funcDeclAST, functionSignature.getReturnType(), typeSymbol, typeCheckContext); - }); - } - }; - - PullTypeChecker.prototype.functionArgumentTypePrivacyErrorReporter = function (declAST, argIndex, paramSymbol, typeSymbol, typeCheckContext) { - var decl = this.resolver.getDeclForAST(declAST); - var enclosingDecl = typeCheckContext.getEnclosingDecl(); - - var isGetter = declAST.isAccessor() && TypeScript.hasFlag(declAST.getFunctionFlags(), 32 /* GetAccessor */); - var isSetter = declAST.isAccessor() && TypeScript.hasFlag(declAST.getFunctionFlags(), 64 /* SetAccessor */); - var isStatic = (decl.getFlags() & 16 /* Static */) === 16 /* Static */; - var isMethod = decl.getKind() === 65536 /* Method */; - var isMethodOfClass = false; - var declParent = decl.getParentDecl(); - if (declParent && (declParent.getKind() === 8 /* Class */ || declParent.getKind() === 32768 /* ConstructorMethod */)) { - isMethodOfClass = true; - } - - var start = declAST.arguments.members[argIndex].minChar; - var length = declAST.arguments.members[argIndex].getLength(); - - var typeSymbolName = typeSymbol.getScopedName(); - if (typeSymbol.isContainer()) { - if (!TypeScript.isQuoted(typeSymbolName)) { - typeSymbolName = "'" + typeSymbolName + "'"; - } - - if (declAST.isConstructor) { - this.context.postError(typeCheckContext.scriptName, start, length, 110 /* Parameter__0__of_constructor_from_exported_class_is_using_inaccessible_module__1_ */, [paramSymbol.getScopedName(), typeSymbolName], enclosingDecl, true); - } else if (isSetter) { - if (isStatic) { - this.context.postError(typeCheckContext.scriptName, start, length, 111 /* Parameter__0__of_public_static_property_setter_from_exported_class_is_using_inaccessible_module__1_ */, [paramSymbol.getScopedName(), typeSymbolName], enclosingDecl, true); - } else { - this.context.postError(typeCheckContext.scriptName, start, length, 112 /* Parameter__0__of_public_property_setter_from_exported_class_is_using_inaccessible_module__1_ */, [paramSymbol.getScopedName(), typeSymbolName], enclosingDecl, true); - } - } else if (declAST.isConstructMember()) { - this.context.postError(typeCheckContext.scriptName, start, length, 113 /* Parameter__0__of_constructor_signature_from_exported_interface_is_using_inaccessible_module__1_ */, [paramSymbol.getScopedName(), typeSymbolName], enclosingDecl, true); - } else if (declAST.isCallMember()) { - this.context.postError(typeCheckContext.scriptName, start, length, 114 /* Parameter__0__of_call_signature_from_exported_interface_is_using_inaccessible_module__1_ */, [paramSymbol.getScopedName(), typeSymbolName], enclosingDecl, true); - } else if (isMethod) { - if (isStatic) { - this.context.postError(typeCheckContext.scriptName, start, length, 115 /* Parameter__0__of_public_static_method_from_exported_class_is_using_inaccessible_module__1_ */, [paramSymbol.getScopedName(), typeSymbolName], enclosingDecl, true); - } else if (isMethodOfClass) { - this.context.postError(typeCheckContext.scriptName, start, length, 116 /* Parameter__0__of_public_method_from_exported_class_is_using_inaccessible_module__1_ */, [paramSymbol.getScopedName(), typeSymbolName], enclosingDecl, true); - } else { - this.context.postError(typeCheckContext.scriptName, start, length, 117 /* Parameter__0__of_method_from_exported_interface_is_using_inaccessible_module__1_ */, [paramSymbol.getScopedName(), typeSymbolName], enclosingDecl, true); - } - } else if (!isGetter) { - this.context.postError(typeCheckContext.scriptName, start, length, 118 /* Parameter__0__of_exported_function_is_using_inaccessible_module__1_ */, [paramSymbol.getScopedName(), typeSymbolName], enclosingDecl, true); - } - } else { - if (declAST.isConstructor) { - this.context.postError(typeCheckContext.scriptName, start, length, 101 /* Parameter__0__of_constructor_from_exported_class_has_or_is_using_private_type__1_ */, [paramSymbol.getScopedName(), typeSymbolName], enclosingDecl, true); - } else if (isSetter) { - if (isStatic) { - this.context.postError(typeCheckContext.scriptName, start, length, 102 /* Parameter__0__of_public_static_property_setter_from_exported_class_has_or_is_using_private_type__1_ */, [paramSymbol.getScopedName(), typeSymbolName], enclosingDecl, true); - } else { - this.context.postError(typeCheckContext.scriptName, start, length, 103 /* Parameter__0__of_public_property_setter_from_exported_class_has_or_is_using_private_type__1_ */, [paramSymbol.getScopedName(), typeSymbolName], enclosingDecl, true); - } - } else if (declAST.isConstructMember()) { - this.context.postError(typeCheckContext.scriptName, start, length, 104 /* Parameter__0__of_constructor_signature_from_exported_interface_has_or_is_using_private_type__1_ */, [paramSymbol.getScopedName(), typeSymbolName], enclosingDecl, true); - } else if (declAST.isCallMember()) { - this.context.postError(typeCheckContext.scriptName, start, length, 105 /* Parameter__0__of_call_signature_from_exported_interface_has_or_is_using_private_type__1_ */, [paramSymbol.getScopedName(), typeSymbolName], enclosingDecl, true); - } else if (isMethod) { - if (isStatic) { - this.context.postError(typeCheckContext.scriptName, start, length, 106 /* Parameter__0__of_public_static_method_from_exported_class_has_or_is_using_private_type__1_ */, [paramSymbol.getScopedName(), typeSymbolName], enclosingDecl, true); - } else if (isMethodOfClass) { - this.context.postError(typeCheckContext.scriptName, start, length, 107 /* Parameter__0__of_public_method_from_exported_class_has_or_is_using_private_type__1_ */, [paramSymbol.getScopedName(), typeSymbolName], enclosingDecl, true); - } else { - this.context.postError(typeCheckContext.scriptName, start, length, 108 /* Parameter__0__of_method_from_exported_interface_has_or_is_using_private_type__1_ */, [paramSymbol.getScopedName(), typeSymbolName], enclosingDecl, true); - } - } else if (!isGetter && !declAST.isIndexerMember()) { - this.context.postError(typeCheckContext.scriptName, start, length, 109 /* Parameter__0__of_exported_function_has_or_is_using_private_type__1_ */, [paramSymbol.getScopedName(), typeSymbolName], enclosingDecl, true); - } - } - }; - - PullTypeChecker.prototype.functionReturnTypePrivacyErrorReporter = function (declAST, funcReturnType, typeSymbol, typeCheckContext) { - var _this = this; - var decl = this.resolver.getDeclForAST(declAST); - var enclosingDecl = typeCheckContext.getEnclosingDecl(); - - var isGetter = declAST.isAccessor() && TypeScript.hasFlag(declAST.getFunctionFlags(), 32 /* GetAccessor */); - var isSetter = declAST.isAccessor() && TypeScript.hasFlag(declAST.getFunctionFlags(), 64 /* SetAccessor */); - var isStatic = (decl.getFlags() & 16 /* Static */) === 16 /* Static */; - var isMethod = decl.getKind() === 65536 /* Method */; - var isMethodOfClass = false; - var declParent = decl.getParentDecl(); - if (declParent && (declParent.getKind() === 8 /* Class */ || declParent.getKind() === 32768 /* ConstructorMethod */)) { - isMethodOfClass = true; - } - - var messageCode = null; - var messageArguments; - var typeSymbolName = typeSymbol.getScopedName(); - if (typeSymbol.isContainer()) { - if (!TypeScript.isQuoted(typeSymbolName)) { - typeSymbolName = "'" + typeSymbolName + "'"; - } - - if (isGetter) { - if (isStatic) { - messageCode = 128 /* Return_type_of_public_static_property_getter_from_exported_class_is_using_inaccessible_module__0_ */; - messageArguments = [typeSymbolName]; - } else { - messageCode = 129 /* Return_type_of_public_property_getter_from_exported_class_is_using_inaccessible_module__0_ */; - messageArguments = [typeSymbolName]; - } - } else if (declAST.isConstructMember()) { - messageCode = 130 /* Return_type_of_constructor_signature_from_exported_interface_is_using_inaccessible_module__0_ */; - messageArguments = [typeSymbolName]; - } else if (declAST.isCallMember()) { - messageCode = 131 /* Return_type_of_call_signature_from_exported_interface_is_using_inaccessible_module__0_ */; - messageArguments = [typeSymbolName]; - } else if (declAST.isIndexerMember()) { - messageCode = 132 /* Return_type_of_index_signature_from_exported_interface_is_using_inaccessible_module__0_ */; - messageArguments = [typeSymbolName]; - } else if (isMethod) { - if (isStatic) { - messageCode = 133 /* Return_type_of_public_static_method_from_exported_class_is_using_inaccessible_module__0_ */; - messageArguments = [typeSymbolName]; - } else if (isMethodOfClass) { - messageCode = 134 /* Return_type_of_public_method_from_exported_class_is_using_inaccessible_module__0_ */; - messageArguments = [typeSymbolName]; - } else { - messageCode = 135 /* Return_type_of_method_from_exported_interface_is_using_inaccessible_module__0_ */; - messageArguments = [typeSymbolName]; - } - } else if (!isSetter && !declAST.isConstructor) { - messageCode = 136 /* Return_type_of_exported_function_is_using_inaccessible_module__0_ */; - messageArguments = [typeSymbolName]; - } - } else { - if (isGetter) { - if (isStatic) { - messageCode = 119 /* Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_private_type__0_ */; - messageArguments = [typeSymbolName]; - } else { - messageCode = 120 /* Return_type_of_public_property_getter_from_exported_class_has_or_is_using_private_type__0_ */; - messageArguments = [typeSymbolName]; - } - } else if (declAST.isConstructMember()) { - messageCode = 121 /* Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_private_type__0_ */; - messageArguments = [typeSymbolName]; - } else if (declAST.isCallMember()) { - messageCode = 122 /* Return_type_of_call_signature_from_exported_interface_has_or_is_using_private_type__0_ */; - messageArguments = [typeSymbolName]; - } else if (declAST.isIndexerMember()) { - messageCode = 123 /* Return_type_of_index_signature_from_exported_interface_has_or_is_using_private_type__0_ */; - messageArguments = [typeSymbolName]; - } else if (isMethod) { - if (isStatic) { - messageCode = 124 /* Return_type_of_public_static_method_from_exported_class_has_or_is_using_private_type__0_ */; - messageArguments = [typeSymbolName]; - } else if (isMethodOfClass) { - messageCode = 125 /* Return_type_of_public_method_from_exported_class_has_or_is_using_private_type__0_ */; - messageArguments = [typeSymbolName]; - } else { - messageCode = 126 /* Return_type_of_method_from_exported_interface_has_or_is_using_private_type__0_ */; - messageArguments = [typeSymbolName]; - } - } else if (!isSetter && !declAST.isConstructor) { - messageCode = 127 /* Return_type_of_exported_function_has_or_is_using_private_type__0_ */; - messageArguments = [typeSymbolName]; - } - } - - if (messageCode) { - var reportOnFuncDecl = false; - var contextForReturnTypeResolution = new TypeScript.PullTypeResolutionContext(); - if (declAST.returnTypeAnnotation) { - var returnExpressionSymbolAndDiagnostics = this.resolver.resolveTypeReference(declAST.returnTypeAnnotation, decl, contextForReturnTypeResolution); - var returnExpressionSymbol = returnExpressionSymbolAndDiagnostics && returnExpressionSymbolAndDiagnostics.symbol; - if (returnExpressionSymbol === funcReturnType) { - this.context.postError(typeCheckContext.scriptName, declAST.returnTypeAnnotation.minChar, declAST.returnTypeAnnotation.getLength(), messageCode, messageArguments, enclosingDecl, true); - } - } - - if (declAST.block) { - var reportErrorOnReturnExpressions = function (ast, parent, walker) { - var go = true; - switch (ast.nodeType) { - case 12 /* FunctionDeclaration */: - go = false; - break; - - case 93 /* ReturnStatement */: - var returnStatement = ast; - var returnExpressionSymbol = _this.resolver.resolveAST(returnStatement.returnExpression, false, decl, contextForReturnTypeResolution).symbol.getType(); - - if (returnExpressionSymbol === funcReturnType) { - _this.context.postError(typeCheckContext.scriptName, returnStatement.minChar, returnStatement.getLength(), messageCode, messageArguments, enclosingDecl, true); - } else { - reportOnFuncDecl = true; - } - go = false; - break; - - default: - break; - } - - walker.options.goChildren = go; - return ast; - }; - - TypeScript.getAstWalkerFactory().walk(declAST.block, reportErrorOnReturnExpressions); - } - - if (reportOnFuncDecl) { - this.context.postError(typeCheckContext.scriptName, declAST.minChar, declAST.getLength(), messageCode, messageArguments, enclosingDecl, true); - } - } - }; - PullTypeChecker.globalPullTypeCheckPhase = 0; - return PullTypeChecker; - })(); - TypeScript.PullTypeChecker = PullTypeChecker; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (PullDeclEdit) { - PullDeclEdit[PullDeclEdit["NoChanges"] = 0] = "NoChanges"; - PullDeclEdit[PullDeclEdit["DeclAdded"] = 1] = "DeclAdded"; - PullDeclEdit[PullDeclEdit["DeclRemoved"] = 2] = "DeclRemoved"; - PullDeclEdit[PullDeclEdit["DeclChanged"] = 3] = "DeclChanged"; - })(TypeScript.PullDeclEdit || (TypeScript.PullDeclEdit = {})); - var PullDeclEdit = TypeScript.PullDeclEdit; - - var PullDeclDiff = (function () { - function PullDeclDiff(oldDecl, newDecl, kind) { - this.oldDecl = oldDecl; - this.newDecl = newDecl; - this.kind = kind; - } - return PullDeclDiff; - })(); - TypeScript.PullDeclDiff = PullDeclDiff; - - var PullDeclDiffer = (function () { - function PullDeclDiffer(oldSemanticInfo, newSemanticInfo) { - this.oldSemanticInfo = oldSemanticInfo; - this.newSemanticInfo = newSemanticInfo; - this.differences = []; - } - PullDeclDiffer.diffDecls = function (oldDecl, oldSemanticInfo, newDecl, newSemanticInfo) { - var declDiffer = new PullDeclDiffer(oldSemanticInfo, newSemanticInfo); - declDiffer.diff(oldDecl, newDecl); - return declDiffer.differences; - }; - - PullDeclDiffer.prototype.diff = function (oldDecl, newDecl) { - TypeScript.Debug.assert(oldDecl.getName() === newDecl.getName()); - TypeScript.Debug.assert(oldDecl.getKind() === newDecl.getKind()); - - var oldAST = this.oldSemanticInfo.getASTForDecl(oldDecl); - var newAST = this.newSemanticInfo.getASTForDecl(newDecl); - TypeScript.Debug.assert(oldAST !== undefined); - TypeScript.Debug.assert(newAST !== undefined); - - if (oldAST === newAST) { - return; - } - - this.diff1(oldDecl, newDecl, oldAST, newAST, oldDecl.childDeclTypeCache, newDecl.childDeclTypeCache); - this.diff1(oldDecl, newDecl, oldAST, newAST, oldDecl.childDeclTypeParameterCache, newDecl.childDeclTypeParameterCache); - this.diff1(oldDecl, newDecl, oldAST, newAST, oldDecl.childDeclValueCache, newDecl.childDeclValueCache); - this.diff1(oldDecl, newDecl, oldAST, newAST, oldDecl.childDeclNamespaceCache, newDecl.childDeclNamespaceCache); - - if (!this.isEquivalent(oldAST, newAST)) { - this.differences.push(new PullDeclDiff(oldDecl, newDecl, 3 /* DeclChanged */)); - } - }; - - PullDeclDiffer.prototype.diff1 = function (oldDecl, newDecl, oldAST, newAST, oldNameToDecls, newNameToDecls) { - var oldChildrenOfName; - var newChildrenOfName; - var oldChild; - var newChild; - - for (var name in oldNameToDecls) { - oldChildrenOfName = oldNameToDecls[name] || PullDeclDiffer.emptyDeclArray; - newChildrenOfName = newNameToDecls[name] || PullDeclDiffer.emptyDeclArray; - - for (var i = 0, n = oldChildrenOfName.length; i < n; i++) { - oldChild = oldChildrenOfName[i]; - - switch (oldChild.getKind()) { - case 131072 /* FunctionExpression */: - case 512 /* ObjectLiteral */: - case 8388608 /* ObjectType */: - case 16777216 /* FunctionType */: - case 33554432 /* ConstructorType */: - continue; - } - - if (i < newChildrenOfName.length) { - newChild = newChildrenOfName[i]; - - if (oldChild.getKind() === newChild.getKind()) { - this.diff(oldChild, newChildrenOfName[i]); - } else { - this.differences.push(new PullDeclDiff(oldChild, null, 2 /* DeclRemoved */)); - this.differences.push(new PullDeclDiff(oldDecl, newChild, 1 /* DeclAdded */)); - } - } else { - this.differences.push(new PullDeclDiff(oldChild, null, 2 /* DeclRemoved */)); - } - } - } - - for (var name in newNameToDecls) { - oldChildrenOfName = oldNameToDecls[name] || PullDeclDiffer.emptyDeclArray; - newChildrenOfName = newNameToDecls[name] || PullDeclDiffer.emptyDeclArray; - - for (var i = oldChildrenOfName.length, n = newChildrenOfName.length; i < n; i++) { - newChild = newChildrenOfName[i]; - this.differences.push(new PullDeclDiff(oldDecl, newChild, 1 /* DeclAdded */)); - } - } - }; - - PullDeclDiffer.prototype.isEquivalent = function (oldAST, newAST) { - TypeScript.Debug.assert(oldAST !== null); - TypeScript.Debug.assert(newAST !== null); - TypeScript.Debug.assert(oldAST !== newAST); - - if (oldAST.nodeType !== newAST.nodeType || oldAST.getFlags() !== newAST.getFlags()) { - return false; - } - - switch (oldAST.nodeType) { - case 16 /* ImportDeclaration */: - return this.importDeclarationIsEquivalent(oldAST, newAST); - case 15 /* ModuleDeclaration */: - return this.moduleDeclarationIsEquivalent(oldAST, newAST); - case 13 /* ClassDeclaration */: - return this.classDeclarationIsEquivalent(oldAST, newAST); - case 14 /* InterfaceDeclaration */: - return this.interfaceDeclarationIsEquivalent(oldAST, newAST); - case 19 /* Parameter */: - return this.argumentDeclarationIsEquivalent(oldAST, newAST); - case 17 /* VariableDeclarator */: - return this.variableDeclarationIsEquivalent(oldAST, newAST); - case 9 /* TypeParameter */: - return this.typeParameterIsEquivalent(oldAST, newAST); - case 12 /* FunctionDeclaration */: - return this.functionDeclarationIsEquivalent(oldAST, newAST); - case 101 /* CatchClause */: - return this.catchClauseIsEquivalent(oldAST, newAST); - case 99 /* WithStatement */: - return this.withStatementIsEquivalent(oldAST, newAST); - case 2 /* Script */: - return this.scriptIsEquivalent(oldAST, newAST); - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - PullDeclDiffer.prototype.importDeclarationIsEquivalent = function (decl1, decl2) { - return TypeScript.structuralEqualsNotIncludingPosition(decl1.alias, decl2.alias); - }; - - PullDeclDiffer.prototype.typeDeclarationIsEquivalent = function (decl1, decl2) { - return decl1.getVarFlags() === decl2.getVarFlags() && TypeScript.structuralEqualsNotIncludingPosition(decl1.typeParameters, decl2.typeParameters) && TypeScript.structuralEqualsNotIncludingPosition(decl1.extendsList, decl2.extendsList) && TypeScript.structuralEqualsNotIncludingPosition(decl1.implementsList, decl2.implementsList); - }; - - PullDeclDiffer.prototype.classDeclarationIsEquivalent = function (decl1, decl2) { - return this.typeDeclarationIsEquivalent(decl1, decl2); - }; - - PullDeclDiffer.prototype.interfaceDeclarationIsEquivalent = function (decl1, decl2) { - return this.typeDeclarationIsEquivalent(decl1, decl2); - }; - - PullDeclDiffer.prototype.typeParameterIsEquivalent = function (decl1, decl2) { - return TypeScript.structuralEqualsNotIncludingPosition(decl1.constraint, decl2.constraint); - }; - - PullDeclDiffer.prototype.boundDeclarationIsEquivalent = function (decl1, decl2) { - if (decl1.getVarFlags() === decl2.getVarFlags() && TypeScript.structuralEqualsNotIncludingPosition(decl1.typeExpr, decl2.typeExpr)) { - if (decl1.typeExpr === null) { - return TypeScript.structuralEqualsNotIncludingPosition(decl1.init, decl2.init); - } else { - return true; - } - } - - return false; - }; - - PullDeclDiffer.prototype.argumentDeclarationIsEquivalent = function (decl1, decl2) { - return this.boundDeclarationIsEquivalent(decl1, decl2) && decl1.isOptional === decl2.isOptional; - }; - - PullDeclDiffer.prototype.variableDeclarationIsEquivalent = function (decl1, decl2) { - return this.boundDeclarationIsEquivalent(decl1, decl2); - }; - - PullDeclDiffer.prototype.functionDeclarationIsEquivalent = function (decl1, decl2) { - if (decl1.hint === decl2.hint && decl1.getFunctionFlags() === decl2.getFunctionFlags() && decl1.variableArgList === decl2.variableArgList && decl1.isConstructor === decl2.isConstructor && TypeScript.structuralEqualsNotIncludingPosition(decl1.returnTypeAnnotation, decl2.returnTypeAnnotation) && TypeScript.structuralEqualsNotIncludingPosition(decl1.typeArguments, decl2.typeArguments) && TypeScript.structuralEqualsNotIncludingPosition(decl1.arguments, decl2.arguments)) { - if (decl1.returnTypeAnnotation === null) { - return TypeScript.structuralEqualsNotIncludingPosition(decl1.block, decl2.block); - } else { - return true; - } - } - - return false; - }; - - PullDeclDiffer.prototype.catchClauseIsEquivalent = function (decl1, decl2) { - return TypeScript.structuralEqualsNotIncludingPosition(decl1.param, decl2.param) && TypeScript.structuralEqualsNotIncludingPosition(decl1.body, decl2.body); - }; - - PullDeclDiffer.prototype.withStatementIsEquivalent = function (decl1, decl2) { - return TypeScript.structuralEqualsNotIncludingPosition(decl1.expr, decl2.expr) && TypeScript.structuralEqualsNotIncludingPosition(decl1.body, decl2.body); - }; - - PullDeclDiffer.prototype.scriptIsEquivalent = function (decl1, decl2) { - return true; - }; - - PullDeclDiffer.prototype.moduleDeclarationIsEquivalent = function (decl1, decl2) { - return decl1.getModuleFlags() === decl2.getModuleFlags() && decl2.prettyName === decl2.prettyName && TypeScript.ArrayUtilities.sequenceEquals(decl1.amdDependencies, decl2.amdDependencies, TypeScript.StringUtilities.stringEquals); - }; - PullDeclDiffer.emptyDeclArray = []; - return PullDeclDiffer; - })(); - TypeScript.PullDeclDiffer = PullDeclDiffer; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - TypeScript.declCacheHit = 0; - TypeScript.declCacheMiss = 0; - TypeScript.symbolCacheHit = 0; - TypeScript.symbolCacheMiss = 0; - - var SemanticInfo = (function () { - function SemanticInfo(compilationUnitPath) { - this.topLevelDecls = []; - this.topLevelSynthesizedDecls = []; - this.astDeclMap = new TypeScript.DataMap(); - this.declASTMap = new TypeScript.DataMap(); - this.syntaxElementDeclMap = new TypeScript.DataMap(); - this.declSyntaxElementMap = new TypeScript.DataMap(); - this.astSymbolMap = new TypeScript.DataMap(); - this.symbolASTMap = new TypeScript.DataMap(); - this.syntaxElementSymbolMap = new TypeScript.DataMap(); - this.symbolSyntaxElementMap = new TypeScript.DataMap(); - this.properties = new SemanticInfoProperties(); - this.hasBeenTypeChecked = false; - this.compilationUnitPath = compilationUnitPath; - } - SemanticInfo.prototype.addTopLevelDecl = function (decl) { - this.topLevelDecls[this.topLevelDecls.length] = decl; - }; - - SemanticInfo.prototype.setTypeChecked = function () { - this.hasBeenTypeChecked = true; - }; - SemanticInfo.prototype.getTypeChecked = function () { - return this.hasBeenTypeChecked; - }; - SemanticInfo.prototype.invalidate = function () { - this.astSymbolMap = new TypeScript.DataMap(); - this.symbolASTMap = new TypeScript.DataMap(); - }; - - SemanticInfo.prototype.getTopLevelDecls = function () { - return this.topLevelDecls; - }; - - SemanticInfo.prototype.getPath = function () { - return this.compilationUnitPath; - }; - - SemanticInfo.prototype.addSynthesizedDecl = function (decl) { - this.topLevelSynthesizedDecls[this.topLevelSynthesizedDecls.length] = decl; - }; - SemanticInfo.prototype.getSynthesizedDecls = function () { - return this.topLevelSynthesizedDecls; - }; - - SemanticInfo.prototype.getDeclForAST = function (ast) { - return this.astDeclMap.read(ast.getID().toString()); - }; - - SemanticInfo.prototype.setDeclForAST = function (ast, decl) { - this.astDeclMap.link(ast.getID().toString(), decl); - }; - - SemanticInfo.prototype.getDeclKey = function (decl) { - var decl1 = decl; - - if (!decl1.__declKey) { - decl1.__declKey = decl.getDeclID().toString() + "-" + decl.getKind().toString(); - } - - return decl1.__declKey; - }; - - SemanticInfo.prototype.getASTForDecl = function (decl) { - return this.declASTMap.read(this.getDeclKey(decl)); - }; - - SemanticInfo.prototype.setASTForDecl = function (decl, ast) { - this.declASTMap.link(this.getDeclKey(decl), ast); - }; - - SemanticInfo.prototype.setSymbolAndDiagnosticsForAST = function (ast, symbolAndDiagnostics) { - this.astSymbolMap.link(ast.getID().toString(), symbolAndDiagnostics); - this.symbolASTMap.link(symbolAndDiagnostics.symbol.getSymbolID().toString(), ast); - }; - - SemanticInfo.prototype.getSymbolAndDiagnosticsForAST = function (ast) { - return this.astSymbolMap.read(ast.getID().toString()); - }; - - SemanticInfo.prototype.getASTForSymbol = function (symbol) { - return this.symbolASTMap.read(symbol.getSymbolID().toString()); - }; - - SemanticInfo.prototype.getSyntaxElementForDecl = function (decl) { - return this.declSyntaxElementMap.read(this.getDeclKey(decl)); - }; - - SemanticInfo.prototype.setSyntaxElementForDecl = function (decl, syntaxElement) { - this.declSyntaxElementMap.link(this.getDeclKey(decl), syntaxElement); - }; - - SemanticInfo.prototype.getDeclForSyntaxElement = function (syntaxElement) { - return this.syntaxElementDeclMap.read(TypeScript.Collections.identityHashCode(syntaxElement).toString()); - }; - - SemanticInfo.prototype.setDeclForSyntaxElement = function (syntaxElement, decl) { - this.syntaxElementDeclMap.link(TypeScript.Collections.identityHashCode(syntaxElement).toString(), decl); - }; - - SemanticInfo.prototype.getSyntaxElementForSymbol = function (symbol) { - return this.symbolSyntaxElementMap.read(symbol.getSymbolID().toString()); - }; - - SemanticInfo.prototype.getSymbolForSyntaxElement = function (syntaxElement) { - return this.syntaxElementSymbolMap.read(TypeScript.Collections.identityHashCode(syntaxElement).toString()); - }; - - SemanticInfo.prototype.setSymbolForSyntaxElement = function (syntaxElement, symbol) { - this.syntaxElementSymbolMap.link(TypeScript.Collections.identityHashCode(syntaxElement).toString(), symbol); - this.symbolSyntaxElementMap.link(symbol.getSymbolID().toString(), syntaxElement); - }; - - SemanticInfo.prototype.getDiagnostics = function (semanticErrors) { - for (var i = 0; i < this.topLevelDecls.length; i++) { - TypeScript.getDiagnosticsFromEnclosingDecl(this.topLevelDecls[i], semanticErrors); - } - }; - - SemanticInfo.prototype.getProperties = function () { - return this.properties; - }; - return SemanticInfo; - })(); - TypeScript.SemanticInfo = SemanticInfo; - - var SemanticInfoProperties = (function () { - function SemanticInfoProperties() { - this.unitContainsBool = false; - } - return SemanticInfoProperties; - })(); - TypeScript.SemanticInfoProperties = SemanticInfoProperties; - - var SemanticInfoChain = (function () { - function SemanticInfoChain() { - this.units = [new SemanticInfo("")]; - this.declCache = new TypeScript.BlockIntrinsics(); - this.symbolCache = new TypeScript.BlockIntrinsics(); - this.unitCache = new TypeScript.BlockIntrinsics(); - this.declSymbolMap = new TypeScript.DataMap(); - this.anyTypeSymbol = null; - this.booleanTypeSymbol = null; - this.numberTypeSymbol = null; - this.stringTypeSymbol = null; - this.nullTypeSymbol = null; - this.undefinedTypeSymbol = null; - this.elementTypeSymbol = null; - this.voidTypeSymbol = null; - if (TypeScript.globalBinder) { - TypeScript.globalBinder.semanticInfoChain = this; - } - - var globalDecl = this.getGlobalDecl(); - var globalInfo = this.units[0]; - globalInfo.addTopLevelDecl(globalDecl); - } - SemanticInfoChain.prototype.addPrimitiveType = function (name, globalDecl) { - var span = new TypeScript.TextSpan(0, 0); - var decl = new TypeScript.PullDecl(name, name, 2 /* Primitive */, 0 /* None */, span, ""); - var symbol = new TypeScript.PullPrimitiveTypeSymbol(name); - - symbol.addDeclaration(decl); - decl.setSymbol(symbol); - - symbol.setResolved(); - - if (globalDecl) { - globalDecl.addChildDecl(decl); - } - - return symbol; - }; - - SemanticInfoChain.prototype.addPrimitiveValue = function (name, type, globalDecl) { - var span = new TypeScript.TextSpan(0, 0); - var decl = new TypeScript.PullDecl(name, name, 1024 /* Variable */, 8 /* Ambient */, span, ""); - var symbol = new TypeScript.PullSymbol(name, 1024 /* Variable */); - - symbol.addDeclaration(decl); - decl.setSymbol(symbol); - symbol.setType(type); - symbol.setResolved(); - - globalDecl.addChildDecl(decl); - }; - - SemanticInfoChain.prototype.getGlobalDecl = function () { - var span = new TypeScript.TextSpan(0, 0); - var globalDecl = new TypeScript.PullDecl("", "", 0 /* Global */, 0 /* None */, span, ""); - - this.anyTypeSymbol = this.addPrimitiveType("any", globalDecl); - this.booleanTypeSymbol = this.addPrimitiveType("boolean", globalDecl); - this.numberTypeSymbol = this.addPrimitiveType("number", globalDecl); - this.stringTypeSymbol = this.addPrimitiveType("string", globalDecl); - this.voidTypeSymbol = this.addPrimitiveType("void", globalDecl); - this.elementTypeSymbol = this.addPrimitiveType("_element", globalDecl); - - this.nullTypeSymbol = this.addPrimitiveType("null", null); - this.undefinedTypeSymbol = this.addPrimitiveType("undefined", null); - this.addPrimitiveValue("undefined", this.undefinedTypeSymbol, globalDecl); - this.addPrimitiveValue("null", this.nullTypeSymbol, globalDecl); - - return globalDecl; - }; - - SemanticInfoChain.prototype.addUnit = function (unit) { - this.units[this.units.length] = unit; - this.unitCache[unit.getPath()] = unit; - }; - - SemanticInfoChain.prototype.getUnit = function (compilationUnitPath) { - for (var i = 0; i < this.units.length; i++) { - if (this.units[i].getPath() === compilationUnitPath) { - return this.units[i]; - } - } - - return null; - }; - - SemanticInfoChain.prototype.updateUnit = function (oldUnit, newUnit) { - for (var i = 0; i < this.units.length; i++) { - if (this.units[i].getPath() === oldUnit.getPath()) { - this.units[i] = newUnit; - this.unitCache[oldUnit.getPath()] = newUnit; - return; - } - } - }; - - SemanticInfoChain.prototype.collectAllTopLevelDecls = function () { - var decls = []; - var unitDecls; - - for (var i = 0; i < this.units.length; i++) { - unitDecls = this.units[i].getTopLevelDecls(); - for (var j = 0; j < unitDecls.length; j++) { - decls[decls.length] = unitDecls[j]; - } - } - - return decls; - }; - - SemanticInfoChain.prototype.collectAllSynthesizedDecls = function () { - var decls = []; - var synthDecls; - - for (var i = 0; i < this.units.length; i++) { - synthDecls = this.units[i].getSynthesizedDecls(); - for (var j = 0; j < synthDecls.length; j++) { - decls[decls.length] = synthDecls[j]; - } - } - - return decls; - }; - - SemanticInfoChain.prototype.getDeclPathCacheID = function (declPath, declKind) { - var cacheID = ""; - - for (var i = 0; i < declPath.length; i++) { - cacheID += "#" + declPath[i]; - } - - return cacheID + "#" + declKind.toString(); - }; - - SemanticInfoChain.prototype.findDecls = function (declPath, declKind) { - var cacheID = this.getDeclPathCacheID(declPath, declKind); - - if (declPath.length) { - var cachedDecls = this.declCache[cacheID]; - - if (cachedDecls && cachedDecls.length) { - TypeScript.declCacheHit++; - return cachedDecls; - } - } - - TypeScript.declCacheMiss++; - - var declsToSearch = this.collectAllTopLevelDecls(); - - var decls = []; - var path; - var foundDecls = []; - var keepSearching = (declKind & 4 /* Container */) || (declKind & 16 /* Interface */); - - for (var i = 0; i < declPath.length; i++) { - path = declPath[i]; - decls = []; - - for (var j = 0; j < declsToSearch.length; j++) { - foundDecls = declsToSearch[j].searchChildDecls(path, declKind); - - for (var k = 0; k < foundDecls.length; k++) { - decls[decls.length] = foundDecls[k]; - } - - if (foundDecls.length && !keepSearching) { - break; - } - } - - declsToSearch = decls; - - if (!declsToSearch) { - break; - } - } - - if (decls.length) { - this.declCache[cacheID] = decls; - } - - return decls; - }; - - SemanticInfoChain.prototype.findSymbol = function (declPath, declType) { - var cacheID = this.getDeclPathCacheID(declPath, declType); - - if (declPath.length) { - var cachedSymbol = this.symbolCache[cacheID]; - - if (cachedSymbol) { - TypeScript.symbolCacheHit++; - return cachedSymbol; - } - } - - TypeScript.symbolCacheMiss++; - - var decls = this.findDecls(declPath, declType); - var symbol = null; - - if (decls.length) { - symbol = decls[0].getSymbol(); - - if (symbol) { - this.symbolCache[cacheID] = symbol; - - symbol.addCacheID(cacheID); - } - } - - return symbol; - }; - - SemanticInfoChain.prototype.cacheGlobalSymbol = function (symbol, kind) { - var cacheID1 = this.getDeclPathCacheID([symbol.getName()], kind); - var cacheID2 = this.getDeclPathCacheID([symbol.getName()], symbol.getKind()); - - if (!this.symbolCache[cacheID1]) { - this.symbolCache[cacheID1] = symbol; - symbol.addCacheID(cacheID1); - } - - if (!this.symbolCache[cacheID2]) { - this.symbolCache[cacheID2] = symbol; - symbol.addCacheID(cacheID2); - } - }; - - SemanticInfoChain.prototype.cleanDecl = function (decl) { - decl.setSymbol(null); - decl.setSignatureSymbol(null); - decl.setSpecializingSignatureSymbol(null); - decl.setIsBound(false); - - var children = decl.getChildDecls(); - - for (var i = 0; i < children.length; i++) { - this.cleanDecl(children[i]); - } - - var typeParameters = decl.getTypeParameters(); - - for (var i = 0; i < typeParameters.length; i++) { - this.cleanDecl(typeParameters[i]); - } - - var valueDecl = decl.getValueDecl(); - - if (valueDecl) { - this.cleanDecl(valueDecl); - } - }; - - SemanticInfoChain.prototype.cleanAllDecls = function () { - var topLevelDecls = this.collectAllTopLevelDecls(); - - for (var i = 1; i < topLevelDecls.length; i++) { - this.cleanDecl(topLevelDecls[i]); - } - - var synthesizedDecls = this.collectAllSynthesizedDecls(); - - for (var i = 0; i < synthesizedDecls.length; i++) { - this.cleanDecl(synthesizedDecls[i]); - } - }; - - SemanticInfoChain.prototype.update = function () { - this.declCache = new TypeScript.BlockIntrinsics(); - this.symbolCache = new TypeScript.BlockIntrinsics(); - this.units[0] = new SemanticInfo(""); - this.units[0].addTopLevelDecl(this.getGlobalDecl()); - this.cleanAllDecls(); - - for (var unit in this.unitCache) { - if (this.unitCache[unit]) { - this.unitCache[unit].invalidate(); - } - } - }; - - SemanticInfoChain.prototype.invalidateUnit = function (compilationUnitPath) { - var unit = this.unitCache[compilationUnitPath]; - if (unit) { - unit.invalidate(); - } - }; - - SemanticInfoChain.prototype.getDeclForAST = function (ast, unitPath) { - var unit = this.unitCache[unitPath]; - - if (unit) { - return unit.getDeclForAST(ast); - } - - return null; - }; - - SemanticInfoChain.prototype.getASTForDecl = function (decl) { - var unit = this.unitCache[decl.getScriptName()]; - - if (unit) { - return unit.getASTForDecl(decl); - } - - return null; - }; - - SemanticInfoChain.prototype.getSymbolAndDiagnosticsForAST = function (ast, unitPath) { - var unit = this.unitCache[unitPath]; - - if (unit) { - return unit.getSymbolAndDiagnosticsForAST(ast); - } - - return null; - }; - - SemanticInfoChain.prototype.getASTForSymbol = function (symbol, unitPath) { - var unit = this.unitCache[unitPath]; - - if (unit) { - return unit.getASTForSymbol(symbol); - } - - return null; - }; - - SemanticInfoChain.prototype.setSymbolAndDiagnosticsForAST = function (ast, symbolAndDiagnostics, unitPath) { - var unit = this.unitCache[unitPath]; - - if (unit) { - unit.setSymbolAndDiagnosticsForAST(ast, symbolAndDiagnostics); - } - }; - - SemanticInfoChain.prototype.setSymbolForDecl = function (decl, symbol) { - this.declSymbolMap.link(decl.getDeclID().toString(), symbol); - }; - SemanticInfoChain.prototype.getSymbolForDecl = function (decl) { - return this.declSymbolMap.read(decl.getDeclID().toString()); - }; - - SemanticInfoChain.prototype.removeSymbolFromCache = function (symbol) { - var path = [symbol.getName()]; - var kind = (symbol.getKind() & TypeScript.PullElementKind.SomeType) !== 0 ? TypeScript.PullElementKind.SomeType : TypeScript.PullElementKind.SomeValue; - - var kindID = this.getDeclPathCacheID(path, kind); - var symID = this.getDeclPathCacheID(path, symbol.getKind()); - - symbol.addCacheID(kindID); - symbol.addCacheID(symID); - - symbol.invalidateCachedIDs(this.symbolCache); - }; - - SemanticInfoChain.prototype.postDiagnostics = function () { - var errors = []; - - for (var i = 1; i < this.units.length; i++) { - this.units[i].getDiagnostics(errors); - } - - return errors; - }; - return SemanticInfoChain; - })(); - TypeScript.SemanticInfoChain = SemanticInfoChain; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var DeclCollectionContext = (function () { - function DeclCollectionContext(semanticInfo, scriptName) { - if (typeof scriptName === "undefined") { scriptName = ""; } - this.semanticInfo = semanticInfo; - this.scriptName = scriptName; - this.parentChain = []; - this.foundValueDecl = false; - } - DeclCollectionContext.prototype.getParent = function () { - return this.parentChain ? this.parentChain[this.parentChain.length - 1] : null; - }; - - DeclCollectionContext.prototype.pushParent = function (parentDecl) { - if (parentDecl) { - this.parentChain[this.parentChain.length] = parentDecl; - } - }; - - DeclCollectionContext.prototype.popParent = function () { - this.parentChain.length--; - }; - return DeclCollectionContext; - })(); - TypeScript.DeclCollectionContext = DeclCollectionContext; - - function preCollectImportDecls(ast, parentAST, context) { - var importDecl = ast; - var declFlags = 0 /* None */; - var span = TypeScript.TextSpan.fromBounds(importDecl.minChar, importDecl.limChar); - - var parent = context.getParent(); - - if (parent && (parent.getKind() === 536870912 /* WithBlock */ || (parent.getFlags() & 2097152 /* DeclaredInAWithBlock */))) { - declFlags |= 2097152 /* DeclaredInAWithBlock */; - } - - var decl = new TypeScript.PullDecl(importDecl.id.text, importDecl.id.actualText, 256 /* TypeAlias */, declFlags, span, context.scriptName); - context.semanticInfo.setDeclForAST(ast, decl); - context.semanticInfo.setASTForDecl(decl, ast); - - parent.addChildDecl(decl); - decl.setParentDecl(parent); - - return false; - } - TypeScript.preCollectImportDecls = preCollectImportDecls; - - function preCollectModuleDecls(ast, parentAST, context) { - var moduleDecl = ast; - var declFlags = 0 /* None */; - var modName = (moduleDecl.name).text; - var isDynamic = TypeScript.isQuoted(modName) || TypeScript.hasFlag(moduleDecl.getModuleFlags(), 512 /* IsDynamic */); - var kind = 4 /* Container */; - - if (TypeScript.hasFlag(moduleDecl.getModuleFlags(), 8 /* Ambient */)) { - declFlags |= 8 /* Ambient */; - } - - if (TypeScript.hasFlag(moduleDecl.getModuleFlags(), 1 /* Exported */)) { - declFlags |= 1 /* Exported */; - } - - if (TypeScript.hasFlag(moduleDecl.getModuleFlags(), 128 /* IsEnum */)) { - declFlags |= (4096 /* Enum */ | 131072 /* InitializedEnum */); - kind = 64 /* Enum */; - } else { - kind = isDynamic ? 32 /* DynamicModule */ : 4 /* Container */; - } - - var span = TypeScript.TextSpan.fromBounds(moduleDecl.minChar, moduleDecl.limChar); - - var decl = new TypeScript.PullDecl(modName, (moduleDecl.name).actualText, kind, declFlags, span, context.scriptName); - context.semanticInfo.setDeclForAST(ast, decl); - context.semanticInfo.setASTForDecl(decl, ast); - - var parent = context.getParent(); - parent.addChildDecl(decl); - decl.setParentDecl(parent); - - context.pushParent(decl); - - return true; - } - TypeScript.preCollectModuleDecls = preCollectModuleDecls; - - function preCollectClassDecls(classDecl, parentAST, context) { - var declFlags = 0 /* None */; - var constructorDeclKind = 1024 /* Variable */; - - if (TypeScript.hasFlag(classDecl.getVarFlags(), 8 /* Ambient */)) { - declFlags |= 8 /* Ambient */; - } - - if (TypeScript.hasFlag(classDecl.getVarFlags(), 1 /* Exported */)) { - declFlags |= 1 /* Exported */; - } - - var span = TypeScript.TextSpan.fromBounds(classDecl.minChar, classDecl.limChar); - - var decl = new TypeScript.PullDecl(classDecl.name.text, classDecl.name.actualText, 8 /* Class */, declFlags, span, context.scriptName); - - var constructorDecl = new TypeScript.PullDecl(classDecl.name.text, classDecl.name.actualText, constructorDeclKind, declFlags | 16384 /* ClassConstructorVariable */, span, context.scriptName); - - decl.setValueDecl(constructorDecl); - - var parent = context.getParent(); - parent.addChildDecl(decl); - parent.addChildDecl(constructorDecl); - decl.setParentDecl(parent); - constructorDecl.setParentDecl(parent); - - context.pushParent(decl); - - context.semanticInfo.setDeclForAST(classDecl, decl); - context.semanticInfo.setASTForDecl(decl, classDecl); - context.semanticInfo.setASTForDecl(constructorDecl, classDecl); - - return true; - } - TypeScript.preCollectClassDecls = preCollectClassDecls; - - function createObjectTypeDeclaration(interfaceDecl, context) { - var declFlags = 0 /* None */; - - var span = TypeScript.TextSpan.fromBounds(interfaceDecl.minChar, interfaceDecl.limChar); - - var parent = context.getParent(); - - if (parent && (parent.getKind() === 536870912 /* WithBlock */ || (parent.getFlags() & 2097152 /* DeclaredInAWithBlock */))) { - declFlags |= 2097152 /* DeclaredInAWithBlock */; - } - - var decl = new TypeScript.PullDecl("", "", 8388608 /* ObjectType */, declFlags, span, context.scriptName); - context.semanticInfo.setDeclForAST(interfaceDecl, decl); - context.semanticInfo.setASTForDecl(decl, interfaceDecl); - - if (parent) { - parent.addChildDecl(decl); - decl.setParentDecl(parent); - } - - context.pushParent(decl); - - return true; - } - TypeScript.createObjectTypeDeclaration = createObjectTypeDeclaration; - - function preCollectInterfaceDecls(interfaceDecl, parentAST, context) { - var declFlags = 0 /* None */; - - if (interfaceDecl.getFlags() & 8 /* TypeReference */) { - return createObjectTypeDeclaration(interfaceDecl, context); - } - - if (TypeScript.hasFlag(interfaceDecl.getVarFlags(), 1 /* Exported */)) { - declFlags |= 1 /* Exported */; - } - - var span = TypeScript.TextSpan.fromBounds(interfaceDecl.minChar, interfaceDecl.limChar); - - var decl = new TypeScript.PullDecl(interfaceDecl.name.text, interfaceDecl.name.actualText, 16 /* Interface */, declFlags, span, context.scriptName); - context.semanticInfo.setDeclForAST(interfaceDecl, decl); - context.semanticInfo.setASTForDecl(decl, interfaceDecl); - - var parent = context.getParent(); - - if (parent) { - parent.addChildDecl(decl); - decl.setParentDecl(parent); - } - - context.pushParent(decl); - - return true; - } - TypeScript.preCollectInterfaceDecls = preCollectInterfaceDecls; - - function preCollectParameterDecl(argDecl, parentAST, context) { - var declFlags = 0 /* None */; - - if (TypeScript.hasFlag(argDecl.getVarFlags(), 2 /* Private */)) { - declFlags |= 2 /* Private */; - } else { - declFlags |= 4 /* Public */; - } - - if (TypeScript.hasFlag(argDecl.getFlags(), 4 /* OptionalName */) || TypeScript.hasFlag(argDecl.id.getFlags(), 4 /* OptionalName */)) { - declFlags |= 128 /* Optional */; - } - - var parent = context.getParent(); - - if (parent && (parent.getKind() === 536870912 /* WithBlock */ || (parent.getFlags() & 2097152 /* DeclaredInAWithBlock */))) { - declFlags |= 2097152 /* DeclaredInAWithBlock */; - } - - var span = TypeScript.TextSpan.fromBounds(argDecl.minChar, argDecl.limChar); - - var decl = new TypeScript.PullDecl(argDecl.id.text, argDecl.id.actualText, 2048 /* Parameter */, declFlags, span, context.scriptName); - - parent.addChildDecl(decl); - decl.setParentDecl(parent); - - if (TypeScript.hasFlag(argDecl.getVarFlags(), 256 /* Property */)) { - var propDecl = new TypeScript.PullDecl(argDecl.id.text, argDecl.id.actualText, 4096 /* Property */, declFlags, span, context.scriptName); - propDecl.setValueDecl(decl); - context.parentChain[context.parentChain.length - 2].addChildDecl(propDecl); - propDecl.setParentDecl(context.parentChain[context.parentChain.length - 2]); - context.semanticInfo.setASTForDecl(decl, argDecl); - context.semanticInfo.setASTForDecl(propDecl, argDecl); - context.semanticInfo.setDeclForAST(argDecl, propDecl); - } else { - context.semanticInfo.setASTForDecl(decl, argDecl); - context.semanticInfo.setDeclForAST(argDecl, decl); - } - - if (argDecl.typeExpr && ((argDecl.typeExpr).term.nodeType === 14 /* InterfaceDeclaration */ || (argDecl.typeExpr).term.nodeType === 12 /* FunctionDeclaration */)) { - var declCollectionContext = new DeclCollectionContext(context.semanticInfo); - - if (parent) { - declCollectionContext.pushParent(parent); - } - - declCollectionContext.scriptName = context.scriptName; - - TypeScript.getAstWalkerFactory().walk((argDecl.typeExpr).term, preCollectDecls, postCollectDecls, null, declCollectionContext); - } - - return false; - } - TypeScript.preCollectParameterDecl = preCollectParameterDecl; - - function preCollectTypeParameterDecl(typeParameterDecl, parentAST, context) { - var declFlags = 0 /* None */; - - var span = TypeScript.TextSpan.fromBounds(typeParameterDecl.minChar, typeParameterDecl.limChar); - - var parent = context.getParent(); - - if (parent && (parent.getKind() === 536870912 /* WithBlock */ || (parent.getFlags() & 2097152 /* DeclaredInAWithBlock */))) { - declFlags |= 2097152 /* DeclaredInAWithBlock */; - } - - var decl = new TypeScript.PullDecl(typeParameterDecl.name.text, typeParameterDecl.name.actualText, 8192 /* TypeParameter */, declFlags, span, context.scriptName); - context.semanticInfo.setASTForDecl(decl, typeParameterDecl); - context.semanticInfo.setDeclForAST(typeParameterDecl, decl); - - parent.addChildDecl(decl); - decl.setParentDecl(parent); - - if (typeParameterDecl.constraint && ((typeParameterDecl.constraint).term.nodeType === 14 /* InterfaceDeclaration */ || (typeParameterDecl.constraint).term.nodeType === 12 /* FunctionDeclaration */)) { - var declCollectionContext = new DeclCollectionContext(context.semanticInfo); - - if (parent) { - declCollectionContext.pushParent(parent); - } - - declCollectionContext.scriptName = context.scriptName; - - TypeScript.getAstWalkerFactory().walk((typeParameterDecl.constraint).term, preCollectDecls, postCollectDecls, null, declCollectionContext); - } - - return true; - } - TypeScript.preCollectTypeParameterDecl = preCollectTypeParameterDecl; - - function createPropertySignature(propertyDecl, context) { - var declFlags = 4 /* Public */; - var parent = context.getParent(); - var declType = parent.getKind() === 64 /* Enum */ ? 67108864 /* EnumMember */ : 4096 /* Property */; - - if (TypeScript.hasFlag(propertyDecl.id.getFlags(), 4 /* OptionalName */)) { - declFlags |= 128 /* Optional */; - } - - if (TypeScript.hasFlag(propertyDecl.getVarFlags(), 4096 /* Constant */)) { - declFlags |= 524288 /* Constant */; - } - - var span = TypeScript.TextSpan.fromBounds(propertyDecl.minChar, propertyDecl.limChar); - - var decl = new TypeScript.PullDecl(propertyDecl.id.text, propertyDecl.id.actualText, declType, declFlags, span, context.scriptName); - context.semanticInfo.setDeclForAST(propertyDecl, decl); - context.semanticInfo.setASTForDecl(decl, propertyDecl); - - parent.addChildDecl(decl); - decl.setParentDecl(parent); - - if (propertyDecl.typeExpr && ((propertyDecl.typeExpr).term.nodeType === 14 /* InterfaceDeclaration */ || (propertyDecl.typeExpr).term.nodeType === 12 /* FunctionDeclaration */)) { - var declCollectionContext = new DeclCollectionContext(context.semanticInfo); - - if (parent) { - declCollectionContext.pushParent(parent); - } - - declCollectionContext.scriptName = context.scriptName; - - TypeScript.getAstWalkerFactory().walk((propertyDecl.typeExpr).term, preCollectDecls, postCollectDecls, null, declCollectionContext); - } - - return false; - } - TypeScript.createPropertySignature = createPropertySignature; - - function createMemberVariableDeclaration(memberDecl, context) { - var declFlags = 0 /* None */; - var declType = 4096 /* Property */; - - if (TypeScript.hasFlag(memberDecl.getVarFlags(), 2 /* Private */)) { - declFlags |= 2 /* Private */; - } else { - declFlags |= 4 /* Public */; - } - - if (TypeScript.hasFlag(memberDecl.getVarFlags(), 16 /* Static */)) { - declFlags |= 16 /* Static */; - } - - var span = TypeScript.TextSpan.fromBounds(memberDecl.minChar, memberDecl.limChar); - - var decl = new TypeScript.PullDecl(memberDecl.id.text, memberDecl.id.actualText, declType, declFlags, span, context.scriptName); - context.semanticInfo.setDeclForAST(memberDecl, decl); - context.semanticInfo.setASTForDecl(decl, memberDecl); - - var parent = context.getParent(); - parent.addChildDecl(decl); - decl.setParentDecl(parent); - - if (memberDecl.typeExpr && ((memberDecl.typeExpr).term.nodeType === 14 /* InterfaceDeclaration */ || (memberDecl.typeExpr).term.nodeType === 12 /* FunctionDeclaration */)) { - var declCollectionContext = new DeclCollectionContext(context.semanticInfo); - - if (parent) { - declCollectionContext.pushParent(parent); - } - - declCollectionContext.scriptName = context.scriptName; - - TypeScript.getAstWalkerFactory().walk((memberDecl.typeExpr).term, preCollectDecls, postCollectDecls, null, declCollectionContext); - } - - return false; - } - TypeScript.createMemberVariableDeclaration = createMemberVariableDeclaration; - - function createVariableDeclaration(varDecl, context) { - var declFlags = 0 /* None */; - var declType = 1024 /* Variable */; - - if (TypeScript.hasFlag(varDecl.getVarFlags(), 8 /* Ambient */)) { - declFlags |= 8 /* Ambient */; - } - - if (TypeScript.hasFlag(varDecl.getVarFlags(), 1 /* Exported */)) { - declFlags |= 1 /* Exported */; - } - - var span = TypeScript.TextSpan.fromBounds(varDecl.minChar, varDecl.limChar); - - var parent = context.getParent(); - - if (parent && (parent.getKind() === 536870912 /* WithBlock */ || (parent.getFlags() & 2097152 /* DeclaredInAWithBlock */))) { - declFlags |= 2097152 /* DeclaredInAWithBlock */; - } - - var decl = new TypeScript.PullDecl(varDecl.id.text, varDecl.id.actualText, declType, declFlags, span, context.scriptName); - context.semanticInfo.setDeclForAST(varDecl, decl); - context.semanticInfo.setASTForDecl(decl, varDecl); - - parent.addChildDecl(decl); - decl.setParentDecl(parent); - - if (varDecl.typeExpr && ((varDecl.typeExpr).term.nodeType === 14 /* InterfaceDeclaration */ || (varDecl.typeExpr).term.nodeType === 12 /* FunctionDeclaration */)) { - var declCollectionContext = new DeclCollectionContext(context.semanticInfo); - - if (parent) { - declCollectionContext.pushParent(parent); - } - - declCollectionContext.scriptName = context.scriptName; - - TypeScript.getAstWalkerFactory().walk((varDecl.typeExpr).term, preCollectDecls, postCollectDecls, null, declCollectionContext); - } - - return false; - } - TypeScript.createVariableDeclaration = createVariableDeclaration; - - function preCollectVarDecls(ast, parentAST, context) { - var varDecl = ast; - var declFlags = 0 /* None */; - var declType = 1024 /* Variable */; - var isProperty = false; - var isStatic = false; - - if (TypeScript.hasFlag(varDecl.getVarFlags(), 2048 /* ClassProperty */)) { - return createMemberVariableDeclaration(varDecl, context); - } else if (TypeScript.hasFlag(varDecl.getVarFlags(), 256 /* Property */)) { - return createPropertySignature(varDecl, context); - } - - return createVariableDeclaration(varDecl, context); - } - TypeScript.preCollectVarDecls = preCollectVarDecls; - - function createFunctionTypeDeclaration(functionTypeDeclAST, context) { - var declFlags = 2048 /* Signature */; - var declType = 16777216 /* FunctionType */; - - var span = TypeScript.TextSpan.fromBounds(functionTypeDeclAST.minChar, functionTypeDeclAST.limChar); - - var parent = context.getParent(); - - if (parent && (parent.getKind() === 536870912 /* WithBlock */ || (parent.getFlags() & 2097152 /* DeclaredInAWithBlock */))) { - declFlags |= 2097152 /* DeclaredInAWithBlock */; - } - - var decl = new TypeScript.PullDecl("", "", declType, declFlags, span, context.semanticInfo.getPath()); - context.semanticInfo.setDeclForAST(functionTypeDeclAST, decl); - context.semanticInfo.setASTForDecl(decl, functionTypeDeclAST); - - if (parent) { - parent.addChildDecl(decl); - decl.setParentDecl(parent); - } - - context.pushParent(decl); - - if (functionTypeDeclAST.returnTypeAnnotation && ((functionTypeDeclAST.returnTypeAnnotation).term.nodeType === 14 /* InterfaceDeclaration */ || (functionTypeDeclAST.returnTypeAnnotation).term.nodeType === 12 /* FunctionDeclaration */)) { - var declCollectionContext = new DeclCollectionContext(context.semanticInfo); - - if (parent) { - declCollectionContext.pushParent(parent); - } - - declCollectionContext.scriptName = context.scriptName; - - TypeScript.getAstWalkerFactory().walk((functionTypeDeclAST.returnTypeAnnotation).term, preCollectDecls, postCollectDecls, null, declCollectionContext); - } - - return true; - } - TypeScript.createFunctionTypeDeclaration = createFunctionTypeDeclaration; - - function createConstructorTypeDeclaration(constructorTypeDeclAST, context) { - var declFlags = 0 /* None */; - var declType = 33554432 /* ConstructorType */; - - var span = TypeScript.TextSpan.fromBounds(constructorTypeDeclAST.minChar, constructorTypeDeclAST.limChar); - - var parent = context.getParent(); - - if (parent && (parent.getKind() === 536870912 /* WithBlock */ || (parent.getFlags() & 2097152 /* DeclaredInAWithBlock */))) { - declFlags |= 2097152 /* DeclaredInAWithBlock */; - } - - var decl = new TypeScript.PullDecl("{new}", "{new}", declType, declFlags, span, context.semanticInfo.getPath()); - context.semanticInfo.setDeclForAST(constructorTypeDeclAST, decl); - context.semanticInfo.setASTForDecl(decl, constructorTypeDeclAST); - - if (parent) { - parent.addChildDecl(decl); - decl.setParentDecl(parent); - } - - context.pushParent(decl); - - if (constructorTypeDeclAST.returnTypeAnnotation && ((constructorTypeDeclAST.returnTypeAnnotation).term.nodeType === 14 /* InterfaceDeclaration */ || (constructorTypeDeclAST.returnTypeAnnotation).term.nodeType === 12 /* FunctionDeclaration */)) { - var declCollectionContext = new DeclCollectionContext(context.semanticInfo); - - if (parent) { - declCollectionContext.pushParent(parent); - } - - declCollectionContext.scriptName = context.scriptName; - - TypeScript.getAstWalkerFactory().walk((constructorTypeDeclAST.returnTypeAnnotation).term, preCollectDecls, postCollectDecls, null, declCollectionContext); - } - - return true; - } - TypeScript.createConstructorTypeDeclaration = createConstructorTypeDeclaration; - - function createFunctionDeclaration(funcDeclAST, context) { - var declFlags = 0 /* None */; - var declType = 16384 /* Function */; - - if (TypeScript.hasFlag(funcDeclAST.getFunctionFlags(), 8 /* Ambient */)) { - declFlags |= 8 /* Ambient */; - } - - if (TypeScript.hasFlag(funcDeclAST.getFunctionFlags(), 1 /* Exported */)) { - declFlags |= 1 /* Exported */; - } - - if (!funcDeclAST.block) { - declFlags |= 2048 /* Signature */; - } - - var span = TypeScript.TextSpan.fromBounds(funcDeclAST.minChar, funcDeclAST.limChar); - - var parent = context.getParent(); - - if (parent && (parent.getKind() === 536870912 /* WithBlock */ || (parent.getFlags() & 2097152 /* DeclaredInAWithBlock */))) { - declFlags |= 2097152 /* DeclaredInAWithBlock */; - } - - var decl = new TypeScript.PullDecl(funcDeclAST.name.text, funcDeclAST.name.actualText, declType, declFlags, span, context.scriptName); - context.semanticInfo.setDeclForAST(funcDeclAST, decl); - context.semanticInfo.setASTForDecl(decl, funcDeclAST); - - if (parent) { - parent.addChildDecl(decl); - decl.setParentDecl(parent); - } - - context.pushParent(decl); - - if (funcDeclAST.returnTypeAnnotation && ((funcDeclAST.returnTypeAnnotation).term.nodeType === 14 /* InterfaceDeclaration */ || (funcDeclAST.returnTypeAnnotation).term.nodeType === 12 /* FunctionDeclaration */)) { - var declCollectionContext = new DeclCollectionContext(context.semanticInfo); - - if (parent) { - declCollectionContext.pushParent(parent); - } - - declCollectionContext.scriptName = context.scriptName; - - TypeScript.getAstWalkerFactory().walk((funcDeclAST.returnTypeAnnotation).term, preCollectDecls, postCollectDecls, null, declCollectionContext); - } - - return true; - } - TypeScript.createFunctionDeclaration = createFunctionDeclaration; - - function createFunctionExpressionDeclaration(functionExpressionDeclAST, context) { - var declFlags = 0 /* None */; - - if (TypeScript.hasFlag(functionExpressionDeclAST.getFunctionFlags(), 2048 /* IsFatArrowFunction */)) { - declFlags |= 8192 /* FatArrow */; - } - - var span = TypeScript.TextSpan.fromBounds(functionExpressionDeclAST.minChar, functionExpressionDeclAST.limChar); - - var parent = context.getParent(); - - if (parent && (parent.getKind() === 536870912 /* WithBlock */ || (parent.getFlags() & 2097152 /* DeclaredInAWithBlock */))) { - declFlags |= 2097152 /* DeclaredInAWithBlock */; - } - - var name = functionExpressionDeclAST.name ? functionExpressionDeclAST.name.actualText : ""; - var decl = new TypeScript.PullFunctionExpressionDecl(name, declFlags, span, context.scriptName); - context.semanticInfo.setDeclForAST(functionExpressionDeclAST, decl); - context.semanticInfo.setASTForDecl(decl, functionExpressionDeclAST); - - if (parent) { - parent.addChildDecl(decl); - decl.setParentDecl(parent); - } - - context.pushParent(decl); - - if (functionExpressionDeclAST.returnTypeAnnotation && ((functionExpressionDeclAST.returnTypeAnnotation).term.nodeType === 14 /* InterfaceDeclaration */ || (functionExpressionDeclAST.returnTypeAnnotation).term.nodeType === 12 /* FunctionDeclaration */)) { - var declCollectionContext = new DeclCollectionContext(context.semanticInfo); - - declCollectionContext.scriptName = context.scriptName; - - if (parent) { - declCollectionContext.pushParent(parent); - } - - TypeScript.getAstWalkerFactory().walk((functionExpressionDeclAST.returnTypeAnnotation).term, preCollectDecls, postCollectDecls, null, declCollectionContext); - } - - return true; - } - TypeScript.createFunctionExpressionDeclaration = createFunctionExpressionDeclaration; - - function createMemberFunctionDeclaration(memberFunctionDeclAST, context) { - var declFlags = 0 /* None */; - var declType = 65536 /* Method */; - - if (TypeScript.hasFlag(memberFunctionDeclAST.getFunctionFlags(), 16 /* Static */)) { - declFlags |= 16 /* Static */; - } - - if (TypeScript.hasFlag(memberFunctionDeclAST.getFunctionFlags(), 2 /* Private */)) { - declFlags |= 2 /* Private */; - } else { - declFlags |= 4 /* Public */; - } - - if (!memberFunctionDeclAST.block) { - declFlags |= 2048 /* Signature */; - } - - if (TypeScript.hasFlag(memberFunctionDeclAST.name.getFlags(), 4 /* OptionalName */)) { - declFlags |= 128 /* Optional */; - } - - var span = TypeScript.TextSpan.fromBounds(memberFunctionDeclAST.minChar, memberFunctionDeclAST.limChar); - - var decl = new TypeScript.PullDecl(memberFunctionDeclAST.name.text, memberFunctionDeclAST.name.actualText, declType, declFlags, span, context.scriptName); - context.semanticInfo.setDeclForAST(memberFunctionDeclAST, decl); - context.semanticInfo.setASTForDecl(decl, memberFunctionDeclAST); - - var parent = context.getParent(); - - if (parent) { - parent.addChildDecl(decl); - decl.setParentDecl(parent); - } - - context.pushParent(decl); - - if (memberFunctionDeclAST.returnTypeAnnotation && ((memberFunctionDeclAST.returnTypeAnnotation).term.nodeType === 14 /* InterfaceDeclaration */ || (memberFunctionDeclAST.returnTypeAnnotation).term.nodeType === 12 /* FunctionDeclaration */)) { - var declCollectionContext = new DeclCollectionContext(context.semanticInfo); - - declCollectionContext.scriptName = context.scriptName; - - if (parent) { - declCollectionContext.pushParent(parent); - } - - TypeScript.getAstWalkerFactory().walk((memberFunctionDeclAST.returnTypeAnnotation).term, preCollectDecls, postCollectDecls, null, declCollectionContext); - } - - return true; - } - TypeScript.createMemberFunctionDeclaration = createMemberFunctionDeclaration; - - function createIndexSignatureDeclaration(indexSignatureDeclAST, context) { - var declFlags = 2048 /* Signature */ | 1024 /* Index */; - var declType = 4194304 /* IndexSignature */; - - var span = TypeScript.TextSpan.fromBounds(indexSignatureDeclAST.minChar, indexSignatureDeclAST.limChar); - - var parent = context.getParent(); - - if (parent && (parent.getKind() === 536870912 /* WithBlock */ || (parent.getFlags() & 2097152 /* DeclaredInAWithBlock */))) { - declFlags |= 2097152 /* DeclaredInAWithBlock */; - } - - var decl = new TypeScript.PullDecl("[]", "[]", declType, declFlags, span, context.scriptName); - context.semanticInfo.setDeclForAST(indexSignatureDeclAST, decl); - context.semanticInfo.setASTForDecl(decl, indexSignatureDeclAST); - - if (parent) { - parent.addChildDecl(decl); - decl.setParentDecl(parent); - } - - context.pushParent(decl); - - if (indexSignatureDeclAST.returnTypeAnnotation && ((indexSignatureDeclAST.returnTypeAnnotation).term.nodeType === 14 /* InterfaceDeclaration */ || (indexSignatureDeclAST.returnTypeAnnotation).term.nodeType === 12 /* FunctionDeclaration */)) { - var declCollectionContext = new DeclCollectionContext(context.semanticInfo); - - if (parent) { - declCollectionContext.pushParent(parent); - } - - declCollectionContext.scriptName = context.scriptName; - - TypeScript.getAstWalkerFactory().walk((indexSignatureDeclAST.returnTypeAnnotation).term, preCollectDecls, postCollectDecls, null, declCollectionContext); - } - - return true; - } - TypeScript.createIndexSignatureDeclaration = createIndexSignatureDeclaration; - - function createCallSignatureDeclaration(callSignatureDeclAST, context) { - var declFlags = 2048 /* Signature */ | 256 /* Call */; - var declType = 1048576 /* CallSignature */; - - var span = TypeScript.TextSpan.fromBounds(callSignatureDeclAST.minChar, callSignatureDeclAST.limChar); - - var parent = context.getParent(); - - if (parent && (parent.getKind() === 536870912 /* WithBlock */ || (parent.getFlags() & 2097152 /* DeclaredInAWithBlock */))) { - declFlags |= 2097152 /* DeclaredInAWithBlock */; - } - - var decl = new TypeScript.PullDecl("()", "()", declType, declFlags, span, context.scriptName); - context.semanticInfo.setDeclForAST(callSignatureDeclAST, decl); - context.semanticInfo.setASTForDecl(decl, callSignatureDeclAST); - - if (parent) { - parent.addChildDecl(decl); - decl.setParentDecl(parent); - } - - context.pushParent(decl); - - if (callSignatureDeclAST.returnTypeAnnotation && ((callSignatureDeclAST.returnTypeAnnotation).term.nodeType === 14 /* InterfaceDeclaration */ || (callSignatureDeclAST.returnTypeAnnotation).term.nodeType === 12 /* FunctionDeclaration */)) { - var declCollectionContext = new DeclCollectionContext(context.semanticInfo); - - declCollectionContext.scriptName = context.scriptName; - - if (parent) { - declCollectionContext.pushParent(parent); - } - - TypeScript.getAstWalkerFactory().walk((callSignatureDeclAST.returnTypeAnnotation).term, preCollectDecls, postCollectDecls, null, declCollectionContext); - } - - return true; - } - TypeScript.createCallSignatureDeclaration = createCallSignatureDeclaration; - - function createConstructSignatureDeclaration(constructSignatureDeclAST, context) { - var declFlags = 2048 /* Signature */ | 256 /* Call */; - var declType = 2097152 /* ConstructSignature */; - - var span = TypeScript.TextSpan.fromBounds(constructSignatureDeclAST.minChar, constructSignatureDeclAST.limChar); - - var parent = context.getParent(); - - if (parent && (parent.getKind() === 536870912 /* WithBlock */ || (parent.getFlags() & 2097152 /* DeclaredInAWithBlock */))) { - declFlags |= 2097152 /* DeclaredInAWithBlock */; - } - - var decl = new TypeScript.PullDecl("new", "new", declType, declFlags, span, context.scriptName); - context.semanticInfo.setDeclForAST(constructSignatureDeclAST, decl); - context.semanticInfo.setASTForDecl(decl, constructSignatureDeclAST); - - if (parent) { - parent.addChildDecl(decl); - decl.setParentDecl(parent); - } - - context.pushParent(decl); - - if (constructSignatureDeclAST.returnTypeAnnotation && ((constructSignatureDeclAST.returnTypeAnnotation).term.nodeType === 14 /* InterfaceDeclaration */ || (constructSignatureDeclAST.returnTypeAnnotation).term.nodeType === 12 /* FunctionDeclaration */)) { - var declCollectionContext = new DeclCollectionContext(context.semanticInfo); - - declCollectionContext.scriptName = context.scriptName; - - if (parent) { - declCollectionContext.pushParent(parent); - } - - TypeScript.getAstWalkerFactory().walk((constructSignatureDeclAST.returnTypeAnnotation).term, preCollectDecls, postCollectDecls, null, declCollectionContext); - } - - return true; - } - TypeScript.createConstructSignatureDeclaration = createConstructSignatureDeclaration; - - function createClassConstructorDeclaration(constructorDeclAST, context) { - var declFlags = 512 /* Constructor */; - var declType = 32768 /* ConstructorMethod */; - - if (!constructorDeclAST.block) { - declFlags |= 2048 /* Signature */; - } - - var span = TypeScript.TextSpan.fromBounds(constructorDeclAST.minChar, constructorDeclAST.limChar); - - var parent = context.getParent(); - - if (parent) { - var parentFlags = parent.getFlags(); - - if (parentFlags & 1 /* Exported */) { - declFlags |= 1 /* Exported */; - } - } - - var decl = new TypeScript.PullDecl(parent.getName(), parent.getDisplayName(), declType, declFlags, span, context.scriptName); - context.semanticInfo.setDeclForAST(constructorDeclAST, decl); - context.semanticInfo.setASTForDecl(decl, constructorDeclAST); - - if (parent) { - parent.addChildDecl(decl); - decl.setParentDecl(parent); - } - - context.pushParent(decl); - - if (constructorDeclAST.returnTypeAnnotation && ((constructorDeclAST.returnTypeAnnotation).term.nodeType === 14 /* InterfaceDeclaration */ || (constructorDeclAST.returnTypeAnnotation).term.nodeType === 12 /* FunctionDeclaration */)) { - var declCollectionContext = new DeclCollectionContext(context.semanticInfo); - - declCollectionContext.scriptName = context.scriptName; - - if (parent) { - declCollectionContext.pushParent(parent); - } - - TypeScript.getAstWalkerFactory().walk((constructorDeclAST.returnTypeAnnotation).term, preCollectDecls, postCollectDecls, null, declCollectionContext); - } - - return true; - } - TypeScript.createClassConstructorDeclaration = createClassConstructorDeclaration; - - function createGetAccessorDeclaration(getAccessorDeclAST, context) { - var declFlags = 4 /* Public */; - var declType = 262144 /* GetAccessor */; - - if (TypeScript.hasFlag(getAccessorDeclAST.getFunctionFlags(), 16 /* Static */)) { - declFlags |= 16 /* Static */; - } - - if (TypeScript.hasFlag(getAccessorDeclAST.name.getFlags(), 4 /* OptionalName */)) { - declFlags |= 128 /* Optional */; - } - - if (TypeScript.hasFlag(getAccessorDeclAST.getFunctionFlags(), 2 /* Private */)) { - declFlags |= 2 /* Private */; - } else { - declFlags |= 4 /* Public */; - } - - var span = TypeScript.TextSpan.fromBounds(getAccessorDeclAST.minChar, getAccessorDeclAST.limChar); - - var parent = context.getParent(); - - if (parent && (parent.getKind() === 536870912 /* WithBlock */ || (parent.getFlags() & 2097152 /* DeclaredInAWithBlock */))) { - declFlags |= 2097152 /* DeclaredInAWithBlock */; - } - - var decl = new TypeScript.PullDecl(getAccessorDeclAST.name.text, getAccessorDeclAST.name.actualText, declType, declFlags, span, context.scriptName); - context.semanticInfo.setDeclForAST(getAccessorDeclAST, decl); - context.semanticInfo.setASTForDecl(decl, getAccessorDeclAST); - - if (parent) { - parent.addChildDecl(decl); - decl.setParentDecl(parent); - } - - context.pushParent(decl); - - if (getAccessorDeclAST.returnTypeAnnotation && ((getAccessorDeclAST.returnTypeAnnotation).term.nodeType === 14 /* InterfaceDeclaration */ || (getAccessorDeclAST.returnTypeAnnotation).term.nodeType === 12 /* FunctionDeclaration */)) { - var declCollectionContext = new DeclCollectionContext(context.semanticInfo); - - declCollectionContext.scriptName = context.scriptName; - - if (parent) { - declCollectionContext.pushParent(parent); - } - - TypeScript.getAstWalkerFactory().walk((getAccessorDeclAST.returnTypeAnnotation).term, preCollectDecls, postCollectDecls, null, declCollectionContext); - } - - return true; - } - TypeScript.createGetAccessorDeclaration = createGetAccessorDeclaration; - - function createSetAccessorDeclaration(setAccessorDeclAST, context) { - var declFlags = 4 /* Public */; - var declType = 524288 /* SetAccessor */; - - if (TypeScript.hasFlag(setAccessorDeclAST.getFunctionFlags(), 16 /* Static */)) { - declFlags |= 16 /* Static */; - } - - if (TypeScript.hasFlag(setAccessorDeclAST.name.getFlags(), 4 /* OptionalName */)) { - declFlags |= 128 /* Optional */; - } - - if (TypeScript.hasFlag(setAccessorDeclAST.getFunctionFlags(), 2 /* Private */)) { - declFlags |= 2 /* Private */; - } else { - declFlags |= 4 /* Public */; - } - - var span = TypeScript.TextSpan.fromBounds(setAccessorDeclAST.minChar, setAccessorDeclAST.limChar); - - var parent = context.getParent(); - - if (parent && (parent.getKind() === 536870912 /* WithBlock */ || (parent.getFlags() & 2097152 /* DeclaredInAWithBlock */))) { - declFlags |= 2097152 /* DeclaredInAWithBlock */; - } - - var decl = new TypeScript.PullDecl(setAccessorDeclAST.name.actualText, setAccessorDeclAST.name.actualText, declType, declFlags, span, context.scriptName); - context.semanticInfo.setDeclForAST(setAccessorDeclAST, decl); - context.semanticInfo.setASTForDecl(decl, setAccessorDeclAST); - - if (parent) { - parent.addChildDecl(decl); - decl.setParentDecl(parent); - } - - context.pushParent(decl); - - return true; - } - TypeScript.createSetAccessorDeclaration = createSetAccessorDeclaration; - - function preCollectCatchDecls(ast, parentAST, context) { - var declFlags = 0 /* None */; - var declType = 1073741824 /* CatchBlock */; - - var span = TypeScript.TextSpan.fromBounds(ast.minChar, ast.limChar); - - var parent = context.getParent(); - - if (parent && (parent.getKind() === 536870912 /* WithBlock */ || (parent.getFlags() & 2097152 /* DeclaredInAWithBlock */))) { - declFlags |= 2097152 /* DeclaredInAWithBlock */; - } - - var decl = new TypeScript.PullDecl("", "", declType, declFlags, span, context.scriptName); - context.semanticInfo.setDeclForAST(ast, decl); - context.semanticInfo.setASTForDecl(decl, ast); - - if (parent) { - parent.addChildDecl(decl); - decl.setParentDecl(parent); - } - - context.pushParent(decl); - - return true; - } - TypeScript.preCollectCatchDecls = preCollectCatchDecls; - - function preCollectWithDecls(ast, parentAST, context) { - var declFlags = 0 /* None */; - var declType = 536870912 /* WithBlock */; - - var span = TypeScript.TextSpan.fromBounds(ast.minChar, ast.limChar); - - var parent = context.getParent(); - - var decl = new TypeScript.PullDecl("", "", declType, declFlags, span, context.scriptName); - context.semanticInfo.setDeclForAST(ast, decl); - context.semanticInfo.setASTForDecl(decl, ast); - - if (parent) { - parent.addChildDecl(decl); - decl.setParentDecl(parent); - } - - context.pushParent(decl); - - return true; - } - TypeScript.preCollectWithDecls = preCollectWithDecls; - - function preCollectFuncDecls(ast, parentAST, context) { - var funcDecl = ast; - - if (funcDecl.isConstructor) { - return createClassConstructorDeclaration(funcDecl, context); - } else if (funcDecl.isGetAccessor()) { - return createGetAccessorDeclaration(funcDecl, context); - } else if (funcDecl.isSetAccessor()) { - return createSetAccessorDeclaration(funcDecl, context); - } else if (TypeScript.hasFlag(funcDecl.getFunctionFlags(), 1024 /* ConstructMember */)) { - return TypeScript.hasFlag(funcDecl.getFlags(), 8 /* TypeReference */) ? createConstructorTypeDeclaration(funcDecl, context) : createConstructSignatureDeclaration(funcDecl, context); - } else if (TypeScript.hasFlag(funcDecl.getFunctionFlags(), 512 /* CallMember */)) { - return createCallSignatureDeclaration(funcDecl, context); - } else if (TypeScript.hasFlag(funcDecl.getFunctionFlags(), 4096 /* IndexerMember */)) { - return createIndexSignatureDeclaration(funcDecl, context); - } else if (TypeScript.hasFlag(funcDecl.getFlags(), 8 /* TypeReference */)) { - return createFunctionTypeDeclaration(funcDecl, context); - } else if (TypeScript.hasFlag(funcDecl.getFunctionFlags(), 256 /* Method */)) { - return createMemberFunctionDeclaration(funcDecl, context); - } else if (TypeScript.hasFlag(funcDecl.getFunctionFlags(), (8192 /* IsFunctionExpression */ | 2048 /* IsFatArrowFunction */ | 16384 /* IsFunctionProperty */))) { - return createFunctionExpressionDeclaration(funcDecl, context); - } - - return createFunctionDeclaration(funcDecl, context); - } - TypeScript.preCollectFuncDecls = preCollectFuncDecls; - - function preCollectDecls(ast, parentAST, walker) { - var context = walker.state; - var go = false; - - if (ast.nodeType === 2 /* Script */) { - var script = ast; - var span = TypeScript.TextSpan.fromBounds(script.minChar, script.limChar); - - var decl = new TypeScript.PullDecl(context.scriptName, context.scriptName, 1 /* Script */, 0 /* None */, span, context.scriptName); - context.semanticInfo.setDeclForAST(ast, decl); - context.semanticInfo.setASTForDecl(decl, ast); - - context.pushParent(decl); - - go = true; - } else if (ast.nodeType === 1 /* List */) { - go = true; - } else if (ast.nodeType === 81 /* Block */) { - go = true; - } else if (ast.nodeType === 18 /* VariableDeclaration */) { - go = true; - } else if (ast.nodeType === 97 /* VariableStatement */) { - go = true; - } else if (ast.nodeType === 15 /* ModuleDeclaration */) { - go = preCollectModuleDecls(ast, parentAST, context); - } else if (ast.nodeType === 13 /* ClassDeclaration */) { - go = preCollectClassDecls(ast, parentAST, context); - } else if (ast.nodeType === 14 /* InterfaceDeclaration */) { - go = preCollectInterfaceDecls(ast, parentAST, context); - } else if (ast.nodeType === 19 /* Parameter */) { - go = preCollectParameterDecl(ast, parentAST, context); - } else if (ast.nodeType === 17 /* VariableDeclarator */) { - go = preCollectVarDecls(ast, parentAST, context); - } else if (ast.nodeType === 12 /* FunctionDeclaration */) { - go = preCollectFuncDecls(ast, parentAST, context); - } else if (ast.nodeType === 16 /* ImportDeclaration */) { - go = preCollectImportDecls(ast, parentAST, context); - } else if (ast.nodeType === 9 /* TypeParameter */) { - go = preCollectTypeParameterDecl(ast, parentAST, context); - } else if (ast.nodeType === 91 /* IfStatement */) { - go = true; - } else if (ast.nodeType === 90 /* ForStatement */) { - go = true; - } else if (ast.nodeType === 89 /* ForInStatement */) { - go = true; - } else if (ast.nodeType === 98 /* WhileStatement */) { - go = true; - } else if (ast.nodeType === 85 /* DoStatement */) { - go = true; - } else if (ast.nodeType === 25 /* CommaExpression */) { - go = true; - } else if (ast.nodeType === 93 /* ReturnStatement */) { - go = true; - } else if (ast.nodeType === 94 /* SwitchStatement */ || ast.nodeType === 100 /* CaseClause */) { - go = true; - } else if (ast.nodeType === 36 /* InvocationExpression */) { - go = true; - } else if (ast.nodeType === 37 /* ObjectCreationExpression */) { - go = true; - } else if (ast.nodeType === 96 /* TryStatement */) { - go = true; - } else if (ast.nodeType === 92 /* LabeledStatement */) { - go = true; - } else if (ast.nodeType === 101 /* CatchClause */) { - go = preCollectCatchDecls(ast, parentAST, context); - } else if (ast.nodeType === 99 /* WithStatement */) { - go = preCollectWithDecls(ast, parentAST, context); - } - - walker.options.goChildren = go; - - return ast; - } - TypeScript.preCollectDecls = preCollectDecls; - - function isContainer(decl) { - return decl.getKind() === 4 /* Container */ || decl.getKind() === 32 /* DynamicModule */ || decl.getKind() === 64 /* Enum */; - } - - function getInitializationFlag(decl) { - if (decl.getKind() & 4 /* Container */) { - return 32768 /* InitializedModule */; - } else if (decl.getKind() & 64 /* Enum */) { - return 131072 /* InitializedEnum */; - } else if (decl.getKind() & 32 /* DynamicModule */) { - return 65536 /* InitializedDynamicModule */; - } - - return 0 /* None */; - } - - function hasInitializationFlag(decl) { - var kind = decl.getKind(); - - if (kind & 4 /* Container */) { - return (decl.getFlags() & 32768 /* InitializedModule */) !== 0; - } else if (kind & 64 /* Enum */) { - return (decl.getFlags() & 131072 /* InitializedEnum */) != 0; - } else if (kind & 32 /* DynamicModule */) { - return (decl.getFlags() & 65536 /* InitializedDynamicModule */) !== 0; - } - - return false; - } - - function postCollectDecls(ast, parentAST, walker) { - var context = walker.state; - var parentDecl; - var initFlag = 0 /* None */; - - if (ast.nodeType === 15 /* ModuleDeclaration */) { - var thisModule = context.getParent(); - context.popParent(); - parentDecl = context.getParent(); - - if (hasInitializationFlag(thisModule)) { - if (parentDecl && isContainer(parentDecl)) { - initFlag = getInitializationFlag(parentDecl); - parentDecl.setFlags(parentDecl.getFlags() | initFlag); - } - - var valueDecl = new TypeScript.PullDecl(thisModule.getName(), thisModule.getDisplayName(), 1024 /* Variable */, thisModule.getFlags(), thisModule.getSpan(), context.scriptName); - - thisModule.setValueDecl(valueDecl); - - context.semanticInfo.setASTForDecl(valueDecl, ast); - - if (parentDecl) { - parentDecl.addChildDecl(valueDecl); - valueDecl.setParentDecl(parentDecl); - } - } - } else if (ast.nodeType === 13 /* ClassDeclaration */) { - context.popParent(); - - parentDecl = context.getParent(); - - if (parentDecl && isContainer(parentDecl)) { - initFlag = getInitializationFlag(parentDecl); - parentDecl.setFlags(parentDecl.getFlags() | initFlag); - } - } else if (ast.nodeType === 14 /* InterfaceDeclaration */) { - context.popParent(); - } else if (ast.nodeType === 12 /* FunctionDeclaration */) { - context.popParent(); - - parentDecl = context.getParent(); - - if (parentDecl && isContainer(parentDecl)) { - initFlag = getInitializationFlag(parentDecl); - parentDecl.setFlags(parentDecl.getFlags() | initFlag); - } - } else if (ast.nodeType === 17 /* VariableDeclarator */) { - parentDecl = context.getParent(); - - if (parentDecl && isContainer(parentDecl)) { - initFlag = getInitializationFlag(parentDecl); - parentDecl.setFlags(parentDecl.getFlags() | initFlag); - } - } else if (ast.nodeType === 101 /* CatchClause */) { - parentDecl = context.getParent(); - - if (parentDecl && isContainer(parentDecl)) { - initFlag = getInitializationFlag(parentDecl); - parentDecl.setFlags(parentDecl.getFlags() | initFlag); - } - - context.popParent(); - } else if (ast.nodeType === 99 /* WithStatement */) { - parentDecl = context.getParent(); - - if (parentDecl && isContainer(parentDecl)) { - initFlag = getInitializationFlag(parentDecl); - parentDecl.setFlags(parentDecl.getFlags() | initFlag); - } - - context.popParent(); - } - - return ast; - } - TypeScript.postCollectDecls = postCollectDecls; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - TypeScript.globalBindingPhase = 0; - - function getPathToDecl(decl) { - if (!decl) { - return []; - } - - var decls = decl.getParentPath(); - - if (decls) { - return decls; - } else { - decls = [decl]; - } - - var parentDecl = decl.getParentDecl(); - - while (parentDecl) { - if (parentDecl && decls[decls.length - 1] != parentDecl && !(parentDecl.getKind() & 512 /* ObjectLiteral */)) { - decls[decls.length] = parentDecl; - } - parentDecl = parentDecl.getParentDecl(); - } - - decls = decls.reverse(); - - decl.setParentPath(decls); - - return decls; - } - TypeScript.getPathToDecl = getPathToDecl; - - function findSymbolInContext(name, declKind, startingDecl) { - var startTime = new Date().getTime(); - var contextSymbolPath = getPathToDecl(startingDecl); - var copyOfContextSymbolPath = []; - var symbol = null; - - var endTime = 0; - - if (contextSymbolPath.length) { - for (var i = 0; i < contextSymbolPath.length; i++) { - copyOfContextSymbolPath[copyOfContextSymbolPath.length] = contextSymbolPath[i].getName(); - } - - copyOfContextSymbolPath[copyOfContextSymbolPath.length] = name; - - while (copyOfContextSymbolPath.length >= 2) { - symbol = TypeScript.globalSemanticInfoChain.findSymbol(copyOfContextSymbolPath, declKind); - - if (symbol) { - endTime = new Date().getTime(); - TypeScript.time_in_findSymbol += endTime - startTime; - - return symbol; - } - copyOfContextSymbolPath.length -= 2; - copyOfContextSymbolPath[copyOfContextSymbolPath.length] = name; - } - } - - symbol = TypeScript.globalSemanticInfoChain.findSymbol([name], declKind); - - endTime = new Date().getTime(); - TypeScript.time_in_findSymbol += endTime - startTime; - - return symbol; - } - TypeScript.findSymbolInContext = findSymbolInContext; - - var PullSymbolBinder = (function () { - function PullSymbolBinder(semanticInfoChain) { - this.semanticInfoChain = semanticInfoChain; - this.bindingPhase = TypeScript.globalBindingPhase++; - this.functionTypeParameterCache = new TypeScript.BlockIntrinsics(); - this.reBindingAfterChange = false; - this.startingDeclForRebind = TypeScript.pullDeclID; - this.startingSymbolForRebind = TypeScript.pullSymbolID; - } - PullSymbolBinder.prototype.findTypeParameterInCache = function (name) { - return this.functionTypeParameterCache[name]; - }; - - PullSymbolBinder.prototype.addTypeParameterToCache = function (typeParameter) { - this.functionTypeParameterCache[typeParameter.getName()] = typeParameter; - }; - - PullSymbolBinder.prototype.resetTypeParameterCache = function () { - this.functionTypeParameterCache = new TypeScript.BlockIntrinsics(); - }; - - PullSymbolBinder.prototype.setUnit = function (fileName) { - this.semanticInfo = this.semanticInfoChain.getUnit(fileName); - }; - - PullSymbolBinder.prototype.getParent = function (decl, returnInstanceType) { - if (typeof returnInstanceType === "undefined") { returnInstanceType = false; } - var parentDecl = decl.getParentDecl(); - - if (parentDecl.getKind() == 1 /* Script */) { - return null; - } - - var parent = parentDecl.getSymbol(); - - if (!parent && parentDecl && !parentDecl.isBound()) { - this.bindDeclToPullSymbol(parentDecl); - } - - parent = parentDecl.getSymbol(); - - if (parent) { - if (returnInstanceType && parent.isType() && parent.isContainer()) { - var instanceSymbol = (parent).getInstanceSymbol(); - - if (instanceSymbol) { - return instanceSymbol.getType(); - } - } - - return parent.getType(); - } - - return null; - }; - - PullSymbolBinder.prototype.findDeclsInContext = function (startingDecl, declKind, searchGlobally) { - if (!searchGlobally) { - var parentDecl = startingDecl.getParentDecl(); - return parentDecl.searchChildDecls(startingDecl.getName(), declKind); - } - - var contextSymbolPath = getPathToDecl(startingDecl); - - if (contextSymbolPath.length) { - var copyOfContextSymbolPath = []; - - for (var i = 0; i < contextSymbolPath.length; i++) { - if (contextSymbolPath[i].getKind() & 1 /* Script */) { - continue; - } - copyOfContextSymbolPath[copyOfContextSymbolPath.length] = contextSymbolPath[i].getName(); - } - - return this.semanticInfoChain.findDecls(copyOfContextSymbolPath, declKind); - } - - return this.semanticInfoChain.findDecls([name], declKind); - }; - - PullSymbolBinder.prototype.symbolIsRedeclaration = function (sym) { - var symID = sym.getSymbolID(); - return (symID >= this.startingSymbolForRebind) || ((sym.getRebindingID() === this.bindingPhase) && (symID !== this.startingSymbolForRebind)); - }; - - PullSymbolBinder.prototype.bindModuleDeclarationToPullSymbol = function (moduleContainerDecl) { - var modName = moduleContainerDecl.getName(); - - var moduleContainerTypeSymbol = null; - var moduleInstanceSymbol = null; - var moduleInstanceTypeSymbol = null; - - var moduleInstanceDecl = moduleContainerDecl.getValueDecl(); - - var moduleKind = moduleContainerDecl.getKind(); - - var parent = this.getParent(moduleContainerDecl); - var parentInstanceSymbol = this.getParent(moduleContainerDecl, true); - var parentDecl = moduleContainerDecl.getParentDecl(); - var moduleAST = this.semanticInfo.getASTForDecl(moduleContainerDecl); - - var isExported = moduleContainerDecl.getFlags() & 1 /* Exported */; - var isEnum = (moduleKind & 64 /* Enum */) != 0; - var searchKind = isEnum ? 64 /* Enum */ : TypeScript.PullElementKind.SomeContainer; - var isInitializedModule = (moduleContainerDecl.getFlags() & TypeScript.PullElementFlags.SomeInitializedModule) != 0; - - var createdNewSymbol = false; - - if (parent) { - if (isExported) { - moduleContainerTypeSymbol = parent.findNestedType(modName, searchKind); - } else { - moduleContainerTypeSymbol = parent.findContainedMember(modName); - - if (moduleContainerTypeSymbol && !(moduleContainerTypeSymbol.getKind() & searchKind)) { - moduleContainerTypeSymbol = null; - } - } - } else if (!isExported || moduleContainerDecl.getKind() === 32 /* DynamicModule */) { - moduleContainerTypeSymbol = findSymbolInContext(modName, searchKind, moduleContainerDecl); - } - - if (moduleContainerTypeSymbol && moduleContainerTypeSymbol.getKind() !== moduleKind) { - if (isInitializedModule) { - moduleContainerDecl.addDiagnostic(new TypeScript.SemanticDiagnostic(this.semanticInfo.getPath(), moduleAST.minChar, moduleAST.getLength(), 69 /* Duplicate_identifier__0_ */, [moduleContainerDecl.getDisplayName()])); - } - - moduleContainerTypeSymbol = null; - } - - if (moduleContainerTypeSymbol) { - moduleInstanceSymbol = moduleContainerTypeSymbol.getInstanceSymbol(); - } else { - moduleContainerTypeSymbol = new TypeScript.PullContainerTypeSymbol(modName, moduleKind); - createdNewSymbol = true; - - if (!parent) { - this.semanticInfoChain.cacheGlobalSymbol(moduleContainerTypeSymbol, searchKind); - } - } - - if (!moduleInstanceSymbol && isInitializedModule) { - var variableSymbol = null; - if (!isEnum) { - if (parentInstanceSymbol) { - if (isExported) { - variableSymbol = parentInstanceSymbol.findMember(modName, false); - - if (!variableSymbol) { - variableSymbol = parentInstanceSymbol.findContainedMember(modName); - } - } else { - variableSymbol = parentInstanceSymbol.findContainedMember(modName); - - if (!variableSymbol) { - variableSymbol = parentInstanceSymbol.findMember(modName, false); - } - } - - if (variableSymbol) { - var declarations = variableSymbol.getDeclarations(); - - if (declarations.length) { - var variableSymbolParent = declarations[0].getParentDecl(); - - if ((parentDecl !== variableSymbolParent) && (!this.reBindingAfterChange || (variableSymbolParent.getDeclID() >= this.startingDeclForRebind))) { - variableSymbol = null; - } - } - } - } else if (!(moduleContainerDecl.getFlags() & 1 /* Exported */)) { - var siblingDecls = parentDecl.getChildDecls(); - var augmentedDecl = null; - - for (var i = 0; i < siblingDecls.length; i++) { - if (siblingDecls[i] == moduleContainerDecl) { - break; - } - - if ((siblingDecls[i].getName() == modName) && (siblingDecls[i].getKind() & (8 /* Class */ | TypeScript.PullElementKind.SomeFunction))) { - augmentedDecl = siblingDecls[i]; - break; - } - } - - if (augmentedDecl) { - variableSymbol = augmentedDecl.getSymbol(); - - if (variableSymbol && variableSymbol.isType()) { - variableSymbol = (variableSymbol).getConstructorMethod(); - } - } - } - } - - if (variableSymbol) { - var prevKind = variableSymbol.getKind(); - var acceptableRedeclaration = (prevKind == 16384 /* Function */) || (prevKind == 32768 /* ConstructorMethod */) || variableSymbol.hasFlag(TypeScript.PullElementFlags.ImplicitVariable); - - if (acceptableRedeclaration) { - moduleInstanceTypeSymbol = variableSymbol.getType(); - } else { - variableSymbol = null; - } - } - - if (!moduleInstanceTypeSymbol) { - moduleInstanceTypeSymbol = new TypeScript.PullTypeSymbol(modName, 8388608 /* ObjectType */); - } - - moduleInstanceTypeSymbol.addDeclaration(moduleContainerDecl); - - moduleInstanceTypeSymbol.setAssociatedContainerType(moduleContainerTypeSymbol); - - if (variableSymbol) { - moduleInstanceSymbol = variableSymbol; - } else { - moduleInstanceSymbol = new TypeScript.PullSymbol(modName, 1024 /* Variable */); - moduleInstanceSymbol.setType(moduleInstanceTypeSymbol); - } - - moduleContainerTypeSymbol.setInstanceSymbol(moduleInstanceSymbol); - } - - moduleContainerTypeSymbol.addDeclaration(moduleContainerDecl); - moduleContainerDecl.setSymbol(moduleContainerTypeSymbol); - - this.semanticInfo.setSymbolAndDiagnosticsForAST(moduleAST.name, TypeScript.SymbolAndDiagnostics.fromSymbol(moduleContainerTypeSymbol)); - this.semanticInfo.setSymbolAndDiagnosticsForAST(moduleAST, TypeScript.SymbolAndDiagnostics.fromSymbol(moduleContainerTypeSymbol)); - - var moduleDeclarations = moduleContainerTypeSymbol.getDeclarations(); - if (isEnum && moduleDeclarations.length > 1 && moduleAST.members.members.length > 0) { - var multipleEnums = TypeScript.ArrayUtilities.where(moduleDeclarations, function (d) { - return d.getKind() === 64 /* Enum */; - }).length > 1; - if (multipleEnums) { - var firstVariable = moduleAST.members.members[0]; - var firstVariableDeclarator = firstVariable.declaration.declarators.members[0]; - if (firstVariableDeclarator.isImplicitlyInitialized) { - moduleContainerDecl.addDiagnostic(new TypeScript.SemanticDiagnostic(this.semanticInfo.getPath(), firstVariableDeclarator.minChar, firstVariableDeclarator.getLength(), 264 /* Enums_with_multiple_declarations_must_provide_an_initializer_for_the_first_enum_element */, null)); - } - } - } - - if (createdNewSymbol) { - if (parent) { - var linkKind = moduleContainerDecl.getFlags() & 1 /* Exported */ ? 5 /* PublicMember */ : 6 /* PrivateMember */; - - if (linkKind === 5 /* PublicMember */) { - parent.addMember(moduleContainerTypeSymbol, linkKind); - } else { - moduleContainerTypeSymbol.setContainer(parent); - } - } - } else if (this.reBindingAfterChange) { - var decls = moduleContainerTypeSymbol.getDeclarations(); - var scriptName = moduleContainerDecl.getScriptName(); - - for (var i = 0; i < decls.length; i++) { - if (decls[i].getScriptName() === scriptName && decls[i].getDeclID() < this.startingDeclForRebind) { - moduleContainerTypeSymbol.removeDeclaration(decls[i]); - } - } - - moduleContainerTypeSymbol.invalidate(); - - moduleInstanceSymbol = moduleContainerTypeSymbol.getInstanceSymbol(); - - if (moduleInstanceSymbol) { - var moduleInstanceTypeSymbol = moduleInstanceSymbol.getType(); - decls = moduleInstanceTypeSymbol.getDeclarations(); - - for (var i = 0; i < decls.length; i++) { - if (decls[i].getScriptName() === scriptName && decls[i].getDeclID() < this.startingDeclForRebind) { - moduleInstanceTypeSymbol.removeDeclaration(decls[i]); - } - } - - moduleInstanceTypeSymbol.addDeclaration(moduleContainerDecl); - moduleInstanceTypeSymbol.invalidate(); - } - } - - if (isEnum) { - moduleInstanceTypeSymbol = moduleContainerTypeSymbol.getInstanceSymbol().getType(); - - if (this.reBindingAfterChange) { - var existingIndexSigs = moduleInstanceTypeSymbol.getIndexSignatures(); - - for (var i = 0; i < existingIndexSigs.length; i++) { - moduleInstanceTypeSymbol.removeIndexSignature(existingIndexSigs[i]); - } - } - - var enumIndexSignature = new TypeScript.PullSignatureSymbol(4194304 /* IndexSignature */); - var enumIndexParameterSymbol = new TypeScript.PullSymbol("x", 2048 /* Parameter */); - enumIndexParameterSymbol.setType(this.semanticInfoChain.numberTypeSymbol); - enumIndexSignature.addParameter(enumIndexParameterSymbol); - enumIndexSignature.setReturnType(this.semanticInfoChain.stringTypeSymbol); - - moduleInstanceTypeSymbol.addIndexSignature(enumIndexSignature); - - moduleInstanceTypeSymbol.recomputeIndexSignatures(); - } - - var valueDecl = moduleContainerDecl.getValueDecl(); - - if (valueDecl) { - valueDecl.ensureSymbolIsBound(); - } - - var otherDecls = this.findDeclsInContext(moduleContainerDecl, moduleContainerDecl.getKind(), true); - - if (otherDecls && otherDecls.length) { - for (var i = 0; i < otherDecls.length; i++) { - otherDecls[i].ensureSymbolIsBound(); - } - } - }; - - PullSymbolBinder.prototype.bindImportDeclaration = function (importDeclaration) { - var declFlags = importDeclaration.getFlags(); - var declKind = importDeclaration.getKind(); - var importDeclAST = this.semanticInfo.getASTForDecl(importDeclaration); - - var isExported = false; - var linkKind = 6 /* PrivateMember */; - var importSymbol = null; - var declName = importDeclaration.getName(); - var parentHadSymbol = false; - var parent = this.getParent(importDeclaration); - - if (parent) { - importSymbol = parent.findMember(declName, false); - - if (!importSymbol) { - importSymbol = parent.findContainedMember(declName); - - if (importSymbol) { - var declarations = importSymbol.getDeclarations(); - - if (declarations.length) { - var importSymbolParent = declarations[0].getParentDecl(); - - if ((importSymbolParent !== importDeclaration.getParentDecl()) && (!this.reBindingAfterChange || (importSymbolParent.getDeclID() >= this.startingDeclForRebind))) { - importSymbol = null; - } - } - } - } - } else if (!(importDeclaration.getFlags() & 1 /* Exported */)) { - importSymbol = findSymbolInContext(declName, TypeScript.PullElementKind.SomeContainer, importDeclaration); - } - - if (importSymbol) { - parentHadSymbol = true; - } - - if (importSymbol && this.symbolIsRedeclaration(importSymbol)) { - importDeclaration.addDiagnostic(new TypeScript.SemanticDiagnostic(this.semanticInfo.getPath(), importDeclAST.minChar, importDeclAST.getLength(), 69 /* Duplicate_identifier__0_ */, [importDeclaration.getDisplayName()])); - importSymbol = null; - } - - if (this.reBindingAfterChange && importSymbol) { - var decls = importSymbol.getDeclarations(); - var scriptName = importDeclaration.getScriptName(); - - for (var j = 0; j < decls.length; j++) { - if (decls[j].getScriptName() === scriptName && decls[j].getDeclID() < this.startingDeclForRebind) { - importSymbol.removeDeclaration(decls[j]); - } - } - - importSymbol.setUnresolved(); - } - - if (!importSymbol) { - importSymbol = new TypeScript.PullTypeAliasSymbol(declName); - - if (!parent) { - this.semanticInfoChain.cacheGlobalSymbol(importSymbol, TypeScript.PullElementKind.SomeContainer); - } - } - - importSymbol.addDeclaration(importDeclaration); - importDeclaration.setSymbol(importSymbol); - - this.semanticInfo.setSymbolAndDiagnosticsForAST(importDeclAST, TypeScript.SymbolAndDiagnostics.fromSymbol(importSymbol)); - - if (parent && !parentHadSymbol) { - if (declFlags & 1 /* Exported */) { - parent.addMember(importSymbol, 5 /* PublicMember */); - } else { - importSymbol.setContainer(parent); - } - } - - importSymbol.setIsBound(this.bindingPhase); - }; - - PullSymbolBinder.prototype.cleanInterfaceSignatures = function (interfaceSymbol) { - var callSigs = interfaceSymbol.getCallSignatures(); - var constructSigs = interfaceSymbol.getConstructSignatures(); - var indexSigs = interfaceSymbol.getIndexSignatures(); - - for (var i = 0; i < callSigs.length; i++) { - if (callSigs[i].getSymbolID() < this.startingSymbolForRebind) { - interfaceSymbol.removeCallSignature(callSigs[i], false); - } - } - for (var i = 0; i < constructSigs.length; i++) { - if (constructSigs[i].getSymbolID() < this.startingSymbolForRebind) { - interfaceSymbol.removeConstructSignature(constructSigs[i], false); - } - } - for (var i = 0; i < indexSigs.length; i++) { - if (indexSigs[i].getSymbolID() < this.startingSymbolForRebind) { - interfaceSymbol.removeIndexSignature(indexSigs[i], false); - } - } - - interfaceSymbol.recomputeCallSignatures(); - interfaceSymbol.recomputeConstructSignatures(); - interfaceSymbol.recomputeIndexSignatures(); - }; - - PullSymbolBinder.prototype.cleanClassSignatures = function (classSymbol) { - var callSigs = classSymbol.getCallSignatures(); - var constructSigs = classSymbol.getConstructSignatures(); - var indexSigs = classSymbol.getIndexSignatures(); - - for (var i = 0; i < callSigs.length; i++) { - classSymbol.removeCallSignature(callSigs[i], false); - } - for (var i = 0; i < constructSigs.length; i++) { - classSymbol.removeConstructSignature(constructSigs[i], false); - } - for (var i = 0; i < indexSigs.length; i++) { - classSymbol.removeIndexSignature(indexSigs[i], false); - } - - classSymbol.recomputeCallSignatures(); - classSymbol.recomputeConstructSignatures(); - classSymbol.recomputeIndexSignatures(); - - var constructorSymbol = classSymbol.getConstructorMethod(); - var constructorTypeSymbol = (constructorSymbol ? constructorSymbol.getType() : null); - - if (constructorTypeSymbol) { - constructSigs = constructorTypeSymbol.getConstructSignatures(); - - for (var i = 0; i < constructSigs.length; i++) { - constructorTypeSymbol.removeConstructSignature(constructSigs[i], false); - } - - constructorTypeSymbol.recomputeConstructSignatures(); - constructorTypeSymbol.invalidate(); - constructorSymbol.invalidate(); - } - - classSymbol.invalidate(); - }; - - PullSymbolBinder.prototype.bindClassDeclarationToPullSymbol = function (classDecl) { - var className = classDecl.getName(); - var classSymbol = null; - - var constructorSymbol = null; - var constructorTypeSymbol = null; - - var classAST = this.semanticInfo.getASTForDecl(classDecl); - var parentHadSymbol = false; - - var parent = this.getParent(classDecl); - var parentDecl = classDecl.getParentDecl(); - var cleanedPreviousDecls = false; - var isExported = classDecl.getFlags() & 1 /* Exported */; - var isGeneric = false; - - var acceptableSharedKind = 8 /* Class */; - - if (parent) { - if (isExported) { - classSymbol = parent.findNestedType(className); - - if (!classSymbol) { - classSymbol = parent.findMember(className, false); - } - } else { - classSymbol = parent.findContainedMember(className); - - if (classSymbol && (classSymbol.getKind() & acceptableSharedKind)) { - var declarations = classSymbol.getDeclarations(); - - if (declarations.length) { - var classSymbolParent = declarations[0].getParentDecl(); - - if ((classSymbolParent !== parentDecl) && (!this.reBindingAfterChange || (classSymbolParent.getDeclID() >= this.startingDeclForRebind))) { - classSymbol = null; - } - } - } else { - classSymbol = null; - } - } - } else { - classSymbol = findSymbolInContext(className, acceptableSharedKind, classDecl); - } - - if (classSymbol && (!(classSymbol.getKind() & acceptableSharedKind) || !this.reBindingAfterChange || this.symbolIsRedeclaration(classSymbol))) { - classDecl.addDiagnostic(new TypeScript.SemanticDiagnostic(this.semanticInfo.getPath(), classAST.minChar, classAST.getLength(), 69 /* Duplicate_identifier__0_ */, [classDecl.getDisplayName()])); - classSymbol = null; - } else if (classSymbol) { - parentHadSymbol = true; - } - - var decls; - - if (this.reBindingAfterChange && classSymbol) { - decls = classSymbol.getDeclarations(); - var scriptName = classDecl.getScriptName(); - - for (var j = 0; j < decls.length; j++) { - if (decls[j].getScriptName() === scriptName && decls[j].getDeclID() < this.startingDeclForRebind) { - classSymbol.removeDeclaration(decls[j]); - - cleanedPreviousDecls = true; - } - } - - constructorSymbol = classSymbol.getConstructorMethod(); - constructorTypeSymbol = constructorSymbol.getType(); - - decls = constructorSymbol.getDeclarations(); - - for (var j = 0; j < decls.length; j++) { - if (decls[j].getScriptName() === scriptName && decls[j].getDeclID() < this.startingDeclForRebind) { - constructorSymbol.removeDeclaration(decls[j]); - - cleanedPreviousDecls = true; - } - } - - if (constructorSymbol.getIsSynthesized()) { - classSymbol.setConstructorMethod(null); - } - - if (classSymbol.isGeneric()) { - isGeneric = true; - - var specializations = classSymbol.getKnownSpecializations(); - var specialization = null; - - for (var i = 0; i < specializations.length; i++) { - specializations[i].setUnresolved(); - specializations[i].invalidate(); - } - - classSymbol.cleanTypeParameters(); - constructorTypeSymbol.cleanTypeParameters(); - } - - classSymbol.setUnresolved(); - constructorSymbol.setUnresolved(); - constructorTypeSymbol.setUnresolved(); - } - - if (!parentHadSymbol) { - classSymbol = new TypeScript.PullClassTypeSymbol(className); - - if (!parent) { - this.semanticInfoChain.cacheGlobalSymbol(classSymbol, acceptableSharedKind); - } - } - - classSymbol.addDeclaration(classDecl); - - classDecl.setSymbol(classSymbol); - - this.semanticInfo.setSymbolAndDiagnosticsForAST(classAST.name, TypeScript.SymbolAndDiagnostics.fromSymbol(classSymbol)); - this.semanticInfo.setSymbolAndDiagnosticsForAST(classAST, TypeScript.SymbolAndDiagnostics.fromSymbol(classSymbol)); - - if (parent && !parentHadSymbol) { - var linkKind = classDecl.getFlags() & 1 /* Exported */ ? 5 /* PublicMember */ : 6 /* PrivateMember */; - - if (linkKind === 5 /* PublicMember */) { - parent.addMember(classSymbol, linkKind); - } else { - classSymbol.setContainer(parent); - } - } - - if (parentHadSymbol && cleanedPreviousDecls) { - this.cleanClassSignatures(classSymbol); - - if (isGeneric) { - specializations = classSymbol.getKnownSpecializations(); - - for (var i = 0; i < specializations.length; i++) { - this.cleanClassSignatures(specializations[i]); - } - } - } - - this.resetTypeParameterCache(); - - this.resetTypeParameterCache(); - - constructorSymbol = classSymbol.getConstructorMethod(); - constructorTypeSymbol = (constructorSymbol ? constructorSymbol.getType() : null); - - if (!constructorSymbol) { - constructorSymbol = new TypeScript.PullSymbol(className, 32768 /* ConstructorMethod */); - constructorTypeSymbol = new TypeScript.PullConstructorTypeSymbol(); - - constructorSymbol.setIsSynthesized(); - - constructorSymbol.setType(constructorTypeSymbol); - constructorSymbol.addDeclaration(classDecl.getValueDecl()); - classSymbol.setConstructorMethod(constructorSymbol); - - constructorTypeSymbol.addDeclaration(classDecl); - - classSymbol.setHasDefaultConstructor(); - } - - constructorTypeSymbol.setAssociatedContainerType(classSymbol); - - var typeParameters = classDecl.getTypeParameters(); - var typeParameter; - var typeParameterDecls = null; - - for (var i = 0; i < typeParameters.length; i++) { - typeParameter = classSymbol.findTypeParameter(typeParameters[i].getName()); - - if (!typeParameter) { - typeParameter = new TypeScript.PullTypeParameterSymbol(typeParameters[i].getName(), false); - - classSymbol.addMember(typeParameter, 18 /* TypeParameter */); - constructorTypeSymbol.addTypeParameter(typeParameter, true); - } else { - typeParameterDecls = typeParameter.getDeclarations(); - - if (this.symbolIsRedeclaration(typeParameter)) { - var typeParameterAST = this.semanticInfoChain.getASTForDecl(typeParameterDecls[0]); - classDecl.addDiagnostic(new TypeScript.SemanticDiagnostic(this.semanticInfo.getPath(), typeParameterAST.minChar, typeParameterAST.getLength(), 69 /* Duplicate_identifier__0_ */, [typeParameter.getName()])); - } - - for (var j = 0; j < typeParameterDecls.length; j++) { - if (typeParameterDecls[j].getDeclID() < this.startingDeclForRebind) { - typeParameter.removeDeclaration(typeParameterDecls[j]); - } - } - } - - typeParameter.addDeclaration(typeParameters[i]); - typeParameters[i].setSymbol(typeParameter); - } - - var valueDecl = classDecl.getValueDecl(); - - if (valueDecl) { - valueDecl.ensureSymbolIsBound(); - } - - classSymbol.setIsBound(this.bindingPhase); - }; - - PullSymbolBinder.prototype.bindInterfaceDeclarationToPullSymbol = function (interfaceDecl) { - var interfaceName = interfaceDecl.getName(); - var interfaceSymbol = findSymbolInContext(interfaceName, TypeScript.PullElementKind.SomeType, interfaceDecl); - - var interfaceAST = this.semanticInfo.getASTForDecl(interfaceDecl); - var createdNewSymbol = false; - var parent = this.getParent(interfaceDecl); - - var acceptableSharedKind = 16 /* Interface */; - - if (parent) { - interfaceSymbol = parent.findNestedType(interfaceName); - } else if (!(interfaceDecl.getFlags() & 1 /* Exported */)) { - interfaceSymbol = findSymbolInContext(interfaceName, acceptableSharedKind, interfaceDecl); - } - - if (interfaceSymbol && !(interfaceSymbol.getKind() & acceptableSharedKind)) { - interfaceDecl.addDiagnostic(new TypeScript.SemanticDiagnostic(this.semanticInfo.getPath(), interfaceAST.minChar, interfaceAST.getLength(), 69 /* Duplicate_identifier__0_ */, [interfaceDecl.getDisplayName()])); - interfaceSymbol = null; - } - - if (!interfaceSymbol) { - interfaceSymbol = new TypeScript.PullTypeSymbol(interfaceName, 16 /* Interface */); - createdNewSymbol = true; - - if (!parent) { - this.semanticInfoChain.cacheGlobalSymbol(interfaceSymbol, acceptableSharedKind); - } - } - - interfaceSymbol.addDeclaration(interfaceDecl); - interfaceDecl.setSymbol(interfaceSymbol); - - if (createdNewSymbol) { - if (parent) { - var linkKind = interfaceDecl.getFlags() & 1 /* Exported */ ? 5 /* PublicMember */ : 6 /* PrivateMember */; - - if (linkKind === 5 /* PublicMember */) { - parent.addMember(interfaceSymbol, linkKind); - } else { - interfaceSymbol.setContainer(parent); - } - } - } else if (this.reBindingAfterChange) { - var decls = interfaceSymbol.getDeclarations(); - var scriptName = interfaceDecl.getScriptName(); - - for (var i = 0; i < decls.length; i++) { - if (decls[i].getScriptName() === scriptName && decls[i].getDeclID() < this.startingDeclForRebind) { - interfaceSymbol.removeDeclaration(decls[i]); - } - } - - if (interfaceSymbol.isGeneric()) { - var specializations = interfaceSymbol.getKnownSpecializations(); - var specialization = null; - - for (var i = 0; i < specializations.length; i++) { - specialization = specializations[i]; - - this.cleanInterfaceSignatures(specialization); - specialization.invalidate(); - } - - interfaceSymbol.cleanTypeParameters(); - } - - this.cleanInterfaceSignatures(interfaceSymbol); - interfaceSymbol.invalidate(); - } - - this.resetTypeParameterCache(); - - this.resetTypeParameterCache(); - - var typeParameters = interfaceDecl.getTypeParameters(); - var typeParameter; - var typeParameterDecls = null; - - for (var i = 0; i < typeParameters.length; i++) { - typeParameter = interfaceSymbol.findTypeParameter(typeParameters[i].getName()); - - if (!typeParameter) { - typeParameter = new TypeScript.PullTypeParameterSymbol(typeParameters[i].getName(), false); - - interfaceSymbol.addMember(typeParameter, 18 /* TypeParameter */); - } else { - typeParameterDecls = typeParameter.getDeclarations(); - - if (this.symbolIsRedeclaration(typeParameter)) { - for (var j = 0; j < typeParameterDecls.length; j++) { - var typeParameterDeclParent = typeParameterDecls[j].getParentDecl(); - - if (typeParameterDeclParent && typeParameterDeclParent === interfaceDecl) { - var typeParameterAST = this.semanticInfoChain.getASTForDecl(typeParameterDecls[0]); - interfaceDecl.addDiagnostic(new TypeScript.SemanticDiagnostic(this.semanticInfo.getPath(), typeParameterAST.minChar, typeParameterAST.getLength(), 69 /* Duplicate_identifier__0_ */, [typeParameter.getName()])); - - break; - } - } - } - - for (var j = 0; j < typeParameterDecls.length; j++) { - if (typeParameterDecls[j].getDeclID() < this.startingDeclForRebind) { - typeParameter.removeDeclaration(typeParameterDecls[j]); - } - } - } - - typeParameter.addDeclaration(typeParameters[i]); - typeParameters[i].setSymbol(typeParameter); - } - - var otherDecls = this.findDeclsInContext(interfaceDecl, interfaceDecl.getKind(), true); - - if (otherDecls && otherDecls.length) { - for (var i = 0; i < otherDecls.length; i++) { - otherDecls[i].ensureSymbolIsBound(); - } - } - }; - - PullSymbolBinder.prototype.bindObjectTypeDeclarationToPullSymbol = function (objectDecl) { - var objectSymbolAST = this.semanticInfo.getASTForDecl(objectDecl); - - var objectSymbol = new TypeScript.PullTypeSymbol("", 8388608 /* ObjectType */); - - objectSymbol.addDeclaration(objectDecl); - objectDecl.setSymbol(objectSymbol); - - this.semanticInfo.setSymbolAndDiagnosticsForAST(objectSymbolAST, TypeScript.SymbolAndDiagnostics.fromSymbol(objectSymbol)); - - var childDecls = objectDecl.getChildDecls(); - - for (var i = 0; i < childDecls.length; i++) { - this.bindDeclToPullSymbol(childDecls[i]); - } - - var typeParameters = objectDecl.getTypeParameters(); - var typeParameter; - var typeParameterDecls = null; - - for (var i = 0; i < typeParameters.length; i++) { - typeParameter = objectSymbol.findTypeParameter(typeParameters[i].getName()); - - if (!typeParameter) { - typeParameter = new TypeScript.PullTypeParameterSymbol(typeParameters[i].getName(), false); - - objectSymbol.addMember(typeParameter, 18 /* TypeParameter */); - } else { - typeParameterDecls = typeParameter.getDeclarations(); - - if (this.symbolIsRedeclaration(typeParameter)) { - var typeParameterAST = this.semanticInfoChain.getASTForDecl(typeParameterDecls[0]); - objectDecl.addDiagnostic(new TypeScript.SemanticDiagnostic(this.semanticInfo.getPath(), typeParameterAST.minChar, typeParameterAST.getLength(), 69 /* Duplicate_identifier__0_ */, [typeParameter.getName()])); - } - - for (var j = 0; j < typeParameterDecls.length; j++) { - if (typeParameterDecls[j].getDeclID() < this.startingDeclForRebind) { - typeParameter.removeDeclaration(typeParameterDecls[j]); - } - } - } - - typeParameter.addDeclaration(typeParameters[i]); - typeParameters[i].setSymbol(typeParameter); - } - }; - - PullSymbolBinder.prototype.bindConstructorTypeDeclarationToPullSymbol = function (constructorTypeDeclaration) { - var declKind = constructorTypeDeclaration.getKind(); - var declFlags = constructorTypeDeclaration.getFlags(); - var constructorTypeAST = this.semanticInfo.getASTForDecl(constructorTypeDeclaration); - - var constructorTypeSymbol = new TypeScript.PullConstructorTypeSymbol(); - - constructorTypeDeclaration.setSymbol(constructorTypeSymbol); - constructorTypeSymbol.addDeclaration(constructorTypeDeclaration); - this.semanticInfo.setSymbolAndDiagnosticsForAST(constructorTypeAST, TypeScript.SymbolAndDiagnostics.fromSymbol(constructorTypeSymbol)); - - var signature = new TypeScript.PullDefinitionSignatureSymbol(2097152 /* ConstructSignature */); - - if ((constructorTypeAST).variableArgList) { - signature.setHasVariableParamList(); - } - - signature.addDeclaration(constructorTypeDeclaration); - constructorTypeDeclaration.setSignatureSymbol(signature); - - this.bindParameterSymbols(this.semanticInfo.getASTForDecl(constructorTypeDeclaration), constructorTypeSymbol, signature); - - constructorTypeSymbol.addSignature(signature); - - var typeParameters = constructorTypeDeclaration.getTypeParameters(); - var typeParameter; - var typeParameterDecls = null; - - for (var i = 0; i < typeParameters.length; i++) { - typeParameter = constructorTypeSymbol.findTypeParameter(typeParameters[i].getName()); - - if (!typeParameter) { - typeParameter = new TypeScript.PullTypeParameterSymbol(typeParameters[i].getName(), false); - - constructorTypeSymbol.addTypeParameter(typeParameter); - } else { - typeParameterDecls = typeParameter.getDeclarations(); - - if (this.symbolIsRedeclaration(typeParameter)) { - var typeParameterAST = this.semanticInfoChain.getASTForDecl(typeParameterDecls[0]); - constructorTypeDeclaration.addDiagnostic(new TypeScript.SemanticDiagnostic(this.semanticInfo.getPath(), typeParameterAST.minChar, typeParameterAST.getLength(), 69 /* Duplicate_identifier__0_ */, [typeParameter.getName()])); - } - - for (var j = 0; j < typeParameterDecls.length; j++) { - if (typeParameterDecls[j].getDeclID() < this.startingDeclForRebind) { - typeParameter.removeDeclaration(typeParameterDecls[j]); - } - } - } - - typeParameter.addDeclaration(typeParameters[i]); - typeParameters[i].setSymbol(typeParameter); - } - }; - - PullSymbolBinder.prototype.bindVariableDeclarationToPullSymbol = function (variableDeclaration) { - var declFlags = variableDeclaration.getFlags(); - var declKind = variableDeclaration.getKind(); - var varDeclAST = this.semanticInfo.getASTForDecl(variableDeclaration); - - var isExported = (declFlags & 1 /* Exported */) !== 0; - - var linkKind = 6 /* PrivateMember */; - - var variableSymbol = null; - - var declName = variableDeclaration.getName(); - - var parentHadSymbol = false; - - var parent = this.getParent(variableDeclaration, true); - - var parentDecl = variableDeclaration.getParentDecl(); - - var isImplicit = (declFlags & TypeScript.PullElementFlags.ImplicitVariable) !== 0; - var isModuleValue = (declFlags & (32768 /* InitializedModule */ | 65536 /* InitializedDynamicModule */ | 131072 /* InitializedEnum */)) != 0; - var isEnumValue = (declFlags & 131072 /* InitializedEnum */) != 0; - var isClassConstructorVariable = (declFlags & 16384 /* ClassConstructorVariable */) != 0; - - if (parentDecl && !isImplicit) { - parentDecl.addVariableDeclToGroup(variableDeclaration); - } - - if (parent) { - if (isExported) { - variableSymbol = parent.findMember(declName, false); - } else { - variableSymbol = parent.findContainedMember(declName); - } - - if (variableSymbol) { - var declarations = variableSymbol.getDeclarations(); - - if (declarations.length) { - var variableSymbolParent = declarations[0].getParentDecl(); - - if ((parentDecl !== variableSymbolParent) && (!this.reBindingAfterChange || (variableSymbolParent.getDeclID() >= this.startingDeclForRebind))) { - variableSymbol = null; - } - } - } - } else if (!(variableDeclaration.getFlags() & 1 /* Exported */)) { - variableSymbol = findSymbolInContext(declName, TypeScript.PullElementKind.SomeValue, variableDeclaration); - } - - if (variableSymbol && !variableSymbol.isType()) { - parentHadSymbol = true; - } - - var span; - var decl; - var decls; - var ast; - var members; - - if (variableSymbol && this.symbolIsRedeclaration(variableSymbol)) { - var prevKind = variableSymbol.getKind(); - var prevIsAmbient = variableSymbol.hasFlag(8 /* Ambient */); - var prevIsEnum = variableSymbol.hasFlag(131072 /* InitializedEnum */); - var prevIsClass = prevKind == 32768 /* ConstructorMethod */; - var prevIsContainer = variableSymbol.hasFlag(32768 /* InitializedModule */ | 65536 /* InitializedDynamicModule */); - var onlyOneIsEnum = (isEnumValue || prevIsEnum) && !(isEnumValue && prevIsEnum); - var isAmbient = (variableDeclaration.getFlags() & 8 /* Ambient */) != 0; - var isClass = variableDeclaration.getKind() == 32768 /* ConstructorMethod */; - - var acceptableRedeclaration = isImplicit && ((!isEnumValue && !isClassConstructorVariable && prevKind == 16384 /* Function */) || (!isModuleValue && prevIsContainer && isAmbient) || (!isModuleValue && prevIsClass) || variableSymbol.hasFlag(TypeScript.PullElementFlags.ImplicitVariable)); - - if (acceptableRedeclaration && prevIsClass && !prevIsAmbient) { - if (variableSymbol.getDeclarations()[0].getScriptName() != variableDeclaration.getScriptName()) { - acceptableRedeclaration = false; - } - } - - if ((!isModuleValue && !isClass && !isAmbient) || !acceptableRedeclaration || onlyOneIsEnum) { - span = variableDeclaration.getSpan(); - if (!parent || variableSymbol.getIsSynthesized()) { - var errorDecl = isImplicit ? variableSymbol.getDeclarations()[0] : variableDeclaration; - errorDecl.addDiagnostic(new TypeScript.SemanticDiagnostic(this.semanticInfo.getPath(), span.start(), span.length(), 69 /* Duplicate_identifier__0_ */, [variableDeclaration.getDisplayName()])); - } - - variableSymbol = null; - parentHadSymbol = false; - } - } else if (variableSymbol && (variableSymbol.getKind() !== 1024 /* Variable */) && !isImplicit) { - span = variableDeclaration.getSpan(); - - variableDeclaration.addDiagnostic(new TypeScript.SemanticDiagnostic(this.semanticInfo.getPath(), span.start(), span.length(), 69 /* Duplicate_identifier__0_ */, [variableDeclaration.getDisplayName()])); - variableSymbol = null; - parentHadSymbol = false; - } - - if (this.reBindingAfterChange && variableSymbol && !variableSymbol.isType()) { - decls = variableSymbol.getDeclarations(); - var scriptName = variableDeclaration.getScriptName(); - - for (var j = 0; j < decls.length; j++) { - if (decls[j].getScriptName() === scriptName && decls[j].getDeclID() < this.startingDeclForRebind) { - variableSymbol.removeDeclaration(decls[j]); - } - } - - variableSymbol.invalidate(); - } - - var replaceProperty = false; - var previousProperty = null; - - if ((declFlags & TypeScript.PullElementFlags.ImplicitVariable) === 0) { - if (!variableSymbol) { - variableSymbol = new TypeScript.PullSymbol(declName, declKind); - } - - variableSymbol.addDeclaration(variableDeclaration); - variableDeclaration.setSymbol(variableSymbol); - - this.semanticInfo.setSymbolAndDiagnosticsForAST(varDeclAST.id, TypeScript.SymbolAndDiagnostics.fromSymbol(variableSymbol)); - this.semanticInfo.setSymbolAndDiagnosticsForAST(varDeclAST, TypeScript.SymbolAndDiagnostics.fromSymbol(variableSymbol)); - } else if (!parentHadSymbol) { - if (isClassConstructorVariable) { - var classTypeSymbol = variableSymbol; - - if (parent) { - members = parent.getMembers(); - - for (var i = 0; i < members.length; i++) { - if ((members[i].getName() === declName) && (members[i].getKind() === 8 /* Class */)) { - classTypeSymbol = members[i]; - break; - } - } - } - - if (!classTypeSymbol) { - var parentDecl = variableDeclaration.getParentDecl(); - - if (parentDecl) { - var childDecls = parentDecl.searchChildDecls(declName, TypeScript.PullElementKind.SomeType); - - if (childDecls.length) { - for (var i = 0; i < childDecls.length; i++) { - if (childDecls[i].getValueDecl() === variableDeclaration) { - classTypeSymbol = childDecls[i].getSymbol(); - } - } - } - } - - if (!classTypeSymbol) { - classTypeSymbol = findSymbolInContext(declName, TypeScript.PullElementKind.SomeType, variableDeclaration); - } - } - - if (classTypeSymbol && (classTypeSymbol.getKind() !== 8 /* Class */)) { - classTypeSymbol = null; - } - - if (classTypeSymbol && classTypeSymbol.isClass()) { - replaceProperty = variableSymbol && variableSymbol.getIsSynthesized(); - - if (replaceProperty) { - previousProperty = variableSymbol; - } - - variableSymbol = classTypeSymbol.getConstructorMethod(); - variableDeclaration.setSymbol(variableSymbol); - - decls = classTypeSymbol.getDeclarations(); - - if (decls.length) { - decl = decls[decls.length - 1]; - ast = this.semanticInfo.getASTForDecl(decl); - - if (ast) { - this.semanticInfo.setASTForDecl(variableDeclaration, ast); - } - } - } else { - if (!variableSymbol) { - variableSymbol = new TypeScript.PullSymbol(declName, declKind); - } - - variableSymbol.addDeclaration(variableDeclaration); - variableDeclaration.setSymbol(variableSymbol); - - variableSymbol.setType(this.semanticInfoChain.anyTypeSymbol); - } - } else if (declFlags & TypeScript.PullElementFlags.SomeInitializedModule) { - var moduleContainerTypeSymbol = null; - var moduleParent = this.getParent(variableDeclaration); - - if (moduleParent) { - members = moduleParent.getMembers(); - - for (var i = 0; i < members.length; i++) { - if ((members[i].getName() === declName) && (members[i].isContainer())) { - moduleContainerTypeSymbol = members[i]; - break; - } - } - } - - if (!moduleContainerTypeSymbol) { - var parentDecl = variableDeclaration.getParentDecl(); - - if (parentDecl) { - var searchKind = (declFlags & (32768 /* InitializedModule */ | 65536 /* InitializedDynamicModule */)) ? TypeScript.PullElementKind.SomeContainer : 64 /* Enum */; - var childDecls = parentDecl.searchChildDecls(declName, searchKind); - - if (childDecls.length) { - for (var i = 0; i < childDecls.length; i++) { - if (childDecls[i].getValueDecl() === variableDeclaration) { - moduleContainerTypeSymbol = childDecls[i].getSymbol(); - } - } - } - } - if (!moduleContainerTypeSymbol) { - moduleContainerTypeSymbol = findSymbolInContext(declName, TypeScript.PullElementKind.SomeContainer, variableDeclaration); - - if (!moduleContainerTypeSymbol) { - moduleContainerTypeSymbol = findSymbolInContext(declName, 64 /* Enum */, variableDeclaration); - } - } - } - - if (moduleContainerTypeSymbol && (!moduleContainerTypeSymbol.isContainer())) { - moduleContainerTypeSymbol = null; - } - - if (moduleContainerTypeSymbol) { - variableSymbol = moduleContainerTypeSymbol.getInstanceSymbol(); - - variableSymbol.addDeclaration(variableDeclaration); - variableDeclaration.setSymbol(variableSymbol); - - decls = moduleContainerTypeSymbol.getDeclarations(); - - if (decls.length) { - decl = decls[decls.length - 1]; - ast = this.semanticInfo.getASTForDecl(decl); - - if (ast) { - this.semanticInfo.setASTForDecl(variableDeclaration, ast); - } - } - } else { - TypeScript.Debug.assert(false, "Attempted to bind invalid implicit variable symbol"); - } - } - } else { - variableSymbol.addDeclaration(variableDeclaration); - variableDeclaration.setSymbol(variableSymbol); - } - - if (parent && !parentHadSymbol) { - if (declFlags & 1 /* Exported */) { - parent.addMember(variableSymbol, 5 /* PublicMember */); - } else { - variableSymbol.setContainer(parent); - } - } else if (replaceProperty) { - parent.removeMember(previousProperty); - parent.addMember(variableSymbol, linkKind); - } - - variableSymbol.setIsBound(this.bindingPhase); - }; - - PullSymbolBinder.prototype.bindPropertyDeclarationToPullSymbol = function (propertyDeclaration) { - var declFlags = propertyDeclaration.getFlags(); - var declKind = propertyDeclaration.getKind(); - var propDeclAST = this.semanticInfo.getASTForDecl(propertyDeclaration); - - var isStatic = false; - var isOptional = false; - - var linkKind = 5 /* PublicMember */; - - var propertySymbol = null; - - if (TypeScript.hasFlag(declFlags, 16 /* Static */)) { - isStatic = true; - } - - if (TypeScript.hasFlag(declFlags, 2 /* Private */)) { - linkKind = 6 /* PrivateMember */; - } - - if (TypeScript.hasFlag(declFlags, 128 /* Optional */)) { - isOptional = true; - } - - var declName = propertyDeclaration.getName(); - - var parentHadSymbol = false; - - var parent = this.getParent(propertyDeclaration, true); - - if (parent.isClass() && isStatic) { - parent = (parent).getConstructorMethod().getType(); - } - - propertySymbol = parent.findMember(declName, false); - - if (propertySymbol && (!this.reBindingAfterChange || this.symbolIsRedeclaration(propertySymbol))) { - var span = propertyDeclaration.getSpan(); - - propertyDeclaration.addDiagnostic(new TypeScript.SemanticDiagnostic(this.semanticInfo.getPath(), span.start(), span.length(), 69 /* Duplicate_identifier__0_ */, [propertyDeclaration.getDisplayName()])); - - propertySymbol = null; - } - - if (propertySymbol) { - parentHadSymbol = true; - } - - if (this.reBindingAfterChange && propertySymbol) { - var decls = propertySymbol.getDeclarations(); - var scriptName = propertyDeclaration.getScriptName(); - - for (var j = 0; j < decls.length; j++) { - if (decls[j].getScriptName() === scriptName && decls[j].getDeclID() < this.startingDeclForRebind) { - propertySymbol.removeDeclaration(decls[j]); - } - } - - propertySymbol.setUnresolved(); - } - - var classTypeSymbol; - - if (!parentHadSymbol) { - propertySymbol = new TypeScript.PullSymbol(declName, declKind); - } - - propertySymbol.addDeclaration(propertyDeclaration); - propertyDeclaration.setSymbol(propertySymbol); - - this.semanticInfo.setSymbolAndDiagnosticsForAST(propDeclAST.id, TypeScript.SymbolAndDiagnostics.fromSymbol(propertySymbol)); - this.semanticInfo.setSymbolAndDiagnosticsForAST(propDeclAST, TypeScript.SymbolAndDiagnostics.fromSymbol(propertySymbol)); - - if (isOptional) { - propertySymbol.setIsOptional(); - } - - if (parent && !parentHadSymbol) { - if (parent.isClass()) { - classTypeSymbol = parent; - - classTypeSymbol.addMember(propertySymbol, linkKind); - } else { - parent.addMember(propertySymbol, linkKind); - } - } - - propertySymbol.setIsBound(this.bindingPhase); - }; - - PullSymbolBinder.prototype.bindParameterSymbols = function (funcDecl, funcType, signatureSymbol) { - var parameters = []; - var decl = null; - var argDecl = null; - var parameterSymbol = null; - var isProperty = false; - var params = new TypeScript.BlockIntrinsics(); - - if (funcDecl.arguments) { - for (var i = 0; i < funcDecl.arguments.members.length; i++) { - argDecl = funcDecl.arguments.members[i]; - decl = this.semanticInfo.getDeclForAST(argDecl); - isProperty = TypeScript.hasFlag(argDecl.getVarFlags(), 256 /* Property */); - parameterSymbol = new TypeScript.PullSymbol(argDecl.id.text, 2048 /* Parameter */); - - if (funcDecl.variableArgList && i === funcDecl.arguments.members.length - 1) { - parameterSymbol.setIsVarArg(); - } - - if (decl.getFlags() & 128 /* Optional */) { - parameterSymbol.setIsOptional(); - } - - if (params[argDecl.id.text]) { - decl.addDiagnostic(new TypeScript.SemanticDiagnostic(this.semanticInfo.getPath(), argDecl.minChar, argDecl.getLength(), 69 /* Duplicate_identifier__0_ */, [argDecl.id.actualText])); - } else { - params[argDecl.id.text] = true; - } - if (decl) { - if (isProperty) { - decl.ensureSymbolIsBound(); - var valDecl = decl.getValueDecl(); - - if (valDecl) { - valDecl.setSymbol(parameterSymbol); - parameterSymbol.addDeclaration(valDecl); - } - } else { - parameterSymbol.addDeclaration(decl); - decl.setSymbol(parameterSymbol); - } - } - - signatureSymbol.addParameter(parameterSymbol, parameterSymbol.getIsOptional()); - - if (signatureSymbol.isDefinition()) { - parameterSymbol.setContainer(funcType); - } - } - } - }; - - PullSymbolBinder.prototype.bindFunctionDeclarationToPullSymbol = function (functionDeclaration) { - var declKind = functionDeclaration.getKind(); - var declFlags = functionDeclaration.getFlags(); - var funcDeclAST = this.semanticInfo.getASTForDecl(functionDeclaration); - - var isExported = (declFlags & 1 /* Exported */) !== 0; - - var funcName = functionDeclaration.getName(); - - var isSignature = (declFlags & 2048 /* Signature */) !== 0; - - var parent = this.getParent(functionDeclaration, true); - var parentDecl = functionDeclaration.getParentDecl(); - var parentHadSymbol = false; - var cleanedPreviousDecls = false; - - var functionSymbol = null; - var functionTypeSymbol = null; - - if (parent) { - functionSymbol = parent.findMember(funcName, false); - - if (!functionSymbol) { - functionSymbol = parent.findContainedMember(funcName); - - if (functionSymbol) { - var declarations = functionSymbol.getDeclarations(); - - if (declarations.length) { - var funcSymbolParent = declarations[0].getParentDecl(); - - if ((parentDecl !== funcSymbolParent) && (!this.reBindingAfterChange || (funcSymbolParent.getDeclID() >= this.startingDeclForRebind))) { - functionSymbol = null; - } - } - } - } - } else if (!(functionDeclaration.getFlags() & 1 /* Exported */)) { - functionSymbol = findSymbolInContext(funcName, TypeScript.PullElementKind.SomeValue, functionDeclaration); - } - - if (functionSymbol && (functionSymbol.getKind() !== 16384 /* Function */ || (this.symbolIsRedeclaration(functionSymbol) && !isSignature && !functionSymbol.allDeclsHaveFlag(2048 /* Signature */)))) { - functionDeclaration.addDiagnostic(new TypeScript.SemanticDiagnostic(this.semanticInfo.getPath(), funcDeclAST.minChar, funcDeclAST.getLength(), 69 /* Duplicate_identifier__0_ */, [functionDeclaration.getDisplayName()])); - functionSymbol = null; - } - - if (functionSymbol) { - functionTypeSymbol = functionSymbol.getType(); - parentHadSymbol = true; - } - - if (this.reBindingAfterChange && functionSymbol) { - var decls = functionSymbol.getDeclarations(); - var scriptName = functionDeclaration.getScriptName(); - var isGeneric = functionTypeSymbol.isGeneric(); - - for (var j = 0; j < decls.length; j++) { - if (decls[j].getScriptName() === scriptName && decls[j].getDeclID() < this.startingDeclForRebind) { - functionSymbol.removeDeclaration(decls[j]); - - cleanedPreviousDecls = true; - } - } - - decls = functionTypeSymbol.getDeclarations(); - - for (var j = 0; j < decls.length; j++) { - if (decls[j].getScriptName() === scriptName && decls[j].getDeclID() < this.startingDeclForRebind) { - functionTypeSymbol.removeDeclaration(decls[j]); - - cleanedPreviousDecls = true; - } - } - - if (isGeneric) { - var specializations = functionTypeSymbol.getKnownSpecializations(); - - for (var i = 0; i < specializations.length; i++) { - specializations[i].invalidate(); - } - } - - functionSymbol.invalidate(); - functionTypeSymbol.invalidate(); - } - - if (!functionSymbol) { - functionSymbol = new TypeScript.PullSymbol(funcName, 16384 /* Function */); - } - - if (!functionTypeSymbol) { - functionTypeSymbol = new TypeScript.PullFunctionTypeSymbol(); - functionSymbol.setType(functionTypeSymbol); - } - - functionDeclaration.setSymbol(functionSymbol); - functionSymbol.addDeclaration(functionDeclaration); - functionTypeSymbol.addDeclaration(functionDeclaration); - - this.semanticInfo.setSymbolAndDiagnosticsForAST(funcDeclAST.name, TypeScript.SymbolAndDiagnostics.fromSymbol(functionSymbol)); - this.semanticInfo.setSymbolAndDiagnosticsForAST(funcDeclAST, TypeScript.SymbolAndDiagnostics.fromSymbol(functionSymbol)); - - if (parent && !parentHadSymbol) { - if (isExported) { - parent.addMember(functionSymbol, 5 /* PublicMember */); - } else { - functionSymbol.setContainer(parent); - } - } - - if (parentHadSymbol && cleanedPreviousDecls) { - var callSigs = functionTypeSymbol.getCallSignatures(); - - for (var i = 0; i < callSigs.length; i++) { - functionTypeSymbol.removeCallSignature(callSigs[i], false); - } - - functionSymbol.invalidate(); - functionTypeSymbol.invalidate(); - functionTypeSymbol.recomputeCallSignatures(); - - if (isGeneric) { - var specializations = functionTypeSymbol.getKnownSpecializations(); - - for (var j = 0; j < specializations.length; j++) { - callSigs = specializations[j].getCallSignatures(); - - for (var i = 0; i < callSigs.length; i++) { - callSigs[i].invalidate(); - } - } - } - } - - var signature = isSignature ? new TypeScript.PullSignatureSymbol(1048576 /* CallSignature */) : new TypeScript.PullDefinitionSignatureSymbol(1048576 /* CallSignature */); - - signature.addDeclaration(functionDeclaration); - functionDeclaration.setSignatureSymbol(signature); - - if (funcDeclAST.variableArgList) { - signature.setHasVariableParamList(); - } - - this.bindParameterSymbols(this.semanticInfo.getASTForDecl(functionDeclaration), functionTypeSymbol, signature); - - var typeParameters = functionDeclaration.getTypeParameters(); - var typeParameter; - var typeParameterDecls = null; - - for (var i = 0; i < typeParameters.length; i++) { - typeParameter = signature.findTypeParameter(typeParameters[i].getName()); - - if (!typeParameter) { - typeParameter = new TypeScript.PullTypeParameterSymbol(typeParameters[i].getName(), true); - - signature.addTypeParameter(typeParameter); - } else { - typeParameterDecls = typeParameter.getDeclarations(); - - if (this.symbolIsRedeclaration(typeParameter)) { - var typeParameterAST = this.semanticInfoChain.getASTForDecl(typeParameterDecls[0]); - functionDeclaration.addDiagnostic(new TypeScript.SemanticDiagnostic(this.semanticInfo.getPath(), typeParameterAST.minChar, typeParameterAST.getLength(), 69 /* Duplicate_identifier__0_ */, [typeParameter.getName()])); - } - - for (var j = 0; j < typeParameterDecls.length; j++) { - if (typeParameterDecls[j].getDeclID() < this.startingDeclForRebind) { - typeParameter.removeDeclaration(typeParameterDecls[j]); - } - } - } - - typeParameter.addDeclaration(typeParameters[i]); - typeParameters[i].setSymbol(typeParameter); - } - - functionTypeSymbol.addCallSignature(signature); - - if (!isSignature) { - } - - functionSymbol.setIsBound(this.bindingPhase); - - var otherDecls = this.findDeclsInContext(functionDeclaration, functionDeclaration.getKind(), false); - - if (otherDecls && otherDecls.length) { - for (var i = 0; i < otherDecls.length; i++) { - otherDecls[i].ensureSymbolIsBound(); - } - } - }; - - PullSymbolBinder.prototype.bindFunctionExpressionToPullSymbol = function (functionExpressionDeclaration) { - var declKind = functionExpressionDeclaration.getKind(); - var declFlags = functionExpressionDeclaration.getFlags(); - var funcExpAST = this.semanticInfo.getASTForDecl(functionExpressionDeclaration); - - var functionName = declKind == 131072 /* FunctionExpression */ ? (functionExpressionDeclaration).getFunctionExpressionName() : functionExpressionDeclaration.getName(); - var functionSymbol = new TypeScript.PullSymbol(functionName, 16384 /* Function */); - var functionTypeSymbol = new TypeScript.PullFunctionTypeSymbol(); - - functionSymbol.setType(functionTypeSymbol); - - functionExpressionDeclaration.setSymbol(functionSymbol); - functionSymbol.addDeclaration(functionExpressionDeclaration); - functionTypeSymbol.addDeclaration(functionExpressionDeclaration); - - if (funcExpAST.name) { - this.semanticInfo.setSymbolAndDiagnosticsForAST(funcExpAST.name, TypeScript.SymbolAndDiagnostics.fromSymbol(functionSymbol)); - } - this.semanticInfo.setSymbolAndDiagnosticsForAST(funcExpAST, TypeScript.SymbolAndDiagnostics.fromSymbol(functionSymbol)); - - var signature = new TypeScript.PullDefinitionSignatureSymbol(1048576 /* CallSignature */); - - if (funcExpAST.variableArgList) { - signature.setHasVariableParamList(); - } - - var typeParameters = functionExpressionDeclaration.getTypeParameters(); - var typeParameter; - var typeParameterDecls = null; - - for (var i = 0; i < typeParameters.length; i++) { - typeParameter = signature.findTypeParameter(typeParameters[i].getName()); - - if (!typeParameter) { - typeParameter = new TypeScript.PullTypeParameterSymbol(typeParameters[i].getName(), true); - - signature.addTypeParameter(typeParameter); - } else { - typeParameterDecls = typeParameter.getDeclarations(); - - if (this.symbolIsRedeclaration(typeParameter)) { - var typeParameterAST = this.semanticInfoChain.getASTForDecl(typeParameterDecls[0]); - functionExpressionDeclaration.addDiagnostic(new TypeScript.SemanticDiagnostic(this.semanticInfo.getPath(), typeParameterAST.minChar, typeParameterAST.getLength(), 69 /* Duplicate_identifier__0_ */, [typeParameter.getName()])); - } - - typeParameterDecls = typeParameter.getDeclarations(); - - for (var j = 0; j < typeParameterDecls.length; j++) { - if (typeParameterDecls[j].getDeclID() < this.startingDeclForRebind) { - typeParameter.removeDeclaration(typeParameterDecls[j]); - } - } - } - - typeParameter.addDeclaration(typeParameters[i]); - typeParameters[i].setSymbol(typeParameter); - } - - signature.addDeclaration(functionExpressionDeclaration); - functionExpressionDeclaration.setSignatureSymbol(signature); - - this.bindParameterSymbols(this.semanticInfo.getASTForDecl(functionExpressionDeclaration), functionTypeSymbol, signature); - - functionTypeSymbol.addSignature(signature); - }; - - PullSymbolBinder.prototype.bindFunctionTypeDeclarationToPullSymbol = function (functionTypeDeclaration) { - var declKind = functionTypeDeclaration.getKind(); - var declFlags = functionTypeDeclaration.getFlags(); - var funcTypeAST = this.semanticInfo.getASTForDecl(functionTypeDeclaration); - - var functionTypeSymbol = new TypeScript.PullFunctionTypeSymbol(); - - functionTypeDeclaration.setSymbol(functionTypeSymbol); - functionTypeSymbol.addDeclaration(functionTypeDeclaration); - this.semanticInfo.setSymbolAndDiagnosticsForAST(funcTypeAST, TypeScript.SymbolAndDiagnostics.fromSymbol(functionTypeSymbol)); - - var isSignature = (declFlags & 2048 /* Signature */) !== 0; - var signature = isSignature ? new TypeScript.PullSignatureSymbol(1048576 /* CallSignature */) : new TypeScript.PullDefinitionSignatureSymbol(1048576 /* CallSignature */); - - if (funcTypeAST.variableArgList) { - signature.setHasVariableParamList(); - } - - var typeParameters = functionTypeDeclaration.getTypeParameters(); - var typeParameter; - var typeParameterDecls = null; - - for (var i = 0; i < typeParameters.length; i++) { - typeParameter = signature.findTypeParameter(typeParameters[i].getName()); - - if (!typeParameter) { - typeParameter = new TypeScript.PullTypeParameterSymbol(typeParameters[i].getName(), true); - - signature.addTypeParameter(typeParameter); - } else { - typeParameterDecls = typeParameter.getDeclarations(); - - if (this.symbolIsRedeclaration(typeParameter)) { - var typeParameterAST = this.semanticInfoChain.getASTForDecl(typeParameterDecls[0]); - functionTypeDeclaration.addDiagnostic(new TypeScript.SemanticDiagnostic(this.semanticInfo.getPath(), typeParameterAST.minChar, typeParameterAST.getLength(), 69 /* Duplicate_identifier__0_ */, [typeParameter.getName()])); - } - - typeParameterDecls = typeParameter.getDeclarations(); - - for (var j = 0; j < typeParameterDecls.length; j++) { - if (typeParameterDecls[j].getDeclID() < this.startingDeclForRebind) { - typeParameter.removeDeclaration(typeParameterDecls[j]); - } - } - } - - typeParameter.addDeclaration(typeParameters[i]); - typeParameters[i].setSymbol(typeParameter); - } - - signature.addDeclaration(functionTypeDeclaration); - functionTypeDeclaration.setSignatureSymbol(signature); - - this.bindParameterSymbols(this.semanticInfo.getASTForDecl(functionTypeDeclaration), functionTypeSymbol, signature); - - functionTypeSymbol.addSignature(signature); - }; - - PullSymbolBinder.prototype.bindMethodDeclarationToPullSymbol = function (methodDeclaration) { - var declKind = methodDeclaration.getKind(); - var declFlags = methodDeclaration.getFlags(); - var methodAST = this.semanticInfo.getASTForDecl(methodDeclaration); - - var isPrivate = (declFlags & 2 /* Private */) !== 0; - var isStatic = (declFlags & 16 /* Static */) !== 0; - var isOptional = (declFlags & 128 /* Optional */) !== 0; - - var methodName = methodDeclaration.getName(); - - var isSignature = (declFlags & 2048 /* Signature */) !== 0; - - var parent = this.getParent(methodDeclaration, true); - var parentHadSymbol = false; - - var cleanedPreviousDecls = false; - - var methodSymbol = null; - var methodTypeSymbol = null; - - var linkKind = isPrivate ? 6 /* PrivateMember */ : 5 /* PublicMember */; - - if (parent.isClass() && isStatic) { - parent = (parent).getConstructorMethod().getType(); - } - - methodSymbol = parent.findMember(methodName, false); - - if (methodSymbol && (methodSymbol.getKind() !== 65536 /* Method */ || (this.symbolIsRedeclaration(methodSymbol) && !isSignature && !methodSymbol.allDeclsHaveFlag(2048 /* Signature */)))) { - methodDeclaration.addDiagnostic(new TypeScript.SemanticDiagnostic(this.semanticInfo.getPath(), methodAST.minChar, methodAST.getLength(), 69 /* Duplicate_identifier__0_ */, [methodDeclaration.getDisplayName()])); - methodSymbol = null; - } - - if (methodSymbol) { - methodTypeSymbol = methodSymbol.getType(); - parentHadSymbol = true; - } - - if (this.reBindingAfterChange && methodSymbol) { - var decls = methodSymbol.getDeclarations(); - var scriptName = methodDeclaration.getScriptName(); - var isGeneric = methodTypeSymbol.isGeneric(); - - for (var j = 0; j < decls.length; j++) { - if (decls[j].getScriptName() === scriptName && decls[j].getDeclID() < this.startingDeclForRebind) { - methodSymbol.removeDeclaration(decls[j]); - - cleanedPreviousDecls = true; - } - } - - decls = methodTypeSymbol.getDeclarations(); - for (var j = 0; j < decls.length; j++) { - if (decls[j].getScriptName() === scriptName && decls[j].getDeclID() < this.startingDeclForRebind) { - methodTypeSymbol.removeDeclaration(decls[j]); - - cleanedPreviousDecls = true; - } - } - - if (isGeneric) { - var specializations = methodTypeSymbol.getKnownSpecializations(); - - for (var i = 0; i < specializations.length; i++) { - specializations[i].invalidate(); - } - } - - methodSymbol.invalidate(); - methodTypeSymbol.invalidate(); - } - - if (!methodSymbol) { - methodSymbol = new TypeScript.PullSymbol(methodName, 65536 /* Method */); - } - - if (!methodTypeSymbol) { - methodTypeSymbol = new TypeScript.PullFunctionTypeSymbol(); - methodSymbol.setType(methodTypeSymbol); - } - - methodDeclaration.setSymbol(methodSymbol); - methodSymbol.addDeclaration(methodDeclaration); - methodTypeSymbol.addDeclaration(methodDeclaration); - this.semanticInfo.setSymbolAndDiagnosticsForAST(methodAST.name, TypeScript.SymbolAndDiagnostics.fromSymbol(methodSymbol)); - this.semanticInfo.setSymbolAndDiagnosticsForAST(methodAST, TypeScript.SymbolAndDiagnostics.fromSymbol(methodSymbol)); - - if (isOptional) { - methodSymbol.setIsOptional(); - } - - if (!parentHadSymbol) { - parent.addMember(methodSymbol, linkKind); - } - - if (parentHadSymbol && cleanedPreviousDecls) { - var callSigs = methodTypeSymbol.getCallSignatures(); - var constructSigs = methodTypeSymbol.getConstructSignatures(); - var indexSigs = methodTypeSymbol.getIndexSignatures(); - - for (var i = 0; i < callSigs.length; i++) { - methodTypeSymbol.removeCallSignature(callSigs[i], false); - } - for (var i = 0; i < constructSigs.length; i++) { - methodTypeSymbol.removeConstructSignature(constructSigs[i], false); - } - for (var i = 0; i < indexSigs.length; i++) { - methodTypeSymbol.removeIndexSignature(indexSigs[i], false); - } - - methodSymbol.invalidate(); - methodTypeSymbol.invalidate(); - methodTypeSymbol.recomputeCallSignatures(); - methodTypeSymbol.recomputeConstructSignatures(); - methodTypeSymbol.recomputeIndexSignatures(); - - if (isGeneric) { - var specializations = methodTypeSymbol.getKnownSpecializations(); - - for (var j = 0; j < specializations.length; j++) { - callSigs = specializations[j].getCallSignatures(); - - for (var i = 0; i < callSigs.length; i++) { - callSigs[i].invalidate(); - } - } - } - } - - var sigKind = 1048576 /* CallSignature */; - - var signature = isSignature ? new TypeScript.PullSignatureSymbol(sigKind) : new TypeScript.PullDefinitionSignatureSymbol(sigKind); - - if (methodAST.variableArgList) { - signature.setHasVariableParamList(); - } - - var typeParameters = methodDeclaration.getTypeParameters(); - var typeParameter; - var typeParameterDecls = null; - var typeParameterName; - var typeParameterAST; - - for (var i = 0; i < typeParameters.length; i++) { - typeParameterName = typeParameters[i].getName(); - typeParameterAST = this.semanticInfo.getASTForDecl(typeParameters[i]); - - typeParameter = signature.findTypeParameter(typeParameterName); - - if (!typeParameter) { - if (!typeParameterAST.constraint) { - typeParameter = this.findTypeParameterInCache(typeParameterName); - } - - if (!typeParameter) { - typeParameter = new TypeScript.PullTypeParameterSymbol(typeParameterName, true); - - if (!typeParameterAST.constraint) { - this.addTypeParameterToCache(typeParameter); - } - } - - signature.addTypeParameter(typeParameter); - } else { - typeParameterDecls = typeParameter.getDeclarations(); - - if (this.symbolIsRedeclaration(typeParameter)) { - typeParameterAST = this.semanticInfoChain.getASTForDecl(typeParameterDecls[0]); - methodDeclaration.addDiagnostic(new TypeScript.SemanticDiagnostic(this.semanticInfo.getPath(), typeParameterAST.minChar, typeParameterAST.getLength(), 69 /* Duplicate_identifier__0_ */, [typeParameter.getName()])); - } - - typeParameterDecls = typeParameter.getDeclarations(); - - for (var j = 0; j < typeParameterDecls.length; j++) { - if (typeParameterDecls[j].getDeclID() < this.startingDeclForRebind) { - typeParameter.removeDeclaration(typeParameterDecls[j]); - } - } - } - - typeParameter.addDeclaration(typeParameters[i]); - typeParameters[i].setSymbol(typeParameter); - } - - signature.addDeclaration(methodDeclaration); - methodDeclaration.setSignatureSymbol(signature); - - this.bindParameterSymbols(this.semanticInfo.getASTForDecl(methodDeclaration), methodTypeSymbol, signature); - - methodTypeSymbol.addSignature(signature); - - if (!isSignature) { - } - - var otherDecls = this.findDeclsInContext(methodDeclaration, methodDeclaration.getKind(), false); - - if (otherDecls && otherDecls.length) { - for (var i = 0; i < otherDecls.length; i++) { - otherDecls[i].ensureSymbolIsBound(); - } - } - }; - - PullSymbolBinder.prototype.bindConstructorDeclarationToPullSymbol = function (constructorDeclaration) { - var declKind = constructorDeclaration.getKind(); - var declFlags = constructorDeclaration.getFlags(); - var constructorAST = this.semanticInfo.getASTForDecl(constructorDeclaration); - - var constructorName = constructorDeclaration.getName(); - - var isSignature = (declFlags & 2048 /* Signature */) !== 0; - - var parent = this.getParent(constructorDeclaration, true); - - var parentHadSymbol = false; - var cleanedPreviousDecls = false; - - var constructorSymbol = parent.getConstructorMethod(); - var constructorTypeSymbol = null; - - var linkKind = 7 /* ConstructorMethod */; - - if (constructorSymbol && (constructorSymbol.getKind() !== 32768 /* ConstructorMethod */ || (!isSignature && constructorSymbol.getType() && constructorSymbol.getType().hasOwnConstructSignatures() && (constructorSymbol.getType()).getDefinitionSignature() && !constructorSymbol.allDeclsHaveFlag(2048 /* Signature */)))) { - constructorDeclaration.addDiagnostic(new TypeScript.SemanticDiagnostic(this.semanticInfo.getPath(), constructorAST.minChar, constructorAST.getLength(), 139 /* Multiple_constructor_implementations_are_not_allowed */, null)); - - constructorSymbol = null; - } - - if (constructorSymbol) { - constructorTypeSymbol = constructorSymbol.getType(); - - if (this.reBindingAfterChange) { - var decls = constructorSymbol.getDeclarations(); - var scriptName = constructorDeclaration.getScriptName(); - var isGeneric = constructorTypeSymbol.isGeneric(); - - for (var j = 0; j < decls.length; j++) { - if (decls[j].getScriptName() === scriptName && decls[j].getDeclID() < this.startingDeclForRebind) { - constructorSymbol.removeDeclaration(decls[j]); - - cleanedPreviousDecls = true; - } - } - - decls = constructorTypeSymbol.getDeclarations(); - - for (var j = 0; j < decls.length; j++) { - if (decls[j].getScriptName() === scriptName && decls[j].getDeclID() < this.startingDeclForRebind) { - constructorTypeSymbol.removeDeclaration(decls[j]); - - cleanedPreviousDecls = true; - } - } - - if (isGeneric) { - var specializations = constructorTypeSymbol.getKnownSpecializations(); - - for (var i = 0; i < specializations.length; i++) { - specializations[i].invalidate(); - } - } - - constructorSymbol.invalidate(); - constructorTypeSymbol.invalidate(); - } - } - - if (!constructorSymbol) { - constructorSymbol = new TypeScript.PullSymbol(constructorName, 32768 /* ConstructorMethod */); - constructorTypeSymbol = new TypeScript.PullConstructorTypeSymbol(); - } - - parent.setConstructorMethod(constructorSymbol); - constructorSymbol.setType(constructorTypeSymbol); - - constructorDeclaration.setSymbol(constructorSymbol); - constructorSymbol.addDeclaration(constructorDeclaration); - constructorTypeSymbol.addDeclaration(constructorDeclaration); - this.semanticInfo.setSymbolAndDiagnosticsForAST(constructorAST, TypeScript.SymbolAndDiagnostics.fromSymbol(constructorSymbol)); - - if (parentHadSymbol && cleanedPreviousDecls) { - var constructSigs = constructorTypeSymbol.getConstructSignatures(); - - for (var i = 0; i < constructSigs.length; i++) { - constructorTypeSymbol.removeConstructSignature(constructSigs[i]); - } - - constructorSymbol.invalidate(); - constructorTypeSymbol.invalidate(); - constructorTypeSymbol.recomputeConstructSignatures(); - - if (isGeneric) { - var specializations = constructorTypeSymbol.getKnownSpecializations(); - - for (var j = 0; j < specializations.length; j++) { - constructSigs = specializations[j].getConstructSignatures(); - - for (var i = 0; i < constructSigs.length; i++) { - constructSigs[i].invalidate(); - } - } - } - } - - var constructSignature = isSignature ? new TypeScript.PullSignatureSymbol(2097152 /* ConstructSignature */) : new TypeScript.PullDefinitionSignatureSymbol(2097152 /* ConstructSignature */); - - constructSignature.setReturnType(parent); - - constructSignature.addDeclaration(constructorDeclaration); - constructorDeclaration.setSignatureSymbol(constructSignature); - - this.bindParameterSymbols(constructorAST, constructorTypeSymbol, constructSignature); - - var typeParameters = constructorTypeSymbol.getTypeParameters(); - - for (var i = 0; i < typeParameters.length; i++) { - constructSignature.addTypeParameter(typeParameters[i]); - } - - if (constructorAST.variableArgList) { - constructSignature.setHasVariableParamList(); - } - - constructorTypeSymbol.addSignature(constructSignature); - - if (!isSignature) { - } - - var otherDecls = this.findDeclsInContext(constructorDeclaration, constructorDeclaration.getKind(), false); - - if (otherDecls && otherDecls.length) { - for (var i = 0; i < otherDecls.length; i++) { - otherDecls[i].ensureSymbolIsBound(); - } - } - }; - - PullSymbolBinder.prototype.bindConstructSignatureDeclarationToPullSymbol = function (constructSignatureDeclaration) { - var parent = this.getParent(constructSignatureDeclaration, true); - var constructorAST = this.semanticInfo.getASTForDecl(constructSignatureDeclaration); - - var constructSigs = parent.getConstructSignatures(); - - for (var i = 0; i < constructSigs.length; i++) { - if (constructSigs[i].getSymbolID() < this.startingSymbolForRebind) { - parent.removeConstructSignature(constructSigs[i], false); - } - } - - parent.recomputeConstructSignatures(); - var constructSignature = new TypeScript.PullSignatureSymbol(2097152 /* ConstructSignature */); - - if (constructorAST.variableArgList) { - constructSignature.setHasVariableParamList(); - } - - var typeParameters = constructSignatureDeclaration.getTypeParameters(); - var typeParameter; - var typeParameterDecls = null; - - for (var i = 0; i < typeParameters.length; i++) { - typeParameter = constructSignature.findTypeParameter(typeParameters[i].getName()); - - if (!typeParameter) { - typeParameter = new TypeScript.PullTypeParameterSymbol(typeParameters[i].getName(), true); - - constructSignature.addTypeParameter(typeParameter); - } else { - typeParameterDecls = typeParameter.getDeclarations(); - - if (this.symbolIsRedeclaration(typeParameter)) { - var typeParameterAST = this.semanticInfoChain.getASTForDecl(typeParameterDecls[0]); - constructSignatureDeclaration.addDiagnostic(new TypeScript.SemanticDiagnostic(this.semanticInfo.getPath(), typeParameterAST.minChar, typeParameterAST.getLength(), 69 /* Duplicate_identifier__0_ */, [typeParameter.getName()])); - } - - for (var j = 0; j < typeParameterDecls.length; j++) { - if (typeParameterDecls[j].getDeclID() < this.startingDeclForRebind) { - typeParameter.removeDeclaration(typeParameterDecls[j]); - } - } - } - - typeParameter.addDeclaration(typeParameters[i]); - typeParameters[i].setSymbol(typeParameter); - } - - constructSignature.addDeclaration(constructSignatureDeclaration); - constructSignatureDeclaration.setSignatureSymbol(constructSignature); - - this.bindParameterSymbols(this.semanticInfo.getASTForDecl(constructSignatureDeclaration), null, constructSignature); - - this.semanticInfo.setSymbolAndDiagnosticsForAST(this.semanticInfo.getASTForDecl(constructSignatureDeclaration), TypeScript.SymbolAndDiagnostics.fromSymbol(constructSignature)); - - parent.addConstructSignature(constructSignature); - }; - - PullSymbolBinder.prototype.bindCallSignatureDeclarationToPullSymbol = function (callSignatureDeclaration) { - var parent = this.getParent(callSignatureDeclaration, true); - var callSignatureAST = this.semanticInfo.getASTForDecl(callSignatureDeclaration); - - var callSigs = parent.getCallSignatures(); - - for (var i = 0; i < callSigs.length; i++) { - if (callSigs[i].getSymbolID() < this.startingSymbolForRebind) { - parent.removeCallSignature(callSigs[i], false); - } - } - - parent.recomputeCallSignatures(); - - var callSignature = new TypeScript.PullSignatureSymbol(1048576 /* CallSignature */); - - if (callSignatureAST.variableArgList) { - callSignature.setHasVariableParamList(); - } - - var typeParameters = callSignatureDeclaration.getTypeParameters(); - var typeParameter; - var typeParameterDecls = null; - - for (var i = 0; i < typeParameters.length; i++) { - typeParameter = callSignature.findTypeParameter(typeParameters[i].getName()); - - if (!typeParameter) { - typeParameter = new TypeScript.PullTypeParameterSymbol(typeParameters[i].getName(), true); - - callSignature.addTypeParameter(typeParameter); - } else { - typeParameterDecls = typeParameter.getDeclarations(); - - if (this.symbolIsRedeclaration(typeParameter)) { - var typeParameterAST = this.semanticInfoChain.getASTForDecl(typeParameterDecls[0]); - callSignatureDeclaration.addDiagnostic(new TypeScript.SemanticDiagnostic(this.semanticInfo.getPath(), typeParameterAST.minChar, typeParameterAST.getLength(), 69 /* Duplicate_identifier__0_ */, [typeParameter.getName()])); - } - - for (var j = 0; j < typeParameterDecls.length; j++) { - if (typeParameterDecls[j].getDeclID() < this.startingDeclForRebind) { - typeParameter.removeDeclaration(typeParameterDecls[j]); - } - } - } - - typeParameter.addDeclaration(typeParameters[i]); - typeParameters[i].setSymbol(typeParameter); - } - - callSignature.addDeclaration(callSignatureDeclaration); - callSignatureDeclaration.setSignatureSymbol(callSignature); - - this.bindParameterSymbols(this.semanticInfo.getASTForDecl(callSignatureDeclaration), null, callSignature); - - this.semanticInfo.setSymbolAndDiagnosticsForAST(this.semanticInfo.getASTForDecl(callSignatureDeclaration), TypeScript.SymbolAndDiagnostics.fromSymbol(callSignature)); - - parent.addCallSignature(callSignature); - }; - - PullSymbolBinder.prototype.bindIndexSignatureDeclarationToPullSymbol = function (indexSignatureDeclaration) { - var parent = this.getParent(indexSignatureDeclaration, true); - - var indexSigs = parent.getIndexSignatures(); - - for (var i = 0; i < indexSigs.length; i++) { - if (indexSigs[i].getSymbolID() < this.startingSymbolForRebind) { - parent.removeIndexSignature(indexSigs[i], false); - } - } - - parent.recomputeIndexSignatures(); - - var indexSignature = new TypeScript.PullSignatureSymbol(4194304 /* IndexSignature */); - - var typeParameters = indexSignatureDeclaration.getTypeParameters(); - var typeParameter; - var typeParameterDecls = null; - - for (var i = 0; i < typeParameters.length; i++) { - typeParameter = indexSignature.findTypeParameter(typeParameters[i].getName()); - - if (!typeParameter) { - typeParameter = new TypeScript.PullTypeParameterSymbol(typeParameters[i].getName(), true); - - indexSignature.addTypeParameter(typeParameter); - } else { - typeParameterDecls = typeParameter.getDeclarations(); - - if (this.symbolIsRedeclaration(typeParameter)) { - var typeParameterAST = this.semanticInfoChain.getASTForDecl(typeParameterDecls[0]); - indexSignatureDeclaration.addDiagnostic(new TypeScript.SemanticDiagnostic(this.semanticInfo.getPath(), typeParameterAST.minChar, typeParameterAST.getLength(), 69 /* Duplicate_identifier__0_ */, [typeParameter.getName()])); - } - - typeParameterDecls = typeParameter.getDeclarations(); - - for (var j = 0; j < typeParameterDecls.length; j++) { - if (typeParameterDecls[j].getDeclID() < this.startingDeclForRebind) { - typeParameter.removeDeclaration(typeParameterDecls[j]); - } - } - } - - typeParameter.addDeclaration(typeParameters[i]); - typeParameters[i].setSymbol(typeParameter); - } - - indexSignature.addDeclaration(indexSignatureDeclaration); - indexSignatureDeclaration.setSignatureSymbol(indexSignature); - - this.bindParameterSymbols(this.semanticInfo.getASTForDecl(indexSignatureDeclaration), null, indexSignature); - - this.semanticInfo.setSymbolAndDiagnosticsForAST(this.semanticInfo.getASTForDecl(indexSignatureDeclaration), TypeScript.SymbolAndDiagnostics.fromSymbol(indexSignature)); - - parent.addIndexSignature(indexSignature); - }; - - PullSymbolBinder.prototype.bindGetAccessorDeclarationToPullSymbol = function (getAccessorDeclaration) { - var declKind = getAccessorDeclaration.getKind(); - var declFlags = getAccessorDeclaration.getFlags(); - var funcDeclAST = this.semanticInfo.getASTForDecl(getAccessorDeclaration); - - var isExported = (declFlags & 1 /* Exported */) !== 0; - - var funcName = getAccessorDeclaration.getName(); - - var isSignature = (declFlags & 2048 /* Signature */) !== 0; - var isStatic = false; - var linkKind = 5 /* PublicMember */; - - if (TypeScript.hasFlag(declFlags, 16 /* Static */)) { - isStatic = true; - } - - if (TypeScript.hasFlag(declFlags, 2 /* Private */)) { - linkKind = 6 /* PrivateMember */; - } - - var parent = this.getParent(getAccessorDeclaration, true); - var parentHadSymbol = false; - var cleanedPreviousDecls = false; - - var accessorSymbol = null; - var getterSymbol = null; - var getterTypeSymbol = null; - - if (isStatic) { - parent = (parent).getConstructorMethod().getType(); - } - - accessorSymbol = parent.findMember(funcName, false); - - if (accessorSymbol) { - if (!accessorSymbol.isAccessor()) { - getAccessorDeclaration.addDiagnostic(new TypeScript.SemanticDiagnostic(this.semanticInfo.getPath(), funcDeclAST.minChar, funcDeclAST.getLength(), 69 /* Duplicate_identifier__0_ */, [getAccessorDeclaration.getDisplayName()])); - accessorSymbol = null; - } else { - getterSymbol = accessorSymbol.getGetter(); - - if (getterSymbol && (!this.reBindingAfterChange || this.symbolIsRedeclaration(getterSymbol))) { - getAccessorDeclaration.addDiagnostic(new TypeScript.SemanticDiagnostic(this.semanticInfo.getPath(), funcDeclAST.minChar, funcDeclAST.getLength(), 84 /* Getter__0__already_declared */, [getAccessorDeclaration.getDisplayName()])); - accessorSymbol = null; - getterSymbol = null; - } - } - } - - if (accessorSymbol) { - parentHadSymbol = true; - } - - if (accessorSymbol && getterSymbol) { - getterTypeSymbol = getterSymbol.getType(); - } - - if (this.reBindingAfterChange && accessorSymbol) { - var decls = accessorSymbol.getDeclarations(); - var scriptName = getAccessorDeclaration.getScriptName(); - - for (var j = 0; j < decls.length; j++) { - if (decls[j].getScriptName() === scriptName && decls[j].getDeclID() < this.startingDeclForRebind) { - accessorSymbol.removeDeclaration(decls[j]); - - cleanedPreviousDecls = true; - } - } - - if (getterSymbol) { - decls = getterSymbol.getDeclarations(); - - for (var j = 0; j < decls.length; j++) { - if (decls[j].getScriptName() === scriptName && decls[j].getDeclID() < this.startingDeclForRebind) { - getterSymbol.removeDeclaration(decls[j]); - - cleanedPreviousDecls = true; - } - } - } - - accessorSymbol.invalidate(); - } - - if (!accessorSymbol) { - accessorSymbol = new TypeScript.PullAccessorSymbol(funcName); - } - - if (!getterSymbol) { - getterSymbol = new TypeScript.PullSymbol(funcName, 16384 /* Function */); - getterTypeSymbol = new TypeScript.PullFunctionTypeSymbol(); - - getterSymbol.setType(getterTypeSymbol); - - accessorSymbol.setGetter(getterSymbol); - } - - getAccessorDeclaration.setSymbol(accessorSymbol); - accessorSymbol.addDeclaration(getAccessorDeclaration); - getterSymbol.addDeclaration(getAccessorDeclaration); - - this.semanticInfo.setSymbolAndDiagnosticsForAST(funcDeclAST.name, TypeScript.SymbolAndDiagnostics.fromSymbol(getterSymbol)); - this.semanticInfo.setSymbolAndDiagnosticsForAST(funcDeclAST, TypeScript.SymbolAndDiagnostics.fromSymbol(getterSymbol)); - - if (!parentHadSymbol) { - parent.addMember(accessorSymbol, linkKind); - } - - if (parentHadSymbol && cleanedPreviousDecls) { - var callSigs = getterTypeSymbol.getCallSignatures(); - - for (var i = 0; i < callSigs.length; i++) { - getterTypeSymbol.removeCallSignature(callSigs[i], false); - } - - getterSymbol.invalidate(); - getterTypeSymbol.invalidate(); - getterTypeSymbol.recomputeCallSignatures(); - } - - var signature = isSignature ? new TypeScript.PullSignatureSymbol(1048576 /* CallSignature */) : new TypeScript.PullDefinitionSignatureSymbol(1048576 /* CallSignature */); - - signature.addDeclaration(getAccessorDeclaration); - getAccessorDeclaration.setSignatureSymbol(signature); - - this.bindParameterSymbols(this.semanticInfo.getASTForDecl(getAccessorDeclaration), getterTypeSymbol, signature); - - var typeParameters = getAccessorDeclaration.getTypeParameters(); - - if (typeParameters.length) { - getAccessorDeclaration.addDiagnostic(new TypeScript.SemanticDiagnostic(this.semanticInfo.getPath(), funcDeclAST.minChar, funcDeclAST.getLength(), 86 /* Accessor_cannot_have_type_parameters */, null)); - } - - getterTypeSymbol.addSignature(signature); - - if (!isSignature) { - } - - getterSymbol.setIsBound(this.bindingPhase); - }; - - PullSymbolBinder.prototype.bindSetAccessorDeclarationToPullSymbol = function (setAccessorDeclaration) { - var declKind = setAccessorDeclaration.getKind(); - var declFlags = setAccessorDeclaration.getFlags(); - var funcDeclAST = this.semanticInfo.getASTForDecl(setAccessorDeclaration); - - var isExported = (declFlags & 1 /* Exported */) !== 0; - - var funcName = setAccessorDeclaration.getName(); - - var isSignature = (declFlags & 2048 /* Signature */) !== 0; - var isStatic = false; - var linkKind = 5 /* PublicMember */; - - if (TypeScript.hasFlag(declFlags, 16 /* Static */)) { - isStatic = true; - } - - if (TypeScript.hasFlag(declFlags, 2 /* Private */)) { - linkKind = 6 /* PrivateMember */; - } - - var parent = this.getParent(setAccessorDeclaration, true); - var parentHadSymbol = false; - var cleanedPreviousDecls = false; - - var accessorSymbol = null; - var setterSymbol = null; - var setterTypeSymbol = null; - - if (isStatic) { - parent = (parent).getConstructorMethod().getType(); - } - - accessorSymbol = parent.findMember(funcName, false); - - if (accessorSymbol) { - if (!accessorSymbol.isAccessor()) { - setAccessorDeclaration.addDiagnostic(new TypeScript.SemanticDiagnostic(this.semanticInfo.getPath(), funcDeclAST.minChar, funcDeclAST.getLength(), 69 /* Duplicate_identifier__0_ */, [setAccessorDeclaration.getDisplayName()])); - accessorSymbol = null; - } else { - setterSymbol = accessorSymbol.getSetter(); - - if (setterSymbol && (!this.reBindingAfterChange || this.symbolIsRedeclaration(setterSymbol))) { - setAccessorDeclaration.addDiagnostic(new TypeScript.SemanticDiagnostic(this.semanticInfo.getPath(), funcDeclAST.minChar, funcDeclAST.getLength(), 85 /* Setter__0__already_declared */, [setAccessorDeclaration.getDisplayName()])); - accessorSymbol = null; - setterSymbol = null; - } - } - } - - if (accessorSymbol) { - parentHadSymbol = true; - } - - if (accessorSymbol && setterSymbol) { - setterTypeSymbol = setterSymbol.getType(); - } - - if (this.reBindingAfterChange && accessorSymbol) { - var decls = accessorSymbol.getDeclarations(); - var scriptName = setAccessorDeclaration.getScriptName(); - - for (var j = 0; j < decls.length; j++) { - if (decls[j].getScriptName() === scriptName && decls[j].getDeclID() < this.startingDeclForRebind) { - accessorSymbol.removeDeclaration(decls[j]); - - cleanedPreviousDecls = true; - } - } - - if (setterSymbol) { - decls = setterSymbol.getDeclarations(); - - for (var j = 0; j < decls.length; j++) { - if (decls[j].getScriptName() === scriptName && decls[j].getDeclID() < this.startingDeclForRebind) { - setterSymbol.removeDeclaration(decls[j]); - - cleanedPreviousDecls = true; - } - } - } - - accessorSymbol.invalidate(); - } - - if (!accessorSymbol) { - accessorSymbol = new TypeScript.PullAccessorSymbol(funcName); - } - - if (!setterSymbol) { - setterSymbol = new TypeScript.PullSymbol(funcName, 16384 /* Function */); - setterTypeSymbol = new TypeScript.PullFunctionTypeSymbol(); - - setterSymbol.setType(setterTypeSymbol); - - accessorSymbol.setSetter(setterSymbol); - } - - setAccessorDeclaration.setSymbol(accessorSymbol); - accessorSymbol.addDeclaration(setAccessorDeclaration); - setterSymbol.addDeclaration(setAccessorDeclaration); - - this.semanticInfo.setSymbolAndDiagnosticsForAST(funcDeclAST.name, TypeScript.SymbolAndDiagnostics.fromSymbol(setterSymbol)); - this.semanticInfo.setSymbolAndDiagnosticsForAST(funcDeclAST, TypeScript.SymbolAndDiagnostics.fromSymbol(setterSymbol)); - - if (!parentHadSymbol) { - parent.addMember(accessorSymbol, linkKind); - } - - if (parentHadSymbol && cleanedPreviousDecls) { - var callSigs = setterTypeSymbol.getCallSignatures(); - - for (var i = 0; i < callSigs.length; i++) { - setterTypeSymbol.removeCallSignature(callSigs[i], false); - } - - setterSymbol.invalidate(); - setterTypeSymbol.invalidate(); - setterTypeSymbol.recomputeCallSignatures(); - } - - var signature = isSignature ? new TypeScript.PullSignatureSymbol(1048576 /* CallSignature */) : new TypeScript.PullDefinitionSignatureSymbol(1048576 /* CallSignature */); - - signature.addDeclaration(setAccessorDeclaration); - setAccessorDeclaration.setSignatureSymbol(signature); - - this.bindParameterSymbols(this.semanticInfo.getASTForDecl(setAccessorDeclaration), setterTypeSymbol, signature); - - var typeParameters = setAccessorDeclaration.getTypeParameters(); - - if (typeParameters.length) { - setAccessorDeclaration.addDiagnostic(new TypeScript.SemanticDiagnostic(this.semanticInfo.getPath(), funcDeclAST.minChar, funcDeclAST.getLength(), 86 /* Accessor_cannot_have_type_parameters */, null)); - } - - setterTypeSymbol.addSignature(signature); - - if (!isSignature) { - } - - setterSymbol.setIsBound(this.bindingPhase); - }; - - PullSymbolBinder.prototype.bindCatchBlockPullSymbols = function (catchBlockDecl) { - }; - - PullSymbolBinder.prototype.bindWithBlockPullSymbols = function (withBlockDecl) { - }; - - PullSymbolBinder.prototype.bindDeclToPullSymbol = function (decl, rebind) { - if (typeof rebind === "undefined") { rebind = false; } - if (rebind) { - this.startingDeclForRebind = TypeScript.lastBoundPullDeclId; - this.startingSymbolForRebind = TypeScript.lastBoundPullSymbolID; - this.reBindingAfterChange = true; - } - - if (decl.isBound()) { - return; - } - - decl.setIsBound(true); - - switch (decl.getKind()) { - case 1 /* Script */: - var childDecls = decl.getChildDecls(); - for (var i = 0; i < childDecls.length; i++) { - this.bindDeclToPullSymbol(childDecls[i]); - } - break; - - case 64 /* Enum */: - case 32 /* DynamicModule */: - case 4 /* Container */: - this.bindModuleDeclarationToPullSymbol(decl); - break; - - case 16 /* Interface */: - this.bindInterfaceDeclarationToPullSymbol(decl); - break; - - case 8 /* Class */: - this.bindClassDeclarationToPullSymbol(decl); - break; - - case 16384 /* Function */: - this.bindFunctionDeclarationToPullSymbol(decl); - break; - - case 1024 /* Variable */: - this.bindVariableDeclarationToPullSymbol(decl); - break; - - case 67108864 /* EnumMember */: - case 4096 /* Property */: - this.bindPropertyDeclarationToPullSymbol(decl); - break; - - case 65536 /* Method */: - this.bindMethodDeclarationToPullSymbol(decl); - break; - - case 32768 /* ConstructorMethod */: - this.bindConstructorDeclarationToPullSymbol(decl); - break; - - case 1048576 /* CallSignature */: - this.bindCallSignatureDeclarationToPullSymbol(decl); - break; - - case 2097152 /* ConstructSignature */: - this.bindConstructSignatureDeclarationToPullSymbol(decl); - break; - - case 4194304 /* IndexSignature */: - this.bindIndexSignatureDeclarationToPullSymbol(decl); - break; - - case 262144 /* GetAccessor */: - this.bindGetAccessorDeclarationToPullSymbol(decl); - break; - - case 524288 /* SetAccessor */: - this.bindSetAccessorDeclarationToPullSymbol(decl); - break; - - case 8388608 /* ObjectType */: - this.bindObjectTypeDeclarationToPullSymbol(decl); - break; - - case 16777216 /* FunctionType */: - this.bindFunctionTypeDeclarationToPullSymbol(decl); - break; - - case 33554432 /* ConstructorType */: - this.bindConstructorTypeDeclarationToPullSymbol(decl); - break; - - case 131072 /* FunctionExpression */: - this.bindFunctionExpressionToPullSymbol(decl); - break; - - case 256 /* TypeAlias */: - this.bindImportDeclaration(decl); - break; - - case 2048 /* Parameter */: - case 8192 /* TypeParameter */: - break; - - case 1073741824 /* CatchBlock */: - this.bindCatchBlockPullSymbols(decl); - - case 536870912 /* WithBlock */: - this.bindWithBlockPullSymbols(decl); - break; - - default: - throw new Error("Unrecognized type declaration"); - } - }; - - PullSymbolBinder.prototype.bindDeclsForUnit = function (filePath, rebind) { - if (typeof rebind === "undefined") { rebind = false; } - this.setUnit(filePath); - - var topLevelDecls = this.semanticInfo.getTopLevelDecls(); - - for (var i = 0; i < topLevelDecls.length; i++) { - this.bindDeclToPullSymbol(topLevelDecls[i], rebind); - } - }; - return PullSymbolBinder; - })(); - TypeScript.PullSymbolBinder = PullSymbolBinder; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - TypeScript.linkID = 0; - - var IListItem = (function () { - function IListItem(value) { - this.value = value; - this.next = null; - this.prev = null; - } - return IListItem; - })(); - TypeScript.IListItem = IListItem; - - var LinkList = (function () { - function LinkList() { - this.head = null; - this.last = null; - this.length = 0; - } - LinkList.prototype.addItem = function (item) { - if (!this.head) { - this.head = new IListItem(item); - this.last = this.head; - } else { - this.last.next = new IListItem(item); - this.last.next.prev = this.last; - this.last = this.last.next; - } - - this.length++; - }; - - LinkList.prototype.find = function (p) { - var node = this.head; - var vals = []; - - while (node) { - if (p(node.value)) { - vals[vals.length] = node.value; - } - node = node.next; - } - - return vals; - }; - - LinkList.prototype.remove = function (p) { - var node = this.head; - var prev = null; - var next = null; - - while (node) { - if (p(node.value)) { - if (node === this.head) { - if (this.last === this.head) { - this.last = null; - } - - this.head = this.head.next; - - if (this.head) { - this.head.prev = null; - } - } else { - prev = node.prev; - next = node.next; - - if (prev) { - prev.next = next; - } - if (next) { - next.prev = prev; - } - - if (node === this.last) { - this.last = prev; - } - } - - this.length--; - } - node = node.next; - } - }; - - LinkList.prototype.update = function (map, context) { - var node = this.head; - - while (node) { - map(node.value, context); - - node = node.next; - } - }; - return LinkList; - })(); - TypeScript.LinkList = LinkList; - - var PullSymbolLink = (function () { - function PullSymbolLink(start, end, kind) { - this.start = start; - this.end = end; - this.kind = kind; - this.id = TypeScript.linkID++; - } - return PullSymbolLink; - })(); - TypeScript.PullSymbolLink = PullSymbolLink; - - (function (GraphUpdateKind) { - GraphUpdateKind[GraphUpdateKind["NoUpdate"] = 0] = "NoUpdate"; - - GraphUpdateKind[GraphUpdateKind["SymbolRemoved"] = 1] = "SymbolRemoved"; - GraphUpdateKind[GraphUpdateKind["SymbolAdded"] = 2] = "SymbolAdded"; - - GraphUpdateKind[GraphUpdateKind["TypeChanged"] = 3] = "TypeChanged"; - })(TypeScript.GraphUpdateKind || (TypeScript.GraphUpdateKind = {})); - var GraphUpdateKind = TypeScript.GraphUpdateKind; - - var PullSymbolUpdate = (function () { - function PullSymbolUpdate(updateKind, symbolToUpdate, updater) { - this.updateKind = updateKind; - this.symbolToUpdate = symbolToUpdate; - this.updater = updater; - } - return PullSymbolUpdate; - })(); - TypeScript.PullSymbolUpdate = PullSymbolUpdate; - - TypeScript.updateVersion = 0; - - var PullSymbolGraphUpdater = (function () { - function PullSymbolGraphUpdater(semanticInfoChain) { - this.semanticInfoChain = semanticInfoChain; - } - PullSymbolGraphUpdater.prototype.removeDecl = function (declToRemove) { - var declSymbol = declToRemove.getSymbol(); - - if (declSymbol) { - declSymbol.removeDeclaration(declToRemove); - - var childDecls = declToRemove.getChildDecls(); - - for (var i = 0; i < childDecls.length; i++) { - this.removeDecl(childDecls[i]); - } - - var remainingDecls = declSymbol.getDeclarations(); - - if (!remainingDecls.length) { - this.removeSymbol(declSymbol); - - this.semanticInfoChain.removeSymbolFromCache(declSymbol); - } else { - declSymbol.invalidate(); - } - } - - var valDecl = declToRemove.getValueDecl(); - - if (valDecl) { - this.removeDecl(valDecl); - } - - TypeScript.updateVersion++; - }; - - PullSymbolGraphUpdater.prototype.addDecl = function (declToAdd) { - var symbolToAdd = declToAdd.getSymbol(); - - if (symbolToAdd) { - this.addSymbol(symbolToAdd); - } - - TypeScript.updateVersion++; - }; - - PullSymbolGraphUpdater.prototype.removeSymbol = function (symbolToRemove) { - if (symbolToRemove.removeUpdateVersion === TypeScript.updateVersion) { - return; - } - - symbolToRemove.removeUpdateVersion = TypeScript.updateVersion; - - symbolToRemove.updateOutgoingLinks(propagateRemovalToOutgoingLinks, new PullSymbolUpdate(1 /* SymbolRemoved */, symbolToRemove, this)); - - symbolToRemove.updateIncomingLinks(propagateRemovalToIncomingLinks, new PullSymbolUpdate(1 /* SymbolRemoved */, symbolToRemove, this)); - - symbolToRemove.unsetContainer(); - - this.semanticInfoChain.removeSymbolFromCache(symbolToRemove); - - var container = symbolToRemove.getContainer(); - - if (container) { - container.removeMember(symbolToRemove); - this.semanticInfoChain.removeSymbolFromCache(symbolToRemove); - } - - if (symbolToRemove.isAccessor()) { - var getterSymbol = (symbolToRemove).getGetter(); - var setterSymbol = (symbolToRemove).getSetter(); - - if (getterSymbol) { - this.removeSymbol(getterSymbol); - } - - if (setterSymbol) { - this.removeSymbol(setterSymbol); - } - } - - symbolToRemove.removeAllLinks(); - }; - - PullSymbolGraphUpdater.prototype.addSymbol = function (symbolToAdd) { - if (symbolToAdd.addUpdateVersion === TypeScript.updateVersion) { - return; - } - - symbolToAdd.addUpdateVersion = TypeScript.updateVersion; - - symbolToAdd.updateOutgoingLinks(propagateAdditionToOutgoingLinks, new PullSymbolUpdate(2 /* SymbolAdded */, symbolToAdd, this)); - - symbolToAdd.updateIncomingLinks(propagateAdditionToIncomingLinks, new PullSymbolUpdate(2 /* SymbolAdded */, symbolToAdd, this)); - }; - - PullSymbolGraphUpdater.prototype.invalidateType = function (symbolWhoseTypeChanged) { - if (!symbolWhoseTypeChanged) { - return; - } - - if (symbolWhoseTypeChanged.isPrimitive()) { - return; - } - - if (symbolWhoseTypeChanged.typeChangeUpdateVersion === TypeScript.updateVersion) { - return; - } - - symbolWhoseTypeChanged.typeChangeUpdateVersion = TypeScript.updateVersion; - - symbolWhoseTypeChanged.updateOutgoingLinks(propagateChangedTypeToOutgoingLinks, new PullSymbolUpdate(3 /* TypeChanged */, symbolWhoseTypeChanged, this)); - - symbolWhoseTypeChanged.updateIncomingLinks(propagateChangedTypeToIncomingLinks, new PullSymbolUpdate(3 /* TypeChanged */, symbolWhoseTypeChanged, this)); - - if (symbolWhoseTypeChanged.getKind() === 4 /* Container */) { - var instanceSymbol = (symbolWhoseTypeChanged).getInstanceSymbol(); - - this.invalidateType(instanceSymbol); - } - - if (symbolWhoseTypeChanged.isResolved()) { - symbolWhoseTypeChanged.invalidate(); - } - - this.invalidateUnitsForSymbol(symbolWhoseTypeChanged); - }; - - PullSymbolGraphUpdater.prototype.invalidateUnitsForSymbol = function (symbol) { - var declarations = symbol.getDeclarations(); - - for (var i = 0; i < declarations.length; i++) { - this.semanticInfoChain.invalidateUnit(declarations[i].getScriptName()); - } - }; - return PullSymbolGraphUpdater; - })(); - TypeScript.PullSymbolGraphUpdater = PullSymbolGraphUpdater; - - function propagateRemovalToOutgoingLinks(link, update) { - var symbolToRemove = update.symbolToUpdate; - var affectedSymbol = link.end; - - if (affectedSymbol.removeUpdateVersion === TypeScript.updateVersion || affectedSymbol.isPrimitive()) { - return; - } - - if (link.kind === 2 /* ProvidesInferredType */) { - update.updater.invalidateType(affectedSymbol); - } else if (link.kind === 21 /* SpecializedTo */) { - (symbolToRemove).removeSpecialization(affectedSymbol); - update.updater.removeSymbol(affectedSymbol); - update.updater.invalidateType(affectedSymbol); - } else if (link.kind === 5 /* PublicMember */) { - update.updater.removeSymbol(affectedSymbol); - } else if (link.kind === 6 /* PrivateMember */) { - update.updater.removeSymbol(affectedSymbol); - } else if (link.kind === 7 /* ConstructorMethod */) { - update.updater.invalidateType(affectedSymbol); - } else if (link.kind === 10 /* ContainedBy */) { - (affectedSymbol).removeMember(symbolToRemove); - update.updater.invalidateType(affectedSymbol); - } else if (link.kind === 13 /* Parameter */) { - update.updater.removeSymbol(affectedSymbol); - } else if (link.kind === 15 /* CallSignature */) { - update.updater.invalidateType(affectedSymbol); - } else if (link.kind === 16 /* ConstructSignature */) { - update.updater.invalidateType(affectedSymbol); - } else if (link.kind === 17 /* IndexSignature */) { - update.updater.invalidateType(affectedSymbol); - } - - symbolToRemove.removeOutgoingLink(link); - } - TypeScript.propagateRemovalToOutgoingLinks = propagateRemovalToOutgoingLinks; - - function propagateRemovalToIncomingLinks(link, update) { - var symbolToRemove = update.symbolToUpdate; - var affectedSymbol = link.start; - - if (affectedSymbol.removeUpdateVersion === TypeScript.updateVersion || affectedSymbol.isPrimitive()) { - return; - } - - if (link.kind === 0 /* TypedAs */) { - update.updater.invalidateType(affectedSymbol); - } else if (link.kind === 1 /* ContextuallyTypedAs */) { - update.updater.invalidateType(affectedSymbol); - } else if (link.kind === 18 /* TypeParameter */) { - update.updater.invalidateType(affectedSymbol); - } else if (link.kind === 19 /* TypeArgument */) { - update.updater.invalidateType(affectedSymbol); - } else if (link.kind === 21 /* SpecializedTo */) { - (affectedSymbol).removeSpecialization(symbolToRemove); - } else if (link.kind === 22 /* TypeConstraint */) { - update.updater.invalidateType(affectedSymbol); - } else if (link.kind === 5 /* PublicMember */) { - (affectedSymbol).removeMember(symbolToRemove); - update.updater.invalidateType(affectedSymbol); - } else if (link.kind === 6 /* PrivateMember */) { - (affectedSymbol).removeMember(symbolToRemove); - update.updater.invalidateType(affectedSymbol); - } else if (link.kind === 7 /* ConstructorMethod */) { - update.updater.invalidateType(affectedSymbol); - } else if (link.kind === 10 /* ContainedBy */) { - update.updater.invalidateType(affectedSymbol); - } else if (link.kind === 11 /* Extends */) { - update.updater.invalidateType(affectedSymbol); - } else if (link.kind === 12 /* Implements */) { - update.updater.invalidateType(affectedSymbol); - } else if (link.kind === 13 /* Parameter */) { - update.updater.invalidateType(affectedSymbol); - } else if (link.kind === 14 /* ReturnType */) { - update.updater.invalidateType(affectedSymbol); - } else if (link.kind === 15 /* CallSignature */) { - update.updater.invalidateType(affectedSymbol); - } else if (link.kind === 16 /* ConstructSignature */) { - update.updater.invalidateType(affectedSymbol); - } else if (link.kind === 17 /* IndexSignature */) { - update.updater.invalidateType(affectedSymbol); - } else if (link.kind === 8 /* Aliases */) { - update.updater.invalidateType(affectedSymbol); - } else if (link.kind === 9 /* ExportAliases */) { - update.updater.invalidateType(affectedSymbol); - } - } - TypeScript.propagateRemovalToIncomingLinks = propagateRemovalToIncomingLinks; - - function propagateAdditionToOutgoingLinks(link, update) { - var symbolToAdd = update.symbolToUpdate; - var affectedSymbol = link.end; - - if (affectedSymbol.addUpdateVersion === TypeScript.updateVersion || affectedSymbol.isPrimitive()) { - return; - } - - if (link.kind === 10 /* ContainedBy */) { - update.updater.invalidateType(affectedSymbol); - } else if (link.kind === 2 /* ProvidesInferredType */) { - update.updater.invalidateType(affectedSymbol); - } else if (link.kind === 18 /* TypeParameter */) { - update.updater.invalidateType(affectedSymbol); - } else if (link.kind === 19 /* TypeArgument */) { - update.updater.invalidateType(affectedSymbol); - } else if (link.kind === 21 /* SpecializedTo */) { - update.updater.invalidateType(affectedSymbol); - } else if (link.kind === 22 /* TypeConstraint */) { - update.updater.invalidateType(affectedSymbol); - } else if (link.kind === 5 /* PublicMember */) { - update.updater.invalidateType(affectedSymbol); - } else if (link.kind === 7 /* ConstructorMethod */) { - update.updater.invalidateType(affectedSymbol); - } else if (link.kind === 14 /* ReturnType */) { - update.updater.invalidateType(affectedSymbol); - } else if (link.kind === 15 /* CallSignature */) { - update.updater.invalidateType(affectedSymbol); - } else if (link.kind === 16 /* ConstructSignature */) { - update.updater.invalidateType(affectedSymbol); - } else if (link.kind === 17 /* IndexSignature */) { - update.updater.invalidateType(affectedSymbol); - } - } - TypeScript.propagateAdditionToOutgoingLinks = propagateAdditionToOutgoingLinks; - - function propagateAdditionToIncomingLinks(link, update) { - var symbolToAdd = update.symbolToUpdate; - var affectedSymbol = link.start; - - if (affectedSymbol.addUpdateVersion === TypeScript.updateVersion || affectedSymbol.isPrimitive()) { - return; - } - - if (link.kind === 0 /* TypedAs */) { - update.updater.invalidateType(affectedSymbol); - } else if (link.kind === 1 /* ContextuallyTypedAs */) { - update.updater.invalidateType(affectedSymbol); - } else if (link.kind === 18 /* TypeParameter */) { - update.updater.invalidateType(affectedSymbol); - } else if (link.kind === 19 /* TypeArgument */) { - update.updater.invalidateType(affectedSymbol); - } else if (link.kind === 22 /* TypeConstraint */) { - update.updater.invalidateType(affectedSymbol); - } else if (link.kind === 5 /* PublicMember */) { - update.updater.invalidateType(affectedSymbol); - } else if (link.kind === 7 /* ConstructorMethod */) { - update.updater.invalidateType(affectedSymbol); - } else if (link.kind === 11 /* Extends */) { - update.updater.invalidateType(affectedSymbol); - } else if (link.kind === 12 /* Implements */) { - update.updater.invalidateType(affectedSymbol); - } else if (link.kind === 14 /* ReturnType */) { - update.updater.invalidateType(affectedSymbol); - } else if (link.kind === 8 /* Aliases */) { - update.updater.invalidateType(affectedSymbol); - } else if (link.kind === 9 /* ExportAliases */) { - update.updater.invalidateType(affectedSymbol); - } - } - TypeScript.propagateAdditionToIncomingLinks = propagateAdditionToIncomingLinks; - - function propagateChangedTypeToOutgoingLinks(link, update) { - var symbolWhoseTypeChanged = update.symbolToUpdate; - var affectedSymbol = link.end; - - if (affectedSymbol.typeChangeUpdateVersion === TypeScript.updateVersion || affectedSymbol.isPrimitive()) { - return; - } - - if (link.kind === 2 /* ProvidesInferredType */) { - update.updater.invalidateType(affectedSymbol); - } else if (link.kind === 10 /* ContainedBy */) { - update.updater.invalidateType(affectedSymbol); - } else if (link.kind === 18 /* TypeParameter */) { - update.updater.invalidateType(affectedSymbol); - } else if (link.kind === 19 /* TypeArgument */) { - update.updater.invalidateType(affectedSymbol); - } else if (link.kind === 21 /* SpecializedTo */) { - update.updater.invalidateType(affectedSymbol); - } else if (link.kind === 22 /* TypeConstraint */) { - update.updater.invalidateType(affectedSymbol); - } else if (link.kind === 5 /* PublicMember */) { - update.updater.invalidateType(affectedSymbol); - } else if (link.kind === 15 /* CallSignature */) { - update.updater.invalidateType(affectedSymbol); - } else if (link.kind === 7 /* ConstructorMethod */) { - update.updater.invalidateType(affectedSymbol); - } else if (link.kind === 16 /* ConstructSignature */) { - update.updater.invalidateType(affectedSymbol); - } else if (link.kind === 17 /* IndexSignature */) { - update.updater.invalidateType(affectedSymbol); - } - } - TypeScript.propagateChangedTypeToOutgoingLinks = propagateChangedTypeToOutgoingLinks; - - function propagateChangedTypeToIncomingLinks(link, update) { - var symbolWhoseTypeChanged = update.symbolToUpdate; - var affectedSymbol = link.start; - - if (affectedSymbol.typeChangeUpdateVersion === TypeScript.updateVersion || affectedSymbol.isPrimitive()) { - return; - } - - if (link.kind === 0 /* TypedAs */) { - update.updater.invalidateType(affectedSymbol); - } else if (link.kind === 1 /* ContextuallyTypedAs */) { - update.updater.invalidateType(affectedSymbol); - } else if (link.kind === 18 /* TypeParameter */) { - update.updater.invalidateType(affectedSymbol); - } else if (link.kind === 19 /* TypeArgument */) { - update.updater.invalidateType(affectedSymbol); - } else if (link.kind === 22 /* TypeConstraint */) { - update.updater.invalidateType(affectedSymbol); - } else if (link.kind === 5 /* PublicMember */) { - update.updater.invalidateType(affectedSymbol); - } else if (link.kind === 17 /* IndexSignature */) { - update.updater.invalidateType(affectedSymbol); - } else if (link.kind === 11 /* Extends */) { - update.updater.invalidateType(affectedSymbol); - } else if (link.kind === 12 /* Implements */) { - update.updater.invalidateType(affectedSymbol); - } else if (link.kind === 14 /* ReturnType */) { - update.updater.invalidateType(affectedSymbol); - } else if (link.kind === 8 /* Aliases */) { - update.updater.invalidateType(affectedSymbol); - } else if (link.kind === 9 /* ExportAliases */) { - update.updater.invalidateType(affectedSymbol); - } - } - TypeScript.propagateChangedTypeToIncomingLinks = propagateChangedTypeToIncomingLinks; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var SemanticDiagnostic = (function (_super) { - __extends(SemanticDiagnostic, _super); - function SemanticDiagnostic() { - _super.apply(this, arguments); - } - SemanticDiagnostic.equals = function (diagnostic1, diagnostic2) { - return TypeScript.Diagnostic.equals(diagnostic1, diagnostic2); - }; - return SemanticDiagnostic; - })(TypeScript.Diagnostic); - TypeScript.SemanticDiagnostic = SemanticDiagnostic; - - function getDiagnosticsFromEnclosingDecl(enclosingDecl, errors) { - var declErrors = enclosingDecl.getDiagnostics(); - - if (declErrors) { - for (var i = 0; i < declErrors.length; i++) { - errors[errors.length] = declErrors[i]; - } - } - - var childDecls = enclosingDecl.getChildDecls(); - - for (var i = 0; i < childDecls.length; i++) { - getDiagnosticsFromEnclosingDecl(childDecls[i], errors); - } - } - TypeScript.getDiagnosticsFromEnclosingDecl = getDiagnosticsFromEnclosingDecl; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (PullHelpers) { - function getSignatureForFuncDecl(funcDecl, semanticInfo) { - var functionDecl = semanticInfo.getDeclForAST(funcDecl); - var funcSymbol = functionDecl.getSymbol(); - - if (!funcSymbol) { - funcSymbol = functionDecl.getSignatureSymbol(); - } - - var functionSignature = null; - var typeSymbolWithAllSignatures = null; - if (funcSymbol.isSignature()) { - functionSignature = funcSymbol; - var parent = functionDecl.getParentDecl(); - typeSymbolWithAllSignatures = parent.getSymbol().getType(); - } else { - functionSignature = functionDecl.getSignatureSymbol(); - typeSymbolWithAllSignatures = funcSymbol.getType(); - } - var signatures; - if (funcDecl.isConstructor || funcDecl.isConstructMember()) { - signatures = typeSymbolWithAllSignatures.getConstructSignatures(); - } else if (funcDecl.isIndexerMember()) { - signatures = typeSymbolWithAllSignatures.getIndexSignatures(); - } else { - signatures = typeSymbolWithAllSignatures.getCallSignatures(); - } - return { - signature: functionSignature, - allSignatures: signatures - }; - } - PullHelpers.getSignatureForFuncDecl = getSignatureForFuncDecl; - - function getAccessorSymbol(getterOrSetter, semanticInfoChain, unitPath) { - var functionDecl = semanticInfoChain.getDeclForAST(getterOrSetter, unitPath); - var getterOrSetterSymbol = functionDecl.getSymbol(); - - return getterOrSetterSymbol; - } - PullHelpers.getAccessorSymbol = getAccessorSymbol; - - function getGetterAndSetterFunction(funcDecl, semanticInfoChain, unitPath) { - var accessorSymbol = PullHelpers.getAccessorSymbol(funcDecl, semanticInfoChain, unitPath); - var result = { - getter: null, - setter: null - }; - var getter = accessorSymbol.getGetter(); - if (getter) { - var getterDecl = getter.getDeclarations()[0]; - result.getter = semanticInfoChain.getASTForDecl(getterDecl); - } - var setter = accessorSymbol.getSetter(); - if (setter) { - var setterDecl = setter.getDeclarations()[0]; - result.setter = semanticInfoChain.getASTForDecl(setterDecl); - } - - return result; - } - PullHelpers.getGetterAndSetterFunction = getGetterAndSetterFunction; - - function symbolIsEnum(source) { - return source && ((source.getKind() & (64 /* Enum */ | 67108864 /* EnumMember */)) || source.hasFlag(131072 /* InitializedEnum */)); - } - PullHelpers.symbolIsEnum = symbolIsEnum; - })(TypeScript.PullHelpers || (TypeScript.PullHelpers = {})); - var PullHelpers = TypeScript.PullHelpers; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var incrementalAst = true; - var SyntaxPositionMap = (function () { - function SyntaxPositionMap(node) { - this.position = 0; - this.elementToPosition = TypeScript.Collections.createHashTable(2048, TypeScript.Collections.identityHashCode); - this.process(node); - } - SyntaxPositionMap.prototype.process = function (element) { - if (element !== null) { - if (element.isToken()) { - this.elementToPosition.add(element, this.position); - this.position += element.fullWidth(); - } else { - if (element.isNode() || (element.isList() && (element).childCount() > 0) || (element.isSeparatedList() && (element).childCount() > 0)) { - this.elementToPosition.add(element, this.position); - } - - for (var i = 0, n = element.childCount(); i < n; i++) { - this.process(element.childAt(i)); - } - } - } - }; - - SyntaxPositionMap.create = function (node) { - var map = new SyntaxPositionMap(node); - return map; - }; - - SyntaxPositionMap.prototype.fullStart = function (element) { - return this.elementToPosition.get(element); - }; - - SyntaxPositionMap.prototype.start = function (element) { - return this.fullStart(element) + element.leadingTriviaWidth(); - }; - - SyntaxPositionMap.prototype.end = function (element) { - return this.start(element) + element.width(); - }; - - SyntaxPositionMap.prototype.fullEnd = function (element) { - return this.fullStart(element) + element.fullWidth(); - }; - return SyntaxPositionMap; - })(); - TypeScript.SyntaxPositionMap = SyntaxPositionMap; - - var SyntaxTreeToAstVisitor = (function () { - function SyntaxTreeToAstVisitor(syntaxPositionMap, fileName, lineMap, compilationSettings) { - this.syntaxPositionMap = syntaxPositionMap; - this.fileName = fileName; - this.lineMap = lineMap; - this.compilationSettings = compilationSettings; - this.position = 0; - this.requiresExtendsBlock = false; - this.previousTokenTrailingComments = null; - this.isParsingAmbientModule = false; - this.containingModuleHasExportAssignment = false; - this.isParsingDeclareFile = TypeScript.isDTSFile(fileName); - } - SyntaxTreeToAstVisitor.visit = function (syntaxTree, fileName, compilationSettings) { - var map = SyntaxTreeToAstVisitor.checkPositions ? SyntaxPositionMap.create(syntaxTree.sourceUnit()) : null; - var visitor = new SyntaxTreeToAstVisitor(map, fileName, syntaxTree.lineMap(), compilationSettings); - return syntaxTree.sourceUnit().accept(visitor); - }; - - SyntaxTreeToAstVisitor.prototype.assertElementAtPosition = function (element) { - if (SyntaxTreeToAstVisitor.checkPositions) { - TypeScript.Debug.assert(this.position === this.syntaxPositionMap.fullStart(element)); - } - }; - - SyntaxTreeToAstVisitor.prototype.movePast = function (element) { - if (element !== null) { - this.assertElementAtPosition(element); - this.position += element.fullWidth(); - } - }; - - SyntaxTreeToAstVisitor.prototype.moveTo = function (element1, element2) { - if (element2 !== null) { - this.position += TypeScript.Syntax.childOffset(element1, element2); - } - }; - - SyntaxTreeToAstVisitor.prototype.applyDelta = function (ast, delta) { - var _this = this; - if (delta === 0) { - return; - } - - var applyDelta = function (ast) { - if (ast.minChar !== -1) { - ast.minChar += delta; - } - if (ast.limChar !== -1) { - ast.limChar += delta; - } - }; - - var applyDeltaToComments = function (comments) { - if (comments && comments.length > 0) { - for (var i = 0; i < comments.length; i++) { - var comment = comments[i]; - applyDelta(comment); - comment.minLine = _this.lineMap.getLineNumberFromPosition(comment.minChar); - comment.limLine = _this.lineMap.getLineNumberFromPosition(comment.limChar); - } - } - }; - - var pre = function (cur, parent, walker) { - applyDelta(cur); - applyDeltaToComments(cur.preComments); - applyDeltaToComments(cur.postComments); - - return cur; - }; - - TypeScript.getAstWalkerFactory().walk(ast, pre); - }; - - SyntaxTreeToAstVisitor.prototype.setSpan = function (span, fullStart, element) { - var desiredMinChar = fullStart + element.leadingTriviaWidth(); - var desiredLimChar = desiredMinChar + element.width(); - - this.setSpanExplicit(span, desiredMinChar, desiredLimChar); - - span.trailingTriviaWidth = element.trailingTriviaWidth(); - }; - - SyntaxTreeToAstVisitor.prototype.setSpanExplicit = function (span, start, end) { - if (span.minChar !== -1) { - TypeScript.Debug.assert(span.limChar !== -1); - TypeScript.Debug.assert((span).nodeType !== undefined); - - var delta = start - span.minChar; - this.applyDelta(span, delta); - - span.limChar = end; - - TypeScript.Debug.assert(span.minChar === start); - TypeScript.Debug.assert(span.limChar === end); - } else { - TypeScript.Debug.assert(span.limChar === -1); - - span.minChar = start; - span.limChar = end; - } - - TypeScript.Debug.assert(!isNaN(span.minChar)); - TypeScript.Debug.assert(!isNaN(span.limChar)); - TypeScript.Debug.assert(span.minChar !== -1); - TypeScript.Debug.assert(span.limChar !== -1); - }; - - SyntaxTreeToAstVisitor.prototype.identifierFromToken = function (token, isOptional, useValueText) { - this.assertElementAtPosition(token); - - var result = null; - if (token.fullWidth() === 0) { - result = new TypeScript.MissingIdentifier(); - } else { - result = new TypeScript.Identifier(token.text()); - result.text = useValueText ? token.valueText() : result.text; - if (result.text == SyntaxTreeToAstVisitor.protoString) { - result.text = SyntaxTreeToAstVisitor.protoSubstitutionString; - } - } - - if (isOptional) { - result.setFlags(result.getFlags() | 4 /* OptionalName */); - } - - var start = this.position + token.leadingTriviaWidth(); - this.setSpanExplicit(result, start, start + token.width()); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.getAST = function (element) { - if (this.previousTokenTrailingComments !== null) { - return null; - } - - if (incrementalAst) { - var result = (element)._ast; - return result ? result : null; - } else { - return null; - } - }; - - SyntaxTreeToAstVisitor.prototype.setAST = function (element, ast) { - if (incrementalAst) { - (element)._ast = ast; - } - }; - - SyntaxTreeToAstVisitor.prototype.visitSyntaxList = function (list) { - var start = this.position; - var result = this.getAST(list); - if (result) { - this.movePast(list); - } else { - result = new TypeScript.ASTList(); - - for (var i = 0, n = list.childCount(); i < n; i++) { - result.append(list.childAt(i).accept(this)); - } - - if (n > 0) { - this.setAST(list, result); - } - } - - this.setSpan(result, start, list); - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitSeparatedSyntaxList = function (list) { - var start = this.position; - var result = this.getAST(list); - if (result) { - this.movePast(list); - } else { - result = new TypeScript.ASTList(); - - for (var i = 0, n = list.childCount(); i < n; i++) { - if (i % 2 === 0) { - result.append(list.childAt(i).accept(this)); - this.previousTokenTrailingComments = null; - } else { - var separatorToken = list.childAt(i); - this.previousTokenTrailingComments = this.convertTokenTrailingComments(separatorToken, this.position + separatorToken.leadingTriviaWidth() + separatorToken.width()); - this.movePast(separatorToken); - } - } - - result.postComments = this.previousTokenTrailingComments; - this.previousTokenTrailingComments = null; - - if (n > 0) { - this.setAST(list, result); - } - } - - this.setSpan(result, start, list); - return result; - }; - - SyntaxTreeToAstVisitor.prototype.createRef = function (text, minChar) { - var id = new TypeScript.Identifier(text); - id.minChar = minChar; - return id; - }; - - SyntaxTreeToAstVisitor.prototype.convertComment = function (trivia, commentStartPosition, hasTrailingNewLine) { - var comment = new TypeScript.Comment(trivia.fullText(), trivia.kind() === 6 /* MultiLineCommentTrivia */, hasTrailingNewLine); - - comment.minChar = commentStartPosition; - comment.limChar = commentStartPosition + trivia.fullWidth(); - comment.minLine = this.lineMap.getLineNumberFromPosition(comment.minChar); - comment.limLine = this.lineMap.getLineNumberFromPosition(comment.limChar); - - return comment; - }; - - SyntaxTreeToAstVisitor.prototype.convertComments = function (triviaList, commentStartPosition) { - var result = []; - - for (var i = 0, n = triviaList.count(); i < n; i++) { - var trivia = triviaList.syntaxTriviaAt(i); - - if (trivia.isComment()) { - var hasTrailingNewLine = ((i + 1) < n) && triviaList.syntaxTriviaAt(i + 1).isNewLine(); - result.push(this.convertComment(trivia, commentStartPosition, hasTrailingNewLine)); - } - - commentStartPosition += trivia.fullWidth(); - } - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.mergeComments = function (comments1, comments2) { - if (comments1 === null) { - return comments2; - } - - if (comments2 === null) { - return comments1; - } - - return comments1.concat(comments2); - }; - - SyntaxTreeToAstVisitor.prototype.convertTokenLeadingComments = function (token, commentStartPosition) { - if (token === null) { - return null; - } - - var preComments = token.hasLeadingComment() ? this.convertComments(token.leadingTrivia(), commentStartPosition) : null; - - var previousTokenTrailingComments = this.previousTokenTrailingComments; - this.previousTokenTrailingComments = null; - - return this.mergeComments(previousTokenTrailingComments, preComments); - }; - - SyntaxTreeToAstVisitor.prototype.convertTokenTrailingComments = function (token, commentStartPosition) { - if (token === null || !token.hasTrailingComment() || token.hasTrailingNewLine()) { - return null; - } - - return this.convertComments(token.trailingTrivia(), commentStartPosition); - }; - - SyntaxTreeToAstVisitor.prototype.convertNodeLeadingComments = function (node, nodeStart) { - return this.convertTokenLeadingComments(node.firstToken(), nodeStart); - }; - - SyntaxTreeToAstVisitor.prototype.convertNodeTrailingComments = function (node, nodeStart) { - return this.convertTokenTrailingComments(node.lastToken(), nodeStart + node.leadingTriviaWidth() + node.width()); - }; - - SyntaxTreeToAstVisitor.prototype.visitToken = function (token) { - this.assertElementAtPosition(token); - - var result = this.getAST(token); - var fullStart = this.position; - - if (result) { - this.movePast(token); - } else { - if (token.kind() === 35 /* ThisKeyword */) { - result = new TypeScript.ThisExpression(); - } else if (token.kind() === 50 /* SuperKeyword */) { - result = new TypeScript.SuperExpression(); - } else if (token.kind() === 37 /* TrueKeyword */) { - result = new TypeScript.LiteralExpression(3 /* TrueLiteral */); - } else if (token.kind() === 24 /* FalseKeyword */) { - result = new TypeScript.LiteralExpression(4 /* FalseLiteral */); - } else if (token.kind() === 32 /* NullKeyword */) { - result = new TypeScript.LiteralExpression(8 /* NullLiteral */); - } else if (token.kind() === 14 /* StringLiteral */) { - result = new TypeScript.StringLiteral(token.text(), token.valueText()); - } else if (token.kind() === 12 /* RegularExpressionLiteral */) { - result = new TypeScript.RegexLiteral(token.text()); - } else if (token.kind() === 13 /* NumericLiteral */) { - var preComments = this.convertTokenLeadingComments(token, fullStart); - - var value = token.text().indexOf(".") > 0 ? parseFloat(token.text()) : parseInt(token.text()); - result = new TypeScript.NumberLiteral(value, token.text()); - - result.preComments = preComments; - } else { - result = this.identifierFromToken(token, false, true); - } - - this.movePast(token); - } - - var start = fullStart + token.leadingTriviaWidth(); - this.setAST(token, result); - this.setSpanExplicit(result, start, start + token.width()); - return result; - }; - - SyntaxTreeToAstVisitor.prototype.getLeadingComments = function (node) { - var firstToken = node.firstToken(); - var result = []; - - if (firstToken.hasLeadingComment()) { - var leadingTrivia = firstToken.leadingTrivia(); - - for (var i = 0, n = leadingTrivia.count(); i < n; i++) { - var trivia = leadingTrivia.syntaxTriviaAt(i); - - if (trivia.isComment()) { - result.push(trivia); - } - } - } - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.hasTopLevelImportOrExport = function (node) { - var firstToken; - - for (var i = 0, n = node.moduleElements.childCount(); i < n; i++) { - var moduleElement = node.moduleElements.childAt(i); - - firstToken = moduleElement.firstToken(); - if (firstToken !== null && firstToken.kind() === 47 /* ExportKeyword */) { - return true; - } - - if (moduleElement.kind() === 133 /* ImportDeclaration */) { - var importDecl = moduleElement; - if (importDecl.moduleReference.kind() === 245 /* ExternalModuleReference */) { - return true; - } - } - } - - var leadingComments = this.getLeadingComments(node); - for (var i = 0, n = leadingComments.length; i < n; i++) { - var trivia = leadingComments[i]; - - if (TypeScript.getImplicitImport(trivia.fullText())) { - return true; - } - } - - return false; - }; - - SyntaxTreeToAstVisitor.prototype.getAmdDependency = function (comment) { - var amdDependencyRegEx = /^\/\/\/\s* 0; - - if (!this.containingModuleHasExportAssignment && (TypeScript.SyntaxUtilities.containsToken(node.modifiers, 47 /* ExportKeyword */) || this.isParsingAmbientModule)) { - result.setVarFlags(result.getVarFlags() | 1 /* Exported */); - } else { - result.setVarFlags(result.getVarFlags() & ~1 /* Exported */); - } - - if (TypeScript.SyntaxUtilities.containsToken(node.modifiers, 64 /* DeclareKeyword */) || this.isParsingAmbientModule || this.isParsingDeclareFile) { - result.setVarFlags(result.getVarFlags() | 8 /* Ambient */); - } else { - result.setVarFlags(result.getVarFlags() & ~8 /* Ambient */); - } - - this.setAST(node, result); - this.setSpan(result, start, node); - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitInterfaceDeclaration = function (node) { - this.assertElementAtPosition(node); - - var start = this.position; - var result = this.getAST(node); - if (result) { - this.movePast(node); - } else { - var preComments = this.convertNodeLeadingComments(node, start); - var postComments = this.convertNodeTrailingComments(node, start); - this.moveTo(node, node.identifier); - var name = this.identifierFromToken(node.identifier, false, true); - this.movePast(node.identifier); - var typeParameters = node.typeParameterList === null ? null : node.typeParameterList.accept(this); - - var extendsList = null; - - for (var i = 0, n = node.heritageClauses.childCount(); i < n; i++) { - var heritageClause = node.heritageClauses.childAt(i); - if (i === 0) { - extendsList = heritageClause.accept(this); - } else { - this.movePast(heritageClause); - } - } - - this.movePast(node.body.openBraceToken); - var members = this.visitSeparatedSyntaxList(node.body.typeMembers); - - this.movePast(node.body.closeBraceToken); - - result = new TypeScript.InterfaceDeclaration(name, typeParameters, members, extendsList, null); - - result.preComments = preComments; - result.postComments = postComments; - } - - if (!this.containingModuleHasExportAssignment && (TypeScript.SyntaxUtilities.containsToken(node.modifiers, 47 /* ExportKeyword */) || this.isParsingAmbientModule)) { - result.setVarFlags(result.getVarFlags() | 1 /* Exported */); - } else { - result.setVarFlags(result.getVarFlags() & ~1 /* Exported */); - } - - this.setAST(node, result); - this.setSpan(result, start, node); - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitHeritageClause = function (node) { - this.assertElementAtPosition(node); - - var start = this.position; - var result = this.getAST(node); - if (result) { - this.movePast(node); - } else { - result = new TypeScript.ASTList(); - - this.movePast(node.extendsOrImplementsKeyword); - for (var i = 0, n = node.typeNames.childCount(); i < n; i++) { - if (i % 2 === 1) { - this.movePast(node.typeNames.childAt(i)); - } else { - var type = this.visitType(node.typeNames.childAt(i)).term; - result.append(type); - } - } - } - - this.setAST(node, result); - this.setSpan(result, start, node); - return result; - }; - - SyntaxTreeToAstVisitor.prototype.getModuleNames = function (node) { - var result = []; - - if (node.stringLiteral !== null) { - result.push(this.identifierFromToken(node.stringLiteral, false, false)); - this.movePast(node.stringLiteral); - } else { - this.getModuleNamesHelper(node.moduleName, result); - } - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.getModuleNamesHelper = function (name, result) { - this.assertElementAtPosition(name); - - if (name.kind() === 122 /* QualifiedName */) { - var qualifiedName = name; - this.getModuleNamesHelper(qualifiedName.left, result); - this.movePast(qualifiedName.dotToken); - result.push(this.identifierFromToken(qualifiedName.right, false, false)); - this.movePast(qualifiedName.right); - } else { - result.push(this.identifierFromToken(name, false, false)); - this.movePast(name); - } - }; - - SyntaxTreeToAstVisitor.prototype.visitModuleDeclaration = function (node) { - this.assertElementAtPosition(node); - - var start = this.position; - var result = this.getAST(node); - if (result) { - this.movePast(node); - } else { - var preComments = this.convertNodeLeadingComments(node, start); - var postComments = this.convertNodeTrailingComments(node, start); - - this.moveTo(node, node.moduleKeyword); - this.movePast(node.moduleKeyword); - var names = this.getModuleNames(node); - this.movePast(node.openBraceToken); - - var savedIsParsingAmbientModule = this.isParsingAmbientModule; - if (TypeScript.SyntaxUtilities.containsToken(node.modifiers, 64 /* DeclareKeyword */) || this.isParsingDeclareFile) { - this.isParsingAmbientModule = true; - } - - var savedContainingModuleHasExportAssignment = this.containingModuleHasExportAssignment; - this.containingModuleHasExportAssignment = TypeScript.ArrayUtilities.any(node.moduleElements.toArray(), function (m) { - return m.kind() === 134 /* ExportAssignment */; - }); - - var members = this.visitSyntaxList(node.moduleElements); - - this.isParsingAmbientModule = savedIsParsingAmbientModule; - this.containingModuleHasExportAssignment = savedContainingModuleHasExportAssignment; - - var closeBracePosition = this.position; - this.movePast(node.closeBraceToken); - var closeBraceSpan = new TypeScript.ASTSpan(); - this.setSpan(closeBraceSpan, closeBracePosition, node.closeBraceToken); - - for (var i = names.length - 1; i >= 0; i--) { - var innerName = names[i]; - - result = new TypeScript.ModuleDeclaration(innerName, members, closeBraceSpan); - this.setSpan(result, start, node); - - result.preComments = preComments; - result.postComments = postComments; - - preComments = null; - postComments = null; - - if (i) { - result.setModuleFlags(result.getModuleFlags() | 1 /* Exported */); - } else if (!this.containingModuleHasExportAssignment && (TypeScript.SyntaxUtilities.containsToken(node.modifiers, 47 /* ExportKeyword */) || this.isParsingAmbientModule)) { - result.setModuleFlags(result.getModuleFlags() | 1 /* Exported */); - } - - members = new TypeScript.ASTList(); - members.append(result); - } - } - - if (TypeScript.SyntaxUtilities.containsToken(node.modifiers, 64 /* DeclareKeyword */) || this.isParsingAmbientModule || this.isParsingDeclareFile) { - result.setModuleFlags(result.getModuleFlags() | 8 /* Ambient */); - } else { - result.setModuleFlags(result.getModuleFlags() & ~8 /* Ambient */); - } - - this.setAST(node, result); - this.setSpan(result, start, node); - return result; - }; - - SyntaxTreeToAstVisitor.prototype.hasDotDotDotParameter = function (parameters) { - for (var i = 0, n = parameters.nonSeparatorCount(); i < n; i++) { - if ((parameters.nonSeparatorAt(i)).dotDotDotToken) { - return true; - } - } - - return false; - }; - - SyntaxTreeToAstVisitor.prototype.visitFunctionDeclaration = function (node) { - this.assertElementAtPosition(node); - - var start = this.position; - var result = this.getAST(node); - if (result) { - this.movePast(node); - } else { - var preComments = this.convertNodeLeadingComments(node, start); - var postComments = this.convertNodeTrailingComments(node, start); - - this.moveTo(node, node.identifier); - var name = this.identifierFromToken(node.identifier, false, true); - - this.movePast(node.identifier); - - var typeParameters = node.callSignature.typeParameterList === null ? null : node.callSignature.typeParameterList.accept(this); - var parameters = node.callSignature.parameterList.accept(this); - - var returnType = node.callSignature.typeAnnotation ? node.callSignature.typeAnnotation.accept(this) : null; - - var block = node.block ? node.block.accept(this) : null; - - this.movePast(node.semicolonToken); - - result = new TypeScript.FunctionDeclaration(name, block, false, typeParameters, parameters, 12 /* FunctionDeclaration */); - - result.preComments = preComments; - result.postComments = postComments; - result.variableArgList = this.hasDotDotDotParameter(node.callSignature.parameterList.parameters); - result.returnTypeAnnotation = returnType; - - if (node.semicolonToken) { - result.setFunctionFlags(result.getFunctionFlags() | 128 /* Signature */); - } - } - - if (!this.containingModuleHasExportAssignment && (TypeScript.SyntaxUtilities.containsToken(node.modifiers, 47 /* ExportKeyword */) || this.isParsingAmbientModule)) { - result.setFunctionFlags(result.getFunctionFlags() | 1 /* Exported */); - } else { - result.setFunctionFlags(result.getFunctionFlags() & ~1 /* Exported */); - } - - if (TypeScript.SyntaxUtilities.containsToken(node.modifiers, 64 /* DeclareKeyword */) || this.isParsingAmbientModule || this.isParsingDeclareFile) { - result.setFunctionFlags(result.getFunctionFlags() | 8 /* Ambient */); - } else { - result.setFunctionFlags(result.getFunctionFlags() & ~8 /* Ambient */); - } - - this.setAST(node, result); - this.setSpan(result, start, node); - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitEnumDeclaration = function (node) { - this.assertElementAtPosition(node); - - var start = this.position; - - var preComments = this.convertNodeLeadingComments(node, start); - var postComments = this.convertNodeTrailingComments(node, start); - - this.moveTo(node, node.identifier); - var name = this.identifierFromToken(node.identifier, false, true); - this.movePast(node.identifier); - - this.movePast(node.openBraceToken); - var members = new TypeScript.ASTList(); - - var lastValue = null; - var memberNames = []; - var memberName; - - for (var i = 0, n = node.enumElements.childCount(); i < n; i++) { - if (i % 2 === 1) { - this.movePast(node.enumElements.childAt(i)); - } else { - var enumElement = node.enumElements.childAt(i); - - var memberValue = null; - - memberName = this.identifierFromToken(enumElement.propertyName, false, true); - this.movePast(enumElement.propertyName); - - if (enumElement.equalsValueClause !== null) { - memberValue = enumElement.equalsValueClause.accept(this); - lastValue = null; - } - - var memberStart = this.position; - - if (memberValue === null) { - if (lastValue === null) { - memberValue = new TypeScript.NumberLiteral(0, "0"); - lastValue = memberValue; - } else { - var nextValue = lastValue.value + 1; - memberValue = new TypeScript.NumberLiteral(nextValue, nextValue.toString()); - lastValue = memberValue; - } - } - - var declarator = new TypeScript.VariableDeclarator(memberName); - declarator.init = memberValue; - declarator.isImplicitlyInitialized = enumElement.equalsValueClause === null; - - declarator.typeExpr = new TypeScript.TypeReference(this.createRef(name.actualText, -1), 0); - declarator.setVarFlags(declarator.getVarFlags() | 256 /* Property */); - this.setSpanExplicit(declarator, memberStart, this.position); - - if (memberValue.nodeType === 7 /* NumericLiteral */) { - declarator.setVarFlags(declarator.getVarFlags() | 4096 /* Constant */); - } else if (memberValue.nodeType === 69 /* LeftShiftExpression */) { - var binop = memberValue; - if (binop.operand1.nodeType === 7 /* NumericLiteral */ && binop.operand2.nodeType === 7 /* NumericLiteral */) { - declarator.setVarFlags(declarator.getVarFlags() | 4096 /* Constant */); - } - } else if (memberValue.nodeType === 20 /* Name */) { - var nameNode = memberValue; - for (var j = 0; j < memberNames.length; j++) { - memberName = memberNames[j]; - if (memberName.text === nameNode.text) { - declarator.setVarFlags(declarator.getVarFlags() | 4096 /* Constant */); - break; - } - } - } - - var declarators = new TypeScript.ASTList(); - declarators.append(declarator); - var declaration = new TypeScript.VariableDeclaration(declarators); - this.setSpanExplicit(declaration, memberStart, this.position); - - var statement = new TypeScript.VariableStatement(declaration); - statement.setFlags(16 /* EnumElement */); - this.setSpanExplicit(statement, memberStart, this.position); - - members.append(statement); - memberNames.push(memberName); - - declarator.setVarFlags(declarator.getVarFlags() | 1 /* Exported */); - } - } - - var closeBracePosition = this.position; - this.movePast(node.closeBraceToken); - var closeBraceSpan = new TypeScript.ASTSpan(); - this.setSpan(closeBraceSpan, closeBracePosition, node.closeBraceToken); - - var modDecl = new TypeScript.ModuleDeclaration(name, members, closeBraceSpan); - this.setSpan(modDecl, start, node); - - modDecl.preComments = preComments; - modDecl.postComments = postComments; - modDecl.setModuleFlags(modDecl.getModuleFlags() | 128 /* IsEnum */); - - if (!this.containingModuleHasExportAssignment && (TypeScript.SyntaxUtilities.containsToken(node.modifiers, 47 /* ExportKeyword */) || this.isParsingAmbientModule)) { - modDecl.setModuleFlags(modDecl.getModuleFlags() | 1 /* Exported */); - } - - return modDecl; - }; - - SyntaxTreeToAstVisitor.prototype.visitEnumElement = function (node) { - throw TypeScript.Errors.invalidOperation(); - }; - - SyntaxTreeToAstVisitor.prototype.visitImportDeclaration = function (node) { - this.assertElementAtPosition(node); - - var start = this.position; - var result = this.getAST(node); - if (result) { - this.movePast(node); - } else { - var preComments = this.convertNodeLeadingComments(node, start); - var postComments = this.convertNodeTrailingComments(node, start); - - this.moveTo(node, node.identifier); - var name = this.identifierFromToken(node.identifier, false, true); - this.movePast(node.identifier); - this.movePast(node.equalsToken); - var alias = node.moduleReference.accept(this); - this.movePast(node.semicolonToken); - - result = new TypeScript.ImportDeclaration(name, alias); - - result.preComments = preComments; - result.postComments = postComments; - result.isDynamicImport = node.moduleReference.kind() === 245 /* ExternalModuleReference */; - } - - this.setAST(node, result); - this.setSpan(result, start, node); - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitExportAssignment = function (node) { - this.assertElementAtPosition(node); - - var start = this.position; - var result = this.getAST(node); - if (result) { - this.movePast(node); - } else { - this.moveTo(node, node.identifier); - var name = this.identifierFromToken(node.identifier, false, true); - this.movePast(node.identifier); - this.movePast(node.semicolonToken); - - result = new TypeScript.ExportAssignment(name); - } - - this.setAST(node, result); - this.setSpan(result, start, node); - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitVariableStatement = function (node) { - this.assertElementAtPosition(node); - - var start = this.position; - - var preComments = null; - if (node.modifiers.childCount() > 0) { - preComments = this.convertTokenLeadingComments(node.modifiers.firstToken(), start); - } - - this.moveTo(node, node.variableDeclaration); - - var declaration = node.variableDeclaration.accept(this); - this.movePast(node.semicolonToken); - - for (var i = 0, n = declaration.declarators.members.length; i < n; i++) { - var varDecl = declaration.declarators.members[i]; - - if (i === 0) { - varDecl.preComments = this.mergeComments(preComments, varDecl.preComments); - } - - if (!this.containingModuleHasExportAssignment && (TypeScript.SyntaxUtilities.containsToken(node.modifiers, 47 /* ExportKeyword */) || this.isParsingAmbientModule)) { - varDecl.setVarFlags(varDecl.getVarFlags() | 1 /* Exported */); - } else { - varDecl.setVarFlags(varDecl.getVarFlags() & ~1 /* Exported */); - } - - if (TypeScript.SyntaxUtilities.containsToken(node.modifiers, 64 /* DeclareKeyword */) || this.isParsingAmbientModule || this.isParsingDeclareFile) { - varDecl.setVarFlags(varDecl.getVarFlags() | 8 /* Ambient */); - } else { - varDecl.setVarFlags(varDecl.getVarFlags() & ~8 /* Ambient */); - } - } - - var result = new TypeScript.VariableStatement(declaration); - - this.setSpan(result, start, node); - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitVariableDeclaration = function (node) { - this.assertElementAtPosition(node); - - var start = this.position; - - var preComments = this.convertNodeLeadingComments(node, start); - var postComments = this.convertNodeTrailingComments(node, start); - - this.moveTo(node, node.variableDeclarators); - var variableDecls = this.visitSeparatedSyntaxList(node.variableDeclarators); - - for (var i = 0; i < variableDecls.members.length; i++) { - if (i === 0) { - variableDecls.members[i].preComments = preComments; - variableDecls.members[i].postComments = postComments; - } - } - - var result = new TypeScript.VariableDeclaration(variableDecls); - this.setSpan(result, start, node); - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitVariableDeclarator = function (node) { - this.assertElementAtPosition(node); - - var start = this.position; - var name = this.identifierFromToken(node.identifier, false, true); - this.movePast(node.identifier); - var typeExpr = node.typeAnnotation ? node.typeAnnotation.accept(this) : null; - var init = node.equalsValueClause ? node.equalsValueClause.accept(this) : null; - - var result = new TypeScript.VariableDeclarator(name); - this.setSpan(result, start, node); - - result.typeExpr = typeExpr; - result.init = init; - if (init && init.nodeType === 12 /* FunctionDeclaration */) { - var funcDecl = init; - funcDecl.hint = name.actualText; - } - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitEqualsValueClause = function (node) { - this.assertElementAtPosition(node); - - this.previousTokenTrailingComments = this.convertTokenTrailingComments(node.equalsToken, this.position + node.equalsToken.leadingTriviaWidth() + node.equalsToken.width()); - - this.movePast(node.equalsToken); - var result = node.value.accept(this); - - this.previousTokenTrailingComments = null; - return result; - }; - - SyntaxTreeToAstVisitor.prototype.getUnaryExpressionNodeType = function (kind) { - switch (kind) { - case 163 /* PlusExpression */: - return 26 /* PlusExpression */; - case 164 /* NegateExpression */: - return 27 /* NegateExpression */; - case 165 /* BitwiseNotExpression */: - return 72 /* BitwiseNotExpression */; - case 166 /* LogicalNotExpression */: - return 73 /* LogicalNotExpression */; - case 167 /* PreIncrementExpression */: - return 74 /* PreIncrementExpression */; - case 168 /* PreDecrementExpression */: - return 75 /* PreDecrementExpression */; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - SyntaxTreeToAstVisitor.prototype.visitPrefixUnaryExpression = function (node) { - this.assertElementAtPosition(node); - - var start = this.position; - var result = this.getAST(node); - if (result) { - this.movePast(node); - } else { - this.movePast(node.operatorToken); - var operand = node.operand.accept(this); - - result = new TypeScript.UnaryExpression(this.getUnaryExpressionNodeType(node.kind()), operand); - } - - this.setAST(node, result); - this.setSpan(result, start, node); - return result; - }; - - SyntaxTreeToAstVisitor.prototype.isOnSingleLine = function (start, end) { - return this.lineMap.getLineNumberFromPosition(start) === this.lineMap.getLineNumberFromPosition(end); - }; - - SyntaxTreeToAstVisitor.prototype.visitArrayLiteralExpression = function (node) { - this.assertElementAtPosition(node); - - var start = this.position; - var result = this.getAST(node); - if (result) { - this.movePast(node); - } else { - var openStart = this.position + node.openBracketToken.leadingTriviaWidth(); - this.movePast(node.openBracketToken); - - var expressions = this.visitSeparatedSyntaxList(node.expressions); - - var closeStart = this.position + node.closeBracketToken.leadingTriviaWidth(); - this.movePast(node.closeBracketToken); - - TypeScript.Debug.assert(expressions !== null); - result = new TypeScript.UnaryExpression(21 /* ArrayLiteralExpression */, expressions); - - if (this.isOnSingleLine(openStart, closeStart)) { - result.setFlags(result.getFlags() | 2 /* SingleLine */); - } - } - - this.setAST(node, result); - this.setSpan(result, start, node); - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitOmittedExpression = function (node) { - this.assertElementAtPosition(node); - - var start = this.position; - var result = this.getAST(node); - if (result) { - this.movePast(node); - } else { - result = new TypeScript.OmittedExpression(); - } - - this.setAST(node, result); - this.setSpan(result, start, node); - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitParenthesizedExpression = function (node) { - this.assertElementAtPosition(node); - - var start = this.position; - var result = this.getAST(node); - if (result) { - this.movePast(node); - } else { - this.movePast(node.openParenToken); - var expr = node.expression.accept(this); - this.movePast(node.closeParenToken); - - result = new TypeScript.ParenthesizedExpression(expr); - } - - this.setAST(node, result); - this.setSpan(result, start, node); - return result; - }; - - SyntaxTreeToAstVisitor.prototype.getArrowFunctionStatements = function (body) { - if (body.kind() === 145 /* Block */) { - return body.accept(this); - } else { - var statements = new TypeScript.ASTList(); - var expression = body.accept(this); - var returnStatement = new TypeScript.ReturnStatement(expression); - - returnStatement.preComments = expression.preComments; - expression.preComments = null; - - statements.append(returnStatement); - var block = new TypeScript.Block(statements); - block.closeBraceSpan = statements.members[0]; - return block; - } - }; - - SyntaxTreeToAstVisitor.prototype.visitSimpleArrowFunctionExpression = function (node) { - this.assertElementAtPosition(node); - - var start = this.position; - var result = this.getAST(node); - if (result) { - this.movePast(node); - } else { - var identifier = this.identifierFromToken(node.identifier, false, true); - this.movePast(node.identifier); - this.movePast(node.equalsGreaterThanToken); - - var parameters = new TypeScript.ASTList(); - - var parameter = new TypeScript.Parameter(identifier); - this.setSpanExplicit(parameter, identifier.minChar, identifier.limChar); - - parameters.append(parameter); - - var statements = this.getArrowFunctionStatements(node.body); - - result = new TypeScript.FunctionDeclaration(null, statements, false, null, parameters, 12 /* FunctionDeclaration */); - - result.returnTypeAnnotation = null; - result.setFunctionFlags(result.getFunctionFlags() | 8192 /* IsFunctionExpression */); - result.setFunctionFlags(result.getFunctionFlags() | 2048 /* IsFatArrowFunction */); - } - - this.setAST(node, result); - this.setSpan(result, start, node); - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitParenthesizedArrowFunctionExpression = function (node) { - this.assertElementAtPosition(node); - - var start = this.position; - var result = this.getAST(node); - if (result) { - this.movePast(node); - } else { - var preComments = this.convertNodeLeadingComments(node, start); - - var typeParameters = node.callSignature.typeParameterList === null ? null : node.callSignature.typeParameterList.accept(this); - var parameters = node.callSignature.parameterList.accept(this); - var returnType = node.callSignature.typeAnnotation ? node.callSignature.typeAnnotation.accept(this) : null; - this.movePast(node.equalsGreaterThanToken); - - var block = this.getArrowFunctionStatements(node.body); - - result = new TypeScript.FunctionDeclaration(null, block, false, typeParameters, parameters, 12 /* FunctionDeclaration */); - - result.preComments = preComments; - result.returnTypeAnnotation = returnType; - result.setFunctionFlags(result.getFunctionFlags() | 8192 /* IsFunctionExpression */); - result.setFunctionFlags(result.getFunctionFlags() | 2048 /* IsFatArrowFunction */); - result.variableArgList = this.hasDotDotDotParameter(node.callSignature.parameterList.parameters); - } - - this.setAST(node, result); - this.setSpan(result, start, node); - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitType = function (type) { - this.assertElementAtPosition(type); - - var result; - if (type.isToken()) { - var start = this.position; - result = new TypeScript.TypeReference(type.accept(this), 0); - this.setSpan(result, start, type); - } else { - result = type.accept(this); - } - - TypeScript.Debug.assert(result.nodeType === 11 /* TypeRef */); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitQualifiedName = function (node) { - this.assertElementAtPosition(node); - - var start = this.position; - var result = this.getAST(node); - if (result) { - this.movePast(node); - } else { - var left = this.visitType(node.left).term; - this.movePast(node.dotToken); - var right = this.identifierFromToken(node.right, false, true); - this.movePast(node.right); - - var term = new TypeScript.BinaryExpression(32 /* MemberAccessExpression */, left, right); - this.setSpan(term, start, node); - - result = new TypeScript.TypeReference(term, 0); - } - - this.setAST(node, result); - this.setSpan(result, start, node); - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitTypeArgumentList = function (node) { - this.assertElementAtPosition(node); - - var result = new TypeScript.ASTList(); - - this.movePast(node.lessThanToken); - - var start = this.position; - - for (var i = 0, n = node.typeArguments.childCount(); i < n; i++) { - if (i % 2 === 1) { - this.movePast(node.typeArguments.childAt(i)); - } else { - result.append(this.visitType(node.typeArguments.childAt(i))); - } - } - this.movePast(node.greaterThanToken); - - this.setSpan(result, start, node.typeArguments); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitConstructorType = function (node) { - this.assertElementAtPosition(node); - - var start = this.position; - var result = this.getAST(node); - if (result) { - this.movePast(node); - } else { - this.movePast(node.newKeyword); - var typeParameters = node.typeParameterList === null ? null : node.typeParameterList.accept(this); - var parameters = node.parameterList.accept(this); - this.movePast(node.equalsGreaterThanToken); - var returnType = node.type ? this.visitType(node.type) : null; - - var funcDecl = new TypeScript.FunctionDeclaration(null, null, false, typeParameters, parameters, 12 /* FunctionDeclaration */); - this.setSpan(funcDecl, start, node); - - funcDecl.returnTypeAnnotation = returnType; - funcDecl.setFunctionFlags(funcDecl.getFunctionFlags() | 128 /* Signature */); - funcDecl.variableArgList = this.hasDotDotDotParameter(node.parameterList.parameters); - - funcDecl.setFunctionFlags(funcDecl.getFunctionFlags() | 1024 /* ConstructMember */); - funcDecl.setFlags(funcDecl.getFlags() | 8 /* TypeReference */); - funcDecl.hint = "_construct"; - funcDecl.classDecl = null; - - result = new TypeScript.TypeReference(funcDecl, 0); - } - - this.setAST(node, result); - this.setSpan(result, start, node); - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitFunctionType = function (node) { - this.assertElementAtPosition(node); - - var start = this.position; - var result = this.getAST(node); - if (result) { - this.movePast(node); - } else { - var typeParameters = node.typeParameterList === null ? null : node.typeParameterList.accept(this); - var parameters = node.parameterList.accept(this); - this.movePast(node.equalsGreaterThanToken); - var returnType = node.type ? this.visitType(node.type) : null; - - var funcDecl = new TypeScript.FunctionDeclaration(null, null, false, typeParameters, parameters, 12 /* FunctionDeclaration */); - this.setSpan(funcDecl, start, node); - - funcDecl.returnTypeAnnotation = returnType; - - funcDecl.setFlags(funcDecl.getFunctionFlags() | 128 /* Signature */); - funcDecl.setFlags(funcDecl.getFlags() | 8 /* TypeReference */); - funcDecl.variableArgList = this.hasDotDotDotParameter(node.parameterList.parameters); - - result = new TypeScript.TypeReference(funcDecl, 0); - } - - this.setAST(node, result); - this.setSpan(result, start, node); - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitObjectType = function (node) { - this.assertElementAtPosition(node); - - var start = this.position; - var result = this.getAST(node); - if (result) { - this.movePast(node); - } else { - this.movePast(node.openBraceToken); - var typeMembers = this.visitSeparatedSyntaxList(node.typeMembers); - this.movePast(node.closeBraceToken); - - var interfaceDecl = new TypeScript.InterfaceDeclaration(new TypeScript.Identifier("__anonymous"), null, typeMembers, null, null); - this.setSpan(interfaceDecl, start, node); - - interfaceDecl.setFlags(interfaceDecl.getFlags() | 8 /* TypeReference */); - - result = new TypeScript.TypeReference(interfaceDecl, 0); - } - - this.setAST(node, result); - this.setSpan(result, start, node); - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitArrayType = function (node) { - this.assertElementAtPosition(node); - - var start = this.position; - var result = this.getAST(node); - if (result) { - this.movePast(node); - } else { - var underlying = this.visitType(node.type); - this.movePast(node.openBracketToken); - this.movePast(node.closeBracketToken); - - if (underlying.nodeType === 11 /* TypeRef */) { - result = underlying; - result.arrayCount++; - } else { - result = new TypeScript.TypeReference(underlying, 1); - } - - result.setFlags(result.getFlags() | 8 /* TypeReference */); - } - - this.setAST(node, result); - this.setSpan(result, start, node); - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitGenericType = function (node) { - this.assertElementAtPosition(node); - - var start = this.position; - var result = this.getAST(node); - if (result) { - this.movePast(node); - } else { - var underlying = this.visitType(node.name).term; - var typeArguments = node.typeArgumentList.accept(this); - - var genericType = new TypeScript.GenericType(underlying, typeArguments); - this.setSpan(genericType, start, node); - - genericType.setFlags(genericType.getFlags() | 8 /* TypeReference */); - - result = new TypeScript.TypeReference(genericType, 0); - } - - this.setAST(node, result); - this.setSpan(result, start, node); - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitTypeAnnotation = function (node) { - this.assertElementAtPosition(node); - - this.movePast(node.colonToken); - return this.visitType(node.type); - }; - - SyntaxTreeToAstVisitor.prototype.visitBlock = function (node) { - this.assertElementAtPosition(node); - - var start = this.position; - var result = this.getAST(node); - if (result) { - this.movePast(node); - } else { - this.movePast(node.openBraceToken); - var statements = this.visitSyntaxList(node.statements); - var closeBracePosition = this.position; - this.movePast(node.closeBraceToken); - var closeBraceSpan = new TypeScript.ASTSpan(); - this.setSpan(closeBraceSpan, closeBracePosition, node.closeBraceToken); - - result = new TypeScript.Block(statements); - result.closeBraceSpan = closeBraceSpan; - } - - this.setAST(node, result); - this.setSpan(result, start, node); - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitParameter = function (node) { - this.assertElementAtPosition(node); - - var start = this.position; - var result = this.getAST(node); - if (result) { - this.movePast(node); - } else { - var preComments = this.convertNodeLeadingComments(node, start); - var postComments = this.convertNodeTrailingComments(node, start); - - this.moveTo(node, node.identifier); - var identifier = this.identifierFromToken(node.identifier, !!node.questionToken, true); - this.movePast(node.identifier); - this.movePast(node.questionToken); - var typeExpr = node.typeAnnotation ? node.typeAnnotation.accept(this) : null; - var init = node.equalsValueClause ? node.equalsValueClause.accept(this) : null; - - result = new TypeScript.Parameter(identifier); - - result.preComments = preComments; - result.postComments = postComments; - result.isOptional = !!node.questionToken; - result.init = init; - result.typeExpr = typeExpr; - - if (node.publicOrPrivateKeyword) { - result.setVarFlags(result.getVarFlags() | 256 /* Property */); - - if (node.publicOrPrivateKeyword.kind() === 57 /* PublicKeyword */) { - result.setVarFlags(result.getVarFlags() | 4 /* Public */); - } else { - result.setVarFlags(result.getVarFlags() | 2 /* Private */); - } - } - - if (node.equalsValueClause || node.dotDotDotToken) { - result.setFlags(result.getFlags() | 4 /* OptionalName */); - } - } - - this.setAST(node, result); - this.setSpan(result, start, node); - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitMemberAccessExpression = function (node) { - this.assertElementAtPosition(node); - - var start = this.position; - var result = this.getAST(node); - if (result) { - this.movePast(node); - } else { - var expression = node.expression.accept(this); - this.movePast(node.dotToken); - var name = this.identifierFromToken(node.name, false, true); - this.movePast(node.name); - - result = new TypeScript.BinaryExpression(32 /* MemberAccessExpression */, expression, name); - } - - this.setAST(node, result); - this.setSpan(result, start, node); - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitPostfixUnaryExpression = function (node) { - this.assertElementAtPosition(node); - - var start = this.position; - var result = this.getAST(node); - if (result) { - this.movePast(node); - } else { - var operand = node.operand.accept(this); - this.movePast(node.operatorToken); - - result = new TypeScript.UnaryExpression(node.kind() === 209 /* PostIncrementExpression */ ? 76 /* PostIncrementExpression */ : 77 /* PostDecrementExpression */, operand); - } - - this.setAST(node, result); - this.setSpan(result, start, node); - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitElementAccessExpression = function (node) { - this.assertElementAtPosition(node); - - var start = this.position; - var result = this.getAST(node); - if (result) { - this.movePast(node); - } else { - var expression = node.expression.accept(this); - this.movePast(node.openBracketToken); - var argumentExpression = node.argumentExpression.accept(this); - this.movePast(node.closeBracketToken); - - result = new TypeScript.BinaryExpression(35 /* ElementAccessExpression */, expression, argumentExpression); - } - - this.setAST(node, result); - this.setSpan(result, start, node); - return result; - }; - - SyntaxTreeToAstVisitor.prototype.convertArgumentListArguments = function (node) { - if (node === null) { - return null; - } - - var start = this.position; - - this.movePast(node.openParenToken); - - var result = this.visitSeparatedSyntaxList(node.arguments); - - if (node.arguments.fullWidth() === 0 && node.closeParenToken.fullWidth() === 0) { - var openParenTokenEnd = start + node.openParenToken.leadingTriviaWidth() + node.openParenToken.width(); - this.setSpanExplicit(result, openParenTokenEnd, openParenTokenEnd + node.openParenToken.trailingTriviaWidth()); - } - - this.movePast(node.closeParenToken); - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitInvocationExpression = function (node) { - this.assertElementAtPosition(node); - - var start = this.position; - var result = this.getAST(node); - if (result) { - this.movePast(node); - } else { - var expression = node.expression.accept(this); - var typeArguments = node.argumentList.typeArgumentList !== null ? node.argumentList.typeArgumentList.accept(this) : null; - var argumentList = this.convertArgumentListArguments(node.argumentList); - - result = new TypeScript.CallExpression(36 /* InvocationExpression */, expression, typeArguments, argumentList); - } - - this.setAST(node, result); - this.setSpan(result, start, node); - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitArgumentList = function (node) { - throw TypeScript.Errors.invalidOperation(); - }; - - SyntaxTreeToAstVisitor.prototype.getBinaryExpressionNodeType = function (node) { - switch (node.kind()) { - case 172 /* CommaExpression */: - return 25 /* CommaExpression */; - case 173 /* AssignmentExpression */: - return 38 /* AssignmentExpression */; - case 174 /* AddAssignmentExpression */: - return 39 /* AddAssignmentExpression */; - case 175 /* SubtractAssignmentExpression */: - return 40 /* SubtractAssignmentExpression */; - case 176 /* MultiplyAssignmentExpression */: - return 42 /* MultiplyAssignmentExpression */; - case 177 /* DivideAssignmentExpression */: - return 41 /* DivideAssignmentExpression */; - case 178 /* ModuloAssignmentExpression */: - return 43 /* ModuloAssignmentExpression */; - case 179 /* AndAssignmentExpression */: - return 44 /* AndAssignmentExpression */; - case 180 /* ExclusiveOrAssignmentExpression */: - return 45 /* ExclusiveOrAssignmentExpression */; - case 181 /* OrAssignmentExpression */: - return 46 /* OrAssignmentExpression */; - case 182 /* LeftShiftAssignmentExpression */: - return 47 /* LeftShiftAssignmentExpression */; - case 183 /* SignedRightShiftAssignmentExpression */: - return 48 /* SignedRightShiftAssignmentExpression */; - case 184 /* UnsignedRightShiftAssignmentExpression */: - return 49 /* UnsignedRightShiftAssignmentExpression */; - case 186 /* LogicalOrExpression */: - return 51 /* LogicalOrExpression */; - case 187 /* LogicalAndExpression */: - return 52 /* LogicalAndExpression */; - case 188 /* BitwiseOrExpression */: - return 53 /* BitwiseOrExpression */; - case 189 /* BitwiseExclusiveOrExpression */: - return 54 /* BitwiseExclusiveOrExpression */; - case 190 /* BitwiseAndExpression */: - return 55 /* BitwiseAndExpression */; - case 191 /* EqualsWithTypeConversionExpression */: - return 56 /* EqualsWithTypeConversionExpression */; - case 192 /* NotEqualsWithTypeConversionExpression */: - return 57 /* NotEqualsWithTypeConversionExpression */; - case 193 /* EqualsExpression */: - return 58 /* EqualsExpression */; - case 194 /* NotEqualsExpression */: - return 59 /* NotEqualsExpression */; - case 195 /* LessThanExpression */: - return 60 /* LessThanExpression */; - case 196 /* GreaterThanExpression */: - return 62 /* GreaterThanExpression */; - case 197 /* LessThanOrEqualExpression */: - return 61 /* LessThanOrEqualExpression */; - case 198 /* GreaterThanOrEqualExpression */: - return 63 /* GreaterThanOrEqualExpression */; - case 199 /* InstanceOfExpression */: - return 33 /* InstanceOfExpression */; - case 200 /* InExpression */: - return 31 /* InExpression */; - case 201 /* LeftShiftExpression */: - return 69 /* LeftShiftExpression */; - case 202 /* SignedRightShiftExpression */: - return 70 /* SignedRightShiftExpression */; - case 203 /* UnsignedRightShiftExpression */: - return 71 /* UnsignedRightShiftExpression */; - case 204 /* MultiplyExpression */: - return 66 /* MultiplyExpression */; - case 205 /* DivideExpression */: - return 67 /* DivideExpression */; - case 206 /* ModuloExpression */: - return 68 /* ModuloExpression */; - case 207 /* AddExpression */: - return 64 /* AddExpression */; - case 208 /* SubtractExpression */: - return 65 /* SubtractExpression */; - } - - throw TypeScript.Errors.invalidOperation(); - }; - - SyntaxTreeToAstVisitor.prototype.visitBinaryExpression = function (node) { - this.assertElementAtPosition(node); - - var start = this.position; - var result = this.getAST(node); - if (result) { - this.movePast(node); - } else { - var nodeType = this.getBinaryExpressionNodeType(node); - var left = node.left.accept(this); - this.movePast(node.operatorToken); - var right = node.right.accept(this); - - result = new TypeScript.BinaryExpression(nodeType, left, right); - - if (right.nodeType === 12 /* FunctionDeclaration */) { - var id = left.nodeType === 32 /* MemberAccessExpression */ ? (left).operand2 : left; - var idHint = id.nodeType === 20 /* Name */ ? id.actualText : null; - - var funcDecl = right; - funcDecl.hint = idHint; - } - } - - this.setAST(node, result); - this.setSpan(result, start, node); - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitConditionalExpression = function (node) { - this.assertElementAtPosition(node); - - var start = this.position; - var result = this.getAST(node); - if (result) { - this.movePast(node); - } else { - var condition = node.condition.accept(this); - this.movePast(node.questionToken); - var whenTrue = node.whenTrue.accept(this); - this.movePast(node.colonToken); - var whenFalse = node.whenFalse.accept(this); - - result = new TypeScript.ConditionalExpression(condition, whenTrue, whenFalse); - } - - this.setAST(node, result); - this.setSpan(result, start, node); - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitConstructSignature = function (node) { - this.assertElementAtPosition(node); - - var start = this.position; - var result = this.getAST(node); - if (result) { - this.movePast(node); - } else { - var preComments = this.convertNodeLeadingComments(node, start); - - this.movePast(node.newKeyword); - var typeParameters = node.callSignature.typeParameterList === null ? null : node.callSignature.typeParameterList.accept(this); - var parameters = node.callSignature.parameterList.accept(this); - var returnType = node.callSignature.typeAnnotation ? node.callSignature.typeAnnotation.accept(this) : null; - - result = new TypeScript.FunctionDeclaration(null, null, false, typeParameters, parameters, 12 /* FunctionDeclaration */); - - result.preComments = preComments; - result.returnTypeAnnotation = returnType; - - result.hint = "_construct"; - result.setFunctionFlags(result.getFunctionFlags() | 1024 /* ConstructMember */); - result.setFunctionFlags(result.getFunctionFlags() | 256 /* Method */); - result.setFunctionFlags(result.getFunctionFlags() | 128 /* Signature */); - result.variableArgList = this.hasDotDotDotParameter(node.callSignature.parameterList.parameters); - } - - this.setAST(node, result); - this.setSpan(result, start, node); - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitMethodSignature = function (node) { - this.assertElementAtPosition(node); - - var start = this.position; - var result = this.getAST(node); - if (result) { - this.movePast(node); - } else { - var preComments = this.convertNodeLeadingComments(node, start); - - var name = this.identifierFromToken(node.propertyName, !!node.questionToken, true); - this.movePast(node.propertyName); - this.movePast(node.questionToken); - - var typeParameters = node.callSignature.typeParameterList ? node.callSignature.typeParameterList.accept(this) : null; - var parameters = node.callSignature.parameterList.accept(this); - var returnType = node.callSignature.typeAnnotation ? node.callSignature.typeAnnotation.accept(this) : null; - - result = new TypeScript.FunctionDeclaration(name, null, false, typeParameters, parameters, 12 /* FunctionDeclaration */); - - result.preComments = preComments; - result.variableArgList = this.hasDotDotDotParameter(node.callSignature.parameterList.parameters); - result.returnTypeAnnotation = returnType; - result.setFunctionFlags(result.getFunctionFlags() | 256 /* Method */); - result.setFunctionFlags(result.getFunctionFlags() | 128 /* Signature */); - } - - this.setAST(node, result); - this.setSpan(result, start, node); - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitIndexSignature = function (node) { - this.assertElementAtPosition(node); - - var start = this.position; - var result = this.getAST(node); - if (result) { - this.movePast(node); - } else { - var preComments = this.convertNodeLeadingComments(node, start); - - this.movePast(node.openBracketToken); - - var parameter = node.parameter.accept(this); - - this.movePast(node.closeBracketToken); - var returnType = node.typeAnnotation ? node.typeAnnotation.accept(this) : null; - - var name = new TypeScript.Identifier("__item"); - this.setSpanExplicit(name, start, start); - - var parameters = new TypeScript.ASTList(); - parameters.append(parameter); - - result = new TypeScript.FunctionDeclaration(name, null, false, null, parameters, 12 /* FunctionDeclaration */); - - result.preComments = preComments; - result.variableArgList = false; - result.returnTypeAnnotation = returnType; - - result.setFunctionFlags(result.getFunctionFlags() | 4096 /* IndexerMember */); - result.setFunctionFlags(result.getFunctionFlags() | 256 /* Method */); - result.setFunctionFlags(result.getFunctionFlags() | 128 /* Signature */); - } - - this.setAST(node, result); - this.setSpan(result, start, node); - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitPropertySignature = function (node) { - this.assertElementAtPosition(node); - - var start = this.position; - var result = this.getAST(node); - if (result) { - this.movePast(node); - } else { - var preComments = this.convertNodeLeadingComments(node, start); - - var name = this.identifierFromToken(node.propertyName, !!node.questionToken, true); - this.movePast(node.propertyName); - this.movePast(node.questionToken); - var typeExpr = node.typeAnnotation ? node.typeAnnotation.accept(this) : null; - - result = new TypeScript.VariableDeclarator(name); - - result.preComments = preComments; - result.typeExpr = typeExpr; - result.setVarFlags(result.getVarFlags() | 256 /* Property */); - } - - this.setAST(node, result); - this.setSpan(result, start, node); - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitParameterList = function (node) { - this.assertElementAtPosition(node); - - var start = this.position; - - var openParenToken = node.openParenToken; - this.previousTokenTrailingComments = this.convertTokenTrailingComments(openParenToken, start + openParenToken.leadingTriviaWidth() + openParenToken.width()); - - this.movePast(node.openParenToken); - var result = this.visitSeparatedSyntaxList(node.parameters); - this.movePast(node.closeParenToken); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitCallSignature = function (node) { - this.assertElementAtPosition(node); - - var start = this.position; - var result = this.getAST(node); - if (result) { - this.movePast(node); - } else { - var preComments = this.convertNodeLeadingComments(node, start); - - var typeParameters = node.typeParameterList === null ? null : node.typeParameterList.accept(this); - var parameters = node.parameterList.accept(this); - var returnType = node.typeAnnotation ? node.typeAnnotation.accept(this) : null; - - result = new TypeScript.FunctionDeclaration(null, null, false, typeParameters, parameters, 12 /* FunctionDeclaration */); - - result.preComments = preComments; - result.variableArgList = this.hasDotDotDotParameter(node.parameterList.parameters); - result.returnTypeAnnotation = returnType; - - result.hint = "_call"; - result.setFunctionFlags(result.getFunctionFlags() | 512 /* CallMember */); - result.setFunctionFlags(result.getFunctionFlags() | 256 /* Method */); - result.setFunctionFlags(result.getFunctionFlags() | 128 /* Signature */); - } - - this.setAST(node, result); - this.setSpan(result, start, node); - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitTypeParameterList = function (node) { - this.assertElementAtPosition(node); - - this.movePast(node.lessThanToken); - var result = this.visitSeparatedSyntaxList(node.typeParameters); - this.movePast(node.greaterThanToken); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitTypeParameter = function (node) { - this.assertElementAtPosition(node); - - var start = this.position; - var result = this.getAST(node); - if (result) { - this.movePast(node); - } else { - var identifier = this.identifierFromToken(node.identifier, false, true); - this.movePast(node.identifier); - var constraint = node.constraint ? node.constraint.accept(this) : null; - - result = new TypeScript.TypeParameter(identifier, constraint); - } - - this.setAST(node, result); - this.setSpan(result, start, node); - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitConstraint = function (node) { - this.assertElementAtPosition(node); - - this.movePast(node.extendsKeyword); - return this.visitType(node.type); - }; - - SyntaxTreeToAstVisitor.prototype.visitIfStatement = function (node) { - this.assertElementAtPosition(node); - - var start = this.position; - var result = this.getAST(node); - if (result) { - this.movePast(node); - } else { - this.moveTo(node, node.condition); - var condition = node.condition.accept(this); - this.movePast(node.closeParenToken); - var thenBod = node.statement.accept(this); - var elseBod = node.elseClause ? node.elseClause.accept(this) : null; - - result = new TypeScript.IfStatement(condition, thenBod, elseBod); - } - - this.setAST(node, result); - this.setSpan(result, start, node); - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitElseClause = function (node) { - this.assertElementAtPosition(node); - - this.movePast(node.elseKeyword); - return node.statement.accept(this); - }; - - SyntaxTreeToAstVisitor.prototype.visitExpressionStatement = function (node) { - this.assertElementAtPosition(node); - - var start = this.position; - var result = this.getAST(node); - if (result) { - this.movePast(node); - } else { - var preComments = this.convertNodeLeadingComments(node, start); - var postComments = this.convertNodeTrailingComments(node, start); - - var expression = node.expression.accept(this); - this.movePast(node.semicolonToken); - - result = new TypeScript.ExpressionStatement(expression); - result.preComments = preComments; - result.postComments = postComments; - } - - this.setAST(node, result); - this.setSpan(result, start, node); - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitConstructorDeclaration = function (node) { - this.assertElementAtPosition(node); - - var start = this.position; - var result = this.getAST(node); - if (result) { - this.movePast(node); - } else { - var preComments = this.convertNodeLeadingComments(node, start); - var postComments = this.convertNodeTrailingComments(node, start); - - this.moveTo(node, node.parameterList); - var parameters = node.parameterList.accept(this); - - var block = node.block ? node.block.accept(this) : null; - - this.movePast(node.semicolonToken); - - result = new TypeScript.FunctionDeclaration(null, block, true, null, parameters, 12 /* FunctionDeclaration */); - - result.preComments = preComments; - result.postComments = postComments; - result.variableArgList = this.hasDotDotDotParameter(node.parameterList.parameters); - - if (node.semicolonToken) { - result.setFunctionFlags(result.getFunctionFlags() | 128 /* Signature */); - } - } - - this.setAST(node, result); - this.setSpan(result, start, node); - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitMemberFunctionDeclaration = function (node) { - this.assertElementAtPosition(node); - - var start = this.position; - var result = this.getAST(node); - if (result) { - this.movePast(node); - } else { - var preComments = this.convertNodeLeadingComments(node, start); - var postComments = this.convertNodeTrailingComments(node, start); - - this.moveTo(node, node.propertyName); - var name = this.identifierFromToken(node.propertyName, false, true); - - this.movePast(node.propertyName); - - var typeParameters = node.callSignature.typeParameterList === null ? null : node.callSignature.typeParameterList.accept(this); - var parameters = node.callSignature.parameterList.accept(this); - var returnType = node.callSignature.typeAnnotation ? node.callSignature.typeAnnotation.accept(this) : null; - - var block = node.block ? node.block.accept(this) : null; - this.movePast(node.semicolonToken); - - result = new TypeScript.FunctionDeclaration(name, block, false, typeParameters, parameters, 12 /* FunctionDeclaration */); - - result.preComments = preComments; - result.postComments = postComments; - result.variableArgList = this.hasDotDotDotParameter(node.callSignature.parameterList.parameters); - result.returnTypeAnnotation = returnType; - - if (node.semicolonToken) { - result.setFunctionFlags(result.getFunctionFlags() | 128 /* Signature */); - } - - if (TypeScript.SyntaxUtilities.containsToken(node.modifiers, 55 /* PrivateKeyword */)) { - result.setFunctionFlags(result.getFunctionFlags() | 2 /* Private */); - } else { - result.setFunctionFlags(result.getFunctionFlags() | 4 /* Public */); - } - - if (TypeScript.SyntaxUtilities.containsToken(node.modifiers, 58 /* StaticKeyword */)) { - result.setFunctionFlags(result.getFunctionFlags() | 16 /* Static */); - } - - result.setFunctionFlags(result.getFunctionFlags() | 256 /* Method */); - } - - this.setAST(node, result); - this.setSpan(result, start, node); - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitMemberAccessorDeclaration = function (node, typeAnnotation) { - this.assertElementAtPosition(node); - - var start = this.position; - var result = this.getAST(node); - if (result) { - this.movePast(node); - } else { - var preComments = this.convertNodeLeadingComments(node, start); - var postComments = this.convertNodeTrailingComments(node, start); - - this.moveTo(node, node.propertyName); - var name = this.identifierFromToken(node.propertyName, false, true); - this.movePast(node.propertyName); - var parameters = node.parameterList.accept(this); - var returnType = typeAnnotation ? typeAnnotation.accept(this) : null; - - var block = node.block ? node.block.accept(this) : null; - result = new TypeScript.FunctionDeclaration(name, block, false, null, parameters, 12 /* FunctionDeclaration */); - - result.preComments = preComments; - result.postComments = postComments; - result.variableArgList = this.hasDotDotDotParameter(node.parameterList.parameters); - result.returnTypeAnnotation = returnType; - - if (TypeScript.SyntaxUtilities.containsToken(node.modifiers, 55 /* PrivateKeyword */)) { - result.setFunctionFlags(result.getFunctionFlags() | 2 /* Private */); - } else { - result.setFunctionFlags(result.getFunctionFlags() | 4 /* Public */); - } - - if (TypeScript.SyntaxUtilities.containsToken(node.modifiers, 58 /* StaticKeyword */)) { - result.setFunctionFlags(result.getFunctionFlags() | 16 /* Static */); - } - - result.setFunctionFlags(result.getFunctionFlags() | 256 /* Method */); - } - - this.setAST(node, result); - this.setSpan(result, start, node); - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitGetMemberAccessorDeclaration = function (node) { - this.assertElementAtPosition(node); - - var result = this.visitMemberAccessorDeclaration(node, node.typeAnnotation); - - result.setFunctionFlags(result.getFunctionFlags() | 32 /* GetAccessor */); - result.hint = "get" + result.name.actualText; - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitSetMemberAccessorDeclaration = function (node) { - this.assertElementAtPosition(node); - - var result = this.visitMemberAccessorDeclaration(node, null); - - result.setFunctionFlags(result.getFunctionFlags() | 64 /* SetAccessor */); - result.hint = "set" + result.name.actualText; - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitMemberVariableDeclaration = function (node) { - this.assertElementAtPosition(node); - - var start = this.position; - var result = this.getAST(node); - if (result) { - this.movePast(node); - } else { - var preComments = this.convertNodeLeadingComments(node, start); - var postComments = this.convertNodeTrailingComments(node, start); - - this.moveTo(node, node.variableDeclarator); - this.moveTo(node.variableDeclarator, node.variableDeclarator.identifier); - - var name = this.identifierFromToken(node.variableDeclarator.identifier, false, true); - this.movePast(node.variableDeclarator.identifier); - var typeExpr = node.variableDeclarator.typeAnnotation ? node.variableDeclarator.typeAnnotation.accept(this) : null; - var init = node.variableDeclarator.equalsValueClause ? node.variableDeclarator.equalsValueClause.accept(this) : null; - this.movePast(node.semicolonToken); - - result = new TypeScript.VariableDeclarator(name); - - result.preComments = preComments; - result.postComments = postComments; - result.typeExpr = typeExpr; - result.init = init; - - if (TypeScript.SyntaxUtilities.containsToken(node.modifiers, 58 /* StaticKeyword */)) { - result.setVarFlags(result.getVarFlags() | 16 /* Static */); - } - - if (TypeScript.SyntaxUtilities.containsToken(node.modifiers, 55 /* PrivateKeyword */)) { - result.setVarFlags(result.getVarFlags() | 2 /* Private */); - } else { - result.setVarFlags(result.getVarFlags() | 4 /* Public */); - } - - result.setVarFlags(result.getVarFlags() | 2048 /* ClassProperty */); - } - - this.setAST(node, result); - this.setSpan(result, start, node); - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitThrowStatement = function (node) { - this.assertElementAtPosition(node); - - var start = this.position; - var result = this.getAST(node); - if (result) { - this.movePast(node); - } else { - this.movePast(node.throwKeyword); - var expression = node.expression.accept(this); - this.movePast(node.semicolonToken); - - result = new TypeScript.ThrowStatement(expression); - } - - this.setAST(node, result); - this.setSpan(result, start, node); - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitReturnStatement = function (node) { - this.assertElementAtPosition(node); - - var start = this.position; - - var result = this.getAST(node); - if (result) { - this.movePast(node); - } else { - var preComments = this.convertNodeLeadingComments(node, start); - var postComments = this.convertNodeTrailingComments(node, start); - - this.movePast(node.returnKeyword); - var expression = node.expression ? node.expression.accept(this) : null; - this.movePast(node.semicolonToken); - - result = new TypeScript.ReturnStatement(expression); - result.preComments = preComments; - result.postComments = postComments; - } - - this.setAST(node, result); - this.setSpan(result, start, node); - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitObjectCreationExpression = function (node) { - this.assertElementAtPosition(node); - - var start = this.position; - var result = this.getAST(node); - if (result) { - this.movePast(node); - } else { - this.movePast(node.newKeyword); - var expression = node.expression.accept(this); - var typeArgumentList = node.argumentList === null || node.argumentList.typeArgumentList === null ? null : node.argumentList.typeArgumentList.accept(this); - var argumentList = this.convertArgumentListArguments(node.argumentList); - - result = new TypeScript.CallExpression(37 /* ObjectCreationExpression */, expression, typeArgumentList, argumentList); - - if (expression.nodeType === 11 /* TypeRef */) { - var typeRef = expression; - - if (typeRef.arrayCount === 0) { - var term = typeRef.term; - if (term.nodeType === 32 /* MemberAccessExpression */ || term.nodeType === 20 /* Name */) { - expression = term; - } - } - } - } - - this.setAST(node, result); - this.setSpan(result, start, node); - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitSwitchStatement = function (node) { - this.assertElementAtPosition(node); - - var start = this.position; - var result = this.getAST(node); - if (result) { - this.movePast(node); - } else { - this.movePast(node.switchKeyword); - this.movePast(node.openParenToken); - var expression = node.expression.accept(this); - this.movePast(node.closeParenToken); - var closeParenPosition = this.position; - this.movePast(node.openBraceToken); - - result = new TypeScript.SwitchStatement(expression); - - result.statement.minChar = start; - result.statement.limChar = closeParenPosition; - - result.caseList = new TypeScript.ASTList(); - - for (var i = 0, n = node.switchClauses.childCount(); i < n; i++) { - var switchClause = node.switchClauses.childAt(i); - var translated = switchClause.accept(this); - - if (switchClause.kind() === 232 /* DefaultSwitchClause */) { - result.defaultCase = translated; - } - - result.caseList.append(translated); - } - - this.movePast(node.closeBraceToken); - } - - this.setAST(node, result); - this.setSpan(result, start, node); - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitCaseSwitchClause = function (node) { - this.assertElementAtPosition(node); - - var start = this.position; - var result = this.getAST(node); - if (result) { - this.movePast(node); - } else { - this.movePast(node.caseKeyword); - var expression = node.expression.accept(this); - this.movePast(node.colonToken); - var statements = this.visitSyntaxList(node.statements); - - result = new TypeScript.CaseClause(); - - result.expr = expression; - result.body = statements; - } - - this.setAST(node, result); - this.setSpan(result, start, node); - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitDefaultSwitchClause = function (node) { - this.assertElementAtPosition(node); - - var start = this.position; - var result = this.getAST(node); - if (result) { - this.movePast(node); - } else { - this.movePast(node.defaultKeyword); - this.movePast(node.colonToken); - var statements = this.visitSyntaxList(node.statements); - - result = new TypeScript.CaseClause(); - result.body = statements; - } - - this.setAST(node, result); - this.setSpan(result, start, node); - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitBreakStatement = function (node) { - this.assertElementAtPosition(node); - - var start = this.position; - var result = this.getAST(node); - if (result) { - this.movePast(node); - } else { - this.movePast(node.breakKeyword); - this.movePast(node.identifier); - this.movePast(node.semicolonToken); - - result = new TypeScript.Jump(82 /* BreakStatement */); - - if (node.identifier !== null) { - result.target = node.identifier.valueText(); - } - } - - this.setAST(node, result); - this.setSpan(result, start, node); - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitContinueStatement = function (node) { - this.assertElementAtPosition(node); - - var start = this.position; - var result = this.getAST(node); - if (result) { - this.movePast(node); - } else { - this.movePast(node.continueKeyword); - this.movePast(node.identifier); - this.movePast(node.semicolonToken); - - result = new TypeScript.Jump(83 /* ContinueStatement */); - - if (node.identifier !== null) { - result.target = node.identifier.valueText(); - } - } - - this.setAST(node, result); - this.setSpan(result, start, node); - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitForStatement = function (node) { - this.assertElementAtPosition(node); - - var start = this.position; - var result = this.getAST(node); - if (result) { - this.movePast(node); - } else { - this.movePast(node.forKeyword); - this.movePast(node.openParenToken); - var init = node.variableDeclaration ? node.variableDeclaration.accept(this) : node.initializer ? node.initializer.accept(this) : null; - this.movePast(node.firstSemicolonToken); - var cond = node.condition ? node.condition.accept(this) : null; - this.movePast(node.secondSemicolonToken); - var incr = node.incrementor ? node.incrementor.accept(this) : null; - this.movePast(node.closeParenToken); - var body = node.statement.accept(this); - - result = new TypeScript.ForStatement(init, cond, incr, body); - } - - this.setAST(node, result); - this.setSpan(result, start, node); - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitForInStatement = function (node) { - this.assertElementAtPosition(node); - - var start = this.position; - var result = this.getAST(node); - if (result) { - this.movePast(node); - } else { - this.movePast(node.forKeyword); - this.movePast(node.openParenToken); - var init = node.variableDeclaration ? node.variableDeclaration.accept(this) : node.left.accept(this); - this.movePast(node.inKeyword); - var expression = node.expression.accept(this); - this.movePast(node.closeParenToken); - var body = node.statement.accept(this); - - result = new TypeScript.ForInStatement(init, expression, body); - } - - this.setAST(node, result); - this.setSpan(result, start, node); - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitWhileStatement = function (node) { - this.assertElementAtPosition(node); - - var start = this.position; - var result = this.getAST(node); - if (result) { - this.movePast(node); - } else { - this.moveTo(node, node.condition); - var condition = node.condition.accept(this); - this.movePast(node.closeParenToken); - var statement = node.statement.accept(this); - - result = new TypeScript.WhileStatement(condition, statement); - } - - this.setAST(node, result); - this.setSpan(result, start, node); - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitWithStatement = function (node) { - this.assertElementAtPosition(node); - - var start = this.position; - var result = this.getAST(node); - if (result) { - this.movePast(node); - } else { - this.moveTo(node, node.condition); - var condition = node.condition.accept(this); - this.movePast(node.closeParenToken); - var statement = node.statement.accept(this); - - result = new TypeScript.WithStatement(condition, statement); - } - - this.setAST(node, result); - this.setSpan(result, start, node); - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitCastExpression = function (node) { - this.assertElementAtPosition(node); - - var start = this.position; - var result = this.getAST(node); - if (result) { - this.movePast(node); - } else { - this.movePast(node.lessThanToken); - var castTerm = this.visitType(node.type); - this.movePast(node.greaterThanToken); - var expression = node.expression.accept(this); - - result = new TypeScript.UnaryExpression(78 /* CastExpression */, expression); - result.castTerm = castTerm; - } - - this.setAST(node, result); - this.setSpan(result, start, node); - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitObjectLiteralExpression = function (node) { - this.assertElementAtPosition(node); - - var start = this.position; - var result = this.getAST(node); - if (result) { - this.movePast(node); - } else { - var preComments = this.convertNodeLeadingComments(node, start); - - var openStart = this.position + node.openBraceToken.leadingTriviaWidth(); - this.movePast(node.openBraceToken); - - var propertyAssignments = this.visitSeparatedSyntaxList(node.propertyAssignments); - - var closeStart = this.position + node.closeBraceToken.leadingTriviaWidth(); - this.movePast(node.closeBraceToken); - - result = new TypeScript.UnaryExpression(22 /* ObjectLiteralExpression */, propertyAssignments); - result.preComments = preComments; - - if (this.isOnSingleLine(openStart, closeStart)) { - result.setFlags(result.getFlags() | 2 /* SingleLine */); - } - } - - this.setAST(node, result); - this.setSpan(result, start, node); - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitSimplePropertyAssignment = function (node) { - this.assertElementAtPosition(node); - - var start = this.position; - var result = this.getAST(node); - if (result) { - this.movePast(node); - } else { - var preComments = this.convertNodeLeadingComments(node, start); - - var left = node.propertyName.accept(this); - - this.previousTokenTrailingComments = this.convertTokenTrailingComments(node.colonToken, this.position + node.colonToken.leadingTriviaWidth() + node.colonToken.width()); - - this.movePast(node.colonToken); - var right = node.expression.accept(this); - - result = new TypeScript.BinaryExpression(80 /* Member */, left, right); - result.preComments = preComments; - - if (right.nodeType === 12 /* FunctionDeclaration */) { - var funcDecl = right; - funcDecl.hint = left.text; - } - } - - this.setAST(node, result); - this.setSpan(result, start, node); - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitFunctionPropertyAssignment = function (node) { - this.assertElementAtPosition(node); - - var start = this.position; - var result = this.getAST(node); - if (result) { - this.movePast(node); - } else { - var left = node.propertyName.accept(this); - var functionDeclaration = node.callSignature.accept(this); - var block = node.block.accept(this); - - functionDeclaration.hint = left.text; - functionDeclaration.block = block; - functionDeclaration.setFunctionFlags(16384 /* IsFunctionProperty */); - - result = new TypeScript.BinaryExpression(80 /* Member */, left, functionDeclaration); - } - - this.setAST(node, result); - this.setSpan(result, start, node); - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitGetAccessorPropertyAssignment = function (node) { - this.assertElementAtPosition(node); - - var start = this.position; - var result = this.getAST(node); - if (result) { - this.movePast(node); - } else { - this.moveTo(node, node.propertyName); - var name = this.identifierFromToken(node.propertyName, false, true); - var functionName = this.identifierFromToken(node.propertyName, false, true); - this.movePast(node.propertyName); - this.movePast(node.openParenToken); - this.movePast(node.closeParenToken); - var returnType = node.typeAnnotation ? node.typeAnnotation.accept(this) : null; - - var block = node.block ? node.block.accept(this) : null; - - var funcDecl = new TypeScript.FunctionDeclaration(functionName, block, false, null, new TypeScript.ASTList(), 12 /* FunctionDeclaration */); - this.setSpan(funcDecl, start, node); - - funcDecl.setFunctionFlags(funcDecl.getFunctionFlags() | 32 /* GetAccessor */); - funcDecl.setFunctionFlags(funcDecl.getFunctionFlags() | 8192 /* IsFunctionExpression */); - funcDecl.hint = "get" + node.propertyName.valueText(); - funcDecl.returnTypeAnnotation = returnType; - - result = new TypeScript.BinaryExpression(80 /* Member */, name, funcDecl); - } - - this.setAST(node, result); - this.setSpan(result, start, node); - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitSetAccessorPropertyAssignment = function (node) { - this.assertElementAtPosition(node); - - var start = this.position; - var result = this.getAST(node); - if (result) { - this.movePast(node); - } else { - this.moveTo(node, node.propertyName); - var name = this.identifierFromToken(node.propertyName, false, true); - var functionName = this.identifierFromToken(node.propertyName, false, true); - this.movePast(node.propertyName); - this.movePast(node.openParenToken); - var parameter = node.parameter.accept(this); - this.movePast(node.closeParenToken); - - var parameters = new TypeScript.ASTList(); - parameters.append(parameter); - - var block = node.block ? node.block.accept(this) : null; - - var funcDecl = new TypeScript.FunctionDeclaration(functionName, block, false, null, parameters, 12 /* FunctionDeclaration */); - this.setSpan(funcDecl, start, node); - - funcDecl.setFunctionFlags(funcDecl.getFunctionFlags() | 64 /* SetAccessor */); - funcDecl.setFunctionFlags(funcDecl.getFunctionFlags() | 8192 /* IsFunctionExpression */); - funcDecl.hint = "set" + node.propertyName.valueText(); - - result = new TypeScript.BinaryExpression(80 /* Member */, name, funcDecl); - } - - this.setAST(node, result); - this.setSpan(result, start, node); - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitFunctionExpression = function (node) { - this.assertElementAtPosition(node); - - var start = this.position; - var result = this.getAST(node); - if (result) { - this.movePast(node); - } else { - var preComments = this.convertNodeLeadingComments(node, start); - - this.movePast(node.functionKeyword); - var name = node.identifier === null ? null : this.identifierFromToken(node.identifier, false, true); - this.movePast(node.identifier); - var typeParameters = node.callSignature.typeParameterList === null ? null : node.callSignature.typeParameterList.accept(this); - var parameters = node.callSignature.parameterList.accept(this); - var returnType = node.callSignature.typeAnnotation ? node.callSignature.typeAnnotation.accept(this) : null; - - var block = node.block ? node.block.accept(this) : null; - - result = new TypeScript.FunctionDeclaration(name, block, false, typeParameters, parameters, 12 /* FunctionDeclaration */); - - result.preComments = preComments; - result.variableArgList = this.hasDotDotDotParameter(node.callSignature.parameterList.parameters); - result.returnTypeAnnotation = returnType; - result.setFunctionFlags(result.getFunctionFlags() | 8192 /* IsFunctionExpression */); - } - - this.setAST(node, result); - this.setSpan(result, start, node); - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitEmptyStatement = function (node) { - this.assertElementAtPosition(node); - - var start = this.position; - var result = this.getAST(node); - if (result) { - this.movePast(node); - } else { - this.movePast(node.semicolonToken); - - result = new TypeScript.EmptyStatement(); - } - - this.setAST(node, result); - this.setSpan(result, start, node); - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitTryStatement = function (node) { - this.assertElementAtPosition(node); - - var start = this.position; - var result = this.getAST(node); - if (result) { - this.movePast(node); - } else { - this.movePast(node.tryKeyword); - var tryBody = node.block.accept(this); - - var catchClause = null; - if (node.catchClause !== null) { - catchClause = node.catchClause.accept(this); - } - - var finallyBody = null; - if (node.finallyClause !== null) { - finallyBody = node.finallyClause.accept(this); - } - - result = new TypeScript.TryStatement(tryBody, catchClause, finallyBody); - } - - TypeScript.Debug.assert(result !== null); - this.setAST(node, result); - this.setSpan(result, start, node); - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitCatchClause = function (node) { - this.assertElementAtPosition(node); - - var start = this.position; - var result = this.getAST(node); - if (result) { - this.movePast(node); - } else { - this.movePast(node.catchKeyword); - this.movePast(node.openParenToken); - var identifier = this.identifierFromToken(node.identifier, false, true); - this.movePast(node.identifier); - var typeExpr = node.typeAnnotation ? node.typeAnnotation.accept(this) : null; - this.movePast(node.closeParenToken); - var block = node.block.accept(this); - - var varDecl = new TypeScript.VariableDeclarator(identifier); - this.setSpanExplicit(varDecl, identifier.minChar, identifier.limChar); - - varDecl.typeExpr = typeExpr; - - result = new TypeScript.CatchClause(varDecl, block); - } - - this.setAST(node, result); - this.setSpan(result, start, node); - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitFinallyClause = function (node) { - this.movePast(node.finallyKeyword); - return node.block.accept(this); - }; - - SyntaxTreeToAstVisitor.prototype.visitLabeledStatement = function (node) { - this.assertElementAtPosition(node); - - var start = this.position; - var result = this.getAST(node); - if (result) { - this.movePast(node); - } else { - var identifier = this.identifierFromToken(node.identifier, false, true); - this.movePast(node.identifier); - this.movePast(node.colonToken); - var statement = node.statement.accept(this); - - result = new TypeScript.LabeledStatement(identifier, statement); - } - - this.setAST(node, result); - this.setSpan(result, start, node); - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitDoStatement = function (node) { - this.assertElementAtPosition(node); - - var start = this.position; - var result = this.getAST(node); - if (result) { - this.movePast(node); - } else { - this.movePast(node.doKeyword); - var statement = node.statement.accept(this); - var whileSpan = new TypeScript.ASTSpan(); - this.setSpan(whileSpan, this.position, node.whileKeyword); - - this.movePast(node.whileKeyword); - this.movePast(node.openParenToken); - var condition = node.condition.accept(this); - this.movePast(node.closeParenToken); - this.movePast(node.semicolonToken); - - result = new TypeScript.DoStatement(statement, condition); - result.whileSpan = whileSpan; - } - - this.setAST(node, result); - this.setSpan(result, start, node); - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitTypeOfExpression = function (node) { - this.assertElementAtPosition(node); - - var start = this.position; - var result = this.getAST(node); - if (result) { - this.movePast(node); - } else { - this.movePast(node.typeOfKeyword); - var expression = node.expression.accept(this); - - result = new TypeScript.UnaryExpression(34 /* TypeOfExpression */, expression); - } - - this.setAST(node, result); - this.setSpan(result, start, node); - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitDeleteExpression = function (node) { - this.assertElementAtPosition(node); - - var start = this.position; - var result = this.getAST(node); - if (result) { - this.movePast(node); - } else { - this.movePast(node.deleteKeyword); - var expression = node.expression.accept(this); - - result = new TypeScript.UnaryExpression(28 /* DeleteExpression */, expression); - } - - this.setAST(node, result); - this.setSpan(result, start, node); - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitVoidExpression = function (node) { - this.assertElementAtPosition(node); - - var start = this.position; - var result = this.getAST(node); - if (result) { - this.movePast(node); - } else { - this.movePast(node.voidKeyword); - var expression = node.expression.accept(this); - - result = new TypeScript.UnaryExpression(24 /* VoidExpression */, expression); - } - - this.setAST(node, result); - this.setSpan(result, start, node); - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitDebuggerStatement = function (node) { - this.assertElementAtPosition(node); - - var start = this.position; - var result = this.getAST(node); - if (result) { - this.movePast(node); - } else { - this.movePast(node.debuggerKeyword); - this.movePast(node.semicolonToken); - - result = new TypeScript.DebuggerStatement(); - } - - this.setAST(node, result); - this.setSpan(result, start, node); - return result; - }; - SyntaxTreeToAstVisitor.checkPositions = false; - - SyntaxTreeToAstVisitor.protoString = "__proto__"; - SyntaxTreeToAstVisitor.protoSubstitutionString = "#__proto__"; - return SyntaxTreeToAstVisitor; - })(); - TypeScript.SyntaxTreeToAstVisitor = SyntaxTreeToAstVisitor; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var Document = (function () { - function Document(fileName, compilationSettings, scriptSnapshot, byteOrderMark, version, isOpen, syntaxTree) { - this.fileName = fileName; - this.compilationSettings = compilationSettings; - this.scriptSnapshot = scriptSnapshot; - this.byteOrderMark = byteOrderMark; - this.version = version; - this.isOpen = isOpen; - this._diagnostics = null; - this._syntaxTree = null; - this._bloomFilter = null; - if (isOpen) { - this._syntaxTree = syntaxTree; - } else { - this._diagnostics = syntaxTree.diagnostics(); - } - - var identifiers = new TypeScript.BlockIntrinsics(); - - var identifierWalker = new TypeScript.IdentifierWalker(identifiers); - syntaxTree.sourceUnit().accept(identifierWalker); - - var identifierCount = 0; - for (var name in identifiers) { - identifierCount++; - } - this._bloomFilter = new TypeScript.BloomFilter(identifierCount); - this._bloomFilter.addKeys(identifiers); - - this.lineMap = syntaxTree.lineMap(); - this.script = TypeScript.SyntaxTreeToAstVisitor.visit(syntaxTree, fileName, compilationSettings); - } - Document.prototype.diagnostics = function () { - if (this._diagnostics === null) { - this._diagnostics = this._syntaxTree.diagnostics(); - } - - return this._diagnostics; - }; - - Document.prototype.syntaxTree = function () { - if (this._syntaxTree) { - return this._syntaxTree; - } - - return TypeScript.Parser.parse(this.fileName, TypeScript.SimpleText.fromScriptSnapshot(this.scriptSnapshot), TypeScript.isDTSFile(this.fileName), this.compilationSettings.codeGenTarget, TypeScript.getParseOptions(this.compilationSettings)); - }; - - Document.prototype.bloomFilter = function () { - return this._bloomFilter; - }; - - Document.prototype.update = function (scriptSnapshot, version, isOpen, textChangeRange, settings) { - var oldScript = this.script; - var oldSyntaxTree = this._syntaxTree; - - var text = TypeScript.SimpleText.fromScriptSnapshot(scriptSnapshot); - - var newSyntaxTree = textChangeRange === null || oldSyntaxTree === null ? TypeScript.Parser.parse(this.fileName, text, TypeScript.isDTSFile(this.fileName), settings.codeGenTarget, TypeScript.getParseOptions(this.compilationSettings)) : TypeScript.Parser.incrementalParse(oldSyntaxTree, textChangeRange, text); - - return new Document(this.fileName, this.compilationSettings, scriptSnapshot, this.byteOrderMark, version, isOpen, newSyntaxTree); - }; - - Document.create = function (fileName, scriptSnapshot, byteOrderMark, version, isOpen, referencedFiles, compilationSettings) { - var syntaxTree = TypeScript.Parser.parse(fileName, TypeScript.SimpleText.fromScriptSnapshot(scriptSnapshot), TypeScript.isDTSFile(fileName), compilationSettings.codeGenTarget, TypeScript.getParseOptions(compilationSettings)); - - var document = new Document(fileName, compilationSettings, scriptSnapshot, byteOrderMark, version, isOpen, syntaxTree); - document.script.referencedFiles = referencedFiles; - - return document; - }; - return Document; - })(); - TypeScript.Document = Document; - - TypeScript.globalSemanticInfoChain = null; - TypeScript.globalBinder = null; - TypeScript.globalLogger = null; - var TypeScriptCompiler = (function () { - function TypeScriptCompiler(logger, settings, diagnosticMessages) { - if (typeof logger === "undefined") { logger = new TypeScript.NullLogger(); } - if (typeof settings === "undefined") { settings = new TypeScript.CompilationSettings(); } - if (typeof diagnosticMessages === "undefined") { diagnosticMessages = null; } - this.logger = logger; - this.settings = settings; - this.diagnosticMessages = diagnosticMessages; - this.pullTypeChecker = null; - this.semanticInfoChain = null; - this.fileNameToDocument = new TypeScript.StringHashTable(); - this.emitOptions = new TypeScript.EmitOptions(this.settings); - TypeScript.globalLogger = logger; - if (this.diagnosticMessages) { - TypeScript.diagnosticMessages = this.diagnosticMessages; - } - } - TypeScriptCompiler.prototype.getDocument = function (fileName) { - return this.fileNameToDocument.lookup(fileName); - }; - - TypeScriptCompiler.prototype.timeFunction = function (funcDescription, func) { - return TypeScript.timeFunction(this.logger, funcDescription, func); - }; - - TypeScriptCompiler.prototype.addSourceUnit = function (fileName, scriptSnapshot, byteOrderMark, version, isOpen, referencedFiles) { - if (typeof referencedFiles === "undefined") { referencedFiles = []; } - var _this = this; - return this.timeFunction("addSourceUnit(" + fileName + ")", function () { - var document = Document.create(fileName, scriptSnapshot, byteOrderMark, version, isOpen, referencedFiles, _this.emitOptions.compilationSettings); - _this.fileNameToDocument.addOrUpdate(fileName, document); - - return document; - }); - }; - - TypeScriptCompiler.prototype.updateSourceUnit = function (fileName, scriptSnapshot, version, isOpen, textChangeRange) { - var _this = this; - return this.timeFunction("pullUpdateUnit(" + fileName + ")", function () { - var document = _this.getDocument(fileName); - var updatedDocument = document.update(scriptSnapshot, version, isOpen, textChangeRange, _this.settings); - - _this.fileNameToDocument.addOrUpdate(fileName, updatedDocument); - - _this.pullUpdateScript(document, updatedDocument); - - return updatedDocument; - }); - }; - - TypeScriptCompiler.prototype.isDynamicModuleCompilation = function () { - var fileNames = this.fileNameToDocument.getAllKeys(); - for (var i = 0, n = fileNames.length; i < n; i++) { - var document = this.getDocument(fileNames[i]); - var script = document.script; - if (!script.isDeclareFile && script.topLevelMod !== null) { - return true; - } - } - return false; - }; - - TypeScriptCompiler.prototype.updateCommonDirectoryPath = function () { - var commonComponents = []; - var commonComponentsLength = -1; - - var fileNames = this.fileNameToDocument.getAllKeys(); - for (var i = 0, len = fileNames.length; i < len; i++) { - var fileName = fileNames[i]; - var document = this.getDocument(fileNames[i]); - var script = document.script; - - if (!script.isDeclareFile) { - var fileComponents = TypeScript.filePathComponents(fileName); - if (commonComponentsLength === -1) { - commonComponents = fileComponents; - commonComponentsLength = commonComponents.length; - } else { - var updatedPath = false; - for (var j = 0; j < commonComponentsLength && j < fileComponents.length; j++) { - if (commonComponents[j] !== fileComponents[j]) { - commonComponentsLength = j; - updatedPath = true; - - if (j === 0) { - return new TypeScript.Diagnostic(null, 0, 0, 273 /* Cannot_find_the_common_subdirectory_path_for_the_input_files */, null); - } - - break; - } - } - - if (!updatedPath && fileComponents.length < commonComponentsLength) { - commonComponentsLength = fileComponents.length; - } - } - } - } - - this.emitOptions.commonDirectoryPath = commonComponents.slice(0, commonComponentsLength).join("/") + "/"; - if (this.emitOptions.compilationSettings.outputOption.charAt(this.emitOptions.compilationSettings.outputOption.length - 1) !== "/") { - this.emitOptions.compilationSettings.outputOption += "/"; - } - - return null; - }; - - TypeScriptCompiler.prototype.parseEmitOption = function (ioHost) { - this.emitOptions.ioHost = ioHost; - if (this.emitOptions.compilationSettings.outputOption === "") { - this.emitOptions.outputMany = true; - this.emitOptions.commonDirectoryPath = ""; - return null; - } - - this.emitOptions.compilationSettings.outputOption = TypeScript.switchToForwardSlashes(this.emitOptions.ioHost.resolvePath(this.emitOptions.compilationSettings.outputOption)); - - if (this.emitOptions.ioHost.directoryExists(this.emitOptions.compilationSettings.outputOption)) { - this.emitOptions.outputMany = true; - } else if (this.emitOptions.ioHost.fileExists(this.emitOptions.compilationSettings.outputOption)) { - this.emitOptions.outputMany = false; - } else { - this.emitOptions.outputMany = !TypeScript.isJSFile(this.emitOptions.compilationSettings.outputOption); - } - - if (this.isDynamicModuleCompilation() && !this.emitOptions.outputMany) { - return new TypeScript.Diagnostic(null, 0, 0, 274 /* Cannot_compile_dynamic_modules_when_emitting_into_single_file */, null); - } - - if (this.emitOptions.outputMany) { - return this.updateCommonDirectoryPath(); - } - - return null; - }; - - TypeScriptCompiler.prototype.getScripts = function () { - var result = []; - var fileNames = this.fileNameToDocument.getAllKeys(); - - for (var i = 0, n = fileNames.length; i < n; i++) { - var document = this.getDocument(fileNames[i]); - result.push(document.script); - } - - return result; - }; - - TypeScriptCompiler.prototype.writeByteOrderMarkForDocument = function (document) { - if (this.emitOptions.outputMany) { - return document.byteOrderMark !== 0 /* None */; - } else { - var fileNames = this.fileNameToDocument.getAllKeys(); - - for (var i = 0, n = fileNames.length; i < n; i++) { - var document = this.getDocument(fileNames[i]); - if (document.byteOrderMark !== 0 /* None */) { - return true; - } - } - - return false; - } - }; - - TypeScriptCompiler.mapToDTSFileName = function (fileName, wholeFileNameReplaced) { - return TypeScript.getDeclareFilePath(fileName); - }; - - TypeScriptCompiler.prototype.canEmitDeclarations = function (script) { - if (!this.settings.generateDeclarationFiles) { - return false; - } - - if (!!script && (script.isDeclareFile || script.moduleElements === null)) { - return false; - } - - return true; - }; - - TypeScriptCompiler.prototype.emitDeclarations = function (document, declarationEmitter) { - var script = document.script; - if (this.canEmitDeclarations(script)) { - if (!declarationEmitter) { - var declareFileName = this.emitOptions.mapOutputFileName(document.fileName, TypeScriptCompiler.mapToDTSFileName); - declarationEmitter = new TypeScript.DeclarationEmitter(declareFileName, this.semanticInfoChain, this.emitOptions, document.byteOrderMark !== 0 /* None */); - } - - declarationEmitter.fileName = document.fileName; - declarationEmitter.emitDeclarations(script); - } - - return declarationEmitter; - }; - - TypeScriptCompiler.prototype.emitAllDeclarations = function () { - if (this.canEmitDeclarations()) { - var sharedEmitter = null; - var fileNames = this.fileNameToDocument.getAllKeys(); - - for (var i = 0, n = fileNames.length; i < n; i++) { - var fileName = fileNames[i]; - - try { - var document = this.getDocument(fileNames[i]); - - if (this.emitOptions.outputMany) { - var singleEmitter = this.emitDeclarations(document); - if (singleEmitter) { - singleEmitter.close(); - } - } else { - sharedEmitter = this.emitDeclarations(document, sharedEmitter); - } - } catch (ex1) { - return TypeScript.Emitter.handleEmitterError(fileName, ex1); - } - } - - if (sharedEmitter) { - try { - sharedEmitter.close(); - } catch (ex2) { - return TypeScript.Emitter.handleEmitterError(sharedEmitter.fileName, ex2); - } - } - } - - return []; - }; - - TypeScriptCompiler.prototype.emitUnitDeclarations = function (fileName) { - if (this.canEmitDeclarations()) { - if (this.emitOptions.outputMany) { - try { - var document = this.getDocument(fileName); - var emitter = this.emitDeclarations(document); - if (emitter) { - emitter.close(); - } - } catch (ex1) { - return TypeScript.Emitter.handleEmitterError(fileName, ex1); - } - } else { - return this.emitAllDeclarations(); - } - } - - return []; - }; - - TypeScriptCompiler.mapToFileNameExtension = function (extension, fileName, wholeFileNameReplaced) { - if (wholeFileNameReplaced) { - return fileName; - } else { - var splitFname = fileName.split("."); - splitFname.pop(); - return splitFname.join(".") + extension; - } - }; - - TypeScriptCompiler.mapToJSFileName = function (fileName, wholeFileNameReplaced) { - return TypeScriptCompiler.mapToFileNameExtension(".js", fileName, wholeFileNameReplaced); - }; - - TypeScriptCompiler.prototype.emit = function (document, inputOutputMapper, emitter) { - var script = document.script; - if (!script.isDeclareFile) { - var typeScriptFileName = document.fileName; - if (!emitter) { - var javaScriptFileName = this.emitOptions.mapOutputFileName(typeScriptFileName, TypeScriptCompiler.mapToJSFileName); - var outFile = this.createFile(javaScriptFileName, this.writeByteOrderMarkForDocument(document)); - - emitter = new TypeScript.Emitter(javaScriptFileName, outFile, this.emitOptions, this.semanticInfoChain); - - if (this.settings.mapSourceFiles) { - var sourceMapFileName = javaScriptFileName + TypeScript.SourceMapper.MapFileExtension; - emitter.setSourceMappings(new TypeScript.SourceMapper(typeScriptFileName, javaScriptFileName, sourceMapFileName, outFile, this.createFile(sourceMapFileName, false), this.settings.emitFullSourceMapPath)); - } - - if (inputOutputMapper) { - inputOutputMapper(typeScriptFileName, javaScriptFileName); - } - } else if (this.settings.mapSourceFiles) { - emitter.setSourceMappings(new TypeScript.SourceMapper(typeScriptFileName, emitter.emittingFileName, emitter.sourceMapper.sourceMapFileName, emitter.outfile, emitter.sourceMapper.sourceMapOut, this.settings.emitFullSourceMapPath)); - } - - emitter.setDocument(document); - emitter.emitJavascript(script, false); - } - - return emitter; - }; - - TypeScriptCompiler.prototype.emitAll = function (ioHost, inputOutputMapper) { - var optionsDiagnostic = this.parseEmitOption(ioHost); - if (optionsDiagnostic) { - return [optionsDiagnostic]; - } - - var startEmitTime = (new Date()).getTime(); - - var fileNames = this.fileNameToDocument.getAllKeys(); - var sharedEmitter = null; - - for (var i = 0, n = fileNames.length; i < n; i++) { - var fileName = fileNames[i]; - - var document = this.getDocument(fileName); - - try { - if (this.emitOptions.outputMany) { - var singleEmitter = this.emit(document, inputOutputMapper); - - if (singleEmitter) { - singleEmitter.emitSourceMapsAndClose(); - } - } else { - sharedEmitter = this.emit(document, inputOutputMapper, sharedEmitter); - } - } catch (ex1) { - return TypeScript.Emitter.handleEmitterError(fileName, ex1); - } - } - - this.logger.log("Emit: " + ((new Date()).getTime() - startEmitTime)); - - if (sharedEmitter) { - try { - sharedEmitter.emitSourceMapsAndClose(); - } catch (ex2) { - return TypeScript.Emitter.handleEmitterError(sharedEmitter.document.fileName, ex2); - } - } - - return []; - }; - - TypeScriptCompiler.prototype.emitUnit = function (fileName, ioHost, inputOutputMapper) { - var optionsDiagnostic = this.parseEmitOption(ioHost); - if (optionsDiagnostic) { - return [optionsDiagnostic]; - } - - if (this.emitOptions.outputMany) { - var document = this.getDocument(fileName); - try { - var emitter = this.emit(document, inputOutputMapper); - - if (emitter) { - emitter.emitSourceMapsAndClose(); - } - } catch (ex1) { - return TypeScript.Emitter.handleEmitterError(fileName, ex1); - } - - return []; - } else { - return this.emitAll(ioHost, inputOutputMapper); - } - }; - - TypeScriptCompiler.prototype.createFile = function (fileName, writeByteOrderMark) { - return new TypeScript.TextWriter(this.emitOptions.ioHost, fileName, writeByteOrderMark); - }; - - TypeScriptCompiler.prototype.getSyntacticDiagnostics = function (fileName) { - return this.getDocument(fileName).diagnostics(); - }; - - TypeScriptCompiler.prototype.getSyntaxTree = function (fileName) { - return this.getDocument(fileName).syntaxTree(); - }; - TypeScriptCompiler.prototype.getScript = function (fileName) { - return this.getDocument(fileName).script; - }; - - TypeScriptCompiler.prototype.getSemanticDiagnostics = function (fileName) { - var errors = []; - var unit = this.semanticInfoChain.getUnit(fileName); - - TypeScript.globalSemanticInfoChain = this.semanticInfoChain; - if (TypeScript.globalBinder) { - TypeScript.globalBinder.semanticInfoChain = this.semanticInfoChain; - } - - if (unit) { - var document = this.getDocument(fileName); - var script = document.script; - - if (script) { - this.pullTypeChecker.typeCheckScript(script, fileName, this); - - unit.getDiagnostics(errors); - } - } - - return errors; - }; - - TypeScriptCompiler.prototype.pullTypeCheck = function () { - var _this = this; - return this.timeFunction("pullTypeCheck()", function () { - _this.semanticInfoChain = new TypeScript.SemanticInfoChain(); - TypeScript.globalSemanticInfoChain = _this.semanticInfoChain; - _this.pullTypeChecker = new TypeScript.PullTypeChecker(_this.settings, _this.semanticInfoChain); - - var declCollectionContext = null; - var i, n; - - var createDeclsStartTime = new Date().getTime(); - - var fileNames = _this.fileNameToDocument.getAllKeys(); - for (var i = 0, n = fileNames.length; i < n; i++) { - var fileName = fileNames[i]; - var document = _this.getDocument(fileName); - var semanticInfo = new TypeScript.SemanticInfo(fileName); - - declCollectionContext = new TypeScript.DeclCollectionContext(semanticInfo); - declCollectionContext.scriptName = fileName; - - TypeScript.getAstWalkerFactory().walk(document.script, TypeScript.preCollectDecls, TypeScript.postCollectDecls, null, declCollectionContext); - - semanticInfo.addTopLevelDecl(declCollectionContext.getParent()); - - _this.semanticInfoChain.addUnit(semanticInfo); - } - - var createDeclsEndTime = new Date().getTime(); - - var bindStartTime = new Date().getTime(); - - var binder = new TypeScript.PullSymbolBinder(_this.semanticInfoChain); - TypeScript.globalBinder = binder; - - var bindEndTime = new Date().getTime(); - - _this.logger.log("Decl creation: " + (createDeclsEndTime - createDeclsStartTime)); - _this.logger.log("Binding: " + (bindEndTime - bindStartTime)); - _this.logger.log(" Time in findSymbol: " + TypeScript.time_in_findSymbol); - _this.logger.log("Number of symbols created: " + TypeScript.pullSymbolID); - _this.logger.log("Number of specialized types created: " + TypeScript.nSpecializationsCreated); - _this.logger.log("Number of specialized signatures created: " + TypeScript.nSpecializedSignaturesCreated); - }); - }; - - TypeScriptCompiler.prototype.pullUpdateScript = function (oldDocument, newDocument) { - var _this = this; - this.timeFunction("pullUpdateScript: ", function () { - var oldScript = oldDocument.script; - var newScript = newDocument.script; - - var newScriptSemanticInfo = new TypeScript.SemanticInfo(oldDocument.fileName); - var oldScriptSemanticInfo = _this.semanticInfoChain.getUnit(oldDocument.fileName); - - TypeScript.lastBoundPullDeclId = TypeScript.pullDeclID; - TypeScript.lastBoundPullSymbolID = TypeScript.pullSymbolID; - - var declCollectionContext = new TypeScript.DeclCollectionContext(newScriptSemanticInfo); - - declCollectionContext.scriptName = oldDocument.fileName; - - TypeScript.getAstWalkerFactory().walk(newScript, TypeScript.preCollectDecls, TypeScript.postCollectDecls, null, declCollectionContext); - - var oldTopLevelDecl = oldScriptSemanticInfo.getTopLevelDecls()[0]; - var newTopLevelDecl = declCollectionContext.getParent(); - - newScriptSemanticInfo.addTopLevelDecl(newTopLevelDecl); - - if (_this.pullTypeChecker && _this.pullTypeChecker.resolver) { - _this.pullTypeChecker.resolver.cleanCachedGlobals(); - } - - _this.semanticInfoChain.updateUnit(oldScriptSemanticInfo, newScriptSemanticInfo); - - _this.logger.log("Cleaning symbols..."); - var cleanStart = new Date().getTime(); - _this.semanticInfoChain.update(); - var cleanEnd = new Date().getTime(); - _this.logger.log(" time to clean: " + (cleanEnd - cleanStart)); - - if (_this.pullTypeChecker && _this.pullTypeChecker.resolver) { - _this.pullTypeChecker.resolver.setUnitPath(oldDocument.fileName); - } - }); - }; - - TypeScriptCompiler.prototype.getSymbolOfDeclaration = function (decl) { - if (!decl) { - return null; - } - var ast = this.pullTypeChecker.resolver.getASTForDecl(decl); - if (!ast) { - return null; - } - var enlosingDecl = this.pullTypeChecker.resolver.getEnclosingDecl(decl); - if (ast.nodeType === 80 /* Member */) { - return this.getSymbolOfDeclaration(enlosingDecl); - } - var resolutionContext = new TypeScript.PullTypeResolutionContext(); - return this.pullTypeChecker.resolver.resolveAST(ast, false, enlosingDecl, resolutionContext).symbol; - }; - - TypeScriptCompiler.prototype.resolvePosition = function (pos, document) { - var declStack = []; - var resultASTs = []; - var script = document.script; - var scriptName = document.fileName; - - var semanticInfo = this.semanticInfoChain.getUnit(scriptName); - var lastDeclAST = null; - var foundAST = null; - var symbol = null; - var candidateSignature = null; - var callSignatures = null; - - var lambdaAST = null; - var declarationInitASTs = []; - var objectLitAST = null; - var asgAST = null; - var typeAssertionASTs = []; - var resolutionContext = new TypeScript.PullTypeResolutionContext(); - var inTypeReference = false; - var enclosingDecl = null; - var isConstructorCall = false; - - TypeScript.globalSemanticInfoChain = this.semanticInfoChain; - if (TypeScript.globalBinder) { - TypeScript.globalBinder.semanticInfoChain = this.semanticInfoChain; - } - - var pre = function (cur, parent) { - if (TypeScript.isValidAstNode(cur)) { - if (pos >= cur.minChar && pos <= cur.limChar) { - var previous = resultASTs[resultASTs.length - 1]; - - if (previous === undefined || (cur.minChar >= previous.minChar && cur.limChar <= previous.limChar)) { - var decl = semanticInfo.getDeclForAST(cur); - - if (decl) { - declStack[declStack.length] = decl; - lastDeclAST = cur; - } - - if (cur.nodeType === 12 /* FunctionDeclaration */ && TypeScript.hasFlag((cur).getFunctionFlags(), 8192 /* IsFunctionExpression */)) { - lambdaAST = cur; - } else if (cur.nodeType === 17 /* VariableDeclarator */) { - declarationInitASTs[declarationInitASTs.length] = cur; - } else if (cur.nodeType === 22 /* ObjectLiteralExpression */) { - objectLitAST = cur; - } else if (cur.nodeType === 78 /* CastExpression */) { - typeAssertionASTs[typeAssertionASTs.length] = cur; - } else if (cur.nodeType === 38 /* AssignmentExpression */) { - asgAST = cur; - } else if (cur.nodeType === 11 /* TypeRef */) { - inTypeReference = true; - } - - resultASTs[resultASTs.length] = cur; - } - } - } - return cur; - }; - - TypeScript.getAstWalkerFactory().walk(script, pre); - - if (resultASTs.length) { - this.pullTypeChecker.setUnit(scriptName); - - foundAST = resultASTs[resultASTs.length - 1]; - - if (foundAST.nodeType === 20 /* Name */ && resultASTs.length > 1) { - var previousAST = resultASTs[resultASTs.length - 2]; - switch (previousAST.nodeType) { - case 14 /* InterfaceDeclaration */: - case 13 /* ClassDeclaration */: - case 15 /* ModuleDeclaration */: - if (foundAST === (previousAST).name) { - foundAST = previousAST; - } - break; - - case 17 /* VariableDeclarator */: - if (foundAST === (previousAST).id) { - foundAST = previousAST; - } - break; - - case 12 /* FunctionDeclaration */: - if (foundAST === (previousAST).name) { - foundAST = previousAST; - } - break; - } - } - - var funcDecl = null; - if (lastDeclAST === foundAST) { - symbol = declStack[declStack.length - 1].getSymbol(); - this.pullTypeChecker.resolver.resolveDeclaredSymbol(symbol, null, resolutionContext); - symbol.setUnresolved(); - enclosingDecl = declStack[declStack.length - 1].getParentDecl(); - if (foundAST.nodeType === 12 /* FunctionDeclaration */) { - funcDecl = foundAST; - } - } else { - for (var i = declStack.length - 1; i >= 0; i--) { - if (!(declStack[i].getKind() & (1024 /* Variable */ | 2048 /* Parameter */))) { - enclosingDecl = declStack[i]; - break; - } - } - - var callExpression = null; - if ((foundAST.nodeType === 30 /* SuperExpression */ || foundAST.nodeType === 29 /* ThisExpression */ || foundAST.nodeType === 20 /* Name */) && resultASTs.length > 1) { - for (var i = resultASTs.length - 2; i >= 0; i--) { - if (resultASTs[i].nodeType === 32 /* MemberAccessExpression */ && (resultASTs[i]).operand2 === resultASTs[i + 1]) { - foundAST = resultASTs[i]; - } else if ((resultASTs[i].nodeType === 36 /* InvocationExpression */ || resultASTs[i].nodeType === 37 /* ObjectCreationExpression */) && (resultASTs[i]).target === resultASTs[i + 1]) { - callExpression = resultASTs[i]; - break; - } else if (resultASTs[i].nodeType === 12 /* FunctionDeclaration */ && (resultASTs[i]).name === resultASTs[i + 1]) { - funcDecl = resultASTs[i]; - break; - } else { - break; - } - } - } - - if (foundAST.nodeType === 1 /* List */) { - for (var i = 0; i < (foundAST).members.length; i++) { - if ((foundAST).members[i].minChar > pos) { - foundAST = (foundAST).members[i]; - break; - } - } - } - - resolutionContext.resolvingTypeReference = inTypeReference; - - var inContextuallyTypedAssignment = false; - - if (declarationInitASTs.length) { - var assigningAST; - - for (var i = 0; i < declarationInitASTs.length; i++) { - assigningAST = declarationInitASTs[i]; - inContextuallyTypedAssignment = (assigningAST !== null) && (assigningAST.typeExpr !== null); - - this.pullTypeChecker.resolver.resolveAST(assigningAST, false, null, resolutionContext); - var varSymbolAndDiagnostics = this.semanticInfoChain.getSymbolAndDiagnosticsForAST(assigningAST, scriptName); - var varSymbol = varSymbolAndDiagnostics && varSymbolAndDiagnostics.symbol; - - if (varSymbol && inContextuallyTypedAssignment) { - var contextualType = varSymbol.getType(); - resolutionContext.pushContextualType(contextualType, false, null); - } - - if (assigningAST.init) { - this.pullTypeChecker.resolver.resolveAST(assigningAST.init, inContextuallyTypedAssignment, enclosingDecl, resolutionContext); - } - } - } - - if (typeAssertionASTs.length) { - for (var i = 0; i < typeAssertionASTs.length; i++) { - this.pullTypeChecker.resolver.resolveAST(typeAssertionASTs[i], inContextuallyTypedAssignment, enclosingDecl, resolutionContext); - } - } - - if (asgAST) { - this.pullTypeChecker.resolver.resolveAST(asgAST, inContextuallyTypedAssignment, enclosingDecl, resolutionContext); - } - - if (objectLitAST) { - this.pullTypeChecker.resolver.resolveAST(objectLitAST, inContextuallyTypedAssignment, enclosingDecl, resolutionContext); - } - - if (lambdaAST) { - this.pullTypeChecker.resolver.resolveAST(lambdaAST, true, enclosingDecl, resolutionContext); - enclosingDecl = semanticInfo.getDeclForAST(lambdaAST); - } - - symbol = this.pullTypeChecker.resolver.resolveAST(foundAST, inContextuallyTypedAssignment, enclosingDecl, resolutionContext).symbol; - if (callExpression) { - var isPropertyOrVar = symbol.getKind() === 4096 /* Property */ || symbol.getKind() === 1024 /* Variable */; - var typeSymbol = symbol.getType(); - if (isPropertyOrVar) { - isPropertyOrVar = (typeSymbol.getKind() !== 16 /* Interface */ && typeSymbol.getKind() !== 8388608 /* ObjectType */) || typeSymbol.getName() === ""; - } - - if (!isPropertyOrVar) { - isConstructorCall = foundAST.nodeType === 30 /* SuperExpression */ || callExpression.nodeType === 37 /* ObjectCreationExpression */; - - if (foundAST.nodeType === 30 /* SuperExpression */) { - if (symbol.getKind() === 8 /* Class */) { - callSignatures = (symbol).getConstructorMethod().getType().getConstructSignatures(); - } - } else { - callSignatures = callExpression.nodeType === 36 /* InvocationExpression */ ? typeSymbol.getCallSignatures() : typeSymbol.getConstructSignatures(); - } - - var callResolutionResults = new TypeScript.PullAdditionalCallResolutionData(); - if (callExpression.nodeType === 36 /* InvocationExpression */) { - this.pullTypeChecker.resolver.resolveCallExpression(callExpression, inContextuallyTypedAssignment, enclosingDecl, resolutionContext, callResolutionResults); - } else { - this.pullTypeChecker.resolver.resolveNewExpression(callExpression, inContextuallyTypedAssignment, enclosingDecl, resolutionContext, callResolutionResults); - } - - if (callResolutionResults.candidateSignature) { - candidateSignature = callResolutionResults.candidateSignature; - } - if (callResolutionResults.targetSymbol && callResolutionResults.targetSymbol.getName() !== "") { - symbol = callResolutionResults.targetSymbol; - } - foundAST = callExpression; - } - } - } - - if (funcDecl) { - if (symbol && symbol.getKind() !== 4096 /* Property */) { - var signatureInfo = TypeScript.PullHelpers.getSignatureForFuncDecl(funcDecl, this.semanticInfoChain.getUnit(scriptName)); - candidateSignature = signatureInfo.signature; - callSignatures = signatureInfo.allSignatures; - } - } else if (!callSignatures && symbol && (symbol.getKind() === 65536 /* Method */ || symbol.getKind() === 16384 /* Function */)) { - var typeSym = symbol.getType(); - if (typeSym) { - callSignatures = typeSym.getCallSignatures(); - } - } - } - - var enclosingScopeSymbol = this.getSymbolOfDeclaration(enclosingDecl); - - return { - symbol: symbol, - ast: foundAST, - enclosingScopeSymbol: enclosingScopeSymbol, - candidateSignature: candidateSignature, - callSignatures: callSignatures, - isConstructorCall: isConstructorCall - }; - }; - - TypeScriptCompiler.prototype.extractResolutionContextFromPath = function (path, document) { - var script = document.script; - var scriptName = document.fileName; - - var semanticInfo = this.semanticInfoChain.getUnit(scriptName); - var enclosingDecl = null; - var enclosingDeclAST = null; - var inContextuallyTypedAssignment = false; - - TypeScript.globalSemanticInfoChain = this.semanticInfoChain; - if (TypeScript.globalBinder) { - TypeScript.globalBinder.semanticInfoChain = this.semanticInfoChain; - } - - var resolutionContext = new TypeScript.PullTypeResolutionContext(); - resolutionContext.resolveAggressively = true; - - if (path.count() === 0) { - return null; - } - - this.pullTypeChecker.setUnit(semanticInfo.getPath()); - - for (var i = 0, n = path.count(); i < n; i++) { - var current = path.asts[i]; - - switch (current.nodeType) { - case 12 /* FunctionDeclaration */: - if (TypeScript.hasFlag((current).getFunctionFlags(), 8192 /* IsFunctionExpression */)) { - this.pullTypeChecker.resolver.resolveAST((current), true, enclosingDecl, resolutionContext); - } - - break; - - case 17 /* VariableDeclarator */: - var assigningAST = current; - inContextuallyTypedAssignment = (assigningAST.typeExpr !== null); - - this.pullTypeChecker.resolver.resolveAST(assigningAST, false, null, resolutionContext); - var varSymbolAndDiagnostics = this.semanticInfoChain.getSymbolAndDiagnosticsForAST(assigningAST, scriptName); - var varSymbol = varSymbolAndDiagnostics && varSymbolAndDiagnostics.symbol; - - var contextualType = null; - if (varSymbol && inContextuallyTypedAssignment) { - contextualType = varSymbol.getType(); - } - - resolutionContext.pushContextualType(contextualType, false, null); - - if (assigningAST.init) { - this.pullTypeChecker.resolver.resolveAST(assigningAST.init, inContextuallyTypedAssignment, enclosingDecl, resolutionContext); - } - - break; - - case 36 /* InvocationExpression */: - case 37 /* ObjectCreationExpression */: - var isNew = current.nodeType === 37 /* ObjectCreationExpression */; - var callExpression = current; - var contextualType = null; - - if ((i + 1 < n) && callExpression.arguments === path.asts[i + 1]) { - var callResolutionResults = new TypeScript.PullAdditionalCallResolutionData(); - if (isNew) { - this.pullTypeChecker.resolver.resolveNewExpression(callExpression, inContextuallyTypedAssignment, enclosingDecl, resolutionContext, callResolutionResults); - } else { - this.pullTypeChecker.resolver.resolveCallExpression(callExpression, inContextuallyTypedAssignment, enclosingDecl, resolutionContext, callResolutionResults); - } - - if (callResolutionResults.actualParametersContextTypeSymbols) { - var argExpression = (path.asts[i + 1] && path.asts[i + 1].nodeType === 1 /* List */) ? path.asts[i + 2] : path.asts[i + 1]; - if (argExpression) { - for (var j = 0, m = callExpression.arguments.members.length; j < m; j++) { - if (callExpression.arguments.members[j] === argExpression) { - var callContextualType = callResolutionResults.actualParametersContextTypeSymbols[j]; - if (callContextualType) { - contextualType = callContextualType; - break; - } - } - } - } - } - } else { - if (isNew) { - this.pullTypeChecker.resolver.resolveNewExpression(callExpression, inContextuallyTypedAssignment, enclosingDecl, resolutionContext); - } else { - this.pullTypeChecker.resolver.resolveCallExpression(callExpression, inContextuallyTypedAssignment, enclosingDecl, resolutionContext); - } - } - - resolutionContext.pushContextualType(contextualType, false, null); - - break; - - case 21 /* ArrayLiteralExpression */: - this.pullTypeChecker.resolver.resolveAST(current, inContextuallyTypedAssignment, enclosingDecl, resolutionContext); - - var contextualType = null; - var currentContextualType = resolutionContext.getContextualType(); - if (currentContextualType && currentContextualType.isArray()) { - contextualType = currentContextualType.getElementType(); - } - - resolutionContext.pushContextualType(contextualType, false, null); - - break; - - case 22 /* ObjectLiteralExpression */: - var objectLiteralExpression = current; - var objectLiteralResolutionContext = new TypeScript.PullAdditionalObjectLiteralResolutionData(); - this.pullTypeChecker.resolver.resolveObjectLiteralExpression(objectLiteralExpression, inContextuallyTypedAssignment, enclosingDecl, resolutionContext, objectLiteralResolutionContext); - - var memeberAST = (path.asts[i + 1] && path.asts[i + 1].nodeType === 1 /* List */) ? path.asts[i + 2] : path.asts[i + 1]; - if (memeberAST) { - var contextualType = null; - var memberDecls = objectLiteralExpression.operand; - if (memberDecls && objectLiteralResolutionContext.membersContextTypeSymbols) { - for (var j = 0, m = memberDecls.members.length; j < m; j++) { - if (memberDecls.members[j] === memeberAST) { - var memberContextualType = objectLiteralResolutionContext.membersContextTypeSymbols[j]; - if (memberContextualType) { - contextualType = memberContextualType; - break; - } - } - } - } - - resolutionContext.pushContextualType(contextualType, false, null); - } - - break; - - case 38 /* AssignmentExpression */: - var assignmentExpression = current; - var contextualType = null; - - if (path.asts[i + 1] && path.asts[i + 1] === assignmentExpression.operand2) { - var leftType = this.pullTypeChecker.resolver.resolveAST(assignmentExpression.operand1, inContextuallyTypedAssignment, enclosingDecl, resolutionContext).symbol.getType(); - if (leftType) { - inContextuallyTypedAssignment = true; - contextualType = leftType; - } - } - - resolutionContext.pushContextualType(contextualType, false, null); - - break; - - case 78 /* CastExpression */: - var castExpression = current; - var contextualType = null; - - if (i + 1 < n && path.asts[i + 1] === castExpression.castTerm) { - resolutionContext.resolvingTypeReference = true; - } - - var typeSymbol = this.pullTypeChecker.resolver.resolveTypeAssertionExpression(castExpression, inContextuallyTypedAssignment, enclosingDecl, resolutionContext).symbol; - - if (typeSymbol) { - inContextuallyTypedAssignment = true; - contextualType = typeSymbol; - } - - resolutionContext.pushContextualType(contextualType, false, null); - - break; - - case 93 /* ReturnStatement */: - var returnStatement = current; - var contextualType = null; - - if (enclosingDecl && (enclosingDecl.getKind() & TypeScript.PullElementKind.SomeFunction)) { - var functionDeclaration = enclosingDeclAST; - if (functionDeclaration.returnTypeAnnotation) { - var currentResolvingTypeReference = resolutionContext.resolvingTypeReference; - resolutionContext.resolvingTypeReference = true; - var returnTypeSymbol = this.pullTypeChecker.resolver.resolveTypeReference(functionDeclaration.returnTypeAnnotation, enclosingDecl, resolutionContext).symbol; - resolutionContext.resolvingTypeReference = currentResolvingTypeReference; - if (returnTypeSymbol) { - inContextuallyTypedAssignment = true; - contextualType = returnTypeSymbol; - } - } else { - var currentContextualType = resolutionContext.getContextualType(); - if (currentContextualType && currentContextualType.isFunction()) { - var currentContextualTypeSignatureSymbol = currentContextualType.getDeclarations()[0].getSignatureSymbol(); - var currentContextualTypeReturnTypeSymbol = currentContextualTypeSignatureSymbol.getReturnType(); - if (currentContextualTypeReturnTypeSymbol) { - inContextuallyTypedAssignment = true; - contextualType = currentContextualTypeReturnTypeSymbol; - } - } - } - } - - resolutionContext.pushContextualType(contextualType, false, null); - - break; - - case 11 /* TypeRef */: - case 9 /* TypeParameter */: - resolutionContext.resolvingTypeReference = true; - break; - } - - var decl = semanticInfo.getDeclForAST(current); - if (decl && !(decl.getKind() & (1024 /* Variable */ | 2048 /* Parameter */ | 8192 /* TypeParameter */))) { - enclosingDecl = decl; - enclosingDeclAST = current; - } - } - - if (path.isNameOfInterface() || path.isInClassImplementsList() || path.isInInterfaceExtendsList()) { - resolutionContext.resolvingTypeReference = true; - } - - if (path.ast().nodeType === 20 /* Name */ && path.count() > 1) { - for (var i = path.count() - 1; i >= 0; i--) { - if (path.asts[path.top - 1].nodeType === 32 /* MemberAccessExpression */ && (path.asts[path.top - 1]).operand2 === path.asts[path.top]) { - path.pop(); - } else { - break; - } - } - } - - return { - ast: path.ast(), - enclosingDecl: enclosingDecl, - resolutionContext: resolutionContext, - inContextuallyTypedAssignment: inContextuallyTypedAssignment - }; - }; - - TypeScriptCompiler.prototype.pullGetSymbolInformationFromPath = function (path, document) { - var context = this.extractResolutionContextFromPath(path, document); - if (!context) { - return null; - } - - TypeScript.globalSemanticInfoChain = this.semanticInfoChain; - if (TypeScript.globalBinder) { - TypeScript.globalBinder.semanticInfoChain = this.semanticInfoChain; - } - - var symbolAndDiagnostics = this.pullTypeChecker.resolver.resolveAST(path.ast(), context.inContextuallyTypedAssignment, context.enclosingDecl, context.resolutionContext); - var symbol = symbolAndDiagnostics && symbolAndDiagnostics.symbol; - - return { - symbol: symbol, - ast: path.ast(), - enclosingScopeSymbol: this.getSymbolOfDeclaration(context.enclosingDecl) - }; - }; - - TypeScriptCompiler.prototype.pullGetDeclarationSymbolInformation = function (path, document) { - var script = document.script; - var scriptName = document.fileName; - - var ast = path.ast(); - - if (ast.nodeType !== 13 /* ClassDeclaration */ && ast.nodeType !== 14 /* InterfaceDeclaration */ && ast.nodeType !== 15 /* ModuleDeclaration */ && ast.nodeType !== 12 /* FunctionDeclaration */ && ast.nodeType !== 17 /* VariableDeclarator */) { - return null; - } - - var context = this.extractResolutionContextFromPath(path, document); - if (!context) { - return null; - } - - TypeScript.globalSemanticInfoChain = this.semanticInfoChain; - if (TypeScript.globalBinder) { - TypeScript.globalBinder.semanticInfoChain = this.semanticInfoChain; - } - - var semanticInfo = this.semanticInfoChain.getUnit(scriptName); - var decl = semanticInfo.getDeclForAST(ast); - var symbol = (decl.getKind() & TypeScript.PullElementKind.SomeSignature) ? decl.getSignatureSymbol() : decl.getSymbol(); - this.pullTypeChecker.resolver.resolveDeclaredSymbol(symbol, null, context.resolutionContext); - - symbol.setUnresolved(); - - return { - symbol: symbol, - ast: path.ast(), - enclosingScopeSymbol: this.getSymbolOfDeclaration(context.enclosingDecl) - }; - }; - - TypeScriptCompiler.prototype.pullGetCallInformationFromPath = function (path, document) { - if (path.ast().nodeType !== 36 /* InvocationExpression */ && path.ast().nodeType !== 37 /* ObjectCreationExpression */) { - return null; - } - - var isNew = (path.ast().nodeType === 37 /* ObjectCreationExpression */); - - var context = this.extractResolutionContextFromPath(path, document); - if (!context) { - return null; - } - - TypeScript.globalSemanticInfoChain = this.semanticInfoChain; - if (TypeScript.globalBinder) { - TypeScript.globalBinder.semanticInfoChain = this.semanticInfoChain; - } - - var callResolutionResults = new TypeScript.PullAdditionalCallResolutionData(); - - if (isNew) { - this.pullTypeChecker.resolver.resolveNewExpression(path.ast(), context.inContextuallyTypedAssignment, context.enclosingDecl, context.resolutionContext, callResolutionResults); - } else { - this.pullTypeChecker.resolver.resolveCallExpression(path.ast(), context.inContextuallyTypedAssignment, context.enclosingDecl, context.resolutionContext, callResolutionResults); - } - - return { - targetSymbol: callResolutionResults.targetSymbol, - resolvedSignatures: callResolutionResults.resolvedSignatures, - candidateSignature: callResolutionResults.candidateSignature, - ast: path.ast(), - enclosingScopeSymbol: this.getSymbolOfDeclaration(context.enclosingDecl), - isConstructorCall: isNew - }; - }; - - TypeScriptCompiler.prototype.pullGetVisibleMemberSymbolsFromPath = function (path, document) { - TypeScript.globalSemanticInfoChain = this.semanticInfoChain; - if (TypeScript.globalBinder) { - TypeScript.globalBinder.semanticInfoChain = this.semanticInfoChain; - } - - var context = this.extractResolutionContextFromPath(path, document); - if (!context) { - return null; - } - - var symbols = this.pullTypeChecker.resolver.getVisibleMembersFromExpression(path.ast(), context.enclosingDecl, context.resolutionContext); - if (!symbols) { - return null; - } - - return { - symbols: symbols, - enclosingScopeSymbol: this.getSymbolOfDeclaration(context.enclosingDecl) - }; - }; - - TypeScriptCompiler.prototype.pullGetVisibleDeclsFromPath = function (path, document) { - TypeScript.globalSemanticInfoChain = this.semanticInfoChain; - if (TypeScript.globalBinder) { - TypeScript.globalBinder.semanticInfoChain = this.semanticInfoChain; - } - - var context = this.extractResolutionContextFromPath(path, document); - if (!context) { - return null; - } - - var symbols = null; - - return this.pullTypeChecker.resolver.getVisibleDecls(context.enclosingDecl, context.resolutionContext); - }; - - TypeScriptCompiler.prototype.pullGetContextualMembersFromPath = function (path, document) { - TypeScript.globalSemanticInfoChain = this.semanticInfoChain; - if (TypeScript.globalBinder) { - TypeScript.globalBinder.semanticInfoChain = this.semanticInfoChain; - } - - if (path.ast().nodeType !== 22 /* ObjectLiteralExpression */) { - return null; - } - - var context = this.extractResolutionContextFromPath(path, document); - if (!context) { - return null; - } - - var members = this.pullTypeChecker.resolver.getVisibleContextSymbols(context.enclosingDecl, context.resolutionContext); - - return { - symbols: members, - enclosingScopeSymbol: this.getSymbolOfDeclaration(context.enclosingDecl) - }; - }; - - TypeScriptCompiler.prototype.pullGetDeclInformation = function (decl, path, document) { - var context = this.extractResolutionContextFromPath(path, document); - if (!context) { - return null; - } - - TypeScript.globalSemanticInfoChain = this.semanticInfoChain; - if (TypeScript.globalBinder) { - TypeScript.globalBinder.semanticInfoChain = this.semanticInfoChain; - } - - var symbol = decl.getSymbol(); - this.pullTypeChecker.resolver.resolveDeclaredSymbol(symbol, context.enclosingDecl, context.resolutionContext); - symbol.setUnresolved(); - - return { - symbol: symbol, - ast: path.ast(), - enclosingScopeSymbol: this.getSymbolOfDeclaration(context.enclosingDecl) - }; - }; - - TypeScriptCompiler.prototype.pullGetTypeInfoAtPosition = function (pos, document) { - var _this = this; - return this.timeFunction("pullGetTypeInfoAtPosition for pos " + pos + ":", function () { - return _this.resolvePosition(pos, document); - }); - }; - - TypeScriptCompiler.prototype.getTopLevelDeclarations = function (scriptName) { - var unit = this.semanticInfoChain.getUnit(scriptName); - - if (!unit) { - return null; - } - - return unit.getTopLevelDecls(); - }; - - TypeScriptCompiler.prototype.reportDiagnostics = function (errors, errorReporter) { - for (var i = 0; i < errors.length; i++) { - errorReporter.addDiagnostic(errors[i]); - } - }; - return TypeScriptCompiler; - })(); - TypeScript.TypeScriptCompiler = TypeScriptCompiler; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (CompilerDiagnostics) { - CompilerDiagnostics.debug = false; - - CompilerDiagnostics.diagnosticWriter = null; - - CompilerDiagnostics.analysisPass = 0; - - function Alert(output) { - if (CompilerDiagnostics.diagnosticWriter) { - CompilerDiagnostics.diagnosticWriter.Alert(output); - } - } - CompilerDiagnostics.Alert = Alert; - - function debugPrint(s) { - if (CompilerDiagnostics.debug) { - Alert(s); - } - } - CompilerDiagnostics.debugPrint = debugPrint; - - function assert(condition, s) { - if (CompilerDiagnostics.debug) { - if (!condition) { - Alert(s); - } - } - } - CompilerDiagnostics.assert = assert; - })(TypeScript.CompilerDiagnostics || (TypeScript.CompilerDiagnostics = {})); - var CompilerDiagnostics = TypeScript.CompilerDiagnostics; - - var NullLogger = (function () { - function NullLogger() { - } - NullLogger.prototype.information = function () { - return false; - }; - NullLogger.prototype.debug = function () { - return false; - }; - NullLogger.prototype.warning = function () { - return false; - }; - NullLogger.prototype.error = function () { - return false; - }; - NullLogger.prototype.fatal = function () { - return false; - }; - NullLogger.prototype.log = function (s) { - }; - return NullLogger; - })(); - TypeScript.NullLogger = NullLogger; - - function timeFunction(logger, funcDescription, func) { - var start = (new Date()).getTime(); - var result = func(); - var end = (new Date()).getTime(); - logger.log(funcDescription + " completed in " + (end - start) + " msec"); - return result; - } - TypeScript.timeFunction = timeFunction; -})(TypeScript || (TypeScript = {})); -var IOUtils; -(function (IOUtils) { - function createDirectoryStructure(ioHost, dirName) { - if (ioHost.directoryExists(dirName)) { - return; - } - - var parentDirectory = ioHost.dirName(dirName); - if (parentDirectory != "") { - createDirectoryStructure(ioHost, parentDirectory); - } - ioHost.createDirectory(dirName); - } - - function writeFileAndFolderStructure(ioHost, fileName, contents, writeByteOrderMark) { - var path = ioHost.resolvePath(fileName); - var dirName = ioHost.dirName(path); - createDirectoryStructure(ioHost, dirName); - return ioHost.writeFile(path, contents, writeByteOrderMark); - } - IOUtils.writeFileAndFolderStructure = writeFileAndFolderStructure; - - function throwIOError(message, error) { - var errorMessage = message; - if (error && error.message) { - errorMessage += (" " + error.message); - } - throw new Error(errorMessage); - } - IOUtils.throwIOError = throwIOError; - - var BufferedTextWriter = (function () { - function BufferedTextWriter(writer, capacity) { - if (typeof capacity === "undefined") { capacity = 1024; } - this.writer = writer; - this.capacity = capacity; - this.buffer = ""; - } - BufferedTextWriter.prototype.Write = function (str) { - this.buffer += str; - if (this.buffer.length >= this.capacity) { - this.writer.Write(this.buffer); - this.buffer = ""; - } - }; - BufferedTextWriter.prototype.WriteLine = function (str) { - this.Write(str + '\r\n'); - }; - BufferedTextWriter.prototype.Close = function () { - this.writer.Write(this.buffer); - this.writer.Close(); - this.buffer = null; - }; - return BufferedTextWriter; - })(); - IOUtils.BufferedTextWriter = BufferedTextWriter; -})(IOUtils || (IOUtils = {})); - -var IO = (function () { - function getWindowsScriptHostIO() { - var fso = new ActiveXObject("Scripting.FileSystemObject"); - var streamObjectPool = []; - - function getStreamObject() { - if (streamObjectPool.length > 0) { - return streamObjectPool.pop(); - } else { - return new ActiveXObject("ADODB.Stream"); - } - } - - function releaseStreamObject(obj) { - streamObjectPool.push(obj); - } - - var args = []; - for (var i = 0; i < WScript.Arguments.length; i++) { - args[i] = WScript.Arguments.Item(i); - } - - return { - readFile: function (path) { - return Environment.readFile(path); - }, - writeFile: function (path, contents, writeByteOrderMark) { - Environment.writeFile(path, contents, writeByteOrderMark); - }, - fileExists: function (path) { - return fso.FileExists(path); - }, - resolvePath: function (path) { - return fso.GetAbsolutePathName(path); - }, - dirName: function (path) { - return fso.GetParentFolderName(path); - }, - findFile: function (rootPath, partialFilePath) { - var path = fso.GetAbsolutePathName(rootPath) + "/" + partialFilePath; - - while (true) { - if (fso.FileExists(path)) { - return { fileInformation: this.readFile(path), path: path }; - } else { - rootPath = fso.GetParentFolderName(fso.GetAbsolutePathName(rootPath)); - - if (rootPath == "") { - return null; - } else { - path = fso.BuildPath(rootPath, partialFilePath); - } - } - } - }, - deleteFile: function (path) { - try { - if (fso.FileExists(path)) { - fso.DeleteFile(path, true); - } - } catch (e) { - IOUtils.throwIOError("Couldn't delete file '" + path + "'.", e); - } - }, - directoryExists: function (path) { - return fso.FolderExists(path); - }, - createDirectory: function (path) { - try { - if (!this.directoryExists(path)) { - fso.CreateFolder(path); - } - } catch (e) { - IOUtils.throwIOError("Couldn't create directory '" + path + "'.", e); - } - }, - dir: function (path, spec, options) { - options = options || {}; - function filesInFolder(folder, root) { - var paths = []; - var fc; - - if (options.recursive) { - fc = new Enumerator(folder.subfolders); - - for (; !fc.atEnd(); fc.moveNext()) { - paths = paths.concat(filesInFolder(fc.item(), root + "/" + fc.item().Name)); - } - } - - fc = new Enumerator(folder.files); - - for (; !fc.atEnd(); fc.moveNext()) { - if (!spec || fc.item().Name.match(spec)) { - paths.push(root + "/" + fc.item().Name); - } - } - - return paths; - } - - var folder = fso.GetFolder(path); - var paths = []; - - return filesInFolder(folder, path); - }, - print: function (str) { - WScript.StdOut.Write(str); - }, - printLine: function (str) { - WScript.Echo(str); - }, - arguments: args, - stderr: WScript.StdErr, - stdout: WScript.StdOut, - watchFile: null, - run: function (source, fileName) { - try { - eval(source); - } catch (e) { - IOUtils.throwIOError("Error while executing file '" + fileName + "'.", e); - } - }, - getExecutingFilePath: function () { - return WScript.ScriptFullName; - }, - quit: function (exitCode) { - if (typeof exitCode === "undefined") { exitCode = 0; } - try { - WScript.Quit(exitCode); - } catch (e) { - } - } - }; - } - ; - - function getNodeIO() { - var _fs = require('fs'); - var _path = require('path'); - var _module = require('module'); - - return { - readFile: function (file) { - return Environment.readFile(file); - }, - writeFile: function (path, contents, writeByteOrderMark) { - Environment.writeFile(path, contents, writeByteOrderMark); - }, - deleteFile: function (path) { - try { - _fs.unlinkSync(path); - } catch (e) { - IOUtils.throwIOError("Couldn't delete file '" + path + "'.", e); - } - }, - fileExists: function (path) { - return _fs.existsSync(path); - }, - dir: function dir(path, spec, options) { - options = options || {}; - - function filesInFolder(folder) { - var paths = []; - - try { - var files = _fs.readdirSync(folder); - for (var i = 0; i < files.length; i++) { - var stat = _fs.statSync(folder + "/" + files[i]); - if (options.recursive && stat.isDirectory()) { - paths = paths.concat(filesInFolder(folder + "/" + files[i])); - } else if (stat.isFile() && (!spec || files[i].match(spec))) { - paths.push(folder + "/" + files[i]); - } - } - } catch (err) { - } - - return paths; - } - - return filesInFolder(path); - }, - createDirectory: function (path) { - try { - if (!this.directoryExists(path)) { - _fs.mkdirSync(path); - } - } catch (e) { - IOUtils.throwIOError("Couldn't create directory '" + path + "'.", e); - } - }, - directoryExists: function (path) { - return _fs.existsSync(path) && _fs.statSync(path).isDirectory(); - }, - resolvePath: function (path) { - return _path.resolve(path); - }, - dirName: function (path) { - return _path.dirname(path); - }, - findFile: function (rootPath, partialFilePath) { - var path = rootPath + "/" + partialFilePath; - - while (true) { - if (_fs.existsSync(path)) { - return { fileInformation: this.readFile(path), path: path }; - } else { - var parentPath = _path.resolve(rootPath, ".."); - - if (rootPath === parentPath) { - return null; - } else { - rootPath = parentPath; - path = _path.resolve(rootPath, partialFilePath); - } - } - } - }, - print: function (str) { - process.stdout.write(str); - }, - printLine: function (str) { - process.stdout.write(str + '\n'); - }, - arguments: process.argv.slice(2), - stderr: { - Write: function (str) { - process.stderr.write(str); - }, - WriteLine: function (str) { - process.stderr.write(str + '\n'); - }, - Close: function () { - } - }, - stdout: { - Write: function (str) { - process.stdout.write(str); - }, - WriteLine: function (str) { - process.stdout.write(str + '\n'); - }, - Close: function () { - } - }, - watchFile: function (fileName, callback) { - var firstRun = true; - var processingChange = false; - - var fileChanged = function (curr, prev) { - if (!firstRun) { - if (curr.mtime < prev.mtime) { - return; - } - - _fs.unwatchFile(fileName, fileChanged); - if (!processingChange) { - processingChange = true; - callback(fileName); - setTimeout(function () { - processingChange = false; - }, 100); - } - } - firstRun = false; - _fs.watchFile(fileName, { persistent: true, interval: 500 }, fileChanged); - }; - - fileChanged(); - return { - fileName: fileName, - close: function () { - _fs.unwatchFile(fileName, fileChanged); - } - }; - }, - run: function (source, fileName) { - require.main.fileName = fileName; - require.main.paths = _module._nodeModulePaths(_path.dirname(_fs.realpathSync(fileName))); - require.main._compile(source, fileName); - }, - getExecutingFilePath: function () { - return process.mainModule.filename; - }, - quit: process.exit - }; - } - ; - - if (typeof ActiveXObject === "function") - return getWindowsScriptHostIO(); else if (typeof module !== 'undefined' && module.exports) - return getNodeIO(); else - return null; -})(); -var OptionsParser = (function () { - function OptionsParser(host) { - this.host = host; - this.DEFAULT_SHORT_FLAG = "-"; - this.DEFAULT_LONG_FLAG = "--"; - this.unnamed = []; - this.options = []; - } - OptionsParser.prototype.findOption = function (arg) { - for (var i = 0; i < this.options.length; i++) { - if (arg === this.options[i].short || arg === this.options[i].name) { - return this.options[i]; - } - } - - return null; - }; - - OptionsParser.prototype.printUsage = function () { - this.host.printLine("Syntax: tsc [options] [file ..]"); - this.host.printLine(""); - this.host.printLine("Examples: tsc hello.ts"); - this.host.printLine(" tsc --out foo.js foo.ts"); - this.host.printLine(" tsc @args.txt"); - this.host.printLine(""); - this.host.printLine("Options:"); - - var output = []; - var maxLength = 0; - var i = 0; - - this.options = this.options.sort(function (a, b) { - var aName = a.name.toLowerCase(); - var bName = b.name.toLowerCase(); - - if (aName > bName) { - return 1; - } else if (aName < bName) { - return -1; - } else { - return 0; - } - }); - - for (i = 0; i < this.options.length; i++) { - var option = this.options[i]; - - if (option.experimental) { - continue; - } - - if (!option.usage) { - break; - } - - var usageString = " "; - var type = option.type ? " " + option.type.toUpperCase() : ""; - - if (option.short) { - usageString += this.DEFAULT_SHORT_FLAG + option.short + type + ", "; - } - - usageString += this.DEFAULT_LONG_FLAG + option.name + type; - - output.push([usageString, option.usage]); - - if (usageString.length > maxLength) { - maxLength = usageString.length; - } - } - - output.push([" @", "Insert command line options and files from a file."]); - - for (i = 0; i < output.length; i++) { - this.host.printLine(output[i][0] + (new Array(maxLength - output[i][0].length + 3)).join(" ") + output[i][1]); - } - }; - - OptionsParser.prototype.option = function (name, config, short) { - if (!config) { - config = short; - short = null; - } - - config.name = name; - config.short = short; - config.flag = false; - - this.options.push(config); - }; - - OptionsParser.prototype.flag = function (name, config, short) { - if (!config) { - config = short; - short = null; - } - - config.name = name; - config.short = short; - config.flag = true; - - this.options.push(config); - }; - - OptionsParser.prototype.parseString = function (argString) { - var position = 0; - var tokens = argString.match(/\s+|"|[^\s"]+/g); - - function peek() { - return tokens[position]; - } - - function consume() { - return tokens[position++]; - } - - function consumeQuotedString() { - var value = ''; - consume(); - - var token = peek(); - - while (token && token !== '"') { - consume(); - - value += token; - - token = peek(); - } - - consume(); - - return value; - } - - var args = []; - var currentArg = ''; - - while (position < tokens.length) { - var token = peek(); - - if (token === '"') { - currentArg += consumeQuotedString(); - } else if (token.match(/\s/)) { - if (currentArg.length > 0) { - args.push(currentArg); - currentArg = ''; - } - - consume(); - } else { - consume(); - currentArg += token; - } - } - - if (currentArg.length > 0) { - args.push(currentArg); - } - - this.parse(args); - }; - - OptionsParser.prototype.parse = function (args) { - var position = 0; - - function consume() { - return args[position++]; - } - - while (position < args.length) { - var current = consume(); - var match = current.match(/^(--?|@)(.*)/); - var value = null; - - if (match) { - if (match[1] === '@') { - this.parseString(this.host.readFile(match[2]).contents()); - } else { - var arg = match[2]; - var option = this.findOption(arg); - - if (option === null) { - this.host.printLine("Unknown option '" + arg + "'"); - this.host.printLine("Use the '--help' flag to see options"); - } else { - if (!option.flag) - value = consume(); - - option.set(value); - } - } - } else { - this.unnamed.push(current); - } - } - }; - return OptionsParser; -})(); -var DiagnosticsLogger = (function () { - function DiagnosticsLogger(ioHost) { - this.ioHost = ioHost; - } - DiagnosticsLogger.prototype.information = function () { - return false; - }; - DiagnosticsLogger.prototype.debug = function () { - return false; - }; - DiagnosticsLogger.prototype.warning = function () { - return false; - }; - DiagnosticsLogger.prototype.error = function () { - return false; - }; - DiagnosticsLogger.prototype.fatal = function () { - return false; - }; - DiagnosticsLogger.prototype.log = function (s) { - this.ioHost.stdout.WriteLine(s); - }; - return DiagnosticsLogger; -})(); - -var ErrorReporter = (function () { - function ErrorReporter(ioHost, compilationEnvironment) { - this.ioHost = ioHost; - this.hasErrors = false; - this.setCompilationEnvironment(compilationEnvironment); - } - ErrorReporter.prototype.addDiagnostic = function (diagnostic) { - this.hasErrors = true; - - if (diagnostic.fileName()) { - var soruceUnit = this.compilationEnvironment.getSourceUnit(diagnostic.fileName()); - if (!soruceUnit) { - soruceUnit = new TypeScript.SourceUnit(diagnostic.fileName(), this.ioHost.readFile(diagnostic.fileName())); - } - var lineMap = new TypeScript.LineMap(soruceUnit.getLineStartPositions(), soruceUnit.getLength()); - var lineCol = { line: -1, character: -1 }; - lineMap.fillLineAndCharacterFromPosition(diagnostic.start(), lineCol); - - this.ioHost.stderr.Write(diagnostic.fileName() + "(" + (lineCol.line + 1) + "," + (lineCol.character + 1) + "): "); - } - - this.ioHost.stderr.WriteLine(diagnostic.message()); - }; - - ErrorReporter.prototype.setCompilationEnvironment = function (compilationEnvironment) { - this.compilationEnvironment = compilationEnvironment; - }; - - ErrorReporter.prototype.reset = function () { - this.hasErrors = false; - }; - return ErrorReporter; -})(); - -var CommandLineHost = (function () { - function CommandLineHost(compilationSettings, errorReporter) { - this.compilationSettings = compilationSettings; - this.errorReporter = errorReporter; - this.pathMap = {}; - this.resolvedPaths = {}; - } - CommandLineHost.prototype.getPathIdentifier = function (path) { - return this.compilationSettings.useCaseSensitiveFileResolution ? path : path.toLocaleUpperCase(); - }; - - CommandLineHost.prototype.isResolved = function (path) { - return this.resolvedPaths[this.getPathIdentifier(this.pathMap[path])] != undefined; - }; - - CommandLineHost.prototype.resolveCompilationEnvironment = function (preEnv, resolver, traceDependencies) { - var _this = this; - var resolvedEnv = new TypeScript.CompilationEnvironment(preEnv.compilationSettings, preEnv.ioHost); - - var nCode = preEnv.code.length; - var path = ""; - - this.errorReporter.setCompilationEnvironment(resolvedEnv); - - var resolutionDispatcher = { - errorReporter: this.errorReporter, - postResolution: function (path, code) { - var pathId = _this.getPathIdentifier(path); - if (!_this.resolvedPaths[pathId]) { - resolvedEnv.code.push(code); - _this.resolvedPaths[pathId] = true; - } - } - }; - - for (var i = 0; i < nCode; i++) { - path = TypeScript.switchToForwardSlashes(preEnv.ioHost.resolvePath(preEnv.code[i].path)); - this.pathMap[preEnv.code[i].path] = path; - resolver.resolveCode(path, "", false, resolutionDispatcher); - } - - return resolvedEnv; - }; - return CommandLineHost; -})(); - -var BatchCompiler = (function () { - function BatchCompiler(ioHost) { - this.ioHost = ioHost; - this.resolvedEnvironment = null; - this.hasResolveErrors = false; - this.compilerVersion = "0.9.0.0"; - this.printedVersion = false; - this.errorReporter = null; - this.compilationSettings = new TypeScript.CompilationSettings(); - this.compilationEnvironment = new TypeScript.CompilationEnvironment(this.compilationSettings, this.ioHost); - this.errorReporter = new ErrorReporter(this.ioHost, this.compilationEnvironment); - } - BatchCompiler.prototype.resolve = function () { - var resolver = new TypeScript.CodeResolver(this.compilationEnvironment); - var commandLineHost = new CommandLineHost(this.compilationSettings, this.errorReporter); - var ret = commandLineHost.resolveCompilationEnvironment(this.compilationEnvironment, resolver, true); - - for (var i = 0; i < this.compilationEnvironment.code.length; i++) { - if (!commandLineHost.isResolved(this.compilationEnvironment.code[i].path)) { - var path = this.compilationEnvironment.code[i].path; - if (!TypeScript.isTSFile(path) && !TypeScript.isDTSFile(path)) { - this.errorReporter.addDiagnostic(new TypeScript.Diagnostic(null, 0, 0, 269 /* Unknown_extension_for_file___0__Only__ts_and_d_ts_extensions_are_allowed */, [path])); - } else { - this.errorReporter.addDiagnostic(new TypeScript.Diagnostic(null, 0, 0, 268 /* Could_not_find_file___0_ */, [path])); - } - } - } - - return ret; - }; - - BatchCompiler.prototype.compile = function () { - var _this = this; - if (typeof localizedDiagnosticMessages === "undefined") { - localizedDiagnosticMessages = null; - } - - var logger = this.compilationSettings.gatherDiagnostics ? new DiagnosticsLogger(this.ioHost) : new TypeScript.NullLogger(); - var compiler = new TypeScript.TypeScriptCompiler(logger, this.compilationSettings, localizedDiagnosticMessages); - - var anySyntacticErrors = false; - var anySemanticErrors = false; - - for (var iCode = 0; iCode < this.resolvedEnvironment.code.length; iCode++) { - var code = this.resolvedEnvironment.code[iCode]; - - if (!this.compilationSettings.resolve) { - code.fileInformation = this.ioHost.readFile(code.path); - - if (this.compilationSettings.generateDeclarationFiles) { - TypeScript.CompilerDiagnostics.assert(code.referencedFiles === null, "With no resolve option, referenced files need to null"); - code.referencedFiles = TypeScript.getReferencedFiles(code.path, code); - } - } - - if (code.fileInformation != null) { - compiler.addSourceUnit(code.path, TypeScript.ScriptSnapshot.fromString(code.fileInformation.contents()), code.fileInformation.byteOrderMark(), 0, false, code.referencedFiles); - - var syntacticDiagnostics = compiler.getSyntacticDiagnostics(code.path); - compiler.reportDiagnostics(syntacticDiagnostics, this.errorReporter); - - if (syntacticDiagnostics.length > 0) { - anySyntacticErrors = true; - } - } - } - - if (anySyntacticErrors) { - return true; - } - - compiler.pullTypeCheck(); - var fileNames = compiler.fileNameToDocument.getAllKeys(); - - for (var i = 0, n = fileNames.length; i < n; i++) { - var fileName = fileNames[i]; - var semanticDiagnostics = compiler.getSemanticDiagnostics(fileName); - if (semanticDiagnostics.length > 0) { - anySemanticErrors = true; - compiler.reportDiagnostics(semanticDiagnostics, this.errorReporter); - } - } - - var emitterIOHost = { - writeFile: function (fileName, contents, writeByteOrderMark) { - return IOUtils.writeFileAndFolderStructure(_this.ioHost, fileName, contents, writeByteOrderMark); - }, - directoryExists: this.ioHost.directoryExists, - fileExists: this.ioHost.fileExists, - resolvePath: this.ioHost.resolvePath - }; - - var mapInputToOutput = function (inputFile, outputFile) { - _this.resolvedEnvironment.inputFileNameToOutputFileName.addOrUpdate(inputFile, outputFile); - }; - - var emitDiagnostics = compiler.emitAll(emitterIOHost, mapInputToOutput); - compiler.reportDiagnostics(emitDiagnostics, this.errorReporter); - if (emitDiagnostics.length > 0) { - return true; - } - - if (anySemanticErrors) { - return true; - } - - var emitDeclarationsDiagnostics = compiler.emitAllDeclarations(); - compiler.reportDiagnostics(emitDeclarationsDiagnostics, this.errorReporter); - if (emitDeclarationsDiagnostics.length > 0) { - return true; - } - - return false; - }; - - BatchCompiler.prototype.updateCompile = function () { - if (typeof localizedDiagnosticMessages === "undefined") { - localizedDiagnosticMessages = null; - } - - var logger = this.compilationSettings.gatherDiagnostics ? new DiagnosticsLogger(this.ioHost) : new TypeScript.NullLogger(); - var compiler = new TypeScript.TypeScriptCompiler(logger, this.compilationSettings, localizedDiagnosticMessages); - - var anySyntacticErrors = false; - var foundLib = false; - - for (var iCode = 0; iCode <= this.resolvedEnvironment.code.length; iCode++) { - var code = this.resolvedEnvironment.code[iCode]; - - if (code.path.indexOf("lib.d.ts") != -1) { - foundLib = true; - } else if ((foundLib && iCode > 1) || (!foundLib && iCode > 0)) { - break; - } - - this.ioHost.stdout.WriteLine("Consuming " + this.resolvedEnvironment.code[iCode].path + "..."); - - if (!this.compilationSettings.resolve) { - code.fileInformation = this.ioHost.readFile(code.path); - - if (this.compilationSettings.generateDeclarationFiles) { - TypeScript.CompilerDiagnostics.assert(code.referencedFiles === null, "With no resolve option, referenced files need to null"); - code.referencedFiles = TypeScript.getReferencedFiles(code.path, code); - } - } - - if (code.fileInformation != null) { - compiler.addSourceUnit(code.path, TypeScript.ScriptSnapshot.fromString(code.fileInformation.contents()), code.fileInformation.byteOrderMark(), 0, true, code.referencedFiles); - - var syntacticDiagnostics = compiler.getSyntacticDiagnostics(code.path); - compiler.reportDiagnostics(syntacticDiagnostics, this.errorReporter); - - if (syntacticDiagnostics.length > 0) { - anySyntacticErrors = true; - } - } - } - - this.ioHost.stdout.WriteLine("**** Initial type check errors:"); - compiler.pullTypeCheck(); - - var semanticDiagnostics; - - for (var i = 0; i < iCode; i++) { - semanticDiagnostics = compiler.getSemanticDiagnostics(this.resolvedEnvironment.code[i].path); - compiler.reportDiagnostics(semanticDiagnostics, this.errorReporter); - } - - if (iCode && iCode <= this.resolvedEnvironment.code.length - 1) { - var lastTypecheckedFileName = this.resolvedEnvironment.code[iCode - 1].path; - var snapshot; - - for (; iCode < this.resolvedEnvironment.code.length; iCode++) { - this.ioHost.stdout.WriteLine("**** Update type check and errors for " + this.resolvedEnvironment.code[iCode].path + ":"); - var text = this.resolvedEnvironment.code[iCode].getText(0, this.resolvedEnvironment.code[iCode].getLength()); - snapshot = TypeScript.ScriptSnapshot.fromString(text); - compiler.updateSourceUnit(lastTypecheckedFileName, snapshot, 0, true, null); - - semanticDiagnostics = compiler.getSemanticDiagnostics(lastTypecheckedFileName); - compiler.reportDiagnostics(semanticDiagnostics, this.errorReporter); - } - } - - return false; - }; - - BatchCompiler.prototype.run = function () { - for (var i in this.resolvedEnvironment.code) { - var outputFileName = this.resolvedEnvironment.inputFileNameToOutputFileName.lookup(this.resolvedEnvironment.code[i].path) || undefined; - if (this.ioHost.fileExists(outputFileName)) { - var unitRes = this.ioHost.readFile(outputFileName); - this.ioHost.run(unitRes.contents(), outputFileName); - } - } - }; - - BatchCompiler.prototype.batchCompile = function () { - var _this = this; - TypeScript.CompilerDiagnostics.diagnosticWriter = { Alert: function (s) { - _this.ioHost.printLine(s); - } }; - - var code; - - var opts = new OptionsParser(this.ioHost); - - opts.option('out', { - usage: 'Concatenate and emit output to single file | Redirect output structure to the directory', - type: 'file|directory', - set: function (str) { - _this.compilationSettings.outputOption = str; - } - }); - - opts.flag('sourcemap', { - usage: 'Generates corresponding .map file', - set: function () { - _this.compilationSettings.mapSourceFiles = true; - } - }); - - opts.flag('fullSourceMapPath', { - usage: 'Writes the full path of map file in the generated js file', - experimental: true, - set: function () { - _this.compilationSettings.emitFullSourceMapPath = true; - } - }); - - opts.flag('declaration', { - usage: 'Generates corresponding .d.ts file', - set: function () { - _this.compilationSettings.generateDeclarationFiles = true; - } - }, 'd'); - - if (this.ioHost.watchFile) { - opts.flag('watch', { - usage: 'Watch input files', - set: function () { - _this.compilationSettings.watch = true; - } - }, 'w'); - } - - opts.flag('exec', { - usage: 'Execute the script after compilation', - set: function () { - _this.compilationSettings.exec = true; - } - }, 'e'); - - opts.flag('minw', { - usage: 'Minimize whitespace', - experimental: true, - set: function () { - _this.compilationSettings.minWhitespace = true; - } - }, 'mw'); - - opts.flag('const', { - usage: 'Propagate constants to emitted code', - experimental: true, - set: function () { - _this.compilationSettings.propagateConstants = true; - } - }); - - opts.flag('comments', { - usage: 'Emit comments to output', - set: function () { - _this.compilationSettings.emitComments = true; - } - }, 'c'); - - opts.flag('noresolve', { - usage: 'Skip resolution and preprocessing', - experimental: true, - set: function () { - _this.compilationSettings.resolve = false; - } - }); - - opts.flag('debug', { - usage: 'Print debug output', - experimental: true, - set: function () { - TypeScript.CompilerDiagnostics.debug = true; - } - }); - - opts.flag('nolib', { - usage: 'Do not include a default lib.d.ts with global declarations', - set: function () { - _this.compilationSettings.useDefaultLib = false; - } - }); - - opts.flag('diagnostics', { - usage: 'gather diagnostic info about the compilation process', - experimental: true, - set: function () { - _this.compilationSettings.gatherDiagnostics = true; - } - }); - - opts.flag('update', { - usage: 'Typecheck each file as an update on the first', - experimental: true, - set: function () { - _this.compilationSettings.updateTC = true; - } - }); - - opts.option('target', { - usage: 'Specify ECMAScript target version: "ES3" (default), or "ES5"', - type: 'VER', - set: function (type) { - type = type.toLowerCase(); - - if (type === 'es3') { - _this.compilationSettings.codeGenTarget = 0 /* EcmaScript3 */; - } else if (type === 'es5') { - _this.compilationSettings.codeGenTarget = 1 /* EcmaScript5 */; - } else { - _this.errorReporter.addDiagnostic(new TypeScript.Diagnostic(null, 0, 0, 266 /* ECMAScript_target_version__0__not_supported___Using_default__1__code_generation */, [type, "ES3"])); - } - } - }); - - opts.option('module', { - usage: 'Specify module code generation: "commonjs" (default) or "amd"', - type: 'kind', - set: function (type) { - type = type.toLowerCase(); - - if (type === 'commonjs' || type === 'node') { - _this.compilationSettings.moduleGenTarget = 0 /* Synchronous */; - } else if (type === 'amd') { - _this.compilationSettings.moduleGenTarget = 1 /* Asynchronous */; - } else { - _this.errorReporter.addDiagnostic(new TypeScript.Diagnostic(null, 0, 0, 267 /* Module_code_generation__0__not_supported___Using_default__1__code_generation */, [type, "commonjs"])); - } - } - }); - - var printedUsage = false; - - opts.flag('help', { - usage: 'Print this message', - set: function () { - _this.printVersion(); - opts.printUsage(); - printedUsage = true; - } - }, 'h'); - - opts.flag('useCaseSensitiveFileResolution', { - usage: 'Force file resolution to be case sensitive', - experimental: true, - set: function () { - _this.compilationSettings.useCaseSensitiveFileResolution = true; - } - }); - - opts.flag('version', { - usage: 'Print the compiler\'s version: ' + this.compilerVersion, - set: function () { - _this.printVersion(); - } - }, 'v'); - - opts.flag('disallowbool', { - usage: 'Throw error for use of deprecated "bool" type', - set: function () { - _this.compilationSettings.disallowBool = true; - } - }, 'b'); - - opts.flag('disallowimportmodule', { - usage: 'Throw error for use of deprecated "module" keyword when referencing an external module. Only allow "require" keyword.', - set: function () { - _this.compilationSettings.allowModuleKeywordInExternalModuleReference = false; - } - }, 'm'); - - opts.parse(this.ioHost.arguments); - - if (this.compilationSettings.useDefaultLib) { - var compilerFilePath = this.ioHost.getExecutingFilePath(); - var binDirPath = this.ioHost.dirName(compilerFilePath); - var libStrPath = this.ioHost.resolvePath(binDirPath + "/lib.d.ts"); - code = new TypeScript.SourceUnit(libStrPath, null); - this.compilationEnvironment.code.push(code); - } - - for (var i = 0; i < opts.unnamed.length; i++) { - code = new TypeScript.SourceUnit(opts.unnamed[i], null); - this.compilationEnvironment.code.push(code); - } - - if (this.compilationEnvironment.code.length === (this.compilationSettings.useDefaultLib ? 1 : 0)) { - if (!printedUsage && !this.printedVersion) { - this.printVersion(); - opts.printUsage(); - this.ioHost.quit(1); - } - return; - } - - if (this.compilationSettings.watch) { - this.watchFiles(this.compilationEnvironment.code.slice(0)); - } else { - this.resolvedEnvironment = this.compilationSettings.resolve ? this.resolve() : this.compilationEnvironment; - - if (!this.compilationSettings.updateTC) { - this.compile(); - } else { - this.updateCompile(); - } - - if (!this.errorReporter.hasErrors) { - if (this.compilationSettings.exec) { - this.run(); - } - } - - this.ioHost.quit(this.errorReporter.hasErrors ? 1 : 0); - } - }; - - BatchCompiler.prototype.printVersion = function () { - if (!this.printedVersion) { - this.ioHost.printLine("Version " + this.compilerVersion); - this.printedVersion = true; - } - }; - - BatchCompiler.prototype.watchFiles = function (sourceFiles) { - var _this = this; - if (!this.ioHost.watchFile) { - this.errorReporter.addDiagnostic(new TypeScript.SemanticDiagnostic(null, 0, 0, 265 /* Current_host_does_not_support__w_atch_option */, null)); - return; - } - - var resolvedFiles = []; - var watchers = {}; - var firstTime = true; - - var addWatcher = function (fileName) { - if (!watchers[fileName]) { - var watcher = _this.ioHost.watchFile(fileName, onWatchedFileChange); - watchers[fileName] = watcher; - } else { - TypeScript.CompilerDiagnostics.debugPrint("Cannot watch file, it is already watched."); - } - }; - - var removeWatcher = function (fileName) { - if (watchers[fileName]) { - watchers[fileName].close(); - delete watchers[fileName]; - } else { - TypeScript.CompilerDiagnostics.debugPrint("Cannot stop watching file, it is not being watched."); - } - }; - - var onWatchedFileChange = function () { - _this.compilationEnvironment.code = sourceFiles; - - _this.errorReporter.reset(); - - _this.resolvedEnvironment = _this.compilationSettings.resolve ? _this.resolve() : _this.compilationEnvironment; - - var oldFiles = resolvedFiles; - var newFiles = []; - _this.resolvedEnvironment.code.forEach(function (sf) { - return newFiles.push(sf.path); - }); - newFiles = newFiles.sort(); - - var i = 0, j = 0; - while (i < oldFiles.length && j < newFiles.length) { - var compareResult = oldFiles[i].localeCompare(newFiles[j]); - if (compareResult === 0) { - i++; - j++; - } else if (compareResult < 0) { - removeWatcher(oldFiles[i]); - i++; - } else { - addWatcher(newFiles[j]); - j++; - } - } - - for (var k = i; k < oldFiles.length; k++) { - removeWatcher(oldFiles[k]); - } - - for (k = j; k < newFiles.length; k++) { - addWatcher(newFiles[k]); - } - - resolvedFiles = newFiles; - - if (!firstTime) { - _this.ioHost.printLine(""); - _this.ioHost.printLine("Recompiling (" + new Date() + "): "); - resolvedFiles.forEach(function (f) { - return _this.ioHost.printLine(" " + f); - }); - } - - _this.compile(); - - if (!_this.errorReporter.hasErrors && _this.compilationSettings.exec) { - try { - _this.run(); - } catch (e) { - if (e.stack) { - _this.ioHost.stderr.WriteLine('\n' + e.stack); - } - } - } - - firstTime = false; - }; - - this.ioHost.stderr = this.ioHost.stdout; - onWatchedFileChange(); - }; - return BatchCompiler; -})(); - -var batch = new BatchCompiler(IO); -batch.batchCompile(); +/*! ***************************************************************************** +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 + +THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED +WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, +MERCHANTABLITY OR NON-INFRINGEMENT. + +See the Apache Version 2.0 License for specific language governing permissions +and limitations under the License. +***************************************************************************** */ + +var TypeScript; +(function (TypeScript) { + TypeScript.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}.", + Missing_close_quote_character: "Missing close quote character.", + 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_separator_not_allowed: "Trailing separator not allowed.", + AsteriskSlash_expected: "'*/' expected.", + 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.", + Rest_parameter_must_be_last_in_list: "Rest parameter must be last in list.", + Parameter_cannot_have_question_mark_and_initializer: "Parameter cannot have question mark and initializer.", + Required_parameter_cannot_follow_optional_parameter: "Required parameter cannot follow optional parameter.", + Index_signatures_cannot_have_rest_parameters: "Index signatures cannot have rest parameters.", + Index_signature_parameter_cannot_have_accessibility_modifiers: "Index signature parameter cannot have accessibility 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.", + Implementations_are_not_allowed_in_ambient_contexts: "Implementations are not allowed in ambient contexts.", + declare_modifier_not_allowed_for_code_already_in_an_ambient_context: "'declare' modifier not allowed for code already in an ambient context.", + Initializers_are_not_allowed_in_ambient_contexts: "Initializers are not allowed in ambient contexts.", + Parameter_property_declarations_can_only_be_used_in_constructors: "Parameter property declarations can only be used in constructors.", + Function_implementation_expected: "Function implementation expected.", + Constructor_implementation_expected: "Constructor implementation expected.", + Function_overload_name_must_be_0: "Function overload name must be '{0}'.", + _0_modifier_cannot_appear_on_a_module_element: "'{0}' modifier cannot appear on a module element.", + declare_modifier_cannot_appear_on_an_interface_declaration: "'declare' modifier cannot appear on an interface declaration.", + declare_modifier_required_for_top_level_element: "'declare' modifier required for top level element.", + Rest_parameter_cannot_be_optional: "Rest parameter cannot be optional.", + Rest_parameter_cannot_have_an_initializer: "Rest parameter cannot have an initializer.", + set_accessor_must_have_one_and_only_one_parameter: "'set' accessor must have one and only one parameter.", + set_accessor_parameter_cannot_have_accessibility_modifier: "'set' accessor parameter cannot have accessibility modifier.", + 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.", + 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}'.", + Module_name_cannot_be_0: "Module name cannot be '{0}'.", + 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.", + Export_assignment_not_allowed_in_module_with_exported_element: "Export assignment not allowed in module with exported element.", + Module_cannot_have_multiple_export_assignments: "Module cannot have multiple export assignments.", + 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", + declare_modifier_not_allowed_on_import_declaration: "'declare' modifier not allowed on import declaration.", + Function_overload_must_be_static: "Function overload must be static", + Function_overload_must_not_be_static: "Function overload must not be static", + Parameter_property_declarations_cannot_be_used_in_an_ambient_context: "Parameter property declarations cannot be used in an ambient context.", + Parameter_property_declarations_cannot_be_used_in_a_constructor_overload: "Parameter property declarations cannot be used in a constructor overload.", + 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.", + Value_of_type_0_is_not_indexable_by_type_1: "Value of type '{0}' is not indexable by type '{1}'.", + Operator_0_cannot_be_applied_to_types_1_and_2: "Operator '{0}' cannot be applied to types '{1}' and '{2}'.", + Operator_0_cannot_be_applied_to_types_1_and_2_3: "Operator '{0}' cannot be applied to types '{1}' and '{2}': {3}", + Cannot_convert_0_to_1: "Cannot convert '{0}' to '{1}'.", + Cannot_convert_0_to_1_NL_2: "Cannot convert '{0}' to '{1}':{NL}{2}", + Expected_var_class_interface_or_module: "Expected var, class, interface, or module.", + Operator_0_cannot_be_applied_to_type_1: "Operator '{0}' cannot be applied to type '{1}'.", + Getter_0_already_declared: "Getter '{0}' already declared.", + Setter_0_already_declared: "Setter '{0}' already declared.", + Accessors_cannot_have_type_parameters: "Accessors cannot have type parameters.", + 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()' 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.", + Unable_to_resolve_external_module_0: "Unable to resolve 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_another_class_or_interface: "An interface may only extend another class or interface.", + An_interface_cannot_implement_another_type: "An interface cannot implement another type.", + 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}", + Invalid_new_expression: "Invalid 'new' expression.", + Call_signatures_used_in_a_new_expression_must_have_a_void_return_type: "Call signatures used in a 'new' expression must have a 'void' return type.", + Could_not_select_overload_for_new_expression: "Could not select overload for 'new' expression.", + Type_0_does_not_satisfy_the_constraint_1_for_type_parameter_2: "Type '{0}' does not satisfy the constraint '{1}' for type parameter '{2}'.", + 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_conditional_expression_cannot_be_determined_Best_common_type_could_not_be_found_between_0_and_1: "Type of conditional expression cannot be determined. Best common type could not be found between '{0}' and '{1}'.", + 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}'.", + The_property_0_does_not_exist_on_value_of_type_1: "The property '{0}' does not exist on value of type '{1}'.", + Could_not_find_symbol_0: "Could not find symbol '{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_methods_cannot_reference_class_type_parameters: "Static methods cannot reference class type parameters.", + Class_0_is_recursively_referenced_as_a_base_type_of_itself: "Class '{0}' is recursively referenced as a base type of itself.", + Interface_0_is_recursively_referenced_as_a_base_type_of_itself: "Interface '{0}' is recursively referenced as a base type of itself.", + super_property_access_is_permitted_only_in_a_constructor_instance_member_function_or_instance_member_accessor_of_a_derived_class: "'super' property access is permitted only in a constructor, instance member function, or instance member accessor of a derived class.", + super_cannot_be_referenced_in_non_derived_classes: "'super' cannot be referenced in non-derived classes.", + 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_local_functions_inside_constructors: "Super calls are not permitted outside constructors or in local functions inside constructors.", + _0_1_is_inaccessible: "'{0}.{1}' is inaccessible.", + this_cannot_be_referenced_within_module_bodies: "'this' cannot be referenced within module bodies.", + 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.", + The_type_of_a_unary_arithmetic_operation_operand_must_be_of_type_any_number_or_an_enum_type: "The type of a unary arithmetic operation 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_string_or_any: "The left-hand side of an 'in' expression must be of types 'string' or 'any'.", + 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_a_subtype_of_the_Function_interface_type: "The right-hand side of an 'instanceof' expression must be of type 'any' or a subtype of 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}'.", + Function_0_declared_a_non_void_return_type_but_has_no_return_expression: "Function '{0}' declared a non-void return type, but has no return expression.", + 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_static_initializers_in_a_class_body: "'this' cannot be referenced in static initializers in a class body.", + 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}", + Duplicate_overload_signature_for_0: "Duplicate overload signature for '{0}'.", + Duplicate_constructor_overload_signature: "Duplicate constructor overload signature.", + Duplicate_overload_call_signature: "Duplicate overload call signature.", + Duplicate_overload_construct_signature: "Duplicate overload construct signature.", + 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_local: "Overload signatures must all be exported or local.", + 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_subtype_of_any_non_specialized_signature: "Specialized overload signature is not subtype of any non-specialized signature.", + this_cannot_be_referenced_in_constructor_arguments: "'this' cannot be referenced in constructor arguments.", + Static_member_cannot_be_accessed_off_an_instance_variable: "Static member cannot be accessed off an instance variable.", + 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.", + Rest_parameters_must_be_array_types: "Rest parameters must be array types.", + 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_instance_methods_of_the_base_class_are_accessible_via_the_super_keyword: "Only public instance methods of the base class are accessible via the 'super' keyword.", + Numeric_indexer_type_0_must_be_a_subtype_of_string_indexer_type_1: "Numeric indexer type '{0}' must be a subtype of string indexer type '{1}'.", + Numeric_indexer_type_0_must_be_a_subtype_of_string_indexer_type_1_NL_2: "Numeric indexer type '{0}' must be a subtype of string indexer type '{1}':{NL}{2}", + All_numerically_named_properties_must_be_subtypes_of_numeric_indexer_type_0: "All numerically named properties must be subtypes of numeric indexer type '{0}'.", + All_numerically_named_properties_must_be_subtypes_of_numeric_indexer_type_0_NL_1: "All numerically named properties must be subtypes of numeric indexer type '{0}':{NL}{1}", + All_named_properties_must_be_subtypes_of_string_indexer_type_0: "All named properties must be subtypes of string indexer type '{0}'.", + All_named_properties_must_be_subtypes_of_string_indexer_type_0_NL_1: "All named properties must be subtypes of string indexer type '{0}':{NL}{1}", + Generic_type_references_must_include_all_type_arguments: "Generic type references must include all type arguments.", + Default_arguments_are_not_allowed_in_an_overload_parameter: "Default arguments are not allowed in an overload parameter.", + Overloads_cannot_differ_only_by_return_type: "Overloads cannot differ only by return type.", + 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.", + Could_not_find_symbol_0_in_module_1: "Could not find symbol '{0}' in module '{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_reference_0_in_extends_clause_doesn_t_reference_constructor_function_for_1: "Type reference '{0}' in extends clause doesn't reference constructor function for '{1}'.", + Internal_module_reference_0_in_import_declaration_doesn_t_reference_module_instance_for_1: "Internal module reference '{0}' in import declaration doesn't reference module instance for '{1}'.", + 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.", + Enums_with_multiple_declarations_must_provide_an_initializer_for_the_first_enum_element: "Enums with multiple declarations must provide an initializer for the first enum element.", + _0_overload_s: " (+ {0} overload(s))", + Current_host_does_not_support_0_option: "Current host does not support '{0}' option.", + ECMAScript_target_version_0_not_supported_Using_default_1_code_generation: "ECMAScript target version '{0}' not supported. Using default '{1}' code generation.", + Module_code_generation_0_not_supported: "Module code generation '{0}' not supported.", + 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 or -. For example '{0}' or '{1}'.", + Unsupported_locale_0: "Unsupported locale: '{0}'.", + Execution_Failed_NL: "Execution Failed.{NL}", + Should_not_emit_a_type_query: "Should not emit a type query", + Should_not_emit_a_type_reference: "Should not emit a type reference", + 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", + Key_was_already_in_table: "Key was already in table", + Unknown_option_0: "Unknown 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}", + Invalid_argument_0_1: "Invalid argument: {0}. {1}", + Invalid_argument_0: "Invalid argument: {0}.", + Argument_out_of_range_0: "Argument out of range: {0}.", + Argument_null_0: "Argument null: {0}.", + Operation_not_implemented_properly_by_subclass: "Operation not implemented properly by subclass.", + Not_yet_implemented: "Not yet implemented.", + Invalid_operation_0: "Invalid operation: {0}", + Invalid_operation: "Invalid operation.", + 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.", + Concatenate_and_emit_output_to_single_file: "Concatenate and emit output to single file", + Generates_corresponding_0_file: "Generates corresponding {0} 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", + Skip_resolution_and_preprocessing: "Skip resolution and preprocessing", + Specify_ECMAScript_target_version_0_default_or_1: "Specify ECMAScript target version: \"{0}\" (default), or \"{1}\"", + Specify_module_code_generation_0_or_1: "Specify module code generation: \"{0}\" or \"{1}\"", + Print_this_message: "Print this message", + Print_the_compiler_s_version_0: "Print the compiler's version: {0}", + Allow_use_of_deprecated_0_keyword_when_referencing_an_external_module: "Allow use of deprecated \"{0}\" keyword when referencing an external module", + Specify_locale_for_errors_and_messages_For_example_0_or_1: "Specify locale for errors and messages. For example '{0}' or '{1}'", + Syntax_0: "Syntax: {0}", + options: "options", + file: "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", + FILE: "FILE", + VERSION: "VERSION", + LOCATION: "LOCATION", + DIRECTORY: "DIRECTORY", + This_version_of_the_Javascript_runtime_does_not_support_the_0_function: "This version of the Javascript runtime does not support the '{0}' function.", + Looking_up_path_for_identifier_token_did_not_result_in_an_identifer: "Looking up path for identifier token did not result in an identifer.", + Unknown_rule: "Unknown rule", + Invalid_line_number_0: "Invalid line number ({0})", + Warn_on_expressions_and_declarations_with_an_implied_any_type: "Warn 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." + }; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var ArrayUtilities = (function () { + function ArrayUtilities() { + } + ArrayUtilities.isArray = function (value) { + return Object.prototype.toString.apply(value, []) === '[object Array]'; + }; + + ArrayUtilities.sequenceEquals = function (array1, array2, equals) { + if (array1 === array2) { + return true; + } + + if (array1 === null || array2 === null) { + 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; + }; + + ArrayUtilities.contains = function (array, value) { + for (var i = 0; i < array.length; i++) { + if (array[i] === value) { + return true; + } + } + + return false; + }; + + ArrayUtilities.groupBy = function (array, func) { + var result = {}; + + for (var i = 0, n = array.length; i < n; i++) { + var v = array[i]; + var k = func(v); + + var list = result[k] || []; + list.push(v); + result[k] = list; + } + + return result; + }; + + ArrayUtilities.min = function (array, func) { + var min = func(array[0]); + + for (var i = 1; i < array.length; i++) { + var next = func(array[i]); + if (next < min) { + min = next; + } + } + + return min; + }; + + ArrayUtilities.max = function (array, func) { + var max = func(array[0]); + + for (var i = 1; i < array.length; i++) { + var next = func(array[i]); + if (next > max) { + max = next; + } + } + + return max; + }; + + ArrayUtilities.last = function (array) { + if (array.length === 0) { + throw TypeScript.Errors.argumentOutOfRange('array'); + } + + return array[array.length - 1]; + }; + + ArrayUtilities.firstOrDefault = function (array, func) { + for (var i = 0, n = array.length; i < n; i++) { + var value = array[i]; + if (func(value)) { + return value; + } + } + + return null; + }; + + ArrayUtilities.sum = function (array, func) { + var result = 0; + + for (var i = 0, n = array.length; i < n; i++) { + result += func(array[i]); + } + + return result; + }; + + ArrayUtilities.whereNotNull = function (array) { + var result = []; + for (var i = 0; i < array.length; i++) { + var value = array[i]; + if (value !== null) { + result.push(value); + } + } + + return result; + }; + + ArrayUtilities.select = function (values, func) { + var result = new Array(values.length); + + for (var i = 0; i < values.length; i++) { + result[i] = func(values[i]); + } + + return result; + }; + + ArrayUtilities.where = function (values, func) { + var result = new Array(); + + for (var i = 0; i < values.length; i++) { + if (func(values[i])) { + result.push(values[i]); + } + } + + return result; + }; + + ArrayUtilities.any = function (array, func) { + for (var i = 0, n = array.length; i < n; i++) { + if (func(array[i])) { + return true; + } + } + + return false; + }; + + ArrayUtilities.all = function (array, func) { + for (var i = 0, n = array.length; i < n; i++) { + if (!func(array[i])) { + return false; + } + } + + return true; + }; + + ArrayUtilities.binarySearch = function (array, value) { + 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; + }; + + ArrayUtilities.createArray = function (length, defaultValue) { + var result = new Array(length); + for (var i = 0; i < length; i++) { + result[i] = defaultValue; + } + + return result; + }; + + ArrayUtilities.grow = function (array, length, defaultValue) { + var count = length - array.length; + for (var i = 0; i < count; i++) { + array.push(defaultValue); + } + }; + + ArrayUtilities.copy = function (sourceArray, sourceIndex, destinationArray, destinationIndex, length) { + for (var i = 0; i < length; i++) { + destinationArray[destinationIndex + i] = sourceArray[sourceIndex + i]; + } + }; + return ArrayUtilities; + })(); + TypeScript.ArrayUtilities = ArrayUtilities; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (Constants) { + Constants[Constants["Max31BitInteger"] = 1073741823] = "Max31BitInteger"; + Constants[Constants["Min31BitInteger"] = -1073741824] = "Min31BitInteger"; + })(TypeScript.Constants || (TypeScript.Constants = {})); + var Constants = TypeScript.Constants; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var Debug = (function () { + function Debug() { + } + Debug.assert = function (expression, message) { + if (!expression) { + throw new Error("Debug Failure. False expression: " + (message ? message : "")); + } + }; + return Debug; + })(); + TypeScript.Debug = Debug; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var Errors = (function () { + function Errors() { + } + Errors.argument = function (argument, message) { + return new Error(message ? TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Invalid_argument_0_1, [argument, message]) : TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Invalid_argument_0, [argument])); + }; + + Errors.argumentOutOfRange = function (argument) { + return new Error(TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Argument_out_of_range_0, [argument])); + }; + + Errors.argumentNull = function (argument) { + return new Error(TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Argument_null_0, [argument])); + }; + + Errors.abstract = function () { + return new Error(TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Operation_not_implemented_properly_by_subclass, null)); + }; + + Errors.notYetImplemented = function () { + return new Error(TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Not_yet_implemented, null)); + }; + + Errors.invalidOperation = function (message) { + return new Error(message ? TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Invalid_operation_0, [message]) : TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Invalid_operation, null)); + }; + return Errors; + })(); + TypeScript.Errors = Errors; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var Hash = (function () { + function Hash() { + } + Hash.computeFnv1aCharArrayHashCode = function (text, start, len) { + var hashCode = Hash.FNV_BASE; + var end = start + len; + + for (var i = start; i < end; i++) { + hashCode = TypeScript.IntegerUtilities.integerMultiplyLow32Bits(hashCode ^ text[i], Hash.FNV_PRIME); + } + + return hashCode; + }; + + Hash.computeSimple31BitCharArrayHashCode = function (key, start, len) { + var hash = 0; + + for (var i = 0; i < len; i++) { + var ch = key[start + i]; + + hash = ((((hash << 5) - hash) | 0) + ch) | 0; + } + + return hash & 0x7FFFFFFF; + }; + + Hash.computeSimple31BitStringHashCode = function (key) { + var hash = 0; + + var start = 0; + var len = key.length; + + for (var i = 0; i < len; i++) { + var ch = key.charCodeAt(start + i); + + hash = ((((hash << 5) - hash) | 0) + ch) | 0; + } + + return hash & 0x7FFFFFFF; + }; + + Hash.computeMurmur2StringHashCode = function (key, seed) { + var m = 0x5bd1e995; + var r = 24; + + var numberOfCharsLeft = key.length; + var h = Math.abs(seed ^ numberOfCharsLeft); + + var index = 0; + while (numberOfCharsLeft >= 2) { + var c1 = key.charCodeAt(index); + var c2 = key.charCodeAt(index + 1); + + var k = Math.abs(c1 | (c2 << 16)); + + k = TypeScript.IntegerUtilities.integerMultiplyLow32Bits(k, m); + k ^= k >> r; + k = TypeScript.IntegerUtilities.integerMultiplyLow32Bits(k, m); + + h = TypeScript.IntegerUtilities.integerMultiplyLow32Bits(h, m); + h ^= k; + + index += 2; + numberOfCharsLeft -= 2; + } + + if (numberOfCharsLeft == 1) { + h ^= key.charCodeAt(index); + h = TypeScript.IntegerUtilities.integerMultiplyLow32Bits(h, m); + } + + h ^= h >> 13; + h = TypeScript.IntegerUtilities.integerMultiplyLow32Bits(h, m); + h ^= h >> 15; + + return h; + }; + + Hash.getPrime = function (min) { + for (var i = 0; i < Hash.primes.length; i++) { + var num = Hash.primes[i]; + if (num >= min) { + return num; + } + } + + throw TypeScript.Errors.notYetImplemented(); + }; + + Hash.expandPrime = function (oldSize) { + var num = oldSize << 1; + if (num > 2146435069 && 2146435069 > oldSize) { + return 2146435069; + } + return Hash.getPrime(num); + }; + + Hash.combine = function (value, currentHash) { + return (((currentHash << 5) + currentHash) + value) & 0x7FFFFFFF; + }; + Hash.FNV_BASE = 2166136261; + Hash.FNV_PRIME = 16777619; + + Hash.primes = [ + 3, + 7, + 11, + 17, + 23, + 29, + 37, + 47, + 59, + 71, + 89, + 107, + 131, + 163, + 197, + 239, + 293, + 353, + 431, + 521, + 631, + 761, + 919, + 1103, + 1327, + 1597, + 1931, + 2333, + 2801, + 3371, + 4049, + 4861, + 5839, + 7013, + 8419, + 10103, + 12143, + 14591, + 17519, + 21023, + 25229, + 30293, + 36353, + 43627, + 52361, + 62851, + 75431, + 90523, + 108631, + 130363, + 156437, + 187751, + 225307, + 270371, + 324449, + 389357, + 467237, + 560689, + 672827, + 807403, + 968897, + 1162687, + 1395263, + 1674319, + 2009191, + 2411033, + 2893249, + 3471899, + 4166287, + 4999559, + 5999471, + 7199369 + ]; + return Hash; + })(); + TypeScript.Hash = Hash; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (Collections) { + Collections.DefaultHashTableCapacity = 1024; + + var HashTableEntry = (function () { + function HashTableEntry(Key, Value, HashCode, Next) { + this.Key = Key; + this.Value = Value; + this.HashCode = HashCode; + this.Next = Next; + } + return HashTableEntry; + })(); + + var HashTable = (function () { + function HashTable(capacity, hash) { + this.hash = hash; + this.count = 0; + var size = TypeScript.Hash.getPrime(capacity); + this.entries = TypeScript.ArrayUtilities.createArray(size, null); + } + HashTable.prototype.set = function (key, value) { + this.addOrSet(key, value, false); + }; + + HashTable.prototype.add = function (key, value) { + this.addOrSet(key, value, true); + }; + + HashTable.prototype.containsKey = function (key) { + var hashCode = this.computeHashCode(key); + var entry = this.findEntry(key, hashCode); + return entry !== null; + }; + + HashTable.prototype.get = function (key) { + var hashCode = this.computeHashCode(key); + var entry = this.findEntry(key, hashCode); + + return entry === null ? null : entry.Value; + }; + + HashTable.prototype.computeHashCode = function (key) { + var hashCode = this.hash === null ? (key).hashCode : this.hash(key); + + hashCode = hashCode & 0x7FFFFFFF; + TypeScript.Debug.assert(hashCode >= 0); + + return hashCode; + }; + + HashTable.prototype.addOrSet = function (key, value, throwOnExistingEntry) { + var hashCode = this.computeHashCode(key); + + var entry = this.findEntry(key, hashCode); + if (entry !== null) { + if (throwOnExistingEntry) { + throw TypeScript.Errors.argument('key', TypeScript.getLocalizedText(TypeScript.DiagnosticCode.Key_was_already_in_table, null)); + } + + entry.Key = key; + entry.Value = value; + return; + } + + return this.addEntry(key, value, hashCode); + }; + + HashTable.prototype.findEntry = function (key, hashCode) { + for (var e = this.entries[hashCode % this.entries.length]; e !== null; e = e.Next) { + if (e.HashCode === hashCode && key === e.Key) { + return e; + } + } + + return null; + }; + + HashTable.prototype.addEntry = function (key, value, hashCode) { + var index = hashCode % this.entries.length; + + var e = new HashTableEntry(key, value, hashCode, this.entries[index]); + + this.entries[index] = e; + + if (this.count >= (this.entries.length / 2)) { + this.grow(); + } + + this.count++; + return e.Key; + }; + + HashTable.prototype.grow = function () { + var newSize = TypeScript.Hash.expandPrime(this.entries.length); + + var oldEntries = this.entries; + var newEntries = TypeScript.ArrayUtilities.createArray(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; + } + } + }; + return HashTable; + })(); + Collections.HashTable = HashTable; + + function createHashTable(capacity, hash) { + if (typeof capacity === "undefined") { capacity = Collections.DefaultHashTableCapacity; } + if (typeof hash === "undefined") { hash = null; } + return new HashTable(capacity, hash); + } + Collections.createHashTable = createHashTable; + + var currentHashCode = 1; + function identityHashCode(value) { + if (value.__hash === undefined) { + value.__hash = currentHashCode; + currentHashCode++; + } + + return value.__hash; + } + Collections.identityHashCode = identityHashCode; + })(TypeScript.Collections || (TypeScript.Collections = {})); + var Collections = TypeScript.Collections; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + TypeScript.LocalizedDiagnosticMessages = null; + + function newLine() { + return Environment ? Environment.newLine : "\r\n"; + } + TypeScript.newLine = newLine; + + var Diagnostic = (function () { + function Diagnostic(fileName, start, length, diagnosticKey, arguments) { + if (typeof arguments === "undefined") { arguments = null; } + this._diagnosticKey = diagnosticKey; + this._arguments = (arguments && arguments.length > 0) ? arguments : null; + this._fileName = fileName; + this._start = start; + this._length = length; + } + Diagnostic.prototype.toJSON = function (key) { + var result = {}; + result.start = this.start(); + result.length = this.length(); + + result.diagnosticCode = this._diagnosticKey; + + var arguments = (this).arguments(); + if (arguments && arguments.length > 0) { + result.arguments = arguments; + } + + return result; + }; + + Diagnostic.prototype.fileName = function () { + return this._fileName; + }; + + Diagnostic.prototype.start = function () { + return this._start; + }; + + Diagnostic.prototype.length = function () { + return this._length; + }; + + Diagnostic.prototype.diagnosticKey = function () { + return this._diagnosticKey; + }; + + Diagnostic.prototype.arguments = function () { + return this._arguments; + }; + + Diagnostic.prototype.text = function () { + return TypeScript.getLocalizedText(this._diagnosticKey, this._arguments); + }; + + Diagnostic.prototype.message = function () { + return TypeScript.getDiagnosticMessage(this._diagnosticKey, this._arguments); + }; + + Diagnostic.prototype.additionalLocations = function () { + return []; + }; + + Diagnostic.equals = function (diagnostic1, diagnostic2) { + return diagnostic1._fileName === diagnostic2._fileName && diagnostic1._start === diagnostic2._start && diagnostic1._length === diagnostic2._length && diagnostic1._diagnosticKey === diagnostic2._diagnosticKey && TypeScript.ArrayUtilities.sequenceEquals(diagnostic1._arguments, diagnostic2._arguments, function (v1, v2) { + return v1 === v2; + }); + }; + return Diagnostic; + })(); + TypeScript.Diagnostic = Diagnostic; + + function getLargestIndex(diagnostic) { + var largest = -1; + var regex = /\{(\d+)\}/g; + + var match; + while ((match = regex.exec(diagnostic)) != null) { + var val = parseInt(match[1]); + if (!isNaN(val) && val > largest) { + largest = val; + } + } + + return largest; + } + + function getDiagnosticInfoFromKey(diagnosticKey) { + var result = TypeScript.diagnosticInformationMap[diagnosticKey]; + TypeScript.Debug.assert(result !== undefined && result !== null); + return result; + } + TypeScript.getDiagnosticInfoFromKey = getDiagnosticInfoFromKey; + + function getLocalizedText(diagnosticKey, args) { + if (TypeScript.LocalizedDiagnosticMessages) { + TypeScript.Debug.assert(TypeScript.LocalizedDiagnosticMessages.hasOwnProperty(diagnosticKey)); + } + + var diagnosticMessageText = TypeScript.LocalizedDiagnosticMessages ? TypeScript.LocalizedDiagnosticMessages[diagnosticKey] : diagnosticKey; + TypeScript.Debug.assert(diagnosticMessageText !== undefined && diagnosticMessageText !== null); + + var actualCount = args ? args.length : 0; + + var expectedCount = 1 + getLargestIndex(diagnosticKey); + + if (expectedCount !== actualCount) { + throw new Error(getLocalizedText(TypeScript.DiagnosticCode.Expected_0_arguments_to_message_got_1_instead, [expectedCount, actualCount])); + } + + var valueCount = 1 + getLargestIndex(diagnosticMessageText); + if (valueCount !== expectedCount) { + throw new Error(getLocalizedText(TypeScript.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; + } + TypeScript.getLocalizedText = getLocalizedText; + + function getDiagnosticMessage(diagnosticKey, args) { + var diagnostic = getDiagnosticInfoFromKey(diagnosticKey); + var diagnosticMessageText = getLocalizedText(diagnosticKey, args); + + var message; + if (diagnostic.category === 1 /* Error */) { + message = getLocalizedText(TypeScript.DiagnosticCode.error_TS_0_1, [diagnostic.code, diagnosticMessageText]); + } else if (diagnostic.category === 0 /* Warning */) { + message = getLocalizedText(TypeScript.DiagnosticCode.warning_TS_0_1, [diagnostic.code, diagnosticMessageText]); + } else { + message = diagnosticMessageText; + } + + return message; + } + TypeScript.getDiagnosticMessage = getDiagnosticMessage; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + TypeScript.nodeMakeDirectoryTime = 0; + TypeScript.nodeCreateBufferTime = 0; + TypeScript.nodeWriteFileSyncTime = 0; +})(TypeScript || (TypeScript = {})); + +var ByteOrderMark; +(function (ByteOrderMark) { + ByteOrderMark[ByteOrderMark["None"] = 0] = "None"; + ByteOrderMark[ByteOrderMark["Utf8"] = 1] = "Utf8"; + ByteOrderMark[ByteOrderMark["Utf16BigEndian"] = 2] = "Utf16BigEndian"; + ByteOrderMark[ByteOrderMark["Utf16LittleEndian"] = 3] = "Utf16LittleEndian"; +})(ByteOrderMark || (ByteOrderMark = {})); + +var FileInformation = (function () { + function FileInformation(contents, byteOrderMark) { + this.contents = contents; + this.byteOrderMark = byteOrderMark; + } + return FileInformation; +})(); + +var Environment = (function () { + function getWindowsScriptHostEnvironment() { + try { + var fso = new ActiveXObject("Scripting.FileSystemObject"); + } catch (e) { + return null; + } + + var streamObjectPool = []; + + function getStreamObject() { + if (streamObjectPool.length > 0) { + return streamObjectPool.pop(); + } else { + return new ActiveXObject("ADODB.Stream"); + } + } + + function releaseStreamObject(obj) { + streamObjectPool.push(obj); + } + + var args = []; + for (var i = 0; i < WScript.Arguments.length; i++) { + args[i] = WScript.Arguments.Item(i); + } + + return { + newLine: "\r\n", + currentDirectory: function () { + return (WScript).CreateObject("WScript.Shell").CurrentDirectory; + }, + readFile: function (path) { + try { + var streamObj = getStreamObject(); + streamObj.Open(); + streamObj.Type = 2; + + streamObj.Charset = 'x-ansi'; + + streamObj.LoadFromFile(path); + var bomChar = streamObj.ReadText(2); + + streamObj.Position = 0; + + var byteOrderMark = 0 /* None */; + + if (bomChar.charCodeAt(0) === 0xFE && bomChar.charCodeAt(1) === 0xFF) { + streamObj.Charset = 'unicode'; + byteOrderMark = 2 /* Utf16BigEndian */; + } else if (bomChar.charCodeAt(0) === 0xFF && bomChar.charCodeAt(1) === 0xFE) { + streamObj.Charset = 'unicode'; + byteOrderMark = 3 /* Utf16LittleEndian */; + } else if (bomChar.charCodeAt(0) === 0xEF && bomChar.charCodeAt(1) === 0xBB) { + streamObj.Charset = 'utf-8'; + byteOrderMark = 1 /* Utf8 */; + } else { + streamObj.Charset = 'utf-8'; + } + + var contents = streamObj.ReadText(-1); + streamObj.Close(); + releaseStreamObject(streamObj); + return new FileInformation(contents, byteOrderMark); + } catch (err) { + var message; + if (err.number === -2147024809) { + message = TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Unsupported_file_encoding, null); + } else { + message = TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Cannot_read_file_0_1, [path, err.message]); + } + + throw new Error(message); + } + }, + writeFile: function (path, contents, writeByteOrderMark) { + var textStream = getStreamObject(); + textStream.Charset = 'utf-8'; + textStream.Open(); + textStream.WriteText(contents, 0); + + if (!writeByteOrderMark) { + textStream.Position = 3; + } else { + textStream.Position = 0; + } + + var fileStream = getStreamObject(); + fileStream.Type = 1; + fileStream.Open(); + + textStream.CopyTo(fileStream); + + fileStream.Flush(); + fileStream.SaveToFile(path, 2); + fileStream.Close(); + + textStream.Flush(); + textStream.Close(); + }, + fileExists: function (path) { + return fso.FileExists(path); + }, + deleteFile: function (path) { + if (fso.FileExists(path)) { + fso.DeleteFile(path, true); + } + }, + directoryExists: function (path) { + return fso.FolderExists(path); + }, + listFiles: function (path, spec, options) { + options = options || {}; + function filesInFolder(folder, root) { + var paths = []; + var fc; + + if (options.recursive) { + fc = new Enumerator(folder.subfolders); + + for (; !fc.atEnd(); fc.moveNext()) { + paths = paths.concat(filesInFolder(fc.item(), root + "\\" + fc.item().Name)); + } + } + + fc = new Enumerator(folder.files); + + for (; !fc.atEnd(); fc.moveNext()) { + if (!spec || fc.item().Name.match(spec)) { + paths.push(root + "\\" + fc.item().Name); + } + } + + return paths; + } + + var folder = fso.GetFolder(path); + var paths = []; + + return filesInFolder(folder, path); + }, + arguments: args, + standardOut: WScript.StdOut + }; + } + ; + + function getNodeEnvironment() { + var _fs = require('fs'); + var _path = require('path'); + var _module = require('module'); + var _os = require('os'); + + return { + newLine: _os.EOL, + currentDirectory: function () { + return (process).cwd(); + }, + readFile: function (file) { + var buffer = _fs.readFileSync(file); + switch (buffer[0]) { + case 0xFE: + if (buffer[1] === 0xFF) { + var i = 0; + while ((i + 1) < buffer.length) { + var temp = buffer[i]; + buffer[i] = buffer[i + 1]; + buffer[i + 1] = temp; + i += 2; + } + return new FileInformation(buffer.toString("ucs2", 2), 2 /* Utf16BigEndian */); + } + break; + case 0xFF: + if (buffer[1] === 0xFE) { + return new FileInformation(buffer.toString("ucs2", 2), 3 /* Utf16LittleEndian */); + } + break; + case 0xEF: + if (buffer[1] === 0xBB) { + return new FileInformation(buffer.toString("utf8", 3), 1 /* Utf8 */); + } + } + + return new FileInformation(buffer.toString("utf8", 0), 0 /* None */); + }, + writeFile: function (path, contents, writeByteOrderMark) { + function mkdirRecursiveSync(path) { + var stats = _fs.statSync(path); + if (stats.isFile()) { + throw "\"" + path + "\" exists but isn't a directory."; + } else if (stats.isDirectory()) { + return; + } else { + mkdirRecursiveSync(_path.dirname(path)); + _fs.mkdirSync(path, 0775); + } + } + var start = new Date().getTime(); + mkdirRecursiveSync(_path.dirname(path)); + TypeScript.nodeMakeDirectoryTime += new Date().getTime() - start; + + if (writeByteOrderMark) { + contents = '\uFEFF' + contents; + } + + var start = new Date().getTime(); + + var chunkLength = 4 * 1024; + var fileDescriptor = _fs.openSync(path, "w"); + try { + for (var index = 0; index < contents.length; index += chunkLength) { + var bufferStart = new Date().getTime(); + var buffer = new Buffer(contents.substr(index, chunkLength), "utf8"); + TypeScript.nodeCreateBufferTime += new Date().getTime() - bufferStart; + + _fs.writeSync(fileDescriptor, buffer, 0, buffer.length, null); + } + } finally { + _fs.closeSync(fileDescriptor); + } + + TypeScript.nodeWriteFileSyncTime += new Date().getTime() - start; + }, + fileExists: function (path) { + return _fs.existsSync(path); + }, + deleteFile: function (path) { + try { + _fs.unlinkSync(path); + } catch (e) { + } + }, + directoryExists: function (path) { + return _fs.existsSync(path) && _fs.statSync(path).isDirectory(); + }, + listFiles: function dir(path, spec, options) { + options = options || {}; + + function filesInFolder(folder) { + var paths = []; + + var files = _fs.readdirSync(folder); + for (var i = 0; i < files.length; i++) { + var stat = _fs.statSync(folder + "\\" + files[i]); + if (options.recursive && stat.isDirectory()) { + paths = paths.concat(filesInFolder(folder + "\\" + files[i])); + } else if (stat.isFile() && (!spec || files[i].match(spec))) { + paths.push(folder + "\\" + files[i]); + } + } + + return paths; + } + + return filesInFolder(path); + }, + arguments: process.argv.slice(2), + standardOut: { + Write: function (str) { + process.stdout.write(str); + }, + WriteLine: function (str) { + process.stdout.write(str + '\n'); + }, + Close: function () { + } + } + }; + } + ; + + if (typeof WScript !== "undefined" && typeof ActiveXObject === "function") { + return getWindowsScriptHostEnvironment(); + } else if (typeof module !== 'undefined' && module.exports) { + return getNodeEnvironment(); + } else { + return null; + } +})(); +var TypeScript; +(function (TypeScript) { + var IntegerUtilities = (function () { + function IntegerUtilities() { + } + IntegerUtilities.integerDivide = function (numerator, denominator) { + return (numerator / denominator) >> 0; + }; + + IntegerUtilities.integerMultiplyLow32Bits = function (n1, n2) { + var n1Low16 = n1 & 0x0000ffff; + var n1High16 = n1 >>> 16; + + var n2Low16 = n2 & 0x0000ffff; + var n2High16 = n2 >>> 16; + + var resultLow32 = (((n1 & 0xffff0000) * n2) >>> 0) + (((n1 & 0x0000ffff) * n2) >>> 0) >>> 0; + return resultLow32; + }; + + IntegerUtilities.integerMultiplyHigh32Bits = function (n1, n2) { + var n1Low16 = n1 & 0x0000ffff; + var n1High16 = n1 >>> 16; + + var n2Low16 = n2 & 0x0000ffff; + var n2High16 = n2 >>> 16; + + var resultHigh32 = n1High16 * n2High16 + ((((n1Low16 * n2Low16) >>> 17) + n1Low16 * n2High16) >>> 15); + return resultHigh32; + }; + return IntegerUtilities; + })(); + TypeScript.IntegerUtilities = IntegerUtilities; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var MathPrototype = (function () { + function MathPrototype() { + } + MathPrototype.max = function (a, b) { + return a >= b ? a : b; + }; + + MathPrototype.min = function (a, b) { + return a <= b ? a : b; + }; + return MathPrototype; + })(); + TypeScript.MathPrototype = MathPrototype; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (Collections) { + Collections.DefaultStringTableCapacity = 256; + + var StringTableEntry = (function () { + function StringTableEntry(Text, HashCode, Next) { + this.Text = Text; + this.HashCode = HashCode; + this.Next = Next; + } + return StringTableEntry; + })(); + + var StringTable = (function () { + function StringTable(capacity) { + this.count = 0; + var size = TypeScript.Hash.getPrime(capacity); + this.entries = TypeScript.ArrayUtilities.createArray(size, null); + } + StringTable.prototype.addCharArray = function (key, start, len) { + var hashCode = TypeScript.Hash.computeSimple31BitCharArrayHashCode(key, start, len) & 0x7FFFFFFF; + + var entry = this.findCharArrayEntry(key, start, len, hashCode); + if (entry !== null) { + return entry.Text; + } + + var slice = key.slice(start, start + len); + return this.addEntry(TypeScript.StringUtilities.fromCharCodeArray(slice), hashCode); + }; + + StringTable.prototype.findCharArrayEntry = function (key, start, len, hashCode) { + 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; + }; + + StringTable.prototype.addEntry = function (text, hashCode) { + var index = hashCode % this.entries.length; + + var e = new StringTableEntry(text, hashCode, this.entries[index]); + + this.entries[index] = e; + + if (this.count === this.entries.length) { + this.grow(); + } + + this.count++; + return e.Text; + }; + + StringTable.prototype.grow = function () { + var newSize = TypeScript.Hash.expandPrime(this.entries.length); + + var oldEntries = this.entries; + var newEntries = TypeScript.ArrayUtilities.createArray(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; + } + } + }; + + StringTable.textCharArrayEquals = function (text, array, start, length) { + 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; + }; + return StringTable; + })(); + Collections.StringTable = StringTable; + + Collections.DefaultStringTable = new StringTable(Collections.DefaultStringTableCapacity); + })(TypeScript.Collections || (TypeScript.Collections = {})); + var Collections = TypeScript.Collections; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var StringUtilities = (function () { + function StringUtilities() { + } + StringUtilities.isString = function (value) { + return Object.prototype.toString.apply(value, []) === '[object String]'; + }; + + StringUtilities.fromCharCodeArray = function (array) { + return String.fromCharCode.apply(null, array); + }; + + StringUtilities.endsWith = function (string, value) { + return string.substring(string.length - value.length, string.length) === value; + }; + + StringUtilities.startsWith = function (string, value) { + return string.substr(0, value.length) === value; + }; + + StringUtilities.copyTo = function (source, sourceIndex, destination, destinationIndex, count) { + for (var i = 0; i < count; i++) { + destination[destinationIndex + i] = source.charCodeAt(sourceIndex + i); + } + }; + + StringUtilities.repeat = function (value, count) { + return Array(count + 1).join(value); + }; + + StringUtilities.stringEquals = function (val1, val2) { + return val1 === val2; + }; + return StringUtilities; + })(); + TypeScript.StringUtilities = StringUtilities; +})(TypeScript || (TypeScript = {})); +var global = Function("return this").call(null); + +var TypeScript; +(function (TypeScript) { + var Clock; + (function (Clock) { + Clock.now; + Clock.resolution; + + if (typeof WScript !== "undefined" && typeof global['WScript'].InitializeProjection !== "undefined") { + global['WScript'].InitializeProjection(); + + Clock.now = function () { + return TestUtilities.QueryPerformanceCounter(); + }; + + Clock.resolution = TestUtilities.QueryPerformanceFrequency(); + } else { + Clock.now = function () { + return Date.now(); + }; + + Clock.resolution = 1000; + } + })(Clock || (Clock = {})); + + var Timer = (function () { + function Timer() { + this.time = 0; + } + Timer.prototype.start = function () { + this.time = 0; + this.startTime = Clock.now(); + }; + + Timer.prototype.end = function () { + this.time = (Clock.now() - this.startTime); + }; + return Timer; + })(); + TypeScript.Timer = Timer; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (DiagnosticCategory) { + DiagnosticCategory[DiagnosticCategory["Warning"] = 0] = "Warning"; + DiagnosticCategory[DiagnosticCategory["Error"] = 1] = "Error"; + DiagnosticCategory[DiagnosticCategory["Message"] = 2] = "Message"; + DiagnosticCategory[DiagnosticCategory["NoPrefix"] = 3] = "NoPrefix"; + })(TypeScript.DiagnosticCategory || (TypeScript.DiagnosticCategory = {})); + var DiagnosticCategory = TypeScript.DiagnosticCategory; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + TypeScript.diagnosticInformationMap = { + "error TS{0}: {1}": { + "code": 0, + "category": 3 /* NoPrefix */ + }, + "warning TS{0}: {1}": { + "code": 1, + "category": 3 /* NoPrefix */ + }, + "Unrecognized escape sequence.": { + "code": 1000, + "category": 1 /* Error */ + }, + "Unexpected character {0}.": { + "code": 1001, + "category": 1 /* Error */ + }, + "Missing close quote character.": { + "code": 1002, + "category": 1 /* Error */ + }, + "Identifier expected.": { + "code": 1003, + "category": 1 /* Error */ + }, + "'{0}' keyword expected.": { + "code": 1004, + "category": 1 /* Error */ + }, + "'{0}' expected.": { + "code": 1005, + "category": 1 /* Error */ + }, + "Identifier expected; '{0}' is a keyword.": { + "code": 1006, + "category": 1 /* Error */ + }, + "Automatic semicolon insertion not allowed.": { + "code": 1007, + "category": 1 /* Error */ + }, + "Unexpected token; '{0}' expected.": { + "code": 1008, + "category": 1 /* Error */ + }, + "Trailing separator not allowed.": { + "code": 1009, + "category": 1 /* Error */ + }, + "'*/' expected.": { + "code": 1010, + "category": 1 /* Error */ + }, + "'public' or 'private' modifier must precede 'static'.": { + "code": 1011, + "category": 1 /* Error */ + }, + "Unexpected token.": { + "code": 1012, + "category": 1 /* Error */ + }, + "Catch clause parameter cannot have a type annotation.": { + "code": 1013, + "category": 1 /* Error */ + }, + "Rest parameter must be last in list.": { + "code": 1014, + "category": 1 /* Error */ + }, + "Parameter cannot have question mark and initializer.": { + "code": 1015, + "category": 1 /* Error */ + }, + "Required parameter cannot follow optional parameter.": { + "code": 1016, + "category": 1 /* Error */ + }, + "Index signatures cannot have rest parameters.": { + "code": 1017, + "category": 1 /* Error */ + }, + "Index signature parameter cannot have accessibility modifiers.": { + "code": 1018, + "category": 1 /* Error */ + }, + "Index signature parameter cannot have a question mark.": { + "code": 1019, + "category": 1 /* Error */ + }, + "Index signature parameter cannot have an initializer.": { + "code": 1020, + "category": 1 /* Error */ + }, + "Index signature must have a type annotation.": { + "code": 1021, + "category": 1 /* Error */ + }, + "Index signature parameter must have a type annotation.": { + "code": 1022, + "category": 1 /* Error */ + }, + "Index signature parameter type must be 'string' or 'number'.": { + "code": 1023, + "category": 1 /* Error */ + }, + "'extends' clause already seen.": { + "code": 1024, + "category": 1 /* Error */ + }, + "'extends' clause must precede 'implements' clause.": { + "code": 1025, + "category": 1 /* Error */ + }, + "Classes can only extend a single class.": { + "code": 1026, + "category": 1 /* Error */ + }, + "'implements' clause already seen.": { + "code": 1027, + "category": 1 /* Error */ + }, + "Accessibility modifier already seen.": { + "code": 1028, + "category": 1 /* Error */ + }, + "'{0}' modifier must precede '{1}' modifier.": { + "code": 1029, + "category": 1 /* Error */ + }, + "'{0}' modifier already seen.": { + "code": 1030, + "category": 1 /* Error */ + }, + "'{0}' modifier cannot appear on a class element.": { + "code": 1031, + "category": 1 /* Error */ + }, + "Interface declaration cannot have 'implements' clause.": { + "code": 1032, + "category": 1 /* Error */ + }, + "'super' invocation cannot have type arguments.": { + "code": 1034, + "category": 1 /* Error */ + }, + "Only ambient modules can use quoted names.": { + "code": 1035, + "category": 1 /* Error */ + }, + "Statements are not allowed in ambient contexts.": { + "code": 1036, + "category": 1 /* Error */ + }, + "Implementations are not allowed in ambient contexts.": { + "code": 1037, + "category": 1 /* Error */ + }, + "'declare' modifier not allowed for code already in an ambient context.": { + "code": 1038, + "category": 1 /* Error */ + }, + "Initializers are not allowed in ambient contexts.": { + "code": 1039, + "category": 1 /* Error */ + }, + "Parameter property declarations can only be used in constructors.": { + "code": 1040, + "category": 1 /* Error */ + }, + "Function implementation expected.": { + "code": 1041, + "category": 1 /* Error */ + }, + "Constructor implementation expected.": { + "code": 1042, + "category": 1 /* Error */ + }, + "Function overload name must be '{0}'.": { + "code": 1043, + "category": 1 /* Error */ + }, + "'{0}' modifier cannot appear on a module element.": { + "code": 1044, + "category": 1 /* Error */ + }, + "'declare' modifier cannot appear on an interface declaration.": { + "code": 1045, + "category": 1 /* Error */ + }, + "'declare' modifier required for top level element.": { + "code": 1046, + "category": 1 /* Error */ + }, + "Rest parameter cannot be optional.": { + "code": 1047, + "category": 1 /* Error */ + }, + "Rest parameter cannot have an initializer.": { + "code": 1048, + "category": 1 /* Error */ + }, + "'set' accessor must have one and only one parameter.": { + "code": 1049, + "category": 1 /* Error */ + }, + "'set' accessor parameter cannot have accessibility modifier.": { + "code": 1050, + "category": 1 /* Error */ + }, + "'set' accessor parameter cannot be optional.": { + "code": 1051, + "category": 1 /* Error */ + }, + "'set' accessor parameter cannot have an initializer.": { + "code": 1052, + "category": 1 /* Error */ + }, + "'set' accessor cannot have rest parameter.": { + "code": 1053, + "category": 1 /* Error */ + }, + "'get' accessor cannot have parameters.": { + "code": 1054, + "category": 1 /* Error */ + }, + "Modifiers cannot appear here.": { + "code": 1055, + "category": 1 /* Error */ + }, + "Accessors are only available when targeting ECMAScript 5 and higher.": { + "code": 1056, + "category": 1 /* Error */ + }, + "Class name cannot be '{0}'.": { + "code": 1057, + "category": 1 /* Error */ + }, + "Interface name cannot be '{0}'.": { + "code": 1058, + "category": 1 /* Error */ + }, + "Enum name cannot be '{0}'.": { + "code": 1059, + "category": 1 /* Error */ + }, + "Module name cannot be '{0}'.": { + "code": 1060, + "category": 1 /* Error */ + }, + "Enum member must have initializer.": { + "code": 1061, + "category": 1 /* Error */ + }, + "Export assignment cannot be used in internal modules.": { + "code": 1063, + "category": 1 /* Error */ + }, + "Export assignment not allowed in module with exported element.": { + "code": 1064, + "category": 1 /* Error */ + }, + "Module cannot have multiple export assignments.": { + "code": 1065, + "category": 1 /* Error */ + }, + "Ambient enum elements can only have integer literal initializers.": { + "code": 1066, + "category": 1 /* Error */ + }, + "module, class, interface, enum, import or statement": { + "code": 1067, + "category": 3 /* NoPrefix */ + }, + "constructor, function, accessor or variable": { + "code": 1068, + "category": 3 /* NoPrefix */ + }, + "statement": { + "code": 1069, + "category": 3 /* NoPrefix */ + }, + "case or default clause": { + "code": 1070, + "category": 3 /* NoPrefix */ + }, + "identifier": { + "code": 1071, + "category": 3 /* NoPrefix */ + }, + "call, construct, index, property or function signature": { + "code": 1072, + "category": 3 /* NoPrefix */ + }, + "expression": { + "code": 1073, + "category": 3 /* NoPrefix */ + }, + "type name": { + "code": 1074, + "category": 3 /* NoPrefix */ + }, + "property or accessor": { + "code": 1075, + "category": 3 /* NoPrefix */ + }, + "parameter": { + "code": 1076, + "category": 3 /* NoPrefix */ + }, + "type": { + "code": 1077, + "category": 3 /* NoPrefix */ + }, + "type parameter": { + "code": 1078, + "category": 3 /* NoPrefix */ + }, + "'declare' modifier not allowed on import declaration.": { + "code": 1079, + "category": 1 /* Error */ + }, + "Function overload must be static": { + "code": 1080, + "category": 1 /* Error */ + }, + "Function overload must not be static": { + "code": 1081, + "category": 1 /* Error */ + }, + "Parameter property declarations cannot be used in an ambient context.": { + "code": 1082, + "category": 1 /* Error */ + }, + "Parameter property declarations cannot be used in a constructor overload.": { + "code": 1083, + "category": 1 /* Error */ + }, + "Duplicate identifier '{0}'.": { + "code": 2000, + "category": 1 /* Error */ + }, + "The name '{0}' does not exist in the current scope.": { + "code": 2001, + "category": 1 /* Error */ + }, + "The name '{0}' does not refer to a value.": { + "code": 2002, + "category": 1 /* Error */ + }, + "'super' can only be used inside a class instance method.": { + "code": 2003, + "category": 1 /* Error */ + }, + "The left-hand side of an assignment expression must be a variable, property or indexer.": { + "code": 2004, + "category": 1 /* Error */ + }, + "Value of type '{0}' is not callable. Did you mean to include 'new'?": { + "code": 2161, + "category": 1 /* Error */ + }, + "Value of type '{0}' is not callable.": { + "code": 2006, + "category": 1 /* Error */ + }, + "Value of type '{0}' is not newable.": { + "code": 2007, + "category": 1 /* Error */ + }, + "Value of type '{0}' is not indexable by type '{1}'.": { + "code": 2008, + "category": 1 /* Error */ + }, + "Operator '{0}' cannot be applied to types '{1}' and '{2}'.": { + "code": 2009, + "category": 1 /* Error */ + }, + "Operator '{0}' cannot be applied to types '{1}' and '{2}': {3}": { + "code": 2010, + "category": 1 /* Error */ + }, + "Cannot convert '{0}' to '{1}'.": { + "code": 2011, + "category": 1 /* Error */ + }, + "Cannot convert '{0}' to '{1}':{NL}{2}": { + "code": 2012, + "category": 1 /* Error */ + }, + "Expected var, class, interface, or module.": { + "code": 2013, + "category": 1 /* Error */ + }, + "Operator '{0}' cannot be applied to type '{1}'.": { + "code": 2014, + "category": 1 /* Error */ + }, + "Getter '{0}' already declared.": { + "code": 2015, + "category": 1 /* Error */ + }, + "Setter '{0}' already declared.": { + "code": 2016, + "category": 1 /* Error */ + }, + "Accessors cannot have type parameters.": { + "code": 2017, + "category": 1 /* Error */ + }, + "Exported class '{0}' extends private class '{1}'.": { + "code": 2018, + "category": 1 /* Error */ + }, + "Exported class '{0}' implements private interface '{1}'.": { + "code": 2019, + "category": 1 /* Error */ + }, + "Exported interface '{0}' extends private interface '{1}'.": { + "code": 2020, + "category": 1 /* Error */ + }, + "Exported class '{0}' extends class from inaccessible module {1}.": { + "code": 2021, + "category": 1 /* Error */ + }, + "Exported class '{0}' implements interface from inaccessible module {1}.": { + "code": 2022, + "category": 1 /* Error */ + }, + "Exported interface '{0}' extends interface from inaccessible module {1}.": { + "code": 2023, + "category": 1 /* Error */ + }, + "Public static property '{0}' of exported class has or is using private type '{1}'.": { + "code": 2024, + "category": 1 /* Error */ + }, + "Public property '{0}' of exported class has or is using private type '{1}'.": { + "code": 2025, + "category": 1 /* Error */ + }, + "Property '{0}' of exported interface has or is using private type '{1}'.": { + "code": 2026, + "category": 1 /* Error */ + }, + "Exported variable '{0}' has or is using private type '{1}'.": { + "code": 2027, + "category": 1 /* Error */ + }, + "Public static property '{0}' of exported class is using inaccessible module {1}.": { + "code": 2028, + "category": 1 /* Error */ + }, + "Public property '{0}' of exported class is using inaccessible module {1}.": { + "code": 2029, + "category": 1 /* Error */ + }, + "Property '{0}' of exported interface is using inaccessible module {1}.": { + "code": 2030, + "category": 1 /* Error */ + }, + "Exported variable '{0}' is using inaccessible module {1}.": { + "code": 2031, + "category": 1 /* Error */ + }, + "Parameter '{0}' of constructor from exported class has or is using private type '{1}'.": { + "code": 2032, + "category": 1 /* Error */ + }, + "Parameter '{0}' of public static property setter from exported class has or is using private type '{1}'.": { + "code": 2033, + "category": 1 /* Error */ + }, + "Parameter '{0}' of public property setter from exported class has or is using private type '{1}'.": { + "code": 2034, + "category": 1 /* Error */ + }, + "Parameter '{0}' of constructor signature from exported interface has or is using private type '{1}'.": { + "code": 2035, + "category": 1 /* Error */ + }, + "Parameter '{0}' of call signature from exported interface has or is using private type '{1}'.": { + "code": 2036, + "category": 1 /* Error */ + }, + "Parameter '{0}' of public static method from exported class has or is using private type '{1}'.": { + "code": 2037, + "category": 1 /* Error */ + }, + "Parameter '{0}' of public method from exported class has or is using private type '{1}'.": { + "code": 2038, + "category": 1 /* Error */ + }, + "Parameter '{0}' of method from exported interface has or is using private type '{1}'.": { + "code": 2039, + "category": 1 /* Error */ + }, + "Parameter '{0}' of exported function has or is using private type '{1}'.": { + "code": 2040, + "category": 1 /* Error */ + }, + "Parameter '{0}' of constructor from exported class is using inaccessible module {1}.": { + "code": 2041, + "category": 1 /* Error */ + }, + "Parameter '{0}' of public static property setter from exported class is using inaccessible module {1}.": { + "code": 2042, + "category": 1 /* Error */ + }, + "Parameter '{0}' of public property setter from exported class is using inaccessible module {1}.": { + "code": 2043, + "category": 1 /* Error */ + }, + "Parameter '{0}' of constructor signature from exported interface is using inaccessible module {1}.": { + "code": 2044, + "category": 1 /* Error */ + }, + "Parameter '{0}' of call signature from exported interface is using inaccessible module {1}": { + "code": 2045, + "category": 1 /* Error */ + }, + "Parameter '{0}' of public static method from exported class is using inaccessible module {1}.": { + "code": 2046, + "category": 1 /* Error */ + }, + "Parameter '{0}' of public method from exported class is using inaccessible module {1}.": { + "code": 2047, + "category": 1 /* Error */ + }, + "Parameter '{0}' of method from exported interface is using inaccessible module {1}.": { + "code": 2048, + "category": 1 /* Error */ + }, + "Parameter '{0}' of exported function is using inaccessible module {1}.": { + "code": 2049, + "category": 1 /* Error */ + }, + "Return type of public static property getter from exported class has or is using private type '{0}'.": { + "code": 2050, + "category": 1 /* Error */ + }, + "Return type of public property getter from exported class has or is using private type '{0}'.": { + "code": 2051, + "category": 1 /* Error */ + }, + "Return type of constructor signature from exported interface has or is using private type '{0}'.": { + "code": 2052, + "category": 1 /* Error */ + }, + "Return type of call signature from exported interface has or is using private type '{0}'.": { + "code": 2053, + "category": 1 /* Error */ + }, + "Return type of index signature from exported interface has or is using private type '{0}'.": { + "code": 2054, + "category": 1 /* Error */ + }, + "Return type of public static method from exported class has or is using private type '{0}'.": { + "code": 2055, + "category": 1 /* Error */ + }, + "Return type of public method from exported class has or is using private type '{0}'.": { + "code": 2056, + "category": 1 /* Error */ + }, + "Return type of method from exported interface has or is using private type '{0}'.": { + "code": 2057, + "category": 1 /* Error */ + }, + "Return type of exported function has or is using private type '{0}'.": { + "code": 2058, + "category": 1 /* Error */ + }, + "Return type of public static property getter from exported class is using inaccessible module {0}.": { + "code": 2059, + "category": 1 /* Error */ + }, + "Return type of public property getter from exported class is using inaccessible module {0}.": { + "code": 2060, + "category": 1 /* Error */ + }, + "Return type of constructor signature from exported interface is using inaccessible module {0}.": { + "code": 2061, + "category": 1 /* Error */ + }, + "Return type of call signature from exported interface is using inaccessible module {0}.": { + "code": 2062, + "category": 1 /* Error */ + }, + "Return type of index signature from exported interface is using inaccessible module {0}.": { + "code": 2063, + "category": 1 /* Error */ + }, + "Return type of public static method from exported class is using inaccessible module {0}.": { + "code": 2064, + "category": 1 /* Error */ + }, + "Return type of public method from exported class is using inaccessible module {0}.": { + "code": 2065, + "category": 1 /* Error */ + }, + "Return type of method from exported interface is using inaccessible module {0}.": { + "code": 2066, + "category": 1 /* Error */ + }, + "Return type of exported function is using inaccessible module {0}.": { + "code": 2067, + "category": 1 /* Error */ + }, + "'new T[]' cannot be used to create an array. Use 'new Array()' instead.": { + "code": 2068, + "category": 1 /* Error */ + }, + "A parameter list must follow a generic type argument list. '(' expected.": { + "code": 2069, + "category": 1 /* Error */ + }, + "Multiple constructor implementations are not allowed.": { + "code": 2070, + "category": 1 /* Error */ + }, + "Unable to resolve external module '{0}'.": { + "code": 2071, + "category": 1 /* Error */ + }, + "Module cannot be aliased to a non-module type.": { + "code": 2072, + "category": 1 /* Error */ + }, + "A class may only extend another class.": { + "code": 2073, + "category": 1 /* Error */ + }, + "A class may only implement another class or interface.": { + "code": 2074, + "category": 1 /* Error */ + }, + "An interface may only extend another class or interface.": { + "code": 2075, + "category": 1 /* Error */ + }, + "An interface cannot implement another type.": { + "code": 2076, + "category": 1 /* Error */ + }, + "Unable to resolve type.": { + "code": 2077, + "category": 1 /* Error */ + }, + "Unable to resolve type of '{0}'.": { + "code": 2078, + "category": 1 /* Error */ + }, + "Unable to resolve type parameter constraint.": { + "code": 2079, + "category": 1 /* Error */ + }, + "Type parameter constraint cannot be a primitive type.": { + "code": 2080, + "category": 1 /* Error */ + }, + "Supplied parameters do not match any signature of call target.": { + "code": 2081, + "category": 1 /* Error */ + }, + "Supplied parameters do not match any signature of call target:{NL}{0}": { + "code": 2082, + "category": 1 /* Error */ + }, + "Invalid 'new' expression.": { + "code": 2083, + "category": 1 /* Error */ + }, + "Call signatures used in a 'new' expression must have a 'void' return type.": { + "code": 2084, + "category": 1 /* Error */ + }, + "Could not select overload for 'new' expression.": { + "code": 2085, + "category": 1 /* Error */ + }, + "Type '{0}' does not satisfy the constraint '{1}' for type parameter '{2}'.": { + "code": 2086, + "category": 1 /* Error */ + }, + "Could not select overload for 'call' expression.": { + "code": 2087, + "category": 1 /* Error */ + }, + "Cannot invoke an expression whose type lacks a call signature.": { + "code": 2088, + "category": 1 /* Error */ + }, + "Calls to 'super' are only valid inside a class.": { + "code": 2089, + "category": 1 /* Error */ + }, + "Generic type '{0}' requires {1} type argument(s).": { + "code": 2090, + "category": 1 /* Error */ + }, + "Type of conditional expression cannot be determined. Best common type could not be found between '{0}' and '{1}'.": { + "code": 2091, + "category": 1 /* Error */ + }, + "Type of array literal cannot be determined. Best common type could not be found for array elements.": { + "code": 2092, + "category": 1 /* Error */ + }, + "Could not find enclosing symbol for dotted name '{0}'.": { + "code": 2093, + "category": 1 /* Error */ + }, + "The property '{0}' does not exist on value of type '{1}'.": { + "code": 2094, + "category": 1 /* Error */ + }, + "Could not find symbol '{0}'.": { + "code": 2095, + "category": 1 /* Error */ + }, + "'get' and 'set' accessor must have the same type.": { + "code": 2096, + "category": 1 /* Error */ + }, + "'this' cannot be referenced in current location.": { + "code": 2097, + "category": 1 /* Error */ + }, + "Static methods cannot reference class type parameters.": { + "code": 2099, + "category": 1 /* Error */ + }, + "Class '{0}' is recursively referenced as a base type of itself.": { + "code": 2100, + "category": 1 /* Error */ + }, + "Interface '{0}' is recursively referenced as a base type of itself.": { + "code": 2101, + "category": 1 /* Error */ + }, + "'super' property access is permitted only in a constructor, instance member function, or instance member accessor of a derived class.": { + "code": 2102, + "category": 1 /* Error */ + }, + "'super' cannot be referenced in non-derived classes.": { + "code": 2103, + "category": 1 /* 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": 1 /* Error */ + }, + "Constructors for derived classes must contain a 'super' call.": { + "code": 2105, + "category": 1 /* Error */ + }, + "Super calls are not permitted outside constructors or in local functions inside constructors.": { + "code": 2106, + "category": 1 /* Error */ + }, + "'{0}.{1}' is inaccessible.": { + "code": 2107, + "category": 1 /* Error */ + }, + "'this' cannot be referenced within module bodies.": { + "code": 2108, + "category": 1 /* Error */ + }, + "Invalid '+' expression - types not known to support the addition operator.": { + "code": 2111, + "category": 1 /* Error */ + }, + "The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.": { + "code": 2112, + "category": 1 /* Error */ + }, + "The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.": { + "code": 2113, + "category": 1 /* Error */ + }, + "The type of a unary arithmetic operation operand must be of type 'any', 'number' or an enum type.": { + "code": 2114, + "category": 1 /* Error */ + }, + "Variable declarations of a 'for' statement cannot use a type annotation.": { + "code": 2115, + "category": 1 /* Error */ + }, + "Variable declarations of a 'for' statement must be of types 'string' or 'any'.": { + "code": 2116, + "category": 1 /* 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": 1 /* Error */ + }, + "The left-hand side of an 'in' expression must be of types 'string' or 'any'.": { + "code": 2118, + "category": 1 /* Error */ + }, + "The right-hand side of an 'in' expression must be of type 'any', an object type or a type parameter.": { + "code": 2119, + "category": 1 /* Error */ + }, + "The left-hand side of an 'instanceof' expression must be of type 'any', an object type or a type parameter.": { + "code": 2120, + "category": 1 /* Error */ + }, + "The right-hand side of an 'instanceof' expression must be of type 'any' or a subtype of the 'Function' interface type.": { + "code": 2121, + "category": 1 /* Error */ + }, + "Setters cannot return a value.": { + "code": 2122, + "category": 1 /* Error */ + }, + "Tried to query type of uninitialized module '{0}'.": { + "code": 2123, + "category": 1 /* Error */ + }, + "Tried to set variable type to uninitialized module type '{0}'.": { + "code": 2124, + "category": 1 /* Error */ + }, + "Function '{0}' declared a non-void return type, but has no return expression.": { + "code": 2125, + "category": 1 /* Error */ + }, + "Getters must return a value.": { + "code": 2126, + "category": 1 /* Error */ + }, + "Getter and setter accessors do not agree in visibility.": { + "code": 2127, + "category": 1 /* Error */ + }, + "Invalid left-hand side of assignment expression.": { + "code": 2130, + "category": 1 /* Error */ + }, + "Function declared a non-void return type, but has no return expression.": { + "code": 2131, + "category": 1 /* Error */ + }, + "Cannot resolve return type reference.": { + "code": 2132, + "category": 1 /* Error */ + }, + "Constructors cannot have a return type of 'void'.": { + "code": 2133, + "category": 1 /* Error */ + }, + "Subsequent variable declarations must have the same type. Variable '{0}' must be of type '{1}', but here has type '{2}'.": { + "code": 2134, + "category": 1 /* Error */ + }, + "All symbols within a with block will be resolved to 'any'.": { + "code": 2135, + "category": 1 /* Error */ + }, + "Import declarations in an internal module cannot reference an external module.": { + "code": 2136, + "category": 1 /* Error */ + }, + "Class {0} declares interface {1} but does not implement it:{NL}{2}": { + "code": 2137, + "category": 1 /* Error */ + }, + "Class {0} declares class {1} as an interface but does not implement it:{NL}{2}": { + "code": 2138, + "category": 1 /* Error */ + }, + "The operand of an increment or decrement operator must be a variable, property or indexer.": { + "code": 2139, + "category": 1 /* Error */ + }, + "'this' cannot be referenced in static initializers in a class body.": { + "code": 2140, + "category": 1 /* Error */ + }, + "Class '{0}' cannot extend class '{1}':{NL}{2}": { + "code": 2141, + "category": 1 /* Error */ + }, + "Interface '{0}' cannot extend class '{1}':{NL}{2}": { + "code": 2142, + "category": 1 /* Error */ + }, + "Interface '{0}' cannot extend interface '{1}':{NL}{2}": { + "code": 2143, + "category": 1 /* Error */ + }, + "Duplicate overload signature for '{0}'.": { + "code": 2144, + "category": 1 /* Error */ + }, + "Duplicate constructor overload signature.": { + "code": 2145, + "category": 1 /* Error */ + }, + "Duplicate overload call signature.": { + "code": 2146, + "category": 1 /* Error */ + }, + "Duplicate overload construct signature.": { + "code": 2147, + "category": 1 /* Error */ + }, + "Overload signature is not compatible with function definition.": { + "code": 2148, + "category": 1 /* Error */ + }, + "Overload signature is not compatible with function definition:{NL}{0}": { + "code": 2149, + "category": 1 /* Error */ + }, + "Overload signatures must all be public or private.": { + "code": 2150, + "category": 1 /* Error */ + }, + "Overload signatures must all be exported or local.": { + "code": 2151, + "category": 1 /* Error */ + }, + "Overload signatures must all be ambient or non-ambient.": { + "code": 2152, + "category": 1 /* Error */ + }, + "Overload signatures must all be optional or required.": { + "code": 2153, + "category": 1 /* Error */ + }, + "Specialized overload signature is not subtype of any non-specialized signature.": { + "code": 2154, + "category": 1 /* Error */ + }, + "'this' cannot be referenced in constructor arguments.": { + "code": 2155, + "category": 1 /* Error */ + }, + "Static member cannot be accessed off an instance variable.": { + "code": 2156, + "category": 1 /* Error */ + }, + "Instance member cannot be accessed off a class.": { + "code": 2157, + "category": 1 /* Error */ + }, + "Untyped function calls may not accept type arguments.": { + "code": 2158, + "category": 1 /* Error */ + }, + "Non-generic functions may not accept type arguments.": { + "code": 2159, + "category": 1 /* Error */ + }, + "A generic type may not reference itself with a wrapped form of its own type parameters.": { + "code": 2160, + "category": 1 /* Error */ + }, + "Rest parameters must be array types.": { + "code": 2162, + "category": 1 /* Error */ + }, + "Overload signature implementation cannot use specialized type.": { + "code": 2163, + "category": 1 /* Error */ + }, + "Export assignments may only be used at the top-level of external modules.": { + "code": 2164, + "category": 1 /* Error */ + }, + "Export assignments may only be made with variables, functions, classes, interfaces, enums and internal modules": { + "code": 2165, + "category": 1 /* Error */ + }, + "Only public instance methods of the base class are accessible via the 'super' keyword.": { + "code": 2166, + "category": 1 /* Error */ + }, + "Numeric indexer type '{0}' must be a subtype of string indexer type '{1}'.": { + "code": 2167, + "category": 1 /* Error */ + }, + "Numeric indexer type '{0}' must be a subtype of string indexer type '{1}':{NL}{2}": { + "code": 2168, + "category": 1 /* Error */ + }, + "All numerically named properties must be subtypes of numeric indexer type '{0}'.": { + "code": 2169, + "category": 1 /* Error */ + }, + "All numerically named properties must be subtypes of numeric indexer type '{0}':{NL}{1}": { + "code": 2170, + "category": 1 /* Error */ + }, + "All named properties must be subtypes of string indexer type '{0}'.": { + "code": 2171, + "category": 1 /* Error */ + }, + "All named properties must be subtypes of string indexer type '{0}':{NL}{1}": { + "code": 2172, + "category": 1 /* Error */ + }, + "Generic type references must include all type arguments.": { + "code": 2173, + "category": 1 /* Error */ + }, + "Default arguments are not allowed in an overload parameter.": { + "code": 2174, + "category": 1 /* Error */ + }, + "Overloads cannot differ only by return type.": { + "code": 2175, + "category": 1 /* Error */ + }, + "Function expression declared a non-void return type, but has no return expression.": { + "code": 2176, + "category": 1 /* Error */ + }, + "Import declaration referencing identifier from internal module can only be made with variables, functions, classes, interfaces, enums and internal modules.": { + "code": 2177, + "category": 1 /* Error */ + }, + "Could not find symbol '{0}' in module '{1}'.": { + "code": 2178, + "category": 1 /* Error */ + }, + "Unable to resolve module reference '{0}'.": { + "code": 2179, + "category": 1 /* Error */ + }, + "Could not find module '{0}' in module '{1}'.": { + "code": 2180, + "category": 1 /* Error */ + }, + "Exported import declaration '{0}' is assigned value with type that has or is using private type '{1}'.": { + "code": 2181, + "category": 1 /* Error */ + }, + "Exported import declaration '{0}' is assigned value with type that is using inaccessible module '{1}'.": { + "code": 2182, + "category": 1 /* Error */ + }, + "Exported import declaration '{0}' is assigned type that has or is using private type '{1}'.": { + "code": 2183, + "category": 1 /* Error */ + }, + "Exported import declaration '{0}' is assigned type that is using inaccessible module '{1}'.": { + "code": 2184, + "category": 1 /* Error */ + }, + "Exported import declaration '{0}' is assigned container that is or is using inaccessible module '{1}'.": { + "code": 2185, + "category": 1 /* Error */ + }, + "Type reference '{0}' in extends clause doesn't reference constructor function for '{1}'.": { + "code": 2186, + "category": 1 /* Error */ + }, + "Internal module reference '{0}' in import declaration doesn't reference module instance for '{1}'.": { + "code": 2187, + "category": 1 /* Error */ + }, + "Type '{0}' is missing property '{1}' from type '{2}'.": { + "code": 4000, + "category": 3 /* NoPrefix */ + }, + "Types of property '{0}' of types '{1}' and '{2}' are incompatible.": { + "code": 4001, + "category": 3 /* NoPrefix */ + }, + "Types of property '{0}' of types '{1}' and '{2}' are incompatible:{NL}{3}": { + "code": 4002, + "category": 3 /* NoPrefix */ + }, + "Property '{0}' defined as private in type '{1}' is defined as public in type '{2}'.": { + "code": 4003, + "category": 3 /* NoPrefix */ + }, + "Property '{0}' defined as public in type '{1}' is defined as private in type '{2}'.": { + "code": 4004, + "category": 3 /* NoPrefix */ + }, + "Types '{0}' and '{1}' define property '{2}' as private.": { + "code": 4005, + "category": 3 /* NoPrefix */ + }, + "Call signatures of types '{0}' and '{1}' are incompatible.": { + "code": 4006, + "category": 3 /* NoPrefix */ + }, + "Call signatures of types '{0}' and '{1}' are incompatible:{NL}{2}": { + "code": 4007, + "category": 3 /* NoPrefix */ + }, + "Type '{0}' requires a call signature, but type '{1}' lacks one.": { + "code": 4008, + "category": 3 /* NoPrefix */ + }, + "Construct signatures of types '{0}' and '{1}' are incompatible.": { + "code": 4009, + "category": 3 /* NoPrefix */ + }, + "Construct signatures of types '{0}' and '{1}' are incompatible:{NL}{2}": { + "code": 40010, + "category": 3 /* NoPrefix */ + }, + "Type '{0}' requires a construct signature, but type '{1}' lacks one.": { + "code": 4011, + "category": 3 /* NoPrefix */ + }, + "Index signatures of types '{0}' and '{1}' are incompatible.": { + "code": 4012, + "category": 3 /* NoPrefix */ + }, + "Index signatures of types '{0}' and '{1}' are incompatible:{NL}{2}": { + "code": 4013, + "category": 3 /* NoPrefix */ + }, + "Call signature expects {0} or fewer parameters.": { + "code": 4014, + "category": 3 /* NoPrefix */ + }, + "Could not apply type '{0}' to argument {1} which is of type '{2}'.": { + "code": 4015, + "category": 3 /* NoPrefix */ + }, + "Class '{0}' defines instance member accessor '{1}', but extended class '{2}' defines it as instance member function.": { + "code": 4016, + "category": 3 /* NoPrefix */ + }, + "Class '{0}' defines instance member property '{1}', but extended class '{2}' defines it as instance member function.": { + "code": 4017, + "category": 3 /* NoPrefix */ + }, + "Class '{0}' defines instance member function '{1}', but extended class '{2}' defines it as instance member accessor.": { + "code": 4018, + "category": 3 /* NoPrefix */ + }, + "Class '{0}' defines instance member function '{1}', but extended class '{2}' defines it as instance member property.": { + "code": 4019, + "category": 3 /* NoPrefix */ + }, + "Types of static property '{0}' of class '{1}' and class '{2}' are incompatible.": { + "code": 4020, + "category": 3 /* NoPrefix */ + }, + "Types of static property '{0}' of class '{1}' and class '{2}' are incompatible:{NL}{3}": { + "code": 4021, + "category": 3 /* NoPrefix */ + }, + "Type reference cannot refer to container '{0}'.": { + "code": 4022, + "category": 1 /* Error */ + }, + "Type reference must refer to type.": { + "code": 4023, + "category": 1 /* Error */ + }, + "Enums with multiple declarations must provide an initializer for the first enum element.": { + "code": 4024, + "category": 1 /* Error */ + }, + " (+ {0} overload(s))": { + "code": 4025, + "category": 2 /* Message */ + }, + "Current host does not support '{0}' option.": { + "code": 5001, + "category": 1 /* Error */ + }, + "ECMAScript target version '{0}' not supported. Using default '{1}' code generation.": { + "code": 5002, + "category": 0 /* Warning */ + }, + "Module code generation '{0}' not supported.": { + "code": 5003, + "category": 0 /* Warning */ + }, + "Could not find file: '{0}'.": { + "code": 5004, + "category": 1 /* Error */ + }, + "A file cannot have a reference to itself.": { + "code": 5006, + "category": 1 /* Error */ + }, + "Cannot resolve referenced file: '{0}'.": { + "code": 5007, + "category": 1 /* Error */ + }, + "Cannot find the common subdirectory path for the input files.": { + "code": 5009, + "category": 1 /* Error */ + }, + "Emit Error: {0}.": { + "code": 5011, + "category": 1 /* Error */ + }, + "Cannot read file '{0}': {1}": { + "code": 5012, + "category": 1 /* Error */ + }, + "Unsupported file encoding.": { + "code": 5013, + "category": 3 /* NoPrefix */ + }, + "Locale must be of the form or -. For example '{0}' or '{1}'.": { + "code": 5014, + "category": 1 /* Error */ + }, + "Unsupported locale: '{0}'.": { + "code": 5015, + "category": 1 /* Error */ + }, + "Execution Failed.{NL}": { + "code": 5016, + "category": 1 /* Error */ + }, + "Should not emit a type query": { + "code": 5017, + "category": 1 /* Error */ + }, + "Should not emit a type reference": { + "code": 5018, + "category": 1 /* Error */ + }, + "Invalid call to 'up'": { + "code": 5019, + "category": 1 /* Error */ + }, + "Invalid call to 'down'": { + "code": 5020, + "category": 1 /* Error */ + }, + "Base64 value '{0}' finished with a continuation bit": { + "code": 5021, + "category": 1 /* Error */ + }, + "Key was already in table": { + "code": 5022, + "category": 1 /* Error */ + }, + "Unknown option '{0}'": { + "code": 5023, + "category": 1 /* Error */ + }, + "Expected {0} arguments to message, got {1} instead": { + "code": 5024, + "category": 1 /* Error */ + }, + "Expected the message '{0}' to have {1} arguments, but it had {2}": { + "code": 5025, + "category": 1 /* Error */ + }, + "Invalid argument: {0}. {1}": { + "code": 5026, + "category": 1 /* Error */ + }, + "Invalid argument: {0}.": { + "code": 5027, + "category": 1 /* Error */ + }, + "Argument out of range: {0}.": { + "code": 5028, + "category": 1 /* Error */ + }, + "Argument null: {0}.": { + "code": 5029, + "category": 1 /* Error */ + }, + "Operation not implemented properly by subclass.": { + "code": 5030, + "category": 1 /* Error */ + }, + "Not yet implemented.": { + "code": 5031, + "category": 1 /* Error */ + }, + "Invalid operation: {0}": { + "code": 5032, + "category": 1 /* Error */ + }, + "Invalid operation.": { + "code": 5033, + "category": 1 /* Error */ + }, + "Could not delete file '{0}'": { + "code": 5034, + "category": 1 /* Error */ + }, + "Could not create directory '{0}'": { + "code": 5035, + "category": 1 /* Error */ + }, + "Error while executing file '{0}': ": { + "code": 5036, + "category": 1 /* Error */ + }, + "Cannot compile external modules unless the '--module' flag is provided.": { + "code": 5037, + "category": 1 /* Error */ + }, + "Option mapRoot cannot be specified without specifying sourcemap option.": { + "code": 5038, + "category": 1 /* Error */ + }, + "Option sourceRoot cannot be specified without specifying sourcemap option.": { + "code": 5039, + "category": 1 /* Error */ + }, + "Options mapRoot and sourceRoot cannot be specified without specifying sourcemap option.": { + "code": 5040, + "category": 1 /* Error */ + }, + "Concatenate and emit output to single file": { + "code": 6001, + "category": 2 /* Message */ + }, + "Generates corresponding {0} file": { + "code": 6002, + "category": 2 /* Message */ + }, + "Specifies the location where debugger should locate map files instead of generated locations.": { + "code": 6003, + "category": 2 /* Message */ + }, + "Specifies the location where debugger should locate TypeScript files instead of source locations.": { + "code": 6004, + "category": 2 /* Message */ + }, + "Watch input files": { + "code": 6005, + "category": 2 /* Message */ + }, + "Redirect output structure to the directory": { + "code": 6006, + "category": 2 /* Message */ + }, + "Do not emit comments to output": { + "code": 6009, + "category": 2 /* Message */ + }, + "Skip resolution and preprocessing": { + "code": 6010, + "category": 2 /* Message */ + }, + "Specify ECMAScript target version: \"{0}\" (default), or \"{1}\"": { + "code": 6015, + "category": 2 /* Message */ + }, + "Specify module code generation: \"{0}\" or \"{1}\"": { + "code": 6016, + "category": 2 /* Message */ + }, + "Print this message": { + "code": 6017, + "category": 2 /* Message */ + }, + "Print the compiler's version: {0}": { + "code": 6019, + "category": 2 /* Message */ + }, + "Allow use of deprecated \"{0}\" keyword when referencing an external module": { + "code": 6021, + "category": 2 /* Message */ + }, + "Specify locale for errors and messages. For example '{0}' or '{1}'": { + "code": 6022, + "category": 2 /* Message */ + }, + "Syntax: {0}": { + "code": 6023, + "category": 2 /* Message */ + }, + "options": { + "code": 6024, + "category": 2 /* Message */ + }, + "file": { + "code": 6025, + "category": 2 /* Message */ + }, + "Examples:": { + "code": 6026, + "category": 2 /* Message */ + }, + "Options:": { + "code": 6027, + "category": 2 /* Message */ + }, + "Insert command line options and files from a file.": { + "code": 6030, + "category": 2 /* Message */ + }, + "Version {0}": { + "code": 6029, + "category": 2 /* Message */ + }, + "Use the '{0}' flag to see options": { + "code": 6031, + "category": 2 /* Message */ + }, + "{NL}Recompiling ({0}):": { + "code": 6032, + "category": 2 /* Message */ + }, + "STRING": { + "code": 6033, + "category": 2 /* Message */ + }, + "KIND": { + "code": 6034, + "category": 2 /* Message */ + }, + "FILE": { + "code": 6035, + "category": 2 /* Message */ + }, + "VERSION": { + "code": 6036, + "category": 2 /* Message */ + }, + "LOCATION": { + "code": 6037, + "category": 2 /* Message */ + }, + "DIRECTORY": { + "code": 6038, + "category": 2 /* Message */ + }, + "This version of the Javascript runtime does not support the '{0}' function.": { + "code": 7000, + "category": 1 /* Error */ + }, + "Looking up path for identifier token did not result in an identifer.": { + "code": 7001, + "category": 1 /* Error */ + }, + "Unknown rule": { + "code": 7002, + "category": 1 /* Error */ + }, + "Invalid line number ({0})": { + "code": 7003, + "category": 1 /* Error */ + }, + "Warn on expressions and declarations with an implied 'any' type.": { + "code": 7004, + "category": 2 /* Message */ + }, + "Variable '{0}' implicitly has an 'any' type.": { + "code": 7005, + "category": 1 /* Error */ + }, + "Parameter '{0}' of '{1}' implicitly has an 'any' type.": { + "code": 7006, + "category": 1 /* Error */ + }, + "Parameter '{0}' of function type implicitly has an 'any' type.": { + "code": 7007, + "category": 1 /* Error */ + }, + "Member '{0}' of object type implicitly has an 'any' type.": { + "code": 7008, + "category": 1 /* Error */ + }, + "\"New\" expression, which lacks a constructor signature, implicitly has an 'any' type.": { + "code": 7009, + "category": 1 /* Error */ + }, + "'{0}', which lacks return-type annotation, implicitly has an 'any' return type.": { + "code": 7010, + "category": 1 /* Error */ + }, + "Function expression, which lacks return-type annotation, implicitly has an 'any' return type.": { + "code": 7011, + "category": 1 /* Error */ + }, + "Parameter '{0}' of lambda function implicitly has an 'any' type.": { + "code": 7012, + "category": 1 /* Error */ + }, + "Constructor signature, which lacks return-type annotation, implicitly has an 'any' return type.": { + "code": 7013, + "category": 1 /* Error */ + }, + "Lambda Function, which lacks return-type annotation, implicitly has an 'any' return type.": { + "code": 7014, + "category": 1 /* Error */ + }, + "Array Literal implicitly has an 'any' type from widening.": { + "code": 7014, + "category": 1 /* Error */ + } + }; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (CharacterCodes) { + CharacterCodes[CharacterCodes["nullCharacter"] = 0] = "nullCharacter"; + CharacterCodes[CharacterCodes["maxAsciiCharacter"] = 127] = "maxAsciiCharacter"; + + CharacterCodes[CharacterCodes["lineFeed"] = 10] = "lineFeed"; + CharacterCodes[CharacterCodes["carriageReturn"] = 13] = "carriageReturn"; + CharacterCodes[CharacterCodes["lineSeparator"] = 0x2028] = "lineSeparator"; + CharacterCodes[CharacterCodes["paragraphSeparator"] = 0x2029] = "paragraphSeparator"; + + CharacterCodes[CharacterCodes["nextLine"] = 0x0085] = "nextLine"; + + CharacterCodes[CharacterCodes["space"] = 0x0020] = "space"; + CharacterCodes[CharacterCodes["nonBreakingSpace"] = 0x00A0] = "nonBreakingSpace"; + CharacterCodes[CharacterCodes["enQuad"] = 0x2000] = "enQuad"; + CharacterCodes[CharacterCodes["emQuad"] = 0x2001] = "emQuad"; + CharacterCodes[CharacterCodes["enSpace"] = 0x2002] = "enSpace"; + CharacterCodes[CharacterCodes["emSpace"] = 0x2003] = "emSpace"; + CharacterCodes[CharacterCodes["threePerEmSpace"] = 0x2004] = "threePerEmSpace"; + CharacterCodes[CharacterCodes["fourPerEmSpace"] = 0x2005] = "fourPerEmSpace"; + CharacterCodes[CharacterCodes["sixPerEmSpace"] = 0x2006] = "sixPerEmSpace"; + CharacterCodes[CharacterCodes["figureSpace"] = 0x2007] = "figureSpace"; + CharacterCodes[CharacterCodes["punctuationSpace"] = 0x2008] = "punctuationSpace"; + CharacterCodes[CharacterCodes["thinSpace"] = 0x2009] = "thinSpace"; + CharacterCodes[CharacterCodes["hairSpace"] = 0x200A] = "hairSpace"; + CharacterCodes[CharacterCodes["zeroWidthSpace"] = 0x200B] = "zeroWidthSpace"; + CharacterCodes[CharacterCodes["narrowNoBreakSpace"] = 0x202F] = "narrowNoBreakSpace"; + CharacterCodes[CharacterCodes["ideographicSpace"] = 0x3000] = "ideographicSpace"; + + CharacterCodes[CharacterCodes["_"] = 95] = "_"; + CharacterCodes[CharacterCodes["$"] = 36] = "$"; + + CharacterCodes[CharacterCodes["_0"] = 48] = "_0"; + CharacterCodes[CharacterCodes["_9"] = 57] = "_9"; + + CharacterCodes[CharacterCodes["a"] = 97] = "a"; + CharacterCodes[CharacterCodes["b"] = 98] = "b"; + CharacterCodes[CharacterCodes["c"] = 99] = "c"; + CharacterCodes[CharacterCodes["d"] = 100] = "d"; + CharacterCodes[CharacterCodes["e"] = 101] = "e"; + CharacterCodes[CharacterCodes["f"] = 102] = "f"; + CharacterCodes[CharacterCodes["g"] = 103] = "g"; + CharacterCodes[CharacterCodes["h"] = 104] = "h"; + CharacterCodes[CharacterCodes["i"] = 105] = "i"; + CharacterCodes[CharacterCodes["k"] = 107] = "k"; + CharacterCodes[CharacterCodes["l"] = 108] = "l"; + CharacterCodes[CharacterCodes["m"] = 109] = "m"; + CharacterCodes[CharacterCodes["n"] = 110] = "n"; + CharacterCodes[CharacterCodes["o"] = 111] = "o"; + CharacterCodes[CharacterCodes["p"] = 112] = "p"; + CharacterCodes[CharacterCodes["q"] = 113] = "q"; + CharacterCodes[CharacterCodes["r"] = 114] = "r"; + CharacterCodes[CharacterCodes["s"] = 115] = "s"; + CharacterCodes[CharacterCodes["t"] = 116] = "t"; + CharacterCodes[CharacterCodes["u"] = 117] = "u"; + CharacterCodes[CharacterCodes["v"] = 118] = "v"; + CharacterCodes[CharacterCodes["w"] = 119] = "w"; + CharacterCodes[CharacterCodes["x"] = 120] = "x"; + CharacterCodes[CharacterCodes["y"] = 121] = "y"; + CharacterCodes[CharacterCodes["z"] = 122] = "z"; + + CharacterCodes[CharacterCodes["A"] = 65] = "A"; + CharacterCodes[CharacterCodes["E"] = 69] = "E"; + CharacterCodes[CharacterCodes["F"] = 70] = "F"; + CharacterCodes[CharacterCodes["X"] = 88] = "X"; + CharacterCodes[CharacterCodes["Z"] = 90] = "Z"; + + CharacterCodes[CharacterCodes["ampersand"] = 38] = "ampersand"; + CharacterCodes[CharacterCodes["asterisk"] = 42] = "asterisk"; + CharacterCodes[CharacterCodes["at"] = 64] = "at"; + CharacterCodes[CharacterCodes["backslash"] = 92] = "backslash"; + CharacterCodes[CharacterCodes["bar"] = 124] = "bar"; + CharacterCodes[CharacterCodes["caret"] = 94] = "caret"; + CharacterCodes[CharacterCodes["closeBrace"] = 125] = "closeBrace"; + CharacterCodes[CharacterCodes["closeBracket"] = 93] = "closeBracket"; + CharacterCodes[CharacterCodes["closeParen"] = 41] = "closeParen"; + CharacterCodes[CharacterCodes["colon"] = 58] = "colon"; + CharacterCodes[CharacterCodes["comma"] = 44] = "comma"; + CharacterCodes[CharacterCodes["dot"] = 46] = "dot"; + CharacterCodes[CharacterCodes["doubleQuote"] = 34] = "doubleQuote"; + CharacterCodes[CharacterCodes["equals"] = 61] = "equals"; + CharacterCodes[CharacterCodes["exclamation"] = 33] = "exclamation"; + CharacterCodes[CharacterCodes["greaterThan"] = 62] = "greaterThan"; + CharacterCodes[CharacterCodes["lessThan"] = 60] = "lessThan"; + CharacterCodes[CharacterCodes["minus"] = 45] = "minus"; + CharacterCodes[CharacterCodes["openBrace"] = 123] = "openBrace"; + CharacterCodes[CharacterCodes["openBracket"] = 91] = "openBracket"; + CharacterCodes[CharacterCodes["openParen"] = 40] = "openParen"; + CharacterCodes[CharacterCodes["percent"] = 37] = "percent"; + CharacterCodes[CharacterCodes["plus"] = 43] = "plus"; + CharacterCodes[CharacterCodes["question"] = 63] = "question"; + CharacterCodes[CharacterCodes["semicolon"] = 59] = "semicolon"; + CharacterCodes[CharacterCodes["singleQuote"] = 39] = "singleQuote"; + CharacterCodes[CharacterCodes["slash"] = 47] = "slash"; + CharacterCodes[CharacterCodes["tilde"] = 126] = "tilde"; + + CharacterCodes[CharacterCodes["backspace"] = 8] = "backspace"; + CharacterCodes[CharacterCodes["formFeed"] = 12] = "formFeed"; + CharacterCodes[CharacterCodes["byteOrderMark"] = 0xFEFF] = "byteOrderMark"; + CharacterCodes[CharacterCodes["tab"] = 9] = "tab"; + CharacterCodes[CharacterCodes["verticalTab"] = 11] = "verticalTab"; + })(TypeScript.CharacterCodes || (TypeScript.CharacterCodes = {})); + var CharacterCodes = TypeScript.CharacterCodes; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (ScriptSnapshot) { + var StringScriptSnapshot = (function () { + function StringScriptSnapshot(text) { + this.text = text; + } + StringScriptSnapshot.prototype.getText = function (start, end) { + return this.text.substring(start, end); + }; + + StringScriptSnapshot.prototype.getLength = function () { + return this.text.length; + }; + + StringScriptSnapshot.prototype.getLineStartPositions = function () { + return TypeScript.TextUtilities.parseLineStarts(TypeScript.SimpleText.fromString(this.text)); + }; + + StringScriptSnapshot.prototype.getTextChangeRangeSinceVersion = function (scriptVersion) { + throw TypeScript.Errors.notYetImplemented(); + }; + return StringScriptSnapshot; + })(); + + function fromString(text) { + return new StringScriptSnapshot(text); + } + ScriptSnapshot.fromString = fromString; + })(TypeScript.ScriptSnapshot || (TypeScript.ScriptSnapshot = {})); + var ScriptSnapshot = TypeScript.ScriptSnapshot; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var LineMap = (function () { + function LineMap(_lineStarts, length) { + this._lineStarts = _lineStarts; + this.length = length; + } + LineMap.prototype.toJSON = function (key) { + return { lineStarts: this._lineStarts, length: this.length }; + }; + + LineMap.prototype.equals = function (other) { + return this.length === other.length && TypeScript.ArrayUtilities.sequenceEquals(this.lineStarts(), other.lineStarts(), function (v1, v2) { + return v1 === v2; + }); + }; + + LineMap.prototype.lineStarts = function () { + return this._lineStarts; + }; + + LineMap.prototype.lineCount = function () { + return this.lineStarts().length; + }; + + LineMap.prototype.getPosition = function (line, character) { + return this.lineStarts()[line] + character; + }; + + LineMap.prototype.getLineNumberFromPosition = function (position) { + if (position < 0 || position > this.length) { + throw TypeScript.Errors.argumentOutOfRange("position"); + } + + if (position === this.length) { + return this.lineCount() - 1; + } + + var lineNumber = TypeScript.ArrayUtilities.binarySearch(this.lineStarts(), position); + if (lineNumber < 0) { + lineNumber = (~lineNumber) - 1; + } + + return lineNumber; + }; + + LineMap.prototype.getLineStartPosition = function (lineNumber) { + return this.lineStarts()[lineNumber]; + }; + + LineMap.prototype.fillLineAndCharacterFromPosition = function (position, lineAndCharacter) { + if (position < 0 || position > this.length) { + throw TypeScript.Errors.argumentOutOfRange("position"); + } + + var lineNumber = this.getLineNumberFromPosition(position); + lineAndCharacter.line = lineNumber; + lineAndCharacter.character = position - this.lineStarts()[lineNumber]; + }; + + LineMap.prototype.getLineAndCharacterFromPosition = function (position) { + if (position < 0 || position > this.length) { + throw TypeScript.Errors.argumentOutOfRange("position"); + } + + var lineNumber = this.getLineNumberFromPosition(position); + + return new TypeScript.LineAndCharacter(lineNumber, position - this.lineStarts()[lineNumber]); + }; + + LineMap.fromSimpleText = function (text) { + var lineStarts = TypeScript.TextUtilities.parseLineStarts(text); + + return new LineMap(lineStarts, text.length()); + }; + + LineMap.fromScriptSnapshot = function (scriptSnapshot) { + return new LineMap(scriptSnapshot.getLineStartPositions(), scriptSnapshot.getLength()); + }; + + LineMap.fromString = function (text) { + return LineMap.fromSimpleText(TypeScript.SimpleText.fromString(text)); + }; + LineMap.empty = new LineMap([0], 0); + return LineMap; + })(); + TypeScript.LineMap = LineMap; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var LineAndCharacter = (function () { + function LineAndCharacter(line, character) { + this._line = 0; + this._character = 0; + if (line < 0) { + throw TypeScript.Errors.argumentOutOfRange("line"); + } + + if (character < 0) { + throw TypeScript.Errors.argumentOutOfRange("character"); + } + + this._line = line; + this._character = character; + } + LineAndCharacter.prototype.line = function () { + return this._line; + }; + + LineAndCharacter.prototype.character = function () { + return this._character; + }; + return LineAndCharacter; + })(); + TypeScript.LineAndCharacter = LineAndCharacter; +})(TypeScript || (TypeScript = {})); +var __extends = this.__extends || function (d, b) { + for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; + function __() { this.constructor = d; } + __.prototype = b.prototype; + d.prototype = new __(); +}; +var TypeScript; +(function (TypeScript) { + (function (TextFactory) { + function getStartAndLengthOfLineBreakEndingAt(text, index, info) { + var c = text.charCodeAt(index); + if (c === 10 /* lineFeed */) { + if (index > 0 && text.charCodeAt(index - 1) === 13 /* carriageReturn */) { + info.startPosition = index - 1; + info.length = 2; + } else { + info.startPosition = index; + info.length = 1; + } + } else if (TypeScript.TextUtilities.isAnyLineBreakCharacter(c)) { + info.startPosition = index; + info.length = 1; + } else { + info.startPosition = index + 1; + info.length = 0; + } + } + + var LinebreakInfo = (function () { + function LinebreakInfo(startPosition, length) { + this.startPosition = startPosition; + this.length = length; + } + return LinebreakInfo; + })(); + + var TextLine = (function () { + function TextLine(text, body, lineBreakLength, lineNumber) { + this._text = null; + this._textSpan = null; + if (text === null) { + throw TypeScript.Errors.argumentNull('text'); + } + TypeScript.Debug.assert(lineBreakLength >= 0); + TypeScript.Debug.assert(lineNumber >= 0); + this._text = text; + this._textSpan = body; + this._lineBreakLength = lineBreakLength; + this._lineNumber = lineNumber; + } + TextLine.prototype.start = function () { + return this._textSpan.start(); + }; + + TextLine.prototype.end = function () { + return this._textSpan.end(); + }; + + TextLine.prototype.endIncludingLineBreak = function () { + return this.end() + this._lineBreakLength; + }; + + TextLine.prototype.extent = function () { + return this._textSpan; + }; + + TextLine.prototype.extentIncludingLineBreak = function () { + return TypeScript.TextSpan.fromBounds(this.start(), this.endIncludingLineBreak()); + }; + + TextLine.prototype.toString = function () { + return this._text.toString(this._textSpan); + }; + + TextLine.prototype.lineNumber = function () { + return this._lineNumber; + }; + return TextLine; + })(); + + var TextBase = (function () { + function TextBase() { + this.lazyLineStarts = null; + this.linebreakInfo = new LinebreakInfo(0, 0); + this.lastLineFoundForPosition = null; + } + TextBase.prototype.length = function () { + throw TypeScript.Errors.abstract(); + }; + + TextBase.prototype.charCodeAt = function (position) { + throw TypeScript.Errors.abstract(); + }; + + TextBase.prototype.checkSubSpan = function (span) { + if (span.start() < 0 || span.start() > this.length() || span.end() > this.length()) { + throw TypeScript.Errors.argumentOutOfRange("span"); + } + }; + + TextBase.prototype.toString = function (span) { + if (typeof span === "undefined") { span = null; } + throw TypeScript.Errors.abstract(); + }; + + TextBase.prototype.subText = function (span) { + this.checkSubSpan(span); + + return new SubText(this, span); + }; + + TextBase.prototype.substr = function (start, length, intern) { + throw TypeScript.Errors.abstract(); + }; + + TextBase.prototype.copyTo = function (sourceIndex, destination, destinationIndex, count) { + throw TypeScript.Errors.abstract(); + }; + + TextBase.prototype.lineCount = function () { + return this.lineStarts().length; + }; + + TextBase.prototype.lines = function () { + var lines = []; + + var length = this.lineCount(); + for (var i = 0; i < length; ++i) { + lines[i] = this.getLineFromLineNumber(i); + } + + return lines; + }; + + TextBase.prototype.lineMap = function () { + return new TypeScript.LineMap(this.lineStarts(), this.length()); + }; + + TextBase.prototype.lineStarts = function () { + if (this.lazyLineStarts === null) { + this.lazyLineStarts = TypeScript.TextUtilities.parseLineStarts(this); + } + + return this.lazyLineStarts; + }; + + TextBase.prototype.getLineFromLineNumber = function (lineNumber) { + var lineStarts = this.lineStarts(); + + if (lineNumber < 0 || lineNumber >= lineStarts.length) { + throw TypeScript.Errors.argumentOutOfRange("lineNumber"); + } + + var first = lineStarts[lineNumber]; + if (lineNumber === lineStarts.length - 1) { + return new TextLine(this, new TypeScript.TextSpan(first, this.length() - first), 0, lineNumber); + } else { + getStartAndLengthOfLineBreakEndingAt(this, lineStarts[lineNumber + 1] - 1, this.linebreakInfo); + return new TextLine(this, new TypeScript.TextSpan(first, this.linebreakInfo.startPosition - first), this.linebreakInfo.length, lineNumber); + } + }; + + TextBase.prototype.getLineFromPosition = function (position) { + var lastFound = this.lastLineFoundForPosition; + if (lastFound !== null && lastFound.start() <= position && lastFound.endIncludingLineBreak() > position) { + return lastFound; + } + + var lineNumber = this.getLineNumberFromPosition(position); + + var result = this.getLineFromLineNumber(lineNumber); + this.lastLineFoundForPosition = result; + return result; + }; + + TextBase.prototype.getLineNumberFromPosition = function (position) { + if (position < 0 || position > this.length()) { + throw TypeScript.Errors.argumentOutOfRange("position"); + } + + if (position === this.length()) { + return this.lineCount() - 1; + } + + var lineNumber = TypeScript.ArrayUtilities.binarySearch(this.lineStarts(), position); + if (lineNumber < 0) { + lineNumber = (~lineNumber) - 1; + } + + return lineNumber; + }; + + TextBase.prototype.getLinePosition = function (position) { + if (position < 0 || position > this.length()) { + throw TypeScript.Errors.argumentOutOfRange("position"); + } + + var lineNumber = this.getLineNumberFromPosition(position); + + return new TypeScript.LineAndCharacter(lineNumber, position - this.lineStarts()[lineNumber]); + }; + return TextBase; + })(); + + var SubText = (function (_super) { + __extends(SubText, _super); + function SubText(text, span) { + _super.call(this); + + if (text === null) { + throw TypeScript.Errors.argumentNull("text"); + } + + if (span.start() < 0 || span.start() >= text.length() || span.end() < 0 || span.end() > text.length()) { + throw TypeScript.Errors.argument("span"); + } + + this.text = text; + this.span = span; + } + SubText.prototype.length = function () { + return this.span.length(); + }; + + SubText.prototype.charCodeAt = function (position) { + if (position < 0 || position > this.length()) { + throw TypeScript.Errors.argumentOutOfRange("position"); + } + + return this.text.charCodeAt(this.span.start() + position); + }; + + SubText.prototype.subText = function (span) { + this.checkSubSpan(span); + + return new SubText(this.text, this.getCompositeSpan(span.start(), span.length())); + }; + + SubText.prototype.copyTo = function (sourceIndex, destination, destinationIndex, count) { + var span = this.getCompositeSpan(sourceIndex, count); + this.text.copyTo(span.start(), destination, destinationIndex, span.length()); + }; + + SubText.prototype.getCompositeSpan = function (start, length) { + var compositeStart = TypeScript.MathPrototype.min(this.text.length(), this.span.start() + start); + var compositeEnd = TypeScript.MathPrototype.min(this.text.length(), compositeStart + length); + return new TypeScript.TextSpan(compositeStart, compositeEnd - compositeStart); + }; + return SubText; + })(TextBase); + + var StringText = (function (_super) { + __extends(StringText, _super); + function StringText(data) { + _super.call(this); + this.source = null; + + if (data === null) { + throw TypeScript.Errors.argumentNull("data"); + } + + this.source = data; + } + StringText.prototype.length = function () { + return this.source.length; + }; + + StringText.prototype.charCodeAt = function (position) { + if (position < 0 || position >= this.source.length) { + throw TypeScript.Errors.argumentOutOfRange("position"); + } + + return this.source.charCodeAt(position); + }; + + StringText.prototype.substr = function (start, length, intern) { + return this.source.substr(start, length); + }; + + StringText.prototype.toString = function (span) { + if (typeof span === "undefined") { span = null; } + if (span === null) { + span = new TypeScript.TextSpan(0, this.length()); + } + + this.checkSubSpan(span); + + if (span.start() === 0 && span.length() === this.length()) { + return this.source; + } + + return this.source.substr(span.start(), span.length()); + }; + + StringText.prototype.copyTo = function (sourceIndex, destination, destinationIndex, count) { + TypeScript.StringUtilities.copyTo(this.source, sourceIndex, destination, destinationIndex, count); + }; + return StringText; + })(TextBase); + + function createText(value) { + return new StringText(value); + } + TextFactory.createText = createText; + })(TypeScript.TextFactory || (TypeScript.TextFactory = {})); + var TextFactory = TypeScript.TextFactory; +})(TypeScript || (TypeScript = {})); + +var TypeScript; +(function (TypeScript) { + (function (SimpleText) { + var SimpleSubText = (function () { + function SimpleSubText(text, span) { + this.text = null; + this.span = null; + if (text === null) { + throw TypeScript.Errors.argumentNull("text"); + } + + if (span.start() < 0 || span.start() >= text.length() || span.end() < 0 || span.end() > text.length()) { + throw TypeScript.Errors.argument("span"); + } + + this.text = text; + this.span = span; + } + SimpleSubText.prototype.checkSubSpan = function (span) { + if (span.start() < 0 || span.start() > this.length() || span.end() > this.length()) { + throw TypeScript.Errors.argumentOutOfRange("span"); + } + }; + + SimpleSubText.prototype.checkSubPosition = function (position) { + if (position < 0 || position >= this.length()) { + throw TypeScript.Errors.argumentOutOfRange("position"); + } + }; + + SimpleSubText.prototype.length = function () { + return this.span.length(); + }; + + SimpleSubText.prototype.subText = function (span) { + this.checkSubSpan(span); + + return new SimpleSubText(this.text, this.getCompositeSpan(span.start(), span.length())); + }; + + SimpleSubText.prototype.copyTo = function (sourceIndex, destination, destinationIndex, count) { + var span = this.getCompositeSpan(sourceIndex, count); + this.text.copyTo(span.start(), destination, destinationIndex, span.length()); + }; + + SimpleSubText.prototype.substr = function (start, length, intern) { + var span = this.getCompositeSpan(start, length); + return this.text.substr(span.start(), span.length(), intern); + }; + + SimpleSubText.prototype.getCompositeSpan = function (start, length) { + var compositeStart = TypeScript.MathPrototype.min(this.text.length(), this.span.start() + start); + var compositeEnd = TypeScript.MathPrototype.min(this.text.length(), compositeStart + length); + return new TypeScript.TextSpan(compositeStart, compositeEnd - compositeStart); + }; + + SimpleSubText.prototype.charCodeAt = function (index) { + this.checkSubPosition(index); + return this.text.charCodeAt(this.span.start() + index); + }; + + SimpleSubText.prototype.lineMap = function () { + return TypeScript.LineMap.fromSimpleText(this); + }; + return SimpleSubText; + })(); + + var SimpleStringText = (function () { + function SimpleStringText(value) { + this.value = value; + } + SimpleStringText.prototype.length = function () { + return this.value.length; + }; + + SimpleStringText.prototype.copyTo = function (sourceIndex, destination, destinationIndex, count) { + TypeScript.StringUtilities.copyTo(this.value, sourceIndex, destination, destinationIndex, count); + }; + + SimpleStringText.prototype.substr = function (start, length, intern) { + if (intern) { + var array = length <= SimpleStringText.charArray.length ? SimpleStringText.charArray : TypeScript.ArrayUtilities.createArray(length, 0); + this.copyTo(start, array, 0, length); + return TypeScript.Collections.DefaultStringTable.addCharArray(array, 0, length); + } + + return this.value.substr(start, length); + }; + + SimpleStringText.prototype.subText = function (span) { + return new SimpleSubText(this, span); + }; + + SimpleStringText.prototype.charCodeAt = function (index) { + return this.value.charCodeAt(index); + }; + + SimpleStringText.prototype.lineMap = function () { + return TypeScript.LineMap.fromSimpleText(this); + }; + SimpleStringText.charArray = TypeScript.ArrayUtilities.createArray(1024, 0); + return SimpleStringText; + })(); + + var SimpleScriptSnapshotText = (function () { + function SimpleScriptSnapshotText(scriptSnapshot) { + this.scriptSnapshot = scriptSnapshot; + } + SimpleScriptSnapshotText.prototype.charCodeAt = function (index) { + return this.scriptSnapshot.getText(index, index + 1).charCodeAt(0); + }; + + SimpleScriptSnapshotText.prototype.length = function () { + return this.scriptSnapshot.getLength(); + }; + + SimpleScriptSnapshotText.prototype.copyTo = function (sourceIndex, destination, destinationIndex, count) { + var text = this.scriptSnapshot.getText(sourceIndex, sourceIndex + count); + TypeScript.StringUtilities.copyTo(text, 0, destination, destinationIndex, count); + }; + + SimpleScriptSnapshotText.prototype.substr = function (start, length, intern) { + return this.scriptSnapshot.getText(start, start + length); + }; + + SimpleScriptSnapshotText.prototype.subText = function (span) { + return new SimpleSubText(this, span); + }; + + SimpleScriptSnapshotText.prototype.lineMap = function () { + var lineStartPositions = this.scriptSnapshot.getLineStartPositions(); + return new TypeScript.LineMap(lineStartPositions, this.length()); + }; + return SimpleScriptSnapshotText; + })(); + + function fromString(value) { + return new SimpleStringText(value); + } + SimpleText.fromString = fromString; + + function fromScriptSnapshot(scriptSnapshot) { + return new SimpleScriptSnapshotText(scriptSnapshot); + } + SimpleText.fromScriptSnapshot = fromScriptSnapshot; + })(TypeScript.SimpleText || (TypeScript.SimpleText = {})); + var SimpleText = TypeScript.SimpleText; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (TextUtilities) { + function parseLineStarts(text) { + var length = text.length(); + + if (0 === length) { + var result = new Array(); + result.push(0); + return result; + } + + var position = 0; + var index = 0; + var arrayBuilder = new Array(); + var lineNumber = 0; + + while (index < length) { + var c = text.charCodeAt(index); + var lineBreakLength; + + if (c > 13 /* carriageReturn */ && c <= 127) { + index++; + continue; + } else if (c === 13 /* carriageReturn */ && index + 1 < length && text.charCodeAt(index + 1) === 10 /* lineFeed */) { + lineBreakLength = 2; + } else if (c === 10 /* lineFeed */) { + lineBreakLength = 1; + } else { + lineBreakLength = TextUtilities.getLengthOfLineBreak(text, index); + } + + if (0 === lineBreakLength) { + index++; + } else { + arrayBuilder.push(position); + index += lineBreakLength; + position = index; + lineNumber++; + } + } + + arrayBuilder.push(position); + + return arrayBuilder; + } + TextUtilities.parseLineStarts = parseLineStarts; + + function getLengthOfLineBreakSlow(text, index, c) { + if (c === 13 /* carriageReturn */) { + var next = index + 1; + return (next < text.length()) && 10 /* lineFeed */ === text.charCodeAt(next) ? 2 : 1; + } else if (isAnyLineBreakCharacter(c)) { + return 1; + } else { + return 0; + } + } + TextUtilities.getLengthOfLineBreakSlow = getLengthOfLineBreakSlow; + + function getLengthOfLineBreak(text, index) { + var c = text.charCodeAt(index); + + if (c > 13 /* carriageReturn */ && c <= 127) { + return 0; + } + + return getLengthOfLineBreakSlow(text, index, c); + } + TextUtilities.getLengthOfLineBreak = getLengthOfLineBreak; + + function isAnyLineBreakCharacter(c) { + return c === 10 /* lineFeed */ || c === 13 /* carriageReturn */ || c === 133 /* nextLine */ || c === 8232 /* lineSeparator */ || c === 8233 /* paragraphSeparator */; + } + TextUtilities.isAnyLineBreakCharacter = isAnyLineBreakCharacter; + })(TypeScript.TextUtilities || (TypeScript.TextUtilities = {})); + var TextUtilities = TypeScript.TextUtilities; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var TextSpan = (function () { + function TextSpan(start, length) { + if (start < 0) { + TypeScript.Errors.argument("start"); + } + + if (length < 0) { + TypeScript.Errors.argument("length"); + } + + this._start = start; + this._length = length; + } + TextSpan.prototype.start = function () { + return this._start; + }; + + TextSpan.prototype.length = function () { + return this._length; + }; + + TextSpan.prototype.end = function () { + return this._start + this._length; + }; + + TextSpan.prototype.isEmpty = function () { + return this._length === 0; + }; + + TextSpan.prototype.containsPosition = function (position) { + return position >= this._start && position < this.end(); + }; + + TextSpan.prototype.containsTextSpan = function (span) { + return span._start >= this._start && span.end() <= this.end(); + }; + + TextSpan.prototype.overlapsWith = function (span) { + var overlapStart = TypeScript.MathPrototype.max(this._start, span._start); + var overlapEnd = TypeScript.MathPrototype.min(this.end(), span.end()); + + return overlapStart < overlapEnd; + }; + + TextSpan.prototype.overlap = function (span) { + var overlapStart = TypeScript.MathPrototype.max(this._start, span._start); + var overlapEnd = TypeScript.MathPrototype.min(this.end(), span.end()); + + if (overlapStart < overlapEnd) { + return TextSpan.fromBounds(overlapStart, overlapEnd); + } + + return null; + }; + + TextSpan.prototype.intersectsWithTextSpan = function (span) { + return span._start <= this.end() && span.end() >= this._start; + }; + + TextSpan.prototype.intersectsWith = function (start, length) { + var end = start + length; + return start <= this.end() && end >= this._start; + }; + + TextSpan.prototype.intersectsWithPosition = function (position) { + return position <= this.end() && position >= this._start; + }; + + TextSpan.prototype.intersection = function (span) { + var intersectStart = TypeScript.MathPrototype.max(this._start, span._start); + var intersectEnd = TypeScript.MathPrototype.min(this.end(), span.end()); + + if (intersectStart <= intersectEnd) { + return TextSpan.fromBounds(intersectStart, intersectEnd); + } + + return null; + }; + + TextSpan.fromBounds = function (start, end) { + TypeScript.Debug.assert(start >= 0); + TypeScript.Debug.assert(end - start >= 0); + return new TextSpan(start, end - start); + }; + return TextSpan; + })(); + TypeScript.TextSpan = TextSpan; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var TextChangeRange = (function () { + function TextChangeRange(span, newLength) { + if (newLength < 0) { + throw TypeScript.Errors.argumentOutOfRange("newLength"); + } + + this._span = span; + this._newLength = newLength; + } + TextChangeRange.prototype.span = function () { + return this._span; + }; + + TextChangeRange.prototype.newLength = function () { + return this._newLength; + }; + + TextChangeRange.prototype.newSpan = function () { + return new TypeScript.TextSpan(this.span().start(), this.newLength()); + }; + + TextChangeRange.prototype.isUnchanged = function () { + return this.span().isEmpty() && this.newLength() === 0; + }; + + TextChangeRange.collapseChangesFromSingleVersion = function (changes) { + var diff = 0; + var start = 1073741823 /* Max31BitInteger */; + var end = 0; + + for (var i = 0; i < changes.length; i++) { + var change = changes[i]; + diff += change.newLength() - change.span().length(); + + if (change.span().start() < start) { + start = change.span().start(); + } + + if (change.span().end() > end) { + end = change.span().end(); + } + } + + if (start > end) { + return null; + } + + var combined = TypeScript.TextSpan.fromBounds(start, end); + var newLen = combined.length() + diff; + + return new TextChangeRange(combined, newLen); + }; + + TextChangeRange.collapseChangesAcrossMultipleVersions = function (changes) { + if (changes.length === 0) { + return TextChangeRange.unchanged; + } + + if (changes.length === 1) { + return changes[0]; + } + + 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]; + + 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 = TypeScript.MathPrototype.min(oldStart1, oldStart2); + oldEndN = TypeScript.MathPrototype.max(oldEnd1, oldEnd1 + (oldEnd2 - newEnd1)); + newEndN = TypeScript.MathPrototype.max(newEnd2, newEnd2 + (newEnd1 - oldEnd2)); + } + + return new TextChangeRange(TypeScript.TextSpan.fromBounds(oldStartN, oldEndN), newEndN - oldStartN); + }; + TextChangeRange.unchanged = new TextChangeRange(new TypeScript.TextSpan(0, 0), 0); + return TextChangeRange; + })(); + TypeScript.TextChangeRange = TextChangeRange; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var CharacterInfo = (function () { + function CharacterInfo() { + } + CharacterInfo.isDecimalDigit = function (c) { + return c >= 48 /* _0 */ && c <= 57 /* _9 */; + }; + + CharacterInfo.isHexDigit = function (c) { + return CharacterInfo.isDecimalDigit(c) || (c >= 65 /* A */ && c <= 70 /* F */) || (c >= 97 /* a */ && c <= 102 /* f */); + }; + + CharacterInfo.hexValue = function (c) { + return CharacterInfo.isDecimalDigit(c) ? (c - 48 /* _0 */) : (c >= 65 /* A */ && c <= 70 /* F */) ? c - 65 /* A */ + 10 : c - 97 /* a */ + 10; + }; + + CharacterInfo.isWhitespace = function (ch) { + switch (ch) { + case 32 /* space */: + case 160 /* nonBreakingSpace */: + case 8192 /* enQuad */: + case 8193 /* emQuad */: + case 8194 /* enSpace */: + case 8195 /* emSpace */: + case 8196 /* threePerEmSpace */: + case 8197 /* fourPerEmSpace */: + case 8198 /* sixPerEmSpace */: + case 8199 /* figureSpace */: + case 8200 /* punctuationSpace */: + case 8201 /* thinSpace */: + case 8202 /* hairSpace */: + case 8203 /* zeroWidthSpace */: + case 8239 /* narrowNoBreakSpace */: + case 12288 /* ideographicSpace */: + + case 9 /* tab */: + case 11 /* verticalTab */: + case 12 /* formFeed */: + case 65279 /* byteOrderMark */: + return true; + } + + return false; + }; + + CharacterInfo.isLineTerminator = function (ch) { + switch (ch) { + case 13 /* carriageReturn */: + case 10 /* lineFeed */: + case 8233 /* paragraphSeparator */: + case 8232 /* lineSeparator */: + return true; + } + + return false; + }; + return CharacterInfo; + })(); + TypeScript.CharacterInfo = CharacterInfo; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (SyntaxConstants) { + SyntaxConstants[SyntaxConstants["TriviaNewLineMask"] = 0x00000001] = "TriviaNewLineMask"; + SyntaxConstants[SyntaxConstants["TriviaCommentMask"] = 0x00000002] = "TriviaCommentMask"; + SyntaxConstants[SyntaxConstants["TriviaFullWidthShift"] = 2] = "TriviaFullWidthShift"; + + SyntaxConstants[SyntaxConstants["NodeDataComputed"] = 0x00000001] = "NodeDataComputed"; + SyntaxConstants[SyntaxConstants["NodeIncrementallyUnusableMask"] = 0x00000002] = "NodeIncrementallyUnusableMask"; + SyntaxConstants[SyntaxConstants["NodeParsedInStrictModeMask"] = 0x00000004] = "NodeParsedInStrictModeMask"; + SyntaxConstants[SyntaxConstants["NodeFullWidthShift"] = 3] = "NodeFullWidthShift"; + })(TypeScript.SyntaxConstants || (TypeScript.SyntaxConstants = {})); + var SyntaxConstants = TypeScript.SyntaxConstants; +})(TypeScript || (TypeScript = {})); +var FormattingOptions = (function () { + function FormattingOptions(useTabs, spacesPerTab, indentSpaces, newLineCharacter) { + this.useTabs = useTabs; + this.spacesPerTab = spacesPerTab; + this.indentSpaces = indentSpaces; + this.newLineCharacter = newLineCharacter; + } + FormattingOptions.defaultOptions = new FormattingOptions(false, 4, 4, "\r\n"); + return FormattingOptions; +})(); +var TypeScript; +(function (TypeScript) { + (function (Indentation) { + function columnForEndOfToken(token, syntaxInformationMap, options) { + return columnForStartOfToken(token, syntaxInformationMap, options) + token.width(); + } + Indentation.columnForEndOfToken = columnForEndOfToken; + + function columnForStartOfToken(token, syntaxInformationMap, options) { + var firstTokenInLine = syntaxInformationMap.firstTokenInLineContainingToken(token); + var leadingTextInReverse = []; + + var current = token; + while (current !== firstTokenInLine) { + current = syntaxInformationMap.previousToken(current); + + if (current === firstTokenInLine) { + leadingTextInReverse.push(current.trailingTrivia().fullText()); + leadingTextInReverse.push(current.text()); + } else { + leadingTextInReverse.push(current.fullText()); + } + } + + collectLeadingTriviaTextToStartOfLine(firstTokenInLine, leadingTextInReverse); + + return columnForLeadingTextInReverse(leadingTextInReverse, options); + } + Indentation.columnForStartOfToken = columnForStartOfToken; + + function columnForStartOfFirstTokenInLineContainingToken(token, syntaxInformationMap, options) { + var firstTokenInLine = syntaxInformationMap.firstTokenInLineContainingToken(token); + var leadingTextInReverse = []; + + collectLeadingTriviaTextToStartOfLine(firstTokenInLine, leadingTextInReverse); + + return columnForLeadingTextInReverse(leadingTextInReverse, options); + } + Indentation.columnForStartOfFirstTokenInLineContainingToken = columnForStartOfFirstTokenInLineContainingToken; + + function collectLeadingTriviaTextToStartOfLine(firstTokenInLine, leadingTextInReverse) { + var leadingTrivia = firstTokenInLine.leadingTrivia(); + + for (var i = leadingTrivia.count() - 1; i >= 0; i--) { + var trivia = leadingTrivia.syntaxTriviaAt(i); + if (trivia.kind() === 5 /* NewLineTrivia */) { + break; + } + + if (trivia.kind() === 6 /* MultiLineCommentTrivia */) { + var lineSegments = TypeScript.Syntax.splitMultiLineCommentTriviaIntoMultipleLines(trivia); + leadingTextInReverse.push(TypeScript.ArrayUtilities.last(lineSegments)); + + if (lineSegments.length > 0) { + break; + } + } + + leadingTextInReverse.push(trivia.fullText()); + } + } + + function columnForLeadingTextInReverse(leadingTextInReverse, options) { + var column = 0; + + for (var i = leadingTextInReverse.length - 1; i >= 0; i--) { + var text = leadingTextInReverse[i]; + column = columnForPositionInStringWorker(text, text.length, column, options); + } + + return column; + } + + function columnForPositionInString(input, position, options) { + return columnForPositionInStringWorker(input, position, 0, options); + } + Indentation.columnForPositionInString = columnForPositionInString; + + function columnForPositionInStringWorker(input, position, startColumn, options) { + var column = startColumn; + var spacesPerTab = options.spacesPerTab; + + for (var j = 0; j < position; j++) { + var ch = input.charCodeAt(j); + + if (ch === 9 /* tab */) { + column += spacesPerTab - column % spacesPerTab; + } else { + column++; + } + } + + return column; + } + + function indentationString(column, options) { + var numberOfTabs = 0; + var numberOfSpaces = TypeScript.MathPrototype.max(0, column); + + if (options.useTabs) { + numberOfTabs = Math.floor(column / options.spacesPerTab); + numberOfSpaces -= numberOfTabs * options.spacesPerTab; + } + + return TypeScript.StringUtilities.repeat('\t', numberOfTabs) + TypeScript.StringUtilities.repeat(' ', numberOfSpaces); + } + Indentation.indentationString = indentationString; + + function indentationTrivia(column, options) { + return TypeScript.Syntax.whitespace(this.indentationString(column, options)); + } + Indentation.indentationTrivia = indentationTrivia; + + function firstNonWhitespacePosition(value) { + for (var i = 0; i < value.length; i++) { + var ch = value.charCodeAt(i); + if (!TypeScript.CharacterInfo.isWhitespace(ch)) { + return i; + } + } + + return value.length; + } + Indentation.firstNonWhitespacePosition = firstNonWhitespacePosition; + })(TypeScript.Indentation || (TypeScript.Indentation = {})); + var Indentation = TypeScript.Indentation; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (LanguageVersion) { + LanguageVersion[LanguageVersion["EcmaScript3"] = 0] = "EcmaScript3"; + LanguageVersion[LanguageVersion["EcmaScript5"] = 1] = "EcmaScript5"; + })(TypeScript.LanguageVersion || (TypeScript.LanguageVersion = {})); + var LanguageVersion = TypeScript.LanguageVersion; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var ParseOptions = (function () { + function ParseOptions(languageVersion, allowAutomaticSemicolonInsertion) { + this._languageVersion = languageVersion; + this._allowAutomaticSemicolonInsertion = allowAutomaticSemicolonInsertion; + } + ParseOptions.prototype.toJSON = function (key) { + return { allowAutomaticSemicolonInsertion: this._allowAutomaticSemicolonInsertion }; + }; + + ParseOptions.prototype.languageVersion = function () { + return this._languageVersion; + }; + + ParseOptions.prototype.allowAutomaticSemicolonInsertion = function () { + return this._allowAutomaticSemicolonInsertion; + }; + return ParseOptions; + })(); + TypeScript.ParseOptions = ParseOptions; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var PositionedElement = (function () { + function PositionedElement(parent, element, fullStart) { + this._parent = parent; + this._element = element; + this._fullStart = fullStart; + } + PositionedElement.create = function (parent, element, fullStart) { + if (element === null) { + return null; + } + + if (element.isNode()) { + return new PositionedNode(parent, element, fullStart); + } else if (element.isToken()) { + return new PositionedToken(parent, element, fullStart); + } else if (element.isList()) { + return new PositionedList(parent, element, fullStart); + } else if (element.isSeparatedList()) { + return new PositionedSeparatedList(parent, element, fullStart); + } else { + throw TypeScript.Errors.invalidOperation(); + } + }; + + PositionedElement.prototype.parent = function () { + return this._parent; + }; + + PositionedElement.prototype.parentElement = function () { + return this._parent && this._parent._element; + }; + + PositionedElement.prototype.element = function () { + return this._element; + }; + + PositionedElement.prototype.kind = function () { + return this.element().kind(); + }; + + PositionedElement.prototype.childIndex = function (child) { + return TypeScript.Syntax.childIndex(this.element(), child); + }; + + PositionedElement.prototype.childCount = function () { + return this.element().childCount(); + }; + + PositionedElement.prototype.childAt = function (index) { + var offset = TypeScript.Syntax.childOffsetAt(this.element(), index); + return PositionedElement.create(this, this.element().childAt(index), this.fullStart() + offset); + }; + + PositionedElement.prototype.childStart = function (child) { + var offset = TypeScript.Syntax.childOffset(this.element(), child); + return this.fullStart() + offset + child.leadingTriviaWidth(); + }; + + PositionedElement.prototype.childEnd = function (child) { + var offset = TypeScript.Syntax.childOffset(this.element(), child); + return this.fullStart() + offset + child.leadingTriviaWidth() + child.width(); + }; + + PositionedElement.prototype.childStartAt = function (index) { + var offset = TypeScript.Syntax.childOffsetAt(this.element(), index); + var child = this.element().childAt(index); + return this.fullStart() + offset + child.leadingTriviaWidth(); + }; + + PositionedElement.prototype.childEndAt = function (index) { + var offset = TypeScript.Syntax.childOffsetAt(this.element(), index); + var child = this.element().childAt(index); + return this.fullStart() + offset + child.leadingTriviaWidth() + child.width(); + }; + + PositionedElement.prototype.getPositionedChild = function (child) { + var offset = TypeScript.Syntax.childOffset(this.element(), child); + return PositionedElement.create(this, child, this.fullStart() + offset); + }; + + PositionedElement.prototype.fullStart = function () { + return this._fullStart; + }; + + PositionedElement.prototype.fullEnd = function () { + return this.fullStart() + this.element().fullWidth(); + }; + + PositionedElement.prototype.fullWidth = function () { + return this.element().fullWidth(); + }; + + PositionedElement.prototype.start = function () { + return this.fullStart() + this.element().leadingTriviaWidth(); + }; + + PositionedElement.prototype.end = function () { + return this.fullStart() + this.element().leadingTriviaWidth() + this.element().width(); + }; + + PositionedElement.prototype.root = function () { + var current = this; + while (current.parent() !== null) { + current = current.parent(); + } + + return current; + }; + + PositionedElement.prototype.containingNode = function () { + var current = this.parent(); + + while (current !== null && !current.element().isNode()) { + current = current.parent(); + } + + return current; + }; + return PositionedElement; + })(); + TypeScript.PositionedElement = PositionedElement; + + var PositionedNodeOrToken = (function (_super) { + __extends(PositionedNodeOrToken, _super); + function PositionedNodeOrToken(parent, nodeOrToken, fullStart) { + _super.call(this, parent, nodeOrToken, fullStart); + } + PositionedNodeOrToken.prototype.nodeOrToken = function () { + return this.element(); + }; + return PositionedNodeOrToken; + })(PositionedElement); + TypeScript.PositionedNodeOrToken = PositionedNodeOrToken; + + var PositionedNode = (function (_super) { + __extends(PositionedNode, _super); + function PositionedNode(parent, node, fullStart) { + _super.call(this, parent, node, fullStart); + } + PositionedNode.prototype.node = function () { + return this.element(); + }; + return PositionedNode; + })(PositionedNodeOrToken); + TypeScript.PositionedNode = PositionedNode; + + var PositionedToken = (function (_super) { + __extends(PositionedToken, _super); + function PositionedToken(parent, token, fullStart) { + _super.call(this, parent, token, fullStart); + } + PositionedToken.prototype.token = function () { + return this.element(); + }; + + PositionedToken.prototype.previousToken = function (includeSkippedTokens) { + if (typeof includeSkippedTokens === "undefined") { includeSkippedTokens = false; } + var triviaList = this.token().leadingTrivia(); + if (includeSkippedTokens && triviaList && triviaList.hasSkippedToken()) { + var currentTriviaEndPosition = this.start(); + for (var i = triviaList.count() - 1; i >= 0; i--) { + var trivia = triviaList.syntaxTriviaAt(i); + if (trivia.isSkippedToken()) { + return new PositionedSkippedToken(this, trivia.skippedToken(), currentTriviaEndPosition - trivia.fullWidth()); + } + + currentTriviaEndPosition -= trivia.fullWidth(); + } + } + + var start = this.fullStart(); + if (start === 0) { + return null; + } + + return this.root().node().findToken(start - 1, includeSkippedTokens); + }; + + PositionedToken.prototype.nextToken = function (includeSkippedTokens) { + if (typeof includeSkippedTokens === "undefined") { includeSkippedTokens = false; } + if (this.token().tokenKind === 10 /* EndOfFileToken */) { + return null; + } + + var triviaList = this.token().trailingTrivia(); + if (includeSkippedTokens && triviaList && triviaList.hasSkippedToken()) { + var fullStart = this.end(); + for (var i = 0, n = triviaList.count(); i < n; i++) { + var trivia = triviaList.syntaxTriviaAt(i); + if (trivia.isSkippedToken()) { + return new PositionedSkippedToken(this, trivia.skippedToken(), fullStart); + } + + fullStart += trivia.fullWidth(); + } + } + + return this.root().node().findToken(this.fullEnd(), includeSkippedTokens); + }; + return PositionedToken; + })(PositionedNodeOrToken); + TypeScript.PositionedToken = PositionedToken; + + var PositionedList = (function (_super) { + __extends(PositionedList, _super); + function PositionedList(parent, list, fullStart) { + _super.call(this, parent, list, fullStart); + } + PositionedList.prototype.list = function () { + return this.element(); + }; + return PositionedList; + })(PositionedElement); + TypeScript.PositionedList = PositionedList; + + var PositionedSeparatedList = (function (_super) { + __extends(PositionedSeparatedList, _super); + function PositionedSeparatedList(parent, list, fullStart) { + _super.call(this, parent, list, fullStart); + } + PositionedSeparatedList.prototype.list = function () { + return this.element(); + }; + return PositionedSeparatedList; + })(PositionedElement); + TypeScript.PositionedSeparatedList = PositionedSeparatedList; + + var PositionedSkippedToken = (function (_super) { + __extends(PositionedSkippedToken, _super); + function PositionedSkippedToken(parentToken, token, fullStart) { + _super.call(this, parentToken.parent(), token, fullStart); + this._parentToken = parentToken; + } + PositionedSkippedToken.prototype.parentToken = function () { + return this._parentToken; + }; + + PositionedSkippedToken.prototype.previousToken = function (includeSkippedTokens) { + if (typeof includeSkippedTokens === "undefined") { includeSkippedTokens = false; } + var start = this.fullStart(); + + if (includeSkippedTokens) { + var previousToken; + + if (start >= this.parentToken().end()) { + previousToken = TypeScript.Syntax.findSkippedTokenInTrailingTriviaList(this.parentToken(), start - 1); + + if (previousToken) { + return previousToken; + } + + return this.parentToken(); + } else { + previousToken = TypeScript.Syntax.findSkippedTokenInLeadingTriviaList(this.parentToken(), start - 1); + + if (previousToken) { + return previousToken; + } + } + } + + var start = this.parentToken().fullStart(); + if (start === 0) { + return null; + } + + return this.root().node().findToken(start - 1, includeSkippedTokens); + }; + + PositionedSkippedToken.prototype.nextToken = function (includeSkippedTokens) { + if (typeof includeSkippedTokens === "undefined") { includeSkippedTokens = false; } + if (this.token().tokenKind === 10 /* EndOfFileToken */) { + return null; + } + + if (includeSkippedTokens) { + var end = this.end(); + var nextToken; + + if (end <= this.parentToken().start()) { + nextToken = TypeScript.Syntax.findSkippedTokenInLeadingTriviaList(this.parentToken(), end); + + if (nextToken) { + return nextToken; + } + + return this.parentToken(); + } else { + nextToken = TypeScript.Syntax.findSkippedTokenInTrailingTriviaList(this.parentToken(), end); + + if (nextToken) { + return nextToken; + } + } + } + + return this.root().node().findToken(this.parentToken().fullEnd(), includeSkippedTokens); + }; + return PositionedSkippedToken; + })(PositionedToken); + TypeScript.PositionedSkippedToken = PositionedSkippedToken; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (SyntaxKind) { + SyntaxKind[SyntaxKind["None"] = 0] = "None"; + SyntaxKind[SyntaxKind["List"] = 1] = "List"; + SyntaxKind[SyntaxKind["SeparatedList"] = 2] = "SeparatedList"; + SyntaxKind[SyntaxKind["TriviaList"] = 3] = "TriviaList"; + + SyntaxKind[SyntaxKind["WhitespaceTrivia"] = 4] = "WhitespaceTrivia"; + SyntaxKind[SyntaxKind["NewLineTrivia"] = 5] = "NewLineTrivia"; + SyntaxKind[SyntaxKind["MultiLineCommentTrivia"] = 6] = "MultiLineCommentTrivia"; + SyntaxKind[SyntaxKind["SingleLineCommentTrivia"] = 7] = "SingleLineCommentTrivia"; + SyntaxKind[SyntaxKind["SkippedTokenTrivia"] = 8] = "SkippedTokenTrivia"; + + SyntaxKind[SyntaxKind["ErrorToken"] = 9] = "ErrorToken"; + SyntaxKind[SyntaxKind["EndOfFileToken"] = 10] = "EndOfFileToken"; + + SyntaxKind[SyntaxKind["IdentifierName"] = 11] = "IdentifierName"; + + SyntaxKind[SyntaxKind["RegularExpressionLiteral"] = 12] = "RegularExpressionLiteral"; + SyntaxKind[SyntaxKind["NumericLiteral"] = 13] = "NumericLiteral"; + SyntaxKind[SyntaxKind["StringLiteral"] = 14] = "StringLiteral"; + + SyntaxKind[SyntaxKind["BreakKeyword"] = 15] = "BreakKeyword"; + SyntaxKind[SyntaxKind["CaseKeyword"] = 16] = "CaseKeyword"; + SyntaxKind[SyntaxKind["CatchKeyword"] = 17] = "CatchKeyword"; + SyntaxKind[SyntaxKind["ContinueKeyword"] = 18] = "ContinueKeyword"; + SyntaxKind[SyntaxKind["DebuggerKeyword"] = 19] = "DebuggerKeyword"; + SyntaxKind[SyntaxKind["DefaultKeyword"] = 20] = "DefaultKeyword"; + SyntaxKind[SyntaxKind["DeleteKeyword"] = 21] = "DeleteKeyword"; + SyntaxKind[SyntaxKind["DoKeyword"] = 22] = "DoKeyword"; + SyntaxKind[SyntaxKind["ElseKeyword"] = 23] = "ElseKeyword"; + SyntaxKind[SyntaxKind["FalseKeyword"] = 24] = "FalseKeyword"; + SyntaxKind[SyntaxKind["FinallyKeyword"] = 25] = "FinallyKeyword"; + SyntaxKind[SyntaxKind["ForKeyword"] = 26] = "ForKeyword"; + SyntaxKind[SyntaxKind["FunctionKeyword"] = 27] = "FunctionKeyword"; + SyntaxKind[SyntaxKind["IfKeyword"] = 28] = "IfKeyword"; + SyntaxKind[SyntaxKind["InKeyword"] = 29] = "InKeyword"; + SyntaxKind[SyntaxKind["InstanceOfKeyword"] = 30] = "InstanceOfKeyword"; + SyntaxKind[SyntaxKind["NewKeyword"] = 31] = "NewKeyword"; + SyntaxKind[SyntaxKind["NullKeyword"] = 32] = "NullKeyword"; + SyntaxKind[SyntaxKind["ReturnKeyword"] = 33] = "ReturnKeyword"; + SyntaxKind[SyntaxKind["SwitchKeyword"] = 34] = "SwitchKeyword"; + SyntaxKind[SyntaxKind["ThisKeyword"] = 35] = "ThisKeyword"; + SyntaxKind[SyntaxKind["ThrowKeyword"] = 36] = "ThrowKeyword"; + SyntaxKind[SyntaxKind["TrueKeyword"] = 37] = "TrueKeyword"; + SyntaxKind[SyntaxKind["TryKeyword"] = 38] = "TryKeyword"; + SyntaxKind[SyntaxKind["TypeOfKeyword"] = 39] = "TypeOfKeyword"; + SyntaxKind[SyntaxKind["VarKeyword"] = 40] = "VarKeyword"; + SyntaxKind[SyntaxKind["VoidKeyword"] = 41] = "VoidKeyword"; + SyntaxKind[SyntaxKind["WhileKeyword"] = 42] = "WhileKeyword"; + SyntaxKind[SyntaxKind["WithKeyword"] = 43] = "WithKeyword"; + + SyntaxKind[SyntaxKind["ClassKeyword"] = 44] = "ClassKeyword"; + SyntaxKind[SyntaxKind["ConstKeyword"] = 45] = "ConstKeyword"; + SyntaxKind[SyntaxKind["EnumKeyword"] = 46] = "EnumKeyword"; + SyntaxKind[SyntaxKind["ExportKeyword"] = 47] = "ExportKeyword"; + SyntaxKind[SyntaxKind["ExtendsKeyword"] = 48] = "ExtendsKeyword"; + SyntaxKind[SyntaxKind["ImportKeyword"] = 49] = "ImportKeyword"; + SyntaxKind[SyntaxKind["SuperKeyword"] = 50] = "SuperKeyword"; + + SyntaxKind[SyntaxKind["ImplementsKeyword"] = 51] = "ImplementsKeyword"; + SyntaxKind[SyntaxKind["InterfaceKeyword"] = 52] = "InterfaceKeyword"; + SyntaxKind[SyntaxKind["LetKeyword"] = 53] = "LetKeyword"; + SyntaxKind[SyntaxKind["PackageKeyword"] = 54] = "PackageKeyword"; + SyntaxKind[SyntaxKind["PrivateKeyword"] = 55] = "PrivateKeyword"; + SyntaxKind[SyntaxKind["ProtectedKeyword"] = 56] = "ProtectedKeyword"; + SyntaxKind[SyntaxKind["PublicKeyword"] = 57] = "PublicKeyword"; + SyntaxKind[SyntaxKind["StaticKeyword"] = 58] = "StaticKeyword"; + SyntaxKind[SyntaxKind["YieldKeyword"] = 59] = "YieldKeyword"; + + SyntaxKind[SyntaxKind["AnyKeyword"] = 60] = "AnyKeyword"; + SyntaxKind[SyntaxKind["BooleanKeyword"] = 61] = "BooleanKeyword"; + SyntaxKind[SyntaxKind["ConstructorKeyword"] = 62] = "ConstructorKeyword"; + SyntaxKind[SyntaxKind["DeclareKeyword"] = 63] = "DeclareKeyword"; + SyntaxKind[SyntaxKind["GetKeyword"] = 64] = "GetKeyword"; + SyntaxKind[SyntaxKind["ModuleKeyword"] = 65] = "ModuleKeyword"; + SyntaxKind[SyntaxKind["RequireKeyword"] = 66] = "RequireKeyword"; + SyntaxKind[SyntaxKind["NumberKeyword"] = 67] = "NumberKeyword"; + SyntaxKind[SyntaxKind["SetKeyword"] = 68] = "SetKeyword"; + SyntaxKind[SyntaxKind["StringKeyword"] = 69] = "StringKeyword"; + + SyntaxKind[SyntaxKind["OpenBraceToken"] = 70] = "OpenBraceToken"; + SyntaxKind[SyntaxKind["CloseBraceToken"] = 71] = "CloseBraceToken"; + SyntaxKind[SyntaxKind["OpenParenToken"] = 72] = "OpenParenToken"; + SyntaxKind[SyntaxKind["CloseParenToken"] = 73] = "CloseParenToken"; + SyntaxKind[SyntaxKind["OpenBracketToken"] = 74] = "OpenBracketToken"; + SyntaxKind[SyntaxKind["CloseBracketToken"] = 75] = "CloseBracketToken"; + SyntaxKind[SyntaxKind["DotToken"] = 76] = "DotToken"; + SyntaxKind[SyntaxKind["DotDotDotToken"] = 77] = "DotDotDotToken"; + SyntaxKind[SyntaxKind["SemicolonToken"] = 78] = "SemicolonToken"; + SyntaxKind[SyntaxKind["CommaToken"] = 79] = "CommaToken"; + SyntaxKind[SyntaxKind["LessThanToken"] = 80] = "LessThanToken"; + SyntaxKind[SyntaxKind["GreaterThanToken"] = 81] = "GreaterThanToken"; + SyntaxKind[SyntaxKind["LessThanEqualsToken"] = 82] = "LessThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanEqualsToken"] = 83] = "GreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["EqualsEqualsToken"] = 84] = "EqualsEqualsToken"; + SyntaxKind[SyntaxKind["EqualsGreaterThanToken"] = 85] = "EqualsGreaterThanToken"; + SyntaxKind[SyntaxKind["ExclamationEqualsToken"] = 86] = "ExclamationEqualsToken"; + SyntaxKind[SyntaxKind["EqualsEqualsEqualsToken"] = 87] = "EqualsEqualsEqualsToken"; + SyntaxKind[SyntaxKind["ExclamationEqualsEqualsToken"] = 88] = "ExclamationEqualsEqualsToken"; + SyntaxKind[SyntaxKind["PlusToken"] = 89] = "PlusToken"; + SyntaxKind[SyntaxKind["MinusToken"] = 90] = "MinusToken"; + SyntaxKind[SyntaxKind["AsteriskToken"] = 91] = "AsteriskToken"; + SyntaxKind[SyntaxKind["PercentToken"] = 92] = "PercentToken"; + SyntaxKind[SyntaxKind["PlusPlusToken"] = 93] = "PlusPlusToken"; + SyntaxKind[SyntaxKind["MinusMinusToken"] = 94] = "MinusMinusToken"; + SyntaxKind[SyntaxKind["LessThanLessThanToken"] = 95] = "LessThanLessThanToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanToken"] = 96] = "GreaterThanGreaterThanToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanToken"] = 97] = "GreaterThanGreaterThanGreaterThanToken"; + SyntaxKind[SyntaxKind["AmpersandToken"] = 98] = "AmpersandToken"; + SyntaxKind[SyntaxKind["BarToken"] = 99] = "BarToken"; + SyntaxKind[SyntaxKind["CaretToken"] = 100] = "CaretToken"; + SyntaxKind[SyntaxKind["ExclamationToken"] = 101] = "ExclamationToken"; + SyntaxKind[SyntaxKind["TildeToken"] = 102] = "TildeToken"; + SyntaxKind[SyntaxKind["AmpersandAmpersandToken"] = 103] = "AmpersandAmpersandToken"; + SyntaxKind[SyntaxKind["BarBarToken"] = 104] = "BarBarToken"; + SyntaxKind[SyntaxKind["QuestionToken"] = 105] = "QuestionToken"; + SyntaxKind[SyntaxKind["ColonToken"] = 106] = "ColonToken"; + SyntaxKind[SyntaxKind["EqualsToken"] = 107] = "EqualsToken"; + SyntaxKind[SyntaxKind["PlusEqualsToken"] = 108] = "PlusEqualsToken"; + SyntaxKind[SyntaxKind["MinusEqualsToken"] = 109] = "MinusEqualsToken"; + SyntaxKind[SyntaxKind["AsteriskEqualsToken"] = 110] = "AsteriskEqualsToken"; + SyntaxKind[SyntaxKind["PercentEqualsToken"] = 111] = "PercentEqualsToken"; + SyntaxKind[SyntaxKind["LessThanLessThanEqualsToken"] = 112] = "LessThanLessThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanEqualsToken"] = 113] = "GreaterThanGreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanEqualsToken"] = 114] = "GreaterThanGreaterThanGreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["AmpersandEqualsToken"] = 115] = "AmpersandEqualsToken"; + SyntaxKind[SyntaxKind["BarEqualsToken"] = 116] = "BarEqualsToken"; + SyntaxKind[SyntaxKind["CaretEqualsToken"] = 117] = "CaretEqualsToken"; + SyntaxKind[SyntaxKind["SlashToken"] = 118] = "SlashToken"; + SyntaxKind[SyntaxKind["SlashEqualsToken"] = 119] = "SlashEqualsToken"; + + SyntaxKind[SyntaxKind["SourceUnit"] = 120] = "SourceUnit"; + + SyntaxKind[SyntaxKind["QualifiedName"] = 121] = "QualifiedName"; + + SyntaxKind[SyntaxKind["ObjectType"] = 122] = "ObjectType"; + SyntaxKind[SyntaxKind["FunctionType"] = 123] = "FunctionType"; + SyntaxKind[SyntaxKind["ArrayType"] = 124] = "ArrayType"; + SyntaxKind[SyntaxKind["ConstructorType"] = 125] = "ConstructorType"; + SyntaxKind[SyntaxKind["GenericType"] = 126] = "GenericType"; + SyntaxKind[SyntaxKind["TypeQuery"] = 127] = "TypeQuery"; + + SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 128] = "InterfaceDeclaration"; + SyntaxKind[SyntaxKind["FunctionDeclaration"] = 129] = "FunctionDeclaration"; + SyntaxKind[SyntaxKind["ModuleDeclaration"] = 130] = "ModuleDeclaration"; + SyntaxKind[SyntaxKind["ClassDeclaration"] = 131] = "ClassDeclaration"; + SyntaxKind[SyntaxKind["EnumDeclaration"] = 132] = "EnumDeclaration"; + SyntaxKind[SyntaxKind["ImportDeclaration"] = 133] = "ImportDeclaration"; + SyntaxKind[SyntaxKind["ExportAssignment"] = 134] = "ExportAssignment"; + + SyntaxKind[SyntaxKind["MemberFunctionDeclaration"] = 135] = "MemberFunctionDeclaration"; + SyntaxKind[SyntaxKind["MemberVariableDeclaration"] = 136] = "MemberVariableDeclaration"; + SyntaxKind[SyntaxKind["ConstructorDeclaration"] = 137] = "ConstructorDeclaration"; + SyntaxKind[SyntaxKind["GetMemberAccessorDeclaration"] = 138] = "GetMemberAccessorDeclaration"; + SyntaxKind[SyntaxKind["SetMemberAccessorDeclaration"] = 139] = "SetMemberAccessorDeclaration"; + + SyntaxKind[SyntaxKind["PropertySignature"] = 140] = "PropertySignature"; + SyntaxKind[SyntaxKind["CallSignature"] = 141] = "CallSignature"; + SyntaxKind[SyntaxKind["ConstructSignature"] = 142] = "ConstructSignature"; + SyntaxKind[SyntaxKind["IndexSignature"] = 143] = "IndexSignature"; + SyntaxKind[SyntaxKind["MethodSignature"] = 144] = "MethodSignature"; + + SyntaxKind[SyntaxKind["Block"] = 145] = "Block"; + SyntaxKind[SyntaxKind["IfStatement"] = 146] = "IfStatement"; + SyntaxKind[SyntaxKind["VariableStatement"] = 147] = "VariableStatement"; + SyntaxKind[SyntaxKind["ExpressionStatement"] = 148] = "ExpressionStatement"; + SyntaxKind[SyntaxKind["ReturnStatement"] = 149] = "ReturnStatement"; + SyntaxKind[SyntaxKind["SwitchStatement"] = 150] = "SwitchStatement"; + SyntaxKind[SyntaxKind["BreakStatement"] = 151] = "BreakStatement"; + SyntaxKind[SyntaxKind["ContinueStatement"] = 152] = "ContinueStatement"; + SyntaxKind[SyntaxKind["ForStatement"] = 153] = "ForStatement"; + SyntaxKind[SyntaxKind["ForInStatement"] = 154] = "ForInStatement"; + SyntaxKind[SyntaxKind["EmptyStatement"] = 155] = "EmptyStatement"; + SyntaxKind[SyntaxKind["ThrowStatement"] = 156] = "ThrowStatement"; + SyntaxKind[SyntaxKind["WhileStatement"] = 157] = "WhileStatement"; + SyntaxKind[SyntaxKind["TryStatement"] = 158] = "TryStatement"; + SyntaxKind[SyntaxKind["LabeledStatement"] = 159] = "LabeledStatement"; + SyntaxKind[SyntaxKind["DoStatement"] = 160] = "DoStatement"; + SyntaxKind[SyntaxKind["DebuggerStatement"] = 161] = "DebuggerStatement"; + SyntaxKind[SyntaxKind["WithStatement"] = 162] = "WithStatement"; + + SyntaxKind[SyntaxKind["PlusExpression"] = 163] = "PlusExpression"; + SyntaxKind[SyntaxKind["NegateExpression"] = 164] = "NegateExpression"; + SyntaxKind[SyntaxKind["BitwiseNotExpression"] = 165] = "BitwiseNotExpression"; + SyntaxKind[SyntaxKind["LogicalNotExpression"] = 166] = "LogicalNotExpression"; + SyntaxKind[SyntaxKind["PreIncrementExpression"] = 167] = "PreIncrementExpression"; + SyntaxKind[SyntaxKind["PreDecrementExpression"] = 168] = "PreDecrementExpression"; + SyntaxKind[SyntaxKind["DeleteExpression"] = 169] = "DeleteExpression"; + SyntaxKind[SyntaxKind["TypeOfExpression"] = 170] = "TypeOfExpression"; + SyntaxKind[SyntaxKind["VoidExpression"] = 171] = "VoidExpression"; + SyntaxKind[SyntaxKind["CommaExpression"] = 172] = "CommaExpression"; + SyntaxKind[SyntaxKind["AssignmentExpression"] = 173] = "AssignmentExpression"; + SyntaxKind[SyntaxKind["AddAssignmentExpression"] = 174] = "AddAssignmentExpression"; + SyntaxKind[SyntaxKind["SubtractAssignmentExpression"] = 175] = "SubtractAssignmentExpression"; + SyntaxKind[SyntaxKind["MultiplyAssignmentExpression"] = 176] = "MultiplyAssignmentExpression"; + SyntaxKind[SyntaxKind["DivideAssignmentExpression"] = 177] = "DivideAssignmentExpression"; + SyntaxKind[SyntaxKind["ModuloAssignmentExpression"] = 178] = "ModuloAssignmentExpression"; + SyntaxKind[SyntaxKind["AndAssignmentExpression"] = 179] = "AndAssignmentExpression"; + SyntaxKind[SyntaxKind["ExclusiveOrAssignmentExpression"] = 180] = "ExclusiveOrAssignmentExpression"; + SyntaxKind[SyntaxKind["OrAssignmentExpression"] = 181] = "OrAssignmentExpression"; + SyntaxKind[SyntaxKind["LeftShiftAssignmentExpression"] = 182] = "LeftShiftAssignmentExpression"; + SyntaxKind[SyntaxKind["SignedRightShiftAssignmentExpression"] = 183] = "SignedRightShiftAssignmentExpression"; + SyntaxKind[SyntaxKind["UnsignedRightShiftAssignmentExpression"] = 184] = "UnsignedRightShiftAssignmentExpression"; + SyntaxKind[SyntaxKind["ConditionalExpression"] = 185] = "ConditionalExpression"; + SyntaxKind[SyntaxKind["LogicalOrExpression"] = 186] = "LogicalOrExpression"; + SyntaxKind[SyntaxKind["LogicalAndExpression"] = 187] = "LogicalAndExpression"; + SyntaxKind[SyntaxKind["BitwiseOrExpression"] = 188] = "BitwiseOrExpression"; + SyntaxKind[SyntaxKind["BitwiseExclusiveOrExpression"] = 189] = "BitwiseExclusiveOrExpression"; + SyntaxKind[SyntaxKind["BitwiseAndExpression"] = 190] = "BitwiseAndExpression"; + SyntaxKind[SyntaxKind["EqualsWithTypeConversionExpression"] = 191] = "EqualsWithTypeConversionExpression"; + SyntaxKind[SyntaxKind["NotEqualsWithTypeConversionExpression"] = 192] = "NotEqualsWithTypeConversionExpression"; + SyntaxKind[SyntaxKind["EqualsExpression"] = 193] = "EqualsExpression"; + SyntaxKind[SyntaxKind["NotEqualsExpression"] = 194] = "NotEqualsExpression"; + SyntaxKind[SyntaxKind["LessThanExpression"] = 195] = "LessThanExpression"; + SyntaxKind[SyntaxKind["GreaterThanExpression"] = 196] = "GreaterThanExpression"; + SyntaxKind[SyntaxKind["LessThanOrEqualExpression"] = 197] = "LessThanOrEqualExpression"; + SyntaxKind[SyntaxKind["GreaterThanOrEqualExpression"] = 198] = "GreaterThanOrEqualExpression"; + SyntaxKind[SyntaxKind["InstanceOfExpression"] = 199] = "InstanceOfExpression"; + SyntaxKind[SyntaxKind["InExpression"] = 200] = "InExpression"; + SyntaxKind[SyntaxKind["LeftShiftExpression"] = 201] = "LeftShiftExpression"; + SyntaxKind[SyntaxKind["SignedRightShiftExpression"] = 202] = "SignedRightShiftExpression"; + SyntaxKind[SyntaxKind["UnsignedRightShiftExpression"] = 203] = "UnsignedRightShiftExpression"; + SyntaxKind[SyntaxKind["MultiplyExpression"] = 204] = "MultiplyExpression"; + SyntaxKind[SyntaxKind["DivideExpression"] = 205] = "DivideExpression"; + SyntaxKind[SyntaxKind["ModuloExpression"] = 206] = "ModuloExpression"; + SyntaxKind[SyntaxKind["AddExpression"] = 207] = "AddExpression"; + SyntaxKind[SyntaxKind["SubtractExpression"] = 208] = "SubtractExpression"; + SyntaxKind[SyntaxKind["PostIncrementExpression"] = 209] = "PostIncrementExpression"; + SyntaxKind[SyntaxKind["PostDecrementExpression"] = 210] = "PostDecrementExpression"; + SyntaxKind[SyntaxKind["MemberAccessExpression"] = 211] = "MemberAccessExpression"; + SyntaxKind[SyntaxKind["InvocationExpression"] = 212] = "InvocationExpression"; + SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 213] = "ArrayLiteralExpression"; + SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 214] = "ObjectLiteralExpression"; + SyntaxKind[SyntaxKind["ObjectCreationExpression"] = 215] = "ObjectCreationExpression"; + SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 216] = "ParenthesizedExpression"; + SyntaxKind[SyntaxKind["ParenthesizedArrowFunctionExpression"] = 217] = "ParenthesizedArrowFunctionExpression"; + SyntaxKind[SyntaxKind["SimpleArrowFunctionExpression"] = 218] = "SimpleArrowFunctionExpression"; + SyntaxKind[SyntaxKind["CastExpression"] = 219] = "CastExpression"; + SyntaxKind[SyntaxKind["ElementAccessExpression"] = 220] = "ElementAccessExpression"; + SyntaxKind[SyntaxKind["FunctionExpression"] = 221] = "FunctionExpression"; + SyntaxKind[SyntaxKind["OmittedExpression"] = 222] = "OmittedExpression"; + + SyntaxKind[SyntaxKind["VariableDeclaration"] = 223] = "VariableDeclaration"; + SyntaxKind[SyntaxKind["VariableDeclarator"] = 224] = "VariableDeclarator"; + + SyntaxKind[SyntaxKind["ArgumentList"] = 225] = "ArgumentList"; + SyntaxKind[SyntaxKind["ParameterList"] = 226] = "ParameterList"; + SyntaxKind[SyntaxKind["TypeArgumentList"] = 227] = "TypeArgumentList"; + SyntaxKind[SyntaxKind["TypeParameterList"] = 228] = "TypeParameterList"; + + SyntaxKind[SyntaxKind["HeritageClause"] = 229] = "HeritageClause"; + SyntaxKind[SyntaxKind["EqualsValueClause"] = 230] = "EqualsValueClause"; + SyntaxKind[SyntaxKind["CaseSwitchClause"] = 231] = "CaseSwitchClause"; + SyntaxKind[SyntaxKind["DefaultSwitchClause"] = 232] = "DefaultSwitchClause"; + SyntaxKind[SyntaxKind["ElseClause"] = 233] = "ElseClause"; + SyntaxKind[SyntaxKind["CatchClause"] = 234] = "CatchClause"; + SyntaxKind[SyntaxKind["FinallyClause"] = 235] = "FinallyClause"; + + SyntaxKind[SyntaxKind["TypeParameter"] = 236] = "TypeParameter"; + SyntaxKind[SyntaxKind["Constraint"] = 237] = "Constraint"; + + SyntaxKind[SyntaxKind["SimplePropertyAssignment"] = 238] = "SimplePropertyAssignment"; + SyntaxKind[SyntaxKind["GetAccessorPropertyAssignment"] = 239] = "GetAccessorPropertyAssignment"; + SyntaxKind[SyntaxKind["SetAccessorPropertyAssignment"] = 240] = "SetAccessorPropertyAssignment"; + SyntaxKind[SyntaxKind["FunctionPropertyAssignment"] = 241] = "FunctionPropertyAssignment"; + + SyntaxKind[SyntaxKind["Parameter"] = 242] = "Parameter"; + SyntaxKind[SyntaxKind["EnumElement"] = 243] = "EnumElement"; + SyntaxKind[SyntaxKind["TypeAnnotation"] = 244] = "TypeAnnotation"; + SyntaxKind[SyntaxKind["ExternalModuleReference"] = 245] = "ExternalModuleReference"; + SyntaxKind[SyntaxKind["ModuleNameModuleReference"] = 246] = "ModuleNameModuleReference"; + + SyntaxKind[SyntaxKind["FirstStandardKeyword"] = SyntaxKind.BreakKeyword] = "FirstStandardKeyword"; + SyntaxKind[SyntaxKind["LastStandardKeyword"] = SyntaxKind.WithKeyword] = "LastStandardKeyword"; + + SyntaxKind[SyntaxKind["FirstFutureReservedKeyword"] = SyntaxKind.ClassKeyword] = "FirstFutureReservedKeyword"; + SyntaxKind[SyntaxKind["LastFutureReservedKeyword"] = SyntaxKind.SuperKeyword] = "LastFutureReservedKeyword"; + + SyntaxKind[SyntaxKind["FirstFutureReservedStrictKeyword"] = SyntaxKind.ImplementsKeyword] = "FirstFutureReservedStrictKeyword"; + SyntaxKind[SyntaxKind["LastFutureReservedStrictKeyword"] = SyntaxKind.YieldKeyword] = "LastFutureReservedStrictKeyword"; + + SyntaxKind[SyntaxKind["FirstTypeScriptKeyword"] = SyntaxKind.AnyKeyword] = "FirstTypeScriptKeyword"; + SyntaxKind[SyntaxKind["LastTypeScriptKeyword"] = SyntaxKind.StringKeyword] = "LastTypeScriptKeyword"; + + SyntaxKind[SyntaxKind["FirstKeyword"] = SyntaxKind.FirstStandardKeyword] = "FirstKeyword"; + SyntaxKind[SyntaxKind["LastKeyword"] = SyntaxKind.LastTypeScriptKeyword] = "LastKeyword"; + + SyntaxKind[SyntaxKind["FirstToken"] = SyntaxKind.ErrorToken] = "FirstToken"; + SyntaxKind[SyntaxKind["LastToken"] = SyntaxKind.SlashEqualsToken] = "LastToken"; + + SyntaxKind[SyntaxKind["FirstPunctuation"] = SyntaxKind.OpenBraceToken] = "FirstPunctuation"; + SyntaxKind[SyntaxKind["LastPunctuation"] = SyntaxKind.SlashEqualsToken] = "LastPunctuation"; + + SyntaxKind[SyntaxKind["FirstFixedWidth"] = SyntaxKind.FirstKeyword] = "FirstFixedWidth"; + SyntaxKind[SyntaxKind["LastFixedWidth"] = SyntaxKind.LastPunctuation] = "LastFixedWidth"; + })(TypeScript.SyntaxKind || (TypeScript.SyntaxKind = {})); + var SyntaxKind = TypeScript.SyntaxKind; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (SyntaxFacts) { + var textToKeywordKind = { + "any": 60 /* AnyKeyword */, + "boolean": 61 /* BooleanKeyword */, + "break": 15 /* BreakKeyword */, + "case": 16 /* CaseKeyword */, + "catch": 17 /* CatchKeyword */, + "class": 44 /* ClassKeyword */, + "continue": 18 /* ContinueKeyword */, + "const": 45 /* ConstKeyword */, + "constructor": 62 /* ConstructorKeyword */, + "debugger": 19 /* DebuggerKeyword */, + "declare": 63 /* DeclareKeyword */, + "default": 20 /* DefaultKeyword */, + "delete": 21 /* DeleteKeyword */, + "do": 22 /* DoKeyword */, + "else": 23 /* ElseKeyword */, + "enum": 46 /* EnumKeyword */, + "export": 47 /* ExportKeyword */, + "extends": 48 /* ExtendsKeyword */, + "false": 24 /* FalseKeyword */, + "finally": 25 /* FinallyKeyword */, + "for": 26 /* ForKeyword */, + "function": 27 /* FunctionKeyword */, + "get": 64 /* GetKeyword */, + "if": 28 /* IfKeyword */, + "implements": 51 /* ImplementsKeyword */, + "import": 49 /* ImportKeyword */, + "in": 29 /* InKeyword */, + "instanceof": 30 /* InstanceOfKeyword */, + "interface": 52 /* InterfaceKeyword */, + "let": 53 /* LetKeyword */, + "module": 65 /* ModuleKeyword */, + "new": 31 /* NewKeyword */, + "null": 32 /* NullKeyword */, + "number": 67 /* NumberKeyword */, + "package": 54 /* PackageKeyword */, + "private": 55 /* PrivateKeyword */, + "protected": 56 /* ProtectedKeyword */, + "public": 57 /* PublicKeyword */, + "require": 66 /* RequireKeyword */, + "return": 33 /* ReturnKeyword */, + "set": 68 /* SetKeyword */, + "static": 58 /* StaticKeyword */, + "string": 69 /* StringKeyword */, + "super": 50 /* SuperKeyword */, + "switch": 34 /* SwitchKeyword */, + "this": 35 /* ThisKeyword */, + "throw": 36 /* ThrowKeyword */, + "true": 37 /* TrueKeyword */, + "try": 38 /* TryKeyword */, + "typeof": 39 /* TypeOfKeyword */, + "var": 40 /* VarKeyword */, + "void": 41 /* VoidKeyword */, + "while": 42 /* WhileKeyword */, + "with": 43 /* WithKeyword */, + "yield": 59 /* YieldKeyword */, + "{": 70 /* OpenBraceToken */, + "}": 71 /* CloseBraceToken */, + "(": 72 /* OpenParenToken */, + ")": 73 /* CloseParenToken */, + "[": 74 /* OpenBracketToken */, + "]": 75 /* CloseBracketToken */, + ".": 76 /* DotToken */, + "...": 77 /* DotDotDotToken */, + ";": 78 /* SemicolonToken */, + ",": 79 /* CommaToken */, + "<": 80 /* LessThanToken */, + ">": 81 /* GreaterThanToken */, + "<=": 82 /* LessThanEqualsToken */, + ">=": 83 /* GreaterThanEqualsToken */, + "==": 84 /* EqualsEqualsToken */, + "=>": 85 /* EqualsGreaterThanToken */, + "!=": 86 /* ExclamationEqualsToken */, + "===": 87 /* EqualsEqualsEqualsToken */, + "!==": 88 /* ExclamationEqualsEqualsToken */, + "+": 89 /* PlusToken */, + "-": 90 /* MinusToken */, + "*": 91 /* AsteriskToken */, + "%": 92 /* PercentToken */, + "++": 93 /* PlusPlusToken */, + "--": 94 /* MinusMinusToken */, + "<<": 95 /* LessThanLessThanToken */, + ">>": 96 /* GreaterThanGreaterThanToken */, + ">>>": 97 /* GreaterThanGreaterThanGreaterThanToken */, + "&": 98 /* AmpersandToken */, + "|": 99 /* BarToken */, + "^": 100 /* CaretToken */, + "!": 101 /* ExclamationToken */, + "~": 102 /* TildeToken */, + "&&": 103 /* AmpersandAmpersandToken */, + "||": 104 /* BarBarToken */, + "?": 105 /* QuestionToken */, + ":": 106 /* ColonToken */, + "=": 107 /* EqualsToken */, + "+=": 108 /* PlusEqualsToken */, + "-=": 109 /* MinusEqualsToken */, + "*=": 110 /* AsteriskEqualsToken */, + "%=": 111 /* PercentEqualsToken */, + "<<=": 112 /* LessThanLessThanEqualsToken */, + ">>=": 113 /* GreaterThanGreaterThanEqualsToken */, + ">>>=": 114 /* GreaterThanGreaterThanGreaterThanEqualsToken */, + "&=": 115 /* AmpersandEqualsToken */, + "|=": 116 /* BarEqualsToken */, + "^=": 117 /* CaretEqualsToken */, + "/": 118 /* SlashToken */, + "/=": 119 /* SlashEqualsToken */ + }; + + var kindToText = new Array(); + + for (var name in textToKeywordKind) { + if (textToKeywordKind.hasOwnProperty(name)) { + kindToText[textToKeywordKind[name]] = name; + } + } + + kindToText[62 /* ConstructorKeyword */] = "constructor"; + + function getTokenKind(text) { + if (textToKeywordKind.hasOwnProperty(text)) { + return textToKeywordKind[text]; + } + + return 0 /* None */; + } + SyntaxFacts.getTokenKind = getTokenKind; + + function getText(kind) { + var result = kindToText[kind]; + return result !== undefined ? result : null; + } + SyntaxFacts.getText = getText; + + function isTokenKind(kind) { + return kind >= 9 /* FirstToken */ && kind <= 119 /* LastToken */; + } + SyntaxFacts.isTokenKind = isTokenKind; + + function isAnyKeyword(kind) { + return kind >= 15 /* FirstKeyword */ && kind <= 69 /* LastKeyword */; + } + SyntaxFacts.isAnyKeyword = isAnyKeyword; + + function isStandardKeyword(kind) { + return kind >= 15 /* FirstStandardKeyword */ && kind <= 43 /* LastStandardKeyword */; + } + SyntaxFacts.isStandardKeyword = isStandardKeyword; + + function isFutureReservedKeyword(kind) { + return kind >= 44 /* FirstFutureReservedKeyword */ && kind <= 50 /* LastFutureReservedKeyword */; + } + SyntaxFacts.isFutureReservedKeyword = isFutureReservedKeyword; + + function isFutureReservedStrictKeyword(kind) { + return kind >= 51 /* FirstFutureReservedStrictKeyword */ && kind <= 59 /* LastFutureReservedStrictKeyword */; + } + SyntaxFacts.isFutureReservedStrictKeyword = isFutureReservedStrictKeyword; + + function isAnyPunctuation(kind) { + return kind >= 70 /* FirstPunctuation */ && kind <= 119 /* LastPunctuation */; + } + SyntaxFacts.isAnyPunctuation = isAnyPunctuation; + + function isPrefixUnaryExpressionOperatorToken(tokenKind) { + return getPrefixUnaryExpressionFromOperatorToken(tokenKind) !== 0 /* None */; + } + SyntaxFacts.isPrefixUnaryExpressionOperatorToken = isPrefixUnaryExpressionOperatorToken; + + function isBinaryExpressionOperatorToken(tokenKind) { + return getBinaryExpressionFromOperatorToken(tokenKind) !== 0 /* None */; + } + SyntaxFacts.isBinaryExpressionOperatorToken = isBinaryExpressionOperatorToken; + + function getPrefixUnaryExpressionFromOperatorToken(tokenKind) { + switch (tokenKind) { + case 89 /* PlusToken */: + return 163 /* PlusExpression */; + case 90 /* MinusToken */: + return 164 /* NegateExpression */; + case 102 /* TildeToken */: + return 165 /* BitwiseNotExpression */; + case 101 /* ExclamationToken */: + return 166 /* LogicalNotExpression */; + case 93 /* PlusPlusToken */: + return 167 /* PreIncrementExpression */; + case 94 /* MinusMinusToken */: + return 168 /* PreDecrementExpression */; + + default: + return 0 /* None */; + } + } + SyntaxFacts.getPrefixUnaryExpressionFromOperatorToken = getPrefixUnaryExpressionFromOperatorToken; + + function getPostfixUnaryExpressionFromOperatorToken(tokenKind) { + switch (tokenKind) { + case 93 /* PlusPlusToken */: + return 209 /* PostIncrementExpression */; + case 94 /* MinusMinusToken */: + return 210 /* PostDecrementExpression */; + default: + return 0 /* None */; + } + } + SyntaxFacts.getPostfixUnaryExpressionFromOperatorToken = getPostfixUnaryExpressionFromOperatorToken; + + function getBinaryExpressionFromOperatorToken(tokenKind) { + switch (tokenKind) { + case 91 /* AsteriskToken */: + return 204 /* MultiplyExpression */; + + case 118 /* SlashToken */: + return 205 /* DivideExpression */; + + case 92 /* PercentToken */: + return 206 /* ModuloExpression */; + + case 89 /* PlusToken */: + return 207 /* AddExpression */; + + case 90 /* MinusToken */: + return 208 /* SubtractExpression */; + + case 95 /* LessThanLessThanToken */: + return 201 /* LeftShiftExpression */; + + case 96 /* GreaterThanGreaterThanToken */: + return 202 /* SignedRightShiftExpression */; + + case 97 /* GreaterThanGreaterThanGreaterThanToken */: + return 203 /* UnsignedRightShiftExpression */; + + case 80 /* LessThanToken */: + return 195 /* LessThanExpression */; + + case 81 /* GreaterThanToken */: + return 196 /* GreaterThanExpression */; + + case 82 /* LessThanEqualsToken */: + return 197 /* LessThanOrEqualExpression */; + + case 83 /* GreaterThanEqualsToken */: + return 198 /* GreaterThanOrEqualExpression */; + + case 30 /* InstanceOfKeyword */: + return 199 /* InstanceOfExpression */; + + case 29 /* InKeyword */: + return 200 /* InExpression */; + + case 84 /* EqualsEqualsToken */: + return 191 /* EqualsWithTypeConversionExpression */; + + case 86 /* ExclamationEqualsToken */: + return 192 /* NotEqualsWithTypeConversionExpression */; + + case 87 /* EqualsEqualsEqualsToken */: + return 193 /* EqualsExpression */; + + case 88 /* ExclamationEqualsEqualsToken */: + return 194 /* NotEqualsExpression */; + + case 98 /* AmpersandToken */: + return 190 /* BitwiseAndExpression */; + + case 100 /* CaretToken */: + return 189 /* BitwiseExclusiveOrExpression */; + + case 99 /* BarToken */: + return 188 /* BitwiseOrExpression */; + + case 103 /* AmpersandAmpersandToken */: + return 187 /* LogicalAndExpression */; + + case 104 /* BarBarToken */: + return 186 /* LogicalOrExpression */; + + case 116 /* BarEqualsToken */: + return 181 /* OrAssignmentExpression */; + + case 115 /* AmpersandEqualsToken */: + return 179 /* AndAssignmentExpression */; + + case 117 /* CaretEqualsToken */: + return 180 /* ExclusiveOrAssignmentExpression */; + + case 112 /* LessThanLessThanEqualsToken */: + return 182 /* LeftShiftAssignmentExpression */; + + case 113 /* GreaterThanGreaterThanEqualsToken */: + return 183 /* SignedRightShiftAssignmentExpression */; + + case 114 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + return 184 /* UnsignedRightShiftAssignmentExpression */; + + case 108 /* PlusEqualsToken */: + return 174 /* AddAssignmentExpression */; + + case 109 /* MinusEqualsToken */: + return 175 /* SubtractAssignmentExpression */; + + case 110 /* AsteriskEqualsToken */: + return 176 /* MultiplyAssignmentExpression */; + + case 119 /* SlashEqualsToken */: + return 177 /* DivideAssignmentExpression */; + + case 111 /* PercentEqualsToken */: + return 178 /* ModuloAssignmentExpression */; + + case 107 /* EqualsToken */: + return 173 /* AssignmentExpression */; + + case 79 /* CommaToken */: + return 172 /* CommaExpression */; + + default: + return 0 /* None */; + } + } + SyntaxFacts.getBinaryExpressionFromOperatorToken = getBinaryExpressionFromOperatorToken; + + function isAnyDivideToken(kind) { + switch (kind) { + case 118 /* SlashToken */: + case 119 /* SlashEqualsToken */: + return true; + default: + return false; + } + } + SyntaxFacts.isAnyDivideToken = isAnyDivideToken; + + function isAnyDivideOrRegularExpressionToken(kind) { + switch (kind) { + case 118 /* SlashToken */: + case 119 /* SlashEqualsToken */: + case 12 /* RegularExpressionLiteral */: + return true; + default: + return false; + } + } + SyntaxFacts.isAnyDivideOrRegularExpressionToken = isAnyDivideOrRegularExpressionToken; + + function isParserGenerated(kind) { + switch (kind) { + case 96 /* GreaterThanGreaterThanToken */: + case 97 /* GreaterThanGreaterThanGreaterThanToken */: + case 83 /* GreaterThanEqualsToken */: + case 113 /* GreaterThanGreaterThanEqualsToken */: + case 114 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + return true; + default: + return false; + } + } + SyntaxFacts.isParserGenerated = isParserGenerated; + + function isAnyBinaryExpression(kind) { + switch (kind) { + case 172 /* CommaExpression */: + case 173 /* AssignmentExpression */: + case 174 /* AddAssignmentExpression */: + case 175 /* SubtractAssignmentExpression */: + case 176 /* MultiplyAssignmentExpression */: + case 177 /* DivideAssignmentExpression */: + case 178 /* ModuloAssignmentExpression */: + case 179 /* AndAssignmentExpression */: + case 180 /* ExclusiveOrAssignmentExpression */: + case 181 /* OrAssignmentExpression */: + case 182 /* LeftShiftAssignmentExpression */: + case 183 /* SignedRightShiftAssignmentExpression */: + case 184 /* UnsignedRightShiftAssignmentExpression */: + case 186 /* LogicalOrExpression */: + case 187 /* LogicalAndExpression */: + case 188 /* BitwiseOrExpression */: + case 189 /* BitwiseExclusiveOrExpression */: + case 190 /* BitwiseAndExpression */: + case 191 /* EqualsWithTypeConversionExpression */: + case 192 /* NotEqualsWithTypeConversionExpression */: + case 193 /* EqualsExpression */: + case 194 /* NotEqualsExpression */: + case 195 /* LessThanExpression */: + case 196 /* GreaterThanExpression */: + case 197 /* LessThanOrEqualExpression */: + case 198 /* GreaterThanOrEqualExpression */: + case 199 /* InstanceOfExpression */: + case 200 /* InExpression */: + case 201 /* LeftShiftExpression */: + case 202 /* SignedRightShiftExpression */: + case 203 /* UnsignedRightShiftExpression */: + case 204 /* MultiplyExpression */: + case 205 /* DivideExpression */: + case 206 /* ModuloExpression */: + case 207 /* AddExpression */: + case 208 /* SubtractExpression */: + return true; + } + + return false; + } + SyntaxFacts.isAnyBinaryExpression = isAnyBinaryExpression; + })(TypeScript.SyntaxFacts || (TypeScript.SyntaxFacts = {})); + var SyntaxFacts = TypeScript.SyntaxFacts; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var isKeywordStartCharacter = TypeScript.ArrayUtilities.createArray(127 /* maxAsciiCharacter */, false); + var isIdentifierStartCharacter = TypeScript.ArrayUtilities.createArray(127 /* maxAsciiCharacter */, false); + var isIdentifierPartCharacter = TypeScript.ArrayUtilities.createArray(127 /* maxAsciiCharacter */, false); + var isNumericLiteralStart = TypeScript.ArrayUtilities.createArray(127 /* maxAsciiCharacter */, false); + + for (var character = 0; character < 127 /* maxAsciiCharacter */; character++) { + if (character >= 97 /* a */ && character <= 122 /* z */) { + isIdentifierStartCharacter[character] = true; + isIdentifierPartCharacter[character] = true; + } else if ((character >= 65 /* A */ && character <= 90 /* Z */) || character === 95 /* _ */ || character === 36 /* $ */) { + isIdentifierStartCharacter[character] = true; + isIdentifierPartCharacter[character] = true; + } else if (character >= 48 /* _0 */ && character <= 57 /* _9 */) { + isIdentifierPartCharacter[character] = true; + isNumericLiteralStart[character] = true; + } + } + + isNumericLiteralStart[46 /* dot */] = true; + + for (var keywordKind = 15 /* FirstKeyword */; keywordKind <= 69 /* LastKeyword */; keywordKind++) { + var keyword = TypeScript.SyntaxFacts.getText(keywordKind); + isKeywordStartCharacter[keyword.charCodeAt(0)] = true; + } + + var Scanner = (function () { + function Scanner(fileName, text, languageVersion, window) { + if (typeof window === "undefined") { window = TypeScript.ArrayUtilities.createArray(2048, 0); } + this.slidingWindow = new TypeScript.SlidingWindow(this, window, 0, text.length()); + this.fileName = fileName; + this.text = text; + this._languageVersion = languageVersion; + } + Scanner.prototype.languageVersion = function () { + return this._languageVersion; + }; + + Scanner.prototype.fetchMoreItems = function (argument, sourceIndex, window, destinationIndex, spaceAvailable) { + var charactersRemaining = this.text.length() - sourceIndex; + var amountToRead = TypeScript.MathPrototype.min(charactersRemaining, spaceAvailable); + this.text.copyTo(sourceIndex, window, destinationIndex, amountToRead); + return amountToRead; + }; + + Scanner.prototype.currentCharCode = function () { + return this.slidingWindow.currentItem(null); + }; + + Scanner.prototype.absoluteIndex = function () { + return this.slidingWindow.absoluteIndex(); + }; + + Scanner.prototype.setAbsoluteIndex = function (index) { + this.slidingWindow.setAbsoluteIndex(index); + }; + + Scanner.prototype.scan = function (diagnostics, allowRegularExpression) { + var diagnosticsLength = diagnostics.length; + var fullStart = this.slidingWindow.absoluteIndex(); + var leadingTriviaInfo = this.scanTriviaInfo(diagnostics, false); + + var start = this.slidingWindow.absoluteIndex(); + var kind = this.scanSyntaxToken(diagnostics, allowRegularExpression); + var end = this.slidingWindow.absoluteIndex(); + + var trailingTriviaInfo = this.scanTriviaInfo(diagnostics, true); + + var token = this.createToken(fullStart, leadingTriviaInfo, start, kind, end, trailingTriviaInfo); + + return diagnosticsLength !== diagnostics.length ? TypeScript.Syntax.realizeToken(token) : token; + }; + + Scanner.prototype.createToken = function (fullStart, leadingTriviaInfo, start, kind, end, trailingTriviaInfo) { + if (kind >= 15 /* FirstFixedWidth */) { + if (leadingTriviaInfo === 0) { + if (trailingTriviaInfo === 0) { + return new TypeScript.Syntax.FixedWidthTokenWithNoTrivia(kind); + } else { + return new TypeScript.Syntax.FixedWidthTokenWithTrailingTrivia(this.text, fullStart, kind, trailingTriviaInfo); + } + } else if (trailingTriviaInfo === 0) { + return new TypeScript.Syntax.FixedWidthTokenWithLeadingTrivia(this.text, fullStart, kind, leadingTriviaInfo); + } else { + return new TypeScript.Syntax.FixedWidthTokenWithLeadingAndTrailingTrivia(this.text, fullStart, kind, leadingTriviaInfo, trailingTriviaInfo); + } + } else { + var width = end - start; + if (leadingTriviaInfo === 0) { + if (trailingTriviaInfo === 0) { + return new TypeScript.Syntax.VariableWidthTokenWithNoTrivia(this.text, fullStart, kind, width); + } else { + return new TypeScript.Syntax.VariableWidthTokenWithTrailingTrivia(this.text, fullStart, kind, width, trailingTriviaInfo); + } + } else if (trailingTriviaInfo === 0) { + return new TypeScript.Syntax.VariableWidthTokenWithLeadingTrivia(this.text, fullStart, kind, leadingTriviaInfo, width); + } else { + return new TypeScript.Syntax.VariableWidthTokenWithLeadingAndTrailingTrivia(this.text, fullStart, kind, leadingTriviaInfo, width, trailingTriviaInfo); + } + } + }; + + Scanner.scanTrivia = function (text, start, length, isTrailing) { + var scanner = new Scanner(null, text.subText(new TypeScript.TextSpan(start, length)), 1 /* EcmaScript5 */, Scanner.triviaWindow); + return scanner.scanTrivia(isTrailing); + }; + + Scanner.prototype.scanTrivia = function (isTrailing) { + var trivia = new Array(); + + while (true) { + if (!this.slidingWindow.isAtEndOfSource()) { + var ch = this.currentCharCode(); + + switch (ch) { + case 32 /* space */: + case 160 /* nonBreakingSpace */: + case 8192 /* enQuad */: + case 8193 /* emQuad */: + case 8194 /* enSpace */: + case 8195 /* emSpace */: + case 8196 /* threePerEmSpace */: + case 8197 /* fourPerEmSpace */: + case 8198 /* sixPerEmSpace */: + case 8199 /* figureSpace */: + case 8200 /* punctuationSpace */: + case 8201 /* thinSpace */: + case 8202 /* hairSpace */: + case 8203 /* zeroWidthSpace */: + case 8239 /* narrowNoBreakSpace */: + case 12288 /* ideographicSpace */: + + case 9 /* tab */: + case 11 /* verticalTab */: + case 12 /* formFeed */: + case 65279 /* byteOrderMark */: + trivia.push(this.scanWhitespaceTrivia()); + continue; + + case 47 /* slash */: + var ch2 = this.slidingWindow.peekItemN(1); + if (ch2 === 47 /* slash */) { + trivia.push(this.scanSingleLineCommentTrivia()); + continue; + } + + if (ch2 === 42 /* asterisk */) { + trivia.push(this.scanMultiLineCommentTrivia()); + continue; + } + + throw TypeScript.Errors.invalidOperation(); + + case 13 /* carriageReturn */: + case 10 /* lineFeed */: + case 8233 /* paragraphSeparator */: + case 8232 /* lineSeparator */: + trivia.push(this.scanLineTerminatorSequenceTrivia(ch)); + + if (!isTrailing) { + continue; + } + + break; + + default: + throw TypeScript.Errors.invalidOperation(); + } + } + + return TypeScript.Syntax.triviaList(trivia); + } + }; + + Scanner.prototype.scanTriviaInfo = function (diagnostics, isTrailing) { + var width = 0; + var hasCommentOrNewLine = 0; + + while (true) { + var ch = this.currentCharCode(); + + switch (ch) { + case 32 /* space */: + case 160 /* nonBreakingSpace */: + case 8192 /* enQuad */: + case 8193 /* emQuad */: + case 8194 /* enSpace */: + case 8195 /* emSpace */: + case 8196 /* threePerEmSpace */: + case 8197 /* fourPerEmSpace */: + case 8198 /* sixPerEmSpace */: + case 8199 /* figureSpace */: + case 8200 /* punctuationSpace */: + case 8201 /* thinSpace */: + case 8202 /* hairSpace */: + case 8203 /* zeroWidthSpace */: + case 8239 /* narrowNoBreakSpace */: + case 12288 /* ideographicSpace */: + + case 9 /* tab */: + case 11 /* verticalTab */: + case 12 /* formFeed */: + case 65279 /* byteOrderMark */: + this.slidingWindow.moveToNextItem(); + width++; + continue; + + case 47 /* slash */: + var ch2 = this.slidingWindow.peekItemN(1); + if (ch2 === 47 /* slash */) { + hasCommentOrNewLine |= 2 /* TriviaCommentMask */; + width += this.scanSingleLineCommentTriviaLength(); + continue; + } + + if (ch2 === 42 /* asterisk */) { + hasCommentOrNewLine |= 2 /* TriviaCommentMask */; + width += this.scanMultiLineCommentTriviaLength(diagnostics); + continue; + } + + break; + + case 13 /* carriageReturn */: + case 10 /* lineFeed */: + case 8233 /* paragraphSeparator */: + case 8232 /* lineSeparator */: + hasCommentOrNewLine |= 1 /* TriviaNewLineMask */; + width += this.scanLineTerminatorSequenceLength(ch); + + if (!isTrailing) { + continue; + } + + break; + } + + return (width << 2 /* TriviaFullWidthShift */) | hasCommentOrNewLine; + } + }; + + Scanner.prototype.isNewLineCharacter = function (ch) { + switch (ch) { + case 13 /* carriageReturn */: + case 10 /* lineFeed */: + case 8233 /* paragraphSeparator */: + case 8232 /* lineSeparator */: + return true; + default: + return false; + } + }; + + Scanner.prototype.scanWhitespaceTrivia = function () { + var absoluteStartIndex = this.slidingWindow.getAndPinAbsoluteIndex(); + + var width = 0; + while (true) { + var ch = this.currentCharCode(); + + switch (ch) { + case 32 /* space */: + case 160 /* nonBreakingSpace */: + case 8192 /* enQuad */: + case 8193 /* emQuad */: + case 8194 /* enSpace */: + case 8195 /* emSpace */: + case 8196 /* threePerEmSpace */: + case 8197 /* fourPerEmSpace */: + case 8198 /* sixPerEmSpace */: + case 8199 /* figureSpace */: + case 8200 /* punctuationSpace */: + case 8201 /* thinSpace */: + case 8202 /* hairSpace */: + case 8203 /* zeroWidthSpace */: + case 8239 /* narrowNoBreakSpace */: + case 12288 /* ideographicSpace */: + + case 9 /* tab */: + case 11 /* verticalTab */: + case 12 /* formFeed */: + case 65279 /* byteOrderMark */: + this.slidingWindow.moveToNextItem(); + width++; + continue; + } + + break; + } + + var text = this.substring(absoluteStartIndex, absoluteStartIndex + width, false); + this.slidingWindow.releaseAndUnpinAbsoluteIndex(absoluteStartIndex); + + return TypeScript.Syntax.whitespace(text); + }; + + Scanner.prototype.scanSingleLineCommentTrivia = function () { + var absoluteStartIndex = this.slidingWindow.getAndPinAbsoluteIndex(); + var width = this.scanSingleLineCommentTriviaLength(); + + var text = this.substring(absoluteStartIndex, absoluteStartIndex + width, false); + this.slidingWindow.releaseAndUnpinAbsoluteIndex(absoluteStartIndex); + + return TypeScript.Syntax.singleLineComment(text); + }; + + Scanner.prototype.scanSingleLineCommentTriviaLength = function () { + this.slidingWindow.moveToNextItem(); + this.slidingWindow.moveToNextItem(); + + var width = 2; + while (true) { + if (this.slidingWindow.isAtEndOfSource() || this.isNewLineCharacter(this.currentCharCode())) { + return width; + } + + this.slidingWindow.moveToNextItem(); + width++; + } + }; + + Scanner.prototype.scanMultiLineCommentTrivia = function () { + var absoluteStartIndex = this.slidingWindow.getAndPinAbsoluteIndex(); + var width = this.scanMultiLineCommentTriviaLength(null); + + var text = this.substring(absoluteStartIndex, absoluteStartIndex + width, false); + this.slidingWindow.releaseAndUnpinAbsoluteIndex(absoluteStartIndex); + + return TypeScript.Syntax.multiLineComment(text); + }; + + Scanner.prototype.scanMultiLineCommentTriviaLength = function (diagnostics) { + this.slidingWindow.moveToNextItem(); + this.slidingWindow.moveToNextItem(); + + var width = 2; + while (true) { + if (this.slidingWindow.isAtEndOfSource()) { + if (diagnostics !== null) { + diagnostics.push(new TypeScript.Diagnostic(this.fileName, this.slidingWindow.absoluteIndex(), 0, TypeScript.DiagnosticCode.AsteriskSlash_expected, null)); + } + + return width; + } + + var ch = this.currentCharCode(); + if (ch === 42 /* asterisk */ && this.slidingWindow.peekItemN(1) === 47 /* slash */) { + this.slidingWindow.moveToNextItem(); + this.slidingWindow.moveToNextItem(); + width += 2; + return width; + } + + this.slidingWindow.moveToNextItem(); + width++; + } + }; + + Scanner.prototype.scanLineTerminatorSequenceTrivia = function (ch) { + var absoluteStartIndex = this.slidingWindow.getAndPinAbsoluteIndex(); + var width = this.scanLineTerminatorSequenceLength(ch); + + var text = this.substring(absoluteStartIndex, absoluteStartIndex + width, false); + this.slidingWindow.releaseAndUnpinAbsoluteIndex(absoluteStartIndex); + + return TypeScript.Syntax.trivia(5 /* NewLineTrivia */, text); + }; + + Scanner.prototype.scanLineTerminatorSequenceLength = function (ch) { + this.slidingWindow.moveToNextItem(); + + if (ch === 13 /* carriageReturn */ && this.currentCharCode() === 10 /* lineFeed */) { + this.slidingWindow.moveToNextItem(); + return 2; + } else { + return 1; + } + }; + + Scanner.prototype.scanSyntaxToken = function (diagnostics, allowRegularExpression) { + if (this.slidingWindow.isAtEndOfSource()) { + return 10 /* EndOfFileToken */; + } + + var character = this.currentCharCode(); + + switch (character) { + case 34 /* doubleQuote */: + case 39 /* singleQuote */: + return this.scanStringLiteral(diagnostics); + + case 47 /* slash */: + return this.scanSlashToken(allowRegularExpression); + + case 46 /* dot */: + return this.scanDotToken(); + + case 45 /* minus */: + return this.scanMinusToken(); + + case 33 /* exclamation */: + return this.scanExclamationToken(); + + case 61 /* equals */: + return this.scanEqualsToken(); + + case 124 /* bar */: + return this.scanBarToken(); + + case 42 /* asterisk */: + return this.scanAsteriskToken(); + + case 43 /* plus */: + return this.scanPlusToken(); + + case 37 /* percent */: + return this.scanPercentToken(); + + case 38 /* ampersand */: + return this.scanAmpersandToken(); + + case 94 /* caret */: + return this.scanCaretToken(); + + case 60 /* lessThan */: + return this.scanLessThanToken(); + + case 62 /* greaterThan */: + return this.advanceAndSetTokenKind(81 /* GreaterThanToken */); + + case 44 /* comma */: + return this.advanceAndSetTokenKind(79 /* CommaToken */); + + case 58 /* colon */: + return this.advanceAndSetTokenKind(106 /* ColonToken */); + + case 59 /* semicolon */: + return this.advanceAndSetTokenKind(78 /* SemicolonToken */); + + case 126 /* tilde */: + return this.advanceAndSetTokenKind(102 /* TildeToken */); + + case 40 /* openParen */: + return this.advanceAndSetTokenKind(72 /* OpenParenToken */); + + case 41 /* closeParen */: + return this.advanceAndSetTokenKind(73 /* CloseParenToken */); + + case 123 /* openBrace */: + return this.advanceAndSetTokenKind(70 /* OpenBraceToken */); + + case 125 /* closeBrace */: + return this.advanceAndSetTokenKind(71 /* CloseBraceToken */); + + case 91 /* openBracket */: + return this.advanceAndSetTokenKind(74 /* OpenBracketToken */); + + case 93 /* closeBracket */: + return this.advanceAndSetTokenKind(75 /* CloseBracketToken */); + + case 63 /* question */: + return this.advanceAndSetTokenKind(105 /* QuestionToken */); + } + + if (isNumericLiteralStart[character]) { + return this.scanNumericLiteral(); + } + + if (isIdentifierStartCharacter[character]) { + var result = this.tryFastScanIdentifierOrKeyword(character); + if (result !== 0 /* None */) { + return result; + } + } + + if (this.isIdentifierStart(this.peekCharOrUnicodeEscape())) { + return this.slowScanIdentifier(diagnostics); + } + + return this.scanDefaultCharacter(character, diagnostics); + }; + + Scanner.prototype.isIdentifierStart = function (interpretedChar) { + if (isIdentifierStartCharacter[interpretedChar]) { + return true; + } + + return interpretedChar > 127 /* maxAsciiCharacter */ && TypeScript.Unicode.isIdentifierStart(interpretedChar, this._languageVersion); + }; + + Scanner.prototype.isIdentifierPart = function (interpretedChar) { + if (isIdentifierPartCharacter[interpretedChar]) { + return true; + } + + return interpretedChar > 127 /* maxAsciiCharacter */ && TypeScript.Unicode.isIdentifierPart(interpretedChar, this._languageVersion); + }; + + Scanner.prototype.tryFastScanIdentifierOrKeyword = function (firstCharacter) { + var startIndex = this.slidingWindow.getAndPinAbsoluteIndex(); + + while (true) { + var character = this.currentCharCode(); + if (isIdentifierPartCharacter[character]) { + this.slidingWindow.moveToNextItem(); + } else if (character === 92 /* backslash */ || character > 127 /* maxAsciiCharacter */) { + this.slidingWindow.rewindToPinnedIndex(startIndex); + this.slidingWindow.releaseAndUnpinAbsoluteIndex(startIndex); + return 0 /* None */; + } else { + var endIndex = this.slidingWindow.absoluteIndex(); + + var kind; + if (isKeywordStartCharacter[firstCharacter]) { + var offset = startIndex - this.slidingWindow.windowAbsoluteStartIndex; + kind = TypeScript.ScannerUtilities.identifierKind(this.slidingWindow.window, offset, endIndex - startIndex); + } else { + kind = 11 /* IdentifierName */; + } + + this.slidingWindow.releaseAndUnpinAbsoluteIndex(startIndex); + return kind; + } + } + }; + + Scanner.prototype.slowScanIdentifier = function (diagnostics) { + var startIndex = this.slidingWindow.absoluteIndex(); + + do { + this.scanCharOrUnicodeEscape(diagnostics); + } while(this.isIdentifierPart(this.peekCharOrUnicodeEscape())); + + return 11 /* IdentifierName */; + }; + + Scanner.prototype.scanNumericLiteral = function () { + if (this.isHexNumericLiteral()) { + return this.scanHexNumericLiteral(); + } else { + return this.scanDecimalNumericLiteral(); + } + }; + + Scanner.prototype.scanDecimalNumericLiteral = function () { + while (TypeScript.CharacterInfo.isDecimalDigit(this.currentCharCode())) { + this.slidingWindow.moveToNextItem(); + } + + if (this.currentCharCode() === 46 /* dot */) { + this.slidingWindow.moveToNextItem(); + } + + while (TypeScript.CharacterInfo.isDecimalDigit(this.currentCharCode())) { + this.slidingWindow.moveToNextItem(); + } + + var ch = this.currentCharCode(); + if (ch === 101 /* e */ || ch === 69 /* E */) { + this.slidingWindow.moveToNextItem(); + + ch = this.currentCharCode(); + if (ch === 45 /* minus */ || ch === 43 /* plus */) { + if (TypeScript.CharacterInfo.isDecimalDigit(this.slidingWindow.peekItemN(1))) { + this.slidingWindow.moveToNextItem(); + } + } + } + + while (TypeScript.CharacterInfo.isDecimalDigit(this.currentCharCode())) { + this.slidingWindow.moveToNextItem(); + } + + return 13 /* NumericLiteral */; + }; + + Scanner.prototype.scanHexNumericLiteral = function () { + this.slidingWindow.moveToNextItem(); + this.slidingWindow.moveToNextItem(); + + while (TypeScript.CharacterInfo.isHexDigit(this.currentCharCode())) { + this.slidingWindow.moveToNextItem(); + } + + return 13 /* NumericLiteral */; + }; + + Scanner.prototype.isHexNumericLiteral = function () { + if (this.currentCharCode() === 48 /* _0 */) { + var ch = this.slidingWindow.peekItemN(1); + + if (ch === 120 /* x */ || ch === 88 /* X */) { + ch = this.slidingWindow.peekItemN(2); + + return TypeScript.CharacterInfo.isHexDigit(ch); + } + } + + return false; + }; + + Scanner.prototype.advanceAndSetTokenKind = function (kind) { + this.slidingWindow.moveToNextItem(); + return kind; + }; + + Scanner.prototype.scanLessThanToken = function () { + this.slidingWindow.moveToNextItem(); + if (this.currentCharCode() === 61 /* equals */) { + this.slidingWindow.moveToNextItem(); + return 82 /* LessThanEqualsToken */; + } else if (this.currentCharCode() === 60 /* lessThan */) { + this.slidingWindow.moveToNextItem(); + if (this.currentCharCode() === 61 /* equals */) { + this.slidingWindow.moveToNextItem(); + return 112 /* LessThanLessThanEqualsToken */; + } else { + return 95 /* LessThanLessThanToken */; + } + } else { + return 80 /* LessThanToken */; + } + }; + + Scanner.prototype.scanBarToken = function () { + this.slidingWindow.moveToNextItem(); + if (this.currentCharCode() === 61 /* equals */) { + this.slidingWindow.moveToNextItem(); + return 116 /* BarEqualsToken */; + } else if (this.currentCharCode() === 124 /* bar */) { + this.slidingWindow.moveToNextItem(); + return 104 /* BarBarToken */; + } else { + return 99 /* BarToken */; + } + }; + + Scanner.prototype.scanCaretToken = function () { + this.slidingWindow.moveToNextItem(); + if (this.currentCharCode() === 61 /* equals */) { + this.slidingWindow.moveToNextItem(); + return 117 /* CaretEqualsToken */; + } else { + return 100 /* CaretToken */; + } + }; + + Scanner.prototype.scanAmpersandToken = function () { + this.slidingWindow.moveToNextItem(); + var character = this.currentCharCode(); + if (character === 61 /* equals */) { + this.slidingWindow.moveToNextItem(); + return 115 /* AmpersandEqualsToken */; + } else if (this.currentCharCode() === 38 /* ampersand */) { + this.slidingWindow.moveToNextItem(); + return 103 /* AmpersandAmpersandToken */; + } else { + return 98 /* AmpersandToken */; + } + }; + + Scanner.prototype.scanPercentToken = function () { + this.slidingWindow.moveToNextItem(); + if (this.currentCharCode() === 61 /* equals */) { + this.slidingWindow.moveToNextItem(); + return 111 /* PercentEqualsToken */; + } else { + return 92 /* PercentToken */; + } + }; + + Scanner.prototype.scanMinusToken = function () { + this.slidingWindow.moveToNextItem(); + var character = this.currentCharCode(); + + if (character === 61 /* equals */) { + this.slidingWindow.moveToNextItem(); + return 109 /* MinusEqualsToken */; + } else if (character === 45 /* minus */) { + this.slidingWindow.moveToNextItem(); + return 94 /* MinusMinusToken */; + } else { + return 90 /* MinusToken */; + } + }; + + Scanner.prototype.scanPlusToken = function () { + this.slidingWindow.moveToNextItem(); + var character = this.currentCharCode(); + if (character === 61 /* equals */) { + this.slidingWindow.moveToNextItem(); + return 108 /* PlusEqualsToken */; + } else if (character === 43 /* plus */) { + this.slidingWindow.moveToNextItem(); + return 93 /* PlusPlusToken */; + } else { + return 89 /* PlusToken */; + } + }; + + Scanner.prototype.scanAsteriskToken = function () { + this.slidingWindow.moveToNextItem(); + if (this.currentCharCode() === 61 /* equals */) { + this.slidingWindow.moveToNextItem(); + return 110 /* AsteriskEqualsToken */; + } else { + return 91 /* AsteriskToken */; + } + }; + + Scanner.prototype.scanEqualsToken = function () { + this.slidingWindow.moveToNextItem(); + var character = this.currentCharCode(); + if (character === 61 /* equals */) { + this.slidingWindow.moveToNextItem(); + + if (this.currentCharCode() === 61 /* equals */) { + this.slidingWindow.moveToNextItem(); + + return 87 /* EqualsEqualsEqualsToken */; + } else { + return 84 /* EqualsEqualsToken */; + } + } else if (character === 62 /* greaterThan */) { + this.slidingWindow.moveToNextItem(); + return 85 /* EqualsGreaterThanToken */; + } else { + return 107 /* EqualsToken */; + } + }; + + Scanner.prototype.isDotPrefixedNumericLiteral = function () { + if (this.currentCharCode() === 46 /* dot */) { + var ch = this.slidingWindow.peekItemN(1); + return TypeScript.CharacterInfo.isDecimalDigit(ch); + } + + return false; + }; + + Scanner.prototype.scanDotToken = function () { + if (this.isDotPrefixedNumericLiteral()) { + return this.scanNumericLiteral(); + } + + this.slidingWindow.moveToNextItem(); + if (this.currentCharCode() === 46 /* dot */ && this.slidingWindow.peekItemN(1) === 46 /* dot */) { + this.slidingWindow.moveToNextItem(); + this.slidingWindow.moveToNextItem(); + return 77 /* DotDotDotToken */; + } else { + return 76 /* DotToken */; + } + }; + + Scanner.prototype.scanSlashToken = function (allowRegularExpression) { + if (allowRegularExpression) { + var result = this.tryScanRegularExpressionToken(); + if (result !== 0 /* None */) { + return result; + } + } + + this.slidingWindow.moveToNextItem(); + if (this.currentCharCode() === 61 /* equals */) { + this.slidingWindow.moveToNextItem(); + return 119 /* SlashEqualsToken */; + } else { + return 118 /* SlashToken */; + } + }; + + Scanner.prototype.tryScanRegularExpressionToken = function () { + var startIndex = this.slidingWindow.getAndPinAbsoluteIndex(); + try { + this.slidingWindow.moveToNextItem(); + + var inEscape = false; + var inCharacterClass = false; + while (true) { + var ch = this.currentCharCode(); + if (this.isNewLineCharacter(ch) || this.slidingWindow.isAtEndOfSource()) { + this.slidingWindow.rewindToPinnedIndex(startIndex); + return 0 /* None */; + } + + this.slidingWindow.moveToNextItem(); + if (inEscape) { + inEscape = false; + continue; + } + + switch (ch) { + case 92 /* backslash */: + inEscape = true; + continue; + + case 91 /* openBracket */: + inCharacterClass = true; + continue; + + case 93 /* closeBracket */: + inCharacterClass = false; + continue; + + case 47 /* slash */: + if (inCharacterClass) { + continue; + } + + break; + + default: + continue; + } + + break; + } + + while (isIdentifierPartCharacter[this.currentCharCode()]) { + this.slidingWindow.moveToNextItem(); + } + + return 12 /* RegularExpressionLiteral */; + } finally { + this.slidingWindow.releaseAndUnpinAbsoluteIndex(startIndex); + } + }; + + Scanner.prototype.scanExclamationToken = function () { + this.slidingWindow.moveToNextItem(); + if (this.currentCharCode() === 61 /* equals */) { + this.slidingWindow.moveToNextItem(); + + if (this.currentCharCode() === 61 /* equals */) { + this.slidingWindow.moveToNextItem(); + + return 88 /* ExclamationEqualsEqualsToken */; + } else { + return 86 /* ExclamationEqualsToken */; + } + } else { + return 101 /* ExclamationToken */; + } + }; + + Scanner.prototype.scanDefaultCharacter = function (character, diagnostics) { + var position = this.slidingWindow.absoluteIndex(); + this.slidingWindow.moveToNextItem(); + + var text = String.fromCharCode(character); + var messageText = this.getErrorMessageText(text); + diagnostics.push(new TypeScript.Diagnostic(this.fileName, position, 1, TypeScript.DiagnosticCode.Unexpected_character_0, [messageText])); + + return 9 /* ErrorToken */; + }; + + Scanner.prototype.getErrorMessageText = function (text) { + if (text === "\\") { + return '"\\"'; + } + + return JSON.stringify(text); + }; + + Scanner.prototype.skipEscapeSequence = function (diagnostics) { + var rewindPoint = this.slidingWindow.getAndPinAbsoluteIndex(); + try { + this.slidingWindow.moveToNextItem(); + + var ch = this.currentCharCode(); + this.slidingWindow.moveToNextItem(); + switch (ch) { + case 120 /* x */: + case 117 /* u */: + this.slidingWindow.rewindToPinnedIndex(rewindPoint); + var value = this.scanUnicodeOrHexEscape(diagnostics); + return; + + case 13 /* carriageReturn */: + if (this.currentCharCode() === 10 /* lineFeed */) { + this.slidingWindow.moveToNextItem(); + } + return; + + default: + return; + } + } finally { + this.slidingWindow.releaseAndUnpinAbsoluteIndex(rewindPoint); + } + }; + + Scanner.prototype.scanStringLiteral = function (diagnostics) { + var quoteCharacter = this.currentCharCode(); + + this.slidingWindow.moveToNextItem(); + + while (true) { + var ch = this.currentCharCode(); + if (ch === 92 /* backslash */) { + this.skipEscapeSequence(diagnostics); + } else if (ch === quoteCharacter) { + this.slidingWindow.moveToNextItem(); + break; + } else if (this.isNewLineCharacter(ch) || this.slidingWindow.isAtEndOfSource()) { + diagnostics.push(new TypeScript.Diagnostic(this.fileName, this.slidingWindow.absoluteIndex(), 1, TypeScript.DiagnosticCode.Missing_close_quote_character, null)); + break; + } else { + this.slidingWindow.moveToNextItem(); + } + } + + return 14 /* StringLiteral */; + }; + + Scanner.prototype.isUnicodeOrHexEscape = function (character) { + return this.isUnicodeEscape(character) || this.isHexEscape(character); + }; + + Scanner.prototype.isUnicodeEscape = function (character) { + if (character === 92 /* backslash */) { + var ch2 = this.slidingWindow.peekItemN(1); + if (ch2 === 117 /* u */) { + return true; + } + } + + return false; + }; + + Scanner.prototype.isHexEscape = function (character) { + if (character === 92 /* backslash */) { + var ch2 = this.slidingWindow.peekItemN(1); + if (ch2 === 120 /* x */) { + return true; + } + } + + return false; + }; + + Scanner.prototype.peekCharOrUnicodeOrHexEscape = function () { + var character = this.currentCharCode(); + if (this.isUnicodeOrHexEscape(character)) { + return this.peekUnicodeOrHexEscape(); + } else { + return character; + } + }; + + Scanner.prototype.peekCharOrUnicodeEscape = function () { + var character = this.currentCharCode(); + if (this.isUnicodeEscape(character)) { + return this.peekUnicodeOrHexEscape(); + } else { + return character; + } + }; + + Scanner.prototype.peekUnicodeOrHexEscape = function () { + var startIndex = this.slidingWindow.getAndPinAbsoluteIndex(); + + var ch = this.scanUnicodeOrHexEscape(null); + + this.slidingWindow.rewindToPinnedIndex(startIndex); + this.slidingWindow.releaseAndUnpinAbsoluteIndex(startIndex); + + return ch; + }; + + Scanner.prototype.scanCharOrUnicodeEscape = function (errors) { + var ch = this.currentCharCode(); + if (ch === 92 /* backslash */) { + var ch2 = this.slidingWindow.peekItemN(1); + if (ch2 === 117 /* u */) { + return this.scanUnicodeOrHexEscape(errors); + } + } + + this.slidingWindow.moveToNextItem(); + return ch; + }; + + Scanner.prototype.scanCharOrUnicodeOrHexEscape = function (errors) { + var ch = this.currentCharCode(); + if (ch === 92 /* backslash */) { + var ch2 = this.slidingWindow.peekItemN(1); + if (ch2 === 117 /* u */ || ch2 === 120 /* x */) { + return this.scanUnicodeOrHexEscape(errors); + } + } + + this.slidingWindow.moveToNextItem(); + return ch; + }; + + Scanner.prototype.scanUnicodeOrHexEscape = function (errors) { + var start = this.slidingWindow.absoluteIndex(); + var character = this.currentCharCode(); + + this.slidingWindow.moveToNextItem(); + + character = this.currentCharCode(); + + var intChar = 0; + this.slidingWindow.moveToNextItem(); + + var count = character === 117 /* u */ ? 4 : 2; + + for (var i = 0; i < count; i++) { + var ch2 = this.currentCharCode(); + if (!TypeScript.CharacterInfo.isHexDigit(ch2)) { + if (errors !== null) { + var end = this.slidingWindow.absoluteIndex(); + var info = this.createIllegalEscapeDiagnostic(start, end); + errors.push(info); + } + + break; + } + + intChar = (intChar << 4) + TypeScript.CharacterInfo.hexValue(ch2); + this.slidingWindow.moveToNextItem(); + } + + return intChar; + }; + + Scanner.prototype.substring = function (start, end, intern) { + var length = end - start; + var offset = start - this.slidingWindow.windowAbsoluteStartIndex; + + if (intern) { + return TypeScript.Collections.DefaultStringTable.addCharArray(this.slidingWindow.window, offset, length); + } else { + return TypeScript.StringUtilities.fromCharCodeArray(this.slidingWindow.window.slice(offset, offset + length)); + } + }; + + Scanner.prototype.createIllegalEscapeDiagnostic = function (start, end) { + return new TypeScript.Diagnostic(this.fileName, start, end - start, TypeScript.DiagnosticCode.Unrecognized_escape_sequence, null); + }; + + Scanner.isValidIdentifier = function (text, languageVersion) { + var scanner = new Scanner(null, text, TypeScript.LanguageVersion, Scanner.triviaWindow); + var errors = new Array(); + var token = scanner.scan(errors, false); + + return errors.length === 0 && TypeScript.SyntaxFacts.isIdentifierNameOrAnyKeyword(token) && token.width() === text.length(); + }; + Scanner.triviaWindow = TypeScript.ArrayUtilities.createArray(2048, 0); + return Scanner; + })(); + TypeScript.Scanner = Scanner; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var ScannerUtilities = (function () { + function ScannerUtilities() { + } + ScannerUtilities.identifierKind = function (array, startIndex, length) { + switch (length) { + case 2: + switch (array[startIndex]) { + case 100 /* d */: + return (array[startIndex + 1] === 111 /* o */) ? 22 /* DoKeyword */ : 11 /* IdentifierName */; + case 105 /* i */: + switch (array[startIndex + 1]) { + case 102 /* f */: + return 28 /* IfKeyword */; + case 110 /* n */: + return 29 /* InKeyword */; + default: + return 11 /* IdentifierName */; + } + + default: + return 11 /* IdentifierName */; + } + + case 3: + switch (array[startIndex]) { + case 102 /* f */: + return (array[startIndex + 1] === 111 /* o */ && array[startIndex + 2] === 114 /* r */) ? 26 /* ForKeyword */ : 11 /* IdentifierName */; + case 110 /* n */: + return (array[startIndex + 1] === 101 /* e */ && array[startIndex + 2] === 119 /* w */) ? 31 /* NewKeyword */ : 11 /* IdentifierName */; + case 116 /* t */: + return (array[startIndex + 1] === 114 /* r */ && array[startIndex + 2] === 121 /* y */) ? 38 /* TryKeyword */ : 11 /* IdentifierName */; + case 118 /* v */: + return (array[startIndex + 1] === 97 /* a */ && array[startIndex + 2] === 114 /* r */) ? 40 /* VarKeyword */ : 11 /* IdentifierName */; + case 108 /* l */: + return (array[startIndex + 1] === 101 /* e */ && array[startIndex + 2] === 116 /* t */) ? 53 /* LetKeyword */ : 11 /* IdentifierName */; + case 97 /* a */: + return (array[startIndex + 1] === 110 /* n */ && array[startIndex + 2] === 121 /* y */) ? 60 /* AnyKeyword */ : 11 /* IdentifierName */; + case 103 /* g */: + return (array[startIndex + 1] === 101 /* e */ && array[startIndex + 2] === 116 /* t */) ? 64 /* GetKeyword */ : 11 /* IdentifierName */; + case 115 /* s */: + return (array[startIndex + 1] === 101 /* e */ && array[startIndex + 2] === 116 /* t */) ? 68 /* SetKeyword */ : 11 /* IdentifierName */; + default: + return 11 /* IdentifierName */; + } + + case 4: + switch (array[startIndex]) { + case 99 /* c */: + return (array[startIndex + 1] === 97 /* a */ && array[startIndex + 2] === 115 /* s */ && array[startIndex + 3] === 101 /* e */) ? 16 /* CaseKeyword */ : 11 /* IdentifierName */; + case 101 /* e */: + switch (array[startIndex + 1]) { + case 108 /* l */: + return (array[startIndex + 2] === 115 /* s */ && array[startIndex + 3] === 101 /* e */) ? 23 /* ElseKeyword */ : 11 /* IdentifierName */; + case 110 /* n */: + return (array[startIndex + 2] === 117 /* u */ && array[startIndex + 3] === 109 /* m */) ? 46 /* EnumKeyword */ : 11 /* IdentifierName */; + default: + return 11 /* IdentifierName */; + } + + case 110 /* n */: + return (array[startIndex + 1] === 117 /* u */ && array[startIndex + 2] === 108 /* l */ && array[startIndex + 3] === 108 /* l */) ? 32 /* NullKeyword */ : 11 /* IdentifierName */; + case 116 /* t */: + switch (array[startIndex + 1]) { + case 104 /* h */: + return (array[startIndex + 2] === 105 /* i */ && array[startIndex + 3] === 115 /* s */) ? 35 /* ThisKeyword */ : 11 /* IdentifierName */; + case 114 /* r */: + return (array[startIndex + 2] === 117 /* u */ && array[startIndex + 3] === 101 /* e */) ? 37 /* TrueKeyword */ : 11 /* IdentifierName */; + default: + return 11 /* IdentifierName */; + } + + case 118 /* v */: + return (array[startIndex + 1] === 111 /* o */ && array[startIndex + 2] === 105 /* i */ && array[startIndex + 3] === 100 /* d */) ? 41 /* VoidKeyword */ : 11 /* IdentifierName */; + case 119 /* w */: + return (array[startIndex + 1] === 105 /* i */ && array[startIndex + 2] === 116 /* t */ && array[startIndex + 3] === 104 /* h */) ? 43 /* WithKeyword */ : 11 /* IdentifierName */; + default: + return 11 /* IdentifierName */; + } + + case 5: + switch (array[startIndex]) { + case 98 /* b */: + return (array[startIndex + 1] === 114 /* r */ && array[startIndex + 2] === 101 /* e */ && array[startIndex + 3] === 97 /* a */ && array[startIndex + 4] === 107 /* k */) ? 15 /* BreakKeyword */ : 11 /* IdentifierName */; + case 99 /* c */: + switch (array[startIndex + 1]) { + case 97 /* a */: + return (array[startIndex + 2] === 116 /* t */ && array[startIndex + 3] === 99 /* c */ && array[startIndex + 4] === 104 /* h */) ? 17 /* CatchKeyword */ : 11 /* IdentifierName */; + case 108 /* l */: + return (array[startIndex + 2] === 97 /* a */ && array[startIndex + 3] === 115 /* s */ && array[startIndex + 4] === 115 /* s */) ? 44 /* ClassKeyword */ : 11 /* IdentifierName */; + case 111 /* o */: + return (array[startIndex + 2] === 110 /* n */ && array[startIndex + 3] === 115 /* s */ && array[startIndex + 4] === 116 /* t */) ? 45 /* ConstKeyword */ : 11 /* IdentifierName */; + default: + return 11 /* IdentifierName */; + } + + case 102 /* f */: + return (array[startIndex + 1] === 97 /* a */ && array[startIndex + 2] === 108 /* l */ && array[startIndex + 3] === 115 /* s */ && array[startIndex + 4] === 101 /* e */) ? 24 /* FalseKeyword */ : 11 /* IdentifierName */; + case 116 /* t */: + return (array[startIndex + 1] === 104 /* h */ && array[startIndex + 2] === 114 /* r */ && array[startIndex + 3] === 111 /* o */ && array[startIndex + 4] === 119 /* w */) ? 36 /* ThrowKeyword */ : 11 /* IdentifierName */; + case 119 /* w */: + return (array[startIndex + 1] === 104 /* h */ && array[startIndex + 2] === 105 /* i */ && array[startIndex + 3] === 108 /* l */ && array[startIndex + 4] === 101 /* e */) ? 42 /* WhileKeyword */ : 11 /* IdentifierName */; + case 115 /* s */: + return (array[startIndex + 1] === 117 /* u */ && array[startIndex + 2] === 112 /* p */ && array[startIndex + 3] === 101 /* e */ && array[startIndex + 4] === 114 /* r */) ? 50 /* SuperKeyword */ : 11 /* IdentifierName */; + case 121 /* y */: + return (array[startIndex + 1] === 105 /* i */ && array[startIndex + 2] === 101 /* e */ && array[startIndex + 3] === 108 /* l */ && array[startIndex + 4] === 100 /* d */) ? 59 /* YieldKeyword */ : 11 /* IdentifierName */; + default: + return 11 /* IdentifierName */; + } + + case 6: + switch (array[startIndex]) { + case 100 /* d */: + return (array[startIndex + 1] === 101 /* e */ && array[startIndex + 2] === 108 /* l */ && array[startIndex + 3] === 101 /* e */ && array[startIndex + 4] === 116 /* t */ && array[startIndex + 5] === 101 /* e */) ? 21 /* DeleteKeyword */ : 11 /* IdentifierName */; + case 114 /* r */: + return (array[startIndex + 1] === 101 /* e */ && array[startIndex + 2] === 116 /* t */ && array[startIndex + 3] === 117 /* u */ && array[startIndex + 4] === 114 /* r */ && array[startIndex + 5] === 110 /* n */) ? 33 /* ReturnKeyword */ : 11 /* IdentifierName */; + case 115 /* s */: + switch (array[startIndex + 1]) { + case 119 /* w */: + return (array[startIndex + 2] === 105 /* i */ && array[startIndex + 3] === 116 /* t */ && array[startIndex + 4] === 99 /* c */ && array[startIndex + 5] === 104 /* h */) ? 34 /* SwitchKeyword */ : 11 /* IdentifierName */; + case 116 /* t */: + switch (array[startIndex + 2]) { + case 97 /* a */: + return (array[startIndex + 3] === 116 /* t */ && array[startIndex + 4] === 105 /* i */ && array[startIndex + 5] === 99 /* c */) ? 58 /* StaticKeyword */ : 11 /* IdentifierName */; + case 114 /* r */: + return (array[startIndex + 3] === 105 /* i */ && array[startIndex + 4] === 110 /* n */ && array[startIndex + 5] === 103 /* g */) ? 69 /* StringKeyword */ : 11 /* IdentifierName */; + default: + return 11 /* IdentifierName */; + } + + default: + return 11 /* IdentifierName */; + } + + case 116 /* t */: + return (array[startIndex + 1] === 121 /* y */ && array[startIndex + 2] === 112 /* p */ && array[startIndex + 3] === 101 /* e */ && array[startIndex + 4] === 111 /* o */ && array[startIndex + 5] === 102 /* f */) ? 39 /* TypeOfKeyword */ : 11 /* IdentifierName */; + case 101 /* e */: + return (array[startIndex + 1] === 120 /* x */ && array[startIndex + 2] === 112 /* p */ && array[startIndex + 3] === 111 /* o */ && array[startIndex + 4] === 114 /* r */ && array[startIndex + 5] === 116 /* t */) ? 47 /* ExportKeyword */ : 11 /* IdentifierName */; + case 105 /* i */: + return (array[startIndex + 1] === 109 /* m */ && array[startIndex + 2] === 112 /* p */ && array[startIndex + 3] === 111 /* o */ && array[startIndex + 4] === 114 /* r */ && array[startIndex + 5] === 116 /* t */) ? 49 /* ImportKeyword */ : 11 /* IdentifierName */; + case 112 /* p */: + return (array[startIndex + 1] === 117 /* u */ && array[startIndex + 2] === 98 /* b */ && array[startIndex + 3] === 108 /* l */ && array[startIndex + 4] === 105 /* i */ && array[startIndex + 5] === 99 /* c */) ? 57 /* PublicKeyword */ : 11 /* IdentifierName */; + case 109 /* m */: + return (array[startIndex + 1] === 111 /* o */ && array[startIndex + 2] === 100 /* d */ && array[startIndex + 3] === 117 /* u */ && array[startIndex + 4] === 108 /* l */ && array[startIndex + 5] === 101 /* e */) ? 65 /* ModuleKeyword */ : 11 /* IdentifierName */; + case 110 /* n */: + return (array[startIndex + 1] === 117 /* u */ && array[startIndex + 2] === 109 /* m */ && array[startIndex + 3] === 98 /* b */ && array[startIndex + 4] === 101 /* e */ && array[startIndex + 5] === 114 /* r */) ? 67 /* NumberKeyword */ : 11 /* IdentifierName */; + default: + return 11 /* IdentifierName */; + } + + case 7: + switch (array[startIndex]) { + case 100 /* d */: + switch (array[startIndex + 1]) { + case 101 /* e */: + switch (array[startIndex + 2]) { + case 102 /* f */: + return (array[startIndex + 3] === 97 /* a */ && array[startIndex + 4] === 117 /* u */ && array[startIndex + 5] === 108 /* l */ && array[startIndex + 6] === 116 /* t */) ? 20 /* DefaultKeyword */ : 11 /* IdentifierName */; + case 99 /* c */: + return (array[startIndex + 3] === 108 /* l */ && array[startIndex + 4] === 97 /* a */ && array[startIndex + 5] === 114 /* r */ && array[startIndex + 6] === 101 /* e */) ? 63 /* DeclareKeyword */ : 11 /* IdentifierName */; + default: + return 11 /* IdentifierName */; + } + + default: + return 11 /* IdentifierName */; + } + + case 102 /* f */: + return (array[startIndex + 1] === 105 /* i */ && array[startIndex + 2] === 110 /* n */ && array[startIndex + 3] === 97 /* a */ && array[startIndex + 4] === 108 /* l */ && array[startIndex + 5] === 108 /* l */ && array[startIndex + 6] === 121 /* y */) ? 25 /* FinallyKeyword */ : 11 /* IdentifierName */; + case 101 /* e */: + return (array[startIndex + 1] === 120 /* x */ && array[startIndex + 2] === 116 /* t */ && array[startIndex + 3] === 101 /* e */ && array[startIndex + 4] === 110 /* n */ && array[startIndex + 5] === 100 /* d */ && array[startIndex + 6] === 115 /* s */) ? 48 /* ExtendsKeyword */ : 11 /* IdentifierName */; + case 112 /* p */: + switch (array[startIndex + 1]) { + case 97 /* a */: + return (array[startIndex + 2] === 99 /* c */ && array[startIndex + 3] === 107 /* k */ && array[startIndex + 4] === 97 /* a */ && array[startIndex + 5] === 103 /* g */ && array[startIndex + 6] === 101 /* e */) ? 54 /* PackageKeyword */ : 11 /* IdentifierName */; + case 114 /* r */: + return (array[startIndex + 2] === 105 /* i */ && array[startIndex + 3] === 118 /* v */ && array[startIndex + 4] === 97 /* a */ && array[startIndex + 5] === 116 /* t */ && array[startIndex + 6] === 101 /* e */) ? 55 /* PrivateKeyword */ : 11 /* IdentifierName */; + default: + return 11 /* IdentifierName */; + } + + case 98 /* b */: + return (array[startIndex + 1] === 111 /* o */ && array[startIndex + 2] === 111 /* o */ && array[startIndex + 3] === 108 /* l */ && array[startIndex + 4] === 101 /* e */ && array[startIndex + 5] === 97 /* a */ && array[startIndex + 6] === 110 /* n */) ? 61 /* BooleanKeyword */ : 11 /* IdentifierName */; + case 114 /* r */: + return (array[startIndex + 1] === 101 /* e */ && array[startIndex + 2] === 113 /* q */ && array[startIndex + 3] === 117 /* u */ && array[startIndex + 4] === 105 /* i */ && array[startIndex + 5] === 114 /* r */ && array[startIndex + 6] === 101 /* e */) ? 66 /* RequireKeyword */ : 11 /* IdentifierName */; + default: + return 11 /* IdentifierName */; + } + + case 8: + switch (array[startIndex]) { + case 99 /* c */: + return (array[startIndex + 1] === 111 /* o */ && array[startIndex + 2] === 110 /* n */ && array[startIndex + 3] === 116 /* t */ && array[startIndex + 4] === 105 /* i */ && array[startIndex + 5] === 110 /* n */ && array[startIndex + 6] === 117 /* u */ && array[startIndex + 7] === 101 /* e */) ? 18 /* ContinueKeyword */ : 11 /* IdentifierName */; + case 100 /* d */: + return (array[startIndex + 1] === 101 /* e */ && array[startIndex + 2] === 98 /* b */ && array[startIndex + 3] === 117 /* u */ && array[startIndex + 4] === 103 /* g */ && array[startIndex + 5] === 103 /* g */ && array[startIndex + 6] === 101 /* e */ && array[startIndex + 7] === 114 /* r */) ? 19 /* DebuggerKeyword */ : 11 /* IdentifierName */; + case 102 /* f */: + return (array[startIndex + 1] === 117 /* u */ && array[startIndex + 2] === 110 /* n */ && array[startIndex + 3] === 99 /* c */ && array[startIndex + 4] === 116 /* t */ && array[startIndex + 5] === 105 /* i */ && array[startIndex + 6] === 111 /* o */ && array[startIndex + 7] === 110 /* n */) ? 27 /* FunctionKeyword */ : 11 /* IdentifierName */; + default: + return 11 /* IdentifierName */; + } + + case 9: + switch (array[startIndex]) { + case 105 /* i */: + return (array[startIndex + 1] === 110 /* n */ && array[startIndex + 2] === 116 /* t */ && array[startIndex + 3] === 101 /* e */ && array[startIndex + 4] === 114 /* r */ && array[startIndex + 5] === 102 /* f */ && array[startIndex + 6] === 97 /* a */ && array[startIndex + 7] === 99 /* c */ && array[startIndex + 8] === 101 /* e */) ? 52 /* InterfaceKeyword */ : 11 /* IdentifierName */; + case 112 /* p */: + return (array[startIndex + 1] === 114 /* r */ && array[startIndex + 2] === 111 /* o */ && array[startIndex + 3] === 116 /* t */ && array[startIndex + 4] === 101 /* e */ && array[startIndex + 5] === 99 /* c */ && array[startIndex + 6] === 116 /* t */ && array[startIndex + 7] === 101 /* e */ && array[startIndex + 8] === 100 /* d */) ? 56 /* ProtectedKeyword */ : 11 /* IdentifierName */; + default: + return 11 /* IdentifierName */; + } + + case 10: + switch (array[startIndex]) { + case 105 /* i */: + switch (array[startIndex + 1]) { + case 110 /* n */: + return (array[startIndex + 2] === 115 /* s */ && array[startIndex + 3] === 116 /* t */ && array[startIndex + 4] === 97 /* a */ && array[startIndex + 5] === 110 /* n */ && array[startIndex + 6] === 99 /* c */ && array[startIndex + 7] === 101 /* e */ && array[startIndex + 8] === 111 /* o */ && array[startIndex + 9] === 102 /* f */) ? 30 /* InstanceOfKeyword */ : 11 /* IdentifierName */; + case 109 /* m */: + return (array[startIndex + 2] === 112 /* p */ && array[startIndex + 3] === 108 /* l */ && array[startIndex + 4] === 101 /* e */ && array[startIndex + 5] === 109 /* m */ && array[startIndex + 6] === 101 /* e */ && array[startIndex + 7] === 110 /* n */ && array[startIndex + 8] === 116 /* t */ && array[startIndex + 9] === 115 /* s */) ? 51 /* ImplementsKeyword */ : 11 /* IdentifierName */; + default: + return 11 /* IdentifierName */; + } + + default: + return 11 /* IdentifierName */; + } + + case 11: + return (array[startIndex] === 99 /* c */ && array[startIndex + 1] === 111 /* o */ && array[startIndex + 2] === 110 /* n */ && array[startIndex + 3] === 115 /* s */ && array[startIndex + 4] === 116 /* t */ && array[startIndex + 5] === 114 /* r */ && array[startIndex + 6] === 117 /* u */ && array[startIndex + 7] === 99 /* c */ && array[startIndex + 8] === 116 /* t */ && array[startIndex + 9] === 111 /* o */ && array[startIndex + 10] === 114 /* r */) ? 62 /* ConstructorKeyword */ : 11 /* IdentifierName */; + default: + return 11 /* IdentifierName */; + } + }; + return ScannerUtilities; + })(); + TypeScript.ScannerUtilities = ScannerUtilities; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (Syntax) { + var EmptySeparatedSyntaxList = (function () { + function EmptySeparatedSyntaxList() { + } + EmptySeparatedSyntaxList.prototype.kind = function () { + return 2 /* SeparatedList */; + }; + + EmptySeparatedSyntaxList.prototype.isNode = function () { + return false; + }; + + EmptySeparatedSyntaxList.prototype.isToken = function () { + return false; + }; + + EmptySeparatedSyntaxList.prototype.isList = function () { + return false; + }; + + EmptySeparatedSyntaxList.prototype.isSeparatedList = function () { + return true; + }; + + EmptySeparatedSyntaxList.prototype.toJSON = function (key) { + return []; + }; + + EmptySeparatedSyntaxList.prototype.childCount = function () { + return 0; + }; + + EmptySeparatedSyntaxList.prototype.nonSeparatorCount = function () { + return 0; + }; + + EmptySeparatedSyntaxList.prototype.separatorCount = function () { + return 0; + }; + + EmptySeparatedSyntaxList.prototype.toArray = function () { + return []; + }; + + EmptySeparatedSyntaxList.prototype.toNonSeparatorArray = function () { + return []; + }; + + EmptySeparatedSyntaxList.prototype.childAt = function (index) { + throw TypeScript.Errors.argumentOutOfRange("index"); + }; + + EmptySeparatedSyntaxList.prototype.nonSeparatorAt = function (index) { + throw TypeScript.Errors.argumentOutOfRange("index"); + }; + + EmptySeparatedSyntaxList.prototype.separatorAt = function (index) { + throw TypeScript.Errors.argumentOutOfRange("index"); + }; + + EmptySeparatedSyntaxList.prototype.collectTextElements = function (elements) { + }; + + EmptySeparatedSyntaxList.prototype.firstToken = function () { + return null; + }; + + EmptySeparatedSyntaxList.prototype.lastToken = function () { + return null; + }; + + EmptySeparatedSyntaxList.prototype.fullWidth = function () { + return 0; + }; + + EmptySeparatedSyntaxList.prototype.fullText = function () { + return ""; + }; + + EmptySeparatedSyntaxList.prototype.width = function () { + return 0; + }; + + EmptySeparatedSyntaxList.prototype.isTypeScriptSpecific = function () { + return false; + }; + + EmptySeparatedSyntaxList.prototype.isIncrementallyUnusable = function () { + return false; + }; + + EmptySeparatedSyntaxList.prototype.findTokenInternal = function (parent, position, fullStart) { + throw TypeScript.Errors.invalidOperation(); + }; + + EmptySeparatedSyntaxList.prototype.insertChildrenInto = function (array, index) { + }; + + EmptySeparatedSyntaxList.prototype.leadingTrivia = function () { + return Syntax.emptyTriviaList; + }; + + EmptySeparatedSyntaxList.prototype.trailingTrivia = function () { + return Syntax.emptyTriviaList; + }; + + EmptySeparatedSyntaxList.prototype.leadingTriviaWidth = function () { + return 0; + }; + + EmptySeparatedSyntaxList.prototype.trailingTriviaWidth = function () { + return 0; + }; + return EmptySeparatedSyntaxList; + })(); + + Syntax.emptySeparatedList = new EmptySeparatedSyntaxList(); + + var SingletonSeparatedSyntaxList = (function () { + function SingletonSeparatedSyntaxList(item) { + this.item = item; + } + SingletonSeparatedSyntaxList.prototype.toJSON = function (key) { + return [this.item]; + }; + + SingletonSeparatedSyntaxList.prototype.kind = function () { + return 2 /* SeparatedList */; + }; + + SingletonSeparatedSyntaxList.prototype.isNode = function () { + return false; + }; + SingletonSeparatedSyntaxList.prototype.isToken = function () { + return false; + }; + SingletonSeparatedSyntaxList.prototype.isList = function () { + return false; + }; + SingletonSeparatedSyntaxList.prototype.isSeparatedList = function () { + return true; + }; + + SingletonSeparatedSyntaxList.prototype.childCount = function () { + return 1; + }; + SingletonSeparatedSyntaxList.prototype.nonSeparatorCount = function () { + return 1; + }; + SingletonSeparatedSyntaxList.prototype.separatorCount = function () { + return 0; + }; + + SingletonSeparatedSyntaxList.prototype.toArray = function () { + return [this.item]; + }; + SingletonSeparatedSyntaxList.prototype.toNonSeparatorArray = function () { + return [this.item]; + }; + + SingletonSeparatedSyntaxList.prototype.childAt = function (index) { + if (index !== 0) { + throw TypeScript.Errors.argumentOutOfRange("index"); + } + + return this.item; + }; + + SingletonSeparatedSyntaxList.prototype.nonSeparatorAt = function (index) { + if (index !== 0) { + throw TypeScript.Errors.argumentOutOfRange("index"); + } + + return this.item; + }; + + SingletonSeparatedSyntaxList.prototype.separatorAt = function (index) { + throw TypeScript.Errors.argumentOutOfRange("index"); + }; + + SingletonSeparatedSyntaxList.prototype.collectTextElements = function (elements) { + this.item.collectTextElements(elements); + }; + + SingletonSeparatedSyntaxList.prototype.firstToken = function () { + return this.item.firstToken(); + }; + + SingletonSeparatedSyntaxList.prototype.lastToken = function () { + return this.item.lastToken(); + }; + + SingletonSeparatedSyntaxList.prototype.fullWidth = function () { + return this.item.fullWidth(); + }; + + SingletonSeparatedSyntaxList.prototype.width = function () { + return this.item.width(); + }; + + SingletonSeparatedSyntaxList.prototype.fullText = function () { + return this.item.fullText(); + }; + + SingletonSeparatedSyntaxList.prototype.leadingTrivia = function () { + return this.item.leadingTrivia(); + }; + + SingletonSeparatedSyntaxList.prototype.trailingTrivia = function () { + return this.item.trailingTrivia(); + }; + + SingletonSeparatedSyntaxList.prototype.leadingTriviaWidth = function () { + return this.item.leadingTriviaWidth(); + }; + + SingletonSeparatedSyntaxList.prototype.trailingTriviaWidth = function () { + return this.item.trailingTriviaWidth(); + }; + + SingletonSeparatedSyntaxList.prototype.isTypeScriptSpecific = function () { + return this.item.isTypeScriptSpecific(); + }; + + SingletonSeparatedSyntaxList.prototype.isIncrementallyUnusable = function () { + return this.item.isIncrementallyUnusable(); + }; + + SingletonSeparatedSyntaxList.prototype.findTokenInternal = function (parent, position, fullStart) { + return (this.item).findTokenInternal(new TypeScript.PositionedSeparatedList(parent, this, fullStart), position, fullStart); + }; + + SingletonSeparatedSyntaxList.prototype.insertChildrenInto = function (array, index) { + array.splice(index, 0, this.item); + }; + return SingletonSeparatedSyntaxList; + })(); + + var NormalSeparatedSyntaxList = (function () { + function NormalSeparatedSyntaxList(elements) { + this._data = 0; + this.elements = elements; + } + NormalSeparatedSyntaxList.prototype.kind = function () { + return 2 /* SeparatedList */; + }; + + NormalSeparatedSyntaxList.prototype.isToken = function () { + return false; + }; + NormalSeparatedSyntaxList.prototype.isNode = function () { + return false; + }; + NormalSeparatedSyntaxList.prototype.isList = function () { + return false; + }; + NormalSeparatedSyntaxList.prototype.isSeparatedList = function () { + return true; + }; + NormalSeparatedSyntaxList.prototype.toJSON = function (key) { + return this.elements; + }; + + NormalSeparatedSyntaxList.prototype.childCount = function () { + return this.elements.length; + }; + NormalSeparatedSyntaxList.prototype.nonSeparatorCount = function () { + return TypeScript.IntegerUtilities.integerDivide(this.elements.length + 1, 2); + }; + NormalSeparatedSyntaxList.prototype.separatorCount = function () { + return TypeScript.IntegerUtilities.integerDivide(this.elements.length, 2); + }; + + NormalSeparatedSyntaxList.prototype.toArray = function () { + return this.elements.slice(0); + }; + + NormalSeparatedSyntaxList.prototype.toNonSeparatorArray = function () { + var result = []; + for (var i = 0, n = this.nonSeparatorCount(); i < n; i++) { + result.push(this.nonSeparatorAt(i)); + } + + return result; + }; + + NormalSeparatedSyntaxList.prototype.childAt = function (index) { + if (index < 0 || index >= this.elements.length) { + throw TypeScript.Errors.argumentOutOfRange("index"); + } + + return this.elements[index]; + }; + + NormalSeparatedSyntaxList.prototype.nonSeparatorAt = function (index) { + var value = index * 2; + if (value < 0 || value >= this.elements.length) { + throw TypeScript.Errors.argumentOutOfRange("index"); + } + + return this.elements[value]; + }; + + NormalSeparatedSyntaxList.prototype.separatorAt = function (index) { + var value = index * 2 + 1; + if (value < 0 || value >= this.elements.length) { + throw TypeScript.Errors.argumentOutOfRange("index"); + } + + return this.elements[value]; + }; + + NormalSeparatedSyntaxList.prototype.firstToken = function () { + var token; + for (var i = 0, n = this.elements.length; i < n; i++) { + if (i % 2 === 0) { + var nodeOrToken = this.elements[i]; + token = nodeOrToken.firstToken(); + if (token !== null) { + return token; + } + } else { + token = this.elements[i]; + if (token.width() > 0) { + return token; + } + } + } + + return null; + }; + + NormalSeparatedSyntaxList.prototype.lastToken = function () { + var token; + for (var i = this.elements.length - 1; i >= 0; i--) { + if (i % 2 === 0) { + var nodeOrToken = this.elements[i]; + token = nodeOrToken.lastToken(); + if (token !== null) { + return token; + } + } else { + token = this.elements[i]; + if (token.width() > 0) { + return token; + } + } + } + + return null; + }; + + NormalSeparatedSyntaxList.prototype.fullText = function () { + var elements = []; + this.collectTextElements(elements); + return elements.join(""); + }; + + NormalSeparatedSyntaxList.prototype.isTypeScriptSpecific = function () { + for (var i = 0, n = this.nonSeparatorCount(); i < n; i++) { + if (this.nonSeparatorAt(i).isTypeScriptSpecific()) { + return true; + } + } + + return false; + }; + + NormalSeparatedSyntaxList.prototype.isIncrementallyUnusable = function () { + return (this.data() & 2 /* NodeIncrementallyUnusableMask */) !== 0; + }; + + NormalSeparatedSyntaxList.prototype.fullWidth = function () { + return this.data() >>> 3 /* NodeFullWidthShift */; + }; + + NormalSeparatedSyntaxList.prototype.width = function () { + var fullWidth = this.fullWidth(); + return fullWidth - this.leadingTriviaWidth() - this.trailingTriviaWidth(); + }; + + NormalSeparatedSyntaxList.prototype.leadingTrivia = function () { + return this.firstToken().leadingTrivia(); + }; + + NormalSeparatedSyntaxList.prototype.trailingTrivia = function () { + return this.lastToken().trailingTrivia(); + }; + + NormalSeparatedSyntaxList.prototype.leadingTriviaWidth = function () { + return this.firstToken().leadingTriviaWidth(); + }; + + NormalSeparatedSyntaxList.prototype.trailingTriviaWidth = function () { + return this.lastToken().trailingTriviaWidth(); + }; + + NormalSeparatedSyntaxList.prototype.computeData = function () { + var fullWidth = 0; + var isIncrementallyUnusable = false; + + for (var i = 0, n = this.elements.length; i < n; i++) { + var element = this.elements[i]; + + var childWidth = element.fullWidth(); + fullWidth += childWidth; + + isIncrementallyUnusable = isIncrementallyUnusable || element.isIncrementallyUnusable(); + } + + return (fullWidth << 3 /* NodeFullWidthShift */) | (isIncrementallyUnusable ? 2 /* NodeIncrementallyUnusableMask */ : 0) | 1 /* NodeDataComputed */; + }; + + NormalSeparatedSyntaxList.prototype.data = function () { + if ((this._data & 1 /* NodeDataComputed */) === 0) { + this._data = this.computeData(); + } + + return this._data; + }; + + NormalSeparatedSyntaxList.prototype.findTokenInternal = function (parent, position, fullStart) { + parent = new TypeScript.PositionedSeparatedList(parent, this, fullStart); + for (var i = 0, n = this.elements.length; i < n; i++) { + var element = this.elements[i]; + + var childWidth = element.fullWidth(); + if (position < childWidth) { + return (element).findTokenInternal(parent, position, fullStart); + } + + position -= childWidth; + fullStart += childWidth; + } + + throw TypeScript.Errors.invalidOperation(); + }; + + NormalSeparatedSyntaxList.prototype.collectTextElements = function (elements) { + for (var i = 0, n = this.elements.length; i < n; i++) { + var element = this.elements[i]; + element.collectTextElements(elements); + } + }; + + NormalSeparatedSyntaxList.prototype.insertChildrenInto = function (array, index) { + if (index === 0) { + array.unshift.apply(array, this.elements); + } else { + array.splice.apply(array, [index, 0].concat(this.elements)); + } + }; + return NormalSeparatedSyntaxList; + })(); + + function separatedList(nodes) { + return separatedListAndValidate(nodes, false); + } + Syntax.separatedList = separatedList; + + function separatedListAndValidate(nodes, validate) { + if (nodes === undefined || nodes === null || nodes.length === 0) { + return Syntax.emptySeparatedList; + } + + if (validate) { + for (var i = 0; i < nodes.length; i++) { + var item = nodes[i]; + + if (i % 2 === 1) { + } + } + } + + if (nodes.length === 1) { + return new SingletonSeparatedSyntaxList(nodes[0]); + } + + return new NormalSeparatedSyntaxList(nodes); + } + })(TypeScript.Syntax || (TypeScript.Syntax = {})); + var Syntax = TypeScript.Syntax; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var SlidingWindow = (function () { + function SlidingWindow(source, window, defaultValue, sourceLength) { + if (typeof sourceLength === "undefined") { sourceLength = -1; } + this.source = source; + this.window = window; + this.defaultValue = defaultValue; + this.sourceLength = sourceLength; + this.windowCount = 0; + this.windowAbsoluteStartIndex = 0; + this.currentRelativeItemIndex = 0; + this._pinCount = 0; + this.firstPinnedAbsoluteIndex = -1; + } + SlidingWindow.prototype.windowAbsoluteEndIndex = function () { + return this.windowAbsoluteStartIndex + this.windowCount; + }; + + SlidingWindow.prototype.addMoreItemsToWindow = function (argument) { + if (this.sourceLength >= 0 && this.absoluteIndex() >= this.sourceLength) { + return false; + } + + if (this.windowCount >= this.window.length) { + this.tryShiftOrGrowWindow(); + } + + var spaceAvailable = this.window.length - this.windowCount; + var amountFetched = this.source.fetchMoreItems(argument, this.windowAbsoluteEndIndex(), this.window, this.windowCount, spaceAvailable); + + this.windowCount += amountFetched; + return amountFetched > 0; + }; + + SlidingWindow.prototype.tryShiftOrGrowWindow = function () { + var currentIndexIsPastWindowHalfwayPoint = this.currentRelativeItemIndex > (this.window.length >>> 1); + + var isAllowedToShift = this.firstPinnedAbsoluteIndex === -1 || this.firstPinnedAbsoluteIndex > this.windowAbsoluteStartIndex; + + if (currentIndexIsPastWindowHalfwayPoint && isAllowedToShift) { + var shiftStartIndex = this.firstPinnedAbsoluteIndex === -1 ? this.currentRelativeItemIndex : this.firstPinnedAbsoluteIndex - this.windowAbsoluteStartIndex; + + var shiftCount = this.windowCount - shiftStartIndex; + + if (shiftCount > 0) { + TypeScript.ArrayUtilities.copy(this.window, shiftStartIndex, this.window, 0, shiftCount); + } + + this.windowAbsoluteStartIndex += shiftStartIndex; + + this.windowCount -= shiftStartIndex; + + this.currentRelativeItemIndex -= shiftStartIndex; + } else { + TypeScript.ArrayUtilities.grow(this.window, this.window.length * 2, this.defaultValue); + } + }; + + SlidingWindow.prototype.absoluteIndex = function () { + return this.windowAbsoluteStartIndex + this.currentRelativeItemIndex; + }; + + SlidingWindow.prototype.isAtEndOfSource = function () { + return this.absoluteIndex() >= this.sourceLength; + }; + + SlidingWindow.prototype.getAndPinAbsoluteIndex = function () { + var absoluteIndex = this.absoluteIndex(); + var pinCount = this._pinCount++; + if (pinCount === 0) { + this.firstPinnedAbsoluteIndex = absoluteIndex; + } + + return absoluteIndex; + }; + + SlidingWindow.prototype.releaseAndUnpinAbsoluteIndex = function (absoluteIndex) { + this._pinCount--; + if (this._pinCount === 0) { + this.firstPinnedAbsoluteIndex = -1; + } + }; + + SlidingWindow.prototype.rewindToPinnedIndex = function (absoluteIndex) { + var relativeIndex = absoluteIndex - this.windowAbsoluteStartIndex; + + this.currentRelativeItemIndex = relativeIndex; + }; + + SlidingWindow.prototype.currentItem = function (argument) { + if (this.currentRelativeItemIndex >= this.windowCount) { + if (!this.addMoreItemsToWindow(argument)) { + return this.defaultValue; + } + } + + return this.window[this.currentRelativeItemIndex]; + }; + + SlidingWindow.prototype.peekItemN = function (n) { + while (this.currentRelativeItemIndex + n >= this.windowCount) { + if (!this.addMoreItemsToWindow(null)) { + return this.defaultValue; + } + } + + return this.window[this.currentRelativeItemIndex + n]; + }; + + SlidingWindow.prototype.moveToNextItem = function () { + this.currentRelativeItemIndex++; + }; + + SlidingWindow.prototype.disgardAllItemsFromCurrentIndexOnwards = function () { + this.windowCount = this.currentRelativeItemIndex; + }; + + SlidingWindow.prototype.setAbsoluteIndex = function (absoluteIndex) { + if (this.absoluteIndex() === absoluteIndex) { + return; + } + + if (this._pinCount > 0) { + } + + if (absoluteIndex >= this.windowAbsoluteStartIndex && absoluteIndex < this.windowAbsoluteEndIndex()) { + this.currentRelativeItemIndex = (absoluteIndex - this.windowAbsoluteStartIndex); + } else { + this.windowAbsoluteStartIndex = absoluteIndex; + + this.windowCount = 0; + + this.currentRelativeItemIndex = 0; + } + }; + + SlidingWindow.prototype.pinCount = function () { + return this._pinCount; + }; + return SlidingWindow; + })(); + TypeScript.SlidingWindow = SlidingWindow; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (Syntax) { + function emptySourceUnit() { + return TypeScript.Syntax.normalModeFactory.sourceUnit(TypeScript.Syntax.emptyList, TypeScript.Syntax.token(10 /* EndOfFileToken */, { text: "" })); + } + Syntax.emptySourceUnit = emptySourceUnit; + + function getStandaloneExpression(positionedToken) { + var token = positionedToken.token(); + if (positionedToken !== null && positionedToken.kind() === 11 /* IdentifierName */) { + var parentPositionedNode = positionedToken.containingNode(); + var parentNode = parentPositionedNode.node(); + + if (parentNode.kind() === 121 /* QualifiedName */ && (parentNode).right === token) { + return parentPositionedNode; + } else if (parentNode.kind() === 211 /* MemberAccessExpression */ && (parentNode).name === token) { + return parentPositionedNode; + } + } + + return positionedToken; + } + Syntax.getStandaloneExpression = getStandaloneExpression; + + function isInModuleOrTypeContext(positionedToken) { + if (positionedToken !== null) { + var positionedNodeOrToken = TypeScript.Syntax.getStandaloneExpression(positionedToken); + var parent = positionedNodeOrToken.containingNode(); + + if (parent !== null) { + switch (parent.kind()) { + case 246 /* ModuleNameModuleReference */: + return true; + case 121 /* QualifiedName */: + return true; + default: + return isInTypeOnlyContext(positionedToken); + } + } + } + + return false; + } + Syntax.isInModuleOrTypeContext = isInModuleOrTypeContext; + + function isInTypeOnlyContext(positionedToken) { + var positionedNodeOrToken = TypeScript.Syntax.getStandaloneExpression(positionedToken); + var positionedParent = positionedNodeOrToken.containingNode(); + + var parent = positionedParent.node(); + var nodeOrToken = positionedNodeOrToken.nodeOrToken(); + + if (parent !== null) { + switch (parent.kind()) { + case 124 /* ArrayType */: + return (parent).type === nodeOrToken; + case 219 /* CastExpression */: + return (parent).type === nodeOrToken; + case 244 /* TypeAnnotation */: + case 229 /* HeritageClause */: + case 227 /* TypeArgumentList */: + return true; + } + } + + return false; + } + Syntax.isInTypeOnlyContext = isInTypeOnlyContext; + + function childOffset(parent, child) { + var offset = 0; + for (var i = 0, n = parent.childCount(); i < n; i++) { + var current = parent.childAt(i); + if (current === child) { + return offset; + } + + if (current !== null) { + offset += current.fullWidth(); + } + } + + throw TypeScript.Errors.invalidOperation(); + } + Syntax.childOffset = childOffset; + + function childOffsetAt(parent, index) { + var offset = 0; + for (var i = 0; i < index; i++) { + var current = parent.childAt(i); + if (current !== null) { + offset += current.fullWidth(); + } + } + + return offset; + } + Syntax.childOffsetAt = childOffsetAt; + + function childIndex(parent, child) { + for (var i = 0, n = parent.childCount(); i < n; i++) { + var current = parent.childAt(i); + if (current === child) { + return i; + } + } + + throw TypeScript.Errors.invalidOperation(); + } + Syntax.childIndex = childIndex; + + function nodeStructuralEquals(node1, node2) { + if (node1 === null) { + return node2 === null; + } + + return node1.structuralEquals(node2); + } + Syntax.nodeStructuralEquals = nodeStructuralEquals; + + function nodeOrTokenStructuralEquals(node1, node2) { + if (node1 === node2) { + return true; + } + + if (node1 === null || node2 === null) { + return false; + } + + if (node1.isToken()) { + return node2.isToken() ? tokenStructuralEquals(node1, node2) : false; + } + + return node2.isNode() ? nodeStructuralEquals(node1, node2) : false; + } + Syntax.nodeOrTokenStructuralEquals = nodeOrTokenStructuralEquals; + + function tokenStructuralEquals(token1, token2) { + if (token1 === token2) { + return true; + } + + if (token1 === null || token2 === null) { + return false; + } + + return token1.kind() === token2.kind() && token1.width() === token2.width() && token1.fullWidth() === token2.fullWidth() && token1.text() === token2.text() && TypeScript.Syntax.triviaListStructuralEquals(token1.leadingTrivia(), token2.leadingTrivia()) && TypeScript.Syntax.triviaListStructuralEquals(token1.trailingTrivia(), token2.trailingTrivia()); + } + Syntax.tokenStructuralEquals = tokenStructuralEquals; + + function triviaListStructuralEquals(triviaList1, triviaList2) { + if (triviaList1.count() !== triviaList2.count()) { + return false; + } + + for (var i = 0, n = triviaList1.count(); i < n; i++) { + if (!TypeScript.Syntax.triviaStructuralEquals(triviaList1.syntaxTriviaAt(i), triviaList2.syntaxTriviaAt(i))) { + return false; + } + } + + return true; + } + Syntax.triviaListStructuralEquals = triviaListStructuralEquals; + + function triviaStructuralEquals(trivia1, trivia2) { + return trivia1.kind() === trivia2.kind() && trivia1.fullWidth() === trivia2.fullWidth() && trivia1.fullText() === trivia2.fullText(); + } + Syntax.triviaStructuralEquals = triviaStructuralEquals; + + function listStructuralEquals(list1, list2) { + if (list1.childCount() !== list2.childCount()) { + return false; + } + + for (var i = 0, n = list1.childCount(); i < n; i++) { + var child1 = list1.childAt(i); + var child2 = list2.childAt(i); + + if (!TypeScript.Syntax.nodeOrTokenStructuralEquals(child1, child2)) { + return false; + } + } + + return true; + } + Syntax.listStructuralEquals = listStructuralEquals; + + function separatedListStructuralEquals(list1, list2) { + if (list1.childCount() !== list2.childCount()) { + return false; + } + + for (var i = 0, n = list1.childCount(); i < n; i++) { + var element1 = list1.childAt(i); + var element2 = list2.childAt(i); + if (!TypeScript.Syntax.nodeOrTokenStructuralEquals(element1, element2)) { + return false; + } + } + + return true; + } + Syntax.separatedListStructuralEquals = separatedListStructuralEquals; + + function elementStructuralEquals(element1, element2) { + if (element1 === element2) { + return true; + } + + if (element1 === null || element2 === null) { + return false; + } + + if (element2.kind() !== element2.kind()) { + return false; + } + + if (element1.isToken()) { + return tokenStructuralEquals(element1, element2); + } else if (element1.isNode()) { + return nodeStructuralEquals(element1, element2); + } else if (element1.isList()) { + return listStructuralEquals(element1, element2); + } else if (element1.isSeparatedList()) { + return separatedListStructuralEquals(element1, element2); + } + + throw TypeScript.Errors.invalidOperation(); + } + Syntax.elementStructuralEquals = elementStructuralEquals; + + function identifierName(text, info) { + if (typeof info === "undefined") { info = null; } + return Syntax.identifier(text); + } + Syntax.identifierName = identifierName; + + function trueExpression() { + return TypeScript.Syntax.token(37 /* TrueKeyword */); + } + Syntax.trueExpression = trueExpression; + + function falseExpression() { + return TypeScript.Syntax.token(24 /* FalseKeyword */); + } + Syntax.falseExpression = falseExpression; + + function numericLiteralExpression(text) { + return TypeScript.Syntax.token(13 /* NumericLiteral */, { text: text }); + } + Syntax.numericLiteralExpression = numericLiteralExpression; + + function stringLiteralExpression(text) { + return TypeScript.Syntax.token(14 /* StringLiteral */, { text: text }); + } + Syntax.stringLiteralExpression = stringLiteralExpression; + + function isSuperInvocationExpression(node) { + return node.kind() === 212 /* InvocationExpression */ && (node).expression.kind() === 50 /* SuperKeyword */; + } + Syntax.isSuperInvocationExpression = isSuperInvocationExpression; + + function isSuperInvocationExpressionStatement(node) { + return node.kind() === 148 /* ExpressionStatement */ && isSuperInvocationExpression((node).expression); + } + Syntax.isSuperInvocationExpressionStatement = isSuperInvocationExpressionStatement; + + function isSuperMemberAccessExpression(node) { + return node.kind() === 211 /* MemberAccessExpression */ && (node).expression.kind() === 50 /* SuperKeyword */; + } + Syntax.isSuperMemberAccessExpression = isSuperMemberAccessExpression; + + function isSuperMemberAccessInvocationExpression(node) { + return node.kind() === 212 /* InvocationExpression */ && isSuperMemberAccessExpression((node).expression); + } + Syntax.isSuperMemberAccessInvocationExpression = isSuperMemberAccessInvocationExpression; + + function assignmentExpression(left, token, right) { + return TypeScript.Syntax.normalModeFactory.binaryExpression(173 /* AssignmentExpression */, left, token, right); + } + Syntax.assignmentExpression = assignmentExpression; + + function nodeHasSkippedOrMissingTokens(node) { + for (var i = 0; i < node.childCount(); i++) { + var child = node.childAt(i); + if (child !== null && child.isToken()) { + var token = child; + + if (token.hasSkippedToken() || (token.width() === 0 && token.kind() !== 10 /* EndOfFileToken */)) { + return true; + } + } + } + return false; + } + Syntax.nodeHasSkippedOrMissingTokens = nodeHasSkippedOrMissingTokens; + + function isUnterminatedStringLiteral(token) { + if (token && token.kind() === 14 /* StringLiteral */) { + var text = token.text(); + return text.length < 2 || text.charCodeAt(text.length - 1) !== text.charCodeAt(0); + } + + return false; + } + Syntax.isUnterminatedStringLiteral = isUnterminatedStringLiteral; + + function isUnterminatedMultilineCommentTrivia(trivia) { + if (trivia && trivia.kind() === 6 /* MultiLineCommentTrivia */) { + var text = trivia.fullText(); + return text.length < 4 || text.substring(text.length - 2) !== "*/"; + } + return false; + } + Syntax.isUnterminatedMultilineCommentTrivia = isUnterminatedMultilineCommentTrivia; + + function isEntirelyInsideCommentTrivia(trivia, fullStart, position) { + if (trivia && trivia.isComment() && position > fullStart) { + var end = fullStart + trivia.fullWidth(); + if (position < end) { + return true; + } else if (position === end) { + return trivia.kind() === 7 /* SingleLineCommentTrivia */ || isUnterminatedMultilineCommentTrivia(trivia); + } + } + + return false; + } + Syntax.isEntirelyInsideCommentTrivia = isEntirelyInsideCommentTrivia; + + function isEntirelyInsideComment(sourceUnit, position) { + var positionedToken = sourceUnit.findToken(position); + var fullStart = positionedToken.fullStart(); + var triviaList = null; + var lastTriviaBeforeToken = null; + + if (positionedToken.kind() === 10 /* EndOfFileToken */) { + if (positionedToken.token().hasLeadingTrivia()) { + triviaList = positionedToken.token().leadingTrivia(); + } else { + positionedToken = positionedToken.previousToken(); + if (positionedToken) { + if (positionedToken && positionedToken.token().hasTrailingTrivia()) { + triviaList = positionedToken.token().trailingTrivia(); + fullStart = positionedToken.end(); + } + } + } + } else { + if (position <= (fullStart + positionedToken.token().leadingTriviaWidth())) { + triviaList = positionedToken.token().leadingTrivia(); + } else if (position >= (fullStart + positionedToken.token().width())) { + triviaList = positionedToken.token().trailingTrivia(); + fullStart = positionedToken.end(); + } + } + + if (triviaList) { + for (var i = 0, n = triviaList.count(); i < n; i++) { + var trivia = triviaList.syntaxTriviaAt(i); + if (position <= fullStart) { + break; + } else if (position <= fullStart + trivia.fullWidth() && trivia.isComment()) { + lastTriviaBeforeToken = trivia; + break; + } + + fullStart += trivia.fullWidth(); + } + } + + return lastTriviaBeforeToken && isEntirelyInsideCommentTrivia(lastTriviaBeforeToken, fullStart, position); + } + Syntax.isEntirelyInsideComment = isEntirelyInsideComment; + + function isEntirelyInStringOrRegularExpressionLiteral(sourceUnit, position) { + var positionedToken = sourceUnit.findToken(position); + + if (positionedToken) { + if (positionedToken.kind() === 10 /* EndOfFileToken */) { + positionedToken = positionedToken.previousToken(); + return positionedToken && positionedToken.token().trailingTriviaWidth() === 0 && isUnterminatedStringLiteral(positionedToken.token()); + } else if (position > positionedToken.start()) { + return (position < positionedToken.end() && (positionedToken.kind() === 14 /* StringLiteral */ || positionedToken.kind() === 12 /* RegularExpressionLiteral */)) || (position <= positionedToken.end() && isUnterminatedStringLiteral(positionedToken.token())); + } + } + + return false; + } + Syntax.isEntirelyInStringOrRegularExpressionLiteral = isEntirelyInStringOrRegularExpressionLiteral; + + function findSkippedTokenInTriviaList(positionedToken, position, lookInLeadingTriviaList) { + var triviaList = null; + var fullStart; + + if (lookInLeadingTriviaList) { + triviaList = positionedToken.token().leadingTrivia(); + fullStart = positionedToken.fullStart(); + } else { + triviaList = positionedToken.token().trailingTrivia(); + fullStart = positionedToken.end(); + } + + if (triviaList && triviaList.hasSkippedToken()) { + for (var i = 0, n = triviaList.count(); i < n; i++) { + var trivia = triviaList.syntaxTriviaAt(i); + var triviaWidth = trivia.fullWidth(); + + if (trivia.isSkippedToken() && position >= fullStart && position <= fullStart + triviaWidth) { + return new TypeScript.PositionedSkippedToken(positionedToken, trivia.skippedToken(), fullStart); + } + + fullStart += triviaWidth; + } + } + + return null; + } + + function findSkippedTokenOnLeftInTriviaList(positionedToken, position, lookInLeadingTriviaList) { + var triviaList = null; + var fullEnd; + + if (lookInLeadingTriviaList) { + triviaList = positionedToken.token().leadingTrivia(); + fullEnd = positionedToken.fullStart() + triviaList.fullWidth(); + } else { + triviaList = positionedToken.token().trailingTrivia(); + fullEnd = positionedToken.fullEnd(); + } + + if (triviaList && triviaList.hasSkippedToken()) { + for (var i = triviaList.count() - 1; i >= 0; i--) { + var trivia = triviaList.syntaxTriviaAt(i); + var triviaWidth = trivia.fullWidth(); + + if (trivia.isSkippedToken() && position >= fullEnd) { + return new TypeScript.PositionedSkippedToken(positionedToken, trivia.skippedToken(), fullEnd - triviaWidth); + } + + fullEnd -= triviaWidth; + } + } + + return null; + } + + function findSkippedTokenInLeadingTriviaList(positionedToken, position) { + return findSkippedTokenInTriviaList(positionedToken, position, true); + } + Syntax.findSkippedTokenInLeadingTriviaList = findSkippedTokenInLeadingTriviaList; + + function findSkippedTokenInTrailingTriviaList(positionedToken, position) { + return findSkippedTokenInTriviaList(positionedToken, position, false); + } + Syntax.findSkippedTokenInTrailingTriviaList = findSkippedTokenInTrailingTriviaList; + + function findSkippedTokenInPositionedToken(positionedToken, position) { + var positionInLeadingTriviaList = (position < positionedToken.start()); + return findSkippedTokenInTriviaList(positionedToken, position, positionInLeadingTriviaList); + } + Syntax.findSkippedTokenInPositionedToken = findSkippedTokenInPositionedToken; + + function findSkippedTokenOnLeft(positionedToken, position) { + var positionInLeadingTriviaList = (position < positionedToken.start()); + return findSkippedTokenOnLeftInTriviaList(positionedToken, position, positionInLeadingTriviaList); + } + Syntax.findSkippedTokenOnLeft = findSkippedTokenOnLeft; + + function getAncestorOfKind(positionedToken, kind) { + while (positionedToken && positionedToken.parent()) { + if (positionedToken.parent().kind() === kind) { + return positionedToken.parent(); + } + + positionedToken = positionedToken.parent(); + } + + return null; + } + Syntax.getAncestorOfKind = getAncestorOfKind; + + function hasAncestorOfKind(positionedToken, kind) { + return TypeScript.Syntax.getAncestorOfKind(positionedToken, kind) !== null; + } + Syntax.hasAncestorOfKind = hasAncestorOfKind; + + function isIntegerLiteral(expression) { + if (expression) { + switch (expression.kind()) { + case 163 /* PlusExpression */: + case 164 /* NegateExpression */: + expression = (expression).operand; + return isInteger((expression).text()); + + case 13 /* NumericLiteral */: + var text = (expression).text(); + return isInteger(text) || isHexInteger(text); + } + } + + return false; + } + Syntax.isIntegerLiteral = isIntegerLiteral; + + function isInteger(text) { + return /^[0-9]+$/.test(text); + } + + function isHexInteger(text) { + return /^0(x|X)[0-9a-fA-F]+$/.test(text); + } + Syntax.isHexInteger = isHexInteger; + })(TypeScript.Syntax || (TypeScript.Syntax = {})); + var Syntax = TypeScript.Syntax; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (Syntax) { + var NormalModeFactory = (function () { + function NormalModeFactory() { + } + NormalModeFactory.prototype.sourceUnit = function (moduleElements, endOfFileToken) { + return new TypeScript.SourceUnitSyntax(moduleElements, endOfFileToken, false); + }; + NormalModeFactory.prototype.externalModuleReference = function (requireKeyword, openParenToken, stringLiteral, closeParenToken) { + return new TypeScript.ExternalModuleReferenceSyntax(requireKeyword, openParenToken, stringLiteral, closeParenToken, false); + }; + NormalModeFactory.prototype.moduleNameModuleReference = function (moduleName) { + return new TypeScript.ModuleNameModuleReferenceSyntax(moduleName, false); + }; + NormalModeFactory.prototype.importDeclaration = function (modifiers, importKeyword, identifier, equalsToken, moduleReference, semicolonToken) { + return new TypeScript.ImportDeclarationSyntax(modifiers, importKeyword, identifier, equalsToken, moduleReference, semicolonToken, false); + }; + NormalModeFactory.prototype.exportAssignment = function (exportKeyword, equalsToken, identifier, semicolonToken) { + return new TypeScript.ExportAssignmentSyntax(exportKeyword, equalsToken, identifier, semicolonToken, false); + }; + NormalModeFactory.prototype.classDeclaration = function (modifiers, classKeyword, identifier, typeParameterList, heritageClauses, openBraceToken, classElements, closeBraceToken) { + return new TypeScript.ClassDeclarationSyntax(modifiers, classKeyword, identifier, typeParameterList, heritageClauses, openBraceToken, classElements, closeBraceToken, false); + }; + NormalModeFactory.prototype.interfaceDeclaration = function (modifiers, interfaceKeyword, identifier, typeParameterList, heritageClauses, body) { + return new TypeScript.InterfaceDeclarationSyntax(modifiers, interfaceKeyword, identifier, typeParameterList, heritageClauses, body, false); + }; + NormalModeFactory.prototype.heritageClause = function (extendsOrImplementsKeyword, typeNames) { + return new TypeScript.HeritageClauseSyntax(extendsOrImplementsKeyword, typeNames, false); + }; + NormalModeFactory.prototype.moduleDeclaration = function (modifiers, moduleKeyword, moduleName, stringLiteral, openBraceToken, moduleElements, closeBraceToken) { + return new TypeScript.ModuleDeclarationSyntax(modifiers, moduleKeyword, moduleName, stringLiteral, openBraceToken, moduleElements, closeBraceToken, false); + }; + NormalModeFactory.prototype.functionDeclaration = function (modifiers, functionKeyword, identifier, callSignature, block, semicolonToken) { + return new TypeScript.FunctionDeclarationSyntax(modifiers, functionKeyword, identifier, callSignature, block, semicolonToken, false); + }; + NormalModeFactory.prototype.variableStatement = function (modifiers, variableDeclaration, semicolonToken) { + return new TypeScript.VariableStatementSyntax(modifiers, variableDeclaration, semicolonToken, false); + }; + NormalModeFactory.prototype.variableDeclaration = function (varKeyword, variableDeclarators) { + return new TypeScript.VariableDeclarationSyntax(varKeyword, variableDeclarators, false); + }; + NormalModeFactory.prototype.variableDeclarator = function (identifier, typeAnnotation, equalsValueClause) { + return new TypeScript.VariableDeclaratorSyntax(identifier, typeAnnotation, equalsValueClause, false); + }; + NormalModeFactory.prototype.equalsValueClause = function (equalsToken, value) { + return new TypeScript.EqualsValueClauseSyntax(equalsToken, value, false); + }; + NormalModeFactory.prototype.prefixUnaryExpression = function (kind, operatorToken, operand) { + return new TypeScript.PrefixUnaryExpressionSyntax(kind, operatorToken, operand, false); + }; + NormalModeFactory.prototype.arrayLiteralExpression = function (openBracketToken, expressions, closeBracketToken) { + return new TypeScript.ArrayLiteralExpressionSyntax(openBracketToken, expressions, closeBracketToken, false); + }; + NormalModeFactory.prototype.omittedExpression = function () { + return new TypeScript.OmittedExpressionSyntax(false); + }; + NormalModeFactory.prototype.parenthesizedExpression = function (openParenToken, expression, closeParenToken) { + return new TypeScript.ParenthesizedExpressionSyntax(openParenToken, expression, closeParenToken, false); + }; + NormalModeFactory.prototype.simpleArrowFunctionExpression = function (identifier, equalsGreaterThanToken, body) { + return new TypeScript.SimpleArrowFunctionExpressionSyntax(identifier, equalsGreaterThanToken, body, false); + }; + NormalModeFactory.prototype.parenthesizedArrowFunctionExpression = function (callSignature, equalsGreaterThanToken, body) { + return new TypeScript.ParenthesizedArrowFunctionExpressionSyntax(callSignature, equalsGreaterThanToken, body, false); + }; + NormalModeFactory.prototype.qualifiedName = function (left, dotToken, right) { + return new TypeScript.QualifiedNameSyntax(left, dotToken, right, false); + }; + NormalModeFactory.prototype.typeArgumentList = function (lessThanToken, typeArguments, greaterThanToken) { + return new TypeScript.TypeArgumentListSyntax(lessThanToken, typeArguments, greaterThanToken, false); + }; + NormalModeFactory.prototype.constructorType = function (newKeyword, typeParameterList, parameterList, equalsGreaterThanToken, type) { + return new TypeScript.ConstructorTypeSyntax(newKeyword, typeParameterList, parameterList, equalsGreaterThanToken, type, false); + }; + NormalModeFactory.prototype.functionType = function (typeParameterList, parameterList, equalsGreaterThanToken, type) { + return new TypeScript.FunctionTypeSyntax(typeParameterList, parameterList, equalsGreaterThanToken, type, false); + }; + NormalModeFactory.prototype.objectType = function (openBraceToken, typeMembers, closeBraceToken) { + return new TypeScript.ObjectTypeSyntax(openBraceToken, typeMembers, closeBraceToken, false); + }; + NormalModeFactory.prototype.arrayType = function (type, openBracketToken, closeBracketToken) { + return new TypeScript.ArrayTypeSyntax(type, openBracketToken, closeBracketToken, false); + }; + NormalModeFactory.prototype.genericType = function (name, typeArgumentList) { + return new TypeScript.GenericTypeSyntax(name, typeArgumentList, false); + }; + NormalModeFactory.prototype.typeQuery = function (typeOfKeyword, name) { + return new TypeScript.TypeQuerySyntax(typeOfKeyword, name, false); + }; + NormalModeFactory.prototype.typeAnnotation = function (colonToken, type) { + return new TypeScript.TypeAnnotationSyntax(colonToken, type, false); + }; + NormalModeFactory.prototype.block = function (openBraceToken, statements, closeBraceToken) { + return new TypeScript.BlockSyntax(openBraceToken, statements, closeBraceToken, false); + }; + NormalModeFactory.prototype.parameter = function (dotDotDotToken, publicOrPrivateKeyword, identifier, questionToken, typeAnnotation, equalsValueClause) { + return new TypeScript.ParameterSyntax(dotDotDotToken, publicOrPrivateKeyword, identifier, questionToken, typeAnnotation, equalsValueClause, false); + }; + NormalModeFactory.prototype.memberAccessExpression = function (expression, dotToken, name) { + return new TypeScript.MemberAccessExpressionSyntax(expression, dotToken, name, false); + }; + NormalModeFactory.prototype.postfixUnaryExpression = function (kind, operand, operatorToken) { + return new TypeScript.PostfixUnaryExpressionSyntax(kind, operand, operatorToken, false); + }; + NormalModeFactory.prototype.elementAccessExpression = function (expression, openBracketToken, argumentExpression, closeBracketToken) { + return new TypeScript.ElementAccessExpressionSyntax(expression, openBracketToken, argumentExpression, closeBracketToken, false); + }; + NormalModeFactory.prototype.invocationExpression = function (expression, argumentList) { + return new TypeScript.InvocationExpressionSyntax(expression, argumentList, false); + }; + NormalModeFactory.prototype.argumentList = function (typeArgumentList, openParenToken, _arguments, closeParenToken) { + return new TypeScript.ArgumentListSyntax(typeArgumentList, openParenToken, _arguments, closeParenToken, false); + }; + NormalModeFactory.prototype.binaryExpression = function (kind, left, operatorToken, right) { + return new TypeScript.BinaryExpressionSyntax(kind, left, operatorToken, right, false); + }; + NormalModeFactory.prototype.conditionalExpression = function (condition, questionToken, whenTrue, colonToken, whenFalse) { + return new TypeScript.ConditionalExpressionSyntax(condition, questionToken, whenTrue, colonToken, whenFalse, false); + }; + NormalModeFactory.prototype.constructSignature = function (newKeyword, callSignature) { + return new TypeScript.ConstructSignatureSyntax(newKeyword, callSignature, false); + }; + NormalModeFactory.prototype.methodSignature = function (propertyName, questionToken, callSignature) { + return new TypeScript.MethodSignatureSyntax(propertyName, questionToken, callSignature, false); + }; + NormalModeFactory.prototype.indexSignature = function (openBracketToken, parameter, closeBracketToken, typeAnnotation) { + return new TypeScript.IndexSignatureSyntax(openBracketToken, parameter, closeBracketToken, typeAnnotation, false); + }; + NormalModeFactory.prototype.propertySignature = function (propertyName, questionToken, typeAnnotation) { + return new TypeScript.PropertySignatureSyntax(propertyName, questionToken, typeAnnotation, false); + }; + NormalModeFactory.prototype.callSignature = function (typeParameterList, parameterList, typeAnnotation) { + return new TypeScript.CallSignatureSyntax(typeParameterList, parameterList, typeAnnotation, false); + }; + NormalModeFactory.prototype.parameterList = function (openParenToken, parameters, closeParenToken) { + return new TypeScript.ParameterListSyntax(openParenToken, parameters, closeParenToken, false); + }; + NormalModeFactory.prototype.typeParameterList = function (lessThanToken, typeParameters, greaterThanToken) { + return new TypeScript.TypeParameterListSyntax(lessThanToken, typeParameters, greaterThanToken, false); + }; + NormalModeFactory.prototype.typeParameter = function (identifier, constraint) { + return new TypeScript.TypeParameterSyntax(identifier, constraint, false); + }; + NormalModeFactory.prototype.constraint = function (extendsKeyword, type) { + return new TypeScript.ConstraintSyntax(extendsKeyword, type, false); + }; + NormalModeFactory.prototype.elseClause = function (elseKeyword, statement) { + return new TypeScript.ElseClauseSyntax(elseKeyword, statement, false); + }; + NormalModeFactory.prototype.ifStatement = function (ifKeyword, openParenToken, condition, closeParenToken, statement, elseClause) { + return new TypeScript.IfStatementSyntax(ifKeyword, openParenToken, condition, closeParenToken, statement, elseClause, false); + }; + NormalModeFactory.prototype.expressionStatement = function (expression, semicolonToken) { + return new TypeScript.ExpressionStatementSyntax(expression, semicolonToken, false); + }; + NormalModeFactory.prototype.constructorDeclaration = function (constructorKeyword, parameterList, block, semicolonToken) { + return new TypeScript.ConstructorDeclarationSyntax(constructorKeyword, parameterList, block, semicolonToken, false); + }; + NormalModeFactory.prototype.memberFunctionDeclaration = function (modifiers, propertyName, callSignature, block, semicolonToken) { + return new TypeScript.MemberFunctionDeclarationSyntax(modifiers, propertyName, callSignature, block, semicolonToken, false); + }; + NormalModeFactory.prototype.getMemberAccessorDeclaration = function (modifiers, getKeyword, propertyName, parameterList, typeAnnotation, block) { + return new TypeScript.GetMemberAccessorDeclarationSyntax(modifiers, getKeyword, propertyName, parameterList, typeAnnotation, block, false); + }; + NormalModeFactory.prototype.setMemberAccessorDeclaration = function (modifiers, setKeyword, propertyName, parameterList, block) { + return new TypeScript.SetMemberAccessorDeclarationSyntax(modifiers, setKeyword, propertyName, parameterList, block, false); + }; + NormalModeFactory.prototype.memberVariableDeclaration = function (modifiers, variableDeclarator, semicolonToken) { + return new TypeScript.MemberVariableDeclarationSyntax(modifiers, variableDeclarator, semicolonToken, false); + }; + NormalModeFactory.prototype.throwStatement = function (throwKeyword, expression, semicolonToken) { + return new TypeScript.ThrowStatementSyntax(throwKeyword, expression, semicolonToken, false); + }; + NormalModeFactory.prototype.returnStatement = function (returnKeyword, expression, semicolonToken) { + return new TypeScript.ReturnStatementSyntax(returnKeyword, expression, semicolonToken, false); + }; + NormalModeFactory.prototype.objectCreationExpression = function (newKeyword, expression, argumentList) { + return new TypeScript.ObjectCreationExpressionSyntax(newKeyword, expression, argumentList, false); + }; + NormalModeFactory.prototype.switchStatement = function (switchKeyword, openParenToken, expression, closeParenToken, openBraceToken, switchClauses, closeBraceToken) { + return new TypeScript.SwitchStatementSyntax(switchKeyword, openParenToken, expression, closeParenToken, openBraceToken, switchClauses, closeBraceToken, false); + }; + NormalModeFactory.prototype.caseSwitchClause = function (caseKeyword, expression, colonToken, statements) { + return new TypeScript.CaseSwitchClauseSyntax(caseKeyword, expression, colonToken, statements, false); + }; + NormalModeFactory.prototype.defaultSwitchClause = function (defaultKeyword, colonToken, statements) { + return new TypeScript.DefaultSwitchClauseSyntax(defaultKeyword, colonToken, statements, false); + }; + NormalModeFactory.prototype.breakStatement = function (breakKeyword, identifier, semicolonToken) { + return new TypeScript.BreakStatementSyntax(breakKeyword, identifier, semicolonToken, false); + }; + NormalModeFactory.prototype.continueStatement = function (continueKeyword, identifier, semicolonToken) { + return new TypeScript.ContinueStatementSyntax(continueKeyword, identifier, semicolonToken, false); + }; + NormalModeFactory.prototype.forStatement = function (forKeyword, openParenToken, variableDeclaration, initializer, firstSemicolonToken, condition, secondSemicolonToken, incrementor, closeParenToken, statement) { + return new TypeScript.ForStatementSyntax(forKeyword, openParenToken, variableDeclaration, initializer, firstSemicolonToken, condition, secondSemicolonToken, incrementor, closeParenToken, statement, false); + }; + NormalModeFactory.prototype.forInStatement = function (forKeyword, openParenToken, variableDeclaration, left, inKeyword, expression, closeParenToken, statement) { + return new TypeScript.ForInStatementSyntax(forKeyword, openParenToken, variableDeclaration, left, inKeyword, expression, closeParenToken, statement, false); + }; + NormalModeFactory.prototype.whileStatement = function (whileKeyword, openParenToken, condition, closeParenToken, statement) { + return new TypeScript.WhileStatementSyntax(whileKeyword, openParenToken, condition, closeParenToken, statement, false); + }; + NormalModeFactory.prototype.withStatement = function (withKeyword, openParenToken, condition, closeParenToken, statement) { + return new TypeScript.WithStatementSyntax(withKeyword, openParenToken, condition, closeParenToken, statement, false); + }; + NormalModeFactory.prototype.enumDeclaration = function (modifiers, enumKeyword, identifier, openBraceToken, enumElements, closeBraceToken) { + return new TypeScript.EnumDeclarationSyntax(modifiers, enumKeyword, identifier, openBraceToken, enumElements, closeBraceToken, false); + }; + NormalModeFactory.prototype.enumElement = function (propertyName, equalsValueClause) { + return new TypeScript.EnumElementSyntax(propertyName, equalsValueClause, false); + }; + NormalModeFactory.prototype.castExpression = function (lessThanToken, type, greaterThanToken, expression) { + return new TypeScript.CastExpressionSyntax(lessThanToken, type, greaterThanToken, expression, false); + }; + NormalModeFactory.prototype.objectLiteralExpression = function (openBraceToken, propertyAssignments, closeBraceToken) { + return new TypeScript.ObjectLiteralExpressionSyntax(openBraceToken, propertyAssignments, closeBraceToken, false); + }; + NormalModeFactory.prototype.simplePropertyAssignment = function (propertyName, colonToken, expression) { + return new TypeScript.SimplePropertyAssignmentSyntax(propertyName, colonToken, expression, false); + }; + NormalModeFactory.prototype.functionPropertyAssignment = function (propertyName, callSignature, block) { + return new TypeScript.FunctionPropertyAssignmentSyntax(propertyName, callSignature, block, false); + }; + NormalModeFactory.prototype.getAccessorPropertyAssignment = function (getKeyword, propertyName, openParenToken, closeParenToken, typeAnnotation, block) { + return new TypeScript.GetAccessorPropertyAssignmentSyntax(getKeyword, propertyName, openParenToken, closeParenToken, typeAnnotation, block, false); + }; + NormalModeFactory.prototype.setAccessorPropertyAssignment = function (setKeyword, propertyName, openParenToken, parameter, closeParenToken, block) { + return new TypeScript.SetAccessorPropertyAssignmentSyntax(setKeyword, propertyName, openParenToken, parameter, closeParenToken, block, false); + }; + NormalModeFactory.prototype.functionExpression = function (functionKeyword, identifier, callSignature, block) { + return new TypeScript.FunctionExpressionSyntax(functionKeyword, identifier, callSignature, block, false); + }; + NormalModeFactory.prototype.emptyStatement = function (semicolonToken) { + return new TypeScript.EmptyStatementSyntax(semicolonToken, false); + }; + NormalModeFactory.prototype.tryStatement = function (tryKeyword, block, catchClause, finallyClause) { + return new TypeScript.TryStatementSyntax(tryKeyword, block, catchClause, finallyClause, false); + }; + NormalModeFactory.prototype.catchClause = function (catchKeyword, openParenToken, identifier, typeAnnotation, closeParenToken, block) { + return new TypeScript.CatchClauseSyntax(catchKeyword, openParenToken, identifier, typeAnnotation, closeParenToken, block, false); + }; + NormalModeFactory.prototype.finallyClause = function (finallyKeyword, block) { + return new TypeScript.FinallyClauseSyntax(finallyKeyword, block, false); + }; + NormalModeFactory.prototype.labeledStatement = function (identifier, colonToken, statement) { + return new TypeScript.LabeledStatementSyntax(identifier, colonToken, statement, false); + }; + NormalModeFactory.prototype.doStatement = function (doKeyword, statement, whileKeyword, openParenToken, condition, closeParenToken, semicolonToken) { + return new TypeScript.DoStatementSyntax(doKeyword, statement, whileKeyword, openParenToken, condition, closeParenToken, semicolonToken, false); + }; + NormalModeFactory.prototype.typeOfExpression = function (typeOfKeyword, expression) { + return new TypeScript.TypeOfExpressionSyntax(typeOfKeyword, expression, false); + }; + NormalModeFactory.prototype.deleteExpression = function (deleteKeyword, expression) { + return new TypeScript.DeleteExpressionSyntax(deleteKeyword, expression, false); + }; + NormalModeFactory.prototype.voidExpression = function (voidKeyword, expression) { + return new TypeScript.VoidExpressionSyntax(voidKeyword, expression, false); + }; + NormalModeFactory.prototype.debuggerStatement = function (debuggerKeyword, semicolonToken) { + return new TypeScript.DebuggerStatementSyntax(debuggerKeyword, semicolonToken, false); + }; + return NormalModeFactory; + })(); + Syntax.NormalModeFactory = NormalModeFactory; + + var StrictModeFactory = (function () { + function StrictModeFactory() { + } + StrictModeFactory.prototype.sourceUnit = function (moduleElements, endOfFileToken) { + return new TypeScript.SourceUnitSyntax(moduleElements, endOfFileToken, true); + }; + StrictModeFactory.prototype.externalModuleReference = function (requireKeyword, openParenToken, stringLiteral, closeParenToken) { + return new TypeScript.ExternalModuleReferenceSyntax(requireKeyword, openParenToken, stringLiteral, closeParenToken, true); + }; + StrictModeFactory.prototype.moduleNameModuleReference = function (moduleName) { + return new TypeScript.ModuleNameModuleReferenceSyntax(moduleName, true); + }; + StrictModeFactory.prototype.importDeclaration = function (modifiers, importKeyword, identifier, equalsToken, moduleReference, semicolonToken) { + return new TypeScript.ImportDeclarationSyntax(modifiers, importKeyword, identifier, equalsToken, moduleReference, semicolonToken, true); + }; + StrictModeFactory.prototype.exportAssignment = function (exportKeyword, equalsToken, identifier, semicolonToken) { + return new TypeScript.ExportAssignmentSyntax(exportKeyword, equalsToken, identifier, semicolonToken, true); + }; + StrictModeFactory.prototype.classDeclaration = function (modifiers, classKeyword, identifier, typeParameterList, heritageClauses, openBraceToken, classElements, closeBraceToken) { + return new TypeScript.ClassDeclarationSyntax(modifiers, classKeyword, identifier, typeParameterList, heritageClauses, openBraceToken, classElements, closeBraceToken, true); + }; + StrictModeFactory.prototype.interfaceDeclaration = function (modifiers, interfaceKeyword, identifier, typeParameterList, heritageClauses, body) { + return new TypeScript.InterfaceDeclarationSyntax(modifiers, interfaceKeyword, identifier, typeParameterList, heritageClauses, body, true); + }; + StrictModeFactory.prototype.heritageClause = function (extendsOrImplementsKeyword, typeNames) { + return new TypeScript.HeritageClauseSyntax(extendsOrImplementsKeyword, typeNames, true); + }; + StrictModeFactory.prototype.moduleDeclaration = function (modifiers, moduleKeyword, moduleName, stringLiteral, openBraceToken, moduleElements, closeBraceToken) { + return new TypeScript.ModuleDeclarationSyntax(modifiers, moduleKeyword, moduleName, stringLiteral, openBraceToken, moduleElements, closeBraceToken, true); + }; + StrictModeFactory.prototype.functionDeclaration = function (modifiers, functionKeyword, identifier, callSignature, block, semicolonToken) { + return new TypeScript.FunctionDeclarationSyntax(modifiers, functionKeyword, identifier, callSignature, block, semicolonToken, true); + }; + StrictModeFactory.prototype.variableStatement = function (modifiers, variableDeclaration, semicolonToken) { + return new TypeScript.VariableStatementSyntax(modifiers, variableDeclaration, semicolonToken, true); + }; + StrictModeFactory.prototype.variableDeclaration = function (varKeyword, variableDeclarators) { + return new TypeScript.VariableDeclarationSyntax(varKeyword, variableDeclarators, true); + }; + StrictModeFactory.prototype.variableDeclarator = function (identifier, typeAnnotation, equalsValueClause) { + return new TypeScript.VariableDeclaratorSyntax(identifier, typeAnnotation, equalsValueClause, true); + }; + StrictModeFactory.prototype.equalsValueClause = function (equalsToken, value) { + return new TypeScript.EqualsValueClauseSyntax(equalsToken, value, true); + }; + StrictModeFactory.prototype.prefixUnaryExpression = function (kind, operatorToken, operand) { + return new TypeScript.PrefixUnaryExpressionSyntax(kind, operatorToken, operand, true); + }; + StrictModeFactory.prototype.arrayLiteralExpression = function (openBracketToken, expressions, closeBracketToken) { + return new TypeScript.ArrayLiteralExpressionSyntax(openBracketToken, expressions, closeBracketToken, true); + }; + StrictModeFactory.prototype.omittedExpression = function () { + return new TypeScript.OmittedExpressionSyntax(true); + }; + StrictModeFactory.prototype.parenthesizedExpression = function (openParenToken, expression, closeParenToken) { + return new TypeScript.ParenthesizedExpressionSyntax(openParenToken, expression, closeParenToken, true); + }; + StrictModeFactory.prototype.simpleArrowFunctionExpression = function (identifier, equalsGreaterThanToken, body) { + return new TypeScript.SimpleArrowFunctionExpressionSyntax(identifier, equalsGreaterThanToken, body, true); + }; + StrictModeFactory.prototype.parenthesizedArrowFunctionExpression = function (callSignature, equalsGreaterThanToken, body) { + return new TypeScript.ParenthesizedArrowFunctionExpressionSyntax(callSignature, equalsGreaterThanToken, body, true); + }; + StrictModeFactory.prototype.qualifiedName = function (left, dotToken, right) { + return new TypeScript.QualifiedNameSyntax(left, dotToken, right, true); + }; + StrictModeFactory.prototype.typeArgumentList = function (lessThanToken, typeArguments, greaterThanToken) { + return new TypeScript.TypeArgumentListSyntax(lessThanToken, typeArguments, greaterThanToken, true); + }; + StrictModeFactory.prototype.constructorType = function (newKeyword, typeParameterList, parameterList, equalsGreaterThanToken, type) { + return new TypeScript.ConstructorTypeSyntax(newKeyword, typeParameterList, parameterList, equalsGreaterThanToken, type, true); + }; + StrictModeFactory.prototype.functionType = function (typeParameterList, parameterList, equalsGreaterThanToken, type) { + return new TypeScript.FunctionTypeSyntax(typeParameterList, parameterList, equalsGreaterThanToken, type, true); + }; + StrictModeFactory.prototype.objectType = function (openBraceToken, typeMembers, closeBraceToken) { + return new TypeScript.ObjectTypeSyntax(openBraceToken, typeMembers, closeBraceToken, true); + }; + StrictModeFactory.prototype.arrayType = function (type, openBracketToken, closeBracketToken) { + return new TypeScript.ArrayTypeSyntax(type, openBracketToken, closeBracketToken, true); + }; + StrictModeFactory.prototype.genericType = function (name, typeArgumentList) { + return new TypeScript.GenericTypeSyntax(name, typeArgumentList, true); + }; + StrictModeFactory.prototype.typeQuery = function (typeOfKeyword, name) { + return new TypeScript.TypeQuerySyntax(typeOfKeyword, name, true); + }; + StrictModeFactory.prototype.typeAnnotation = function (colonToken, type) { + return new TypeScript.TypeAnnotationSyntax(colonToken, type, true); + }; + StrictModeFactory.prototype.block = function (openBraceToken, statements, closeBraceToken) { + return new TypeScript.BlockSyntax(openBraceToken, statements, closeBraceToken, true); + }; + StrictModeFactory.prototype.parameter = function (dotDotDotToken, publicOrPrivateKeyword, identifier, questionToken, typeAnnotation, equalsValueClause) { + return new TypeScript.ParameterSyntax(dotDotDotToken, publicOrPrivateKeyword, identifier, questionToken, typeAnnotation, equalsValueClause, true); + }; + StrictModeFactory.prototype.memberAccessExpression = function (expression, dotToken, name) { + return new TypeScript.MemberAccessExpressionSyntax(expression, dotToken, name, true); + }; + StrictModeFactory.prototype.postfixUnaryExpression = function (kind, operand, operatorToken) { + return new TypeScript.PostfixUnaryExpressionSyntax(kind, operand, operatorToken, true); + }; + StrictModeFactory.prototype.elementAccessExpression = function (expression, openBracketToken, argumentExpression, closeBracketToken) { + return new TypeScript.ElementAccessExpressionSyntax(expression, openBracketToken, argumentExpression, closeBracketToken, true); + }; + StrictModeFactory.prototype.invocationExpression = function (expression, argumentList) { + return new TypeScript.InvocationExpressionSyntax(expression, argumentList, true); + }; + StrictModeFactory.prototype.argumentList = function (typeArgumentList, openParenToken, _arguments, closeParenToken) { + return new TypeScript.ArgumentListSyntax(typeArgumentList, openParenToken, _arguments, closeParenToken, true); + }; + StrictModeFactory.prototype.binaryExpression = function (kind, left, operatorToken, right) { + return new TypeScript.BinaryExpressionSyntax(kind, left, operatorToken, right, true); + }; + StrictModeFactory.prototype.conditionalExpression = function (condition, questionToken, whenTrue, colonToken, whenFalse) { + return new TypeScript.ConditionalExpressionSyntax(condition, questionToken, whenTrue, colonToken, whenFalse, true); + }; + StrictModeFactory.prototype.constructSignature = function (newKeyword, callSignature) { + return new TypeScript.ConstructSignatureSyntax(newKeyword, callSignature, true); + }; + StrictModeFactory.prototype.methodSignature = function (propertyName, questionToken, callSignature) { + return new TypeScript.MethodSignatureSyntax(propertyName, questionToken, callSignature, true); + }; + StrictModeFactory.prototype.indexSignature = function (openBracketToken, parameter, closeBracketToken, typeAnnotation) { + return new TypeScript.IndexSignatureSyntax(openBracketToken, parameter, closeBracketToken, typeAnnotation, true); + }; + StrictModeFactory.prototype.propertySignature = function (propertyName, questionToken, typeAnnotation) { + return new TypeScript.PropertySignatureSyntax(propertyName, questionToken, typeAnnotation, true); + }; + StrictModeFactory.prototype.callSignature = function (typeParameterList, parameterList, typeAnnotation) { + return new TypeScript.CallSignatureSyntax(typeParameterList, parameterList, typeAnnotation, true); + }; + StrictModeFactory.prototype.parameterList = function (openParenToken, parameters, closeParenToken) { + return new TypeScript.ParameterListSyntax(openParenToken, parameters, closeParenToken, true); + }; + StrictModeFactory.prototype.typeParameterList = function (lessThanToken, typeParameters, greaterThanToken) { + return new TypeScript.TypeParameterListSyntax(lessThanToken, typeParameters, greaterThanToken, true); + }; + StrictModeFactory.prototype.typeParameter = function (identifier, constraint) { + return new TypeScript.TypeParameterSyntax(identifier, constraint, true); + }; + StrictModeFactory.prototype.constraint = function (extendsKeyword, type) { + return new TypeScript.ConstraintSyntax(extendsKeyword, type, true); + }; + StrictModeFactory.prototype.elseClause = function (elseKeyword, statement) { + return new TypeScript.ElseClauseSyntax(elseKeyword, statement, true); + }; + StrictModeFactory.prototype.ifStatement = function (ifKeyword, openParenToken, condition, closeParenToken, statement, elseClause) { + return new TypeScript.IfStatementSyntax(ifKeyword, openParenToken, condition, closeParenToken, statement, elseClause, true); + }; + StrictModeFactory.prototype.expressionStatement = function (expression, semicolonToken) { + return new TypeScript.ExpressionStatementSyntax(expression, semicolonToken, true); + }; + StrictModeFactory.prototype.constructorDeclaration = function (constructorKeyword, parameterList, block, semicolonToken) { + return new TypeScript.ConstructorDeclarationSyntax(constructorKeyword, parameterList, block, semicolonToken, true); + }; + StrictModeFactory.prototype.memberFunctionDeclaration = function (modifiers, propertyName, callSignature, block, semicolonToken) { + return new TypeScript.MemberFunctionDeclarationSyntax(modifiers, propertyName, callSignature, block, semicolonToken, true); + }; + StrictModeFactory.prototype.getMemberAccessorDeclaration = function (modifiers, getKeyword, propertyName, parameterList, typeAnnotation, block) { + return new TypeScript.GetMemberAccessorDeclarationSyntax(modifiers, getKeyword, propertyName, parameterList, typeAnnotation, block, true); + }; + StrictModeFactory.prototype.setMemberAccessorDeclaration = function (modifiers, setKeyword, propertyName, parameterList, block) { + return new TypeScript.SetMemberAccessorDeclarationSyntax(modifiers, setKeyword, propertyName, parameterList, block, true); + }; + StrictModeFactory.prototype.memberVariableDeclaration = function (modifiers, variableDeclarator, semicolonToken) { + return new TypeScript.MemberVariableDeclarationSyntax(modifiers, variableDeclarator, semicolonToken, true); + }; + StrictModeFactory.prototype.throwStatement = function (throwKeyword, expression, semicolonToken) { + return new TypeScript.ThrowStatementSyntax(throwKeyword, expression, semicolonToken, true); + }; + StrictModeFactory.prototype.returnStatement = function (returnKeyword, expression, semicolonToken) { + return new TypeScript.ReturnStatementSyntax(returnKeyword, expression, semicolonToken, true); + }; + StrictModeFactory.prototype.objectCreationExpression = function (newKeyword, expression, argumentList) { + return new TypeScript.ObjectCreationExpressionSyntax(newKeyword, expression, argumentList, true); + }; + StrictModeFactory.prototype.switchStatement = function (switchKeyword, openParenToken, expression, closeParenToken, openBraceToken, switchClauses, closeBraceToken) { + return new TypeScript.SwitchStatementSyntax(switchKeyword, openParenToken, expression, closeParenToken, openBraceToken, switchClauses, closeBraceToken, true); + }; + StrictModeFactory.prototype.caseSwitchClause = function (caseKeyword, expression, colonToken, statements) { + return new TypeScript.CaseSwitchClauseSyntax(caseKeyword, expression, colonToken, statements, true); + }; + StrictModeFactory.prototype.defaultSwitchClause = function (defaultKeyword, colonToken, statements) { + return new TypeScript.DefaultSwitchClauseSyntax(defaultKeyword, colonToken, statements, true); + }; + StrictModeFactory.prototype.breakStatement = function (breakKeyword, identifier, semicolonToken) { + return new TypeScript.BreakStatementSyntax(breakKeyword, identifier, semicolonToken, true); + }; + StrictModeFactory.prototype.continueStatement = function (continueKeyword, identifier, semicolonToken) { + return new TypeScript.ContinueStatementSyntax(continueKeyword, identifier, semicolonToken, true); + }; + StrictModeFactory.prototype.forStatement = function (forKeyword, openParenToken, variableDeclaration, initializer, firstSemicolonToken, condition, secondSemicolonToken, incrementor, closeParenToken, statement) { + return new TypeScript.ForStatementSyntax(forKeyword, openParenToken, variableDeclaration, initializer, firstSemicolonToken, condition, secondSemicolonToken, incrementor, closeParenToken, statement, true); + }; + StrictModeFactory.prototype.forInStatement = function (forKeyword, openParenToken, variableDeclaration, left, inKeyword, expression, closeParenToken, statement) { + return new TypeScript.ForInStatementSyntax(forKeyword, openParenToken, variableDeclaration, left, inKeyword, expression, closeParenToken, statement, true); + }; + StrictModeFactory.prototype.whileStatement = function (whileKeyword, openParenToken, condition, closeParenToken, statement) { + return new TypeScript.WhileStatementSyntax(whileKeyword, openParenToken, condition, closeParenToken, statement, true); + }; + StrictModeFactory.prototype.withStatement = function (withKeyword, openParenToken, condition, closeParenToken, statement) { + return new TypeScript.WithStatementSyntax(withKeyword, openParenToken, condition, closeParenToken, statement, true); + }; + StrictModeFactory.prototype.enumDeclaration = function (modifiers, enumKeyword, identifier, openBraceToken, enumElements, closeBraceToken) { + return new TypeScript.EnumDeclarationSyntax(modifiers, enumKeyword, identifier, openBraceToken, enumElements, closeBraceToken, true); + }; + StrictModeFactory.prototype.enumElement = function (propertyName, equalsValueClause) { + return new TypeScript.EnumElementSyntax(propertyName, equalsValueClause, true); + }; + StrictModeFactory.prototype.castExpression = function (lessThanToken, type, greaterThanToken, expression) { + return new TypeScript.CastExpressionSyntax(lessThanToken, type, greaterThanToken, expression, true); + }; + StrictModeFactory.prototype.objectLiteralExpression = function (openBraceToken, propertyAssignments, closeBraceToken) { + return new TypeScript.ObjectLiteralExpressionSyntax(openBraceToken, propertyAssignments, closeBraceToken, true); + }; + StrictModeFactory.prototype.simplePropertyAssignment = function (propertyName, colonToken, expression) { + return new TypeScript.SimplePropertyAssignmentSyntax(propertyName, colonToken, expression, true); + }; + StrictModeFactory.prototype.functionPropertyAssignment = function (propertyName, callSignature, block) { + return new TypeScript.FunctionPropertyAssignmentSyntax(propertyName, callSignature, block, true); + }; + StrictModeFactory.prototype.getAccessorPropertyAssignment = function (getKeyword, propertyName, openParenToken, closeParenToken, typeAnnotation, block) { + return new TypeScript.GetAccessorPropertyAssignmentSyntax(getKeyword, propertyName, openParenToken, closeParenToken, typeAnnotation, block, true); + }; + StrictModeFactory.prototype.setAccessorPropertyAssignment = function (setKeyword, propertyName, openParenToken, parameter, closeParenToken, block) { + return new TypeScript.SetAccessorPropertyAssignmentSyntax(setKeyword, propertyName, openParenToken, parameter, closeParenToken, block, true); + }; + StrictModeFactory.prototype.functionExpression = function (functionKeyword, identifier, callSignature, block) { + return new TypeScript.FunctionExpressionSyntax(functionKeyword, identifier, callSignature, block, true); + }; + StrictModeFactory.prototype.emptyStatement = function (semicolonToken) { + return new TypeScript.EmptyStatementSyntax(semicolonToken, true); + }; + StrictModeFactory.prototype.tryStatement = function (tryKeyword, block, catchClause, finallyClause) { + return new TypeScript.TryStatementSyntax(tryKeyword, block, catchClause, finallyClause, true); + }; + StrictModeFactory.prototype.catchClause = function (catchKeyword, openParenToken, identifier, typeAnnotation, closeParenToken, block) { + return new TypeScript.CatchClauseSyntax(catchKeyword, openParenToken, identifier, typeAnnotation, closeParenToken, block, true); + }; + StrictModeFactory.prototype.finallyClause = function (finallyKeyword, block) { + return new TypeScript.FinallyClauseSyntax(finallyKeyword, block, true); + }; + StrictModeFactory.prototype.labeledStatement = function (identifier, colonToken, statement) { + return new TypeScript.LabeledStatementSyntax(identifier, colonToken, statement, true); + }; + StrictModeFactory.prototype.doStatement = function (doKeyword, statement, whileKeyword, openParenToken, condition, closeParenToken, semicolonToken) { + return new TypeScript.DoStatementSyntax(doKeyword, statement, whileKeyword, openParenToken, condition, closeParenToken, semicolonToken, true); + }; + StrictModeFactory.prototype.typeOfExpression = function (typeOfKeyword, expression) { + return new TypeScript.TypeOfExpressionSyntax(typeOfKeyword, expression, true); + }; + StrictModeFactory.prototype.deleteExpression = function (deleteKeyword, expression) { + return new TypeScript.DeleteExpressionSyntax(deleteKeyword, expression, true); + }; + StrictModeFactory.prototype.voidExpression = function (voidKeyword, expression) { + return new TypeScript.VoidExpressionSyntax(voidKeyword, expression, true); + }; + StrictModeFactory.prototype.debuggerStatement = function (debuggerKeyword, semicolonToken) { + return new TypeScript.DebuggerStatementSyntax(debuggerKeyword, semicolonToken, true); + }; + return StrictModeFactory; + })(); + Syntax.StrictModeFactory = StrictModeFactory; + + Syntax.normalModeFactory = new NormalModeFactory(); + Syntax.strictModeFactory = new StrictModeFactory(); + })(TypeScript.Syntax || (TypeScript.Syntax = {})); + var Syntax = TypeScript.Syntax; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (SyntaxFacts) { + function isDirectivePrologueElement(node) { + if (node.kind() === 148 /* ExpressionStatement */) { + var expressionStatement = node; + var expression = expressionStatement.expression; + + if (expression.kind() === 14 /* StringLiteral */) { + return true; + } + } + + return false; + } + SyntaxFacts.isDirectivePrologueElement = isDirectivePrologueElement; + + function isUseStrictDirective(node) { + var expressionStatement = node; + var stringLiteral = expressionStatement.expression; + + var text = stringLiteral.text(); + return text === '"use strict"' || text === "'use strict'"; + } + SyntaxFacts.isUseStrictDirective = isUseStrictDirective; + + function isIdentifierNameOrAnyKeyword(token) { + var tokenKind = token.tokenKind; + return tokenKind === 11 /* IdentifierName */ || TypeScript.SyntaxFacts.isAnyKeyword(tokenKind); + } + SyntaxFacts.isIdentifierNameOrAnyKeyword = isIdentifierNameOrAnyKeyword; + })(TypeScript.SyntaxFacts || (TypeScript.SyntaxFacts = {})); + var SyntaxFacts = TypeScript.SyntaxFacts; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (Syntax) { + var EmptySyntaxList = (function () { + function EmptySyntaxList() { + } + EmptySyntaxList.prototype.kind = function () { + return 1 /* List */; + }; + + EmptySyntaxList.prototype.isNode = function () { + return false; + }; + EmptySyntaxList.prototype.isToken = function () { + return false; + }; + EmptySyntaxList.prototype.isList = function () { + return true; + }; + EmptySyntaxList.prototype.isSeparatedList = function () { + return false; + }; + + EmptySyntaxList.prototype.toJSON = function (key) { + return []; + }; + + EmptySyntaxList.prototype.childCount = function () { + return 0; + }; + + EmptySyntaxList.prototype.childAt = function (index) { + throw TypeScript.Errors.argumentOutOfRange("index"); + }; + + EmptySyntaxList.prototype.toArray = function () { + return []; + }; + + EmptySyntaxList.prototype.collectTextElements = function (elements) { + }; + + EmptySyntaxList.prototype.firstToken = function () { + return null; + }; + + EmptySyntaxList.prototype.lastToken = function () { + return null; + }; + + EmptySyntaxList.prototype.fullWidth = function () { + return 0; + }; + + EmptySyntaxList.prototype.width = function () { + return 0; + }; + + EmptySyntaxList.prototype.leadingTrivia = function () { + return TypeScript.Syntax.emptyTriviaList; + }; + + EmptySyntaxList.prototype.trailingTrivia = function () { + return TypeScript.Syntax.emptyTriviaList; + }; + + EmptySyntaxList.prototype.leadingTriviaWidth = function () { + return 0; + }; + + EmptySyntaxList.prototype.trailingTriviaWidth = function () { + return 0; + }; + + EmptySyntaxList.prototype.fullText = function () { + return ""; + }; + + EmptySyntaxList.prototype.isTypeScriptSpecific = function () { + return false; + }; + + EmptySyntaxList.prototype.isIncrementallyUnusable = function () { + return false; + }; + + EmptySyntaxList.prototype.findTokenInternal = function (parent, position, fullStart) { + throw TypeScript.Errors.invalidOperation(); + }; + + EmptySyntaxList.prototype.insertChildrenInto = function (array, index) { + }; + return EmptySyntaxList; + })(); + Syntax.EmptySyntaxList = EmptySyntaxList; + + Syntax.emptyList = new EmptySyntaxList(); + + var SingletonSyntaxList = (function () { + function SingletonSyntaxList(item) { + this.item = item; + } + SingletonSyntaxList.prototype.kind = function () { + return 1 /* List */; + }; + + SingletonSyntaxList.prototype.isToken = function () { + return false; + }; + SingletonSyntaxList.prototype.isNode = function () { + return false; + }; + SingletonSyntaxList.prototype.isList = function () { + return true; + }; + SingletonSyntaxList.prototype.isSeparatedList = function () { + return false; + }; + + SingletonSyntaxList.prototype.toJSON = function (key) { + return [this.item]; + }; + + SingletonSyntaxList.prototype.childCount = function () { + return 1; + }; + + SingletonSyntaxList.prototype.childAt = function (index) { + if (index !== 0) { + throw TypeScript.Errors.argumentOutOfRange("index"); + } + + return this.item; + }; + + SingletonSyntaxList.prototype.toArray = function () { + return [this.item]; + }; + + SingletonSyntaxList.prototype.collectTextElements = function (elements) { + this.item.collectTextElements(elements); + }; + + SingletonSyntaxList.prototype.firstToken = function () { + return this.item.firstToken(); + }; + + SingletonSyntaxList.prototype.lastToken = function () { + return this.item.lastToken(); + }; + + SingletonSyntaxList.prototype.fullWidth = function () { + return this.item.fullWidth(); + }; + + SingletonSyntaxList.prototype.width = function () { + return this.item.width(); + }; + + SingletonSyntaxList.prototype.leadingTrivia = function () { + return this.item.leadingTrivia(); + }; + + SingletonSyntaxList.prototype.trailingTrivia = function () { + return this.item.trailingTrivia(); + }; + + SingletonSyntaxList.prototype.leadingTriviaWidth = function () { + return this.item.leadingTriviaWidth(); + }; + + SingletonSyntaxList.prototype.trailingTriviaWidth = function () { + return this.item.trailingTriviaWidth(); + }; + + SingletonSyntaxList.prototype.fullText = function () { + return this.item.fullText(); + }; + + SingletonSyntaxList.prototype.isTypeScriptSpecific = function () { + return this.item.isTypeScriptSpecific(); + }; + + SingletonSyntaxList.prototype.isIncrementallyUnusable = function () { + return this.item.isIncrementallyUnusable(); + }; + + SingletonSyntaxList.prototype.findTokenInternal = function (parent, position, fullStart) { + return (this.item).findTokenInternal(new TypeScript.PositionedList(parent, this, fullStart), position, fullStart); + }; + + SingletonSyntaxList.prototype.insertChildrenInto = function (array, index) { + array.splice(index, 0, this.item); + }; + return SingletonSyntaxList; + })(); + + var NormalSyntaxList = (function () { + function NormalSyntaxList(nodeOrTokens) { + this._data = 0; + this.nodeOrTokens = nodeOrTokens; + } + NormalSyntaxList.prototype.kind = function () { + return 1 /* List */; + }; + + NormalSyntaxList.prototype.isNode = function () { + return false; + }; + NormalSyntaxList.prototype.isToken = function () { + return false; + }; + NormalSyntaxList.prototype.isList = function () { + return true; + }; + NormalSyntaxList.prototype.isSeparatedList = function () { + return false; + }; + + NormalSyntaxList.prototype.toJSON = function (key) { + return this.nodeOrTokens; + }; + + NormalSyntaxList.prototype.childCount = function () { + return this.nodeOrTokens.length; + }; + + NormalSyntaxList.prototype.childAt = function (index) { + if (index < 0 || index >= this.nodeOrTokens.length) { + throw TypeScript.Errors.argumentOutOfRange("index"); + } + + return this.nodeOrTokens[index]; + }; + + NormalSyntaxList.prototype.toArray = function () { + return this.nodeOrTokens.slice(0); + }; + + NormalSyntaxList.prototype.collectTextElements = function (elements) { + for (var i = 0, n = this.nodeOrTokens.length; i < n; i++) { + var element = this.nodeOrTokens[i]; + element.collectTextElements(elements); + } + }; + + NormalSyntaxList.prototype.firstToken = function () { + for (var i = 0, n = this.nodeOrTokens.length; i < n; i++) { + var token = this.nodeOrTokens[i].firstToken(); + if (token !== null) { + return token; + } + } + + return null; + }; + + NormalSyntaxList.prototype.lastToken = function () { + for (var i = this.nodeOrTokens.length - 1; i >= 0; i--) { + var token = this.nodeOrTokens[i].lastToken(); + if (token !== null) { + return token; + } + } + + return null; + }; + + NormalSyntaxList.prototype.fullText = function () { + var elements = new Array(); + this.collectTextElements(elements); + return elements.join(""); + }; + + NormalSyntaxList.prototype.isTypeScriptSpecific = function () { + for (var i = 0, n = this.nodeOrTokens.length; i < n; i++) { + if (this.nodeOrTokens[i].isTypeScriptSpecific()) { + return true; + } + } + + return false; + }; + + NormalSyntaxList.prototype.isIncrementallyUnusable = function () { + return (this.data() & 2 /* NodeIncrementallyUnusableMask */) !== 0; + }; + + NormalSyntaxList.prototype.fullWidth = function () { + return this.data() >>> 3 /* NodeFullWidthShift */; + }; + + NormalSyntaxList.prototype.width = function () { + var fullWidth = this.fullWidth(); + return fullWidth - this.leadingTriviaWidth() - this.trailingTriviaWidth(); + }; + + NormalSyntaxList.prototype.leadingTrivia = function () { + return this.firstToken().leadingTrivia(); + }; + + NormalSyntaxList.prototype.trailingTrivia = function () { + return this.lastToken().trailingTrivia(); + }; + + NormalSyntaxList.prototype.leadingTriviaWidth = function () { + return this.firstToken().leadingTriviaWidth(); + }; + + NormalSyntaxList.prototype.trailingTriviaWidth = function () { + return this.lastToken().trailingTriviaWidth(); + }; + + NormalSyntaxList.prototype.computeData = function () { + var fullWidth = 0; + var isIncrementallyUnusable = false; + + for (var i = 0, n = this.nodeOrTokens.length; i < n; i++) { + var node = this.nodeOrTokens[i]; + fullWidth += node.fullWidth(); + isIncrementallyUnusable = isIncrementallyUnusable || node.isIncrementallyUnusable(); + } + + return (fullWidth << 3 /* NodeFullWidthShift */) | (isIncrementallyUnusable ? 2 /* NodeIncrementallyUnusableMask */ : 0) | 1 /* NodeDataComputed */; + }; + + NormalSyntaxList.prototype.data = function () { + if ((this._data & 1 /* NodeDataComputed */) === 0) { + this._data = this.computeData(); + } + + return this._data; + }; + + NormalSyntaxList.prototype.findTokenInternal = function (parent, position, fullStart) { + parent = new TypeScript.PositionedList(parent, this, fullStart); + for (var i = 0, n = this.nodeOrTokens.length; i < n; i++) { + var nodeOrToken = this.nodeOrTokens[i]; + + var childWidth = nodeOrToken.fullWidth(); + if (position < childWidth) { + return (nodeOrToken).findTokenInternal(parent, position, fullStart); + } + + position -= childWidth; + fullStart += childWidth; + } + + throw TypeScript.Errors.invalidOperation(); + }; + + NormalSyntaxList.prototype.insertChildrenInto = function (array, index) { + if (index === 0) { + array.unshift.apply(array, this.nodeOrTokens); + } else { + array.splice.apply(array, [index, 0].concat(this.nodeOrTokens)); + } + }; + return NormalSyntaxList; + })(); + + function list(nodes) { + if (nodes === undefined || nodes === null || nodes.length === 0) { + return Syntax.emptyList; + } + + if (nodes.length === 1) { + var item = nodes[0]; + return new SingletonSyntaxList(item); + } + + return new NormalSyntaxList(nodes); + } + Syntax.list = list; + })(TypeScript.Syntax || (TypeScript.Syntax = {})); + var Syntax = TypeScript.Syntax; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var SyntaxNode = (function () { + function SyntaxNode(parsedInStrictMode) { + this._data = parsedInStrictMode ? 4 /* NodeParsedInStrictModeMask */ : 0; + } + SyntaxNode.prototype.isNode = function () { + return true; + }; + SyntaxNode.prototype.isToken = function () { + return false; + }; + SyntaxNode.prototype.isList = function () { + return false; + }; + SyntaxNode.prototype.isSeparatedList = function () { + return false; + }; + + SyntaxNode.prototype.kind = function () { + throw TypeScript.Errors.abstract(); + }; + + SyntaxNode.prototype.childCount = function () { + throw TypeScript.Errors.abstract(); + }; + + SyntaxNode.prototype.childAt = function (slot) { + throw TypeScript.Errors.abstract(); + }; + + SyntaxNode.prototype.firstToken = function () { + for (var i = 0, n = this.childCount(); i < n; i++) { + var element = this.childAt(i); + + if (element !== null) { + if (element.fullWidth() > 0 || element.kind() === 10 /* EndOfFileToken */) { + return element.firstToken(); + } + } + } + + return null; + }; + + SyntaxNode.prototype.lastToken = function () { + for (var i = this.childCount() - 1; i >= 0; i--) { + var element = this.childAt(i); + + if (element !== null) { + if (element.fullWidth() > 0 || element.kind() === 10 /* EndOfFileToken */) { + return element.lastToken(); + } + } + } + + return null; + }; + + SyntaxNode.prototype.insertChildrenInto = function (array, index) { + for (var i = this.childCount() - 1; i >= 0; i--) { + var element = this.childAt(i); + + if (element !== null) { + if (element.isNode() || element.isToken()) { + array.splice(index, 0, element); + } else if (element.isList()) { + (element).insertChildrenInto(array, index); + } else if (element.isSeparatedList()) { + (element).insertChildrenInto(array, index); + } else { + throw TypeScript.Errors.invalidOperation(); + } + } + } + }; + + SyntaxNode.prototype.leadingTrivia = function () { + return this.firstToken().leadingTrivia(); + }; + + SyntaxNode.prototype.trailingTrivia = function () { + return this.lastToken().trailingTrivia(); + }; + + SyntaxNode.prototype.toJSON = function (key) { + var result = { + kind: TypeScript.SyntaxKind[this.kind()], + fullWidth: this.fullWidth() + }; + + if (this.isIncrementallyUnusable()) { + result.isIncrementallyUnusable = true; + } + + if (this.parsedInStrictMode()) { + result.parsedInStrictMode = true; + } + + for (var i = 0, n = this.childCount(); i < n; i++) { + var value = this.childAt(i); + + if (value) { + for (var name in this) { + if (value === this[name]) { + result[name] = value; + break; + } + } + } + } + + return result; + }; + + SyntaxNode.prototype.accept = function (visitor) { + throw TypeScript.Errors.abstract(); + }; + + SyntaxNode.prototype.fullText = function () { + var elements = []; + this.collectTextElements(elements); + return elements.join(""); + }; + + SyntaxNode.prototype.collectTextElements = function (elements) { + for (var i = 0, n = this.childCount(); i < n; i++) { + var element = this.childAt(i); + + if (element !== null) { + element.collectTextElements(elements); + } + } + }; + + SyntaxNode.prototype.replaceToken = function (token1, token2) { + if (token1 === token2) { + return this; + } + + return this.accept(new TypeScript.SyntaxTokenReplacer(token1, token2)); + }; + + SyntaxNode.prototype.withLeadingTrivia = function (trivia) { + return this.replaceToken(this.firstToken(), this.firstToken().withLeadingTrivia(trivia)); + }; + + SyntaxNode.prototype.withTrailingTrivia = function (trivia) { + return this.replaceToken(this.lastToken(), this.lastToken().withTrailingTrivia(trivia)); + }; + + SyntaxNode.prototype.hasLeadingTrivia = function () { + return this.lastToken().hasLeadingTrivia(); + }; + + SyntaxNode.prototype.hasTrailingTrivia = function () { + return this.lastToken().hasTrailingTrivia(); + }; + + SyntaxNode.prototype.isTypeScriptSpecific = function () { + return false; + }; + + SyntaxNode.prototype.isIncrementallyUnusable = function () { + return (this.data() & 2 /* NodeIncrementallyUnusableMask */) !== 0; + }; + + SyntaxNode.prototype.parsedInStrictMode = function () { + return (this.data() & 4 /* NodeParsedInStrictModeMask */) !== 0; + }; + + SyntaxNode.prototype.fullWidth = function () { + return this.data() >>> 3 /* NodeFullWidthShift */; + }; + + SyntaxNode.prototype.computeData = function () { + var slotCount = this.childCount(); + + var fullWidth = 0; + var childWidth = 0; + + var isIncrementallyUnusable = ((this._data & 2 /* NodeIncrementallyUnusableMask */) !== 0) || slotCount === 0; + + for (var i = 0, n = slotCount; i < n; i++) { + var element = this.childAt(i); + + if (element !== null) { + childWidth = element.fullWidth(); + fullWidth += childWidth; + + if (!isIncrementallyUnusable) { + isIncrementallyUnusable = element.isIncrementallyUnusable(); + } + } + } + + return (fullWidth << 3 /* NodeFullWidthShift */) | (isIncrementallyUnusable ? 2 /* NodeIncrementallyUnusableMask */ : 0) | 1 /* NodeDataComputed */; + }; + + SyntaxNode.prototype.data = function () { + if ((this._data & 1 /* NodeDataComputed */) === 0) { + this._data |= this.computeData(); + } + + return this._data; + }; + + SyntaxNode.prototype.findToken = function (position, includeSkippedTokens) { + if (typeof includeSkippedTokens === "undefined") { includeSkippedTokens = false; } + var endOfFileToken = this.tryGetEndOfFileAt(position); + if (endOfFileToken !== null) { + return endOfFileToken; + } + + if (position < 0 || position >= this.fullWidth()) { + throw TypeScript.Errors.argumentOutOfRange("position"); + } + + var positionedToken = this.findTokenInternal(null, position, 0); + + if (includeSkippedTokens) { + return TypeScript.Syntax.findSkippedTokenInPositionedToken(positionedToken, position) || positionedToken; + } + + return positionedToken; + }; + + SyntaxNode.prototype.tryGetEndOfFileAt = function (position) { + if (this.kind() === 120 /* SourceUnit */ && position === this.fullWidth()) { + var sourceUnit = this; + return new TypeScript.PositionedToken(new TypeScript.PositionedNode(null, sourceUnit, 0), sourceUnit.endOfFileToken, sourceUnit.moduleElements.fullWidth()); + } + + return null; + }; + + SyntaxNode.prototype.findTokenInternal = function (parent, position, fullStart) { + parent = new TypeScript.PositionedNode(parent, this, fullStart); + for (var i = 0, n = this.childCount(); i < n; i++) { + var element = this.childAt(i); + + if (element !== null) { + var childWidth = element.fullWidth(); + + if (position < childWidth) { + return (element).findTokenInternal(parent, position, fullStart); + } + + position -= childWidth; + fullStart += childWidth; + } + } + + throw TypeScript.Errors.invalidOperation(); + }; + + SyntaxNode.prototype.findTokenOnLeft = function (position, includeSkippedTokens) { + if (typeof includeSkippedTokens === "undefined") { includeSkippedTokens = false; } + var positionedToken = this.findToken(position, false); + var start = positionedToken.start(); + + if (includeSkippedTokens) { + positionedToken = TypeScript.Syntax.findSkippedTokenOnLeft(positionedToken, position) || positionedToken; + } + + if (position > start) { + return positionedToken; + } + + if (positionedToken.fullStart() === 0) { + return null; + } + + return positionedToken.previousToken(includeSkippedTokens); + }; + + SyntaxNode.prototype.findCompleteTokenOnLeft = function (position, includeSkippedTokens) { + if (typeof includeSkippedTokens === "undefined") { includeSkippedTokens = false; } + var positionedToken = this.findToken(position, false); + + if (includeSkippedTokens) { + positionedToken = TypeScript.Syntax.findSkippedTokenOnLeft(positionedToken, position) || positionedToken; + } + + if (positionedToken.token().width() > 0 && position >= positionedToken.end()) { + return positionedToken; + } + + return positionedToken.previousToken(includeSkippedTokens); + }; + + SyntaxNode.prototype.isModuleElement = function () { + return false; + }; + + SyntaxNode.prototype.isClassElement = function () { + return false; + }; + + SyntaxNode.prototype.isTypeMember = function () { + return false; + }; + + SyntaxNode.prototype.isStatement = function () { + return false; + }; + + SyntaxNode.prototype.isSwitchClause = function () { + return false; + }; + + SyntaxNode.prototype.structuralEquals = function (node) { + if (this === node) { + return true; + } + if (node === null) { + return false; + } + if (this.kind() !== node.kind()) { + return false; + } + + for (var i = 0, n = this.childCount(); i < n; i++) { + var element1 = this.childAt(i); + var element2 = node.childAt(i); + + if (!TypeScript.Syntax.elementStructuralEquals(element1, element2)) { + return false; + } + } + + return true; + }; + + SyntaxNode.prototype.width = function () { + return this.fullWidth() - this.leadingTriviaWidth() - this.trailingTriviaWidth(); + }; + + SyntaxNode.prototype.leadingTriviaWidth = function () { + var firstToken = this.firstToken(); + return firstToken === null ? 0 : firstToken.leadingTriviaWidth(); + }; + + SyntaxNode.prototype.trailingTriviaWidth = function () { + var lastToken = this.lastToken(); + return lastToken === null ? 0 : lastToken.trailingTriviaWidth(); + }; + return SyntaxNode; + })(); + TypeScript.SyntaxNode = SyntaxNode; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var SourceUnitSyntax = (function (_super) { + __extends(SourceUnitSyntax, _super); + function SourceUnitSyntax(moduleElements, endOfFileToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.moduleElements = moduleElements; + this.endOfFileToken = endOfFileToken; + } + SourceUnitSyntax.prototype.accept = function (visitor) { + return visitor.visitSourceUnit(this); + }; + + SourceUnitSyntax.prototype.kind = function () { + return 120 /* SourceUnit */; + }; + + SourceUnitSyntax.prototype.childCount = function () { + return 2; + }; + + SourceUnitSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.moduleElements; + case 1: + return this.endOfFileToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + SourceUnitSyntax.prototype.update = function (moduleElements, endOfFileToken) { + if (this.moduleElements === moduleElements && this.endOfFileToken === endOfFileToken) { + return this; + } + + return new SourceUnitSyntax(moduleElements, endOfFileToken, this.parsedInStrictMode()); + }; + + SourceUnitSyntax.create = function (endOfFileToken) { + return new SourceUnitSyntax(TypeScript.Syntax.emptyList, endOfFileToken, false); + }; + + SourceUnitSyntax.create1 = function (endOfFileToken) { + return new SourceUnitSyntax(TypeScript.Syntax.emptyList, endOfFileToken, false); + }; + + SourceUnitSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + SourceUnitSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + SourceUnitSyntax.prototype.withModuleElements = function (moduleElements) { + return this.update(moduleElements, this.endOfFileToken); + }; + + SourceUnitSyntax.prototype.withModuleElement = function (moduleElement) { + return this.withModuleElements(TypeScript.Syntax.list([moduleElement])); + }; + + SourceUnitSyntax.prototype.withEndOfFileToken = function (endOfFileToken) { + return this.update(this.moduleElements, endOfFileToken); + }; + + SourceUnitSyntax.prototype.isTypeScriptSpecific = function () { + if (this.moduleElements.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return SourceUnitSyntax; + })(TypeScript.SyntaxNode); + TypeScript.SourceUnitSyntax = SourceUnitSyntax; + + var ModuleReferenceSyntax = (function (_super) { + __extends(ModuleReferenceSyntax, _super); + function ModuleReferenceSyntax(parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + } + ModuleReferenceSyntax.prototype.isModuleReference = function () { + return true; + }; + + ModuleReferenceSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ModuleReferenceSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ModuleReferenceSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return ModuleReferenceSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ModuleReferenceSyntax = ModuleReferenceSyntax; + + var ExternalModuleReferenceSyntax = (function (_super) { + __extends(ExternalModuleReferenceSyntax, _super); + function ExternalModuleReferenceSyntax(requireKeyword, openParenToken, stringLiteral, closeParenToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.requireKeyword = requireKeyword; + this.openParenToken = openParenToken; + this.stringLiteral = stringLiteral; + this.closeParenToken = closeParenToken; + } + ExternalModuleReferenceSyntax.prototype.accept = function (visitor) { + return visitor.visitExternalModuleReference(this); + }; + + ExternalModuleReferenceSyntax.prototype.kind = function () { + return 245 /* ExternalModuleReference */; + }; + + ExternalModuleReferenceSyntax.prototype.childCount = function () { + return 4; + }; + + ExternalModuleReferenceSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.requireKeyword; + case 1: + return this.openParenToken; + case 2: + return this.stringLiteral; + case 3: + return this.closeParenToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ExternalModuleReferenceSyntax.prototype.update = function (requireKeyword, openParenToken, stringLiteral, closeParenToken) { + if (this.requireKeyword === requireKeyword && this.openParenToken === openParenToken && this.stringLiteral === stringLiteral && this.closeParenToken === closeParenToken) { + return this; + } + + return new ExternalModuleReferenceSyntax(requireKeyword, openParenToken, stringLiteral, closeParenToken, this.parsedInStrictMode()); + }; + + ExternalModuleReferenceSyntax.create1 = function (stringLiteral) { + return new ExternalModuleReferenceSyntax(TypeScript.Syntax.token(66 /* RequireKeyword */), TypeScript.Syntax.token(72 /* OpenParenToken */), stringLiteral, TypeScript.Syntax.token(73 /* CloseParenToken */), false); + }; + + ExternalModuleReferenceSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ExternalModuleReferenceSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ExternalModuleReferenceSyntax.prototype.withRequireKeyword = function (requireKeyword) { + return this.update(requireKeyword, this.openParenToken, this.stringLiteral, this.closeParenToken); + }; + + ExternalModuleReferenceSyntax.prototype.withOpenParenToken = function (openParenToken) { + return this.update(this.requireKeyword, openParenToken, this.stringLiteral, this.closeParenToken); + }; + + ExternalModuleReferenceSyntax.prototype.withStringLiteral = function (stringLiteral) { + return this.update(this.requireKeyword, this.openParenToken, stringLiteral, this.closeParenToken); + }; + + ExternalModuleReferenceSyntax.prototype.withCloseParenToken = function (closeParenToken) { + return this.update(this.requireKeyword, this.openParenToken, this.stringLiteral, closeParenToken); + }; + + ExternalModuleReferenceSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return ExternalModuleReferenceSyntax; + })(ModuleReferenceSyntax); + TypeScript.ExternalModuleReferenceSyntax = ExternalModuleReferenceSyntax; + + var ModuleNameModuleReferenceSyntax = (function (_super) { + __extends(ModuleNameModuleReferenceSyntax, _super); + function ModuleNameModuleReferenceSyntax(moduleName, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.moduleName = moduleName; + } + ModuleNameModuleReferenceSyntax.prototype.accept = function (visitor) { + return visitor.visitModuleNameModuleReference(this); + }; + + ModuleNameModuleReferenceSyntax.prototype.kind = function () { + return 246 /* ModuleNameModuleReference */; + }; + + ModuleNameModuleReferenceSyntax.prototype.childCount = function () { + return 1; + }; + + ModuleNameModuleReferenceSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.moduleName; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ModuleNameModuleReferenceSyntax.prototype.update = function (moduleName) { + if (this.moduleName === moduleName) { + return this; + } + + return new ModuleNameModuleReferenceSyntax(moduleName, this.parsedInStrictMode()); + }; + + ModuleNameModuleReferenceSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ModuleNameModuleReferenceSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ModuleNameModuleReferenceSyntax.prototype.withModuleName = function (moduleName) { + return this.update(moduleName); + }; + + ModuleNameModuleReferenceSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return ModuleNameModuleReferenceSyntax; + })(ModuleReferenceSyntax); + TypeScript.ModuleNameModuleReferenceSyntax = ModuleNameModuleReferenceSyntax; + + var ImportDeclarationSyntax = (function (_super) { + __extends(ImportDeclarationSyntax, _super); + function ImportDeclarationSyntax(modifiers, importKeyword, identifier, equalsToken, moduleReference, semicolonToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.modifiers = modifiers; + this.importKeyword = importKeyword; + this.identifier = identifier; + this.equalsToken = equalsToken; + this.moduleReference = moduleReference; + this.semicolonToken = semicolonToken; + } + ImportDeclarationSyntax.prototype.accept = function (visitor) { + return visitor.visitImportDeclaration(this); + }; + + ImportDeclarationSyntax.prototype.kind = function () { + return 133 /* ImportDeclaration */; + }; + + ImportDeclarationSyntax.prototype.childCount = function () { + return 6; + }; + + ImportDeclarationSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.modifiers; + case 1: + return this.importKeyword; + case 2: + return this.identifier; + case 3: + return this.equalsToken; + case 4: + return this.moduleReference; + case 5: + return this.semicolonToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ImportDeclarationSyntax.prototype.isModuleElement = function () { + return true; + }; + + ImportDeclarationSyntax.prototype.update = function (modifiers, importKeyword, identifier, equalsToken, moduleReference, semicolonToken) { + if (this.modifiers === modifiers && this.importKeyword === importKeyword && this.identifier === identifier && this.equalsToken === equalsToken && this.moduleReference === moduleReference && this.semicolonToken === semicolonToken) { + return this; + } + + return new ImportDeclarationSyntax(modifiers, importKeyword, identifier, equalsToken, moduleReference, semicolonToken, this.parsedInStrictMode()); + }; + + ImportDeclarationSyntax.create = function (importKeyword, identifier, equalsToken, moduleReference, semicolonToken) { + return new ImportDeclarationSyntax(TypeScript.Syntax.emptyList, importKeyword, identifier, equalsToken, moduleReference, semicolonToken, false); + }; + + ImportDeclarationSyntax.create1 = function (identifier, moduleReference) { + return new ImportDeclarationSyntax(TypeScript.Syntax.emptyList, TypeScript.Syntax.token(49 /* ImportKeyword */), identifier, TypeScript.Syntax.token(107 /* EqualsToken */), moduleReference, TypeScript.Syntax.token(78 /* SemicolonToken */), false); + }; + + ImportDeclarationSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ImportDeclarationSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ImportDeclarationSyntax.prototype.withModifiers = function (modifiers) { + return this.update(modifiers, this.importKeyword, this.identifier, this.equalsToken, this.moduleReference, this.semicolonToken); + }; + + ImportDeclarationSyntax.prototype.withModifier = function (modifier) { + return this.withModifiers(TypeScript.Syntax.list([modifier])); + }; + + ImportDeclarationSyntax.prototype.withImportKeyword = function (importKeyword) { + return this.update(this.modifiers, importKeyword, this.identifier, this.equalsToken, this.moduleReference, this.semicolonToken); + }; + + ImportDeclarationSyntax.prototype.withIdentifier = function (identifier) { + return this.update(this.modifiers, this.importKeyword, identifier, this.equalsToken, this.moduleReference, this.semicolonToken); + }; + + ImportDeclarationSyntax.prototype.withEqualsToken = function (equalsToken) { + return this.update(this.modifiers, this.importKeyword, this.identifier, equalsToken, this.moduleReference, this.semicolonToken); + }; + + ImportDeclarationSyntax.prototype.withModuleReference = function (moduleReference) { + return this.update(this.modifiers, this.importKeyword, this.identifier, this.equalsToken, moduleReference, this.semicolonToken); + }; + + ImportDeclarationSyntax.prototype.withSemicolonToken = function (semicolonToken) { + return this.update(this.modifiers, this.importKeyword, this.identifier, this.equalsToken, this.moduleReference, semicolonToken); + }; + + ImportDeclarationSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return ImportDeclarationSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ImportDeclarationSyntax = ImportDeclarationSyntax; + + var ExportAssignmentSyntax = (function (_super) { + __extends(ExportAssignmentSyntax, _super); + function ExportAssignmentSyntax(exportKeyword, equalsToken, identifier, semicolonToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.exportKeyword = exportKeyword; + this.equalsToken = equalsToken; + this.identifier = identifier; + this.semicolonToken = semicolonToken; + } + ExportAssignmentSyntax.prototype.accept = function (visitor) { + return visitor.visitExportAssignment(this); + }; + + ExportAssignmentSyntax.prototype.kind = function () { + return 134 /* ExportAssignment */; + }; + + ExportAssignmentSyntax.prototype.childCount = function () { + return 4; + }; + + ExportAssignmentSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.exportKeyword; + case 1: + return this.equalsToken; + case 2: + return this.identifier; + case 3: + return this.semicolonToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ExportAssignmentSyntax.prototype.isModuleElement = function () { + return true; + }; + + ExportAssignmentSyntax.prototype.update = function (exportKeyword, equalsToken, identifier, semicolonToken) { + if (this.exportKeyword === exportKeyword && this.equalsToken === equalsToken && this.identifier === identifier && this.semicolonToken === semicolonToken) { + return this; + } + + return new ExportAssignmentSyntax(exportKeyword, equalsToken, identifier, semicolonToken, this.parsedInStrictMode()); + }; + + ExportAssignmentSyntax.create1 = function (identifier) { + return new ExportAssignmentSyntax(TypeScript.Syntax.token(47 /* ExportKeyword */), TypeScript.Syntax.token(107 /* EqualsToken */), identifier, TypeScript.Syntax.token(78 /* SemicolonToken */), false); + }; + + ExportAssignmentSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ExportAssignmentSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ExportAssignmentSyntax.prototype.withExportKeyword = function (exportKeyword) { + return this.update(exportKeyword, this.equalsToken, this.identifier, this.semicolonToken); + }; + + ExportAssignmentSyntax.prototype.withEqualsToken = function (equalsToken) { + return this.update(this.exportKeyword, equalsToken, this.identifier, this.semicolonToken); + }; + + ExportAssignmentSyntax.prototype.withIdentifier = function (identifier) { + return this.update(this.exportKeyword, this.equalsToken, identifier, this.semicolonToken); + }; + + ExportAssignmentSyntax.prototype.withSemicolonToken = function (semicolonToken) { + return this.update(this.exportKeyword, this.equalsToken, this.identifier, semicolonToken); + }; + + ExportAssignmentSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return ExportAssignmentSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ExportAssignmentSyntax = ExportAssignmentSyntax; + + var ClassDeclarationSyntax = (function (_super) { + __extends(ClassDeclarationSyntax, _super); + function ClassDeclarationSyntax(modifiers, classKeyword, identifier, typeParameterList, heritageClauses, openBraceToken, classElements, closeBraceToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.modifiers = modifiers; + this.classKeyword = classKeyword; + this.identifier = identifier; + this.typeParameterList = typeParameterList; + this.heritageClauses = heritageClauses; + this.openBraceToken = openBraceToken; + this.classElements = classElements; + this.closeBraceToken = closeBraceToken; + } + ClassDeclarationSyntax.prototype.accept = function (visitor) { + return visitor.visitClassDeclaration(this); + }; + + ClassDeclarationSyntax.prototype.kind = function () { + return 131 /* ClassDeclaration */; + }; + + ClassDeclarationSyntax.prototype.childCount = function () { + return 8; + }; + + ClassDeclarationSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.modifiers; + case 1: + return this.classKeyword; + case 2: + return this.identifier; + case 3: + return this.typeParameterList; + case 4: + return this.heritageClauses; + case 5: + return this.openBraceToken; + case 6: + return this.classElements; + case 7: + return this.closeBraceToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ClassDeclarationSyntax.prototype.isModuleElement = function () { + return true; + }; + + ClassDeclarationSyntax.prototype.update = function (modifiers, classKeyword, identifier, typeParameterList, heritageClauses, openBraceToken, classElements, closeBraceToken) { + if (this.modifiers === modifiers && this.classKeyword === classKeyword && this.identifier === identifier && this.typeParameterList === typeParameterList && this.heritageClauses === heritageClauses && this.openBraceToken === openBraceToken && this.classElements === classElements && this.closeBraceToken === closeBraceToken) { + return this; + } + + return new ClassDeclarationSyntax(modifiers, classKeyword, identifier, typeParameterList, heritageClauses, openBraceToken, classElements, closeBraceToken, this.parsedInStrictMode()); + }; + + ClassDeclarationSyntax.create = function (classKeyword, identifier, openBraceToken, closeBraceToken) { + return new ClassDeclarationSyntax(TypeScript.Syntax.emptyList, classKeyword, identifier, null, TypeScript.Syntax.emptyList, openBraceToken, TypeScript.Syntax.emptyList, closeBraceToken, false); + }; + + ClassDeclarationSyntax.create1 = function (identifier) { + return new ClassDeclarationSyntax(TypeScript.Syntax.emptyList, TypeScript.Syntax.token(44 /* ClassKeyword */), identifier, null, TypeScript.Syntax.emptyList, TypeScript.Syntax.token(70 /* OpenBraceToken */), TypeScript.Syntax.emptyList, TypeScript.Syntax.token(71 /* CloseBraceToken */), false); + }; + + ClassDeclarationSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ClassDeclarationSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ClassDeclarationSyntax.prototype.withModifiers = function (modifiers) { + return this.update(modifiers, this.classKeyword, this.identifier, this.typeParameterList, this.heritageClauses, this.openBraceToken, this.classElements, this.closeBraceToken); + }; + + ClassDeclarationSyntax.prototype.withModifier = function (modifier) { + return this.withModifiers(TypeScript.Syntax.list([modifier])); + }; + + ClassDeclarationSyntax.prototype.withClassKeyword = function (classKeyword) { + return this.update(this.modifiers, classKeyword, this.identifier, this.typeParameterList, this.heritageClauses, this.openBraceToken, this.classElements, this.closeBraceToken); + }; + + ClassDeclarationSyntax.prototype.withIdentifier = function (identifier) { + return this.update(this.modifiers, this.classKeyword, identifier, this.typeParameterList, this.heritageClauses, this.openBraceToken, this.classElements, this.closeBraceToken); + }; + + ClassDeclarationSyntax.prototype.withTypeParameterList = function (typeParameterList) { + return this.update(this.modifiers, this.classKeyword, this.identifier, typeParameterList, this.heritageClauses, this.openBraceToken, this.classElements, this.closeBraceToken); + }; + + ClassDeclarationSyntax.prototype.withHeritageClauses = function (heritageClauses) { + return this.update(this.modifiers, this.classKeyword, this.identifier, this.typeParameterList, heritageClauses, this.openBraceToken, this.classElements, this.closeBraceToken); + }; + + ClassDeclarationSyntax.prototype.withHeritageClause = function (heritageClause) { + return this.withHeritageClauses(TypeScript.Syntax.list([heritageClause])); + }; + + ClassDeclarationSyntax.prototype.withOpenBraceToken = function (openBraceToken) { + return this.update(this.modifiers, this.classKeyword, this.identifier, this.typeParameterList, this.heritageClauses, openBraceToken, this.classElements, this.closeBraceToken); + }; + + ClassDeclarationSyntax.prototype.withClassElements = function (classElements) { + return this.update(this.modifiers, this.classKeyword, this.identifier, this.typeParameterList, this.heritageClauses, this.openBraceToken, classElements, this.closeBraceToken); + }; + + ClassDeclarationSyntax.prototype.withClassElement = function (classElement) { + return this.withClassElements(TypeScript.Syntax.list([classElement])); + }; + + ClassDeclarationSyntax.prototype.withCloseBraceToken = function (closeBraceToken) { + return this.update(this.modifiers, this.classKeyword, this.identifier, this.typeParameterList, this.heritageClauses, this.openBraceToken, this.classElements, closeBraceToken); + }; + + ClassDeclarationSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return ClassDeclarationSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ClassDeclarationSyntax = ClassDeclarationSyntax; + + var InterfaceDeclarationSyntax = (function (_super) { + __extends(InterfaceDeclarationSyntax, _super); + function InterfaceDeclarationSyntax(modifiers, interfaceKeyword, identifier, typeParameterList, heritageClauses, body, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.modifiers = modifiers; + this.interfaceKeyword = interfaceKeyword; + this.identifier = identifier; + this.typeParameterList = typeParameterList; + this.heritageClauses = heritageClauses; + this.body = body; + } + InterfaceDeclarationSyntax.prototype.accept = function (visitor) { + return visitor.visitInterfaceDeclaration(this); + }; + + InterfaceDeclarationSyntax.prototype.kind = function () { + return 128 /* InterfaceDeclaration */; + }; + + InterfaceDeclarationSyntax.prototype.childCount = function () { + return 6; + }; + + InterfaceDeclarationSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.modifiers; + case 1: + return this.interfaceKeyword; + case 2: + return this.identifier; + case 3: + return this.typeParameterList; + case 4: + return this.heritageClauses; + case 5: + return this.body; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + InterfaceDeclarationSyntax.prototype.isModuleElement = function () { + return true; + }; + + InterfaceDeclarationSyntax.prototype.update = function (modifiers, interfaceKeyword, identifier, typeParameterList, heritageClauses, body) { + if (this.modifiers === modifiers && this.interfaceKeyword === interfaceKeyword && this.identifier === identifier && this.typeParameterList === typeParameterList && this.heritageClauses === heritageClauses && this.body === body) { + return this; + } + + return new InterfaceDeclarationSyntax(modifiers, interfaceKeyword, identifier, typeParameterList, heritageClauses, body, this.parsedInStrictMode()); + }; + + InterfaceDeclarationSyntax.create = function (interfaceKeyword, identifier, body) { + return new InterfaceDeclarationSyntax(TypeScript.Syntax.emptyList, interfaceKeyword, identifier, null, TypeScript.Syntax.emptyList, body, false); + }; + + InterfaceDeclarationSyntax.create1 = function (identifier) { + return new InterfaceDeclarationSyntax(TypeScript.Syntax.emptyList, TypeScript.Syntax.token(52 /* InterfaceKeyword */), identifier, null, TypeScript.Syntax.emptyList, ObjectTypeSyntax.create1(), false); + }; + + InterfaceDeclarationSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + InterfaceDeclarationSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + InterfaceDeclarationSyntax.prototype.withModifiers = function (modifiers) { + return this.update(modifiers, this.interfaceKeyword, this.identifier, this.typeParameterList, this.heritageClauses, this.body); + }; + + InterfaceDeclarationSyntax.prototype.withModifier = function (modifier) { + return this.withModifiers(TypeScript.Syntax.list([modifier])); + }; + + InterfaceDeclarationSyntax.prototype.withInterfaceKeyword = function (interfaceKeyword) { + return this.update(this.modifiers, interfaceKeyword, this.identifier, this.typeParameterList, this.heritageClauses, this.body); + }; + + InterfaceDeclarationSyntax.prototype.withIdentifier = function (identifier) { + return this.update(this.modifiers, this.interfaceKeyword, identifier, this.typeParameterList, this.heritageClauses, this.body); + }; + + InterfaceDeclarationSyntax.prototype.withTypeParameterList = function (typeParameterList) { + return this.update(this.modifiers, this.interfaceKeyword, this.identifier, typeParameterList, this.heritageClauses, this.body); + }; + + InterfaceDeclarationSyntax.prototype.withHeritageClauses = function (heritageClauses) { + return this.update(this.modifiers, this.interfaceKeyword, this.identifier, this.typeParameterList, heritageClauses, this.body); + }; + + InterfaceDeclarationSyntax.prototype.withHeritageClause = function (heritageClause) { + return this.withHeritageClauses(TypeScript.Syntax.list([heritageClause])); + }; + + InterfaceDeclarationSyntax.prototype.withBody = function (body) { + return this.update(this.modifiers, this.interfaceKeyword, this.identifier, this.typeParameterList, this.heritageClauses, body); + }; + + InterfaceDeclarationSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return InterfaceDeclarationSyntax; + })(TypeScript.SyntaxNode); + TypeScript.InterfaceDeclarationSyntax = InterfaceDeclarationSyntax; + + var HeritageClauseSyntax = (function (_super) { + __extends(HeritageClauseSyntax, _super); + function HeritageClauseSyntax(extendsOrImplementsKeyword, typeNames, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.extendsOrImplementsKeyword = extendsOrImplementsKeyword; + this.typeNames = typeNames; + } + HeritageClauseSyntax.prototype.accept = function (visitor) { + return visitor.visitHeritageClause(this); + }; + + HeritageClauseSyntax.prototype.kind = function () { + return 229 /* HeritageClause */; + }; + + HeritageClauseSyntax.prototype.childCount = function () { + return 2; + }; + + HeritageClauseSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.extendsOrImplementsKeyword; + case 1: + return this.typeNames; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + HeritageClauseSyntax.prototype.update = function (extendsOrImplementsKeyword, typeNames) { + if (this.extendsOrImplementsKeyword === extendsOrImplementsKeyword && this.typeNames === typeNames) { + return this; + } + + return new HeritageClauseSyntax(extendsOrImplementsKeyword, typeNames, this.parsedInStrictMode()); + }; + + HeritageClauseSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + HeritageClauseSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + HeritageClauseSyntax.prototype.withExtendsOrImplementsKeyword = function (extendsOrImplementsKeyword) { + return this.update(extendsOrImplementsKeyword, this.typeNames); + }; + + HeritageClauseSyntax.prototype.withTypeNames = function (typeNames) { + return this.update(this.extendsOrImplementsKeyword, typeNames); + }; + + HeritageClauseSyntax.prototype.withTypeName = function (typeName) { + return this.withTypeNames(TypeScript.Syntax.separatedList([typeName])); + }; + + HeritageClauseSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return HeritageClauseSyntax; + })(TypeScript.SyntaxNode); + TypeScript.HeritageClauseSyntax = HeritageClauseSyntax; + + var ModuleDeclarationSyntax = (function (_super) { + __extends(ModuleDeclarationSyntax, _super); + function ModuleDeclarationSyntax(modifiers, moduleKeyword, moduleName, stringLiteral, openBraceToken, moduleElements, closeBraceToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.modifiers = modifiers; + this.moduleKeyword = moduleKeyword; + this.moduleName = moduleName; + this.stringLiteral = stringLiteral; + this.openBraceToken = openBraceToken; + this.moduleElements = moduleElements; + this.closeBraceToken = closeBraceToken; + } + ModuleDeclarationSyntax.prototype.accept = function (visitor) { + return visitor.visitModuleDeclaration(this); + }; + + ModuleDeclarationSyntax.prototype.kind = function () { + return 130 /* ModuleDeclaration */; + }; + + ModuleDeclarationSyntax.prototype.childCount = function () { + return 7; + }; + + ModuleDeclarationSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.modifiers; + case 1: + return this.moduleKeyword; + case 2: + return this.moduleName; + case 3: + return this.stringLiteral; + case 4: + return this.openBraceToken; + case 5: + return this.moduleElements; + case 6: + return this.closeBraceToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ModuleDeclarationSyntax.prototype.isModuleElement = function () { + return true; + }; + + ModuleDeclarationSyntax.prototype.update = function (modifiers, moduleKeyword, moduleName, stringLiteral, openBraceToken, moduleElements, closeBraceToken) { + if (this.modifiers === modifiers && this.moduleKeyword === moduleKeyword && this.moduleName === moduleName && this.stringLiteral === stringLiteral && this.openBraceToken === openBraceToken && this.moduleElements === moduleElements && this.closeBraceToken === closeBraceToken) { + return this; + } + + return new ModuleDeclarationSyntax(modifiers, moduleKeyword, moduleName, stringLiteral, openBraceToken, moduleElements, closeBraceToken, this.parsedInStrictMode()); + }; + + ModuleDeclarationSyntax.create = function (moduleKeyword, openBraceToken, closeBraceToken) { + return new ModuleDeclarationSyntax(TypeScript.Syntax.emptyList, moduleKeyword, null, null, openBraceToken, TypeScript.Syntax.emptyList, closeBraceToken, false); + }; + + ModuleDeclarationSyntax.create1 = function () { + return new ModuleDeclarationSyntax(TypeScript.Syntax.emptyList, TypeScript.Syntax.token(65 /* ModuleKeyword */), null, null, TypeScript.Syntax.token(70 /* OpenBraceToken */), TypeScript.Syntax.emptyList, TypeScript.Syntax.token(71 /* CloseBraceToken */), false); + }; + + ModuleDeclarationSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ModuleDeclarationSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ModuleDeclarationSyntax.prototype.withModifiers = function (modifiers) { + return this.update(modifiers, this.moduleKeyword, this.moduleName, this.stringLiteral, this.openBraceToken, this.moduleElements, this.closeBraceToken); + }; + + ModuleDeclarationSyntax.prototype.withModifier = function (modifier) { + return this.withModifiers(TypeScript.Syntax.list([modifier])); + }; + + ModuleDeclarationSyntax.prototype.withModuleKeyword = function (moduleKeyword) { + return this.update(this.modifiers, moduleKeyword, this.moduleName, this.stringLiteral, this.openBraceToken, this.moduleElements, this.closeBraceToken); + }; + + ModuleDeclarationSyntax.prototype.withModuleName = function (moduleName) { + return this.update(this.modifiers, this.moduleKeyword, moduleName, this.stringLiteral, this.openBraceToken, this.moduleElements, this.closeBraceToken); + }; + + ModuleDeclarationSyntax.prototype.withStringLiteral = function (stringLiteral) { + return this.update(this.modifiers, this.moduleKeyword, this.moduleName, stringLiteral, this.openBraceToken, this.moduleElements, this.closeBraceToken); + }; + + ModuleDeclarationSyntax.prototype.withOpenBraceToken = function (openBraceToken) { + return this.update(this.modifiers, this.moduleKeyword, this.moduleName, this.stringLiteral, openBraceToken, this.moduleElements, this.closeBraceToken); + }; + + ModuleDeclarationSyntax.prototype.withModuleElements = function (moduleElements) { + return this.update(this.modifiers, this.moduleKeyword, this.moduleName, this.stringLiteral, this.openBraceToken, moduleElements, this.closeBraceToken); + }; + + ModuleDeclarationSyntax.prototype.withModuleElement = function (moduleElement) { + return this.withModuleElements(TypeScript.Syntax.list([moduleElement])); + }; + + ModuleDeclarationSyntax.prototype.withCloseBraceToken = function (closeBraceToken) { + return this.update(this.modifiers, this.moduleKeyword, this.moduleName, this.stringLiteral, this.openBraceToken, this.moduleElements, closeBraceToken); + }; + + ModuleDeclarationSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return ModuleDeclarationSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ModuleDeclarationSyntax = ModuleDeclarationSyntax; + + var FunctionDeclarationSyntax = (function (_super) { + __extends(FunctionDeclarationSyntax, _super); + function FunctionDeclarationSyntax(modifiers, functionKeyword, identifier, callSignature, block, semicolonToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.modifiers = modifiers; + this.functionKeyword = functionKeyword; + this.identifier = identifier; + this.callSignature = callSignature; + this.block = block; + this.semicolonToken = semicolonToken; + } + FunctionDeclarationSyntax.prototype.accept = function (visitor) { + return visitor.visitFunctionDeclaration(this); + }; + + FunctionDeclarationSyntax.prototype.kind = function () { + return 129 /* FunctionDeclaration */; + }; + + FunctionDeclarationSyntax.prototype.childCount = function () { + return 6; + }; + + FunctionDeclarationSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.modifiers; + case 1: + return this.functionKeyword; + case 2: + return this.identifier; + case 3: + return this.callSignature; + case 4: + return this.block; + case 5: + return this.semicolonToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + FunctionDeclarationSyntax.prototype.isStatement = function () { + return true; + }; + + FunctionDeclarationSyntax.prototype.isModuleElement = function () { + return true; + }; + + FunctionDeclarationSyntax.prototype.update = function (modifiers, functionKeyword, identifier, callSignature, block, semicolonToken) { + if (this.modifiers === modifiers && this.functionKeyword === functionKeyword && this.identifier === identifier && this.callSignature === callSignature && this.block === block && this.semicolonToken === semicolonToken) { + return this; + } + + return new FunctionDeclarationSyntax(modifiers, functionKeyword, identifier, callSignature, block, semicolonToken, this.parsedInStrictMode()); + }; + + FunctionDeclarationSyntax.create = function (functionKeyword, identifier, callSignature) { + return new FunctionDeclarationSyntax(TypeScript.Syntax.emptyList, functionKeyword, identifier, callSignature, null, null, false); + }; + + FunctionDeclarationSyntax.create1 = function (identifier) { + return new FunctionDeclarationSyntax(TypeScript.Syntax.emptyList, TypeScript.Syntax.token(27 /* FunctionKeyword */), identifier, CallSignatureSyntax.create1(), null, null, false); + }; + + FunctionDeclarationSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + FunctionDeclarationSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + FunctionDeclarationSyntax.prototype.withModifiers = function (modifiers) { + return this.update(modifiers, this.functionKeyword, this.identifier, this.callSignature, this.block, this.semicolonToken); + }; + + FunctionDeclarationSyntax.prototype.withModifier = function (modifier) { + return this.withModifiers(TypeScript.Syntax.list([modifier])); + }; + + FunctionDeclarationSyntax.prototype.withFunctionKeyword = function (functionKeyword) { + return this.update(this.modifiers, functionKeyword, this.identifier, this.callSignature, this.block, this.semicolonToken); + }; + + FunctionDeclarationSyntax.prototype.withIdentifier = function (identifier) { + return this.update(this.modifiers, this.functionKeyword, identifier, this.callSignature, this.block, this.semicolonToken); + }; + + FunctionDeclarationSyntax.prototype.withCallSignature = function (callSignature) { + return this.update(this.modifiers, this.functionKeyword, this.identifier, callSignature, this.block, this.semicolonToken); + }; + + FunctionDeclarationSyntax.prototype.withBlock = function (block) { + return this.update(this.modifiers, this.functionKeyword, this.identifier, this.callSignature, block, this.semicolonToken); + }; + + FunctionDeclarationSyntax.prototype.withSemicolonToken = function (semicolonToken) { + return this.update(this.modifiers, this.functionKeyword, this.identifier, this.callSignature, this.block, semicolonToken); + }; + + FunctionDeclarationSyntax.prototype.isTypeScriptSpecific = function () { + if (this.modifiers.isTypeScriptSpecific()) { + return true; + } + if (this.callSignature.isTypeScriptSpecific()) { + return true; + } + if (this.block !== null && this.block.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return FunctionDeclarationSyntax; + })(TypeScript.SyntaxNode); + TypeScript.FunctionDeclarationSyntax = FunctionDeclarationSyntax; + + var VariableStatementSyntax = (function (_super) { + __extends(VariableStatementSyntax, _super); + function VariableStatementSyntax(modifiers, variableDeclaration, semicolonToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.modifiers = modifiers; + this.variableDeclaration = variableDeclaration; + this.semicolonToken = semicolonToken; + } + VariableStatementSyntax.prototype.accept = function (visitor) { + return visitor.visitVariableStatement(this); + }; + + VariableStatementSyntax.prototype.kind = function () { + return 147 /* VariableStatement */; + }; + + VariableStatementSyntax.prototype.childCount = function () { + return 3; + }; + + VariableStatementSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.modifiers; + case 1: + return this.variableDeclaration; + case 2: + return this.semicolonToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + VariableStatementSyntax.prototype.isStatement = function () { + return true; + }; + + VariableStatementSyntax.prototype.isModuleElement = function () { + return true; + }; + + VariableStatementSyntax.prototype.update = function (modifiers, variableDeclaration, semicolonToken) { + if (this.modifiers === modifiers && this.variableDeclaration === variableDeclaration && this.semicolonToken === semicolonToken) { + return this; + } + + return new VariableStatementSyntax(modifiers, variableDeclaration, semicolonToken, this.parsedInStrictMode()); + }; + + VariableStatementSyntax.create = function (variableDeclaration, semicolonToken) { + return new VariableStatementSyntax(TypeScript.Syntax.emptyList, variableDeclaration, semicolonToken, false); + }; + + VariableStatementSyntax.create1 = function (variableDeclaration) { + return new VariableStatementSyntax(TypeScript.Syntax.emptyList, variableDeclaration, TypeScript.Syntax.token(78 /* SemicolonToken */), false); + }; + + VariableStatementSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + VariableStatementSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + VariableStatementSyntax.prototype.withModifiers = function (modifiers) { + return this.update(modifiers, this.variableDeclaration, this.semicolonToken); + }; + + VariableStatementSyntax.prototype.withModifier = function (modifier) { + return this.withModifiers(TypeScript.Syntax.list([modifier])); + }; + + VariableStatementSyntax.prototype.withVariableDeclaration = function (variableDeclaration) { + return this.update(this.modifiers, variableDeclaration, this.semicolonToken); + }; + + VariableStatementSyntax.prototype.withSemicolonToken = function (semicolonToken) { + return this.update(this.modifiers, this.variableDeclaration, semicolonToken); + }; + + VariableStatementSyntax.prototype.isTypeScriptSpecific = function () { + if (this.modifiers.isTypeScriptSpecific()) { + return true; + } + if (this.variableDeclaration.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return VariableStatementSyntax; + })(TypeScript.SyntaxNode); + TypeScript.VariableStatementSyntax = VariableStatementSyntax; + + var VariableDeclarationSyntax = (function (_super) { + __extends(VariableDeclarationSyntax, _super); + function VariableDeclarationSyntax(varKeyword, variableDeclarators, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.varKeyword = varKeyword; + this.variableDeclarators = variableDeclarators; + } + VariableDeclarationSyntax.prototype.accept = function (visitor) { + return visitor.visitVariableDeclaration(this); + }; + + VariableDeclarationSyntax.prototype.kind = function () { + return 223 /* VariableDeclaration */; + }; + + VariableDeclarationSyntax.prototype.childCount = function () { + return 2; + }; + + VariableDeclarationSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.varKeyword; + case 1: + return this.variableDeclarators; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + VariableDeclarationSyntax.prototype.update = function (varKeyword, variableDeclarators) { + if (this.varKeyword === varKeyword && this.variableDeclarators === variableDeclarators) { + return this; + } + + return new VariableDeclarationSyntax(varKeyword, variableDeclarators, this.parsedInStrictMode()); + }; + + VariableDeclarationSyntax.create1 = function (variableDeclarators) { + return new VariableDeclarationSyntax(TypeScript.Syntax.token(40 /* VarKeyword */), variableDeclarators, false); + }; + + VariableDeclarationSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + VariableDeclarationSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + VariableDeclarationSyntax.prototype.withVarKeyword = function (varKeyword) { + return this.update(varKeyword, this.variableDeclarators); + }; + + VariableDeclarationSyntax.prototype.withVariableDeclarators = function (variableDeclarators) { + return this.update(this.varKeyword, variableDeclarators); + }; + + VariableDeclarationSyntax.prototype.withVariableDeclarator = function (variableDeclarator) { + return this.withVariableDeclarators(TypeScript.Syntax.separatedList([variableDeclarator])); + }; + + VariableDeclarationSyntax.prototype.isTypeScriptSpecific = function () { + if (this.variableDeclarators.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return VariableDeclarationSyntax; + })(TypeScript.SyntaxNode); + TypeScript.VariableDeclarationSyntax = VariableDeclarationSyntax; + + var VariableDeclaratorSyntax = (function (_super) { + __extends(VariableDeclaratorSyntax, _super); + function VariableDeclaratorSyntax(identifier, typeAnnotation, equalsValueClause, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.identifier = identifier; + this.typeAnnotation = typeAnnotation; + this.equalsValueClause = equalsValueClause; + } + VariableDeclaratorSyntax.prototype.accept = function (visitor) { + return visitor.visitVariableDeclarator(this); + }; + + VariableDeclaratorSyntax.prototype.kind = function () { + return 224 /* VariableDeclarator */; + }; + + VariableDeclaratorSyntax.prototype.childCount = function () { + return 3; + }; + + VariableDeclaratorSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.identifier; + case 1: + return this.typeAnnotation; + case 2: + return this.equalsValueClause; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + VariableDeclaratorSyntax.prototype.update = function (identifier, typeAnnotation, equalsValueClause) { + if (this.identifier === identifier && this.typeAnnotation === typeAnnotation && this.equalsValueClause === equalsValueClause) { + return this; + } + + return new VariableDeclaratorSyntax(identifier, typeAnnotation, equalsValueClause, this.parsedInStrictMode()); + }; + + VariableDeclaratorSyntax.create = function (identifier) { + return new VariableDeclaratorSyntax(identifier, null, null, false); + }; + + VariableDeclaratorSyntax.create1 = function (identifier) { + return new VariableDeclaratorSyntax(identifier, null, null, false); + }; + + VariableDeclaratorSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + VariableDeclaratorSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + VariableDeclaratorSyntax.prototype.withIdentifier = function (identifier) { + return this.update(identifier, this.typeAnnotation, this.equalsValueClause); + }; + + VariableDeclaratorSyntax.prototype.withTypeAnnotation = function (typeAnnotation) { + return this.update(this.identifier, typeAnnotation, this.equalsValueClause); + }; + + VariableDeclaratorSyntax.prototype.withEqualsValueClause = function (equalsValueClause) { + return this.update(this.identifier, this.typeAnnotation, equalsValueClause); + }; + + VariableDeclaratorSyntax.prototype.isTypeScriptSpecific = function () { + if (this.typeAnnotation !== null) { + return true; + } + if (this.equalsValueClause !== null && this.equalsValueClause.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return VariableDeclaratorSyntax; + })(TypeScript.SyntaxNode); + TypeScript.VariableDeclaratorSyntax = VariableDeclaratorSyntax; + + var EqualsValueClauseSyntax = (function (_super) { + __extends(EqualsValueClauseSyntax, _super); + function EqualsValueClauseSyntax(equalsToken, value, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.equalsToken = equalsToken; + this.value = value; + } + EqualsValueClauseSyntax.prototype.accept = function (visitor) { + return visitor.visitEqualsValueClause(this); + }; + + EqualsValueClauseSyntax.prototype.kind = function () { + return 230 /* EqualsValueClause */; + }; + + EqualsValueClauseSyntax.prototype.childCount = function () { + return 2; + }; + + EqualsValueClauseSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.equalsToken; + case 1: + return this.value; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + EqualsValueClauseSyntax.prototype.update = function (equalsToken, value) { + if (this.equalsToken === equalsToken && this.value === value) { + return this; + } + + return new EqualsValueClauseSyntax(equalsToken, value, this.parsedInStrictMode()); + }; + + EqualsValueClauseSyntax.create1 = function (value) { + return new EqualsValueClauseSyntax(TypeScript.Syntax.token(107 /* EqualsToken */), value, false); + }; + + EqualsValueClauseSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + EqualsValueClauseSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + EqualsValueClauseSyntax.prototype.withEqualsToken = function (equalsToken) { + return this.update(equalsToken, this.value); + }; + + EqualsValueClauseSyntax.prototype.withValue = function (value) { + return this.update(this.equalsToken, value); + }; + + EqualsValueClauseSyntax.prototype.isTypeScriptSpecific = function () { + if (this.value.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return EqualsValueClauseSyntax; + })(TypeScript.SyntaxNode); + TypeScript.EqualsValueClauseSyntax = EqualsValueClauseSyntax; + + var PrefixUnaryExpressionSyntax = (function (_super) { + __extends(PrefixUnaryExpressionSyntax, _super); + function PrefixUnaryExpressionSyntax(kind, operatorToken, operand, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.operatorToken = operatorToken; + this.operand = operand; + + this._kind = kind; + } + PrefixUnaryExpressionSyntax.prototype.accept = function (visitor) { + return visitor.visitPrefixUnaryExpression(this); + }; + + PrefixUnaryExpressionSyntax.prototype.childCount = function () { + return 2; + }; + + PrefixUnaryExpressionSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.operatorToken; + case 1: + return this.operand; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + PrefixUnaryExpressionSyntax.prototype.isUnaryExpression = function () { + return true; + }; + + PrefixUnaryExpressionSyntax.prototype.isExpression = function () { + return true; + }; + + PrefixUnaryExpressionSyntax.prototype.kind = function () { + return this._kind; + }; + + PrefixUnaryExpressionSyntax.prototype.update = function (kind, operatorToken, operand) { + if (this._kind === kind && this.operatorToken === operatorToken && this.operand === operand) { + return this; + } + + return new PrefixUnaryExpressionSyntax(kind, operatorToken, operand, this.parsedInStrictMode()); + }; + + PrefixUnaryExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + PrefixUnaryExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + PrefixUnaryExpressionSyntax.prototype.withKind = function (kind) { + return this.update(kind, this.operatorToken, this.operand); + }; + + PrefixUnaryExpressionSyntax.prototype.withOperatorToken = function (operatorToken) { + return this.update(this._kind, operatorToken, this.operand); + }; + + PrefixUnaryExpressionSyntax.prototype.withOperand = function (operand) { + return this.update(this._kind, this.operatorToken, operand); + }; + + PrefixUnaryExpressionSyntax.prototype.isTypeScriptSpecific = function () { + if (this.operand.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return PrefixUnaryExpressionSyntax; + })(TypeScript.SyntaxNode); + TypeScript.PrefixUnaryExpressionSyntax = PrefixUnaryExpressionSyntax; + + var ArrayLiteralExpressionSyntax = (function (_super) { + __extends(ArrayLiteralExpressionSyntax, _super); + function ArrayLiteralExpressionSyntax(openBracketToken, expressions, closeBracketToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.openBracketToken = openBracketToken; + this.expressions = expressions; + this.closeBracketToken = closeBracketToken; + } + ArrayLiteralExpressionSyntax.prototype.accept = function (visitor) { + return visitor.visitArrayLiteralExpression(this); + }; + + ArrayLiteralExpressionSyntax.prototype.kind = function () { + return 213 /* ArrayLiteralExpression */; + }; + + ArrayLiteralExpressionSyntax.prototype.childCount = function () { + return 3; + }; + + ArrayLiteralExpressionSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.openBracketToken; + case 1: + return this.expressions; + case 2: + return this.closeBracketToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ArrayLiteralExpressionSyntax.prototype.isUnaryExpression = function () { + return true; + }; + + ArrayLiteralExpressionSyntax.prototype.isExpression = function () { + return true; + }; + + ArrayLiteralExpressionSyntax.prototype.update = function (openBracketToken, expressions, closeBracketToken) { + if (this.openBracketToken === openBracketToken && this.expressions === expressions && this.closeBracketToken === closeBracketToken) { + return this; + } + + return new ArrayLiteralExpressionSyntax(openBracketToken, expressions, closeBracketToken, this.parsedInStrictMode()); + }; + + ArrayLiteralExpressionSyntax.create = function (openBracketToken, closeBracketToken) { + return new ArrayLiteralExpressionSyntax(openBracketToken, TypeScript.Syntax.emptySeparatedList, closeBracketToken, false); + }; + + ArrayLiteralExpressionSyntax.create1 = function () { + return new ArrayLiteralExpressionSyntax(TypeScript.Syntax.token(74 /* OpenBracketToken */), TypeScript.Syntax.emptySeparatedList, TypeScript.Syntax.token(75 /* CloseBracketToken */), false); + }; + + ArrayLiteralExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ArrayLiteralExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ArrayLiteralExpressionSyntax.prototype.withOpenBracketToken = function (openBracketToken) { + return this.update(openBracketToken, this.expressions, this.closeBracketToken); + }; + + ArrayLiteralExpressionSyntax.prototype.withExpressions = function (expressions) { + return this.update(this.openBracketToken, expressions, this.closeBracketToken); + }; + + ArrayLiteralExpressionSyntax.prototype.withExpression = function (expression) { + return this.withExpressions(TypeScript.Syntax.separatedList([expression])); + }; + + ArrayLiteralExpressionSyntax.prototype.withCloseBracketToken = function (closeBracketToken) { + return this.update(this.openBracketToken, this.expressions, closeBracketToken); + }; + + ArrayLiteralExpressionSyntax.prototype.isTypeScriptSpecific = function () { + if (this.expressions.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return ArrayLiteralExpressionSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ArrayLiteralExpressionSyntax = ArrayLiteralExpressionSyntax; + + var OmittedExpressionSyntax = (function (_super) { + __extends(OmittedExpressionSyntax, _super); + function OmittedExpressionSyntax(parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + } + OmittedExpressionSyntax.prototype.accept = function (visitor) { + return visitor.visitOmittedExpression(this); + }; + + OmittedExpressionSyntax.prototype.kind = function () { + return 222 /* OmittedExpression */; + }; + + OmittedExpressionSyntax.prototype.childCount = function () { + return 0; + }; + + OmittedExpressionSyntax.prototype.childAt = function (slot) { + throw TypeScript.Errors.invalidOperation(); + }; + + OmittedExpressionSyntax.prototype.isExpression = function () { + return true; + }; + + OmittedExpressionSyntax.prototype.update = function () { + return this; + }; + + OmittedExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + OmittedExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + OmittedExpressionSyntax.prototype.isTypeScriptSpecific = function () { + return false; + }; + return OmittedExpressionSyntax; + })(TypeScript.SyntaxNode); + TypeScript.OmittedExpressionSyntax = OmittedExpressionSyntax; + + var ParenthesizedExpressionSyntax = (function (_super) { + __extends(ParenthesizedExpressionSyntax, _super); + function ParenthesizedExpressionSyntax(openParenToken, expression, closeParenToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.openParenToken = openParenToken; + this.expression = expression; + this.closeParenToken = closeParenToken; + } + ParenthesizedExpressionSyntax.prototype.accept = function (visitor) { + return visitor.visitParenthesizedExpression(this); + }; + + ParenthesizedExpressionSyntax.prototype.kind = function () { + return 216 /* ParenthesizedExpression */; + }; + + ParenthesizedExpressionSyntax.prototype.childCount = function () { + return 3; + }; + + ParenthesizedExpressionSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.openParenToken; + case 1: + return this.expression; + case 2: + return this.closeParenToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ParenthesizedExpressionSyntax.prototype.isUnaryExpression = function () { + return true; + }; + + ParenthesizedExpressionSyntax.prototype.isExpression = function () { + return true; + }; + + ParenthesizedExpressionSyntax.prototype.update = function (openParenToken, expression, closeParenToken) { + if (this.openParenToken === openParenToken && this.expression === expression && this.closeParenToken === closeParenToken) { + return this; + } + + return new ParenthesizedExpressionSyntax(openParenToken, expression, closeParenToken, this.parsedInStrictMode()); + }; + + ParenthesizedExpressionSyntax.create1 = function (expression) { + return new ParenthesizedExpressionSyntax(TypeScript.Syntax.token(72 /* OpenParenToken */), expression, TypeScript.Syntax.token(73 /* CloseParenToken */), false); + }; + + ParenthesizedExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ParenthesizedExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ParenthesizedExpressionSyntax.prototype.withOpenParenToken = function (openParenToken) { + return this.update(openParenToken, this.expression, this.closeParenToken); + }; + + ParenthesizedExpressionSyntax.prototype.withExpression = function (expression) { + return this.update(this.openParenToken, expression, this.closeParenToken); + }; + + ParenthesizedExpressionSyntax.prototype.withCloseParenToken = function (closeParenToken) { + return this.update(this.openParenToken, this.expression, closeParenToken); + }; + + ParenthesizedExpressionSyntax.prototype.isTypeScriptSpecific = function () { + if (this.expression.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return ParenthesizedExpressionSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ParenthesizedExpressionSyntax = ParenthesizedExpressionSyntax; + + var ArrowFunctionExpressionSyntax = (function (_super) { + __extends(ArrowFunctionExpressionSyntax, _super); + function ArrowFunctionExpressionSyntax(equalsGreaterThanToken, body, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.equalsGreaterThanToken = equalsGreaterThanToken; + this.body = body; + } + ArrowFunctionExpressionSyntax.prototype.isUnaryExpression = function () { + return true; + }; + + ArrowFunctionExpressionSyntax.prototype.isExpression = function () { + return true; + }; + + ArrowFunctionExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ArrowFunctionExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ArrowFunctionExpressionSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return ArrowFunctionExpressionSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ArrowFunctionExpressionSyntax = ArrowFunctionExpressionSyntax; + + var SimpleArrowFunctionExpressionSyntax = (function (_super) { + __extends(SimpleArrowFunctionExpressionSyntax, _super); + function SimpleArrowFunctionExpressionSyntax(identifier, equalsGreaterThanToken, body, parsedInStrictMode) { + _super.call(this, equalsGreaterThanToken, body, parsedInStrictMode); + this.identifier = identifier; + } + SimpleArrowFunctionExpressionSyntax.prototype.accept = function (visitor) { + return visitor.visitSimpleArrowFunctionExpression(this); + }; + + SimpleArrowFunctionExpressionSyntax.prototype.kind = function () { + return 218 /* SimpleArrowFunctionExpression */; + }; + + SimpleArrowFunctionExpressionSyntax.prototype.childCount = function () { + return 3; + }; + + SimpleArrowFunctionExpressionSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.identifier; + case 1: + return this.equalsGreaterThanToken; + case 2: + return this.body; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + SimpleArrowFunctionExpressionSyntax.prototype.update = function (identifier, equalsGreaterThanToken, body) { + if (this.identifier === identifier && this.equalsGreaterThanToken === equalsGreaterThanToken && this.body === body) { + return this; + } + + return new SimpleArrowFunctionExpressionSyntax(identifier, equalsGreaterThanToken, body, this.parsedInStrictMode()); + }; + + SimpleArrowFunctionExpressionSyntax.create1 = function (identifier, body) { + return new SimpleArrowFunctionExpressionSyntax(identifier, TypeScript.Syntax.token(85 /* EqualsGreaterThanToken */), body, false); + }; + + SimpleArrowFunctionExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + SimpleArrowFunctionExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + SimpleArrowFunctionExpressionSyntax.prototype.withIdentifier = function (identifier) { + return this.update(identifier, this.equalsGreaterThanToken, this.body); + }; + + SimpleArrowFunctionExpressionSyntax.prototype.withEqualsGreaterThanToken = function (equalsGreaterThanToken) { + return this.update(this.identifier, equalsGreaterThanToken, this.body); + }; + + SimpleArrowFunctionExpressionSyntax.prototype.withBody = function (body) { + return this.update(this.identifier, this.equalsGreaterThanToken, body); + }; + + SimpleArrowFunctionExpressionSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return SimpleArrowFunctionExpressionSyntax; + })(ArrowFunctionExpressionSyntax); + TypeScript.SimpleArrowFunctionExpressionSyntax = SimpleArrowFunctionExpressionSyntax; + + var ParenthesizedArrowFunctionExpressionSyntax = (function (_super) { + __extends(ParenthesizedArrowFunctionExpressionSyntax, _super); + function ParenthesizedArrowFunctionExpressionSyntax(callSignature, equalsGreaterThanToken, body, parsedInStrictMode) { + _super.call(this, equalsGreaterThanToken, body, parsedInStrictMode); + this.callSignature = callSignature; + } + ParenthesizedArrowFunctionExpressionSyntax.prototype.accept = function (visitor) { + return visitor.visitParenthesizedArrowFunctionExpression(this); + }; + + ParenthesizedArrowFunctionExpressionSyntax.prototype.kind = function () { + return 217 /* ParenthesizedArrowFunctionExpression */; + }; + + ParenthesizedArrowFunctionExpressionSyntax.prototype.childCount = function () { + return 3; + }; + + ParenthesizedArrowFunctionExpressionSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.callSignature; + case 1: + return this.equalsGreaterThanToken; + case 2: + return this.body; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ParenthesizedArrowFunctionExpressionSyntax.prototype.update = function (callSignature, equalsGreaterThanToken, body) { + if (this.callSignature === callSignature && this.equalsGreaterThanToken === equalsGreaterThanToken && this.body === body) { + return this; + } + + return new ParenthesizedArrowFunctionExpressionSyntax(callSignature, equalsGreaterThanToken, body, this.parsedInStrictMode()); + }; + + ParenthesizedArrowFunctionExpressionSyntax.create1 = function (body) { + return new ParenthesizedArrowFunctionExpressionSyntax(CallSignatureSyntax.create1(), TypeScript.Syntax.token(85 /* EqualsGreaterThanToken */), body, false); + }; + + ParenthesizedArrowFunctionExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ParenthesizedArrowFunctionExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ParenthesizedArrowFunctionExpressionSyntax.prototype.withCallSignature = function (callSignature) { + return this.update(callSignature, this.equalsGreaterThanToken, this.body); + }; + + ParenthesizedArrowFunctionExpressionSyntax.prototype.withEqualsGreaterThanToken = function (equalsGreaterThanToken) { + return this.update(this.callSignature, equalsGreaterThanToken, this.body); + }; + + ParenthesizedArrowFunctionExpressionSyntax.prototype.withBody = function (body) { + return this.update(this.callSignature, this.equalsGreaterThanToken, body); + }; + + ParenthesizedArrowFunctionExpressionSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return ParenthesizedArrowFunctionExpressionSyntax; + })(ArrowFunctionExpressionSyntax); + TypeScript.ParenthesizedArrowFunctionExpressionSyntax = ParenthesizedArrowFunctionExpressionSyntax; + + var QualifiedNameSyntax = (function (_super) { + __extends(QualifiedNameSyntax, _super); + function QualifiedNameSyntax(left, dotToken, right, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.left = left; + this.dotToken = dotToken; + this.right = right; + } + QualifiedNameSyntax.prototype.accept = function (visitor) { + return visitor.visitQualifiedName(this); + }; + + QualifiedNameSyntax.prototype.kind = function () { + return 121 /* QualifiedName */; + }; + + QualifiedNameSyntax.prototype.childCount = function () { + return 3; + }; + + QualifiedNameSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.left; + case 1: + return this.dotToken; + case 2: + return this.right; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + QualifiedNameSyntax.prototype.isName = function () { + return true; + }; + + QualifiedNameSyntax.prototype.isType = function () { + return true; + }; + + QualifiedNameSyntax.prototype.isUnaryExpression = function () { + return true; + }; + + QualifiedNameSyntax.prototype.isExpression = function () { + return true; + }; + + QualifiedNameSyntax.prototype.update = function (left, dotToken, right) { + if (this.left === left && this.dotToken === dotToken && this.right === right) { + return this; + } + + return new QualifiedNameSyntax(left, dotToken, right, this.parsedInStrictMode()); + }; + + QualifiedNameSyntax.create1 = function (left, right) { + return new QualifiedNameSyntax(left, TypeScript.Syntax.token(76 /* DotToken */), right, false); + }; + + QualifiedNameSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + QualifiedNameSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + QualifiedNameSyntax.prototype.withLeft = function (left) { + return this.update(left, this.dotToken, this.right); + }; + + QualifiedNameSyntax.prototype.withDotToken = function (dotToken) { + return this.update(this.left, dotToken, this.right); + }; + + QualifiedNameSyntax.prototype.withRight = function (right) { + return this.update(this.left, this.dotToken, right); + }; + + QualifiedNameSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return QualifiedNameSyntax; + })(TypeScript.SyntaxNode); + TypeScript.QualifiedNameSyntax = QualifiedNameSyntax; + + var TypeArgumentListSyntax = (function (_super) { + __extends(TypeArgumentListSyntax, _super); + function TypeArgumentListSyntax(lessThanToken, typeArguments, greaterThanToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.lessThanToken = lessThanToken; + this.typeArguments = typeArguments; + this.greaterThanToken = greaterThanToken; + } + TypeArgumentListSyntax.prototype.accept = function (visitor) { + return visitor.visitTypeArgumentList(this); + }; + + TypeArgumentListSyntax.prototype.kind = function () { + return 227 /* TypeArgumentList */; + }; + + TypeArgumentListSyntax.prototype.childCount = function () { + return 3; + }; + + TypeArgumentListSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.lessThanToken; + case 1: + return this.typeArguments; + case 2: + return this.greaterThanToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + TypeArgumentListSyntax.prototype.update = function (lessThanToken, typeArguments, greaterThanToken) { + if (this.lessThanToken === lessThanToken && this.typeArguments === typeArguments && this.greaterThanToken === greaterThanToken) { + return this; + } + + return new TypeArgumentListSyntax(lessThanToken, typeArguments, greaterThanToken, this.parsedInStrictMode()); + }; + + TypeArgumentListSyntax.create = function (lessThanToken, greaterThanToken) { + return new TypeArgumentListSyntax(lessThanToken, TypeScript.Syntax.emptySeparatedList, greaterThanToken, false); + }; + + TypeArgumentListSyntax.create1 = function () { + return new TypeArgumentListSyntax(TypeScript.Syntax.token(80 /* LessThanToken */), TypeScript.Syntax.emptySeparatedList, TypeScript.Syntax.token(81 /* GreaterThanToken */), false); + }; + + TypeArgumentListSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + TypeArgumentListSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + TypeArgumentListSyntax.prototype.withLessThanToken = function (lessThanToken) { + return this.update(lessThanToken, this.typeArguments, this.greaterThanToken); + }; + + TypeArgumentListSyntax.prototype.withTypeArguments = function (typeArguments) { + return this.update(this.lessThanToken, typeArguments, this.greaterThanToken); + }; + + TypeArgumentListSyntax.prototype.withTypeArgument = function (typeArgument) { + return this.withTypeArguments(TypeScript.Syntax.separatedList([typeArgument])); + }; + + TypeArgumentListSyntax.prototype.withGreaterThanToken = function (greaterThanToken) { + return this.update(this.lessThanToken, this.typeArguments, greaterThanToken); + }; + + TypeArgumentListSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return TypeArgumentListSyntax; + })(TypeScript.SyntaxNode); + TypeScript.TypeArgumentListSyntax = TypeArgumentListSyntax; + + var ConstructorTypeSyntax = (function (_super) { + __extends(ConstructorTypeSyntax, _super); + function ConstructorTypeSyntax(newKeyword, typeParameterList, parameterList, equalsGreaterThanToken, type, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.newKeyword = newKeyword; + this.typeParameterList = typeParameterList; + this.parameterList = parameterList; + this.equalsGreaterThanToken = equalsGreaterThanToken; + this.type = type; + } + ConstructorTypeSyntax.prototype.accept = function (visitor) { + return visitor.visitConstructorType(this); + }; + + ConstructorTypeSyntax.prototype.kind = function () { + return 125 /* ConstructorType */; + }; + + ConstructorTypeSyntax.prototype.childCount = function () { + return 5; + }; + + ConstructorTypeSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.newKeyword; + case 1: + return this.typeParameterList; + case 2: + return this.parameterList; + case 3: + return this.equalsGreaterThanToken; + case 4: + return this.type; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ConstructorTypeSyntax.prototype.isType = function () { + return true; + }; + + ConstructorTypeSyntax.prototype.isUnaryExpression = function () { + return true; + }; + + ConstructorTypeSyntax.prototype.isExpression = function () { + return true; + }; + + ConstructorTypeSyntax.prototype.update = function (newKeyword, typeParameterList, parameterList, equalsGreaterThanToken, type) { + if (this.newKeyword === newKeyword && this.typeParameterList === typeParameterList && this.parameterList === parameterList && this.equalsGreaterThanToken === equalsGreaterThanToken && this.type === type) { + return this; + } + + return new ConstructorTypeSyntax(newKeyword, typeParameterList, parameterList, equalsGreaterThanToken, type, this.parsedInStrictMode()); + }; + + ConstructorTypeSyntax.create = function (newKeyword, parameterList, equalsGreaterThanToken, type) { + return new ConstructorTypeSyntax(newKeyword, null, parameterList, equalsGreaterThanToken, type, false); + }; + + ConstructorTypeSyntax.create1 = function (type) { + return new ConstructorTypeSyntax(TypeScript.Syntax.token(31 /* NewKeyword */), null, ParameterListSyntax.create1(), TypeScript.Syntax.token(85 /* EqualsGreaterThanToken */), type, false); + }; + + ConstructorTypeSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ConstructorTypeSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ConstructorTypeSyntax.prototype.withNewKeyword = function (newKeyword) { + return this.update(newKeyword, this.typeParameterList, this.parameterList, this.equalsGreaterThanToken, this.type); + }; + + ConstructorTypeSyntax.prototype.withTypeParameterList = function (typeParameterList) { + return this.update(this.newKeyword, typeParameterList, this.parameterList, this.equalsGreaterThanToken, this.type); + }; + + ConstructorTypeSyntax.prototype.withParameterList = function (parameterList) { + return this.update(this.newKeyword, this.typeParameterList, parameterList, this.equalsGreaterThanToken, this.type); + }; + + ConstructorTypeSyntax.prototype.withEqualsGreaterThanToken = function (equalsGreaterThanToken) { + return this.update(this.newKeyword, this.typeParameterList, this.parameterList, equalsGreaterThanToken, this.type); + }; + + ConstructorTypeSyntax.prototype.withType = function (type) { + return this.update(this.newKeyword, this.typeParameterList, this.parameterList, this.equalsGreaterThanToken, type); + }; + + ConstructorTypeSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return ConstructorTypeSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ConstructorTypeSyntax = ConstructorTypeSyntax; + + var FunctionTypeSyntax = (function (_super) { + __extends(FunctionTypeSyntax, _super); + function FunctionTypeSyntax(typeParameterList, parameterList, equalsGreaterThanToken, type, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.typeParameterList = typeParameterList; + this.parameterList = parameterList; + this.equalsGreaterThanToken = equalsGreaterThanToken; + this.type = type; + } + FunctionTypeSyntax.prototype.accept = function (visitor) { + return visitor.visitFunctionType(this); + }; + + FunctionTypeSyntax.prototype.kind = function () { + return 123 /* FunctionType */; + }; + + FunctionTypeSyntax.prototype.childCount = function () { + return 4; + }; + + FunctionTypeSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.typeParameterList; + case 1: + return this.parameterList; + case 2: + return this.equalsGreaterThanToken; + case 3: + return this.type; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + FunctionTypeSyntax.prototype.isType = function () { + return true; + }; + + FunctionTypeSyntax.prototype.isUnaryExpression = function () { + return true; + }; + + FunctionTypeSyntax.prototype.isExpression = function () { + return true; + }; + + FunctionTypeSyntax.prototype.update = function (typeParameterList, parameterList, equalsGreaterThanToken, type) { + if (this.typeParameterList === typeParameterList && this.parameterList === parameterList && this.equalsGreaterThanToken === equalsGreaterThanToken && this.type === type) { + return this; + } + + return new FunctionTypeSyntax(typeParameterList, parameterList, equalsGreaterThanToken, type, this.parsedInStrictMode()); + }; + + FunctionTypeSyntax.create = function (parameterList, equalsGreaterThanToken, type) { + return new FunctionTypeSyntax(null, parameterList, equalsGreaterThanToken, type, false); + }; + + FunctionTypeSyntax.create1 = function (type) { + return new FunctionTypeSyntax(null, ParameterListSyntax.create1(), TypeScript.Syntax.token(85 /* EqualsGreaterThanToken */), type, false); + }; + + FunctionTypeSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + FunctionTypeSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + FunctionTypeSyntax.prototype.withTypeParameterList = function (typeParameterList) { + return this.update(typeParameterList, this.parameterList, this.equalsGreaterThanToken, this.type); + }; + + FunctionTypeSyntax.prototype.withParameterList = function (parameterList) { + return this.update(this.typeParameterList, parameterList, this.equalsGreaterThanToken, this.type); + }; + + FunctionTypeSyntax.prototype.withEqualsGreaterThanToken = function (equalsGreaterThanToken) { + return this.update(this.typeParameterList, this.parameterList, equalsGreaterThanToken, this.type); + }; + + FunctionTypeSyntax.prototype.withType = function (type) { + return this.update(this.typeParameterList, this.parameterList, this.equalsGreaterThanToken, type); + }; + + FunctionTypeSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return FunctionTypeSyntax; + })(TypeScript.SyntaxNode); + TypeScript.FunctionTypeSyntax = FunctionTypeSyntax; + + var ObjectTypeSyntax = (function (_super) { + __extends(ObjectTypeSyntax, _super); + function ObjectTypeSyntax(openBraceToken, typeMembers, closeBraceToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.openBraceToken = openBraceToken; + this.typeMembers = typeMembers; + this.closeBraceToken = closeBraceToken; + } + ObjectTypeSyntax.prototype.accept = function (visitor) { + return visitor.visitObjectType(this); + }; + + ObjectTypeSyntax.prototype.kind = function () { + return 122 /* ObjectType */; + }; + + ObjectTypeSyntax.prototype.childCount = function () { + return 3; + }; + + ObjectTypeSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.openBraceToken; + case 1: + return this.typeMembers; + case 2: + return this.closeBraceToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ObjectTypeSyntax.prototype.isType = function () { + return true; + }; + + ObjectTypeSyntax.prototype.isUnaryExpression = function () { + return true; + }; + + ObjectTypeSyntax.prototype.isExpression = function () { + return true; + }; + + ObjectTypeSyntax.prototype.update = function (openBraceToken, typeMembers, closeBraceToken) { + if (this.openBraceToken === openBraceToken && this.typeMembers === typeMembers && this.closeBraceToken === closeBraceToken) { + return this; + } + + return new ObjectTypeSyntax(openBraceToken, typeMembers, closeBraceToken, this.parsedInStrictMode()); + }; + + ObjectTypeSyntax.create = function (openBraceToken, closeBraceToken) { + return new ObjectTypeSyntax(openBraceToken, TypeScript.Syntax.emptySeparatedList, closeBraceToken, false); + }; + + ObjectTypeSyntax.create1 = function () { + return new ObjectTypeSyntax(TypeScript.Syntax.token(70 /* OpenBraceToken */), TypeScript.Syntax.emptySeparatedList, TypeScript.Syntax.token(71 /* CloseBraceToken */), false); + }; + + ObjectTypeSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ObjectTypeSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ObjectTypeSyntax.prototype.withOpenBraceToken = function (openBraceToken) { + return this.update(openBraceToken, this.typeMembers, this.closeBraceToken); + }; + + ObjectTypeSyntax.prototype.withTypeMembers = function (typeMembers) { + return this.update(this.openBraceToken, typeMembers, this.closeBraceToken); + }; + + ObjectTypeSyntax.prototype.withTypeMember = function (typeMember) { + return this.withTypeMembers(TypeScript.Syntax.separatedList([typeMember])); + }; + + ObjectTypeSyntax.prototype.withCloseBraceToken = function (closeBraceToken) { + return this.update(this.openBraceToken, this.typeMembers, closeBraceToken); + }; + + ObjectTypeSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return ObjectTypeSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ObjectTypeSyntax = ObjectTypeSyntax; + + var ArrayTypeSyntax = (function (_super) { + __extends(ArrayTypeSyntax, _super); + function ArrayTypeSyntax(type, openBracketToken, closeBracketToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.type = type; + this.openBracketToken = openBracketToken; + this.closeBracketToken = closeBracketToken; + } + ArrayTypeSyntax.prototype.accept = function (visitor) { + return visitor.visitArrayType(this); + }; + + ArrayTypeSyntax.prototype.kind = function () { + return 124 /* ArrayType */; + }; + + ArrayTypeSyntax.prototype.childCount = function () { + return 3; + }; + + ArrayTypeSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.type; + case 1: + return this.openBracketToken; + case 2: + return this.closeBracketToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ArrayTypeSyntax.prototype.isType = function () { + return true; + }; + + ArrayTypeSyntax.prototype.isUnaryExpression = function () { + return true; + }; + + ArrayTypeSyntax.prototype.isExpression = function () { + return true; + }; + + ArrayTypeSyntax.prototype.update = function (type, openBracketToken, closeBracketToken) { + if (this.type === type && this.openBracketToken === openBracketToken && this.closeBracketToken === closeBracketToken) { + return this; + } + + return new ArrayTypeSyntax(type, openBracketToken, closeBracketToken, this.parsedInStrictMode()); + }; + + ArrayTypeSyntax.create1 = function (type) { + return new ArrayTypeSyntax(type, TypeScript.Syntax.token(74 /* OpenBracketToken */), TypeScript.Syntax.token(75 /* CloseBracketToken */), false); + }; + + ArrayTypeSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ArrayTypeSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ArrayTypeSyntax.prototype.withType = function (type) { + return this.update(type, this.openBracketToken, this.closeBracketToken); + }; + + ArrayTypeSyntax.prototype.withOpenBracketToken = function (openBracketToken) { + return this.update(this.type, openBracketToken, this.closeBracketToken); + }; + + ArrayTypeSyntax.prototype.withCloseBracketToken = function (closeBracketToken) { + return this.update(this.type, this.openBracketToken, closeBracketToken); + }; + + ArrayTypeSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return ArrayTypeSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ArrayTypeSyntax = ArrayTypeSyntax; + + var GenericTypeSyntax = (function (_super) { + __extends(GenericTypeSyntax, _super); + function GenericTypeSyntax(name, typeArgumentList, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.name = name; + this.typeArgumentList = typeArgumentList; + } + GenericTypeSyntax.prototype.accept = function (visitor) { + return visitor.visitGenericType(this); + }; + + GenericTypeSyntax.prototype.kind = function () { + return 126 /* GenericType */; + }; + + GenericTypeSyntax.prototype.childCount = function () { + return 2; + }; + + GenericTypeSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.name; + case 1: + return this.typeArgumentList; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + GenericTypeSyntax.prototype.isType = function () { + return true; + }; + + GenericTypeSyntax.prototype.isUnaryExpression = function () { + return true; + }; + + GenericTypeSyntax.prototype.isExpression = function () { + return true; + }; + + GenericTypeSyntax.prototype.update = function (name, typeArgumentList) { + if (this.name === name && this.typeArgumentList === typeArgumentList) { + return this; + } + + return new GenericTypeSyntax(name, typeArgumentList, this.parsedInStrictMode()); + }; + + GenericTypeSyntax.create1 = function (name) { + return new GenericTypeSyntax(name, TypeArgumentListSyntax.create1(), false); + }; + + GenericTypeSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + GenericTypeSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + GenericTypeSyntax.prototype.withName = function (name) { + return this.update(name, this.typeArgumentList); + }; + + GenericTypeSyntax.prototype.withTypeArgumentList = function (typeArgumentList) { + return this.update(this.name, typeArgumentList); + }; + + GenericTypeSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return GenericTypeSyntax; + })(TypeScript.SyntaxNode); + TypeScript.GenericTypeSyntax = GenericTypeSyntax; + + var TypeQuerySyntax = (function (_super) { + __extends(TypeQuerySyntax, _super); + function TypeQuerySyntax(typeOfKeyword, name, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.typeOfKeyword = typeOfKeyword; + this.name = name; + } + TypeQuerySyntax.prototype.accept = function (visitor) { + return visitor.visitTypeQuery(this); + }; + + TypeQuerySyntax.prototype.kind = function () { + return 127 /* TypeQuery */; + }; + + TypeQuerySyntax.prototype.childCount = function () { + return 2; + }; + + TypeQuerySyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.typeOfKeyword; + case 1: + return this.name; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + TypeQuerySyntax.prototype.isType = function () { + return true; + }; + + TypeQuerySyntax.prototype.isUnaryExpression = function () { + return true; + }; + + TypeQuerySyntax.prototype.isExpression = function () { + return true; + }; + + TypeQuerySyntax.prototype.update = function (typeOfKeyword, name) { + if (this.typeOfKeyword === typeOfKeyword && this.name === name) { + return this; + } + + return new TypeQuerySyntax(typeOfKeyword, name, this.parsedInStrictMode()); + }; + + TypeQuerySyntax.create1 = function (name) { + return new TypeQuerySyntax(TypeScript.Syntax.token(39 /* TypeOfKeyword */), name, false); + }; + + TypeQuerySyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + TypeQuerySyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + TypeQuerySyntax.prototype.withTypeOfKeyword = function (typeOfKeyword) { + return this.update(typeOfKeyword, this.name); + }; + + TypeQuerySyntax.prototype.withName = function (name) { + return this.update(this.typeOfKeyword, name); + }; + + TypeQuerySyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return TypeQuerySyntax; + })(TypeScript.SyntaxNode); + TypeScript.TypeQuerySyntax = TypeQuerySyntax; + + var TypeAnnotationSyntax = (function (_super) { + __extends(TypeAnnotationSyntax, _super); + function TypeAnnotationSyntax(colonToken, type, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.colonToken = colonToken; + this.type = type; + } + TypeAnnotationSyntax.prototype.accept = function (visitor) { + return visitor.visitTypeAnnotation(this); + }; + + TypeAnnotationSyntax.prototype.kind = function () { + return 244 /* TypeAnnotation */; + }; + + TypeAnnotationSyntax.prototype.childCount = function () { + return 2; + }; + + TypeAnnotationSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.colonToken; + case 1: + return this.type; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + TypeAnnotationSyntax.prototype.update = function (colonToken, type) { + if (this.colonToken === colonToken && this.type === type) { + return this; + } + + return new TypeAnnotationSyntax(colonToken, type, this.parsedInStrictMode()); + }; + + TypeAnnotationSyntax.create1 = function (type) { + return new TypeAnnotationSyntax(TypeScript.Syntax.token(106 /* ColonToken */), type, false); + }; + + TypeAnnotationSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + TypeAnnotationSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + TypeAnnotationSyntax.prototype.withColonToken = function (colonToken) { + return this.update(colonToken, this.type); + }; + + TypeAnnotationSyntax.prototype.withType = function (type) { + return this.update(this.colonToken, type); + }; + + TypeAnnotationSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return TypeAnnotationSyntax; + })(TypeScript.SyntaxNode); + TypeScript.TypeAnnotationSyntax = TypeAnnotationSyntax; + + var BlockSyntax = (function (_super) { + __extends(BlockSyntax, _super); + function BlockSyntax(openBraceToken, statements, closeBraceToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.openBraceToken = openBraceToken; + this.statements = statements; + this.closeBraceToken = closeBraceToken; + } + BlockSyntax.prototype.accept = function (visitor) { + return visitor.visitBlock(this); + }; + + BlockSyntax.prototype.kind = function () { + return 145 /* Block */; + }; + + BlockSyntax.prototype.childCount = function () { + return 3; + }; + + BlockSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.openBraceToken; + case 1: + return this.statements; + case 2: + return this.closeBraceToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + BlockSyntax.prototype.isStatement = function () { + return true; + }; + + BlockSyntax.prototype.isModuleElement = function () { + return true; + }; + + BlockSyntax.prototype.update = function (openBraceToken, statements, closeBraceToken) { + if (this.openBraceToken === openBraceToken && this.statements === statements && this.closeBraceToken === closeBraceToken) { + return this; + } + + return new BlockSyntax(openBraceToken, statements, closeBraceToken, this.parsedInStrictMode()); + }; + + BlockSyntax.create = function (openBraceToken, closeBraceToken) { + return new BlockSyntax(openBraceToken, TypeScript.Syntax.emptyList, closeBraceToken, false); + }; + + BlockSyntax.create1 = function () { + return new BlockSyntax(TypeScript.Syntax.token(70 /* OpenBraceToken */), TypeScript.Syntax.emptyList, TypeScript.Syntax.token(71 /* CloseBraceToken */), false); + }; + + BlockSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + BlockSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + BlockSyntax.prototype.withOpenBraceToken = function (openBraceToken) { + return this.update(openBraceToken, this.statements, this.closeBraceToken); + }; + + BlockSyntax.prototype.withStatements = function (statements) { + return this.update(this.openBraceToken, statements, this.closeBraceToken); + }; + + BlockSyntax.prototype.withStatement = function (statement) { + return this.withStatements(TypeScript.Syntax.list([statement])); + }; + + BlockSyntax.prototype.withCloseBraceToken = function (closeBraceToken) { + return this.update(this.openBraceToken, this.statements, closeBraceToken); + }; + + BlockSyntax.prototype.isTypeScriptSpecific = function () { + if (this.statements.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return BlockSyntax; + })(TypeScript.SyntaxNode); + TypeScript.BlockSyntax = BlockSyntax; + + var ParameterSyntax = (function (_super) { + __extends(ParameterSyntax, _super); + function ParameterSyntax(dotDotDotToken, publicOrPrivateKeyword, identifier, questionToken, typeAnnotation, equalsValueClause, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.dotDotDotToken = dotDotDotToken; + this.publicOrPrivateKeyword = publicOrPrivateKeyword; + this.identifier = identifier; + this.questionToken = questionToken; + this.typeAnnotation = typeAnnotation; + this.equalsValueClause = equalsValueClause; + } + ParameterSyntax.prototype.accept = function (visitor) { + return visitor.visitParameter(this); + }; + + ParameterSyntax.prototype.kind = function () { + return 242 /* Parameter */; + }; + + ParameterSyntax.prototype.childCount = function () { + return 6; + }; + + ParameterSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.dotDotDotToken; + case 1: + return this.publicOrPrivateKeyword; + case 2: + return this.identifier; + case 3: + return this.questionToken; + case 4: + return this.typeAnnotation; + case 5: + return this.equalsValueClause; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ParameterSyntax.prototype.update = function (dotDotDotToken, publicOrPrivateKeyword, identifier, questionToken, typeAnnotation, equalsValueClause) { + if (this.dotDotDotToken === dotDotDotToken && this.publicOrPrivateKeyword === publicOrPrivateKeyword && this.identifier === identifier && this.questionToken === questionToken && this.typeAnnotation === typeAnnotation && this.equalsValueClause === equalsValueClause) { + return this; + } + + return new ParameterSyntax(dotDotDotToken, publicOrPrivateKeyword, identifier, questionToken, typeAnnotation, equalsValueClause, this.parsedInStrictMode()); + }; + + ParameterSyntax.create = function (identifier) { + return new ParameterSyntax(null, null, identifier, null, null, null, false); + }; + + ParameterSyntax.create1 = function (identifier) { + return new ParameterSyntax(null, null, identifier, null, null, null, false); + }; + + ParameterSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ParameterSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ParameterSyntax.prototype.withDotDotDotToken = function (dotDotDotToken) { + return this.update(dotDotDotToken, this.publicOrPrivateKeyword, this.identifier, this.questionToken, this.typeAnnotation, this.equalsValueClause); + }; + + ParameterSyntax.prototype.withPublicOrPrivateKeyword = function (publicOrPrivateKeyword) { + return this.update(this.dotDotDotToken, publicOrPrivateKeyword, this.identifier, this.questionToken, this.typeAnnotation, this.equalsValueClause); + }; + + ParameterSyntax.prototype.withIdentifier = function (identifier) { + return this.update(this.dotDotDotToken, this.publicOrPrivateKeyword, identifier, this.questionToken, this.typeAnnotation, this.equalsValueClause); + }; + + ParameterSyntax.prototype.withQuestionToken = function (questionToken) { + return this.update(this.dotDotDotToken, this.publicOrPrivateKeyword, this.identifier, questionToken, this.typeAnnotation, this.equalsValueClause); + }; + + ParameterSyntax.prototype.withTypeAnnotation = function (typeAnnotation) { + return this.update(this.dotDotDotToken, this.publicOrPrivateKeyword, this.identifier, this.questionToken, typeAnnotation, this.equalsValueClause); + }; + + ParameterSyntax.prototype.withEqualsValueClause = function (equalsValueClause) { + return this.update(this.dotDotDotToken, this.publicOrPrivateKeyword, this.identifier, this.questionToken, this.typeAnnotation, equalsValueClause); + }; + + ParameterSyntax.prototype.isTypeScriptSpecific = function () { + if (this.dotDotDotToken !== null) { + return true; + } + if (this.publicOrPrivateKeyword !== null) { + return true; + } + if (this.questionToken !== null) { + return true; + } + if (this.typeAnnotation !== null) { + return true; + } + if (this.equalsValueClause !== null) { + return true; + } + return false; + }; + return ParameterSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ParameterSyntax = ParameterSyntax; + + var MemberAccessExpressionSyntax = (function (_super) { + __extends(MemberAccessExpressionSyntax, _super); + function MemberAccessExpressionSyntax(expression, dotToken, name, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.expression = expression; + this.dotToken = dotToken; + this.name = name; + } + MemberAccessExpressionSyntax.prototype.accept = function (visitor) { + return visitor.visitMemberAccessExpression(this); + }; + + MemberAccessExpressionSyntax.prototype.kind = function () { + return 211 /* MemberAccessExpression */; + }; + + MemberAccessExpressionSyntax.prototype.childCount = function () { + return 3; + }; + + MemberAccessExpressionSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.expression; + case 1: + return this.dotToken; + case 2: + return this.name; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + MemberAccessExpressionSyntax.prototype.isUnaryExpression = function () { + return true; + }; + + MemberAccessExpressionSyntax.prototype.isExpression = function () { + return true; + }; + + MemberAccessExpressionSyntax.prototype.update = function (expression, dotToken, name) { + if (this.expression === expression && this.dotToken === dotToken && this.name === name) { + return this; + } + + return new MemberAccessExpressionSyntax(expression, dotToken, name, this.parsedInStrictMode()); + }; + + MemberAccessExpressionSyntax.create1 = function (expression, name) { + return new MemberAccessExpressionSyntax(expression, TypeScript.Syntax.token(76 /* DotToken */), name, false); + }; + + MemberAccessExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + MemberAccessExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + MemberAccessExpressionSyntax.prototype.withExpression = function (expression) { + return this.update(expression, this.dotToken, this.name); + }; + + MemberAccessExpressionSyntax.prototype.withDotToken = function (dotToken) { + return this.update(this.expression, dotToken, this.name); + }; + + MemberAccessExpressionSyntax.prototype.withName = function (name) { + return this.update(this.expression, this.dotToken, name); + }; + + MemberAccessExpressionSyntax.prototype.isTypeScriptSpecific = function () { + if (this.expression.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return MemberAccessExpressionSyntax; + })(TypeScript.SyntaxNode); + TypeScript.MemberAccessExpressionSyntax = MemberAccessExpressionSyntax; + + var PostfixUnaryExpressionSyntax = (function (_super) { + __extends(PostfixUnaryExpressionSyntax, _super); + function PostfixUnaryExpressionSyntax(kind, operand, operatorToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.operand = operand; + this.operatorToken = operatorToken; + + this._kind = kind; + } + PostfixUnaryExpressionSyntax.prototype.accept = function (visitor) { + return visitor.visitPostfixUnaryExpression(this); + }; + + PostfixUnaryExpressionSyntax.prototype.childCount = function () { + return 2; + }; + + PostfixUnaryExpressionSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.operand; + case 1: + return this.operatorToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + PostfixUnaryExpressionSyntax.prototype.isUnaryExpression = function () { + return true; + }; + + PostfixUnaryExpressionSyntax.prototype.isExpression = function () { + return true; + }; + + PostfixUnaryExpressionSyntax.prototype.kind = function () { + return this._kind; + }; + + PostfixUnaryExpressionSyntax.prototype.update = function (kind, operand, operatorToken) { + if (this._kind === kind && this.operand === operand && this.operatorToken === operatorToken) { + return this; + } + + return new PostfixUnaryExpressionSyntax(kind, operand, operatorToken, this.parsedInStrictMode()); + }; + + PostfixUnaryExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + PostfixUnaryExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + PostfixUnaryExpressionSyntax.prototype.withKind = function (kind) { + return this.update(kind, this.operand, this.operatorToken); + }; + + PostfixUnaryExpressionSyntax.prototype.withOperand = function (operand) { + return this.update(this._kind, operand, this.operatorToken); + }; + + PostfixUnaryExpressionSyntax.prototype.withOperatorToken = function (operatorToken) { + return this.update(this._kind, this.operand, operatorToken); + }; + + PostfixUnaryExpressionSyntax.prototype.isTypeScriptSpecific = function () { + if (this.operand.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return PostfixUnaryExpressionSyntax; + })(TypeScript.SyntaxNode); + TypeScript.PostfixUnaryExpressionSyntax = PostfixUnaryExpressionSyntax; + + var ElementAccessExpressionSyntax = (function (_super) { + __extends(ElementAccessExpressionSyntax, _super); + function ElementAccessExpressionSyntax(expression, openBracketToken, argumentExpression, closeBracketToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.expression = expression; + this.openBracketToken = openBracketToken; + this.argumentExpression = argumentExpression; + this.closeBracketToken = closeBracketToken; + } + ElementAccessExpressionSyntax.prototype.accept = function (visitor) { + return visitor.visitElementAccessExpression(this); + }; + + ElementAccessExpressionSyntax.prototype.kind = function () { + return 220 /* ElementAccessExpression */; + }; + + ElementAccessExpressionSyntax.prototype.childCount = function () { + return 4; + }; + + ElementAccessExpressionSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.expression; + case 1: + return this.openBracketToken; + case 2: + return this.argumentExpression; + case 3: + return this.closeBracketToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ElementAccessExpressionSyntax.prototype.isUnaryExpression = function () { + return true; + }; + + ElementAccessExpressionSyntax.prototype.isExpression = function () { + return true; + }; + + ElementAccessExpressionSyntax.prototype.update = function (expression, openBracketToken, argumentExpression, closeBracketToken) { + if (this.expression === expression && this.openBracketToken === openBracketToken && this.argumentExpression === argumentExpression && this.closeBracketToken === closeBracketToken) { + return this; + } + + return new ElementAccessExpressionSyntax(expression, openBracketToken, argumentExpression, closeBracketToken, this.parsedInStrictMode()); + }; + + ElementAccessExpressionSyntax.create1 = function (expression, argumentExpression) { + return new ElementAccessExpressionSyntax(expression, TypeScript.Syntax.token(74 /* OpenBracketToken */), argumentExpression, TypeScript.Syntax.token(75 /* CloseBracketToken */), false); + }; + + ElementAccessExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ElementAccessExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ElementAccessExpressionSyntax.prototype.withExpression = function (expression) { + return this.update(expression, this.openBracketToken, this.argumentExpression, this.closeBracketToken); + }; + + ElementAccessExpressionSyntax.prototype.withOpenBracketToken = function (openBracketToken) { + return this.update(this.expression, openBracketToken, this.argumentExpression, this.closeBracketToken); + }; + + ElementAccessExpressionSyntax.prototype.withArgumentExpression = function (argumentExpression) { + return this.update(this.expression, this.openBracketToken, argumentExpression, this.closeBracketToken); + }; + + ElementAccessExpressionSyntax.prototype.withCloseBracketToken = function (closeBracketToken) { + return this.update(this.expression, this.openBracketToken, this.argumentExpression, closeBracketToken); + }; + + ElementAccessExpressionSyntax.prototype.isTypeScriptSpecific = function () { + if (this.expression.isTypeScriptSpecific()) { + return true; + } + if (this.argumentExpression.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return ElementAccessExpressionSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ElementAccessExpressionSyntax = ElementAccessExpressionSyntax; + + var InvocationExpressionSyntax = (function (_super) { + __extends(InvocationExpressionSyntax, _super); + function InvocationExpressionSyntax(expression, argumentList, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.expression = expression; + this.argumentList = argumentList; + } + InvocationExpressionSyntax.prototype.accept = function (visitor) { + return visitor.visitInvocationExpression(this); + }; + + InvocationExpressionSyntax.prototype.kind = function () { + return 212 /* InvocationExpression */; + }; + + InvocationExpressionSyntax.prototype.childCount = function () { + return 2; + }; + + InvocationExpressionSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.expression; + case 1: + return this.argumentList; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + InvocationExpressionSyntax.prototype.isUnaryExpression = function () { + return true; + }; + + InvocationExpressionSyntax.prototype.isExpression = function () { + return true; + }; + + InvocationExpressionSyntax.prototype.update = function (expression, argumentList) { + if (this.expression === expression && this.argumentList === argumentList) { + return this; + } + + return new InvocationExpressionSyntax(expression, argumentList, this.parsedInStrictMode()); + }; + + InvocationExpressionSyntax.create1 = function (expression) { + return new InvocationExpressionSyntax(expression, ArgumentListSyntax.create1(), false); + }; + + InvocationExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + InvocationExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + InvocationExpressionSyntax.prototype.withExpression = function (expression) { + return this.update(expression, this.argumentList); + }; + + InvocationExpressionSyntax.prototype.withArgumentList = function (argumentList) { + return this.update(this.expression, argumentList); + }; + + InvocationExpressionSyntax.prototype.isTypeScriptSpecific = function () { + if (this.expression.isTypeScriptSpecific()) { + return true; + } + if (this.argumentList.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return InvocationExpressionSyntax; + })(TypeScript.SyntaxNode); + TypeScript.InvocationExpressionSyntax = InvocationExpressionSyntax; + + var ArgumentListSyntax = (function (_super) { + __extends(ArgumentListSyntax, _super); + function ArgumentListSyntax(typeArgumentList, openParenToken, arguments, closeParenToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.typeArgumentList = typeArgumentList; + this.openParenToken = openParenToken; + this.arguments = arguments; + this.closeParenToken = closeParenToken; + } + ArgumentListSyntax.prototype.accept = function (visitor) { + return visitor.visitArgumentList(this); + }; + + ArgumentListSyntax.prototype.kind = function () { + return 225 /* ArgumentList */; + }; + + ArgumentListSyntax.prototype.childCount = function () { + return 4; + }; + + ArgumentListSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.typeArgumentList; + case 1: + return this.openParenToken; + case 2: + return this.arguments; + case 3: + return this.closeParenToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ArgumentListSyntax.prototype.update = function (typeArgumentList, openParenToken, _arguments, closeParenToken) { + if (this.typeArgumentList === typeArgumentList && this.openParenToken === openParenToken && this.arguments === _arguments && this.closeParenToken === closeParenToken) { + return this; + } + + return new ArgumentListSyntax(typeArgumentList, openParenToken, _arguments, closeParenToken, this.parsedInStrictMode()); + }; + + ArgumentListSyntax.create = function (openParenToken, closeParenToken) { + return new ArgumentListSyntax(null, openParenToken, TypeScript.Syntax.emptySeparatedList, closeParenToken, false); + }; + + ArgumentListSyntax.create1 = function () { + return new ArgumentListSyntax(null, TypeScript.Syntax.token(72 /* OpenParenToken */), TypeScript.Syntax.emptySeparatedList, TypeScript.Syntax.token(73 /* CloseParenToken */), false); + }; + + ArgumentListSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ArgumentListSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ArgumentListSyntax.prototype.withTypeArgumentList = function (typeArgumentList) { + return this.update(typeArgumentList, this.openParenToken, this.arguments, this.closeParenToken); + }; + + ArgumentListSyntax.prototype.withOpenParenToken = function (openParenToken) { + return this.update(this.typeArgumentList, openParenToken, this.arguments, this.closeParenToken); + }; + + ArgumentListSyntax.prototype.withArguments = function (_arguments) { + return this.update(this.typeArgumentList, this.openParenToken, _arguments, this.closeParenToken); + }; + + ArgumentListSyntax.prototype.withArgument = function (_argument) { + return this.withArguments(TypeScript.Syntax.separatedList([_argument])); + }; + + ArgumentListSyntax.prototype.withCloseParenToken = function (closeParenToken) { + return this.update(this.typeArgumentList, this.openParenToken, this.arguments, closeParenToken); + }; + + ArgumentListSyntax.prototype.isTypeScriptSpecific = function () { + if (this.typeArgumentList !== null && this.typeArgumentList.isTypeScriptSpecific()) { + return true; + } + if (this.arguments.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return ArgumentListSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ArgumentListSyntax = ArgumentListSyntax; + + var BinaryExpressionSyntax = (function (_super) { + __extends(BinaryExpressionSyntax, _super); + function BinaryExpressionSyntax(kind, left, operatorToken, right, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.left = left; + this.operatorToken = operatorToken; + this.right = right; + + this._kind = kind; + } + BinaryExpressionSyntax.prototype.accept = function (visitor) { + return visitor.visitBinaryExpression(this); + }; + + BinaryExpressionSyntax.prototype.childCount = function () { + return 3; + }; + + BinaryExpressionSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.left; + case 1: + return this.operatorToken; + case 2: + return this.right; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + BinaryExpressionSyntax.prototype.isExpression = function () { + return true; + }; + + BinaryExpressionSyntax.prototype.kind = function () { + return this._kind; + }; + + BinaryExpressionSyntax.prototype.update = function (kind, left, operatorToken, right) { + if (this._kind === kind && this.left === left && this.operatorToken === operatorToken && this.right === right) { + return this; + } + + return new BinaryExpressionSyntax(kind, left, operatorToken, right, this.parsedInStrictMode()); + }; + + BinaryExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + BinaryExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + BinaryExpressionSyntax.prototype.withKind = function (kind) { + return this.update(kind, this.left, this.operatorToken, this.right); + }; + + BinaryExpressionSyntax.prototype.withLeft = function (left) { + return this.update(this._kind, left, this.operatorToken, this.right); + }; + + BinaryExpressionSyntax.prototype.withOperatorToken = function (operatorToken) { + return this.update(this._kind, this.left, operatorToken, this.right); + }; + + BinaryExpressionSyntax.prototype.withRight = function (right) { + return this.update(this._kind, this.left, this.operatorToken, right); + }; + + BinaryExpressionSyntax.prototype.isTypeScriptSpecific = function () { + if (this.left.isTypeScriptSpecific()) { + return true; + } + if (this.right.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return BinaryExpressionSyntax; + })(TypeScript.SyntaxNode); + TypeScript.BinaryExpressionSyntax = BinaryExpressionSyntax; + + var ConditionalExpressionSyntax = (function (_super) { + __extends(ConditionalExpressionSyntax, _super); + function ConditionalExpressionSyntax(condition, questionToken, whenTrue, colonToken, whenFalse, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.condition = condition; + this.questionToken = questionToken; + this.whenTrue = whenTrue; + this.colonToken = colonToken; + this.whenFalse = whenFalse; + } + ConditionalExpressionSyntax.prototype.accept = function (visitor) { + return visitor.visitConditionalExpression(this); + }; + + ConditionalExpressionSyntax.prototype.kind = function () { + return 185 /* ConditionalExpression */; + }; + + ConditionalExpressionSyntax.prototype.childCount = function () { + return 5; + }; + + ConditionalExpressionSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.condition; + case 1: + return this.questionToken; + case 2: + return this.whenTrue; + case 3: + return this.colonToken; + case 4: + return this.whenFalse; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ConditionalExpressionSyntax.prototype.isExpression = function () { + return true; + }; + + ConditionalExpressionSyntax.prototype.update = function (condition, questionToken, whenTrue, colonToken, whenFalse) { + if (this.condition === condition && this.questionToken === questionToken && this.whenTrue === whenTrue && this.colonToken === colonToken && this.whenFalse === whenFalse) { + return this; + } + + return new ConditionalExpressionSyntax(condition, questionToken, whenTrue, colonToken, whenFalse, this.parsedInStrictMode()); + }; + + ConditionalExpressionSyntax.create1 = function (condition, whenTrue, whenFalse) { + return new ConditionalExpressionSyntax(condition, TypeScript.Syntax.token(105 /* QuestionToken */), whenTrue, TypeScript.Syntax.token(106 /* ColonToken */), whenFalse, false); + }; + + ConditionalExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ConditionalExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ConditionalExpressionSyntax.prototype.withCondition = function (condition) { + return this.update(condition, this.questionToken, this.whenTrue, this.colonToken, this.whenFalse); + }; + + ConditionalExpressionSyntax.prototype.withQuestionToken = function (questionToken) { + return this.update(this.condition, questionToken, this.whenTrue, this.colonToken, this.whenFalse); + }; + + ConditionalExpressionSyntax.prototype.withWhenTrue = function (whenTrue) { + return this.update(this.condition, this.questionToken, whenTrue, this.colonToken, this.whenFalse); + }; + + ConditionalExpressionSyntax.prototype.withColonToken = function (colonToken) { + return this.update(this.condition, this.questionToken, this.whenTrue, colonToken, this.whenFalse); + }; + + ConditionalExpressionSyntax.prototype.withWhenFalse = function (whenFalse) { + return this.update(this.condition, this.questionToken, this.whenTrue, this.colonToken, whenFalse); + }; + + ConditionalExpressionSyntax.prototype.isTypeScriptSpecific = function () { + if (this.condition.isTypeScriptSpecific()) { + return true; + } + if (this.whenTrue.isTypeScriptSpecific()) { + return true; + } + if (this.whenFalse.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return ConditionalExpressionSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ConditionalExpressionSyntax = ConditionalExpressionSyntax; + + var ConstructSignatureSyntax = (function (_super) { + __extends(ConstructSignatureSyntax, _super); + function ConstructSignatureSyntax(newKeyword, callSignature, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.newKeyword = newKeyword; + this.callSignature = callSignature; + } + ConstructSignatureSyntax.prototype.accept = function (visitor) { + return visitor.visitConstructSignature(this); + }; + + ConstructSignatureSyntax.prototype.kind = function () { + return 142 /* ConstructSignature */; + }; + + ConstructSignatureSyntax.prototype.childCount = function () { + return 2; + }; + + ConstructSignatureSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.newKeyword; + case 1: + return this.callSignature; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ConstructSignatureSyntax.prototype.isTypeMember = function () { + return true; + }; + + ConstructSignatureSyntax.prototype.update = function (newKeyword, callSignature) { + if (this.newKeyword === newKeyword && this.callSignature === callSignature) { + return this; + } + + return new ConstructSignatureSyntax(newKeyword, callSignature, this.parsedInStrictMode()); + }; + + ConstructSignatureSyntax.create1 = function () { + return new ConstructSignatureSyntax(TypeScript.Syntax.token(31 /* NewKeyword */), CallSignatureSyntax.create1(), false); + }; + + ConstructSignatureSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ConstructSignatureSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ConstructSignatureSyntax.prototype.withNewKeyword = function (newKeyword) { + return this.update(newKeyword, this.callSignature); + }; + + ConstructSignatureSyntax.prototype.withCallSignature = function (callSignature) { + return this.update(this.newKeyword, callSignature); + }; + + ConstructSignatureSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return ConstructSignatureSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ConstructSignatureSyntax = ConstructSignatureSyntax; + + var MethodSignatureSyntax = (function (_super) { + __extends(MethodSignatureSyntax, _super); + function MethodSignatureSyntax(propertyName, questionToken, callSignature, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.propertyName = propertyName; + this.questionToken = questionToken; + this.callSignature = callSignature; + } + MethodSignatureSyntax.prototype.accept = function (visitor) { + return visitor.visitMethodSignature(this); + }; + + MethodSignatureSyntax.prototype.kind = function () { + return 144 /* MethodSignature */; + }; + + MethodSignatureSyntax.prototype.childCount = function () { + return 3; + }; + + MethodSignatureSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.propertyName; + case 1: + return this.questionToken; + case 2: + return this.callSignature; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + MethodSignatureSyntax.prototype.isTypeMember = function () { + return true; + }; + + MethodSignatureSyntax.prototype.update = function (propertyName, questionToken, callSignature) { + if (this.propertyName === propertyName && this.questionToken === questionToken && this.callSignature === callSignature) { + return this; + } + + return new MethodSignatureSyntax(propertyName, questionToken, callSignature, this.parsedInStrictMode()); + }; + + MethodSignatureSyntax.create = function (propertyName, callSignature) { + return new MethodSignatureSyntax(propertyName, null, callSignature, false); + }; + + MethodSignatureSyntax.create1 = function (propertyName) { + return new MethodSignatureSyntax(propertyName, null, CallSignatureSyntax.create1(), false); + }; + + MethodSignatureSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + MethodSignatureSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + MethodSignatureSyntax.prototype.withPropertyName = function (propertyName) { + return this.update(propertyName, this.questionToken, this.callSignature); + }; + + MethodSignatureSyntax.prototype.withQuestionToken = function (questionToken) { + return this.update(this.propertyName, questionToken, this.callSignature); + }; + + MethodSignatureSyntax.prototype.withCallSignature = function (callSignature) { + return this.update(this.propertyName, this.questionToken, callSignature); + }; + + MethodSignatureSyntax.prototype.isTypeScriptSpecific = function () { + if (this.callSignature.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return MethodSignatureSyntax; + })(TypeScript.SyntaxNode); + TypeScript.MethodSignatureSyntax = MethodSignatureSyntax; + + var IndexSignatureSyntax = (function (_super) { + __extends(IndexSignatureSyntax, _super); + function IndexSignatureSyntax(openBracketToken, parameter, closeBracketToken, typeAnnotation, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.openBracketToken = openBracketToken; + this.parameter = parameter; + this.closeBracketToken = closeBracketToken; + this.typeAnnotation = typeAnnotation; + } + IndexSignatureSyntax.prototype.accept = function (visitor) { + return visitor.visitIndexSignature(this); + }; + + IndexSignatureSyntax.prototype.kind = function () { + return 143 /* IndexSignature */; + }; + + IndexSignatureSyntax.prototype.childCount = function () { + return 4; + }; + + IndexSignatureSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.openBracketToken; + case 1: + return this.parameter; + case 2: + return this.closeBracketToken; + case 3: + return this.typeAnnotation; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + IndexSignatureSyntax.prototype.isTypeMember = function () { + return true; + }; + + IndexSignatureSyntax.prototype.isClassElement = function () { + return true; + }; + + IndexSignatureSyntax.prototype.update = function (openBracketToken, parameter, closeBracketToken, typeAnnotation) { + if (this.openBracketToken === openBracketToken && this.parameter === parameter && this.closeBracketToken === closeBracketToken && this.typeAnnotation === typeAnnotation) { + return this; + } + + return new IndexSignatureSyntax(openBracketToken, parameter, closeBracketToken, typeAnnotation, this.parsedInStrictMode()); + }; + + IndexSignatureSyntax.create = function (openBracketToken, parameter, closeBracketToken) { + return new IndexSignatureSyntax(openBracketToken, parameter, closeBracketToken, null, false); + }; + + IndexSignatureSyntax.create1 = function (parameter) { + return new IndexSignatureSyntax(TypeScript.Syntax.token(74 /* OpenBracketToken */), parameter, TypeScript.Syntax.token(75 /* CloseBracketToken */), null, false); + }; + + IndexSignatureSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + IndexSignatureSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + IndexSignatureSyntax.prototype.withOpenBracketToken = function (openBracketToken) { + return this.update(openBracketToken, this.parameter, this.closeBracketToken, this.typeAnnotation); + }; + + IndexSignatureSyntax.prototype.withParameter = function (parameter) { + return this.update(this.openBracketToken, parameter, this.closeBracketToken, this.typeAnnotation); + }; + + IndexSignatureSyntax.prototype.withCloseBracketToken = function (closeBracketToken) { + return this.update(this.openBracketToken, this.parameter, closeBracketToken, this.typeAnnotation); + }; + + IndexSignatureSyntax.prototype.withTypeAnnotation = function (typeAnnotation) { + return this.update(this.openBracketToken, this.parameter, this.closeBracketToken, typeAnnotation); + }; + + IndexSignatureSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return IndexSignatureSyntax; + })(TypeScript.SyntaxNode); + TypeScript.IndexSignatureSyntax = IndexSignatureSyntax; + + var PropertySignatureSyntax = (function (_super) { + __extends(PropertySignatureSyntax, _super); + function PropertySignatureSyntax(propertyName, questionToken, typeAnnotation, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.propertyName = propertyName; + this.questionToken = questionToken; + this.typeAnnotation = typeAnnotation; + } + PropertySignatureSyntax.prototype.accept = function (visitor) { + return visitor.visitPropertySignature(this); + }; + + PropertySignatureSyntax.prototype.kind = function () { + return 140 /* PropertySignature */; + }; + + PropertySignatureSyntax.prototype.childCount = function () { + return 3; + }; + + PropertySignatureSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.propertyName; + case 1: + return this.questionToken; + case 2: + return this.typeAnnotation; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + PropertySignatureSyntax.prototype.isTypeMember = function () { + return true; + }; + + PropertySignatureSyntax.prototype.update = function (propertyName, questionToken, typeAnnotation) { + if (this.propertyName === propertyName && this.questionToken === questionToken && this.typeAnnotation === typeAnnotation) { + return this; + } + + return new PropertySignatureSyntax(propertyName, questionToken, typeAnnotation, this.parsedInStrictMode()); + }; + + PropertySignatureSyntax.create = function (propertyName) { + return new PropertySignatureSyntax(propertyName, null, null, false); + }; + + PropertySignatureSyntax.create1 = function (propertyName) { + return new PropertySignatureSyntax(propertyName, null, null, false); + }; + + PropertySignatureSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + PropertySignatureSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + PropertySignatureSyntax.prototype.withPropertyName = function (propertyName) { + return this.update(propertyName, this.questionToken, this.typeAnnotation); + }; + + PropertySignatureSyntax.prototype.withQuestionToken = function (questionToken) { + return this.update(this.propertyName, questionToken, this.typeAnnotation); + }; + + PropertySignatureSyntax.prototype.withTypeAnnotation = function (typeAnnotation) { + return this.update(this.propertyName, this.questionToken, typeAnnotation); + }; + + PropertySignatureSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return PropertySignatureSyntax; + })(TypeScript.SyntaxNode); + TypeScript.PropertySignatureSyntax = PropertySignatureSyntax; + + var CallSignatureSyntax = (function (_super) { + __extends(CallSignatureSyntax, _super); + function CallSignatureSyntax(typeParameterList, parameterList, typeAnnotation, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.typeParameterList = typeParameterList; + this.parameterList = parameterList; + this.typeAnnotation = typeAnnotation; + } + CallSignatureSyntax.prototype.accept = function (visitor) { + return visitor.visitCallSignature(this); + }; + + CallSignatureSyntax.prototype.kind = function () { + return 141 /* CallSignature */; + }; + + CallSignatureSyntax.prototype.childCount = function () { + return 3; + }; + + CallSignatureSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.typeParameterList; + case 1: + return this.parameterList; + case 2: + return this.typeAnnotation; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + CallSignatureSyntax.prototype.isTypeMember = function () { + return true; + }; + + CallSignatureSyntax.prototype.update = function (typeParameterList, parameterList, typeAnnotation) { + if (this.typeParameterList === typeParameterList && this.parameterList === parameterList && this.typeAnnotation === typeAnnotation) { + return this; + } + + return new CallSignatureSyntax(typeParameterList, parameterList, typeAnnotation, this.parsedInStrictMode()); + }; + + CallSignatureSyntax.create = function (parameterList) { + return new CallSignatureSyntax(null, parameterList, null, false); + }; + + CallSignatureSyntax.create1 = function () { + return new CallSignatureSyntax(null, ParameterListSyntax.create1(), null, false); + }; + + CallSignatureSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + CallSignatureSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + CallSignatureSyntax.prototype.withTypeParameterList = function (typeParameterList) { + return this.update(typeParameterList, this.parameterList, this.typeAnnotation); + }; + + CallSignatureSyntax.prototype.withParameterList = function (parameterList) { + return this.update(this.typeParameterList, parameterList, this.typeAnnotation); + }; + + CallSignatureSyntax.prototype.withTypeAnnotation = function (typeAnnotation) { + return this.update(this.typeParameterList, this.parameterList, typeAnnotation); + }; + + CallSignatureSyntax.prototype.isTypeScriptSpecific = function () { + if (this.typeParameterList !== null) { + return true; + } + if (this.parameterList.isTypeScriptSpecific()) { + return true; + } + if (this.typeAnnotation !== null) { + return true; + } + return false; + }; + return CallSignatureSyntax; + })(TypeScript.SyntaxNode); + TypeScript.CallSignatureSyntax = CallSignatureSyntax; + + var ParameterListSyntax = (function (_super) { + __extends(ParameterListSyntax, _super); + function ParameterListSyntax(openParenToken, parameters, closeParenToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.openParenToken = openParenToken; + this.parameters = parameters; + this.closeParenToken = closeParenToken; + } + ParameterListSyntax.prototype.accept = function (visitor) { + return visitor.visitParameterList(this); + }; + + ParameterListSyntax.prototype.kind = function () { + return 226 /* ParameterList */; + }; + + ParameterListSyntax.prototype.childCount = function () { + return 3; + }; + + ParameterListSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.openParenToken; + case 1: + return this.parameters; + case 2: + return this.closeParenToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ParameterListSyntax.prototype.update = function (openParenToken, parameters, closeParenToken) { + if (this.openParenToken === openParenToken && this.parameters === parameters && this.closeParenToken === closeParenToken) { + return this; + } + + return new ParameterListSyntax(openParenToken, parameters, closeParenToken, this.parsedInStrictMode()); + }; + + ParameterListSyntax.create = function (openParenToken, closeParenToken) { + return new ParameterListSyntax(openParenToken, TypeScript.Syntax.emptySeparatedList, closeParenToken, false); + }; + + ParameterListSyntax.create1 = function () { + return new ParameterListSyntax(TypeScript.Syntax.token(72 /* OpenParenToken */), TypeScript.Syntax.emptySeparatedList, TypeScript.Syntax.token(73 /* CloseParenToken */), false); + }; + + ParameterListSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ParameterListSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ParameterListSyntax.prototype.withOpenParenToken = function (openParenToken) { + return this.update(openParenToken, this.parameters, this.closeParenToken); + }; + + ParameterListSyntax.prototype.withParameters = function (parameters) { + return this.update(this.openParenToken, parameters, this.closeParenToken); + }; + + ParameterListSyntax.prototype.withParameter = function (parameter) { + return this.withParameters(TypeScript.Syntax.separatedList([parameter])); + }; + + ParameterListSyntax.prototype.withCloseParenToken = function (closeParenToken) { + return this.update(this.openParenToken, this.parameters, closeParenToken); + }; + + ParameterListSyntax.prototype.isTypeScriptSpecific = function () { + if (this.parameters.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return ParameterListSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ParameterListSyntax = ParameterListSyntax; + + var TypeParameterListSyntax = (function (_super) { + __extends(TypeParameterListSyntax, _super); + function TypeParameterListSyntax(lessThanToken, typeParameters, greaterThanToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.lessThanToken = lessThanToken; + this.typeParameters = typeParameters; + this.greaterThanToken = greaterThanToken; + } + TypeParameterListSyntax.prototype.accept = function (visitor) { + return visitor.visitTypeParameterList(this); + }; + + TypeParameterListSyntax.prototype.kind = function () { + return 228 /* TypeParameterList */; + }; + + TypeParameterListSyntax.prototype.childCount = function () { + return 3; + }; + + TypeParameterListSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.lessThanToken; + case 1: + return this.typeParameters; + case 2: + return this.greaterThanToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + TypeParameterListSyntax.prototype.update = function (lessThanToken, typeParameters, greaterThanToken) { + if (this.lessThanToken === lessThanToken && this.typeParameters === typeParameters && this.greaterThanToken === greaterThanToken) { + return this; + } + + return new TypeParameterListSyntax(lessThanToken, typeParameters, greaterThanToken, this.parsedInStrictMode()); + }; + + TypeParameterListSyntax.create = function (lessThanToken, greaterThanToken) { + return new TypeParameterListSyntax(lessThanToken, TypeScript.Syntax.emptySeparatedList, greaterThanToken, false); + }; + + TypeParameterListSyntax.create1 = function () { + return new TypeParameterListSyntax(TypeScript.Syntax.token(80 /* LessThanToken */), TypeScript.Syntax.emptySeparatedList, TypeScript.Syntax.token(81 /* GreaterThanToken */), false); + }; + + TypeParameterListSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + TypeParameterListSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + TypeParameterListSyntax.prototype.withLessThanToken = function (lessThanToken) { + return this.update(lessThanToken, this.typeParameters, this.greaterThanToken); + }; + + TypeParameterListSyntax.prototype.withTypeParameters = function (typeParameters) { + return this.update(this.lessThanToken, typeParameters, this.greaterThanToken); + }; + + TypeParameterListSyntax.prototype.withTypeParameter = function (typeParameter) { + return this.withTypeParameters(TypeScript.Syntax.separatedList([typeParameter])); + }; + + TypeParameterListSyntax.prototype.withGreaterThanToken = function (greaterThanToken) { + return this.update(this.lessThanToken, this.typeParameters, greaterThanToken); + }; + + TypeParameterListSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return TypeParameterListSyntax; + })(TypeScript.SyntaxNode); + TypeScript.TypeParameterListSyntax = TypeParameterListSyntax; + + var TypeParameterSyntax = (function (_super) { + __extends(TypeParameterSyntax, _super); + function TypeParameterSyntax(identifier, constraint, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.identifier = identifier; + this.constraint = constraint; + } + TypeParameterSyntax.prototype.accept = function (visitor) { + return visitor.visitTypeParameter(this); + }; + + TypeParameterSyntax.prototype.kind = function () { + return 236 /* TypeParameter */; + }; + + TypeParameterSyntax.prototype.childCount = function () { + return 2; + }; + + TypeParameterSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.identifier; + case 1: + return this.constraint; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + TypeParameterSyntax.prototype.update = function (identifier, constraint) { + if (this.identifier === identifier && this.constraint === constraint) { + return this; + } + + return new TypeParameterSyntax(identifier, constraint, this.parsedInStrictMode()); + }; + + TypeParameterSyntax.create = function (identifier) { + return new TypeParameterSyntax(identifier, null, false); + }; + + TypeParameterSyntax.create1 = function (identifier) { + return new TypeParameterSyntax(identifier, null, false); + }; + + TypeParameterSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + TypeParameterSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + TypeParameterSyntax.prototype.withIdentifier = function (identifier) { + return this.update(identifier, this.constraint); + }; + + TypeParameterSyntax.prototype.withConstraint = function (constraint) { + return this.update(this.identifier, constraint); + }; + + TypeParameterSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return TypeParameterSyntax; + })(TypeScript.SyntaxNode); + TypeScript.TypeParameterSyntax = TypeParameterSyntax; + + var ConstraintSyntax = (function (_super) { + __extends(ConstraintSyntax, _super); + function ConstraintSyntax(extendsKeyword, type, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.extendsKeyword = extendsKeyword; + this.type = type; + } + ConstraintSyntax.prototype.accept = function (visitor) { + return visitor.visitConstraint(this); + }; + + ConstraintSyntax.prototype.kind = function () { + return 237 /* Constraint */; + }; + + ConstraintSyntax.prototype.childCount = function () { + return 2; + }; + + ConstraintSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.extendsKeyword; + case 1: + return this.type; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ConstraintSyntax.prototype.update = function (extendsKeyword, type) { + if (this.extendsKeyword === extendsKeyword && this.type === type) { + return this; + } + + return new ConstraintSyntax(extendsKeyword, type, this.parsedInStrictMode()); + }; + + ConstraintSyntax.create1 = function (type) { + return new ConstraintSyntax(TypeScript.Syntax.token(48 /* ExtendsKeyword */), type, false); + }; + + ConstraintSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ConstraintSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ConstraintSyntax.prototype.withExtendsKeyword = function (extendsKeyword) { + return this.update(extendsKeyword, this.type); + }; + + ConstraintSyntax.prototype.withType = function (type) { + return this.update(this.extendsKeyword, type); + }; + + ConstraintSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return ConstraintSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ConstraintSyntax = ConstraintSyntax; + + var ElseClauseSyntax = (function (_super) { + __extends(ElseClauseSyntax, _super); + function ElseClauseSyntax(elseKeyword, statement, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.elseKeyword = elseKeyword; + this.statement = statement; + } + ElseClauseSyntax.prototype.accept = function (visitor) { + return visitor.visitElseClause(this); + }; + + ElseClauseSyntax.prototype.kind = function () { + return 233 /* ElseClause */; + }; + + ElseClauseSyntax.prototype.childCount = function () { + return 2; + }; + + ElseClauseSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.elseKeyword; + case 1: + return this.statement; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ElseClauseSyntax.prototype.update = function (elseKeyword, statement) { + if (this.elseKeyword === elseKeyword && this.statement === statement) { + return this; + } + + return new ElseClauseSyntax(elseKeyword, statement, this.parsedInStrictMode()); + }; + + ElseClauseSyntax.create1 = function (statement) { + return new ElseClauseSyntax(TypeScript.Syntax.token(23 /* ElseKeyword */), statement, false); + }; + + ElseClauseSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ElseClauseSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ElseClauseSyntax.prototype.withElseKeyword = function (elseKeyword) { + return this.update(elseKeyword, this.statement); + }; + + ElseClauseSyntax.prototype.withStatement = function (statement) { + return this.update(this.elseKeyword, statement); + }; + + ElseClauseSyntax.prototype.isTypeScriptSpecific = function () { + if (this.statement.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return ElseClauseSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ElseClauseSyntax = ElseClauseSyntax; + + var IfStatementSyntax = (function (_super) { + __extends(IfStatementSyntax, _super); + function IfStatementSyntax(ifKeyword, openParenToken, condition, closeParenToken, statement, elseClause, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.ifKeyword = ifKeyword; + this.openParenToken = openParenToken; + this.condition = condition; + this.closeParenToken = closeParenToken; + this.statement = statement; + this.elseClause = elseClause; + } + IfStatementSyntax.prototype.accept = function (visitor) { + return visitor.visitIfStatement(this); + }; + + IfStatementSyntax.prototype.kind = function () { + return 146 /* IfStatement */; + }; + + IfStatementSyntax.prototype.childCount = function () { + return 6; + }; + + IfStatementSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.ifKeyword; + case 1: + return this.openParenToken; + case 2: + return this.condition; + case 3: + return this.closeParenToken; + case 4: + return this.statement; + case 5: + return this.elseClause; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + IfStatementSyntax.prototype.isStatement = function () { + return true; + }; + + IfStatementSyntax.prototype.isModuleElement = function () { + return true; + }; + + IfStatementSyntax.prototype.update = function (ifKeyword, openParenToken, condition, closeParenToken, statement, elseClause) { + if (this.ifKeyword === ifKeyword && this.openParenToken === openParenToken && this.condition === condition && this.closeParenToken === closeParenToken && this.statement === statement && this.elseClause === elseClause) { + return this; + } + + return new IfStatementSyntax(ifKeyword, openParenToken, condition, closeParenToken, statement, elseClause, this.parsedInStrictMode()); + }; + + IfStatementSyntax.create = function (ifKeyword, openParenToken, condition, closeParenToken, statement) { + return new IfStatementSyntax(ifKeyword, openParenToken, condition, closeParenToken, statement, null, false); + }; + + IfStatementSyntax.create1 = function (condition, statement) { + return new IfStatementSyntax(TypeScript.Syntax.token(28 /* IfKeyword */), TypeScript.Syntax.token(72 /* OpenParenToken */), condition, TypeScript.Syntax.token(73 /* CloseParenToken */), statement, null, false); + }; + + IfStatementSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + IfStatementSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + IfStatementSyntax.prototype.withIfKeyword = function (ifKeyword) { + return this.update(ifKeyword, this.openParenToken, this.condition, this.closeParenToken, this.statement, this.elseClause); + }; + + IfStatementSyntax.prototype.withOpenParenToken = function (openParenToken) { + return this.update(this.ifKeyword, openParenToken, this.condition, this.closeParenToken, this.statement, this.elseClause); + }; + + IfStatementSyntax.prototype.withCondition = function (condition) { + return this.update(this.ifKeyword, this.openParenToken, condition, this.closeParenToken, this.statement, this.elseClause); + }; + + IfStatementSyntax.prototype.withCloseParenToken = function (closeParenToken) { + return this.update(this.ifKeyword, this.openParenToken, this.condition, closeParenToken, this.statement, this.elseClause); + }; + + IfStatementSyntax.prototype.withStatement = function (statement) { + return this.update(this.ifKeyword, this.openParenToken, this.condition, this.closeParenToken, statement, this.elseClause); + }; + + IfStatementSyntax.prototype.withElseClause = function (elseClause) { + return this.update(this.ifKeyword, this.openParenToken, this.condition, this.closeParenToken, this.statement, elseClause); + }; + + IfStatementSyntax.prototype.isTypeScriptSpecific = function () { + if (this.condition.isTypeScriptSpecific()) { + return true; + } + if (this.statement.isTypeScriptSpecific()) { + return true; + } + if (this.elseClause !== null && this.elseClause.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return IfStatementSyntax; + })(TypeScript.SyntaxNode); + TypeScript.IfStatementSyntax = IfStatementSyntax; + + var ExpressionStatementSyntax = (function (_super) { + __extends(ExpressionStatementSyntax, _super); + function ExpressionStatementSyntax(expression, semicolonToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.expression = expression; + this.semicolonToken = semicolonToken; + } + ExpressionStatementSyntax.prototype.accept = function (visitor) { + return visitor.visitExpressionStatement(this); + }; + + ExpressionStatementSyntax.prototype.kind = function () { + return 148 /* ExpressionStatement */; + }; + + ExpressionStatementSyntax.prototype.childCount = function () { + return 2; + }; + + ExpressionStatementSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.expression; + case 1: + return this.semicolonToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ExpressionStatementSyntax.prototype.isStatement = function () { + return true; + }; + + ExpressionStatementSyntax.prototype.isModuleElement = function () { + return true; + }; + + ExpressionStatementSyntax.prototype.update = function (expression, semicolonToken) { + if (this.expression === expression && this.semicolonToken === semicolonToken) { + return this; + } + + return new ExpressionStatementSyntax(expression, semicolonToken, this.parsedInStrictMode()); + }; + + ExpressionStatementSyntax.create1 = function (expression) { + return new ExpressionStatementSyntax(expression, TypeScript.Syntax.token(78 /* SemicolonToken */), false); + }; + + ExpressionStatementSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ExpressionStatementSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ExpressionStatementSyntax.prototype.withExpression = function (expression) { + return this.update(expression, this.semicolonToken); + }; + + ExpressionStatementSyntax.prototype.withSemicolonToken = function (semicolonToken) { + return this.update(this.expression, semicolonToken); + }; + + ExpressionStatementSyntax.prototype.isTypeScriptSpecific = function () { + if (this.expression.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return ExpressionStatementSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ExpressionStatementSyntax = ExpressionStatementSyntax; + + var ConstructorDeclarationSyntax = (function (_super) { + __extends(ConstructorDeclarationSyntax, _super); + function ConstructorDeclarationSyntax(constructorKeyword, parameterList, block, semicolonToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.constructorKeyword = constructorKeyword; + this.parameterList = parameterList; + this.block = block; + this.semicolonToken = semicolonToken; + } + ConstructorDeclarationSyntax.prototype.accept = function (visitor) { + return visitor.visitConstructorDeclaration(this); + }; + + ConstructorDeclarationSyntax.prototype.kind = function () { + return 137 /* ConstructorDeclaration */; + }; + + ConstructorDeclarationSyntax.prototype.childCount = function () { + return 4; + }; + + ConstructorDeclarationSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.constructorKeyword; + case 1: + return this.parameterList; + case 2: + return this.block; + case 3: + return this.semicolonToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ConstructorDeclarationSyntax.prototype.isClassElement = function () { + return true; + }; + + ConstructorDeclarationSyntax.prototype.update = function (constructorKeyword, parameterList, block, semicolonToken) { + if (this.constructorKeyword === constructorKeyword && this.parameterList === parameterList && this.block === block && this.semicolonToken === semicolonToken) { + return this; + } + + return new ConstructorDeclarationSyntax(constructorKeyword, parameterList, block, semicolonToken, this.parsedInStrictMode()); + }; + + ConstructorDeclarationSyntax.create = function (constructorKeyword, parameterList) { + return new ConstructorDeclarationSyntax(constructorKeyword, parameterList, null, null, false); + }; + + ConstructorDeclarationSyntax.create1 = function () { + return new ConstructorDeclarationSyntax(TypeScript.Syntax.token(62 /* ConstructorKeyword */), ParameterListSyntax.create1(), null, null, false); + }; + + ConstructorDeclarationSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ConstructorDeclarationSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ConstructorDeclarationSyntax.prototype.withConstructorKeyword = function (constructorKeyword) { + return this.update(constructorKeyword, this.parameterList, this.block, this.semicolonToken); + }; + + ConstructorDeclarationSyntax.prototype.withParameterList = function (parameterList) { + return this.update(this.constructorKeyword, parameterList, this.block, this.semicolonToken); + }; + + ConstructorDeclarationSyntax.prototype.withBlock = function (block) { + return this.update(this.constructorKeyword, this.parameterList, block, this.semicolonToken); + }; + + ConstructorDeclarationSyntax.prototype.withSemicolonToken = function (semicolonToken) { + return this.update(this.constructorKeyword, this.parameterList, this.block, semicolonToken); + }; + + ConstructorDeclarationSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return ConstructorDeclarationSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ConstructorDeclarationSyntax = ConstructorDeclarationSyntax; + + var MemberFunctionDeclarationSyntax = (function (_super) { + __extends(MemberFunctionDeclarationSyntax, _super); + function MemberFunctionDeclarationSyntax(modifiers, propertyName, callSignature, block, semicolonToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.modifiers = modifiers; + this.propertyName = propertyName; + this.callSignature = callSignature; + this.block = block; + this.semicolonToken = semicolonToken; + } + MemberFunctionDeclarationSyntax.prototype.accept = function (visitor) { + return visitor.visitMemberFunctionDeclaration(this); + }; + + MemberFunctionDeclarationSyntax.prototype.kind = function () { + return 135 /* MemberFunctionDeclaration */; + }; + + MemberFunctionDeclarationSyntax.prototype.childCount = function () { + return 5; + }; + + MemberFunctionDeclarationSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.modifiers; + case 1: + return this.propertyName; + case 2: + return this.callSignature; + case 3: + return this.block; + case 4: + return this.semicolonToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + MemberFunctionDeclarationSyntax.prototype.isMemberDeclaration = function () { + return true; + }; + + MemberFunctionDeclarationSyntax.prototype.isClassElement = function () { + return true; + }; + + MemberFunctionDeclarationSyntax.prototype.update = function (modifiers, propertyName, callSignature, block, semicolonToken) { + if (this.modifiers === modifiers && this.propertyName === propertyName && this.callSignature === callSignature && this.block === block && this.semicolonToken === semicolonToken) { + return this; + } + + return new MemberFunctionDeclarationSyntax(modifiers, propertyName, callSignature, block, semicolonToken, this.parsedInStrictMode()); + }; + + MemberFunctionDeclarationSyntax.create = function (propertyName, callSignature) { + return new MemberFunctionDeclarationSyntax(TypeScript.Syntax.emptyList, propertyName, callSignature, null, null, false); + }; + + MemberFunctionDeclarationSyntax.create1 = function (propertyName) { + return new MemberFunctionDeclarationSyntax(TypeScript.Syntax.emptyList, propertyName, CallSignatureSyntax.create1(), null, null, false); + }; + + MemberFunctionDeclarationSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + MemberFunctionDeclarationSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + MemberFunctionDeclarationSyntax.prototype.withModifiers = function (modifiers) { + return this.update(modifiers, this.propertyName, this.callSignature, this.block, this.semicolonToken); + }; + + MemberFunctionDeclarationSyntax.prototype.withModifier = function (modifier) { + return this.withModifiers(TypeScript.Syntax.list([modifier])); + }; + + MemberFunctionDeclarationSyntax.prototype.withPropertyName = function (propertyName) { + return this.update(this.modifiers, propertyName, this.callSignature, this.block, this.semicolonToken); + }; + + MemberFunctionDeclarationSyntax.prototype.withCallSignature = function (callSignature) { + return this.update(this.modifiers, this.propertyName, callSignature, this.block, this.semicolonToken); + }; + + MemberFunctionDeclarationSyntax.prototype.withBlock = function (block) { + return this.update(this.modifiers, this.propertyName, this.callSignature, block, this.semicolonToken); + }; + + MemberFunctionDeclarationSyntax.prototype.withSemicolonToken = function (semicolonToken) { + return this.update(this.modifiers, this.propertyName, this.callSignature, this.block, semicolonToken); + }; + + MemberFunctionDeclarationSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return MemberFunctionDeclarationSyntax; + })(TypeScript.SyntaxNode); + TypeScript.MemberFunctionDeclarationSyntax = MemberFunctionDeclarationSyntax; + + var MemberAccessorDeclarationSyntax = (function (_super) { + __extends(MemberAccessorDeclarationSyntax, _super); + function MemberAccessorDeclarationSyntax(modifiers, propertyName, parameterList, block, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.modifiers = modifiers; + this.propertyName = propertyName; + this.parameterList = parameterList; + this.block = block; + } + MemberAccessorDeclarationSyntax.prototype.isMemberDeclaration = function () { + return true; + }; + + MemberAccessorDeclarationSyntax.prototype.isClassElement = function () { + return true; + }; + + MemberAccessorDeclarationSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + MemberAccessorDeclarationSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + MemberAccessorDeclarationSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return MemberAccessorDeclarationSyntax; + })(TypeScript.SyntaxNode); + TypeScript.MemberAccessorDeclarationSyntax = MemberAccessorDeclarationSyntax; + + var GetMemberAccessorDeclarationSyntax = (function (_super) { + __extends(GetMemberAccessorDeclarationSyntax, _super); + function GetMemberAccessorDeclarationSyntax(modifiers, getKeyword, propertyName, parameterList, typeAnnotation, block, parsedInStrictMode) { + _super.call(this, modifiers, propertyName, parameterList, block, parsedInStrictMode); + this.getKeyword = getKeyword; + this.typeAnnotation = typeAnnotation; + } + GetMemberAccessorDeclarationSyntax.prototype.accept = function (visitor) { + return visitor.visitGetMemberAccessorDeclaration(this); + }; + + GetMemberAccessorDeclarationSyntax.prototype.kind = function () { + return 138 /* GetMemberAccessorDeclaration */; + }; + + GetMemberAccessorDeclarationSyntax.prototype.childCount = function () { + return 6; + }; + + GetMemberAccessorDeclarationSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.modifiers; + case 1: + return this.getKeyword; + case 2: + return this.propertyName; + case 3: + return this.parameterList; + case 4: + return this.typeAnnotation; + case 5: + return this.block; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + GetMemberAccessorDeclarationSyntax.prototype.update = function (modifiers, getKeyword, propertyName, parameterList, typeAnnotation, block) { + if (this.modifiers === modifiers && this.getKeyword === getKeyword && this.propertyName === propertyName && this.parameterList === parameterList && this.typeAnnotation === typeAnnotation && this.block === block) { + return this; + } + + return new GetMemberAccessorDeclarationSyntax(modifiers, getKeyword, propertyName, parameterList, typeAnnotation, block, this.parsedInStrictMode()); + }; + + GetMemberAccessorDeclarationSyntax.create = function (getKeyword, propertyName, parameterList, block) { + return new GetMemberAccessorDeclarationSyntax(TypeScript.Syntax.emptyList, getKeyword, propertyName, parameterList, null, block, false); + }; + + GetMemberAccessorDeclarationSyntax.create1 = function (propertyName) { + return new GetMemberAccessorDeclarationSyntax(TypeScript.Syntax.emptyList, TypeScript.Syntax.token(64 /* GetKeyword */), propertyName, ParameterListSyntax.create1(), null, BlockSyntax.create1(), false); + }; + + GetMemberAccessorDeclarationSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + GetMemberAccessorDeclarationSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + GetMemberAccessorDeclarationSyntax.prototype.withModifiers = function (modifiers) { + return this.update(modifiers, this.getKeyword, this.propertyName, this.parameterList, this.typeAnnotation, this.block); + }; + + GetMemberAccessorDeclarationSyntax.prototype.withModifier = function (modifier) { + return this.withModifiers(TypeScript.Syntax.list([modifier])); + }; + + GetMemberAccessorDeclarationSyntax.prototype.withGetKeyword = function (getKeyword) { + return this.update(this.modifiers, getKeyword, this.propertyName, this.parameterList, this.typeAnnotation, this.block); + }; + + GetMemberAccessorDeclarationSyntax.prototype.withPropertyName = function (propertyName) { + return this.update(this.modifiers, this.getKeyword, propertyName, this.parameterList, this.typeAnnotation, this.block); + }; + + GetMemberAccessorDeclarationSyntax.prototype.withParameterList = function (parameterList) { + return this.update(this.modifiers, this.getKeyword, this.propertyName, parameterList, this.typeAnnotation, this.block); + }; + + GetMemberAccessorDeclarationSyntax.prototype.withTypeAnnotation = function (typeAnnotation) { + return this.update(this.modifiers, this.getKeyword, this.propertyName, this.parameterList, typeAnnotation, this.block); + }; + + GetMemberAccessorDeclarationSyntax.prototype.withBlock = function (block) { + return this.update(this.modifiers, this.getKeyword, this.propertyName, this.parameterList, this.typeAnnotation, block); + }; + + GetMemberAccessorDeclarationSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return GetMemberAccessorDeclarationSyntax; + })(MemberAccessorDeclarationSyntax); + TypeScript.GetMemberAccessorDeclarationSyntax = GetMemberAccessorDeclarationSyntax; + + var SetMemberAccessorDeclarationSyntax = (function (_super) { + __extends(SetMemberAccessorDeclarationSyntax, _super); + function SetMemberAccessorDeclarationSyntax(modifiers, setKeyword, propertyName, parameterList, block, parsedInStrictMode) { + _super.call(this, modifiers, propertyName, parameterList, block, parsedInStrictMode); + this.setKeyword = setKeyword; + } + SetMemberAccessorDeclarationSyntax.prototype.accept = function (visitor) { + return visitor.visitSetMemberAccessorDeclaration(this); + }; + + SetMemberAccessorDeclarationSyntax.prototype.kind = function () { + return 139 /* SetMemberAccessorDeclaration */; + }; + + SetMemberAccessorDeclarationSyntax.prototype.childCount = function () { + return 5; + }; + + SetMemberAccessorDeclarationSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.modifiers; + case 1: + return this.setKeyword; + case 2: + return this.propertyName; + case 3: + return this.parameterList; + case 4: + return this.block; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + SetMemberAccessorDeclarationSyntax.prototype.update = function (modifiers, setKeyword, propertyName, parameterList, block) { + if (this.modifiers === modifiers && this.setKeyword === setKeyword && this.propertyName === propertyName && this.parameterList === parameterList && this.block === block) { + return this; + } + + return new SetMemberAccessorDeclarationSyntax(modifiers, setKeyword, propertyName, parameterList, block, this.parsedInStrictMode()); + }; + + SetMemberAccessorDeclarationSyntax.create = function (setKeyword, propertyName, parameterList, block) { + return new SetMemberAccessorDeclarationSyntax(TypeScript.Syntax.emptyList, setKeyword, propertyName, parameterList, block, false); + }; + + SetMemberAccessorDeclarationSyntax.create1 = function (propertyName) { + return new SetMemberAccessorDeclarationSyntax(TypeScript.Syntax.emptyList, TypeScript.Syntax.token(68 /* SetKeyword */), propertyName, ParameterListSyntax.create1(), BlockSyntax.create1(), false); + }; + + SetMemberAccessorDeclarationSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + SetMemberAccessorDeclarationSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + SetMemberAccessorDeclarationSyntax.prototype.withModifiers = function (modifiers) { + return this.update(modifiers, this.setKeyword, this.propertyName, this.parameterList, this.block); + }; + + SetMemberAccessorDeclarationSyntax.prototype.withModifier = function (modifier) { + return this.withModifiers(TypeScript.Syntax.list([modifier])); + }; + + SetMemberAccessorDeclarationSyntax.prototype.withSetKeyword = function (setKeyword) { + return this.update(this.modifiers, setKeyword, this.propertyName, this.parameterList, this.block); + }; + + SetMemberAccessorDeclarationSyntax.prototype.withPropertyName = function (propertyName) { + return this.update(this.modifiers, this.setKeyword, propertyName, this.parameterList, this.block); + }; + + SetMemberAccessorDeclarationSyntax.prototype.withParameterList = function (parameterList) { + return this.update(this.modifiers, this.setKeyword, this.propertyName, parameterList, this.block); + }; + + SetMemberAccessorDeclarationSyntax.prototype.withBlock = function (block) { + return this.update(this.modifiers, this.setKeyword, this.propertyName, this.parameterList, block); + }; + + SetMemberAccessorDeclarationSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return SetMemberAccessorDeclarationSyntax; + })(MemberAccessorDeclarationSyntax); + TypeScript.SetMemberAccessorDeclarationSyntax = SetMemberAccessorDeclarationSyntax; + + var MemberVariableDeclarationSyntax = (function (_super) { + __extends(MemberVariableDeclarationSyntax, _super); + function MemberVariableDeclarationSyntax(modifiers, variableDeclarator, semicolonToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.modifiers = modifiers; + this.variableDeclarator = variableDeclarator; + this.semicolonToken = semicolonToken; + } + MemberVariableDeclarationSyntax.prototype.accept = function (visitor) { + return visitor.visitMemberVariableDeclaration(this); + }; + + MemberVariableDeclarationSyntax.prototype.kind = function () { + return 136 /* MemberVariableDeclaration */; + }; + + MemberVariableDeclarationSyntax.prototype.childCount = function () { + return 3; + }; + + MemberVariableDeclarationSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.modifiers; + case 1: + return this.variableDeclarator; + case 2: + return this.semicolonToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + MemberVariableDeclarationSyntax.prototype.isMemberDeclaration = function () { + return true; + }; + + MemberVariableDeclarationSyntax.prototype.isClassElement = function () { + return true; + }; + + MemberVariableDeclarationSyntax.prototype.update = function (modifiers, variableDeclarator, semicolonToken) { + if (this.modifiers === modifiers && this.variableDeclarator === variableDeclarator && this.semicolonToken === semicolonToken) { + return this; + } + + return new MemberVariableDeclarationSyntax(modifiers, variableDeclarator, semicolonToken, this.parsedInStrictMode()); + }; + + MemberVariableDeclarationSyntax.create = function (variableDeclarator, semicolonToken) { + return new MemberVariableDeclarationSyntax(TypeScript.Syntax.emptyList, variableDeclarator, semicolonToken, false); + }; + + MemberVariableDeclarationSyntax.create1 = function (variableDeclarator) { + return new MemberVariableDeclarationSyntax(TypeScript.Syntax.emptyList, variableDeclarator, TypeScript.Syntax.token(78 /* SemicolonToken */), false); + }; + + MemberVariableDeclarationSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + MemberVariableDeclarationSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + MemberVariableDeclarationSyntax.prototype.withModifiers = function (modifiers) { + return this.update(modifiers, this.variableDeclarator, this.semicolonToken); + }; + + MemberVariableDeclarationSyntax.prototype.withModifier = function (modifier) { + return this.withModifiers(TypeScript.Syntax.list([modifier])); + }; + + MemberVariableDeclarationSyntax.prototype.withVariableDeclarator = function (variableDeclarator) { + return this.update(this.modifiers, variableDeclarator, this.semicolonToken); + }; + + MemberVariableDeclarationSyntax.prototype.withSemicolonToken = function (semicolonToken) { + return this.update(this.modifiers, this.variableDeclarator, semicolonToken); + }; + + MemberVariableDeclarationSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return MemberVariableDeclarationSyntax; + })(TypeScript.SyntaxNode); + TypeScript.MemberVariableDeclarationSyntax = MemberVariableDeclarationSyntax; + + var ThrowStatementSyntax = (function (_super) { + __extends(ThrowStatementSyntax, _super); + function ThrowStatementSyntax(throwKeyword, expression, semicolonToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.throwKeyword = throwKeyword; + this.expression = expression; + this.semicolonToken = semicolonToken; + } + ThrowStatementSyntax.prototype.accept = function (visitor) { + return visitor.visitThrowStatement(this); + }; + + ThrowStatementSyntax.prototype.kind = function () { + return 156 /* ThrowStatement */; + }; + + ThrowStatementSyntax.prototype.childCount = function () { + return 3; + }; + + ThrowStatementSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.throwKeyword; + case 1: + return this.expression; + case 2: + return this.semicolonToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ThrowStatementSyntax.prototype.isStatement = function () { + return true; + }; + + ThrowStatementSyntax.prototype.isModuleElement = function () { + return true; + }; + + ThrowStatementSyntax.prototype.update = function (throwKeyword, expression, semicolonToken) { + if (this.throwKeyword === throwKeyword && this.expression === expression && this.semicolonToken === semicolonToken) { + return this; + } + + return new ThrowStatementSyntax(throwKeyword, expression, semicolonToken, this.parsedInStrictMode()); + }; + + ThrowStatementSyntax.create1 = function (expression) { + return new ThrowStatementSyntax(TypeScript.Syntax.token(36 /* ThrowKeyword */), expression, TypeScript.Syntax.token(78 /* SemicolonToken */), false); + }; + + ThrowStatementSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ThrowStatementSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ThrowStatementSyntax.prototype.withThrowKeyword = function (throwKeyword) { + return this.update(throwKeyword, this.expression, this.semicolonToken); + }; + + ThrowStatementSyntax.prototype.withExpression = function (expression) { + return this.update(this.throwKeyword, expression, this.semicolonToken); + }; + + ThrowStatementSyntax.prototype.withSemicolonToken = function (semicolonToken) { + return this.update(this.throwKeyword, this.expression, semicolonToken); + }; + + ThrowStatementSyntax.prototype.isTypeScriptSpecific = function () { + if (this.expression.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return ThrowStatementSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ThrowStatementSyntax = ThrowStatementSyntax; + + var ReturnStatementSyntax = (function (_super) { + __extends(ReturnStatementSyntax, _super); + function ReturnStatementSyntax(returnKeyword, expression, semicolonToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.returnKeyword = returnKeyword; + this.expression = expression; + this.semicolonToken = semicolonToken; + } + ReturnStatementSyntax.prototype.accept = function (visitor) { + return visitor.visitReturnStatement(this); + }; + + ReturnStatementSyntax.prototype.kind = function () { + return 149 /* ReturnStatement */; + }; + + ReturnStatementSyntax.prototype.childCount = function () { + return 3; + }; + + ReturnStatementSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.returnKeyword; + case 1: + return this.expression; + case 2: + return this.semicolonToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ReturnStatementSyntax.prototype.isStatement = function () { + return true; + }; + + ReturnStatementSyntax.prototype.isModuleElement = function () { + return true; + }; + + ReturnStatementSyntax.prototype.update = function (returnKeyword, expression, semicolonToken) { + if (this.returnKeyword === returnKeyword && this.expression === expression && this.semicolonToken === semicolonToken) { + return this; + } + + return new ReturnStatementSyntax(returnKeyword, expression, semicolonToken, this.parsedInStrictMode()); + }; + + ReturnStatementSyntax.create = function (returnKeyword, semicolonToken) { + return new ReturnStatementSyntax(returnKeyword, null, semicolonToken, false); + }; + + ReturnStatementSyntax.create1 = function () { + return new ReturnStatementSyntax(TypeScript.Syntax.token(33 /* ReturnKeyword */), null, TypeScript.Syntax.token(78 /* SemicolonToken */), false); + }; + + ReturnStatementSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ReturnStatementSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ReturnStatementSyntax.prototype.withReturnKeyword = function (returnKeyword) { + return this.update(returnKeyword, this.expression, this.semicolonToken); + }; + + ReturnStatementSyntax.prototype.withExpression = function (expression) { + return this.update(this.returnKeyword, expression, this.semicolonToken); + }; + + ReturnStatementSyntax.prototype.withSemicolonToken = function (semicolonToken) { + return this.update(this.returnKeyword, this.expression, semicolonToken); + }; + + ReturnStatementSyntax.prototype.isTypeScriptSpecific = function () { + if (this.expression !== null && this.expression.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return ReturnStatementSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ReturnStatementSyntax = ReturnStatementSyntax; + + var ObjectCreationExpressionSyntax = (function (_super) { + __extends(ObjectCreationExpressionSyntax, _super); + function ObjectCreationExpressionSyntax(newKeyword, expression, argumentList, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.newKeyword = newKeyword; + this.expression = expression; + this.argumentList = argumentList; + } + ObjectCreationExpressionSyntax.prototype.accept = function (visitor) { + return visitor.visitObjectCreationExpression(this); + }; + + ObjectCreationExpressionSyntax.prototype.kind = function () { + return 215 /* ObjectCreationExpression */; + }; + + ObjectCreationExpressionSyntax.prototype.childCount = function () { + return 3; + }; + + ObjectCreationExpressionSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.newKeyword; + case 1: + return this.expression; + case 2: + return this.argumentList; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ObjectCreationExpressionSyntax.prototype.isUnaryExpression = function () { + return true; + }; + + ObjectCreationExpressionSyntax.prototype.isExpression = function () { + return true; + }; + + ObjectCreationExpressionSyntax.prototype.update = function (newKeyword, expression, argumentList) { + if (this.newKeyword === newKeyword && this.expression === expression && this.argumentList === argumentList) { + return this; + } + + return new ObjectCreationExpressionSyntax(newKeyword, expression, argumentList, this.parsedInStrictMode()); + }; + + ObjectCreationExpressionSyntax.create = function (newKeyword, expression) { + return new ObjectCreationExpressionSyntax(newKeyword, expression, null, false); + }; + + ObjectCreationExpressionSyntax.create1 = function (expression) { + return new ObjectCreationExpressionSyntax(TypeScript.Syntax.token(31 /* NewKeyword */), expression, null, false); + }; + + ObjectCreationExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ObjectCreationExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ObjectCreationExpressionSyntax.prototype.withNewKeyword = function (newKeyword) { + return this.update(newKeyword, this.expression, this.argumentList); + }; + + ObjectCreationExpressionSyntax.prototype.withExpression = function (expression) { + return this.update(this.newKeyword, expression, this.argumentList); + }; + + ObjectCreationExpressionSyntax.prototype.withArgumentList = function (argumentList) { + return this.update(this.newKeyword, this.expression, argumentList); + }; + + ObjectCreationExpressionSyntax.prototype.isTypeScriptSpecific = function () { + if (this.expression.isTypeScriptSpecific()) { + return true; + } + if (this.argumentList !== null && this.argumentList.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return ObjectCreationExpressionSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ObjectCreationExpressionSyntax = ObjectCreationExpressionSyntax; + + var SwitchStatementSyntax = (function (_super) { + __extends(SwitchStatementSyntax, _super); + function SwitchStatementSyntax(switchKeyword, openParenToken, expression, closeParenToken, openBraceToken, switchClauses, closeBraceToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.switchKeyword = switchKeyword; + this.openParenToken = openParenToken; + this.expression = expression; + this.closeParenToken = closeParenToken; + this.openBraceToken = openBraceToken; + this.switchClauses = switchClauses; + this.closeBraceToken = closeBraceToken; + } + SwitchStatementSyntax.prototype.accept = function (visitor) { + return visitor.visitSwitchStatement(this); + }; + + SwitchStatementSyntax.prototype.kind = function () { + return 150 /* SwitchStatement */; + }; + + SwitchStatementSyntax.prototype.childCount = function () { + return 7; + }; + + SwitchStatementSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.switchKeyword; + case 1: + return this.openParenToken; + case 2: + return this.expression; + case 3: + return this.closeParenToken; + case 4: + return this.openBraceToken; + case 5: + return this.switchClauses; + case 6: + return this.closeBraceToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + SwitchStatementSyntax.prototype.isStatement = function () { + return true; + }; + + SwitchStatementSyntax.prototype.isModuleElement = function () { + return true; + }; + + SwitchStatementSyntax.prototype.update = function (switchKeyword, openParenToken, expression, closeParenToken, openBraceToken, switchClauses, closeBraceToken) { + if (this.switchKeyword === switchKeyword && this.openParenToken === openParenToken && this.expression === expression && this.closeParenToken === closeParenToken && this.openBraceToken === openBraceToken && this.switchClauses === switchClauses && this.closeBraceToken === closeBraceToken) { + return this; + } + + return new SwitchStatementSyntax(switchKeyword, openParenToken, expression, closeParenToken, openBraceToken, switchClauses, closeBraceToken, this.parsedInStrictMode()); + }; + + SwitchStatementSyntax.create = function (switchKeyword, openParenToken, expression, closeParenToken, openBraceToken, closeBraceToken) { + return new SwitchStatementSyntax(switchKeyword, openParenToken, expression, closeParenToken, openBraceToken, TypeScript.Syntax.emptyList, closeBraceToken, false); + }; + + SwitchStatementSyntax.create1 = function (expression) { + return new SwitchStatementSyntax(TypeScript.Syntax.token(34 /* SwitchKeyword */), TypeScript.Syntax.token(72 /* OpenParenToken */), expression, TypeScript.Syntax.token(73 /* CloseParenToken */), TypeScript.Syntax.token(70 /* OpenBraceToken */), TypeScript.Syntax.emptyList, TypeScript.Syntax.token(71 /* CloseBraceToken */), false); + }; + + SwitchStatementSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + SwitchStatementSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + SwitchStatementSyntax.prototype.withSwitchKeyword = function (switchKeyword) { + return this.update(switchKeyword, this.openParenToken, this.expression, this.closeParenToken, this.openBraceToken, this.switchClauses, this.closeBraceToken); + }; + + SwitchStatementSyntax.prototype.withOpenParenToken = function (openParenToken) { + return this.update(this.switchKeyword, openParenToken, this.expression, this.closeParenToken, this.openBraceToken, this.switchClauses, this.closeBraceToken); + }; + + SwitchStatementSyntax.prototype.withExpression = function (expression) { + return this.update(this.switchKeyword, this.openParenToken, expression, this.closeParenToken, this.openBraceToken, this.switchClauses, this.closeBraceToken); + }; + + SwitchStatementSyntax.prototype.withCloseParenToken = function (closeParenToken) { + return this.update(this.switchKeyword, this.openParenToken, this.expression, closeParenToken, this.openBraceToken, this.switchClauses, this.closeBraceToken); + }; + + SwitchStatementSyntax.prototype.withOpenBraceToken = function (openBraceToken) { + return this.update(this.switchKeyword, this.openParenToken, this.expression, this.closeParenToken, openBraceToken, this.switchClauses, this.closeBraceToken); + }; + + SwitchStatementSyntax.prototype.withSwitchClauses = function (switchClauses) { + return this.update(this.switchKeyword, this.openParenToken, this.expression, this.closeParenToken, this.openBraceToken, switchClauses, this.closeBraceToken); + }; + + SwitchStatementSyntax.prototype.withSwitchClause = function (switchClause) { + return this.withSwitchClauses(TypeScript.Syntax.list([switchClause])); + }; + + SwitchStatementSyntax.prototype.withCloseBraceToken = function (closeBraceToken) { + return this.update(this.switchKeyword, this.openParenToken, this.expression, this.closeParenToken, this.openBraceToken, this.switchClauses, closeBraceToken); + }; + + SwitchStatementSyntax.prototype.isTypeScriptSpecific = function () { + if (this.expression.isTypeScriptSpecific()) { + return true; + } + if (this.switchClauses.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return SwitchStatementSyntax; + })(TypeScript.SyntaxNode); + TypeScript.SwitchStatementSyntax = SwitchStatementSyntax; + + var SwitchClauseSyntax = (function (_super) { + __extends(SwitchClauseSyntax, _super); + function SwitchClauseSyntax(colonToken, statements, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.colonToken = colonToken; + this.statements = statements; + } + SwitchClauseSyntax.prototype.isSwitchClause = function () { + return true; + }; + + SwitchClauseSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + SwitchClauseSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + SwitchClauseSyntax.prototype.isTypeScriptSpecific = function () { + return false; + }; + return SwitchClauseSyntax; + })(TypeScript.SyntaxNode); + TypeScript.SwitchClauseSyntax = SwitchClauseSyntax; + + var CaseSwitchClauseSyntax = (function (_super) { + __extends(CaseSwitchClauseSyntax, _super); + function CaseSwitchClauseSyntax(caseKeyword, expression, colonToken, statements, parsedInStrictMode) { + _super.call(this, colonToken, statements, parsedInStrictMode); + this.caseKeyword = caseKeyword; + this.expression = expression; + } + CaseSwitchClauseSyntax.prototype.accept = function (visitor) { + return visitor.visitCaseSwitchClause(this); + }; + + CaseSwitchClauseSyntax.prototype.kind = function () { + return 231 /* CaseSwitchClause */; + }; + + CaseSwitchClauseSyntax.prototype.childCount = function () { + return 4; + }; + + CaseSwitchClauseSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.caseKeyword; + case 1: + return this.expression; + case 2: + return this.colonToken; + case 3: + return this.statements; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + CaseSwitchClauseSyntax.prototype.update = function (caseKeyword, expression, colonToken, statements) { + if (this.caseKeyword === caseKeyword && this.expression === expression && this.colonToken === colonToken && this.statements === statements) { + return this; + } + + return new CaseSwitchClauseSyntax(caseKeyword, expression, colonToken, statements, this.parsedInStrictMode()); + }; + + CaseSwitchClauseSyntax.create = function (caseKeyword, expression, colonToken) { + return new CaseSwitchClauseSyntax(caseKeyword, expression, colonToken, TypeScript.Syntax.emptyList, false); + }; + + CaseSwitchClauseSyntax.create1 = function (expression) { + return new CaseSwitchClauseSyntax(TypeScript.Syntax.token(16 /* CaseKeyword */), expression, TypeScript.Syntax.token(106 /* ColonToken */), TypeScript.Syntax.emptyList, false); + }; + + CaseSwitchClauseSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + CaseSwitchClauseSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + CaseSwitchClauseSyntax.prototype.withCaseKeyword = function (caseKeyword) { + return this.update(caseKeyword, this.expression, this.colonToken, this.statements); + }; + + CaseSwitchClauseSyntax.prototype.withExpression = function (expression) { + return this.update(this.caseKeyword, expression, this.colonToken, this.statements); + }; + + CaseSwitchClauseSyntax.prototype.withColonToken = function (colonToken) { + return this.update(this.caseKeyword, this.expression, colonToken, this.statements); + }; + + CaseSwitchClauseSyntax.prototype.withStatements = function (statements) { + return this.update(this.caseKeyword, this.expression, this.colonToken, statements); + }; + + CaseSwitchClauseSyntax.prototype.withStatement = function (statement) { + return this.withStatements(TypeScript.Syntax.list([statement])); + }; + + CaseSwitchClauseSyntax.prototype.isTypeScriptSpecific = function () { + if (this.expression.isTypeScriptSpecific()) { + return true; + } + if (this.statements.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return CaseSwitchClauseSyntax; + })(SwitchClauseSyntax); + TypeScript.CaseSwitchClauseSyntax = CaseSwitchClauseSyntax; + + var DefaultSwitchClauseSyntax = (function (_super) { + __extends(DefaultSwitchClauseSyntax, _super); + function DefaultSwitchClauseSyntax(defaultKeyword, colonToken, statements, parsedInStrictMode) { + _super.call(this, colonToken, statements, parsedInStrictMode); + this.defaultKeyword = defaultKeyword; + } + DefaultSwitchClauseSyntax.prototype.accept = function (visitor) { + return visitor.visitDefaultSwitchClause(this); + }; + + DefaultSwitchClauseSyntax.prototype.kind = function () { + return 232 /* DefaultSwitchClause */; + }; + + DefaultSwitchClauseSyntax.prototype.childCount = function () { + return 3; + }; + + DefaultSwitchClauseSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.defaultKeyword; + case 1: + return this.colonToken; + case 2: + return this.statements; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + DefaultSwitchClauseSyntax.prototype.update = function (defaultKeyword, colonToken, statements) { + if (this.defaultKeyword === defaultKeyword && this.colonToken === colonToken && this.statements === statements) { + return this; + } + + return new DefaultSwitchClauseSyntax(defaultKeyword, colonToken, statements, this.parsedInStrictMode()); + }; + + DefaultSwitchClauseSyntax.create = function (defaultKeyword, colonToken) { + return new DefaultSwitchClauseSyntax(defaultKeyword, colonToken, TypeScript.Syntax.emptyList, false); + }; + + DefaultSwitchClauseSyntax.create1 = function () { + return new DefaultSwitchClauseSyntax(TypeScript.Syntax.token(20 /* DefaultKeyword */), TypeScript.Syntax.token(106 /* ColonToken */), TypeScript.Syntax.emptyList, false); + }; + + DefaultSwitchClauseSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + DefaultSwitchClauseSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + DefaultSwitchClauseSyntax.prototype.withDefaultKeyword = function (defaultKeyword) { + return this.update(defaultKeyword, this.colonToken, this.statements); + }; + + DefaultSwitchClauseSyntax.prototype.withColonToken = function (colonToken) { + return this.update(this.defaultKeyword, colonToken, this.statements); + }; + + DefaultSwitchClauseSyntax.prototype.withStatements = function (statements) { + return this.update(this.defaultKeyword, this.colonToken, statements); + }; + + DefaultSwitchClauseSyntax.prototype.withStatement = function (statement) { + return this.withStatements(TypeScript.Syntax.list([statement])); + }; + + DefaultSwitchClauseSyntax.prototype.isTypeScriptSpecific = function () { + if (this.statements.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return DefaultSwitchClauseSyntax; + })(SwitchClauseSyntax); + TypeScript.DefaultSwitchClauseSyntax = DefaultSwitchClauseSyntax; + + var BreakStatementSyntax = (function (_super) { + __extends(BreakStatementSyntax, _super); + function BreakStatementSyntax(breakKeyword, identifier, semicolonToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.breakKeyword = breakKeyword; + this.identifier = identifier; + this.semicolonToken = semicolonToken; + } + BreakStatementSyntax.prototype.accept = function (visitor) { + return visitor.visitBreakStatement(this); + }; + + BreakStatementSyntax.prototype.kind = function () { + return 151 /* BreakStatement */; + }; + + BreakStatementSyntax.prototype.childCount = function () { + return 3; + }; + + BreakStatementSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.breakKeyword; + case 1: + return this.identifier; + case 2: + return this.semicolonToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + BreakStatementSyntax.prototype.isStatement = function () { + return true; + }; + + BreakStatementSyntax.prototype.isModuleElement = function () { + return true; + }; + + BreakStatementSyntax.prototype.update = function (breakKeyword, identifier, semicolonToken) { + if (this.breakKeyword === breakKeyword && this.identifier === identifier && this.semicolonToken === semicolonToken) { + return this; + } + + return new BreakStatementSyntax(breakKeyword, identifier, semicolonToken, this.parsedInStrictMode()); + }; + + BreakStatementSyntax.create = function (breakKeyword, semicolonToken) { + return new BreakStatementSyntax(breakKeyword, null, semicolonToken, false); + }; + + BreakStatementSyntax.create1 = function () { + return new BreakStatementSyntax(TypeScript.Syntax.token(15 /* BreakKeyword */), null, TypeScript.Syntax.token(78 /* SemicolonToken */), false); + }; + + BreakStatementSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + BreakStatementSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + BreakStatementSyntax.prototype.withBreakKeyword = function (breakKeyword) { + return this.update(breakKeyword, this.identifier, this.semicolonToken); + }; + + BreakStatementSyntax.prototype.withIdentifier = function (identifier) { + return this.update(this.breakKeyword, identifier, this.semicolonToken); + }; + + BreakStatementSyntax.prototype.withSemicolonToken = function (semicolonToken) { + return this.update(this.breakKeyword, this.identifier, semicolonToken); + }; + + BreakStatementSyntax.prototype.isTypeScriptSpecific = function () { + return false; + }; + return BreakStatementSyntax; + })(TypeScript.SyntaxNode); + TypeScript.BreakStatementSyntax = BreakStatementSyntax; + + var ContinueStatementSyntax = (function (_super) { + __extends(ContinueStatementSyntax, _super); + function ContinueStatementSyntax(continueKeyword, identifier, semicolonToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.continueKeyword = continueKeyword; + this.identifier = identifier; + this.semicolonToken = semicolonToken; + } + ContinueStatementSyntax.prototype.accept = function (visitor) { + return visitor.visitContinueStatement(this); + }; + + ContinueStatementSyntax.prototype.kind = function () { + return 152 /* ContinueStatement */; + }; + + ContinueStatementSyntax.prototype.childCount = function () { + return 3; + }; + + ContinueStatementSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.continueKeyword; + case 1: + return this.identifier; + case 2: + return this.semicolonToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ContinueStatementSyntax.prototype.isStatement = function () { + return true; + }; + + ContinueStatementSyntax.prototype.isModuleElement = function () { + return true; + }; + + ContinueStatementSyntax.prototype.update = function (continueKeyword, identifier, semicolonToken) { + if (this.continueKeyword === continueKeyword && this.identifier === identifier && this.semicolonToken === semicolonToken) { + return this; + } + + return new ContinueStatementSyntax(continueKeyword, identifier, semicolonToken, this.parsedInStrictMode()); + }; + + ContinueStatementSyntax.create = function (continueKeyword, semicolonToken) { + return new ContinueStatementSyntax(continueKeyword, null, semicolonToken, false); + }; + + ContinueStatementSyntax.create1 = function () { + return new ContinueStatementSyntax(TypeScript.Syntax.token(18 /* ContinueKeyword */), null, TypeScript.Syntax.token(78 /* SemicolonToken */), false); + }; + + ContinueStatementSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ContinueStatementSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ContinueStatementSyntax.prototype.withContinueKeyword = function (continueKeyword) { + return this.update(continueKeyword, this.identifier, this.semicolonToken); + }; + + ContinueStatementSyntax.prototype.withIdentifier = function (identifier) { + return this.update(this.continueKeyword, identifier, this.semicolonToken); + }; + + ContinueStatementSyntax.prototype.withSemicolonToken = function (semicolonToken) { + return this.update(this.continueKeyword, this.identifier, semicolonToken); + }; + + ContinueStatementSyntax.prototype.isTypeScriptSpecific = function () { + return false; + }; + return ContinueStatementSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ContinueStatementSyntax = ContinueStatementSyntax; + + var IterationStatementSyntax = (function (_super) { + __extends(IterationStatementSyntax, _super); + function IterationStatementSyntax(openParenToken, closeParenToken, statement, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.openParenToken = openParenToken; + this.closeParenToken = closeParenToken; + this.statement = statement; + } + IterationStatementSyntax.prototype.isStatement = function () { + return true; + }; + + IterationStatementSyntax.prototype.isModuleElement = function () { + return true; + }; + + IterationStatementSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + IterationStatementSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + IterationStatementSyntax.prototype.isTypeScriptSpecific = function () { + return false; + }; + return IterationStatementSyntax; + })(TypeScript.SyntaxNode); + TypeScript.IterationStatementSyntax = IterationStatementSyntax; + + var BaseForStatementSyntax = (function (_super) { + __extends(BaseForStatementSyntax, _super); + function BaseForStatementSyntax(forKeyword, openParenToken, variableDeclaration, closeParenToken, statement, parsedInStrictMode) { + _super.call(this, openParenToken, closeParenToken, statement, parsedInStrictMode); + this.forKeyword = forKeyword; + this.variableDeclaration = variableDeclaration; + } + BaseForStatementSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + BaseForStatementSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + BaseForStatementSyntax.prototype.isTypeScriptSpecific = function () { + return false; + }; + return BaseForStatementSyntax; + })(IterationStatementSyntax); + TypeScript.BaseForStatementSyntax = BaseForStatementSyntax; + + var ForStatementSyntax = (function (_super) { + __extends(ForStatementSyntax, _super); + function ForStatementSyntax(forKeyword, openParenToken, variableDeclaration, initializer, firstSemicolonToken, condition, secondSemicolonToken, incrementor, closeParenToken, statement, parsedInStrictMode) { + _super.call(this, forKeyword, openParenToken, variableDeclaration, closeParenToken, statement, parsedInStrictMode); + this.initializer = initializer; + this.firstSemicolonToken = firstSemicolonToken; + this.condition = condition; + this.secondSemicolonToken = secondSemicolonToken; + this.incrementor = incrementor; + } + ForStatementSyntax.prototype.accept = function (visitor) { + return visitor.visitForStatement(this); + }; + + ForStatementSyntax.prototype.kind = function () { + return 153 /* ForStatement */; + }; + + ForStatementSyntax.prototype.childCount = function () { + return 10; + }; + + ForStatementSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.forKeyword; + case 1: + return this.openParenToken; + case 2: + return this.variableDeclaration; + case 3: + return this.initializer; + case 4: + return this.firstSemicolonToken; + case 5: + return this.condition; + case 6: + return this.secondSemicolonToken; + case 7: + return this.incrementor; + case 8: + return this.closeParenToken; + case 9: + return this.statement; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ForStatementSyntax.prototype.update = function (forKeyword, openParenToken, variableDeclaration, initializer, firstSemicolonToken, condition, secondSemicolonToken, incrementor, closeParenToken, statement) { + if (this.forKeyword === forKeyword && this.openParenToken === openParenToken && this.variableDeclaration === variableDeclaration && this.initializer === initializer && this.firstSemicolonToken === firstSemicolonToken && this.condition === condition && this.secondSemicolonToken === secondSemicolonToken && this.incrementor === incrementor && this.closeParenToken === closeParenToken && this.statement === statement) { + return this; + } + + return new ForStatementSyntax(forKeyword, openParenToken, variableDeclaration, initializer, firstSemicolonToken, condition, secondSemicolonToken, incrementor, closeParenToken, statement, this.parsedInStrictMode()); + }; + + ForStatementSyntax.create = function (forKeyword, openParenToken, firstSemicolonToken, secondSemicolonToken, closeParenToken, statement) { + return new ForStatementSyntax(forKeyword, openParenToken, null, null, firstSemicolonToken, null, secondSemicolonToken, null, closeParenToken, statement, false); + }; + + ForStatementSyntax.create1 = function (statement) { + return new ForStatementSyntax(TypeScript.Syntax.token(26 /* ForKeyword */), TypeScript.Syntax.token(72 /* OpenParenToken */), null, null, TypeScript.Syntax.token(78 /* SemicolonToken */), null, TypeScript.Syntax.token(78 /* SemicolonToken */), null, TypeScript.Syntax.token(73 /* CloseParenToken */), statement, false); + }; + + ForStatementSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ForStatementSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ForStatementSyntax.prototype.withForKeyword = function (forKeyword) { + return this.update(forKeyword, this.openParenToken, this.variableDeclaration, this.initializer, this.firstSemicolonToken, this.condition, this.secondSemicolonToken, this.incrementor, this.closeParenToken, this.statement); + }; + + ForStatementSyntax.prototype.withOpenParenToken = function (openParenToken) { + return this.update(this.forKeyword, openParenToken, this.variableDeclaration, this.initializer, this.firstSemicolonToken, this.condition, this.secondSemicolonToken, this.incrementor, this.closeParenToken, this.statement); + }; + + ForStatementSyntax.prototype.withVariableDeclaration = function (variableDeclaration) { + return this.update(this.forKeyword, this.openParenToken, variableDeclaration, this.initializer, this.firstSemicolonToken, this.condition, this.secondSemicolonToken, this.incrementor, this.closeParenToken, this.statement); + }; + + ForStatementSyntax.prototype.withInitializer = function (initializer) { + return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, initializer, this.firstSemicolonToken, this.condition, this.secondSemicolonToken, this.incrementor, this.closeParenToken, this.statement); + }; + + ForStatementSyntax.prototype.withFirstSemicolonToken = function (firstSemicolonToken) { + return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, this.initializer, firstSemicolonToken, this.condition, this.secondSemicolonToken, this.incrementor, this.closeParenToken, this.statement); + }; + + ForStatementSyntax.prototype.withCondition = function (condition) { + return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, this.initializer, this.firstSemicolonToken, condition, this.secondSemicolonToken, this.incrementor, this.closeParenToken, this.statement); + }; + + ForStatementSyntax.prototype.withSecondSemicolonToken = function (secondSemicolonToken) { + return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, this.initializer, this.firstSemicolonToken, this.condition, secondSemicolonToken, this.incrementor, this.closeParenToken, this.statement); + }; + + ForStatementSyntax.prototype.withIncrementor = function (incrementor) { + return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, this.initializer, this.firstSemicolonToken, this.condition, this.secondSemicolonToken, incrementor, this.closeParenToken, this.statement); + }; + + ForStatementSyntax.prototype.withCloseParenToken = function (closeParenToken) { + return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, this.initializer, this.firstSemicolonToken, this.condition, this.secondSemicolonToken, this.incrementor, closeParenToken, this.statement); + }; + + ForStatementSyntax.prototype.withStatement = function (statement) { + return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, this.initializer, this.firstSemicolonToken, this.condition, this.secondSemicolonToken, this.incrementor, this.closeParenToken, statement); + }; + + ForStatementSyntax.prototype.isTypeScriptSpecific = function () { + if (this.variableDeclaration !== null && this.variableDeclaration.isTypeScriptSpecific()) { + return true; + } + if (this.initializer !== null && this.initializer.isTypeScriptSpecific()) { + return true; + } + if (this.condition !== null && this.condition.isTypeScriptSpecific()) { + return true; + } + if (this.incrementor !== null && this.incrementor.isTypeScriptSpecific()) { + return true; + } + if (this.statement.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return ForStatementSyntax; + })(BaseForStatementSyntax); + TypeScript.ForStatementSyntax = ForStatementSyntax; + + var ForInStatementSyntax = (function (_super) { + __extends(ForInStatementSyntax, _super); + function ForInStatementSyntax(forKeyword, openParenToken, variableDeclaration, left, inKeyword, expression, closeParenToken, statement, parsedInStrictMode) { + _super.call(this, forKeyword, openParenToken, variableDeclaration, closeParenToken, statement, parsedInStrictMode); + this.left = left; + this.inKeyword = inKeyword; + this.expression = expression; + } + ForInStatementSyntax.prototype.accept = function (visitor) { + return visitor.visitForInStatement(this); + }; + + ForInStatementSyntax.prototype.kind = function () { + return 154 /* ForInStatement */; + }; + + ForInStatementSyntax.prototype.childCount = function () { + return 8; + }; + + ForInStatementSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.forKeyword; + case 1: + return this.openParenToken; + case 2: + return this.variableDeclaration; + case 3: + return this.left; + case 4: + return this.inKeyword; + case 5: + return this.expression; + case 6: + return this.closeParenToken; + case 7: + return this.statement; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ForInStatementSyntax.prototype.update = function (forKeyword, openParenToken, variableDeclaration, left, inKeyword, expression, closeParenToken, statement) { + if (this.forKeyword === forKeyword && this.openParenToken === openParenToken && this.variableDeclaration === variableDeclaration && this.left === left && this.inKeyword === inKeyword && this.expression === expression && this.closeParenToken === closeParenToken && this.statement === statement) { + return this; + } + + return new ForInStatementSyntax(forKeyword, openParenToken, variableDeclaration, left, inKeyword, expression, closeParenToken, statement, this.parsedInStrictMode()); + }; + + ForInStatementSyntax.create = function (forKeyword, openParenToken, inKeyword, expression, closeParenToken, statement) { + return new ForInStatementSyntax(forKeyword, openParenToken, null, null, inKeyword, expression, closeParenToken, statement, false); + }; + + ForInStatementSyntax.create1 = function (expression, statement) { + return new ForInStatementSyntax(TypeScript.Syntax.token(26 /* ForKeyword */), TypeScript.Syntax.token(72 /* OpenParenToken */), null, null, TypeScript.Syntax.token(29 /* InKeyword */), expression, TypeScript.Syntax.token(73 /* CloseParenToken */), statement, false); + }; + + ForInStatementSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ForInStatementSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ForInStatementSyntax.prototype.withForKeyword = function (forKeyword) { + return this.update(forKeyword, this.openParenToken, this.variableDeclaration, this.left, this.inKeyword, this.expression, this.closeParenToken, this.statement); + }; + + ForInStatementSyntax.prototype.withOpenParenToken = function (openParenToken) { + return this.update(this.forKeyword, openParenToken, this.variableDeclaration, this.left, this.inKeyword, this.expression, this.closeParenToken, this.statement); + }; + + ForInStatementSyntax.prototype.withVariableDeclaration = function (variableDeclaration) { + return this.update(this.forKeyword, this.openParenToken, variableDeclaration, this.left, this.inKeyword, this.expression, this.closeParenToken, this.statement); + }; + + ForInStatementSyntax.prototype.withLeft = function (left) { + return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, left, this.inKeyword, this.expression, this.closeParenToken, this.statement); + }; + + ForInStatementSyntax.prototype.withInKeyword = function (inKeyword) { + return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, this.left, inKeyword, this.expression, this.closeParenToken, this.statement); + }; + + ForInStatementSyntax.prototype.withExpression = function (expression) { + return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, this.left, this.inKeyword, expression, this.closeParenToken, this.statement); + }; + + ForInStatementSyntax.prototype.withCloseParenToken = function (closeParenToken) { + return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, this.left, this.inKeyword, this.expression, closeParenToken, this.statement); + }; + + ForInStatementSyntax.prototype.withStatement = function (statement) { + return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, this.left, this.inKeyword, this.expression, this.closeParenToken, statement); + }; + + ForInStatementSyntax.prototype.isTypeScriptSpecific = function () { + if (this.variableDeclaration !== null && this.variableDeclaration.isTypeScriptSpecific()) { + return true; + } + if (this.left !== null && this.left.isTypeScriptSpecific()) { + return true; + } + if (this.expression.isTypeScriptSpecific()) { + return true; + } + if (this.statement.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return ForInStatementSyntax; + })(BaseForStatementSyntax); + TypeScript.ForInStatementSyntax = ForInStatementSyntax; + + var WhileStatementSyntax = (function (_super) { + __extends(WhileStatementSyntax, _super); + function WhileStatementSyntax(whileKeyword, openParenToken, condition, closeParenToken, statement, parsedInStrictMode) { + _super.call(this, openParenToken, closeParenToken, statement, parsedInStrictMode); + this.whileKeyword = whileKeyword; + this.condition = condition; + } + WhileStatementSyntax.prototype.accept = function (visitor) { + return visitor.visitWhileStatement(this); + }; + + WhileStatementSyntax.prototype.kind = function () { + return 157 /* WhileStatement */; + }; + + WhileStatementSyntax.prototype.childCount = function () { + return 5; + }; + + WhileStatementSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.whileKeyword; + case 1: + return this.openParenToken; + case 2: + return this.condition; + case 3: + return this.closeParenToken; + case 4: + return this.statement; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + WhileStatementSyntax.prototype.update = function (whileKeyword, openParenToken, condition, closeParenToken, statement) { + if (this.whileKeyword === whileKeyword && this.openParenToken === openParenToken && this.condition === condition && this.closeParenToken === closeParenToken && this.statement === statement) { + return this; + } + + return new WhileStatementSyntax(whileKeyword, openParenToken, condition, closeParenToken, statement, this.parsedInStrictMode()); + }; + + WhileStatementSyntax.create1 = function (condition, statement) { + return new WhileStatementSyntax(TypeScript.Syntax.token(42 /* WhileKeyword */), TypeScript.Syntax.token(72 /* OpenParenToken */), condition, TypeScript.Syntax.token(73 /* CloseParenToken */), statement, false); + }; + + WhileStatementSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + WhileStatementSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + WhileStatementSyntax.prototype.withWhileKeyword = function (whileKeyword) { + return this.update(whileKeyword, this.openParenToken, this.condition, this.closeParenToken, this.statement); + }; + + WhileStatementSyntax.prototype.withOpenParenToken = function (openParenToken) { + return this.update(this.whileKeyword, openParenToken, this.condition, this.closeParenToken, this.statement); + }; + + WhileStatementSyntax.prototype.withCondition = function (condition) { + return this.update(this.whileKeyword, this.openParenToken, condition, this.closeParenToken, this.statement); + }; + + WhileStatementSyntax.prototype.withCloseParenToken = function (closeParenToken) { + return this.update(this.whileKeyword, this.openParenToken, this.condition, closeParenToken, this.statement); + }; + + WhileStatementSyntax.prototype.withStatement = function (statement) { + return this.update(this.whileKeyword, this.openParenToken, this.condition, this.closeParenToken, statement); + }; + + WhileStatementSyntax.prototype.isTypeScriptSpecific = function () { + if (this.condition.isTypeScriptSpecific()) { + return true; + } + if (this.statement.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return WhileStatementSyntax; + })(IterationStatementSyntax); + TypeScript.WhileStatementSyntax = WhileStatementSyntax; + + var WithStatementSyntax = (function (_super) { + __extends(WithStatementSyntax, _super); + function WithStatementSyntax(withKeyword, openParenToken, condition, closeParenToken, statement, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.withKeyword = withKeyword; + this.openParenToken = openParenToken; + this.condition = condition; + this.closeParenToken = closeParenToken; + this.statement = statement; + } + WithStatementSyntax.prototype.accept = function (visitor) { + return visitor.visitWithStatement(this); + }; + + WithStatementSyntax.prototype.kind = function () { + return 162 /* WithStatement */; + }; + + WithStatementSyntax.prototype.childCount = function () { + return 5; + }; + + WithStatementSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.withKeyword; + case 1: + return this.openParenToken; + case 2: + return this.condition; + case 3: + return this.closeParenToken; + case 4: + return this.statement; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + WithStatementSyntax.prototype.isStatement = function () { + return true; + }; + + WithStatementSyntax.prototype.isModuleElement = function () { + return true; + }; + + WithStatementSyntax.prototype.update = function (withKeyword, openParenToken, condition, closeParenToken, statement) { + if (this.withKeyword === withKeyword && this.openParenToken === openParenToken && this.condition === condition && this.closeParenToken === closeParenToken && this.statement === statement) { + return this; + } + + return new WithStatementSyntax(withKeyword, openParenToken, condition, closeParenToken, statement, this.parsedInStrictMode()); + }; + + WithStatementSyntax.create1 = function (condition, statement) { + return new WithStatementSyntax(TypeScript.Syntax.token(43 /* WithKeyword */), TypeScript.Syntax.token(72 /* OpenParenToken */), condition, TypeScript.Syntax.token(73 /* CloseParenToken */), statement, false); + }; + + WithStatementSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + WithStatementSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + WithStatementSyntax.prototype.withWithKeyword = function (withKeyword) { + return this.update(withKeyword, this.openParenToken, this.condition, this.closeParenToken, this.statement); + }; + + WithStatementSyntax.prototype.withOpenParenToken = function (openParenToken) { + return this.update(this.withKeyword, openParenToken, this.condition, this.closeParenToken, this.statement); + }; + + WithStatementSyntax.prototype.withCondition = function (condition) { + return this.update(this.withKeyword, this.openParenToken, condition, this.closeParenToken, this.statement); + }; + + WithStatementSyntax.prototype.withCloseParenToken = function (closeParenToken) { + return this.update(this.withKeyword, this.openParenToken, this.condition, closeParenToken, this.statement); + }; + + WithStatementSyntax.prototype.withStatement = function (statement) { + return this.update(this.withKeyword, this.openParenToken, this.condition, this.closeParenToken, statement); + }; + + WithStatementSyntax.prototype.isTypeScriptSpecific = function () { + if (this.condition.isTypeScriptSpecific()) { + return true; + } + if (this.statement.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return WithStatementSyntax; + })(TypeScript.SyntaxNode); + TypeScript.WithStatementSyntax = WithStatementSyntax; + + var EnumDeclarationSyntax = (function (_super) { + __extends(EnumDeclarationSyntax, _super); + function EnumDeclarationSyntax(modifiers, enumKeyword, identifier, openBraceToken, enumElements, closeBraceToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.modifiers = modifiers; + this.enumKeyword = enumKeyword; + this.identifier = identifier; + this.openBraceToken = openBraceToken; + this.enumElements = enumElements; + this.closeBraceToken = closeBraceToken; + } + EnumDeclarationSyntax.prototype.accept = function (visitor) { + return visitor.visitEnumDeclaration(this); + }; + + EnumDeclarationSyntax.prototype.kind = function () { + return 132 /* EnumDeclaration */; + }; + + EnumDeclarationSyntax.prototype.childCount = function () { + return 6; + }; + + EnumDeclarationSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.modifiers; + case 1: + return this.enumKeyword; + case 2: + return this.identifier; + case 3: + return this.openBraceToken; + case 4: + return this.enumElements; + case 5: + return this.closeBraceToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + EnumDeclarationSyntax.prototype.isModuleElement = function () { + return true; + }; + + EnumDeclarationSyntax.prototype.update = function (modifiers, enumKeyword, identifier, openBraceToken, enumElements, closeBraceToken) { + if (this.modifiers === modifiers && this.enumKeyword === enumKeyword && this.identifier === identifier && this.openBraceToken === openBraceToken && this.enumElements === enumElements && this.closeBraceToken === closeBraceToken) { + return this; + } + + return new EnumDeclarationSyntax(modifiers, enumKeyword, identifier, openBraceToken, enumElements, closeBraceToken, this.parsedInStrictMode()); + }; + + EnumDeclarationSyntax.create = function (enumKeyword, identifier, openBraceToken, closeBraceToken) { + return new EnumDeclarationSyntax(TypeScript.Syntax.emptyList, enumKeyword, identifier, openBraceToken, TypeScript.Syntax.emptySeparatedList, closeBraceToken, false); + }; + + EnumDeclarationSyntax.create1 = function (identifier) { + return new EnumDeclarationSyntax(TypeScript.Syntax.emptyList, TypeScript.Syntax.token(46 /* EnumKeyword */), identifier, TypeScript.Syntax.token(70 /* OpenBraceToken */), TypeScript.Syntax.emptySeparatedList, TypeScript.Syntax.token(71 /* CloseBraceToken */), false); + }; + + EnumDeclarationSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + EnumDeclarationSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + EnumDeclarationSyntax.prototype.withModifiers = function (modifiers) { + return this.update(modifiers, this.enumKeyword, this.identifier, this.openBraceToken, this.enumElements, this.closeBraceToken); + }; + + EnumDeclarationSyntax.prototype.withModifier = function (modifier) { + return this.withModifiers(TypeScript.Syntax.list([modifier])); + }; + + EnumDeclarationSyntax.prototype.withEnumKeyword = function (enumKeyword) { + return this.update(this.modifiers, enumKeyword, this.identifier, this.openBraceToken, this.enumElements, this.closeBraceToken); + }; + + EnumDeclarationSyntax.prototype.withIdentifier = function (identifier) { + return this.update(this.modifiers, this.enumKeyword, identifier, this.openBraceToken, this.enumElements, this.closeBraceToken); + }; + + EnumDeclarationSyntax.prototype.withOpenBraceToken = function (openBraceToken) { + return this.update(this.modifiers, this.enumKeyword, this.identifier, openBraceToken, this.enumElements, this.closeBraceToken); + }; + + EnumDeclarationSyntax.prototype.withEnumElements = function (enumElements) { + return this.update(this.modifiers, this.enumKeyword, this.identifier, this.openBraceToken, enumElements, this.closeBraceToken); + }; + + EnumDeclarationSyntax.prototype.withEnumElement = function (enumElement) { + return this.withEnumElements(TypeScript.Syntax.separatedList([enumElement])); + }; + + EnumDeclarationSyntax.prototype.withCloseBraceToken = function (closeBraceToken) { + return this.update(this.modifiers, this.enumKeyword, this.identifier, this.openBraceToken, this.enumElements, closeBraceToken); + }; + + EnumDeclarationSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return EnumDeclarationSyntax; + })(TypeScript.SyntaxNode); + TypeScript.EnumDeclarationSyntax = EnumDeclarationSyntax; + + var EnumElementSyntax = (function (_super) { + __extends(EnumElementSyntax, _super); + function EnumElementSyntax(propertyName, equalsValueClause, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.propertyName = propertyName; + this.equalsValueClause = equalsValueClause; + } + EnumElementSyntax.prototype.accept = function (visitor) { + return visitor.visitEnumElement(this); + }; + + EnumElementSyntax.prototype.kind = function () { + return 243 /* EnumElement */; + }; + + EnumElementSyntax.prototype.childCount = function () { + return 2; + }; + + EnumElementSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.propertyName; + case 1: + return this.equalsValueClause; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + EnumElementSyntax.prototype.update = function (propertyName, equalsValueClause) { + if (this.propertyName === propertyName && this.equalsValueClause === equalsValueClause) { + return this; + } + + return new EnumElementSyntax(propertyName, equalsValueClause, this.parsedInStrictMode()); + }; + + EnumElementSyntax.create = function (propertyName) { + return new EnumElementSyntax(propertyName, null, false); + }; + + EnumElementSyntax.create1 = function (propertyName) { + return new EnumElementSyntax(propertyName, null, false); + }; + + EnumElementSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + EnumElementSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + EnumElementSyntax.prototype.withPropertyName = function (propertyName) { + return this.update(propertyName, this.equalsValueClause); + }; + + EnumElementSyntax.prototype.withEqualsValueClause = function (equalsValueClause) { + return this.update(this.propertyName, equalsValueClause); + }; + + EnumElementSyntax.prototype.isTypeScriptSpecific = function () { + if (this.equalsValueClause !== null && this.equalsValueClause.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return EnumElementSyntax; + })(TypeScript.SyntaxNode); + TypeScript.EnumElementSyntax = EnumElementSyntax; + + var CastExpressionSyntax = (function (_super) { + __extends(CastExpressionSyntax, _super); + function CastExpressionSyntax(lessThanToken, type, greaterThanToken, expression, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.lessThanToken = lessThanToken; + this.type = type; + this.greaterThanToken = greaterThanToken; + this.expression = expression; + } + CastExpressionSyntax.prototype.accept = function (visitor) { + return visitor.visitCastExpression(this); + }; + + CastExpressionSyntax.prototype.kind = function () { + return 219 /* CastExpression */; + }; + + CastExpressionSyntax.prototype.childCount = function () { + return 4; + }; + + CastExpressionSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.lessThanToken; + case 1: + return this.type; + case 2: + return this.greaterThanToken; + case 3: + return this.expression; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + CastExpressionSyntax.prototype.isUnaryExpression = function () { + return true; + }; + + CastExpressionSyntax.prototype.isExpression = function () { + return true; + }; + + CastExpressionSyntax.prototype.update = function (lessThanToken, type, greaterThanToken, expression) { + if (this.lessThanToken === lessThanToken && this.type === type && this.greaterThanToken === greaterThanToken && this.expression === expression) { + return this; + } + + return new CastExpressionSyntax(lessThanToken, type, greaterThanToken, expression, this.parsedInStrictMode()); + }; + + CastExpressionSyntax.create1 = function (type, expression) { + return new CastExpressionSyntax(TypeScript.Syntax.token(80 /* LessThanToken */), type, TypeScript.Syntax.token(81 /* GreaterThanToken */), expression, false); + }; + + CastExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + CastExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + CastExpressionSyntax.prototype.withLessThanToken = function (lessThanToken) { + return this.update(lessThanToken, this.type, this.greaterThanToken, this.expression); + }; + + CastExpressionSyntax.prototype.withType = function (type) { + return this.update(this.lessThanToken, type, this.greaterThanToken, this.expression); + }; + + CastExpressionSyntax.prototype.withGreaterThanToken = function (greaterThanToken) { + return this.update(this.lessThanToken, this.type, greaterThanToken, this.expression); + }; + + CastExpressionSyntax.prototype.withExpression = function (expression) { + return this.update(this.lessThanToken, this.type, this.greaterThanToken, expression); + }; + + CastExpressionSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return CastExpressionSyntax; + })(TypeScript.SyntaxNode); + TypeScript.CastExpressionSyntax = CastExpressionSyntax; + + var ObjectLiteralExpressionSyntax = (function (_super) { + __extends(ObjectLiteralExpressionSyntax, _super); + function ObjectLiteralExpressionSyntax(openBraceToken, propertyAssignments, closeBraceToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.openBraceToken = openBraceToken; + this.propertyAssignments = propertyAssignments; + this.closeBraceToken = closeBraceToken; + } + ObjectLiteralExpressionSyntax.prototype.accept = function (visitor) { + return visitor.visitObjectLiteralExpression(this); + }; + + ObjectLiteralExpressionSyntax.prototype.kind = function () { + return 214 /* ObjectLiteralExpression */; + }; + + ObjectLiteralExpressionSyntax.prototype.childCount = function () { + return 3; + }; + + ObjectLiteralExpressionSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.openBraceToken; + case 1: + return this.propertyAssignments; + case 2: + return this.closeBraceToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ObjectLiteralExpressionSyntax.prototype.isUnaryExpression = function () { + return true; + }; + + ObjectLiteralExpressionSyntax.prototype.isExpression = function () { + return true; + }; + + ObjectLiteralExpressionSyntax.prototype.update = function (openBraceToken, propertyAssignments, closeBraceToken) { + if (this.openBraceToken === openBraceToken && this.propertyAssignments === propertyAssignments && this.closeBraceToken === closeBraceToken) { + return this; + } + + return new ObjectLiteralExpressionSyntax(openBraceToken, propertyAssignments, closeBraceToken, this.parsedInStrictMode()); + }; + + ObjectLiteralExpressionSyntax.create = function (openBraceToken, closeBraceToken) { + return new ObjectLiteralExpressionSyntax(openBraceToken, TypeScript.Syntax.emptySeparatedList, closeBraceToken, false); + }; + + ObjectLiteralExpressionSyntax.create1 = function () { + return new ObjectLiteralExpressionSyntax(TypeScript.Syntax.token(70 /* OpenBraceToken */), TypeScript.Syntax.emptySeparatedList, TypeScript.Syntax.token(71 /* CloseBraceToken */), false); + }; + + ObjectLiteralExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ObjectLiteralExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ObjectLiteralExpressionSyntax.prototype.withOpenBraceToken = function (openBraceToken) { + return this.update(openBraceToken, this.propertyAssignments, this.closeBraceToken); + }; + + ObjectLiteralExpressionSyntax.prototype.withPropertyAssignments = function (propertyAssignments) { + return this.update(this.openBraceToken, propertyAssignments, this.closeBraceToken); + }; + + ObjectLiteralExpressionSyntax.prototype.withPropertyAssignment = function (propertyAssignment) { + return this.withPropertyAssignments(TypeScript.Syntax.separatedList([propertyAssignment])); + }; + + ObjectLiteralExpressionSyntax.prototype.withCloseBraceToken = function (closeBraceToken) { + return this.update(this.openBraceToken, this.propertyAssignments, closeBraceToken); + }; + + ObjectLiteralExpressionSyntax.prototype.isTypeScriptSpecific = function () { + if (this.propertyAssignments.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return ObjectLiteralExpressionSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ObjectLiteralExpressionSyntax = ObjectLiteralExpressionSyntax; + + var PropertyAssignmentSyntax = (function (_super) { + __extends(PropertyAssignmentSyntax, _super); + function PropertyAssignmentSyntax(propertyName, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.propertyName = propertyName; + } + PropertyAssignmentSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + PropertyAssignmentSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + PropertyAssignmentSyntax.prototype.isTypeScriptSpecific = function () { + return false; + }; + return PropertyAssignmentSyntax; + })(TypeScript.SyntaxNode); + TypeScript.PropertyAssignmentSyntax = PropertyAssignmentSyntax; + + var SimplePropertyAssignmentSyntax = (function (_super) { + __extends(SimplePropertyAssignmentSyntax, _super); + function SimplePropertyAssignmentSyntax(propertyName, colonToken, expression, parsedInStrictMode) { + _super.call(this, propertyName, parsedInStrictMode); + this.colonToken = colonToken; + this.expression = expression; + } + SimplePropertyAssignmentSyntax.prototype.accept = function (visitor) { + return visitor.visitSimplePropertyAssignment(this); + }; + + SimplePropertyAssignmentSyntax.prototype.kind = function () { + return 238 /* SimplePropertyAssignment */; + }; + + SimplePropertyAssignmentSyntax.prototype.childCount = function () { + return 3; + }; + + SimplePropertyAssignmentSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.propertyName; + case 1: + return this.colonToken; + case 2: + return this.expression; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + SimplePropertyAssignmentSyntax.prototype.update = function (propertyName, colonToken, expression) { + if (this.propertyName === propertyName && this.colonToken === colonToken && this.expression === expression) { + return this; + } + + return new SimplePropertyAssignmentSyntax(propertyName, colonToken, expression, this.parsedInStrictMode()); + }; + + SimplePropertyAssignmentSyntax.create1 = function (propertyName, expression) { + return new SimplePropertyAssignmentSyntax(propertyName, TypeScript.Syntax.token(106 /* ColonToken */), expression, false); + }; + + SimplePropertyAssignmentSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + SimplePropertyAssignmentSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + SimplePropertyAssignmentSyntax.prototype.withPropertyName = function (propertyName) { + return this.update(propertyName, this.colonToken, this.expression); + }; + + SimplePropertyAssignmentSyntax.prototype.withColonToken = function (colonToken) { + return this.update(this.propertyName, colonToken, this.expression); + }; + + SimplePropertyAssignmentSyntax.prototype.withExpression = function (expression) { + return this.update(this.propertyName, this.colonToken, expression); + }; + + SimplePropertyAssignmentSyntax.prototype.isTypeScriptSpecific = function () { + if (this.expression.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return SimplePropertyAssignmentSyntax; + })(PropertyAssignmentSyntax); + TypeScript.SimplePropertyAssignmentSyntax = SimplePropertyAssignmentSyntax; + + var FunctionPropertyAssignmentSyntax = (function (_super) { + __extends(FunctionPropertyAssignmentSyntax, _super); + function FunctionPropertyAssignmentSyntax(propertyName, callSignature, block, parsedInStrictMode) { + _super.call(this, propertyName, parsedInStrictMode); + this.callSignature = callSignature; + this.block = block; + } + FunctionPropertyAssignmentSyntax.prototype.accept = function (visitor) { + return visitor.visitFunctionPropertyAssignment(this); + }; + + FunctionPropertyAssignmentSyntax.prototype.kind = function () { + return 241 /* FunctionPropertyAssignment */; + }; + + FunctionPropertyAssignmentSyntax.prototype.childCount = function () { + return 3; + }; + + FunctionPropertyAssignmentSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.propertyName; + case 1: + return this.callSignature; + case 2: + return this.block; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + FunctionPropertyAssignmentSyntax.prototype.update = function (propertyName, callSignature, block) { + if (this.propertyName === propertyName && this.callSignature === callSignature && this.block === block) { + return this; + } + + return new FunctionPropertyAssignmentSyntax(propertyName, callSignature, block, this.parsedInStrictMode()); + }; + + FunctionPropertyAssignmentSyntax.create1 = function (propertyName) { + return new FunctionPropertyAssignmentSyntax(propertyName, CallSignatureSyntax.create1(), BlockSyntax.create1(), false); + }; + + FunctionPropertyAssignmentSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + FunctionPropertyAssignmentSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + FunctionPropertyAssignmentSyntax.prototype.withPropertyName = function (propertyName) { + return this.update(propertyName, this.callSignature, this.block); + }; + + FunctionPropertyAssignmentSyntax.prototype.withCallSignature = function (callSignature) { + return this.update(this.propertyName, callSignature, this.block); + }; + + FunctionPropertyAssignmentSyntax.prototype.withBlock = function (block) { + return this.update(this.propertyName, this.callSignature, block); + }; + + FunctionPropertyAssignmentSyntax.prototype.isTypeScriptSpecific = function () { + if (this.callSignature.isTypeScriptSpecific()) { + return true; + } + if (this.block.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return FunctionPropertyAssignmentSyntax; + })(PropertyAssignmentSyntax); + TypeScript.FunctionPropertyAssignmentSyntax = FunctionPropertyAssignmentSyntax; + + var AccessorPropertyAssignmentSyntax = (function (_super) { + __extends(AccessorPropertyAssignmentSyntax, _super); + function AccessorPropertyAssignmentSyntax(propertyName, openParenToken, closeParenToken, block, parsedInStrictMode) { + _super.call(this, propertyName, parsedInStrictMode); + this.openParenToken = openParenToken; + this.closeParenToken = closeParenToken; + this.block = block; + } + AccessorPropertyAssignmentSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + AccessorPropertyAssignmentSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + AccessorPropertyAssignmentSyntax.prototype.isTypeScriptSpecific = function () { + return false; + }; + return AccessorPropertyAssignmentSyntax; + })(PropertyAssignmentSyntax); + TypeScript.AccessorPropertyAssignmentSyntax = AccessorPropertyAssignmentSyntax; + + var GetAccessorPropertyAssignmentSyntax = (function (_super) { + __extends(GetAccessorPropertyAssignmentSyntax, _super); + function GetAccessorPropertyAssignmentSyntax(getKeyword, propertyName, openParenToken, closeParenToken, typeAnnotation, block, parsedInStrictMode) { + _super.call(this, propertyName, openParenToken, closeParenToken, block, parsedInStrictMode); + this.getKeyword = getKeyword; + this.typeAnnotation = typeAnnotation; + } + GetAccessorPropertyAssignmentSyntax.prototype.accept = function (visitor) { + return visitor.visitGetAccessorPropertyAssignment(this); + }; + + GetAccessorPropertyAssignmentSyntax.prototype.kind = function () { + return 239 /* GetAccessorPropertyAssignment */; + }; + + GetAccessorPropertyAssignmentSyntax.prototype.childCount = function () { + return 6; + }; + + GetAccessorPropertyAssignmentSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.getKeyword; + case 1: + return this.propertyName; + case 2: + return this.openParenToken; + case 3: + return this.closeParenToken; + case 4: + return this.typeAnnotation; + case 5: + return this.block; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + GetAccessorPropertyAssignmentSyntax.prototype.update = function (getKeyword, propertyName, openParenToken, closeParenToken, typeAnnotation, block) { + if (this.getKeyword === getKeyword && this.propertyName === propertyName && this.openParenToken === openParenToken && this.closeParenToken === closeParenToken && this.typeAnnotation === typeAnnotation && this.block === block) { + return this; + } + + return new GetAccessorPropertyAssignmentSyntax(getKeyword, propertyName, openParenToken, closeParenToken, typeAnnotation, block, this.parsedInStrictMode()); + }; + + GetAccessorPropertyAssignmentSyntax.create = function (getKeyword, propertyName, openParenToken, closeParenToken, block) { + return new GetAccessorPropertyAssignmentSyntax(getKeyword, propertyName, openParenToken, closeParenToken, null, block, false); + }; + + GetAccessorPropertyAssignmentSyntax.create1 = function (propertyName) { + return new GetAccessorPropertyAssignmentSyntax(TypeScript.Syntax.token(64 /* GetKeyword */), propertyName, TypeScript.Syntax.token(72 /* OpenParenToken */), TypeScript.Syntax.token(73 /* CloseParenToken */), null, BlockSyntax.create1(), false); + }; + + GetAccessorPropertyAssignmentSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + GetAccessorPropertyAssignmentSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + GetAccessorPropertyAssignmentSyntax.prototype.withGetKeyword = function (getKeyword) { + return this.update(getKeyword, this.propertyName, this.openParenToken, this.closeParenToken, this.typeAnnotation, this.block); + }; + + GetAccessorPropertyAssignmentSyntax.prototype.withPropertyName = function (propertyName) { + return this.update(this.getKeyword, propertyName, this.openParenToken, this.closeParenToken, this.typeAnnotation, this.block); + }; + + GetAccessorPropertyAssignmentSyntax.prototype.withOpenParenToken = function (openParenToken) { + return this.update(this.getKeyword, this.propertyName, openParenToken, this.closeParenToken, this.typeAnnotation, this.block); + }; + + GetAccessorPropertyAssignmentSyntax.prototype.withCloseParenToken = function (closeParenToken) { + return this.update(this.getKeyword, this.propertyName, this.openParenToken, closeParenToken, this.typeAnnotation, this.block); + }; + + GetAccessorPropertyAssignmentSyntax.prototype.withTypeAnnotation = function (typeAnnotation) { + return this.update(this.getKeyword, this.propertyName, this.openParenToken, this.closeParenToken, typeAnnotation, this.block); + }; + + GetAccessorPropertyAssignmentSyntax.prototype.withBlock = function (block) { + return this.update(this.getKeyword, this.propertyName, this.openParenToken, this.closeParenToken, this.typeAnnotation, block); + }; + + GetAccessorPropertyAssignmentSyntax.prototype.isTypeScriptSpecific = function () { + if (this.typeAnnotation !== null && this.typeAnnotation.isTypeScriptSpecific()) { + return true; + } + if (this.block.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return GetAccessorPropertyAssignmentSyntax; + })(AccessorPropertyAssignmentSyntax); + TypeScript.GetAccessorPropertyAssignmentSyntax = GetAccessorPropertyAssignmentSyntax; + + var SetAccessorPropertyAssignmentSyntax = (function (_super) { + __extends(SetAccessorPropertyAssignmentSyntax, _super); + function SetAccessorPropertyAssignmentSyntax(setKeyword, propertyName, openParenToken, parameter, closeParenToken, block, parsedInStrictMode) { + _super.call(this, propertyName, openParenToken, closeParenToken, block, parsedInStrictMode); + this.setKeyword = setKeyword; + this.parameter = parameter; + } + SetAccessorPropertyAssignmentSyntax.prototype.accept = function (visitor) { + return visitor.visitSetAccessorPropertyAssignment(this); + }; + + SetAccessorPropertyAssignmentSyntax.prototype.kind = function () { + return 240 /* SetAccessorPropertyAssignment */; + }; + + SetAccessorPropertyAssignmentSyntax.prototype.childCount = function () { + return 6; + }; + + SetAccessorPropertyAssignmentSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.setKeyword; + case 1: + return this.propertyName; + case 2: + return this.openParenToken; + case 3: + return this.parameter; + case 4: + return this.closeParenToken; + case 5: + return this.block; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + SetAccessorPropertyAssignmentSyntax.prototype.update = function (setKeyword, propertyName, openParenToken, parameter, closeParenToken, block) { + if (this.setKeyword === setKeyword && this.propertyName === propertyName && this.openParenToken === openParenToken && this.parameter === parameter && this.closeParenToken === closeParenToken && this.block === block) { + return this; + } + + return new SetAccessorPropertyAssignmentSyntax(setKeyword, propertyName, openParenToken, parameter, closeParenToken, block, this.parsedInStrictMode()); + }; + + SetAccessorPropertyAssignmentSyntax.create1 = function (propertyName, parameter) { + return new SetAccessorPropertyAssignmentSyntax(TypeScript.Syntax.token(68 /* SetKeyword */), propertyName, TypeScript.Syntax.token(72 /* OpenParenToken */), parameter, TypeScript.Syntax.token(73 /* CloseParenToken */), BlockSyntax.create1(), false); + }; + + SetAccessorPropertyAssignmentSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + SetAccessorPropertyAssignmentSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + SetAccessorPropertyAssignmentSyntax.prototype.withSetKeyword = function (setKeyword) { + return this.update(setKeyword, this.propertyName, this.openParenToken, this.parameter, this.closeParenToken, this.block); + }; + + SetAccessorPropertyAssignmentSyntax.prototype.withPropertyName = function (propertyName) { + return this.update(this.setKeyword, propertyName, this.openParenToken, this.parameter, this.closeParenToken, this.block); + }; + + SetAccessorPropertyAssignmentSyntax.prototype.withOpenParenToken = function (openParenToken) { + return this.update(this.setKeyword, this.propertyName, openParenToken, this.parameter, this.closeParenToken, this.block); + }; + + SetAccessorPropertyAssignmentSyntax.prototype.withParameter = function (parameter) { + return this.update(this.setKeyword, this.propertyName, this.openParenToken, parameter, this.closeParenToken, this.block); + }; + + SetAccessorPropertyAssignmentSyntax.prototype.withCloseParenToken = function (closeParenToken) { + return this.update(this.setKeyword, this.propertyName, this.openParenToken, this.parameter, closeParenToken, this.block); + }; + + SetAccessorPropertyAssignmentSyntax.prototype.withBlock = function (block) { + return this.update(this.setKeyword, this.propertyName, this.openParenToken, this.parameter, this.closeParenToken, block); + }; + + SetAccessorPropertyAssignmentSyntax.prototype.isTypeScriptSpecific = function () { + if (this.parameter.isTypeScriptSpecific()) { + return true; + } + if (this.block.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return SetAccessorPropertyAssignmentSyntax; + })(AccessorPropertyAssignmentSyntax); + TypeScript.SetAccessorPropertyAssignmentSyntax = SetAccessorPropertyAssignmentSyntax; + + var FunctionExpressionSyntax = (function (_super) { + __extends(FunctionExpressionSyntax, _super); + function FunctionExpressionSyntax(functionKeyword, identifier, callSignature, block, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.functionKeyword = functionKeyword; + this.identifier = identifier; + this.callSignature = callSignature; + this.block = block; + } + FunctionExpressionSyntax.prototype.accept = function (visitor) { + return visitor.visitFunctionExpression(this); + }; + + FunctionExpressionSyntax.prototype.kind = function () { + return 221 /* FunctionExpression */; + }; + + FunctionExpressionSyntax.prototype.childCount = function () { + return 4; + }; + + FunctionExpressionSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.functionKeyword; + case 1: + return this.identifier; + case 2: + return this.callSignature; + case 3: + return this.block; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + FunctionExpressionSyntax.prototype.isUnaryExpression = function () { + return true; + }; + + FunctionExpressionSyntax.prototype.isExpression = function () { + return true; + }; + + FunctionExpressionSyntax.prototype.update = function (functionKeyword, identifier, callSignature, block) { + if (this.functionKeyword === functionKeyword && this.identifier === identifier && this.callSignature === callSignature && this.block === block) { + return this; + } + + return new FunctionExpressionSyntax(functionKeyword, identifier, callSignature, block, this.parsedInStrictMode()); + }; + + FunctionExpressionSyntax.create = function (functionKeyword, callSignature, block) { + return new FunctionExpressionSyntax(functionKeyword, null, callSignature, block, false); + }; + + FunctionExpressionSyntax.create1 = function () { + return new FunctionExpressionSyntax(TypeScript.Syntax.token(27 /* FunctionKeyword */), null, CallSignatureSyntax.create1(), BlockSyntax.create1(), false); + }; + + FunctionExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + FunctionExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + FunctionExpressionSyntax.prototype.withFunctionKeyword = function (functionKeyword) { + return this.update(functionKeyword, this.identifier, this.callSignature, this.block); + }; + + FunctionExpressionSyntax.prototype.withIdentifier = function (identifier) { + return this.update(this.functionKeyword, identifier, this.callSignature, this.block); + }; + + FunctionExpressionSyntax.prototype.withCallSignature = function (callSignature) { + return this.update(this.functionKeyword, this.identifier, callSignature, this.block); + }; + + FunctionExpressionSyntax.prototype.withBlock = function (block) { + return this.update(this.functionKeyword, this.identifier, this.callSignature, block); + }; + + FunctionExpressionSyntax.prototype.isTypeScriptSpecific = function () { + if (this.callSignature.isTypeScriptSpecific()) { + return true; + } + if (this.block.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return FunctionExpressionSyntax; + })(TypeScript.SyntaxNode); + TypeScript.FunctionExpressionSyntax = FunctionExpressionSyntax; + + var EmptyStatementSyntax = (function (_super) { + __extends(EmptyStatementSyntax, _super); + function EmptyStatementSyntax(semicolonToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.semicolonToken = semicolonToken; + } + EmptyStatementSyntax.prototype.accept = function (visitor) { + return visitor.visitEmptyStatement(this); + }; + + EmptyStatementSyntax.prototype.kind = function () { + return 155 /* EmptyStatement */; + }; + + EmptyStatementSyntax.prototype.childCount = function () { + return 1; + }; + + EmptyStatementSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.semicolonToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + EmptyStatementSyntax.prototype.isStatement = function () { + return true; + }; + + EmptyStatementSyntax.prototype.isModuleElement = function () { + return true; + }; + + EmptyStatementSyntax.prototype.update = function (semicolonToken) { + if (this.semicolonToken === semicolonToken) { + return this; + } + + return new EmptyStatementSyntax(semicolonToken, this.parsedInStrictMode()); + }; + + EmptyStatementSyntax.create1 = function () { + return new EmptyStatementSyntax(TypeScript.Syntax.token(78 /* SemicolonToken */), false); + }; + + EmptyStatementSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + EmptyStatementSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + EmptyStatementSyntax.prototype.withSemicolonToken = function (semicolonToken) { + return this.update(semicolonToken); + }; + + EmptyStatementSyntax.prototype.isTypeScriptSpecific = function () { + return false; + }; + return EmptyStatementSyntax; + })(TypeScript.SyntaxNode); + TypeScript.EmptyStatementSyntax = EmptyStatementSyntax; + + var TryStatementSyntax = (function (_super) { + __extends(TryStatementSyntax, _super); + function TryStatementSyntax(tryKeyword, block, catchClause, finallyClause, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.tryKeyword = tryKeyword; + this.block = block; + this.catchClause = catchClause; + this.finallyClause = finallyClause; + } + TryStatementSyntax.prototype.accept = function (visitor) { + return visitor.visitTryStatement(this); + }; + + TryStatementSyntax.prototype.kind = function () { + return 158 /* TryStatement */; + }; + + TryStatementSyntax.prototype.childCount = function () { + return 4; + }; + + TryStatementSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.tryKeyword; + case 1: + return this.block; + case 2: + return this.catchClause; + case 3: + return this.finallyClause; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + TryStatementSyntax.prototype.isStatement = function () { + return true; + }; + + TryStatementSyntax.prototype.isModuleElement = function () { + return true; + }; + + TryStatementSyntax.prototype.update = function (tryKeyword, block, catchClause, finallyClause) { + if (this.tryKeyword === tryKeyword && this.block === block && this.catchClause === catchClause && this.finallyClause === finallyClause) { + return this; + } + + return new TryStatementSyntax(tryKeyword, block, catchClause, finallyClause, this.parsedInStrictMode()); + }; + + TryStatementSyntax.create = function (tryKeyword, block) { + return new TryStatementSyntax(tryKeyword, block, null, null, false); + }; + + TryStatementSyntax.create1 = function () { + return new TryStatementSyntax(TypeScript.Syntax.token(38 /* TryKeyword */), BlockSyntax.create1(), null, null, false); + }; + + TryStatementSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + TryStatementSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + TryStatementSyntax.prototype.withTryKeyword = function (tryKeyword) { + return this.update(tryKeyword, this.block, this.catchClause, this.finallyClause); + }; + + TryStatementSyntax.prototype.withBlock = function (block) { + return this.update(this.tryKeyword, block, this.catchClause, this.finallyClause); + }; + + TryStatementSyntax.prototype.withCatchClause = function (catchClause) { + return this.update(this.tryKeyword, this.block, catchClause, this.finallyClause); + }; + + TryStatementSyntax.prototype.withFinallyClause = function (finallyClause) { + return this.update(this.tryKeyword, this.block, this.catchClause, finallyClause); + }; + + TryStatementSyntax.prototype.isTypeScriptSpecific = function () { + if (this.block.isTypeScriptSpecific()) { + return true; + } + if (this.catchClause !== null && this.catchClause.isTypeScriptSpecific()) { + return true; + } + if (this.finallyClause !== null && this.finallyClause.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return TryStatementSyntax; + })(TypeScript.SyntaxNode); + TypeScript.TryStatementSyntax = TryStatementSyntax; + + var CatchClauseSyntax = (function (_super) { + __extends(CatchClauseSyntax, _super); + function CatchClauseSyntax(catchKeyword, openParenToken, identifier, typeAnnotation, closeParenToken, block, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.catchKeyword = catchKeyword; + this.openParenToken = openParenToken; + this.identifier = identifier; + this.typeAnnotation = typeAnnotation; + this.closeParenToken = closeParenToken; + this.block = block; + } + CatchClauseSyntax.prototype.accept = function (visitor) { + return visitor.visitCatchClause(this); + }; + + CatchClauseSyntax.prototype.kind = function () { + return 234 /* CatchClause */; + }; + + CatchClauseSyntax.prototype.childCount = function () { + return 6; + }; + + CatchClauseSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.catchKeyword; + case 1: + return this.openParenToken; + case 2: + return this.identifier; + case 3: + return this.typeAnnotation; + case 4: + return this.closeParenToken; + case 5: + return this.block; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + CatchClauseSyntax.prototype.update = function (catchKeyword, openParenToken, identifier, typeAnnotation, closeParenToken, block) { + if (this.catchKeyword === catchKeyword && this.openParenToken === openParenToken && this.identifier === identifier && this.typeAnnotation === typeAnnotation && this.closeParenToken === closeParenToken && this.block === block) { + return this; + } + + return new CatchClauseSyntax(catchKeyword, openParenToken, identifier, typeAnnotation, closeParenToken, block, this.parsedInStrictMode()); + }; + + CatchClauseSyntax.create = function (catchKeyword, openParenToken, identifier, closeParenToken, block) { + return new CatchClauseSyntax(catchKeyword, openParenToken, identifier, null, closeParenToken, block, false); + }; + + CatchClauseSyntax.create1 = function (identifier) { + return new CatchClauseSyntax(TypeScript.Syntax.token(17 /* CatchKeyword */), TypeScript.Syntax.token(72 /* OpenParenToken */), identifier, null, TypeScript.Syntax.token(73 /* CloseParenToken */), BlockSyntax.create1(), false); + }; + + CatchClauseSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + CatchClauseSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + CatchClauseSyntax.prototype.withCatchKeyword = function (catchKeyword) { + return this.update(catchKeyword, this.openParenToken, this.identifier, this.typeAnnotation, this.closeParenToken, this.block); + }; + + CatchClauseSyntax.prototype.withOpenParenToken = function (openParenToken) { + return this.update(this.catchKeyword, openParenToken, this.identifier, this.typeAnnotation, this.closeParenToken, this.block); + }; + + CatchClauseSyntax.prototype.withIdentifier = function (identifier) { + return this.update(this.catchKeyword, this.openParenToken, identifier, this.typeAnnotation, this.closeParenToken, this.block); + }; + + CatchClauseSyntax.prototype.withTypeAnnotation = function (typeAnnotation) { + return this.update(this.catchKeyword, this.openParenToken, this.identifier, typeAnnotation, this.closeParenToken, this.block); + }; + + CatchClauseSyntax.prototype.withCloseParenToken = function (closeParenToken) { + return this.update(this.catchKeyword, this.openParenToken, this.identifier, this.typeAnnotation, closeParenToken, this.block); + }; + + CatchClauseSyntax.prototype.withBlock = function (block) { + return this.update(this.catchKeyword, this.openParenToken, this.identifier, this.typeAnnotation, this.closeParenToken, block); + }; + + CatchClauseSyntax.prototype.isTypeScriptSpecific = function () { + if (this.typeAnnotation !== null && this.typeAnnotation.isTypeScriptSpecific()) { + return true; + } + if (this.block.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return CatchClauseSyntax; + })(TypeScript.SyntaxNode); + TypeScript.CatchClauseSyntax = CatchClauseSyntax; + + var FinallyClauseSyntax = (function (_super) { + __extends(FinallyClauseSyntax, _super); + function FinallyClauseSyntax(finallyKeyword, block, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.finallyKeyword = finallyKeyword; + this.block = block; + } + FinallyClauseSyntax.prototype.accept = function (visitor) { + return visitor.visitFinallyClause(this); + }; + + FinallyClauseSyntax.prototype.kind = function () { + return 235 /* FinallyClause */; + }; + + FinallyClauseSyntax.prototype.childCount = function () { + return 2; + }; + + FinallyClauseSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.finallyKeyword; + case 1: + return this.block; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + FinallyClauseSyntax.prototype.update = function (finallyKeyword, block) { + if (this.finallyKeyword === finallyKeyword && this.block === block) { + return this; + } + + return new FinallyClauseSyntax(finallyKeyword, block, this.parsedInStrictMode()); + }; + + FinallyClauseSyntax.create1 = function () { + return new FinallyClauseSyntax(TypeScript.Syntax.token(25 /* FinallyKeyword */), BlockSyntax.create1(), false); + }; + + FinallyClauseSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + FinallyClauseSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + FinallyClauseSyntax.prototype.withFinallyKeyword = function (finallyKeyword) { + return this.update(finallyKeyword, this.block); + }; + + FinallyClauseSyntax.prototype.withBlock = function (block) { + return this.update(this.finallyKeyword, block); + }; + + FinallyClauseSyntax.prototype.isTypeScriptSpecific = function () { + if (this.block.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return FinallyClauseSyntax; + })(TypeScript.SyntaxNode); + TypeScript.FinallyClauseSyntax = FinallyClauseSyntax; + + var LabeledStatementSyntax = (function (_super) { + __extends(LabeledStatementSyntax, _super); + function LabeledStatementSyntax(identifier, colonToken, statement, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.identifier = identifier; + this.colonToken = colonToken; + this.statement = statement; + } + LabeledStatementSyntax.prototype.accept = function (visitor) { + return visitor.visitLabeledStatement(this); + }; + + LabeledStatementSyntax.prototype.kind = function () { + return 159 /* LabeledStatement */; + }; + + LabeledStatementSyntax.prototype.childCount = function () { + return 3; + }; + + LabeledStatementSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.identifier; + case 1: + return this.colonToken; + case 2: + return this.statement; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + LabeledStatementSyntax.prototype.isStatement = function () { + return true; + }; + + LabeledStatementSyntax.prototype.isModuleElement = function () { + return true; + }; + + LabeledStatementSyntax.prototype.update = function (identifier, colonToken, statement) { + if (this.identifier === identifier && this.colonToken === colonToken && this.statement === statement) { + return this; + } + + return new LabeledStatementSyntax(identifier, colonToken, statement, this.parsedInStrictMode()); + }; + + LabeledStatementSyntax.create1 = function (identifier, statement) { + return new LabeledStatementSyntax(identifier, TypeScript.Syntax.token(106 /* ColonToken */), statement, false); + }; + + LabeledStatementSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + LabeledStatementSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + LabeledStatementSyntax.prototype.withIdentifier = function (identifier) { + return this.update(identifier, this.colonToken, this.statement); + }; + + LabeledStatementSyntax.prototype.withColonToken = function (colonToken) { + return this.update(this.identifier, colonToken, this.statement); + }; + + LabeledStatementSyntax.prototype.withStatement = function (statement) { + return this.update(this.identifier, this.colonToken, statement); + }; + + LabeledStatementSyntax.prototype.isTypeScriptSpecific = function () { + if (this.statement.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return LabeledStatementSyntax; + })(TypeScript.SyntaxNode); + TypeScript.LabeledStatementSyntax = LabeledStatementSyntax; + + var DoStatementSyntax = (function (_super) { + __extends(DoStatementSyntax, _super); + function DoStatementSyntax(doKeyword, statement, whileKeyword, openParenToken, condition, closeParenToken, semicolonToken, parsedInStrictMode) { + _super.call(this, openParenToken, closeParenToken, statement, parsedInStrictMode); + this.doKeyword = doKeyword; + this.whileKeyword = whileKeyword; + this.condition = condition; + this.semicolonToken = semicolonToken; + } + DoStatementSyntax.prototype.accept = function (visitor) { + return visitor.visitDoStatement(this); + }; + + DoStatementSyntax.prototype.kind = function () { + return 160 /* DoStatement */; + }; + + DoStatementSyntax.prototype.childCount = function () { + return 7; + }; + + DoStatementSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.doKeyword; + case 1: + return this.statement; + case 2: + return this.whileKeyword; + case 3: + return this.openParenToken; + case 4: + return this.condition; + case 5: + return this.closeParenToken; + case 6: + return this.semicolonToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + DoStatementSyntax.prototype.update = function (doKeyword, statement, whileKeyword, openParenToken, condition, closeParenToken, semicolonToken) { + if (this.doKeyword === doKeyword && this.statement === statement && this.whileKeyword === whileKeyword && this.openParenToken === openParenToken && this.condition === condition && this.closeParenToken === closeParenToken && this.semicolonToken === semicolonToken) { + return this; + } + + return new DoStatementSyntax(doKeyword, statement, whileKeyword, openParenToken, condition, closeParenToken, semicolonToken, this.parsedInStrictMode()); + }; + + DoStatementSyntax.create1 = function (statement, condition) { + return new DoStatementSyntax(TypeScript.Syntax.token(22 /* DoKeyword */), statement, TypeScript.Syntax.token(42 /* WhileKeyword */), TypeScript.Syntax.token(72 /* OpenParenToken */), condition, TypeScript.Syntax.token(73 /* CloseParenToken */), TypeScript.Syntax.token(78 /* SemicolonToken */), false); + }; + + DoStatementSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + DoStatementSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + DoStatementSyntax.prototype.withDoKeyword = function (doKeyword) { + return this.update(doKeyword, this.statement, this.whileKeyword, this.openParenToken, this.condition, this.closeParenToken, this.semicolonToken); + }; + + DoStatementSyntax.prototype.withStatement = function (statement) { + return this.update(this.doKeyword, statement, this.whileKeyword, this.openParenToken, this.condition, this.closeParenToken, this.semicolonToken); + }; + + DoStatementSyntax.prototype.withWhileKeyword = function (whileKeyword) { + return this.update(this.doKeyword, this.statement, whileKeyword, this.openParenToken, this.condition, this.closeParenToken, this.semicolonToken); + }; + + DoStatementSyntax.prototype.withOpenParenToken = function (openParenToken) { + return this.update(this.doKeyword, this.statement, this.whileKeyword, openParenToken, this.condition, this.closeParenToken, this.semicolonToken); + }; + + DoStatementSyntax.prototype.withCondition = function (condition) { + return this.update(this.doKeyword, this.statement, this.whileKeyword, this.openParenToken, condition, this.closeParenToken, this.semicolonToken); + }; + + DoStatementSyntax.prototype.withCloseParenToken = function (closeParenToken) { + return this.update(this.doKeyword, this.statement, this.whileKeyword, this.openParenToken, this.condition, closeParenToken, this.semicolonToken); + }; + + DoStatementSyntax.prototype.withSemicolonToken = function (semicolonToken) { + return this.update(this.doKeyword, this.statement, this.whileKeyword, this.openParenToken, this.condition, this.closeParenToken, semicolonToken); + }; + + DoStatementSyntax.prototype.isTypeScriptSpecific = function () { + if (this.statement.isTypeScriptSpecific()) { + return true; + } + if (this.condition.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return DoStatementSyntax; + })(IterationStatementSyntax); + TypeScript.DoStatementSyntax = DoStatementSyntax; + + var TypeOfExpressionSyntax = (function (_super) { + __extends(TypeOfExpressionSyntax, _super); + function TypeOfExpressionSyntax(typeOfKeyword, expression, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.typeOfKeyword = typeOfKeyword; + this.expression = expression; + } + TypeOfExpressionSyntax.prototype.accept = function (visitor) { + return visitor.visitTypeOfExpression(this); + }; + + TypeOfExpressionSyntax.prototype.kind = function () { + return 170 /* TypeOfExpression */; + }; + + TypeOfExpressionSyntax.prototype.childCount = function () { + return 2; + }; + + TypeOfExpressionSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.typeOfKeyword; + case 1: + return this.expression; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + TypeOfExpressionSyntax.prototype.isUnaryExpression = function () { + return true; + }; + + TypeOfExpressionSyntax.prototype.isExpression = function () { + return true; + }; + + TypeOfExpressionSyntax.prototype.update = function (typeOfKeyword, expression) { + if (this.typeOfKeyword === typeOfKeyword && this.expression === expression) { + return this; + } + + return new TypeOfExpressionSyntax(typeOfKeyword, expression, this.parsedInStrictMode()); + }; + + TypeOfExpressionSyntax.create1 = function (expression) { + return new TypeOfExpressionSyntax(TypeScript.Syntax.token(39 /* TypeOfKeyword */), expression, false); + }; + + TypeOfExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + TypeOfExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + TypeOfExpressionSyntax.prototype.withTypeOfKeyword = function (typeOfKeyword) { + return this.update(typeOfKeyword, this.expression); + }; + + TypeOfExpressionSyntax.prototype.withExpression = function (expression) { + return this.update(this.typeOfKeyword, expression); + }; + + TypeOfExpressionSyntax.prototype.isTypeScriptSpecific = function () { + if (this.expression.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return TypeOfExpressionSyntax; + })(TypeScript.SyntaxNode); + TypeScript.TypeOfExpressionSyntax = TypeOfExpressionSyntax; + + var DeleteExpressionSyntax = (function (_super) { + __extends(DeleteExpressionSyntax, _super); + function DeleteExpressionSyntax(deleteKeyword, expression, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.deleteKeyword = deleteKeyword; + this.expression = expression; + } + DeleteExpressionSyntax.prototype.accept = function (visitor) { + return visitor.visitDeleteExpression(this); + }; + + DeleteExpressionSyntax.prototype.kind = function () { + return 169 /* DeleteExpression */; + }; + + DeleteExpressionSyntax.prototype.childCount = function () { + return 2; + }; + + DeleteExpressionSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.deleteKeyword; + case 1: + return this.expression; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + DeleteExpressionSyntax.prototype.isUnaryExpression = function () { + return true; + }; + + DeleteExpressionSyntax.prototype.isExpression = function () { + return true; + }; + + DeleteExpressionSyntax.prototype.update = function (deleteKeyword, expression) { + if (this.deleteKeyword === deleteKeyword && this.expression === expression) { + return this; + } + + return new DeleteExpressionSyntax(deleteKeyword, expression, this.parsedInStrictMode()); + }; + + DeleteExpressionSyntax.create1 = function (expression) { + return new DeleteExpressionSyntax(TypeScript.Syntax.token(21 /* DeleteKeyword */), expression, false); + }; + + DeleteExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + DeleteExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + DeleteExpressionSyntax.prototype.withDeleteKeyword = function (deleteKeyword) { + return this.update(deleteKeyword, this.expression); + }; + + DeleteExpressionSyntax.prototype.withExpression = function (expression) { + return this.update(this.deleteKeyword, expression); + }; + + DeleteExpressionSyntax.prototype.isTypeScriptSpecific = function () { + if (this.expression.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return DeleteExpressionSyntax; + })(TypeScript.SyntaxNode); + TypeScript.DeleteExpressionSyntax = DeleteExpressionSyntax; + + var VoidExpressionSyntax = (function (_super) { + __extends(VoidExpressionSyntax, _super); + function VoidExpressionSyntax(voidKeyword, expression, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.voidKeyword = voidKeyword; + this.expression = expression; + } + VoidExpressionSyntax.prototype.accept = function (visitor) { + return visitor.visitVoidExpression(this); + }; + + VoidExpressionSyntax.prototype.kind = function () { + return 171 /* VoidExpression */; + }; + + VoidExpressionSyntax.prototype.childCount = function () { + return 2; + }; + + VoidExpressionSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.voidKeyword; + case 1: + return this.expression; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + VoidExpressionSyntax.prototype.isUnaryExpression = function () { + return true; + }; + + VoidExpressionSyntax.prototype.isExpression = function () { + return true; + }; + + VoidExpressionSyntax.prototype.update = function (voidKeyword, expression) { + if (this.voidKeyword === voidKeyword && this.expression === expression) { + return this; + } + + return new VoidExpressionSyntax(voidKeyword, expression, this.parsedInStrictMode()); + }; + + VoidExpressionSyntax.create1 = function (expression) { + return new VoidExpressionSyntax(TypeScript.Syntax.token(41 /* VoidKeyword */), expression, false); + }; + + VoidExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + VoidExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + VoidExpressionSyntax.prototype.withVoidKeyword = function (voidKeyword) { + return this.update(voidKeyword, this.expression); + }; + + VoidExpressionSyntax.prototype.withExpression = function (expression) { + return this.update(this.voidKeyword, expression); + }; + + VoidExpressionSyntax.prototype.isTypeScriptSpecific = function () { + if (this.expression.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return VoidExpressionSyntax; + })(TypeScript.SyntaxNode); + TypeScript.VoidExpressionSyntax = VoidExpressionSyntax; + + var DebuggerStatementSyntax = (function (_super) { + __extends(DebuggerStatementSyntax, _super); + function DebuggerStatementSyntax(debuggerKeyword, semicolonToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.debuggerKeyword = debuggerKeyword; + this.semicolonToken = semicolonToken; + } + DebuggerStatementSyntax.prototype.accept = function (visitor) { + return visitor.visitDebuggerStatement(this); + }; + + DebuggerStatementSyntax.prototype.kind = function () { + return 161 /* DebuggerStatement */; + }; + + DebuggerStatementSyntax.prototype.childCount = function () { + return 2; + }; + + DebuggerStatementSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.debuggerKeyword; + case 1: + return this.semicolonToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + DebuggerStatementSyntax.prototype.isStatement = function () { + return true; + }; + + DebuggerStatementSyntax.prototype.isModuleElement = function () { + return true; + }; + + DebuggerStatementSyntax.prototype.update = function (debuggerKeyword, semicolonToken) { + if (this.debuggerKeyword === debuggerKeyword && this.semicolonToken === semicolonToken) { + return this; + } + + return new DebuggerStatementSyntax(debuggerKeyword, semicolonToken, this.parsedInStrictMode()); + }; + + DebuggerStatementSyntax.create1 = function () { + return new DebuggerStatementSyntax(TypeScript.Syntax.token(19 /* DebuggerKeyword */), TypeScript.Syntax.token(78 /* SemicolonToken */), false); + }; + + DebuggerStatementSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + DebuggerStatementSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + DebuggerStatementSyntax.prototype.withDebuggerKeyword = function (debuggerKeyword) { + return this.update(debuggerKeyword, this.semicolonToken); + }; + + DebuggerStatementSyntax.prototype.withSemicolonToken = function (semicolonToken) { + return this.update(this.debuggerKeyword, semicolonToken); + }; + + DebuggerStatementSyntax.prototype.isTypeScriptSpecific = function () { + return false; + }; + return DebuggerStatementSyntax; + })(TypeScript.SyntaxNode); + TypeScript.DebuggerStatementSyntax = DebuggerStatementSyntax; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var SyntaxRewriter = (function () { + function SyntaxRewriter() { + } + SyntaxRewriter.prototype.visitToken = function (token) { + return token; + }; + + SyntaxRewriter.prototype.visitNode = function (node) { + return node.accept(this); + }; + + SyntaxRewriter.prototype.visitNodeOrToken = function (node) { + return node.isToken() ? this.visitToken(node) : this.visitNode(node); + }; + + SyntaxRewriter.prototype.visitList = function (list) { + var newItems = null; + + for (var i = 0, n = list.childCount(); i < n; i++) { + var item = list.childAt(i); + var newItem = this.visitNodeOrToken(item); + + if (item !== newItem && newItems === null) { + newItems = []; + for (var j = 0; j < i; j++) { + newItems.push(list.childAt(j)); + } + } + + if (newItems) { + newItems.push(newItem); + } + } + + return newItems === null ? list : TypeScript.Syntax.list(newItems); + }; + + SyntaxRewriter.prototype.visitSeparatedList = function (list) { + var newItems = null; + + for (var i = 0, n = list.childCount(); i < n; i++) { + var item = list.childAt(i); + var newItem = item.isToken() ? this.visitToken(item) : this.visitNode(item); + + if (item !== newItem && newItems === null) { + newItems = []; + for (var j = 0; j < i; j++) { + newItems.push(list.childAt(j)); + } + } + + if (newItems) { + newItems.push(newItem); + } + } + + return newItems === null ? list : TypeScript.Syntax.separatedList(newItems); + }; + + SyntaxRewriter.prototype.visitSourceUnit = function (node) { + return node.update(this.visitList(node.moduleElements), this.visitToken(node.endOfFileToken)); + }; + + SyntaxRewriter.prototype.visitExternalModuleReference = function (node) { + return node.update(this.visitToken(node.requireKeyword), this.visitToken(node.openParenToken), this.visitToken(node.stringLiteral), this.visitToken(node.closeParenToken)); + }; + + SyntaxRewriter.prototype.visitModuleNameModuleReference = function (node) { + return node.update(this.visitNodeOrToken(node.moduleName)); + }; + + SyntaxRewriter.prototype.visitImportDeclaration = function (node) { + return node.update(this.visitList(node.modifiers), this.visitToken(node.importKeyword), this.visitToken(node.identifier), this.visitToken(node.equalsToken), this.visitNode(node.moduleReference), this.visitToken(node.semicolonToken)); + }; + + SyntaxRewriter.prototype.visitExportAssignment = function (node) { + return node.update(this.visitToken(node.exportKeyword), this.visitToken(node.equalsToken), this.visitToken(node.identifier), this.visitToken(node.semicolonToken)); + }; + + SyntaxRewriter.prototype.visitClassDeclaration = function (node) { + return node.update(this.visitList(node.modifiers), this.visitToken(node.classKeyword), this.visitToken(node.identifier), node.typeParameterList === null ? null : this.visitNode(node.typeParameterList), this.visitList(node.heritageClauses), this.visitToken(node.openBraceToken), this.visitList(node.classElements), this.visitToken(node.closeBraceToken)); + }; + + SyntaxRewriter.prototype.visitInterfaceDeclaration = function (node) { + return node.update(this.visitList(node.modifiers), this.visitToken(node.interfaceKeyword), this.visitToken(node.identifier), node.typeParameterList === null ? null : this.visitNode(node.typeParameterList), this.visitList(node.heritageClauses), this.visitNode(node.body)); + }; + + SyntaxRewriter.prototype.visitHeritageClause = function (node) { + return node.update(this.visitToken(node.extendsOrImplementsKeyword), this.visitSeparatedList(node.typeNames)); + }; + + SyntaxRewriter.prototype.visitModuleDeclaration = function (node) { + return node.update(this.visitList(node.modifiers), this.visitToken(node.moduleKeyword), node.moduleName === null ? null : this.visitNodeOrToken(node.moduleName), node.stringLiteral === null ? null : this.visitToken(node.stringLiteral), this.visitToken(node.openBraceToken), this.visitList(node.moduleElements), this.visitToken(node.closeBraceToken)); + }; + + SyntaxRewriter.prototype.visitFunctionDeclaration = function (node) { + return node.update(this.visitList(node.modifiers), this.visitToken(node.functionKeyword), this.visitToken(node.identifier), this.visitNode(node.callSignature), node.block === null ? null : this.visitNode(node.block), node.semicolonToken === null ? null : this.visitToken(node.semicolonToken)); + }; + + SyntaxRewriter.prototype.visitVariableStatement = function (node) { + return node.update(this.visitList(node.modifiers), this.visitNode(node.variableDeclaration), this.visitToken(node.semicolonToken)); + }; + + SyntaxRewriter.prototype.visitVariableDeclaration = function (node) { + return node.update(this.visitToken(node.varKeyword), this.visitSeparatedList(node.variableDeclarators)); + }; + + SyntaxRewriter.prototype.visitVariableDeclarator = function (node) { + return node.update(this.visitToken(node.identifier), node.typeAnnotation === null ? null : this.visitNode(node.typeAnnotation), node.equalsValueClause === null ? null : this.visitNode(node.equalsValueClause)); + }; + + SyntaxRewriter.prototype.visitEqualsValueClause = function (node) { + return node.update(this.visitToken(node.equalsToken), this.visitNodeOrToken(node.value)); + }; + + SyntaxRewriter.prototype.visitPrefixUnaryExpression = function (node) { + return node.update(node.kind(), this.visitToken(node.operatorToken), this.visitNodeOrToken(node.operand)); + }; + + SyntaxRewriter.prototype.visitArrayLiteralExpression = function (node) { + return node.update(this.visitToken(node.openBracketToken), this.visitSeparatedList(node.expressions), this.visitToken(node.closeBracketToken)); + }; + + SyntaxRewriter.prototype.visitOmittedExpression = function (node) { + return node; + }; + + SyntaxRewriter.prototype.visitParenthesizedExpression = function (node) { + return node.update(this.visitToken(node.openParenToken), this.visitNodeOrToken(node.expression), this.visitToken(node.closeParenToken)); + }; + + SyntaxRewriter.prototype.visitSimpleArrowFunctionExpression = function (node) { + return node.update(this.visitToken(node.identifier), this.visitToken(node.equalsGreaterThanToken), this.visitNodeOrToken(node.body)); + }; + + SyntaxRewriter.prototype.visitParenthesizedArrowFunctionExpression = function (node) { + return node.update(this.visitNode(node.callSignature), this.visitToken(node.equalsGreaterThanToken), this.visitNodeOrToken(node.body)); + }; + + SyntaxRewriter.prototype.visitQualifiedName = function (node) { + return node.update(this.visitNodeOrToken(node.left), this.visitToken(node.dotToken), this.visitToken(node.right)); + }; + + SyntaxRewriter.prototype.visitTypeArgumentList = function (node) { + return node.update(this.visitToken(node.lessThanToken), this.visitSeparatedList(node.typeArguments), this.visitToken(node.greaterThanToken)); + }; + + SyntaxRewriter.prototype.visitConstructorType = function (node) { + return node.update(this.visitToken(node.newKeyword), node.typeParameterList === null ? null : this.visitNode(node.typeParameterList), this.visitNode(node.parameterList), this.visitToken(node.equalsGreaterThanToken), this.visitNodeOrToken(node.type)); + }; + + SyntaxRewriter.prototype.visitFunctionType = function (node) { + return node.update(node.typeParameterList === null ? null : this.visitNode(node.typeParameterList), this.visitNode(node.parameterList), this.visitToken(node.equalsGreaterThanToken), this.visitNodeOrToken(node.type)); + }; + + SyntaxRewriter.prototype.visitObjectType = function (node) { + return node.update(this.visitToken(node.openBraceToken), this.visitSeparatedList(node.typeMembers), this.visitToken(node.closeBraceToken)); + }; + + SyntaxRewriter.prototype.visitArrayType = function (node) { + return node.update(this.visitNodeOrToken(node.type), this.visitToken(node.openBracketToken), this.visitToken(node.closeBracketToken)); + }; + + SyntaxRewriter.prototype.visitGenericType = function (node) { + return node.update(this.visitNodeOrToken(node.name), this.visitNode(node.typeArgumentList)); + }; + + SyntaxRewriter.prototype.visitTypeQuery = function (node) { + return node.update(this.visitToken(node.typeOfKeyword), this.visitNodeOrToken(node.name)); + }; + + SyntaxRewriter.prototype.visitTypeAnnotation = function (node) { + return node.update(this.visitToken(node.colonToken), this.visitNodeOrToken(node.type)); + }; + + SyntaxRewriter.prototype.visitBlock = function (node) { + return node.update(this.visitToken(node.openBraceToken), this.visitList(node.statements), this.visitToken(node.closeBraceToken)); + }; + + SyntaxRewriter.prototype.visitParameter = function (node) { + return node.update(node.dotDotDotToken === null ? null : this.visitToken(node.dotDotDotToken), node.publicOrPrivateKeyword === null ? null : this.visitToken(node.publicOrPrivateKeyword), this.visitToken(node.identifier), node.questionToken === null ? null : this.visitToken(node.questionToken), node.typeAnnotation === null ? null : this.visitNode(node.typeAnnotation), node.equalsValueClause === null ? null : this.visitNode(node.equalsValueClause)); + }; + + SyntaxRewriter.prototype.visitMemberAccessExpression = function (node) { + return node.update(this.visitNodeOrToken(node.expression), this.visitToken(node.dotToken), this.visitToken(node.name)); + }; + + SyntaxRewriter.prototype.visitPostfixUnaryExpression = function (node) { + return node.update(node.kind(), this.visitNodeOrToken(node.operand), this.visitToken(node.operatorToken)); + }; + + SyntaxRewriter.prototype.visitElementAccessExpression = function (node) { + return node.update(this.visitNodeOrToken(node.expression), this.visitToken(node.openBracketToken), this.visitNodeOrToken(node.argumentExpression), this.visitToken(node.closeBracketToken)); + }; + + SyntaxRewriter.prototype.visitInvocationExpression = function (node) { + return node.update(this.visitNodeOrToken(node.expression), this.visitNode(node.argumentList)); + }; + + SyntaxRewriter.prototype.visitArgumentList = function (node) { + return node.update(node.typeArgumentList === null ? null : this.visitNode(node.typeArgumentList), this.visitToken(node.openParenToken), this.visitSeparatedList(node.arguments), this.visitToken(node.closeParenToken)); + }; + + SyntaxRewriter.prototype.visitBinaryExpression = function (node) { + return node.update(node.kind(), this.visitNodeOrToken(node.left), this.visitToken(node.operatorToken), this.visitNodeOrToken(node.right)); + }; + + SyntaxRewriter.prototype.visitConditionalExpression = function (node) { + return node.update(this.visitNodeOrToken(node.condition), this.visitToken(node.questionToken), this.visitNodeOrToken(node.whenTrue), this.visitToken(node.colonToken), this.visitNodeOrToken(node.whenFalse)); + }; + + SyntaxRewriter.prototype.visitConstructSignature = function (node) { + return node.update(this.visitToken(node.newKeyword), this.visitNode(node.callSignature)); + }; + + SyntaxRewriter.prototype.visitMethodSignature = function (node) { + return node.update(this.visitToken(node.propertyName), node.questionToken === null ? null : this.visitToken(node.questionToken), this.visitNode(node.callSignature)); + }; + + SyntaxRewriter.prototype.visitIndexSignature = function (node) { + return node.update(this.visitToken(node.openBracketToken), this.visitNode(node.parameter), this.visitToken(node.closeBracketToken), node.typeAnnotation === null ? null : this.visitNode(node.typeAnnotation)); + }; + + SyntaxRewriter.prototype.visitPropertySignature = function (node) { + return node.update(this.visitToken(node.propertyName), node.questionToken === null ? null : this.visitToken(node.questionToken), node.typeAnnotation === null ? null : this.visitNode(node.typeAnnotation)); + }; + + SyntaxRewriter.prototype.visitCallSignature = function (node) { + return node.update(node.typeParameterList === null ? null : this.visitNode(node.typeParameterList), this.visitNode(node.parameterList), node.typeAnnotation === null ? null : this.visitNode(node.typeAnnotation)); + }; + + SyntaxRewriter.prototype.visitParameterList = function (node) { + return node.update(this.visitToken(node.openParenToken), this.visitSeparatedList(node.parameters), this.visitToken(node.closeParenToken)); + }; + + SyntaxRewriter.prototype.visitTypeParameterList = function (node) { + return node.update(this.visitToken(node.lessThanToken), this.visitSeparatedList(node.typeParameters), this.visitToken(node.greaterThanToken)); + }; + + SyntaxRewriter.prototype.visitTypeParameter = function (node) { + return node.update(this.visitToken(node.identifier), node.constraint === null ? null : this.visitNode(node.constraint)); + }; + + SyntaxRewriter.prototype.visitConstraint = function (node) { + return node.update(this.visitToken(node.extendsKeyword), this.visitNodeOrToken(node.type)); + }; + + SyntaxRewriter.prototype.visitElseClause = function (node) { + return node.update(this.visitToken(node.elseKeyword), this.visitNodeOrToken(node.statement)); + }; + + SyntaxRewriter.prototype.visitIfStatement = function (node) { + return node.update(this.visitToken(node.ifKeyword), this.visitToken(node.openParenToken), this.visitNodeOrToken(node.condition), this.visitToken(node.closeParenToken), this.visitNodeOrToken(node.statement), node.elseClause === null ? null : this.visitNode(node.elseClause)); + }; + + SyntaxRewriter.prototype.visitExpressionStatement = function (node) { + return node.update(this.visitNodeOrToken(node.expression), this.visitToken(node.semicolonToken)); + }; + + SyntaxRewriter.prototype.visitConstructorDeclaration = function (node) { + return node.update(this.visitToken(node.constructorKeyword), this.visitNode(node.parameterList), node.block === null ? null : this.visitNode(node.block), node.semicolonToken === null ? null : this.visitToken(node.semicolonToken)); + }; + + SyntaxRewriter.prototype.visitMemberFunctionDeclaration = function (node) { + return node.update(this.visitList(node.modifiers), this.visitToken(node.propertyName), this.visitNode(node.callSignature), node.block === null ? null : this.visitNode(node.block), node.semicolonToken === null ? null : this.visitToken(node.semicolonToken)); + }; + + SyntaxRewriter.prototype.visitGetMemberAccessorDeclaration = function (node) { + return node.update(this.visitList(node.modifiers), this.visitToken(node.getKeyword), this.visitToken(node.propertyName), this.visitNode(node.parameterList), node.typeAnnotation === null ? null : this.visitNode(node.typeAnnotation), this.visitNode(node.block)); + }; + + SyntaxRewriter.prototype.visitSetMemberAccessorDeclaration = function (node) { + return node.update(this.visitList(node.modifiers), this.visitToken(node.setKeyword), this.visitToken(node.propertyName), this.visitNode(node.parameterList), this.visitNode(node.block)); + }; + + SyntaxRewriter.prototype.visitMemberVariableDeclaration = function (node) { + return node.update(this.visitList(node.modifiers), this.visitNode(node.variableDeclarator), this.visitToken(node.semicolonToken)); + }; + + SyntaxRewriter.prototype.visitThrowStatement = function (node) { + return node.update(this.visitToken(node.throwKeyword), this.visitNodeOrToken(node.expression), this.visitToken(node.semicolonToken)); + }; + + SyntaxRewriter.prototype.visitReturnStatement = function (node) { + return node.update(this.visitToken(node.returnKeyword), node.expression === null ? null : this.visitNodeOrToken(node.expression), this.visitToken(node.semicolonToken)); + }; + + SyntaxRewriter.prototype.visitObjectCreationExpression = function (node) { + return node.update(this.visitToken(node.newKeyword), this.visitNodeOrToken(node.expression), node.argumentList === null ? null : this.visitNode(node.argumentList)); + }; + + SyntaxRewriter.prototype.visitSwitchStatement = function (node) { + return node.update(this.visitToken(node.switchKeyword), this.visitToken(node.openParenToken), this.visitNodeOrToken(node.expression), this.visitToken(node.closeParenToken), this.visitToken(node.openBraceToken), this.visitList(node.switchClauses), this.visitToken(node.closeBraceToken)); + }; + + SyntaxRewriter.prototype.visitCaseSwitchClause = function (node) { + return node.update(this.visitToken(node.caseKeyword), this.visitNodeOrToken(node.expression), this.visitToken(node.colonToken), this.visitList(node.statements)); + }; + + SyntaxRewriter.prototype.visitDefaultSwitchClause = function (node) { + return node.update(this.visitToken(node.defaultKeyword), this.visitToken(node.colonToken), this.visitList(node.statements)); + }; + + SyntaxRewriter.prototype.visitBreakStatement = function (node) { + return node.update(this.visitToken(node.breakKeyword), node.identifier === null ? null : this.visitToken(node.identifier), this.visitToken(node.semicolonToken)); + }; + + SyntaxRewriter.prototype.visitContinueStatement = function (node) { + return node.update(this.visitToken(node.continueKeyword), node.identifier === null ? null : this.visitToken(node.identifier), this.visitToken(node.semicolonToken)); + }; + + SyntaxRewriter.prototype.visitForStatement = function (node) { + return node.update(this.visitToken(node.forKeyword), this.visitToken(node.openParenToken), node.variableDeclaration === null ? null : this.visitNode(node.variableDeclaration), node.initializer === null ? null : this.visitNodeOrToken(node.initializer), this.visitToken(node.firstSemicolonToken), node.condition === null ? null : this.visitNodeOrToken(node.condition), this.visitToken(node.secondSemicolonToken), node.incrementor === null ? null : this.visitNodeOrToken(node.incrementor), this.visitToken(node.closeParenToken), this.visitNodeOrToken(node.statement)); + }; + + SyntaxRewriter.prototype.visitForInStatement = function (node) { + return node.update(this.visitToken(node.forKeyword), this.visitToken(node.openParenToken), node.variableDeclaration === null ? null : this.visitNode(node.variableDeclaration), node.left === null ? null : this.visitNodeOrToken(node.left), this.visitToken(node.inKeyword), this.visitNodeOrToken(node.expression), this.visitToken(node.closeParenToken), this.visitNodeOrToken(node.statement)); + }; + + SyntaxRewriter.prototype.visitWhileStatement = function (node) { + return node.update(this.visitToken(node.whileKeyword), this.visitToken(node.openParenToken), this.visitNodeOrToken(node.condition), this.visitToken(node.closeParenToken), this.visitNodeOrToken(node.statement)); + }; + + SyntaxRewriter.prototype.visitWithStatement = function (node) { + return node.update(this.visitToken(node.withKeyword), this.visitToken(node.openParenToken), this.visitNodeOrToken(node.condition), this.visitToken(node.closeParenToken), this.visitNodeOrToken(node.statement)); + }; + + SyntaxRewriter.prototype.visitEnumDeclaration = function (node) { + return node.update(this.visitList(node.modifiers), this.visitToken(node.enumKeyword), this.visitToken(node.identifier), this.visitToken(node.openBraceToken), this.visitSeparatedList(node.enumElements), this.visitToken(node.closeBraceToken)); + }; + + SyntaxRewriter.prototype.visitEnumElement = function (node) { + return node.update(this.visitToken(node.propertyName), node.equalsValueClause === null ? null : this.visitNode(node.equalsValueClause)); + }; + + SyntaxRewriter.prototype.visitCastExpression = function (node) { + return node.update(this.visitToken(node.lessThanToken), this.visitNodeOrToken(node.type), this.visitToken(node.greaterThanToken), this.visitNodeOrToken(node.expression)); + }; + + SyntaxRewriter.prototype.visitObjectLiteralExpression = function (node) { + return node.update(this.visitToken(node.openBraceToken), this.visitSeparatedList(node.propertyAssignments), this.visitToken(node.closeBraceToken)); + }; + + SyntaxRewriter.prototype.visitSimplePropertyAssignment = function (node) { + return node.update(this.visitToken(node.propertyName), this.visitToken(node.colonToken), this.visitNodeOrToken(node.expression)); + }; + + SyntaxRewriter.prototype.visitFunctionPropertyAssignment = function (node) { + return node.update(this.visitToken(node.propertyName), this.visitNode(node.callSignature), this.visitNode(node.block)); + }; + + SyntaxRewriter.prototype.visitGetAccessorPropertyAssignment = function (node) { + return node.update(this.visitToken(node.getKeyword), this.visitToken(node.propertyName), this.visitToken(node.openParenToken), this.visitToken(node.closeParenToken), node.typeAnnotation === null ? null : this.visitNode(node.typeAnnotation), this.visitNode(node.block)); + }; + + SyntaxRewriter.prototype.visitSetAccessorPropertyAssignment = function (node) { + return node.update(this.visitToken(node.setKeyword), this.visitToken(node.propertyName), this.visitToken(node.openParenToken), this.visitNode(node.parameter), this.visitToken(node.closeParenToken), this.visitNode(node.block)); + }; + + SyntaxRewriter.prototype.visitFunctionExpression = function (node) { + return node.update(this.visitToken(node.functionKeyword), node.identifier === null ? null : this.visitToken(node.identifier), this.visitNode(node.callSignature), this.visitNode(node.block)); + }; + + SyntaxRewriter.prototype.visitEmptyStatement = function (node) { + return node.update(this.visitToken(node.semicolonToken)); + }; + + SyntaxRewriter.prototype.visitTryStatement = function (node) { + return node.update(this.visitToken(node.tryKeyword), this.visitNode(node.block), node.catchClause === null ? null : this.visitNode(node.catchClause), node.finallyClause === null ? null : this.visitNode(node.finallyClause)); + }; + + SyntaxRewriter.prototype.visitCatchClause = function (node) { + return node.update(this.visitToken(node.catchKeyword), this.visitToken(node.openParenToken), this.visitToken(node.identifier), node.typeAnnotation === null ? null : this.visitNode(node.typeAnnotation), this.visitToken(node.closeParenToken), this.visitNode(node.block)); + }; + + SyntaxRewriter.prototype.visitFinallyClause = function (node) { + return node.update(this.visitToken(node.finallyKeyword), this.visitNode(node.block)); + }; + + SyntaxRewriter.prototype.visitLabeledStatement = function (node) { + return node.update(this.visitToken(node.identifier), this.visitToken(node.colonToken), this.visitNodeOrToken(node.statement)); + }; + + SyntaxRewriter.prototype.visitDoStatement = function (node) { + return node.update(this.visitToken(node.doKeyword), this.visitNodeOrToken(node.statement), this.visitToken(node.whileKeyword), this.visitToken(node.openParenToken), this.visitNodeOrToken(node.condition), this.visitToken(node.closeParenToken), this.visitToken(node.semicolonToken)); + }; + + SyntaxRewriter.prototype.visitTypeOfExpression = function (node) { + return node.update(this.visitToken(node.typeOfKeyword), this.visitNodeOrToken(node.expression)); + }; + + SyntaxRewriter.prototype.visitDeleteExpression = function (node) { + return node.update(this.visitToken(node.deleteKeyword), this.visitNodeOrToken(node.expression)); + }; + + SyntaxRewriter.prototype.visitVoidExpression = function (node) { + return node.update(this.visitToken(node.voidKeyword), this.visitNodeOrToken(node.expression)); + }; + + SyntaxRewriter.prototype.visitDebuggerStatement = function (node) { + return node.update(this.visitToken(node.debuggerKeyword), this.visitToken(node.semicolonToken)); + }; + return SyntaxRewriter; + })(); + TypeScript.SyntaxRewriter = SyntaxRewriter; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var SyntaxDedenter = (function (_super) { + __extends(SyntaxDedenter, _super); + function SyntaxDedenter(dedentFirstToken, dedentationAmount, minimumIndent, options) { + _super.call(this); + this.dedentationAmount = dedentationAmount; + this.minimumIndent = minimumIndent; + this.options = options; + this.lastTriviaWasNewLine = dedentFirstToken; + } + SyntaxDedenter.prototype.abort = function () { + this.lastTriviaWasNewLine = false; + this.dedentationAmount = 0; + }; + + SyntaxDedenter.prototype.isAborted = function () { + return this.dedentationAmount === 0; + }; + + SyntaxDedenter.prototype.visitToken = function (token) { + if (token.width() === 0) { + return token; + } + + var result = token; + if (this.lastTriviaWasNewLine) { + result = token.withLeadingTrivia(this.dedentTriviaList(token.leadingTrivia())); + } + + if (this.isAborted()) { + return token; + } + + this.lastTriviaWasNewLine = token.hasTrailingNewLine(); + return result; + }; + + SyntaxDedenter.prototype.dedentTriviaList = function (triviaList) { + var result = []; + var dedentNextWhitespace = true; + + 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() === 4 /* WhitespaceTrivia */) { + var hasFollowingNewLine = (i < triviaList.count() - 1) && triviaList.syntaxTriviaAt(i + 1).kind() === 5 /* NewLineTrivia */; + result.push(this.dedentWhitespace(trivia, hasFollowingNewLine)); + continue; + } else if (trivia.kind() !== 5 /* NewLineTrivia */) { + this.abort(); + break; + } + } + + if (trivia.kind() === 6 /* MultiLineCommentTrivia */) { + result.push(this.dedentMultiLineComment(trivia)); + continue; + } + + result.push(trivia); + if (trivia.kind() === 5 /* NewLineTrivia */) { + dedentNextWhitespace = true; + } + } + + if (dedentNextWhitespace) { + this.abort(); + } + + if (this.isAborted()) { + return triviaList; + } + + return TypeScript.Syntax.triviaList(result); + }; + + SyntaxDedenter.prototype.dedentSegment = function (segment, hasFollowingNewLineTrivia) { + var firstNonWhitespacePosition = TypeScript.Indentation.firstNonWhitespacePosition(segment); + + if (firstNonWhitespacePosition === segment.length) { + if (hasFollowingNewLineTrivia) { + return ""; + } + } else if (TypeScript.CharacterInfo.isLineTerminator(segment.charCodeAt(firstNonWhitespacePosition))) { + return segment.substring(firstNonWhitespacePosition); + } + + var firstNonWhitespaceColumn = TypeScript.Indentation.columnForPositionInString(segment, firstNonWhitespacePosition, this.options); + + var newFirstNonWhitespaceColumn = TypeScript.MathPrototype.min(firstNonWhitespaceColumn, TypeScript.MathPrototype.max(firstNonWhitespaceColumn - this.dedentationAmount, this.minimumIndent)); + + if (newFirstNonWhitespaceColumn === firstNonWhitespaceColumn) { + this.abort(); + return segment; + } + + this.dedentationAmount = firstNonWhitespaceColumn - newFirstNonWhitespaceColumn; + TypeScript.Debug.assert(this.dedentationAmount >= 0); + + var indentationString = TypeScript.Indentation.indentationString(newFirstNonWhitespaceColumn, this.options); + + return indentationString + segment.substring(firstNonWhitespacePosition); + }; + + SyntaxDedenter.prototype.dedentWhitespace = function (trivia, hasFollowingNewLineTrivia) { + var newIndentation = this.dedentSegment(trivia.fullText(), hasFollowingNewLineTrivia); + return TypeScript.Syntax.whitespace(newIndentation); + }; + + SyntaxDedenter.prototype.dedentMultiLineComment = function (trivia) { + var segments = TypeScript.Syntax.splitMultiLineCommentTriviaIntoMultipleLines(trivia); + if (segments.length === 1) { + return trivia; + } + + for (var i = 1; i < segments.length; i++) { + var segment = segments[i]; + segments[i] = this.dedentSegment(segment, false); + } + + var result = segments.join(""); + + return TypeScript.Syntax.multiLineComment(result); + }; + + SyntaxDedenter.dedentNode = function (node, dedentFirstToken, dedentAmount, minimumIndent, options) { + var dedenter = new SyntaxDedenter(dedentFirstToken, dedentAmount, minimumIndent, options); + var result = node.accept(dedenter); + + if (dedenter.isAborted()) { + return node; + } + + return result; + }; + return SyntaxDedenter; + })(TypeScript.SyntaxRewriter); + TypeScript.SyntaxDedenter = SyntaxDedenter; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var SyntaxIndenter = (function (_super) { + __extends(SyntaxIndenter, _super); + function SyntaxIndenter(indentFirstToken, indentationAmount, options) { + _super.call(this); + this.indentationAmount = indentationAmount; + this.options = options; + this.lastTriviaWasNewLine = indentFirstToken; + this.indentationTrivia = TypeScript.Indentation.indentationTrivia(this.indentationAmount, this.options); + } + SyntaxIndenter.prototype.visitToken = function (token) { + if (token.width() === 0) { + return token; + } + + var result = token; + if (this.lastTriviaWasNewLine) { + result = token.withLeadingTrivia(this.indentTriviaList(token.leadingTrivia())); + } + + this.lastTriviaWasNewLine = token.hasTrailingNewLine(); + return result; + }; + + SyntaxIndenter.prototype.indentTriviaList = function (triviaList) { + var result = []; + + 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 6 /* MultiLineCommentTrivia */: + this.indentMultiLineComment(trivia, indentThisTrivia, result); + continue; + + case 7 /* SingleLineCommentTrivia */: + case 8 /* SkippedTokenTrivia */: + this.indentSingleLineOrSkippedText(trivia, indentThisTrivia, result); + continue; + + case 4 /* WhitespaceTrivia */: + this.indentWhitespace(trivia, indentThisTrivia, result); + continue; + + case 5 /* NewLineTrivia */: + result.push(trivia); + indentNextTrivia = true; + continue; + + default: + throw TypeScript.Errors.invalidOperation(); + } + } + + if (indentNextTrivia) { + result.push(this.indentationTrivia); + } + + return TypeScript.Syntax.triviaList(result); + }; + + SyntaxIndenter.prototype.indentSegment = function (segment) { + var firstNonWhitespacePosition = TypeScript.Indentation.firstNonWhitespacePosition(segment); + + if (firstNonWhitespacePosition < segment.length && TypeScript.CharacterInfo.isLineTerminator(segment.charCodeAt(firstNonWhitespacePosition))) { + return segment; + } + + var firstNonWhitespaceColumn = TypeScript.Indentation.columnForPositionInString(segment, firstNonWhitespacePosition, this.options); + + var newFirstNonWhitespaceColumn = firstNonWhitespaceColumn + this.indentationAmount; + + var indentationString = TypeScript.Indentation.indentationString(newFirstNonWhitespaceColumn, this.options); + + return indentationString + segment.substring(firstNonWhitespacePosition); + }; + + SyntaxIndenter.prototype.indentWhitespace = function (trivia, indentThisTrivia, result) { + if (!indentThisTrivia) { + result.push(trivia); + return; + } + + var newIndentation = this.indentSegment(trivia.fullText()); + result.push(TypeScript.Syntax.whitespace(newIndentation)); + }; + + SyntaxIndenter.prototype.indentSingleLineOrSkippedText = function (trivia, indentThisTrivia, result) { + if (indentThisTrivia) { + result.push(this.indentationTrivia); + } + + result.push(trivia); + }; + + SyntaxIndenter.prototype.indentMultiLineComment = function (trivia, indentThisTrivia, result) { + if (indentThisTrivia) { + result.push(this.indentationTrivia); + } + + var segments = TypeScript.Syntax.splitMultiLineCommentTriviaIntoMultipleLines(trivia); + + for (var i = 1; i < segments.length; i++) { + segments[i] = this.indentSegment(segments[i]); + } + + var newText = segments.join(""); + result.push(TypeScript.Syntax.multiLineComment(newText)); + }; + + SyntaxIndenter.indentNode = function (node, indentFirstToken, indentAmount, options) { + var indenter = new SyntaxIndenter(indentFirstToken, indentAmount, options); + return node.accept(indenter); + }; + + SyntaxIndenter.indentNodes = function (nodes, indentFirstToken, indentAmount, options) { + var indenter = new SyntaxIndenter(indentFirstToken, indentAmount, options); + var result = TypeScript.ArrayUtilities.select(nodes, function (n) { + return n.accept(indenter); + }); + + return result; + }; + return SyntaxIndenter; + })(TypeScript.SyntaxRewriter); + TypeScript.SyntaxIndenter = SyntaxIndenter; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (Syntax) { + var VariableWidthTokenWithNoTrivia = (function () { + function VariableWidthTokenWithNoTrivia(sourceText, fullStart, kind, textOrWidth) { + this._sourceText = sourceText; + this._fullStart = fullStart; + this.tokenKind = kind; + this._textOrWidth = textOrWidth; + } + VariableWidthTokenWithNoTrivia.prototype.clone = function () { + return new VariableWidthTokenWithNoTrivia(this._sourceText, this._fullStart, this.tokenKind, this._textOrWidth); + }; + + VariableWidthTokenWithNoTrivia.prototype.isNode = function () { + return false; + }; + VariableWidthTokenWithNoTrivia.prototype.isToken = function () { + return true; + }; + VariableWidthTokenWithNoTrivia.prototype.isList = function () { + return false; + }; + VariableWidthTokenWithNoTrivia.prototype.isSeparatedList = function () { + return false; + }; + + VariableWidthTokenWithNoTrivia.prototype.kind = function () { + return this.tokenKind; + }; + + VariableWidthTokenWithNoTrivia.prototype.childCount = function () { + return 0; + }; + VariableWidthTokenWithNoTrivia.prototype.childAt = function (index) { + throw TypeScript.Errors.argumentOutOfRange('index'); + }; + + VariableWidthTokenWithNoTrivia.prototype.fullWidth = function () { + return this.width(); + }; + VariableWidthTokenWithNoTrivia.prototype.start = function () { + return this._fullStart; + }; + VariableWidthTokenWithNoTrivia.prototype.end = function () { + return this.start() + this.width(); + }; + + VariableWidthTokenWithNoTrivia.prototype.width = function () { + return typeof this._textOrWidth === 'number' ? this._textOrWidth : this._textOrWidth.length; + }; + + VariableWidthTokenWithNoTrivia.prototype.text = function () { + if (typeof this._textOrWidth === 'number') { + this._textOrWidth = this._sourceText.substr(this.start(), this._textOrWidth, this.tokenKind === 11 /* IdentifierName */); + } + + return this._textOrWidth; + }; + + VariableWidthTokenWithNoTrivia.prototype.fullText = function () { + return this._sourceText.substr(this._fullStart, this.fullWidth(), false); + }; + + VariableWidthTokenWithNoTrivia.prototype.value = function () { + if ((this)._value === undefined) { + (this)._value = Syntax.value(this); + } + + return (this)._value; + }; + + VariableWidthTokenWithNoTrivia.prototype.valueText = function () { + if ((this)._valueText === undefined) { + (this)._valueText = Syntax.valueText(this); + } + + return (this)._valueText; + }; + + VariableWidthTokenWithNoTrivia.prototype.hasLeadingTrivia = function () { + return false; + }; + VariableWidthTokenWithNoTrivia.prototype.hasLeadingComment = function () { + return false; + }; + VariableWidthTokenWithNoTrivia.prototype.hasLeadingNewLine = function () { + return false; + }; + VariableWidthTokenWithNoTrivia.prototype.hasLeadingSkippedText = function () { + return false; + }; + VariableWidthTokenWithNoTrivia.prototype.leadingTriviaWidth = function () { + return 0; + }; + VariableWidthTokenWithNoTrivia.prototype.leadingTrivia = function () { + return TypeScript.Syntax.emptyTriviaList; + }; + + VariableWidthTokenWithNoTrivia.prototype.hasTrailingTrivia = function () { + return false; + }; + VariableWidthTokenWithNoTrivia.prototype.hasTrailingComment = function () { + return false; + }; + VariableWidthTokenWithNoTrivia.prototype.hasTrailingNewLine = function () { + return false; + }; + VariableWidthTokenWithNoTrivia.prototype.hasTrailingSkippedText = function () { + return false; + }; + VariableWidthTokenWithNoTrivia.prototype.trailingTriviaWidth = function () { + return 0; + }; + VariableWidthTokenWithNoTrivia.prototype.trailingTrivia = function () { + return TypeScript.Syntax.emptyTriviaList; + }; + + VariableWidthTokenWithNoTrivia.prototype.hasSkippedToken = function () { + return false; + }; + VariableWidthTokenWithNoTrivia.prototype.toJSON = function (key) { + return Syntax.tokenToJSON(this); + }; + VariableWidthTokenWithNoTrivia.prototype.firstToken = function () { + return this; + }; + VariableWidthTokenWithNoTrivia.prototype.lastToken = function () { + return this; + }; + VariableWidthTokenWithNoTrivia.prototype.isTypeScriptSpecific = function () { + return false; + }; + VariableWidthTokenWithNoTrivia.prototype.isIncrementallyUnusable = function () { + return this.fullWidth() === 0 || TypeScript.SyntaxFacts.isAnyDivideOrRegularExpressionToken(this.tokenKind); + }; + VariableWidthTokenWithNoTrivia.prototype.accept = function (visitor) { + return visitor.visitToken(this); + }; + VariableWidthTokenWithNoTrivia.prototype.realize = function () { + return Syntax.realizeToken(this); + }; + VariableWidthTokenWithNoTrivia.prototype.collectTextElements = function (elements) { + collectTokenTextElements(this, elements); + }; + + VariableWidthTokenWithNoTrivia.prototype.findTokenInternal = function (parent, position, fullStart) { + return new TypeScript.PositionedToken(parent, this, fullStart); + }; + + VariableWidthTokenWithNoTrivia.prototype.withLeadingTrivia = function (leadingTrivia) { + return this.realize().withLeadingTrivia(leadingTrivia); + }; + + VariableWidthTokenWithNoTrivia.prototype.withTrailingTrivia = function (trailingTrivia) { + return this.realize().withTrailingTrivia(trailingTrivia); + }; + return VariableWidthTokenWithNoTrivia; + })(); + Syntax.VariableWidthTokenWithNoTrivia = VariableWidthTokenWithNoTrivia; + + var VariableWidthTokenWithLeadingTrivia = (function () { + function VariableWidthTokenWithLeadingTrivia(sourceText, fullStart, kind, leadingTriviaInfo, textOrWidth) { + this._sourceText = sourceText; + this._fullStart = fullStart; + this.tokenKind = kind; + this._leadingTriviaInfo = leadingTriviaInfo; + this._textOrWidth = textOrWidth; + } + VariableWidthTokenWithLeadingTrivia.prototype.clone = function () { + return new VariableWidthTokenWithLeadingTrivia(this._sourceText, this._fullStart, this.tokenKind, this._leadingTriviaInfo, this._textOrWidth); + }; + + VariableWidthTokenWithLeadingTrivia.prototype.isNode = function () { + return false; + }; + VariableWidthTokenWithLeadingTrivia.prototype.isToken = function () { + return true; + }; + VariableWidthTokenWithLeadingTrivia.prototype.isList = function () { + return false; + }; + VariableWidthTokenWithLeadingTrivia.prototype.isSeparatedList = function () { + return false; + }; + + VariableWidthTokenWithLeadingTrivia.prototype.kind = function () { + return this.tokenKind; + }; + + VariableWidthTokenWithLeadingTrivia.prototype.childCount = function () { + return 0; + }; + VariableWidthTokenWithLeadingTrivia.prototype.childAt = function (index) { + throw TypeScript.Errors.argumentOutOfRange('index'); + }; + + VariableWidthTokenWithLeadingTrivia.prototype.fullWidth = function () { + return getTriviaWidth(this._leadingTriviaInfo) + this.width(); + }; + VariableWidthTokenWithLeadingTrivia.prototype.start = function () { + return this._fullStart + getTriviaWidth(this._leadingTriviaInfo); + }; + VariableWidthTokenWithLeadingTrivia.prototype.end = function () { + return this.start() + this.width(); + }; + + VariableWidthTokenWithLeadingTrivia.prototype.width = function () { + return typeof this._textOrWidth === 'number' ? this._textOrWidth : this._textOrWidth.length; + }; + + VariableWidthTokenWithLeadingTrivia.prototype.text = function () { + if (typeof this._textOrWidth === 'number') { + this._textOrWidth = this._sourceText.substr(this.start(), this._textOrWidth, this.tokenKind === 11 /* IdentifierName */); + } + + return this._textOrWidth; + }; + + VariableWidthTokenWithLeadingTrivia.prototype.fullText = function () { + return this._sourceText.substr(this._fullStart, this.fullWidth(), false); + }; + + VariableWidthTokenWithLeadingTrivia.prototype.value = function () { + if ((this)._value === undefined) { + (this)._value = Syntax.value(this); + } + + return (this)._value; + }; + + VariableWidthTokenWithLeadingTrivia.prototype.valueText = function () { + if ((this)._valueText === undefined) { + (this)._valueText = Syntax.valueText(this); + } + + return (this)._valueText; + }; + + VariableWidthTokenWithLeadingTrivia.prototype.hasLeadingTrivia = function () { + return true; + }; + VariableWidthTokenWithLeadingTrivia.prototype.hasLeadingComment = function () { + return hasTriviaComment(this._leadingTriviaInfo); + }; + VariableWidthTokenWithLeadingTrivia.prototype.hasLeadingNewLine = function () { + return hasTriviaNewLine(this._leadingTriviaInfo); + }; + VariableWidthTokenWithLeadingTrivia.prototype.hasLeadingSkippedText = function () { + return false; + }; + VariableWidthTokenWithLeadingTrivia.prototype.leadingTriviaWidth = function () { + return getTriviaWidth(this._leadingTriviaInfo); + }; + VariableWidthTokenWithLeadingTrivia.prototype.leadingTrivia = function () { + return TypeScript.Scanner.scanTrivia(this._sourceText, this._fullStart, getTriviaWidth(this._leadingTriviaInfo), false); + }; + + VariableWidthTokenWithLeadingTrivia.prototype.hasTrailingTrivia = function () { + return false; + }; + VariableWidthTokenWithLeadingTrivia.prototype.hasTrailingComment = function () { + return false; + }; + VariableWidthTokenWithLeadingTrivia.prototype.hasTrailingNewLine = function () { + return false; + }; + VariableWidthTokenWithLeadingTrivia.prototype.hasTrailingSkippedText = function () { + return false; + }; + VariableWidthTokenWithLeadingTrivia.prototype.trailingTriviaWidth = function () { + return 0; + }; + VariableWidthTokenWithLeadingTrivia.prototype.trailingTrivia = function () { + return TypeScript.Syntax.emptyTriviaList; + }; + + VariableWidthTokenWithLeadingTrivia.prototype.hasSkippedToken = function () { + return false; + }; + VariableWidthTokenWithLeadingTrivia.prototype.toJSON = function (key) { + return Syntax.tokenToJSON(this); + }; + VariableWidthTokenWithLeadingTrivia.prototype.firstToken = function () { + return this; + }; + VariableWidthTokenWithLeadingTrivia.prototype.lastToken = function () { + return this; + }; + VariableWidthTokenWithLeadingTrivia.prototype.isTypeScriptSpecific = function () { + return false; + }; + VariableWidthTokenWithLeadingTrivia.prototype.isIncrementallyUnusable = function () { + return this.fullWidth() === 0 || TypeScript.SyntaxFacts.isAnyDivideOrRegularExpressionToken(this.tokenKind); + }; + VariableWidthTokenWithLeadingTrivia.prototype.accept = function (visitor) { + return visitor.visitToken(this); + }; + VariableWidthTokenWithLeadingTrivia.prototype.realize = function () { + return Syntax.realizeToken(this); + }; + VariableWidthTokenWithLeadingTrivia.prototype.collectTextElements = function (elements) { + collectTokenTextElements(this, elements); + }; + + VariableWidthTokenWithLeadingTrivia.prototype.findTokenInternal = function (parent, position, fullStart) { + return new TypeScript.PositionedToken(parent, this, fullStart); + }; + + VariableWidthTokenWithLeadingTrivia.prototype.withLeadingTrivia = function (leadingTrivia) { + return this.realize().withLeadingTrivia(leadingTrivia); + }; + + VariableWidthTokenWithLeadingTrivia.prototype.withTrailingTrivia = function (trailingTrivia) { + return this.realize().withTrailingTrivia(trailingTrivia); + }; + return VariableWidthTokenWithLeadingTrivia; + })(); + Syntax.VariableWidthTokenWithLeadingTrivia = VariableWidthTokenWithLeadingTrivia; + + var VariableWidthTokenWithTrailingTrivia = (function () { + function VariableWidthTokenWithTrailingTrivia(sourceText, fullStart, kind, textOrWidth, trailingTriviaInfo) { + this._sourceText = sourceText; + this._fullStart = fullStart; + this.tokenKind = kind; + this._textOrWidth = textOrWidth; + this._trailingTriviaInfo = trailingTriviaInfo; + } + VariableWidthTokenWithTrailingTrivia.prototype.clone = function () { + return new VariableWidthTokenWithTrailingTrivia(this._sourceText, this._fullStart, this.tokenKind, this._textOrWidth, this._trailingTriviaInfo); + }; + + VariableWidthTokenWithTrailingTrivia.prototype.isNode = function () { + return false; + }; + VariableWidthTokenWithTrailingTrivia.prototype.isToken = function () { + return true; + }; + VariableWidthTokenWithTrailingTrivia.prototype.isList = function () { + return false; + }; + VariableWidthTokenWithTrailingTrivia.prototype.isSeparatedList = function () { + return false; + }; + + VariableWidthTokenWithTrailingTrivia.prototype.kind = function () { + return this.tokenKind; + }; + + VariableWidthTokenWithTrailingTrivia.prototype.childCount = function () { + return 0; + }; + VariableWidthTokenWithTrailingTrivia.prototype.childAt = function (index) { + throw TypeScript.Errors.argumentOutOfRange('index'); + }; + + VariableWidthTokenWithTrailingTrivia.prototype.fullWidth = function () { + return this.width() + getTriviaWidth(this._trailingTriviaInfo); + }; + VariableWidthTokenWithTrailingTrivia.prototype.start = function () { + return this._fullStart; + }; + VariableWidthTokenWithTrailingTrivia.prototype.end = function () { + return this.start() + this.width(); + }; + + VariableWidthTokenWithTrailingTrivia.prototype.width = function () { + return typeof this._textOrWidth === 'number' ? this._textOrWidth : this._textOrWidth.length; + }; + + VariableWidthTokenWithTrailingTrivia.prototype.text = function () { + if (typeof this._textOrWidth === 'number') { + this._textOrWidth = this._sourceText.substr(this.start(), this._textOrWidth, this.tokenKind === 11 /* IdentifierName */); + } + + return this._textOrWidth; + }; + + VariableWidthTokenWithTrailingTrivia.prototype.fullText = function () { + return this._sourceText.substr(this._fullStart, this.fullWidth(), false); + }; + + VariableWidthTokenWithTrailingTrivia.prototype.value = function () { + if ((this)._value === undefined) { + (this)._value = Syntax.value(this); + } + + return (this)._value; + }; + + VariableWidthTokenWithTrailingTrivia.prototype.valueText = function () { + if ((this)._valueText === undefined) { + (this)._valueText = Syntax.valueText(this); + } + + return (this)._valueText; + }; + + VariableWidthTokenWithTrailingTrivia.prototype.hasLeadingTrivia = function () { + return false; + }; + VariableWidthTokenWithTrailingTrivia.prototype.hasLeadingComment = function () { + return false; + }; + VariableWidthTokenWithTrailingTrivia.prototype.hasLeadingNewLine = function () { + return false; + }; + VariableWidthTokenWithTrailingTrivia.prototype.hasLeadingSkippedText = function () { + return false; + }; + VariableWidthTokenWithTrailingTrivia.prototype.leadingTriviaWidth = function () { + return 0; + }; + VariableWidthTokenWithTrailingTrivia.prototype.leadingTrivia = function () { + return TypeScript.Syntax.emptyTriviaList; + }; + + VariableWidthTokenWithTrailingTrivia.prototype.hasTrailingTrivia = function () { + return true; + }; + VariableWidthTokenWithTrailingTrivia.prototype.hasTrailingComment = function () { + return hasTriviaComment(this._trailingTriviaInfo); + }; + VariableWidthTokenWithTrailingTrivia.prototype.hasTrailingNewLine = function () { + return hasTriviaNewLine(this._trailingTriviaInfo); + }; + VariableWidthTokenWithTrailingTrivia.prototype.hasTrailingSkippedText = function () { + return false; + }; + VariableWidthTokenWithTrailingTrivia.prototype.trailingTriviaWidth = function () { + return getTriviaWidth(this._trailingTriviaInfo); + }; + VariableWidthTokenWithTrailingTrivia.prototype.trailingTrivia = function () { + return TypeScript.Scanner.scanTrivia(this._sourceText, this.end(), getTriviaWidth(this._trailingTriviaInfo), true); + }; + + VariableWidthTokenWithTrailingTrivia.prototype.hasSkippedToken = function () { + return false; + }; + VariableWidthTokenWithTrailingTrivia.prototype.toJSON = function (key) { + return Syntax.tokenToJSON(this); + }; + VariableWidthTokenWithTrailingTrivia.prototype.firstToken = function () { + return this; + }; + VariableWidthTokenWithTrailingTrivia.prototype.lastToken = function () { + return this; + }; + VariableWidthTokenWithTrailingTrivia.prototype.isTypeScriptSpecific = function () { + return false; + }; + VariableWidthTokenWithTrailingTrivia.prototype.isIncrementallyUnusable = function () { + return this.fullWidth() === 0 || TypeScript.SyntaxFacts.isAnyDivideOrRegularExpressionToken(this.tokenKind); + }; + VariableWidthTokenWithTrailingTrivia.prototype.accept = function (visitor) { + return visitor.visitToken(this); + }; + VariableWidthTokenWithTrailingTrivia.prototype.realize = function () { + return Syntax.realizeToken(this); + }; + VariableWidthTokenWithTrailingTrivia.prototype.collectTextElements = function (elements) { + collectTokenTextElements(this, elements); + }; + + VariableWidthTokenWithTrailingTrivia.prototype.findTokenInternal = function (parent, position, fullStart) { + return new TypeScript.PositionedToken(parent, this, fullStart); + }; + + VariableWidthTokenWithTrailingTrivia.prototype.withLeadingTrivia = function (leadingTrivia) { + return this.realize().withLeadingTrivia(leadingTrivia); + }; + + VariableWidthTokenWithTrailingTrivia.prototype.withTrailingTrivia = function (trailingTrivia) { + return this.realize().withTrailingTrivia(trailingTrivia); + }; + return VariableWidthTokenWithTrailingTrivia; + })(); + Syntax.VariableWidthTokenWithTrailingTrivia = VariableWidthTokenWithTrailingTrivia; + + var VariableWidthTokenWithLeadingAndTrailingTrivia = (function () { + function VariableWidthTokenWithLeadingAndTrailingTrivia(sourceText, fullStart, kind, leadingTriviaInfo, textOrWidth, trailingTriviaInfo) { + this._sourceText = sourceText; + this._fullStart = fullStart; + this.tokenKind = kind; + this._leadingTriviaInfo = leadingTriviaInfo; + this._textOrWidth = textOrWidth; + this._trailingTriviaInfo = trailingTriviaInfo; + } + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.clone = function () { + return new VariableWidthTokenWithLeadingAndTrailingTrivia(this._sourceText, this._fullStart, this.tokenKind, this._leadingTriviaInfo, this._textOrWidth, this._trailingTriviaInfo); + }; + + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.isNode = function () { + return false; + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.isToken = function () { + return true; + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.isList = function () { + return false; + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.isSeparatedList = function () { + return false; + }; + + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.kind = function () { + return this.tokenKind; + }; + + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.childCount = function () { + return 0; + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.childAt = function (index) { + throw TypeScript.Errors.argumentOutOfRange('index'); + }; + + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.fullWidth = function () { + return getTriviaWidth(this._leadingTriviaInfo) + this.width() + getTriviaWidth(this._trailingTriviaInfo); + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.start = function () { + return this._fullStart + getTriviaWidth(this._leadingTriviaInfo); + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.end = function () { + return this.start() + this.width(); + }; + + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.width = function () { + return typeof this._textOrWidth === 'number' ? this._textOrWidth : this._textOrWidth.length; + }; + + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.text = function () { + if (typeof this._textOrWidth === 'number') { + this._textOrWidth = this._sourceText.substr(this.start(), this._textOrWidth, this.tokenKind === 11 /* IdentifierName */); + } + + return this._textOrWidth; + }; + + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.fullText = function () { + return this._sourceText.substr(this._fullStart, this.fullWidth(), false); + }; + + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.value = function () { + if ((this)._value === undefined) { + (this)._value = Syntax.value(this); + } + + return (this)._value; + }; + + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.valueText = function () { + if ((this)._valueText === undefined) { + (this)._valueText = Syntax.valueText(this); + } + + return (this)._valueText; + }; + + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.hasLeadingTrivia = function () { + return true; + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.hasLeadingComment = function () { + return hasTriviaComment(this._leadingTriviaInfo); + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.hasLeadingNewLine = function () { + return hasTriviaNewLine(this._leadingTriviaInfo); + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.hasLeadingSkippedText = function () { + return false; + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.leadingTriviaWidth = function () { + return getTriviaWidth(this._leadingTriviaInfo); + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.leadingTrivia = function () { + return TypeScript.Scanner.scanTrivia(this._sourceText, this._fullStart, getTriviaWidth(this._leadingTriviaInfo), false); + }; + + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.hasTrailingTrivia = function () { + return true; + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.hasTrailingComment = function () { + return hasTriviaComment(this._trailingTriviaInfo); + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.hasTrailingNewLine = function () { + return hasTriviaNewLine(this._trailingTriviaInfo); + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.hasTrailingSkippedText = function () { + return false; + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.trailingTriviaWidth = function () { + return getTriviaWidth(this._trailingTriviaInfo); + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.trailingTrivia = function () { + return TypeScript.Scanner.scanTrivia(this._sourceText, this.end(), getTriviaWidth(this._trailingTriviaInfo), true); + }; + + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.hasSkippedToken = function () { + return false; + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.toJSON = function (key) { + return Syntax.tokenToJSON(this); + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.firstToken = function () { + return this; + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.lastToken = function () { + return this; + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.isTypeScriptSpecific = function () { + return false; + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.isIncrementallyUnusable = function () { + return this.fullWidth() === 0 || TypeScript.SyntaxFacts.isAnyDivideOrRegularExpressionToken(this.tokenKind); + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.accept = function (visitor) { + return visitor.visitToken(this); + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.realize = function () { + return Syntax.realizeToken(this); + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.collectTextElements = function (elements) { + collectTokenTextElements(this, elements); + }; + + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.findTokenInternal = function (parent, position, fullStart) { + return new TypeScript.PositionedToken(parent, this, fullStart); + }; + + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.withLeadingTrivia = function (leadingTrivia) { + return this.realize().withLeadingTrivia(leadingTrivia); + }; + + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.withTrailingTrivia = function (trailingTrivia) { + return this.realize().withTrailingTrivia(trailingTrivia); + }; + return VariableWidthTokenWithLeadingAndTrailingTrivia; + })(); + Syntax.VariableWidthTokenWithLeadingAndTrailingTrivia = VariableWidthTokenWithLeadingAndTrailingTrivia; + + var FixedWidthTokenWithNoTrivia = (function () { + function FixedWidthTokenWithNoTrivia(kind) { + this.tokenKind = kind; + } + FixedWidthTokenWithNoTrivia.prototype.clone = function () { + return new FixedWidthTokenWithNoTrivia(this.tokenKind); + }; + + FixedWidthTokenWithNoTrivia.prototype.isNode = function () { + return false; + }; + FixedWidthTokenWithNoTrivia.prototype.isToken = function () { + return true; + }; + FixedWidthTokenWithNoTrivia.prototype.isList = function () { + return false; + }; + FixedWidthTokenWithNoTrivia.prototype.isSeparatedList = function () { + return false; + }; + + FixedWidthTokenWithNoTrivia.prototype.kind = function () { + return this.tokenKind; + }; + + FixedWidthTokenWithNoTrivia.prototype.childCount = function () { + return 0; + }; + FixedWidthTokenWithNoTrivia.prototype.childAt = function (index) { + throw TypeScript.Errors.argumentOutOfRange('index'); + }; + + FixedWidthTokenWithNoTrivia.prototype.fullWidth = function () { + return this.width(); + }; + FixedWidthTokenWithNoTrivia.prototype.width = function () { + return this.text().length; + }; + FixedWidthTokenWithNoTrivia.prototype.text = function () { + return TypeScript.SyntaxFacts.getText(this.tokenKind); + }; + FixedWidthTokenWithNoTrivia.prototype.fullText = function () { + return this.text(); + }; + + FixedWidthTokenWithNoTrivia.prototype.value = function () { + return Syntax.value(this); + }; + FixedWidthTokenWithNoTrivia.prototype.valueText = function () { + return Syntax.valueText(this); + }; + FixedWidthTokenWithNoTrivia.prototype.hasLeadingTrivia = function () { + return false; + }; + FixedWidthTokenWithNoTrivia.prototype.hasLeadingComment = function () { + return false; + }; + FixedWidthTokenWithNoTrivia.prototype.hasLeadingNewLine = function () { + return false; + }; + FixedWidthTokenWithNoTrivia.prototype.hasLeadingSkippedText = function () { + return false; + }; + FixedWidthTokenWithNoTrivia.prototype.leadingTriviaWidth = function () { + return 0; + }; + FixedWidthTokenWithNoTrivia.prototype.leadingTrivia = function () { + return TypeScript.Syntax.emptyTriviaList; + }; + + FixedWidthTokenWithNoTrivia.prototype.hasTrailingTrivia = function () { + return false; + }; + FixedWidthTokenWithNoTrivia.prototype.hasTrailingComment = function () { + return false; + }; + FixedWidthTokenWithNoTrivia.prototype.hasTrailingNewLine = function () { + return false; + }; + FixedWidthTokenWithNoTrivia.prototype.hasTrailingSkippedText = function () { + return false; + }; + FixedWidthTokenWithNoTrivia.prototype.trailingTriviaWidth = function () { + return 0; + }; + FixedWidthTokenWithNoTrivia.prototype.trailingTrivia = function () { + return TypeScript.Syntax.emptyTriviaList; + }; + + FixedWidthTokenWithNoTrivia.prototype.hasSkippedToken = function () { + return false; + }; + FixedWidthTokenWithNoTrivia.prototype.toJSON = function (key) { + return Syntax.tokenToJSON(this); + }; + FixedWidthTokenWithNoTrivia.prototype.firstToken = function () { + return this; + }; + FixedWidthTokenWithNoTrivia.prototype.lastToken = function () { + return this; + }; + FixedWidthTokenWithNoTrivia.prototype.isTypeScriptSpecific = function () { + return false; + }; + FixedWidthTokenWithNoTrivia.prototype.isIncrementallyUnusable = function () { + return this.fullWidth() === 0 || TypeScript.SyntaxFacts.isAnyDivideOrRegularExpressionToken(this.tokenKind); + }; + FixedWidthTokenWithNoTrivia.prototype.accept = function (visitor) { + return visitor.visitToken(this); + }; + FixedWidthTokenWithNoTrivia.prototype.realize = function () { + return Syntax.realizeToken(this); + }; + FixedWidthTokenWithNoTrivia.prototype.collectTextElements = function (elements) { + collectTokenTextElements(this, elements); + }; + + FixedWidthTokenWithNoTrivia.prototype.findTokenInternal = function (parent, position, fullStart) { + return new TypeScript.PositionedToken(parent, this, fullStart); + }; + + FixedWidthTokenWithNoTrivia.prototype.withLeadingTrivia = function (leadingTrivia) { + return this.realize().withLeadingTrivia(leadingTrivia); + }; + + FixedWidthTokenWithNoTrivia.prototype.withTrailingTrivia = function (trailingTrivia) { + return this.realize().withTrailingTrivia(trailingTrivia); + }; + return FixedWidthTokenWithNoTrivia; + })(); + Syntax.FixedWidthTokenWithNoTrivia = FixedWidthTokenWithNoTrivia; + + var FixedWidthTokenWithLeadingTrivia = (function () { + function FixedWidthTokenWithLeadingTrivia(sourceText, fullStart, kind, leadingTriviaInfo) { + this._sourceText = sourceText; + this._fullStart = fullStart; + this.tokenKind = kind; + this._leadingTriviaInfo = leadingTriviaInfo; + } + FixedWidthTokenWithLeadingTrivia.prototype.clone = function () { + return new FixedWidthTokenWithLeadingTrivia(this._sourceText, this._fullStart, this.tokenKind, this._leadingTriviaInfo); + }; + + FixedWidthTokenWithLeadingTrivia.prototype.isNode = function () { + return false; + }; + FixedWidthTokenWithLeadingTrivia.prototype.isToken = function () { + return true; + }; + FixedWidthTokenWithLeadingTrivia.prototype.isList = function () { + return false; + }; + FixedWidthTokenWithLeadingTrivia.prototype.isSeparatedList = function () { + return false; + }; + + FixedWidthTokenWithLeadingTrivia.prototype.kind = function () { + return this.tokenKind; + }; + + FixedWidthTokenWithLeadingTrivia.prototype.childCount = function () { + return 0; + }; + FixedWidthTokenWithLeadingTrivia.prototype.childAt = function (index) { + throw TypeScript.Errors.argumentOutOfRange('index'); + }; + + FixedWidthTokenWithLeadingTrivia.prototype.fullWidth = function () { + return getTriviaWidth(this._leadingTriviaInfo) + this.width(); + }; + FixedWidthTokenWithLeadingTrivia.prototype.start = function () { + return this._fullStart + getTriviaWidth(this._leadingTriviaInfo); + }; + FixedWidthTokenWithLeadingTrivia.prototype.end = function () { + return this.start() + this.width(); + }; + + FixedWidthTokenWithLeadingTrivia.prototype.width = function () { + return this.text().length; + }; + FixedWidthTokenWithLeadingTrivia.prototype.text = function () { + return TypeScript.SyntaxFacts.getText(this.tokenKind); + }; + FixedWidthTokenWithLeadingTrivia.prototype.fullText = function () { + return this._sourceText.substr(this._fullStart, this.fullWidth(), false); + }; + + FixedWidthTokenWithLeadingTrivia.prototype.value = function () { + return Syntax.value(this); + }; + FixedWidthTokenWithLeadingTrivia.prototype.valueText = function () { + return Syntax.valueText(this); + }; + FixedWidthTokenWithLeadingTrivia.prototype.hasLeadingTrivia = function () { + return true; + }; + FixedWidthTokenWithLeadingTrivia.prototype.hasLeadingComment = function () { + return hasTriviaComment(this._leadingTriviaInfo); + }; + FixedWidthTokenWithLeadingTrivia.prototype.hasLeadingNewLine = function () { + return hasTriviaNewLine(this._leadingTriviaInfo); + }; + FixedWidthTokenWithLeadingTrivia.prototype.hasLeadingSkippedText = function () { + return false; + }; + FixedWidthTokenWithLeadingTrivia.prototype.leadingTriviaWidth = function () { + return getTriviaWidth(this._leadingTriviaInfo); + }; + FixedWidthTokenWithLeadingTrivia.prototype.leadingTrivia = function () { + return TypeScript.Scanner.scanTrivia(this._sourceText, this._fullStart, getTriviaWidth(this._leadingTriviaInfo), false); + }; + + FixedWidthTokenWithLeadingTrivia.prototype.hasTrailingTrivia = function () { + return false; + }; + FixedWidthTokenWithLeadingTrivia.prototype.hasTrailingComment = function () { + return false; + }; + FixedWidthTokenWithLeadingTrivia.prototype.hasTrailingNewLine = function () { + return false; + }; + FixedWidthTokenWithLeadingTrivia.prototype.hasTrailingSkippedText = function () { + return false; + }; + FixedWidthTokenWithLeadingTrivia.prototype.trailingTriviaWidth = function () { + return 0; + }; + FixedWidthTokenWithLeadingTrivia.prototype.trailingTrivia = function () { + return TypeScript.Syntax.emptyTriviaList; + }; + + FixedWidthTokenWithLeadingTrivia.prototype.hasSkippedToken = function () { + return false; + }; + FixedWidthTokenWithLeadingTrivia.prototype.toJSON = function (key) { + return Syntax.tokenToJSON(this); + }; + FixedWidthTokenWithLeadingTrivia.prototype.firstToken = function () { + return this; + }; + FixedWidthTokenWithLeadingTrivia.prototype.lastToken = function () { + return this; + }; + FixedWidthTokenWithLeadingTrivia.prototype.isTypeScriptSpecific = function () { + return false; + }; + FixedWidthTokenWithLeadingTrivia.prototype.isIncrementallyUnusable = function () { + return this.fullWidth() === 0 || TypeScript.SyntaxFacts.isAnyDivideOrRegularExpressionToken(this.tokenKind); + }; + FixedWidthTokenWithLeadingTrivia.prototype.accept = function (visitor) { + return visitor.visitToken(this); + }; + FixedWidthTokenWithLeadingTrivia.prototype.realize = function () { + return Syntax.realizeToken(this); + }; + FixedWidthTokenWithLeadingTrivia.prototype.collectTextElements = function (elements) { + collectTokenTextElements(this, elements); + }; + + FixedWidthTokenWithLeadingTrivia.prototype.findTokenInternal = function (parent, position, fullStart) { + return new TypeScript.PositionedToken(parent, this, fullStart); + }; + + FixedWidthTokenWithLeadingTrivia.prototype.withLeadingTrivia = function (leadingTrivia) { + return this.realize().withLeadingTrivia(leadingTrivia); + }; + + FixedWidthTokenWithLeadingTrivia.prototype.withTrailingTrivia = function (trailingTrivia) { + return this.realize().withTrailingTrivia(trailingTrivia); + }; + return FixedWidthTokenWithLeadingTrivia; + })(); + Syntax.FixedWidthTokenWithLeadingTrivia = FixedWidthTokenWithLeadingTrivia; + + var FixedWidthTokenWithTrailingTrivia = (function () { + function FixedWidthTokenWithTrailingTrivia(sourceText, fullStart, kind, trailingTriviaInfo) { + this._sourceText = sourceText; + this._fullStart = fullStart; + this.tokenKind = kind; + this._trailingTriviaInfo = trailingTriviaInfo; + } + FixedWidthTokenWithTrailingTrivia.prototype.clone = function () { + return new FixedWidthTokenWithTrailingTrivia(this._sourceText, this._fullStart, this.tokenKind, this._trailingTriviaInfo); + }; + + FixedWidthTokenWithTrailingTrivia.prototype.isNode = function () { + return false; + }; + FixedWidthTokenWithTrailingTrivia.prototype.isToken = function () { + return true; + }; + FixedWidthTokenWithTrailingTrivia.prototype.isList = function () { + return false; + }; + FixedWidthTokenWithTrailingTrivia.prototype.isSeparatedList = function () { + return false; + }; + + FixedWidthTokenWithTrailingTrivia.prototype.kind = function () { + return this.tokenKind; + }; + + FixedWidthTokenWithTrailingTrivia.prototype.childCount = function () { + return 0; + }; + FixedWidthTokenWithTrailingTrivia.prototype.childAt = function (index) { + throw TypeScript.Errors.argumentOutOfRange('index'); + }; + + FixedWidthTokenWithTrailingTrivia.prototype.fullWidth = function () { + return this.width() + getTriviaWidth(this._trailingTriviaInfo); + }; + FixedWidthTokenWithTrailingTrivia.prototype.start = function () { + return this._fullStart; + }; + FixedWidthTokenWithTrailingTrivia.prototype.end = function () { + return this.start() + this.width(); + }; + + FixedWidthTokenWithTrailingTrivia.prototype.width = function () { + return this.text().length; + }; + FixedWidthTokenWithTrailingTrivia.prototype.text = function () { + return TypeScript.SyntaxFacts.getText(this.tokenKind); + }; + FixedWidthTokenWithTrailingTrivia.prototype.fullText = function () { + return this._sourceText.substr(this._fullStart, this.fullWidth(), false); + }; + + FixedWidthTokenWithTrailingTrivia.prototype.value = function () { + return Syntax.value(this); + }; + FixedWidthTokenWithTrailingTrivia.prototype.valueText = function () { + return Syntax.valueText(this); + }; + FixedWidthTokenWithTrailingTrivia.prototype.hasLeadingTrivia = function () { + return false; + }; + FixedWidthTokenWithTrailingTrivia.prototype.hasLeadingComment = function () { + return false; + }; + FixedWidthTokenWithTrailingTrivia.prototype.hasLeadingNewLine = function () { + return false; + }; + FixedWidthTokenWithTrailingTrivia.prototype.hasLeadingSkippedText = function () { + return false; + }; + FixedWidthTokenWithTrailingTrivia.prototype.leadingTriviaWidth = function () { + return 0; + }; + FixedWidthTokenWithTrailingTrivia.prototype.leadingTrivia = function () { + return TypeScript.Syntax.emptyTriviaList; + }; + + FixedWidthTokenWithTrailingTrivia.prototype.hasTrailingTrivia = function () { + return true; + }; + FixedWidthTokenWithTrailingTrivia.prototype.hasTrailingComment = function () { + return hasTriviaComment(this._trailingTriviaInfo); + }; + FixedWidthTokenWithTrailingTrivia.prototype.hasTrailingNewLine = function () { + return hasTriviaNewLine(this._trailingTriviaInfo); + }; + FixedWidthTokenWithTrailingTrivia.prototype.hasTrailingSkippedText = function () { + return false; + }; + FixedWidthTokenWithTrailingTrivia.prototype.trailingTriviaWidth = function () { + return getTriviaWidth(this._trailingTriviaInfo); + }; + FixedWidthTokenWithTrailingTrivia.prototype.trailingTrivia = function () { + return TypeScript.Scanner.scanTrivia(this._sourceText, this.end(), getTriviaWidth(this._trailingTriviaInfo), true); + }; + + FixedWidthTokenWithTrailingTrivia.prototype.hasSkippedToken = function () { + return false; + }; + FixedWidthTokenWithTrailingTrivia.prototype.toJSON = function (key) { + return Syntax.tokenToJSON(this); + }; + FixedWidthTokenWithTrailingTrivia.prototype.firstToken = function () { + return this; + }; + FixedWidthTokenWithTrailingTrivia.prototype.lastToken = function () { + return this; + }; + FixedWidthTokenWithTrailingTrivia.prototype.isTypeScriptSpecific = function () { + return false; + }; + FixedWidthTokenWithTrailingTrivia.prototype.isIncrementallyUnusable = function () { + return this.fullWidth() === 0 || TypeScript.SyntaxFacts.isAnyDivideOrRegularExpressionToken(this.tokenKind); + }; + FixedWidthTokenWithTrailingTrivia.prototype.accept = function (visitor) { + return visitor.visitToken(this); + }; + FixedWidthTokenWithTrailingTrivia.prototype.realize = function () { + return Syntax.realizeToken(this); + }; + FixedWidthTokenWithTrailingTrivia.prototype.collectTextElements = function (elements) { + collectTokenTextElements(this, elements); + }; + + FixedWidthTokenWithTrailingTrivia.prototype.findTokenInternal = function (parent, position, fullStart) { + return new TypeScript.PositionedToken(parent, this, fullStart); + }; + + FixedWidthTokenWithTrailingTrivia.prototype.withLeadingTrivia = function (leadingTrivia) { + return this.realize().withLeadingTrivia(leadingTrivia); + }; + + FixedWidthTokenWithTrailingTrivia.prototype.withTrailingTrivia = function (trailingTrivia) { + return this.realize().withTrailingTrivia(trailingTrivia); + }; + return FixedWidthTokenWithTrailingTrivia; + })(); + Syntax.FixedWidthTokenWithTrailingTrivia = FixedWidthTokenWithTrailingTrivia; + + var FixedWidthTokenWithLeadingAndTrailingTrivia = (function () { + function FixedWidthTokenWithLeadingAndTrailingTrivia(sourceText, fullStart, kind, leadingTriviaInfo, trailingTriviaInfo) { + this._sourceText = sourceText; + this._fullStart = fullStart; + this.tokenKind = kind; + this._leadingTriviaInfo = leadingTriviaInfo; + this._trailingTriviaInfo = trailingTriviaInfo; + } + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.clone = function () { + return new FixedWidthTokenWithLeadingAndTrailingTrivia(this._sourceText, this._fullStart, this.tokenKind, this._leadingTriviaInfo, this._trailingTriviaInfo); + }; + + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.isNode = function () { + return false; + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.isToken = function () { + return true; + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.isList = function () { + return false; + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.isSeparatedList = function () { + return false; + }; + + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.kind = function () { + return this.tokenKind; + }; + + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.childCount = function () { + return 0; + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.childAt = function (index) { + throw TypeScript.Errors.argumentOutOfRange('index'); + }; + + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.fullWidth = function () { + return getTriviaWidth(this._leadingTriviaInfo) + this.width() + getTriviaWidth(this._trailingTriviaInfo); + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.start = function () { + return this._fullStart + getTriviaWidth(this._leadingTriviaInfo); + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.end = function () { + return this.start() + this.width(); + }; + + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.width = function () { + return this.text().length; + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.text = function () { + return TypeScript.SyntaxFacts.getText(this.tokenKind); + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.fullText = function () { + return this._sourceText.substr(this._fullStart, this.fullWidth(), false); + }; + + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.value = function () { + return Syntax.value(this); + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.valueText = function () { + return Syntax.valueText(this); + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.hasLeadingTrivia = function () { + return true; + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.hasLeadingComment = function () { + return hasTriviaComment(this._leadingTriviaInfo); + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.hasLeadingNewLine = function () { + return hasTriviaNewLine(this._leadingTriviaInfo); + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.hasLeadingSkippedText = function () { + return false; + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.leadingTriviaWidth = function () { + return getTriviaWidth(this._leadingTriviaInfo); + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.leadingTrivia = function () { + return TypeScript.Scanner.scanTrivia(this._sourceText, this._fullStart, getTriviaWidth(this._leadingTriviaInfo), false); + }; + + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.hasTrailingTrivia = function () { + return true; + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.hasTrailingComment = function () { + return hasTriviaComment(this._trailingTriviaInfo); + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.hasTrailingNewLine = function () { + return hasTriviaNewLine(this._trailingTriviaInfo); + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.hasTrailingSkippedText = function () { + return false; + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.trailingTriviaWidth = function () { + return getTriviaWidth(this._trailingTriviaInfo); + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.trailingTrivia = function () { + return TypeScript.Scanner.scanTrivia(this._sourceText, this.end(), getTriviaWidth(this._trailingTriviaInfo), true); + }; + + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.hasSkippedToken = function () { + return false; + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.toJSON = function (key) { + return Syntax.tokenToJSON(this); + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.firstToken = function () { + return this; + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.lastToken = function () { + return this; + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.isTypeScriptSpecific = function () { + return false; + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.isIncrementallyUnusable = function () { + return this.fullWidth() === 0 || TypeScript.SyntaxFacts.isAnyDivideOrRegularExpressionToken(this.tokenKind); + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.accept = function (visitor) { + return visitor.visitToken(this); + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.realize = function () { + return Syntax.realizeToken(this); + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.collectTextElements = function (elements) { + collectTokenTextElements(this, elements); + }; + + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.findTokenInternal = function (parent, position, fullStart) { + return new TypeScript.PositionedToken(parent, this, fullStart); + }; + + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.withLeadingTrivia = function (leadingTrivia) { + return this.realize().withLeadingTrivia(leadingTrivia); + }; + + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.withTrailingTrivia = function (trailingTrivia) { + return this.realize().withTrailingTrivia(trailingTrivia); + }; + return FixedWidthTokenWithLeadingAndTrailingTrivia; + })(); + Syntax.FixedWidthTokenWithLeadingAndTrailingTrivia = FixedWidthTokenWithLeadingAndTrailingTrivia; + + function collectTokenTextElements(token, elements) { + token.leadingTrivia().collectTextElements(elements); + elements.push(token.text()); + token.trailingTrivia().collectTextElements(elements); + } + + function fixedWidthToken(sourceText, fullStart, kind, leadingTriviaInfo, trailingTriviaInfo) { + if (leadingTriviaInfo === 0) { + if (trailingTriviaInfo === 0) { + return new FixedWidthTokenWithNoTrivia(kind); + } else { + return new FixedWidthTokenWithTrailingTrivia(sourceText, fullStart, kind, trailingTriviaInfo); + } + } else if (trailingTriviaInfo === 0) { + return new FixedWidthTokenWithLeadingTrivia(sourceText, fullStart, kind, leadingTriviaInfo); + } else { + return new FixedWidthTokenWithLeadingAndTrailingTrivia(sourceText, fullStart, kind, leadingTriviaInfo, trailingTriviaInfo); + } + } + Syntax.fixedWidthToken = fixedWidthToken; + + function variableWidthToken(sourceText, fullStart, kind, leadingTriviaInfo, width, trailingTriviaInfo) { + if (leadingTriviaInfo === 0) { + if (trailingTriviaInfo === 0) { + return new VariableWidthTokenWithNoTrivia(sourceText, fullStart, kind, width); + } else { + return new VariableWidthTokenWithTrailingTrivia(sourceText, fullStart, kind, width, trailingTriviaInfo); + } + } else if (trailingTriviaInfo === 0) { + return new VariableWidthTokenWithLeadingTrivia(sourceText, fullStart, kind, leadingTriviaInfo, width); + } else { + return new VariableWidthTokenWithLeadingAndTrailingTrivia(sourceText, fullStart, kind, leadingTriviaInfo, width, trailingTriviaInfo); + } + } + Syntax.variableWidthToken = variableWidthToken; + + function getTriviaWidth(value) { + return value >>> 2 /* TriviaFullWidthShift */; + } + + function hasTriviaComment(value) { + return (value & 2 /* TriviaCommentMask */) !== 0; + } + + function hasTriviaNewLine(value) { + return (value & 1 /* TriviaNewLineMask */) !== 0; + } + })(TypeScript.Syntax || (TypeScript.Syntax = {})); + var Syntax = TypeScript.Syntax; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (Syntax) { + function realizeToken(token) { + return new RealizedToken(token.tokenKind, token.leadingTrivia(), token.text(), token.value(), token.valueText(), token.trailingTrivia()); + } + Syntax.realizeToken = realizeToken; + + function convertToIdentifierName(token) { + TypeScript.Debug.assert(TypeScript.SyntaxFacts.isAnyKeyword(token.tokenKind)); + return new RealizedToken(11 /* IdentifierName */, token.leadingTrivia(), token.text(), token.text(), token.text(), token.trailingTrivia()); + } + Syntax.convertToIdentifierName = convertToIdentifierName; + + function tokenToJSON(token) { + var result = {}; + + for (var name in TypeScript.SyntaxKind) { + if (TypeScript.SyntaxKind[name] === token.kind()) { + result.kind = name; + break; + } + } + + result.width = token.width(); + if (token.fullWidth() !== token.width()) { + result.fullWidth = token.fullWidth(); + } + + result.text = token.text(); + + var value = token.value(); + if (value !== null) { + result.value = value; + result.valueText = token.valueText(); + } + + if (token.hasLeadingTrivia()) { + result.hasLeadingTrivia = true; + } + + if (token.hasLeadingComment()) { + result.hasLeadingComment = true; + } + + if (token.hasLeadingNewLine()) { + result.hasLeadingNewLine = true; + } + + if (token.hasLeadingSkippedText()) { + result.hasLeadingSkippedText = true; + } + + if (token.hasTrailingTrivia()) { + result.hasTrailingTrivia = true; + } + + if (token.hasTrailingComment()) { + result.hasTrailingComment = true; + } + + if (token.hasTrailingNewLine()) { + result.hasTrailingNewLine = true; + } + + if (token.hasTrailingSkippedText()) { + result.hasTrailingSkippedText = true; + } + + var trivia = token.leadingTrivia(); + if (trivia.count() > 0) { + result.leadingTrivia = trivia; + } + + trivia = token.trailingTrivia(); + if (trivia.count() > 0) { + result.trailingTrivia = trivia; + } + + return result; + } + Syntax.tokenToJSON = tokenToJSON; + + function value(token) { + return value1(token.tokenKind, token.text()); + } + Syntax.value = value; + + function hexValue(text, start, length) { + var intChar = 0; + for (var i = 0; i < length; i++) { + var ch2 = text.charCodeAt(start + i); + if (!TypeScript.CharacterInfo.isHexDigit(ch2)) { + break; + } + + intChar = (intChar << 4) + TypeScript.CharacterInfo.hexValue(ch2); + } + + return intChar; + } + + var characterArray = []; + + function convertEscapes(text) { + characterArray.length = 0; + var result = ""; + + for (var i = 0, n = text.length; i < n; i++) { + var ch = text.charCodeAt(i); + + if (ch === 92 /* backslash */) { + i++; + if (i < n) { + ch = text.charCodeAt(i); + switch (ch) { + case 48 /* _0 */: + characterArray.push(0 /* nullCharacter */); + continue; + + case 98 /* b */: + characterArray.push(8 /* backspace */); + continue; + + case 102 /* f */: + characterArray.push(12 /* formFeed */); + continue; + + case 110 /* n */: + characterArray.push(10 /* lineFeed */); + continue; + + case 114 /* r */: + characterArray.push(13 /* carriageReturn */); + continue; + + case 116 /* t */: + characterArray.push(9 /* tab */); + continue; + + case 118 /* v */: + characterArray.push(11 /* verticalTab */); + continue; + + case 120 /* x */: + characterArray.push(hexValue(text, i + 1, 2)); + i += 2; + continue; + + case 117 /* u */: + characterArray.push(hexValue(text, i + 1, 4)); + i += 4; + continue; + + default: + } + } + } + + characterArray.push(ch); + + if (i && !(i % 1024)) { + result = result.concat(String.fromCharCode.apply(null, characterArray)); + characterArray.length = 0; + } + } + + if (characterArray.length) { + result = result.concat(String.fromCharCode.apply(null, characterArray)); + } + + return result; + } + + function massageEscapes(text) { + return text.indexOf("\\") >= 0 ? convertEscapes(text) : text; + } + Syntax.massageEscapes = massageEscapes; + + function value1(kind, text) { + if (kind === 11 /* IdentifierName */) { + return massageEscapes(text); + } + + switch (kind) { + case 37 /* TrueKeyword */: + return true; + case 24 /* FalseKeyword */: + return false; + case 32 /* NullKeyword */: + return null; + } + + if (TypeScript.SyntaxFacts.isAnyKeyword(kind) || TypeScript.SyntaxFacts.isAnyPunctuation(kind)) { + return TypeScript.SyntaxFacts.getText(kind); + } + + if (kind === 13 /* NumericLiteral */) { + return Syntax.isHexInteger(text) ? parseInt(text, 16) : parseFloat(text); + } else if (kind === 14 /* StringLiteral */) { + if (text.length > 1 && text.charCodeAt(text.length - 1) === text.charCodeAt(0)) { + return massageEscapes(text.substr(1, text.length - 2)); + } else { + return massageEscapes(text.substr(1)); + } + } else if (kind === 12 /* RegularExpressionLiteral */) { + 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 null; + } + } else if (kind === 10 /* EndOfFileToken */ || kind === 9 /* ErrorToken */) { + return null; + } else { + throw TypeScript.Errors.invalidOperation(); + } + } + + function valueText1(kind, text) { + var value = value1(kind, text); + return value === null ? "" : value.toString(); + } + + function valueText(token) { + var value = token.value(); + return value === null ? "" : value.toString(); + } + Syntax.valueText = valueText; + + var EmptyToken = (function () { + function EmptyToken(kind) { + this.tokenKind = kind; + } + EmptyToken.prototype.clone = function () { + return new EmptyToken(this.tokenKind); + }; + + EmptyToken.prototype.kind = function () { + return this.tokenKind; + }; + + EmptyToken.prototype.isToken = function () { + return true; + }; + EmptyToken.prototype.isNode = function () { + return false; + }; + EmptyToken.prototype.isList = function () { + return false; + }; + EmptyToken.prototype.isSeparatedList = function () { + return false; + }; + + EmptyToken.prototype.childCount = function () { + return 0; + }; + + EmptyToken.prototype.childAt = function (index) { + throw TypeScript.Errors.argumentOutOfRange("index"); + }; + + EmptyToken.prototype.toJSON = function (key) { + return tokenToJSON(this); + }; + EmptyToken.prototype.accept = function (visitor) { + return visitor.visitToken(this); + }; + + EmptyToken.prototype.findTokenInternal = function (parent, position, fullStart) { + return new TypeScript.PositionedToken(parent, this, fullStart); + }; + + EmptyToken.prototype.firstToken = function () { + return this; + }; + EmptyToken.prototype.lastToken = function () { + return this; + }; + EmptyToken.prototype.isTypeScriptSpecific = function () { + return false; + }; + + EmptyToken.prototype.isIncrementallyUnusable = function () { + return true; + }; + + EmptyToken.prototype.fullWidth = function () { + return 0; + }; + EmptyToken.prototype.width = function () { + return 0; + }; + EmptyToken.prototype.text = function () { + return ""; + }; + EmptyToken.prototype.fullText = function () { + return ""; + }; + EmptyToken.prototype.value = function () { + return null; + }; + EmptyToken.prototype.valueText = function () { + return ""; + }; + + EmptyToken.prototype.hasLeadingTrivia = function () { + return false; + }; + EmptyToken.prototype.hasLeadingComment = function () { + return false; + }; + EmptyToken.prototype.hasLeadingNewLine = function () { + return false; + }; + EmptyToken.prototype.hasLeadingSkippedText = function () { + return false; + }; + EmptyToken.prototype.leadingTriviaWidth = function () { + return 0; + }; + EmptyToken.prototype.hasTrailingTrivia = function () { + return false; + }; + EmptyToken.prototype.hasTrailingComment = function () { + return false; + }; + EmptyToken.prototype.hasTrailingNewLine = function () { + return false; + }; + EmptyToken.prototype.hasTrailingSkippedText = function () { + return false; + }; + EmptyToken.prototype.hasSkippedToken = function () { + return false; + }; + + EmptyToken.prototype.trailingTriviaWidth = function () { + return 0; + }; + EmptyToken.prototype.leadingTrivia = function () { + return TypeScript.Syntax.emptyTriviaList; + }; + EmptyToken.prototype.trailingTrivia = function () { + return TypeScript.Syntax.emptyTriviaList; + }; + EmptyToken.prototype.realize = function () { + return realizeToken(this); + }; + EmptyToken.prototype.collectTextElements = function (elements) { + }; + + EmptyToken.prototype.withLeadingTrivia = function (leadingTrivia) { + return this.realize().withLeadingTrivia(leadingTrivia); + }; + + EmptyToken.prototype.withTrailingTrivia = function (trailingTrivia) { + return this.realize().withTrailingTrivia(trailingTrivia); + }; + return EmptyToken; + })(); + + function emptyToken(kind) { + return new EmptyToken(kind); + } + Syntax.emptyToken = emptyToken; + + var RealizedToken = (function () { + function RealizedToken(tokenKind, leadingTrivia, text, value, valueText, trailingTrivia) { + this.tokenKind = tokenKind; + this._leadingTrivia = leadingTrivia; + this._text = text; + this._value = value; + this._valueText = valueText; + this._trailingTrivia = trailingTrivia; + } + RealizedToken.prototype.clone = function () { + return new RealizedToken(this.tokenKind, this._leadingTrivia, this._text, this._value, this._valueText, this._trailingTrivia); + }; + + RealizedToken.prototype.kind = function () { + return this.tokenKind; + }; + RealizedToken.prototype.toJSON = function (key) { + return tokenToJSON(this); + }; + RealizedToken.prototype.firstToken = function () { + return this; + }; + RealizedToken.prototype.lastToken = function () { + return this; + }; + RealizedToken.prototype.isTypeScriptSpecific = function () { + return false; + }; + + RealizedToken.prototype.isIncrementallyUnusable = function () { + return true; + }; + + RealizedToken.prototype.accept = function (visitor) { + return visitor.visitToken(this); + }; + + RealizedToken.prototype.childCount = function () { + return 0; + }; + + RealizedToken.prototype.childAt = function (index) { + throw TypeScript.Errors.argumentOutOfRange("index"); + }; + + RealizedToken.prototype.isToken = function () { + return true; + }; + RealizedToken.prototype.isNode = function () { + return false; + }; + RealizedToken.prototype.isList = function () { + return false; + }; + RealizedToken.prototype.isSeparatedList = function () { + return false; + }; + RealizedToken.prototype.isTrivia = function () { + return false; + }; + RealizedToken.prototype.isTriviaList = function () { + return false; + }; + + RealizedToken.prototype.fullWidth = function () { + return this._leadingTrivia.fullWidth() + this.width() + this._trailingTrivia.fullWidth(); + }; + RealizedToken.prototype.width = function () { + return this.text().length; + }; + + RealizedToken.prototype.text = function () { + return this._text; + }; + RealizedToken.prototype.fullText = function () { + return this._leadingTrivia.fullText() + this.text() + this._trailingTrivia.fullText(); + }; + + RealizedToken.prototype.value = function () { + return this._value; + }; + RealizedToken.prototype.valueText = function () { + return this._valueText; + }; + + RealizedToken.prototype.hasLeadingTrivia = function () { + return this._leadingTrivia.count() > 0; + }; + RealizedToken.prototype.hasLeadingComment = function () { + return this._leadingTrivia.hasComment(); + }; + RealizedToken.prototype.hasLeadingNewLine = function () { + return this._leadingTrivia.hasNewLine(); + }; + RealizedToken.prototype.hasLeadingSkippedText = function () { + return this._leadingTrivia.hasSkippedToken(); + }; + RealizedToken.prototype.leadingTriviaWidth = function () { + return this._leadingTrivia.fullWidth(); + }; + + RealizedToken.prototype.hasTrailingTrivia = function () { + return this._trailingTrivia.count() > 0; + }; + RealizedToken.prototype.hasTrailingComment = function () { + return this._trailingTrivia.hasComment(); + }; + RealizedToken.prototype.hasTrailingNewLine = function () { + return this._trailingTrivia.hasNewLine(); + }; + RealizedToken.prototype.hasTrailingSkippedText = function () { + return this._trailingTrivia.hasSkippedToken(); + }; + RealizedToken.prototype.trailingTriviaWidth = function () { + return this._trailingTrivia.fullWidth(); + }; + + RealizedToken.prototype.hasSkippedToken = function () { + return this.hasLeadingSkippedText() || this.hasTrailingSkippedText(); + }; + + RealizedToken.prototype.leadingTrivia = function () { + return this._leadingTrivia; + }; + RealizedToken.prototype.trailingTrivia = function () { + return this._trailingTrivia; + }; + + RealizedToken.prototype.findTokenInternal = function (parent, position, fullStart) { + return new TypeScript.PositionedToken(parent, this, fullStart); + }; + + RealizedToken.prototype.collectTextElements = function (elements) { + this.leadingTrivia().collectTextElements(elements); + elements.push(this.text()); + this.trailingTrivia().collectTextElements(elements); + }; + + RealizedToken.prototype.withLeadingTrivia = function (leadingTrivia) { + return new RealizedToken(this.tokenKind, leadingTrivia, this._text, this._value, this._valueText, this._trailingTrivia); + }; + + RealizedToken.prototype.withTrailingTrivia = function (trailingTrivia) { + return new RealizedToken(this.tokenKind, this._leadingTrivia, this._text, this._value, this._valueText, trailingTrivia); + }; + return RealizedToken; + })(); + + function token(kind, info) { + if (typeof info === "undefined") { info = null; } + var text = (info !== null && info.text !== undefined) ? info.text : TypeScript.SyntaxFacts.getText(kind); + + return new RealizedToken(kind, TypeScript.Syntax.triviaList(info === null ? null : info.leadingTrivia), text, value1(kind, text), valueText1(kind, text), TypeScript.Syntax.triviaList(info === null ? null : info.trailingTrivia)); + } + Syntax.token = token; + + function identifier(text, info) { + if (typeof info === "undefined") { info = null; } + info = info || {}; + info.text = text; + return token(11 /* IdentifierName */, info); + } + Syntax.identifier = identifier; + })(TypeScript.Syntax || (TypeScript.Syntax = {})); + var Syntax = TypeScript.Syntax; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var SyntaxTokenReplacer = (function (_super) { + __extends(SyntaxTokenReplacer, _super); + function SyntaxTokenReplacer(token1, token2) { + _super.call(this); + this.token1 = token1; + this.token2 = token2; + } + SyntaxTokenReplacer.prototype.visitToken = function (token) { + if (token === this.token1) { + var result = this.token2; + this.token1 = null; + this.token2 = null; + + return result; + } + + return token; + }; + + SyntaxTokenReplacer.prototype.visitNode = function (node) { + if (this.token1 === null) { + return node; + } + + return _super.prototype.visitNode.call(this, node); + }; + + SyntaxTokenReplacer.prototype.visitList = function (list) { + if (this.token1 === null) { + return list; + } + + return _super.prototype.visitList.call(this, list); + }; + + SyntaxTokenReplacer.prototype.visitSeparatedList = function (list) { + if (this.token1 === null) { + return list; + } + + return _super.prototype.visitSeparatedList.call(this, list); + }; + return SyntaxTokenReplacer; + })(TypeScript.SyntaxRewriter); + TypeScript.SyntaxTokenReplacer = SyntaxTokenReplacer; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (Syntax) { + var SyntaxTrivia = (function () { + function SyntaxTrivia(kind, textOrToken) { + this._kind = kind; + this._textOrToken = textOrToken; + } + SyntaxTrivia.prototype.toJSON = function (key) { + var result = {}; + result.kind = TypeScript.SyntaxKind[this._kind]; + + if (this.isSkippedToken()) { + result.skippedToken = this._textOrToken; + } else { + result.text = this._textOrToken; + } + return result; + }; + + SyntaxTrivia.prototype.kind = function () { + return this._kind; + }; + + SyntaxTrivia.prototype.fullWidth = function () { + return this.fullText().length; + }; + + SyntaxTrivia.prototype.fullText = function () { + return this.isSkippedToken() ? this.skippedToken().fullText() : this._textOrToken; + }; + + SyntaxTrivia.prototype.isWhitespace = function () { + return this.kind() === 4 /* WhitespaceTrivia */; + }; + + SyntaxTrivia.prototype.isComment = function () { + return this.kind() === 7 /* SingleLineCommentTrivia */ || this.kind() === 6 /* MultiLineCommentTrivia */; + }; + + SyntaxTrivia.prototype.isNewLine = function () { + return this.kind() === 5 /* NewLineTrivia */; + }; + + SyntaxTrivia.prototype.isSkippedToken = function () { + return this.kind() === 8 /* SkippedTokenTrivia */; + }; + + SyntaxTrivia.prototype.skippedToken = function () { + TypeScript.Debug.assert(this.isSkippedToken()); + return this._textOrToken; + }; + + SyntaxTrivia.prototype.collectTextElements = function (elements) { + elements.push(this.fullText()); + }; + return SyntaxTrivia; + })(); + + function trivia(kind, text) { + return new SyntaxTrivia(kind, text); + } + Syntax.trivia = trivia; + + function skippedTokenTrivia(token) { + TypeScript.Debug.assert(!token.hasLeadingTrivia()); + TypeScript.Debug.assert(!token.hasTrailingTrivia()); + TypeScript.Debug.assert(token.fullWidth() > 0); + return new SyntaxTrivia(8 /* SkippedTokenTrivia */, token); + } + Syntax.skippedTokenTrivia = skippedTokenTrivia; + + function spaces(count) { + return trivia(4 /* WhitespaceTrivia */, TypeScript.StringUtilities.repeat(" ", count)); + } + Syntax.spaces = spaces; + + function whitespace(text) { + return trivia(4 /* WhitespaceTrivia */, text); + } + Syntax.whitespace = whitespace; + + function multiLineComment(text) { + return trivia(6 /* MultiLineCommentTrivia */, text); + } + Syntax.multiLineComment = multiLineComment; + + function singleLineComment(text) { + return trivia(7 /* SingleLineCommentTrivia */, text); + } + Syntax.singleLineComment = singleLineComment; + + Syntax.spaceTrivia = spaces(1); + Syntax.lineFeedTrivia = trivia(5 /* NewLineTrivia */, "\n"); + Syntax.carriageReturnTrivia = trivia(5 /* NewLineTrivia */, "\r"); + Syntax.carriageReturnLineFeedTrivia = trivia(5 /* NewLineTrivia */, "\r\n"); + + function splitMultiLineCommentTriviaIntoMultipleLines(trivia) { + var result = []; + + var triviaText = trivia.fullText(); + var currentIndex = 0; + + for (var i = 0; i < triviaText.length; i++) { + var ch = triviaText.charCodeAt(i); + + var isCarriageReturnLineFeed = false; + switch (ch) { + case 13 /* carriageReturn */: + if (i < triviaText.length - 1 && triviaText.charCodeAt(i + 1) === 10 /* lineFeed */) { + i++; + } + + case 10 /* lineFeed */: + case 8233 /* paragraphSeparator */: + case 8232 /* lineSeparator */: + result.push(triviaText.substring(currentIndex, i + 1)); + + currentIndex = i + 1; + continue; + } + } + + result.push(triviaText.substring(currentIndex)); + return result; + } + Syntax.splitMultiLineCommentTriviaIntoMultipleLines = splitMultiLineCommentTriviaIntoMultipleLines; + })(TypeScript.Syntax || (TypeScript.Syntax = {})); + var Syntax = TypeScript.Syntax; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (Syntax) { + Syntax.emptyTriviaList = { + kind: function () { + return 3 /* TriviaList */; + }, + count: function () { + return 0; + }, + syntaxTriviaAt: function (index) { + throw TypeScript.Errors.argumentOutOfRange("index"); + }, + last: function () { + throw TypeScript.Errors.argumentOutOfRange("index"); + }, + fullWidth: function () { + return 0; + }, + fullText: function () { + return ""; + }, + hasComment: function () { + return false; + }, + hasNewLine: function () { + return false; + }, + hasSkippedToken: function () { + return false; + }, + toJSON: function (key) { + return []; + }, + collectTextElements: function (elements) { + }, + toArray: function () { + return []; + }, + concat: function (trivia) { + return trivia; + } + }; + + function concatTrivia(list1, list2) { + if (list1.count() === 0) { + return list2; + } + + if (list2.count() === 0) { + return list1; + } + + var trivia = list1.toArray(); + trivia.push.apply(trivia, list2.toArray()); + + return triviaList(trivia); + } + + function isComment(trivia) { + return trivia.kind() === 6 /* MultiLineCommentTrivia */ || trivia.kind() === 7 /* SingleLineCommentTrivia */; + } + + var SingletonSyntaxTriviaList = (function () { + function SingletonSyntaxTriviaList(item) { + this.item = item; + } + SingletonSyntaxTriviaList.prototype.kind = function () { + return 3 /* TriviaList */; + }; + + SingletonSyntaxTriviaList.prototype.count = function () { + return 1; + }; + + SingletonSyntaxTriviaList.prototype.syntaxTriviaAt = function (index) { + if (index !== 0) { + throw TypeScript.Errors.argumentOutOfRange("index"); + } + + return this.item; + }; + + SingletonSyntaxTriviaList.prototype.last = function () { + return this.item; + }; + + SingletonSyntaxTriviaList.prototype.fullWidth = function () { + return this.item.fullWidth(); + }; + + SingletonSyntaxTriviaList.prototype.fullText = function () { + return this.item.fullText(); + }; + + SingletonSyntaxTriviaList.prototype.hasComment = function () { + return isComment(this.item); + }; + + SingletonSyntaxTriviaList.prototype.hasNewLine = function () { + return this.item.kind() === 5 /* NewLineTrivia */; + }; + + SingletonSyntaxTriviaList.prototype.hasSkippedToken = function () { + return this.item.kind() === 8 /* SkippedTokenTrivia */; + }; + + SingletonSyntaxTriviaList.prototype.toJSON = function (key) { + return [this.item]; + }; + + SingletonSyntaxTriviaList.prototype.collectTextElements = function (elements) { + (this.item).collectTextElements(elements); + }; + + SingletonSyntaxTriviaList.prototype.toArray = function () { + return [this.item]; + }; + + SingletonSyntaxTriviaList.prototype.concat = function (trivia) { + return concatTrivia(this, trivia); + }; + return SingletonSyntaxTriviaList; + })(); + + var NormalSyntaxTriviaList = (function () { + function NormalSyntaxTriviaList(trivia) { + this.trivia = trivia; + } + NormalSyntaxTriviaList.prototype.kind = function () { + return 3 /* TriviaList */; + }; + + NormalSyntaxTriviaList.prototype.count = function () { + return this.trivia.length; + }; + + NormalSyntaxTriviaList.prototype.syntaxTriviaAt = function (index) { + if (index < 0 || index >= this.trivia.length) { + throw TypeScript.Errors.argumentOutOfRange("index"); + } + + return this.trivia[index]; + }; + + NormalSyntaxTriviaList.prototype.last = function () { + return this.trivia[this.trivia.length - 1]; + }; + + NormalSyntaxTriviaList.prototype.fullWidth = function () { + return TypeScript.ArrayUtilities.sum(this.trivia, function (t) { + return t.fullWidth(); + }); + }; + + NormalSyntaxTriviaList.prototype.fullText = function () { + var result = ""; + + for (var i = 0, n = this.trivia.length; i < n; i++) { + result += this.trivia[i].fullText(); + } + + return result; + }; + + NormalSyntaxTriviaList.prototype.hasComment = function () { + for (var i = 0; i < this.trivia.length; i++) { + if (isComment(this.trivia[i])) { + return true; + } + } + + return false; + }; + + NormalSyntaxTriviaList.prototype.hasNewLine = function () { + for (var i = 0; i < this.trivia.length; i++) { + if (this.trivia[i].kind() === 5 /* NewLineTrivia */) { + return true; + } + } + + return false; + }; + + NormalSyntaxTriviaList.prototype.hasSkippedToken = function () { + for (var i = 0; i < this.trivia.length; i++) { + if (this.trivia[i].kind() === 8 /* SkippedTokenTrivia */) { + return true; + } + } + + return false; + }; + + NormalSyntaxTriviaList.prototype.toJSON = function (key) { + return this.trivia; + }; + + NormalSyntaxTriviaList.prototype.collectTextElements = function (elements) { + for (var i = 0; i < this.trivia.length; i++) { + (this.trivia[i]).collectTextElements(elements); + } + }; + + NormalSyntaxTriviaList.prototype.toArray = function () { + return this.trivia.slice(0); + }; + + NormalSyntaxTriviaList.prototype.concat = function (trivia) { + return concatTrivia(this, trivia); + }; + return NormalSyntaxTriviaList; + })(); + + function triviaList(trivia) { + if (trivia === undefined || trivia === null || trivia.length === 0) { + return TypeScript.Syntax.emptyTriviaList; + } + + if (trivia.length === 1) { + return new SingletonSyntaxTriviaList(trivia[0]); + } + + return new NormalSyntaxTriviaList(trivia); + } + Syntax.triviaList = triviaList; + + Syntax.spaceTriviaList = triviaList([TypeScript.Syntax.spaceTrivia]); + })(TypeScript.Syntax || (TypeScript.Syntax = {})); + var Syntax = TypeScript.Syntax; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var SyntaxUtilities = (function () { + function SyntaxUtilities() { + } + SyntaxUtilities.isAngleBracket = function (positionedElement) { + var element = positionedElement.element(); + var parent = positionedElement.parentElement(); + if (parent !== null && (element.kind() === 80 /* LessThanToken */ || element.kind() === 81 /* GreaterThanToken */)) { + switch (parent.kind()) { + case 227 /* TypeArgumentList */: + case 228 /* TypeParameterList */: + case 219 /* CastExpression */: + return true; + } + } + + return false; + }; + + SyntaxUtilities.getToken = function (list, kind) { + for (var i = 0, n = list.childCount(); i < n; i++) { + var token = list.childAt(i); + if (token.tokenKind === kind) { + return token; + } + } + + return null; + }; + + SyntaxUtilities.containsToken = function (list, kind) { + return SyntaxUtilities.getToken(list, kind) !== null; + }; + + SyntaxUtilities.hasExportKeyword = function (moduleElement) { + return SyntaxUtilities.getExportKeyword(moduleElement) !== null; + }; + + SyntaxUtilities.getExportKeyword = function (moduleElement) { + switch (moduleElement.kind()) { + case 130 /* ModuleDeclaration */: + case 131 /* ClassDeclaration */: + case 129 /* FunctionDeclaration */: + case 147 /* VariableStatement */: + case 132 /* EnumDeclaration */: + case 128 /* InterfaceDeclaration */: + case 133 /* ImportDeclaration */: + return SyntaxUtilities.getToken((moduleElement).modifiers, 47 /* ExportKeyword */); + default: + return null; + } + }; + + SyntaxUtilities.isAmbientDeclarationSyntax = function (positionNode) { + if (!positionNode) { + return false; + } + + var node = positionNode.node(); + switch (node.kind()) { + case 130 /* ModuleDeclaration */: + case 131 /* ClassDeclaration */: + case 129 /* FunctionDeclaration */: + case 147 /* VariableStatement */: + case 132 /* EnumDeclaration */: + if (SyntaxUtilities.containsToken((node).modifiers, 63 /* DeclareKeyword */)) { + return true; + } + + case 133 /* ImportDeclaration */: + case 137 /* ConstructorDeclaration */: + case 135 /* MemberFunctionDeclaration */: + case 138 /* GetMemberAccessorDeclaration */: + case 139 /* SetMemberAccessorDeclaration */: + case 136 /* MemberVariableDeclaration */: + if (node.isClassElement() || node.isModuleElement()) { + return SyntaxUtilities.isAmbientDeclarationSyntax(positionNode.containingNode()); + } + + case 243 /* EnumElement */: + return SyntaxUtilities.isAmbientDeclarationSyntax(positionNode.containingNode().containingNode()); + + default: + return SyntaxUtilities.isAmbientDeclarationSyntax(positionNode.containingNode()); + } + }; + return SyntaxUtilities; + })(); + TypeScript.SyntaxUtilities = SyntaxUtilities; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var SyntaxVisitor = (function () { + function SyntaxVisitor() { + } + SyntaxVisitor.prototype.defaultVisit = function (node) { + return null; + }; + + SyntaxVisitor.prototype.visitToken = function (token) { + return this.defaultVisit(token); + }; + + SyntaxVisitor.prototype.visitSourceUnit = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitExternalModuleReference = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitModuleNameModuleReference = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitImportDeclaration = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitExportAssignment = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitClassDeclaration = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitInterfaceDeclaration = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitHeritageClause = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitModuleDeclaration = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitFunctionDeclaration = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitVariableStatement = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitVariableDeclaration = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitVariableDeclarator = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitEqualsValueClause = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitPrefixUnaryExpression = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitArrayLiteralExpression = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitOmittedExpression = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitParenthesizedExpression = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitSimpleArrowFunctionExpression = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitParenthesizedArrowFunctionExpression = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitQualifiedName = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitTypeArgumentList = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitConstructorType = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitFunctionType = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitObjectType = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitArrayType = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitGenericType = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitTypeQuery = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitTypeAnnotation = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitBlock = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitParameter = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitMemberAccessExpression = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitPostfixUnaryExpression = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitElementAccessExpression = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitInvocationExpression = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitArgumentList = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitBinaryExpression = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitConditionalExpression = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitConstructSignature = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitMethodSignature = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitIndexSignature = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitPropertySignature = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitCallSignature = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitParameterList = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitTypeParameterList = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitTypeParameter = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitConstraint = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitElseClause = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitIfStatement = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitExpressionStatement = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitConstructorDeclaration = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitMemberFunctionDeclaration = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitGetMemberAccessorDeclaration = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitSetMemberAccessorDeclaration = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitMemberVariableDeclaration = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitThrowStatement = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitReturnStatement = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitObjectCreationExpression = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitSwitchStatement = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitCaseSwitchClause = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitDefaultSwitchClause = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitBreakStatement = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitContinueStatement = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitForStatement = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitForInStatement = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitWhileStatement = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitWithStatement = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitEnumDeclaration = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitEnumElement = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitCastExpression = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitObjectLiteralExpression = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitSimplePropertyAssignment = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitFunctionPropertyAssignment = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitGetAccessorPropertyAssignment = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitSetAccessorPropertyAssignment = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitFunctionExpression = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitEmptyStatement = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitTryStatement = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitCatchClause = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitFinallyClause = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitLabeledStatement = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitDoStatement = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitTypeOfExpression = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitDeleteExpression = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitVoidExpression = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitDebuggerStatement = function (node) { + return this.defaultVisit(node); + }; + return SyntaxVisitor; + })(); + TypeScript.SyntaxVisitor = SyntaxVisitor; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var SyntaxWalker = (function () { + function SyntaxWalker() { + } + SyntaxWalker.prototype.visitToken = function (token) { + }; + + SyntaxWalker.prototype.visitNode = function (node) { + node.accept(this); + }; + + SyntaxWalker.prototype.visitNodeOrToken = function (nodeOrToken) { + if (nodeOrToken.isToken()) { + this.visitToken(nodeOrToken); + } else { + this.visitNode(nodeOrToken); + } + }; + + SyntaxWalker.prototype.visitOptionalToken = function (token) { + if (token === null) { + return; + } + + this.visitToken(token); + }; + + SyntaxWalker.prototype.visitOptionalNode = function (node) { + if (node === null) { + return; + } + + this.visitNode(node); + }; + + SyntaxWalker.prototype.visitOptionalNodeOrToken = function (nodeOrToken) { + if (nodeOrToken === null) { + return; + } + + this.visitNodeOrToken(nodeOrToken); + }; + + SyntaxWalker.prototype.visitList = function (list) { + for (var i = 0, n = list.childCount(); i < n; i++) { + this.visitNodeOrToken(list.childAt(i)); + } + }; + + SyntaxWalker.prototype.visitSeparatedList = function (list) { + for (var i = 0, n = list.childCount(); i < n; i++) { + var item = list.childAt(i); + this.visitNodeOrToken(item); + } + }; + + SyntaxWalker.prototype.visitSourceUnit = function (node) { + this.visitList(node.moduleElements); + this.visitToken(node.endOfFileToken); + }; + + SyntaxWalker.prototype.visitExternalModuleReference = function (node) { + this.visitToken(node.requireKeyword); + this.visitToken(node.openParenToken); + this.visitToken(node.stringLiteral); + this.visitToken(node.closeParenToken); + }; + + SyntaxWalker.prototype.visitModuleNameModuleReference = function (node) { + this.visitNodeOrToken(node.moduleName); + }; + + SyntaxWalker.prototype.visitImportDeclaration = function (node) { + this.visitList(node.modifiers); + this.visitToken(node.importKeyword); + this.visitToken(node.identifier); + this.visitToken(node.equalsToken); + this.visitNode(node.moduleReference); + this.visitToken(node.semicolonToken); + }; + + SyntaxWalker.prototype.visitExportAssignment = function (node) { + this.visitToken(node.exportKeyword); + this.visitToken(node.equalsToken); + this.visitToken(node.identifier); + this.visitToken(node.semicolonToken); + }; + + SyntaxWalker.prototype.visitClassDeclaration = function (node) { + this.visitList(node.modifiers); + this.visitToken(node.classKeyword); + this.visitToken(node.identifier); + this.visitOptionalNode(node.typeParameterList); + this.visitList(node.heritageClauses); + this.visitToken(node.openBraceToken); + this.visitList(node.classElements); + this.visitToken(node.closeBraceToken); + }; + + SyntaxWalker.prototype.visitInterfaceDeclaration = function (node) { + this.visitList(node.modifiers); + this.visitToken(node.interfaceKeyword); + this.visitToken(node.identifier); + this.visitOptionalNode(node.typeParameterList); + this.visitList(node.heritageClauses); + this.visitNode(node.body); + }; + + SyntaxWalker.prototype.visitHeritageClause = function (node) { + this.visitToken(node.extendsOrImplementsKeyword); + this.visitSeparatedList(node.typeNames); + }; + + SyntaxWalker.prototype.visitModuleDeclaration = function (node) { + this.visitList(node.modifiers); + this.visitToken(node.moduleKeyword); + this.visitOptionalNodeOrToken(node.moduleName); + this.visitOptionalToken(node.stringLiteral); + this.visitToken(node.openBraceToken); + this.visitList(node.moduleElements); + this.visitToken(node.closeBraceToken); + }; + + SyntaxWalker.prototype.visitFunctionDeclaration = function (node) { + this.visitList(node.modifiers); + this.visitToken(node.functionKeyword); + this.visitToken(node.identifier); + this.visitNode(node.callSignature); + this.visitOptionalNode(node.block); + this.visitOptionalToken(node.semicolonToken); + }; + + SyntaxWalker.prototype.visitVariableStatement = function (node) { + this.visitList(node.modifiers); + this.visitNode(node.variableDeclaration); + this.visitToken(node.semicolonToken); + }; + + SyntaxWalker.prototype.visitVariableDeclaration = function (node) { + this.visitToken(node.varKeyword); + this.visitSeparatedList(node.variableDeclarators); + }; + + SyntaxWalker.prototype.visitVariableDeclarator = function (node) { + this.visitToken(node.identifier); + this.visitOptionalNode(node.typeAnnotation); + this.visitOptionalNode(node.equalsValueClause); + }; + + SyntaxWalker.prototype.visitEqualsValueClause = function (node) { + this.visitToken(node.equalsToken); + this.visitNodeOrToken(node.value); + }; + + SyntaxWalker.prototype.visitPrefixUnaryExpression = function (node) { + this.visitToken(node.operatorToken); + this.visitNodeOrToken(node.operand); + }; + + SyntaxWalker.prototype.visitArrayLiteralExpression = function (node) { + this.visitToken(node.openBracketToken); + this.visitSeparatedList(node.expressions); + this.visitToken(node.closeBracketToken); + }; + + SyntaxWalker.prototype.visitOmittedExpression = function (node) { + }; + + SyntaxWalker.prototype.visitParenthesizedExpression = function (node) { + this.visitToken(node.openParenToken); + this.visitNodeOrToken(node.expression); + this.visitToken(node.closeParenToken); + }; + + SyntaxWalker.prototype.visitSimpleArrowFunctionExpression = function (node) { + this.visitToken(node.identifier); + this.visitToken(node.equalsGreaterThanToken); + this.visitNodeOrToken(node.body); + }; + + SyntaxWalker.prototype.visitParenthesizedArrowFunctionExpression = function (node) { + this.visitNode(node.callSignature); + this.visitToken(node.equalsGreaterThanToken); + this.visitNodeOrToken(node.body); + }; + + SyntaxWalker.prototype.visitQualifiedName = function (node) { + this.visitNodeOrToken(node.left); + this.visitToken(node.dotToken); + this.visitToken(node.right); + }; + + SyntaxWalker.prototype.visitTypeArgumentList = function (node) { + this.visitToken(node.lessThanToken); + this.visitSeparatedList(node.typeArguments); + this.visitToken(node.greaterThanToken); + }; + + SyntaxWalker.prototype.visitConstructorType = function (node) { + this.visitToken(node.newKeyword); + this.visitOptionalNode(node.typeParameterList); + this.visitNode(node.parameterList); + this.visitToken(node.equalsGreaterThanToken); + this.visitNodeOrToken(node.type); + }; + + SyntaxWalker.prototype.visitFunctionType = function (node) { + this.visitOptionalNode(node.typeParameterList); + this.visitNode(node.parameterList); + this.visitToken(node.equalsGreaterThanToken); + this.visitNodeOrToken(node.type); + }; + + SyntaxWalker.prototype.visitObjectType = function (node) { + this.visitToken(node.openBraceToken); + this.visitSeparatedList(node.typeMembers); + this.visitToken(node.closeBraceToken); + }; + + SyntaxWalker.prototype.visitArrayType = function (node) { + this.visitNodeOrToken(node.type); + this.visitToken(node.openBracketToken); + this.visitToken(node.closeBracketToken); + }; + + SyntaxWalker.prototype.visitGenericType = function (node) { + this.visitNodeOrToken(node.name); + this.visitNode(node.typeArgumentList); + }; + + SyntaxWalker.prototype.visitTypeQuery = function (node) { + this.visitToken(node.typeOfKeyword); + this.visitNodeOrToken(node.name); + }; + + SyntaxWalker.prototype.visitTypeAnnotation = function (node) { + this.visitToken(node.colonToken); + this.visitNodeOrToken(node.type); + }; + + SyntaxWalker.prototype.visitBlock = function (node) { + this.visitToken(node.openBraceToken); + this.visitList(node.statements); + this.visitToken(node.closeBraceToken); + }; + + SyntaxWalker.prototype.visitParameter = function (node) { + this.visitOptionalToken(node.dotDotDotToken); + this.visitOptionalToken(node.publicOrPrivateKeyword); + this.visitToken(node.identifier); + this.visitOptionalToken(node.questionToken); + this.visitOptionalNode(node.typeAnnotation); + this.visitOptionalNode(node.equalsValueClause); + }; + + SyntaxWalker.prototype.visitMemberAccessExpression = function (node) { + this.visitNodeOrToken(node.expression); + this.visitToken(node.dotToken); + this.visitToken(node.name); + }; + + SyntaxWalker.prototype.visitPostfixUnaryExpression = function (node) { + this.visitNodeOrToken(node.operand); + this.visitToken(node.operatorToken); + }; + + SyntaxWalker.prototype.visitElementAccessExpression = function (node) { + this.visitNodeOrToken(node.expression); + this.visitToken(node.openBracketToken); + this.visitNodeOrToken(node.argumentExpression); + this.visitToken(node.closeBracketToken); + }; + + SyntaxWalker.prototype.visitInvocationExpression = function (node) { + this.visitNodeOrToken(node.expression); + this.visitNode(node.argumentList); + }; + + SyntaxWalker.prototype.visitArgumentList = function (node) { + this.visitOptionalNode(node.typeArgumentList); + this.visitToken(node.openParenToken); + this.visitSeparatedList(node.arguments); + this.visitToken(node.closeParenToken); + }; + + SyntaxWalker.prototype.visitBinaryExpression = function (node) { + this.visitNodeOrToken(node.left); + this.visitToken(node.operatorToken); + this.visitNodeOrToken(node.right); + }; + + SyntaxWalker.prototype.visitConditionalExpression = function (node) { + this.visitNodeOrToken(node.condition); + this.visitToken(node.questionToken); + this.visitNodeOrToken(node.whenTrue); + this.visitToken(node.colonToken); + this.visitNodeOrToken(node.whenFalse); + }; + + SyntaxWalker.prototype.visitConstructSignature = function (node) { + this.visitToken(node.newKeyword); + this.visitNode(node.callSignature); + }; + + SyntaxWalker.prototype.visitMethodSignature = function (node) { + this.visitToken(node.propertyName); + this.visitOptionalToken(node.questionToken); + this.visitNode(node.callSignature); + }; + + SyntaxWalker.prototype.visitIndexSignature = function (node) { + this.visitToken(node.openBracketToken); + this.visitNode(node.parameter); + this.visitToken(node.closeBracketToken); + this.visitOptionalNode(node.typeAnnotation); + }; + + SyntaxWalker.prototype.visitPropertySignature = function (node) { + this.visitToken(node.propertyName); + this.visitOptionalToken(node.questionToken); + this.visitOptionalNode(node.typeAnnotation); + }; + + SyntaxWalker.prototype.visitCallSignature = function (node) { + this.visitOptionalNode(node.typeParameterList); + this.visitNode(node.parameterList); + this.visitOptionalNode(node.typeAnnotation); + }; + + SyntaxWalker.prototype.visitParameterList = function (node) { + this.visitToken(node.openParenToken); + this.visitSeparatedList(node.parameters); + this.visitToken(node.closeParenToken); + }; + + SyntaxWalker.prototype.visitTypeParameterList = function (node) { + this.visitToken(node.lessThanToken); + this.visitSeparatedList(node.typeParameters); + this.visitToken(node.greaterThanToken); + }; + + SyntaxWalker.prototype.visitTypeParameter = function (node) { + this.visitToken(node.identifier); + this.visitOptionalNode(node.constraint); + }; + + SyntaxWalker.prototype.visitConstraint = function (node) { + this.visitToken(node.extendsKeyword); + this.visitNodeOrToken(node.type); + }; + + SyntaxWalker.prototype.visitElseClause = function (node) { + this.visitToken(node.elseKeyword); + this.visitNodeOrToken(node.statement); + }; + + SyntaxWalker.prototype.visitIfStatement = function (node) { + this.visitToken(node.ifKeyword); + this.visitToken(node.openParenToken); + this.visitNodeOrToken(node.condition); + this.visitToken(node.closeParenToken); + this.visitNodeOrToken(node.statement); + this.visitOptionalNode(node.elseClause); + }; + + SyntaxWalker.prototype.visitExpressionStatement = function (node) { + this.visitNodeOrToken(node.expression); + this.visitToken(node.semicolonToken); + }; + + SyntaxWalker.prototype.visitConstructorDeclaration = function (node) { + this.visitToken(node.constructorKeyword); + this.visitNode(node.parameterList); + this.visitOptionalNode(node.block); + this.visitOptionalToken(node.semicolonToken); + }; + + SyntaxWalker.prototype.visitMemberFunctionDeclaration = function (node) { + this.visitList(node.modifiers); + this.visitToken(node.propertyName); + this.visitNode(node.callSignature); + this.visitOptionalNode(node.block); + this.visitOptionalToken(node.semicolonToken); + }; + + SyntaxWalker.prototype.visitGetMemberAccessorDeclaration = function (node) { + this.visitList(node.modifiers); + this.visitToken(node.getKeyword); + this.visitToken(node.propertyName); + this.visitNode(node.parameterList); + this.visitOptionalNode(node.typeAnnotation); + this.visitNode(node.block); + }; + + SyntaxWalker.prototype.visitSetMemberAccessorDeclaration = function (node) { + this.visitList(node.modifiers); + this.visitToken(node.setKeyword); + this.visitToken(node.propertyName); + this.visitNode(node.parameterList); + this.visitNode(node.block); + }; + + SyntaxWalker.prototype.visitMemberVariableDeclaration = function (node) { + this.visitList(node.modifiers); + this.visitNode(node.variableDeclarator); + this.visitToken(node.semicolonToken); + }; + + SyntaxWalker.prototype.visitThrowStatement = function (node) { + this.visitToken(node.throwKeyword); + this.visitNodeOrToken(node.expression); + this.visitToken(node.semicolonToken); + }; + + SyntaxWalker.prototype.visitReturnStatement = function (node) { + this.visitToken(node.returnKeyword); + this.visitOptionalNodeOrToken(node.expression); + this.visitToken(node.semicolonToken); + }; + + SyntaxWalker.prototype.visitObjectCreationExpression = function (node) { + this.visitToken(node.newKeyword); + this.visitNodeOrToken(node.expression); + this.visitOptionalNode(node.argumentList); + }; + + SyntaxWalker.prototype.visitSwitchStatement = function (node) { + this.visitToken(node.switchKeyword); + this.visitToken(node.openParenToken); + this.visitNodeOrToken(node.expression); + this.visitToken(node.closeParenToken); + this.visitToken(node.openBraceToken); + this.visitList(node.switchClauses); + this.visitToken(node.closeBraceToken); + }; + + SyntaxWalker.prototype.visitCaseSwitchClause = function (node) { + this.visitToken(node.caseKeyword); + this.visitNodeOrToken(node.expression); + this.visitToken(node.colonToken); + this.visitList(node.statements); + }; + + SyntaxWalker.prototype.visitDefaultSwitchClause = function (node) { + this.visitToken(node.defaultKeyword); + this.visitToken(node.colonToken); + this.visitList(node.statements); + }; + + SyntaxWalker.prototype.visitBreakStatement = function (node) { + this.visitToken(node.breakKeyword); + this.visitOptionalToken(node.identifier); + this.visitToken(node.semicolonToken); + }; + + SyntaxWalker.prototype.visitContinueStatement = function (node) { + this.visitToken(node.continueKeyword); + this.visitOptionalToken(node.identifier); + this.visitToken(node.semicolonToken); + }; + + SyntaxWalker.prototype.visitForStatement = function (node) { + this.visitToken(node.forKeyword); + this.visitToken(node.openParenToken); + this.visitOptionalNode(node.variableDeclaration); + this.visitOptionalNodeOrToken(node.initializer); + this.visitToken(node.firstSemicolonToken); + this.visitOptionalNodeOrToken(node.condition); + this.visitToken(node.secondSemicolonToken); + this.visitOptionalNodeOrToken(node.incrementor); + this.visitToken(node.closeParenToken); + this.visitNodeOrToken(node.statement); + }; + + SyntaxWalker.prototype.visitForInStatement = function (node) { + this.visitToken(node.forKeyword); + this.visitToken(node.openParenToken); + this.visitOptionalNode(node.variableDeclaration); + this.visitOptionalNodeOrToken(node.left); + this.visitToken(node.inKeyword); + this.visitNodeOrToken(node.expression); + this.visitToken(node.closeParenToken); + this.visitNodeOrToken(node.statement); + }; + + SyntaxWalker.prototype.visitWhileStatement = function (node) { + this.visitToken(node.whileKeyword); + this.visitToken(node.openParenToken); + this.visitNodeOrToken(node.condition); + this.visitToken(node.closeParenToken); + this.visitNodeOrToken(node.statement); + }; + + SyntaxWalker.prototype.visitWithStatement = function (node) { + this.visitToken(node.withKeyword); + this.visitToken(node.openParenToken); + this.visitNodeOrToken(node.condition); + this.visitToken(node.closeParenToken); + this.visitNodeOrToken(node.statement); + }; + + SyntaxWalker.prototype.visitEnumDeclaration = function (node) { + this.visitList(node.modifiers); + this.visitToken(node.enumKeyword); + this.visitToken(node.identifier); + this.visitToken(node.openBraceToken); + this.visitSeparatedList(node.enumElements); + this.visitToken(node.closeBraceToken); + }; + + SyntaxWalker.prototype.visitEnumElement = function (node) { + this.visitToken(node.propertyName); + this.visitOptionalNode(node.equalsValueClause); + }; + + SyntaxWalker.prototype.visitCastExpression = function (node) { + this.visitToken(node.lessThanToken); + this.visitNodeOrToken(node.type); + this.visitToken(node.greaterThanToken); + this.visitNodeOrToken(node.expression); + }; + + SyntaxWalker.prototype.visitObjectLiteralExpression = function (node) { + this.visitToken(node.openBraceToken); + this.visitSeparatedList(node.propertyAssignments); + this.visitToken(node.closeBraceToken); + }; + + SyntaxWalker.prototype.visitSimplePropertyAssignment = function (node) { + this.visitToken(node.propertyName); + this.visitToken(node.colonToken); + this.visitNodeOrToken(node.expression); + }; + + SyntaxWalker.prototype.visitFunctionPropertyAssignment = function (node) { + this.visitToken(node.propertyName); + this.visitNode(node.callSignature); + this.visitNode(node.block); + }; + + SyntaxWalker.prototype.visitGetAccessorPropertyAssignment = function (node) { + this.visitToken(node.getKeyword); + this.visitToken(node.propertyName); + this.visitToken(node.openParenToken); + this.visitToken(node.closeParenToken); + this.visitOptionalNode(node.typeAnnotation); + this.visitNode(node.block); + }; + + SyntaxWalker.prototype.visitSetAccessorPropertyAssignment = function (node) { + this.visitToken(node.setKeyword); + this.visitToken(node.propertyName); + this.visitToken(node.openParenToken); + this.visitNode(node.parameter); + this.visitToken(node.closeParenToken); + this.visitNode(node.block); + }; + + SyntaxWalker.prototype.visitFunctionExpression = function (node) { + this.visitToken(node.functionKeyword); + this.visitOptionalToken(node.identifier); + this.visitNode(node.callSignature); + this.visitNode(node.block); + }; + + SyntaxWalker.prototype.visitEmptyStatement = function (node) { + this.visitToken(node.semicolonToken); + }; + + SyntaxWalker.prototype.visitTryStatement = function (node) { + this.visitToken(node.tryKeyword); + this.visitNode(node.block); + this.visitOptionalNode(node.catchClause); + this.visitOptionalNode(node.finallyClause); + }; + + SyntaxWalker.prototype.visitCatchClause = function (node) { + this.visitToken(node.catchKeyword); + this.visitToken(node.openParenToken); + this.visitToken(node.identifier); + this.visitOptionalNode(node.typeAnnotation); + this.visitToken(node.closeParenToken); + this.visitNode(node.block); + }; + + SyntaxWalker.prototype.visitFinallyClause = function (node) { + this.visitToken(node.finallyKeyword); + this.visitNode(node.block); + }; + + SyntaxWalker.prototype.visitLabeledStatement = function (node) { + this.visitToken(node.identifier); + this.visitToken(node.colonToken); + this.visitNodeOrToken(node.statement); + }; + + SyntaxWalker.prototype.visitDoStatement = function (node) { + this.visitToken(node.doKeyword); + this.visitNodeOrToken(node.statement); + this.visitToken(node.whileKeyword); + this.visitToken(node.openParenToken); + this.visitNodeOrToken(node.condition); + this.visitToken(node.closeParenToken); + this.visitToken(node.semicolonToken); + }; + + SyntaxWalker.prototype.visitTypeOfExpression = function (node) { + this.visitToken(node.typeOfKeyword); + this.visitNodeOrToken(node.expression); + }; + + SyntaxWalker.prototype.visitDeleteExpression = function (node) { + this.visitToken(node.deleteKeyword); + this.visitNodeOrToken(node.expression); + }; + + SyntaxWalker.prototype.visitVoidExpression = function (node) { + this.visitToken(node.voidKeyword); + this.visitNodeOrToken(node.expression); + }; + + SyntaxWalker.prototype.visitDebuggerStatement = function (node) { + this.visitToken(node.debuggerKeyword); + this.visitToken(node.semicolonToken); + }; + return SyntaxWalker; + })(); + TypeScript.SyntaxWalker = SyntaxWalker; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var PositionTrackingWalker = (function (_super) { + __extends(PositionTrackingWalker, _super); + function PositionTrackingWalker() { + _super.apply(this, arguments); + this._position = 0; + } + PositionTrackingWalker.prototype.visitToken = function (token) { + this._position += token.fullWidth(); + }; + + PositionTrackingWalker.prototype.position = function () { + return this._position; + }; + + PositionTrackingWalker.prototype.skip = function (element) { + this._position += element.fullWidth(); + }; + return PositionTrackingWalker; + })(TypeScript.SyntaxWalker); + TypeScript.PositionTrackingWalker = PositionTrackingWalker; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var SyntaxInformationMap = (function (_super) { + __extends(SyntaxInformationMap, _super); + function SyntaxInformationMap(trackParents, trackPreviousToken) { + _super.call(this); + this.trackParents = trackParents; + this.trackPreviousToken = trackPreviousToken; + this.tokenToInformation = TypeScript.Collections.createHashTable(TypeScript.Collections.DefaultHashTableCapacity, TypeScript.Collections.identityHashCode); + this.elementToPosition = TypeScript.Collections.createHashTable(TypeScript.Collections.DefaultHashTableCapacity, TypeScript.Collections.identityHashCode); + this._previousToken = null; + this._previousTokenInformation = null; + this._currentPosition = 0; + this._elementToParent = TypeScript.Collections.createHashTable(TypeScript.Collections.DefaultHashTableCapacity, TypeScript.Collections.identityHashCode); + this._parentStack = []; + this._parentStack.push(null); + } + SyntaxInformationMap.create = function (node, trackParents, trackPreviousToken) { + var map = new SyntaxInformationMap(trackParents, trackPreviousToken); + map.visitNode(node); + return map; + }; + + SyntaxInformationMap.prototype.visitNode = function (node) { + this.trackParents && this._elementToParent.add(node, TypeScript.ArrayUtilities.last(this._parentStack)); + this.elementToPosition.add(node, this._currentPosition); + + this.trackParents && this._parentStack.push(node); + _super.prototype.visitNode.call(this, node); + this.trackParents && this._parentStack.pop(); + }; + + SyntaxInformationMap.prototype.visitToken = function (token) { + this.trackParents && this._elementToParent.add(token, TypeScript.ArrayUtilities.last(this._parentStack)); + + if (this.trackPreviousToken) { + var tokenInformation = { + previousToken: this._previousToken, + nextToken: null + }; + + if (this._previousTokenInformation !== null) { + this._previousTokenInformation.nextToken = token; + } + + this._previousToken = token; + this._previousTokenInformation = tokenInformation; + + this.tokenToInformation.add(token, tokenInformation); + } + + this.elementToPosition.add(token, this._currentPosition); + this._currentPosition += token.fullWidth(); + }; + + SyntaxInformationMap.prototype.parent = function (element) { + return this._elementToParent.get(element); + }; + + SyntaxInformationMap.prototype.fullStart = function (element) { + return this.elementToPosition.get(element); + }; + + SyntaxInformationMap.prototype.start = function (element) { + return this.fullStart(element) + element.leadingTriviaWidth(); + }; + + SyntaxInformationMap.prototype.end = function (element) { + return this.start(element) + element.width(); + }; + + SyntaxInformationMap.prototype.previousToken = function (token) { + return this.tokenInformation(token).previousToken; + }; + + SyntaxInformationMap.prototype.tokenInformation = function (token) { + return this.tokenToInformation.get(token); + }; + + SyntaxInformationMap.prototype.firstTokenInLineContainingToken = function (token) { + var current = token; + while (true) { + var information = this.tokenInformation(current); + if (this.isFirstTokenInLineWorker(information)) { + break; + } + + current = information.previousToken; + } + + return current; + }; + + SyntaxInformationMap.prototype.isFirstTokenInLine = function (token) { + var information = this.tokenInformation(token); + return this.isFirstTokenInLineWorker(information); + }; + + SyntaxInformationMap.prototype.isFirstTokenInLineWorker = function (information) { + return information.previousToken === null || information.previousToken.hasTrailingNewLine(); + }; + return SyntaxInformationMap; + })(TypeScript.SyntaxWalker); + TypeScript.SyntaxInformationMap = SyntaxInformationMap; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var SyntaxNodeInvariantsChecker = (function (_super) { + __extends(SyntaxNodeInvariantsChecker, _super); + function SyntaxNodeInvariantsChecker() { + _super.apply(this, arguments); + this.tokenTable = TypeScript.Collections.createHashTable(TypeScript.Collections.DefaultHashTableCapacity, TypeScript.Collections.identityHashCode); + } + SyntaxNodeInvariantsChecker.checkInvariants = function (node) { + node.accept(new SyntaxNodeInvariantsChecker()); + }; + + SyntaxNodeInvariantsChecker.prototype.visitToken = function (token) { + this.tokenTable.add(token, token); + }; + return SyntaxNodeInvariantsChecker; + })(TypeScript.SyntaxWalker); + TypeScript.SyntaxNodeInvariantsChecker = SyntaxNodeInvariantsChecker; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var DepthLimitedWalker = (function (_super) { + __extends(DepthLimitedWalker, _super); + function DepthLimitedWalker(maximumDepth) { + _super.call(this); + this._depth = 0; + this._maximumDepth = 0; + this._maximumDepth = maximumDepth; + } + DepthLimitedWalker.prototype.visitNode = function (node) { + if (this._depth < this._maximumDepth) { + this._depth++; + _super.prototype.visitNode.call(this, node); + this._depth--; + } else { + this.skip(node); + } + }; + return DepthLimitedWalker; + })(TypeScript.PositionTrackingWalker); + TypeScript.DepthLimitedWalker = DepthLimitedWalker; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (Parser) { + var ExpressionPrecedence; + (function (ExpressionPrecedence) { + ExpressionPrecedence[ExpressionPrecedence["CommaExpressionPrecedence"] = 1] = "CommaExpressionPrecedence"; + + ExpressionPrecedence[ExpressionPrecedence["AssignmentExpressionPrecedence"] = 2] = "AssignmentExpressionPrecedence"; + + ExpressionPrecedence[ExpressionPrecedence["ConditionalExpressionPrecedence"] = 3] = "ConditionalExpressionPrecedence"; + + ExpressionPrecedence[ExpressionPrecedence["ArrowFunctionPrecedence"] = 4] = "ArrowFunctionPrecedence"; + + ExpressionPrecedence[ExpressionPrecedence["LogicalOrExpressionPrecedence"] = 5] = "LogicalOrExpressionPrecedence"; + ExpressionPrecedence[ExpressionPrecedence["LogicalAndExpressionPrecedence"] = 6] = "LogicalAndExpressionPrecedence"; + ExpressionPrecedence[ExpressionPrecedence["BitwiseOrExpressionPrecedence"] = 7] = "BitwiseOrExpressionPrecedence"; + ExpressionPrecedence[ExpressionPrecedence["BitwiseExclusiveOrExpressionPrecedence"] = 8] = "BitwiseExclusiveOrExpressionPrecedence"; + ExpressionPrecedence[ExpressionPrecedence["BitwiseAndExpressionPrecedence"] = 9] = "BitwiseAndExpressionPrecedence"; + ExpressionPrecedence[ExpressionPrecedence["EqualityExpressionPrecedence"] = 10] = "EqualityExpressionPrecedence"; + ExpressionPrecedence[ExpressionPrecedence["RelationalExpressionPrecedence"] = 11] = "RelationalExpressionPrecedence"; + ExpressionPrecedence[ExpressionPrecedence["ShiftExpressionPrecdence"] = 12] = "ShiftExpressionPrecdence"; + ExpressionPrecedence[ExpressionPrecedence["AdditiveExpressionPrecedence"] = 13] = "AdditiveExpressionPrecedence"; + ExpressionPrecedence[ExpressionPrecedence["MultiplicativeExpressionPrecedence"] = 14] = "MultiplicativeExpressionPrecedence"; + + ExpressionPrecedence[ExpressionPrecedence["UnaryExpressionPrecedence"] = 15] = "UnaryExpressionPrecedence"; + })(ExpressionPrecedence || (ExpressionPrecedence = {})); + + var ListParsingState; + (function (ListParsingState) { + ListParsingState[ListParsingState["SourceUnit_ModuleElements"] = 1 << 0] = "SourceUnit_ModuleElements"; + ListParsingState[ListParsingState["ClassDeclaration_ClassElements"] = 1 << 1] = "ClassDeclaration_ClassElements"; + ListParsingState[ListParsingState["ModuleDeclaration_ModuleElements"] = 1 << 2] = "ModuleDeclaration_ModuleElements"; + ListParsingState[ListParsingState["SwitchStatement_SwitchClauses"] = 1 << 3] = "SwitchStatement_SwitchClauses"; + ListParsingState[ListParsingState["SwitchClause_Statements"] = 1 << 4] = "SwitchClause_Statements"; + ListParsingState[ListParsingState["Block_Statements"] = 1 << 5] = "Block_Statements"; + ListParsingState[ListParsingState["TryBlock_Statements"] = 1 << 6] = "TryBlock_Statements"; + ListParsingState[ListParsingState["CatchBlock_Statements"] = 1 << 7] = "CatchBlock_Statements"; + ListParsingState[ListParsingState["EnumDeclaration_EnumElements"] = 1 << 8] = "EnumDeclaration_EnumElements"; + ListParsingState[ListParsingState["ObjectType_TypeMembers"] = 1 << 9] = "ObjectType_TypeMembers"; + ListParsingState[ListParsingState["ClassOrInterfaceDeclaration_HeritageClauses"] = 1 << 10] = "ClassOrInterfaceDeclaration_HeritageClauses"; + ListParsingState[ListParsingState["HeritageClause_TypeNameList"] = 1 << 11] = "HeritageClause_TypeNameList"; + ListParsingState[ListParsingState["VariableDeclaration_VariableDeclarators_AllowIn"] = 1 << 12] = "VariableDeclaration_VariableDeclarators_AllowIn"; + ListParsingState[ListParsingState["VariableDeclaration_VariableDeclarators_DisallowIn"] = 1 << 13] = "VariableDeclaration_VariableDeclarators_DisallowIn"; + ListParsingState[ListParsingState["ArgumentList_AssignmentExpressions"] = 1 << 14] = "ArgumentList_AssignmentExpressions"; + ListParsingState[ListParsingState["ObjectLiteralExpression_PropertyAssignments"] = 1 << 15] = "ObjectLiteralExpression_PropertyAssignments"; + ListParsingState[ListParsingState["ArrayLiteralExpression_AssignmentExpressions"] = 1 << 16] = "ArrayLiteralExpression_AssignmentExpressions"; + ListParsingState[ListParsingState["ParameterList_Parameters"] = 1 << 17] = "ParameterList_Parameters"; + ListParsingState[ListParsingState["TypeArgumentList_Types"] = 1 << 18] = "TypeArgumentList_Types"; + ListParsingState[ListParsingState["TypeParameterList_TypeParameters"] = 1 << 19] = "TypeParameterList_TypeParameters"; + + ListParsingState[ListParsingState["FirstListParsingState"] = ListParsingState.SourceUnit_ModuleElements] = "FirstListParsingState"; + ListParsingState[ListParsingState["LastListParsingState"] = ListParsingState.TypeArgumentList_Types] = "LastListParsingState"; + })(ListParsingState || (ListParsingState = {})); + + var SyntaxCursor = (function () { + function SyntaxCursor(sourceUnit) { + this._elements = []; + this._index = 0; + this._pinCount = 0; + sourceUnit.insertChildrenInto(this._elements, 0); + } + SyntaxCursor.prototype.isFinished = function () { + return this._index === this._elements.length; + }; + + SyntaxCursor.prototype.currentElement = function () { + if (this.isFinished()) { + return null; + } + + return this._elements[this._index]; + }; + + SyntaxCursor.prototype.currentNode = function () { + var element = this.currentElement(); + return element !== null && element.isNode() ? element : null; + }; + + SyntaxCursor.prototype.moveToFirstChild = function () { + if (this.isFinished()) { + return; + } + + var element = this._elements[this._index]; + if (element.isToken()) { + return; + } + + var node = element; + + this._elements.splice(this._index, 1); + + node.insertChildrenInto(this._elements, this._index); + }; + + SyntaxCursor.prototype.moveToNextSibling = function () { + if (this.isFinished()) { + return; + } + + if (this._pinCount > 0) { + this._index++; + return; + } + + this._elements.shift(); + }; + + SyntaxCursor.prototype.getAndPinCursorIndex = function () { + this._pinCount++; + return this._index; + }; + + SyntaxCursor.prototype.releaseAndUnpinCursorIndex = function (index) { + this._pinCount--; + if (this._pinCount === 0) { + } + }; + + SyntaxCursor.prototype.rewindToPinnedCursorIndex = function (index) { + this._index = index; + }; + + SyntaxCursor.prototype.pinCount = function () { + return this._pinCount; + }; + + SyntaxCursor.prototype.moveToFirstToken = function () { + var element; + + while (!this.isFinished()) { + element = this.currentElement(); + if (element.isNode()) { + this.moveToFirstChild(); + continue; + } + + return; + } + }; + + SyntaxCursor.prototype.currentToken = function () { + this.moveToFirstToken(); + if (this.isFinished()) { + return null; + } + + var element = this.currentElement(); + + return element; + }; + + SyntaxCursor.prototype.peekToken = function (n) { + this.moveToFirstToken(); + var pin = this.getAndPinCursorIndex(); + try { + for (var i = 0; i < n; i++) { + this.moveToNextSibling(); + this.moveToFirstToken(); + } + + return this.currentToken(); + } finally { + this.rewindToPinnedCursorIndex(pin); + this.releaseAndUnpinCursorIndex(pin); + } + }; + return SyntaxCursor; + })(); + + var NormalParserSource = (function () { + function NormalParserSource(fileName, text, languageVersion) { + this._previousToken = null; + this._absolutePosition = 0; + this._tokenDiagnostics = []; + this.rewindPointPool = []; + this.rewindPointPoolCount = 0; + this.slidingWindow = new TypeScript.SlidingWindow(this, TypeScript.ArrayUtilities.createArray(32, null), null); + this.scanner = new TypeScript.Scanner(fileName, text, languageVersion); + } + NormalParserSource.prototype.currentNode = function () { + return null; + }; + + NormalParserSource.prototype.moveToNextNode = function () { + throw TypeScript.Errors.invalidOperation(); + }; + + NormalParserSource.prototype.absolutePosition = function () { + return this._absolutePosition; + }; + + NormalParserSource.prototype.previousToken = function () { + return this._previousToken; + }; + + NormalParserSource.prototype.tokenDiagnostics = function () { + return this._tokenDiagnostics; + }; + + NormalParserSource.prototype.getOrCreateRewindPoint = function () { + if (this.rewindPointPoolCount === 0) { + return {}; + } + + this.rewindPointPoolCount--; + var result = this.rewindPointPool[this.rewindPointPoolCount]; + this.rewindPointPool[this.rewindPointPoolCount] = null; + return result; + }; + + NormalParserSource.prototype.getRewindPoint = function () { + var slidingWindowIndex = this.slidingWindow.getAndPinAbsoluteIndex(); + + var rewindPoint = this.getOrCreateRewindPoint(); + + rewindPoint.slidingWindowIndex = slidingWindowIndex; + rewindPoint.previousToken = this._previousToken; + rewindPoint.absolutePosition = this._absolutePosition; + + rewindPoint.pinCount = this.slidingWindow.pinCount(); + + return rewindPoint; + }; + + NormalParserSource.prototype.isPinned = function () { + return this.slidingWindow.pinCount() > 0; + }; + + NormalParserSource.prototype.rewind = function (rewindPoint) { + this.slidingWindow.rewindToPinnedIndex(rewindPoint.slidingWindowIndex); + + this._previousToken = rewindPoint.previousToken; + this._absolutePosition = rewindPoint.absolutePosition; + }; + + NormalParserSource.prototype.releaseRewindPoint = function (rewindPoint) { + this.slidingWindow.releaseAndUnpinAbsoluteIndex((rewindPoint).absoluteIndex); + + this.rewindPointPool[this.rewindPointPoolCount] = rewindPoint; + this.rewindPointPoolCount++; + }; + + NormalParserSource.prototype.fetchMoreItems = function (allowRegularExpression, sourceIndex, window, destinationIndex, spaceAvailable) { + window[destinationIndex] = this.scanner.scan(this._tokenDiagnostics, allowRegularExpression); + return 1; + }; + + NormalParserSource.prototype.peekToken = function (n) { + return this.slidingWindow.peekItemN(n); + }; + + NormalParserSource.prototype.moveToNextToken = function () { + var currentToken = this.currentToken(); + this._absolutePosition += currentToken.fullWidth(); + this._previousToken = currentToken; + + this.slidingWindow.moveToNextItem(); + }; + + NormalParserSource.prototype.currentToken = function () { + return this.slidingWindow.currentItem(false); + }; + + NormalParserSource.prototype.removeDiagnosticsOnOrAfterPosition = function (position) { + var tokenDiagnosticsLength = this._tokenDiagnostics.length; + while (tokenDiagnosticsLength > 0) { + var diagnostic = this._tokenDiagnostics[tokenDiagnosticsLength - 1]; + if (diagnostic.start() >= position) { + tokenDiagnosticsLength--; + } else { + break; + } + } + + this._tokenDiagnostics.length = tokenDiagnosticsLength; + }; + + NormalParserSource.prototype.resetToPosition = function (absolutePosition, previousToken) { + this._absolutePosition = absolutePosition; + this._previousToken = previousToken; + + this.removeDiagnosticsOnOrAfterPosition(absolutePosition); + + this.slidingWindow.disgardAllItemsFromCurrentIndexOnwards(); + + this.scanner.setAbsoluteIndex(absolutePosition); + }; + + NormalParserSource.prototype.currentTokenAllowingRegularExpression = function () { + this.resetToPosition(this._absolutePosition, this._previousToken); + + var token = this.slidingWindow.currentItem(true); + + return token; + }; + return NormalParserSource; + })(); + + var IncrementalParserSource = (function () { + function IncrementalParserSource(oldSyntaxTree, textChangeRange, newText) { + this._changeDelta = 0; + var oldSourceUnit = oldSyntaxTree.sourceUnit(); + this._oldSourceUnitCursor = new SyntaxCursor(oldSourceUnit); + + this._changeRange = IncrementalParserSource.extendToAffectedRange(textChangeRange, oldSourceUnit); + + this._normalParserSource = new NormalParserSource(oldSyntaxTree.fileName(), newText, oldSyntaxTree.parseOptions().languageVersion()); + } + IncrementalParserSource.extendToAffectedRange = function (changeRange, sourceUnit) { + var maxLookahead = 1; + + var start = changeRange.span().start(); + + for (var i = 0; start > 0 && i <= maxLookahead; i++) { + var token = sourceUnit.findToken(start); + + var position = token.fullStart(); + + start = TypeScript.MathPrototype.max(0, position - 1); + } + + var finalSpan = TypeScript.TextSpan.fromBounds(start, changeRange.span().end()); + var finalLength = changeRange.newLength() + (changeRange.span().start() - start); + + return new TypeScript.TextChangeRange(finalSpan, finalLength); + }; + + IncrementalParserSource.prototype.absolutePosition = function () { + return this._normalParserSource.absolutePosition(); + }; + + IncrementalParserSource.prototype.previousToken = function () { + return this._normalParserSource.previousToken(); + }; + + IncrementalParserSource.prototype.tokenDiagnostics = function () { + return this._normalParserSource.tokenDiagnostics(); + }; + + IncrementalParserSource.prototype.getRewindPoint = function () { + var rewindPoint = this._normalParserSource.getRewindPoint(); + var oldSourceUnitCursorIndex = this._oldSourceUnitCursor.getAndPinCursorIndex(); + + rewindPoint.changeDelta = this._changeDelta; + rewindPoint.changeRange = this._changeRange; + rewindPoint.oldSourceUnitCursorIndex = oldSourceUnitCursorIndex; + + return rewindPoint; + }; + + IncrementalParserSource.prototype.rewind = function (rewindPoint) { + this._changeRange = rewindPoint.changeRange; + this._changeDelta = rewindPoint.changeDelta; + this._oldSourceUnitCursor.rewindToPinnedCursorIndex(rewindPoint.oldSourceUnitCursorIndex); + + this._normalParserSource.rewind(rewindPoint); + }; + + IncrementalParserSource.prototype.releaseRewindPoint = function (rewindPoint) { + this._oldSourceUnitCursor.releaseAndUnpinCursorIndex(rewindPoint.oldSourceUnitCursorIndex); + this._normalParserSource.releaseRewindPoint(rewindPoint); + }; + + IncrementalParserSource.prototype.canReadFromOldSourceUnit = function () { + if (this._normalParserSource.isPinned()) { + return false; + } + + if (this._changeRange !== null && this._changeRange.newSpan().intersectsWithPosition(this.absolutePosition())) { + return false; + } + + this.syncCursorToNewTextIfBehind(); + + return this._changeDelta === 0 && !this._oldSourceUnitCursor.isFinished(); + }; + + IncrementalParserSource.prototype.currentNode = function () { + if (this.canReadFromOldSourceUnit()) { + return this.tryGetNodeFromOldSourceUnit(); + } + + return null; + }; + + IncrementalParserSource.prototype.currentToken = function () { + if (this.canReadFromOldSourceUnit()) { + var token = this.tryGetTokenFromOldSourceUnit(); + if (token !== null) { + return token; + } + } + + return this._normalParserSource.currentToken(); + }; + + IncrementalParserSource.prototype.currentTokenAllowingRegularExpression = function () { + return this._normalParserSource.currentTokenAllowingRegularExpression(); + }; + + IncrementalParserSource.prototype.syncCursorToNewTextIfBehind = function () { + while (true) { + if (this._oldSourceUnitCursor.isFinished()) { + break; + } + + if (this._changeDelta >= 0) { + break; + } + + var currentElement = this._oldSourceUnitCursor.currentElement(); + + if (currentElement.isNode() && (currentElement.fullWidth() > Math.abs(this._changeDelta))) { + this._oldSourceUnitCursor.moveToFirstChild(); + } else { + this._oldSourceUnitCursor.moveToNextSibling(); + + this._changeDelta += currentElement.fullWidth(); + } + } + }; + + IncrementalParserSource.prototype.intersectsWithChangeRangeSpanInOriginalText = function (start, length) { + return this._changeRange !== null && this._changeRange.span().intersectsWith(start, length); + }; + + IncrementalParserSource.prototype.tryGetNodeFromOldSourceUnit = function () { + while (true) { + var node = this._oldSourceUnitCursor.currentNode(); + if (node === null) { + return null; + } + + if (!this.intersectsWithChangeRangeSpanInOriginalText(this.absolutePosition(), node.fullWidth())) { + if (!node.isIncrementallyUnusable()) { + return node; + } + } + + this._oldSourceUnitCursor.moveToFirstChild(); + } + }; + + IncrementalParserSource.prototype.canReuseTokenFromOldSourceUnit = function (position, token) { + if (token !== null) { + if (!this.intersectsWithChangeRangeSpanInOriginalText(position, token.fullWidth())) { + if (!token.isIncrementallyUnusable()) { + return true; + } + } + } + + return false; + }; + + IncrementalParserSource.prototype.tryGetTokenFromOldSourceUnit = function () { + var token = this._oldSourceUnitCursor.currentToken(); + + return this.canReuseTokenFromOldSourceUnit(this.absolutePosition(), token) ? token : null; + }; + + IncrementalParserSource.prototype.peekToken = function (n) { + if (this.canReadFromOldSourceUnit()) { + var token = this.tryPeekTokenFromOldSourceUnit(n); + if (token !== null) { + return token; + } + } + + return this._normalParserSource.peekToken(n); + }; + + IncrementalParserSource.prototype.tryPeekTokenFromOldSourceUnit = function (n) { + var currentPosition = this.absolutePosition(); + for (var i = 0; i < n; i++) { + var interimToken = this._oldSourceUnitCursor.peekToken(i); + if (!this.canReuseTokenFromOldSourceUnit(currentPosition, interimToken)) { + return null; + } + + currentPosition += interimToken.fullWidth(); + } + + var token = this._oldSourceUnitCursor.peekToken(n); + return this.canReuseTokenFromOldSourceUnit(currentPosition, token) ? token : null; + }; + + IncrementalParserSource.prototype.moveToNextNode = function () { + var currentElement = this._oldSourceUnitCursor.currentElement(); + var currentNode = this._oldSourceUnitCursor.currentNode(); + + this._oldSourceUnitCursor.moveToNextSibling(); + + var absolutePosition = this.absolutePosition() + currentNode.fullWidth(); + var previousToken = currentNode.lastToken(); + this._normalParserSource.resetToPosition(absolutePosition, previousToken); + + if (this._changeRange !== null) { + } + }; + + IncrementalParserSource.prototype.moveToNextToken = function () { + var currentToken = this.currentToken(); + + if (this._oldSourceUnitCursor.currentToken() === currentToken) { + this._oldSourceUnitCursor.moveToNextSibling(); + + var absolutePosition = this.absolutePosition() + currentToken.fullWidth(); + var previousToken = currentToken; + this._normalParserSource.resetToPosition(absolutePosition, previousToken); + + if (this._changeRange !== null) { + } + } else { + this._changeDelta -= currentToken.fullWidth(); + + this._normalParserSource.moveToNextToken(); + + if (this._changeRange !== null) { + var changeRangeSpanInNewText = this._changeRange.newSpan(); + if (this.absolutePosition() >= changeRangeSpanInNewText.end()) { + this._changeDelta += this._changeRange.newLength() - this._changeRange.span().length(); + this._changeRange = null; + } + } + } + }; + return IncrementalParserSource; + })(); + + var ParserImpl = (function () { + function ParserImpl(fileName, lineMap, source, parseOptions) { + this.listParsingState = 0; + this.isInStrictMode = false; + this.diagnostics = []; + this.factory = TypeScript.Syntax.normalModeFactory; + this.mergeTokensStorage = []; + this.arrayPool = []; + this.fileName = fileName; + this.lineMap = lineMap; + this.source = source; + this.parseOptions = parseOptions; + } + ParserImpl.prototype.getRewindPoint = function () { + var rewindPoint = this.source.getRewindPoint(); + + rewindPoint.diagnosticsCount = this.diagnostics.length; + + rewindPoint.isInStrictMode = this.isInStrictMode; + rewindPoint.listParsingState = this.listParsingState; + + return rewindPoint; + }; + + ParserImpl.prototype.rewind = function (rewindPoint) { + this.source.rewind(rewindPoint); + + this.diagnostics.length = rewindPoint.diagnosticsCount; + }; + + ParserImpl.prototype.releaseRewindPoint = function (rewindPoint) { + this.source.releaseRewindPoint(rewindPoint); + }; + + ParserImpl.prototype.currentTokenStart = function () { + return this.source.absolutePosition() + this.currentToken().leadingTriviaWidth(); + }; + + ParserImpl.prototype.previousTokenStart = function () { + if (this.previousToken() === null) { + return 0; + } + + return this.source.absolutePosition() - this.previousToken().fullWidth() + this.previousToken().leadingTriviaWidth(); + }; + + ParserImpl.prototype.previousTokenEnd = function () { + if (this.previousToken() === null) { + return 0; + } + + return this.previousTokenStart() + this.previousToken().width(); + }; + + ParserImpl.prototype.currentNode = function () { + var node = this.source.currentNode(); + + if (node === null || node.parsedInStrictMode() !== this.isInStrictMode) { + return null; + } + + return node; + }; + + ParserImpl.prototype.currentToken = function () { + return this.source.currentToken(); + }; + + ParserImpl.prototype.currentTokenAllowingRegularExpression = function () { + return this.source.currentTokenAllowingRegularExpression(); + }; + + ParserImpl.prototype.peekToken = function (n) { + return this.source.peekToken(n); + }; + + ParserImpl.prototype.eatAnyToken = function () { + var token = this.currentToken(); + this.moveToNextToken(); + return token; + }; + + ParserImpl.prototype.moveToNextToken = function () { + this.source.moveToNextToken(); + }; + + ParserImpl.prototype.previousToken = function () { + return this.source.previousToken(); + }; + + ParserImpl.prototype.eatNode = function () { + var node = this.source.currentNode(); + this.source.moveToNextNode(); + return node; + }; + + ParserImpl.prototype.eatToken = function (kind) { + var token = this.currentToken(); + if (token.tokenKind === kind) { + this.moveToNextToken(); + return token; + } + + return this.createMissingToken(kind, token); + }; + + ParserImpl.prototype.tryEatToken = function (kind) { + if (this.currentToken().tokenKind === kind) { + return this.eatToken(kind); + } + + return null; + }; + + ParserImpl.prototype.tryEatKeyword = function (kind) { + if (this.currentToken().tokenKind === kind) { + return this.eatKeyword(kind); + } + + return null; + }; + + ParserImpl.prototype.eatKeyword = function (kind) { + var token = this.currentToken(); + if (token.tokenKind === kind) { + this.moveToNextToken(); + return token; + } + + return this.createMissingToken(kind, token); + }; + + ParserImpl.prototype.isIdentifier = function (token) { + var tokenKind = token.tokenKind; + + if (tokenKind === 11 /* IdentifierName */) { + return true; + } + + if (tokenKind >= 51 /* FirstFutureReservedStrictKeyword */) { + if (tokenKind <= 59 /* LastFutureReservedStrictKeyword */) { + return !this.isInStrictMode; + } + + return tokenKind <= 69 /* LastTypeScriptKeyword */; + } + + return false; + }; + + ParserImpl.prototype.eatIdentifierNameToken = function () { + var token = this.currentToken(); + + if (token.tokenKind === 11 /* IdentifierName */) { + this.moveToNextToken(); + return token; + } + + if (TypeScript.SyntaxFacts.isAnyKeyword(token.tokenKind)) { + this.moveToNextToken(); + return TypeScript.Syntax.convertToIdentifierName(token); + } + + return this.createMissingToken(11 /* IdentifierName */, token); + }; + + ParserImpl.prototype.eatIdentifierToken = function () { + var token = this.currentToken(); + if (this.isIdentifier(token)) { + this.moveToNextToken(); + + if (token.tokenKind === 11 /* IdentifierName */) { + return token; + } + + return TypeScript.Syntax.convertToIdentifierName(token); + } + + return this.createMissingToken(11 /* IdentifierName */, token); + }; + + ParserImpl.prototype.canEatAutomaticSemicolon = function (allowWithoutNewLine) { + var token = this.currentToken(); + + if (token.tokenKind === 10 /* EndOfFileToken */) { + return true; + } + + if (token.tokenKind === 71 /* CloseBraceToken */) { + return true; + } + + if (allowWithoutNewLine) { + return true; + } + + if (this.previousToken() !== null && this.previousToken().hasTrailingNewLine()) { + return true; + } + + return false; + }; + + ParserImpl.prototype.canEatExplicitOrAutomaticSemicolon = function (allowWithoutNewline) { + var token = this.currentToken(); + + if (token.tokenKind === 78 /* SemicolonToken */) { + return true; + } + + return this.canEatAutomaticSemicolon(allowWithoutNewline); + }; + + ParserImpl.prototype.eatExplicitOrAutomaticSemicolon = function (allowWithoutNewline) { + var token = this.currentToken(); + + if (token.tokenKind === 78 /* SemicolonToken */) { + return this.eatToken(78 /* SemicolonToken */); + } + + if (this.canEatAutomaticSemicolon(allowWithoutNewline)) { + var semicolonToken = TypeScript.Syntax.emptyToken(78 /* SemicolonToken */); + + if (!this.parseOptions.allowAutomaticSemicolonInsertion()) { + this.addDiagnostic(new TypeScript.Diagnostic(this.fileName, this.previousTokenEnd(), 0, TypeScript.DiagnosticCode.Automatic_semicolon_insertion_not_allowed, null)); + } + + return semicolonToken; + } + + return this.eatToken(78 /* SemicolonToken */); + }; + + ParserImpl.prototype.isKeyword = function (kind) { + if (kind >= 15 /* FirstKeyword */) { + if (kind <= 50 /* LastFutureReservedKeyword */) { + return true; + } + + if (this.isInStrictMode) { + return kind <= 59 /* LastFutureReservedStrictKeyword */; + } + } + + return false; + }; + + ParserImpl.prototype.createMissingToken = function (expectedKind, actual) { + var diagnostic = this.getExpectedTokenDiagnostic(expectedKind, actual); + this.addDiagnostic(diagnostic); + + return TypeScript.Syntax.emptyToken(expectedKind); + }; + + ParserImpl.prototype.getExpectedTokenDiagnostic = function (expectedKind, actual) { + var token = this.currentToken(); + + if (TypeScript.SyntaxFacts.isAnyKeyword(expectedKind) || TypeScript.SyntaxFacts.isAnyPunctuation(expectedKind)) { + return new TypeScript.Diagnostic(this.fileName, this.currentTokenStart(), token.width(), TypeScript.DiagnosticCode._0_expected, [TypeScript.SyntaxFacts.getText(expectedKind)]); + } else { + if (actual !== null && TypeScript.SyntaxFacts.isAnyKeyword(actual.tokenKind)) { + return new TypeScript.Diagnostic(this.fileName, this.currentTokenStart(), token.width(), TypeScript.DiagnosticCode.Identifier_expected_0_is_a_keyword, [TypeScript.SyntaxFacts.getText(actual.tokenKind)]); + } else { + return new TypeScript.Diagnostic(this.fileName, this.currentTokenStart(), token.width(), TypeScript.DiagnosticCode.Identifier_expected, null); + } + } + }; + + ParserImpl.getPrecedence = function (expressionKind) { + switch (expressionKind) { + case 172 /* CommaExpression */: + return 1 /* CommaExpressionPrecedence */; + + case 173 /* AssignmentExpression */: + case 174 /* AddAssignmentExpression */: + case 175 /* SubtractAssignmentExpression */: + case 176 /* MultiplyAssignmentExpression */: + case 177 /* DivideAssignmentExpression */: + case 178 /* ModuloAssignmentExpression */: + case 179 /* AndAssignmentExpression */: + case 180 /* ExclusiveOrAssignmentExpression */: + case 181 /* OrAssignmentExpression */: + case 182 /* LeftShiftAssignmentExpression */: + case 183 /* SignedRightShiftAssignmentExpression */: + case 184 /* UnsignedRightShiftAssignmentExpression */: + return 2 /* AssignmentExpressionPrecedence */; + + case 185 /* ConditionalExpression */: + return 3 /* ConditionalExpressionPrecedence */; + + case 186 /* LogicalOrExpression */: + return 5 /* LogicalOrExpressionPrecedence */; + + case 187 /* LogicalAndExpression */: + return 6 /* LogicalAndExpressionPrecedence */; + + case 188 /* BitwiseOrExpression */: + return 7 /* BitwiseOrExpressionPrecedence */; + + case 189 /* BitwiseExclusiveOrExpression */: + return 8 /* BitwiseExclusiveOrExpressionPrecedence */; + + case 190 /* BitwiseAndExpression */: + return 9 /* BitwiseAndExpressionPrecedence */; + + case 191 /* EqualsWithTypeConversionExpression */: + case 192 /* NotEqualsWithTypeConversionExpression */: + case 193 /* EqualsExpression */: + case 194 /* NotEqualsExpression */: + return 10 /* EqualityExpressionPrecedence */; + + case 195 /* LessThanExpression */: + case 196 /* GreaterThanExpression */: + case 197 /* LessThanOrEqualExpression */: + case 198 /* GreaterThanOrEqualExpression */: + case 199 /* InstanceOfExpression */: + case 200 /* InExpression */: + return 11 /* RelationalExpressionPrecedence */; + + case 201 /* LeftShiftExpression */: + case 202 /* SignedRightShiftExpression */: + case 203 /* UnsignedRightShiftExpression */: + return 12 /* ShiftExpressionPrecdence */; + + case 207 /* AddExpression */: + case 208 /* SubtractExpression */: + return 13 /* AdditiveExpressionPrecedence */; + + case 204 /* MultiplyExpression */: + case 205 /* DivideExpression */: + case 206 /* ModuloExpression */: + return 14 /* MultiplicativeExpressionPrecedence */; + + case 163 /* PlusExpression */: + case 164 /* NegateExpression */: + case 165 /* BitwiseNotExpression */: + case 166 /* LogicalNotExpression */: + case 169 /* DeleteExpression */: + case 170 /* TypeOfExpression */: + case 171 /* VoidExpression */: + case 167 /* PreIncrementExpression */: + case 168 /* PreDecrementExpression */: + return 15 /* UnaryExpressionPrecedence */; + } + + throw TypeScript.Errors.invalidOperation(); + }; + + ParserImpl.prototype.addSkippedTokenAfterNodeOrToken = function (nodeOrToken, skippedToken) { + if (nodeOrToken.isToken()) { + return this.addSkippedTokenAfterToken(nodeOrToken, skippedToken); + } else if (nodeOrToken.isNode()) { + return this.addSkippedTokenAfterNode(nodeOrToken, skippedToken); + } else { + throw TypeScript.Errors.invalidOperation(); + } + }; + + ParserImpl.prototype.addSkippedTokenAfterNode = function (node, skippedToken) { + var oldToken = node.lastToken(); + var newToken = this.addSkippedTokenAfterToken(oldToken, skippedToken); + + return node.replaceToken(oldToken, newToken); + }; + + ParserImpl.prototype.addSkippedTokensBeforeNode = function (node, skippedTokens) { + if (skippedTokens.length > 0) { + var oldToken = node.firstToken(); + var newToken = this.addSkippedTokensBeforeToken(oldToken, skippedTokens); + + return node.replaceToken(oldToken, newToken); + } + + return node; + }; + + ParserImpl.prototype.addSkippedTokensBeforeToken = function (token, skippedTokens) { + var leadingTrivia = []; + for (var i = 0, n = skippedTokens.length; i < n; i++) { + this.addSkippedTokenToTriviaArray(leadingTrivia, skippedTokens[i]); + } + + this.addTriviaTo(token.leadingTrivia(), leadingTrivia); + + this.returnArray(skippedTokens); + return token.withLeadingTrivia(TypeScript.Syntax.triviaList(leadingTrivia)); + }; + + ParserImpl.prototype.addSkippedTokensAfterToken = function (token, skippedTokens) { + if (skippedTokens.length === 0) { + this.returnArray(skippedTokens); + return token; + } + + var trailingTrivia = token.trailingTrivia().toArray(); + + for (var i = 0, n = skippedTokens.length; i < n; i++) { + this.addSkippedTokenToTriviaArray(trailingTrivia, skippedTokens[i]); + } + + this.returnArray(skippedTokens); + return token.withTrailingTrivia(TypeScript.Syntax.triviaList(trailingTrivia)); + }; + + ParserImpl.prototype.addSkippedTokenAfterToken = function (token, skippedToken) { + var trailingTrivia = token.trailingTrivia().toArray(); + this.addSkippedTokenToTriviaArray(trailingTrivia, skippedToken); + + return token.withTrailingTrivia(TypeScript.Syntax.triviaList(trailingTrivia)); + }; + + ParserImpl.prototype.addSkippedTokenToTriviaArray = function (array, skippedToken) { + this.addTriviaTo(skippedToken.leadingTrivia(), array); + + var trimmedToken = skippedToken.withLeadingTrivia(TypeScript.Syntax.emptyTriviaList).withTrailingTrivia(TypeScript.Syntax.emptyTriviaList); + array.push(TypeScript.Syntax.skippedTokenTrivia(trimmedToken)); + + this.addTriviaTo(skippedToken.trailingTrivia(), array); + }; + + ParserImpl.prototype.addTriviaTo = function (list, array) { + for (var i = 0, n = list.count(); i < n; i++) { + array.push(list.syntaxTriviaAt(i)); + } + }; + + ParserImpl.prototype.parseSyntaxTree = function (isDeclaration) { + var sourceUnit = this.parseSourceUnit(); + + var allDiagnostics = this.source.tokenDiagnostics().concat(this.diagnostics); + allDiagnostics.sort(function (a, b) { + return a.start() - b.start(); + }); + + return new TypeScript.SyntaxTree(sourceUnit, isDeclaration, allDiagnostics, this.fileName, this.lineMap, this.parseOptions); + }; + + ParserImpl.prototype.setStrictMode = function (isInStrictMode) { + this.isInStrictMode = isInStrictMode; + this.factory = isInStrictMode ? TypeScript.Syntax.strictModeFactory : TypeScript.Syntax.normalModeFactory; + }; + + ParserImpl.prototype.parseSourceUnit = function () { + var savedIsInStrictMode = this.isInStrictMode; + + var result = this.parseSyntaxList(1 /* SourceUnit_ModuleElements */, ParserImpl.updateStrictModeState); + var moduleElements = result.list; + + this.setStrictMode(savedIsInStrictMode); + + var sourceUnit = this.factory.sourceUnit(moduleElements, this.currentToken()); + sourceUnit = this.addSkippedTokensBeforeNode(sourceUnit, result.skippedTokens); + + return sourceUnit; + }; + + ParserImpl.updateStrictModeState = function (parser, items) { + if (!parser.isInStrictMode) { + for (var i = 0; i < items.length; i++) { + var item = items[i]; + if (!TypeScript.SyntaxFacts.isDirectivePrologueElement(item)) { + return; + } + } + + parser.setStrictMode(TypeScript.SyntaxFacts.isUseStrictDirective(items[items.length - 1])); + } + }; + + ParserImpl.prototype.isModuleElement = function (inErrorRecovery) { + if (this.currentNode() !== null && this.currentNode().isModuleElement()) { + return true; + } + + return this.isImportDeclaration() || this.isExportAssignment() || this.isModuleDeclaration() || this.isInterfaceDeclaration() || this.isClassDeclaration() || this.isEnumDeclaration() || this.isStatement(inErrorRecovery); + }; + + ParserImpl.prototype.parseModuleElement = function () { + if (this.currentNode() !== null && this.currentNode().isModuleElement()) { + return this.eatNode(); + } + + if (this.isImportDeclaration()) { + return this.parseImportDeclaration(); + } else if (this.isExportAssignment()) { + return this.parseExportAssignment(); + } else if (this.isModuleDeclaration()) { + return this.parseModuleDeclaration(); + } else if (this.isInterfaceDeclaration()) { + return this.parseInterfaceDeclaration(); + } else if (this.isClassDeclaration()) { + return this.parseClassDeclaration(); + } else if (this.isEnumDeclaration()) { + return this.parseEnumDeclaration(); + } else if (this.isStatement(false)) { + return this.parseStatement(); + } else { + throw TypeScript.Errors.invalidOperation(); + } + }; + + ParserImpl.prototype.isImportDeclaration = function () { + var index = this.modifierCount(); + + if (index > 0 && this.peekToken(index).tokenKind === 49 /* ImportKeyword */) { + return true; + } + + return this.currentToken().tokenKind === 49 /* ImportKeyword */ && this.isIdentifier(this.peekToken(1)); + }; + + ParserImpl.prototype.parseImportDeclaration = function () { + var modifiers = this.parseModifiers(); + var importKeyword = this.eatKeyword(49 /* ImportKeyword */); + var identifier = this.eatIdentifierToken(); + var equalsToken = this.eatToken(107 /* EqualsToken */); + var moduleReference = this.parseModuleReference(); + var semicolonToken = this.eatExplicitOrAutomaticSemicolon(false); + + return this.factory.importDeclaration(modifiers, importKeyword, identifier, equalsToken, moduleReference, semicolonToken); + }; + + ParserImpl.prototype.isExportAssignment = function () { + return this.currentToken().tokenKind === 47 /* ExportKeyword */ && this.peekToken(1).tokenKind === 107 /* EqualsToken */; + }; + + ParserImpl.prototype.parseExportAssignment = function () { + var exportKeyword = this.eatKeyword(47 /* ExportKeyword */); + var equalsToken = this.eatToken(107 /* EqualsToken */); + var identifier = this.eatIdentifierToken(); + var semicolonToken = this.eatExplicitOrAutomaticSemicolon(false); + + return this.factory.exportAssignment(exportKeyword, equalsToken, identifier, semicolonToken); + }; + + ParserImpl.prototype.parseModuleReference = function () { + if (this.isExternalModuleReference()) { + return this.parseExternalModuleReference(); + } else { + return this.parseModuleNameModuleReference(); + } + }; + + ParserImpl.prototype.isExternalModuleReference = function () { + var token0 = this.currentToken(); + if (token0.tokenKind === 66 /* RequireKeyword */) { + return this.peekToken(1).tokenKind === 72 /* OpenParenToken */; + } + + return false; + }; + + ParserImpl.prototype.parseExternalModuleReference = function () { + var requireKeyword = this.eatKeyword(66 /* RequireKeyword */); + var openParenToken = this.eatToken(72 /* OpenParenToken */); + var stringLiteral = this.eatToken(14 /* StringLiteral */); + var closeParenToken = this.eatToken(73 /* CloseParenToken */); + + return this.factory.externalModuleReference(requireKeyword, openParenToken, stringLiteral, closeParenToken); + }; + + ParserImpl.prototype.parseModuleNameModuleReference = function () { + var name = this.parseName(); + return this.factory.moduleNameModuleReference(name); + }; + + ParserImpl.prototype.parseIdentifierName = function () { + var identifierName = this.eatIdentifierNameToken(); + return identifierName; + }; + + ParserImpl.prototype.isName = function () { + return this.isIdentifier(this.currentToken()); + }; + + ParserImpl.prototype.tryParseTypeArgumentList = function (inExpression) { + if (this.currentToken().kind() !== 80 /* LessThanToken */) { + return null; + } + + var lessThanToken; + var greaterThanToken; + var result; + var typeArguments; + + if (!inExpression) { + lessThanToken = this.eatToken(80 /* LessThanToken */); + + result = this.parseSeparatedSyntaxList(262144 /* TypeArgumentList_Types */); + typeArguments = result.list; + lessThanToken = this.addSkippedTokensAfterToken(lessThanToken, result.skippedTokens); + + greaterThanToken = this.eatToken(81 /* GreaterThanToken */); + + return this.factory.typeArgumentList(lessThanToken, typeArguments, greaterThanToken); + } + + var rewindPoint = this.getRewindPoint(); + try { + lessThanToken = this.eatToken(80 /* LessThanToken */); + + result = this.parseSeparatedSyntaxList(262144 /* TypeArgumentList_Types */); + typeArguments = result.list; + lessThanToken = this.addSkippedTokensAfterToken(lessThanToken, result.skippedTokens); + + greaterThanToken = this.eatToken(81 /* GreaterThanToken */); + + if (greaterThanToken.fullWidth() === 0 || !this.canFollowTypeArgumentListInExpression(this.currentToken().kind())) { + this.rewind(rewindPoint); + return null; + } + + return this.factory.typeArgumentList(lessThanToken, typeArguments, greaterThanToken); + } finally { + this.releaseRewindPoint(rewindPoint); + } + }; + + ParserImpl.prototype.canFollowTypeArgumentListInExpression = function (kind) { + switch (kind) { + case 72 /* OpenParenToken */: + case 76 /* DotToken */: + + case 73 /* CloseParenToken */: + case 75 /* CloseBracketToken */: + case 106 /* ColonToken */: + case 78 /* SemicolonToken */: + case 79 /* CommaToken */: + case 105 /* QuestionToken */: + case 84 /* EqualsEqualsToken */: + case 87 /* EqualsEqualsEqualsToken */: + case 86 /* ExclamationEqualsToken */: + case 88 /* ExclamationEqualsEqualsToken */: + case 103 /* AmpersandAmpersandToken */: + case 104 /* BarBarToken */: + case 100 /* CaretToken */: + case 98 /* AmpersandToken */: + case 99 /* BarToken */: + case 71 /* CloseBraceToken */: + case 10 /* EndOfFileToken */: + return true; + + default: + return false; + } + }; + + ParserImpl.prototype.parseName = function () { + var shouldContinue = this.isIdentifier(this.currentToken()); + var current = this.eatIdentifierToken(); + + while (shouldContinue && this.currentToken().tokenKind === 76 /* DotToken */) { + var dotToken = this.eatToken(76 /* DotToken */); + + var currentToken = this.currentToken(); + var identifierName; + + if (TypeScript.SyntaxFacts.isAnyKeyword(currentToken.tokenKind) && this.previousToken().hasTrailingNewLine() && !currentToken.hasTrailingNewLine() && TypeScript.SyntaxFacts.isIdentifierNameOrAnyKeyword(this.peekToken(1))) { + identifierName = this.createMissingToken(11 /* IdentifierName */, currentToken); + } else { + identifierName = this.eatIdentifierNameToken(); + } + + current = this.factory.qualifiedName(current, dotToken, identifierName); + + shouldContinue = identifierName.fullWidth() > 0; + } + + return current; + }; + + ParserImpl.prototype.isEnumDeclaration = function () { + var index = this.modifierCount(); + + if (index > 0 && this.peekToken(index).tokenKind === 46 /* EnumKeyword */) { + return true; + } + + return this.currentToken().tokenKind === 46 /* EnumKeyword */ && this.isIdentifier(this.peekToken(1)); + }; + + ParserImpl.prototype.parseEnumDeclaration = function () { + var modifiers = this.parseModifiers(); + var enumKeyword = this.eatKeyword(46 /* EnumKeyword */); + var identifier = this.eatIdentifierToken(); + + var openBraceToken = this.eatToken(70 /* OpenBraceToken */); + var enumElements = TypeScript.Syntax.emptySeparatedList; + + if (openBraceToken.width() > 0) { + var result = this.parseSeparatedSyntaxList(256 /* EnumDeclaration_EnumElements */); + enumElements = result.list; + openBraceToken = this.addSkippedTokensAfterToken(openBraceToken, result.skippedTokens); + } + + var closeBraceToken = this.eatToken(71 /* CloseBraceToken */); + + return this.factory.enumDeclaration(modifiers, enumKeyword, identifier, openBraceToken, enumElements, closeBraceToken); + }; + + ParserImpl.prototype.isEnumElement = function (inErrorRecovery) { + if (this.currentNode() !== null && this.currentNode().kind() === 243 /* EnumElement */) { + return true; + } + + return this.isPropertyName(this.currentToken(), inErrorRecovery); + }; + + ParserImpl.prototype.parseEnumElement = function () { + if (this.currentNode() !== null && this.currentNode().kind() === 243 /* EnumElement */) { + return this.eatNode(); + } + + var propertyName = this.eatPropertyName(); + var equalsValueClause = null; + if (this.isEqualsValueClause(false)) { + equalsValueClause = this.parseEqualsValueClause(true); + } + + return this.factory.enumElement(propertyName, equalsValueClause); + }; + + ParserImpl.isModifier = function (token) { + switch (token.tokenKind) { + case 57 /* PublicKeyword */: + case 55 /* PrivateKeyword */: + case 58 /* StaticKeyword */: + case 47 /* ExportKeyword */: + case 63 /* DeclareKeyword */: + return true; + + default: + return false; + } + }; + + ParserImpl.prototype.modifierCount = function () { + var modifierCount = 0; + while (true) { + if (ParserImpl.isModifier(this.peekToken(modifierCount))) { + modifierCount++; + continue; + } + + break; + } + + return modifierCount; + }; + + ParserImpl.prototype.parseModifiers = function () { + var tokens = this.getArray(); + + while (true) { + if (ParserImpl.isModifier(this.currentToken())) { + tokens.push(this.eatAnyToken()); + continue; + } + + break; + } + + var result = TypeScript.Syntax.list(tokens); + + this.returnZeroOrOneLengthArray(tokens); + + return result; + }; + + ParserImpl.prototype.isClassDeclaration = function () { + var index = this.modifierCount(); + + if (index > 0 && this.peekToken(index).tokenKind === 44 /* ClassKeyword */) { + return true; + } + + return this.currentToken().tokenKind === 44 /* ClassKeyword */ && this.isIdentifier(this.peekToken(1)); + }; + + ParserImpl.prototype.parseHeritageClauses = function () { + var heritageClauses = TypeScript.Syntax.emptyList; + + if (this.isHeritageClause()) { + var result = this.parseSyntaxList(1024 /* ClassOrInterfaceDeclaration_HeritageClauses */); + heritageClauses = result.list; + TypeScript.Debug.assert(result.skippedTokens.length === 0); + } + + return heritageClauses; + }; + + ParserImpl.prototype.parseClassDeclaration = function () { + var modifiers = this.parseModifiers(); + + var classKeyword = this.eatKeyword(44 /* ClassKeyword */); + var identifier = this.eatIdentifierToken(); + var typeParameterList = this.parseOptionalTypeParameterList(false); + var heritageClauses = this.parseHeritageClauses(); + var openBraceToken = this.eatToken(70 /* OpenBraceToken */); + var classElements = TypeScript.Syntax.emptyList; + + if (openBraceToken.width() > 0) { + var result = this.parseSyntaxList(2 /* ClassDeclaration_ClassElements */); + + classElements = result.list; + openBraceToken = this.addSkippedTokensAfterToken(openBraceToken, result.skippedTokens); + } + + var closeBraceToken = this.eatToken(71 /* CloseBraceToken */); + return this.factory.classDeclaration(modifiers, classKeyword, identifier, typeParameterList, heritageClauses, openBraceToken, classElements, closeBraceToken); + }; + + ParserImpl.prototype.isConstructorDeclaration = function () { + return this.currentToken().tokenKind === 62 /* ConstructorKeyword */; + }; + + ParserImpl.isPublicOrPrivateKeyword = function (token) { + return token.tokenKind === 57 /* PublicKeyword */ || token.tokenKind === 55 /* PrivateKeyword */; + }; + + ParserImpl.prototype.isMemberAccessorDeclaration = function (inErrorRecovery) { + var index = this.modifierCount(); + + if (this.peekToken(index).tokenKind !== 64 /* GetKeyword */ && this.peekToken(index).tokenKind !== 68 /* SetKeyword */) { + return false; + } + + index++; + return this.isPropertyName(this.peekToken(index), inErrorRecovery); + }; + + ParserImpl.prototype.parseMemberAccessorDeclaration = function () { + var modifiers = this.parseModifiers(); + + if (this.currentToken().tokenKind === 64 /* GetKeyword */) { + return this.parseGetMemberAccessorDeclaration(modifiers); + } else if (this.currentToken().tokenKind === 68 /* SetKeyword */) { + return this.parseSetMemberAccessorDeclaration(modifiers); + } else { + throw TypeScript.Errors.invalidOperation(); + } + }; + + ParserImpl.prototype.parseGetMemberAccessorDeclaration = function (modifiers) { + var getKeyword = this.eatKeyword(64 /* GetKeyword */); + var propertyName = this.eatPropertyName(); + var parameterList = this.parseParameterList(); + var typeAnnotation = this.parseOptionalTypeAnnotation(false); + var block = this.parseBlock(false, false); + + return this.factory.getMemberAccessorDeclaration(modifiers, getKeyword, propertyName, parameterList, typeAnnotation, block); + }; + + ParserImpl.prototype.parseSetMemberAccessorDeclaration = function (modifiers) { + var setKeyword = this.eatKeyword(68 /* SetKeyword */); + var propertyName = this.eatPropertyName(); + var parameterList = this.parseParameterList(); + var block = this.parseBlock(false, false); + + return this.factory.setMemberAccessorDeclaration(modifiers, setKeyword, propertyName, parameterList, block); + }; + + ParserImpl.prototype.isClassElement = function (inErrorRecovery) { + if (this.currentNode() !== null && this.currentNode().isClassElement()) { + return true; + } + + return this.isConstructorDeclaration() || this.isMemberFunctionDeclaration(inErrorRecovery) || this.isMemberAccessorDeclaration(inErrorRecovery) || this.isMemberVariableDeclaration(inErrorRecovery) || this.isIndexSignature(); + }; + + ParserImpl.prototype.parseConstructorDeclaration = function () { + var constructorKeyword = this.eatKeyword(62 /* ConstructorKeyword */); + var parameterList = this.parseParameterList(); + + var semicolonToken = null; + var block = null; + + if (this.isBlock()) { + block = this.parseBlock(false, true); + } else { + semicolonToken = this.eatExplicitOrAutomaticSemicolon(false); + } + + return this.factory.constructorDeclaration(constructorKeyword, parameterList, block, semicolonToken); + }; + + ParserImpl.prototype.isMemberFunctionDeclaration = function (inErrorRecovery) { + var index = 0; + + while (true) { + var token = this.peekToken(index); + if (this.isPropertyName(token, inErrorRecovery) && this.isCallSignature(index + 1)) { + return true; + } + + if (ParserImpl.isModifier(token)) { + index++; + continue; + } + + return false; + } + }; + + ParserImpl.prototype.parseMemberFunctionDeclaration = function () { + var modifierArray = this.getArray(); + + while (true) { + var currentToken = this.currentToken(); + if (this.isPropertyName(currentToken, false) && this.isCallSignature(1)) { + break; + } + + TypeScript.Debug.assert(ParserImpl.isModifier(currentToken)); + modifierArray.push(this.eatAnyToken()); + } + + var modifiers = TypeScript.Syntax.list(modifierArray); + this.returnZeroOrOneLengthArray(modifierArray); + + var propertyName = this.eatPropertyName(); + var callSignature = this.parseCallSignature(false); + + var newCallSignature = this.tryAddUnexpectedEqualsGreaterThanToken(callSignature); + var parseBlockEvenWithNoOpenBrace = callSignature !== newCallSignature; + callSignature = newCallSignature; + + var block = null; + var semicolon = null; + + if (parseBlockEvenWithNoOpenBrace || this.isBlock()) { + block = this.parseBlock(parseBlockEvenWithNoOpenBrace, true); + } else { + semicolon = this.eatExplicitOrAutomaticSemicolon(false); + } + + return this.factory.memberFunctionDeclaration(modifiers, propertyName, callSignature, block, semicolon); + }; + + ParserImpl.prototype.isDefinitelyMemberVariablePropertyName = function (index) { + if (TypeScript.SyntaxFacts.isAnyKeyword(this.peekToken(index).tokenKind)) { + switch (this.peekToken(index + 1).tokenKind) { + case 78 /* SemicolonToken */: + case 107 /* EqualsToken */: + case 106 /* ColonToken */: + case 71 /* CloseBraceToken */: + case 10 /* EndOfFileToken */: + return true; + default: + return false; + } + } else { + return true; + } + }; + + ParserImpl.prototype.isMemberVariableDeclaration = function (inErrorRecovery) { + var index = 0; + + while (true) { + var token = this.peekToken(index); + if (this.isPropertyName(token, inErrorRecovery) && this.isDefinitelyMemberVariablePropertyName(index)) { + return true; + } + + if (ParserImpl.isModifier(this.peekToken(index))) { + index++; + continue; + } + + return false; + } + }; + + ParserImpl.prototype.parseMemberVariableDeclaration = function () { + var modifierArray = this.getArray(); + + while (true) { + var currentToken = this.currentToken(); + if (this.isPropertyName(currentToken, false) && this.isDefinitelyMemberVariablePropertyName(0)) { + break; + } + + TypeScript.Debug.assert(ParserImpl.isModifier(currentToken)); + modifierArray.push(this.eatAnyToken()); + } + + var modifiers = TypeScript.Syntax.list(modifierArray); + this.returnZeroOrOneLengthArray(modifierArray); + + var variableDeclarator = this.parseVariableDeclarator(true, true); + var semicolon = this.eatExplicitOrAutomaticSemicolon(false); + + return this.factory.memberVariableDeclaration(modifiers, variableDeclarator, semicolon); + }; + + ParserImpl.prototype.parseClassElement = function (inErrorRecovery) { + if (this.currentNode() !== null && this.currentNode().isClassElement()) { + return this.eatNode(); + } + + if (this.isConstructorDeclaration()) { + return this.parseConstructorDeclaration(); + } else if (this.isMemberFunctionDeclaration(inErrorRecovery)) { + return this.parseMemberFunctionDeclaration(); + } else if (this.isMemberAccessorDeclaration(inErrorRecovery)) { + return this.parseMemberAccessorDeclaration(); + } else if (this.isMemberVariableDeclaration(inErrorRecovery)) { + return this.parseMemberVariableDeclaration(); + } else if (this.isIndexSignature()) { + return this.parseIndexSignature(); + } else { + throw TypeScript.Errors.invalidOperation(); + } + }; + + ParserImpl.prototype.tryAddUnexpectedEqualsGreaterThanToken = function (callSignature) { + var token0 = this.currentToken(); + + var hasEqualsGreaterThanToken = token0.tokenKind === 85 /* EqualsGreaterThanToken */; + if (hasEqualsGreaterThanToken) { + var diagnostic = new TypeScript.Diagnostic(this.fileName, this.currentTokenStart(), token0.width(), TypeScript.DiagnosticCode.Unexpected_token_0_expected, [TypeScript.SyntaxFacts.getText(70 /* OpenBraceToken */)]); + this.addDiagnostic(diagnostic); + + var token = this.eatAnyToken(); + return this.addSkippedTokenAfterNode(callSignature, token0); + } + + return callSignature; + }; + + ParserImpl.prototype.isFunctionDeclaration = function () { + var index = this.modifierCount(); + return this.peekToken(index).tokenKind === 27 /* FunctionKeyword */; + }; + + ParserImpl.prototype.parseFunctionDeclaration = function () { + var modifiers = this.parseModifiers(); + var functionKeyword = this.eatKeyword(27 /* FunctionKeyword */); + var identifier = this.eatIdentifierToken(); + var callSignature = this.parseCallSignature(false); + + var newCallSignature = this.tryAddUnexpectedEqualsGreaterThanToken(callSignature); + var parseBlockEvenWithNoOpenBrace = callSignature !== newCallSignature; + callSignature = newCallSignature; + + var semicolonToken = null; + var block = null; + + if (parseBlockEvenWithNoOpenBrace || this.isBlock()) { + block = this.parseBlock(parseBlockEvenWithNoOpenBrace, true); + } else { + semicolonToken = this.eatExplicitOrAutomaticSemicolon(false); + } + + return this.factory.functionDeclaration(modifiers, functionKeyword, identifier, callSignature, block, semicolonToken); + }; + + ParserImpl.prototype.isModuleDeclaration = function () { + var index = this.modifierCount(); + + if (index > 0 && this.peekToken(index).tokenKind === 65 /* ModuleKeyword */) { + return true; + } + + if (this.currentToken().tokenKind === 65 /* ModuleKeyword */) { + var token1 = this.peekToken(1); + return this.isIdentifier(token1) || token1.tokenKind === 14 /* StringLiteral */; + } + + return false; + }; + + ParserImpl.prototype.parseModuleDeclaration = function () { + var modifiers = this.parseModifiers(); + var moduleKeyword = this.eatKeyword(65 /* ModuleKeyword */); + + var moduleName = null; + var stringLiteral = null; + + if (this.currentToken().tokenKind === 14 /* StringLiteral */) { + stringLiteral = this.eatToken(14 /* StringLiteral */); + } else { + moduleName = this.parseName(); + } + + var openBraceToken = this.eatToken(70 /* OpenBraceToken */); + + var moduleElements = TypeScript.Syntax.emptyList; + if (openBraceToken.width() > 0) { + var result = this.parseSyntaxList(4 /* ModuleDeclaration_ModuleElements */); + moduleElements = result.list; + openBraceToken = this.addSkippedTokensAfterToken(openBraceToken, result.skippedTokens); + } + + var closeBraceToken = this.eatToken(71 /* CloseBraceToken */); + + return this.factory.moduleDeclaration(modifiers, moduleKeyword, moduleName, stringLiteral, openBraceToken, moduleElements, closeBraceToken); + }; + + ParserImpl.prototype.isInterfaceDeclaration = function () { + var index = this.modifierCount(); + + if (index > 0 && this.peekToken(index).tokenKind === 52 /* InterfaceKeyword */) { + return true; + } + + return this.currentToken().tokenKind === 52 /* InterfaceKeyword */ && this.isIdentifier(this.peekToken(1)); + }; + + ParserImpl.prototype.parseInterfaceDeclaration = function () { + var modifiers = this.parseModifiers(); + var interfaceKeyword = this.eatKeyword(52 /* InterfaceKeyword */); + var identifier = this.eatIdentifierToken(); + var typeParameterList = this.parseOptionalTypeParameterList(false); + var heritageClauses = this.parseHeritageClauses(); + + var objectType = this.parseObjectType(); + return this.factory.interfaceDeclaration(modifiers, interfaceKeyword, identifier, typeParameterList, heritageClauses, objectType); + }; + + ParserImpl.prototype.parseObjectType = function () { + var openBraceToken = this.eatToken(70 /* OpenBraceToken */); + + var typeMembers = TypeScript.Syntax.emptySeparatedList; + if (openBraceToken.width() > 0) { + var result = this.parseSeparatedSyntaxList(512 /* ObjectType_TypeMembers */); + typeMembers = result.list; + openBraceToken = this.addSkippedTokensAfterToken(openBraceToken, result.skippedTokens); + } + + var closeBraceToken = this.eatToken(71 /* CloseBraceToken */); + return this.factory.objectType(openBraceToken, typeMembers, closeBraceToken); + }; + + ParserImpl.prototype.isTypeMember = function (inErrorRecovery) { + if (this.currentNode() !== null && this.currentNode().isTypeMember()) { + return true; + } + + return this.isCallSignature(0) || this.isConstructSignature() || this.isIndexSignature() || this.isMethodSignature(inErrorRecovery) || this.isPropertySignature(inErrorRecovery); + }; + + ParserImpl.prototype.parseTypeMember = function () { + if (this.currentNode() !== null && this.currentNode().isTypeMember()) { + return this.eatNode(); + } + + if (this.isCallSignature(0)) { + return this.parseCallSignature(false); + } else if (this.isConstructSignature()) { + return this.parseConstructSignature(); + } else if (this.isIndexSignature()) { + return this.parseIndexSignature(); + } else if (this.isMethodSignature(false)) { + return this.parseMethodSignature(); + } else if (this.isPropertySignature(false)) { + return this.parsePropertySignature(); + } else { + throw TypeScript.Errors.invalidOperation(); + } + }; + + ParserImpl.prototype.parseConstructSignature = function () { + var newKeyword = this.eatKeyword(31 /* NewKeyword */); + var callSignature = this.parseCallSignature(false); + + return this.factory.constructSignature(newKeyword, callSignature); + }; + + ParserImpl.prototype.parseIndexSignature = function () { + var openBracketToken = this.eatToken(74 /* OpenBracketToken */); + var parameter = this.parseParameter(); + var closeBracketToken = this.eatToken(75 /* CloseBracketToken */); + var typeAnnotation = this.parseOptionalTypeAnnotation(false); + + return this.factory.indexSignature(openBracketToken, parameter, closeBracketToken, typeAnnotation); + }; + + ParserImpl.prototype.parseMethodSignature = function () { + var propertyName = this.eatPropertyName(); + var questionToken = this.tryEatToken(105 /* QuestionToken */); + var callSignature = this.parseCallSignature(false); + + return this.factory.methodSignature(propertyName, questionToken, callSignature); + }; + + ParserImpl.prototype.parsePropertySignature = function () { + var propertyName = this.eatPropertyName(); + var questionToken = this.tryEatToken(105 /* QuestionToken */); + var typeAnnotation = this.parseOptionalTypeAnnotation(false); + + return this.factory.propertySignature(propertyName, questionToken, typeAnnotation); + }; + + ParserImpl.prototype.isCallSignature = function (tokenIndex) { + var tokenKind = this.peekToken(tokenIndex).tokenKind; + return tokenKind === 72 /* OpenParenToken */ || tokenKind === 80 /* LessThanToken */; + }; + + ParserImpl.prototype.isConstructSignature = function () { + if (this.currentToken().tokenKind !== 31 /* NewKeyword */) { + return false; + } + + var token1 = this.peekToken(1); + return token1.tokenKind === 80 /* LessThanToken */ || token1.tokenKind === 72 /* OpenParenToken */; + }; + + ParserImpl.prototype.isIndexSignature = function () { + return this.currentToken().tokenKind === 74 /* OpenBracketToken */; + }; + + ParserImpl.prototype.isMethodSignature = function (inErrorRecovery) { + if (this.isPropertyName(this.currentToken(), inErrorRecovery)) { + if (this.isCallSignature(1)) { + return true; + } + + if (this.peekToken(1).tokenKind === 105 /* QuestionToken */ && this.isCallSignature(2)) { + return true; + } + } + + return false; + }; + + ParserImpl.prototype.isPropertySignature = function (inErrorRecovery) { + var currentToken = this.currentToken(); + + if (ParserImpl.isModifier(currentToken) && !currentToken.hasTrailingNewLine() && this.isPropertyName(this.peekToken(1), inErrorRecovery)) { + return false; + } + + return this.isPropertyName(currentToken, inErrorRecovery); + }; + + ParserImpl.prototype.isHeritageClause = function () { + var token0 = this.currentToken(); + return token0.tokenKind === 48 /* ExtendsKeyword */ || token0.tokenKind === 51 /* ImplementsKeyword */; + }; + + ParserImpl.prototype.isNotHeritageClauseTypeName = function () { + if (this.currentToken().tokenKind === 51 /* ImplementsKeyword */ || this.currentToken().tokenKind === 48 /* ExtendsKeyword */) { + return this.isIdentifier(this.peekToken(1)); + } + + return false; + }; + + ParserImpl.prototype.isHeritageClauseTypeName = function () { + if (this.isName()) { + return !this.isNotHeritageClauseTypeName(); + } + + return false; + }; + + ParserImpl.prototype.parseHeritageClause = function () { + var extendsOrImplementsKeyword = this.eatAnyToken(); + TypeScript.Debug.assert(extendsOrImplementsKeyword.tokenKind === 48 /* ExtendsKeyword */ || extendsOrImplementsKeyword.tokenKind === 51 /* ImplementsKeyword */); + + var result = this.parseSeparatedSyntaxList(2048 /* HeritageClause_TypeNameList */); + var typeNames = result.list; + extendsOrImplementsKeyword = this.addSkippedTokensAfterToken(extendsOrImplementsKeyword, result.skippedTokens); + + return this.factory.heritageClause(extendsOrImplementsKeyword, typeNames); + }; + + ParserImpl.prototype.isStatement = function (inErrorRecovery) { + if (this.currentNode() !== null && this.currentNode().isStatement()) { + return true; + } + + switch (this.currentToken().tokenKind) { + case 57 /* PublicKeyword */: + case 55 /* PrivateKeyword */: + case 58 /* StaticKeyword */: + var token1 = this.peekToken(1); + if (TypeScript.SyntaxFacts.isIdentifierNameOrAnyKeyword(token1)) { + return false; + } + } + + return this.isVariableStatement() || this.isLabeledStatement() || this.isFunctionDeclaration() || this.isIfStatement() || this.isBlock() || this.isExpressionStatement() || this.isReturnStatement() || this.isSwitchStatement() || this.isThrowStatement() || this.isBreakStatement() || this.isContinueStatement() || this.isForOrForInStatement() || this.isEmptyStatement(inErrorRecovery) || this.isWhileStatement() || this.isWithStatement() || this.isDoStatement() || this.isTryStatement() || this.isDebuggerStatement(); + }; + + ParserImpl.prototype.parseStatement = function () { + if (this.currentNode() !== null && this.currentNode().isStatement()) { + return this.eatNode(); + } + + if (this.isVariableStatement()) { + return this.parseVariableStatement(); + } else if (this.isLabeledStatement()) { + return this.parseLabeledStatement(); + } else if (this.isFunctionDeclaration()) { + return this.parseFunctionDeclaration(); + } else if (this.isIfStatement()) { + return this.parseIfStatement(); + } else if (this.isBlock()) { + return this.parseBlock(false, false); + } else if (this.isReturnStatement()) { + return this.parseReturnStatement(); + } else if (this.isSwitchStatement()) { + return this.parseSwitchStatement(); + } else if (this.isThrowStatement()) { + return this.parseThrowStatement(); + } else if (this.isBreakStatement()) { + return this.parseBreakStatement(); + } else if (this.isContinueStatement()) { + return this.parseContinueStatement(); + } else if (this.isForOrForInStatement()) { + return this.parseForOrForInStatement(); + } else if (this.isEmptyStatement(false)) { + return this.parseEmptyStatement(); + } else if (this.isWhileStatement()) { + return this.parseWhileStatement(); + } else if (this.isWithStatement()) { + return this.parseWithStatement(); + } else if (this.isDoStatement()) { + return this.parseDoStatement(); + } else if (this.isTryStatement()) { + return this.parseTryStatement(); + } else if (this.isDebuggerStatement()) { + return this.parseDebuggerStatement(); + } else { + return this.parseExpressionStatement(); + } + }; + + ParserImpl.prototype.isDebuggerStatement = function () { + return this.currentToken().tokenKind === 19 /* DebuggerKeyword */; + }; + + ParserImpl.prototype.parseDebuggerStatement = function () { + var debuggerKeyword = this.eatKeyword(19 /* DebuggerKeyword */); + var semicolonToken = this.eatExplicitOrAutomaticSemicolon(false); + + return this.factory.debuggerStatement(debuggerKeyword, semicolonToken); + }; + + ParserImpl.prototype.isDoStatement = function () { + return this.currentToken().tokenKind === 22 /* DoKeyword */; + }; + + ParserImpl.prototype.parseDoStatement = function () { + var doKeyword = this.eatKeyword(22 /* DoKeyword */); + var statement = this.parseStatement(); + var whileKeyword = this.eatKeyword(42 /* WhileKeyword */); + var openParenToken = this.eatToken(72 /* OpenParenToken */); + var condition = this.parseExpression(true); + var closeParenToken = this.eatToken(73 /* CloseParenToken */); + + var semicolonToken = this.eatExplicitOrAutomaticSemicolon(true); + + return this.factory.doStatement(doKeyword, statement, whileKeyword, openParenToken, condition, closeParenToken, semicolonToken); + }; + + ParserImpl.prototype.isLabeledStatement = function () { + return this.isIdentifier(this.currentToken()) && this.peekToken(1).tokenKind === 106 /* ColonToken */; + }; + + ParserImpl.prototype.parseLabeledStatement = function () { + var identifier = this.eatIdentifierToken(); + var colonToken = this.eatToken(106 /* ColonToken */); + var statement = this.parseStatement(); + + return this.factory.labeledStatement(identifier, colonToken, statement); + }; + + ParserImpl.prototype.isTryStatement = function () { + return this.currentToken().tokenKind === 38 /* TryKeyword */; + }; + + ParserImpl.prototype.parseTryStatement = function () { + var tryKeyword = this.eatKeyword(38 /* TryKeyword */); + + var savedListParsingState = this.listParsingState; + this.listParsingState |= 64 /* TryBlock_Statements */; + var block = this.parseBlock(false, false); + this.listParsingState = savedListParsingState; + + var catchClause = null; + if (this.isCatchClause()) { + catchClause = this.parseCatchClause(); + } + + var finallyClause = null; + if (catchClause === null || this.isFinallyClause()) { + finallyClause = this.parseFinallyClause(); + } + + return this.factory.tryStatement(tryKeyword, block, catchClause, finallyClause); + }; + + ParserImpl.prototype.isCatchClause = function () { + return this.currentToken().tokenKind === 17 /* CatchKeyword */; + }; + + ParserImpl.prototype.parseCatchClause = function () { + var catchKeyword = this.eatKeyword(17 /* CatchKeyword */); + var openParenToken = this.eatToken(72 /* OpenParenToken */); + var identifier = this.eatIdentifierToken(); + var typeAnnotation = this.parseOptionalTypeAnnotation(false); + var closeParenToken = this.eatToken(73 /* CloseParenToken */); + + var savedListParsingState = this.listParsingState; + this.listParsingState |= 128 /* CatchBlock_Statements */; + var block = this.parseBlock(false, false); + this.listParsingState = savedListParsingState; + + return this.factory.catchClause(catchKeyword, openParenToken, identifier, typeAnnotation, closeParenToken, block); + }; + + ParserImpl.prototype.isFinallyClause = function () { + return this.currentToken().tokenKind === 25 /* FinallyKeyword */; + }; + + ParserImpl.prototype.parseFinallyClause = function () { + var finallyKeyword = this.eatKeyword(25 /* FinallyKeyword */); + var block = this.parseBlock(false, false); + + return this.factory.finallyClause(finallyKeyword, block); + }; + + ParserImpl.prototype.isWithStatement = function () { + return this.currentToken().tokenKind === 43 /* WithKeyword */; + }; + + ParserImpl.prototype.parseWithStatement = function () { + var withKeyword = this.eatKeyword(43 /* WithKeyword */); + var openParenToken = this.eatToken(72 /* OpenParenToken */); + var condition = this.parseExpression(true); + var closeParenToken = this.eatToken(73 /* CloseParenToken */); + var statement = this.parseStatement(); + + return this.factory.withStatement(withKeyword, openParenToken, condition, closeParenToken, statement); + }; + + ParserImpl.prototype.isWhileStatement = function () { + return this.currentToken().tokenKind === 42 /* WhileKeyword */; + }; + + ParserImpl.prototype.parseWhileStatement = function () { + var whileKeyword = this.eatKeyword(42 /* WhileKeyword */); + var openParenToken = this.eatToken(72 /* OpenParenToken */); + var condition = this.parseExpression(true); + var closeParenToken = this.eatToken(73 /* CloseParenToken */); + var statement = this.parseStatement(); + + return this.factory.whileStatement(whileKeyword, openParenToken, condition, closeParenToken, statement); + }; + + ParserImpl.prototype.isEmptyStatement = function (inErrorRecovery) { + if (inErrorRecovery) { + return false; + } + + return this.currentToken().tokenKind === 78 /* SemicolonToken */; + }; + + ParserImpl.prototype.parseEmptyStatement = function () { + var semicolonToken = this.eatToken(78 /* SemicolonToken */); + return this.factory.emptyStatement(semicolonToken); + }; + + ParserImpl.prototype.isForOrForInStatement = function () { + return this.currentToken().tokenKind === 26 /* ForKeyword */; + }; + + ParserImpl.prototype.parseForOrForInStatement = function () { + var forKeyword = this.eatKeyword(26 /* ForKeyword */); + var openParenToken = this.eatToken(72 /* OpenParenToken */); + + var currentToken = this.currentToken(); + if (currentToken.tokenKind === 40 /* VarKeyword */) { + return this.parseForOrForInStatementWithVariableDeclaration(forKeyword, openParenToken); + } else if (currentToken.tokenKind === 78 /* SemicolonToken */) { + return this.parseForStatement(forKeyword, openParenToken); + } else { + return this.parseForOrForInStatementWithInitializer(forKeyword, openParenToken); + } + }; + + ParserImpl.prototype.parseForOrForInStatementWithVariableDeclaration = function (forKeyword, openParenToken) { + var variableDeclaration = this.parseVariableDeclaration(false); + + if (this.currentToken().tokenKind === 29 /* InKeyword */) { + return this.parseForInStatementWithVariableDeclarationOrInitializer(forKeyword, openParenToken, variableDeclaration, null); + } + + return this.parseForStatementWithVariableDeclarationOrInitializer(forKeyword, openParenToken, variableDeclaration, null); + }; + + ParserImpl.prototype.parseForInStatementWithVariableDeclarationOrInitializer = function (forKeyword, openParenToken, variableDeclaration, initializer) { + var inKeyword = this.eatKeyword(29 /* InKeyword */); + var expression = this.parseExpression(true); + var closeParenToken = this.eatToken(73 /* CloseParenToken */); + var statement = this.parseStatement(); + + return this.factory.forInStatement(forKeyword, openParenToken, variableDeclaration, initializer, inKeyword, expression, closeParenToken, statement); + }; + + ParserImpl.prototype.parseForOrForInStatementWithInitializer = function (forKeyword, openParenToken) { + var initializer = this.parseExpression(false); + if (this.currentToken().tokenKind === 29 /* InKeyword */) { + return this.parseForInStatementWithVariableDeclarationOrInitializer(forKeyword, openParenToken, null, initializer); + } else { + return this.parseForStatementWithVariableDeclarationOrInitializer(forKeyword, openParenToken, null, initializer); + } + }; + + ParserImpl.prototype.parseForStatement = function (forKeyword, openParenToken) { + var initializer = null; + + if (this.currentToken().tokenKind !== 78 /* SemicolonToken */ && this.currentToken().tokenKind !== 73 /* CloseParenToken */ && this.currentToken().tokenKind !== 10 /* EndOfFileToken */) { + initializer = this.parseExpression(false); + } + + return this.parseForStatementWithVariableDeclarationOrInitializer(forKeyword, openParenToken, null, initializer); + }; + + ParserImpl.prototype.parseForStatementWithVariableDeclarationOrInitializer = function (forKeyword, openParenToken, variableDeclaration, initializer) { + var firstSemicolonToken = this.eatToken(78 /* SemicolonToken */); + + var condition = null; + if (this.currentToken().tokenKind !== 78 /* SemicolonToken */ && this.currentToken().tokenKind !== 73 /* CloseParenToken */ && this.currentToken().tokenKind !== 10 /* EndOfFileToken */) { + condition = this.parseExpression(true); + } + + var secondSemicolonToken = this.eatToken(78 /* SemicolonToken */); + + var incrementor = null; + if (this.currentToken().tokenKind !== 73 /* CloseParenToken */ && this.currentToken().tokenKind !== 10 /* EndOfFileToken */) { + incrementor = this.parseExpression(true); + } + + var closeParenToken = this.eatToken(73 /* CloseParenToken */); + var statement = this.parseStatement(); + + return this.factory.forStatement(forKeyword, openParenToken, variableDeclaration, initializer, firstSemicolonToken, condition, secondSemicolonToken, incrementor, closeParenToken, statement); + }; + + ParserImpl.prototype.isBreakStatement = function () { + return this.currentToken().tokenKind === 15 /* BreakKeyword */; + }; + + ParserImpl.prototype.parseBreakStatement = function () { + var breakKeyword = this.eatKeyword(15 /* BreakKeyword */); + + var identifier = null; + if (!this.canEatExplicitOrAutomaticSemicolon(false)) { + if (this.isIdentifier(this.currentToken())) { + identifier = this.eatIdentifierToken(); + } + } + + var semicolon = this.eatExplicitOrAutomaticSemicolon(false); + return this.factory.breakStatement(breakKeyword, identifier, semicolon); + }; + + ParserImpl.prototype.isContinueStatement = function () { + return this.currentToken().tokenKind === 18 /* ContinueKeyword */; + }; + + ParserImpl.prototype.parseContinueStatement = function () { + var continueKeyword = this.eatKeyword(18 /* ContinueKeyword */); + + var identifier = null; + if (!this.canEatExplicitOrAutomaticSemicolon(false)) { + if (this.isIdentifier(this.currentToken())) { + identifier = this.eatIdentifierToken(); + } + } + + var semicolon = this.eatExplicitOrAutomaticSemicolon(false); + return this.factory.continueStatement(continueKeyword, identifier, semicolon); + }; + + ParserImpl.prototype.isSwitchStatement = function () { + return this.currentToken().tokenKind === 34 /* SwitchKeyword */; + }; + + ParserImpl.prototype.parseSwitchStatement = function () { + var switchKeyword = this.eatKeyword(34 /* SwitchKeyword */); + var openParenToken = this.eatToken(72 /* OpenParenToken */); + var expression = this.parseExpression(true); + var closeParenToken = this.eatToken(73 /* CloseParenToken */); + + var openBraceToken = this.eatToken(70 /* OpenBraceToken */); + + var switchClauses = TypeScript.Syntax.emptyList; + if (openBraceToken.width() > 0) { + var result = this.parseSyntaxList(8 /* SwitchStatement_SwitchClauses */); + switchClauses = result.list; + openBraceToken = this.addSkippedTokensAfterToken(openBraceToken, result.skippedTokens); + } + + var closeBraceToken = this.eatToken(71 /* CloseBraceToken */); + return this.factory.switchStatement(switchKeyword, openParenToken, expression, closeParenToken, openBraceToken, switchClauses, closeBraceToken); + }; + + ParserImpl.prototype.isCaseSwitchClause = function () { + return this.currentToken().tokenKind === 16 /* CaseKeyword */; + }; + + ParserImpl.prototype.isDefaultSwitchClause = function () { + return this.currentToken().tokenKind === 20 /* DefaultKeyword */; + }; + + ParserImpl.prototype.isSwitchClause = function () { + if (this.currentNode() !== null && this.currentNode().isSwitchClause()) { + return true; + } + + return this.isCaseSwitchClause() || this.isDefaultSwitchClause(); + }; + + ParserImpl.prototype.parseSwitchClause = function () { + if (this.currentNode() !== null && this.currentNode().isSwitchClause()) { + return this.eatNode(); + } + + if (this.isCaseSwitchClause()) { + return this.parseCaseSwitchClause(); + } else if (this.isDefaultSwitchClause()) { + return this.parseDefaultSwitchClause(); + } else { + throw TypeScript.Errors.invalidOperation(); + } + }; + + ParserImpl.prototype.parseCaseSwitchClause = function () { + var caseKeyword = this.eatKeyword(16 /* CaseKeyword */); + var expression = this.parseExpression(true); + var colonToken = this.eatToken(106 /* ColonToken */); + var statements = TypeScript.Syntax.emptyList; + + if (colonToken.fullWidth() > 0) { + var result = this.parseSyntaxList(16 /* SwitchClause_Statements */); + statements = result.list; + colonToken = this.addSkippedTokensAfterToken(colonToken, result.skippedTokens); + } + + return this.factory.caseSwitchClause(caseKeyword, expression, colonToken, statements); + }; + + ParserImpl.prototype.parseDefaultSwitchClause = function () { + var defaultKeyword = this.eatKeyword(20 /* DefaultKeyword */); + var colonToken = this.eatToken(106 /* ColonToken */); + var statements = TypeScript.Syntax.emptyList; + + if (colonToken.fullWidth() > 0) { + var result = this.parseSyntaxList(16 /* SwitchClause_Statements */); + statements = result.list; + colonToken = this.addSkippedTokensAfterToken(colonToken, result.skippedTokens); + } + + return this.factory.defaultSwitchClause(defaultKeyword, colonToken, statements); + }; + + ParserImpl.prototype.isThrowStatement = function () { + return this.currentToken().tokenKind === 36 /* ThrowKeyword */; + }; + + ParserImpl.prototype.parseThrowStatement = function () { + var throwKeyword = this.eatKeyword(36 /* ThrowKeyword */); + + var expression = null; + if (this.canEatExplicitOrAutomaticSemicolon(false)) { + var token = this.createMissingToken(11 /* IdentifierName */, null); + expression = token; + } else { + expression = this.parseExpression(true); + } + + var semicolonToken = this.eatExplicitOrAutomaticSemicolon(false); + + return this.factory.throwStatement(throwKeyword, expression, semicolonToken); + }; + + ParserImpl.prototype.isReturnStatement = function () { + return this.currentToken().tokenKind === 33 /* ReturnKeyword */; + }; + + ParserImpl.prototype.parseReturnStatement = function () { + var returnKeyword = this.eatKeyword(33 /* ReturnKeyword */); + + var expression = null; + if (!this.canEatExplicitOrAutomaticSemicolon(false)) { + expression = this.parseExpression(true); + } + + var semicolonToken = this.eatExplicitOrAutomaticSemicolon(false); + + return this.factory.returnStatement(returnKeyword, expression, semicolonToken); + }; + + ParserImpl.prototype.isExpressionStatement = function () { + var currentToken = this.currentToken(); + + var kind = currentToken.tokenKind; + if (kind === 70 /* OpenBraceToken */ || kind === 27 /* FunctionKeyword */) { + return false; + } + + return this.isExpression(); + }; + + ParserImpl.prototype.isAssignmentOrOmittedExpression = function () { + if (this.currentToken().tokenKind === 79 /* CommaToken */) { + return true; + } + + return this.isExpression(); + }; + + ParserImpl.prototype.parseAssignmentOrOmittedExpression = function () { + if (this.currentToken().tokenKind === 79 /* CommaToken */) { + return this.factory.omittedExpression(); + } + + return this.parseAssignmentExpression(true); + }; + + ParserImpl.prototype.isExpression = function () { + var currentToken = this.currentToken(); + var kind = currentToken.tokenKind; + + switch (kind) { + case 13 /* NumericLiteral */: + case 14 /* StringLiteral */: + case 12 /* RegularExpressionLiteral */: + return true; + + case 74 /* OpenBracketToken */: + case 72 /* OpenParenToken */: + return true; + + case 80 /* LessThanToken */: + return true; + + case 93 /* PlusPlusToken */: + case 94 /* MinusMinusToken */: + case 89 /* PlusToken */: + case 90 /* MinusToken */: + case 102 /* TildeToken */: + case 101 /* ExclamationToken */: + return true; + + case 70 /* OpenBraceToken */: + return true; + + case 85 /* EqualsGreaterThanToken */: + return true; + + case 118 /* SlashToken */: + case 119 /* SlashEqualsToken */: + return true; + + case 50 /* SuperKeyword */: + case 35 /* ThisKeyword */: + case 37 /* TrueKeyword */: + case 24 /* FalseKeyword */: + case 32 /* NullKeyword */: + return true; + + case 31 /* NewKeyword */: + return true; + + case 21 /* DeleteKeyword */: + case 41 /* VoidKeyword */: + case 39 /* TypeOfKeyword */: + return true; + + case 27 /* FunctionKeyword */: + return true; + } + + if (this.isIdentifier(this.currentToken())) { + return true; + } + + return false; + }; + + ParserImpl.prototype.parseExpressionStatement = function () { + var expression = this.parseExpression(true); + + var semicolon = this.eatExplicitOrAutomaticSemicolon(false); + + return this.factory.expressionStatement(expression, semicolon); + }; + + ParserImpl.prototype.isIfStatement = function () { + return this.currentToken().tokenKind === 28 /* IfKeyword */; + }; + + ParserImpl.prototype.parseIfStatement = function () { + var ifKeyword = this.eatKeyword(28 /* IfKeyword */); + var openParenToken = this.eatToken(72 /* OpenParenToken */); + var condition = this.parseExpression(true); + var closeParenToken = this.eatToken(73 /* CloseParenToken */); + var statement = this.parseStatement(); + + var elseClause = null; + if (this.isElseClause()) { + elseClause = this.parseElseClause(); + } + + return this.factory.ifStatement(ifKeyword, openParenToken, condition, closeParenToken, statement, elseClause); + }; + + ParserImpl.prototype.isElseClause = function () { + return this.currentToken().tokenKind === 23 /* ElseKeyword */; + }; + + ParserImpl.prototype.parseElseClause = function () { + var elseKeyword = this.eatKeyword(23 /* ElseKeyword */); + var statement = this.parseStatement(); + + return this.factory.elseClause(elseKeyword, statement); + }; + + ParserImpl.prototype.isVariableStatement = function () { + var index = this.modifierCount(); + return this.peekToken(index).tokenKind === 40 /* VarKeyword */; + }; + + ParserImpl.prototype.parseVariableStatement = function () { + var modifiers = this.parseModifiers(); + var variableDeclaration = this.parseVariableDeclaration(true); + var semicolonToken = this.eatExplicitOrAutomaticSemicolon(false); + + return this.factory.variableStatement(modifiers, variableDeclaration, semicolonToken); + }; + + ParserImpl.prototype.parseVariableDeclaration = function (allowIn) { + var varKeyword = this.eatKeyword(40 /* VarKeyword */); + + var listParsingState = allowIn ? 4096 /* VariableDeclaration_VariableDeclarators_AllowIn */ : 8192 /* VariableDeclaration_VariableDeclarators_DisallowIn */; + + var result = this.parseSeparatedSyntaxList(listParsingState); + var variableDeclarators = result.list; + varKeyword = this.addSkippedTokensAfterToken(varKeyword, result.skippedTokens); + + return this.factory.variableDeclaration(varKeyword, variableDeclarators); + }; + + ParserImpl.prototype.isVariableDeclarator = function () { + if (this.currentNode() !== null && this.currentNode().kind() === 224 /* VariableDeclarator */) { + return true; + } + + return this.isIdentifier(this.currentToken()); + }; + + ParserImpl.prototype.canReuseVariableDeclaratorNode = function (node) { + if (node === null || node.kind() !== 224 /* VariableDeclarator */) { + return false; + } + + var variableDeclarator = node; + return variableDeclarator.equalsValueClause === null; + }; + + ParserImpl.prototype.parseVariableDeclarator = function (allowIn, allowPropertyName) { + if (this.canReuseVariableDeclaratorNode(this.currentNode())) { + return this.eatNode(); + } + + var propertyName = allowPropertyName ? this.eatPropertyName() : this.eatIdentifierToken(); + var equalsValueClause = null; + var typeAnnotation = null; + + if (propertyName.width() > 0) { + typeAnnotation = this.parseOptionalTypeAnnotation(false); + + if (this.isEqualsValueClause(false)) { + equalsValueClause = this.parseEqualsValueClause(allowIn); + } + } + + return this.factory.variableDeclarator(propertyName, typeAnnotation, equalsValueClause); + }; + + ParserImpl.prototype.isColonValueClause = function () { + return this.currentToken().tokenKind === 106 /* ColonToken */; + }; + + ParserImpl.prototype.isEqualsValueClause = function (inParameter) { + var token0 = this.currentToken(); + if (token0.tokenKind === 107 /* EqualsToken */) { + return true; + } + + if (!this.previousToken().hasTrailingNewLine()) { + if (token0.tokenKind === 85 /* EqualsGreaterThanToken */) { + return false; + } + + if (token0.tokenKind === 70 /* OpenBraceToken */ && inParameter) { + return false; + } + + return this.isExpression(); + } + + return false; + }; + + ParserImpl.prototype.parseEqualsValueClause = function (allowIn) { + var equalsToken = this.eatToken(107 /* EqualsToken */); + var value = this.parseAssignmentExpression(allowIn); + + return this.factory.equalsValueClause(equalsToken, value); + }; + + ParserImpl.prototype.parseExpression = function (allowIn) { + return this.parseSubExpression(0, allowIn); + }; + + ParserImpl.prototype.parseAssignmentExpression = function (allowIn) { + return this.parseSubExpression(2 /* AssignmentExpressionPrecedence */, allowIn); + }; + + ParserImpl.prototype.parseUnaryExpression = function () { + var currentTokenKind = this.currentToken().tokenKind; + if (TypeScript.SyntaxFacts.isPrefixUnaryExpressionOperatorToken(currentTokenKind)) { + var operatorKind = TypeScript.SyntaxFacts.getPrefixUnaryExpressionFromOperatorToken(currentTokenKind); + + var operatorToken = this.eatAnyToken(); + + var operand = this.parseUnaryExpression(); + return this.factory.prefixUnaryExpression(operatorKind, operatorToken, operand); + } else { + return this.parseTerm(false); + } + }; + + ParserImpl.prototype.parseSubExpression = function (precedence, allowIn) { + var leftOperand = this.parseUnaryExpression(); + leftOperand = this.parseBinaryOrConditionalExpressions(precedence, allowIn, leftOperand); + + return leftOperand; + }; + + ParserImpl.prototype.parseBinaryOrConditionalExpressions = function (precedence, allowIn, leftOperand) { + while (true) { + var token0 = this.currentToken(); + var token0Kind = token0.tokenKind; + + if (TypeScript.SyntaxFacts.isBinaryExpressionOperatorToken(token0Kind)) { + if (token0Kind === 29 /* InKeyword */ && !allowIn) { + break; + } + + var mergedToken = this.tryMergeBinaryExpressionTokens(); + var tokenKind = mergedToken === null ? token0Kind : mergedToken.syntaxKind; + + var binaryExpressionKind = TypeScript.SyntaxFacts.getBinaryExpressionFromOperatorToken(tokenKind); + var newPrecedence = ParserImpl.getPrecedence(binaryExpressionKind); + + if (newPrecedence < precedence) { + break; + } + + if (newPrecedence === precedence && !this.isRightAssociative(binaryExpressionKind)) { + break; + } + + var operatorToken = mergedToken === null ? token0 : TypeScript.Syntax.token(mergedToken.syntaxKind).withLeadingTrivia(token0.leadingTrivia()).withTrailingTrivia(this.peekToken(mergedToken.tokenCount - 1).trailingTrivia()); + + var skipCount = mergedToken === null ? 1 : mergedToken.tokenCount; + for (var i = 0; i < skipCount; i++) { + this.eatAnyToken(); + } + + leftOperand = this.factory.binaryExpression(binaryExpressionKind, leftOperand, operatorToken, this.parseSubExpression(newPrecedence, allowIn)); + continue; + } + + if (token0Kind === 105 /* QuestionToken */ && precedence <= 3 /* ConditionalExpressionPrecedence */) { + var questionToken = this.eatToken(105 /* QuestionToken */); + + var whenTrueExpression = this.parseAssignmentExpression(allowIn); + var colon = this.eatToken(106 /* ColonToken */); + + var whenFalseExpression = this.parseAssignmentExpression(allowIn); + leftOperand = this.factory.conditionalExpression(leftOperand, questionToken, whenTrueExpression, colon, whenFalseExpression); + continue; + } + + break; + } + + return leftOperand; + }; + + ParserImpl.prototype.tryMergeBinaryExpressionTokens = function () { + var token0 = this.currentToken(); + + if (token0.tokenKind === 81 /* GreaterThanToken */ && !token0.hasTrailingTrivia()) { + var storage = this.mergeTokensStorage; + storage[0] = 0 /* None */; + storage[1] = 0 /* None */; + storage[2] = 0 /* None */; + + for (var i = 0; i < storage.length; i++) { + var nextToken = this.peekToken(i + 1); + + if (!nextToken.hasLeadingTrivia()) { + storage[i] = nextToken.tokenKind; + } + + if (nextToken.hasTrailingTrivia()) { + break; + } + } + + if (storage[0] === 81 /* GreaterThanToken */) { + if (storage[1] === 81 /* GreaterThanToken */) { + if (storage[2] === 107 /* EqualsToken */) { + return { tokenCount: 4, syntaxKind: 114 /* GreaterThanGreaterThanGreaterThanEqualsToken */ }; + } else { + return { tokenCount: 3, syntaxKind: 97 /* GreaterThanGreaterThanGreaterThanToken */ }; + } + } else if (storage[1] === 107 /* EqualsToken */) { + return { tokenCount: 3, syntaxKind: 113 /* GreaterThanGreaterThanEqualsToken */ }; + } else { + return { tokenCount: 2, syntaxKind: 96 /* GreaterThanGreaterThanToken */ }; + } + } else if (storage[0] === 107 /* EqualsToken */) { + return { tokenCount: 2, syntaxKind: 83 /* GreaterThanEqualsToken */ }; + } + } + + return null; + }; + + ParserImpl.prototype.isRightAssociative = function (expressionKind) { + switch (expressionKind) { + case 173 /* AssignmentExpression */: + case 174 /* AddAssignmentExpression */: + case 175 /* SubtractAssignmentExpression */: + case 176 /* MultiplyAssignmentExpression */: + case 177 /* DivideAssignmentExpression */: + case 178 /* ModuloAssignmentExpression */: + case 179 /* AndAssignmentExpression */: + case 180 /* ExclusiveOrAssignmentExpression */: + case 181 /* OrAssignmentExpression */: + case 182 /* LeftShiftAssignmentExpression */: + case 183 /* SignedRightShiftAssignmentExpression */: + case 184 /* UnsignedRightShiftAssignmentExpression */: + return true; + default: + return false; + } + }; + + ParserImpl.prototype.parseTerm = function (inObjectCreation) { + var term = this.parseTermWorker(); + if (term === null) { + return this.eatIdentifierToken(); + } + + return this.parsePostFixExpression(term, inObjectCreation); + }; + + ParserImpl.prototype.parsePostFixExpression = function (expression, inObjectCreation) { + while (true) { + var currentTokenKind = this.currentToken().tokenKind; + switch (currentTokenKind) { + case 72 /* OpenParenToken */: + if (inObjectCreation) { + return expression; + } + + expression = this.factory.invocationExpression(expression, this.parseArgumentList(null)); + continue; + + case 80 /* LessThanToken */: + if (inObjectCreation) { + return expression; + } + + var argumentList = this.tryParseArgumentList(); + if (argumentList !== null) { + expression = this.factory.invocationExpression(expression, argumentList); + continue; + } + + break; + + case 74 /* OpenBracketToken */: + expression = this.parseElementAccessExpression(expression, inObjectCreation); + continue; + + case 93 /* PlusPlusToken */: + case 94 /* MinusMinusToken */: + if (this.previousToken() !== null && this.previousToken().hasTrailingNewLine()) { + break; + } + + expression = this.factory.postfixUnaryExpression(TypeScript.SyntaxFacts.getPostfixUnaryExpressionFromOperatorToken(currentTokenKind), expression, this.eatAnyToken()); + continue; + + case 76 /* DotToken */: + expression = this.factory.memberAccessExpression(expression, this.eatToken(76 /* DotToken */), this.eatIdentifierNameToken()); + continue; + } + + return expression; + } + }; + + ParserImpl.prototype.tryParseArgumentList = function () { + var typeArgumentList = null; + + if (this.currentToken().tokenKind === 80 /* LessThanToken */) { + var rewindPoint = this.getRewindPoint(); + try { + typeArgumentList = this.tryParseTypeArgumentList(true); + var token0 = this.currentToken(); + + var isOpenParen = token0.tokenKind === 72 /* OpenParenToken */; + var isDot = token0.tokenKind === 76 /* DotToken */; + var isOpenParenOrDot = isOpenParen || isDot; + if (typeArgumentList === null || !isOpenParenOrDot) { + this.rewind(rewindPoint); + return null; + } + + if (isDot) { + var diagnostic = new TypeScript.Diagnostic(this.fileName, this.currentTokenStart(), token0.width(), TypeScript.DiagnosticCode.A_parameter_list_must_follow_a_generic_type_argument_list_expected, null); + this.addDiagnostic(diagnostic); + + return this.factory.argumentList(typeArgumentList, TypeScript.Syntax.emptyToken(72 /* OpenParenToken */), TypeScript.Syntax.emptySeparatedList, TypeScript.Syntax.emptyToken(73 /* CloseParenToken */)); + } + } finally { + this.releaseRewindPoint(rewindPoint); + } + } + + if (this.currentToken().tokenKind === 72 /* OpenParenToken */) { + return this.parseArgumentList(typeArgumentList); + } + + return null; + }; + + ParserImpl.prototype.parseArgumentList = function (typeArgumentList) { + var openParenToken = this.eatToken(72 /* OpenParenToken */); + var arguments = TypeScript.Syntax.emptySeparatedList; + + if (openParenToken.fullWidth() > 0) { + var result = this.parseSeparatedSyntaxList(16384 /* ArgumentList_AssignmentExpressions */); + arguments = result.list; + openParenToken = this.addSkippedTokensAfterToken(openParenToken, result.skippedTokens); + } + + var closeParenToken = this.eatToken(73 /* CloseParenToken */); + + return this.factory.argumentList(typeArgumentList, openParenToken, arguments, closeParenToken); + }; + + ParserImpl.prototype.parseElementAccessExpression = function (expression, inObjectCreation) { + var start = this.currentTokenStart(); + var openBracketToken = this.eatToken(74 /* OpenBracketToken */); + var argumentExpression; + + if (this.currentToken().tokenKind === 75 /* CloseBracketToken */ && inObjectCreation) { + var end = this.currentTokenStart() + this.currentToken().width(); + var diagnostic = new TypeScript.Diagnostic(this.fileName, start, end - start, TypeScript.DiagnosticCode.new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead, null); + this.addDiagnostic(diagnostic); + + argumentExpression = TypeScript.Syntax.emptyToken(11 /* IdentifierName */); + } else { + argumentExpression = this.parseExpression(true); + } + + var closeBracketToken = this.eatToken(75 /* CloseBracketToken */); + + return this.factory.elementAccessExpression(expression, openBracketToken, argumentExpression, closeBracketToken); + }; + + ParserImpl.prototype.parseTermWorker = function () { + var currentToken = this.currentToken(); + + if (currentToken.tokenKind === 85 /* EqualsGreaterThanToken */) { + return this.parseSimpleArrowFunctionExpression(); + } + + if (this.isIdentifier(currentToken)) { + if (this.isSimpleArrowFunctionExpression()) { + return this.parseSimpleArrowFunctionExpression(); + } else { + var identifier = this.eatIdentifierToken(); + return identifier; + } + } + + var currentTokenKind = currentToken.tokenKind; + switch (currentTokenKind) { + case 35 /* ThisKeyword */: + return this.parseThisExpression(); + + case 37 /* TrueKeyword */: + case 24 /* FalseKeyword */: + return this.parseLiteralExpression(); + + case 32 /* NullKeyword */: + return this.parseLiteralExpression(); + + case 31 /* NewKeyword */: + return this.parseObjectCreationExpression(); + + case 27 /* FunctionKeyword */: + return this.parseFunctionExpression(); + + case 50 /* SuperKeyword */: + return this.parseSuperExpression(); + + case 39 /* TypeOfKeyword */: + return this.parseTypeOfExpression(); + + case 21 /* DeleteKeyword */: + return this.parseDeleteExpression(); + + case 41 /* VoidKeyword */: + return this.parseVoidExpression(); + + case 13 /* NumericLiteral */: + return this.parseLiteralExpression(); + + case 12 /* RegularExpressionLiteral */: + return this.parseLiteralExpression(); + + case 14 /* StringLiteral */: + return this.parseLiteralExpression(); + + case 74 /* OpenBracketToken */: + return this.parseArrayLiteralExpression(); + + case 70 /* OpenBraceToken */: + return this.parseObjectLiteralExpression(); + + case 72 /* OpenParenToken */: + return this.parseParenthesizedOrArrowFunctionExpression(); + + case 80 /* LessThanToken */: + return this.parseCastOrArrowFunctionExpression(); + + case 118 /* SlashToken */: + case 119 /* SlashEqualsToken */: + var result = this.tryReparseDivideAsRegularExpression(); + if (result !== null) { + return result; + } + break; + } + + return null; + }; + + ParserImpl.prototype.tryReparseDivideAsRegularExpression = function () { + var currentToken = this.currentToken(); + + if (this.previousToken() !== null) { + var previousTokenKind = this.previousToken().tokenKind; + switch (previousTokenKind) { + case 11 /* IdentifierName */: + return null; + + case 35 /* ThisKeyword */: + case 37 /* TrueKeyword */: + case 24 /* FalseKeyword */: + return null; + + case 14 /* StringLiteral */: + case 13 /* NumericLiteral */: + case 12 /* RegularExpressionLiteral */: + case 93 /* PlusPlusToken */: + case 94 /* MinusMinusToken */: + case 75 /* CloseBracketToken */: + case 71 /* CloseBraceToken */: + return null; + } + } + + currentToken = this.currentTokenAllowingRegularExpression(); + + if (currentToken.tokenKind === 118 /* SlashToken */ || currentToken.tokenKind === 119 /* SlashEqualsToken */) { + return null; + } else if (currentToken.tokenKind === 12 /* RegularExpressionLiteral */) { + return this.parseLiteralExpression(); + } else { + throw TypeScript.Errors.invalidOperation(); + } + }; + + ParserImpl.prototype.parseTypeOfExpression = function () { + var typeOfKeyword = this.eatKeyword(39 /* TypeOfKeyword */); + var expression = this.parseUnaryExpression(); + + return this.factory.typeOfExpression(typeOfKeyword, expression); + }; + + ParserImpl.prototype.parseDeleteExpression = function () { + var deleteKeyword = this.eatKeyword(21 /* DeleteKeyword */); + var expression = this.parseUnaryExpression(); + + return this.factory.deleteExpression(deleteKeyword, expression); + }; + + ParserImpl.prototype.parseVoidExpression = function () { + var voidKeyword = this.eatKeyword(41 /* VoidKeyword */); + var expression = this.parseUnaryExpression(); + + return this.factory.voidExpression(voidKeyword, expression); + }; + + ParserImpl.prototype.parseSuperExpression = function () { + var superKeyword = this.eatKeyword(50 /* SuperKeyword */); + return superKeyword; + }; + + ParserImpl.prototype.parseFunctionExpression = function () { + var functionKeyword = this.eatKeyword(27 /* FunctionKeyword */); + var identifier = null; + + if (this.isIdentifier(this.currentToken())) { + identifier = this.eatIdentifierToken(); + } + + var callSignature = this.parseCallSignature(false); + var block = this.parseBlock(false, true); + + return this.factory.functionExpression(functionKeyword, identifier, callSignature, block); + }; + + ParserImpl.prototype.parseObjectCreationExpression = function () { + var newKeyword = this.eatKeyword(31 /* NewKeyword */); + + var expression = this.parseTerm(true); + var argumentList = this.tryParseArgumentList(); + + return this.factory.objectCreationExpression(newKeyword, expression, argumentList); + }; + + ParserImpl.prototype.parseCastOrArrowFunctionExpression = function () { + var rewindPoint = this.getRewindPoint(); + try { + var arrowFunction = this.tryParseArrowFunctionExpression(); + if (arrowFunction !== null) { + return arrowFunction; + } + + this.rewind(rewindPoint); + return this.parseCastExpression(); + } finally { + this.releaseRewindPoint(rewindPoint); + } + }; + + ParserImpl.prototype.parseCastExpression = function () { + var lessThanToken = this.eatToken(80 /* LessThanToken */); + var type = this.parseType(); + var greaterThanToken = this.eatToken(81 /* GreaterThanToken */); + var expression = this.parseUnaryExpression(); + + return this.factory.castExpression(lessThanToken, type, greaterThanToken, expression); + }; + + ParserImpl.prototype.parseParenthesizedOrArrowFunctionExpression = function () { + var result = this.tryParseArrowFunctionExpression(); + if (result !== null) { + return result; + } + + var openParenToken = this.eatToken(72 /* OpenParenToken */); + var expression = this.parseExpression(true); + var closeParenToken = this.eatToken(73 /* CloseParenToken */); + + return this.factory.parenthesizedExpression(openParenToken, expression, closeParenToken); + }; + + ParserImpl.prototype.tryParseArrowFunctionExpression = function () { + var tokenKind = this.currentToken().tokenKind; + + if (this.isDefinitelyArrowFunctionExpression()) { + return this.parseParenthesizedArrowFunctionExpression(false); + } + + if (!this.isPossiblyArrowFunctionExpression()) { + return null; + } + + var rewindPoint = this.getRewindPoint(); + try { + var arrowFunction = this.parseParenthesizedArrowFunctionExpression(true); + if (arrowFunction === null) { + this.rewind(rewindPoint); + } + return arrowFunction; + } finally { + this.releaseRewindPoint(rewindPoint); + } + }; + + ParserImpl.prototype.parseParenthesizedArrowFunctionExpression = function (requireArrow) { + var currentToken = this.currentToken(); + + var callSignature = this.parseCallSignature(true); + + if (requireArrow && this.currentToken().tokenKind !== 85 /* EqualsGreaterThanToken */) { + return null; + } + + var equalsGreaterThanToken = this.eatToken(85 /* EqualsGreaterThanToken */); + var body = this.parseArrowFunctionBody(); + + return this.factory.parenthesizedArrowFunctionExpression(callSignature, equalsGreaterThanToken, body); + }; + + ParserImpl.prototype.parseArrowFunctionBody = function () { + if (this.isBlock()) { + return this.parseBlock(false, false); + } else { + return this.parseAssignmentExpression(true); + } + }; + + ParserImpl.prototype.isSimpleArrowFunctionExpression = function () { + if (this.currentToken().tokenKind === 85 /* EqualsGreaterThanToken */) { + return true; + } + + return this.isIdentifier(this.currentToken()) && this.peekToken(1).tokenKind === 85 /* EqualsGreaterThanToken */; + }; + + ParserImpl.prototype.parseSimpleArrowFunctionExpression = function () { + var identifier = this.eatIdentifierToken(); + var equalsGreaterThanToken = this.eatToken(85 /* EqualsGreaterThanToken */); + var body = this.parseArrowFunctionBody(); + + return this.factory.simpleArrowFunctionExpression(identifier, equalsGreaterThanToken, body); + }; + + ParserImpl.prototype.isBlock = function () { + return this.currentToken().tokenKind === 70 /* OpenBraceToken */; + }; + + ParserImpl.prototype.isDefinitelyArrowFunctionExpression = function () { + var token0 = this.currentToken(); + if (token0.tokenKind !== 72 /* OpenParenToken */) { + return false; + } + + var token1 = this.peekToken(1); + var token2; + + if (token1.tokenKind === 73 /* CloseParenToken */) { + token2 = this.peekToken(2); + return token2.tokenKind === 106 /* ColonToken */ || token2.tokenKind === 85 /* EqualsGreaterThanToken */ || token2.tokenKind === 70 /* OpenBraceToken */; + } + + if (token1.tokenKind === 77 /* DotDotDotToken */) { + return true; + } + + if (!this.isIdentifier(token1)) { + return false; + } + + token2 = this.peekToken(2); + if (token2.tokenKind === 106 /* ColonToken */) { + return true; + } + + var token3 = this.peekToken(3); + if (token2.tokenKind === 105 /* QuestionToken */) { + if (token3.tokenKind === 106 /* ColonToken */ || token3.tokenKind === 73 /* CloseParenToken */ || token3.tokenKind === 79 /* CommaToken */) { + return true; + } + } + + if (token2.tokenKind === 73 /* CloseParenToken */) { + if (token3.tokenKind === 85 /* EqualsGreaterThanToken */) { + return true; + } + } + + return false; + }; + + ParserImpl.prototype.isPossiblyArrowFunctionExpression = function () { + var token0 = this.currentToken(); + if (token0.tokenKind !== 72 /* OpenParenToken */) { + return true; + } + + var token1 = this.peekToken(1); + + if (!this.isIdentifier(token1)) { + return false; + } + + var token2 = this.peekToken(2); + if (token2.tokenKind === 107 /* EqualsToken */) { + return true; + } + + if (token2.tokenKind === 79 /* CommaToken */) { + return true; + } + + if (token2.tokenKind === 73 /* CloseParenToken */) { + var token3 = this.peekToken(3); + if (token3.tokenKind === 106 /* ColonToken */) { + return true; + } + } + + return false; + }; + + ParserImpl.prototype.parseObjectLiteralExpression = function () { + var openBraceToken = this.eatToken(70 /* OpenBraceToken */); + + var result = this.parseSeparatedSyntaxList(32768 /* ObjectLiteralExpression_PropertyAssignments */); + var propertyAssignments = result.list; + openBraceToken = this.addSkippedTokensAfterToken(openBraceToken, result.skippedTokens); + + var closeBraceToken = this.eatToken(71 /* CloseBraceToken */); + + return this.factory.objectLiteralExpression(openBraceToken, propertyAssignments, closeBraceToken); + }; + + ParserImpl.prototype.parsePropertyAssignment = function () { + if (this.isGetAccessorPropertyAssignment(false)) { + return this.parseGetAccessorPropertyAssignment(); + } else if (this.isSetAccessorPropertyAssignment(false)) { + return this.parseSetAccessorPropertyAssignment(); + } else if (this.isFunctionPropertyAssignment(false)) { + return this.parseFunctionPropertyAssignment(); + } else if (this.isSimplePropertyAssignment(false)) { + return this.parseSimplePropertyAssignment(); + } else { + throw TypeScript.Errors.invalidOperation(); + } + }; + + ParserImpl.prototype.isPropertyAssignment = function (inErrorRecovery) { + return this.isGetAccessorPropertyAssignment(inErrorRecovery) || this.isSetAccessorPropertyAssignment(inErrorRecovery) || this.isFunctionPropertyAssignment(inErrorRecovery) || this.isSimplePropertyAssignment(inErrorRecovery); + }; + + ParserImpl.prototype.isGetAccessorPropertyAssignment = function (inErrorRecovery) { + return this.currentToken().tokenKind === 64 /* GetKeyword */ && this.isPropertyName(this.peekToken(1), inErrorRecovery); + }; + + ParserImpl.prototype.parseGetAccessorPropertyAssignment = function () { + var getKeyword = this.eatKeyword(64 /* GetKeyword */); + var propertyName = this.eatPropertyName(); + var openParenToken = this.eatToken(72 /* OpenParenToken */); + var closeParenToken = this.eatToken(73 /* CloseParenToken */); + var typeAnnotation = this.parseOptionalTypeAnnotation(false); + var block = this.parseBlock(false, true); + + return this.factory.getAccessorPropertyAssignment(getKeyword, propertyName, openParenToken, closeParenToken, typeAnnotation, block); + }; + + ParserImpl.prototype.isSetAccessorPropertyAssignment = function (inErrorRecovery) { + return this.currentToken().tokenKind === 68 /* SetKeyword */ && this.isPropertyName(this.peekToken(1), inErrorRecovery); + }; + + ParserImpl.prototype.parseSetAccessorPropertyAssignment = function () { + var setKeyword = this.eatKeyword(68 /* SetKeyword */); + var propertyName = this.eatPropertyName(); + var openParenToken = this.eatToken(72 /* OpenParenToken */); + var parameter = this.parseParameter(); + var closeParenToken = this.eatToken(73 /* CloseParenToken */); + var block = this.parseBlock(false, true); + + return this.factory.setAccessorPropertyAssignment(setKeyword, propertyName, openParenToken, parameter, closeParenToken, block); + }; + + ParserImpl.prototype.eatPropertyName = function () { + return TypeScript.SyntaxFacts.isIdentifierNameOrAnyKeyword(this.currentToken()) ? this.eatIdentifierNameToken() : this.eatAnyToken(); + }; + + ParserImpl.prototype.isFunctionPropertyAssignment = function (inErrorRecovery) { + return this.isPropertyName(this.currentToken(), inErrorRecovery) && this.isCallSignature(1); + }; + + ParserImpl.prototype.parseFunctionPropertyAssignment = function () { + var propertyName = this.eatPropertyName(); + var callSignature = this.parseCallSignature(false); + var block = this.parseBlock(false, true); + + return this.factory.functionPropertyAssignment(propertyName, callSignature, block); + }; + + ParserImpl.prototype.isSimplePropertyAssignment = function (inErrorRecovery) { + return this.isPropertyName(this.currentToken(), inErrorRecovery); + }; + + ParserImpl.prototype.parseSimplePropertyAssignment = function () { + var propertyName = this.eatPropertyName(); + var colonToken = this.eatToken(106 /* ColonToken */); + var expression = this.parseAssignmentExpression(true); + + return this.factory.simplePropertyAssignment(propertyName, colonToken, expression); + }; + + ParserImpl.prototype.isPropertyName = function (token, inErrorRecovery) { + if (TypeScript.SyntaxFacts.isIdentifierNameOrAnyKeyword(token)) { + if (inErrorRecovery) { + return this.isIdentifier(token); + } else { + return true; + } + } + + switch (token.tokenKind) { + case 14 /* StringLiteral */: + case 13 /* NumericLiteral */: + return true; + + default: + return false; + } + }; + + ParserImpl.prototype.parseArrayLiteralExpression = function () { + var openBracketToken = this.eatToken(74 /* OpenBracketToken */); + + var result = this.parseSeparatedSyntaxList(65536 /* ArrayLiteralExpression_AssignmentExpressions */); + var expressions = result.list; + openBracketToken = this.addSkippedTokensAfterToken(openBracketToken, result.skippedTokens); + + var closeBracketToken = this.eatToken(75 /* CloseBracketToken */); + + return this.factory.arrayLiteralExpression(openBracketToken, expressions, closeBracketToken); + }; + + ParserImpl.prototype.parseLiteralExpression = function () { + return this.eatAnyToken(); + }; + + ParserImpl.prototype.parseThisExpression = function () { + var thisKeyword = this.eatKeyword(35 /* ThisKeyword */); + return thisKeyword; + }; + + ParserImpl.prototype.parseBlock = function (parseBlockEvenWithNoOpenBrace, checkForStrictMode) { + var openBraceToken = this.eatToken(70 /* OpenBraceToken */); + + var statements = TypeScript.Syntax.emptyList; + + if (parseBlockEvenWithNoOpenBrace || openBraceToken.width() > 0) { + var savedIsInStrictMode = this.isInStrictMode; + + var processItems = checkForStrictMode ? ParserImpl.updateStrictModeState : null; + var result = this.parseSyntaxList(32 /* Block_Statements */, processItems); + statements = result.list; + openBraceToken = this.addSkippedTokensAfterToken(openBraceToken, result.skippedTokens); + + this.setStrictMode(savedIsInStrictMode); + } + + var closeBraceToken = this.eatToken(71 /* CloseBraceToken */); + + return this.factory.block(openBraceToken, statements, closeBraceToken); + }; + + ParserImpl.prototype.parseCallSignature = function (requireCompleteTypeParameterList) { + var typeParameterList = this.parseOptionalTypeParameterList(requireCompleteTypeParameterList); + var parameterList = this.parseParameterList(); + var typeAnnotation = this.parseOptionalTypeAnnotation(false); + + return this.factory.callSignature(typeParameterList, parameterList, typeAnnotation); + }; + + ParserImpl.prototype.parseOptionalTypeParameterList = function (requireCompleteTypeParameterList) { + if (this.currentToken().tokenKind !== 80 /* LessThanToken */) { + return null; + } + + var rewindPoint = this.getRewindPoint(); + try { + var lessThanToken = this.eatToken(80 /* LessThanToken */); + + var result = this.parseSeparatedSyntaxList(524288 /* TypeParameterList_TypeParameters */); + var typeParameterList = result.list; + lessThanToken = this.addSkippedTokensAfterToken(lessThanToken, result.skippedTokens); + + var greaterThanToken = this.eatToken(81 /* GreaterThanToken */); + + if (requireCompleteTypeParameterList && greaterThanToken.fullWidth() === 0) { + this.rewind(rewindPoint); + return null; + } + + return this.factory.typeParameterList(lessThanToken, typeParameterList, greaterThanToken); + } finally { + this.releaseRewindPoint(rewindPoint); + } + }; + + ParserImpl.prototype.isTypeParameter = function () { + return this.isIdentifier(this.currentToken()); + }; + + ParserImpl.prototype.parseTypeParameter = function () { + var identifier = this.eatIdentifierToken(); + var constraint = this.parseOptionalConstraint(); + + return this.factory.typeParameter(identifier, constraint); + }; + + ParserImpl.prototype.parseOptionalConstraint = function () { + if (this.currentToken().kind() !== 48 /* ExtendsKeyword */) { + return null; + } + + var extendsKeyword = this.eatKeyword(48 /* ExtendsKeyword */); + var type = this.parseType(); + + return this.factory.constraint(extendsKeyword, type); + }; + + ParserImpl.prototype.parseParameterList = function () { + var openParenToken = this.eatToken(72 /* OpenParenToken */); + var parameters = TypeScript.Syntax.emptySeparatedList; + + if (openParenToken.width() > 0) { + var result = this.parseSeparatedSyntaxList(131072 /* ParameterList_Parameters */); + parameters = result.list; + openParenToken = this.addSkippedTokensAfterToken(openParenToken, result.skippedTokens); + } + + var closeParenToken = this.eatToken(73 /* CloseParenToken */); + return this.factory.parameterList(openParenToken, parameters, closeParenToken); + }; + + ParserImpl.prototype.isTypeAnnotation = function () { + return this.currentToken().tokenKind === 106 /* ColonToken */; + }; + + ParserImpl.prototype.parseOptionalTypeAnnotation = function (allowStringLiteral) { + return this.isTypeAnnotation() ? this.parseTypeAnnotation(allowStringLiteral) : null; + }; + + ParserImpl.prototype.parseTypeAnnotation = function (allowStringLiteral) { + var colonToken = this.eatToken(106 /* ColonToken */); + var type = allowStringLiteral && this.currentToken().tokenKind === 14 /* StringLiteral */ ? this.eatToken(14 /* StringLiteral */) : this.parseType(); + + return this.factory.typeAnnotation(colonToken, type); + }; + + ParserImpl.prototype.isType = function () { + return this.isPredefinedType() || this.isTypeLiteral() || this.isTypeQuery() || this.isName(); + }; + + ParserImpl.prototype.parseType = function () { + if (this.isTypeQuery()) { + return this.parseTypeQuery(); + } else { + var type = this.parseNonArrayType(); + + while (this.currentToken().tokenKind === 74 /* OpenBracketToken */) { + var openBracketToken = this.eatToken(74 /* OpenBracketToken */); + var closeBracketToken = this.eatToken(75 /* CloseBracketToken */); + + type = this.factory.arrayType(type, openBracketToken, closeBracketToken); + } + + return type; + } + }; + + ParserImpl.prototype.isTypeQuery = function () { + return this.currentToken().tokenKind === 39 /* TypeOfKeyword */; + }; + + ParserImpl.prototype.parseTypeQuery = function () { + var typeOfKeyword = this.eatToken(39 /* TypeOfKeyword */); + var name = this.parseName(); + + return this.factory.typeQuery(typeOfKeyword, name); + }; + + ParserImpl.prototype.parseNonArrayType = function () { + if (this.isPredefinedType()) { + return this.parsePredefinedType(); + } else if (this.isTypeLiteral()) { + return this.parseTypeLiteral(); + } else { + return this.parseNameOrGenericType(); + } + }; + + ParserImpl.prototype.parseNameOrGenericType = function () { + var name = this.parseName(); + var typeArgumentList = this.tryParseTypeArgumentList(false); + + return typeArgumentList === null ? name : this.factory.genericType(name, typeArgumentList); + }; + + ParserImpl.prototype.parseTypeLiteral = function () { + if (this.isObjectType()) { + return this.parseObjectType(); + } else if (this.isFunctionType()) { + return this.parseFunctionType(); + } else if (this.isConstructorType()) { + return this.parseConstructorType(); + } else { + throw TypeScript.Errors.invalidOperation(); + } + }; + + ParserImpl.prototype.parseFunctionType = function () { + var typeParameterList = this.parseOptionalTypeParameterList(false); + var parameterList = this.parseParameterList(); + var equalsGreaterThanToken = this.eatToken(85 /* EqualsGreaterThanToken */); + var returnType = this.parseType(); + + return this.factory.functionType(typeParameterList, parameterList, equalsGreaterThanToken, returnType); + }; + + ParserImpl.prototype.parseConstructorType = function () { + var newKeyword = this.eatKeyword(31 /* NewKeyword */); + var parameterList = this.parseParameterList(); + var equalsGreaterThanToken = this.eatToken(85 /* EqualsGreaterThanToken */); + var type = this.parseType(); + + return this.factory.constructorType(newKeyword, null, parameterList, equalsGreaterThanToken, type); + }; + + ParserImpl.prototype.isTypeLiteral = function () { + return this.isObjectType() || this.isFunctionType() || this.isConstructorType(); + }; + + ParserImpl.prototype.isObjectType = function () { + return this.currentToken().tokenKind === 70 /* OpenBraceToken */; + }; + + ParserImpl.prototype.isFunctionType = function () { + var tokenKind = this.currentToken().tokenKind; + return tokenKind === 72 /* OpenParenToken */ || tokenKind === 80 /* LessThanToken */; + }; + + ParserImpl.prototype.isConstructorType = function () { + return this.currentToken().tokenKind === 31 /* NewKeyword */; + }; + + ParserImpl.prototype.parsePredefinedType = function () { + return this.eatAnyToken(); + }; + + ParserImpl.prototype.isPredefinedType = function () { + switch (this.currentToken().tokenKind) { + case 60 /* AnyKeyword */: + case 67 /* NumberKeyword */: + case 61 /* BooleanKeyword */: + case 69 /* StringKeyword */: + case 41 /* VoidKeyword */: + return true; + } + + return false; + }; + + ParserImpl.prototype.isParameter = function () { + if (this.currentNode() !== null && this.currentNode().kind() === 242 /* Parameter */) { + return true; + } + + var token = this.currentToken(); + if (token.tokenKind === 77 /* DotDotDotToken */) { + return true; + } + + if (ParserImpl.isPublicOrPrivateKeyword(token)) { + return true; + } + + return this.isIdentifier(token); + }; + + ParserImpl.prototype.parseParameter = function () { + if (this.currentNode() !== null && this.currentNode().kind() === 242 /* Parameter */) { + return this.eatNode(); + } + + var dotDotDotToken = this.tryEatToken(77 /* DotDotDotToken */); + + var publicOrPrivateToken = null; + if (ParserImpl.isPublicOrPrivateKeyword(this.currentToken())) { + publicOrPrivateToken = this.eatAnyToken(); + } + + var identifier = this.eatIdentifierToken(); + var questionToken = this.tryEatToken(105 /* QuestionToken */); + var typeAnnotation = this.parseOptionalTypeAnnotation(true); + + var equalsValueClause = null; + if (this.isEqualsValueClause(true)) { + equalsValueClause = this.parseEqualsValueClause(true); + } + + return this.factory.parameter(dotDotDotToken, publicOrPrivateToken, identifier, questionToken, typeAnnotation, equalsValueClause); + }; + + ParserImpl.prototype.parseSyntaxList = function (currentListType, processItems) { + if (typeof processItems === "undefined") { processItems = null; } + var savedListParsingState = this.listParsingState; + this.listParsingState |= currentListType; + + var result = this.parseSyntaxListWorker(currentListType, processItems); + + this.listParsingState = savedListParsingState; + + return result; + }; + + ParserImpl.prototype.parseSeparatedSyntaxList = function (currentListType) { + var savedListParsingState = this.listParsingState; + this.listParsingState |= currentListType; + + var result = this.parseSeparatedSyntaxListWorker(currentListType); + + this.listParsingState = savedListParsingState; + + return result; + }; + + ParserImpl.prototype.abortParsingListOrMoveToNextToken = function (currentListType, items, skippedTokens) { + this.reportUnexpectedTokenDiagnostic(currentListType); + + for (var state = 262144 /* LastListParsingState */; state >= 1 /* FirstListParsingState */; state >>= 1) { + if ((this.listParsingState & state) !== 0) { + if (this.isExpectedListTerminator(state) || this.isExpectedListItem(state, true)) { + return true; + } + } + } + + var skippedToken = this.currentToken(); + + this.moveToNextToken(); + + this.addSkippedTokenToList(items, skippedTokens, skippedToken); + + return false; + }; + + ParserImpl.prototype.addSkippedTokenToList = function (items, skippedTokens, skippedToken) { + for (var i = items.length - 1; i >= 0; i--) { + var item = items[i]; + var lastToken = item.lastToken(); + if (lastToken.fullWidth() > 0) { + items[i] = this.addSkippedTokenAfterNodeOrToken(item, skippedToken); + return; + } + } + + skippedTokens.push(skippedToken); + }; + + ParserImpl.prototype.tryParseExpectedListItem = function (currentListType, inErrorRecovery, items, processItems) { + if (this.isExpectedListItem(currentListType, inErrorRecovery)) { + var item = this.parseExpectedListItem(currentListType); + + items.push(item); + + if (processItems !== null) { + processItems(this, items); + } + } + }; + + ParserImpl.prototype.listIsTerminated = function (currentListType) { + return this.isExpectedListTerminator(currentListType) || this.currentToken().tokenKind === 10 /* EndOfFileToken */; + }; + + ParserImpl.prototype.getArray = function () { + if (this.arrayPool.length > 0) { + return this.arrayPool.pop(); + } + + return []; + }; + + ParserImpl.prototype.returnZeroOrOneLengthArray = function (array) { + if (array.length <= 1) { + this.returnArray(array); + } + }; + + ParserImpl.prototype.returnArray = function (array) { + array.length = 0; + this.arrayPool.push(array); + }; + + ParserImpl.prototype.parseSyntaxListWorker = function (currentListType, processItems) { + var items = this.getArray(); + var skippedTokens = this.getArray(); + + while (true) { + var oldItemsCount = items.length; + this.tryParseExpectedListItem(currentListType, false, items, processItems); + + var newItemsCount = items.length; + if (newItemsCount === oldItemsCount) { + if (this.listIsTerminated(currentListType)) { + break; + } + + var abort = this.abortParsingListOrMoveToNextToken(currentListType, items, skippedTokens); + if (abort) { + break; + } + } + } + + var result = TypeScript.Syntax.list(items); + + this.returnZeroOrOneLengthArray(items); + + return { skippedTokens: skippedTokens, list: result }; + }; + + ParserImpl.prototype.parseSeparatedSyntaxListWorker = function (currentListType) { + var items = this.getArray(); + var skippedTokens = this.getArray(); + TypeScript.Debug.assert(items.length === 0); + TypeScript.Debug.assert(skippedTokens.length === 0); + TypeScript.Debug.assert(skippedTokens !== items); + + var separatorKind = this.separatorKind(currentListType); + var allowAutomaticSemicolonInsertion = separatorKind === 78 /* SemicolonToken */; + + var inErrorRecovery = false; + var listWasTerminated = false; + while (true) { + var oldItemsCount = items.length; + + this.tryParseExpectedListItem(currentListType, inErrorRecovery, items, null); + + var newItemsCount = items.length; + if (newItemsCount === oldItemsCount) { + if (this.listIsTerminated(currentListType)) { + listWasTerminated = true; + break; + } + + var abort = this.abortParsingListOrMoveToNextToken(currentListType, items, skippedTokens); + if (abort) { + break; + } else { + inErrorRecovery = true; + continue; + } + } + + inErrorRecovery = false; + + var currentToken = this.currentToken(); + if (currentToken.tokenKind === separatorKind || currentToken.tokenKind === 79 /* CommaToken */) { + items.push(this.eatAnyToken()); + continue; + } + + if (this.listIsTerminated(currentListType)) { + listWasTerminated = true; + break; + } + + if (allowAutomaticSemicolonInsertion && this.canEatAutomaticSemicolon(false)) { + items.push(this.eatExplicitOrAutomaticSemicolon(false)); + + continue; + } + + items.push(this.eatToken(separatorKind)); + + inErrorRecovery = true; + } + + var result = TypeScript.Syntax.separatedList(items); + + this.returnZeroOrOneLengthArray(items); + + return { skippedTokens: skippedTokens, list: result }; + }; + + ParserImpl.prototype.separatorKind = function (currentListType) { + switch (currentListType) { + case 2048 /* HeritageClause_TypeNameList */: + case 16384 /* ArgumentList_AssignmentExpressions */: + case 256 /* EnumDeclaration_EnumElements */: + case 4096 /* VariableDeclaration_VariableDeclarators_AllowIn */: + case 8192 /* VariableDeclaration_VariableDeclarators_DisallowIn */: + case 32768 /* ObjectLiteralExpression_PropertyAssignments */: + case 131072 /* ParameterList_Parameters */: + case 65536 /* ArrayLiteralExpression_AssignmentExpressions */: + case 262144 /* TypeArgumentList_Types */: + case 524288 /* TypeParameterList_TypeParameters */: + return 79 /* CommaToken */; + + case 512 /* ObjectType_TypeMembers */: + return 78 /* SemicolonToken */; + + case 1 /* SourceUnit_ModuleElements */: + case 1024 /* ClassOrInterfaceDeclaration_HeritageClauses */: + case 2 /* ClassDeclaration_ClassElements */: + case 4 /* ModuleDeclaration_ModuleElements */: + case 8 /* SwitchStatement_SwitchClauses */: + case 16 /* SwitchClause_Statements */: + case 32 /* Block_Statements */: + default: + throw TypeScript.Errors.notYetImplemented(); + } + }; + + ParserImpl.prototype.reportUnexpectedTokenDiagnostic = function (listType) { + var token = this.currentToken(); + + var diagnostic = new TypeScript.Diagnostic(this.fileName, this.currentTokenStart(), token.width(), TypeScript.DiagnosticCode.Unexpected_token_0_expected, [this.getExpectedListElementType(listType)]); + this.addDiagnostic(diagnostic); + }; + + ParserImpl.prototype.addDiagnostic = function (diagnostic) { + if (this.diagnostics.length > 0 && this.diagnostics[this.diagnostics.length - 1].start() === diagnostic.start()) { + return; + } + + this.diagnostics.push(diagnostic); + }; + + ParserImpl.prototype.isExpectedListTerminator = function (currentListType) { + switch (currentListType) { + case 1 /* SourceUnit_ModuleElements */: + return this.isExpectedSourceUnit_ModuleElementsTerminator(); + + case 1024 /* ClassOrInterfaceDeclaration_HeritageClauses */: + return this.isExpectedClassOrInterfaceDeclaration_HeritageClausesTerminator(); + + case 2 /* ClassDeclaration_ClassElements */: + return this.isExpectedClassDeclaration_ClassElementsTerminator(); + + case 4 /* ModuleDeclaration_ModuleElements */: + return this.isExpectedModuleDeclaration_ModuleElementsTerminator(); + + case 8 /* SwitchStatement_SwitchClauses */: + return this.isExpectedSwitchStatement_SwitchClausesTerminator(); + + case 16 /* SwitchClause_Statements */: + return this.isExpectedSwitchClause_StatementsTerminator(); + + case 32 /* Block_Statements */: + return this.isExpectedBlock_StatementsTerminator(); + + case 64 /* TryBlock_Statements */: + return this.isExpectedTryBlock_StatementsTerminator(); + + case 128 /* CatchBlock_Statements */: + return this.isExpectedCatchBlock_StatementsTerminator(); + + case 256 /* EnumDeclaration_EnumElements */: + return this.isExpectedEnumDeclaration_EnumElementsTerminator(); + + case 512 /* ObjectType_TypeMembers */: + return this.isExpectedObjectType_TypeMembersTerminator(); + + case 16384 /* ArgumentList_AssignmentExpressions */: + return this.isExpectedArgumentList_AssignmentExpressionsTerminator(); + + case 2048 /* HeritageClause_TypeNameList */: + return this.isExpectedHeritageClause_TypeNameListTerminator(); + + case 4096 /* VariableDeclaration_VariableDeclarators_AllowIn */: + return this.isExpectedVariableDeclaration_VariableDeclarators_AllowInTerminator(); + + case 8192 /* VariableDeclaration_VariableDeclarators_DisallowIn */: + return this.isExpectedVariableDeclaration_VariableDeclarators_DisallowInTerminator(); + + case 32768 /* ObjectLiteralExpression_PropertyAssignments */: + return this.isExpectedObjectLiteralExpression_PropertyAssignmentsTerminator(); + + case 131072 /* ParameterList_Parameters */: + return this.isExpectedParameterList_ParametersTerminator(); + + case 262144 /* TypeArgumentList_Types */: + return this.isExpectedTypeArgumentList_TypesTerminator(); + + case 524288 /* TypeParameterList_TypeParameters */: + return this.isExpectedTypeParameterList_TypeParametersTerminator(); + + case 65536 /* ArrayLiteralExpression_AssignmentExpressions */: + return this.isExpectedLiteralExpression_AssignmentExpressionsTerminator(); + + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ParserImpl.prototype.isExpectedSourceUnit_ModuleElementsTerminator = function () { + return this.currentToken().tokenKind === 10 /* EndOfFileToken */; + }; + + ParserImpl.prototype.isExpectedEnumDeclaration_EnumElementsTerminator = function () { + return this.currentToken().tokenKind === 71 /* CloseBraceToken */; + }; + + ParserImpl.prototype.isExpectedModuleDeclaration_ModuleElementsTerminator = function () { + return this.currentToken().tokenKind === 71 /* CloseBraceToken */; + }; + + ParserImpl.prototype.isExpectedObjectType_TypeMembersTerminator = function () { + return this.currentToken().tokenKind === 71 /* CloseBraceToken */; + }; + + ParserImpl.prototype.isExpectedObjectLiteralExpression_PropertyAssignmentsTerminator = function () { + return this.currentToken().tokenKind === 71 /* CloseBraceToken */; + }; + + ParserImpl.prototype.isExpectedLiteralExpression_AssignmentExpressionsTerminator = function () { + return this.currentToken().tokenKind === 75 /* CloseBracketToken */; + }; + + ParserImpl.prototype.isExpectedTypeArgumentList_TypesTerminator = function () { + var token = this.currentToken(); + if (token.tokenKind === 81 /* GreaterThanToken */) { + return true; + } + + if (this.canFollowTypeArgumentListInExpression(token.tokenKind)) { + return true; + } + + return false; + }; + + ParserImpl.prototype.isExpectedTypeParameterList_TypeParametersTerminator = function () { + var token = this.currentToken(); + if (token.tokenKind === 81 /* GreaterThanToken */) { + return true; + } + + if (token.tokenKind === 72 /* OpenParenToken */ || token.tokenKind === 70 /* OpenBraceToken */ || token.tokenKind === 48 /* ExtendsKeyword */ || token.tokenKind === 51 /* ImplementsKeyword */) { + return true; + } + + return false; + }; + + ParserImpl.prototype.isExpectedParameterList_ParametersTerminator = function () { + var token = this.currentToken(); + if (token.tokenKind === 73 /* CloseParenToken */) { + return true; + } + + if (token.tokenKind === 70 /* OpenBraceToken */) { + return true; + } + + if (token.tokenKind === 85 /* EqualsGreaterThanToken */) { + return true; + } + + return false; + }; + + ParserImpl.prototype.isExpectedVariableDeclaration_VariableDeclarators_DisallowInTerminator = function () { + if (this.currentToken().tokenKind === 78 /* SemicolonToken */ || this.currentToken().tokenKind === 73 /* CloseParenToken */) { + return true; + } + + if (this.currentToken().tokenKind === 29 /* InKeyword */) { + return true; + } + + return false; + }; + + ParserImpl.prototype.isExpectedVariableDeclaration_VariableDeclarators_AllowInTerminator = function () { + if (this.previousToken().tokenKind === 79 /* CommaToken */) { + return false; + } + + if (this.currentToken().tokenKind === 85 /* EqualsGreaterThanToken */) { + return true; + } + + return this.canEatExplicitOrAutomaticSemicolon(false); + }; + + ParserImpl.prototype.isExpectedClassOrInterfaceDeclaration_HeritageClausesTerminator = function () { + var token0 = this.currentToken(); + if (token0.tokenKind === 70 /* OpenBraceToken */ || token0.tokenKind === 71 /* CloseBraceToken */) { + return true; + } + + return false; + }; + + ParserImpl.prototype.isExpectedHeritageClause_TypeNameListTerminator = function () { + var token0 = this.currentToken(); + if (token0.tokenKind === 48 /* ExtendsKeyword */ || token0.tokenKind === 51 /* ImplementsKeyword */) { + return true; + } + + if (this.isExpectedClassOrInterfaceDeclaration_HeritageClausesTerminator()) { + return true; + } + + return false; + }; + + ParserImpl.prototype.isExpectedArgumentList_AssignmentExpressionsTerminator = function () { + var token0 = this.currentToken(); + return token0.tokenKind === 73 /* CloseParenToken */ || token0.tokenKind === 78 /* SemicolonToken */; + }; + + ParserImpl.prototype.isExpectedClassDeclaration_ClassElementsTerminator = function () { + return this.currentToken().tokenKind === 71 /* CloseBraceToken */; + }; + + ParserImpl.prototype.isExpectedSwitchStatement_SwitchClausesTerminator = function () { + return this.currentToken().tokenKind === 71 /* CloseBraceToken */; + }; + + ParserImpl.prototype.isExpectedSwitchClause_StatementsTerminator = function () { + return this.currentToken().tokenKind === 71 /* CloseBraceToken */ || this.isSwitchClause(); + }; + + ParserImpl.prototype.isExpectedBlock_StatementsTerminator = function () { + return this.currentToken().tokenKind === 71 /* CloseBraceToken */; + }; + + ParserImpl.prototype.isExpectedTryBlock_StatementsTerminator = function () { + return this.currentToken().tokenKind === 17 /* CatchKeyword */ || this.currentToken().tokenKind === 25 /* FinallyKeyword */; + }; + + ParserImpl.prototype.isExpectedCatchBlock_StatementsTerminator = function () { + return this.currentToken().tokenKind === 25 /* FinallyKeyword */; + }; + + ParserImpl.prototype.isExpectedListItem = function (currentListType, inErrorRecovery) { + switch (currentListType) { + case 1 /* SourceUnit_ModuleElements */: + return this.isModuleElement(inErrorRecovery); + + case 1024 /* ClassOrInterfaceDeclaration_HeritageClauses */: + return this.isHeritageClause(); + + case 2 /* ClassDeclaration_ClassElements */: + return this.isClassElement(inErrorRecovery); + + case 4 /* ModuleDeclaration_ModuleElements */: + return this.isModuleElement(inErrorRecovery); + + case 8 /* SwitchStatement_SwitchClauses */: + return this.isSwitchClause(); + + case 16 /* SwitchClause_Statements */: + return this.isStatement(inErrorRecovery); + + case 32 /* Block_Statements */: + return this.isStatement(inErrorRecovery); + + case 64 /* TryBlock_Statements */: + case 128 /* CatchBlock_Statements */: + return false; + + case 256 /* EnumDeclaration_EnumElements */: + return this.isEnumElement(inErrorRecovery); + + case 4096 /* VariableDeclaration_VariableDeclarators_AllowIn */: + case 8192 /* VariableDeclaration_VariableDeclarators_DisallowIn */: + return this.isVariableDeclarator(); + + case 512 /* ObjectType_TypeMembers */: + return this.isTypeMember(inErrorRecovery); + + case 16384 /* ArgumentList_AssignmentExpressions */: + return this.isExpectedArgumentList_AssignmentExpression(); + + case 2048 /* HeritageClause_TypeNameList */: + return this.isHeritageClauseTypeName(); + + case 32768 /* ObjectLiteralExpression_PropertyAssignments */: + return this.isPropertyAssignment(inErrorRecovery); + + case 131072 /* ParameterList_Parameters */: + return this.isParameter(); + + case 262144 /* TypeArgumentList_Types */: + return this.isType(); + + case 524288 /* TypeParameterList_TypeParameters */: + return this.isTypeParameter(); + + case 65536 /* ArrayLiteralExpression_AssignmentExpressions */: + return this.isAssignmentOrOmittedExpression(); + + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ParserImpl.prototype.isExpectedArgumentList_AssignmentExpression = function () { + if (this.isExpression()) { + return true; + } + + if (this.currentToken().tokenKind === 79 /* CommaToken */) { + return true; + } + + return false; + }; + + ParserImpl.prototype.parseExpectedListItem = function (currentListType) { + switch (currentListType) { + case 1 /* SourceUnit_ModuleElements */: + return this.parseModuleElement(); + + case 1024 /* ClassOrInterfaceDeclaration_HeritageClauses */: + return this.parseHeritageClause(); + + case 2 /* ClassDeclaration_ClassElements */: + return this.parseClassElement(false); + + case 4 /* ModuleDeclaration_ModuleElements */: + return this.parseModuleElement(); + + case 8 /* SwitchStatement_SwitchClauses */: + return this.parseSwitchClause(); + + case 16 /* SwitchClause_Statements */: + return this.parseStatement(); + + case 32 /* Block_Statements */: + return this.parseStatement(); + + case 256 /* EnumDeclaration_EnumElements */: + return this.parseEnumElement(); + + case 512 /* ObjectType_TypeMembers */: + return this.parseTypeMember(); + + case 16384 /* ArgumentList_AssignmentExpressions */: + return this.parseAssignmentExpression(true); + + case 2048 /* HeritageClause_TypeNameList */: + return this.parseNameOrGenericType(); + + case 4096 /* VariableDeclaration_VariableDeclarators_AllowIn */: + return this.parseVariableDeclarator(true, false); + + case 8192 /* VariableDeclaration_VariableDeclarators_DisallowIn */: + return this.parseVariableDeclarator(false, false); + + case 32768 /* ObjectLiteralExpression_PropertyAssignments */: + return this.parsePropertyAssignment(); + + case 65536 /* ArrayLiteralExpression_AssignmentExpressions */: + return this.parseAssignmentOrOmittedExpression(); + + case 131072 /* ParameterList_Parameters */: + return this.parseParameter(); + + case 262144 /* TypeArgumentList_Types */: + return this.parseType(); + + case 524288 /* TypeParameterList_TypeParameters */: + return this.parseTypeParameter(); + + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ParserImpl.prototype.getExpectedListElementType = function (currentListType) { + switch (currentListType) { + case 1 /* SourceUnit_ModuleElements */: + return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.module_class_interface_enum_import_or_statement, null); + + case 1024 /* ClassOrInterfaceDeclaration_HeritageClauses */: + return '{'; + + case 2 /* ClassDeclaration_ClassElements */: + return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.constructor_function_accessor_or_variable, null); + + case 4 /* ModuleDeclaration_ModuleElements */: + return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.module_class_interface_enum_import_or_statement, null); + + case 8 /* SwitchStatement_SwitchClauses */: + return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.case_or_default_clause, null); + + case 16 /* SwitchClause_Statements */: + return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.statement, null); + + case 32 /* Block_Statements */: + return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.statement, null); + + case 4096 /* VariableDeclaration_VariableDeclarators_AllowIn */: + case 8192 /* VariableDeclaration_VariableDeclarators_DisallowIn */: + return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.identifier, null); + + case 256 /* EnumDeclaration_EnumElements */: + return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.identifier, null); + + case 512 /* ObjectType_TypeMembers */: + return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.call_construct_index_property_or_function_signature, null); + + case 16384 /* ArgumentList_AssignmentExpressions */: + return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.expression, null); + + case 2048 /* HeritageClause_TypeNameList */: + return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.type_name, null); + + case 32768 /* ObjectLiteralExpression_PropertyAssignments */: + return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.property_or_accessor, null); + + case 131072 /* ParameterList_Parameters */: + return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.parameter, null); + + case 262144 /* TypeArgumentList_Types */: + return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.type, null); + + case 524288 /* TypeParameterList_TypeParameters */: + return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.type_parameter, null); + + case 65536 /* ArrayLiteralExpression_AssignmentExpressions */: + return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.expression, null); + + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + return ParserImpl; + })(); + + function parse(fileName, text, isDeclaration, options) { + var source = new NormalParserSource(fileName, text, options.languageVersion()); + + return new ParserImpl(fileName, text.lineMap(), source, options).parseSyntaxTree(isDeclaration); + } + Parser.parse = parse; + + function incrementalParse(oldSyntaxTree, textChangeRange, newText) { + if (textChangeRange.isUnchanged()) { + return oldSyntaxTree; + } + + var source = new IncrementalParserSource(oldSyntaxTree, textChangeRange, newText); + + return new ParserImpl(oldSyntaxTree.fileName(), newText.lineMap(), source, oldSyntaxTree.parseOptions()).parseSyntaxTree(oldSyntaxTree.isDeclaration()); + } + Parser.incrementalParse = incrementalParse; + })(TypeScript.Parser || (TypeScript.Parser = {})); + var Parser = TypeScript.Parser; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var SyntaxTree = (function () { + function SyntaxTree(sourceUnit, isDeclaration, diagnostics, fileName, lineMap, parseOtions) { + this._allDiagnostics = null; + this._sourceUnit = sourceUnit; + this._isDeclaration = isDeclaration; + this._parserDiagnostics = diagnostics; + this._fileName = fileName; + this._lineMap = lineMap; + this._parseOptions = parseOtions; + } + SyntaxTree.prototype.toJSON = function (key) { + var result = {}; + + result.isDeclaration = this._isDeclaration; + result.languageVersion = TypeScript.LanguageVersion[this._parseOptions.languageVersion()]; + result.parseOptions = this._parseOptions; + + if (this.diagnostics().length > 0) { + result.diagnostics = this.diagnostics(); + } + + result.sourceUnit = this._sourceUnit; + result.lineMap = this._lineMap; + + return result; + }; + + SyntaxTree.prototype.sourceUnit = function () { + return this._sourceUnit; + }; + + SyntaxTree.prototype.isDeclaration = function () { + return this._isDeclaration; + }; + + SyntaxTree.prototype.computeDiagnostics = function () { + if (this._parserDiagnostics.length > 0) { + return this._parserDiagnostics; + } + + var diagnostics = []; + this.sourceUnit().accept(new GrammarCheckerWalker(this, diagnostics)); + + return diagnostics; + }; + + SyntaxTree.prototype.diagnostics = function () { + if (this._allDiagnostics === null) { + this._allDiagnostics = this.computeDiagnostics(); + } + + return this._allDiagnostics; + }; + + SyntaxTree.prototype.fileName = function () { + return this._fileName; + }; + + SyntaxTree.prototype.lineMap = function () { + return this._lineMap; + }; + + SyntaxTree.prototype.parseOptions = function () { + return this._parseOptions; + }; + + SyntaxTree.prototype.structuralEquals = function (tree) { + return TypeScript.ArrayUtilities.sequenceEquals(this.diagnostics(), tree.diagnostics(), TypeScript.Diagnostic.equals) && this.sourceUnit().structuralEquals(tree.sourceUnit()); + }; + return SyntaxTree; + })(); + TypeScript.SyntaxTree = SyntaxTree; + + var GrammarCheckerWalker = (function (_super) { + __extends(GrammarCheckerWalker, _super); + function GrammarCheckerWalker(syntaxTree, diagnostics) { + _super.call(this); + this.syntaxTree = syntaxTree; + this.diagnostics = diagnostics; + this.inAmbientDeclaration = false; + this.inBlock = false; + this.currentConstructor = null; + } + GrammarCheckerWalker.prototype.childFullStart = function (parent, child) { + return this.position() + TypeScript.Syntax.childOffset(parent, child); + }; + + GrammarCheckerWalker.prototype.childStart = function (parent, child) { + return this.childFullStart(parent, child) + child.leadingTriviaWidth(); + }; + + GrammarCheckerWalker.prototype.pushDiagnostic = function (start, length, diagnosticKey, args) { + if (typeof args === "undefined") { args = null; } + this.diagnostics.push(new TypeScript.Diagnostic(this.syntaxTree.fileName(), start, length, diagnosticKey, args)); + }; + + GrammarCheckerWalker.prototype.pushDiagnostic1 = function (elementFullStart, element, diagnosticKey, args) { + if (typeof args === "undefined") { args = null; } + this.diagnostics.push(new TypeScript.Diagnostic(this.syntaxTree.fileName(), elementFullStart + element.leadingTriviaWidth(), element.width(), diagnosticKey, args)); + }; + + GrammarCheckerWalker.prototype.visitCatchClause = function (node) { + if (node.typeAnnotation) { + this.pushDiagnostic(this.childStart(node, node.typeAnnotation), node.typeAnnotation.width(), TypeScript.DiagnosticCode.Catch_clause_parameter_cannot_have_a_type_annotation); + } + + _super.prototype.visitCatchClause.call(this, node); + }; + + GrammarCheckerWalker.prototype.checkParameterListOrder = function (node) { + var parameterFullStart = this.childFullStart(node, node.parameters); + + var seenOptionalParameter = false; + var parameterCount = node.parameters.nonSeparatorCount(); + + for (var i = 0, n = node.parameters.childCount(); i < n; i++) { + var nodeOrToken = node.parameters.childAt(i); + if (i % 2 === 0) { + var parameterIndex = i / 2; + var parameter = node.parameters.childAt(i); + + if (parameter.dotDotDotToken) { + if (parameterIndex !== (parameterCount - 1)) { + this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.Rest_parameter_must_be_last_in_list); + return true; + } + + if (parameter.questionToken) { + this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.Rest_parameter_cannot_be_optional); + return true; + } + + if (parameter.equalsValueClause) { + this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.Rest_parameter_cannot_have_an_initializer); + return true; + } + } else if (parameter.questionToken || parameter.equalsValueClause) { + seenOptionalParameter = true; + + if (parameter.questionToken && parameter.equalsValueClause) { + this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.Parameter_cannot_have_question_mark_and_initializer); + return true; + } + } else { + if (seenOptionalParameter) { + this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.Required_parameter_cannot_follow_optional_parameter); + return true; + } + } + } + + parameterFullStart += nodeOrToken.fullWidth(); + } + + return false; + }; + + GrammarCheckerWalker.prototype.checkParameterListAcessibilityModifiers = function (node) { + if (this.currentConstructor !== null && this.currentConstructor.parameterList === node && this.currentConstructor.block && !this.inAmbientDeclaration) { + return false; + } + + var parameterFullStart = this.childFullStart(node, node.parameters); + + for (var i = 0, n = node.parameters.childCount(); i < n; i++) { + var nodeOrToken = node.parameters.childAt(i); + if (i % 2 === 0) { + var parameter = node.parameters.childAt(i); + + if (parameter.publicOrPrivateKeyword) { + var keywordFullStart = parameterFullStart + TypeScript.Syntax.childOffset(parameter, parameter.publicOrPrivateKeyword); + + if (this.inAmbientDeclaration) { + this.pushDiagnostic1(keywordFullStart, parameter.publicOrPrivateKeyword, TypeScript.DiagnosticCode.Parameter_property_declarations_cannot_be_used_in_an_ambient_context); + } else if (!this.currentConstructor.block) { + this.pushDiagnostic1(keywordFullStart, parameter.publicOrPrivateKeyword, TypeScript.DiagnosticCode.Parameter_property_declarations_cannot_be_used_in_a_constructor_overload); + } else { + this.pushDiagnostic1(keywordFullStart, parameter.publicOrPrivateKeyword, TypeScript.DiagnosticCode.Parameter_property_declarations_can_only_be_used_in_constructors); + } + } + } + + parameterFullStart += nodeOrToken.fullWidth(); + } + + return false; + }; + + GrammarCheckerWalker.prototype.checkForTrailingSeparator = function (parent, list) { + if (list.childCount() === 0 || list.childCount() % 2 === 1) { + return false; + } + + var currentElementFullStart = this.childFullStart(parent, list); + + for (var i = 0, n = list.childCount(); i < n; i++) { + var child = list.childAt(i); + if (i === n - 1) { + this.pushDiagnostic1(currentElementFullStart, child, TypeScript.DiagnosticCode.Trailing_separator_not_allowed); + } + + currentElementFullStart += child.fullWidth(); + } + + return true; + }; + + GrammarCheckerWalker.prototype.checkForAtLeastOneElement = function (parent, list, expected) { + if (list.childCount() > 0) { + return false; + } + + var listFullStart = this.childFullStart(parent, list); + var tokenAtStart = this.syntaxTree.sourceUnit().findToken(listFullStart); + + this.pushDiagnostic1(listFullStart, tokenAtStart.token(), TypeScript.DiagnosticCode.Unexpected_token_0_expected, [expected]); + + return true; + }; + + GrammarCheckerWalker.prototype.visitParameterList = function (node) { + if (this.checkParameterListAcessibilityModifiers(node) || this.checkParameterListOrder(node) || this.checkForTrailingSeparator(node, node.parameters)) { + this.skip(node); + return; + } + + _super.prototype.visitParameterList.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitHeritageClause = function (node) { + if (this.checkForTrailingSeparator(node, node.typeNames) || this.checkForAtLeastOneElement(node, node.typeNames, TypeScript.getLocalizedText(TypeScript.DiagnosticCode.type_name, null))) { + this.skip(node); + return; + } + + _super.prototype.visitHeritageClause.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitArgumentList = function (node) { + if (this.checkForTrailingSeparator(node, node.arguments)) { + this.skip(node); + return; + } + + _super.prototype.visitArgumentList.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitVariableDeclaration = function (node) { + if (this.checkForTrailingSeparator(node, node.variableDeclarators) || this.checkForAtLeastOneElement(node, node.variableDeclarators, TypeScript.getLocalizedText(TypeScript.DiagnosticCode.identifier, null))) { + this.skip(node); + return; + } + + _super.prototype.visitVariableDeclaration.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitTypeArgumentList = function (node) { + if (this.checkForTrailingSeparator(node, node.typeArguments) || this.checkForAtLeastOneElement(node, node.typeArguments, TypeScript.getLocalizedText(TypeScript.DiagnosticCode.identifier, null))) { + this.skip(node); + return; + } + + _super.prototype.visitTypeArgumentList.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitTypeParameterList = function (node) { + if (this.checkForTrailingSeparator(node, node.typeParameters) || this.checkForAtLeastOneElement(node, node.typeParameters, TypeScript.getLocalizedText(TypeScript.DiagnosticCode.identifier, null))) { + this.skip(node); + return; + } + + _super.prototype.visitTypeParameterList.call(this, node); + }; + + GrammarCheckerWalker.prototype.checkIndexSignatureParameter = function (node) { + var parameterFullStart = this.childFullStart(node, node.parameter); + var parameter = node.parameter; + + if (parameter.dotDotDotToken) { + this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.Index_signatures_cannot_have_rest_parameters); + return true; + } else if (parameter.publicOrPrivateKeyword) { + this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.Index_signature_parameter_cannot_have_accessibility_modifiers); + return true; + } else if (parameter.questionToken) { + this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.Index_signature_parameter_cannot_have_a_question_mark); + return true; + } else if (parameter.equalsValueClause) { + this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.Index_signature_parameter_cannot_have_an_initializer); + return true; + } else if (!parameter.typeAnnotation) { + this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.Index_signature_parameter_must_have_a_type_annotation); + return true; + } else if (parameter.typeAnnotation.type.kind() !== 69 /* StringKeyword */ && parameter.typeAnnotation.type.kind() !== 67 /* NumberKeyword */) { + this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.Index_signature_parameter_type_must_be_string_or_number); + return true; + } + + return false; + }; + + GrammarCheckerWalker.prototype.visitIndexSignature = function (node) { + if (this.checkIndexSignatureParameter(node)) { + this.skip(node); + return; + } + + if (!node.typeAnnotation) { + this.pushDiagnostic1(this.position(), node, TypeScript.DiagnosticCode.Index_signature_must_have_a_type_annotation); + this.skip(node); + return; + } + + _super.prototype.visitIndexSignature.call(this, node); + }; + + GrammarCheckerWalker.prototype.checkClassDeclarationHeritageClauses = function (node) { + var heritageClauseFullStart = this.childFullStart(node, node.heritageClauses); + + var seenExtendsClause = false; + var seenImplementsClause = false; + + for (var i = 0, n = node.heritageClauses.childCount(); i < n; i++) { + TypeScript.Debug.assert(i <= 2); + var heritageClause = node.heritageClauses.childAt(i); + + if (heritageClause.extendsOrImplementsKeyword.tokenKind === 48 /* ExtendsKeyword */) { + if (seenExtendsClause) { + this.pushDiagnostic1(heritageClauseFullStart, heritageClause, TypeScript.DiagnosticCode.extends_clause_already_seen); + return true; + } + + if (seenImplementsClause) { + this.pushDiagnostic1(heritageClauseFullStart, heritageClause, TypeScript.DiagnosticCode.extends_clause_must_precede_implements_clause); + return true; + } + + if (heritageClause.typeNames.nonSeparatorCount() > 1) { + this.pushDiagnostic1(heritageClauseFullStart, heritageClause, TypeScript.DiagnosticCode.Classes_can_only_extend_a_single_class); + return true; + } + + seenExtendsClause = true; + } else { + TypeScript.Debug.assert(heritageClause.extendsOrImplementsKeyword.tokenKind === 51 /* ImplementsKeyword */); + if (seenImplementsClause) { + this.pushDiagnostic1(heritageClauseFullStart, heritageClause, TypeScript.DiagnosticCode.implements_clause_already_seen); + return true; + } + + seenImplementsClause = true; + } + + heritageClauseFullStart += heritageClause.fullWidth(); + } + + return false; + }; + + GrammarCheckerWalker.prototype.checkForDisallowedDeclareModifier = function (modifiers) { + if (this.inAmbientDeclaration) { + var declareToken = TypeScript.SyntaxUtilities.getToken(modifiers, 63 /* DeclareKeyword */); + + if (declareToken) { + this.pushDiagnostic1(this.childFullStart(modifiers, declareToken), declareToken, TypeScript.DiagnosticCode.declare_modifier_not_allowed_for_code_already_in_an_ambient_context); + return true; + } + } + + return false; + }; + + GrammarCheckerWalker.prototype.checkForRequiredDeclareModifier = function (moduleElement, typeKeyword, modifiers) { + if (!this.inAmbientDeclaration && this.syntaxTree.isDeclaration()) { + if (!TypeScript.SyntaxUtilities.containsToken(modifiers, 63 /* DeclareKeyword */)) { + this.pushDiagnostic1(this.childFullStart(moduleElement, typeKeyword), typeKeyword.firstToken(), TypeScript.DiagnosticCode.declare_modifier_required_for_top_level_element); + return true; + } + } + }; + + GrammarCheckerWalker.prototype.checkFunctionOverloads = function (node, moduleElements) { + if (!this.inAmbientDeclaration && !this.syntaxTree.isDeclaration()) { + var moduleElementFullStart = this.childFullStart(node, moduleElements); + + var inFunctionOverloadChain = false; + var functionOverloadChainName = null; + + for (var i = 0, n = moduleElements.childCount(); i < n; i++) { + var moduleElement = moduleElements.childAt(i); + var lastElement = i === (n - 1); + + if (inFunctionOverloadChain) { + if (moduleElement.kind() !== 129 /* FunctionDeclaration */) { + this.pushDiagnostic1(moduleElementFullStart, moduleElement.firstToken(), TypeScript.DiagnosticCode.Function_implementation_expected); + return true; + } + + var functionDeclaration = moduleElement; + if (functionDeclaration.identifier.valueText() !== functionOverloadChainName) { + var identifierFullStart = moduleElementFullStart + TypeScript.Syntax.childOffset(moduleElement, functionDeclaration.identifier); + this.pushDiagnostic1(identifierFullStart, functionDeclaration.identifier, TypeScript.DiagnosticCode.Function_overload_name_must_be_0, [functionOverloadChainName]); + return true; + } + } + + if (moduleElement.kind() === 129 /* FunctionDeclaration */) { + functionDeclaration = moduleElement; + if (!TypeScript.SyntaxUtilities.containsToken(functionDeclaration.modifiers, 63 /* DeclareKeyword */)) { + inFunctionOverloadChain = functionDeclaration.block === null; + functionOverloadChainName = functionDeclaration.identifier.valueText(); + + if (lastElement && inFunctionOverloadChain) { + this.pushDiagnostic1(moduleElementFullStart, moduleElement.firstToken(), TypeScript.DiagnosticCode.Function_implementation_expected); + return true; + } + } else { + inFunctionOverloadChain = false; + functionOverloadChainName = ""; + } + } + + moduleElementFullStart += moduleElement.fullWidth(); + } + } + + return false; + }; + + GrammarCheckerWalker.prototype.checkClassOverloads = function (node) { + if (!this.inAmbientDeclaration && !TypeScript.SyntaxUtilities.containsToken(node.modifiers, 63 /* DeclareKeyword */)) { + var classElementFullStart = this.childFullStart(node, node.classElements); + + var inFunctionOverloadChain = false; + var inConstructorOverloadChain = false; + + var functionOverloadChainName = null; + var isInStaticOverloadChain = null; + var memberFunctionDeclaration = null; + + for (var i = 0, n = node.classElements.childCount(); i < n; i++) { + var classElement = node.classElements.childAt(i); + var lastElement = i === (n - 1); + var isStaticOverload = null; + + if (inFunctionOverloadChain) { + if (classElement.kind() !== 135 /* MemberFunctionDeclaration */) { + this.pushDiagnostic1(classElementFullStart, classElement.firstToken(), TypeScript.DiagnosticCode.Function_implementation_expected); + return true; + } + + memberFunctionDeclaration = classElement; + if (memberFunctionDeclaration.propertyName.valueText() !== functionOverloadChainName) { + var propertyNameFullStart = classElementFullStart + TypeScript.Syntax.childOffset(classElement, memberFunctionDeclaration.propertyName); + this.pushDiagnostic1(propertyNameFullStart, memberFunctionDeclaration.propertyName, TypeScript.DiagnosticCode.Function_overload_name_must_be_0, [functionOverloadChainName]); + return true; + } + isStaticOverload = TypeScript.SyntaxUtilities.containsToken(memberFunctionDeclaration.modifiers, 58 /* StaticKeyword */); + if (isStaticOverload !== isInStaticOverloadChain) { + propertyNameFullStart = classElementFullStart + TypeScript.Syntax.childOffset(classElement, memberFunctionDeclaration.propertyName); + var diagnostic = isInStaticOverloadChain ? TypeScript.DiagnosticCode.Function_overload_must_be_static : TypeScript.DiagnosticCode.Function_overload_must_not_be_static; + this.pushDiagnostic1(propertyNameFullStart, memberFunctionDeclaration.propertyName, diagnostic, null); + return true; + } + } else if (inConstructorOverloadChain) { + if (classElement.kind() !== 137 /* ConstructorDeclaration */) { + this.pushDiagnostic1(classElementFullStart, classElement.firstToken(), TypeScript.DiagnosticCode.Constructor_implementation_expected); + return true; + } + } + + if (classElement.kind() === 135 /* MemberFunctionDeclaration */) { + memberFunctionDeclaration = classElement; + + inFunctionOverloadChain = memberFunctionDeclaration.block === null; + functionOverloadChainName = memberFunctionDeclaration.propertyName.valueText(); + isInStaticOverloadChain = TypeScript.SyntaxUtilities.containsToken(memberFunctionDeclaration.modifiers, 58 /* StaticKeyword */); + + if (lastElement && inFunctionOverloadChain) { + this.pushDiagnostic1(classElementFullStart, classElement.firstToken(), TypeScript.DiagnosticCode.Function_implementation_expected); + return true; + } + } else if (classElement.kind() === 137 /* ConstructorDeclaration */) { + var constructorDeclaration = classElement; + + inConstructorOverloadChain = constructorDeclaration.block === null; + if (lastElement && inConstructorOverloadChain) { + this.pushDiagnostic1(classElementFullStart, classElement.firstToken(), TypeScript.DiagnosticCode.Constructor_implementation_expected); + return true; + } + } + + classElementFullStart += classElement.fullWidth(); + } + } + + return false; + }; + + GrammarCheckerWalker.prototype.checkForReservedName = function (parent, name, diagnosticKey) { + var nameFullStart = this.childFullStart(parent, name); + var token; + var tokenFullStart; + + var current = name; + while (current !== null) { + if (current.kind() === 121 /* QualifiedName */) { + var qualifiedName = current; + token = qualifiedName.right; + tokenFullStart = nameFullStart + this.childFullStart(qualifiedName, token); + current = qualifiedName.left; + } else { + TypeScript.Debug.assert(current.kind() === 11 /* IdentifierName */); + token = current; + tokenFullStart = nameFullStart; + current = null; + } + + switch (token.valueText()) { + case "any": + case "number": + case "boolean": + case "string": + case "void": + this.pushDiagnostic(tokenFullStart + token.leadingTriviaWidth(), token.width(), diagnosticKey, [token.valueText()]); + return true; + } + } + + return false; + }; + + GrammarCheckerWalker.prototype.visitClassDeclaration = function (node) { + if (this.checkForReservedName(node, node.identifier, TypeScript.DiagnosticCode.Class_name_cannot_be_0) || this.checkForDisallowedDeclareModifier(node.modifiers) || this.checkForRequiredDeclareModifier(node, node.classKeyword, node.modifiers) || this.checkModuleElementModifiers(node.modifiers) || this.checkClassDeclarationHeritageClauses(node) || this.checkClassOverloads(node)) { + this.skip(node); + return; + } + + var savedInAmbientDeclaration = this.inAmbientDeclaration; + this.inAmbientDeclaration = this.inAmbientDeclaration || this.syntaxTree.isDeclaration() || TypeScript.SyntaxUtilities.containsToken(node.modifiers, 63 /* DeclareKeyword */); + _super.prototype.visitClassDeclaration.call(this, node); + this.inAmbientDeclaration = savedInAmbientDeclaration; + }; + + GrammarCheckerWalker.prototype.checkInterfaceDeclarationHeritageClauses = function (node) { + var heritageClauseFullStart = this.childFullStart(node, node.heritageClauses); + + var seenExtendsClause = false; + + for (var i = 0, n = node.heritageClauses.childCount(); i < n; i++) { + TypeScript.Debug.assert(i <= 1); + var heritageClause = node.heritageClauses.childAt(i); + + if (heritageClause.extendsOrImplementsKeyword.tokenKind === 48 /* ExtendsKeyword */) { + if (seenExtendsClause) { + this.pushDiagnostic1(heritageClauseFullStart, heritageClause, TypeScript.DiagnosticCode.extends_clause_already_seen); + return true; + } + + seenExtendsClause = true; + } else { + TypeScript.Debug.assert(heritageClause.extendsOrImplementsKeyword.tokenKind === 51 /* ImplementsKeyword */); + this.pushDiagnostic1(heritageClauseFullStart, heritageClause, TypeScript.DiagnosticCode.Interface_declaration_cannot_have_implements_clause); + return true; + } + + heritageClauseFullStart += heritageClause.fullWidth(); + } + + return false; + }; + + GrammarCheckerWalker.prototype.checkInterfaceModifiers = function (modifiers) { + var modifierFullStart = this.position(); + + for (var i = 0, n = modifiers.childCount(); i < n; i++) { + var modifier = modifiers.childAt(i); + if (modifier.tokenKind === 63 /* DeclareKeyword */) { + this.pushDiagnostic1(modifierFullStart, modifier, TypeScript.DiagnosticCode.declare_modifier_cannot_appear_on_an_interface_declaration); + return true; + } + + modifierFullStart += modifier.fullWidth(); + } + + return false; + }; + + GrammarCheckerWalker.prototype.visitInterfaceDeclaration = function (node) { + if (this.checkForReservedName(node, node.identifier, TypeScript.DiagnosticCode.Interface_name_cannot_be_0) || this.checkInterfaceModifiers(node.modifiers) || this.checkModuleElementModifiers(node.modifiers) || this.checkInterfaceDeclarationHeritageClauses(node)) { + this.skip(node); + return; + } + + _super.prototype.visitInterfaceDeclaration.call(this, node); + }; + + GrammarCheckerWalker.prototype.checkClassElementModifiers = function (list) { + var modifierFullStart = this.position(); + + var seenAccessibilityModifier = false; + var seenStaticModifier = false; + + for (var i = 0, n = list.childCount(); i < n; i++) { + var modifier = list.childAt(i); + if (modifier.tokenKind === 57 /* PublicKeyword */ || modifier.tokenKind === 55 /* PrivateKeyword */) { + if (seenAccessibilityModifier) { + this.pushDiagnostic1(modifierFullStart, modifier, TypeScript.DiagnosticCode.Accessibility_modifier_already_seen); + return true; + } + + if (seenStaticModifier) { + var previousToken = list.childAt(i - 1); + this.pushDiagnostic1(modifierFullStart, modifier, TypeScript.DiagnosticCode._0_modifier_must_precede_1_modifier, [modifier.text(), previousToken.text()]); + return true; + } + + seenAccessibilityModifier = true; + } else if (modifier.tokenKind === 58 /* StaticKeyword */) { + if (seenStaticModifier) { + this.pushDiagnostic1(modifierFullStart, modifier, TypeScript.DiagnosticCode._0_modifier_already_seen, [modifier.text()]); + return true; + } + + seenStaticModifier = true; + } else { + this.pushDiagnostic1(modifierFullStart, modifier, TypeScript.DiagnosticCode._0_modifier_cannot_appear_on_a_class_element, [modifier.text()]); + return true; + } + + modifierFullStart += modifier.fullWidth(); + } + + return false; + }; + + GrammarCheckerWalker.prototype.visitMemberVariableDeclaration = function (node) { + if (this.checkClassElementModifiers(node.modifiers)) { + this.skip(node); + return; + } + + _super.prototype.visitMemberVariableDeclaration.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitMemberFunctionDeclaration = function (node) { + if (this.checkClassElementModifiers(node.modifiers)) { + this.skip(node); + return; + } + + _super.prototype.visitMemberFunctionDeclaration.call(this, node); + }; + + GrammarCheckerWalker.prototype.checkGetMemberAccessorParameter = function (node) { + var getKeywordFullStart = this.childFullStart(node, node.getKeyword); + if (node.parameterList.parameters.childCount() !== 0) { + this.pushDiagnostic1(getKeywordFullStart, node.getKeyword, TypeScript.DiagnosticCode.get_accessor_cannot_have_parameters); + return true; + } + + return false; + }; + + GrammarCheckerWalker.prototype.checkEcmaScriptVersionIsAtLeast = function (parent, node, languageVersion, diagnosticKey) { + if (this.syntaxTree.parseOptions().languageVersion() < languageVersion) { + var nodeFullStart = this.childFullStart(parent, node); + this.pushDiagnostic1(nodeFullStart, node, diagnosticKey); + return true; + } + + return false; + }; + + GrammarCheckerWalker.prototype.visitGetMemberAccessorDeclaration = function (node) { + if (this.checkEcmaScriptVersionIsAtLeast(node, node.getKeyword, 1 /* EcmaScript5 */, TypeScript.DiagnosticCode.Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher) || this.checkClassElementModifiers(node.modifiers) || this.checkGetMemberAccessorParameter(node)) { + this.skip(node); + return; + } + + _super.prototype.visitGetMemberAccessorDeclaration.call(this, node); + }; + + GrammarCheckerWalker.prototype.checkSetMemberAccessorParameter = function (node) { + var setKeywordFullStart = this.childFullStart(node, node.setKeyword); + if (node.parameterList.parameters.childCount() !== 1) { + this.pushDiagnostic1(setKeywordFullStart, node.setKeyword, TypeScript.DiagnosticCode.set_accessor_must_have_one_and_only_one_parameter); + return true; + } + + var parameterListFullStart = this.childFullStart(node, node.parameterList); + var parameterFullStart = parameterListFullStart + TypeScript.Syntax.childOffset(node.parameterList, node.parameterList.openParenToken); + var parameter = node.parameterList.parameters.childAt(0); + + if (parameter.publicOrPrivateKeyword) { + this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.set_accessor_parameter_cannot_have_accessibility_modifier); + return true; + } + + if (parameter.questionToken) { + this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.set_accessor_parameter_cannot_be_optional); + return true; + } + + if (parameter.equalsValueClause) { + this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.set_accessor_parameter_cannot_have_an_initializer); + return true; + } + + if (parameter.dotDotDotToken) { + this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.set_accessor_cannot_have_rest_parameter); + return true; + } + + return false; + }; + + GrammarCheckerWalker.prototype.visitSetMemberAccessorDeclaration = function (node) { + if (this.checkEcmaScriptVersionIsAtLeast(node, node.setKeyword, 1 /* EcmaScript5 */, TypeScript.DiagnosticCode.Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher) || this.checkClassElementModifiers(node.modifiers) || this.checkSetMemberAccessorParameter(node)) { + this.skip(node); + return; + } + + _super.prototype.visitSetMemberAccessorDeclaration.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitGetAccessorPropertyAssignment = function (node) { + if (this.checkEcmaScriptVersionIsAtLeast(node, node.getKeyword, 1 /* EcmaScript5 */, TypeScript.DiagnosticCode.Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher)) { + this.skip(node); + return; + } + + _super.prototype.visitGetAccessorPropertyAssignment.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitSetAccessorPropertyAssignment = function (node) { + if (this.checkEcmaScriptVersionIsAtLeast(node, node.setKeyword, 1 /* EcmaScript5 */, TypeScript.DiagnosticCode.Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher)) { + this.skip(node); + return; + } + + _super.prototype.visitSetAccessorPropertyAssignment.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitEnumDeclaration = function (node) { + if (this.checkForReservedName(node, node.identifier, TypeScript.DiagnosticCode.Enum_name_cannot_be_0) || this.checkForDisallowedDeclareModifier(node.modifiers) || this.checkForRequiredDeclareModifier(node, node.enumKeyword, node.modifiers) || this.checkModuleElementModifiers(node.modifiers), this.checkEnumElements(node)) { + this.skip(node); + return; + } + + var savedInAmbientDeclaration = this.inAmbientDeclaration; + this.inAmbientDeclaration = this.inAmbientDeclaration || this.syntaxTree.isDeclaration() || TypeScript.SyntaxUtilities.containsToken(node.modifiers, 63 /* DeclareKeyword */); + _super.prototype.visitEnumDeclaration.call(this, node); + this.inAmbientDeclaration = savedInAmbientDeclaration; + }; + + GrammarCheckerWalker.prototype.checkEnumElements = function (node) { + var enumElementFullStart = this.childFullStart(node, node.enumElements); + + var seenComputedValue = false; + for (var i = 0, n = node.enumElements.childCount(); i < n; i++) { + var child = node.enumElements.childAt(i); + + if (i % 2 === 0) { + var enumElement = child; + + if (!enumElement.equalsValueClause && seenComputedValue) { + this.pushDiagnostic1(enumElementFullStart, enumElement, TypeScript.DiagnosticCode.Enum_member_must_have_initializer, null); + return true; + } + + if (enumElement.equalsValueClause) { + var value = enumElement.equalsValueClause.value; + if (!TypeScript.Syntax.isIntegerLiteral(value)) { + seenComputedValue = true; + } + } + } + + enumElementFullStart += child.fullWidth(); + } + + return false; + }; + + GrammarCheckerWalker.prototype.visitEnumElement = function (node) { + if (this.inAmbientDeclaration && node.equalsValueClause) { + var expression = node.equalsValueClause.value; + if (!TypeScript.Syntax.isIntegerLiteral(expression)) { + this.pushDiagnostic1(this.childFullStart(node, node.equalsValueClause), node.equalsValueClause.firstToken(), TypeScript.DiagnosticCode.Ambient_enum_elements_can_only_have_integer_literal_initializers); + this.skip(node); + return; + } + } + + _super.prototype.visitEnumElement.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitInvocationExpression = function (node) { + if (node.expression.kind() === 50 /* SuperKeyword */ && node.argumentList.typeArgumentList !== null) { + this.pushDiagnostic1(this.position(), node, TypeScript.DiagnosticCode.super_invocation_cannot_have_type_arguments); + } + + _super.prototype.visitInvocationExpression.call(this, node); + }; + + GrammarCheckerWalker.prototype.checkModuleElementModifiers = function (modifiers) { + var modifierFullStart = this.position(); + var seenExportModifier = false; + var seenDeclareModifier = false; + + for (var i = 0, n = modifiers.childCount(); i < n; i++) { + var modifier = modifiers.childAt(i); + if (modifier.tokenKind === 57 /* PublicKeyword */ || modifier.tokenKind === 55 /* PrivateKeyword */ || modifier.tokenKind === 58 /* StaticKeyword */) { + this.pushDiagnostic1(modifierFullStart, modifier, TypeScript.DiagnosticCode._0_modifier_cannot_appear_on_a_module_element, [modifier.text()]); + return true; + } + + if (modifier.tokenKind === 63 /* DeclareKeyword */) { + if (seenDeclareModifier) { + this.pushDiagnostic1(modifierFullStart, modifier, TypeScript.DiagnosticCode.Accessibility_modifier_already_seen); + return; + } + + seenDeclareModifier = true; + } else if (modifier.tokenKind === 47 /* ExportKeyword */) { + if (seenExportModifier) { + this.pushDiagnostic1(modifierFullStart, modifier, TypeScript.DiagnosticCode._0_modifier_already_seen, [modifier.text()]); + return; + } + + if (seenDeclareModifier) { + this.pushDiagnostic1(modifierFullStart, modifier, TypeScript.DiagnosticCode._0_modifier_must_precede_1_modifier, [TypeScript.SyntaxFacts.getText(47 /* ExportKeyword */), TypeScript.SyntaxFacts.getText(63 /* DeclareKeyword */)]); + return; + } + + seenExportModifier = true; + } + + modifierFullStart += modifier.fullWidth(); + } + + return false; + }; + + GrammarCheckerWalker.prototype.checkForDisallowedImportDeclaration = function (node) { + if (node.stringLiteral === null) { + var currentElementFullStart = this.childFullStart(node, node.moduleElements); + + for (var i = 0, n = node.moduleElements.childCount(); i < n; i++) { + var child = node.moduleElements.childAt(i); + if (child.kind() === 133 /* ImportDeclaration */) { + var importDeclaration = child; + if (importDeclaration.moduleReference.kind() === 245 /* ExternalModuleReference */) { + this.pushDiagnostic1(currentElementFullStart, importDeclaration, TypeScript.DiagnosticCode.Import_declarations_in_an_internal_module_cannot_reference_an_external_module, null); + } + } + + currentElementFullStart += child.fullWidth(); + } + } + + return false; + }; + + GrammarCheckerWalker.prototype.checkForDisallowedDeclareModifierOnImportDeclaration = function (modifiers) { + var declareToken = TypeScript.SyntaxUtilities.getToken(modifiers, 63 /* DeclareKeyword */); + + if (declareToken) { + this.pushDiagnostic1(this.childFullStart(modifiers, declareToken), declareToken, TypeScript.DiagnosticCode.declare_modifier_not_allowed_on_import_declaration); + return true; + } + }; + + GrammarCheckerWalker.prototype.visitImportDeclaration = function (node) { + if (this.checkForDisallowedDeclareModifierOnImportDeclaration(node.modifiers) || this.checkModuleElementModifiers(node.modifiers)) { + this.skip(node); + return; + } + + _super.prototype.visitImportDeclaration.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitModuleDeclaration = function (node) { + if (this.checkForReservedName(node, node.moduleName, TypeScript.DiagnosticCode.Module_name_cannot_be_0) || this.checkForDisallowedDeclareModifier(node.modifiers) || this.checkForRequiredDeclareModifier(node, node.moduleKeyword, node.modifiers) || this.checkModuleElementModifiers(node.modifiers) || this.checkForDisallowedImportDeclaration(node) || this.checkForDisallowedExports(node, node.moduleElements) || this.checkForMultipleExportAssignments(node, node.moduleElements)) { + this.skip(node); + return; + } + + if (!TypeScript.SyntaxUtilities.containsToken(node.modifiers, 63 /* DeclareKeyword */) && this.checkFunctionOverloads(node, node.moduleElements)) { + this.skip(node); + return; + } + + if (node.stringLiteral) { + if (!this.inAmbientDeclaration && !TypeScript.SyntaxUtilities.containsToken(node.modifiers, 63 /* DeclareKeyword */)) { + var stringLiteralFullStart = this.childFullStart(node, node.stringLiteral); + this.pushDiagnostic1(stringLiteralFullStart, node.stringLiteral, TypeScript.DiagnosticCode.Only_ambient_modules_can_use_quoted_names); + this.skip(node); + return; + } + } + + if (!node.stringLiteral && this.checkForDisallowedExportAssignment(node)) { + this.skip(node); + return; + } + + var savedInAmbientDeclaration = this.inAmbientDeclaration; + this.inAmbientDeclaration = this.inAmbientDeclaration || this.syntaxTree.isDeclaration() || TypeScript.SyntaxUtilities.containsToken(node.modifiers, 63 /* DeclareKeyword */); + _super.prototype.visitModuleDeclaration.call(this, node); + this.inAmbientDeclaration = savedInAmbientDeclaration; + }; + + GrammarCheckerWalker.prototype.checkForDisallowedExports = function (node, moduleElements) { + var seenExportedElement = false; + for (var i = 0, n = moduleElements.childCount(); i < n; i++) { + var child = moduleElements.childAt(i); + + if (TypeScript.SyntaxUtilities.hasExportKeyword(child)) { + seenExportedElement = true; + break; + } + } + + var moduleElementFullStart = this.childFullStart(node, moduleElements); + if (seenExportedElement) { + for (var i = 0, n = moduleElements.childCount(); i < n; i++) { + var child = moduleElements.childAt(i); + + if (child.kind() === 134 /* ExportAssignment */) { + this.pushDiagnostic1(moduleElementFullStart, child, TypeScript.DiagnosticCode.Export_assignment_not_allowed_in_module_with_exported_element); + return true; + } + + moduleElementFullStart += child.fullWidth(); + } + } + + return false; + }; + + GrammarCheckerWalker.prototype.checkForMultipleExportAssignments = function (node, moduleElements) { + var moduleElementFullStart = this.childFullStart(node, moduleElements); + var seenExportAssignment = false; + var errorFound = false; + for (var i = 0, n = moduleElements.childCount(); i < n; i++) { + var child = moduleElements.childAt(i); + if (child.kind() === 134 /* ExportAssignment */) { + if (seenExportAssignment) { + this.pushDiagnostic1(moduleElementFullStart, child, TypeScript.DiagnosticCode.Module_cannot_have_multiple_export_assignments); + errorFound = true; + } + seenExportAssignment = true; + } + + moduleElementFullStart += child.fullWidth(); + } + + return errorFound; + }; + + GrammarCheckerWalker.prototype.checkForDisallowedExportAssignment = function (node) { + var moduleElementFullStart = this.childFullStart(node, node.moduleElements); + + for (var i = 0, n = node.moduleElements.childCount(); i < n; i++) { + var child = node.moduleElements.childAt(i); + + if (child.kind() === 134 /* ExportAssignment */) { + this.pushDiagnostic1(moduleElementFullStart, child, TypeScript.DiagnosticCode.Export_assignment_cannot_be_used_in_internal_modules); + + return true; + } + + moduleElementFullStart += child.fullWidth(); + } + + return false; + }; + + GrammarCheckerWalker.prototype.visitBlock = function (node) { + if (this.inAmbientDeclaration || this.syntaxTree.isDeclaration()) { + this.pushDiagnostic1(this.position(), node.firstToken(), TypeScript.DiagnosticCode.Implementations_are_not_allowed_in_ambient_contexts); + this.skip(node); + return; + } + + if (this.checkFunctionOverloads(node, node.statements)) { + this.skip(node); + return; + } + + var savedInBlock = this.inBlock; + this.inBlock = true; + _super.prototype.visitBlock.call(this, node); + this.inBlock = savedInBlock; + }; + + GrammarCheckerWalker.prototype.checkForStatementInAmbientContxt = function (node) { + if (this.inAmbientDeclaration || this.syntaxTree.isDeclaration()) { + this.pushDiagnostic1(this.position(), node.firstToken(), TypeScript.DiagnosticCode.Statements_are_not_allowed_in_ambient_contexts); + return true; + } + + return false; + }; + + GrammarCheckerWalker.prototype.visitBreakStatement = function (node) { + if (this.checkForStatementInAmbientContxt(node)) { + this.skip(node); + return; + } + + _super.prototype.visitBreakStatement.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitContinueStatement = function (node) { + if (this.checkForStatementInAmbientContxt(node)) { + this.skip(node); + return; + } + + _super.prototype.visitContinueStatement.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitDebuggerStatement = function (node) { + if (this.checkForStatementInAmbientContxt(node)) { + this.skip(node); + return; + } + + _super.prototype.visitDebuggerStatement.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitDoStatement = function (node) { + if (this.checkForStatementInAmbientContxt(node)) { + this.skip(node); + return; + } + + _super.prototype.visitDoStatement.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitEmptyStatement = function (node) { + if (this.checkForStatementInAmbientContxt(node)) { + this.skip(node); + return; + } + + _super.prototype.visitEmptyStatement.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitExpressionStatement = function (node) { + if (this.checkForStatementInAmbientContxt(node)) { + this.skip(node); + return; + } + + _super.prototype.visitExpressionStatement.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitForInStatement = function (node) { + if (this.checkForStatementInAmbientContxt(node)) { + this.skip(node); + return; + } + + _super.prototype.visitForInStatement.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitForStatement = function (node) { + if (this.checkForStatementInAmbientContxt(node)) { + this.skip(node); + return; + } + + _super.prototype.visitForStatement.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitIfStatement = function (node) { + if (this.checkForStatementInAmbientContxt(node)) { + this.skip(node); + return; + } + + _super.prototype.visitIfStatement.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitLabeledStatement = function (node) { + if (this.checkForStatementInAmbientContxt(node)) { + this.skip(node); + return; + } + + _super.prototype.visitLabeledStatement.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitReturnStatement = function (node) { + if (this.checkForStatementInAmbientContxt(node)) { + this.skip(node); + return; + } + + _super.prototype.visitReturnStatement.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitSwitchStatement = function (node) { + if (this.checkForStatementInAmbientContxt(node)) { + this.skip(node); + return; + } + + _super.prototype.visitSwitchStatement.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitThrowStatement = function (node) { + if (this.checkForStatementInAmbientContxt(node)) { + this.skip(node); + return; + } + + _super.prototype.visitThrowStatement.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitTryStatement = function (node) { + if (this.checkForStatementInAmbientContxt(node)) { + this.skip(node); + return; + } + + _super.prototype.visitTryStatement.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitWhileStatement = function (node) { + if (this.checkForStatementInAmbientContxt(node)) { + this.skip(node); + return; + } + + _super.prototype.visitWhileStatement.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitWithStatement = function (node) { + if (this.checkForStatementInAmbientContxt(node)) { + this.skip(node); + return; + } + + _super.prototype.visitWithStatement.call(this, node); + }; + + GrammarCheckerWalker.prototype.checkForDisallowedModifiers = function (parent, modifiers) { + if (this.inBlock && modifiers.childCount() > 0) { + var modifierFullStart = this.childFullStart(parent, modifiers); + this.pushDiagnostic1(modifierFullStart, modifiers.childAt(0), TypeScript.DiagnosticCode.Modifiers_cannot_appear_here); + return true; + } + + return false; + }; + + GrammarCheckerWalker.prototype.visitFunctionDeclaration = function (node) { + if (this.checkForDisallowedDeclareModifier(node.modifiers) || this.checkForDisallowedModifiers(node, node.modifiers) || this.checkForRequiredDeclareModifier(node, node.functionKeyword, node.modifiers) || this.checkModuleElementModifiers(node.modifiers)) { + this.skip(node); + return; + } + + var savedInAmbientDeclaration = this.inAmbientDeclaration; + this.inAmbientDeclaration = this.inAmbientDeclaration || this.syntaxTree.isDeclaration() || TypeScript.SyntaxUtilities.containsToken(node.modifiers, 63 /* DeclareKeyword */); + _super.prototype.visitFunctionDeclaration.call(this, node); + this.inAmbientDeclaration = savedInAmbientDeclaration; + }; + + GrammarCheckerWalker.prototype.visitVariableStatement = function (node) { + if (this.checkForDisallowedDeclareModifier(node.modifiers) || this.checkForDisallowedModifiers(node, node.modifiers) || this.checkForRequiredDeclareModifier(node, node.variableDeclaration, node.modifiers) || this.checkModuleElementModifiers(node.modifiers)) { + this.skip(node); + return; + } + + var savedInAmbientDeclaration = this.inAmbientDeclaration; + this.inAmbientDeclaration = this.inAmbientDeclaration || this.syntaxTree.isDeclaration() || TypeScript.SyntaxUtilities.containsToken(node.modifiers, 63 /* DeclareKeyword */); + _super.prototype.visitVariableStatement.call(this, node); + this.inAmbientDeclaration = savedInAmbientDeclaration; + }; + + GrammarCheckerWalker.prototype.checkListSeparators = function (parent, list, kind) { + var currentElementFullStart = this.childFullStart(parent, list); + + for (var i = 0, n = list.childCount(); i < n; i++) { + var child = list.childAt(i); + if (i % 2 === 1 && child.kind() !== kind) { + this.pushDiagnostic1(currentElementFullStart, child, TypeScript.DiagnosticCode._0_expected, [TypeScript.SyntaxFacts.getText(kind)]); + } + + currentElementFullStart += child.fullWidth(); + } + + return false; + }; + + GrammarCheckerWalker.prototype.visitObjectType = function (node) { + if (this.checkListSeparators(node, node.typeMembers, 78 /* SemicolonToken */)) { + this.skip(node); + return; + } + + var savedInAmbientDeclaration = this.inAmbientDeclaration; + this.inAmbientDeclaration = true; + _super.prototype.visitObjectType.call(this, node); + this.inAmbientDeclaration = savedInAmbientDeclaration; + }; + + GrammarCheckerWalker.prototype.visitArrayType = function (node) { + var savedInAmbientDeclaration = this.inAmbientDeclaration; + this.inAmbientDeclaration = true; + _super.prototype.visitArrayType.call(this, node); + this.inAmbientDeclaration = savedInAmbientDeclaration; + }; + + GrammarCheckerWalker.prototype.visitFunctionType = function (node) { + var savedInAmbientDeclaration = this.inAmbientDeclaration; + this.inAmbientDeclaration = true; + _super.prototype.visitFunctionType.call(this, node); + this.inAmbientDeclaration = savedInAmbientDeclaration; + }; + + GrammarCheckerWalker.prototype.visitConstructorType = function (node) { + var savedInAmbientDeclaration = this.inAmbientDeclaration; + this.inAmbientDeclaration = true; + _super.prototype.visitConstructorType.call(this, node); + this.inAmbientDeclaration = savedInAmbientDeclaration; + }; + + GrammarCheckerWalker.prototype.visitVariableDeclarator = function (node) { + if (this.inAmbientDeclaration && node.equalsValueClause) { + this.pushDiagnostic1(this.childFullStart(node, node.equalsValueClause), node.equalsValueClause.firstToken(), TypeScript.DiagnosticCode.Initializers_are_not_allowed_in_ambient_contexts); + this.skip(node); + return; + } + + _super.prototype.visitVariableDeclarator.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitConstructorDeclaration = function (node) { + var savedCurrentConstructor = this.currentConstructor; + this.currentConstructor = node; + _super.prototype.visitConstructorDeclaration.call(this, node); + this.currentConstructor = savedCurrentConstructor; + }; + + GrammarCheckerWalker.prototype.visitSourceUnit = function (node) { + if (this.checkFunctionOverloads(node, node.moduleElements) || this.checkForDisallowedExports(node, node.moduleElements) || this.checkForMultipleExportAssignments(node, node.moduleElements)) { + this.skip(node); + return; + } + + _super.prototype.visitSourceUnit.call(this, node); + }; + return GrammarCheckerWalker; + })(TypeScript.PositionTrackingWalker); +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var TextSpanWalker = (function (_super) { + __extends(TextSpanWalker, _super); + function TextSpanWalker(textSpan) { + _super.call(this); + this.textSpan = textSpan; + this._position = 0; + } + TextSpanWalker.prototype.visitToken = function (token) { + this._position += token.fullWidth(); + }; + + TextSpanWalker.prototype.visitNode = function (node) { + var nodeSpan = new TypeScript.TextSpan(this.position(), node.fullWidth()); + + if (nodeSpan.intersectsWithTextSpan(this.textSpan)) { + node.accept(this); + } else { + this._position += node.fullWidth(); + } + }; + + TextSpanWalker.prototype.position = function () { + return this._position; + }; + return TextSpanWalker; + })(TypeScript.SyntaxWalker); +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var Unicode = (function () { + function Unicode() { + } + Unicode.lookupInUnicodeMap = function (code, map) { + if (code < map[0]) { + return false; + } + + var lo = 0; + var hi = map.length; + var mid; + + while (lo + 1 < hi) { + mid = lo + (hi - lo) / 2; + + mid -= mid % 2; + if (map[mid] <= code && code <= map[mid + 1]) { + return true; + } + + if (code < map[mid]) { + hi = mid; + } else { + lo = mid + 2; + } + } + + return false; + }; + + Unicode.isIdentifierStart = function (code, languageVersion) { + if (languageVersion === 0 /* EcmaScript3 */) { + return Unicode.lookupInUnicodeMap(code, Unicode.unicodeES3IdentifierStart); + } else if (languageVersion === 1 /* EcmaScript5 */) { + return Unicode.lookupInUnicodeMap(code, Unicode.unicodeES5IdentifierStart); + } else { + throw TypeScript.Errors.argumentOutOfRange("languageVersion"); + } + }; + + Unicode.isIdentifierPart = function (code, languageVersion) { + if (languageVersion === 0 /* EcmaScript3 */) { + return Unicode.lookupInUnicodeMap(code, Unicode.unicodeES3IdentifierPart); + } else if (languageVersion === 1 /* EcmaScript5 */) { + return Unicode.lookupInUnicodeMap(code, Unicode.unicodeES5IdentifierPart); + } else { + throw TypeScript.Errors.argumentOutOfRange("languageVersion"); + } + }; + Unicode.unicodeES3IdentifierStart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 543, 546, 563, 592, 685, 688, 696, 699, 705, 720, 721, 736, 740, 750, 750, 890, 890, 902, 902, 904, 906, 908, 908, 910, 929, 931, 974, 976, 983, 986, 1011, 1024, 1153, 1164, 1220, 1223, 1224, 1227, 1228, 1232, 1269, 1272, 1273, 1329, 1366, 1369, 1369, 1377, 1415, 1488, 1514, 1520, 1522, 1569, 1594, 1600, 1610, 1649, 1747, 1749, 1749, 1765, 1766, 1786, 1788, 1808, 1808, 1810, 1836, 1920, 1957, 2309, 2361, 2365, 2365, 2384, 2384, 2392, 2401, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2524, 2525, 2527, 2529, 2544, 2545, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2649, 2652, 2654, 2654, 2674, 2676, 2693, 2699, 2701, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2749, 2749, 2768, 2768, 2784, 2784, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2870, 2873, 2877, 2877, 2908, 2909, 2911, 2913, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 2997, 2999, 3001, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3168, 3169, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3294, 3294, 3296, 3297, 3333, 3340, 3342, 3344, 3346, 3368, 3370, 3385, 3424, 3425, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3585, 3632, 3634, 3635, 3648, 3654, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3760, 3762, 3763, 3773, 3773, 3776, 3780, 3782, 3782, 3804, 3805, 3840, 3840, 3904, 3911, 3913, 3946, 3976, 3979, 4096, 4129, 4131, 4135, 4137, 4138, 4176, 4181, 4256, 4293, 4304, 4342, 4352, 4441, 4447, 4514, 4520, 4601, 4608, 4614, 4616, 4678, 4680, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4742, 4744, 4744, 4746, 4749, 4752, 4782, 4784, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4814, 4816, 4822, 4824, 4846, 4848, 4878, 4880, 4880, 4882, 4885, 4888, 4894, 4896, 4934, 4936, 4954, 5024, 5108, 5121, 5740, 5743, 5750, 5761, 5786, 5792, 5866, 6016, 6067, 6176, 6263, 6272, 6312, 7680, 7835, 7840, 7929, 7936, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8319, 8319, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8497, 8499, 8505, 8544, 8579, 12293, 12295, 12321, 12329, 12337, 12341, 12344, 12346, 12353, 12436, 12445, 12446, 12449, 12538, 12540, 12542, 12549, 12588, 12593, 12686, 12704, 12727, 13312, 19893, 19968, 40869, 40960, 42124, 44032, 55203, 63744, 64045, 64256, 64262, 64275, 64279, 64285, 64285, 64287, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65136, 65138, 65140, 65140, 65142, 65276, 65313, 65338, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500]; + Unicode.unicodeES3IdentifierPart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 543, 546, 563, 592, 685, 688, 696, 699, 705, 720, 721, 736, 740, 750, 750, 768, 846, 864, 866, 890, 890, 902, 902, 904, 906, 908, 908, 910, 929, 931, 974, 976, 983, 986, 1011, 1024, 1153, 1155, 1158, 1164, 1220, 1223, 1224, 1227, 1228, 1232, 1269, 1272, 1273, 1329, 1366, 1369, 1369, 1377, 1415, 1425, 1441, 1443, 1465, 1467, 1469, 1471, 1471, 1473, 1474, 1476, 1476, 1488, 1514, 1520, 1522, 1569, 1594, 1600, 1621, 1632, 1641, 1648, 1747, 1749, 1756, 1759, 1768, 1770, 1773, 1776, 1788, 1808, 1836, 1840, 1866, 1920, 1968, 2305, 2307, 2309, 2361, 2364, 2381, 2384, 2388, 2392, 2403, 2406, 2415, 2433, 2435, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2492, 2492, 2494, 2500, 2503, 2504, 2507, 2509, 2519, 2519, 2524, 2525, 2527, 2531, 2534, 2545, 2562, 2562, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2620, 2620, 2622, 2626, 2631, 2632, 2635, 2637, 2649, 2652, 2654, 2654, 2662, 2676, 2689, 2691, 2693, 2699, 2701, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2748, 2757, 2759, 2761, 2763, 2765, 2768, 2768, 2784, 2784, 2790, 2799, 2817, 2819, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2870, 2873, 2876, 2883, 2887, 2888, 2891, 2893, 2902, 2903, 2908, 2909, 2911, 2913, 2918, 2927, 2946, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 2997, 2999, 3001, 3006, 3010, 3014, 3016, 3018, 3021, 3031, 3031, 3047, 3055, 3073, 3075, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3134, 3140, 3142, 3144, 3146, 3149, 3157, 3158, 3168, 3169, 3174, 3183, 3202, 3203, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3262, 3268, 3270, 3272, 3274, 3277, 3285, 3286, 3294, 3294, 3296, 3297, 3302, 3311, 3330, 3331, 3333, 3340, 3342, 3344, 3346, 3368, 3370, 3385, 3390, 3395, 3398, 3400, 3402, 3405, 3415, 3415, 3424, 3425, 3430, 3439, 3458, 3459, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3530, 3530, 3535, 3540, 3542, 3542, 3544, 3551, 3570, 3571, 3585, 3642, 3648, 3662, 3664, 3673, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3769, 3771, 3773, 3776, 3780, 3782, 3782, 3784, 3789, 3792, 3801, 3804, 3805, 3840, 3840, 3864, 3865, 3872, 3881, 3893, 3893, 3895, 3895, 3897, 3897, 3902, 3911, 3913, 3946, 3953, 3972, 3974, 3979, 3984, 3991, 3993, 4028, 4038, 4038, 4096, 4129, 4131, 4135, 4137, 4138, 4140, 4146, 4150, 4153, 4160, 4169, 4176, 4185, 4256, 4293, 4304, 4342, 4352, 4441, 4447, 4514, 4520, 4601, 4608, 4614, 4616, 4678, 4680, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4742, 4744, 4744, 4746, 4749, 4752, 4782, 4784, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4814, 4816, 4822, 4824, 4846, 4848, 4878, 4880, 4880, 4882, 4885, 4888, 4894, 4896, 4934, 4936, 4954, 4969, 4977, 5024, 5108, 5121, 5740, 5743, 5750, 5761, 5786, 5792, 5866, 6016, 6099, 6112, 6121, 6160, 6169, 6176, 6263, 6272, 6313, 7680, 7835, 7840, 7929, 7936, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8255, 8256, 8319, 8319, 8400, 8412, 8417, 8417, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8497, 8499, 8505, 8544, 8579, 12293, 12295, 12321, 12335, 12337, 12341, 12344, 12346, 12353, 12436, 12441, 12442, 12445, 12446, 12449, 12542, 12549, 12588, 12593, 12686, 12704, 12727, 13312, 19893, 19968, 40869, 40960, 42124, 44032, 55203, 63744, 64045, 64256, 64262, 64275, 64279, 64285, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65056, 65059, 65075, 65076, 65101, 65103, 65136, 65138, 65140, 65140, 65142, 65276, 65296, 65305, 65313, 65338, 65343, 65343, 65345, 65370, 65381, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500]; + + Unicode.unicodeES5IdentifierStart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 705, 710, 721, 736, 740, 748, 748, 750, 750, 880, 884, 886, 887, 890, 893, 902, 902, 904, 906, 908, 908, 910, 929, 931, 1013, 1015, 1153, 1162, 1319, 1329, 1366, 1369, 1369, 1377, 1415, 1488, 1514, 1520, 1522, 1568, 1610, 1646, 1647, 1649, 1747, 1749, 1749, 1765, 1766, 1774, 1775, 1786, 1788, 1791, 1791, 1808, 1808, 1810, 1839, 1869, 1957, 1969, 1969, 1994, 2026, 2036, 2037, 2042, 2042, 2048, 2069, 2074, 2074, 2084, 2084, 2088, 2088, 2112, 2136, 2208, 2208, 2210, 2220, 2308, 2361, 2365, 2365, 2384, 2384, 2392, 2401, 2417, 2423, 2425, 2431, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2493, 2493, 2510, 2510, 2524, 2525, 2527, 2529, 2544, 2545, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2649, 2652, 2654, 2654, 2674, 2676, 2693, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2749, 2749, 2768, 2768, 2784, 2785, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2869, 2873, 2877, 2877, 2908, 2909, 2911, 2913, 2929, 2929, 2947, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 3001, 3024, 3024, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3133, 3133, 3160, 3161, 3168, 3169, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3261, 3261, 3294, 3294, 3296, 3297, 3313, 3314, 3333, 3340, 3342, 3344, 3346, 3386, 3389, 3389, 3406, 3406, 3424, 3425, 3450, 3455, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3585, 3632, 3634, 3635, 3648, 3654, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3760, 3762, 3763, 3773, 3773, 3776, 3780, 3782, 3782, 3804, 3807, 3840, 3840, 3904, 3911, 3913, 3948, 3976, 3980, 4096, 4138, 4159, 4159, 4176, 4181, 4186, 4189, 4193, 4193, 4197, 4198, 4206, 4208, 4213, 4225, 4238, 4238, 4256, 4293, 4295, 4295, 4301, 4301, 4304, 4346, 4348, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4744, 4746, 4749, 4752, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4822, 4824, 4880, 4882, 4885, 4888, 4954, 4992, 5007, 5024, 5108, 5121, 5740, 5743, 5759, 5761, 5786, 5792, 5866, 5870, 5872, 5888, 5900, 5902, 5905, 5920, 5937, 5952, 5969, 5984, 5996, 5998, 6000, 6016, 6067, 6103, 6103, 6108, 6108, 6176, 6263, 6272, 6312, 6314, 6314, 6320, 6389, 6400, 6428, 6480, 6509, 6512, 6516, 6528, 6571, 6593, 6599, 6656, 6678, 6688, 6740, 6823, 6823, 6917, 6963, 6981, 6987, 7043, 7072, 7086, 7087, 7098, 7141, 7168, 7203, 7245, 7247, 7258, 7293, 7401, 7404, 7406, 7409, 7413, 7414, 7424, 7615, 7680, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8305, 8305, 8319, 8319, 8336, 8348, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8505, 8508, 8511, 8517, 8521, 8526, 8526, 8544, 8584, 11264, 11310, 11312, 11358, 11360, 11492, 11499, 11502, 11506, 11507, 11520, 11557, 11559, 11559, 11565, 11565, 11568, 11623, 11631, 11631, 11648, 11670, 11680, 11686, 11688, 11694, 11696, 11702, 11704, 11710, 11712, 11718, 11720, 11726, 11728, 11734, 11736, 11742, 11823, 11823, 12293, 12295, 12321, 12329, 12337, 12341, 12344, 12348, 12353, 12438, 12445, 12447, 12449, 12538, 12540, 12543, 12549, 12589, 12593, 12686, 12704, 12730, 12784, 12799, 13312, 19893, 19968, 40908, 40960, 42124, 42192, 42237, 42240, 42508, 42512, 42527, 42538, 42539, 42560, 42606, 42623, 42647, 42656, 42735, 42775, 42783, 42786, 42888, 42891, 42894, 42896, 42899, 42912, 42922, 43000, 43009, 43011, 43013, 43015, 43018, 43020, 43042, 43072, 43123, 43138, 43187, 43250, 43255, 43259, 43259, 43274, 43301, 43312, 43334, 43360, 43388, 43396, 43442, 43471, 43471, 43520, 43560, 43584, 43586, 43588, 43595, 43616, 43638, 43642, 43642, 43648, 43695, 43697, 43697, 43701, 43702, 43705, 43709, 43712, 43712, 43714, 43714, 43739, 43741, 43744, 43754, 43762, 43764, 43777, 43782, 43785, 43790, 43793, 43798, 43808, 43814, 43816, 43822, 43968, 44002, 44032, 55203, 55216, 55238, 55243, 55291, 63744, 64109, 64112, 64217, 64256, 64262, 64275, 64279, 64285, 64285, 64287, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65136, 65140, 65142, 65276, 65313, 65338, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500]; + Unicode.unicodeES5IdentifierPart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 705, 710, 721, 736, 740, 748, 748, 750, 750, 768, 884, 886, 887, 890, 893, 902, 902, 904, 906, 908, 908, 910, 929, 931, 1013, 1015, 1153, 1155, 1159, 1162, 1319, 1329, 1366, 1369, 1369, 1377, 1415, 1425, 1469, 1471, 1471, 1473, 1474, 1476, 1477, 1479, 1479, 1488, 1514, 1520, 1522, 1552, 1562, 1568, 1641, 1646, 1747, 1749, 1756, 1759, 1768, 1770, 1788, 1791, 1791, 1808, 1866, 1869, 1969, 1984, 2037, 2042, 2042, 2048, 2093, 2112, 2139, 2208, 2208, 2210, 2220, 2276, 2302, 2304, 2403, 2406, 2415, 2417, 2423, 2425, 2431, 2433, 2435, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2492, 2500, 2503, 2504, 2507, 2510, 2519, 2519, 2524, 2525, 2527, 2531, 2534, 2545, 2561, 2563, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2620, 2620, 2622, 2626, 2631, 2632, 2635, 2637, 2641, 2641, 2649, 2652, 2654, 2654, 2662, 2677, 2689, 2691, 2693, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2748, 2757, 2759, 2761, 2763, 2765, 2768, 2768, 2784, 2787, 2790, 2799, 2817, 2819, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2869, 2873, 2876, 2884, 2887, 2888, 2891, 2893, 2902, 2903, 2908, 2909, 2911, 2915, 2918, 2927, 2929, 2929, 2946, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 3001, 3006, 3010, 3014, 3016, 3018, 3021, 3024, 3024, 3031, 3031, 3046, 3055, 3073, 3075, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3133, 3140, 3142, 3144, 3146, 3149, 3157, 3158, 3160, 3161, 3168, 3171, 3174, 3183, 3202, 3203, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3260, 3268, 3270, 3272, 3274, 3277, 3285, 3286, 3294, 3294, 3296, 3299, 3302, 3311, 3313, 3314, 3330, 3331, 3333, 3340, 3342, 3344, 3346, 3386, 3389, 3396, 3398, 3400, 3402, 3406, 3415, 3415, 3424, 3427, 3430, 3439, 3450, 3455, 3458, 3459, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3530, 3530, 3535, 3540, 3542, 3542, 3544, 3551, 3570, 3571, 3585, 3642, 3648, 3662, 3664, 3673, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3769, 3771, 3773, 3776, 3780, 3782, 3782, 3784, 3789, 3792, 3801, 3804, 3807, 3840, 3840, 3864, 3865, 3872, 3881, 3893, 3893, 3895, 3895, 3897, 3897, 3902, 3911, 3913, 3948, 3953, 3972, 3974, 3991, 3993, 4028, 4038, 4038, 4096, 4169, 4176, 4253, 4256, 4293, 4295, 4295, 4301, 4301, 4304, 4346, 4348, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4744, 4746, 4749, 4752, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4822, 4824, 4880, 4882, 4885, 4888, 4954, 4957, 4959, 4992, 5007, 5024, 5108, 5121, 5740, 5743, 5759, 5761, 5786, 5792, 5866, 5870, 5872, 5888, 5900, 5902, 5908, 5920, 5940, 5952, 5971, 5984, 5996, 5998, 6000, 6002, 6003, 6016, 6099, 6103, 6103, 6108, 6109, 6112, 6121, 6155, 6157, 6160, 6169, 6176, 6263, 6272, 6314, 6320, 6389, 6400, 6428, 6432, 6443, 6448, 6459, 6470, 6509, 6512, 6516, 6528, 6571, 6576, 6601, 6608, 6617, 6656, 6683, 6688, 6750, 6752, 6780, 6783, 6793, 6800, 6809, 6823, 6823, 6912, 6987, 6992, 7001, 7019, 7027, 7040, 7155, 7168, 7223, 7232, 7241, 7245, 7293, 7376, 7378, 7380, 7414, 7424, 7654, 7676, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8204, 8205, 8255, 8256, 8276, 8276, 8305, 8305, 8319, 8319, 8336, 8348, 8400, 8412, 8417, 8417, 8421, 8432, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8505, 8508, 8511, 8517, 8521, 8526, 8526, 8544, 8584, 11264, 11310, 11312, 11358, 11360, 11492, 11499, 11507, 11520, 11557, 11559, 11559, 11565, 11565, 11568, 11623, 11631, 11631, 11647, 11670, 11680, 11686, 11688, 11694, 11696, 11702, 11704, 11710, 11712, 11718, 11720, 11726, 11728, 11734, 11736, 11742, 11744, 11775, 11823, 11823, 12293, 12295, 12321, 12335, 12337, 12341, 12344, 12348, 12353, 12438, 12441, 12442, 12445, 12447, 12449, 12538, 12540, 12543, 12549, 12589, 12593, 12686, 12704, 12730, 12784, 12799, 13312, 19893, 19968, 40908, 40960, 42124, 42192, 42237, 42240, 42508, 42512, 42539, 42560, 42607, 42612, 42621, 42623, 42647, 42655, 42737, 42775, 42783, 42786, 42888, 42891, 42894, 42896, 42899, 42912, 42922, 43000, 43047, 43072, 43123, 43136, 43204, 43216, 43225, 43232, 43255, 43259, 43259, 43264, 43309, 43312, 43347, 43360, 43388, 43392, 43456, 43471, 43481, 43520, 43574, 43584, 43597, 43600, 43609, 43616, 43638, 43642, 43643, 43648, 43714, 43739, 43741, 43744, 43759, 43762, 43766, 43777, 43782, 43785, 43790, 43793, 43798, 43808, 43814, 43816, 43822, 43968, 44010, 44012, 44013, 44016, 44025, 44032, 55203, 55216, 55238, 55243, 55291, 63744, 64109, 64112, 64217, 64256, 64262, 64275, 64279, 64285, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65024, 65039, 65056, 65062, 65075, 65076, 65101, 65103, 65136, 65140, 65142, 65276, 65296, 65305, 65313, 65338, 65343, 65343, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500]; + return Unicode; + })(); + TypeScript.Unicode = Unicode; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (CompilerDiagnostics) { + CompilerDiagnostics.debug = false; + + CompilerDiagnostics.diagnosticWriter = null; + + CompilerDiagnostics.analysisPass = 0; + + function Alert(output) { + if (CompilerDiagnostics.diagnosticWriter) { + CompilerDiagnostics.diagnosticWriter.Alert(output); + } + } + CompilerDiagnostics.Alert = Alert; + + function debugPrint(s) { + if (CompilerDiagnostics.debug) { + Alert(s); + } + } + CompilerDiagnostics.debugPrint = debugPrint; + + function assert(condition, s) { + if (CompilerDiagnostics.debug) { + if (!condition) { + Alert(s); + } + } + } + CompilerDiagnostics.assert = assert; + })(TypeScript.CompilerDiagnostics || (TypeScript.CompilerDiagnostics = {})); + var CompilerDiagnostics = TypeScript.CompilerDiagnostics; + + var NullLogger = (function () { + function NullLogger() { + } + NullLogger.prototype.information = function () { + return false; + }; + NullLogger.prototype.debug = function () { + return false; + }; + NullLogger.prototype.warning = function () { + return false; + }; + NullLogger.prototype.error = function () { + return false; + }; + NullLogger.prototype.fatal = function () { + return false; + }; + NullLogger.prototype.log = function (s) { + }; + return NullLogger; + })(); + TypeScript.NullLogger = NullLogger; + + function timeFunction(logger, funcDescription, func) { + var start = (new Date()).getTime(); + var result = func(); + var end = (new Date()).getTime(); + logger.log(funcDescription + " completed in " + (end - start) + " msec"); + return result; + } + TypeScript.timeFunction = timeFunction; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + function hasFlag(val, flag) { + return (val & flag) !== 0; + } + TypeScript.hasFlag = hasFlag; + + function withoutFlag(val, flag) { + return val & ~flag; + } + TypeScript.withoutFlag = withoutFlag; + + (function (ASTFlags) { + ASTFlags[ASTFlags["None"] = 0] = "None"; + ASTFlags[ASTFlags["SingleLine"] = 1 << 1] = "SingleLine"; + ASTFlags[ASTFlags["OptionalName"] = 1 << 2] = "OptionalName"; + ASTFlags[ASTFlags["TypeReference"] = 1 << 3] = "TypeReference"; + ASTFlags[ASTFlags["EnumElement"] = 1 << 4] = "EnumElement"; + })(TypeScript.ASTFlags || (TypeScript.ASTFlags = {})); + var ASTFlags = TypeScript.ASTFlags; + + (function (DeclFlags) { + DeclFlags[DeclFlags["None"] = 0] = "None"; + DeclFlags[DeclFlags["Exported"] = 1] = "Exported"; + DeclFlags[DeclFlags["Private"] = 1 << 1] = "Private"; + DeclFlags[DeclFlags["Public"] = 1 << 2] = "Public"; + DeclFlags[DeclFlags["Ambient"] = 1 << 3] = "Ambient"; + DeclFlags[DeclFlags["Static"] = 1 << 4] = "Static"; + })(TypeScript.DeclFlags || (TypeScript.DeclFlags = {})); + var DeclFlags = TypeScript.DeclFlags; + + (function (ModuleFlags) { + ModuleFlags[ModuleFlags["None"] = 0] = "None"; + ModuleFlags[ModuleFlags["Exported"] = 1] = "Exported"; + ModuleFlags[ModuleFlags["Private"] = 1 << 1] = "Private"; + ModuleFlags[ModuleFlags["Public"] = 1 << 2] = "Public"; + ModuleFlags[ModuleFlags["Ambient"] = 1 << 3] = "Ambient"; + ModuleFlags[ModuleFlags["Static"] = 1 << 4] = "Static"; + ModuleFlags[ModuleFlags["IsEnum"] = 1 << 7] = "IsEnum"; + ModuleFlags[ModuleFlags["IsWholeFile"] = 1 << 8] = "IsWholeFile"; + ModuleFlags[ModuleFlags["IsDynamic"] = 1 << 9] = "IsDynamic"; + })(TypeScript.ModuleFlags || (TypeScript.ModuleFlags = {})); + var ModuleFlags = TypeScript.ModuleFlags; + + (function (VariableFlags) { + VariableFlags[VariableFlags["None"] = 0] = "None"; + VariableFlags[VariableFlags["Exported"] = 1] = "Exported"; + VariableFlags[VariableFlags["Private"] = 1 << 1] = "Private"; + VariableFlags[VariableFlags["Public"] = 1 << 2] = "Public"; + VariableFlags[VariableFlags["Ambient"] = 1 << 3] = "Ambient"; + VariableFlags[VariableFlags["Static"] = 1 << 4] = "Static"; + VariableFlags[VariableFlags["Property"] = 1 << 8] = "Property"; + VariableFlags[VariableFlags["ClassProperty"] = 1 << 11] = "ClassProperty"; + VariableFlags[VariableFlags["EnumElement"] = 1 << 13] = "EnumElement"; + VariableFlags[VariableFlags["ForInVariable"] = 1 << 14] = "ForInVariable"; + })(TypeScript.VariableFlags || (TypeScript.VariableFlags = {})); + var VariableFlags = TypeScript.VariableFlags; + + (function (FunctionFlags) { + FunctionFlags[FunctionFlags["None"] = 0] = "None"; + FunctionFlags[FunctionFlags["Exported"] = 1] = "Exported"; + FunctionFlags[FunctionFlags["Private"] = 1 << 1] = "Private"; + FunctionFlags[FunctionFlags["Public"] = 1 << 2] = "Public"; + FunctionFlags[FunctionFlags["Ambient"] = 1 << 3] = "Ambient"; + FunctionFlags[FunctionFlags["Static"] = 1 << 4] = "Static"; + FunctionFlags[FunctionFlags["GetAccessor"] = 1 << 5] = "GetAccessor"; + FunctionFlags[FunctionFlags["SetAccessor"] = 1 << 6] = "SetAccessor"; + FunctionFlags[FunctionFlags["Signature"] = 1 << 7] = "Signature"; + FunctionFlags[FunctionFlags["Method"] = 1 << 8] = "Method"; + FunctionFlags[FunctionFlags["CallMember"] = 1 << 9] = "CallMember"; + FunctionFlags[FunctionFlags["ConstructMember"] = 1 << 10] = "ConstructMember"; + FunctionFlags[FunctionFlags["IsFatArrowFunction"] = 1 << 11] = "IsFatArrowFunction"; + FunctionFlags[FunctionFlags["IndexerMember"] = 1 << 12] = "IndexerMember"; + FunctionFlags[FunctionFlags["IsFunctionExpression"] = 1 << 13] = "IsFunctionExpression"; + FunctionFlags[FunctionFlags["IsFunctionProperty"] = 1 << 14] = "IsFunctionProperty"; + })(TypeScript.FunctionFlags || (TypeScript.FunctionFlags = {})); + var FunctionFlags = TypeScript.FunctionFlags; + + function ToDeclFlags(fncOrVarOrModuleFlags) { + return fncOrVarOrModuleFlags; + } + TypeScript.ToDeclFlags = ToDeclFlags; + + (function (TypeRelationshipFlags) { + TypeRelationshipFlags[TypeRelationshipFlags["SuccessfulComparison"] = 0] = "SuccessfulComparison"; + TypeRelationshipFlags[TypeRelationshipFlags["RequiredPropertyIsMissing"] = 1 << 1] = "RequiredPropertyIsMissing"; + TypeRelationshipFlags[TypeRelationshipFlags["IncompatibleSignatures"] = 1 << 2] = "IncompatibleSignatures"; + TypeRelationshipFlags[TypeRelationshipFlags["SourceSignatureHasTooManyParameters"] = 3] = "SourceSignatureHasTooManyParameters"; + TypeRelationshipFlags[TypeRelationshipFlags["IncompatibleReturnTypes"] = 1 << 4] = "IncompatibleReturnTypes"; + TypeRelationshipFlags[TypeRelationshipFlags["IncompatiblePropertyTypes"] = 1 << 5] = "IncompatiblePropertyTypes"; + TypeRelationshipFlags[TypeRelationshipFlags["IncompatibleParameterTypes"] = 1 << 6] = "IncompatibleParameterTypes"; + TypeRelationshipFlags[TypeRelationshipFlags["InconsistantPropertyAccesibility"] = 1 << 7] = "InconsistantPropertyAccesibility"; + })(TypeScript.TypeRelationshipFlags || (TypeScript.TypeRelationshipFlags = {})); + var TypeRelationshipFlags = TypeScript.TypeRelationshipFlags; + + (function (ModuleGenTarget) { + ModuleGenTarget[ModuleGenTarget["Unspecified"] = 0] = "Unspecified"; + ModuleGenTarget[ModuleGenTarget["Synchronous"] = 1] = "Synchronous"; + ModuleGenTarget[ModuleGenTarget["Asynchronous"] = 2] = "Asynchronous"; + })(TypeScript.ModuleGenTarget || (TypeScript.ModuleGenTarget = {})); + var ModuleGenTarget = TypeScript.ModuleGenTarget; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (NodeType) { + NodeType[NodeType["None"] = 0] = "None"; + NodeType[NodeType["List"] = 1] = "List"; + NodeType[NodeType["Script"] = 2] = "Script"; + + NodeType[NodeType["TrueLiteral"] = 3] = "TrueLiteral"; + NodeType[NodeType["FalseLiteral"] = 4] = "FalseLiteral"; + NodeType[NodeType["StringLiteral"] = 5] = "StringLiteral"; + NodeType[NodeType["RegularExpressionLiteral"] = 6] = "RegularExpressionLiteral"; + NodeType[NodeType["NumericLiteral"] = 7] = "NumericLiteral"; + NodeType[NodeType["NullLiteral"] = 8] = "NullLiteral"; + + NodeType[NodeType["TypeParameter"] = 9] = "TypeParameter"; + NodeType[NodeType["GenericType"] = 10] = "GenericType"; + NodeType[NodeType["TypeRef"] = 11] = "TypeRef"; + NodeType[NodeType["TypeQuery"] = 12] = "TypeQuery"; + + NodeType[NodeType["FunctionDeclaration"] = 13] = "FunctionDeclaration"; + NodeType[NodeType["ClassDeclaration"] = 14] = "ClassDeclaration"; + NodeType[NodeType["InterfaceDeclaration"] = 15] = "InterfaceDeclaration"; + NodeType[NodeType["ModuleDeclaration"] = 16] = "ModuleDeclaration"; + NodeType[NodeType["ImportDeclaration"] = 17] = "ImportDeclaration"; + NodeType[NodeType["VariableDeclarator"] = 18] = "VariableDeclarator"; + NodeType[NodeType["VariableDeclaration"] = 19] = "VariableDeclaration"; + NodeType[NodeType["Parameter"] = 20] = "Parameter"; + + NodeType[NodeType["Name"] = 21] = "Name"; + NodeType[NodeType["ArrayLiteralExpression"] = 22] = "ArrayLiteralExpression"; + NodeType[NodeType["ObjectLiteralExpression"] = 23] = "ObjectLiteralExpression"; + NodeType[NodeType["OmittedExpression"] = 24] = "OmittedExpression"; + NodeType[NodeType["VoidExpression"] = 25] = "VoidExpression"; + NodeType[NodeType["CommaExpression"] = 26] = "CommaExpression"; + NodeType[NodeType["PlusExpression"] = 27] = "PlusExpression"; + NodeType[NodeType["NegateExpression"] = 28] = "NegateExpression"; + NodeType[NodeType["DeleteExpression"] = 29] = "DeleteExpression"; + NodeType[NodeType["ThisExpression"] = 30] = "ThisExpression"; + NodeType[NodeType["SuperExpression"] = 31] = "SuperExpression"; + NodeType[NodeType["InExpression"] = 32] = "InExpression"; + NodeType[NodeType["MemberAccessExpression"] = 33] = "MemberAccessExpression"; + NodeType[NodeType["InstanceOfExpression"] = 34] = "InstanceOfExpression"; + NodeType[NodeType["TypeOfExpression"] = 35] = "TypeOfExpression"; + NodeType[NodeType["ElementAccessExpression"] = 36] = "ElementAccessExpression"; + NodeType[NodeType["InvocationExpression"] = 37] = "InvocationExpression"; + NodeType[NodeType["ObjectCreationExpression"] = 38] = "ObjectCreationExpression"; + NodeType[NodeType["AssignmentExpression"] = 39] = "AssignmentExpression"; + NodeType[NodeType["AddAssignmentExpression"] = 40] = "AddAssignmentExpression"; + NodeType[NodeType["SubtractAssignmentExpression"] = 41] = "SubtractAssignmentExpression"; + NodeType[NodeType["DivideAssignmentExpression"] = 42] = "DivideAssignmentExpression"; + NodeType[NodeType["MultiplyAssignmentExpression"] = 43] = "MultiplyAssignmentExpression"; + NodeType[NodeType["ModuloAssignmentExpression"] = 44] = "ModuloAssignmentExpression"; + NodeType[NodeType["AndAssignmentExpression"] = 45] = "AndAssignmentExpression"; + NodeType[NodeType["ExclusiveOrAssignmentExpression"] = 46] = "ExclusiveOrAssignmentExpression"; + NodeType[NodeType["OrAssignmentExpression"] = 47] = "OrAssignmentExpression"; + NodeType[NodeType["LeftShiftAssignmentExpression"] = 48] = "LeftShiftAssignmentExpression"; + NodeType[NodeType["SignedRightShiftAssignmentExpression"] = 49] = "SignedRightShiftAssignmentExpression"; + NodeType[NodeType["UnsignedRightShiftAssignmentExpression"] = 50] = "UnsignedRightShiftAssignmentExpression"; + NodeType[NodeType["ConditionalExpression"] = 51] = "ConditionalExpression"; + NodeType[NodeType["LogicalOrExpression"] = 52] = "LogicalOrExpression"; + NodeType[NodeType["LogicalAndExpression"] = 53] = "LogicalAndExpression"; + NodeType[NodeType["BitwiseOrExpression"] = 54] = "BitwiseOrExpression"; + NodeType[NodeType["BitwiseExclusiveOrExpression"] = 55] = "BitwiseExclusiveOrExpression"; + NodeType[NodeType["BitwiseAndExpression"] = 56] = "BitwiseAndExpression"; + NodeType[NodeType["EqualsWithTypeConversionExpression"] = 57] = "EqualsWithTypeConversionExpression"; + NodeType[NodeType["NotEqualsWithTypeConversionExpression"] = 58] = "NotEqualsWithTypeConversionExpression"; + NodeType[NodeType["EqualsExpression"] = 59] = "EqualsExpression"; + NodeType[NodeType["NotEqualsExpression"] = 60] = "NotEqualsExpression"; + NodeType[NodeType["LessThanExpression"] = 61] = "LessThanExpression"; + NodeType[NodeType["LessThanOrEqualExpression"] = 62] = "LessThanOrEqualExpression"; + NodeType[NodeType["GreaterThanExpression"] = 63] = "GreaterThanExpression"; + NodeType[NodeType["GreaterThanOrEqualExpression"] = 64] = "GreaterThanOrEqualExpression"; + NodeType[NodeType["AddExpression"] = 65] = "AddExpression"; + NodeType[NodeType["SubtractExpression"] = 66] = "SubtractExpression"; + NodeType[NodeType["MultiplyExpression"] = 67] = "MultiplyExpression"; + NodeType[NodeType["DivideExpression"] = 68] = "DivideExpression"; + NodeType[NodeType["ModuloExpression"] = 69] = "ModuloExpression"; + NodeType[NodeType["LeftShiftExpression"] = 70] = "LeftShiftExpression"; + NodeType[NodeType["SignedRightShiftExpression"] = 71] = "SignedRightShiftExpression"; + NodeType[NodeType["UnsignedRightShiftExpression"] = 72] = "UnsignedRightShiftExpression"; + NodeType[NodeType["BitwiseNotExpression"] = 73] = "BitwiseNotExpression"; + NodeType[NodeType["LogicalNotExpression"] = 74] = "LogicalNotExpression"; + NodeType[NodeType["PreIncrementExpression"] = 75] = "PreIncrementExpression"; + NodeType[NodeType["PreDecrementExpression"] = 76] = "PreDecrementExpression"; + NodeType[NodeType["PostIncrementExpression"] = 77] = "PostIncrementExpression"; + NodeType[NodeType["PostDecrementExpression"] = 78] = "PostDecrementExpression"; + NodeType[NodeType["CastExpression"] = 79] = "CastExpression"; + NodeType[NodeType["ParenthesizedExpression"] = 80] = "ParenthesizedExpression"; + NodeType[NodeType["Member"] = 81] = "Member"; + + NodeType[NodeType["Block"] = 82] = "Block"; + NodeType[NodeType["BreakStatement"] = 83] = "BreakStatement"; + NodeType[NodeType["ContinueStatement"] = 84] = "ContinueStatement"; + NodeType[NodeType["DebuggerStatement"] = 85] = "DebuggerStatement"; + NodeType[NodeType["DoStatement"] = 86] = "DoStatement"; + NodeType[NodeType["EmptyStatement"] = 87] = "EmptyStatement"; + NodeType[NodeType["ExportAssignment"] = 88] = "ExportAssignment"; + NodeType[NodeType["ExpressionStatement"] = 89] = "ExpressionStatement"; + NodeType[NodeType["ForInStatement"] = 90] = "ForInStatement"; + NodeType[NodeType["ForStatement"] = 91] = "ForStatement"; + NodeType[NodeType["IfStatement"] = 92] = "IfStatement"; + NodeType[NodeType["LabeledStatement"] = 93] = "LabeledStatement"; + NodeType[NodeType["ReturnStatement"] = 94] = "ReturnStatement"; + NodeType[NodeType["SwitchStatement"] = 95] = "SwitchStatement"; + NodeType[NodeType["ThrowStatement"] = 96] = "ThrowStatement"; + NodeType[NodeType["TryStatement"] = 97] = "TryStatement"; + NodeType[NodeType["VariableStatement"] = 98] = "VariableStatement"; + NodeType[NodeType["WhileStatement"] = 99] = "WhileStatement"; + NodeType[NodeType["WithStatement"] = 100] = "WithStatement"; + + NodeType[NodeType["CaseClause"] = 101] = "CaseClause"; + NodeType[NodeType["CatchClause"] = 102] = "CatchClause"; + + NodeType[NodeType["Comment"] = 103] = "Comment"; + })(TypeScript.NodeType || (TypeScript.NodeType = {})); + var NodeType = TypeScript.NodeType; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var BlockIntrinsics = (function () { + function BlockIntrinsics() { + this.prototype = undefined; + this.toString = undefined; + this.toLocaleString = undefined; + this.valueOf = undefined; + this.hasOwnProperty = undefined; + this.propertyIsEnumerable = undefined; + this.isPrototypeOf = undefined; + this["constructor"] = undefined; + } + return BlockIntrinsics; + })(); + TypeScript.BlockIntrinsics = BlockIntrinsics; + + var StringHashTable = (function () { + function StringHashTable() { + this.itemCount = 0; + this.table = (new BlockIntrinsics()); + } + StringHashTable.prototype.getAllKeys = function () { + var result = []; + + for (var k in this.table) { + if (this.table[k] !== undefined) { + result.push(k); + } + } + + return result; + }; + + StringHashTable.prototype.add = function (key, data) { + if (this.table[key] !== undefined) { + return false; + } + + this.table[key] = data; + this.itemCount++; + return true; + }; + + StringHashTable.prototype.addOrUpdate = function (key, data) { + if (this.table[key] !== undefined) { + this.table[key] = data; + return false; + } + + this.table[key] = data; + this.itemCount++; + return true; + }; + + StringHashTable.prototype.map = function (fn, context) { + for (var k in this.table) { + var data = this.table[k]; + + if (data !== undefined) { + fn(k, this.table[k], context); + } + } + }; + + StringHashTable.prototype.every = function (fn, context) { + 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; + }; + + StringHashTable.prototype.some = function (fn, context) { + 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; + }; + + StringHashTable.prototype.count = function () { + return this.itemCount; + }; + + StringHashTable.prototype.lookup = function (key) { + var data = this.table[key]; + return data === undefined ? null : data; + }; + return StringHashTable; + })(); + TypeScript.StringHashTable = StringHashTable; + + var IdentiferNameHashTable = (function (_super) { + __extends(IdentiferNameHashTable, _super); + function IdentiferNameHashTable() { + _super.apply(this, arguments); + } + IdentiferNameHashTable.prototype.getAllKeys = function () { + var result = []; + + _super.prototype.map.call(this, function (k, v, c) { + if (v !== undefined) { + result.push(k.substring(1)); + } + }, null); + + return result; + }; + + IdentiferNameHashTable.prototype.add = function (key, data) { + return _super.prototype.add.call(this, "#" + key, data); + }; + + IdentiferNameHashTable.prototype.addOrUpdate = function (key, data) { + return _super.prototype.addOrUpdate.call(this, "#" + key, data); + }; + + IdentiferNameHashTable.prototype.map = function (fn, context) { + return _super.prototype.map.call(this, function (k, v, c) { + return fn(k.substring(1), v, c); + }, context); + }; + + IdentiferNameHashTable.prototype.every = function (fn, context) { + return _super.prototype.every.call(this, function (k, v, c) { + return fn(k.substring(1), v, c); + }, context); + }; + + IdentiferNameHashTable.prototype.some = function (fn, context) { + return _super.prototype.some.call(this, function (k, v, c) { + return fn(k.substring(1), v, c); + }, context); + }; + + IdentiferNameHashTable.prototype.lookup = function (key) { + return _super.prototype.lookup.call(this, "#" + key); + }; + return IdentiferNameHashTable; + })(StringHashTable); + TypeScript.IdentiferNameHashTable = IdentiferNameHashTable; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var AstWalkOptions = (function () { + function AstWalkOptions() { + this.goChildren = true; + } + return AstWalkOptions; + })(); + TypeScript.AstWalkOptions = AstWalkOptions; + + var AstWalker = (function () { + function AstWalker(childrenWalkers, pre, post, options, state) { + this.childrenWalkers = childrenWalkers; + this.pre = pre; + this.post = post; + this.options = options; + this.state = state; + } + AstWalker.prototype.walk = function (ast, parent) { + var preAst = this.pre(ast, parent, this); + if (preAst === undefined) { + preAst = ast; + } + if (this.options.goChildren) { + this.childrenWalkers[ast.nodeType()](ast, parent, this); + } else { + this.options.goChildren = true; + } + + if (this.post) { + var postAst = this.post(preAst, parent, this); + if (postAst === undefined) { + postAst = preAst; + } + return postAst; + } else { + return preAst; + } + }; + return AstWalker; + })(); + + var AstWalkerFactory = (function () { + function AstWalkerFactory() { + this.childrenWalkers = []; + this.initChildrenWalkers(); + } + AstWalkerFactory.prototype.walk = function (ast, pre, post, options, state) { + return this.getWalker(pre, post, options, state).walk(ast, null); + }; + + AstWalkerFactory.prototype.getWalker = function (pre, post, options, state) { + return this.getSlowWalker(pre, post, options, state); + }; + + AstWalkerFactory.prototype.getSlowWalker = function (pre, post, options, state) { + if (!options) { + options = new AstWalkOptions(); + } + + return new AstWalker(this.childrenWalkers, pre, post, options, state); + }; + + AstWalkerFactory.prototype.initChildrenWalkers = function () { + this.childrenWalkers[0 /* None */] = ChildrenWalkers.walkNone; + this.childrenWalkers[87 /* EmptyStatement */] = ChildrenWalkers.walkNone; + this.childrenWalkers[24 /* OmittedExpression */] = ChildrenWalkers.walkNone; + this.childrenWalkers[3 /* TrueLiteral */] = ChildrenWalkers.walkNone; + this.childrenWalkers[4 /* FalseLiteral */] = ChildrenWalkers.walkNone; + this.childrenWalkers[30 /* ThisExpression */] = ChildrenWalkers.walkNone; + this.childrenWalkers[31 /* SuperExpression */] = ChildrenWalkers.walkNone; + this.childrenWalkers[5 /* StringLiteral */] = ChildrenWalkers.walkNone; + this.childrenWalkers[6 /* RegularExpressionLiteral */] = ChildrenWalkers.walkNone; + this.childrenWalkers[8 /* NullLiteral */] = ChildrenWalkers.walkNone; + this.childrenWalkers[22 /* ArrayLiteralExpression */] = ChildrenWalkers.walkUnaryExpressionChildren; + this.childrenWalkers[23 /* ObjectLiteralExpression */] = ChildrenWalkers.walkUnaryExpressionChildren; + this.childrenWalkers[25 /* VoidExpression */] = ChildrenWalkers.walkUnaryExpressionChildren; + this.childrenWalkers[26 /* CommaExpression */] = ChildrenWalkers.walkBinaryExpressionChildren; + this.childrenWalkers[27 /* PlusExpression */] = ChildrenWalkers.walkUnaryExpressionChildren; + this.childrenWalkers[28 /* NegateExpression */] = ChildrenWalkers.walkUnaryExpressionChildren; + this.childrenWalkers[29 /* DeleteExpression */] = ChildrenWalkers.walkUnaryExpressionChildren; + this.childrenWalkers[32 /* InExpression */] = ChildrenWalkers.walkBinaryExpressionChildren; + this.childrenWalkers[33 /* MemberAccessExpression */] = ChildrenWalkers.walkBinaryExpressionChildren; + this.childrenWalkers[34 /* InstanceOfExpression */] = ChildrenWalkers.walkBinaryExpressionChildren; + this.childrenWalkers[35 /* TypeOfExpression */] = ChildrenWalkers.walkUnaryExpressionChildren; + this.childrenWalkers[7 /* NumericLiteral */] = ChildrenWalkers.walkNone; + this.childrenWalkers[21 /* Name */] = ChildrenWalkers.walkNone; + this.childrenWalkers[9 /* TypeParameter */] = ChildrenWalkers.walkTypeParameterChildren; + this.childrenWalkers[10 /* GenericType */] = ChildrenWalkers.walkGenericTypeChildren; + this.childrenWalkers[11 /* TypeRef */] = ChildrenWalkers.walkTypeReferenceChildren; + this.childrenWalkers[12 /* TypeQuery */] = ChildrenWalkers.walkTypeQueryChildren; + this.childrenWalkers[36 /* ElementAccessExpression */] = ChildrenWalkers.walkBinaryExpressionChildren; + this.childrenWalkers[37 /* InvocationExpression */] = ChildrenWalkers.walkInvocationExpressionChildren; + this.childrenWalkers[38 /* ObjectCreationExpression */] = ChildrenWalkers.walkObjectCreationExpressionChildren; + this.childrenWalkers[39 /* AssignmentExpression */] = ChildrenWalkers.walkBinaryExpressionChildren; + this.childrenWalkers[40 /* AddAssignmentExpression */] = ChildrenWalkers.walkBinaryExpressionChildren; + this.childrenWalkers[41 /* SubtractAssignmentExpression */] = ChildrenWalkers.walkBinaryExpressionChildren; + this.childrenWalkers[42 /* DivideAssignmentExpression */] = ChildrenWalkers.walkBinaryExpressionChildren; + this.childrenWalkers[43 /* MultiplyAssignmentExpression */] = ChildrenWalkers.walkBinaryExpressionChildren; + this.childrenWalkers[44 /* ModuloAssignmentExpression */] = ChildrenWalkers.walkBinaryExpressionChildren; + this.childrenWalkers[45 /* AndAssignmentExpression */] = ChildrenWalkers.walkBinaryExpressionChildren; + this.childrenWalkers[46 /* ExclusiveOrAssignmentExpression */] = ChildrenWalkers.walkBinaryExpressionChildren; + this.childrenWalkers[47 /* OrAssignmentExpression */] = ChildrenWalkers.walkBinaryExpressionChildren; + this.childrenWalkers[48 /* LeftShiftAssignmentExpression */] = ChildrenWalkers.walkBinaryExpressionChildren; + this.childrenWalkers[49 /* SignedRightShiftAssignmentExpression */] = ChildrenWalkers.walkBinaryExpressionChildren; + this.childrenWalkers[50 /* UnsignedRightShiftAssignmentExpression */] = ChildrenWalkers.walkBinaryExpressionChildren; + this.childrenWalkers[51 /* ConditionalExpression */] = ChildrenWalkers.walkTrinaryExpressionChildren; + this.childrenWalkers[52 /* LogicalOrExpression */] = ChildrenWalkers.walkBinaryExpressionChildren; + this.childrenWalkers[53 /* LogicalAndExpression */] = ChildrenWalkers.walkBinaryExpressionChildren; + this.childrenWalkers[54 /* BitwiseOrExpression */] = ChildrenWalkers.walkBinaryExpressionChildren; + this.childrenWalkers[55 /* BitwiseExclusiveOrExpression */] = ChildrenWalkers.walkBinaryExpressionChildren; + this.childrenWalkers[56 /* BitwiseAndExpression */] = ChildrenWalkers.walkBinaryExpressionChildren; + this.childrenWalkers[57 /* EqualsWithTypeConversionExpression */] = ChildrenWalkers.walkBinaryExpressionChildren; + this.childrenWalkers[58 /* NotEqualsWithTypeConversionExpression */] = ChildrenWalkers.walkBinaryExpressionChildren; + this.childrenWalkers[59 /* EqualsExpression */] = ChildrenWalkers.walkBinaryExpressionChildren; + this.childrenWalkers[60 /* NotEqualsExpression */] = ChildrenWalkers.walkBinaryExpressionChildren; + this.childrenWalkers[61 /* LessThanExpression */] = ChildrenWalkers.walkBinaryExpressionChildren; + this.childrenWalkers[62 /* LessThanOrEqualExpression */] = ChildrenWalkers.walkBinaryExpressionChildren; + this.childrenWalkers[63 /* GreaterThanExpression */] = ChildrenWalkers.walkBinaryExpressionChildren; + this.childrenWalkers[64 /* GreaterThanOrEqualExpression */] = ChildrenWalkers.walkBinaryExpressionChildren; + this.childrenWalkers[65 /* AddExpression */] = ChildrenWalkers.walkBinaryExpressionChildren; + this.childrenWalkers[66 /* SubtractExpression */] = ChildrenWalkers.walkBinaryExpressionChildren; + this.childrenWalkers[67 /* MultiplyExpression */] = ChildrenWalkers.walkBinaryExpressionChildren; + this.childrenWalkers[68 /* DivideExpression */] = ChildrenWalkers.walkBinaryExpressionChildren; + this.childrenWalkers[69 /* ModuloExpression */] = ChildrenWalkers.walkBinaryExpressionChildren; + this.childrenWalkers[70 /* LeftShiftExpression */] = ChildrenWalkers.walkBinaryExpressionChildren; + this.childrenWalkers[71 /* SignedRightShiftExpression */] = ChildrenWalkers.walkBinaryExpressionChildren; + this.childrenWalkers[72 /* UnsignedRightShiftExpression */] = ChildrenWalkers.walkBinaryExpressionChildren; + this.childrenWalkers[73 /* BitwiseNotExpression */] = ChildrenWalkers.walkUnaryExpressionChildren; + this.childrenWalkers[74 /* LogicalNotExpression */] = ChildrenWalkers.walkUnaryExpressionChildren; + this.childrenWalkers[75 /* PreIncrementExpression */] = ChildrenWalkers.walkUnaryExpressionChildren; + this.childrenWalkers[76 /* PreDecrementExpression */] = ChildrenWalkers.walkUnaryExpressionChildren; + this.childrenWalkers[77 /* PostIncrementExpression */] = ChildrenWalkers.walkUnaryExpressionChildren; + this.childrenWalkers[78 /* PostDecrementExpression */] = ChildrenWalkers.walkUnaryExpressionChildren; + this.childrenWalkers[79 /* CastExpression */] = ChildrenWalkers.walkUnaryExpressionChildren; + this.childrenWalkers[80 /* ParenthesizedExpression */] = ChildrenWalkers.walkParenthesizedExpressionChildren; + this.childrenWalkers[13 /* FunctionDeclaration */] = ChildrenWalkers.walkFuncDeclChildren; + this.childrenWalkers[81 /* Member */] = ChildrenWalkers.walkBinaryExpressionChildren; + this.childrenWalkers[18 /* VariableDeclarator */] = ChildrenWalkers.walkBoundDeclChildren; + this.childrenWalkers[19 /* VariableDeclaration */] = ChildrenWalkers.walkVariableDeclarationChildren; + this.childrenWalkers[20 /* Parameter */] = ChildrenWalkers.walkBoundDeclChildren; + this.childrenWalkers[94 /* ReturnStatement */] = ChildrenWalkers.walkReturnStatementChildren; + this.childrenWalkers[83 /* BreakStatement */] = ChildrenWalkers.walkNone; + this.childrenWalkers[84 /* ContinueStatement */] = ChildrenWalkers.walkNone; + this.childrenWalkers[96 /* ThrowStatement */] = ChildrenWalkers.walkThrowStatementChildren; + this.childrenWalkers[91 /* ForStatement */] = ChildrenWalkers.walkForStatementChildren; + this.childrenWalkers[90 /* ForInStatement */] = ChildrenWalkers.walkForInStatementChildren; + this.childrenWalkers[92 /* IfStatement */] = ChildrenWalkers.walkIfStatementChildren; + this.childrenWalkers[99 /* WhileStatement */] = ChildrenWalkers.walkWhileStatementChildren; + this.childrenWalkers[86 /* DoStatement */] = ChildrenWalkers.walkDoStatementChildren; + this.childrenWalkers[82 /* Block */] = ChildrenWalkers.walkBlockChildren; + this.childrenWalkers[101 /* CaseClause */] = ChildrenWalkers.walkCaseClauseChildren; + this.childrenWalkers[95 /* SwitchStatement */] = ChildrenWalkers.walkSwitchStatementChildren; + this.childrenWalkers[97 /* TryStatement */] = ChildrenWalkers.walkTryStatementChildren; + this.childrenWalkers[102 /* CatchClause */] = ChildrenWalkers.walkCatchClauseChildren; + this.childrenWalkers[1 /* List */] = ChildrenWalkers.walkListChildren; + this.childrenWalkers[2 /* Script */] = ChildrenWalkers.walkScriptChildren; + this.childrenWalkers[14 /* ClassDeclaration */] = ChildrenWalkers.walkClassDeclChildren; + this.childrenWalkers[15 /* InterfaceDeclaration */] = ChildrenWalkers.walkTypeDeclChildren; + this.childrenWalkers[16 /* ModuleDeclaration */] = ChildrenWalkers.walkModuleDeclChildren; + this.childrenWalkers[17 /* ImportDeclaration */] = ChildrenWalkers.walkImportDeclChildren; + this.childrenWalkers[88 /* ExportAssignment */] = ChildrenWalkers.walkExportAssignmentChildren; + this.childrenWalkers[100 /* WithStatement */] = ChildrenWalkers.walkWithStatementChildren; + this.childrenWalkers[89 /* ExpressionStatement */] = ChildrenWalkers.walkExpressionStatementChildren; + this.childrenWalkers[93 /* LabeledStatement */] = ChildrenWalkers.walkLabeledStatementChildren; + this.childrenWalkers[98 /* VariableStatement */] = ChildrenWalkers.walkVariableStatementChildren; + this.childrenWalkers[103 /* Comment */] = ChildrenWalkers.walkNone; + this.childrenWalkers[85 /* DebuggerStatement */] = ChildrenWalkers.walkNone; + + for (var e in TypeScript.NodeType) { + if (TypeScript.NodeType.hasOwnProperty(e) && TypeScript.StringUtilities.isString(TypeScript.NodeType[e])) { + TypeScript.CompilerDiagnostics.assert(this.childrenWalkers[e] !== undefined, "initWalkers function is not up to date with enum content!"); + } + } + }; + return AstWalkerFactory; + })(); + TypeScript.AstWalkerFactory = AstWalkerFactory; + + var globalAstWalkerFactory; + + function getAstWalkerFactory() { + if (!globalAstWalkerFactory) { + globalAstWalkerFactory = new AstWalkerFactory(); + } + return globalAstWalkerFactory; + } + TypeScript.getAstWalkerFactory = getAstWalkerFactory; + + var ChildrenWalkers; + (function (ChildrenWalkers) { + function walkNone(preAst, parent, walker) { + } + ChildrenWalkers.walkNone = walkNone; + + function walkListChildren(preAst, parent, walker) { + var len = preAst.members.length; + + for (var i = 0; i < len; i++) { + preAst.members[i] = walker.walk(preAst.members[i], preAst); + } + } + ChildrenWalkers.walkListChildren = walkListChildren; + + function walkThrowStatementChildren(preAst, parent, walker) { + if (preAst.expression) { + preAst.expression = walker.walk(preAst.expression, preAst); + } + } + ChildrenWalkers.walkThrowStatementChildren = walkThrowStatementChildren; + + function walkUnaryExpressionChildren(preAst, parent, walker) { + if (preAst.castTerm) { + preAst.castTerm = walker.walk(preAst.castTerm, preAst); + } + if (preAst.operand) { + preAst.operand = walker.walk(preAst.operand, preAst); + } + } + ChildrenWalkers.walkUnaryExpressionChildren = walkUnaryExpressionChildren; + + function walkParenthesizedExpressionChildren(preAst, parent, walker) { + if (preAst.expression) { + preAst.expression = walker.walk(preAst.expression, preAst); + } + } + ChildrenWalkers.walkParenthesizedExpressionChildren = walkParenthesizedExpressionChildren; + + function walkBinaryExpressionChildren(preAst, parent, walker) { + if (preAst.operand1) { + preAst.operand1 = walker.walk(preAst.operand1, preAst); + } + if (preAst.operand2) { + preAst.operand2 = walker.walk(preAst.operand2, preAst); + } + } + ChildrenWalkers.walkBinaryExpressionChildren = walkBinaryExpressionChildren; + + function walkTypeParameterChildren(preAst, parent, walker) { + if (preAst.name) { + preAst.name = walker.walk(preAst.name, preAst); + } + + if (preAst.constraint) { + preAst.constraint = walker.walk(preAst.constraint, preAst); + } + } + ChildrenWalkers.walkTypeParameterChildren = walkTypeParameterChildren; + + function walkGenericTypeChildren(preAst, parent, walker) { + if (preAst.name) { + preAst.name = walker.walk(preAst.name, preAst); + } + + if (preAst.typeArguments) { + preAst.typeArguments = walker.walk(preAst.typeArguments, preAst); + } + } + ChildrenWalkers.walkGenericTypeChildren = walkGenericTypeChildren; + + function walkTypeReferenceChildren(preAst, parent, walker) { + if (preAst.term) { + preAst.term = walker.walk(preAst.term, preAst); + } + } + ChildrenWalkers.walkTypeReferenceChildren = walkTypeReferenceChildren; + + function walkTypeQueryChildren(preAst, parent, walker) { + if (preAst.name) { + preAst.name = walker.walk(preAst.name, preAst); + } + } + ChildrenWalkers.walkTypeQueryChildren = walkTypeQueryChildren; + + function walkInvocationExpressionChildren(preAst, parent, walker) { + preAst.target = walker.walk(preAst.target, preAst); + + if (preAst.typeArguments) { + preAst.typeArguments = walker.walk(preAst.typeArguments, preAst); + } + + if (preAst.arguments) { + preAst.arguments = walker.walk(preAst.arguments, preAst); + } + } + ChildrenWalkers.walkInvocationExpressionChildren = walkInvocationExpressionChildren; + + function walkObjectCreationExpressionChildren(preAst, parent, walker) { + preAst.target = walker.walk(preAst.target, preAst); + + if (preAst.typeArguments) { + preAst.typeArguments = walker.walk(preAst.typeArguments, preAst); + } + + if (preAst.arguments) { + preAst.arguments = walker.walk(preAst.arguments, preAst); + } + } + ChildrenWalkers.walkObjectCreationExpressionChildren = walkObjectCreationExpressionChildren; + + function walkTrinaryExpressionChildren(preAst, parent, walker) { + if (preAst.operand1) { + preAst.operand1 = walker.walk(preAst.operand1, preAst); + } + if (preAst.operand2) { + preAst.operand2 = walker.walk(preAst.operand2, preAst); + } + if (preAst.operand3) { + preAst.operand3 = walker.walk(preAst.operand3, preAst); + } + } + ChildrenWalkers.walkTrinaryExpressionChildren = walkTrinaryExpressionChildren; + + function walkFuncDeclChildren(preAst, parent, walker) { + if (preAst.name) { + preAst.name = walker.walk(preAst.name, preAst); + } + if (preAst.typeArguments) { + preAst.typeArguments = walker.walk(preAst.typeArguments, preAst); + } + if (preAst.arguments) { + preAst.arguments = walker.walk(preAst.arguments, preAst); + } + if (preAst.returnTypeAnnotation) { + preAst.returnTypeAnnotation = walker.walk(preAst.returnTypeAnnotation, preAst); + } + if (preAst.block) { + preAst.block = walker.walk(preAst.block, preAst); + } + } + ChildrenWalkers.walkFuncDeclChildren = walkFuncDeclChildren; + + function walkBoundDeclChildren(preAst, parent, walker) { + if (preAst.id) { + preAst.id = walker.walk(preAst.id, preAst); + } + if (preAst.init) { + preAst.init = walker.walk(preAst.init, preAst); + } + if (preAst.typeExpr) { + preAst.typeExpr = walker.walk(preAst.typeExpr, preAst); + } + } + ChildrenWalkers.walkBoundDeclChildren = walkBoundDeclChildren; + + function walkReturnStatementChildren(preAst, parent, walker) { + if (preAst.returnExpression) { + preAst.returnExpression = walker.walk(preAst.returnExpression, preAst); + } + } + ChildrenWalkers.walkReturnStatementChildren = walkReturnStatementChildren; + + function walkForStatementChildren(preAst, parent, walker) { + if (preAst.init) { + preAst.init = walker.walk(preAst.init, preAst); + } + + if (preAst.cond) { + preAst.cond = walker.walk(preAst.cond, preAst); + } + + if (preAst.incr) { + preAst.incr = walker.walk(preAst.incr, preAst); + } + + if (preAst.body) { + preAst.body = walker.walk(preAst.body, preAst); + } + } + ChildrenWalkers.walkForStatementChildren = walkForStatementChildren; + + function walkForInStatementChildren(preAst, parent, walker) { + preAst.lval = walker.walk(preAst.lval, preAst); + preAst.obj = walker.walk(preAst.obj, preAst); + + if (preAst.body) { + preAst.body = walker.walk(preAst.body, preAst); + } + } + ChildrenWalkers.walkForInStatementChildren = walkForInStatementChildren; + + function walkIfStatementChildren(preAst, parent, walker) { + preAst.cond = walker.walk(preAst.cond, preAst); + if (preAst.thenBod) { + preAst.thenBod = walker.walk(preAst.thenBod, preAst); + } + if (preAst.elseBod) { + preAst.elseBod = walker.walk(preAst.elseBod, preAst); + } + } + ChildrenWalkers.walkIfStatementChildren = walkIfStatementChildren; + + function walkWhileStatementChildren(preAst, parent, walker) { + preAst.cond = walker.walk(preAst.cond, preAst); + if (preAst.body) { + preAst.body = walker.walk(preAst.body, preAst); + } + } + ChildrenWalkers.walkWhileStatementChildren = walkWhileStatementChildren; + + function walkDoStatementChildren(preAst, parent, walker) { + preAst.cond = walker.walk(preAst.cond, preAst); + if (preAst.body) { + preAst.body = walker.walk(preAst.body, preAst); + } + } + ChildrenWalkers.walkDoStatementChildren = walkDoStatementChildren; + + function walkBlockChildren(preAst, parent, walker) { + if (preAst.statements) { + preAst.statements = walker.walk(preAst.statements, preAst); + } + } + ChildrenWalkers.walkBlockChildren = walkBlockChildren; + + function walkVariableDeclarationChildren(preAst, parent, walker) { + if (preAst.declarators) { + preAst.declarators = walker.walk(preAst.declarators, preAst); + } + } + ChildrenWalkers.walkVariableDeclarationChildren = walkVariableDeclarationChildren; + + function walkCaseClauseChildren(preAst, parent, walker) { + if (preAst.expr) { + preAst.expr = walker.walk(preAst.expr, preAst); + } + + if (preAst.body) { + preAst.body = walker.walk(preAst.body, preAst); + } + } + ChildrenWalkers.walkCaseClauseChildren = walkCaseClauseChildren; + + function walkSwitchStatementChildren(preAst, parent, walker) { + if (preAst.val) { + preAst.val = walker.walk(preAst.val, preAst); + } + + if (preAst.caseList) { + preAst.caseList = walker.walk(preAst.caseList, preAst); + } + } + ChildrenWalkers.walkSwitchStatementChildren = walkSwitchStatementChildren; + + function walkTryStatementChildren(preAst, parent, walker) { + if (preAst.tryBody) { + preAst.tryBody = walker.walk(preAst.tryBody, preAst); + } + if (preAst.catchClause) { + preAst.catchClause = walker.walk(preAst.catchClause, preAst); + } + if (preAst.finallyBody) { + preAst.finallyBody = walker.walk(preAst.finallyBody, preAst); + } + } + ChildrenWalkers.walkTryStatementChildren = walkTryStatementChildren; + + function walkCatchClauseChildren(preAst, parent, walker) { + if (preAst.param) { + preAst.param = walker.walk(preAst.param, preAst); + } + + if (preAst.body) { + preAst.body = walker.walk(preAst.body, preAst); + } + } + ChildrenWalkers.walkCatchClauseChildren = walkCatchClauseChildren; + + function walkClassDeclChildren(preAst, parent, walker) { + preAst.name = walker.walk(preAst.name, preAst); + + if (preAst.members) { + preAst.members = walker.walk(preAst.members, preAst); + } + + if (preAst.typeParameters) { + preAst.typeParameters = walker.walk(preAst.typeParameters, preAst); + } + + if (preAst.extendsList) { + preAst.extendsList = walker.walk(preAst.extendsList, preAst); + } + + if (preAst.implementsList) { + preAst.implementsList = walker.walk(preAst.implementsList, preAst); + } + } + ChildrenWalkers.walkClassDeclChildren = walkClassDeclChildren; + + function walkScriptChildren(preAst, parent, walker) { + if (preAst.moduleElements) { + preAst.moduleElements = walker.walk(preAst.moduleElements, preAst); + } + } + ChildrenWalkers.walkScriptChildren = walkScriptChildren; + + function walkTypeDeclChildren(preAst, parent, walker) { + preAst.name = walker.walk(preAst.name, preAst); + if (preAst.members) { + preAst.members = walker.walk(preAst.members, preAst); + } + + if (preAst.typeParameters) { + preAst.typeParameters = walker.walk(preAst.typeParameters, preAst); + } + + if (preAst.extendsList) { + preAst.extendsList = walker.walk(preAst.extendsList, preAst); + } + + if (preAst.implementsList) { + preAst.implementsList = walker.walk(preAst.implementsList, preAst); + } + } + ChildrenWalkers.walkTypeDeclChildren = walkTypeDeclChildren; + + function walkModuleDeclChildren(preAst, parent, walker) { + preAst.name = walker.walk(preAst.name, preAst); + if (preAst.members) { + preAst.members = walker.walk(preAst.members, preAst); + } + } + ChildrenWalkers.walkModuleDeclChildren = walkModuleDeclChildren; + + function walkImportDeclChildren(preAst, parent, walker) { + if (preAst.id) { + preAst.id = walker.walk(preAst.id, preAst); + } + if (preAst.alias) { + preAst.alias = walker.walk(preAst.alias, preAst); + } + } + ChildrenWalkers.walkImportDeclChildren = walkImportDeclChildren; + + function walkExportAssignmentChildren(preAst, parent, walker) { + if (preAst.id) { + preAst.id = walker.walk(preAst.id, preAst); + } + } + ChildrenWalkers.walkExportAssignmentChildren = walkExportAssignmentChildren; + + function walkWithStatementChildren(preAst, parent, walker) { + if (preAst.expr) { + preAst.expr = walker.walk(preAst.expr, preAst); + } + + if (preAst.body) { + preAst.body = walker.walk(preAst.body, preAst); + } + } + ChildrenWalkers.walkWithStatementChildren = walkWithStatementChildren; + + function walkExpressionStatementChildren(preAst, parent, walker) { + preAst.expression = walker.walk(preAst.expression, preAst); + } + ChildrenWalkers.walkExpressionStatementChildren = walkExpressionStatementChildren; + + function walkLabeledStatementChildren(preAst, parent, walker) { + preAst.identifier = walker.walk(preAst.identifier, preAst); + preAst.statement = walker.walk(preAst.statement, preAst); + } + ChildrenWalkers.walkLabeledStatementChildren = walkLabeledStatementChildren; + + function walkVariableStatementChildren(preAst, parent, walker) { + preAst.declaration = walker.walk(preAst.declaration, preAst); + } + ChildrenWalkers.walkVariableStatementChildren = walkVariableStatementChildren; + })(ChildrenWalkers || (ChildrenWalkers = {})); +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + function max(a, b) { + return a >= b ? a : b; + } + TypeScript.max = max; + + function min(a, b) { + return a <= b ? a : b; + } + TypeScript.min = min; + + var AstPath = (function () { + function AstPath() { + this.asts = new Array(); + this.top = -1; + } + AstPath.reverseIndexOf = function (items, index) { + return (items === null || items.length <= index) ? null : items[items.length - index - 1]; + }; + + AstPath.prototype.clone = function () { + var clone = new AstPath(); + clone.asts = this.asts.map(function (value) { + return value; + }); + clone.top = this.top; + return clone; + }; + + AstPath.prototype.pop = function () { + var head = this.ast(); + this.up(); + + while (this.asts.length > this.count()) { + this.asts.pop(); + } + return head; + }; + + AstPath.prototype.push = function (ast) { + while (this.asts.length > this.count()) { + this.asts.pop(); + } + this.top = this.asts.length; + this.asts.push(ast); + }; + + AstPath.prototype.up = function () { + if (this.top <= -1) + throw TypeScript.Errors.invalidOperation(TypeScript.getLocalizedText(TypeScript.DiagnosticCode.Invalid_call_to_up, null)); + this.top--; + }; + + AstPath.prototype.down = function () { + if (this.top === this.ast.length - 1) + throw TypeScript.Errors.invalidOperation(TypeScript.getLocalizedText(TypeScript.DiagnosticCode.Invalid_call_to_down, null)); + this.top++; + }; + + AstPath.prototype.nodeType = function () { + if (this.ast() === null) + return 0 /* None */; + return this.ast().nodeType(); + }; + + AstPath.prototype.ast = function () { + return AstPath.reverseIndexOf(this.asts, this.asts.length - (this.top + 1)); + }; + + AstPath.prototype.parent = function () { + return AstPath.reverseIndexOf(this.asts, this.asts.length - this.top); + }; + + AstPath.prototype.count = function () { + return this.top + 1; + }; + + AstPath.prototype.get = function (index) { + return this.asts[index]; + }; + + AstPath.prototype.isNameOfClass = function () { + if (this.ast() === null || this.parent() === null) + return false; + + return (this.ast().nodeType() === 21 /* Name */) && (this.parent().nodeType() === 14 /* ClassDeclaration */) && ((this.parent()).name === this.ast()); + }; + + AstPath.prototype.isNameOfInterface = function () { + if (this.ast() === null || this.parent() === null) + return false; + + return (this.ast().nodeType() === 21 /* Name */) && (this.parent().nodeType() === 15 /* InterfaceDeclaration */) && ((this.parent()).name === this.ast()); + }; + + AstPath.prototype.isNameOfArgument = function () { + if (this.ast() === null || this.parent() === null) + return false; + + return (this.ast().nodeType() === 21 /* Name */) && (this.parent().nodeType() === 20 /* Parameter */) && ((this.parent()).id === this.ast()); + }; + + AstPath.prototype.isNameOfVariable = function () { + if (this.ast() === null || this.parent() === null) + return false; + + return (this.ast().nodeType() === 21 /* Name */) && (this.parent().nodeType() === 18 /* VariableDeclarator */) && ((this.parent()).id === this.ast()); + }; + + AstPath.prototype.isNameOfModule = function () { + if (this.ast() === null || this.parent() === null) + return false; + + return (this.ast().nodeType() === 21 /* Name */) && (this.parent().nodeType() === 16 /* ModuleDeclaration */) && ((this.parent()).name === this.ast()); + }; + + AstPath.prototype.isNameOfFunction = function () { + if (this.ast() === null || this.parent() === null) + return false; + + return (this.ast().nodeType() === 21 /* Name */) && (this.parent().nodeType() === 13 /* FunctionDeclaration */) && ((this.parent()).name === this.ast()); + }; + + AstPath.prototype.isBodyOfFunction = function () { + return this.count() >= 2 && this.asts[this.top - 1].nodeType() === 13 /* FunctionDeclaration */ && (this.asts[this.top - 1]).block === this.asts[this.top - 0]; + }; + + AstPath.prototype.isArgumentListOfFunction = function () { + return this.count() >= 2 && this.asts[this.top - 0].nodeType() === 1 /* List */ && this.asts[this.top - 1].nodeType() === 13 /* FunctionDeclaration */ && (this.asts[this.top - 1]).arguments === this.asts[this.top - 0]; + }; + + AstPath.prototype.isTargetOfCall = function () { + return this.count() >= 2 && this.asts[this.top - 1].nodeType() === 37 /* InvocationExpression */ && (this.asts[this.top - 1]).target === this.asts[this.top]; + }; + + AstPath.prototype.isTargetOfNew = function () { + return this.count() >= 2 && this.asts[this.top - 1].nodeType() === 38 /* ObjectCreationExpression */ && (this.asts[this.top - 1]).target === this.asts[this.top]; + }; + + AstPath.prototype.isInClassImplementsList = function () { + if (this.ast() === null || this.parent() === null) + return false; + + return (this.parent().nodeType() === 14 /* ClassDeclaration */) && (this.isMemberOfList((this.parent()).implementsList, this.ast())); + }; + + AstPath.prototype.isInInterfaceExtendsList = function () { + if (this.ast() === null || this.parent() === null) + return false; + + return (this.parent().nodeType() === 15 /* InterfaceDeclaration */) && (this.isMemberOfList((this.parent()).extendsList, this.ast())); + }; + + AstPath.prototype.isMemberOfMemberAccessExpression = function () { + if (this.count() > 1 && this.parent().nodeType() === 33 /* MemberAccessExpression */ && (this.parent()).operand2 === this.asts[this.top]) { + return true; + } + + return false; + }; + + AstPath.prototype.isCallExpression = function () { + return this.count() >= 1 && (this.asts[this.top - 0].nodeType() === 37 /* InvocationExpression */ || this.asts[this.top - 0].nodeType() === 38 /* ObjectCreationExpression */); + }; + + AstPath.prototype.isCallExpressionTarget = function () { + if (this.count() < 2) { + return false; + } + + var current = this.top; + + var nodeType = this.asts[current].nodeType(); + if (nodeType === 30 /* ThisExpression */ || nodeType === 31 /* SuperExpression */ || nodeType === 21 /* Name */) { + current--; + } + + while (current >= 0) { + if (current < this.top && this.asts[current].nodeType() === 33 /* MemberAccessExpression */ && (this.asts[current]).operand2 === this.asts[current + 1]) { + current--; + continue; + } + + break; + } + + return current < this.top && (this.asts[current].nodeType() === 37 /* InvocationExpression */ || this.asts[current].nodeType() === 38 /* ObjectCreationExpression */) && this.asts[current + 1] === (this.asts[current]).target; + }; + + AstPath.prototype.isDeclaration = function () { + if (this.ast() !== null) { + switch (this.ast().nodeType()) { + case 14 /* ClassDeclaration */: + case 15 /* InterfaceDeclaration */: + case 16 /* ModuleDeclaration */: + case 13 /* FunctionDeclaration */: + case 18 /* VariableDeclarator */: + return true; + } + } + + return false; + }; + + AstPath.prototype.isMemberOfList = function (list, item) { + if (list && list.members) { + for (var i = 0, n = list.members.length; i < n; i++) { + if (list.members[i] === item) { + return true; + } + } + } + + return false; + }; + return AstPath; + })(); + TypeScript.AstPath = AstPath; + + function isValidAstNode(ast) { + if (ast === null) + return false; + + if (ast.minChar === -1 || ast.limChar === -1) + return false; + + return true; + } + TypeScript.isValidAstNode = isValidAstNode; + + var AstPathContext = (function () { + function AstPathContext() { + this.path = new TypeScript.AstPath(); + } + return AstPathContext; + })(); + TypeScript.AstPathContext = AstPathContext; + + function getAstPathToPosition(script, pos, useTrailingTriviaAsLimChar) { + if (typeof useTrailingTriviaAsLimChar === "undefined") { useTrailingTriviaAsLimChar = true; } + var lookInComments = function (comments) { + if (comments && comments.length > 0) { + for (var i = 0; i < comments.length; i++) { + var minChar = comments[i].minChar; + var limChar = comments[i].limChar + (useTrailingTriviaAsLimChar ? comments[i].trailingTriviaWidth : 0); + if (!comments[i].isBlockComment) { + limChar++; + } + if (pos >= minChar && pos < limChar) { + ctx.path.push(comments[i]); + } + } + } + }; + + var pre = function (cur, parent, walker) { + if (isValidAstNode(cur)) { + var isInvalid1 = cur.nodeType() === 89 /* ExpressionStatement */ && cur.getLength() === 0; + + if (isInvalid1) { + walker.options.goChildren = false; + } else { + var inclusive = cur.nodeType() === 21 /* Name */ || cur.nodeType() === 33 /* MemberAccessExpression */ || cur.nodeType() === 11 /* TypeRef */ || cur.nodeType() === 19 /* VariableDeclaration */ || cur.nodeType() === 18 /* VariableDeclarator */ || cur.nodeType() === 37 /* InvocationExpression */ || pos === script.limChar + script.trailingTriviaWidth; + + var minChar = cur.minChar; + var limChar = cur.limChar + (useTrailingTriviaAsLimChar ? cur.trailingTriviaWidth : 0) + (inclusive ? 1 : 0); + if (pos >= minChar && pos < limChar) { + var previous = ctx.path.ast(); + if (previous === null || (cur.minChar >= previous.minChar && (cur.limChar + (useTrailingTriviaAsLimChar ? cur.trailingTriviaWidth : 0)) <= (previous.limChar + (useTrailingTriviaAsLimChar ? previous.trailingTriviaWidth : 0)))) { + ctx.path.push(cur); + } else { + } + } + + if (pos < limChar) { + lookInComments(cur.preComments()); + } + if (pos >= minChar) { + lookInComments(cur.postComments()); + } + + walker.options.goChildren = (minChar <= pos && pos <= limChar); + } + } + + return cur; + }; + + var ctx = new AstPathContext(); + TypeScript.getAstWalkerFactory().walk(script, pre, null, null, ctx); + return ctx.path; + } + TypeScript.getAstPathToPosition = getAstPathToPosition; + + function walkAST(ast, callback) { + var pre = function (cur, parent, walker) { + var path = walker.state; + path.push(cur); + callback(path, walker); + return cur; + }; + var post = function (cur, parent, walker) { + var path = walker.state; + path.pop(); + return cur; + }; + + var path = new AstPath(); + TypeScript.getAstWalkerFactory().walk(ast, pre, post, null, path); + } + TypeScript.walkAST = walkAST; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var Base64Format = (function () { + function Base64Format() { + } + Base64Format.encode = function (inValue) { + if (inValue < 64) { + return Base64Format.encodedValues.charAt(inValue); + } + throw TypeError(inValue + ": not a 64 based value"); + }; + + Base64Format.decodeChar = function (inChar) { + if (inChar.length === 1) { + return Base64Format.encodedValues.indexOf(inChar); + } else { + throw TypeError('"' + inChar + '" must have length 1'); + } + }; + Base64Format.encodedValues = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'; + return Base64Format; + })(); + + var Base64VLQFormat = (function () { + function Base64VLQFormat() { + } + Base64VLQFormat.encode = function (inValue) { + if (inValue < 0) { + inValue = ((-inValue) << 1) + 1; + } else { + inValue = inValue << 1; + } + + var encodedStr = ""; + do { + var currentDigit = inValue & 31; + inValue = inValue >> 5; + if (inValue > 0) { + currentDigit = currentDigit | 32; + } + encodedStr = encodedStr + Base64Format.encode(currentDigit); + } while(inValue > 0); + + return encodedStr; + }; + + Base64VLQFormat.decode = function (inString) { + var result = 0; + var negative = false; + + var shift = 0; + for (var i = 0; i < inString.length; i++) { + var byte = Base64Format.decodeChar(inString[i]); + if (i === 0) { + if ((byte & 1) === 1) { + negative = true; + } + result = (byte >> 1) & 15; + } else { + result = result | ((byte & 31) << shift); + } + + shift += (i === 0) ? 4 : 5; + + if ((byte & 32) === 32) { + } else { + return { value: negative ? -(result) : result, rest: inString.substr(i + 1) }; + } + } + + throw new Error(TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Base64_value_0_finished_with_a_continuation_bit, [inString])); + }; + return Base64VLQFormat; + })(); + TypeScript.Base64VLQFormat = Base64VLQFormat; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var SourceMapPosition = (function () { + function SourceMapPosition() { + } + return SourceMapPosition; + })(); + TypeScript.SourceMapPosition = SourceMapPosition; + + var SourceMapping = (function () { + function SourceMapping() { + this.start = new SourceMapPosition(); + this.end = new SourceMapPosition(); + this.nameIndex = -1; + this.childMappings = []; + } + return SourceMapping; + })(); + TypeScript.SourceMapping = SourceMapping; + + var SourceMapSourceInfo = (function () { + function SourceMapSourceInfo(oldSourceMapSourceInfo) { + if (oldSourceMapSourceInfo) { + this.jsFileName = oldSourceMapSourceInfo.jsFileName; + this.sourceMapPath = oldSourceMapSourceInfo.sourceMapPath; + this.sourceMapDirectory = oldSourceMapSourceInfo.sourceMapDirectory; + + this.sourceRoot = oldSourceMapSourceInfo.sourceRoot; + } + } + return SourceMapSourceInfo; + })(); + TypeScript.SourceMapSourceInfo = SourceMapSourceInfo; + + var SourceMapper = (function () { + function SourceMapper(jsFile, sourceMapOut, sourceMapSourceInfo) { + this.jsFile = jsFile; + this.sourceMapOut = sourceMapOut; + this.sourceMapSourceInfo = sourceMapSourceInfo; + this.sourceMappings = []; + this.currentMappings = []; + this.names = []; + this.currentNameIndex = []; + this.currentMappings.push(this.sourceMappings); + } + SourceMapper.emitSourceMapping = function (allSourceMappers) { + var sourceMapper = allSourceMappers[0]; + sourceMapper.jsFile.WriteLine("//# sourceMappingURL=" + sourceMapper.sourceMapSourceInfo.sourceMapPath); + + var sourceMapOut = sourceMapper.sourceMapOut; + var mappingsString = ""; + var tsFiles = []; + + var prevEmittedColumn = 0; + var prevEmittedLine = 0; + var prevSourceColumn = 0; + var prevSourceLine = 0; + var prevSourceIndex = 0; + var prevNameIndex = 0; + var namesList = []; + var namesCount = 0; + var emitComma = false; + + var recordedPosition = null; + for (var sourceMapperIndex = 0; sourceMapperIndex < allSourceMappers.length; sourceMapperIndex++) { + sourceMapper = allSourceMappers[sourceMapperIndex]; + + var currentSourceIndex = tsFiles.length; + tsFiles.push(sourceMapper.sourceMapSourceInfo.tsFilePath); + + if (sourceMapper.names.length > 0) { + namesList.push.apply(namesList, sourceMapper.names); + } + + var recordSourceMapping = function (mappedPosition, nameIndex) { + if (recordedPosition !== null && recordedPosition.emittedColumn === mappedPosition.emittedColumn && recordedPosition.emittedLine === mappedPosition.emittedLine) { + return; + } + + if (prevEmittedLine !== mappedPosition.emittedLine) { + while (prevEmittedLine < mappedPosition.emittedLine) { + prevEmittedColumn = 0; + mappingsString = mappingsString + ";"; + prevEmittedLine++; + } + emitComma = false; + } else if (emitComma) { + mappingsString = mappingsString + ","; + } + + mappingsString = mappingsString + TypeScript.Base64VLQFormat.encode(mappedPosition.emittedColumn - prevEmittedColumn); + prevEmittedColumn = mappedPosition.emittedColumn; + + mappingsString = mappingsString + TypeScript.Base64VLQFormat.encode(currentSourceIndex - prevSourceIndex); + prevSourceIndex = currentSourceIndex; + + mappingsString = mappingsString + TypeScript.Base64VLQFormat.encode(mappedPosition.sourceLine - 1 - prevSourceLine); + prevSourceLine = mappedPosition.sourceLine - 1; + + mappingsString = mappingsString + TypeScript.Base64VLQFormat.encode(mappedPosition.sourceColumn - prevSourceColumn); + prevSourceColumn = mappedPosition.sourceColumn; + + if (nameIndex >= 0) { + mappingsString = mappingsString + TypeScript.Base64VLQFormat.encode(namesCount + nameIndex - prevNameIndex); + prevNameIndex = namesCount + nameIndex; + } + + emitComma = true; + recordedPosition = mappedPosition; + }; + + var recordSourceMappingSiblings = function (sourceMappings) { + 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(sourceMapper.sourceMappings); + namesCount = namesCount + sourceMapper.names.length; + } + + sourceMapOut.Write(JSON.stringify({ + version: 3, + file: sourceMapper.sourceMapSourceInfo.jsFileName, + sourceRoot: sourceMapper.sourceMapSourceInfo.sourceRoot, + sources: tsFiles, + names: namesList, + mappings: mappingsString + })); + + sourceMapOut.Close(); + }; + SourceMapper.MapFileExtension = ".map"; + return SourceMapper; + })(); + TypeScript.SourceMapper = SourceMapper; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (EmitContainer) { + EmitContainer[EmitContainer["Prog"] = 0] = "Prog"; + EmitContainer[EmitContainer["Module"] = 1] = "Module"; + EmitContainer[EmitContainer["DynamicModule"] = 2] = "DynamicModule"; + EmitContainer[EmitContainer["Class"] = 3] = "Class"; + EmitContainer[EmitContainer["Constructor"] = 4] = "Constructor"; + EmitContainer[EmitContainer["Function"] = 5] = "Function"; + EmitContainer[EmitContainer["Args"] = 6] = "Args"; + EmitContainer[EmitContainer["Interface"] = 7] = "Interface"; + })(TypeScript.EmitContainer || (TypeScript.EmitContainer = {})); + var EmitContainer = TypeScript.EmitContainer; + + var EmitState = (function () { + function EmitState() { + this.column = 0; + this.line = 0; + this.container = 0 /* Prog */; + } + return EmitState; + })(); + TypeScript.EmitState = EmitState; + + var EmitOptions = (function () { + function EmitOptions(compilationSettings) { + this.compilationSettings = compilationSettings; + this.ioHost = null; + this.outputMany = true; + this.commonDirectoryPath = ""; + } + EmitOptions.prototype.mapOutputFileName = function (document, extensionChanger) { + if (this.outputMany || document.script.topLevelMod) { + var updatedFileName = document.fileName; + if (this.compilationSettings.outDirOption !== "") { + updatedFileName = document.fileName.replace(this.commonDirectoryPath, ""); + updatedFileName = this.compilationSettings.outDirOption + updatedFileName; + } + return extensionChanger(updatedFileName, false); + } else { + return extensionChanger(this.compilationSettings.outFileOption, true); + } + }; + + EmitOptions.prototype.decodeSourceMapOptions = function (document, jsFilePath, oldSourceMapSourceInfo) { + var sourceMapSourceInfo = new TypeScript.SourceMapSourceInfo(oldSourceMapSourceInfo); + + var tsFilePath = TypeScript.switchToForwardSlashes(document.fileName); + + if (!oldSourceMapSourceInfo) { + var prettyJsFileName = TypeScript.getPrettyName(jsFilePath, false, true); + var prettyMapFileName = prettyJsFileName + TypeScript.SourceMapper.MapFileExtension; + sourceMapSourceInfo.jsFileName = prettyJsFileName; + + if (this.compilationSettings.mapRoot) { + if (this.outputMany || document.script.topLevelMod) { + var sourceMapPath = tsFilePath.replace(this.commonDirectoryPath, ""); + sourceMapPath = this.compilationSettings.mapRoot + sourceMapPath; + sourceMapPath = TypeScript.TypeScriptCompiler.mapToJSFileName(sourceMapPath, false) + TypeScript.SourceMapper.MapFileExtension; + sourceMapSourceInfo.sourceMapPath = sourceMapPath; + + if (TypeScript.isRelative(sourceMapSourceInfo.sourceMapPath)) { + sourceMapPath = this.commonDirectoryPath + sourceMapSourceInfo.sourceMapPath; + } + sourceMapSourceInfo.sourceMapDirectory = TypeScript.getRootFilePath(sourceMapPath); + } else { + sourceMapSourceInfo.sourceMapPath = this.compilationSettings.mapRoot + prettyMapFileName; + sourceMapSourceInfo.sourceMapDirectory = this.compilationSettings.mapRoot; + if (TypeScript.isRelative(sourceMapSourceInfo.sourceMapDirectory)) { + sourceMapSourceInfo.sourceMapDirectory = TypeScript.getRootFilePath(jsFilePath) + this.compilationSettings.mapRoot; + } + } + } else { + sourceMapSourceInfo.sourceMapPath = prettyMapFileName; + sourceMapSourceInfo.sourceMapDirectory = TypeScript.getRootFilePath(jsFilePath); + } + sourceMapSourceInfo.sourceRoot = this.compilationSettings.sourceRoot; + } + + if (this.compilationSettings.sourceRoot) { + sourceMapSourceInfo.tsFilePath = TypeScript.getRelativePathToFixedPath(this.commonDirectoryPath, tsFilePath); + } else { + sourceMapSourceInfo.tsFilePath = TypeScript.getRelativePathToFixedPath(sourceMapSourceInfo.sourceMapDirectory, tsFilePath); + } + return sourceMapSourceInfo; + }; + return EmitOptions; + })(); + TypeScript.EmitOptions = EmitOptions; + + var Indenter = (function () { + function Indenter() { + this.indentAmt = 0; + } + Indenter.prototype.increaseIndent = function () { + this.indentAmt += Indenter.indentStep; + }; + + Indenter.prototype.decreaseIndent = function () { + this.indentAmt -= Indenter.indentStep; + }; + + Indenter.prototype.getIndent = function () { + var indentString = Indenter.indentStrings[this.indentAmt]; + if (indentString === undefined) { + indentString = ""; + for (var i = 0; i < this.indentAmt; i = i + Indenter.indentStep) { + indentString += Indenter.indentStepString; + } + Indenter.indentStrings[this.indentAmt] = indentString; + } + return indentString; + }; + Indenter.indentStep = 4; + Indenter.indentStepString = " "; + Indenter.indentStrings = []; + return Indenter; + })(); + TypeScript.Indenter = Indenter; + + var Emitter = (function () { + function Emitter(emittingFileName, outfile, emitOptions, semanticInfoChain) { + this.emittingFileName = emittingFileName; + this.outfile = outfile; + this.emitOptions = emitOptions; + this.semanticInfoChain = semanticInfoChain; + this.globalThisCapturePrologueEmitted = false; + this.extendsPrologueEmitted = false; + this.thisClassNode = null; + this.thisFunctionDeclaration = null; + this.moduleName = ""; + this.emitState = new EmitState(); + this.indenter = new Indenter(); + this.modAliasId = null; + this.firstModAlias = null; + this.allSourceMappers = []; + this.sourceMapper = null; + this.captureThisStmtString = "var _this = this;"; + this.varListCountStack = [0]; + this.declStack = []; + this.resolvingContext = new TypeScript.PullTypeResolutionContext(); + this.exportAssignmentIdentifier = null; + this.document = null; + this.copyrightElement = null; + TypeScript.globalSemanticInfoChain = semanticInfoChain; + TypeScript.globalBinder.semanticInfoChain = semanticInfoChain; + } + Emitter.prototype.pushDecl = function (decl) { + if (decl) { + this.declStack[this.declStack.length] = decl; + } + }; + + Emitter.prototype.popDecl = function (decl) { + if (decl) { + this.declStack.length--; + } + }; + + Emitter.prototype.getEnclosingDecl = function () { + var declStackLen = this.declStack.length; + var enclosingDecl = declStackLen > 0 ? this.declStack[declStackLen - 1] : null; + return enclosingDecl; + }; + + Emitter.prototype.setExportAssignmentIdentifier = function (id) { + this.exportAssignmentIdentifier = id; + }; + + Emitter.prototype.getExportAssignmentIdentifier = function () { + return this.exportAssignmentIdentifier; + }; + + Emitter.prototype.setDocument = function (document) { + this.document = document; + }; + + Emitter.prototype.importStatementShouldBeEmitted = function (importDeclAST, unitPath) { + var importDecl = this.semanticInfoChain.getDeclForAST(importDeclAST, this.document.fileName); + var pullSymbol = importDecl.getSymbol(); + if (!importDeclAST.isExternalImportDeclaration()) { + if (pullSymbol.getExportAssignedValueSymbol()) { + return true; + } + var containerSymbol = pullSymbol.getExportAssignedContainerSymbol(); + if (containerSymbol && containerSymbol.getInstanceSymbol()) { + return true; + } + } + + return pullSymbol.isUsedAsValue; + }; + + Emitter.prototype.emitImportDeclaration = function (importDeclAST) { + if (this.importStatementShouldBeEmitted(importDeclAST)) { + var prevModAliasId = this.modAliasId; + var prevFirstModAlias = this.firstModAlias; + + this.emitComments(importDeclAST, true); + + var importDecl = this.semanticInfoChain.getDeclForAST(importDeclAST, this.document.fileName); + var importSymbol = importDecl.getSymbol(); + + var parentSymbol = importSymbol.getContainer(); + var parentKind = parentSymbol ? parentSymbol.kind : 0 /* None */; + var associatedParentSymbol = parentSymbol ? parentSymbol.getAssociatedContainerType() : null; + var associatedParentSymbolKind = associatedParentSymbol ? associatedParentSymbol.kind : 0 /* None */; + + var needsPropertyAssignment = false; + var usePropertyAssignmentInsteadOfVarDecl = false; + var moduleNamePrefix; + + if (TypeScript.hasFlag(importDecl.flags, 1 /* Exported */) && (parentKind == 4 /* Container */ || parentKind === 32 /* DynamicModule */ || associatedParentSymbolKind === 4 /* Container */ || associatedParentSymbolKind === 32 /* DynamicModule */)) { + if (importSymbol.getExportAssignedTypeSymbol() || importSymbol.getExportAssignedContainerSymbol()) { + needsPropertyAssignment = true; + } else { + var valueSymbol = importSymbol.getExportAssignedValueSymbol(); + if (valueSymbol && (valueSymbol.kind == 65536 /* Method */ || valueSymbol.kind == 16384 /* Function */)) { + needsPropertyAssignment = true; + } else { + usePropertyAssignmentInsteadOfVarDecl = true; + } + } + + if (this.emitState.container === 2 /* DynamicModule */) { + moduleNamePrefix = "exports."; + } else { + moduleNamePrefix = this.moduleName + "."; + } + } + + this.recordSourceMappingStart(importDeclAST); + if (usePropertyAssignmentInsteadOfVarDecl) { + this.writeToOutput(moduleNamePrefix); + } else { + this.writeToOutput("var "); + } + this.writeToOutput(importDeclAST.id.actualText + " = "); + this.modAliasId = importDeclAST.id.actualText; + this.firstModAlias = importDeclAST.firstAliasedModToString(); + var aliasAST = importDeclAST.alias.nodeType() === 11 /* TypeRef */ ? (importDeclAST.alias).term : importDeclAST.alias; + + this.emitJavascript(aliasAST, false); + this.recordSourceMappingEnd(importDeclAST); + this.writeToOutput(";"); + + if (needsPropertyAssignment) { + this.writeLineToOutput(""); + this.emitIndent(); + this.recordSourceMappingStart(importDeclAST); + this.writeToOutput(moduleNamePrefix + importDeclAST.id.actualText + " = " + importDeclAST.id.actualText); + this.recordSourceMappingEnd(importDeclAST); + this.writeToOutput(";"); + } + this.emitComments(importDeclAST, false); + + this.modAliasId = prevModAliasId; + this.firstModAlias = prevFirstModAlias; + } + }; + + Emitter.prototype.setSourceMappings = function (mapper) { + this.allSourceMappers.push(mapper); + this.sourceMapper = mapper; + }; + + Emitter.prototype.updateLineAndColumn = function (s) { + var lineNumbers = TypeScript.TextUtilities.parseLineStarts(TypeScript.TextFactory.createText(s)); + if (lineNumbers.length > 1) { + this.emitState.line += lineNumbers.length - 1; + this.emitState.column = s.length - lineNumbers[lineNumbers.length - 1]; + } else { + this.emitState.column += s.length; + } + }; + + Emitter.prototype.writeToOutput = function (s) { + this.outfile.Write(s); + this.updateLineAndColumn(s); + }; + + Emitter.prototype.writeToOutputTrimmable = function (s) { + this.writeToOutput(s); + }; + + Emitter.prototype.writeLineToOutput = function (s) { + this.outfile.WriteLine(s); + this.updateLineAndColumn(s); + this.emitState.column = 0; + this.emitState.line++; + }; + + Emitter.prototype.writeCaptureThisStatement = function (ast) { + this.emitIndent(); + this.recordSourceMappingStart(ast); + this.writeToOutput(this.captureThisStmtString); + this.recordSourceMappingEnd(ast); + this.writeLineToOutput(""); + }; + + Emitter.prototype.setInVarBlock = function (count) { + this.varListCountStack[this.varListCountStack.length - 1] = count; + }; + + Emitter.prototype.setContainer = function (c) { + var temp = this.emitState.container; + this.emitState.container = c; + return temp; + }; + + Emitter.prototype.getIndentString = function () { + return this.indenter.getIndent(); + }; + + Emitter.prototype.emitIndent = function () { + this.writeToOutput(this.getIndentString()); + }; + + Emitter.prototype.emitComment = function (comment) { + if (this.emitOptions.compilationSettings.removeComments) { + return; + } + + var text = comment.getText(); + var emitColumn = this.emitState.column; + + if (emitColumn === 0) { + this.emitIndent(); + } + + if (comment.isBlockComment) { + this.recordSourceMappingStart(comment); + this.writeToOutput(text[0]); + + if (text.length > 1 || comment.endsLine) { + for (var i = 1; i < text.length; i++) { + this.writeLineToOutput(""); + this.emitIndent(); + this.writeToOutput(text[i]); + } + this.recordSourceMappingEnd(comment); + this.writeLineToOutput(""); + } else { + this.recordSourceMappingEnd(comment); + this.writeToOutput(" "); + return; + } + } else { + this.recordSourceMappingStart(comment); + this.writeToOutput(text[0]); + this.recordSourceMappingEnd(comment); + this.writeLineToOutput(""); + } + + if (emitColumn != 0) { + this.emitIndent(); + } + }; + + Emitter.prototype.emitComments = function (ast, pre) { + var comments; + if (pre) { + var preComments = ast.preComments(); + if (preComments && ast === this.copyrightElement) { + var copyrightComments = this.getCopyrightComments(); + comments = preComments.slice(copyrightComments.length); + } else { + comments = preComments; + } + } else { + comments = ast.postComments(); + } + + this.emitCommentsArray(comments); + }; + + Emitter.prototype.emitCommentsArray = function (comments) { + if (!this.emitOptions.compilationSettings.removeComments && comments) { + for (var i = 0, n = comments.length; i < n; i++) { + this.emitComment(comments[i]); + } + } + }; + + Emitter.prototype.emitObjectLiteral = function (objectLiteral) { + var useNewLines = !TypeScript.hasFlag(objectLiteral.getFlags(), 2 /* SingleLine */); + + this.writeToOutput("{"); + var list = objectLiteral.operand; + if (list.members.length > 0) { + if (useNewLines) { + this.writeLineToOutput(""); + } else { + this.writeToOutput(" "); + } + + this.indenter.increaseIndent(); + this.emitCommaSeparatedList(list, useNewLines); + this.indenter.decreaseIndent(); + if (useNewLines) { + this.emitIndent(); + } else { + this.writeToOutput(" "); + } + } + this.writeToOutput("}"); + }; + + Emitter.prototype.emitArrayLiteral = function (arrayLiteral) { + var useNewLines = !TypeScript.hasFlag(arrayLiteral.getFlags(), 2 /* SingleLine */); + + this.writeToOutput("["); + var list = arrayLiteral.operand; + if (list.members.length > 0) { + if (useNewLines) { + this.writeLineToOutput(""); + } + + this.indenter.increaseIndent(); + this.emitCommaSeparatedList(list, useNewLines); + this.indenter.decreaseIndent(); + if (useNewLines) { + this.emitIndent(); + } + } + this.writeToOutput("]"); + }; + + Emitter.prototype.emitNew = function (objectCreationExpression, target, args) { + this.writeToOutput("new "); + if (target.nodeType() === 11 /* TypeRef */) { + var typeRef = target; + if (typeRef.arrayCount) { + this.writeToOutput("Array()"); + } else { + typeRef.term.emit(this); + this.writeToOutput("()"); + } + } else { + target.emit(this); + this.recordSourceMappingStart(args); + this.writeToOutput("("); + this.emitCommaSeparatedList(args); + this.recordSourceMappingStart(objectCreationExpression.closeParenSpan); + this.writeToOutput(")"); + this.recordSourceMappingEnd(objectCreationExpression.closeParenSpan); + this.recordSourceMappingEnd(args); + } + }; + + Emitter.prototype.getVarDeclFromIdentifier = function (boundDeclInfo) { + TypeScript.CompilerDiagnostics.assert(boundDeclInfo.boundDecl && boundDeclInfo.boundDecl.init && boundDeclInfo.boundDecl.init.nodeType() === 21 /* Name */, "The init expression of bound declaration when emitting as constant has to be indentifier"); + + var init = boundDeclInfo.boundDecl.init; + var ident = init; + + var pullSymbol = this.semanticInfoChain.getSymbolForAST(boundDeclInfo.boundDecl, this.document.fileName); + + if (pullSymbol) { + var pullDecls = pullSymbol.getDeclarations(); + if (pullDecls.length === 1) { + var pullDecl = pullDecls[0]; + var ast = this.semanticInfoChain.getASTForDecl(pullDecl); + if (ast && ast.nodeType() === 18 /* VariableDeclarator */) { + return { boundDecl: ast, pullDecl: pullDecl }; + } + } + } + + return null; + }; + + Emitter.prototype.getConstantDecl = function (dotExpr) { + var pullSymbol = this.semanticInfoChain.getSymbolForAST(dotExpr, this.document.fileName); + if (pullSymbol && pullSymbol.hasFlag(524288 /* Constant */)) { + var pullDecls = pullSymbol.getDeclarations(); + if (pullDecls.length === 1) { + var pullDecl = pullDecls[0]; + var ast = this.semanticInfoChain.getASTForDecl(pullDecl); + if (ast && ast.nodeType() === 18 /* VariableDeclarator */) { + return { boundDecl: ast, pullDecl: pullDecl }; + } + } + } + + return null; + }; + + Emitter.prototype.tryEmitConstant = function (dotExpr) { + if (!this.emitOptions.compilationSettings.propagateEnumConstants) { + return false; + } + var propertyName = dotExpr.operand2; + var boundDeclInfo = this.getConstantDecl(dotExpr); + if (boundDeclInfo) { + var value = boundDeclInfo.boundDecl.constantValue; + if (value !== null) { + this.writeToOutput(value.toString()); + var comment = " /* "; + comment += propertyName.actualText; + comment += " */"; + this.writeToOutput(comment); + return true; + } + } + + return false; + }; + + Emitter.prototype.emitCall = function (callNode, target, args) { + if (!this.emitSuperCall(callNode)) { + if (target.nodeType() === 13 /* FunctionDeclaration */) { + this.writeToOutput("("); + } + if (callNode.target.nodeType() === 31 /* SuperExpression */ && this.emitState.container === 4 /* Constructor */) { + this.writeToOutput("_super.call"); + } else { + this.emitJavascript(target, false); + } + if (target.nodeType() === 13 /* FunctionDeclaration */) { + this.writeToOutput(")"); + } + this.recordSourceMappingStart(args); + this.writeToOutput("("); + if (callNode.target.nodeType() === 31 /* SuperExpression */ && this.emitState.container === 4 /* Constructor */) { + this.writeToOutput("this"); + if (args && args.members.length) { + this.writeToOutput(", "); + } + } + this.emitCommaSeparatedList(args); + this.recordSourceMappingStart(callNode.closeParenSpan); + this.writeToOutput(")"); + this.recordSourceMappingEnd(callNode.closeParenSpan); + this.recordSourceMappingEnd(args); + } + }; + + Emitter.prototype.emitInnerFunction = function (funcDecl, printName, includePreComments) { + if (typeof includePreComments === "undefined") { includePreComments = true; } + var pullDecl = this.semanticInfoChain.getDeclForAST(funcDecl, this.document.fileName); + this.pushDecl(pullDecl); + + var shouldParenthesize = false; + + if (includePreComments) { + this.emitComments(funcDecl, true); + } + + if (shouldParenthesize) { + this.writeToOutput("("); + } + this.recordSourceMappingStart(funcDecl); + var accessorSymbol = funcDecl.isAccessor() ? TypeScript.PullHelpers.getAccessorSymbol(funcDecl, this.semanticInfoChain, this.document.fileName) : null; + var container = accessorSymbol ? accessorSymbol.getContainer() : null; + var containerKind = container ? container.kind : 0 /* None */; + if (!(funcDecl.isAccessor() && containerKind !== 8 /* Class */ && containerKind !== 33554432 /* ConstructorType */)) { + this.writeToOutput("function "); + } + + if (funcDecl.isConstructor) { + this.writeToOutput(this.thisClassNode.name.actualText); + } + + if (printName) { + var id = funcDecl.getNameText(); + if (id && !funcDecl.isAccessor()) { + if (funcDecl.name) { + this.recordSourceMappingStart(funcDecl.name); + } + this.writeToOutput(id); + if (funcDecl.name) { + this.recordSourceMappingEnd(funcDecl.name); + } + } + } + + this.writeToOutput("("); + var argsLen = 0; + if (funcDecl.arguments) { + this.emitComments(funcDecl.arguments, true); + + var tempContainer = this.setContainer(6 /* Args */); + argsLen = funcDecl.arguments.members.length; + var printLen = argsLen; + if (funcDecl.variableArgList) { + printLen--; + } + for (var i = 0; i < printLen; i++) { + var arg = funcDecl.arguments.members[i]; + arg.emit(this); + + if (i < (printLen - 1)) { + this.writeToOutput(", "); + } + } + this.setContainer(tempContainer); + + this.emitComments(funcDecl.arguments, false); + } + this.writeLineToOutput(") {"); + + if (funcDecl.isConstructor) { + this.recordSourceMappingNameStart("constructor"); + } else if (funcDecl.isGetAccessor()) { + this.recordSourceMappingNameStart("get_" + funcDecl.getNameText()); + } else if (funcDecl.isSetAccessor()) { + this.recordSourceMappingNameStart("set_" + funcDecl.getNameText()); + } else { + this.recordSourceMappingNameStart(funcDecl.getNameText()); + } + this.indenter.increaseIndent(); + + this.emitDefaultValueAssignments(funcDecl); + this.emitRestParameterInitializer(funcDecl); + + if (this.shouldCaptureThis(funcDecl)) { + this.writeCaptureThisStatement(funcDecl); + } + + if (funcDecl.isConstructor) { + this.emitConstructorStatements(funcDecl); + } else { + this.emitModuleElements(funcDecl.block.statements); + } + + this.emitCommentsArray(funcDecl.block.closeBraceLeadingComments); + + this.indenter.decreaseIndent(); + this.emitIndent(); + this.recordSourceMappingStart(funcDecl.block.closeBraceSpan); + this.writeToOutput("}"); + + this.recordSourceMappingNameEnd(); + this.recordSourceMappingEnd(funcDecl.block.closeBraceSpan); + this.recordSourceMappingEnd(funcDecl); + + if (shouldParenthesize) { + this.writeToOutput(")"); + } + + this.recordSourceMappingEnd(funcDecl); + + this.emitComments(funcDecl, false); + + this.popDecl(pullDecl); + }; + + Emitter.prototype.emitDefaultValueAssignments = function (funcDecl) { + var n = funcDecl.arguments.members.length; + if (funcDecl.variableArgList) { + n--; + } + + for (var i = 0; i < n; i++) { + var arg = funcDecl.arguments.members[i]; + if (arg.init) { + this.emitIndent(); + this.recordSourceMappingStart(arg); + this.writeToOutput("if (typeof " + arg.id.actualText + " === \"undefined\") { "); + this.recordSourceMappingStart(arg.id); + this.writeToOutput(arg.id.actualText); + this.recordSourceMappingEnd(arg.id); + this.writeToOutput(" = "); + this.emitJavascript(arg.init, false); + this.writeLineToOutput("; }"); + this.recordSourceMappingEnd(arg); + } + } + }; + + Emitter.prototype.emitRestParameterInitializer = function (funcDecl) { + if (funcDecl.variableArgList) { + var n = funcDecl.arguments.members.length; + var lastArg = funcDecl.arguments.members[n - 1]; + this.emitIndent(); + this.recordSourceMappingStart(lastArg); + this.writeToOutput("var "); + this.recordSourceMappingStart(lastArg.id); + this.writeToOutput(lastArg.id.actualText); + this.recordSourceMappingEnd(lastArg.id); + this.writeLineToOutput(" = [];"); + this.recordSourceMappingEnd(lastArg); + this.emitIndent(); + this.writeToOutput("for ("); + this.recordSourceMappingStart(lastArg); + this.writeToOutput("var _i = 0;"); + this.recordSourceMappingEnd(lastArg); + this.writeToOutput(" "); + this.recordSourceMappingStart(lastArg); + this.writeToOutput("_i < (arguments.length - " + (n - 1) + ")"); + this.recordSourceMappingEnd(lastArg); + this.writeToOutput("; "); + this.recordSourceMappingStart(lastArg); + this.writeToOutput("_i++"); + this.recordSourceMappingEnd(lastArg); + this.writeLineToOutput(") {"); + this.indenter.increaseIndent(); + this.emitIndent(); + + this.recordSourceMappingStart(lastArg); + this.writeToOutput(lastArg.id.actualText + "[_i] = arguments[_i + " + (n - 1) + "];"); + this.recordSourceMappingEnd(lastArg); + this.writeLineToOutput(""); + this.indenter.decreaseIndent(); + this.emitIndent(); + this.writeLineToOutput("}"); + } + }; + + Emitter.prototype.getImportDecls = function (fileName) { + var semanticInfo = this.semanticInfoChain.getUnit(this.document.fileName); + var result = []; + + var queue = semanticInfo.getTopLevelDecls(); + + while (queue.length > 0) { + var decl = queue.shift(); + + if (decl.kind & 256 /* TypeAlias */) { + var importStatementAST = semanticInfo.getASTForDecl(decl); + if (importStatementAST.alias.nodeType() === 21 /* Name */) { + var text = (importStatementAST.alias).actualText; + if (TypeScript.isQuoted(text)) { + var symbol = decl.getSymbol(); + var typeSymbol = symbol && symbol.type; + if (typeSymbol && typeSymbol !== this.semanticInfoChain.anyTypeSymbol && !typeSymbol.isError()) { + result.push(decl); + } + } + } + } + + queue = queue.concat(decl.getChildDecls()); + } + + return result; + }; + + Emitter.prototype.getModuleImportAndDependencyList = function (moduleDecl) { + var importList = ""; + var dependencyList = ""; + + var semanticInfo = this.semanticInfoChain.getUnit(this.document.fileName); + var importDecls = this.getImportDecls(this.document.fileName); + + if (importDecls.length) { + for (var i = 0; i < importDecls.length; i++) { + var importStatementDecl = importDecls[i]; + var importStatementSymbol = importStatementDecl.getSymbol(); + var importStatementAST = semanticInfo.getASTForDecl(importStatementDecl); + + if (importStatementSymbol.isUsedAsValue) { + if (i <= importDecls.length - 1) { + dependencyList += ", "; + importList += ", "; + } + + importList += "__" + importStatementDecl.name + "__"; + dependencyList += importStatementAST.firstAliasedModToString(); + } + } + } + + for (var i = 0; i < moduleDecl.amdDependencies.length; i++) { + dependencyList += ", \"" + moduleDecl.amdDependencies[i] + "\""; + } + + return { + importList: importList, + dependencyList: dependencyList + }; + }; + + Emitter.prototype.shouldCaptureThis = function (ast) { + if (ast.nodeType() === 2 /* Script */) { + var scriptDecl = this.semanticInfoChain.getUnit(this.document.fileName).getTopLevelDecls()[0]; + return (scriptDecl.flags & 262144 /* MustCaptureThis */) === 262144 /* MustCaptureThis */; + } + + var decl = this.semanticInfoChain.getDeclForAST(ast, this.document.fileName); + if (decl) { + return (decl.flags & 262144 /* MustCaptureThis */) === 262144 /* MustCaptureThis */; + } + + return false; + }; + + Emitter.prototype.emitModule = function (moduleDecl) { + var pullDecl = this.semanticInfoChain.getDeclForAST(moduleDecl, this.document.fileName); + this.pushDecl(pullDecl); + + var svModuleName = this.moduleName; + this.moduleName = moduleDecl.name.actualText; + if (TypeScript.isTSFile(this.moduleName)) { + this.moduleName = this.moduleName.substring(0, this.moduleName.length - ".ts".length); + } + + var isDynamicMod = TypeScript.hasFlag(moduleDecl.getModuleFlags(), 512 /* IsDynamic */); + var prevOutFile = this.outfile; + var prevOutFileName = this.emittingFileName; + var prevAllSourceMappers = this.allSourceMappers; + var prevSourceMapper = this.sourceMapper; + var prevColumn = this.emitState.column; + var prevLine = this.emitState.line; + var temp = this.setContainer(1 /* Module */); + var isExported = TypeScript.hasFlag(pullDecl.flags, 1 /* Exported */); + var isWholeFile = TypeScript.hasFlag(moduleDecl.getModuleFlags(), 256 /* IsWholeFile */); + + if (isDynamicMod) { + this.setExportAssignmentIdentifier(null); + this.setContainer(2 /* DynamicModule */); + + this.recordSourceMappingStart(moduleDecl); + if (this.emitOptions.compilationSettings.moduleGenTarget === 2 /* Asynchronous */) { + var dependencyList = "[\"require\", \"exports\""; + var importList = "require, exports"; + + var importAndDependencyList = this.getModuleImportAndDependencyList(moduleDecl); + importList += importAndDependencyList.importList; + dependencyList += importAndDependencyList.dependencyList + "]"; + + this.writeLineToOutput("define(" + dependencyList + "," + " function(" + importList + ") {"); + } + } else { + if (!isExported) { + this.recordSourceMappingStart(moduleDecl); + this.writeToOutput("var "); + this.recordSourceMappingStart(moduleDecl.name); + this.writeToOutput(this.moduleName); + this.recordSourceMappingEnd(moduleDecl.name); + this.writeLineToOutput(";"); + this.recordSourceMappingEnd(moduleDecl); + this.emitIndent(); + } + + this.writeToOutput("("); + this.recordSourceMappingStart(moduleDecl); + this.writeToOutput("function ("); + this.recordSourceMappingStart(moduleDecl.name); + this.writeToOutput(this.moduleName); + this.recordSourceMappingEnd(moduleDecl.name); + this.writeLineToOutput(") {"); + } + + if (!isWholeFile) { + this.recordSourceMappingNameStart(this.moduleName); + } + + if (!isDynamicMod || this.emitOptions.compilationSettings.moduleGenTarget === 2 /* Asynchronous */) { + this.indenter.increaseIndent(); + } + + if (this.shouldCaptureThis(moduleDecl)) { + this.writeCaptureThisStatement(moduleDecl); + } + + this.emitModuleElements(moduleDecl.members); + if (!isDynamicMod || this.emitOptions.compilationSettings.moduleGenTarget === 2 /* Asynchronous */) { + this.indenter.decreaseIndent(); + } + this.emitIndent(); + + if (isDynamicMod) { + var exportAssignmentIdentifier = this.getExportAssignmentIdentifier(); + var exportAssignmentValueSymbol = (pullDecl.getSymbol()).getExportAssignedValueSymbol(); + + if (this.emitOptions.compilationSettings.moduleGenTarget === 2 /* Asynchronous */) { + if (exportAssignmentIdentifier && exportAssignmentValueSymbol && !(exportAssignmentValueSymbol.kind & TypeScript.PullElementKind.SomeTypeReference)) { + this.indenter.increaseIndent(); + this.emitIndent(); + this.writeLineToOutput("return " + exportAssignmentIdentifier + ";"); + this.indenter.decreaseIndent(); + } + this.writeToOutput("});"); + } else if (exportAssignmentIdentifier && exportAssignmentValueSymbol && !(exportAssignmentValueSymbol.kind & TypeScript.PullElementKind.SomeTypeReference)) { + this.emitIndent(); + this.writeLineToOutput("module.exports = " + exportAssignmentIdentifier + ";"); + } + + if (!isWholeFile) { + this.recordSourceMappingNameEnd(); + } + this.recordSourceMappingEnd(moduleDecl); + + if (this.outfile !== prevOutFile) { + this.emitSourceMapsAndClose(); + if (prevSourceMapper !== null) { + this.allSourceMappers = prevAllSourceMappers; + this.sourceMapper = prevSourceMapper; + this.emitState.column = prevColumn; + this.emitState.line = prevLine; + } + this.outfile = prevOutFile; + this.emittingFileName = prevOutFileName; + } + } else { + var parentIsDynamic = temp === 2 /* DynamicModule */; + this.recordSourceMappingStart(moduleDecl.endingToken); + if (temp === 0 /* Prog */ && isExported) { + this.writeToOutput("}"); + if (!isWholeFile) { + this.recordSourceMappingNameEnd(); + } + this.recordSourceMappingEnd(moduleDecl.endingToken); + this.writeToOutput(")(this." + this.moduleName + " || (this." + this.moduleName + " = {}));"); + } else if (isExported || temp === 0 /* Prog */) { + var dotMod = svModuleName !== "" ? (parentIsDynamic ? "exports" : svModuleName) + "." : svModuleName; + this.writeToOutput("}"); + if (!isWholeFile) { + this.recordSourceMappingNameEnd(); + } + this.recordSourceMappingEnd(moduleDecl.endingToken); + this.writeToOutput(")(" + dotMod + this.moduleName + " || (" + dotMod + this.moduleName + " = {}));"); + } else if (!isExported && temp !== 0 /* Prog */) { + this.writeToOutput("}"); + if (!isWholeFile) { + this.recordSourceMappingNameEnd(); + } + this.recordSourceMappingEnd(moduleDecl.endingToken); + this.writeToOutput(")(" + this.moduleName + " || (" + this.moduleName + " = {}));"); + } else { + this.writeToOutput("}"); + if (!isWholeFile) { + this.recordSourceMappingNameEnd(); + } + this.recordSourceMappingEnd(moduleDecl.endingToken); + this.writeToOutput(")();"); + } + + this.recordSourceMappingEnd(moduleDecl); + if (temp !== 0 /* Prog */ && isExported) { + this.recordSourceMappingStart(moduleDecl); + if (parentIsDynamic) { + this.writeLineToOutput(""); + this.emitIndent(); + this.writeToOutput("var " + this.moduleName + " = exports." + this.moduleName + ";"); + } else { + this.writeLineToOutput(""); + this.emitIndent(); + this.writeToOutput("var " + this.moduleName + " = " + svModuleName + "." + this.moduleName + ";"); + } + this.recordSourceMappingEnd(moduleDecl); + } + } + + this.setContainer(temp); + this.moduleName = svModuleName; + + this.popDecl(pullDecl); + }; + + Emitter.prototype.emitEnumElement = function (varDecl) { + this.emitComments(varDecl, true); + this.recordSourceMappingStart(varDecl); + var name = varDecl.id.actualText; + var quoted = TypeScript.isQuoted(name); + this.writeToOutput(this.moduleName); + this.writeToOutput('['); + this.writeToOutput(this.moduleName); + this.writeToOutput('['); + this.writeToOutput(quoted ? name : '"' + name + '"'); + this.writeToOutput('] = '); + + if (varDecl.init) { + varDecl.init.emit(this); + } else if (varDecl.constantValue !== null) { + this.writeToOutput(varDecl.constantValue.toString()); + } else { + this.writeToOutput("null"); + } + + this.writeToOutput('] = '); + this.writeToOutput(quoted ? name : '"' + name + '"'); + this.recordSourceMappingEnd(varDecl); + this.emitComments(varDecl, false); + this.writeToOutput(';'); + }; + + Emitter.prototype.emitIndex = function (operand1, operand2) { + operand1.emit(this); + this.writeToOutput("["); + operand2.emit(this); + this.writeToOutput("]"); + }; + + Emitter.prototype.emitFunction = function (funcDecl) { + if (TypeScript.hasFlag(funcDecl.getFunctionFlags(), 128 /* Signature */)) { + return; + } + var temp; + var tempFnc = this.thisFunctionDeclaration; + this.thisFunctionDeclaration = funcDecl; + + if (funcDecl.isConstructor) { + temp = this.setContainer(4 /* Constructor */); + } else { + temp = this.setContainer(5 /* Function */); + } + + var funcName = funcDecl.getNameText(); + + if (((temp !== 4 /* Constructor */) || ((funcDecl.getFunctionFlags() & 256 /* Method */) === 0 /* None */))) { + this.recordSourceMappingStart(funcDecl); + this.emitInnerFunction(funcDecl, (funcDecl.name && !funcDecl.name.isMissing())); + } + this.setContainer(temp); + this.thisFunctionDeclaration = tempFnc; + + if (!TypeScript.hasFlag(funcDecl.getFunctionFlags(), 128 /* Signature */)) { + var pullFunctionDecl = this.semanticInfoChain.getDeclForAST(funcDecl, this.document.fileName); + if (TypeScript.hasFlag(funcDecl.getFunctionFlags(), 16 /* Static */)) { + if (this.thisClassNode) { + this.writeLineToOutput(""); + if (funcDecl.isAccessor()) { + this.emitPropertyAccessor(funcDecl, this.thisClassNode.name.actualText, false); + } else { + this.emitIndent(); + this.recordSourceMappingStart(funcDecl); + this.writeToOutput(this.thisClassNode.name.actualText + "." + funcName + " = " + funcName + ";"); + this.recordSourceMappingEnd(funcDecl); + } + } + } else if ((this.emitState.container === 1 /* Module */ || this.emitState.container === 2 /* DynamicModule */) && TypeScript.hasFlag(pullFunctionDecl.flags, 1 /* Exported */)) { + this.writeLineToOutput(""); + this.emitIndent(); + var modName = this.emitState.container === 1 /* Module */ ? this.moduleName : "exports"; + this.recordSourceMappingStart(funcDecl); + this.writeToOutput(modName + "." + funcName + " = " + funcName + ";"); + this.recordSourceMappingEnd(funcDecl); + } + } + }; + + Emitter.prototype.emitAmbientVarDecl = function (varDecl) { + if (varDecl.init) { + this.emitComments(varDecl, true); + this.recordSourceMappingStart(varDecl); + this.recordSourceMappingStart(varDecl.id); + this.writeToOutput(varDecl.id.actualText); + this.recordSourceMappingEnd(varDecl.id); + this.writeToOutput(" = "); + this.emitJavascript(varDecl.init, false); + this.recordSourceMappingEnd(varDecl); + this.emitComments(varDecl, false); + } + }; + + Emitter.prototype.varListCount = function () { + return this.varListCountStack[this.varListCountStack.length - 1]; + }; + + Emitter.prototype.emitVarDeclVar = function () { + if (this.varListCount() >= 0) { + this.writeToOutput("var "); + this.setInVarBlock(-this.varListCount()); + } + return true; + }; + + Emitter.prototype.onEmitVar = function () { + if (this.varListCount() > 0) { + this.setInVarBlock(this.varListCount() - 1); + } else if (this.varListCount() < 0) { + this.setInVarBlock(this.varListCount() + 1); + } + }; + + Emitter.prototype.emitVariableDeclaration = function (declaration) { + var varDecl = declaration.declarators.members[0]; + + var symbol = this.semanticInfoChain.getSymbolForAST(varDecl, this.document.fileName); + + var parentSymbol = symbol ? symbol.getContainer() : null; + var parentKind = parentSymbol ? parentSymbol.kind : 0 /* None */; + var inClass = parentKind === 8 /* Class */; + + this.emitComments(declaration, true); + this.recordSourceMappingStart(declaration); + this.setInVarBlock(declaration.declarators.members.length); + + var pullVarDecl = this.semanticInfoChain.getDeclForAST(varDecl, this.document.fileName); + var isAmbientWithoutInit = pullVarDecl && TypeScript.hasFlag(pullVarDecl.flags, 8 /* Ambient */) && varDecl.init === null; + if (!isAmbientWithoutInit) { + for (var i = 0, n = declaration.declarators.members.length; i < n; i++) { + var declarator = declaration.declarators.members[i]; + + if (i > 0) { + if (inClass) { + this.writeToOutputTrimmable(";"); + } else { + this.writeToOutputTrimmable(", "); + } + } + + declarator.emit(this); + } + } + + this.recordSourceMappingEnd(declaration); + this.emitComments(declaration, false); + }; + + Emitter.prototype.emitVariableDeclarator = function (varDecl) { + var pullDecl = this.semanticInfoChain.getDeclForAST(varDecl, this.document.fileName); + this.pushDecl(pullDecl); + if ((pullDecl.flags & 8 /* Ambient */) === 8 /* Ambient */) { + this.emitAmbientVarDecl(varDecl); + this.onEmitVar(); + } else { + this.emitComments(varDecl, true); + this.recordSourceMappingStart(varDecl); + + var symbol = this.semanticInfoChain.getSymbolForAST(varDecl, this.document.fileName); + var parentSymbol = symbol ? symbol.getContainer() : null; + var parentKind = parentSymbol ? parentSymbol.kind : 0 /* None */; + var associatedParentSymbol = parentSymbol ? parentSymbol.getAssociatedContainerType() : null; + var associatedParentSymbolKind = associatedParentSymbol ? associatedParentSymbol.kind : 0 /* None */; + if (parentKind === 8 /* Class */) { + if (this.emitState.container !== 6 /* Args */) { + if (varDecl.isStatic()) { + this.writeToOutput(parentSymbol.getName() + "."); + } else { + this.writeToOutput("this."); + } + } + } else if (TypeScript.PullHelpers.symbolIsModule(parentSymbol) || TypeScript.PullHelpers.symbolIsEnum(parentSymbol) || TypeScript.PullHelpers.symbolIsModule(associatedParentSymbol) || TypeScript.PullHelpers.symbolIsEnum(associatedParentSymbol) || parentKind === 32 /* DynamicModule */ || associatedParentSymbolKind === 32 /* DynamicModule */) { + if (!TypeScript.hasFlag(pullDecl.flags, 1 /* Exported */) && !varDecl.isProperty()) { + this.emitVarDeclVar(); + } else { + if (this.emitState.container === 2 /* DynamicModule */) { + this.writeToOutput("exports."); + } else { + this.writeToOutput(this.moduleName + "."); + } + } + } else { + this.emitVarDeclVar(); + } + + this.recordSourceMappingStart(varDecl.id); + this.writeToOutput(varDecl.id.actualText); + this.recordSourceMappingEnd(varDecl.id); + var hasInitializer = (varDecl.init !== null); + if (hasInitializer) { + this.writeToOutputTrimmable(" = "); + + this.varListCountStack.push(0); + varDecl.init.emit(this); + this.varListCountStack.pop(); + } + + if (parentKind === 8 /* Class */) { + if (this.emitState.container !== 6 /* Args */) { + this.writeToOutput(";"); + } + } + + this.onEmitVar(); + + this.recordSourceMappingEnd(varDecl); + this.emitComments(varDecl, false); + } + this.popDecl(pullDecl); + }; + + Emitter.prototype.symbolIsUsedInItsEnclosingContainer = function (symbol, dynamic) { + if (typeof dynamic === "undefined") { dynamic = false; } + var symDecls = symbol.getDeclarations(); + + if (symDecls.length) { + var enclosingDecl = this.getEnclosingDecl(); + if (enclosingDecl) { + var parentDecl = symDecls[0].getParentDecl(); + if (parentDecl) { + var symbolDeclarationEnclosingContainer = parentDecl; + var enclosingContainer = enclosingDecl; + + while (symbolDeclarationEnclosingContainer) { + if (symbolDeclarationEnclosingContainer.kind === (dynamic ? 32 /* DynamicModule */ : 4 /* Container */)) { + break; + } + symbolDeclarationEnclosingContainer = symbolDeclarationEnclosingContainer.getParentDecl(); + } + + if (symbolDeclarationEnclosingContainer) { + while (enclosingContainer) { + if (enclosingContainer.kind === (dynamic ? 32 /* DynamicModule */ : 4 /* Container */)) { + break; + } + + enclosingContainer = enclosingContainer.getParentDecl(); + } + } + + if (symbolDeclarationEnclosingContainer && enclosingContainer) { + var same = symbolDeclarationEnclosingContainer === enclosingContainer; + + if (!same && symbol.hasFlag(32768 /* InitializedModule */)) { + same = symbolDeclarationEnclosingContainer === enclosingContainer.getParentDecl(); + } + + return same; + } + } + } + } + + return false; + }; + + Emitter.prototype.emitName = function (name, addThis) { + this.emitComments(name, true); + this.recordSourceMappingStart(name); + if (!name.isMissing()) { + var pullSymbol = this.semanticInfoChain.getSymbolForAST(name, this.document.fileName); + if (!pullSymbol) { + pullSymbol = this.semanticInfoChain.anyTypeSymbol; + } + var pullSymbolAlias = this.semanticInfoChain.getAliasSymbolForAST(name, this.document.fileName); + if (pullSymbol && pullSymbolAlias) { + var symbolToCompare = this.resolvingContext.resolvingTypeReference ? pullSymbolAlias.getExportAssignedTypeSymbol() : pullSymbolAlias.getExportAssignedValueSymbol(); + + if (pullSymbol == symbolToCompare) { + pullSymbol = pullSymbolAlias; + pullSymbolAlias = null; + } + } + + var pullSymbolKind = pullSymbol.kind; + var isLocalAlias = pullSymbolAlias && (pullSymbolAlias.getDeclarations()[0].getParentDecl() == this.getEnclosingDecl()); + if (addThis && (this.emitState.container !== 6 /* Args */) && pullSymbol) { + var pullSymbolContainer = pullSymbol.getContainer(); + + if (pullSymbolContainer) { + var pullSymbolContainerKind = pullSymbolContainer.kind; + + if (pullSymbolContainerKind === 8 /* Class */) { + if (pullSymbol.hasFlag(16 /* Static */)) { + this.writeToOutput(pullSymbolContainer.getName() + "."); + } else if (pullSymbolKind === 4096 /* Property */) { + this.emitThis(); + this.writeToOutput("."); + } + } else if (TypeScript.PullHelpers.symbolIsModule(pullSymbolContainer) || pullSymbolContainerKind === 64 /* Enum */ || pullSymbolContainer.hasFlag(32768 /* InitializedModule */ | 131072 /* InitializedEnum */)) { + if (pullSymbolKind === 4096 /* Property */ || pullSymbolKind === 67108864 /* EnumMember */) { + this.writeToOutput(pullSymbolContainer.getDisplayName() + "."); + } else if (pullSymbol.hasFlag(1 /* Exported */) && pullSymbolKind === 1024 /* Variable */ && !pullSymbol.hasFlag(32768 /* InitializedModule */ | 131072 /* InitializedEnum */)) { + this.writeToOutput(pullSymbolContainer.getDisplayName() + "."); + } else if (pullSymbol.hasFlag(1 /* Exported */) && !this.symbolIsUsedInItsEnclosingContainer(pullSymbol)) { + this.writeToOutput(pullSymbolContainer.getDisplayName() + "."); + } + } else if (pullSymbolContainerKind === 32 /* DynamicModule */ || pullSymbolContainer.hasFlag(65536 /* InitializedDynamicModule */)) { + if (pullSymbolKind === 4096 /* Property */) { + this.writeToOutput("exports."); + } else if (pullSymbol.hasFlag(1 /* Exported */) && !isLocalAlias && !pullSymbol.hasFlag(TypeScript.PullElementFlags.ImplicitVariable) && pullSymbol.kind !== 32768 /* ConstructorMethod */ && pullSymbol.kind !== 8 /* Class */ && pullSymbol.kind !== 64 /* Enum */) { + this.writeToOutput("exports."); + } + } else if (pullSymbolKind === 4096 /* Property */) { + if (pullSymbolContainer.kind === 8 /* Class */) { + this.emitThis(); + this.writeToOutput("."); + } + } else { + var pullDecls = pullSymbol.getDeclarations(); + var emitContainerName = true; + for (var i = 0; i < pullDecls.length; i++) { + if (pullDecls[i].getScriptName() === this.document.fileName) { + emitContainerName = false; + } + } + if (emitContainerName) { + this.writeToOutput(pullSymbolContainer.getName() + "."); + } + } + } + } + + if (pullSymbol && pullSymbolKind === 32 /* DynamicModule */) { + if (this.emitOptions.compilationSettings.moduleGenTarget === 2 /* Asynchronous */) { + this.writeToOutput("__" + this.modAliasId + "__"); + } else { + var moduleDecl = this.semanticInfoChain.getASTForSymbol(pullSymbol, this.document.fileName); + var modPath = name.actualText; + var isAmbient = pullSymbol.hasFlag(8 /* Ambient */); + modPath = isAmbient ? modPath : this.firstModAlias ? this.firstModAlias : TypeScript.quoteBaseName(modPath); + modPath = isAmbient ? modPath : (!TypeScript.isRelative(TypeScript.stripQuotes(modPath)) ? TypeScript.quoteStr("./" + TypeScript.stripQuotes(modPath)) : modPath); + this.writeToOutput("require(" + modPath + ")"); + } + } else { + this.writeToOutput(name.actualText); + } + } + + this.recordSourceMappingEnd(name); + this.emitComments(name, false); + }; + + Emitter.prototype.recordSourceMappingNameStart = function (name) { + if (this.sourceMapper) { + var finalName = name; + if (!name) { + finalName = ""; + } else if (this.sourceMapper.currentNameIndex.length > 0) { + finalName = this.sourceMapper.names[this.sourceMapper.currentNameIndex[this.sourceMapper.currentNameIndex.length - 1]] + "." + name; + } + + this.sourceMapper.names.push(finalName); + this.sourceMapper.currentNameIndex.push(this.sourceMapper.names.length - 1); + } + }; + + Emitter.prototype.recordSourceMappingNameEnd = function () { + if (this.sourceMapper) { + this.sourceMapper.currentNameIndex.pop(); + } + }; + + Emitter.prototype.recordSourceMappingStart = function (ast) { + if (this.sourceMapper && TypeScript.isValidAstNode(ast)) { + var lineCol = { line: -1, character: -1 }; + var sourceMapping = new TypeScript.SourceMapping(); + sourceMapping.start.emittedColumn = this.emitState.column; + sourceMapping.start.emittedLine = this.emitState.line; + + var lineMap = this.document.lineMap; + lineMap.fillLineAndCharacterFromPosition(ast.minChar, lineCol); + sourceMapping.start.sourceColumn = lineCol.character; + sourceMapping.start.sourceLine = lineCol.line + 1; + lineMap.fillLineAndCharacterFromPosition(ast.limChar, lineCol); + sourceMapping.end.sourceColumn = lineCol.character; + sourceMapping.end.sourceLine = lineCol.line + 1; + if (this.sourceMapper.currentNameIndex.length > 0) { + sourceMapping.nameIndex = this.sourceMapper.currentNameIndex[this.sourceMapper.currentNameIndex.length - 1]; + } + + var siblings = this.sourceMapper.currentMappings[this.sourceMapper.currentMappings.length - 1]; + siblings.push(sourceMapping); + this.sourceMapper.currentMappings.push(sourceMapping.childMappings); + } + }; + + Emitter.prototype.recordSourceMappingEnd = function (ast) { + if (this.sourceMapper && TypeScript.isValidAstNode(ast)) { + this.sourceMapper.currentMappings.pop(); + + var siblings = this.sourceMapper.currentMappings[this.sourceMapper.currentMappings.length - 1]; + var sourceMapping = siblings[siblings.length - 1]; + + sourceMapping.end.emittedColumn = this.emitState.column; + sourceMapping.end.emittedLine = this.emitState.line; + } + }; + + Emitter.prototype.emitSourceMapsAndClose = function () { + if (this.sourceMapper !== null) { + TypeScript.SourceMapper.emitSourceMapping(this.allSourceMappers); + } + + try { + this.outfile.Close(); + } catch (e) { + Emitter.throwEmitterError(e); + } + }; + + Emitter.prototype.emitParameterPropertyAndMemberVariableAssignments = function () { + var constructorDecl = this.thisClassNode.constructorDecl; + + if (constructorDecl && constructorDecl.arguments) { + for (var i = 0, n = constructorDecl.arguments.members.length; i < n; i++) { + var arg = constructorDecl.arguments.members[i]; + if ((arg.getVarFlags() & 256 /* Property */) !== 0 /* None */) { + this.emitIndent(); + this.recordSourceMappingStart(arg); + this.recordSourceMappingStart(arg.id); + this.writeToOutput("this." + arg.id.actualText); + this.recordSourceMappingEnd(arg.id); + this.writeToOutput(" = "); + this.recordSourceMappingStart(arg.id); + this.writeToOutput(arg.id.actualText); + this.recordSourceMappingEnd(arg.id); + this.writeLineToOutput(";"); + this.recordSourceMappingEnd(arg); + } + } + } + + for (var i = 0, n = this.thisClassNode.members.members.length; i < n; i++) { + if (this.thisClassNode.members.members[i].nodeType() === 18 /* VariableDeclarator */) { + var varDecl = this.thisClassNode.members.members[i]; + if (!TypeScript.hasFlag(varDecl.getVarFlags(), 16 /* Static */) && varDecl.init) { + this.emitIndent(); + this.emitVariableDeclarator(varDecl); + this.writeLineToOutput(""); + } + } + } + }; + + Emitter.prototype.emitCommaSeparatedList = function (list, startLine) { + if (typeof startLine === "undefined") { startLine = false; } + if (list === null) { + return; + } else { + for (var i = 0, n = list.members.length; i < n; i++) { + var emitNode = list.members[i]; + this.emitJavascript(emitNode, startLine); + + if (i < (n - 1)) { + this.writeToOutput(startLine ? "," : ", "); + } + + if (startLine) { + this.writeLineToOutput(""); + } + } + } + }; + + Emitter.prototype.emitModuleElements = function (list) { + if (list === null) { + return; + } + + this.emitComments(list, true); + var lastEmittedNode = null; + + for (var i = 0, n = list.members.length; i < n; i++) { + var node = list.members[i]; + + if (node.shouldEmit()) { + this.emitSpaceBetweenConstructs(lastEmittedNode, node); + + this.emitJavascript(node, true); + this.writeLineToOutput(""); + + lastEmittedNode = node; + } + } + + this.emitComments(list, false); + }; + + Emitter.prototype.isDirectivePrologueElement = function (node) { + if (node.nodeType() === 89 /* ExpressionStatement */) { + var exprStatement = node; + return exprStatement.expression.nodeType() === 5 /* StringLiteral */; + } + + return false; + }; + + Emitter.prototype.emitSpaceBetweenConstructs = function (node1, node2) { + if (node1 === null || node2 === null) { + return; + } + + if (node1.minChar === -1 || node1.limChar === -1 || node2.minChar === -1 || node2.limChar === -1) { + return; + } + + var lineMap = this.document.lineMap; + var node1EndLine = lineMap.getLineNumberFromPosition(node1.limChar); + var node2StartLine = lineMap.getLineNumberFromPosition(node2.minChar); + + if ((node2StartLine - node1EndLine) > 1) { + this.writeLineToOutput(""); + } + }; + + Emitter.prototype.getCopyrightComments = function () { + var preComments = this.copyrightElement.preComments(); + if (preComments) { + var lineMap = this.document.lineMap; + + var copyrightComments = []; + var lastComment = null; + + for (var i = 0, n = preComments.length; i < n; i++) { + var comment = preComments[i]; + + if (lastComment) { + var lastCommentLine = lineMap.getLineNumberFromPosition(lastComment.limChar); + var commentLine = lineMap.getLineNumberFromPosition(comment.minChar); + + if (commentLine >= lastCommentLine + 2) { + return copyrightComments; + } + } + + copyrightComments.push(comment); + lastComment = comment; + } + + var lastCommentLine = lineMap.getLineNumberFromPosition(TypeScript.ArrayUtilities.last(copyrightComments).limChar); + var astLine = lineMap.getLineNumberFromPosition(this.copyrightElement.minChar); + if (astLine >= lastCommentLine + 2) { + return copyrightComments; + } + } + + return []; + }; + + Emitter.prototype.emitPossibleCopyrightHeaders = function (script) { + var list = script.moduleElements; + if (list.members.length > 0) { + var firstElement = list.members[0]; + if (firstElement.nodeType() === 16 /* ModuleDeclaration */) { + var moduleDeclaration = firstElement; + if (moduleDeclaration.isWholeFile()) { + firstElement = moduleDeclaration.members.members[0]; + } + } + + this.copyrightElement = firstElement; + this.emitCommentsArray(this.getCopyrightComments()); + } + }; + + Emitter.prototype.emitScriptElements = function (script) { + var list = script.moduleElements; + + this.emitPossibleCopyrightHeaders(script); + + for (var i = 0, n = list.members.length; i < n; i++) { + var node = list.members[i]; + + if (!this.isDirectivePrologueElement(node)) { + break; + } + + this.emitJavascript(node, true); + this.writeLineToOutput(""); + } + + this.emitPrologue(script); + var lastEmittedNode = null; + + for (; i < n; i++) { + var node = list.members[i]; + + if (node.shouldEmit()) { + this.emitSpaceBetweenConstructs(lastEmittedNode, node); + + this.emitJavascript(node, true); + this.writeLineToOutput(""); + + lastEmittedNode = node; + } + } + }; + + Emitter.prototype.emitConstructorStatements = function (funcDecl) { + var list = funcDecl.block.statements; + + if (list === null) { + return; + } + + this.emitComments(list, true); + + var emitPropertyAssignmentsAfterSuperCall = this.thisClassNode.extendsList && this.thisClassNode.extendsList.members.length > 0; + var propertyAssignmentIndex = emitPropertyAssignmentsAfterSuperCall ? 1 : 0; + var lastEmittedNode = null; + + for (var i = 0, n = list.members.length; i < n; i++) { + if (i === propertyAssignmentIndex) { + this.emitParameterPropertyAndMemberVariableAssignments(); + } + + var node = list.members[i]; + + if (node.shouldEmit()) { + this.emitSpaceBetweenConstructs(lastEmittedNode, node); + + this.emitJavascript(node, true); + this.writeLineToOutput(""); + + lastEmittedNode = node; + } + } + + if (i === propertyAssignmentIndex) { + this.emitParameterPropertyAndMemberVariableAssignments(); + } + + this.emitComments(list, false); + }; + + Emitter.prototype.emitJavascript = function (ast, startLine) { + if (ast === null) { + return; + } + + if (startLine && this.indenter.indentAmt > 0) { + this.emitIndent(); + } + + ast.emit(this); + }; + + Emitter.prototype.emitPropertyAccessor = function (funcDecl, className, isProto) { + if (!TypeScript.hasFlag(funcDecl.getFunctionFlags(), 32 /* GetAccessor */)) { + var accessorSymbol = TypeScript.PullHelpers.getAccessorSymbol(funcDecl, this.semanticInfoChain, this.document.fileName); + if (accessorSymbol.getGetter()) { + return; + } + } + + this.emitIndent(); + this.recordSourceMappingStart(funcDecl); + this.writeLineToOutput("Object.defineProperty(" + className + (isProto ? ".prototype, \"" : ", \"") + funcDecl.name.actualText + "\"" + ", {"); + this.indenter.increaseIndent(); + + var accessors = TypeScript.PullHelpers.getGetterAndSetterFunction(funcDecl, this.semanticInfoChain, this.document.fileName); + if (accessors.getter) { + this.emitIndent(); + this.recordSourceMappingStart(accessors.getter); + this.writeToOutput("get: "); + this.emitInnerFunction(accessors.getter, false); + this.writeLineToOutput(","); + } + + if (accessors.setter) { + this.emitIndent(); + this.recordSourceMappingStart(accessors.setter); + this.writeToOutput("set: "); + this.emitInnerFunction(accessors.setter, false); + this.writeLineToOutput(","); + } + + this.emitIndent(); + this.writeLineToOutput("enumerable: true,"); + this.emitIndent(); + this.writeLineToOutput("configurable: true"); + this.indenter.decreaseIndent(); + this.emitIndent(); + this.writeLineToOutput("});"); + this.recordSourceMappingEnd(funcDecl); + }; + + Emitter.prototype.emitPrototypeMember = function (funcDecl, className) { + if (funcDecl.isAccessor()) { + this.emitPropertyAccessor(funcDecl, className, true); + } else { + this.emitIndent(); + this.recordSourceMappingStart(funcDecl); + this.emitComments(funcDecl, true); + this.writeToOutput(className + ".prototype." + funcDecl.getNameText() + " = "); + this.emitInnerFunction(funcDecl, false, false); + this.writeLineToOutput(";"); + } + }; + + Emitter.prototype.emitClass = function (classDecl) { + var pullDecl = this.semanticInfoChain.getDeclForAST(classDecl, this.document.fileName); + this.pushDecl(pullDecl); + + var svClassNode = this.thisClassNode; + this.thisClassNode = classDecl; + var className = classDecl.name.actualText; + this.emitComments(classDecl, true); + var temp = this.setContainer(3 /* Class */); + + this.recordSourceMappingStart(classDecl); + this.writeToOutput("var " + className); + + var hasBaseClass = classDecl.extendsList && classDecl.extendsList.members.length; + var baseNameDecl = null; + var baseName = null; + var varDecl = null; + + if (hasBaseClass) { + this.writeLineToOutput(" = (function (_super) {"); + } else { + this.writeLineToOutput(" = (function () {"); + } + + this.recordSourceMappingNameStart(className); + this.indenter.increaseIndent(); + + if (hasBaseClass) { + baseNameDecl = classDecl.extendsList.members[0]; + baseName = baseNameDecl.nodeType() === 37 /* InvocationExpression */ ? (baseNameDecl).target : baseNameDecl; + this.emitIndent(); + this.writeLineToOutput("__extends(" + className + ", _super);"); + } + + this.emitIndent(); + + var constrDecl = classDecl.constructorDecl; + + if (constrDecl) { + constrDecl.emit(this); + this.writeLineToOutput(""); + } else { + this.recordSourceMappingStart(classDecl); + + this.indenter.increaseIndent(); + this.writeLineToOutput("function " + classDecl.name.actualText + "() {"); + this.recordSourceMappingNameStart("constructor"); + if (hasBaseClass) { + this.emitIndent(); + this.writeLineToOutput("_super.apply(this, arguments);"); + } + + if (this.shouldCaptureThis(classDecl)) { + this.writeCaptureThisStatement(classDecl); + } + + this.emitParameterPropertyAndMemberVariableAssignments(); + + this.indenter.decreaseIndent(); + this.emitIndent(); + this.writeLineToOutput("}"); + + this.recordSourceMappingNameEnd(); + this.recordSourceMappingEnd(classDecl); + } + + this.emitClassMembers(classDecl); + + this.emitIndent(); + this.recordSourceMappingStart(classDecl.endingToken); + this.writeLineToOutput("return " + className + ";"); + this.recordSourceMappingEnd(classDecl.endingToken); + this.indenter.decreaseIndent(); + this.emitIndent(); + this.recordSourceMappingStart(classDecl.endingToken); + this.writeToOutput("}"); + this.recordSourceMappingNameEnd(); + this.recordSourceMappingEnd(classDecl.endingToken); + this.recordSourceMappingStart(classDecl); + this.writeToOutput(")("); + if (hasBaseClass) { + this.resolvingContext.resolvingTypeReference = true; + this.emitJavascript(baseName, false); + this.resolvingContext.resolvingTypeReference = false; + } + this.writeToOutput(");"); + this.recordSourceMappingEnd(classDecl); + + if ((temp === 1 /* Module */ || temp === 2 /* DynamicModule */) && TypeScript.hasFlag(pullDecl.flags, 1 /* Exported */)) { + this.writeLineToOutput(""); + this.emitIndent(); + var modName = temp === 1 /* Module */ ? this.moduleName : "exports"; + this.recordSourceMappingStart(classDecl); + this.writeToOutput(modName + "." + className + " = " + className + ";"); + this.recordSourceMappingEnd(classDecl); + } + + this.recordSourceMappingEnd(classDecl); + this.emitComments(classDecl, false); + this.setContainer(temp); + this.thisClassNode = svClassNode; + + this.popDecl(pullDecl); + }; + + Emitter.prototype.emitClassMembers = function (classDecl) { + var lastEmittedMember = null; + + for (var i = 0, n = classDecl.members.members.length; i < n; i++) { + var memberDecl = classDecl.members.members[i]; + + if (memberDecl.nodeType() === 13 /* FunctionDeclaration */) { + var fn = memberDecl; + + if (TypeScript.hasFlag(fn.getFunctionFlags(), 256 /* Method */) && !fn.isSignature()) { + this.emitSpaceBetweenConstructs(lastEmittedMember, fn); + + if (!TypeScript.hasFlag(fn.getFunctionFlags(), 16 /* Static */)) { + this.emitPrototypeMember(fn, classDecl.name.actualText); + } else { + if (fn.isAccessor()) { + this.emitPropertyAccessor(fn, this.thisClassNode.name.actualText, false); + } else { + this.emitIndent(); + this.recordSourceMappingStart(fn); + this.writeToOutput(classDecl.name.actualText + "." + fn.name.actualText + " = "); + this.emitInnerFunction(fn, false); + this.writeLineToOutput(";"); + } + } + + lastEmittedMember = fn; + } + } + } + + for (var i = 0, n = classDecl.members.members.length; i < n; i++) { + var memberDecl = classDecl.members.members[i]; + + if (memberDecl.nodeType() === 18 /* VariableDeclarator */) { + var varDecl = memberDecl; + + if (TypeScript.hasFlag(varDecl.getVarFlags(), 16 /* Static */) && varDecl.init) { + this.emitSpaceBetweenConstructs(lastEmittedMember, varDecl); + + this.emitIndent(); + this.recordSourceMappingStart(varDecl); + this.writeToOutput(classDecl.name.actualText + "." + varDecl.id.actualText + " = "); + varDecl.init.emit(this); + + this.writeLineToOutput(";"); + this.recordSourceMappingEnd(varDecl); + + lastEmittedMember = varDecl; + } + } + } + }; + + Emitter.prototype.requiresExtendsBlock = function (moduleElements) { + for (var i = 0, n = moduleElements.members.length; i < n; i++) { + var moduleElement = moduleElements.members[i]; + + if (moduleElement.nodeType() === 16 /* ModuleDeclaration */) { + if (this.requiresExtendsBlock((moduleElement).members)) { + return true; + } + } else if (moduleElement.nodeType() === 14 /* ClassDeclaration */) { + var classDeclaration = moduleElement; + + if (classDeclaration.extendsList && classDeclaration.extendsList.members.length > 0) { + return true; + } + } + } + + return false; + }; + + Emitter.prototype.emitPrologue = function (script) { + if (!this.extendsPrologueEmitted) { + if (this.requiresExtendsBlock(script.moduleElements)) { + this.extendsPrologueEmitted = true; + this.writeLineToOutput("var __extends = this.__extends || function (d, b) {"); + this.writeLineToOutput(" for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];"); + this.writeLineToOutput(" function __() { this.constructor = d; }"); + this.writeLineToOutput(" __.prototype = b.prototype;"); + this.writeLineToOutput(" d.prototype = new __();"); + this.writeLineToOutput("};"); + } + } + + if (!this.globalThisCapturePrologueEmitted) { + if (this.shouldCaptureThis(script)) { + this.globalThisCapturePrologueEmitted = true; + this.writeLineToOutput(this.captureThisStmtString); + } + } + }; + + Emitter.prototype.emitSuperReference = function () { + this.writeToOutput("_super.prototype"); + }; + + Emitter.prototype.emitSuperCall = function (callEx) { + if (callEx.target.nodeType() === 33 /* MemberAccessExpression */) { + var dotNode = callEx.target; + if (dotNode.operand1.nodeType() === 31 /* SuperExpression */) { + dotNode.emit(this); + this.writeToOutput(".call("); + this.emitThis(); + if (callEx.arguments && callEx.arguments.members.length > 0) { + this.writeToOutput(", "); + this.emitCommaSeparatedList(callEx.arguments); + } + this.writeToOutput(")"); + return true; + } + } + return false; + }; + + Emitter.prototype.emitThis = function () { + if (this.thisFunctionDeclaration && !this.thisFunctionDeclaration.isMethod() && (!this.thisFunctionDeclaration.isConstructor)) { + this.writeToOutput("_this"); + } else { + this.writeToOutput("this"); + } + }; + + Emitter.prototype.emitBlockOrStatement = function (node) { + if (node.nodeType() === 82 /* Block */) { + node.emit(this); + } else { + this.writeLineToOutput(""); + this.indenter.increaseIndent(); + this.emitJavascript(node, true); + this.indenter.decreaseIndent(); + } + }; + + Emitter.throwEmitterError = function (e) { + var error = new Error(e.message); + error.isEmitterError = true; + throw error; + }; + + Emitter.handleEmitterError = function (fileName, e) { + if ((e).isEmitterError === true) { + return [new TypeScript.Diagnostic(fileName, 0, 0, TypeScript.DiagnosticCode.Emit_Error_0, [e.message])]; + } + + throw e; + }; + return Emitter; + })(); + TypeScript.Emitter = Emitter; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var MemberName = (function () { + function MemberName() { + this.prefix = ""; + this.suffix = ""; + } + MemberName.prototype.isString = function () { + return false; + }; + MemberName.prototype.isArray = function () { + return false; + }; + MemberName.prototype.isMarker = function () { + return !this.isString() && !this.isArray(); + }; + + MemberName.prototype.toString = function () { + return MemberName.memberNameToString(this); + }; + + MemberName.memberNameToString = function (memberName, markerInfo, markerBaseLength) { + if (typeof markerBaseLength === "undefined") { markerBaseLength = 0; } + var result = memberName.prefix; + + if (memberName.isString()) { + result += (memberName).text; + } else if (memberName.isArray()) { + var ar = memberName; + for (var index = 0; index < ar.entries.length; index++) { + if (ar.entries[index].isMarker()) { + if (markerInfo) { + markerInfo.push(markerBaseLength + result.length); + } + continue; + } + + result += MemberName.memberNameToString(ar.entries[index], markerInfo, markerBaseLength + result.length); + result += ar.delim; + } + } + + result += memberName.suffix; + return result; + }; + + MemberName.create = function (arg1, arg2, arg3) { + if (typeof arg1 === "string") { + return new MemberNameString(arg1); + } else { + var result = new MemberNameArray(); + if (arg2) + result.prefix = arg2; + if (arg3) + result.suffix = arg3; + result.entries.push(arg1); + return result; + } + }; + return MemberName; + })(); + TypeScript.MemberName = MemberName; + + var MemberNameString = (function (_super) { + __extends(MemberNameString, _super); + function MemberNameString(text) { + _super.call(this); + this.text = text; + } + MemberNameString.prototype.isString = function () { + return true; + }; + return MemberNameString; + })(MemberName); + TypeScript.MemberNameString = MemberNameString; + + var MemberNameArray = (function (_super) { + __extends(MemberNameArray, _super); + function MemberNameArray() { + _super.call(this); + this.delim = ""; + this.entries = []; + } + MemberNameArray.prototype.isArray = function () { + return true; + }; + + MemberNameArray.prototype.add = function (entry) { + this.entries.push(entry); + }; + + MemberNameArray.prototype.addAll = function (entries) { + for (var i = 0; i < entries.length; i++) { + this.entries.push(entries[i]); + } + }; + return MemberNameArray; + })(MemberName); + TypeScript.MemberNameArray = MemberNameArray; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var quoteRegEx = /["']/g; + function stripQuotes(str) { + return str.replace(quoteRegEx, ""); + } + TypeScript.stripQuotes = stripQuotes; + + function isSingleQuoted(str) { + return str.indexOf("'") !== -1; + } + TypeScript.isSingleQuoted = isSingleQuoted; + + function isQuoted(str) { + return str.indexOf("\"") !== -1 || isSingleQuoted(str); + } + TypeScript.isQuoted = isQuoted; + + function quoteStr(str) { + return "\"" + str + "\""; + } + TypeScript.quoteStr = quoteStr; + + function swapQuotes(str) { + if (str.indexOf("\"") !== -1) { + str = str.replace("\"", "'"); + str = str.replace("\"", "'"); + } else { + str = str.replace("'", "\""); + str = str.replace("'", "\""); + } + + return str; + } + TypeScript.swapQuotes = swapQuotes; + + var switchToForwardSlashesRegEx = /\\/g; + function switchToForwardSlashes(path) { + return path.replace(switchToForwardSlashesRegEx, "/"); + } + TypeScript.switchToForwardSlashes = switchToForwardSlashes; + + function trimModName(modName) { + if (modName.length > 5 && modName.substring(modName.length - 5, modName.length) === ".d.ts") { + return modName.substring(0, modName.length - 5); + } + if (modName.length > 3 && modName.substring(modName.length - 3, modName.length) === ".ts") { + return modName.substring(0, modName.length - 3); + } + + if (modName.length > 3 && modName.substring(modName.length - 3, modName.length) === ".js") { + return modName.substring(0, modName.length - 3); + } + + return modName; + } + TypeScript.trimModName = trimModName; + + function getDeclareFilePath(fname) { + return isTSFile(fname) ? changePathToDTS(fname) : changePathToDTS(fname); + } + TypeScript.getDeclareFilePath = getDeclareFilePath; + + function isFileOfExtension(fname, ext) { + var invariantFname = fname.toLocaleUpperCase(); + var invariantExt = ext.toLocaleUpperCase(); + var extLength = invariantExt.length; + return invariantFname.length > extLength && invariantFname.substring(invariantFname.length - extLength, invariantFname.length) === invariantExt; + } + + function isJSFile(fname) { + return isFileOfExtension(fname, ".js"); + } + TypeScript.isJSFile = isJSFile; + + function isTSFile(fname) { + return isFileOfExtension(fname, ".ts"); + } + TypeScript.isTSFile = isTSFile; + + function isDTSFile(fname) { + return isFileOfExtension(fname, ".d.ts"); + } + TypeScript.isDTSFile = isDTSFile; + + function getPrettyName(modPath, quote, treatAsFileName) { + if (typeof quote === "undefined") { quote = true; } + if (typeof treatAsFileName === "undefined") { treatAsFileName = false; } + var modName = treatAsFileName ? switchToForwardSlashes(modPath) : trimModName(stripQuotes(modPath)); + var components = this.getPathComponents(modName); + return components.length ? (quote ? quoteStr(components[components.length - 1]) : components[components.length - 1]) : modPath; + } + TypeScript.getPrettyName = getPrettyName; + + function getPathComponents(path) { + return path.split("/"); + } + TypeScript.getPathComponents = getPathComponents; + + function getRelativePathToFixedPath(fixedModFilePath, absoluteModPath, isAbsoultePathURL) { + if (typeof isAbsoultePathURL === "undefined") { isAbsoultePathURL = true; } + absoluteModPath = switchToForwardSlashes(absoluteModPath); + + var modComponents = this.getPathComponents(absoluteModPath); + var fixedModComponents = this.getPathComponents(fixedModFilePath); + + var joinStartIndex = 0; + for (; joinStartIndex < modComponents.length && joinStartIndex < fixedModComponents.length; joinStartIndex++) { + if (fixedModComponents[joinStartIndex] !== modComponents[joinStartIndex]) { + break; + } + } + + if (joinStartIndex !== 0) { + var relativePath = ""; + var relativePathComponents = modComponents.slice(joinStartIndex, modComponents.length); + for (; joinStartIndex < fixedModComponents.length; joinStartIndex++) { + if (fixedModComponents[joinStartIndex] !== "") { + relativePath = relativePath + "../"; + } + } + + return relativePath + relativePathComponents.join("/"); + } + + if (isAbsoultePathURL && absoluteModPath.indexOf("://") === -1) { + absoluteModPath = "file:///" + absoluteModPath; + } + + return absoluteModPath; + } + TypeScript.getRelativePathToFixedPath = getRelativePathToFixedPath; + + function quoteBaseName(modPath) { + var modName = trimModName(stripQuotes(modPath)); + var path = getRootFilePath(modName); + if (path === "") { + return modPath; + } else { + var components = modName.split(path); + var fileIndex = components.length > 1 ? 1 : 0; + return quoteStr(components[fileIndex]); + } + } + TypeScript.quoteBaseName = quoteBaseName; + + function changePathToDTS(modPath) { + return trimModName(stripQuotes(modPath)) + ".d.ts"; + } + TypeScript.changePathToDTS = changePathToDTS; + + function isRelative(path) { + return path.length > 0 && path.charAt(0) === "."; + } + TypeScript.isRelative = isRelative; + function isRooted(path) { + return path.length > 0 && (path.charAt(0) === "\\" || path.charAt(0) === "/" || (path.indexOf(":\\") !== -1) || (path.indexOf(":/") !== -1)); + } + TypeScript.isRooted = isRooted; + + function getRootFilePath(outFname) { + if (outFname === "") { + return outFname; + } else { + var isPath = outFname.indexOf("/") !== -1; + return isPath ? filePath(outFname) : ""; + } + } + TypeScript.getRootFilePath = getRootFilePath; + + function filePathComponents(fullPath) { + fullPath = switchToForwardSlashes(fullPath); + var components = getPathComponents(fullPath); + return components.slice(0, components.length - 1); + } + TypeScript.filePathComponents = filePathComponents; + + function filePath(fullPath) { + var path = filePathComponents(fullPath); + return path.join("/") + "/"; + } + TypeScript.filePath = filePath; + + var normalizePathRegEx = /^\\\\[^\\]/; + function normalizePath(path) { + if (normalizePathRegEx.test(path)) { + path = "file:" + path; + } + var parts = this.getPathComponents(switchToForwardSlashes(path)); + var normalizedParts = []; + + for (var i = 0; i < parts.length; i++) { + var part = parts[i]; + if (part === ".") { + continue; + } + + if (normalizedParts.length > 0 && TypeScript.ArrayUtilities.last(normalizedParts) !== ".." && part === "..") { + normalizedParts.pop(); + continue; + } + + normalizedParts.push(part); + } + + return normalizedParts.join("/"); + } + TypeScript.normalizePath = normalizePath; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var CompilationSettings = (function () { + function CompilationSettings() { + this.propagateEnumConstants = false; + this.removeComments = false; + this.watch = false; + this.noResolve = false; + this.allowAutomaticSemicolonInsertion = true; + this.noImplicitAny = false; + this.noLib = false; + this.codeGenTarget = 0 /* EcmaScript3 */; + this.moduleGenTarget = 0 /* Unspecified */; + this.outFileOption = ""; + this.outDirOption = ""; + this.mapSourceFiles = false; + this.mapRoot = ""; + this.sourceRoot = ""; + this.generateDeclarationFiles = false; + this.useCaseSensitiveFileResolution = false; + this.gatherDiagnostics = false; + this.updateTC = false; + } + return CompilationSettings; + })(); + TypeScript.CompilationSettings = CompilationSettings; + + function getFileReferenceFromReferencePath(comment) { + var referencesRegEx = /^(\/\/\/\s*/gim; + var match = referencesRegEx.exec(comment); + + if (match) { + var path = TypeScript.normalizePath(match[3]); + var adjustedPath = TypeScript.normalizePath(path); + + var isResident = match.length >= 7 && match[6] === "true"; + if (isResident) { + TypeScript.CompilerDiagnostics.debugPrint(path + " is resident"); + } + return { + line: 0, + character: 0, + position: 0, + length: 0, + path: TypeScript.switchToForwardSlashes(adjustedPath), + isResident: isResident + }; + } else { + return null; + } + } + + function getImplicitImport(comment) { + var implicitImportRegEx = /^(\/\/\/\s*/gim; + var match = implicitImportRegEx.exec(comment); + + if (match) { + return true; + } + + return false; + } + TypeScript.getImplicitImport = getImplicitImport; + + function getReferencedFiles(fileName, sourceText) { + var preProcessInfo = preProcessFile(fileName, sourceText, null, false); + return preProcessInfo.referencedFiles; + } + TypeScript.getReferencedFiles = getReferencedFiles; + + var scannerWindow = TypeScript.ArrayUtilities.createArray(2048, 0); + var scannerDiagnostics = []; + + function processImports(lineMap, scanner, token, importedFiles) { + var position = 0; + var lineChar = { line: -1, character: -1 }; + + while (token.tokenKind !== 10 /* EndOfFileToken */) { + if (token.tokenKind === 49 /* ImportKeyword */) { + var importStart = position + token.leadingTriviaWidth(); + token = scanner.scan(scannerDiagnostics, false); + + if (TypeScript.SyntaxFacts.isIdentifierNameOrAnyKeyword(token)) { + token = scanner.scan(scannerDiagnostics, false); + + if (token.tokenKind === 107 /* EqualsToken */) { + token = scanner.scan(scannerDiagnostics, false); + + if (token.tokenKind === 65 /* ModuleKeyword */ || token.tokenKind === 66 /* RequireKeyword */) { + token = scanner.scan(scannerDiagnostics, false); + + if (token.tokenKind === 72 /* OpenParenToken */) { + var afterOpenParenPosition = scanner.absoluteIndex(); + token = scanner.scan(scannerDiagnostics, false); + + lineMap.fillLineAndCharacterFromPosition(importStart, lineChar); + + if (token.tokenKind === 14 /* StringLiteral */) { + var ref = { + line: lineChar.line, + character: lineChar.character, + position: afterOpenParenPosition + token.leadingTriviaWidth(), + length: token.width(), + path: TypeScript.stripQuotes(TypeScript.switchToForwardSlashes(token.text())), + isResident: false + }; + importedFiles.push(ref); + } + } + } + } + } + } + + position = scanner.absoluteIndex(); + token = scanner.scan(scannerDiagnostics, false); + } + } + + function processTripleSlashDirectives(lineMap, firstToken, settings, referencedFiles) { + var leadingTrivia = firstToken.leadingTrivia(); + + var position = 0; + var lineChar = { line: -1, character: -1 }; + var noDefaultLib = false; + + for (var i = 0, n = leadingTrivia.count(); i < n; i++) { + var trivia = leadingTrivia.syntaxTriviaAt(i); + + if (trivia.kind() === 7 /* SingleLineCommentTrivia */) { + var triviaText = trivia.fullText(); + var referencedCode = getFileReferenceFromReferencePath(triviaText); + + if (referencedCode) { + lineMap.fillLineAndCharacterFromPosition(position, lineChar); + referencedCode.position = position; + referencedCode.length = trivia.fullWidth(); + referencedCode.line = lineChar.line; + referencedCode.character = lineChar.character; + + referencedFiles.push(referencedCode); + } + + if (settings) { + var isNoDefaultLibRegex = /^(\/\/\/\s*/gim; + var isNoDefaultLibMatch = isNoDefaultLibRegex.exec(triviaText); + if (isNoDefaultLibMatch) { + noDefaultLib = (isNoDefaultLibMatch[3] === "true"); + } + } + } + + position += trivia.fullWidth(); + } + + return { noDefaultLib: noDefaultLib }; + } + + function preProcessFile(fileName, sourceText, settings, readImportFiles) { + if (typeof readImportFiles === "undefined") { readImportFiles = true; } + settings = settings || new CompilationSettings(); + + var text = TypeScript.SimpleText.fromScriptSnapshot(sourceText); + var scanner = new TypeScript.Scanner(fileName, text, settings.codeGenTarget, scannerWindow); + + var firstToken = scanner.scan(scannerDiagnostics, false); + + var importedFiles = []; + if (readImportFiles) { + processImports(text.lineMap(), scanner, firstToken, importedFiles); + } + + var referencedFiles = []; + var properties = processTripleSlashDirectives(text.lineMap(), firstToken, settings, referencedFiles); + + scannerDiagnostics.length = 0; + return { settings: settings, referencedFiles: referencedFiles, importedFiles: importedFiles, isLibFile: properties.noDefaultLib }; + } + TypeScript.preProcessFile = preProcessFile; + + function getParseOptions(settings) { + return new TypeScript.ParseOptions(settings.codeGenTarget, settings.allowAutomaticSemicolonInsertion); + } + TypeScript.getParseOptions = getParseOptions; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var ReferenceResolutionResult = (function () { + function ReferenceResolutionResult() { + this.resolvedFiles = []; + this.diagnostics = []; + this.seenNoDefaultLibTag = false; + } + return ReferenceResolutionResult; + })(); + TypeScript.ReferenceResolutionResult = ReferenceResolutionResult; + + var ReferenceLocation = (function () { + function ReferenceLocation(filePath, position, length, isImported) { + this.filePath = filePath; + this.position = position; + this.length = length; + this.isImported = isImported; + } + return ReferenceLocation; + })(); + + var ReferenceResolver = (function () { + function ReferenceResolver(inputFileNames, host, settings) { + this.inputFileNames = inputFileNames; + this.host = host; + this.settings = settings; + this.visited = {}; + } + ReferenceResolver.resolve = function (inputFileNames, host, settings) { + var resolver = new ReferenceResolver(inputFileNames, host, settings); + return resolver.resolveInputFiles(); + }; + + ReferenceResolver.prototype.resolveInputFiles = function () { + var result = new ReferenceResolutionResult(); + + if (!this.inputFileNames || this.inputFileNames.length <= 0) { + return result; + } + + var referenceLocation = new ReferenceLocation(null, 0, 0, false); + for (var i = 0, n = this.inputFileNames.length; i < n; i++) { + this.resolveIncludedFile(this.inputFileNames[i], referenceLocation, result); + } + + return result; + }; + + ReferenceResolver.prototype.resolveIncludedFile = function (path, referenceLocation, resolutionResult) { + var normalizedPath = this.getNormalizedFilePath(path, referenceLocation.filePath); + + if (this.isSameFile(normalizedPath, referenceLocation.filePath)) { + if (!referenceLocation.isImported) { + resolutionResult.diagnostics.push(new TypeScript.Diagnostic(referenceLocation.filePath, referenceLocation.position, referenceLocation.length, TypeScript.DiagnosticCode.A_file_cannot_have_a_reference_to_itself, null)); + } + + return normalizedPath; + } + + if (!TypeScript.isTSFile(normalizedPath) && !TypeScript.isDTSFile(normalizedPath)) { + var dtsFile = normalizedPath + ".d.ts"; + var tsFile = normalizedPath + ".ts"; + + if (this.host.fileExists(dtsFile)) { + normalizedPath = dtsFile; + } else { + normalizedPath = tsFile; + } + } + + if (!this.host.fileExists(normalizedPath)) { + if (!referenceLocation.isImported) { + resolutionResult.diagnostics.push(new TypeScript.Diagnostic(referenceLocation.filePath, referenceLocation.position, referenceLocation.length, TypeScript.DiagnosticCode.Cannot_resolve_referenced_file_0, [path])); + } + + return normalizedPath; + } + + return this.resolveFile(normalizedPath, resolutionResult); + }; + + ReferenceResolver.prototype.resolveImportedFile = function (path, referenceLocation, resolutionResult) { + var isRelativePath = TypeScript.isRelative(path); + var isRootedPath = isRelativePath ? false : TypeScript.isRooted(path); + + if (isRelativePath || isRootedPath) { + return this.resolveIncludedFile(path, referenceLocation, resolutionResult); + } else { + var parentDirectory = this.host.getParentDirectory(referenceLocation.filePath); + var searchFilePath = null; + var dtsFileName = path + ".d.ts"; + var tsFilePath = path + ".ts"; + + do { + var currentFilePath = this.host.resolveRelativePath(dtsFileName, parentDirectory); + if (this.host.fileExists(currentFilePath)) { + searchFilePath = currentFilePath; + break; + } + + currentFilePath = this.host.resolveRelativePath(tsFilePath, parentDirectory); + if (this.host.fileExists(currentFilePath)) { + searchFilePath = currentFilePath; + break; + } + + parentDirectory = this.host.getParentDirectory(parentDirectory); + } while(parentDirectory); + + if (!searchFilePath) { + return path; + } + + return this.resolveFile(searchFilePath, resolutionResult); + } + }; + + ReferenceResolver.prototype.resolveFile = function (normalizedPath, resolutionResult) { + var visitedPath = this.isVisited(normalizedPath); + if (!visitedPath) { + this.recordVisitedFile(normalizedPath); + + var preprocessedFileInformation = TypeScript.preProcessFile(normalizedPath, this.host.getScriptSnapshot(normalizedPath), this.settings); + + if (preprocessedFileInformation.isLibFile) { + resolutionResult.seenNoDefaultLibTag = true; + } + + var normalizedReferencePaths = []; + for (var i = 0, n = preprocessedFileInformation.referencedFiles.length; i < n; i++) { + var fileReference = preprocessedFileInformation.referencedFiles[i]; + var currentReferenceLocation = new ReferenceLocation(normalizedPath, fileReference.position, fileReference.length, false); + var normalizedReferencePath = this.resolveIncludedFile(fileReference.path, currentReferenceLocation, resolutionResult); + normalizedReferencePaths.push(normalizedReferencePath); + } + + var normalizedImportPaths = []; + for (var i = 0; i < preprocessedFileInformation.importedFiles.length; i++) { + var fileImport = preprocessedFileInformation.importedFiles[i]; + var currentReferenceLocation = new ReferenceLocation(normalizedPath, fileImport.position, fileImport.length, true); + var normalizedImportPath = this.resolveImportedFile(fileImport.path, currentReferenceLocation, resolutionResult); + normalizedImportPaths.push(normalizedImportPath); + } + + resolutionResult.resolvedFiles.push({ + path: normalizedPath, + referencedFiles: normalizedReferencePaths, + importedFiles: normalizedImportPaths + }); + } else { + normalizedPath = visitedPath; + } + + return normalizedPath; + }; + + ReferenceResolver.prototype.getNormalizedFilePath = function (path, parentFilePath) { + var parentFileDirectory = parentFilePath ? this.host.getParentDirectory(parentFilePath) : ""; + var normalizedPath = this.host.resolveRelativePath(path, parentFileDirectory); + return normalizedPath; + }; + + ReferenceResolver.prototype.getUniqueFileId = function (filePath) { + return this.settings.useCaseSensitiveFileResolution ? filePath : filePath.toLocaleUpperCase(); + }; + + ReferenceResolver.prototype.recordVisitedFile = function (filePath) { + this.visited[this.getUniqueFileId(filePath)] = filePath; + }; + + ReferenceResolver.prototype.isVisited = function (filePath) { + return this.visited[this.getUniqueFileId(filePath)]; + }; + + ReferenceResolver.prototype.isSameFile = function (filePath1, filePath2) { + if (!filePath1 || !filePath2) { + return false; + } + + if (this.settings.useCaseSensitiveFileResolution) { + return filePath1 === filePath2; + } else { + return filePath1.toLocaleUpperCase() === filePath2.toLocaleUpperCase(); + } + }; + return ReferenceResolver; + })(); + TypeScript.ReferenceResolver = ReferenceResolver; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var TextWriter = (function () { + function TextWriter(ioHost, path, writeByteOrderMark) { + this.ioHost = ioHost; + this.path = path; + this.writeByteOrderMark = writeByteOrderMark; + this.contents = ""; + this.onNewLine = true; + } + TextWriter.prototype.Write = function (s) { + this.contents += s; + this.onNewLine = false; + }; + + TextWriter.prototype.WriteLine = function (s) { + this.contents += s; + this.contents += TypeScript.newLine(); + this.onNewLine = true; + }; + + TextWriter.prototype.Close = function () { + try { + this.ioHost.writeFile(this.path, this.contents, this.writeByteOrderMark); + } catch (e) { + TypeScript.Emitter.throwEmitterError(e); + } + }; + return TextWriter; + })(); + TypeScript.TextWriter = TextWriter; + + var DeclarationEmitter = (function () { + function DeclarationEmitter(emittingFileName, document, compiler) { + this.emittingFileName = emittingFileName; + this.document = document; + this.compiler = compiler; + this.declFile = null; + this.indenter = new TypeScript.Indenter(); + this.declarationContainerStack = []; + this.isDottedModuleName = []; + this.ignoreCallbackAst = null; + this.varListCount = 0; + this.emittedReferencePaths = false; + this.declFile = new TextWriter(this.compiler.emitOptions.ioHost, emittingFileName, this.document.byteOrderMark !== 0 /* None */); + } + DeclarationEmitter.prototype.widenType = function (type) { + if (type === this.compiler.semanticInfoChain.undefinedTypeSymbol || type === this.compiler.semanticInfoChain.nullTypeSymbol) { + return this.compiler.semanticInfoChain.anyTypeSymbol; + } + + return type; + }; + + DeclarationEmitter.prototype.close = function () { + try { + this.declFile.Close(); + } catch (e) { + TypeScript.Emitter.throwEmitterError(e); + } + }; + + DeclarationEmitter.prototype.emitDeclarations = function (script) { + var _this = this; + var walk = function (pre, ast) { + switch (ast.nodeType()) { + case 98 /* VariableStatement */: + return _this.variableStatementCallback(pre, ast); + case 19 /* VariableDeclaration */: + return _this.variableDeclarationCallback(pre, ast); + case 18 /* VariableDeclarator */: + return _this.variableDeclaratorCallback(pre, ast); + case 82 /* Block */: + return _this.blockCallback(pre, ast); + case 13 /* FunctionDeclaration */: + return _this.functionDeclarationCallback(pre, ast); + case 14 /* ClassDeclaration */: + return _this.classDeclarationCallback(pre, ast); + case 15 /* InterfaceDeclaration */: + return _this.interfaceDeclarationCallback(pre, ast); + case 17 /* ImportDeclaration */: + return _this.importDeclarationCallback(pre, ast); + case 16 /* ModuleDeclaration */: + return _this.moduleDeclarationCallback(pre, ast); + case 88 /* ExportAssignment */: + return _this.exportAssignmentCallback(pre, ast); + case 2 /* Script */: + return _this.scriptCallback(pre, ast); + default: + return _this.defaultCallback(pre, ast); + } + }; + + TypeScript.getAstWalkerFactory().walk(script, function (ast, parent, walker) { + walker.options.goChildren = walk(true, ast); + return ast; + }, function (ast, parent, walker) { + walker.options.goChildren = walk(false, ast); + return ast; + }); + }; + + DeclarationEmitter.prototype.getAstDeclarationContainer = function () { + return this.declarationContainerStack[this.declarationContainerStack.length - 1]; + }; + + DeclarationEmitter.prototype.emitDottedModuleName = function () { + return (this.isDottedModuleName.length === 0) ? false : this.isDottedModuleName[this.isDottedModuleName.length - 1]; + }; + + DeclarationEmitter.prototype.getIndentString = function (declIndent) { + if (typeof declIndent === "undefined") { declIndent = false; } + return this.indenter.getIndent(); + }; + + DeclarationEmitter.prototype.emitIndent = function () { + this.declFile.Write(this.getIndentString()); + }; + + DeclarationEmitter.prototype.canEmitSignature = function (declFlags, declAST, canEmitGlobalAmbientDecl, useDeclarationContainerTop) { + if (typeof canEmitGlobalAmbientDecl === "undefined") { canEmitGlobalAmbientDecl = true; } + if (typeof useDeclarationContainerTop === "undefined") { useDeclarationContainerTop = true; } + var container; + if (useDeclarationContainerTop) { + container = this.getAstDeclarationContainer(); + } else { + container = this.declarationContainerStack[this.declarationContainerStack.length - 2]; + } + + var pullDecl = this.compiler.semanticInfoChain.getDeclForAST(declAST, this.document.fileName); + if (container.nodeType() === 16 /* ModuleDeclaration */) { + if (!TypeScript.hasFlag(pullDecl.flags, 1 /* Exported */)) { + var start = new Date().getTime(); + var declSymbol = this.compiler.semanticInfoChain.getSymbolForAST(declAST, this.document.fileName); + var result = declSymbol && declSymbol.isExternallyVisible(); + TypeScript.declarationEmitIsExternallyVisibleTime += new Date().getTime() - start; + + return result; + } + } + + if (!canEmitGlobalAmbientDecl && container.nodeType() === 2 /* Script */ && TypeScript.hasFlag(pullDecl.flags, 8 /* Ambient */)) { + return false; + } + + return true; + }; + + DeclarationEmitter.prototype.canEmitPrePostAstSignature = function (declFlags, astWithPrePostCallback, preCallback) { + if (this.ignoreCallbackAst) { + TypeScript.CompilerDiagnostics.assert(this.ignoreCallbackAst !== astWithPrePostCallback, "Ignore Callback AST mismatch"); + this.ignoreCallbackAst = null; + return false; + } else if (preCallback && !this.canEmitSignature(declFlags, astWithPrePostCallback, true, preCallback)) { + this.ignoreCallbackAst = astWithPrePostCallback; + return false; + } + + return true; + }; + + DeclarationEmitter.prototype.getDeclFlagsString = function (declFlags, pullDecl, typeString) { + var result = this.getIndentString(); + var pullFlags = pullDecl.flags; + + if (TypeScript.hasFlag(declFlags, 16 /* Static */)) { + if (TypeScript.hasFlag(declFlags, 2 /* Private */)) { + result += "private "; + } + result += "static "; + } else { + if (TypeScript.hasFlag(declFlags, 2 /* Private */)) { + result += "private "; + } else if (TypeScript.hasFlag(declFlags, 4 /* Public */)) { + result += "public "; + } else { + var emitDeclare = !TypeScript.hasFlag(pullFlags, 1 /* Exported */); + + var container = this.getAstDeclarationContainer(); + if (container.nodeType() === 16 /* ModuleDeclaration */ && TypeScript.hasFlag((container).getModuleFlags(), 256 /* IsWholeFile */) && TypeScript.hasFlag(pullFlags, 1 /* Exported */)) { + result += "export "; + emitDeclare = true; + } + + if (emitDeclare && typeString !== "interface" && typeString != "import") { + result += "declare "; + } + + result += typeString + " "; + } + } + + return result; + }; + + DeclarationEmitter.prototype.emitDeclFlags = function (declFlags, pullDecl, typeString) { + this.declFile.Write(this.getDeclFlagsString(declFlags, pullDecl, typeString)); + }; + + DeclarationEmitter.prototype.canEmitTypeAnnotationSignature = function (declFlag) { + if (typeof declFlag === "undefined") { declFlag = 0 /* None */; } + return !TypeScript.hasFlag(declFlag, 2 /* Private */); + }; + + DeclarationEmitter.prototype.pushDeclarationContainer = function (ast) { + this.declarationContainerStack.push(ast); + }; + + DeclarationEmitter.prototype.popDeclarationContainer = function (ast) { + TypeScript.CompilerDiagnostics.assert(ast !== this.getAstDeclarationContainer(), 'Declaration container mismatch'); + this.declarationContainerStack.pop(); + }; + + DeclarationEmitter.prototype.emitTypeNamesMember = function (memberName, emitIndent) { + if (typeof emitIndent === "undefined") { emitIndent = false; } + if (memberName.prefix === "{ ") { + if (emitIndent) { + this.emitIndent(); + } + + this.declFile.WriteLine("{"); + this.indenter.increaseIndent(); + emitIndent = true; + } else if (memberName.prefix !== "") { + if (emitIndent) { + this.emitIndent(); + } + + this.declFile.Write(memberName.prefix); + emitIndent = false; + } + + if (memberName.isString()) { + if (emitIndent) { + this.emitIndent(); + } + + this.declFile.Write((memberName).text); + } else if (memberName.isArray()) { + var ar = memberName; + for (var index = 0; index < ar.entries.length; index++) { + this.emitTypeNamesMember(ar.entries[index], emitIndent); + if (ar.delim === "; ") { + this.declFile.WriteLine(";"); + } + } + } + + if (memberName.suffix === "}") { + this.indenter.decreaseIndent(); + this.emitIndent(); + this.declFile.Write(memberName.suffix); + } else { + this.declFile.Write(memberName.suffix); + } + }; + + DeclarationEmitter.prototype.emitTypeSignature = function (type) { + var declarationContainerAst = this.getAstDeclarationContainer(); + + var start = new Date().getTime(); + var declarationContainerDecl = this.compiler.semanticInfoChain.getDeclForAST(declarationContainerAst, this.document.fileName); + var declarationPullSymbol = declarationContainerDecl.getSymbol(); + TypeScript.declarationEmitTypeSignatureTime += new Date().getTime() - start; + + var typeNameMembers = type.getScopedNameEx(declarationPullSymbol); + this.emitTypeNamesMember(typeNameMembers); + }; + + DeclarationEmitter.prototype.emitComment = function (comment) { + var text = comment.getText(); + if (this.declFile.onNewLine) { + this.emitIndent(); + } else if (!comment.isBlockComment) { + this.declFile.WriteLine(""); + this.emitIndent(); + } + + this.declFile.Write(text[0]); + + for (var i = 1; i < text.length; i++) { + this.declFile.WriteLine(""); + this.emitIndent(); + this.declFile.Write(text[i]); + } + + if (comment.endsLine || !comment.isBlockComment) { + this.declFile.WriteLine(""); + } else { + this.declFile.Write(" "); + } + }; + + DeclarationEmitter.prototype.emitDeclarationComments = function (astOrSymbol, endLine) { + if (typeof endLine === "undefined") { endLine = true; } + if (this.compiler.emitOptions.compilationSettings.removeComments) { + return; + } + + var declComments = astOrSymbol.docComments(); + this.writeDeclarationComments(declComments, endLine); + }; + + DeclarationEmitter.prototype.writeDeclarationComments = function (declComments, endLine) { + if (typeof endLine === "undefined") { endLine = true; } + if (declComments.length > 0) { + for (var i = 0; i < declComments.length; i++) { + this.emitComment(declComments[i]); + } + + if (endLine) { + if (!this.declFile.onNewLine) { + this.declFile.WriteLine(""); + } + } else { + if (this.declFile.onNewLine) { + this.emitIndent(); + } + } + } + }; + + DeclarationEmitter.prototype.emitTypeOfBoundDecl = function (boundDecl) { + var start = new Date().getTime(); + var decl = this.compiler.semanticInfoChain.getDeclForAST(boundDecl, this.document.fileName); + var pullSymbol = decl.getSymbol(); + TypeScript.declarationEmitGetBoundDeclTypeTime += new Date().getTime() - start; + + var type = this.widenType(pullSymbol.type); + if (!type) { + return; + } + + if (boundDecl.typeExpr || (boundDecl.init && type !== this.compiler.semanticInfoChain.anyTypeSymbol)) { + this.declFile.Write(": "); + this.emitTypeSignature(type); + } + }; + + DeclarationEmitter.prototype.variableDeclaratorCallback = function (pre, varDecl) { + if (pre && this.canEmitSignature(TypeScript.ToDeclFlags(varDecl.getVarFlags()), varDecl, false)) { + var interfaceMember = (this.getAstDeclarationContainer().nodeType() === 15 /* InterfaceDeclaration */); + this.emitDeclarationComments(varDecl); + if (!interfaceMember) { + if (this.varListCount >= 0) { + this.emitDeclFlags(TypeScript.ToDeclFlags(varDecl.getVarFlags()), this.compiler.semanticInfoChain.getDeclForAST(varDecl, this.document.fileName), "var"); + this.varListCount = -this.varListCount; + } + + this.declFile.Write(varDecl.id.actualText); + } else { + this.emitIndent(); + this.declFile.Write(varDecl.id.actualText); + if (TypeScript.hasFlag(varDecl.id.getFlags(), 4 /* OptionalName */)) { + this.declFile.Write("?"); + } + } + + if (this.canEmitTypeAnnotationSignature(TypeScript.ToDeclFlags(varDecl.getVarFlags()))) { + this.emitTypeOfBoundDecl(varDecl); + } + + if (this.varListCount > 0) { + this.varListCount--; + } else if (this.varListCount < 0) { + this.varListCount++; + } + + if (this.varListCount < 0) { + this.declFile.Write(", "); + } else { + this.declFile.WriteLine(";"); + } + } + return false; + }; + + DeclarationEmitter.prototype.blockCallback = function (pre, block) { + return false; + }; + + DeclarationEmitter.prototype.variableStatementCallback = function (pre, variableStatement) { + return true; + }; + + DeclarationEmitter.prototype.variableDeclarationCallback = function (pre, variableDeclaration) { + if (pre) { + this.varListCount = variableDeclaration.declarators.members.length; + } else { + this.varListCount = 0; + } + + return true; + }; + + DeclarationEmitter.prototype.emitArgDecl = function (argDecl, funcDecl) { + this.indenter.increaseIndent(); + + this.emitDeclarationComments(argDecl, false); + this.declFile.Write(argDecl.id.actualText); + if (argDecl.isOptionalArg()) { + this.declFile.Write("?"); + } + + this.indenter.decreaseIndent(); + + if (this.canEmitTypeAnnotationSignature(TypeScript.ToDeclFlags(funcDecl.getFunctionFlags()))) { + this.emitTypeOfBoundDecl(argDecl); + } + }; + + DeclarationEmitter.prototype.isOverloadedCallSignature = function (funcDecl) { + var start = new Date().getTime(); + var functionDecl = this.compiler.semanticInfoChain.getDeclForAST(funcDecl, this.document.fileName); + var funcSymbol = functionDecl.getSymbol(); + TypeScript.declarationEmitIsOverloadedCallSignatureTime += new Date().getTime() - start; + + var funcTypeSymbol = funcSymbol.type; + var signatures = funcTypeSymbol.getCallSignatures(); + var result = signatures && signatures.length > 1; + + return result; + }; + + DeclarationEmitter.prototype.functionDeclarationCallback = function (pre, funcDecl) { + if (!pre) { + return false; + } + + if (funcDecl.isAccessor()) { + return this.emitPropertyAccessorSignature(funcDecl); + } + + var isInterfaceMember = (this.getAstDeclarationContainer().nodeType() === 15 /* InterfaceDeclaration */); + + var start = new Date().getTime(); + var funcSymbol = this.compiler.semanticInfoChain.getSymbolForAST(funcDecl, this.document.fileName); + + TypeScript.declarationEmitFunctionDeclarationGetSymbolTime += new Date().getTime() - start; + + var funcTypeSymbol = funcSymbol.type; + if (funcDecl.block) { + var constructSignatures = funcTypeSymbol.getConstructSignatures(); + if (constructSignatures && constructSignatures.length > 1) { + return false; + } else if (this.isOverloadedCallSignature(funcDecl)) { + return false; + } + } else if (!isInterfaceMember && TypeScript.hasFlag(funcDecl.getFunctionFlags(), 2 /* Private */) && this.isOverloadedCallSignature(funcDecl)) { + var callSignatures = funcTypeSymbol.getCallSignatures(); + TypeScript.Debug.assert(callSignatures && callSignatures.length > 1); + var firstSignature = callSignatures[0].isDefinition() ? callSignatures[1] : callSignatures[0]; + var firstSignatureDecl = firstSignature.getDeclarations()[0]; + var firstFuncDecl = this.compiler.semanticInfoChain.getASTForDecl(firstSignatureDecl); + if (firstFuncDecl !== funcDecl) { + return false; + } + } + + if (!this.canEmitSignature(TypeScript.ToDeclFlags(funcDecl.getFunctionFlags()), funcDecl, false)) { + return false; + } + + var funcPullDecl = this.compiler.semanticInfoChain.getDeclForAST(funcDecl, this.document.fileName); + var funcSignature = funcPullDecl.getSignatureSymbol(); + this.emitDeclarationComments(funcDecl); + if (funcDecl.isConstructor) { + this.emitIndent(); + this.declFile.Write("constructor"); + this.emitTypeParameters(funcDecl.typeArguments, funcSignature); + } else { + var id = funcDecl.getNameText(); + if (!isInterfaceMember) { + this.emitDeclFlags(TypeScript.ToDeclFlags(funcDecl.getFunctionFlags()), funcPullDecl, "function"); + if (id !== "__missing" || !funcDecl.name || !funcDecl.name.isMissing()) { + this.declFile.Write(id); + } else if (funcDecl.isConstructMember()) { + this.declFile.Write("new"); + } + + this.emitTypeParameters(funcDecl.typeArguments, funcSignature); + } else { + this.emitIndent(); + if (funcDecl.isConstructMember()) { + this.declFile.Write("new"); + this.emitTypeParameters(funcDecl.typeArguments, funcSignature); + } else if (!funcDecl.isCallMember() && !funcDecl.isIndexerMember()) { + this.declFile.Write(id); + this.emitTypeParameters(funcDecl.typeArguments, funcSignature); + if (TypeScript.hasFlag(funcDecl.name.getFlags(), 4 /* OptionalName */)) { + this.declFile.Write("? "); + } + } else { + this.emitTypeParameters(funcDecl.typeArguments, funcSignature); + } + } + } + + if (!funcDecl.isIndexerMember()) { + this.declFile.Write("("); + } else { + this.declFile.Write("["); + } + + if (funcDecl.arguments) { + var argsLen = funcDecl.arguments.members.length; + if (funcDecl.variableArgList) { + argsLen--; + } + + for (var i = 0; i < argsLen; i++) { + var argDecl = funcDecl.arguments.members[i]; + this.emitArgDecl(argDecl, funcDecl); + if (i < (argsLen - 1)) { + this.declFile.Write(", "); + } + } + } + + if (funcDecl.variableArgList) { + var lastArg = funcDecl.arguments.members[funcDecl.arguments.members.length - 1]; + if (funcDecl.arguments.members.length > 1) { + this.declFile.Write(", ..."); + } else { + this.declFile.Write("..."); + } + + this.emitArgDecl(lastArg, funcDecl); + } + + if (!funcDecl.isIndexerMember()) { + this.declFile.Write(")"); + } else { + this.declFile.Write("]"); + } + + if (!funcDecl.isConstructor && this.canEmitTypeAnnotationSignature(TypeScript.ToDeclFlags(funcDecl.getFunctionFlags()))) { + var returnType = funcSignature.returnType; + if (funcDecl.returnTypeAnnotation || (returnType && returnType !== this.compiler.semanticInfoChain.anyTypeSymbol)) { + this.declFile.Write(": "); + this.emitTypeSignature(returnType); + } + } + + this.declFile.WriteLine(";"); + + return false; + }; + + DeclarationEmitter.prototype.emitBaseExpression = function (bases, index) { + var start = new Date().getTime(); + var baseTypeAndDiagnostics = this.compiler.semanticInfoChain.getSymbolForAST(bases.members[index], this.document.fileName); + TypeScript.declarationEmitGetBaseTypeTime += new Date().getTime() - start; + + var baseType = baseTypeAndDiagnostics && baseTypeAndDiagnostics; + this.emitTypeSignature(baseType); + }; + + DeclarationEmitter.prototype.emitBaseList = function (typeDecl, useExtendsList) { + var bases = useExtendsList ? typeDecl.extendsList : typeDecl.implementsList; + if (bases && (bases.members.length > 0)) { + var qual = useExtendsList ? "extends" : "implements"; + this.declFile.Write(" " + qual + " "); + var basesLen = bases.members.length; + for (var i = 0; i < basesLen; i++) { + if (i > 0) { + this.declFile.Write(", "); + } + this.emitBaseExpression(bases, i); + } + } + }; + + DeclarationEmitter.prototype.emitAccessorDeclarationComments = function (funcDecl) { + if (this.compiler.emitOptions.compilationSettings.removeComments) { + return; + } + + var start = new Date().getTime(); + var accessors = TypeScript.PullHelpers.getGetterAndSetterFunction(funcDecl, this.compiler.semanticInfoChain, this.document.fileName); + TypeScript.declarationEmitGetAccessorFunctionTime += new Date().getTime(); + + var comments = []; + if (accessors.getter) { + comments = comments.concat(accessors.getter.docComments()); + } + if (accessors.setter) { + comments = comments.concat(accessors.setter.docComments()); + } + + this.writeDeclarationComments(comments); + }; + + DeclarationEmitter.prototype.emitPropertyAccessorSignature = function (funcDecl) { + var start = new Date().getTime(); + var accessorSymbol = TypeScript.PullHelpers.getAccessorSymbol(funcDecl, this.compiler.semanticInfoChain, this.document.fileName); + TypeScript.declarationEmitGetAccessorFunctionTime += new Date().getTime(); + + if (!TypeScript.hasFlag(funcDecl.getFunctionFlags(), 32 /* GetAccessor */) && accessorSymbol.getGetter()) { + return false; + } + + this.emitAccessorDeclarationComments(funcDecl); + this.emitDeclFlags(TypeScript.ToDeclFlags(funcDecl.getFunctionFlags()), this.compiler.semanticInfoChain.getDeclForAST(funcDecl, this.document.fileName), "var"); + this.declFile.Write(funcDecl.name.actualText); + if (this.canEmitTypeAnnotationSignature(TypeScript.ToDeclFlags(funcDecl.getFunctionFlags()))) { + this.declFile.Write(" : "); + var type = accessorSymbol.type; + this.emitTypeSignature(type); + } + this.declFile.WriteLine(";"); + + return false; + }; + + DeclarationEmitter.prototype.emitClassMembersFromConstructorDefinition = function (funcDecl) { + if (funcDecl.arguments) { + var argsLen = funcDecl.arguments.members.length; + if (funcDecl.variableArgList) { + argsLen--; + } + + for (var i = 0; i < argsLen; i++) { + var argDecl = funcDecl.arguments.members[i]; + if (TypeScript.hasFlag(argDecl.getVarFlags(), 256 /* Property */)) { + var funcPullDecl = this.compiler.semanticInfoChain.getDeclForAST(funcDecl, this.document.fileName); + this.emitDeclarationComments(argDecl); + this.emitDeclFlags(TypeScript.ToDeclFlags(argDecl.getVarFlags()), funcPullDecl, "var"); + this.declFile.Write(argDecl.id.actualText); + + if (this.canEmitTypeAnnotationSignature(TypeScript.ToDeclFlags(argDecl.getVarFlags()))) { + this.emitTypeOfBoundDecl(argDecl); + } + this.declFile.WriteLine(";"); + } + } + } + }; + + DeclarationEmitter.prototype.classDeclarationCallback = function (pre, classDecl) { + if (!this.canEmitPrePostAstSignature(TypeScript.ToDeclFlags(classDecl.getVarFlags()), classDecl, pre)) { + return false; + } + + if (pre) { + var className = classDecl.name.actualText; + this.emitDeclarationComments(classDecl); + var classPullDecl = this.compiler.semanticInfoChain.getDeclForAST(classDecl, this.document.fileName); + this.emitDeclFlags(TypeScript.ToDeclFlags(classDecl.getVarFlags()), classPullDecl, "class"); + this.declFile.Write(className); + this.pushDeclarationContainer(classDecl); + this.emitTypeParameters(classDecl.typeParameters); + this.emitBaseList(classDecl, true); + this.emitBaseList(classDecl, false); + this.declFile.WriteLine(" {"); + + this.indenter.increaseIndent(); + if (classDecl.constructorDecl) { + this.emitClassMembersFromConstructorDefinition(classDecl.constructorDecl); + } + } else { + this.indenter.decreaseIndent(); + this.popDeclarationContainer(classDecl); + + this.emitIndent(); + this.declFile.WriteLine("}"); + } + + return true; + }; + + DeclarationEmitter.prototype.emitTypeParameters = function (typeParams, funcSignature) { + if (!typeParams || !typeParams.members.length) { + return; + } + + this.declFile.Write("<"); + var containerAst = this.getAstDeclarationContainer(); + + var start = new Date().getTime(); + var containerDecl = this.compiler.semanticInfoChain.getDeclForAST(containerAst, this.document.fileName); + var containerSymbol = containerDecl.getSymbol(); + TypeScript.declarationEmitGetTypeParameterSymbolTime += new Date().getTime() - start; + + var typars; + if (funcSignature) { + typars = funcSignature.getTypeParameters(); + } else { + typars = containerSymbol.getTypeArguments(); + if (!typars || !typars.length) { + typars = containerSymbol.getTypeParameters(); + } + } + + for (var i = 0; i < typars.length; i++) { + if (i) { + this.declFile.Write(", "); + } + + var memberName = typars[i].getScopedNameEx(containerSymbol, true); + this.emitTypeNamesMember(memberName); + } + + this.declFile.Write(">"); + }; + + DeclarationEmitter.prototype.interfaceDeclarationCallback = function (pre, interfaceDecl) { + if (!this.canEmitPrePostAstSignature(TypeScript.ToDeclFlags(interfaceDecl.getVarFlags()), interfaceDecl, pre)) { + return false; + } + + if (interfaceDecl.isObjectTypeLiteral) { + return false; + } + + if (pre) { + var interfaceName = interfaceDecl.name.actualText; + this.emitDeclarationComments(interfaceDecl); + var interfacePullDecl = this.compiler.semanticInfoChain.getDeclForAST(interfaceDecl, this.document.fileName); + this.emitDeclFlags(TypeScript.ToDeclFlags(interfaceDecl.getVarFlags()), interfacePullDecl, "interface"); + this.declFile.Write(interfaceName); + this.pushDeclarationContainer(interfaceDecl); + this.emitTypeParameters(interfaceDecl.typeParameters); + this.emitBaseList(interfaceDecl, true); + this.declFile.WriteLine(" {"); + + this.indenter.increaseIndent(); + } else { + this.indenter.decreaseIndent(); + this.popDeclarationContainer(interfaceDecl); + + this.emitIndent(); + this.declFile.WriteLine("}"); + } + + return true; + }; + + DeclarationEmitter.prototype.importDeclarationCallback = function (pre, importDeclAST) { + if (pre) { + var importDecl = this.compiler.semanticInfoChain.getDeclForAST(importDeclAST, this.document.fileName); + var importSymbol = importDecl.getSymbol(); + var isExportedImportDecl = TypeScript.hasFlag(importDeclAST.getVarFlags(), 1 /* Exported */); + + if (isExportedImportDecl || importSymbol.typeUsedExternally || TypeScript.PullContainerTypeSymbol.usedAsSymbol(importSymbol.getContainer(), importSymbol)) { + this.emitDeclarationComments(importDeclAST); + this.emitIndent(); + if (isExportedImportDecl) { + this.declFile.Write("export "); + } + this.declFile.Write("import "); + this.declFile.Write(importDeclAST.id.actualText + " = "); + if (importDeclAST.isExternalImportDeclaration()) { + this.declFile.WriteLine("require(" + importDeclAST.getAliasName() + ");"); + } else { + this.declFile.WriteLine(importDeclAST.getAliasName() + ";"); + } + } + } + + return false; + }; + + DeclarationEmitter.prototype.emitEnumSignature = function (moduleDecl) { + if (!this.canEmitSignature(TypeScript.ToDeclFlags(moduleDecl.getModuleFlags()), moduleDecl)) { + return false; + } + + this.emitDeclarationComments(moduleDecl); + var modulePullDecl = this.compiler.semanticInfoChain.getDeclForAST(moduleDecl, this.document.fileName); + this.emitDeclFlags(TypeScript.ToDeclFlags(moduleDecl.getModuleFlags()), modulePullDecl, "enum"); + this.declFile.WriteLine(moduleDecl.name.actualText + " {"); + + this.indenter.increaseIndent(); + var membersLen = moduleDecl.members.members.length; + for (var j = 0; j < membersLen; j++) { + var memberDecl = moduleDecl.members.members[j]; + var variableStatement = memberDecl; + var varDeclarator = variableStatement.declaration.declarators.members[0]; + this.emitDeclarationComments(varDeclarator); + this.emitIndent(); + this.declFile.Write(varDeclarator.id.actualText); + if (varDeclarator.init && varDeclarator.init.nodeType() == 7 /* NumericLiteral */) { + this.declFile.Write(" = " + (varDeclarator.init).text()); + } + this.declFile.WriteLine(","); + } + this.indenter.decreaseIndent(); + + this.emitIndent(); + this.declFile.WriteLine("}"); + + return false; + }; + + DeclarationEmitter.prototype.moduleDeclarationCallback = function (pre, moduleDecl) { + if (TypeScript.hasFlag(moduleDecl.getModuleFlags(), 256 /* IsWholeFile */)) { + if (TypeScript.hasFlag(moduleDecl.getModuleFlags(), 512 /* IsDynamic */)) { + if (pre) { + this.pushDeclarationContainer(moduleDecl); + } else { + this.popDeclarationContainer(moduleDecl); + } + } + + return true; + } + + if (moduleDecl.isEnum()) { + if (pre) { + this.emitEnumSignature(moduleDecl); + } + return false; + } + + if (!this.canEmitPrePostAstSignature(TypeScript.ToDeclFlags(moduleDecl.getModuleFlags()), moduleDecl, pre)) { + return false; + } + + if (pre) { + if (this.emitDottedModuleName()) { + this.dottedModuleEmit += "."; + } else { + var modulePullDecl = this.compiler.semanticInfoChain.getDeclForAST(moduleDecl, this.document.fileName); + this.dottedModuleEmit = this.getDeclFlagsString(TypeScript.ToDeclFlags(moduleDecl.getModuleFlags()), modulePullDecl, "module"); + } + + this.dottedModuleEmit += moduleDecl.name.actualText; + + var isCurrentModuleDotted = (moduleDecl.members.members.length === 1 && moduleDecl.members.members[0].nodeType() === 16 /* ModuleDeclaration */ && !(moduleDecl.members.members[0]).isEnum() && TypeScript.hasFlag((moduleDecl.members.members[0]).getModuleFlags(), 1 /* Exported */)); + + var moduleDeclComments = moduleDecl.docComments(); + isCurrentModuleDotted = isCurrentModuleDotted && (moduleDeclComments === null || moduleDeclComments.length === 0); + + this.isDottedModuleName.push(isCurrentModuleDotted); + this.pushDeclarationContainer(moduleDecl); + + if (!isCurrentModuleDotted) { + this.emitDeclarationComments(moduleDecl); + this.declFile.Write(this.dottedModuleEmit); + this.declFile.WriteLine(" {"); + this.indenter.increaseIndent(); + } + } else { + if (!this.emitDottedModuleName()) { + this.indenter.decreaseIndent(); + this.emitIndent(); + this.declFile.WriteLine("}"); + } + + this.popDeclarationContainer(moduleDecl); + this.isDottedModuleName.pop(); + } + + return true; + }; + + DeclarationEmitter.prototype.exportAssignmentCallback = function (pre, ast) { + if (pre) { + this.emitIndent(); + this.declFile.Write("export = "); + this.declFile.Write(ast.id.actualText); + this.declFile.WriteLine(";"); + } + + return false; + }; + + DeclarationEmitter.prototype.emitReferencePaths = function (script) { + if (this.emittedReferencePaths) { + return; + } + + var documents = []; + if (this.compiler.emitOptions.outputMany || script.topLevelMod) { + var scriptReferences = script.referencedFiles; + var addedGlobalDocument = false; + for (var j = 0; j < scriptReferences.length; j++) { + var currentReference = scriptReferences[j]; + var document = this.compiler.getDocument(currentReference); + + if (this.compiler.emitOptions.outputMany || document.script.isDeclareFile || document.script.topLevelMod || !addedGlobalDocument) { + documents = documents.concat(document); + if (!document.script.isDeclareFile && document.script.topLevelMod) { + addedGlobalDocument = true; + } + } + } + } else { + var allDocuments = this.compiler.getDocuments(); + for (var i = 0; i < allDocuments.length; i++) { + if (!allDocuments[i].script.isDeclareFile && !allDocuments[i].script.topLevelMod) { + var scriptReferences = allDocuments[i].script.referencedFiles; + for (var j = 0; j < scriptReferences.length; j++) { + var currentReference = scriptReferences[j]; + var document = this.compiler.getDocument(currentReference); + + if (document.script.isDeclareFile || document.script.topLevelMod) { + for (var k = 0; k < documents.length; k++) { + if (documents[k] == document) { + break; + } + } + + if (k == documents.length) { + documents = documents.concat(document); + } + } + } + } + } + } + + var emittingFilePath = documents.length ? TypeScript.getRootFilePath(this.emittingFileName) : null; + for (var i = 0; i < documents.length; i++) { + var document = documents[i]; + var declFileName; + if (document.script.isDeclareFile) { + declFileName = document.fileName; + } else { + declFileName = this.compiler.emitOptions.mapOutputFileName(document, TypeScript.TypeScriptCompiler.mapToDTSFileName); + } + + declFileName = TypeScript.getRelativePathToFixedPath(emittingFilePath, declFileName, false); + this.declFile.WriteLine('/// '); + } + + this.emittedReferencePaths = true; + }; + + DeclarationEmitter.prototype.scriptCallback = function (pre, script) { + if (pre) { + this.emitReferencePaths(script); + this.pushDeclarationContainer(script); + } else { + this.popDeclarationContainer(script); + } + return true; + }; + + DeclarationEmitter.prototype.defaultCallback = function (pre, ast) { + return !ast.isStatement(); + }; + return DeclarationEmitter; + })(); + TypeScript.DeclarationEmitter = DeclarationEmitter; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var BloomFilter = (function () { + function BloomFilter(expectedCount) { + var m = Math.max(1, BloomFilter.computeM(expectedCount)); + var k = Math.max(1, BloomFilter.computeK(expectedCount)); + ; + + var sizeInEvenBytes = (m + 7) & ~7; + + this.bitArray = []; + for (var i = 0, len = sizeInEvenBytes; i < len; i++) { + this.bitArray[i] = false; + } + this.hashFunctionCount = k; + } + BloomFilter.computeM = function (expectedCount) { + var p = BloomFilter.falsePositiveProbability; + var n = expectedCount; + + var numerator = n * Math.log(p); + var denominator = Math.log(1.0 / Math.pow(2.0, Math.log(2.0))); + return Math.ceil(numerator / denominator); + }; + + BloomFilter.computeK = function (expectedCount) { + var n = expectedCount; + var m = BloomFilter.computeM(expectedCount); + + var temp = Math.log(2.0) * m / n; + return Math.round(temp); + }; + + BloomFilter.prototype.computeHash = function (key, seed) { + return TypeScript.Hash.computeMurmur2StringHashCode(key, seed); + }; + + BloomFilter.prototype.addKeys = function (keys) { + for (var name in keys) { + if (keys[name]) { + this.add(name); + } + } + }; + + BloomFilter.prototype.add = function (value) { + for (var i = 0; i < this.hashFunctionCount; i++) { + var hash = this.computeHash(value, i); + hash = hash % this.bitArray.length; + this.bitArray[Math.abs(hash)] = true; + } + }; + + BloomFilter.prototype.probablyContains = function (value) { + for (var i = 0; i < this.hashFunctionCount; i++) { + var hash = this.computeHash(value, i); + hash = hash % this.bitArray.length; + if (!this.bitArray[Math.abs(hash)]) { + return false; + } + } + + return true; + }; + + BloomFilter.prototype.isEquivalent = function (filter) { + return BloomFilter.isEquivalent(this.bitArray, filter.bitArray) && this.hashFunctionCount == filter.hashFunctionCount; + }; + + BloomFilter.isEquivalent = function (array1, array2) { + if (array1.length != array2.length) { + return false; + } + + for (var i = 0; i < array1.length; i++) { + if (array1[i] != array2[i]) { + return false; + } + } + + return true; + }; + BloomFilter.falsePositiveProbability = 0.0001; + return BloomFilter; + })(); + TypeScript.BloomFilter = BloomFilter; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var IdentifierWalker = (function (_super) { + __extends(IdentifierWalker, _super); + function IdentifierWalker(list) { + _super.call(this); + this.list = list; + } + IdentifierWalker.prototype.visitToken = function (token) { + this.list[token.text()] = true; + }; + return IdentifierWalker; + })(TypeScript.SyntaxWalker); + TypeScript.IdentifierWalker = IdentifierWalker; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var DataMap = (function () { + function DataMap() { + this.map = {}; + } + DataMap.prototype.link = function (id, data) { + this.map[id] = data; + }; + + DataMap.prototype.unlink = function (id) { + this.map[id] = undefined; + }; + + DataMap.prototype.read = function (id) { + return this.map[id]; + }; + return DataMap; + })(); + TypeScript.DataMap = DataMap; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (PullElementFlags) { + PullElementFlags[PullElementFlags["None"] = 0] = "None"; + PullElementFlags[PullElementFlags["Exported"] = 1] = "Exported"; + PullElementFlags[PullElementFlags["Private"] = 1 << 1] = "Private"; + PullElementFlags[PullElementFlags["Public"] = 1 << 2] = "Public"; + PullElementFlags[PullElementFlags["Ambient"] = 1 << 3] = "Ambient"; + PullElementFlags[PullElementFlags["Static"] = 1 << 4] = "Static"; + PullElementFlags[PullElementFlags["GetAccessor"] = 1 << 5] = "GetAccessor"; + PullElementFlags[PullElementFlags["SetAccessor"] = 1 << 6] = "SetAccessor"; + PullElementFlags[PullElementFlags["Optional"] = 1 << 7] = "Optional"; + PullElementFlags[PullElementFlags["Call"] = 1 << 8] = "Call"; + PullElementFlags[PullElementFlags["Constructor"] = 1 << 9] = "Constructor"; + PullElementFlags[PullElementFlags["Index"] = 1 << 10] = "Index"; + PullElementFlags[PullElementFlags["Signature"] = 1 << 11] = "Signature"; + PullElementFlags[PullElementFlags["Enum"] = 1 << 12] = "Enum"; + PullElementFlags[PullElementFlags["FatArrow"] = 1 << 13] = "FatArrow"; + + PullElementFlags[PullElementFlags["ClassConstructorVariable"] = 1 << 14] = "ClassConstructorVariable"; + PullElementFlags[PullElementFlags["InitializedModule"] = 1 << 15] = "InitializedModule"; + PullElementFlags[PullElementFlags["InitializedDynamicModule"] = 1 << 16] = "InitializedDynamicModule"; + PullElementFlags[PullElementFlags["InitializedEnum"] = 1 << 17] = "InitializedEnum"; + + PullElementFlags[PullElementFlags["MustCaptureThis"] = 1 << 18] = "MustCaptureThis"; + PullElementFlags[PullElementFlags["Constant"] = 1 << 19] = "Constant"; + + PullElementFlags[PullElementFlags["ExpressionElement"] = 1 << 20] = "ExpressionElement"; + + PullElementFlags[PullElementFlags["DeclaredInAWithBlock"] = 1 << 21] = "DeclaredInAWithBlock"; + + PullElementFlags[PullElementFlags["HasReturnStatement"] = 1 << 22] = "HasReturnStatement"; + + PullElementFlags[PullElementFlags["PropertyParameter"] = 1 << 23] = "PropertyParameter"; + + PullElementFlags[PullElementFlags["IsAnnotatedWithAny"] = 1 << 24] = "IsAnnotatedWithAny"; + + PullElementFlags[PullElementFlags["ImplicitVariable"] = PullElementFlags.ClassConstructorVariable | PullElementFlags.InitializedModule | PullElementFlags.InitializedDynamicModule | PullElementFlags.InitializedEnum] = "ImplicitVariable"; + PullElementFlags[PullElementFlags["SomeInitializedModule"] = PullElementFlags.InitializedModule | PullElementFlags.InitializedDynamicModule | PullElementFlags.InitializedEnum] = "SomeInitializedModule"; + })(TypeScript.PullElementFlags || (TypeScript.PullElementFlags = {})); + var PullElementFlags = TypeScript.PullElementFlags; + + (function (PullElementKind) { + PullElementKind[PullElementKind["None"] = 0] = "None"; + PullElementKind[PullElementKind["Global"] = 0] = "Global"; + + PullElementKind[PullElementKind["Script"] = 1] = "Script"; + PullElementKind[PullElementKind["Primitive"] = 1 << 1] = "Primitive"; + + PullElementKind[PullElementKind["Container"] = 1 << 2] = "Container"; + PullElementKind[PullElementKind["Class"] = 1 << 3] = "Class"; + PullElementKind[PullElementKind["Interface"] = 1 << 4] = "Interface"; + PullElementKind[PullElementKind["DynamicModule"] = 1 << 5] = "DynamicModule"; + PullElementKind[PullElementKind["Enum"] = 1 << 6] = "Enum"; + PullElementKind[PullElementKind["Array"] = 1 << 7] = "Array"; + PullElementKind[PullElementKind["TypeAlias"] = 1 << 8] = "TypeAlias"; + PullElementKind[PullElementKind["ObjectLiteral"] = 1 << 9] = "ObjectLiteral"; + + PullElementKind[PullElementKind["Variable"] = 1 << 10] = "Variable"; + PullElementKind[PullElementKind["Parameter"] = 1 << 11] = "Parameter"; + PullElementKind[PullElementKind["Property"] = 1 << 12] = "Property"; + PullElementKind[PullElementKind["TypeParameter"] = 1 << 13] = "TypeParameter"; + + PullElementKind[PullElementKind["Function"] = 1 << 14] = "Function"; + PullElementKind[PullElementKind["ConstructorMethod"] = 1 << 15] = "ConstructorMethod"; + PullElementKind[PullElementKind["Method"] = 1 << 16] = "Method"; + PullElementKind[PullElementKind["FunctionExpression"] = 1 << 17] = "FunctionExpression"; + + PullElementKind[PullElementKind["GetAccessor"] = 1 << 18] = "GetAccessor"; + PullElementKind[PullElementKind["SetAccessor"] = 1 << 19] = "SetAccessor"; + + PullElementKind[PullElementKind["CallSignature"] = 1 << 20] = "CallSignature"; + PullElementKind[PullElementKind["ConstructSignature"] = 1 << 21] = "ConstructSignature"; + PullElementKind[PullElementKind["IndexSignature"] = 1 << 22] = "IndexSignature"; + + PullElementKind[PullElementKind["ObjectType"] = 1 << 23] = "ObjectType"; + PullElementKind[PullElementKind["FunctionType"] = 1 << 24] = "FunctionType"; + PullElementKind[PullElementKind["ConstructorType"] = 1 << 25] = "ConstructorType"; + + PullElementKind[PullElementKind["EnumMember"] = 1 << 26] = "EnumMember"; + PullElementKind[PullElementKind["ErrorType"] = 1 << 27] = "ErrorType"; + + PullElementKind[PullElementKind["Expression"] = 1 << 28] = "Expression"; + + PullElementKind[PullElementKind["WithBlock"] = 1 << 29] = "WithBlock"; + PullElementKind[PullElementKind["CatchBlock"] = 1 << 30] = "CatchBlock"; + + PullElementKind[PullElementKind["All"] = PullElementKind.Script | PullElementKind.Global | PullElementKind.Primitive | PullElementKind.Container | PullElementKind.Class | PullElementKind.Interface | PullElementKind.DynamicModule | PullElementKind.Enum | PullElementKind.Array | PullElementKind.TypeAlias | PullElementKind.ObjectLiteral | PullElementKind.Variable | PullElementKind.Parameter | PullElementKind.Property | PullElementKind.TypeParameter | PullElementKind.Function | PullElementKind.ConstructorMethod | PullElementKind.Method | PullElementKind.FunctionExpression | PullElementKind.GetAccessor | PullElementKind.SetAccessor | PullElementKind.CallSignature | PullElementKind.ConstructSignature | PullElementKind.IndexSignature | PullElementKind.ObjectType | PullElementKind.FunctionType | PullElementKind.ConstructorType | PullElementKind.EnumMember | PullElementKind.ErrorType | PullElementKind.Expression | PullElementKind.WithBlock | PullElementKind.CatchBlock] = "All"; + + PullElementKind[PullElementKind["SomeFunction"] = PullElementKind.Function | PullElementKind.ConstructorMethod | PullElementKind.Method | PullElementKind.FunctionExpression | PullElementKind.GetAccessor | PullElementKind.SetAccessor | PullElementKind.CallSignature | PullElementKind.ConstructSignature | PullElementKind.IndexSignature] = "SomeFunction"; + + PullElementKind[PullElementKind["SomeValue"] = PullElementKind.Variable | PullElementKind.Parameter | PullElementKind.Property | PullElementKind.EnumMember | PullElementKind.SomeFunction] = "SomeValue"; + + PullElementKind[PullElementKind["SomeType"] = PullElementKind.Script | PullElementKind.Global | PullElementKind.Primitive | PullElementKind.Class | PullElementKind.Interface | PullElementKind.Enum | PullElementKind.Array | PullElementKind.ObjectType | PullElementKind.FunctionType | PullElementKind.ConstructorType | PullElementKind.TypeParameter | PullElementKind.ErrorType] = "SomeType"; + + PullElementKind[PullElementKind["AcceptableAlias"] = PullElementKind.Variable | PullElementKind.SomeFunction | PullElementKind.Class | PullElementKind.Interface | PullElementKind.Enum | PullElementKind.Container | PullElementKind.ObjectType | PullElementKind.FunctionType | PullElementKind.ConstructorType] = "AcceptableAlias"; + + PullElementKind[PullElementKind["SomeContainer"] = PullElementKind.Container | PullElementKind.DynamicModule | PullElementKind.TypeAlias] = "SomeContainer"; + + PullElementKind[PullElementKind["SomeBlock"] = PullElementKind.WithBlock | PullElementKind.CatchBlock] = "SomeBlock"; + + PullElementKind[PullElementKind["SomeSignature"] = PullElementKind.CallSignature | PullElementKind.ConstructSignature | PullElementKind.IndexSignature] = "SomeSignature"; + + PullElementKind[PullElementKind["SomeAccessor"] = PullElementKind.GetAccessor | PullElementKind.SetAccessor] = "SomeAccessor"; + + PullElementKind[PullElementKind["SomeTypeReference"] = PullElementKind.Interface | PullElementKind.ObjectType | PullElementKind.FunctionType | PullElementKind.ConstructorType] = "SomeTypeReference"; + + PullElementKind[PullElementKind["SomeLHS"] = PullElementKind.Variable | PullElementKind.Property | PullElementKind.Parameter | PullElementKind.SetAccessor | PullElementKind.Method] = "SomeLHS"; + + PullElementKind[PullElementKind["InterfaceTypeExtension"] = PullElementKind.Interface | PullElementKind.Class | PullElementKind.Enum] = "InterfaceTypeExtension"; + PullElementKind[PullElementKind["ClassTypeExtension"] = PullElementKind.Interface | PullElementKind.Class] = "ClassTypeExtension"; + PullElementKind[PullElementKind["EnumTypeExtension"] = PullElementKind.Interface | PullElementKind.Enum] = "EnumTypeExtension"; + })(TypeScript.PullElementKind || (TypeScript.PullElementKind = {})); + var PullElementKind = TypeScript.PullElementKind; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + TypeScript.pullDeclID = 0; + TypeScript.lastBoundPullDeclId = 0; + var sentinelEmptyPullDeclArray = []; + + var PullDecl = (function () { + function PullDecl(declName, displayName, kind, declFlags, span, scriptName) { + this.symbol = null; + this.declGroups = new TypeScript.BlockIntrinsics(); + this.signatureSymbol = null; + this.specializingSignatureSymbol = null; + this.childDecls = null; + this.typeParameters = null; + this.childDeclTypeCache = new TypeScript.BlockIntrinsics(); + this.childDeclValueCache = new TypeScript.BlockIntrinsics(); + this.childDeclNamespaceCache = new TypeScript.BlockIntrinsics(); + this.childDeclTypeParameterCache = new TypeScript.BlockIntrinsics(); + this.declID = TypeScript.pullDeclID++; + this.declIDString = null; + this.flags = 0 /* None */; + this.diagnostics = null; + this.parentDecl = null; + this._parentPath = null; + this._isBound = false; + this.synthesizedValDecl = null; + this.hashCode = -1; + this.ast = null; + this.name = declName; + this.kind = kind; + this.flags = declFlags; + this.span = span; + this.scriptName = scriptName; + + if (displayName !== this.name) { + this.declDisplayName = displayName; + } + + this.hashCode = this.declID ^ this.kind; + this.declIDString = this.declID.toString(); + } + PullDecl.prototype.getDisplayName = function () { + return this.declDisplayName === undefined ? this.name : this.declDisplayName; + }; + + PullDecl.prototype.setSymbol = function (symbol) { + this.symbol = symbol; + }; + + PullDecl.prototype.ensureSymbolIsBound = function (bindSignatureSymbol) { + if (typeof bindSignatureSymbol === "undefined") { bindSignatureSymbol = false; } + if (!((bindSignatureSymbol && this.signatureSymbol) || this.symbol) && !this._isBound && this.kind != 1 /* Script */) { + var prevUnit = TypeScript.globalBinder.semanticInfo; + TypeScript.globalBinder.setUnit(this.scriptName); + TypeScript.globalBinder.bindDeclToPullSymbol(this); + if (prevUnit) { + TypeScript.globalBinder.setUnit(prevUnit.getPath()); + } + } + }; + + PullDecl.prototype.getSymbol = function () { + if (this.kind == 1 /* Script */) { + return null; + } + + this.ensureSymbolIsBound(); + + return this.symbol; + }; + + PullDecl.prototype.hasSymbol = function () { + return this.symbol != null; + }; + + PullDecl.prototype.setSignatureSymbol = function (signature) { + this.signatureSymbol = signature; + }; + PullDecl.prototype.getSignatureSymbol = function () { + this.ensureSymbolIsBound(true); + + return this.signatureSymbol; + }; + + PullDecl.prototype.hasSignature = function () { + return this.signatureSymbol != null; + }; + + PullDecl.prototype.setSpecializingSignatureSymbol = function (signature) { + this.specializingSignatureSymbol = signature; + }; + PullDecl.prototype.getSpecializingSignatureSymbol = function () { + if (this.specializingSignatureSymbol) { + return this.specializingSignatureSymbol; + } + + return this.signatureSymbol; + }; + + PullDecl.prototype.setFlags = function (flags) { + this.flags = flags; + }; + PullDecl.prototype.setFlag = function (flags) { + this.flags |= flags; + }; + + PullDecl.prototype.getSpan = function () { + return this.span; + }; + PullDecl.prototype.setSpan = function (span) { + this.span = span; + }; + + PullDecl.prototype.getScriptName = function () { + return this.scriptName; + }; + + PullDecl.prototype.setValueDecl = function (valDecl) { + this.synthesizedValDecl = valDecl; + }; + PullDecl.prototype.getValueDecl = function () { + return this.synthesizedValDecl; + }; + + PullDecl.prototype.isEqual = function (other) { + return (this.name === other.name) && (this.kind === other.kind) && (this.flags === other.flags) && (this.scriptName === other.scriptName) && (this.span.start() === other.span.start()) && (this.span.end() === other.span.end()); + }; + + PullDecl.prototype.getParentDecl = function () { + return this.parentDecl; + }; + + PullDecl.prototype.setParentDecl = function (parentDecl) { + this.parentDecl = parentDecl; + }; + + PullDecl.prototype.addDiagnostic = function (diagnostic) { + if (diagnostic) { + if (!this.diagnostics) { + this.diagnostics = []; + } + + this.diagnostics[this.diagnostics.length] = diagnostic; + } + }; + + PullDecl.prototype.getDiagnostics = function () { + return this.diagnostics ? this.diagnostics : sentinelEmptyPullDeclArray; + }; + + PullDecl.prototype.resetErrors = function () { + this.diagnostics = null; + }; + + PullDecl.prototype.getChildDeclCache = function (declKind) { + return declKind === 8192 /* TypeParameter */ ? this.childDeclTypeParameterCache : TypeScript.hasFlag(declKind, TypeScript.PullElementKind.SomeContainer) ? this.childDeclNamespaceCache : TypeScript.hasFlag(declKind, TypeScript.PullElementKind.SomeType) ? this.childDeclTypeCache : this.childDeclValueCache; + }; + + PullDecl.prototype.addChildDecl = function (childDecl) { + if (childDecl.kind === 8192 /* TypeParameter */) { + if (!this.typeParameters) { + this.typeParameters = []; + } + this.typeParameters[this.typeParameters.length] = childDecl; + } else { + if (!this.childDecls) { + this.childDecls = []; + } + this.childDecls[this.childDecls.length] = childDecl; + } + + var declName = childDecl.name; + var cache = this.getChildDeclCache(childDecl.kind); + var childrenOfName = cache[declName]; + if (!childrenOfName) { + childrenOfName = []; + } + + childrenOfName.push(childDecl); + cache[declName] = childrenOfName; + }; + + PullDecl.prototype.searchChildDecls = function (declName, searchKind) { + var cacheVal = null; + + if (searchKind & TypeScript.PullElementKind.SomeType) { + cacheVal = this.childDeclTypeCache[declName]; + } else if (searchKind & TypeScript.PullElementKind.SomeContainer) { + cacheVal = this.childDeclNamespaceCache[declName]; + } else { + cacheVal = this.childDeclValueCache[declName]; + } + + if (cacheVal) { + return cacheVal; + } else { + if (searchKind & TypeScript.PullElementKind.SomeType) { + cacheVal = this.childDeclTypeParameterCache[declName]; + + if (cacheVal) { + return cacheVal; + } + } + + return sentinelEmptyPullDeclArray; + } + }; + + PullDecl.prototype.getChildDecls = function () { + return this.childDecls ? this.childDecls : sentinelEmptyPullDeclArray; + }; + PullDecl.prototype.getTypeParameters = function () { + return this.typeParameters ? this.typeParameters : sentinelEmptyPullDeclArray; + }; + + PullDecl.prototype.addVariableDeclToGroup = function (decl) { + var declGroup = this.declGroups[decl.name]; + if (declGroup) { + declGroup.addDecl(decl); + } else { + declGroup = new PullDeclGroup(decl.name); + declGroup.addDecl(decl); + this.declGroups[decl.name] = declGroup; + } + }; + + PullDecl.prototype.getVariableDeclGroups = function () { + var declGroups = null; + + for (var declName in this.declGroups) { + if (this.declGroups[declName]) { + if (!declGroups) { + declGroups = []; + } + + declGroups[declGroups.length] = this.declGroups[declName].getDecls(); + } + } + + return declGroups ? declGroups : sentinelEmptyPullDeclArray; + }; + + PullDecl.prototype.getParentPath = function () { + return this._parentPath; + }; + + PullDecl.prototype.setParentPath = function (path) { + this._parentPath = path; + }; + + PullDecl.prototype.setIsBound = function (isBinding) { + this._isBound = isBinding; + }; + + PullDecl.prototype.isBound = function () { + return this._isBound; + }; + return PullDecl; + })(); + TypeScript.PullDecl = PullDecl; + + var PullFunctionExpressionDecl = (function (_super) { + __extends(PullFunctionExpressionDecl, _super); + function PullFunctionExpressionDecl(expressionName, declFlags, span, scriptName) { + _super.call(this, "", "", 131072 /* FunctionExpression */, declFlags, span, scriptName); + this.functionExpressionName = expressionName; + } + PullFunctionExpressionDecl.prototype.getFunctionExpressionName = function () { + return this.functionExpressionName; + }; + return PullFunctionExpressionDecl; + })(PullDecl); + TypeScript.PullFunctionExpressionDecl = PullFunctionExpressionDecl; + + var PullDeclGroup = (function () { + function PullDeclGroup(name) { + this.name = name; + this._decls = []; + } + PullDeclGroup.prototype.addDecl = function (decl) { + if (decl.name === this.name) { + this._decls[this._decls.length] = decl; + } + }; + + PullDeclGroup.prototype.getDecls = function () { + return this._decls; + }; + return PullDeclGroup; + })(); + TypeScript.PullDeclGroup = PullDeclGroup; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + TypeScript.pullSymbolID = 0; + TypeScript.globalTyvarID = 0; + TypeScript.sentinelEmptyArray = []; + + var PullSymbol = (function () { + function PullSymbol(name, declKind) { + this.pullSymbolID = TypeScript.pullSymbolID++; + this.pullSymbolIDString = null; + this.cachedPathIDs = {}; + this._container = null; + this.type = null; + this._declarations = null; + this.isResolved = false; + this.isOptional = false; + this.inResolution = false; + this.isSynthesized = false; + this.isVarArg = false; + this.isSpecialized = false; + this.isBeingSpecialized = false; + this.rootSymbol = null; + this._parentAccessorSymbol = null; + this._enclosingSignature = null; + this.docComments = null; + this.isPrinting = false; + this.ast = null; + this.name = name; + this.kind = declKind; + this.pullSymbolIDString = this.pullSymbolID.toString(); + } + PullSymbol.prototype.isType = function () { + return (this.kind & TypeScript.PullElementKind.SomeType) != 0; + }; + + PullSymbol.prototype.isSignature = function () { + return (this.kind & TypeScript.PullElementKind.SomeSignature) != 0; + }; + + PullSymbol.prototype.isArray = function () { + return (this.kind & 128 /* Array */) != 0; + }; + + PullSymbol.prototype.isPrimitive = function () { + return this.kind === 2 /* Primitive */; + }; + + PullSymbol.prototype.isAccessor = function () { + return false; + }; + + PullSymbol.prototype.isError = function () { + return false; + }; + + PullSymbol.prototype.isInterface = function () { + return this.kind === 16 /* Interface */; + }; + + PullSymbol.prototype.isMethod = function () { + return this.kind === 65536 /* Method */; + }; + + PullSymbol.prototype.isProperty = function () { + return this.kind === 4096 /* Property */; + }; + + PullSymbol.prototype.isAlias = function () { + return false; + }; + PullSymbol.prototype.isContainer = function () { + return false; + }; + + PullSymbol.prototype.setAccessorSymbol = function (accessor) { + this._parentAccessorSymbol = accessor; + }; + + PullSymbol.prototype.getAccessorySymbol = function () { + return this._parentAccessorSymbol; + }; + + PullSymbol.prototype.findAliasedType = function (decls) { + for (var i = 0; i < decls.length; i++) { + var childDecls = decls[i].getChildDecls(); + for (var j = 0; j < childDecls.length; j++) { + if (childDecls[j].kind === 256 /* TypeAlias */) { + var symbol = childDecls[j].getSymbol(); + if (PullContainerTypeSymbol.usedAsSymbol(symbol, this)) { + return symbol; + } + } + } + } + + return null; + }; + + PullSymbol.prototype.getAliasedSymbol = function (scopeSymbol) { + if (!scopeSymbol) { + return null; + } + + var scopePath = scopeSymbol.pathToRoot(); + if (scopePath.length && scopePath[scopePath.length - 1].kind === 32 /* DynamicModule */) { + var decls = scopePath[scopePath.length - 1].getDeclarations(); + var symbol = this.findAliasedType(decls); + return symbol; + } + + return null; + }; + + PullSymbol.prototype.getScopedDynamicModuleAlias = function (scopeSymbol) { + var aliasSymbol = this.getAliasedSymbol(scopeSymbol); + + if (aliasSymbol) { + if (aliasSymbol.assignedValue) { + return null; + } + + if (aliasSymbol.assignedType && aliasSymbol.assignedType != aliasSymbol.assignedContainer) { + return null; + } + + if (aliasSymbol.assignedContainer.kind != 32 /* DynamicModule */) { + return null; + } + } + return aliasSymbol; + }; + + PullSymbol.prototype.getName = function (scopeSymbol, useConstraintInName) { + var symbol = this.getScopedDynamicModuleAlias(scopeSymbol); + if (symbol) { + return symbol.getName(); + } + + return this.name; + }; + + PullSymbol.prototype.getDisplayName = function (scopeSymbol, useConstraintInName) { + var symbol = this.getScopedDynamicModuleAlias(scopeSymbol); + if (symbol) { + return symbol.getDisplayName(); + } + + var decls = this.getDeclarations(); + return decls.length ? this.getDeclarations()[0].getDisplayName() : this.name; + }; + + PullSymbol.prototype.setIsSpecialized = function () { + this.isSpecialized = true; + this.isBeingSpecialized = false; + }; + PullSymbol.prototype.getIsSpecialized = function () { + return this.isSpecialized; + }; + PullSymbol.prototype.currentlyBeingSpecialized = function () { + return this.isBeingSpecialized; + }; + PullSymbol.prototype.setIsBeingSpecialized = function () { + this.isBeingSpecialized = true; + }; + PullSymbol.prototype.setValueIsBeingSpecialized = function (val) { + this.isBeingSpecialized = val; + }; + + PullSymbol.prototype.getRootSymbol = function () { + if (!this.rootSymbol) { + return this; + } + return this.rootSymbol; + }; + PullSymbol.prototype.setRootSymbol = function (symbol) { + this.rootSymbol = symbol; + }; + + PullSymbol.prototype.setIsSynthesized = function (value) { + if (typeof value === "undefined") { value = true; } + this.isSynthesized = value; + }; + PullSymbol.prototype.getIsSynthesized = function () { + return this.isSynthesized; + }; + + PullSymbol.prototype.setEnclosingSignature = function (signature) { + this._enclosingSignature = signature; + }; + + PullSymbol.prototype.getEnclosingSignature = function () { + return this._enclosingSignature; + }; + + PullSymbol.prototype.addCacheID = function (cacheID) { + if (!this.cachedPathIDs[cacheID]) { + this.cachedPathIDs[cacheID] = true; + } + }; + + PullSymbol.prototype.invalidateCachedIDs = function (cache) { + for (var id in this.cachedPathIDs) { + if (cache[id]) { + cache[id] = undefined; + } + } + }; + + PullSymbol.prototype.addDeclaration = function (decl) { + TypeScript.Debug.assert(!!decl); + + if (this.rootSymbol) { + return; + } + + if (!this._declarations) { + this._declarations = [decl]; + } else { + this._declarations[this._declarations.length] = decl; + } + }; + + PullSymbol.prototype.getDeclarations = function () { + if (this.rootSymbol) { + return this.rootSymbol.getDeclarations(); + } + + if (!this._declarations) { + this._declarations = []; + } + + return this._declarations; + }; + + PullSymbol.prototype.setContainer = function (containerSymbol) { + if (this.rootSymbol) { + return; + } + + this._container = containerSymbol; + }; + + PullSymbol.prototype.getContainer = function () { + if (this.rootSymbol) { + return this.rootSymbol.getContainer(); + } + + return this._container; + }; + + PullSymbol.prototype.setResolved = function () { + this.isResolved = true; + this.inResolution = false; + }; + + PullSymbol.prototype.startResolving = function () { + this.inResolution = true; + }; + + PullSymbol.prototype.setUnresolved = function () { + this.isResolved = false; + this.inResolution = false; + }; + + PullSymbol.prototype.invalidate = function () { + this.isResolved = false; + + var declarations = this.getDeclarations(); + }; + + PullSymbol.prototype.hasFlag = function (flag) { + var declarations = this.getDeclarations(); + for (var i = 0, n = declarations.length; i < n; i++) { + if ((declarations[i].flags & flag) !== 0 /* None */) { + return true; + } + } + return false; + }; + + PullSymbol.prototype.allDeclsHaveFlag = function (flag) { + var declarations = this.getDeclarations(); + for (var i = 0, n = declarations.length; i < n; i++) { + if (!((declarations[i].flags & flag) !== 0 /* None */)) { + return false; + } + } + return true; + }; + + PullSymbol.prototype.pathToRoot = function () { + var path = []; + var node = this; + while (node) { + if (node.isType()) { + var associatedContainerSymbol = (node).getAssociatedContainerType(); + if (associatedContainerSymbol) { + node = associatedContainerSymbol; + } + } + path[path.length] = node; + var nodeKind = node.kind; + if (nodeKind == 2048 /* Parameter */) { + break; + } else { + node = node.getContainer(); + } + } + return path; + }; + + PullSymbol.prototype.findCommonAncestorPath = function (b) { + var aPath = this.pathToRoot(); + if (aPath.length === 1) { + return aPath; + } + + var bPath; + if (b) { + bPath = b.pathToRoot(); + } else { + return aPath; + } + + var commonNodeIndex = -1; + for (var i = 0, aLen = aPath.length; i < aLen; i++) { + var aNode = aPath[i]; + for (var j = 0, bLen = bPath.length; j < bLen; j++) { + var bNode = bPath[j]; + if (aNode === bNode) { + var aDecl = null; + if (i > 0) { + var decls = aPath[i - 1].getDeclarations(); + if (decls.length) { + aDecl = decls[0].getParentDecl(); + } + } + var bDecl = null; + if (j > 0) { + var decls = bPath[j - 1].getDeclarations(); + if (decls.length) { + bDecl = decls[0].getParentDecl(); + } + } + if (!aDecl || !bDecl || aDecl == bDecl) { + commonNodeIndex = i; + break; + } + } + } + if (commonNodeIndex >= 0) { + break; + } + } + + if (commonNodeIndex >= 0) { + return aPath.slice(0, commonNodeIndex); + } else { + return aPath; + } + }; + + PullSymbol.prototype.toString = function (scopeSymbol, useConstraintInName) { + var str = this.getNameAndTypeName(scopeSymbol); + return str; + }; + + PullSymbol.prototype.getNamePartForFullName = function () { + return this.getDisplayName(null, true); + }; + + PullSymbol.prototype.fullName = function (scopeSymbol) { + var path = this.pathToRoot(); + var fullName = ""; + var aliasedSymbol = this.getScopedDynamicModuleAlias(scopeSymbol); + if (aliasedSymbol) { + return aliasedSymbol.fullName(scopeSymbol); + } + + for (var i = 1; i < path.length; i++) { + aliasedSymbol = path[i].getScopedDynamicModuleAlias(scopeSymbol); + if (aliasedSymbol) { + fullName = aliasedSymbol.fullName(scopeSymbol) + "." + fullName; + break; + } else { + var scopedName = path[i].getNamePartForFullName(); + if (path[i].kind == 32 /* DynamicModule */ && !TypeScript.isQuoted(scopedName)) { + break; + } + + if (scopedName === "") { + break; + } + + fullName = scopedName + "." + fullName; + } + } + + fullName = fullName + this.getNamePartForFullName(); + return fullName; + }; + + PullSymbol.prototype.getScopedName = function (scopeSymbol, useConstraintInName) { + var path = this.findCommonAncestorPath(scopeSymbol); + var fullName = ""; + var aliasedSymbol = this.getScopedDynamicModuleAlias(scopeSymbol); + if (aliasedSymbol) { + return aliasedSymbol.getScopedName(scopeSymbol); + } + + for (var i = 1; i < path.length; i++) { + var kind = path[i].kind; + if (kind === 4 /* Container */ || kind === 32 /* DynamicModule */) { + aliasedSymbol = path[i].getScopedDynamicModuleAlias(scopeSymbol); + if (aliasedSymbol) { + fullName = aliasedSymbol.getScopedName(scopeSymbol) + "." + fullName; + break; + } else if (kind === 4 /* Container */) { + fullName = path[i].getDisplayName() + "." + fullName; + } else { + var displayName = path[i].getDisplayName(); + if (TypeScript.isQuoted(displayName)) { + fullName = displayName + "." + fullName; + } + break; + } + } else { + break; + } + } + fullName = fullName + this.getDisplayName(scopeSymbol, useConstraintInName); + return fullName; + }; + + PullSymbol.prototype.getScopedNameEx = function (scopeSymbol, useConstraintInName, getPrettyTypeName, getTypeParamMarkerInfo) { + var name = this.getScopedName(scopeSymbol, useConstraintInName); + return TypeScript.MemberName.create(name); + }; + + PullSymbol.prototype.getTypeName = function (scopeSymbol, getPrettyTypeName) { + var memberName = this.getTypeNameEx(scopeSymbol, getPrettyTypeName); + return memberName.toString(); + }; + + PullSymbol.prototype.getTypeNameEx = function (scopeSymbol, getPrettyTypeName) { + var type = this.type; + if (type) { + var memberName = getPrettyTypeName ? this.getTypeNameForFunctionSignature("", scopeSymbol, getPrettyTypeName) : null; + if (!memberName) { + memberName = type.getScopedNameEx(scopeSymbol, true, getPrettyTypeName); + } + + return memberName; + } + return TypeScript.MemberName.create(""); + }; + + PullSymbol.prototype.getTypeNameForFunctionSignature = function (prefix, scopeSymbol, getPrettyTypeName) { + var type = this.type; + if (type && !type.isNamedTypeSymbol() && this.kind != 4096 /* Property */ && this.kind != 1024 /* Variable */ && this.kind != 2048 /* Parameter */) { + var signatures = type.getCallSignatures(); + if (signatures.length == 1 || (getPrettyTypeName && signatures.length)) { + var typeName = new TypeScript.MemberNameArray(); + var signatureName = PullSignatureSymbol.getSignaturesTypeNameEx(signatures, prefix, false, false, scopeSymbol, getPrettyTypeName); + typeName.addAll(signatureName); + return typeName; + } + } + + return null; + }; + + PullSymbol.prototype.getNameAndTypeName = function (scopeSymbol) { + var nameAndTypeName = this.getNameAndTypeNameEx(scopeSymbol); + return nameAndTypeName.toString(); + }; + + PullSymbol.prototype.getNameAndTypeNameEx = function (scopeSymbol) { + var type = this.type; + var nameStr = this.getDisplayName(scopeSymbol); + if (type) { + nameStr = nameStr + (this.isOptional ? "?" : ""); + var memberName = this.getTypeNameForFunctionSignature(nameStr, scopeSymbol); + if (!memberName) { + var typeNameEx = type.getScopedNameEx(scopeSymbol); + memberName = TypeScript.MemberName.create(typeNameEx, nameStr + ": ", ""); + } + return memberName; + } + return TypeScript.MemberName.create(nameStr); + }; + + PullSymbol.getTypeParameterString = function (typars, scopeSymbol, useContraintInName) { + return PullSymbol.getTypeParameterStringEx(typars, scopeSymbol, undefined, useContraintInName).toString(); + }; + + PullSymbol.getTypeParameterStringEx = function (typeParameters, scopeSymbol, getTypeParamMarkerInfo, useContraintInName) { + var builder = new TypeScript.MemberNameArray(); + builder.prefix = ""; + + if (typeParameters && typeParameters.length) { + builder.add(TypeScript.MemberName.create("<")); + + for (var i = 0; i < typeParameters.length; i++) { + if (i) { + builder.add(TypeScript.MemberName.create(", ")); + } + + if (getTypeParamMarkerInfo) { + builder.add(new TypeScript.MemberName()); + } + + builder.add(typeParameters[i].getScopedNameEx(scopeSymbol, useContraintInName)); + + if (getTypeParamMarkerInfo) { + builder.add(new TypeScript.MemberName()); + } + } + + builder.add(TypeScript.MemberName.create(">")); + } + + return builder; + }; + + PullSymbol.getIsExternallyVisible = function (symbol, fromIsExternallyVisibleSymbol, inIsExternallyVisibleSymbols) { + if (inIsExternallyVisibleSymbols) { + for (var i = 0; i < inIsExternallyVisibleSymbols.length; i++) { + if (inIsExternallyVisibleSymbols[i] === symbol) { + return true; + } + } + } else { + inIsExternallyVisibleSymbols = []; + } + + if (fromIsExternallyVisibleSymbol === symbol) { + return true; + } + inIsExternallyVisibleSymbols = inIsExternallyVisibleSymbols.concat(fromIsExternallyVisibleSymbol); + + return symbol.isExternallyVisible(inIsExternallyVisibleSymbols); + }; + + PullSymbol.prototype.isExternallyVisible = function (inIsExternallyVisibleSymbols) { + var kind = this.kind; + if (kind === 2 /* Primitive */) { + return true; + } + + if (this.isType()) { + var associatedContainerSymbol = (this).getAssociatedContainerType(); + if (associatedContainerSymbol) { + return PullSymbol.getIsExternallyVisible(associatedContainerSymbol, this, inIsExternallyVisibleSymbols); + } + } + + if (this.hasFlag(2 /* Private */)) { + return false; + } + + var container = this.getContainer(); + if (container === null) { + return true; + } + + if (container.kind == 32 /* DynamicModule */ || (container.getAssociatedContainerType() && container.getAssociatedContainerType().kind == 32 /* DynamicModule */)) { + var containerTypeSymbol = container.kind == 32 /* DynamicModule */ ? container : container.getAssociatedContainerType(); + if (PullContainerTypeSymbol.usedAsSymbol(containerTypeSymbol, this)) { + return true; + } + } + + if (!this.hasFlag(1 /* Exported */) && kind != 4096 /* Property */ && kind != 65536 /* Method */) { + return false; + } + + return PullSymbol.getIsExternallyVisible(container, this, inIsExternallyVisibleSymbols); + }; + return PullSymbol; + })(); + TypeScript.PullSymbol = PullSymbol; + + var PullSignatureSymbol = (function (_super) { + __extends(PullSignatureSymbol, _super); + function PullSignatureSymbol(kind) { + _super.call(this, "", kind); + this.parameters = TypeScript.sentinelEmptyArray; + this.typeParameters = null; + this.returnType = null; + this.functionType = null; + this.hasOptionalParam = false; + this.nonOptionalParamCount = 0; + this.hasVarArgs = false; + this.specializationCache = {}; + this.memberTypeParameterNameCache = null; + this.hasAGenericParameter = false; + this.stringConstantOverload = undefined; + this.hasBeenChecked = false; + } + PullSignatureSymbol.prototype.isDefinition = function () { + return false; + }; + + PullSignatureSymbol.prototype.isGeneric = function () { + return this.hasAGenericParameter || (this.typeParameters && this.typeParameters.length != 0); + }; + + PullSignatureSymbol.prototype.addParameter = function (parameter, isOptional) { + if (typeof isOptional === "undefined") { isOptional = false; } + if (this.parameters == TypeScript.sentinelEmptyArray) { + this.parameters = []; + } + + this.parameters[this.parameters.length] = parameter; + this.hasOptionalParam = isOptional; + + if (!parameter.getEnclosingSignature()) { + parameter.setEnclosingSignature(this); + } + + if (!isOptional) { + this.nonOptionalParamCount++; + } + }; + + PullSignatureSymbol.prototype.addSpecialization = function (signature, typeArguments) { + if (typeArguments && typeArguments.length) { + this.specializationCache[getIDForTypeSubstitutions(typeArguments)] = signature; + } + }; + + PullSignatureSymbol.prototype.getSpecialization = function (typeArguments) { + if (typeArguments) { + var sig = this.specializationCache[getIDForTypeSubstitutions(typeArguments)]; + + if (sig) { + return sig; + } + } + + return null; + }; + + PullSignatureSymbol.prototype.addTypeParameter = function (typeParameter) { + if (!this.typeParameters) { + this.typeParameters = []; + } + + if (!this.memberTypeParameterNameCache) { + this.memberTypeParameterNameCache = new TypeScript.BlockIntrinsics(); + } + + this.typeParameters[this.typeParameters.length] = typeParameter; + + this.memberTypeParameterNameCache[typeParameter.getName()] = typeParameter; + }; + + PullSignatureSymbol.prototype.getTypeParameters = function () { + if (!this.typeParameters) { + this.typeParameters = []; + } + + return this.typeParameters; + }; + + PullSignatureSymbol.prototype.findTypeParameter = function (name) { + var memberSymbol; + + if (!this.memberTypeParameterNameCache) { + this.memberTypeParameterNameCache = new TypeScript.BlockIntrinsics(); + + if (this.typeParameters) { + for (var i = 0; i < this.typeParameters.length; i++) { + this.memberTypeParameterNameCache[this.typeParameters[i].getName()] = this.typeParameters[i]; + } + } + } + + memberSymbol = this.memberTypeParameterNameCache[name]; + + return memberSymbol; + }; + + PullSignatureSymbol.prototype.mimicSignature = function (signature, resolver) { + var typeParameters = signature.getTypeParameters(); + var typeParameter; + + if (typeParameters) { + for (var i = 0; i < typeParameters.length; i++) { + this.addTypeParameter(typeParameters[i]); + } + } + + var parameters = signature.parameters; + var parameter; + + if (parameters) { + for (var j = 0; j < parameters.length; j++) { + parameter = new PullSymbol(parameters[j].name, 2048 /* Parameter */); + parameter.setRootSymbol(parameters[j]); + + if (parameters[j].isOptional) { + parameter.isOptional = true; + } + if (parameters[j].isVarArg) { + parameter.isVarArg = true; + this.hasVarArgs = true; + } + this.addParameter(parameter); + } + } + + var returnType = signature.returnType; + + if (!resolver.isTypeArgumentOrWrapper(returnType)) { + this.returnType = returnType; + } + }; + + PullSignatureSymbol.prototype.isFixed = function () { + if (!this.isGeneric()) { + return true; + } + + if (this.parameters) { + var paramType; + for (var i = 0; i < this.parameters.length; i++) { + paramType = this.parameters[i].type; + + if (paramType && !paramType.isFixed()) { + return false; + } + } + } + + if (this.returnType) { + if (!this.returnType.isFixed()) { + return false; + } + } + + return true; + }; + + PullSignatureSymbol.prototype.invalidate = function () { + this.nonOptionalParamCount = 0; + this.hasOptionalParam = false; + this.hasAGenericParameter = false; + this.stringConstantOverload = undefined; + + _super.prototype.invalidate.call(this); + }; + + PullSignatureSymbol.prototype.isStringConstantOverloadSignature = function () { + if (this.stringConstantOverload === undefined) { + var params = this.parameters; + this.stringConstantOverload = false; + for (var i = 0; i < params.length; i++) { + var paramType = params[i].type; + if (paramType && paramType.isPrimitive() && (paramType).isStringConstant()) { + this.stringConstantOverload = true; + } + } + } + + return this.stringConstantOverload; + }; + + PullSignatureSymbol.getSignatureTypeMemberName = function (candidateSignature, signatures, scopeSymbol) { + var allMemberNames = new TypeScript.MemberNameArray(); + var signatureMemberName = PullSignatureSymbol.getSignaturesTypeNameEx(signatures, "", false, false, scopeSymbol, true, candidateSignature); + allMemberNames.addAll(signatureMemberName); + return allMemberNames; + }; + + PullSignatureSymbol.getSignaturesTypeNameEx = function (signatures, prefix, shortform, brackets, scopeSymbol, getPrettyTypeName, candidateSignature) { + var result = []; + if (!signatures) { + return result; + } + + var len = signatures.length; + if (!getPrettyTypeName && len > 1) { + shortform = false; + } + + var foundDefinition = false; + if (candidateSignature && candidateSignature.isDefinition() && len > 1) { + candidateSignature = null; + } + + for (var i = 0; i < len; i++) { + if (len > 1 && signatures[i].isDefinition()) { + foundDefinition = true; + continue; + } + + var signature = signatures[i]; + if (getPrettyTypeName && candidateSignature) { + signature = candidateSignature; + } + + result.push(signature.getSignatureTypeNameEx(prefix, shortform, brackets, scopeSymbol)); + if (getPrettyTypeName) { + break; + } + } + + if (getPrettyTypeName && result.length && len > 1) { + var lastMemberName = result[result.length - 1]; + for (var i = i + 1; i < len; i++) { + if (signatures[i].isDefinition()) { + foundDefinition = true; + break; + } + } + var overloadString = TypeScript.getLocalizedText(TypeScript.DiagnosticCode._0_overload_s, [foundDefinition ? len - 2 : len - 1]); + lastMemberName.add(TypeScript.MemberName.create(overloadString)); + } + + return result; + }; + + PullSignatureSymbol.prototype.toString = function (scopeSymbol, useConstraintInName) { + var s = this.getSignatureTypeNameEx(this.getScopedNameEx().toString(), false, false, scopeSymbol, undefined, useConstraintInName).toString(); + return s; + }; + + PullSignatureSymbol.prototype.getSignatureTypeNameEx = function (prefix, shortform, brackets, scopeSymbol, getParamMarkerInfo, getTypeParamMarkerInfo) { + var typeParamterBuilder = new TypeScript.MemberNameArray(); + + typeParamterBuilder.add(PullSymbol.getTypeParameterStringEx(this.getTypeParameters(), scopeSymbol, getTypeParamMarkerInfo, true)); + + if (brackets) { + typeParamterBuilder.add(TypeScript.MemberName.create("[")); + } else { + typeParamterBuilder.add(TypeScript.MemberName.create("(")); + } + + var builder = new TypeScript.MemberNameArray(); + builder.prefix = prefix; + + if (getTypeParamMarkerInfo) { + builder.prefix = prefix; + builder.addAll(typeParamterBuilder.entries); + } else { + builder.prefix = prefix + typeParamterBuilder.toString(); + } + + var params = this.parameters; + var paramLen = params.length; + for (var i = 0; i < paramLen; i++) { + var paramType = params[i].type; + var typeString = paramType ? ": " : ""; + var paramIsVarArg = params[i].isVarArg; + var varArgPrefix = paramIsVarArg ? "..." : ""; + var optionalString = (!paramIsVarArg && params[i].isOptional) ? "?" : ""; + if (getParamMarkerInfo) { + builder.add(new TypeScript.MemberName()); + } + builder.add(TypeScript.MemberName.create(varArgPrefix + params[i].getScopedNameEx(scopeSymbol).toString() + optionalString + typeString)); + if (paramType) { + builder.add(paramType.getScopedNameEx(scopeSymbol)); + } + if (getParamMarkerInfo) { + builder.add(new TypeScript.MemberName()); + } + if (i < paramLen - 1) { + builder.add(TypeScript.MemberName.create(", ")); + } + } + + if (shortform) { + if (brackets) { + builder.add(TypeScript.MemberName.create("] => ")); + } else { + builder.add(TypeScript.MemberName.create(") => ")); + } + } else { + if (brackets) { + builder.add(TypeScript.MemberName.create("]: ")); + } else { + builder.add(TypeScript.MemberName.create("): ")); + } + } + + if (this.returnType) { + builder.add(this.returnType.getScopedNameEx(scopeSymbol)); + } else { + builder.add(TypeScript.MemberName.create("any")); + } + + return builder; + }; + return PullSignatureSymbol; + })(PullSymbol); + TypeScript.PullSignatureSymbol = PullSignatureSymbol; + + var PullTypeSymbol = (function (_super) { + __extends(PullTypeSymbol, _super); + function PullTypeSymbol(name, kind) { + _super.call(this, name, kind); + this._members = TypeScript.sentinelEmptyArray; + this._enclosedMemberTypes = null; + this._typeParameters = null; + this._typeArguments = null; + this._containedNonMembers = null; + this._containedNonMemberTypes = null; + this._specializedVersionsOfThisType = null; + this._arrayVersionOfThisType = null; + this._implementedTypes = null; + this._extendedTypes = null; + this._typesThatExplicitlyImplementThisType = null; + this._typesThatExtendThisType = null; + this._callSignatures = null; + this._allCallSignatures = null; + this._constructSignatures = null; + this._allConstructSignatures = null; + this._indexSignatures = null; + this._allIndexSignatures = null; + this._elementType = null; + this._memberNameCache = null; + this._enclosedTypeNameCache = null; + this._typeParameterNameCache = null; + this._containedNonMemberNameCache = null; + this._containedNonMemberTypeNameCache = null; + this._specializedTypeIDCache = null; + this._hasGenericSignature = false; + this._hasGenericMember = false; + this._hasBaseTypeConflict = false; + this._knownBaseTypeCount = 0; + this._invalidatedSpecializations = false; + this._associatedContainerTypeSymbol = null; + this._constructorMethod = null; + this._hasDefaultConstructor = false; + this._functionSymbol = null; + this.hasRecursiveSpecializationError = false; + this.inMemberTypeNameEx = false; + this.inSymbolPrivacyCheck = false; + this.type = this; + } + PullTypeSymbol.prototype.isType = function () { + return true; + }; + PullTypeSymbol.prototype.isClass = function () { + return this.kind == 8 /* Class */ || (this._constructorMethod != null); + }; + PullTypeSymbol.prototype.isFunction = function () { + return (this.kind & (33554432 /* ConstructorType */ | 16777216 /* FunctionType */)) != 0; + }; + PullTypeSymbol.prototype.isConstructor = function () { + return this.kind == 33554432 /* ConstructorType */; + }; + PullTypeSymbol.prototype.isTypeParameter = function () { + return false; + }; + PullTypeSymbol.prototype.isTypeVariable = function () { + return false; + }; + PullTypeSymbol.prototype.isError = function () { + return false; + }; + PullTypeSymbol.prototype.isEnum = function () { + return this.kind == 64 /* Enum */; + }; + + PullTypeSymbol.prototype.getKnownBaseTypeCount = function () { + return this._knownBaseTypeCount; + }; + PullTypeSymbol.prototype.resetKnownBaseTypeCount = function () { + this._knownBaseTypeCount = 0; + }; + PullTypeSymbol.prototype.incrementKnownBaseCount = function () { + this._knownBaseTypeCount++; + }; + + PullTypeSymbol.prototype.setHasBaseTypeConflict = function () { + this._hasBaseTypeConflict = true; + }; + PullTypeSymbol.prototype.hasBaseTypeConflict = function () { + return this._hasBaseTypeConflict; + }; + + PullTypeSymbol.prototype.setUnresolved = function () { + _super.prototype.setUnresolved.call(this); + + this._invalidatedSpecializations = false; + + var specializations = this.getKnownSpecializations(); + + for (var i = 0; i < specializations.length; i++) { + specializations[i].setUnresolved(); + } + }; + + PullTypeSymbol.prototype.hasMembers = function () { + if (this._members != TypeScript.sentinelEmptyArray) { + return true; + } + + var parents = this.getExtendedTypes(); + + for (var i = 0; i < parents.length; i++) { + if (parents[i].hasMembers()) { + return true; + } + } + + return false; + }; + + PullTypeSymbol.prototype.setHasGenericSignature = function () { + this._hasGenericSignature = true; + }; + PullTypeSymbol.prototype.getHasGenericSignature = function () { + return this._hasGenericSignature; + }; + + PullTypeSymbol.prototype.setHasGenericMember = function () { + this._hasGenericMember = true; + }; + PullTypeSymbol.prototype.getHasGenericMember = function () { + return this._hasGenericMember; + }; + + PullTypeSymbol.prototype.setAssociatedContainerType = function (type) { + this._associatedContainerTypeSymbol = type; + }; + + PullTypeSymbol.prototype.getAssociatedContainerType = function () { + return this._associatedContainerTypeSymbol; + }; + + PullTypeSymbol.prototype.getArrayType = function () { + return this._arrayVersionOfThisType; + }; + + PullTypeSymbol.prototype.getElementType = function () { + return this._elementType; + }; + + PullTypeSymbol.prototype.setElementType = function (type) { + this._elementType = type; + }; + + PullTypeSymbol.prototype.setArrayType = function (arrayType) { + this._arrayVersionOfThisType = arrayType; + }; + + PullTypeSymbol.prototype.getFunctionSymbol = function () { + return this._functionSymbol; + }; + + PullTypeSymbol.prototype.setFunctionSymbol = function (symbol) { + if (symbol) { + this._functionSymbol = symbol; + } + }; + + PullTypeSymbol.prototype.addContainedNonMember = function (nonMember) { + if (!nonMember) { + return; + } + + if (!this._containedNonMembers) { + this._containedNonMembers = []; + } + + this._containedNonMembers[this._containedNonMembers.length] = nonMember; + + if (!this._containedNonMemberNameCache) { + this._containedNonMemberNameCache = new TypeScript.BlockIntrinsics(); + } + + this._containedNonMemberNameCache[nonMember.name] = nonMember; + }; + + PullTypeSymbol.prototype.findContainedNonMember = function (name) { + if (!this._containedNonMemberNameCache) { + return null; + } + + return this._containedNonMemberNameCache[name]; + }; + + PullTypeSymbol.prototype.findContainedNonMemberType = function (typeName) { + if (!this._containedNonMemberTypeNameCache) { + return null; + } + + return this._containedNonMemberTypeNameCache[typeName]; + }; + + PullTypeSymbol.prototype.addMember = function (memberSymbol) { + if (!memberSymbol) { + return; + } + + memberSymbol.setContainer(this); + + if (!this._memberNameCache) { + this._memberNameCache = new TypeScript.BlockIntrinsics(); + } + + if (this._members == TypeScript.sentinelEmptyArray) { + this._members = []; + } + + this._members[this._members.length] = memberSymbol; + this._memberNameCache[memberSymbol.name] = memberSymbol; + }; + + PullTypeSymbol.prototype.addEnclosedMemberType = function (enclosedType) { + if (!enclosedType) { + return; + } + + enclosedType.setContainer(this); + + if (!this._enclosedTypeNameCache) { + this._enclosedTypeNameCache = new TypeScript.BlockIntrinsics(); + } + + if (!this._enclosedMemberTypes) { + this._enclosedMemberTypes = []; + } + + this._enclosedMemberTypes[this._enclosedMemberTypes.length] = enclosedType; + this._enclosedTypeNameCache[enclosedType.name] = enclosedType; + }; + + PullTypeSymbol.prototype.addEnclosedNonMember = function (enclosedNonMember) { + if (!enclosedNonMember) { + return; + } + + enclosedNonMember.setContainer(this); + + if (!this._containedNonMemberNameCache) { + this._containedNonMemberNameCache = new TypeScript.BlockIntrinsics(); + } + + if (!this._containedNonMembers) { + this._containedNonMembers = []; + } + + this._containedNonMembers[this._containedNonMembers.length] = enclosedNonMember; + this._containedNonMemberNameCache[enclosedNonMember.name] = enclosedNonMember; + }; + + PullTypeSymbol.prototype.addEnclosedNonMemberType = function (enclosedNonMemberType) { + if (!enclosedNonMemberType) { + return; + } + + enclosedNonMemberType.setContainer(this); + + if (!this._containedNonMemberTypeNameCache) { + this._containedNonMemberTypeNameCache = new TypeScript.BlockIntrinsics(); + } + + if (!this._containedNonMemberTypes) { + this._containedNonMemberTypes = []; + } + + this._containedNonMemberTypes[this._containedNonMemberTypes.length] = enclosedNonMemberType; + this._containedNonMemberTypeNameCache[enclosedNonMemberType.name] = enclosedNonMemberType; + }; + + PullTypeSymbol.prototype.addTypeParameter = function (typeParameter) { + if (!typeParameter) { + return; + } + + if (!typeParameter.getContainer()) { + typeParameter.setContainer(this); + } + + if (!this._typeParameterNameCache) { + this._typeParameterNameCache = new TypeScript.BlockIntrinsics(); + } + + if (!this._typeParameters) { + this._typeParameters = []; + } + + this._typeParameters[this._typeParameters.length] = typeParameter; + this._typeParameterNameCache[typeParameter.getName()] = typeParameter; + }; + + PullTypeSymbol.prototype.addConstructorTypeParameter = function (typeParameter) { + this.addTypeParameter(typeParameter); + + var constructSignatures = this.getConstructSignatures(); + + for (var i = 0; i < constructSignatures.length; i++) { + constructSignatures[i].addTypeParameter(typeParameter); + } + }; + + PullTypeSymbol.prototype.getMembers = function () { + return this._members; + }; + + PullTypeSymbol.prototype.setHasDefaultConstructor = function (hasOne) { + if (typeof hasOne === "undefined") { hasOne = true; } + this._hasDefaultConstructor = hasOne; + }; + + PullTypeSymbol.prototype.getHasDefaultConstructor = function () { + return this._hasDefaultConstructor; + }; + + PullTypeSymbol.prototype.getConstructorMethod = function () { + return this._constructorMethod; + }; + + PullTypeSymbol.prototype.setConstructorMethod = function (constructorMethod) { + this._constructorMethod = constructorMethod; + }; + + PullTypeSymbol.prototype.getTypeParameters = function () { + if (!this._typeParameters) { + return TypeScript.sentinelEmptyArray; + } + + return this._typeParameters; + }; + + PullTypeSymbol.prototype.isGeneric = function () { + return (this._typeParameters && this._typeParameters.length != 0) || this._hasGenericSignature || this._hasGenericMember || (this._typeArguments && this._typeArguments.length) || this.isArray(); + }; + + PullTypeSymbol.prototype.isFixed = function () { + if (!this.isGeneric()) { + return true; + } + + if (this._typeParameters && this._typeArguments) { + if (!this._typeArguments.length || this._typeArguments.length < this._typeParameters.length) { + return false; + } + + for (var i = 0; i < this._typeArguments.length; i++) { + if (!this._typeArguments[i].isFixed()) { + return false; + } + } + + return true; + } else if (this._hasGenericMember) { + var members = this.getMembers(); + var memberType = null; + + for (var i = 0; i < members.length; i++) { + memberType = members[i].type; + + if (memberType && !memberType.isFixed()) { + return false; + } + } + + return true; + } + + return false; + }; + + PullTypeSymbol.prototype.addSpecialization = function (specializedVersionOfThisType, substitutingTypes) { + if (!substitutingTypes || !substitutingTypes.length) { + return; + } + + if (!this._specializedTypeIDCache) { + this._specializedTypeIDCache = new TypeScript.BlockIntrinsics(); + } + + if (!this._specializedVersionsOfThisType) { + this._specializedVersionsOfThisType = []; + } + + this._specializedVersionsOfThisType[this._specializedVersionsOfThisType.length] = specializedVersionOfThisType; + + this._specializedTypeIDCache[getIDForTypeSubstitutions(substitutingTypes)] = specializedVersionOfThisType; + }; + + PullTypeSymbol.prototype.getSpecialization = function (substitutingTypes) { + if (!substitutingTypes || !substitutingTypes.length) { + return null; + } + + if (!this._specializedTypeIDCache) { + this._specializedTypeIDCache = new TypeScript.BlockIntrinsics(); + + return null; + } + + var specialization = this._specializedTypeIDCache[getIDForTypeSubstitutions(substitutingTypes)]; + + if (!specialization) { + return null; + } + + return specialization; + }; + + PullTypeSymbol.prototype.getKnownSpecializations = function () { + if (!this._specializedVersionsOfThisType) { + return TypeScript.sentinelEmptyArray; + } + + return this._specializedVersionsOfThisType; + }; + + PullTypeSymbol.prototype.getTypeArguments = function () { + return this._typeArguments; + }; + PullTypeSymbol.prototype.setTypeArguments = function (typeArgs) { + this._typeArguments = typeArgs; + }; + + PullTypeSymbol.prototype.addCallSignature = function (callSignature) { + if (!this._callSignatures) { + this._callSignatures = []; + } + + this._callSignatures[this._callSignatures.length] = callSignature; + + if (callSignature.isGeneric()) { + this._hasGenericSignature = true; + } + + callSignature.functionType = this; + }; + + PullTypeSymbol.prototype.addConstructSignature = function (constructSignature) { + if (!this._constructSignatures) { + this._constructSignatures = []; + } + + this._constructSignatures[this._constructSignatures.length] = constructSignature; + + if (constructSignature.isGeneric()) { + this._hasGenericSignature = true; + } + + constructSignature.functionType = this; + }; + + PullTypeSymbol.prototype.addIndexSignature = function (indexSignature) { + if (!this._indexSignatures) { + this._indexSignatures = []; + } + + this._indexSignatures[this._indexSignatures.length] = indexSignature; + + if (indexSignature.isGeneric()) { + this._hasGenericSignature = true; + } + + indexSignature.functionType = this; + }; + + PullTypeSymbol.prototype.hasOwnCallSignatures = function () { + return !!this._callSignatures; + }; + + PullTypeSymbol.prototype.getCallSignatures = function (collectBaseSignatures) { + if (typeof collectBaseSignatures === "undefined") { collectBaseSignatures = true; } + if (!collectBaseSignatures) { + return this._callSignatures || []; + } + + if (this._allCallSignatures) { + return this._allCallSignatures; + } + + var signatures = []; + + if (this._callSignatures) { + signatures = signatures.concat(this._callSignatures); + } + + if (collectBaseSignatures && this._extendedTypes) { + for (var i = 0; i < this._extendedTypes.length; i++) { + if (this._extendedTypes[i].hasBase(this)) { + continue; + } + + signatures = signatures.concat(this._extendedTypes[i].getCallSignatures()); + } + } + + this._allCallSignatures = signatures; + + return signatures; + }; + + PullTypeSymbol.prototype.hasOwnConstructSignatures = function () { + return !!this._constructSignatures; + }; + + PullTypeSymbol.prototype.getConstructSignatures = function (collectBaseSignatures) { + if (typeof collectBaseSignatures === "undefined") { collectBaseSignatures = true; } + if (!collectBaseSignatures) { + return this._constructSignatures || []; + } + + var signatures = []; + + if (this._constructSignatures) { + signatures = signatures.concat(this._constructSignatures); + } + + if (collectBaseSignatures && this._extendedTypes && !(this.kind == 33554432 /* ConstructorType */)) { + for (var i = 0; i < this._extendedTypes.length; i++) { + if (this._extendedTypes[i].hasBase(this)) { + continue; + } + + signatures = signatures.concat(this._extendedTypes[i].getConstructSignatures()); + } + } + + return signatures; + }; + + PullTypeSymbol.prototype.hasOwnIndexSignatures = function () { + return !!this._indexSignatures; + }; + + PullTypeSymbol.prototype.getIndexSignatures = function (collectBaseSignatures) { + if (typeof collectBaseSignatures === "undefined") { collectBaseSignatures = true; } + if (!collectBaseSignatures) { + return this._indexSignatures || []; + } + + if (this._allIndexSignatures) { + return this._allIndexSignatures; + } + + var signatures = []; + + if (this._indexSignatures) { + signatures = signatures.concat(this._indexSignatures); + } + + if (collectBaseSignatures && this._extendedTypes) { + for (var i = 0; i < this._extendedTypes.length; i++) { + if (this._extendedTypes[i].hasBase(this)) { + continue; + } + + signatures = signatures.concat(this._extendedTypes[i].getIndexSignatures()); + } + } + + this._allIndexSignatures = signatures; + + return signatures; + }; + + PullTypeSymbol.prototype.addImplementedType = function (implementedType) { + if (!implementedType) { + return; + } + + if (!this._implementedTypes) { + this._implementedTypes = []; + } + + this._implementedTypes[this._implementedTypes.length] = implementedType; + + implementedType.addTypeThatExplicitlyImplementsThisType(this); + }; + + PullTypeSymbol.prototype.getImplementedTypes = function () { + if (!this._implementedTypes) { + return TypeScript.sentinelEmptyArray; + } + + return this._implementedTypes; + }; + + PullTypeSymbol.prototype.addExtendedType = function (extendedType) { + if (!extendedType) { + return; + } + + if (!this._extendedTypes) { + this._extendedTypes = []; + } + + this._extendedTypes[this._extendedTypes.length] = extendedType; + + extendedType.addTypeThatExtendsThisType(this); + }; + + PullTypeSymbol.prototype.getExtendedTypes = function () { + if (!this._extendedTypes) { + return TypeScript.sentinelEmptyArray; + } + + return this._extendedTypes; + }; + + PullTypeSymbol.prototype.addTypeThatExtendsThisType = function (type) { + if (!type) { + return; + } + + if (!this._typesThatExtendThisType) { + this._typesThatExtendThisType = []; + } + + this._typesThatExtendThisType[this._typesThatExtendThisType.length] = type; + }; + + PullTypeSymbol.prototype.getTypesThatExtendThisType = function () { + if (!this._typesThatExplicitlyImplementThisType) { + this._typesThatExplicitlyImplementThisType = []; + } + + return this._typesThatExtendThisType; + }; + + PullTypeSymbol.prototype.addTypeThatExplicitlyImplementsThisType = function (type) { + if (!type) { + return; + } + + if (!this._typesThatExplicitlyImplementThisType) { + this._typesThatExplicitlyImplementThisType = []; + } + + this._typesThatExplicitlyImplementThisType[this._typesThatExplicitlyImplementThisType.length] = type; + }; + + PullTypeSymbol.prototype.getTypesThatExplicitlyImplementThisType = function () { + if (!this._typesThatExplicitlyImplementThisType) { + this._typesThatExplicitlyImplementThisType = []; + } + + return this._typesThatExplicitlyImplementThisType; + }; + + PullTypeSymbol.prototype.hasBase = function (potentialBase, origin) { + if (typeof origin === "undefined") { origin = null; } + if (this === potentialBase) { + return true; + } + + if (origin && (this === origin || this.getRootSymbol() === origin)) { + return true; + } + + if (!origin) { + origin = this; + } + + var extendedTypes = this.getExtendedTypes(); + + for (var i = 0; i < extendedTypes.length; i++) { + if (extendedTypes[i].hasBase(potentialBase, origin)) { + return true; + } + } + + var implementedTypes = this.getImplementedTypes(); + + for (var i = 0; i < implementedTypes.length; i++) { + if (implementedTypes[i].hasBase(potentialBase, origin)) { + return true; + } + } + + return false; + }; + + PullTypeSymbol.prototype.isValidBaseKind = function (baseType, isExtendedType) { + if (baseType.isError()) { + return false; + } + + var thisIsClass = this.isClass(); + if (isExtendedType) { + if (thisIsClass) { + return baseType.kind === 8 /* Class */; + } + } else { + if (!thisIsClass) { + return false; + } + } + + return !!(baseType.kind & (16 /* Interface */ | 8 /* Class */ | 128 /* Array */)); + }; + + PullTypeSymbol.prototype.findMember = function (name, lookInParent) { + if (typeof lookInParent === "undefined") { lookInParent = true; } + var memberSymbol = null; + + if (this._memberNameCache) { + memberSymbol = this._memberNameCache[name]; + } + + if (!lookInParent) { + return memberSymbol; + } else if (memberSymbol) { + return memberSymbol; + } + + if (!memberSymbol && this._extendedTypes) { + for (var i = 0; i < this._extendedTypes.length; i++) { + memberSymbol = this._extendedTypes[i].findMember(name); + + if (memberSymbol) { + return memberSymbol; + } + } + } + + return null; + }; + + PullTypeSymbol.prototype.findNestedType = function (name, kind) { + if (typeof kind === "undefined") { kind = 0 /* None */; } + var memberSymbol; + + if (!this._enclosedTypeNameCache) { + return null; + } + + memberSymbol = this._enclosedTypeNameCache[name]; + + if (memberSymbol && kind != 0 /* None */) { + memberSymbol = ((memberSymbol.kind & kind) != 0) ? memberSymbol : null; + } + + return memberSymbol; + }; + + PullTypeSymbol.prototype.getAllMembers = function (searchDeclKind, includePrivate) { + var allMembers = []; + + var i = 0; + var j = 0; + var m = 0; + var n = 0; + + if (this._members != TypeScript.sentinelEmptyArray) { + for (var i = 0, n = this._members.length; i < n; i++) { + var member = this._members[i]; + if ((member.kind & searchDeclKind) && (includePrivate || !member.hasFlag(2 /* Private */))) { + allMembers[allMembers.length] = member; + } + } + } + + if (this._extendedTypes) { + for (var i = 0, n = this._extendedTypes.length; i < n; i++) { + var extendedMembers = this._extendedTypes[i].getAllMembers(searchDeclKind, includePrivate); + + for (var j = 0, m = extendedMembers.length; j < m; j++) { + var extendedMember = extendedMembers[j]; + if (!(this._memberNameCache && this._memberNameCache[extendedMember.name])) { + allMembers[allMembers.length] = extendedMember; + } + } + } + } + + if (this.isContainer() && this._enclosedMemberTypes) { + for (var i = 0; i < this._enclosedMemberTypes.length; i++) { + allMembers[allMembers.length] = this._enclosedMemberTypes[i]; + } + } + + return allMembers; + }; + + PullTypeSymbol.prototype.findTypeParameter = function (name) { + if (!this._typeParameterNameCache) { + return null; + } + + return this._typeParameterNameCache[name]; + }; + + PullTypeSymbol.prototype.setResolved = function () { + _super.prototype.setResolved.call(this); + }; + + PullTypeSymbol.prototype.invalidate = function () { + if (this._constructorMethod) { + this._constructorMethod.invalidate(); + } + + this._knownBaseTypeCount = 0; + + _super.prototype.invalidate.call(this); + }; + + PullTypeSymbol.prototype.getNamePartForFullName = function () { + var name = _super.prototype.getNamePartForFullName.call(this); + + var typars = this.getTypeArguments(); + if (!typars || !typars.length) { + typars = this.getTypeParameters(); + } + + var typarString = PullSymbol.getTypeParameterString(typars, this, true); + return name + typarString; + }; + + PullTypeSymbol.prototype.getScopedName = function (scopeSymbol, useConstraintInName) { + return this.getScopedNameEx(scopeSymbol, useConstraintInName).toString(); + }; + + PullTypeSymbol.prototype.isNamedTypeSymbol = function () { + if (this.isArray()) { + return false; + } + + var kind = this.kind; + if (kind === 2 /* Primitive */ || kind === 8 /* Class */ || kind === 4 /* Container */ || kind === 32 /* DynamicModule */ || kind === 256 /* TypeAlias */ || kind === 64 /* Enum */ || kind === 8192 /* TypeParameter */ || ((kind === 16 /* Interface */ || kind === 8388608 /* ObjectType */) && this.name != "")) { + return true; + } + + return false; + }; + + PullTypeSymbol.prototype.toString = function (scopeSymbol, useConstraintInName) { + var s = this.getScopedNameEx(scopeSymbol, useConstraintInName).toString(); + return s; + }; + + PullTypeSymbol.prototype.getScopedNameEx = function (scopeSymbol, useConstraintInName, getPrettyTypeName, getTypeParamMarkerInfo) { + if (this.isArray()) { + var elementMemberName = this._elementType ? (this._elementType.isArray() || this._elementType.isNamedTypeSymbol() ? this._elementType.getScopedNameEx(scopeSymbol, false, getPrettyTypeName, getTypeParamMarkerInfo) : this._elementType.getMemberTypeNameEx(false, scopeSymbol, getPrettyTypeName)) : TypeScript.MemberName.create("any"); + return TypeScript.MemberName.create(elementMemberName, "", "[]"); + } + + if (!this.isNamedTypeSymbol()) { + return this.getMemberTypeNameEx(true, scopeSymbol, getPrettyTypeName); + } + + var builder = new TypeScript.MemberNameArray(); + builder.prefix = _super.prototype.getScopedName.call(this, scopeSymbol, useConstraintInName); + + var typars = this.getTypeArguments(); + if (!typars || !typars.length) { + typars = this.getTypeParameters(); + } + + builder.add(PullSymbol.getTypeParameterStringEx(typars, scopeSymbol, getTypeParamMarkerInfo, useConstraintInName)); + + return builder; + }; + + PullTypeSymbol.prototype.hasOnlyOverloadCallSignatures = function () { + var members = this.getMembers(); + var callSignatures = this.getCallSignatures(); + var constructSignatures = this.getConstructSignatures(); + return members.length === 0 && constructSignatures.length === 0 && callSignatures.length > 1; + }; + + PullTypeSymbol.prototype.getMemberTypeNameEx = function (topLevel, scopeSymbol, getPrettyTypeName) { + var members = this.getMembers(); + var callSignatures = this.getCallSignatures(); + var constructSignatures = this.getConstructSignatures(); + var indexSignatures = this.getIndexSignatures(); + + if (members.length > 0 || callSignatures.length > 0 || constructSignatures.length > 0 || indexSignatures.length > 0) { + if (this.inMemberTypeNameEx) { + var associatedContainerType = this.getAssociatedContainerType(); + if (associatedContainerType && associatedContainerType.isNamedTypeSymbol()) { + var nameForTypeOf = associatedContainerType.getScopedNameEx(scopeSymbol); + return TypeScript.MemberName.create(nameForTypeOf, "typeof ", ""); + } else { + return TypeScript.MemberName.create("any"); + } + } + + this.inMemberTypeNameEx = true; + + var allMemberNames = new TypeScript.MemberNameArray(); + var curlies = !topLevel || indexSignatures.length != 0; + var delim = "; "; + for (var i = 0; i < members.length; i++) { + if (members[i].kind == 65536 /* Method */ && members[i].type.hasOnlyOverloadCallSignatures()) { + var methodCallSignatures = members[i].type.getCallSignatures(); + var nameStr = members[i].getDisplayName(scopeSymbol) + (members[i].isOptional ? "?" : ""); + ; + var methodMemberNames = PullSignatureSymbol.getSignaturesTypeNameEx(methodCallSignatures, nameStr, false, false, scopeSymbol); + allMemberNames.addAll(methodMemberNames); + } else { + var memberTypeName = members[i].getNameAndTypeNameEx(scopeSymbol); + if (memberTypeName.isArray() && (memberTypeName).delim === delim) { + allMemberNames.addAll((memberTypeName).entries); + } else { + allMemberNames.add(memberTypeName); + } + } + curlies = true; + } + + var getPrettyFunctionOverload = getPrettyTypeName && !curlies && this.hasOnlyOverloadCallSignatures(); + + var signatureCount = callSignatures.length + constructSignatures.length + indexSignatures.length; + var useShortFormSignature = !curlies && (signatureCount === 1); + var signatureMemberName; + + if (callSignatures.length > 0) { + signatureMemberName = PullSignatureSymbol.getSignaturesTypeNameEx(callSignatures, "", useShortFormSignature, false, scopeSymbol, getPrettyFunctionOverload); + allMemberNames.addAll(signatureMemberName); + } + + if (constructSignatures.length > 0) { + signatureMemberName = PullSignatureSymbol.getSignaturesTypeNameEx(constructSignatures, "new", useShortFormSignature, false, scopeSymbol); + allMemberNames.addAll(signatureMemberName); + } + + if (indexSignatures.length > 0) { + signatureMemberName = PullSignatureSymbol.getSignaturesTypeNameEx(indexSignatures, "", useShortFormSignature, true, scopeSymbol); + allMemberNames.addAll(signatureMemberName); + } + + if ((curlies) || (!getPrettyFunctionOverload && (signatureCount > 1) && topLevel)) { + allMemberNames.prefix = "{ "; + allMemberNames.suffix = "}"; + allMemberNames.delim = delim; + } else if (allMemberNames.entries.length > 1) { + allMemberNames.delim = delim; + } + + this.inMemberTypeNameEx = false; + + return allMemberNames; + } + + return TypeScript.MemberName.create("{}"); + }; + + PullTypeSymbol.prototype.isExternallyVisible = function (inIsExternallyVisibleSymbols) { + var isVisible = _super.prototype.isExternallyVisible.call(this, inIsExternallyVisibleSymbols); + if (isVisible) { + var typars = this.getTypeArguments(); + if (!typars || !typars.length) { + typars = this.getTypeParameters(); + } + + if (typars) { + for (var i = 0; i < typars.length; i++) { + isVisible = PullSymbol.getIsExternallyVisible(typars[i], this, inIsExternallyVisibleSymbols); + if (!isVisible) { + break; + } + } + } + } + + return isVisible; + }; + return PullTypeSymbol; + })(PullSymbol); + TypeScript.PullTypeSymbol = PullTypeSymbol; + + var PullPrimitiveTypeSymbol = (function (_super) { + __extends(PullPrimitiveTypeSymbol, _super); + function PullPrimitiveTypeSymbol(name) { + _super.call(this, name, 2 /* Primitive */); + + this.isResolved = true; + } + PullPrimitiveTypeSymbol.prototype.isStringConstant = function () { + return false; + }; + + PullPrimitiveTypeSymbol.prototype.isFixed = function () { + return true; + }; + + PullPrimitiveTypeSymbol.prototype.invalidate = function () { + }; + return PullPrimitiveTypeSymbol; + })(PullTypeSymbol); + TypeScript.PullPrimitiveTypeSymbol = PullPrimitiveTypeSymbol; + + var PullStringConstantTypeSymbol = (function (_super) { + __extends(PullStringConstantTypeSymbol, _super); + function PullStringConstantTypeSymbol(name) { + _super.call(this, name); + } + PullStringConstantTypeSymbol.prototype.isStringConstant = function () { + return true; + }; + return PullStringConstantTypeSymbol; + })(PullPrimitiveTypeSymbol); + TypeScript.PullStringConstantTypeSymbol = PullStringConstantTypeSymbol; + + var PullErrorTypeSymbol = (function (_super) { + __extends(PullErrorTypeSymbol, _super); + function PullErrorTypeSymbol(diagnostic, delegateType, _data) { + if (typeof _data === "undefined") { _data = null; } + _super.call(this, "error"); + this.diagnostic = diagnostic; + this.delegateType = delegateType; + this._data = _data; + + this.isResolved = true; + } + PullErrorTypeSymbol.prototype.isError = function () { + return true; + }; + + PullErrorTypeSymbol.prototype.getDiagnostic = function () { + return this.diagnostic; + }; + + PullErrorTypeSymbol.prototype.getName = function (scopeSymbol, useConstraintInName) { + return this.delegateType.getName(scopeSymbol, useConstraintInName); + }; + + PullErrorTypeSymbol.prototype.getDisplayName = function (scopeSymbol, useConstraintInName) { + return this.delegateType.getDisplayName(scopeSymbol, useConstraintInName); + }; + + PullErrorTypeSymbol.prototype.toString = function (scopeSymbol, useConstraintInName) { + return this.delegateType.toString(scopeSymbol, useConstraintInName); + }; + + PullErrorTypeSymbol.prototype.setData = function (data) { + this._data = data; + }; + + PullErrorTypeSymbol.prototype.getData = function () { + return this._data; + }; + return PullErrorTypeSymbol; + })(PullPrimitiveTypeSymbol); + TypeScript.PullErrorTypeSymbol = PullErrorTypeSymbol; + + var PullContainerTypeSymbol = (function (_super) { + __extends(PullContainerTypeSymbol, _super); + function PullContainerTypeSymbol(name, kind) { + if (typeof kind === "undefined") { kind = 4 /* Container */; } + _super.call(this, name, kind); + this.instanceSymbol = null; + this.assignedValue = null; + this.assignedType = null; + this.assignedContainer = null; + } + PullContainerTypeSymbol.prototype.isContainer = function () { + return true; + }; + + PullContainerTypeSymbol.prototype.setInstanceSymbol = function (symbol) { + this.instanceSymbol = symbol; + }; + + PullContainerTypeSymbol.prototype.getInstanceSymbol = function () { + return this.instanceSymbol; + }; + + PullContainerTypeSymbol.prototype.invalidate = function () { + if (this.instanceSymbol) { + this.instanceSymbol.invalidate(); + } + + _super.prototype.invalidate.call(this); + }; + + PullContainerTypeSymbol.prototype.setExportAssignedValueSymbol = function (symbol) { + this.assignedValue = symbol; + }; + PullContainerTypeSymbol.prototype.getExportAssignedValueSymbol = function () { + return this.assignedValue; + }; + + PullContainerTypeSymbol.prototype.setExportAssignedTypeSymbol = function (type) { + this.assignedType = type; + }; + + PullContainerTypeSymbol.prototype.getExportAssignedTypeSymbol = function () { + return this.assignedType; + }; + + PullContainerTypeSymbol.prototype.setExportAssignedContainerSymbol = function (container) { + this.assignedContainer = container; + }; + + PullContainerTypeSymbol.prototype.getExportAssignedContainerSymbol = function () { + return this.assignedContainer; + }; + + PullContainerTypeSymbol.prototype.resetExportAssignedSymbols = function () { + this.assignedValue = null; + this.assignedType = null; + this.assignedContainer = null; + }; + + PullContainerTypeSymbol.usedAsSymbol = function (containerSymbol, symbol) { + if (!containerSymbol || !containerSymbol.isContainer()) { + return false; + } + + if (!containerSymbol.isAlias() && containerSymbol.type == symbol) { + return true; + } + + var containerTypeSymbol = containerSymbol; + var valueExportSymbol = containerTypeSymbol.getExportAssignedValueSymbol(); + var typeExportSymbol = containerTypeSymbol.getExportAssignedTypeSymbol(); + var containerExportSymbol = containerTypeSymbol.getExportAssignedContainerSymbol(); + if (valueExportSymbol || typeExportSymbol || containerExportSymbol) { + return valueExportSymbol == symbol || typeExportSymbol == symbol || containerExportSymbol == symbol || PullContainerTypeSymbol.usedAsSymbol(containerExportSymbol, symbol); + } + + return false; + }; + + PullContainerTypeSymbol.prototype.getInstanceType = function () { + return this.instanceSymbol ? this.instanceSymbol.type : null; + }; + return PullContainerTypeSymbol; + })(PullTypeSymbol); + TypeScript.PullContainerTypeSymbol = PullContainerTypeSymbol; + + var PullTypeAliasSymbol = (function (_super) { + __extends(PullTypeAliasSymbol, _super); + function PullTypeAliasSymbol(name) { + _super.call(this, name, 256 /* TypeAlias */); + this.assignedValue = null; + this.assignedType = null; + this.assignedContainer = null; + this.isUsedAsValue = false; + this.typeUsedExternally = false; + this.retrievingExportAssignment = false; + } + PullTypeAliasSymbol.prototype.isAlias = function () { + return true; + }; + PullTypeAliasSymbol.prototype.isContainer = function () { + return true; + }; + + PullTypeAliasSymbol.prototype.setAssignedValueSymbol = function (symbol) { + this.assignedValue = symbol; + }; + + PullTypeAliasSymbol.prototype.getExportAssignedValueSymbol = function () { + if (this.assignedValue) { + return this.assignedValue; + } + + if (this.retrievingExportAssignment) { + return null; + } + + if (this.assignedContainer) { + this.retrievingExportAssignment = true; + var sym = this.assignedContainer.getExportAssignedValueSymbol(); + this.retrievingExportAssignment = false; + return sym; + } + + return null; + }; + + PullTypeAliasSymbol.prototype.setAssignedTypeSymbol = function (type) { + this.assignedType = type; + }; + + PullTypeAliasSymbol.prototype.getExportAssignedTypeSymbol = function () { + if (this.retrievingExportAssignment) { + return null; + } + + if (this.assignedType) { + if (this.assignedType.isAlias()) { + this.retrievingExportAssignment = true; + var sym = (this.assignedType).getExportAssignedTypeSymbol(); + this.retrievingExportAssignment = false; + } else if (this.assignedType != this.assignedContainer) { + return this.assignedType; + } + } + + if (this.assignedContainer) { + this.retrievingExportAssignment = true; + var sym = this.assignedContainer.getExportAssignedTypeSymbol(); + this.retrievingExportAssignment = false; + if (sym) { + return sym; + } + } + + return this.assignedContainer; + }; + + PullTypeAliasSymbol.prototype.setAssignedContainerSymbol = function (container) { + this.assignedContainer = container; + }; + + PullTypeAliasSymbol.prototype.getExportAssignedContainerSymbol = function () { + if (this.retrievingExportAssignment) { + return null; + } + + if (this.assignedContainer) { + this.retrievingExportAssignment = true; + var sym = this.assignedContainer.getExportAssignedContainerSymbol(); + this.retrievingExportAssignment = false; + if (sym) { + return sym; + } + } + + return this.assignedContainer; + }; + + PullTypeAliasSymbol.prototype.getMembers = function () { + if (this.assignedType) { + return this.assignedType.getMembers(); + } + + return TypeScript.sentinelEmptyArray; + }; + + PullTypeAliasSymbol.prototype.getCallSignatures = function () { + if (this.assignedType) { + return this.assignedType.getCallSignatures(); + } + + return TypeScript.sentinelEmptyArray; + }; + + PullTypeAliasSymbol.prototype.getConstructSignatures = function () { + if (this.assignedType) { + return this.assignedType.getConstructSignatures(); + } + + return TypeScript.sentinelEmptyArray; + }; + + PullTypeAliasSymbol.prototype.getIndexSignatures = function () { + if (this.assignedType) { + return this.assignedType.getIndexSignatures(); + } + + return TypeScript.sentinelEmptyArray; + }; + + PullTypeAliasSymbol.prototype.findMember = function (name) { + if (this.assignedType) { + return this.assignedType.findMember(name); + } + + return null; + }; + + PullTypeAliasSymbol.prototype.findNestedType = function (name) { + if (this.assignedType) { + return this.assignedType.findNestedType(name); + } + + return null; + }; + + PullTypeAliasSymbol.prototype.getAllMembers = function (searchDeclKind, includePrivate) { + if (this.assignedType) { + return this.assignedType.getAllMembers(searchDeclKind, includePrivate); + } + + return TypeScript.sentinelEmptyArray; + }; + + PullTypeAliasSymbol.prototype.invalidate = function () { + this.isUsedAsValue = false; + + _super.prototype.invalidate.call(this); + }; + return PullTypeAliasSymbol; + })(PullTypeSymbol); + TypeScript.PullTypeAliasSymbol = PullTypeAliasSymbol; + + var PullDefinitionSignatureSymbol = (function (_super) { + __extends(PullDefinitionSignatureSymbol, _super); + function PullDefinitionSignatureSymbol() { + _super.apply(this, arguments); + } + PullDefinitionSignatureSymbol.prototype.isDefinition = function () { + return true; + }; + return PullDefinitionSignatureSymbol; + })(PullSignatureSymbol); + TypeScript.PullDefinitionSignatureSymbol = PullDefinitionSignatureSymbol; + + var PullTypeParameterSymbol = (function (_super) { + __extends(PullTypeParameterSymbol, _super); + function PullTypeParameterSymbol(name, _isFunctionTypeParameter) { + _super.call(this, name, 8192 /* TypeParameter */); + this._isFunctionTypeParameter = _isFunctionTypeParameter; + this._constraint = null; + } + PullTypeParameterSymbol.prototype.isTypeParameter = function () { + return true; + }; + PullTypeParameterSymbol.prototype.isFunctionTypeParameter = function () { + return this._isFunctionTypeParameter; + }; + + PullTypeParameterSymbol.prototype.isFixed = function () { + return false; + }; + + PullTypeParameterSymbol.prototype.setConstraint = function (constraintType) { + this._constraint = constraintType; + }; + + PullTypeParameterSymbol.prototype.getConstraint = function () { + return this._constraint; + }; + + PullTypeParameterSymbol.prototype.isGeneric = function () { + return true; + }; + + PullTypeParameterSymbol.prototype.fullName = function (scopeSymbol) { + var name = this.getDisplayName(scopeSymbol); + var container = this.getContainer(); + if (container) { + var containerName = container.fullName(scopeSymbol); + name = name + " in " + containerName; + } + + return name; + }; + + PullTypeParameterSymbol.prototype.getName = function (scopeSymbol, useConstraintInName) { + var name = _super.prototype.getName.call(this, scopeSymbol); + + if (this.isPrinting) { + return name; + } + + this.isPrinting = true; + + if (useConstraintInName && this._constraint) { + name += " extends " + this._constraint.toString(scopeSymbol); + } + + this.isPrinting = false; + + return name; + }; + + PullTypeParameterSymbol.prototype.getDisplayName = function (scopeSymbol, useConstraintInName) { + var name = _super.prototype.getDisplayName.call(this, scopeSymbol, useConstraintInName); + + if (this.isPrinting) { + return name; + } + + this.isPrinting = true; + + if (useConstraintInName && this._constraint) { + name += " extends " + this._constraint.toString(scopeSymbol); + } + + this.isPrinting = false; + + return name; + }; + + PullTypeParameterSymbol.prototype.isExternallyVisible = function (inIsExternallyVisibleSymbols) { + var constraint = this.getConstraint(); + if (constraint) { + return PullSymbol.getIsExternallyVisible(constraint, this, inIsExternallyVisibleSymbols); + } + + return true; + }; + return PullTypeParameterSymbol; + })(PullTypeSymbol); + TypeScript.PullTypeParameterSymbol = PullTypeParameterSymbol; + + var PullTypeVariableSymbol = (function (_super) { + __extends(PullTypeVariableSymbol, _super); + function PullTypeVariableSymbol(name, isFunctionTypeParameter) { + _super.call(this, name, isFunctionTypeParameter); + this.tyvarID = TypeScript.globalTyvarID++; + } + PullTypeVariableSymbol.prototype.isTypeParameter = function () { + return true; + }; + PullTypeVariableSymbol.prototype.isTypeVariable = function () { + return true; + }; + return PullTypeVariableSymbol; + })(PullTypeParameterSymbol); + TypeScript.PullTypeVariableSymbol = PullTypeVariableSymbol; + + var PullAccessorSymbol = (function (_super) { + __extends(PullAccessorSymbol, _super); + function PullAccessorSymbol(name) { + _super.call(this, name, 4096 /* Property */); + this._getterSymbol = null; + this._setterSymbol = null; + } + PullAccessorSymbol.prototype.isAccessor = function () { + return true; + }; + + PullAccessorSymbol.prototype.setSetter = function (setter) { + if (!setter) { + return; + } + + this._setterSymbol = setter; + + setter.setAccessorSymbol(this); + }; + + PullAccessorSymbol.prototype.getSetter = function () { + return this._setterSymbol; + }; + + PullAccessorSymbol.prototype.setGetter = function (getter) { + if (!getter) { + return; + } + + this._getterSymbol = getter; + + getter.setAccessorSymbol(this); + }; + + PullAccessorSymbol.prototype.getGetter = function () { + return this._getterSymbol; + }; + + PullAccessorSymbol.prototype.invalidate = function () { + if (this._getterSymbol) { + this._getterSymbol.invalidate(); + } + + if (this._setterSymbol) { + this._setterSymbol.invalidate(); + } + + _super.prototype.invalidate.call(this); + }; + return PullAccessorSymbol; + })(PullSymbol); + TypeScript.PullAccessorSymbol = PullAccessorSymbol; + + function typeWrapsTypeParameter(type, typeParameter) { + if (type.isTypeParameter()) { + return type == typeParameter; + } + + var typeArguments = type.getTypeArguments(); + + if (typeArguments) { + for (var i = 0; i < typeArguments.length; i++) { + if (typeWrapsTypeParameter(typeArguments[i], typeParameter)) { + return true; + } + } + } + + return false; + } + TypeScript.typeWrapsTypeParameter = typeWrapsTypeParameter; + + function getRootType(typeToSpecialize) { + var decl = typeToSpecialize.getDeclarations()[0]; + + if (!typeToSpecialize.isGeneric()) { + return typeToSpecialize; + } + + return (typeToSpecialize.kind & (8 /* Class */ | 16 /* Interface */)) ? decl.getSymbol().type : typeToSpecialize; + } + TypeScript.getRootType = getRootType; + + TypeScript.nSpecializationsCreated = 0; + TypeScript.nSpecializedSignaturesCreated = 0; + + function shouldSpecializeTypeParameterForTypeParameter(specialization, typeToSpecialize) { + if (specialization == typeToSpecialize) { + return false; + } + + if (!(specialization.isTypeParameter() && typeToSpecialize.isTypeParameter())) { + return true; + } + + var parent = specialization.getDeclarations()[0].getParentDecl(); + var targetParent = typeToSpecialize.getDeclarations()[0].getParentDecl(); + + if (parent == targetParent) { + return true; + } + + while (parent) { + if (parent.flags & 16 /* Static */) { + return true; + } + + if (parent == targetParent) { + return false; + } + + parent = parent.getParentDecl(); + } + + return true; + } + TypeScript.shouldSpecializeTypeParameterForTypeParameter = shouldSpecializeTypeParameterForTypeParameter; + + function specializeType(typeToSpecialize, typeArguments, resolver, enclosingDecl, context, ast) { + if (typeToSpecialize.isPrimitive() || !typeToSpecialize.isGeneric()) { + return typeToSpecialize; + } + + var searchForExistingSpecialization = typeArguments != null; + + if (typeArguments === null || (context.specializingToAny && typeArguments.length)) { + typeArguments = []; + } + + if (typeToSpecialize.isTypeParameter()) { + if (context.specializingToAny) { + return resolver.semanticInfoChain.anyTypeSymbol; + } + + var substitution = context.findSpecializationForType(typeToSpecialize); + + if (substitution != typeToSpecialize) { + if (shouldSpecializeTypeParameterForTypeParameter(substitution, typeToSpecialize)) { + return substitution; + } + } + + if (typeArguments && typeArguments.length) { + if (shouldSpecializeTypeParameterForTypeParameter(typeArguments[0], typeToSpecialize)) { + return typeArguments[0]; + } + } + + return typeToSpecialize; + } + + if (typeToSpecialize.isArray()) { + if (typeToSpecialize.currentlyBeingSpecialized()) { + return typeToSpecialize; + } + + var newElementType = null; + + if (!context.specializingToAny) { + var elementType = typeToSpecialize.getElementType(); + + newElementType = specializeType(elementType, typeArguments, resolver, enclosingDecl, context, ast); + } else { + newElementType = resolver.semanticInfoChain.anyTypeSymbol; + } + + var newArrayType = specializeType(resolver.getCachedArrayType(), [newElementType], resolver, enclosingDecl, context); + + return newArrayType; + } + + var typeParameters = typeToSpecialize.getTypeParameters(); + + if (!context.specializingToAny && searchForExistingSpecialization && (typeParameters.length > typeArguments.length)) { + searchForExistingSpecialization = false; + } + + var newType = null; + + var newTypeDecl = typeToSpecialize.getDeclarations()[0]; + + var rootType = getRootType(typeToSpecialize); + + var isArray = typeToSpecialize === resolver.getCachedArrayType() || typeToSpecialize.isArray(); + + if (searchForExistingSpecialization || context.specializingToAny || typeToSpecialize.hasRecursiveSpecializationError) { + if (!typeArguments.length || context.specializingToAny || typeToSpecialize.hasRecursiveSpecializationError) { + for (var i = 0; i < typeParameters.length; i++) { + typeArguments[i] = resolver.semanticInfoChain.anyTypeSymbol; + } + } + + if (isArray) { + newType = typeArguments[0].getArrayType(); + } else if (typeArguments.length) { + newType = rootType.getSpecialization(typeArguments); + } + + if (!newType && !typeParameters.length && context.specializingToAny) { + newType = rootType.getSpecialization([resolver.semanticInfoChain.anyTypeSymbol]); + } + + for (var i = 0; i < typeArguments.length; i++) { + if (!typeArguments[i].isTypeParameter() && (typeArguments[i] == rootType || typeWrapsTypeParameter(typeArguments[i], typeParameters[i]))) { + declAST = resolver.semanticInfoChain.getASTForDecl(newTypeDecl); + if (declAST && typeArguments[i] != resolver.getCachedArrayType()) { + diagnostic = context.postError(enclosingDecl.getScriptName(), declAST.minChar, declAST.getLength(), TypeScript.DiagnosticCode.A_generic_type_may_not_reference_itself_with_a_wrapped_form_of_its_own_type_parameters, null, enclosingDecl); + typeToSpecialize.hasRecursiveSpecializationError = true; + return resolver.getNewErrorTypeSymbol(diagnostic); + } else { + return resolver.semanticInfoChain.anyTypeSymbol; + } + } + } + } else { + var knownTypeArguments = typeToSpecialize.getTypeArguments(); + var typesToReplace = knownTypeArguments ? knownTypeArguments : typeParameters; + var diagnostic; + var declAST; + + for (var i = 0; i < typesToReplace.length; i++) { + if (!typesToReplace[i].isTypeParameter() && (typeArguments[i] == rootType || typeWrapsTypeParameter(typesToReplace[i], typeParameters[i]))) { + declAST = resolver.semanticInfoChain.getASTForDecl(newTypeDecl); + if (declAST && typeArguments[i] != resolver.getCachedArrayType()) { + diagnostic = context.postError(enclosingDecl.getScriptName(), declAST.minChar, declAST.getLength(), TypeScript.DiagnosticCode.A_generic_type_may_not_reference_itself_with_a_wrapped_form_of_its_own_type_parameters, null, enclosingDecl); + typeToSpecialize.hasRecursiveSpecializationError = true; + return resolver.getNewErrorTypeSymbol(diagnostic); + } else { + return resolver.semanticInfoChain.anyTypeSymbol; + } + } + + substitution = specializeType(typesToReplace[i], null, resolver, enclosingDecl, context, ast); + + typeArguments[i] = substitution != null ? substitution : typesToReplace[i]; + } + + newType = rootType.getSpecialization(typeArguments); + } + + var rootTypeParameters = rootType.getTypeParameters(); + + if (rootTypeParameters.length && (rootTypeParameters.length == typeArguments.length)) { + for (var i = 0; i < typeArguments.length; i++) { + if (typeArguments[i] != rootTypeParameters[i]) { + break; + } + } + + if (i == rootTypeParameters.length) { + return rootType; + } + } + + if (newType) { + if (!newType.isResolved && !newType.currentlyBeingSpecialized()) { + } else { + return newType; + } + } + + var prevInSpecialization = context.inSpecialization; + context.inSpecialization = true; + + if (!newType) { + TypeScript.nSpecializationsCreated++; + + newType = typeToSpecialize.isClass() ? new PullTypeSymbol(typeToSpecialize.name, 8 /* Class */) : isArray ? new PullTypeSymbol("Array", 128 /* Array */) : typeToSpecialize.isTypeParameter() ? new PullTypeVariableSymbol(typeToSpecialize.name, (typeToSpecialize).isFunctionTypeParameter()) : new PullTypeSymbol(typeToSpecialize.name, typeToSpecialize.kind); + newType.setRootSymbol(rootType); + } + + newType.setIsBeingSpecialized(); + + newType.setTypeArguments(typeArguments); + + newType.hasRecursiveSpecializationError = typeToSpecialize.hasRecursiveSpecializationError; + + rootType.addSpecialization(newType, typeArguments); + + if (isArray) { + newType.setElementType(typeArguments[0]); + typeArguments[0].setArrayType(newType); + } + + if (typeToSpecialize.currentlyBeingSpecialized()) { + return newType; + } + + var prevCurrentlyBeingSpecialized = typeToSpecialize.currentlyBeingSpecialized(); + if (typeToSpecialize.kind == 33554432 /* ConstructorType */) { + typeToSpecialize.setIsBeingSpecialized(); + } + + var typeReplacementMap = {}; + + for (var i = 0; i < typeParameters.length; i++) { + if (typeParameters[i] != typeArguments[i]) { + typeReplacementMap[typeParameters[i].pullSymbolIDString] = typeArguments[i]; + } + newType.addTypeParameter(typeParameters[i]); + } + + var extendedTypesToSpecialize = typeToSpecialize.getExtendedTypes(); + var typeDecl; + var typeAST; + var unitPath; + var decls = typeToSpecialize.getDeclarations(); + var extendTypeSymbol = null; + var implementedTypeSymbol = null; + + if (extendedTypesToSpecialize.length) { + for (var i = 0; i < decls.length; i++) { + typeDecl = decls[i]; + typeAST = resolver.semanticInfoChain.getASTForDecl(typeDecl); + + if (typeAST.extendsList) { + unitPath = resolver.getUnitPath(); + resolver.setUnitPath(typeDecl.getScriptName()); + for (var j = 0; j < typeAST.extendsList.members.length; j++) { + context.pushTypeSpecializationCache(typeReplacementMap); + extendTypeSymbol = resolver.resolveTypeReference(new TypeScript.TypeReference(typeAST.extendsList.members[j], 0), typeDecl, context); + resolver.setUnitPath(unitPath); + context.popTypeSpecializationCache(); + + newType.addExtendedType(extendTypeSymbol); + } + } + } + } + + var implementedTypesToSpecialize = typeToSpecialize.getImplementedTypes(); + + if (implementedTypesToSpecialize.length) { + for (var i = 0; i < decls.length; i++) { + typeDecl = decls[i]; + typeAST = resolver.semanticInfoChain.getASTForDecl(typeDecl); + + if (typeAST.implementsList) { + unitPath = resolver.getUnitPath(); + resolver.setUnitPath(typeDecl.getScriptName()); + for (var j = 0; j < typeAST.implementsList.members.length; j++) { + context.pushTypeSpecializationCache(typeReplacementMap); + implementedTypeSymbol = resolver.resolveTypeReference(new TypeScript.TypeReference(typeAST.implementsList.members[j], 0), typeDecl, context); + resolver.setUnitPath(unitPath); + context.popTypeSpecializationCache(); + + newType.addImplementedType(implementedTypeSymbol); + } + } + } + } + + var callSignatures = typeToSpecialize.getCallSignatures(false); + var constructSignatures = typeToSpecialize.getConstructSignatures(false); + var indexSignatures = typeToSpecialize.getIndexSignatures(false); + var members = typeToSpecialize.getMembers(); + + var newSignature; + var placeHolderSignature; + var signature; + + var decl = null; + var declAST = null; + var parameters; + var newParameters; + var returnType = null; + var prevSpecializationSignature = null; + + for (var i = 0; i < callSignatures.length; i++) { + signature = callSignatures[i]; + + if (!signature.currentlyBeingSpecialized()) { + context.pushTypeSpecializationCache(typeReplacementMap); + + decl = signature.getDeclarations()[0]; + unitPath = resolver.getUnitPath(); + resolver.setUnitPath(decl.getScriptName()); + + newSignature = new PullSignatureSymbol(signature.kind); + TypeScript.nSpecializedSignaturesCreated++; + newSignature.mimicSignature(signature, resolver); + declAST = resolver.semanticInfoChain.getASTForDecl(decl); + + TypeScript.Debug.assert(declAST != null, "Call signature for type '" + typeToSpecialize.toString() + "' could not be specialized because of a stale declaration"); + + prevSpecializationSignature = decl.getSpecializingSignatureSymbol(); + decl.setSpecializingSignatureSymbol(newSignature); + + if (!(signature.isResolved || signature.inResolution)) { + resolver.resolveDeclaredSymbol(signature, enclosingDecl, new TypeScript.PullTypeResolutionContext()); + } + + resolver.resolveAST(declAST, false, newTypeDecl, context, true); + decl.setSpecializingSignatureSymbol(prevSpecializationSignature); + + parameters = signature.parameters; + newParameters = newSignature.parameters; + + for (var p = 0; p < parameters.length; p++) { + newParameters[p].type = parameters[p].type; + } + newSignature.setResolved(); + + resolver.setUnitPath(unitPath); + + returnType = newSignature.returnType; + + if (!returnType) { + newSignature.returnType = signature.returnType; + } + + signature.setIsBeingSpecialized(); + newSignature.setRootSymbol(signature); + placeHolderSignature = newSignature; + newSignature = specializeSignature(newSignature, true, typeReplacementMap, null, resolver, newTypeDecl, context); + signature.setIsSpecialized(); + + if (newSignature != placeHolderSignature) { + newSignature.setRootSymbol(signature); + } + + context.popTypeSpecializationCache(); + + if (!newSignature) { + context.inSpecialization = prevInSpecialization; + typeToSpecialize.setValueIsBeingSpecialized(prevCurrentlyBeingSpecialized); + TypeScript.Debug.assert(false, "returning from call"); + return resolver.semanticInfoChain.anyTypeSymbol; + } + } else { + newSignature = signature; + } + + newType.addCallSignature(newSignature); + + if (newSignature.hasAGenericParameter) { + newType.setHasGenericSignature(); + } + } + + for (var i = 0; i < constructSignatures.length; i++) { + signature = constructSignatures[i]; + + if (!signature.currentlyBeingSpecialized()) { + context.pushTypeSpecializationCache(typeReplacementMap); + + decl = signature.getDeclarations()[0]; + unitPath = resolver.getUnitPath(); + resolver.setUnitPath(decl.getScriptName()); + + newSignature = new PullSignatureSymbol(signature.kind); + TypeScript.nSpecializedSignaturesCreated++; + newSignature.mimicSignature(signature, resolver); + declAST = resolver.semanticInfoChain.getASTForDecl(decl); + + TypeScript.Debug.assert(declAST != null, "Construct signature for type '" + typeToSpecialize.toString() + "' could not be specialized because of a stale declaration"); + + prevSpecializationSignature = decl.getSpecializingSignatureSymbol(); + decl.setSpecializingSignatureSymbol(newSignature); + + if (!(signature.isResolved || signature.inResolution)) { + resolver.resolveDeclaredSymbol(signature, enclosingDecl, new TypeScript.PullTypeResolutionContext()); + } + + resolver.resolveAST(declAST, false, newTypeDecl, context, true); + decl.setSpecializingSignatureSymbol(prevSpecializationSignature); + + parameters = signature.parameters; + newParameters = newSignature.parameters; + + for (var p = 0; p < parameters.length; p++) { + newParameters[p].type = parameters[p].type; + } + newSignature.setResolved(); + + resolver.setUnitPath(unitPath); + + returnType = newSignature.returnType; + + if (!returnType) { + newSignature.returnType = signature.returnType; + } + + signature.setIsBeingSpecialized(); + newSignature.setRootSymbol(signature); + placeHolderSignature = newSignature; + newSignature = specializeSignature(newSignature, true, typeReplacementMap, null, resolver, newTypeDecl, context); + signature.setIsSpecialized(); + + if (newSignature != placeHolderSignature) { + newSignature.setRootSymbol(signature); + } + + context.popTypeSpecializationCache(); + + if (!newSignature) { + context.inSpecialization = prevInSpecialization; + typeToSpecialize.setValueIsBeingSpecialized(prevCurrentlyBeingSpecialized); + TypeScript.Debug.assert(false, "returning from construct"); + return resolver.semanticInfoChain.anyTypeSymbol; + } + } else { + newSignature = signature; + } + + newType.addConstructSignature(newSignature); + + if (newSignature.hasAGenericParameter) { + newType.setHasGenericSignature(); + } + } + + for (var i = 0; i < indexSignatures.length; i++) { + signature = indexSignatures[i]; + + if (!signature.currentlyBeingSpecialized()) { + context.pushTypeSpecializationCache(typeReplacementMap); + + decl = signature.getDeclarations()[0]; + unitPath = resolver.getUnitPath(); + resolver.setUnitPath(decl.getScriptName()); + + newSignature = new PullSignatureSymbol(signature.kind); + TypeScript.nSpecializedSignaturesCreated++; + newSignature.mimicSignature(signature, resolver); + declAST = resolver.semanticInfoChain.getASTForDecl(decl); + + TypeScript.Debug.assert(declAST != null, "Index signature for type '" + typeToSpecialize.toString() + "' could not be specialized because of a stale declaration"); + + prevSpecializationSignature = decl.getSpecializingSignatureSymbol(); + decl.setSpecializingSignatureSymbol(newSignature); + + if (!(signature.isResolved || signature.inResolution)) { + resolver.resolveDeclaredSymbol(signature, enclosingDecl, new TypeScript.PullTypeResolutionContext()); + } + + resolver.resolveAST(declAST, false, newTypeDecl, context, true); + decl.setSpecializingSignatureSymbol(prevSpecializationSignature); + + parameters = signature.parameters; + newParameters = newSignature.parameters; + + for (var p = 0; p < parameters.length; p++) { + newParameters[p].type = parameters[p].type; + } + newSignature.setResolved(); + + resolver.setUnitPath(unitPath); + + returnType = newSignature.returnType; + + if (!returnType) { + newSignature.returnType = signature.returnType; + } + + signature.setIsBeingSpecialized(); + newSignature.setRootSymbol(signature); + placeHolderSignature = newSignature; + newSignature = specializeSignature(newSignature, true, typeReplacementMap, null, resolver, newTypeDecl, context); + signature.setIsSpecialized(); + + if (newSignature != placeHolderSignature) { + newSignature.setRootSymbol(signature); + } + + context.popTypeSpecializationCache(); + + if (!newSignature) { + context.inSpecialization = prevInSpecialization; + typeToSpecialize.setValueIsBeingSpecialized(prevCurrentlyBeingSpecialized); + TypeScript.Debug.assert(false, "returning from index"); + return resolver.semanticInfoChain.anyTypeSymbol; + } + } else { + newSignature = signature; + } + + newType.addIndexSignature(newSignature); + + if (newSignature.hasAGenericParameter) { + newType.setHasGenericSignature(); + } + } + + var field = null; + var newField = null; + + var fieldType = null; + var newFieldType = null; + var replacementType = null; + + var fieldSignatureSymbol = null; + + for (var i = 0; i < members.length; i++) { + field = members[i]; + field.setIsBeingSpecialized(); + + decls = field.getDeclarations(); + + newField = new PullSymbol(field.name, field.kind); + + newField.setRootSymbol(field); + + if (field.isOptional) { + newField.isOptional = true; + } + + if (!field.isResolved) { + resolver.resolveDeclaredSymbol(field, newTypeDecl, context); + } + + fieldType = field.type; + + if (!fieldType) { + fieldType = newType; + } + + replacementType = typeReplacementMap[fieldType.pullSymbolIDString]; + + if (replacementType) { + newField.type = replacementType; + } else { + if (fieldType.isGeneric() && !fieldType.isFixed()) { + unitPath = resolver.getUnitPath(); + resolver.setUnitPath(decls[0].getScriptName()); + + context.pushTypeSpecializationCache(typeReplacementMap); + + newFieldType = specializeType(fieldType, !fieldType.getIsSpecialized() ? typeArguments : null, resolver, newTypeDecl, context, ast); + + resolver.setUnitPath(unitPath); + + context.popTypeSpecializationCache(); + + newField.type = newFieldType; + } else { + newField.type = fieldType; + } + } + field.setIsSpecialized(); + newType.addMember(newField); + } + + if (typeToSpecialize.isClass()) { + var constructorMethod = typeToSpecialize.getConstructorMethod(); + + if (!constructorMethod.isResolved) { + var prevIsSpecializingConstructorMethod = context.isSpecializingConstructorMethod; + context.isSpecializingConstructorMethod = true; + resolver.resolveDeclaredSymbol(constructorMethod, enclosingDecl, context); + context.isSpecializingConstructorMethod = prevIsSpecializingConstructorMethod; + } + + var newConstructorMethod = new PullSymbol(constructorMethod.name, 32768 /* ConstructorMethod */); + var newConstructorType = specializeType(constructorMethod.type, typeArguments, resolver, newTypeDecl, context, ast); + + newConstructorMethod.type = newConstructorType; + + var constructorDecls = constructorMethod.getDeclarations(); + + newConstructorMethod.setRootSymbol(constructorMethod); + + newType.setConstructorMethod(newConstructorMethod); + } + + newType.setIsSpecialized(); + + newType.setResolved(); + typeToSpecialize.setValueIsBeingSpecialized(prevCurrentlyBeingSpecialized); + context.inSpecialization = prevInSpecialization; + return newType; + } + TypeScript.specializeType = specializeType; + + function specializeSignature(signature, skipLocalTypeParameters, typeReplacementMap, typeArguments, resolver, enclosingDecl, context, ast) { + if (signature.currentlyBeingSpecialized()) { + return signature; + } + + if (!signature.isResolved && !signature.inResolution) { + resolver.resolveDeclaredSymbol(signature, enclosingDecl, context); + } + + var newSignature = signature.getSpecialization(typeArguments); + + if (newSignature) { + return newSignature; + } + + signature.setIsBeingSpecialized(); + + var prevInSpecialization = context.inSpecialization; + context.inSpecialization = true; + + newSignature = new PullSignatureSymbol(signature.kind); + TypeScript.nSpecializedSignaturesCreated++; + newSignature.setRootSymbol(signature); + + if (signature.hasVarArgs) { + newSignature.hasVarArgs = true; + } + + if (signature.hasAGenericParameter) { + newSignature.hasAGenericParameter = true; + } + + signature.addSpecialization(newSignature, typeArguments); + + var parameters = signature.parameters; + var typeParameters = signature.getTypeParameters(); + var returnType = signature.returnType; + + for (var i = 0; i < typeParameters.length; i++) { + newSignature.addTypeParameter(typeParameters[i]); + } + + if (signature.hasAGenericParameter) { + newSignature.hasAGenericParameter = true; + } + + var newParameter; + var newParameterType; + var newParameterElementType; + var parameterType; + var replacementParameterType; + var localTypeParameters = new TypeScript.BlockIntrinsics(); + var localSkipMap = null; + + if (skipLocalTypeParameters) { + for (var i = 0; i < typeParameters.length; i++) { + localTypeParameters[typeParameters[i].getName()] = true; + if (!localSkipMap) { + localSkipMap = {}; + } + localSkipMap[typeParameters[i].pullSymbolIDString] = typeParameters[i]; + } + } + + context.pushTypeSpecializationCache(typeReplacementMap); + + if (skipLocalTypeParameters && localSkipMap) { + context.pushTypeSpecializationCache(localSkipMap); + } + var newReturnType = (!localTypeParameters[returnType.name]) ? specializeType(returnType, null, resolver, enclosingDecl, context, ast) : returnType; + if (skipLocalTypeParameters && localSkipMap) { + context.popTypeSpecializationCache(); + } + context.popTypeSpecializationCache(); + + newSignature.returnType = newReturnType; + + for (var k = 0; k < parameters.length; k++) { + newParameter = new PullSymbol(parameters[k].name, parameters[k].kind); + newParameter.setRootSymbol(parameters[k]); + + parameterType = parameters[k].type; + + context.pushTypeSpecializationCache(typeReplacementMap); + if (skipLocalTypeParameters && localSkipMap) { + context.pushTypeSpecializationCache(localSkipMap); + } + newParameterType = !localTypeParameters[parameterType.name] ? specializeType(parameterType, null, resolver, enclosingDecl, context, ast) : parameterType; + if (skipLocalTypeParameters && localSkipMap) { + context.popTypeSpecializationCache(); + } + context.popTypeSpecializationCache(); + + if (parameters[k].isOptional) { + newParameter.isOptional = true; + } + + if (parameters[k].isVarArg) { + newParameter.isVarArg = true; + newSignature.hasVarArgs = true; + } + + if (resolver.isTypeArgumentOrWrapper(newParameterType)) { + newSignature.hasAGenericParameter = true; + } + + newParameter.type = newParameterType; + newSignature.addParameter(newParameter, newParameter.isOptional); + } + + signature.setIsSpecialized(); + + context.inSpecialization = prevInSpecialization; + + return newSignature; + } + TypeScript.specializeSignature = specializeSignature; + + function getIDForTypeSubstitutions(types) { + var substitution = ""; + + for (var i = 0; i < types.length; i++) { + substitution += types[i].pullSymbolIDString + "#"; + } + + return substitution; + } + TypeScript.getIDForTypeSubstitutions = getIDForTypeSubstitutions; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var PullSymbolBindingContext = (function () { + function PullSymbolBindingContext(semanticInfoChain, scriptName) { + this.semanticInfoChain = semanticInfoChain; + this.scriptName = scriptName; + this.parentChain = []; + this.declPath = []; + this.reBindingAfterChange = false; + this.startingDeclForRebind = TypeScript.pullDeclID; + this.semanticInfo = this.semanticInfoChain.getUnit(this.scriptName); + } + PullSymbolBindingContext.prototype.getParent = function (n) { + if (typeof n === "undefined") { n = 0; } + return this.parentChain ? this.parentChain[this.parentChain.length - 1 - n] : null; + }; + PullSymbolBindingContext.prototype.getDeclPath = function () { + return this.declPath; + }; + + PullSymbolBindingContext.prototype.pushParent = function (parentDecl) { + if (parentDecl) { + this.parentChain[this.parentChain.length] = parentDecl; + this.declPath[this.declPath.length] = parentDecl.name; + } + }; + + PullSymbolBindingContext.prototype.popParent = function () { + if (this.parentChain.length) { + this.parentChain.length--; + this.declPath.length--; + } + }; + return PullSymbolBindingContext; + })(); + TypeScript.PullSymbolBindingContext = PullSymbolBindingContext; + + TypeScript.time_in_findSymbol = 0; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var CandidateInferenceInfo = (function () { + function CandidateInferenceInfo() { + this.typeParameter = null; + this.isFixed = false; + this.inferenceCandidates = []; + } + CandidateInferenceInfo.prototype.addCandidate = function (candidate) { + if (!this.isFixed) { + this.inferenceCandidates[this.inferenceCandidates.length] = candidate; + } + }; + return CandidateInferenceInfo; + })(); + TypeScript.CandidateInferenceInfo = CandidateInferenceInfo; + + var ArgumentInferenceContext = (function () { + function ArgumentInferenceContext() { + this.inferenceCache = {}; + this.candidateCache = {}; + } + ArgumentInferenceContext.prototype.alreadyRelatingTypes = function (objectType, parameterType) { + var comboID = objectType.pullSymbolIDString + "#" + parameterType.pullSymbolIDString; + + if (this.inferenceCache[comboID]) { + return true; + } else { + this.inferenceCache[comboID] = true; + return false; + } + }; + + ArgumentInferenceContext.prototype.resetRelationshipCache = function () { + this.inferenceCache = {}; + }; + + ArgumentInferenceContext.prototype.addInferenceRoot = function (param) { + var info = this.candidateCache[param.pullSymbolIDString]; + + if (!info) { + info = new CandidateInferenceInfo(); + info.typeParameter = param; + this.candidateCache[param.pullSymbolIDString] = info; + } + }; + + ArgumentInferenceContext.prototype.getInferenceInfo = function (param) { + return this.candidateCache[param.pullSymbolIDString]; + }; + + ArgumentInferenceContext.prototype.addCandidateForInference = function (param, candidate, fix) { + var info = this.getInferenceInfo(param); + + if (info) { + if (candidate) { + info.addCandidate(candidate); + } + + if (!info.isFixed) { + info.isFixed = fix; + } + } + }; + + ArgumentInferenceContext.prototype.getInferenceCandidates = function () { + var inferenceCandidates = []; + var info; + var val; + + for (var infoKey in this.candidateCache) { + info = this.candidateCache[infoKey]; + + for (var i = 0; i < info.inferenceCandidates.length; i++) { + val = {}; + val[info.typeParameter.pullSymbolIDString] = info.inferenceCandidates[i]; + inferenceCandidates[inferenceCandidates.length] = val; + } + } + + return inferenceCandidates; + }; + + ArgumentInferenceContext.prototype.inferArgumentTypes = function (resolver, context) { + var info = null; + + var collection; + + var bestCommonType; + + var results = []; + + var unfit = false; + + for (var infoKey in this.candidateCache) { + info = this.candidateCache[infoKey]; + + if (!info.inferenceCandidates.length) { + results[results.length] = { param: info.typeParameter, type: resolver.semanticInfoChain.anyTypeSymbol }; + continue; + } + + collection = { + getLength: function () { + return info.inferenceCandidates.length; + }, + setTypeAtIndex: function (index, type) { + }, + getTypeAtIndex: function (index) { + return info.inferenceCandidates[index].type; + } + }; + + bestCommonType = resolver.widenType(resolver.findBestCommonType(info.inferenceCandidates[0], null, collection, context, new TypeScript.TypeComparisonInfo())); + + if (!bestCommonType) { + unfit = true; + } else { + for (var i = 0; i < results.length; i++) { + if (results[i].type == info.typeParameter) { + results[i].type = bestCommonType; + } + } + } + + results[results.length] = { param: info.typeParameter, type: bestCommonType }; + } + + return { results: results, unfit: unfit }; + }; + return ArgumentInferenceContext; + })(); + TypeScript.ArgumentInferenceContext = ArgumentInferenceContext; + + var PullContextualTypeContext = (function () { + function PullContextualTypeContext(contextualType, provisional, substitutions) { + this.contextualType = contextualType; + this.provisional = provisional; + this.substitutions = substitutions; + this.provisionallyTypedSymbols = []; + this.provisionalDiagnostic = []; + } + PullContextualTypeContext.prototype.recordProvisionallyTypedSymbol = function (symbol) { + this.provisionallyTypedSymbols[this.provisionallyTypedSymbols.length] = symbol; + }; + + PullContextualTypeContext.prototype.invalidateProvisionallyTypedSymbols = function () { + for (var i = 0; i < this.provisionallyTypedSymbols.length; i++) { + this.provisionallyTypedSymbols[i].invalidate(); + } + }; + + PullContextualTypeContext.prototype.postDiagnostic = function (error) { + this.provisionalDiagnostic[this.provisionalDiagnostic.length] = error; + }; + + PullContextualTypeContext.prototype.hadProvisionalErrors = function () { + return this.provisionalDiagnostic.length > 0; + }; + return PullContextualTypeContext; + })(); + TypeScript.PullContextualTypeContext = PullContextualTypeContext; + + var PullTypeResolutionContext = (function () { + function PullTypeResolutionContext(inTypeCheck) { + if (typeof inTypeCheck === "undefined") { inTypeCheck = false; } + this.inTypeCheck = inTypeCheck; + this.contextStack = []; + this.typeSpecializationStack = []; + this.genericASTResolutionStack = []; + this.resolvingTypeReference = false; + this.resolvingNamespaceMemberAccess = false; + this.resolveAggressively = false; + this.canUseTypeSymbol = false; + this.specializingToAny = false; + this.specializingToObject = false; + this.isResolvingClassExtendedType = false; + this.isSpecializingSignatureAtCallSite = false; + this.isSpecializingConstructorMethod = false; + this.isComparingSpecializedSignatures = false; + this.isResolvingSuperConstructorTarget = false; + this.inConstructorArguments = false; + this.inImportDeclaration = false; + this.isInStaticInitializer = false; + this.isInInvocationExpression = false; + this.resolvingTypeNameAsNameExpression = false; + this.inSpecialization = false; + this.suppressErrors = false; + this.inBaseTypeResolution = false; + } + PullTypeResolutionContext.prototype.pushContextualType = function (type, provisional, substitutions) { + this.contextStack.push(new PullContextualTypeContext(type, provisional, substitutions)); + }; + + PullTypeResolutionContext.prototype.popContextualType = function () { + var tc = this.contextStack.pop(); + + tc.invalidateProvisionallyTypedSymbols(); + + return tc; + }; + + PullTypeResolutionContext.prototype.findSubstitution = function (type) { + var substitution = null; + + if (this.contextStack.length) { + for (var i = this.contextStack.length - 1; i >= 0; i--) { + if (this.contextStack[i].substitutions) { + substitution = this.contextStack[i].substitutions[type.pullSymbolIDString]; + + if (substitution) { + break; + } + } + } + } + + return substitution; + }; + + PullTypeResolutionContext.prototype.getContextualType = function () { + var context = !this.contextStack.length ? null : this.contextStack[this.contextStack.length - 1]; + + if (context) { + var type = context.contextualType; + + if (!type) { + return null; + } + + if (type.isTypeParameter() && (type).getConstraint()) { + type = (type).getConstraint(); + } + + var substitution = this.findSubstitution(type); + + return substitution ? substitution : type; + } + + return null; + }; + + PullTypeResolutionContext.prototype.inProvisionalResolution = function () { + return (!this.contextStack.length ? false : this.contextStack[this.contextStack.length - 1].provisional); + }; + + PullTypeResolutionContext.prototype.isInBaseTypeResolution = function () { + return this.inBaseTypeResolution; + }; + + PullTypeResolutionContext.prototype.startBaseTypeResolution = function () { + var wasInBaseTypeResoltion = this.inBaseTypeResolution; + this.inBaseTypeResolution = true; + return wasInBaseTypeResoltion; + }; + + PullTypeResolutionContext.prototype.doneBaseTypeResolution = function (wasInBaseTypeResolution) { + this.inBaseTypeResolution = wasInBaseTypeResolution; + }; + + PullTypeResolutionContext.prototype.setTypeInContext = function (symbol, type) { + var substitution = this.findSubstitution(type); + + symbol.type = substitution ? substitution : type; + + if (this.contextStack.length && this.inProvisionalResolution()) { + this.contextStack[this.contextStack.length - 1].recordProvisionallyTypedSymbol(symbol); + } + }; + + PullTypeResolutionContext.prototype.pushTypeSpecializationCache = function (cache) { + this.typeSpecializationStack[this.typeSpecializationStack.length] = cache; + }; + + PullTypeResolutionContext.prototype.popTypeSpecializationCache = function () { + if (this.typeSpecializationStack.length) { + this.typeSpecializationStack.length--; + } + }; + + PullTypeResolutionContext.prototype.findSpecializationForType = function (type) { + var specialization = null; + + for (var i = this.typeSpecializationStack.length - 1; i >= 0; i--) { + specialization = (this.typeSpecializationStack[i])[type.pullSymbolIDString]; + + if (specialization) { + return specialization; + } + } + + return type; + }; + + PullTypeResolutionContext.prototype.postError = function (fileName, offset, length, diagnosticKey, arguments, enclosingDecl, post) { + if (typeof post === "undefined") { post = true; } + var diagnostic = new TypeScript.Diagnostic(fileName, offset, length, diagnosticKey, arguments); + + if (post) { + this.postDiagnostic(diagnostic, enclosingDecl); + } + + return diagnostic; + }; + + PullTypeResolutionContext.prototype.postDiagnostic = function (diagnostic, enclosingDecl) { + if (this.inProvisionalResolution()) { + (this.contextStack[this.contextStack.length - 1]).postDiagnostic(diagnostic); + } else if (this.inTypeCheck && !this.suppressErrors && enclosingDecl) { + enclosingDecl.addDiagnostic(diagnostic); + } + }; + + PullTypeResolutionContext.prototype.typeCheck = function () { + return this.inTypeCheck && !this.inSpecialization; + }; + + PullTypeResolutionContext.prototype.startResolvingTypeArguments = function (ast) { + this.genericASTResolutionStack[this.genericASTResolutionStack.length] = ast; + }; + + PullTypeResolutionContext.prototype.isResolvingTypeArguments = function (ast) { + for (var i = 0; i < this.genericASTResolutionStack.length; i++) { + if (this.genericASTResolutionStack[i].astID === ast.astID) { + return true; + } + } + + return false; + }; + + PullTypeResolutionContext.prototype.doneResolvingTypeArguments = function () { + this.genericASTResolutionStack.length--; + }; + return PullTypeResolutionContext; + })(); + TypeScript.PullTypeResolutionContext = PullTypeResolutionContext; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var PullResolutionDataCache = (function () { + function PullResolutionDataCache() { + this.cacheSize = 16; + this.rdCache = []; + this.nextUp = 0; + for (var i = 0; i < this.cacheSize; i++) { + this.rdCache[i] = { + actuals: [], + exactCandidates: [], + conversionCandidates: [], + id: i + }; + } + } + PullResolutionDataCache.prototype.getResolutionData = function () { + var rd = null; + + if (this.nextUp < this.cacheSize) { + rd = this.rdCache[this.nextUp]; + } + + if (rd === null) { + this.cacheSize++; + rd = { + actuals: [], + exactCandidates: [], + conversionCandidates: [], + id: this.cacheSize + }; + this.rdCache[this.cacheSize] = rd; + } + + this.nextUp++; + + return rd; + }; + + PullResolutionDataCache.prototype.returnResolutionData = function (rd) { + rd.actuals.length = 0; + rd.exactCandidates.length = 0; + rd.conversionCandidates.length = 0; + + this.nextUp = rd.id; + }; + return PullResolutionDataCache; + })(); + TypeScript.PullResolutionDataCache = PullResolutionDataCache; + + var PullAdditionalCallResolutionData = (function () { + function PullAdditionalCallResolutionData() { + this.targetSymbol = null; + this.targetTypeSymbol = null; + this.resolvedSignatures = null; + this.candidateSignature = null; + this.actualParametersContextTypeSymbols = null; + } + return PullAdditionalCallResolutionData; + })(); + TypeScript.PullAdditionalCallResolutionData = PullAdditionalCallResolutionData; + + var PullAdditionalObjectLiteralResolutionData = (function () { + function PullAdditionalObjectLiteralResolutionData() { + this.membersContextTypeSymbols = null; + } + return PullAdditionalObjectLiteralResolutionData; + })(); + TypeScript.PullAdditionalObjectLiteralResolutionData = PullAdditionalObjectLiteralResolutionData; + + var PullTypeResolver = (function () { + function PullTypeResolver(compilationSettings, semanticInfoChain, unitPath) { + this.compilationSettings = compilationSettings; + this.semanticInfoChain = semanticInfoChain; + this.unitPath = unitPath; + this._cachedArrayInterfaceType = null; + this._cachedNumberInterfaceType = null; + this._cachedStringInterfaceType = null; + this._cachedBooleanInterfaceType = null; + this._cachedObjectInterfaceType = null; + this._cachedFunctionInterfaceType = null; + this._cachedIArgumentsInterfaceType = null; + this._cachedRegExpInterfaceType = null; + this.cachedFunctionArgumentsSymbol = null; + this.seenSuperConstructorCall = false; + this.assignableCache = {}; + this.subtypeCache = {}; + this.identicalCache = {}; + this.resolutionDataCache = new PullResolutionDataCache(); + this.currentUnit = null; + this.lastExternalModulePath = ""; + this.cachedFunctionArgumentsSymbol = new TypeScript.PullSymbol("arguments", 1024 /* Variable */); + this.cachedFunctionArgumentsSymbol.type = this.cachedIArgumentsInterfaceType() ? this.cachedIArgumentsInterfaceType() : this.semanticInfoChain.anyTypeSymbol; + this.cachedFunctionArgumentsSymbol.setResolved(); + + var functionArgumentsDecl = new TypeScript.PullDecl("arguments", "arguments", 2048 /* Parameter */, 0 /* None */, new TypeScript.TextSpan(0, 0), unitPath); + functionArgumentsDecl.setSymbol(this.cachedFunctionArgumentsSymbol); + this.cachedFunctionArgumentsSymbol.addDeclaration(functionArgumentsDecl); + + this.currentUnit = this.semanticInfoChain.getUnit(unitPath); + } + PullTypeResolver.prototype.cleanCachedGlobals = function () { + this._cachedArrayInterfaceType = null; + this._cachedNumberInterfaceType = null; + this._cachedStringInterfaceType = null; + this._cachedBooleanInterfaceType = null; + this._cachedObjectInterfaceType = null; + this._cachedFunctionInterfaceType = null; + this._cachedIArgumentsInterfaceType = null; + this._cachedRegExpInterfaceType = null; + this.cachedFunctionArgumentsSymbol = null; + + this.identicalCache = {}; + this.subtypeCache = {}; + this.assignableCache = {}; + }; + + PullTypeResolver.prototype.cachedArrayInterfaceType = function () { + if (!this._cachedArrayInterfaceType) { + this._cachedArrayInterfaceType = this.getSymbolFromDeclPath("Array", [], 16 /* Interface */); + } + + if (!this._cachedArrayInterfaceType) { + this._cachedArrayInterfaceType = this.semanticInfoChain.anyTypeSymbol; + } + + if (!this._cachedArrayInterfaceType.isResolved) { + this.resolveDeclaredSymbol(this._cachedArrayInterfaceType, null, new TypeScript.PullTypeResolutionContext()); + } + + return this._cachedArrayInterfaceType; + }; + + PullTypeResolver.prototype.getCachedArrayType = function () { + return this.cachedArrayInterfaceType(); + }; + + PullTypeResolver.prototype.cachedNumberInterfaceType = function () { + if (!this._cachedNumberInterfaceType) { + this._cachedNumberInterfaceType = this.getSymbolFromDeclPath("Number", [], 16 /* Interface */); + } + + if (this._cachedNumberInterfaceType && !this._cachedNumberInterfaceType.isResolved) { + this.resolveDeclaredSymbol(this._cachedNumberInterfaceType, null, new TypeScript.PullTypeResolutionContext()); + } + + return this._cachedNumberInterfaceType; + }; + + PullTypeResolver.prototype.cachedStringInterfaceType = function () { + if (!this._cachedStringInterfaceType) { + this._cachedStringInterfaceType = this.getSymbolFromDeclPath("String", [], 16 /* Interface */); + } + + if (this._cachedStringInterfaceType && !this._cachedStringInterfaceType.isResolved) { + this.resolveDeclaredSymbol(this._cachedStringInterfaceType, null, new TypeScript.PullTypeResolutionContext()); + } + + return this._cachedStringInterfaceType; + }; + + PullTypeResolver.prototype.cachedBooleanInterfaceType = function () { + if (!this._cachedBooleanInterfaceType) { + this._cachedBooleanInterfaceType = this.getSymbolFromDeclPath("Boolean", [], 16 /* Interface */); + } + + if (this._cachedBooleanInterfaceType && !this._cachedBooleanInterfaceType.isResolved) { + this.resolveDeclaredSymbol(this._cachedBooleanInterfaceType, null, new TypeScript.PullTypeResolutionContext()); + } + + return this._cachedBooleanInterfaceType; + }; + + PullTypeResolver.prototype.cachedObjectInterfaceType = function () { + if (!this._cachedObjectInterfaceType) { + this._cachedObjectInterfaceType = this.getSymbolFromDeclPath("Object", [], 16 /* Interface */); + } + + if (!this._cachedObjectInterfaceType) { + this._cachedObjectInterfaceType = this.semanticInfoChain.anyTypeSymbol; + } + + if (!this._cachedObjectInterfaceType.isResolved) { + this.resolveDeclaredSymbol(this._cachedObjectInterfaceType, null, new TypeScript.PullTypeResolutionContext()); + } + + return this._cachedObjectInterfaceType; + }; + + PullTypeResolver.prototype.cachedFunctionInterfaceType = function () { + if (!this._cachedFunctionInterfaceType) { + this._cachedFunctionInterfaceType = this.getSymbolFromDeclPath("Function", [], 16 /* Interface */); + } + + if (this._cachedFunctionInterfaceType && !this._cachedFunctionInterfaceType.isResolved) { + this.resolveDeclaredSymbol(this._cachedFunctionInterfaceType, null, new TypeScript.PullTypeResolutionContext()); + } + + return this._cachedFunctionInterfaceType; + }; + + PullTypeResolver.prototype.cachedIArgumentsInterfaceType = function () { + if (!this._cachedIArgumentsInterfaceType) { + this._cachedIArgumentsInterfaceType = this.getSymbolFromDeclPath("IArguments", [], 16 /* Interface */); + } + + if (this._cachedIArgumentsInterfaceType && !this._cachedIArgumentsInterfaceType.isResolved) { + this.resolveDeclaredSymbol(this._cachedIArgumentsInterfaceType, null, new TypeScript.PullTypeResolutionContext()); + } + + return this._cachedIArgumentsInterfaceType; + }; + + PullTypeResolver.prototype.cachedRegExpInterfaceType = function () { + if (!this._cachedRegExpInterfaceType) { + this._cachedRegExpInterfaceType = this.getSymbolFromDeclPath("RegExp", [], 16 /* Interface */); + } + + if (!this._cachedRegExpInterfaceType.isResolved) { + this.resolveDeclaredSymbol(this._cachedRegExpInterfaceType, null, new TypeScript.PullTypeResolutionContext()); + } + + return this._cachedRegExpInterfaceType; + }; + + PullTypeResolver.prototype.getUnitPath = function () { + return this.unitPath; + }; + + PullTypeResolver.prototype.setUnitPath = function (unitPath) { + this.unitPath = unitPath; + + this.currentUnit = this.semanticInfoChain.getUnit(unitPath); + }; + + PullTypeResolver.prototype.getDeclForAST = function (ast) { + return this.semanticInfoChain.getDeclForAST(ast, this.unitPath); + }; + + PullTypeResolver.prototype.getSymbolForAST = function (ast) { + return this.semanticInfoChain.getSymbolForAST(ast, this.unitPath); + }; + + PullTypeResolver.prototype.setSymbolForAST = function (ast, symbol, context) { + if (context && (context.inProvisionalResolution() || context.inSpecialization)) { + return; + } + + this.semanticInfoChain.setSymbolForAST(ast, symbol, this.unitPath); + }; + + PullTypeResolver.prototype.getASTForSymbol = function (symbol) { + return this.semanticInfoChain.getASTForSymbol(symbol, this.unitPath); + }; + + PullTypeResolver.prototype.getASTForDecl = function (decl) { + return this.semanticInfoChain.getASTForDecl(decl); + }; + + PullTypeResolver.prototype.getNewErrorTypeSymbol = function (diagnostic, data) { + return new TypeScript.PullErrorTypeSymbol(diagnostic, this.semanticInfoChain.anyTypeSymbol, data); + }; + + PullTypeResolver.prototype.getEnclosingDecl = function (decl) { + var declPath = TypeScript.getPathToDecl(decl); + + if (!declPath.length) { + return null; + } else if (declPath.length > 1 && declPath[declPath.length - 1] === decl) { + return declPath[declPath.length - 2]; + } else { + return declPath[declPath.length - 1]; + } + }; + + PullTypeResolver.prototype.getExportedMemberSymbol = function (symbol, parent) { + if (!(symbol.kind & (65536 /* Method */ | 4096 /* Property */))) { + var isContainer = (parent.kind & (4 /* Container */ | 32 /* DynamicModule */)) != 0; + var containerType = !isContainer ? parent.getAssociatedContainerType() : parent; + + if (isContainer && containerType) { + if (symbol.hasFlag(1 /* Exported */)) { + return symbol; + } + + return null; + } + } + + return symbol; + }; + + PullTypeResolver.prototype.getMemberSymbol = function (symbolName, declSearchKind, parent) { + var member = null; + + if (declSearchKind & TypeScript.PullElementKind.SomeValue) { + member = parent.findMember(symbolName); + } else { + member = parent.findNestedType(symbolName); + } + + if (member) { + return this.getExportedMemberSymbol(member, parent); + } + + var containerType = parent.getAssociatedContainerType(); + + if (containerType) { + if (containerType.isClass()) { + return null; + } + + parent = containerType; + } + + if (declSearchKind & TypeScript.PullElementKind.SomeValue) { + member = parent.findMember(symbolName); + } else { + member = parent.findNestedType(symbolName); + } + + if (member) { + return this.getExportedMemberSymbol(member, parent); + } + + var typeDeclarations = parent.getDeclarations(); + var childDecls = null; + + for (var j = 0; j < typeDeclarations.length; j++) { + childDecls = typeDeclarations[j].searchChildDecls(symbolName, declSearchKind); + + if (childDecls.length) { + member = childDecls[0].getSymbol(); + + if (!member) { + member = childDecls[0].getSignatureSymbol(); + } + return this.getExportedMemberSymbol(member, parent); + } + + if ((declSearchKind & TypeScript.PullElementKind.SomeType) != 0 || (declSearchKind & TypeScript.PullElementKind.SomeValue) != 0) { + childDecls = typeDeclarations[j].searchChildDecls(symbolName, 256 /* TypeAlias */); + if (childDecls.length && childDecls[0].kind == 256 /* TypeAlias */) { + var aliasSymbol = this.getExportedMemberSymbol(childDecls[0].getSymbol(), parent); + if (aliasSymbol) { + if ((declSearchKind & TypeScript.PullElementKind.SomeType) != 0) { + var typeSymbol = aliasSymbol.getExportAssignedTypeSymbol(); + if (typeSymbol) { + return typeSymbol; + } + } else { + var valueSymbol = aliasSymbol.getExportAssignedValueSymbol(); + if (valueSymbol) { + return valueSymbol; + } + } + } + } + } + } + }; + + PullTypeResolver.prototype.getSymbolFromDeclPath = function (symbolName, declPath, declSearchKind) { + var symbol = null; + + var decl = null; + var childDecls; + var declSymbol = null; + var declMembers; + var pathDeclKind; + var valDecl = null; + var kind; + var instanceSymbol = null; + var instanceType = null; + var childSymbol = null; + + for (var i = declPath.length - 1; i >= 0; i--) { + decl = declPath[i]; + pathDeclKind = decl.kind; + + if (decl.flags & 2097152 /* DeclaredInAWithBlock */) { + return this.semanticInfoChain.anyTypeSymbol; + } + + if (pathDeclKind & (4 /* Container */ | 32 /* DynamicModule */)) { + childDecls = decl.searchChildDecls(symbolName, declSearchKind); + + if (childDecls.length) { + return childDecls[0].getSymbol(); + } + + if (declSearchKind & TypeScript.PullElementKind.SomeValue) { + instanceSymbol = (decl.getSymbol()).getInstanceSymbol(); + + childDecls = decl.searchChildDecls(symbolName, 256 /* TypeAlias */); + + if (childDecls.length) { + var sym = childDecls[0].getSymbol(); + + if (sym.isAlias()) { + return sym; + } + } + + if (instanceSymbol) { + instanceType = instanceSymbol.type; + + childSymbol = this.getMemberSymbol(symbolName, declSearchKind, instanceType); + + if (childSymbol && (childSymbol.kind & declSearchKind)) { + return childSymbol; + } + } + + valDecl = decl.getValueDecl(); + + if (valDecl) { + decl = valDecl; + } + } + + declSymbol = decl.getSymbol().type; + + var childSymbol = this.getMemberSymbol(symbolName, declSearchKind, declSymbol); + + if (childSymbol) { + return childSymbol; + } + } else if ((declSearchKind & (TypeScript.PullElementKind.SomeType | TypeScript.PullElementKind.SomeContainer)) || !(pathDeclKind & 8 /* Class */)) { + var candidateSymbol = null; + + if (pathDeclKind === 131072 /* FunctionExpression */ && symbolName === (decl).getFunctionExpressionName()) { + candidateSymbol = decl.getSymbol(); + } + + childDecls = decl.searchChildDecls(symbolName, declSearchKind); + + if (childDecls.length) { + if (decl.kind & TypeScript.PullElementKind.SomeFunction) { + decl.ensureSymbolIsBound(); + } + return childDecls[0].getSymbol(); + } + + if (candidateSymbol) { + return candidateSymbol; + } + + if (declSearchKind & TypeScript.PullElementKind.SomeValue) { + childDecls = decl.searchChildDecls(symbolName, 256 /* TypeAlias */); + + if (childDecls.length) { + var sym = childDecls[0].getSymbol(); + + if (sym.isAlias()) { + return sym; + } + } + } + } + } + + symbol = this.semanticInfoChain.findSymbol([symbolName], declSearchKind); + + return symbol; + }; + + PullTypeResolver.prototype.getVisibleDeclsFromDeclPath = function (declPath, declSearchKind) { + var result = []; + var decl = null; + var childDecls; + var pathDeclKind; + + for (var i = declPath.length - 1; i >= 0; i--) { + decl = declPath[i]; + pathDeclKind = decl.kind; + + var declKind = decl.kind; + + if (declKind !== 8 /* Class */ && declKind !== 16 /* Interface */) { + this.addFilteredDecls(decl.getChildDecls(), declSearchKind, result); + } + + switch (declKind) { + case 4 /* Container */: + case 32 /* DynamicModule */: + var otherDecls = this.semanticInfoChain.findDeclsFromPath(declPath.slice(0, i + 1), TypeScript.PullElementKind.SomeContainer); + for (var j = 0, m = otherDecls.length; j < m; j++) { + var otherDecl = otherDecls[j]; + if (otherDecl === decl) { + continue; + } + + var otherDeclChildren = otherDecl.getChildDecls(); + for (var k = 0, s = otherDeclChildren.length; k < s; k++) { + var otherDeclChild = otherDeclChildren[k]; + if ((otherDeclChild.flags & 1 /* Exported */) && (otherDeclChild.kind & declSearchKind)) { + result.push(otherDeclChild); + } + } + } + + break; + + case 8 /* Class */: + case 16 /* Interface */: + var parameters = decl.getTypeParameters(); + if (parameters && parameters.length) { + this.addFilteredDecls(parameters, declSearchKind, result); + } + + break; + + case 131072 /* FunctionExpression */: + var functionExpressionName = (decl).getFunctionExpressionName(); + if (functionExpressionName) { + result.push(decl); + } + + case 16384 /* Function */: + case 32768 /* ConstructorMethod */: + case 65536 /* Method */: + var parameters = decl.getTypeParameters(); + if (parameters && parameters.length) { + this.addFilteredDecls(parameters, declSearchKind, result); + } + + break; + } + } + + var units = this.semanticInfoChain.units; + for (var i = 0, n = units.length; i < n; i++) { + var unit = units[i]; + if (unit === this.currentUnit && declPath.length != 0) { + continue; + } + var topLevelDecls = unit.getTopLevelDecls(); + if (topLevelDecls.length) { + for (var j = 0, m = topLevelDecls.length; j < m; j++) { + var topLevelDecl = topLevelDecls[j]; + if (topLevelDecl.kind === 1 /* Script */ || topLevelDecl.kind === 0 /* Global */) { + this.addFilteredDecls(topLevelDecl.getChildDecls(), declSearchKind, result); + } + } + } + } + + return result; + }; + + PullTypeResolver.prototype.addFilteredDecls = function (decls, declSearchKind, result) { + if (decls.length) { + for (var i = 0, n = decls.length; i < n; i++) { + var decl = decls[i]; + if (decl.kind & declSearchKind) { + result.push(decl); + } + } + } + }; + + PullTypeResolver.prototype.getVisibleDecls = function (enclosingDecl, context) { + var declPath = enclosingDecl !== null ? TypeScript.getPathToDecl(enclosingDecl) : []; + + if (enclosingDecl && !declPath.length) { + declPath = [enclosingDecl]; + } + + var declSearchKind = TypeScript.PullElementKind.SomeType | TypeScript.PullElementKind.SomeContainer | TypeScript.PullElementKind.SomeValue; + + return this.getVisibleDeclsFromDeclPath(declPath, declSearchKind); + }; + + PullTypeResolver.prototype.getVisibleContextSymbols = function (enclosingDecl, context) { + var contextualTypeSymbol = context.getContextualType(); + if (!contextualTypeSymbol || this.isAnyOrEquivalent(contextualTypeSymbol)) { + return null; + } + + var declSearchKind = TypeScript.PullElementKind.SomeType | TypeScript.PullElementKind.SomeContainer | TypeScript.PullElementKind.SomeValue; + var members = contextualTypeSymbol.getAllMembers(declSearchKind, false); + + for (var i = 0; i < members.length; i++) { + members[i].setUnresolved(); + } + + return members; + }; + + PullTypeResolver.prototype.getVisibleMembersFromExpression = function (expression, enclosingDecl, context) { + var prevCanUseTypeSymbol = context.canUseTypeSymbol; + var prevResolvingNamespaceMemberAccess = context.resolvingNamespaceMemberAccess; + context.canUseTypeSymbol = true; + context.resolvingNamespaceMemberAccess = true; + var lhs = this.resolveAST(expression, false, enclosingDecl, context); + context.canUseTypeSymbol = prevCanUseTypeSymbol; + context.resolvingNamespaceMemberAccess = prevResolvingNamespaceMemberAccess; + + if (context.resolvingTypeReference && (lhs.kind === 8 /* Class */ || lhs.kind === 16 /* Interface */)) { + return null; + } + + var lhsType = lhs.type; + if (!lhsType) { + return null; + } + + if (this.isAnyOrEquivalent(lhsType)) { + return null; + } + + if (!lhsType.isResolved) { + this.resolveDeclaredSymbol(lhsType, enclosingDecl, context); + } + + var includePrivate = false; + var containerSymbol = lhsType; + if (containerSymbol.kind === 33554432 /* ConstructorType */) { + containerSymbol = containerSymbol.getConstructSignatures()[0].returnType; + } + + if (containerSymbol && containerSymbol.isClass()) { + var declPath = TypeScript.getPathToDecl(enclosingDecl); + if (declPath && declPath.length) { + var declarations = containerSymbol.getDeclarations(); + for (var i = 0, n = declarations.length; i < n; i++) { + var declaration = declarations[i]; + if (declPath.indexOf(declaration) >= 0) { + includePrivate = true; + break; + } + } + } + } + + var declSearchKind = TypeScript.PullElementKind.SomeType | TypeScript.PullElementKind.SomeContainer | TypeScript.PullElementKind.SomeValue; + + var members = []; + + if (lhsType.isContainer()) { + var exportedAssignedContainerSymbol = (lhsType).getExportAssignedContainerSymbol(); + if (exportedAssignedContainerSymbol) { + lhsType = exportedAssignedContainerSymbol; + } + } + + if (lhsType.isTypeParameter()) { + var constraint = (lhsType).getConstraint(); + + if (constraint) { + lhsType = constraint; + members = lhsType.getAllMembers(declSearchKind, false); + } + } else { + if (lhs.kind == 67108864 /* EnumMember */) { + lhsType = this.semanticInfoChain.numberTypeSymbol; + } + + if (lhsType === this.semanticInfoChain.numberTypeSymbol && this.cachedNumberInterfaceType()) { + lhsType = this.cachedNumberInterfaceType(); + } else if (lhsType === this.semanticInfoChain.stringTypeSymbol && this.cachedStringInterfaceType()) { + lhsType = this.cachedStringInterfaceType(); + } else if (lhsType === this.semanticInfoChain.booleanTypeSymbol && this.cachedBooleanInterfaceType()) { + lhsType = this.cachedBooleanInterfaceType(); + } + + if (!lhsType.isResolved) { + var potentiallySpecializedType = this.resolveDeclaredSymbol(lhsType, enclosingDecl, context); + + if (potentiallySpecializedType != lhsType) { + if (!lhs.isType()) { + context.setTypeInContext(lhs, potentiallySpecializedType); + } + + lhsType = potentiallySpecializedType; + } + } + + members = lhsType.getAllMembers(declSearchKind, includePrivate); + + if (lhsType.isContainer()) { + if (lhsType.isAlias()) { + lhsType = (lhsType).getExportAssignedTypeSymbol(); + } + var associatedInstance = (lhsType).getInstanceSymbol(); + if (associatedInstance) { + var instanceType = associatedInstance.type; + if (!instanceType.isResolved) { + this.resolveDeclaredSymbol(instanceType, enclosingDecl, context); + } + var instanceMembers = instanceType.getAllMembers(declSearchKind, includePrivate); + members = members.concat(instanceMembers); + } + + var exportedContainer = (lhsType).getExportAssignedContainerSymbol(); + if (exportedContainer) { + var exportedContainerMembers = exportedContainer.getAllMembers(declSearchKind, includePrivate); + members = members.concat(exportedContainerMembers); + } + } else if (lhsType.isConstructor()) { + var prototypeStr = "prototype"; + var prototypeSymbol = new TypeScript.PullSymbol(prototypeStr, 4096 /* Property */); + var parentDecl = lhsType.getDeclarations()[0]; + var prototypeDecl = new TypeScript.PullDecl(prototypeStr, prototypeStr, parentDecl.kind, parentDecl.flags, parentDecl.getSpan(), parentDecl.getScriptName()); + this.currentUnit.addSynthesizedDecl(prototypeDecl); + prototypeDecl.setParentDecl(parentDecl); + prototypeSymbol.addDeclaration(prototypeDecl); + prototypeSymbol.type = lhsType.getAssociatedContainerType(); + prototypeSymbol.isResolved = true; + members.push(prototypeSymbol); + } else { + var associatedContainerSymbol = lhsType.getAssociatedContainerType(); + if (associatedContainerSymbol) { + var containerType = associatedContainerSymbol.type; + if (!containerType.isResolved) { + this.resolveDeclaredSymbol(containerType, enclosingDecl, context); + } + var containerMembers = containerType.getAllMembers(declSearchKind, includePrivate); + members = members.concat(containerMembers); + } + } + } + + if (lhsType.getCallSignatures().length && this.cachedFunctionInterfaceType()) { + members = members.concat(this.cachedFunctionInterfaceType().getAllMembers(declSearchKind, false)); + } + + return members; + }; + + PullTypeResolver.prototype.isAnyOrEquivalent = function (type) { + return (type === this.semanticInfoChain.anyTypeSymbol) || type.isError(); + }; + + PullTypeResolver.prototype.isNumberOrEquivalent = function (type) { + return (type === this.semanticInfoChain.numberTypeSymbol) || (this.cachedNumberInterfaceType() && type === this.cachedNumberInterfaceType()); + }; + + PullTypeResolver.prototype.isTypeArgumentOrWrapper = function (type) { + if (!type) { + return false; + } + + if (!type.isGeneric()) { + return false; + } + + if (type.isTypeParameter()) { + return true; + } + + if (type.isArray()) { + return this.isTypeArgumentOrWrapper(type.getElementType()); + } + + var typeArguments = type.getTypeArguments(); + + if (typeArguments) { + for (var i = 0; i < typeArguments.length; i++) { + if (this.isTypeArgumentOrWrapper(typeArguments[i])) { + return true; + } + } + } else { + return true; + } + + return false; + }; + + PullTypeResolver.prototype.isArrayOrEquivalent = function (type) { + return (type.isArray() && type.getElementType()) || type == this.cachedArrayInterfaceType(); + }; + + PullTypeResolver.prototype.findTypeSymbolForDynamicModule = function (idText, currentFileName, search) { + var originalIdText = idText; + var symbol = null; + + if (!TypeScript.isRelative(originalIdText)) { + idText = originalIdText; + + var strippedIdText = TypeScript.stripQuotes(idText); + + if (this.lastExternalModulePath != "") { + idText = TypeScript.normalizePath(this.lastExternalModulePath + strippedIdText + ".ts"); + symbol = search(idText); + + if (symbol) { + return symbol; + } + + if (symbol === null) { + idText = TypeScript.normalizePath(this.lastExternalModulePath + strippedIdText + ".d.ts"); + symbol = search(idText); + } + + if (symbol) { + return symbol; + } + } + + var path = TypeScript.getRootFilePath(TypeScript.switchToForwardSlashes(currentFileName)); + + while (symbol === null && path != "") { + idText = TypeScript.normalizePath(path + strippedIdText + ".d.ts"); + symbol = search(idText); + + if (symbol === null) { + idText = TypeScript.normalizePath(path + strippedIdText + ".ts"); + symbol = search(idText); + } + + if (symbol === null) { + if (path === '/') { + path = ''; + } else { + path = TypeScript.normalizePath(path + ".."); + path = path && path != '/' ? path + '/' : path; + } + } + + if (symbol) { + this.lastExternalModulePath = path; + } + } + } + + symbol = search(originalIdText); + + if (symbol === null) { + if (!symbol) { + idText = TypeScript.swapQuotes(originalIdText); + symbol = search(idText); + } + + if (!symbol) { + idText = TypeScript.stripQuotes(originalIdText) + ".d.ts"; + symbol = search(idText); + } + + if (!symbol) { + idText = TypeScript.stripQuotes(originalIdText) + ".ts"; + symbol = search(idText); + } + } + + return symbol; + }; + + PullTypeResolver.prototype.resolveDeclaredSymbol = function (symbol, enclosingDecl, context) { + var savedResolvingTypeReference = context.resolvingTypeReference; + context.resolvingTypeReference = false; + + var result = this.resolveDeclaredSymbolWorker(symbol, enclosingDecl, context); + context.resolvingTypeReference = savedResolvingTypeReference; + + return result; + }; + + PullTypeResolver.prototype.resolveDeclaredSymbolWorker = function (symbol, enclosingDecl, context) { + if (!symbol || symbol.isResolved) { + return symbol; + } + + if (symbol.inResolution) { + if (!symbol.currentlyBeingSpecialized()) { + if (!symbol.isType()) { + symbol.type = this.semanticInfoChain.anyTypeSymbol; + } + + return symbol; + } + } + + var thisUnit = this.unitPath; + + var decls = symbol.getDeclarations(); + + var ast = null; + + for (var i = 0; i < decls.length; i++) { + var decl = decls[i]; + + ast = this.semanticInfoChain.getASTForDecl(decl); + + if (!ast || ast.nodeType() === 81 /* Member */) { + this.setUnitPath(thisUnit); + return symbol; + } + + this.setUnitPath(decl.getScriptName()); + var resolvedSymbol = this.resolveAST(ast, false, enclosingDecl, context); + + if (decl.kind == 2048 /* Parameter */ && !symbol.isResolved && !symbol.type && resolvedSymbol && symbol.hasFlag(8388608 /* PropertyParameter */)) { + symbol.type = resolvedSymbol.type; + symbol.setResolved(); + } + } + + var typeArgs = symbol.isType() ? (symbol).getTypeArguments() : null; + + if (typeArgs && typeArgs.length) { + var typeParameters = (symbol).getTypeParameters(); + var typeCache = {}; + + for (var i = 0; i < typeParameters.length; i++) { + typeCache[typeParameters[i].pullSymbolIDString] = typeArgs[i]; + } + + context.pushTypeSpecializationCache(typeCache); + var rootType = TypeScript.getRootType(symbol.type); + + var specializedSymbol = TypeScript.specializeType(rootType, typeArgs, this, enclosingDecl, context, ast); + + context.popTypeSpecializationCache(); + + symbol = specializedSymbol; + } + + this.setUnitPath(thisUnit); + + return symbol; + }; + + PullTypeResolver.prototype.resolveModuleDeclaration = function (ast, context) { + var containerDecl = this.getDeclForAST(ast); + var containerSymbol = containerDecl.getSymbol(); + + if (containerSymbol.isResolved || containerSymbol.inResolution) { + return containerSymbol; + } + + containerSymbol.inResolution = true; + + var containerDecls = containerSymbol.getDeclarations(); + + for (var i = 0; i < containerDecls.length; i++) { + var childDecls = containerDecls[i].getChildDecls(); + + for (var j = 0; j < childDecls.length; j++) { + childDecls[j].ensureSymbolIsBound(); + } + } + + var members = ast.members.members; + + if (containerDecl.kind != 64 /* Enum */) { + var instanceSymbol = containerSymbol.getInstanceSymbol(); + + if (instanceSymbol) { + this.resolveDeclaredSymbol(instanceSymbol, containerDecl.getParentDecl(), context); + } + + for (var i = 0; i < members.length; i++) { + if (members[i].nodeType() == 88 /* ExportAssignment */) { + this.resolveExportAssignmentStatement(members[i], containerDecl, context); + break; + } + } + } + + if (context.typeCheck()) { + var subModuleAST = null; + var currentPath = this.unitPath; + for (var i = 0; i < containerDecls.length; i++) { + subModuleAST = this.getASTForDecl(containerDecls[i]); + + if (subModuleAST) { + this.setUnitPath(containerDecls[i].getScriptName()); + this.resolveAST(subModuleAST.members, false, containerDecls[i], context); + } + } + + this.setUnitPath(currentPath); + + this.validateVariableDeclarationGroups(containerDecl, context); + } + + if (!context.isInBaseTypeResolution()) { + containerSymbol.setResolved(); + } else { + containerSymbol.inResolution = false; + } + + return containerSymbol; + }; + + PullTypeResolver.prototype.isTypeRefWithoutTypeArgs = function (typeRef) { + if (typeRef.nodeType() != 11 /* TypeRef */) { + return false; + } + + if (typeRef.term.nodeType() == 21 /* Name */) { + return true; + } else if (typeRef.term.nodeType() == 33 /* MemberAccessExpression */) { + var binex = typeRef.term; + + if (binex.operand2.nodeType() == 21 /* Name */) { + return true; + } + } + + return false; + }; + + PullTypeResolver.prototype.resolveReferenceTypeDeclaration = function (typeDeclAST, context) { + var typeDecl = this.getDeclForAST(typeDeclAST); + var enclosingDecl = this.getEnclosingDecl(typeDecl); + var typeDeclSymbol = typeDecl.getSymbol(); + var typeDeclIsClass = typeDeclAST.nodeType() === 14 /* ClassDeclaration */; + var hasVisited = this.getSymbolForAST(typeDeclAST) != null; + var extendedTypes = []; + var implementedTypes = []; + + if ((typeDeclSymbol.isResolved && hasVisited) || (typeDeclSymbol.inResolution && !context.isInBaseTypeResolution())) { + return typeDeclSymbol; + } + + var wasResolving = typeDeclSymbol.inResolution; + typeDeclSymbol.startResolving(); + + if (!typeDeclSymbol.isResolved) { + var typeDeclTypeParameters = typeDeclSymbol.getTypeParameters(); + for (var i = 0; i < typeDeclTypeParameters.length; i++) { + this.resolveDeclaredSymbol(typeDeclTypeParameters[i], typeDecl, context); + } + } + + var typeRefDecls = typeDeclSymbol.getDeclarations(); + + for (var i = 0; i < typeRefDecls.length; i++) { + var childDecls = typeRefDecls[i].getChildDecls(); + + for (var j = 0; j < childDecls.length; j++) { + childDecls[j].ensureSymbolIsBound(); + } + } + + var wasInBaseTypeResolution = context.startBaseTypeResolution(); + + if (!typeDeclIsClass && !hasVisited) { + typeDeclSymbol.resetKnownBaseTypeCount(); + } + + if (typeDeclAST.extendsList) { + var savedIsResolvingClassExtendedType = context.isResolvingClassExtendedType; + if (typeDeclIsClass) { + context.isResolvingClassExtendedType = true; + } + + for (var i = typeDeclSymbol.getKnownBaseTypeCount(); i < typeDeclAST.extendsList.members.length; i = typeDeclSymbol.getKnownBaseTypeCount()) { + typeDeclSymbol.incrementKnownBaseCount(); + var parentType = this.resolveTypeReference(new TypeScript.TypeReference(typeDeclAST.extendsList.members[i], 0), typeDecl, context); + + if (typeDeclSymbol.isValidBaseKind(parentType, true)) { + var resolvedParentType = parentType; + extendedTypes[extendedTypes.length] = parentType; + if (parentType.isGeneric() && parentType.isResolved && !parentType.getIsSpecialized()) { + parentType = this.specializeTypeToAny(parentType, enclosingDecl, context); + typeDecl.addDiagnostic(new TypeScript.Diagnostic(typeDecl.getScriptName(), typeDeclAST.minChar, typeDeclAST.getLength(), TypeScript.DiagnosticCode.Generic_type_references_must_include_all_type_arguments)); + } + if (!typeDeclSymbol.hasBase(parentType)) { + this.setSymbolForAST(typeDeclAST.extendsList.members[i], resolvedParentType, context); + typeDeclSymbol.addExtendedType(parentType); + + var specializations = typeDeclSymbol.getKnownSpecializations(); + + for (var j = 0; j < specializations.length; j++) { + specializations[j].addExtendedType(parentType); + } + } + } + } + + context.isResolvingClassExtendedType = savedIsResolvingClassExtendedType; + } + + if (typeDeclAST.implementsList && typeDeclIsClass) { + var extendsCount = typeDeclAST.extendsList ? typeDeclAST.extendsList.members.length : 0; + for (var i = typeDeclSymbol.getKnownBaseTypeCount(); ((i - extendsCount) >= 0) && ((i - extendsCount) < typeDeclAST.implementsList.members.length); i = typeDeclSymbol.getKnownBaseTypeCount()) { + typeDeclSymbol.incrementKnownBaseCount(); + var implementedType = this.resolveTypeReference(new TypeScript.TypeReference(typeDeclAST.implementsList.members[i - extendsCount], 0), typeDecl, context); + + if (typeDeclSymbol.isValidBaseKind(implementedType, false)) { + var resolvedImplementedType = implementedType; + implementedTypes[implementedTypes.length] = implementedType; + if (implementedType.isGeneric() && implementedType.isResolved && !implementedType.getIsSpecialized()) { + implementedType = this.specializeTypeToAny(implementedType, enclosingDecl, context); + typeDecl.addDiagnostic(new TypeScript.Diagnostic(typeDecl.getScriptName(), typeDeclAST.minChar, typeDeclAST.getLength(), TypeScript.DiagnosticCode.Generic_type_references_must_include_all_type_arguments)); + this.setSymbolForAST(typeDeclAST.implementsList.members[i - extendsCount], implementedType, context); + typeDeclSymbol.addImplementedType(implementedType); + } else if (!typeDeclSymbol.hasBase(implementedType)) { + this.setSymbolForAST(typeDeclAST.implementsList.members[i - extendsCount], resolvedImplementedType, context); + typeDeclSymbol.addImplementedType(implementedType); + } + } + } + } + + context.doneBaseTypeResolution(wasInBaseTypeResolution); + + if (wasInBaseTypeResolution) { + typeDeclSymbol.inResolution = false; + return typeDeclSymbol; + } + + if (!typeDeclSymbol.isResolved) { + var typeDeclMembers = typeDeclSymbol.getMembers(); + + if (TypeScript.globalBinder) { + TypeScript.globalBinder.resetTypeParameterCache(); + } + + if (context.typeCheck()) { + for (var i = 0; i < typeDeclMembers.length; i++) { + this.resolveDeclaredSymbol(typeDeclMembers[i], typeDecl, context); + } + } + + if (!typeDeclIsClass) { + var callSignatures = typeDeclSymbol.getCallSignatures(); + for (var i = 0; i < callSignatures.length; i++) { + this.resolveDeclaredSymbol(callSignatures[i], typeDecl, context); + } + + var constructSignatures = typeDeclSymbol.getConstructSignatures(); + for (var i = 0; i < constructSignatures.length; i++) { + this.resolveDeclaredSymbol(constructSignatures[i], typeDecl, context); + } + + var indexSignatures = typeDeclSymbol.getIndexSignatures(); + for (var i = 0; i < indexSignatures.length; i++) { + this.resolveDeclaredSymbol(indexSignatures[i], typeDecl, context); + } + + if (context.typeCheck()) { + this.typeCheckBases(typeDeclAST, typeDeclSymbol, enclosingDecl, context); + } + } + } + + this.setSymbolForAST(typeDeclAST.name, typeDeclSymbol, context); + this.setSymbolForAST(typeDeclAST, typeDeclSymbol, context); + + typeDeclSymbol.setResolved(); + + return typeDeclSymbol; + }; + + PullTypeResolver.prototype.resolveClassDeclaration = function (classDeclAST, context) { + var classDecl = this.getDeclForAST(classDeclAST); + var classDeclSymbol = classDecl.getSymbol(); + if (classDeclSymbol.isResolved) { + return classDeclSymbol; + } + + this.resolveReferenceTypeDeclaration(classDeclAST, context); + + var constructorMethod = classDeclSymbol.getConstructorMethod(); + var extendedTypes = classDeclSymbol.getExtendedTypes(); + var parentType = extendedTypes.length ? extendedTypes[0] : null; + + if (constructorMethod) { + var constructorTypeSymbol = constructorMethod.type; + + var constructSignatures = constructorTypeSymbol.getConstructSignatures(); + + if (!constructSignatures.length) { + var constructorSignature; + + if (parentType) { + var parentClass = parentType; + var parentConstructor = parentClass.getConstructorMethod(); + var parentConstructorType = parentConstructor.type; + var parentConstructSignatures = parentConstructorType.getConstructSignatures(); + + var parentConstructSignature; + var parentParameters; + for (var i = 0; i < parentConstructSignatures.length; i++) { + parentConstructSignature = parentConstructSignatures[i]; + parentParameters = parentConstructSignature.parameters; + + constructorSignature = parentConstructSignature.isDefinition() ? new TypeScript.PullDefinitionSignatureSymbol(2097152 /* ConstructSignature */) : new TypeScript.PullSignatureSymbol(2097152 /* ConstructSignature */); + constructorSignature.returnType = classDeclSymbol; + + for (var j = 0; j < parentParameters.length; j++) { + constructorSignature.addParameter(parentParameters[j], parentParameters[j].isOptional); + } + + var typeParameters = constructorTypeSymbol.getTypeParameters(); + + for (var j = 0; j < typeParameters.length; j++) { + constructorSignature.addTypeParameter(typeParameters[j]); + } + + constructorTypeSymbol.addConstructSignature(constructorSignature); + constructorSignature.addDeclaration(classDecl); + } + } else { + constructorSignature = new TypeScript.PullSignatureSymbol(2097152 /* ConstructSignature */); + constructorSignature.returnType = classDeclSymbol; + constructorTypeSymbol.addConstructSignature(constructorSignature); + constructorSignature.addDeclaration(classDecl); + + var typeParameters = constructorTypeSymbol.getTypeParameters(); + + for (var i = 0; i < typeParameters.length; i++) { + constructorSignature.addTypeParameter(typeParameters[i]); + } + } + } + + if (!classDeclSymbol.isResolved) { + return classDeclSymbol; + } + + if (context.typeCheck()) { + var constructorMembers = constructorTypeSymbol.getMembers(); + + this.resolveDeclaredSymbol(constructorMethod, classDecl, context); + + for (var i = 0; i < constructorMembers.length; i++) { + this.resolveDeclaredSymbol(constructorMembers[i], classDecl, context); + } + } + } + + if (parentType) { + var parentConstructorSymbol = parentType.getConstructorMethod(); + var parentConstructorTypeSymbol = parentConstructorSymbol.type; + + if (!constructorTypeSymbol.hasBase(parentConstructorTypeSymbol)) { + constructorTypeSymbol.addExtendedType(parentConstructorTypeSymbol); + } + } + + if (context.typeCheck()) { + this.typeCheckBases(classDeclAST, classDeclSymbol, this.getEnclosingDecl(classDecl), context); + if (classDeclSymbol.isResolved && !classDeclSymbol.hasBaseTypeConflict()) { + this.typeCheckMembersAgainstIndexer(classDeclSymbol, classDecl, context); + } + } + + return classDeclSymbol; + }; + + PullTypeResolver.prototype.resolveInterfaceDeclaration = function (interfaceDeclAST, context) { + var interfaceDecl = this.getDeclForAST(interfaceDeclAST); + var interfaceDeclSymbol = interfaceDecl.getSymbol(); + + this.resolveReferenceTypeDeclaration(interfaceDeclAST, context); + + if (context.typeCheck()) { + if (!interfaceDeclSymbol.hasBaseTypeConflict()) { + this.typeCheckMembersAgainstIndexer(interfaceDeclSymbol, interfaceDecl, context); + } + } + + return interfaceDeclSymbol; + }; + + PullTypeResolver.prototype.filterSymbol = function (symbol, kind) { + if (symbol) { + if (symbol.kind & kind) { + return symbol; + } + + if (symbol.isAlias()) { + var alias = symbol; + if (kind & TypeScript.PullElementKind.SomeContainer) { + return alias.getExportAssignedContainerSymbol(); + } else if (kind & TypeScript.PullElementKind.SomeType) { + return alias.getExportAssignedTypeSymbol(); + } else if (kind & TypeScript.PullElementKind.SomeValue) { + return alias.getExportAssignedValueSymbol(); + } + } + } + return null; + }; + + PullTypeResolver.prototype.getMemberSymbolOfKind = function (symbolName, kind, pullTypeSymbol) { + var symbol = this.getMemberSymbol(symbolName, kind, pullTypeSymbol); + + return this.filterSymbol(symbol, kind); + }; + + PullTypeResolver.prototype.resolveIdentifierOfInternalModuleReference = function (importDecl, identifier, moduleSymbol, enclosingDecl, context) { + if (identifier.isMissing()) { + return null; + } + + var moduleTypeSymbol = moduleSymbol.type; + var rhsName = identifier.text(); + var containerSymbol = this.getMemberSymbolOfKind(rhsName, TypeScript.PullElementKind.SomeContainer, moduleTypeSymbol); + var valueSymbol = null; + var typeSymbol = null; + + var acceptableAlias = true; + + if (containerSymbol) { + acceptableAlias = (containerSymbol.kind & TypeScript.PullElementKind.AcceptableAlias) != 0; + } + + if (!acceptableAlias && containerSymbol && containerSymbol.kind == 256 /* TypeAlias */) { + if (!containerSymbol.isResolved) { + this.resolveDeclaredSymbol(containerSymbol, enclosingDecl, context); + } + var aliasedAssignedValue = (containerSymbol).getExportAssignedValueSymbol(); + var aliasedAssignedType = (containerSymbol).getExportAssignedTypeSymbol(); + var aliasedAssignedContainer = (containerSymbol).getExportAssignedContainerSymbol(); + + if (aliasedAssignedValue || aliasedAssignedType || aliasedAssignedContainer) { + valueSymbol = aliasedAssignedValue; + typeSymbol = aliasedAssignedType; + containerSymbol = aliasedAssignedContainer; + acceptableAlias = true; + } + } + + if (!acceptableAlias) { + importDecl.addDiagnostic(new TypeScript.Diagnostic(importDecl.getScriptName(), identifier.minChar, identifier.getLength(), TypeScript.DiagnosticCode.Import_declaration_referencing_identifier_from_internal_module_can_only_be_made_with_variables_functions_classes_interfaces_enums_and_internal_modules)); + return null; + } + + if (!valueSymbol) { + if (moduleTypeSymbol.getInstanceSymbol()) { + valueSymbol = this.getMemberSymbolOfKind(rhsName, TypeScript.PullElementKind.SomeValue, moduleTypeSymbol.getInstanceSymbol().type); + } + } + if (!typeSymbol) { + typeSymbol = this.getMemberSymbolOfKind(rhsName, TypeScript.PullElementKind.SomeType, moduleTypeSymbol); + } + + if (!valueSymbol && !typeSymbol && !containerSymbol) { + importDecl.addDiagnostic(new TypeScript.Diagnostic(importDecl.getScriptName(), identifier.minChar, identifier.getLength(), TypeScript.DiagnosticCode.Could_not_find_symbol_0_in_module_1, [rhsName, moduleSymbol.toString()])); + return null; + } + + if (valueSymbol) { + if (!valueSymbol.isResolved) { + this.resolveDeclaredSymbol(valueSymbol, enclosingDecl, context); + } + } + if (typeSymbol) { + if (!typeSymbol.isResolved) { + this.resolveDeclaredSymbol(typeSymbol, enclosingDecl, context); + } + } + if (containerSymbol) { + if (!containerSymbol.isResolved) { + this.resolveDeclaredSymbol(containerSymbol, enclosingDecl, context); + } + } + + if (!typeSymbol && containerSymbol) { + typeSymbol = containerSymbol; + } + + return { + valueSymbol: valueSymbol, + typeSymbol: typeSymbol, + containerSymbol: containerSymbol + }; + }; + + PullTypeResolver.prototype.resolveModuleReference = function (importDecl, moduleNameExpr, context, declPath) { + TypeScript.CompilerDiagnostics.assert(moduleNameExpr.nodeType() == 33 /* MemberAccessExpression */ || moduleNameExpr.nodeType() == 21 /* Name */, "resolving module reference should always be either name or member reference"); + + var moduleSymbol = null; + var moduleName; + + if (moduleNameExpr.nodeType() == 33 /* MemberAccessExpression */) { + var dottedNameAST = moduleNameExpr; + var moduleContainer = this.resolveModuleReference(importDecl, dottedNameAST.operand1, context, declPath); + if (moduleContainer) { + moduleName = (dottedNameAST.operand2).text(); + moduleSymbol = this.getMemberSymbolOfKind(moduleName, 4 /* Container */, moduleContainer.type); + if (!moduleSymbol) { + importDecl.addDiagnostic(new TypeScript.Diagnostic(importDecl.getScriptName(), dottedNameAST.operand2.minChar, dottedNameAST.operand2.getLength(), TypeScript.DiagnosticCode.Could_not_find_module_0_in_module_1, [moduleName, moduleContainer.toString()])); + } + } + } else if (!(moduleNameExpr).isMissing()) { + moduleName = (moduleNameExpr).text(); + moduleSymbol = this.filterSymbol(this.getSymbolFromDeclPath(moduleName, declPath, 4 /* Container */), 4 /* Container */); + if (!moduleSymbol) { + importDecl.addDiagnostic(new TypeScript.Diagnostic(importDecl.getScriptName(), moduleNameExpr.minChar, moduleNameExpr.getLength(), TypeScript.DiagnosticCode.Unable_to_resolve_module_reference_0, [moduleName])); + } + } + + return moduleSymbol; + }; + + PullTypeResolver.prototype.resolveInternalModuleReference = function (importStatementAST, context) { + var importDecl = this.getDeclForAST(importStatementAST); + var enclosingDecl = this.getEnclosingDecl(importDecl); + + var aliasExpr = importStatementAST.alias.nodeType() == 11 /* TypeRef */ ? (importStatementAST.alias).term : importStatementAST.alias; + var declPath = enclosingDecl !== null ? TypeScript.getPathToDecl(enclosingDecl) : []; + var aliasedType = null; + + if (aliasExpr.nodeType() == 21 /* Name */) { + var moduleSymbol = this.resolveModuleReference(importDecl, aliasExpr, context, declPath); + if (moduleSymbol) { + aliasedType = moduleSymbol.type; + if (context.typeCheck() && aliasedType.hasFlag(32768 /* InitializedModule */)) { + var moduleName = (aliasExpr).text(); + var valueSymbol = this.getSymbolFromDeclPath(moduleName, declPath, TypeScript.PullElementKind.SomeValue); + var instanceSymbol = (aliasedType).getInstanceSymbol(); + if (valueSymbol && (instanceSymbol != valueSymbol || valueSymbol.type == aliasedType)) { + context.postError(this.unitPath, aliasExpr.minChar, aliasExpr.getLength(), TypeScript.DiagnosticCode.Internal_module_reference_0_in_import_declaration_doesn_t_reference_module_instance_for_1, [(aliasExpr).actualText, moduleSymbol.type.toString(enclosingDecl ? enclosingDecl.getSymbol() : null)], enclosingDecl); + } + } + } else { + aliasedType = this.semanticInfoChain.anyTypeSymbol; + } + } else if (aliasExpr.nodeType() == 33 /* MemberAccessExpression */) { + var importDeclSymbol = importDecl.getSymbol(); + var dottedNameAST = aliasExpr; + var moduleSymbol = this.resolveModuleReference(importDecl, dottedNameAST.operand1, context, declPath); + if (moduleSymbol) { + var identifierResolution = this.resolveIdentifierOfInternalModuleReference(importDecl, dottedNameAST.operand2, moduleSymbol, enclosingDecl, context); + if (identifierResolution) { + importDeclSymbol.setAssignedValueSymbol(identifierResolution.valueSymbol); + importDeclSymbol.setAssignedTypeSymbol(identifierResolution.typeSymbol); + importDeclSymbol.setAssignedContainerSymbol(identifierResolution.containerSymbol); + if (identifierResolution.valueSymbol) { + importDeclSymbol.isUsedAsValue = true; + } + this.semanticInfoChain.setSymbolForAST(importStatementAST.alias, importDeclSymbol, this.unitPath); + return null; + } + } + + importDeclSymbol.setAssignedTypeSymbol(this.semanticInfoChain.anyTypeSymbol); + } + + return aliasedType; + }; + + PullTypeResolver.prototype.resolveImportDeclaration = function (importStatementAST, context) { + var _this = this; + var importDecl = this.getDeclForAST(importStatementAST); + var enclosingDecl = this.getEnclosingDecl(importDecl); + var importDeclSymbol = importDecl.getSymbol(); + + var aliasedType = null; + + if (importDeclSymbol.isResolved) { + return importDeclSymbol; + } + + importDeclSymbol.startResolving(); + + var isExternalImportDeclaration = importStatementAST.isExternalImportDeclaration(); + + if (isExternalImportDeclaration) { + var modPath = (importStatementAST.alias).actualText; + var declPath = TypeScript.getPathToDecl(enclosingDecl); + + aliasedType = this.findTypeSymbolForDynamicModule(modPath, importDecl.getScriptName(), function (s) { + return _this.semanticInfoChain.findSymbol([s], 32 /* DynamicModule */); + }); + + if (!aliasedType) { + aliasedType = this.findTypeSymbolForDynamicModule(modPath, importDecl.getScriptName(), function (s) { + return _this.getSymbolFromDeclPath(s, declPath, 32 /* DynamicModule */); + }); + } + if (!aliasedType) { + importDecl.addDiagnostic(new TypeScript.Diagnostic(this.currentUnit.getPath(), importStatementAST.minChar, importStatementAST.getLength(), TypeScript.DiagnosticCode.Unable_to_resolve_external_module_0, [modPath])); + aliasedType = this.semanticInfoChain.anyTypeSymbol; + } + } else { + aliasedType = this.resolveInternalModuleReference(importStatementAST, context); + } + + if (aliasedType) { + if (!aliasedType.isContainer()) { + importDecl.addDiagnostic(new TypeScript.Diagnostic(this.currentUnit.getPath(), importStatementAST.minChar, importStatementAST.getLength(), TypeScript.DiagnosticCode.Module_cannot_be_aliased_to_a_non_module_type)); + aliasedType = this.semanticInfoChain.anyTypeSymbol; + } else if ((aliasedType).getExportAssignedValueSymbol()) { + importDeclSymbol.isUsedAsValue = true; + } + + if (aliasedType.isContainer()) { + importDeclSymbol.setAssignedContainerSymbol(aliasedType); + } + importDeclSymbol.setAssignedTypeSymbol(aliasedType); + + this.semanticInfoChain.setSymbolForAST(importStatementAST.alias, aliasedType, this.unitPath); + } + + importDeclSymbol.setResolved(); + + if (context.typeCheck()) { + var checkPrivacy; + if (isExternalImportDeclaration) { + var containerSymbol = importDeclSymbol.getExportAssignedContainerSymbol(); + var container = containerSymbol ? containerSymbol.getContainer() : null; + if (container && container.kind == 32 /* DynamicModule */) { + checkPrivacy = true; + } + } else { + checkPrivacy = true; + } + + if (checkPrivacy) { + var typeSymbol = importDeclSymbol.getExportAssignedTypeSymbol(); + var containerSymbol = importDeclSymbol.getExportAssignedContainerSymbol(); + var valueSymbol = importDeclSymbol.getExportAssignedValueSymbol(); + + this.checkSymbolPrivacy(importDeclSymbol, containerSymbol, context, function (symbol) { + var messageCode = TypeScript.DiagnosticCode.Exported_import_declaration_0_is_assigned_container_that_is_or_is_using_inaccessible_module_1; + var messageArguments = [importDeclSymbol.getScopedName(enclosingDecl ? enclosingDecl.getSymbol() : null), symbol.getScopedName(enclosingDecl ? enclosingDecl.getSymbol() : null)]; + context.postError(_this.unitPath, importStatementAST.minChar, importStatementAST.getLength(), messageCode, messageArguments, enclosingDecl); + }); + + if (typeSymbol != containerSymbol) { + this.checkSymbolPrivacy(importDeclSymbol, typeSymbol, context, function (symbol) { + var messageCode = symbol.isContainer() && !(symbol).isEnum() ? TypeScript.DiagnosticCode.Exported_import_declaration_0_is_assigned_type_that_is_using_inaccessible_module_1 : TypeScript.DiagnosticCode.Exported_import_declaration_0_is_assigned_type_that_has_or_is_using_private_type_1; + + var messageArguments = [importDeclSymbol.getScopedName(enclosingDecl ? enclosingDecl.getSymbol() : null), symbol.getScopedName(enclosingDecl ? enclosingDecl.getSymbol() : null)]; + context.postError(_this.unitPath, importStatementAST.minChar, importStatementAST.getLength(), messageCode, messageArguments, enclosingDecl); + }); + } + + if (valueSymbol) { + this.checkSymbolPrivacy(importDeclSymbol, valueSymbol.type, context, function (symbol) { + var messageCode = symbol.isContainer() && !(symbol).isEnum() ? TypeScript.DiagnosticCode.Exported_import_declaration_0_is_assigned_value_with_type_that_is_using_inaccessible_module_1 : TypeScript.DiagnosticCode.Exported_import_declaration_0_is_assigned_value_with_type_that_has_or_is_using_private_type_1; + var messageArguments = [importDeclSymbol.getScopedName(enclosingDecl ? enclosingDecl.getSymbol() : null), symbol.getScopedName(enclosingDecl ? enclosingDecl.getSymbol() : null)]; + context.postError(_this.unitPath, importStatementAST.minChar, importStatementAST.getLength(), messageCode, messageArguments, enclosingDecl); + }); + } + } + } + + return importDeclSymbol; + }; + + PullTypeResolver.prototype.resolveExportAssignmentStatement = function (exportAssignmentAST, enclosingDecl, context) { + var id = exportAssignmentAST.id.text(); + var valueSymbol = null; + var typeSymbol = null; + var containerSymbol = null; + + var parentSymbol = enclosingDecl.getSymbol(); + + if (!parentSymbol.isType() && (parentSymbol).isContainer()) { + enclosingDecl.addDiagnostic(new TypeScript.Diagnostic(enclosingDecl.getScriptName(), exportAssignmentAST.minChar, exportAssignmentAST.getLength(), TypeScript.DiagnosticCode.Export_assignments_may_only_be_used_at_the_top_level_of_external_modules)); + return this.semanticInfoChain.anyTypeSymbol; + } + + var declPath = enclosingDecl !== null ? [enclosingDecl] : []; + + containerSymbol = this.getSymbolFromDeclPath(id, declPath, TypeScript.PullElementKind.SomeContainer); + + var acceptableAlias = true; + + if (containerSymbol) { + acceptableAlias = (containerSymbol.kind & TypeScript.PullElementKind.AcceptableAlias) != 0; + } + + if (!acceptableAlias && containerSymbol && containerSymbol.kind == 256 /* TypeAlias */) { + if (!containerSymbol.isResolved) { + this.resolveDeclaredSymbol(containerSymbol, enclosingDecl, context); + } + + var aliasedAssignedValue = (containerSymbol).getExportAssignedValueSymbol(); + var aliasedAssignedType = (containerSymbol).getExportAssignedTypeSymbol(); + var aliasedAssignedContainer = (containerSymbol).getExportAssignedContainerSymbol(); + + if (aliasedAssignedValue || aliasedAssignedType || aliasedAssignedContainer) { + valueSymbol = aliasedAssignedValue; + typeSymbol = aliasedAssignedType; + containerSymbol = aliasedAssignedContainer; + acceptableAlias = true; + } + } + + if (!acceptableAlias) { + enclosingDecl.addDiagnostic(new TypeScript.Diagnostic(enclosingDecl.getScriptName(), exportAssignmentAST.minChar, exportAssignmentAST.getLength(), TypeScript.DiagnosticCode.Export_assignments_may_only_be_made_with_variables_functions_classes_interfaces_enums_and_internal_modules)); + return this.semanticInfoChain.voidTypeSymbol; + } + + if (!valueSymbol) { + valueSymbol = this.getSymbolFromDeclPath(id, declPath, TypeScript.PullElementKind.SomeValue); + } + if (!typeSymbol) { + typeSymbol = this.getSymbolFromDeclPath(id, declPath, TypeScript.PullElementKind.SomeType); + } + + if (!valueSymbol && !typeSymbol && !containerSymbol) { + context.postError(enclosingDecl.getScriptName(), exportAssignmentAST.minChar, exportAssignmentAST.getLength(), TypeScript.DiagnosticCode.Could_not_find_symbol_0, [id], enclosingDecl); + return this.semanticInfoChain.voidTypeSymbol; + } + + if (valueSymbol) { + (parentSymbol).setExportAssignedValueSymbol(valueSymbol); + } + if (typeSymbol) { + (parentSymbol).setExportAssignedTypeSymbol(typeSymbol); + } + if (containerSymbol) { + (parentSymbol).setExportAssignedContainerSymbol(containerSymbol); + } + + if (valueSymbol && !valueSymbol.isResolved) { + this.resolveDeclaredSymbol(valueSymbol, enclosingDecl, context); + } + if (typeSymbol && !typeSymbol.isResolved) { + this.resolveDeclaredSymbol(typeSymbol, enclosingDecl, context); + } + if (containerSymbol && !containerSymbol.isResolved) { + this.resolveDeclaredSymbol(containerSymbol, enclosingDecl, context); + } + + return this.semanticInfoChain.voidTypeSymbol; + }; + + PullTypeResolver.prototype.resolveFunctionTypeSignature = function (funcDeclAST, enclosingDecl, context) { + var funcDeclSymbol = null; + + var functionDecl = this.getDeclForAST(funcDeclAST); + + if (!functionDecl) { + var semanticInfo = this.semanticInfoChain.getUnit(this.unitPath); + var declCollectionContext = new TypeScript.DeclCollectionContext(semanticInfo, this.unitPath); + + if (enclosingDecl) { + declCollectionContext.pushParent(enclosingDecl); + } + + TypeScript.getAstWalkerFactory().walk(funcDeclAST, TypeScript.preCollectDecls, TypeScript.postCollectDecls, null, declCollectionContext); + + functionDecl = this.getDeclForAST(funcDeclAST); + this.currentUnit.addSynthesizedDecl(functionDecl); + } + + if (!functionDecl.hasSymbol()) { + var binder = new TypeScript.PullSymbolBinder(this.semanticInfoChain); + binder.setUnit(this.unitPath); + if (functionDecl.kind === 33554432 /* ConstructorType */) { + binder.bindConstructorTypeDeclarationToPullSymbol(functionDecl); + } else { + binder.bindFunctionTypeDeclarationToPullSymbol(functionDecl); + } + } + + funcDeclSymbol = functionDecl.getSymbol(); + + var signature = funcDeclSymbol.kind === 33554432 /* ConstructorType */ ? funcDeclSymbol.getConstructSignatures()[0] : funcDeclSymbol.getCallSignatures()[0]; + + if (funcDeclAST.returnTypeAnnotation) { + var returnTypeSymbol = this.resolveTypeReference(funcDeclAST.returnTypeAnnotation, functionDecl, context); + + signature.returnType = returnTypeSymbol; + + if (this.isTypeArgumentOrWrapper(returnTypeSymbol)) { + signature.hasAGenericParameter = true; + + if (funcDeclSymbol) { + funcDeclSymbol.type.setHasGenericSignature(); + } + } + } + + if (funcDeclAST.arguments) { + for (var i = 0; i < funcDeclAST.arguments.members.length; i++) { + this.resolveFunctionTypeSignatureParameter(funcDeclAST.arguments.members[i], signature, functionDecl, context); + } + } + + if (funcDeclSymbol && signature.hasAGenericParameter) { + funcDeclSymbol.type.setHasGenericSignature(); + } + + if (signature.hasAGenericParameter) { + if (funcDeclSymbol) { + funcDeclSymbol.type.setHasGenericSignature(); + } + } + + funcDeclSymbol.setResolved(); + + if (context.typeCheck()) { + this.typeCheckFunctionOverloads(funcDeclAST, context); + } + + return funcDeclSymbol; + }; + + PullTypeResolver.prototype.resolveFunctionTypeSignatureParameter = function (argDeclAST, signature, enclosingDecl, context) { + var paramDecl = this.getDeclForAST(argDeclAST); + var paramSymbol = paramDecl.getSymbol(); + + if (argDeclAST.typeExpr) { + var typeRef = this.resolveTypeReference(argDeclAST.typeExpr, enclosingDecl, context); + + if (paramSymbol.isVarArg && !(typeRef.isArray() || typeRef == this.cachedArrayInterfaceType())) { + var diagnostic = context.postError(this.unitPath, argDeclAST.minChar, argDeclAST.getLength(), TypeScript.DiagnosticCode.Rest_parameters_must_be_array_types, null, enclosingDecl); + typeRef = this.getNewErrorTypeSymbol(diagnostic); + } + + context.setTypeInContext(paramSymbol, typeRef); + + if (this.isTypeArgumentOrWrapper(typeRef)) { + signature.hasAGenericParameter = true; + } + } else { + if (paramSymbol.isVarArg && paramSymbol.type) { + if (this.cachedArrayInterfaceType()) { + context.setTypeInContext(paramSymbol, TypeScript.specializeType(this.cachedArrayInterfaceType(), [paramSymbol.type], this, this.cachedArrayInterfaceType().getDeclarations()[0], context)); + } else { + context.setTypeInContext(paramSymbol, paramSymbol.type); + } + } else { + context.setTypeInContext(paramSymbol, this.semanticInfoChain.anyTypeSymbol); + + if (this.compilationSettings.noImplicitAny && !context.isInInvocationExpression) { + context.postError(this.unitPath, argDeclAST.minChar, argDeclAST.getLength(), TypeScript.DiagnosticCode.Parameter_0_of_function_type_implicitly_has_an_any_type, [argDeclAST.id.actualText], enclosingDecl); + } + } + } + + paramSymbol.setResolved(); + }; + + PullTypeResolver.prototype.resolveFunctionExpressionParameter = function (argDeclAST, contextParam, enclosingDecl, context) { + var paramDecl = this.getDeclForAST(argDeclAST); + var paramSymbol = paramDecl.getSymbol(); + + if (argDeclAST.typeExpr) { + var typeRef = this.resolveTypeReference(argDeclAST.typeExpr, enclosingDecl, context); + + if (paramSymbol.isVarArg && !(typeRef.isArray() || typeRef == this.cachedArrayInterfaceType())) { + var diagnostic = context.postError(this.unitPath, argDeclAST.minChar, argDeclAST.getLength(), TypeScript.DiagnosticCode.Rest_parameters_must_be_array_types, null, enclosingDecl); + typeRef = this.getNewErrorTypeSymbol(diagnostic); + } + + context.setTypeInContext(paramSymbol, typeRef); + } else { + if (contextParam) { + context.setTypeInContext(paramSymbol, contextParam.type); + } else { + if (paramSymbol.isVarArg && this.cachedArrayInterfaceType()) { + context.setTypeInContext(paramSymbol, TypeScript.specializeType(this.cachedArrayInterfaceType(), [this.semanticInfoChain.anyTypeSymbol], this, this.cachedArrayInterfaceType().getDeclarations()[0], context)); + } else { + context.setTypeInContext(paramSymbol, this.semanticInfoChain.anyTypeSymbol); + } + + if (this.compilationSettings.noImplicitAny && !context.isInInvocationExpression) { + var functionExpressionName = (paramDecl.getParentDecl()).getFunctionExpressionName(); + if (functionExpressionName != "") { + context.postError(this.unitPath, argDeclAST.minChar, argDeclAST.getLength(), TypeScript.DiagnosticCode.Parameter_0_of_1_implicitly_has_an_any_type, [argDeclAST.id.actualText, functionExpressionName], enclosingDecl, true); + } else { + context.postError(this.unitPath, argDeclAST.minChar, argDeclAST.getLength(), TypeScript.DiagnosticCode.Parameter_0_of_lambda_function_implicitly_has_an_any_type, [argDeclAST.id.actualText], enclosingDecl, true); + } + } + } + } + + paramSymbol.setResolved(); + }; + + PullTypeResolver.prototype.resolveInterfaceTypeReference = function (interfaceDeclAST, enclosingDecl, context) { + var interfaceSymbol = null; + + var interfaceDecl = this.getDeclForAST(interfaceDeclAST); + + if (!interfaceDecl) { + var semanticInfo = this.semanticInfoChain.getUnit(this.unitPath); + var declCollectionContext = new TypeScript.DeclCollectionContext(semanticInfo, this.unitPath); + + if (enclosingDecl) { + declCollectionContext.pushParent(enclosingDecl); + } + + TypeScript.getAstWalkerFactory().walk(interfaceDeclAST, TypeScript.preCollectDecls, TypeScript.postCollectDecls, null, declCollectionContext); + + var interfaceDecl = this.getDeclForAST(interfaceDeclAST); + this.currentUnit.addSynthesizedDecl(interfaceDecl); + + var binder = new TypeScript.PullSymbolBinder(this.semanticInfoChain); + + binder.setUnit(this.unitPath); + binder.bindObjectTypeDeclarationToPullSymbol(interfaceDecl); + } + + interfaceSymbol = interfaceDecl.getSymbol(); + + if (interfaceDeclAST.members) { + var memberDecl = null; + var memberSymbol = null; + var memberType = null; + var typeMembers = interfaceDeclAST.members; + + for (var i = 0; i < typeMembers.members.length; i++) { + memberDecl = this.getDeclForAST(typeMembers.members[i]); + memberSymbol = (memberDecl.kind & TypeScript.PullElementKind.SomeSignature) ? memberDecl.getSignatureSymbol() : memberDecl.getSymbol(); + + this.resolveDeclaredSymbol(memberSymbol, enclosingDecl, context); + + memberType = memberSymbol.type; + + if ((memberType && memberType.isGeneric()) || (memberSymbol.isSignature() && (memberSymbol).isGeneric())) { + interfaceSymbol.setHasGenericMember(); + } + } + } + + interfaceSymbol.setResolved(); + + if (context.typeCheck()) { + if (!interfaceSymbol.hasBaseTypeConflict()) { + this.typeCheckMembersAgainstIndexer(interfaceSymbol, interfaceDecl, context); + } + } + + return interfaceSymbol; + }; + + PullTypeResolver.prototype.resolveTypeReference = function (typeRef, enclosingDecl, context) { + if (typeRef === null) { + return null; + } + + var type = this.getSymbolForAST(typeRef); + var aliasType = null; + if (!type) { + type = this.computeTypeReferenceSymbol(typeRef, enclosingDecl, context); + + if (type.kind == 4 /* Container */) { + var containerType = type; + var instanceSymbol = containerType.getInstanceSymbol(); + + if (instanceSymbol && (instanceSymbol.hasFlag(16384 /* ClassConstructorVariable */) || instanceSymbol.kind == 32768 /* ConstructorMethod */)) { + type = instanceSymbol.type.getAssociatedContainerType(); + } + } + + if (type && type.isAlias()) { + aliasType = type; + type = aliasType.getExportAssignedTypeSymbol(); + } + + if (type && !type.isGeneric()) { + this.setSymbolForAST(typeRef, type, context); + if (aliasType) { + this.currentUnit.setAliasSymbolForAST(typeRef, aliasType); + } + } + } + + if (type && !type.isError()) { + if ((type.kind & TypeScript.PullElementKind.SomeType) === 0) { + if (type.kind & TypeScript.PullElementKind.SomeContainer) { + context.postError(this.unitPath, typeRef.minChar, typeRef.getLength(), TypeScript.DiagnosticCode.Type_reference_cannot_refer_to_container_0, [aliasType ? aliasType.toString() : type.toString()], enclosingDecl); + } else { + context.postError(this.unitPath, typeRef.minChar, typeRef.getLength(), TypeScript.DiagnosticCode.Type_reference_must_refer_to_type, null, enclosingDecl); + } + } + } + + return type; + }; + + PullTypeResolver.prototype.computeTypeReferenceSymbol = function (typeRef, enclosingDecl, context) { + var typeDeclSymbol = null; + var diagnostic = null; + var typeSymbol = null; + + if (typeRef.term.nodeType() === 21 /* Name */) { + var prevResolvingTypeReference = context.resolvingTypeReference; + context.resolvingTypeReference = true; + typeSymbol = this.resolveTypeNameExpression(typeRef.term, enclosingDecl, context); + typeDeclSymbol = typeSymbol; + + context.resolvingTypeReference = prevResolvingTypeReference; + } else if (typeRef.term.nodeType() === 13 /* FunctionDeclaration */) { + typeDeclSymbol = this.resolveFunctionTypeSignature(typeRef.term, enclosingDecl, context); + } else if (typeRef.term.nodeType() === 15 /* InterfaceDeclaration */) { + typeDeclSymbol = this.resolveInterfaceTypeReference(typeRef.term, enclosingDecl, context); + } else if (typeRef.term.nodeType() === 10 /* GenericType */) { + typeSymbol = this.resolveGenericTypeReference(typeRef.term, enclosingDecl, context); + typeDeclSymbol = typeSymbol; + } else if (typeRef.term.nodeType() === 33 /* MemberAccessExpression */) { + var dottedName = typeRef.term; + + prevResolvingTypeReference = context.resolvingTypeReference; + typeSymbol = this.resolveDottedTypeNameExpression(dottedName, enclosingDecl, context); + typeDeclSymbol = typeSymbol; + context.resolvingTypeReference = prevResolvingTypeReference; + } else if (typeRef.term.nodeType() === 5 /* StringLiteral */) { + var stringConstantAST = typeRef.term; + typeDeclSymbol = new TypeScript.PullStringConstantTypeSymbol(stringConstantAST.actualText); + var decl = new TypeScript.PullDecl(stringConstantAST.actualText, stringConstantAST.actualText, typeDeclSymbol.kind, null, new TypeScript.TextSpan(stringConstantAST.minChar, stringConstantAST.getLength()), enclosingDecl.getScriptName()); + this.currentUnit.addSynthesizedDecl(decl); + typeDeclSymbol.addDeclaration(decl); + } else if (typeRef.term.nodeType() === 12 /* TypeQuery */) { + var typeQuery = typeRef.term; + + var typeQueryTerm = typeQuery.name; + if (typeQueryTerm.nodeType() === 11 /* TypeRef */) { + typeQueryTerm = (typeQueryTerm).term; + } + + var savedResolvingTypeReference = context.resolvingTypeReference; + context.resolvingTypeReference = false; + var valueSymbol = this.resolveAST(typeQueryTerm, false, enclosingDecl, context); + context.resolvingTypeReference = savedResolvingTypeReference; + + if (valueSymbol && valueSymbol.isAlias()) { + if ((valueSymbol).assignedValue) { + valueSymbol = (valueSymbol).assignedValue; + } else { + var containerSymbol = (valueSymbol).getExportAssignedContainerSymbol(); + valueSymbol = (containerSymbol && containerSymbol.isContainer() && !containerSymbol.isEnum()) ? containerSymbol.getInstanceSymbol() : null; + } + } + + if (valueSymbol) { + typeDeclSymbol = valueSymbol.type; + } else { + typeDeclSymbol = this.getNewErrorTypeSymbol(null); + } + } + + if (!typeDeclSymbol) { + context.postError(this.unitPath, typeRef.term.minChar, typeRef.term.getLength(), TypeScript.DiagnosticCode.Unable_to_resolve_type, null, enclosingDecl); + return this.getNewErrorTypeSymbol(null); + } + + if (typeDeclSymbol.isError()) { + return typeDeclSymbol; + } + + if (typeRef.arrayCount) { + var arraySymbol = typeDeclSymbol.getArrayType(); + + if (!arraySymbol) { + if (!this.cachedArrayInterfaceType().isResolved) { + this.resolveDeclaredSymbol(this.cachedArrayInterfaceType(), enclosingDecl, context); + } + + if (this.genericTypeIsUsedWithoutRequiredTypeArguments(typeDeclSymbol, typeRef, context)) { + context.postError(this.unitPath, typeRef.minChar, typeRef.getLength(), TypeScript.DiagnosticCode.Generic_type_references_must_include_all_type_arguments, null, enclosingDecl); + typeDeclSymbol = this.specializeTypeToAny(typeDeclSymbol, enclosingDecl, context); + } + + arraySymbol = TypeScript.specializeType(this.cachedArrayInterfaceType(), [typeDeclSymbol], this, this.cachedArrayInterfaceType().getDeclarations()[0], context, typeRef); + + if (!arraySymbol) { + arraySymbol = this.semanticInfoChain.anyTypeSymbol; + } + } + + if (typeRef.arrayCount > 1) { + for (var arity = typeRef.arrayCount - 1; arity > 0; arity--) { + var existingArraySymbol = arraySymbol.getArrayType(); + + if (!existingArraySymbol) { + arraySymbol = TypeScript.specializeType(this.cachedArrayInterfaceType(), [arraySymbol], this, this.cachedArrayInterfaceType().getDeclarations()[0], context, typeRef); + } else { + arraySymbol = existingArraySymbol; + } + } + } + + typeDeclSymbol = arraySymbol; + } + + return typeDeclSymbol; + }; + + PullTypeResolver.prototype.genericTypeIsUsedWithoutRequiredTypeArguments = function (typeSymbol, typeReference, context) { + return typeSymbol.isNamedTypeSymbol() && typeSymbol.isGeneric() && !typeSymbol.isTypeParameter() && (typeSymbol.isResolved || (typeSymbol.inResolution && !context.inSpecialization)) && !typeSymbol.getIsSpecialized() && typeSymbol.getTypeParameters().length && (typeSymbol.getTypeArguments() == null && !this.isArrayOrEquivalent(typeSymbol)) && this.isTypeRefWithoutTypeArgs(typeReference); + }; + + PullTypeResolver.prototype.resolveVariableDeclaration = function (varDecl, context, enclosingDecl) { + var _this = this; + var decl = this.getDeclForAST(varDecl); + + if (enclosingDecl && decl.kind == 2048 /* Parameter */) { + enclosingDecl.ensureSymbolIsBound(); + } + + var declSymbol = decl.getSymbol(); + var declParameterSymbol = decl.getValueDecl() ? decl.getValueDecl().getSymbol() : null; + + if (declSymbol.isResolved) { + var declType = declSymbol.type; + var valDecl = decl.getValueDecl(); + + if (valDecl) { + var valSymbol = valDecl.getSymbol(); + + if (valSymbol && !valSymbol.isResolved) { + valSymbol.type = declType; + valSymbol.setResolved(); + } + } + return declSymbol; + } + + if (declSymbol.inResolution) { + if (!context.inSpecialization) { + declSymbol.type = this.semanticInfoChain.anyTypeSymbol; + declSymbol.setResolved(); + return declSymbol; + } + } + + declSymbol.startResolving(); + + var wrapperDecl = this.getEnclosingDecl(decl); + wrapperDecl = wrapperDecl ? wrapperDecl : enclosingDecl; + + var typeExprSymbol = null; + var initExprSymbol = null; + var initTypeSymbol = null; + var inConstructorArgumentList = context.inConstructorArguments; + context.inConstructorArguments = false; + + if (varDecl.typeExpr) { + typeExprSymbol = this.resolveTypeReference(varDecl.typeExpr, wrapperDecl, context); + + if (!typeExprSymbol) { + diagnostic = context.postError(this.unitPath, varDecl.minChar, varDecl.getLength(), TypeScript.DiagnosticCode.Unable_to_resolve_type_of_0, [varDecl.id.actualText], decl); + declSymbol.type = this.getNewErrorTypeSymbol(diagnostic); + + if (declParameterSymbol) { + context.setTypeInContext(declParameterSymbol, this.semanticInfoChain.anyTypeSymbol); + } + } else if (typeExprSymbol.isError()) { + context.setTypeInContext(declSymbol, typeExprSymbol); + if (declParameterSymbol) { + context.setTypeInContext(declParameterSymbol, typeExprSymbol); + } + } else { + if (typeExprSymbol == this.semanticInfoChain.anyTypeSymbol) { + decl.setFlag(16777216 /* IsAnnotatedWithAny */); + } + + if (this.genericTypeIsUsedWithoutRequiredTypeArguments(typeExprSymbol, varDecl.typeExpr, context)) { + context.postError(this.unitPath, varDecl.typeExpr.minChar, varDecl.typeExpr.getLength(), TypeScript.DiagnosticCode.Generic_type_references_must_include_all_type_arguments, null, enclosingDecl); + + typeExprSymbol = this.specializeTypeToAny(typeExprSymbol, enclosingDecl, context); + } + + if (typeExprSymbol.isContainer()) { + var exportedTypeSymbol = (typeExprSymbol).getExportAssignedTypeSymbol(); + + if (exportedTypeSymbol) { + typeExprSymbol = exportedTypeSymbol; + } else { + typeExprSymbol = typeExprSymbol.type; + + if (typeExprSymbol.isAlias()) { + typeExprSymbol = (typeExprSymbol).getExportAssignedTypeSymbol(); + } + + if (typeExprSymbol && typeExprSymbol.isContainer() && !typeExprSymbol.isEnum()) { + var instanceSymbol = (typeExprSymbol).getInstanceSymbol(); + + if (!instanceSymbol || !TypeScript.PullHelpers.symbolIsEnum(instanceSymbol)) { + typeExprSymbol = this.getNewErrorTypeSymbol(diagnostic); + } else { + typeExprSymbol = instanceSymbol.type; + } + } + } + } else if (declSymbol.isVarArg && !(typeExprSymbol.isArray() || typeExprSymbol == this.cachedArrayInterfaceType())) { + var diagnostic = context.postError(this.unitPath, varDecl.minChar, varDecl.getLength(), TypeScript.DiagnosticCode.Rest_parameters_must_be_array_types, null, enclosingDecl); + typeExprSymbol = this.getNewErrorTypeSymbol(diagnostic); + } + + context.setTypeInContext(declSymbol, typeExprSymbol); + + if (declParameterSymbol) { + declParameterSymbol.type = typeExprSymbol; + } + + if (typeExprSymbol.kind == 16777216 /* FunctionType */) { + typeExprSymbol.setFunctionSymbol(declSymbol); + } + + if ((varDecl.nodeType() === 20 /* Parameter */) && enclosingDecl && ((typeExprSymbol.isGeneric() && !typeExprSymbol.isArray()) || this.isTypeArgumentOrWrapper(typeExprSymbol))) { + var signature = enclosingDecl.getSpecializingSignatureSymbol(); + + if (signature) { + signature.hasAGenericParameter = true; + } + } + } + } + + if (varDecl.init && (context.typeCheck() || !varDecl.typeExpr)) { + if (typeExprSymbol) { + context.pushContextualType(typeExprSymbol, context.inProvisionalResolution(), null); + } + + if (inConstructorArgumentList) { + context.inConstructorArguments = inConstructorArgumentList; + } + + context.isInStaticInitializer = (decl.flags & 16 /* Static */) != 0; + initExprSymbol = this.resolveAST(varDecl.init, typeExprSymbol != null, wrapperDecl, context); + context.isInStaticInitializer = false; + + context.inConstructorArguments = false; + + if (typeExprSymbol) { + context.popContextualType(); + } + + if (!initExprSymbol) { + diagnostic = context.postError(this.unitPath, varDecl.minChar, varDecl.getLength(), TypeScript.DiagnosticCode.Unable_to_resolve_type_of_0, [varDecl.id.actualText], decl); + + if (!varDecl.typeExpr) { + context.setTypeInContext(declSymbol, this.getNewErrorTypeSymbol(diagnostic)); + + if (declParameterSymbol) { + context.setTypeInContext(declParameterSymbol, this.semanticInfoChain.anyTypeSymbol); + } + } + } else { + initTypeSymbol = initExprSymbol.type; + + if (!varDecl.typeExpr) { + context.setTypeInContext(declSymbol, this.widenType(initTypeSymbol)); + + if (declParameterSymbol) { + context.setTypeInContext(declParameterSymbol, initTypeSymbol); + } + + if (this.compilationSettings.noImplicitAny) { + if ((declSymbol.type != initTypeSymbol) && (declSymbol.type == this.semanticInfoChain.anyTypeSymbol)) { + context.postError(this.unitPath, varDecl.minChar, varDecl.getLength(), TypeScript.DiagnosticCode.Variable_0_implicitly_has_an_any_type, [varDecl.id.actualText], enclosingDecl); + } + } + } + } + } + + if (!(varDecl.typeExpr || varDecl.init)) { + var defaultType = this.semanticInfoChain.anyTypeSymbol; + + if (this.compilationSettings.noImplicitAny && ((varDecl.getVarFlags() & 16384 /* ForInVariable */) === 0)) { + if (wrapperDecl.kind == 16384 /* Function */ || wrapperDecl.kind == 65536 /* Method */ || wrapperDecl.kind == 32768 /* ConstructorMethod */ || wrapperDecl.kind == 2097152 /* ConstructSignature */) { + context.postError(this.unitPath, varDecl.minChar, varDecl.getLength(), TypeScript.DiagnosticCode.Parameter_0_of_1_implicitly_has_an_any_type, [varDecl.id.actualText, enclosingDecl.name], enclosingDecl); + } else if (wrapperDecl.kind == 8388608 /* ObjectType */) { + context.postError(this.unitPath, varDecl.minChar, varDecl.getLength(), TypeScript.DiagnosticCode.Member_0_of_object_type_implicitly_has_an_any_type, [varDecl.id.actualText], enclosingDecl); + } else if (wrapperDecl.kind != 1073741824 /* CatchBlock */) { + context.postError(this.unitPath, varDecl.minChar, varDecl.getLength(), TypeScript.DiagnosticCode.Variable_0_implicitly_has_an_any_type, [varDecl.id.actualText], enclosingDecl); + } + } + + if (declSymbol.isVarArg) { + defaultType = TypeScript.specializeType(this.cachedArrayInterfaceType(), [defaultType], this, this.cachedArrayInterfaceType().getDeclarations()[0], context); + } + + context.setTypeInContext(declSymbol, defaultType); + + if (declParameterSymbol) { + declParameterSymbol.type = defaultType; + } + } else if (context.typeCheck()) { + if (typeExprSymbol && typeExprSymbol.isAlias()) { + typeExprSymbol = (typeExprSymbol).getExportAssignedTypeSymbol(); + } + + if (typeExprSymbol && typeExprSymbol.isContainer()) { + var exportedTypeSymbol = (typeExprSymbol).getExportAssignedTypeSymbol(); + + if (exportedTypeSymbol) { + typeExprSymbol = exportedTypeSymbol; + } else { + var instanceTypeSymbol = (typeExprSymbol).getInstanceType(); + + if (!instanceTypeSymbol || !TypeScript.PullHelpers.symbolIsEnum(instanceTypeSymbol)) { + context.postError(this.unitPath, varDecl.minChar, varDecl.getLength(), TypeScript.DiagnosticCode.Tried_to_set_variable_type_to_uninitialized_module_type_0, [typeExprSymbol.toString()], enclosingDecl); + typeExprSymbol = null; + } else { + typeExprSymbol = instanceTypeSymbol; + } + } + } + + initTypeSymbol = this.getInstanceTypeForAssignment(varDecl, initTypeSymbol, enclosingDecl, context); + + if (initTypeSymbol && typeExprSymbol) { + var comparisonInfo = new TypeComparisonInfo(); + + var isAssignable = this.sourceIsAssignableToTarget(initTypeSymbol, typeExprSymbol, context, comparisonInfo); + + if (!isAssignable) { + if (comparisonInfo.message) { + context.postError(this.unitPath, varDecl.minChar, varDecl.getLength(), TypeScript.DiagnosticCode.Cannot_convert_0_to_1_NL_2, [initTypeSymbol.toString(), typeExprSymbol.toString(), comparisonInfo.message], enclosingDecl); + } else { + context.postError(this.unitPath, varDecl.minChar, varDecl.getLength(), TypeScript.DiagnosticCode.Cannot_convert_0_to_1, [initTypeSymbol.toString(), typeExprSymbol.toString()], enclosingDecl); + } + } + } + } + + declSymbol.setResolved(); + + if (declParameterSymbol) { + declParameterSymbol.setResolved(); + } + + if (context.typeCheck()) { + if (varDecl.init && varDecl.nodeType() === 20 /* Parameter */) { + var containerSignature = enclosingDecl.getSignatureSymbol(); + if (containerSignature && !containerSignature.isDefinition()) { + context.postError(this.unitPath, varDecl.minChar, varDecl.getLength(), TypeScript.DiagnosticCode.Default_arguments_are_not_allowed_in_an_overload_parameter, [], enclosingDecl); + } + } + if (declSymbol.kind != 2048 /* Parameter */ && (declSymbol.kind != 4096 /* Property */ || declSymbol.getContainer().isNamedTypeSymbol())) { + this.checkSymbolPrivacy(declSymbol, declSymbol.type, context, function (symbol) { + return _this.variablePrivacyErrorReporter(declSymbol, symbol, context); + }); + } + } + + context.inConstructorArguments = inConstructorArgumentList; + + return declSymbol; + }; + + PullTypeResolver.prototype.resolveTypeParameterDeclaration = function (typeParameterAST, context) { + var typeParameterDecl = this.getDeclForAST(typeParameterAST); + var typeParameterSymbol = typeParameterDecl.getSymbol(); + + if (typeParameterSymbol.isResolved || typeParameterSymbol.inResolution) { + return typeParameterSymbol; + } + + typeParameterSymbol.startResolving(); + + if (typeParameterAST.constraint) { + var enclosingDecl = this.getEnclosingDecl(typeParameterDecl); + var constraintTypeSymbol = this.resolveTypeReference(typeParameterAST.constraint, enclosingDecl, context); + + if (constraintTypeSymbol && constraintTypeSymbol.isPrimitive() && !constraintTypeSymbol.isError()) { + context.postError(this.unitPath, typeParameterAST.minChar, typeParameterAST.getLength(), TypeScript.DiagnosticCode.Type_parameter_constraint_cannot_be_a_primitive_type, null, enclosingDecl); + constraintTypeSymbol = this.specializeTypeToAny(constraintTypeSymbol, enclosingDecl, context); + } else if (this.genericTypeIsUsedWithoutRequiredTypeArguments(constraintTypeSymbol, typeParameterAST.constraint, context)) { + context.postError(this.unitPath, typeParameterAST.constraint.minChar, typeParameterAST.constraint.getLength(), TypeScript.DiagnosticCode.Generic_type_references_must_include_all_type_arguments, null, enclosingDecl); + constraintTypeSymbol = this.specializeTypeToAny(constraintTypeSymbol, enclosingDecl, context); + } + + if (constraintTypeSymbol) { + typeParameterSymbol.setConstraint(constraintTypeSymbol); + } + } + + typeParameterSymbol.setResolved(); + + return typeParameterSymbol; + }; + + PullTypeResolver.prototype.resolveFunctionBodyReturnTypes = function (funcDeclAST, signature, useContextualType, enclosingDecl, context) { + var _this = this; + var returnStatements = []; + + var enclosingDeclStack = [enclosingDecl]; + + var preFindReturnExpressionTypes = function (ast, parent, walker) { + var go = true; + + switch (ast.nodeType()) { + case 13 /* FunctionDeclaration */: + go = false; + break; + + case 94 /* ReturnStatement */: + var returnStatement = ast; + enclosingDecl.setFlag(4194304 /* HasReturnStatement */); + returnStatements[returnStatements.length] = { returnStatement: returnStatement, enclosingDecl: enclosingDeclStack[enclosingDeclStack.length - 1] }; + go = false; + break; + + case 102 /* CatchClause */: + case 100 /* WithStatement */: + enclosingDeclStack[enclosingDeclStack.length] = _this.getDeclForAST(ast); + break; + + default: + break; + } + + walker.options.goChildren = go; + + return ast; + }; + + var postFindReturnExpressionEnclosingDecls = function (ast, parent, walker) { + switch (ast.nodeType()) { + case 102 /* CatchClause */: + case 100 /* WithStatement */: + enclosingDeclStack.length--; + break; + default: + break; + } + + walker.options.goChildren = true; + + return ast; + }; + + TypeScript.getAstWalkerFactory().walk(funcDeclAST.block, preFindReturnExpressionTypes, postFindReturnExpressionEnclosingDecls); + + if (!returnStatements.length) { + signature.returnType = this.semanticInfoChain.voidTypeSymbol; + } else { + var returnExpressionSymbols = []; + var returnType; + + for (var i = 0; i < returnStatements.length; i++) { + if (returnStatements[i].returnStatement.returnExpression) { + returnType = this.resolveAST(returnStatements[i].returnStatement.returnExpression, useContextualType, returnStatements[i].enclosingDecl, context).type; + + if (returnType.isError()) { + signature.returnType = returnType; + return; + } else { + this.setSymbolForAST(returnStatements[i].returnStatement, returnType, context); + } + + returnExpressionSymbols[returnExpressionSymbols.length] = returnType; + } + } + + if (!returnExpressionSymbols.length) { + signature.returnType = this.semanticInfoChain.voidTypeSymbol; + } else { + var collection = { + getLength: function () { + return returnExpressionSymbols.length; + }, + setTypeAtIndex: function (index, type) { + }, + getTypeAtIndex: function (index) { + return returnExpressionSymbols[index].type; + } + }; + + returnType = this.findBestCommonType(returnExpressionSymbols[0], null, collection, context, new TypeComparisonInfo()); + + if (useContextualType && returnType == this.semanticInfoChain.anyTypeSymbol) { + var contextualType = context.getContextualType(); + + if (contextualType) { + returnType = contextualType; + } + } + + var functionDecl = this.getDeclForAST(funcDeclAST); + var functionSymbol = functionDecl.getSymbol(); + + if (returnType) { + var previousReturnType = returnType; + var newReturnType = this.widenType(returnType); + signature.returnType = newReturnType; + + if (this.compilationSettings.noImplicitAny) { + if (previousReturnType !== newReturnType && newReturnType === this.semanticInfoChain.anyTypeSymbol) { + var functionName = enclosingDecl.name; + if (functionName == "") { + functionName = (enclosingDecl).getFunctionExpressionName(); + } + + if (functionName != "") { + context.postError(this.unitPath, funcDeclAST.minChar, funcDeclAST.getLength(), TypeScript.DiagnosticCode._0_which_lacks_return_type_annotation_implicitly_has_an_any_return_type, [functionName], enclosingDecl); + } else { + context.postError(this.unitPath, funcDeclAST.minChar, funcDeclAST.getLength(), TypeScript.DiagnosticCode.Function_expression_which_lacks_return_type_annotation_implicitly_has_an_any_return_type, [], enclosingDecl); + } + } + } + } + + if (this.isTypeArgumentOrWrapper(returnType) && functionSymbol) { + functionSymbol.type.setHasGenericSignature(); + } + } + } + }; + + PullTypeResolver.prototype.resolveFunctionDeclaration = function (funcDeclAST, context) { + var _this = this; + var funcDecl = this.getDeclForAST(funcDeclAST); + + var funcSymbol = funcDecl.getSymbol(); + + var signature = funcDecl.getSpecializingSignatureSymbol(); + + var hadError = false; + + var isConstructor = funcDeclAST.isConstructor || TypeScript.hasFlag(funcDeclAST.getFunctionFlags(), 1024 /* ConstructMember */); + + if (signature) { + if (signature.isResolved) { + return funcSymbol; + } + + if (isConstructor && !signature.inResolution) { + var classAST = funcDeclAST.classDecl; + + if (classAST) { + var classDecl = this.getDeclForAST(classAST); + var classSymbol = classDecl.getSymbol(); + + if (!classSymbol.isResolved && !classSymbol.inResolution) { + this.resolveDeclaredSymbol(classSymbol, this.getEnclosingDecl(classDecl), context); + } + } + } + + var diagnostic; + + var functionTypeSymbol = funcSymbol && funcSymbol.type; + + if (signature.inResolution) { + if (funcDeclAST.returnTypeAnnotation) { + var returnTypeSymbol = this.resolveTypeReference(funcDeclAST.returnTypeAnnotation, funcDecl, context); + if (!returnTypeSymbol) { + diagnostic = context.postError(this.unitPath, funcDeclAST.returnTypeAnnotation.minChar, funcDeclAST.returnTypeAnnotation.getLength(), TypeScript.DiagnosticCode.Cannot_resolve_return_type_reference, null, funcDecl); + signature.returnType = this.getNewErrorTypeSymbol(diagnostic); + hadError = true; + } else { + if (this.isTypeArgumentOrWrapper(returnTypeSymbol)) { + signature.hasAGenericParameter = true; + if (funcSymbol) { + funcSymbol.type.setHasGenericSignature(); + } + } + signature.returnType = returnTypeSymbol; + + if (isConstructor && returnTypeSymbol === this.semanticInfoChain.voidTypeSymbol) { + context.postError(this.unitPath, funcDeclAST.minChar, funcDeclAST.getLength(), TypeScript.DiagnosticCode.Constructors_cannot_have_a_return_type_of_void, null, funcDecl); + } + } + } else { + signature.returnType = this.semanticInfoChain.anyTypeSymbol; + } + + if (funcSymbol) { + funcSymbol.setUnresolved(); + if (funcSymbol.type === this.semanticInfoChain.anyTypeSymbol) { + funcSymbol.type = functionTypeSymbol; + } + } + signature.setResolved(); + return funcSymbol; + } + + if (funcSymbol) { + funcSymbol.startResolving(); + } + signature.startResolving(); + + if (funcDeclAST.typeArguments) { + for (var i = 0; i < funcDeclAST.typeArguments.members.length; i++) { + this.resolveTypeParameterDeclaration(funcDeclAST.typeArguments.members[i], context); + } + } + + if (funcDeclAST.arguments) { + var prevInConstructorArguments = context.inConstructorArguments; + context.inConstructorArguments = isConstructor; + for (var i = 0; i < funcDeclAST.arguments.members.length; i++) { + this.resolveVariableDeclaration(funcDeclAST.arguments.members[i], context, funcDecl); + } + context.inConstructorArguments = prevInConstructorArguments; + } + + if (signature.isGeneric()) { + if (funcSymbol) { + funcSymbol.type.setHasGenericSignature(); + } + } + + if (funcDeclAST.returnTypeAnnotation) { + var prevReturnTypeSymbol = signature.returnType; + + returnTypeSymbol = this.resolveTypeReference(funcDeclAST.returnTypeAnnotation, funcDecl, context); + + if (!returnTypeSymbol) { + diagnostic = context.postError(this.unitPath, funcDeclAST.returnTypeAnnotation.minChar, funcDeclAST.returnTypeAnnotation.getLength(), TypeScript.DiagnosticCode.Cannot_resolve_return_type_reference, null, funcDecl); + signature.returnType = this.getNewErrorTypeSymbol(diagnostic); + + hadError = true; + } else if (!(this.isTypeArgumentOrWrapper(returnTypeSymbol) && prevReturnTypeSymbol && !this.isTypeArgumentOrWrapper(prevReturnTypeSymbol))) { + if (this.isTypeArgumentOrWrapper(returnTypeSymbol)) { + signature.hasAGenericParameter = true; + + if (funcSymbol) { + funcSymbol.type.setHasGenericSignature(); + } + } + + signature.returnType = returnTypeSymbol; + + if (isConstructor && returnTypeSymbol === this.semanticInfoChain.voidTypeSymbol) { + context.postError(this.unitPath, funcDeclAST.minChar, funcDeclAST.getLength(), TypeScript.DiagnosticCode.Constructors_cannot_have_a_return_type_of_void, null, funcDecl); + } + } + } else if (!funcDeclAST.isConstructor && !funcDeclAST.isConstructMember()) { + if (funcDeclAST.isSignature()) { + signature.returnType = this.semanticInfoChain.anyTypeSymbol; + + if (this.compilationSettings.noImplicitAny) { + var funcDeclASTName = funcDeclAST.name; + if (funcDeclASTName) { + context.postError(this.unitPath, funcDeclAST.minChar, funcDeclAST.getLength(), TypeScript.DiagnosticCode._0_which_lacks_return_type_annotation_implicitly_has_an_any_return_type, [funcDeclASTName.actualText], funcDecl); + } else { + context.postError(this.unitPath, funcDeclAST.minChar, funcDeclAST.getLength(), TypeScript.DiagnosticCode.Lambda_Function_which_lacks_return_type_annotation_implicitly_has_an_any_return_type, [], funcDecl); + } + } + } else { + this.resolveFunctionBodyReturnTypes(funcDeclAST, signature, false, funcDecl, context); + } + } else if (funcDeclAST.isConstructMember()) { + if (funcDeclAST.isSignature()) { + signature.returnType = this.semanticInfoChain.anyTypeSymbol; + + if (this.compilationSettings.noImplicitAny) { + context.postError(this.unitPath, funcDeclAST.minChar, funcDeclAST.getLength(), TypeScript.DiagnosticCode.Constructor_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type, [], funcDecl); + } + } + } + + if (!hadError) { + if (funcSymbol) { + funcSymbol.setUnresolved(); + if (funcSymbol.type === this.semanticInfoChain.anyTypeSymbol) { + funcSymbol.type = functionTypeSymbol; + } + } + signature.setResolved(); + } + } + + if (context.inTypeCheck && (!context.inSpecialization || !signature.isGeneric())) { + var prevSeenSuperConstructorCall = this.seenSuperConstructorCall; + + PullTypeResolver.typeCheckCallBacks.push(function () { + if (signature.hasBeenChecked) { + return; + } + + _this.setUnitPath(funcDecl.getScriptName()); + _this.seenSuperConstructorCall = false; + + _this.resolveAST(funcDeclAST.block, false, funcDecl, context); + + _this.validateVariableDeclarationGroups(funcDecl, context); + + var enclosingDecl = _this.getEnclosingDecl(funcDecl); + + var hasReturn = (funcDecl.flags & (2048 /* Signature */ | 4194304 /* HasReturnStatement */)) != 0; + + var parameters = signature.parameters; + + if (funcDeclAST.isConstructor || TypeScript.hasFlag(funcDeclAST.getFunctionFlags(), 1024 /* ConstructMember */)) { + if (funcDecl.getSignatureSymbol() && funcDecl.getSignatureSymbol().isDefinition() && _this.enclosingClassIsDerived(funcDecl)) { + if (!_this.seenSuperConstructorCall) { + context.postError(_this.unitPath, funcDeclAST.minChar, 11, TypeScript.DiagnosticCode.Constructors_for_derived_classes_must_contain_a_super_call, null, enclosingDecl); + } else if (_this.superCallMustBeFirstStatementInConstructor(funcDecl, enclosingDecl)) { + var firstStatement = _this.getFirstStatementFromFunctionDeclAST(funcDeclAST); + if (!firstStatement || !_this.isSuperCallNode(firstStatement)) { + context.postError(_this.unitPath, funcDeclAST.minChar, 11, TypeScript.DiagnosticCode.A_super_call_must_be_the_first_statement_in_the_constructor_when_a_class_contains_initialized_properties_or_has_parameter_properties, null, enclosingDecl); + } + } + } + _this.typeCheckFunctionOverloads(funcDeclAST, context); + } else if (TypeScript.hasFlag(funcDeclAST.getFunctionFlags(), 4096 /* IndexerMember */)) { + var allIndexSignatures = enclosingDecl.getSymbol().type.getIndexSignatures(); + + for (var i = 0; i < allIndexSignatures.length; i++) { + if (!allIndexSignatures[i].isResolved) { + _this.resolveDeclaredSymbol(allIndexSignatures[i], allIndexSignatures[i].getDeclarations()[0].getParentDecl(), context); + } + + if (allIndexSignatures[i].parameters[0].type !== parameters[0].type) { + var stringIndexSignature = null; + var numberIndexSignature = null; + + var indexSignature = signature; + + var isNumericIndexer = parameters[0].type === _this.semanticInfoChain.numberTypeSymbol; + + if (isNumericIndexer) { + numberIndexSignature = indexSignature; + stringIndexSignature = allIndexSignatures[i]; + } else { + numberIndexSignature = allIndexSignatures[i]; + stringIndexSignature = indexSignature; + + if (enclosingDecl.getSymbol() === numberIndexSignature.getDeclarations()[0].getParentDecl().getSymbol()) { + break; + } + } + var comparisonInfo = new TypeComparisonInfo(); + var resolutionContext = new TypeScript.PullTypeResolutionContext(); + if (!_this.sourceIsSubtypeOfTarget(numberIndexSignature.returnType, stringIndexSignature.returnType, resolutionContext, comparisonInfo)) { + if (comparisonInfo.message) { + context.postError(_this.unitPath, funcDeclAST.minChar, funcDeclAST.getLength(), TypeScript.DiagnosticCode.Numeric_indexer_type_0_must_be_a_subtype_of_string_indexer_type_1_NL_2, [numberIndexSignature.returnType.toString(), stringIndexSignature.returnType.toString(), comparisonInfo.message], enclosingDecl); + } else { + context.postError(_this.unitPath, funcDeclAST.minChar, funcDeclAST.getLength(), TypeScript.DiagnosticCode.Numeric_indexer_type_0_must_be_a_subtype_of_string_indexer_type_1, [numberIndexSignature.returnType.toString(), stringIndexSignature.returnType.toString()], enclosingDecl); + } + } + break; + } + } + + var allMembers = enclosingDecl.getSymbol().type.getAllMembers(TypeScript.PullElementKind.All, true); + for (var i = 0; i < allMembers.length; i++) { + var name = allMembers[i].name; + if (name) { + if (!allMembers[i].isResolved) { + _this.resolveDeclaredSymbol(allMembers[i], allMembers[i].getDeclarations()[0].getParentDecl(), context); + } + + if (enclosingDecl.getSymbol() !== allMembers[i].getContainer()) { + var isMemberNumeric = isFinite(+name); + if (isNumericIndexer === isMemberNumeric) { + _this.checkThatMemberIsSubtypeOfIndexer(allMembers[i], indexSignature, funcDeclAST, context, enclosingDecl, isNumericIndexer); + } + } + } + } + } else { + if (funcDeclAST.block && funcDeclAST.returnTypeAnnotation != null && !hasReturn) { + var isVoidOrAny = _this.isAnyOrEquivalent(returnTypeSymbol) || returnTypeSymbol === _this.semanticInfoChain.voidTypeSymbol; + + if (!isVoidOrAny && !(funcDeclAST.block.statements.members.length > 0 && funcDeclAST.block.statements.members[0].nodeType() === 96 /* ThrowStatement */)) { + var funcName = funcDecl.getDisplayName(); + funcName = funcName ? funcName : "expression"; + + context.postError(_this.unitPath, funcDeclAST.returnTypeAnnotation.minChar, funcDeclAST.returnTypeAnnotation.getLength(), TypeScript.DiagnosticCode.Function_0_declared_a_non_void_return_type_but_has_no_return_expression, [funcName], enclosingDecl); + } + } + _this.typeCheckFunctionOverloads(funcDeclAST, context); + } + + _this.checkFunctionTypePrivacy(funcDeclAST, false, context); + _this.seenSuperConstructorCall = prevSeenSuperConstructorCall; + + signature.hasBeenChecked = true; + }); + } + + return funcSymbol; + }; + + PullTypeResolver.prototype.resolveGetAccessorDeclaration = function (funcDeclAST, context) { + var funcDecl = this.getDeclForAST(funcDeclAST); + var accessorSymbol = funcDecl.getSymbol(); + + var getterSymbol = accessorSymbol.getGetter(); + var getterTypeSymbol = getterSymbol.type; + + var signature = getterTypeSymbol.getCallSignatures()[0]; + + var hadError = false; + var diagnostic; + + if (signature) { + if (signature.isResolved) { + return accessorSymbol; + } + + if (signature.inResolution) { + signature.returnType = this.semanticInfoChain.anyTypeSymbol; + signature.setResolved(); + + return accessorSymbol; + } + + signature.startResolving(); + + if (funcDeclAST.arguments) { + for (var i = 0; i < funcDeclAST.arguments.members.length; i++) { + this.resolveVariableDeclaration(funcDeclAST.arguments.members[i], context, funcDecl); + } + } + + if (signature.hasAGenericParameter) { + if (getterSymbol) { + getterTypeSymbol.setHasGenericSignature(); + } + } + + if (funcDeclAST.returnTypeAnnotation) { + var returnTypeSymbol = this.resolveTypeReference(funcDeclAST.returnTypeAnnotation, funcDecl, context); + + if (!returnTypeSymbol) { + diagnostic = context.postError(this.unitPath, funcDeclAST.returnTypeAnnotation.minChar, funcDeclAST.returnTypeAnnotation.getLength(), TypeScript.DiagnosticCode.Cannot_resolve_return_type_reference, null, funcDecl); + signature.returnType = this.getNewErrorTypeSymbol(diagnostic); + + hadError = true; + } else { + if (this.isTypeArgumentOrWrapper(returnTypeSymbol)) { + signature.hasAGenericParameter = true; + + if (getterSymbol) { + getterTypeSymbol.setHasGenericSignature(); + } + } + + signature.returnType = returnTypeSymbol; + } + } else { + if (funcDeclAST.isSignature()) { + signature.returnType = this.semanticInfoChain.anyTypeSymbol; + } else { + this.resolveFunctionBodyReturnTypes(funcDeclAST, signature, false, funcDecl, context); + } + } + + if (!hadError) { + signature.setResolved(); + } + } + + var accessorType = signature.returnType; + + var setter = accessorSymbol.getSetter(); + + if (setter) { + var setterType = setter.type; + var setterSig = setterType.getCallSignatures()[0]; + + if (setterSig.isResolved) { + var setterParameters = setterSig.parameters; + + if (setterParameters.length) { + var setterParameter = setterParameters[0]; + var setterParameterType = setterParameter.type; + + if (!this.typesAreIdentical(accessorType, setterParameterType)) { + diagnostic = context.postError(this.unitPath, funcDeclAST.minChar, funcDeclAST.getLength(), TypeScript.DiagnosticCode.get_and_set_accessor_must_have_the_same_type, null, this.getEnclosingDecl(funcDecl)); + accessorSymbol.type = this.getNewErrorTypeSymbol(diagnostic); + } + } + } else { + accessorSymbol.type = accessorType; + } + } else { + accessorSymbol.type = accessorType; + } + + if (context.typeCheck()) { + var prevSeenSuperConstructorCall = this.seenSuperConstructorCall; + this.seenSuperConstructorCall = false; + + this.resolveAST(funcDeclAST.block, false, funcDecl, context); + + this.validateVariableDeclarationGroups(funcDecl, context); + + var enclosingDecl = this.getEnclosingDecl(funcDecl); + + var hasReturn = (funcDecl.flags & (2048 /* Signature */ | 4194304 /* HasReturnStatement */)) != 0; + + var isGetter = TypeScript.hasFlag(funcDeclAST.getFunctionFlags(), 32 /* GetAccessor */); + var isSetter = !isGetter; + + var getter = accessorSymbol.getGetter(); + var setter = accessorSymbol.getSetter(); + + var funcNameAST = funcDeclAST.name; + + if (!hasReturn) { + if (!(funcDeclAST.block.statements.members.length > 0 && funcDeclAST.block.statements.members[0].nodeType() === 96 /* ThrowStatement */)) { + context.postError(this.unitPath, funcNameAST.minChar, funcNameAST.getLength(), TypeScript.DiagnosticCode.Getters_must_return_a_value, null, enclosingDecl); + } + } + + if (getter && setter) { + var getterDecl = getter.getDeclarations()[0]; + var setterDecl = setter.getDeclarations()[0]; + + var getterIsPrivate = getterDecl.flags & 2 /* Private */; + var setterIsPrivate = setterDecl.flags & 2 /* Private */; + + if (getterIsPrivate != setterIsPrivate) { + context.postError(this.unitPath, funcNameAST.minChar, funcNameAST.getLength(), TypeScript.DiagnosticCode.Getter_and_setter_accessors_do_not_agree_in_visibility, null, enclosingDecl); + } + } + + this.checkFunctionTypePrivacy(funcDeclAST, false, context); + } + + return accessorSymbol; + }; + + PullTypeResolver.prototype.resolveSetAccessorDeclaration = function (funcDeclAST, context) { + var funcDecl = this.getDeclForAST(funcDeclAST); + var accessorSymbol = funcDecl.getSymbol(); + + var setterSymbol = accessorSymbol.getSetter(); + var setterTypeSymbol = setterSymbol.type; + + var signature = setterTypeSymbol.getCallSignatures()[0]; + + var hadError = false; + + if (signature) { + if (signature.isResolved) { + return accessorSymbol; + } + + if (signature.inResolution) { + signature.returnType = this.semanticInfoChain.anyTypeSymbol; + signature.setResolved(); + + return accessorSymbol; + } + + signature.startResolving(); + + if (funcDeclAST.arguments) { + for (var i = 0; i < funcDeclAST.arguments.members.length; i++) { + this.resolveVariableDeclaration(funcDeclAST.arguments.members[i], context, funcDecl); + } + } + + if (signature.hasAGenericParameter) { + if (setterSymbol) { + setterTypeSymbol.setHasGenericSignature(); + } + } + + if (!hadError) { + signature.setResolved(); + } + } + + var parameters = signature.parameters; + + var getter = accessorSymbol.getGetter(); + + var accessorType = parameters.length ? parameters[0].type : getter ? getter.type : this.semanticInfoChain.undefinedTypeSymbol; + + if (getter) { + var getterType = getter.type; + var getterSig = getterType.getCallSignatures()[0]; + + if (accessorType == this.semanticInfoChain.undefinedTypeSymbol) { + accessorType = getterType; + } + + if (getterSig.isResolved) { + var getterReturnType = getterSig.returnType; + + if (!this.typesAreIdentical(accessorType, getterReturnType)) { + if (this.isAnyOrEquivalent(accessorType)) { + accessorSymbol.type = getterReturnType; + if (!accessorType.isError()) { + parameters[0].type = getterReturnType; + } + } else { + var diagnostic = context.postError(this.unitPath, funcDeclAST.minChar, funcDeclAST.getLength(), TypeScript.DiagnosticCode.get_and_set_accessor_must_have_the_same_type, null, this.getEnclosingDecl(funcDecl)); + accessorSymbol.type = this.getNewErrorTypeSymbol(diagnostic); + } + } + } else { + accessorSymbol.type = accessorType; + } + } else { + accessorSymbol.type = accessorType; + + if (this.compilationSettings.noImplicitAny) { + if (accessorSymbol.type == this.semanticInfoChain.anyTypeSymbol) { + context.postError(this.unitPath, funcDeclAST.minChar, funcDeclAST.getLength(), TypeScript.DiagnosticCode._0_which_lacks_return_type_annotation_implicitly_has_an_any_return_type, [funcDeclAST.name.actualText], this.getEnclosingDecl(funcDecl)); + } + } + } + + if (context.typeCheck()) { + var prevSeenSuperConstructorCall = this.seenSuperConstructorCall; + this.seenSuperConstructorCall = false; + + this.resolveAST(funcDeclAST.block, false, funcDecl, context); + + this.validateVariableDeclarationGroups(funcDecl, context); + + var enclosingDecl = this.getEnclosingDecl(funcDecl); + + var hasReturn = (funcDecl.flags & (2048 /* Signature */ | 4194304 /* HasReturnStatement */)) != 0; + + var isGetter = TypeScript.hasFlag(funcDeclAST.getFunctionFlags(), 32 /* GetAccessor */); + var isSetter = !isGetter; + + var getter = accessorSymbol.getGetter(); + var setter = accessorSymbol.getSetter(); + + var funcNameAST = funcDeclAST.name; + + if (getter && setter) { + var getterDecl = getter.getDeclarations()[0]; + var setterDecl = setter.getDeclarations()[0]; + + var getterIsPrivate = getterDecl.flags & 2 /* Private */; + var setterIsPrivate = setterDecl.flags & 2 /* Private */; + + if (getterIsPrivate != setterIsPrivate) { + context.postError(this.unitPath, funcNameAST.minChar, funcNameAST.getLength(), TypeScript.DiagnosticCode.Getter_and_setter_accessors_do_not_agree_in_visibility, null, enclosingDecl); + } + } + + this.checkFunctionTypePrivacy(funcDeclAST, false, context); + } + + return accessorSymbol; + }; + + PullTypeResolver.prototype.resolveList = function (list, enclosingDecl, context) { + if (context.typeCheck()) { + for (var i = 0; i < list.members.length; i++) { + this.resolveAST(list.members[i], false, enclosingDecl, context); + } + } + + return this.semanticInfoChain.voidTypeSymbol; + }; + + PullTypeResolver.prototype.resolveVoidExpression = function (ast, enclosingDecl, context) { + if (context.typeCheck()) { + this.resolveAST((ast).operand, false, enclosingDecl, context); + } + + this.setSymbolForAST(ast, this.semanticInfoChain.voidTypeSymbol, context); + return this.semanticInfoChain.voidTypeSymbol; + }; + + PullTypeResolver.prototype.resolveLogicalOperation = function (ast, enclosingDecl, context) { + if (context.typeCheck()) { + var binex = ast; + + var leftType = this.resolveAST(binex.operand1, false, enclosingDecl, context).type; + var rightType = this.resolveAST(binex.operand2, false, enclosingDecl, context).type; + + var comparisonInfo = new TypeComparisonInfo(); + if (!this.sourceIsAssignableToTarget(leftType, rightType, context, comparisonInfo) && !this.sourceIsAssignableToTarget(rightType, leftType, context, comparisonInfo)) { + context.postError(this.unitPath, binex.minChar, binex.getLength(), TypeScript.DiagnosticCode.Operator_0_cannot_be_applied_to_types_1_and_2, [TypeScript.BinaryExpression.getTextForBinaryToken(binex.nodeType()), leftType.toString(), rightType.toString()], enclosingDecl); + } + } + + this.setSymbolForAST(ast, this.semanticInfoChain.booleanTypeSymbol, context); + return this.semanticInfoChain.booleanTypeSymbol; + }; + + PullTypeResolver.prototype.resolveUnaryLogicalOperation = function (ast, enclosingDecl, context) { + if (context.typeCheck()) { + this.resolveAST((ast).operand, false, enclosingDecl, context); + } + + this.setSymbolForAST(ast, this.semanticInfoChain.booleanTypeSymbol, context); + return this.semanticInfoChain.booleanTypeSymbol; + }; + + PullTypeResolver.prototype.resolveUnaryArithmeticOperation = function (ast, enclosingDecl, context) { + var nodeType = ast.nodeType(); + if (context.typeCheck()) { + var unaryExpression = ast; + var expression = this.resolveAST(unaryExpression.operand, false, enclosingDecl, context); + + if (nodeType == 27 /* PlusExpression */ || nodeType == 28 /* NegateExpression */ || nodeType == 73 /* BitwiseNotExpression */) { + return this.semanticInfoChain.numberTypeSymbol; + } + var operandType = expression.type; + + var operandIsFit = this.isAnyOrEquivalent(operandType) || operandType === this.semanticInfoChain.numberTypeSymbol || TypeScript.PullHelpers.symbolIsEnum(operandType); + + if (!operandIsFit) { + context.postError(this.unitPath, unaryExpression.operand.minChar, unaryExpression.operand.getLength(), TypeScript.DiagnosticCode.The_type_of_a_unary_arithmetic_operation_operand_must_be_of_type_any_number_or_an_enum_type, null, enclosingDecl); + } + + switch (unaryExpression.nodeType()) { + case 77 /* PostIncrementExpression */: + case 75 /* PreIncrementExpression */: + case 78 /* PostDecrementExpression */: + case 76 /* PreDecrementExpression */: + if (!this.isValidLHS(unaryExpression.operand, expression)) { + context.postError(this.unitPath, unaryExpression.operand.minChar, unaryExpression.operand.getLength(), TypeScript.DiagnosticCode.The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_property_or_indexer, null, enclosingDecl); + } + + break; + } + } + + this.setSymbolForAST(ast, this.semanticInfoChain.numberTypeSymbol, context); + return this.semanticInfoChain.numberTypeSymbol; + }; + + PullTypeResolver.prototype.resolveBinaryArithmeticExpression = function (ast, enclosingDecl, context) { + if (context.typeCheck()) { + var binaryExpression = ast; + + var lhsSymbol = this.resolveAST(binaryExpression.operand1, false, enclosingDecl, context); + + var lhsType = lhsSymbol.type; + var rhsType = this.resolveAST(binaryExpression.operand2, false, enclosingDecl, context).type; + + var lhsIsFit = this.isAnyOrEquivalent(lhsType) || lhsType === this.semanticInfoChain.numberTypeSymbol || TypeScript.PullHelpers.symbolIsEnum(lhsType); + var rhsIsFit = this.isAnyOrEquivalent(rhsType) || rhsType === this.semanticInfoChain.numberTypeSymbol || TypeScript.PullHelpers.symbolIsEnum(rhsType); + + if (!rhsIsFit) { + context.postError(this.unitPath, binaryExpression.operand1.minChar, binaryExpression.operand1.getLength(), TypeScript.DiagnosticCode.The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type, null, enclosingDecl); + } + + if (!lhsIsFit) { + context.postError(this.unitPath, binaryExpression.operand2.minChar, binaryExpression.operand2.getLength(), TypeScript.DiagnosticCode.The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type, null, enclosingDecl); + } + + if (rhsIsFit && lhsIsFit) { + switch (binaryExpression.nodeType()) { + case 48 /* LeftShiftAssignmentExpression */: + case 49 /* SignedRightShiftAssignmentExpression */: + case 50 /* UnsignedRightShiftAssignmentExpression */: + case 41 /* SubtractAssignmentExpression */: + case 43 /* MultiplyAssignmentExpression */: + case 42 /* DivideAssignmentExpression */: + case 44 /* ModuloAssignmentExpression */: + case 47 /* OrAssignmentExpression */: + case 45 /* AndAssignmentExpression */: + case 46 /* ExclusiveOrAssignmentExpression */: + if (!this.isValidLHS(binaryExpression.operand1, lhsSymbol)) { + context.postError(this.unitPath, binaryExpression.operand1.minChar, binaryExpression.operand1.getLength(), TypeScript.DiagnosticCode.Invalid_left_hand_side_of_assignment_expression, null, enclosingDecl); + } + + this.checkAssignability(binaryExpression.operand1, rhsType, lhsType, enclosingDecl, context); + break; + } + } + } + + this.setSymbolForAST(ast, this.semanticInfoChain.numberTypeSymbol, context); + return this.semanticInfoChain.numberTypeSymbol; + }; + + PullTypeResolver.prototype.resolveTypeOfExpression = function (ast, enclosingDecl, context) { + if (context.typeCheck()) { + this.resolveAST((ast).operand, false, enclosingDecl, context); + } + + this.setSymbolForAST(ast, this.semanticInfoChain.stringTypeSymbol, context); + return this.semanticInfoChain.stringTypeSymbol; + }; + + PullTypeResolver.prototype.resolveThrowStatement = function (ast, enclosingDecl, context) { + if (context.typeCheck()) { + this.resolveAST((ast).expression, false, enclosingDecl, context); + } + + this.setSymbolForAST(ast, this.semanticInfoChain.voidTypeSymbol, context); + return this.semanticInfoChain.voidTypeSymbol; + }; + + PullTypeResolver.prototype.resolveDeleteStatement = function (ast, enclosingDecl, context) { + if (context.typeCheck()) { + this.resolveAST((ast).operand, false, enclosingDecl, context); + } + + this.setSymbolForAST(ast, this.semanticInfoChain.booleanTypeSymbol, context); + return this.semanticInfoChain.booleanTypeSymbol; + }; + + PullTypeResolver.prototype.resolveInstanceOfExpression = function (ast, enclosingDecl, context) { + if (context.typeCheck()) { + var binaryExpression = ast; + + var lhsType = this.widenType(this.resolveAST(binaryExpression.operand1, false, enclosingDecl, context).type); + var rhsType = this.widenType(this.resolveAST(binaryExpression.operand2, false, enclosingDecl, context).type); + + var isValidLHS = lhsType && (this.isAnyOrEquivalent(lhsType) || !lhsType.isPrimitive()); + var isValidRHS = rhsType && (this.isAnyOrEquivalent(rhsType) || rhsType.isClass() || this.typeIsSubtypeOfFunction(rhsType, context)); + + if (!isValidLHS) { + context.postError(this.unitPath, binaryExpression.operand1.minChar, binaryExpression.operand1.getLength(), TypeScript.DiagnosticCode.The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter, null, enclosingDecl); + } + + if (!isValidRHS) { + context.postError(this.unitPath, binaryExpression.operand1.minChar, binaryExpression.operand1.getLength(), TypeScript.DiagnosticCode.The_right_hand_side_of_an_instanceof_expression_must_be_of_type_any_or_a_subtype_of_the_Function_interface_type, null, enclosingDecl); + } + } + + this.setSymbolForAST(ast, this.semanticInfoChain.booleanTypeSymbol, context); + return this.semanticInfoChain.booleanTypeSymbol; + }; + + PullTypeResolver.prototype.resolveCommaExpression = function (ast, enclosingDecl, context) { + if (context.typeCheck()) { + this.resolveAST((ast).operand1, false, enclosingDecl, context); + return this.resolveAST((ast).operand2, false, enclosingDecl, context); + } + + return this.semanticInfoChain.voidTypeSymbol; + }; + + PullTypeResolver.prototype.resolveInExpression = function (ast, enclosingDecl, context) { + if (context.typeCheck()) { + var binaryExpression = ast; + var lhsType = this.widenType(this.resolveAST(binaryExpression.operand1, false, enclosingDecl, context).type); + var rhsType = this.widenType(this.resolveAST(binaryExpression.operand2, false, enclosingDecl, context).type); + + var isStringAnyOrNumber = lhsType.type === this.semanticInfoChain.stringTypeSymbol || this.isAnyOrEquivalent(lhsType.type) || this.isNumberOrEquivalent(lhsType.type); + var isValidRHS = rhsType && (this.isAnyOrEquivalent(rhsType) || !rhsType.isPrimitive()); + + if (!isStringAnyOrNumber) { + context.postError(this.unitPath, binaryExpression.operand1.minChar, binaryExpression.operand1.getLength(), TypeScript.DiagnosticCode.The_left_hand_side_of_an_in_expression_must_be_of_types_string_or_any, null, enclosingDecl); + } + + if (!isValidRHS) { + context.postError(this.unitPath, binaryExpression.operand1.minChar, binaryExpression.operand1.getLength(), TypeScript.DiagnosticCode.The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter, null, enclosingDecl); + } + } + + this.setSymbolForAST(ast, this.semanticInfoChain.booleanTypeSymbol, context); + return this.semanticInfoChain.booleanTypeSymbol; + }; + + PullTypeResolver.prototype.resolveForStatement = function (ast, enclosingDecl, context) { + if (context.typeCheck()) { + this.resolveAST((ast).init, false, enclosingDecl, context); + this.resolveAST((ast).cond, false, enclosingDecl, context); + this.resolveAST((ast).incr, false, enclosingDecl, context); + this.resolveAST((ast).body, false, enclosingDecl, context); + } + + this.setSymbolForAST(ast, this.semanticInfoChain.voidTypeSymbol, context); + return this.semanticInfoChain.voidTypeSymbol; + }; + + PullTypeResolver.prototype.resolveForInStatement = function (ast, enclosingDecl, context) { + if (context.typeCheck()) { + var forInStatement = ast; + + var rhsType = this.widenType(this.resolveAST(forInStatement.obj, false, enclosingDecl, context).type); + var lval = forInStatement.lval; + + if (lval.nodeType() === 19 /* VariableDeclaration */) { + var declaration = forInStatement.lval; + var varDecl = declaration.declarators.members[0]; + + if (varDecl.typeExpr) { + context.postError(this.unitPath, lval.minChar, lval.getLength(), TypeScript.DiagnosticCode.Variable_declarations_of_a_for_statement_cannot_use_a_type_annotation, null, enclosingDecl); + } + } + + var varSym = this.resolveAST(forInStatement.lval, false, enclosingDecl, context); + + if (lval.nodeType() === 19 /* VariableDeclaration */) { + varSym = this.getSymbolForAST((forInStatement.lval).declarators.members[0]); + } + + var isStringOrNumber = varSym.type === this.semanticInfoChain.stringTypeSymbol || this.isAnyOrEquivalent(varSym.type); + + var isValidRHS = rhsType && (this.isAnyOrEquivalent(rhsType) || !rhsType.isPrimitive()); + + if (!isStringOrNumber) { + context.postError(this.unitPath, lval.minChar, lval.getLength(), TypeScript.DiagnosticCode.Variable_declarations_of_a_for_statement_must_be_of_types_string_or_any, null, enclosingDecl); + } + + if (!isValidRHS) { + context.postError(this.unitPath, forInStatement.obj.minChar, forInStatement.obj.getLength(), TypeScript.DiagnosticCode.The_right_hand_side_of_a_for_in_statement_must_be_of_type_any_an_object_type_or_a_type_parameter, null, enclosingDecl); + } + + this.resolveAST(forInStatement.body, false, enclosingDecl, context); + } + + this.setSymbolForAST(ast, this.semanticInfoChain.voidTypeSymbol, context); + return this.semanticInfoChain.voidTypeSymbol; + }; + + PullTypeResolver.prototype.resolveWhileStatement = function (ast, enclosingDecl, context) { + if (context.typeCheck()) { + this.resolveAST((ast).cond, false, enclosingDecl, context); + this.resolveAST((ast).body, false, enclosingDecl, context); + } + + this.setSymbolForAST(ast, this.semanticInfoChain.voidTypeSymbol, context); + return this.semanticInfoChain.voidTypeSymbol; + }; + + PullTypeResolver.prototype.resolveDoStatement = function (ast, enclosingDecl, context) { + if (context.typeCheck()) { + this.resolveAST((ast).cond, false, enclosingDecl, context); + this.resolveAST((ast).body, false, enclosingDecl, context); + } + + this.setSymbolForAST(ast, this.semanticInfoChain.voidTypeSymbol, context); + return this.semanticInfoChain.voidTypeSymbol; + }; + + PullTypeResolver.prototype.resolveIfStatement = function (ast, enclosingDecl, context) { + if (context.typeCheck()) { + this.resolveAST((ast).cond, false, enclosingDecl, context); + this.resolveAST((ast).thenBod, false, enclosingDecl, context); + this.resolveAST((ast).elseBod, false, enclosingDecl, context); + } + + this.setSymbolForAST(ast, this.semanticInfoChain.voidTypeSymbol, context); + return this.semanticInfoChain.voidTypeSymbol; + }; + + PullTypeResolver.prototype.resolveBlock = function (ast, enclosingDecl, context) { + if (context.typeCheck()) { + this.resolveAST((ast).statements, false, enclosingDecl, context); + } + + return this.semanticInfoChain.voidTypeSymbol; + }; + + PullTypeResolver.prototype.resolveVariableStatement = function (ast, enclosingDecl, context) { + if (context.typeCheck()) { + this.resolveAST((ast).declaration, false, enclosingDecl, context); + } + + return this.semanticInfoChain.voidTypeSymbol; + }; + + PullTypeResolver.prototype.resolveVariableDeclarationList = function (ast, enclosingDecl, context) { + if (context.typeCheck()) { + this.resolveAST((ast).declarators, false, enclosingDecl, context); + } + + return this.semanticInfoChain.voidTypeSymbol; + }; + + PullTypeResolver.prototype.resolveWithStatement = function (ast, enclosingDecl, context) { + if (context.typeCheck()) { + var withStatement = ast; + context.postError(this.unitPath, withStatement.expr.minChar, withStatement.expr.getLength(), TypeScript.DiagnosticCode.All_symbols_within_a_with_block_will_be_resolved_to_any, null, enclosingDecl); + } + + this.setSymbolForAST(ast, this.semanticInfoChain.voidTypeSymbol, context); + return this.semanticInfoChain.voidTypeSymbol; + }; + + PullTypeResolver.prototype.resolveTryStatement = function (ast, enclosingDecl, context) { + if (context.typeCheck()) { + var tryStatement = ast; + + this.resolveAST(tryStatement.tryBody, false, enclosingDecl, context); + this.resolveAST(tryStatement.catchClause, false, enclosingDecl, context); + this.resolveAST(tryStatement.finallyBody, false, enclosingDecl, context); + } + + this.setSymbolForAST(ast, this.semanticInfoChain.voidTypeSymbol, context); + return this.semanticInfoChain.voidTypeSymbol; + }; + + PullTypeResolver.prototype.resolveCatchClause = function (ast, enclosingDecl, context) { + if (context.typeCheck()) { + this.resolveAST((ast).body, false, this.getDeclForAST(ast), context); + } + + this.setSymbolForAST(ast, this.semanticInfoChain.voidTypeSymbol, context); + return this.semanticInfoChain.voidTypeSymbol; + }; + + PullTypeResolver.prototype.resolveReturnStatement = function (ast, inContextuallyTypedAssignment, enclosingDecl, context) { + var parentDecl = enclosingDecl; + var returnAST = ast; + var returnExpr = returnAST.returnExpression; + + while (parentDecl) { + if (parentDecl.kind & TypeScript.PullElementKind.SomeFunction) { + parentDecl.setFlag(4194304 /* HasReturnStatement */); + break; + } + + parentDecl = parentDecl.getParentDecl(); + } + + var inContextuallyTypedAssignment = false; + var enclosingDeclAST; + + if (enclosingDecl.kind & TypeScript.PullElementKind.SomeFunction) { + enclosingDeclAST = this.getASTForDecl(enclosingDecl); + if (enclosingDeclAST.returnTypeAnnotation) { + var returnTypeAnnotationSymbol = this.resolveTypeReference(enclosingDeclAST.returnTypeAnnotation, enclosingDecl, context); + if (returnTypeAnnotationSymbol) { + inContextuallyTypedAssignment = true; + context.pushContextualType(returnTypeAnnotationSymbol, context.inProvisionalResolution(), null); + } + } else { + var currentContextualType = context.getContextualType(); + if (currentContextualType && currentContextualType.isFunction()) { + var currentContextualTypeSignatureSymbol = currentContextualType.getDeclarations()[0].getSignatureSymbol(); + var currentContextualTypeReturnTypeSymbol = currentContextualTypeSignatureSymbol.returnType; + if (currentContextualTypeReturnTypeSymbol) { + inContextuallyTypedAssignment = true; + context.pushContextualType(currentContextualTypeReturnTypeSymbol, context.inProvisionalResolution(), null); + } + } + } + } + + var returnType = returnExpr ? this.resolveAST(returnExpr, inContextuallyTypedAssignment, enclosingDecl, context).type : this.semanticInfoChain.voidTypeSymbol; + + if (inContextuallyTypedAssignment) { + context.popContextualType(); + } + + if (context.typeCheck() && returnExpr) { + if (enclosingDecl.kind === 524288 /* SetAccessor */ && returnExpr) { + context.postError(this.unitPath, returnExpr.minChar, returnExpr.getLength(), TypeScript.DiagnosticCode.Setters_cannot_return_a_value, null, enclosingDecl); + } + + if (enclosingDecl.kind & TypeScript.PullElementKind.SomeFunction) { + enclosingDeclAST = this.getASTForDecl(enclosingDecl); + + if (enclosingDeclAST.returnTypeAnnotation) { + var signatureSymbol = enclosingDecl.getSignatureSymbol(); + var sigReturnType = signatureSymbol.returnType; + + if (returnType && sigReturnType) { + var comparisonInfo = new TypeComparisonInfo(); + var upperBound = null; + + if (returnType.isTypeParameter()) { + upperBound = (returnType).getConstraint(); + + if (upperBound) { + returnType = upperBound; + } + } + + if (sigReturnType.isTypeParameter()) { + upperBound = (sigReturnType).getConstraint(); + + if (upperBound) { + sigReturnType = upperBound; + } + } + + if (!returnType.isResolved) { + this.resolveDeclaredSymbol(returnType, enclosingDecl, context); + } + + if (!sigReturnType.isResolved) { + this.resolveDeclaredSymbol(sigReturnType, enclosingDecl, context); + } + + var isAssignable = this.sourceIsAssignableToTarget(returnType, sigReturnType, context, comparisonInfo); + + if (!isAssignable) { + if (comparisonInfo.message) { + context.postError(this.unitPath, returnExpr.minChar, returnExpr.getLength(), TypeScript.DiagnosticCode.Cannot_convert_0_to_1_NL_2, [returnType.toString(), sigReturnType.toString(), comparisonInfo.message], enclosingDecl); + } else { + context.postError(this.unitPath, returnExpr.minChar, returnExpr.getLength(), TypeScript.DiagnosticCode.Cannot_convert_0_to_1, [returnType.toString(), sigReturnType.toString()], enclosingDecl); + } + } + } + } + } + } + + this.setSymbolForAST(ast, returnType, context); + + return returnType; + }; + + PullTypeResolver.prototype.resolveSwitchStatement = function (ast, enclosingDecl, context) { + if (context.typeCheck()) { + var switchStatement = ast; + + var expressionType = this.resolveAST(switchStatement.val, false, enclosingDecl, context).type; + + this.resolveAST(switchStatement.caseList, false, enclosingDecl, context); + this.resolveAST(switchStatement.defaultCase, false, enclosingDecl, context); + + if (switchStatement.caseList && switchStatement.caseList.members) { + for (var i = 0, n = switchStatement.caseList.members.length; i < n; i++) { + var caseClause = switchStatement.caseList.members[i]; + if (caseClause !== switchStatement.defaultCase) { + var caseClauseExpressionType = this.resolveAST(caseClause.expr, false, enclosingDecl, context).type; + + var comparisonInfo = new TypeComparisonInfo(); + if (!this.sourceIsAssignableToTarget(expressionType, caseClauseExpressionType, context, comparisonInfo) && !this.sourceIsAssignableToTarget(caseClauseExpressionType, expressionType, context, comparisonInfo)) { + if (comparisonInfo.message) { + context.postError(this.unitPath, caseClause.expr.minChar, caseClause.expr.getLength(), TypeScript.DiagnosticCode.Cannot_convert_0_to_1_NL_2, [caseClauseExpressionType.toString(), expressionType.toString(), comparisonInfo.message], enclosingDecl); + } else { + context.postError(this.unitPath, caseClause.expr.minChar, caseClause.expr.getLength(), TypeScript.DiagnosticCode.Cannot_convert_0_to_1, [caseClauseExpressionType.toString(), expressionType.toString()], enclosingDecl); + } + } + } + } + } + } + + this.setSymbolForAST(ast, this.semanticInfoChain.voidTypeSymbol, context); + return this.semanticInfoChain.voidTypeSymbol; + }; + + PullTypeResolver.prototype.resolveCaseClause = function (ast, enclosingDecl, context) { + if (context.typeCheck()) { + this.resolveAST((ast).expr, false, enclosingDecl, context); + this.resolveAST((ast).body, false, enclosingDecl, context); + } + + this.setSymbolForAST(ast, this.semanticInfoChain.voidTypeSymbol, context); + return this.semanticInfoChain.voidTypeSymbol; + }; + + PullTypeResolver.prototype.resolveLabeledStatement = function (ast, enclosingDecl, context) { + return this.resolveAST((ast).statement, false, enclosingDecl, context); + }; + + PullTypeResolver.prototype.resolveAST = function (ast, inContextuallyTypedAssignment, enclosingDecl, context, specializingSignature) { + if (typeof specializingSignature === "undefined") { specializingSignature = false; } + TypeScript.globalSemanticInfoChain = this.semanticInfoChain; + + if (TypeScript.globalBinder) { + TypeScript.globalBinder.semanticInfoChain = this.semanticInfoChain; + } + + if (!ast) { + return; + } + + var symbol = specializingSignature ? null : this.semanticInfoChain.getSymbolForAST(ast, this.unitPath); + + if (symbol && symbol.type && (symbol.isResolved)) { + return symbol; + } + + var nodeType = ast.nodeType(); + + switch (nodeType) { + case 1 /* List */: + return this.resolveList(ast, enclosingDecl, context); + + case 2 /* Script */: + return null; + + case 16 /* ModuleDeclaration */: + return this.resolveModuleDeclaration(ast, context); + + case 15 /* InterfaceDeclaration */: + return this.resolveInterfaceDeclaration(ast, context); + + case 14 /* ClassDeclaration */: + return this.resolveClassDeclaration(ast, context); + + case 19 /* VariableDeclaration */: + return this.resolveVariableDeclarationList(ast, enclosingDecl, context); + + case 18 /* VariableDeclarator */: + case 20 /* Parameter */: + return this.resolveVariableDeclaration(ast, context, enclosingDecl); + + case 9 /* TypeParameter */: + return this.resolveTypeParameterDeclaration(ast, context); + + case 17 /* ImportDeclaration */: + return this.resolveImportDeclaration(ast, context); + + case 23 /* ObjectLiteralExpression */: + return this.resolveObjectLiteralExpression(ast, inContextuallyTypedAssignment, enclosingDecl, context); + + case 10 /* GenericType */: + return this.resolveGenericTypeReference(ast, enclosingDecl, context); + + case 21 /* Name */: + if (context.resolvingTypeReference) { + return this.resolveTypeNameExpression(ast, enclosingDecl, context); + } else { + return this.resolveNameExpression(ast, enclosingDecl, context); + } + + case 33 /* MemberAccessExpression */: + if (context.resolvingTypeReference) { + return this.resolveDottedTypeNameExpression(ast, enclosingDecl, context); + } else { + return this.resolveDottedNameExpression(ast, enclosingDecl, context); + } + + case 10 /* GenericType */: + return this.resolveGenericTypeReference(ast, enclosingDecl, context); + + case 13 /* FunctionDeclaration */: { + var funcDecl = ast; + + if (funcDecl.isGetAccessor()) { + return this.resolveGetAccessorDeclaration(funcDecl, context); + } else if (funcDecl.isSetAccessor()) { + return this.resolveSetAccessorDeclaration(funcDecl, context); + } else if (inContextuallyTypedAssignment || (funcDecl.getFunctionFlags() & 8192 /* IsFunctionExpression */) || (funcDecl.getFunctionFlags() & 2048 /* IsFatArrowFunction */) || (funcDecl.getFunctionFlags() & 16384 /* IsFunctionProperty */)) { + return this.resolveFunctionExpression(funcDecl, inContextuallyTypedAssignment, enclosingDecl, context); + } else { + return this.resolveFunctionDeclaration(funcDecl, context); + } + } + + case 18 /* VariableDeclarator */: + case 20 /* Parameter */: + return this.resolveVariableDeclaration(ast, context, enclosingDecl); + + case 9 /* TypeParameter */: + return this.resolveTypeParameterDeclaration(ast, context); + + case 17 /* ImportDeclaration */: + return this.resolveImportDeclaration(ast, context); + + case 23 /* ObjectLiteralExpression */: + return this.resolveObjectLiteralExpression(ast, inContextuallyTypedAssignment, enclosingDecl, context); + + case 10 /* GenericType */: + return this.resolveGenericTypeReference(ast, enclosingDecl, context); + + case 21 /* Name */: + if (context.resolvingTypeReference) { + return this.resolveTypeNameExpression(ast, enclosingDecl, context); + } else { + return this.resolveNameExpression(ast, enclosingDecl, context); + } + + case 33 /* MemberAccessExpression */: + if (context.resolvingTypeReference) { + return this.resolveDottedTypeNameExpression(ast, enclosingDecl, context); + } else { + return this.resolveDottedNameExpression(ast, enclosingDecl, context); + } + + case 10 /* GenericType */: + return this.resolveGenericTypeReference(ast, enclosingDecl, context); + + case 13 /* FunctionDeclaration */: { + var funcDecl = ast; + + if (funcDecl.isGetAccessor()) { + return this.resolveGetAccessorDeclaration(funcDecl, context); + } else if (funcDecl.isSetAccessor()) { + return this.resolveSetAccessorDeclaration(funcDecl, context); + } else if (inContextuallyTypedAssignment || (funcDecl.getFunctionFlags() & 8192 /* IsFunctionExpression */) || (funcDecl.getFunctionFlags() & 2048 /* IsFatArrowFunction */) || (funcDecl.getFunctionFlags() & 16384 /* IsFunctionProperty */)) { + return this.resolveFunctionExpression(funcDecl, inContextuallyTypedAssignment, enclosingDecl, context); + } else { + return this.resolveFunctionDeclaration(funcDecl, context); + } + } + + case 22 /* ArrayLiteralExpression */: + return this.resolveArrayLiteralExpression(ast, inContextuallyTypedAssignment, enclosingDecl, context); + + case 30 /* ThisExpression */: + return this.resolveThisExpression(ast, enclosingDecl, context); + + case 31 /* SuperExpression */: + return this.resolveSuperExpression(ast, enclosingDecl, context); + + case 37 /* InvocationExpression */: + return this.resolveInvocationExpression(ast, inContextuallyTypedAssignment, enclosingDecl, context); + + case 38 /* ObjectCreationExpression */: + return this.resolveObjectCreationExpression(ast, inContextuallyTypedAssignment, enclosingDecl, context); + + case 79 /* CastExpression */: + return this.resolveTypeAssertionExpression(ast, inContextuallyTypedAssignment, enclosingDecl, context); + + case 11 /* TypeRef */: + return this.resolveTypeReference(ast, enclosingDecl, context); + + case 88 /* ExportAssignment */: + return this.resolveExportAssignmentStatement(ast, enclosingDecl, context); + + case 7 /* NumericLiteral */: + return this.semanticInfoChain.numberTypeSymbol; + case 5 /* StringLiteral */: + return this.semanticInfoChain.stringTypeSymbol; + case 8 /* NullLiteral */: + return this.semanticInfoChain.nullTypeSymbol; + case 3 /* TrueLiteral */: + case 4 /* FalseLiteral */: + return this.semanticInfoChain.booleanTypeSymbol; + case 25 /* VoidExpression */: + return this.resolveVoidExpression(ast, enclosingDecl, context); + + case 39 /* AssignmentExpression */: + return this.resolveAssignmentStatement(ast, inContextuallyTypedAssignment, enclosingDecl, context); + + case 74 /* LogicalNotExpression */: + return this.resolveUnaryLogicalOperation(ast, enclosingDecl, context); + + case 58 /* NotEqualsWithTypeConversionExpression */: + case 57 /* EqualsWithTypeConversionExpression */: + case 59 /* EqualsExpression */: + case 60 /* NotEqualsExpression */: + case 61 /* LessThanExpression */: + case 62 /* LessThanOrEqualExpression */: + case 64 /* GreaterThanOrEqualExpression */: + case 63 /* GreaterThanExpression */: + return this.resolveLogicalOperation(ast, enclosingDecl, context); + + case 65 /* AddExpression */: + case 40 /* AddAssignmentExpression */: + return this.resolveBinaryAdditionOperation(ast, inContextuallyTypedAssignment, enclosingDecl, context); + + case 27 /* PlusExpression */: + case 28 /* NegateExpression */: + case 73 /* BitwiseNotExpression */: + case 77 /* PostIncrementExpression */: + case 75 /* PreIncrementExpression */: + case 78 /* PostDecrementExpression */: + case 76 /* PreDecrementExpression */: + return this.resolveUnaryArithmeticOperation(ast, enclosingDecl, context); + + case 66 /* SubtractExpression */: + case 67 /* MultiplyExpression */: + case 68 /* DivideExpression */: + case 69 /* ModuloExpression */: + case 54 /* BitwiseOrExpression */: + case 56 /* BitwiseAndExpression */: + case 70 /* LeftShiftExpression */: + case 71 /* SignedRightShiftExpression */: + case 72 /* UnsignedRightShiftExpression */: + case 55 /* BitwiseExclusiveOrExpression */: + case 46 /* ExclusiveOrAssignmentExpression */: + case 48 /* LeftShiftAssignmentExpression */: + case 49 /* SignedRightShiftAssignmentExpression */: + case 50 /* UnsignedRightShiftAssignmentExpression */: + case 41 /* SubtractAssignmentExpression */: + case 43 /* MultiplyAssignmentExpression */: + case 42 /* DivideAssignmentExpression */: + case 44 /* ModuloAssignmentExpression */: + case 47 /* OrAssignmentExpression */: + case 45 /* AndAssignmentExpression */: + return this.resolveBinaryArithmeticExpression(ast, enclosingDecl, context); + + case 36 /* ElementAccessExpression */: + return this.resolveIndexExpression(ast, inContextuallyTypedAssignment, enclosingDecl, context); + + case 52 /* LogicalOrExpression */: + return this.resolveLogicalOrExpression(ast, inContextuallyTypedAssignment, enclosingDecl, context); + + case 53 /* LogicalAndExpression */: + return this.resolveLogicalAndExpression(ast, inContextuallyTypedAssignment, enclosingDecl, context); + + case 35 /* TypeOfExpression */: + return this.resolveTypeOfExpression(ast, enclosingDecl, context); + + case 96 /* ThrowStatement */: + return this.resolveThrowStatement(ast, enclosingDecl, context); + + case 29 /* DeleteExpression */: + return this.resolveDeleteStatement(ast, enclosingDecl, context); + + case 51 /* ConditionalExpression */: + return this.resolveConditionalExpression(ast, enclosingDecl, context); + + case 6 /* RegularExpressionLiteral */: + return this.resolveRegularExpressionLiteral(); + + case 80 /* ParenthesizedExpression */: + return this.resolveParenthesizedExpression(ast, enclosingDecl, context); + + case 89 /* ExpressionStatement */: + return this.resolveExpressionStatement(ast, inContextuallyTypedAssignment, enclosingDecl, context); + + case 34 /* InstanceOfExpression */: + return this.resolveInstanceOfExpression(ast, enclosingDecl, context); + + case 26 /* CommaExpression */: + return this.resolveCommaExpression(ast, enclosingDecl, context); + + case 32 /* InExpression */: + return this.resolveInExpression(ast, enclosingDecl, context); + + case 91 /* ForStatement */: + return this.resolveForStatement(ast, enclosingDecl, context); + + case 90 /* ForInStatement */: + return this.resolveForInStatement(ast, enclosingDecl, context); + + case 99 /* WhileStatement */: + return this.resolveWhileStatement(ast, enclosingDecl, context); + + case 86 /* DoStatement */: + return this.resolveDoStatement(ast, enclosingDecl, context); + + case 92 /* IfStatement */: + return this.resolveIfStatement(ast, enclosingDecl, context); + + case 82 /* Block */: + return this.resolveBlock(ast, enclosingDecl, context); + + case 98 /* VariableStatement */: + return this.resolveVariableStatement(ast, enclosingDecl, context); + + case 100 /* WithStatement */: + return this.resolveWithStatement(ast, enclosingDecl, context); + + case 97 /* TryStatement */: + return this.resolveTryStatement(ast, enclosingDecl, context); + + case 102 /* CatchClause */: + return this.resolveCatchClause(ast, enclosingDecl, context); + + case 94 /* ReturnStatement */: + return this.resolveReturnStatement(ast, inContextuallyTypedAssignment, enclosingDecl, context); + + case 95 /* SwitchStatement */: + return this.resolveSwitchStatement(ast, enclosingDecl, context); + + case 101 /* CaseClause */: + return this.resolveCaseClause(ast, enclosingDecl, context); + + case 93 /* LabeledStatement */: + return this.resolveLabeledStatement(ast, enclosingDecl, context); + } + + return this.semanticInfoChain.anyTypeSymbol; + }; + + PullTypeResolver.prototype.resolveRegularExpressionLiteral = function () { + if (this.cachedRegExpInterfaceType()) { + return this.cachedRegExpInterfaceType(); + } else { + return this.semanticInfoChain.anyTypeSymbol; + } + }; + + PullTypeResolver.prototype.isNameOrMemberAccessExpression = function (ast) { + var checkAST = ast; + + while (checkAST) { + if (checkAST.nodeType() === 89 /* ExpressionStatement */) { + checkAST = (checkAST).expression; + } else if (checkAST.nodeType() === 80 /* ParenthesizedExpression */) { + checkAST = (checkAST).expression; + } else if (checkAST.nodeType() === 21 /* Name */) { + return true; + } else if (checkAST.nodeType() === 33 /* MemberAccessExpression */) { + return true; + } else { + return false; + } + } + }; + + PullTypeResolver.prototype.resolveNameSymbol = function (nameSymbol, context) { + if (nameSymbol && !context.canUseTypeSymbol && nameSymbol != this.semanticInfoChain.undefinedTypeSymbol && nameSymbol != this.semanticInfoChain.nullTypeSymbol && (nameSymbol.isPrimitive() || !(nameSymbol.kind & TypeScript.PullElementKind.SomeValue))) { + var valueSymbol = nameSymbol.isAlias() ? (nameSymbol).getExportAssignedValueSymbol() : null; + if (valueSymbol) { + nameSymbol = valueSymbol; + } else { + nameSymbol = null; + } + } + + return nameSymbol; + }; + + PullTypeResolver.prototype.resolveNameExpression = function (nameAST, enclosingDecl, context) { + var nameSymbol = this.getSymbolForAST(nameAST); + var foundCached = nameSymbol != null; + + if (!foundCached) { + nameSymbol = this.computeNameExpression(nameAST, enclosingDecl, context); + } + + if (!nameSymbol.isResolved) { + this.resolveDeclaredSymbol(nameSymbol, enclosingDecl, context); + } + + if (nameSymbol && (nameSymbol.type != this.semanticInfoChain.anyTypeSymbol || nameSymbol.hasFlag(16777216 /* IsAnnotatedWithAny */))) { + this.setSymbolForAST(nameAST, nameSymbol, context); + } + + return nameSymbol; + }; + + PullTypeResolver.prototype.computeNameExpression = function (nameAST, enclosingDecl, context) { + if (nameAST.isMissing()) { + return this.semanticInfoChain.anyTypeSymbol; + } + + var id = nameAST.text(); + + var declPath = enclosingDecl !== null ? TypeScript.getPathToDecl(enclosingDecl) : []; + + if (enclosingDecl && !declPath.length) { + declPath = [enclosingDecl]; + } + + var aliasSymbol = null; + var nameSymbol = this.getSymbolFromDeclPath(id, declPath, TypeScript.PullElementKind.SomeValue); + + if (!nameSymbol && id === "arguments" && enclosingDecl && (enclosingDecl.kind & TypeScript.PullElementKind.SomeFunction)) { + nameSymbol = this.cachedFunctionArgumentsSymbol; + + if (this.cachedIArgumentsInterfaceType() && !this.cachedIArgumentsInterfaceType().isResolved) { + this.resolveDeclaredSymbol(this.cachedIArgumentsInterfaceType(), enclosingDecl, context); + } + } + + if (!nameSymbol) { + nameSymbol = this.getSymbolFromDeclPath(id, declPath, 256 /* TypeAlias */); + + if (nameSymbol && !nameSymbol.isAlias()) { + nameSymbol = null; + } + } + + if (!nameSymbol) { + if (context.resolvingTypeNameAsNameExpression) { + return null; + } else { + context.postError(this.unitPath, nameAST.minChar, nameAST.getLength(), TypeScript.DiagnosticCode.Could_not_find_symbol_0, [nameAST.actualText], enclosingDecl); + return this.getNewErrorTypeSymbol(null, id); + } + } + + if (nameSymbol.isType() && nameSymbol.isAlias()) { + aliasSymbol = nameSymbol; + aliasSymbol.isUsedAsValue = true; + + if (!nameSymbol.isResolved) { + this.resolveDeclaredSymbol(nameSymbol, enclosingDecl, context); + } + + if (aliasSymbol.assignedValue) { + if (!aliasSymbol.assignedValue.isResolved) { + this.resolveDeclaredSymbol(aliasSymbol.assignedValue, enclosingDecl, context); + } + } else if (aliasSymbol.assignedContainer && !aliasSymbol.assignedContainer.isResolved) { + this.resolveDeclaredSymbol(aliasSymbol.assignedContainer, enclosingDecl, context); + } + + var exportAssignmentSymbol = (nameSymbol).getExportAssignedValueSymbol(); + + if (exportAssignmentSymbol) { + nameSymbol = exportAssignmentSymbol; + } else { + aliasSymbol = null; + } + } + + if (aliasSymbol) { + this.currentUnit.setAliasSymbolForAST(nameAST, aliasSymbol); + } + + return nameSymbol; + }; + + PullTypeResolver.prototype.resolveDottedNameExpression = function (dottedNameAST, enclosingDecl, context) { + var symbol = this.getSymbolForAST(dottedNameAST); + var foundCached = symbol != null; + + if (!foundCached) { + symbol = this.computeDottedNameExpressionSymbol(dottedNameAST, enclosingDecl, context); + } + + if (symbol && !symbol.isResolved) { + this.resolveDeclaredSymbol(symbol, enclosingDecl, context); + } + + if (symbol && (symbol.type != this.semanticInfoChain.anyTypeSymbol || symbol.hasFlag(16777216 /* IsAnnotatedWithAny */))) { + this.setSymbolForAST(dottedNameAST, symbol, context); + this.setSymbolForAST(dottedNameAST.operand2, symbol, context); + } + + return symbol; + }; + + PullTypeResolver.prototype.isPrototypeMember = function (dottedNameAST, enclosingDecl, context) { + var rhsName = (dottedNameAST.operand2).text(); + if (rhsName === "prototype") { + var prevCanUseTypeSymbol = context.canUseTypeSymbol; + context.canUseTypeSymbol = true; + var lhsType = this.resolveAST(dottedNameAST.operand1, false, enclosingDecl, context).type; + context.canUseTypeSymbol = prevCanUseTypeSymbol; + + if (lhsType) { + if (lhsType.isClass() || lhsType.isConstructor()) { + return true; + } else { + var classInstanceType = lhsType.getAssociatedContainerType(); + + if (classInstanceType && classInstanceType.isClass()) { + return true; + } + } + } + } + + return false; + }; + + PullTypeResolver.prototype.computeDottedNameExpressionSymbol = function (dottedNameAST, enclosingDecl, context) { + if ((dottedNameAST.operand2).isMissing()) { + return this.semanticInfoChain.anyTypeSymbol; + } + + var rhsName = (dottedNameAST.operand2).text(); + var prevCanUseTypeSymbol = context.canUseTypeSymbol; + context.canUseTypeSymbol = true; + var lhs = this.resolveAST(dottedNameAST.operand1, false, enclosingDecl, context); + context.canUseTypeSymbol = prevCanUseTypeSymbol; + var lhsType = lhs.type; + + if (lhs.isAlias()) { + (lhs).isUsedAsValue = true; + lhsType = (lhs).getExportAssignedTypeSymbol(); + } + + if (this.isAnyOrEquivalent(lhsType)) { + return lhsType; + } + + if (lhsType.isAlias()) { + lhsType = (lhsType).getExportAssignedTypeSymbol(); + } + + if (!lhsType) { + context.postError(this.unitPath, dottedNameAST.operand2.minChar, dottedNameAST.operand2.getLength(), TypeScript.DiagnosticCode.Could_not_find_enclosing_symbol_for_dotted_name_0, [(dottedNameAST.operand2).actualText], enclosingDecl); + return this.getNewErrorTypeSymbol(null); + } + + if ((lhsType === this.semanticInfoChain.numberTypeSymbol || (lhs.kind == 67108864 /* EnumMember */)) && this.cachedNumberInterfaceType()) { + lhsType = this.cachedNumberInterfaceType(); + } else if (lhsType === this.semanticInfoChain.stringTypeSymbol && this.cachedStringInterfaceType()) { + lhsType = this.cachedStringInterfaceType(); + } else if (lhsType === this.semanticInfoChain.booleanTypeSymbol && this.cachedBooleanInterfaceType()) { + lhsType = this.cachedBooleanInterfaceType(); + } + + if (!lhsType.isResolved) { + var potentiallySpecializedType = this.resolveDeclaredSymbol(lhsType, enclosingDecl, context); + + if (potentiallySpecializedType != lhsType) { + if (!lhs.isType()) { + context.setTypeInContext(lhs, potentiallySpecializedType); + } + + lhsType = potentiallySpecializedType; + } + } + + if (lhsType.isContainer() && !lhsType.isAlias()) { + var instanceSymbol = (lhsType).getInstanceSymbol(); + + if (instanceSymbol) { + lhsType = instanceSymbol.type; + } + } + + if (this.isPrototypeMember(dottedNameAST, enclosingDecl, context)) { + if (lhsType.isClass()) { + this.checkForStaticMemberAccess(dottedNameAST, lhsType, lhsType, enclosingDecl, context); + return lhsType; + } else { + var classInstanceType = lhsType.getAssociatedContainerType(); + + if (classInstanceType && classInstanceType.isClass()) { + this.checkForStaticMemberAccess(dottedNameAST, lhsType, classInstanceType, enclosingDecl, context); + return classInstanceType; + } + } + } + + if (lhsType.isTypeParameter()) { + lhsType = this.substituteUpperBoundForType(lhsType); + } + + var nameSymbol = null; + if (!(lhs.isType() && (lhs).isClass() && this.isNameOrMemberAccessExpression(dottedNameAST.operand1)) && !nameSymbol) { + nameSymbol = this.getMemberSymbol(rhsName, TypeScript.PullElementKind.SomeValue, lhsType); + nameSymbol = this.resolveNameSymbol(nameSymbol, context); + } + + if (!nameSymbol) { + if (lhsType.isClass()) { + var staticType = lhsType.getConstructorMethod().type; + + nameSymbol = this.getMemberSymbol(rhsName, TypeScript.PullElementKind.SomeValue, staticType); + + if (!nameSymbol) { + nameSymbol = this.getMemberSymbol(rhsName, TypeScript.PullElementKind.SomeValue, lhsType); + } + } else if ((lhsType.getCallSignatures().length || lhsType.getConstructSignatures().length) && this.cachedFunctionInterfaceType()) { + nameSymbol = this.getMemberSymbol(rhsName, TypeScript.PullElementKind.SomeValue, this.cachedFunctionInterfaceType()); + } else if (lhsType.isContainer()) { + var containerType = lhsType; + var associatedInstance = containerType.getInstanceSymbol(); + + if (associatedInstance) { + var instanceType = associatedInstance.type; + + nameSymbol = this.getMemberSymbol(rhsName, TypeScript.PullElementKind.SomeValue, instanceType); + } + } else { + var associatedType = lhsType.getAssociatedContainerType(); + + if (associatedType && !associatedType.isClass()) { + nameSymbol = this.getMemberSymbol(rhsName, TypeScript.PullElementKind.SomeValue, associatedType); + } + } + + nameSymbol = this.resolveNameSymbol(nameSymbol, context); + + if (!nameSymbol && !lhsType.isPrimitive() && this.cachedObjectInterfaceType()) { + nameSymbol = this.getMemberSymbol(rhsName, TypeScript.PullElementKind.SomeValue, this.cachedObjectInterfaceType()); + } + + if (!nameSymbol) { + context.postError(this.unitPath, dottedNameAST.operand2.minChar, dottedNameAST.operand2.getLength(), TypeScript.DiagnosticCode.The_property_0_does_not_exist_on_value_of_type_1, [(dottedNameAST.operand2).actualText, lhsType.toString(enclosingDecl ? enclosingDecl.getSymbol() : null)], enclosingDecl); + return this.getNewErrorTypeSymbol(null, rhsName); + } + } + + if (context.typeCheck()) { + this.checkForSuperMemberAccess(dottedNameAST, nameSymbol, enclosingDecl, context) || this.checkForPrivateMemberAccess(dottedNameAST, lhsType, nameSymbol, enclosingDecl, context) || this.checkForStaticMemberAccess(dottedNameAST, lhsType, nameSymbol, enclosingDecl, context); + } + + return nameSymbol; + }; + + PullTypeResolver.prototype.resolveTypeNameExpression = function (nameAST, enclosingDecl, context) { + var typeNameSymbol = this.getSymbolForAST(nameAST); + + if (!typeNameSymbol || !typeNameSymbol.isType()) { + typeNameSymbol = this.computeTypeNameExpression(nameAST, enclosingDecl, context); + this.setSymbolForAST(nameAST, typeNameSymbol, context); + } + + if (!typeNameSymbol.isResolved) { + var savedResolvingNamespaceMemberAccess = context.resolvingNamespaceMemberAccess; + context.resolvingNamespaceMemberAccess = false; + this.resolveDeclaredSymbol(typeNameSymbol, enclosingDecl, context); + context.resolvingNamespaceMemberAccess = savedResolvingNamespaceMemberAccess; + } + + if (typeNameSymbol && !(typeNameSymbol.isTypeParameter() && (typeNameSymbol).isFunctionTypeParameter() && context.isSpecializingSignatureAtCallSite && !context.isSpecializingConstructorMethod)) { + var substitution = context.findSpecializationForType(typeNameSymbol); + + if (typeNameSymbol.isTypeParameter() && (substitution != typeNameSymbol)) { + if (TypeScript.shouldSpecializeTypeParameterForTypeParameter(substitution, typeNameSymbol)) { + typeNameSymbol = substitution; + } + } + } + + return typeNameSymbol; + }; + + PullTypeResolver.prototype.computeTypeNameExpression = function (nameAST, enclosingDecl, context) { + if (nameAST.isMissing()) { + return this.semanticInfoChain.anyTypeSymbol; + } + + var id = nameAST.text(); + + if (id === "any") { + return this.semanticInfoChain.anyTypeSymbol; + } else if (id === "string") { + return this.semanticInfoChain.stringTypeSymbol; + } else if (id === "number") { + return this.semanticInfoChain.numberTypeSymbol; + } else if (id === "boolean") { + return this.semanticInfoChain.booleanTypeSymbol; + } else if (id === "void") { + return this.semanticInfoChain.voidTypeSymbol; + } else { + var declPath = enclosingDecl !== null ? TypeScript.getPathToDecl(enclosingDecl) : []; + + if (enclosingDecl && !declPath.length) { + declPath = [enclosingDecl]; + } + + var kindToCheckFirst = context.resolvingNamespaceMemberAccess ? TypeScript.PullElementKind.SomeContainer : TypeScript.PullElementKind.SomeType; + var kindToCheckSecond = context.resolvingNamespaceMemberAccess ? TypeScript.PullElementKind.SomeType : TypeScript.PullElementKind.SomeContainer; + + var typeNameSymbol = this.getSymbolFromDeclPath(id, declPath, kindToCheckFirst); + + if (!typeNameSymbol) { + typeNameSymbol = this.getSymbolFromDeclPath(id, declPath, kindToCheckSecond); + } + + if (!typeNameSymbol) { + context.postError(this.unitPath, nameAST.minChar, nameAST.getLength(), TypeScript.DiagnosticCode.Could_not_find_symbol_0, [nameAST.actualText], enclosingDecl); + return this.getNewErrorTypeSymbol(null, id); + } + + var typeNameSymbolAlias = null; + if (typeNameSymbol.isAlias()) { + typeNameSymbolAlias = typeNameSymbol; + if (!typeNameSymbol.isResolved) { + var savedResolvingNamespaceMemberAccess = context.resolvingNamespaceMemberAccess; + context.resolvingNamespaceMemberAccess = false; + this.resolveDeclaredSymbol(typeNameSymbol, enclosingDecl, context); + context.resolvingNamespaceMemberAccess = savedResolvingNamespaceMemberAccess; + } + + var aliasedType = typeNameSymbolAlias.getExportAssignedTypeSymbol(); + + if (aliasedType && !aliasedType.isResolved) { + this.resolveDeclaredSymbol(aliasedType, enclosingDecl, context); + } + } + + if (typeNameSymbol.isTypeParameter()) { + if (enclosingDecl && (enclosingDecl.kind & TypeScript.PullElementKind.SomeFunction) && (enclosingDecl.flags & 16 /* Static */)) { + var parentDecl = typeNameSymbol.getDeclarations()[0].getParentDecl(); + + if (parentDecl.kind == 8 /* Class */) { + context.postError(this.unitPath, nameAST.minChar, nameAST.getLength(), TypeScript.DiagnosticCode.Static_methods_cannot_reference_class_type_parameters, null, enclosingDecl); + return this.getNewErrorTypeSymbol(null); + } + } + } + } + + return typeNameSymbol; + }; + + PullTypeResolver.prototype.resolveGenericTypeReference = function (genericTypeAST, enclosingDecl, context) { + var savedResolvingTypeReference = context.resolvingTypeReference; + context.resolvingTypeReference = true; + var genericTypeSymbol = this.resolveAST(genericTypeAST.name, false, enclosingDecl, context).type; + context.resolvingTypeReference = savedResolvingTypeReference; + + if (genericTypeSymbol.isError()) { + return genericTypeSymbol; + } + + if (!genericTypeSymbol.inResolution && !genericTypeSymbol.isResolved) { + this.resolveDeclaredSymbol(genericTypeSymbol, enclosingDecl, context); + } + + if (genericTypeSymbol.isAlias()) { + genericTypeSymbol = (genericTypeSymbol).getExportAssignedTypeSymbol(); + } + + var typeArgs = []; + + if (!context.isResolvingTypeArguments(genericTypeAST)) { + context.startResolvingTypeArguments(genericTypeAST); + var savedIsResolvingClassExtendedType = context.isResolvingClassExtendedType; + context.isResolvingClassExtendedType = false; + + if (genericTypeAST.typeArguments && genericTypeAST.typeArguments.members.length) { + for (var i = 0; i < genericTypeAST.typeArguments.members.length; i++) { + var typeArg = this.resolveTypeReference(genericTypeAST.typeArguments.members[i], enclosingDecl, context); + + if (this.genericTypeIsUsedWithoutRequiredTypeArguments(typeArg, genericTypeAST.typeArguments.members[i], context)) { + context.postError(this.unitPath, genericTypeAST.typeArguments.members[i].minChar, genericTypeAST.typeArguments.members[i].getLength(), TypeScript.DiagnosticCode.Generic_type_references_must_include_all_type_arguments, null, enclosingDecl); + typeArg = this.specializeTypeToAny(typeArg, enclosingDecl, context); + } + + if (!(typeArg.isTypeParameter() && (typeArg).isFunctionTypeParameter() && context.isSpecializingSignatureAtCallSite && !context.isSpecializingConstructorMethod)) { + typeArgs[i] = context.findSpecializationForType(typeArg); + } else { + typeArgs[i] = typeArg; + } + } + } + context.isResolvingClassExtendedType = savedIsResolvingClassExtendedType; + context.doneResolvingTypeArguments(); + } + + var typeParameters = genericTypeSymbol.getTypeParameters(); + + if (typeArgs.length && typeArgs.length != typeParameters.length) { + context.postError(this.unitPath, genericTypeAST.minChar, genericTypeAST.getLength(), TypeScript.DiagnosticCode.Generic_type_0_requires_1_type_argument_s, [genericTypeSymbol.toString(), genericTypeSymbol.getTypeParameters().length], enclosingDecl); + return this.getNewErrorTypeSymbol(null); + } + + var specializedSymbol = TypeScript.specializeType(genericTypeSymbol, typeArgs, this, enclosingDecl, context, genericTypeAST); + + var typeConstraint = null; + var upperBound = null; + + for (var iArg = 0; (iArg < typeArgs.length) && (iArg < typeParameters.length); iArg++) { + typeArg = typeArgs[iArg]; + typeConstraint = typeParameters[iArg].getConstraint(); + + if (typeConstraint) { + if (typeConstraint.isTypeParameter()) { + for (var j = 0; j < typeParameters.length && j < typeArgs.length; j++) { + if (typeParameters[j] == typeConstraint) { + typeConstraint = typeArgs[j]; + } + } + } + + if (typeArg.isTypeParameter()) { + upperBound = (typeArg).getConstraint(); + + if (upperBound) { + typeArg = upperBound; + } + } + + if (typeArg.inResolution) { + return specializedSymbol; + } + if (!this.sourceIsAssignableToTarget(typeArg, typeConstraint, context)) { + context.postError(this.unitPath, genericTypeAST.minChar, genericTypeAST.getLength(), TypeScript.DiagnosticCode.Type_0_does_not_satisfy_the_constraint_1_for_type_parameter_2, [typeArg.toString(null, true), typeConstraint.toString(null, true), typeParameters[iArg].toString(null, true)], enclosingDecl); + } + } + } + + return specializedSymbol; + }; + + PullTypeResolver.prototype.resolveDottedTypeNameExpression = function (dottedNameAST, enclosingDecl, context) { + var symbol = this.getSymbolForAST(dottedNameAST); + if (!symbol) { + symbol = this.computeDottedTypeNameExpression(dottedNameAST, enclosingDecl, context); + this.setSymbolForAST(dottedNameAST, symbol, context); + } + + if (!symbol.isResolved) { + this.resolveDeclaredSymbol(symbol, enclosingDecl, context); + } + + return symbol; + }; + + PullTypeResolver.prototype.computeDottedTypeNameExpression = function (dottedNameAST, enclosingDecl, context) { + if ((dottedNameAST.operand2).isMissing()) { + return this.semanticInfoChain.anyTypeSymbol; + } + + var rhsName = (dottedNameAST.operand2).text(); + + var savedResolvingTypeReference = context.resolvingTypeReference; + var savedResolvingNamespaceMemberAccess = context.resolvingNamespaceMemberAccess; + context.resolvingNamespaceMemberAccess = true; + context.resolvingTypeReference = true; + var lhs = this.resolveAST(dottedNameAST.operand1, false, enclosingDecl, context); + context.resolvingTypeReference = savedResolvingTypeReference; + context.resolvingNamespaceMemberAccess = savedResolvingNamespaceMemberAccess; + + var lhsType = lhs.isAlias() ? (lhs).getExportAssignedTypeSymbol() : lhs.type; + + if (context.isResolvingClassExtendedType) { + if (lhs.isAlias()) { + (lhs).isUsedAsValue = true; + } + } + + if (this.isAnyOrEquivalent(lhsType)) { + return lhsType; + } + + if (!lhsType) { + context.postError(this.unitPath, dottedNameAST.operand2.minChar, dottedNameAST.operand2.getLength(), TypeScript.DiagnosticCode.Could_not_find_enclosing_symbol_for_dotted_name_0, [(dottedNameAST.operand2).actualText], enclosingDecl); + return this.getNewErrorTypeSymbol(null); + } + + var memberKind = context.resolvingNamespaceMemberAccess ? TypeScript.PullElementKind.SomeContainer : TypeScript.PullElementKind.SomeType; + var childTypeSymbol = this.getMemberSymbol(rhsName, memberKind, lhsType); + + if (!childTypeSymbol && lhsType.isContainer()) { + var exportedContainer = (lhsType).getExportAssignedContainerSymbol(); + + if (exportedContainer) { + childTypeSymbol = this.getMemberSymbol(rhsName, memberKind, exportedContainer); + } + } + + if (!childTypeSymbol && enclosingDecl) { + var parentDecl = enclosingDecl; + + while (parentDecl) { + if (parentDecl.kind & TypeScript.PullElementKind.SomeContainer) { + break; + } + + parentDecl = parentDecl.getParentDecl(); + } + + if (parentDecl) { + var enclosingSymbolType = parentDecl.getSymbol().type; + + if (enclosingSymbolType === lhsType) { + childTypeSymbol = this.getMemberSymbol(rhsName, memberKind, lhsType); + } + } + } + + if (!childTypeSymbol) { + context.postError(this.unitPath, dottedNameAST.operand2.minChar, dottedNameAST.operand2.getLength(), TypeScript.DiagnosticCode.The_property_0_does_not_exist_on_value_of_type_1, [(dottedNameAST.operand2).actualText, lhsType.toString(enclosingDecl ? enclosingDecl.getSymbol() : null)], enclosingDecl); + return this.getNewErrorTypeSymbol(null, rhsName); + } + + return childTypeSymbol; + }; + + PullTypeResolver.prototype.resolveFunctionExpression = function (funcDeclAST, inContextuallyTypedAssignment, enclosingDecl, context) { + var _this = this; + var funcDeclSymbol = null; + var functionDecl = this.getDeclForAST(funcDeclAST); + + if (functionDecl && functionDecl.hasSymbol()) { + funcDeclSymbol = functionDecl.getSymbol(); + if (funcDeclSymbol.isResolved) { + return funcDeclSymbol; + } + } + + var shouldContextuallyType = inContextuallyTypedAssignment; + + var assigningFunctionTypeSymbol = null; + var assigningFunctionSignature = null; + + if (funcDeclAST.returnTypeAnnotation) { + shouldContextuallyType = false; + } + + if (shouldContextuallyType && funcDeclAST.arguments) { + for (var i = 0; i < funcDeclAST.arguments.members.length; i++) { + var parameter = funcDeclAST.arguments.members[i]; + if (parameter.typeExpr) { + shouldContextuallyType = false; + break; + } + } + } + + if (shouldContextuallyType) { + assigningFunctionTypeSymbol = context.getContextualType(); + + if (assigningFunctionTypeSymbol) { + this.resolveDeclaredSymbol(assigningFunctionTypeSymbol, enclosingDecl, context); + + if (assigningFunctionTypeSymbol) { + assigningFunctionSignature = assigningFunctionTypeSymbol.getCallSignatures()[0]; + } + } + } + + if (!functionDecl) { + var semanticInfo = this.semanticInfoChain.getUnit(this.unitPath); + var declCollectionContext = new TypeScript.DeclCollectionContext(semanticInfo, this.unitPath); + + if (enclosingDecl) { + declCollectionContext.pushParent(enclosingDecl); + } + + TypeScript.getAstWalkerFactory().walk(funcDeclAST, TypeScript.preCollectDecls, TypeScript.postCollectDecls, null, declCollectionContext); + + functionDecl = this.getDeclForAST(funcDeclAST); + this.currentUnit.addSynthesizedDecl(functionDecl); + + var binder = new TypeScript.PullSymbolBinder(this.semanticInfoChain); + binder.setUnit(this.unitPath); + binder.bindFunctionExpressionToPullSymbol(functionDecl); + } + + funcDeclSymbol = functionDecl.getSymbol(); + var funcDeclType = funcDeclSymbol.type; + var signature = funcDeclType.getCallSignatures()[0]; + funcDeclSymbol.startResolving(); + + if (funcDeclAST.arguments) { + var contextParams = []; + + if (assigningFunctionSignature) { + contextParams = assigningFunctionSignature.parameters; + } + + var contextualParametersCount = contextParams.length; + for (var i = 0, n = funcDeclAST.arguments.members.length; i < n; i++) { + var actualParameter = funcDeclAST.arguments.members[i]; + + var actualParameterIsVarArgParameter = funcDeclAST.variableArgList && i === n - 1; + var correspondingContextualParameter = null; + var contextualParameterType = null; + + if (i < contextualParametersCount) { + correspondingContextualParameter = contextParams[i]; + } else if (contextualParametersCount && contextParams[contextualParametersCount - 1].isVarArg) { + correspondingContextualParameter = contextParams[contextualParametersCount - 1]; + } + + if (correspondingContextualParameter) { + if (correspondingContextualParameter.isVarArg === actualParameterIsVarArgParameter) { + contextualParameterType = correspondingContextualParameter.type; + } else if (correspondingContextualParameter.isVarArg) { + contextualParameterType = correspondingContextualParameter.type.getElementType(); + } + } + + this.resolveFunctionExpressionParameter(actualParameter, contextualParameterType, functionDecl, context); + } + } + + if (funcDeclAST.returnTypeAnnotation) { + var returnTypeSymbol = this.resolveTypeReference(funcDeclAST.returnTypeAnnotation, functionDecl, context); + + signature.returnType = returnTypeSymbol; + } else { + if (assigningFunctionSignature) { + var returnType = assigningFunctionSignature.returnType; + + if (returnType) { + context.pushContextualType(returnType, context.inProvisionalResolution(), null); + + this.resolveFunctionBodyReturnTypes(funcDeclAST, signature, true, functionDecl, context); + context.popContextualType(); + } else { + signature.returnType = this.semanticInfoChain.anyTypeSymbol; + + if (this.compilationSettings.noImplicitAny && !context.isInInvocationExpression) { + var functionExpressionName = (functionDecl).getFunctionExpressionName(); + + if (functionExpressionName != "") { + context.postError(this.unitPath, funcDeclAST.minChar, funcDeclAST.getLength(), TypeScript.DiagnosticCode._0_which_lacks_return_type_annotation_implicitly_has_an_any_return_type, [functionExpressionName], functionDecl); + } else { + context.postError(this.unitPath, funcDeclAST.minChar, funcDeclAST.getLength(), TypeScript.DiagnosticCode.Function_expression_which_lacks_return_type_annotation_implicitly_has_an_any_return_type, [], functionDecl); + } + } + } + } else { + this.resolveFunctionBodyReturnTypes(funcDeclAST, signature, false, functionDecl, context); + } + } + + funcDeclSymbol.type = funcDeclType; + funcDeclSymbol.setResolved(); + + if (context.typeCheck()) { + PullTypeResolver.typeCheckCallBacks.push(function () { + _this.setUnitPath(functionDecl.getScriptName()); + _this.seenSuperConstructorCall = false; + + _this.resolveAST(funcDeclAST.block, false, functionDecl, context); + + _this.validateVariableDeclarationGroups(functionDecl, context); + + var hasReturn = (functionDecl.flags & (2048 /* Signature */ | 4194304 /* HasReturnStatement */)) != 0; + + if (funcDeclAST.block && funcDeclAST.returnTypeAnnotation != null && !hasReturn) { + var isVoidOrAny = _this.isAnyOrEquivalent(returnTypeSymbol) || returnTypeSymbol === _this.semanticInfoChain.voidTypeSymbol; + + if (!isVoidOrAny && !(funcDeclAST.block.statements.members.length > 0 && funcDeclAST.block.statements.members[0].nodeType() === 96 /* ThrowStatement */)) { + var funcName = functionDecl.getDisplayName(); + funcName = funcName ? "'" + funcName + "'" : "expression"; + + context.postError(_this.unitPath, funcDeclAST.returnTypeAnnotation.minChar, funcDeclAST.returnTypeAnnotation.getLength(), TypeScript.DiagnosticCode.Function_0_declared_a_non_void_return_type_but_has_no_return_expression, [funcName], enclosingDecl); + } + } + + _this.typeCheckFunctionOverloads(funcDeclAST, context); + }); + } + + return funcDeclSymbol; + }; + + PullTypeResolver.prototype.resolveThisExpression = function (ast, enclosingDecl, context) { + var symbol = this.getSymbolForAST(ast); + + if (!symbol) { + symbol = this.computeThisExpressionSymbol(ast, enclosingDecl, context); + this.setSymbolForAST(ast, symbol, context); + } + + this.checkForThisOrSuperCaptureInArrowFunction(ast, enclosingDecl); + + return symbol; + }; + + PullTypeResolver.prototype.computeThisExpressionSymbol = function (ast, enclosingDecl, context) { + if (enclosingDecl) { + var enclosingDeclKind = enclosingDecl.kind; + var diagnostics; + var thisTypeSymbol = this.semanticInfoChain.anyTypeSymbol; + var classDecl = null; + + if (!(enclosingDeclKind & (TypeScript.PullElementKind.SomeFunction | 1 /* Script */ | TypeScript.PullElementKind.SomeBlock | 8 /* Class */))) { + thisTypeSymbol = this.getNewErrorTypeSymbol(null); + } else { + var declPath = TypeScript.getPathToDecl(enclosingDecl); + + if (declPath.length) { + var isStaticContext = false; + for (var i = declPath.length - 1; i >= 0; i--) { + var decl = declPath[i]; + var declKind = decl.kind; + var declFlags = decl.flags; + + if (declFlags & 16 /* Static */) { + isStaticContext = true; + } else if (declKind === 131072 /* FunctionExpression */ && !TypeScript.hasFlag(declFlags, 8192 /* FatArrow */)) { + break; + } else if (declKind === 16384 /* Function */) { + break; + } else if (declKind === 8 /* Class */) { + if (context.isInStaticInitializer) { + thisTypeSymbol = this.getNewErrorTypeSymbol(null); + } else { + var classSymbol = decl.getSymbol(); + classDecl = decl; + if (isStaticContext) { + var constructorSymbol = classSymbol.getConstructorMethod(); + thisTypeSymbol = constructorSymbol.type; + } else { + thisTypeSymbol = classSymbol; + } + } + break; + } + } + } + } + } + + if (context.typeCheck()) { + var thisExpressionAST = ast; + var enclosingNonLambdaDecl = this.getEnclosingNonLambdaDecl(enclosingDecl); + + if (context.isResolvingSuperConstructorTarget && this.superCallMustBeFirstStatementInConstructor(enclosingDecl, classDecl)) { + context.postError(this.unitPath, thisExpressionAST.minChar, thisExpressionAST.getLength(), TypeScript.DiagnosticCode.this_cannot_be_referenced_in_current_location, null, enclosingDecl); + } else if (enclosingNonLambdaDecl) { + if (enclosingNonLambdaDecl.kind === 8 /* Class */ && context.isInStaticInitializer) { + context.postError(this.unitPath, thisExpressionAST.minChar, thisExpressionAST.getLength(), TypeScript.DiagnosticCode.this_cannot_be_referenced_in_static_initializers_in_a_class_body, null, enclosingDecl); + } else if (enclosingNonLambdaDecl.kind === 4 /* Container */ || enclosingNonLambdaDecl.kind === 32 /* DynamicModule */) { + context.postError(this.unitPath, thisExpressionAST.minChar, thisExpressionAST.getLength(), TypeScript.DiagnosticCode.this_cannot_be_referenced_within_module_bodies, null, enclosingDecl); + } else if (context.inConstructorArguments) { + context.postError(this.unitPath, thisExpressionAST.minChar, thisExpressionAST.getLength(), TypeScript.DiagnosticCode.this_cannot_be_referenced_in_constructor_arguments, null, enclosingDecl); + } + } + } + + return thisTypeSymbol; + }; + + PullTypeResolver.prototype.getEnclosingNonLambdaDecl = function (enclosingDecl) { + var declPath = enclosingDecl !== null ? TypeScript.getPathToDecl(enclosingDecl) : []; + + if (declPath.length) { + for (var i = declPath.length - 1; i >= 0; i--) { + var decl = declPath[i]; + if (!(decl.kind === 131072 /* FunctionExpression */ && (decl.flags & 8192 /* FatArrow */))) { + return decl; + } + } + } + + return null; + }; + + PullTypeResolver.prototype.resolveSuperExpression = function (ast, enclosingDecl, context) { + if (!enclosingDecl) { + return this.semanticInfoChain.anyTypeSymbol; + } + + var declPath = enclosingDecl !== null ? TypeScript.getPathToDecl(enclosingDecl) : []; + var classSymbol = null; + var superType = this.semanticInfoChain.anyTypeSymbol; + + if (declPath.length) { + for (var i = declPath.length - 1; i >= 0; i--) { + var decl = declPath[i]; + var declFlags = decl.flags; + + if (decl.kind === 131072 /* FunctionExpression */ && !(declFlags & 8192 /* FatArrow */)) { + break; + } else if (declFlags & 16 /* Static */) { + break; + } else if (decl.kind === 8 /* Class */) { + classSymbol = decl.getSymbol(); + + break; + } + } + } + + if (classSymbol) { + if (!classSymbol.isResolved) { + this.resolveDeclaredSymbol(classSymbol, enclosingDecl, context); + } + + var parents = classSymbol.getExtendedTypes(); + + if (parents.length) { + superType = parents[0]; + } + } + + if (context.typeCheck()) { + var nonLambdaEnclosingDecl = this.getEnclosingNonLambdaDecl(enclosingDecl); + + if (nonLambdaEnclosingDecl) { + var nonLambdaEnclosingDeclKind = nonLambdaEnclosingDecl.kind; + var inSuperConstructorTarget = context.isResolvingSuperConstructorTarget; + + if (inSuperConstructorTarget && enclosingDecl.kind !== 32768 /* ConstructorMethod */) { + context.postError(this.unitPath, ast.minChar, ast.getLength(), TypeScript.DiagnosticCode.Super_calls_are_not_permitted_outside_constructors_or_in_local_functions_inside_constructors, null, enclosingDecl); + } else if ((nonLambdaEnclosingDeclKind !== 65536 /* Method */ && nonLambdaEnclosingDeclKind !== 262144 /* GetAccessor */ && nonLambdaEnclosingDeclKind !== 524288 /* SetAccessor */ && nonLambdaEnclosingDeclKind !== 32768 /* ConstructorMethod */) || ((nonLambdaEnclosingDecl.flags & 16 /* Static */) !== 0)) { + context.postError(this.unitPath, ast.minChar, ast.getLength(), TypeScript.DiagnosticCode.super_property_access_is_permitted_only_in_a_constructor_instance_member_function_or_instance_member_accessor_of_a_derived_class, null, enclosingDecl); + } else if (!this.enclosingClassIsDerived(enclosingDecl)) { + context.postError(this.unitPath, ast.minChar, ast.getLength(), TypeScript.DiagnosticCode.super_cannot_be_referenced_in_non_derived_classes, null, enclosingDecl); + } + } + } + + this.checkForThisOrSuperCaptureInArrowFunction(ast, enclosingDecl); + + return superType; + }; + + PullTypeResolver.prototype.resolveObjectLiteralExpression = function (expressionAST, inContextuallyTypedAssignment, enclosingDecl, context, additionalResults) { + var symbol = this.getSymbolForAST(expressionAST); + + if (!symbol || additionalResults) { + symbol = this.computeObjectLiteralExpression(expressionAST, inContextuallyTypedAssignment, enclosingDecl, context, additionalResults); + this.setSymbolForAST(expressionAST, symbol, context); + } + + return symbol; + }; + + PullTypeResolver.prototype.computeObjectLiteralExpression = function (expressionAST, inContextuallyTypedAssignment, enclosingDecl, context, additionalResults) { + var objectLitAST = expressionAST; + var span = TypeScript.TextSpan.fromBounds(objectLitAST.minChar, objectLitAST.limChar); + + var objectLitDecl = new TypeScript.PullDecl("", "", 512 /* ObjectLiteral */, 0 /* None */, span, this.unitPath); + this.currentUnit.addSynthesizedDecl(objectLitDecl); + + if (enclosingDecl) { + objectLitDecl.setParentDecl(enclosingDecl); + } + + this.currentUnit.setDeclForAST(objectLitAST, objectLitDecl); + this.currentUnit.setASTForDecl(objectLitDecl, objectLitAST); + + var typeSymbol = new TypeScript.PullTypeSymbol("", 16 /* Interface */); + typeSymbol.addDeclaration(objectLitDecl); + objectLitDecl.setSymbol(typeSymbol); + + var memberDecls = objectLitAST.operand; + + var contextualType = null; + + if (inContextuallyTypedAssignment) { + contextualType = context.getContextualType(); + + this.resolveDeclaredSymbol(contextualType, enclosingDecl, context); + } + + if (memberDecls) { + var binex; + var memberSymbol; + var assigningSymbol = null; + var acceptedContextualType = false; + + if (additionalResults) { + additionalResults.membersContextTypeSymbols = []; + } + + for (var i = 0, len = memberDecls.members.length; i < len; i++) { + binex = memberDecls.members[i]; + + var id = binex.operand1; + var text; + var actualText; + + if (id.nodeType() === 21 /* Name */) { + actualText = (id).actualText; + text = (id).text(); + } else if (id.nodeType() === 5 /* StringLiteral */) { + actualText = (id).actualText; + text = (id).text(); + } else if (id.nodeType() === 7 /* NumericLiteral */) { + actualText = text = (id).text(); + } else { + return this.semanticInfoChain.anyTypeSymbol; + } + + span = TypeScript.TextSpan.fromBounds(binex.minChar, binex.limChar); + + var isAccessor = binex.operand2.nodeType() === 13 /* FunctionDeclaration */ && (binex.operand2).isAccessor(); + + if (!isAccessor) { + var decl = new TypeScript.PullDecl(text, actualText, 4096 /* Property */, 4 /* Public */, span, this.unitPath); + this.currentUnit.addSynthesizedDecl(decl); + + objectLitDecl.addChildDecl(decl); + decl.setParentDecl(objectLitDecl); + + this.semanticInfoChain.getUnit(this.unitPath).setDeclForAST(binex, decl); + this.semanticInfoChain.getUnit(this.unitPath).setASTForDecl(decl, binex); + + memberSymbol = new TypeScript.PullSymbol(text, 4096 /* Property */); + + memberSymbol.addDeclaration(decl); + decl.setSymbol(memberSymbol); + } + + if (contextualType) { + assigningSymbol = this.getMemberSymbol(text, TypeScript.PullElementKind.SomeValue, contextualType); + + if (assigningSymbol) { + this.resolveDeclaredSymbol(assigningSymbol, enclosingDecl, context); + + context.pushContextualType(assigningSymbol.type, context.inProvisionalResolution(), null); + + acceptedContextualType = true; + + if (additionalResults) { + additionalResults.membersContextTypeSymbols[i] = assigningSymbol.type; + } + } + } + + if (isAccessor) { + var funcDeclAST = binex.operand2; + var semanticInfo = this.semanticInfoChain.getUnit(this.unitPath); + var declCollectionContext = new TypeScript.DeclCollectionContext(semanticInfo, this.unitPath); + + declCollectionContext.pushParent(objectLitDecl); + + TypeScript.getAstWalkerFactory().walk(funcDeclAST, TypeScript.preCollectDecls, TypeScript.postCollectDecls, null, declCollectionContext); + + var functionDecl = this.getDeclForAST(funcDeclAST); + this.currentUnit.addSynthesizedDecl(functionDecl); + + var binder = new TypeScript.PullSymbolBinder(this.semanticInfoChain); + binder.setUnit(this.unitPath); + + if (funcDeclAST.isGetAccessor()) { + binder.bindGetAccessorDeclarationToPullSymbol(functionDecl); + } else { + binder.bindSetAccessorDeclarationToPullSymbol(functionDecl); + } + } + + var memberExprType = this.resolveAST(binex.operand2, assigningSymbol != null, enclosingDecl, context); + + if (acceptedContextualType) { + context.popContextualType(); + acceptedContextualType = false; + } + + if (isAccessor) { + this.setSymbolForAST(binex.operand1, memberExprType, context); + } else { + context.setTypeInContext(memberSymbol, memberExprType.type); + memberSymbol.setResolved(); + + this.setSymbolForAST(binex.operand1, memberSymbol, context); + typeSymbol.addMember(memberSymbol); + } + } + } + + typeSymbol.setResolved(); + return typeSymbol; + }; + + PullTypeResolver.prototype.resolveArrayLiteralExpression = function (arrayLit, inContextuallyTypedAssignment, enclosingDecl, context) { + var symbol = this.getSymbolForAST(arrayLit); + if (!symbol) { + symbol = this.computeArrayLiteralExpressionSymbol(arrayLit, inContextuallyTypedAssignment, enclosingDecl, context); + this.setSymbolForAST(arrayLit, symbol, context); + } + + return symbol; + }; + + PullTypeResolver.prototype.computeArrayLiteralExpressionSymbol = function (arrayLit, inContextuallyTypedAssignment, enclosingDecl, context) { + var elements = arrayLit.operand; + var elementType = this.semanticInfoChain.anyTypeSymbol; + var elementTypes = []; + var comparisonInfo = new TypeComparisonInfo(); + var contextualElementType = null; + comparisonInfo.onlyCaptureFirstError = true; + + if (inContextuallyTypedAssignment) { + var contextualType = context.getContextualType(); + + this.resolveDeclaredSymbol(contextualType, enclosingDecl, context); + + if (contextualType) { + if (contextualType.isArray()) { + contextualElementType = contextualType.getElementType(); + } else { + var indexSignatures = contextualType.getIndexSignatures(); + for (var i = 0; i < indexSignatures.length; i++) { + var signature = indexSignatures[i]; + if (signature.parameters[0].type === this.semanticInfoChain.numberTypeSymbol) { + contextualElementType = signature.returnType; + break; + } + } + } + } + } + + if (elements) { + if (inContextuallyTypedAssignment) { + context.pushContextualType(contextualElementType, context.inProvisionalResolution(), null); + } + + for (var i = 0; i < elements.members.length; i++) { + elementTypes[elementTypes.length] = this.resolveAST(elements.members[i], inContextuallyTypedAssignment, enclosingDecl, context).type; + } + + if (inContextuallyTypedAssignment) { + context.popContextualType(); + } + } + + if (this.compilationSettings.noImplicitAny && !context.isInInvocationExpression) { + if (!inContextuallyTypedAssignment && elements.members.length == 0) { + context.postError(this.unitPath, arrayLit.minChar, arrayLit.getLength(), TypeScript.DiagnosticCode.Array_Literal_implicitly_has_an_any_type_from_widening, [], enclosingDecl); + } + } + + if (contextualElementType && !contextualElementType.isTypeParameter()) { + elementType = contextualElementType; + + for (var i = 0; i < elementTypes.length; i++) { + var comparisonInfo = new TypeComparisonInfo(); + var currentElementType = elementTypes[i]; + var currentElementAST = elements.members[i]; + if (!this.sourceIsAssignableToTarget(currentElementType, contextualElementType, context, comparisonInfo)) { + var message; + if (comparisonInfo.message) { + message = context.postError(this.getUnitPath(), currentElementAST.minChar, currentElementAST.getLength(), TypeScript.DiagnosticCode.Cannot_convert_0_to_1_NL_2, [currentElementType.toString(), contextualElementType.toString(), comparisonInfo.message], enclosingDecl); + } else { + message = context.postError(this.getUnitPath(), currentElementAST.minChar, currentElementAST.getLength(), TypeScript.DiagnosticCode.Cannot_convert_0_to_1, [currentElementType.toString(), contextualElementType.toString()], enclosingDecl); + } + + return this.getNewErrorTypeSymbol(null); + } + } + } else { + if (elementTypes.length) { + elementType = elementTypes[0]; + } else if (contextualElementType) { + elementType = contextualElementType; + } + + var collection = { + getLength: function () { + return elements.members.length; + }, + setTypeAtIndex: function (index, type) { + elementTypes[index] = type; + }, + getTypeAtIndex: function (index) { + return elementTypes[index]; + } + }; + + elementType = this.findBestCommonType(elementType, null, collection, context, comparisonInfo); + + if (elementType === this.semanticInfoChain.undefinedTypeSymbol || elementType === this.semanticInfoChain.nullTypeSymbol) { + elementType = this.semanticInfoChain.anyTypeSymbol; + + if (this.compilationSettings.noImplicitAny && !inContextuallyTypedAssignment && !context.isInInvocationExpression) { + context.postError(this.unitPath, arrayLit.minChar, arrayLit.getLength(), TypeScript.DiagnosticCode.Array_Literal_implicitly_has_an_any_type_from_widening, [], enclosingDecl); + } + } + + if (!elementType) { + elementType = this.semanticInfoChain.anyTypeSymbol; + + if (this.compilationSettings.noImplicitAny && !inContextuallyTypedAssignment && !context.isInInvocationExpression) { + context.postError(this.unitPath, arrayLit.minChar, arrayLit.getLength(), TypeScript.DiagnosticCode.Array_Literal_implicitly_has_an_any_type_from_widening, [], enclosingDecl); + } + } else if (contextualElementType && !contextualElementType.isTypeParameter()) { + if (this.sourceIsAssignableToTarget(elementType, contextualElementType, context)) { + elementType = contextualType; + } + } + } + + var arraySymbol = elementType.getArrayType(); + + if (!arraySymbol) { + if (!this.cachedArrayInterfaceType().isResolved) { + this.resolveDeclaredSymbol(this.cachedArrayInterfaceType(), enclosingDecl, context); + } + + arraySymbol = TypeScript.specializeType(this.cachedArrayInterfaceType(), [elementType], this, this.cachedArrayInterfaceType().getDeclarations()[0], context, arrayLit); + + if (!arraySymbol) { + arraySymbol = this.semanticInfoChain.anyTypeSymbol; + } + } + + return arraySymbol; + }; + + PullTypeResolver.prototype.resolveIndexExpression = function (callEx, inContextuallyTypedAssignment, enclosingDecl, context) { + var symbol = this.getSymbolForAST(callEx); + if (!symbol) { + symbol = this.computeIndexExpressionSymbol(callEx, inContextuallyTypedAssignment, enclosingDecl, context); + this.setSymbolForAST(callEx, symbol, context); + } + + return symbol; + }; + + PullTypeResolver.prototype.computeIndexExpressionSymbol = function (callEx, inContextuallyTypedAssignment, enclosingDecl, context) { + var targetSymbol = this.resolveAST(callEx.operand1, inContextuallyTypedAssignment, enclosingDecl, context); + + var targetTypeSymbol = targetSymbol.type; + + if (this.isAnyOrEquivalent(targetTypeSymbol)) { + return targetTypeSymbol; + } + + var elementType = targetTypeSymbol.getElementType(); + + var indexType = this.resolveAST(callEx.operand2, inContextuallyTypedAssignment, enclosingDecl, context).type; + + var isNumberIndex = indexType === this.semanticInfoChain.numberTypeSymbol || TypeScript.PullHelpers.symbolIsEnum(indexType); + + if (elementType && isNumberIndex) { + return elementType; + } + + if (callEx.operand2.nodeType() === 5 /* StringLiteral */ || callEx.operand2.nodeType() === 7 /* NumericLiteral */) { + var memberName = callEx.operand2.nodeType() === 5 /* StringLiteral */ ? TypeScript.stripQuotes((callEx.operand2).actualText) : (callEx.operand2).value.toString(); + + var member = this.getMemberSymbol(memberName, TypeScript.PullElementKind.SomeValue, targetTypeSymbol); + + if (member) { + return member.type; + } + } + + var signatures = targetTypeSymbol.getIndexSignatures(); + + var stringSignature = null; + var numberSignature = null; + var signature = null; + var paramSymbols; + var paramType; + + for (var i = 0; i < signatures.length; i++) { + if (stringSignature && numberSignature) { + break; + } + + signature = signatures[i]; + + paramSymbols = signature.parameters; + + if (paramSymbols.length) { + paramType = paramSymbols[0].type; + + if (paramType === this.semanticInfoChain.stringTypeSymbol) { + stringSignature = signatures[i]; + continue; + } else if (paramType === this.semanticInfoChain.numberTypeSymbol || paramType.kind === 64 /* Enum */) { + numberSignature = signatures[i]; + continue; + } + } + } + + if (numberSignature && (isNumberIndex || indexType === this.semanticInfoChain.anyTypeSymbol)) { + var returnType = numberSignature.returnType; + + if (!returnType) { + returnType = this.semanticInfoChain.anyTypeSymbol; + } + + return returnType; + } else if (stringSignature && (isNumberIndex || indexType === this.semanticInfoChain.anyTypeSymbol || indexType === this.semanticInfoChain.stringTypeSymbol)) { + var returnType = stringSignature.returnType; + + if (!returnType) { + returnType = this.semanticInfoChain.anyTypeSymbol; + } + + return returnType; + } else if (isNumberIndex || indexType === this.semanticInfoChain.anyTypeSymbol || indexType === this.semanticInfoChain.stringTypeSymbol) { + var returnType = this.semanticInfoChain.anyTypeSymbol; + return returnType; + } else { + context.postError(this.getUnitPath(), callEx.minChar, callEx.getLength(), TypeScript.DiagnosticCode.Value_of_type_0_is_not_indexable_by_type_1, [targetTypeSymbol.toString(), indexType.toString()], enclosingDecl); + return this.getNewErrorTypeSymbol(null); + } + }; + + PullTypeResolver.prototype.resolveBitwiseOperator = function (expressionAST, inContextuallyTypedAssignment, enclosingDecl, context) { + var binex = expressionAST; + + var leftType = this.resolveAST(binex.operand1, inContextuallyTypedAssignment, enclosingDecl, context).type; + var rightType = this.resolveAST(binex.operand2, inContextuallyTypedAssignment, enclosingDecl, context).type; + + if (this.sourceIsSubtypeOfTarget(leftType, this.semanticInfoChain.numberTypeSymbol, context) && this.sourceIsSubtypeOfTarget(rightType, this.semanticInfoChain.numberTypeSymbol, context)) { + return this.semanticInfoChain.numberTypeSymbol; + } else if ((leftType === this.semanticInfoChain.booleanTypeSymbol) && (rightType === this.semanticInfoChain.booleanTypeSymbol)) { + return this.semanticInfoChain.booleanTypeSymbol; + } else if (this.isAnyOrEquivalent(leftType)) { + if ((this.isAnyOrEquivalent(rightType) || (rightType === this.semanticInfoChain.numberTypeSymbol) || (rightType === this.semanticInfoChain.booleanTypeSymbol))) { + return this.semanticInfoChain.anyTypeSymbol; + } + } else if (this.isAnyOrEquivalent(rightType)) { + if ((leftType === this.semanticInfoChain.numberTypeSymbol) || (leftType === this.semanticInfoChain.booleanTypeSymbol)) { + return this.semanticInfoChain.anyTypeSymbol; + } + } + + return this.semanticInfoChain.anyTypeSymbol; + }; + + PullTypeResolver.prototype.resolveBinaryAdditionOperation = function (binaryExpression, inContextuallyTypedAssignment, enclosingDecl, context) { + var lhsType = this.resolveAST(binaryExpression.operand1, false, enclosingDecl, context).type; + var rhsType = this.resolveAST(binaryExpression.operand2, false, enclosingDecl, context).type; + + if (TypeScript.PullHelpers.symbolIsEnum(lhsType)) { + lhsType = this.semanticInfoChain.numberTypeSymbol; + } else if (lhsType === this.semanticInfoChain.nullTypeSymbol || lhsType === this.semanticInfoChain.undefinedTypeSymbol) { + if (rhsType != this.semanticInfoChain.nullTypeSymbol && rhsType != this.semanticInfoChain.undefinedTypeSymbol) { + lhsType = rhsType; + } else { + lhsType = this.semanticInfoChain.anyTypeSymbol; + } + } + + if (TypeScript.PullHelpers.symbolIsEnum(rhsType)) { + rhsType = this.semanticInfoChain.numberTypeSymbol; + } else if (rhsType === this.semanticInfoChain.nullTypeSymbol || rhsType === this.semanticInfoChain.undefinedTypeSymbol) { + if (lhsType != this.semanticInfoChain.nullTypeSymbol && lhsType != this.semanticInfoChain.undefinedTypeSymbol) { + rhsType = lhsType; + } else { + rhsType = this.semanticInfoChain.anyTypeSymbol; + } + } + + var exprType = null; + + if (lhsType === this.semanticInfoChain.stringTypeSymbol || rhsType === this.semanticInfoChain.stringTypeSymbol) { + exprType = this.semanticInfoChain.stringTypeSymbol; + } else if (this.isAnyOrEquivalent(lhsType) || this.isAnyOrEquivalent(rhsType)) { + exprType = this.semanticInfoChain.anyTypeSymbol; + } else if (rhsType === this.semanticInfoChain.numberTypeSymbol && lhsType === this.semanticInfoChain.numberTypeSymbol) { + exprType = this.semanticInfoChain.numberTypeSymbol; + } + + if (exprType) { + if (binaryExpression.nodeType() === 40 /* AddAssignmentExpression */) { + var lhsExpression = this.resolveAST(binaryExpression.operand1, false, enclosingDecl, context); + if (!this.isValidLHS(binaryExpression.operand1, lhsExpression)) { + context.postError(this.unitPath, binaryExpression.operand1.minChar, binaryExpression.operand1.getLength(), TypeScript.DiagnosticCode.Invalid_left_hand_side_of_assignment_expression, null, enclosingDecl); + } + + this.checkAssignability(binaryExpression.operand1, exprType, lhsType, enclosingDecl, context); + } + } else { + context.postError(this.unitPath, binaryExpression.operand1.minChar, binaryExpression.operand1.getLength(), TypeScript.DiagnosticCode.Invalid_expression_types_not_known_to_support_the_addition_operator, null, enclosingDecl); + exprType = this.semanticInfoChain.anyTypeSymbol; + } + + return exprType; + }; + + PullTypeResolver.prototype.resolveLogicalOrExpression = function (binex, inContextuallyTypedAssignment, enclosingDecl, context) { + var symbol = this.getSymbolForAST(binex); + if (!symbol) { + symbol = this.computeLogicalOrExpressionSymbol(binex, inContextuallyTypedAssignment, enclosingDecl, context); + this.setSymbolForAST(binex, symbol, context); + } + + return symbol; + }; + + PullTypeResolver.prototype.computeLogicalOrExpressionSymbol = function (binex, inContextuallyTypedAssignment, enclosingDecl, context) { + var leftType = this.resolveAST(binex.operand1, inContextuallyTypedAssignment, enclosingDecl, context).type; + var rightType = this.resolveAST(binex.operand2, inContextuallyTypedAssignment, enclosingDecl, context).type; + + if (this.isAnyOrEquivalent(leftType) || this.isAnyOrEquivalent(rightType)) { + return this.semanticInfoChain.anyTypeSymbol; + } else if (leftType === this.semanticInfoChain.booleanTypeSymbol) { + if (rightType === this.semanticInfoChain.booleanTypeSymbol) { + return this.semanticInfoChain.booleanTypeSymbol; + } else { + return this.semanticInfoChain.anyTypeSymbol; + } + } else if (leftType === this.semanticInfoChain.numberTypeSymbol) { + if (rightType === this.semanticInfoChain.numberTypeSymbol) { + return this.semanticInfoChain.numberTypeSymbol; + } else { + return this.semanticInfoChain.anyTypeSymbol; + } + } else if (leftType === this.semanticInfoChain.stringTypeSymbol) { + if (rightType === this.semanticInfoChain.stringTypeSymbol) { + return this.semanticInfoChain.stringTypeSymbol; + } else { + return this.semanticInfoChain.anyTypeSymbol; + } + } else if (this.sourceIsSubtypeOfTarget(leftType, rightType, context)) { + return rightType; + } else if (this.sourceIsSubtypeOfTarget(rightType, leftType, context)) { + return leftType; + } + + return this.semanticInfoChain.anyTypeSymbol; + }; + + PullTypeResolver.prototype.resolveLogicalAndExpression = function (binex, inContextuallyTypedAssignment, enclosingDecl, context) { + if (context.typeCheck()) { + this.resolveAST(binex.operand1, inContextuallyTypedAssignment, enclosingDecl, context); + } + + return this.resolveAST(binex.operand2, inContextuallyTypedAssignment, enclosingDecl, context).type; + }; + + PullTypeResolver.prototype.resolveConditionalExpression = function (trinex, enclosingDecl, context) { + var symbol = this.getSymbolForAST(trinex); + if (!symbol) { + symbol = this.computeConditionalExpressionSymbol(trinex, enclosingDecl, context); + this.setSymbolForAST(trinex, symbol, context); + } + + return symbol; + }; + + PullTypeResolver.prototype.computeConditionalExpressionSymbol = function (trinex, enclosingDecl, context) { + if (context.typeCheck()) { + this.resolveAST(trinex.operand1, false, enclosingDecl, context); + } + + var leftType = this.resolveAST(trinex.operand2, false, enclosingDecl, context).type; + var rightType = this.resolveAST(trinex.operand3, false, enclosingDecl, context).type; + + var symbol = null; + if (this.typesAreIdentical(leftType, rightType)) { + symbol = leftType; + } else if (this.sourceIsSubtypeOfTarget(leftType, rightType, context) || this.sourceIsSubtypeOfTarget(rightType, leftType, context)) { + var collection = { + getLength: function () { + return 2; + }, + setTypeAtIndex: function (index, type) { + }, + getTypeAtIndex: function (index) { + return rightType; + } + }; + + var bestCommonType = this.findBestCommonType(leftType, null, collection, context); + + if (bestCommonType) { + symbol = bestCommonType; + } + } + + if (!symbol) { + context.postError(this.getUnitPath(), trinex.minChar, trinex.getLength(), TypeScript.DiagnosticCode.Type_of_conditional_expression_cannot_be_determined_Best_common_type_could_not_be_found_between_0_and_1, [leftType.toString(), rightType.toString()], enclosingDecl); + return this.getNewErrorTypeSymbol(null); + } + + return symbol; + }; + + PullTypeResolver.prototype.resolveParenthesizedExpression = function (ast, enclosingDecl, context) { + return this.resolveAST(ast.expression, false, enclosingDecl, context); + }; + + PullTypeResolver.prototype.resolveExpressionStatement = function (ast, inContextuallyTypedAssignment, enclosingDecl, context) { + return this.resolveAST(ast.expression, inContextuallyTypedAssignment, enclosingDecl, context); + }; + + PullTypeResolver.prototype.resolveInvocationExpression = function (callEx, inContextuallyTypedAssignment, enclosingDecl, context, additionalResults) { + var symbol = this.getSymbolForAST(callEx); + var callResolutionData = this.currentUnit.getCallResolutionDataForAST(callEx); + + if (!symbol || !symbol.isResolved || (additionalResults && !callResolutionData)) { + symbol = this.computeInvocationExpressionSymbol(callEx, inContextuallyTypedAssignment, enclosingDecl, context, additionalResults); + if (symbol != this.semanticInfoChain.anyTypeSymbol) { + this.setSymbolForAST(callEx, symbol, context); + } + this.currentUnit.setCallResolutionDataForAST(callEx, additionalResults); + } else { + if (additionalResults && callResolutionData && (callResolutionData != additionalResults)) { + additionalResults.actualParametersContextTypeSymbols = callResolutionData.actualParametersContextTypeSymbols; + additionalResults.candidateSignature = callResolutionData.candidateSignature; + additionalResults.resolvedSignatures = callResolutionData.resolvedSignatures; + additionalResults.targetSymbol = callResolutionData.targetSymbol; + additionalResults.targetTypeSymbol = callResolutionData.targetTypeSymbol; + } + } + + return symbol; + }; + + PullTypeResolver.prototype.computeInvocationExpressionSymbol = function (callEx, inContextuallyTypedAssignment, enclosingDecl, context, additionalResults) { + var targetSymbol = this.resolveAST(callEx.target, inContextuallyTypedAssignment, enclosingDecl, context); + + var targetAST = this.getLastIdentifierInTarget(callEx); + + var targetTypeSymbol = targetSymbol.type; + if (this.isAnyOrEquivalent(targetTypeSymbol)) { + this.resolveAST(callEx.arguments, inContextuallyTypedAssignment, enclosingDecl, context); + + if (targetSymbol != this.semanticInfoChain.anyTypeSymbol && callEx.typeArguments) { + context.postError(this.unitPath, targetAST.minChar, targetAST.getLength(), TypeScript.DiagnosticCode.Untyped_function_calls_may_not_accept_type_arguments, null, enclosingDecl); + return this.getNewErrorTypeSymbol(null); + } + + return this.semanticInfoChain.anyTypeSymbol; + } + + var isSuperCall = false; + + if (callEx.target.nodeType() === 31 /* SuperExpression */) { + isSuperCall = true; + + if (targetTypeSymbol.isClass()) { + this.seenSuperConstructorCall = true; + targetSymbol = targetTypeSymbol.getConstructorMethod(); + targetTypeSymbol = targetSymbol.type; + } else { + context.postError(this.unitPath, targetAST.minChar, targetAST.getLength(), TypeScript.DiagnosticCode.Calls_to_super_are_only_valid_inside_a_class, null, enclosingDecl); + + return this.getNewErrorTypeSymbol(null); + } + } + + var signatures = isSuperCall ? targetTypeSymbol.getConstructSignatures() : targetTypeSymbol.getCallSignatures(); + + if (!signatures.length && (targetTypeSymbol.kind == 33554432 /* ConstructorType */)) { + context.postError(this.unitPath, targetAST.minChar, targetAST.getLength(), TypeScript.DiagnosticCode.Value_of_type_0_is_not_callable_Did_you_mean_to_include_new, [targetTypeSymbol.toString()], enclosingDecl); + } + + var typeArgs = null; + var typeReplacementMap = null; + var couldNotFindGenericOverload = false; + var couldNotAssignToConstraint; + var constraintDiagnostic = null; + var diagnostics = []; + + if (callEx.typeArguments) { + typeArgs = []; + + if (callEx.typeArguments && callEx.typeArguments.members.length) { + for (var i = 0; i < callEx.typeArguments.members.length; i++) { + var typeArg = this.resolveTypeReference(callEx.typeArguments.members[i], enclosingDecl, context); + typeArgs[i] = context.findSpecializationForType(typeArg); + } + } + } else if (isSuperCall && targetTypeSymbol.isGeneric()) { + typeArgs = targetTypeSymbol.getTypeArguments(); + } + + if (targetTypeSymbol.isGeneric()) { + var resolvedSignatures = []; + var inferredTypeArgs; + var specializedSignature; + var typeParameters; + var typeConstraint = null; + var prevSpecializingToAny = context.specializingToAny; + var prevSpecializing = context.isSpecializingSignatureAtCallSite; + var beforeResolutionSignatures = signatures; + var triedToInferTypeArgs; + + for (var i = 0; i < signatures.length; i++) { + typeParameters = signatures[i].getTypeParameters(); + couldNotAssignToConstraint = false; + triedToInferTypeArgs = false; + + if (signatures[i].isGeneric() && typeParameters.length && !signatures[i].isFixed()) { + if (typeArgs) { + inferredTypeArgs = typeArgs; + } else if (callEx.arguments) { + inferredTypeArgs = this.inferArgumentTypesForSignature(signatures[i], callEx.arguments, new TypeComparisonInfo(), enclosingDecl, context); + triedToInferTypeArgs = true; + } + + if (inferredTypeArgs) { + typeReplacementMap = {}; + + if (inferredTypeArgs.length) { + if (inferredTypeArgs.length != typeParameters.length) { + continue; + } + + for (var j = 0; j < typeParameters.length; j++) { + typeReplacementMap[typeParameters[j].pullSymbolIDString] = inferredTypeArgs[j]; + } + for (var j = 0; j < typeParameters.length; j++) { + typeConstraint = typeParameters[j].getConstraint(); + + if (typeConstraint) { + if (typeConstraint.isTypeParameter()) { + for (var k = 0; k < typeParameters.length && k < inferredTypeArgs.length; k++) { + if (typeParameters[k] == typeConstraint) { + typeConstraint = inferredTypeArgs[k]; + } + } + } + if (typeConstraint.isTypeParameter()) { + context.pushTypeSpecializationCache(typeReplacementMap); + typeConstraint = TypeScript.specializeType(typeConstraint, null, this, enclosingDecl, context); + context.popTypeSpecializationCache(); + } + context.isComparingSpecializedSignatures = true; + if (!this.sourceIsAssignableToTarget(inferredTypeArgs[j], typeConstraint, context)) { + constraintDiagnostic = context.postError(this.unitPath, targetAST.minChar, targetAST.getLength(), TypeScript.DiagnosticCode.Type_0_does_not_satisfy_the_constraint_1_for_type_parameter_2, [inferredTypeArgs[j].toString(null, true), typeConstraint.toString(null, true), typeParameters[j].toString(null, true)], enclosingDecl, false); + couldNotAssignToConstraint = true; + } + context.isComparingSpecializedSignatures = false; + + if (couldNotAssignToConstraint) { + break; + } + } + } + } else { + if (triedToInferTypeArgs) { + if (signatures[i].isFixed()) { + if (signatures[i].hasAGenericParameter) { + context.specializingToAny = true; + } else { + resolvedSignatures[resolvedSignatures.length] = signatures[i]; + } + } else { + continue; + } + } + + context.specializingToAny = true; + } + + if (couldNotAssignToConstraint) { + continue; + } + + context.isSpecializingSignatureAtCallSite = true; + specializedSignature = TypeScript.specializeSignature(signatures[i], false, typeReplacementMap, inferredTypeArgs, this, enclosingDecl, context); + + context.isSpecializingSignatureAtCallSite = prevSpecializing; + context.specializingToAny = prevSpecializingToAny; + + if (specializedSignature) { + resolvedSignatures[resolvedSignatures.length] = specializedSignature; + } + } + } else { + if (!(callEx.typeArguments && callEx.typeArguments.members.length)) { + resolvedSignatures[resolvedSignatures.length] = signatures[i]; + } + } + } + + if (signatures.length && !resolvedSignatures.length) { + couldNotFindGenericOverload = true; + } + + signatures = resolvedSignatures; + } + + var errorCondition = null; + + if (!signatures.length) { + if (additionalResults) { + additionalResults.targetSymbol = targetSymbol; + additionalResults.targetTypeSymbol = targetTypeSymbol; + additionalResults.resolvedSignatures = beforeResolutionSignatures; + additionalResults.candidateSignature = beforeResolutionSignatures && beforeResolutionSignatures.length ? beforeResolutionSignatures[0] : null; + + additionalResults.actualParametersContextTypeSymbols = actualParametersContextTypeSymbols; + } + + if (!couldNotFindGenericOverload) { + if (this.cachedFunctionInterfaceType() && this.sourceIsSubtypeOfTarget(targetTypeSymbol, this.cachedFunctionInterfaceType(), context)) { + return this.semanticInfoChain.anyTypeSymbol; + } + + context.postError(this.unitPath, callEx.minChar, callEx.getLength(), TypeScript.DiagnosticCode.Cannot_invoke_an_expression_whose_type_lacks_a_call_signature, null, enclosingDecl); + errorCondition = this.getNewErrorTypeSymbol(null); + } else { + context.postError(this.unitPath, callEx.minChar, callEx.getLength(), TypeScript.DiagnosticCode.Could_not_select_overload_for_call_expression, null, enclosingDecl); + errorCondition = this.getNewErrorTypeSymbol(null); + } + + if (constraintDiagnostic) { + context.postDiagnostic(constraintDiagnostic, enclosingDecl); + } + + return errorCondition; + } + + var prevIsResolvingSuperConstructorTarget = context.isResolvingSuperConstructorTarget; + + if (isSuperCall) { + context.isResolvingSuperConstructorTarget = true; + } + + var signature = this.resolveOverloads(callEx, signatures, enclosingDecl, callEx.typeArguments != null, context, diagnostics); + var useBeforeResolutionSignatures = signature == null; + + if (isSuperCall) { + context.isResolvingSuperConstructorTarget = prevIsResolvingSuperConstructorTarget; + } + + if (!signature) { + for (var i = 0; i < diagnostics.length; i++) { + context.postDiagnostic(diagnostics[i], enclosingDecl); + } + + context.postError(this.unitPath, targetAST.minChar, targetAST.getLength(), TypeScript.DiagnosticCode.Could_not_select_overload_for_call_expression, null, enclosingDecl); + + errorCondition = this.getNewErrorTypeSymbol(null); + + if (!signatures.length) { + return errorCondition; + } + + signature = signatures[0]; + + if (callEx.arguments) { + for (var k = 0, n = callEx.arguments.members.length; k < n; k++) { + var arg = callEx.arguments.members[k]; + var argSymbol = this.getSymbolForAST(arg); + + if (argSymbol) { + var argType = argSymbol.type; + if (arg.nodeType() === 13 /* FunctionDeclaration */) { + if (!this.canApplyContextualTypeToFunction(argType, arg, true)) { + continue; + } + } + + argSymbol.invalidate(); + } + } + } + } + + if (!signature.isGeneric() && callEx.typeArguments) { + context.postError(this.unitPath, targetAST.minChar, targetAST.getLength(), TypeScript.DiagnosticCode.Non_generic_functions_may_not_accept_type_arguments, null, enclosingDecl); + } + + var returnType = isSuperCall ? this.semanticInfoChain.voidTypeSymbol : signature.returnType; + + var actualParametersContextTypeSymbols = []; + if (callEx.arguments) { + var len = callEx.arguments.members.length; + var params = signature.parameters; + var contextualType = null; + var signatureDecl = signature.getDeclarations()[0]; + + for (var i = 0; i < len; i++) { + if (params.length) { + if (i < params.length - 1 || (i < params.length && !signature.hasVarArgs)) { + if (typeReplacementMap) { + context.pushTypeSpecializationCache(typeReplacementMap); + } + this.resolveDeclaredSymbol(params[i], signatureDecl, context); + if (typeReplacementMap) { + context.popTypeSpecializationCache(); + } + contextualType = params[i].type; + } else if (signature.hasVarArgs) { + contextualType = params[params.length - 1].type; + if (contextualType.isArray()) { + contextualType = contextualType.getElementType(); + } + } + } + + if (contextualType) { + context.pushContextualType(contextualType, context.inProvisionalResolution(), null); + actualParametersContextTypeSymbols[i] = contextualType; + } + + this.resolveAST(callEx.arguments.members[i], contextualType != null, enclosingDecl, context); + + if (contextualType) { + context.popContextualType(); + contextualType = null; + } + } + } + + if (additionalResults) { + additionalResults.targetSymbol = targetSymbol; + additionalResults.targetTypeSymbol = targetTypeSymbol; + if (useBeforeResolutionSignatures && beforeResolutionSignatures) { + additionalResults.resolvedSignatures = beforeResolutionSignatures; + additionalResults.candidateSignature = beforeResolutionSignatures[0]; + } else { + additionalResults.resolvedSignatures = signatures; + additionalResults.candidateSignature = signature; + } + additionalResults.actualParametersContextTypeSymbols = actualParametersContextTypeSymbols; + } + + if (errorCondition) { + return errorCondition; + } + + if (!returnType) { + returnType = this.semanticInfoChain.anyTypeSymbol; + } + + return returnType; + }; + + PullTypeResolver.prototype.resolveObjectCreationExpression = function (callEx, inContextuallyTypedAssignment, enclosingDecl, context, additionalResults) { + var symbol = this.getSymbolForAST(callEx); + var callResolutionData = this.currentUnit.getCallResolutionDataForAST(callEx); + + if (!symbol || !symbol.isResolved || (additionalResults && !callResolutionData)) { + symbol = this.computeObjectCreationExpressionSymbol(callEx, inContextuallyTypedAssignment, enclosingDecl, context, additionalResults); + this.setSymbolForAST(callEx, symbol, context); + this.currentUnit.setCallResolutionDataForAST(callEx, additionalResults); + } else { + if (additionalResults && callResolutionData && (callResolutionData != additionalResults)) { + additionalResults.actualParametersContextTypeSymbols = callResolutionData.actualParametersContextTypeSymbols; + additionalResults.candidateSignature = callResolutionData.candidateSignature; + additionalResults.resolvedSignatures = callResolutionData.resolvedSignatures; + additionalResults.targetSymbol = callResolutionData.targetSymbol; + additionalResults.targetTypeSymbol = callResolutionData.targetTypeSymbol; + } + } + + return symbol; + }; + + PullTypeResolver.prototype.computeObjectCreationExpressionSymbol = function (callEx, inContextuallyTypedAssignment, enclosingDecl, context, additionalResults) { + var returnType = null; + + var targetSymbol = this.resolveAST(callEx.target, inContextuallyTypedAssignment, enclosingDecl, context); + var targetTypeSymbol = targetSymbol.isType() ? targetSymbol : targetSymbol.type; + + var targetAST = this.getLastIdentifierInTarget(callEx); + + if (targetTypeSymbol.isClass()) { + targetTypeSymbol = targetTypeSymbol.getConstructorMethod().type; + } + + var constructSignatures = targetTypeSymbol.getConstructSignatures(); + + var typeArgs = null; + var typeReplacementMap = null; + var usedCallSignaturesInstead = false; + var couldNotAssignToConstraint; + var constraintDiagnostic = null; + var diagnostics = []; + + if (this.isAnyOrEquivalent(targetTypeSymbol)) { + this.resolveAST(callEx.arguments, inContextuallyTypedAssignment, enclosingDecl, context); + return targetTypeSymbol; + } + + if (!constructSignatures.length) { + constructSignatures = targetTypeSymbol.getCallSignatures(); + usedCallSignaturesInstead = true; + + if (this.compilationSettings.noImplicitAny) { + context.postError(this.unitPath, callEx.minChar, callEx.getLength(), TypeScript.DiagnosticCode.New_expression_which_lacks_a_constructor_signature_implicitly_has_an_any_type, [], enclosingDecl); + } + } + + if (constructSignatures.length) { + if (callEx.typeArguments) { + typeArgs = []; + + if (callEx.typeArguments && callEx.typeArguments.members.length) { + for (var i = 0; i < callEx.typeArguments.members.length; i++) { + var typeArg = this.resolveTypeReference(callEx.typeArguments.members[i], enclosingDecl, context); + typeArgs[i] = context.findSpecializationForType(typeArg); + } + } + } + + if (targetTypeSymbol.isGeneric()) { + var resolvedSignatures = []; + var inferredTypeArgs; + var specializedSignature; + var typeParameters; + var typeConstraint = null; + var prevSpecializingToAny = context.specializingToAny; + var prevIsSpecializing = context.isSpecializingSignatureAtCallSite = true; + var triedToInferTypeArgs; + + for (var i = 0; i < constructSignatures.length; i++) { + couldNotAssignToConstraint = false; + + if (constructSignatures[i].isGeneric() && !constructSignatures[i].isFixed()) { + if (typeArgs) { + inferredTypeArgs = typeArgs; + } else if (callEx.arguments) { + inferredTypeArgs = this.inferArgumentTypesForSignature(constructSignatures[i], callEx.arguments, new TypeComparisonInfo(), enclosingDecl, context); + triedToInferTypeArgs = true; + } + + if (inferredTypeArgs) { + typeParameters = constructSignatures[i].getTypeParameters(); + + typeReplacementMap = {}; + + if (inferredTypeArgs.length) { + if (inferredTypeArgs.length < typeParameters.length) { + continue; + } + + for (var j = 0; j < typeParameters.length; j++) { + typeReplacementMap[typeParameters[j].pullSymbolIDString] = inferredTypeArgs[j]; + } + for (var j = 0; j < typeParameters.length; j++) { + typeConstraint = typeParameters[j].getConstraint(); + + if (typeConstraint) { + if (typeConstraint.isTypeParameter()) { + for (var k = 0; k < typeParameters.length && k < inferredTypeArgs.length; k++) { + if (typeParameters[k] == typeConstraint) { + typeConstraint = inferredTypeArgs[k]; + } + } + } + if (typeConstraint.isTypeParameter()) { + context.pushTypeSpecializationCache(typeReplacementMap); + typeConstraint = TypeScript.specializeType(typeConstraint, null, this, enclosingDecl, context); + context.popTypeSpecializationCache(); + } + + context.isComparingSpecializedSignatures = true; + if (!this.sourceIsAssignableToTarget(inferredTypeArgs[j], typeConstraint, context)) { + constraintDiagnostic = context.postError(this.unitPath, targetAST.minChar, targetAST.getLength(), TypeScript.DiagnosticCode.Type_0_does_not_satisfy_the_constraint_1_for_type_parameter_2, [inferredTypeArgs[j].toString(null, true), typeConstraint.toString(null, true), typeParameters[j].toString(null, true)], enclosingDecl, false); + couldNotAssignToConstraint = true; + } + context.isComparingSpecializedSignatures = false; + + if (couldNotAssignToConstraint) { + break; + } + } + } + } else { + if (triedToInferTypeArgs) { + if (constructSignatures[i].isFixed()) { + if (!constructSignatures[i].hasAGenericParameter) { + resolvedSignatures[resolvedSignatures.length] = constructSignatures[i]; + } + } else { + continue; + } + } else { + context.specializingToAny = true; + } + } + + if (couldNotAssignToConstraint) { + continue; + } + + context.isSpecializingSignatureAtCallSite = true; + specializedSignature = TypeScript.specializeSignature(constructSignatures[i], false, typeReplacementMap, inferredTypeArgs, this, enclosingDecl, context); + + context.specializingToAny = prevSpecializingToAny; + context.isSpecializingSignatureAtCallSite = prevIsSpecializing; + + if (specializedSignature) { + resolvedSignatures[resolvedSignatures.length] = specializedSignature; + } + } + } else { + if (!(callEx.typeArguments && callEx.typeArguments.members.length)) { + resolvedSignatures[resolvedSignatures.length] = constructSignatures[i]; + } + } + } + + constructSignatures = resolvedSignatures; + } + + var signature = this.resolveOverloads(callEx, constructSignatures, enclosingDecl, callEx.typeArguments != null, context, diagnostics); + + if (additionalResults) { + additionalResults.targetSymbol = targetSymbol; + additionalResults.targetTypeSymbol = targetTypeSymbol; + additionalResults.resolvedSignatures = constructSignatures; + additionalResults.candidateSignature = signature; + additionalResults.actualParametersContextTypeSymbols = []; + } + + if (!constructSignatures.length) { + if (constraintDiagnostic) { + context.postDiagnostic(constraintDiagnostic, enclosingDecl); + } + + return this.getNewErrorTypeSymbol(null); + } + + var errorCondition = null; + + if (!signature) { + for (var i = 0; i < diagnostics.length; i++) { + context.postDiagnostic(diagnostics[i], enclosingDecl); + } + + context.postError(this.unitPath, targetAST.minChar, targetAST.getLength(), TypeScript.DiagnosticCode.Could_not_select_overload_for_new_expression, null, enclosingDecl); + + errorCondition = this.getNewErrorTypeSymbol(null); + + if (!constructSignatures.length) { + return errorCondition; + } + + signature = constructSignatures[0]; + + if (callEx.arguments) { + for (var k = 0, n = callEx.arguments.members.length; k < n; k++) { + var arg = callEx.arguments.members[k]; + var argSymbol = this.getSymbolForAST(arg); + + if (argSymbol) { + var argType = argSymbol.type; + if (arg.nodeType() === 13 /* FunctionDeclaration */) { + if (!this.canApplyContextualTypeToFunction(argType, arg, true)) { + continue; + } + } + + argSymbol.invalidate(); + } + } + } + } + + returnType = signature.returnType; + + if (returnType && !signature.isGeneric() && returnType.isGeneric() && !returnType.getIsSpecialized()) { + if (typeArgs && typeArgs.length) { + returnType = TypeScript.specializeType(returnType, typeArgs, this, enclosingDecl, context, callEx); + } else { + returnType = this.specializeTypeToAny(returnType, enclosingDecl, context); + } + } + + if (usedCallSignaturesInstead) { + if (returnType != this.semanticInfoChain.voidTypeSymbol) { + context.postError(this.unitPath, targetAST.minChar, targetAST.getLength(), TypeScript.DiagnosticCode.Call_signatures_used_in_a_new_expression_must_have_a_void_return_type, null, enclosingDecl); + + return this.getNewErrorTypeSymbol(null); + } else { + returnType = this.semanticInfoChain.anyTypeSymbol; + } + } + + if (!returnType) { + returnType = signature.returnType; + + if (!returnType) { + returnType = targetTypeSymbol; + } + } + + var actualParametersContextTypeSymbols = []; + if (callEx.arguments) { + var len = callEx.arguments.members.length; + var params = signature.parameters; + var contextualType = null; + var signatureDecl = signature.getDeclarations()[0]; + + for (var i = 0; i < len; i++) { + if (params.length) { + if (i < params.length - 1 || (i < params.length && !signature.hasVarArgs)) { + if (typeReplacementMap) { + context.pushTypeSpecializationCache(typeReplacementMap); + } + this.resolveDeclaredSymbol(params[i], signatureDecl, context); + if (typeReplacementMap) { + context.popTypeSpecializationCache(); + } + contextualType = params[i].type; + } else if (signature.hasVarArgs) { + contextualType = params[params.length - 1].type; + if (contextualType.isArray()) { + contextualType = contextualType.getElementType(); + } + } + } + + if (contextualType) { + context.pushContextualType(contextualType, context.inProvisionalResolution(), null); + actualParametersContextTypeSymbols[i] = contextualType; + } + + this.resolveAST(callEx.arguments.members[i], contextualType != null, enclosingDecl, context); + + if (contextualType) { + context.popContextualType(); + contextualType = null; + } + } + } + + if (additionalResults) { + additionalResults.targetSymbol = targetSymbol; + additionalResults.targetTypeSymbol = targetTypeSymbol; + additionalResults.resolvedSignatures = constructSignatures; + additionalResults.candidateSignature = signature; + additionalResults.actualParametersContextTypeSymbols = actualParametersContextTypeSymbols; + } + + if (errorCondition) { + return errorCondition; + } + + if (!returnType) { + returnType = this.semanticInfoChain.anyTypeSymbol; + } + + return returnType; + } else if (targetTypeSymbol.isClass()) { + return returnType; + } + + context.postError(this.unitPath, targetAST.minChar, targetAST.getLength(), TypeScript.DiagnosticCode.Invalid_new_expression, null, enclosingDecl); + + return this.getNewErrorTypeSymbol(null); + }; + + PullTypeResolver.prototype.resolveTypeAssertionExpression = function (assertionExpression, inContextuallyTypedAssignment, enclosingDecl, context) { + var returnType = this.resolveAST(assertionExpression.castTerm, false, enclosingDecl, context).type; + this.setSymbolForAST(assertionExpression, returnType, context); + + if (context.typeCheck()) { + if (returnType.isError()) { + var symbolName = (returnType).getData(); + context.postError(this.unitPath, assertionExpression.minChar, assertionExpression.getLength(), TypeScript.DiagnosticCode.Could_not_find_symbol_0, [symbolName], enclosingDecl); + } + + context.pushContextualType(returnType, context.inProvisionalResolution(), null); + var exprType = this.resolveAST(assertionExpression.operand, true, enclosingDecl, context).type; + context.popContextualType(); + + if (!exprType.isResolved) { + this.resolveDeclaredSymbol(exprType, enclosingDecl, context); + } + + var comparisonInfo = new TypeComparisonInfo(); + + var isAssignable = this.sourceIsAssignableToTarget(returnType, exprType, context, comparisonInfo) || this.sourceIsAssignableToTarget(exprType, returnType, context, comparisonInfo); + + if (!isAssignable) { + var message; + if (comparisonInfo.message) { + context.postError(this.unitPath, assertionExpression.minChar, assertionExpression.getLength(), TypeScript.DiagnosticCode.Cannot_convert_0_to_1_NL_2, [exprType.toString(), returnType.toString(), comparisonInfo.message], enclosingDecl); + } else { + context.postError(this.unitPath, assertionExpression.minChar, assertionExpression.getLength(), TypeScript.DiagnosticCode.Cannot_convert_0_to_1, [exprType.toString(), returnType.toString()], enclosingDecl); + } + } + } + + return returnType; + }; + + PullTypeResolver.prototype.resolveAssignmentStatement = function (binaryExpression, inContextuallyTypedAssignment, enclosingDecl, context) { + var leftExpr = this.resolveAST(binaryExpression.operand1, false, enclosingDecl, context); + var leftType = leftExpr.type; + + leftType = this.widenType(leftExpr.type); + + context.pushContextualType(leftType, context.inProvisionalResolution(), null); + var rightType = this.widenType(this.resolveAST(binaryExpression.operand2, true, enclosingDecl, context).type); + context.popContextualType(); + + rightType = this.getInstanceTypeForAssignment(binaryExpression.operand1, rightType, enclosingDecl, context); + + if (context.typeCheck()) { + if (!this.isValidLHS(binaryExpression.operand1, leftExpr)) { + context.postError(this.unitPath, binaryExpression.operand1.minChar, binaryExpression.operand1.getLength(), TypeScript.DiagnosticCode.Invalid_left_hand_side_of_assignment_expression, null, enclosingDecl); + } + + this.checkAssignability(binaryExpression.operand1, rightType, leftType, enclosingDecl, context); + } + return rightType; + }; + + PullTypeResolver.prototype.computeAssignmentStatementSymbol = function (binex, inContextuallyTypedAssignment, enclosingDecl, context) { + var leftType = this.resolveAST(binex.operand1, inContextuallyTypedAssignment, enclosingDecl, context).type; + + context.pushContextualType(leftType, context.inProvisionalResolution(), null); + this.resolveAST(binex.operand2, true, enclosingDecl, context); + context.popContextualType(); + + return leftType; + }; + + PullTypeResolver.prototype.getInstanceTypeForAssignment = function (lhs, type, enclosingDecl, context) { + var typeToReturn = type; + if (typeToReturn && typeToReturn.isAlias()) { + typeToReturn = (typeToReturn).getExportAssignedTypeSymbol(); + } + + if (typeToReturn && typeToReturn.isContainer()) { + var instanceTypeSymbol = (typeToReturn).getInstanceType(); + + if (!instanceTypeSymbol) { + context.postError(this.unitPath, lhs.minChar, lhs.getLength(), TypeScript.DiagnosticCode.Tried_to_set_variable_type_to_uninitialized_module_type_0, [type.toString()], enclosingDecl); + typeToReturn = null; + } else { + typeToReturn = instanceTypeSymbol; + } + } + + return typeToReturn; + }; + + PullTypeResolver.prototype.resolveBoundDecls = function (decl, context) { + if (!decl) { + return; + } + + switch (decl.kind) { + case 1 /* Script */: + var childDecls = decl.getChildDecls(); + for (var i = 0; i < childDecls.length; i++) { + this.resolveBoundDecls(childDecls[i], context); + } + break; + case 32 /* DynamicModule */: + case 4 /* Container */: + case 64 /* Enum */: + var moduleDecl = this.semanticInfoChain.getASTForDecl(decl); + this.resolveModuleDeclaration(moduleDecl, context); + break; + case 16 /* Interface */: + var interfaceDecl = this.semanticInfoChain.getASTForDecl(decl); + this.resolveInterfaceDeclaration(interfaceDecl, context); + break; + case 8 /* Class */: + var classDecl = this.semanticInfoChain.getASTForDecl(decl); + this.resolveClassDeclaration(classDecl, context); + break; + case 65536 /* Method */: + case 16384 /* Function */: + var funcDecl = this.semanticInfoChain.getASTForDecl(decl); + this.resolveFunctionDeclaration(funcDecl, context); + break; + case 262144 /* GetAccessor */: + funcDecl = this.semanticInfoChain.getASTForDecl(decl); + this.resolveGetAccessorDeclaration(funcDecl, context); + break; + case 524288 /* SetAccessor */: + funcDecl = this.semanticInfoChain.getASTForDecl(decl); + this.resolveSetAccessorDeclaration(funcDecl, context); + break; + case 4096 /* Property */: + case 1024 /* Variable */: + case 2048 /* Parameter */: + var varDecl = this.semanticInfoChain.getASTForDecl(decl); + + if (varDecl) { + this.resolveVariableDeclaration(varDecl, context); + } + break; + } + }; + + PullTypeResolver.prototype.mergeOrdered = function (a, b, context, comparisonInfo) { + if (this.isAnyOrEquivalent(a) || this.isAnyOrEquivalent(b)) { + return this.semanticInfoChain.anyTypeSymbol; + } else if (a === b) { + return a; + } else if ((b === this.semanticInfoChain.nullTypeSymbol) && a != this.semanticInfoChain.nullTypeSymbol) { + return a; + } else if ((a === this.semanticInfoChain.nullTypeSymbol) && (b != this.semanticInfoChain.nullTypeSymbol)) { + return b; + } else if ((a === this.semanticInfoChain.voidTypeSymbol) && (b === this.semanticInfoChain.voidTypeSymbol || b === this.semanticInfoChain.undefinedTypeSymbol || b === this.semanticInfoChain.nullTypeSymbol)) { + return a; + } else if ((a === this.semanticInfoChain.voidTypeSymbol) && (b === this.semanticInfoChain.anyTypeSymbol)) { + return b; + } else if ((b === this.semanticInfoChain.undefinedTypeSymbol) && a != this.semanticInfoChain.voidTypeSymbol) { + return a; + } else if ((a === this.semanticInfoChain.undefinedTypeSymbol) && (b != this.semanticInfoChain.undefinedTypeSymbol)) { + return b; + } else if (a.isTypeParameter() && !b.isTypeParameter()) { + return b; + } else if (!a.isTypeParameter() && b.isTypeParameter()) { + return a; + } else if (a.isArray() && b.isArray()) { + if (a.getElementType() === b.getElementType()) { + return a; + } else { + var mergedET = this.mergeOrdered(a.getElementType(), b.getElementType(), context, comparisonInfo); + if (mergedET) { + var mergedArrayType = mergedET.getArrayType(); + + if (!mergedArrayType) { + mergedArrayType = TypeScript.specializeType(this.cachedArrayInterfaceType(), [mergedET], this, this.cachedArrayInterfaceType().getDeclarations()[0], context); + } + + return mergedArrayType; + } + } + } else if (this.sourceIsSubtypeOfTarget(a, b, context, comparisonInfo)) { + return b; + } else if (this.sourceIsSubtypeOfTarget(b, a, context, comparisonInfo)) { + return a; + } + + return null; + }; + + PullTypeResolver.prototype.widenType = function (type) { + if (type === this.semanticInfoChain.undefinedTypeSymbol || type === this.semanticInfoChain.nullTypeSymbol || type.isError()) { + return this.semanticInfoChain.anyTypeSymbol; + } + + return type; + }; + + PullTypeResolver.prototype.isNullOrUndefinedType = function (type) { + return type === this.semanticInfoChain.nullTypeSymbol || type === this.semanticInfoChain.undefinedTypeSymbol; + }; + + PullTypeResolver.prototype.canApplyContextualType = function (type) { + if (!type) { + return true; + } + + var kind = type.kind; + + if ((kind & 8388608 /* ObjectType */) != 0) { + return true; + } + if ((kind & 16 /* Interface */) != 0) { + return true; + } else if ((kind & TypeScript.PullElementKind.SomeFunction) != 0) { + return this.canApplyContextualTypeToFunction(type, this.semanticInfoChain.getASTForDecl(type.getDeclarations[0]), true); + } else if ((kind & 128 /* Array */) != 0) { + return true; + } else if (type == this.semanticInfoChain.anyTypeSymbol || kind != 2 /* Primitive */) { + return true; + } + + return false; + }; + + PullTypeResolver.prototype.findBestCommonType = function (initialType, targetType, collection, context, comparisonInfo) { + var len = collection.getLength(); + var nlastChecked = 0; + var bestCommonType = initialType; + + if (targetType && this.canApplyContextualType(bestCommonType)) { + if (bestCommonType) { + bestCommonType = this.mergeOrdered(bestCommonType, targetType, context); + } else { + bestCommonType = targetType; + } + } + + var convergenceType = bestCommonType; + + while (nlastChecked < len) { + for (var i = 0; i < len; i++) { + if (i === nlastChecked) { + continue; + } + + if (convergenceType && (bestCommonType = this.mergeOrdered(convergenceType, collection.getTypeAtIndex(i), context, comparisonInfo))) { + convergenceType = bestCommonType; + } + + if (bestCommonType === null || this.isAnyOrEquivalent(bestCommonType)) { + break; + } else if (targetType && !(bestCommonType.isTypeParameter() || targetType.isTypeParameter())) { + collection.setTypeAtIndex(i, targetType); + } + } + + if (convergenceType && bestCommonType) { + break; + } + + nlastChecked++; + if (nlastChecked < len) { + convergenceType = collection.getTypeAtIndex(nlastChecked); + } + } + + if (!bestCommonType) { + var emptyTypeDecl = new TypeScript.PullDecl("{}", "{}", 8388608 /* ObjectType */, 0 /* None */, new TypeScript.TextSpan(0, 0), this.currentUnit.getPath()); + var emptyType = new TypeScript.PullTypeSymbol("{}", 8388608 /* ObjectType */); + + emptyTypeDecl.setSymbol(emptyType); + emptyType.addDeclaration(emptyTypeDecl); + + bestCommonType = emptyType; + } + + return bestCommonType; + }; + + PullTypeResolver.prototype.typesAreIdentical = function (t1, t2, val) { + if (t1 === t2) { + return true; + } + + if (!t1 || !t2) { + return false; + } + + if (val && t1.isPrimitive() && (t1).isStringConstant() && t2 === this.semanticInfoChain.stringTypeSymbol) { + return (val.nodeType() === 5 /* StringLiteral */) && (TypeScript.stripQuotes((val).actualText) === TypeScript.stripQuotes(t1.name)); + } + + if (val && t2.isPrimitive() && (t2).isStringConstant() && t2 === this.semanticInfoChain.stringTypeSymbol) { + return (val.nodeType() === 5 /* StringLiteral */) && (TypeScript.stripQuotes((val).actualText) === TypeScript.stripQuotes(t2.name)); + } + + if (t1.isPrimitive() && (t1).isStringConstant() && t2.isPrimitive() && (t2).isStringConstant()) { + return TypeScript.stripQuotes(t1.name) === TypeScript.stripQuotes(t2.name); + } + + if (t1.isPrimitive() || t2.isPrimitive()) { + return false; + } + + if (t1.isClass()) { + return false; + } + + if (t1.isError() && t2.isError()) { + return true; + } + + if (t1.isTypeParameter()) { + if (!t2.isTypeParameter()) { + return false; + } + + var t1ParentDeclaration = t1.getDeclarations()[0].getParentDecl(); + var t2ParentDeclaration = t2.getDeclarations()[0].getParentDecl(); + + if (t1ParentDeclaration === t2ParentDeclaration) { + return this.symbolsShareDeclaration(t1, t2); + } else { + return true; + } + } + + var comboId = t2.pullSymbolIDString + "#" + t1.pullSymbolIDString; + + if (this.identicalCache[comboId] != undefined) { + return true; + } + + if ((t1.kind & 64 /* Enum */) || (t2.kind & 64 /* Enum */)) { + return t1.getAssociatedContainerType() === t2 || t2.getAssociatedContainerType() === t1; + } + + if (t1.isArray() || t2.isArray()) { + if (!(t1.isArray() && t2.isArray())) { + return false; + } + this.identicalCache[comboId] = false; + var ret = this.typesAreIdentical(t1.getElementType(), t2.getElementType()); + if (ret) { + this.identicalCache[comboId] = true; + } else { + this.identicalCache[comboId] = undefined; + } + + return ret; + } + + if (t1.isPrimitive() != t2.isPrimitive()) { + return false; + } + + this.identicalCache[comboId] = false; + + if (t1.hasMembers() && t2.hasMembers()) { + var t1Members = t1.getMembers(); + var t2Members = t2.getMembers(); + + if (t1Members.length != t2Members.length) { + this.identicalCache[comboId] = undefined; + return false; + } + + var t1MemberSymbol = null; + var t2MemberSymbol = null; + + var t1MemberType = null; + var t2MemberType = null; + + for (var iMember = 0; iMember < t1Members.length; iMember++) { + t1MemberSymbol = t1Members[iMember]; + t2MemberSymbol = this.getMemberSymbol(t1MemberSymbol.name, TypeScript.PullElementKind.SomeValue, t2); + + if (!t2MemberSymbol || (t1MemberSymbol.isOptional != t2MemberSymbol.isOptional)) { + this.identicalCache[comboId] = undefined; + return false; + } + + t1MemberType = t1MemberSymbol.type; + t2MemberType = t2MemberSymbol.type; + + if (t1MemberType && t2MemberType && (this.identicalCache[t2MemberType.pullSymbolIDString + "#" + t1MemberType.pullSymbolIDString] != undefined)) { + continue; + } + + if (!this.typesAreIdentical(t1MemberType, t2MemberType)) { + this.identicalCache[comboId] = undefined; + return false; + } + } + } else if (t1.hasMembers() || t2.hasMembers()) { + this.identicalCache[comboId] = undefined; + return false; + } + + var t1CallSigs = t1.getCallSignatures(); + var t2CallSigs = t2.getCallSignatures(); + + var t1ConstructSigs = t1.getConstructSignatures(); + var t2ConstructSigs = t2.getConstructSignatures(); + + var t1IndexSigs = t1.getIndexSignatures(); + var t2IndexSigs = t2.getIndexSignatures(); + + if (!this.signatureGroupsAreIdentical(t1CallSigs, t2CallSigs)) { + this.identicalCache[comboId] = undefined; + return false; + } + + if (!this.signatureGroupsAreIdentical(t1ConstructSigs, t2ConstructSigs)) { + this.identicalCache[comboId] = undefined; + return false; + } + + if (!this.signatureGroupsAreIdentical(t1IndexSigs, t2IndexSigs)) { + this.identicalCache[comboId] = undefined; + return false; + } + + this.identicalCache[comboId] = true; + return true; + }; + + PullTypeResolver.prototype.signatureGroupsAreIdentical = function (sg1, sg2) { + if (sg1 === sg2) { + return true; + } + + if (!sg1 || !sg2) { + return false; + } + + if (sg1.length != sg2.length) { + return false; + } + + var sig1 = null; + var sig2 = null; + var sigsMatch = false; + + for (var iSig1 = 0; iSig1 < sg1.length; iSig1++) { + sig1 = sg1[iSig1]; + + for (var iSig2 = 0; iSig2 < sg2.length; iSig2++) { + sig2 = sg2[iSig2]; + + if (this.signaturesAreIdentical(sig1, sig2)) { + sigsMatch = true; + break; + } + } + + if (sigsMatch) { + sigsMatch = false; + continue; + } + + return false; + } + + return true; + }; + + PullTypeResolver.prototype.signaturesAreIdentical = function (s1, s2, includingReturnType) { + if (typeof includingReturnType === "undefined") { includingReturnType = true; } + if (s1.hasVarArgs != s2.hasVarArgs) { + return false; + } + + if (s1.nonOptionalParamCount != s2.nonOptionalParamCount) { + return false; + } + + if (s1.typeParameters && s2.typeParameters && (s1.typeParameters.length != s2.typeParameters.length)) { + return false; + } + + var s1Params = s1.parameters; + var s2Params = s2.parameters; + + if (s1Params.length != s2Params.length) { + return false; + } + + if (includingReturnType && !this.typesAreIdentical(s1.returnType, s2.returnType)) { + return false; + } + + for (var iParam = 0; iParam < s1Params.length; iParam++) { + if (!this.typesAreIdentical(s1Params[iParam].type, s2Params[iParam].type)) { + return false; + } + } + + return true; + }; + + PullTypeResolver.prototype.substituteUpperBoundForType = function (type) { + if (!type || !type.isTypeParameter()) { + return type; + } + + var constraint = (type).getConstraint(); + + if (constraint) { + return this.substituteUpperBoundForType(constraint); + } + + if (this.cachedObjectInterfaceType()) { + return this.cachedObjectInterfaceType(); + } + + return type; + }; + + PullTypeResolver.prototype.symbolsShareDeclaration = function (symbol1, symbol2) { + var decls1 = symbol1.getDeclarations(); + var decls2 = symbol2.getDeclarations(); + + if (decls1.length && decls2.length) { + return decls1[0].isEqual(decls2[0]); + } + + return false; + }; + + PullTypeResolver.prototype.sourceExtendsTarget = function (source, target, context) { + if (source.isGeneric() != target.isGeneric()) { + return false; + } + + if (source.hasBase(target)) { + return true; + } + + if (context.isInBaseTypeResolution() && (source.kind & (16 /* Interface */ | 8 /* Class */)) && (target.kind & (16 /* Interface */ | 8 /* Class */))) { + var sourceDecls = source.getDeclarations(); + var sourceAST = null; + var extendsSymbol = null; + var extendsList = null; + + for (var i = 0; i < sourceDecls.length; i++) { + sourceAST = this.semanticInfoChain.getASTForDecl(sourceDecls[i]); + extendsList = sourceAST.extendsList; + + if (extendsList && extendsList.members && extendsList.members.length) { + for (var j = 0; j < extendsList.members.length; j++) { + extendsSymbol = this.semanticInfoChain.getSymbolForAST(extendsList.members[j], sourceDecls[i].getScriptName()); + + if (extendsSymbol == target || this.sourceExtendsTarget(extendsSymbol, target, context)) { + return true; + } + } + } + } + + return false; + } + }; + + PullTypeResolver.prototype.sourceIsSubtypeOfTarget = function (source, target, context, comparisonInfo) { + return this.sourceIsRelatableToTarget(source, target, false, this.subtypeCache, context, comparisonInfo); + }; + + PullTypeResolver.prototype.sourceMembersAreSubtypeOfTargetMembers = function (source, target, context, comparisonInfo) { + return this.sourceMembersAreRelatableToTargetMembers(source, target, false, this.subtypeCache, context, comparisonInfo); + }; + + PullTypeResolver.prototype.sourcePropertyIsSubtypeOfTargetProperty = function (source, target, sourceProp, targetProp, context, comparisonInfo) { + return this.sourcePropertyIsRelatableToTargetProperty(source, target, sourceProp, targetProp, false, this.subtypeCache, context, comparisonInfo); + }; + + PullTypeResolver.prototype.sourceCallSignaturesAreSubtypeOfTargetCallSignatures = function (source, target, context, comparisonInfo) { + return this.sourceCallSignaturesAreRelatableToTargetCallSignatures(source, target, false, this.subtypeCache, context, comparisonInfo); + }; + + PullTypeResolver.prototype.sourceConstructSignaturesAreSubtypeOfTargetConstructSignatures = function (source, target, context, comparisonInfo) { + return this.sourceConstructSignaturesAreRelatableToTargetConstructSignatures(source, target, false, this.subtypeCache, context, comparisonInfo); + }; + + PullTypeResolver.prototype.sourceIndexSignaturesAreSubtypeOfTargetIndexSignatures = function (source, target, context, comparisonInfo) { + return this.sourceIndexSignaturesAreRelatableToTargetIndexSignatures(source, target, false, this.subtypeCache, context, comparisonInfo); + }; + + PullTypeResolver.prototype.typeIsSubtypeOfFunction = function (source, context) { + var callSignatures = source.getCallSignatures(); + + if (callSignatures.length) { + return true; + } + + var constructSignatures = source.getConstructSignatures(); + + if (constructSignatures.length) { + return true; + } + + if (this.cachedFunctionInterfaceType()) { + return this.sourceIsSubtypeOfTarget(source, this.cachedFunctionInterfaceType(), context); + } + + return false; + }; + + PullTypeResolver.prototype.signatureGroupIsSubtypeOfTarget = function (sg1, sg2, context, comparisonInfo) { + return this.signatureGroupIsRelatableToTarget(sg1, sg2, false, this.subtypeCache, context, comparisonInfo); + }; + + PullTypeResolver.prototype.signatureIsSubtypeOfTarget = function (s1, s2, context, comparisonInfo) { + return this.signatureIsRelatableToTarget(s1, s2, false, this.subtypeCache, context, comparisonInfo); + }; + + PullTypeResolver.prototype.sourceIsAssignableToTarget = function (source, target, context, comparisonInfo, isInProvisionalResolution) { + if (typeof isInProvisionalResolution === "undefined") { isInProvisionalResolution = false; } + var cache = isInProvisionalResolution ? {} : this.assignableCache; + return this.sourceIsRelatableToTarget(source, target, true, cache, context, comparisonInfo); + }; + + PullTypeResolver.prototype.signatureGroupIsAssignableToTarget = function (sg1, sg2, context, comparisonInfo) { + return this.signatureGroupIsRelatableToTarget(sg1, sg2, true, this.assignableCache, context, comparisonInfo); + }; + + PullTypeResolver.prototype.signatureIsAssignableToTarget = function (s1, s2, context, comparisonInfo) { + return this.signatureIsRelatableToTarget(s1, s2, true, this.assignableCache, context, comparisonInfo); + }; + + PullTypeResolver.prototype.sourceIsRelatableToTarget = function (source, target, assignableTo, comparisonCache, context, comparisonInfo) { + if (source === target) { + return true; + } + + if (!(source && target)) { + return true; + } + + if (context.specializingToAny && (target.isTypeParameter() || source.isTypeParameter())) { + return true; + } + + if (context.specializingToObject) { + if (target.isTypeParameter()) { + target = this.cachedObjectInterfaceType(); + } + if (source.isTypeParameter()) { + target = this.cachedObjectInterfaceType(); + } + } + + var sourceSubstitution = source; + + if (source == this.semanticInfoChain.stringTypeSymbol && this.cachedStringInterfaceType()) { + if (!this.cachedStringInterfaceType().isResolved) { + this.resolveDeclaredSymbol(this.cachedStringInterfaceType(), null, context); + } + sourceSubstitution = this.cachedStringInterfaceType(); + } else if (source == this.semanticInfoChain.numberTypeSymbol && this.cachedNumberInterfaceType()) { + if (!this.cachedNumberInterfaceType().isResolved) { + this.resolveDeclaredSymbol(this.cachedNumberInterfaceType(), null, context); + } + sourceSubstitution = this.cachedNumberInterfaceType(); + } else if (source == this.semanticInfoChain.booleanTypeSymbol && this.cachedBooleanInterfaceType()) { + if (!this.cachedBooleanInterfaceType().isResolved) { + this.resolveDeclaredSymbol(this.cachedBooleanInterfaceType(), null, context); + } + sourceSubstitution = this.cachedBooleanInterfaceType(); + } else if (TypeScript.PullHelpers.symbolIsEnum(source) && this.cachedNumberInterfaceType()) { + sourceSubstitution = this.cachedNumberInterfaceType(); + } else if (source.isTypeParameter()) { + sourceSubstitution = this.substituteUpperBoundForType(source); + } + + var comboId = source.pullSymbolIDString + "#" + target.pullSymbolIDString; + + if (comparisonCache[comboId] != undefined) { + return true; + } + + if (assignableTo) { + if (this.isAnyOrEquivalent(source) || this.isAnyOrEquivalent(target)) { + return true; + } + + if (source === this.semanticInfoChain.stringTypeSymbol && target.isPrimitive() && (target).isStringConstant()) { + return comparisonInfo && comparisonInfo.stringConstantVal && (comparisonInfo.stringConstantVal.nodeType() === 5 /* StringLiteral */) && (TypeScript.stripQuotes((comparisonInfo.stringConstantVal).actualText) === TypeScript.stripQuotes(target.name)); + } + } else { + if (this.isAnyOrEquivalent(target)) { + return true; + } + + if (target === this.semanticInfoChain.stringTypeSymbol && source.isPrimitive() && (source).isStringConstant()) { + return true; + } + } + + if (source.isPrimitive() && (source).isStringConstant() && target.isPrimitive() && (target).isStringConstant()) { + return TypeScript.stripQuotes(source.name) === TypeScript.stripQuotes(target.name); + } + + if (source === this.semanticInfoChain.undefinedTypeSymbol) { + return true; + } + + if ((source === this.semanticInfoChain.nullTypeSymbol) && (target != this.semanticInfoChain.undefinedTypeSymbol && target != this.semanticInfoChain.voidTypeSymbol)) { + return true; + } + + if (target == this.semanticInfoChain.voidTypeSymbol) { + if (source == this.semanticInfoChain.anyTypeSymbol || source == this.semanticInfoChain.undefinedTypeSymbol || source == this.semanticInfoChain.nullTypeSymbol) { + return true; + } + + return false; + } else if (source == this.semanticInfoChain.voidTypeSymbol) { + if (target == this.semanticInfoChain.anyTypeSymbol) { + return true; + } + + return false; + } + + if (target === this.semanticInfoChain.numberTypeSymbol && TypeScript.PullHelpers.symbolIsEnum(source)) { + return true; + } + + if (source === this.semanticInfoChain.numberTypeSymbol && TypeScript.PullHelpers.symbolIsEnum(target)) { + return true; + } + + if (TypeScript.PullHelpers.symbolIsEnum(target) && TypeScript.PullHelpers.symbolIsEnum(source)) { + return this.symbolsShareDeclaration(target, source); + } + + if ((source.kind & 64 /* Enum */) || (target.kind & 64 /* Enum */)) { + return false; + } + + if (source.isArray() && target.isArray()) { + comparisonCache[comboId] = false; + var ret = this.sourceIsRelatableToTarget(source.getElementType(), target.getElementType(), assignableTo, comparisonCache, context, comparisonInfo); + if (ret) { + comparisonCache[comboId] = true; + } else { + comparisonCache[comboId] = undefined; + } + + return ret; + } else if (source.isArray() && target == this.cachedArrayInterfaceType()) { + return true; + } else if (target.isArray() && source == this.cachedArrayInterfaceType()) { + return true; + } + + if (source.isPrimitive() && target.isPrimitive()) { + return false; + } else if (source.isPrimitive() != target.isPrimitive()) { + if (target.isPrimitive()) { + return false; + } + } + + if (target.isTypeParameter()) { + if (source.isTypeParameter() && (source == sourceSubstitution)) { + var targetParentDeclaration = target.getDeclarations()[0].getParentDecl(); + var sourceParentDeclaration = source.getDeclarations()[0].getParentDecl(); + + if (targetParentDeclaration !== sourceParentDeclaration) { + return this.symbolsShareDeclaration(target, source); + } else { + return true; + } + } else { + if (context.isComparingSpecializedSignatures) { + target = this.substituteUpperBoundForType(target); + } else { + return false; + } + } + } + + comparisonCache[comboId] = false; + + if (this.sourceExtendsTarget(source, target, context)) { + return true; + } + + if (this.cachedObjectInterfaceType() && target === this.cachedObjectInterfaceType()) { + return true; + } + + if (this.cachedFunctionInterfaceType() && (sourceSubstitution.getCallSignatures().length || sourceSubstitution.getConstructSignatures().length) && target === this.cachedFunctionInterfaceType()) { + return true; + } + + if (target.hasMembers() && !this.sourceMembersAreRelatableToTargetMembers(sourceSubstitution, target, assignableTo, comparisonCache, context, comparisonInfo)) { + comparisonCache[comboId] = undefined; + return false; + } + + if (!this.sourceCallSignaturesAreRelatableToTargetCallSignatures(sourceSubstitution, target, assignableTo, comparisonCache, context, comparisonInfo)) { + comparisonCache[comboId] = undefined; + return false; + } + + if (!this.sourceConstructSignaturesAreRelatableToTargetConstructSignatures(sourceSubstitution, target, assignableTo, comparisonCache, context, comparisonInfo)) { + comparisonCache[comboId] = undefined; + return false; + } + + if (!this.sourceIndexSignaturesAreRelatableToTargetIndexSignatures(sourceSubstitution, target, assignableTo, comparisonCache, context, comparisonInfo)) { + comparisonCache[comboId] = undefined; + return false; + } + + comparisonCache[comboId] = true; + return true; + }; + + PullTypeResolver.prototype.sourceMembersAreRelatableToTargetMembers = function (source, target, assignableTo, comparisonCache, context, comparisonInfo) { + var targetProps = target.getAllMembers(TypeScript.PullElementKind.SomeValue, true); + + for (var itargetProp = 0; itargetProp < targetProps.length; itargetProp++) { + var targetProp = targetProps[itargetProp]; + var sourceProp = this.getMemberSymbol(targetProp.name, TypeScript.PullElementKind.SomeValue, source); + + if (!targetProp.isResolved) { + this.resolveDeclaredSymbol(targetProp, null, context); + } + + var targetPropType = targetProp.type; + + if (!sourceProp) { + if (this.cachedObjectInterfaceType()) { + sourceProp = this.getMemberSymbol(targetProp.name, TypeScript.PullElementKind.SomeValue, this.cachedObjectInterfaceType()); + } + + if (!sourceProp) { + if (this.cachedFunctionInterfaceType() && (targetPropType.getCallSignatures().length || targetPropType.getConstructSignatures().length)) { + sourceProp = this.getMemberSymbol(targetProp.name, TypeScript.PullElementKind.SomeValue, this.cachedFunctionInterfaceType()); + } + + if (!sourceProp) { + if (!(targetProp.isOptional)) { + if (comparisonInfo) { + comparisonInfo.flags |= 2 /* RequiredPropertyIsMissing */; + comparisonInfo.addMessage(TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Type_0_is_missing_property_1_from_type_2, [source.toString(), targetProp.getScopedNameEx().toString(), target.toString()])); + } + return false; + } + continue; + } + } + } + + if (!this.sourcePropertyIsRelatableToTargetProperty(source, target, sourceProp, targetProp, assignableTo, comparisonCache, context, comparisonInfo)) { + return false; + } + } + + return true; + }; + + PullTypeResolver.prototype.sourcePropertyIsRelatableToTargetProperty = function (source, target, sourceProp, targetProp, assignableTo, comparisonCache, context, comparisonInfo) { + var targetPropIsPrivate = targetProp.hasFlag(2 /* Private */); + var sourcePropIsPrivate = sourceProp.hasFlag(2 /* Private */); + + if (targetPropIsPrivate != sourcePropIsPrivate) { + if (comparisonInfo) { + if (targetPropIsPrivate) { + comparisonInfo.addMessage(TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Property_0_defined_as_public_in_type_1_is_defined_as_private_in_type_2, [targetProp.getScopedNameEx().toString(), sourceProp.getContainer().toString(), targetProp.getContainer().toString()])); + } else { + comparisonInfo.addMessage(TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Property_0_defined_as_private_in_type_1_is_defined_as_public_in_type_2, [targetProp.getScopedNameEx().toString(), sourceProp.getContainer().toString(), targetProp.getContainer().toString()])); + } + comparisonInfo.flags |= 128 /* InconsistantPropertyAccesibility */; + } + return false; + } else if (sourcePropIsPrivate && targetPropIsPrivate) { + var targetDecl = targetProp.getDeclarations()[0]; + var sourceDecl = sourceProp.getDeclarations()[0]; + + if (!targetDecl.isEqual(sourceDecl)) { + if (comparisonInfo) { + comparisonInfo.flags |= 128 /* InconsistantPropertyAccesibility */; + comparisonInfo.addMessage(TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Types_0_and_1_define_property_2_as_private, [sourceProp.getContainer().toString(), targetProp.getContainer().toString(), targetProp.getScopedNameEx().toString()])); + } + + return false; + } + } + + if (!sourceProp.isResolved) { + this.resolveDeclaredSymbol(sourceProp, null, context); + } + + var sourcePropType = sourceProp.type; + var targetPropType = targetProp.type; + + if (targetPropType && sourcePropType && (comparisonCache[sourcePropType.pullSymbolIDString + "#" + targetPropType.pullSymbolIDString] != undefined)) { + return true; + } + + var comparisonInfoPropertyTypeCheck = null; + if (comparisonInfo && !comparisonInfo.onlyCaptureFirstError) { + comparisonInfoPropertyTypeCheck = new TypeComparisonInfo(comparisonInfo); + } + if (!this.sourceIsRelatableToTarget(sourcePropType, targetPropType, assignableTo, comparisonCache, context, comparisonInfoPropertyTypeCheck)) { + if (comparisonInfo) { + comparisonInfo.flags |= 32 /* IncompatiblePropertyTypes */; + var message; + if (comparisonInfoPropertyTypeCheck && comparisonInfoPropertyTypeCheck.message) { + message = TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Types_of_property_0_of_types_1_and_2_are_incompatible_NL_3, [targetProp.getScopedNameEx().toString(), source.toString(), target.toString(), comparisonInfoPropertyTypeCheck.message]); + } else { + message = TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Types_of_property_0_of_types_1_and_2_are_incompatible, [targetProp.getScopedNameEx().toString(), source.toString(), target.toString()]); + } + comparisonInfo.addMessage(message); + } + + return false; + } + + return true; + }; + + PullTypeResolver.prototype.sourceCallSignaturesAreRelatableToTargetCallSignatures = function (source, target, assignableTo, comparisonCache, context, comparisonInfo) { + var targetCallSigs = target.getCallSignatures(); + + if (targetCallSigs.length) { + var comparisonInfoSignatuesTypeCheck = null; + if (comparisonInfo && !comparisonInfo.onlyCaptureFirstError) { + comparisonInfoSignatuesTypeCheck = new TypeComparisonInfo(comparisonInfo); + } + + var sourceCallSigs = source.getCallSignatures(); + if (!this.signatureGroupIsRelatableToTarget(sourceCallSigs, targetCallSigs, assignableTo, comparisonCache, context, comparisonInfoSignatuesTypeCheck)) { + if (comparisonInfo) { + var message; + if (sourceCallSigs.length && targetCallSigs.length) { + if (comparisonInfoSignatuesTypeCheck && comparisonInfoSignatuesTypeCheck.message) { + message = TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Call_signatures_of_types_0_and_1_are_incompatible_NL_2, [source.toString(), target.toString(), comparisonInfoSignatuesTypeCheck.message]); + } else { + message = TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Call_signatures_of_types_0_and_1_are_incompatible, [source.toString(), target.toString()]); + } + } else { + var hasSig = targetCallSigs.length ? target.toString() : source.toString(); + var lacksSig = !targetCallSigs.length ? target.toString() : source.toString(); + message = TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Type_0_requires_a_call_signature_but_type_1_lacks_one, [hasSig, lacksSig]); + } + comparisonInfo.flags |= 4 /* IncompatibleSignatures */; + comparisonInfo.addMessage(message); + } + return false; + } + } + + return true; + }; + + PullTypeResolver.prototype.sourceConstructSignaturesAreRelatableToTargetConstructSignatures = function (source, target, assignableTo, comparisonCache, context, comparisonInfo) { + var targetConstructSigs = target.getConstructSignatures(); + if (targetConstructSigs.length) { + var comparisonInfoSignatuesTypeCheck = null; + if (comparisonInfo && !comparisonInfo.onlyCaptureFirstError) { + comparisonInfoSignatuesTypeCheck = new TypeComparisonInfo(comparisonInfo); + } + + var sourceConstructSigs = source.getConstructSignatures(); + if (!this.signatureGroupIsRelatableToTarget(sourceConstructSigs, targetConstructSigs, assignableTo, comparisonCache, context, comparisonInfoSignatuesTypeCheck)) { + if (comparisonInfo) { + var message; + if (sourceConstructSigs.length && targetConstructSigs.length) { + if (comparisonInfoSignatuesTypeCheck && comparisonInfoSignatuesTypeCheck.message) { + message = TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Construct_signatures_of_types_0_and_1_are_incompatible_NL_2, [source.toString(), target.toString(), comparisonInfoSignatuesTypeCheck.message]); + } else { + message = TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Construct_signatures_of_types_0_and_1_are_incompatible, [source.toString(), target.toString()]); + } + } else { + var hasSig = targetConstructSigs.length ? target.toString() : source.toString(); + var lacksSig = !targetConstructSigs.length ? target.toString() : source.toString(); + message = TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Type_0_requires_a_construct_signature_but_type_1_lacks_one, [hasSig, lacksSig]); + } + comparisonInfo.flags |= 4 /* IncompatibleSignatures */; + comparisonInfo.addMessage(message); + } + return false; + } + } + + return true; + }; + + PullTypeResolver.prototype.sourceIndexSignaturesAreRelatableToTargetIndexSignatures = function (source, target, assignableTo, comparisonCache, context, comparisonInfo) { + var targetIndexSigs = target.getIndexSignatures(); + + if (targetIndexSigs.length) { + var sourceIndexSigs = source.getIndexSignatures(); + + var targetIndex = !targetIndexSigs.length && this.cachedObjectInterfaceType() ? this.cachedObjectInterfaceType().getIndexSignatures() : targetIndexSigs; + var sourceIndex = !sourceIndexSigs.length && this.cachedObjectInterfaceType() ? this.cachedObjectInterfaceType().getIndexSignatures() : sourceIndexSigs; + + var sourceStringSig = null; + var sourceNumberSig = null; + + var targetStringSig = null; + var targetNumberSig = null; + + var params; + + for (var i = 0; i < targetIndex.length; i++) { + if (targetStringSig && targetNumberSig) { + break; + } + + params = targetIndex[i].parameters; + + if (params.length) { + if (!targetStringSig && params[0].type === this.semanticInfoChain.stringTypeSymbol) { + targetStringSig = targetIndex[i]; + continue; + } else if (!targetNumberSig && params[0].type === this.semanticInfoChain.numberTypeSymbol) { + targetNumberSig = targetIndex[i]; + continue; + } + } + } + + for (var i = 0; i < sourceIndex.length; i++) { + if (sourceStringSig && sourceNumberSig) { + break; + } + + params = sourceIndex[i].parameters; + + if (params.length) { + if (!sourceStringSig && params[0].type === this.semanticInfoChain.stringTypeSymbol) { + sourceStringSig = sourceIndex[i]; + continue; + } else if (!sourceNumberSig && params[0].type === this.semanticInfoChain.numberTypeSymbol) { + sourceNumberSig = sourceIndex[i]; + continue; + } + } + } + + var comparable = true; + var comparisonInfoSignatuesTypeCheck = null; + if (comparisonInfo && !comparisonInfo.onlyCaptureFirstError) { + comparisonInfoSignatuesTypeCheck = new TypeComparisonInfo(comparisonInfo); + } + + if (targetStringSig) { + if (sourceStringSig) { + comparable = this.signatureIsAssignableToTarget(sourceStringSig, targetStringSig, context, comparisonInfoSignatuesTypeCheck); + } else { + comparable = false; + } + } + + if (comparable && targetNumberSig) { + if (sourceNumberSig) { + comparable = this.signatureIsAssignableToTarget(sourceNumberSig, targetNumberSig, context, comparisonInfoSignatuesTypeCheck); + } else if (sourceStringSig) { + comparable = this.sourceIsAssignableToTarget(sourceStringSig.returnType, targetNumberSig.returnType, context, comparisonInfoSignatuesTypeCheck); + } else { + comparable = false; + } + } + + if (!comparable) { + if (comparisonInfo) { + var message; + if (comparisonInfoSignatuesTypeCheck && comparisonInfoSignatuesTypeCheck.message) { + message = TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Index_signatures_of_types_0_and_1_are_incompatible_NL_2, [source.toString(), target.toString(), comparisonInfoSignatuesTypeCheck.message]); + } else { + message = TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Index_signatures_of_types_0_and_1_are_incompatible, [source.toString(), target.toString()]); + } + comparisonInfo.flags |= 4 /* IncompatibleSignatures */; + comparisonInfo.addMessage(message); + } + return false; + } + } + + if (targetStringSig && !source.isNamedTypeSymbol() && source.hasMembers()) { + var targetReturnType = targetStringSig.returnType; + var sourceMembers = source.getMembers(); + + for (var i = 0; i < sourceMembers.length; i++) { + if (!this.sourceIsRelatableToTarget(sourceMembers[i].type, targetReturnType, assignableTo, comparisonCache, context, comparisonInfo)) { + return false; + } + } + } + + return true; + }; + + PullTypeResolver.prototype.signatureGroupIsRelatableToTarget = function (sourceSG, targetSG, assignableTo, comparisonCache, context, comparisonInfo) { + if (sourceSG === targetSG) { + return true; + } + + if (!(sourceSG.length && targetSG.length)) { + return false; + } + + var mSig = null; + var nSig = null; + var foundMatch = false; + + var targetExcludeDefinition = targetSG.length > 1; + var sourceExcludeDefinition = sourceSG.length > 1; + for (var iMSig = 0; iMSig < targetSG.length; iMSig++) { + mSig = targetSG[iMSig]; + + if (mSig.isStringConstantOverloadSignature() || (targetExcludeDefinition && mSig.isDefinition())) { + continue; + } + + for (var iNSig = 0; iNSig < sourceSG.length; iNSig++) { + nSig = sourceSG[iNSig]; + + if (nSig.isStringConstantOverloadSignature() || (sourceExcludeDefinition && nSig.isDefinition())) { + continue; + } + + if (this.signatureIsRelatableToTarget(nSig, mSig, assignableTo, comparisonCache, context, comparisonInfo)) { + foundMatch = true; + break; + } + } + + if (foundMatch) { + foundMatch = false; + continue; + } + return false; + } + + return true; + }; + + PullTypeResolver.prototype.signatureIsRelatableToTarget = function (sourceSig, targetSig, assignableTo, comparisonCache, context, comparisonInfo) { + var sourceParameters = sourceSig.parameters; + var targetParameters = targetSig.parameters; + + if (!sourceParameters || !targetParameters) { + return false; + } + + var targetVarArgCount = targetSig.nonOptionalParamCount; + var sourceVarArgCount = sourceSig.nonOptionalParamCount; + + if (sourceVarArgCount > targetVarArgCount && !targetSig.hasVarArgs) { + if (comparisonInfo) { + comparisonInfo.flags |= 3 /* SourceSignatureHasTooManyParameters */; + comparisonInfo.addMessage(TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Call_signature_expects_0_or_fewer_parameters, [targetVarArgCount])); + } + return false; + } + + var sourceReturnType = sourceSig.returnType; + var targetReturnType = targetSig.returnType; + + var prevSpecializingToObject = context.specializingToObject; + context.specializingToObject = true; + + if (targetReturnType != this.semanticInfoChain.voidTypeSymbol) { + if (!this.sourceIsRelatableToTarget(sourceReturnType, targetReturnType, assignableTo, comparisonCache, context, comparisonInfo)) { + if (comparisonInfo) { + comparisonInfo.flags |= 16 /* IncompatibleReturnTypes */; + } + context.specializingToObject = prevSpecializingToObject; + return false; + } + } + + var len = (sourceVarArgCount < targetVarArgCount && (sourceSig.hasVarArgs || (sourceParameters.length > sourceVarArgCount))) ? targetVarArgCount : sourceVarArgCount; + var sourceParamType = null; + var targetParamType = null; + var sourceParamName = ""; + var targetParamName = ""; + + for (var iSource = 0, iTarget = 0; iSource < len; iSource++, iTarget++) { + if (iSource < sourceParameters.length && (!sourceSig.hasVarArgs || iSource < sourceVarArgCount)) { + sourceParamType = sourceParameters[iSource].type; + sourceParamName = sourceParameters[iSource].name; + } else if (iSource === sourceVarArgCount) { + sourceParamType = sourceParameters[iSource].type; + if (sourceParamType.isArray()) { + sourceParamType = sourceParamType.getElementType(); + } + sourceParamName = sourceParameters[iSource].name; + } + + if (iTarget < targetParameters.length && iTarget < targetVarArgCount) { + targetParamType = targetParameters[iTarget].type; + targetParamName = targetParameters[iTarget].name; + } else if (targetSig.hasVarArgs && iTarget === targetVarArgCount) { + targetParamType = targetParameters[iTarget].type; + + if (targetParamType.isArray()) { + targetParamType = targetParamType.getElementType(); + } + targetParamName = targetParameters[iTarget].name; + } + + if (sourceParamType && sourceParamType.isTypeParameter() && this.cachedObjectInterfaceType()) { + sourceParamType = this.cachedObjectInterfaceType(); + } + if (targetParamType && targetParamType.isTypeParameter() && this.cachedObjectInterfaceType()) { + targetParamType = this.cachedObjectInterfaceType(); + } + + if (!(this.sourceIsRelatableToTarget(sourceParamType, targetParamType, assignableTo, comparisonCache, context, comparisonInfo) || this.sourceIsRelatableToTarget(targetParamType, sourceParamType, assignableTo, comparisonCache, context, comparisonInfo))) { + if (comparisonInfo) { + comparisonInfo.flags |= 64 /* IncompatibleParameterTypes */; + } + context.specializingToObject = prevSpecializingToObject; + return false; + } + } + context.specializingToObject = prevSpecializingToObject; + return true; + }; + + PullTypeResolver.prototype.resolveOverloads = function (application, group, enclosingDecl, haveTypeArgumentsAtCallSite, context, diagnostics) { + var rd = this.resolutionDataCache.getResolutionData(); + var actuals = rd.actuals; + var exactCandidates = rd.exactCandidates; + var conversionCandidates = rd.conversionCandidates; + var candidate = null; + var hasOverloads = group.length > 1; + var comparisonInfo = new TypeComparisonInfo(); + var args = null; + var target = null; + + if (application.nodeType() === 37 /* InvocationExpression */ || application.nodeType() === 38 /* ObjectCreationExpression */) { + var callEx = application; + + args = callEx.arguments; + target = this.getLastIdentifierInTarget(callEx); + + if (callEx.arguments) { + var len = callEx.arguments.members.length; + var originalIsInInvocationExpression = context.isInInvocationExpression; + context.isInInvocationExpression = true; + + for (var i = 0; i < len; i++) { + var argSym = this.resolveAST(callEx.arguments.members[i], false, enclosingDecl, context); + actuals[i] = argSym.type; + } + + context.isInInvocationExpression = originalIsInInvocationExpression; + } + } else if (application.nodeType() === 36 /* ElementAccessExpression */) { + var binExp = application; + target = binExp.operand1; + args = new TypeScript.ASTList([binExp.operand2]); + + var argSym = this.resolveAST(args.members[0], false, enclosingDecl, context); + actuals[0] = argSym.type; + } + + var signature; + var returnType; + var candidateInfo; + + for (var j = 0, groupLen = group.length; j < groupLen; j++) { + signature = group[j]; + if ((hasOverloads && signature.isDefinition()) || (haveTypeArgumentsAtCallSite && !signature.isGeneric())) { + continue; + } + + returnType = signature.returnType; + + this.getCandidateSignatures(signature, actuals, args, exactCandidates, conversionCandidates, enclosingDecl, context, comparisonInfo); + } + if (exactCandidates.length === 0) { + var applicableCandidates = this.getApplicableSignaturesFromCandidates(conversionCandidates, args, comparisonInfo, enclosingDecl, context); + if (applicableCandidates.length > 0) { + candidateInfo = this.findMostApplicableSignature(applicableCandidates, args, enclosingDecl, context); + + candidate = candidateInfo.sig; + } else { + if (comparisonInfo.message) { + diagnostics.push(context.postError(this.unitPath, target.minChar, target.getLength(), TypeScript.DiagnosticCode.Supplied_parameters_do_not_match_any_signature_of_call_target_NL_0, [comparisonInfo.message], enclosingDecl, false)); + } else { + diagnostics.push(context.postError(this.unitPath, target.minChar, target.getLength(), TypeScript.DiagnosticCode.Supplied_parameters_do_not_match_any_signature_of_call_target, null, enclosingDecl, false)); + } + } + } else { + if (exactCandidates.length > 1) { + var applicableSigs = []; + for (var i = 0; i < exactCandidates.length; i++) { + applicableSigs[i] = { signature: exactCandidates[i], hadProvisionalErrors: false }; + } + candidateInfo = this.findMostApplicableSignature(applicableSigs, args, enclosingDecl, context); + + candidate = candidateInfo.sig; + } else { + candidate = exactCandidates[0]; + } + } + + this.resolutionDataCache.returnResolutionData(rd); + return candidate; + }; + + PullTypeResolver.prototype.getLastIdentifierInTarget = function (callEx) { + return (callEx.target.nodeType() === 33 /* MemberAccessExpression */) ? (callEx.target).operand2 : callEx.target; + }; + + PullTypeResolver.prototype.getCandidateSignatures = function (signature, actuals, args, exactCandidates, conversionCandidates, enclosingDecl, context, comparisonInfo) { + var parameters = signature.parameters; + var lowerBound = signature.nonOptionalParamCount; + var upperBound = parameters.length; + var formalLen = lowerBound; + var acceptable = false; + + var actualsLength = args && actuals.length == args.separatorCount && actuals.length ? args.separatorCount + 1 : actuals.length; + if ((actualsLength >= lowerBound) && (signature.hasVarArgs || actualsLength <= upperBound)) { + formalLen = (signature.hasVarArgs ? parameters.length : actuals.length); + acceptable = true; + } + + var repeatType = null; + + if (acceptable) { + if (signature.hasVarArgs) { + formalLen -= 1; + repeatType = parameters[formalLen].type; + repeatType = repeatType.getElementType(); + acceptable = actualsLength >= (formalLen < lowerBound ? formalLen : lowerBound); + } + var len = actuals.length; + + var exact = acceptable; + var convert = acceptable; + + var typeA; + var typeB; + + for (var i = 0; i < len; i++) { + if (i < formalLen) { + typeA = parameters[i].type; + } else { + typeA = repeatType; + } + + typeB = actuals[i]; + + if (typeA && !typeA.isResolved) { + this.resolveDeclaredSymbol(typeA, enclosingDecl, context); + } + + if (typeB && !typeB.isResolved) { + this.resolveDeclaredSymbol(typeB, enclosingDecl, context); + } + + if (!typeA || !typeB || !(this.typesAreIdentical(typeA, typeB, args.members[i]))) { + exact = false; + } + + comparisonInfo.stringConstantVal = args.members[i]; + + if (!this.sourceIsAssignableToTarget(typeB, typeA, context, comparisonInfo)) { + convert = false; + } + + comparisonInfo.stringConstantVal = null; + + if (!(exact || convert)) { + break; + } + } + if (exact) { + exactCandidates[exactCandidates.length] = signature; + } else if (convert && (exactCandidates.length === 0)) { + conversionCandidates[conversionCandidates.length] = signature; + } + } + }; + + PullTypeResolver.prototype.getApplicableSignaturesFromCandidates = function (candidateSignatures, args, comparisonInfo, enclosingDecl, context) { + var applicableSigs = []; + var memberType = null; + var miss = false; + var cxt = null; + var hadProvisionalErrors = false; + + var parameters; + var signature; + var argSym; + + for (var i = 0; i < candidateSignatures.length; i++) { + miss = false; + + signature = candidateSignatures[i]; + parameters = signature.parameters; + + for (var j = 0; j < args.members.length; j++) { + if (j >= parameters.length) { + continue; + } + + if (!parameters[j].isResolved) { + this.resolveDeclaredSymbol(parameters[j], enclosingDecl, context); + } + + memberType = parameters[j].type; + + if (signature.hasVarArgs && (j >= signature.nonOptionalParamCount) && memberType.isArray()) { + memberType = memberType.getElementType(); + } + + if (this.isAnyOrEquivalent(memberType)) { + continue; + } else if (args.members[j].nodeType() === 13 /* FunctionDeclaration */) { + if (this.cachedFunctionInterfaceType() && memberType === this.cachedFunctionInterfaceType()) { + continue; + } + + argSym = this.resolveFunctionExpression(args.members[j], false, enclosingDecl, context); + + if (!this.canApplyContextualTypeToFunction(memberType, args.members[j], true)) { + if (this.canApplyContextualTypeToFunction(memberType, args.members[j], false)) { + if (!this.sourceIsAssignableToTarget(argSym.type, memberType, context, comparisonInfo, true)) { + break; + } + } else { + break; + } + } else { + argSym.invalidate(); + context.pushContextualType(memberType, true, null); + + argSym = this.resolveFunctionExpression(args.members[j], true, enclosingDecl, context); + + if (!this.sourceIsAssignableToTarget(argSym.type, memberType, context, comparisonInfo, true)) { + if (comparisonInfo) { + comparisonInfo.setMessage(TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Could_not_apply_type_0_to_argument_1_which_is_of_type_2, [memberType.toString(), (j + 1), argSym.getTypeName()])); + } + miss = true; + } + argSym.invalidate(); + cxt = context.popContextualType(); + hadProvisionalErrors = cxt.hadProvisionalErrors(); + + if (miss) { + break; + } + } + } else if (args.members[j].nodeType() === 23 /* ObjectLiteralExpression */) { + if (this.cachedObjectInterfaceType() && memberType === this.cachedObjectInterfaceType()) { + continue; + } + + context.pushContextualType(memberType, true, null); + argSym = this.resolveObjectLiteralExpression(args.members[j], true, enclosingDecl, context); + + if (!this.sourceIsAssignableToTarget(argSym.type, memberType, context, comparisonInfo, true)) { + if (comparisonInfo) { + comparisonInfo.setMessage(TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Could_not_apply_type_0_to_argument_1_which_is_of_type_2, [memberType.toString(), (j + 1), argSym.getTypeName()])); + } + + miss = true; + } + + argSym.invalidate(); + cxt = context.popContextualType(); + hadProvisionalErrors = cxt.hadProvisionalErrors(); + + if (miss) { + break; + } + } else if (args.members[j].nodeType() === 22 /* ArrayLiteralExpression */) { + if (memberType === this.cachedArrayInterfaceType()) { + continue; + } + + context.pushContextualType(memberType, true, null); + var argSym = this.resolveArrayLiteralExpression(args.members[j], true, enclosingDecl, context); + + if (!this.sourceIsAssignableToTarget(argSym.type, memberType, context, comparisonInfo, true)) { + if (comparisonInfo) { + comparisonInfo.setMessage(TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Could_not_apply_type_0_to_argument_1_which_is_of_type_2, [memberType.toString(), (j + 1), argSym.getTypeName()])); + } + break; + } + + argSym.invalidate(); + cxt = context.popContextualType(); + + hadProvisionalErrors = cxt.hadProvisionalErrors(); + + if (miss) { + break; + } + } + } + + if (j === args.members.length) { + applicableSigs[applicableSigs.length] = { signature: candidateSignatures[i], hadProvisionalErrors: hadProvisionalErrors }; + } + + hadProvisionalErrors = false; + } + + return applicableSigs; + }; + + PullTypeResolver.prototype.findMostApplicableSignature = function (signatures, args, enclosingDecl, context) { + if (signatures.length === 1) { + return { sig: signatures[0].signature, ambiguous: false }; + } + + var best = signatures[0]; + var Q = null; + + var AType = null; + var PType = null; + var QType = null; + + var ambiguous = false; + + var bestParams; + var qParams; + + for (var qSig = 1; qSig < signatures.length; qSig++) { + Q = signatures[qSig]; + + for (var i = 0; args && i < args.members.length; i++) { + var argSym = this.resolveAST(args.members[i], false, enclosingDecl, context); + + AType = argSym.type; + + argSym.invalidate(); + + bestParams = best.signature.parameters; + qParams = Q.signature.parameters; + + PType = i < bestParams.length ? bestParams[i].type : bestParams[bestParams.length - 1].type.getElementType(); + QType = i < qParams.length ? qParams[i].type : qParams[qParams.length - 1].type.getElementType(); + + if (this.typesAreIdentical(PType, QType) && !(QType.isPrimitive() && (QType).isStringConstant())) { + continue; + } else if (PType.isPrimitive() && (PType).isStringConstant() && args.members[i].nodeType() === 5 /* StringLiteral */ && TypeScript.stripQuotes((args.members[i]).actualText) === TypeScript.stripQuotes((PType).name)) { + break; + } else if (QType.isPrimitive() && (QType).isStringConstant() && args.members[i].nodeType() === 5 /* StringLiteral */ && TypeScript.stripQuotes((args.members[i]).actualText) === TypeScript.stripQuotes((QType).name)) { + best = Q; + } else if (this.typesAreIdentical(AType, PType)) { + break; + } else if (this.typesAreIdentical(AType, QType)) { + best = Q; + break; + } else if (this.sourceIsSubtypeOfTarget(PType, QType, context)) { + break; + } else if (this.sourceIsSubtypeOfTarget(QType, PType, context)) { + best = Q; + break; + } else if (Q.hadProvisionalErrors) { + break; + } else if (best.hadProvisionalErrors) { + best = Q; + break; + } + } + + if (!args || i === args.members.length) { + var collection = { + getLength: function () { + return 2; + }, + setTypeAtIndex: function (index, type) { + }, + getTypeAtIndex: function (index) { + return index ? Q.signature.returnType : best.signature.returnType; + } + }; + var bct = this.findBestCommonType(best.signature.returnType, null, collection, context); + ambiguous = !bct; + } else { + ambiguous = false; + } + } + + return { sig: best.signature, ambiguous: ambiguous }; + }; + + PullTypeResolver.prototype.canApplyContextualTypeToFunction = function (candidateType, funcDecl, beStringent) { + if (funcDecl.isMethod() || beStringent && funcDecl.returnTypeAnnotation) { + return false; + } + + beStringent = beStringent || (this.cachedFunctionInterfaceType() === candidateType); + + if (!beStringent) { + return true; + } + var functionSymbol = this.getDeclForAST(funcDecl).getSymbol(); + var signature = functionSymbol.type.getCallSignatures()[0]; + var parameters = signature.parameters; + var paramLen = parameters.length; + + for (var i = 0; i < paramLen; i++) { + var param = parameters[i]; + var argDecl = this.getASTForDecl(param.getDeclarations()[0]); + + if (beStringent && argDecl.typeExpr) { + return false; + } + } + + if (candidateType.getConstructSignatures().length && candidateType.getCallSignatures().length) { + return false; + } + + var candidateSigs = candidateType.getConstructSignatures().length ? candidateType.getConstructSignatures() : candidateType.getCallSignatures(); + + if (!candidateSigs || candidateSigs.length > 1) { + return false; + } + + return true; + }; + + PullTypeResolver.prototype.inferArgumentTypesForSignature = function (signature, args, comparisonInfo, enclosingDecl, context) { + var cxt = null; + var hadProvisionalErrors = false; + + var parameters = signature.parameters; + var typeParameters = signature.getTypeParameters(); + var argContext = new TypeScript.ArgumentInferenceContext(); + + var parameterType = null; + + for (var i = 0; i < typeParameters.length; i++) { + argContext.addInferenceRoot(typeParameters[i]); + } + + var substitutions; + var inferenceCandidates; + var inferenceCandidate; + + for (var i = 0; i < args.members.length; i++) { + if (i >= parameters.length) { + break; + } + + parameterType = parameters[i].type; + + if (signature.hasVarArgs && (i >= signature.nonOptionalParamCount - 1) && parameterType.isArray()) { + parameterType = parameterType.getElementType(); + } + + inferenceCandidates = argContext.getInferenceCandidates(); + substitutions = {}; + + if (inferenceCandidates.length) { + for (var j = 0; j < inferenceCandidates.length; j++) { + argContext.resetRelationshipCache(); + + inferenceCandidate = inferenceCandidates[j]; + + substitutions = inferenceCandidates[j]; + + context.pushContextualType(parameterType, true, substitutions); + + var argSym = this.resolveAST(args.members[i], true, enclosingDecl, context); + + this.relateTypeToTypeParameters(argSym.type, parameterType, false, argContext, enclosingDecl, context); + + cxt = context.popContextualType(); + + argSym.invalidate(); + + hadProvisionalErrors = cxt.hadProvisionalErrors(); + } + } else { + context.pushContextualType(parameterType, true, {}); + var argSym = this.resolveAST(args.members[i], true, enclosingDecl, context); + + this.relateTypeToTypeParameters(argSym.type, parameterType, false, argContext, enclosingDecl, context); + + cxt = context.popContextualType(); + + argSym.invalidate(); + + hadProvisionalErrors = cxt.hadProvisionalErrors(); + } + } + + hadProvisionalErrors = false; + + var inferenceResults = argContext.inferArgumentTypes(this, context); + + if (inferenceResults.unfit) { + return null; + } + + var resultTypes = []; + + for (var i = 0; i < typeParameters.length; i++) { + for (var j = 0; j < inferenceResults.results.length; j++) { + if (inferenceResults.results[j].param == typeParameters[i]) { + resultTypes[resultTypes.length] = inferenceResults.results[j].type; + break; + } + } + } + + if (!args.members.length && !resultTypes.length && typeParameters.length) { + for (var i = 0; i < typeParameters.length; i++) { + resultTypes[resultTypes.length] = this.semanticInfoChain.anyTypeSymbol; + } + } else if (resultTypes.length && resultTypes.length < typeParameters.length) { + for (var i = resultTypes.length; i < typeParameters.length; i++) { + resultTypes[i] = this.semanticInfoChain.anyTypeSymbol; + } + } + + return resultTypes; + }; + + PullTypeResolver.prototype.relateTypeToTypeParameters = function (expressionType, parameterType, shouldFix, argContext, enclosingDecl, context) { + if (!expressionType || !parameterType) { + return; + } + + if (expressionType.isError()) { + expressionType = this.semanticInfoChain.anyTypeSymbol; + } + + if (parameterType === expressionType) { + return; + } + + if (parameterType.isTypeParameter()) { + if (expressionType.isGeneric() && !expressionType.isFixed()) { + expressionType = this.specializeTypeToAny(expressionType, enclosingDecl, context); + } + argContext.addCandidateForInference(parameterType, expressionType, shouldFix); + return; + } + var parameterDeclarations = parameterType.getDeclarations(); + var expressionDeclarations = expressionType.getDeclarations(); + if (!parameterType.isArray() && parameterDeclarations.length && expressionDeclarations.length && (parameterDeclarations[0].isEqual(expressionDeclarations[0]) || (expressionType.isGeneric() && parameterType.isGeneric() && this.sourceIsSubtypeOfTarget(expressionType, parameterType, context, null))) && expressionType.isGeneric()) { + var typeParameters = parameterType.getIsSpecialized() ? parameterType.getTypeArguments() : parameterType.getTypeParameters(); + var typeArguments = expressionType.getTypeArguments(); + + if (!typeArguments) { + typeParameters = parameterType.getTypeArguments(); + typeArguments = expressionType.getIsSpecialized() ? expressionType.getTypeArguments() : expressionType.getTypeParameters(); + } + + if (typeParameters && typeArguments && typeParameters.length === typeArguments.length) { + for (var i = 0; i < typeParameters.length; i++) { + if (typeArguments[i] != typeParameters[i]) { + this.relateTypeToTypeParameters(typeArguments[i], typeParameters[i], true, argContext, enclosingDecl, context); + } + } + } + } + + var prevSpecializingToAny = context.specializingToAny; + context.specializingToAny = true; + + if (!this.sourceIsAssignableToTarget(expressionType, parameterType, context)) { + context.specializingToAny = prevSpecializingToAny; + return; + } + context.specializingToAny = prevSpecializingToAny; + + if (expressionType.isArray() && parameterType.isArray()) { + this.relateArrayTypeToTypeParameters(expressionType, parameterType, shouldFix, argContext, enclosingDecl, context); + + return; + } + + this.relateObjectTypeToTypeParameters(expressionType, parameterType, shouldFix, argContext, enclosingDecl, context); + }; + + PullTypeResolver.prototype.relateFunctionSignatureToTypeParameters = function (expressionSignature, parameterSignature, argContext, enclosingDecl, context) { + var expressionParams = expressionSignature.parameters; + var expressionReturnType = expressionSignature.returnType; + + var parameterParams = parameterSignature.parameters; + var parameterReturnType = parameterSignature.returnType; + + var len = parameterParams.length < expressionParams.length ? parameterParams.length : expressionParams.length; + + for (var i = 0; i < len; i++) { + this.relateTypeToTypeParameters(expressionParams[i].type, parameterParams[i].type, true, argContext, enclosingDecl, context); + } + + this.relateTypeToTypeParameters(expressionReturnType, parameterReturnType, false, argContext, enclosingDecl, context); + }; + + PullTypeResolver.prototype.relateObjectTypeToTypeParameters = function (objectType, parameterType, shouldFix, argContext, enclosingDecl, context) { + var parameterTypeMembers = parameterType.getMembers(); + var parameterSignatures; + var parameterSignature; + + var objectMember; + var objectSignatures; + + if (argContext.alreadyRelatingTypes(objectType, parameterType)) { + return; + } + + var objectTypeArguments = objectType.getTypeArguments(); + var parameterTypeParameters = parameterType.getTypeParameters(); + + if (objectTypeArguments && (objectTypeArguments.length === parameterTypeParameters.length)) { + for (var i = 0; i < objectTypeArguments.length; i++) { + argContext.addCandidateForInference(parameterTypeParameters[i], objectTypeArguments[i], shouldFix); + } + } + + for (var i = 0; i < parameterTypeMembers.length; i++) { + objectMember = this.getMemberSymbol(parameterTypeMembers[i].name, TypeScript.PullElementKind.SomeValue, objectType); + + if (objectMember) { + this.relateTypeToTypeParameters(objectMember.type, parameterTypeMembers[i].type, shouldFix, argContext, enclosingDecl, context); + } + } + + parameterSignatures = parameterType.getCallSignatures(); + objectSignatures = objectType.getCallSignatures(); + + for (var i = 0; i < parameterSignatures.length; i++) { + parameterSignature = parameterSignatures[i]; + + for (var j = 0; j < objectSignatures.length; j++) { + this.relateFunctionSignatureToTypeParameters(objectSignatures[j], parameterSignature, argContext, enclosingDecl, context); + } + } + + parameterSignatures = parameterType.getConstructSignatures(); + objectSignatures = objectType.getConstructSignatures(); + + for (var i = 0; i < parameterSignatures.length; i++) { + parameterSignature = parameterSignatures[i]; + + for (var j = 0; j < objectSignatures.length; j++) { + this.relateFunctionSignatureToTypeParameters(objectSignatures[j], parameterSignature, argContext, enclosingDecl, context); + } + } + + parameterSignatures = parameterType.getIndexSignatures(); + objectSignatures = objectType.getIndexSignatures(); + + for (var i = 0; i < parameterSignatures.length; i++) { + parameterSignature = parameterSignatures[i]; + + for (var j = 0; j < objectSignatures.length; j++) { + this.relateFunctionSignatureToTypeParameters(objectSignatures[j], parameterSignature, argContext, enclosingDecl, context); + } + } + }; + + PullTypeResolver.prototype.relateArrayTypeToTypeParameters = function (argArrayType, parameterArrayType, shouldFix, argContext, enclosingDecl, context) { + var argElement = argArrayType.getElementType(); + var paramElement = parameterArrayType.getElementType(); + + this.relateTypeToTypeParameters(argElement, paramElement, shouldFix, argContext, enclosingDecl, context); + }; + + PullTypeResolver.prototype.specializeTypeToAny = function (typeToSpecialize, enclosingDecl, context) { + var prevSpecialize = context.specializingToAny; + + context.specializingToAny = true; + + var rootType = TypeScript.getRootType(typeToSpecialize); + + var type = TypeScript.specializeType(rootType, [], this, enclosingDecl, context); + + context.specializingToAny = prevSpecialize; + + return type; + }; + + PullTypeResolver.prototype.specializeSignatureToAny = function (signatureToSpecialize, enclosingDecl, context) { + var typeParameters = signatureToSpecialize.getTypeParameters(); + var typeReplacementMap = {}; + var typeArguments = []; + + for (var i = 0; i < typeParameters.length; i++) { + typeArguments[i] = this.semanticInfoChain.anyTypeSymbol; + typeReplacementMap[typeParameters[i].pullSymbolIDString] = typeArguments[i]; + } + if (!typeArguments.length) { + typeArguments[0] = this.semanticInfoChain.anyTypeSymbol; + } + + var prevSpecialize = context.specializingToAny; + + context.specializingToAny = true; + + var sig = TypeScript.specializeSignature(signatureToSpecialize, false, typeReplacementMap, typeArguments, this, enclosingDecl, context); + context.specializingToAny = prevSpecialize; + + return sig; + }; + + PullTypeResolver.typeCheck = function (compilationSettings, semanticInfoChain, scriptName, script) { + var unit = semanticInfoChain.getUnit(scriptName); + + if (unit.getTypeChecked()) { + return; + } + + var scriptDecl = unit.getTopLevelDecls()[0]; + + var resolver = new PullTypeResolver(compilationSettings, semanticInfoChain, scriptName); + var context = new TypeScript.PullTypeResolutionContext(true); + + resolver.resolveAST(script.moduleElements, false, scriptDecl, context); + + resolver.validateVariableDeclarationGroups(scriptDecl, context); + + PullTypeResolver.globalTypeCheckPhase++; + var callBack = null; + + while (PullTypeResolver.typeCheckCallBacks.length) { + callBack = PullTypeResolver.typeCheckCallBacks[PullTypeResolver.typeCheckCallBacks.length - 1]; + PullTypeResolver.typeCheckCallBacks.pop(); + callBack(); + } + + unit.setTypeChecked(); + }; + + PullTypeResolver.prototype.validateVariableDeclarationGroups = function (enclosingDecl, context) { + var declGroups = enclosingDecl.getVariableDeclGroups(); + var decl; + var firstSymbol; + var firstSymbolType; + var symbol; + var symbolType; + var boundDeclAST; + + for (var i = 0; i < declGroups.length; i++) { + for (var j = 0; j < declGroups[i].length; j++) { + decl = declGroups[i][j]; + symbol = decl.getSymbol(); + boundDeclAST = this.semanticInfoChain.getASTForDecl(decl); + symbolType = this.resolveAST(boundDeclAST, false, enclosingDecl, context).type; + if (!j) { + firstSymbol = symbol; + firstSymbolType = symbolType; + continue; + } + + if (symbolType && firstSymbolType && !this.typesAreIdentical(symbolType, firstSymbolType)) { + context.postError(this.currentUnit.getPath(), boundDeclAST.minChar, boundDeclAST.getLength(), TypeScript.DiagnosticCode.Subsequent_variable_declarations_must_have_the_same_type_Variable_0_must_be_of_type_1_but_here_has_type_2, [symbol.getScopedName(), firstSymbolType.toString(), symbolType.toString()], enclosingDecl); + } + } + } + }; + + PullTypeResolver.prototype.typeCheckFunctionOverloads = function (funcDecl, context, signature, allSignatures) { + if (!signature) { + var functionSignatureInfo = TypeScript.PullHelpers.getSignatureForFuncDecl(funcDecl, this.currentUnit); + signature = functionSignatureInfo.signature; + allSignatures = functionSignatureInfo.allSignatures; + } + var functionDeclaration = this.currentUnit.getDeclForAST(funcDecl); + var funcSymbol = functionDeclaration.getSymbol(); + + var definitionSignature = null; + for (var i = allSignatures.length - 1; i >= 0; i--) { + if (allSignatures[i].isDefinition()) { + definitionSignature = allSignatures[i]; + break; + } + } + + if (!signature.isDefinition()) { + for (var i = 0; i < allSignatures.length; i++) { + if (allSignatures[i] === signature) { + break; + } + + if (this.signaturesAreIdentical(allSignatures[i], signature, false)) { + if (!this.typesAreIdentical(allSignatures[i].returnType, signature.returnType)) { + context.postError(this.unitPath, funcDecl.minChar, funcDecl.getLength(), TypeScript.DiagnosticCode.Overloads_cannot_differ_only_by_return_type, null, functionDeclaration); + } else if (funcDecl.isConstructor) { + context.postError(this.unitPath, funcDecl.minChar, funcDecl.getLength(), TypeScript.DiagnosticCode.Duplicate_constructor_overload_signature, null, functionDeclaration); + } else if (funcDecl.isConstructMember()) { + context.postError(this.unitPath, funcDecl.minChar, funcDecl.getLength(), TypeScript.DiagnosticCode.Duplicate_overload_construct_signature, null, functionDeclaration); + } else if (funcDecl.isCallMember()) { + context.postError(this.unitPath, funcDecl.minChar, funcDecl.getLength(), TypeScript.DiagnosticCode.Duplicate_overload_call_signature, null, functionDeclaration); + } else { + context.postError(this.unitPath, funcDecl.minChar, funcDecl.getLength(), TypeScript.DiagnosticCode.Duplicate_overload_signature_for_0, [funcSymbol.getScopedNameEx().toString()], functionDeclaration); + } + + break; + } + } + } + + var isConstantOverloadSignature = signature.isStringConstantOverloadSignature(); + if (isConstantOverloadSignature) { + if (signature.isDefinition()) { + context.postError(this.unitPath, funcDecl.minChar, funcDecl.getLength(), TypeScript.DiagnosticCode.Overload_signature_implementation_cannot_use_specialized_type, null, functionDeclaration); + } else { + var foundSubtypeSignature = false; + for (var i = 0; i < allSignatures.length; i++) { + if (allSignatures[i].isDefinition() || allSignatures[i] === signature) { + continue; + } + + if (!allSignatures[i].isResolved) { + this.resolveDeclaredSymbol(allSignatures[i], this.getEnclosingDecl(functionDeclaration), context); + } + + if (allSignatures[i].isStringConstantOverloadSignature()) { + continue; + } + + if (this.signatureIsSubtypeOfTarget(signature, allSignatures[i], context)) { + foundSubtypeSignature = true; + break; + } + } + + if (!foundSubtypeSignature) { + context.postError(this.unitPath, funcDecl.minChar, funcDecl.getLength(), TypeScript.DiagnosticCode.Specialized_overload_signature_is_not_subtype_of_any_non_specialized_signature, null, functionDeclaration); + } + } + } else if (definitionSignature && definitionSignature != signature) { + var comparisonInfo = new TypeComparisonInfo(); + + if (!definitionSignature.isResolved) { + this.resolveDeclaredSymbol(definitionSignature, this.getEnclosingDecl(functionDeclaration), context); + } + + if (!this.signatureIsAssignableToTarget(definitionSignature, signature, context, comparisonInfo)) { + if (comparisonInfo.message) { + context.postError(this.unitPath, funcDecl.minChar, funcDecl.getLength(), TypeScript.DiagnosticCode.Overload_signature_is_not_compatible_with_function_definition_NL_0, [comparisonInfo.message], functionDeclaration); + } else { + context.postError(this.unitPath, funcDecl.minChar, funcDecl.getLength(), TypeScript.DiagnosticCode.Overload_signature_is_not_compatible_with_function_definition, null, functionDeclaration); + } + } + } + + var signatureForVisibilityCheck = definitionSignature; + if (!definitionSignature) { + if (allSignatures[0] === signature) { + return; + } + signatureForVisibilityCheck = allSignatures[0]; + } + + if (!funcDecl.isConstructor && !funcDecl.isConstructMember() && signatureForVisibilityCheck && signature != signatureForVisibilityCheck) { + var errorCode; + + if (signatureForVisibilityCheck.hasFlag(2 /* Private */) != signature.hasFlag(2 /* Private */)) { + errorCode = TypeScript.DiagnosticCode.Overload_signatures_must_all_be_public_or_private; + } else if (signatureForVisibilityCheck.hasFlag(1 /* Exported */) != signature.hasFlag(1 /* Exported */)) { + errorCode = TypeScript.DiagnosticCode.Overload_signatures_must_all_be_exported_or_local; + } else if (signatureForVisibilityCheck.hasFlag(8 /* Ambient */) != signature.hasFlag(8 /* Ambient */)) { + errorCode = TypeScript.DiagnosticCode.Overload_signatures_must_all_be_ambient_or_non_ambient; + } else if (signatureForVisibilityCheck.hasFlag(128 /* Optional */) != signature.hasFlag(128 /* Optional */)) { + errorCode = TypeScript.DiagnosticCode.Overload_signatures_must_all_be_optional_or_required; + } + + if (errorCode) { + context.postError(this.unitPath, funcDecl.minChar, funcDecl.getLength(), errorCode, null, functionDeclaration); + } + } + }; + + PullTypeResolver.prototype.checkSymbolPrivacy = function (declSymbol, symbol, context, privacyErrorReporter) { + if (!symbol || symbol.kind === 2 /* Primitive */) { + return; + } + + if (symbol.isType()) { + var typeSymbol = symbol; + if (typeSymbol.isArray()) { + this.checkSymbolPrivacy(declSymbol, typeSymbol.getElementType(), context, privacyErrorReporter); + return; + } + + if (!typeSymbol.isNamedTypeSymbol()) { + if (typeSymbol.inSymbolPrivacyCheck) { + return; + } + + typeSymbol.inSymbolPrivacyCheck = true; + + var members = typeSymbol.getMembers(); + for (var i = 0; i < members.length; i++) { + this.checkSymbolPrivacy(declSymbol, members[i].type, context, privacyErrorReporter); + } + + this.checkTypePrivacyOfSignatures(declSymbol, typeSymbol.getCallSignatures(), context, privacyErrorReporter); + this.checkTypePrivacyOfSignatures(declSymbol, typeSymbol.getConstructSignatures(), context, privacyErrorReporter); + this.checkTypePrivacyOfSignatures(declSymbol, typeSymbol.getIndexSignatures(), context, privacyErrorReporter); + + typeSymbol.inSymbolPrivacyCheck = false; + + return; + } + } + + if (declSymbol.isExternallyVisible()) { + var symbolIsVisible = symbol.isExternallyVisible(); + + if (symbolIsVisible) { + var symbolPath = symbol.pathToRoot(); + if (symbolPath.length && symbolPath[symbolPath.length - 1].kind === 32 /* DynamicModule */) { + var declSymbolPath = declSymbol.pathToRoot(); + var verifyAlias = false; + if (declSymbolPath.length) { + if (declSymbolPath[declSymbolPath.length - 1] != symbolPath[symbolPath.length - 1]) { + verifyAlias = true; + } else if (symbolPath.length > 1 && symbolPath[symbolPath.length - 2].kind == 32 /* DynamicModule */) { + if (declSymbolPath.length < 2 || declSymbolPath[declSymbolPath.length - 2] != symbolPath[symbolPath.length - 2]) { + verifyAlias = true; + } + } + } + + if (verifyAlias) { + symbolIsVisible = false; + for (var i = symbolPath.length - 1; i >= 0; i--) { + var aliasSymbol = symbolPath[i].getAliasedSymbol(declSymbol); + if (aliasSymbol) { + symbolIsVisible = true; + aliasSymbol.typeUsedExternally = true; + break; + } + } + symbol = symbolPath[symbolPath.length - 1]; + } + } + } + + if (!symbolIsVisible) { + privacyErrorReporter(symbol); + } + } + }; + + PullTypeResolver.prototype.checkTypePrivacyOfSignatures = function (declSymbol, signatures, context, privacyErrorReporter) { + for (var i = 0; i < signatures.length; i++) { + var signature = signatures[i]; + if (signatures.length > 1 && signature.isDefinition()) { + continue; + } + + var typeParams = signature.getTypeParameters(); + for (var j = 0; j < typeParams.length; j++) { + this.checkSymbolPrivacy(declSymbol, typeParams[j], context, privacyErrorReporter); + } + + var params = signature.parameters; + for (var j = 0; j < params.length; j++) { + var paramType = params[j].type; + this.checkSymbolPrivacy(declSymbol, paramType, context, privacyErrorReporter); + } + + var returnType = signature.returnType; + this.checkSymbolPrivacy(declSymbol, returnType, context, privacyErrorReporter); + } + }; + + PullTypeResolver.prototype.baseListPrivacyErrorReporter = function (declAST, declSymbol, baseAst, isExtendedType, symbol, context) { + var decl = this.getDeclForAST(declAST); + var enclosingDecl = this.getEnclosingDecl(decl); + var enclosingSymbol = enclosingDecl ? enclosingDecl.getSymbol() : null; + var messageCode; + + var typeSymbol = symbol; + var typeSymbolName = typeSymbol.getScopedName(enclosingSymbol); + if (typeSymbol.isContainer() && !typeSymbol.isEnum()) { + if (!TypeScript.isQuoted(typeSymbolName)) { + typeSymbolName = "'" + typeSymbolName + "'"; + } + if (declAST.nodeType() === 14 /* ClassDeclaration */) { + if (isExtendedType) { + messageCode = TypeScript.DiagnosticCode.Exported_class_0_extends_class_from_inaccessible_module_1; + } else { + messageCode = TypeScript.DiagnosticCode.Exported_class_0_implements_interface_from_inaccessible_module_1; + } + } else { + messageCode = TypeScript.DiagnosticCode.Exported_interface_0_extends_interface_from_inaccessible_module_1; + } + } else { + if (declAST.nodeType() === 14 /* ClassDeclaration */) { + if (isExtendedType) { + messageCode = TypeScript.DiagnosticCode.Exported_class_0_extends_private_class_1; + } else { + messageCode = TypeScript.DiagnosticCode.Exported_class_0_implements_private_interface_1; + } + } else { + messageCode = TypeScript.DiagnosticCode.Exported_interface_0_extends_private_interface_1; + } + } + + var messageArguments = [declSymbol.getScopedName(enclosingSymbol), typeSymbolName]; + context.postError(this.unitPath, baseAst.minChar, baseAst.getLength(), messageCode, messageArguments, enclosingDecl); + }; + + PullTypeResolver.prototype.variablePrivacyErrorReporter = function (declSymbol, symbol, context) { + var typeSymbol = symbol; + var declAST = this.getASTForSymbol(declSymbol); + var enclosingDecl = this.getEnclosingDecl(declSymbol.getDeclarations()[0]); + var enclosingSymbol = enclosingDecl ? enclosingDecl.getSymbol() : null; + + var isProperty = declSymbol.kind === 4096 /* Property */; + var isPropertyOfClass = false; + var declParent = declSymbol.getContainer(); + if (declParent && (declParent.kind === 8 /* Class */ || declParent.kind === 32768 /* ConstructorMethod */)) { + isPropertyOfClass = true; + } + + var messageCode; + var typeSymbolName = typeSymbol.getScopedName(enclosingSymbol); + if (typeSymbol.isContainer() && !typeSymbol.isEnum()) { + if (!TypeScript.isQuoted(typeSymbolName)) { + typeSymbolName = "'" + typeSymbolName + "'"; + } + + if (declSymbol.hasFlag(16 /* Static */)) { + messageCode = TypeScript.DiagnosticCode.Public_static_property_0_of_exported_class_is_using_inaccessible_module_1; + } else if (isProperty) { + if (isPropertyOfClass) { + messageCode = TypeScript.DiagnosticCode.Public_property_0_of_exported_class_is_using_inaccessible_module_1; + } else { + messageCode = TypeScript.DiagnosticCode.Property_0_of_exported_interface_is_using_inaccessible_module_1; + } + } else { + messageCode = TypeScript.DiagnosticCode.Exported_variable_0_is_using_inaccessible_module_1; + } + } else { + if (declSymbol.hasFlag(16 /* Static */)) { + messageCode = TypeScript.DiagnosticCode.Public_static_property_0_of_exported_class_has_or_is_using_private_type_1; + } else if (isProperty) { + if (isPropertyOfClass) { + messageCode = TypeScript.DiagnosticCode.Public_property_0_of_exported_class_has_or_is_using_private_type_1; + } else { + messageCode = TypeScript.DiagnosticCode.Property_0_of_exported_interface_has_or_is_using_private_type_1; + } + } else { + messageCode = TypeScript.DiagnosticCode.Exported_variable_0_has_or_is_using_private_type_1; + } + } + + var messageArguments = [declSymbol.getScopedName(enclosingSymbol), typeSymbolName]; + context.postError(this.unitPath, declAST.minChar, declAST.getLength(), messageCode, messageArguments, enclosingDecl); + }; + + PullTypeResolver.prototype.checkFunctionTypePrivacy = function (funcDeclAST, inContextuallyTypedAssignment, context) { + var _this = this; + if (inContextuallyTypedAssignment || (funcDeclAST.getFunctionFlags() & 8192 /* IsFunctionExpression */) || (funcDeclAST.getFunctionFlags() & 16384 /* IsFunctionProperty */)) { + return; + } + + var functionDecl = this.currentUnit.getDeclForAST(funcDeclAST); + var functionSymbol = functionDecl.getSymbol(); + ; + var functionSignature; + + var isGetter = funcDeclAST.isGetAccessor(); + var isSetter = funcDeclAST.isSetAccessor(); + + if (isGetter || isSetter) { + var accessorSymbol = functionSymbol; + functionSignature = (isGetter ? accessorSymbol.getGetter() : accessorSymbol.getSetter()).type.getCallSignatures()[0]; + } else { + if (!functionSymbol) { + var parentDecl = functionDecl.getParentDecl(); + functionSymbol = parentDecl.getSymbol(); + if (functionSymbol && functionSymbol.isType() && !(functionSymbol).isNamedTypeSymbol()) { + return; + } + } else if (functionSymbol.kind == 65536 /* Method */ && !functionSymbol.getContainer().isNamedTypeSymbol()) { + return; + } + functionSignature = functionDecl.getSignatureSymbol(); + } + + if (!isGetter) { + var funcParams = functionSignature.parameters; + for (var i = 0; i < funcParams.length; i++) { + this.checkSymbolPrivacy(functionSymbol, funcParams[i].type, context, function (symbol) { + return _this.functionArgumentTypePrivacyErrorReporter(funcDeclAST, i, funcParams[i], symbol, context); + }); + } + } + + if (!isSetter) { + this.checkSymbolPrivacy(functionSymbol, functionSignature.returnType, context, function (symbol) { + return _this.functionReturnTypePrivacyErrorReporter(funcDeclAST, functionSignature.returnType, symbol, context); + }); + } + }; + + PullTypeResolver.prototype.functionArgumentTypePrivacyErrorReporter = function (declAST, argIndex, paramSymbol, symbol, context) { + var decl = this.getDeclForAST(declAST); + var enclosingDecl = this.getEnclosingDecl(decl); + var enclosingSymbol = enclosingDecl ? enclosingDecl.getSymbol() : null; + + var isGetter = declAST.isAccessor() && TypeScript.hasFlag(declAST.getFunctionFlags(), 32 /* GetAccessor */); + var isSetter = declAST.isAccessor() && TypeScript.hasFlag(declAST.getFunctionFlags(), 64 /* SetAccessor */); + var isStatic = (decl.flags & 16 /* Static */) === 16 /* Static */; + var isMethod = decl.kind === 65536 /* Method */; + var isMethodOfClass = false; + var declParent = decl.getParentDecl(); + if (declParent && (declParent.kind === 8 /* Class */ || declParent.kind === 32768 /* ConstructorMethod */)) { + isMethodOfClass = true; + } + + var start = declAST.arguments.members[argIndex].minChar; + var length = declAST.arguments.members[argIndex].getLength(); + + var typeSymbol = symbol; + var typeSymbolName = typeSymbol.getScopedName(enclosingSymbol); + var messageCode; + if (typeSymbol.isContainer() && !typeSymbol.isEnum()) { + if (!TypeScript.isQuoted(typeSymbolName)) { + typeSymbolName = "'" + typeSymbolName + "'"; + } + + if (declAST.isConstructor) { + messageCode = TypeScript.DiagnosticCode.Parameter_0_of_constructor_from_exported_class_is_using_inaccessible_module_1; + } else if (isSetter) { + if (isStatic) { + messageCode = TypeScript.DiagnosticCode.Parameter_0_of_public_static_property_setter_from_exported_class_is_using_inaccessible_module_1; + } else { + messageCode = TypeScript.DiagnosticCode.Parameter_0_of_public_property_setter_from_exported_class_is_using_inaccessible_module_1; + } + } else if (declAST.isConstructMember()) { + messageCode = TypeScript.DiagnosticCode.Parameter_0_of_constructor_signature_from_exported_interface_is_using_inaccessible_module_1; + } else if (declAST.isCallMember()) { + messageCode = TypeScript.DiagnosticCode.Parameter_0_of_call_signature_from_exported_interface_is_using_inaccessible_module_1; + } else if (isMethod) { + if (isStatic) { + messageCode = TypeScript.DiagnosticCode.Parameter_0_of_public_static_method_from_exported_class_is_using_inaccessible_module_1; + } else if (isMethodOfClass) { + messageCode = TypeScript.DiagnosticCode.Parameter_0_of_public_method_from_exported_class_is_using_inaccessible_module_1; + } else { + messageCode = TypeScript.DiagnosticCode.Parameter_0_of_method_from_exported_interface_is_using_inaccessible_module_1; + } + } else if (!isGetter) { + messageCode = TypeScript.DiagnosticCode.Parameter_0_of_exported_function_is_using_inaccessible_module_1; + } + } else { + if (declAST.isConstructor) { + messageCode = TypeScript.DiagnosticCode.Parameter_0_of_constructor_from_exported_class_has_or_is_using_private_type_1; + } else if (isSetter) { + if (isStatic) { + messageCode = TypeScript.DiagnosticCode.Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_private_type_1; + } else { + messageCode = TypeScript.DiagnosticCode.Parameter_0_of_public_property_setter_from_exported_class_has_or_is_using_private_type_1; + } + } else if (declAST.isConstructMember()) { + messageCode = TypeScript.DiagnosticCode.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_type_1; + } else if (declAST.isCallMember()) { + messageCode = TypeScript.DiagnosticCode.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_type_1; + } else if (isMethod) { + if (isStatic) { + messageCode = TypeScript.DiagnosticCode.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_type_1; + } else if (isMethodOfClass) { + messageCode = TypeScript.DiagnosticCode.Parameter_0_of_public_method_from_exported_class_has_or_is_using_private_type_1; + } else { + messageCode = TypeScript.DiagnosticCode.Parameter_0_of_method_from_exported_interface_has_or_is_using_private_type_1; + } + } else if (!isGetter && !declAST.isIndexerMember()) { + messageCode = TypeScript.DiagnosticCode.Parameter_0_of_exported_function_has_or_is_using_private_type_1; + } + } + + if (messageCode) { + var messageArgs = [paramSymbol.getScopedName(enclosingSymbol), typeSymbolName]; + context.postError(this.unitPath, start, length, messageCode, messageArgs, enclosingDecl); + } + }; + + PullTypeResolver.prototype.functionReturnTypePrivacyErrorReporter = function (declAST, funcReturnType, symbol, context) { + var _this = this; + var decl = this.getDeclForAST(declAST); + var enclosingDecl = this.getEnclosingDecl(decl); + + var isGetter = declAST.isAccessor() && TypeScript.hasFlag(declAST.getFunctionFlags(), 32 /* GetAccessor */); + var isSetter = declAST.isAccessor() && TypeScript.hasFlag(declAST.getFunctionFlags(), 64 /* SetAccessor */); + var isStatic = (decl.flags & 16 /* Static */) === 16 /* Static */; + var isMethod = decl.kind === 65536 /* Method */; + var isMethodOfClass = false; + var declParent = decl.getParentDecl(); + if (declParent && (declParent.kind === 8 /* Class */ || declParent.kind === 32768 /* ConstructorMethod */)) { + isMethodOfClass = true; + } + + var messageCode = null; + var typeSymbol = symbol; + var typeSymbolName = typeSymbol.getScopedName(enclosingDecl ? enclosingDecl.getSymbol() : null); + if (typeSymbol.isContainer() && !typeSymbol.isEnum()) { + if (!TypeScript.isQuoted(typeSymbolName)) { + typeSymbolName = "'" + typeSymbolName + "'"; + } + + if (isGetter) { + if (isStatic) { + messageCode = TypeScript.DiagnosticCode.Return_type_of_public_static_property_getter_from_exported_class_is_using_inaccessible_module_0; + } else { + messageCode = TypeScript.DiagnosticCode.Return_type_of_public_property_getter_from_exported_class_is_using_inaccessible_module_0; + } + } else if (declAST.isConstructMember()) { + messageCode = TypeScript.DiagnosticCode.Return_type_of_constructor_signature_from_exported_interface_is_using_inaccessible_module_0; + } else if (declAST.isCallMember()) { + messageCode = TypeScript.DiagnosticCode.Return_type_of_call_signature_from_exported_interface_is_using_inaccessible_module_0; + } else if (declAST.isIndexerMember()) { + messageCode = TypeScript.DiagnosticCode.Return_type_of_index_signature_from_exported_interface_is_using_inaccessible_module_0; + } else if (isMethod) { + if (isStatic) { + messageCode = TypeScript.DiagnosticCode.Return_type_of_public_static_method_from_exported_class_is_using_inaccessible_module_0; + } else if (isMethodOfClass) { + messageCode = TypeScript.DiagnosticCode.Return_type_of_public_method_from_exported_class_is_using_inaccessible_module_0; + } else { + messageCode = TypeScript.DiagnosticCode.Return_type_of_method_from_exported_interface_is_using_inaccessible_module_0; + } + } else if (!isSetter && !declAST.isConstructor) { + messageCode = TypeScript.DiagnosticCode.Return_type_of_exported_function_is_using_inaccessible_module_0; + } + } else { + if (isGetter) { + if (isStatic) { + messageCode = TypeScript.DiagnosticCode.Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_private_type_0; + } else { + messageCode = TypeScript.DiagnosticCode.Return_type_of_public_property_getter_from_exported_class_has_or_is_using_private_type_0; + } + } else if (declAST.isConstructMember()) { + messageCode = TypeScript.DiagnosticCode.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_private_type_0; + } else if (declAST.isCallMember()) { + messageCode = TypeScript.DiagnosticCode.Return_type_of_call_signature_from_exported_interface_has_or_is_using_private_type_0; + } else if (declAST.isIndexerMember()) { + messageCode = TypeScript.DiagnosticCode.Return_type_of_index_signature_from_exported_interface_has_or_is_using_private_type_0; + } else if (isMethod) { + if (isStatic) { + messageCode = TypeScript.DiagnosticCode.Return_type_of_public_static_method_from_exported_class_has_or_is_using_private_type_0; + } else if (isMethodOfClass) { + messageCode = TypeScript.DiagnosticCode.Return_type_of_public_method_from_exported_class_has_or_is_using_private_type_0; + } else { + messageCode = TypeScript.DiagnosticCode.Return_type_of_method_from_exported_interface_has_or_is_using_private_type_0; + } + } else if (!isSetter && !declAST.isConstructor) { + messageCode = TypeScript.DiagnosticCode.Return_type_of_exported_function_has_or_is_using_private_type_0; + } + } + + if (messageCode) { + var messageArguments = [typeSymbolName]; + var reportOnFuncDecl = false; + + if (declAST.returnTypeAnnotation) { + var returnExpressionSymbol = this.resolveTypeReference(declAST.returnTypeAnnotation, decl, context); + if (returnExpressionSymbol === funcReturnType) { + context.postError(this.unitPath, declAST.returnTypeAnnotation.minChar, declAST.returnTypeAnnotation.getLength(), messageCode, messageArguments, enclosingDecl); + } + } + + if (declAST.block) { + var reportErrorOnReturnExpressions = function (ast, parent, walker) { + var go = true; + switch (ast.nodeType()) { + case 13 /* FunctionDeclaration */: + go = false; + break; + + case 94 /* ReturnStatement */: + var returnStatement = ast; + var returnExpressionSymbol = _this.resolveAST(returnStatement.returnExpression, false, decl, context).type; + + if (returnExpressionSymbol === funcReturnType) { + context.postError(_this.unitPath, returnStatement.minChar, returnStatement.getLength(), messageCode, messageArguments, enclosingDecl); + } else { + reportOnFuncDecl = true; + } + go = false; + break; + + default: + break; + } + + walker.options.goChildren = go; + return ast; + }; + + TypeScript.getAstWalkerFactory().walk(declAST.block, reportErrorOnReturnExpressions); + } + + if (reportOnFuncDecl) { + context.postError(this.unitPath, declAST.minChar, declAST.getLength(), messageCode, messageArguments, enclosingDecl); + } + } + }; + + PullTypeResolver.prototype.enclosingClassIsDerived = function (decl) { + if (decl) { + var parentDecl = decl.getParentDecl(); + var classSymbol = null; + + while (parentDecl) { + if (parentDecl.kind == 8 /* Class */) { + classSymbol = parentDecl.getSymbol(); + if (classSymbol.getExtendedTypes().length > 0) { + return true; + } + + break; + } + parentDecl = parentDecl.getParentDecl(); + } + } + + return false; + }; + + PullTypeResolver.prototype.isSuperCallNode = function (node) { + if (node && node.nodeType() === 89 /* ExpressionStatement */) { + var expressionStatement = node; + if (expressionStatement.expression && expressionStatement.expression.nodeType() === 37 /* InvocationExpression */) { + var callExpression = expressionStatement.expression; + if (callExpression.target && callExpression.target.nodeType() === 31 /* SuperExpression */) { + return true; + } + } + } + return false; + }; + + PullTypeResolver.prototype.getFirstStatementFromFunctionDeclAST = function (funcDeclAST) { + if (funcDeclAST.block && funcDeclAST.block.statements && funcDeclAST.block.statements.members) { + return funcDeclAST.block.statements.members[0]; + } + + return null; + }; + + PullTypeResolver.prototype.superCallMustBeFirstStatementInConstructor = function (enclosingConstructor, enclosingClass) { + if (enclosingConstructor && enclosingClass) { + var classSymbol = enclosingClass.getSymbol(); + if (classSymbol.getExtendedTypes().length === 0) { + return false; + } + + var classMembers = classSymbol.getMembers(); + for (var i = 0, n1 = classMembers.length; i < n1; i++) { + var member = classMembers[i]; + + if (member.kind === 4096 /* Property */) { + var declarations = member.getDeclarations(); + for (var j = 0, n2 = declarations.length; j < n2; j++) { + var declaration = declarations[j]; + var ast = this.semanticInfoChain.getASTForDecl(declaration); + if (ast.nodeType() === 20 /* Parameter */) { + return true; + } + + if (ast.nodeType() === 18 /* VariableDeclarator */) { + var variableDeclarator = ast; + if (variableDeclarator.init) { + return true; + } + } + } + } + } + } + + return false; + }; + + PullTypeResolver.prototype.checkForThisOrSuperCaptureInArrowFunction = function (expression, enclosingDecl) { + var declPath = TypeScript.getPathToDecl(enclosingDecl); + + if (declPath.length) { + var inFatArrow = false; + for (var i = declPath.length - 1; i >= 0; i--) { + var decl = declPath[i]; + var declKind = decl.kind; + var declFlags = decl.flags; + + if (declKind === 131072 /* FunctionExpression */ && TypeScript.hasFlag(declFlags, 8192 /* FatArrow */)) { + inFatArrow = true; + continue; + } + + if (inFatArrow) { + if (declKind === 16384 /* Function */ || declKind === 65536 /* Method */ || declKind === 32768 /* ConstructorMethod */ || declKind === 262144 /* GetAccessor */ || declKind === 524288 /* SetAccessor */ || declKind === 131072 /* FunctionExpression */ || declKind === 8 /* Class */ || declKind === 4 /* Container */ || declKind === 32 /* DynamicModule */ || declKind === 1 /* Script */) { + decl.setFlags(decl.flags | 262144 /* MustCaptureThis */); + + if (declKind === 8 /* Class */) { + var constructorSymbol = (decl.getSymbol()).getConstructorMethod(); + var constructorDecls = constructorSymbol.getDeclarations(); + for (var i = 0; i < constructorDecls.length; i++) { + constructorDecls[i].flags = constructorDecls[i].flags | 262144 /* MustCaptureThis */; + } + } + break; + } + } else if (declKind === 16384 /* Function */ || declKind === 131072 /* FunctionExpression */) { + break; + } + } + } + }; + + PullTypeResolver.prototype.typeCheckMembersAgainstIndexer = function (containerType, containerTypeDecl, context) { + var indexSignatures = containerType.getIndexSignatures(); + + if (indexSignatures.length > 0) { + var members = containerTypeDecl.getChildDecls(); + for (var i = 0; i < members.length; i++) { + var member = members[i]; + if (!member.name || member.kind & TypeScript.PullElementKind.SomeSignature) { + continue; + } + + var isMemberNumeric = isFinite(+member.name); + for (var j = 0; j < indexSignatures.length; j++) { + if (!indexSignatures[j].isResolved) { + this.resolveDeclaredSymbol(indexSignatures[j], indexSignatures[j].getDeclarations()[0].getParentDecl(), context); + } + if ((indexSignatures[j].parameters[0].type === this.semanticInfoChain.numberTypeSymbol) === isMemberNumeric) { + this.checkThatMemberIsSubtypeOfIndexer(member.getSymbol(), indexSignatures[j], this.semanticInfoChain.getASTForDecl(member), context, containerTypeDecl, isMemberNumeric); + break; + } + } + } + } + }; + + PullTypeResolver.prototype.checkThatMemberIsSubtypeOfIndexer = function (member, indexSignature, astForError, context, enclosingDecl, isNumeric) { + var comparisonInfo = new TypeComparisonInfo(); + var resolutionContext = new TypeScript.PullTypeResolutionContext(); + + if (!this.sourceIsSubtypeOfTarget(member.type, indexSignature.returnType, resolutionContext, comparisonInfo)) { + if (isNumeric) { + if (comparisonInfo.message) { + context.postError(this.unitPath, astForError.minChar, astForError.getLength(), TypeScript.DiagnosticCode.All_numerically_named_properties_must_be_subtypes_of_numeric_indexer_type_0_NL_1, [indexSignature.returnType.toString(), comparisonInfo.message], enclosingDecl); + } else { + context.postError(this.unitPath, astForError.minChar, astForError.getLength(), TypeScript.DiagnosticCode.All_numerically_named_properties_must_be_subtypes_of_numeric_indexer_type_0, [indexSignature.returnType.toString()], enclosingDecl); + } + } else { + if (comparisonInfo.message) { + context.postError(this.unitPath, astForError.minChar, astForError.getLength(), TypeScript.DiagnosticCode.All_named_properties_must_be_subtypes_of_string_indexer_type_0_NL_1, [indexSignature.returnType.toString(), comparisonInfo.message], enclosingDecl); + } else { + context.postError(this.unitPath, astForError.minChar, astForError.getLength(), TypeScript.DiagnosticCode.All_named_properties_must_be_subtypes_of_string_indexer_type_0, [indexSignature.returnType.toString()], enclosingDecl); + } + } + } + }; + + PullTypeResolver.prototype.typeCheckIfTypeMemberPropertyOkToOverride = function (typeSymbol, extendedType, typeMember, extendedTypeMember, enclosingDecl, comparisonInfo) { + if (!typeSymbol.isClass()) { + return true; + } + + var typeMemberKind = typeMember.kind; + var extendedMemberKind = extendedTypeMember.kind; + + if (typeMemberKind === extendedMemberKind) { + return true; + } + + var errorCode; + if (typeMemberKind === 4096 /* Property */) { + if (typeMember.isAccessor()) { + errorCode = TypeScript.DiagnosticCode.Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_function; + } else { + errorCode = TypeScript.DiagnosticCode.Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_function; + } + } else if (typeMemberKind === 65536 /* Method */) { + if (extendedTypeMember.isAccessor()) { + errorCode = TypeScript.DiagnosticCode.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_accessor; + } else { + errorCode = TypeScript.DiagnosticCode.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_property; + } + } + + var message = TypeScript.getDiagnosticMessage(errorCode, [typeSymbol.toString(), typeMember.getScopedNameEx().toString(), extendedType.toString()]); + comparisonInfo.addMessage(message); + return false; + }; + + PullTypeResolver.prototype.typeCheckIfTypeExtendsType = function (typeDecl, typeSymbol, extendedType, enclosingDecl, context) { + var typeMembers = typeSymbol.getMembers(); + + var resolutionContext = new TypeScript.PullTypeResolutionContext(); + var comparisonInfo = new TypeComparisonInfo(); + var foundError = false; + + for (var i = 0; i < typeMembers.length; i++) { + var propName = typeMembers[i].name; + var extendedTypeProp = extendedType.findMember(propName); + if (extendedTypeProp) { + foundError = !this.typeCheckIfTypeMemberPropertyOkToOverride(typeSymbol, extendedType, typeMembers[i], extendedTypeProp, enclosingDecl, comparisonInfo); + + if (!foundError) { + foundError = !this.sourcePropertyIsSubtypeOfTargetProperty(typeSymbol, extendedType, typeMembers[i], extendedTypeProp, resolutionContext, comparisonInfo); + } + + if (foundError) { + break; + } + } + } + + if (!foundError && typeSymbol.hasOwnCallSignatures()) { + foundError = !this.sourceCallSignaturesAreSubtypeOfTargetCallSignatures(typeSymbol, extendedType, resolutionContext, comparisonInfo); + } + + if (!foundError && typeSymbol.hasOwnConstructSignatures()) { + foundError = !this.sourceConstructSignaturesAreSubtypeOfTargetConstructSignatures(typeSymbol, extendedType, resolutionContext, comparisonInfo); + } + + if (!foundError && typeSymbol.hasOwnIndexSignatures()) { + foundError = !this.sourceIndexSignaturesAreSubtypeOfTargetIndexSignatures(typeSymbol, extendedType, resolutionContext, comparisonInfo); + } + + if (!foundError && typeSymbol.isClass()) { + var typeConstructorType = typeSymbol.getConstructorMethod().type; + var typeConstructorTypeMembers = typeConstructorType.getMembers(); + if (typeConstructorTypeMembers.length) { + var extendedConstructorType = extendedType.getConstructorMethod().type; + var comparisonInfoForPropTypeCheck = new TypeComparisonInfo(comparisonInfo); + + for (var i = 0; i < typeConstructorTypeMembers.length; i++) { + var propName = typeConstructorTypeMembers[i].name; + var extendedConstructorTypeProp = extendedConstructorType.findMember(propName); + if (extendedConstructorTypeProp) { + if (!extendedConstructorTypeProp.isResolved) { + var extendedClassAst = this.currentUnit.getASTForSymbol(extendedType); + var extendedClassDecl = this.currentUnit.getDeclForAST(extendedClassAst); + this.resolveDeclaredSymbol(extendedConstructorTypeProp, extendedClassDecl, resolutionContext); + } + + var typeConstructorTypePropType = typeConstructorTypeMembers[i].type; + var extendedConstructorTypePropType = extendedConstructorTypeProp.type; + if (!this.sourceIsSubtypeOfTarget(typeConstructorTypePropType, extendedConstructorTypePropType, resolutionContext, comparisonInfoForPropTypeCheck)) { + var propMessage; + if (comparisonInfoForPropTypeCheck.message) { + propMessage = TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Types_of_static_property_0_of_class_1_and_class_2_are_incompatible_NL_3, [extendedConstructorTypeProp.getScopedNameEx().toString(), typeSymbol.toString(), extendedType.toString(), comparisonInfoForPropTypeCheck.message]); + } else { + propMessage = TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Types_of_static_property_0_of_class_1_and_class_2_are_incompatible, [extendedConstructorTypeProp.getScopedNameEx().toString(), typeSymbol.toString(), extendedType.toString()]); + } + comparisonInfo.addMessage(propMessage); + foundError = true; + break; + } + } + } + } + } + + if (foundError) { + var errorCode; + if (typeSymbol.isClass()) { + errorCode = TypeScript.DiagnosticCode.Class_0_cannot_extend_class_1_NL_2; + } else { + if (extendedType.isClass()) { + errorCode = TypeScript.DiagnosticCode.Interface_0_cannot_extend_class_1_NL_2; + } else { + errorCode = TypeScript.DiagnosticCode.Interface_0_cannot_extend_interface_1_NL_2; + } + } + + context.postError(this.unitPath, typeDecl.name.minChar, typeDecl.name.getLength(), errorCode, [typeSymbol.getScopedName(), extendedType.getScopedName(), comparisonInfo.message], enclosingDecl); + } + }; + + PullTypeResolver.prototype.typeCheckIfClassImplementsType = function (classDecl, classSymbol, implementedType, enclosingDecl, context) { + var resolutionContext = new TypeScript.PullTypeResolutionContext(); + var comparisonInfo = new TypeComparisonInfo(); + var foundError = !this.sourceMembersAreSubtypeOfTargetMembers(classSymbol, implementedType, resolutionContext, comparisonInfo); + if (!foundError) { + foundError = !this.sourceCallSignaturesAreSubtypeOfTargetCallSignatures(classSymbol, implementedType, resolutionContext, comparisonInfo); + if (!foundError) { + foundError = !this.sourceConstructSignaturesAreSubtypeOfTargetConstructSignatures(classSymbol, implementedType, resolutionContext, comparisonInfo); + if (!foundError) { + foundError = !this.sourceIndexSignaturesAreSubtypeOfTargetIndexSignatures(classSymbol, implementedType, resolutionContext, comparisonInfo); + } + } + } + + if (foundError) { + context.postError(this.unitPath, classDecl.name.minChar, classDecl.name.getLength(), TypeScript.DiagnosticCode.Class_0_declares_interface_1_but_does_not_implement_it_NL_2, [classSymbol.getScopedName(), implementedType.getScopedName(), comparisonInfo.message], enclosingDecl); + } + }; + + PullTypeResolver.prototype.hasClassTypeSymbolConflictAsValue = function (valueDeclAST, typeSymbol, enclosingDecl, context) { + var typeSymbolAlias = this.currentUnit.getAliasSymbolForAST(valueDeclAST); + var tempResolvingTypeNameAsNameExpression = context.resolvingTypeNameAsNameExpression; + context.resolvingTypeNameAsNameExpression = true; + var valueSymbol = this.computeNameExpression(valueDeclAST, enclosingDecl, context); + context.resolvingTypeNameAsNameExpression = tempResolvingTypeNameAsNameExpression; + var valueSymbolAlias = this.currentUnit.getAliasSymbolForAST(valueDeclAST); + + this.currentUnit.setAliasSymbolForAST(valueDeclAST, typeSymbolAlias); + + if (typeSymbolAlias && valueSymbolAlias) { + return typeSymbolAlias != valueSymbolAlias; + } + + if (!valueSymbol.hasFlag(16384 /* ClassConstructorVariable */)) { + return true; + } + + var associatedContainerType = valueSymbol.type ? valueSymbol.type.getAssociatedContainerType() : null; + if (associatedContainerType) { + return associatedContainerType != typeSymbol; + } + + return true; + }; + + PullTypeResolver.prototype.typeCheckBase = function (typeDeclAst, typeSymbol, baseDeclAST, isExtendedType, enclosingDecl, context) { + var _this = this; + var typeDecl = this.getDeclForAST(typeDeclAst); + var contextForBaseTypeResolution = new TypeScript.PullTypeResolutionContext(); + contextForBaseTypeResolution.isResolvingClassExtendedType = true; + + var baseType = this.resolveAST(baseDeclAST, false, enclosingDecl, context); + contextForBaseTypeResolution.isResolvingClassExtendedType = false; + + var typeDeclIsClass = typeSymbol.isClass(); + + if (!typeSymbol.isValidBaseKind(baseType, isExtendedType)) { + if (baseType.isError()) { + var error = (baseType).getDiagnostic(); + if (error) { + context.postError(this.unitPath, baseDeclAST.minChar, baseDeclAST.getLength(), error.diagnosticKey(), error.arguments(), enclosingDecl); + } + } else if (isExtendedType) { + if (typeDeclIsClass) { + context.postError(this.unitPath, baseDeclAST.minChar, baseDeclAST.getLength(), TypeScript.DiagnosticCode.A_class_may_only_extend_another_class, null, enclosingDecl); + } else { + context.postError(this.unitPath, baseDeclAST.minChar, baseDeclAST.getLength(), TypeScript.DiagnosticCode.An_interface_may_only_extend_another_class_or_interface, null, enclosingDecl); + } + } else { + context.postError(this.unitPath, baseDeclAST.minChar, baseDeclAST.getLength(), TypeScript.DiagnosticCode.A_class_may_only_implement_another_class_or_interface, null, enclosingDecl); + } + return; + } else if (typeDeclIsClass && isExtendedType && baseDeclAST.nodeType() == 21 /* Name */) { + if (this.hasClassTypeSymbolConflictAsValue(baseDeclAST, baseType, enclosingDecl, context)) { + context.postError(this.unitPath, baseDeclAST.minChar, baseDeclAST.getLength(), TypeScript.DiagnosticCode.Type_reference_0_in_extends_clause_doesn_t_reference_constructor_function_for_1, [(baseDeclAST).actualText, baseType.toString(enclosingDecl ? enclosingDecl.getSymbol() : null)], enclosingDecl); + } + } + + if ((baseType.getRootSymbol()).hasBase(typeSymbol.getRootSymbol())) { + typeSymbol.setHasBaseTypeConflict(); + baseType.setHasBaseTypeConflict(); + + context.postError(this.unitPath, typeDeclAst.name.minChar, typeDeclAst.name.getLength(), typeDeclIsClass ? TypeScript.DiagnosticCode.Class_0_is_recursively_referenced_as_a_base_type_of_itself : TypeScript.DiagnosticCode.Interface_0_is_recursively_referenced_as_a_base_type_of_itself, [typeSymbol.getScopedName()], enclosingDecl); + return; + } + + if (isExtendedType) { + this.typeCheckIfTypeExtendsType(typeDeclAst, typeSymbol, baseType, enclosingDecl, context); + } else { + this.typeCheckIfClassImplementsType(typeDeclAst, typeSymbol, baseType, enclosingDecl, context); + } + + this.checkSymbolPrivacy(typeSymbol, baseType, context, function (errorSymbol) { + return _this.baseListPrivacyErrorReporter(typeDeclAst, typeSymbol, baseDeclAST, isExtendedType, errorSymbol, context); + }); + }; + + PullTypeResolver.prototype.typeCheckBases = function (typeDeclAst, typeSymbol, enclosingDecl, context) { + if (!context.typeCheck()) { + return; + } + + if (!typeDeclAst.extendsList && !typeDeclAst.implementsList) { + return; + } + + if (typeDeclAst.extendsList) { + for (var i = 0; i < typeDeclAst.extendsList.members.length; i++) { + this.typeCheckBase(typeDeclAst, typeSymbol, typeDeclAst.extendsList.members[i], true, enclosingDecl, context); + } + } + + if (typeSymbol.isClass()) { + if (typeDeclAst.implementsList) { + for (var i = 0; i < typeDeclAst.implementsList.members.length; i++) { + this.typeCheckBase(typeDeclAst, typeSymbol, typeDeclAst.implementsList.members[i], false, enclosingDecl, context); + } + } + } else if (typeDeclAst.implementsList) { + context.postError(this.unitPath, typeDeclAst.implementsList.minChar, typeDeclAst.implementsList.getLength(), TypeScript.DiagnosticCode.An_interface_cannot_implement_another_type, null, enclosingDecl); + } + }; + + PullTypeResolver.prototype.checkAssignability = function (ast, source, target, enclosingDecl, context) { + var comparisonInfo = new TypeComparisonInfo(); + + var isAssignable = this.sourceIsAssignableToTarget(source, target, context, comparisonInfo); + + if (!isAssignable) { + if (comparisonInfo.message) { + context.postError(this.unitPath, ast.minChar, ast.getLength(), TypeScript.DiagnosticCode.Cannot_convert_0_to_1_NL_2, [source.toString(), target.toString(), comparisonInfo.message], enclosingDecl); + } else { + context.postError(this.unitPath, ast.minChar, ast.getLength(), TypeScript.DiagnosticCode.Cannot_convert_0_to_1, [source.toString(), target.toString()], enclosingDecl); + } + } + }; + + PullTypeResolver.prototype.isValidLHS = function (ast, expressionSymbol) { + var expressionTypeSymbol = expressionSymbol.type; + + if (ast.nodeType() === 36 /* ElementAccessExpression */ || this.isAnyOrEquivalent(expressionTypeSymbol)) { + return true; + } else if (!expressionSymbol.isType() || expressionTypeSymbol.isArray()) { + return ((expressionSymbol.kind & TypeScript.PullElementKind.SomeLHS) != 0) && !expressionSymbol.hasFlag(4096 /* Enum */); + } + + return false; + }; + + PullTypeResolver.prototype.checkForSuperMemberAccess = function (memberAccessExpression, resolvedName, enclosingDecl, context) { + if (resolvedName) { + if (memberAccessExpression.operand1.nodeType() === 31 /* SuperExpression */ && !resolvedName.isError() && resolvedName.kind !== 65536 /* Method */) { + context.postError(this.unitPath, memberAccessExpression.operand2.minChar, memberAccessExpression.operand2.getLength(), TypeScript.DiagnosticCode.Only_public_instance_methods_of_the_base_class_are_accessible_via_the_super_keyword, [], enclosingDecl); + return true; + } + } + + return false; + }; + + PullTypeResolver.prototype.checkForPrivateMemberAccess = function (memberAccessExpression, expressionType, resolvedName, enclosingDecl, context) { + if (resolvedName) { + if (resolvedName.hasFlag(2 /* Private */)) { + var memberContainer = resolvedName.getContainer(); + if (memberContainer && memberContainer.kind === 33554432 /* ConstructorType */) { + memberContainer = memberContainer.getAssociatedContainerType(); + } + + if (memberContainer && memberContainer.isClass()) { + var containingClass = enclosingDecl; + + while (containingClass && containingClass.kind != 8 /* Class */) { + containingClass = containingClass.getParentDecl(); + } + + if (!containingClass || containingClass.getSymbol() !== memberContainer) { + var name = memberAccessExpression.operand2; + context.postError(this.unitPath, name.minChar, name.getLength(), TypeScript.DiagnosticCode._0_1_is_inaccessible, [memberContainer.toString(null, false), name.actualText], enclosingDecl); + return true; + } + } + } + } + + return false; + }; + + PullTypeResolver.prototype.checkForStaticMemberAccess = function (memberAccessExpression, expressionType, resolvedName, enclosingDecl, context) { + if (expressionType && resolvedName && !resolvedName.isError()) { + if (expressionType.isClass() || expressionType.kind === 33554432 /* ConstructorType */) { + var name = memberAccessExpression.operand2; + + if (resolvedName.hasFlag(16 /* Static */) || this.isPrototypeMember(memberAccessExpression, enclosingDecl, context)) { + if (expressionType.kind !== 33554432 /* ConstructorType */) { + context.postError(this.unitPath, name.minChar, name.getLength(), TypeScript.DiagnosticCode.Static_member_cannot_be_accessed_off_an_instance_variable, null, enclosingDecl); + return true; + } + } + } + } + + return false; + }; + PullTypeResolver.typeCheckCallBacks = []; + + PullTypeResolver.globalTypeCheckPhase = 0; + return PullTypeResolver; + })(); + TypeScript.PullTypeResolver = PullTypeResolver; + + var TypeComparisonInfo = (function () { + function TypeComparisonInfo(sourceComparisonInfo) { + this.onlyCaptureFirstError = false; + this.flags = 0 /* SuccessfulComparison */; + this.message = ""; + this.stringConstantVal = null; + this.indent = 1; + if (sourceComparisonInfo) { + this.flags = sourceComparisonInfo.flags; + this.onlyCaptureFirstError = sourceComparisonInfo.onlyCaptureFirstError; + this.stringConstantVal = sourceComparisonInfo.stringConstantVal; + this.indent = sourceComparisonInfo.indent + 1; + } + } + TypeComparisonInfo.prototype.indentString = function () { + var result = ""; + + for (var i = 0; i < this.indent; i++) { + result += "\t"; + } + + return result; + }; + + TypeComparisonInfo.prototype.addMessage = function (message) { + if (!this.onlyCaptureFirstError && this.message) { + this.message = this.message + TypeScript.newLine() + this.indentString() + message; + } else { + this.message = this.indentString() + message; + } + }; + + TypeComparisonInfo.prototype.setMessage = function (message) { + this.message = this.indentString() + message; + }; + return TypeComparisonInfo; + })(); + TypeScript.TypeComparisonInfo = TypeComparisonInfo; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + TypeScript.declCacheHit = 0; + TypeScript.declCacheMiss = 0; + TypeScript.symbolCacheHit = 0; + TypeScript.symbolCacheMiss = 0; + + var sentinalEmptyArray = []; + + var SemanticInfo = (function () { + function SemanticInfo(compilationUnitPath) { + this.topLevelDecls = []; + this.topLevelSynthesizedDecls = []; + this.declASTMap = new TypeScript.DataMap(); + this.astDeclMap = new TypeScript.DataMap(); + this.astSymbolMap = new TypeScript.DataMap(); + this.astAliasSymbolMap = new TypeScript.DataMap(); + this.symbolASTMap = new TypeScript.DataMap(); + this.astCallResolutionDataMap = TypeScript.Collections.createHashTable(TypeScript.Collections.DefaultHashTableCapacity, function (k) { + return k; + }); + this.syntaxElementSymbolMap = new TypeScript.DataMap(); + this.symbolSyntaxElementMap = new TypeScript.DataMap(); + this.hasBeenTypeChecked = false; + this.compilationUnitPath = compilationUnitPath; + } + SemanticInfo.prototype.addTopLevelDecl = function (decl) { + this.topLevelDecls[this.topLevelDecls.length] = decl; + }; + + SemanticInfo.prototype.setTypeChecked = function (shouldTC) { + if (typeof shouldTC === "undefined") { shouldTC = true; } + this.hasBeenTypeChecked = shouldTC; + }; + SemanticInfo.prototype.getTypeChecked = function () { + return this.hasBeenTypeChecked; + }; + SemanticInfo.prototype.invalidate = function () { + this.astSymbolMap = new TypeScript.DataMap(); + this.symbolASTMap = new TypeScript.DataMap(); + }; + + SemanticInfo.prototype.getTopLevelDecls = function () { + return this.topLevelDecls; + }; + + SemanticInfo.prototype.getPath = function () { + return this.compilationUnitPath; + }; + + SemanticInfo.prototype.addSynthesizedDecl = function (decl) { + this.topLevelSynthesizedDecls[this.topLevelSynthesizedDecls.length] = decl; + }; + + SemanticInfo.prototype.getSynthesizedDecls = function () { + return this.topLevelSynthesizedDecls; + }; + + SemanticInfo.prototype.cleanSynthesizedDecls = function () { + this.topLevelSynthesizedDecls = []; + }; + + SemanticInfo.prototype.getDeclForAST = function (ast) { + if (TypeScript.useDirectTypeStorage) { + return ast.decl; + } + + return this.astDeclMap.read(ast.astIDString); + }; + + SemanticInfo.prototype.setDeclForAST = function (ast, decl) { + if (TypeScript.useDirectTypeStorage) { + ast.decl = decl; + return; + } + + this.astDeclMap.link(ast.astIDString, decl); + }; + + SemanticInfo.prototype.getASTForDecl = function (decl) { + if (TypeScript.useDirectTypeStorage) { + return decl.ast; + } + + return this.declASTMap.read(decl.declIDString); + }; + + SemanticInfo.prototype.setASTForDecl = function (decl, ast) { + if (TypeScript.useDirectTypeStorage) { + decl.ast = ast; + return; + } + + this.declASTMap.link(decl.declIDString, ast); + }; + + SemanticInfo.prototype.setSymbolForAST = function (ast, symbol) { + if (TypeScript.useDirectTypeStorage) { + ast.symbol = symbol; + symbol.ast = ast; + return; + } + + this.astSymbolMap.link(ast.astIDString, symbol); + this.symbolASTMap.link(symbol.pullSymbolIDString, ast); + }; + + SemanticInfo.prototype.getSymbolForAST = function (ast) { + if (TypeScript.useDirectTypeStorage) { + return (ast).symbol; + } + return this.astSymbolMap.read(ast.astIDString); + }; + + SemanticInfo.prototype.getASTForSymbol = function (symbol) { + if (TypeScript.useDirectTypeStorage) { + return symbol.ast; + } + return this.symbolASTMap.read(symbol.pullSymbolIDString); + }; + + SemanticInfo.prototype.setAliasSymbolForAST = function (ast, symbol) { + if (TypeScript.useDirectTypeStorage) { + ast.aliasSymbol = symbol; + return; + } + this.astAliasSymbolMap.link(ast.astIDString, symbol); + }; + + SemanticInfo.prototype.getAliasSymbolForAST = function (ast) { + if (TypeScript.useDirectTypeStorage) { + return (ast).aliasSymbol; + } + return this.astAliasSymbolMap.read(ast.astIDString); + }; + + SemanticInfo.prototype.getCallResolutionDataForAST = function (ast) { + if (TypeScript.useDirectTypeStorage) { + return (ast).callResolutionData; + } + return this.astCallResolutionDataMap.get(ast.astID); + }; + + SemanticInfo.prototype.setCallResolutionDataForAST = function (ast, callResolutionData) { + if (callResolutionData) { + if (TypeScript.useDirectTypeStorage) { + (ast).callResolutionData = callResolutionData; + return; + } + this.astCallResolutionDataMap.set(ast.astID, callResolutionData); + } + }; + + SemanticInfo.prototype.getDiagnostics = function (semanticErrors) { + for (var i = 0; i < this.topLevelDecls.length; i++) { + TypeScript.getDiagnosticsFromEnclosingDecl(this.topLevelDecls[i], semanticErrors); + } + }; + return SemanticInfo; + })(); + TypeScript.SemanticInfo = SemanticInfo; + + var SemanticInfoChain = (function () { + function SemanticInfoChain() { + this.units = [new SemanticInfo("")]; + this.declCache = new TypeScript.BlockIntrinsics(); + this.symbolCache = new TypeScript.BlockIntrinsics(); + this.unitCache = new TypeScript.BlockIntrinsics(); + this.topLevelDecls = []; + this.anyTypeSymbol = null; + this.booleanTypeSymbol = null; + this.numberTypeSymbol = null; + this.stringTypeSymbol = null; + this.nullTypeSymbol = null; + this.undefinedTypeSymbol = null; + this.voidTypeSymbol = null; + if (TypeScript.globalBinder) { + TypeScript.globalBinder.semanticInfoChain = this; + } + + var globalDecl = this.getGlobalDecl(); + var globalInfo = this.units[0]; + globalInfo.addTopLevelDecl(globalDecl); + } + SemanticInfoChain.prototype.addPrimitiveType = function (name, globalDecl) { + var span = new TypeScript.TextSpan(0, 0); + var decl = new TypeScript.PullDecl(name, name, 2 /* Primitive */, 0 /* None */, span, ""); + var symbol = new TypeScript.PullPrimitiveTypeSymbol(name); + + symbol.addDeclaration(decl); + decl.setSymbol(symbol); + + symbol.setResolved(); + + if (globalDecl) { + globalDecl.addChildDecl(decl); + } + + return symbol; + }; + + SemanticInfoChain.prototype.addPrimitiveValue = function (name, type, globalDecl) { + var span = new TypeScript.TextSpan(0, 0); + var decl = new TypeScript.PullDecl(name, name, 1024 /* Variable */, 8 /* Ambient */, span, ""); + var symbol = new TypeScript.PullSymbol(name, 1024 /* Variable */); + + symbol.addDeclaration(decl); + decl.setSymbol(symbol); + symbol.type = type; + symbol.setResolved(); + + globalDecl.addChildDecl(decl); + }; + + SemanticInfoChain.prototype.getGlobalDecl = function () { + var span = new TypeScript.TextSpan(0, 0); + var globalDecl = new TypeScript.PullDecl("", "", 0 /* Global */, 0 /* None */, span, ""); + + this.anyTypeSymbol = this.addPrimitiveType("any", globalDecl); + this.booleanTypeSymbol = this.addPrimitiveType("boolean", globalDecl); + this.numberTypeSymbol = this.addPrimitiveType("number", globalDecl); + this.stringTypeSymbol = this.addPrimitiveType("string", globalDecl); + this.voidTypeSymbol = this.addPrimitiveType("void", globalDecl); + + this.nullTypeSymbol = this.addPrimitiveType("null", null); + this.undefinedTypeSymbol = this.addPrimitiveType("undefined", null); + this.addPrimitiveValue("undefined", this.undefinedTypeSymbol, globalDecl); + this.addPrimitiveValue("null", this.nullTypeSymbol, globalDecl); + + return globalDecl; + }; + + SemanticInfoChain.prototype.addUnit = function (unit) { + this.units[this.units.length] = unit; + this.unitCache[unit.getPath()] = unit; + }; + + SemanticInfoChain.prototype.getUnit = function (compilationUnitPath) { + return this.unitCache[compilationUnitPath]; + }; + + SemanticInfoChain.prototype.updateUnit = function (oldUnit, newUnit) { + for (var i = 0; i < this.units.length; i++) { + if (this.units[i].getPath() === oldUnit.getPath()) { + this.units[i] = newUnit; + this.unitCache[oldUnit.getPath()] = newUnit; + return; + } + } + }; + + SemanticInfoChain.prototype.collectAllTopLevelDecls = function () { + if (this.topLevelDecls.length) { + return this.topLevelDecls; + } + + var unitDecls; + + for (var i = 0; i < this.units.length; i++) { + unitDecls = this.units[i].getTopLevelDecls(); + for (var j = 0; j < unitDecls.length; j++) { + this.topLevelDecls[this.topLevelDecls.length] = unitDecls[j]; + } + } + + return this.topLevelDecls; + }; + + SemanticInfoChain.prototype.collectAllSynthesizedDecls = function () { + var decls = []; + var synthDecls; + + for (var i = 0; i < this.units.length; i++) { + synthDecls = this.units[i].getSynthesizedDecls(); + for (var j = 0; j < synthDecls.length; j++) { + decls[decls.length] = synthDecls[j]; + } + } + + return decls; + }; + + SemanticInfoChain.prototype.getDeclPathCacheID = function (declPath, declKind) { + var cacheID = ""; + + for (var i = 0; i < declPath.length; i++) { + cacheID += "#" + declPath[i]; + } + + return cacheID + "#" + declKind.toString(); + }; + + SemanticInfoChain.prototype.findTopLevelSymbol = function (name, kind, stopAtFile) { + var cacheID = this.getDeclPathCacheID([name], kind); + + var symbol = this.symbolCache[name]; + + if (!symbol) { + var topLevelDecls = this.collectAllTopLevelDecls(); + var foundDecls = null; + + for (var i = 0; i < topLevelDecls.length; i++) { + foundDecls = topLevelDecls[i].searchChildDecls(name, kind); + + if (foundDecls.length) { + symbol = foundDecls[0].getSymbol(); + break; + } + + if (topLevelDecls[i].name == stopAtFile) { + break; + } + } + + if (symbol) { + this.symbolCache[cacheID] = symbol; + + symbol.addCacheID(cacheID); + } + } + + return symbol; + }; + + SemanticInfoChain.prototype.findDecls = function (declPath, declKind) { + var cacheID = this.getDeclPathCacheID(declPath, declKind); + + if (declPath.length) { + var cachedDecls = this.declCache[cacheID]; + + if (cachedDecls && cachedDecls.length) { + TypeScript.declCacheHit++; + return cachedDecls; + } + } + + TypeScript.declCacheMiss++; + + if (declKind == 32 /* DynamicModule */ && declPath.length == 1) { + var path = declPath[0]; + + if (TypeScript.isRooted(path)) { + var unit = this.unitCache[path]; + + if (unit) { + var decl = unit.getTopLevelDecls()[0].getChildDecls()[0]; + + if (decl.kind == 32 /* DynamicModule */) { + return [decl]; + } + } + + return TypeScript.sentinelEmptyArray; + } + } + + var declsToSearch = this.collectAllTopLevelDecls(); + + var decls = TypeScript.sentinelEmptyArray; + var path; + var foundDecls = TypeScript.sentinelEmptyArray; + var keepSearching = (declKind & TypeScript.PullElementKind.SomeContainer) || (declKind & 16 /* Interface */); + + for (var i = 0; i < declPath.length; i++) { + path = declPath[i]; + decls = TypeScript.sentinelEmptyArray; + + for (var j = 0; j < declsToSearch.length; j++) { + foundDecls = declsToSearch[j].searchChildDecls(path, declKind); + + for (var k = 0; k < foundDecls.length; k++) { + if (decls == TypeScript.sentinelEmptyArray) { + decls = []; + } + decls[decls.length] = foundDecls[k]; + } + + if (foundDecls.length && !keepSearching) { + break; + } + } + + declsToSearch = decls; + + if (!declsToSearch) { + break; + } + } + + if (decls.length) { + this.declCache[cacheID] = decls; + } + + return decls; + }; + + SemanticInfoChain.prototype.findDeclsFromPath = function (declPath, declKind) { + var declString = []; + + for (var i = 0, n = declPath.length; i < n; i++) { + if (declPath[i].kind & 1 /* Script */) { + continue; + } + + declString.push(declPath[i].name); + } + + return this.findDecls(declString, declKind); + }; + + SemanticInfoChain.prototype.findSymbol = function (declPath, declType) { + var cacheID = this.getDeclPathCacheID(declPath, declType); + + if (declPath.length) { + var cachedSymbol = this.symbolCache[cacheID]; + + if (cachedSymbol) { + TypeScript.symbolCacheHit++; + return cachedSymbol; + } + } + + TypeScript.symbolCacheMiss++; + + var decls = this.findDecls(declPath, declType); + var symbol = null; + + if (decls.length) { + symbol = decls[0].getSymbol(); + + if (symbol) { + this.symbolCache[cacheID] = symbol; + + symbol.addCacheID(cacheID); + } + } + + return symbol; + }; + + SemanticInfoChain.prototype.cacheGlobalSymbol = function (symbol, kind) { + var cacheID1 = this.getDeclPathCacheID([symbol.name], kind); + var cacheID2 = this.getDeclPathCacheID([symbol.name], symbol.kind); + + if (!this.symbolCache[cacheID1]) { + this.symbolCache[cacheID1] = symbol; + symbol.addCacheID(cacheID1); + } + + if (!this.symbolCache[cacheID2]) { + this.symbolCache[cacheID2] = symbol; + symbol.addCacheID(cacheID2); + } + }; + + SemanticInfoChain.prototype.cleanDecl = function (decl) { + decl.setSymbol(null); + decl.setSignatureSymbol(null); + decl.setSpecializingSignatureSymbol(null); + decl.setIsBound(false); + + var children = decl.getChildDecls(); + + for (var i = 0; i < children.length; i++) { + this.cleanDecl(children[i]); + } + + var typeParameters = decl.getTypeParameters(); + + for (var i = 0; i < typeParameters.length; i++) { + this.cleanDecl(typeParameters[i]); + } + + var valueDecl = decl.getValueDecl(); + + if (valueDecl) { + this.cleanDecl(valueDecl); + } + }; + + SemanticInfoChain.prototype.cleanAllDecls = function () { + var topLevelDecls = this.collectAllTopLevelDecls(); + + for (var i = 1; i < topLevelDecls.length; i++) { + this.cleanDecl(topLevelDecls[i]); + } + + var synthesizedDecls = this.collectAllSynthesizedDecls(); + + for (var i = 0; i < synthesizedDecls.length; i++) { + this.cleanDecl(synthesizedDecls[i]); + } + + this.cleanAllSynthesizedDecls(); + this.topLevelDecls = []; + }; + + SemanticInfoChain.prototype.cleanAllSynthesizedDecls = function () { + for (var i = 0; i < this.units.length; i++) { + this.units[i].cleanSynthesizedDecls(); + } + }; + + SemanticInfoChain.prototype.update = function () { + this.declCache = new TypeScript.BlockIntrinsics(); + this.symbolCache = new TypeScript.BlockIntrinsics(); + this.units[0] = new SemanticInfo(""); + this.units[0].addTopLevelDecl(this.getGlobalDecl()); + this.cleanAllDecls(); + + for (var unit in this.unitCache) { + if (this.unitCache[unit]) { + this.unitCache[unit].invalidate(); + } + } + }; + + SemanticInfoChain.prototype.invalidateUnit = function (compilationUnitPath) { + var unit = this.unitCache[compilationUnitPath]; + if (unit) { + unit.invalidate(); + } + }; + + SemanticInfoChain.prototype.forceTypeCheck = function (compilationUnitPath) { + var unit = this.unitCache[compilationUnitPath]; + if (unit) { + unit.setTypeChecked(false); + } + }; + + SemanticInfoChain.prototype.getDeclForAST = function (ast, unitPath) { + var unit = this.unitCache[unitPath]; + + if (unit) { + return unit.getDeclForAST(ast); + } + + return null; + }; + + SemanticInfoChain.prototype.getASTForDecl = function (decl) { + var unit = this.unitCache[decl.getScriptName()]; + + if (unit) { + return unit.getASTForDecl(decl); + } + + return null; + }; + + SemanticInfoChain.prototype.getSymbolForAST = function (ast, unitPath) { + if (TypeScript.useDirectTypeStorage) { + return (ast).symbol; + } + + var unit = this.unitCache[unitPath]; + + if (unit) { + return unit.getSymbolForAST(ast); + } + + return null; + }; + + SemanticInfoChain.prototype.getASTForSymbol = function (symbol, unitPath) { + if (TypeScript.useDirectTypeStorage) { + return symbol.ast; + } + + var unit = this.unitCache[unitPath]; + + if (unit) { + return unit.getASTForSymbol(symbol); + } + + return null; + }; + + SemanticInfoChain.prototype.setSymbolForAST = function (ast, symbol, unitPath) { + if (TypeScript.useDirectTypeStorage) { + ast.symbol = symbol; + return; + } + + var unit = this.unitCache[unitPath]; + + if (unit) { + unit.setSymbolForAST(ast, symbol); + } + }; + + SemanticInfoChain.prototype.getAliasSymbolForAST = function (ast, unitPath) { + if (TypeScript.useDirectTypeStorage) { + return (ast).aliasSymbol; + } + + var unit = this.unitCache[unitPath]; + + if (unit) { + return unit.getAliasSymbolForAST(ast); + } + + return null; + }; + + SemanticInfoChain.prototype.removeSymbolFromCache = function (symbol) { + var path = [symbol.name]; + var kind = (symbol.kind & TypeScript.PullElementKind.SomeType) !== 0 ? TypeScript.PullElementKind.SomeType : TypeScript.PullElementKind.SomeValue; + + var kindID = this.getDeclPathCacheID(path, kind); + var symID = this.getDeclPathCacheID(path, symbol.kind); + + symbol.addCacheID(kindID); + symbol.addCacheID(symID); + + symbol.invalidateCachedIDs(this.symbolCache); + }; + + SemanticInfoChain.prototype.postDiagnostics = function () { + var errors = []; + + for (var i = 1; i < this.units.length; i++) { + this.units[i].getDiagnostics(errors); + } + + return errors; + }; + return SemanticInfoChain; + })(); + TypeScript.SemanticInfoChain = SemanticInfoChain; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var DeclCollectionContext = (function () { + function DeclCollectionContext(semanticInfo, scriptName) { + this.semanticInfo = semanticInfo; + this.scriptName = scriptName; + this.isDeclareFile = false; + this.parentChain = new Array(); + this.containingModuleHasExportAssignmentArray = [false]; + this.isParsingAmbientModuleArray = [false]; + this.foundValueDecl = false; + } + DeclCollectionContext.prototype.getParent = function () { + return this.parentChain ? this.parentChain[this.parentChain.length - 1] : null; + }; + + DeclCollectionContext.prototype.pushParent = function (parentDecl) { + if (parentDecl) { + this.parentChain[this.parentChain.length] = parentDecl; + } + }; + + DeclCollectionContext.prototype.popParent = function () { + this.parentChain.length--; + }; + + DeclCollectionContext.prototype.containingModuleHasExportAssignment = function () { + TypeScript.Debug.assert(this.containingModuleHasExportAssignmentArray.length > 0); + return TypeScript.ArrayUtilities.last(this.containingModuleHasExportAssignmentArray); + }; + + DeclCollectionContext.prototype.isParsingAmbientModule = function () { + TypeScript.Debug.assert(this.isParsingAmbientModuleArray.length > 0); + return TypeScript.ArrayUtilities.last(this.isParsingAmbientModuleArray); + }; + return DeclCollectionContext; + })(); + TypeScript.DeclCollectionContext = DeclCollectionContext; + + function preCollectImportDecls(ast, parentAST, context) { + var importDecl = ast; + var declFlags = 0 /* None */; + var span = TypeScript.TextSpan.fromBounds(importDecl.minChar, importDecl.limChar); + + var parent = context.getParent(); + + if (!context.containingModuleHasExportAssignment() && TypeScript.hasFlag(importDecl.getVarFlags(), 1 /* Exported */)) { + declFlags |= 1 /* Exported */; + } + + if (parent && (parent.kind === 536870912 /* WithBlock */ || (parent.flags & 2097152 /* DeclaredInAWithBlock */))) { + declFlags |= 2097152 /* DeclaredInAWithBlock */; + } + + var decl = new TypeScript.PullDecl(importDecl.id.text(), importDecl.id.actualText, 256 /* TypeAlias */, declFlags, span, context.scriptName); + context.semanticInfo.setDeclForAST(ast, decl); + context.semanticInfo.setASTForDecl(decl, ast); + + parent.addChildDecl(decl); + decl.setParentDecl(parent); + + return false; + } + + function preCollectModuleDecls(ast, parentAST, context) { + var moduleDecl = ast; + var declFlags = 0 /* None */; + var modName = (moduleDecl.name).text(); + var isDynamic = TypeScript.isQuoted(modName) || TypeScript.hasFlag(moduleDecl.getModuleFlags(), 512 /* IsDynamic */); + var kind = 4 /* Container */; + + if (!context.containingModuleHasExportAssignment() && (TypeScript.hasFlag(moduleDecl.getModuleFlags(), 1 /* Exported */) || context.isParsingAmbientModule())) { + declFlags |= 1 /* Exported */; + } + + if (TypeScript.hasFlag(moduleDecl.getModuleFlags(), 8 /* Ambient */) || context.isParsingAmbientModule() || context.isDeclareFile) { + declFlags |= 8 /* Ambient */; + } + + if (TypeScript.hasFlag(moduleDecl.getModuleFlags(), 128 /* IsEnum */)) { + declFlags |= (4096 /* Enum */ | 131072 /* InitializedEnum */); + kind = 64 /* Enum */; + } else { + kind = isDynamic ? 32 /* DynamicModule */ : 4 /* Container */; + } + + var span = TypeScript.TextSpan.fromBounds(moduleDecl.minChar, moduleDecl.limChar); + + var decl = new TypeScript.PullDecl(modName, (moduleDecl.name).actualText, kind, declFlags, span, context.scriptName); + context.semanticInfo.setDeclForAST(ast, decl); + context.semanticInfo.setASTForDecl(decl, ast); + + var parent = context.getParent(); + parent.addChildDecl(decl); + decl.setParentDecl(parent); + + context.pushParent(decl); + + context.containingModuleHasExportAssignmentArray.push(TypeScript.ArrayUtilities.any(moduleDecl.members.members, function (m) { + return m.nodeType() === 88 /* ExportAssignment */; + })); + context.isParsingAmbientModuleArray.push(context.isDeclareFile || TypeScript.ArrayUtilities.last(context.isParsingAmbientModuleArray) || TypeScript.hasFlag(moduleDecl.getModuleFlags(), 8 /* Ambient */)); + + return true; + } + + function preCollectClassDecls(classDecl, parentAST, context) { + var declFlags = 0 /* None */; + var constructorDeclKind = 1024 /* Variable */; + + if (!context.containingModuleHasExportAssignment() && (TypeScript.hasFlag(classDecl.getVarFlags(), 1 /* Exported */) || context.isParsingAmbientModule())) { + declFlags |= 1 /* Exported */; + } + + if (TypeScript.hasFlag(classDecl.getVarFlags(), 8 /* Ambient */) || context.isParsingAmbientModule() || context.isDeclareFile) { + declFlags |= 8 /* Ambient */; + } + + var span = TypeScript.TextSpan.fromBounds(classDecl.minChar, classDecl.limChar); + + var decl = new TypeScript.PullDecl(classDecl.name.text(), classDecl.name.actualText, 8 /* Class */, declFlags, span, context.scriptName); + + var constructorDecl = new TypeScript.PullDecl(classDecl.name.text(), classDecl.name.actualText, constructorDeclKind, declFlags | 16384 /* ClassConstructorVariable */, span, context.scriptName); + + decl.setValueDecl(constructorDecl); + + var parent = context.getParent(); + parent.addChildDecl(decl); + parent.addChildDecl(constructorDecl); + decl.setParentDecl(parent); + constructorDecl.setParentDecl(parent); + + context.pushParent(decl); + + context.semanticInfo.setDeclForAST(classDecl, decl); + context.semanticInfo.setASTForDecl(decl, classDecl); + context.semanticInfo.setASTForDecl(constructorDecl, classDecl); + + return true; + } + + function createObjectTypeDeclaration(interfaceDecl, context) { + var declFlags = 0 /* None */; + + var span = TypeScript.TextSpan.fromBounds(interfaceDecl.minChar, interfaceDecl.limChar); + + var parent = context.getParent(); + + if (parent && (parent.kind === 536870912 /* WithBlock */ || (parent.flags & 2097152 /* DeclaredInAWithBlock */))) { + declFlags |= 2097152 /* DeclaredInAWithBlock */; + } + + var decl = new TypeScript.PullDecl("", "", 8388608 /* ObjectType */, declFlags, span, context.scriptName); + context.semanticInfo.setDeclForAST(interfaceDecl, decl); + context.semanticInfo.setASTForDecl(decl, interfaceDecl); + + if (parent) { + parent.addChildDecl(decl); + decl.setParentDecl(parent); + } + + context.pushParent(decl); + + return true; + } + + function preCollectInterfaceDecls(interfaceDecl, parentAST, context) { + var declFlags = 0 /* None */; + + if (interfaceDecl.getFlags() & 8 /* TypeReference */) { + return createObjectTypeDeclaration(interfaceDecl, context); + } + + if (!context.containingModuleHasExportAssignment() && (TypeScript.hasFlag(interfaceDecl.getVarFlags(), 1 /* Exported */) || context.isParsingAmbientModule())) { + declFlags |= 1 /* Exported */; + } + + var span = TypeScript.TextSpan.fromBounds(interfaceDecl.minChar, interfaceDecl.limChar); + + var decl = new TypeScript.PullDecl(interfaceDecl.name.text(), interfaceDecl.name.actualText, 16 /* Interface */, declFlags, span, context.scriptName); + context.semanticInfo.setDeclForAST(interfaceDecl, decl); + context.semanticInfo.setASTForDecl(decl, interfaceDecl); + + var parent = context.getParent(); + + if (parent) { + parent.addChildDecl(decl); + decl.setParentDecl(parent); + } + + context.pushParent(decl); + + return true; + } + + function preCollectParameterDecl(argDecl, parentAST, context) { + var declFlags = 0 /* None */; + + if (TypeScript.hasFlag(argDecl.getVarFlags(), 2 /* Private */)) { + declFlags |= 2 /* Private */; + } else { + declFlags |= 4 /* Public */; + } + + if (TypeScript.hasFlag(argDecl.getFlags(), 4 /* OptionalName */) || TypeScript.hasFlag(argDecl.id.getFlags(), 4 /* OptionalName */)) { + declFlags |= 128 /* Optional */; + } + + var parent = context.getParent(); + + if (parent && (parent.kind === 536870912 /* WithBlock */ || (parent.flags & 2097152 /* DeclaredInAWithBlock */))) { + declFlags |= 2097152 /* DeclaredInAWithBlock */; + } + + var span = TypeScript.TextSpan.fromBounds(argDecl.minChar, argDecl.limChar); + + var decl = new TypeScript.PullDecl(argDecl.id.text(), argDecl.id.actualText, 2048 /* Parameter */, declFlags, span, context.scriptName); + + parent.addChildDecl(decl); + decl.setParentDecl(parent); + + if (TypeScript.hasFlag(argDecl.getVarFlags(), 256 /* Property */)) { + var propDecl = new TypeScript.PullDecl(argDecl.id.text(), argDecl.id.actualText, 4096 /* Property */, declFlags, span, context.scriptName); + propDecl.setValueDecl(decl); + decl.setFlag(8388608 /* PropertyParameter */); + context.parentChain[context.parentChain.length - 2].addChildDecl(propDecl); + propDecl.setParentDecl(context.parentChain[context.parentChain.length - 2]); + context.semanticInfo.setASTForDecl(decl, argDecl); + context.semanticInfo.setASTForDecl(propDecl, argDecl); + context.semanticInfo.setDeclForAST(argDecl, propDecl); + } else { + context.semanticInfo.setASTForDecl(decl, argDecl); + context.semanticInfo.setDeclForAST(argDecl, decl); + } + + if (argDecl.typeExpr && ((argDecl.typeExpr).term.nodeType() === 15 /* InterfaceDeclaration */ || (argDecl.typeExpr).term.nodeType() === 13 /* FunctionDeclaration */)) { + var declCollectionContext = new DeclCollectionContext(context.semanticInfo, context.scriptName); + + if (parent) { + declCollectionContext.pushParent(parent); + } + + TypeScript.getAstWalkerFactory().walk((argDecl.typeExpr).term, preCollectDecls, postCollectDecls, null, declCollectionContext); + } + + return false; + } + + function preCollectTypeParameterDecl(typeParameterDecl, parentAST, context) { + var declFlags = 0 /* None */; + + var span = TypeScript.TextSpan.fromBounds(typeParameterDecl.minChar, typeParameterDecl.limChar); + + var parent = context.getParent(); + + if (parent && (parent.kind === 536870912 /* WithBlock */ || (parent.flags & 2097152 /* DeclaredInAWithBlock */))) { + declFlags |= 2097152 /* DeclaredInAWithBlock */; + } + + var decl = new TypeScript.PullDecl(typeParameterDecl.name.text(), typeParameterDecl.name.actualText, 8192 /* TypeParameter */, declFlags, span, context.scriptName); + context.semanticInfo.setASTForDecl(decl, typeParameterDecl); + context.semanticInfo.setDeclForAST(typeParameterDecl, decl); + + parent.addChildDecl(decl); + decl.setParentDecl(parent); + + if (typeParameterDecl.constraint && ((typeParameterDecl.constraint).term.nodeType() === 15 /* InterfaceDeclaration */ || (typeParameterDecl.constraint).term.nodeType() === 13 /* FunctionDeclaration */)) { + var declCollectionContext = new DeclCollectionContext(context.semanticInfo, context.scriptName); + + if (parent) { + declCollectionContext.pushParent(parent); + } + + TypeScript.getAstWalkerFactory().walk((typeParameterDecl.constraint).term, preCollectDecls, postCollectDecls, null, declCollectionContext); + } + + return true; + } + + function createPropertySignature(propertyDecl, context) { + var declFlags = 4 /* Public */; + var parent = context.getParent(); + var declType = parent.kind === 64 /* Enum */ ? 67108864 /* EnumMember */ : 4096 /* Property */; + + if (TypeScript.hasFlag(propertyDecl.id.getFlags(), 4 /* OptionalName */)) { + declFlags |= 128 /* Optional */; + } + + if (propertyDecl.constantValue !== null) { + declFlags |= 524288 /* Constant */; + } + + var span = TypeScript.TextSpan.fromBounds(propertyDecl.minChar, propertyDecl.limChar); + + var decl = new TypeScript.PullDecl(propertyDecl.id.text(), propertyDecl.id.actualText, declType, declFlags, span, context.scriptName); + context.semanticInfo.setDeclForAST(propertyDecl, decl); + context.semanticInfo.setASTForDecl(decl, propertyDecl); + + parent.addChildDecl(decl); + decl.setParentDecl(parent); + + if (propertyDecl.typeExpr && ((propertyDecl.typeExpr).term.nodeType() === 15 /* InterfaceDeclaration */ || (propertyDecl.typeExpr).term.nodeType() === 13 /* FunctionDeclaration */)) { + var declCollectionContext = new DeclCollectionContext(context.semanticInfo, context.scriptName); + + if (parent) { + declCollectionContext.pushParent(parent); + } + + TypeScript.getAstWalkerFactory().walk((propertyDecl.typeExpr).term, preCollectDecls, postCollectDecls, null, declCollectionContext); + } + + return false; + } + + function createMemberVariableDeclaration(memberDecl, context) { + var declFlags = 0 /* None */; + var declType = 4096 /* Property */; + + if (TypeScript.hasFlag(memberDecl.getVarFlags(), 2 /* Private */)) { + declFlags |= 2 /* Private */; + } else { + declFlags |= 4 /* Public */; + } + + if (TypeScript.hasFlag(memberDecl.getVarFlags(), 16 /* Static */)) { + declFlags |= 16 /* Static */; + } + + var span = TypeScript.TextSpan.fromBounds(memberDecl.minChar, memberDecl.limChar); + + var decl = new TypeScript.PullDecl(memberDecl.id.text(), memberDecl.id.actualText, declType, declFlags, span, context.scriptName); + context.semanticInfo.setDeclForAST(memberDecl, decl); + context.semanticInfo.setASTForDecl(decl, memberDecl); + + var parent = context.getParent(); + parent.addChildDecl(decl); + decl.setParentDecl(parent); + + if (memberDecl.typeExpr && ((memberDecl.typeExpr).term.nodeType() === 15 /* InterfaceDeclaration */ || (memberDecl.typeExpr).term.nodeType() === 13 /* FunctionDeclaration */)) { + var declCollectionContext = new DeclCollectionContext(context.semanticInfo, context.scriptName); + + if (parent) { + declCollectionContext.pushParent(parent); + } + + TypeScript.getAstWalkerFactory().walk((memberDecl.typeExpr).term, preCollectDecls, postCollectDecls, null, declCollectionContext); + } + + return false; + } + + function createVariableDeclaration(varDecl, context) { + var declFlags = 0 /* None */; + var declType = 1024 /* Variable */; + + if (!context.containingModuleHasExportAssignment() && (TypeScript.hasFlag(varDecl.getVarFlags(), 1 /* Exported */) || context.isParsingAmbientModule())) { + declFlags |= 1 /* Exported */; + } + + if (TypeScript.hasFlag(varDecl.getVarFlags(), 8 /* Ambient */) || context.isParsingAmbientModule() || context.isDeclareFile) { + declFlags |= 8 /* Ambient */; + } + + var span = TypeScript.TextSpan.fromBounds(varDecl.minChar, varDecl.limChar); + + var parent = context.getParent(); + + if (parent && (parent.kind === 536870912 /* WithBlock */ || (parent.flags & 2097152 /* DeclaredInAWithBlock */))) { + declFlags |= 2097152 /* DeclaredInAWithBlock */; + } + + var decl = new TypeScript.PullDecl(varDecl.id.text(), varDecl.id.actualText, declType, declFlags, span, context.scriptName); + context.semanticInfo.setDeclForAST(varDecl, decl); + context.semanticInfo.setASTForDecl(decl, varDecl); + + parent.addChildDecl(decl); + decl.setParentDecl(parent); + + if (varDecl.typeExpr && ((varDecl.typeExpr).term.nodeType() === 15 /* InterfaceDeclaration */ || (varDecl.typeExpr).term.nodeType() === 13 /* FunctionDeclaration */)) { + var declCollectionContext = new DeclCollectionContext(context.semanticInfo, context.scriptName); + + if (parent) { + declCollectionContext.pushParent(parent); + } + + TypeScript.getAstWalkerFactory().walk((varDecl.typeExpr).term, preCollectDecls, postCollectDecls, null, declCollectionContext); + } + + return false; + } + + function preCollectVarDecls(ast, parentAST, context) { + var varDecl = ast; + var declFlags = 0 /* None */; + var declType = 1024 /* Variable */; + var isProperty = false; + var isStatic = false; + + if (TypeScript.hasFlag(varDecl.getVarFlags(), 2048 /* ClassProperty */)) { + return createMemberVariableDeclaration(varDecl, context); + } else if (TypeScript.hasFlag(varDecl.getVarFlags(), 256 /* Property */)) { + return createPropertySignature(varDecl, context); + } + + return createVariableDeclaration(varDecl, context); + } + + function createFunctionTypeDeclaration(functionTypeDeclAST, context) { + var declFlags = 2048 /* Signature */; + var declType = 16777216 /* FunctionType */; + + var span = TypeScript.TextSpan.fromBounds(functionTypeDeclAST.minChar, functionTypeDeclAST.limChar); + + var parent = context.getParent(); + + if (parent && (parent.kind === 536870912 /* WithBlock */ || (parent.flags & 2097152 /* DeclaredInAWithBlock */))) { + declFlags |= 2097152 /* DeclaredInAWithBlock */; + } + + var decl = new TypeScript.PullDecl("", "", declType, declFlags, span, context.semanticInfo.getPath()); + context.semanticInfo.setDeclForAST(functionTypeDeclAST, decl); + context.semanticInfo.setASTForDecl(decl, functionTypeDeclAST); + + if (parent) { + parent.addChildDecl(decl); + decl.setParentDecl(parent); + } + + context.pushParent(decl); + + if (functionTypeDeclAST.returnTypeAnnotation && ((functionTypeDeclAST.returnTypeAnnotation).term.nodeType() === 15 /* InterfaceDeclaration */ || (functionTypeDeclAST.returnTypeAnnotation).term.nodeType() === 13 /* FunctionDeclaration */)) { + var declCollectionContext = new DeclCollectionContext(context.semanticInfo, context.scriptName); + + declCollectionContext.pushParent(decl); + + TypeScript.getAstWalkerFactory().walk((functionTypeDeclAST.returnTypeAnnotation).term, preCollectDecls, postCollectDecls, null, declCollectionContext); + } + + return true; + } + + function createConstructorTypeDeclaration(constructorTypeDeclAST, context) { + var declFlags = 0 /* None */; + var declType = 33554432 /* ConstructorType */; + + var span = TypeScript.TextSpan.fromBounds(constructorTypeDeclAST.minChar, constructorTypeDeclAST.limChar); + + var parent = context.getParent(); + + if (parent && (parent.kind === 536870912 /* WithBlock */ || (parent.flags & 2097152 /* DeclaredInAWithBlock */))) { + declFlags |= 2097152 /* DeclaredInAWithBlock */; + } + + var decl = new TypeScript.PullDecl("", "", declType, declFlags, span, context.semanticInfo.getPath()); + context.semanticInfo.setDeclForAST(constructorTypeDeclAST, decl); + context.semanticInfo.setASTForDecl(decl, constructorTypeDeclAST); + + if (parent) { + parent.addChildDecl(decl); + decl.setParentDecl(parent); + } + + context.pushParent(decl); + + if (constructorTypeDeclAST.returnTypeAnnotation && ((constructorTypeDeclAST.returnTypeAnnotation).term.nodeType() === 15 /* InterfaceDeclaration */ || (constructorTypeDeclAST.returnTypeAnnotation).term.nodeType() === 13 /* FunctionDeclaration */)) { + var declCollectionContext = new DeclCollectionContext(context.semanticInfo, context.scriptName); + + declCollectionContext.pushParent(decl); + + TypeScript.getAstWalkerFactory().walk((constructorTypeDeclAST.returnTypeAnnotation).term, preCollectDecls, postCollectDecls, null, declCollectionContext); + } + + return true; + } + + function createFunctionDeclaration(funcDeclAST, context) { + var declFlags = 0 /* None */; + var declType = 16384 /* Function */; + + if (!context.containingModuleHasExportAssignment() && (TypeScript.hasFlag(funcDeclAST.getFunctionFlags(), 1 /* Exported */) || context.isParsingAmbientModule())) { + declFlags |= 1 /* Exported */; + } + + if (TypeScript.hasFlag(funcDeclAST.getFunctionFlags(), 8 /* Ambient */) || context.isParsingAmbientModule() || context.isDeclareFile) { + declFlags |= 8 /* Ambient */; + } + + if (!funcDeclAST.block) { + declFlags |= 2048 /* Signature */; + } + + var span = TypeScript.TextSpan.fromBounds(funcDeclAST.minChar, funcDeclAST.limChar); + + var parent = context.getParent(); + + if (parent && (parent.kind === 536870912 /* WithBlock */ || (parent.flags & 2097152 /* DeclaredInAWithBlock */))) { + declFlags |= 2097152 /* DeclaredInAWithBlock */; + } + + var decl = new TypeScript.PullDecl(funcDeclAST.name.text(), funcDeclAST.name.actualText, declType, declFlags, span, context.scriptName); + context.semanticInfo.setDeclForAST(funcDeclAST, decl); + context.semanticInfo.setASTForDecl(decl, funcDeclAST); + + if (parent) { + parent.addChildDecl(decl); + decl.setParentDecl(parent); + } + + context.pushParent(decl); + + if (funcDeclAST.returnTypeAnnotation && ((funcDeclAST.returnTypeAnnotation).term.nodeType() === 15 /* InterfaceDeclaration */ || (funcDeclAST.returnTypeAnnotation).term.nodeType() === 13 /* FunctionDeclaration */)) { + var declCollectionContext = new DeclCollectionContext(context.semanticInfo, context.scriptName); + + declCollectionContext.pushParent(decl); + + TypeScript.getAstWalkerFactory().walk((funcDeclAST.returnTypeAnnotation).term, preCollectDecls, postCollectDecls, null, declCollectionContext); + } + + return true; + } + + function createFunctionExpressionDeclaration(functionExpressionDeclAST, context) { + var declFlags = 0 /* None */; + + if (TypeScript.hasFlag(functionExpressionDeclAST.getFunctionFlags(), 2048 /* IsFatArrowFunction */)) { + declFlags |= 8192 /* FatArrow */; + } + + var span = TypeScript.TextSpan.fromBounds(functionExpressionDeclAST.minChar, functionExpressionDeclAST.limChar); + + var parent = context.getParent(); + + if (parent && (parent.kind === 536870912 /* WithBlock */ || (parent.flags & 2097152 /* DeclaredInAWithBlock */))) { + declFlags |= 2097152 /* DeclaredInAWithBlock */; + } + + var name = functionExpressionDeclAST.name ? functionExpressionDeclAST.name.actualText : ""; + var decl = new TypeScript.PullFunctionExpressionDecl(name, declFlags, span, context.scriptName); + context.semanticInfo.setDeclForAST(functionExpressionDeclAST, decl); + context.semanticInfo.setASTForDecl(decl, functionExpressionDeclAST); + + if (parent) { + parent.addChildDecl(decl); + decl.setParentDecl(parent); + } + + context.pushParent(decl); + + if (functionExpressionDeclAST.returnTypeAnnotation && ((functionExpressionDeclAST.returnTypeAnnotation).term.nodeType() === 15 /* InterfaceDeclaration */ || (functionExpressionDeclAST.returnTypeAnnotation).term.nodeType() === 13 /* FunctionDeclaration */)) { + var declCollectionContext = new DeclCollectionContext(context.semanticInfo, context.scriptName); + + declCollectionContext.pushParent(decl); + + TypeScript.getAstWalkerFactory().walk((functionExpressionDeclAST.returnTypeAnnotation).term, preCollectDecls, postCollectDecls, null, declCollectionContext); + } + + return true; + } + + function createMemberFunctionDeclaration(memberFunctionDeclAST, context) { + var declFlags = 0 /* None */; + var declType = 65536 /* Method */; + + if (TypeScript.hasFlag(memberFunctionDeclAST.getFunctionFlags(), 16 /* Static */)) { + declFlags |= 16 /* Static */; + } + + if (TypeScript.hasFlag(memberFunctionDeclAST.getFunctionFlags(), 2 /* Private */)) { + declFlags |= 2 /* Private */; + } else { + declFlags |= 4 /* Public */; + } + + if (!memberFunctionDeclAST.block) { + declFlags |= 2048 /* Signature */; + } + + if (TypeScript.hasFlag(memberFunctionDeclAST.name.getFlags(), 4 /* OptionalName */)) { + declFlags |= 128 /* Optional */; + } + + var span = TypeScript.TextSpan.fromBounds(memberFunctionDeclAST.minChar, memberFunctionDeclAST.limChar); + + var decl = new TypeScript.PullDecl(memberFunctionDeclAST.name.text(), memberFunctionDeclAST.name.actualText, declType, declFlags, span, context.scriptName); + context.semanticInfo.setDeclForAST(memberFunctionDeclAST, decl); + context.semanticInfo.setASTForDecl(decl, memberFunctionDeclAST); + + var parent = context.getParent(); + + if (parent) { + parent.addChildDecl(decl); + decl.setParentDecl(parent); + } + + context.pushParent(decl); + + if (memberFunctionDeclAST.returnTypeAnnotation && ((memberFunctionDeclAST.returnTypeAnnotation).term.nodeType() === 15 /* InterfaceDeclaration */ || (memberFunctionDeclAST.returnTypeAnnotation).term.nodeType() === 13 /* FunctionDeclaration */)) { + var declCollectionContext = new DeclCollectionContext(context.semanticInfo, context.scriptName); + + declCollectionContext.pushParent(decl); + + TypeScript.getAstWalkerFactory().walk((memberFunctionDeclAST.returnTypeAnnotation).term, preCollectDecls, postCollectDecls, null, declCollectionContext); + } + + return true; + } + + function createIndexSignatureDeclaration(indexSignatureDeclAST, context) { + var declFlags = 2048 /* Signature */ | 1024 /* Index */; + var declType = 4194304 /* IndexSignature */; + + var span = TypeScript.TextSpan.fromBounds(indexSignatureDeclAST.minChar, indexSignatureDeclAST.limChar); + + var parent = context.getParent(); + + if (parent && (parent.kind === 536870912 /* WithBlock */ || (parent.flags & 2097152 /* DeclaredInAWithBlock */))) { + declFlags |= 2097152 /* DeclaredInAWithBlock */; + } + + var decl = new TypeScript.PullDecl("", "", declType, declFlags, span, context.scriptName); + context.semanticInfo.setDeclForAST(indexSignatureDeclAST, decl); + context.semanticInfo.setASTForDecl(decl, indexSignatureDeclAST); + + if (parent) { + parent.addChildDecl(decl); + decl.setParentDecl(parent); + } + + context.pushParent(decl); + + if (indexSignatureDeclAST.returnTypeAnnotation && ((indexSignatureDeclAST.returnTypeAnnotation).term.nodeType() === 15 /* InterfaceDeclaration */ || (indexSignatureDeclAST.returnTypeAnnotation).term.nodeType() === 13 /* FunctionDeclaration */)) { + var declCollectionContext = new DeclCollectionContext(context.semanticInfo, context.scriptName); + + if (parent) { + declCollectionContext.pushParent(parent); + } + + TypeScript.getAstWalkerFactory().walk((indexSignatureDeclAST.returnTypeAnnotation).term, preCollectDecls, postCollectDecls, null, declCollectionContext); + } + + return true; + } + + function createCallSignatureDeclaration(callSignatureDeclAST, context) { + var declFlags = 2048 /* Signature */ | 256 /* Call */; + var declType = 1048576 /* CallSignature */; + + var span = TypeScript.TextSpan.fromBounds(callSignatureDeclAST.minChar, callSignatureDeclAST.limChar); + + var parent = context.getParent(); + + if (parent && (parent.kind === 536870912 /* WithBlock */ || (parent.flags & 2097152 /* DeclaredInAWithBlock */))) { + declFlags |= 2097152 /* DeclaredInAWithBlock */; + } + + var decl = new TypeScript.PullDecl("", "", declType, declFlags, span, context.scriptName); + context.semanticInfo.setDeclForAST(callSignatureDeclAST, decl); + context.semanticInfo.setASTForDecl(decl, callSignatureDeclAST); + + if (parent) { + parent.addChildDecl(decl); + decl.setParentDecl(parent); + } + + context.pushParent(decl); + + if (callSignatureDeclAST.returnTypeAnnotation && ((callSignatureDeclAST.returnTypeAnnotation).term.nodeType() === 15 /* InterfaceDeclaration */ || (callSignatureDeclAST.returnTypeAnnotation).term.nodeType() === 13 /* FunctionDeclaration */)) { + var declCollectionContext = new DeclCollectionContext(context.semanticInfo, context.scriptName); + + declCollectionContext.pushParent(decl); + + TypeScript.getAstWalkerFactory().walk((callSignatureDeclAST.returnTypeAnnotation).term, preCollectDecls, postCollectDecls, null, declCollectionContext); + } + + return true; + } + + function createConstructSignatureDeclaration(constructSignatureDeclAST, context) { + var declFlags = 2048 /* Signature */ | 256 /* Call */; + var declType = 2097152 /* ConstructSignature */; + + var span = TypeScript.TextSpan.fromBounds(constructSignatureDeclAST.minChar, constructSignatureDeclAST.limChar); + + var parent = context.getParent(); + + if (parent && (parent.kind === 536870912 /* WithBlock */ || (parent.flags & 2097152 /* DeclaredInAWithBlock */))) { + declFlags |= 2097152 /* DeclaredInAWithBlock */; + } + + var decl = new TypeScript.PullDecl("", "", declType, declFlags, span, context.scriptName); + context.semanticInfo.setDeclForAST(constructSignatureDeclAST, decl); + context.semanticInfo.setASTForDecl(decl, constructSignatureDeclAST); + + if (parent) { + parent.addChildDecl(decl); + decl.setParentDecl(parent); + } + + context.pushParent(decl); + + if (constructSignatureDeclAST.returnTypeAnnotation && ((constructSignatureDeclAST.returnTypeAnnotation).term.nodeType() === 15 /* InterfaceDeclaration */ || (constructSignatureDeclAST.returnTypeAnnotation).term.nodeType() === 13 /* FunctionDeclaration */)) { + var declCollectionContext = new DeclCollectionContext(context.semanticInfo, context.scriptName); + + declCollectionContext.pushParent(decl); + + TypeScript.getAstWalkerFactory().walk((constructSignatureDeclAST.returnTypeAnnotation).term, preCollectDecls, postCollectDecls, null, declCollectionContext); + } + + return true; + } + + function createClassConstructorDeclaration(constructorDeclAST, context) { + var declFlags = 512 /* Constructor */; + var declType = 32768 /* ConstructorMethod */; + + if (!constructorDeclAST.block) { + declFlags |= 2048 /* Signature */; + } + + var span = TypeScript.TextSpan.fromBounds(constructorDeclAST.minChar, constructorDeclAST.limChar); + + var parent = context.getParent(); + + if (parent) { + var parentFlags = parent.flags; + + if (parentFlags & 1 /* Exported */) { + declFlags |= 1 /* Exported */; + } + } + + var decl = new TypeScript.PullDecl(parent.name, parent.getDisplayName(), declType, declFlags, span, context.scriptName); + context.semanticInfo.setDeclForAST(constructorDeclAST, decl); + context.semanticInfo.setASTForDecl(decl, constructorDeclAST); + + if (parent) { + parent.addChildDecl(decl); + decl.setParentDecl(parent); + } + + context.pushParent(decl); + + if (constructorDeclAST.returnTypeAnnotation && ((constructorDeclAST.returnTypeAnnotation).term.nodeType() === 15 /* InterfaceDeclaration */ || (constructorDeclAST.returnTypeAnnotation).term.nodeType() === 13 /* FunctionDeclaration */)) { + var declCollectionContext = new DeclCollectionContext(context.semanticInfo, context.scriptName); + + declCollectionContext.pushParent(decl); + + TypeScript.getAstWalkerFactory().walk((constructorDeclAST.returnTypeAnnotation).term, preCollectDecls, postCollectDecls, null, declCollectionContext); + } + + return true; + } + + function createGetAccessorDeclaration(getAccessorDeclAST, context) { + var declFlags = 4 /* Public */; + var declType = 262144 /* GetAccessor */; + + if (TypeScript.hasFlag(getAccessorDeclAST.getFunctionFlags(), 16 /* Static */)) { + declFlags |= 16 /* Static */; + } + + if (TypeScript.hasFlag(getAccessorDeclAST.name.getFlags(), 4 /* OptionalName */)) { + declFlags |= 128 /* Optional */; + } + + if (TypeScript.hasFlag(getAccessorDeclAST.getFunctionFlags(), 2 /* Private */)) { + declFlags |= 2 /* Private */; + } else { + declFlags |= 4 /* Public */; + } + + var span = TypeScript.TextSpan.fromBounds(getAccessorDeclAST.minChar, getAccessorDeclAST.limChar); + + var parent = context.getParent(); + + if (parent && (parent.kind === 536870912 /* WithBlock */ || (parent.flags & 2097152 /* DeclaredInAWithBlock */))) { + declFlags |= 2097152 /* DeclaredInAWithBlock */; + } + + var decl = new TypeScript.PullDecl(getAccessorDeclAST.name.text(), getAccessorDeclAST.name.actualText, declType, declFlags, span, context.scriptName); + context.semanticInfo.setDeclForAST(getAccessorDeclAST, decl); + context.semanticInfo.setASTForDecl(decl, getAccessorDeclAST); + + if (parent) { + parent.addChildDecl(decl); + decl.setParentDecl(parent); + } + + context.pushParent(decl); + + if (getAccessorDeclAST.returnTypeAnnotation && ((getAccessorDeclAST.returnTypeAnnotation).term.nodeType() === 15 /* InterfaceDeclaration */ || (getAccessorDeclAST.returnTypeAnnotation).term.nodeType() === 13 /* FunctionDeclaration */)) { + var declCollectionContext = new DeclCollectionContext(context.semanticInfo, context.scriptName); + + declCollectionContext.pushParent(decl); + + TypeScript.getAstWalkerFactory().walk((getAccessorDeclAST.returnTypeAnnotation).term, preCollectDecls, postCollectDecls, null, declCollectionContext); + } + + return true; + } + + function createSetAccessorDeclaration(setAccessorDeclAST, context) { + var declFlags = 4 /* Public */; + var declType = 524288 /* SetAccessor */; + + if (TypeScript.hasFlag(setAccessorDeclAST.getFunctionFlags(), 16 /* Static */)) { + declFlags |= 16 /* Static */; + } + + if (TypeScript.hasFlag(setAccessorDeclAST.name.getFlags(), 4 /* OptionalName */)) { + declFlags |= 128 /* Optional */; + } + + if (TypeScript.hasFlag(setAccessorDeclAST.getFunctionFlags(), 2 /* Private */)) { + declFlags |= 2 /* Private */; + } else { + declFlags |= 4 /* Public */; + } + + var span = TypeScript.TextSpan.fromBounds(setAccessorDeclAST.minChar, setAccessorDeclAST.limChar); + + var parent = context.getParent(); + + if (parent && (parent.kind === 536870912 /* WithBlock */ || (parent.flags & 2097152 /* DeclaredInAWithBlock */))) { + declFlags |= 2097152 /* DeclaredInAWithBlock */; + } + + var decl = new TypeScript.PullDecl(setAccessorDeclAST.name.actualText, setAccessorDeclAST.name.actualText, declType, declFlags, span, context.scriptName); + context.semanticInfo.setDeclForAST(setAccessorDeclAST, decl); + context.semanticInfo.setASTForDecl(decl, setAccessorDeclAST); + + if (parent) { + parent.addChildDecl(decl); + decl.setParentDecl(parent); + } + + context.pushParent(decl); + + return true; + } + + function preCollectCatchDecls(ast, parentAST, context) { + var declFlags = 0 /* None */; + var declType = 1073741824 /* CatchBlock */; + + var span = TypeScript.TextSpan.fromBounds(ast.minChar, ast.limChar); + + var parent = context.getParent(); + + if (parent && (parent.kind === 536870912 /* WithBlock */ || (parent.flags & 2097152 /* DeclaredInAWithBlock */))) { + declFlags |= 2097152 /* DeclaredInAWithBlock */; + } + + var decl = new TypeScript.PullDecl("", "", declType, declFlags, span, context.scriptName); + context.semanticInfo.setDeclForAST(ast, decl); + context.semanticInfo.setASTForDecl(decl, ast); + + if (parent) { + parent.addChildDecl(decl); + decl.setParentDecl(parent); + } + + context.pushParent(decl); + + return true; + } + + function preCollectWithDecls(ast, parentAST, context) { + var declFlags = 0 /* None */; + var declType = 536870912 /* WithBlock */; + + var span = TypeScript.TextSpan.fromBounds(ast.minChar, ast.limChar); + + var parent = context.getParent(); + + var decl = new TypeScript.PullDecl("", "", declType, declFlags, span, context.scriptName); + context.semanticInfo.setDeclForAST(ast, decl); + context.semanticInfo.setASTForDecl(decl, ast); + + if (parent) { + parent.addChildDecl(decl); + decl.setParentDecl(parent); + } + + context.pushParent(decl); + + return true; + } + + function preCollectFuncDecls(ast, parentAST, context) { + var funcDecl = ast; + + if (funcDecl.isConstructor) { + return createClassConstructorDeclaration(funcDecl, context); + } else if (funcDecl.isGetAccessor()) { + return createGetAccessorDeclaration(funcDecl, context); + } else if (funcDecl.isSetAccessor()) { + return createSetAccessorDeclaration(funcDecl, context); + } else if (TypeScript.hasFlag(funcDecl.getFunctionFlags(), 1024 /* ConstructMember */)) { + return TypeScript.hasFlag(funcDecl.getFlags(), 8 /* TypeReference */) ? createConstructorTypeDeclaration(funcDecl, context) : createConstructSignatureDeclaration(funcDecl, context); + } else if (TypeScript.hasFlag(funcDecl.getFunctionFlags(), 512 /* CallMember */)) { + return createCallSignatureDeclaration(funcDecl, context); + } else if (TypeScript.hasFlag(funcDecl.getFunctionFlags(), 4096 /* IndexerMember */)) { + return createIndexSignatureDeclaration(funcDecl, context); + } else if (TypeScript.hasFlag(funcDecl.getFlags(), 8 /* TypeReference */)) { + return createFunctionTypeDeclaration(funcDecl, context); + } else if (TypeScript.hasFlag(funcDecl.getFunctionFlags(), 256 /* Method */)) { + return createMemberFunctionDeclaration(funcDecl, context); + } else if (TypeScript.hasFlag(funcDecl.getFunctionFlags(), (8192 /* IsFunctionExpression */ | 2048 /* IsFatArrowFunction */ | 16384 /* IsFunctionProperty */))) { + return createFunctionExpressionDeclaration(funcDecl, context); + } + + return createFunctionDeclaration(funcDecl, context); + } + + function preCollectDecls(ast, parentAST, walker) { + var context = walker.state; + var go = false; + + if (ast.nodeType() === 2 /* Script */) { + var script = ast; + var span = TypeScript.TextSpan.fromBounds(script.minChar, script.limChar); + + var decl = new TypeScript.PullDecl(context.scriptName, context.scriptName, 1 /* Script */, 0 /* None */, span, context.scriptName); + context.semanticInfo.setDeclForAST(ast, decl); + context.semanticInfo.setASTForDecl(decl, ast); + + context.pushParent(decl); + context.isDeclareFile = script.isDeclareFile; + + go = true; + } else if (ast.nodeType() === 1 /* List */) { + go = true; + } else if (ast.nodeType() === 82 /* Block */) { + go = true; + } else if (ast.nodeType() === 19 /* VariableDeclaration */) { + go = true; + } else if (ast.nodeType() === 98 /* VariableStatement */) { + go = true; + } else if (ast.nodeType() === 16 /* ModuleDeclaration */) { + go = preCollectModuleDecls(ast, parentAST, context); + } else if (ast.nodeType() === 14 /* ClassDeclaration */) { + go = preCollectClassDecls(ast, parentAST, context); + } else if (ast.nodeType() === 15 /* InterfaceDeclaration */) { + go = preCollectInterfaceDecls(ast, parentAST, context); + } else if (ast.nodeType() === 20 /* Parameter */) { + go = preCollectParameterDecl(ast, parentAST, context); + } else if (ast.nodeType() === 18 /* VariableDeclarator */) { + go = preCollectVarDecls(ast, parentAST, context); + } else if (ast.nodeType() === 13 /* FunctionDeclaration */) { + go = preCollectFuncDecls(ast, parentAST, context); + } else if (ast.nodeType() === 17 /* ImportDeclaration */) { + go = preCollectImportDecls(ast, parentAST, context); + } else if (ast.nodeType() === 9 /* TypeParameter */) { + go = preCollectTypeParameterDecl(ast, parentAST, context); + } else if (ast.nodeType() === 92 /* IfStatement */) { + go = true; + } else if (ast.nodeType() === 91 /* ForStatement */) { + go = true; + } else if (ast.nodeType() === 90 /* ForInStatement */) { + go = true; + } else if (ast.nodeType() === 99 /* WhileStatement */) { + go = true; + } else if (ast.nodeType() === 86 /* DoStatement */) { + go = true; + } else if (ast.nodeType() === 26 /* CommaExpression */) { + go = true; + } else if (ast.nodeType() === 94 /* ReturnStatement */) { + go = true; + } else if (ast.nodeType() === 95 /* SwitchStatement */ || ast.nodeType() === 101 /* CaseClause */) { + go = true; + } else if (ast.nodeType() === 37 /* InvocationExpression */) { + go = true; + } else if (ast.nodeType() === 38 /* ObjectCreationExpression */) { + go = true; + } else if (ast.nodeType() === 97 /* TryStatement */) { + go = true; + } else if (ast.nodeType() === 93 /* LabeledStatement */) { + go = true; + } else if (ast.nodeType() === 102 /* CatchClause */) { + go = preCollectCatchDecls(ast, parentAST, context); + } else if (ast.nodeType() === 100 /* WithStatement */) { + go = preCollectWithDecls(ast, parentAST, context); + } + + walker.options.goChildren = go; + + return ast; + } + TypeScript.preCollectDecls = preCollectDecls; + + function isContainer(decl) { + return decl.kind === 4 /* Container */ || decl.kind === 32 /* DynamicModule */ || decl.kind === 64 /* Enum */; + } + + function getInitializationFlag(decl) { + if (decl.kind & 4 /* Container */) { + return 32768 /* InitializedModule */; + } else if (decl.kind & 64 /* Enum */) { + return 131072 /* InitializedEnum */; + } else if (decl.kind & 32 /* DynamicModule */) { + return 65536 /* InitializedDynamicModule */; + } + + return 0 /* None */; + } + + function hasInitializationFlag(decl) { + var kind = decl.kind; + + if (kind & 4 /* Container */) { + return (decl.flags & 32768 /* InitializedModule */) !== 0; + } else if (kind & 64 /* Enum */) { + return (decl.flags & 131072 /* InitializedEnum */) != 0; + } else if (kind & 32 /* DynamicModule */) { + return (decl.flags & 65536 /* InitializedDynamicModule */) !== 0; + } + + return false; + } + + function postCollectDecls(ast, parentAST, walker) { + var context = walker.state; + var parentDecl; + var initFlag = 0 /* None */; + + if (ast.nodeType() === 16 /* ModuleDeclaration */) { + var thisModule = context.getParent(); + context.popParent(); + context.containingModuleHasExportAssignmentArray.pop(); + context.isParsingAmbientModuleArray.pop(); + + parentDecl = context.getParent(); + + if (hasInitializationFlag(thisModule)) { + if (parentDecl && isContainer(parentDecl)) { + initFlag = getInitializationFlag(parentDecl); + parentDecl.setFlags(parentDecl.flags | initFlag); + } + + var valueDecl = new TypeScript.PullDecl(thisModule.name, thisModule.getDisplayName(), 1024 /* Variable */, thisModule.flags, thisModule.getSpan(), context.scriptName); + + thisModule.setValueDecl(valueDecl); + + context.semanticInfo.setASTForDecl(valueDecl, ast); + + if (parentDecl) { + parentDecl.addChildDecl(valueDecl); + valueDecl.setParentDecl(parentDecl); + } + } + } else if (ast.nodeType() === 14 /* ClassDeclaration */) { + context.popParent(); + + parentDecl = context.getParent(); + + if (parentDecl && isContainer(parentDecl)) { + initFlag = getInitializationFlag(parentDecl); + parentDecl.setFlags(parentDecl.flags | initFlag); + } + } else if (ast.nodeType() === 15 /* InterfaceDeclaration */) { + context.popParent(); + } else if (ast.nodeType() === 13 /* FunctionDeclaration */) { + context.popParent(); + + parentDecl = context.getParent(); + + if (parentDecl && isContainer(parentDecl)) { + initFlag = getInitializationFlag(parentDecl); + parentDecl.setFlags(parentDecl.flags | initFlag); + } + } else if (ast.nodeType() === 18 /* VariableDeclarator */) { + parentDecl = context.getParent(); + + if (parentDecl && isContainer(parentDecl)) { + initFlag = getInitializationFlag(parentDecl); + parentDecl.setFlags(parentDecl.flags | initFlag); + } + } else if (ast.nodeType() === 102 /* CatchClause */) { + parentDecl = context.getParent(); + + if (parentDecl && isContainer(parentDecl)) { + initFlag = getInitializationFlag(parentDecl); + parentDecl.setFlags(parentDecl.flags | initFlag); + } + + context.popParent(); + } else if (ast.nodeType() === 100 /* WithStatement */) { + parentDecl = context.getParent(); + + if (parentDecl && isContainer(parentDecl)) { + initFlag = getInitializationFlag(parentDecl); + parentDecl.setFlags(parentDecl.flags | initFlag); + } + + context.popParent(); + } + + return ast; + } + TypeScript.postCollectDecls = postCollectDecls; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + function getPathToDecl(decl) { + if (!decl) { + return []; + } + + var decls = decl.getParentPath(); + + if (decls) { + return decls; + } else { + decls = [decl]; + } + + var parentDecl = decl.getParentDecl(); + + while (parentDecl) { + if (parentDecl && decls[decls.length - 1] != parentDecl && !(parentDecl.kind & 512 /* ObjectLiteral */)) { + decls[decls.length] = parentDecl; + } + parentDecl = parentDecl.getParentDecl(); + } + + decls = decls.reverse(); + + decl.setParentPath(decls); + + return decls; + } + TypeScript.getPathToDecl = getPathToDecl; + + var PullSymbolBinder = (function () { + function PullSymbolBinder(semanticInfoChain) { + this.semanticInfoChain = semanticInfoChain; + this.functionTypeParameterCache = new TypeScript.BlockIntrinsics(); + this.semanticInfo = null; + } + PullSymbolBinder.prototype.findTypeParameterInCache = function (name) { + return this.functionTypeParameterCache[name]; + }; + + PullSymbolBinder.prototype.addTypeParameterToCache = function (typeParameter) { + this.functionTypeParameterCache[typeParameter.getName()] = typeParameter; + }; + + PullSymbolBinder.prototype.resetTypeParameterCache = function () { + this.functionTypeParameterCache = new TypeScript.BlockIntrinsics(); + }; + + PullSymbolBinder.prototype.setUnit = function (fileName) { + this.semanticInfo = this.semanticInfoChain.getUnit(fileName); + }; + + PullSymbolBinder.prototype.getParent = function (decl, returnInstanceType) { + if (typeof returnInstanceType === "undefined") { returnInstanceType = false; } + var parentDecl = decl.getParentDecl(); + + if (parentDecl.kind == 1 /* Script */) { + return null; + } + + var parent = parentDecl.getSymbol(); + + if (!parent && parentDecl && !parentDecl.isBound()) { + this.bindDeclToPullSymbol(parentDecl); + } + + parent = parentDecl.getSymbol(); + if (parent) { + var parentDeclKind = parentDecl.kind; + if (parentDeclKind == 262144 /* GetAccessor */) { + parent = (parent).getGetter(); + } else if (parentDeclKind == 524288 /* SetAccessor */) { + parent = (parent).getSetter(); + } + } + + if (parent) { + if (returnInstanceType && parent.isType() && parent.isContainer()) { + var instanceSymbol = (parent).getInstanceSymbol(); + + if (instanceSymbol) { + return instanceSymbol.type; + } + } + + return parent.type; + } + + return null; + }; + + PullSymbolBinder.prototype.findDeclsInContext = function (startingDecl, declKind, searchGlobally) { + if (!searchGlobally) { + var parentDecl = startingDecl.getParentDecl(); + return parentDecl.searchChildDecls(startingDecl.name, declKind); + } + + var contextSymbolPath = getPathToDecl(startingDecl); + + if (contextSymbolPath.length) { + var copyOfContextSymbolPath = []; + + for (var i = 0; i < contextSymbolPath.length; i++) { + if (contextSymbolPath[i].kind & 1 /* Script */) { + continue; + } + copyOfContextSymbolPath[copyOfContextSymbolPath.length] = contextSymbolPath[i].name; + } + + return this.semanticInfoChain.findDecls(copyOfContextSymbolPath, declKind); + } + + return this.semanticInfoChain.findDecls([name], declKind); + }; + + PullSymbolBinder.prototype.bindModuleDeclarationToPullSymbol = function (moduleContainerDecl) { + var modName = moduleContainerDecl.name; + + var moduleContainerTypeSymbol = null; + var moduleInstanceSymbol = null; + var moduleInstanceTypeSymbol = null; + + var moduleInstanceDecl = moduleContainerDecl.getValueDecl(); + + var moduleKind = moduleContainerDecl.kind; + + var parent = this.getParent(moduleContainerDecl); + var parentInstanceSymbol = this.getParent(moduleContainerDecl, true); + var parentDecl = moduleContainerDecl.getParentDecl(); + var moduleAST = this.semanticInfo.getASTForDecl(moduleContainerDecl); + + var isExported = moduleContainerDecl.flags & 1 /* Exported */; + var isEnum = (moduleKind & 64 /* Enum */) != 0; + var searchKind = isEnum ? 64 /* Enum */ : TypeScript.PullElementKind.SomeContainer; + var isInitializedModule = (moduleContainerDecl.flags & TypeScript.PullElementFlags.SomeInitializedModule) != 0; + + var createdNewSymbol = false; + + if (parent) { + if (isExported) { + moduleContainerTypeSymbol = parent.findNestedType(modName, searchKind); + } else { + moduleContainerTypeSymbol = parent.findContainedNonMemberType(modName); + + if (moduleContainerTypeSymbol && !(moduleContainerTypeSymbol.kind & searchKind)) { + moduleContainerTypeSymbol = null; + } + } + } else if (!isExported || moduleContainerDecl.kind === 32 /* DynamicModule */) { + moduleContainerTypeSymbol = this.semanticInfoChain.findTopLevelSymbol(modName, searchKind, this.semanticInfo.getPath()); + } + + if (moduleContainerTypeSymbol && moduleContainerTypeSymbol.kind !== moduleKind) { + if (isInitializedModule) { + moduleContainerDecl.addDiagnostic(new TypeScript.Diagnostic(this.semanticInfo.getPath(), moduleAST.minChar, moduleAST.getLength(), TypeScript.DiagnosticCode.Duplicate_identifier_0, [moduleContainerDecl.getDisplayName()])); + } + + moduleContainerTypeSymbol = null; + } + + if (moduleContainerTypeSymbol) { + moduleInstanceSymbol = moduleContainerTypeSymbol.getInstanceSymbol(); + } else { + moduleContainerTypeSymbol = new TypeScript.PullContainerTypeSymbol(modName, moduleKind); + createdNewSymbol = true; + + if (!parent) { + this.semanticInfoChain.cacheGlobalSymbol(moduleContainerTypeSymbol, searchKind); + } + } + + if (!moduleInstanceSymbol && isInitializedModule) { + var variableSymbol = null; + if (!isEnum) { + if (parentInstanceSymbol) { + if (isExported) { + variableSymbol = parentInstanceSymbol.findMember(modName, false); + + if (!variableSymbol) { + variableSymbol = parentInstanceSymbol.findContainedNonMember(modName); + } + } else { + variableSymbol = parentInstanceSymbol.findContainedNonMember(modName); + + if (!variableSymbol) { + variableSymbol = parentInstanceSymbol.findMember(modName, false); + } + } + + if (variableSymbol) { + var declarations = variableSymbol.getDeclarations(); + + if (declarations.length) { + var variableSymbolParentDecl = declarations[0].getParentDecl(); + + if (parentDecl !== variableSymbolParentDecl) { + variableSymbol = null; + } + } + } + } else if (!(moduleContainerDecl.flags & 1 /* Exported */)) { + var siblingDecls = parentDecl.getChildDecls(); + var augmentedDecl = null; + + for (var i = 0; i < siblingDecls.length; i++) { + if (siblingDecls[i] == moduleContainerDecl) { + break; + } + + if ((siblingDecls[i].name == modName) && (siblingDecls[i].kind & (8 /* Class */ | TypeScript.PullElementKind.SomeFunction))) { + augmentedDecl = siblingDecls[i]; + break; + } + } + + if (augmentedDecl) { + variableSymbol = augmentedDecl.getSymbol(); + + if (variableSymbol && variableSymbol.isType()) { + variableSymbol = (variableSymbol).getConstructorMethod(); + } + } + } + } + + if (variableSymbol) { + var prevKind = variableSymbol.kind; + var acceptableRedeclaration = (prevKind == 16384 /* Function */) || (prevKind == 32768 /* ConstructorMethod */) || variableSymbol.hasFlag(TypeScript.PullElementFlags.ImplicitVariable); + + if (acceptableRedeclaration) { + moduleInstanceTypeSymbol = variableSymbol.type; + } else { + variableSymbol = null; + } + } + + if (!moduleInstanceTypeSymbol) { + moduleInstanceTypeSymbol = new TypeScript.PullTypeSymbol("", 8388608 /* ObjectType */); + } + + moduleInstanceTypeSymbol.addDeclaration(moduleContainerDecl); + + if (!moduleInstanceTypeSymbol.getAssociatedContainerType()) { + moduleInstanceTypeSymbol.setAssociatedContainerType(moduleContainerTypeSymbol); + } + + if (variableSymbol) { + moduleInstanceSymbol = variableSymbol; + } else { + moduleInstanceSymbol = new TypeScript.PullSymbol(modName, 1024 /* Variable */); + moduleInstanceSymbol.type = moduleInstanceTypeSymbol; + } + + moduleContainerTypeSymbol.setInstanceSymbol(moduleInstanceSymbol); + } + + moduleContainerTypeSymbol.addDeclaration(moduleContainerDecl); + moduleContainerDecl.setSymbol(moduleContainerTypeSymbol); + + this.semanticInfo.setSymbolForAST(moduleAST.name, moduleContainerTypeSymbol); + this.semanticInfo.setSymbolForAST(moduleAST, moduleContainerTypeSymbol); + + var moduleDeclarations = moduleContainerTypeSymbol.getDeclarations(); + + if (isEnum && moduleDeclarations.length > 1 && moduleAST.members.members.length > 0) { + var multipleEnums = TypeScript.ArrayUtilities.where(moduleDeclarations, function (d) { + return d.kind === 64 /* Enum */; + }).length > 1; + if (multipleEnums) { + var firstVariable = moduleAST.members.members[0]; + var firstVariableDeclarator = firstVariable.declaration.declarators.members[0]; + if (!firstVariableDeclarator.init) { + moduleContainerDecl.addDiagnostic(new TypeScript.Diagnostic(this.semanticInfo.getPath(), firstVariableDeclarator.minChar, firstVariableDeclarator.getLength(), TypeScript.DiagnosticCode.Enums_with_multiple_declarations_must_provide_an_initializer_for_the_first_enum_element, null)); + } + } + } + + if (createdNewSymbol) { + if (parent) { + if (moduleContainerDecl.flags & 1 /* Exported */) { + parent.addEnclosedMemberType(moduleContainerTypeSymbol); + } else { + parent.addEnclosedNonMemberType(moduleContainerTypeSymbol); + } + } + } + + if (isEnum) { + moduleInstanceTypeSymbol = moduleContainerTypeSymbol.getInstanceSymbol().type; + + var enumIndexSignature = new TypeScript.PullSignatureSymbol(4194304 /* IndexSignature */); + var enumIndexParameterSymbol = new TypeScript.PullSymbol("x", 2048 /* Parameter */); + enumIndexParameterSymbol.type = this.semanticInfoChain.numberTypeSymbol; + enumIndexSignature.addParameter(enumIndexParameterSymbol); + enumIndexSignature.returnType = this.semanticInfoChain.stringTypeSymbol; + + moduleInstanceTypeSymbol.addIndexSignature(enumIndexSignature); + } + + var valueDecl = moduleContainerDecl.getValueDecl(); + + if (valueDecl) { + valueDecl.ensureSymbolIsBound(); + } + + var otherDecls = this.findDeclsInContext(moduleContainerDecl, moduleContainerDecl.kind, true); + + if (otherDecls && otherDecls.length) { + for (var i = 0; i < otherDecls.length; i++) { + otherDecls[i].ensureSymbolIsBound(); + } + } + }; + + PullSymbolBinder.prototype.bindImportDeclaration = function (importDeclaration) { + var declFlags = importDeclaration.flags; + var declKind = importDeclaration.kind; + var importDeclAST = this.semanticInfo.getASTForDecl(importDeclaration); + + var isExported = false; + var importSymbol = null; + var declName = importDeclaration.name; + var parentHadSymbol = false; + var parent = this.getParent(importDeclaration); + + if (parent) { + importSymbol = parent.findMember(declName, false); + + if (!importSymbol) { + importSymbol = parent.findContainedNonMemberType(declName); + + if (importSymbol) { + var declarations = importSymbol.getDeclarations(); + + if (declarations.length) { + var importSymbolParent = declarations[0].getParentDecl(); + + if (importSymbolParent !== importDeclaration.getParentDecl()) { + importSymbol = null; + } + } + } + } + } else if (!(importDeclaration.flags & 1 /* Exported */)) { + importSymbol = this.semanticInfoChain.findTopLevelSymbol(declName, TypeScript.PullElementKind.SomeContainer, this.semanticInfo.getPath()); + } + + if (importSymbol) { + parentHadSymbol = true; + } + + if (importSymbol) { + importDeclaration.addDiagnostic(new TypeScript.Diagnostic(this.semanticInfo.getPath(), importDeclAST.minChar, importDeclAST.getLength(), TypeScript.DiagnosticCode.Duplicate_identifier_0, [importDeclaration.getDisplayName()])); + importSymbol = null; + } + + if (!importSymbol) { + importSymbol = new TypeScript.PullTypeAliasSymbol(declName); + + if (!parent) { + this.semanticInfoChain.cacheGlobalSymbol(importSymbol, TypeScript.PullElementKind.SomeContainer); + } + } + + importSymbol.addDeclaration(importDeclaration); + importDeclaration.setSymbol(importSymbol); + + this.semanticInfo.setSymbolForAST(importDeclAST, importSymbol); + + if (parent && !parentHadSymbol) { + if (declFlags & 1 /* Exported */) { + parent.addEnclosedMemberType(importSymbol); + } else { + parent.addEnclosedNonMemberType(importSymbol); + } + } + }; + + PullSymbolBinder.prototype.bindClassDeclarationToPullSymbol = function (classDecl) { + var className = classDecl.name; + var classSymbol = null; + + var constructorSymbol = null; + var constructorTypeSymbol = null; + + var classAST = this.semanticInfo.getASTForDecl(classDecl); + + var parent = this.getParent(classDecl); + var parentDecl = classDecl.getParentDecl(); + var isExported = classDecl.flags & 1 /* Exported */; + var isGeneric = false; + + if (parent) { + if (isExported) { + classSymbol = parent.findNestedType(className); + + if (!classSymbol) { + classSymbol = parent.findMember(className, false); + } + } else { + classSymbol = parent.findContainedNonMemberType(className); + + if (classSymbol && (classSymbol.kind & 8 /* Class */)) { + var declarations = classSymbol.getDeclarations(); + + if (declarations.length) { + var classSymbolParentDecl = declarations[0].getParentDecl(); + + if (classSymbolParentDecl !== parentDecl) { + classSymbol = null; + } + } + } else { + classSymbol = null; + } + } + } else { + classSymbol = this.semanticInfoChain.findTopLevelSymbol(className, 8 /* Class */, this.semanticInfo.getPath()); + } + + if (classSymbol) { + classDecl.addDiagnostic(new TypeScript.Diagnostic(this.semanticInfo.getPath(), classAST.minChar, classAST.getLength(), TypeScript.DiagnosticCode.Duplicate_identifier_0, [classDecl.getDisplayName()])); + classSymbol = null; + } + + var decls; + + classSymbol = new TypeScript.PullTypeSymbol(className, 8 /* Class */); + + if (!parent) { + this.semanticInfoChain.cacheGlobalSymbol(classSymbol, 8 /* Class */); + } + + classSymbol.addDeclaration(classDecl); + + classDecl.setSymbol(classSymbol); + + this.semanticInfo.setSymbolForAST(classAST.name, classSymbol); + this.semanticInfo.setSymbolForAST(classAST, classSymbol); + + if (parent) { + if (classDecl.flags & 1 /* Exported */) { + parent.addEnclosedMemberType(classSymbol); + } else { + parent.addEnclosedNonMemberType(classSymbol); + } + } + + this.resetTypeParameterCache(); + + constructorSymbol = classSymbol.getConstructorMethod(); + constructorTypeSymbol = constructorSymbol ? constructorSymbol.type : null; + + if (!constructorSymbol) { + constructorSymbol = new TypeScript.PullSymbol(className, 32768 /* ConstructorMethod */); + constructorTypeSymbol = new TypeScript.PullTypeSymbol("", 33554432 /* ConstructorType */); + + constructorSymbol.setIsSynthesized(); + + constructorSymbol.type = constructorTypeSymbol; + classSymbol.setConstructorMethod(constructorSymbol); + + classSymbol.setHasDefaultConstructor(); + } + + if (constructorSymbol.getIsSynthesized()) { + constructorSymbol.addDeclaration(classDecl.getValueDecl()); + constructorTypeSymbol.addDeclaration(classDecl); + } else { + classSymbol.setHasDefaultConstructor(false); + } + + constructorTypeSymbol.setAssociatedContainerType(classSymbol); + + var typeParameters = classDecl.getTypeParameters(); + var typeParameter; + var typeParameterDecls = null; + + for (var i = 0; i < typeParameters.length; i++) { + typeParameter = classSymbol.findTypeParameter(typeParameters[i].name); + + if (!typeParameter) { + typeParameter = new TypeScript.PullTypeParameterSymbol(typeParameters[i].name, false); + + classSymbol.addTypeParameter(typeParameter); + constructorTypeSymbol.addConstructorTypeParameter(typeParameter); + } else { + typeParameterDecls = typeParameter.getDeclarations(); + + var typeParameterAST = this.semanticInfoChain.getASTForDecl(typeParameterDecls[0]); + classDecl.addDiagnostic(new TypeScript.Diagnostic(this.semanticInfo.getPath(), typeParameterAST.minChar, typeParameterAST.getLength(), TypeScript.DiagnosticCode.Duplicate_identifier_0, [typeParameter.getName()])); + } + + typeParameter.addDeclaration(typeParameters[i]); + typeParameters[i].setSymbol(typeParameter); + } + + var valueDecl = classDecl.getValueDecl(); + + if (valueDecl) { + valueDecl.ensureSymbolIsBound(); + } + }; + + PullSymbolBinder.prototype.bindInterfaceDeclarationToPullSymbol = function (interfaceDecl) { + var interfaceName = interfaceDecl.name; + var interfaceSymbol = null; + + var interfaceAST = this.semanticInfo.getASTForDecl(interfaceDecl); + var createdNewSymbol = false; + var parent = this.getParent(interfaceDecl); + + var acceptableSharedKind = 16 /* Interface */; + + if (parent) { + interfaceSymbol = parent.findNestedType(interfaceName, TypeScript.PullElementKind.SomeType); + } else if (!(interfaceDecl.flags & 1 /* Exported */)) { + interfaceSymbol = this.semanticInfoChain.findTopLevelSymbol(interfaceName, 16 /* Interface */, this.semanticInfo.getPath()); + } + + if (interfaceSymbol && !(interfaceSymbol.kind & acceptableSharedKind)) { + interfaceDecl.addDiagnostic(new TypeScript.Diagnostic(this.semanticInfo.getPath(), interfaceAST.minChar, interfaceAST.getLength(), TypeScript.DiagnosticCode.Duplicate_identifier_0, [interfaceDecl.getDisplayName()])); + interfaceSymbol = null; + } + + if (!interfaceSymbol) { + interfaceSymbol = new TypeScript.PullTypeSymbol(interfaceName, 16 /* Interface */); + createdNewSymbol = true; + + if (!parent) { + this.semanticInfoChain.cacheGlobalSymbol(interfaceSymbol, acceptableSharedKind); + } + } + + interfaceSymbol.addDeclaration(interfaceDecl); + interfaceDecl.setSymbol(interfaceSymbol); + + if (createdNewSymbol) { + if (parent) { + if (interfaceDecl.flags & 1 /* Exported */) { + parent.addEnclosedMemberType(interfaceSymbol); + } else { + parent.addEnclosedNonMemberType(interfaceSymbol); + } + } + } + + this.resetTypeParameterCache(); + + var typeParameters = interfaceDecl.getTypeParameters(); + var typeParameter; + var typeParameterDecls = null; + + for (var i = 0; i < typeParameters.length; i++) { + typeParameter = interfaceSymbol.findTypeParameter(typeParameters[i].name); + + if (!typeParameter) { + typeParameter = new TypeScript.PullTypeParameterSymbol(typeParameters[i].name, false); + + interfaceSymbol.addTypeParameter(typeParameter); + } else { + typeParameterDecls = typeParameter.getDeclarations(); + + for (var j = 0; j < typeParameterDecls.length; j++) { + var typeParameterDeclParent = typeParameterDecls[j].getParentDecl(); + + if (typeParameterDeclParent && typeParameterDeclParent === interfaceDecl) { + var typeParameterAST = this.semanticInfoChain.getASTForDecl(typeParameterDecls[0]); + interfaceDecl.addDiagnostic(new TypeScript.Diagnostic(this.semanticInfo.getPath(), typeParameterAST.minChar, typeParameterAST.getLength(), TypeScript.DiagnosticCode.Duplicate_identifier_0, [typeParameter.getName()])); + + break; + } + } + } + + typeParameter.addDeclaration(typeParameters[i]); + typeParameters[i].setSymbol(typeParameter); + } + + var otherDecls = this.findDeclsInContext(interfaceDecl, interfaceDecl.kind, true); + + if (otherDecls && otherDecls.length) { + for (var i = 0; i < otherDecls.length; i++) { + otherDecls[i].ensureSymbolIsBound(); + } + } + }; + + PullSymbolBinder.prototype.bindObjectTypeDeclarationToPullSymbol = function (objectDecl) { + var objectSymbolAST = this.semanticInfo.getASTForDecl(objectDecl); + + var objectSymbol = new TypeScript.PullTypeSymbol("", 8388608 /* ObjectType */); + + objectSymbol.addDeclaration(objectDecl); + objectDecl.setSymbol(objectSymbol); + + this.semanticInfo.setSymbolForAST(objectSymbolAST, objectSymbol); + + var childDecls = objectDecl.getChildDecls(); + + for (var i = 0; i < childDecls.length; i++) { + this.bindDeclToPullSymbol(childDecls[i]); + } + + var typeParameters = objectDecl.getTypeParameters(); + var typeParameter; + var typeParameterDecls = null; + + for (var i = 0; i < typeParameters.length; i++) { + typeParameter = objectSymbol.findTypeParameter(typeParameters[i].name); + + if (!typeParameter) { + typeParameter = new TypeScript.PullTypeParameterSymbol(typeParameters[i].name, false); + + objectSymbol.addTypeParameter(typeParameter); + } else { + typeParameterDecls = typeParameter.getDeclarations(); + + var typeParameterAST = this.semanticInfoChain.getASTForDecl(typeParameterDecls[0]); + objectDecl.addDiagnostic(new TypeScript.Diagnostic(this.semanticInfo.getPath(), typeParameterAST.minChar, typeParameterAST.getLength(), TypeScript.DiagnosticCode.Duplicate_identifier_0, [typeParameter.name])); + } + + typeParameter.addDeclaration(typeParameters[i]); + typeParameters[i].setSymbol(typeParameter); + } + }; + + PullSymbolBinder.prototype.bindConstructorTypeDeclarationToPullSymbol = function (constructorTypeDeclaration) { + var declKind = constructorTypeDeclaration.kind; + var declFlags = constructorTypeDeclaration.flags; + var constructorTypeAST = this.semanticInfo.getASTForDecl(constructorTypeDeclaration); + + var constructorTypeSymbol = new TypeScript.PullTypeSymbol("", 33554432 /* ConstructorType */); + + constructorTypeDeclaration.setSymbol(constructorTypeSymbol); + constructorTypeSymbol.addDeclaration(constructorTypeDeclaration); + this.semanticInfo.setSymbolForAST(constructorTypeAST, constructorTypeSymbol); + + var signature = new TypeScript.PullDefinitionSignatureSymbol(2097152 /* ConstructSignature */); + + if ((constructorTypeAST).variableArgList) { + signature.hasVarArgs = true; + } + + signature.addDeclaration(constructorTypeDeclaration); + constructorTypeDeclaration.setSignatureSymbol(signature); + + this.bindParameterSymbols(this.semanticInfo.getASTForDecl(constructorTypeDeclaration), constructorTypeSymbol, signature); + + constructorTypeSymbol.addConstructSignature(signature); + + var typeParameters = constructorTypeDeclaration.getTypeParameters(); + var typeParameter; + var typeParameterDecls = null; + + for (var i = 0; i < typeParameters.length; i++) { + typeParameter = constructorTypeSymbol.findTypeParameter(typeParameters[i].name); + + if (!typeParameter) { + typeParameter = new TypeScript.PullTypeParameterSymbol(typeParameters[i].name, false); + + constructorTypeSymbol.addConstructorTypeParameter(typeParameter); + } else { + typeParameterDecls = typeParameter.getDeclarations(); + + var typeParameterAST = this.semanticInfoChain.getASTForDecl(typeParameterDecls[0]); + constructorTypeDeclaration.addDiagnostic(new TypeScript.Diagnostic(this.semanticInfo.getPath(), typeParameterAST.minChar, typeParameterAST.getLength(), TypeScript.DiagnosticCode.Duplicate_identifier_0, [typeParameter.name])); + } + + typeParameter.addDeclaration(typeParameters[i]); + typeParameters[i].setSymbol(typeParameter); + } + }; + + PullSymbolBinder.prototype.bindVariableDeclarationToPullSymbol = function (variableDeclaration) { + var declFlags = variableDeclaration.flags; + var declKind = variableDeclaration.kind; + var varDeclAST = this.semanticInfo.getASTForDecl(variableDeclaration); + + var isExported = (declFlags & 1 /* Exported */) !== 0; + + var variableSymbol = null; + + var declName = variableDeclaration.name; + + var parentHadSymbol = false; + + var parent = this.getParent(variableDeclaration, true); + + var parentDecl = variableDeclaration.getParentDecl(); + + var isImplicit = (declFlags & TypeScript.PullElementFlags.ImplicitVariable) !== 0; + var isModuleValue = (declFlags & (TypeScript.PullElementFlags.SomeInitializedModule)) != 0; + var isEnumValue = (declFlags & 131072 /* InitializedEnum */) != 0; + var isClassConstructorVariable = (declFlags & 16384 /* ClassConstructorVariable */) != 0; + + if (parentDecl && !isImplicit) { + parentDecl.addVariableDeclToGroup(variableDeclaration); + } + + if (parent) { + if (isExported) { + variableSymbol = parent.findMember(declName, false); + } else { + variableSymbol = parent.findContainedNonMember(declName); + } + + if (variableSymbol) { + var declarations = variableSymbol.getDeclarations(); + + if (declarations.length) { + var variableSymbolParentDecl = declarations[0].getParentDecl(); + + if (parentDecl !== variableSymbolParentDecl) { + variableSymbol = null; + } + } + } + } else if (!(variableDeclaration.flags & 1 /* Exported */)) { + variableSymbol = this.semanticInfoChain.findTopLevelSymbol(declName, TypeScript.PullElementKind.SomeValue, this.semanticInfo.getPath()); + } + + if (variableSymbol && !variableSymbol.isType()) { + parentHadSymbol = true; + } + + var span; + var decl; + var decls; + var ast; + var members; + + if (variableSymbol) { + var prevKind = variableSymbol.kind; + var prevIsAmbient = variableSymbol.hasFlag(8 /* Ambient */); + var prevIsEnum = variableSymbol.hasFlag(131072 /* InitializedEnum */); + var prevIsClassConstructorVariable = variableSymbol.hasFlag(16384 /* ClassConstructorVariable */); + var prevIsModuleValue = variableSymbol.hasFlag(TypeScript.PullElementFlags.SomeInitializedModule); + var prevIsImplicit = variableSymbol.hasFlag(TypeScript.PullElementFlags.ImplicitVariable); + var onlyOneIsEnum = (isEnumValue || prevIsEnum) && !(isEnumValue && prevIsEnum); + var isAmbient = (variableDeclaration.flags & 8 /* Ambient */) != 0; + var prevDecl = variableSymbol.getDeclarations()[0]; + var bothAreGlobal = parentDecl && (parentDecl.kind == 1 /* Script */) && (declKind == prevKind); + var shareParent = bothAreGlobal || prevDecl.getParentDecl() == variableDeclaration.getParentDecl(); + var prevIsParam = shareParent && prevKind == 2048 /* Parameter */ && declKind == 1024 /* Variable */; + + var acceptableRedeclaration = (!shareParent || prevIsParam) || (isImplicit && ((!isEnumValue && !isClassConstructorVariable && prevKind == 16384 /* Function */) || (isModuleValue && prevIsModuleValue) || (isClassConstructorVariable && prevIsModuleValue && isAmbient) || (isModuleValue && prevIsClassConstructorVariable))); + + if (acceptableRedeclaration && prevIsClassConstructorVariable && !prevIsAmbient) { + if (prevDecl.getScriptName() != variableDeclaration.getScriptName()) { + acceptableRedeclaration = false; + } + } + + if (shareParent && !prevIsParam && (!acceptableRedeclaration || onlyOneIsEnum)) { + if (isImplicit || prevIsImplicit || (prevKind & TypeScript.PullElementKind.SomeFunction) !== 0) { + span = variableDeclaration.getSpan(); + var errorDecl = isImplicit ? variableSymbol.getDeclarations()[0] : variableDeclaration; + errorDecl.addDiagnostic(new TypeScript.Diagnostic(this.semanticInfo.getPath(), span.start(), span.length(), TypeScript.DiagnosticCode.Duplicate_identifier_0, [variableDeclaration.getDisplayName()])); + } + + variableSymbol = null; + parentHadSymbol = false; + } + } else if (variableSymbol && (variableSymbol.kind !== 1024 /* Variable */) && !isImplicit) { + span = variableDeclaration.getSpan(); + + variableDeclaration.addDiagnostic(new TypeScript.Diagnostic(this.semanticInfo.getPath(), span.start(), span.length(), TypeScript.DiagnosticCode.Duplicate_identifier_0, [variableDeclaration.getDisplayName()])); + variableSymbol = null; + parentHadSymbol = false; + } + + if ((declFlags & TypeScript.PullElementFlags.ImplicitVariable) === 0) { + if (!variableSymbol) { + variableSymbol = new TypeScript.PullSymbol(declName, declKind); + this.semanticInfoChain.cacheGlobalSymbol(variableSymbol, declKind); + } + + variableSymbol.addDeclaration(variableDeclaration); + variableDeclaration.setSymbol(variableSymbol); + + this.semanticInfo.setSymbolForAST(varDeclAST.id, variableSymbol); + this.semanticInfo.setSymbolForAST(varDeclAST, variableSymbol); + } else if (!parentHadSymbol) { + if (isClassConstructorVariable) { + var classTypeSymbol = variableSymbol; + + if (parent) { + members = parent.getMembers(); + + for (var i = 0; i < members.length; i++) { + if ((members[i].name === declName) && (members[i].kind === 8 /* Class */)) { + classTypeSymbol = members[i]; + break; + } + } + } + + if (!classTypeSymbol) { + var parentDecl = variableDeclaration.getParentDecl(); + + if (parentDecl) { + var childDecls = parentDecl.searchChildDecls(declName, TypeScript.PullElementKind.SomeType); + + if (childDecls.length) { + for (var i = 0; i < childDecls.length; i++) { + if (childDecls[i].getValueDecl() === variableDeclaration) { + classTypeSymbol = childDecls[i].getSymbol(); + } + } + } + } + + if (!classTypeSymbol) { + classTypeSymbol = this.semanticInfoChain.findTopLevelSymbol(declName, TypeScript.PullElementKind.SomeType, this.semanticInfo.getPath()); + } + } + + if (classTypeSymbol && (classTypeSymbol.kind !== 8 /* Class */)) { + classTypeSymbol = null; + } + + if (classTypeSymbol && classTypeSymbol.isClass()) { + variableSymbol = classTypeSymbol.getConstructorMethod(); + variableDeclaration.setSymbol(variableSymbol); + + decls = classTypeSymbol.getDeclarations(); + + if (decls.length) { + decl = decls[decls.length - 1]; + ast = this.semanticInfo.getASTForDecl(decl); + + if (ast) { + this.semanticInfo.setASTForDecl(variableDeclaration, ast); + } + } + } else { + if (!variableSymbol) { + variableSymbol = new TypeScript.PullSymbol(declName, declKind); + } + + variableSymbol.addDeclaration(variableDeclaration); + variableDeclaration.setSymbol(variableSymbol); + + variableSymbol.type = this.semanticInfoChain.anyTypeSymbol; + } + } else if (declFlags & TypeScript.PullElementFlags.SomeInitializedModule) { + var moduleContainerTypeSymbol = null; + var moduleParent = this.getParent(variableDeclaration); + + if (moduleParent) { + members = moduleParent.getMembers(); + + for (var i = 0; i < members.length; i++) { + if ((members[i].name === declName) && (members[i].isContainer())) { + moduleContainerTypeSymbol = members[i]; + break; + } + } + } + + if (!moduleContainerTypeSymbol) { + var parentDecl = variableDeclaration.getParentDecl(); + + if (parentDecl) { + var searchKind = (declFlags & (32768 /* InitializedModule */ | 65536 /* InitializedDynamicModule */)) ? TypeScript.PullElementKind.SomeContainer : 64 /* Enum */; + var childDecls = parentDecl.searchChildDecls(declName, searchKind); + + if (childDecls.length) { + for (var i = 0; i < childDecls.length; i++) { + if (childDecls[i].getValueDecl() === variableDeclaration) { + moduleContainerTypeSymbol = childDecls[i].getSymbol(); + } + } + } + } + if (!moduleContainerTypeSymbol) { + moduleContainerTypeSymbol = this.semanticInfoChain.findTopLevelSymbol(declName, TypeScript.PullElementKind.SomeContainer, this.semanticInfo.getPath()); + + if (!moduleContainerTypeSymbol) { + moduleContainerTypeSymbol = this.semanticInfoChain.findTopLevelSymbol(declName, 64 /* Enum */, this.semanticInfo.getPath()); + } + } + } + + if (moduleContainerTypeSymbol && (!moduleContainerTypeSymbol.isContainer())) { + moduleContainerTypeSymbol = null; + } + + if (moduleContainerTypeSymbol) { + variableSymbol = moduleContainerTypeSymbol.getInstanceSymbol(); + + variableSymbol.addDeclaration(variableDeclaration); + variableDeclaration.setSymbol(variableSymbol); + + decls = moduleContainerTypeSymbol.getDeclarations(); + + if (decls.length) { + decl = decls[decls.length - 1]; + ast = this.semanticInfo.getASTForDecl(decl); + + if (ast) { + this.semanticInfo.setASTForDecl(variableDeclaration, ast); + } + } + } else { + TypeScript.Debug.assert(false, "Attempted to bind invalid implicit variable symbol"); + } + } + } else { + variableSymbol.addDeclaration(variableDeclaration); + variableDeclaration.setSymbol(variableSymbol); + } + + if (parent && !parentHadSymbol) { + if (declFlags & 1 /* Exported */) { + parent.addMember(variableSymbol); + } else { + parent.addEnclosedNonMember(variableSymbol); + } + } + }; + + PullSymbolBinder.prototype.bindPropertyDeclarationToPullSymbol = function (propertyDeclaration) { + var declFlags = propertyDeclaration.flags; + var declKind = propertyDeclaration.kind; + var propDeclAST = this.semanticInfo.getASTForDecl(propertyDeclaration); + + var isStatic = false; + var isOptional = false; + + var propertySymbol = null; + + if (TypeScript.hasFlag(declFlags, 16 /* Static */)) { + isStatic = true; + } + + if (TypeScript.hasFlag(declFlags, 128 /* Optional */)) { + isOptional = true; + } + + var declName = propertyDeclaration.name; + + var parentHadSymbol = false; + + var parent = this.getParent(propertyDeclaration, true); + + if (parent.isClass() && isStatic) { + parent = parent.getConstructorMethod().type; + } + + propertySymbol = parent.findMember(declName, false); + + if (propertySymbol) { + var span = propertyDeclaration.getSpan(); + + propertyDeclaration.addDiagnostic(new TypeScript.Diagnostic(this.semanticInfo.getPath(), span.start(), span.length(), TypeScript.DiagnosticCode.Duplicate_identifier_0, [propertyDeclaration.getDisplayName()])); + + propertySymbol = null; + } + + if (propertySymbol) { + parentHadSymbol = true; + } + + var classTypeSymbol; + + if (!parentHadSymbol) { + propertySymbol = new TypeScript.PullSymbol(declName, declKind); + } + + propertySymbol.addDeclaration(propertyDeclaration); + propertyDeclaration.setSymbol(propertySymbol); + + this.semanticInfo.setSymbolForAST(propDeclAST.id, propertySymbol); + this.semanticInfo.setSymbolForAST(propDeclAST, propertySymbol); + + if (isOptional) { + propertySymbol.isOptional = true; + } + + if (parent && !parentHadSymbol) { + parent.addMember(propertySymbol); + } + }; + + PullSymbolBinder.prototype.bindParameterSymbols = function (funcDecl, funcType, signatureSymbol) { + var parameters = []; + var decl = null; + var argDecl = null; + var parameterSymbol = null; + var isProperty = false; + var params = new TypeScript.BlockIntrinsics(); + + if (funcDecl.arguments) { + for (var i = 0; i < funcDecl.arguments.members.length; i++) { + argDecl = funcDecl.arguments.members[i]; + decl = this.semanticInfo.getDeclForAST(argDecl); + isProperty = TypeScript.hasFlag(argDecl.getVarFlags(), 256 /* Property */); + parameterSymbol = new TypeScript.PullSymbol(argDecl.id.text(), 2048 /* Parameter */); + + if (funcDecl.variableArgList && i === funcDecl.arguments.members.length - 1) { + parameterSymbol.isVarArg = true; + } + + if (decl.flags & 128 /* Optional */) { + parameterSymbol.isOptional = true; + } + + if (params[argDecl.id.text()]) { + decl.addDiagnostic(new TypeScript.Diagnostic(this.semanticInfo.getPath(), argDecl.minChar, argDecl.getLength(), TypeScript.DiagnosticCode.Duplicate_identifier_0, [argDecl.id.actualText])); + } else { + params[argDecl.id.text()] = true; + } + if (decl) { + if (isProperty) { + decl.ensureSymbolIsBound(); + var valDecl = decl.getValueDecl(); + + if (valDecl) { + valDecl.setSymbol(parameterSymbol); + parameterSymbol.addDeclaration(valDecl); + } + } else { + parameterSymbol.addDeclaration(decl); + decl.setSymbol(parameterSymbol); + } + } + + signatureSymbol.addParameter(parameterSymbol, parameterSymbol.isOptional); + + if (signatureSymbol.isDefinition()) { + funcType.addEnclosedNonMember(parameterSymbol); + } + } + } + }; + + PullSymbolBinder.prototype.bindFunctionDeclarationToPullSymbol = function (functionDeclaration) { + var declKind = functionDeclaration.kind; + var declFlags = functionDeclaration.flags; + var funcDeclAST = this.semanticInfo.getASTForDecl(functionDeclaration); + + var isExported = (declFlags & 1 /* Exported */) !== 0; + + var funcName = functionDeclaration.name; + + var isSignature = (declFlags & 2048 /* Signature */) !== 0; + + var parent = this.getParent(functionDeclaration, true); + var parentDecl = functionDeclaration.getParentDecl(); + var parentHadSymbol = false; + + var functionSymbol = null; + var functionTypeSymbol = null; + + if (parent) { + functionSymbol = parent.findMember(funcName, false); + + if (!functionSymbol) { + functionSymbol = parent.findContainedNonMember(funcName); + + if (functionSymbol) { + var declarations = functionSymbol.getDeclarations(); + + if (declarations.length) { + var funcSymbolParentDecl = declarations[0].getParentDecl(); + + if (parentDecl !== funcSymbolParentDecl) { + functionSymbol = null; + } + } + } + } + } else if (!(functionDeclaration.flags & 1 /* Exported */)) { + functionSymbol = this.semanticInfoChain.findTopLevelSymbol(funcName, TypeScript.PullElementKind.SomeValue, this.semanticInfo.getPath()); + } + + if (functionSymbol && (functionSymbol.kind !== 16384 /* Function */ || (!isSignature && !functionSymbol.allDeclsHaveFlag(2048 /* Signature */)))) { + functionDeclaration.addDiagnostic(new TypeScript.Diagnostic(this.semanticInfo.getPath(), funcDeclAST.minChar, funcDeclAST.getLength(), TypeScript.DiagnosticCode.Duplicate_identifier_0, [functionDeclaration.getDisplayName()])); + functionSymbol = null; + } + + if (functionSymbol) { + functionTypeSymbol = functionSymbol.type; + parentHadSymbol = true; + } + + if (!functionSymbol) { + functionSymbol = new TypeScript.PullSymbol(funcName, 16384 /* Function */); + } + + if (!functionTypeSymbol) { + functionTypeSymbol = new TypeScript.PullTypeSymbol("", 16777216 /* FunctionType */); + functionSymbol.type = functionTypeSymbol; + functionTypeSymbol.setFunctionSymbol(functionSymbol); + } + + functionDeclaration.setSymbol(functionSymbol); + functionSymbol.addDeclaration(functionDeclaration); + functionTypeSymbol.addDeclaration(functionDeclaration); + + this.semanticInfo.setSymbolForAST(funcDeclAST.name, functionSymbol); + this.semanticInfo.setSymbolForAST(funcDeclAST, functionSymbol); + + if (parent && !parentHadSymbol) { + if (isExported) { + parent.addMember(functionSymbol); + } else { + parent.addEnclosedNonMember(functionSymbol); + } + } + + var signature = isSignature ? new TypeScript.PullSignatureSymbol(1048576 /* CallSignature */) : new TypeScript.PullDefinitionSignatureSymbol(1048576 /* CallSignature */); + + signature.addDeclaration(functionDeclaration); + functionDeclaration.setSignatureSymbol(signature); + + if (funcDeclAST.variableArgList) { + signature.hasVarArgs = true; + } + + this.bindParameterSymbols(this.semanticInfo.getASTForDecl(functionDeclaration), functionTypeSymbol, signature); + + var typeParameters = functionDeclaration.getTypeParameters(); + var typeParameter; + var typeParameterDecls = null; + + for (var i = 0; i < typeParameters.length; i++) { + typeParameter = signature.findTypeParameter(typeParameters[i].name); + + if (!typeParameter) { + typeParameter = new TypeScript.PullTypeParameterSymbol(typeParameters[i].name, true); + + signature.addTypeParameter(typeParameter); + } else { + typeParameterDecls = typeParameter.getDeclarations(); + + var typeParameterAST = this.semanticInfoChain.getASTForDecl(typeParameterDecls[0]); + functionDeclaration.addDiagnostic(new TypeScript.Diagnostic(this.semanticInfo.getPath(), typeParameterAST.minChar, typeParameterAST.getLength(), TypeScript.DiagnosticCode.Duplicate_identifier_0, [typeParameter.name])); + } + + typeParameter.addDeclaration(typeParameters[i]); + typeParameters[i].setSymbol(typeParameter); + } + + functionTypeSymbol.addCallSignature(signature); + + var otherDecls = this.findDeclsInContext(functionDeclaration, functionDeclaration.kind, false); + + if (otherDecls && otherDecls.length) { + for (var i = 0; i < otherDecls.length; i++) { + otherDecls[i].ensureSymbolIsBound(); + } + } + }; + + PullSymbolBinder.prototype.bindFunctionExpressionToPullSymbol = function (functionExpressionDeclaration) { + var declKind = functionExpressionDeclaration.kind; + var declFlags = functionExpressionDeclaration.flags; + var funcExpAST = this.semanticInfo.getASTForDecl(functionExpressionDeclaration); + + var functionName = declKind == 131072 /* FunctionExpression */ ? (functionExpressionDeclaration).getFunctionExpressionName() : functionExpressionDeclaration.name; + var functionSymbol = new TypeScript.PullSymbol(functionName, 16384 /* Function */); + var functionTypeSymbol = new TypeScript.PullTypeSymbol("", 16777216 /* FunctionType */); + functionTypeSymbol.setFunctionSymbol(functionSymbol); + + functionSymbol.type = functionTypeSymbol; + + functionExpressionDeclaration.setSymbol(functionSymbol); + functionSymbol.addDeclaration(functionExpressionDeclaration); + functionTypeSymbol.addDeclaration(functionExpressionDeclaration); + + if (funcExpAST.name) { + this.semanticInfo.setSymbolForAST(funcExpAST.name, functionSymbol); + } + this.semanticInfo.setSymbolForAST(funcExpAST, functionSymbol); + + var signature = new TypeScript.PullDefinitionSignatureSymbol(1048576 /* CallSignature */); + + if (funcExpAST.variableArgList) { + signature.hasVarArgs = true; + } + + var typeParameters = functionExpressionDeclaration.getTypeParameters(); + var typeParameter; + var typeParameterDecls = null; + + for (var i = 0; i < typeParameters.length; i++) { + typeParameter = signature.findTypeParameter(typeParameters[i].name); + + if (!typeParameter) { + typeParameter = new TypeScript.PullTypeParameterSymbol(typeParameters[i].name, true); + + signature.addTypeParameter(typeParameter); + } else { + typeParameterDecls = typeParameter.getDeclarations(); + + var typeParameterAST = this.semanticInfoChain.getASTForDecl(typeParameterDecls[0]); + functionExpressionDeclaration.addDiagnostic(new TypeScript.Diagnostic(this.semanticInfo.getPath(), typeParameterAST.minChar, typeParameterAST.getLength(), TypeScript.DiagnosticCode.Duplicate_identifier_0, [typeParameter.getName()])); + } + + typeParameter.addDeclaration(typeParameters[i]); + typeParameters[i].setSymbol(typeParameter); + } + + signature.addDeclaration(functionExpressionDeclaration); + functionExpressionDeclaration.setSignatureSymbol(signature); + + this.bindParameterSymbols(this.semanticInfo.getASTForDecl(functionExpressionDeclaration), functionTypeSymbol, signature); + + functionTypeSymbol.addCallSignature(signature); + }; + + PullSymbolBinder.prototype.bindFunctionTypeDeclarationToPullSymbol = function (functionTypeDeclaration) { + var declKind = functionTypeDeclaration.kind; + var declFlags = functionTypeDeclaration.flags; + var funcTypeAST = this.semanticInfo.getASTForDecl(functionTypeDeclaration); + + var functionTypeSymbol = new TypeScript.PullTypeSymbol("", 16777216 /* FunctionType */); + + functionTypeDeclaration.setSymbol(functionTypeSymbol); + functionTypeSymbol.addDeclaration(functionTypeDeclaration); + this.semanticInfo.setSymbolForAST(funcTypeAST, functionTypeSymbol); + + var isSignature = (declFlags & 2048 /* Signature */) !== 0; + var signature = isSignature ? new TypeScript.PullSignatureSymbol(1048576 /* CallSignature */) : new TypeScript.PullDefinitionSignatureSymbol(1048576 /* CallSignature */); + + if (funcTypeAST.variableArgList) { + signature.hasVarArgs = true; + } + + var typeParameters = functionTypeDeclaration.getTypeParameters(); + var typeParameter; + var typeParameterDecls = null; + + for (var i = 0; i < typeParameters.length; i++) { + typeParameter = signature.findTypeParameter(typeParameters[i].name); + + if (!typeParameter) { + typeParameter = new TypeScript.PullTypeParameterSymbol(typeParameters[i].name, true); + + signature.addTypeParameter(typeParameter); + } else { + var typeParameterAST = this.semanticInfoChain.getASTForDecl(typeParameterDecls[0]); + functionTypeDeclaration.addDiagnostic(new TypeScript.Diagnostic(this.semanticInfo.getPath(), typeParameterAST.minChar, typeParameterAST.getLength(), TypeScript.DiagnosticCode.Duplicate_identifier_0, [typeParameter.name])); + } + + typeParameter.addDeclaration(typeParameters[i]); + typeParameters[i].setSymbol(typeParameter); + } + + signature.addDeclaration(functionTypeDeclaration); + functionTypeDeclaration.setSignatureSymbol(signature); + + this.bindParameterSymbols(this.semanticInfo.getASTForDecl(functionTypeDeclaration), functionTypeSymbol, signature); + + functionTypeSymbol.addCallSignature(signature); + }; + + PullSymbolBinder.prototype.bindMethodDeclarationToPullSymbol = function (methodDeclaration) { + var declKind = methodDeclaration.kind; + var declFlags = methodDeclaration.flags; + var methodAST = this.semanticInfo.getASTForDecl(methodDeclaration); + + var isPrivate = (declFlags & 2 /* Private */) !== 0; + var isStatic = (declFlags & 16 /* Static */) !== 0; + var isOptional = (declFlags & 128 /* Optional */) !== 0; + + var methodName = methodDeclaration.name; + + var isSignature = (declFlags & 2048 /* Signature */) !== 0; + + var parent = this.getParent(methodDeclaration, true); + var parentHadSymbol = false; + + var methodSymbol = null; + var methodTypeSymbol = null; + + if (parent.isClass() && isStatic) { + parent = parent.getConstructorMethod().type; + } + + methodSymbol = parent.findMember(methodName, false); + + if (methodSymbol && (methodSymbol.kind !== 65536 /* Method */ || (!isSignature && !methodSymbol.allDeclsHaveFlag(2048 /* Signature */)))) { + methodDeclaration.addDiagnostic(new TypeScript.Diagnostic(this.semanticInfo.getPath(), methodAST.minChar, methodAST.getLength(), TypeScript.DiagnosticCode.Duplicate_identifier_0, [methodDeclaration.getDisplayName()])); + methodSymbol = null; + } + + if (methodSymbol) { + methodTypeSymbol = methodSymbol.type; + parentHadSymbol = true; + } + + if (!methodSymbol) { + methodSymbol = new TypeScript.PullSymbol(methodName, 65536 /* Method */); + } + + if (!methodTypeSymbol) { + methodTypeSymbol = new TypeScript.PullTypeSymbol("", 16777216 /* FunctionType */); + methodSymbol.type = methodTypeSymbol; + methodTypeSymbol.setFunctionSymbol(methodSymbol); + } + + methodDeclaration.setSymbol(methodSymbol); + methodSymbol.addDeclaration(methodDeclaration); + methodTypeSymbol.addDeclaration(methodDeclaration); + this.semanticInfo.setSymbolForAST(methodAST.name, methodSymbol); + this.semanticInfo.setSymbolForAST(methodAST, methodSymbol); + + if (isOptional) { + methodSymbol.isOptional = true; + } + + if (!parentHadSymbol) { + parent.addMember(methodSymbol); + } + + var sigKind = 1048576 /* CallSignature */; + + var signature = isSignature ? new TypeScript.PullSignatureSymbol(sigKind) : new TypeScript.PullDefinitionSignatureSymbol(sigKind); + + if (methodAST.variableArgList) { + signature.hasVarArgs = true; + } + + var typeParameters = methodDeclaration.getTypeParameters(); + var typeParameter; + var typeParameterDecls = null; + var typeParameterName; + var typeParameterAST; + + for (var i = 0; i < typeParameters.length; i++) { + typeParameterName = typeParameters[i].name; + typeParameterAST = this.semanticInfo.getASTForDecl(typeParameters[i]); + + typeParameter = signature.findTypeParameter(typeParameterName); + + if (!typeParameter) { + if (!typeParameterAST.constraint) { + typeParameter = this.findTypeParameterInCache(typeParameterName); + } + + if (!typeParameter) { + typeParameter = new TypeScript.PullTypeParameterSymbol(typeParameterName, true); + + if (!typeParameterAST.constraint) { + this.addTypeParameterToCache(typeParameter); + } + } + + signature.addTypeParameter(typeParameter); + } else { + typeParameterDecls = typeParameter.getDeclarations(); + + typeParameterAST = this.semanticInfoChain.getASTForDecl(typeParameterDecls[0]); + methodDeclaration.addDiagnostic(new TypeScript.Diagnostic(this.semanticInfo.getPath(), typeParameterAST.minChar, typeParameterAST.getLength(), TypeScript.DiagnosticCode.Duplicate_identifier_0, [typeParameter.getName()])); + } + + typeParameter.addDeclaration(typeParameters[i]); + typeParameters[i].setSymbol(typeParameter); + } + + signature.addDeclaration(methodDeclaration); + methodDeclaration.setSignatureSymbol(signature); + + this.bindParameterSymbols(this.semanticInfo.getASTForDecl(methodDeclaration), methodTypeSymbol, signature); + + methodTypeSymbol.addCallSignature(signature); + + var otherDecls = this.findDeclsInContext(methodDeclaration, methodDeclaration.kind, false); + + if (otherDecls && otherDecls.length) { + for (var i = 0; i < otherDecls.length; i++) { + otherDecls[i].ensureSymbolIsBound(); + } + } + }; + + PullSymbolBinder.prototype.bindConstructorDeclarationToPullSymbol = function (constructorDeclaration) { + var declKind = constructorDeclaration.kind; + var declFlags = constructorDeclaration.flags; + var constructorAST = this.semanticInfo.getASTForDecl(constructorDeclaration); + + var constructorName = constructorDeclaration.name; + + var isSignature = (declFlags & 2048 /* Signature */) !== 0; + + var parent = this.getParent(constructorDeclaration, true); + + var parentHadSymbol = false; + + var constructorSymbol = parent.getConstructorMethod(); + var constructorTypeSymbol = null; + + if (constructorSymbol && (constructorSymbol.kind !== 32768 /* ConstructorMethod */ || (!isSignature && constructorSymbol.type && constructorSymbol.type.hasOwnConstructSignatures()))) { + var hasDefinitionSignature = false; + var constructorSigs = constructorSymbol.type.getConstructSignatures(); + + for (var i = 0; i < constructorSigs.length; i++) { + if (!constructorSigs[i].hasFlag(2048 /* Signature */)) { + hasDefinitionSignature = true; + break; + } + } + + if (hasDefinitionSignature) { + constructorDeclaration.addDiagnostic(new TypeScript.Diagnostic(this.semanticInfo.getPath(), constructorAST.minChar, constructorAST.getLength(), TypeScript.DiagnosticCode.Multiple_constructor_implementations_are_not_allowed, null)); + + constructorSymbol = null; + } + } + + if (constructorSymbol) { + constructorTypeSymbol = constructorSymbol.type; + } else { + constructorSymbol = new TypeScript.PullSymbol(constructorName, 32768 /* ConstructorMethod */); + constructorTypeSymbol = new TypeScript.PullTypeSymbol("", 33554432 /* ConstructorType */); + } + + parent.setConstructorMethod(constructorSymbol); + constructorSymbol.type = constructorTypeSymbol; + + constructorDeclaration.setSymbol(constructorSymbol); + constructorSymbol.addDeclaration(constructorDeclaration); + constructorTypeSymbol.addDeclaration(constructorDeclaration); + constructorSymbol.setIsSynthesized(false); + this.semanticInfo.setSymbolForAST(constructorAST, constructorSymbol); + + var constructSignature = isSignature ? new TypeScript.PullSignatureSymbol(2097152 /* ConstructSignature */) : new TypeScript.PullDefinitionSignatureSymbol(2097152 /* ConstructSignature */); + + constructSignature.returnType = parent; + + constructSignature.addDeclaration(constructorDeclaration); + constructorDeclaration.setSignatureSymbol(constructSignature); + + this.bindParameterSymbols(constructorAST, constructorTypeSymbol, constructSignature); + + var typeParameters = constructorTypeSymbol.getTypeParameters(); + + for (var i = 0; i < typeParameters.length; i++) { + constructSignature.addTypeParameter(typeParameters[i]); + } + + if (constructorAST.variableArgList) { + constructSignature.hasVarArgs = true; + } + + constructorTypeSymbol.addConstructSignature(constructSignature); + + var otherDecls = this.findDeclsInContext(constructorDeclaration, constructorDeclaration.kind, false); + + if (otherDecls && otherDecls.length) { + for (var i = 0; i < otherDecls.length; i++) { + otherDecls[i].ensureSymbolIsBound(); + } + } + }; + + PullSymbolBinder.prototype.bindConstructSignatureDeclarationToPullSymbol = function (constructSignatureDeclaration) { + var parent = this.getParent(constructSignatureDeclaration, true); + var constructorAST = this.semanticInfo.getASTForDecl(constructSignatureDeclaration); + + var constructSignature = new TypeScript.PullSignatureSymbol(2097152 /* ConstructSignature */); + + if (constructorAST.variableArgList) { + constructSignature.hasVarArgs = true; + } + + var typeParameters = constructSignatureDeclaration.getTypeParameters(); + var typeParameter; + var typeParameterDecls = null; + + for (var i = 0; i < typeParameters.length; i++) { + typeParameter = constructSignature.findTypeParameter(typeParameters[i].name); + + if (!typeParameter) { + typeParameter = new TypeScript.PullTypeParameterSymbol(typeParameters[i].name, true); + + constructSignature.addTypeParameter(typeParameter); + } else { + typeParameterDecls = typeParameter.getDeclarations(); + + var typeParameterAST = this.semanticInfoChain.getASTForDecl(typeParameterDecls[0]); + constructSignatureDeclaration.addDiagnostic(new TypeScript.Diagnostic(this.semanticInfo.getPath(), typeParameterAST.minChar, typeParameterAST.getLength(), TypeScript.DiagnosticCode.Duplicate_identifier_0, [typeParameter.getName()])); + } + + typeParameter.addDeclaration(typeParameters[i]); + typeParameters[i].setSymbol(typeParameter); + } + + constructSignature.addDeclaration(constructSignatureDeclaration); + constructSignatureDeclaration.setSignatureSymbol(constructSignature); + + this.bindParameterSymbols(this.semanticInfo.getASTForDecl(constructSignatureDeclaration), null, constructSignature); + + this.semanticInfo.setSymbolForAST(this.semanticInfo.getASTForDecl(constructSignatureDeclaration), constructSignature); + + parent.addConstructSignature(constructSignature); + }; + + PullSymbolBinder.prototype.bindCallSignatureDeclarationToPullSymbol = function (callSignatureDeclaration) { + var parent = this.getParent(callSignatureDeclaration, true); + var callSignatureAST = this.semanticInfo.getASTForDecl(callSignatureDeclaration); + + var callSignature = new TypeScript.PullSignatureSymbol(1048576 /* CallSignature */); + + if (callSignatureAST.variableArgList) { + callSignature.hasVarArgs = true; + } + + var typeParameters = callSignatureDeclaration.getTypeParameters(); + var typeParameter; + var typeParameterDecls = null; + + for (var i = 0; i < typeParameters.length; i++) { + typeParameter = callSignature.findTypeParameter(typeParameters[i].name); + + if (!typeParameter) { + typeParameter = new TypeScript.PullTypeParameterSymbol(typeParameters[i].name, true); + + callSignature.addTypeParameter(typeParameter); + } else { + typeParameterDecls = typeParameter.getDeclarations(); + + var typeParameterAST = this.semanticInfoChain.getASTForDecl(typeParameterDecls[0]); + callSignatureDeclaration.addDiagnostic(new TypeScript.Diagnostic(this.semanticInfo.getPath(), typeParameterAST.minChar, typeParameterAST.getLength(), TypeScript.DiagnosticCode.Duplicate_identifier_0, [typeParameter.getName()])); + } + + typeParameter.addDeclaration(typeParameters[i]); + typeParameters[i].setSymbol(typeParameter); + } + + callSignature.addDeclaration(callSignatureDeclaration); + callSignatureDeclaration.setSignatureSymbol(callSignature); + + this.bindParameterSymbols(this.semanticInfo.getASTForDecl(callSignatureDeclaration), null, callSignature); + + this.semanticInfo.setSymbolForAST(this.semanticInfo.getASTForDecl(callSignatureDeclaration), callSignature); + + parent.addCallSignature(callSignature); + }; + + PullSymbolBinder.prototype.bindIndexSignatureDeclarationToPullSymbol = function (indexSignatureDeclaration) { + var parent = this.getParent(indexSignatureDeclaration, true); + + var indexSignature = new TypeScript.PullSignatureSymbol(4194304 /* IndexSignature */); + + var typeParameters = indexSignatureDeclaration.getTypeParameters(); + var typeParameter; + var typeParameterDecls = null; + + for (var i = 0; i < typeParameters.length; i++) { + typeParameter = indexSignature.findTypeParameter(typeParameters[i].name); + + if (!typeParameter) { + typeParameter = new TypeScript.PullTypeParameterSymbol(typeParameters[i].name, true); + + indexSignature.addTypeParameter(typeParameter); + } else { + typeParameterDecls = typeParameter.getDeclarations(); + + var typeParameterAST = this.semanticInfoChain.getASTForDecl(typeParameterDecls[0]); + indexSignatureDeclaration.addDiagnostic(new TypeScript.Diagnostic(this.semanticInfo.getPath(), typeParameterAST.minChar, typeParameterAST.getLength(), TypeScript.DiagnosticCode.Duplicate_identifier_0, [typeParameter.name])); + } + + typeParameter.addDeclaration(typeParameters[i]); + typeParameters[i].setSymbol(typeParameter); + } + + indexSignature.addDeclaration(indexSignatureDeclaration); + indexSignatureDeclaration.setSignatureSymbol(indexSignature); + + this.bindParameterSymbols(this.semanticInfo.getASTForDecl(indexSignatureDeclaration), null, indexSignature); + + this.semanticInfo.setSymbolForAST(this.semanticInfo.getASTForDecl(indexSignatureDeclaration), indexSignature); + + parent.addIndexSignature(indexSignature); + }; + + PullSymbolBinder.prototype.bindGetAccessorDeclarationToPullSymbol = function (getAccessorDeclaration) { + var declKind = getAccessorDeclaration.kind; + var declFlags = getAccessorDeclaration.flags; + var funcDeclAST = this.semanticInfo.getASTForDecl(getAccessorDeclaration); + + var isExported = (declFlags & 1 /* Exported */) !== 0; + + var funcName = getAccessorDeclaration.name; + + var isSignature = (declFlags & 2048 /* Signature */) !== 0; + var isStatic = false; + + if (TypeScript.hasFlag(declFlags, 16 /* Static */)) { + isStatic = true; + } + + var parent = this.getParent(getAccessorDeclaration, true); + var parentHadSymbol = false; + + var accessorSymbol = null; + var getterSymbol = null; + var getterTypeSymbol = null; + + if (isStatic) { + parent = parent.getConstructorMethod().type; + } + + accessorSymbol = parent.findMember(funcName, false); + + if (accessorSymbol) { + if (!accessorSymbol.isAccessor()) { + getAccessorDeclaration.addDiagnostic(new TypeScript.Diagnostic(this.semanticInfo.getPath(), funcDeclAST.minChar, funcDeclAST.getLength(), TypeScript.DiagnosticCode.Duplicate_identifier_0, [getAccessorDeclaration.getDisplayName()])); + accessorSymbol = null; + } else { + getterSymbol = accessorSymbol.getGetter(); + + if (getterSymbol) { + getAccessorDeclaration.addDiagnostic(new TypeScript.Diagnostic(this.semanticInfo.getPath(), funcDeclAST.minChar, funcDeclAST.getLength(), TypeScript.DiagnosticCode.Getter_0_already_declared, [getAccessorDeclaration.getDisplayName()])); + accessorSymbol = null; + getterSymbol = null; + } + } + } + + if (accessorSymbol) { + parentHadSymbol = true; + } + + if (accessorSymbol && getterSymbol) { + getterTypeSymbol = getterSymbol.type; + } + + if (!accessorSymbol) { + accessorSymbol = new TypeScript.PullAccessorSymbol(funcName); + } + + if (!getterSymbol) { + getterSymbol = new TypeScript.PullSymbol(funcName, 16384 /* Function */); + getterTypeSymbol = new TypeScript.PullTypeSymbol("", 16777216 /* FunctionType */); + getterTypeSymbol.setFunctionSymbol(getterSymbol); + + getterSymbol.type = getterTypeSymbol; + + accessorSymbol.setGetter(getterSymbol); + } + + getAccessorDeclaration.setSymbol(accessorSymbol); + accessorSymbol.addDeclaration(getAccessorDeclaration); + getterSymbol.addDeclaration(getAccessorDeclaration); + + this.semanticInfo.setSymbolForAST(funcDeclAST.name, getterSymbol); + this.semanticInfo.setSymbolForAST(funcDeclAST, getterSymbol); + + if (!parentHadSymbol) { + parent.addMember(accessorSymbol); + } + + var signature = isSignature ? new TypeScript.PullSignatureSymbol(1048576 /* CallSignature */) : new TypeScript.PullDefinitionSignatureSymbol(1048576 /* CallSignature */); + + signature.addDeclaration(getAccessorDeclaration); + getAccessorDeclaration.setSignatureSymbol(signature); + + this.bindParameterSymbols(this.semanticInfo.getASTForDecl(getAccessorDeclaration), getterTypeSymbol, signature); + + var typeParameters = getAccessorDeclaration.getTypeParameters(); + + if (typeParameters.length) { + getAccessorDeclaration.addDiagnostic(new TypeScript.Diagnostic(this.semanticInfo.getPath(), funcDeclAST.minChar, funcDeclAST.getLength(), TypeScript.DiagnosticCode.Accessors_cannot_have_type_parameters, null)); + } + + getterTypeSymbol.addCallSignature(signature); + }; + + PullSymbolBinder.prototype.bindSetAccessorDeclarationToPullSymbol = function (setAccessorDeclaration) { + var declKind = setAccessorDeclaration.kind; + var declFlags = setAccessorDeclaration.flags; + var funcDeclAST = this.semanticInfo.getASTForDecl(setAccessorDeclaration); + + var isExported = (declFlags & 1 /* Exported */) !== 0; + + var funcName = setAccessorDeclaration.name; + + var isSignature = (declFlags & 2048 /* Signature */) !== 0; + var isStatic = false; + + if (TypeScript.hasFlag(declFlags, 16 /* Static */)) { + isStatic = true; + } + + var parent = this.getParent(setAccessorDeclaration, true); + var parentHadSymbol = false; + + var accessorSymbol = null; + var setterSymbol = null; + var setterTypeSymbol = null; + + if (isStatic) { + parent = parent.getConstructorMethod().type; + } + + accessorSymbol = parent.findMember(funcName, false); + + if (accessorSymbol) { + if (!accessorSymbol.isAccessor()) { + setAccessorDeclaration.addDiagnostic(new TypeScript.Diagnostic(this.semanticInfo.getPath(), funcDeclAST.minChar, funcDeclAST.getLength(), TypeScript.DiagnosticCode.Duplicate_identifier_0, [setAccessorDeclaration.getDisplayName()])); + accessorSymbol = null; + } else { + setterSymbol = accessorSymbol.getSetter(); + + if (setterSymbol) { + setAccessorDeclaration.addDiagnostic(new TypeScript.Diagnostic(this.semanticInfo.getPath(), funcDeclAST.minChar, funcDeclAST.getLength(), TypeScript.DiagnosticCode.Setter_0_already_declared, [setAccessorDeclaration.getDisplayName()])); + accessorSymbol = null; + setterSymbol = null; + } + } + } + + if (accessorSymbol) { + parentHadSymbol = true; + + if (setterSymbol) { + setterTypeSymbol = setterSymbol.type; + } + } + + if (!accessorSymbol) { + accessorSymbol = new TypeScript.PullAccessorSymbol(funcName); + } + + if (!setterSymbol) { + setterSymbol = new TypeScript.PullSymbol(funcName, 16384 /* Function */); + setterTypeSymbol = new TypeScript.PullTypeSymbol("", 16777216 /* FunctionType */); + setterTypeSymbol.setFunctionSymbol(setterSymbol); + + setterSymbol.type = setterTypeSymbol; + + accessorSymbol.setSetter(setterSymbol); + } + + setAccessorDeclaration.setSymbol(accessorSymbol); + accessorSymbol.addDeclaration(setAccessorDeclaration); + setterSymbol.addDeclaration(setAccessorDeclaration); + + this.semanticInfo.setSymbolForAST(funcDeclAST.name, setterSymbol); + this.semanticInfo.setSymbolForAST(funcDeclAST, setterSymbol); + + if (!parentHadSymbol) { + parent.addMember(accessorSymbol); + } + + var signature = isSignature ? new TypeScript.PullSignatureSymbol(1048576 /* CallSignature */) : new TypeScript.PullDefinitionSignatureSymbol(1048576 /* CallSignature */); + + signature.addDeclaration(setAccessorDeclaration); + setAccessorDeclaration.setSignatureSymbol(signature); + + this.bindParameterSymbols(this.semanticInfo.getASTForDecl(setAccessorDeclaration), setterTypeSymbol, signature); + + var typeParameters = setAccessorDeclaration.getTypeParameters(); + + if (typeParameters.length) { + setAccessorDeclaration.addDiagnostic(new TypeScript.Diagnostic(this.semanticInfo.getPath(), funcDeclAST.minChar, funcDeclAST.getLength(), TypeScript.DiagnosticCode.Accessors_cannot_have_type_parameters, null)); + } + + setterTypeSymbol.addCallSignature(signature); + }; + + PullSymbolBinder.prototype.bindDeclToPullSymbol = function (decl) { + if (decl.isBound()) { + return; + } + + decl.setIsBound(true); + + switch (decl.kind) { + case 1 /* Script */: + var childDecls = decl.getChildDecls(); + for (var i = 0; i < childDecls.length; i++) { + this.bindDeclToPullSymbol(childDecls[i]); + } + break; + + case 64 /* Enum */: + case 32 /* DynamicModule */: + case 4 /* Container */: + this.bindModuleDeclarationToPullSymbol(decl); + break; + + case 16 /* Interface */: + this.bindInterfaceDeclarationToPullSymbol(decl); + break; + + case 8 /* Class */: + this.bindClassDeclarationToPullSymbol(decl); + break; + + case 16384 /* Function */: + this.bindFunctionDeclarationToPullSymbol(decl); + break; + + case 1024 /* Variable */: + this.bindVariableDeclarationToPullSymbol(decl); + break; + + case 67108864 /* EnumMember */: + case 4096 /* Property */: + this.bindPropertyDeclarationToPullSymbol(decl); + break; + + case 65536 /* Method */: + this.bindMethodDeclarationToPullSymbol(decl); + break; + + case 32768 /* ConstructorMethod */: + this.bindConstructorDeclarationToPullSymbol(decl); + break; + + case 1048576 /* CallSignature */: + this.bindCallSignatureDeclarationToPullSymbol(decl); + break; + + case 2097152 /* ConstructSignature */: + this.bindConstructSignatureDeclarationToPullSymbol(decl); + break; + + case 4194304 /* IndexSignature */: + this.bindIndexSignatureDeclarationToPullSymbol(decl); + break; + + case 262144 /* GetAccessor */: + this.bindGetAccessorDeclarationToPullSymbol(decl); + break; + + case 524288 /* SetAccessor */: + this.bindSetAccessorDeclarationToPullSymbol(decl); + break; + + case 8388608 /* ObjectType */: + this.bindObjectTypeDeclarationToPullSymbol(decl); + break; + + case 16777216 /* FunctionType */: + this.bindFunctionTypeDeclarationToPullSymbol(decl); + break; + + case 33554432 /* ConstructorType */: + this.bindConstructorTypeDeclarationToPullSymbol(decl); + break; + + case 131072 /* FunctionExpression */: + this.bindFunctionExpressionToPullSymbol(decl); + break; + + case 256 /* TypeAlias */: + this.bindImportDeclaration(decl); + break; + + case 2048 /* Parameter */: + case 8192 /* TypeParameter */: + break; + + case 1073741824 /* CatchBlock */: + case 536870912 /* WithBlock */: + break; + + default: + TypeScript.CompilerDiagnostics.assert(false, "Unrecognized type declaration"); + } + }; + + PullSymbolBinder.prototype.bindDeclsForUnit = function (filePath) { + this.setUnit(filePath); + + var topLevelDecls = this.semanticInfo.getTopLevelDecls(); + + for (var i = 0; i < topLevelDecls.length; i++) { + this.bindDeclToPullSymbol(topLevelDecls[i]); + } + }; + return PullSymbolBinder; + })(); + TypeScript.PullSymbolBinder = PullSymbolBinder; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + function getDiagnosticsFromEnclosingDecl(enclosingDecl, errors) { + var declErrors = enclosingDecl.getDiagnostics(); + + if (declErrors) { + for (var i = 0; i < declErrors.length; i++) { + errors[errors.length] = declErrors[i]; + } + } + + var childDecls = enclosingDecl.getChildDecls(); + + for (var i = 0; i < childDecls.length; i++) { + getDiagnosticsFromEnclosingDecl(childDecls[i], errors); + } + } + TypeScript.getDiagnosticsFromEnclosingDecl = getDiagnosticsFromEnclosingDecl; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (PullHelpers) { + function getSignatureForFuncDecl(funcDecl, semanticInfo) { + var functionDecl = semanticInfo.getDeclForAST(funcDecl); + var funcSymbol = functionDecl.getSymbol(); + + if (!funcSymbol) { + funcSymbol = functionDecl.getSignatureSymbol(); + } + + var functionSignature = null; + var typeSymbolWithAllSignatures = null; + if (funcSymbol.isSignature()) { + functionSignature = funcSymbol; + var parent = functionDecl.getParentDecl(); + typeSymbolWithAllSignatures = parent.getSymbol().type; + } else { + functionSignature = functionDecl.getSignatureSymbol(); + typeSymbolWithAllSignatures = funcSymbol.type; + } + var signatures; + if (funcDecl.isConstructor || funcDecl.isConstructMember()) { + signatures = typeSymbolWithAllSignatures.getConstructSignatures(); + } else if (funcDecl.isIndexerMember()) { + signatures = typeSymbolWithAllSignatures.getIndexSignatures(); + } else { + signatures = typeSymbolWithAllSignatures.getCallSignatures(); + } + return { + signature: functionSignature, + allSignatures: signatures + }; + } + PullHelpers.getSignatureForFuncDecl = getSignatureForFuncDecl; + + function getAccessorSymbol(getterOrSetter, semanticInfoChain, unitPath) { + var functionDecl = semanticInfoChain.getDeclForAST(getterOrSetter, unitPath); + var getterOrSetterSymbol = functionDecl.getSymbol(); + + return getterOrSetterSymbol; + } + PullHelpers.getAccessorSymbol = getAccessorSymbol; + + function getGetterAndSetterFunction(funcDecl, semanticInfoChain, unitPath) { + var accessorSymbol = PullHelpers.getAccessorSymbol(funcDecl, semanticInfoChain, unitPath); + var result = { + getter: null, + setter: null + }; + var getter = accessorSymbol.getGetter(); + if (getter) { + var getterDecl = getter.getDeclarations()[0]; + result.getter = semanticInfoChain.getASTForDecl(getterDecl); + } + var setter = accessorSymbol.getSetter(); + if (setter) { + var setterDecl = setter.getDeclarations()[0]; + result.setter = semanticInfoChain.getASTForDecl(setterDecl); + } + + return result; + } + PullHelpers.getGetterAndSetterFunction = getGetterAndSetterFunction; + + function symbolIsEnum(source) { + return source && ((source.kind & (64 /* Enum */ | 67108864 /* EnumMember */)) || source.hasFlag(131072 /* InitializedEnum */)); + } + PullHelpers.symbolIsEnum = symbolIsEnum; + + function symbolIsModule(symbol) { + return symbol && (symbol.kind == 4 /* Container */ || isOneDeclarationOfKind(symbol, 4 /* Container */)); + } + PullHelpers.symbolIsModule = symbolIsModule; + + function isOneDeclarationOfKind(symbol, kind) { + var decls = symbol.getDeclarations(); + for (var i = 0; i < decls.length; i++) { + if (decls[i].kind === kind) { + return true; + } + } + + return false; + } + })(TypeScript.PullHelpers || (TypeScript.PullHelpers = {})); + var PullHelpers = TypeScript.PullHelpers; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var SyntaxTreeToAstVisitor = (function () { + function SyntaxTreeToAstVisitor(fileName, lineMap, compilationSettings) { + this.fileName = fileName; + this.lineMap = lineMap; + this.compilationSettings = compilationSettings; + this.position = 0; + this.previousTokenTrailingComments = null; + } + SyntaxTreeToAstVisitor.visit = function (syntaxTree, fileName, compilationSettings, incrementalAST) { + var visitor = incrementalAST ? new SyntaxTreeToIncrementalAstVisitor(fileName, syntaxTree.lineMap(), compilationSettings) : new SyntaxTreeToAstVisitor(fileName, syntaxTree.lineMap(), compilationSettings); + return syntaxTree.sourceUnit().accept(visitor); + }; + + SyntaxTreeToAstVisitor.prototype.movePast = function (element) { + if (element !== null) { + this.position += element.fullWidth(); + } + }; + + SyntaxTreeToAstVisitor.prototype.moveTo = function (element1, element2) { + if (element2 !== null) { + this.position += TypeScript.Syntax.childOffset(element1, element2); + } + }; + + SyntaxTreeToAstVisitor.prototype.setCommentsAndSpan = function (ast, fullStart, node) { + var firstToken = node.firstToken(); + var lastToken = node.lastToken(); + + this.setSpan2(ast, fullStart, node, firstToken, lastToken); + ast.setPreComments(this.convertTokenLeadingComments(firstToken, fullStart)); + ast.setPostComments(this.convertNodeTrailingComments(node, lastToken, fullStart)); + }; + + SyntaxTreeToAstVisitor.prototype.copySpan = function (from, to) { + to.minChar = from.minChar; + to.limChar = from.limChar; + to.trailingTriviaWidth = from.trailingTriviaWidth; + }; + + SyntaxTreeToAstVisitor.prototype.setSpan = function (span, fullStart, element) { + this.setSpan2(span, fullStart, element, element.firstToken(), element.lastToken()); + }; + + SyntaxTreeToAstVisitor.prototype.setSpan2 = function (span, fullStart, element, firstToken, lastToken) { + var leadingTriviaWidth = firstToken ? firstToken.leadingTriviaWidth() : 0; + var trailingTriviaWidth = lastToken ? lastToken.trailingTriviaWidth() : 0; + + var desiredMinChar = fullStart + leadingTriviaWidth; + var desiredLimChar = fullStart + element.fullWidth() - trailingTriviaWidth; + + this.setSpanExplicit(span, desiredMinChar, desiredLimChar); + + span.trailingTriviaWidth = trailingTriviaWidth; + }; + + SyntaxTreeToAstVisitor.prototype.setSpanExplicit = function (span, start, end) { + span.minChar = start; + span.limChar = end; + }; + + SyntaxTreeToAstVisitor.prototype.identifierFromToken = function (token, isOptional) { + var result = null; + if (token.fullWidth() === 0) { + result = new TypeScript.MissingIdentifier(); + } else if (token.kind() === 11 /* IdentifierName */) { + var tokenText = token.text(); + var text = tokenText === SyntaxTreeToAstVisitor.protoString ? SyntaxTreeToAstVisitor.protoSubstitutionString : null; + + result = new TypeScript.Identifier(tokenText, text); + } else { + var tokenText = token.text(); + result = new TypeScript.Identifier(tokenText, tokenText); + } + + if (isOptional) { + result.setFlags(result.getFlags() | 4 /* OptionalName */); + } + + var start = this.position + token.leadingTriviaWidth(); + this.setSpanExplicit(result, start, start + token.width()); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitSyntaxList = function (node) { + var start = this.position; + var array = new Array(node.childCount()); + + for (var i = 0, n = node.childCount(); i < n; i++) { + array[i] = node.childAt(i).accept(this); + } + + var result = new TypeScript.ASTList(array); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitSeparatedSyntaxList = function (list) { + var start = this.position; + var array = new Array(list.nonSeparatorCount()); + + for (var i = 0, n = list.childCount(); i < n; i++) { + if (i % 2 === 0) { + array[i / 2] = list.childAt(i).accept(this); + this.previousTokenTrailingComments = null; + } else { + var separatorToken = list.childAt(i); + this.previousTokenTrailingComments = this.convertTokenTrailingComments(separatorToken, this.position + separatorToken.leadingTriviaWidth() + separatorToken.width()); + this.movePast(separatorToken); + } + } + + var result = new TypeScript.ASTList(array, list.separatorCount()); + this.setSpan(result, start, list); + + result.setPostComments(this.previousTokenTrailingComments); + this.previousTokenTrailingComments = null; + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.createRef = function (text, minChar) { + var id = new TypeScript.Identifier(text, null); + id.minChar = minChar; + return id; + }; + + SyntaxTreeToAstVisitor.prototype.convertComment = function (trivia, commentStartPosition, hasTrailingNewLine) { + var comment = new TypeScript.Comment(trivia.fullText(), trivia.kind() === 6 /* MultiLineCommentTrivia */, hasTrailingNewLine); + + comment.minChar = commentStartPosition; + comment.limChar = commentStartPosition + trivia.fullWidth(); + + return comment; + }; + + SyntaxTreeToAstVisitor.prototype.convertComments = function (triviaList, commentStartPosition) { + var result = []; + + for (var i = 0, n = triviaList.count(); i < n; i++) { + var trivia = triviaList.syntaxTriviaAt(i); + + if (trivia.isComment()) { + var hasTrailingNewLine = ((i + 1) < n) && triviaList.syntaxTriviaAt(i + 1).isNewLine(); + result.push(this.convertComment(trivia, commentStartPosition, hasTrailingNewLine)); + } + + commentStartPosition += trivia.fullWidth(); + } + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.mergeComments = function (comments1, comments2) { + if (comments1 === null) { + return comments2; + } + + if (comments2 === null) { + return comments1; + } + + return comments1.concat(comments2); + }; + + SyntaxTreeToAstVisitor.prototype.convertTokenLeadingComments = function (token, commentStartPosition) { + if (token === null) { + return null; + } + + var preComments = token.hasLeadingComment() ? this.convertComments(token.leadingTrivia(), commentStartPosition) : null; + + var previousTokenTrailingComments = this.previousTokenTrailingComments; + this.previousTokenTrailingComments = null; + + return this.mergeComments(previousTokenTrailingComments, preComments); + }; + + SyntaxTreeToAstVisitor.prototype.convertTokenTrailingComments = function (token, commentStartPosition) { + if (token === null || !token.hasTrailingComment() || token.hasTrailingNewLine()) { + return null; + } + + return this.convertComments(token.trailingTrivia(), commentStartPosition); + }; + + SyntaxTreeToAstVisitor.prototype.convertNodeTrailingComments = function (node, lastToken, nodeStart) { + if (lastToken === null || !lastToken.hasTrailingComment() || lastToken.hasTrailingNewLine()) { + return null; + } + + return this.convertComments(lastToken.trailingTrivia(), nodeStart + node.fullWidth() - lastToken.trailingTriviaWidth()); + }; + + SyntaxTreeToAstVisitor.prototype.visitToken = function (token) { + var fullStart = this.position; + + var result; + if (token.kind() === 35 /* ThisKeyword */) { + result = new TypeScript.ThisExpression(); + } else if (token.kind() === 50 /* SuperKeyword */) { + result = new TypeScript.SuperExpression(); + } else if (token.kind() === 37 /* TrueKeyword */) { + result = new TypeScript.LiteralExpression(3 /* TrueLiteral */); + } else if (token.kind() === 24 /* FalseKeyword */) { + result = new TypeScript.LiteralExpression(4 /* FalseLiteral */); + } else if (token.kind() === 32 /* NullKeyword */) { + result = new TypeScript.LiteralExpression(8 /* NullLiteral */); + } else if (token.kind() === 14 /* StringLiteral */) { + result = new TypeScript.StringLiteral(token.text(), token.valueText()); + } else if (token.kind() === 12 /* RegularExpressionLiteral */) { + result = new TypeScript.RegexLiteral(token.text()); + } else if (token.kind() === 13 /* NumericLiteral */) { + var preComments = this.convertTokenLeadingComments(token, fullStart); + + var value = token.text().indexOf(".") > 0 ? parseFloat(token.text()) : parseInt(token.text()); + result = new TypeScript.NumberLiteral(value, token.text()); + + result.setPreComments(preComments); + } else { + result = this.identifierFromToken(token, false); + } + + this.movePast(token); + + var start = fullStart + token.leadingTriviaWidth(); + this.setSpanExplicit(result, start, start + token.width()); + return result; + }; + + SyntaxTreeToAstVisitor.prototype.getLeadingComments = function (node) { + var firstToken = node.firstToken(); + var result = []; + + if (firstToken.hasLeadingComment()) { + var leadingTrivia = firstToken.leadingTrivia(); + + for (var i = 0, n = leadingTrivia.count(); i < n; i++) { + var trivia = leadingTrivia.syntaxTriviaAt(i); + + if (trivia.isComment()) { + result.push(trivia); + } + } + } + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.hasTopLevelImportOrExport = function (node) { + var firstToken; + + for (var i = 0, n = node.moduleElements.childCount(); i < n; i++) { + var moduleElement = node.moduleElements.childAt(i); + + firstToken = moduleElement.firstToken(); + if (firstToken !== null && firstToken.kind() === 47 /* ExportKeyword */) { + return true; + } + + if (moduleElement.kind() === 133 /* ImportDeclaration */) { + var importDecl = moduleElement; + if (importDecl.moduleReference.kind() === 245 /* ExternalModuleReference */) { + return true; + } + } + } + + var leadingComments = this.getLeadingComments(node); + for (var i = 0, n = leadingComments.length; i < n; i++) { + var trivia = leadingComments[i]; + + if (TypeScript.getImplicitImport(trivia.fullText())) { + return true; + } + } + + return false; + }; + + SyntaxTreeToAstVisitor.prototype.getAmdDependency = function (comment) { + var amdDependencyRegEx = /^\/\/\/\s*= 0; i--) { + var innerName = names[i]; + + var result = new TypeScript.ModuleDeclaration(innerName, members, closeBraceSpan); + this.setSpan(result, start, node); + + result.setPreComments(preComments); + result.setPostComments(postComments); + + preComments = null; + postComments = null; + + if (i || TypeScript.SyntaxUtilities.containsToken(node.modifiers, 47 /* ExportKeyword */)) { + result.setModuleFlags(result.getModuleFlags() | 1 /* Exported */); + } + + members = new TypeScript.ASTList([result]); + } + + this.completeModuleDeclaration(node, result); + + this.setSpan(result, start, node); + return result; + }; + + SyntaxTreeToAstVisitor.prototype.completeModuleDeclaration = function (node, result) { + if (TypeScript.SyntaxUtilities.containsToken(node.modifiers, 63 /* DeclareKeyword */)) { + result.setModuleFlags(result.getModuleFlags() | 8 /* Ambient */); + } + }; + + SyntaxTreeToAstVisitor.prototype.hasDotDotDotParameter = function (parameters) { + for (var i = 0, n = parameters.nonSeparatorCount(); i < n; i++) { + if ((parameters.nonSeparatorAt(i)).dotDotDotToken) { + return true; + } + } + + return false; + }; + + SyntaxTreeToAstVisitor.prototype.visitFunctionDeclaration = function (node) { + var start = this.position; + + this.moveTo(node, node.identifier); + var name = this.identifierFromToken(node.identifier, false); + + this.movePast(node.identifier); + + var typeParameters = node.callSignature.typeParameterList === null ? null : node.callSignature.typeParameterList.accept(this); + var parameters = node.callSignature.parameterList.accept(this); + + var returnType = node.callSignature.typeAnnotation ? node.callSignature.typeAnnotation.accept(this) : null; + + var block = node.block ? node.block.accept(this) : null; + + this.movePast(node.semicolonToken); + + var result = new TypeScript.FunctionDeclaration(name, block, false, typeParameters, parameters, returnType, this.hasDotDotDotParameter(node.callSignature.parameterList.parameters)); + this.setCommentsAndSpan(result, start, node); + + if (node.semicolonToken) { + result.setFunctionFlags(result.getFunctionFlags() | 128 /* Signature */); + } + + this.completeFunctionDeclaration(node, result); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.completeFunctionDeclaration = function (node, result) { + var flags = result.getFunctionFlags(); + if (TypeScript.SyntaxUtilities.containsToken(node.modifiers, 47 /* ExportKeyword */)) { + flags = flags | 1 /* Exported */; + } + + if (TypeScript.SyntaxUtilities.containsToken(node.modifiers, 63 /* DeclareKeyword */)) { + flags = flags | 8 /* Ambient */; + } + + result.setFunctionFlags(flags); + }; + + SyntaxTreeToAstVisitor.prototype.visitEnumDeclaration = function (node) { + var start = this.position; + + this.moveTo(node, node.identifier); + var name = this.identifierFromToken(node.identifier, false); + this.movePast(node.identifier); + + this.movePast(node.openBraceToken); + var array = new Array(node.enumElements.nonSeparatorCount()); + + var declarators = []; + + for (var i = 0, n = node.enumElements.childCount(); i < n; i++) { + if (i % 2 === 1) { + this.movePast(node.enumElements.childAt(i)); + } else { + var enumElement = node.enumElements.childAt(i); + var enumElementFullStart = this.position; + var memberStart = this.position + enumElement.leadingTriviaWidth(); + + var memberName = this.identifierFromToken(enumElement.propertyName, false); + this.movePast(enumElement.propertyName); + + var init = enumElement.equalsValueClause !== null ? enumElement.equalsValueClause.accept(this) : null; + + var declarator = new TypeScript.VariableDeclarator(memberName, new TypeScript.TypeReference(this.createRef(name.actualText, -1), 0), init); + declarator.constantValue = this.determineConstantValue(enumElement.equalsValueClause, declarators); + + declarator.setVarFlags(declarator.getVarFlags() | 256 /* Property */); + this.setSpanExplicit(declarator, memberStart, this.position); + declarator.setPreComments(this.convertTokenLeadingComments(enumElement.firstToken(), enumElementFullStart)); + declarator.setPostComments(this.convertNodeTrailingComments(enumElement, enumElement.lastToken(), enumElementFullStart)); + + declarators.push(declarator); + + var declaration = new TypeScript.VariableDeclaration(new TypeScript.ASTList([declarator])); + this.setSpanExplicit(declaration, memberStart, this.position); + + var statement = new TypeScript.VariableStatement(declaration); + statement.setFlags(16 /* EnumElement */); + this.setSpanExplicit(statement, memberStart, this.position); + + array[i / 2] = statement; + + declarator.setVarFlags(declarator.getVarFlags() | 1 /* Exported */); + } + } + + var members = new TypeScript.ASTList(array); + + var closeBracePosition = this.position; + this.movePast(node.closeBraceToken); + var closeBraceSpan = new TypeScript.ASTSpan(); + this.setSpan(closeBraceSpan, closeBracePosition, node.closeBraceToken); + + var result = new TypeScript.ModuleDeclaration(name, members, closeBraceSpan); + this.setCommentsAndSpan(result, start, node); + + var flags = result.getModuleFlags() | 128 /* IsEnum */; + + if (TypeScript.SyntaxUtilities.containsToken(node.modifiers, 47 /* ExportKeyword */)) { + flags = flags | 1 /* Exported */; + } + + result.setModuleFlags(flags); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.determineConstantValue = function (equalsValue, declarators) { + var value = equalsValue === null ? null : equalsValue.value; + if (value === null) { + if (declarators.length === 0) { + return 0; + } else { + var lastConstantValue = TypeScript.ArrayUtilities.last(declarators).constantValue; + return lastConstantValue !== null ? lastConstantValue + 1 : null; + } + } else { + return this.computeConstantValue(value, declarators); + } + }; + + SyntaxTreeToAstVisitor.prototype.computeConstantValue = function (expression, declarators) { + if (TypeScript.Syntax.isIntegerLiteral(expression)) { + var token; + switch (expression.kind()) { + case 163 /* PlusExpression */: + case 164 /* NegateExpression */: + token = (expression).operand; + break; + default: + token = expression; + } + + var value = token.value(); + return value && expression.kind() === 164 /* NegateExpression */ ? -value : value; + } else if (this.compilationSettings.propagateEnumConstants) { + switch (expression.kind()) { + case 11 /* IdentifierName */: + var variableDeclarator = TypeScript.ArrayUtilities.firstOrDefault(declarators, function (d) { + return d.id.text() === (expression).valueText(); + }); + return variableDeclarator ? variableDeclarator.constantValue : null; + + case 201 /* LeftShiftExpression */: + var binaryExpression = expression; + return this.computeConstantValue(binaryExpression.left, declarators) << this.computeConstantValue(binaryExpression.right, declarators); + } + + return null; + } else { + return null; + } + }; + + SyntaxTreeToAstVisitor.prototype.visitEnumElement = function (node) { + throw TypeScript.Errors.invalidOperation(); + }; + + SyntaxTreeToAstVisitor.prototype.visitImportDeclaration = function (node) { + var start = this.position; + + this.moveTo(node, node.identifier); + var name = this.identifierFromToken(node.identifier, false); + this.movePast(node.identifier); + this.movePast(node.equalsToken); + var alias = node.moduleReference.accept(this); + this.movePast(node.semicolonToken); + + var result = new TypeScript.ImportDeclaration(name, alias); + this.setCommentsAndSpan(result, start, node); + + var flags = result.getVarFlags(); + if (TypeScript.SyntaxUtilities.containsToken(node.modifiers, 47 /* ExportKeyword */)) { + flags = flags | 1 /* Exported */; + } + result.setVarFlags(flags); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitExportAssignment = function (node) { + var start = this.position; + + this.moveTo(node, node.identifier); + var name = this.identifierFromToken(node.identifier, false); + this.movePast(node.identifier); + this.movePast(node.semicolonToken); + + var result = new TypeScript.ExportAssignment(name); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitVariableStatement = function (node) { + var start = this.position; + + var preComments = null; + if (node.modifiers.childCount() > 0) { + preComments = this.convertTokenLeadingComments(node.modifiers.firstToken(), start); + } + + this.moveTo(node, node.variableDeclaration); + + var declaration = node.variableDeclaration.accept(this); + this.movePast(node.semicolonToken); + + for (var i = 0, n = declaration.declarators.members.length; i < n; i++) { + var varDecl = declaration.declarators.members[i]; + + if (i === 0) { + varDecl.setPreComments(this.mergeComments(preComments, varDecl.preComments())); + } + + var flags = varDecl.getVarFlags(); + if (TypeScript.SyntaxUtilities.containsToken(node.modifiers, 47 /* ExportKeyword */)) { + flags = flags | 1 /* Exported */; + } + + if (TypeScript.SyntaxUtilities.containsToken(node.modifiers, 63 /* DeclareKeyword */)) { + flags = flags | 8 /* Ambient */; + } + + varDecl.setVarFlags(flags); + } + + var result = new TypeScript.VariableStatement(declaration); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitVariableDeclaration = function (node) { + var start = this.position; + + var firstToken = node.firstToken(); + var preComments = this.convertTokenLeadingComments(firstToken, start); + var postComments = this.convertNodeTrailingComments(node, node.lastToken(), start); + + this.moveTo(node, node.variableDeclarators); + var variableDecls = this.visitSeparatedSyntaxList(node.variableDeclarators); + + for (var i = 0; i < variableDecls.members.length; i++) { + if (i === 0) { + variableDecls.members[i].setPreComments(preComments); + variableDecls.members[i].setPostComments(postComments); + } + } + + var result = new TypeScript.VariableDeclaration(variableDecls); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitVariableDeclarator = function (node) { + var start = this.position; + var name = this.identifierFromToken(node.identifier, false); + this.movePast(node.identifier); + var typeExpr = node.typeAnnotation ? node.typeAnnotation.accept(this) : null; + var init = node.equalsValueClause ? node.equalsValueClause.accept(this) : null; + + var result = new TypeScript.VariableDeclarator(name, typeExpr, init); + this.setSpan(result, start, node); + + if (init && init.nodeType() === 13 /* FunctionDeclaration */) { + var funcDecl = init; + funcDecl.hint = name.actualText; + } + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitEqualsValueClause = function (node) { + var afterEqualsComments = this.convertTokenTrailingComments(node.equalsToken, this.position + node.equalsToken.leadingTriviaWidth() + node.equalsToken.width()); + + this.movePast(node.equalsToken); + var result = node.value.accept(this); + result.setPreComments(this.mergeComments(afterEqualsComments, result.preComments())); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.getUnaryExpressionNodeType = function (kind) { + switch (kind) { + case 163 /* PlusExpression */: + return 27 /* PlusExpression */; + case 164 /* NegateExpression */: + return 28 /* NegateExpression */; + case 165 /* BitwiseNotExpression */: + return 73 /* BitwiseNotExpression */; + case 166 /* LogicalNotExpression */: + return 74 /* LogicalNotExpression */; + case 167 /* PreIncrementExpression */: + return 75 /* PreIncrementExpression */; + case 168 /* PreDecrementExpression */: + return 76 /* PreDecrementExpression */; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + SyntaxTreeToAstVisitor.prototype.visitPrefixUnaryExpression = function (node) { + var start = this.position; + + this.movePast(node.operatorToken); + var operand = node.operand.accept(this); + + var result = new TypeScript.UnaryExpression(this.getUnaryExpressionNodeType(node.kind()), operand, null); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.isOnSingleLine = function (start, end) { + return this.lineMap.getLineNumberFromPosition(start) === this.lineMap.getLineNumberFromPosition(end); + }; + + SyntaxTreeToAstVisitor.prototype.visitArrayLiteralExpression = function (node) { + var start = this.position; + var openStart = this.position + node.openBracketToken.leadingTriviaWidth(); + this.movePast(node.openBracketToken); + + var expressions = this.visitSeparatedSyntaxList(node.expressions); + + var closeStart = this.position + node.closeBracketToken.leadingTriviaWidth(); + this.movePast(node.closeBracketToken); + + var result = new TypeScript.UnaryExpression(22 /* ArrayLiteralExpression */, expressions, null); + this.setSpan(result, start, node); + + if (this.isOnSingleLine(openStart, closeStart)) { + result.setFlags(result.getFlags() | 2 /* SingleLine */); + } + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitOmittedExpression = function (node) { + var start = this.position; + + var result = new TypeScript.OmittedExpression(); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitParenthesizedExpression = function (node) { + var start = this.position; + + this.movePast(node.openParenToken); + var expr = node.expression.accept(this); + this.movePast(node.closeParenToken); + + var result = new TypeScript.ParenthesizedExpression(expr); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.getArrowFunctionStatements = function (body) { + if (body.kind() === 145 /* Block */) { + return body.accept(this); + } else { + var expression = body.accept(this); + var returnStatement = new TypeScript.ReturnStatement(expression); + + var preComments = expression.preComments(); + if (preComments) { + (body)._ast = undefined; + returnStatement.setPreComments(preComments); + expression.setPreComments(null); + } + + var statements = new TypeScript.ASTList([returnStatement]); + + var block = new TypeScript.Block(statements, statements.members[0]); + return block; + } + }; + + SyntaxTreeToAstVisitor.prototype.visitSimpleArrowFunctionExpression = function (node) { + var start = this.position; + + var identifier = this.identifierFromToken(node.identifier, false); + this.movePast(node.identifier); + this.movePast(node.equalsGreaterThanToken); + + var parameter = new TypeScript.Parameter(identifier, null, null, false); + this.setSpanExplicit(parameter, identifier.minChar, identifier.limChar); + + var parameters = new TypeScript.ASTList([parameter]); + + var statements = this.getArrowFunctionStatements(node.body); + + var result = new TypeScript.FunctionDeclaration(null, statements, false, null, parameters, null, false); + this.setSpan(result, start, node); + + result.setFunctionFlags(result.getFunctionFlags() | 8192 /* IsFunctionExpression */ | 2048 /* IsFatArrowFunction */); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitParenthesizedArrowFunctionExpression = function (node) { + var start = this.position; + + var typeParameters = node.callSignature.typeParameterList === null ? null : node.callSignature.typeParameterList.accept(this); + var parameters = node.callSignature.parameterList.accept(this); + var returnType = node.callSignature.typeAnnotation ? node.callSignature.typeAnnotation.accept(this) : null; + this.movePast(node.equalsGreaterThanToken); + + var block = this.getArrowFunctionStatements(node.body); + + var result = new TypeScript.FunctionDeclaration(null, block, false, typeParameters, parameters, returnType, this.hasDotDotDotParameter(node.callSignature.parameterList.parameters)); + this.setCommentsAndSpan(result, start, node); + + result.setFunctionFlags(result.getFunctionFlags() | 8192 /* IsFunctionExpression */ | 2048 /* IsFatArrowFunction */); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitType = function (type) { + var result; + if (type.isToken()) { + var start = this.position; + result = new TypeScript.TypeReference(type.accept(this), 0); + this.setSpan(result, start, type); + } else { + result = type.accept(this); + } + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitTypeQuery = function (node) { + var start = this.position; + this.movePast(node.typeOfKeyword); + var name = node.name.accept(this); + + var typeQuery = new TypeScript.TypeQuery(name); + this.setSpan(typeQuery, start, node); + + var result = new TypeScript.TypeReference(typeQuery, 0); + this.copySpan(typeQuery, result); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitQualifiedName = function (node) { + var start = this.position; + var left = this.visitType(node.left).term; + this.movePast(node.dotToken); + var right = this.identifierFromToken(node.right, false); + this.movePast(node.right); + + var term = new TypeScript.BinaryExpression(33 /* MemberAccessExpression */, left, right); + this.setSpan(term, start, node); + + var result = new TypeScript.TypeReference(term, 0); + this.copySpan(term, result); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitTypeArgumentList = function (node) { + var array = new Array(node.typeArguments.nonSeparatorCount()); + + this.movePast(node.lessThanToken); + + var start = this.position; + + for (var i = 0, n = node.typeArguments.childCount(); i < n; i++) { + if (i % 2 === 1) { + this.movePast(node.typeArguments.childAt(i)); + } else { + array[i / 2] = this.visitType(node.typeArguments.childAt(i)); + } + } + this.movePast(node.greaterThanToken); + + var result = new TypeScript.ASTList(array); + this.setSpan(result, start, node.typeArguments); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitConstructorType = function (node) { + var start = this.position; + + this.movePast(node.newKeyword); + var typeParameters = node.typeParameterList === null ? null : node.typeParameterList.accept(this); + var parameters = node.parameterList.accept(this); + this.movePast(node.equalsGreaterThanToken); + var returnType = node.type ? this.visitType(node.type) : null; + + var funcDecl = new TypeScript.FunctionDeclaration(null, null, false, typeParameters, parameters, returnType, this.hasDotDotDotParameter(node.parameterList.parameters)); + this.setSpan(funcDecl, start, node); + + funcDecl.setFunctionFlags(funcDecl.getFunctionFlags() | 128 /* Signature */ | 1024 /* ConstructMember */); + + funcDecl.setFlags(funcDecl.getFlags() | 8 /* TypeReference */); + funcDecl.hint = "_construct"; + funcDecl.classDecl = null; + + var result = new TypeScript.TypeReference(funcDecl, 0); + this.copySpan(funcDecl, result); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitFunctionType = function (node) { + var start = this.position; + var typeParameters = node.typeParameterList === null ? null : node.typeParameterList.accept(this); + var parameters = node.parameterList.accept(this); + this.movePast(node.equalsGreaterThanToken); + var returnType = node.type ? this.visitType(node.type) : null; + + var funcDecl = new TypeScript.FunctionDeclaration(null, null, false, typeParameters, parameters, returnType, this.hasDotDotDotParameter(node.parameterList.parameters)); + this.setSpan(funcDecl, start, node); + + funcDecl.setFlags(funcDecl.getFunctionFlags() | 128 /* Signature */); + funcDecl.setFlags(funcDecl.getFlags() | 8 /* TypeReference */); + + var result = new TypeScript.TypeReference(funcDecl, 0); + this.copySpan(funcDecl, result); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitObjectType = function (node) { + var start = this.position; + + this.movePast(node.openBraceToken); + var typeMembers = this.visitSeparatedSyntaxList(node.typeMembers); + this.movePast(node.closeBraceToken); + + var interfaceDecl = new TypeScript.InterfaceDeclaration(new TypeScript.Identifier("__anonymous", "__anonymous"), null, typeMembers, null, null, true); + this.setSpan(interfaceDecl, start, node); + + interfaceDecl.setFlags(interfaceDecl.getFlags() | 8 /* TypeReference */); + + var result = new TypeScript.TypeReference(interfaceDecl, 0); + this.copySpan(interfaceDecl, result); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitArrayType = function (node) { + var start = this.position; + + var result; + var underlying = this.visitType(node.type); + this.movePast(node.openBracketToken); + this.movePast(node.closeBracketToken); + + if (underlying.nodeType() === 11 /* TypeRef */) { + result = underlying; + result.arrayCount++; + } else { + result = new TypeScript.TypeReference(underlying, 1); + } + + result.setFlags(result.getFlags() | 8 /* TypeReference */); + + this.setSpan(result, start, node); + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitGenericType = function (node) { + var start = this.position; + + var underlying = this.visitType(node.name).term; + var typeArguments = node.typeArgumentList.accept(this); + + var genericType = new TypeScript.GenericType(underlying, typeArguments); + this.setSpan(genericType, start, node); + + genericType.setFlags(genericType.getFlags() | 8 /* TypeReference */); + + var result = new TypeScript.TypeReference(genericType, 0); + this.copySpan(genericType, result); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitTypeAnnotation = function (node) { + this.movePast(node.colonToken); + return this.visitType(node.type); + }; + + SyntaxTreeToAstVisitor.prototype.visitBlock = function (node) { + var start = this.position; + + this.movePast(node.openBraceToken); + var statements = this.visitSyntaxList(node.statements); + var closeBracePosition = this.position; + + var closeBraceLeadingComments = this.convertTokenLeadingComments(node.closeBraceToken, this.position); + this.movePast(node.closeBraceToken); + var closeBraceSpan = new TypeScript.ASTSpan(); + this.setSpan(closeBraceSpan, closeBracePosition, node.closeBraceToken); + + var result = new TypeScript.Block(statements, closeBraceSpan); + this.setSpan(result, start, node); + + result.closeBraceLeadingComments = closeBraceLeadingComments; + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitParameter = function (node) { + var start = this.position; + + this.moveTo(node, node.identifier); + var identifier = this.identifierFromToken(node.identifier, !!node.questionToken); + this.movePast(node.identifier); + this.movePast(node.questionToken); + var typeExpr = node.typeAnnotation ? node.typeAnnotation.accept(this) : null; + var init = node.equalsValueClause ? node.equalsValueClause.accept(this) : null; + + var result = new TypeScript.Parameter(identifier, typeExpr, init, !!node.questionToken); + this.setCommentsAndSpan(result, start, node); + + if (node.publicOrPrivateKeyword) { + if (node.publicOrPrivateKeyword.kind() === 57 /* PublicKeyword */) { + result.setVarFlags(result.getVarFlags() | 256 /* Property */ | 4 /* Public */); + } else { + result.setVarFlags(result.getVarFlags() | 256 /* Property */ | 2 /* Private */); + } + } + + if (node.equalsValueClause || node.dotDotDotToken) { + result.setFlags(result.getFlags() | 4 /* OptionalName */); + } + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitMemberAccessExpression = function (node) { + var start = this.position; + + var expression = node.expression.accept(this); + this.movePast(node.dotToken); + var name = this.identifierFromToken(node.name, false); + this.movePast(node.name); + + var result = new TypeScript.BinaryExpression(33 /* MemberAccessExpression */, expression, name); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitPostfixUnaryExpression = function (node) { + var start = this.position; + + var operand = node.operand.accept(this); + this.movePast(node.operatorToken); + + var result = new TypeScript.UnaryExpression(node.kind() === 209 /* PostIncrementExpression */ ? 77 /* PostIncrementExpression */ : 78 /* PostDecrementExpression */, operand, null); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitElementAccessExpression = function (node) { + var start = this.position; + + var expression = node.expression.accept(this); + this.movePast(node.openBracketToken); + var argumentExpression = node.argumentExpression.accept(this); + this.movePast(node.closeBracketToken); + + var result = new TypeScript.BinaryExpression(36 /* ElementAccessExpression */, expression, argumentExpression); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.convertArgumentListArguments = function (node) { + if (node === null) { + return null; + } + + var start = this.position; + + this.movePast(node.openParenToken); + + var result = this.visitSeparatedSyntaxList(node.arguments); + + if (node.arguments.fullWidth() === 0 && node.closeParenToken.fullWidth() === 0) { + var openParenTokenEnd = start + node.openParenToken.leadingTriviaWidth() + node.openParenToken.width(); + this.setSpanExplicit(result, openParenTokenEnd, openParenTokenEnd + node.openParenToken.trailingTriviaWidth()); + } + + var closeParenPos = this.position; + this.movePast(node.closeParenToken); + var closeParenSpan = new TypeScript.ASTSpan(); + this.setSpan(closeParenSpan, closeParenPos, node.closeParenToken); + + return { + argumentList: result, + closeParenSpan: closeParenSpan + }; + }; + + SyntaxTreeToAstVisitor.prototype.visitInvocationExpression = function (node) { + var start = this.position; + + var expression = node.expression.accept(this); + var typeArguments = node.argumentList.typeArgumentList !== null ? node.argumentList.typeArgumentList.accept(this) : null; + var argumentList = this.convertArgumentListArguments(node.argumentList); + + var result = new TypeScript.InvocationExpression(expression, typeArguments, argumentList ? argumentList.argumentList : null, argumentList ? argumentList.closeParenSpan : null); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitArgumentList = function (node) { + throw TypeScript.Errors.invalidOperation(); + }; + + SyntaxTreeToAstVisitor.prototype.getBinaryExpressionNodeType = function (node) { + switch (node.kind()) { + case 172 /* CommaExpression */: + return 26 /* CommaExpression */; + case 173 /* AssignmentExpression */: + return 39 /* AssignmentExpression */; + case 174 /* AddAssignmentExpression */: + return 40 /* AddAssignmentExpression */; + case 175 /* SubtractAssignmentExpression */: + return 41 /* SubtractAssignmentExpression */; + case 176 /* MultiplyAssignmentExpression */: + return 43 /* MultiplyAssignmentExpression */; + case 177 /* DivideAssignmentExpression */: + return 42 /* DivideAssignmentExpression */; + case 178 /* ModuloAssignmentExpression */: + return 44 /* ModuloAssignmentExpression */; + case 179 /* AndAssignmentExpression */: + return 45 /* AndAssignmentExpression */; + case 180 /* ExclusiveOrAssignmentExpression */: + return 46 /* ExclusiveOrAssignmentExpression */; + case 181 /* OrAssignmentExpression */: + return 47 /* OrAssignmentExpression */; + case 182 /* LeftShiftAssignmentExpression */: + return 48 /* LeftShiftAssignmentExpression */; + case 183 /* SignedRightShiftAssignmentExpression */: + return 49 /* SignedRightShiftAssignmentExpression */; + case 184 /* UnsignedRightShiftAssignmentExpression */: + return 50 /* UnsignedRightShiftAssignmentExpression */; + case 186 /* LogicalOrExpression */: + return 52 /* LogicalOrExpression */; + case 187 /* LogicalAndExpression */: + return 53 /* LogicalAndExpression */; + case 188 /* BitwiseOrExpression */: + return 54 /* BitwiseOrExpression */; + case 189 /* BitwiseExclusiveOrExpression */: + return 55 /* BitwiseExclusiveOrExpression */; + case 190 /* BitwiseAndExpression */: + return 56 /* BitwiseAndExpression */; + case 191 /* EqualsWithTypeConversionExpression */: + return 57 /* EqualsWithTypeConversionExpression */; + case 192 /* NotEqualsWithTypeConversionExpression */: + return 58 /* NotEqualsWithTypeConversionExpression */; + case 193 /* EqualsExpression */: + return 59 /* EqualsExpression */; + case 194 /* NotEqualsExpression */: + return 60 /* NotEqualsExpression */; + case 195 /* LessThanExpression */: + return 61 /* LessThanExpression */; + case 196 /* GreaterThanExpression */: + return 63 /* GreaterThanExpression */; + case 197 /* LessThanOrEqualExpression */: + return 62 /* LessThanOrEqualExpression */; + case 198 /* GreaterThanOrEqualExpression */: + return 64 /* GreaterThanOrEqualExpression */; + case 199 /* InstanceOfExpression */: + return 34 /* InstanceOfExpression */; + case 200 /* InExpression */: + return 32 /* InExpression */; + case 201 /* LeftShiftExpression */: + return 70 /* LeftShiftExpression */; + case 202 /* SignedRightShiftExpression */: + return 71 /* SignedRightShiftExpression */; + case 203 /* UnsignedRightShiftExpression */: + return 72 /* UnsignedRightShiftExpression */; + case 204 /* MultiplyExpression */: + return 67 /* MultiplyExpression */; + case 205 /* DivideExpression */: + return 68 /* DivideExpression */; + case 206 /* ModuloExpression */: + return 69 /* ModuloExpression */; + case 207 /* AddExpression */: + return 65 /* AddExpression */; + case 208 /* SubtractExpression */: + return 66 /* SubtractExpression */; + } + + throw TypeScript.Errors.invalidOperation(); + }; + + SyntaxTreeToAstVisitor.prototype.visitBinaryExpression = function (node) { + var start = this.position; + + var nodeType = this.getBinaryExpressionNodeType(node); + var left = node.left.accept(this); + this.movePast(node.operatorToken); + var right = node.right.accept(this); + + var result = new TypeScript.BinaryExpression(nodeType, left, right); + this.setSpan(result, start, node); + + if (right.nodeType() === 13 /* FunctionDeclaration */) { + var id = left.nodeType() === 33 /* MemberAccessExpression */ ? (left).operand2 : left; + var idHint = id.nodeType() === 21 /* Name */ ? id.actualText : null; + + var funcDecl = right; + funcDecl.hint = idHint; + } + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitConditionalExpression = function (node) { + var start = this.position; + + var condition = node.condition.accept(this); + this.movePast(node.questionToken); + var whenTrue = node.whenTrue.accept(this); + this.movePast(node.colonToken); + var whenFalse = node.whenFalse.accept(this); + + var result = new TypeScript.ConditionalExpression(condition, whenTrue, whenFalse); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitConstructSignature = function (node) { + var start = this.position; + + this.movePast(node.newKeyword); + var typeParameters = node.callSignature.typeParameterList === null ? null : node.callSignature.typeParameterList.accept(this); + var parameters = node.callSignature.parameterList.accept(this); + var returnType = node.callSignature.typeAnnotation ? node.callSignature.typeAnnotation.accept(this) : null; + + var result = new TypeScript.FunctionDeclaration(null, null, false, typeParameters, parameters, returnType, this.hasDotDotDotParameter(node.callSignature.parameterList.parameters)); + this.setCommentsAndSpan(result, start, node); + + result.hint = "_construct"; + result.setFunctionFlags(result.getFunctionFlags() | 1024 /* ConstructMember */ | 256 /* Method */ | 128 /* Signature */); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitMethodSignature = function (node) { + var start = this.position; + + var name = this.identifierFromToken(node.propertyName, !!node.questionToken); + this.movePast(node.propertyName); + this.movePast(node.questionToken); + + var typeParameters = node.callSignature.typeParameterList ? node.callSignature.typeParameterList.accept(this) : null; + var parameters = node.callSignature.parameterList.accept(this); + var returnType = node.callSignature.typeAnnotation ? node.callSignature.typeAnnotation.accept(this) : null; + + var result = new TypeScript.FunctionDeclaration(name, null, false, typeParameters, parameters, returnType, this.hasDotDotDotParameter(node.callSignature.parameterList.parameters)); + this.setCommentsAndSpan(result, start, node); + + result.setFunctionFlags(result.getFunctionFlags() | 256 /* Method */ | 128 /* Signature */); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitIndexSignature = function (node) { + var start = this.position; + + this.movePast(node.openBracketToken); + + var parameter = node.parameter.accept(this); + + this.movePast(node.closeBracketToken); + var returnType = node.typeAnnotation ? node.typeAnnotation.accept(this) : null; + + var name = new TypeScript.Identifier("__item", "__item"); + this.setSpanExplicit(name, start, start); + + var parameters = new TypeScript.ASTList([parameter]); + + var result = new TypeScript.FunctionDeclaration(name, null, false, null, parameters, returnType, false); + this.setCommentsAndSpan(result, start, node); + + result.setFunctionFlags(result.getFunctionFlags() | 4096 /* IndexerMember */ | 256 /* Method */ | 128 /* Signature */); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitPropertySignature = function (node) { + var start = this.position; + + var name = this.identifierFromToken(node.propertyName, !!node.questionToken); + this.movePast(node.propertyName); + this.movePast(node.questionToken); + var typeExpr = node.typeAnnotation ? node.typeAnnotation.accept(this) : null; + + var result = new TypeScript.VariableDeclarator(name, typeExpr, null); + this.setCommentsAndSpan(result, start, node); + + result.setVarFlags(result.getVarFlags() | 256 /* Property */); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitParameterList = function (node) { + var start = this.position; + + var openParenToken = node.openParenToken; + this.previousTokenTrailingComments = this.convertTokenTrailingComments(openParenToken, start + openParenToken.leadingTriviaWidth() + openParenToken.width()); + + this.movePast(node.openParenToken); + var result = this.visitSeparatedSyntaxList(node.parameters); + this.movePast(node.closeParenToken); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitCallSignature = function (node) { + var start = this.position; + + var typeParameters = node.typeParameterList === null ? null : node.typeParameterList.accept(this); + var parameters = node.parameterList.accept(this); + var returnType = node.typeAnnotation ? node.typeAnnotation.accept(this) : null; + + var result = new TypeScript.FunctionDeclaration(null, null, false, typeParameters, parameters, returnType, this.hasDotDotDotParameter(node.parameterList.parameters)); + this.setCommentsAndSpan(result, start, node); + + result.hint = "_call"; + result.setFunctionFlags(result.getFunctionFlags() | 512 /* CallMember */ | 256 /* Method */ | 128 /* Signature */); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitTypeParameterList = function (node) { + this.movePast(node.lessThanToken); + var result = this.visitSeparatedSyntaxList(node.typeParameters); + this.movePast(node.greaterThanToken); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitTypeParameter = function (node) { + var start = this.position; + + var identifier = this.identifierFromToken(node.identifier, false); + this.movePast(node.identifier); + var constraint = node.constraint ? node.constraint.accept(this) : null; + + var result = new TypeScript.TypeParameter(identifier, constraint); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitConstraint = function (node) { + this.movePast(node.extendsKeyword); + return this.visitType(node.type); + }; + + SyntaxTreeToAstVisitor.prototype.visitIfStatement = function (node) { + var start = this.position; + + this.moveTo(node, node.condition); + var condition = node.condition.accept(this); + this.movePast(node.closeParenToken); + var thenBod = node.statement.accept(this); + var elseBod = node.elseClause ? node.elseClause.accept(this) : null; + + var result = new TypeScript.IfStatement(condition, thenBod, elseBod); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitElseClause = function (node) { + this.movePast(node.elseKeyword); + return node.statement.accept(this); + }; + + SyntaxTreeToAstVisitor.prototype.visitExpressionStatement = function (node) { + var start = this.position; + + var expression = node.expression.accept(this); + this.movePast(node.semicolonToken); + + var result = new TypeScript.ExpressionStatement(expression); + this.setCommentsAndSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitConstructorDeclaration = function (node) { + var start = this.position; + + this.moveTo(node, node.parameterList); + var parameters = node.parameterList.accept(this); + + var block = node.block ? node.block.accept(this) : null; + + this.movePast(node.semicolonToken); + + var result = new TypeScript.FunctionDeclaration(null, block, true, null, parameters, null, this.hasDotDotDotParameter(node.parameterList.parameters)); + this.setCommentsAndSpan(result, start, node); + + if (node.semicolonToken) { + result.setFunctionFlags(result.getFunctionFlags() | 128 /* Signature */); + } + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitMemberFunctionDeclaration = function (node) { + var start = this.position; + + this.moveTo(node, node.propertyName); + var name = this.identifierFromToken(node.propertyName, false); + + this.movePast(node.propertyName); + + var typeParameters = node.callSignature.typeParameterList === null ? null : node.callSignature.typeParameterList.accept(this); + var parameters = node.callSignature.parameterList.accept(this); + var returnType = node.callSignature.typeAnnotation ? node.callSignature.typeAnnotation.accept(this) : null; + + var block = node.block ? node.block.accept(this) : null; + this.movePast(node.semicolonToken); + + var result = new TypeScript.FunctionDeclaration(name, block, false, typeParameters, parameters, returnType, this.hasDotDotDotParameter(node.callSignature.parameterList.parameters)); + this.setCommentsAndSpan(result, start, node); + + var flags = result.getFunctionFlags(); + if (node.semicolonToken) { + flags = flags | 128 /* Signature */; + } + + if (TypeScript.SyntaxUtilities.containsToken(node.modifiers, 55 /* PrivateKeyword */)) { + flags = flags | 2 /* Private */; + } else { + flags = flags | 4 /* Public */; + } + + if (TypeScript.SyntaxUtilities.containsToken(node.modifiers, 58 /* StaticKeyword */)) { + flags = flags | 16 /* Static */; + } + + flags = flags | 256 /* Method */; + result.setFunctionFlags(flags); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitMemberAccessorDeclaration = function (node, typeAnnotation) { + var start = this.position; + + this.moveTo(node, node.propertyName); + var name = this.identifierFromToken(node.propertyName, false); + this.movePast(node.propertyName); + var parameters = node.parameterList.accept(this); + var returnType = typeAnnotation ? typeAnnotation.accept(this) : null; + + var block = node.block ? node.block.accept(this) : null; + var result = new TypeScript.FunctionDeclaration(name, block, false, null, parameters, returnType, this.hasDotDotDotParameter(node.parameterList.parameters)); + this.setCommentsAndSpan(result, start, node); + + if (TypeScript.SyntaxUtilities.containsToken(node.modifiers, 55 /* PrivateKeyword */)) { + result.setFunctionFlags(result.getFunctionFlags() | 2 /* Private */); + } else { + result.setFunctionFlags(result.getFunctionFlags() | 4 /* Public */); + } + + if (TypeScript.SyntaxUtilities.containsToken(node.modifiers, 58 /* StaticKeyword */)) { + result.setFunctionFlags(result.getFunctionFlags() | 16 /* Static */); + } + + result.setFunctionFlags(result.getFunctionFlags() | 256 /* Method */); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitGetMemberAccessorDeclaration = function (node) { + var result = this.visitMemberAccessorDeclaration(node, node.typeAnnotation); + + result.setFunctionFlags(result.getFunctionFlags() | 32 /* GetAccessor */); + result.hint = "get" + result.name.actualText; + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitSetMemberAccessorDeclaration = function (node) { + var result = this.visitMemberAccessorDeclaration(node, null); + + result.setFunctionFlags(result.getFunctionFlags() | 64 /* SetAccessor */); + result.hint = "set" + result.name.actualText; + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitMemberVariableDeclaration = function (node) { + var start = this.position; + + this.moveTo(node, node.variableDeclarator); + this.moveTo(node.variableDeclarator, node.variableDeclarator.identifier); + + var name = this.identifierFromToken(node.variableDeclarator.identifier, false); + this.movePast(node.variableDeclarator.identifier); + var typeExpr = node.variableDeclarator.typeAnnotation ? node.variableDeclarator.typeAnnotation.accept(this) : null; + var init = node.variableDeclarator.equalsValueClause ? node.variableDeclarator.equalsValueClause.accept(this) : null; + this.movePast(node.semicolonToken); + + var result = new TypeScript.VariableDeclarator(name, typeExpr, init); + this.setCommentsAndSpan(result, start, node); + + if (TypeScript.SyntaxUtilities.containsToken(node.modifiers, 58 /* StaticKeyword */)) { + result.setVarFlags(result.getVarFlags() | 16 /* Static */); + } + + if (TypeScript.SyntaxUtilities.containsToken(node.modifiers, 55 /* PrivateKeyword */)) { + result.setVarFlags(result.getVarFlags() | 2 /* Private */); + } else { + result.setVarFlags(result.getVarFlags() | 4 /* Public */); + } + + result.setVarFlags(result.getVarFlags() | 2048 /* ClassProperty */); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitThrowStatement = function (node) { + var start = this.position; + + this.movePast(node.throwKeyword); + var expression = node.expression.accept(this); + this.movePast(node.semicolonToken); + + var result = new TypeScript.ThrowStatement(expression); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitReturnStatement = function (node) { + var start = this.position; + + this.movePast(node.returnKeyword); + var expression = node.expression ? node.expression.accept(this) : null; + this.movePast(node.semicolonToken); + + var result = new TypeScript.ReturnStatement(expression); + this.setCommentsAndSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitObjectCreationExpression = function (node) { + var start = this.position; + + this.movePast(node.newKeyword); + var expression = node.expression.accept(this); + var typeArgumentList = node.argumentList === null || node.argumentList.typeArgumentList === null ? null : node.argumentList.typeArgumentList.accept(this); + var argumentList = this.convertArgumentListArguments(node.argumentList); + + var result = new TypeScript.ObjectCreationExpression(expression, typeArgumentList, argumentList ? argumentList.argumentList : null, argumentList ? argumentList.closeParenSpan : null); + this.setSpan(result, start, node); + + if (expression.nodeType() === 11 /* TypeRef */) { + var typeRef = expression; + + if (typeRef.arrayCount === 0) { + var term = typeRef.term; + if (term.nodeType() === 33 /* MemberAccessExpression */ || term.nodeType() === 21 /* Name */) { + expression = term; + } + } + } + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitSwitchStatement = function (node) { + var start = this.position; + + this.movePast(node.switchKeyword); + this.movePast(node.openParenToken); + var expression = node.expression.accept(this); + this.movePast(node.closeParenToken); + var closeParenPosition = this.position; + this.movePast(node.openBraceToken); + + var array = new Array(node.switchClauses.childCount()); + var defaultCase = null; + + for (var i = 0, n = node.switchClauses.childCount(); i < n; i++) { + var switchClause = node.switchClauses.childAt(i); + var translated = switchClause.accept(this); + + if (switchClause.kind() === 232 /* DefaultSwitchClause */) { + defaultCase = translated; + } + + array[i] = translated; + } + + var span = new TypeScript.ASTSpan(); + span.minChar = start; + span.limChar = closeParenPosition; + + this.movePast(node.closeBraceToken); + + var result = new TypeScript.SwitchStatement(expression, new TypeScript.ASTList(array), defaultCase, span); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitCaseSwitchClause = function (node) { + var start = this.position; + + this.movePast(node.caseKeyword); + var expression = node.expression.accept(this); + this.movePast(node.colonToken); + var statements = this.visitSyntaxList(node.statements); + + var result = new TypeScript.CaseClause(expression, statements); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitDefaultSwitchClause = function (node) { + var start = this.position; + + this.movePast(node.defaultKeyword); + this.movePast(node.colonToken); + var statements = this.visitSyntaxList(node.statements); + + var result = new TypeScript.CaseClause(null, statements); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitBreakStatement = function (node) { + var start = this.position; + + this.movePast(node.breakKeyword); + this.movePast(node.identifier); + this.movePast(node.semicolonToken); + var identifier = node.identifier ? node.identifier.valueText() : null; + + var result = new TypeScript.Jump(83 /* BreakStatement */, identifier); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitContinueStatement = function (node) { + var start = this.position; + + this.movePast(node.continueKeyword); + this.movePast(node.identifier); + this.movePast(node.semicolonToken); + + var result = new TypeScript.Jump(84 /* ContinueStatement */, node.identifier ? node.identifier.valueText() : null); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitForStatement = function (node) { + var start = this.position; + + this.movePast(node.forKeyword); + this.movePast(node.openParenToken); + var init = node.variableDeclaration ? node.variableDeclaration.accept(this) : node.initializer ? node.initializer.accept(this) : null; + this.movePast(node.firstSemicolonToken); + var cond = node.condition ? node.condition.accept(this) : null; + this.movePast(node.secondSemicolonToken); + var incr = node.incrementor ? node.incrementor.accept(this) : null; + this.movePast(node.closeParenToken); + var body = node.statement.accept(this); + + var result = new TypeScript.ForStatement(init, cond, incr, body); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitForInStatement = function (node) { + var start = this.position; + + this.movePast(node.forKeyword); + this.movePast(node.openParenToken); + var init = node.variableDeclaration ? node.variableDeclaration.accept(this) : node.left.accept(this); + if (node.variableDeclaration) { + var variableDeclaration = init; + for (var i = 0, n = variableDeclaration.declarators.members.length; i < n; i++) { + var boundDecl = variableDeclaration.declarators.members[i]; + boundDecl.setVarFlags(boundDecl.getVarFlags() | 16384 /* ForInVariable */); + } + } + + this.movePast(node.inKeyword); + var expression = node.expression.accept(this); + this.movePast(node.closeParenToken); + var body = node.statement.accept(this); + + var result = new TypeScript.ForInStatement(init, expression, body); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitWhileStatement = function (node) { + var start = this.position; + + this.moveTo(node, node.condition); + var condition = node.condition.accept(this); + this.movePast(node.closeParenToken); + var statement = node.statement.accept(this); + + var result = new TypeScript.WhileStatement(condition, statement); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitWithStatement = function (node) { + var start = this.position; + + this.moveTo(node, node.condition); + var condition = node.condition.accept(this); + this.movePast(node.closeParenToken); + var statement = node.statement.accept(this); + + var result = new TypeScript.WithStatement(condition, statement); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitCastExpression = function (node) { + var start = this.position; + + this.movePast(node.lessThanToken); + var castTerm = this.visitType(node.type); + this.movePast(node.greaterThanToken); + var expression = node.expression.accept(this); + + var result = new TypeScript.UnaryExpression(79 /* CastExpression */, expression, castTerm); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitObjectLiteralExpression = function (node) { + var start = this.position; + + var openStart = this.position + node.openBraceToken.leadingTriviaWidth(); + this.movePast(node.openBraceToken); + + var propertyAssignments = this.visitSeparatedSyntaxList(node.propertyAssignments); + + var closeStart = this.position + node.closeBraceToken.leadingTriviaWidth(); + this.movePast(node.closeBraceToken); + + var result = new TypeScript.UnaryExpression(23 /* ObjectLiteralExpression */, propertyAssignments, null); + this.setCommentsAndSpan(result, start, node); + + if (this.isOnSingleLine(openStart, closeStart)) { + result.setFlags(result.getFlags() | 2 /* SingleLine */); + } + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitSimplePropertyAssignment = function (node) { + var start = this.position; + + var left = node.propertyName.accept(this); + + var afterColonComments = this.convertTokenTrailingComments(node.colonToken, this.position + node.colonToken.leadingTriviaWidth() + node.colonToken.width()); + + this.movePast(node.colonToken); + var right = node.expression.accept(this); + right.setPreComments(this.mergeComments(afterColonComments, right.preComments())); + + var result = new TypeScript.BinaryExpression(81 /* Member */, left, right); + this.setCommentsAndSpan(result, start, node); + + if (right.nodeType() === 13 /* FunctionDeclaration */) { + var funcDecl = right; + funcDecl.hint = left.text(); + } + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitFunctionPropertyAssignment = function (node) { + var start = this.position; + + var left = node.propertyName.accept(this); + var functionDeclaration = node.callSignature.accept(this); + var block = node.block.accept(this); + + functionDeclaration.hint = left.text(); + functionDeclaration.block = block; + functionDeclaration.setFunctionFlags(16384 /* IsFunctionProperty */); + + var result = new TypeScript.BinaryExpression(81 /* Member */, left, functionDeclaration); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitGetAccessorPropertyAssignment = function (node) { + var start = this.position; + + this.moveTo(node, node.propertyName); + var name = this.identifierFromToken(node.propertyName, false); + var functionName = this.identifierFromToken(node.propertyName, false); + this.movePast(node.propertyName); + this.movePast(node.openParenToken); + this.movePast(node.closeParenToken); + var returnType = node.typeAnnotation ? node.typeAnnotation.accept(this) : null; + + var block = node.block ? node.block.accept(this) : null; + + var funcDecl = new TypeScript.FunctionDeclaration(functionName, block, false, null, new TypeScript.ASTList([]), returnType, false); + this.setSpan(funcDecl, start, node); + + funcDecl.setFunctionFlags(funcDecl.getFunctionFlags() | 32 /* GetAccessor */ | 8192 /* IsFunctionExpression */); + funcDecl.hint = "get" + node.propertyName.valueText(); + + var result = new TypeScript.BinaryExpression(81 /* Member */, name, funcDecl); + this.copySpan(funcDecl, result); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitSetAccessorPropertyAssignment = function (node) { + var start = this.position; + + this.moveTo(node, node.propertyName); + var name = this.identifierFromToken(node.propertyName, false); + var functionName = this.identifierFromToken(node.propertyName, false); + this.movePast(node.propertyName); + this.movePast(node.openParenToken); + var parameter = node.parameter.accept(this); + this.movePast(node.closeParenToken); + + var parameters = new TypeScript.ASTList([parameter]); + + var block = node.block ? node.block.accept(this) : null; + + var funcDecl = new TypeScript.FunctionDeclaration(functionName, block, false, null, parameters, null, false); + this.setSpan(funcDecl, start, node); + + funcDecl.setFunctionFlags(funcDecl.getFunctionFlags() | 64 /* SetAccessor */ | 8192 /* IsFunctionExpression */); + funcDecl.hint = "set" + node.propertyName.valueText(); + + var result = new TypeScript.BinaryExpression(81 /* Member */, name, funcDecl); + this.copySpan(funcDecl, result); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitFunctionExpression = function (node) { + var start = this.position; + + this.movePast(node.functionKeyword); + var name = node.identifier === null ? null : this.identifierFromToken(node.identifier, false); + this.movePast(node.identifier); + var typeParameters = node.callSignature.typeParameterList === null ? null : node.callSignature.typeParameterList.accept(this); + var parameters = node.callSignature.parameterList.accept(this); + var returnType = node.callSignature.typeAnnotation ? node.callSignature.typeAnnotation.accept(this) : null; + + var block = node.block ? node.block.accept(this) : null; + + var result = new TypeScript.FunctionDeclaration(name, block, false, typeParameters, parameters, returnType, this.hasDotDotDotParameter(node.callSignature.parameterList.parameters)); + this.setCommentsAndSpan(result, start, node); + + result.setFunctionFlags(result.getFunctionFlags() | 8192 /* IsFunctionExpression */); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitEmptyStatement = function (node) { + var start = this.position; + + this.movePast(node.semicolonToken); + + var result = new TypeScript.EmptyStatement(); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitTryStatement = function (node) { + var start = this.position; + + this.movePast(node.tryKeyword); + var tryBody = node.block.accept(this); + + var catchClause = null; + if (node.catchClause !== null) { + catchClause = node.catchClause.accept(this); + } + + var finallyBody = null; + if (node.finallyClause !== null) { + finallyBody = node.finallyClause.accept(this); + } + + var result = new TypeScript.TryStatement(tryBody, catchClause, finallyBody); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitCatchClause = function (node) { + var start = this.position; + + this.movePast(node.catchKeyword); + this.movePast(node.openParenToken); + var identifier = this.identifierFromToken(node.identifier, false); + this.movePast(node.identifier); + var typeExpr = node.typeAnnotation ? node.typeAnnotation.accept(this) : null; + this.movePast(node.closeParenToken); + var block = node.block.accept(this); + + var varDecl = new TypeScript.VariableDeclarator(identifier, typeExpr, null); + this.setSpanExplicit(varDecl, identifier.minChar, identifier.limChar); + + var result = new TypeScript.CatchClause(varDecl, block); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitFinallyClause = function (node) { + this.movePast(node.finallyKeyword); + return node.block.accept(this); + }; + + SyntaxTreeToAstVisitor.prototype.visitLabeledStatement = function (node) { + var start = this.position; + + var identifier = this.identifierFromToken(node.identifier, false); + this.movePast(node.identifier); + this.movePast(node.colonToken); + var statement = node.statement.accept(this); + + var result = new TypeScript.LabeledStatement(identifier, statement); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitDoStatement = function (node) { + var start = this.position; + + this.movePast(node.doKeyword); + var statement = node.statement.accept(this); + var whileSpan = new TypeScript.ASTSpan(); + this.setSpan(whileSpan, this.position, node.whileKeyword); + + this.movePast(node.whileKeyword); + this.movePast(node.openParenToken); + var condition = node.condition.accept(this); + this.movePast(node.closeParenToken); + this.movePast(node.semicolonToken); + + var result = new TypeScript.DoStatement(statement, condition, whileSpan); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitTypeOfExpression = function (node) { + var start = this.position; + + this.movePast(node.typeOfKeyword); + var expression = node.expression.accept(this); + + var result = new TypeScript.UnaryExpression(35 /* TypeOfExpression */, expression, null); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitDeleteExpression = function (node) { + var start = this.position; + + this.movePast(node.deleteKeyword); + var expression = node.expression.accept(this); + + var result = new TypeScript.UnaryExpression(29 /* DeleteExpression */, expression, null); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitVoidExpression = function (node) { + var start = this.position; + + this.movePast(node.voidKeyword); + var expression = node.expression.accept(this); + + var result = new TypeScript.UnaryExpression(25 /* VoidExpression */, expression, null); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitDebuggerStatement = function (node) { + var start = this.position; + + this.movePast(node.debuggerKeyword); + this.movePast(node.semicolonToken); + + var result = new TypeScript.DebuggerStatement(); + this.setSpan(result, start, node); + + return result; + }; + SyntaxTreeToAstVisitor.protoString = "__proto__"; + SyntaxTreeToAstVisitor.protoSubstitutionString = "#__proto__"; + return SyntaxTreeToAstVisitor; + })(); + TypeScript.SyntaxTreeToAstVisitor = SyntaxTreeToAstVisitor; + + var SyntaxTreeToIncrementalAstVisitor = (function (_super) { + __extends(SyntaxTreeToIncrementalAstVisitor, _super); + function SyntaxTreeToIncrementalAstVisitor() { + _super.apply(this, arguments); + } + SyntaxTreeToIncrementalAstVisitor.prototype.applyDelta = function (ast, delta) { + if (delta === 0) { + return; + } + + var applyDelta = function (ast) { + if (ast.minChar !== -1) { + ast.minChar += delta; + } + if (ast.limChar !== -1) { + ast.limChar += delta; + } + }; + + var applyDeltaToComments = function (comments) { + if (comments && comments.length > 0) { + for (var i = 0; i < comments.length; i++) { + var comment = comments[i]; + applyDelta(comment); + } + } + }; + + var pre = function (cur, parent, walker) { + applyDelta(cur); + applyDeltaToComments(cur.preComments()); + applyDeltaToComments(cur.postComments()); + + return cur; + }; + + TypeScript.getAstWalkerFactory().walk(ast, pre); + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.setSpanExplicit = function (span, start, end) { + if (span.minChar !== -1) { + var delta = start - span.minChar; + this.applyDelta(span, delta); + + span.limChar = end; + } else { + _super.prototype.setSpanExplicit.call(this, span, start, end); + } + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.getAndMovePastAST = function (element) { + if (this.previousTokenTrailingComments !== null) { + return null; + } + + var result = (element)._ast; + if (!result) { + return null; + } + + var start = this.position; + this.movePast(element); + this.setSpan(result, start, element); + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.setAST = function (element, ast) { + (element)._ast = ast; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitSyntaxList = function (list) { + var result = this.getAndMovePastAST(list); + if (!result) { + result = _super.prototype.visitSyntaxList.call(this, list); + + if (list.childCount() > 0) { + this.setAST(list, result); + } + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitSeparatedSyntaxList = function (list) { + var result = this.getAndMovePastAST(list); + if (!result) { + result = _super.prototype.visitSeparatedSyntaxList.call(this, list); + + if (list.childCount() > 0) { + this.setAST(list, result); + } + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitToken = function (token) { + var result = this.getAndMovePastAST(token); + + if (!result) { + result = _super.prototype.visitToken.call(this, token); + this.setAST(token, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitClassDeclaration = function (node) { + var result = this.getAndMovePastAST(node); + if (result) { + this.completeClassDeclaration(node, result); + } else { + result = _super.prototype.visitClassDeclaration.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitInterfaceDeclaration = function (node) { + var result = this.getAndMovePastAST(node); + if (result) { + this.completeInterfaceDeclaration(node, result); + } else { + result = _super.prototype.visitInterfaceDeclaration.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitHeritageClause = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitHeritageClause.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitModuleDeclaration = function (node) { + var result = this.getAndMovePastAST(node); + if (result) { + this.completeModuleDeclaration(node, result); + } else { + result = _super.prototype.visitModuleDeclaration.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitFunctionDeclaration = function (node) { + var result = this.getAndMovePastAST(node); + if (result) { + this.completeFunctionDeclaration(node, result); + } else { + result = _super.prototype.visitFunctionDeclaration.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitImportDeclaration = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitImportDeclaration.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitExportAssignment = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitExportAssignment.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitPrefixUnaryExpression = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitPrefixUnaryExpression.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitArrayLiteralExpression = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitArrayLiteralExpression.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitOmittedExpression = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitOmittedExpression.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitParenthesizedExpression = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitParenthesizedExpression.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitSimpleArrowFunctionExpression = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitSimpleArrowFunctionExpression.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitParenthesizedArrowFunctionExpression = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitParenthesizedArrowFunctionExpression.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitQualifiedName = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + var result = _super.prototype.visitQualifiedName.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitConstructorType = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitConstructorType.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitFunctionType = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitFunctionType.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitObjectType = function (node) { + var start = this.position; + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitObjectType.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitArrayType = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitArrayType.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitGenericType = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitGenericType.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitBlock = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitBlock.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitParameter = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitParameter.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitMemberAccessExpression = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitMemberAccessExpression.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitPostfixUnaryExpression = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitPostfixUnaryExpression.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitElementAccessExpression = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitElementAccessExpression.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitInvocationExpression = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitInvocationExpression.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitBinaryExpression = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitBinaryExpression.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitConditionalExpression = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitConditionalExpression.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitConstructSignature = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitConstructSignature.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitMethodSignature = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitMethodSignature.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitIndexSignature = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitIndexSignature.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitPropertySignature = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitPropertySignature.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitCallSignature = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitCallSignature.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitTypeParameter = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitTypeParameter.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitIfStatement = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitIfStatement.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitExpressionStatement = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitExpressionStatement.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitConstructorDeclaration = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitConstructorDeclaration.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitMemberFunctionDeclaration = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitMemberFunctionDeclaration.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitMemberAccessorDeclaration = function (node, typeAnnotation) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitMemberAccessorDeclaration.call(this, node, typeAnnotation); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitMemberVariableDeclaration = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitMemberVariableDeclaration.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitThrowStatement = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitThrowStatement.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitReturnStatement = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitReturnStatement.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitObjectCreationExpression = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitObjectCreationExpression.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitSwitchStatement = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitSwitchStatement.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitCaseSwitchClause = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitCaseSwitchClause.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitDefaultSwitchClause = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitDefaultSwitchClause.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitBreakStatement = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitBreakStatement.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitContinueStatement = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitContinueStatement.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitForStatement = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitForStatement.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitForInStatement = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitForInStatement.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitWhileStatement = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitWhileStatement.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitWithStatement = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitWithStatement.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitCastExpression = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitCastExpression.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitObjectLiteralExpression = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitObjectLiteralExpression.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitSimplePropertyAssignment = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitSimplePropertyAssignment.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitFunctionPropertyAssignment = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitFunctionPropertyAssignment.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitGetAccessorPropertyAssignment = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitGetAccessorPropertyAssignment.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitSetAccessorPropertyAssignment = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitSetAccessorPropertyAssignment.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitFunctionExpression = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitFunctionExpression.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitEmptyStatement = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitEmptyStatement.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitTryStatement = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitTryStatement.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitCatchClause = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitCatchClause.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitLabeledStatement = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitLabeledStatement.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitDoStatement = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitDoStatement.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitTypeOfExpression = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitTypeOfExpression.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitDeleteExpression = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitDeleteExpression.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitVoidExpression = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitVoidExpression.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitDebuggerStatement = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitDebuggerStatement.call(this, node); + this.setAST(node, result); + } + + return result; + }; + return SyntaxTreeToIncrementalAstVisitor; + })(SyntaxTreeToAstVisitor); +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + TypeScript.fileResolutionTime = 0; + TypeScript.sourceCharactersCompiled = 0; + TypeScript.syntaxTreeParseTime = 0; + TypeScript.syntaxDiagnosticsTime = 0; + TypeScript.astTranslationTime = 0; + TypeScript.typeCheckTime = 0; + + TypeScript.emitTime = 0; + TypeScript.emitWriteFileTime = 0; + TypeScript.emitDirectoryExistsTime = 0; + TypeScript.emitFileExistsTime = 0; + TypeScript.emitResolvePathTime = 0; + + TypeScript.declarationEmitTime = 0; + TypeScript.declarationEmitIsExternallyVisibleTime = 0; + TypeScript.declarationEmitTypeSignatureTime = 0; + TypeScript.declarationEmitGetBoundDeclTypeTime = 0; + TypeScript.declarationEmitIsOverloadedCallSignatureTime = 0; + TypeScript.declarationEmitFunctionDeclarationGetSymbolTime = 0; + TypeScript.declarationEmitGetBaseTypeTime = 0; + TypeScript.declarationEmitGetAccessorFunctionTime = 0; + TypeScript.declarationEmitGetTypeParameterSymbolTime = 0; + TypeScript.declarationEmitGetImportDeclarationSymbolTime = 0; + + TypeScript.ioHostResolvePathTime = 0; + TypeScript.ioHostDirectoryNameTime = 0; + TypeScript.ioHostCreateDirectoryStructureTime = 0; + TypeScript.ioHostWriteFileTime = 0; + + var Document = (function () { + function Document(fileName, compilationSettings, scriptSnapshot, byteOrderMark, version, isOpen, syntaxTree) { + this.fileName = fileName; + this.compilationSettings = compilationSettings; + this.scriptSnapshot = scriptSnapshot; + this.byteOrderMark = byteOrderMark; + this.version = version; + this.isOpen = isOpen; + this._diagnostics = null; + this._syntaxTree = null; + this._bloomFilter = null; + if (isOpen) { + this._syntaxTree = syntaxTree; + } else { + var start = new Date().getTime(); + this._diagnostics = syntaxTree.diagnostics(); + TypeScript.syntaxDiagnosticsTime += new Date().getTime() - start; + } + + this.lineMap = syntaxTree.lineMap(); + + var start = new Date().getTime(); + this.script = TypeScript.SyntaxTreeToAstVisitor.visit(syntaxTree, fileName, compilationSettings, isOpen); + TypeScript.astTranslationTime += new Date().getTime() - start; + } + Document.prototype.diagnostics = function () { + if (this._diagnostics === null) { + this._diagnostics = this._syntaxTree.diagnostics(); + } + + return this._diagnostics; + }; + + Document.prototype.syntaxTree = function () { + if (this._syntaxTree) { + return this._syntaxTree; + } + + return TypeScript.Parser.parse(this.fileName, TypeScript.SimpleText.fromScriptSnapshot(this.scriptSnapshot), TypeScript.isDTSFile(this.fileName), TypeScript.getParseOptions(this.compilationSettings)); + }; + + Document.prototype.bloomFilter = function () { + if (!this._bloomFilter) { + var identifiers = new TypeScript.BlockIntrinsics(); + var pre = function (cur, parent, walker) { + if (TypeScript.isValidAstNode(cur)) { + if (cur.nodeType() === 21 /* Name */) { + var nodeText = (cur).text(); + + identifiers[nodeText] = true; + } + } + + return cur; + }; + + TypeScript.getAstWalkerFactory().walk(this.script, pre, null, null, identifiers); + + var identifierCount = 0; + for (var name in identifiers) { + if (identifiers[name]) { + identifierCount++; + } + } + + this._bloomFilter = new TypeScript.BloomFilter(identifierCount); + this._bloomFilter.addKeys(identifiers); + } + return this._bloomFilter; + }; + + Document.prototype.update = function (scriptSnapshot, version, isOpen, textChangeRange, settings) { + var oldScript = this.script; + var oldSyntaxTree = this._syntaxTree; + + var text = TypeScript.SimpleText.fromScriptSnapshot(scriptSnapshot); + + var newSyntaxTree = textChangeRange === null || oldSyntaxTree === null ? TypeScript.Parser.parse(this.fileName, text, TypeScript.isDTSFile(this.fileName), TypeScript.getParseOptions(this.compilationSettings)) : TypeScript.Parser.incrementalParse(oldSyntaxTree, textChangeRange, text); + + return new Document(this.fileName, this.compilationSettings, scriptSnapshot, this.byteOrderMark, version, isOpen, newSyntaxTree); + }; + + Document.create = function (fileName, scriptSnapshot, byteOrderMark, version, isOpen, referencedFiles, compilationSettings) { + var start = new Date().getTime(); + var syntaxTree = TypeScript.Parser.parse(fileName, TypeScript.SimpleText.fromScriptSnapshot(scriptSnapshot), TypeScript.isDTSFile(fileName), TypeScript.getParseOptions(compilationSettings)); + TypeScript.syntaxTreeParseTime += new Date().getTime() - start; + + var document = new Document(fileName, compilationSettings, scriptSnapshot, byteOrderMark, version, isOpen, syntaxTree); + document.script.referencedFiles = referencedFiles; + + return document; + }; + return Document; + })(); + TypeScript.Document = Document; + + TypeScript.globalSemanticInfoChain = null; + TypeScript.globalBinder = null; + TypeScript.globalLogger = null; + + TypeScript.useDirectTypeStorage = false; + + var TypeScriptCompiler = (function () { + function TypeScriptCompiler(logger, settings) { + if (typeof logger === "undefined") { logger = new TypeScript.NullLogger(); } + if (typeof settings === "undefined") { settings = new TypeScript.CompilationSettings(); } + this.logger = logger; + this.settings = settings; + this.resolver = null; + this.semanticInfoChain = null; + this.fileNameToDocument = new TypeScript.StringHashTable(); + this.emitOptions = new TypeScript.EmitOptions(this.settings); + TypeScript.globalLogger = logger; + } + TypeScriptCompiler.prototype.getDocument = function (fileName) { + return this.fileNameToDocument.lookup(TypeScript.switchToForwardSlashes(fileName)); + }; + + TypeScriptCompiler.prototype.timeFunction = function (funcDescription, func) { + return TypeScript.timeFunction(this.logger, funcDescription, func); + }; + + TypeScriptCompiler.prototype.addSourceUnit = function (fileName, scriptSnapshot, byteOrderMark, version, isOpen, referencedFiles) { + if (typeof referencedFiles === "undefined") { referencedFiles = []; } + fileName = TypeScript.switchToForwardSlashes(fileName); + + TypeScript.sourceCharactersCompiled += scriptSnapshot.getLength(); + + var document = Document.create(fileName, scriptSnapshot, byteOrderMark, version, isOpen, referencedFiles, this.emitOptions.compilationSettings); + this.fileNameToDocument.addOrUpdate(fileName, document); + + return document; + }; + + TypeScriptCompiler.prototype.updateSourceUnit = function (fileName, scriptSnapshot, version, isOpen, textChangeRange) { + var _this = this; + fileName = TypeScript.switchToForwardSlashes(fileName); + return this.timeFunction("pullUpdateUnit(" + fileName + ")", function () { + var document = _this.getDocument(fileName); + var updatedDocument = document.update(scriptSnapshot, version, isOpen, textChangeRange, _this.settings); + + _this.fileNameToDocument.addOrUpdate(fileName, updatedDocument); + + _this.pullUpdateScript(document, updatedDocument); + + return updatedDocument; + }); + }; + + TypeScriptCompiler.prototype.isDynamicModuleCompilation = function () { + var fileNames = this.fileNameToDocument.getAllKeys(); + for (var i = 0, n = fileNames.length; i < n; i++) { + var document = this.getDocument(fileNames[i]); + var script = document.script; + if (!script.isDeclareFile && script.topLevelMod !== null) { + return true; + } + } + return false; + }; + + TypeScriptCompiler.prototype.updateCommonDirectoryPath = function () { + var commonComponents = []; + var commonComponentsLength = -1; + + var fileNames = this.fileNameToDocument.getAllKeys(); + for (var i = 0, len = fileNames.length; i < len; i++) { + var fileName = fileNames[i]; + var document = this.getDocument(fileNames[i]); + var script = document.script; + + if (!script.isDeclareFile) { + var fileComponents = TypeScript.filePathComponents(fileName); + if (commonComponentsLength === -1) { + commonComponents = fileComponents; + commonComponentsLength = commonComponents.length; + } else { + var updatedPath = false; + for (var j = 0; j < commonComponentsLength && j < fileComponents.length; j++) { + if (commonComponents[j] !== fileComponents[j]) { + commonComponentsLength = j; + updatedPath = true; + + if (j === 0) { + if (this.emitOptions.compilationSettings.outDirOption || this.emitOptions.compilationSettings.sourceRoot) { + return new TypeScript.Diagnostic(null, 0, 0, TypeScript.DiagnosticCode.Cannot_find_the_common_subdirectory_path_for_the_input_files, null); + } else { + this.emitOptions.commonDirectoryPath = ""; + return null; + } + } + + break; + } + } + + if (!updatedPath && fileComponents.length < commonComponentsLength) { + commonComponentsLength = fileComponents.length; + } + } + } + } + + this.emitOptions.commonDirectoryPath = commonComponents.slice(0, commonComponentsLength).join("/") + "/"; + return null; + }; + + TypeScriptCompiler.prototype.convertToDirectoryPath = function (dirPath) { + if (dirPath && dirPath.charAt(dirPath.length - 1) !== "/") { + dirPath += "/"; + } + + return dirPath; + }; + + TypeScriptCompiler.prototype.setEmitOptions = function (ioHost) { + this.emitOptions.ioHost = ioHost; + + if (this.emitOptions.compilationSettings.moduleGenTarget === 0 /* Unspecified */ && this.isDynamicModuleCompilation()) { + return new TypeScript.Diagnostic(null, 0, 0, TypeScript.DiagnosticCode.Cannot_compile_external_modules_unless_the_module_flag_is_provided, null); + } + + if (!this.emitOptions.compilationSettings.mapSourceFiles) { + if (this.emitOptions.compilationSettings.mapRoot) { + if (this.emitOptions.compilationSettings.sourceRoot) { + return new TypeScript.Diagnostic(null, 0, 0, TypeScript.DiagnosticCode.Options_mapRoot_and_sourceRoot_cannot_be_specified_without_specifying_sourcemap_option, null); + } else { + return new TypeScript.Diagnostic(null, 0, 0, TypeScript.DiagnosticCode.Option_mapRoot_cannot_be_specified_without_specifying_sourcemap_option, null); + } + } else if (this.emitOptions.compilationSettings.sourceRoot) { + return new TypeScript.Diagnostic(null, 0, 0, TypeScript.DiagnosticCode.Option_sourceRoot_cannot_be_specified_without_specifying_sourcemap_option, null); + } + } + + this.emitOptions.compilationSettings.mapRoot = this.convertToDirectoryPath(TypeScript.switchToForwardSlashes(this.emitOptions.compilationSettings.mapRoot)); + this.emitOptions.compilationSettings.sourceRoot = this.convertToDirectoryPath(TypeScript.switchToForwardSlashes(this.emitOptions.compilationSettings.sourceRoot)); + + if (!this.emitOptions.compilationSettings.outFileOption && !this.emitOptions.compilationSettings.outDirOption && !this.emitOptions.compilationSettings.mapRoot && !this.emitOptions.compilationSettings.sourceRoot) { + this.emitOptions.outputMany = true; + this.emitOptions.commonDirectoryPath = ""; + return null; + } + + if (this.emitOptions.compilationSettings.outFileOption) { + this.emitOptions.compilationSettings.outFileOption = TypeScript.switchToForwardSlashes(this.emitOptions.ioHost.resolvePath(this.emitOptions.compilationSettings.outFileOption)); + this.emitOptions.outputMany = false; + } else { + this.emitOptions.outputMany = true; + } + + if (this.emitOptions.compilationSettings.outDirOption) { + this.emitOptions.compilationSettings.outDirOption = TypeScript.switchToForwardSlashes(this.emitOptions.ioHost.resolvePath(this.emitOptions.compilationSettings.outDirOption)); + this.emitOptions.compilationSettings.outDirOption = this.convertToDirectoryPath(this.emitOptions.compilationSettings.outDirOption); + } + + if (this.emitOptions.compilationSettings.outDirOption || this.emitOptions.compilationSettings.mapRoot || this.emitOptions.compilationSettings.sourceRoot) { + return this.updateCommonDirectoryPath(); + } + + return null; + }; + + TypeScriptCompiler.prototype.getScripts = function () { + var result = []; + var fileNames = this.fileNameToDocument.getAllKeys(); + + for (var i = 0, n = fileNames.length; i < n; i++) { + var document = this.getDocument(fileNames[i]); + result.push(document.script); + } + + return result; + }; + + TypeScriptCompiler.prototype.getDocuments = function () { + var result = []; + var fileNames = this.fileNameToDocument.getAllKeys(); + + for (var i = 0, n = fileNames.length; i < n; i++) { + var document = this.getDocument(fileNames[i]); + result.push(document); + } + + return result; + }; + + TypeScriptCompiler.prototype.writeByteOrderMarkForDocument = function (document) { + if (this.emitOptions.outputMany || document.script.topLevelMod) { + return document.byteOrderMark !== 0 /* None */; + } else { + var fileNames = this.fileNameToDocument.getAllKeys(); + + for (var i = 0, n = fileNames.length; i < n; i++) { + if (document.script.topLevelMod) { + continue; + } + var document = this.getDocument(fileNames[i]); + if (document.byteOrderMark !== 0 /* None */) { + return true; + } + } + + return false; + } + }; + + TypeScriptCompiler.mapToDTSFileName = function (fileName, wholeFileNameReplaced) { + return TypeScript.getDeclareFilePath(fileName); + }; + + TypeScriptCompiler.prototype.canEmitDeclarations = function (script) { + if (!this.settings.generateDeclarationFiles) { + return false; + } + + if (!!script && (script.isDeclareFile || script.moduleElements === null)) { + return false; + } + + return true; + }; + + TypeScriptCompiler.prototype.emitDeclarations = function (document, declarationEmitter) { + var script = document.script; + if (this.canEmitDeclarations(script)) { + if (declarationEmitter) { + declarationEmitter.document = document; + } else { + var declareFileName = this.emitOptions.mapOutputFileName(document, TypeScriptCompiler.mapToDTSFileName); + declarationEmitter = new TypeScript.DeclarationEmitter(declareFileName, document, this); + } + + declarationEmitter.emitDeclarations(script); + } + + return declarationEmitter; + }; + + TypeScriptCompiler.prototype.emitAllDeclarations = function () { + var start = new Date().getTime(); + + if (this.canEmitDeclarations()) { + var sharedEmitter = null; + var fileNames = this.fileNameToDocument.getAllKeys(); + + for (var i = 0, n = fileNames.length; i < n; i++) { + var fileName = fileNames[i]; + + try { + var document = this.getDocument(fileNames[i]); + + if (this.emitOptions.outputMany || document.script.topLevelMod) { + var singleEmitter = this.emitDeclarations(document); + if (singleEmitter) { + singleEmitter.close(); + } + } else { + sharedEmitter = this.emitDeclarations(document, sharedEmitter); + } + } catch (ex1) { + return TypeScript.Emitter.handleEmitterError(fileName, ex1); + } + } + + if (sharedEmitter) { + try { + sharedEmitter.close(); + } catch (ex2) { + return TypeScript.Emitter.handleEmitterError(sharedEmitter.document.fileName, ex2); + } + } + } + + TypeScript.declarationEmitTime += new Date().getTime() - start; + + return []; + }; + + TypeScriptCompiler.prototype.emitUnitDeclarations = function (fileName) { + if (this.canEmitDeclarations()) { + var document = this.getDocument(fileName); + + if (this.emitOptions.outputMany || document.script.topLevelMod) { + try { + var emitter = this.emitDeclarations(document); + if (emitter) { + emitter.close(); + } + } catch (ex1) { + return TypeScript.Emitter.handleEmitterError(fileName, ex1); + } + } else { + return this.emitAllDeclarations(); + } + } + + return []; + }; + + TypeScriptCompiler.mapToFileNameExtension = function (extension, fileName, wholeFileNameReplaced) { + if (wholeFileNameReplaced) { + return fileName; + } else { + var splitFname = fileName.split("."); + splitFname.pop(); + return splitFname.join(".") + extension; + } + }; + + TypeScriptCompiler.mapToJSFileName = function (fileName, wholeFileNameReplaced) { + return TypeScriptCompiler.mapToFileNameExtension(".js", fileName, wholeFileNameReplaced); + }; + + TypeScriptCompiler.prototype.emit = function (document, inputOutputMapper, emitter) { + var script = document.script; + if (!script.isDeclareFile) { + var typeScriptFileName = document.fileName; + if (!emitter) { + var javaScriptFileName = this.emitOptions.mapOutputFileName(document, TypeScriptCompiler.mapToJSFileName); + var outFile = this.createFile(javaScriptFileName, this.writeByteOrderMarkForDocument(document)); + + emitter = new TypeScript.Emitter(javaScriptFileName, outFile, this.emitOptions, this.semanticInfoChain); + + if (this.settings.mapSourceFiles) { + var sourceMapFile = this.createFile(javaScriptFileName + TypeScript.SourceMapper.MapFileExtension, false); + var sourceMapSourceInfo = this.emitOptions.decodeSourceMapOptions(document, javaScriptFileName); + emitter.setSourceMappings(new TypeScript.SourceMapper(outFile, sourceMapFile, sourceMapSourceInfo)); + } + + if (inputOutputMapper) { + inputOutputMapper(typeScriptFileName, javaScriptFileName); + } + } else if (this.settings.mapSourceFiles) { + var sourceMapSourceInfo = this.emitOptions.decodeSourceMapOptions(document, emitter.emittingFileName, emitter.sourceMapper.sourceMapSourceInfo); + emitter.setSourceMappings(new TypeScript.SourceMapper(emitter.outfile, emitter.sourceMapper.sourceMapOut, sourceMapSourceInfo)); + } + + emitter.setDocument(document); + emitter.emitJavascript(script, false); + } + + return emitter; + }; + + TypeScriptCompiler.prototype.emitAll = function (ioHost, inputOutputMapper) { + var start = new Date().getTime(); + + var optionsDiagnostic = this.setEmitOptions(ioHost); + if (optionsDiagnostic) { + return [optionsDiagnostic]; + } + + var fileNames = this.fileNameToDocument.getAllKeys(); + var sharedEmitter = null; + + for (var i = 0, n = fileNames.length; i < n; i++) { + var fileName = fileNames[i]; + + var document = this.getDocument(fileName); + + try { + if (this.emitOptions.outputMany || document.script.topLevelMod) { + var singleEmitter = this.emit(document, inputOutputMapper); + + if (singleEmitter) { + singleEmitter.emitSourceMapsAndClose(); + } + } else { + sharedEmitter = this.emit(document, inputOutputMapper, sharedEmitter); + } + } catch (ex1) { + return TypeScript.Emitter.handleEmitterError(fileName, ex1); + } + } + + if (sharedEmitter) { + try { + sharedEmitter.emitSourceMapsAndClose(); + } catch (ex2) { + return TypeScript.Emitter.handleEmitterError(sharedEmitter.document.fileName, ex2); + } + } + + TypeScript.emitTime += new Date().getTime() - start; + return []; + }; + + TypeScriptCompiler.prototype.emitUnit = function (fileName, ioHost, inputOutputMapper) { + var optionsDiagnostic = this.setEmitOptions(ioHost); + if (optionsDiagnostic) { + return [optionsDiagnostic]; + } + + var document = this.getDocument(fileName); + + if (this.emitOptions.outputMany || document.script.topLevelMod) { + try { + var emitter = this.emit(document, inputOutputMapper); + + if (emitter) { + emitter.emitSourceMapsAndClose(); + } + } catch (ex1) { + return TypeScript.Emitter.handleEmitterError(fileName, ex1); + } + + return []; + } else { + return this.emitAll(ioHost, inputOutputMapper); + } + }; + + TypeScriptCompiler.prototype.createFile = function (fileName, writeByteOrderMark) { + return new TypeScript.TextWriter(this.emitOptions.ioHost, fileName, writeByteOrderMark); + }; + + TypeScriptCompiler.prototype.pullResolveFile = function (fileName) { + var unit = this.semanticInfoChain.getUnit(fileName); + + if (!unit) { + return false; + } + + this.setUnit(fileName); + + this.resolver.resolveBoundDecls(unit.getTopLevelDecls()[0], new TypeScript.PullTypeResolutionContext()); + + return true; + }; + + TypeScriptCompiler.prototype.getSyntacticDiagnostics = function (fileName) { + return this.getDocument(fileName).diagnostics(); + }; + + TypeScriptCompiler.prototype.getSyntaxTree = function (fileName) { + return this.getDocument(fileName).syntaxTree(); + }; + TypeScriptCompiler.prototype.getScript = function (fileName) { + return this.getDocument(fileName).script; + }; + + TypeScriptCompiler.prototype.getSemanticDiagnostics = function (fileName) { + var errors = []; + var unit = this.semanticInfoChain.getUnit(fileName); + + TypeScript.globalSemanticInfoChain = this.semanticInfoChain; + if (TypeScript.globalBinder) { + TypeScript.globalBinder.semanticInfoChain = this.semanticInfoChain; + } + + if (unit) { + var document = this.getDocument(fileName); + var script = document.script; + + if (script) { + var startTime = (new Date()).getTime(); + TypeScript.PullTypeResolver.typeCheck(this.settings, this.semanticInfoChain, fileName, script); + var endTime = (new Date()).getTime(); + + TypeScript.typeCheckTime += endTime - startTime; + + unit.getDiagnostics(errors); + } + } + + return errors; + }; + + TypeScriptCompiler.prototype.resolveAllFiles = function () { + var fileNames = this.fileNameToDocument.getAllKeys(); + for (var i = 0, n = fileNames.length; i < n; i++) { + this.getSemanticDiagnostics(fileNames[i]); + } + }; + + TypeScriptCompiler.prototype.setUnit = function (unitPath) { + if (!this.resolver) { + this.resolver = new TypeScript.PullTypeResolver(this.settings, this.semanticInfoChain, unitPath); + } + + this.resolver.setUnitPath(unitPath); + }; + + TypeScriptCompiler.prototype.pullTypeCheck = function () { + var start = new Date().getTime(); + + this.semanticInfoChain = new TypeScript.SemanticInfoChain(); + TypeScript.globalSemanticInfoChain = this.semanticInfoChain; + + if (this.resolver) { + this.resolver.semanticInfoChain = this.semanticInfoChain; + } + + var declCollectionContext = null; + var i, n; + + var createDeclsStartTime = new Date().getTime(); + + var fileNames = this.fileNameToDocument.getAllKeys(); + var n = fileNames.length; + for (var i = 0; i < n; i++) { + var fileName = fileNames[i]; + var document = this.getDocument(fileName); + var semanticInfo = new TypeScript.SemanticInfo(fileName); + + declCollectionContext = new TypeScript.DeclCollectionContext(semanticInfo, fileName); + + TypeScript.getAstWalkerFactory().walk(document.script, TypeScript.preCollectDecls, TypeScript.postCollectDecls, null, declCollectionContext); + + semanticInfo.addTopLevelDecl(declCollectionContext.getParent()); + + this.semanticInfoChain.addUnit(semanticInfo); + } + + var createDeclsEndTime = new Date().getTime(); + + var bindStartTime = new Date().getTime(); + + var binder = new TypeScript.PullSymbolBinder(this.semanticInfoChain); + TypeScript.globalBinder = binder; + + for (var i = 1; i < this.semanticInfoChain.units.length; i++) { + binder.bindDeclsForUnit(this.semanticInfoChain.units[i].getPath()); + } + + var bindEndTime = new Date().getTime(); + + this.logger.log("Decl creation: " + (createDeclsEndTime - createDeclsStartTime)); + this.logger.log("Binding: " + (bindEndTime - bindStartTime)); + this.logger.log(" Time in findSymbol: " + TypeScript.time_in_findSymbol); + this.logger.log("Number of symbols created: " + TypeScript.pullSymbolID); + this.logger.log("Number of specialized types created: " + TypeScript.nSpecializationsCreated); + this.logger.log("Number of specialized signatures created: " + TypeScript.nSpecializedSignaturesCreated); + }; + + TypeScriptCompiler.prototype.pullUpdateScript = function (oldDocument, newDocument) { + var _this = this; + this.timeFunction("pullUpdateScript: ", function () { + var oldScript = oldDocument.script; + var newScript = newDocument.script; + + var newScriptSemanticInfo = new TypeScript.SemanticInfo(oldDocument.fileName); + var oldScriptSemanticInfo = _this.semanticInfoChain.getUnit(oldDocument.fileName); + + TypeScript.lastBoundPullDeclId = TypeScript.pullDeclID; + + var declCollectionContext = new TypeScript.DeclCollectionContext(newScriptSemanticInfo, oldDocument.fileName); + + TypeScript.getAstWalkerFactory().walk(newScript, TypeScript.preCollectDecls, TypeScript.postCollectDecls, null, declCollectionContext); + + var oldTopLevelDecl = oldScriptSemanticInfo.getTopLevelDecls()[0]; + var newTopLevelDecl = declCollectionContext.getParent(); + + newScriptSemanticInfo.addTopLevelDecl(newTopLevelDecl); + + if (_this.resolver) { + _this.resolver.cleanCachedGlobals(); + } + + _this.semanticInfoChain.updateUnit(oldScriptSemanticInfo, newScriptSemanticInfo); + + _this.logger.log("Cleaning symbols..."); + var cleanStart = new Date().getTime(); + _this.semanticInfoChain.update(); + var cleanEnd = new Date().getTime(); + _this.logger.log(" time to clean: " + (cleanEnd - cleanStart)); + + if (_this.resolver) { + _this.resolver.setUnitPath(oldDocument.fileName); + } + }); + }; + + TypeScriptCompiler.prototype.getSymbolOfDeclaration = function (decl) { + if (!decl) { + return null; + } + var ast = this.resolver.getASTForDecl(decl); + if (!ast) { + return null; + } + var enlosingDecl = this.resolver.getEnclosingDecl(decl); + if (ast.nodeType() === 81 /* Member */) { + return this.getSymbolOfDeclaration(enlosingDecl); + } + var resolutionContext = new TypeScript.PullTypeResolutionContext(); + return this.resolver.resolveAST(ast, false, enlosingDecl, resolutionContext); + }; + + TypeScriptCompiler.prototype.resolvePosition = function (pos, document) { + var declStack = []; + var resultASTs = []; + var script = document.script; + var scriptName = document.fileName; + + var semanticInfo = this.semanticInfoChain.getUnit(scriptName); + var lastDeclAST = null; + var foundAST = null; + var symbol = null; + var candidateSignature = null; + var callSignatures = null; + + var lambdaAST = null; + var declarationInitASTs = []; + var objectLitAST = null; + var asgAST = null; + var typeAssertionASTs = []; + var resolutionContext = new TypeScript.PullTypeResolutionContext(); + var inTypeReference = false; + var enclosingDecl = null; + var isConstructorCall = false; + + TypeScript.globalSemanticInfoChain = this.semanticInfoChain; + if (TypeScript.globalBinder) { + TypeScript.globalBinder.semanticInfoChain = this.semanticInfoChain; + } + + var pre = function (cur, parent) { + if (TypeScript.isValidAstNode(cur)) { + if (pos >= cur.minChar && pos <= cur.limChar) { + var previous = resultASTs[resultASTs.length - 1]; + + if (previous === undefined || (cur.minChar >= previous.minChar && cur.limChar <= previous.limChar)) { + var decl = semanticInfo.getDeclForAST(cur); + + if (decl) { + declStack[declStack.length] = decl; + lastDeclAST = cur; + } + + if (cur.nodeType() === 13 /* FunctionDeclaration */ && TypeScript.hasFlag((cur).getFunctionFlags(), 8192 /* IsFunctionExpression */)) { + lambdaAST = cur; + } else if (cur.nodeType() === 18 /* VariableDeclarator */) { + declarationInitASTs[declarationInitASTs.length] = cur; + } else if (cur.nodeType() === 23 /* ObjectLiteralExpression */) { + objectLitAST = cur; + } else if (cur.nodeType() === 79 /* CastExpression */) { + typeAssertionASTs[typeAssertionASTs.length] = cur; + } else if (cur.nodeType() === 39 /* AssignmentExpression */) { + asgAST = cur; + } else if (cur.nodeType() === 11 /* TypeRef */) { + inTypeReference = true; + } + + resultASTs[resultASTs.length] = cur; + } + } + } + return cur; + }; + + TypeScript.getAstWalkerFactory().walk(script, pre); + + if (resultASTs.length) { + this.setUnit(scriptName); + + foundAST = resultASTs[resultASTs.length - 1]; + + if (foundAST.nodeType() === 21 /* Name */ && resultASTs.length > 1) { + var previousAST = resultASTs[resultASTs.length - 2]; + switch (previousAST.nodeType()) { + case 15 /* InterfaceDeclaration */: + if (foundAST === (previousAST).name) { + foundAST = previousAST; + } + break; + case 14 /* ClassDeclaration */: + if (foundAST === (previousAST).name) { + foundAST = previousAST; + } + break; + case 16 /* ModuleDeclaration */: + if (foundAST === (previousAST).name) { + foundAST = previousAST; + } + break; + + case 18 /* VariableDeclarator */: + if (foundAST === (previousAST).id) { + foundAST = previousAST; + } + break; + + case 13 /* FunctionDeclaration */: + if (foundAST === (previousAST).name) { + foundAST = previousAST; + } + break; + } + } + + var funcDecl = null; + if (lastDeclAST === foundAST) { + symbol = declStack[declStack.length - 1].getSymbol(); + this.resolver.resolveDeclaredSymbol(symbol, null, resolutionContext); + symbol.setUnresolved(); + enclosingDecl = declStack[declStack.length - 1].getParentDecl(); + if (foundAST.nodeType() === 13 /* FunctionDeclaration */) { + funcDecl = foundAST; + } + } else { + for (var i = declStack.length - 1; i >= 0; i--) { + if (!(declStack[i].kind & (1024 /* Variable */ | 2048 /* Parameter */))) { + enclosingDecl = declStack[i]; + break; + } + } + + var callExpression = null; + if ((foundAST.nodeType() === 31 /* SuperExpression */ || foundAST.nodeType() === 30 /* ThisExpression */ || foundAST.nodeType() === 21 /* Name */) && resultASTs.length > 1) { + for (var i = resultASTs.length - 2; i >= 0; i--) { + if (resultASTs[i].nodeType() === 33 /* MemberAccessExpression */ && (resultASTs[i]).operand2 === resultASTs[i + 1]) { + foundAST = resultASTs[i]; + } else if ((resultASTs[i].nodeType() === 37 /* InvocationExpression */ || resultASTs[i].nodeType() === 38 /* ObjectCreationExpression */) && (resultASTs[i]).target === resultASTs[i + 1]) { + callExpression = resultASTs[i]; + break; + } else if (resultASTs[i].nodeType() === 13 /* FunctionDeclaration */ && (resultASTs[i]).name === resultASTs[i + 1]) { + funcDecl = resultASTs[i]; + break; + } else { + break; + } + } + } + + if (foundAST.nodeType() === 1 /* List */) { + for (var i = 0; i < (foundAST).members.length; i++) { + if ((foundAST).members[i].minChar > pos) { + foundAST = (foundAST).members[i]; + break; + } + } + } + + resolutionContext.resolvingTypeReference = inTypeReference; + + var inContextuallyTypedAssignment = false; + + if (declarationInitASTs.length) { + var assigningAST; + + for (var i = 0; i < declarationInitASTs.length; i++) { + assigningAST = declarationInitASTs[i]; + inContextuallyTypedAssignment = (assigningAST !== null) && (assigningAST.typeExpr !== null); + + this.resolver.resolveAST(assigningAST, false, null, resolutionContext); + var varSymbol = this.semanticInfoChain.getSymbolForAST(assigningAST, scriptName); + + if (varSymbol && inContextuallyTypedAssignment) { + var contextualType = varSymbol.type; + resolutionContext.pushContextualType(contextualType, false, null); + } + + if (assigningAST.init) { + this.resolver.resolveAST(assigningAST.init, inContextuallyTypedAssignment, enclosingDecl, resolutionContext); + } + } + } + + if (typeAssertionASTs.length) { + for (var i = 0; i < typeAssertionASTs.length; i++) { + this.resolver.resolveAST(typeAssertionASTs[i], inContextuallyTypedAssignment, enclosingDecl, resolutionContext); + } + } + + if (asgAST) { + this.resolver.resolveAST(asgAST, inContextuallyTypedAssignment, enclosingDecl, resolutionContext); + } + + if (objectLitAST) { + this.resolver.resolveAST(objectLitAST, inContextuallyTypedAssignment, enclosingDecl, resolutionContext); + } + + if (lambdaAST) { + this.resolver.resolveAST(lambdaAST, true, enclosingDecl, resolutionContext); + enclosingDecl = semanticInfo.getDeclForAST(lambdaAST); + } + + symbol = this.resolver.resolveAST(foundAST, inContextuallyTypedAssignment, enclosingDecl, resolutionContext); + if (callExpression) { + var isPropertyOrVar = symbol.kind === 4096 /* Property */ || symbol.kind === 1024 /* Variable */; + var typeSymbol = symbol.type; + if (isPropertyOrVar) { + isPropertyOrVar = (typeSymbol.kind !== 16 /* Interface */ && typeSymbol.kind !== 8388608 /* ObjectType */) || typeSymbol.name === ""; + } + + if (!isPropertyOrVar) { + isConstructorCall = foundAST.nodeType() === 31 /* SuperExpression */ || callExpression.nodeType() === 38 /* ObjectCreationExpression */; + + if (foundAST.nodeType() === 31 /* SuperExpression */) { + if (symbol.kind === 8 /* Class */) { + callSignatures = (symbol).getConstructorMethod().type.getConstructSignatures(); + } + } else { + callSignatures = callExpression.nodeType() === 37 /* InvocationExpression */ ? typeSymbol.getCallSignatures() : typeSymbol.getConstructSignatures(); + } + + var callResolutionResults = new TypeScript.PullAdditionalCallResolutionData(); + if (callExpression.nodeType() === 37 /* InvocationExpression */) { + this.resolver.resolveInvocationExpression(callExpression, inContextuallyTypedAssignment, enclosingDecl, resolutionContext, callResolutionResults); + } else { + this.resolver.resolveObjectCreationExpression(callExpression, inContextuallyTypedAssignment, enclosingDecl, resolutionContext, callResolutionResults); + } + + if (callResolutionResults.candidateSignature) { + candidateSignature = callResolutionResults.candidateSignature; + } + if (callResolutionResults.targetSymbol && callResolutionResults.targetSymbol.name !== "") { + symbol = callResolutionResults.targetSymbol; + } + foundAST = callExpression; + } + } + } + + if (funcDecl) { + if (symbol && symbol.kind !== 4096 /* Property */) { + var signatureInfo = TypeScript.PullHelpers.getSignatureForFuncDecl(funcDecl, this.semanticInfoChain.getUnit(scriptName)); + candidateSignature = signatureInfo.signature; + callSignatures = signatureInfo.allSignatures; + } + } else if (!callSignatures && symbol && (symbol.kind === 65536 /* Method */ || symbol.kind === 16384 /* Function */)) { + var typeSym = symbol.type; + if (typeSym) { + callSignatures = typeSym.getCallSignatures(); + } + } + } + + var enclosingScopeSymbol = this.getSymbolOfDeclaration(enclosingDecl); + + return { + symbol: symbol, + ast: foundAST, + enclosingScopeSymbol: enclosingScopeSymbol, + candidateSignature: candidateSignature, + callSignatures: callSignatures, + isConstructorCall: isConstructorCall + }; + }; + + TypeScriptCompiler.prototype.extractResolutionContextFromPath = function (path, document, propagateContextualTypes) { + var script = document.script; + var scriptName = document.fileName; + + var semanticInfo = this.semanticInfoChain.getUnit(scriptName); + var enclosingDecl = null; + var enclosingDeclAST = null; + var inContextuallyTypedAssignment = false; + + TypeScript.globalSemanticInfoChain = this.semanticInfoChain; + if (TypeScript.globalBinder) { + TypeScript.globalBinder.semanticInfoChain = this.semanticInfoChain; + } + + var resolutionContext = new TypeScript.PullTypeResolutionContext(); + resolutionContext.resolveAggressively = true; + + if (path.count() === 0) { + return null; + } + + this.setUnit(semanticInfo.getPath()); + + for (var i = 0, n = path.count(); i < n; i++) { + var current = path.asts[i]; + + switch (current.nodeType()) { + case 13 /* FunctionDeclaration */: + if (TypeScript.hasFlag((current).getFunctionFlags(), 8192 /* IsFunctionExpression */)) { + this.resolver.resolveAST((current), true, enclosingDecl, resolutionContext); + } + + break; + + case 18 /* VariableDeclarator */: + var assigningAST = current; + inContextuallyTypedAssignment = (assigningAST.typeExpr !== null); + + if (inContextuallyTypedAssignment) { + if (propagateContextualTypes) { + this.resolver.resolveAST(assigningAST, false, null, resolutionContext); + var varSymbol = this.semanticInfoChain.getSymbolForAST(assigningAST, scriptName); + + var contextualType = null; + if (varSymbol && inContextuallyTypedAssignment) { + contextualType = varSymbol.type; + } + + resolutionContext.pushContextualType(contextualType, false, null); + + if (assigningAST.init) { + this.resolver.resolveAST(assigningAST.init, inContextuallyTypedAssignment, enclosingDecl, resolutionContext); + } + } + } + + break; + + case 37 /* InvocationExpression */: + case 38 /* ObjectCreationExpression */: + if (propagateContextualTypes) { + var isNew = current.nodeType() === 38 /* ObjectCreationExpression */; + var callExpression = current; + var contextualType = null; + + if ((i + 1 < n) && callExpression.arguments === path.asts[i + 1]) { + var callResolutionResults = new TypeScript.PullAdditionalCallResolutionData(); + if (isNew) { + this.resolver.resolveObjectCreationExpression(callExpression, inContextuallyTypedAssignment, enclosingDecl, resolutionContext, callResolutionResults); + } else { + this.resolver.resolveInvocationExpression(callExpression, inContextuallyTypedAssignment, enclosingDecl, resolutionContext, callResolutionResults); + } + + if (callResolutionResults.actualParametersContextTypeSymbols) { + var argExpression = (path.asts[i + 1] && path.asts[i + 1].nodeType() === 1 /* List */) ? path.asts[i + 2] : path.asts[i + 1]; + if (argExpression) { + for (var j = 0, m = callExpression.arguments.members.length; j < m; j++) { + if (callExpression.arguments.members[j] === argExpression) { + var callContextualType = callResolutionResults.actualParametersContextTypeSymbols[j]; + if (callContextualType) { + contextualType = callContextualType; + break; + } + } + } + } + } + } else { + if (isNew) { + this.resolver.resolveObjectCreationExpression(callExpression, inContextuallyTypedAssignment, enclosingDecl, resolutionContext); + } else { + this.resolver.resolveInvocationExpression(callExpression, inContextuallyTypedAssignment, enclosingDecl, resolutionContext); + } + } + + resolutionContext.pushContextualType(contextualType, false, null); + } + + break; + + case 22 /* ArrayLiteralExpression */: + if (propagateContextualTypes) { + var contextualType = null; + var currentContextualType = resolutionContext.getContextualType(); + if (currentContextualType && currentContextualType.isArray()) { + contextualType = currentContextualType.getElementType(); + } + + resolutionContext.pushContextualType(contextualType, false, null); + } + + break; + + case 23 /* ObjectLiteralExpression */: + if (propagateContextualTypes) { + var objectLiteralExpression = current; + var objectLiteralResolutionContext = new TypeScript.PullAdditionalObjectLiteralResolutionData(); + this.resolver.resolveObjectLiteralExpression(objectLiteralExpression, inContextuallyTypedAssignment, enclosingDecl, resolutionContext, objectLiteralResolutionContext); + + var memeberAST = (path.asts[i + 1] && path.asts[i + 1].nodeType() === 1 /* List */) ? path.asts[i + 2] : path.asts[i + 1]; + if (memeberAST) { + var contextualType = null; + var memberDecls = objectLiteralExpression.operand; + if (memberDecls && objectLiteralResolutionContext.membersContextTypeSymbols) { + for (var j = 0, m = memberDecls.members.length; j < m; j++) { + if (memberDecls.members[j] === memeberAST) { + var memberContextualType = objectLiteralResolutionContext.membersContextTypeSymbols[j]; + if (memberContextualType) { + contextualType = memberContextualType; + break; + } + } + } + } + + resolutionContext.pushContextualType(contextualType, false, null); + } + } + + break; + + case 39 /* AssignmentExpression */: + if (propagateContextualTypes) { + var assignmentExpression = current; + var contextualType = null; + + if (path.asts[i + 1] && path.asts[i + 1] === assignmentExpression.operand2) { + var leftType = this.resolver.resolveAST(assignmentExpression.operand1, inContextuallyTypedAssignment, enclosingDecl, resolutionContext).type; + if (leftType) { + inContextuallyTypedAssignment = true; + contextualType = leftType; + } + } + + resolutionContext.pushContextualType(contextualType, false, null); + } + + break; + + case 79 /* CastExpression */: + var castExpression = current; + + if (i + 1 < n && path.asts[i + 1] === castExpression.castTerm) { + resolutionContext.resolvingTypeReference = true; + } else { + if (propagateContextualTypes) { + var contextualType = null; + var typeSymbol = this.resolver.resolveTypeAssertionExpression(castExpression, inContextuallyTypedAssignment, enclosingDecl, resolutionContext); + + if (typeSymbol) { + inContextuallyTypedAssignment = true; + contextualType = typeSymbol; + } + + resolutionContext.pushContextualType(contextualType, false, null); + } + } + + break; + + case 94 /* ReturnStatement */: + if (propagateContextualTypes) { + var returnStatement = current; + var contextualType = null; + + if (enclosingDecl && (enclosingDecl.kind & TypeScript.PullElementKind.SomeFunction)) { + var functionDeclaration = enclosingDeclAST; + if (functionDeclaration.returnTypeAnnotation) { + var currentResolvingTypeReference = resolutionContext.resolvingTypeReference; + resolutionContext.resolvingTypeReference = true; + var returnTypeSymbol = this.resolver.resolveTypeReference(functionDeclaration.returnTypeAnnotation, enclosingDecl, resolutionContext); + resolutionContext.resolvingTypeReference = currentResolvingTypeReference; + if (returnTypeSymbol) { + inContextuallyTypedAssignment = true; + contextualType = returnTypeSymbol; + } + } else { + var currentContextualType = resolutionContext.getContextualType(); + if (currentContextualType && currentContextualType.isFunction()) { + var currentContextualTypeSignatureSymbol = currentContextualType.getDeclarations()[0].getSignatureSymbol(); + var currentContextualTypeReturnTypeSymbol = currentContextualTypeSignatureSymbol.returnType; + if (currentContextualTypeReturnTypeSymbol) { + inContextuallyTypedAssignment = true; + contextualType = currentContextualTypeReturnTypeSymbol; + } + } + } + } + + resolutionContext.pushContextualType(contextualType, false, null); + } + + break; + + case 11 /* TypeRef */: + case 9 /* TypeParameter */: + resolutionContext.resolvingTypeReference = true; + break; + + case 14 /* ClassDeclaration */: + var classDeclaration = current; + if (path.asts[i + 1]) { + if (path.asts[i + 1] === classDeclaration.extendsList || path.asts[i + 1] === classDeclaration.implementsList) { + resolutionContext.resolvingTypeReference = true; + } + } + + break; + + case 15 /* InterfaceDeclaration */: + var interfaceDeclaration = current; + if (path.asts[i + 1]) { + if (path.asts[i + 1] === interfaceDeclaration.extendsList || path.asts[i + 1] === interfaceDeclaration.implementsList || path.asts[i + 1] === interfaceDeclaration.name) { + resolutionContext.resolvingTypeReference = true; + } + } + + break; + } + + var decl = semanticInfo.getDeclForAST(current); + if (decl && !(decl.kind & (1024 /* Variable */ | 2048 /* Parameter */ | 8192 /* TypeParameter */))) { + enclosingDecl = decl; + enclosingDeclAST = current; + } + } + + if (path.ast().nodeType() === 21 /* Name */ && path.count() > 1) { + for (var i = path.count() - 1; i >= 0; i--) { + if (path.asts[path.top - 1].nodeType() === 33 /* MemberAccessExpression */ && (path.asts[path.top - 1]).operand2 === path.asts[path.top]) { + path.pop(); + } else { + break; + } + } + } + + return { + ast: path.ast(), + enclosingDecl: enclosingDecl, + resolutionContext: resolutionContext, + inContextuallyTypedAssignment: inContextuallyTypedAssignment + }; + }; + + TypeScriptCompiler.prototype.pullGetSymbolInformationFromPath = function (path, document) { + var context = this.extractResolutionContextFromPath(path, document, true); + if (!context) { + return null; + } + + TypeScript.globalSemanticInfoChain = this.semanticInfoChain; + if (TypeScript.globalBinder) { + TypeScript.globalBinder.semanticInfoChain = this.semanticInfoChain; + } + + var symbol = this.resolver.resolveAST(path.ast(), context.inContextuallyTypedAssignment, context.enclosingDecl, context.resolutionContext); + + return { + symbol: symbol, + ast: path.ast(), + enclosingScopeSymbol: this.getSymbolOfDeclaration(context.enclosingDecl) + }; + }; + + TypeScriptCompiler.prototype.pullGetDeclarationSymbolInformation = function (path, document) { + var script = document.script; + var scriptName = document.fileName; + + var ast = path.ast(); + + if (ast.nodeType() !== 14 /* ClassDeclaration */ && ast.nodeType() !== 15 /* InterfaceDeclaration */ && ast.nodeType() !== 16 /* ModuleDeclaration */ && ast.nodeType() !== 13 /* FunctionDeclaration */ && ast.nodeType() !== 18 /* VariableDeclarator */) { + return null; + } + + var context = this.extractResolutionContextFromPath(path, document, true); + if (!context) { + return null; + } + + TypeScript.globalSemanticInfoChain = this.semanticInfoChain; + if (TypeScript.globalBinder) { + TypeScript.globalBinder.semanticInfoChain = this.semanticInfoChain; + } + + var semanticInfo = this.semanticInfoChain.getUnit(scriptName); + var decl = semanticInfo.getDeclForAST(ast); + var symbol = (decl.kind & TypeScript.PullElementKind.SomeSignature) ? decl.getSignatureSymbol() : decl.getSymbol(); + this.resolver.resolveDeclaredSymbol(symbol, null, context.resolutionContext); + + symbol.setUnresolved(); + + return { + symbol: symbol, + ast: path.ast(), + enclosingScopeSymbol: this.getSymbolOfDeclaration(context.enclosingDecl) + }; + }; + + TypeScriptCompiler.prototype.pullGetCallInformationFromPath = function (path, document) { + if (path.ast().nodeType() !== 37 /* InvocationExpression */ && path.ast().nodeType() !== 38 /* ObjectCreationExpression */) { + return null; + } + + var isNew = (path.ast().nodeType() === 38 /* ObjectCreationExpression */); + + var context = this.extractResolutionContextFromPath(path, document, true); + if (!context) { + return null; + } + + TypeScript.globalSemanticInfoChain = this.semanticInfoChain; + if (TypeScript.globalBinder) { + TypeScript.globalBinder.semanticInfoChain = this.semanticInfoChain; + } + + var callResolutionResults = new TypeScript.PullAdditionalCallResolutionData(); + + if (isNew) { + this.resolver.resolveObjectCreationExpression(path.ast(), context.inContextuallyTypedAssignment, context.enclosingDecl, context.resolutionContext, callResolutionResults); + } else { + this.resolver.resolveInvocationExpression(path.ast(), context.inContextuallyTypedAssignment, context.enclosingDecl, context.resolutionContext, callResolutionResults); + } + + return { + targetSymbol: callResolutionResults.targetSymbol, + resolvedSignatures: callResolutionResults.resolvedSignatures, + candidateSignature: callResolutionResults.candidateSignature, + ast: path.ast(), + enclosingScopeSymbol: this.getSymbolOfDeclaration(context.enclosingDecl), + isConstructorCall: isNew + }; + }; + + TypeScriptCompiler.prototype.pullGetVisibleMemberSymbolsFromPath = function (path, document) { + TypeScript.globalSemanticInfoChain = this.semanticInfoChain; + if (TypeScript.globalBinder) { + TypeScript.globalBinder.semanticInfoChain = this.semanticInfoChain; + } + + var context = this.extractResolutionContextFromPath(path, document, true); + if (!context) { + return null; + } + + var symbols = this.resolver.getVisibleMembersFromExpression(path.ast(), context.enclosingDecl, context.resolutionContext); + if (!symbols) { + return null; + } + + return { + symbols: symbols, + enclosingScopeSymbol: this.getSymbolOfDeclaration(context.enclosingDecl) + }; + }; + + TypeScriptCompiler.prototype.pullGetVisibleDeclsFromPath = function (path, document) { + TypeScript.globalSemanticInfoChain = this.semanticInfoChain; + if (TypeScript.globalBinder) { + TypeScript.globalBinder.semanticInfoChain = this.semanticInfoChain; + } + + var context = this.extractResolutionContextFromPath(path, document, false); + if (!context) { + return null; + } + + return this.resolver.getVisibleDecls(context.enclosingDecl, context.resolutionContext); + }; + + TypeScriptCompiler.prototype.pullGetContextualMembersFromPath = function (path, document) { + TypeScript.globalSemanticInfoChain = this.semanticInfoChain; + if (TypeScript.globalBinder) { + TypeScript.globalBinder.semanticInfoChain = this.semanticInfoChain; + } + + if (path.ast().nodeType() !== 23 /* ObjectLiteralExpression */) { + return null; + } + + var context = this.extractResolutionContextFromPath(path, document, true); + if (!context) { + return null; + } + + var members = this.resolver.getVisibleContextSymbols(context.enclosingDecl, context.resolutionContext); + + return { + symbols: members, + enclosingScopeSymbol: this.getSymbolOfDeclaration(context.enclosingDecl) + }; + }; + + TypeScriptCompiler.prototype.pullGetDeclInformation = function (decl, path, document) { + var context = this.extractResolutionContextFromPath(path, document, true); + if (!context) { + return null; + } + + TypeScript.globalSemanticInfoChain = this.semanticInfoChain; + if (TypeScript.globalBinder) { + TypeScript.globalBinder.semanticInfoChain = this.semanticInfoChain; + } + + var symbol = decl.getSymbol(); + this.resolver.resolveDeclaredSymbol(symbol, context.enclosingDecl, context.resolutionContext); + symbol.setUnresolved(); + + return { + symbol: symbol, + ast: path.ast(), + enclosingScopeSymbol: this.getSymbolOfDeclaration(context.enclosingDecl) + }; + }; + + TypeScriptCompiler.prototype.pullGetTypeInfoAtPosition = function (pos, document) { + var _this = this; + return this.timeFunction("pullGetTypeInfoAtPosition for pos " + pos + ":", function () { + return _this.resolvePosition(pos, document); + }); + }; + + TypeScriptCompiler.prototype.getTopLevelDeclarations = function (scriptName) { + var unit = this.semanticInfoChain.getUnit(scriptName); + + if (!unit) { + return null; + } + + return unit.getTopLevelDecls(); + }; + + TypeScriptCompiler.prototype.reportDiagnostics = function (errors, errorReporter) { + for (var i = 0; i < errors.length; i++) { + errorReporter.addDiagnostic(errors[i]); + } + }; + return TypeScriptCompiler; + })(); + TypeScript.TypeScriptCompiler = TypeScriptCompiler; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var ASTSpan = (function () { + function ASTSpan() { + this.minChar = -1; + this.limChar = -1; + this.trailingTriviaWidth = 0; + } + return ASTSpan; + })(); + TypeScript.ASTSpan = ASTSpan; + + var astID = 0; + + function structuralEqualsNotIncludingPosition(ast1, ast2) { + return structuralEquals(ast1, ast2, false); + } + TypeScript.structuralEqualsNotIncludingPosition = structuralEqualsNotIncludingPosition; + + function structuralEqualsIncludingPosition(ast1, ast2) { + return structuralEquals(ast1, ast2, true); + } + TypeScript.structuralEqualsIncludingPosition = structuralEqualsIncludingPosition; + + function structuralEquals(ast1, ast2, includingPosition) { + if (ast1 === ast2) { + return true; + } + + return ast1 !== null && ast2 !== null && ast1.nodeType() === ast2.nodeType() && ast1.structuralEquals(ast2, includingPosition); + } + + function astArrayStructuralEquals(array1, array2, includingPosition) { + return TypeScript.ArrayUtilities.sequenceEquals(array1, array2, includingPosition ? structuralEqualsIncludingPosition : structuralEqualsNotIncludingPosition); + } + + var AST = (function () { + function AST() { + this.minChar = -1; + this.limChar = -1; + this.trailingTriviaWidth = 0; + this._flags = 0 /* None */; + this.typeCheckPhase = -1; + this.astIDString = astID.toString(); + this.astID = astID++; + this.symbol = null; + this.aliasSymbol = null; + this.decl = null; + this._preComments = null; + this._postComments = null; + this._docComments = null; + } + AST.prototype.nodeType = function () { + throw TypeScript.Errors.abstract(); + }; + + AST.prototype.isStatement = function () { + return false; + }; + + AST.prototype.preComments = function () { + return this._preComments; + }; + + AST.prototype.postComments = function () { + return this._postComments; + }; + + AST.prototype.setPreComments = function (comments) { + if (comments && comments.length) { + this._preComments = comments; + } else if (this._preComments) { + this._preComments = null; + } + }; + + AST.prototype.setPostComments = function (comments) { + if (comments && comments.length) { + this._postComments = comments; + } else if (this._postComments) { + this._postComments = null; + } + }; + + AST.prototype.shouldEmit = function () { + return true; + }; + + AST.prototype.getFlags = function () { + return this._flags; + }; + + AST.prototype.setFlags = function (flags) { + this._flags = flags; + }; + + AST.prototype.getLength = function () { + return this.limChar - this.minChar; + }; + + AST.prototype.isDeclaration = function () { + return false; + }; + + AST.prototype.emit = function (emitter) { + emitter.emitComments(this, true); + emitter.recordSourceMappingStart(this); + this.emitWorker(emitter); + emitter.recordSourceMappingEnd(this); + emitter.emitComments(this, false); + }; + + AST.prototype.emitWorker = function (emitter) { + throw TypeScript.Errors.abstract(); + }; + + AST.prototype.docComments = function () { + if (!this.isDeclaration() || !this.preComments() || this.preComments().length === 0) { + return []; + } + + if (!this._docComments) { + var preComments = this.preComments(); + var preCommentsLength = preComments.length; + var docComments = new Array(); + for (var i = preCommentsLength - 1; i >= 0; i--) { + if (preComments[i].isDocComment()) { + docComments.push(preComments[i]); + continue; + } + break; + } + + this._docComments = docComments.reverse(); + } + + return this._docComments; + }; + + AST.prototype.structuralEquals = function (ast, includingPosition) { + if (includingPosition) { + if (this.minChar !== ast.minChar || this.limChar !== ast.limChar) { + return false; + } + } + + return this._flags === ast._flags && astArrayStructuralEquals(this.preComments(), ast.preComments(), includingPosition) && astArrayStructuralEquals(this.postComments(), ast.postComments(), includingPosition); + }; + return AST; + })(); + TypeScript.AST = AST; + + var ASTList = (function (_super) { + __extends(ASTList, _super); + function ASTList(members, separatorCount) { + _super.call(this); + this.members = members; + this.separatorCount = separatorCount; + } + ASTList.prototype.nodeType = function () { + return 1 /* List */; + }; + + ASTList.prototype.emit = function (emitter) { + emitter.recordSourceMappingStart(this); + emitter.emitModuleElements(this); + emitter.recordSourceMappingEnd(this); + }; + + ASTList.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && astArrayStructuralEquals(this.members, ast.members, includingPosition); + }; + return ASTList; + })(AST); + TypeScript.ASTList = ASTList; + + var Identifier = (function (_super) { + __extends(Identifier, _super); + function Identifier(actualText, text) { + _super.call(this); + this.actualText = actualText; + this._text = text; + } + Identifier.prototype.text = function () { + if (!this._text) { + this._text = TypeScript.Syntax.massageEscapes(this.actualText); + } + + return this._text; + }; + + Identifier.prototype.nodeType = function () { + return 21 /* Name */; + }; + + Identifier.prototype.isMissing = function () { + return false; + }; + + Identifier.prototype.emit = function (emitter) { + emitter.emitName(this, true); + }; + + Identifier.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && this.actualText === ast.actualText && this.isMissing() === ast.isMissing(); + }; + return Identifier; + })(AST); + TypeScript.Identifier = Identifier; + + var MissingIdentifier = (function (_super) { + __extends(MissingIdentifier, _super); + function MissingIdentifier() { + _super.call(this, "__missing", "__missing"); + } + MissingIdentifier.prototype.isMissing = function () { + return true; + }; + + MissingIdentifier.prototype.emit = function (emitter) { + }; + return MissingIdentifier; + })(Identifier); + TypeScript.MissingIdentifier = MissingIdentifier; + + var LiteralExpression = (function (_super) { + __extends(LiteralExpression, _super); + function LiteralExpression(_nodeType) { + _super.call(this); + this._nodeType = _nodeType; + } + LiteralExpression.prototype.nodeType = function () { + return this._nodeType; + }; + + LiteralExpression.prototype.emitWorker = function (emitter) { + switch (this.nodeType()) { + case 8 /* NullLiteral */: + emitter.writeToOutput("null"); + break; + case 4 /* FalseLiteral */: + emitter.writeToOutput("false"); + break; + case 3 /* TrueLiteral */: + emitter.writeToOutput("true"); + break; + default: + throw TypeScript.Errors.abstract(); + } + }; + + LiteralExpression.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition); + }; + return LiteralExpression; + })(AST); + TypeScript.LiteralExpression = LiteralExpression; + + var ThisExpression = (function (_super) { + __extends(ThisExpression, _super); + function ThisExpression() { + _super.apply(this, arguments); + } + ThisExpression.prototype.nodeType = function () { + return 30 /* ThisExpression */; + }; + + ThisExpression.prototype.emitWorker = function (emitter) { + if (emitter.thisFunctionDeclaration && (TypeScript.hasFlag(emitter.thisFunctionDeclaration.getFunctionFlags(), 2048 /* IsFatArrowFunction */))) { + emitter.writeToOutput("_this"); + } else { + emitter.writeToOutput("this"); + } + }; + + ThisExpression.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition); + }; + return ThisExpression; + })(AST); + TypeScript.ThisExpression = ThisExpression; + + var SuperExpression = (function (_super) { + __extends(SuperExpression, _super); + function SuperExpression() { + _super.apply(this, arguments); + } + SuperExpression.prototype.nodeType = function () { + return 31 /* SuperExpression */; + }; + + SuperExpression.prototype.emitWorker = function (emitter) { + emitter.emitSuperReference(); + }; + + SuperExpression.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition); + }; + return SuperExpression; + })(AST); + TypeScript.SuperExpression = SuperExpression; + + var ParenthesizedExpression = (function (_super) { + __extends(ParenthesizedExpression, _super); + function ParenthesizedExpression(expression) { + _super.call(this); + this.expression = expression; + } + ParenthesizedExpression.prototype.nodeType = function () { + return 80 /* ParenthesizedExpression */; + }; + + ParenthesizedExpression.prototype.emitWorker = function (emitter) { + emitter.writeToOutput("("); + this.expression.emit(emitter); + emitter.writeToOutput(")"); + }; + + ParenthesizedExpression.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.expression, ast.expression, includingPosition); + }; + return ParenthesizedExpression; + })(AST); + TypeScript.ParenthesizedExpression = ParenthesizedExpression; + + var UnaryExpression = (function (_super) { + __extends(UnaryExpression, _super); + function UnaryExpression(_nodeType, operand, castTerm) { + _super.call(this); + this._nodeType = _nodeType; + this.operand = operand; + this.castTerm = castTerm; + } + UnaryExpression.prototype.nodeType = function () { + return this._nodeType; + }; + + UnaryExpression.prototype.emitWorker = function (emitter) { + switch (this.nodeType()) { + case 77 /* PostIncrementExpression */: + this.operand.emit(emitter); + emitter.writeToOutput("++"); + break; + case 74 /* LogicalNotExpression */: + emitter.writeToOutput("!"); + this.operand.emit(emitter); + break; + case 78 /* PostDecrementExpression */: + this.operand.emit(emitter); + emitter.writeToOutput("--"); + break; + case 23 /* ObjectLiteralExpression */: + emitter.emitObjectLiteral(this); + break; + case 22 /* ArrayLiteralExpression */: + emitter.emitArrayLiteral(this); + break; + case 73 /* BitwiseNotExpression */: + emitter.writeToOutput("~"); + this.operand.emit(emitter); + break; + case 28 /* NegateExpression */: + emitter.writeToOutput("-"); + if (this.operand.nodeType() === 28 /* NegateExpression */ || this.operand.nodeType() === 76 /* PreDecrementExpression */) { + emitter.writeToOutput(" "); + } + this.operand.emit(emitter); + break; + case 27 /* PlusExpression */: + emitter.writeToOutput("+"); + if (this.operand.nodeType() === 27 /* PlusExpression */ || this.operand.nodeType() === 75 /* PreIncrementExpression */) { + emitter.writeToOutput(" "); + } + this.operand.emit(emitter); + break; + case 75 /* PreIncrementExpression */: + emitter.writeToOutput("++"); + this.operand.emit(emitter); + break; + case 76 /* PreDecrementExpression */: + emitter.writeToOutput("--"); + this.operand.emit(emitter); + break; + case 35 /* TypeOfExpression */: + emitter.writeToOutput("typeof "); + this.operand.emit(emitter); + break; + case 29 /* DeleteExpression */: + emitter.writeToOutput("delete "); + this.operand.emit(emitter); + break; + case 25 /* VoidExpression */: + emitter.writeToOutput("void "); + this.operand.emit(emitter); + break; + case 79 /* CastExpression */: + this.operand.emit(emitter); + break; + default: + throw TypeScript.Errors.abstract(); + } + }; + + UnaryExpression.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.castTerm, ast.castTerm, includingPosition) && structuralEquals(this.operand, ast.operand, includingPosition); + }; + return UnaryExpression; + })(AST); + TypeScript.UnaryExpression = UnaryExpression; + + var ObjectCreationExpression = (function (_super) { + __extends(ObjectCreationExpression, _super); + function ObjectCreationExpression(target, typeArguments, arguments, closeParenSpan) { + _super.call(this); + this.target = target; + this.typeArguments = typeArguments; + this.arguments = arguments; + this.closeParenSpan = closeParenSpan; + this.callResolutionData = null; + } + ObjectCreationExpression.prototype.nodeType = function () { + return 38 /* ObjectCreationExpression */; + }; + + ObjectCreationExpression.prototype.emitWorker = function (emitter) { + emitter.emitNew(this, this.target, this.arguments); + }; + + ObjectCreationExpression.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.target, ast.target, includingPosition) && structuralEquals(this.typeArguments, ast.typeArguments, includingPosition) && structuralEquals(this.arguments, ast.arguments, includingPosition); + }; + return ObjectCreationExpression; + })(AST); + TypeScript.ObjectCreationExpression = ObjectCreationExpression; + + var InvocationExpression = (function (_super) { + __extends(InvocationExpression, _super); + function InvocationExpression(target, typeArguments, arguments, closeParenSpan) { + _super.call(this); + this.target = target; + this.typeArguments = typeArguments; + this.arguments = arguments; + this.closeParenSpan = closeParenSpan; + this.callResolutionData = null; + } + InvocationExpression.prototype.nodeType = function () { + return 37 /* InvocationExpression */; + }; + + InvocationExpression.prototype.emitWorker = function (emitter) { + emitter.emitCall(this, this.target, this.arguments); + }; + + InvocationExpression.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.target, ast.target, includingPosition) && structuralEquals(this.typeArguments, ast.typeArguments, includingPosition) && structuralEquals(this.arguments, ast.arguments, includingPosition); + }; + return InvocationExpression; + })(AST); + TypeScript.InvocationExpression = InvocationExpression; + + var BinaryExpression = (function (_super) { + __extends(BinaryExpression, _super); + function BinaryExpression(_nodeType, operand1, operand2) { + _super.call(this); + this._nodeType = _nodeType; + this.operand1 = operand1; + this.operand2 = operand2; + } + BinaryExpression.prototype.nodeType = function () { + return this._nodeType; + }; + + BinaryExpression.getTextForBinaryToken = function (nodeType) { + switch (nodeType) { + case 26 /* CommaExpression */: + return ","; + case 39 /* AssignmentExpression */: + return "="; + case 40 /* AddAssignmentExpression */: + return "+="; + case 41 /* SubtractAssignmentExpression */: + return "-="; + case 43 /* MultiplyAssignmentExpression */: + return "*="; + case 42 /* DivideAssignmentExpression */: + return "/="; + case 44 /* ModuloAssignmentExpression */: + return "%="; + case 45 /* AndAssignmentExpression */: + return "&="; + case 46 /* ExclusiveOrAssignmentExpression */: + return "^="; + case 47 /* OrAssignmentExpression */: + return "|="; + case 48 /* LeftShiftAssignmentExpression */: + return "<<="; + case 49 /* SignedRightShiftAssignmentExpression */: + return ">>="; + case 50 /* UnsignedRightShiftAssignmentExpression */: + return ">>>="; + case 52 /* LogicalOrExpression */: + return "||"; + case 53 /* LogicalAndExpression */: + return "&&"; + case 54 /* BitwiseOrExpression */: + return "|"; + case 55 /* BitwiseExclusiveOrExpression */: + return "^"; + case 56 /* BitwiseAndExpression */: + return "&"; + case 57 /* EqualsWithTypeConversionExpression */: + return "=="; + case 58 /* NotEqualsWithTypeConversionExpression */: + return "!="; + case 59 /* EqualsExpression */: + return "==="; + case 60 /* NotEqualsExpression */: + return "!=="; + case 61 /* LessThanExpression */: + return "<"; + case 63 /* GreaterThanExpression */: + return ">"; + case 62 /* LessThanOrEqualExpression */: + return "<="; + case 64 /* GreaterThanOrEqualExpression */: + return ">="; + case 34 /* InstanceOfExpression */: + return "instanceof"; + case 32 /* InExpression */: + return "in"; + case 70 /* LeftShiftExpression */: + return "<<"; + case 71 /* SignedRightShiftExpression */: + return ">>"; + case 72 /* UnsignedRightShiftExpression */: + return ">>>"; + case 67 /* MultiplyExpression */: + return "*"; + case 68 /* DivideExpression */: + return "/"; + case 69 /* ModuloExpression */: + return "%"; + case 65 /* AddExpression */: + return "+"; + case 66 /* SubtractExpression */: + return "-"; + } + + throw TypeScript.Errors.invalidOperation(); + }; + + BinaryExpression.prototype.emitWorker = function (emitter) { + switch (this.nodeType()) { + case 33 /* MemberAccessExpression */: + if (!emitter.tryEmitConstant(this)) { + this.operand1.emit(emitter); + emitter.writeToOutput("."); + emitter.emitName(this.operand2, false); + } + break; + case 36 /* ElementAccessExpression */: + emitter.emitIndex(this.operand1, this.operand2); + break; + + case 81 /* Member */: + if (this.operand2.nodeType() === 13 /* FunctionDeclaration */ && (this.operand2).isAccessor()) { + var funcDecl = this.operand2; + if (TypeScript.hasFlag(funcDecl.getFunctionFlags(), 32 /* GetAccessor */)) { + emitter.writeToOutput("get "); + } else { + emitter.writeToOutput("set "); + } + this.operand1.emit(emitter); + } else { + this.operand1.emit(emitter); + emitter.writeToOutputTrimmable(": "); + } + this.operand2.emit(emitter); + break; + case 26 /* CommaExpression */: + this.operand1.emit(emitter); + emitter.writeToOutput(", "); + this.operand2.emit(emitter); + break; + default: { + this.operand1.emit(emitter); + var binOp = BinaryExpression.getTextForBinaryToken(this.nodeType()); + if (binOp === "instanceof") { + emitter.writeToOutput(" instanceof "); + } else if (binOp === "in") { + emitter.writeToOutput(" in "); + } else { + emitter.writeToOutputTrimmable(" " + binOp + " "); + } + this.operand2.emit(emitter); + } + } + }; + + BinaryExpression.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.operand1, ast.operand1, includingPosition) && structuralEquals(this.operand2, ast.operand2, includingPosition); + }; + return BinaryExpression; + })(AST); + TypeScript.BinaryExpression = BinaryExpression; + + var ConditionalExpression = (function (_super) { + __extends(ConditionalExpression, _super); + function ConditionalExpression(operand1, operand2, operand3) { + _super.call(this); + this.operand1 = operand1; + this.operand2 = operand2; + this.operand3 = operand3; + } + ConditionalExpression.prototype.nodeType = function () { + return 51 /* ConditionalExpression */; + }; + + ConditionalExpression.prototype.emitWorker = function (emitter) { + this.operand1.emit(emitter); + emitter.writeToOutput(" ? "); + this.operand2.emit(emitter); + emitter.writeToOutput(" : "); + this.operand3.emit(emitter); + }; + + ConditionalExpression.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.operand1, ast.operand1, includingPosition) && structuralEquals(this.operand2, ast.operand2, includingPosition) && structuralEquals(this.operand3, ast.operand3, includingPosition); + }; + return ConditionalExpression; + })(AST); + TypeScript.ConditionalExpression = ConditionalExpression; + + var NumberLiteral = (function (_super) { + __extends(NumberLiteral, _super); + function NumberLiteral(value, text) { + _super.call(this); + this.value = value; + this._text = text; + } + NumberLiteral.prototype.text = function () { + return this._text; + }; + + NumberLiteral.prototype.nodeType = function () { + return 7 /* NumericLiteral */; + }; + + NumberLiteral.prototype.emitWorker = function (emitter) { + emitter.writeToOutput(this._text); + }; + + NumberLiteral.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && this.value === ast.value && this._text === ast._text; + }; + return NumberLiteral; + })(AST); + TypeScript.NumberLiteral = NumberLiteral; + + var RegexLiteral = (function (_super) { + __extends(RegexLiteral, _super); + function RegexLiteral(text) { + _super.call(this); + this.text = text; + } + RegexLiteral.prototype.nodeType = function () { + return 6 /* RegularExpressionLiteral */; + }; + + RegexLiteral.prototype.emitWorker = function (emitter) { + emitter.writeToOutput(this.text); + }; + + RegexLiteral.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && this.text === ast.text; + }; + return RegexLiteral; + })(AST); + TypeScript.RegexLiteral = RegexLiteral; + + var StringLiteral = (function (_super) { + __extends(StringLiteral, _super); + function StringLiteral(actualText, text) { + _super.call(this); + this.actualText = actualText; + this._text = text; + } + StringLiteral.prototype.text = function () { + return this._text; + }; + + StringLiteral.prototype.nodeType = function () { + return 5 /* StringLiteral */; + }; + + StringLiteral.prototype.emitWorker = function (emitter) { + emitter.writeToOutput(this.actualText); + }; + + StringLiteral.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && this.actualText === ast.actualText; + }; + return StringLiteral; + })(AST); + TypeScript.StringLiteral = StringLiteral; + + var ImportDeclaration = (function (_super) { + __extends(ImportDeclaration, _super); + function ImportDeclaration(id, alias) { + _super.call(this); + this.id = id; + this.alias = alias; + this._varFlags = 0 /* None */; + } + ImportDeclaration.prototype.nodeType = function () { + return 17 /* ImportDeclaration */; + }; + + ImportDeclaration.prototype.isDeclaration = function () { + return true; + }; + + ImportDeclaration.prototype.getVarFlags = function () { + return this._varFlags; + }; + + ImportDeclaration.prototype.setVarFlags = function (flags) { + this._varFlags = flags; + }; + + ImportDeclaration.prototype.isExternalImportDeclaration = function () { + if (this.alias.nodeType() == 21 /* Name */) { + var text = (this.alias).actualText; + return TypeScript.isQuoted(text); + } + + return false; + }; + + ImportDeclaration.prototype.emit = function (emitter) { + emitter.emitImportDeclaration(this); + }; + + ImportDeclaration.prototype.getAliasName = function (aliasAST) { + if (typeof aliasAST === "undefined") { aliasAST = this.alias; } + if (aliasAST.nodeType() == 11 /* TypeRef */) { + aliasAST = (aliasAST).term; + } + + if (aliasAST.nodeType() === 21 /* Name */) { + return (aliasAST).actualText; + } else { + var dotExpr = aliasAST; + return this.getAliasName(dotExpr.operand1) + "." + this.getAliasName(dotExpr.operand2); + } + }; + + ImportDeclaration.prototype.firstAliasedModToString = function () { + if (this.alias.nodeType() === 21 /* Name */) { + return (this.alias).actualText; + } else { + var dotExpr = this.alias; + var firstMod = (dotExpr.term).operand1; + return firstMod.actualText; + } + }; + + ImportDeclaration.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && this._varFlags === ast._varFlags && structuralEquals(this.id, ast.id, includingPosition) && structuralEquals(this.alias, ast.alias, includingPosition); + }; + return ImportDeclaration; + })(AST); + TypeScript.ImportDeclaration = ImportDeclaration; + + var ExportAssignment = (function (_super) { + __extends(ExportAssignment, _super); + function ExportAssignment(id) { + _super.call(this); + this.id = id; + } + ExportAssignment.prototype.nodeType = function () { + return 88 /* ExportAssignment */; + }; + + ExportAssignment.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.id, ast.id, includingPosition); + }; + + ExportAssignment.prototype.emit = function (emitter) { + emitter.setExportAssignmentIdentifier(this.id.actualText); + }; + return ExportAssignment; + })(AST); + TypeScript.ExportAssignment = ExportAssignment; + + var BoundDecl = (function (_super) { + __extends(BoundDecl, _super); + function BoundDecl(id, typeExpr, init) { + _super.call(this); + this.id = id; + this.typeExpr = typeExpr; + this.init = init; + this.constantValue = null; + this._varFlags = 0 /* None */; + } + BoundDecl.prototype.isDeclaration = function () { + return true; + }; + + BoundDecl.prototype.getVarFlags = function () { + return this._varFlags; + }; + + BoundDecl.prototype.setVarFlags = function (flags) { + this._varFlags = flags; + }; + + BoundDecl.prototype.isProperty = function () { + return TypeScript.hasFlag(this.getVarFlags(), 256 /* Property */); + }; + + BoundDecl.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && this._varFlags === ast._varFlags && structuralEquals(this.init, ast.init, includingPosition) && structuralEquals(this.typeExpr, ast.typeExpr, includingPosition) && structuralEquals(this.id, ast.id, includingPosition); + }; + return BoundDecl; + })(AST); + TypeScript.BoundDecl = BoundDecl; + + var VariableDeclarator = (function (_super) { + __extends(VariableDeclarator, _super); + function VariableDeclarator(id, typeExpr, init) { + _super.call(this, id, typeExpr, init); + } + VariableDeclarator.prototype.nodeType = function () { + return 18 /* VariableDeclarator */; + }; + + VariableDeclarator.prototype.isStatic = function () { + return TypeScript.hasFlag(this.getVarFlags(), 16 /* Static */); + }; + + VariableDeclarator.prototype.emit = function (emitter) { + emitter.emitVariableDeclarator(this); + }; + return VariableDeclarator; + })(BoundDecl); + TypeScript.VariableDeclarator = VariableDeclarator; + + var Parameter = (function (_super) { + __extends(Parameter, _super); + function Parameter(id, typeExpr, init, isOptional) { + _super.call(this, id, typeExpr, init); + this.isOptional = isOptional; + } + Parameter.prototype.nodeType = function () { + return 20 /* Parameter */; + }; + + Parameter.prototype.isOptionalArg = function () { + return this.isOptional || this.init; + }; + + Parameter.prototype.emitWorker = function (emitter) { + emitter.writeToOutput(this.id.actualText); + }; + + Parameter.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && this.isOptional === ast.isOptional; + }; + return Parameter; + })(BoundDecl); + TypeScript.Parameter = Parameter; + + var FunctionDeclaration = (function (_super) { + __extends(FunctionDeclaration, _super); + function FunctionDeclaration(name, block, isConstructor, typeArguments, arguments, returnTypeAnnotation, variableArgList) { + _super.call(this); + this.name = name; + this.block = block; + this.isConstructor = isConstructor; + this.typeArguments = typeArguments; + this.arguments = arguments; + this.returnTypeAnnotation = returnTypeAnnotation; + this.variableArgList = variableArgList; + this.hint = null; + this._functionFlags = 0 /* None */; + this.classDecl = null; + } + FunctionDeclaration.prototype.isDeclaration = function () { + return true; + }; + + FunctionDeclaration.prototype.nodeType = function () { + return 13 /* FunctionDeclaration */; + }; + + FunctionDeclaration.prototype.getFunctionFlags = function () { + return this._functionFlags; + }; + + FunctionDeclaration.prototype.setFunctionFlags = function (flags) { + this._functionFlags = flags; + }; + + FunctionDeclaration.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && this._functionFlags === ast._functionFlags && this.hint === ast.hint && this.variableArgList === ast.variableArgList && structuralEquals(this.name, ast.name, includingPosition) && structuralEquals(this.block, ast.block, includingPosition) && this.isConstructor === ast.isConstructor && structuralEquals(this.typeArguments, ast.typeArguments, includingPosition) && structuralEquals(this.arguments, ast.arguments, includingPosition); + }; + + FunctionDeclaration.prototype.shouldEmit = function () { + return !TypeScript.hasFlag(this.getFunctionFlags(), 128 /* Signature */) && !TypeScript.hasFlag(this.getFunctionFlags(), 8 /* Ambient */); + }; + + FunctionDeclaration.prototype.emit = function (emitter) { + emitter.emitFunction(this); + }; + + FunctionDeclaration.prototype.getNameText = function () { + if (this.name) { + return this.name.actualText; + } else { + return this.hint; + } + }; + + FunctionDeclaration.prototype.isMethod = function () { + return (this.getFunctionFlags() & 256 /* Method */) !== 0 /* None */; + }; + + FunctionDeclaration.prototype.isCallMember = function () { + return TypeScript.hasFlag(this.getFunctionFlags(), 512 /* CallMember */); + }; + FunctionDeclaration.prototype.isConstructMember = function () { + return TypeScript.hasFlag(this.getFunctionFlags(), 1024 /* ConstructMember */); + }; + FunctionDeclaration.prototype.isIndexerMember = function () { + return TypeScript.hasFlag(this.getFunctionFlags(), 4096 /* IndexerMember */); + }; + FunctionDeclaration.prototype.isSpecialFn = function () { + return this.isCallMember() || this.isIndexerMember() || this.isConstructMember(); + }; + FunctionDeclaration.prototype.isAccessor = function () { + return TypeScript.hasFlag(this.getFunctionFlags(), 32 /* GetAccessor */) || TypeScript.hasFlag(this.getFunctionFlags(), 64 /* SetAccessor */); + }; + FunctionDeclaration.prototype.isGetAccessor = function () { + return TypeScript.hasFlag(this.getFunctionFlags(), 32 /* GetAccessor */); + }; + FunctionDeclaration.prototype.isSetAccessor = function () { + return TypeScript.hasFlag(this.getFunctionFlags(), 64 /* SetAccessor */); + }; + FunctionDeclaration.prototype.isStatic = function () { + return TypeScript.hasFlag(this.getFunctionFlags(), 16 /* Static */); + }; + + FunctionDeclaration.prototype.isSignature = function () { + return (this.getFunctionFlags() & 128 /* Signature */) !== 0 /* None */; + }; + return FunctionDeclaration; + })(AST); + TypeScript.FunctionDeclaration = FunctionDeclaration; + + var Script = (function (_super) { + __extends(Script, _super); + function Script() { + _super.apply(this, arguments); + this.moduleElements = null; + this.referencedFiles = new Array(); + this.isDeclareFile = false; + this.topLevelMod = null; + } + Script.prototype.nodeType = function () { + return 2 /* Script */; + }; + + Script.prototype.emit = function (emitter) { + if (!this.isDeclareFile) { + emitter.emitScriptElements(this); + } + }; + + Script.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.moduleElements, ast.moduleElements, includingPosition); + }; + return Script; + })(AST); + TypeScript.Script = Script; + + var ModuleDeclaration = (function (_super) { + __extends(ModuleDeclaration, _super); + function ModuleDeclaration(name, members, endingToken) { + _super.call(this); + this.name = name; + this.members = members; + this.endingToken = endingToken; + this._moduleFlags = 0 /* None */; + this.amdDependencies = new Array(); + + this.prettyName = this.name.actualText; + } + ModuleDeclaration.prototype.isDeclaration = function () { + return true; + }; + + ModuleDeclaration.prototype.nodeType = function () { + return 16 /* ModuleDeclaration */; + }; + + ModuleDeclaration.prototype.getModuleFlags = function () { + return this._moduleFlags; + }; + + ModuleDeclaration.prototype.setModuleFlags = function (flags) { + this._moduleFlags = flags; + }; + + ModuleDeclaration.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && this._moduleFlags === ast._moduleFlags && structuralEquals(this.name, ast.name, includingPosition) && structuralEquals(this.members, ast.members, includingPosition); + }; + + ModuleDeclaration.prototype.isEnum = function () { + return TypeScript.hasFlag(this.getModuleFlags(), 128 /* IsEnum */); + }; + ModuleDeclaration.prototype.isWholeFile = function () { + return TypeScript.hasFlag(this.getModuleFlags(), 256 /* IsWholeFile */); + }; + + ModuleDeclaration.prototype.shouldEmit = function () { + if (TypeScript.hasFlag(this.getModuleFlags(), 8 /* Ambient */)) { + return false; + } + + if (TypeScript.hasFlag(this.getModuleFlags(), 128 /* IsEnum */)) { + return true; + } + + for (var i = 0, n = this.members.members.length; i < n; i++) { + var member = this.members.members[i]; + + if (member.nodeType() === 16 /* ModuleDeclaration */) { + if ((member).shouldEmit()) { + return true; + } + } else if (member.nodeType() !== 15 /* InterfaceDeclaration */) { + return true; + } + } + + return false; + }; + + ModuleDeclaration.prototype.emit = function (emitter) { + if (this.shouldEmit()) { + emitter.emitComments(this, true); + emitter.emitModule(this); + emitter.emitComments(this, false); + } + }; + return ModuleDeclaration; + })(AST); + TypeScript.ModuleDeclaration = ModuleDeclaration; + + var TypeDeclaration = (function (_super) { + __extends(TypeDeclaration, _super); + function TypeDeclaration(name, typeParameters, extendsList, implementsList, members) { + _super.call(this); + this.name = name; + this.typeParameters = typeParameters; + this.extendsList = extendsList; + this.implementsList = implementsList; + this.members = members; + this._varFlags = 0 /* None */; + } + TypeDeclaration.prototype.isDeclaration = function () { + return true; + }; + + TypeDeclaration.prototype.getVarFlags = function () { + return this._varFlags; + }; + + TypeDeclaration.prototype.setVarFlags = function (flags) { + this._varFlags = flags; + }; + + TypeDeclaration.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && this._varFlags === ast._varFlags && structuralEquals(this.name, ast.name, includingPosition) && structuralEquals(this.members, ast.members, includingPosition) && structuralEquals(this.typeParameters, ast.typeParameters, includingPosition) && structuralEquals(this.extendsList, ast.extendsList, includingPosition) && structuralEquals(this.implementsList, ast.implementsList, includingPosition); + }; + return TypeDeclaration; + })(AST); + TypeScript.TypeDeclaration = TypeDeclaration; + + var ClassDeclaration = (function (_super) { + __extends(ClassDeclaration, _super); + function ClassDeclaration(name, typeParameters, members, extendsList, implementsList, endingToken) { + _super.call(this, name, typeParameters, extendsList, implementsList, members); + this.endingToken = endingToken; + this.constructorDecl = null; + } + ClassDeclaration.prototype.nodeType = function () { + return 14 /* ClassDeclaration */; + }; + + ClassDeclaration.prototype.shouldEmit = function () { + return !TypeScript.hasFlag(this.getVarFlags(), 8 /* Ambient */); + }; + + ClassDeclaration.prototype.emit = function (emitter) { + emitter.emitClass(this); + }; + return ClassDeclaration; + })(TypeDeclaration); + TypeScript.ClassDeclaration = ClassDeclaration; + + var InterfaceDeclaration = (function (_super) { + __extends(InterfaceDeclaration, _super); + function InterfaceDeclaration(name, typeParameters, members, extendsList, implementsList, isObjectTypeLiteral) { + _super.call(this, name, typeParameters, extendsList, implementsList, members); + this.isObjectTypeLiteral = isObjectTypeLiteral; + } + InterfaceDeclaration.prototype.nodeType = function () { + return 15 /* InterfaceDeclaration */; + }; + + InterfaceDeclaration.prototype.shouldEmit = function () { + return false; + }; + return InterfaceDeclaration; + })(TypeDeclaration); + TypeScript.InterfaceDeclaration = InterfaceDeclaration; + + var ThrowStatement = (function (_super) { + __extends(ThrowStatement, _super); + function ThrowStatement(expression) { + _super.call(this); + this.expression = expression; + } + ThrowStatement.prototype.nodeType = function () { + return 96 /* ThrowStatement */; + }; + + ThrowStatement.prototype.isStatement = function () { + return true; + }; + + ThrowStatement.prototype.emitWorker = function (emitter) { + emitter.writeToOutput("throw "); + this.expression.emit(emitter); + emitter.writeToOutput(";"); + }; + + ThrowStatement.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.expression, ast.expression, includingPosition); + }; + return ThrowStatement; + })(AST); + TypeScript.ThrowStatement = ThrowStatement; + + var ExpressionStatement = (function (_super) { + __extends(ExpressionStatement, _super); + function ExpressionStatement(expression) { + _super.call(this); + this.expression = expression; + } + ExpressionStatement.prototype.nodeType = function () { + return 89 /* ExpressionStatement */; + }; + + ExpressionStatement.prototype.isStatement = function () { + return true; + }; + + ExpressionStatement.prototype.emitWorker = function (emitter) { + var isArrowExpression = this.expression.nodeType() === 13 /* FunctionDeclaration */ && TypeScript.hasFlag((this.expression).getFunctionFlags(), 2048 /* IsFatArrowFunction */); + + if (isArrowExpression) { + emitter.writeToOutput("("); + } + + this.expression.emit(emitter); + + if (isArrowExpression) { + emitter.writeToOutput(")"); + } + + emitter.writeToOutput(";"); + }; + + ExpressionStatement.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.expression, ast.expression, includingPosition); + }; + return ExpressionStatement; + })(AST); + TypeScript.ExpressionStatement = ExpressionStatement; + + var LabeledStatement = (function (_super) { + __extends(LabeledStatement, _super); + function LabeledStatement(identifier, statement) { + _super.call(this); + this.identifier = identifier; + this.statement = statement; + } + LabeledStatement.prototype.nodeType = function () { + return 93 /* LabeledStatement */; + }; + + LabeledStatement.prototype.isStatement = function () { + return true; + }; + + LabeledStatement.prototype.emitWorker = function (emitter) { + emitter.recordSourceMappingStart(this.identifier); + emitter.writeToOutput(this.identifier.actualText); + emitter.recordSourceMappingEnd(this.identifier); + emitter.writeLineToOutput(":"); + emitter.emitJavascript(this.statement, true); + }; + + LabeledStatement.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.identifier, ast.identifier, includingPosition) && structuralEquals(this.statement, ast.statement, includingPosition); + }; + return LabeledStatement; + })(AST); + TypeScript.LabeledStatement = LabeledStatement; + + var VariableDeclaration = (function (_super) { + __extends(VariableDeclaration, _super); + function VariableDeclaration(declarators) { + _super.call(this); + this.declarators = declarators; + } + VariableDeclaration.prototype.nodeType = function () { + return 19 /* VariableDeclaration */; + }; + + VariableDeclaration.prototype.emit = function (emitter) { + emitter.emitVariableDeclaration(this); + }; + + VariableDeclaration.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.declarators, ast.declarators, includingPosition); + }; + return VariableDeclaration; + })(AST); + TypeScript.VariableDeclaration = VariableDeclaration; + + var VariableStatement = (function (_super) { + __extends(VariableStatement, _super); + function VariableStatement(declaration) { + _super.call(this); + this.declaration = declaration; + } + VariableStatement.prototype.nodeType = function () { + return 98 /* VariableStatement */; + }; + + VariableStatement.prototype.isStatement = function () { + return true; + }; + + VariableStatement.prototype.shouldEmit = function () { + var varDecl = this.declaration.declarators.members[0]; + return !TypeScript.hasFlag(varDecl.getVarFlags(), 8 /* Ambient */) || varDecl.init !== null; + }; + + VariableStatement.prototype.emitWorker = function (emitter) { + if (TypeScript.hasFlag(this.getFlags(), 16 /* EnumElement */)) { + emitter.emitEnumElement(this.declaration.declarators.members[0]); + } else { + this.declaration.emit(emitter); + emitter.writeToOutput(";"); + } + }; + + VariableStatement.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.declaration, ast.declaration, includingPosition); + }; + return VariableStatement; + })(AST); + TypeScript.VariableStatement = VariableStatement; + + var Block = (function (_super) { + __extends(Block, _super); + function Block(statements, closeBraceSpan) { + _super.call(this); + this.statements = statements; + this.closeBraceSpan = closeBraceSpan; + this.closeBraceLeadingComments = null; + } + Block.prototype.nodeType = function () { + return 82 /* Block */; + }; + + Block.prototype.isStatement = function () { + return true; + }; + + Block.prototype.emitWorker = function (emitter) { + emitter.writeLineToOutput(" {"); + emitter.indenter.increaseIndent(); + if (this.statements) { + emitter.emitModuleElements(this.statements); + } + emitter.emitCommentsArray(this.closeBraceLeadingComments); + emitter.indenter.decreaseIndent(); + emitter.emitIndent(); + emitter.writeToOutput("}"); + }; + + Block.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.statements, ast.statements, includingPosition); + }; + return Block; + })(AST); + TypeScript.Block = Block; + + var Jump = (function (_super) { + __extends(Jump, _super); + function Jump(_nodeType, target) { + _super.call(this); + this._nodeType = _nodeType; + this.target = target; + } + Jump.prototype.nodeType = function () { + return this._nodeType; + }; + + Jump.prototype.isStatement = function () { + return true; + }; + + Jump.prototype.hasExplicitTarget = function () { + return this.target; + }; + + Jump.prototype.emitWorker = function (emitter) { + if (this.nodeType() === 83 /* BreakStatement */) { + emitter.writeToOutput("break"); + } else { + emitter.writeToOutput("continue"); + } + if (this.hasExplicitTarget()) { + emitter.writeToOutput(" " + this.target); + } + emitter.writeToOutput(";"); + }; + + Jump.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && this.target === ast.target; + }; + return Jump; + })(AST); + TypeScript.Jump = Jump; + + var WhileStatement = (function (_super) { + __extends(WhileStatement, _super); + function WhileStatement(cond, body) { + _super.call(this); + this.cond = cond; + this.body = body; + } + WhileStatement.prototype.nodeType = function () { + return 99 /* WhileStatement */; + }; + + WhileStatement.prototype.isStatement = function () { + return true; + }; + + WhileStatement.prototype.emitWorker = function (emitter) { + emitter.writeToOutput("while ("); + this.cond.emit(emitter); + emitter.writeToOutput(")"); + emitter.emitBlockOrStatement(this.body); + }; + + WhileStatement.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.cond, ast.cond, includingPosition) && structuralEquals(this.body, ast.body, includingPosition); + }; + return WhileStatement; + })(AST); + TypeScript.WhileStatement = WhileStatement; + + var DoStatement = (function (_super) { + __extends(DoStatement, _super); + function DoStatement(body, cond, whileSpan) { + _super.call(this); + this.body = body; + this.cond = cond; + this.whileSpan = whileSpan; + } + DoStatement.prototype.nodeType = function () { + return 86 /* DoStatement */; + }; + + DoStatement.prototype.isStatement = function () { + return true; + }; + + DoStatement.prototype.emitWorker = function (emitter) { + emitter.writeToOutput("do"); + emitter.emitBlockOrStatement(this.body); + emitter.recordSourceMappingStart(this.whileSpan); + emitter.writeToOutput(" while"); + emitter.recordSourceMappingEnd(this.whileSpan); + emitter.writeToOutput('('); + this.cond.emit(emitter); + emitter.writeToOutput(")"); + emitter.writeToOutput(";"); + }; + + DoStatement.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.body, ast.body, includingPosition) && structuralEquals(this.cond, ast.cond, includingPosition); + }; + return DoStatement; + })(AST); + TypeScript.DoStatement = DoStatement; + + var IfStatement = (function (_super) { + __extends(IfStatement, _super); + function IfStatement(cond, thenBod, elseBod) { + _super.call(this); + this.cond = cond; + this.thenBod = thenBod; + this.elseBod = elseBod; + } + IfStatement.prototype.nodeType = function () { + return 92 /* IfStatement */; + }; + + IfStatement.prototype.isStatement = function () { + return true; + }; + + IfStatement.prototype.emitWorker = function (emitter) { + emitter.writeToOutput("if ("); + this.cond.emit(emitter); + emitter.writeToOutput(")"); + + emitter.emitBlockOrStatement(this.thenBod); + + if (this.elseBod) { + if (this.thenBod.nodeType() !== 82 /* Block */) { + emitter.writeLineToOutput(""); + } else { + emitter.writeToOutput(" "); + } + + if (this.elseBod.nodeType() === 92 /* IfStatement */) { + emitter.writeToOutput("else "); + this.elseBod.emit(emitter); + } else { + emitter.writeToOutput("else"); + emitter.emitBlockOrStatement(this.elseBod); + } + } + }; + + IfStatement.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.cond, ast.cond, includingPosition) && structuralEquals(this.thenBod, ast.thenBod, includingPosition) && structuralEquals(this.elseBod, ast.elseBod, includingPosition); + }; + return IfStatement; + })(AST); + TypeScript.IfStatement = IfStatement; + + var ReturnStatement = (function (_super) { + __extends(ReturnStatement, _super); + function ReturnStatement(returnExpression) { + _super.call(this); + this.returnExpression = returnExpression; + } + ReturnStatement.prototype.nodeType = function () { + return 94 /* ReturnStatement */; + }; + + ReturnStatement.prototype.isStatement = function () { + return true; + }; + + ReturnStatement.prototype.emitWorker = function (emitter) { + if (this.returnExpression) { + emitter.writeToOutput("return "); + this.returnExpression.emit(emitter); + emitter.writeToOutput(";"); + } else { + emitter.writeToOutput("return;"); + } + }; + + ReturnStatement.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.returnExpression, ast.returnExpression, includingPosition); + }; + return ReturnStatement; + })(AST); + TypeScript.ReturnStatement = ReturnStatement; + + var ForInStatement = (function (_super) { + __extends(ForInStatement, _super); + function ForInStatement(lval, obj, body) { + _super.call(this); + this.lval = lval; + this.obj = obj; + this.body = body; + } + ForInStatement.prototype.nodeType = function () { + return 90 /* ForInStatement */; + }; + + ForInStatement.prototype.isStatement = function () { + return true; + }; + + ForInStatement.prototype.emitWorker = function (emitter) { + emitter.writeToOutput("for ("); + this.lval.emit(emitter); + emitter.writeToOutput(" in "); + this.obj.emit(emitter); + emitter.writeToOutput(")"); + emitter.emitBlockOrStatement(this.body); + }; + + ForInStatement.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.lval, ast.lval, includingPosition) && structuralEquals(this.obj, ast.obj, includingPosition) && structuralEquals(this.body, ast.body, includingPosition); + }; + return ForInStatement; + })(AST); + TypeScript.ForInStatement = ForInStatement; + + var ForStatement = (function (_super) { + __extends(ForStatement, _super); + function ForStatement(init, cond, incr, body) { + _super.call(this); + this.init = init; + this.cond = cond; + this.incr = incr; + this.body = body; + } + ForStatement.prototype.nodeType = function () { + return 91 /* ForStatement */; + }; + + ForStatement.prototype.isStatement = function () { + return true; + }; + + ForStatement.prototype.emitWorker = function (emitter) { + emitter.writeToOutput("for ("); + if (this.init) { + if (this.init.nodeType() !== 1 /* List */) { + this.init.emit(emitter); + } else { + emitter.setInVarBlock((this.init).members.length); + emitter.emitCommaSeparatedList(this.init); + } + } + + emitter.writeToOutput("; "); + emitter.emitJavascript(this.cond, false); + emitter.writeToOutput(";"); + if (this.incr) { + emitter.writeToOutput(" "); + emitter.emitJavascript(this.incr, false); + } + emitter.writeToOutput(")"); + emitter.emitBlockOrStatement(this.body); + }; + + ForStatement.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.init, ast.init, includingPosition) && structuralEquals(this.cond, ast.cond, includingPosition) && structuralEquals(this.incr, ast.incr, includingPosition) && structuralEquals(this.body, ast.body, includingPosition); + }; + return ForStatement; + })(AST); + TypeScript.ForStatement = ForStatement; + + var WithStatement = (function (_super) { + __extends(WithStatement, _super); + function WithStatement(expr, body) { + _super.call(this); + this.expr = expr; + this.body = body; + } + WithStatement.prototype.nodeType = function () { + return 100 /* WithStatement */; + }; + + WithStatement.prototype.isStatement = function () { + return true; + }; + + WithStatement.prototype.emitWorker = function (emitter) { + emitter.writeToOutput("with ("); + if (this.expr) { + this.expr.emit(emitter); + } + + emitter.writeToOutput(")"); + emitter.emitBlockOrStatement(this.body); + }; + + WithStatement.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.expr, ast.expr, includingPosition) && structuralEquals(this.body, ast.body, includingPosition); + }; + return WithStatement; + })(AST); + TypeScript.WithStatement = WithStatement; + + var SwitchStatement = (function (_super) { + __extends(SwitchStatement, _super); + function SwitchStatement(val, caseList, defaultCase, statement) { + _super.call(this); + this.val = val; + this.caseList = caseList; + this.defaultCase = defaultCase; + this.statement = statement; + } + SwitchStatement.prototype.nodeType = function () { + return 95 /* SwitchStatement */; + }; + + SwitchStatement.prototype.isStatement = function () { + return true; + }; + + SwitchStatement.prototype.emitWorker = function (emitter) { + emitter.recordSourceMappingStart(this.statement); + emitter.writeToOutput("switch ("); + this.val.emit(emitter); + emitter.writeToOutput(")"); + emitter.recordSourceMappingEnd(this.statement); + emitter.writeLineToOutput(" {"); + emitter.indenter.increaseIndent(); + + var lastEmittedNode = null; + for (var i = 0, n = this.caseList.members.length; i < n; i++) { + var caseExpr = this.caseList.members[i]; + + emitter.emitSpaceBetweenConstructs(lastEmittedNode, caseExpr); + emitter.emitJavascript(caseExpr, true); + + lastEmittedNode = caseExpr; + } + emitter.indenter.decreaseIndent(); + emitter.emitIndent(); + emitter.writeToOutput("}"); + }; + + SwitchStatement.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.caseList, ast.caseList, includingPosition) && structuralEquals(this.val, ast.val, includingPosition); + }; + return SwitchStatement; + })(AST); + TypeScript.SwitchStatement = SwitchStatement; + + var CaseClause = (function (_super) { + __extends(CaseClause, _super); + function CaseClause(expr, body) { + _super.call(this); + this.expr = expr; + this.body = body; + } + CaseClause.prototype.nodeType = function () { + return 101 /* CaseClause */; + }; + + CaseClause.prototype.emitWorker = function (emitter) { + if (this.expr) { + emitter.writeToOutput("case "); + this.expr.emit(emitter); + } else { + emitter.writeToOutput("default"); + } + emitter.writeToOutput(":"); + + if (this.body.members.length === 1 && this.body.members[0].nodeType() === 82 /* Block */) { + this.body.members[0].emit(emitter); + emitter.writeLineToOutput(""); + } else { + emitter.writeLineToOutput(""); + emitter.indenter.increaseIndent(); + this.body.emit(emitter); + emitter.indenter.decreaseIndent(); + } + }; + + CaseClause.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.expr, ast.expr, includingPosition) && structuralEquals(this.body, ast.body, includingPosition); + }; + return CaseClause; + })(AST); + TypeScript.CaseClause = CaseClause; + + var TypeParameter = (function (_super) { + __extends(TypeParameter, _super); + function TypeParameter(name, constraint) { + _super.call(this); + this.name = name; + this.constraint = constraint; + } + TypeParameter.prototype.nodeType = function () { + return 9 /* TypeParameter */; + }; + + TypeParameter.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.name, ast.name, includingPosition) && structuralEquals(this.constraint, ast.constraint, includingPosition); + }; + return TypeParameter; + })(AST); + TypeScript.TypeParameter = TypeParameter; + + var GenericType = (function (_super) { + __extends(GenericType, _super); + function GenericType(name, typeArguments) { + _super.call(this); + this.name = name; + this.typeArguments = typeArguments; + } + GenericType.prototype.nodeType = function () { + return 10 /* GenericType */; + }; + + GenericType.prototype.emit = function (emitter) { + this.name.emit(emitter); + }; + + GenericType.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.name, ast.name, includingPosition) && structuralEquals(this.typeArguments, ast.typeArguments, includingPosition); + }; + return GenericType; + })(AST); + TypeScript.GenericType = GenericType; + + var TypeQuery = (function (_super) { + __extends(TypeQuery, _super); + function TypeQuery(name) { + _super.call(this); + this.name = name; + } + TypeQuery.prototype.nodeType = function () { + return 12 /* TypeQuery */; + }; + + TypeQuery.prototype.emit = function (emitter) { + TypeScript.Emitter.throwEmitterError(new Error(TypeScript.getLocalizedText(TypeScript.DiagnosticCode.Should_not_emit_a_type_query, null))); + }; + + TypeQuery.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.name, ast.name, includingPosition); + }; + return TypeQuery; + })(AST); + TypeScript.TypeQuery = TypeQuery; + + var TypeReference = (function (_super) { + __extends(TypeReference, _super); + function TypeReference(term, arrayCount) { + _super.call(this); + this.term = term; + this.arrayCount = arrayCount; + this.minChar = term.minChar; + this.limChar = term.limChar; + } + TypeReference.prototype.nodeType = function () { + return 11 /* TypeRef */; + }; + + TypeReference.prototype.emit = function (emitter) { + TypeScript.Emitter.throwEmitterError(new Error(TypeScript.getLocalizedText(TypeScript.DiagnosticCode.Should_not_emit_a_type_reference, null))); + }; + + TypeReference.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.term, ast.term, includingPosition) && this.arrayCount === ast.arrayCount; + }; + return TypeReference; + })(AST); + TypeScript.TypeReference = TypeReference; + + var TryStatement = (function (_super) { + __extends(TryStatement, _super); + function TryStatement(tryBody, catchClause, finallyBody) { + _super.call(this); + this.tryBody = tryBody; + this.catchClause = catchClause; + this.finallyBody = finallyBody; + } + TryStatement.prototype.nodeType = function () { + return 97 /* TryStatement */; + }; + + TryStatement.prototype.isStatement = function () { + return true; + }; + + TryStatement.prototype.emitWorker = function (emitter) { + emitter.writeToOutput("try "); + this.tryBody.emit(emitter); + emitter.emitJavascript(this.catchClause, false); + + if (this.finallyBody) { + emitter.writeToOutput(" finally"); + this.finallyBody.emit(emitter); + } + }; + + TryStatement.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.tryBody, ast.tryBody, includingPosition) && structuralEquals(this.catchClause, ast.catchClause, includingPosition) && structuralEquals(this.finallyBody, ast.finallyBody, includingPosition); + }; + return TryStatement; + })(AST); + TypeScript.TryStatement = TryStatement; + + var CatchClause = (function (_super) { + __extends(CatchClause, _super); + function CatchClause(param, body) { + _super.call(this); + this.param = param; + this.body = body; + } + CatchClause.prototype.nodeType = function () { + return 102 /* CatchClause */; + }; + + CatchClause.prototype.emitWorker = function (emitter) { + emitter.writeToOutput(" "); + emitter.writeToOutput("catch ("); + this.param.id.emit(emitter); + emitter.writeToOutput(")"); + this.body.emit(emitter); + }; + + CatchClause.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.param, ast.param, includingPosition) && structuralEquals(this.body, ast.body, includingPosition); + }; + return CatchClause; + })(AST); + TypeScript.CatchClause = CatchClause; + + var DebuggerStatement = (function (_super) { + __extends(DebuggerStatement, _super); + function DebuggerStatement() { + _super.apply(this, arguments); + } + DebuggerStatement.prototype.nodeType = function () { + return 85 /* DebuggerStatement */; + }; + + DebuggerStatement.prototype.isStatement = function () { + return true; + }; + + DebuggerStatement.prototype.emitWorker = function (emitter) { + emitter.writeToOutput("debugger;"); + }; + return DebuggerStatement; + })(AST); + TypeScript.DebuggerStatement = DebuggerStatement; + + var OmittedExpression = (function (_super) { + __extends(OmittedExpression, _super); + function OmittedExpression() { + _super.apply(this, arguments); + } + OmittedExpression.prototype.nodeType = function () { + return 24 /* OmittedExpression */; + }; + + OmittedExpression.prototype.emitWorker = function (emitter) { + }; + + OmittedExpression.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition); + }; + return OmittedExpression; + })(AST); + TypeScript.OmittedExpression = OmittedExpression; + + var EmptyStatement = (function (_super) { + __extends(EmptyStatement, _super); + function EmptyStatement() { + _super.apply(this, arguments); + } + EmptyStatement.prototype.nodeType = function () { + return 87 /* EmptyStatement */; + }; + + EmptyStatement.prototype.isStatement = function () { + return true; + }; + + EmptyStatement.prototype.emitWorker = function (emitter) { + emitter.writeToOutput(";"); + }; + + EmptyStatement.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition); + }; + return EmptyStatement; + })(AST); + TypeScript.EmptyStatement = EmptyStatement; + + var Comment = (function (_super) { + __extends(Comment, _super); + function Comment(content, isBlockComment, endsLine) { + _super.call(this); + this.content = content; + this.isBlockComment = isBlockComment; + this.endsLine = endsLine; + this.text = null; + this.docCommentText = null; + } + Comment.prototype.nodeType = function () { + return 103 /* Comment */; + }; + + Comment.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && this.content === ast.content && this.isBlockComment === ast.isBlockComment && this.endsLine === ast.endsLine; + }; + + Comment.prototype.getText = function () { + if (this.text === null) { + if (this.isBlockComment) { + this.text = this.content.split("\n"); + for (var i = 0; i < this.text.length; i++) { + this.text[i] = this.text[i].replace(/^\s+|\s+$/g, ''); + } + } else { + this.text = [(this.content.replace(/^\s+|\s+$/g, ''))]; + } + } + + return this.text; + }; + + Comment.prototype.isDocComment = function () { + if (this.isBlockComment) { + return this.content.charAt(2) === "*" && this.content.charAt(3) !== "/"; + } + + return false; + }; + + Comment.prototype.getDocCommentTextValue = function () { + if (this.docCommentText === null) { + this.docCommentText = Comment.cleanJSDocComment(this.content); + } + + return this.docCommentText; + }; + + Comment.consumeLeadingSpace = function (line, startIndex, maxSpacesToRemove) { + var endIndex = line.length; + if (maxSpacesToRemove !== undefined) { + endIndex = TypeScript.min(startIndex + maxSpacesToRemove, endIndex); + } + + for (; startIndex < endIndex; startIndex++) { + var charCode = line.charCodeAt(startIndex); + if (charCode !== 32 /* space */ && charCode !== 9 /* tab */) { + return startIndex; + } + } + + if (endIndex !== line.length) { + return endIndex; + } + + return -1; + }; + + Comment.isSpaceChar = function (line, index) { + var length = line.length; + if (index < length) { + var charCode = line.charCodeAt(index); + + return charCode === 32 /* space */ || charCode === 9 /* tab */; + } + + return index === length; + }; + + Comment.cleanDocCommentLine = function (line, jsDocStyleComment, jsDocLineSpaceToRemove) { + var nonSpaceIndex = Comment.consumeLeadingSpace(line, 0); + if (nonSpaceIndex !== -1) { + var jsDocSpacesRemoved = nonSpaceIndex; + if (jsDocStyleComment && line.charAt(nonSpaceIndex) === '*') { + var startIndex = nonSpaceIndex + 1; + nonSpaceIndex = Comment.consumeLeadingSpace(line, startIndex, jsDocLineSpaceToRemove); + + if (nonSpaceIndex !== -1) { + jsDocSpacesRemoved = nonSpaceIndex - startIndex; + } else { + return null; + } + } + + return { + minChar: nonSpaceIndex, + limChar: line.charAt(line.length - 1) === "\r" ? line.length - 1 : line.length, + jsDocSpacesRemoved: jsDocSpacesRemoved + }; + } + + return null; + }; + + Comment.cleanJSDocComment = function (content, spacesToRemove) { + var docCommentLines = new Array(); + content = content.replace("/**", ""); + if (content.length >= 2 && content.charAt(content.length - 1) === "/" && content.charAt(content.length - 2) === "*") { + content = content.substring(0, content.length - 2); + } + var lines = content.split("\n"); + var inParamTag = false; + for (var l = 0; l < lines.length; l++) { + var line = lines[l]; + var cleanLinePos = Comment.cleanDocCommentLine(line, true, spacesToRemove); + if (!cleanLinePos) { + continue; + } + + var docCommentText = ""; + var prevPos = cleanLinePos.minChar; + for (var i = line.indexOf("@", cleanLinePos.minChar); 0 <= i && i < cleanLinePos.limChar; i = line.indexOf("@", i + 1)) { + var wasInParamtag = inParamTag; + + if (line.indexOf("param", i + 1) === i + 1 && Comment.isSpaceChar(line, i + 6)) { + if (!wasInParamtag) { + docCommentText += line.substring(prevPos, i); + } + + prevPos = i; + inParamTag = true; + } else if (wasInParamtag) { + prevPos = i; + inParamTag = false; + } + } + + if (!inParamTag) { + docCommentText += line.substring(prevPos, cleanLinePos.limChar); + } + + var newCleanPos = Comment.cleanDocCommentLine(docCommentText, false); + if (newCleanPos) { + if (spacesToRemove === undefined) { + spacesToRemove = cleanLinePos.jsDocSpacesRemoved; + } + docCommentLines.push(docCommentText); + } + } + + return docCommentLines.join("\n"); + }; + + Comment.getDocCommentText = function (comments) { + var docCommentText = new Array(); + for (var c = 0; c < comments.length; c++) { + var commentText = comments[c].getDocCommentTextValue(); + if (commentText !== "") { + docCommentText.push(commentText); + } + } + return docCommentText.join("\n"); + }; + + Comment.getParameterDocCommentText = function (param, fncDocComments) { + if (fncDocComments.length === 0 || !fncDocComments[0].isBlockComment) { + return ""; + } + + for (var i = 0; i < fncDocComments.length; i++) { + var commentContents = fncDocComments[i].content; + for (var j = commentContents.indexOf("@param", 0); 0 <= j; j = commentContents.indexOf("@param", j)) { + j += 6; + if (!Comment.isSpaceChar(commentContents, j)) { + continue; + } + + j = Comment.consumeLeadingSpace(commentContents, j); + if (j === -1) { + break; + } + + if (commentContents.charCodeAt(j) === 123 /* openBrace */) { + j++; + + var charCode = 0; + for (var curlies = 1; j < commentContents.length; j++) { + charCode = commentContents.charCodeAt(j); + + if (charCode === 123 /* openBrace */) { + curlies++; + continue; + } + + if (charCode === 125 /* closeBrace */) { + curlies--; + if (curlies === 0) { + break; + } else { + continue; + } + } + + if (charCode === 64 /* at */) { + break; + } + } + + if (j === commentContents.length) { + break; + } + + if (charCode === 64 /* at */) { + continue; + } + + j = Comment.consumeLeadingSpace(commentContents, j + 1); + if (j === -1) { + break; + } + } + + if (param !== commentContents.substr(j, param.length) || !Comment.isSpaceChar(commentContents, j + param.length)) { + continue; + } + + j = Comment.consumeLeadingSpace(commentContents, j + param.length); + if (j === -1) { + return ""; + } + + var endOfParam = commentContents.indexOf("@", j); + var paramHelpString = commentContents.substring(j, endOfParam < 0 ? commentContents.length : endOfParam); + + var paramSpacesToRemove = undefined; + var paramLineIndex = commentContents.substring(0, j).lastIndexOf("\n") + 1; + if (paramLineIndex !== 0) { + if (paramLineIndex < j && commentContents.charAt(paramLineIndex + 1) === "\r") { + paramLineIndex++; + } + } + var startSpaceRemovalIndex = Comment.consumeLeadingSpace(commentContents, paramLineIndex); + if (startSpaceRemovalIndex !== j && commentContents.charAt(startSpaceRemovalIndex) === "*") { + paramSpacesToRemove = j - startSpaceRemovalIndex - 1; + } + + return Comment.cleanJSDocComment(paramHelpString, paramSpacesToRemove); + } + } + + return ""; + }; + return Comment; + })(AST); + TypeScript.Comment = Comment; +})(TypeScript || (TypeScript = {})); +var IOUtils; +(function (IOUtils) { + function createDirectoryStructure(ioHost, dirName) { + if (ioHost.directoryExists(dirName)) { + return; + } + + var parentDirectory = ioHost.dirName(dirName); + if (parentDirectory != "") { + createDirectoryStructure(ioHost, parentDirectory); + } + ioHost.createDirectory(dirName); + } + + function writeFileAndFolderStructure(ioHost, fileName, contents, writeByteOrderMark) { + var start = new Date().getTime(); + var path = ioHost.resolvePath(fileName); + TypeScript.ioHostResolvePathTime += new Date().getTime() - start; + + var start = new Date().getTime(); + var dirName = ioHost.dirName(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; + } + IOUtils.writeFileAndFolderStructure = writeFileAndFolderStructure; + + function throwIOError(message, error) { + var errorMessage = message; + if (error && error.message) { + errorMessage += (" " + error.message); + } + throw new Error(errorMessage); + } + IOUtils.throwIOError = throwIOError; + + function combine(prefix, suffix) { + return prefix + "/" + suffix; + } + IOUtils.combine = combine; + + var BufferedTextWriter = (function () { + function BufferedTextWriter(writer, capacity) { + if (typeof capacity === "undefined") { capacity = 1024; } + this.writer = writer; + this.capacity = capacity; + this.buffer = ""; + } + BufferedTextWriter.prototype.Write = function (str) { + this.buffer += str; + if (this.buffer.length >= this.capacity) { + this.writer.Write(this.buffer); + this.buffer = ""; + } + }; + BufferedTextWriter.prototype.WriteLine = function (str) { + this.Write(str + '\r\n'); + }; + BufferedTextWriter.prototype.Close = function () { + this.writer.Write(this.buffer); + this.writer.Close(); + this.buffer = null; + }; + return BufferedTextWriter; + })(); + IOUtils.BufferedTextWriter = BufferedTextWriter; +})(IOUtils || (IOUtils = {})); + +var IO = (function () { + function getWindowsScriptHostIO() { + var fso = new ActiveXObject("Scripting.FileSystemObject"); + var streamObjectPool = []; + + function getStreamObject() { + if (streamObjectPool.length > 0) { + return streamObjectPool.pop(); + } else { + return new ActiveXObject("ADODB.Stream"); + } + } + + function releaseStreamObject(obj) { + streamObjectPool.push(obj); + } + + var args = []; + for (var i = 0; i < WScript.Arguments.length; i++) { + args[i] = WScript.Arguments.Item(i); + } + + return { + readFile: function (path) { + return Environment.readFile(path); + }, + writeFile: function (path, contents, writeByteOrderMark) { + Environment.writeFile(path, contents, writeByteOrderMark); + }, + fileExists: function (path) { + return fso.FileExists(path); + }, + resolvePath: function (path) { + return fso.GetAbsolutePathName(path); + }, + dirName: function (path) { + return fso.GetParentFolderName(path); + }, + findFile: function (rootPath, partialFilePath) { + var path = fso.GetAbsolutePathName(rootPath) + "/" + partialFilePath; + + while (true) { + if (fso.FileExists(path)) { + return { fileInformation: this.readFile(path), path: path }; + } else { + rootPath = fso.GetParentFolderName(fso.GetAbsolutePathName(rootPath)); + + if (rootPath == "") { + return null; + } else { + path = fso.BuildPath(rootPath, partialFilePath); + } + } + } + }, + deleteFile: function (path) { + try { + if (fso.FileExists(path)) { + fso.DeleteFile(path, true); + } + } catch (e) { + IOUtils.throwIOError(TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Could_not_delete_file_0, [path]), e); + } + }, + directoryExists: function (path) { + return fso.FolderExists(path); + }, + createDirectory: function (path) { + try { + if (!this.directoryExists(path)) { + fso.CreateFolder(path); + } + } catch (e) { + IOUtils.throwIOError(TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Could_not_create_directory_0, [path]), e); + } + }, + dir: function (path, spec, options) { + options = options || {}; + function filesInFolder(folder, root) { + var paths = []; + var fc; + + if (options.recursive) { + fc = new Enumerator(folder.subfolders); + + for (; !fc.atEnd(); fc.moveNext()) { + paths = paths.concat(filesInFolder(fc.item(), root + "/" + fc.item().Name)); + } + } + + fc = new Enumerator(folder.files); + + for (; !fc.atEnd(); fc.moveNext()) { + if (!spec || fc.item().Name.match(spec)) { + paths.push(root + "/" + fc.item().Name); + } + } + + return paths; + } + + var folder = fso.GetFolder(path); + var paths = []; + + return filesInFolder(folder, path); + }, + print: function (str) { + WScript.StdOut.Write(str); + }, + printLine: function (str) { + WScript.Echo(str); + }, + arguments: args, + stderr: WScript.StdErr, + stdout: WScript.StdOut, + watchFile: null, + run: function (source, fileName) { + try { + eval(source); + } catch (e) { + IOUtils.throwIOError(TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Error_while_executing_file_0, [fileName]), e); + } + }, + getExecutingFilePath: function () { + return WScript.ScriptFullName; + }, + quit: function (exitCode) { + if (typeof exitCode === "undefined") { exitCode = 0; } + try { + WScript.Quit(exitCode); + } catch (e) { + } + } + }; + } + ; + + function getNodeIO() { + var _fs = require('fs'); + var _path = require('path'); + var _module = require('module'); + + return { + readFile: function (file) { + return Environment.readFile(file); + }, + writeFile: function (path, contents, writeByteOrderMark) { + Environment.writeFile(path, contents, writeByteOrderMark); + }, + deleteFile: function (path) { + try { + _fs.unlinkSync(path); + } catch (e) { + IOUtils.throwIOError(TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Could_not_delete_file_0, [path]), e); + } + }, + fileExists: function (path) { + return _fs.existsSync(path); + }, + dir: function dir(path, spec, options) { + options = options || {}; + + function filesInFolder(folder) { + var paths = []; + + try { + var files = _fs.readdirSync(folder); + for (var i = 0; i < files.length; i++) { + var stat = _fs.statSync(folder + "/" + files[i]); + if (options.recursive && stat.isDirectory()) { + paths = paths.concat(filesInFolder(folder + "/" + files[i])); + } else if (stat.isFile() && (!spec || files[i].match(spec))) { + paths.push(folder + "/" + files[i]); + } + } + } catch (err) { + } + + return paths; + } + + return filesInFolder(path); + }, + createDirectory: function (path) { + try { + if (!this.directoryExists(path)) { + _fs.mkdirSync(path); + } + } catch (e) { + IOUtils.throwIOError(TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Could_not_create_directory_0, [path]), e); + } + }, + directoryExists: function (path) { + return _fs.existsSync(path) && _fs.statSync(path).isDirectory(); + }, + resolvePath: function (path) { + return _path.resolve(path); + }, + dirName: function (path) { + var dirPath = _path.dirname(path); + + if (dirPath === path) { + dirPath = null; + } + + return dirPath; + }, + findFile: function (rootPath, partialFilePath) { + var path = rootPath + "/" + partialFilePath; + + while (true) { + if (_fs.existsSync(path)) { + return { fileInformation: this.readFile(path), path: path }; + } else { + var parentPath = _path.resolve(rootPath, ".."); + + if (rootPath === parentPath) { + return null; + } else { + rootPath = parentPath; + path = _path.resolve(rootPath, partialFilePath); + } + } + } + }, + print: function (str) { + process.stdout.write(str); + }, + printLine: function (str) { + process.stdout.write(str + '\n'); + }, + arguments: process.argv.slice(2), + stderr: { + Write: function (str) { + process.stderr.write(str); + }, + WriteLine: function (str) { + process.stderr.write(str + '\n'); + }, + Close: function () { + } + }, + stdout: { + Write: function (str) { + process.stdout.write(str); + }, + WriteLine: function (str) { + process.stdout.write(str + '\n'); + }, + Close: function () { + } + }, + watchFile: function (fileName, callback) { + var firstRun = true; + var processingChange = false; + + var fileChanged = function (curr, prev) { + if (!firstRun) { + if (curr.mtime < prev.mtime) { + return; + } + + _fs.unwatchFile(fileName, fileChanged); + if (!processingChange) { + processingChange = true; + callback(fileName); + setTimeout(function () { + processingChange = false; + }, 100); + } + } + firstRun = false; + _fs.watchFile(fileName, { persistent: true, interval: 500 }, fileChanged); + }; + + fileChanged(); + return { + fileName: fileName, + close: function () { + _fs.unwatchFile(fileName, fileChanged); + } + }; + }, + run: function (source, fileName) { + require.main.fileName = fileName; + require.main.paths = _module._nodeModulePaths(_path.dirname(_fs.realpathSync(fileName))); + require.main._compile(source, fileName); + }, + getExecutingFilePath: function () { + return process.mainModule.filename; + }, + quit: function (code) { + var stderrFlushed = process.stderr.write(''); + var stdoutFlushed = process.stdout.write(''); + process.stderr.on('drain', function () { + stderrFlushed = true; + if (stdoutFlushed) { + process.exit(code); + } + }); + process.stdout.on('drain', function () { + stdoutFlushed = true; + if (stderrFlushed) { + process.exit(code); + } + }); + setTimeout(function () { + process.exit(code); + }, 5); + } + }; + } + ; + + if (typeof WScript !== "undefined" && typeof ActiveXObject === "function") + return getWindowsScriptHostIO(); +else if (typeof module !== 'undefined' && module.exports) + return getNodeIO(); +else + return null; +})(); +var TypeScript; +(function (TypeScript) { + var OptionsParser = (function () { + function OptionsParser(host, version) { + this.host = host; + this.version = version; + this.DEFAULT_SHORT_FLAG = "-"; + this.DEFAULT_LONG_FLAG = "--"; + this.printedVersion = false; + this.unnamed = []; + this.options = []; + } + OptionsParser.prototype.findOption = function (arg) { + for (var i = 0; i < this.options.length; i++) { + if (arg === this.options[i].short || arg === this.options[i].name) { + return this.options[i]; + } + } + + return null; + }; + + OptionsParser.prototype.printUsage = function () { + this.printVersion(); + + var optionsWord = TypeScript.getLocalizedText(TypeScript.DiagnosticCode.options, null); + var fileWord = TypeScript.getLocalizedText(TypeScript.DiagnosticCode.file, null); + var tscSyntax = "tsc [" + optionsWord + "] [" + fileWord + " ..]"; + var syntaxHelp = TypeScript.getLocalizedText(TypeScript.DiagnosticCode.Syntax_0, [tscSyntax]); + this.host.printLine(syntaxHelp); + this.host.printLine(""); + this.host.printLine(TypeScript.getLocalizedText(TypeScript.DiagnosticCode.Examples, null) + " tsc hello.ts"); + this.host.printLine(" tsc --out foo.js foo.ts"); + this.host.printLine(" tsc @args.txt"); + this.host.printLine(""); + this.host.printLine(TypeScript.getLocalizedText(TypeScript.DiagnosticCode.Options, null)); + + var output = []; + var maxLength = 0; + var i = 0; + + this.options = this.options.sort(function (a, b) { + var aName = a.name.toLowerCase(); + var bName = b.name.toLowerCase(); + + if (aName > bName) { + return 1; + } else if (aName < bName) { + return -1; + } else { + return 0; + } + }); + + for (i = 0; i < this.options.length; i++) { + var option = this.options[i]; + + if (option.experimental) { + continue; + } + + if (!option.usage) { + break; + } + + var usageString = " "; + var type = option.type ? (" " + TypeScript.getLocalizedText(option.type, null)) : ""; + + if (option.short) { + usageString += this.DEFAULT_SHORT_FLAG + option.short + type + ", "; + } + + usageString += this.DEFAULT_LONG_FLAG + option.name + type; + + output.push([usageString, TypeScript.getLocalizedText(option.usage.locCode, option.usage.args)]); + + if (usageString.length > maxLength) { + maxLength = usageString.length; + } + } + + var fileDescription = TypeScript.getLocalizedText(TypeScript.DiagnosticCode.Insert_command_line_options_and_files_from_a_file, null); + output.push([" @<" + fileWord + ">", fileDescription]); + + for (i = 0; i < output.length; i++) { + this.host.printLine(output[i][0] + (new Array(maxLength - output[i][0].length + 3)).join(" ") + output[i][1]); + } + }; + + OptionsParser.prototype.printVersion = function () { + if (!this.printedVersion) { + this.host.printLine(TypeScript.getLocalizedText(TypeScript.DiagnosticCode.Version_0, [this.version])); + this.printedVersion = true; + } + }; + + OptionsParser.prototype.option = function (name, config, short) { + if (!config) { + config = short; + short = null; + } + + config.name = name; + config.short = short; + config.flag = false; + + this.options.push(config); + }; + + OptionsParser.prototype.flag = function (name, config, short) { + if (!config) { + config = short; + short = null; + } + + config.name = name; + config.short = short; + config.flag = true; + + this.options.push(config); + }; + + OptionsParser.prototype.parseString = function (argString) { + var position = 0; + var tokens = argString.match(/\s+|"|[^\s"]+/g); + + function peek() { + return tokens[position]; + } + + function consume() { + return tokens[position++]; + } + + function consumeQuotedString() { + var value = ''; + consume(); + + var token = peek(); + + while (token && token !== '"') { + consume(); + + value += token; + + token = peek(); + } + + consume(); + + return value; + } + + var args = []; + var currentArg = ''; + + while (position < tokens.length) { + var token = peek(); + + if (token === '"') { + currentArg += consumeQuotedString(); + } else if (token.match(/\s/)) { + if (currentArg.length > 0) { + args.push(currentArg); + currentArg = ''; + } + + consume(); + } else { + consume(); + currentArg += token; + } + } + + if (currentArg.length > 0) { + args.push(currentArg); + } + + this.parse(args); + }; + + OptionsParser.prototype.parse = function (args) { + var position = 0; + + function consume() { + return args[position++]; + } + + while (position < args.length) { + var current = consume(); + var match = current.match(/^(--?|@)(.*)/); + var value = null; + + if (match) { + if (match[1] === '@') { + this.parseString(this.host.readFile(match[2]).contents); + } else { + var arg = match[2]; + var option = this.findOption(arg); + + if (option === null) { + this.host.printLine(TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Unknown_option_0, [arg])); + this.host.printLine(TypeScript.getLocalizedText(TypeScript.DiagnosticCode.Use_the_0_flag_to_see_options, ["--help"])); + } else { + if (!option.flag) + value = consume(); + + option.set(value); + } + } + } else { + this.unnamed.push(current); + } + } + }; + return OptionsParser; + })(); + TypeScript.OptionsParser = OptionsParser; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var SourceFile = (function () { + function SourceFile(scriptSnapshot, byteOrderMark) { + this.scriptSnapshot = scriptSnapshot; + this.byteOrderMark = byteOrderMark; + } + return SourceFile; + })(); + + var DiagnosticsLogger = (function () { + function DiagnosticsLogger(ioHost) { + this.ioHost = ioHost; + } + DiagnosticsLogger.prototype.information = function () { + return false; + }; + DiagnosticsLogger.prototype.debug = function () { + return false; + }; + DiagnosticsLogger.prototype.warning = function () { + return false; + }; + DiagnosticsLogger.prototype.error = function () { + return false; + }; + DiagnosticsLogger.prototype.fatal = function () { + return false; + }; + DiagnosticsLogger.prototype.log = function (s) { + this.ioHost.stdout.WriteLine(s); + }; + return DiagnosticsLogger; + })(); + + TypeScript.useDirectTypeStorage = true; + + var BatchCompiler = (function () { + function BatchCompiler(ioHost) { + this.ioHost = ioHost; + this.compilerVersion = "0.9.1.0"; + this.inputFiles = []; + this.resolvedFiles = []; + this.inputFileNameToOutputFileName = new TypeScript.StringHashTable(); + this.fileNameToSourceFile = new TypeScript.StringHashTable(); + this.hasErrors = false; + this.logger = null; + this.tcOnly = false; + this.compilationSettings = new TypeScript.CompilationSettings(); + } + BatchCompiler.prototype.batchCompile = function () { + var _this = this; + var start = new Date().getTime(); + + TypeScript.CompilerDiagnostics.diagnosticWriter = { Alert: function (s) { + _this.ioHost.printLine(s); + } }; + + if (this.parseOptions()) { + this.logger = this.compilationSettings.gatherDiagnostics ? new DiagnosticsLogger(this.ioHost) : new TypeScript.NullLogger(); + + if (this.compilationSettings.watch) { + this.watchFiles(); + return; + } + + this.resolve(); + + if (!this.compilationSettings.updateTC) { + this.compile(); + + if (this.compilationSettings.gatherDiagnostics) { + this.logger.log(""); + this.logger.log("File resolution time: " + TypeScript.fileResolutionTime); + this.logger.log("SyntaxTree parse time: " + TypeScript.syntaxTreeParseTime); + this.logger.log("Syntax Diagnostics time: " + TypeScript.syntaxDiagnosticsTime); + this.logger.log("AST translation time: " + TypeScript.astTranslationTime); + this.logger.log(""); + this.logger.log("Type check time: " + TypeScript.typeCheckTime); + this.logger.log(""); + this.logger.log("Emit time: " + TypeScript.emitTime); + this.logger.log("Declaration emit time: " + TypeScript.declarationEmitTime); + + this.logger.log(" IsExternallyVisibleTime: " + TypeScript.declarationEmitIsExternallyVisibleTime); + this.logger.log(" TypeSignatureTime: " + TypeScript.declarationEmitTypeSignatureTime); + this.logger.log(" GetBoundDeclTypeTime: " + TypeScript.declarationEmitGetBoundDeclTypeTime); + this.logger.log(" IsOverloadedCallSignatureTime: " + TypeScript.declarationEmitIsOverloadedCallSignatureTime); + this.logger.log(" FunctionDeclarationGetSymbolTime: " + TypeScript.declarationEmitFunctionDeclarationGetSymbolTime); + this.logger.log(" GetBaseTypeTime: " + TypeScript.declarationEmitGetBaseTypeTime); + this.logger.log(" GetAccessorFunctionTime: " + TypeScript.declarationEmitGetAccessorFunctionTime); + this.logger.log(" GetTypeParameterSymbolTime: " + TypeScript.declarationEmitGetTypeParameterSymbolTime); + this.logger.log(" GetImportDeclarationSymbolTime: " + TypeScript.declarationEmitGetImportDeclarationSymbolTime); + + this.logger.log("Emit write file time: " + TypeScript.emitWriteFileTime); + this.logger.log("Emit directory exists time: " + TypeScript.emitDirectoryExistsTime); + this.logger.log("Emit file exists time: " + TypeScript.emitFileExistsTime); + this.logger.log("Emit resolve path time: " + TypeScript.emitResolvePathTime); + + this.logger.log("IO host resolve path time: " + TypeScript.ioHostResolvePathTime); + this.logger.log("IO host directory name time: " + TypeScript.ioHostDirectoryNameTime); + this.logger.log("IO host create directory structure time: " + TypeScript.ioHostCreateDirectoryStructureTime); + this.logger.log("IO host write file time: " + TypeScript.ioHostWriteFileTime); + + this.logger.log("Node make directory time: " + TypeScript.nodeMakeDirectoryTime); + this.logger.log("Node writeFileSync time: " + TypeScript.nodeWriteFileSyncTime); + this.logger.log("Node createBuffer time: " + TypeScript.nodeCreateBufferTime); + } + } else { + this.updateCompile(); + } + } + + this.ioHost.quit(this.hasErrors ? 1 : 0); + }; + + BatchCompiler.prototype.resolve = function () { + var includeDefaultLibrary = !this.compilationSettings.noLib; + var resolvedFiles = []; + + var start = new Date().getTime(); + + if (!this.compilationSettings.noResolve) { + var resolutionResults = TypeScript.ReferenceResolver.resolve(this.inputFiles, this, this.compilationSettings); + resolvedFiles = resolutionResults.resolvedFiles; + + includeDefaultLibrary = !this.compilationSettings.noLib && !resolutionResults.seenNoDefaultLibTag; + + for (var i = 0, n = resolutionResults.diagnostics.length; i < n; i++) { + this.addDiagnostic(resolutionResults.diagnostics[i]); + } + } else { + for (var i = 0, n = this.inputFiles.length; i < n; i++) { + var inputFile = this.inputFiles[i]; + var referencedFiles = []; + var importedFiles = []; + + if (this.compilationSettings.generateDeclarationFiles) { + var references = TypeScript.getReferencedFiles(inputFile, this.getScriptSnapshot(inputFile)); + references.forEach(function (reference) { + referencedFiles.push(reference.path); + }); + } + + resolvedFiles.push({ + path: inputFile, + referencedFiles: referencedFiles, + importedFiles: importedFiles + }); + } + } + + if (includeDefaultLibrary) { + var libraryResolvedFile = { + path: this.getDefaultLibraryFilePath(), + referencedFiles: [], + importedFiles: [] + }; + + resolvedFiles = [libraryResolvedFile].concat(resolvedFiles); + } + + this.resolvedFiles = resolvedFiles; + + TypeScript.fileResolutionTime = new Date().getTime() - start; + }; + + BatchCompiler.prototype.compile = function () { + var _this = this; + var compiler = new TypeScript.TypeScriptCompiler(this.logger, this.compilationSettings); + + var anySyntacticErrors = false; + var anySemanticErrors = false; + + for (var i = 0, n = this.resolvedFiles.length; i < n; i++) { + var resolvedFile = this.resolvedFiles[i]; + var sourceFile = this.getSourceFile(resolvedFile.path); + compiler.addSourceUnit(resolvedFile.path, sourceFile.scriptSnapshot, sourceFile.byteOrderMark, 0, false, resolvedFile.referencedFiles); + + var syntacticDiagnostics = compiler.getSyntacticDiagnostics(resolvedFile.path); + compiler.reportDiagnostics(syntacticDiagnostics, this); + + if (syntacticDiagnostics.length > 0) { + anySyntacticErrors = true; + } + } + + if (anySyntacticErrors) { + return true; + } + + compiler.pullTypeCheck(); + var fileNames = compiler.fileNameToDocument.getAllKeys(); + var n = fileNames.length; + for (var i = 0; i < n; i++) { + var fileName = fileNames[i]; + var semanticDiagnostics = compiler.getSemanticDiagnostics(fileName); + if (semanticDiagnostics.length > 0) { + anySemanticErrors = true; + compiler.reportDiagnostics(semanticDiagnostics, this); + } + } + + if (!this.tcOnly) { + var mapInputToOutput = function (inputFile, outputFile) { + _this.inputFileNameToOutputFileName.addOrUpdate(inputFile, outputFile); + }; + + var emitDiagnostics = compiler.emitAll(this, mapInputToOutput); + compiler.reportDiagnostics(emitDiagnostics, this); + if (emitDiagnostics.length > 0) { + return true; + } + + if (anySemanticErrors) { + return true; + } + + var emitDeclarationsDiagnostics = compiler.emitAllDeclarations(); + compiler.reportDiagnostics(emitDeclarationsDiagnostics, this); + if (emitDeclarationsDiagnostics.length > 0) { + return true; + } + } + + return false; + }; + + BatchCompiler.prototype.updateCompile = function () { + var compiler = new TypeScript.TypeScriptCompiler(this.logger, this.compilationSettings); + + var anySyntacticErrors = false; + var foundLib = false; + + for (var iCode = 0, n = this.resolvedFiles.length; iCode < n; iCode++) { + var resolvedFile = this.resolvedFiles[iCode]; + + if (resolvedFile.path.indexOf("lib.d.ts") != -1) { + foundLib = true; + } else if ((foundLib && iCode > 1) || (!foundLib && iCode > 0)) { + break; + } + + this.ioHost.stdout.WriteLine("Consuming " + resolvedFile.path + "..."); + + var sourceFile = this.getSourceFile(resolvedFile.path); + compiler.addSourceUnit(resolvedFile.path, sourceFile.scriptSnapshot, sourceFile.byteOrderMark, 0, true, resolvedFile.referencedFiles); + + var syntacticDiagnostics = compiler.getSyntacticDiagnostics(resolvedFile.path); + compiler.reportDiagnostics(syntacticDiagnostics, this); + + if (syntacticDiagnostics.length > 0) { + anySyntacticErrors = true; + } + } + + this.ioHost.stdout.WriteLine("**** Initial type check errors:"); + compiler.pullTypeCheck(); + + var semanticDiagnostics; + + for (var i = 0; i < iCode; i++) { + semanticDiagnostics = compiler.getSemanticDiagnostics(this.resolvedFiles[i].path); + compiler.reportDiagnostics(semanticDiagnostics, this); + } + + if (iCode && iCode <= this.resolvedFiles.length - 1) { + var lastTypecheckedFileName = this.resolvedFiles[iCode - 1].path; + var snapshot; + + for (; iCode < this.resolvedFiles.length; iCode++) { + var resolvedFile = this.resolvedFiles[iCode]; + var sourceFile = this.getSourceFile(resolvedFile.path); + this.ioHost.stdout.WriteLine("**** Update type check and errors for " + resolvedFile.path + ":"); + + compiler.updateSourceUnit(lastTypecheckedFileName, sourceFile.scriptSnapshot, 0, true, null); + + semanticDiagnostics = compiler.getSemanticDiagnostics(lastTypecheckedFileName); + compiler.reportDiagnostics(semanticDiagnostics, this); + } + } + + return false; + }; + + BatchCompiler.prototype.parseOptions = function () { + var _this = this; + var opts = new TypeScript.OptionsParser(this.ioHost, this.compilerVersion); + + opts.option('out', { + usage: { + locCode: TypeScript.DiagnosticCode.Concatenate_and_emit_output_to_single_file, + args: null + }, + type: TypeScript.DiagnosticCode.FILE, + set: function (str) { + _this.compilationSettings.outFileOption = str; + } + }); + + opts.option('outDir', { + usage: { + locCode: TypeScript.DiagnosticCode.Redirect_output_structure_to_the_directory, + args: null + }, + type: TypeScript.DiagnosticCode.DIRECTORY, + set: function (str) { + _this.compilationSettings.outDirOption = str; + } + }); + + opts.flag('sourcemap', { + usage: { + locCode: TypeScript.DiagnosticCode.Generates_corresponding_0_file, + args: ['.map'] + }, + set: function () { + _this.compilationSettings.mapSourceFiles = true; + } + }); + + opts.option('mapRoot', { + usage: { + locCode: TypeScript.DiagnosticCode.Specifies_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations, + args: null + }, + type: TypeScript.DiagnosticCode.LOCATION, + set: function (str) { + _this.compilationSettings.mapRoot = str; + } + }); + + opts.option('sourceRoot', { + usage: { + locCode: TypeScript.DiagnosticCode.Specifies_the_location_where_debugger_should_locate_TypeScript_files_instead_of_source_locations, + args: null + }, + type: TypeScript.DiagnosticCode.LOCATION, + set: function (str) { + _this.compilationSettings.sourceRoot = str; + } + }); + + opts.flag('declaration', { + usage: { + locCode: TypeScript.DiagnosticCode.Generates_corresponding_0_file, + args: ['.d.ts'] + }, + set: function () { + _this.compilationSettings.generateDeclarationFiles = true; + } + }, 'd'); + + if (this.ioHost.watchFile) { + opts.flag('watch', { + usage: { + locCode: TypeScript.DiagnosticCode.Watch_input_files, + args: null + }, + set: function () { + _this.compilationSettings.watch = true; + } + }, 'w'); + } + + opts.flag('propagateEnumConstants', { + experimental: true, + set: function () { + _this.compilationSettings.propagateEnumConstants = true; + } + }); + + opts.flag('removeComments', { + usage: { + locCode: TypeScript.DiagnosticCode.Do_not_emit_comments_to_output, + args: null + }, + set: function () { + _this.compilationSettings.removeComments = true; + } + }); + + opts.flag('noResolve', { + usage: { + locCode: TypeScript.DiagnosticCode.Skip_resolution_and_preprocessing, + args: null + }, + set: function () { + _this.compilationSettings.noResolve = true; + } + }); + + opts.flag('noLib', { + experimental: true, + set: function () { + _this.compilationSettings.noLib = true; + } + }); + + opts.flag('diagnostics', { + experimental: true, + set: function () { + _this.compilationSettings.gatherDiagnostics = true; + } + }); + + opts.flag('update', { + experimental: true, + set: function () { + _this.compilationSettings.updateTC = true; + } + }); + + opts.option('target', { + usage: { + locCode: TypeScript.DiagnosticCode.Specify_ECMAScript_target_version_0_default_or_1, + args: ['ES3', 'ES5'] + }, + type: TypeScript.DiagnosticCode.VERSION, + set: function (type) { + type = type.toLowerCase(); + + if (type === 'es3') { + _this.compilationSettings.codeGenTarget = 0 /* EcmaScript3 */; + } else if (type === 'es5') { + _this.compilationSettings.codeGenTarget = 1 /* EcmaScript5 */; + } else { + _this.addDiagnostic(new TypeScript.Diagnostic(null, 0, 0, TypeScript.DiagnosticCode.ECMAScript_target_version_0_not_supported_Using_default_1_code_generation, [type, "ES3"])); + } + } + }, 't'); + + opts.option('module', { + usage: { + locCode: TypeScript.DiagnosticCode.Specify_module_code_generation_0_or_1, + args: ['commonjs', 'amd'] + }, + type: TypeScript.DiagnosticCode.KIND, + set: function (type) { + type = type.toLowerCase(); + + if (type === 'commonjs') { + _this.compilationSettings.moduleGenTarget = 1 /* Synchronous */; + } else if (type === 'amd') { + _this.compilationSettings.moduleGenTarget = 2 /* Asynchronous */; + } else { + _this.addDiagnostic(new TypeScript.Diagnostic(null, 0, 0, TypeScript.DiagnosticCode.Module_code_generation_0_not_supported, [type])); + } + } + }, 'm'); + + var needsHelp = false; + opts.flag('help', { + usage: { + locCode: TypeScript.DiagnosticCode.Print_this_message, + args: null + }, + set: function () { + needsHelp = true; + } + }, 'h'); + + opts.flag('useCaseSensitiveFileResolution', { + experimental: true, + set: function () { + _this.compilationSettings.useCaseSensitiveFileResolution = true; + } + }); + var shouldPrintVersionOnly = false; + opts.flag('version', { + usage: { + locCode: TypeScript.DiagnosticCode.Print_the_compiler_s_version_0, + args: [this.compilerVersion] + }, + set: function () { + shouldPrintVersionOnly = true; + } + }, 'v'); + + var locale = null; + opts.option('locale', { + experimental: true, + usage: { + locCode: TypeScript.DiagnosticCode.Specify_locale_for_errors_and_messages_For_example_0_or_1, + args: ['en', 'ja-jp'] + }, + type: TypeScript.DiagnosticCode.STRING, + set: function (value) { + locale = value; + } + }); + + opts.flag('noImplicitAny', { + usage: { + locCode: TypeScript.DiagnosticCode.Warn_on_expressions_and_declarations_with_an_implied_any_type, + args: null + }, + set: function () { + _this.compilationSettings.noImplicitAny = true; + } + }); + + opts.parse(this.ioHost.arguments); + + if (locale) { + if (!this.setLocale(locale)) { + return false; + } + } + + for (var i = 0, n = opts.unnamed.length; i < n; i++) { + this.inputFiles.push(opts.unnamed[i]); + } + + if (this.inputFiles.length === 0 || needsHelp) { + opts.printUsage(); + return false; + } else if (shouldPrintVersionOnly) { + opts.printVersion(); + } + + return !this.hasErrors; + }; + + BatchCompiler.prototype.setLocale = function (locale) { + var matchResult = /^([a-z]+)([_\-]([a-z]+))?$/.exec(locale.toLowerCase()); + if (!matchResult) { + this.addDiagnostic(new TypeScript.Diagnostic(null, 0, 0, TypeScript.DiagnosticCode.Locale_must_be_of_the_form_language_or_language_territory_For_example_0_or_1, ['en', 'ja-jp'])); + return false; + } + + var language = matchResult[1]; + var territory = matchResult[3]; + + if (!this.setLanguageAndTerritory(language, territory) && !this.setLanguageAndTerritory(language, null)) { + this.addDiagnostic(new TypeScript.Diagnostic(null, 0, 0, TypeScript.DiagnosticCode.Unsupported_locale_0, [locale])); + return false; + } + + return true; + }; + + BatchCompiler.prototype.setLanguageAndTerritory = function (language, territory) { + var compilerFilePath = this.ioHost.getExecutingFilePath(); + var containingDirectoryPath = this.ioHost.dirName(compilerFilePath); + + var filePath = IOUtils.combine(containingDirectoryPath, language); + if (territory) { + filePath = filePath + "-" + territory; + } + + filePath = this.ioHost.resolvePath(IOUtils.combine(filePath, "diagnosticMessages.generated.json")); + + if (!this.ioHost.fileExists(filePath)) { + return false; + } + + var fileContents = this.ioHost.readFile(filePath); + TypeScript.LocalizedDiagnosticMessages = JSON.parse(fileContents.contents); + return true; + }; + + BatchCompiler.prototype.watchFiles = function () { + var _this = this; + if (!this.ioHost.watchFile) { + this.addDiagnostic(new TypeScript.Diagnostic(null, 0, 0, TypeScript.DiagnosticCode.Current_host_does_not_support_0_option, ['-w[atch]'])); + return; + } + + var lastResolvedFileSet = []; + var watchers = {}; + var firstTime = true; + + var addWatcher = function (fileName) { + if (!watchers[fileName]) { + var watcher = _this.ioHost.watchFile(fileName, onWatchedFileChange); + watchers[fileName] = watcher; + } else { + TypeScript.CompilerDiagnostics.debugPrint("Cannot watch file, it is already watched."); + } + }; + + var removeWatcher = function (fileName) { + if (watchers[fileName]) { + watchers[fileName].close(); + delete watchers[fileName]; + } else { + TypeScript.CompilerDiagnostics.debugPrint("Cannot stop watching file, it is not being watched."); + } + }; + + var onWatchedFileChange = function () { + _this.hasErrors = false; + + _this.fileNameToSourceFile = new TypeScript.StringHashTable(); + + _this.resolve(); + + var oldFiles = lastResolvedFileSet; + var newFiles = _this.resolvedFiles.map(function (resolvedFile) { + return resolvedFile.path; + }).sort(); + + var i = 0, j = 0; + while (i < oldFiles.length && j < newFiles.length) { + var compareResult = oldFiles[i].localeCompare(newFiles[j]); + if (compareResult === 0) { + i++; + j++; + } else if (compareResult < 0) { + removeWatcher(oldFiles[i]); + i++; + } else { + addWatcher(newFiles[j]); + j++; + } + } + + for (var k = i; k < oldFiles.length; k++) { + removeWatcher(oldFiles[k]); + } + + for (k = j; k < newFiles.length; k++) { + addWatcher(newFiles[k]); + } + + lastResolvedFileSet = newFiles; + + if (!firstTime) { + var fileNames = ""; + lastResolvedFileSet.forEach(function (f) { + fileNames += Environment.newLine + " " + f; + }); + _this.ioHost.printLine(TypeScript.getLocalizedText(TypeScript.DiagnosticCode.NL_Recompiling_0, [fileNames])); + } else { + firstTime = false; + } + + _this.compile(); + }; + + this.ioHost.stderr = this.ioHost.stdout; + + onWatchedFileChange(); + }; + + BatchCompiler.prototype.getSourceFile = function (fileName) { + var sourceFile = this.fileNameToSourceFile.lookup(fileName); + if (!sourceFile) { + var fileInformation; + + try { + fileInformation = this.ioHost.readFile(fileName); + } catch (e) { + this.addDiagnostic(new TypeScript.Diagnostic(null, 0, 0, TypeScript.DiagnosticCode.Cannot_read_file_0_1, [fileName, e.message])); + fileInformation = new FileInformation("", 0 /* None */); + } + + var snapshot = TypeScript.ScriptSnapshot.fromString(fileInformation.contents); + var sourceFile = new SourceFile(snapshot, fileInformation.byteOrderMark); + this.fileNameToSourceFile.add(fileName, sourceFile); + } + + return sourceFile; + }; + + BatchCompiler.prototype.getDefaultLibraryFilePath = function () { + var compilerFilePath = this.ioHost.getExecutingFilePath(); + var containingDirectoryPath = this.ioHost.dirName(compilerFilePath); + var libraryFilePath = this.ioHost.resolvePath(IOUtils.combine(containingDirectoryPath, "lib.d.ts")); + + return libraryFilePath; + }; + + BatchCompiler.prototype.getScriptSnapshot = function (fileName) { + return this.getSourceFile(fileName).scriptSnapshot; + }; + + BatchCompiler.prototype.resolveRelativePath = function (path, directory) { + var unQuotedPath = TypeScript.stripQuotes(path); + var normalizedPath; + + if (TypeScript.isRooted(unQuotedPath) || !directory) { + normalizedPath = unQuotedPath; + } else { + normalizedPath = IOUtils.combine(directory, unQuotedPath); + } + + normalizedPath = this.resolvePath(normalizedPath); + + normalizedPath = TypeScript.switchToForwardSlashes(normalizedPath); + + return normalizedPath; + }; + + BatchCompiler.prototype.fileExists = function (path) { + var start = new Date().getTime(); + var result = this.ioHost.fileExists(path); + TypeScript.emitFileExistsTime += new Date().getTime() - start; + return result; + }; + + BatchCompiler.prototype.getParentDirectory = function (path) { + return this.ioHost.dirName(path); + }; + + BatchCompiler.prototype.addDiagnostic = function (diagnostic) { + this.hasErrors = true; + + if (diagnostic.fileName()) { + var scriptSnapshot = this.getScriptSnapshot(diagnostic.fileName()); + var lineMap = new TypeScript.LineMap(scriptSnapshot.getLineStartPositions(), scriptSnapshot.getLength()); + var lineCol = { line: -1, character: -1 }; + lineMap.fillLineAndCharacterFromPosition(diagnostic.start(), lineCol); + + this.ioHost.stderr.Write(diagnostic.fileName() + "(" + (lineCol.line + 1) + "," + (lineCol.character + 1) + "): "); + } + + this.ioHost.stderr.WriteLine(diagnostic.message()); + }; + + BatchCompiler.prototype.writeFile = function (fileName, contents, writeByteOrderMark) { + var start = new Date().getTime(); + IOUtils.writeFileAndFolderStructure(this.ioHost, fileName, contents, writeByteOrderMark); + TypeScript.emitWriteFileTime += new Date().getTime() - start; + }; + + BatchCompiler.prototype.directoryExists = function (path) { + var start = new Date().getTime(); + var result = this.ioHost.directoryExists(path); + TypeScript.emitDirectoryExistsTime += new Date().getTime() - start; + return result; + }; + + BatchCompiler.prototype.resolvePath = function (path) { + var start = new Date().getTime(); + var result = this.ioHost.resolvePath(path); + TypeScript.emitResolvePathTime += new Date().getTime() - start; + return result; + }; + return BatchCompiler; + })(); + TypeScript.BatchCompiler = BatchCompiler; +})(TypeScript || (TypeScript = {})); + +var batch = new TypeScript.BatchCompiler(IO); +batch.batchCompile(); diff --git a/_infrastructure/tests/typescript/typescript.js b/_infrastructure/tests/typescript/typescript.js index 0fdb51331..d25291ab0 100644 --- a/_infrastructure/tests/typescript/typescript.js +++ b/_infrastructure/tests/typescript/typescript.js @@ -1,55609 +1,54655 @@ -/* ***************************************************************************** -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 - -THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED -WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, -MERCHANTABLITY OR NON-INFRINGEMENT. - -See the Apache Version 2.0 License for specific language governing permissions -and limitations under the License. -***************************************************************************** */ - -var TypeScript; -(function (TypeScript) { - var ArrayUtilities = (function () { - function ArrayUtilities() { - } - ArrayUtilities.isArray = function (value) { - return Object.prototype.toString.apply(value, []) === '[object Array]'; - }; - - ArrayUtilities.sequenceEquals = function (array1, array2, equals) { - if (array1 === array2) { - return true; - } - - if (array1 === null || array2 === null) { - 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; - }; - - ArrayUtilities.contains = function (array, value) { - for (var i = 0; i < array.length; i++) { - if (array[i] === value) { - return true; - } - } - - return false; - }; - - ArrayUtilities.groupBy = function (array, func) { - var result = {}; - - for (var i = 0, n = array.length; i < n; i++) { - var v = array[i]; - var k = func(v); - - var list = result[k] || []; - list.push(v); - result[k] = list; - } - - return result; - }; - - ArrayUtilities.min = function (array, func) { - var min = func(array[0]); - - for (var i = 1; i < array.length; i++) { - var next = func(array[i]); - if (next < min) { - min = next; - } - } - - return min; - }; - - ArrayUtilities.max = function (array, func) { - var max = func(array[0]); - - for (var i = 1; i < array.length; i++) { - var next = func(array[i]); - if (next > max) { - max = next; - } - } - - return max; - }; - - ArrayUtilities.last = function (array) { - if (array.length === 0) { - throw TypeScript.Errors.argumentOutOfRange('array'); - } - - return array[array.length - 1]; - }; - - ArrayUtilities.firstOrDefault = function (array, func) { - for (var i = 0, n = array.length; i < n; i++) { - var value = array[i]; - if (func(value)) { - return value; - } - } - - return null; - }; - - ArrayUtilities.sum = function (array, func) { - var result = 0; - - for (var i = 0, n = array.length; i < n; i++) { - result += func(array[i]); - } - - return result; - }; - - ArrayUtilities.whereNotNull = function (array) { - var result = []; - for (var i = 0; i < array.length; i++) { - var value = array[i]; - if (value !== null) { - result.push(value); - } - } - - return result; - }; - - ArrayUtilities.select = function (values, func) { - var result = []; - - for (var i = 0; i < values.length; i++) { - result.push(func(values[i])); - } - - return result; - }; - - ArrayUtilities.where = function (values, func) { - var result = []; - - for (var i = 0; i < values.length; i++) { - if (func(values[i])) { - result.push(values[i]); - } - } - - return result; - }; - - ArrayUtilities.any = function (array, func) { - for (var i = 0, n = array.length; i < n; i++) { - if (func(array[i])) { - return true; - } - } - - return false; - }; - - ArrayUtilities.all = function (array, func) { - for (var i = 0, n = array.length; i < n; i++) { - if (!func(array[i])) { - return false; - } - } - - return true; - }; - - ArrayUtilities.binarySearch = function (array, value) { - 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; - }; - - ArrayUtilities.createArray = function (length, defaultvalue) { - var result = []; - for (var i = 0; i < length; i++) { - result.push(defaultvalue); - } - - return result; - }; - - ArrayUtilities.grow = function (array, length, defaultValue) { - var count = length - array.length; - for (var i = 0; i < count; i++) { - array.push(defaultValue); - } - }; - - ArrayUtilities.copy = function (sourceArray, sourceIndex, destinationArray, destinationIndex, length) { - for (var i = 0; i < length; i++) { - destinationArray[destinationIndex + i] = sourceArray[sourceIndex + i]; - } - }; - return ArrayUtilities; - })(); - TypeScript.ArrayUtilities = ArrayUtilities; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (Constants) { - Constants[Constants["Max31BitInteger"] = 1073741823] = "Max31BitInteger"; - Constants[Constants["Min31BitInteger"] = -1073741824] = "Min31BitInteger"; - })(TypeScript.Constants || (TypeScript.Constants = {})); - var Constants = TypeScript.Constants; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var Contract = (function () { - function Contract() { - } - Contract.requires = function (expression) { - if (!expression) { - throw new Error("Contract violated. False expression."); - } - }; - - Contract.throwIfFalse = function (expression) { - if (!expression) { - throw new Error("Contract violated. False expression."); - } - }; - - Contract.throwIfNull = function (value) { - if (value === null) { - throw new Error("Contract violated. Null value."); - } - }; - return Contract; - })(); - TypeScript.Contract = Contract; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var Debug = (function () { - function Debug() { - } - Debug.assert = function (expression, message) { - if (!expression) { - throw new Error("Debug Failure. False expression: " + (message ? message : "")); - } - }; - return Debug; - })(); - TypeScript.Debug = Debug; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (DiagnosticCategory) { - DiagnosticCategory[DiagnosticCategory["Warning"] = 0] = "Warning"; - DiagnosticCategory[DiagnosticCategory["Error"] = 1] = "Error"; - DiagnosticCategory[DiagnosticCategory["Message"] = 2] = "Message"; - DiagnosticCategory[DiagnosticCategory["NoPrefix"] = 3] = "NoPrefix"; - })(TypeScript.DiagnosticCategory || (TypeScript.DiagnosticCategory = {})); - var DiagnosticCategory = TypeScript.DiagnosticCategory; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (DiagnosticCode) { - DiagnosticCode[DiagnosticCode["error_TS_0__1"] = 0] = "error_TS_0__1"; - DiagnosticCode[DiagnosticCode["warning_TS_0__1"] = 1] = "warning_TS_0__1"; - - DiagnosticCode[DiagnosticCode["_0__NL__1_TB__2"] = 2] = "_0__NL__1_TB__2"; - DiagnosticCode[DiagnosticCode["_0_TB__1"] = 3] = "_0_TB__1"; - - DiagnosticCode[DiagnosticCode["Unrecognized_escape_sequence"] = 4] = "Unrecognized_escape_sequence"; - DiagnosticCode[DiagnosticCode["Unexpected_character_0"] = 5] = "Unexpected_character_0"; - DiagnosticCode[DiagnosticCode["Missing_closing_quote_character"] = 6] = "Missing_closing_quote_character"; - DiagnosticCode[DiagnosticCode["Identifier_expected"] = 7] = "Identifier_expected"; - DiagnosticCode[DiagnosticCode["_0_keyword_expected"] = 8] = "_0_keyword_expected"; - DiagnosticCode[DiagnosticCode["_0_expected"] = 9] = "_0_expected"; - DiagnosticCode[DiagnosticCode["Identifier_expected__0__is_a_keyword"] = 10] = "Identifier_expected__0__is_a_keyword"; - DiagnosticCode[DiagnosticCode["Automatic_semicolon_insertion_not_allowed"] = 11] = "Automatic_semicolon_insertion_not_allowed"; - DiagnosticCode[DiagnosticCode["Unexpected_token__0_expected"] = 12] = "Unexpected_token__0_expected"; - DiagnosticCode[DiagnosticCode["Trailing_separator_not_allowed"] = 13] = "Trailing_separator_not_allowed"; - DiagnosticCode[DiagnosticCode["_StarSlash__expected"] = 14] = "_StarSlash__expected"; - DiagnosticCode[DiagnosticCode["_public_or_private_modifier_must_precede__static_"] = 15] = "_public_or_private_modifier_must_precede__static_"; - DiagnosticCode[DiagnosticCode["Unexpected_token_"] = 16] = "Unexpected_token_"; - DiagnosticCode[DiagnosticCode["A_catch_clause_variable_cannot_have_a_type_annotation"] = 17] = "A_catch_clause_variable_cannot_have_a_type_annotation"; - DiagnosticCode[DiagnosticCode["Rest_parameter_must_be_last_in_list"] = 18] = "Rest_parameter_must_be_last_in_list"; - DiagnosticCode[DiagnosticCode["Parameter_cannot_have_question_mark_and_initializer"] = 19] = "Parameter_cannot_have_question_mark_and_initializer"; - DiagnosticCode[DiagnosticCode["Required_parameter_cannot_follow_optional_parameter"] = 20] = "Required_parameter_cannot_follow_optional_parameter"; - DiagnosticCode[DiagnosticCode["Index_signatures_cannot_have_rest_parameters"] = 21] = "Index_signatures_cannot_have_rest_parameters"; - DiagnosticCode[DiagnosticCode["Index_signature_parameter_cannot_have_accessibility_modifiers"] = 22] = "Index_signature_parameter_cannot_have_accessibility_modifiers"; - DiagnosticCode[DiagnosticCode["Index_signature_parameter_cannot_have_a_question_mark"] = 23] = "Index_signature_parameter_cannot_have_a_question_mark"; - DiagnosticCode[DiagnosticCode["Index_signature_parameter_cannot_have_an_initializer"] = 24] = "Index_signature_parameter_cannot_have_an_initializer"; - DiagnosticCode[DiagnosticCode["Index_signature_must_have_a_type_annotation"] = 25] = "Index_signature_must_have_a_type_annotation"; - DiagnosticCode[DiagnosticCode["Index_signature_parameter_must_have_a_type_annotation"] = 26] = "Index_signature_parameter_must_have_a_type_annotation"; - DiagnosticCode[DiagnosticCode["Index_signature_parameter_type_must_be__string__or__number_"] = 27] = "Index_signature_parameter_type_must_be__string__or__number_"; - DiagnosticCode[DiagnosticCode["_extends__clause_already_seen"] = 28] = "_extends__clause_already_seen"; - DiagnosticCode[DiagnosticCode["_extends__clause_must_precede__implements__clause"] = 29] = "_extends__clause_must_precede__implements__clause"; - DiagnosticCode[DiagnosticCode["Class_can_only_extend_single_type"] = 30] = "Class_can_only_extend_single_type"; - DiagnosticCode[DiagnosticCode["_implements__clause_already_seen"] = 31] = "_implements__clause_already_seen"; - DiagnosticCode[DiagnosticCode["Accessibility_modifier_already_seen"] = 32] = "Accessibility_modifier_already_seen"; - DiagnosticCode[DiagnosticCode["_0__modifier_must_precede__1__modifier"] = 33] = "_0__modifier_must_precede__1__modifier"; - DiagnosticCode[DiagnosticCode["_0__modifier_already_seen"] = 34] = "_0__modifier_already_seen"; - DiagnosticCode[DiagnosticCode["_0__modifier_cannot_appear_on_a_class_element"] = 35] = "_0__modifier_cannot_appear_on_a_class_element"; - DiagnosticCode[DiagnosticCode["Interface_declaration_cannot_have__implements__clause"] = 36] = "Interface_declaration_cannot_have__implements__clause"; - DiagnosticCode[DiagnosticCode["_super__invocation_cannot_have_type_arguments"] = 37] = "_super__invocation_cannot_have_type_arguments"; - DiagnosticCode[DiagnosticCode["Non_ambient_modules_cannot_use_quoted_names"] = 38] = "Non_ambient_modules_cannot_use_quoted_names"; - DiagnosticCode[DiagnosticCode["Statements_are_not_allowed_in_ambient_contexts"] = 39] = "Statements_are_not_allowed_in_ambient_contexts"; - DiagnosticCode[DiagnosticCode["Implementations_are_not_allowed_in_ambient_contexts"] = 40] = "Implementations_are_not_allowed_in_ambient_contexts"; - DiagnosticCode[DiagnosticCode["_declare__modifier_not_allowed_for_code_already_in_an_ambient_context"] = 41] = "_declare__modifier_not_allowed_for_code_already_in_an_ambient_context"; - DiagnosticCode[DiagnosticCode["Initializers_are_not_allowed_in_ambient_contexts"] = 42] = "Initializers_are_not_allowed_in_ambient_contexts"; - DiagnosticCode[DiagnosticCode["Overload_and_ambient_signatures_cannot_specify_parameter_properties"] = 43] = "Overload_and_ambient_signatures_cannot_specify_parameter_properties"; - DiagnosticCode[DiagnosticCode["Function_implementation_expected"] = 44] = "Function_implementation_expected"; - DiagnosticCode[DiagnosticCode["Constructor_implementation_expected"] = 45] = "Constructor_implementation_expected"; - DiagnosticCode[DiagnosticCode["Function_overload_name_must_be__0_"] = 46] = "Function_overload_name_must_be__0_"; - DiagnosticCode[DiagnosticCode["_0__modifier_cannot_appear_on_a_module_element"] = 47] = "_0__modifier_cannot_appear_on_a_module_element"; - DiagnosticCode[DiagnosticCode["_declare__modifier_cannot_appear_on_an_interface_declaration"] = 48] = "_declare__modifier_cannot_appear_on_an_interface_declaration"; - DiagnosticCode[DiagnosticCode["_declare__modifier_required_for_top_level_element"] = 49] = "_declare__modifier_required_for_top_level_element"; - DiagnosticCode[DiagnosticCode["_set__accessor_must_have_only_one_parameter"] = 50] = "_set__accessor_must_have_only_one_parameter"; - DiagnosticCode[DiagnosticCode["_set__accessor_parameter_cannot_have_accessibility_modifier"] = 51] = "_set__accessor_parameter_cannot_have_accessibility_modifier"; - DiagnosticCode[DiagnosticCode["_set__accessor_parameter_cannot_be_optional"] = 52] = "_set__accessor_parameter_cannot_be_optional"; - DiagnosticCode[DiagnosticCode["_set__accessor_parameter_cannot_have_initializer"] = 53] = "_set__accessor_parameter_cannot_have_initializer"; - DiagnosticCode[DiagnosticCode["_set__accessor_cannot_have_rest_parameter"] = 54] = "_set__accessor_cannot_have_rest_parameter"; - DiagnosticCode[DiagnosticCode["_get__accessor_cannot_have_parameters"] = 55] = "_get__accessor_cannot_have_parameters"; - DiagnosticCode[DiagnosticCode["Rest_parameter_cannot_be_optional"] = 56] = "Rest_parameter_cannot_be_optional"; - DiagnosticCode[DiagnosticCode["Rest_parameter_cannot_have_initializer"] = 57] = "Rest_parameter_cannot_have_initializer"; - DiagnosticCode[DiagnosticCode["Modifiers_cannot_appear_here"] = 58] = "Modifiers_cannot_appear_here"; - DiagnosticCode[DiagnosticCode["Accessors_are_only_available_when_targeting_EcmaScript5_and_higher"] = 59] = "Accessors_are_only_available_when_targeting_EcmaScript5_and_higher"; - DiagnosticCode[DiagnosticCode["Class_name_cannot_be__0_"] = 60] = "Class_name_cannot_be__0_"; - DiagnosticCode[DiagnosticCode["Interface_name_cannot_be__0_"] = 61] = "Interface_name_cannot_be__0_"; - DiagnosticCode[DiagnosticCode["Enum_name_cannot_be__0_"] = 62] = "Enum_name_cannot_be__0_"; - DiagnosticCode[DiagnosticCode["Module_name_cannot_be__0_"] = 63] = "Module_name_cannot_be__0_"; - DiagnosticCode[DiagnosticCode["Enum_member_must_have_initializer"] = 64] = "Enum_member_must_have_initializer"; - DiagnosticCode[DiagnosticCode["_module_______is_deprecated__Use__require_______instead"] = 65] = "_module_______is_deprecated__Use__require_______instead"; - DiagnosticCode[DiagnosticCode["Export_assignments_cannot_be_used_in_internal_modules"] = 66] = "Export_assignments_cannot_be_used_in_internal_modules"; - DiagnosticCode[DiagnosticCode["Export_assignment_not_allowed_in_module_with_exported_element"] = 67] = "Export_assignment_not_allowed_in_module_with_exported_element"; - DiagnosticCode[DiagnosticCode["Module_cannot_have_multiple_export_assignments"] = 68] = "Module_cannot_have_multiple_export_assignments"; - - DiagnosticCode[DiagnosticCode["Duplicate_identifier__0_"] = 69] = "Duplicate_identifier__0_"; - DiagnosticCode[DiagnosticCode["The_name__0__does_not_exist_in_the_current_scope"] = 70] = "The_name__0__does_not_exist_in_the_current_scope"; - DiagnosticCode[DiagnosticCode["The_name__0__does_not_refer_to_a_value"] = 71] = "The_name__0__does_not_refer_to_a_value"; - DiagnosticCode[DiagnosticCode["Keyword__super__can_only_be_used_inside_a_class_instance_method"] = 72] = "Keyword__super__can_only_be_used_inside_a_class_instance_method"; - DiagnosticCode[DiagnosticCode["The_left_hand_side_of_an_assignment_expression_must_be_a_variable__property_or_indexer"] = 73] = "The_left_hand_side_of_an_assignment_expression_must_be_a_variable__property_or_indexer"; - DiagnosticCode[DiagnosticCode["Value_of_type__0__is_not_callable__Did_you_mean_to_include__new__"] = 74] = "Value_of_type__0__is_not_callable__Did_you_mean_to_include__new__"; - DiagnosticCode[DiagnosticCode["Value_of_type__0__is_not_callable"] = 75] = "Value_of_type__0__is_not_callable"; - DiagnosticCode[DiagnosticCode["Value_of_type__0__is_not_newable"] = 76] = "Value_of_type__0__is_not_newable"; - DiagnosticCode[DiagnosticCode["Value_of_type__0__is_not_indexable_by_type__1_"] = 77] = "Value_of_type__0__is_not_indexable_by_type__1_"; - DiagnosticCode[DiagnosticCode["Operator__0__cannot_be_applied_to_types__1__and__2_"] = 78] = "Operator__0__cannot_be_applied_to_types__1__and__2_"; - DiagnosticCode[DiagnosticCode["Operator__0__cannot_be_applied_to_types__1__and__2__3"] = 79] = "Operator__0__cannot_be_applied_to_types__1__and__2__3"; - DiagnosticCode[DiagnosticCode["Cannot_convert__0__to__1_"] = 80] = "Cannot_convert__0__to__1_"; - DiagnosticCode[DiagnosticCode["Cannot_convert__0__to__1__NL__2"] = 81] = "Cannot_convert__0__to__1__NL__2"; - DiagnosticCode[DiagnosticCode["Expected_var__class__interface__or_module"] = 82] = "Expected_var__class__interface__or_module"; - DiagnosticCode[DiagnosticCode["Operator__0__cannot_be_applied_to_type__1_"] = 83] = "Operator__0__cannot_be_applied_to_type__1_"; - DiagnosticCode[DiagnosticCode["Getter__0__already_declared"] = 84] = "Getter__0__already_declared"; - DiagnosticCode[DiagnosticCode["Setter__0__already_declared"] = 85] = "Setter__0__already_declared"; - DiagnosticCode[DiagnosticCode["Accessor_cannot_have_type_parameters"] = 86] = "Accessor_cannot_have_type_parameters"; - DiagnosticCode[DiagnosticCode["Exported_class__0__extends_private_class__1_"] = 87] = "Exported_class__0__extends_private_class__1_"; - DiagnosticCode[DiagnosticCode["Exported_class__0__implements_private_interface__1_"] = 88] = "Exported_class__0__implements_private_interface__1_"; - DiagnosticCode[DiagnosticCode["Exported_interface__0__extends_private_interface__1_"] = 89] = "Exported_interface__0__extends_private_interface__1_"; - DiagnosticCode[DiagnosticCode["Exported_class__0__extends_class_from_inaccessible_module__1_"] = 90] = "Exported_class__0__extends_class_from_inaccessible_module__1_"; - DiagnosticCode[DiagnosticCode["Exported_class__0__implements_interface_from_inaccessible_module__1_"] = 91] = "Exported_class__0__implements_interface_from_inaccessible_module__1_"; - DiagnosticCode[DiagnosticCode["Exported_interface__0__extends_interface_from_inaccessible_module__1_"] = 92] = "Exported_interface__0__extends_interface_from_inaccessible_module__1_"; - DiagnosticCode[DiagnosticCode["Public_static_property__0__of__exported_class_has_or_is_using_private_type__1_"] = 93] = "Public_static_property__0__of__exported_class_has_or_is_using_private_type__1_"; - DiagnosticCode[DiagnosticCode["Public_property__0__of__exported_class_has_or_is_using_private_type__1_"] = 94] = "Public_property__0__of__exported_class_has_or_is_using_private_type__1_"; - DiagnosticCode[DiagnosticCode["Property__0__of__exported_interface_has_or_is_using_private_type__1_"] = 95] = "Property__0__of__exported_interface_has_or_is_using_private_type__1_"; - DiagnosticCode[DiagnosticCode["Exported_variable__0__has_or_is_using_private_type__1_"] = 96] = "Exported_variable__0__has_or_is_using_private_type__1_"; - DiagnosticCode[DiagnosticCode["Public_static_property__0__of__exported_class_is_using_inaccessible_module__1_"] = 97] = "Public_static_property__0__of__exported_class_is_using_inaccessible_module__1_"; - DiagnosticCode[DiagnosticCode["Public_property__0__of__exported_class_is_using_inaccessible_module__1_"] = 98] = "Public_property__0__of__exported_class_is_using_inaccessible_module__1_"; - DiagnosticCode[DiagnosticCode["Property__0__of__exported_interface_is_using_inaccessible_module__1_"] = 99] = "Property__0__of__exported_interface_is_using_inaccessible_module__1_"; - DiagnosticCode[DiagnosticCode["Exported_variable__0__is_using_inaccessible_module__1_"] = 100] = "Exported_variable__0__is_using_inaccessible_module__1_"; - DiagnosticCode[DiagnosticCode["Parameter__0__of_constructor_from_exported_class_has_or_is_using_private_type__1_"] = 101] = "Parameter__0__of_constructor_from_exported_class_has_or_is_using_private_type__1_"; - DiagnosticCode[DiagnosticCode["Parameter__0__of_public_static_property_setter_from_exported_class_has_or_is_using_private_type__1_"] = 102] = "Parameter__0__of_public_static_property_setter_from_exported_class_has_or_is_using_private_type__1_"; - DiagnosticCode[DiagnosticCode["Parameter__0__of_public_property_setter_from_exported_class_has_or_is_using_private_type__1_"] = 103] = "Parameter__0__of_public_property_setter_from_exported_class_has_or_is_using_private_type__1_"; - DiagnosticCode[DiagnosticCode["Parameter__0__of_constructor_signature_from_exported_interface_has_or_is_using_private_type__1_"] = 104] = "Parameter__0__of_constructor_signature_from_exported_interface_has_or_is_using_private_type__1_"; - DiagnosticCode[DiagnosticCode["Parameter__0__of_call_signature_from_exported_interface_has_or_is_using_private_type__1_"] = 105] = "Parameter__0__of_call_signature_from_exported_interface_has_or_is_using_private_type__1_"; - DiagnosticCode[DiagnosticCode["Parameter__0__of_public_static_method_from_exported_class_has_or_is_using_private_type__1_"] = 106] = "Parameter__0__of_public_static_method_from_exported_class_has_or_is_using_private_type__1_"; - DiagnosticCode[DiagnosticCode["Parameter__0__of_public_method_from_exported_class_has_or_is_using_private_type__1_"] = 107] = "Parameter__0__of_public_method_from_exported_class_has_or_is_using_private_type__1_"; - DiagnosticCode[DiagnosticCode["Parameter__0__of_method_from_exported_interface_has_or_is_using_private_type__1_"] = 108] = "Parameter__0__of_method_from_exported_interface_has_or_is_using_private_type__1_"; - DiagnosticCode[DiagnosticCode["Parameter__0__of_exported_function_has_or_is_using_private_type__1_"] = 109] = "Parameter__0__of_exported_function_has_or_is_using_private_type__1_"; - DiagnosticCode[DiagnosticCode["Parameter__0__of_constructor_from_exported_class_is_using_inaccessible_module__1_"] = 110] = "Parameter__0__of_constructor_from_exported_class_is_using_inaccessible_module__1_"; - DiagnosticCode[DiagnosticCode["Parameter__0__of_public_static_property_setter_from_exported_class_is_using_inaccessible_module__1_"] = 111] = "Parameter__0__of_public_static_property_setter_from_exported_class_is_using_inaccessible_module__1_"; - DiagnosticCode[DiagnosticCode["Parameter__0__of_public_property_setter_from_exported_class_is_using_inaccessible_module__1_"] = 112] = "Parameter__0__of_public_property_setter_from_exported_class_is_using_inaccessible_module__1_"; - DiagnosticCode[DiagnosticCode["Parameter__0__of_constructor_signature_from_exported_interface_is_using_inaccessible_module__1_"] = 113] = "Parameter__0__of_constructor_signature_from_exported_interface_is_using_inaccessible_module__1_"; - DiagnosticCode[DiagnosticCode["Parameter__0__of_call_signature_from_exported_interface_is_using_inaccessible_module__1_"] = 114] = "Parameter__0__of_call_signature_from_exported_interface_is_using_inaccessible_module__1_"; - DiagnosticCode[DiagnosticCode["Parameter__0__of_public_static_method_from_exported_class_is_using_inaccessible_module__1_"] = 115] = "Parameter__0__of_public_static_method_from_exported_class_is_using_inaccessible_module__1_"; - DiagnosticCode[DiagnosticCode["Parameter__0__of_public_method_from_exported_class_is_using_inaccessible_module__1_"] = 116] = "Parameter__0__of_public_method_from_exported_class_is_using_inaccessible_module__1_"; - DiagnosticCode[DiagnosticCode["Parameter__0__of_method_from_exported_interface_is_using_inaccessible_module__1_"] = 117] = "Parameter__0__of_method_from_exported_interface_is_using_inaccessible_module__1_"; - DiagnosticCode[DiagnosticCode["Parameter__0__of_exported_function_is_using_inaccessible_module__1_"] = 118] = "Parameter__0__of_exported_function_is_using_inaccessible_module__1_"; - DiagnosticCode[DiagnosticCode["Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_private_type__0_"] = 119] = "Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_private_type__0_"; - DiagnosticCode[DiagnosticCode["Return_type_of_public_property_getter_from_exported_class_has_or_is_using_private_type__0_"] = 120] = "Return_type_of_public_property_getter_from_exported_class_has_or_is_using_private_type__0_"; - DiagnosticCode[DiagnosticCode["Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_private_type__0_"] = 121] = "Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_private_type__0_"; - DiagnosticCode[DiagnosticCode["Return_type_of_call_signature_from_exported_interface_has_or_is_using_private_type__0_"] = 122] = "Return_type_of_call_signature_from_exported_interface_has_or_is_using_private_type__0_"; - DiagnosticCode[DiagnosticCode["Return_type_of_index_signature_from_exported_interface_has_or_is_using_private_type__0_"] = 123] = "Return_type_of_index_signature_from_exported_interface_has_or_is_using_private_type__0_"; - DiagnosticCode[DiagnosticCode["Return_type_of_public_static_method_from_exported_class_has_or_is_using_private_type__0_"] = 124] = "Return_type_of_public_static_method_from_exported_class_has_or_is_using_private_type__0_"; - DiagnosticCode[DiagnosticCode["Return_type_of_public_method_from_exported_class_has_or_is_using_private_type__0_"] = 125] = "Return_type_of_public_method_from_exported_class_has_or_is_using_private_type__0_"; - DiagnosticCode[DiagnosticCode["Return_type_of_method_from_exported_interface_has_or_is_using_private_type__0_"] = 126] = "Return_type_of_method_from_exported_interface_has_or_is_using_private_type__0_"; - DiagnosticCode[DiagnosticCode["Return_type_of_exported_function_has_or_is_using_private_type__0_"] = 127] = "Return_type_of_exported_function_has_or_is_using_private_type__0_"; - DiagnosticCode[DiagnosticCode["Return_type_of_public_static_property_getter_from_exported_class_is_using_inaccessible_module__0_"] = 128] = "Return_type_of_public_static_property_getter_from_exported_class_is_using_inaccessible_module__0_"; - DiagnosticCode[DiagnosticCode["Return_type_of_public_property_getter_from_exported_class_is_using_inaccessible_module__0_"] = 129] = "Return_type_of_public_property_getter_from_exported_class_is_using_inaccessible_module__0_"; - DiagnosticCode[DiagnosticCode["Return_type_of_constructor_signature_from_exported_interface_is_using_inaccessible_module__0_"] = 130] = "Return_type_of_constructor_signature_from_exported_interface_is_using_inaccessible_module__0_"; - DiagnosticCode[DiagnosticCode["Return_type_of_call_signature_from_exported_interface_is_using_inaccessible_module__0_"] = 131] = "Return_type_of_call_signature_from_exported_interface_is_using_inaccessible_module__0_"; - DiagnosticCode[DiagnosticCode["Return_type_of_index_signature_from_exported_interface_is_using_inaccessible_module__0_"] = 132] = "Return_type_of_index_signature_from_exported_interface_is_using_inaccessible_module__0_"; - DiagnosticCode[DiagnosticCode["Return_type_of_public_static_method_from_exported_class_is_using_inaccessible_module__0_"] = 133] = "Return_type_of_public_static_method_from_exported_class_is_using_inaccessible_module__0_"; - DiagnosticCode[DiagnosticCode["Return_type_of_public_method_from_exported_class_is_using_inaccessible_module__0_"] = 134] = "Return_type_of_public_method_from_exported_class_is_using_inaccessible_module__0_"; - DiagnosticCode[DiagnosticCode["Return_type_of_method_from_exported_interface_is_using_inaccessible_module__0_"] = 135] = "Return_type_of_method_from_exported_interface_is_using_inaccessible_module__0_"; - DiagnosticCode[DiagnosticCode["Return_type_of_exported_function_is_using_inaccessible_module__0_"] = 136] = "Return_type_of_exported_function_is_using_inaccessible_module__0_"; - DiagnosticCode[DiagnosticCode["_new_T____cannot_be_used_to_create_an_array__Use__new_Array_T_____instead"] = 137] = "_new_T____cannot_be_used_to_create_an_array__Use__new_Array_T_____instead"; - DiagnosticCode[DiagnosticCode["A_parameter_list_must_follow_a_generic_type_argument_list______expected"] = 138] = "A_parameter_list_must_follow_a_generic_type_argument_list______expected"; - DiagnosticCode[DiagnosticCode["Multiple_constructor_implementations_are_not_allowed"] = 139] = "Multiple_constructor_implementations_are_not_allowed"; - DiagnosticCode[DiagnosticCode["Unable_to_resolve_external_module__0_"] = 140] = "Unable_to_resolve_external_module__0_"; - DiagnosticCode[DiagnosticCode["Module_cannot_be_aliased_to_a_non_module_type"] = 141] = "Module_cannot_be_aliased_to_a_non_module_type"; - DiagnosticCode[DiagnosticCode["A_class_may_only_extend_another_class"] = 142] = "A_class_may_only_extend_another_class"; - DiagnosticCode[DiagnosticCode["A_class_may_only_implement_another_class_or_interface"] = 143] = "A_class_may_only_implement_another_class_or_interface"; - DiagnosticCode[DiagnosticCode["An_interface_may_only_extend_another_class_or_interface"] = 144] = "An_interface_may_only_extend_another_class_or_interface"; - DiagnosticCode[DiagnosticCode["An_interface_cannot_implement_another_type"] = 145] = "An_interface_cannot_implement_another_type"; - DiagnosticCode[DiagnosticCode["Unable_to_resolve_type"] = 146] = "Unable_to_resolve_type"; - DiagnosticCode[DiagnosticCode["Unable_to_resolve_type_of__0_"] = 147] = "Unable_to_resolve_type_of__0_"; - DiagnosticCode[DiagnosticCode["Unable_to_resolve_type_parameter_constraint"] = 148] = "Unable_to_resolve_type_parameter_constraint"; - DiagnosticCode[DiagnosticCode["Type_parameter_constraint_cannot_be_a_primitive_type"] = 149] = "Type_parameter_constraint_cannot_be_a_primitive_type"; - DiagnosticCode[DiagnosticCode["Supplied_parameters_do_not_match_any_signature_of_call_target"] = 150] = "Supplied_parameters_do_not_match_any_signature_of_call_target"; - DiagnosticCode[DiagnosticCode["Supplied_parameters_do_not_match_any_signature_of_call_target__NL__0"] = 151] = "Supplied_parameters_do_not_match_any_signature_of_call_target__NL__0"; - DiagnosticCode[DiagnosticCode["Invalid__new__expression"] = 152] = "Invalid__new__expression"; - DiagnosticCode[DiagnosticCode["Call_signatures_used_in_a__new__expression_must_have_a__void__return_type"] = 153] = "Call_signatures_used_in_a__new__expression_must_have_a__void__return_type"; - DiagnosticCode[DiagnosticCode["Could_not_select_overload_for__new__expression"] = 154] = "Could_not_select_overload_for__new__expression"; - DiagnosticCode[DiagnosticCode["Type__0__does_not_satisfy_the_constraint__1__for_type_parameter__2_"] = 155] = "Type__0__does_not_satisfy_the_constraint__1__for_type_parameter__2_"; - DiagnosticCode[DiagnosticCode["Could_not_select_overload_for__call__expression"] = 156] = "Could_not_select_overload_for__call__expression"; - DiagnosticCode[DiagnosticCode["Unable_to_invoke_type_with_no_call_signatures"] = 157] = "Unable_to_invoke_type_with_no_call_signatures"; - DiagnosticCode[DiagnosticCode["Calls_to__super__are_only_valid_inside_a_class"] = 158] = "Calls_to__super__are_only_valid_inside_a_class"; - DiagnosticCode[DiagnosticCode["Generic_type__0__requires_1_type_argument_s_"] = 159] = "Generic_type__0__requires_1_type_argument_s_"; - DiagnosticCode[DiagnosticCode["Type_of_conditional_expression_cannot_be_determined__Best_common_type_could_not_be_found_between__0__and__1_"] = 160] = "Type_of_conditional_expression_cannot_be_determined__Best_common_type_could_not_be_found_between__0__and__1_"; - DiagnosticCode[DiagnosticCode["Type_of_array_literal_cannot_be_determined__Best_common_type_could_not_be_found_for_array_elements"] = 161] = "Type_of_array_literal_cannot_be_determined__Best_common_type_could_not_be_found_for_array_elements"; - DiagnosticCode[DiagnosticCode["Could_not_find_enclosing_symbol_for_dotted_name__0_"] = 162] = "Could_not_find_enclosing_symbol_for_dotted_name__0_"; - DiagnosticCode[DiagnosticCode["The_property__0__does_not_exist_on_value_of_type__1__"] = 163] = "The_property__0__does_not_exist_on_value_of_type__1__"; - DiagnosticCode[DiagnosticCode["Could_not_find_symbol__0_"] = 164] = "Could_not_find_symbol__0_"; - DiagnosticCode[DiagnosticCode["_get__and__set__accessor_must_have_the_same_type"] = 165] = "_get__and__set__accessor_must_have_the_same_type"; - DiagnosticCode[DiagnosticCode["_this__cannot_be_referenced_in_current_location"] = 166] = "_this__cannot_be_referenced_in_current_location"; - DiagnosticCode[DiagnosticCode["Use_of_deprecated__bool__type__Use__boolean__instead"] = 167] = "Use_of_deprecated__bool__type__Use__boolean__instead"; - - DiagnosticCode[DiagnosticCode["Class__0__is_recursively_referenced_as_a_base_type_of_itself"] = 168] = "Class__0__is_recursively_referenced_as_a_base_type_of_itself"; - DiagnosticCode[DiagnosticCode["Interface__0__is_recursively_referenced_as_a_base_type_of_itself"] = 169] = "Interface__0__is_recursively_referenced_as_a_base_type_of_itself"; - DiagnosticCode[DiagnosticCode["_super__property_access_is_permitted_only_in_a_constructor__instance_member_function__or_instance_member_accessor_of_a_derived_class"] = 170] = "_super__property_access_is_permitted_only_in_a_constructor__instance_member_function__or_instance_member_accessor_of_a_derived_class"; - DiagnosticCode[DiagnosticCode["_super__cannot_be_referenced_in_non_derived_classes"] = 171] = "_super__cannot_be_referenced_in_non_derived_classes"; - DiagnosticCode[DiagnosticCode["A__super__call_must_be_the_first_statement_in_the_constructor_when_a_class_contains_intialized_properties_or_has_parameter_properties"] = 172] = "A__super__call_must_be_the_first_statement_in_the_constructor_when_a_class_contains_intialized_properties_or_has_parameter_properties"; - DiagnosticCode[DiagnosticCode["Constructors_for_derived_classes_must_contain_a__super__call"] = 173] = "Constructors_for_derived_classes_must_contain_a__super__call"; - DiagnosticCode[DiagnosticCode["Super_calls_are_not_permitted_outside_constructors_or_in_local_functions_inside_constructors"] = 174] = "Super_calls_are_not_permitted_outside_constructors_or_in_local_functions_inside_constructors"; - DiagnosticCode[DiagnosticCode["_0_1__is_inaccessible"] = 175] = "_0_1__is_inaccessible"; - DiagnosticCode[DiagnosticCode["_this__cannot_be_referenced_within_module_bodies"] = 176] = "_this__cannot_be_referenced_within_module_bodies"; - DiagnosticCode[DiagnosticCode["_this__must_only_be_used_inside_a_function_or_script_context"] = 177] = "_this__must_only_be_used_inside_a_function_or_script_context"; - DiagnosticCode[DiagnosticCode["Invalid__addition__expression___types_do_not_agree"] = 178] = "Invalid__addition__expression___types_do_not_agree"; - DiagnosticCode[DiagnosticCode["The_right_hand_side_of_an_arithmetic_operation_must_be_of_type__any____number__or_an_enum_type"] = 179] = "The_right_hand_side_of_an_arithmetic_operation_must_be_of_type__any____number__or_an_enum_type"; - DiagnosticCode[DiagnosticCode["The_left_hand_side_of_an_arithmetic_operation_must_be_of_type__any____number__or_an_enum_type"] = 180] = "The_left_hand_side_of_an_arithmetic_operation_must_be_of_type__any____number__or_an_enum_type"; - DiagnosticCode[DiagnosticCode["The_type_of_a_unary_arithmetic_operation_operand_must_be_of_type__any____number__or_an_enum_type"] = 181] = "The_type_of_a_unary_arithmetic_operation_operand_must_be_of_type__any____number__or_an_enum_type"; - DiagnosticCode[DiagnosticCode["Variable_declarations_for_for_in_expressions_cannot_contain_a_type_annotation"] = 182] = "Variable_declarations_for_for_in_expressions_cannot_contain_a_type_annotation"; - DiagnosticCode[DiagnosticCode["Variable_declarations_for_for_in_expressions_must_be_of_types__string__or__any_"] = 183] = "Variable_declarations_for_for_in_expressions_must_be_of_types__string__or__any_"; - DiagnosticCode[DiagnosticCode["The_right_operand_of_a_for_in_expression_must_be_of_type__any____an_object_type_or_a_type_parameter"] = 184] = "The_right_operand_of_a_for_in_expression_must_be_of_type__any____an_object_type_or_a_type_parameter"; - DiagnosticCode[DiagnosticCode["The_left_hand_side_of_an__in__expression_must_be_of_types__string__or__any_"] = 185] = "The_left_hand_side_of_an__in__expression_must_be_of_types__string__or__any_"; - DiagnosticCode[DiagnosticCode["The_right_hand_side_of_an__in__expression_must_be_of_type__any___an_object_type_or_a_type_parameter"] = 186] = "The_right_hand_side_of_an__in__expression_must_be_of_type__any___an_object_type_or_a_type_parameter"; - DiagnosticCode[DiagnosticCode["The_left_hand_side_of_an__instanceOf__expression_must_be_of_type__any___an_object_type_or_a_type_parameter"] = 187] = "The_left_hand_side_of_an__instanceOf__expression_must_be_of_type__any___an_object_type_or_a_type_parameter"; - DiagnosticCode[DiagnosticCode["The_right_hand_side_of_an__instanceOf__expression_must_be_of_type__any__or_a_subtype_of_the__Function__interface_type"] = 188] = "The_right_hand_side_of_an__instanceOf__expression_must_be_of_type__any__or_a_subtype_of_the__Function__interface_type"; - DiagnosticCode[DiagnosticCode["Setters_cannot_return_a_value"] = 189] = "Setters_cannot_return_a_value"; - DiagnosticCode[DiagnosticCode["Tried_to_set_variable_type_to_module_type__0__"] = 190] = "Tried_to_set_variable_type_to_module_type__0__"; - DiagnosticCode[DiagnosticCode["Tried_to_set_variable_type_to_uninitialized_module_type__0__"] = 191] = "Tried_to_set_variable_type_to_uninitialized_module_type__0__"; - DiagnosticCode[DiagnosticCode["Function__0__declared_a_non_void_return_type__but_has_no_return_expression"] = 192] = "Function__0__declared_a_non_void_return_type__but_has_no_return_expression"; - DiagnosticCode[DiagnosticCode["Getters_must_return_a_value"] = 193] = "Getters_must_return_a_value"; - DiagnosticCode[DiagnosticCode["Getter_and_setter_accessors_do_not_agree_in_visibility"] = 194] = "Getter_and_setter_accessors_do_not_agree_in_visibility"; - DiagnosticCode[DiagnosticCode["Invalid_left_hand_side_of_assignment_expression"] = 195] = "Invalid_left_hand_side_of_assignment_expression"; - DiagnosticCode[DiagnosticCode["Function_declared_a_non_void_return_type__but_has_no_return_expression"] = 196] = "Function_declared_a_non_void_return_type__but_has_no_return_expression"; - DiagnosticCode[DiagnosticCode["Cannot_resolve_return_type_reference"] = 197] = "Cannot_resolve_return_type_reference"; - DiagnosticCode[DiagnosticCode["Constructors_cannot_have_a_return_type_of__void_"] = 198] = "Constructors_cannot_have_a_return_type_of__void_"; - DiagnosticCode[DiagnosticCode["Subsequent_variable_declarations_must_have_the_same_type___Variable__0__must_be_of_type__1___but_here_has_type___2_"] = 199] = "Subsequent_variable_declarations_must_have_the_same_type___Variable__0__must_be_of_type__1___but_here_has_type___2_"; - DiagnosticCode[DiagnosticCode["All_symbols_within_a__with__block_will_be_resolved_to__any__"] = 200] = "All_symbols_within_a__with__block_will_be_resolved_to__any__"; - DiagnosticCode[DiagnosticCode["Import_declarations_in_an_internal_module_cannot_reference_an_external_module"] = 201] = "Import_declarations_in_an_internal_module_cannot_reference_an_external_module"; - DiagnosticCode[DiagnosticCode["Class__0__declares_interface__1__but_does_not_implement_it__NL__2"] = 202] = "Class__0__declares_interface__1__but_does_not_implement_it__NL__2"; - DiagnosticCode[DiagnosticCode["Class__0__declares_class__1__but_does_not_implement_it__NL__2"] = 203] = "Class__0__declares_class__1__but_does_not_implement_it__NL__2"; - DiagnosticCode[DiagnosticCode["The_operand_of_an_increment_or_decrement_operator_must_be_a_variable__property_or_indexer"] = 204] = "The_operand_of_an_increment_or_decrement_operator_must_be_a_variable__property_or_indexer"; - DiagnosticCode[DiagnosticCode["_this__cannot_be_referenced_in_initializers_in_a_class_body"] = 205] = "_this__cannot_be_referenced_in_initializers_in_a_class_body"; - DiagnosticCode[DiagnosticCode["Class__0__cannot_extend_class__1__NL__2"] = 206] = "Class__0__cannot_extend_class__1__NL__2"; - DiagnosticCode[DiagnosticCode["Interface__0__cannot_extend_class__1__NL__2"] = 207] = "Interface__0__cannot_extend_class__1__NL__2"; - DiagnosticCode[DiagnosticCode["Interface__0__cannot_extend_interface__1__NL__2"] = 208] = "Interface__0__cannot_extend_interface__1__NL__2"; - DiagnosticCode[DiagnosticCode["Duplicate_overload_signature_for__0_"] = 209] = "Duplicate_overload_signature_for__0_"; - DiagnosticCode[DiagnosticCode["Duplicate_constructor_overload_signature"] = 210] = "Duplicate_constructor_overload_signature"; - DiagnosticCode[DiagnosticCode["Duplicate_overload_call_signature"] = 211] = "Duplicate_overload_call_signature"; - DiagnosticCode[DiagnosticCode["Duplicate_overload_construct_signature"] = 212] = "Duplicate_overload_construct_signature"; - DiagnosticCode[DiagnosticCode["Overload_signature_is_not_compatible_with_function_definition"] = 213] = "Overload_signature_is_not_compatible_with_function_definition"; - DiagnosticCode[DiagnosticCode["Overload_signature_is_not_compatible_with_function_definition__NL__0"] = 214] = "Overload_signature_is_not_compatible_with_function_definition__NL__0"; - DiagnosticCode[DiagnosticCode["Overload_signatures_must_all_be_public_or_private"] = 215] = "Overload_signatures_must_all_be_public_or_private"; - DiagnosticCode[DiagnosticCode["Overload_signatures_must_all_be_exported_or_local"] = 216] = "Overload_signatures_must_all_be_exported_or_local"; - DiagnosticCode[DiagnosticCode["Overload_signatures_must_all_be_ambient_or_non_ambient"] = 217] = "Overload_signatures_must_all_be_ambient_or_non_ambient"; - DiagnosticCode[DiagnosticCode["Overload_signatures_must_all_be_optional_or_required"] = 218] = "Overload_signatures_must_all_be_optional_or_required"; - DiagnosticCode[DiagnosticCode["Specialized_overload_signature_is_not_subtype_of_any_non_specialized_signature"] = 219] = "Specialized_overload_signature_is_not_subtype_of_any_non_specialized_signature"; - DiagnosticCode[DiagnosticCode["_this__cannot_be_referenced_in_constructor_arguments"] = 220] = "_this__cannot_be_referenced_in_constructor_arguments"; - DiagnosticCode[DiagnosticCode["Static_member_cannot_be_accessed_off_an_instance_variable"] = 221] = "Static_member_cannot_be_accessed_off_an_instance_variable"; - DiagnosticCode[DiagnosticCode["Instance_member_cannot_be_accessed_off_a_class"] = 222] = "Instance_member_cannot_be_accessed_off_a_class"; - DiagnosticCode[DiagnosticCode["Untyped_function_calls_may_not_accept_type_arguments"] = 223] = "Untyped_function_calls_may_not_accept_type_arguments"; - DiagnosticCode[DiagnosticCode["Non_generic_functions_may_not_accept_type_arguments"] = 224] = "Non_generic_functions_may_not_accept_type_arguments"; - DiagnosticCode[DiagnosticCode["A_generic_type_may_not_reference_itself_with_its_own_type_parameters"] = 225] = "A_generic_type_may_not_reference_itself_with_its_own_type_parameters"; - DiagnosticCode[DiagnosticCode["Static_methods_cannot_reference_class_type_parameters"] = 226] = "Static_methods_cannot_reference_class_type_parameters"; - DiagnosticCode[DiagnosticCode["Value_of_type__0__is_not_callable__Did_you_mean_to_include__new___"] = 227] = "Value_of_type__0__is_not_callable__Did_you_mean_to_include__new___"; - DiagnosticCode[DiagnosticCode["Rest_parameters_must_be_array_types"] = 228] = "Rest_parameters_must_be_array_types"; - DiagnosticCode[DiagnosticCode["Overload_signature_implementation_cannot_use_specialized_type"] = 229] = "Overload_signature_implementation_cannot_use_specialized_type"; - DiagnosticCode[DiagnosticCode["Export_assignments_may_only_be_used_in_External_modules"] = 230] = "Export_assignments_may_only_be_used_in_External_modules"; - DiagnosticCode[DiagnosticCode["Export_assignments_may_only_be_made_with_acceptable_kinds"] = 231] = "Export_assignments_may_only_be_made_with_acceptable_kinds"; - DiagnosticCode[DiagnosticCode["Only_public_instance_methods_of_the_base_class_are_accessible_via_the_super_keyword"] = 232] = "Only_public_instance_methods_of_the_base_class_are_accessible_via_the_super_keyword"; - DiagnosticCode[DiagnosticCode["Numeric_indexer_type___0___must_be_a_subtype_of_string_indexer_type___1__"] = 233] = "Numeric_indexer_type___0___must_be_a_subtype_of_string_indexer_type___1__"; - DiagnosticCode[DiagnosticCode["Numeric_indexer_type___0___must_be_a_subtype_of_string_indexer_type___1____NL__2"] = 234] = "Numeric_indexer_type___0___must_be_a_subtype_of_string_indexer_type___1____NL__2"; - DiagnosticCode[DiagnosticCode["All_numerically_named_properties_must_be_subtypes_of_numeric_indexer_type___0__"] = 235] = "All_numerically_named_properties_must_be_subtypes_of_numeric_indexer_type___0__"; - DiagnosticCode[DiagnosticCode["All_numerically_named_properties_must_be_subtypes_of_numeric_indexer_type___0____NL__1"] = 236] = "All_numerically_named_properties_must_be_subtypes_of_numeric_indexer_type___0____NL__1"; - DiagnosticCode[DiagnosticCode["All_named_properties_must_be_subtypes_of_string_indexer_type___0__"] = 237] = "All_named_properties_must_be_subtypes_of_string_indexer_type___0__"; - DiagnosticCode[DiagnosticCode["All_named_properties_must_be_subtypes_of_string_indexer_type___0____NL__1"] = 238] = "All_named_properties_must_be_subtypes_of_string_indexer_type___0____NL__1"; - DiagnosticCode[DiagnosticCode["Generic_type_references_must_include_all_type_arguments"] = 239] = "Generic_type_references_must_include_all_type_arguments"; - - DiagnosticCode[DiagnosticCode["Type__0__is_missing_property__1__from_type__2_"] = 240] = "Type__0__is_missing_property__1__from_type__2_"; - DiagnosticCode[DiagnosticCode["Types_of_property__0__of_types__1__and__2__are_incompatible"] = 241] = "Types_of_property__0__of_types__1__and__2__are_incompatible"; - DiagnosticCode[DiagnosticCode["Types_of_property__0__of_types__1__and__2__are_incompatible__NL__3"] = 242] = "Types_of_property__0__of_types__1__and__2__are_incompatible__NL__3"; - DiagnosticCode[DiagnosticCode["Property__0__defined_as_private_in_type__1__is_defined_as_public_in_type__2_"] = 243] = "Property__0__defined_as_private_in_type__1__is_defined_as_public_in_type__2_"; - DiagnosticCode[DiagnosticCode["Property__0__defined_as_public_in_type__1__is_defined_as_private_in_type__2_"] = 244] = "Property__0__defined_as_public_in_type__1__is_defined_as_private_in_type__2_"; - DiagnosticCode[DiagnosticCode["Types__0__and__1__define_property__2__as_private"] = 245] = "Types__0__and__1__define_property__2__as_private"; - DiagnosticCode[DiagnosticCode["Call_signatures_of_types__0__and__1__are_incompatible"] = 246] = "Call_signatures_of_types__0__and__1__are_incompatible"; - DiagnosticCode[DiagnosticCode["Call_signatures_of_types__0__and__1__are_incompatible__NL__2"] = 247] = "Call_signatures_of_types__0__and__1__are_incompatible__NL__2"; - DiagnosticCode[DiagnosticCode["Type__0__requires_a_call_signature__but_Type__1__lacks_one"] = 248] = "Type__0__requires_a_call_signature__but_Type__1__lacks_one"; - DiagnosticCode[DiagnosticCode["Construct_signatures_of_types__0__and__1__are_incompatible"] = 249] = "Construct_signatures_of_types__0__and__1__are_incompatible"; - DiagnosticCode[DiagnosticCode["Construct_signatures_of_types__0__and__1__are_incompatible__NL__2"] = 250] = "Construct_signatures_of_types__0__and__1__are_incompatible__NL__2"; - DiagnosticCode[DiagnosticCode["Type__0__requires_a_construct_signature__but_Type__1__lacks_one"] = 251] = "Type__0__requires_a_construct_signature__but_Type__1__lacks_one"; - DiagnosticCode[DiagnosticCode["Index_signatures_of_types__0__and__1__are_incompatible"] = 252] = "Index_signatures_of_types__0__and__1__are_incompatible"; - DiagnosticCode[DiagnosticCode["Index_signatures_of_types__0__and__1__are_incompatible__NL__2"] = 253] = "Index_signatures_of_types__0__and__1__are_incompatible__NL__2"; - DiagnosticCode[DiagnosticCode["Call_signature_expects__0__or_fewer_parameters"] = 254] = "Call_signature_expects__0__or_fewer_parameters"; - DiagnosticCode[DiagnosticCode["Could_not_apply_type__0__to_argument__1__which_is_of_type__2_"] = 255] = "Could_not_apply_type__0__to_argument__1__which_is_of_type__2_"; - DiagnosticCode[DiagnosticCode["Class__0__defines_instance_member_accessor__1___but_extended_class__2__defines_it_as_instance_member_function"] = 256] = "Class__0__defines_instance_member_accessor__1___but_extended_class__2__defines_it_as_instance_member_function"; - DiagnosticCode[DiagnosticCode["Class__0__defines_instance_member_property__1___but_extended_class__2__defines_it_as_instance_member_function"] = 257] = "Class__0__defines_instance_member_property__1___but_extended_class__2__defines_it_as_instance_member_function"; - DiagnosticCode[DiagnosticCode["Class__0__defines_instance_member_function__1___but_extended_class__2__defines_it_as_instance_member_accessor"] = 258] = "Class__0__defines_instance_member_function__1___but_extended_class__2__defines_it_as_instance_member_accessor"; - DiagnosticCode[DiagnosticCode["Class__0__defines_instance_member_function__1___but_extended_class__2__defines_it_as_instance_member_property"] = 259] = "Class__0__defines_instance_member_function__1___but_extended_class__2__defines_it_as_instance_member_property"; - DiagnosticCode[DiagnosticCode["Types_of_static_property__0__of_class__1__and_class__2__are_incompatible"] = 260] = "Types_of_static_property__0__of_class__1__and_class__2__are_incompatible"; - DiagnosticCode[DiagnosticCode["Types_of_static_property__0__of_class__1__and_class__2__are_incompatible__NL__3"] = 261] = "Types_of_static_property__0__of_class__1__and_class__2__are_incompatible__NL__3"; - DiagnosticCode[DiagnosticCode["Type_reference_cannot_refer_to_container__0_"] = 262] = "Type_reference_cannot_refer_to_container__0_"; - DiagnosticCode[DiagnosticCode["Type_reference_must_refer_to_type"] = 263] = "Type_reference_must_refer_to_type"; - DiagnosticCode[DiagnosticCode["Enums_with_multiple_declarations_must_provide_an_initializer_for_the_first_enum_element"] = 264] = "Enums_with_multiple_declarations_must_provide_an_initializer_for_the_first_enum_element"; - - DiagnosticCode[DiagnosticCode["Current_host_does_not_support__w_atch_option"] = 265] = "Current_host_does_not_support__w_atch_option"; - DiagnosticCode[DiagnosticCode["ECMAScript_target_version__0__not_supported___Using_default__1__code_generation"] = 266] = "ECMAScript_target_version__0__not_supported___Using_default__1__code_generation"; - DiagnosticCode[DiagnosticCode["Module_code_generation__0__not_supported___Using_default__1__code_generation"] = 267] = "Module_code_generation__0__not_supported___Using_default__1__code_generation"; - DiagnosticCode[DiagnosticCode["Could_not_find_file___0_"] = 268] = "Could_not_find_file___0_"; - DiagnosticCode[DiagnosticCode["Unknown_extension_for_file___0__Only__ts_and_d_ts_extensions_are_allowed"] = 269] = "Unknown_extension_for_file___0__Only__ts_and_d_ts_extensions_are_allowed"; - DiagnosticCode[DiagnosticCode["A_file_cannot_have_a_reference_itself"] = 270] = "A_file_cannot_have_a_reference_itself"; - DiagnosticCode[DiagnosticCode["Cannot_resolve_referenced_file___0_"] = 271] = "Cannot_resolve_referenced_file___0_"; - DiagnosticCode[DiagnosticCode["Cannot_resolve_imported_file___0_"] = 272] = "Cannot_resolve_imported_file___0_"; - DiagnosticCode[DiagnosticCode["Cannot_find_the_common_subdirectory_path_for_the_input_files"] = 273] = "Cannot_find_the_common_subdirectory_path_for_the_input_files"; - DiagnosticCode[DiagnosticCode["Cannot_compile_dynamic_modules_when_emitting_into_single_file"] = 274] = "Cannot_compile_dynamic_modules_when_emitting_into_single_file"; - DiagnosticCode[DiagnosticCode["Emit_Error__0"] = 275] = "Emit_Error__0"; - })(TypeScript.DiagnosticCode || (TypeScript.DiagnosticCode = {})); - var DiagnosticCode = TypeScript.DiagnosticCode; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - TypeScript.diagnosticMessages = { - error_TS_0__1: { - category: 3 /* NoPrefix */, - message: "error TS{0}: {1}", - code: 0 - }, - warning_TS_0__1: { - category: 3 /* NoPrefix */, - message: "warning TS{0}: {1}", - code: 1 - }, - _0__NL__1_TB__2: { - category: 3 /* NoPrefix */, - message: "{0}{NL}{{1}TB}{2}", - code: 21 - }, - _0_TB__1: { - category: 3 /* NoPrefix */, - message: "{{0}TB}{1}", - code: 22 - }, - Unrecognized_escape_sequence: { - category: 1 /* Error */, - message: "Unrecognized escape sequence.", - code: 1000 - }, - Unexpected_character_0: { - category: 1 /* Error */, - message: "Unexpected character {0}.", - code: 1001 - }, - Missing_closing_quote_character: { - category: 1 /* Error */, - message: "Missing close quote character.", - code: 1002 - }, - Identifier_expected: { - category: 1 /* Error */, - message: "Identifier expected.", - code: 1003 - }, - _0_keyword_expected: { - category: 1 /* Error */, - message: "'{0}' keyword expected.", - code: 1004 - }, - _0_expected: { - category: 1 /* Error */, - message: "'{0}' expected.", - code: 1005 - }, - Identifier_expected__0__is_a_keyword: { - category: 1 /* Error */, - message: "Identifier expected; '{0}' is a keyword.", - code: 1006 - }, - Automatic_semicolon_insertion_not_allowed: { - category: 1 /* Error */, - message: "Automatic semicolon insertion not allowed.", - code: 1007 - }, - Unexpected_token__0_expected: { - category: 1 /* Error */, - message: "Unexpected token; '{0}' expected.", - code: 1008 - }, - Trailing_separator_not_allowed: { - category: 1 /* Error */, - message: "Trailing separator not allowed.", - code: 1009 - }, - _StarSlash__expected: { - category: 1 /* Error */, - message: "'*/' expected.", - code: 1010 - }, - _public_or_private_modifier_must_precede__static_: { - category: 1 /* Error */, - message: "'public' or 'private' modifier must precede 'static'.", - code: 1011 - }, - Unexpected_token_: { - category: 1 /* Error */, - message: "Unexpected token.", - code: 1012 - }, - A_catch_clause_variable_cannot_have_a_type_annotation: { - category: 1 /* Error */, - message: "A catch clause variable cannot have a type annotation.", - code: 1013 - }, - Rest_parameter_must_be_last_in_list: { - category: 1 /* Error */, - message: "Rest parameter must be last in list.", - code: 1014 - }, - Parameter_cannot_have_question_mark_and_initializer: { - category: 1 /* Error */, - message: "Parameter cannot have question mark and initializer.", - code: 1015 - }, - Required_parameter_cannot_follow_optional_parameter: { - category: 1 /* Error */, - message: "Required parameter cannot follow optional parameter.", - code: 1016 - }, - Index_signatures_cannot_have_rest_parameters: { - category: 1 /* Error */, - message: "Index signatures cannot have rest parameters.", - code: 1017 - }, - Index_signature_parameter_cannot_have_accessibility_modifiers: { - category: 1 /* Error */, - message: "Index signature parameter cannot have accessibility modifiers.", - code: 1018 - }, - Index_signature_parameter_cannot_have_a_question_mark: { - category: 1 /* Error */, - message: "Index signature parameter cannot have a question mark.", - code: 1019 - }, - Index_signature_parameter_cannot_have_an_initializer: { - category: 1 /* Error */, - message: "Index signature parameter cannot have an initializer.", - code: 1020 - }, - Index_signature_must_have_a_type_annotation: { - category: 1 /* Error */, - message: "Index signature must have a type annotation.", - code: 1021 - }, - Index_signature_parameter_must_have_a_type_annotation: { - category: 1 /* Error */, - message: "Index signature parameter must have a type annotation.", - code: 1022 - }, - Index_signature_parameter_type_must_be__string__or__number_: { - category: 1 /* Error */, - message: "Index signature parameter type must be 'string' or 'number'.", - code: 1023 - }, - _extends__clause_already_seen: { - category: 1 /* Error */, - message: "'extends' clause already seen.", - code: 1024 - }, - _extends__clause_must_precede__implements__clause: { - category: 1 /* Error */, - message: "'extends' clause must precede 'implements' clause.", - code: 1025 - }, - Class_can_only_extend_single_type: { - category: 1 /* Error */, - message: "Class can only extend single type.", - code: 1026 - }, - _implements__clause_already_seen: { - category: 1 /* Error */, - message: "'implements' clause already seen.", - code: 1027 - }, - Accessibility_modifier_already_seen: { - category: 1 /* Error */, - message: "Accessibility modifier already seen.", - code: 1028 - }, - _0__modifier_must_precede__1__modifier: { - category: 1 /* Error */, - message: "'{0}' modifier must precede '{1}' modifier.", - code: 1029 - }, - _0__modifier_already_seen: { - category: 1 /* Error */, - message: "'{0}' modifier already seen.", - code: 1030 - }, - _0__modifier_cannot_appear_on_a_class_element: { - category: 1 /* Error */, - message: "'{0}' modifier cannot appear on a class element.", - code: 1031 - }, - Interface_declaration_cannot_have__implements__clause: { - category: 1 /* Error */, - message: "Interface declaration cannot have 'implements' clause.", - code: 1032 - }, - _super__invocation_cannot_have_type_arguments: { - category: 1 /* Error */, - message: "'super' invocation cannot have type arguments.", - code: 1034 - }, - Non_ambient_modules_cannot_use_quoted_names: { - category: 1 /* Error */, - message: "Non ambient modules cannot use quoted names.", - code: 1035 - }, - Statements_are_not_allowed_in_ambient_contexts: { - category: 1 /* Error */, - message: "Statements are not allowed in ambient contexts.", - code: 1036 - }, - Implementations_are_not_allowed_in_ambient_contexts: { - category: 1 /* Error */, - message: "Implementations are not allowed in ambient contexts.", - code: 1037 - }, - _declare__modifier_not_allowed_for_code_already_in_an_ambient_context: { - category: 1 /* Error */, - message: "'declare' modifier not allowed for code already in an ambient context.", - code: 1038 - }, - Initializers_are_not_allowed_in_ambient_contexts: { - category: 1 /* Error */, - message: "Initializers are not allowed in ambient contexts.", - code: 1039 - }, - Overload_and_ambient_signatures_cannot_specify_parameter_properties: { - category: 1 /* Error */, - message: "Overload and ambient signatures cannot specify parameter properties.", - code: 1040 - }, - Function_implementation_expected: { - category: 1 /* Error */, - message: "Function implementation expected.", - code: 1041 - }, - Constructor_implementation_expected: { - category: 1 /* Error */, - message: "Constructor implementation expected.", - code: 1042 - }, - Function_overload_name_must_be__0_: { - category: 1 /* Error */, - message: "Function overload name must be '{0}'.", - code: 1043 - }, - _0__modifier_cannot_appear_on_a_module_element: { - category: 1 /* Error */, - message: "'{0}' modifier cannot appear on a module element.", - code: 1044 - }, - _declare__modifier_cannot_appear_on_an_interface_declaration: { - category: 1 /* Error */, - message: "'declare' modifier cannot appear on an interface declaration.", - code: 1045 - }, - _declare__modifier_required_for_top_level_element: { - category: 1 /* Error */, - message: "'declare' modifier required for top level element.", - code: 1046 - }, - Rest_parameter_cannot_be_optional: { - category: 1 /* Error */, - message: "Rest parameter cannot be optional.", - code: 1047 - }, - Rest_parameter_cannot_have_initializer: { - category: 1 /* Error */, - message: "Rest parameter cannot have initializer.", - code: 1048 - }, - _set__accessor_must_have_only_one_parameter: { - category: 1 /* Error */, - message: "'set' accessor must have one and only one parameter.", - code: 1049 - }, - _set__accessor_parameter_cannot_have_accessibility_modifier: { - category: 1 /* Error */, - message: "'set' accessor parameter cannot have accessibility modifier.", - code: 1050 - }, - _set__accessor_parameter_cannot_be_optional: { - category: 1 /* Error */, - message: "'set' accessor parameter cannot be optional.", - code: 1051 - }, - _set__accessor_parameter_cannot_have_initializer: { - category: 1 /* Error */, - message: "'set' accessor parameter cannot have initializer.", - code: 1052 - }, - _set__accessor_cannot_have_rest_parameter: { - category: 1 /* Error */, - message: "'set' accessor cannot have rest parameter.", - code: 1053 - }, - _get__accessor_cannot_have_parameters: { - category: 1 /* Error */, - message: "'get' accessor cannot have parameters.", - code: 1054 - }, - Modifiers_cannot_appear_here: { - category: 1 /* Error */, - message: "Modifiers cannot appear here.", - code: 1055 - }, - Accessors_are_only_available_when_targeting_EcmaScript5_and_higher: { - category: 1 /* Error */, - message: "Accessors are only when targeting EcmaScript5 and higher.", - code: 1056 - }, - Class_name_cannot_be__0_: { - category: 1 /* Error */, - message: "Class name cannot be '{0}'.", - code: 1057 - }, - Interface_name_cannot_be__0_: { - category: 1 /* Error */, - message: "Interface name cannot be '{0}'.", - code: 1058 - }, - Enum_name_cannot_be__0_: { - category: 1 /* Error */, - message: "Enum name cannot be '{0}'.", - code: 1059 - }, - Module_name_cannot_be__0_: { - category: 1 /* Error */, - message: "Module name cannot be '{0}'.", - code: 1060 - }, - Enum_member_must_have_initializer: { - category: 1 /* Error */, - message: "Enum member must have initializer.", - code: 1061 - }, - _module_______is_deprecated__Use__require_______instead: { - category: 0 /* Warning */, - message: "'module(...)' is deprecated. Use 'require(...)' instead.", - code: 1062 - }, - Export_assignments_cannot_be_used_in_internal_modules: { - category: 1 /* Error */, - message: "Export assignments cannot be used in internal modules.", - code: 1063 - }, - Export_assignment_not_allowed_in_module_with_exported_element: { - category: 1 /* Error */, - message: "Export assignment not allowed in module with exported element.", - code: 1064 - }, - Module_cannot_have_multiple_export_assignments: { - category: 1 /* Error */, - message: "Module cannot have multiple export assignments.", - code: 1065 - }, - Duplicate_identifier__0_: { - category: 1 /* Error */, - message: "Duplicate identifier '{0}'.", - code: 2000 - }, - The_name__0__does_not_exist_in_the_current_scope: { - category: 1 /* Error */, - message: "The name '{0}' does not exist in the current scope.", - code: 2001 - }, - The_name__0__does_not_refer_to_a_value: { - category: 1 /* Error */, - message: "The name '{0}' does not refer to a value.", - code: 2002 - }, - Keyword__super__can_only_be_used_inside_a_class_instance_method: { - category: 1 /* Error */, - message: "Keyword 'super' can only be used inside a class instance method.", - code: 2003 - }, - The_left_hand_side_of_an_assignment_expression_must_be_a_variable__property_or_indexer: { - category: 1 /* Error */, - message: "The left-hand side of an assignment expression must be a variable, property or indexer.", - code: 2004 - }, - Value_of_type__0__is_not_callable__Did_you_mean_to_include__new__: { - category: 1 /* Error */, - message: "Value of type '{0}' is not callable. Did you mean to include 'new'?", - code: 2005 - }, - Value_of_type__0__is_not_callable: { - category: 1 /* Error */, - message: "Value of type '{0}' is not callable.", - code: 2006 - }, - Value_of_type__0__is_not_newable: { - category: 1 /* Error */, - message: "Value of type '{0}' is not newable.", - code: 2007 - }, - Value_of_type__0__is_not_indexable_by_type__1_: { - category: 1 /* Error */, - message: "Value of type '{0}' is not indexable by type '{1}'.", - code: 2008 - }, - Operator__0__cannot_be_applied_to_types__1__and__2_: { - category: 1 /* Error */, - message: "Operator '{0}' cannot be applied to types '{1}' and '{2}'.", - code: 2009 - }, - Operator__0__cannot_be_applied_to_types__1__and__2__3: { - category: 1 /* Error */, - message: "Operator '{0}' cannot be applied to types '{1}' and '{2}': {3}", - code: 2010 - }, - Cannot_convert__0__to__1_: { - category: 1 /* Error */, - message: "Cannot convert '{0}' to '{1}'.", - code: 2011 - }, - Cannot_convert__0__to__1__NL__2: { - category: 1 /* Error */, - message: "Cannot convert '{0}' to '{1}':{NL}{2}", - code: 2012 - }, - Expected_var__class__interface__or_module: { - category: 1 /* Error */, - message: "Expected var, class, interface, or module.", - code: 2013 - }, - Operator__0__cannot_be_applied_to_type__1_: { - category: 1 /* Error */, - message: "Operator '{0}' cannot be applied to type '{1}'.", - code: 2014 - }, - Getter__0__already_declared: { - category: 1 /* Error */, - message: "Getter '{0}' already declared.", - code: 2015 - }, - Setter__0__already_declared: { - category: 1 /* Error */, - message: "Setter '{0}' already declared.", - code: 2016 - }, - Accessor_cannot_have_type_parameters: { - category: 1 /* Error */, - message: "Accessors cannot have type parameters.", - code: 2017 - }, - Exported_class__0__extends_private_class__1_: { - category: 1 /* Error */, - message: "Exported class '{0}' extends private class '{1}'.", - code: 2018 - }, - Exported_class__0__implements_private_interface__1_: { - category: 1 /* Error */, - message: "Exported class '{0}' implements private interface '{1}'.", - code: 2019 - }, - Exported_interface__0__extends_private_interface__1_: { - category: 1 /* Error */, - message: "Exported interface '{0}' extends private interface '{1}'.", - code: 2020 - }, - Exported_class__0__extends_class_from_inaccessible_module__1_: { - category: 1 /* Error */, - message: "Exported class '{0}' extends class from inaccessible module {1}.", - code: 2021 - }, - Exported_class__0__implements_interface_from_inaccessible_module__1_: { - category: 1 /* Error */, - message: "Exported class '{0}' implements interface from inaccessible module {1}.", - code: 2022 - }, - Exported_interface__0__extends_interface_from_inaccessible_module__1_: { - category: 1 /* Error */, - message: "Exported interface '{0}' extends interface from inaccessible module {1}.", - code: 2023 - }, - Public_static_property__0__of__exported_class_has_or_is_using_private_type__1_: { - category: 1 /* Error */, - message: "Public static property '{0}' of exported class has or is using private type '{1}'.", - code: 2024 - }, - Public_property__0__of__exported_class_has_or_is_using_private_type__1_: { - category: 1 /* Error */, - message: "Public property '{0}' of exported class has or is using private type '{1}'.", - code: 2025 - }, - Property__0__of__exported_interface_has_or_is_using_private_type__1_: { - category: 1 /* Error */, - message: "Property '{0}' of exported interface has or is using private type '{1}'.", - code: 2026 - }, - Exported_variable__0__has_or_is_using_private_type__1_: { - category: 1 /* Error */, - message: "Exported variable '{0}' has or is using private type '{1}'.", - code: 2027 - }, - Public_static_property__0__of__exported_class_is_using_inaccessible_module__1_: { - category: 1 /* Error */, - message: "Public static property '{0}' of exported class is using inaccessible module {1}.", - code: 2028 - }, - Public_property__0__of__exported_class_is_using_inaccessible_module__1_: { - category: 1 /* Error */, - message: "Public property '{0}' of exported class is using inaccessible module {1}.", - code: 2029 - }, - Property__0__of__exported_interface_is_using_inaccessible_module__1_: { - category: 1 /* Error */, - message: "Property '{0}' of exported interface is using inaccessible module {1}.", - code: 2030 - }, - Exported_variable__0__is_using_inaccessible_module__1_: { - category: 1 /* Error */, - message: "Exported variable '{0}' is using inaccessible module {1}.", - code: 2031 - }, - Parameter__0__of_constructor_from_exported_class_has_or_is_using_private_type__1_: { - category: 1 /* Error */, - message: "Parameter '{0}' of constructor from exported class has or is using private type '{1}'.", - code: 2032 - }, - Parameter__0__of_public_static_property_setter_from_exported_class_has_or_is_using_private_type__1_: { - category: 1 /* Error */, - message: "Parameter '{0}' of public static property setter from exported class has or is using private type '{1}'.", - code: 2033 - }, - Parameter__0__of_public_property_setter_from_exported_class_has_or_is_using_private_type__1_: { - category: 1 /* Error */, - message: "Parameter '{0}' of public property setter from exported class has or is using private type '{1}'.", - code: 2034 - }, - Parameter__0__of_constructor_signature_from_exported_interface_has_or_is_using_private_type__1_: { - category: 1 /* Error */, - message: "Parameter '{0}' of constructor signature from exported interface has or is using private type '{1}'.", - code: 2035 - }, - Parameter__0__of_call_signature_from_exported_interface_has_or_is_using_private_type__1_: { - category: 1 /* Error */, - message: "Parameter '{0}' of call signature from exported interface has or is using private type '{1}'.", - code: 2036 - }, - Parameter__0__of_public_static_method_from_exported_class_has_or_is_using_private_type__1_: { - category: 1 /* Error */, - message: "Parameter '{0}' of public static method from exported class has or is using private type '{1}'.", - code: 2037 - }, - Parameter__0__of_public_method_from_exported_class_has_or_is_using_private_type__1_: { - category: 1 /* Error */, - message: "Parameter '{0}' of public method from exported class has or is using private type '{1}'.", - code: 2038 - }, - Parameter__0__of_method_from_exported_interface_has_or_is_using_private_type__1_: { - category: 1 /* Error */, - message: "Parameter '{0}' of method from exported interface has or is using private type '{1}'.", - code: 2039 - }, - Parameter__0__of_exported_function_has_or_is_using_private_type__1_: { - category: 1 /* Error */, - message: "Parameter '{0}' of exported function has or is using private type '{1}'.", - code: 2040 - }, - Parameter__0__of_constructor_from_exported_class_is_using_inaccessible_module__1_: { - category: 1 /* Error */, - message: "Parameter '{0}' of constructor from exported class is using inaccessible module {1}.", - code: 2041 - }, - Parameter__0__of_public_static_property_setter_from_exported_class_is_using_inaccessible_module__1_: { - category: 1 /* Error */, - message: "Parameter '{0}' of public static property setter from exported class is using inaccessible module {1}.", - code: 2042 - }, - Parameter__0__of_public_property_setter_from_exported_class_is_using_inaccessible_module__1_: { - category: 1 /* Error */, - message: "Parameter '{0}' of public property setter from exported class is using inaccessible module {1}.", - code: 2043 - }, - Parameter__0__of_constructor_signature_from_exported_interface_is_using_inaccessible_module__1_: { - category: 1 /* Error */, - message: "Parameter '{0}' of constructor signature from exported interface is using inaccessible module {1}.", - code: 2044 - }, - Parameter__0__of_call_signature_from_exported_interface_is_using_inaccessible_module__1_: { - category: 1 /* Error */, - message: "Parameter '{0}' of call signature from exported interface is using inaccessible module {1}", - code: 2045 - }, - Parameter__0__of_public_static_method_from_exported_class_is_using_inaccessible_module__1_: { - category: 1 /* Error */, - message: "Parameter '{0}' of public static method from exported class is using inaccessible module {1}.", - code: 2046 - }, - Parameter__0__of_public_method_from_exported_class_is_using_inaccessible_module__1_: { - category: 1 /* Error */, - message: "Parameter '{0}' of public method from exported class is using inaccessible module {1}.", - code: 2047 - }, - Parameter__0__of_method_from_exported_interface_is_using_inaccessible_module__1_: { - category: 1 /* Error */, - message: "Parameter '{0}' of method from exported interface is using inaccessible module {1}.", - code: 2048 - }, - Parameter__0__of_exported_function_is_using_inaccessible_module__1_: { - category: 1 /* Error */, - message: "Parameter '{0}' of exported function is using inaccessible module {1}.", - code: 2049 - }, - Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_private_type__0_: { - category: 1 /* Error */, - message: "Return type of public static property getter from exported class has or is using private type '{0}'.", - code: 2050 - }, - Return_type_of_public_property_getter_from_exported_class_has_or_is_using_private_type__0_: { - category: 1 /* Error */, - message: "Return type of public property getter from exported class has or is using private type '{0}'.", - code: 2051 - }, - Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_private_type__0_: { - category: 1 /* Error */, - message: "Return type of constructor signature from exported interface has or is using private type '{0}'.", - code: 2052 - }, - Return_type_of_call_signature_from_exported_interface_has_or_is_using_private_type__0_: { - category: 1 /* Error */, - message: "Return type of call signature from exported interface has or is using private type '{0}'.", - code: 2053 - }, - Return_type_of_index_signature_from_exported_interface_has_or_is_using_private_type__0_: { - category: 1 /* Error */, - message: "Return type of index signature from exported interface has or is using private type '{0}'.", - code: 2054 - }, - Return_type_of_public_static_method_from_exported_class_has_or_is_using_private_type__0_: { - category: 1 /* Error */, - message: "Return type of public static method from exported class has or is using private type '{0}'.", - code: 2055 - }, - Return_type_of_public_method_from_exported_class_has_or_is_using_private_type__0_: { - category: 1 /* Error */, - message: "Return type of public method from exported class has or is using private type '{0}'.", - code: 2056 - }, - Return_type_of_method_from_exported_interface_has_or_is_using_private_type__0_: { - category: 1 /* Error */, - message: "Return type of method from exported interface has or is using private type '{0}'.", - code: 2057 - }, - Return_type_of_exported_function_has_or_is_using_private_type__0_: { - category: 1 /* Error */, - message: "Return type of exported function has or is using private type '{0}'.", - code: 2058 - }, - Return_type_of_public_static_property_getter_from_exported_class_is_using_inaccessible_module__0_: { - category: 1 /* Error */, - message: "Return type of public static property getter from exported class is using inaccessible module {0}.", - code: 2059 - }, - Return_type_of_public_property_getter_from_exported_class_is_using_inaccessible_module__0_: { - category: 1 /* Error */, - message: "Return type of public property getter from exported class is using inaccessible module {0}.", - code: 2060 - }, - Return_type_of_constructor_signature_from_exported_interface_is_using_inaccessible_module__0_: { - category: 1 /* Error */, - message: "Return type of constructor signature from exported interface is using inaccessible module {0}.", - code: 2061 - }, - Return_type_of_call_signature_from_exported_interface_is_using_inaccessible_module__0_: { - category: 1 /* Error */, - message: "Return type of call signature from exported interface is using inaccessible module {0}.", - code: 2062 - }, - Return_type_of_index_signature_from_exported_interface_is_using_inaccessible_module__0_: { - category: 1 /* Error */, - message: "Return type of index signature from exported interface is using inaccessible module {0}.", - code: 2063 - }, - Return_type_of_public_static_method_from_exported_class_is_using_inaccessible_module__0_: { - category: 1 /* Error */, - message: "Return type of public static method from exported class is using inaccessible module {0}.", - code: 2064 - }, - Return_type_of_public_method_from_exported_class_is_using_inaccessible_module__0_: { - category: 1 /* Error */, - message: "Return type of public method from exported class is using inaccessible module {0}.", - code: 2065 - }, - Return_type_of_method_from_exported_interface_is_using_inaccessible_module__0_: { - category: 1 /* Error */, - message: "Return type of method from exported interface is using inaccessible module {0}.", - code: 2066 - }, - Return_type_of_exported_function_is_using_inaccessible_module__0_: { - category: 1 /* Error */, - message: "Return type of exported function is using inaccessible module {0}.", - code: 2067 - }, - _new_T____cannot_be_used_to_create_an_array__Use__new_Array_T_____instead: { - category: 1 /* Error */, - message: "'new T[]' cannot be used to create an array. Use 'new Array()' instead.", - code: 2068 - }, - A_parameter_list_must_follow_a_generic_type_argument_list______expected: { - category: 1 /* Error */, - message: "A parameter list must follow a generic type argument list. '(' expected.", - code: 2069 - }, - Multiple_constructor_implementations_are_not_allowed: { - category: 1 /* Error */, - message: "Multiple constructor implementations are not allowed.", - code: 2070 - }, - Unable_to_resolve_external_module__0_: { - category: 1 /* Error */, - message: "Unable to resolve external module '{0}'.", - code: 2071 - }, - Module_cannot_be_aliased_to_a_non_module_type: { - category: 1 /* Error */, - message: "Module cannot be aliased to a non-module type.", - code: 2072 - }, - A_class_may_only_extend_another_class: { - category: 1 /* Error */, - message: "A class may only extend another class.", - code: 2073 - }, - A_class_may_only_implement_another_class_or_interface: { - category: 1 /* Error */, - message: "A class may only implement another class or interface.", - code: 2074 - }, - An_interface_may_only_extend_another_class_or_interface: { - category: 1 /* Error */, - message: "An interface may only extend another class or interface.", - code: 2075 - }, - An_interface_cannot_implement_another_type: { - category: 1 /* Error */, - message: "An interface cannot implement another type.", - code: 2076 - }, - Unable_to_resolve_type: { - category: 1 /* Error */, - message: "Unable to resolve type.", - code: 2077 - }, - Unable_to_resolve_type_of__0_: { - category: 1 /* Error */, - message: "Unable to resolve type of '{0}'.", - code: 2078 - }, - Unable_to_resolve_type_parameter_constraint: { - category: 1 /* Error */, - message: "Unable to resolve type parameter constraint.", - code: 2079 - }, - Type_parameter_constraint_cannot_be_a_primitive_type: { - category: 1 /* Error */, - message: "Type parameter constraint cannot be a primitive type.", - code: 2080 - }, - Supplied_parameters_do_not_match_any_signature_of_call_target: { - category: 1 /* Error */, - message: "Supplied parameters do not match any signature of call target.", - code: 2081 - }, - Supplied_parameters_do_not_match_any_signature_of_call_target__NL__0: { - category: 1 /* Error */, - message: "Supplied parameters do not match any signature of call target:{NL}{0}", - code: 2082 - }, - Invalid__new__expression: { - category: 1 /* Error */, - message: "Invalid 'new' expression.", - code: 2083 - }, - Call_signatures_used_in_a__new__expression_must_have_a__void__return_type: { - category: 1 /* Error */, - message: "Call signatures used in a 'new' expression must have a 'void' return type.", - code: 2084 - }, - Could_not_select_overload_for__new__expression: { - category: 1 /* Error */, - message: "Could not select overload for 'new' expression.", - code: 2085 - }, - Type__0__does_not_satisfy_the_constraint__1__for_type_parameter__2_: { - category: 1 /* Error */, - message: "Type '{0}' does not satisfy the constraint '{1}' for type parameter '{2}'.", - code: 2086 - }, - Could_not_select_overload_for__call__expression: { - category: 1 /* Error */, - message: "Could not select overload for 'call' expression.", - code: 2087 - }, - Unable_to_invoke_type_with_no_call_signatures: { - category: 1 /* Error */, - message: "Unable to invoke type with no call signatures.", - code: 2088 - }, - Calls_to__super__are_only_valid_inside_a_class: { - category: 1 /* Error */, - message: "Calls to 'super' are only valid inside a class.", - code: 2089 - }, - Generic_type__0__requires_1_type_argument_s_: { - category: 1 /* Error */, - message: "Generic type '{0}' requires {1} type argument(s).", - code: 2090 - }, - Type_of_conditional_expression_cannot_be_determined__Best_common_type_could_not_be_found_between__0__and__1_: { - category: 1 /* Error */, - message: "Type of conditional expression cannot be determined. Best common type could not be found between '{0}' and '{1}'.", - code: 2091 - }, - Type_of_array_literal_cannot_be_determined__Best_common_type_could_not_be_found_for_array_elements: { - category: 1 /* Error */, - message: "Type of array literal cannot be determined. Best common type could not be found for array elements.", - code: 2092 - }, - Could_not_find_enclosing_symbol_for_dotted_name__0_: { - category: 1 /* Error */, - message: "Could not find enclosing symbol for dotted name '{0}'.", - code: 2093 - }, - The_property__0__does_not_exist_on_value_of_type__1__: { - category: 1 /* Error */, - message: "The property '{0}' does not exist on value of type '{1}'.", - code: 2094 - }, - Could_not_find_symbol__0_: { - category: 1 /* Error */, - message: "Could not find symbol '{0}'.", - code: 2095 - }, - _get__and__set__accessor_must_have_the_same_type: { - category: 1 /* Error */, - message: "'get' and 'set' accessor must have the same type.", - code: 2096 - }, - _this__cannot_be_referenced_in_current_location: { - category: 1 /* Error */, - message: "'this' cannot be referenced in current location.", - code: 2097 - }, - Use_of_deprecated__bool__type__Use__boolean__instead: { - category: 0 /* Warning */, - message: "Use of deprecated type 'bool'. Use 'boolean' instead.", - code: 2098 - }, - Static_methods_cannot_reference_class_type_parameters: { - category: 1 /* Error */, - message: "Static methods cannot reference class type parameters.", - code: 2099 - }, - Class__0__is_recursively_referenced_as_a_base_type_of_itself: { - category: 1 /* Error */, - message: "Class '{0}' is recursively referenced as a base type of itself.", - code: 2100 - }, - Interface__0__is_recursively_referenced_as_a_base_type_of_itself: { - category: 1 /* Error */, - message: "Interface '{0}' is recursively referenced as a base type of itself.", - code: 2101 - }, - _super__property_access_is_permitted_only_in_a_constructor__instance_member_function__or_instance_member_accessor_of_a_derived_class: { - category: 1 /* Error */, - message: "'super' property access is permitted only in a constructor, instance member function, or instance member accessor of a derived class.", - code: 2102 - }, - _super__cannot_be_referenced_in_non_derived_classes: { - category: 1 /* Error */, - message: "'super' cannot be referenced in non-derived classes.", - code: 2103 - }, - A__super__call_must_be_the_first_statement_in_the_constructor_when_a_class_contains_intialized_properties_or_has_parameter_properties: { - category: 1 /* Error */, - message: "A 'super' call must be the first statement in the constructor when a class contains initialized properties or has parameter properties.", - code: 2104 - }, - Constructors_for_derived_classes_must_contain_a__super__call: { - category: 1 /* Error */, - message: "Constructors for derived classes must contain a 'super' call.", - code: 2105 - }, - Super_calls_are_not_permitted_outside_constructors_or_in_local_functions_inside_constructors: { - category: 1 /* Error */, - message: "Super calls are not permitted outside constructors or in local functions inside constructors.", - code: 2106 - }, - _0_1__is_inaccessible: { - category: 1 /* Error */, - message: "'{0}.{1}' is inaccessible.", - code: 2107 - }, - _this__cannot_be_referenced_within_module_bodies: { - category: 1 /* Error */, - message: "'this' cannot be referenced within module bodies.", - code: 2108 - }, - _this__must_only_be_used_inside_a_function_or_script_context: { - category: 1 /* Error */, - message: "'this' must only be used inside a function or script context.", - code: 2109 - }, - Invalid__addition__expression___types_do_not_agree: { - category: 1 /* Error */, - message: "Invalid '+' expression - types not known to support the addition operator.", - code: 2111 - }, - The_right_hand_side_of_an_arithmetic_operation_must_be_of_type__any____number__or_an_enum_type: { - category: 1 /* Error */, - message: "The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.", - code: 2112 - }, - The_left_hand_side_of_an_arithmetic_operation_must_be_of_type__any____number__or_an_enum_type: { - category: 1 /* Error */, - message: "The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.", - code: 2113 - }, - The_type_of_a_unary_arithmetic_operation_operand_must_be_of_type__any____number__or_an_enum_type: { - category: 1 /* Error */, - message: "The type of a unary arithmetic operation operand must be of type 'any', 'number' or an enum type.", - code: 2114 - }, - Variable_declarations_for_for_in_expressions_cannot_contain_a_type_annotation: { - category: 1 /* Error */, - message: "Variable declarations for for/in expressions cannot contain a type annotation.", - code: 2115 - }, - Variable_declarations_for_for_in_expressions_must_be_of_types__string__or__any_: { - category: 1 /* Error */, - message: "Variable declarations for for/in expressions must be of types 'string' or 'any'.", - code: 2116 - }, - The_right_operand_of_a_for_in_expression_must_be_of_type__any____an_object_type_or_a_type_parameter: { - category: 1 /* Error */, - message: "The right operand of a for/in expression must be of type 'any', an object type or a type parameter.", - code: 2117 - }, - The_left_hand_side_of_an__in__expression_must_be_of_types__string__or__any_: { - category: 1 /* Error */, - message: "The left-hand side of an 'in' expression must be of types 'string' or 'any'.", - code: 2118 - }, - The_right_hand_side_of_an__in__expression_must_be_of_type__any___an_object_type_or_a_type_parameter: { - category: 1 /* Error */, - message: "The right-hand side of an 'in' expression must be of type 'any', an object type or a type parameter.", - code: 2119 - }, - The_left_hand_side_of_an__instanceOf__expression_must_be_of_type__any___an_object_type_or_a_type_parameter: { - category: 1 /* Error */, - message: "The left-hand side of an 'instanceOf' expression must be of type 'any', an object type or a type parameter.", - code: 2120 - }, - The_right_hand_side_of_an__instanceOf__expression_must_be_of_type__any__or_a_subtype_of_the__Function__interface_type: { - category: 1 /* Error */, - message: "The right-hand side of an 'instanceOf' expression must be of type 'any' or a subtype of the 'Function' interface type.", - code: 2121 - }, - Setters_cannot_return_a_value: { - category: 1 /* Error */, - message: "Setters cannot return a value.", - code: 2122 - }, - Tried_to_set_variable_type_to_module_type__0__: { - category: 1 /* Error */, - message: "Tried to set variable type to container type '{0}'.", - code: 2123 - }, - Tried_to_set_variable_type_to_uninitialized_module_type__0__: { - category: 1 /* Error */, - message: "Tried to set variable type to uninitialized module type '{0}'.", - code: 2124 - }, - Function__0__declared_a_non_void_return_type__but_has_no_return_expression: { - category: 1 /* Error */, - message: "Function {0} declared a non-void return type, but has no return expression.", - code: 2125 - }, - Getters_must_return_a_value: { - category: 1 /* Error */, - message: "Getters must return a value.", - code: 2126 - }, - Getter_and_setter_accessors_do_not_agree_in_visibility: { - category: 1 /* Error */, - message: "Getter and setter accessors do not agree in visibility.", - code: 2127 - }, - Invalid_left_hand_side_of_assignment_expression: { - category: 1 /* Error */, - message: "Invalid left-hand side of assignment expression.", - code: 2130 - }, - Function_declared_a_non_void_return_type__but_has_no_return_expression: { - category: 1 /* Error */, - message: "Function declared a non-void return type, but has no return expression.", - code: 2131 - }, - Cannot_resolve_return_type_reference: { - category: 1 /* Error */, - message: "Cannot resolve return type reference.", - code: 2132 - }, - Constructors_cannot_have_a_return_type_of__void_: { - category: 1 /* Error */, - message: "Constructors cannot have a return type of 'void'.", - code: 2133 - }, - Subsequent_variable_declarations_must_have_the_same_type___Variable__0__must_be_of_type__1___but_here_has_type___2_: { - category: 1 /* Error */, - message: "Subsequent variable declarations must have the same type. Variable '{0}' must be of type '{1}', but here has type '{2}'", - code: 2134 - }, - All_symbols_within_a__with__block_will_be_resolved_to__any__: { - category: 1 /* Error */, - message: "All symbols within a with block will be resolved to 'any'.", - code: 2135 - }, - Import_declarations_in_an_internal_module_cannot_reference_an_external_module: { - category: 1 /* Error */, - message: "Import declarations in an internal module cannot reference an external module.", - code: 2136 - }, - Class__0__declares_interface__1__but_does_not_implement_it__NL__2: { - category: 1 /* Error */, - message: "Class {0} declares interface {1} but does not implement it:{NL}{2}", - code: 2137 - }, - Class__0__declares_class__1__but_does_not_implement_it__NL__2: { - category: 1 /* Error */, - message: "Class {0} declares class {1} as an implemented interface but does not implement it:{NL}{2}", - code: 2138 - }, - The_operand_of_an_increment_or_decrement_operator_must_be_a_variable__property_or_indexer: { - category: 1 /* Error */, - message: "The operand of an increment or decrement operator must be a variable, property or indexer.", - code: 2139 - }, - _this__cannot_be_referenced_in_initializers_in_a_class_body: { - category: 1 /* Error */, - message: "'this' cannot be referenced in initializers in a class body.", - code: 2140 - }, - Class__0__cannot_extend_class__1__NL__2: { - category: 1 /* Error */, - message: "Class '{0}' cannot extend class '{1}':{NL}{2}", - code: 2141 - }, - Interface__0__cannot_extend_class__1__NL__2: { - category: 1 /* Error */, - message: "Interface '{0}' cannot extend class '{1}':{NL}{2}", - code: 2142 - }, - Interface__0__cannot_extend_interface__1__NL__2: { - category: 1 /* Error */, - message: "Interface '{0}' cannot extend interface '{1}':{NL}{2}", - code: 2143 - }, - Duplicate_overload_signature_for__0_: { - category: 1 /* Error */, - message: "Duplicate overload signature for '{0}'.", - code: 2144 - }, - Duplicate_constructor_overload_signature: { - category: 1 /* Error */, - message: "Duplicate constructor overload signature.", - code: 2145 - }, - Duplicate_overload_call_signature: { - category: 1 /* Error */, - message: "Duplicate overload call signature.", - code: 2146 - }, - Duplicate_overload_construct_signature: { - category: 1 /* Error */, - message: "Duplicate overload construct signature.", - code: 2147 - }, - Overload_signature_is_not_compatible_with_function_definition: { - category: 1 /* Error */, - message: "Overload signature is not compatible with function definition.", - code: 2148 - }, - Overload_signature_is_not_compatible_with_function_definition__NL__0: { - category: 1 /* Error */, - message: "Overload signature is not compatible with function definition:{NL}{0}", - code: 2149 - }, - Overload_signatures_must_all_be_public_or_private: { - category: 1 /* Error */, - message: "Overload signatures must all be public or private.", - code: 2150 - }, - Overload_signatures_must_all_be_exported_or_local: { - category: 1 /* Error */, - message: "Overload signatures must all be exported or local.", - code: 2151 - }, - Overload_signatures_must_all_be_ambient_or_non_ambient: { - category: 1 /* Error */, - message: "Overload signatures must all be ambient or non-ambient.", - code: 2152 - }, - Overload_signatures_must_all_be_optional_or_required: { - category: 1 /* Error */, - message: "Overload signatures must all be optional or required.", - code: 2153 - }, - Specialized_overload_signature_is_not_subtype_of_any_non_specialized_signature: { - category: 1 /* Error */, - message: "Specialized overload signature is not subtype of any non-specialized signature.", - code: 2154 - }, - _this__cannot_be_referenced_in_constructor_arguments: { - category: 1 /* Error */, - message: "'this' cannot be referenced in constructor arguments.", - code: 2155 - }, - Static_member_cannot_be_accessed_off_an_instance_variable: { - category: 1 /* Error */, - message: "Static member cannot be accessed off an instance variable.", - code: 2156 - }, - Instance_member_cannot_be_accessed_off_a_class: { - category: 1 /* Error */, - message: "Instance member cannot be accessed off a class.", - code: 2157 - }, - Untyped_function_calls_may_not_accept_type_arguments: { - category: 1 /* Error */, - message: "Untyped function calls may not accept type arguments.", - code: 2158 - }, - Non_generic_functions_may_not_accept_type_arguments: { - category: 1 /* Error */, - message: "Non-generic functions may not accept type arguments.", - code: 2159 - }, - A_generic_type_may_not_reference_itself_with_its_own_type_parameters: { - category: 1 /* Error */, - message: "A generic type may not reference itself with a wrapped form of its own type parameters.", - code: 2160 - }, - Value_of_type__0__is_not_callable__Did_you_mean_to_include__new___: { - category: 1 /* Error */, - message: "Value of type '{0}' is not callable. Did you mean to include 'new'?", - code: 2161 - }, - Rest_parameters_must_be_array_types: { - category: 1 /* Error */, - message: "Rest parameters must be array types.", - code: 2162 - }, - Overload_signature_implementation_cannot_use_specialized_type: { - category: 1 /* Error */, - message: "Overload signature implementation cannot use specialized type.", - code: 2163 - }, - Export_assignments_may_only_be_used_in_External_modules: { - category: 1 /* Error */, - message: "Export assignments may only be used at the top-level of external modules", - code: 2164 - }, - Export_assignments_may_only_be_made_with_acceptable_kinds: { - category: 1 /* Error */, - message: "Export assignments may only be made with variables, functions, classes, interfaces, enums and internal modules", - code: 2165 - }, - Only_public_instance_methods_of_the_base_class_are_accessible_via_the_super_keyword: { - category: 1 /* Error */, - message: "Only public instance methods of the base class are accessible via the super keyword", - code: 2166 - }, - Numeric_indexer_type___0___must_be_a_subtype_of_string_indexer_type___1__: { - category: 1 /* Error */, - message: "Numeric indexer type '{0}' must be a subtype of string indexer type '{1}'", - code: 2167 - }, - Numeric_indexer_type___0___must_be_a_subtype_of_string_indexer_type___1____NL__2: { - category: 1 /* Error */, - message: "Numeric indexer type '{0}' must be a subtype of string indexer type '{1}':{NL}{2}", - code: 2168 - }, - All_numerically_named_properties_must_be_subtypes_of_numeric_indexer_type___0__: { - category: 1 /* Error */, - message: "All numerically named properties must be subtypes of numeric indexer type '{0}'", - code: 2169 - }, - All_numerically_named_properties_must_be_subtypes_of_numeric_indexer_type___0____NL__1: { - category: 1 /* Error */, - message: "All numerically named properties must be subtypes of numeric indexer type '{0}':{NL}{1}", - code: 2170 - }, - All_named_properties_must_be_subtypes_of_string_indexer_type___0__: { - category: 1 /* Error */, - message: "All named properties must be subtypes of string indexer type '{0}'", - code: 2171 - }, - All_named_properties_must_be_subtypes_of_string_indexer_type___0____NL__1: { - category: 1 /* Error */, - message: "All named properties must be subtypes of string indexer type '{0}':{NL}{1}", - code: 2172 - }, - Generic_type_references_must_include_all_type_arguments: { - category: 1 /* Error */, - message: "Generic type references must include all type arguments", - code: 2173 - }, - Type__0__is_missing_property__1__from_type__2_: { - category: 3 /* NoPrefix */, - message: "Type '{0}' is missing property '{1}' from type '{2}'.", - code: 4000 - }, - Types_of_property__0__of_types__1__and__2__are_incompatible: { - category: 3 /* NoPrefix */, - message: "Types of property '{0}' of types '{1}' and '{2}' are incompatible.", - code: 4001 - }, - Types_of_property__0__of_types__1__and__2__are_incompatible__NL__3: { - category: 3 /* NoPrefix */, - message: "Types of property '{0}' of types '{1}' and '{2}' are incompatible:{NL}{3}", - code: 4002 - }, - Property__0__defined_as_private_in_type__1__is_defined_as_public_in_type__2_: { - category: 3 /* NoPrefix */, - message: "Property '{0}' defined as private in type '{1}' is defined as public in type '{2}'.", - code: 4003 - }, - Property__0__defined_as_public_in_type__1__is_defined_as_private_in_type__2_: { - category: 3 /* NoPrefix */, - message: "Property '{0}' defined as public in type '{1}' is defined as private in type '{2}'.", - code: 4004 - }, - Types__0__and__1__define_property__2__as_private: { - category: 3 /* NoPrefix */, - message: "Types '{0}' and '{1}' define property '{2}' as private.", - code: 4005 - }, - Call_signatures_of_types__0__and__1__are_incompatible: { - category: 3 /* NoPrefix */, - message: "Call signatures of types '{0}' and '{1}' are incompatible.", - code: 4006 - }, - Call_signatures_of_types__0__and__1__are_incompatible__NL__2: { - category: 3 /* NoPrefix */, - message: "Call signatures of types '{0}' and '{1}' are incompatible:{NL}{2}", - code: 4007 - }, - Type__0__requires_a_call_signature__but_Type__1__lacks_one: { - category: 3 /* NoPrefix */, - message: "Type '{0}' requires a call signature, but type '{1}' lacks one.", - code: 4008 - }, - Construct_signatures_of_types__0__and__1__are_incompatible: { - category: 3 /* NoPrefix */, - message: "Construct signatures of types '{0}' and '{1}' are incompatible.", - code: 4009 - }, - Construct_signatures_of_types__0__and__1__are_incompatible__NL__2: { - category: 3 /* NoPrefix */, - message: "Construct signatures of types '{0}' and '{1}' are incompatible:{NL}{2}", - code: 40010 - }, - Type__0__requires_a_construct_signature__but_Type__1__lacks_one: { - category: 3 /* NoPrefix */, - message: "Type '{0}' requires a construct signature, but type '{1}' lacks one.", - code: 4011 - }, - Index_signatures_of_types__0__and__1__are_incompatible: { - category: 3 /* NoPrefix */, - message: "Index signatures of types '{0}' and '{1}' are incompatible.", - code: 4012 - }, - Index_signatures_of_types__0__and__1__are_incompatible__NL__2: { - category: 3 /* NoPrefix */, - message: "Index signatures of types '{0}' and '{1}' are incompatible:{NL}{2}", - code: 4013 - }, - Call_signature_expects__0__or_fewer_parameters: { - category: 3 /* NoPrefix */, - message: "Call signature expects {0} or fewer parameters.", - code: 4014 - }, - Could_not_apply_type__0__to_argument__1__which_is_of_type__2_: { - category: 3 /* NoPrefix */, - message: "Could not apply type'{0}' to argument {1} which is of type '{2}'.", - code: 4015 - }, - Class__0__defines_instance_member_accessor__1___but_extended_class__2__defines_it_as_instance_member_function: { - category: 3 /* NoPrefix */, - message: "Class '{0}' defines instance member accessor '{1}', but extended class '{2}' defines it as instance member function.", - code: 4016 - }, - Class__0__defines_instance_member_property__1___but_extended_class__2__defines_it_as_instance_member_function: { - category: 3 /* NoPrefix */, - message: "Class '{0}' defines instance member property '{1}', but extended class '{2}' defines it as instance member function.", - code: 4017 - }, - Class__0__defines_instance_member_function__1___but_extended_class__2__defines_it_as_instance_member_accessor: { - category: 3 /* NoPrefix */, - message: "Class '{0}' defines instance member function '{1}', but extended class '{2}' defines it as instance member accessor.", - code: 4018 - }, - Class__0__defines_instance_member_function__1___but_extended_class__2__defines_it_as_instance_member_property: { - category: 3 /* NoPrefix */, - message: "Class '{0}' defines instance member function '{1}', but extended class '{2}' defines it as instance member property.", - code: 4019 - }, - Types_of_static_property__0__of_class__1__and_class__2__are_incompatible: { - category: 3 /* NoPrefix */, - message: "Types of static property '{0}' of class '{1}' and class '{2}' are incompatible.", - code: 4020 - }, - Types_of_static_property__0__of_class__1__and_class__2__are_incompatible__NL__3: { - category: 3 /* NoPrefix */, - message: "Types of static property '{0}' of class '{1}' and class '{2}' are incompatible:{NL}{3}", - code: 4021 - }, - Type_reference_cannot_refer_to_container__0_: { - category: 1 /* Error */, - message: "Type reference cannot refer to container '{0}'.", - code: 4022 - }, - Type_reference_must_refer_to_type: { - category: 1 /* Error */, - message: "Type reference cannot must refer to type.", - code: 4023 - }, - Enums_with_multiple_declarations_must_provide_an_initializer_for_the_first_enum_element: { - category: 1 /* Error */, - message: "Enums with multiple declarations must provide an initializer for the first enum element.", - code: 4024 - }, - Current_host_does_not_support__w_atch_option: { - category: 1 /* Error */, - message: "Current host does not support -w[atch] option.", - code: 5001 - }, - ECMAScript_target_version__0__not_supported___Using_default__1__code_generation: { - category: 0 /* Warning */, - message: "ECMAScript target version '{0}' not supported. Using default '{1}' code generation.", - code: 5002 - }, - Module_code_generation__0__not_supported___Using_default__1__code_generation: { - category: 0 /* Warning */, - message: "Module code generation '{0}' not supported. Using default '{1}' code generation.", - code: 5003 - }, - Could_not_find_file___0_: { - category: 1 /* Error */, - message: "Could not find file: '{0}'.", - code: 5004 - }, - Unknown_extension_for_file___0__Only__ts_and_d_ts_extensions_are_allowed: { - category: 1 /* Error */, - message: "Unknown extension for file: '{0}'. Only .ts and .d.ts extensions are allowed.", - code: 5005 - }, - A_file_cannot_have_a_reference_itself: { - category: 1 /* Error */, - message: "A file cannot have a reference itself.", - code: 5006 - }, - Cannot_resolve_referenced_file___0_: { - category: 1 /* Error */, - message: "Cannot resolve referenced file: '{0}'.", - code: 5007 - }, - Cannot_resolve_imported_file___0_: { - category: 1 /* Error */, - message: "Cannot resolve imported file: '{0}'.", - code: 5008 - }, - Cannot_find_the_common_subdirectory_path_for_the_input_files: { - category: 1 /* Error */, - message: "Cannot find the common subdirectory path for the input files", - code: 5009 - }, - Cannot_compile_dynamic_modules_when_emitting_into_single_file: { - category: 1 /* Error */, - message: "Cannot compile dynamic modules when emitting into single file", - code: 5010 - }, - Emit_Error__0: { - category: 1 /* Error */, - message: "Emit Error: {0}.", - code: 5011 - } - }; - - var seenCodes = []; - for (var name in TypeScript.diagnosticMessages) { - if (TypeScript.diagnosticMessages.hasOwnProperty(name)) { - var diagnosticMessage = TypeScript.diagnosticMessages[name]; - var value = seenCodes[diagnosticMessage.code]; - if (value) { - throw new Error("Duplicate diagnostic code: " + diagnosticMessage.code); - } - - seenCodes[diagnosticMessage.code] = diagnosticMessage; - } - } -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var Errors = (function () { - function Errors() { - } - Errors.argument = function (argument, message) { - return new Error("Invalid argument: " + argument + "." + (message ? (" " + message) : "")); - }; - - Errors.argumentOutOfRange = function (argument) { - return new Error("Argument out of range: " + argument + "."); - }; - - Errors.argumentNull = function (argument) { - return new Error("Argument null: " + argument + "."); - }; - - Errors.abstract = function () { - return new Error("Operation not implemented properly by subclass."); - }; - - Errors.notYetImplemented = function () { - return new Error("Not yet implemented."); - }; - - Errors.invalidOperation = function (message) { - return new Error(message ? ("Invalid operation: " + message) : "Invalid operation."); - }; - return Errors; - })(); - TypeScript.Errors = Errors; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var Hash = (function () { - function Hash() { - } - Hash.computeFnv1aCharArrayHashCode = function (text, start, len) { - var hashCode = Hash.FNV_BASE; - var end = start + len; - - for (var i = start; i < end; i++) { - hashCode = (hashCode ^ text[i]) * Hash.FNV_PRIME; - } - - return hashCode; - }; - - Hash.computeSimple31BitCharArrayHashCode = function (key, start, len) { - var hash = 0; - - for (var i = 0; i < len; i++) { - var ch = key[start + i]; - - hash = (((hash << 5) + hash) + ch) | 0; - } - - return hash & 0x7FFFFFFF; - }; - - Hash.computeSimple31BitStringHashCode = function (key) { - var hash = 0; - - var start = 0; - var len = key.length; - - for (var i = 0; i < len; i++) { - var ch = key.charCodeAt(start + i); - - hash = (((hash << 5) + hash) + ch) | 0; - } - - return hash & 0x7FFFFFFF; - }; - - Hash.computeMurmur2CharArrayHashCode = function (key, start, len) { - var m = 0x5bd1e995; - var r = 24; - - var numberOfCharsLeft = len; - var h = (0 ^ numberOfCharsLeft); - - var index = start; - while (numberOfCharsLeft >= 2) { - var c1 = key[index]; - var c2 = key[index + 1]; - - var k = c1 | (c2 << 16); - - k *= m; - k ^= k >> r; - k *= m; - - h *= m; - h ^= k; - - index += 2; - numberOfCharsLeft -= 2; - } - - if (numberOfCharsLeft === 1) { - h ^= key[index]; - h *= m; - } - - h ^= h >> 13; - h *= m; - h ^= h >> 15; - - return h; - }; - - Hash.computeMurmur2StringHashCode = function (key) { - var m = 0x5bd1e995; - var r = 24; - - var start = 0; - var len = key.length; - var numberOfCharsLeft = len; - - var h = (0 ^ numberOfCharsLeft); - - var index = start; - while (numberOfCharsLeft >= 2) { - var c1 = key.charCodeAt(index); - var c2 = key.charCodeAt(index + 1); - - var k = c1 | (c2 << 16); - - k *= m; - k ^= k >> r; - k *= m; - - h *= m; - h ^= k; - - index += 2; - numberOfCharsLeft -= 2; - } - - if (numberOfCharsLeft === 1) { - h ^= key.charCodeAt(index); - h *= m; - } - - h ^= h >> 13; - h *= m; - h ^= h >> 15; - - return h; - }; - - Hash.getPrime = function (min) { - for (var i = 0; i < Hash.primes.length; i++) { - var num = Hash.primes[i]; - if (num >= min) { - return num; - } - } - - throw TypeScript.Errors.notYetImplemented(); - }; - - Hash.expandPrime = function (oldSize) { - var num = oldSize << 1; - if (num > 2146435069 && 2146435069 > oldSize) { - return 2146435069; - } - return Hash.getPrime(num); - }; - - Hash.combine = function (value, currentHash) { - return (((currentHash << 5) + currentHash) + value) & 0x7FFFFFFF; - }; - Hash.FNV_BASE = 2166136261; - Hash.FNV_PRIME = 16777619; - - Hash.primes = [ - 3, - 7, - 11, - 17, - 23, - 29, - 37, - 47, - 59, - 71, - 89, - 107, - 131, - 163, - 197, - 239, - 293, - 353, - 431, - 521, - 631, - 761, - 919, - 1103, - 1327, - 1597, - 1931, - 2333, - 2801, - 3371, - 4049, - 4861, - 5839, - 7013, - 8419, - 10103, - 12143, - 14591, - 17519, - 21023, - 25229, - 30293, - 36353, - 43627, - 52361, - 62851, - 75431, - 90523, - 108631, - 130363, - 156437, - 187751, - 225307, - 270371, - 324449, - 389357, - 467237, - 560689, - 672827, - 807403, - 968897, - 1162687, - 1395263, - 1674319, - 2009191, - 2411033, - 2893249, - 3471899, - 4166287, - 4999559, - 5999471, - 7199369 - ]; - return Hash; - })(); - TypeScript.Hash = Hash; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (Collections) { - Collections.DefaultHashTableCapacity = 256; - - var HashTableEntry = (function () { - function HashTableEntry(Key, Value, HashCode, Next) { - this.Key = Key; - this.Value = Value; - this.HashCode = HashCode; - this.Next = Next; - } - return HashTableEntry; - })(); - - var HashTable = (function () { - function HashTable(capacity, hash, equals) { - this.hash = hash; - this.equals = equals; - this.entries = []; - this.count = 0; - var size = TypeScript.Hash.getPrime(capacity); - this.hash = hash; - this.equals = equals; - this.entries = TypeScript.ArrayUtilities.createArray(size, null); - } - HashTable.prototype.set = function (key, value) { - this.addOrSet(key, value, false); - }; - - HashTable.prototype.add = function (key, value) { - this.addOrSet(key, value, true); - }; - - HashTable.prototype.containsKey = function (key) { - var hashCode = this.computeHashCode(key); - var entry = this.findEntry(key, hashCode); - return entry !== null; - }; - - HashTable.prototype.get = function (key) { - var hashCode = this.computeHashCode(key); - var entry = this.findEntry(key, hashCode); - - return entry === null ? null : entry.Value; - }; - - HashTable.prototype.computeHashCode = function (key) { - var hashCode = this.hash === null ? key.hashCode() : this.hash(key); - - hashCode = hashCode & 0x7FFFFFFF; - TypeScript.Debug.assert(hashCode > 0); - - return hashCode; - }; - - HashTable.prototype.addOrSet = function (key, value, throwOnExistingEntry) { - var hashCode = this.computeHashCode(key); - - var entry = this.findEntry(key, hashCode); - if (entry !== null) { - if (throwOnExistingEntry) { - throw TypeScript.Errors.argument('key', 'Key was already in table.'); - } - - entry.Key = key; - entry.Value = value; - return; - } - - return this.addEntry(key, value, hashCode); - }; - - HashTable.prototype.findEntry = function (key, hashCode) { - for (var e = this.entries[hashCode % this.entries.length]; e !== null; e = e.Next) { - if (e.HashCode === hashCode) { - var equals = this.equals === null ? key === e.Key : this.equals(key, e.Key); - - if (equals) { - return e; - } - } - } - - return null; - }; - - HashTable.prototype.addEntry = function (key, value, hashCode) { - var index = hashCode % this.entries.length; - - var e = new HashTableEntry(key, value, hashCode, this.entries[index]); - - this.entries[index] = e; - - if (this.count === this.entries.length) { - this.grow(); - } - - this.count++; - return e.Key; - }; - - HashTable.prototype.grow = function () { - var newSize = TypeScript.Hash.expandPrime(this.entries.length); - - var oldEntries = this.entries; - var newEntries = TypeScript.ArrayUtilities.createArray(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; - } - } - }; - return HashTable; - })(); - Collections.HashTable = HashTable; - - function createHashTable(capacity, hash, equals) { - if (typeof capacity === "undefined") { capacity = Collections.DefaultHashTableCapacity; } - if (typeof hash === "undefined") { hash = null; } - if (typeof equals === "undefined") { equals = null; } - return new HashTable(capacity, hash, equals); - } - Collections.createHashTable = createHashTable; - - var currentHashCode = 1; - function identityHashCode(value) { - if (value.__hash === undefined) { - value.__hash = currentHashCode; - currentHashCode++; - } - - return value.__hash; - } - Collections.identityHashCode = identityHashCode; - })(TypeScript.Collections || (TypeScript.Collections = {})); - var Collections = TypeScript.Collections; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var Diagnostic = (function () { - function Diagnostic(fileName, start, length, diagnosticCode, arguments) { - if (typeof arguments === "undefined") { arguments = null; } - this._diagnosticCode = diagnosticCode; - this._arguments = (arguments && arguments.length > 0) ? arguments : null; - this._fileName = fileName; - this._originalStart = this._start = start; - this._length = length; - } - Diagnostic.prototype.toJSON = function (key) { - var result = {}; - result.start = this.start(); - result.length = this.length(); - - result.diagnosticCode = TypeScript.DiagnosticCode[this.diagnosticCode()]; - - var arguments = (this).arguments(); - if (arguments && arguments.length > 0) { - result.arguments = arguments; - } - - return result; - }; - - Diagnostic.prototype.fileName = function () { - return this._fileName; - }; - - Diagnostic.prototype.start = function () { - return this._start; - }; - - Diagnostic.prototype.length = function () { - return this._length; - }; - - Diagnostic.prototype.diagnosticCode = function () { - return this._diagnosticCode; - }; - - Diagnostic.prototype.arguments = function () { - return this._arguments; - }; - - Diagnostic.prototype.text = function () { - return TypeScript.getDiagnosticText(this._diagnosticCode, this._arguments); - }; - - Diagnostic.prototype.message = function () { - return TypeScript.getDiagnosticMessage(this._diagnosticCode, this._arguments); - }; - - Diagnostic.prototype.adjustOffset = function (pos) { - this._start = this._originalStart + pos; - }; - - Diagnostic.prototype.additionalLocations = function () { - return []; - }; - - Diagnostic.equals = function (diagnostic1, diagnostic2) { - return diagnostic1._fileName === diagnostic2._fileName && diagnostic1._start === diagnostic2._start && diagnostic1._length === diagnostic2._length && diagnostic1._diagnosticCode === diagnostic2._diagnosticCode && TypeScript.ArrayUtilities.sequenceEquals(diagnostic1._arguments, diagnostic2._arguments, function (v1, v2) { - return v1 === v2; - }); - }; - return Diagnostic; - })(); - TypeScript.Diagnostic = Diagnostic; - - function getLargestIndex(diagnostic) { - var largest = -1; - var stringComponents = diagnostic.split("_"); - - for (var i = 0; i < stringComponents.length; i++) { - var val = parseInt(stringComponents[i]); - if (!isNaN(val) && val > largest) { - largest = val; - } - } - - return largest; - } - - function getDiagnosticInfoFromCode(diagnosticCode) { - var diagnosticName = TypeScript.DiagnosticCode[diagnosticCode]; - return TypeScript.diagnosticMessages[diagnosticName]; - } - TypeScript.getDiagnosticInfoFromCode = getDiagnosticInfoFromCode; - - function getDiagnosticText(diagnosticCode, args) { - var diagnosticName = TypeScript.DiagnosticCode[diagnosticCode]; - - var diagnostic = TypeScript.diagnosticMessages[diagnosticName]; - - var actualCount = args ? args.length : 0; - if (!diagnostic) { - throw new Error("Invalid diagnostic"); - } else { - var expectedCount = 1 + getLargestIndex(diagnosticName); - - if (expectedCount !== actualCount) { - throw new Error("Expected " + expectedCount + " arguments to diagnostic, got " + actualCount + " instead"); - } - } - - var diagnosticMessageText = diagnostic.message.replace(/{({(\d+)})?TB}/g, function (match, p1, num) { - var tabChar = "\t"; - var result = tabChar; - if (num && args[num]) { - for (var i = 1; i < args[num]; i++) { - result += tabChar; - } - } - - return result; - }); - - diagnosticMessageText = diagnosticMessageText.replace(/{(\d+)}/g, function (match, num) { - return typeof args[num] !== 'undefined' ? args[num] : match; - }); - - diagnosticMessageText = diagnosticMessageText.replace(/{(NL)}/g, function (match) { - return "\r\n"; - }); - - return diagnosticMessageText; - } - TypeScript.getDiagnosticText = getDiagnosticText; - - function getDiagnosticMessage(diagnosticCode, args) { - var diagnostic = getDiagnosticInfoFromCode(diagnosticCode); - var diagnosticMessageText = getDiagnosticText(diagnosticCode, args); - - var message; - if (diagnostic.category === 1 /* Error */) { - message = getDiagnosticText(0 /* error_TS_0__1 */, [diagnostic.code, diagnosticMessageText]); - } else if (diagnostic.category === 0 /* Warning */) { - message = getDiagnosticText(1 /* warning_TS_0__1 */, [diagnostic.code, diagnosticMessageText]); - } else { - message = diagnosticMessageText; - } - - return message; - } - TypeScript.getDiagnosticMessage = getDiagnosticMessage; -})(TypeScript || (TypeScript = {})); -var ByteOrderMark; -(function (ByteOrderMark) { - ByteOrderMark[ByteOrderMark["None"] = 0] = "None"; - ByteOrderMark[ByteOrderMark["Utf8"] = 1] = "Utf8"; - ByteOrderMark[ByteOrderMark["Utf16BigEndian"] = 2] = "Utf16BigEndian"; - ByteOrderMark[ByteOrderMark["Utf16LittleEndian"] = 3] = "Utf16LittleEndian"; -})(ByteOrderMark || (ByteOrderMark = {})); - -var FileInformation = (function () { - function FileInformation(contents, byteOrderMark) { - this._contents = contents; - this._byteOrderMark = byteOrderMark; - } - FileInformation.prototype.contents = function () { - return this._contents; - }; - - FileInformation.prototype.byteOrderMark = function () { - return this._byteOrderMark; - }; - return FileInformation; -})(); - -var Environment = (function () { - function getWindowsScriptHostEnvironment() { - try { - var fso = new ActiveXObject("Scripting.FileSystemObject"); - } catch (e) { - return null; - } - - var streamObjectPool = []; - - function getStreamObject() { - if (streamObjectPool.length > 0) { - return streamObjectPool.pop(); - } else { - return new ActiveXObject("ADODB.Stream"); - } - } - - function releaseStreamObject(obj) { - streamObjectPool.push(obj); - } - - var args = []; - for (var i = 0; i < WScript.Arguments.length; i++) { - args[i] = WScript.Arguments.Item(i); - } - - return { - currentDirectory: function () { - return (WScript).CreateObject("WScript.Shell").CurrentDirectory; - }, - readFile: function (path) { - try { - var streamObj = getStreamObject(); - streamObj.Open(); - streamObj.Type = 2; - - streamObj.Charset = 'x-ansi'; - - streamObj.LoadFromFile(path); - var bomChar = streamObj.ReadText(2); - - streamObj.Position = 0; - - var byteOrderMark = 0 /* None */; - - if (bomChar.charCodeAt(0) === 0xFE && bomChar.charCodeAt(1) === 0xFF) { - streamObj.Charset = 'unicode'; - byteOrderMark = 2 /* Utf16BigEndian */; - } else if (bomChar.charCodeAt(0) === 0xFF && bomChar.charCodeAt(1) === 0xFE) { - streamObj.Charset = 'unicode'; - byteOrderMark = 3 /* Utf16LittleEndian */; - } else if (bomChar.charCodeAt(0) === 0xEF && bomChar.charCodeAt(1) === 0xBB) { - streamObj.Charset = 'utf-8'; - byteOrderMark = 1 /* Utf8 */; - } else { - streamObj.Charset = 'utf-8'; - } - - var contents = streamObj.ReadText(-1); - streamObj.Close(); - releaseStreamObject(streamObj); - return new FileInformation(contents, byteOrderMark); - } catch (err) { - throw new Error("Error reading file \"" + path + "\": " + err.message); - } - }, - writeFile: function (path, contents, writeByteOrderMark) { - var textStream = getStreamObject(); - textStream.Charset = 'utf-8'; - textStream.Open(); - textStream.WriteText(contents, 0); - - if (!writeByteOrderMark) { - textStream.Position = 3; - } else { - textStream.Position = 0; - } - - var fileStream = getStreamObject(); - fileStream.Type = 1; - fileStream.Open(); - - textStream.CopyTo(fileStream); - - fileStream.Flush(); - fileStream.SaveToFile(path, 2); - fileStream.Close(); - - textStream.Flush(); - textStream.Close(); - }, - fileExists: function (path) { - return fso.FileExists(path); - }, - deleteFile: function (path) { - if (fso.FileExists(path)) { - fso.DeleteFile(path, true); - } - }, - directoryExists: function (path) { - return fso.FolderExists(path); - }, - listFiles: function (path, spec, options) { - options = options || {}; - function filesInFolder(folder, root) { - var paths = []; - var fc; - - if (options.recursive) { - fc = new Enumerator(folder.subfolders); - - for (; !fc.atEnd(); fc.moveNext()) { - paths = paths.concat(filesInFolder(fc.item(), root + "\\" + fc.item().Name)); - } - } - - fc = new Enumerator(folder.files); - - for (; !fc.atEnd(); fc.moveNext()) { - if (!spec || fc.item().Name.match(spec)) { - paths.push(root + "\\" + fc.item().Name); - } - } - - return paths; - } - - var folder = fso.GetFolder(path); - var paths = []; - - return filesInFolder(folder, path); - }, - arguments: args, - standardOut: WScript.StdOut - }; - } - ; - - function getNodeEnvironment() { - var _fs = require('fs'); - var _path = require('path'); - var _module = require('module'); - - return { - currentDirectory: function () { - return (process).cwd(); - }, - readFile: function (file) { - var buffer = _fs.readFileSync(file); - switch (buffer[0]) { - case 0xFE: - if (buffer[1] === 0xFF) { - var i = 0; - while ((i + 1) < buffer.length) { - var temp = buffer[i]; - buffer[i] = buffer[i + 1]; - buffer[i + 1] = temp; - i += 2; - } - return new FileInformation(buffer.toString("ucs2", 2), 2 /* Utf16BigEndian */); - } - break; - case 0xFF: - if (buffer[1] === 0xFE) { - return new FileInformation(buffer.toString("ucs2", 2), 3 /* Utf16LittleEndian */); - } - break; - case 0xEF: - if (buffer[1] === 0xBB) { - return new FileInformation(buffer.toString("utf8", 3), 1 /* Utf8 */); - } - } - - return new FileInformation(buffer.toString("utf8", 0), 0 /* None */); - }, - writeFile: function (path, contents, writeByteOrderMark) { - function mkdirRecursiveSync(path) { - var stats = _fs.statSync(path); - if (stats.isFile()) { - throw "\"" + path + "\" exists but isn't a directory."; - } else if (stats.isDirectory()) { - return; - } else { - mkdirRecursiveSync(_path.dirname(path)); - _fs.mkdirSync(path, 0775); - } - } - mkdirRecursiveSync(_path.dirname(path)); - - if (writeByteOrderMark) { - contents = '\uFEFF' + contents; - } - _fs.writeFileSync(path, contents, "utf8"); - }, - fileExists: function (path) { - return _fs.existsSync(path); - }, - deleteFile: function (path) { - try { - _fs.unlinkSync(path); - } catch (e) { - } - }, - directoryExists: function (path) { - return _fs.existsSync(path) && _fs.statSync(path).isDirectory(); - }, - listFiles: function dir(path, spec, options) { - options = options || {}; - - function filesInFolder(folder) { - var paths = []; - - var files = _fs.readdirSync(folder); - for (var i = 0; i < files.length; i++) { - var stat = _fs.statSync(folder + "\\" + files[i]); - if (options.recursive && stat.isDirectory()) { - paths = paths.concat(filesInFolder(folder + "\\" + files[i])); - } else if (stat.isFile() && (!spec || files[i].match(spec))) { - paths.push(folder + "\\" + files[i]); - } - } - - return paths; - } - - return filesInFolder(path); - }, - arguments: process.argv.slice(2), - standardOut: { - Write: function (str) { - process.stdout.write(str); - }, - WriteLine: function (str) { - process.stdout.write(str + '\n'); - }, - Close: function () { - } - } - }; - } - ; - - if (typeof WScript !== "undefined" && typeof ActiveXObject === "function") { - return getWindowsScriptHostEnvironment(); - } else if (typeof module !== 'undefined' && module.exports) { - return getNodeEnvironment(); - } else { - return null; - } -})(); -var TypeScript; -(function (TypeScript) { - var IntegerUtilities = (function () { - function IntegerUtilities() { - } - IntegerUtilities.integerDivide = function (numerator, denominator) { - return (numerator / denominator) >> 0; - }; - - IntegerUtilities.integerMultiplyLow32Bits = function (n1, n2) { - var n1Low16 = n1 & 0x0000ffff; - var n1High16 = n1 >>> 16; - - var n2Low16 = n2 & 0x0000ffff; - var n2High16 = n2 >>> 16; - - var resultLow32 = (((n1 & 0xffff0000) * n2) >>> 0) + (((n1 & 0x0000ffff) * n2) >>> 0) >>> 0; - return resultLow32; - }; - - IntegerUtilities.integerMultiplyHigh32Bits = function (n1, n2) { - var n1Low16 = n1 & 0x0000ffff; - var n1High16 = n1 >>> 16; - - var n2Low16 = n2 & 0x0000ffff; - var n2High16 = n2 >>> 16; - - var resultHigh32 = n1High16 * n2High16 + ((((n1Low16 * n2Low16) >>> 17) + n1Low16 * n2High16) >>> 15); - return resultHigh32; - }; - return IntegerUtilities; - })(); - TypeScript.IntegerUtilities = IntegerUtilities; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var MathPrototype = (function () { - function MathPrototype() { - } - MathPrototype.max = function (a, b) { - return a >= b ? a : b; - }; - - MathPrototype.min = function (a, b) { - return a <= b ? a : b; - }; - return MathPrototype; - })(); - TypeScript.MathPrototype = MathPrototype; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (Collections) { - Collections.DefaultStringTableCapacity = 256; - - var StringTableEntry = (function () { - function StringTableEntry(Text, HashCode, Next) { - this.Text = Text; - this.HashCode = HashCode; - this.Next = Next; - } - return StringTableEntry; - })(); - - var StringTable = (function () { - function StringTable(capacity) { - this.entries = []; - this.count = 0; - var size = TypeScript.Hash.getPrime(capacity); - this.entries = TypeScript.ArrayUtilities.createArray(size, null); - } - StringTable.prototype.addCharArray = function (key, start, len) { - var hashCode = TypeScript.Hash.computeSimple31BitCharArrayHashCode(key, start, len) & 0x7FFFFFFF; - - var entry = this.findCharArrayEntry(key, start, len, hashCode); - if (entry !== null) { - return entry.Text; - } - - var slice = key.slice(start, start + len); - return this.addEntry(TypeScript.StringUtilities.fromCharCodeArray(slice), hashCode); - }; - - StringTable.prototype.findCharArrayEntry = function (key, start, len, hashCode) { - 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; - }; - - StringTable.prototype.addEntry = function (text, hashCode) { - var index = hashCode % this.entries.length; - - var e = new StringTableEntry(text, hashCode, this.entries[index]); - - this.entries[index] = e; - - if (this.count === this.entries.length) { - this.grow(); - } - - this.count++; - return e.Text; - }; - - StringTable.prototype.grow = function () { - var newSize = TypeScript.Hash.expandPrime(this.entries.length); - - var oldEntries = this.entries; - var newEntries = TypeScript.ArrayUtilities.createArray(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; - } - } - }; - - StringTable.textCharArrayEquals = function (text, array, start, length) { - 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; - }; - return StringTable; - })(); - Collections.StringTable = StringTable; - - Collections.DefaultStringTable = new StringTable(Collections.DefaultStringTableCapacity); - })(TypeScript.Collections || (TypeScript.Collections = {})); - var Collections = TypeScript.Collections; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var StringUtilities = (function () { - function StringUtilities() { - } - StringUtilities.isString = function (value) { - return Object.prototype.toString.apply(value, []) === '[object String]'; - }; - - StringUtilities.fromCharCodeArray = function (array) { - return String.fromCharCode.apply(null, array); - }; - - StringUtilities.endsWith = function (string, value) { - return string.substring(string.length - value.length, string.length) === value; - }; - - StringUtilities.startsWith = function (string, value) { - return string.substr(0, value.length) === value; - }; - - StringUtilities.copyTo = function (source, sourceIndex, destination, destinationIndex, count) { - for (var i = 0; i < count; i++) { - destination[destinationIndex + i] = source.charCodeAt(sourceIndex + i); - } - }; - - StringUtilities.repeat = function (value, count) { - return Array(count + 1).join(value); - }; - - StringUtilities.stringEquals = function (val1, val2) { - return val1 === val2; - }; - return StringUtilities; - })(); - TypeScript.StringUtilities = StringUtilities; -})(TypeScript || (TypeScript = {})); -var global = Function("return this").call(null); - -var TypeScript; -(function (TypeScript) { - var Clock; - (function (Clock) { - Clock.now; - Clock.resolution; - - if (typeof WScript !== "undefined" && typeof global['WScript'].InitializeProjection !== "undefined") { - global['WScript'].InitializeProjection(); - - Clock.now = function () { - return TestUtilities.QueryPerformanceCounter(); - }; - - Clock.resolution = TestUtilities.QueryPerformanceFrequency(); - } else { - Clock.now = function () { - return Date.now(); - }; - - Clock.resolution = 1000; - } - })(Clock || (Clock = {})); - - var Timer = (function () { - function Timer() { - this.time = 0; - } - Timer.prototype.start = function () { - this.time = 0; - this.startTime = Clock.now(); - }; - - Timer.prototype.end = function () { - this.time = (Clock.now() - this.startTime); - }; - return Timer; - })(); - TypeScript.Timer = Timer; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (CharacterCodes) { - CharacterCodes[CharacterCodes["nullCharacter"] = 0] = "nullCharacter"; - CharacterCodes[CharacterCodes["maxAsciiCharacter"] = 127] = "maxAsciiCharacter"; - - CharacterCodes[CharacterCodes["lineFeed"] = 10] = "lineFeed"; - CharacterCodes[CharacterCodes["carriageReturn"] = 13] = "carriageReturn"; - CharacterCodes[CharacterCodes["lineSeparator"] = 0x2028] = "lineSeparator"; - CharacterCodes[CharacterCodes["paragraphSeparator"] = 0x2029] = "paragraphSeparator"; - - CharacterCodes[CharacterCodes["nextLine"] = 0x0085] = "nextLine"; - - CharacterCodes[CharacterCodes["space"] = 0x0020] = "space"; - CharacterCodes[CharacterCodes["nonBreakingSpace"] = 0x00A0] = "nonBreakingSpace"; - CharacterCodes[CharacterCodes["enQuad"] = 0x2000] = "enQuad"; - CharacterCodes[CharacterCodes["emQuad"] = 0x2001] = "emQuad"; - CharacterCodes[CharacterCodes["enSpace"] = 0x2002] = "enSpace"; - CharacterCodes[CharacterCodes["emSpace"] = 0x2003] = "emSpace"; - CharacterCodes[CharacterCodes["threePerEmSpace"] = 0x2004] = "threePerEmSpace"; - CharacterCodes[CharacterCodes["fourPerEmSpace"] = 0x2005] = "fourPerEmSpace"; - CharacterCodes[CharacterCodes["sixPerEmSpace"] = 0x2006] = "sixPerEmSpace"; - CharacterCodes[CharacterCodes["figureSpace"] = 0x2007] = "figureSpace"; - CharacterCodes[CharacterCodes["punctuationSpace"] = 0x2008] = "punctuationSpace"; - CharacterCodes[CharacterCodes["thinSpace"] = 0x2009] = "thinSpace"; - CharacterCodes[CharacterCodes["hairSpace"] = 0x200A] = "hairSpace"; - CharacterCodes[CharacterCodes["zeroWidthSpace"] = 0x200B] = "zeroWidthSpace"; - CharacterCodes[CharacterCodes["narrowNoBreakSpace"] = 0x202F] = "narrowNoBreakSpace"; - CharacterCodes[CharacterCodes["ideographicSpace"] = 0x3000] = "ideographicSpace"; - - CharacterCodes[CharacterCodes["_"] = 95] = "_"; - CharacterCodes[CharacterCodes["$"] = 36] = "$"; - - CharacterCodes[CharacterCodes["_0"] = 48] = "_0"; - CharacterCodes[CharacterCodes["_9"] = 57] = "_9"; - - CharacterCodes[CharacterCodes["a"] = 97] = "a"; - CharacterCodes[CharacterCodes["b"] = 98] = "b"; - CharacterCodes[CharacterCodes["c"] = 99] = "c"; - CharacterCodes[CharacterCodes["d"] = 100] = "d"; - CharacterCodes[CharacterCodes["e"] = 101] = "e"; - CharacterCodes[CharacterCodes["f"] = 102] = "f"; - CharacterCodes[CharacterCodes["g"] = 103] = "g"; - CharacterCodes[CharacterCodes["h"] = 104] = "h"; - CharacterCodes[CharacterCodes["i"] = 105] = "i"; - CharacterCodes[CharacterCodes["k"] = 107] = "k"; - CharacterCodes[CharacterCodes["l"] = 108] = "l"; - CharacterCodes[CharacterCodes["m"] = 109] = "m"; - CharacterCodes[CharacterCodes["n"] = 110] = "n"; - CharacterCodes[CharacterCodes["o"] = 111] = "o"; - CharacterCodes[CharacterCodes["p"] = 112] = "p"; - CharacterCodes[CharacterCodes["q"] = 113] = "q"; - CharacterCodes[CharacterCodes["r"] = 114] = "r"; - CharacterCodes[CharacterCodes["s"] = 115] = "s"; - CharacterCodes[CharacterCodes["t"] = 116] = "t"; - CharacterCodes[CharacterCodes["u"] = 117] = "u"; - CharacterCodes[CharacterCodes["v"] = 118] = "v"; - CharacterCodes[CharacterCodes["w"] = 119] = "w"; - CharacterCodes[CharacterCodes["x"] = 120] = "x"; - CharacterCodes[CharacterCodes["y"] = 121] = "y"; - CharacterCodes[CharacterCodes["z"] = 122] = "z"; - - CharacterCodes[CharacterCodes["A"] = 65] = "A"; - CharacterCodes[CharacterCodes["E"] = 69] = "E"; - CharacterCodes[CharacterCodes["F"] = 70] = "F"; - CharacterCodes[CharacterCodes["X"] = 88] = "X"; - CharacterCodes[CharacterCodes["Z"] = 90] = "Z"; - - CharacterCodes[CharacterCodes["ampersand"] = 38] = "ampersand"; - CharacterCodes[CharacterCodes["asterisk"] = 42] = "asterisk"; - CharacterCodes[CharacterCodes["at"] = 64] = "at"; - CharacterCodes[CharacterCodes["backslash"] = 92] = "backslash"; - CharacterCodes[CharacterCodes["bar"] = 124] = "bar"; - CharacterCodes[CharacterCodes["caret"] = 94] = "caret"; - CharacterCodes[CharacterCodes["closeBrace"] = 125] = "closeBrace"; - CharacterCodes[CharacterCodes["closeBracket"] = 93] = "closeBracket"; - CharacterCodes[CharacterCodes["closeParen"] = 41] = "closeParen"; - CharacterCodes[CharacterCodes["colon"] = 58] = "colon"; - CharacterCodes[CharacterCodes["comma"] = 44] = "comma"; - CharacterCodes[CharacterCodes["dot"] = 46] = "dot"; - CharacterCodes[CharacterCodes["doubleQuote"] = 34] = "doubleQuote"; - CharacterCodes[CharacterCodes["equals"] = 61] = "equals"; - CharacterCodes[CharacterCodes["exclamation"] = 33] = "exclamation"; - CharacterCodes[CharacterCodes["greaterThan"] = 62] = "greaterThan"; - CharacterCodes[CharacterCodes["lessThan"] = 60] = "lessThan"; - CharacterCodes[CharacterCodes["minus"] = 45] = "minus"; - CharacterCodes[CharacterCodes["openBrace"] = 123] = "openBrace"; - CharacterCodes[CharacterCodes["openBracket"] = 91] = "openBracket"; - CharacterCodes[CharacterCodes["openParen"] = 40] = "openParen"; - CharacterCodes[CharacterCodes["percent"] = 37] = "percent"; - CharacterCodes[CharacterCodes["plus"] = 43] = "plus"; - CharacterCodes[CharacterCodes["question"] = 63] = "question"; - CharacterCodes[CharacterCodes["semicolon"] = 59] = "semicolon"; - CharacterCodes[CharacterCodes["singleQuote"] = 39] = "singleQuote"; - CharacterCodes[CharacterCodes["slash"] = 47] = "slash"; - CharacterCodes[CharacterCodes["tilde"] = 126] = "tilde"; - - CharacterCodes[CharacterCodes["backspace"] = 8] = "backspace"; - CharacterCodes[CharacterCodes["formFeed"] = 12] = "formFeed"; - CharacterCodes[CharacterCodes["byteOrderMark"] = 0xFEFF] = "byteOrderMark"; - CharacterCodes[CharacterCodes["tab"] = 9] = "tab"; - CharacterCodes[CharacterCodes["verticalTab"] = 11] = "verticalTab"; - })(TypeScript.CharacterCodes || (TypeScript.CharacterCodes = {})); - var CharacterCodes = TypeScript.CharacterCodes; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (ScriptSnapshot) { - var StringScriptSnapshot = (function () { - function StringScriptSnapshot(text) { - this.text = text; - } - StringScriptSnapshot.prototype.getText = function (start, end) { - return this.text.substring(start, end); - }; - - StringScriptSnapshot.prototype.getLength = function () { - return this.text.length; - }; - - StringScriptSnapshot.prototype.getLineStartPositions = function () { - return TypeScript.TextUtilities.parseLineStarts(TypeScript.SimpleText.fromString(this.text)); - }; - - StringScriptSnapshot.prototype.getTextChangeRangeSinceVersion = function (scriptVersion) { - throw TypeScript.Errors.notYetImplemented(); - }; - return StringScriptSnapshot; - })(); - - function fromString(text) { - return new StringScriptSnapshot(text); - } - ScriptSnapshot.fromString = fromString; - })(TypeScript.ScriptSnapshot || (TypeScript.ScriptSnapshot = {})); - var ScriptSnapshot = TypeScript.ScriptSnapshot; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var LineMap = (function () { - function LineMap(_lineStarts, length) { - this._lineStarts = _lineStarts; - this.length = length; - } - LineMap.prototype.toJSON = function (key) { - return { lineStarts: this._lineStarts, length: this.length }; - }; - - LineMap.prototype.equals = function (other) { - return this.length === other.length && TypeScript.ArrayUtilities.sequenceEquals(this.lineStarts(), other.lineStarts(), function (v1, v2) { - return v1 === v2; - }); - }; - - LineMap.prototype.lineStarts = function () { - return this._lineStarts; - }; - - LineMap.prototype.lineCount = function () { - return this.lineStarts().length; - }; - - LineMap.prototype.getPosition = function (line, character) { - return this.lineStarts()[line] + character; - }; - - LineMap.prototype.getLineNumberFromPosition = function (position) { - if (position < 0 || position > this.length) { - throw TypeScript.Errors.argumentOutOfRange("position"); - } - - if (position === this.length) { - return this.lineCount() - 1; - } - - var lineNumber = TypeScript.ArrayUtilities.binarySearch(this.lineStarts(), position); - if (lineNumber < 0) { - lineNumber = (~lineNumber) - 1; - } - - return lineNumber; - }; - - LineMap.prototype.getLineStartPosition = function (lineNumber) { - return this.lineStarts()[lineNumber]; - }; - - LineMap.prototype.fillLineAndCharacterFromPosition = function (position, lineAndCharacter) { - if (position < 0 || position > this.length) { - throw TypeScript.Errors.argumentOutOfRange("position"); - } - - var lineNumber = this.getLineNumberFromPosition(position); - lineAndCharacter.line = lineNumber; - lineAndCharacter.character = position - this.lineStarts()[lineNumber]; - }; - - LineMap.prototype.getLineAndCharacterFromPosition = function (position) { - if (position < 0 || position > this.length) { - throw TypeScript.Errors.argumentOutOfRange("position"); - } - - var lineNumber = this.getLineNumberFromPosition(position); - - return new TypeScript.LineAndCharacter(lineNumber, position - this.lineStarts()[lineNumber]); - }; - - LineMap.fromSimpleText = function (text) { - var lineStarts = TypeScript.TextUtilities.parseLineStarts(text); - - return new LineMap(lineStarts, text.length()); - }; - - LineMap.fromScriptSnapshot = function (scriptSnapshot) { - return new LineMap(scriptSnapshot.getLineStartPositions(), scriptSnapshot.getLength()); - }; - - LineMap.fromString = function (text) { - return LineMap.fromSimpleText(TypeScript.SimpleText.fromString(text)); - }; - LineMap.empty = new LineMap([0], 0); - return LineMap; - })(); - TypeScript.LineMap = LineMap; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var LineAndCharacter = (function () { - function LineAndCharacter(line, character) { - this._line = 0; - this._character = 0; - if (line < 0) { - throw TypeScript.Errors.argumentOutOfRange("line"); - } - - if (character < 0) { - throw TypeScript.Errors.argumentOutOfRange("character"); - } - - this._line = line; - this._character = character; - } - LineAndCharacter.prototype.line = function () { - return this._line; - }; - - LineAndCharacter.prototype.character = function () { - return this._character; - }; - return LineAndCharacter; - })(); - TypeScript.LineAndCharacter = LineAndCharacter; -})(TypeScript || (TypeScript = {})); -var __extends = this.__extends || function (d, b) { - for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; - function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); -}; -var TypeScript; -(function (TypeScript) { - (function (TextFactory) { - function getStartAndLengthOfLineBreakEndingAt(text, index, info) { - var c = text.charCodeAt(index); - if (c === 10 /* lineFeed */) { - if (index > 0 && text.charCodeAt(index - 1) === 13 /* carriageReturn */) { - info.startPosition = index - 1; - info.length = 2; - } else { - info.startPosition = index; - info.length = 1; - } - } else if (TypeScript.TextUtilities.isAnyLineBreakCharacter(c)) { - info.startPosition = index; - info.length = 1; - } else { - info.startPosition = index + 1; - info.length = 0; - } - } - - var LinebreakInfo = (function () { - function LinebreakInfo(startPosition, length) { - this.startPosition = startPosition; - this.length = length; - } - return LinebreakInfo; - })(); - - var TextLine = (function () { - function TextLine(text, body, lineBreakLength, lineNumber) { - this._text = null; - this._textSpan = null; - TypeScript.Contract.throwIfNull(text); - TypeScript.Contract.throwIfFalse(lineBreakLength >= 0); - TypeScript.Contract.requires(lineNumber >= 0); - this._text = text; - this._textSpan = body; - this._lineBreakLength = lineBreakLength; - this._lineNumber = lineNumber; - } - TextLine.prototype.start = function () { - return this._textSpan.start(); - }; - - TextLine.prototype.end = function () { - return this._textSpan.end(); - }; - - TextLine.prototype.endIncludingLineBreak = function () { - return this.end() + this._lineBreakLength; - }; - - TextLine.prototype.extent = function () { - return this._textSpan; - }; - - TextLine.prototype.extentIncludingLineBreak = function () { - return TypeScript.TextSpan.fromBounds(this.start(), this.endIncludingLineBreak()); - }; - - TextLine.prototype.toString = function () { - return this._text.toString(this._textSpan); - }; - - TextLine.prototype.lineNumber = function () { - return this._lineNumber; - }; - return TextLine; - })(); - - var TextBase = (function () { - function TextBase() { - this.lazyLineStarts = null; - this.linebreakInfo = new LinebreakInfo(0, 0); - this.lastLineFoundForPosition = null; - } - TextBase.prototype.length = function () { - throw TypeScript.Errors.abstract(); - }; - - TextBase.prototype.charCodeAt = function (position) { - throw TypeScript.Errors.abstract(); - }; - - TextBase.prototype.checkSubSpan = function (span) { - if (span.start() < 0 || span.start() > this.length() || span.end() > this.length()) { - throw TypeScript.Errors.argumentOutOfRange("span"); - } - }; - - TextBase.prototype.toString = function (span) { - if (typeof span === "undefined") { span = null; } - throw TypeScript.Errors.abstract(); - }; - - TextBase.prototype.subText = function (span) { - this.checkSubSpan(span); - - return new SubText(this, span); - }; - - TextBase.prototype.substr = function (start, length, intern) { - throw TypeScript.Errors.abstract(); - }; - - TextBase.prototype.copyTo = function (sourceIndex, destination, destinationIndex, count) { - throw TypeScript.Errors.abstract(); - }; - - TextBase.prototype.lineCount = function () { - return this.lineStarts().length; - }; - - TextBase.prototype.lines = function () { - var lines = []; - - var length = this.lineCount(); - for (var i = 0; i < length; ++i) { - lines[i] = this.getLineFromLineNumber(i); - } - - return lines; - }; - - TextBase.prototype.lineMap = function () { - return new TypeScript.LineMap(this.lineStarts(), this.length()); - }; - - TextBase.prototype.lineStarts = function () { - if (this.lazyLineStarts === null) { - this.lazyLineStarts = TypeScript.TextUtilities.parseLineStarts(this); - } - - return this.lazyLineStarts; - }; - - TextBase.prototype.getLineFromLineNumber = function (lineNumber) { - var lineStarts = this.lineStarts(); - - if (lineNumber < 0 || lineNumber >= lineStarts.length) { - throw TypeScript.Errors.argumentOutOfRange("lineNumber"); - } - - var first = lineStarts[lineNumber]; - if (lineNumber === lineStarts.length - 1) { - return new TextLine(this, new TypeScript.TextSpan(first, this.length() - first), 0, lineNumber); - } else { - getStartAndLengthOfLineBreakEndingAt(this, lineStarts[lineNumber + 1] - 1, this.linebreakInfo); - return new TextLine(this, new TypeScript.TextSpan(first, this.linebreakInfo.startPosition - first), this.linebreakInfo.length, lineNumber); - } - }; - - TextBase.prototype.getLineFromPosition = function (position) { - var lastFound = this.lastLineFoundForPosition; - if (lastFound !== null && lastFound.start() <= position && lastFound.endIncludingLineBreak() > position) { - return lastFound; - } - - var lineNumber = this.getLineNumberFromPosition(position); - - var result = this.getLineFromLineNumber(lineNumber); - this.lastLineFoundForPosition = result; - return result; - }; - - TextBase.prototype.getLineNumberFromPosition = function (position) { - if (position < 0 || position > this.length()) { - throw TypeScript.Errors.argumentOutOfRange("position"); - } - - if (position === this.length()) { - return this.lineCount() - 1; - } - - var lineNumber = TypeScript.ArrayUtilities.binarySearch(this.lineStarts(), position); - if (lineNumber < 0) { - lineNumber = (~lineNumber) - 1; - } - - return lineNumber; - }; - - TextBase.prototype.getLinePosition = function (position) { - if (position < 0 || position > this.length()) { - throw TypeScript.Errors.argumentOutOfRange("position"); - } - - var lineNumber = this.getLineNumberFromPosition(position); - - return new TypeScript.LineAndCharacter(lineNumber, position - this.lineStarts()[lineNumber]); - }; - return TextBase; - })(); - - var SubText = (function (_super) { - __extends(SubText, _super); - function SubText(text, span) { - _super.call(this); - - if (text === null) { - throw TypeScript.Errors.argumentNull("text"); - } - - if (span.start() < 0 || span.start() >= text.length() || span.end() < 0 || span.end() > text.length()) { - throw TypeScript.Errors.argument("span"); - } - - this.text = text; - this.span = span; - } - SubText.prototype.length = function () { - return this.span.length(); - }; - - SubText.prototype.charCodeAt = function (position) { - if (position < 0 || position > this.length()) { - throw TypeScript.Errors.argumentOutOfRange("position"); - } - - return this.text.charCodeAt(this.span.start() + position); - }; - - SubText.prototype.subText = function (span) { - this.checkSubSpan(span); - - return new SubText(this.text, this.getCompositeSpan(span.start(), span.length())); - }; - - SubText.prototype.copyTo = function (sourceIndex, destination, destinationIndex, count) { - var span = this.getCompositeSpan(sourceIndex, count); - this.text.copyTo(span.start(), destination, destinationIndex, span.length()); - }; - - SubText.prototype.getCompositeSpan = function (start, length) { - var compositeStart = TypeScript.MathPrototype.min(this.text.length(), this.span.start() + start); - var compositeEnd = TypeScript.MathPrototype.min(this.text.length(), compositeStart + length); - return new TypeScript.TextSpan(compositeStart, compositeEnd - compositeStart); - }; - return SubText; - })(TextBase); - - var StringText = (function (_super) { - __extends(StringText, _super); - function StringText(data) { - _super.call(this); - this.source = null; - - if (data === null) { - throw TypeScript.Errors.argumentNull("data"); - } - - this.source = data; - } - StringText.prototype.length = function () { - return this.source.length; - }; - - StringText.prototype.charCodeAt = function (position) { - if (position < 0 || position >= this.source.length) { - throw TypeScript.Errors.argumentOutOfRange("position"); - } - - return this.source.charCodeAt(position); - }; - - StringText.prototype.substr = function (start, length, intern) { - return this.source.substr(start, length); - }; - - StringText.prototype.toString = function (span) { - if (typeof span === "undefined") { span = null; } - if (span === null) { - span = new TypeScript.TextSpan(0, this.length()); - } - - this.checkSubSpan(span); - - if (span.start() === 0 && span.length() === this.length()) { - return this.source; - } - - return this.source.substr(span.start(), span.length()); - }; - - StringText.prototype.copyTo = function (sourceIndex, destination, destinationIndex, count) { - TypeScript.StringUtilities.copyTo(this.source, sourceIndex, destination, destinationIndex, count); - }; - return StringText; - })(TextBase); - - function createText(value) { - return new StringText(value); - } - TextFactory.createText = createText; - })(TypeScript.TextFactory || (TypeScript.TextFactory = {})); - var TextFactory = TypeScript.TextFactory; -})(TypeScript || (TypeScript = {})); - -var TypeScript; -(function (TypeScript) { - (function (SimpleText) { - var SimpleSubText = (function () { - function SimpleSubText(text, span) { - this.text = null; - this.span = null; - if (text === null) { - throw TypeScript.Errors.argumentNull("text"); - } - - if (span.start() < 0 || span.start() >= text.length() || span.end() < 0 || span.end() > text.length()) { - throw TypeScript.Errors.argument("span"); - } - - this.text = text; - this.span = span; - } - SimpleSubText.prototype.checkSubSpan = function (span) { - if (span.start() < 0 || span.start() > this.length() || span.end() > this.length()) { - throw TypeScript.Errors.argumentOutOfRange("span"); - } - }; - - SimpleSubText.prototype.checkSubPosition = function (position) { - if (position < 0 || position >= this.length()) { - throw TypeScript.Errors.argumentOutOfRange("position"); - } - }; - - SimpleSubText.prototype.length = function () { - return this.span.length(); - }; - - SimpleSubText.prototype.subText = function (span) { - this.checkSubSpan(span); - - return new SimpleSubText(this.text, this.getCompositeSpan(span.start(), span.length())); - }; - - SimpleSubText.prototype.copyTo = function (sourceIndex, destination, destinationIndex, count) { - var span = this.getCompositeSpan(sourceIndex, count); - this.text.copyTo(span.start(), destination, destinationIndex, span.length()); - }; - - SimpleSubText.prototype.substr = function (start, length, intern) { - var span = this.getCompositeSpan(start, length); - return this.text.substr(span.start(), span.length(), intern); - }; - - SimpleSubText.prototype.getCompositeSpan = function (start, length) { - var compositeStart = TypeScript.MathPrototype.min(this.text.length(), this.span.start() + start); - var compositeEnd = TypeScript.MathPrototype.min(this.text.length(), compositeStart + length); - return new TypeScript.TextSpan(compositeStart, compositeEnd - compositeStart); - }; - - SimpleSubText.prototype.charCodeAt = function (index) { - this.checkSubPosition(index); - return this.text.charCodeAt(this.span.start() + index); - }; - - SimpleSubText.prototype.lineMap = function () { - return TypeScript.LineMap.fromSimpleText(this); - }; - return SimpleSubText; - })(); - - var SimpleStringText = (function () { - function SimpleStringText(value) { - this.value = value; - } - SimpleStringText.prototype.length = function () { - return this.value.length; - }; - - SimpleStringText.prototype.copyTo = function (sourceIndex, destination, destinationIndex, count) { - TypeScript.StringUtilities.copyTo(this.value, sourceIndex, destination, destinationIndex, count); - }; - - SimpleStringText.prototype.substr = function (start, length, intern) { - if (intern) { - var array = length <= SimpleStringText.charArray.length ? SimpleStringText.charArray : TypeScript.ArrayUtilities.createArray(length, 0); - this.copyTo(start, array, 0, length); - return TypeScript.Collections.DefaultStringTable.addCharArray(array, 0, length); - } - - return this.value.substr(start, length); - }; - - SimpleStringText.prototype.subText = function (span) { - return new SimpleSubText(this, span); - }; - - SimpleStringText.prototype.charCodeAt = function (index) { - return this.value.charCodeAt(index); - }; - - SimpleStringText.prototype.lineMap = function () { - return TypeScript.LineMap.fromSimpleText(this); - }; - SimpleStringText.charArray = TypeScript.ArrayUtilities.createArray(1024, 0); - return SimpleStringText; - })(); - - var SimpleScriptSnapshotText = (function () { - function SimpleScriptSnapshotText(scriptSnapshot) { - this.scriptSnapshot = scriptSnapshot; - } - SimpleScriptSnapshotText.prototype.charCodeAt = function (index) { - return this.scriptSnapshot.getText(index, index + 1).charCodeAt(0); - }; - - SimpleScriptSnapshotText.prototype.length = function () { - return this.scriptSnapshot.getLength(); - }; - - SimpleScriptSnapshotText.prototype.copyTo = function (sourceIndex, destination, destinationIndex, count) { - var text = this.scriptSnapshot.getText(sourceIndex, sourceIndex + count); - TypeScript.StringUtilities.copyTo(text, 0, destination, destinationIndex, count); - }; - - SimpleScriptSnapshotText.prototype.substr = function (start, length, intern) { - return this.scriptSnapshot.getText(start, start + length); - }; - - SimpleScriptSnapshotText.prototype.subText = function (span) { - return new SimpleSubText(this, span); - }; - - SimpleScriptSnapshotText.prototype.lineMap = function () { - var lineStartPositions = this.scriptSnapshot.getLineStartPositions(); - return new TypeScript.LineMap(lineStartPositions, this.length()); - }; - return SimpleScriptSnapshotText; - })(); - - function fromString(value) { - return new SimpleStringText(value); - } - SimpleText.fromString = fromString; - - function fromScriptSnapshot(scriptSnapshot) { - return new SimpleScriptSnapshotText(scriptSnapshot); - } - SimpleText.fromScriptSnapshot = fromScriptSnapshot; - })(TypeScript.SimpleText || (TypeScript.SimpleText = {})); - var SimpleText = TypeScript.SimpleText; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (TextUtilities) { - function parseLineStarts(text) { - var length = text.length(); - - if (0 === length) { - var result = []; - result.push(0); - return result; - } - - var position = 0; - var index = 0; - var arrayBuilder = []; - var lineNumber = 0; - - while (index < length) { - var c = text.charCodeAt(index); - var lineBreakLength; - - if (c > 13 /* carriageReturn */ && c <= 127) { - index++; - continue; - } else if (c === 13 /* carriageReturn */ && index + 1 < length && text.charCodeAt(index + 1) === 10 /* lineFeed */) { - lineBreakLength = 2; - } else if (c === 10 /* lineFeed */) { - lineBreakLength = 1; - } else { - lineBreakLength = TextUtilities.getLengthOfLineBreak(text, index); - } - - if (0 === lineBreakLength) { - index++; - } else { - arrayBuilder.push(position); - index += lineBreakLength; - position = index; - lineNumber++; - } - } - - arrayBuilder.push(position); - - return arrayBuilder; - } - TextUtilities.parseLineStarts = parseLineStarts; - - function getLengthOfLineBreakSlow(text, index, c) { - if (c === 13 /* carriageReturn */) { - var next = index + 1; - return (next < text.length()) && 10 /* lineFeed */ === text.charCodeAt(next) ? 2 : 1; - } else if (isAnyLineBreakCharacter(c)) { - return 1; - } else { - return 0; - } - } - TextUtilities.getLengthOfLineBreakSlow = getLengthOfLineBreakSlow; - - function getLengthOfLineBreak(text, index) { - var c = text.charCodeAt(index); - - if (c > 13 /* carriageReturn */ && c <= 127) { - return 0; - } - - return getLengthOfLineBreakSlow(text, index, c); - } - TextUtilities.getLengthOfLineBreak = getLengthOfLineBreak; - - function isAnyLineBreakCharacter(c) { - return c === 10 /* lineFeed */ || c === 13 /* carriageReturn */ || c === 133 /* nextLine */ || c === 8232 /* lineSeparator */ || c === 8233 /* paragraphSeparator */; - } - TextUtilities.isAnyLineBreakCharacter = isAnyLineBreakCharacter; - })(TypeScript.TextUtilities || (TypeScript.TextUtilities = {})); - var TextUtilities = TypeScript.TextUtilities; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var TextSpan = (function () { - function TextSpan(start, length) { - if (start < 0) { - TypeScript.Errors.argument("start"); - } - - if (start + length < start) { - throw new Error("length"); - } - - this._start = start; - this._length = length; - } - TextSpan.prototype.start = function () { - return this._start; - }; - - TextSpan.prototype.length = function () { - return this._length; - }; - - TextSpan.prototype.end = function () { - return this._start + this._length; - }; - - TextSpan.prototype.isEmpty = function () { - return this._length === 0; - }; - - TextSpan.prototype.containsPosition = function (position) { - return position >= this._start && position < this.end(); - }; - - TextSpan.prototype.containsTextSpan = function (span) { - return span._start >= this._start && span.end() <= this.end(); - }; - - TextSpan.prototype.overlapsWith = function (span) { - var overlapStart = TypeScript.MathPrototype.max(this._start, span._start); - var overlapEnd = TypeScript.MathPrototype.min(this.end(), span.end()); - - return overlapStart < overlapEnd; - }; - - TextSpan.prototype.overlap = function (span) { - var overlapStart = TypeScript.MathPrototype.max(this._start, span._start); - var overlapEnd = TypeScript.MathPrototype.min(this.end(), span.end()); - - if (overlapStart < overlapEnd) { - return TextSpan.fromBounds(overlapStart, overlapEnd); - } - - return null; - }; - - TextSpan.prototype.intersectsWithTextSpan = function (span) { - return span._start <= this.end() && span.end() >= this._start; - }; - - TextSpan.prototype.intersectsWith = function (start, length) { - var end = start + length; - return start <= this.end() && end >= this._start; - }; - - TextSpan.prototype.intersectsWithPosition = function (position) { - return position <= this.end() && position >= this._start; - }; - - TextSpan.prototype.intersection = function (span) { - var intersectStart = TypeScript.MathPrototype.max(this._start, span._start); - var intersectEnd = TypeScript.MathPrototype.min(this.end(), span.end()); - - if (intersectStart <= intersectEnd) { - return TextSpan.fromBounds(intersectStart, intersectEnd); - } - - return null; - }; - - TextSpan.fromBounds = function (start, end) { - TypeScript.Contract.requires(start >= 0); - TypeScript.Contract.requires(end - start >= 0); - return new TextSpan(start, end - start); - }; - return TextSpan; - })(); - TypeScript.TextSpan = TextSpan; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var TextChangeRange = (function () { - function TextChangeRange(span, newLength) { - if (newLength < 0) { - throw TypeScript.Errors.argumentOutOfRange("newLength"); - } - - this._span = span; - this._newLength = newLength; - } - TextChangeRange.prototype.span = function () { - return this._span; - }; - - TextChangeRange.prototype.newLength = function () { - return this._newLength; - }; - - TextChangeRange.prototype.newSpan = function () { - return new TypeScript.TextSpan(this.span().start(), this.newLength()); - }; - - TextChangeRange.prototype.isUnchanged = function () { - return this.span().isEmpty() && this.newLength() === 0; - }; - - TextChangeRange.collapseChangesFromSingleVersion = function (changes) { - var diff = 0; - var start = 1073741823 /* Max31BitInteger */; - var end = 0; - - for (var i = 0; i < changes.length; i++) { - var change = changes[i]; - diff += change.newLength() - change.span().length(); - - if (change.span().start() < start) { - start = change.span().start(); - } - - if (change.span().end() > end) { - end = change.span().end(); - } - } - - if (start > end) { - return null; - } - - var combined = TypeScript.TextSpan.fromBounds(start, end); - var newLen = combined.length() + diff; - - return new TextChangeRange(combined, newLen); - }; - - TextChangeRange.collapseChangesAcrossMultipleVersions = function (changes) { - if (changes.length === 0) { - return TextChangeRange.unchanged; - } - - if (changes.length === 1) { - return changes[0]; - } - - 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]; - - 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 = TypeScript.MathPrototype.min(oldStart1, oldStart2); - oldEndN = TypeScript.MathPrototype.max(oldEnd1, oldEnd1 + (oldEnd2 - newEnd1)); - newEndN = TypeScript.MathPrototype.max(newEnd2, newEnd2 + (newEnd1 - oldEnd2)); - } - - return new TextChangeRange(TypeScript.TextSpan.fromBounds(oldStartN, oldEndN), newEndN - oldStartN); - }; - TextChangeRange.unchanged = new TextChangeRange(new TypeScript.TextSpan(0, 0), 0); - return TextChangeRange; - })(); - TypeScript.TextChangeRange = TextChangeRange; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var CharacterInfo = (function () { - function CharacterInfo() { - } - CharacterInfo.isDecimalDigit = function (c) { - return c >= 48 /* _0 */ && c <= 57 /* _9 */; - }; - - CharacterInfo.isHexDigit = function (c) { - return CharacterInfo.isDecimalDigit(c) || (c >= 65 /* A */ && c <= 70 /* F */) || (c >= 97 /* a */ && c <= 102 /* f */); - }; - - CharacterInfo.hexValue = function (c) { - return CharacterInfo.isDecimalDigit(c) ? (c - 48 /* _0 */) : (c >= 65 /* A */ && c <= 70 /* F */) ? c - 65 /* A */ + 10 : c - 97 /* a */ + 10; - }; - - CharacterInfo.isWhitespace = function (ch) { - switch (ch) { - case 32 /* space */: - case 160 /* nonBreakingSpace */: - case 8192 /* enQuad */: - case 8193 /* emQuad */: - case 8194 /* enSpace */: - case 8195 /* emSpace */: - case 8196 /* threePerEmSpace */: - case 8197 /* fourPerEmSpace */: - case 8198 /* sixPerEmSpace */: - case 8199 /* figureSpace */: - case 8200 /* punctuationSpace */: - case 8201 /* thinSpace */: - case 8202 /* hairSpace */: - case 8203 /* zeroWidthSpace */: - case 8239 /* narrowNoBreakSpace */: - case 12288 /* ideographicSpace */: - - case 9 /* tab */: - case 11 /* verticalTab */: - case 12 /* formFeed */: - case 65279 /* byteOrderMark */: - return true; - } - - return false; - }; - - CharacterInfo.isLineTerminator = function (ch) { - switch (ch) { - case 13 /* carriageReturn */: - case 10 /* lineFeed */: - case 8233 /* paragraphSeparator */: - case 8232 /* lineSeparator */: - return true; - } - - return false; - }; - return CharacterInfo; - })(); - TypeScript.CharacterInfo = CharacterInfo; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (SyntaxConstants) { - SyntaxConstants[SyntaxConstants["TriviaNewLineMask"] = 0x00000001] = "TriviaNewLineMask"; - SyntaxConstants[SyntaxConstants["TriviaCommentMask"] = 0x00000002] = "TriviaCommentMask"; - SyntaxConstants[SyntaxConstants["TriviaFullWidthShift"] = 2] = "TriviaFullWidthShift"; - - SyntaxConstants[SyntaxConstants["NodeDataComputed"] = 0x00000001] = "NodeDataComputed"; - SyntaxConstants[SyntaxConstants["NodeIncrementallyUnusableMask"] = 0x00000002] = "NodeIncrementallyUnusableMask"; - SyntaxConstants[SyntaxConstants["NodeParsedInStrictModeMask"] = 0x00000004] = "NodeParsedInStrictModeMask"; - SyntaxConstants[SyntaxConstants["NodeFullWidthShift"] = 3] = "NodeFullWidthShift"; - })(TypeScript.SyntaxConstants || (TypeScript.SyntaxConstants = {})); - var SyntaxConstants = TypeScript.SyntaxConstants; -})(TypeScript || (TypeScript = {})); -var FormattingOptions = (function () { - function FormattingOptions(useTabs, spacesPerTab, indentSpaces, newLineCharacter) { - this.useTabs = useTabs; - this.spacesPerTab = spacesPerTab; - this.indentSpaces = indentSpaces; - this.newLineCharacter = newLineCharacter; - } - FormattingOptions.defaultOptions = new FormattingOptions(false, 4, 4, "\r\n"); - return FormattingOptions; -})(); -var TypeScript; -(function (TypeScript) { - (function (Indentation) { - function columnForEndOfToken(token, syntaxInformationMap, options) { - return columnForStartOfToken(token, syntaxInformationMap, options) + token.width(); - } - Indentation.columnForEndOfToken = columnForEndOfToken; - - function columnForStartOfToken(token, syntaxInformationMap, options) { - var firstTokenInLine = syntaxInformationMap.firstTokenInLineContainingToken(token); - var leadingTextInReverse = []; - - var current = token; - while (current !== firstTokenInLine) { - current = syntaxInformationMap.previousToken(current); - - if (current === firstTokenInLine) { - leadingTextInReverse.push(current.trailingTrivia().fullText()); - leadingTextInReverse.push(current.text()); - } else { - leadingTextInReverse.push(current.fullText()); - } - } - - collectLeadingTriviaTextToStartOfLine(firstTokenInLine, leadingTextInReverse); - - return columnForLeadingTextInReverse(leadingTextInReverse, options); - } - Indentation.columnForStartOfToken = columnForStartOfToken; - - function columnForStartOfFirstTokenInLineContainingToken(token, syntaxInformationMap, options) { - var firstTokenInLine = syntaxInformationMap.firstTokenInLineContainingToken(token); - var leadingTextInReverse = []; - - collectLeadingTriviaTextToStartOfLine(firstTokenInLine, leadingTextInReverse); - - return columnForLeadingTextInReverse(leadingTextInReverse, options); - } - Indentation.columnForStartOfFirstTokenInLineContainingToken = columnForStartOfFirstTokenInLineContainingToken; - - function collectLeadingTriviaTextToStartOfLine(firstTokenInLine, leadingTextInReverse) { - var leadingTrivia = firstTokenInLine.leadingTrivia(); - - for (var i = leadingTrivia.count() - 1; i >= 0; i--) { - var trivia = leadingTrivia.syntaxTriviaAt(i); - if (trivia.kind() === 5 /* NewLineTrivia */) { - break; - } - - if (trivia.kind() === 6 /* MultiLineCommentTrivia */) { - var lineSegments = TypeScript.Syntax.splitMultiLineCommentTriviaIntoMultipleLines(trivia); - leadingTextInReverse.push(TypeScript.ArrayUtilities.last(lineSegments)); - - if (lineSegments.length > 0) { - break; - } - } - - leadingTextInReverse.push(trivia.fullText()); - } - } - - function columnForLeadingTextInReverse(leadingTextInReverse, options) { - var column = 0; - - for (var i = leadingTextInReverse.length - 1; i >= 0; i--) { - var text = leadingTextInReverse[i]; - column = columnForPositionInStringWorker(text, text.length, column, options); - } - - return column; - } - - function columnForPositionInString(input, position, options) { - return columnForPositionInStringWorker(input, position, 0, options); - } - Indentation.columnForPositionInString = columnForPositionInString; - - function columnForPositionInStringWorker(input, position, startColumn, options) { - var column = startColumn; - var spacesPerTab = options.spacesPerTab; - - for (var j = 0; j < position; j++) { - var ch = input.charCodeAt(j); - - if (ch === 9 /* tab */) { - column += spacesPerTab - column % spacesPerTab; - } else { - column++; - } - } - - return column; - } - - function indentationString(column, options) { - var numberOfTabs = 0; - var numberOfSpaces = TypeScript.MathPrototype.max(0, column); - - if (options.useTabs) { - numberOfTabs = Math.floor(column / options.spacesPerTab); - numberOfSpaces -= numberOfTabs * options.spacesPerTab; - } - - return TypeScript.StringUtilities.repeat('\t', numberOfTabs) + TypeScript.StringUtilities.repeat(' ', numberOfSpaces); - } - Indentation.indentationString = indentationString; - - function indentationTrivia(column, options) { - return TypeScript.Syntax.whitespace(this.indentationString(column, options)); - } - Indentation.indentationTrivia = indentationTrivia; - - function firstNonWhitespacePosition(value) { - for (var i = 0; i < value.length; i++) { - var ch = value.charCodeAt(i); - if (!TypeScript.CharacterInfo.isWhitespace(ch)) { - return i; - } - } - - return value.length; - } - Indentation.firstNonWhitespacePosition = firstNonWhitespacePosition; - })(TypeScript.Indentation || (TypeScript.Indentation = {})); - var Indentation = TypeScript.Indentation; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (LanguageVersion) { - LanguageVersion[LanguageVersion["EcmaScript3"] = 0] = "EcmaScript3"; - LanguageVersion[LanguageVersion["EcmaScript5"] = 1] = "EcmaScript5"; - })(TypeScript.LanguageVersion || (TypeScript.LanguageVersion = {})); - var LanguageVersion = TypeScript.LanguageVersion; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var ParseOptions = (function () { - function ParseOptions(allowAutomaticSemicolonInsertion, allowModuleKeywordInExternalModuleReference) { - this._allowAutomaticSemicolonInsertion = allowAutomaticSemicolonInsertion; - this._allowModuleKeywordInExternalModuleReference = allowModuleKeywordInExternalModuleReference; - } - ParseOptions.prototype.toJSON = function (key) { - return { - allowAutomaticSemicolonInsertion: this._allowAutomaticSemicolonInsertion, - allowModuleKeywordInExternalModuleReference: this._allowModuleKeywordInExternalModuleReference - }; - }; - - ParseOptions.prototype.allowAutomaticSemicolonInsertion = function () { - return this._allowAutomaticSemicolonInsertion; - }; - - ParseOptions.prototype.allowModuleKeywordInExternalModuleReference = function () { - return this._allowModuleKeywordInExternalModuleReference; - }; - return ParseOptions; - })(); - TypeScript.ParseOptions = ParseOptions; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var PositionedElement = (function () { - function PositionedElement(parent, element, fullStart) { - this._parent = parent; - this._element = element; - this._fullStart = fullStart; - } - PositionedElement.create = function (parent, element, fullStart) { - if (element === null) { - return null; - } - - if (element.isNode()) { - return new PositionedNode(parent, element, fullStart); - } else if (element.isToken()) { - return new PositionedToken(parent, element, fullStart); - } else if (element.isList()) { - return new PositionedList(parent, element, fullStart); - } else if (element.isSeparatedList()) { - return new PositionedSeparatedList(parent, element, fullStart); - } else { - throw TypeScript.Errors.invalidOperation(); - } - }; - - PositionedElement.prototype.parent = function () { - return this._parent; - }; - - PositionedElement.prototype.parentElement = function () { - return this._parent && this._parent._element; - }; - - PositionedElement.prototype.element = function () { - return this._element; - }; - - PositionedElement.prototype.kind = function () { - return this.element().kind(); - }; - - PositionedElement.prototype.childIndex = function (child) { - return TypeScript.Syntax.childIndex(this.element(), child); - }; - - PositionedElement.prototype.childCount = function () { - return this.element().childCount(); - }; - - PositionedElement.prototype.childAt = function (index) { - var offset = TypeScript.Syntax.childOffsetAt(this.element(), index); - return PositionedElement.create(this, this.element().childAt(index), this.fullStart() + offset); - }; - - PositionedElement.prototype.childStart = function (child) { - var offset = TypeScript.Syntax.childOffset(this.element(), child); - return this.fullStart() + offset + child.leadingTriviaWidth(); - }; - - PositionedElement.prototype.childEnd = function (child) { - var offset = TypeScript.Syntax.childOffset(this.element(), child); - return this.fullStart() + offset + child.leadingTriviaWidth() + child.width(); - }; - - PositionedElement.prototype.childStartAt = function (index) { - var offset = TypeScript.Syntax.childOffsetAt(this.element(), index); - var child = this.element().childAt(index); - return this.fullStart() + offset + child.leadingTriviaWidth(); - }; - - PositionedElement.prototype.childEndAt = function (index) { - var offset = TypeScript.Syntax.childOffsetAt(this.element(), index); - var child = this.element().childAt(index); - return this.fullStart() + offset + child.leadingTriviaWidth() + child.width(); - }; - - PositionedElement.prototype.getPositionedChild = function (child) { - var offset = TypeScript.Syntax.childOffset(this.element(), child); - return PositionedElement.create(this, child, this.fullStart() + offset); - }; - - PositionedElement.prototype.fullStart = function () { - return this._fullStart; - }; - - PositionedElement.prototype.fullEnd = function () { - return this.fullStart() + this.element().fullWidth(); - }; - - PositionedElement.prototype.fullWidth = function () { - return this.element().fullWidth(); - }; - - PositionedElement.prototype.start = function () { - return this.fullStart() + this.element().leadingTriviaWidth(); - }; - - PositionedElement.prototype.end = function () { - return this.fullStart() + this.element().leadingTriviaWidth() + this.element().width(); - }; - - PositionedElement.prototype.root = function () { - var current = this; - while (current.parent() !== null) { - current = current.parent(); - } - - return current; - }; - - PositionedElement.prototype.containingNode = function () { - var current = this.parent(); - - while (current !== null && !current.element().isNode()) { - current = current.parent(); - } - - return current; - }; - return PositionedElement; - })(); - TypeScript.PositionedElement = PositionedElement; - - var PositionedNodeOrToken = (function (_super) { - __extends(PositionedNodeOrToken, _super); - function PositionedNodeOrToken(parent, nodeOrToken, fullStart) { - _super.call(this, parent, nodeOrToken, fullStart); - } - PositionedNodeOrToken.prototype.nodeOrToken = function () { - return this.element(); - }; - return PositionedNodeOrToken; - })(PositionedElement); - TypeScript.PositionedNodeOrToken = PositionedNodeOrToken; - - var PositionedNode = (function (_super) { - __extends(PositionedNode, _super); - function PositionedNode(parent, node, fullStart) { - _super.call(this, parent, node, fullStart); - } - PositionedNode.prototype.node = function () { - return this.element(); - }; - return PositionedNode; - })(PositionedNodeOrToken); - TypeScript.PositionedNode = PositionedNode; - - var PositionedToken = (function (_super) { - __extends(PositionedToken, _super); - function PositionedToken(parent, token, fullStart) { - _super.call(this, parent, token, fullStart); - } - PositionedToken.prototype.token = function () { - return this.element(); - }; - - PositionedToken.prototype.previousToken = function (includeSkippedTokens) { - if (typeof includeSkippedTokens === "undefined") { includeSkippedTokens = false; } - var triviaList = this.token().leadingTrivia(); - if (includeSkippedTokens && triviaList && triviaList.hasSkippedToken()) { - var currentTriviaEndPosition = this.start(); - for (var i = triviaList.count() - 1; i >= 0; i--) { - var trivia = triviaList.syntaxTriviaAt(i); - if (trivia.isSkippedToken()) { - return new PositionedSkippedToken(this, trivia.skippedToken(), currentTriviaEndPosition - trivia.fullWidth()); - } - - currentTriviaEndPosition -= trivia.fullWidth(); - } - } - - var start = this.fullStart(); - if (start === 0) { - return null; - } - - return this.root().node().findToken(start - 1, includeSkippedTokens); - }; - - PositionedToken.prototype.nextToken = function (includeSkippedTokens) { - if (typeof includeSkippedTokens === "undefined") { includeSkippedTokens = false; } - if (this.token().tokenKind === 10 /* EndOfFileToken */) { - return null; - } - - var triviaList = this.token().trailingTrivia(); - if (includeSkippedTokens && triviaList && triviaList.hasSkippedToken()) { - var fullStart = this.end(); - for (var i = 0, n = triviaList.count(); i < n; i++) { - var trivia = triviaList.syntaxTriviaAt(i); - if (trivia.isSkippedToken()) { - return new PositionedSkippedToken(this, trivia.skippedToken(), fullStart); - } - - fullStart += trivia.fullWidth(); - } - } - - return this.root().node().findToken(this.fullEnd(), includeSkippedTokens); - }; - return PositionedToken; - })(PositionedNodeOrToken); - TypeScript.PositionedToken = PositionedToken; - - var PositionedList = (function (_super) { - __extends(PositionedList, _super); - function PositionedList(parent, list, fullStart) { - _super.call(this, parent, list, fullStart); - } - PositionedList.prototype.list = function () { - return this.element(); - }; - return PositionedList; - })(PositionedElement); - TypeScript.PositionedList = PositionedList; - - var PositionedSeparatedList = (function (_super) { - __extends(PositionedSeparatedList, _super); - function PositionedSeparatedList(parent, list, fullStart) { - _super.call(this, parent, list, fullStart); - } - PositionedSeparatedList.prototype.list = function () { - return this.element(); - }; - return PositionedSeparatedList; - })(PositionedElement); - TypeScript.PositionedSeparatedList = PositionedSeparatedList; - - var PositionedSkippedToken = (function (_super) { - __extends(PositionedSkippedToken, _super); - function PositionedSkippedToken(parentToken, token, fullStart) { - _super.call(this, parentToken.parent(), token, fullStart); - this._parentToken = parentToken; - } - PositionedSkippedToken.prototype.parentToken = function () { - return this._parentToken; - }; - - PositionedSkippedToken.prototype.previousToken = function (includeSkippedTokens) { - if (typeof includeSkippedTokens === "undefined") { includeSkippedTokens = false; } - var start = this.fullStart(); - - if (includeSkippedTokens) { - var previousToken; - - if (start >= this.parentToken().end()) { - previousToken = TypeScript.Syntax.findSkippedTokenInTrailingTriviaList(this.parentToken(), start - 1); - - if (previousToken) { - return previousToken; - } - - return this.parentToken(); - } else { - previousToken = TypeScript.Syntax.findSkippedTokenInLeadingTriviaList(this.parentToken(), start - 1); - - if (previousToken) { - return previousToken; - } - } - } - - var start = this.parentToken().fullStart(); - if (start === 0) { - return null; - } - - return this.root().node().findToken(start - 1, includeSkippedTokens); - }; - - PositionedSkippedToken.prototype.nextToken = function (includeSkippedTokens) { - if (typeof includeSkippedTokens === "undefined") { includeSkippedTokens = false; } - if (this.token().tokenKind === 10 /* EndOfFileToken */) { - return null; - } - - if (includeSkippedTokens) { - var end = this.end(); - var nextToken; - - if (end <= this.parentToken().start()) { - nextToken = TypeScript.Syntax.findSkippedTokenInLeadingTriviaList(this.parentToken(), end); - - if (nextToken) { - return nextToken; - } - - return this.parentToken(); - } else { - nextToken = TypeScript.Syntax.findSkippedTokenInTrailingTriviaList(this.parentToken(), end); - - if (nextToken) { - return nextToken; - } - } - } - - return this.root().node().findToken(this.parentToken().fullEnd(), includeSkippedTokens); - }; - return PositionedSkippedToken; - })(PositionedToken); - TypeScript.PositionedSkippedToken = PositionedSkippedToken; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var Scanner = (function () { - function Scanner(fileName, text, languageVersion, window) { - if (typeof window === "undefined") { window = TypeScript.ArrayUtilities.createArray(2048, 0); } - Scanner.initializeStaticData(); - - this.slidingWindow = new TypeScript.SlidingWindow(this, window, 0, text.length()); - this.fileName = fileName; - this.text = text; - this._languageVersion = languageVersion; - } - Scanner.initializeStaticData = function () { - if (Scanner.isKeywordStartCharacter.length === 0) { - Scanner.isKeywordStartCharacter = TypeScript.ArrayUtilities.createArray(127 /* maxAsciiCharacter */, false); - Scanner.isIdentifierStartCharacter = TypeScript.ArrayUtilities.createArray(127 /* maxAsciiCharacter */, false); - Scanner.isIdentifierPartCharacter = TypeScript.ArrayUtilities.createArray(127 /* maxAsciiCharacter */, false); - Scanner.isNumericLiteralStart = TypeScript.ArrayUtilities.createArray(127 /* maxAsciiCharacter */, false); - - for (var character = 0; character < 127 /* maxAsciiCharacter */; character++) { - if (character >= 97 /* a */ && character <= 122 /* z */) { - Scanner.isIdentifierStartCharacter[character] = true; - Scanner.isIdentifierPartCharacter[character] = true; - } else if ((character >= 65 /* A */ && character <= 90 /* Z */) || character === 95 /* _ */ || character === 36 /* $ */) { - Scanner.isIdentifierStartCharacter[character] = true; - Scanner.isIdentifierPartCharacter[character] = true; - } else if (character >= 48 /* _0 */ && character <= 57 /* _9 */) { - Scanner.isIdentifierPartCharacter[character] = true; - Scanner.isNumericLiteralStart[character] = true; - } - } - - Scanner.isNumericLiteralStart[46 /* dot */] = true; - - for (var keywordKind = TypeScript.SyntaxKind.FirstKeyword; keywordKind <= TypeScript.SyntaxKind.LastKeyword; keywordKind++) { - var keyword = TypeScript.SyntaxFacts.getText(keywordKind); - Scanner.isKeywordStartCharacter[keyword.charCodeAt(0)] = true; - } - } - }; - - Scanner.prototype.languageVersion = function () { - return this._languageVersion; - }; - - Scanner.prototype.fetchMoreItems = function (argument, sourceIndex, window, destinationIndex, spaceAvailable) { - var charactersRemaining = this.text.length() - sourceIndex; - var amountToRead = TypeScript.MathPrototype.min(charactersRemaining, spaceAvailable); - this.text.copyTo(sourceIndex, window, destinationIndex, amountToRead); - return amountToRead; - }; - - Scanner.prototype.currentCharCode = function () { - return this.slidingWindow.currentItem(null); - }; - - Scanner.prototype.absoluteIndex = function () { - return this.slidingWindow.absoluteIndex(); - }; - - Scanner.prototype.setAbsoluteIndex = function (index) { - this.slidingWindow.setAbsoluteIndex(index); - }; - - Scanner.prototype.scan = function (diagnostics, allowRegularExpression) { - var diagnosticsLength = diagnostics.length; - var fullStart = this.slidingWindow.absoluteIndex(); - var leadingTriviaInfo = this.scanTriviaInfo(diagnostics, false); - - var start = this.slidingWindow.absoluteIndex(); - var kind = this.scanSyntaxToken(diagnostics, allowRegularExpression); - var end = this.slidingWindow.absoluteIndex(); - - var trailingTriviaInfo = this.scanTriviaInfo(diagnostics, true); - - var token = this.createToken(fullStart, leadingTriviaInfo, start, kind, end, trailingTriviaInfo); - - return diagnosticsLength !== diagnostics.length ? TypeScript.Syntax.realizeToken(token) : token; - }; - - Scanner.prototype.createToken = function (fullStart, leadingTriviaInfo, start, kind, end, trailingTriviaInfo) { - if (kind >= TypeScript.SyntaxKind.FirstFixedWidth) { - if (leadingTriviaInfo === 0) { - if (trailingTriviaInfo === 0) { - return new TypeScript.Syntax.FixedWidthTokenWithNoTrivia(kind); - } else { - return new TypeScript.Syntax.FixedWidthTokenWithTrailingTrivia(this.text, fullStart, kind, trailingTriviaInfo); - } - } else if (trailingTriviaInfo === 0) { - return new TypeScript.Syntax.FixedWidthTokenWithLeadingTrivia(this.text, fullStart, kind, leadingTriviaInfo); - } else { - return new TypeScript.Syntax.FixedWidthTokenWithLeadingAndTrailingTrivia(this.text, fullStart, kind, leadingTriviaInfo, trailingTriviaInfo); - } - } else { - var width = end - start; - if (leadingTriviaInfo === 0) { - if (trailingTriviaInfo === 0) { - return new TypeScript.Syntax.VariableWidthTokenWithNoTrivia(this.text, fullStart, kind, width); - } else { - return new TypeScript.Syntax.VariableWidthTokenWithTrailingTrivia(this.text, fullStart, kind, width, trailingTriviaInfo); - } - } else if (trailingTriviaInfo === 0) { - return new TypeScript.Syntax.VariableWidthTokenWithLeadingTrivia(this.text, fullStart, kind, leadingTriviaInfo, width); - } else { - return new TypeScript.Syntax.VariableWidthTokenWithLeadingAndTrailingTrivia(this.text, fullStart, kind, leadingTriviaInfo, width, trailingTriviaInfo); - } - } - }; - - Scanner.scanTrivia = function (text, start, length, isTrailing) { - var scanner = new Scanner(null, text.subText(new TypeScript.TextSpan(start, length)), 1 /* EcmaScript5 */, Scanner.triviaWindow); - return scanner.scanTrivia(isTrailing); - }; - - Scanner.prototype.scanTrivia = function (isTrailing) { - var trivia = []; - - while (true) { - if (!this.slidingWindow.isAtEndOfSource()) { - var ch = this.currentCharCode(); - - switch (ch) { - case 32 /* space */: - case 160 /* nonBreakingSpace */: - case 8192 /* enQuad */: - case 8193 /* emQuad */: - case 8194 /* enSpace */: - case 8195 /* emSpace */: - case 8196 /* threePerEmSpace */: - case 8197 /* fourPerEmSpace */: - case 8198 /* sixPerEmSpace */: - case 8199 /* figureSpace */: - case 8200 /* punctuationSpace */: - case 8201 /* thinSpace */: - case 8202 /* hairSpace */: - case 8203 /* zeroWidthSpace */: - case 8239 /* narrowNoBreakSpace */: - case 12288 /* ideographicSpace */: - - case 9 /* tab */: - case 11 /* verticalTab */: - case 12 /* formFeed */: - case 65279 /* byteOrderMark */: - trivia.push(this.scanWhitespaceTrivia()); - continue; - - case 47 /* slash */: - var ch2 = this.slidingWindow.peekItemN(1); - if (ch2 === 47 /* slash */) { - trivia.push(this.scanSingleLineCommentTrivia()); - continue; - } - - if (ch2 === 42 /* asterisk */) { - trivia.push(this.scanMultiLineCommentTrivia()); - continue; - } - - throw TypeScript.Errors.invalidOperation(); - - case 13 /* carriageReturn */: - case 10 /* lineFeed */: - case 8233 /* paragraphSeparator */: - case 8232 /* lineSeparator */: - trivia.push(this.scanLineTerminatorSequenceTrivia(ch)); - - if (!isTrailing) { - continue; - } - - break; - - default: - throw TypeScript.Errors.invalidOperation(); - } - } - - return TypeScript.Syntax.triviaList(trivia); - } - }; - - Scanner.prototype.scanTriviaInfo = function (diagnostics, isTrailing) { - var width = 0; - var hasCommentOrNewLine = 0; - - while (true) { - var ch = this.currentCharCode(); - - switch (ch) { - case 32 /* space */: - case 160 /* nonBreakingSpace */: - case 8192 /* enQuad */: - case 8193 /* emQuad */: - case 8194 /* enSpace */: - case 8195 /* emSpace */: - case 8196 /* threePerEmSpace */: - case 8197 /* fourPerEmSpace */: - case 8198 /* sixPerEmSpace */: - case 8199 /* figureSpace */: - case 8200 /* punctuationSpace */: - case 8201 /* thinSpace */: - case 8202 /* hairSpace */: - case 8203 /* zeroWidthSpace */: - case 8239 /* narrowNoBreakSpace */: - case 12288 /* ideographicSpace */: - - case 9 /* tab */: - case 11 /* verticalTab */: - case 12 /* formFeed */: - case 65279 /* byteOrderMark */: - this.slidingWindow.moveToNextItem(); - width++; - continue; - - case 47 /* slash */: - var ch2 = this.slidingWindow.peekItemN(1); - if (ch2 === 47 /* slash */) { - hasCommentOrNewLine |= 2 /* TriviaCommentMask */; - width += this.scanSingleLineCommentTriviaLength(); - continue; - } - - if (ch2 === 42 /* asterisk */) { - hasCommentOrNewLine |= 2 /* TriviaCommentMask */; - width += this.scanMultiLineCommentTriviaLength(diagnostics); - continue; - } - - break; - - case 13 /* carriageReturn */: - case 10 /* lineFeed */: - case 8233 /* paragraphSeparator */: - case 8232 /* lineSeparator */: - hasCommentOrNewLine |= 1 /* TriviaNewLineMask */; - width += this.scanLineTerminatorSequenceLength(ch); - - if (!isTrailing) { - continue; - } - - break; - } - - return (width << 2 /* TriviaFullWidthShift */) | hasCommentOrNewLine; - } - }; - - Scanner.prototype.isNewLineCharacter = function (ch) { - switch (ch) { - case 13 /* carriageReturn */: - case 10 /* lineFeed */: - case 8233 /* paragraphSeparator */: - case 8232 /* lineSeparator */: - return true; - default: - return false; - } - }; - - Scanner.prototype.scanWhitespaceTrivia = function () { - var absoluteStartIndex = this.slidingWindow.getAndPinAbsoluteIndex(); - - var width = 0; - while (true) { - var ch = this.currentCharCode(); - - switch (ch) { - case 32 /* space */: - case 160 /* nonBreakingSpace */: - case 8192 /* enQuad */: - case 8193 /* emQuad */: - case 8194 /* enSpace */: - case 8195 /* emSpace */: - case 8196 /* threePerEmSpace */: - case 8197 /* fourPerEmSpace */: - case 8198 /* sixPerEmSpace */: - case 8199 /* figureSpace */: - case 8200 /* punctuationSpace */: - case 8201 /* thinSpace */: - case 8202 /* hairSpace */: - case 8203 /* zeroWidthSpace */: - case 8239 /* narrowNoBreakSpace */: - case 12288 /* ideographicSpace */: - - case 9 /* tab */: - case 11 /* verticalTab */: - case 12 /* formFeed */: - case 65279 /* byteOrderMark */: - this.slidingWindow.moveToNextItem(); - width++; - continue; - } - - break; - } - - var text = this.substring(absoluteStartIndex, absoluteStartIndex + width, false); - this.slidingWindow.releaseAndUnpinAbsoluteIndex(absoluteStartIndex); - - return TypeScript.Syntax.whitespace(text); - }; - - Scanner.prototype.scanSingleLineCommentTrivia = function () { - var absoluteStartIndex = this.slidingWindow.getAndPinAbsoluteIndex(); - var width = this.scanSingleLineCommentTriviaLength(); - - var text = this.substring(absoluteStartIndex, absoluteStartIndex + width, false); - this.slidingWindow.releaseAndUnpinAbsoluteIndex(absoluteStartIndex); - - return TypeScript.Syntax.singleLineComment(text); - }; - - Scanner.prototype.scanSingleLineCommentTriviaLength = function () { - this.slidingWindow.moveToNextItem(); - this.slidingWindow.moveToNextItem(); - - var width = 2; - while (true) { - if (this.slidingWindow.isAtEndOfSource() || this.isNewLineCharacter(this.currentCharCode())) { - return width; - } - - this.slidingWindow.moveToNextItem(); - width++; - } - }; - - Scanner.prototype.scanMultiLineCommentTrivia = function () { - var absoluteStartIndex = this.slidingWindow.getAndPinAbsoluteIndex(); - var width = this.scanMultiLineCommentTriviaLength(null); - - var text = this.substring(absoluteStartIndex, absoluteStartIndex + width, false); - this.slidingWindow.releaseAndUnpinAbsoluteIndex(absoluteStartIndex); - - return TypeScript.Syntax.multiLineComment(text); - }; - - Scanner.prototype.scanMultiLineCommentTriviaLength = function (diagnostics) { - this.slidingWindow.moveToNextItem(); - this.slidingWindow.moveToNextItem(); - - var width = 2; - while (true) { - if (this.slidingWindow.isAtEndOfSource()) { - if (diagnostics !== null) { - diagnostics.push(new TypeScript.SyntaxDiagnostic(this.fileName, this.slidingWindow.absoluteIndex(), 0, 14 /* _StarSlash__expected */, null)); - } - - return width; - } - - var ch = this.currentCharCode(); - if (ch === 42 /* asterisk */ && this.slidingWindow.peekItemN(1) === 47 /* slash */) { - this.slidingWindow.moveToNextItem(); - this.slidingWindow.moveToNextItem(); - width += 2; - return width; - } - - this.slidingWindow.moveToNextItem(); - width++; - } - }; - - Scanner.prototype.scanLineTerminatorSequenceTrivia = function (ch) { - var absoluteStartIndex = this.slidingWindow.getAndPinAbsoluteIndex(); - var width = this.scanLineTerminatorSequenceLength(ch); - - var text = this.substring(absoluteStartIndex, absoluteStartIndex + width, false); - this.slidingWindow.releaseAndUnpinAbsoluteIndex(absoluteStartIndex); - - return TypeScript.Syntax.trivia(5 /* NewLineTrivia */, text); - }; - - Scanner.prototype.scanLineTerminatorSequenceLength = function (ch) { - this.slidingWindow.moveToNextItem(); - - if (ch === 13 /* carriageReturn */ && this.currentCharCode() === 10 /* lineFeed */) { - this.slidingWindow.moveToNextItem(); - return 2; - } else { - return 1; - } - }; - - Scanner.prototype.scanSyntaxToken = function (diagnostics, allowRegularExpression) { - if (this.slidingWindow.isAtEndOfSource()) { - return 10 /* EndOfFileToken */; - } - - var character = this.currentCharCode(); - - switch (character) { - case 34 /* doubleQuote */: - case 39 /* singleQuote */: - return this.scanStringLiteral(diagnostics); - - case 47 /* slash */: - return this.scanSlashToken(allowRegularExpression); - - case 46 /* dot */: - return this.scanDotToken(); - - case 45 /* minus */: - return this.scanMinusToken(); - - case 33 /* exclamation */: - return this.scanExclamationToken(); - - case 61 /* equals */: - return this.scanEqualsToken(); - - case 124 /* bar */: - return this.scanBarToken(); - - case 42 /* asterisk */: - return this.scanAsteriskToken(); - - case 43 /* plus */: - return this.scanPlusToken(); - - case 37 /* percent */: - return this.scanPercentToken(); - - case 38 /* ampersand */: - return this.scanAmpersandToken(); - - case 94 /* caret */: - return this.scanCaretToken(); - - case 60 /* lessThan */: - return this.scanLessThanToken(); - - case 62 /* greaterThan */: - return this.advanceAndSetTokenKind(82 /* GreaterThanToken */); - - case 44 /* comma */: - return this.advanceAndSetTokenKind(80 /* CommaToken */); - - case 58 /* colon */: - return this.advanceAndSetTokenKind(107 /* ColonToken */); - - case 59 /* semicolon */: - return this.advanceAndSetTokenKind(79 /* SemicolonToken */); - - case 126 /* tilde */: - return this.advanceAndSetTokenKind(103 /* TildeToken */); - - case 40 /* openParen */: - return this.advanceAndSetTokenKind(73 /* OpenParenToken */); - - case 41 /* closeParen */: - return this.advanceAndSetTokenKind(74 /* CloseParenToken */); - - case 123 /* openBrace */: - return this.advanceAndSetTokenKind(71 /* OpenBraceToken */); - - case 125 /* closeBrace */: - return this.advanceAndSetTokenKind(72 /* CloseBraceToken */); - - case 91 /* openBracket */: - return this.advanceAndSetTokenKind(75 /* OpenBracketToken */); - - case 93 /* closeBracket */: - return this.advanceAndSetTokenKind(76 /* CloseBracketToken */); - - case 63 /* question */: - return this.advanceAndSetTokenKind(106 /* QuestionToken */); - } - - if (Scanner.isNumericLiteralStart[character]) { - return this.scanNumericLiteral(); - } - - if (Scanner.isIdentifierStartCharacter[character]) { - var result = this.tryFastScanIdentifierOrKeyword(character); - if (result !== 0 /* None */) { - return result; - } - } - - if (this.isIdentifierStart(this.peekCharOrUnicodeEscape())) { - return this.slowScanIdentifier(diagnostics); - } - - return this.scanDefaultCharacter(character, diagnostics); - }; - - Scanner.prototype.isIdentifierStart = function (interpretedChar) { - if (Scanner.isIdentifierStartCharacter[interpretedChar]) { - return true; - } - - return interpretedChar > 127 /* maxAsciiCharacter */ && TypeScript.Unicode.isIdentifierStart(interpretedChar, this._languageVersion); - }; - - Scanner.prototype.isIdentifierPart = function (interpretedChar) { - if (Scanner.isIdentifierPartCharacter[interpretedChar]) { - return true; - } - - return interpretedChar > 127 /* maxAsciiCharacter */ && TypeScript.Unicode.isIdentifierPart(interpretedChar, this._languageVersion); - }; - - Scanner.prototype.tryFastScanIdentifierOrKeyword = function (firstCharacter) { - var startIndex = this.slidingWindow.getAndPinAbsoluteIndex(); - - while (true) { - var character = this.currentCharCode(); - if (Scanner.isIdentifierPartCharacter[character]) { - this.slidingWindow.moveToNextItem(); - } else if (character === 92 /* backslash */ || character > 127 /* maxAsciiCharacter */) { - this.slidingWindow.rewindToPinnedIndex(startIndex); - this.slidingWindow.releaseAndUnpinAbsoluteIndex(startIndex); - return 0 /* None */; - } else { - var endIndex = this.slidingWindow.absoluteIndex(); - - var kind; - if (Scanner.isKeywordStartCharacter[firstCharacter]) { - var offset = startIndex - this.slidingWindow.windowAbsoluteStartIndex; - kind = TypeScript.ScannerUtilities.identifierKind(this.slidingWindow.window, offset, endIndex - startIndex); - } else { - kind = 11 /* IdentifierName */; - } - - this.slidingWindow.releaseAndUnpinAbsoluteIndex(startIndex); - return kind; - } - } - }; - - Scanner.prototype.slowScanIdentifier = function (diagnostics) { - var startIndex = this.slidingWindow.absoluteIndex(); - - do { - this.scanCharOrUnicodeEscape(diagnostics); - } while(this.isIdentifierPart(this.peekCharOrUnicodeEscape())); - - return 11 /* IdentifierName */; - }; - - Scanner.prototype.scanNumericLiteral = function () { - if (this.isHexNumericLiteral()) { - return this.scanHexNumericLiteral(); - } else { - return this.scanDecimalNumericLiteral(); - } - }; - - Scanner.prototype.scanDecimalNumericLiteral = function () { - while (TypeScript.CharacterInfo.isDecimalDigit(this.currentCharCode())) { - this.slidingWindow.moveToNextItem(); - } - - if (this.currentCharCode() === 46 /* dot */) { - this.slidingWindow.moveToNextItem(); - } - - while (TypeScript.CharacterInfo.isDecimalDigit(this.currentCharCode())) { - this.slidingWindow.moveToNextItem(); - } - - var ch = this.currentCharCode(); - if (ch === 101 /* e */ || ch === 69 /* E */) { - this.slidingWindow.moveToNextItem(); - - ch = this.currentCharCode(); - if (ch === 45 /* minus */ || ch === 43 /* plus */) { - if (TypeScript.CharacterInfo.isDecimalDigit(this.slidingWindow.peekItemN(1))) { - this.slidingWindow.moveToNextItem(); - } - } - } - - while (TypeScript.CharacterInfo.isDecimalDigit(this.currentCharCode())) { - this.slidingWindow.moveToNextItem(); - } - - return 13 /* NumericLiteral */; - }; - - Scanner.prototype.scanHexNumericLiteral = function () { - this.slidingWindow.moveToNextItem(); - this.slidingWindow.moveToNextItem(); - - while (TypeScript.CharacterInfo.isHexDigit(this.currentCharCode())) { - this.slidingWindow.moveToNextItem(); - } - - return 13 /* NumericLiteral */; - }; - - Scanner.prototype.isHexNumericLiteral = function () { - if (this.currentCharCode() === 48 /* _0 */) { - var ch = this.slidingWindow.peekItemN(1); - - if (ch === 120 /* x */ || ch === 88 /* X */) { - ch = this.slidingWindow.peekItemN(2); - - return TypeScript.CharacterInfo.isHexDigit(ch); - } - } - - return false; - }; - - Scanner.prototype.advanceAndSetTokenKind = function (kind) { - this.slidingWindow.moveToNextItem(); - return kind; - }; - - Scanner.prototype.scanLessThanToken = function () { - this.slidingWindow.moveToNextItem(); - if (this.currentCharCode() === 61 /* equals */) { - this.slidingWindow.moveToNextItem(); - return 83 /* LessThanEqualsToken */; - } else if (this.currentCharCode() === 60 /* lessThan */) { - this.slidingWindow.moveToNextItem(); - if (this.currentCharCode() === 61 /* equals */) { - this.slidingWindow.moveToNextItem(); - return 113 /* LessThanLessThanEqualsToken */; - } else { - return 96 /* LessThanLessThanToken */; - } - } else { - return 81 /* LessThanToken */; - } - }; - - Scanner.prototype.scanBarToken = function () { - this.slidingWindow.moveToNextItem(); - if (this.currentCharCode() === 61 /* equals */) { - this.slidingWindow.moveToNextItem(); - return 117 /* BarEqualsToken */; - } else if (this.currentCharCode() === 124 /* bar */) { - this.slidingWindow.moveToNextItem(); - return 105 /* BarBarToken */; - } else { - return 100 /* BarToken */; - } - }; - - Scanner.prototype.scanCaretToken = function () { - this.slidingWindow.moveToNextItem(); - if (this.currentCharCode() === 61 /* equals */) { - this.slidingWindow.moveToNextItem(); - return 118 /* CaretEqualsToken */; - } else { - return 101 /* CaretToken */; - } - }; - - Scanner.prototype.scanAmpersandToken = function () { - this.slidingWindow.moveToNextItem(); - var character = this.currentCharCode(); - if (character === 61 /* equals */) { - this.slidingWindow.moveToNextItem(); - return 116 /* AmpersandEqualsToken */; - } else if (this.currentCharCode() === 38 /* ampersand */) { - this.slidingWindow.moveToNextItem(); - return 104 /* AmpersandAmpersandToken */; - } else { - return 99 /* AmpersandToken */; - } - }; - - Scanner.prototype.scanPercentToken = function () { - this.slidingWindow.moveToNextItem(); - if (this.currentCharCode() === 61 /* equals */) { - this.slidingWindow.moveToNextItem(); - return 112 /* PercentEqualsToken */; - } else { - return 93 /* PercentToken */; - } - }; - - Scanner.prototype.scanMinusToken = function () { - this.slidingWindow.moveToNextItem(); - var character = this.currentCharCode(); - - if (character === 61 /* equals */) { - this.slidingWindow.moveToNextItem(); - return 110 /* MinusEqualsToken */; - } else if (character === 45 /* minus */) { - this.slidingWindow.moveToNextItem(); - return 95 /* MinusMinusToken */; - } else { - return 91 /* MinusToken */; - } - }; - - Scanner.prototype.scanPlusToken = function () { - this.slidingWindow.moveToNextItem(); - var character = this.currentCharCode(); - if (character === 61 /* equals */) { - this.slidingWindow.moveToNextItem(); - return 109 /* PlusEqualsToken */; - } else if (character === 43 /* plus */) { - this.slidingWindow.moveToNextItem(); - return 94 /* PlusPlusToken */; - } else { - return 90 /* PlusToken */; - } - }; - - Scanner.prototype.scanAsteriskToken = function () { - this.slidingWindow.moveToNextItem(); - if (this.currentCharCode() === 61 /* equals */) { - this.slidingWindow.moveToNextItem(); - return 111 /* AsteriskEqualsToken */; - } else { - return 92 /* AsteriskToken */; - } - }; - - Scanner.prototype.scanEqualsToken = function () { - this.slidingWindow.moveToNextItem(); - var character = this.currentCharCode(); - if (character === 61 /* equals */) { - this.slidingWindow.moveToNextItem(); - - if (this.currentCharCode() === 61 /* equals */) { - this.slidingWindow.moveToNextItem(); - - return 88 /* EqualsEqualsEqualsToken */; - } else { - return 85 /* EqualsEqualsToken */; - } - } else if (character === 62 /* greaterThan */) { - this.slidingWindow.moveToNextItem(); - return 86 /* EqualsGreaterThanToken */; - } else { - return 108 /* EqualsToken */; - } - }; - - Scanner.prototype.isDotPrefixedNumericLiteral = function () { - if (this.currentCharCode() === 46 /* dot */) { - var ch = this.slidingWindow.peekItemN(1); - return TypeScript.CharacterInfo.isDecimalDigit(ch); - } - - return false; - }; - - Scanner.prototype.scanDotToken = function () { - if (this.isDotPrefixedNumericLiteral()) { - return this.scanNumericLiteral(); - } - - this.slidingWindow.moveToNextItem(); - if (this.currentCharCode() === 46 /* dot */ && this.slidingWindow.peekItemN(1) === 46 /* dot */) { - this.slidingWindow.moveToNextItem(); - this.slidingWindow.moveToNextItem(); - return 78 /* DotDotDotToken */; - } else { - return 77 /* DotToken */; - } - }; - - Scanner.prototype.scanSlashToken = function (allowRegularExpression) { - if (allowRegularExpression) { - var result = this.tryScanRegularExpressionToken(); - if (result !== 0 /* None */) { - return result; - } - } - - this.slidingWindow.moveToNextItem(); - if (this.currentCharCode() === 61 /* equals */) { - this.slidingWindow.moveToNextItem(); - return 120 /* SlashEqualsToken */; - } else { - return 119 /* SlashToken */; - } - }; - - Scanner.prototype.tryScanRegularExpressionToken = function () { - var startIndex = this.slidingWindow.getAndPinAbsoluteIndex(); - try { - this.slidingWindow.moveToNextItem(); - - var inEscape = false; - var inCharacterClass = false; - while (true) { - var ch = this.currentCharCode(); - if (this.isNewLineCharacter(ch) || this.slidingWindow.isAtEndOfSource()) { - this.slidingWindow.rewindToPinnedIndex(startIndex); - return 0 /* None */; - } - - this.slidingWindow.moveToNextItem(); - if (inEscape) { - inEscape = false; - continue; - } - - switch (ch) { - case 92 /* backslash */: - inEscape = true; - continue; - - case 91 /* openBracket */: - inCharacterClass = true; - continue; - - case 93 /* closeBracket */: - inCharacterClass = false; - continue; - - case 47 /* slash */: - if (inCharacterClass) { - continue; - } - - break; - - default: - continue; - } - - break; - } - - while (Scanner.isIdentifierPartCharacter[this.currentCharCode()]) { - this.slidingWindow.moveToNextItem(); - } - - return 12 /* RegularExpressionLiteral */; - } finally { - this.slidingWindow.releaseAndUnpinAbsoluteIndex(startIndex); - } - }; - - Scanner.prototype.scanExclamationToken = function () { - this.slidingWindow.moveToNextItem(); - if (this.currentCharCode() === 61 /* equals */) { - this.slidingWindow.moveToNextItem(); - - if (this.currentCharCode() === 61 /* equals */) { - this.slidingWindow.moveToNextItem(); - - return 89 /* ExclamationEqualsEqualsToken */; - } else { - return 87 /* ExclamationEqualsToken */; - } - } else { - return 102 /* ExclamationToken */; - } - }; - - Scanner.prototype.scanDefaultCharacter = function (character, diagnostics) { - var position = this.slidingWindow.absoluteIndex(); - this.slidingWindow.moveToNextItem(); - - var text = String.fromCharCode(character); - var messageText = this.getErrorMessageText(text); - diagnostics.push(new TypeScript.SyntaxDiagnostic(this.fileName, position, 1, 5 /* Unexpected_character_0 */, [messageText])); - - return 9 /* ErrorToken */; - }; - - Scanner.prototype.getErrorMessageText = function (text) { - if (text === "\\") { - return '"\\"'; - } - - return JSON.stringify(text); - }; - - Scanner.prototype.skipEscapeSequence = function (diagnostics) { - var rewindPoint = this.slidingWindow.getAndPinAbsoluteIndex(); - try { - this.slidingWindow.moveToNextItem(); - - var ch = this.currentCharCode(); - this.slidingWindow.moveToNextItem(); - switch (ch) { - case 120 /* x */: - case 117 /* u */: - this.slidingWindow.rewindToPinnedIndex(rewindPoint); - var value = this.scanUnicodeOrHexEscape(diagnostics); - return; - - case 13 /* carriageReturn */: - if (this.currentCharCode() === 10 /* lineFeed */) { - this.slidingWindow.moveToNextItem(); - } - return; - - default: - return; - } - } finally { - this.slidingWindow.releaseAndUnpinAbsoluteIndex(rewindPoint); - } - }; - - Scanner.prototype.scanStringLiteral = function (diagnostics) { - var quoteCharacter = this.currentCharCode(); - - this.slidingWindow.moveToNextItem(); - - while (true) { - var ch = this.currentCharCode(); - if (ch === 92 /* backslash */) { - this.skipEscapeSequence(diagnostics); - } else if (ch === quoteCharacter) { - this.slidingWindow.moveToNextItem(); - break; - } else if (this.isNewLineCharacter(ch) || this.slidingWindow.isAtEndOfSource()) { - diagnostics.push(new TypeScript.SyntaxDiagnostic(this.fileName, this.slidingWindow.absoluteIndex(), 1, 6 /* Missing_closing_quote_character */, null)); - break; - } else { - this.slidingWindow.moveToNextItem(); - } - } - - return 14 /* StringLiteral */; - }; - - Scanner.prototype.isUnicodeOrHexEscape = function (character) { - return this.isUnicodeEscape(character) || this.isHexEscape(character); - }; - - Scanner.prototype.isUnicodeEscape = function (character) { - if (character === 92 /* backslash */) { - var ch2 = this.slidingWindow.peekItemN(1); - if (ch2 === 117 /* u */) { - return true; - } - } - - return false; - }; - - Scanner.prototype.isHexEscape = function (character) { - if (character === 92 /* backslash */) { - var ch2 = this.slidingWindow.peekItemN(1); - if (ch2 === 120 /* x */) { - return true; - } - } - - return false; - }; - - Scanner.prototype.peekCharOrUnicodeOrHexEscape = function () { - var character = this.currentCharCode(); - if (this.isUnicodeOrHexEscape(character)) { - return this.peekUnicodeOrHexEscape(); - } else { - return character; - } - }; - - Scanner.prototype.peekCharOrUnicodeEscape = function () { - var character = this.currentCharCode(); - if (this.isUnicodeEscape(character)) { - return this.peekUnicodeOrHexEscape(); - } else { - return character; - } - }; - - Scanner.prototype.peekUnicodeOrHexEscape = function () { - var startIndex = this.slidingWindow.getAndPinAbsoluteIndex(); - - var ch = this.scanUnicodeOrHexEscape(null); - - this.slidingWindow.rewindToPinnedIndex(startIndex); - this.slidingWindow.releaseAndUnpinAbsoluteIndex(startIndex); - - return ch; - }; - - Scanner.prototype.scanCharOrUnicodeEscape = function (errors) { - var ch = this.currentCharCode(); - if (ch === 92 /* backslash */) { - var ch2 = this.slidingWindow.peekItemN(1); - if (ch2 === 117 /* u */) { - return this.scanUnicodeOrHexEscape(errors); - } - } - - this.slidingWindow.moveToNextItem(); - return ch; - }; - - Scanner.prototype.scanCharOrUnicodeOrHexEscape = function (errors) { - var ch = this.currentCharCode(); - if (ch === 92 /* backslash */) { - var ch2 = this.slidingWindow.peekItemN(1); - if (ch2 === 117 /* u */ || ch2 === 120 /* x */) { - return this.scanUnicodeOrHexEscape(errors); - } - } - - this.slidingWindow.moveToNextItem(); - return ch; - }; - - Scanner.prototype.scanUnicodeOrHexEscape = function (errors) { - var start = this.slidingWindow.absoluteIndex(); - var character = this.currentCharCode(); - - this.slidingWindow.moveToNextItem(); - - character = this.currentCharCode(); - - var intChar = 0; - this.slidingWindow.moveToNextItem(); - - var count = character === 117 /* u */ ? 4 : 2; - - for (var i = 0; i < count; i++) { - var ch2 = this.currentCharCode(); - if (!TypeScript.CharacterInfo.isHexDigit(ch2)) { - if (errors !== null) { - var end = this.slidingWindow.absoluteIndex(); - var info = this.createIllegalEscapeDiagnostic(start, end); - errors.push(info); - } - - break; - } - - intChar = (intChar << 4) + TypeScript.CharacterInfo.hexValue(ch2); - this.slidingWindow.moveToNextItem(); - } - - return intChar; - }; - - Scanner.prototype.substring = function (start, end, intern) { - var length = end - start; - var offset = start - this.slidingWindow.windowAbsoluteStartIndex; - - if (intern) { - return TypeScript.Collections.DefaultStringTable.addCharArray(this.slidingWindow.window, offset, length); - } else { - return TypeScript.StringUtilities.fromCharCodeArray(this.slidingWindow.window.slice(offset, offset + length)); - } - }; - - Scanner.prototype.createIllegalEscapeDiagnostic = function (start, end) { - return new TypeScript.SyntaxDiagnostic(this.fileName, start, end - start, 4 /* Unrecognized_escape_sequence */, null); - }; - - Scanner.isValidIdentifier = function (text, languageVersion) { - var scanner = new Scanner(null, text, TypeScript.LanguageVersion, Scanner.triviaWindow); - var errors = []; - var token = scanner.scan(errors, false); - - return errors.length === 0 && TypeScript.SyntaxFacts.isIdentifierNameOrAnyKeyword(token) && token.width() === text.length(); - }; - Scanner.isKeywordStartCharacter = []; - Scanner.isIdentifierStartCharacter = []; - Scanner.isIdentifierPartCharacter = []; - Scanner.isNumericLiteralStart = []; - - Scanner.triviaWindow = TypeScript.ArrayUtilities.createArray(2048, 0); - return Scanner; - })(); - TypeScript.Scanner = Scanner; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var ScannerUtilities = (function () { - function ScannerUtilities() { - } - ScannerUtilities.identifierKind = function (array, startIndex, length) { - switch (length) { - case 2: - switch (array[startIndex]) { - case 100 /* d */: - return (array[startIndex + 1] === 111 /* o */) ? 22 /* DoKeyword */ : 11 /* IdentifierName */; - case 105 /* i */: - switch (array[startIndex + 1]) { - case 102 /* f */: - return 28 /* IfKeyword */; - case 110 /* n */: - return 29 /* InKeyword */; - default: - return 11 /* IdentifierName */; - } - - default: - return 11 /* IdentifierName */; - } - - case 3: - switch (array[startIndex]) { - case 102 /* f */: - return (array[startIndex + 1] === 111 /* o */ && array[startIndex + 2] === 114 /* r */) ? 26 /* ForKeyword */ : 11 /* IdentifierName */; - case 110 /* n */: - return (array[startIndex + 1] === 101 /* e */ && array[startIndex + 2] === 119 /* w */) ? 31 /* NewKeyword */ : 11 /* IdentifierName */; - case 116 /* t */: - return (array[startIndex + 1] === 114 /* r */ && array[startIndex + 2] === 121 /* y */) ? 38 /* TryKeyword */ : 11 /* IdentifierName */; - case 118 /* v */: - return (array[startIndex + 1] === 97 /* a */ && array[startIndex + 2] === 114 /* r */) ? 40 /* VarKeyword */ : 11 /* IdentifierName */; - case 108 /* l */: - return (array[startIndex + 1] === 101 /* e */ && array[startIndex + 2] === 116 /* t */) ? 53 /* LetKeyword */ : 11 /* IdentifierName */; - case 97 /* a */: - return (array[startIndex + 1] === 110 /* n */ && array[startIndex + 2] === 121 /* y */) ? 60 /* AnyKeyword */ : 11 /* IdentifierName */; - case 103 /* g */: - return (array[startIndex + 1] === 101 /* e */ && array[startIndex + 2] === 116 /* t */) ? 65 /* GetKeyword */ : 11 /* IdentifierName */; - case 115 /* s */: - return (array[startIndex + 1] === 101 /* e */ && array[startIndex + 2] === 116 /* t */) ? 69 /* SetKeyword */ : 11 /* IdentifierName */; - default: - return 11 /* IdentifierName */; - } - - case 4: - switch (array[startIndex]) { - case 99 /* c */: - return (array[startIndex + 1] === 97 /* a */ && array[startIndex + 2] === 115 /* s */ && array[startIndex + 3] === 101 /* e */) ? 16 /* CaseKeyword */ : 11 /* IdentifierName */; - case 101 /* e */: - switch (array[startIndex + 1]) { - case 108 /* l */: - return (array[startIndex + 2] === 115 /* s */ && array[startIndex + 3] === 101 /* e */) ? 23 /* ElseKeyword */ : 11 /* IdentifierName */; - case 110 /* n */: - return (array[startIndex + 2] === 117 /* u */ && array[startIndex + 3] === 109 /* m */) ? 46 /* EnumKeyword */ : 11 /* IdentifierName */; - default: - return 11 /* IdentifierName */; - } - - case 110 /* n */: - return (array[startIndex + 1] === 117 /* u */ && array[startIndex + 2] === 108 /* l */ && array[startIndex + 3] === 108 /* l */) ? 32 /* NullKeyword */ : 11 /* IdentifierName */; - case 116 /* t */: - switch (array[startIndex + 1]) { - case 104 /* h */: - return (array[startIndex + 2] === 105 /* i */ && array[startIndex + 3] === 115 /* s */) ? 35 /* ThisKeyword */ : 11 /* IdentifierName */; - case 114 /* r */: - return (array[startIndex + 2] === 117 /* u */ && array[startIndex + 3] === 101 /* e */) ? 37 /* TrueKeyword */ : 11 /* IdentifierName */; - default: - return 11 /* IdentifierName */; - } - - case 118 /* v */: - return (array[startIndex + 1] === 111 /* o */ && array[startIndex + 2] === 105 /* i */ && array[startIndex + 3] === 100 /* d */) ? 41 /* VoidKeyword */ : 11 /* IdentifierName */; - case 119 /* w */: - return (array[startIndex + 1] === 105 /* i */ && array[startIndex + 2] === 116 /* t */ && array[startIndex + 3] === 104 /* h */) ? 43 /* WithKeyword */ : 11 /* IdentifierName */; - case 98 /* b */: - return (array[startIndex + 1] === 111 /* o */ && array[startIndex + 2] === 111 /* o */ && array[startIndex + 3] === 108 /* l */) ? 62 /* BoolKeyword */ : 11 /* IdentifierName */; - default: - return 11 /* IdentifierName */; - } - - case 5: - switch (array[startIndex]) { - case 98 /* b */: - return (array[startIndex + 1] === 114 /* r */ && array[startIndex + 2] === 101 /* e */ && array[startIndex + 3] === 97 /* a */ && array[startIndex + 4] === 107 /* k */) ? 15 /* BreakKeyword */ : 11 /* IdentifierName */; - case 99 /* c */: - switch (array[startIndex + 1]) { - case 97 /* a */: - return (array[startIndex + 2] === 116 /* t */ && array[startIndex + 3] === 99 /* c */ && array[startIndex + 4] === 104 /* h */) ? 17 /* CatchKeyword */ : 11 /* IdentifierName */; - case 108 /* l */: - return (array[startIndex + 2] === 97 /* a */ && array[startIndex + 3] === 115 /* s */ && array[startIndex + 4] === 115 /* s */) ? 44 /* ClassKeyword */ : 11 /* IdentifierName */; - case 111 /* o */: - return (array[startIndex + 2] === 110 /* n */ && array[startIndex + 3] === 115 /* s */ && array[startIndex + 4] === 116 /* t */) ? 45 /* ConstKeyword */ : 11 /* IdentifierName */; - default: - return 11 /* IdentifierName */; - } - - case 102 /* f */: - return (array[startIndex + 1] === 97 /* a */ && array[startIndex + 2] === 108 /* l */ && array[startIndex + 3] === 115 /* s */ && array[startIndex + 4] === 101 /* e */) ? 24 /* FalseKeyword */ : 11 /* IdentifierName */; - case 116 /* t */: - return (array[startIndex + 1] === 104 /* h */ && array[startIndex + 2] === 114 /* r */ && array[startIndex + 3] === 111 /* o */ && array[startIndex + 4] === 119 /* w */) ? 36 /* ThrowKeyword */ : 11 /* IdentifierName */; - case 119 /* w */: - return (array[startIndex + 1] === 104 /* h */ && array[startIndex + 2] === 105 /* i */ && array[startIndex + 3] === 108 /* l */ && array[startIndex + 4] === 101 /* e */) ? 42 /* WhileKeyword */ : 11 /* IdentifierName */; - case 115 /* s */: - return (array[startIndex + 1] === 117 /* u */ && array[startIndex + 2] === 112 /* p */ && array[startIndex + 3] === 101 /* e */ && array[startIndex + 4] === 114 /* r */) ? 50 /* SuperKeyword */ : 11 /* IdentifierName */; - case 121 /* y */: - return (array[startIndex + 1] === 105 /* i */ && array[startIndex + 2] === 101 /* e */ && array[startIndex + 3] === 108 /* l */ && array[startIndex + 4] === 100 /* d */) ? 59 /* YieldKeyword */ : 11 /* IdentifierName */; - default: - return 11 /* IdentifierName */; - } - - case 6: - switch (array[startIndex]) { - case 100 /* d */: - return (array[startIndex + 1] === 101 /* e */ && array[startIndex + 2] === 108 /* l */ && array[startIndex + 3] === 101 /* e */ && array[startIndex + 4] === 116 /* t */ && array[startIndex + 5] === 101 /* e */) ? 21 /* DeleteKeyword */ : 11 /* IdentifierName */; - case 114 /* r */: - return (array[startIndex + 1] === 101 /* e */ && array[startIndex + 2] === 116 /* t */ && array[startIndex + 3] === 117 /* u */ && array[startIndex + 4] === 114 /* r */ && array[startIndex + 5] === 110 /* n */) ? 33 /* ReturnKeyword */ : 11 /* IdentifierName */; - case 115 /* s */: - switch (array[startIndex + 1]) { - case 119 /* w */: - return (array[startIndex + 2] === 105 /* i */ && array[startIndex + 3] === 116 /* t */ && array[startIndex + 4] === 99 /* c */ && array[startIndex + 5] === 104 /* h */) ? 34 /* SwitchKeyword */ : 11 /* IdentifierName */; - case 116 /* t */: - switch (array[startIndex + 2]) { - case 97 /* a */: - return (array[startIndex + 3] === 116 /* t */ && array[startIndex + 4] === 105 /* i */ && array[startIndex + 5] === 99 /* c */) ? 58 /* StaticKeyword */ : 11 /* IdentifierName */; - case 114 /* r */: - return (array[startIndex + 3] === 105 /* i */ && array[startIndex + 4] === 110 /* n */ && array[startIndex + 5] === 103 /* g */) ? 70 /* StringKeyword */ : 11 /* IdentifierName */; - default: - return 11 /* IdentifierName */; - } - - default: - return 11 /* IdentifierName */; - } - - case 116 /* t */: - return (array[startIndex + 1] === 121 /* y */ && array[startIndex + 2] === 112 /* p */ && array[startIndex + 3] === 101 /* e */ && array[startIndex + 4] === 111 /* o */ && array[startIndex + 5] === 102 /* f */) ? 39 /* TypeOfKeyword */ : 11 /* IdentifierName */; - case 101 /* e */: - return (array[startIndex + 1] === 120 /* x */ && array[startIndex + 2] === 112 /* p */ && array[startIndex + 3] === 111 /* o */ && array[startIndex + 4] === 114 /* r */ && array[startIndex + 5] === 116 /* t */) ? 47 /* ExportKeyword */ : 11 /* IdentifierName */; - case 105 /* i */: - return (array[startIndex + 1] === 109 /* m */ && array[startIndex + 2] === 112 /* p */ && array[startIndex + 3] === 111 /* o */ && array[startIndex + 4] === 114 /* r */ && array[startIndex + 5] === 116 /* t */) ? 49 /* ImportKeyword */ : 11 /* IdentifierName */; - case 112 /* p */: - return (array[startIndex + 1] === 117 /* u */ && array[startIndex + 2] === 98 /* b */ && array[startIndex + 3] === 108 /* l */ && array[startIndex + 4] === 105 /* i */ && array[startIndex + 5] === 99 /* c */) ? 57 /* PublicKeyword */ : 11 /* IdentifierName */; - case 109 /* m */: - return (array[startIndex + 1] === 111 /* o */ && array[startIndex + 2] === 100 /* d */ && array[startIndex + 3] === 117 /* u */ && array[startIndex + 4] === 108 /* l */ && array[startIndex + 5] === 101 /* e */) ? 66 /* ModuleKeyword */ : 11 /* IdentifierName */; - case 110 /* n */: - return (array[startIndex + 1] === 117 /* u */ && array[startIndex + 2] === 109 /* m */ && array[startIndex + 3] === 98 /* b */ && array[startIndex + 4] === 101 /* e */ && array[startIndex + 5] === 114 /* r */) ? 68 /* NumberKeyword */ : 11 /* IdentifierName */; - default: - return 11 /* IdentifierName */; - } - - case 7: - switch (array[startIndex]) { - case 100 /* d */: - switch (array[startIndex + 1]) { - case 101 /* e */: - switch (array[startIndex + 2]) { - case 102 /* f */: - return (array[startIndex + 3] === 97 /* a */ && array[startIndex + 4] === 117 /* u */ && array[startIndex + 5] === 108 /* l */ && array[startIndex + 6] === 116 /* t */) ? 20 /* DefaultKeyword */ : 11 /* IdentifierName */; - case 99 /* c */: - return (array[startIndex + 3] === 108 /* l */ && array[startIndex + 4] === 97 /* a */ && array[startIndex + 5] === 114 /* r */ && array[startIndex + 6] === 101 /* e */) ? 64 /* DeclareKeyword */ : 11 /* IdentifierName */; - default: - return 11 /* IdentifierName */; - } - - default: - return 11 /* IdentifierName */; - } - - case 102 /* f */: - return (array[startIndex + 1] === 105 /* i */ && array[startIndex + 2] === 110 /* n */ && array[startIndex + 3] === 97 /* a */ && array[startIndex + 4] === 108 /* l */ && array[startIndex + 5] === 108 /* l */ && array[startIndex + 6] === 121 /* y */) ? 25 /* FinallyKeyword */ : 11 /* IdentifierName */; - case 101 /* e */: - return (array[startIndex + 1] === 120 /* x */ && array[startIndex + 2] === 116 /* t */ && array[startIndex + 3] === 101 /* e */ && array[startIndex + 4] === 110 /* n */ && array[startIndex + 5] === 100 /* d */ && array[startIndex + 6] === 115 /* s */) ? 48 /* ExtendsKeyword */ : 11 /* IdentifierName */; - case 112 /* p */: - switch (array[startIndex + 1]) { - case 97 /* a */: - return (array[startIndex + 2] === 99 /* c */ && array[startIndex + 3] === 107 /* k */ && array[startIndex + 4] === 97 /* a */ && array[startIndex + 5] === 103 /* g */ && array[startIndex + 6] === 101 /* e */) ? 54 /* PackageKeyword */ : 11 /* IdentifierName */; - case 114 /* r */: - return (array[startIndex + 2] === 105 /* i */ && array[startIndex + 3] === 118 /* v */ && array[startIndex + 4] === 97 /* a */ && array[startIndex + 5] === 116 /* t */ && array[startIndex + 6] === 101 /* e */) ? 55 /* PrivateKeyword */ : 11 /* IdentifierName */; - default: - return 11 /* IdentifierName */; - } - - case 98 /* b */: - return (array[startIndex + 1] === 111 /* o */ && array[startIndex + 2] === 111 /* o */ && array[startIndex + 3] === 108 /* l */ && array[startIndex + 4] === 101 /* e */ && array[startIndex + 5] === 97 /* a */ && array[startIndex + 6] === 110 /* n */) ? 61 /* BooleanKeyword */ : 11 /* IdentifierName */; - case 114 /* r */: - return (array[startIndex + 1] === 101 /* e */ && array[startIndex + 2] === 113 /* q */ && array[startIndex + 3] === 117 /* u */ && array[startIndex + 4] === 105 /* i */ && array[startIndex + 5] === 114 /* r */ && array[startIndex + 6] === 101 /* e */) ? 67 /* RequireKeyword */ : 11 /* IdentifierName */; - default: - return 11 /* IdentifierName */; - } - - case 8: - switch (array[startIndex]) { - case 99 /* c */: - return (array[startIndex + 1] === 111 /* o */ && array[startIndex + 2] === 110 /* n */ && array[startIndex + 3] === 116 /* t */ && array[startIndex + 4] === 105 /* i */ && array[startIndex + 5] === 110 /* n */ && array[startIndex + 6] === 117 /* u */ && array[startIndex + 7] === 101 /* e */) ? 18 /* ContinueKeyword */ : 11 /* IdentifierName */; - case 100 /* d */: - return (array[startIndex + 1] === 101 /* e */ && array[startIndex + 2] === 98 /* b */ && array[startIndex + 3] === 117 /* u */ && array[startIndex + 4] === 103 /* g */ && array[startIndex + 5] === 103 /* g */ && array[startIndex + 6] === 101 /* e */ && array[startIndex + 7] === 114 /* r */) ? 19 /* DebuggerKeyword */ : 11 /* IdentifierName */; - case 102 /* f */: - return (array[startIndex + 1] === 117 /* u */ && array[startIndex + 2] === 110 /* n */ && array[startIndex + 3] === 99 /* c */ && array[startIndex + 4] === 116 /* t */ && array[startIndex + 5] === 105 /* i */ && array[startIndex + 6] === 111 /* o */ && array[startIndex + 7] === 110 /* n */) ? 27 /* FunctionKeyword */ : 11 /* IdentifierName */; - default: - return 11 /* IdentifierName */; - } - - case 9: - switch (array[startIndex]) { - case 105 /* i */: - return (array[startIndex + 1] === 110 /* n */ && array[startIndex + 2] === 116 /* t */ && array[startIndex + 3] === 101 /* e */ && array[startIndex + 4] === 114 /* r */ && array[startIndex + 5] === 102 /* f */ && array[startIndex + 6] === 97 /* a */ && array[startIndex + 7] === 99 /* c */ && array[startIndex + 8] === 101 /* e */) ? 52 /* InterfaceKeyword */ : 11 /* IdentifierName */; - case 112 /* p */: - return (array[startIndex + 1] === 114 /* r */ && array[startIndex + 2] === 111 /* o */ && array[startIndex + 3] === 116 /* t */ && array[startIndex + 4] === 101 /* e */ && array[startIndex + 5] === 99 /* c */ && array[startIndex + 6] === 116 /* t */ && array[startIndex + 7] === 101 /* e */ && array[startIndex + 8] === 100 /* d */) ? 56 /* ProtectedKeyword */ : 11 /* IdentifierName */; - default: - return 11 /* IdentifierName */; - } - - case 10: - switch (array[startIndex]) { - case 105 /* i */: - switch (array[startIndex + 1]) { - case 110 /* n */: - return (array[startIndex + 2] === 115 /* s */ && array[startIndex + 3] === 116 /* t */ && array[startIndex + 4] === 97 /* a */ && array[startIndex + 5] === 110 /* n */ && array[startIndex + 6] === 99 /* c */ && array[startIndex + 7] === 101 /* e */ && array[startIndex + 8] === 111 /* o */ && array[startIndex + 9] === 102 /* f */) ? 30 /* InstanceOfKeyword */ : 11 /* IdentifierName */; - case 109 /* m */: - return (array[startIndex + 2] === 112 /* p */ && array[startIndex + 3] === 108 /* l */ && array[startIndex + 4] === 101 /* e */ && array[startIndex + 5] === 109 /* m */ && array[startIndex + 6] === 101 /* e */ && array[startIndex + 7] === 110 /* n */ && array[startIndex + 8] === 116 /* t */ && array[startIndex + 9] === 115 /* s */) ? 51 /* ImplementsKeyword */ : 11 /* IdentifierName */; - default: - return 11 /* IdentifierName */; - } - - default: - return 11 /* IdentifierName */; - } - - case 11: - return (array[startIndex] === 99 /* c */ && array[startIndex + 1] === 111 /* o */ && array[startIndex + 2] === 110 /* n */ && array[startIndex + 3] === 115 /* s */ && array[startIndex + 4] === 116 /* t */ && array[startIndex + 5] === 114 /* r */ && array[startIndex + 6] === 117 /* u */ && array[startIndex + 7] === 99 /* c */ && array[startIndex + 8] === 116 /* t */ && array[startIndex + 9] === 111 /* o */ && array[startIndex + 10] === 114 /* r */) ? 63 /* ConstructorKeyword */ : 11 /* IdentifierName */; - default: - return 11 /* IdentifierName */; - } - }; - return ScannerUtilities; - })(); - TypeScript.ScannerUtilities = ScannerUtilities; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (Syntax) { - var EmptySeparatedSyntaxList = (function () { - function EmptySeparatedSyntaxList() { - } - EmptySeparatedSyntaxList.prototype.kind = function () { - return 2 /* SeparatedList */; - }; - - EmptySeparatedSyntaxList.prototype.isNode = function () { - return false; - }; - - EmptySeparatedSyntaxList.prototype.isToken = function () { - return false; - }; - - EmptySeparatedSyntaxList.prototype.isList = function () { - return false; - }; - - EmptySeparatedSyntaxList.prototype.isSeparatedList = function () { - return true; - }; - - EmptySeparatedSyntaxList.prototype.toJSON = function (key) { - return []; - }; - - EmptySeparatedSyntaxList.prototype.childCount = function () { - return 0; - }; - - EmptySeparatedSyntaxList.prototype.nonSeparatorCount = function () { - return 0; - }; - - EmptySeparatedSyntaxList.prototype.separatorCount = function () { - return 0; - }; - - EmptySeparatedSyntaxList.prototype.toArray = function () { - return []; - }; - - EmptySeparatedSyntaxList.prototype.toNonSeparatorArray = function () { - return []; - }; - - EmptySeparatedSyntaxList.prototype.childAt = function (index) { - throw TypeScript.Errors.argumentOutOfRange("index"); - }; - - EmptySeparatedSyntaxList.prototype.nonSeparatorAt = function (index) { - throw TypeScript.Errors.argumentOutOfRange("index"); - }; - - EmptySeparatedSyntaxList.prototype.separatorAt = function (index) { - throw TypeScript.Errors.argumentOutOfRange("index"); - }; - - EmptySeparatedSyntaxList.prototype.collectTextElements = function (elements) { - }; - - EmptySeparatedSyntaxList.prototype.firstToken = function () { - return null; - }; - - EmptySeparatedSyntaxList.prototype.lastToken = function () { - return null; - }; - - EmptySeparatedSyntaxList.prototype.fullWidth = function () { - return 0; - }; - - EmptySeparatedSyntaxList.prototype.fullText = function () { - return ""; - }; - - EmptySeparatedSyntaxList.prototype.width = function () { - return 0; - }; - - EmptySeparatedSyntaxList.prototype.isTypeScriptSpecific = function () { - return false; - }; - - EmptySeparatedSyntaxList.prototype.isIncrementallyUnusable = function () { - return false; - }; - - EmptySeparatedSyntaxList.prototype.findTokenInternal = function (parent, position, fullStart) { - throw TypeScript.Errors.invalidOperation(); - }; - - EmptySeparatedSyntaxList.prototype.insertChildrenInto = function (array, index) { - }; - - EmptySeparatedSyntaxList.prototype.leadingTrivia = function () { - return Syntax.emptyTriviaList; - }; - - EmptySeparatedSyntaxList.prototype.trailingTrivia = function () { - return Syntax.emptyTriviaList; - }; - - EmptySeparatedSyntaxList.prototype.leadingTriviaWidth = function () { - return 0; - }; - - EmptySeparatedSyntaxList.prototype.trailingTriviaWidth = function () { - return 0; - }; - return EmptySeparatedSyntaxList; - })(); - - Syntax.emptySeparatedList = new EmptySeparatedSyntaxList(); - - var SingletonSeparatedSyntaxList = (function () { - function SingletonSeparatedSyntaxList(item) { - this.item = item; - } - SingletonSeparatedSyntaxList.prototype.toJSON = function (key) { - return [this.item]; - }; - - SingletonSeparatedSyntaxList.prototype.kind = function () { - return 2 /* SeparatedList */; - }; - - SingletonSeparatedSyntaxList.prototype.isNode = function () { - return false; - }; - SingletonSeparatedSyntaxList.prototype.isToken = function () { - return false; - }; - SingletonSeparatedSyntaxList.prototype.isList = function () { - return false; - }; - SingletonSeparatedSyntaxList.prototype.isSeparatedList = function () { - return true; - }; - - SingletonSeparatedSyntaxList.prototype.childCount = function () { - return 1; - }; - SingletonSeparatedSyntaxList.prototype.nonSeparatorCount = function () { - return 1; - }; - SingletonSeparatedSyntaxList.prototype.separatorCount = function () { - return 0; - }; - - SingletonSeparatedSyntaxList.prototype.toArray = function () { - return [this.item]; - }; - SingletonSeparatedSyntaxList.prototype.toNonSeparatorArray = function () { - return [this.item]; - }; - - SingletonSeparatedSyntaxList.prototype.childAt = function (index) { - if (index !== 0) { - throw TypeScript.Errors.argumentOutOfRange("index"); - } - - return this.item; - }; - - SingletonSeparatedSyntaxList.prototype.nonSeparatorAt = function (index) { - if (index !== 0) { - throw TypeScript.Errors.argumentOutOfRange("index"); - } - - return this.item; - }; - - SingletonSeparatedSyntaxList.prototype.separatorAt = function (index) { - throw TypeScript.Errors.argumentOutOfRange("index"); - }; - - SingletonSeparatedSyntaxList.prototype.collectTextElements = function (elements) { - this.item.collectTextElements(elements); - }; - - SingletonSeparatedSyntaxList.prototype.firstToken = function () { - return this.item.firstToken(); - }; - - SingletonSeparatedSyntaxList.prototype.lastToken = function () { - return this.item.lastToken(); - }; - - SingletonSeparatedSyntaxList.prototype.fullWidth = function () { - return this.item.fullWidth(); - }; - - SingletonSeparatedSyntaxList.prototype.width = function () { - return this.item.width(); - }; - - SingletonSeparatedSyntaxList.prototype.fullText = function () { - return this.item.fullText(); - }; - - SingletonSeparatedSyntaxList.prototype.leadingTrivia = function () { - return this.item.leadingTrivia(); - }; - - SingletonSeparatedSyntaxList.prototype.trailingTrivia = function () { - return this.item.trailingTrivia(); - }; - - SingletonSeparatedSyntaxList.prototype.leadingTriviaWidth = function () { - return this.item.leadingTriviaWidth(); - }; - - SingletonSeparatedSyntaxList.prototype.trailingTriviaWidth = function () { - return this.item.trailingTriviaWidth(); - }; - - SingletonSeparatedSyntaxList.prototype.isTypeScriptSpecific = function () { - return this.item.isTypeScriptSpecific(); - }; - - SingletonSeparatedSyntaxList.prototype.isIncrementallyUnusable = function () { - return this.item.isIncrementallyUnusable(); - }; - - SingletonSeparatedSyntaxList.prototype.findTokenInternal = function (parent, position, fullStart) { - return (this.item).findTokenInternal(new TypeScript.PositionedSeparatedList(parent, this, fullStart), position, fullStart); - }; - - SingletonSeparatedSyntaxList.prototype.insertChildrenInto = function (array, index) { - array.splice(index, 0, this.item); - }; - return SingletonSeparatedSyntaxList; - })(); - - var NormalSeparatedSyntaxList = (function () { - function NormalSeparatedSyntaxList(elements) { - this._data = 0; - this.elements = elements; - } - NormalSeparatedSyntaxList.prototype.kind = function () { - return 2 /* SeparatedList */; - }; - - NormalSeparatedSyntaxList.prototype.isToken = function () { - return false; - }; - NormalSeparatedSyntaxList.prototype.isNode = function () { - return false; - }; - NormalSeparatedSyntaxList.prototype.isList = function () { - return false; - }; - NormalSeparatedSyntaxList.prototype.isSeparatedList = function () { - return true; - }; - NormalSeparatedSyntaxList.prototype.toJSON = function (key) { - return this.elements; - }; - - NormalSeparatedSyntaxList.prototype.childCount = function () { - return this.elements.length; - }; - NormalSeparatedSyntaxList.prototype.nonSeparatorCount = function () { - return TypeScript.IntegerUtilities.integerDivide(this.elements.length + 1, 2); - }; - NormalSeparatedSyntaxList.prototype.separatorCount = function () { - return TypeScript.IntegerUtilities.integerDivide(this.elements.length, 2); - }; - - NormalSeparatedSyntaxList.prototype.toArray = function () { - return this.elements.slice(0); - }; - - NormalSeparatedSyntaxList.prototype.toNonSeparatorArray = function () { - var result = []; - for (var i = 0, n = this.nonSeparatorCount(); i < n; i++) { - result.push(this.nonSeparatorAt(i)); - } - - return result; - }; - - NormalSeparatedSyntaxList.prototype.childAt = function (index) { - if (index < 0 || index >= this.elements.length) { - throw TypeScript.Errors.argumentOutOfRange("index"); - } - - return this.elements[index]; - }; - - NormalSeparatedSyntaxList.prototype.nonSeparatorAt = function (index) { - var value = index * 2; - if (value < 0 || value >= this.elements.length) { - throw TypeScript.Errors.argumentOutOfRange("index"); - } - - return this.elements[value]; - }; - - NormalSeparatedSyntaxList.prototype.separatorAt = function (index) { - var value = index * 2 + 1; - if (value < 0 || value >= this.elements.length) { - throw TypeScript.Errors.argumentOutOfRange("index"); - } - - return this.elements[value]; - }; - - NormalSeparatedSyntaxList.prototype.firstToken = function () { - var token; - for (var i = 0, n = this.elements.length; i < n; i++) { - if (i % 2 === 0) { - var nodeOrToken = this.elements[i]; - token = nodeOrToken.firstToken(); - if (token !== null) { - return token; - } - } else { - token = this.elements[i]; - if (token.width() > 0) { - return token; - } - } - } - - return null; - }; - - NormalSeparatedSyntaxList.prototype.lastToken = function () { - var token; - for (var i = this.elements.length - 1; i >= 0; i--) { - if (i % 2 === 0) { - var nodeOrToken = this.elements[i]; - token = nodeOrToken.lastToken(); - if (token !== null) { - return token; - } - } else { - token = this.elements[i]; - if (token.width() > 0) { - return token; - } - } - } - - return null; - }; - - NormalSeparatedSyntaxList.prototype.fullText = function () { - var elements = []; - this.collectTextElements(elements); - return elements.join(""); - }; - - NormalSeparatedSyntaxList.prototype.isTypeScriptSpecific = function () { - for (var i = 0, n = this.nonSeparatorCount(); i < n; i++) { - if (this.nonSeparatorAt(i).isTypeScriptSpecific()) { - return true; - } - } - - return false; - }; - - NormalSeparatedSyntaxList.prototype.isIncrementallyUnusable = function () { - return (this.data() & 2 /* NodeIncrementallyUnusableMask */) !== 0; - }; - - NormalSeparatedSyntaxList.prototype.fullWidth = function () { - return this.data() >>> 3 /* NodeFullWidthShift */; - }; - - NormalSeparatedSyntaxList.prototype.width = function () { - var fullWidth = this.fullWidth(); - return fullWidth - this.leadingTriviaWidth() - this.trailingTriviaWidth(); - }; - - NormalSeparatedSyntaxList.prototype.leadingTrivia = function () { - return this.firstToken().leadingTrivia(); - }; - - NormalSeparatedSyntaxList.prototype.trailingTrivia = function () { - return this.lastToken().trailingTrivia(); - }; - - NormalSeparatedSyntaxList.prototype.leadingTriviaWidth = function () { - return this.firstToken().leadingTriviaWidth(); - }; - - NormalSeparatedSyntaxList.prototype.trailingTriviaWidth = function () { - return this.lastToken().trailingTriviaWidth(); - }; - - NormalSeparatedSyntaxList.prototype.computeData = function () { - var fullWidth = 0; - var isIncrementallyUnusable = false; - - for (var i = 0, n = this.elements.length; i < n; i++) { - var element = this.elements[i]; - - var childWidth = element.fullWidth(); - fullWidth += childWidth; - - isIncrementallyUnusable = isIncrementallyUnusable || element.isIncrementallyUnusable(); - } - - return (fullWidth << 3 /* NodeFullWidthShift */) | (isIncrementallyUnusable ? 2 /* NodeIncrementallyUnusableMask */ : 0) | 1 /* NodeDataComputed */; - }; - - NormalSeparatedSyntaxList.prototype.data = function () { - if ((this._data & 1 /* NodeDataComputed */) === 0) { - this._data = this.computeData(); - } - - return this._data; - }; - - NormalSeparatedSyntaxList.prototype.findTokenInternal = function (parent, position, fullStart) { - parent = new TypeScript.PositionedSeparatedList(parent, this, fullStart); - for (var i = 0, n = this.elements.length; i < n; i++) { - var element = this.elements[i]; - - var childWidth = element.fullWidth(); - if (position < childWidth) { - return (element).findTokenInternal(parent, position, fullStart); - } - - position -= childWidth; - fullStart += childWidth; - } - - throw TypeScript.Errors.invalidOperation(); - }; - - NormalSeparatedSyntaxList.prototype.collectTextElements = function (elements) { - for (var i = 0, n = this.elements.length; i < n; i++) { - var element = this.elements[i]; - element.collectTextElements(elements); - } - }; - - NormalSeparatedSyntaxList.prototype.insertChildrenInto = function (array, index) { - if (index === 0) { - array.unshift.apply(array, this.elements); - } else { - array.splice.apply(array, [index, 0].concat(this.elements)); - } - }; - return NormalSeparatedSyntaxList; - })(); - - function separatedList(nodes) { - return separatedListAndValidate(nodes, false); - } - Syntax.separatedList = separatedList; - - function separatedListAndValidate(nodes, validate) { - if (nodes === undefined || nodes === null || nodes.length === 0) { - return Syntax.emptySeparatedList; - } - - if (validate) { - for (var i = 0; i < nodes.length; i++) { - var item = nodes[i]; - - if (i % 2 === 1) { - } - } - } - - if (nodes.length === 1) { - return new SingletonSeparatedSyntaxList(nodes[0]); - } - - return new NormalSeparatedSyntaxList(nodes); - } - })(TypeScript.Syntax || (TypeScript.Syntax = {})); - var Syntax = TypeScript.Syntax; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var SlidingWindow = (function () { - function SlidingWindow(source, window, defaultValue, sourceLength) { - if (typeof sourceLength === "undefined") { sourceLength = -1; } - this.source = source; - this.window = window; - this.defaultValue = defaultValue; - this.sourceLength = sourceLength; - this.windowCount = 0; - this.windowAbsoluteStartIndex = 0; - this.currentRelativeItemIndex = 0; - this._pinCount = 0; - this.firstPinnedAbsoluteIndex = -1; - } - SlidingWindow.prototype.windowAbsoluteEndIndex = function () { - return this.windowAbsoluteStartIndex + this.windowCount; - }; - - SlidingWindow.prototype.addMoreItemsToWindow = function (argument) { - if (this.sourceLength >= 0 && this.absoluteIndex() >= this.sourceLength) { - return false; - } - - if (this.windowCount >= this.window.length) { - this.tryShiftOrGrowWindow(); - } - - var spaceAvailable = this.window.length - this.windowCount; - var amountFetched = this.source.fetchMoreItems(argument, this.windowAbsoluteEndIndex(), this.window, this.windowCount, spaceAvailable); - - this.windowCount += amountFetched; - return amountFetched > 0; - }; - - SlidingWindow.prototype.tryShiftOrGrowWindow = function () { - var currentIndexIsPastWindowHalfwayPoint = this.currentRelativeItemIndex > (this.window.length >>> 1); - - var isAllowedToShift = this.firstPinnedAbsoluteIndex === -1 || this.firstPinnedAbsoluteIndex > this.windowAbsoluteStartIndex; - - if (currentIndexIsPastWindowHalfwayPoint && isAllowedToShift) { - var shiftStartIndex = this.firstPinnedAbsoluteIndex === -1 ? this.currentRelativeItemIndex : this.firstPinnedAbsoluteIndex - this.windowAbsoluteStartIndex; - - var shiftCount = this.windowCount - shiftStartIndex; - - if (shiftCount > 0) { - TypeScript.ArrayUtilities.copy(this.window, shiftStartIndex, this.window, 0, shiftCount); - } - - this.windowAbsoluteStartIndex += shiftStartIndex; - - this.windowCount -= shiftStartIndex; - - this.currentRelativeItemIndex -= shiftStartIndex; - } else { - TypeScript.ArrayUtilities.grow(this.window, this.window.length * 2, this.defaultValue); - } - }; - - SlidingWindow.prototype.absoluteIndex = function () { - return this.windowAbsoluteStartIndex + this.currentRelativeItemIndex; - }; - - SlidingWindow.prototype.isAtEndOfSource = function () { - return this.absoluteIndex() >= this.sourceLength; - }; - - SlidingWindow.prototype.getAndPinAbsoluteIndex = function () { - var absoluteIndex = this.absoluteIndex(); - var pinCount = this._pinCount++; - if (pinCount === 0) { - this.firstPinnedAbsoluteIndex = absoluteIndex; - } - - return absoluteIndex; - }; - - SlidingWindow.prototype.releaseAndUnpinAbsoluteIndex = function (absoluteIndex) { - this._pinCount--; - if (this._pinCount === 0) { - this.firstPinnedAbsoluteIndex = -1; - } - }; - - SlidingWindow.prototype.rewindToPinnedIndex = function (absoluteIndex) { - var relativeIndex = absoluteIndex - this.windowAbsoluteStartIndex; - - this.currentRelativeItemIndex = relativeIndex; - }; - - SlidingWindow.prototype.currentItem = function (argument) { - if (this.currentRelativeItemIndex >= this.windowCount) { - if (!this.addMoreItemsToWindow(argument)) { - return this.defaultValue; - } - } - - return this.window[this.currentRelativeItemIndex]; - }; - - SlidingWindow.prototype.peekItemN = function (n) { - while (this.currentRelativeItemIndex + n >= this.windowCount) { - if (!this.addMoreItemsToWindow(null)) { - return this.defaultValue; - } - } - - return this.window[this.currentRelativeItemIndex + n]; - }; - - SlidingWindow.prototype.moveToNextItem = function () { - this.currentRelativeItemIndex++; - }; - - SlidingWindow.prototype.disgardAllItemsFromCurrentIndexOnwards = function () { - this.windowCount = this.currentRelativeItemIndex; - }; - - SlidingWindow.prototype.setAbsoluteIndex = function (absoluteIndex) { - if (this.absoluteIndex() === absoluteIndex) { - return; - } - - if (this._pinCount > 0) { - } - - if (absoluteIndex >= this.windowAbsoluteStartIndex && absoluteIndex < this.windowAbsoluteEndIndex()) { - this.currentRelativeItemIndex = (absoluteIndex - this.windowAbsoluteStartIndex); - } else { - this.windowAbsoluteStartIndex = absoluteIndex; - - this.windowCount = 0; - - this.currentRelativeItemIndex = 0; - } - }; - - SlidingWindow.prototype.pinCount = function () { - return this._pinCount; - }; - return SlidingWindow; - })(); - TypeScript.SlidingWindow = SlidingWindow; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var Strings = (function () { - function Strings() { - } - Strings.module__class__interface__enum__import_or_statement = "module, class, interface, enum, import or statement"; - Strings.constructor__function__accessor_or_variable = "constructor, function, accessor or variable"; - Strings.statement = "statement"; - Strings.case_or_default_clause = "case or default clause"; - Strings.identifier = "identifier"; - Strings.call__construct__index__property_or_function_signature = "call, construct, index, property or function signature"; - Strings.expression = "expression"; - Strings.type_name = "type name"; - Strings.property_or_accessor = "property or accessor"; - Strings.parameter = "parameter"; - Strings.type = "type"; - Strings.type_parameter = "type parameter"; - return Strings; - })(); - TypeScript.Strings = Strings; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (Syntax) { - function emptySourceUnit() { - return TypeScript.Syntax.normalModeFactory.sourceUnit(TypeScript.Syntax.emptyList, TypeScript.Syntax.token(10 /* EndOfFileToken */, { text: "" })); - } - Syntax.emptySourceUnit = emptySourceUnit; - - function getStandaloneExpression(positionedToken) { - var token = positionedToken.token(); - if (positionedToken !== null && positionedToken.kind() === 11 /* IdentifierName */) { - var parentPositionedNode = positionedToken.containingNode(); - var parentNode = parentPositionedNode.node(); - - if (parentNode.kind() === 122 /* QualifiedName */ && (parentNode).right === token) { - return parentPositionedNode; - } else if (parentNode.kind() === 211 /* MemberAccessExpression */ && (parentNode).name === token) { - return parentPositionedNode; - } - } - - return positionedToken; - } - Syntax.getStandaloneExpression = getStandaloneExpression; - - function isInModuleOrTypeContext(positionedToken) { - if (positionedToken !== null) { - var positionedNodeOrToken = TypeScript.Syntax.getStandaloneExpression(positionedToken); - var parent = positionedNodeOrToken.containingNode(); - - if (parent !== null) { - switch (parent.kind()) { - case 246 /* ModuleNameModuleReference */: - return true; - case 122 /* QualifiedName */: - return true; - default: - return isInTypeOnlyContext(positionedToken); - } - } - } - - return false; - } - Syntax.isInModuleOrTypeContext = isInModuleOrTypeContext; - - function isInTypeOnlyContext(positionedToken) { - var positionedNodeOrToken = TypeScript.Syntax.getStandaloneExpression(positionedToken); - var positionedParent = positionedNodeOrToken.containingNode(); - - var parent = positionedParent.node(); - var nodeOrToken = positionedNodeOrToken.nodeOrToken(); - - if (parent !== null) { - switch (parent.kind()) { - case 125 /* ArrayType */: - return (parent).type === nodeOrToken; - case 219 /* CastExpression */: - return (parent).type === nodeOrToken; - case 244 /* TypeAnnotation */: - case 229 /* HeritageClause */: - case 227 /* TypeArgumentList */: - return true; - } - } - - return false; - } - Syntax.isInTypeOnlyContext = isInTypeOnlyContext; - - function childOffset(parent, child) { - var offset = 0; - for (var i = 0, n = parent.childCount(); i < n; i++) { - var current = parent.childAt(i); - if (current === child) { - return offset; - } - - if (current !== null) { - offset += current.fullWidth(); - } - } - - throw TypeScript.Errors.invalidOperation(); - } - Syntax.childOffset = childOffset; - - function childOffsetAt(parent, index) { - var offset = 0; - for (var i = 0; i < index; i++) { - var current = parent.childAt(i); - if (current !== null) { - offset += current.fullWidth(); - } - } - - return offset; - } - Syntax.childOffsetAt = childOffsetAt; - - function childIndex(parent, child) { - for (var i = 0, n = parent.childCount(); i < n; i++) { - var current = parent.childAt(i); - if (current === child) { - return i; - } - } - - throw TypeScript.Errors.invalidOperation(); - } - Syntax.childIndex = childIndex; - - function nodeStructuralEquals(node1, node2) { - if (node1 === null) { - return node2 === null; - } - - return node1.structuralEquals(node2); - } - Syntax.nodeStructuralEquals = nodeStructuralEquals; - - function nodeOrTokenStructuralEquals(node1, node2) { - if (node1 === node2) { - return true; - } - - if (node1 === null || node2 === null) { - return false; - } - - if (node1.isToken()) { - return node2.isToken() ? tokenStructuralEquals(node1, node2) : false; - } - - return node2.isNode() ? nodeStructuralEquals(node1, node2) : false; - } - Syntax.nodeOrTokenStructuralEquals = nodeOrTokenStructuralEquals; - - function tokenStructuralEquals(token1, token2) { - if (token1 === token2) { - return true; - } - - if (token1 === null || token2 === null) { - return false; - } - - return token1.kind() === token2.kind() && token1.width() === token2.width() && token1.fullWidth() === token2.fullWidth() && token1.text() === token2.text() && TypeScript.Syntax.triviaListStructuralEquals(token1.leadingTrivia(), token2.leadingTrivia()) && TypeScript.Syntax.triviaListStructuralEquals(token1.trailingTrivia(), token2.trailingTrivia()); - } - Syntax.tokenStructuralEquals = tokenStructuralEquals; - - function triviaListStructuralEquals(triviaList1, triviaList2) { - if (triviaList1.count() !== triviaList2.count()) { - return false; - } - - for (var i = 0, n = triviaList1.count(); i < n; i++) { - if (!TypeScript.Syntax.triviaStructuralEquals(triviaList1.syntaxTriviaAt(i), triviaList2.syntaxTriviaAt(i))) { - return false; - } - } - - return true; - } - Syntax.triviaListStructuralEquals = triviaListStructuralEquals; - - function triviaStructuralEquals(trivia1, trivia2) { - return trivia1.kind() === trivia2.kind() && trivia1.fullWidth() === trivia2.fullWidth() && trivia1.fullText() === trivia2.fullText(); - } - Syntax.triviaStructuralEquals = triviaStructuralEquals; - - function listStructuralEquals(list1, list2) { - if (list1.childCount() !== list2.childCount()) { - return false; - } - - for (var i = 0, n = list1.childCount(); i < n; i++) { - var child1 = list1.childAt(i); - var child2 = list2.childAt(i); - - if (!TypeScript.Syntax.nodeOrTokenStructuralEquals(child1, child2)) { - return false; - } - } - - return true; - } - Syntax.listStructuralEquals = listStructuralEquals; - - function separatedListStructuralEquals(list1, list2) { - if (list1.childCount() !== list2.childCount()) { - return false; - } - - for (var i = 0, n = list1.childCount(); i < n; i++) { - var element1 = list1.childAt(i); - var element2 = list2.childAt(i); - if (!TypeScript.Syntax.nodeOrTokenStructuralEquals(element1, element2)) { - return false; - } - } - - return true; - } - Syntax.separatedListStructuralEquals = separatedListStructuralEquals; - - function elementStructuralEquals(element1, element2) { - if (element1 === element2) { - return true; - } - - if (element1 === null || element2 === null) { - return false; - } - - if (element2.kind() !== element2.kind()) { - return false; - } - - if (element1.isToken()) { - return tokenStructuralEquals(element1, element2); - } else if (element1.isNode()) { - return nodeStructuralEquals(element1, element2); - } else if (element1.isList()) { - return listStructuralEquals(element1, element2); - } else if (element1.isSeparatedList()) { - return separatedListStructuralEquals(element1, element2); - } - - throw TypeScript.Errors.invalidOperation(); - } - Syntax.elementStructuralEquals = elementStructuralEquals; - - function identifierName(text, info) { - if (typeof info === "undefined") { info = null; } - return Syntax.identifier(text); - } - Syntax.identifierName = identifierName; - - function trueExpression() { - return TypeScript.Syntax.token(37 /* TrueKeyword */); - } - Syntax.trueExpression = trueExpression; - - function falseExpression() { - return TypeScript.Syntax.token(24 /* FalseKeyword */); - } - Syntax.falseExpression = falseExpression; - - function numericLiteralExpression(text) { - return TypeScript.Syntax.token(13 /* NumericLiteral */, { text: text }); - } - Syntax.numericLiteralExpression = numericLiteralExpression; - - function stringLiteralExpression(text) { - return TypeScript.Syntax.token(14 /* StringLiteral */, { text: text }); - } - Syntax.stringLiteralExpression = stringLiteralExpression; - - function isSuperInvocationExpression(node) { - return node.kind() === 212 /* InvocationExpression */ && (node).expression.kind() === 50 /* SuperKeyword */; - } - Syntax.isSuperInvocationExpression = isSuperInvocationExpression; - - function isSuperInvocationExpressionStatement(node) { - return node.kind() === 148 /* ExpressionStatement */ && isSuperInvocationExpression((node).expression); - } - Syntax.isSuperInvocationExpressionStatement = isSuperInvocationExpressionStatement; - - function isSuperMemberAccessExpression(node) { - return node.kind() === 211 /* MemberAccessExpression */ && (node).expression.kind() === 50 /* SuperKeyword */; - } - Syntax.isSuperMemberAccessExpression = isSuperMemberAccessExpression; - - function isSuperMemberAccessInvocationExpression(node) { - return node.kind() === 212 /* InvocationExpression */ && isSuperMemberAccessExpression((node).expression); - } - Syntax.isSuperMemberAccessInvocationExpression = isSuperMemberAccessInvocationExpression; - - function assignmentExpression(left, token, right) { - return TypeScript.Syntax.normalModeFactory.binaryExpression(173 /* AssignmentExpression */, left, token, right); - } - Syntax.assignmentExpression = assignmentExpression; - - function nodeHasSkippedOrMissingTokens(node) { - for (var i = 0; i < node.childCount(); i++) { - var child = node.childAt(i); - if (child !== null && child.isToken()) { - var token = child; - - if (token.hasSkippedToken() || (token.width() === 0 && token.kind() !== 10 /* EndOfFileToken */)) { - return true; - } - } - } - return false; - } - Syntax.nodeHasSkippedOrMissingTokens = nodeHasSkippedOrMissingTokens; - - function isUnterminatedStringLiteral(token) { - if (token && token.kind() === 14 /* StringLiteral */) { - var text = token.text(); - return text.length < 2 || text.charCodeAt(text.length - 1) !== text.charCodeAt(0); - } - - return false; - } - Syntax.isUnterminatedStringLiteral = isUnterminatedStringLiteral; - - function isUnterminatedMultilineCommentTrivia(trivia) { - if (trivia && trivia.kind() === 6 /* MultiLineCommentTrivia */) { - var text = trivia.fullText(); - return text.length < 4 || text.substring(text.length - 2) !== "*/"; - } - return false; - } - Syntax.isUnterminatedMultilineCommentTrivia = isUnterminatedMultilineCommentTrivia; - - function isEntirelyInsideCommentTrivia(trivia, fullStart, position) { - if (trivia && trivia.isComment() && position > fullStart) { - var end = fullStart + trivia.fullWidth(); - if (position < end) { - return true; - } else if (position === end) { - return trivia.kind() === 7 /* SingleLineCommentTrivia */ || isUnterminatedMultilineCommentTrivia(trivia); - } - } - - return false; - } - Syntax.isEntirelyInsideCommentTrivia = isEntirelyInsideCommentTrivia; - - function isEntirelyInsideComment(sourceUnit, position) { - var positionedToken = sourceUnit.findToken(position); - var fullStart = positionedToken.fullStart(); - var triviaList = null; - var lastTriviaBeforeToken = null; - - if (positionedToken.kind() === 10 /* EndOfFileToken */) { - if (positionedToken.token().hasLeadingTrivia()) { - triviaList = positionedToken.token().leadingTrivia(); - } else { - positionedToken = positionedToken.previousToken(); - if (positionedToken) { - if (positionedToken && positionedToken.token().hasTrailingTrivia()) { - triviaList = positionedToken.token().trailingTrivia(); - fullStart = positionedToken.end(); - } - } - } - } else { - if (position <= (fullStart + positionedToken.token().leadingTriviaWidth())) { - triviaList = positionedToken.token().leadingTrivia(); - } else if (position >= (fullStart + positionedToken.token().width())) { - triviaList = positionedToken.token().trailingTrivia(); - fullStart = positionedToken.end(); - } - } - - if (triviaList) { - for (var i = 0, n = triviaList.count(); i < n; i++) { - var trivia = triviaList.syntaxTriviaAt(i); - if (position <= fullStart) { - break; - } else if (position <= fullStart + trivia.fullWidth() && trivia.isComment()) { - lastTriviaBeforeToken = trivia; - break; - } - - fullStart += trivia.fullWidth(); - } - } - - return lastTriviaBeforeToken && isEntirelyInsideCommentTrivia(lastTriviaBeforeToken, fullStart, position); - } - Syntax.isEntirelyInsideComment = isEntirelyInsideComment; - - function isEntirelyInStringOrRegularExpressionLiteral(sourceUnit, position) { - var positionedToken = sourceUnit.findToken(position); - - if (positionedToken) { - if (positionedToken.kind() === 10 /* EndOfFileToken */) { - positionedToken = positionedToken.previousToken(); - return positionedToken && positionedToken.token().trailingTriviaWidth() === 0 && isUnterminatedStringLiteral(positionedToken.token()); - } else if (position > positionedToken.start()) { - return (position < positionedToken.end() && (positionedToken.kind() === 14 /* StringLiteral */ || positionedToken.kind() === 12 /* RegularExpressionLiteral */)) || (position <= positionedToken.end() && isUnterminatedStringLiteral(positionedToken.token())); - } - } - - return false; - } - Syntax.isEntirelyInStringOrRegularExpressionLiteral = isEntirelyInStringOrRegularExpressionLiteral; - - function findSkippedTokenInTriviaList(positionedToken, position, lookInLeadingTriviaList) { - var triviaList = null; - var fullStart; - - if (lookInLeadingTriviaList) { - triviaList = positionedToken.token().leadingTrivia(); - fullStart = positionedToken.fullStart(); - } else { - triviaList = positionedToken.token().trailingTrivia(); - fullStart = positionedToken.end(); - } - - if (triviaList && triviaList.hasSkippedToken()) { - for (var i = 0, n = triviaList.count(); i < n; i++) { - var trivia = triviaList.syntaxTriviaAt(i); - var triviaWidth = trivia.fullWidth(); - - if (trivia.isSkippedToken() && position >= fullStart && position <= fullStart + triviaWidth) { - return new TypeScript.PositionedSkippedToken(positionedToken, trivia.skippedToken(), fullStart); - } - - fullStart += triviaWidth; - } - } - - return null; - } - - function findSkippedTokenInLeadingTriviaList(positionedToken, position) { - return findSkippedTokenInTriviaList(positionedToken, position, true); - } - Syntax.findSkippedTokenInLeadingTriviaList = findSkippedTokenInLeadingTriviaList; - - function findSkippedTokenInTrailingTriviaList(positionedToken, position) { - return findSkippedTokenInTriviaList(positionedToken, position, false); - } - Syntax.findSkippedTokenInTrailingTriviaList = findSkippedTokenInTrailingTriviaList; - - function findSkippedTokenInPositionedToken(positionedToken, position) { - var positionInLeadingTriviaList = (position < positionedToken.start()); - return findSkippedTokenInTriviaList(positionedToken, position, positionInLeadingTriviaList); - } - Syntax.findSkippedTokenInPositionedToken = findSkippedTokenInPositionedToken; - - function getAncestorOfKind(positionedToken, kind) { - while (positionedToken && positionedToken.parent()) { - if (positionedToken.parent().kind() === kind) { - return positionedToken.parent(); - } - - positionedToken = positionedToken.parent(); - } - - return null; - } - Syntax.getAncestorOfKind = getAncestorOfKind; - - function hasAncestorOfKind(positionedToken, kind) { - return TypeScript.Syntax.getAncestorOfKind(positionedToken, kind) !== null; - } - Syntax.hasAncestorOfKind = hasAncestorOfKind; - })(TypeScript.Syntax || (TypeScript.Syntax = {})); - var Syntax = TypeScript.Syntax; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var SyntaxDiagnostic = (function (_super) { - __extends(SyntaxDiagnostic, _super); - function SyntaxDiagnostic() { - _super.apply(this, arguments); - } - SyntaxDiagnostic.equals = function (diagnostic1, diagnostic2) { - return TypeScript.Diagnostic.equals(diagnostic1, diagnostic2); - }; - return SyntaxDiagnostic; - })(TypeScript.Diagnostic); - TypeScript.SyntaxDiagnostic = SyntaxDiagnostic; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (Syntax) { - var NormalModeFactory = (function () { - function NormalModeFactory() { - } - NormalModeFactory.prototype.sourceUnit = function (moduleElements, endOfFileToken) { - return new TypeScript.SourceUnitSyntax(moduleElements, endOfFileToken, false); - }; - NormalModeFactory.prototype.externalModuleReference = function (moduleOrRequireKeyword, openParenToken, stringLiteral, closeParenToken) { - return new TypeScript.ExternalModuleReferenceSyntax(moduleOrRequireKeyword, openParenToken, stringLiteral, closeParenToken, false); - }; - NormalModeFactory.prototype.moduleNameModuleReference = function (moduleName) { - return new TypeScript.ModuleNameModuleReferenceSyntax(moduleName, false); - }; - NormalModeFactory.prototype.importDeclaration = function (importKeyword, identifier, equalsToken, moduleReference, semicolonToken) { - return new TypeScript.ImportDeclarationSyntax(importKeyword, identifier, equalsToken, moduleReference, semicolonToken, false); - }; - NormalModeFactory.prototype.exportAssignment = function (exportKeyword, equalsToken, identifier, semicolonToken) { - return new TypeScript.ExportAssignmentSyntax(exportKeyword, equalsToken, identifier, semicolonToken, false); - }; - NormalModeFactory.prototype.classDeclaration = function (modifiers, classKeyword, identifier, typeParameterList, heritageClauses, openBraceToken, classElements, closeBraceToken) { - return new TypeScript.ClassDeclarationSyntax(modifiers, classKeyword, identifier, typeParameterList, heritageClauses, openBraceToken, classElements, closeBraceToken, false); - }; - NormalModeFactory.prototype.interfaceDeclaration = function (modifiers, interfaceKeyword, identifier, typeParameterList, heritageClauses, body) { - return new TypeScript.InterfaceDeclarationSyntax(modifiers, interfaceKeyword, identifier, typeParameterList, heritageClauses, body, false); - }; - NormalModeFactory.prototype.heritageClause = function (extendsOrImplementsKeyword, typeNames) { - return new TypeScript.HeritageClauseSyntax(extendsOrImplementsKeyword, typeNames, false); - }; - NormalModeFactory.prototype.moduleDeclaration = function (modifiers, moduleKeyword, moduleName, stringLiteral, openBraceToken, moduleElements, closeBraceToken) { - return new TypeScript.ModuleDeclarationSyntax(modifiers, moduleKeyword, moduleName, stringLiteral, openBraceToken, moduleElements, closeBraceToken, false); - }; - NormalModeFactory.prototype.functionDeclaration = function (modifiers, functionKeyword, identifier, callSignature, block, semicolonToken) { - return new TypeScript.FunctionDeclarationSyntax(modifiers, functionKeyword, identifier, callSignature, block, semicolonToken, false); - }; - NormalModeFactory.prototype.variableStatement = function (modifiers, variableDeclaration, semicolonToken) { - return new TypeScript.VariableStatementSyntax(modifiers, variableDeclaration, semicolonToken, false); - }; - NormalModeFactory.prototype.variableDeclaration = function (varKeyword, variableDeclarators) { - return new TypeScript.VariableDeclarationSyntax(varKeyword, variableDeclarators, false); - }; - NormalModeFactory.prototype.variableDeclarator = function (identifier, typeAnnotation, equalsValueClause) { - return new TypeScript.VariableDeclaratorSyntax(identifier, typeAnnotation, equalsValueClause, false); - }; - NormalModeFactory.prototype.equalsValueClause = function (equalsToken, value) { - return new TypeScript.EqualsValueClauseSyntax(equalsToken, value, false); - }; - NormalModeFactory.prototype.prefixUnaryExpression = function (kind, operatorToken, operand) { - return new TypeScript.PrefixUnaryExpressionSyntax(kind, operatorToken, operand, false); - }; - NormalModeFactory.prototype.arrayLiteralExpression = function (openBracketToken, expressions, closeBracketToken) { - return new TypeScript.ArrayLiteralExpressionSyntax(openBracketToken, expressions, closeBracketToken, false); - }; - NormalModeFactory.prototype.omittedExpression = function () { - return new TypeScript.OmittedExpressionSyntax(false); - }; - NormalModeFactory.prototype.parenthesizedExpression = function (openParenToken, expression, closeParenToken) { - return new TypeScript.ParenthesizedExpressionSyntax(openParenToken, expression, closeParenToken, false); - }; - NormalModeFactory.prototype.simpleArrowFunctionExpression = function (identifier, equalsGreaterThanToken, body) { - return new TypeScript.SimpleArrowFunctionExpressionSyntax(identifier, equalsGreaterThanToken, body, false); - }; - NormalModeFactory.prototype.parenthesizedArrowFunctionExpression = function (callSignature, equalsGreaterThanToken, body) { - return new TypeScript.ParenthesizedArrowFunctionExpressionSyntax(callSignature, equalsGreaterThanToken, body, false); - }; - NormalModeFactory.prototype.qualifiedName = function (left, dotToken, right) { - return new TypeScript.QualifiedNameSyntax(left, dotToken, right, false); - }; - NormalModeFactory.prototype.typeArgumentList = function (lessThanToken, typeArguments, greaterThanToken) { - return new TypeScript.TypeArgumentListSyntax(lessThanToken, typeArguments, greaterThanToken, false); - }; - NormalModeFactory.prototype.constructorType = function (newKeyword, typeParameterList, parameterList, equalsGreaterThanToken, type) { - return new TypeScript.ConstructorTypeSyntax(newKeyword, typeParameterList, parameterList, equalsGreaterThanToken, type, false); - }; - NormalModeFactory.prototype.functionType = function (typeParameterList, parameterList, equalsGreaterThanToken, type) { - return new TypeScript.FunctionTypeSyntax(typeParameterList, parameterList, equalsGreaterThanToken, type, false); - }; - NormalModeFactory.prototype.objectType = function (openBraceToken, typeMembers, closeBraceToken) { - return new TypeScript.ObjectTypeSyntax(openBraceToken, typeMembers, closeBraceToken, false); - }; - NormalModeFactory.prototype.arrayType = function (type, openBracketToken, closeBracketToken) { - return new TypeScript.ArrayTypeSyntax(type, openBracketToken, closeBracketToken, false); - }; - NormalModeFactory.prototype.genericType = function (name, typeArgumentList) { - return new TypeScript.GenericTypeSyntax(name, typeArgumentList, false); - }; - NormalModeFactory.prototype.typeAnnotation = function (colonToken, type) { - return new TypeScript.TypeAnnotationSyntax(colonToken, type, false); - }; - NormalModeFactory.prototype.block = function (openBraceToken, statements, closeBraceToken) { - return new TypeScript.BlockSyntax(openBraceToken, statements, closeBraceToken, false); - }; - NormalModeFactory.prototype.parameter = function (dotDotDotToken, publicOrPrivateKeyword, identifier, questionToken, typeAnnotation, equalsValueClause) { - return new TypeScript.ParameterSyntax(dotDotDotToken, publicOrPrivateKeyword, identifier, questionToken, typeAnnotation, equalsValueClause, false); - }; - NormalModeFactory.prototype.memberAccessExpression = function (expression, dotToken, name) { - return new TypeScript.MemberAccessExpressionSyntax(expression, dotToken, name, false); - }; - NormalModeFactory.prototype.postfixUnaryExpression = function (kind, operand, operatorToken) { - return new TypeScript.PostfixUnaryExpressionSyntax(kind, operand, operatorToken, false); - }; - NormalModeFactory.prototype.elementAccessExpression = function (expression, openBracketToken, argumentExpression, closeBracketToken) { - return new TypeScript.ElementAccessExpressionSyntax(expression, openBracketToken, argumentExpression, closeBracketToken, false); - }; - NormalModeFactory.prototype.invocationExpression = function (expression, argumentList) { - return new TypeScript.InvocationExpressionSyntax(expression, argumentList, false); - }; - NormalModeFactory.prototype.argumentList = function (typeArgumentList, openParenToken, _arguments, closeParenToken) { - return new TypeScript.ArgumentListSyntax(typeArgumentList, openParenToken, _arguments, closeParenToken, false); - }; - NormalModeFactory.prototype.binaryExpression = function (kind, left, operatorToken, right) { - return new TypeScript.BinaryExpressionSyntax(kind, left, operatorToken, right, false); - }; - NormalModeFactory.prototype.conditionalExpression = function (condition, questionToken, whenTrue, colonToken, whenFalse) { - return new TypeScript.ConditionalExpressionSyntax(condition, questionToken, whenTrue, colonToken, whenFalse, false); - }; - NormalModeFactory.prototype.constructSignature = function (newKeyword, callSignature) { - return new TypeScript.ConstructSignatureSyntax(newKeyword, callSignature, false); - }; - NormalModeFactory.prototype.methodSignature = function (propertyName, questionToken, callSignature) { - return new TypeScript.MethodSignatureSyntax(propertyName, questionToken, callSignature, false); - }; - NormalModeFactory.prototype.indexSignature = function (openBracketToken, parameter, closeBracketToken, typeAnnotation) { - return new TypeScript.IndexSignatureSyntax(openBracketToken, parameter, closeBracketToken, typeAnnotation, false); - }; - NormalModeFactory.prototype.propertySignature = function (propertyName, questionToken, typeAnnotation) { - return new TypeScript.PropertySignatureSyntax(propertyName, questionToken, typeAnnotation, false); - }; - NormalModeFactory.prototype.callSignature = function (typeParameterList, parameterList, typeAnnotation) { - return new TypeScript.CallSignatureSyntax(typeParameterList, parameterList, typeAnnotation, false); - }; - NormalModeFactory.prototype.parameterList = function (openParenToken, parameters, closeParenToken) { - return new TypeScript.ParameterListSyntax(openParenToken, parameters, closeParenToken, false); - }; - NormalModeFactory.prototype.typeParameterList = function (lessThanToken, typeParameters, greaterThanToken) { - return new TypeScript.TypeParameterListSyntax(lessThanToken, typeParameters, greaterThanToken, false); - }; - NormalModeFactory.prototype.typeParameter = function (identifier, constraint) { - return new TypeScript.TypeParameterSyntax(identifier, constraint, false); - }; - NormalModeFactory.prototype.constraint = function (extendsKeyword, type) { - return new TypeScript.ConstraintSyntax(extendsKeyword, type, false); - }; - NormalModeFactory.prototype.elseClause = function (elseKeyword, statement) { - return new TypeScript.ElseClauseSyntax(elseKeyword, statement, false); - }; - NormalModeFactory.prototype.ifStatement = function (ifKeyword, openParenToken, condition, closeParenToken, statement, elseClause) { - return new TypeScript.IfStatementSyntax(ifKeyword, openParenToken, condition, closeParenToken, statement, elseClause, false); - }; - NormalModeFactory.prototype.expressionStatement = function (expression, semicolonToken) { - return new TypeScript.ExpressionStatementSyntax(expression, semicolonToken, false); - }; - NormalModeFactory.prototype.constructorDeclaration = function (constructorKeyword, parameterList, block, semicolonToken) { - return new TypeScript.ConstructorDeclarationSyntax(constructorKeyword, parameterList, block, semicolonToken, false); - }; - NormalModeFactory.prototype.memberFunctionDeclaration = function (modifiers, propertyName, callSignature, block, semicolonToken) { - return new TypeScript.MemberFunctionDeclarationSyntax(modifiers, propertyName, callSignature, block, semicolonToken, false); - }; - NormalModeFactory.prototype.getMemberAccessorDeclaration = function (modifiers, getKeyword, propertyName, parameterList, typeAnnotation, block) { - return new TypeScript.GetMemberAccessorDeclarationSyntax(modifiers, getKeyword, propertyName, parameterList, typeAnnotation, block, false); - }; - NormalModeFactory.prototype.setMemberAccessorDeclaration = function (modifiers, setKeyword, propertyName, parameterList, block) { - return new TypeScript.SetMemberAccessorDeclarationSyntax(modifiers, setKeyword, propertyName, parameterList, block, false); - }; - NormalModeFactory.prototype.memberVariableDeclaration = function (modifiers, variableDeclarator, semicolonToken) { - return new TypeScript.MemberVariableDeclarationSyntax(modifiers, variableDeclarator, semicolonToken, false); - }; - NormalModeFactory.prototype.throwStatement = function (throwKeyword, expression, semicolonToken) { - return new TypeScript.ThrowStatementSyntax(throwKeyword, expression, semicolonToken, false); - }; - NormalModeFactory.prototype.returnStatement = function (returnKeyword, expression, semicolonToken) { - return new TypeScript.ReturnStatementSyntax(returnKeyword, expression, semicolonToken, false); - }; - NormalModeFactory.prototype.objectCreationExpression = function (newKeyword, expression, argumentList) { - return new TypeScript.ObjectCreationExpressionSyntax(newKeyword, expression, argumentList, false); - }; - NormalModeFactory.prototype.switchStatement = function (switchKeyword, openParenToken, expression, closeParenToken, openBraceToken, switchClauses, closeBraceToken) { - return new TypeScript.SwitchStatementSyntax(switchKeyword, openParenToken, expression, closeParenToken, openBraceToken, switchClauses, closeBraceToken, false); - }; - NormalModeFactory.prototype.caseSwitchClause = function (caseKeyword, expression, colonToken, statements) { - return new TypeScript.CaseSwitchClauseSyntax(caseKeyword, expression, colonToken, statements, false); - }; - NormalModeFactory.prototype.defaultSwitchClause = function (defaultKeyword, colonToken, statements) { - return new TypeScript.DefaultSwitchClauseSyntax(defaultKeyword, colonToken, statements, false); - }; - NormalModeFactory.prototype.breakStatement = function (breakKeyword, identifier, semicolonToken) { - return new TypeScript.BreakStatementSyntax(breakKeyword, identifier, semicolonToken, false); - }; - NormalModeFactory.prototype.continueStatement = function (continueKeyword, identifier, semicolonToken) { - return new TypeScript.ContinueStatementSyntax(continueKeyword, identifier, semicolonToken, false); - }; - NormalModeFactory.prototype.forStatement = function (forKeyword, openParenToken, variableDeclaration, initializer, firstSemicolonToken, condition, secondSemicolonToken, incrementor, closeParenToken, statement) { - return new TypeScript.ForStatementSyntax(forKeyword, openParenToken, variableDeclaration, initializer, firstSemicolonToken, condition, secondSemicolonToken, incrementor, closeParenToken, statement, false); - }; - NormalModeFactory.prototype.forInStatement = function (forKeyword, openParenToken, variableDeclaration, left, inKeyword, expression, closeParenToken, statement) { - return new TypeScript.ForInStatementSyntax(forKeyword, openParenToken, variableDeclaration, left, inKeyword, expression, closeParenToken, statement, false); - }; - NormalModeFactory.prototype.whileStatement = function (whileKeyword, openParenToken, condition, closeParenToken, statement) { - return new TypeScript.WhileStatementSyntax(whileKeyword, openParenToken, condition, closeParenToken, statement, false); - }; - NormalModeFactory.prototype.withStatement = function (withKeyword, openParenToken, condition, closeParenToken, statement) { - return new TypeScript.WithStatementSyntax(withKeyword, openParenToken, condition, closeParenToken, statement, false); - }; - NormalModeFactory.prototype.enumDeclaration = function (modifiers, enumKeyword, identifier, openBraceToken, enumElements, closeBraceToken) { - return new TypeScript.EnumDeclarationSyntax(modifiers, enumKeyword, identifier, openBraceToken, enumElements, closeBraceToken, false); - }; - NormalModeFactory.prototype.enumElement = function (propertyName, equalsValueClause) { - return new TypeScript.EnumElementSyntax(propertyName, equalsValueClause, false); - }; - NormalModeFactory.prototype.castExpression = function (lessThanToken, type, greaterThanToken, expression) { - return new TypeScript.CastExpressionSyntax(lessThanToken, type, greaterThanToken, expression, false); - }; - NormalModeFactory.prototype.objectLiteralExpression = function (openBraceToken, propertyAssignments, closeBraceToken) { - return new TypeScript.ObjectLiteralExpressionSyntax(openBraceToken, propertyAssignments, closeBraceToken, false); - }; - NormalModeFactory.prototype.simplePropertyAssignment = function (propertyName, colonToken, expression) { - return new TypeScript.SimplePropertyAssignmentSyntax(propertyName, colonToken, expression, false); - }; - NormalModeFactory.prototype.functionPropertyAssignment = function (propertyName, callSignature, block) { - return new TypeScript.FunctionPropertyAssignmentSyntax(propertyName, callSignature, block, false); - }; - NormalModeFactory.prototype.getAccessorPropertyAssignment = function (getKeyword, propertyName, openParenToken, closeParenToken, typeAnnotation, block) { - return new TypeScript.GetAccessorPropertyAssignmentSyntax(getKeyword, propertyName, openParenToken, closeParenToken, typeAnnotation, block, false); - }; - NormalModeFactory.prototype.setAccessorPropertyAssignment = function (setKeyword, propertyName, openParenToken, parameter, closeParenToken, block) { - return new TypeScript.SetAccessorPropertyAssignmentSyntax(setKeyword, propertyName, openParenToken, parameter, closeParenToken, block, false); - }; - NormalModeFactory.prototype.functionExpression = function (functionKeyword, identifier, callSignature, block) { - return new TypeScript.FunctionExpressionSyntax(functionKeyword, identifier, callSignature, block, false); - }; - NormalModeFactory.prototype.emptyStatement = function (semicolonToken) { - return new TypeScript.EmptyStatementSyntax(semicolonToken, false); - }; - NormalModeFactory.prototype.tryStatement = function (tryKeyword, block, catchClause, finallyClause) { - return new TypeScript.TryStatementSyntax(tryKeyword, block, catchClause, finallyClause, false); - }; - NormalModeFactory.prototype.catchClause = function (catchKeyword, openParenToken, identifier, typeAnnotation, closeParenToken, block) { - return new TypeScript.CatchClauseSyntax(catchKeyword, openParenToken, identifier, typeAnnotation, closeParenToken, block, false); - }; - NormalModeFactory.prototype.finallyClause = function (finallyKeyword, block) { - return new TypeScript.FinallyClauseSyntax(finallyKeyword, block, false); - }; - NormalModeFactory.prototype.labeledStatement = function (identifier, colonToken, statement) { - return new TypeScript.LabeledStatementSyntax(identifier, colonToken, statement, false); - }; - NormalModeFactory.prototype.doStatement = function (doKeyword, statement, whileKeyword, openParenToken, condition, closeParenToken, semicolonToken) { - return new TypeScript.DoStatementSyntax(doKeyword, statement, whileKeyword, openParenToken, condition, closeParenToken, semicolonToken, false); - }; - NormalModeFactory.prototype.typeOfExpression = function (typeOfKeyword, expression) { - return new TypeScript.TypeOfExpressionSyntax(typeOfKeyword, expression, false); - }; - NormalModeFactory.prototype.deleteExpression = function (deleteKeyword, expression) { - return new TypeScript.DeleteExpressionSyntax(deleteKeyword, expression, false); - }; - NormalModeFactory.prototype.voidExpression = function (voidKeyword, expression) { - return new TypeScript.VoidExpressionSyntax(voidKeyword, expression, false); - }; - NormalModeFactory.prototype.debuggerStatement = function (debuggerKeyword, semicolonToken) { - return new TypeScript.DebuggerStatementSyntax(debuggerKeyword, semicolonToken, false); - }; - return NormalModeFactory; - })(); - Syntax.NormalModeFactory = NormalModeFactory; - - var StrictModeFactory = (function () { - function StrictModeFactory() { - } - StrictModeFactory.prototype.sourceUnit = function (moduleElements, endOfFileToken) { - return new TypeScript.SourceUnitSyntax(moduleElements, endOfFileToken, true); - }; - StrictModeFactory.prototype.externalModuleReference = function (moduleOrRequireKeyword, openParenToken, stringLiteral, closeParenToken) { - return new TypeScript.ExternalModuleReferenceSyntax(moduleOrRequireKeyword, openParenToken, stringLiteral, closeParenToken, true); - }; - StrictModeFactory.prototype.moduleNameModuleReference = function (moduleName) { - return new TypeScript.ModuleNameModuleReferenceSyntax(moduleName, true); - }; - StrictModeFactory.prototype.importDeclaration = function (importKeyword, identifier, equalsToken, moduleReference, semicolonToken) { - return new TypeScript.ImportDeclarationSyntax(importKeyword, identifier, equalsToken, moduleReference, semicolonToken, true); - }; - StrictModeFactory.prototype.exportAssignment = function (exportKeyword, equalsToken, identifier, semicolonToken) { - return new TypeScript.ExportAssignmentSyntax(exportKeyword, equalsToken, identifier, semicolonToken, true); - }; - StrictModeFactory.prototype.classDeclaration = function (modifiers, classKeyword, identifier, typeParameterList, heritageClauses, openBraceToken, classElements, closeBraceToken) { - return new TypeScript.ClassDeclarationSyntax(modifiers, classKeyword, identifier, typeParameterList, heritageClauses, openBraceToken, classElements, closeBraceToken, true); - }; - StrictModeFactory.prototype.interfaceDeclaration = function (modifiers, interfaceKeyword, identifier, typeParameterList, heritageClauses, body) { - return new TypeScript.InterfaceDeclarationSyntax(modifiers, interfaceKeyword, identifier, typeParameterList, heritageClauses, body, true); - }; - StrictModeFactory.prototype.heritageClause = function (extendsOrImplementsKeyword, typeNames) { - return new TypeScript.HeritageClauseSyntax(extendsOrImplementsKeyword, typeNames, true); - }; - StrictModeFactory.prototype.moduleDeclaration = function (modifiers, moduleKeyword, moduleName, stringLiteral, openBraceToken, moduleElements, closeBraceToken) { - return new TypeScript.ModuleDeclarationSyntax(modifiers, moduleKeyword, moduleName, stringLiteral, openBraceToken, moduleElements, closeBraceToken, true); - }; - StrictModeFactory.prototype.functionDeclaration = function (modifiers, functionKeyword, identifier, callSignature, block, semicolonToken) { - return new TypeScript.FunctionDeclarationSyntax(modifiers, functionKeyword, identifier, callSignature, block, semicolonToken, true); - }; - StrictModeFactory.prototype.variableStatement = function (modifiers, variableDeclaration, semicolonToken) { - return new TypeScript.VariableStatementSyntax(modifiers, variableDeclaration, semicolonToken, true); - }; - StrictModeFactory.prototype.variableDeclaration = function (varKeyword, variableDeclarators) { - return new TypeScript.VariableDeclarationSyntax(varKeyword, variableDeclarators, true); - }; - StrictModeFactory.prototype.variableDeclarator = function (identifier, typeAnnotation, equalsValueClause) { - return new TypeScript.VariableDeclaratorSyntax(identifier, typeAnnotation, equalsValueClause, true); - }; - StrictModeFactory.prototype.equalsValueClause = function (equalsToken, value) { - return new TypeScript.EqualsValueClauseSyntax(equalsToken, value, true); - }; - StrictModeFactory.prototype.prefixUnaryExpression = function (kind, operatorToken, operand) { - return new TypeScript.PrefixUnaryExpressionSyntax(kind, operatorToken, operand, true); - }; - StrictModeFactory.prototype.arrayLiteralExpression = function (openBracketToken, expressions, closeBracketToken) { - return new TypeScript.ArrayLiteralExpressionSyntax(openBracketToken, expressions, closeBracketToken, true); - }; - StrictModeFactory.prototype.omittedExpression = function () { - return new TypeScript.OmittedExpressionSyntax(true); - }; - StrictModeFactory.prototype.parenthesizedExpression = function (openParenToken, expression, closeParenToken) { - return new TypeScript.ParenthesizedExpressionSyntax(openParenToken, expression, closeParenToken, true); - }; - StrictModeFactory.prototype.simpleArrowFunctionExpression = function (identifier, equalsGreaterThanToken, body) { - return new TypeScript.SimpleArrowFunctionExpressionSyntax(identifier, equalsGreaterThanToken, body, true); - }; - StrictModeFactory.prototype.parenthesizedArrowFunctionExpression = function (callSignature, equalsGreaterThanToken, body) { - return new TypeScript.ParenthesizedArrowFunctionExpressionSyntax(callSignature, equalsGreaterThanToken, body, true); - }; - StrictModeFactory.prototype.qualifiedName = function (left, dotToken, right) { - return new TypeScript.QualifiedNameSyntax(left, dotToken, right, true); - }; - StrictModeFactory.prototype.typeArgumentList = function (lessThanToken, typeArguments, greaterThanToken) { - return new TypeScript.TypeArgumentListSyntax(lessThanToken, typeArguments, greaterThanToken, true); - }; - StrictModeFactory.prototype.constructorType = function (newKeyword, typeParameterList, parameterList, equalsGreaterThanToken, type) { - return new TypeScript.ConstructorTypeSyntax(newKeyword, typeParameterList, parameterList, equalsGreaterThanToken, type, true); - }; - StrictModeFactory.prototype.functionType = function (typeParameterList, parameterList, equalsGreaterThanToken, type) { - return new TypeScript.FunctionTypeSyntax(typeParameterList, parameterList, equalsGreaterThanToken, type, true); - }; - StrictModeFactory.prototype.objectType = function (openBraceToken, typeMembers, closeBraceToken) { - return new TypeScript.ObjectTypeSyntax(openBraceToken, typeMembers, closeBraceToken, true); - }; - StrictModeFactory.prototype.arrayType = function (type, openBracketToken, closeBracketToken) { - return new TypeScript.ArrayTypeSyntax(type, openBracketToken, closeBracketToken, true); - }; - StrictModeFactory.prototype.genericType = function (name, typeArgumentList) { - return new TypeScript.GenericTypeSyntax(name, typeArgumentList, true); - }; - StrictModeFactory.prototype.typeAnnotation = function (colonToken, type) { - return new TypeScript.TypeAnnotationSyntax(colonToken, type, true); - }; - StrictModeFactory.prototype.block = function (openBraceToken, statements, closeBraceToken) { - return new TypeScript.BlockSyntax(openBraceToken, statements, closeBraceToken, true); - }; - StrictModeFactory.prototype.parameter = function (dotDotDotToken, publicOrPrivateKeyword, identifier, questionToken, typeAnnotation, equalsValueClause) { - return new TypeScript.ParameterSyntax(dotDotDotToken, publicOrPrivateKeyword, identifier, questionToken, typeAnnotation, equalsValueClause, true); - }; - StrictModeFactory.prototype.memberAccessExpression = function (expression, dotToken, name) { - return new TypeScript.MemberAccessExpressionSyntax(expression, dotToken, name, true); - }; - StrictModeFactory.prototype.postfixUnaryExpression = function (kind, operand, operatorToken) { - return new TypeScript.PostfixUnaryExpressionSyntax(kind, operand, operatorToken, true); - }; - StrictModeFactory.prototype.elementAccessExpression = function (expression, openBracketToken, argumentExpression, closeBracketToken) { - return new TypeScript.ElementAccessExpressionSyntax(expression, openBracketToken, argumentExpression, closeBracketToken, true); - }; - StrictModeFactory.prototype.invocationExpression = function (expression, argumentList) { - return new TypeScript.InvocationExpressionSyntax(expression, argumentList, true); - }; - StrictModeFactory.prototype.argumentList = function (typeArgumentList, openParenToken, _arguments, closeParenToken) { - return new TypeScript.ArgumentListSyntax(typeArgumentList, openParenToken, _arguments, closeParenToken, true); - }; - StrictModeFactory.prototype.binaryExpression = function (kind, left, operatorToken, right) { - return new TypeScript.BinaryExpressionSyntax(kind, left, operatorToken, right, true); - }; - StrictModeFactory.prototype.conditionalExpression = function (condition, questionToken, whenTrue, colonToken, whenFalse) { - return new TypeScript.ConditionalExpressionSyntax(condition, questionToken, whenTrue, colonToken, whenFalse, true); - }; - StrictModeFactory.prototype.constructSignature = function (newKeyword, callSignature) { - return new TypeScript.ConstructSignatureSyntax(newKeyword, callSignature, true); - }; - StrictModeFactory.prototype.methodSignature = function (propertyName, questionToken, callSignature) { - return new TypeScript.MethodSignatureSyntax(propertyName, questionToken, callSignature, true); - }; - StrictModeFactory.prototype.indexSignature = function (openBracketToken, parameter, closeBracketToken, typeAnnotation) { - return new TypeScript.IndexSignatureSyntax(openBracketToken, parameter, closeBracketToken, typeAnnotation, true); - }; - StrictModeFactory.prototype.propertySignature = function (propertyName, questionToken, typeAnnotation) { - return new TypeScript.PropertySignatureSyntax(propertyName, questionToken, typeAnnotation, true); - }; - StrictModeFactory.prototype.callSignature = function (typeParameterList, parameterList, typeAnnotation) { - return new TypeScript.CallSignatureSyntax(typeParameterList, parameterList, typeAnnotation, true); - }; - StrictModeFactory.prototype.parameterList = function (openParenToken, parameters, closeParenToken) { - return new TypeScript.ParameterListSyntax(openParenToken, parameters, closeParenToken, true); - }; - StrictModeFactory.prototype.typeParameterList = function (lessThanToken, typeParameters, greaterThanToken) { - return new TypeScript.TypeParameterListSyntax(lessThanToken, typeParameters, greaterThanToken, true); - }; - StrictModeFactory.prototype.typeParameter = function (identifier, constraint) { - return new TypeScript.TypeParameterSyntax(identifier, constraint, true); - }; - StrictModeFactory.prototype.constraint = function (extendsKeyword, type) { - return new TypeScript.ConstraintSyntax(extendsKeyword, type, true); - }; - StrictModeFactory.prototype.elseClause = function (elseKeyword, statement) { - return new TypeScript.ElseClauseSyntax(elseKeyword, statement, true); - }; - StrictModeFactory.prototype.ifStatement = function (ifKeyword, openParenToken, condition, closeParenToken, statement, elseClause) { - return new TypeScript.IfStatementSyntax(ifKeyword, openParenToken, condition, closeParenToken, statement, elseClause, true); - }; - StrictModeFactory.prototype.expressionStatement = function (expression, semicolonToken) { - return new TypeScript.ExpressionStatementSyntax(expression, semicolonToken, true); - }; - StrictModeFactory.prototype.constructorDeclaration = function (constructorKeyword, parameterList, block, semicolonToken) { - return new TypeScript.ConstructorDeclarationSyntax(constructorKeyword, parameterList, block, semicolonToken, true); - }; - StrictModeFactory.prototype.memberFunctionDeclaration = function (modifiers, propertyName, callSignature, block, semicolonToken) { - return new TypeScript.MemberFunctionDeclarationSyntax(modifiers, propertyName, callSignature, block, semicolonToken, true); - }; - StrictModeFactory.prototype.getMemberAccessorDeclaration = function (modifiers, getKeyword, propertyName, parameterList, typeAnnotation, block) { - return new TypeScript.GetMemberAccessorDeclarationSyntax(modifiers, getKeyword, propertyName, parameterList, typeAnnotation, block, true); - }; - StrictModeFactory.prototype.setMemberAccessorDeclaration = function (modifiers, setKeyword, propertyName, parameterList, block) { - return new TypeScript.SetMemberAccessorDeclarationSyntax(modifiers, setKeyword, propertyName, parameterList, block, true); - }; - StrictModeFactory.prototype.memberVariableDeclaration = function (modifiers, variableDeclarator, semicolonToken) { - return new TypeScript.MemberVariableDeclarationSyntax(modifiers, variableDeclarator, semicolonToken, true); - }; - StrictModeFactory.prototype.throwStatement = function (throwKeyword, expression, semicolonToken) { - return new TypeScript.ThrowStatementSyntax(throwKeyword, expression, semicolonToken, true); - }; - StrictModeFactory.prototype.returnStatement = function (returnKeyword, expression, semicolonToken) { - return new TypeScript.ReturnStatementSyntax(returnKeyword, expression, semicolonToken, true); - }; - StrictModeFactory.prototype.objectCreationExpression = function (newKeyword, expression, argumentList) { - return new TypeScript.ObjectCreationExpressionSyntax(newKeyword, expression, argumentList, true); - }; - StrictModeFactory.prototype.switchStatement = function (switchKeyword, openParenToken, expression, closeParenToken, openBraceToken, switchClauses, closeBraceToken) { - return new TypeScript.SwitchStatementSyntax(switchKeyword, openParenToken, expression, closeParenToken, openBraceToken, switchClauses, closeBraceToken, true); - }; - StrictModeFactory.prototype.caseSwitchClause = function (caseKeyword, expression, colonToken, statements) { - return new TypeScript.CaseSwitchClauseSyntax(caseKeyword, expression, colonToken, statements, true); - }; - StrictModeFactory.prototype.defaultSwitchClause = function (defaultKeyword, colonToken, statements) { - return new TypeScript.DefaultSwitchClauseSyntax(defaultKeyword, colonToken, statements, true); - }; - StrictModeFactory.prototype.breakStatement = function (breakKeyword, identifier, semicolonToken) { - return new TypeScript.BreakStatementSyntax(breakKeyword, identifier, semicolonToken, true); - }; - StrictModeFactory.prototype.continueStatement = function (continueKeyword, identifier, semicolonToken) { - return new TypeScript.ContinueStatementSyntax(continueKeyword, identifier, semicolonToken, true); - }; - StrictModeFactory.prototype.forStatement = function (forKeyword, openParenToken, variableDeclaration, initializer, firstSemicolonToken, condition, secondSemicolonToken, incrementor, closeParenToken, statement) { - return new TypeScript.ForStatementSyntax(forKeyword, openParenToken, variableDeclaration, initializer, firstSemicolonToken, condition, secondSemicolonToken, incrementor, closeParenToken, statement, true); - }; - StrictModeFactory.prototype.forInStatement = function (forKeyword, openParenToken, variableDeclaration, left, inKeyword, expression, closeParenToken, statement) { - return new TypeScript.ForInStatementSyntax(forKeyword, openParenToken, variableDeclaration, left, inKeyword, expression, closeParenToken, statement, true); - }; - StrictModeFactory.prototype.whileStatement = function (whileKeyword, openParenToken, condition, closeParenToken, statement) { - return new TypeScript.WhileStatementSyntax(whileKeyword, openParenToken, condition, closeParenToken, statement, true); - }; - StrictModeFactory.prototype.withStatement = function (withKeyword, openParenToken, condition, closeParenToken, statement) { - return new TypeScript.WithStatementSyntax(withKeyword, openParenToken, condition, closeParenToken, statement, true); - }; - StrictModeFactory.prototype.enumDeclaration = function (modifiers, enumKeyword, identifier, openBraceToken, enumElements, closeBraceToken) { - return new TypeScript.EnumDeclarationSyntax(modifiers, enumKeyword, identifier, openBraceToken, enumElements, closeBraceToken, true); - }; - StrictModeFactory.prototype.enumElement = function (propertyName, equalsValueClause) { - return new TypeScript.EnumElementSyntax(propertyName, equalsValueClause, true); - }; - StrictModeFactory.prototype.castExpression = function (lessThanToken, type, greaterThanToken, expression) { - return new TypeScript.CastExpressionSyntax(lessThanToken, type, greaterThanToken, expression, true); - }; - StrictModeFactory.prototype.objectLiteralExpression = function (openBraceToken, propertyAssignments, closeBraceToken) { - return new TypeScript.ObjectLiteralExpressionSyntax(openBraceToken, propertyAssignments, closeBraceToken, true); - }; - StrictModeFactory.prototype.simplePropertyAssignment = function (propertyName, colonToken, expression) { - return new TypeScript.SimplePropertyAssignmentSyntax(propertyName, colonToken, expression, true); - }; - StrictModeFactory.prototype.functionPropertyAssignment = function (propertyName, callSignature, block) { - return new TypeScript.FunctionPropertyAssignmentSyntax(propertyName, callSignature, block, true); - }; - StrictModeFactory.prototype.getAccessorPropertyAssignment = function (getKeyword, propertyName, openParenToken, closeParenToken, typeAnnotation, block) { - return new TypeScript.GetAccessorPropertyAssignmentSyntax(getKeyword, propertyName, openParenToken, closeParenToken, typeAnnotation, block, true); - }; - StrictModeFactory.prototype.setAccessorPropertyAssignment = function (setKeyword, propertyName, openParenToken, parameter, closeParenToken, block) { - return new TypeScript.SetAccessorPropertyAssignmentSyntax(setKeyword, propertyName, openParenToken, parameter, closeParenToken, block, true); - }; - StrictModeFactory.prototype.functionExpression = function (functionKeyword, identifier, callSignature, block) { - return new TypeScript.FunctionExpressionSyntax(functionKeyword, identifier, callSignature, block, true); - }; - StrictModeFactory.prototype.emptyStatement = function (semicolonToken) { - return new TypeScript.EmptyStatementSyntax(semicolonToken, true); - }; - StrictModeFactory.prototype.tryStatement = function (tryKeyword, block, catchClause, finallyClause) { - return new TypeScript.TryStatementSyntax(tryKeyword, block, catchClause, finallyClause, true); - }; - StrictModeFactory.prototype.catchClause = function (catchKeyword, openParenToken, identifier, typeAnnotation, closeParenToken, block) { - return new TypeScript.CatchClauseSyntax(catchKeyword, openParenToken, identifier, typeAnnotation, closeParenToken, block, true); - }; - StrictModeFactory.prototype.finallyClause = function (finallyKeyword, block) { - return new TypeScript.FinallyClauseSyntax(finallyKeyword, block, true); - }; - StrictModeFactory.prototype.labeledStatement = function (identifier, colonToken, statement) { - return new TypeScript.LabeledStatementSyntax(identifier, colonToken, statement, true); - }; - StrictModeFactory.prototype.doStatement = function (doKeyword, statement, whileKeyword, openParenToken, condition, closeParenToken, semicolonToken) { - return new TypeScript.DoStatementSyntax(doKeyword, statement, whileKeyword, openParenToken, condition, closeParenToken, semicolonToken, true); - }; - StrictModeFactory.prototype.typeOfExpression = function (typeOfKeyword, expression) { - return new TypeScript.TypeOfExpressionSyntax(typeOfKeyword, expression, true); - }; - StrictModeFactory.prototype.deleteExpression = function (deleteKeyword, expression) { - return new TypeScript.DeleteExpressionSyntax(deleteKeyword, expression, true); - }; - StrictModeFactory.prototype.voidExpression = function (voidKeyword, expression) { - return new TypeScript.VoidExpressionSyntax(voidKeyword, expression, true); - }; - StrictModeFactory.prototype.debuggerStatement = function (debuggerKeyword, semicolonToken) { - return new TypeScript.DebuggerStatementSyntax(debuggerKeyword, semicolonToken, true); - }; - return StrictModeFactory; - })(); - Syntax.StrictModeFactory = StrictModeFactory; - - Syntax.normalModeFactory = new NormalModeFactory(); - Syntax.strictModeFactory = new StrictModeFactory(); - })(TypeScript.Syntax || (TypeScript.Syntax = {})); - var Syntax = TypeScript.Syntax; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (SyntaxKind) { - SyntaxKind[SyntaxKind["None"] = 0] = "None"; - SyntaxKind[SyntaxKind["List"] = 1] = "List"; - SyntaxKind[SyntaxKind["SeparatedList"] = 2] = "SeparatedList"; - SyntaxKind[SyntaxKind["TriviaList"] = 3] = "TriviaList"; - - SyntaxKind[SyntaxKind["WhitespaceTrivia"] = 4] = "WhitespaceTrivia"; - SyntaxKind[SyntaxKind["NewLineTrivia"] = 5] = "NewLineTrivia"; - SyntaxKind[SyntaxKind["MultiLineCommentTrivia"] = 6] = "MultiLineCommentTrivia"; - SyntaxKind[SyntaxKind["SingleLineCommentTrivia"] = 7] = "SingleLineCommentTrivia"; - SyntaxKind[SyntaxKind["SkippedTokenTrivia"] = 8] = "SkippedTokenTrivia"; - - SyntaxKind[SyntaxKind["ErrorToken"] = 9] = "ErrorToken"; - SyntaxKind[SyntaxKind["EndOfFileToken"] = 10] = "EndOfFileToken"; - - SyntaxKind[SyntaxKind["IdentifierName"] = 11] = "IdentifierName"; - - SyntaxKind[SyntaxKind["RegularExpressionLiteral"] = 12] = "RegularExpressionLiteral"; - SyntaxKind[SyntaxKind["NumericLiteral"] = 13] = "NumericLiteral"; - SyntaxKind[SyntaxKind["StringLiteral"] = 14] = "StringLiteral"; - - SyntaxKind[SyntaxKind["BreakKeyword"] = 15] = "BreakKeyword"; - SyntaxKind[SyntaxKind["CaseKeyword"] = 16] = "CaseKeyword"; - SyntaxKind[SyntaxKind["CatchKeyword"] = 17] = "CatchKeyword"; - SyntaxKind[SyntaxKind["ContinueKeyword"] = 18] = "ContinueKeyword"; - SyntaxKind[SyntaxKind["DebuggerKeyword"] = 19] = "DebuggerKeyword"; - SyntaxKind[SyntaxKind["DefaultKeyword"] = 20] = "DefaultKeyword"; - SyntaxKind[SyntaxKind["DeleteKeyword"] = 21] = "DeleteKeyword"; - SyntaxKind[SyntaxKind["DoKeyword"] = 22] = "DoKeyword"; - SyntaxKind[SyntaxKind["ElseKeyword"] = 23] = "ElseKeyword"; - SyntaxKind[SyntaxKind["FalseKeyword"] = 24] = "FalseKeyword"; - SyntaxKind[SyntaxKind["FinallyKeyword"] = 25] = "FinallyKeyword"; - SyntaxKind[SyntaxKind["ForKeyword"] = 26] = "ForKeyword"; - SyntaxKind[SyntaxKind["FunctionKeyword"] = 27] = "FunctionKeyword"; - SyntaxKind[SyntaxKind["IfKeyword"] = 28] = "IfKeyword"; - SyntaxKind[SyntaxKind["InKeyword"] = 29] = "InKeyword"; - SyntaxKind[SyntaxKind["InstanceOfKeyword"] = 30] = "InstanceOfKeyword"; - SyntaxKind[SyntaxKind["NewKeyword"] = 31] = "NewKeyword"; - SyntaxKind[SyntaxKind["NullKeyword"] = 32] = "NullKeyword"; - SyntaxKind[SyntaxKind["ReturnKeyword"] = 33] = "ReturnKeyword"; - SyntaxKind[SyntaxKind["SwitchKeyword"] = 34] = "SwitchKeyword"; - SyntaxKind[SyntaxKind["ThisKeyword"] = 35] = "ThisKeyword"; - SyntaxKind[SyntaxKind["ThrowKeyword"] = 36] = "ThrowKeyword"; - SyntaxKind[SyntaxKind["TrueKeyword"] = 37] = "TrueKeyword"; - SyntaxKind[SyntaxKind["TryKeyword"] = 38] = "TryKeyword"; - SyntaxKind[SyntaxKind["TypeOfKeyword"] = 39] = "TypeOfKeyword"; - SyntaxKind[SyntaxKind["VarKeyword"] = 40] = "VarKeyword"; - SyntaxKind[SyntaxKind["VoidKeyword"] = 41] = "VoidKeyword"; - SyntaxKind[SyntaxKind["WhileKeyword"] = 42] = "WhileKeyword"; - SyntaxKind[SyntaxKind["WithKeyword"] = 43] = "WithKeyword"; - - SyntaxKind[SyntaxKind["ClassKeyword"] = 44] = "ClassKeyword"; - SyntaxKind[SyntaxKind["ConstKeyword"] = 45] = "ConstKeyword"; - SyntaxKind[SyntaxKind["EnumKeyword"] = 46] = "EnumKeyword"; - SyntaxKind[SyntaxKind["ExportKeyword"] = 47] = "ExportKeyword"; - SyntaxKind[SyntaxKind["ExtendsKeyword"] = 48] = "ExtendsKeyword"; - SyntaxKind[SyntaxKind["ImportKeyword"] = 49] = "ImportKeyword"; - SyntaxKind[SyntaxKind["SuperKeyword"] = 50] = "SuperKeyword"; - - SyntaxKind[SyntaxKind["ImplementsKeyword"] = 51] = "ImplementsKeyword"; - SyntaxKind[SyntaxKind["InterfaceKeyword"] = 52] = "InterfaceKeyword"; - SyntaxKind[SyntaxKind["LetKeyword"] = 53] = "LetKeyword"; - SyntaxKind[SyntaxKind["PackageKeyword"] = 54] = "PackageKeyword"; - SyntaxKind[SyntaxKind["PrivateKeyword"] = 55] = "PrivateKeyword"; - SyntaxKind[SyntaxKind["ProtectedKeyword"] = 56] = "ProtectedKeyword"; - SyntaxKind[SyntaxKind["PublicKeyword"] = 57] = "PublicKeyword"; - SyntaxKind[SyntaxKind["StaticKeyword"] = 58] = "StaticKeyword"; - SyntaxKind[SyntaxKind["YieldKeyword"] = 59] = "YieldKeyword"; - - SyntaxKind[SyntaxKind["AnyKeyword"] = 60] = "AnyKeyword"; - SyntaxKind[SyntaxKind["BooleanKeyword"] = 61] = "BooleanKeyword"; - SyntaxKind[SyntaxKind["BoolKeyword"] = 62] = "BoolKeyword"; - SyntaxKind[SyntaxKind["ConstructorKeyword"] = 63] = "ConstructorKeyword"; - SyntaxKind[SyntaxKind["DeclareKeyword"] = 64] = "DeclareKeyword"; - SyntaxKind[SyntaxKind["GetKeyword"] = 65] = "GetKeyword"; - SyntaxKind[SyntaxKind["ModuleKeyword"] = 66] = "ModuleKeyword"; - SyntaxKind[SyntaxKind["RequireKeyword"] = 67] = "RequireKeyword"; - SyntaxKind[SyntaxKind["NumberKeyword"] = 68] = "NumberKeyword"; - SyntaxKind[SyntaxKind["SetKeyword"] = 69] = "SetKeyword"; - SyntaxKind[SyntaxKind["StringKeyword"] = 70] = "StringKeyword"; - - SyntaxKind[SyntaxKind["OpenBraceToken"] = 71] = "OpenBraceToken"; - SyntaxKind[SyntaxKind["CloseBraceToken"] = 72] = "CloseBraceToken"; - SyntaxKind[SyntaxKind["OpenParenToken"] = 73] = "OpenParenToken"; - SyntaxKind[SyntaxKind["CloseParenToken"] = 74] = "CloseParenToken"; - SyntaxKind[SyntaxKind["OpenBracketToken"] = 75] = "OpenBracketToken"; - SyntaxKind[SyntaxKind["CloseBracketToken"] = 76] = "CloseBracketToken"; - SyntaxKind[SyntaxKind["DotToken"] = 77] = "DotToken"; - SyntaxKind[SyntaxKind["DotDotDotToken"] = 78] = "DotDotDotToken"; - SyntaxKind[SyntaxKind["SemicolonToken"] = 79] = "SemicolonToken"; - SyntaxKind[SyntaxKind["CommaToken"] = 80] = "CommaToken"; - SyntaxKind[SyntaxKind["LessThanToken"] = 81] = "LessThanToken"; - SyntaxKind[SyntaxKind["GreaterThanToken"] = 82] = "GreaterThanToken"; - SyntaxKind[SyntaxKind["LessThanEqualsToken"] = 83] = "LessThanEqualsToken"; - SyntaxKind[SyntaxKind["GreaterThanEqualsToken"] = 84] = "GreaterThanEqualsToken"; - SyntaxKind[SyntaxKind["EqualsEqualsToken"] = 85] = "EqualsEqualsToken"; - SyntaxKind[SyntaxKind["EqualsGreaterThanToken"] = 86] = "EqualsGreaterThanToken"; - SyntaxKind[SyntaxKind["ExclamationEqualsToken"] = 87] = "ExclamationEqualsToken"; - SyntaxKind[SyntaxKind["EqualsEqualsEqualsToken"] = 88] = "EqualsEqualsEqualsToken"; - SyntaxKind[SyntaxKind["ExclamationEqualsEqualsToken"] = 89] = "ExclamationEqualsEqualsToken"; - SyntaxKind[SyntaxKind["PlusToken"] = 90] = "PlusToken"; - SyntaxKind[SyntaxKind["MinusToken"] = 91] = "MinusToken"; - SyntaxKind[SyntaxKind["AsteriskToken"] = 92] = "AsteriskToken"; - SyntaxKind[SyntaxKind["PercentToken"] = 93] = "PercentToken"; - SyntaxKind[SyntaxKind["PlusPlusToken"] = 94] = "PlusPlusToken"; - SyntaxKind[SyntaxKind["MinusMinusToken"] = 95] = "MinusMinusToken"; - SyntaxKind[SyntaxKind["LessThanLessThanToken"] = 96] = "LessThanLessThanToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanToken"] = 97] = "GreaterThanGreaterThanToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanToken"] = 98] = "GreaterThanGreaterThanGreaterThanToken"; - SyntaxKind[SyntaxKind["AmpersandToken"] = 99] = "AmpersandToken"; - SyntaxKind[SyntaxKind["BarToken"] = 100] = "BarToken"; - SyntaxKind[SyntaxKind["CaretToken"] = 101] = "CaretToken"; - SyntaxKind[SyntaxKind["ExclamationToken"] = 102] = "ExclamationToken"; - SyntaxKind[SyntaxKind["TildeToken"] = 103] = "TildeToken"; - SyntaxKind[SyntaxKind["AmpersandAmpersandToken"] = 104] = "AmpersandAmpersandToken"; - SyntaxKind[SyntaxKind["BarBarToken"] = 105] = "BarBarToken"; - SyntaxKind[SyntaxKind["QuestionToken"] = 106] = "QuestionToken"; - SyntaxKind[SyntaxKind["ColonToken"] = 107] = "ColonToken"; - SyntaxKind[SyntaxKind["EqualsToken"] = 108] = "EqualsToken"; - SyntaxKind[SyntaxKind["PlusEqualsToken"] = 109] = "PlusEqualsToken"; - SyntaxKind[SyntaxKind["MinusEqualsToken"] = 110] = "MinusEqualsToken"; - SyntaxKind[SyntaxKind["AsteriskEqualsToken"] = 111] = "AsteriskEqualsToken"; - SyntaxKind[SyntaxKind["PercentEqualsToken"] = 112] = "PercentEqualsToken"; - SyntaxKind[SyntaxKind["LessThanLessThanEqualsToken"] = 113] = "LessThanLessThanEqualsToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanEqualsToken"] = 114] = "GreaterThanGreaterThanEqualsToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanEqualsToken"] = 115] = "GreaterThanGreaterThanGreaterThanEqualsToken"; - SyntaxKind[SyntaxKind["AmpersandEqualsToken"] = 116] = "AmpersandEqualsToken"; - SyntaxKind[SyntaxKind["BarEqualsToken"] = 117] = "BarEqualsToken"; - SyntaxKind[SyntaxKind["CaretEqualsToken"] = 118] = "CaretEqualsToken"; - SyntaxKind[SyntaxKind["SlashToken"] = 119] = "SlashToken"; - SyntaxKind[SyntaxKind["SlashEqualsToken"] = 120] = "SlashEqualsToken"; - - SyntaxKind[SyntaxKind["SourceUnit"] = 121] = "SourceUnit"; - - SyntaxKind[SyntaxKind["QualifiedName"] = 122] = "QualifiedName"; - - SyntaxKind[SyntaxKind["ObjectType"] = 123] = "ObjectType"; - SyntaxKind[SyntaxKind["FunctionType"] = 124] = "FunctionType"; - SyntaxKind[SyntaxKind["ArrayType"] = 125] = "ArrayType"; - SyntaxKind[SyntaxKind["ConstructorType"] = 126] = "ConstructorType"; - SyntaxKind[SyntaxKind["GenericType"] = 127] = "GenericType"; - - SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 128] = "InterfaceDeclaration"; - SyntaxKind[SyntaxKind["FunctionDeclaration"] = 129] = "FunctionDeclaration"; - SyntaxKind[SyntaxKind["ModuleDeclaration"] = 130] = "ModuleDeclaration"; - SyntaxKind[SyntaxKind["ClassDeclaration"] = 131] = "ClassDeclaration"; - SyntaxKind[SyntaxKind["EnumDeclaration"] = 132] = "EnumDeclaration"; - SyntaxKind[SyntaxKind["ImportDeclaration"] = 133] = "ImportDeclaration"; - SyntaxKind[SyntaxKind["ExportAssignment"] = 134] = "ExportAssignment"; - - SyntaxKind[SyntaxKind["MemberFunctionDeclaration"] = 135] = "MemberFunctionDeclaration"; - SyntaxKind[SyntaxKind["MemberVariableDeclaration"] = 136] = "MemberVariableDeclaration"; - SyntaxKind[SyntaxKind["ConstructorDeclaration"] = 137] = "ConstructorDeclaration"; - SyntaxKind[SyntaxKind["GetMemberAccessorDeclaration"] = 138] = "GetMemberAccessorDeclaration"; - SyntaxKind[SyntaxKind["SetMemberAccessorDeclaration"] = 139] = "SetMemberAccessorDeclaration"; - - SyntaxKind[SyntaxKind["PropertySignature"] = 140] = "PropertySignature"; - SyntaxKind[SyntaxKind["CallSignature"] = 141] = "CallSignature"; - SyntaxKind[SyntaxKind["ConstructSignature"] = 142] = "ConstructSignature"; - SyntaxKind[SyntaxKind["IndexSignature"] = 143] = "IndexSignature"; - SyntaxKind[SyntaxKind["MethodSignature"] = 144] = "MethodSignature"; - - SyntaxKind[SyntaxKind["Block"] = 145] = "Block"; - SyntaxKind[SyntaxKind["IfStatement"] = 146] = "IfStatement"; - SyntaxKind[SyntaxKind["VariableStatement"] = 147] = "VariableStatement"; - SyntaxKind[SyntaxKind["ExpressionStatement"] = 148] = "ExpressionStatement"; - SyntaxKind[SyntaxKind["ReturnStatement"] = 149] = "ReturnStatement"; - SyntaxKind[SyntaxKind["SwitchStatement"] = 150] = "SwitchStatement"; - SyntaxKind[SyntaxKind["BreakStatement"] = 151] = "BreakStatement"; - SyntaxKind[SyntaxKind["ContinueStatement"] = 152] = "ContinueStatement"; - SyntaxKind[SyntaxKind["ForStatement"] = 153] = "ForStatement"; - SyntaxKind[SyntaxKind["ForInStatement"] = 154] = "ForInStatement"; - SyntaxKind[SyntaxKind["EmptyStatement"] = 155] = "EmptyStatement"; - SyntaxKind[SyntaxKind["ThrowStatement"] = 156] = "ThrowStatement"; - SyntaxKind[SyntaxKind["WhileStatement"] = 157] = "WhileStatement"; - SyntaxKind[SyntaxKind["TryStatement"] = 158] = "TryStatement"; - SyntaxKind[SyntaxKind["LabeledStatement"] = 159] = "LabeledStatement"; - SyntaxKind[SyntaxKind["DoStatement"] = 160] = "DoStatement"; - SyntaxKind[SyntaxKind["DebuggerStatement"] = 161] = "DebuggerStatement"; - SyntaxKind[SyntaxKind["WithStatement"] = 162] = "WithStatement"; - - SyntaxKind[SyntaxKind["PlusExpression"] = 163] = "PlusExpression"; - SyntaxKind[SyntaxKind["NegateExpression"] = 164] = "NegateExpression"; - SyntaxKind[SyntaxKind["BitwiseNotExpression"] = 165] = "BitwiseNotExpression"; - SyntaxKind[SyntaxKind["LogicalNotExpression"] = 166] = "LogicalNotExpression"; - SyntaxKind[SyntaxKind["PreIncrementExpression"] = 167] = "PreIncrementExpression"; - SyntaxKind[SyntaxKind["PreDecrementExpression"] = 168] = "PreDecrementExpression"; - SyntaxKind[SyntaxKind["DeleteExpression"] = 169] = "DeleteExpression"; - SyntaxKind[SyntaxKind["TypeOfExpression"] = 170] = "TypeOfExpression"; - SyntaxKind[SyntaxKind["VoidExpression"] = 171] = "VoidExpression"; - SyntaxKind[SyntaxKind["CommaExpression"] = 172] = "CommaExpression"; - SyntaxKind[SyntaxKind["AssignmentExpression"] = 173] = "AssignmentExpression"; - SyntaxKind[SyntaxKind["AddAssignmentExpression"] = 174] = "AddAssignmentExpression"; - SyntaxKind[SyntaxKind["SubtractAssignmentExpression"] = 175] = "SubtractAssignmentExpression"; - SyntaxKind[SyntaxKind["MultiplyAssignmentExpression"] = 176] = "MultiplyAssignmentExpression"; - SyntaxKind[SyntaxKind["DivideAssignmentExpression"] = 177] = "DivideAssignmentExpression"; - SyntaxKind[SyntaxKind["ModuloAssignmentExpression"] = 178] = "ModuloAssignmentExpression"; - SyntaxKind[SyntaxKind["AndAssignmentExpression"] = 179] = "AndAssignmentExpression"; - SyntaxKind[SyntaxKind["ExclusiveOrAssignmentExpression"] = 180] = "ExclusiveOrAssignmentExpression"; - SyntaxKind[SyntaxKind["OrAssignmentExpression"] = 181] = "OrAssignmentExpression"; - SyntaxKind[SyntaxKind["LeftShiftAssignmentExpression"] = 182] = "LeftShiftAssignmentExpression"; - SyntaxKind[SyntaxKind["SignedRightShiftAssignmentExpression"] = 183] = "SignedRightShiftAssignmentExpression"; - SyntaxKind[SyntaxKind["UnsignedRightShiftAssignmentExpression"] = 184] = "UnsignedRightShiftAssignmentExpression"; - SyntaxKind[SyntaxKind["ConditionalExpression"] = 185] = "ConditionalExpression"; - SyntaxKind[SyntaxKind["LogicalOrExpression"] = 186] = "LogicalOrExpression"; - SyntaxKind[SyntaxKind["LogicalAndExpression"] = 187] = "LogicalAndExpression"; - SyntaxKind[SyntaxKind["BitwiseOrExpression"] = 188] = "BitwiseOrExpression"; - SyntaxKind[SyntaxKind["BitwiseExclusiveOrExpression"] = 189] = "BitwiseExclusiveOrExpression"; - SyntaxKind[SyntaxKind["BitwiseAndExpression"] = 190] = "BitwiseAndExpression"; - SyntaxKind[SyntaxKind["EqualsWithTypeConversionExpression"] = 191] = "EqualsWithTypeConversionExpression"; - SyntaxKind[SyntaxKind["NotEqualsWithTypeConversionExpression"] = 192] = "NotEqualsWithTypeConversionExpression"; - SyntaxKind[SyntaxKind["EqualsExpression"] = 193] = "EqualsExpression"; - SyntaxKind[SyntaxKind["NotEqualsExpression"] = 194] = "NotEqualsExpression"; - SyntaxKind[SyntaxKind["LessThanExpression"] = 195] = "LessThanExpression"; - SyntaxKind[SyntaxKind["GreaterThanExpression"] = 196] = "GreaterThanExpression"; - SyntaxKind[SyntaxKind["LessThanOrEqualExpression"] = 197] = "LessThanOrEqualExpression"; - SyntaxKind[SyntaxKind["GreaterThanOrEqualExpression"] = 198] = "GreaterThanOrEqualExpression"; - SyntaxKind[SyntaxKind["InstanceOfExpression"] = 199] = "InstanceOfExpression"; - SyntaxKind[SyntaxKind["InExpression"] = 200] = "InExpression"; - SyntaxKind[SyntaxKind["LeftShiftExpression"] = 201] = "LeftShiftExpression"; - SyntaxKind[SyntaxKind["SignedRightShiftExpression"] = 202] = "SignedRightShiftExpression"; - SyntaxKind[SyntaxKind["UnsignedRightShiftExpression"] = 203] = "UnsignedRightShiftExpression"; - SyntaxKind[SyntaxKind["MultiplyExpression"] = 204] = "MultiplyExpression"; - SyntaxKind[SyntaxKind["DivideExpression"] = 205] = "DivideExpression"; - SyntaxKind[SyntaxKind["ModuloExpression"] = 206] = "ModuloExpression"; - SyntaxKind[SyntaxKind["AddExpression"] = 207] = "AddExpression"; - SyntaxKind[SyntaxKind["SubtractExpression"] = 208] = "SubtractExpression"; - SyntaxKind[SyntaxKind["PostIncrementExpression"] = 209] = "PostIncrementExpression"; - SyntaxKind[SyntaxKind["PostDecrementExpression"] = 210] = "PostDecrementExpression"; - SyntaxKind[SyntaxKind["MemberAccessExpression"] = 211] = "MemberAccessExpression"; - SyntaxKind[SyntaxKind["InvocationExpression"] = 212] = "InvocationExpression"; - SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 213] = "ArrayLiteralExpression"; - SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 214] = "ObjectLiteralExpression"; - SyntaxKind[SyntaxKind["ObjectCreationExpression"] = 215] = "ObjectCreationExpression"; - SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 216] = "ParenthesizedExpression"; - SyntaxKind[SyntaxKind["ParenthesizedArrowFunctionExpression"] = 217] = "ParenthesizedArrowFunctionExpression"; - SyntaxKind[SyntaxKind["SimpleArrowFunctionExpression"] = 218] = "SimpleArrowFunctionExpression"; - SyntaxKind[SyntaxKind["CastExpression"] = 219] = "CastExpression"; - SyntaxKind[SyntaxKind["ElementAccessExpression"] = 220] = "ElementAccessExpression"; - SyntaxKind[SyntaxKind["FunctionExpression"] = 221] = "FunctionExpression"; - SyntaxKind[SyntaxKind["OmittedExpression"] = 222] = "OmittedExpression"; - - SyntaxKind[SyntaxKind["VariableDeclaration"] = 223] = "VariableDeclaration"; - SyntaxKind[SyntaxKind["VariableDeclarator"] = 224] = "VariableDeclarator"; - - SyntaxKind[SyntaxKind["ArgumentList"] = 225] = "ArgumentList"; - SyntaxKind[SyntaxKind["ParameterList"] = 226] = "ParameterList"; - SyntaxKind[SyntaxKind["TypeArgumentList"] = 227] = "TypeArgumentList"; - SyntaxKind[SyntaxKind["TypeParameterList"] = 228] = "TypeParameterList"; - - SyntaxKind[SyntaxKind["HeritageClause"] = 229] = "HeritageClause"; - SyntaxKind[SyntaxKind["EqualsValueClause"] = 230] = "EqualsValueClause"; - SyntaxKind[SyntaxKind["CaseSwitchClause"] = 231] = "CaseSwitchClause"; - SyntaxKind[SyntaxKind["DefaultSwitchClause"] = 232] = "DefaultSwitchClause"; - SyntaxKind[SyntaxKind["ElseClause"] = 233] = "ElseClause"; - SyntaxKind[SyntaxKind["CatchClause"] = 234] = "CatchClause"; - SyntaxKind[SyntaxKind["FinallyClause"] = 235] = "FinallyClause"; - - SyntaxKind[SyntaxKind["TypeParameter"] = 236] = "TypeParameter"; - SyntaxKind[SyntaxKind["Constraint"] = 237] = "Constraint"; - - SyntaxKind[SyntaxKind["SimplePropertyAssignment"] = 238] = "SimplePropertyAssignment"; - SyntaxKind[SyntaxKind["GetAccessorPropertyAssignment"] = 239] = "GetAccessorPropertyAssignment"; - SyntaxKind[SyntaxKind["SetAccessorPropertyAssignment"] = 240] = "SetAccessorPropertyAssignment"; - SyntaxKind[SyntaxKind["FunctionPropertyAssignment"] = 241] = "FunctionPropertyAssignment"; - - SyntaxKind[SyntaxKind["Parameter"] = 242] = "Parameter"; - SyntaxKind[SyntaxKind["EnumElement"] = 243] = "EnumElement"; - SyntaxKind[SyntaxKind["TypeAnnotation"] = 244] = "TypeAnnotation"; - SyntaxKind[SyntaxKind["ExternalModuleReference"] = 245] = "ExternalModuleReference"; - SyntaxKind[SyntaxKind["ModuleNameModuleReference"] = 246] = "ModuleNameModuleReference"; - - SyntaxKind[SyntaxKind["FirstStandardKeyword"] = SyntaxKind.BreakKeyword] = "FirstStandardKeyword"; - SyntaxKind[SyntaxKind["LastStandardKeyword"] = SyntaxKind.WithKeyword] = "LastStandardKeyword"; - - SyntaxKind[SyntaxKind["FirstFutureReservedKeyword"] = SyntaxKind.ClassKeyword] = "FirstFutureReservedKeyword"; - SyntaxKind[SyntaxKind["LastFutureReservedKeyword"] = SyntaxKind.SuperKeyword] = "LastFutureReservedKeyword"; - - SyntaxKind[SyntaxKind["FirstFutureReservedStrictKeyword"] = SyntaxKind.ImplementsKeyword] = "FirstFutureReservedStrictKeyword"; - SyntaxKind[SyntaxKind["LastFutureReservedStrictKeyword"] = SyntaxKind.YieldKeyword] = "LastFutureReservedStrictKeyword"; - - SyntaxKind[SyntaxKind["FirstTypeScriptKeyword"] = SyntaxKind.AnyKeyword] = "FirstTypeScriptKeyword"; - SyntaxKind[SyntaxKind["LastTypeScriptKeyword"] = SyntaxKind.StringKeyword] = "LastTypeScriptKeyword"; - - SyntaxKind[SyntaxKind["FirstKeyword"] = SyntaxKind.FirstStandardKeyword] = "FirstKeyword"; - SyntaxKind[SyntaxKind["LastKeyword"] = SyntaxKind.LastTypeScriptKeyword] = "LastKeyword"; - - SyntaxKind[SyntaxKind["FirstToken"] = SyntaxKind.ErrorToken] = "FirstToken"; - SyntaxKind[SyntaxKind["LastToken"] = SyntaxKind.SlashEqualsToken] = "LastToken"; - - SyntaxKind[SyntaxKind["FirstPunctuation"] = SyntaxKind.OpenBraceToken] = "FirstPunctuation"; - SyntaxKind[SyntaxKind["LastPunctuation"] = SyntaxKind.SlashEqualsToken] = "LastPunctuation"; - - SyntaxKind[SyntaxKind["FirstFixedWidth"] = SyntaxKind.FirstKeyword] = "FirstFixedWidth"; - SyntaxKind[SyntaxKind["LastFixedWidth"] = SyntaxKind.LastPunctuation] = "LastFixedWidth"; - })(TypeScript.SyntaxKind || (TypeScript.SyntaxKind = {})); - var SyntaxKind = TypeScript.SyntaxKind; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (SyntaxFacts) { - var textToKeywordKind = { - "any": 60 /* AnyKeyword */, - "bool": 62 /* BoolKeyword */, - "boolean": 61 /* BooleanKeyword */, - "break": 15 /* BreakKeyword */, - "case": 16 /* CaseKeyword */, - "catch": 17 /* CatchKeyword */, - "class": 44 /* ClassKeyword */, - "continue": 18 /* ContinueKeyword */, - "const": 45 /* ConstKeyword */, - "constructor": 63 /* ConstructorKeyword */, - "debugger": 19 /* DebuggerKeyword */, - "declare": 64 /* DeclareKeyword */, - "default": 20 /* DefaultKeyword */, - "delete": 21 /* DeleteKeyword */, - "do": 22 /* DoKeyword */, - "else": 23 /* ElseKeyword */, - "enum": 46 /* EnumKeyword */, - "export": 47 /* ExportKeyword */, - "extends": 48 /* ExtendsKeyword */, - "false": 24 /* FalseKeyword */, - "finally": 25 /* FinallyKeyword */, - "for": 26 /* ForKeyword */, - "function": 27 /* FunctionKeyword */, - "get": 65 /* GetKeyword */, - "if": 28 /* IfKeyword */, - "implements": 51 /* ImplementsKeyword */, - "import": 49 /* ImportKeyword */, - "in": 29 /* InKeyword */, - "instanceof": 30 /* InstanceOfKeyword */, - "interface": 52 /* InterfaceKeyword */, - "let": 53 /* LetKeyword */, - "module": 66 /* ModuleKeyword */, - "new": 31 /* NewKeyword */, - "null": 32 /* NullKeyword */, - "number": 68 /* NumberKeyword */, - "package": 54 /* PackageKeyword */, - "private": 55 /* PrivateKeyword */, - "protected": 56 /* ProtectedKeyword */, - "public": 57 /* PublicKeyword */, - "require": 67 /* RequireKeyword */, - "return": 33 /* ReturnKeyword */, - "set": 69 /* SetKeyword */, - "static": 58 /* StaticKeyword */, - "string": 70 /* StringKeyword */, - "super": 50 /* SuperKeyword */, - "switch": 34 /* SwitchKeyword */, - "this": 35 /* ThisKeyword */, - "throw": 36 /* ThrowKeyword */, - "true": 37 /* TrueKeyword */, - "try": 38 /* TryKeyword */, - "typeof": 39 /* TypeOfKeyword */, - "var": 40 /* VarKeyword */, - "void": 41 /* VoidKeyword */, - "while": 42 /* WhileKeyword */, - "with": 43 /* WithKeyword */, - "yield": 59 /* YieldKeyword */, - "{": 71 /* OpenBraceToken */, - "}": 72 /* CloseBraceToken */, - "(": 73 /* OpenParenToken */, - ")": 74 /* CloseParenToken */, - "[": 75 /* OpenBracketToken */, - "]": 76 /* CloseBracketToken */, - ".": 77 /* DotToken */, - "...": 78 /* DotDotDotToken */, - ";": 79 /* SemicolonToken */, - ",": 80 /* CommaToken */, - "<": 81 /* LessThanToken */, - ">": 82 /* GreaterThanToken */, - "<=": 83 /* LessThanEqualsToken */, - ">=": 84 /* GreaterThanEqualsToken */, - "==": 85 /* EqualsEqualsToken */, - "=>": 86 /* EqualsGreaterThanToken */, - "!=": 87 /* ExclamationEqualsToken */, - "===": 88 /* EqualsEqualsEqualsToken */, - "!==": 89 /* ExclamationEqualsEqualsToken */, - "+": 90 /* PlusToken */, - "-": 91 /* MinusToken */, - "*": 92 /* AsteriskToken */, - "%": 93 /* PercentToken */, - "++": 94 /* PlusPlusToken */, - "--": 95 /* MinusMinusToken */, - "<<": 96 /* LessThanLessThanToken */, - ">>": 97 /* GreaterThanGreaterThanToken */, - ">>>": 98 /* GreaterThanGreaterThanGreaterThanToken */, - "&": 99 /* AmpersandToken */, - "|": 100 /* BarToken */, - "^": 101 /* CaretToken */, - "!": 102 /* ExclamationToken */, - "~": 103 /* TildeToken */, - "&&": 104 /* AmpersandAmpersandToken */, - "||": 105 /* BarBarToken */, - "?": 106 /* QuestionToken */, - ":": 107 /* ColonToken */, - "=": 108 /* EqualsToken */, - "+=": 109 /* PlusEqualsToken */, - "-=": 110 /* MinusEqualsToken */, - "*=": 111 /* AsteriskEqualsToken */, - "%=": 112 /* PercentEqualsToken */, - "<<=": 113 /* LessThanLessThanEqualsToken */, - ">>=": 114 /* GreaterThanGreaterThanEqualsToken */, - ">>>=": 115 /* GreaterThanGreaterThanGreaterThanEqualsToken */, - "&=": 116 /* AmpersandEqualsToken */, - "|=": 117 /* BarEqualsToken */, - "^=": 118 /* CaretEqualsToken */, - "/": 119 /* SlashToken */, - "/=": 120 /* SlashEqualsToken */ - }; - - var kindToText = []; - - for (var name in textToKeywordKind) { - if (textToKeywordKind.hasOwnProperty(name)) { - kindToText[textToKeywordKind[name]] = name; - } - } - - kindToText[63 /* ConstructorKeyword */] = "constructor"; - - function getTokenKind(text) { - if (textToKeywordKind.hasOwnProperty(text)) { - return textToKeywordKind[text]; - } - - return 0 /* None */; - } - SyntaxFacts.getTokenKind = getTokenKind; - - function getText(kind) { - var result = kindToText[kind]; - return result !== undefined ? result : null; - } - SyntaxFacts.getText = getText; - - function isTokenKind(kind) { - return kind >= 9 /* FirstToken */ && kind <= 120 /* LastToken */; - } - SyntaxFacts.isTokenKind = isTokenKind; - - function isAnyKeyword(kind) { - return kind >= TypeScript.SyntaxKind.FirstKeyword && kind <= TypeScript.SyntaxKind.LastKeyword; - } - SyntaxFacts.isAnyKeyword = isAnyKeyword; - - function isStandardKeyword(kind) { - return kind >= 15 /* FirstStandardKeyword */ && kind <= 43 /* LastStandardKeyword */; - } - SyntaxFacts.isStandardKeyword = isStandardKeyword; - - function isFutureReservedKeyword(kind) { - return kind >= 44 /* FirstFutureReservedKeyword */ && kind <= 50 /* LastFutureReservedKeyword */; - } - SyntaxFacts.isFutureReservedKeyword = isFutureReservedKeyword; - - function isFutureReservedStrictKeyword(kind) { - return kind >= 51 /* FirstFutureReservedStrictKeyword */ && kind <= 59 /* LastFutureReservedStrictKeyword */; - } - SyntaxFacts.isFutureReservedStrictKeyword = isFutureReservedStrictKeyword; - - function isAnyPunctuation(kind) { - return kind >= 71 /* FirstPunctuation */ && kind <= 120 /* LastPunctuation */; - } - SyntaxFacts.isAnyPunctuation = isAnyPunctuation; - - function isPrefixUnaryExpressionOperatorToken(tokenKind) { - return getPrefixUnaryExpressionFromOperatorToken(tokenKind) !== 0 /* None */; - } - SyntaxFacts.isPrefixUnaryExpressionOperatorToken = isPrefixUnaryExpressionOperatorToken; - - function isBinaryExpressionOperatorToken(tokenKind) { - return getBinaryExpressionFromOperatorToken(tokenKind) !== 0 /* None */; - } - SyntaxFacts.isBinaryExpressionOperatorToken = isBinaryExpressionOperatorToken; - - function getPrefixUnaryExpressionFromOperatorToken(tokenKind) { - switch (tokenKind) { - case 90 /* PlusToken */: - return 163 /* PlusExpression */; - case 91 /* MinusToken */: - return 164 /* NegateExpression */; - case 103 /* TildeToken */: - return 165 /* BitwiseNotExpression */; - case 102 /* ExclamationToken */: - return 166 /* LogicalNotExpression */; - case 94 /* PlusPlusToken */: - return 167 /* PreIncrementExpression */; - case 95 /* MinusMinusToken */: - return 168 /* PreDecrementExpression */; - - default: - return 0 /* None */; - } - } - SyntaxFacts.getPrefixUnaryExpressionFromOperatorToken = getPrefixUnaryExpressionFromOperatorToken; - - function getPostfixUnaryExpressionFromOperatorToken(tokenKind) { - switch (tokenKind) { - case 94 /* PlusPlusToken */: - return 209 /* PostIncrementExpression */; - case 95 /* MinusMinusToken */: - return 210 /* PostDecrementExpression */; - default: - return 0 /* None */; - } - } - SyntaxFacts.getPostfixUnaryExpressionFromOperatorToken = getPostfixUnaryExpressionFromOperatorToken; - - function getBinaryExpressionFromOperatorToken(tokenKind) { - switch (tokenKind) { - case 92 /* AsteriskToken */: - return 204 /* MultiplyExpression */; - - case 119 /* SlashToken */: - return 205 /* DivideExpression */; - - case 93 /* PercentToken */: - return 206 /* ModuloExpression */; - - case 90 /* PlusToken */: - return 207 /* AddExpression */; - - case 91 /* MinusToken */: - return 208 /* SubtractExpression */; - - case 96 /* LessThanLessThanToken */: - return 201 /* LeftShiftExpression */; - - case 97 /* GreaterThanGreaterThanToken */: - return 202 /* SignedRightShiftExpression */; - - case 98 /* GreaterThanGreaterThanGreaterThanToken */: - return 203 /* UnsignedRightShiftExpression */; - - case 81 /* LessThanToken */: - return 195 /* LessThanExpression */; - - case 82 /* GreaterThanToken */: - return 196 /* GreaterThanExpression */; - - case 83 /* LessThanEqualsToken */: - return 197 /* LessThanOrEqualExpression */; - - case 84 /* GreaterThanEqualsToken */: - return 198 /* GreaterThanOrEqualExpression */; - - case 30 /* InstanceOfKeyword */: - return 199 /* InstanceOfExpression */; - - case 29 /* InKeyword */: - return 200 /* InExpression */; - - case 85 /* EqualsEqualsToken */: - return 191 /* EqualsWithTypeConversionExpression */; - - case 87 /* ExclamationEqualsToken */: - return 192 /* NotEqualsWithTypeConversionExpression */; - - case 88 /* EqualsEqualsEqualsToken */: - return 193 /* EqualsExpression */; - - case 89 /* ExclamationEqualsEqualsToken */: - return 194 /* NotEqualsExpression */; - - case 99 /* AmpersandToken */: - return 190 /* BitwiseAndExpression */; - - case 101 /* CaretToken */: - return 189 /* BitwiseExclusiveOrExpression */; - - case 100 /* BarToken */: - return 188 /* BitwiseOrExpression */; - - case 104 /* AmpersandAmpersandToken */: - return 187 /* LogicalAndExpression */; - - case 105 /* BarBarToken */: - return 186 /* LogicalOrExpression */; - - case 117 /* BarEqualsToken */: - return 181 /* OrAssignmentExpression */; - - case 116 /* AmpersandEqualsToken */: - return 179 /* AndAssignmentExpression */; - - case 118 /* CaretEqualsToken */: - return 180 /* ExclusiveOrAssignmentExpression */; - - case 113 /* LessThanLessThanEqualsToken */: - return 182 /* LeftShiftAssignmentExpression */; - - case 114 /* GreaterThanGreaterThanEqualsToken */: - return 183 /* SignedRightShiftAssignmentExpression */; - - case 115 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - return 184 /* UnsignedRightShiftAssignmentExpression */; - - case 109 /* PlusEqualsToken */: - return 174 /* AddAssignmentExpression */; - - case 110 /* MinusEqualsToken */: - return 175 /* SubtractAssignmentExpression */; - - case 111 /* AsteriskEqualsToken */: - return 176 /* MultiplyAssignmentExpression */; - - case 120 /* SlashEqualsToken */: - return 177 /* DivideAssignmentExpression */; - - case 112 /* PercentEqualsToken */: - return 178 /* ModuloAssignmentExpression */; - - case 108 /* EqualsToken */: - return 173 /* AssignmentExpression */; - - case 80 /* CommaToken */: - return 172 /* CommaExpression */; - - default: - return 0 /* None */; - } - } - SyntaxFacts.getBinaryExpressionFromOperatorToken = getBinaryExpressionFromOperatorToken; - - function isAnyDivideToken(kind) { - switch (kind) { - case 119 /* SlashToken */: - case 120 /* SlashEqualsToken */: - return true; - default: - return false; - } - } - SyntaxFacts.isAnyDivideToken = isAnyDivideToken; - - function isAnyDivideOrRegularExpressionToken(kind) { - switch (kind) { - case 119 /* SlashToken */: - case 120 /* SlashEqualsToken */: - case 12 /* RegularExpressionLiteral */: - return true; - default: - return false; - } - } - SyntaxFacts.isAnyDivideOrRegularExpressionToken = isAnyDivideOrRegularExpressionToken; - - function isParserGenerated(kind) { - switch (kind) { - case 97 /* GreaterThanGreaterThanToken */: - case 98 /* GreaterThanGreaterThanGreaterThanToken */: - case 84 /* GreaterThanEqualsToken */: - case 114 /* GreaterThanGreaterThanEqualsToken */: - case 115 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - return true; - default: - return false; - } - } - SyntaxFacts.isParserGenerated = isParserGenerated; - - function isAnyBinaryExpression(kind) { - switch (kind) { - case 172 /* CommaExpression */: - case 173 /* AssignmentExpression */: - case 174 /* AddAssignmentExpression */: - case 175 /* SubtractAssignmentExpression */: - case 176 /* MultiplyAssignmentExpression */: - case 177 /* DivideAssignmentExpression */: - case 178 /* ModuloAssignmentExpression */: - case 179 /* AndAssignmentExpression */: - case 180 /* ExclusiveOrAssignmentExpression */: - case 181 /* OrAssignmentExpression */: - case 182 /* LeftShiftAssignmentExpression */: - case 183 /* SignedRightShiftAssignmentExpression */: - case 184 /* UnsignedRightShiftAssignmentExpression */: - case 186 /* LogicalOrExpression */: - case 187 /* LogicalAndExpression */: - case 188 /* BitwiseOrExpression */: - case 189 /* BitwiseExclusiveOrExpression */: - case 190 /* BitwiseAndExpression */: - case 191 /* EqualsWithTypeConversionExpression */: - case 192 /* NotEqualsWithTypeConversionExpression */: - case 193 /* EqualsExpression */: - case 194 /* NotEqualsExpression */: - case 195 /* LessThanExpression */: - case 196 /* GreaterThanExpression */: - case 197 /* LessThanOrEqualExpression */: - case 198 /* GreaterThanOrEqualExpression */: - case 199 /* InstanceOfExpression */: - case 200 /* InExpression */: - case 201 /* LeftShiftExpression */: - case 202 /* SignedRightShiftExpression */: - case 203 /* UnsignedRightShiftExpression */: - case 204 /* MultiplyExpression */: - case 205 /* DivideExpression */: - case 206 /* ModuloExpression */: - case 207 /* AddExpression */: - case 208 /* SubtractExpression */: - return true; - } - - return false; - } - SyntaxFacts.isAnyBinaryExpression = isAnyBinaryExpression; - })(TypeScript.SyntaxFacts || (TypeScript.SyntaxFacts = {})); - var SyntaxFacts = TypeScript.SyntaxFacts; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (SyntaxFacts) { - function isDirectivePrologueElement(node) { - if (node.kind() === 148 /* ExpressionStatement */) { - var expressionStatement = node; - var expression = expressionStatement.expression; - - if (expression.kind() === 14 /* StringLiteral */) { - return true; - } - } - - return false; - } - SyntaxFacts.isDirectivePrologueElement = isDirectivePrologueElement; - - function isUseStrictDirective(node) { - var expressionStatement = node; - var stringLiteral = expressionStatement.expression; - - var text = stringLiteral.text(); - return text === '"use strict"' || text === "'use strict'"; - } - SyntaxFacts.isUseStrictDirective = isUseStrictDirective; - - function isIdentifierNameOrAnyKeyword(token) { - var tokenKind = token.tokenKind; - return tokenKind === 11 /* IdentifierName */ || TypeScript.SyntaxFacts.isAnyKeyword(tokenKind); - } - SyntaxFacts.isIdentifierNameOrAnyKeyword = isIdentifierNameOrAnyKeyword; - })(TypeScript.SyntaxFacts || (TypeScript.SyntaxFacts = {})); - var SyntaxFacts = TypeScript.SyntaxFacts; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (Syntax) { - var EmptySyntaxList = (function () { - function EmptySyntaxList() { - } - EmptySyntaxList.prototype.kind = function () { - return 1 /* List */; - }; - - EmptySyntaxList.prototype.isNode = function () { - return false; - }; - EmptySyntaxList.prototype.isToken = function () { - return false; - }; - EmptySyntaxList.prototype.isList = function () { - return true; - }; - EmptySyntaxList.prototype.isSeparatedList = function () { - return false; - }; - - EmptySyntaxList.prototype.toJSON = function (key) { - return []; - }; - - EmptySyntaxList.prototype.childCount = function () { - return 0; - }; - - EmptySyntaxList.prototype.childAt = function (index) { - throw TypeScript.Errors.argumentOutOfRange("index"); - }; - - EmptySyntaxList.prototype.toArray = function () { - return []; - }; - - EmptySyntaxList.prototype.collectTextElements = function (elements) { - }; - - EmptySyntaxList.prototype.firstToken = function () { - return null; - }; - - EmptySyntaxList.prototype.lastToken = function () { - return null; - }; - - EmptySyntaxList.prototype.fullWidth = function () { - return 0; - }; - - EmptySyntaxList.prototype.width = function () { - return 0; - }; - - EmptySyntaxList.prototype.leadingTrivia = function () { - return TypeScript.Syntax.emptyTriviaList; - }; - - EmptySyntaxList.prototype.trailingTrivia = function () { - return TypeScript.Syntax.emptyTriviaList; - }; - - EmptySyntaxList.prototype.leadingTriviaWidth = function () { - return 0; - }; - - EmptySyntaxList.prototype.trailingTriviaWidth = function () { - return 0; - }; - - EmptySyntaxList.prototype.fullText = function () { - return ""; - }; - - EmptySyntaxList.prototype.isTypeScriptSpecific = function () { - return false; - }; - - EmptySyntaxList.prototype.isIncrementallyUnusable = function () { - return false; - }; - - EmptySyntaxList.prototype.findTokenInternal = function (parent, position, fullStart) { - throw TypeScript.Errors.invalidOperation(); - }; - - EmptySyntaxList.prototype.insertChildrenInto = function (array, index) { - }; - return EmptySyntaxList; - })(); - Syntax.EmptySyntaxList = EmptySyntaxList; - - Syntax.emptyList = new EmptySyntaxList(); - - var SingletonSyntaxList = (function () { - function SingletonSyntaxList(item) { - this.item = item; - } - SingletonSyntaxList.prototype.kind = function () { - return 1 /* List */; - }; - - SingletonSyntaxList.prototype.isToken = function () { - return false; - }; - SingletonSyntaxList.prototype.isNode = function () { - return false; - }; - SingletonSyntaxList.prototype.isList = function () { - return true; - }; - SingletonSyntaxList.prototype.isSeparatedList = function () { - return false; - }; - - SingletonSyntaxList.prototype.toJSON = function (key) { - return [this.item]; - }; - - SingletonSyntaxList.prototype.childCount = function () { - return 1; - }; - - SingletonSyntaxList.prototype.childAt = function (index) { - if (index !== 0) { - throw TypeScript.Errors.argumentOutOfRange("index"); - } - - return this.item; - }; - - SingletonSyntaxList.prototype.toArray = function () { - return [this.item]; - }; - - SingletonSyntaxList.prototype.collectTextElements = function (elements) { - this.item.collectTextElements(elements); - }; - - SingletonSyntaxList.prototype.firstToken = function () { - return this.item.firstToken(); - }; - - SingletonSyntaxList.prototype.lastToken = function () { - return this.item.lastToken(); - }; - - SingletonSyntaxList.prototype.fullWidth = function () { - return this.item.fullWidth(); - }; - - SingletonSyntaxList.prototype.width = function () { - return this.item.width(); - }; - - SingletonSyntaxList.prototype.leadingTrivia = function () { - return this.item.leadingTrivia(); - }; - - SingletonSyntaxList.prototype.trailingTrivia = function () { - return this.item.trailingTrivia(); - }; - - SingletonSyntaxList.prototype.leadingTriviaWidth = function () { - return this.item.leadingTriviaWidth(); - }; - - SingletonSyntaxList.prototype.trailingTriviaWidth = function () { - return this.item.trailingTriviaWidth(); - }; - - SingletonSyntaxList.prototype.fullText = function () { - return this.item.fullText(); - }; - - SingletonSyntaxList.prototype.isTypeScriptSpecific = function () { - return this.item.isTypeScriptSpecific(); - }; - - SingletonSyntaxList.prototype.isIncrementallyUnusable = function () { - return this.item.isIncrementallyUnusable(); - }; - - SingletonSyntaxList.prototype.findTokenInternal = function (parent, position, fullStart) { - return (this.item).findTokenInternal(new TypeScript.PositionedList(parent, this, fullStart), position, fullStart); - }; - - SingletonSyntaxList.prototype.insertChildrenInto = function (array, index) { - array.splice(index, 0, this.item); - }; - return SingletonSyntaxList; - })(); - - var NormalSyntaxList = (function () { - function NormalSyntaxList(nodeOrTokens) { - this._data = 0; - this.nodeOrTokens = nodeOrTokens; - } - NormalSyntaxList.prototype.kind = function () { - return 1 /* List */; - }; - - NormalSyntaxList.prototype.isNode = function () { - return false; - }; - NormalSyntaxList.prototype.isToken = function () { - return false; - }; - NormalSyntaxList.prototype.isList = function () { - return true; - }; - NormalSyntaxList.prototype.isSeparatedList = function () { - return false; - }; - - NormalSyntaxList.prototype.toJSON = function (key) { - return this.nodeOrTokens; - }; - - NormalSyntaxList.prototype.childCount = function () { - return this.nodeOrTokens.length; - }; - - NormalSyntaxList.prototype.childAt = function (index) { - if (index < 0 || index >= this.nodeOrTokens.length) { - throw TypeScript.Errors.argumentOutOfRange("index"); - } - - return this.nodeOrTokens[index]; - }; - - NormalSyntaxList.prototype.toArray = function () { - return this.nodeOrTokens.slice(0); - }; - - NormalSyntaxList.prototype.collectTextElements = function (elements) { - for (var i = 0, n = this.nodeOrTokens.length; i < n; i++) { - var element = this.nodeOrTokens[i]; - element.collectTextElements(elements); - } - }; - - NormalSyntaxList.prototype.firstToken = function () { - for (var i = 0, n = this.nodeOrTokens.length; i < n; i++) { - var token = this.nodeOrTokens[i].firstToken(); - if (token !== null) { - return token; - } - } - - return null; - }; - - NormalSyntaxList.prototype.lastToken = function () { - for (var i = this.nodeOrTokens.length - 1; i >= 0; i--) { - var token = this.nodeOrTokens[i].lastToken(); - if (token !== null) { - return token; - } - } - - return null; - }; - - NormalSyntaxList.prototype.fullText = function () { - var elements = []; - this.collectTextElements(elements); - return elements.join(""); - }; - - NormalSyntaxList.prototype.isTypeScriptSpecific = function () { - for (var i = 0, n = this.nodeOrTokens.length; i < n; i++) { - if (this.nodeOrTokens[i].isTypeScriptSpecific()) { - return true; - } - } - - return false; - }; - - NormalSyntaxList.prototype.isIncrementallyUnusable = function () { - return (this.data() & 2 /* NodeIncrementallyUnusableMask */) !== 0; - }; - - NormalSyntaxList.prototype.fullWidth = function () { - return this.data() >>> 3 /* NodeFullWidthShift */; - }; - - NormalSyntaxList.prototype.width = function () { - var fullWidth = this.fullWidth(); - return fullWidth - this.leadingTriviaWidth() - this.trailingTriviaWidth(); - }; - - NormalSyntaxList.prototype.leadingTrivia = function () { - return this.firstToken().leadingTrivia(); - }; - - NormalSyntaxList.prototype.trailingTrivia = function () { - return this.lastToken().trailingTrivia(); - }; - - NormalSyntaxList.prototype.leadingTriviaWidth = function () { - return this.firstToken().leadingTriviaWidth(); - }; - - NormalSyntaxList.prototype.trailingTriviaWidth = function () { - return this.lastToken().trailingTriviaWidth(); - }; - - NormalSyntaxList.prototype.computeData = function () { - var fullWidth = 0; - var isIncrementallyUnusable = false; - - for (var i = 0, n = this.nodeOrTokens.length; i < n; i++) { - var node = this.nodeOrTokens[i]; - fullWidth += node.fullWidth(); - isIncrementallyUnusable = isIncrementallyUnusable || node.isIncrementallyUnusable(); - } - - return (fullWidth << 3 /* NodeFullWidthShift */) | (isIncrementallyUnusable ? 2 /* NodeIncrementallyUnusableMask */ : 0) | 1 /* NodeDataComputed */; - }; - - NormalSyntaxList.prototype.data = function () { - if ((this._data & 1 /* NodeDataComputed */) === 0) { - this._data = this.computeData(); - } - - return this._data; - }; - - NormalSyntaxList.prototype.findTokenInternal = function (parent, position, fullStart) { - parent = new TypeScript.PositionedList(parent, this, fullStart); - for (var i = 0, n = this.nodeOrTokens.length; i < n; i++) { - var nodeOrToken = this.nodeOrTokens[i]; - - var childWidth = nodeOrToken.fullWidth(); - if (position < childWidth) { - return (nodeOrToken).findTokenInternal(parent, position, fullStart); - } - - position -= childWidth; - fullStart += childWidth; - } - - throw TypeScript.Errors.invalidOperation(); - }; - - NormalSyntaxList.prototype.insertChildrenInto = function (array, index) { - if (index === 0) { - array.unshift.apply(array, this.nodeOrTokens); - } else { - array.splice.apply(array, [index, 0].concat(this.nodeOrTokens)); - } - }; - return NormalSyntaxList; - })(); - - function list(nodes) { - if (nodes === undefined || nodes === null || nodes.length === 0) { - return Syntax.emptyList; - } - - if (nodes.length === 1) { - var item = nodes[0]; - return new SingletonSyntaxList(item); - } - - return new NormalSyntaxList(nodes); - } - Syntax.list = list; - })(TypeScript.Syntax || (TypeScript.Syntax = {})); - var Syntax = TypeScript.Syntax; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var SyntaxNode = (function () { - function SyntaxNode(parsedInStrictMode) { - this._data = parsedInStrictMode ? 4 /* NodeParsedInStrictModeMask */ : 0; - } - SyntaxNode.prototype.isNode = function () { - return true; - }; - SyntaxNode.prototype.isToken = function () { - return false; - }; - SyntaxNode.prototype.isList = function () { - return false; - }; - SyntaxNode.prototype.isSeparatedList = function () { - return false; - }; - - SyntaxNode.prototype.kind = function () { - throw TypeScript.Errors.abstract(); - }; - - SyntaxNode.prototype.childCount = function () { - throw TypeScript.Errors.abstract(); - }; - - SyntaxNode.prototype.childAt = function (slot) { - throw TypeScript.Errors.abstract(); - }; - - SyntaxNode.prototype.firstToken = function () { - for (var i = 0, n = this.childCount(); i < n; i++) { - var element = this.childAt(i); - - if (element !== null) { - if (element.fullWidth() > 0 || element.kind() === 10 /* EndOfFileToken */) { - return element.firstToken(); - } - } - } - - return null; - }; - - SyntaxNode.prototype.lastToken = function () { - for (var i = this.childCount() - 1; i >= 0; i--) { - var element = this.childAt(i); - - if (element !== null) { - if (element.fullWidth() > 0 || element.kind() === 10 /* EndOfFileToken */) { - return element.lastToken(); - } - } - } - - return null; - }; - - SyntaxNode.prototype.insertChildrenInto = function (array, index) { - for (var i = this.childCount() - 1; i >= 0; i--) { - var element = this.childAt(i); - - if (element !== null) { - if (element.isNode() || element.isToken()) { - array.splice(index, 0, element); - } else if (element.isList()) { - (element).insertChildrenInto(array, index); - } else if (element.isSeparatedList()) { - (element).insertChildrenInto(array, index); - } else { - throw TypeScript.Errors.invalidOperation(); - } - } - } - }; - - SyntaxNode.prototype.leadingTrivia = function () { - return this.firstToken().leadingTrivia(); - }; - - SyntaxNode.prototype.trailingTrivia = function () { - return this.lastToken().trailingTrivia(); - }; - - SyntaxNode.prototype.toJSON = function (key) { - var result = { - kind: TypeScript.SyntaxKind[this.kind()], - fullWidth: this.fullWidth() - }; - - if (this.isIncrementallyUnusable()) { - result.isIncrementallyUnusable = true; - } - - if (this.parsedInStrictMode()) { - result.parsedInStrictMode = true; - } - - for (var i = 0, n = this.childCount(); i < n; i++) { - var value = this.childAt(i); - - if (value) { - for (var name in this) { - if (value === this[name]) { - result[name] = value; - break; - } - } - } - } - - return result; - }; - - SyntaxNode.prototype.accept = function (visitor) { - throw TypeScript.Errors.abstract(); - }; - - SyntaxNode.prototype.fullText = function () { - var elements = []; - this.collectTextElements(elements); - return elements.join(""); - }; - - SyntaxNode.prototype.collectTextElements = function (elements) { - for (var i = 0, n = this.childCount(); i < n; i++) { - var element = this.childAt(i); - - if (element !== null) { - element.collectTextElements(elements); - } - } - }; - - SyntaxNode.prototype.replaceToken = function (token1, token2) { - if (token1 === token2) { - return this; - } - - return this.accept(new TypeScript.SyntaxTokenReplacer(token1, token2)); - }; - - SyntaxNode.prototype.withLeadingTrivia = function (trivia) { - return this.replaceToken(this.firstToken(), this.firstToken().withLeadingTrivia(trivia)); - }; - - SyntaxNode.prototype.withTrailingTrivia = function (trivia) { - return this.replaceToken(this.lastToken(), this.lastToken().withTrailingTrivia(trivia)); - }; - - SyntaxNode.prototype.hasLeadingTrivia = function () { - return this.lastToken().hasLeadingTrivia(); - }; - - SyntaxNode.prototype.hasTrailingTrivia = function () { - return this.lastToken().hasTrailingTrivia(); - }; - - SyntaxNode.prototype.isTypeScriptSpecific = function () { - return false; - }; - - SyntaxNode.prototype.isIncrementallyUnusable = function () { - return (this.data() & 2 /* NodeIncrementallyUnusableMask */) !== 0; - }; - - SyntaxNode.prototype.parsedInStrictMode = function () { - return (this.data() & 4 /* NodeParsedInStrictModeMask */) !== 0; - }; - - SyntaxNode.prototype.fullWidth = function () { - return this.data() >>> 3 /* NodeFullWidthShift */; - }; - - SyntaxNode.prototype.computeData = function () { - var slotCount = this.childCount(); - - var fullWidth = 0; - var childWidth = 0; - - var isIncrementallyUnusable = ((this._data & 2 /* NodeIncrementallyUnusableMask */) !== 0) || slotCount === 0; - - for (var i = 0, n = slotCount; i < n; i++) { - var element = this.childAt(i); - - if (element !== null) { - childWidth = element.fullWidth(); - fullWidth += childWidth; - - if (!isIncrementallyUnusable) { - isIncrementallyUnusable = element.isIncrementallyUnusable(); - } - } - } - - return (fullWidth << 3 /* NodeFullWidthShift */) | (isIncrementallyUnusable ? 2 /* NodeIncrementallyUnusableMask */ : 0) | 1 /* NodeDataComputed */; - }; - - SyntaxNode.prototype.data = function () { - if ((this._data & 1 /* NodeDataComputed */) === 0) { - this._data |= this.computeData(); - } - - return this._data; - }; - - SyntaxNode.prototype.findToken = function (position, includeSkippedTokens) { - if (typeof includeSkippedTokens === "undefined") { includeSkippedTokens = false; } - var endOfFileToken = this.tryGetEndOfFileAt(position); - if (endOfFileToken !== null) { - return endOfFileToken; - } - - if (position < 0 || position >= this.fullWidth()) { - throw TypeScript.Errors.argumentOutOfRange("position"); - } - - var positionedToken = this.findTokenInternal(null, position, 0); - - if (includeSkippedTokens) { - return TypeScript.Syntax.findSkippedTokenInPositionedToken(positionedToken, position) || positionedToken; - } - - return positionedToken; - }; - - SyntaxNode.prototype.tryGetEndOfFileAt = function (position) { - if (this.kind() === 121 /* SourceUnit */ && position === this.fullWidth()) { - var sourceUnit = this; - return new TypeScript.PositionedToken(new TypeScript.PositionedNode(null, sourceUnit, 0), sourceUnit.endOfFileToken, sourceUnit.moduleElements.fullWidth()); - } - - return null; - }; - - SyntaxNode.prototype.findTokenInternal = function (parent, position, fullStart) { - parent = new TypeScript.PositionedNode(parent, this, fullStart); - for (var i = 0, n = this.childCount(); i < n; i++) { - var element = this.childAt(i); - - if (element !== null) { - var childWidth = element.fullWidth(); - - if (position < childWidth) { - return (element).findTokenInternal(parent, position, fullStart); - } - - position -= childWidth; - fullStart += childWidth; - } - } - - throw TypeScript.Errors.invalidOperation(); - }; - - SyntaxNode.prototype.findTokenOnLeft = function (position, includeSkippedTokens) { - if (typeof includeSkippedTokens === "undefined") { includeSkippedTokens = false; } - var positionedToken = this.findToken(position, includeSkippedTokens); - var start = positionedToken.start(); - - if (position > start) { - return positionedToken; - } - - if (positionedToken.fullStart() === 0) { - return null; - } - - return positionedToken.previousToken(includeSkippedTokens); - }; - - SyntaxNode.prototype.findCompleteTokenOnLeft = function (position, includeSkippedTokens) { - if (typeof includeSkippedTokens === "undefined") { includeSkippedTokens = false; } - var positionedToken = this.findToken(position, includeSkippedTokens); - - if (positionedToken.token().width() > 0 && position >= positionedToken.end()) { - return positionedToken; - } - - return positionedToken.previousToken(includeSkippedTokens); - }; - - SyntaxNode.prototype.isModuleElement = function () { - return false; - }; - - SyntaxNode.prototype.isClassElement = function () { - return false; - }; - - SyntaxNode.prototype.isTypeMember = function () { - return false; - }; - - SyntaxNode.prototype.isStatement = function () { - return false; - }; - - SyntaxNode.prototype.isSwitchClause = function () { - return false; - }; - - SyntaxNode.prototype.structuralEquals = function (node) { - if (this === node) { - return true; - } - if (node === null) { - return false; - } - if (this.kind() !== node.kind()) { - return false; - } - - for (var i = 0, n = this.childCount(); i < n; i++) { - var element1 = this.childAt(i); - var element2 = node.childAt(i); - - if (!TypeScript.Syntax.elementStructuralEquals(element1, element2)) { - return false; - } - } - - return true; - }; - - SyntaxNode.prototype.width = function () { - return this.fullWidth() - this.leadingTriviaWidth() - this.trailingTriviaWidth(); - }; - - SyntaxNode.prototype.leadingTriviaWidth = function () { - var firstToken = this.firstToken(); - return firstToken === null ? 0 : firstToken.leadingTriviaWidth(); - }; - - SyntaxNode.prototype.trailingTriviaWidth = function () { - var lastToken = this.lastToken(); - return lastToken === null ? 0 : lastToken.trailingTriviaWidth(); - }; - return SyntaxNode; - })(); - TypeScript.SyntaxNode = SyntaxNode; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var SourceUnitSyntax = (function (_super) { - __extends(SourceUnitSyntax, _super); - function SourceUnitSyntax(moduleElements, endOfFileToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.moduleElements = moduleElements; - this.endOfFileToken = endOfFileToken; - } - SourceUnitSyntax.prototype.accept = function (visitor) { - return visitor.visitSourceUnit(this); - }; - - SourceUnitSyntax.prototype.kind = function () { - return 121 /* SourceUnit */; - }; - - SourceUnitSyntax.prototype.childCount = function () { - return 2; - }; - - SourceUnitSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.moduleElements; - case 1: - return this.endOfFileToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - SourceUnitSyntax.prototype.update = function (moduleElements, endOfFileToken) { - if (this.moduleElements === moduleElements && this.endOfFileToken === endOfFileToken) { - return this; - } - - return new SourceUnitSyntax(moduleElements, endOfFileToken, this.parsedInStrictMode()); - }; - - SourceUnitSyntax.create = function (endOfFileToken) { - return new SourceUnitSyntax(TypeScript.Syntax.emptyList, endOfFileToken, false); - }; - - SourceUnitSyntax.create1 = function (endOfFileToken) { - return new SourceUnitSyntax(TypeScript.Syntax.emptyList, endOfFileToken, false); - }; - - SourceUnitSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - SourceUnitSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - SourceUnitSyntax.prototype.withModuleElements = function (moduleElements) { - return this.update(moduleElements, this.endOfFileToken); - }; - - SourceUnitSyntax.prototype.withModuleElement = function (moduleElement) { - return this.withModuleElements(TypeScript.Syntax.list([moduleElement])); - }; - - SourceUnitSyntax.prototype.withEndOfFileToken = function (endOfFileToken) { - return this.update(this.moduleElements, endOfFileToken); - }; - - SourceUnitSyntax.prototype.isTypeScriptSpecific = function () { - if (this.moduleElements.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return SourceUnitSyntax; - })(TypeScript.SyntaxNode); - TypeScript.SourceUnitSyntax = SourceUnitSyntax; - - var ModuleReferenceSyntax = (function (_super) { - __extends(ModuleReferenceSyntax, _super); - function ModuleReferenceSyntax(parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - } - ModuleReferenceSyntax.prototype.isModuleReference = function () { - return true; - }; - - ModuleReferenceSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ModuleReferenceSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ModuleReferenceSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return ModuleReferenceSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ModuleReferenceSyntax = ModuleReferenceSyntax; - - var ExternalModuleReferenceSyntax = (function (_super) { - __extends(ExternalModuleReferenceSyntax, _super); - function ExternalModuleReferenceSyntax(moduleOrRequireKeyword, openParenToken, stringLiteral, closeParenToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.moduleOrRequireKeyword = moduleOrRequireKeyword; - this.openParenToken = openParenToken; - this.stringLiteral = stringLiteral; - this.closeParenToken = closeParenToken; - } - ExternalModuleReferenceSyntax.prototype.accept = function (visitor) { - return visitor.visitExternalModuleReference(this); - }; - - ExternalModuleReferenceSyntax.prototype.kind = function () { - return 245 /* ExternalModuleReference */; - }; - - ExternalModuleReferenceSyntax.prototype.childCount = function () { - return 4; - }; - - ExternalModuleReferenceSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.moduleOrRequireKeyword; - case 1: - return this.openParenToken; - case 2: - return this.stringLiteral; - case 3: - return this.closeParenToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ExternalModuleReferenceSyntax.prototype.update = function (moduleOrRequireKeyword, openParenToken, stringLiteral, closeParenToken) { - if (this.moduleOrRequireKeyword === moduleOrRequireKeyword && this.openParenToken === openParenToken && this.stringLiteral === stringLiteral && this.closeParenToken === closeParenToken) { - return this; - } - - return new ExternalModuleReferenceSyntax(moduleOrRequireKeyword, openParenToken, stringLiteral, closeParenToken, this.parsedInStrictMode()); - }; - - ExternalModuleReferenceSyntax.create1 = function (moduleOrRequireKeyword, stringLiteral) { - return new ExternalModuleReferenceSyntax(moduleOrRequireKeyword, TypeScript.Syntax.token(73 /* OpenParenToken */), stringLiteral, TypeScript.Syntax.token(74 /* CloseParenToken */), false); - }; - - ExternalModuleReferenceSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ExternalModuleReferenceSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ExternalModuleReferenceSyntax.prototype.withModuleOrRequireKeyword = function (moduleOrRequireKeyword) { - return this.update(moduleOrRequireKeyword, this.openParenToken, this.stringLiteral, this.closeParenToken); - }; - - ExternalModuleReferenceSyntax.prototype.withOpenParenToken = function (openParenToken) { - return this.update(this.moduleOrRequireKeyword, openParenToken, this.stringLiteral, this.closeParenToken); - }; - - ExternalModuleReferenceSyntax.prototype.withStringLiteral = function (stringLiteral) { - return this.update(this.moduleOrRequireKeyword, this.openParenToken, stringLiteral, this.closeParenToken); - }; - - ExternalModuleReferenceSyntax.prototype.withCloseParenToken = function (closeParenToken) { - return this.update(this.moduleOrRequireKeyword, this.openParenToken, this.stringLiteral, closeParenToken); - }; - - ExternalModuleReferenceSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return ExternalModuleReferenceSyntax; - })(ModuleReferenceSyntax); - TypeScript.ExternalModuleReferenceSyntax = ExternalModuleReferenceSyntax; - - var ModuleNameModuleReferenceSyntax = (function (_super) { - __extends(ModuleNameModuleReferenceSyntax, _super); - function ModuleNameModuleReferenceSyntax(moduleName, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.moduleName = moduleName; - } - ModuleNameModuleReferenceSyntax.prototype.accept = function (visitor) { - return visitor.visitModuleNameModuleReference(this); - }; - - ModuleNameModuleReferenceSyntax.prototype.kind = function () { - return 246 /* ModuleNameModuleReference */; - }; - - ModuleNameModuleReferenceSyntax.prototype.childCount = function () { - return 1; - }; - - ModuleNameModuleReferenceSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.moduleName; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ModuleNameModuleReferenceSyntax.prototype.update = function (moduleName) { - if (this.moduleName === moduleName) { - return this; - } - - return new ModuleNameModuleReferenceSyntax(moduleName, this.parsedInStrictMode()); - }; - - ModuleNameModuleReferenceSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ModuleNameModuleReferenceSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ModuleNameModuleReferenceSyntax.prototype.withModuleName = function (moduleName) { - return this.update(moduleName); - }; - - ModuleNameModuleReferenceSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return ModuleNameModuleReferenceSyntax; - })(ModuleReferenceSyntax); - TypeScript.ModuleNameModuleReferenceSyntax = ModuleNameModuleReferenceSyntax; - - var ImportDeclarationSyntax = (function (_super) { - __extends(ImportDeclarationSyntax, _super); - function ImportDeclarationSyntax(importKeyword, identifier, equalsToken, moduleReference, semicolonToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.importKeyword = importKeyword; - this.identifier = identifier; - this.equalsToken = equalsToken; - this.moduleReference = moduleReference; - this.semicolonToken = semicolonToken; - } - ImportDeclarationSyntax.prototype.accept = function (visitor) { - return visitor.visitImportDeclaration(this); - }; - - ImportDeclarationSyntax.prototype.kind = function () { - return 133 /* ImportDeclaration */; - }; - - ImportDeclarationSyntax.prototype.childCount = function () { - return 5; - }; - - ImportDeclarationSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.importKeyword; - case 1: - return this.identifier; - case 2: - return this.equalsToken; - case 3: - return this.moduleReference; - case 4: - return this.semicolonToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ImportDeclarationSyntax.prototype.isModuleElement = function () { - return true; - }; - - ImportDeclarationSyntax.prototype.update = function (importKeyword, identifier, equalsToken, moduleReference, semicolonToken) { - if (this.importKeyword === importKeyword && this.identifier === identifier && this.equalsToken === equalsToken && this.moduleReference === moduleReference && this.semicolonToken === semicolonToken) { - return this; - } - - return new ImportDeclarationSyntax(importKeyword, identifier, equalsToken, moduleReference, semicolonToken, this.parsedInStrictMode()); - }; - - ImportDeclarationSyntax.create1 = function (identifier, moduleReference) { - return new ImportDeclarationSyntax(TypeScript.Syntax.token(49 /* ImportKeyword */), identifier, TypeScript.Syntax.token(108 /* EqualsToken */), moduleReference, TypeScript.Syntax.token(79 /* SemicolonToken */), false); - }; - - ImportDeclarationSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ImportDeclarationSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ImportDeclarationSyntax.prototype.withImportKeyword = function (importKeyword) { - return this.update(importKeyword, this.identifier, this.equalsToken, this.moduleReference, this.semicolonToken); - }; - - ImportDeclarationSyntax.prototype.withIdentifier = function (identifier) { - return this.update(this.importKeyword, identifier, this.equalsToken, this.moduleReference, this.semicolonToken); - }; - - ImportDeclarationSyntax.prototype.withEqualsToken = function (equalsToken) { - return this.update(this.importKeyword, this.identifier, equalsToken, this.moduleReference, this.semicolonToken); - }; - - ImportDeclarationSyntax.prototype.withModuleReference = function (moduleReference) { - return this.update(this.importKeyword, this.identifier, this.equalsToken, moduleReference, this.semicolonToken); - }; - - ImportDeclarationSyntax.prototype.withSemicolonToken = function (semicolonToken) { - return this.update(this.importKeyword, this.identifier, this.equalsToken, this.moduleReference, semicolonToken); - }; - - ImportDeclarationSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return ImportDeclarationSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ImportDeclarationSyntax = ImportDeclarationSyntax; - - var ExportAssignmentSyntax = (function (_super) { - __extends(ExportAssignmentSyntax, _super); - function ExportAssignmentSyntax(exportKeyword, equalsToken, identifier, semicolonToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.exportKeyword = exportKeyword; - this.equalsToken = equalsToken; - this.identifier = identifier; - this.semicolonToken = semicolonToken; - } - ExportAssignmentSyntax.prototype.accept = function (visitor) { - return visitor.visitExportAssignment(this); - }; - - ExportAssignmentSyntax.prototype.kind = function () { - return 134 /* ExportAssignment */; - }; - - ExportAssignmentSyntax.prototype.childCount = function () { - return 4; - }; - - ExportAssignmentSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.exportKeyword; - case 1: - return this.equalsToken; - case 2: - return this.identifier; - case 3: - return this.semicolonToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ExportAssignmentSyntax.prototype.isModuleElement = function () { - return true; - }; - - ExportAssignmentSyntax.prototype.update = function (exportKeyword, equalsToken, identifier, semicolonToken) { - if (this.exportKeyword === exportKeyword && this.equalsToken === equalsToken && this.identifier === identifier && this.semicolonToken === semicolonToken) { - return this; - } - - return new ExportAssignmentSyntax(exportKeyword, equalsToken, identifier, semicolonToken, this.parsedInStrictMode()); - }; - - ExportAssignmentSyntax.create1 = function (identifier) { - return new ExportAssignmentSyntax(TypeScript.Syntax.token(47 /* ExportKeyword */), TypeScript.Syntax.token(108 /* EqualsToken */), identifier, TypeScript.Syntax.token(79 /* SemicolonToken */), false); - }; - - ExportAssignmentSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ExportAssignmentSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ExportAssignmentSyntax.prototype.withExportKeyword = function (exportKeyword) { - return this.update(exportKeyword, this.equalsToken, this.identifier, this.semicolonToken); - }; - - ExportAssignmentSyntax.prototype.withEqualsToken = function (equalsToken) { - return this.update(this.exportKeyword, equalsToken, this.identifier, this.semicolonToken); - }; - - ExportAssignmentSyntax.prototype.withIdentifier = function (identifier) { - return this.update(this.exportKeyword, this.equalsToken, identifier, this.semicolonToken); - }; - - ExportAssignmentSyntax.prototype.withSemicolonToken = function (semicolonToken) { - return this.update(this.exportKeyword, this.equalsToken, this.identifier, semicolonToken); - }; - - ExportAssignmentSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return ExportAssignmentSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ExportAssignmentSyntax = ExportAssignmentSyntax; - - var ClassDeclarationSyntax = (function (_super) { - __extends(ClassDeclarationSyntax, _super); - function ClassDeclarationSyntax(modifiers, classKeyword, identifier, typeParameterList, heritageClauses, openBraceToken, classElements, closeBraceToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.modifiers = modifiers; - this.classKeyword = classKeyword; - this.identifier = identifier; - this.typeParameterList = typeParameterList; - this.heritageClauses = heritageClauses; - this.openBraceToken = openBraceToken; - this.classElements = classElements; - this.closeBraceToken = closeBraceToken; - } - ClassDeclarationSyntax.prototype.accept = function (visitor) { - return visitor.visitClassDeclaration(this); - }; - - ClassDeclarationSyntax.prototype.kind = function () { - return 131 /* ClassDeclaration */; - }; - - ClassDeclarationSyntax.prototype.childCount = function () { - return 8; - }; - - ClassDeclarationSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.modifiers; - case 1: - return this.classKeyword; - case 2: - return this.identifier; - case 3: - return this.typeParameterList; - case 4: - return this.heritageClauses; - case 5: - return this.openBraceToken; - case 6: - return this.classElements; - case 7: - return this.closeBraceToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ClassDeclarationSyntax.prototype.isModuleElement = function () { - return true; - }; - - ClassDeclarationSyntax.prototype.update = function (modifiers, classKeyword, identifier, typeParameterList, heritageClauses, openBraceToken, classElements, closeBraceToken) { - if (this.modifiers === modifiers && this.classKeyword === classKeyword && this.identifier === identifier && this.typeParameterList === typeParameterList && this.heritageClauses === heritageClauses && this.openBraceToken === openBraceToken && this.classElements === classElements && this.closeBraceToken === closeBraceToken) { - return this; - } - - return new ClassDeclarationSyntax(modifiers, classKeyword, identifier, typeParameterList, heritageClauses, openBraceToken, classElements, closeBraceToken, this.parsedInStrictMode()); - }; - - ClassDeclarationSyntax.create = function (classKeyword, identifier, openBraceToken, closeBraceToken) { - return new ClassDeclarationSyntax(TypeScript.Syntax.emptyList, classKeyword, identifier, null, TypeScript.Syntax.emptyList, openBraceToken, TypeScript.Syntax.emptyList, closeBraceToken, false); - }; - - ClassDeclarationSyntax.create1 = function (identifier) { - return new ClassDeclarationSyntax(TypeScript.Syntax.emptyList, TypeScript.Syntax.token(44 /* ClassKeyword */), identifier, null, TypeScript.Syntax.emptyList, TypeScript.Syntax.token(71 /* OpenBraceToken */), TypeScript.Syntax.emptyList, TypeScript.Syntax.token(72 /* CloseBraceToken */), false); - }; - - ClassDeclarationSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ClassDeclarationSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ClassDeclarationSyntax.prototype.withModifiers = function (modifiers) { - return this.update(modifiers, this.classKeyword, this.identifier, this.typeParameterList, this.heritageClauses, this.openBraceToken, this.classElements, this.closeBraceToken); - }; - - ClassDeclarationSyntax.prototype.withModifier = function (modifier) { - return this.withModifiers(TypeScript.Syntax.list([modifier])); - }; - - ClassDeclarationSyntax.prototype.withClassKeyword = function (classKeyword) { - return this.update(this.modifiers, classKeyword, this.identifier, this.typeParameterList, this.heritageClauses, this.openBraceToken, this.classElements, this.closeBraceToken); - }; - - ClassDeclarationSyntax.prototype.withIdentifier = function (identifier) { - return this.update(this.modifiers, this.classKeyword, identifier, this.typeParameterList, this.heritageClauses, this.openBraceToken, this.classElements, this.closeBraceToken); - }; - - ClassDeclarationSyntax.prototype.withTypeParameterList = function (typeParameterList) { - return this.update(this.modifiers, this.classKeyword, this.identifier, typeParameterList, this.heritageClauses, this.openBraceToken, this.classElements, this.closeBraceToken); - }; - - ClassDeclarationSyntax.prototype.withHeritageClauses = function (heritageClauses) { - return this.update(this.modifiers, this.classKeyword, this.identifier, this.typeParameterList, heritageClauses, this.openBraceToken, this.classElements, this.closeBraceToken); - }; - - ClassDeclarationSyntax.prototype.withHeritageClause = function (heritageClause) { - return this.withHeritageClauses(TypeScript.Syntax.list([heritageClause])); - }; - - ClassDeclarationSyntax.prototype.withOpenBraceToken = function (openBraceToken) { - return this.update(this.modifiers, this.classKeyword, this.identifier, this.typeParameterList, this.heritageClauses, openBraceToken, this.classElements, this.closeBraceToken); - }; - - ClassDeclarationSyntax.prototype.withClassElements = function (classElements) { - return this.update(this.modifiers, this.classKeyword, this.identifier, this.typeParameterList, this.heritageClauses, this.openBraceToken, classElements, this.closeBraceToken); - }; - - ClassDeclarationSyntax.prototype.withClassElement = function (classElement) { - return this.withClassElements(TypeScript.Syntax.list([classElement])); - }; - - ClassDeclarationSyntax.prototype.withCloseBraceToken = function (closeBraceToken) { - return this.update(this.modifiers, this.classKeyword, this.identifier, this.typeParameterList, this.heritageClauses, this.openBraceToken, this.classElements, closeBraceToken); - }; - - ClassDeclarationSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return ClassDeclarationSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ClassDeclarationSyntax = ClassDeclarationSyntax; - - var InterfaceDeclarationSyntax = (function (_super) { - __extends(InterfaceDeclarationSyntax, _super); - function InterfaceDeclarationSyntax(modifiers, interfaceKeyword, identifier, typeParameterList, heritageClauses, body, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.modifiers = modifiers; - this.interfaceKeyword = interfaceKeyword; - this.identifier = identifier; - this.typeParameterList = typeParameterList; - this.heritageClauses = heritageClauses; - this.body = body; - } - InterfaceDeclarationSyntax.prototype.accept = function (visitor) { - return visitor.visitInterfaceDeclaration(this); - }; - - InterfaceDeclarationSyntax.prototype.kind = function () { - return 128 /* InterfaceDeclaration */; - }; - - InterfaceDeclarationSyntax.prototype.childCount = function () { - return 6; - }; - - InterfaceDeclarationSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.modifiers; - case 1: - return this.interfaceKeyword; - case 2: - return this.identifier; - case 3: - return this.typeParameterList; - case 4: - return this.heritageClauses; - case 5: - return this.body; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - InterfaceDeclarationSyntax.prototype.isModuleElement = function () { - return true; - }; - - InterfaceDeclarationSyntax.prototype.update = function (modifiers, interfaceKeyword, identifier, typeParameterList, heritageClauses, body) { - if (this.modifiers === modifiers && this.interfaceKeyword === interfaceKeyword && this.identifier === identifier && this.typeParameterList === typeParameterList && this.heritageClauses === heritageClauses && this.body === body) { - return this; - } - - return new InterfaceDeclarationSyntax(modifiers, interfaceKeyword, identifier, typeParameterList, heritageClauses, body, this.parsedInStrictMode()); - }; - - InterfaceDeclarationSyntax.create = function (interfaceKeyword, identifier, body) { - return new InterfaceDeclarationSyntax(TypeScript.Syntax.emptyList, interfaceKeyword, identifier, null, TypeScript.Syntax.emptyList, body, false); - }; - - InterfaceDeclarationSyntax.create1 = function (identifier) { - return new InterfaceDeclarationSyntax(TypeScript.Syntax.emptyList, TypeScript.Syntax.token(52 /* InterfaceKeyword */), identifier, null, TypeScript.Syntax.emptyList, ObjectTypeSyntax.create1(), false); - }; - - InterfaceDeclarationSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - InterfaceDeclarationSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - InterfaceDeclarationSyntax.prototype.withModifiers = function (modifiers) { - return this.update(modifiers, this.interfaceKeyword, this.identifier, this.typeParameterList, this.heritageClauses, this.body); - }; - - InterfaceDeclarationSyntax.prototype.withModifier = function (modifier) { - return this.withModifiers(TypeScript.Syntax.list([modifier])); - }; - - InterfaceDeclarationSyntax.prototype.withInterfaceKeyword = function (interfaceKeyword) { - return this.update(this.modifiers, interfaceKeyword, this.identifier, this.typeParameterList, this.heritageClauses, this.body); - }; - - InterfaceDeclarationSyntax.prototype.withIdentifier = function (identifier) { - return this.update(this.modifiers, this.interfaceKeyword, identifier, this.typeParameterList, this.heritageClauses, this.body); - }; - - InterfaceDeclarationSyntax.prototype.withTypeParameterList = function (typeParameterList) { - return this.update(this.modifiers, this.interfaceKeyword, this.identifier, typeParameterList, this.heritageClauses, this.body); - }; - - InterfaceDeclarationSyntax.prototype.withHeritageClauses = function (heritageClauses) { - return this.update(this.modifiers, this.interfaceKeyword, this.identifier, this.typeParameterList, heritageClauses, this.body); - }; - - InterfaceDeclarationSyntax.prototype.withHeritageClause = function (heritageClause) { - return this.withHeritageClauses(TypeScript.Syntax.list([heritageClause])); - }; - - InterfaceDeclarationSyntax.prototype.withBody = function (body) { - return this.update(this.modifiers, this.interfaceKeyword, this.identifier, this.typeParameterList, this.heritageClauses, body); - }; - - InterfaceDeclarationSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return InterfaceDeclarationSyntax; - })(TypeScript.SyntaxNode); - TypeScript.InterfaceDeclarationSyntax = InterfaceDeclarationSyntax; - - var HeritageClauseSyntax = (function (_super) { - __extends(HeritageClauseSyntax, _super); - function HeritageClauseSyntax(extendsOrImplementsKeyword, typeNames, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.extendsOrImplementsKeyword = extendsOrImplementsKeyword; - this.typeNames = typeNames; - } - HeritageClauseSyntax.prototype.accept = function (visitor) { - return visitor.visitHeritageClause(this); - }; - - HeritageClauseSyntax.prototype.kind = function () { - return 229 /* HeritageClause */; - }; - - HeritageClauseSyntax.prototype.childCount = function () { - return 2; - }; - - HeritageClauseSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.extendsOrImplementsKeyword; - case 1: - return this.typeNames; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - HeritageClauseSyntax.prototype.update = function (extendsOrImplementsKeyword, typeNames) { - if (this.extendsOrImplementsKeyword === extendsOrImplementsKeyword && this.typeNames === typeNames) { - return this; - } - - return new HeritageClauseSyntax(extendsOrImplementsKeyword, typeNames, this.parsedInStrictMode()); - }; - - HeritageClauseSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - HeritageClauseSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - HeritageClauseSyntax.prototype.withExtendsOrImplementsKeyword = function (extendsOrImplementsKeyword) { - return this.update(extendsOrImplementsKeyword, this.typeNames); - }; - - HeritageClauseSyntax.prototype.withTypeNames = function (typeNames) { - return this.update(this.extendsOrImplementsKeyword, typeNames); - }; - - HeritageClauseSyntax.prototype.withTypeName = function (typeName) { - return this.withTypeNames(TypeScript.Syntax.separatedList([typeName])); - }; - - HeritageClauseSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return HeritageClauseSyntax; - })(TypeScript.SyntaxNode); - TypeScript.HeritageClauseSyntax = HeritageClauseSyntax; - - var ModuleDeclarationSyntax = (function (_super) { - __extends(ModuleDeclarationSyntax, _super); - function ModuleDeclarationSyntax(modifiers, moduleKeyword, moduleName, stringLiteral, openBraceToken, moduleElements, closeBraceToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.modifiers = modifiers; - this.moduleKeyword = moduleKeyword; - this.moduleName = moduleName; - this.stringLiteral = stringLiteral; - this.openBraceToken = openBraceToken; - this.moduleElements = moduleElements; - this.closeBraceToken = closeBraceToken; - } - ModuleDeclarationSyntax.prototype.accept = function (visitor) { - return visitor.visitModuleDeclaration(this); - }; - - ModuleDeclarationSyntax.prototype.kind = function () { - return 130 /* ModuleDeclaration */; - }; - - ModuleDeclarationSyntax.prototype.childCount = function () { - return 7; - }; - - ModuleDeclarationSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.modifiers; - case 1: - return this.moduleKeyword; - case 2: - return this.moduleName; - case 3: - return this.stringLiteral; - case 4: - return this.openBraceToken; - case 5: - return this.moduleElements; - case 6: - return this.closeBraceToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ModuleDeclarationSyntax.prototype.isModuleElement = function () { - return true; - }; - - ModuleDeclarationSyntax.prototype.update = function (modifiers, moduleKeyword, moduleName, stringLiteral, openBraceToken, moduleElements, closeBraceToken) { - if (this.modifiers === modifiers && this.moduleKeyword === moduleKeyword && this.moduleName === moduleName && this.stringLiteral === stringLiteral && this.openBraceToken === openBraceToken && this.moduleElements === moduleElements && this.closeBraceToken === closeBraceToken) { - return this; - } - - return new ModuleDeclarationSyntax(modifiers, moduleKeyword, moduleName, stringLiteral, openBraceToken, moduleElements, closeBraceToken, this.parsedInStrictMode()); - }; - - ModuleDeclarationSyntax.create = function (moduleKeyword, openBraceToken, closeBraceToken) { - return new ModuleDeclarationSyntax(TypeScript.Syntax.emptyList, moduleKeyword, null, null, openBraceToken, TypeScript.Syntax.emptyList, closeBraceToken, false); - }; - - ModuleDeclarationSyntax.create1 = function () { - return new ModuleDeclarationSyntax(TypeScript.Syntax.emptyList, TypeScript.Syntax.token(66 /* ModuleKeyword */), null, null, TypeScript.Syntax.token(71 /* OpenBraceToken */), TypeScript.Syntax.emptyList, TypeScript.Syntax.token(72 /* CloseBraceToken */), false); - }; - - ModuleDeclarationSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ModuleDeclarationSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ModuleDeclarationSyntax.prototype.withModifiers = function (modifiers) { - return this.update(modifiers, this.moduleKeyword, this.moduleName, this.stringLiteral, this.openBraceToken, this.moduleElements, this.closeBraceToken); - }; - - ModuleDeclarationSyntax.prototype.withModifier = function (modifier) { - return this.withModifiers(TypeScript.Syntax.list([modifier])); - }; - - ModuleDeclarationSyntax.prototype.withModuleKeyword = function (moduleKeyword) { - return this.update(this.modifiers, moduleKeyword, this.moduleName, this.stringLiteral, this.openBraceToken, this.moduleElements, this.closeBraceToken); - }; - - ModuleDeclarationSyntax.prototype.withModuleName = function (moduleName) { - return this.update(this.modifiers, this.moduleKeyword, moduleName, this.stringLiteral, this.openBraceToken, this.moduleElements, this.closeBraceToken); - }; - - ModuleDeclarationSyntax.prototype.withStringLiteral = function (stringLiteral) { - return this.update(this.modifiers, this.moduleKeyword, this.moduleName, stringLiteral, this.openBraceToken, this.moduleElements, this.closeBraceToken); - }; - - ModuleDeclarationSyntax.prototype.withOpenBraceToken = function (openBraceToken) { - return this.update(this.modifiers, this.moduleKeyword, this.moduleName, this.stringLiteral, openBraceToken, this.moduleElements, this.closeBraceToken); - }; - - ModuleDeclarationSyntax.prototype.withModuleElements = function (moduleElements) { - return this.update(this.modifiers, this.moduleKeyword, this.moduleName, this.stringLiteral, this.openBraceToken, moduleElements, this.closeBraceToken); - }; - - ModuleDeclarationSyntax.prototype.withModuleElement = function (moduleElement) { - return this.withModuleElements(TypeScript.Syntax.list([moduleElement])); - }; - - ModuleDeclarationSyntax.prototype.withCloseBraceToken = function (closeBraceToken) { - return this.update(this.modifiers, this.moduleKeyword, this.moduleName, this.stringLiteral, this.openBraceToken, this.moduleElements, closeBraceToken); - }; - - ModuleDeclarationSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return ModuleDeclarationSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ModuleDeclarationSyntax = ModuleDeclarationSyntax; - - var FunctionDeclarationSyntax = (function (_super) { - __extends(FunctionDeclarationSyntax, _super); - function FunctionDeclarationSyntax(modifiers, functionKeyword, identifier, callSignature, block, semicolonToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.modifiers = modifiers; - this.functionKeyword = functionKeyword; - this.identifier = identifier; - this.callSignature = callSignature; - this.block = block; - this.semicolonToken = semicolonToken; - } - FunctionDeclarationSyntax.prototype.accept = function (visitor) { - return visitor.visitFunctionDeclaration(this); - }; - - FunctionDeclarationSyntax.prototype.kind = function () { - return 129 /* FunctionDeclaration */; - }; - - FunctionDeclarationSyntax.prototype.childCount = function () { - return 6; - }; - - FunctionDeclarationSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.modifiers; - case 1: - return this.functionKeyword; - case 2: - return this.identifier; - case 3: - return this.callSignature; - case 4: - return this.block; - case 5: - return this.semicolonToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - FunctionDeclarationSyntax.prototype.isStatement = function () { - return true; - }; - - FunctionDeclarationSyntax.prototype.isModuleElement = function () { - return true; - }; - - FunctionDeclarationSyntax.prototype.update = function (modifiers, functionKeyword, identifier, callSignature, block, semicolonToken) { - if (this.modifiers === modifiers && this.functionKeyword === functionKeyword && this.identifier === identifier && this.callSignature === callSignature && this.block === block && this.semicolonToken === semicolonToken) { - return this; - } - - return new FunctionDeclarationSyntax(modifiers, functionKeyword, identifier, callSignature, block, semicolonToken, this.parsedInStrictMode()); - }; - - FunctionDeclarationSyntax.create = function (functionKeyword, identifier, callSignature) { - return new FunctionDeclarationSyntax(TypeScript.Syntax.emptyList, functionKeyword, identifier, callSignature, null, null, false); - }; - - FunctionDeclarationSyntax.create1 = function (identifier) { - return new FunctionDeclarationSyntax(TypeScript.Syntax.emptyList, TypeScript.Syntax.token(27 /* FunctionKeyword */), identifier, CallSignatureSyntax.create1(), null, null, false); - }; - - FunctionDeclarationSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - FunctionDeclarationSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - FunctionDeclarationSyntax.prototype.withModifiers = function (modifiers) { - return this.update(modifiers, this.functionKeyword, this.identifier, this.callSignature, this.block, this.semicolonToken); - }; - - FunctionDeclarationSyntax.prototype.withModifier = function (modifier) { - return this.withModifiers(TypeScript.Syntax.list([modifier])); - }; - - FunctionDeclarationSyntax.prototype.withFunctionKeyword = function (functionKeyword) { - return this.update(this.modifiers, functionKeyword, this.identifier, this.callSignature, this.block, this.semicolonToken); - }; - - FunctionDeclarationSyntax.prototype.withIdentifier = function (identifier) { - return this.update(this.modifiers, this.functionKeyword, identifier, this.callSignature, this.block, this.semicolonToken); - }; - - FunctionDeclarationSyntax.prototype.withCallSignature = function (callSignature) { - return this.update(this.modifiers, this.functionKeyword, this.identifier, callSignature, this.block, this.semicolonToken); - }; - - FunctionDeclarationSyntax.prototype.withBlock = function (block) { - return this.update(this.modifiers, this.functionKeyword, this.identifier, this.callSignature, block, this.semicolonToken); - }; - - FunctionDeclarationSyntax.prototype.withSemicolonToken = function (semicolonToken) { - return this.update(this.modifiers, this.functionKeyword, this.identifier, this.callSignature, this.block, semicolonToken); - }; - - FunctionDeclarationSyntax.prototype.isTypeScriptSpecific = function () { - if (this.modifiers.isTypeScriptSpecific()) { - return true; - } - if (this.callSignature.isTypeScriptSpecific()) { - return true; - } - if (this.block !== null && this.block.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return FunctionDeclarationSyntax; - })(TypeScript.SyntaxNode); - TypeScript.FunctionDeclarationSyntax = FunctionDeclarationSyntax; - - var VariableStatementSyntax = (function (_super) { - __extends(VariableStatementSyntax, _super); - function VariableStatementSyntax(modifiers, variableDeclaration, semicolonToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.modifiers = modifiers; - this.variableDeclaration = variableDeclaration; - this.semicolonToken = semicolonToken; - } - VariableStatementSyntax.prototype.accept = function (visitor) { - return visitor.visitVariableStatement(this); - }; - - VariableStatementSyntax.prototype.kind = function () { - return 147 /* VariableStatement */; - }; - - VariableStatementSyntax.prototype.childCount = function () { - return 3; - }; - - VariableStatementSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.modifiers; - case 1: - return this.variableDeclaration; - case 2: - return this.semicolonToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - VariableStatementSyntax.prototype.isStatement = function () { - return true; - }; - - VariableStatementSyntax.prototype.isModuleElement = function () { - return true; - }; - - VariableStatementSyntax.prototype.update = function (modifiers, variableDeclaration, semicolonToken) { - if (this.modifiers === modifiers && this.variableDeclaration === variableDeclaration && this.semicolonToken === semicolonToken) { - return this; - } - - return new VariableStatementSyntax(modifiers, variableDeclaration, semicolonToken, this.parsedInStrictMode()); - }; - - VariableStatementSyntax.create = function (variableDeclaration, semicolonToken) { - return new VariableStatementSyntax(TypeScript.Syntax.emptyList, variableDeclaration, semicolonToken, false); - }; - - VariableStatementSyntax.create1 = function (variableDeclaration) { - return new VariableStatementSyntax(TypeScript.Syntax.emptyList, variableDeclaration, TypeScript.Syntax.token(79 /* SemicolonToken */), false); - }; - - VariableStatementSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - VariableStatementSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - VariableStatementSyntax.prototype.withModifiers = function (modifiers) { - return this.update(modifiers, this.variableDeclaration, this.semicolonToken); - }; - - VariableStatementSyntax.prototype.withModifier = function (modifier) { - return this.withModifiers(TypeScript.Syntax.list([modifier])); - }; - - VariableStatementSyntax.prototype.withVariableDeclaration = function (variableDeclaration) { - return this.update(this.modifiers, variableDeclaration, this.semicolonToken); - }; - - VariableStatementSyntax.prototype.withSemicolonToken = function (semicolonToken) { - return this.update(this.modifiers, this.variableDeclaration, semicolonToken); - }; - - VariableStatementSyntax.prototype.isTypeScriptSpecific = function () { - if (this.modifiers.isTypeScriptSpecific()) { - return true; - } - if (this.variableDeclaration.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return VariableStatementSyntax; - })(TypeScript.SyntaxNode); - TypeScript.VariableStatementSyntax = VariableStatementSyntax; - - var VariableDeclarationSyntax = (function (_super) { - __extends(VariableDeclarationSyntax, _super); - function VariableDeclarationSyntax(varKeyword, variableDeclarators, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.varKeyword = varKeyword; - this.variableDeclarators = variableDeclarators; - } - VariableDeclarationSyntax.prototype.accept = function (visitor) { - return visitor.visitVariableDeclaration(this); - }; - - VariableDeclarationSyntax.prototype.kind = function () { - return 223 /* VariableDeclaration */; - }; - - VariableDeclarationSyntax.prototype.childCount = function () { - return 2; - }; - - VariableDeclarationSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.varKeyword; - case 1: - return this.variableDeclarators; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - VariableDeclarationSyntax.prototype.update = function (varKeyword, variableDeclarators) { - if (this.varKeyword === varKeyword && this.variableDeclarators === variableDeclarators) { - return this; - } - - return new VariableDeclarationSyntax(varKeyword, variableDeclarators, this.parsedInStrictMode()); - }; - - VariableDeclarationSyntax.create1 = function (variableDeclarators) { - return new VariableDeclarationSyntax(TypeScript.Syntax.token(40 /* VarKeyword */), variableDeclarators, false); - }; - - VariableDeclarationSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - VariableDeclarationSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - VariableDeclarationSyntax.prototype.withVarKeyword = function (varKeyword) { - return this.update(varKeyword, this.variableDeclarators); - }; - - VariableDeclarationSyntax.prototype.withVariableDeclarators = function (variableDeclarators) { - return this.update(this.varKeyword, variableDeclarators); - }; - - VariableDeclarationSyntax.prototype.withVariableDeclarator = function (variableDeclarator) { - return this.withVariableDeclarators(TypeScript.Syntax.separatedList([variableDeclarator])); - }; - - VariableDeclarationSyntax.prototype.isTypeScriptSpecific = function () { - if (this.variableDeclarators.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return VariableDeclarationSyntax; - })(TypeScript.SyntaxNode); - TypeScript.VariableDeclarationSyntax = VariableDeclarationSyntax; - - var VariableDeclaratorSyntax = (function (_super) { - __extends(VariableDeclaratorSyntax, _super); - function VariableDeclaratorSyntax(identifier, typeAnnotation, equalsValueClause, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.identifier = identifier; - this.typeAnnotation = typeAnnotation; - this.equalsValueClause = equalsValueClause; - } - VariableDeclaratorSyntax.prototype.accept = function (visitor) { - return visitor.visitVariableDeclarator(this); - }; - - VariableDeclaratorSyntax.prototype.kind = function () { - return 224 /* VariableDeclarator */; - }; - - VariableDeclaratorSyntax.prototype.childCount = function () { - return 3; - }; - - VariableDeclaratorSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.identifier; - case 1: - return this.typeAnnotation; - case 2: - return this.equalsValueClause; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - VariableDeclaratorSyntax.prototype.update = function (identifier, typeAnnotation, equalsValueClause) { - if (this.identifier === identifier && this.typeAnnotation === typeAnnotation && this.equalsValueClause === equalsValueClause) { - return this; - } - - return new VariableDeclaratorSyntax(identifier, typeAnnotation, equalsValueClause, this.parsedInStrictMode()); - }; - - VariableDeclaratorSyntax.create = function (identifier) { - return new VariableDeclaratorSyntax(identifier, null, null, false); - }; - - VariableDeclaratorSyntax.create1 = function (identifier) { - return new VariableDeclaratorSyntax(identifier, null, null, false); - }; - - VariableDeclaratorSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - VariableDeclaratorSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - VariableDeclaratorSyntax.prototype.withIdentifier = function (identifier) { - return this.update(identifier, this.typeAnnotation, this.equalsValueClause); - }; - - VariableDeclaratorSyntax.prototype.withTypeAnnotation = function (typeAnnotation) { - return this.update(this.identifier, typeAnnotation, this.equalsValueClause); - }; - - VariableDeclaratorSyntax.prototype.withEqualsValueClause = function (equalsValueClause) { - return this.update(this.identifier, this.typeAnnotation, equalsValueClause); - }; - - VariableDeclaratorSyntax.prototype.isTypeScriptSpecific = function () { - if (this.typeAnnotation !== null) { - return true; - } - if (this.equalsValueClause !== null && this.equalsValueClause.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return VariableDeclaratorSyntax; - })(TypeScript.SyntaxNode); - TypeScript.VariableDeclaratorSyntax = VariableDeclaratorSyntax; - - var EqualsValueClauseSyntax = (function (_super) { - __extends(EqualsValueClauseSyntax, _super); - function EqualsValueClauseSyntax(equalsToken, value, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.equalsToken = equalsToken; - this.value = value; - } - EqualsValueClauseSyntax.prototype.accept = function (visitor) { - return visitor.visitEqualsValueClause(this); - }; - - EqualsValueClauseSyntax.prototype.kind = function () { - return 230 /* EqualsValueClause */; - }; - - EqualsValueClauseSyntax.prototype.childCount = function () { - return 2; - }; - - EqualsValueClauseSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.equalsToken; - case 1: - return this.value; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - EqualsValueClauseSyntax.prototype.update = function (equalsToken, value) { - if (this.equalsToken === equalsToken && this.value === value) { - return this; - } - - return new EqualsValueClauseSyntax(equalsToken, value, this.parsedInStrictMode()); - }; - - EqualsValueClauseSyntax.create1 = function (value) { - return new EqualsValueClauseSyntax(TypeScript.Syntax.token(108 /* EqualsToken */), value, false); - }; - - EqualsValueClauseSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - EqualsValueClauseSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - EqualsValueClauseSyntax.prototype.withEqualsToken = function (equalsToken) { - return this.update(equalsToken, this.value); - }; - - EqualsValueClauseSyntax.prototype.withValue = function (value) { - return this.update(this.equalsToken, value); - }; - - EqualsValueClauseSyntax.prototype.isTypeScriptSpecific = function () { - if (this.value.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return EqualsValueClauseSyntax; - })(TypeScript.SyntaxNode); - TypeScript.EqualsValueClauseSyntax = EqualsValueClauseSyntax; - - var PrefixUnaryExpressionSyntax = (function (_super) { - __extends(PrefixUnaryExpressionSyntax, _super); - function PrefixUnaryExpressionSyntax(kind, operatorToken, operand, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.operatorToken = operatorToken; - this.operand = operand; - - this._kind = kind; - } - PrefixUnaryExpressionSyntax.prototype.accept = function (visitor) { - return visitor.visitPrefixUnaryExpression(this); - }; - - PrefixUnaryExpressionSyntax.prototype.childCount = function () { - return 2; - }; - - PrefixUnaryExpressionSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.operatorToken; - case 1: - return this.operand; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - PrefixUnaryExpressionSyntax.prototype.isUnaryExpression = function () { - return true; - }; - - PrefixUnaryExpressionSyntax.prototype.isExpression = function () { - return true; - }; - - PrefixUnaryExpressionSyntax.prototype.kind = function () { - return this._kind; - }; - - PrefixUnaryExpressionSyntax.prototype.update = function (kind, operatorToken, operand) { - if (this._kind === kind && this.operatorToken === operatorToken && this.operand === operand) { - return this; - } - - return new PrefixUnaryExpressionSyntax(kind, operatorToken, operand, this.parsedInStrictMode()); - }; - - PrefixUnaryExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - PrefixUnaryExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - PrefixUnaryExpressionSyntax.prototype.withKind = function (kind) { - return this.update(kind, this.operatorToken, this.operand); - }; - - PrefixUnaryExpressionSyntax.prototype.withOperatorToken = function (operatorToken) { - return this.update(this._kind, operatorToken, this.operand); - }; - - PrefixUnaryExpressionSyntax.prototype.withOperand = function (operand) { - return this.update(this._kind, this.operatorToken, operand); - }; - - PrefixUnaryExpressionSyntax.prototype.isTypeScriptSpecific = function () { - if (this.operand.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return PrefixUnaryExpressionSyntax; - })(TypeScript.SyntaxNode); - TypeScript.PrefixUnaryExpressionSyntax = PrefixUnaryExpressionSyntax; - - var ArrayLiteralExpressionSyntax = (function (_super) { - __extends(ArrayLiteralExpressionSyntax, _super); - function ArrayLiteralExpressionSyntax(openBracketToken, expressions, closeBracketToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.openBracketToken = openBracketToken; - this.expressions = expressions; - this.closeBracketToken = closeBracketToken; - } - ArrayLiteralExpressionSyntax.prototype.accept = function (visitor) { - return visitor.visitArrayLiteralExpression(this); - }; - - ArrayLiteralExpressionSyntax.prototype.kind = function () { - return 213 /* ArrayLiteralExpression */; - }; - - ArrayLiteralExpressionSyntax.prototype.childCount = function () { - return 3; - }; - - ArrayLiteralExpressionSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.openBracketToken; - case 1: - return this.expressions; - case 2: - return this.closeBracketToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ArrayLiteralExpressionSyntax.prototype.isUnaryExpression = function () { - return true; - }; - - ArrayLiteralExpressionSyntax.prototype.isExpression = function () { - return true; - }; - - ArrayLiteralExpressionSyntax.prototype.update = function (openBracketToken, expressions, closeBracketToken) { - if (this.openBracketToken === openBracketToken && this.expressions === expressions && this.closeBracketToken === closeBracketToken) { - return this; - } - - return new ArrayLiteralExpressionSyntax(openBracketToken, expressions, closeBracketToken, this.parsedInStrictMode()); - }; - - ArrayLiteralExpressionSyntax.create = function (openBracketToken, closeBracketToken) { - return new ArrayLiteralExpressionSyntax(openBracketToken, TypeScript.Syntax.emptySeparatedList, closeBracketToken, false); - }; - - ArrayLiteralExpressionSyntax.create1 = function () { - return new ArrayLiteralExpressionSyntax(TypeScript.Syntax.token(75 /* OpenBracketToken */), TypeScript.Syntax.emptySeparatedList, TypeScript.Syntax.token(76 /* CloseBracketToken */), false); - }; - - ArrayLiteralExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ArrayLiteralExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ArrayLiteralExpressionSyntax.prototype.withOpenBracketToken = function (openBracketToken) { - return this.update(openBracketToken, this.expressions, this.closeBracketToken); - }; - - ArrayLiteralExpressionSyntax.prototype.withExpressions = function (expressions) { - return this.update(this.openBracketToken, expressions, this.closeBracketToken); - }; - - ArrayLiteralExpressionSyntax.prototype.withExpression = function (expression) { - return this.withExpressions(TypeScript.Syntax.separatedList([expression])); - }; - - ArrayLiteralExpressionSyntax.prototype.withCloseBracketToken = function (closeBracketToken) { - return this.update(this.openBracketToken, this.expressions, closeBracketToken); - }; - - ArrayLiteralExpressionSyntax.prototype.isTypeScriptSpecific = function () { - if (this.expressions.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return ArrayLiteralExpressionSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ArrayLiteralExpressionSyntax = ArrayLiteralExpressionSyntax; - - var OmittedExpressionSyntax = (function (_super) { - __extends(OmittedExpressionSyntax, _super); - function OmittedExpressionSyntax(parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - } - OmittedExpressionSyntax.prototype.accept = function (visitor) { - return visitor.visitOmittedExpression(this); - }; - - OmittedExpressionSyntax.prototype.kind = function () { - return 222 /* OmittedExpression */; - }; - - OmittedExpressionSyntax.prototype.childCount = function () { - return 0; - }; - - OmittedExpressionSyntax.prototype.childAt = function (slot) { - throw TypeScript.Errors.invalidOperation(); - }; - - OmittedExpressionSyntax.prototype.isExpression = function () { - return true; - }; - - OmittedExpressionSyntax.prototype.update = function () { - return this; - }; - - OmittedExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - OmittedExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - OmittedExpressionSyntax.prototype.isTypeScriptSpecific = function () { - return false; - }; - return OmittedExpressionSyntax; - })(TypeScript.SyntaxNode); - TypeScript.OmittedExpressionSyntax = OmittedExpressionSyntax; - - var ParenthesizedExpressionSyntax = (function (_super) { - __extends(ParenthesizedExpressionSyntax, _super); - function ParenthesizedExpressionSyntax(openParenToken, expression, closeParenToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.openParenToken = openParenToken; - this.expression = expression; - this.closeParenToken = closeParenToken; - } - ParenthesizedExpressionSyntax.prototype.accept = function (visitor) { - return visitor.visitParenthesizedExpression(this); - }; - - ParenthesizedExpressionSyntax.prototype.kind = function () { - return 216 /* ParenthesizedExpression */; - }; - - ParenthesizedExpressionSyntax.prototype.childCount = function () { - return 3; - }; - - ParenthesizedExpressionSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.openParenToken; - case 1: - return this.expression; - case 2: - return this.closeParenToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ParenthesizedExpressionSyntax.prototype.isUnaryExpression = function () { - return true; - }; - - ParenthesizedExpressionSyntax.prototype.isExpression = function () { - return true; - }; - - ParenthesizedExpressionSyntax.prototype.update = function (openParenToken, expression, closeParenToken) { - if (this.openParenToken === openParenToken && this.expression === expression && this.closeParenToken === closeParenToken) { - return this; - } - - return new ParenthesizedExpressionSyntax(openParenToken, expression, closeParenToken, this.parsedInStrictMode()); - }; - - ParenthesizedExpressionSyntax.create1 = function (expression) { - return new ParenthesizedExpressionSyntax(TypeScript.Syntax.token(73 /* OpenParenToken */), expression, TypeScript.Syntax.token(74 /* CloseParenToken */), false); - }; - - ParenthesizedExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ParenthesizedExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ParenthesizedExpressionSyntax.prototype.withOpenParenToken = function (openParenToken) { - return this.update(openParenToken, this.expression, this.closeParenToken); - }; - - ParenthesizedExpressionSyntax.prototype.withExpression = function (expression) { - return this.update(this.openParenToken, expression, this.closeParenToken); - }; - - ParenthesizedExpressionSyntax.prototype.withCloseParenToken = function (closeParenToken) { - return this.update(this.openParenToken, this.expression, closeParenToken); - }; - - ParenthesizedExpressionSyntax.prototype.isTypeScriptSpecific = function () { - if (this.expression.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return ParenthesizedExpressionSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ParenthesizedExpressionSyntax = ParenthesizedExpressionSyntax; - - var ArrowFunctionExpressionSyntax = (function (_super) { - __extends(ArrowFunctionExpressionSyntax, _super); - function ArrowFunctionExpressionSyntax(equalsGreaterThanToken, body, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.equalsGreaterThanToken = equalsGreaterThanToken; - this.body = body; - } - ArrowFunctionExpressionSyntax.prototype.isUnaryExpression = function () { - return true; - }; - - ArrowFunctionExpressionSyntax.prototype.isExpression = function () { - return true; - }; - - ArrowFunctionExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ArrowFunctionExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ArrowFunctionExpressionSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return ArrowFunctionExpressionSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ArrowFunctionExpressionSyntax = ArrowFunctionExpressionSyntax; - - var SimpleArrowFunctionExpressionSyntax = (function (_super) { - __extends(SimpleArrowFunctionExpressionSyntax, _super); - function SimpleArrowFunctionExpressionSyntax(identifier, equalsGreaterThanToken, body, parsedInStrictMode) { - _super.call(this, equalsGreaterThanToken, body, parsedInStrictMode); - this.identifier = identifier; - } - SimpleArrowFunctionExpressionSyntax.prototype.accept = function (visitor) { - return visitor.visitSimpleArrowFunctionExpression(this); - }; - - SimpleArrowFunctionExpressionSyntax.prototype.kind = function () { - return 218 /* SimpleArrowFunctionExpression */; - }; - - SimpleArrowFunctionExpressionSyntax.prototype.childCount = function () { - return 3; - }; - - SimpleArrowFunctionExpressionSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.identifier; - case 1: - return this.equalsGreaterThanToken; - case 2: - return this.body; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - SimpleArrowFunctionExpressionSyntax.prototype.update = function (identifier, equalsGreaterThanToken, body) { - if (this.identifier === identifier && this.equalsGreaterThanToken === equalsGreaterThanToken && this.body === body) { - return this; - } - - return new SimpleArrowFunctionExpressionSyntax(identifier, equalsGreaterThanToken, body, this.parsedInStrictMode()); - }; - - SimpleArrowFunctionExpressionSyntax.create1 = function (identifier, body) { - return new SimpleArrowFunctionExpressionSyntax(identifier, TypeScript.Syntax.token(86 /* EqualsGreaterThanToken */), body, false); - }; - - SimpleArrowFunctionExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - SimpleArrowFunctionExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - SimpleArrowFunctionExpressionSyntax.prototype.withIdentifier = function (identifier) { - return this.update(identifier, this.equalsGreaterThanToken, this.body); - }; - - SimpleArrowFunctionExpressionSyntax.prototype.withEqualsGreaterThanToken = function (equalsGreaterThanToken) { - return this.update(this.identifier, equalsGreaterThanToken, this.body); - }; - - SimpleArrowFunctionExpressionSyntax.prototype.withBody = function (body) { - return this.update(this.identifier, this.equalsGreaterThanToken, body); - }; - - SimpleArrowFunctionExpressionSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return SimpleArrowFunctionExpressionSyntax; - })(ArrowFunctionExpressionSyntax); - TypeScript.SimpleArrowFunctionExpressionSyntax = SimpleArrowFunctionExpressionSyntax; - - var ParenthesizedArrowFunctionExpressionSyntax = (function (_super) { - __extends(ParenthesizedArrowFunctionExpressionSyntax, _super); - function ParenthesizedArrowFunctionExpressionSyntax(callSignature, equalsGreaterThanToken, body, parsedInStrictMode) { - _super.call(this, equalsGreaterThanToken, body, parsedInStrictMode); - this.callSignature = callSignature; - } - ParenthesizedArrowFunctionExpressionSyntax.prototype.accept = function (visitor) { - return visitor.visitParenthesizedArrowFunctionExpression(this); - }; - - ParenthesizedArrowFunctionExpressionSyntax.prototype.kind = function () { - return 217 /* ParenthesizedArrowFunctionExpression */; - }; - - ParenthesizedArrowFunctionExpressionSyntax.prototype.childCount = function () { - return 3; - }; - - ParenthesizedArrowFunctionExpressionSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.callSignature; - case 1: - return this.equalsGreaterThanToken; - case 2: - return this.body; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ParenthesizedArrowFunctionExpressionSyntax.prototype.update = function (callSignature, equalsGreaterThanToken, body) { - if (this.callSignature === callSignature && this.equalsGreaterThanToken === equalsGreaterThanToken && this.body === body) { - return this; - } - - return new ParenthesizedArrowFunctionExpressionSyntax(callSignature, equalsGreaterThanToken, body, this.parsedInStrictMode()); - }; - - ParenthesizedArrowFunctionExpressionSyntax.create1 = function (body) { - return new ParenthesizedArrowFunctionExpressionSyntax(CallSignatureSyntax.create1(), TypeScript.Syntax.token(86 /* EqualsGreaterThanToken */), body, false); - }; - - ParenthesizedArrowFunctionExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ParenthesizedArrowFunctionExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ParenthesizedArrowFunctionExpressionSyntax.prototype.withCallSignature = function (callSignature) { - return this.update(callSignature, this.equalsGreaterThanToken, this.body); - }; - - ParenthesizedArrowFunctionExpressionSyntax.prototype.withEqualsGreaterThanToken = function (equalsGreaterThanToken) { - return this.update(this.callSignature, equalsGreaterThanToken, this.body); - }; - - ParenthesizedArrowFunctionExpressionSyntax.prototype.withBody = function (body) { - return this.update(this.callSignature, this.equalsGreaterThanToken, body); - }; - - ParenthesizedArrowFunctionExpressionSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return ParenthesizedArrowFunctionExpressionSyntax; - })(ArrowFunctionExpressionSyntax); - TypeScript.ParenthesizedArrowFunctionExpressionSyntax = ParenthesizedArrowFunctionExpressionSyntax; - - var QualifiedNameSyntax = (function (_super) { - __extends(QualifiedNameSyntax, _super); - function QualifiedNameSyntax(left, dotToken, right, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.left = left; - this.dotToken = dotToken; - this.right = right; - } - QualifiedNameSyntax.prototype.accept = function (visitor) { - return visitor.visitQualifiedName(this); - }; - - QualifiedNameSyntax.prototype.kind = function () { - return 122 /* QualifiedName */; - }; - - QualifiedNameSyntax.prototype.childCount = function () { - return 3; - }; - - QualifiedNameSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.left; - case 1: - return this.dotToken; - case 2: - return this.right; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - QualifiedNameSyntax.prototype.isName = function () { - return true; - }; - - QualifiedNameSyntax.prototype.isType = function () { - return true; - }; - - QualifiedNameSyntax.prototype.isUnaryExpression = function () { - return true; - }; - - QualifiedNameSyntax.prototype.isExpression = function () { - return true; - }; - - QualifiedNameSyntax.prototype.update = function (left, dotToken, right) { - if (this.left === left && this.dotToken === dotToken && this.right === right) { - return this; - } - - return new QualifiedNameSyntax(left, dotToken, right, this.parsedInStrictMode()); - }; - - QualifiedNameSyntax.create1 = function (left, right) { - return new QualifiedNameSyntax(left, TypeScript.Syntax.token(77 /* DotToken */), right, false); - }; - - QualifiedNameSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - QualifiedNameSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - QualifiedNameSyntax.prototype.withLeft = function (left) { - return this.update(left, this.dotToken, this.right); - }; - - QualifiedNameSyntax.prototype.withDotToken = function (dotToken) { - return this.update(this.left, dotToken, this.right); - }; - - QualifiedNameSyntax.prototype.withRight = function (right) { - return this.update(this.left, this.dotToken, right); - }; - - QualifiedNameSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return QualifiedNameSyntax; - })(TypeScript.SyntaxNode); - TypeScript.QualifiedNameSyntax = QualifiedNameSyntax; - - var TypeArgumentListSyntax = (function (_super) { - __extends(TypeArgumentListSyntax, _super); - function TypeArgumentListSyntax(lessThanToken, typeArguments, greaterThanToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.lessThanToken = lessThanToken; - this.typeArguments = typeArguments; - this.greaterThanToken = greaterThanToken; - } - TypeArgumentListSyntax.prototype.accept = function (visitor) { - return visitor.visitTypeArgumentList(this); - }; - - TypeArgumentListSyntax.prototype.kind = function () { - return 227 /* TypeArgumentList */; - }; - - TypeArgumentListSyntax.prototype.childCount = function () { - return 3; - }; - - TypeArgumentListSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.lessThanToken; - case 1: - return this.typeArguments; - case 2: - return this.greaterThanToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - TypeArgumentListSyntax.prototype.update = function (lessThanToken, typeArguments, greaterThanToken) { - if (this.lessThanToken === lessThanToken && this.typeArguments === typeArguments && this.greaterThanToken === greaterThanToken) { - return this; - } - - return new TypeArgumentListSyntax(lessThanToken, typeArguments, greaterThanToken, this.parsedInStrictMode()); - }; - - TypeArgumentListSyntax.create = function (lessThanToken, greaterThanToken) { - return new TypeArgumentListSyntax(lessThanToken, TypeScript.Syntax.emptySeparatedList, greaterThanToken, false); - }; - - TypeArgumentListSyntax.create1 = function () { - return new TypeArgumentListSyntax(TypeScript.Syntax.token(81 /* LessThanToken */), TypeScript.Syntax.emptySeparatedList, TypeScript.Syntax.token(82 /* GreaterThanToken */), false); - }; - - TypeArgumentListSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - TypeArgumentListSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - TypeArgumentListSyntax.prototype.withLessThanToken = function (lessThanToken) { - return this.update(lessThanToken, this.typeArguments, this.greaterThanToken); - }; - - TypeArgumentListSyntax.prototype.withTypeArguments = function (typeArguments) { - return this.update(this.lessThanToken, typeArguments, this.greaterThanToken); - }; - - TypeArgumentListSyntax.prototype.withTypeArgument = function (typeArgument) { - return this.withTypeArguments(TypeScript.Syntax.separatedList([typeArgument])); - }; - - TypeArgumentListSyntax.prototype.withGreaterThanToken = function (greaterThanToken) { - return this.update(this.lessThanToken, this.typeArguments, greaterThanToken); - }; - - TypeArgumentListSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return TypeArgumentListSyntax; - })(TypeScript.SyntaxNode); - TypeScript.TypeArgumentListSyntax = TypeArgumentListSyntax; - - var ConstructorTypeSyntax = (function (_super) { - __extends(ConstructorTypeSyntax, _super); - function ConstructorTypeSyntax(newKeyword, typeParameterList, parameterList, equalsGreaterThanToken, type, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.newKeyword = newKeyword; - this.typeParameterList = typeParameterList; - this.parameterList = parameterList; - this.equalsGreaterThanToken = equalsGreaterThanToken; - this.type = type; - } - ConstructorTypeSyntax.prototype.accept = function (visitor) { - return visitor.visitConstructorType(this); - }; - - ConstructorTypeSyntax.prototype.kind = function () { - return 126 /* ConstructorType */; - }; - - ConstructorTypeSyntax.prototype.childCount = function () { - return 5; - }; - - ConstructorTypeSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.newKeyword; - case 1: - return this.typeParameterList; - case 2: - return this.parameterList; - case 3: - return this.equalsGreaterThanToken; - case 4: - return this.type; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ConstructorTypeSyntax.prototype.isType = function () { - return true; - }; - - ConstructorTypeSyntax.prototype.isUnaryExpression = function () { - return true; - }; - - ConstructorTypeSyntax.prototype.isExpression = function () { - return true; - }; - - ConstructorTypeSyntax.prototype.update = function (newKeyword, typeParameterList, parameterList, equalsGreaterThanToken, type) { - if (this.newKeyword === newKeyword && this.typeParameterList === typeParameterList && this.parameterList === parameterList && this.equalsGreaterThanToken === equalsGreaterThanToken && this.type === type) { - return this; - } - - return new ConstructorTypeSyntax(newKeyword, typeParameterList, parameterList, equalsGreaterThanToken, type, this.parsedInStrictMode()); - }; - - ConstructorTypeSyntax.create = function (newKeyword, parameterList, equalsGreaterThanToken, type) { - return new ConstructorTypeSyntax(newKeyword, null, parameterList, equalsGreaterThanToken, type, false); - }; - - ConstructorTypeSyntax.create1 = function (type) { - return new ConstructorTypeSyntax(TypeScript.Syntax.token(31 /* NewKeyword */), null, ParameterListSyntax.create1(), TypeScript.Syntax.token(86 /* EqualsGreaterThanToken */), type, false); - }; - - ConstructorTypeSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ConstructorTypeSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ConstructorTypeSyntax.prototype.withNewKeyword = function (newKeyword) { - return this.update(newKeyword, this.typeParameterList, this.parameterList, this.equalsGreaterThanToken, this.type); - }; - - ConstructorTypeSyntax.prototype.withTypeParameterList = function (typeParameterList) { - return this.update(this.newKeyword, typeParameterList, this.parameterList, this.equalsGreaterThanToken, this.type); - }; - - ConstructorTypeSyntax.prototype.withParameterList = function (parameterList) { - return this.update(this.newKeyword, this.typeParameterList, parameterList, this.equalsGreaterThanToken, this.type); - }; - - ConstructorTypeSyntax.prototype.withEqualsGreaterThanToken = function (equalsGreaterThanToken) { - return this.update(this.newKeyword, this.typeParameterList, this.parameterList, equalsGreaterThanToken, this.type); - }; - - ConstructorTypeSyntax.prototype.withType = function (type) { - return this.update(this.newKeyword, this.typeParameterList, this.parameterList, this.equalsGreaterThanToken, type); - }; - - ConstructorTypeSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return ConstructorTypeSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ConstructorTypeSyntax = ConstructorTypeSyntax; - - var FunctionTypeSyntax = (function (_super) { - __extends(FunctionTypeSyntax, _super); - function FunctionTypeSyntax(typeParameterList, parameterList, equalsGreaterThanToken, type, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.typeParameterList = typeParameterList; - this.parameterList = parameterList; - this.equalsGreaterThanToken = equalsGreaterThanToken; - this.type = type; - } - FunctionTypeSyntax.prototype.accept = function (visitor) { - return visitor.visitFunctionType(this); - }; - - FunctionTypeSyntax.prototype.kind = function () { - return 124 /* FunctionType */; - }; - - FunctionTypeSyntax.prototype.childCount = function () { - return 4; - }; - - FunctionTypeSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.typeParameterList; - case 1: - return this.parameterList; - case 2: - return this.equalsGreaterThanToken; - case 3: - return this.type; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - FunctionTypeSyntax.prototype.isType = function () { - return true; - }; - - FunctionTypeSyntax.prototype.isUnaryExpression = function () { - return true; - }; - - FunctionTypeSyntax.prototype.isExpression = function () { - return true; - }; - - FunctionTypeSyntax.prototype.update = function (typeParameterList, parameterList, equalsGreaterThanToken, type) { - if (this.typeParameterList === typeParameterList && this.parameterList === parameterList && this.equalsGreaterThanToken === equalsGreaterThanToken && this.type === type) { - return this; - } - - return new FunctionTypeSyntax(typeParameterList, parameterList, equalsGreaterThanToken, type, this.parsedInStrictMode()); - }; - - FunctionTypeSyntax.create = function (parameterList, equalsGreaterThanToken, type) { - return new FunctionTypeSyntax(null, parameterList, equalsGreaterThanToken, type, false); - }; - - FunctionTypeSyntax.create1 = function (type) { - return new FunctionTypeSyntax(null, ParameterListSyntax.create1(), TypeScript.Syntax.token(86 /* EqualsGreaterThanToken */), type, false); - }; - - FunctionTypeSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - FunctionTypeSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - FunctionTypeSyntax.prototype.withTypeParameterList = function (typeParameterList) { - return this.update(typeParameterList, this.parameterList, this.equalsGreaterThanToken, this.type); - }; - - FunctionTypeSyntax.prototype.withParameterList = function (parameterList) { - return this.update(this.typeParameterList, parameterList, this.equalsGreaterThanToken, this.type); - }; - - FunctionTypeSyntax.prototype.withEqualsGreaterThanToken = function (equalsGreaterThanToken) { - return this.update(this.typeParameterList, this.parameterList, equalsGreaterThanToken, this.type); - }; - - FunctionTypeSyntax.prototype.withType = function (type) { - return this.update(this.typeParameterList, this.parameterList, this.equalsGreaterThanToken, type); - }; - - FunctionTypeSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return FunctionTypeSyntax; - })(TypeScript.SyntaxNode); - TypeScript.FunctionTypeSyntax = FunctionTypeSyntax; - - var ObjectTypeSyntax = (function (_super) { - __extends(ObjectTypeSyntax, _super); - function ObjectTypeSyntax(openBraceToken, typeMembers, closeBraceToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.openBraceToken = openBraceToken; - this.typeMembers = typeMembers; - this.closeBraceToken = closeBraceToken; - } - ObjectTypeSyntax.prototype.accept = function (visitor) { - return visitor.visitObjectType(this); - }; - - ObjectTypeSyntax.prototype.kind = function () { - return 123 /* ObjectType */; - }; - - ObjectTypeSyntax.prototype.childCount = function () { - return 3; - }; - - ObjectTypeSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.openBraceToken; - case 1: - return this.typeMembers; - case 2: - return this.closeBraceToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ObjectTypeSyntax.prototype.isType = function () { - return true; - }; - - ObjectTypeSyntax.prototype.isUnaryExpression = function () { - return true; - }; - - ObjectTypeSyntax.prototype.isExpression = function () { - return true; - }; - - ObjectTypeSyntax.prototype.update = function (openBraceToken, typeMembers, closeBraceToken) { - if (this.openBraceToken === openBraceToken && this.typeMembers === typeMembers && this.closeBraceToken === closeBraceToken) { - return this; - } - - return new ObjectTypeSyntax(openBraceToken, typeMembers, closeBraceToken, this.parsedInStrictMode()); - }; - - ObjectTypeSyntax.create = function (openBraceToken, closeBraceToken) { - return new ObjectTypeSyntax(openBraceToken, TypeScript.Syntax.emptySeparatedList, closeBraceToken, false); - }; - - ObjectTypeSyntax.create1 = function () { - return new ObjectTypeSyntax(TypeScript.Syntax.token(71 /* OpenBraceToken */), TypeScript.Syntax.emptySeparatedList, TypeScript.Syntax.token(72 /* CloseBraceToken */), false); - }; - - ObjectTypeSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ObjectTypeSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ObjectTypeSyntax.prototype.withOpenBraceToken = function (openBraceToken) { - return this.update(openBraceToken, this.typeMembers, this.closeBraceToken); - }; - - ObjectTypeSyntax.prototype.withTypeMembers = function (typeMembers) { - return this.update(this.openBraceToken, typeMembers, this.closeBraceToken); - }; - - ObjectTypeSyntax.prototype.withTypeMember = function (typeMember) { - return this.withTypeMembers(TypeScript.Syntax.separatedList([typeMember])); - }; - - ObjectTypeSyntax.prototype.withCloseBraceToken = function (closeBraceToken) { - return this.update(this.openBraceToken, this.typeMembers, closeBraceToken); - }; - - ObjectTypeSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return ObjectTypeSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ObjectTypeSyntax = ObjectTypeSyntax; - - var ArrayTypeSyntax = (function (_super) { - __extends(ArrayTypeSyntax, _super); - function ArrayTypeSyntax(type, openBracketToken, closeBracketToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.type = type; - this.openBracketToken = openBracketToken; - this.closeBracketToken = closeBracketToken; - } - ArrayTypeSyntax.prototype.accept = function (visitor) { - return visitor.visitArrayType(this); - }; - - ArrayTypeSyntax.prototype.kind = function () { - return 125 /* ArrayType */; - }; - - ArrayTypeSyntax.prototype.childCount = function () { - return 3; - }; - - ArrayTypeSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.type; - case 1: - return this.openBracketToken; - case 2: - return this.closeBracketToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ArrayTypeSyntax.prototype.isType = function () { - return true; - }; - - ArrayTypeSyntax.prototype.isUnaryExpression = function () { - return true; - }; - - ArrayTypeSyntax.prototype.isExpression = function () { - return true; - }; - - ArrayTypeSyntax.prototype.update = function (type, openBracketToken, closeBracketToken) { - if (this.type === type && this.openBracketToken === openBracketToken && this.closeBracketToken === closeBracketToken) { - return this; - } - - return new ArrayTypeSyntax(type, openBracketToken, closeBracketToken, this.parsedInStrictMode()); - }; - - ArrayTypeSyntax.create1 = function (type) { - return new ArrayTypeSyntax(type, TypeScript.Syntax.token(75 /* OpenBracketToken */), TypeScript.Syntax.token(76 /* CloseBracketToken */), false); - }; - - ArrayTypeSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ArrayTypeSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ArrayTypeSyntax.prototype.withType = function (type) { - return this.update(type, this.openBracketToken, this.closeBracketToken); - }; - - ArrayTypeSyntax.prototype.withOpenBracketToken = function (openBracketToken) { - return this.update(this.type, openBracketToken, this.closeBracketToken); - }; - - ArrayTypeSyntax.prototype.withCloseBracketToken = function (closeBracketToken) { - return this.update(this.type, this.openBracketToken, closeBracketToken); - }; - - ArrayTypeSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return ArrayTypeSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ArrayTypeSyntax = ArrayTypeSyntax; - - var GenericTypeSyntax = (function (_super) { - __extends(GenericTypeSyntax, _super); - function GenericTypeSyntax(name, typeArgumentList, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.name = name; - this.typeArgumentList = typeArgumentList; - } - GenericTypeSyntax.prototype.accept = function (visitor) { - return visitor.visitGenericType(this); - }; - - GenericTypeSyntax.prototype.kind = function () { - return 127 /* GenericType */; - }; - - GenericTypeSyntax.prototype.childCount = function () { - return 2; - }; - - GenericTypeSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.name; - case 1: - return this.typeArgumentList; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - GenericTypeSyntax.prototype.isType = function () { - return true; - }; - - GenericTypeSyntax.prototype.isUnaryExpression = function () { - return true; - }; - - GenericTypeSyntax.prototype.isExpression = function () { - return true; - }; - - GenericTypeSyntax.prototype.update = function (name, typeArgumentList) { - if (this.name === name && this.typeArgumentList === typeArgumentList) { - return this; - } - - return new GenericTypeSyntax(name, typeArgumentList, this.parsedInStrictMode()); - }; - - GenericTypeSyntax.create1 = function (name) { - return new GenericTypeSyntax(name, TypeArgumentListSyntax.create1(), false); - }; - - GenericTypeSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - GenericTypeSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - GenericTypeSyntax.prototype.withName = function (name) { - return this.update(name, this.typeArgumentList); - }; - - GenericTypeSyntax.prototype.withTypeArgumentList = function (typeArgumentList) { - return this.update(this.name, typeArgumentList); - }; - - GenericTypeSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return GenericTypeSyntax; - })(TypeScript.SyntaxNode); - TypeScript.GenericTypeSyntax = GenericTypeSyntax; - - var TypeAnnotationSyntax = (function (_super) { - __extends(TypeAnnotationSyntax, _super); - function TypeAnnotationSyntax(colonToken, type, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.colonToken = colonToken; - this.type = type; - } - TypeAnnotationSyntax.prototype.accept = function (visitor) { - return visitor.visitTypeAnnotation(this); - }; - - TypeAnnotationSyntax.prototype.kind = function () { - return 244 /* TypeAnnotation */; - }; - - TypeAnnotationSyntax.prototype.childCount = function () { - return 2; - }; - - TypeAnnotationSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.colonToken; - case 1: - return this.type; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - TypeAnnotationSyntax.prototype.update = function (colonToken, type) { - if (this.colonToken === colonToken && this.type === type) { - return this; - } - - return new TypeAnnotationSyntax(colonToken, type, this.parsedInStrictMode()); - }; - - TypeAnnotationSyntax.create1 = function (type) { - return new TypeAnnotationSyntax(TypeScript.Syntax.token(107 /* ColonToken */), type, false); - }; - - TypeAnnotationSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - TypeAnnotationSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - TypeAnnotationSyntax.prototype.withColonToken = function (colonToken) { - return this.update(colonToken, this.type); - }; - - TypeAnnotationSyntax.prototype.withType = function (type) { - return this.update(this.colonToken, type); - }; - - TypeAnnotationSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return TypeAnnotationSyntax; - })(TypeScript.SyntaxNode); - TypeScript.TypeAnnotationSyntax = TypeAnnotationSyntax; - - var BlockSyntax = (function (_super) { - __extends(BlockSyntax, _super); - function BlockSyntax(openBraceToken, statements, closeBraceToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.openBraceToken = openBraceToken; - this.statements = statements; - this.closeBraceToken = closeBraceToken; - } - BlockSyntax.prototype.accept = function (visitor) { - return visitor.visitBlock(this); - }; - - BlockSyntax.prototype.kind = function () { - return 145 /* Block */; - }; - - BlockSyntax.prototype.childCount = function () { - return 3; - }; - - BlockSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.openBraceToken; - case 1: - return this.statements; - case 2: - return this.closeBraceToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - BlockSyntax.prototype.isStatement = function () { - return true; - }; - - BlockSyntax.prototype.isModuleElement = function () { - return true; - }; - - BlockSyntax.prototype.update = function (openBraceToken, statements, closeBraceToken) { - if (this.openBraceToken === openBraceToken && this.statements === statements && this.closeBraceToken === closeBraceToken) { - return this; - } - - return new BlockSyntax(openBraceToken, statements, closeBraceToken, this.parsedInStrictMode()); - }; - - BlockSyntax.create = function (openBraceToken, closeBraceToken) { - return new BlockSyntax(openBraceToken, TypeScript.Syntax.emptyList, closeBraceToken, false); - }; - - BlockSyntax.create1 = function () { - return new BlockSyntax(TypeScript.Syntax.token(71 /* OpenBraceToken */), TypeScript.Syntax.emptyList, TypeScript.Syntax.token(72 /* CloseBraceToken */), false); - }; - - BlockSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - BlockSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - BlockSyntax.prototype.withOpenBraceToken = function (openBraceToken) { - return this.update(openBraceToken, this.statements, this.closeBraceToken); - }; - - BlockSyntax.prototype.withStatements = function (statements) { - return this.update(this.openBraceToken, statements, this.closeBraceToken); - }; - - BlockSyntax.prototype.withStatement = function (statement) { - return this.withStatements(TypeScript.Syntax.list([statement])); - }; - - BlockSyntax.prototype.withCloseBraceToken = function (closeBraceToken) { - return this.update(this.openBraceToken, this.statements, closeBraceToken); - }; - - BlockSyntax.prototype.isTypeScriptSpecific = function () { - if (this.statements.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return BlockSyntax; - })(TypeScript.SyntaxNode); - TypeScript.BlockSyntax = BlockSyntax; - - var ParameterSyntax = (function (_super) { - __extends(ParameterSyntax, _super); - function ParameterSyntax(dotDotDotToken, publicOrPrivateKeyword, identifier, questionToken, typeAnnotation, equalsValueClause, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.dotDotDotToken = dotDotDotToken; - this.publicOrPrivateKeyword = publicOrPrivateKeyword; - this.identifier = identifier; - this.questionToken = questionToken; - this.typeAnnotation = typeAnnotation; - this.equalsValueClause = equalsValueClause; - } - ParameterSyntax.prototype.accept = function (visitor) { - return visitor.visitParameter(this); - }; - - ParameterSyntax.prototype.kind = function () { - return 242 /* Parameter */; - }; - - ParameterSyntax.prototype.childCount = function () { - return 6; - }; - - ParameterSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.dotDotDotToken; - case 1: - return this.publicOrPrivateKeyword; - case 2: - return this.identifier; - case 3: - return this.questionToken; - case 4: - return this.typeAnnotation; - case 5: - return this.equalsValueClause; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ParameterSyntax.prototype.update = function (dotDotDotToken, publicOrPrivateKeyword, identifier, questionToken, typeAnnotation, equalsValueClause) { - if (this.dotDotDotToken === dotDotDotToken && this.publicOrPrivateKeyword === publicOrPrivateKeyword && this.identifier === identifier && this.questionToken === questionToken && this.typeAnnotation === typeAnnotation && this.equalsValueClause === equalsValueClause) { - return this; - } - - return new ParameterSyntax(dotDotDotToken, publicOrPrivateKeyword, identifier, questionToken, typeAnnotation, equalsValueClause, this.parsedInStrictMode()); - }; - - ParameterSyntax.create = function (identifier) { - return new ParameterSyntax(null, null, identifier, null, null, null, false); - }; - - ParameterSyntax.create1 = function (identifier) { - return new ParameterSyntax(null, null, identifier, null, null, null, false); - }; - - ParameterSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ParameterSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ParameterSyntax.prototype.withDotDotDotToken = function (dotDotDotToken) { - return this.update(dotDotDotToken, this.publicOrPrivateKeyword, this.identifier, this.questionToken, this.typeAnnotation, this.equalsValueClause); - }; - - ParameterSyntax.prototype.withPublicOrPrivateKeyword = function (publicOrPrivateKeyword) { - return this.update(this.dotDotDotToken, publicOrPrivateKeyword, this.identifier, this.questionToken, this.typeAnnotation, this.equalsValueClause); - }; - - ParameterSyntax.prototype.withIdentifier = function (identifier) { - return this.update(this.dotDotDotToken, this.publicOrPrivateKeyword, identifier, this.questionToken, this.typeAnnotation, this.equalsValueClause); - }; - - ParameterSyntax.prototype.withQuestionToken = function (questionToken) { - return this.update(this.dotDotDotToken, this.publicOrPrivateKeyword, this.identifier, questionToken, this.typeAnnotation, this.equalsValueClause); - }; - - ParameterSyntax.prototype.withTypeAnnotation = function (typeAnnotation) { - return this.update(this.dotDotDotToken, this.publicOrPrivateKeyword, this.identifier, this.questionToken, typeAnnotation, this.equalsValueClause); - }; - - ParameterSyntax.prototype.withEqualsValueClause = function (equalsValueClause) { - return this.update(this.dotDotDotToken, this.publicOrPrivateKeyword, this.identifier, this.questionToken, this.typeAnnotation, equalsValueClause); - }; - - ParameterSyntax.prototype.isTypeScriptSpecific = function () { - if (this.dotDotDotToken !== null) { - return true; - } - if (this.publicOrPrivateKeyword !== null) { - return true; - } - if (this.questionToken !== null) { - return true; - } - if (this.typeAnnotation !== null) { - return true; - } - if (this.equalsValueClause !== null) { - return true; - } - return false; - }; - return ParameterSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ParameterSyntax = ParameterSyntax; - - var MemberAccessExpressionSyntax = (function (_super) { - __extends(MemberAccessExpressionSyntax, _super); - function MemberAccessExpressionSyntax(expression, dotToken, name, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.expression = expression; - this.dotToken = dotToken; - this.name = name; - } - MemberAccessExpressionSyntax.prototype.accept = function (visitor) { - return visitor.visitMemberAccessExpression(this); - }; - - MemberAccessExpressionSyntax.prototype.kind = function () { - return 211 /* MemberAccessExpression */; - }; - - MemberAccessExpressionSyntax.prototype.childCount = function () { - return 3; - }; - - MemberAccessExpressionSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.expression; - case 1: - return this.dotToken; - case 2: - return this.name; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - MemberAccessExpressionSyntax.prototype.isUnaryExpression = function () { - return true; - }; - - MemberAccessExpressionSyntax.prototype.isExpression = function () { - return true; - }; - - MemberAccessExpressionSyntax.prototype.update = function (expression, dotToken, name) { - if (this.expression === expression && this.dotToken === dotToken && this.name === name) { - return this; - } - - return new MemberAccessExpressionSyntax(expression, dotToken, name, this.parsedInStrictMode()); - }; - - MemberAccessExpressionSyntax.create1 = function (expression, name) { - return new MemberAccessExpressionSyntax(expression, TypeScript.Syntax.token(77 /* DotToken */), name, false); - }; - - MemberAccessExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - MemberAccessExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - MemberAccessExpressionSyntax.prototype.withExpression = function (expression) { - return this.update(expression, this.dotToken, this.name); - }; - - MemberAccessExpressionSyntax.prototype.withDotToken = function (dotToken) { - return this.update(this.expression, dotToken, this.name); - }; - - MemberAccessExpressionSyntax.prototype.withName = function (name) { - return this.update(this.expression, this.dotToken, name); - }; - - MemberAccessExpressionSyntax.prototype.isTypeScriptSpecific = function () { - if (this.expression.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return MemberAccessExpressionSyntax; - })(TypeScript.SyntaxNode); - TypeScript.MemberAccessExpressionSyntax = MemberAccessExpressionSyntax; - - var PostfixUnaryExpressionSyntax = (function (_super) { - __extends(PostfixUnaryExpressionSyntax, _super); - function PostfixUnaryExpressionSyntax(kind, operand, operatorToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.operand = operand; - this.operatorToken = operatorToken; - - this._kind = kind; - } - PostfixUnaryExpressionSyntax.prototype.accept = function (visitor) { - return visitor.visitPostfixUnaryExpression(this); - }; - - PostfixUnaryExpressionSyntax.prototype.childCount = function () { - return 2; - }; - - PostfixUnaryExpressionSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.operand; - case 1: - return this.operatorToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - PostfixUnaryExpressionSyntax.prototype.isUnaryExpression = function () { - return true; - }; - - PostfixUnaryExpressionSyntax.prototype.isExpression = function () { - return true; - }; - - PostfixUnaryExpressionSyntax.prototype.kind = function () { - return this._kind; - }; - - PostfixUnaryExpressionSyntax.prototype.update = function (kind, operand, operatorToken) { - if (this._kind === kind && this.operand === operand && this.operatorToken === operatorToken) { - return this; - } - - return new PostfixUnaryExpressionSyntax(kind, operand, operatorToken, this.parsedInStrictMode()); - }; - - PostfixUnaryExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - PostfixUnaryExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - PostfixUnaryExpressionSyntax.prototype.withKind = function (kind) { - return this.update(kind, this.operand, this.operatorToken); - }; - - PostfixUnaryExpressionSyntax.prototype.withOperand = function (operand) { - return this.update(this._kind, operand, this.operatorToken); - }; - - PostfixUnaryExpressionSyntax.prototype.withOperatorToken = function (operatorToken) { - return this.update(this._kind, this.operand, operatorToken); - }; - - PostfixUnaryExpressionSyntax.prototype.isTypeScriptSpecific = function () { - if (this.operand.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return PostfixUnaryExpressionSyntax; - })(TypeScript.SyntaxNode); - TypeScript.PostfixUnaryExpressionSyntax = PostfixUnaryExpressionSyntax; - - var ElementAccessExpressionSyntax = (function (_super) { - __extends(ElementAccessExpressionSyntax, _super); - function ElementAccessExpressionSyntax(expression, openBracketToken, argumentExpression, closeBracketToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.expression = expression; - this.openBracketToken = openBracketToken; - this.argumentExpression = argumentExpression; - this.closeBracketToken = closeBracketToken; - } - ElementAccessExpressionSyntax.prototype.accept = function (visitor) { - return visitor.visitElementAccessExpression(this); - }; - - ElementAccessExpressionSyntax.prototype.kind = function () { - return 220 /* ElementAccessExpression */; - }; - - ElementAccessExpressionSyntax.prototype.childCount = function () { - return 4; - }; - - ElementAccessExpressionSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.expression; - case 1: - return this.openBracketToken; - case 2: - return this.argumentExpression; - case 3: - return this.closeBracketToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ElementAccessExpressionSyntax.prototype.isUnaryExpression = function () { - return true; - }; - - ElementAccessExpressionSyntax.prototype.isExpression = function () { - return true; - }; - - ElementAccessExpressionSyntax.prototype.update = function (expression, openBracketToken, argumentExpression, closeBracketToken) { - if (this.expression === expression && this.openBracketToken === openBracketToken && this.argumentExpression === argumentExpression && this.closeBracketToken === closeBracketToken) { - return this; - } - - return new ElementAccessExpressionSyntax(expression, openBracketToken, argumentExpression, closeBracketToken, this.parsedInStrictMode()); - }; - - ElementAccessExpressionSyntax.create1 = function (expression, argumentExpression) { - return new ElementAccessExpressionSyntax(expression, TypeScript.Syntax.token(75 /* OpenBracketToken */), argumentExpression, TypeScript.Syntax.token(76 /* CloseBracketToken */), false); - }; - - ElementAccessExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ElementAccessExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ElementAccessExpressionSyntax.prototype.withExpression = function (expression) { - return this.update(expression, this.openBracketToken, this.argumentExpression, this.closeBracketToken); - }; - - ElementAccessExpressionSyntax.prototype.withOpenBracketToken = function (openBracketToken) { - return this.update(this.expression, openBracketToken, this.argumentExpression, this.closeBracketToken); - }; - - ElementAccessExpressionSyntax.prototype.withArgumentExpression = function (argumentExpression) { - return this.update(this.expression, this.openBracketToken, argumentExpression, this.closeBracketToken); - }; - - ElementAccessExpressionSyntax.prototype.withCloseBracketToken = function (closeBracketToken) { - return this.update(this.expression, this.openBracketToken, this.argumentExpression, closeBracketToken); - }; - - ElementAccessExpressionSyntax.prototype.isTypeScriptSpecific = function () { - if (this.expression.isTypeScriptSpecific()) { - return true; - } - if (this.argumentExpression.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return ElementAccessExpressionSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ElementAccessExpressionSyntax = ElementAccessExpressionSyntax; - - var InvocationExpressionSyntax = (function (_super) { - __extends(InvocationExpressionSyntax, _super); - function InvocationExpressionSyntax(expression, argumentList, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.expression = expression; - this.argumentList = argumentList; - } - InvocationExpressionSyntax.prototype.accept = function (visitor) { - return visitor.visitInvocationExpression(this); - }; - - InvocationExpressionSyntax.prototype.kind = function () { - return 212 /* InvocationExpression */; - }; - - InvocationExpressionSyntax.prototype.childCount = function () { - return 2; - }; - - InvocationExpressionSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.expression; - case 1: - return this.argumentList; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - InvocationExpressionSyntax.prototype.isUnaryExpression = function () { - return true; - }; - - InvocationExpressionSyntax.prototype.isExpression = function () { - return true; - }; - - InvocationExpressionSyntax.prototype.update = function (expression, argumentList) { - if (this.expression === expression && this.argumentList === argumentList) { - return this; - } - - return new InvocationExpressionSyntax(expression, argumentList, this.parsedInStrictMode()); - }; - - InvocationExpressionSyntax.create1 = function (expression) { - return new InvocationExpressionSyntax(expression, ArgumentListSyntax.create1(), false); - }; - - InvocationExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - InvocationExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - InvocationExpressionSyntax.prototype.withExpression = function (expression) { - return this.update(expression, this.argumentList); - }; - - InvocationExpressionSyntax.prototype.withArgumentList = function (argumentList) { - return this.update(this.expression, argumentList); - }; - - InvocationExpressionSyntax.prototype.isTypeScriptSpecific = function () { - if (this.expression.isTypeScriptSpecific()) { - return true; - } - if (this.argumentList.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return InvocationExpressionSyntax; - })(TypeScript.SyntaxNode); - TypeScript.InvocationExpressionSyntax = InvocationExpressionSyntax; - - var ArgumentListSyntax = (function (_super) { - __extends(ArgumentListSyntax, _super); - function ArgumentListSyntax(typeArgumentList, openParenToken, arguments, closeParenToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.typeArgumentList = typeArgumentList; - this.openParenToken = openParenToken; - this.arguments = arguments; - this.closeParenToken = closeParenToken; - } - ArgumentListSyntax.prototype.accept = function (visitor) { - return visitor.visitArgumentList(this); - }; - - ArgumentListSyntax.prototype.kind = function () { - return 225 /* ArgumentList */; - }; - - ArgumentListSyntax.prototype.childCount = function () { - return 4; - }; - - ArgumentListSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.typeArgumentList; - case 1: - return this.openParenToken; - case 2: - return this.arguments; - case 3: - return this.closeParenToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ArgumentListSyntax.prototype.update = function (typeArgumentList, openParenToken, _arguments, closeParenToken) { - if (this.typeArgumentList === typeArgumentList && this.openParenToken === openParenToken && this.arguments === _arguments && this.closeParenToken === closeParenToken) { - return this; - } - - return new ArgumentListSyntax(typeArgumentList, openParenToken, _arguments, closeParenToken, this.parsedInStrictMode()); - }; - - ArgumentListSyntax.create = function (openParenToken, closeParenToken) { - return new ArgumentListSyntax(null, openParenToken, TypeScript.Syntax.emptySeparatedList, closeParenToken, false); - }; - - ArgumentListSyntax.create1 = function () { - return new ArgumentListSyntax(null, TypeScript.Syntax.token(73 /* OpenParenToken */), TypeScript.Syntax.emptySeparatedList, TypeScript.Syntax.token(74 /* CloseParenToken */), false); - }; - - ArgumentListSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ArgumentListSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ArgumentListSyntax.prototype.withTypeArgumentList = function (typeArgumentList) { - return this.update(typeArgumentList, this.openParenToken, this.arguments, this.closeParenToken); - }; - - ArgumentListSyntax.prototype.withOpenParenToken = function (openParenToken) { - return this.update(this.typeArgumentList, openParenToken, this.arguments, this.closeParenToken); - }; - - ArgumentListSyntax.prototype.withArguments = function (_arguments) { - return this.update(this.typeArgumentList, this.openParenToken, _arguments, this.closeParenToken); - }; - - ArgumentListSyntax.prototype.withArgument = function (_argument) { - return this.withArguments(TypeScript.Syntax.separatedList([_argument])); - }; - - ArgumentListSyntax.prototype.withCloseParenToken = function (closeParenToken) { - return this.update(this.typeArgumentList, this.openParenToken, this.arguments, closeParenToken); - }; - - ArgumentListSyntax.prototype.isTypeScriptSpecific = function () { - if (this.typeArgumentList !== null && this.typeArgumentList.isTypeScriptSpecific()) { - return true; - } - if (this.arguments.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return ArgumentListSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ArgumentListSyntax = ArgumentListSyntax; - - var BinaryExpressionSyntax = (function (_super) { - __extends(BinaryExpressionSyntax, _super); - function BinaryExpressionSyntax(kind, left, operatorToken, right, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.left = left; - this.operatorToken = operatorToken; - this.right = right; - - this._kind = kind; - } - BinaryExpressionSyntax.prototype.accept = function (visitor) { - return visitor.visitBinaryExpression(this); - }; - - BinaryExpressionSyntax.prototype.childCount = function () { - return 3; - }; - - BinaryExpressionSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.left; - case 1: - return this.operatorToken; - case 2: - return this.right; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - BinaryExpressionSyntax.prototype.isExpression = function () { - return true; - }; - - BinaryExpressionSyntax.prototype.kind = function () { - return this._kind; - }; - - BinaryExpressionSyntax.prototype.update = function (kind, left, operatorToken, right) { - if (this._kind === kind && this.left === left && this.operatorToken === operatorToken && this.right === right) { - return this; - } - - return new BinaryExpressionSyntax(kind, left, operatorToken, right, this.parsedInStrictMode()); - }; - - BinaryExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - BinaryExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - BinaryExpressionSyntax.prototype.withKind = function (kind) { - return this.update(kind, this.left, this.operatorToken, this.right); - }; - - BinaryExpressionSyntax.prototype.withLeft = function (left) { - return this.update(this._kind, left, this.operatorToken, this.right); - }; - - BinaryExpressionSyntax.prototype.withOperatorToken = function (operatorToken) { - return this.update(this._kind, this.left, operatorToken, this.right); - }; - - BinaryExpressionSyntax.prototype.withRight = function (right) { - return this.update(this._kind, this.left, this.operatorToken, right); - }; - - BinaryExpressionSyntax.prototype.isTypeScriptSpecific = function () { - if (this.left.isTypeScriptSpecific()) { - return true; - } - if (this.right.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return BinaryExpressionSyntax; - })(TypeScript.SyntaxNode); - TypeScript.BinaryExpressionSyntax = BinaryExpressionSyntax; - - var ConditionalExpressionSyntax = (function (_super) { - __extends(ConditionalExpressionSyntax, _super); - function ConditionalExpressionSyntax(condition, questionToken, whenTrue, colonToken, whenFalse, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.condition = condition; - this.questionToken = questionToken; - this.whenTrue = whenTrue; - this.colonToken = colonToken; - this.whenFalse = whenFalse; - } - ConditionalExpressionSyntax.prototype.accept = function (visitor) { - return visitor.visitConditionalExpression(this); - }; - - ConditionalExpressionSyntax.prototype.kind = function () { - return 185 /* ConditionalExpression */; - }; - - ConditionalExpressionSyntax.prototype.childCount = function () { - return 5; - }; - - ConditionalExpressionSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.condition; - case 1: - return this.questionToken; - case 2: - return this.whenTrue; - case 3: - return this.colonToken; - case 4: - return this.whenFalse; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ConditionalExpressionSyntax.prototype.isExpression = function () { - return true; - }; - - ConditionalExpressionSyntax.prototype.update = function (condition, questionToken, whenTrue, colonToken, whenFalse) { - if (this.condition === condition && this.questionToken === questionToken && this.whenTrue === whenTrue && this.colonToken === colonToken && this.whenFalse === whenFalse) { - return this; - } - - return new ConditionalExpressionSyntax(condition, questionToken, whenTrue, colonToken, whenFalse, this.parsedInStrictMode()); - }; - - ConditionalExpressionSyntax.create1 = function (condition, whenTrue, whenFalse) { - return new ConditionalExpressionSyntax(condition, TypeScript.Syntax.token(106 /* QuestionToken */), whenTrue, TypeScript.Syntax.token(107 /* ColonToken */), whenFalse, false); - }; - - ConditionalExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ConditionalExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ConditionalExpressionSyntax.prototype.withCondition = function (condition) { - return this.update(condition, this.questionToken, this.whenTrue, this.colonToken, this.whenFalse); - }; - - ConditionalExpressionSyntax.prototype.withQuestionToken = function (questionToken) { - return this.update(this.condition, questionToken, this.whenTrue, this.colonToken, this.whenFalse); - }; - - ConditionalExpressionSyntax.prototype.withWhenTrue = function (whenTrue) { - return this.update(this.condition, this.questionToken, whenTrue, this.colonToken, this.whenFalse); - }; - - ConditionalExpressionSyntax.prototype.withColonToken = function (colonToken) { - return this.update(this.condition, this.questionToken, this.whenTrue, colonToken, this.whenFalse); - }; - - ConditionalExpressionSyntax.prototype.withWhenFalse = function (whenFalse) { - return this.update(this.condition, this.questionToken, this.whenTrue, this.colonToken, whenFalse); - }; - - ConditionalExpressionSyntax.prototype.isTypeScriptSpecific = function () { - if (this.condition.isTypeScriptSpecific()) { - return true; - } - if (this.whenTrue.isTypeScriptSpecific()) { - return true; - } - if (this.whenFalse.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return ConditionalExpressionSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ConditionalExpressionSyntax = ConditionalExpressionSyntax; - - var ConstructSignatureSyntax = (function (_super) { - __extends(ConstructSignatureSyntax, _super); - function ConstructSignatureSyntax(newKeyword, callSignature, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.newKeyword = newKeyword; - this.callSignature = callSignature; - } - ConstructSignatureSyntax.prototype.accept = function (visitor) { - return visitor.visitConstructSignature(this); - }; - - ConstructSignatureSyntax.prototype.kind = function () { - return 142 /* ConstructSignature */; - }; - - ConstructSignatureSyntax.prototype.childCount = function () { - return 2; - }; - - ConstructSignatureSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.newKeyword; - case 1: - return this.callSignature; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ConstructSignatureSyntax.prototype.isTypeMember = function () { - return true; - }; - - ConstructSignatureSyntax.prototype.update = function (newKeyword, callSignature) { - if (this.newKeyword === newKeyword && this.callSignature === callSignature) { - return this; - } - - return new ConstructSignatureSyntax(newKeyword, callSignature, this.parsedInStrictMode()); - }; - - ConstructSignatureSyntax.create1 = function () { - return new ConstructSignatureSyntax(TypeScript.Syntax.token(31 /* NewKeyword */), CallSignatureSyntax.create1(), false); - }; - - ConstructSignatureSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ConstructSignatureSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ConstructSignatureSyntax.prototype.withNewKeyword = function (newKeyword) { - return this.update(newKeyword, this.callSignature); - }; - - ConstructSignatureSyntax.prototype.withCallSignature = function (callSignature) { - return this.update(this.newKeyword, callSignature); - }; - - ConstructSignatureSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return ConstructSignatureSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ConstructSignatureSyntax = ConstructSignatureSyntax; - - var MethodSignatureSyntax = (function (_super) { - __extends(MethodSignatureSyntax, _super); - function MethodSignatureSyntax(propertyName, questionToken, callSignature, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.propertyName = propertyName; - this.questionToken = questionToken; - this.callSignature = callSignature; - } - MethodSignatureSyntax.prototype.accept = function (visitor) { - return visitor.visitMethodSignature(this); - }; - - MethodSignatureSyntax.prototype.kind = function () { - return 144 /* MethodSignature */; - }; - - MethodSignatureSyntax.prototype.childCount = function () { - return 3; - }; - - MethodSignatureSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.propertyName; - case 1: - return this.questionToken; - case 2: - return this.callSignature; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - MethodSignatureSyntax.prototype.isTypeMember = function () { - return true; - }; - - MethodSignatureSyntax.prototype.update = function (propertyName, questionToken, callSignature) { - if (this.propertyName === propertyName && this.questionToken === questionToken && this.callSignature === callSignature) { - return this; - } - - return new MethodSignatureSyntax(propertyName, questionToken, callSignature, this.parsedInStrictMode()); - }; - - MethodSignatureSyntax.create = function (propertyName, callSignature) { - return new MethodSignatureSyntax(propertyName, null, callSignature, false); - }; - - MethodSignatureSyntax.create1 = function (propertyName) { - return new MethodSignatureSyntax(propertyName, null, CallSignatureSyntax.create1(), false); - }; - - MethodSignatureSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - MethodSignatureSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - MethodSignatureSyntax.prototype.withPropertyName = function (propertyName) { - return this.update(propertyName, this.questionToken, this.callSignature); - }; - - MethodSignatureSyntax.prototype.withQuestionToken = function (questionToken) { - return this.update(this.propertyName, questionToken, this.callSignature); - }; - - MethodSignatureSyntax.prototype.withCallSignature = function (callSignature) { - return this.update(this.propertyName, this.questionToken, callSignature); - }; - - MethodSignatureSyntax.prototype.isTypeScriptSpecific = function () { - if (this.callSignature.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return MethodSignatureSyntax; - })(TypeScript.SyntaxNode); - TypeScript.MethodSignatureSyntax = MethodSignatureSyntax; - - var IndexSignatureSyntax = (function (_super) { - __extends(IndexSignatureSyntax, _super); - function IndexSignatureSyntax(openBracketToken, parameter, closeBracketToken, typeAnnotation, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.openBracketToken = openBracketToken; - this.parameter = parameter; - this.closeBracketToken = closeBracketToken; - this.typeAnnotation = typeAnnotation; - } - IndexSignatureSyntax.prototype.accept = function (visitor) { - return visitor.visitIndexSignature(this); - }; - - IndexSignatureSyntax.prototype.kind = function () { - return 143 /* IndexSignature */; - }; - - IndexSignatureSyntax.prototype.childCount = function () { - return 4; - }; - - IndexSignatureSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.openBracketToken; - case 1: - return this.parameter; - case 2: - return this.closeBracketToken; - case 3: - return this.typeAnnotation; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - IndexSignatureSyntax.prototype.isTypeMember = function () { - return true; - }; - - IndexSignatureSyntax.prototype.isClassElement = function () { - return true; - }; - - IndexSignatureSyntax.prototype.update = function (openBracketToken, parameter, closeBracketToken, typeAnnotation) { - if (this.openBracketToken === openBracketToken && this.parameter === parameter && this.closeBracketToken === closeBracketToken && this.typeAnnotation === typeAnnotation) { - return this; - } - - return new IndexSignatureSyntax(openBracketToken, parameter, closeBracketToken, typeAnnotation, this.parsedInStrictMode()); - }; - - IndexSignatureSyntax.create = function (openBracketToken, parameter, closeBracketToken) { - return new IndexSignatureSyntax(openBracketToken, parameter, closeBracketToken, null, false); - }; - - IndexSignatureSyntax.create1 = function (parameter) { - return new IndexSignatureSyntax(TypeScript.Syntax.token(75 /* OpenBracketToken */), parameter, TypeScript.Syntax.token(76 /* CloseBracketToken */), null, false); - }; - - IndexSignatureSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - IndexSignatureSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - IndexSignatureSyntax.prototype.withOpenBracketToken = function (openBracketToken) { - return this.update(openBracketToken, this.parameter, this.closeBracketToken, this.typeAnnotation); - }; - - IndexSignatureSyntax.prototype.withParameter = function (parameter) { - return this.update(this.openBracketToken, parameter, this.closeBracketToken, this.typeAnnotation); - }; - - IndexSignatureSyntax.prototype.withCloseBracketToken = function (closeBracketToken) { - return this.update(this.openBracketToken, this.parameter, closeBracketToken, this.typeAnnotation); - }; - - IndexSignatureSyntax.prototype.withTypeAnnotation = function (typeAnnotation) { - return this.update(this.openBracketToken, this.parameter, this.closeBracketToken, typeAnnotation); - }; - - IndexSignatureSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return IndexSignatureSyntax; - })(TypeScript.SyntaxNode); - TypeScript.IndexSignatureSyntax = IndexSignatureSyntax; - - var PropertySignatureSyntax = (function (_super) { - __extends(PropertySignatureSyntax, _super); - function PropertySignatureSyntax(propertyName, questionToken, typeAnnotation, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.propertyName = propertyName; - this.questionToken = questionToken; - this.typeAnnotation = typeAnnotation; - } - PropertySignatureSyntax.prototype.accept = function (visitor) { - return visitor.visitPropertySignature(this); - }; - - PropertySignatureSyntax.prototype.kind = function () { - return 140 /* PropertySignature */; - }; - - PropertySignatureSyntax.prototype.childCount = function () { - return 3; - }; - - PropertySignatureSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.propertyName; - case 1: - return this.questionToken; - case 2: - return this.typeAnnotation; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - PropertySignatureSyntax.prototype.isTypeMember = function () { - return true; - }; - - PropertySignatureSyntax.prototype.update = function (propertyName, questionToken, typeAnnotation) { - if (this.propertyName === propertyName && this.questionToken === questionToken && this.typeAnnotation === typeAnnotation) { - return this; - } - - return new PropertySignatureSyntax(propertyName, questionToken, typeAnnotation, this.parsedInStrictMode()); - }; - - PropertySignatureSyntax.create = function (propertyName) { - return new PropertySignatureSyntax(propertyName, null, null, false); - }; - - PropertySignatureSyntax.create1 = function (propertyName) { - return new PropertySignatureSyntax(propertyName, null, null, false); - }; - - PropertySignatureSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - PropertySignatureSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - PropertySignatureSyntax.prototype.withPropertyName = function (propertyName) { - return this.update(propertyName, this.questionToken, this.typeAnnotation); - }; - - PropertySignatureSyntax.prototype.withQuestionToken = function (questionToken) { - return this.update(this.propertyName, questionToken, this.typeAnnotation); - }; - - PropertySignatureSyntax.prototype.withTypeAnnotation = function (typeAnnotation) { - return this.update(this.propertyName, this.questionToken, typeAnnotation); - }; - - PropertySignatureSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return PropertySignatureSyntax; - })(TypeScript.SyntaxNode); - TypeScript.PropertySignatureSyntax = PropertySignatureSyntax; - - var CallSignatureSyntax = (function (_super) { - __extends(CallSignatureSyntax, _super); - function CallSignatureSyntax(typeParameterList, parameterList, typeAnnotation, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.typeParameterList = typeParameterList; - this.parameterList = parameterList; - this.typeAnnotation = typeAnnotation; - } - CallSignatureSyntax.prototype.accept = function (visitor) { - return visitor.visitCallSignature(this); - }; - - CallSignatureSyntax.prototype.kind = function () { - return 141 /* CallSignature */; - }; - - CallSignatureSyntax.prototype.childCount = function () { - return 3; - }; - - CallSignatureSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.typeParameterList; - case 1: - return this.parameterList; - case 2: - return this.typeAnnotation; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - CallSignatureSyntax.prototype.isTypeMember = function () { - return true; - }; - - CallSignatureSyntax.prototype.update = function (typeParameterList, parameterList, typeAnnotation) { - if (this.typeParameterList === typeParameterList && this.parameterList === parameterList && this.typeAnnotation === typeAnnotation) { - return this; - } - - return new CallSignatureSyntax(typeParameterList, parameterList, typeAnnotation, this.parsedInStrictMode()); - }; - - CallSignatureSyntax.create = function (parameterList) { - return new CallSignatureSyntax(null, parameterList, null, false); - }; - - CallSignatureSyntax.create1 = function () { - return new CallSignatureSyntax(null, ParameterListSyntax.create1(), null, false); - }; - - CallSignatureSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - CallSignatureSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - CallSignatureSyntax.prototype.withTypeParameterList = function (typeParameterList) { - return this.update(typeParameterList, this.parameterList, this.typeAnnotation); - }; - - CallSignatureSyntax.prototype.withParameterList = function (parameterList) { - return this.update(this.typeParameterList, parameterList, this.typeAnnotation); - }; - - CallSignatureSyntax.prototype.withTypeAnnotation = function (typeAnnotation) { - return this.update(this.typeParameterList, this.parameterList, typeAnnotation); - }; - - CallSignatureSyntax.prototype.isTypeScriptSpecific = function () { - if (this.typeParameterList !== null) { - return true; - } - if (this.parameterList.isTypeScriptSpecific()) { - return true; - } - if (this.typeAnnotation !== null) { - return true; - } - return false; - }; - return CallSignatureSyntax; - })(TypeScript.SyntaxNode); - TypeScript.CallSignatureSyntax = CallSignatureSyntax; - - var ParameterListSyntax = (function (_super) { - __extends(ParameterListSyntax, _super); - function ParameterListSyntax(openParenToken, parameters, closeParenToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.openParenToken = openParenToken; - this.parameters = parameters; - this.closeParenToken = closeParenToken; - } - ParameterListSyntax.prototype.accept = function (visitor) { - return visitor.visitParameterList(this); - }; - - ParameterListSyntax.prototype.kind = function () { - return 226 /* ParameterList */; - }; - - ParameterListSyntax.prototype.childCount = function () { - return 3; - }; - - ParameterListSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.openParenToken; - case 1: - return this.parameters; - case 2: - return this.closeParenToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ParameterListSyntax.prototype.update = function (openParenToken, parameters, closeParenToken) { - if (this.openParenToken === openParenToken && this.parameters === parameters && this.closeParenToken === closeParenToken) { - return this; - } - - return new ParameterListSyntax(openParenToken, parameters, closeParenToken, this.parsedInStrictMode()); - }; - - ParameterListSyntax.create = function (openParenToken, closeParenToken) { - return new ParameterListSyntax(openParenToken, TypeScript.Syntax.emptySeparatedList, closeParenToken, false); - }; - - ParameterListSyntax.create1 = function () { - return new ParameterListSyntax(TypeScript.Syntax.token(73 /* OpenParenToken */), TypeScript.Syntax.emptySeparatedList, TypeScript.Syntax.token(74 /* CloseParenToken */), false); - }; - - ParameterListSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ParameterListSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ParameterListSyntax.prototype.withOpenParenToken = function (openParenToken) { - return this.update(openParenToken, this.parameters, this.closeParenToken); - }; - - ParameterListSyntax.prototype.withParameters = function (parameters) { - return this.update(this.openParenToken, parameters, this.closeParenToken); - }; - - ParameterListSyntax.prototype.withParameter = function (parameter) { - return this.withParameters(TypeScript.Syntax.separatedList([parameter])); - }; - - ParameterListSyntax.prototype.withCloseParenToken = function (closeParenToken) { - return this.update(this.openParenToken, this.parameters, closeParenToken); - }; - - ParameterListSyntax.prototype.isTypeScriptSpecific = function () { - if (this.parameters.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return ParameterListSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ParameterListSyntax = ParameterListSyntax; - - var TypeParameterListSyntax = (function (_super) { - __extends(TypeParameterListSyntax, _super); - function TypeParameterListSyntax(lessThanToken, typeParameters, greaterThanToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.lessThanToken = lessThanToken; - this.typeParameters = typeParameters; - this.greaterThanToken = greaterThanToken; - } - TypeParameterListSyntax.prototype.accept = function (visitor) { - return visitor.visitTypeParameterList(this); - }; - - TypeParameterListSyntax.prototype.kind = function () { - return 228 /* TypeParameterList */; - }; - - TypeParameterListSyntax.prototype.childCount = function () { - return 3; - }; - - TypeParameterListSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.lessThanToken; - case 1: - return this.typeParameters; - case 2: - return this.greaterThanToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - TypeParameterListSyntax.prototype.update = function (lessThanToken, typeParameters, greaterThanToken) { - if (this.lessThanToken === lessThanToken && this.typeParameters === typeParameters && this.greaterThanToken === greaterThanToken) { - return this; - } - - return new TypeParameterListSyntax(lessThanToken, typeParameters, greaterThanToken, this.parsedInStrictMode()); - }; - - TypeParameterListSyntax.create = function (lessThanToken, greaterThanToken) { - return new TypeParameterListSyntax(lessThanToken, TypeScript.Syntax.emptySeparatedList, greaterThanToken, false); - }; - - TypeParameterListSyntax.create1 = function () { - return new TypeParameterListSyntax(TypeScript.Syntax.token(81 /* LessThanToken */), TypeScript.Syntax.emptySeparatedList, TypeScript.Syntax.token(82 /* GreaterThanToken */), false); - }; - - TypeParameterListSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - TypeParameterListSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - TypeParameterListSyntax.prototype.withLessThanToken = function (lessThanToken) { - return this.update(lessThanToken, this.typeParameters, this.greaterThanToken); - }; - - TypeParameterListSyntax.prototype.withTypeParameters = function (typeParameters) { - return this.update(this.lessThanToken, typeParameters, this.greaterThanToken); - }; - - TypeParameterListSyntax.prototype.withTypeParameter = function (typeParameter) { - return this.withTypeParameters(TypeScript.Syntax.separatedList([typeParameter])); - }; - - TypeParameterListSyntax.prototype.withGreaterThanToken = function (greaterThanToken) { - return this.update(this.lessThanToken, this.typeParameters, greaterThanToken); - }; - - TypeParameterListSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return TypeParameterListSyntax; - })(TypeScript.SyntaxNode); - TypeScript.TypeParameterListSyntax = TypeParameterListSyntax; - - var TypeParameterSyntax = (function (_super) { - __extends(TypeParameterSyntax, _super); - function TypeParameterSyntax(identifier, constraint, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.identifier = identifier; - this.constraint = constraint; - } - TypeParameterSyntax.prototype.accept = function (visitor) { - return visitor.visitTypeParameter(this); - }; - - TypeParameterSyntax.prototype.kind = function () { - return 236 /* TypeParameter */; - }; - - TypeParameterSyntax.prototype.childCount = function () { - return 2; - }; - - TypeParameterSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.identifier; - case 1: - return this.constraint; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - TypeParameterSyntax.prototype.update = function (identifier, constraint) { - if (this.identifier === identifier && this.constraint === constraint) { - return this; - } - - return new TypeParameterSyntax(identifier, constraint, this.parsedInStrictMode()); - }; - - TypeParameterSyntax.create = function (identifier) { - return new TypeParameterSyntax(identifier, null, false); - }; - - TypeParameterSyntax.create1 = function (identifier) { - return new TypeParameterSyntax(identifier, null, false); - }; - - TypeParameterSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - TypeParameterSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - TypeParameterSyntax.prototype.withIdentifier = function (identifier) { - return this.update(identifier, this.constraint); - }; - - TypeParameterSyntax.prototype.withConstraint = function (constraint) { - return this.update(this.identifier, constraint); - }; - - TypeParameterSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return TypeParameterSyntax; - })(TypeScript.SyntaxNode); - TypeScript.TypeParameterSyntax = TypeParameterSyntax; - - var ConstraintSyntax = (function (_super) { - __extends(ConstraintSyntax, _super); - function ConstraintSyntax(extendsKeyword, type, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.extendsKeyword = extendsKeyword; - this.type = type; - } - ConstraintSyntax.prototype.accept = function (visitor) { - return visitor.visitConstraint(this); - }; - - ConstraintSyntax.prototype.kind = function () { - return 237 /* Constraint */; - }; - - ConstraintSyntax.prototype.childCount = function () { - return 2; - }; - - ConstraintSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.extendsKeyword; - case 1: - return this.type; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ConstraintSyntax.prototype.update = function (extendsKeyword, type) { - if (this.extendsKeyword === extendsKeyword && this.type === type) { - return this; - } - - return new ConstraintSyntax(extendsKeyword, type, this.parsedInStrictMode()); - }; - - ConstraintSyntax.create1 = function (type) { - return new ConstraintSyntax(TypeScript.Syntax.token(48 /* ExtendsKeyword */), type, false); - }; - - ConstraintSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ConstraintSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ConstraintSyntax.prototype.withExtendsKeyword = function (extendsKeyword) { - return this.update(extendsKeyword, this.type); - }; - - ConstraintSyntax.prototype.withType = function (type) { - return this.update(this.extendsKeyword, type); - }; - - ConstraintSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return ConstraintSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ConstraintSyntax = ConstraintSyntax; - - var ElseClauseSyntax = (function (_super) { - __extends(ElseClauseSyntax, _super); - function ElseClauseSyntax(elseKeyword, statement, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.elseKeyword = elseKeyword; - this.statement = statement; - } - ElseClauseSyntax.prototype.accept = function (visitor) { - return visitor.visitElseClause(this); - }; - - ElseClauseSyntax.prototype.kind = function () { - return 233 /* ElseClause */; - }; - - ElseClauseSyntax.prototype.childCount = function () { - return 2; - }; - - ElseClauseSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.elseKeyword; - case 1: - return this.statement; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ElseClauseSyntax.prototype.update = function (elseKeyword, statement) { - if (this.elseKeyword === elseKeyword && this.statement === statement) { - return this; - } - - return new ElseClauseSyntax(elseKeyword, statement, this.parsedInStrictMode()); - }; - - ElseClauseSyntax.create1 = function (statement) { - return new ElseClauseSyntax(TypeScript.Syntax.token(23 /* ElseKeyword */), statement, false); - }; - - ElseClauseSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ElseClauseSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ElseClauseSyntax.prototype.withElseKeyword = function (elseKeyword) { - return this.update(elseKeyword, this.statement); - }; - - ElseClauseSyntax.prototype.withStatement = function (statement) { - return this.update(this.elseKeyword, statement); - }; - - ElseClauseSyntax.prototype.isTypeScriptSpecific = function () { - if (this.statement.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return ElseClauseSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ElseClauseSyntax = ElseClauseSyntax; - - var IfStatementSyntax = (function (_super) { - __extends(IfStatementSyntax, _super); - function IfStatementSyntax(ifKeyword, openParenToken, condition, closeParenToken, statement, elseClause, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.ifKeyword = ifKeyword; - this.openParenToken = openParenToken; - this.condition = condition; - this.closeParenToken = closeParenToken; - this.statement = statement; - this.elseClause = elseClause; - } - IfStatementSyntax.prototype.accept = function (visitor) { - return visitor.visitIfStatement(this); - }; - - IfStatementSyntax.prototype.kind = function () { - return 146 /* IfStatement */; - }; - - IfStatementSyntax.prototype.childCount = function () { - return 6; - }; - - IfStatementSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.ifKeyword; - case 1: - return this.openParenToken; - case 2: - return this.condition; - case 3: - return this.closeParenToken; - case 4: - return this.statement; - case 5: - return this.elseClause; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - IfStatementSyntax.prototype.isStatement = function () { - return true; - }; - - IfStatementSyntax.prototype.isModuleElement = function () { - return true; - }; - - IfStatementSyntax.prototype.update = function (ifKeyword, openParenToken, condition, closeParenToken, statement, elseClause) { - if (this.ifKeyword === ifKeyword && this.openParenToken === openParenToken && this.condition === condition && this.closeParenToken === closeParenToken && this.statement === statement && this.elseClause === elseClause) { - return this; - } - - return new IfStatementSyntax(ifKeyword, openParenToken, condition, closeParenToken, statement, elseClause, this.parsedInStrictMode()); - }; - - IfStatementSyntax.create = function (ifKeyword, openParenToken, condition, closeParenToken, statement) { - return new IfStatementSyntax(ifKeyword, openParenToken, condition, closeParenToken, statement, null, false); - }; - - IfStatementSyntax.create1 = function (condition, statement) { - return new IfStatementSyntax(TypeScript.Syntax.token(28 /* IfKeyword */), TypeScript.Syntax.token(73 /* OpenParenToken */), condition, TypeScript.Syntax.token(74 /* CloseParenToken */), statement, null, false); - }; - - IfStatementSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - IfStatementSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - IfStatementSyntax.prototype.withIfKeyword = function (ifKeyword) { - return this.update(ifKeyword, this.openParenToken, this.condition, this.closeParenToken, this.statement, this.elseClause); - }; - - IfStatementSyntax.prototype.withOpenParenToken = function (openParenToken) { - return this.update(this.ifKeyword, openParenToken, this.condition, this.closeParenToken, this.statement, this.elseClause); - }; - - IfStatementSyntax.prototype.withCondition = function (condition) { - return this.update(this.ifKeyword, this.openParenToken, condition, this.closeParenToken, this.statement, this.elseClause); - }; - - IfStatementSyntax.prototype.withCloseParenToken = function (closeParenToken) { - return this.update(this.ifKeyword, this.openParenToken, this.condition, closeParenToken, this.statement, this.elseClause); - }; - - IfStatementSyntax.prototype.withStatement = function (statement) { - return this.update(this.ifKeyword, this.openParenToken, this.condition, this.closeParenToken, statement, this.elseClause); - }; - - IfStatementSyntax.prototype.withElseClause = function (elseClause) { - return this.update(this.ifKeyword, this.openParenToken, this.condition, this.closeParenToken, this.statement, elseClause); - }; - - IfStatementSyntax.prototype.isTypeScriptSpecific = function () { - if (this.condition.isTypeScriptSpecific()) { - return true; - } - if (this.statement.isTypeScriptSpecific()) { - return true; - } - if (this.elseClause !== null && this.elseClause.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return IfStatementSyntax; - })(TypeScript.SyntaxNode); - TypeScript.IfStatementSyntax = IfStatementSyntax; - - var ExpressionStatementSyntax = (function (_super) { - __extends(ExpressionStatementSyntax, _super); - function ExpressionStatementSyntax(expression, semicolonToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.expression = expression; - this.semicolonToken = semicolonToken; - } - ExpressionStatementSyntax.prototype.accept = function (visitor) { - return visitor.visitExpressionStatement(this); - }; - - ExpressionStatementSyntax.prototype.kind = function () { - return 148 /* ExpressionStatement */; - }; - - ExpressionStatementSyntax.prototype.childCount = function () { - return 2; - }; - - ExpressionStatementSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.expression; - case 1: - return this.semicolonToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ExpressionStatementSyntax.prototype.isStatement = function () { - return true; - }; - - ExpressionStatementSyntax.prototype.isModuleElement = function () { - return true; - }; - - ExpressionStatementSyntax.prototype.update = function (expression, semicolonToken) { - if (this.expression === expression && this.semicolonToken === semicolonToken) { - return this; - } - - return new ExpressionStatementSyntax(expression, semicolonToken, this.parsedInStrictMode()); - }; - - ExpressionStatementSyntax.create1 = function (expression) { - return new ExpressionStatementSyntax(expression, TypeScript.Syntax.token(79 /* SemicolonToken */), false); - }; - - ExpressionStatementSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ExpressionStatementSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ExpressionStatementSyntax.prototype.withExpression = function (expression) { - return this.update(expression, this.semicolonToken); - }; - - ExpressionStatementSyntax.prototype.withSemicolonToken = function (semicolonToken) { - return this.update(this.expression, semicolonToken); - }; - - ExpressionStatementSyntax.prototype.isTypeScriptSpecific = function () { - if (this.expression.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return ExpressionStatementSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ExpressionStatementSyntax = ExpressionStatementSyntax; - - var ConstructorDeclarationSyntax = (function (_super) { - __extends(ConstructorDeclarationSyntax, _super); - function ConstructorDeclarationSyntax(constructorKeyword, parameterList, block, semicolonToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.constructorKeyword = constructorKeyword; - this.parameterList = parameterList; - this.block = block; - this.semicolonToken = semicolonToken; - } - ConstructorDeclarationSyntax.prototype.accept = function (visitor) { - return visitor.visitConstructorDeclaration(this); - }; - - ConstructorDeclarationSyntax.prototype.kind = function () { - return 137 /* ConstructorDeclaration */; - }; - - ConstructorDeclarationSyntax.prototype.childCount = function () { - return 4; - }; - - ConstructorDeclarationSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.constructorKeyword; - case 1: - return this.parameterList; - case 2: - return this.block; - case 3: - return this.semicolonToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ConstructorDeclarationSyntax.prototype.isClassElement = function () { - return true; - }; - - ConstructorDeclarationSyntax.prototype.update = function (constructorKeyword, parameterList, block, semicolonToken) { - if (this.constructorKeyword === constructorKeyword && this.parameterList === parameterList && this.block === block && this.semicolonToken === semicolonToken) { - return this; - } - - return new ConstructorDeclarationSyntax(constructorKeyword, parameterList, block, semicolonToken, this.parsedInStrictMode()); - }; - - ConstructorDeclarationSyntax.create = function (constructorKeyword, parameterList) { - return new ConstructorDeclarationSyntax(constructorKeyword, parameterList, null, null, false); - }; - - ConstructorDeclarationSyntax.create1 = function () { - return new ConstructorDeclarationSyntax(TypeScript.Syntax.token(63 /* ConstructorKeyword */), ParameterListSyntax.create1(), null, null, false); - }; - - ConstructorDeclarationSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ConstructorDeclarationSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ConstructorDeclarationSyntax.prototype.withConstructorKeyword = function (constructorKeyword) { - return this.update(constructorKeyword, this.parameterList, this.block, this.semicolonToken); - }; - - ConstructorDeclarationSyntax.prototype.withParameterList = function (parameterList) { - return this.update(this.constructorKeyword, parameterList, this.block, this.semicolonToken); - }; - - ConstructorDeclarationSyntax.prototype.withBlock = function (block) { - return this.update(this.constructorKeyword, this.parameterList, block, this.semicolonToken); - }; - - ConstructorDeclarationSyntax.prototype.withSemicolonToken = function (semicolonToken) { - return this.update(this.constructorKeyword, this.parameterList, this.block, semicolonToken); - }; - - ConstructorDeclarationSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return ConstructorDeclarationSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ConstructorDeclarationSyntax = ConstructorDeclarationSyntax; - - var MemberFunctionDeclarationSyntax = (function (_super) { - __extends(MemberFunctionDeclarationSyntax, _super); - function MemberFunctionDeclarationSyntax(modifiers, propertyName, callSignature, block, semicolonToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.modifiers = modifiers; - this.propertyName = propertyName; - this.callSignature = callSignature; - this.block = block; - this.semicolonToken = semicolonToken; - } - MemberFunctionDeclarationSyntax.prototype.accept = function (visitor) { - return visitor.visitMemberFunctionDeclaration(this); - }; - - MemberFunctionDeclarationSyntax.prototype.kind = function () { - return 135 /* MemberFunctionDeclaration */; - }; - - MemberFunctionDeclarationSyntax.prototype.childCount = function () { - return 5; - }; - - MemberFunctionDeclarationSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.modifiers; - case 1: - return this.propertyName; - case 2: - return this.callSignature; - case 3: - return this.block; - case 4: - return this.semicolonToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - MemberFunctionDeclarationSyntax.prototype.isMemberDeclaration = function () { - return true; - }; - - MemberFunctionDeclarationSyntax.prototype.isClassElement = function () { - return true; - }; - - MemberFunctionDeclarationSyntax.prototype.update = function (modifiers, propertyName, callSignature, block, semicolonToken) { - if (this.modifiers === modifiers && this.propertyName === propertyName && this.callSignature === callSignature && this.block === block && this.semicolonToken === semicolonToken) { - return this; - } - - return new MemberFunctionDeclarationSyntax(modifiers, propertyName, callSignature, block, semicolonToken, this.parsedInStrictMode()); - }; - - MemberFunctionDeclarationSyntax.create = function (propertyName, callSignature) { - return new MemberFunctionDeclarationSyntax(TypeScript.Syntax.emptyList, propertyName, callSignature, null, null, false); - }; - - MemberFunctionDeclarationSyntax.create1 = function (propertyName) { - return new MemberFunctionDeclarationSyntax(TypeScript.Syntax.emptyList, propertyName, CallSignatureSyntax.create1(), null, null, false); - }; - - MemberFunctionDeclarationSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - MemberFunctionDeclarationSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - MemberFunctionDeclarationSyntax.prototype.withModifiers = function (modifiers) { - return this.update(modifiers, this.propertyName, this.callSignature, this.block, this.semicolonToken); - }; - - MemberFunctionDeclarationSyntax.prototype.withModifier = function (modifier) { - return this.withModifiers(TypeScript.Syntax.list([modifier])); - }; - - MemberFunctionDeclarationSyntax.prototype.withPropertyName = function (propertyName) { - return this.update(this.modifiers, propertyName, this.callSignature, this.block, this.semicolonToken); - }; - - MemberFunctionDeclarationSyntax.prototype.withCallSignature = function (callSignature) { - return this.update(this.modifiers, this.propertyName, callSignature, this.block, this.semicolonToken); - }; - - MemberFunctionDeclarationSyntax.prototype.withBlock = function (block) { - return this.update(this.modifiers, this.propertyName, this.callSignature, block, this.semicolonToken); - }; - - MemberFunctionDeclarationSyntax.prototype.withSemicolonToken = function (semicolonToken) { - return this.update(this.modifiers, this.propertyName, this.callSignature, this.block, semicolonToken); - }; - - MemberFunctionDeclarationSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return MemberFunctionDeclarationSyntax; - })(TypeScript.SyntaxNode); - TypeScript.MemberFunctionDeclarationSyntax = MemberFunctionDeclarationSyntax; - - var MemberAccessorDeclarationSyntax = (function (_super) { - __extends(MemberAccessorDeclarationSyntax, _super); - function MemberAccessorDeclarationSyntax(modifiers, propertyName, parameterList, block, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.modifiers = modifiers; - this.propertyName = propertyName; - this.parameterList = parameterList; - this.block = block; - } - MemberAccessorDeclarationSyntax.prototype.isMemberDeclaration = function () { - return true; - }; - - MemberAccessorDeclarationSyntax.prototype.isClassElement = function () { - return true; - }; - - MemberAccessorDeclarationSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - MemberAccessorDeclarationSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - MemberAccessorDeclarationSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return MemberAccessorDeclarationSyntax; - })(TypeScript.SyntaxNode); - TypeScript.MemberAccessorDeclarationSyntax = MemberAccessorDeclarationSyntax; - - var GetMemberAccessorDeclarationSyntax = (function (_super) { - __extends(GetMemberAccessorDeclarationSyntax, _super); - function GetMemberAccessorDeclarationSyntax(modifiers, getKeyword, propertyName, parameterList, typeAnnotation, block, parsedInStrictMode) { - _super.call(this, modifiers, propertyName, parameterList, block, parsedInStrictMode); - this.getKeyword = getKeyword; - this.typeAnnotation = typeAnnotation; - } - GetMemberAccessorDeclarationSyntax.prototype.accept = function (visitor) { - return visitor.visitGetMemberAccessorDeclaration(this); - }; - - GetMemberAccessorDeclarationSyntax.prototype.kind = function () { - return 138 /* GetMemberAccessorDeclaration */; - }; - - GetMemberAccessorDeclarationSyntax.prototype.childCount = function () { - return 6; - }; - - GetMemberAccessorDeclarationSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.modifiers; - case 1: - return this.getKeyword; - case 2: - return this.propertyName; - case 3: - return this.parameterList; - case 4: - return this.typeAnnotation; - case 5: - return this.block; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - GetMemberAccessorDeclarationSyntax.prototype.update = function (modifiers, getKeyword, propertyName, parameterList, typeAnnotation, block) { - if (this.modifiers === modifiers && this.getKeyword === getKeyword && this.propertyName === propertyName && this.parameterList === parameterList && this.typeAnnotation === typeAnnotation && this.block === block) { - return this; - } - - return new GetMemberAccessorDeclarationSyntax(modifiers, getKeyword, propertyName, parameterList, typeAnnotation, block, this.parsedInStrictMode()); - }; - - GetMemberAccessorDeclarationSyntax.create = function (getKeyword, propertyName, parameterList, block) { - return new GetMemberAccessorDeclarationSyntax(TypeScript.Syntax.emptyList, getKeyword, propertyName, parameterList, null, block, false); - }; - - GetMemberAccessorDeclarationSyntax.create1 = function (propertyName) { - return new GetMemberAccessorDeclarationSyntax(TypeScript.Syntax.emptyList, TypeScript.Syntax.token(65 /* GetKeyword */), propertyName, ParameterListSyntax.create1(), null, BlockSyntax.create1(), false); - }; - - GetMemberAccessorDeclarationSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - GetMemberAccessorDeclarationSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - GetMemberAccessorDeclarationSyntax.prototype.withModifiers = function (modifiers) { - return this.update(modifiers, this.getKeyword, this.propertyName, this.parameterList, this.typeAnnotation, this.block); - }; - - GetMemberAccessorDeclarationSyntax.prototype.withModifier = function (modifier) { - return this.withModifiers(TypeScript.Syntax.list([modifier])); - }; - - GetMemberAccessorDeclarationSyntax.prototype.withGetKeyword = function (getKeyword) { - return this.update(this.modifiers, getKeyword, this.propertyName, this.parameterList, this.typeAnnotation, this.block); - }; - - GetMemberAccessorDeclarationSyntax.prototype.withPropertyName = function (propertyName) { - return this.update(this.modifiers, this.getKeyword, propertyName, this.parameterList, this.typeAnnotation, this.block); - }; - - GetMemberAccessorDeclarationSyntax.prototype.withParameterList = function (parameterList) { - return this.update(this.modifiers, this.getKeyword, this.propertyName, parameterList, this.typeAnnotation, this.block); - }; - - GetMemberAccessorDeclarationSyntax.prototype.withTypeAnnotation = function (typeAnnotation) { - return this.update(this.modifiers, this.getKeyword, this.propertyName, this.parameterList, typeAnnotation, this.block); - }; - - GetMemberAccessorDeclarationSyntax.prototype.withBlock = function (block) { - return this.update(this.modifiers, this.getKeyword, this.propertyName, this.parameterList, this.typeAnnotation, block); - }; - - GetMemberAccessorDeclarationSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return GetMemberAccessorDeclarationSyntax; - })(MemberAccessorDeclarationSyntax); - TypeScript.GetMemberAccessorDeclarationSyntax = GetMemberAccessorDeclarationSyntax; - - var SetMemberAccessorDeclarationSyntax = (function (_super) { - __extends(SetMemberAccessorDeclarationSyntax, _super); - function SetMemberAccessorDeclarationSyntax(modifiers, setKeyword, propertyName, parameterList, block, parsedInStrictMode) { - _super.call(this, modifiers, propertyName, parameterList, block, parsedInStrictMode); - this.setKeyword = setKeyword; - } - SetMemberAccessorDeclarationSyntax.prototype.accept = function (visitor) { - return visitor.visitSetMemberAccessorDeclaration(this); - }; - - SetMemberAccessorDeclarationSyntax.prototype.kind = function () { - return 139 /* SetMemberAccessorDeclaration */; - }; - - SetMemberAccessorDeclarationSyntax.prototype.childCount = function () { - return 5; - }; - - SetMemberAccessorDeclarationSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.modifiers; - case 1: - return this.setKeyword; - case 2: - return this.propertyName; - case 3: - return this.parameterList; - case 4: - return this.block; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - SetMemberAccessorDeclarationSyntax.prototype.update = function (modifiers, setKeyword, propertyName, parameterList, block) { - if (this.modifiers === modifiers && this.setKeyword === setKeyword && this.propertyName === propertyName && this.parameterList === parameterList && this.block === block) { - return this; - } - - return new SetMemberAccessorDeclarationSyntax(modifiers, setKeyword, propertyName, parameterList, block, this.parsedInStrictMode()); - }; - - SetMemberAccessorDeclarationSyntax.create = function (setKeyword, propertyName, parameterList, block) { - return new SetMemberAccessorDeclarationSyntax(TypeScript.Syntax.emptyList, setKeyword, propertyName, parameterList, block, false); - }; - - SetMemberAccessorDeclarationSyntax.create1 = function (propertyName) { - return new SetMemberAccessorDeclarationSyntax(TypeScript.Syntax.emptyList, TypeScript.Syntax.token(69 /* SetKeyword */), propertyName, ParameterListSyntax.create1(), BlockSyntax.create1(), false); - }; - - SetMemberAccessorDeclarationSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - SetMemberAccessorDeclarationSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - SetMemberAccessorDeclarationSyntax.prototype.withModifiers = function (modifiers) { - return this.update(modifiers, this.setKeyword, this.propertyName, this.parameterList, this.block); - }; - - SetMemberAccessorDeclarationSyntax.prototype.withModifier = function (modifier) { - return this.withModifiers(TypeScript.Syntax.list([modifier])); - }; - - SetMemberAccessorDeclarationSyntax.prototype.withSetKeyword = function (setKeyword) { - return this.update(this.modifiers, setKeyword, this.propertyName, this.parameterList, this.block); - }; - - SetMemberAccessorDeclarationSyntax.prototype.withPropertyName = function (propertyName) { - return this.update(this.modifiers, this.setKeyword, propertyName, this.parameterList, this.block); - }; - - SetMemberAccessorDeclarationSyntax.prototype.withParameterList = function (parameterList) { - return this.update(this.modifiers, this.setKeyword, this.propertyName, parameterList, this.block); - }; - - SetMemberAccessorDeclarationSyntax.prototype.withBlock = function (block) { - return this.update(this.modifiers, this.setKeyword, this.propertyName, this.parameterList, block); - }; - - SetMemberAccessorDeclarationSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return SetMemberAccessorDeclarationSyntax; - })(MemberAccessorDeclarationSyntax); - TypeScript.SetMemberAccessorDeclarationSyntax = SetMemberAccessorDeclarationSyntax; - - var MemberVariableDeclarationSyntax = (function (_super) { - __extends(MemberVariableDeclarationSyntax, _super); - function MemberVariableDeclarationSyntax(modifiers, variableDeclarator, semicolonToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.modifiers = modifiers; - this.variableDeclarator = variableDeclarator; - this.semicolonToken = semicolonToken; - } - MemberVariableDeclarationSyntax.prototype.accept = function (visitor) { - return visitor.visitMemberVariableDeclaration(this); - }; - - MemberVariableDeclarationSyntax.prototype.kind = function () { - return 136 /* MemberVariableDeclaration */; - }; - - MemberVariableDeclarationSyntax.prototype.childCount = function () { - return 3; - }; - - MemberVariableDeclarationSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.modifiers; - case 1: - return this.variableDeclarator; - case 2: - return this.semicolonToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - MemberVariableDeclarationSyntax.prototype.isMemberDeclaration = function () { - return true; - }; - - MemberVariableDeclarationSyntax.prototype.isClassElement = function () { - return true; - }; - - MemberVariableDeclarationSyntax.prototype.update = function (modifiers, variableDeclarator, semicolonToken) { - if (this.modifiers === modifiers && this.variableDeclarator === variableDeclarator && this.semicolonToken === semicolonToken) { - return this; - } - - return new MemberVariableDeclarationSyntax(modifiers, variableDeclarator, semicolonToken, this.parsedInStrictMode()); - }; - - MemberVariableDeclarationSyntax.create = function (variableDeclarator, semicolonToken) { - return new MemberVariableDeclarationSyntax(TypeScript.Syntax.emptyList, variableDeclarator, semicolonToken, false); - }; - - MemberVariableDeclarationSyntax.create1 = function (variableDeclarator) { - return new MemberVariableDeclarationSyntax(TypeScript.Syntax.emptyList, variableDeclarator, TypeScript.Syntax.token(79 /* SemicolonToken */), false); - }; - - MemberVariableDeclarationSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - MemberVariableDeclarationSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - MemberVariableDeclarationSyntax.prototype.withModifiers = function (modifiers) { - return this.update(modifiers, this.variableDeclarator, this.semicolonToken); - }; - - MemberVariableDeclarationSyntax.prototype.withModifier = function (modifier) { - return this.withModifiers(TypeScript.Syntax.list([modifier])); - }; - - MemberVariableDeclarationSyntax.prototype.withVariableDeclarator = function (variableDeclarator) { - return this.update(this.modifiers, variableDeclarator, this.semicolonToken); - }; - - MemberVariableDeclarationSyntax.prototype.withSemicolonToken = function (semicolonToken) { - return this.update(this.modifiers, this.variableDeclarator, semicolonToken); - }; - - MemberVariableDeclarationSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return MemberVariableDeclarationSyntax; - })(TypeScript.SyntaxNode); - TypeScript.MemberVariableDeclarationSyntax = MemberVariableDeclarationSyntax; - - var ThrowStatementSyntax = (function (_super) { - __extends(ThrowStatementSyntax, _super); - function ThrowStatementSyntax(throwKeyword, expression, semicolonToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.throwKeyword = throwKeyword; - this.expression = expression; - this.semicolonToken = semicolonToken; - } - ThrowStatementSyntax.prototype.accept = function (visitor) { - return visitor.visitThrowStatement(this); - }; - - ThrowStatementSyntax.prototype.kind = function () { - return 156 /* ThrowStatement */; - }; - - ThrowStatementSyntax.prototype.childCount = function () { - return 3; - }; - - ThrowStatementSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.throwKeyword; - case 1: - return this.expression; - case 2: - return this.semicolonToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ThrowStatementSyntax.prototype.isStatement = function () { - return true; - }; - - ThrowStatementSyntax.prototype.isModuleElement = function () { - return true; - }; - - ThrowStatementSyntax.prototype.update = function (throwKeyword, expression, semicolonToken) { - if (this.throwKeyword === throwKeyword && this.expression === expression && this.semicolonToken === semicolonToken) { - return this; - } - - return new ThrowStatementSyntax(throwKeyword, expression, semicolonToken, this.parsedInStrictMode()); - }; - - ThrowStatementSyntax.create1 = function (expression) { - return new ThrowStatementSyntax(TypeScript.Syntax.token(36 /* ThrowKeyword */), expression, TypeScript.Syntax.token(79 /* SemicolonToken */), false); - }; - - ThrowStatementSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ThrowStatementSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ThrowStatementSyntax.prototype.withThrowKeyword = function (throwKeyword) { - return this.update(throwKeyword, this.expression, this.semicolonToken); - }; - - ThrowStatementSyntax.prototype.withExpression = function (expression) { - return this.update(this.throwKeyword, expression, this.semicolonToken); - }; - - ThrowStatementSyntax.prototype.withSemicolonToken = function (semicolonToken) { - return this.update(this.throwKeyword, this.expression, semicolonToken); - }; - - ThrowStatementSyntax.prototype.isTypeScriptSpecific = function () { - if (this.expression.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return ThrowStatementSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ThrowStatementSyntax = ThrowStatementSyntax; - - var ReturnStatementSyntax = (function (_super) { - __extends(ReturnStatementSyntax, _super); - function ReturnStatementSyntax(returnKeyword, expression, semicolonToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.returnKeyword = returnKeyword; - this.expression = expression; - this.semicolonToken = semicolonToken; - } - ReturnStatementSyntax.prototype.accept = function (visitor) { - return visitor.visitReturnStatement(this); - }; - - ReturnStatementSyntax.prototype.kind = function () { - return 149 /* ReturnStatement */; - }; - - ReturnStatementSyntax.prototype.childCount = function () { - return 3; - }; - - ReturnStatementSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.returnKeyword; - case 1: - return this.expression; - case 2: - return this.semicolonToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ReturnStatementSyntax.prototype.isStatement = function () { - return true; - }; - - ReturnStatementSyntax.prototype.isModuleElement = function () { - return true; - }; - - ReturnStatementSyntax.prototype.update = function (returnKeyword, expression, semicolonToken) { - if (this.returnKeyword === returnKeyword && this.expression === expression && this.semicolonToken === semicolonToken) { - return this; - } - - return new ReturnStatementSyntax(returnKeyword, expression, semicolonToken, this.parsedInStrictMode()); - }; - - ReturnStatementSyntax.create = function (returnKeyword, semicolonToken) { - return new ReturnStatementSyntax(returnKeyword, null, semicolonToken, false); - }; - - ReturnStatementSyntax.create1 = function () { - return new ReturnStatementSyntax(TypeScript.Syntax.token(33 /* ReturnKeyword */), null, TypeScript.Syntax.token(79 /* SemicolonToken */), false); - }; - - ReturnStatementSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ReturnStatementSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ReturnStatementSyntax.prototype.withReturnKeyword = function (returnKeyword) { - return this.update(returnKeyword, this.expression, this.semicolonToken); - }; - - ReturnStatementSyntax.prototype.withExpression = function (expression) { - return this.update(this.returnKeyword, expression, this.semicolonToken); - }; - - ReturnStatementSyntax.prototype.withSemicolonToken = function (semicolonToken) { - return this.update(this.returnKeyword, this.expression, semicolonToken); - }; - - ReturnStatementSyntax.prototype.isTypeScriptSpecific = function () { - if (this.expression !== null && this.expression.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return ReturnStatementSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ReturnStatementSyntax = ReturnStatementSyntax; - - var ObjectCreationExpressionSyntax = (function (_super) { - __extends(ObjectCreationExpressionSyntax, _super); - function ObjectCreationExpressionSyntax(newKeyword, expression, argumentList, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.newKeyword = newKeyword; - this.expression = expression; - this.argumentList = argumentList; - } - ObjectCreationExpressionSyntax.prototype.accept = function (visitor) { - return visitor.visitObjectCreationExpression(this); - }; - - ObjectCreationExpressionSyntax.prototype.kind = function () { - return 215 /* ObjectCreationExpression */; - }; - - ObjectCreationExpressionSyntax.prototype.childCount = function () { - return 3; - }; - - ObjectCreationExpressionSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.newKeyword; - case 1: - return this.expression; - case 2: - return this.argumentList; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ObjectCreationExpressionSyntax.prototype.isUnaryExpression = function () { - return true; - }; - - ObjectCreationExpressionSyntax.prototype.isExpression = function () { - return true; - }; - - ObjectCreationExpressionSyntax.prototype.update = function (newKeyword, expression, argumentList) { - if (this.newKeyword === newKeyword && this.expression === expression && this.argumentList === argumentList) { - return this; - } - - return new ObjectCreationExpressionSyntax(newKeyword, expression, argumentList, this.parsedInStrictMode()); - }; - - ObjectCreationExpressionSyntax.create = function (newKeyword, expression) { - return new ObjectCreationExpressionSyntax(newKeyword, expression, null, false); - }; - - ObjectCreationExpressionSyntax.create1 = function (expression) { - return new ObjectCreationExpressionSyntax(TypeScript.Syntax.token(31 /* NewKeyword */), expression, null, false); - }; - - ObjectCreationExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ObjectCreationExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ObjectCreationExpressionSyntax.prototype.withNewKeyword = function (newKeyword) { - return this.update(newKeyword, this.expression, this.argumentList); - }; - - ObjectCreationExpressionSyntax.prototype.withExpression = function (expression) { - return this.update(this.newKeyword, expression, this.argumentList); - }; - - ObjectCreationExpressionSyntax.prototype.withArgumentList = function (argumentList) { - return this.update(this.newKeyword, this.expression, argumentList); - }; - - ObjectCreationExpressionSyntax.prototype.isTypeScriptSpecific = function () { - if (this.expression.isTypeScriptSpecific()) { - return true; - } - if (this.argumentList !== null && this.argumentList.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return ObjectCreationExpressionSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ObjectCreationExpressionSyntax = ObjectCreationExpressionSyntax; - - var SwitchStatementSyntax = (function (_super) { - __extends(SwitchStatementSyntax, _super); - function SwitchStatementSyntax(switchKeyword, openParenToken, expression, closeParenToken, openBraceToken, switchClauses, closeBraceToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.switchKeyword = switchKeyword; - this.openParenToken = openParenToken; - this.expression = expression; - this.closeParenToken = closeParenToken; - this.openBraceToken = openBraceToken; - this.switchClauses = switchClauses; - this.closeBraceToken = closeBraceToken; - } - SwitchStatementSyntax.prototype.accept = function (visitor) { - return visitor.visitSwitchStatement(this); - }; - - SwitchStatementSyntax.prototype.kind = function () { - return 150 /* SwitchStatement */; - }; - - SwitchStatementSyntax.prototype.childCount = function () { - return 7; - }; - - SwitchStatementSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.switchKeyword; - case 1: - return this.openParenToken; - case 2: - return this.expression; - case 3: - return this.closeParenToken; - case 4: - return this.openBraceToken; - case 5: - return this.switchClauses; - case 6: - return this.closeBraceToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - SwitchStatementSyntax.prototype.isStatement = function () { - return true; - }; - - SwitchStatementSyntax.prototype.isModuleElement = function () { - return true; - }; - - SwitchStatementSyntax.prototype.update = function (switchKeyword, openParenToken, expression, closeParenToken, openBraceToken, switchClauses, closeBraceToken) { - if (this.switchKeyword === switchKeyword && this.openParenToken === openParenToken && this.expression === expression && this.closeParenToken === closeParenToken && this.openBraceToken === openBraceToken && this.switchClauses === switchClauses && this.closeBraceToken === closeBraceToken) { - return this; - } - - return new SwitchStatementSyntax(switchKeyword, openParenToken, expression, closeParenToken, openBraceToken, switchClauses, closeBraceToken, this.parsedInStrictMode()); - }; - - SwitchStatementSyntax.create = function (switchKeyword, openParenToken, expression, closeParenToken, openBraceToken, closeBraceToken) { - return new SwitchStatementSyntax(switchKeyword, openParenToken, expression, closeParenToken, openBraceToken, TypeScript.Syntax.emptyList, closeBraceToken, false); - }; - - SwitchStatementSyntax.create1 = function (expression) { - return new SwitchStatementSyntax(TypeScript.Syntax.token(34 /* SwitchKeyword */), TypeScript.Syntax.token(73 /* OpenParenToken */), expression, TypeScript.Syntax.token(74 /* CloseParenToken */), TypeScript.Syntax.token(71 /* OpenBraceToken */), TypeScript.Syntax.emptyList, TypeScript.Syntax.token(72 /* CloseBraceToken */), false); - }; - - SwitchStatementSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - SwitchStatementSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - SwitchStatementSyntax.prototype.withSwitchKeyword = function (switchKeyword) { - return this.update(switchKeyword, this.openParenToken, this.expression, this.closeParenToken, this.openBraceToken, this.switchClauses, this.closeBraceToken); - }; - - SwitchStatementSyntax.prototype.withOpenParenToken = function (openParenToken) { - return this.update(this.switchKeyword, openParenToken, this.expression, this.closeParenToken, this.openBraceToken, this.switchClauses, this.closeBraceToken); - }; - - SwitchStatementSyntax.prototype.withExpression = function (expression) { - return this.update(this.switchKeyword, this.openParenToken, expression, this.closeParenToken, this.openBraceToken, this.switchClauses, this.closeBraceToken); - }; - - SwitchStatementSyntax.prototype.withCloseParenToken = function (closeParenToken) { - return this.update(this.switchKeyword, this.openParenToken, this.expression, closeParenToken, this.openBraceToken, this.switchClauses, this.closeBraceToken); - }; - - SwitchStatementSyntax.prototype.withOpenBraceToken = function (openBraceToken) { - return this.update(this.switchKeyword, this.openParenToken, this.expression, this.closeParenToken, openBraceToken, this.switchClauses, this.closeBraceToken); - }; - - SwitchStatementSyntax.prototype.withSwitchClauses = function (switchClauses) { - return this.update(this.switchKeyword, this.openParenToken, this.expression, this.closeParenToken, this.openBraceToken, switchClauses, this.closeBraceToken); - }; - - SwitchStatementSyntax.prototype.withSwitchClause = function (switchClause) { - return this.withSwitchClauses(TypeScript.Syntax.list([switchClause])); - }; - - SwitchStatementSyntax.prototype.withCloseBraceToken = function (closeBraceToken) { - return this.update(this.switchKeyword, this.openParenToken, this.expression, this.closeParenToken, this.openBraceToken, this.switchClauses, closeBraceToken); - }; - - SwitchStatementSyntax.prototype.isTypeScriptSpecific = function () { - if (this.expression.isTypeScriptSpecific()) { - return true; - } - if (this.switchClauses.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return SwitchStatementSyntax; - })(TypeScript.SyntaxNode); - TypeScript.SwitchStatementSyntax = SwitchStatementSyntax; - - var SwitchClauseSyntax = (function (_super) { - __extends(SwitchClauseSyntax, _super); - function SwitchClauseSyntax(colonToken, statements, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.colonToken = colonToken; - this.statements = statements; - } - SwitchClauseSyntax.prototype.isSwitchClause = function () { - return true; - }; - - SwitchClauseSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - SwitchClauseSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - SwitchClauseSyntax.prototype.isTypeScriptSpecific = function () { - return false; - }; - return SwitchClauseSyntax; - })(TypeScript.SyntaxNode); - TypeScript.SwitchClauseSyntax = SwitchClauseSyntax; - - var CaseSwitchClauseSyntax = (function (_super) { - __extends(CaseSwitchClauseSyntax, _super); - function CaseSwitchClauseSyntax(caseKeyword, expression, colonToken, statements, parsedInStrictMode) { - _super.call(this, colonToken, statements, parsedInStrictMode); - this.caseKeyword = caseKeyword; - this.expression = expression; - } - CaseSwitchClauseSyntax.prototype.accept = function (visitor) { - return visitor.visitCaseSwitchClause(this); - }; - - CaseSwitchClauseSyntax.prototype.kind = function () { - return 231 /* CaseSwitchClause */; - }; - - CaseSwitchClauseSyntax.prototype.childCount = function () { - return 4; - }; - - CaseSwitchClauseSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.caseKeyword; - case 1: - return this.expression; - case 2: - return this.colonToken; - case 3: - return this.statements; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - CaseSwitchClauseSyntax.prototype.update = function (caseKeyword, expression, colonToken, statements) { - if (this.caseKeyword === caseKeyword && this.expression === expression && this.colonToken === colonToken && this.statements === statements) { - return this; - } - - return new CaseSwitchClauseSyntax(caseKeyword, expression, colonToken, statements, this.parsedInStrictMode()); - }; - - CaseSwitchClauseSyntax.create = function (caseKeyword, expression, colonToken) { - return new CaseSwitchClauseSyntax(caseKeyword, expression, colonToken, TypeScript.Syntax.emptyList, false); - }; - - CaseSwitchClauseSyntax.create1 = function (expression) { - return new CaseSwitchClauseSyntax(TypeScript.Syntax.token(16 /* CaseKeyword */), expression, TypeScript.Syntax.token(107 /* ColonToken */), TypeScript.Syntax.emptyList, false); - }; - - CaseSwitchClauseSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - CaseSwitchClauseSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - CaseSwitchClauseSyntax.prototype.withCaseKeyword = function (caseKeyword) { - return this.update(caseKeyword, this.expression, this.colonToken, this.statements); - }; - - CaseSwitchClauseSyntax.prototype.withExpression = function (expression) { - return this.update(this.caseKeyword, expression, this.colonToken, this.statements); - }; - - CaseSwitchClauseSyntax.prototype.withColonToken = function (colonToken) { - return this.update(this.caseKeyword, this.expression, colonToken, this.statements); - }; - - CaseSwitchClauseSyntax.prototype.withStatements = function (statements) { - return this.update(this.caseKeyword, this.expression, this.colonToken, statements); - }; - - CaseSwitchClauseSyntax.prototype.withStatement = function (statement) { - return this.withStatements(TypeScript.Syntax.list([statement])); - }; - - CaseSwitchClauseSyntax.prototype.isTypeScriptSpecific = function () { - if (this.expression.isTypeScriptSpecific()) { - return true; - } - if (this.statements.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return CaseSwitchClauseSyntax; - })(SwitchClauseSyntax); - TypeScript.CaseSwitchClauseSyntax = CaseSwitchClauseSyntax; - - var DefaultSwitchClauseSyntax = (function (_super) { - __extends(DefaultSwitchClauseSyntax, _super); - function DefaultSwitchClauseSyntax(defaultKeyword, colonToken, statements, parsedInStrictMode) { - _super.call(this, colonToken, statements, parsedInStrictMode); - this.defaultKeyword = defaultKeyword; - } - DefaultSwitchClauseSyntax.prototype.accept = function (visitor) { - return visitor.visitDefaultSwitchClause(this); - }; - - DefaultSwitchClauseSyntax.prototype.kind = function () { - return 232 /* DefaultSwitchClause */; - }; - - DefaultSwitchClauseSyntax.prototype.childCount = function () { - return 3; - }; - - DefaultSwitchClauseSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.defaultKeyword; - case 1: - return this.colonToken; - case 2: - return this.statements; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - DefaultSwitchClauseSyntax.prototype.update = function (defaultKeyword, colonToken, statements) { - if (this.defaultKeyword === defaultKeyword && this.colonToken === colonToken && this.statements === statements) { - return this; - } - - return new DefaultSwitchClauseSyntax(defaultKeyword, colonToken, statements, this.parsedInStrictMode()); - }; - - DefaultSwitchClauseSyntax.create = function (defaultKeyword, colonToken) { - return new DefaultSwitchClauseSyntax(defaultKeyword, colonToken, TypeScript.Syntax.emptyList, false); - }; - - DefaultSwitchClauseSyntax.create1 = function () { - return new DefaultSwitchClauseSyntax(TypeScript.Syntax.token(20 /* DefaultKeyword */), TypeScript.Syntax.token(107 /* ColonToken */), TypeScript.Syntax.emptyList, false); - }; - - DefaultSwitchClauseSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - DefaultSwitchClauseSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - DefaultSwitchClauseSyntax.prototype.withDefaultKeyword = function (defaultKeyword) { - return this.update(defaultKeyword, this.colonToken, this.statements); - }; - - DefaultSwitchClauseSyntax.prototype.withColonToken = function (colonToken) { - return this.update(this.defaultKeyword, colonToken, this.statements); - }; - - DefaultSwitchClauseSyntax.prototype.withStatements = function (statements) { - return this.update(this.defaultKeyword, this.colonToken, statements); - }; - - DefaultSwitchClauseSyntax.prototype.withStatement = function (statement) { - return this.withStatements(TypeScript.Syntax.list([statement])); - }; - - DefaultSwitchClauseSyntax.prototype.isTypeScriptSpecific = function () { - if (this.statements.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return DefaultSwitchClauseSyntax; - })(SwitchClauseSyntax); - TypeScript.DefaultSwitchClauseSyntax = DefaultSwitchClauseSyntax; - - var BreakStatementSyntax = (function (_super) { - __extends(BreakStatementSyntax, _super); - function BreakStatementSyntax(breakKeyword, identifier, semicolonToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.breakKeyword = breakKeyword; - this.identifier = identifier; - this.semicolonToken = semicolonToken; - } - BreakStatementSyntax.prototype.accept = function (visitor) { - return visitor.visitBreakStatement(this); - }; - - BreakStatementSyntax.prototype.kind = function () { - return 151 /* BreakStatement */; - }; - - BreakStatementSyntax.prototype.childCount = function () { - return 3; - }; - - BreakStatementSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.breakKeyword; - case 1: - return this.identifier; - case 2: - return this.semicolonToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - BreakStatementSyntax.prototype.isStatement = function () { - return true; - }; - - BreakStatementSyntax.prototype.isModuleElement = function () { - return true; - }; - - BreakStatementSyntax.prototype.update = function (breakKeyword, identifier, semicolonToken) { - if (this.breakKeyword === breakKeyword && this.identifier === identifier && this.semicolonToken === semicolonToken) { - return this; - } - - return new BreakStatementSyntax(breakKeyword, identifier, semicolonToken, this.parsedInStrictMode()); - }; - - BreakStatementSyntax.create = function (breakKeyword, semicolonToken) { - return new BreakStatementSyntax(breakKeyword, null, semicolonToken, false); - }; - - BreakStatementSyntax.create1 = function () { - return new BreakStatementSyntax(TypeScript.Syntax.token(15 /* BreakKeyword */), null, TypeScript.Syntax.token(79 /* SemicolonToken */), false); - }; - - BreakStatementSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - BreakStatementSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - BreakStatementSyntax.prototype.withBreakKeyword = function (breakKeyword) { - return this.update(breakKeyword, this.identifier, this.semicolonToken); - }; - - BreakStatementSyntax.prototype.withIdentifier = function (identifier) { - return this.update(this.breakKeyword, identifier, this.semicolonToken); - }; - - BreakStatementSyntax.prototype.withSemicolonToken = function (semicolonToken) { - return this.update(this.breakKeyword, this.identifier, semicolonToken); - }; - - BreakStatementSyntax.prototype.isTypeScriptSpecific = function () { - return false; - }; - return BreakStatementSyntax; - })(TypeScript.SyntaxNode); - TypeScript.BreakStatementSyntax = BreakStatementSyntax; - - var ContinueStatementSyntax = (function (_super) { - __extends(ContinueStatementSyntax, _super); - function ContinueStatementSyntax(continueKeyword, identifier, semicolonToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.continueKeyword = continueKeyword; - this.identifier = identifier; - this.semicolonToken = semicolonToken; - } - ContinueStatementSyntax.prototype.accept = function (visitor) { - return visitor.visitContinueStatement(this); - }; - - ContinueStatementSyntax.prototype.kind = function () { - return 152 /* ContinueStatement */; - }; - - ContinueStatementSyntax.prototype.childCount = function () { - return 3; - }; - - ContinueStatementSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.continueKeyword; - case 1: - return this.identifier; - case 2: - return this.semicolonToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ContinueStatementSyntax.prototype.isStatement = function () { - return true; - }; - - ContinueStatementSyntax.prototype.isModuleElement = function () { - return true; - }; - - ContinueStatementSyntax.prototype.update = function (continueKeyword, identifier, semicolonToken) { - if (this.continueKeyword === continueKeyword && this.identifier === identifier && this.semicolonToken === semicolonToken) { - return this; - } - - return new ContinueStatementSyntax(continueKeyword, identifier, semicolonToken, this.parsedInStrictMode()); - }; - - ContinueStatementSyntax.create = function (continueKeyword, semicolonToken) { - return new ContinueStatementSyntax(continueKeyword, null, semicolonToken, false); - }; - - ContinueStatementSyntax.create1 = function () { - return new ContinueStatementSyntax(TypeScript.Syntax.token(18 /* ContinueKeyword */), null, TypeScript.Syntax.token(79 /* SemicolonToken */), false); - }; - - ContinueStatementSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ContinueStatementSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ContinueStatementSyntax.prototype.withContinueKeyword = function (continueKeyword) { - return this.update(continueKeyword, this.identifier, this.semicolonToken); - }; - - ContinueStatementSyntax.prototype.withIdentifier = function (identifier) { - return this.update(this.continueKeyword, identifier, this.semicolonToken); - }; - - ContinueStatementSyntax.prototype.withSemicolonToken = function (semicolonToken) { - return this.update(this.continueKeyword, this.identifier, semicolonToken); - }; - - ContinueStatementSyntax.prototype.isTypeScriptSpecific = function () { - return false; - }; - return ContinueStatementSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ContinueStatementSyntax = ContinueStatementSyntax; - - var IterationStatementSyntax = (function (_super) { - __extends(IterationStatementSyntax, _super); - function IterationStatementSyntax(openParenToken, closeParenToken, statement, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.openParenToken = openParenToken; - this.closeParenToken = closeParenToken; - this.statement = statement; - } - IterationStatementSyntax.prototype.isStatement = function () { - return true; - }; - - IterationStatementSyntax.prototype.isModuleElement = function () { - return true; - }; - - IterationStatementSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - IterationStatementSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - IterationStatementSyntax.prototype.isTypeScriptSpecific = function () { - return false; - }; - return IterationStatementSyntax; - })(TypeScript.SyntaxNode); - TypeScript.IterationStatementSyntax = IterationStatementSyntax; - - var BaseForStatementSyntax = (function (_super) { - __extends(BaseForStatementSyntax, _super); - function BaseForStatementSyntax(forKeyword, openParenToken, variableDeclaration, closeParenToken, statement, parsedInStrictMode) { - _super.call(this, openParenToken, closeParenToken, statement, parsedInStrictMode); - this.forKeyword = forKeyword; - this.variableDeclaration = variableDeclaration; - } - BaseForStatementSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - BaseForStatementSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - BaseForStatementSyntax.prototype.isTypeScriptSpecific = function () { - return false; - }; - return BaseForStatementSyntax; - })(IterationStatementSyntax); - TypeScript.BaseForStatementSyntax = BaseForStatementSyntax; - - var ForStatementSyntax = (function (_super) { - __extends(ForStatementSyntax, _super); - function ForStatementSyntax(forKeyword, openParenToken, variableDeclaration, initializer, firstSemicolonToken, condition, secondSemicolonToken, incrementor, closeParenToken, statement, parsedInStrictMode) { - _super.call(this, forKeyword, openParenToken, variableDeclaration, closeParenToken, statement, parsedInStrictMode); - this.initializer = initializer; - this.firstSemicolonToken = firstSemicolonToken; - this.condition = condition; - this.secondSemicolonToken = secondSemicolonToken; - this.incrementor = incrementor; - } - ForStatementSyntax.prototype.accept = function (visitor) { - return visitor.visitForStatement(this); - }; - - ForStatementSyntax.prototype.kind = function () { - return 153 /* ForStatement */; - }; - - ForStatementSyntax.prototype.childCount = function () { - return 10; - }; - - ForStatementSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.forKeyword; - case 1: - return this.openParenToken; - case 2: - return this.variableDeclaration; - case 3: - return this.initializer; - case 4: - return this.firstSemicolonToken; - case 5: - return this.condition; - case 6: - return this.secondSemicolonToken; - case 7: - return this.incrementor; - case 8: - return this.closeParenToken; - case 9: - return this.statement; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ForStatementSyntax.prototype.update = function (forKeyword, openParenToken, variableDeclaration, initializer, firstSemicolonToken, condition, secondSemicolonToken, incrementor, closeParenToken, statement) { - if (this.forKeyword === forKeyword && this.openParenToken === openParenToken && this.variableDeclaration === variableDeclaration && this.initializer === initializer && this.firstSemicolonToken === firstSemicolonToken && this.condition === condition && this.secondSemicolonToken === secondSemicolonToken && this.incrementor === incrementor && this.closeParenToken === closeParenToken && this.statement === statement) { - return this; - } - - return new ForStatementSyntax(forKeyword, openParenToken, variableDeclaration, initializer, firstSemicolonToken, condition, secondSemicolonToken, incrementor, closeParenToken, statement, this.parsedInStrictMode()); - }; - - ForStatementSyntax.create = function (forKeyword, openParenToken, firstSemicolonToken, secondSemicolonToken, closeParenToken, statement) { - return new ForStatementSyntax(forKeyword, openParenToken, null, null, firstSemicolonToken, null, secondSemicolonToken, null, closeParenToken, statement, false); - }; - - ForStatementSyntax.create1 = function (statement) { - return new ForStatementSyntax(TypeScript.Syntax.token(26 /* ForKeyword */), TypeScript.Syntax.token(73 /* OpenParenToken */), null, null, TypeScript.Syntax.token(79 /* SemicolonToken */), null, TypeScript.Syntax.token(79 /* SemicolonToken */), null, TypeScript.Syntax.token(74 /* CloseParenToken */), statement, false); - }; - - ForStatementSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ForStatementSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ForStatementSyntax.prototype.withForKeyword = function (forKeyword) { - return this.update(forKeyword, this.openParenToken, this.variableDeclaration, this.initializer, this.firstSemicolonToken, this.condition, this.secondSemicolonToken, this.incrementor, this.closeParenToken, this.statement); - }; - - ForStatementSyntax.prototype.withOpenParenToken = function (openParenToken) { - return this.update(this.forKeyword, openParenToken, this.variableDeclaration, this.initializer, this.firstSemicolonToken, this.condition, this.secondSemicolonToken, this.incrementor, this.closeParenToken, this.statement); - }; - - ForStatementSyntax.prototype.withVariableDeclaration = function (variableDeclaration) { - return this.update(this.forKeyword, this.openParenToken, variableDeclaration, this.initializer, this.firstSemicolonToken, this.condition, this.secondSemicolonToken, this.incrementor, this.closeParenToken, this.statement); - }; - - ForStatementSyntax.prototype.withInitializer = function (initializer) { - return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, initializer, this.firstSemicolonToken, this.condition, this.secondSemicolonToken, this.incrementor, this.closeParenToken, this.statement); - }; - - ForStatementSyntax.prototype.withFirstSemicolonToken = function (firstSemicolonToken) { - return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, this.initializer, firstSemicolonToken, this.condition, this.secondSemicolonToken, this.incrementor, this.closeParenToken, this.statement); - }; - - ForStatementSyntax.prototype.withCondition = function (condition) { - return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, this.initializer, this.firstSemicolonToken, condition, this.secondSemicolonToken, this.incrementor, this.closeParenToken, this.statement); - }; - - ForStatementSyntax.prototype.withSecondSemicolonToken = function (secondSemicolonToken) { - return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, this.initializer, this.firstSemicolonToken, this.condition, secondSemicolonToken, this.incrementor, this.closeParenToken, this.statement); - }; - - ForStatementSyntax.prototype.withIncrementor = function (incrementor) { - return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, this.initializer, this.firstSemicolonToken, this.condition, this.secondSemicolonToken, incrementor, this.closeParenToken, this.statement); - }; - - ForStatementSyntax.prototype.withCloseParenToken = function (closeParenToken) { - return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, this.initializer, this.firstSemicolonToken, this.condition, this.secondSemicolonToken, this.incrementor, closeParenToken, this.statement); - }; - - ForStatementSyntax.prototype.withStatement = function (statement) { - return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, this.initializer, this.firstSemicolonToken, this.condition, this.secondSemicolonToken, this.incrementor, this.closeParenToken, statement); - }; - - ForStatementSyntax.prototype.isTypeScriptSpecific = function () { - if (this.variableDeclaration !== null && this.variableDeclaration.isTypeScriptSpecific()) { - return true; - } - if (this.initializer !== null && this.initializer.isTypeScriptSpecific()) { - return true; - } - if (this.condition !== null && this.condition.isTypeScriptSpecific()) { - return true; - } - if (this.incrementor !== null && this.incrementor.isTypeScriptSpecific()) { - return true; - } - if (this.statement.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return ForStatementSyntax; - })(BaseForStatementSyntax); - TypeScript.ForStatementSyntax = ForStatementSyntax; - - var ForInStatementSyntax = (function (_super) { - __extends(ForInStatementSyntax, _super); - function ForInStatementSyntax(forKeyword, openParenToken, variableDeclaration, left, inKeyword, expression, closeParenToken, statement, parsedInStrictMode) { - _super.call(this, forKeyword, openParenToken, variableDeclaration, closeParenToken, statement, parsedInStrictMode); - this.left = left; - this.inKeyword = inKeyword; - this.expression = expression; - } - ForInStatementSyntax.prototype.accept = function (visitor) { - return visitor.visitForInStatement(this); - }; - - ForInStatementSyntax.prototype.kind = function () { - return 154 /* ForInStatement */; - }; - - ForInStatementSyntax.prototype.childCount = function () { - return 8; - }; - - ForInStatementSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.forKeyword; - case 1: - return this.openParenToken; - case 2: - return this.variableDeclaration; - case 3: - return this.left; - case 4: - return this.inKeyword; - case 5: - return this.expression; - case 6: - return this.closeParenToken; - case 7: - return this.statement; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ForInStatementSyntax.prototype.update = function (forKeyword, openParenToken, variableDeclaration, left, inKeyword, expression, closeParenToken, statement) { - if (this.forKeyword === forKeyword && this.openParenToken === openParenToken && this.variableDeclaration === variableDeclaration && this.left === left && this.inKeyword === inKeyword && this.expression === expression && this.closeParenToken === closeParenToken && this.statement === statement) { - return this; - } - - return new ForInStatementSyntax(forKeyword, openParenToken, variableDeclaration, left, inKeyword, expression, closeParenToken, statement, this.parsedInStrictMode()); - }; - - ForInStatementSyntax.create = function (forKeyword, openParenToken, inKeyword, expression, closeParenToken, statement) { - return new ForInStatementSyntax(forKeyword, openParenToken, null, null, inKeyword, expression, closeParenToken, statement, false); - }; - - ForInStatementSyntax.create1 = function (expression, statement) { - return new ForInStatementSyntax(TypeScript.Syntax.token(26 /* ForKeyword */), TypeScript.Syntax.token(73 /* OpenParenToken */), null, null, TypeScript.Syntax.token(29 /* InKeyword */), expression, TypeScript.Syntax.token(74 /* CloseParenToken */), statement, false); - }; - - ForInStatementSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ForInStatementSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ForInStatementSyntax.prototype.withForKeyword = function (forKeyword) { - return this.update(forKeyword, this.openParenToken, this.variableDeclaration, this.left, this.inKeyword, this.expression, this.closeParenToken, this.statement); - }; - - ForInStatementSyntax.prototype.withOpenParenToken = function (openParenToken) { - return this.update(this.forKeyword, openParenToken, this.variableDeclaration, this.left, this.inKeyword, this.expression, this.closeParenToken, this.statement); - }; - - ForInStatementSyntax.prototype.withVariableDeclaration = function (variableDeclaration) { - return this.update(this.forKeyword, this.openParenToken, variableDeclaration, this.left, this.inKeyword, this.expression, this.closeParenToken, this.statement); - }; - - ForInStatementSyntax.prototype.withLeft = function (left) { - return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, left, this.inKeyword, this.expression, this.closeParenToken, this.statement); - }; - - ForInStatementSyntax.prototype.withInKeyword = function (inKeyword) { - return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, this.left, inKeyword, this.expression, this.closeParenToken, this.statement); - }; - - ForInStatementSyntax.prototype.withExpression = function (expression) { - return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, this.left, this.inKeyword, expression, this.closeParenToken, this.statement); - }; - - ForInStatementSyntax.prototype.withCloseParenToken = function (closeParenToken) { - return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, this.left, this.inKeyword, this.expression, closeParenToken, this.statement); - }; - - ForInStatementSyntax.prototype.withStatement = function (statement) { - return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, this.left, this.inKeyword, this.expression, this.closeParenToken, statement); - }; - - ForInStatementSyntax.prototype.isTypeScriptSpecific = function () { - if (this.variableDeclaration !== null && this.variableDeclaration.isTypeScriptSpecific()) { - return true; - } - if (this.left !== null && this.left.isTypeScriptSpecific()) { - return true; - } - if (this.expression.isTypeScriptSpecific()) { - return true; - } - if (this.statement.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return ForInStatementSyntax; - })(BaseForStatementSyntax); - TypeScript.ForInStatementSyntax = ForInStatementSyntax; - - var WhileStatementSyntax = (function (_super) { - __extends(WhileStatementSyntax, _super); - function WhileStatementSyntax(whileKeyword, openParenToken, condition, closeParenToken, statement, parsedInStrictMode) { - _super.call(this, openParenToken, closeParenToken, statement, parsedInStrictMode); - this.whileKeyword = whileKeyword; - this.condition = condition; - } - WhileStatementSyntax.prototype.accept = function (visitor) { - return visitor.visitWhileStatement(this); - }; - - WhileStatementSyntax.prototype.kind = function () { - return 157 /* WhileStatement */; - }; - - WhileStatementSyntax.prototype.childCount = function () { - return 5; - }; - - WhileStatementSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.whileKeyword; - case 1: - return this.openParenToken; - case 2: - return this.condition; - case 3: - return this.closeParenToken; - case 4: - return this.statement; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - WhileStatementSyntax.prototype.update = function (whileKeyword, openParenToken, condition, closeParenToken, statement) { - if (this.whileKeyword === whileKeyword && this.openParenToken === openParenToken && this.condition === condition && this.closeParenToken === closeParenToken && this.statement === statement) { - return this; - } - - return new WhileStatementSyntax(whileKeyword, openParenToken, condition, closeParenToken, statement, this.parsedInStrictMode()); - }; - - WhileStatementSyntax.create1 = function (condition, statement) { - return new WhileStatementSyntax(TypeScript.Syntax.token(42 /* WhileKeyword */), TypeScript.Syntax.token(73 /* OpenParenToken */), condition, TypeScript.Syntax.token(74 /* CloseParenToken */), statement, false); - }; - - WhileStatementSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - WhileStatementSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - WhileStatementSyntax.prototype.withWhileKeyword = function (whileKeyword) { - return this.update(whileKeyword, this.openParenToken, this.condition, this.closeParenToken, this.statement); - }; - - WhileStatementSyntax.prototype.withOpenParenToken = function (openParenToken) { - return this.update(this.whileKeyword, openParenToken, this.condition, this.closeParenToken, this.statement); - }; - - WhileStatementSyntax.prototype.withCondition = function (condition) { - return this.update(this.whileKeyword, this.openParenToken, condition, this.closeParenToken, this.statement); - }; - - WhileStatementSyntax.prototype.withCloseParenToken = function (closeParenToken) { - return this.update(this.whileKeyword, this.openParenToken, this.condition, closeParenToken, this.statement); - }; - - WhileStatementSyntax.prototype.withStatement = function (statement) { - return this.update(this.whileKeyword, this.openParenToken, this.condition, this.closeParenToken, statement); - }; - - WhileStatementSyntax.prototype.isTypeScriptSpecific = function () { - if (this.condition.isTypeScriptSpecific()) { - return true; - } - if (this.statement.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return WhileStatementSyntax; - })(IterationStatementSyntax); - TypeScript.WhileStatementSyntax = WhileStatementSyntax; - - var WithStatementSyntax = (function (_super) { - __extends(WithStatementSyntax, _super); - function WithStatementSyntax(withKeyword, openParenToken, condition, closeParenToken, statement, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.withKeyword = withKeyword; - this.openParenToken = openParenToken; - this.condition = condition; - this.closeParenToken = closeParenToken; - this.statement = statement; - } - WithStatementSyntax.prototype.accept = function (visitor) { - return visitor.visitWithStatement(this); - }; - - WithStatementSyntax.prototype.kind = function () { - return 162 /* WithStatement */; - }; - - WithStatementSyntax.prototype.childCount = function () { - return 5; - }; - - WithStatementSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.withKeyword; - case 1: - return this.openParenToken; - case 2: - return this.condition; - case 3: - return this.closeParenToken; - case 4: - return this.statement; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - WithStatementSyntax.prototype.isStatement = function () { - return true; - }; - - WithStatementSyntax.prototype.isModuleElement = function () { - return true; - }; - - WithStatementSyntax.prototype.update = function (withKeyword, openParenToken, condition, closeParenToken, statement) { - if (this.withKeyword === withKeyword && this.openParenToken === openParenToken && this.condition === condition && this.closeParenToken === closeParenToken && this.statement === statement) { - return this; - } - - return new WithStatementSyntax(withKeyword, openParenToken, condition, closeParenToken, statement, this.parsedInStrictMode()); - }; - - WithStatementSyntax.create1 = function (condition, statement) { - return new WithStatementSyntax(TypeScript.Syntax.token(43 /* WithKeyword */), TypeScript.Syntax.token(73 /* OpenParenToken */), condition, TypeScript.Syntax.token(74 /* CloseParenToken */), statement, false); - }; - - WithStatementSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - WithStatementSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - WithStatementSyntax.prototype.withWithKeyword = function (withKeyword) { - return this.update(withKeyword, this.openParenToken, this.condition, this.closeParenToken, this.statement); - }; - - WithStatementSyntax.prototype.withOpenParenToken = function (openParenToken) { - return this.update(this.withKeyword, openParenToken, this.condition, this.closeParenToken, this.statement); - }; - - WithStatementSyntax.prototype.withCondition = function (condition) { - return this.update(this.withKeyword, this.openParenToken, condition, this.closeParenToken, this.statement); - }; - - WithStatementSyntax.prototype.withCloseParenToken = function (closeParenToken) { - return this.update(this.withKeyword, this.openParenToken, this.condition, closeParenToken, this.statement); - }; - - WithStatementSyntax.prototype.withStatement = function (statement) { - return this.update(this.withKeyword, this.openParenToken, this.condition, this.closeParenToken, statement); - }; - - WithStatementSyntax.prototype.isTypeScriptSpecific = function () { - if (this.condition.isTypeScriptSpecific()) { - return true; - } - if (this.statement.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return WithStatementSyntax; - })(TypeScript.SyntaxNode); - TypeScript.WithStatementSyntax = WithStatementSyntax; - - var EnumDeclarationSyntax = (function (_super) { - __extends(EnumDeclarationSyntax, _super); - function EnumDeclarationSyntax(modifiers, enumKeyword, identifier, openBraceToken, enumElements, closeBraceToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.modifiers = modifiers; - this.enumKeyword = enumKeyword; - this.identifier = identifier; - this.openBraceToken = openBraceToken; - this.enumElements = enumElements; - this.closeBraceToken = closeBraceToken; - } - EnumDeclarationSyntax.prototype.accept = function (visitor) { - return visitor.visitEnumDeclaration(this); - }; - - EnumDeclarationSyntax.prototype.kind = function () { - return 132 /* EnumDeclaration */; - }; - - EnumDeclarationSyntax.prototype.childCount = function () { - return 6; - }; - - EnumDeclarationSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.modifiers; - case 1: - return this.enumKeyword; - case 2: - return this.identifier; - case 3: - return this.openBraceToken; - case 4: - return this.enumElements; - case 5: - return this.closeBraceToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - EnumDeclarationSyntax.prototype.isModuleElement = function () { - return true; - }; - - EnumDeclarationSyntax.prototype.update = function (modifiers, enumKeyword, identifier, openBraceToken, enumElements, closeBraceToken) { - if (this.modifiers === modifiers && this.enumKeyword === enumKeyword && this.identifier === identifier && this.openBraceToken === openBraceToken && this.enumElements === enumElements && this.closeBraceToken === closeBraceToken) { - return this; - } - - return new EnumDeclarationSyntax(modifiers, enumKeyword, identifier, openBraceToken, enumElements, closeBraceToken, this.parsedInStrictMode()); - }; - - EnumDeclarationSyntax.create = function (enumKeyword, identifier, openBraceToken, closeBraceToken) { - return new EnumDeclarationSyntax(TypeScript.Syntax.emptyList, enumKeyword, identifier, openBraceToken, TypeScript.Syntax.emptySeparatedList, closeBraceToken, false); - }; - - EnumDeclarationSyntax.create1 = function (identifier) { - return new EnumDeclarationSyntax(TypeScript.Syntax.emptyList, TypeScript.Syntax.token(46 /* EnumKeyword */), identifier, TypeScript.Syntax.token(71 /* OpenBraceToken */), TypeScript.Syntax.emptySeparatedList, TypeScript.Syntax.token(72 /* CloseBraceToken */), false); - }; - - EnumDeclarationSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - EnumDeclarationSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - EnumDeclarationSyntax.prototype.withModifiers = function (modifiers) { - return this.update(modifiers, this.enumKeyword, this.identifier, this.openBraceToken, this.enumElements, this.closeBraceToken); - }; - - EnumDeclarationSyntax.prototype.withModifier = function (modifier) { - return this.withModifiers(TypeScript.Syntax.list([modifier])); - }; - - EnumDeclarationSyntax.prototype.withEnumKeyword = function (enumKeyword) { - return this.update(this.modifiers, enumKeyword, this.identifier, this.openBraceToken, this.enumElements, this.closeBraceToken); - }; - - EnumDeclarationSyntax.prototype.withIdentifier = function (identifier) { - return this.update(this.modifiers, this.enumKeyword, identifier, this.openBraceToken, this.enumElements, this.closeBraceToken); - }; - - EnumDeclarationSyntax.prototype.withOpenBraceToken = function (openBraceToken) { - return this.update(this.modifiers, this.enumKeyword, this.identifier, openBraceToken, this.enumElements, this.closeBraceToken); - }; - - EnumDeclarationSyntax.prototype.withEnumElements = function (enumElements) { - return this.update(this.modifiers, this.enumKeyword, this.identifier, this.openBraceToken, enumElements, this.closeBraceToken); - }; - - EnumDeclarationSyntax.prototype.withEnumElement = function (enumElement) { - return this.withEnumElements(TypeScript.Syntax.separatedList([enumElement])); - }; - - EnumDeclarationSyntax.prototype.withCloseBraceToken = function (closeBraceToken) { - return this.update(this.modifiers, this.enumKeyword, this.identifier, this.openBraceToken, this.enumElements, closeBraceToken); - }; - - EnumDeclarationSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return EnumDeclarationSyntax; - })(TypeScript.SyntaxNode); - TypeScript.EnumDeclarationSyntax = EnumDeclarationSyntax; - - var EnumElementSyntax = (function (_super) { - __extends(EnumElementSyntax, _super); - function EnumElementSyntax(propertyName, equalsValueClause, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.propertyName = propertyName; - this.equalsValueClause = equalsValueClause; - } - EnumElementSyntax.prototype.accept = function (visitor) { - return visitor.visitEnumElement(this); - }; - - EnumElementSyntax.prototype.kind = function () { - return 243 /* EnumElement */; - }; - - EnumElementSyntax.prototype.childCount = function () { - return 2; - }; - - EnumElementSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.propertyName; - case 1: - return this.equalsValueClause; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - EnumElementSyntax.prototype.update = function (propertyName, equalsValueClause) { - if (this.propertyName === propertyName && this.equalsValueClause === equalsValueClause) { - return this; - } - - return new EnumElementSyntax(propertyName, equalsValueClause, this.parsedInStrictMode()); - }; - - EnumElementSyntax.create = function (propertyName) { - return new EnumElementSyntax(propertyName, null, false); - }; - - EnumElementSyntax.create1 = function (propertyName) { - return new EnumElementSyntax(propertyName, null, false); - }; - - EnumElementSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - EnumElementSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - EnumElementSyntax.prototype.withPropertyName = function (propertyName) { - return this.update(propertyName, this.equalsValueClause); - }; - - EnumElementSyntax.prototype.withEqualsValueClause = function (equalsValueClause) { - return this.update(this.propertyName, equalsValueClause); - }; - - EnumElementSyntax.prototype.isTypeScriptSpecific = function () { - if (this.equalsValueClause !== null && this.equalsValueClause.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return EnumElementSyntax; - })(TypeScript.SyntaxNode); - TypeScript.EnumElementSyntax = EnumElementSyntax; - - var CastExpressionSyntax = (function (_super) { - __extends(CastExpressionSyntax, _super); - function CastExpressionSyntax(lessThanToken, type, greaterThanToken, expression, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.lessThanToken = lessThanToken; - this.type = type; - this.greaterThanToken = greaterThanToken; - this.expression = expression; - } - CastExpressionSyntax.prototype.accept = function (visitor) { - return visitor.visitCastExpression(this); - }; - - CastExpressionSyntax.prototype.kind = function () { - return 219 /* CastExpression */; - }; - - CastExpressionSyntax.prototype.childCount = function () { - return 4; - }; - - CastExpressionSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.lessThanToken; - case 1: - return this.type; - case 2: - return this.greaterThanToken; - case 3: - return this.expression; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - CastExpressionSyntax.prototype.isUnaryExpression = function () { - return true; - }; - - CastExpressionSyntax.prototype.isExpression = function () { - return true; - }; - - CastExpressionSyntax.prototype.update = function (lessThanToken, type, greaterThanToken, expression) { - if (this.lessThanToken === lessThanToken && this.type === type && this.greaterThanToken === greaterThanToken && this.expression === expression) { - return this; - } - - return new CastExpressionSyntax(lessThanToken, type, greaterThanToken, expression, this.parsedInStrictMode()); - }; - - CastExpressionSyntax.create1 = function (type, expression) { - return new CastExpressionSyntax(TypeScript.Syntax.token(81 /* LessThanToken */), type, TypeScript.Syntax.token(82 /* GreaterThanToken */), expression, false); - }; - - CastExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - CastExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - CastExpressionSyntax.prototype.withLessThanToken = function (lessThanToken) { - return this.update(lessThanToken, this.type, this.greaterThanToken, this.expression); - }; - - CastExpressionSyntax.prototype.withType = function (type) { - return this.update(this.lessThanToken, type, this.greaterThanToken, this.expression); - }; - - CastExpressionSyntax.prototype.withGreaterThanToken = function (greaterThanToken) { - return this.update(this.lessThanToken, this.type, greaterThanToken, this.expression); - }; - - CastExpressionSyntax.prototype.withExpression = function (expression) { - return this.update(this.lessThanToken, this.type, this.greaterThanToken, expression); - }; - - CastExpressionSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return CastExpressionSyntax; - })(TypeScript.SyntaxNode); - TypeScript.CastExpressionSyntax = CastExpressionSyntax; - - var ObjectLiteralExpressionSyntax = (function (_super) { - __extends(ObjectLiteralExpressionSyntax, _super); - function ObjectLiteralExpressionSyntax(openBraceToken, propertyAssignments, closeBraceToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.openBraceToken = openBraceToken; - this.propertyAssignments = propertyAssignments; - this.closeBraceToken = closeBraceToken; - } - ObjectLiteralExpressionSyntax.prototype.accept = function (visitor) { - return visitor.visitObjectLiteralExpression(this); - }; - - ObjectLiteralExpressionSyntax.prototype.kind = function () { - return 214 /* ObjectLiteralExpression */; - }; - - ObjectLiteralExpressionSyntax.prototype.childCount = function () { - return 3; - }; - - ObjectLiteralExpressionSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.openBraceToken; - case 1: - return this.propertyAssignments; - case 2: - return this.closeBraceToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ObjectLiteralExpressionSyntax.prototype.isUnaryExpression = function () { - return true; - }; - - ObjectLiteralExpressionSyntax.prototype.isExpression = function () { - return true; - }; - - ObjectLiteralExpressionSyntax.prototype.update = function (openBraceToken, propertyAssignments, closeBraceToken) { - if (this.openBraceToken === openBraceToken && this.propertyAssignments === propertyAssignments && this.closeBraceToken === closeBraceToken) { - return this; - } - - return new ObjectLiteralExpressionSyntax(openBraceToken, propertyAssignments, closeBraceToken, this.parsedInStrictMode()); - }; - - ObjectLiteralExpressionSyntax.create = function (openBraceToken, closeBraceToken) { - return new ObjectLiteralExpressionSyntax(openBraceToken, TypeScript.Syntax.emptySeparatedList, closeBraceToken, false); - }; - - ObjectLiteralExpressionSyntax.create1 = function () { - return new ObjectLiteralExpressionSyntax(TypeScript.Syntax.token(71 /* OpenBraceToken */), TypeScript.Syntax.emptySeparatedList, TypeScript.Syntax.token(72 /* CloseBraceToken */), false); - }; - - ObjectLiteralExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ObjectLiteralExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ObjectLiteralExpressionSyntax.prototype.withOpenBraceToken = function (openBraceToken) { - return this.update(openBraceToken, this.propertyAssignments, this.closeBraceToken); - }; - - ObjectLiteralExpressionSyntax.prototype.withPropertyAssignments = function (propertyAssignments) { - return this.update(this.openBraceToken, propertyAssignments, this.closeBraceToken); - }; - - ObjectLiteralExpressionSyntax.prototype.withPropertyAssignment = function (propertyAssignment) { - return this.withPropertyAssignments(TypeScript.Syntax.separatedList([propertyAssignment])); - }; - - ObjectLiteralExpressionSyntax.prototype.withCloseBraceToken = function (closeBraceToken) { - return this.update(this.openBraceToken, this.propertyAssignments, closeBraceToken); - }; - - ObjectLiteralExpressionSyntax.prototype.isTypeScriptSpecific = function () { - if (this.propertyAssignments.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return ObjectLiteralExpressionSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ObjectLiteralExpressionSyntax = ObjectLiteralExpressionSyntax; - - var PropertyAssignmentSyntax = (function (_super) { - __extends(PropertyAssignmentSyntax, _super); - function PropertyAssignmentSyntax(propertyName, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.propertyName = propertyName; - } - PropertyAssignmentSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - PropertyAssignmentSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - PropertyAssignmentSyntax.prototype.isTypeScriptSpecific = function () { - return false; - }; - return PropertyAssignmentSyntax; - })(TypeScript.SyntaxNode); - TypeScript.PropertyAssignmentSyntax = PropertyAssignmentSyntax; - - var SimplePropertyAssignmentSyntax = (function (_super) { - __extends(SimplePropertyAssignmentSyntax, _super); - function SimplePropertyAssignmentSyntax(propertyName, colonToken, expression, parsedInStrictMode) { - _super.call(this, propertyName, parsedInStrictMode); - this.colonToken = colonToken; - this.expression = expression; - } - SimplePropertyAssignmentSyntax.prototype.accept = function (visitor) { - return visitor.visitSimplePropertyAssignment(this); - }; - - SimplePropertyAssignmentSyntax.prototype.kind = function () { - return 238 /* SimplePropertyAssignment */; - }; - - SimplePropertyAssignmentSyntax.prototype.childCount = function () { - return 3; - }; - - SimplePropertyAssignmentSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.propertyName; - case 1: - return this.colonToken; - case 2: - return this.expression; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - SimplePropertyAssignmentSyntax.prototype.update = function (propertyName, colonToken, expression) { - if (this.propertyName === propertyName && this.colonToken === colonToken && this.expression === expression) { - return this; - } - - return new SimplePropertyAssignmentSyntax(propertyName, colonToken, expression, this.parsedInStrictMode()); - }; - - SimplePropertyAssignmentSyntax.create1 = function (propertyName, expression) { - return new SimplePropertyAssignmentSyntax(propertyName, TypeScript.Syntax.token(107 /* ColonToken */), expression, false); - }; - - SimplePropertyAssignmentSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - SimplePropertyAssignmentSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - SimplePropertyAssignmentSyntax.prototype.withPropertyName = function (propertyName) { - return this.update(propertyName, this.colonToken, this.expression); - }; - - SimplePropertyAssignmentSyntax.prototype.withColonToken = function (colonToken) { - return this.update(this.propertyName, colonToken, this.expression); - }; - - SimplePropertyAssignmentSyntax.prototype.withExpression = function (expression) { - return this.update(this.propertyName, this.colonToken, expression); - }; - - SimplePropertyAssignmentSyntax.prototype.isTypeScriptSpecific = function () { - if (this.expression.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return SimplePropertyAssignmentSyntax; - })(PropertyAssignmentSyntax); - TypeScript.SimplePropertyAssignmentSyntax = SimplePropertyAssignmentSyntax; - - var FunctionPropertyAssignmentSyntax = (function (_super) { - __extends(FunctionPropertyAssignmentSyntax, _super); - function FunctionPropertyAssignmentSyntax(propertyName, callSignature, block, parsedInStrictMode) { - _super.call(this, propertyName, parsedInStrictMode); - this.callSignature = callSignature; - this.block = block; - } - FunctionPropertyAssignmentSyntax.prototype.accept = function (visitor) { - return visitor.visitFunctionPropertyAssignment(this); - }; - - FunctionPropertyAssignmentSyntax.prototype.kind = function () { - return 241 /* FunctionPropertyAssignment */; - }; - - FunctionPropertyAssignmentSyntax.prototype.childCount = function () { - return 3; - }; - - FunctionPropertyAssignmentSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.propertyName; - case 1: - return this.callSignature; - case 2: - return this.block; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - FunctionPropertyAssignmentSyntax.prototype.update = function (propertyName, callSignature, block) { - if (this.propertyName === propertyName && this.callSignature === callSignature && this.block === block) { - return this; - } - - return new FunctionPropertyAssignmentSyntax(propertyName, callSignature, block, this.parsedInStrictMode()); - }; - - FunctionPropertyAssignmentSyntax.create1 = function (propertyName) { - return new FunctionPropertyAssignmentSyntax(propertyName, CallSignatureSyntax.create1(), BlockSyntax.create1(), false); - }; - - FunctionPropertyAssignmentSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - FunctionPropertyAssignmentSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - FunctionPropertyAssignmentSyntax.prototype.withPropertyName = function (propertyName) { - return this.update(propertyName, this.callSignature, this.block); - }; - - FunctionPropertyAssignmentSyntax.prototype.withCallSignature = function (callSignature) { - return this.update(this.propertyName, callSignature, this.block); - }; - - FunctionPropertyAssignmentSyntax.prototype.withBlock = function (block) { - return this.update(this.propertyName, this.callSignature, block); - }; - - FunctionPropertyAssignmentSyntax.prototype.isTypeScriptSpecific = function () { - if (this.callSignature.isTypeScriptSpecific()) { - return true; - } - if (this.block.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return FunctionPropertyAssignmentSyntax; - })(PropertyAssignmentSyntax); - TypeScript.FunctionPropertyAssignmentSyntax = FunctionPropertyAssignmentSyntax; - - var AccessorPropertyAssignmentSyntax = (function (_super) { - __extends(AccessorPropertyAssignmentSyntax, _super); - function AccessorPropertyAssignmentSyntax(propertyName, openParenToken, closeParenToken, block, parsedInStrictMode) { - _super.call(this, propertyName, parsedInStrictMode); - this.openParenToken = openParenToken; - this.closeParenToken = closeParenToken; - this.block = block; - } - AccessorPropertyAssignmentSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - AccessorPropertyAssignmentSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - AccessorPropertyAssignmentSyntax.prototype.isTypeScriptSpecific = function () { - return false; - }; - return AccessorPropertyAssignmentSyntax; - })(PropertyAssignmentSyntax); - TypeScript.AccessorPropertyAssignmentSyntax = AccessorPropertyAssignmentSyntax; - - var GetAccessorPropertyAssignmentSyntax = (function (_super) { - __extends(GetAccessorPropertyAssignmentSyntax, _super); - function GetAccessorPropertyAssignmentSyntax(getKeyword, propertyName, openParenToken, closeParenToken, typeAnnotation, block, parsedInStrictMode) { - _super.call(this, propertyName, openParenToken, closeParenToken, block, parsedInStrictMode); - this.getKeyword = getKeyword; - this.typeAnnotation = typeAnnotation; - } - GetAccessorPropertyAssignmentSyntax.prototype.accept = function (visitor) { - return visitor.visitGetAccessorPropertyAssignment(this); - }; - - GetAccessorPropertyAssignmentSyntax.prototype.kind = function () { - return 239 /* GetAccessorPropertyAssignment */; - }; - - GetAccessorPropertyAssignmentSyntax.prototype.childCount = function () { - return 6; - }; - - GetAccessorPropertyAssignmentSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.getKeyword; - case 1: - return this.propertyName; - case 2: - return this.openParenToken; - case 3: - return this.closeParenToken; - case 4: - return this.typeAnnotation; - case 5: - return this.block; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - GetAccessorPropertyAssignmentSyntax.prototype.update = function (getKeyword, propertyName, openParenToken, closeParenToken, typeAnnotation, block) { - if (this.getKeyword === getKeyword && this.propertyName === propertyName && this.openParenToken === openParenToken && this.closeParenToken === closeParenToken && this.typeAnnotation === typeAnnotation && this.block === block) { - return this; - } - - return new GetAccessorPropertyAssignmentSyntax(getKeyword, propertyName, openParenToken, closeParenToken, typeAnnotation, block, this.parsedInStrictMode()); - }; - - GetAccessorPropertyAssignmentSyntax.create = function (getKeyword, propertyName, openParenToken, closeParenToken, block) { - return new GetAccessorPropertyAssignmentSyntax(getKeyword, propertyName, openParenToken, closeParenToken, null, block, false); - }; - - GetAccessorPropertyAssignmentSyntax.create1 = function (propertyName) { - return new GetAccessorPropertyAssignmentSyntax(TypeScript.Syntax.token(65 /* GetKeyword */), propertyName, TypeScript.Syntax.token(73 /* OpenParenToken */), TypeScript.Syntax.token(74 /* CloseParenToken */), null, BlockSyntax.create1(), false); - }; - - GetAccessorPropertyAssignmentSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - GetAccessorPropertyAssignmentSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - GetAccessorPropertyAssignmentSyntax.prototype.withGetKeyword = function (getKeyword) { - return this.update(getKeyword, this.propertyName, this.openParenToken, this.closeParenToken, this.typeAnnotation, this.block); - }; - - GetAccessorPropertyAssignmentSyntax.prototype.withPropertyName = function (propertyName) { - return this.update(this.getKeyword, propertyName, this.openParenToken, this.closeParenToken, this.typeAnnotation, this.block); - }; - - GetAccessorPropertyAssignmentSyntax.prototype.withOpenParenToken = function (openParenToken) { - return this.update(this.getKeyword, this.propertyName, openParenToken, this.closeParenToken, this.typeAnnotation, this.block); - }; - - GetAccessorPropertyAssignmentSyntax.prototype.withCloseParenToken = function (closeParenToken) { - return this.update(this.getKeyword, this.propertyName, this.openParenToken, closeParenToken, this.typeAnnotation, this.block); - }; - - GetAccessorPropertyAssignmentSyntax.prototype.withTypeAnnotation = function (typeAnnotation) { - return this.update(this.getKeyword, this.propertyName, this.openParenToken, this.closeParenToken, typeAnnotation, this.block); - }; - - GetAccessorPropertyAssignmentSyntax.prototype.withBlock = function (block) { - return this.update(this.getKeyword, this.propertyName, this.openParenToken, this.closeParenToken, this.typeAnnotation, block); - }; - - GetAccessorPropertyAssignmentSyntax.prototype.isTypeScriptSpecific = function () { - if (this.typeAnnotation !== null && this.typeAnnotation.isTypeScriptSpecific()) { - return true; - } - if (this.block.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return GetAccessorPropertyAssignmentSyntax; - })(AccessorPropertyAssignmentSyntax); - TypeScript.GetAccessorPropertyAssignmentSyntax = GetAccessorPropertyAssignmentSyntax; - - var SetAccessorPropertyAssignmentSyntax = (function (_super) { - __extends(SetAccessorPropertyAssignmentSyntax, _super); - function SetAccessorPropertyAssignmentSyntax(setKeyword, propertyName, openParenToken, parameter, closeParenToken, block, parsedInStrictMode) { - _super.call(this, propertyName, openParenToken, closeParenToken, block, parsedInStrictMode); - this.setKeyword = setKeyword; - this.parameter = parameter; - } - SetAccessorPropertyAssignmentSyntax.prototype.accept = function (visitor) { - return visitor.visitSetAccessorPropertyAssignment(this); - }; - - SetAccessorPropertyAssignmentSyntax.prototype.kind = function () { - return 240 /* SetAccessorPropertyAssignment */; - }; - - SetAccessorPropertyAssignmentSyntax.prototype.childCount = function () { - return 6; - }; - - SetAccessorPropertyAssignmentSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.setKeyword; - case 1: - return this.propertyName; - case 2: - return this.openParenToken; - case 3: - return this.parameter; - case 4: - return this.closeParenToken; - case 5: - return this.block; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - SetAccessorPropertyAssignmentSyntax.prototype.update = function (setKeyword, propertyName, openParenToken, parameter, closeParenToken, block) { - if (this.setKeyword === setKeyword && this.propertyName === propertyName && this.openParenToken === openParenToken && this.parameter === parameter && this.closeParenToken === closeParenToken && this.block === block) { - return this; - } - - return new SetAccessorPropertyAssignmentSyntax(setKeyword, propertyName, openParenToken, parameter, closeParenToken, block, this.parsedInStrictMode()); - }; - - SetAccessorPropertyAssignmentSyntax.create1 = function (propertyName, parameter) { - return new SetAccessorPropertyAssignmentSyntax(TypeScript.Syntax.token(69 /* SetKeyword */), propertyName, TypeScript.Syntax.token(73 /* OpenParenToken */), parameter, TypeScript.Syntax.token(74 /* CloseParenToken */), BlockSyntax.create1(), false); - }; - - SetAccessorPropertyAssignmentSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - SetAccessorPropertyAssignmentSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - SetAccessorPropertyAssignmentSyntax.prototype.withSetKeyword = function (setKeyword) { - return this.update(setKeyword, this.propertyName, this.openParenToken, this.parameter, this.closeParenToken, this.block); - }; - - SetAccessorPropertyAssignmentSyntax.prototype.withPropertyName = function (propertyName) { - return this.update(this.setKeyword, propertyName, this.openParenToken, this.parameter, this.closeParenToken, this.block); - }; - - SetAccessorPropertyAssignmentSyntax.prototype.withOpenParenToken = function (openParenToken) { - return this.update(this.setKeyword, this.propertyName, openParenToken, this.parameter, this.closeParenToken, this.block); - }; - - SetAccessorPropertyAssignmentSyntax.prototype.withParameter = function (parameter) { - return this.update(this.setKeyword, this.propertyName, this.openParenToken, parameter, this.closeParenToken, this.block); - }; - - SetAccessorPropertyAssignmentSyntax.prototype.withCloseParenToken = function (closeParenToken) { - return this.update(this.setKeyword, this.propertyName, this.openParenToken, this.parameter, closeParenToken, this.block); - }; - - SetAccessorPropertyAssignmentSyntax.prototype.withBlock = function (block) { - return this.update(this.setKeyword, this.propertyName, this.openParenToken, this.parameter, this.closeParenToken, block); - }; - - SetAccessorPropertyAssignmentSyntax.prototype.isTypeScriptSpecific = function () { - if (this.parameter.isTypeScriptSpecific()) { - return true; - } - if (this.block.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return SetAccessorPropertyAssignmentSyntax; - })(AccessorPropertyAssignmentSyntax); - TypeScript.SetAccessorPropertyAssignmentSyntax = SetAccessorPropertyAssignmentSyntax; - - var FunctionExpressionSyntax = (function (_super) { - __extends(FunctionExpressionSyntax, _super); - function FunctionExpressionSyntax(functionKeyword, identifier, callSignature, block, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.functionKeyword = functionKeyword; - this.identifier = identifier; - this.callSignature = callSignature; - this.block = block; - } - FunctionExpressionSyntax.prototype.accept = function (visitor) { - return visitor.visitFunctionExpression(this); - }; - - FunctionExpressionSyntax.prototype.kind = function () { - return 221 /* FunctionExpression */; - }; - - FunctionExpressionSyntax.prototype.childCount = function () { - return 4; - }; - - FunctionExpressionSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.functionKeyword; - case 1: - return this.identifier; - case 2: - return this.callSignature; - case 3: - return this.block; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - FunctionExpressionSyntax.prototype.isUnaryExpression = function () { - return true; - }; - - FunctionExpressionSyntax.prototype.isExpression = function () { - return true; - }; - - FunctionExpressionSyntax.prototype.update = function (functionKeyword, identifier, callSignature, block) { - if (this.functionKeyword === functionKeyword && this.identifier === identifier && this.callSignature === callSignature && this.block === block) { - return this; - } - - return new FunctionExpressionSyntax(functionKeyword, identifier, callSignature, block, this.parsedInStrictMode()); - }; - - FunctionExpressionSyntax.create = function (functionKeyword, callSignature, block) { - return new FunctionExpressionSyntax(functionKeyword, null, callSignature, block, false); - }; - - FunctionExpressionSyntax.create1 = function () { - return new FunctionExpressionSyntax(TypeScript.Syntax.token(27 /* FunctionKeyword */), null, CallSignatureSyntax.create1(), BlockSyntax.create1(), false); - }; - - FunctionExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - FunctionExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - FunctionExpressionSyntax.prototype.withFunctionKeyword = function (functionKeyword) { - return this.update(functionKeyword, this.identifier, this.callSignature, this.block); - }; - - FunctionExpressionSyntax.prototype.withIdentifier = function (identifier) { - return this.update(this.functionKeyword, identifier, this.callSignature, this.block); - }; - - FunctionExpressionSyntax.prototype.withCallSignature = function (callSignature) { - return this.update(this.functionKeyword, this.identifier, callSignature, this.block); - }; - - FunctionExpressionSyntax.prototype.withBlock = function (block) { - return this.update(this.functionKeyword, this.identifier, this.callSignature, block); - }; - - FunctionExpressionSyntax.prototype.isTypeScriptSpecific = function () { - if (this.callSignature.isTypeScriptSpecific()) { - return true; - } - if (this.block.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return FunctionExpressionSyntax; - })(TypeScript.SyntaxNode); - TypeScript.FunctionExpressionSyntax = FunctionExpressionSyntax; - - var EmptyStatementSyntax = (function (_super) { - __extends(EmptyStatementSyntax, _super); - function EmptyStatementSyntax(semicolonToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.semicolonToken = semicolonToken; - } - EmptyStatementSyntax.prototype.accept = function (visitor) { - return visitor.visitEmptyStatement(this); - }; - - EmptyStatementSyntax.prototype.kind = function () { - return 155 /* EmptyStatement */; - }; - - EmptyStatementSyntax.prototype.childCount = function () { - return 1; - }; - - EmptyStatementSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.semicolonToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - EmptyStatementSyntax.prototype.isStatement = function () { - return true; - }; - - EmptyStatementSyntax.prototype.isModuleElement = function () { - return true; - }; - - EmptyStatementSyntax.prototype.update = function (semicolonToken) { - if (this.semicolonToken === semicolonToken) { - return this; - } - - return new EmptyStatementSyntax(semicolonToken, this.parsedInStrictMode()); - }; - - EmptyStatementSyntax.create1 = function () { - return new EmptyStatementSyntax(TypeScript.Syntax.token(79 /* SemicolonToken */), false); - }; - - EmptyStatementSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - EmptyStatementSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - EmptyStatementSyntax.prototype.withSemicolonToken = function (semicolonToken) { - return this.update(semicolonToken); - }; - - EmptyStatementSyntax.prototype.isTypeScriptSpecific = function () { - return false; - }; - return EmptyStatementSyntax; - })(TypeScript.SyntaxNode); - TypeScript.EmptyStatementSyntax = EmptyStatementSyntax; - - var TryStatementSyntax = (function (_super) { - __extends(TryStatementSyntax, _super); - function TryStatementSyntax(tryKeyword, block, catchClause, finallyClause, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.tryKeyword = tryKeyword; - this.block = block; - this.catchClause = catchClause; - this.finallyClause = finallyClause; - } - TryStatementSyntax.prototype.accept = function (visitor) { - return visitor.visitTryStatement(this); - }; - - TryStatementSyntax.prototype.kind = function () { - return 158 /* TryStatement */; - }; - - TryStatementSyntax.prototype.childCount = function () { - return 4; - }; - - TryStatementSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.tryKeyword; - case 1: - return this.block; - case 2: - return this.catchClause; - case 3: - return this.finallyClause; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - TryStatementSyntax.prototype.isStatement = function () { - return true; - }; - - TryStatementSyntax.prototype.isModuleElement = function () { - return true; - }; - - TryStatementSyntax.prototype.update = function (tryKeyword, block, catchClause, finallyClause) { - if (this.tryKeyword === tryKeyword && this.block === block && this.catchClause === catchClause && this.finallyClause === finallyClause) { - return this; - } - - return new TryStatementSyntax(tryKeyword, block, catchClause, finallyClause, this.parsedInStrictMode()); - }; - - TryStatementSyntax.create = function (tryKeyword, block) { - return new TryStatementSyntax(tryKeyword, block, null, null, false); - }; - - TryStatementSyntax.create1 = function () { - return new TryStatementSyntax(TypeScript.Syntax.token(38 /* TryKeyword */), BlockSyntax.create1(), null, null, false); - }; - - TryStatementSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - TryStatementSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - TryStatementSyntax.prototype.withTryKeyword = function (tryKeyword) { - return this.update(tryKeyword, this.block, this.catchClause, this.finallyClause); - }; - - TryStatementSyntax.prototype.withBlock = function (block) { - return this.update(this.tryKeyword, block, this.catchClause, this.finallyClause); - }; - - TryStatementSyntax.prototype.withCatchClause = function (catchClause) { - return this.update(this.tryKeyword, this.block, catchClause, this.finallyClause); - }; - - TryStatementSyntax.prototype.withFinallyClause = function (finallyClause) { - return this.update(this.tryKeyword, this.block, this.catchClause, finallyClause); - }; - - TryStatementSyntax.prototype.isTypeScriptSpecific = function () { - if (this.block.isTypeScriptSpecific()) { - return true; - } - if (this.catchClause !== null && this.catchClause.isTypeScriptSpecific()) { - return true; - } - if (this.finallyClause !== null && this.finallyClause.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return TryStatementSyntax; - })(TypeScript.SyntaxNode); - TypeScript.TryStatementSyntax = TryStatementSyntax; - - var CatchClauseSyntax = (function (_super) { - __extends(CatchClauseSyntax, _super); - function CatchClauseSyntax(catchKeyword, openParenToken, identifier, typeAnnotation, closeParenToken, block, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.catchKeyword = catchKeyword; - this.openParenToken = openParenToken; - this.identifier = identifier; - this.typeAnnotation = typeAnnotation; - this.closeParenToken = closeParenToken; - this.block = block; - } - CatchClauseSyntax.prototype.accept = function (visitor) { - return visitor.visitCatchClause(this); - }; - - CatchClauseSyntax.prototype.kind = function () { - return 234 /* CatchClause */; - }; - - CatchClauseSyntax.prototype.childCount = function () { - return 6; - }; - - CatchClauseSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.catchKeyword; - case 1: - return this.openParenToken; - case 2: - return this.identifier; - case 3: - return this.typeAnnotation; - case 4: - return this.closeParenToken; - case 5: - return this.block; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - CatchClauseSyntax.prototype.update = function (catchKeyword, openParenToken, identifier, typeAnnotation, closeParenToken, block) { - if (this.catchKeyword === catchKeyword && this.openParenToken === openParenToken && this.identifier === identifier && this.typeAnnotation === typeAnnotation && this.closeParenToken === closeParenToken && this.block === block) { - return this; - } - - return new CatchClauseSyntax(catchKeyword, openParenToken, identifier, typeAnnotation, closeParenToken, block, this.parsedInStrictMode()); - }; - - CatchClauseSyntax.create = function (catchKeyword, openParenToken, identifier, closeParenToken, block) { - return new CatchClauseSyntax(catchKeyword, openParenToken, identifier, null, closeParenToken, block, false); - }; - - CatchClauseSyntax.create1 = function (identifier) { - return new CatchClauseSyntax(TypeScript.Syntax.token(17 /* CatchKeyword */), TypeScript.Syntax.token(73 /* OpenParenToken */), identifier, null, TypeScript.Syntax.token(74 /* CloseParenToken */), BlockSyntax.create1(), false); - }; - - CatchClauseSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - CatchClauseSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - CatchClauseSyntax.prototype.withCatchKeyword = function (catchKeyword) { - return this.update(catchKeyword, this.openParenToken, this.identifier, this.typeAnnotation, this.closeParenToken, this.block); - }; - - CatchClauseSyntax.prototype.withOpenParenToken = function (openParenToken) { - return this.update(this.catchKeyword, openParenToken, this.identifier, this.typeAnnotation, this.closeParenToken, this.block); - }; - - CatchClauseSyntax.prototype.withIdentifier = function (identifier) { - return this.update(this.catchKeyword, this.openParenToken, identifier, this.typeAnnotation, this.closeParenToken, this.block); - }; - - CatchClauseSyntax.prototype.withTypeAnnotation = function (typeAnnotation) { - return this.update(this.catchKeyword, this.openParenToken, this.identifier, typeAnnotation, this.closeParenToken, this.block); - }; - - CatchClauseSyntax.prototype.withCloseParenToken = function (closeParenToken) { - return this.update(this.catchKeyword, this.openParenToken, this.identifier, this.typeAnnotation, closeParenToken, this.block); - }; - - CatchClauseSyntax.prototype.withBlock = function (block) { - return this.update(this.catchKeyword, this.openParenToken, this.identifier, this.typeAnnotation, this.closeParenToken, block); - }; - - CatchClauseSyntax.prototype.isTypeScriptSpecific = function () { - if (this.typeAnnotation !== null && this.typeAnnotation.isTypeScriptSpecific()) { - return true; - } - if (this.block.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return CatchClauseSyntax; - })(TypeScript.SyntaxNode); - TypeScript.CatchClauseSyntax = CatchClauseSyntax; - - var FinallyClauseSyntax = (function (_super) { - __extends(FinallyClauseSyntax, _super); - function FinallyClauseSyntax(finallyKeyword, block, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.finallyKeyword = finallyKeyword; - this.block = block; - } - FinallyClauseSyntax.prototype.accept = function (visitor) { - return visitor.visitFinallyClause(this); - }; - - FinallyClauseSyntax.prototype.kind = function () { - return 235 /* FinallyClause */; - }; - - FinallyClauseSyntax.prototype.childCount = function () { - return 2; - }; - - FinallyClauseSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.finallyKeyword; - case 1: - return this.block; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - FinallyClauseSyntax.prototype.update = function (finallyKeyword, block) { - if (this.finallyKeyword === finallyKeyword && this.block === block) { - return this; - } - - return new FinallyClauseSyntax(finallyKeyword, block, this.parsedInStrictMode()); - }; - - FinallyClauseSyntax.create1 = function () { - return new FinallyClauseSyntax(TypeScript.Syntax.token(25 /* FinallyKeyword */), BlockSyntax.create1(), false); - }; - - FinallyClauseSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - FinallyClauseSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - FinallyClauseSyntax.prototype.withFinallyKeyword = function (finallyKeyword) { - return this.update(finallyKeyword, this.block); - }; - - FinallyClauseSyntax.prototype.withBlock = function (block) { - return this.update(this.finallyKeyword, block); - }; - - FinallyClauseSyntax.prototype.isTypeScriptSpecific = function () { - if (this.block.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return FinallyClauseSyntax; - })(TypeScript.SyntaxNode); - TypeScript.FinallyClauseSyntax = FinallyClauseSyntax; - - var LabeledStatementSyntax = (function (_super) { - __extends(LabeledStatementSyntax, _super); - function LabeledStatementSyntax(identifier, colonToken, statement, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.identifier = identifier; - this.colonToken = colonToken; - this.statement = statement; - } - LabeledStatementSyntax.prototype.accept = function (visitor) { - return visitor.visitLabeledStatement(this); - }; - - LabeledStatementSyntax.prototype.kind = function () { - return 159 /* LabeledStatement */; - }; - - LabeledStatementSyntax.prototype.childCount = function () { - return 3; - }; - - LabeledStatementSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.identifier; - case 1: - return this.colonToken; - case 2: - return this.statement; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - LabeledStatementSyntax.prototype.isStatement = function () { - return true; - }; - - LabeledStatementSyntax.prototype.isModuleElement = function () { - return true; - }; - - LabeledStatementSyntax.prototype.update = function (identifier, colonToken, statement) { - if (this.identifier === identifier && this.colonToken === colonToken && this.statement === statement) { - return this; - } - - return new LabeledStatementSyntax(identifier, colonToken, statement, this.parsedInStrictMode()); - }; - - LabeledStatementSyntax.create1 = function (identifier, statement) { - return new LabeledStatementSyntax(identifier, TypeScript.Syntax.token(107 /* ColonToken */), statement, false); - }; - - LabeledStatementSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - LabeledStatementSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - LabeledStatementSyntax.prototype.withIdentifier = function (identifier) { - return this.update(identifier, this.colonToken, this.statement); - }; - - LabeledStatementSyntax.prototype.withColonToken = function (colonToken) { - return this.update(this.identifier, colonToken, this.statement); - }; - - LabeledStatementSyntax.prototype.withStatement = function (statement) { - return this.update(this.identifier, this.colonToken, statement); - }; - - LabeledStatementSyntax.prototype.isTypeScriptSpecific = function () { - if (this.statement.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return LabeledStatementSyntax; - })(TypeScript.SyntaxNode); - TypeScript.LabeledStatementSyntax = LabeledStatementSyntax; - - var DoStatementSyntax = (function (_super) { - __extends(DoStatementSyntax, _super); - function DoStatementSyntax(doKeyword, statement, whileKeyword, openParenToken, condition, closeParenToken, semicolonToken, parsedInStrictMode) { - _super.call(this, openParenToken, closeParenToken, statement, parsedInStrictMode); - this.doKeyword = doKeyword; - this.whileKeyword = whileKeyword; - this.condition = condition; - this.semicolonToken = semicolonToken; - } - DoStatementSyntax.prototype.accept = function (visitor) { - return visitor.visitDoStatement(this); - }; - - DoStatementSyntax.prototype.kind = function () { - return 160 /* DoStatement */; - }; - - DoStatementSyntax.prototype.childCount = function () { - return 7; - }; - - DoStatementSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.doKeyword; - case 1: - return this.statement; - case 2: - return this.whileKeyword; - case 3: - return this.openParenToken; - case 4: - return this.condition; - case 5: - return this.closeParenToken; - case 6: - return this.semicolonToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - DoStatementSyntax.prototype.update = function (doKeyword, statement, whileKeyword, openParenToken, condition, closeParenToken, semicolonToken) { - if (this.doKeyword === doKeyword && this.statement === statement && this.whileKeyword === whileKeyword && this.openParenToken === openParenToken && this.condition === condition && this.closeParenToken === closeParenToken && this.semicolonToken === semicolonToken) { - return this; - } - - return new DoStatementSyntax(doKeyword, statement, whileKeyword, openParenToken, condition, closeParenToken, semicolonToken, this.parsedInStrictMode()); - }; - - DoStatementSyntax.create1 = function (statement, condition) { - return new DoStatementSyntax(TypeScript.Syntax.token(22 /* DoKeyword */), statement, TypeScript.Syntax.token(42 /* WhileKeyword */), TypeScript.Syntax.token(73 /* OpenParenToken */), condition, TypeScript.Syntax.token(74 /* CloseParenToken */), TypeScript.Syntax.token(79 /* SemicolonToken */), false); - }; - - DoStatementSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - DoStatementSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - DoStatementSyntax.prototype.withDoKeyword = function (doKeyword) { - return this.update(doKeyword, this.statement, this.whileKeyword, this.openParenToken, this.condition, this.closeParenToken, this.semicolonToken); - }; - - DoStatementSyntax.prototype.withStatement = function (statement) { - return this.update(this.doKeyword, statement, this.whileKeyword, this.openParenToken, this.condition, this.closeParenToken, this.semicolonToken); - }; - - DoStatementSyntax.prototype.withWhileKeyword = function (whileKeyword) { - return this.update(this.doKeyword, this.statement, whileKeyword, this.openParenToken, this.condition, this.closeParenToken, this.semicolonToken); - }; - - DoStatementSyntax.prototype.withOpenParenToken = function (openParenToken) { - return this.update(this.doKeyword, this.statement, this.whileKeyword, openParenToken, this.condition, this.closeParenToken, this.semicolonToken); - }; - - DoStatementSyntax.prototype.withCondition = function (condition) { - return this.update(this.doKeyword, this.statement, this.whileKeyword, this.openParenToken, condition, this.closeParenToken, this.semicolonToken); - }; - - DoStatementSyntax.prototype.withCloseParenToken = function (closeParenToken) { - return this.update(this.doKeyword, this.statement, this.whileKeyword, this.openParenToken, this.condition, closeParenToken, this.semicolonToken); - }; - - DoStatementSyntax.prototype.withSemicolonToken = function (semicolonToken) { - return this.update(this.doKeyword, this.statement, this.whileKeyword, this.openParenToken, this.condition, this.closeParenToken, semicolonToken); - }; - - DoStatementSyntax.prototype.isTypeScriptSpecific = function () { - if (this.statement.isTypeScriptSpecific()) { - return true; - } - if (this.condition.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return DoStatementSyntax; - })(IterationStatementSyntax); - TypeScript.DoStatementSyntax = DoStatementSyntax; - - var TypeOfExpressionSyntax = (function (_super) { - __extends(TypeOfExpressionSyntax, _super); - function TypeOfExpressionSyntax(typeOfKeyword, expression, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.typeOfKeyword = typeOfKeyword; - this.expression = expression; - } - TypeOfExpressionSyntax.prototype.accept = function (visitor) { - return visitor.visitTypeOfExpression(this); - }; - - TypeOfExpressionSyntax.prototype.kind = function () { - return 170 /* TypeOfExpression */; - }; - - TypeOfExpressionSyntax.prototype.childCount = function () { - return 2; - }; - - TypeOfExpressionSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.typeOfKeyword; - case 1: - return this.expression; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - TypeOfExpressionSyntax.prototype.isUnaryExpression = function () { - return true; - }; - - TypeOfExpressionSyntax.prototype.isExpression = function () { - return true; - }; - - TypeOfExpressionSyntax.prototype.update = function (typeOfKeyword, expression) { - if (this.typeOfKeyword === typeOfKeyword && this.expression === expression) { - return this; - } - - return new TypeOfExpressionSyntax(typeOfKeyword, expression, this.parsedInStrictMode()); - }; - - TypeOfExpressionSyntax.create1 = function (expression) { - return new TypeOfExpressionSyntax(TypeScript.Syntax.token(39 /* TypeOfKeyword */), expression, false); - }; - - TypeOfExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - TypeOfExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - TypeOfExpressionSyntax.prototype.withTypeOfKeyword = function (typeOfKeyword) { - return this.update(typeOfKeyword, this.expression); - }; - - TypeOfExpressionSyntax.prototype.withExpression = function (expression) { - return this.update(this.typeOfKeyword, expression); - }; - - TypeOfExpressionSyntax.prototype.isTypeScriptSpecific = function () { - if (this.expression.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return TypeOfExpressionSyntax; - })(TypeScript.SyntaxNode); - TypeScript.TypeOfExpressionSyntax = TypeOfExpressionSyntax; - - var DeleteExpressionSyntax = (function (_super) { - __extends(DeleteExpressionSyntax, _super); - function DeleteExpressionSyntax(deleteKeyword, expression, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.deleteKeyword = deleteKeyword; - this.expression = expression; - } - DeleteExpressionSyntax.prototype.accept = function (visitor) { - return visitor.visitDeleteExpression(this); - }; - - DeleteExpressionSyntax.prototype.kind = function () { - return 169 /* DeleteExpression */; - }; - - DeleteExpressionSyntax.prototype.childCount = function () { - return 2; - }; - - DeleteExpressionSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.deleteKeyword; - case 1: - return this.expression; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - DeleteExpressionSyntax.prototype.isUnaryExpression = function () { - return true; - }; - - DeleteExpressionSyntax.prototype.isExpression = function () { - return true; - }; - - DeleteExpressionSyntax.prototype.update = function (deleteKeyword, expression) { - if (this.deleteKeyword === deleteKeyword && this.expression === expression) { - return this; - } - - return new DeleteExpressionSyntax(deleteKeyword, expression, this.parsedInStrictMode()); - }; - - DeleteExpressionSyntax.create1 = function (expression) { - return new DeleteExpressionSyntax(TypeScript.Syntax.token(21 /* DeleteKeyword */), expression, false); - }; - - DeleteExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - DeleteExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - DeleteExpressionSyntax.prototype.withDeleteKeyword = function (deleteKeyword) { - return this.update(deleteKeyword, this.expression); - }; - - DeleteExpressionSyntax.prototype.withExpression = function (expression) { - return this.update(this.deleteKeyword, expression); - }; - - DeleteExpressionSyntax.prototype.isTypeScriptSpecific = function () { - if (this.expression.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return DeleteExpressionSyntax; - })(TypeScript.SyntaxNode); - TypeScript.DeleteExpressionSyntax = DeleteExpressionSyntax; - - var VoidExpressionSyntax = (function (_super) { - __extends(VoidExpressionSyntax, _super); - function VoidExpressionSyntax(voidKeyword, expression, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.voidKeyword = voidKeyword; - this.expression = expression; - } - VoidExpressionSyntax.prototype.accept = function (visitor) { - return visitor.visitVoidExpression(this); - }; - - VoidExpressionSyntax.prototype.kind = function () { - return 171 /* VoidExpression */; - }; - - VoidExpressionSyntax.prototype.childCount = function () { - return 2; - }; - - VoidExpressionSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.voidKeyword; - case 1: - return this.expression; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - VoidExpressionSyntax.prototype.isUnaryExpression = function () { - return true; - }; - - VoidExpressionSyntax.prototype.isExpression = function () { - return true; - }; - - VoidExpressionSyntax.prototype.update = function (voidKeyword, expression) { - if (this.voidKeyword === voidKeyword && this.expression === expression) { - return this; - } - - return new VoidExpressionSyntax(voidKeyword, expression, this.parsedInStrictMode()); - }; - - VoidExpressionSyntax.create1 = function (expression) { - return new VoidExpressionSyntax(TypeScript.Syntax.token(41 /* VoidKeyword */), expression, false); - }; - - VoidExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - VoidExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - VoidExpressionSyntax.prototype.withVoidKeyword = function (voidKeyword) { - return this.update(voidKeyword, this.expression); - }; - - VoidExpressionSyntax.prototype.withExpression = function (expression) { - return this.update(this.voidKeyword, expression); - }; - - VoidExpressionSyntax.prototype.isTypeScriptSpecific = function () { - if (this.expression.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return VoidExpressionSyntax; - })(TypeScript.SyntaxNode); - TypeScript.VoidExpressionSyntax = VoidExpressionSyntax; - - var DebuggerStatementSyntax = (function (_super) { - __extends(DebuggerStatementSyntax, _super); - function DebuggerStatementSyntax(debuggerKeyword, semicolonToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.debuggerKeyword = debuggerKeyword; - this.semicolonToken = semicolonToken; - } - DebuggerStatementSyntax.prototype.accept = function (visitor) { - return visitor.visitDebuggerStatement(this); - }; - - DebuggerStatementSyntax.prototype.kind = function () { - return 161 /* DebuggerStatement */; - }; - - DebuggerStatementSyntax.prototype.childCount = function () { - return 2; - }; - - DebuggerStatementSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.debuggerKeyword; - case 1: - return this.semicolonToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - DebuggerStatementSyntax.prototype.isStatement = function () { - return true; - }; - - DebuggerStatementSyntax.prototype.isModuleElement = function () { - return true; - }; - - DebuggerStatementSyntax.prototype.update = function (debuggerKeyword, semicolonToken) { - if (this.debuggerKeyword === debuggerKeyword && this.semicolonToken === semicolonToken) { - return this; - } - - return new DebuggerStatementSyntax(debuggerKeyword, semicolonToken, this.parsedInStrictMode()); - }; - - DebuggerStatementSyntax.create1 = function () { - return new DebuggerStatementSyntax(TypeScript.Syntax.token(19 /* DebuggerKeyword */), TypeScript.Syntax.token(79 /* SemicolonToken */), false); - }; - - DebuggerStatementSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - DebuggerStatementSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - DebuggerStatementSyntax.prototype.withDebuggerKeyword = function (debuggerKeyword) { - return this.update(debuggerKeyword, this.semicolonToken); - }; - - DebuggerStatementSyntax.prototype.withSemicolonToken = function (semicolonToken) { - return this.update(this.debuggerKeyword, semicolonToken); - }; - - DebuggerStatementSyntax.prototype.isTypeScriptSpecific = function () { - return false; - }; - return DebuggerStatementSyntax; - })(TypeScript.SyntaxNode); - TypeScript.DebuggerStatementSyntax = DebuggerStatementSyntax; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var SyntaxRewriter = (function () { - function SyntaxRewriter() { - } - SyntaxRewriter.prototype.visitToken = function (token) { - return token; - }; - - SyntaxRewriter.prototype.visitNode = function (node) { - return node.accept(this); - }; - - SyntaxRewriter.prototype.visitNodeOrToken = function (node) { - return node.isToken() ? this.visitToken(node) : this.visitNode(node); - }; - - SyntaxRewriter.prototype.visitList = function (list) { - var newItems = null; - - for (var i = 0, n = list.childCount(); i < n; i++) { - var item = list.childAt(i); - var newItem = this.visitNodeOrToken(item); - - if (item !== newItem && newItems === null) { - newItems = []; - for (var j = 0; j < i; j++) { - newItems.push(list.childAt(j)); - } - } - - if (newItems) { - newItems.push(newItem); - } - } - - return newItems === null ? list : TypeScript.Syntax.list(newItems); - }; - - SyntaxRewriter.prototype.visitSeparatedList = function (list) { - var newItems = null; - - for (var i = 0, n = list.childCount(); i < n; i++) { - var item = list.childAt(i); - var newItem = item.isToken() ? this.visitToken(item) : this.visitNode(item); - - if (item !== newItem && newItems === null) { - newItems = []; - for (var j = 0; j < i; j++) { - newItems.push(list.childAt(j)); - } - } - - if (newItems) { - newItems.push(newItem); - } - } - - return newItems === null ? list : TypeScript.Syntax.separatedList(newItems); - }; - - SyntaxRewriter.prototype.visitSourceUnit = function (node) { - return node.update(this.visitList(node.moduleElements), this.visitToken(node.endOfFileToken)); - }; - - SyntaxRewriter.prototype.visitExternalModuleReference = function (node) { - return node.update(this.visitToken(node.moduleOrRequireKeyword), this.visitToken(node.openParenToken), this.visitToken(node.stringLiteral), this.visitToken(node.closeParenToken)); - }; - - SyntaxRewriter.prototype.visitModuleNameModuleReference = function (node) { - return node.update(this.visitNodeOrToken(node.moduleName)); - }; - - SyntaxRewriter.prototype.visitImportDeclaration = function (node) { - return node.update(this.visitToken(node.importKeyword), this.visitToken(node.identifier), this.visitToken(node.equalsToken), this.visitNode(node.moduleReference), this.visitToken(node.semicolonToken)); - }; - - SyntaxRewriter.prototype.visitExportAssignment = function (node) { - return node.update(this.visitToken(node.exportKeyword), this.visitToken(node.equalsToken), this.visitToken(node.identifier), this.visitToken(node.semicolonToken)); - }; - - SyntaxRewriter.prototype.visitClassDeclaration = function (node) { - return node.update(this.visitList(node.modifiers), this.visitToken(node.classKeyword), this.visitToken(node.identifier), node.typeParameterList === null ? null : this.visitNode(node.typeParameterList), this.visitList(node.heritageClauses), this.visitToken(node.openBraceToken), this.visitList(node.classElements), this.visitToken(node.closeBraceToken)); - }; - - SyntaxRewriter.prototype.visitInterfaceDeclaration = function (node) { - return node.update(this.visitList(node.modifiers), this.visitToken(node.interfaceKeyword), this.visitToken(node.identifier), node.typeParameterList === null ? null : this.visitNode(node.typeParameterList), this.visitList(node.heritageClauses), this.visitNode(node.body)); - }; - - SyntaxRewriter.prototype.visitHeritageClause = function (node) { - return node.update(this.visitToken(node.extendsOrImplementsKeyword), this.visitSeparatedList(node.typeNames)); - }; - - SyntaxRewriter.prototype.visitModuleDeclaration = function (node) { - return node.update(this.visitList(node.modifiers), this.visitToken(node.moduleKeyword), node.moduleName === null ? null : this.visitNodeOrToken(node.moduleName), node.stringLiteral === null ? null : this.visitToken(node.stringLiteral), this.visitToken(node.openBraceToken), this.visitList(node.moduleElements), this.visitToken(node.closeBraceToken)); - }; - - SyntaxRewriter.prototype.visitFunctionDeclaration = function (node) { - return node.update(this.visitList(node.modifiers), this.visitToken(node.functionKeyword), this.visitToken(node.identifier), this.visitNode(node.callSignature), node.block === null ? null : this.visitNode(node.block), node.semicolonToken === null ? null : this.visitToken(node.semicolonToken)); - }; - - SyntaxRewriter.prototype.visitVariableStatement = function (node) { - return node.update(this.visitList(node.modifiers), this.visitNode(node.variableDeclaration), this.visitToken(node.semicolonToken)); - }; - - SyntaxRewriter.prototype.visitVariableDeclaration = function (node) { - return node.update(this.visitToken(node.varKeyword), this.visitSeparatedList(node.variableDeclarators)); - }; - - SyntaxRewriter.prototype.visitVariableDeclarator = function (node) { - return node.update(this.visitToken(node.identifier), node.typeAnnotation === null ? null : this.visitNode(node.typeAnnotation), node.equalsValueClause === null ? null : this.visitNode(node.equalsValueClause)); - }; - - SyntaxRewriter.prototype.visitEqualsValueClause = function (node) { - return node.update(this.visitToken(node.equalsToken), this.visitNodeOrToken(node.value)); - }; - - SyntaxRewriter.prototype.visitPrefixUnaryExpression = function (node) { - return node.update(node.kind(), this.visitToken(node.operatorToken), this.visitNodeOrToken(node.operand)); - }; - - SyntaxRewriter.prototype.visitArrayLiteralExpression = function (node) { - return node.update(this.visitToken(node.openBracketToken), this.visitSeparatedList(node.expressions), this.visitToken(node.closeBracketToken)); - }; - - SyntaxRewriter.prototype.visitOmittedExpression = function (node) { - return node; - }; - - SyntaxRewriter.prototype.visitParenthesizedExpression = function (node) { - return node.update(this.visitToken(node.openParenToken), this.visitNodeOrToken(node.expression), this.visitToken(node.closeParenToken)); - }; - - SyntaxRewriter.prototype.visitSimpleArrowFunctionExpression = function (node) { - return node.update(this.visitToken(node.identifier), this.visitToken(node.equalsGreaterThanToken), this.visitNodeOrToken(node.body)); - }; - - SyntaxRewriter.prototype.visitParenthesizedArrowFunctionExpression = function (node) { - return node.update(this.visitNode(node.callSignature), this.visitToken(node.equalsGreaterThanToken), this.visitNodeOrToken(node.body)); - }; - - SyntaxRewriter.prototype.visitQualifiedName = function (node) { - return node.update(this.visitNodeOrToken(node.left), this.visitToken(node.dotToken), this.visitToken(node.right)); - }; - - SyntaxRewriter.prototype.visitTypeArgumentList = function (node) { - return node.update(this.visitToken(node.lessThanToken), this.visitSeparatedList(node.typeArguments), this.visitToken(node.greaterThanToken)); - }; - - SyntaxRewriter.prototype.visitConstructorType = function (node) { - return node.update(this.visitToken(node.newKeyword), node.typeParameterList === null ? null : this.visitNode(node.typeParameterList), this.visitNode(node.parameterList), this.visitToken(node.equalsGreaterThanToken), this.visitNodeOrToken(node.type)); - }; - - SyntaxRewriter.prototype.visitFunctionType = function (node) { - return node.update(node.typeParameterList === null ? null : this.visitNode(node.typeParameterList), this.visitNode(node.parameterList), this.visitToken(node.equalsGreaterThanToken), this.visitNodeOrToken(node.type)); - }; - - SyntaxRewriter.prototype.visitObjectType = function (node) { - return node.update(this.visitToken(node.openBraceToken), this.visitSeparatedList(node.typeMembers), this.visitToken(node.closeBraceToken)); - }; - - SyntaxRewriter.prototype.visitArrayType = function (node) { - return node.update(this.visitNodeOrToken(node.type), this.visitToken(node.openBracketToken), this.visitToken(node.closeBracketToken)); - }; - - SyntaxRewriter.prototype.visitGenericType = function (node) { - return node.update(this.visitNodeOrToken(node.name), this.visitNode(node.typeArgumentList)); - }; - - SyntaxRewriter.prototype.visitTypeAnnotation = function (node) { - return node.update(this.visitToken(node.colonToken), this.visitNodeOrToken(node.type)); - }; - - SyntaxRewriter.prototype.visitBlock = function (node) { - return node.update(this.visitToken(node.openBraceToken), this.visitList(node.statements), this.visitToken(node.closeBraceToken)); - }; - - SyntaxRewriter.prototype.visitParameter = function (node) { - return node.update(node.dotDotDotToken === null ? null : this.visitToken(node.dotDotDotToken), node.publicOrPrivateKeyword === null ? null : this.visitToken(node.publicOrPrivateKeyword), this.visitToken(node.identifier), node.questionToken === null ? null : this.visitToken(node.questionToken), node.typeAnnotation === null ? null : this.visitNode(node.typeAnnotation), node.equalsValueClause === null ? null : this.visitNode(node.equalsValueClause)); - }; - - SyntaxRewriter.prototype.visitMemberAccessExpression = function (node) { - return node.update(this.visitNodeOrToken(node.expression), this.visitToken(node.dotToken), this.visitToken(node.name)); - }; - - SyntaxRewriter.prototype.visitPostfixUnaryExpression = function (node) { - return node.update(node.kind(), this.visitNodeOrToken(node.operand), this.visitToken(node.operatorToken)); - }; - - SyntaxRewriter.prototype.visitElementAccessExpression = function (node) { - return node.update(this.visitNodeOrToken(node.expression), this.visitToken(node.openBracketToken), this.visitNodeOrToken(node.argumentExpression), this.visitToken(node.closeBracketToken)); - }; - - SyntaxRewriter.prototype.visitInvocationExpression = function (node) { - return node.update(this.visitNodeOrToken(node.expression), this.visitNode(node.argumentList)); - }; - - SyntaxRewriter.prototype.visitArgumentList = function (node) { - return node.update(node.typeArgumentList === null ? null : this.visitNode(node.typeArgumentList), this.visitToken(node.openParenToken), this.visitSeparatedList(node.arguments), this.visitToken(node.closeParenToken)); - }; - - SyntaxRewriter.prototype.visitBinaryExpression = function (node) { - return node.update(node.kind(), this.visitNodeOrToken(node.left), this.visitToken(node.operatorToken), this.visitNodeOrToken(node.right)); - }; - - SyntaxRewriter.prototype.visitConditionalExpression = function (node) { - return node.update(this.visitNodeOrToken(node.condition), this.visitToken(node.questionToken), this.visitNodeOrToken(node.whenTrue), this.visitToken(node.colonToken), this.visitNodeOrToken(node.whenFalse)); - }; - - SyntaxRewriter.prototype.visitConstructSignature = function (node) { - return node.update(this.visitToken(node.newKeyword), this.visitNode(node.callSignature)); - }; - - SyntaxRewriter.prototype.visitMethodSignature = function (node) { - return node.update(this.visitToken(node.propertyName), node.questionToken === null ? null : this.visitToken(node.questionToken), this.visitNode(node.callSignature)); - }; - - SyntaxRewriter.prototype.visitIndexSignature = function (node) { - return node.update(this.visitToken(node.openBracketToken), this.visitNode(node.parameter), this.visitToken(node.closeBracketToken), node.typeAnnotation === null ? null : this.visitNode(node.typeAnnotation)); - }; - - SyntaxRewriter.prototype.visitPropertySignature = function (node) { - return node.update(this.visitToken(node.propertyName), node.questionToken === null ? null : this.visitToken(node.questionToken), node.typeAnnotation === null ? null : this.visitNode(node.typeAnnotation)); - }; - - SyntaxRewriter.prototype.visitCallSignature = function (node) { - return node.update(node.typeParameterList === null ? null : this.visitNode(node.typeParameterList), this.visitNode(node.parameterList), node.typeAnnotation === null ? null : this.visitNode(node.typeAnnotation)); - }; - - SyntaxRewriter.prototype.visitParameterList = function (node) { - return node.update(this.visitToken(node.openParenToken), this.visitSeparatedList(node.parameters), this.visitToken(node.closeParenToken)); - }; - - SyntaxRewriter.prototype.visitTypeParameterList = function (node) { - return node.update(this.visitToken(node.lessThanToken), this.visitSeparatedList(node.typeParameters), this.visitToken(node.greaterThanToken)); - }; - - SyntaxRewriter.prototype.visitTypeParameter = function (node) { - return node.update(this.visitToken(node.identifier), node.constraint === null ? null : this.visitNode(node.constraint)); - }; - - SyntaxRewriter.prototype.visitConstraint = function (node) { - return node.update(this.visitToken(node.extendsKeyword), this.visitNodeOrToken(node.type)); - }; - - SyntaxRewriter.prototype.visitElseClause = function (node) { - return node.update(this.visitToken(node.elseKeyword), this.visitNodeOrToken(node.statement)); - }; - - SyntaxRewriter.prototype.visitIfStatement = function (node) { - return node.update(this.visitToken(node.ifKeyword), this.visitToken(node.openParenToken), this.visitNodeOrToken(node.condition), this.visitToken(node.closeParenToken), this.visitNodeOrToken(node.statement), node.elseClause === null ? null : this.visitNode(node.elseClause)); - }; - - SyntaxRewriter.prototype.visitExpressionStatement = function (node) { - return node.update(this.visitNodeOrToken(node.expression), this.visitToken(node.semicolonToken)); - }; - - SyntaxRewriter.prototype.visitConstructorDeclaration = function (node) { - return node.update(this.visitToken(node.constructorKeyword), this.visitNode(node.parameterList), node.block === null ? null : this.visitNode(node.block), node.semicolonToken === null ? null : this.visitToken(node.semicolonToken)); - }; - - SyntaxRewriter.prototype.visitMemberFunctionDeclaration = function (node) { - return node.update(this.visitList(node.modifiers), this.visitToken(node.propertyName), this.visitNode(node.callSignature), node.block === null ? null : this.visitNode(node.block), node.semicolonToken === null ? null : this.visitToken(node.semicolonToken)); - }; - - SyntaxRewriter.prototype.visitGetMemberAccessorDeclaration = function (node) { - return node.update(this.visitList(node.modifiers), this.visitToken(node.getKeyword), this.visitToken(node.propertyName), this.visitNode(node.parameterList), node.typeAnnotation === null ? null : this.visitNode(node.typeAnnotation), this.visitNode(node.block)); - }; - - SyntaxRewriter.prototype.visitSetMemberAccessorDeclaration = function (node) { - return node.update(this.visitList(node.modifiers), this.visitToken(node.setKeyword), this.visitToken(node.propertyName), this.visitNode(node.parameterList), this.visitNode(node.block)); - }; - - SyntaxRewriter.prototype.visitMemberVariableDeclaration = function (node) { - return node.update(this.visitList(node.modifiers), this.visitNode(node.variableDeclarator), this.visitToken(node.semicolonToken)); - }; - - SyntaxRewriter.prototype.visitThrowStatement = function (node) { - return node.update(this.visitToken(node.throwKeyword), this.visitNodeOrToken(node.expression), this.visitToken(node.semicolonToken)); - }; - - SyntaxRewriter.prototype.visitReturnStatement = function (node) { - return node.update(this.visitToken(node.returnKeyword), node.expression === null ? null : this.visitNodeOrToken(node.expression), this.visitToken(node.semicolonToken)); - }; - - SyntaxRewriter.prototype.visitObjectCreationExpression = function (node) { - return node.update(this.visitToken(node.newKeyword), this.visitNodeOrToken(node.expression), node.argumentList === null ? null : this.visitNode(node.argumentList)); - }; - - SyntaxRewriter.prototype.visitSwitchStatement = function (node) { - return node.update(this.visitToken(node.switchKeyword), this.visitToken(node.openParenToken), this.visitNodeOrToken(node.expression), this.visitToken(node.closeParenToken), this.visitToken(node.openBraceToken), this.visitList(node.switchClauses), this.visitToken(node.closeBraceToken)); - }; - - SyntaxRewriter.prototype.visitCaseSwitchClause = function (node) { - return node.update(this.visitToken(node.caseKeyword), this.visitNodeOrToken(node.expression), this.visitToken(node.colonToken), this.visitList(node.statements)); - }; - - SyntaxRewriter.prototype.visitDefaultSwitchClause = function (node) { - return node.update(this.visitToken(node.defaultKeyword), this.visitToken(node.colonToken), this.visitList(node.statements)); - }; - - SyntaxRewriter.prototype.visitBreakStatement = function (node) { - return node.update(this.visitToken(node.breakKeyword), node.identifier === null ? null : this.visitToken(node.identifier), this.visitToken(node.semicolonToken)); - }; - - SyntaxRewriter.prototype.visitContinueStatement = function (node) { - return node.update(this.visitToken(node.continueKeyword), node.identifier === null ? null : this.visitToken(node.identifier), this.visitToken(node.semicolonToken)); - }; - - SyntaxRewriter.prototype.visitForStatement = function (node) { - return node.update(this.visitToken(node.forKeyword), this.visitToken(node.openParenToken), node.variableDeclaration === null ? null : this.visitNode(node.variableDeclaration), node.initializer === null ? null : this.visitNodeOrToken(node.initializer), this.visitToken(node.firstSemicolonToken), node.condition === null ? null : this.visitNodeOrToken(node.condition), this.visitToken(node.secondSemicolonToken), node.incrementor === null ? null : this.visitNodeOrToken(node.incrementor), this.visitToken(node.closeParenToken), this.visitNodeOrToken(node.statement)); - }; - - SyntaxRewriter.prototype.visitForInStatement = function (node) { - return node.update(this.visitToken(node.forKeyword), this.visitToken(node.openParenToken), node.variableDeclaration === null ? null : this.visitNode(node.variableDeclaration), node.left === null ? null : this.visitNodeOrToken(node.left), this.visitToken(node.inKeyword), this.visitNodeOrToken(node.expression), this.visitToken(node.closeParenToken), this.visitNodeOrToken(node.statement)); - }; - - SyntaxRewriter.prototype.visitWhileStatement = function (node) { - return node.update(this.visitToken(node.whileKeyword), this.visitToken(node.openParenToken), this.visitNodeOrToken(node.condition), this.visitToken(node.closeParenToken), this.visitNodeOrToken(node.statement)); - }; - - SyntaxRewriter.prototype.visitWithStatement = function (node) { - return node.update(this.visitToken(node.withKeyword), this.visitToken(node.openParenToken), this.visitNodeOrToken(node.condition), this.visitToken(node.closeParenToken), this.visitNodeOrToken(node.statement)); - }; - - SyntaxRewriter.prototype.visitEnumDeclaration = function (node) { - return node.update(this.visitList(node.modifiers), this.visitToken(node.enumKeyword), this.visitToken(node.identifier), this.visitToken(node.openBraceToken), this.visitSeparatedList(node.enumElements), this.visitToken(node.closeBraceToken)); - }; - - SyntaxRewriter.prototype.visitEnumElement = function (node) { - return node.update(this.visitToken(node.propertyName), node.equalsValueClause === null ? null : this.visitNode(node.equalsValueClause)); - }; - - SyntaxRewriter.prototype.visitCastExpression = function (node) { - return node.update(this.visitToken(node.lessThanToken), this.visitNodeOrToken(node.type), this.visitToken(node.greaterThanToken), this.visitNodeOrToken(node.expression)); - }; - - SyntaxRewriter.prototype.visitObjectLiteralExpression = function (node) { - return node.update(this.visitToken(node.openBraceToken), this.visitSeparatedList(node.propertyAssignments), this.visitToken(node.closeBraceToken)); - }; - - SyntaxRewriter.prototype.visitSimplePropertyAssignment = function (node) { - return node.update(this.visitToken(node.propertyName), this.visitToken(node.colonToken), this.visitNodeOrToken(node.expression)); - }; - - SyntaxRewriter.prototype.visitFunctionPropertyAssignment = function (node) { - return node.update(this.visitToken(node.propertyName), this.visitNode(node.callSignature), this.visitNode(node.block)); - }; - - SyntaxRewriter.prototype.visitGetAccessorPropertyAssignment = function (node) { - return node.update(this.visitToken(node.getKeyword), this.visitToken(node.propertyName), this.visitToken(node.openParenToken), this.visitToken(node.closeParenToken), node.typeAnnotation === null ? null : this.visitNode(node.typeAnnotation), this.visitNode(node.block)); - }; - - SyntaxRewriter.prototype.visitSetAccessorPropertyAssignment = function (node) { - return node.update(this.visitToken(node.setKeyword), this.visitToken(node.propertyName), this.visitToken(node.openParenToken), this.visitNode(node.parameter), this.visitToken(node.closeParenToken), this.visitNode(node.block)); - }; - - SyntaxRewriter.prototype.visitFunctionExpression = function (node) { - return node.update(this.visitToken(node.functionKeyword), node.identifier === null ? null : this.visitToken(node.identifier), this.visitNode(node.callSignature), this.visitNode(node.block)); - }; - - SyntaxRewriter.prototype.visitEmptyStatement = function (node) { - return node.update(this.visitToken(node.semicolonToken)); - }; - - SyntaxRewriter.prototype.visitTryStatement = function (node) { - return node.update(this.visitToken(node.tryKeyword), this.visitNode(node.block), node.catchClause === null ? null : this.visitNode(node.catchClause), node.finallyClause === null ? null : this.visitNode(node.finallyClause)); - }; - - SyntaxRewriter.prototype.visitCatchClause = function (node) { - return node.update(this.visitToken(node.catchKeyword), this.visitToken(node.openParenToken), this.visitToken(node.identifier), node.typeAnnotation === null ? null : this.visitNode(node.typeAnnotation), this.visitToken(node.closeParenToken), this.visitNode(node.block)); - }; - - SyntaxRewriter.prototype.visitFinallyClause = function (node) { - return node.update(this.visitToken(node.finallyKeyword), this.visitNode(node.block)); - }; - - SyntaxRewriter.prototype.visitLabeledStatement = function (node) { - return node.update(this.visitToken(node.identifier), this.visitToken(node.colonToken), this.visitNodeOrToken(node.statement)); - }; - - SyntaxRewriter.prototype.visitDoStatement = function (node) { - return node.update(this.visitToken(node.doKeyword), this.visitNodeOrToken(node.statement), this.visitToken(node.whileKeyword), this.visitToken(node.openParenToken), this.visitNodeOrToken(node.condition), this.visitToken(node.closeParenToken), this.visitToken(node.semicolonToken)); - }; - - SyntaxRewriter.prototype.visitTypeOfExpression = function (node) { - return node.update(this.visitToken(node.typeOfKeyword), this.visitNodeOrToken(node.expression)); - }; - - SyntaxRewriter.prototype.visitDeleteExpression = function (node) { - return node.update(this.visitToken(node.deleteKeyword), this.visitNodeOrToken(node.expression)); - }; - - SyntaxRewriter.prototype.visitVoidExpression = function (node) { - return node.update(this.visitToken(node.voidKeyword), this.visitNodeOrToken(node.expression)); - }; - - SyntaxRewriter.prototype.visitDebuggerStatement = function (node) { - return node.update(this.visitToken(node.debuggerKeyword), this.visitToken(node.semicolonToken)); - }; - return SyntaxRewriter; - })(); - TypeScript.SyntaxRewriter = SyntaxRewriter; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var SyntaxDedenter = (function (_super) { - __extends(SyntaxDedenter, _super); - function SyntaxDedenter(dedentFirstToken, dedentationAmount, minimumIndent, options) { - _super.call(this); - this.dedentationAmount = dedentationAmount; - this.minimumIndent = minimumIndent; - this.options = options; - this.lastTriviaWasNewLine = dedentFirstToken; - } - SyntaxDedenter.prototype.abort = function () { - this.lastTriviaWasNewLine = false; - this.dedentationAmount = 0; - }; - - SyntaxDedenter.prototype.isAborted = function () { - return this.dedentationAmount === 0; - }; - - SyntaxDedenter.prototype.visitToken = function (token) { - if (token.width() === 0) { - return token; - } - - var result = token; - if (this.lastTriviaWasNewLine) { - result = token.withLeadingTrivia(this.dedentTriviaList(token.leadingTrivia())); - } - - if (this.isAborted()) { - return token; - } - - this.lastTriviaWasNewLine = token.hasTrailingNewLine(); - return result; - }; - - SyntaxDedenter.prototype.dedentTriviaList = function (triviaList) { - var result = []; - var dedentNextWhitespace = true; - - 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() === 4 /* WhitespaceTrivia */) { - var hasFollowingNewLine = (i < triviaList.count() - 1) && triviaList.syntaxTriviaAt(i + 1).kind() === 5 /* NewLineTrivia */; - result.push(this.dedentWhitespace(trivia, hasFollowingNewLine)); - continue; - } else if (trivia.kind() !== 5 /* NewLineTrivia */) { - this.abort(); - break; - } - } - - if (trivia.kind() === 6 /* MultiLineCommentTrivia */) { - result.push(this.dedentMultiLineComment(trivia)); - continue; - } - - result.push(trivia); - if (trivia.kind() === 5 /* NewLineTrivia */) { - dedentNextWhitespace = true; - } - } - - if (dedentNextWhitespace) { - this.abort(); - } - - if (this.isAborted()) { - return triviaList; - } - - return TypeScript.Syntax.triviaList(result); - }; - - SyntaxDedenter.prototype.dedentSegment = function (segment, hasFollowingNewLineTrivia) { - var firstNonWhitespacePosition = TypeScript.Indentation.firstNonWhitespacePosition(segment); - - if (firstNonWhitespacePosition === segment.length) { - if (hasFollowingNewLineTrivia) { - return ""; - } - } else if (TypeScript.CharacterInfo.isLineTerminator(segment.charCodeAt(firstNonWhitespacePosition))) { - return segment.substring(firstNonWhitespacePosition); - } - - var firstNonWhitespaceColumn = TypeScript.Indentation.columnForPositionInString(segment, firstNonWhitespacePosition, this.options); - - var newFirstNonWhitespaceColumn = TypeScript.MathPrototype.min(firstNonWhitespaceColumn, TypeScript.MathPrototype.max(firstNonWhitespaceColumn - this.dedentationAmount, this.minimumIndent)); - - if (newFirstNonWhitespaceColumn === firstNonWhitespaceColumn) { - this.abort(); - return segment; - } - - this.dedentationAmount = firstNonWhitespaceColumn - newFirstNonWhitespaceColumn; - TypeScript.Debug.assert(this.dedentationAmount >= 0); - - var indentationString = TypeScript.Indentation.indentationString(newFirstNonWhitespaceColumn, this.options); - - return indentationString + segment.substring(firstNonWhitespacePosition); - }; - - SyntaxDedenter.prototype.dedentWhitespace = function (trivia, hasFollowingNewLineTrivia) { - var newIndentation = this.dedentSegment(trivia.fullText(), hasFollowingNewLineTrivia); - return TypeScript.Syntax.whitespace(newIndentation); - }; - - SyntaxDedenter.prototype.dedentMultiLineComment = function (trivia) { - var segments = TypeScript.Syntax.splitMultiLineCommentTriviaIntoMultipleLines(trivia); - if (segments.length === 1) { - return trivia; - } - - for (var i = 1; i < segments.length; i++) { - var segment = segments[i]; - segments[i] = this.dedentSegment(segment, false); - } - - var result = segments.join(""); - - return TypeScript.Syntax.multiLineComment(result); - }; - - SyntaxDedenter.dedentNode = function (node, dedentFirstToken, dedentAmount, minimumIndent, options) { - var dedenter = new SyntaxDedenter(dedentFirstToken, dedentAmount, minimumIndent, options); - var result = node.accept(dedenter); - - if (dedenter.isAborted()) { - return node; - } - - return result; - }; - return SyntaxDedenter; - })(TypeScript.SyntaxRewriter); - TypeScript.SyntaxDedenter = SyntaxDedenter; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var SyntaxIndenter = (function (_super) { - __extends(SyntaxIndenter, _super); - function SyntaxIndenter(indentFirstToken, indentationAmount, options) { - _super.call(this); - this.indentationAmount = indentationAmount; - this.options = options; - this.lastTriviaWasNewLine = indentFirstToken; - this.indentationTrivia = TypeScript.Indentation.indentationTrivia(this.indentationAmount, this.options); - } - SyntaxIndenter.prototype.visitToken = function (token) { - if (token.width() === 0) { - return token; - } - - var result = token; - if (this.lastTriviaWasNewLine) { - result = token.withLeadingTrivia(this.indentTriviaList(token.leadingTrivia())); - } - - this.lastTriviaWasNewLine = token.hasTrailingNewLine(); - return result; - }; - - SyntaxIndenter.prototype.indentTriviaList = function (triviaList) { - var result = []; - - 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 6 /* MultiLineCommentTrivia */: - this.indentMultiLineComment(trivia, indentThisTrivia, result); - continue; - - case 7 /* SingleLineCommentTrivia */: - case 8 /* SkippedTokenTrivia */: - this.indentSingleLineOrSkippedText(trivia, indentThisTrivia, result); - continue; - - case 4 /* WhitespaceTrivia */: - this.indentWhitespace(trivia, indentThisTrivia, result); - continue; - - case 5 /* NewLineTrivia */: - result.push(trivia); - indentNextTrivia = true; - continue; - - default: - throw TypeScript.Errors.invalidOperation(); - } - } - - if (indentNextTrivia) { - result.push(this.indentationTrivia); - } - - return TypeScript.Syntax.triviaList(result); - }; - - SyntaxIndenter.prototype.indentSegment = function (segment) { - var firstNonWhitespacePosition = TypeScript.Indentation.firstNonWhitespacePosition(segment); - - if (firstNonWhitespacePosition < segment.length && TypeScript.CharacterInfo.isLineTerminator(segment.charCodeAt(firstNonWhitespacePosition))) { - return segment; - } - - var firstNonWhitespaceColumn = TypeScript.Indentation.columnForPositionInString(segment, firstNonWhitespacePosition, this.options); - - var newFirstNonWhitespaceColumn = firstNonWhitespaceColumn + this.indentationAmount; - - var indentationString = TypeScript.Indentation.indentationString(newFirstNonWhitespaceColumn, this.options); - - return indentationString + segment.substring(firstNonWhitespacePosition); - }; - - SyntaxIndenter.prototype.indentWhitespace = function (trivia, indentThisTrivia, result) { - if (!indentThisTrivia) { - result.push(trivia); - return; - } - - var newIndentation = this.indentSegment(trivia.fullText()); - result.push(TypeScript.Syntax.whitespace(newIndentation)); - }; - - SyntaxIndenter.prototype.indentSingleLineOrSkippedText = function (trivia, indentThisTrivia, result) { - if (indentThisTrivia) { - result.push(this.indentationTrivia); - } - - result.push(trivia); - }; - - SyntaxIndenter.prototype.indentMultiLineComment = function (trivia, indentThisTrivia, result) { - if (indentThisTrivia) { - result.push(this.indentationTrivia); - } - - var segments = TypeScript.Syntax.splitMultiLineCommentTriviaIntoMultipleLines(trivia); - - for (var i = 1; i < segments.length; i++) { - segments[i] = this.indentSegment(segments[i]); - } - - var newText = segments.join(""); - result.push(TypeScript.Syntax.multiLineComment(newText)); - }; - - SyntaxIndenter.indentNode = function (node, indentFirstToken, indentAmount, options) { - var indenter = new SyntaxIndenter(indentFirstToken, indentAmount, options); - return node.accept(indenter); - }; - - SyntaxIndenter.indentNodes = function (nodes, indentFirstToken, indentAmount, options) { - var indenter = new SyntaxIndenter(indentFirstToken, indentAmount, options); - var result = TypeScript.ArrayUtilities.select(nodes, function (n) { - return n.accept(indenter); - }); - - return result; - }; - return SyntaxIndenter; - })(TypeScript.SyntaxRewriter); - TypeScript.SyntaxIndenter = SyntaxIndenter; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (Syntax) { - var VariableWidthTokenWithNoTrivia = (function () { - function VariableWidthTokenWithNoTrivia(sourceText, fullStart, kind, textOrWidth) { - this._sourceText = sourceText; - this._fullStart = fullStart; - this.tokenKind = kind; - this._textOrWidth = textOrWidth; - } - VariableWidthTokenWithNoTrivia.prototype.clone = function () { - return new VariableWidthTokenWithNoTrivia(this._sourceText, this._fullStart, this.tokenKind, this._textOrWidth); - }; - - VariableWidthTokenWithNoTrivia.prototype.isNode = function () { - return false; - }; - VariableWidthTokenWithNoTrivia.prototype.isToken = function () { - return true; - }; - VariableWidthTokenWithNoTrivia.prototype.isList = function () { - return false; - }; - VariableWidthTokenWithNoTrivia.prototype.isSeparatedList = function () { - return false; - }; - - VariableWidthTokenWithNoTrivia.prototype.kind = function () { - return this.tokenKind; - }; - - VariableWidthTokenWithNoTrivia.prototype.childCount = function () { - return 0; - }; - VariableWidthTokenWithNoTrivia.prototype.childAt = function (index) { - throw TypeScript.Errors.argumentOutOfRange('index'); - }; - - VariableWidthTokenWithNoTrivia.prototype.fullWidth = function () { - return this.width(); - }; - VariableWidthTokenWithNoTrivia.prototype.start = function () { - return this._fullStart; - }; - VariableWidthTokenWithNoTrivia.prototype.end = function () { - return this.start() + this.width(); - }; - - VariableWidthTokenWithNoTrivia.prototype.width = function () { - return typeof this._textOrWidth === 'number' ? this._textOrWidth : this._textOrWidth.length; - }; - - VariableWidthTokenWithNoTrivia.prototype.text = function () { - if (typeof this._textOrWidth === 'number') { - this._textOrWidth = this._sourceText.substr(this.start(), this._textOrWidth, this.tokenKind === 11 /* IdentifierName */); - } - - return this._textOrWidth; - }; - - VariableWidthTokenWithNoTrivia.prototype.fullText = function () { - return this._sourceText.substr(this._fullStart, this.fullWidth(), false); - }; - - VariableWidthTokenWithNoTrivia.prototype.value = function () { - if ((this)._value === undefined) { - (this)._value = Syntax.value(this); - } - - return (this)._value; - }; - - VariableWidthTokenWithNoTrivia.prototype.valueText = function () { - if ((this)._valueText === undefined) { - (this)._valueText = Syntax.valueText(this); - } - - return (this)._valueText; - }; - - VariableWidthTokenWithNoTrivia.prototype.hasLeadingTrivia = function () { - return false; - }; - VariableWidthTokenWithNoTrivia.prototype.hasLeadingComment = function () { - return false; - }; - VariableWidthTokenWithNoTrivia.prototype.hasLeadingNewLine = function () { - return false; - }; - VariableWidthTokenWithNoTrivia.prototype.hasLeadingSkippedText = function () { - return false; - }; - VariableWidthTokenWithNoTrivia.prototype.leadingTriviaWidth = function () { - return 0; - }; - VariableWidthTokenWithNoTrivia.prototype.leadingTrivia = function () { - return TypeScript.Syntax.emptyTriviaList; - }; - - VariableWidthTokenWithNoTrivia.prototype.hasTrailingTrivia = function () { - return false; - }; - VariableWidthTokenWithNoTrivia.prototype.hasTrailingComment = function () { - return false; - }; - VariableWidthTokenWithNoTrivia.prototype.hasTrailingNewLine = function () { - return false; - }; - VariableWidthTokenWithNoTrivia.prototype.hasTrailingSkippedText = function () { - return false; - }; - VariableWidthTokenWithNoTrivia.prototype.trailingTriviaWidth = function () { - return 0; - }; - VariableWidthTokenWithNoTrivia.prototype.trailingTrivia = function () { - return TypeScript.Syntax.emptyTriviaList; - }; - - VariableWidthTokenWithNoTrivia.prototype.hasSkippedToken = function () { - return false; - }; - VariableWidthTokenWithNoTrivia.prototype.toJSON = function (key) { - return Syntax.tokenToJSON(this); - }; - VariableWidthTokenWithNoTrivia.prototype.firstToken = function () { - return this; - }; - VariableWidthTokenWithNoTrivia.prototype.lastToken = function () { - return this; - }; - VariableWidthTokenWithNoTrivia.prototype.isTypeScriptSpecific = function () { - return false; - }; - VariableWidthTokenWithNoTrivia.prototype.isIncrementallyUnusable = function () { - return this.fullWidth() === 0 || TypeScript.SyntaxFacts.isAnyDivideOrRegularExpressionToken(this.tokenKind); - }; - VariableWidthTokenWithNoTrivia.prototype.accept = function (visitor) { - return visitor.visitToken(this); - }; - VariableWidthTokenWithNoTrivia.prototype.realize = function () { - return Syntax.realizeToken(this); - }; - VariableWidthTokenWithNoTrivia.prototype.collectTextElements = function (elements) { - collectTokenTextElements(this, elements); - }; - - VariableWidthTokenWithNoTrivia.prototype.findTokenInternal = function (parent, position, fullStart) { - return new TypeScript.PositionedToken(parent, this, fullStart); - }; - - VariableWidthTokenWithNoTrivia.prototype.withLeadingTrivia = function (leadingTrivia) { - return this.realize().withLeadingTrivia(leadingTrivia); - }; - - VariableWidthTokenWithNoTrivia.prototype.withTrailingTrivia = function (trailingTrivia) { - return this.realize().withTrailingTrivia(trailingTrivia); - }; - return VariableWidthTokenWithNoTrivia; - })(); - Syntax.VariableWidthTokenWithNoTrivia = VariableWidthTokenWithNoTrivia; - - var VariableWidthTokenWithLeadingTrivia = (function () { - function VariableWidthTokenWithLeadingTrivia(sourceText, fullStart, kind, leadingTriviaInfo, textOrWidth) { - this._sourceText = sourceText; - this._fullStart = fullStart; - this.tokenKind = kind; - this._leadingTriviaInfo = leadingTriviaInfo; - this._textOrWidth = textOrWidth; - } - VariableWidthTokenWithLeadingTrivia.prototype.clone = function () { - return new VariableWidthTokenWithLeadingTrivia(this._sourceText, this._fullStart, this.tokenKind, this._leadingTriviaInfo, this._textOrWidth); - }; - - VariableWidthTokenWithLeadingTrivia.prototype.isNode = function () { - return false; - }; - VariableWidthTokenWithLeadingTrivia.prototype.isToken = function () { - return true; - }; - VariableWidthTokenWithLeadingTrivia.prototype.isList = function () { - return false; - }; - VariableWidthTokenWithLeadingTrivia.prototype.isSeparatedList = function () { - return false; - }; - - VariableWidthTokenWithLeadingTrivia.prototype.kind = function () { - return this.tokenKind; - }; - - VariableWidthTokenWithLeadingTrivia.prototype.childCount = function () { - return 0; - }; - VariableWidthTokenWithLeadingTrivia.prototype.childAt = function (index) { - throw TypeScript.Errors.argumentOutOfRange('index'); - }; - - VariableWidthTokenWithLeadingTrivia.prototype.fullWidth = function () { - return getTriviaWidth(this._leadingTriviaInfo) + this.width(); - }; - VariableWidthTokenWithLeadingTrivia.prototype.start = function () { - return this._fullStart + getTriviaWidth(this._leadingTriviaInfo); - }; - VariableWidthTokenWithLeadingTrivia.prototype.end = function () { - return this.start() + this.width(); - }; - - VariableWidthTokenWithLeadingTrivia.prototype.width = function () { - return typeof this._textOrWidth === 'number' ? this._textOrWidth : this._textOrWidth.length; - }; - - VariableWidthTokenWithLeadingTrivia.prototype.text = function () { - if (typeof this._textOrWidth === 'number') { - this._textOrWidth = this._sourceText.substr(this.start(), this._textOrWidth, this.tokenKind === 11 /* IdentifierName */); - } - - return this._textOrWidth; - }; - - VariableWidthTokenWithLeadingTrivia.prototype.fullText = function () { - return this._sourceText.substr(this._fullStart, this.fullWidth(), false); - }; - - VariableWidthTokenWithLeadingTrivia.prototype.value = function () { - if ((this)._value === undefined) { - (this)._value = Syntax.value(this); - } - - return (this)._value; - }; - - VariableWidthTokenWithLeadingTrivia.prototype.valueText = function () { - if ((this)._valueText === undefined) { - (this)._valueText = Syntax.valueText(this); - } - - return (this)._valueText; - }; - - VariableWidthTokenWithLeadingTrivia.prototype.hasLeadingTrivia = function () { - return true; - }; - VariableWidthTokenWithLeadingTrivia.prototype.hasLeadingComment = function () { - return hasTriviaComment(this._leadingTriviaInfo); - }; - VariableWidthTokenWithLeadingTrivia.prototype.hasLeadingNewLine = function () { - return hasTriviaNewLine(this._leadingTriviaInfo); - }; - VariableWidthTokenWithLeadingTrivia.prototype.hasLeadingSkippedText = function () { - return false; - }; - VariableWidthTokenWithLeadingTrivia.prototype.leadingTriviaWidth = function () { - return getTriviaWidth(this._leadingTriviaInfo); - }; - VariableWidthTokenWithLeadingTrivia.prototype.leadingTrivia = function () { - return TypeScript.Scanner.scanTrivia(this._sourceText, this._fullStart, getTriviaWidth(this._leadingTriviaInfo), false); - }; - - VariableWidthTokenWithLeadingTrivia.prototype.hasTrailingTrivia = function () { - return false; - }; - VariableWidthTokenWithLeadingTrivia.prototype.hasTrailingComment = function () { - return false; - }; - VariableWidthTokenWithLeadingTrivia.prototype.hasTrailingNewLine = function () { - return false; - }; - VariableWidthTokenWithLeadingTrivia.prototype.hasTrailingSkippedText = function () { - return false; - }; - VariableWidthTokenWithLeadingTrivia.prototype.trailingTriviaWidth = function () { - return 0; - }; - VariableWidthTokenWithLeadingTrivia.prototype.trailingTrivia = function () { - return TypeScript.Syntax.emptyTriviaList; - }; - - VariableWidthTokenWithLeadingTrivia.prototype.hasSkippedToken = function () { - return false; - }; - VariableWidthTokenWithLeadingTrivia.prototype.toJSON = function (key) { - return Syntax.tokenToJSON(this); - }; - VariableWidthTokenWithLeadingTrivia.prototype.firstToken = function () { - return this; - }; - VariableWidthTokenWithLeadingTrivia.prototype.lastToken = function () { - return this; - }; - VariableWidthTokenWithLeadingTrivia.prototype.isTypeScriptSpecific = function () { - return false; - }; - VariableWidthTokenWithLeadingTrivia.prototype.isIncrementallyUnusable = function () { - return this.fullWidth() === 0 || TypeScript.SyntaxFacts.isAnyDivideOrRegularExpressionToken(this.tokenKind); - }; - VariableWidthTokenWithLeadingTrivia.prototype.accept = function (visitor) { - return visitor.visitToken(this); - }; - VariableWidthTokenWithLeadingTrivia.prototype.realize = function () { - return Syntax.realizeToken(this); - }; - VariableWidthTokenWithLeadingTrivia.prototype.collectTextElements = function (elements) { - collectTokenTextElements(this, elements); - }; - - VariableWidthTokenWithLeadingTrivia.prototype.findTokenInternal = function (parent, position, fullStart) { - return new TypeScript.PositionedToken(parent, this, fullStart); - }; - - VariableWidthTokenWithLeadingTrivia.prototype.withLeadingTrivia = function (leadingTrivia) { - return this.realize().withLeadingTrivia(leadingTrivia); - }; - - VariableWidthTokenWithLeadingTrivia.prototype.withTrailingTrivia = function (trailingTrivia) { - return this.realize().withTrailingTrivia(trailingTrivia); - }; - return VariableWidthTokenWithLeadingTrivia; - })(); - Syntax.VariableWidthTokenWithLeadingTrivia = VariableWidthTokenWithLeadingTrivia; - - var VariableWidthTokenWithTrailingTrivia = (function () { - function VariableWidthTokenWithTrailingTrivia(sourceText, fullStart, kind, textOrWidth, trailingTriviaInfo) { - this._sourceText = sourceText; - this._fullStart = fullStart; - this.tokenKind = kind; - this._textOrWidth = textOrWidth; - this._trailingTriviaInfo = trailingTriviaInfo; - } - VariableWidthTokenWithTrailingTrivia.prototype.clone = function () { - return new VariableWidthTokenWithTrailingTrivia(this._sourceText, this._fullStart, this.tokenKind, this._textOrWidth, this._trailingTriviaInfo); - }; - - VariableWidthTokenWithTrailingTrivia.prototype.isNode = function () { - return false; - }; - VariableWidthTokenWithTrailingTrivia.prototype.isToken = function () { - return true; - }; - VariableWidthTokenWithTrailingTrivia.prototype.isList = function () { - return false; - }; - VariableWidthTokenWithTrailingTrivia.prototype.isSeparatedList = function () { - return false; - }; - - VariableWidthTokenWithTrailingTrivia.prototype.kind = function () { - return this.tokenKind; - }; - - VariableWidthTokenWithTrailingTrivia.prototype.childCount = function () { - return 0; - }; - VariableWidthTokenWithTrailingTrivia.prototype.childAt = function (index) { - throw TypeScript.Errors.argumentOutOfRange('index'); - }; - - VariableWidthTokenWithTrailingTrivia.prototype.fullWidth = function () { - return this.width() + getTriviaWidth(this._trailingTriviaInfo); - }; - VariableWidthTokenWithTrailingTrivia.prototype.start = function () { - return this._fullStart; - }; - VariableWidthTokenWithTrailingTrivia.prototype.end = function () { - return this.start() + this.width(); - }; - - VariableWidthTokenWithTrailingTrivia.prototype.width = function () { - return typeof this._textOrWidth === 'number' ? this._textOrWidth : this._textOrWidth.length; - }; - - VariableWidthTokenWithTrailingTrivia.prototype.text = function () { - if (typeof this._textOrWidth === 'number') { - this._textOrWidth = this._sourceText.substr(this.start(), this._textOrWidth, this.tokenKind === 11 /* IdentifierName */); - } - - return this._textOrWidth; - }; - - VariableWidthTokenWithTrailingTrivia.prototype.fullText = function () { - return this._sourceText.substr(this._fullStart, this.fullWidth(), false); - }; - - VariableWidthTokenWithTrailingTrivia.prototype.value = function () { - if ((this)._value === undefined) { - (this)._value = Syntax.value(this); - } - - return (this)._value; - }; - - VariableWidthTokenWithTrailingTrivia.prototype.valueText = function () { - if ((this)._valueText === undefined) { - (this)._valueText = Syntax.valueText(this); - } - - return (this)._valueText; - }; - - VariableWidthTokenWithTrailingTrivia.prototype.hasLeadingTrivia = function () { - return false; - }; - VariableWidthTokenWithTrailingTrivia.prototype.hasLeadingComment = function () { - return false; - }; - VariableWidthTokenWithTrailingTrivia.prototype.hasLeadingNewLine = function () { - return false; - }; - VariableWidthTokenWithTrailingTrivia.prototype.hasLeadingSkippedText = function () { - return false; - }; - VariableWidthTokenWithTrailingTrivia.prototype.leadingTriviaWidth = function () { - return 0; - }; - VariableWidthTokenWithTrailingTrivia.prototype.leadingTrivia = function () { - return TypeScript.Syntax.emptyTriviaList; - }; - - VariableWidthTokenWithTrailingTrivia.prototype.hasTrailingTrivia = function () { - return true; - }; - VariableWidthTokenWithTrailingTrivia.prototype.hasTrailingComment = function () { - return hasTriviaComment(this._trailingTriviaInfo); - }; - VariableWidthTokenWithTrailingTrivia.prototype.hasTrailingNewLine = function () { - return hasTriviaNewLine(this._trailingTriviaInfo); - }; - VariableWidthTokenWithTrailingTrivia.prototype.hasTrailingSkippedText = function () { - return false; - }; - VariableWidthTokenWithTrailingTrivia.prototype.trailingTriviaWidth = function () { - return getTriviaWidth(this._trailingTriviaInfo); - }; - VariableWidthTokenWithTrailingTrivia.prototype.trailingTrivia = function () { - return TypeScript.Scanner.scanTrivia(this._sourceText, this.end(), getTriviaWidth(this._trailingTriviaInfo), true); - }; - - VariableWidthTokenWithTrailingTrivia.prototype.hasSkippedToken = function () { - return false; - }; - VariableWidthTokenWithTrailingTrivia.prototype.toJSON = function (key) { - return Syntax.tokenToJSON(this); - }; - VariableWidthTokenWithTrailingTrivia.prototype.firstToken = function () { - return this; - }; - VariableWidthTokenWithTrailingTrivia.prototype.lastToken = function () { - return this; - }; - VariableWidthTokenWithTrailingTrivia.prototype.isTypeScriptSpecific = function () { - return false; - }; - VariableWidthTokenWithTrailingTrivia.prototype.isIncrementallyUnusable = function () { - return this.fullWidth() === 0 || TypeScript.SyntaxFacts.isAnyDivideOrRegularExpressionToken(this.tokenKind); - }; - VariableWidthTokenWithTrailingTrivia.prototype.accept = function (visitor) { - return visitor.visitToken(this); - }; - VariableWidthTokenWithTrailingTrivia.prototype.realize = function () { - return Syntax.realizeToken(this); - }; - VariableWidthTokenWithTrailingTrivia.prototype.collectTextElements = function (elements) { - collectTokenTextElements(this, elements); - }; - - VariableWidthTokenWithTrailingTrivia.prototype.findTokenInternal = function (parent, position, fullStart) { - return new TypeScript.PositionedToken(parent, this, fullStart); - }; - - VariableWidthTokenWithTrailingTrivia.prototype.withLeadingTrivia = function (leadingTrivia) { - return this.realize().withLeadingTrivia(leadingTrivia); - }; - - VariableWidthTokenWithTrailingTrivia.prototype.withTrailingTrivia = function (trailingTrivia) { - return this.realize().withTrailingTrivia(trailingTrivia); - }; - return VariableWidthTokenWithTrailingTrivia; - })(); - Syntax.VariableWidthTokenWithTrailingTrivia = VariableWidthTokenWithTrailingTrivia; - - var VariableWidthTokenWithLeadingAndTrailingTrivia = (function () { - function VariableWidthTokenWithLeadingAndTrailingTrivia(sourceText, fullStart, kind, leadingTriviaInfo, textOrWidth, trailingTriviaInfo) { - this._sourceText = sourceText; - this._fullStart = fullStart; - this.tokenKind = kind; - this._leadingTriviaInfo = leadingTriviaInfo; - this._textOrWidth = textOrWidth; - this._trailingTriviaInfo = trailingTriviaInfo; - } - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.clone = function () { - return new VariableWidthTokenWithLeadingAndTrailingTrivia(this._sourceText, this._fullStart, this.tokenKind, this._leadingTriviaInfo, this._textOrWidth, this._trailingTriviaInfo); - }; - - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.isNode = function () { - return false; - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.isToken = function () { - return true; - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.isList = function () { - return false; - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.isSeparatedList = function () { - return false; - }; - - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.kind = function () { - return this.tokenKind; - }; - - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.childCount = function () { - return 0; - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.childAt = function (index) { - throw TypeScript.Errors.argumentOutOfRange('index'); - }; - - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.fullWidth = function () { - return getTriviaWidth(this._leadingTriviaInfo) + this.width() + getTriviaWidth(this._trailingTriviaInfo); - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.start = function () { - return this._fullStart + getTriviaWidth(this._leadingTriviaInfo); - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.end = function () { - return this.start() + this.width(); - }; - - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.width = function () { - return typeof this._textOrWidth === 'number' ? this._textOrWidth : this._textOrWidth.length; - }; - - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.text = function () { - if (typeof this._textOrWidth === 'number') { - this._textOrWidth = this._sourceText.substr(this.start(), this._textOrWidth, this.tokenKind === 11 /* IdentifierName */); - } - - return this._textOrWidth; - }; - - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.fullText = function () { - return this._sourceText.substr(this._fullStart, this.fullWidth(), false); - }; - - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.value = function () { - if ((this)._value === undefined) { - (this)._value = Syntax.value(this); - } - - return (this)._value; - }; - - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.valueText = function () { - if ((this)._valueText === undefined) { - (this)._valueText = Syntax.valueText(this); - } - - return (this)._valueText; - }; - - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.hasLeadingTrivia = function () { - return true; - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.hasLeadingComment = function () { - return hasTriviaComment(this._leadingTriviaInfo); - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.hasLeadingNewLine = function () { - return hasTriviaNewLine(this._leadingTriviaInfo); - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.hasLeadingSkippedText = function () { - return false; - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.leadingTriviaWidth = function () { - return getTriviaWidth(this._leadingTriviaInfo); - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.leadingTrivia = function () { - return TypeScript.Scanner.scanTrivia(this._sourceText, this._fullStart, getTriviaWidth(this._leadingTriviaInfo), false); - }; - - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.hasTrailingTrivia = function () { - return true; - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.hasTrailingComment = function () { - return hasTriviaComment(this._trailingTriviaInfo); - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.hasTrailingNewLine = function () { - return hasTriviaNewLine(this._trailingTriviaInfo); - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.hasTrailingSkippedText = function () { - return false; - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.trailingTriviaWidth = function () { - return getTriviaWidth(this._trailingTriviaInfo); - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.trailingTrivia = function () { - return TypeScript.Scanner.scanTrivia(this._sourceText, this.end(), getTriviaWidth(this._trailingTriviaInfo), true); - }; - - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.hasSkippedToken = function () { - return false; - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.toJSON = function (key) { - return Syntax.tokenToJSON(this); - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.firstToken = function () { - return this; - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.lastToken = function () { - return this; - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.isTypeScriptSpecific = function () { - return false; - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.isIncrementallyUnusable = function () { - return this.fullWidth() === 0 || TypeScript.SyntaxFacts.isAnyDivideOrRegularExpressionToken(this.tokenKind); - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.accept = function (visitor) { - return visitor.visitToken(this); - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.realize = function () { - return Syntax.realizeToken(this); - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.collectTextElements = function (elements) { - collectTokenTextElements(this, elements); - }; - - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.findTokenInternal = function (parent, position, fullStart) { - return new TypeScript.PositionedToken(parent, this, fullStart); - }; - - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.withLeadingTrivia = function (leadingTrivia) { - return this.realize().withLeadingTrivia(leadingTrivia); - }; - - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.withTrailingTrivia = function (trailingTrivia) { - return this.realize().withTrailingTrivia(trailingTrivia); - }; - return VariableWidthTokenWithLeadingAndTrailingTrivia; - })(); - Syntax.VariableWidthTokenWithLeadingAndTrailingTrivia = VariableWidthTokenWithLeadingAndTrailingTrivia; - - var FixedWidthTokenWithNoTrivia = (function () { - function FixedWidthTokenWithNoTrivia(kind) { - this.tokenKind = kind; - } - FixedWidthTokenWithNoTrivia.prototype.clone = function () { - return new FixedWidthTokenWithNoTrivia(this.tokenKind); - }; - - FixedWidthTokenWithNoTrivia.prototype.isNode = function () { - return false; - }; - FixedWidthTokenWithNoTrivia.prototype.isToken = function () { - return true; - }; - FixedWidthTokenWithNoTrivia.prototype.isList = function () { - return false; - }; - FixedWidthTokenWithNoTrivia.prototype.isSeparatedList = function () { - return false; - }; - - FixedWidthTokenWithNoTrivia.prototype.kind = function () { - return this.tokenKind; - }; - - FixedWidthTokenWithNoTrivia.prototype.childCount = function () { - return 0; - }; - FixedWidthTokenWithNoTrivia.prototype.childAt = function (index) { - throw TypeScript.Errors.argumentOutOfRange('index'); - }; - - FixedWidthTokenWithNoTrivia.prototype.fullWidth = function () { - return this.width(); - }; - FixedWidthTokenWithNoTrivia.prototype.width = function () { - return this.text().length; - }; - FixedWidthTokenWithNoTrivia.prototype.text = function () { - return TypeScript.SyntaxFacts.getText(this.tokenKind); - }; - FixedWidthTokenWithNoTrivia.prototype.fullText = function () { - return this.text(); - }; - - FixedWidthTokenWithNoTrivia.prototype.value = function () { - return Syntax.value(this); - }; - FixedWidthTokenWithNoTrivia.prototype.valueText = function () { - return Syntax.valueText(this); - }; - FixedWidthTokenWithNoTrivia.prototype.hasLeadingTrivia = function () { - return false; - }; - FixedWidthTokenWithNoTrivia.prototype.hasLeadingComment = function () { - return false; - }; - FixedWidthTokenWithNoTrivia.prototype.hasLeadingNewLine = function () { - return false; - }; - FixedWidthTokenWithNoTrivia.prototype.hasLeadingSkippedText = function () { - return false; - }; - FixedWidthTokenWithNoTrivia.prototype.leadingTriviaWidth = function () { - return 0; - }; - FixedWidthTokenWithNoTrivia.prototype.leadingTrivia = function () { - return TypeScript.Syntax.emptyTriviaList; - }; - - FixedWidthTokenWithNoTrivia.prototype.hasTrailingTrivia = function () { - return false; - }; - FixedWidthTokenWithNoTrivia.prototype.hasTrailingComment = function () { - return false; - }; - FixedWidthTokenWithNoTrivia.prototype.hasTrailingNewLine = function () { - return false; - }; - FixedWidthTokenWithNoTrivia.prototype.hasTrailingSkippedText = function () { - return false; - }; - FixedWidthTokenWithNoTrivia.prototype.trailingTriviaWidth = function () { - return 0; - }; - FixedWidthTokenWithNoTrivia.prototype.trailingTrivia = function () { - return TypeScript.Syntax.emptyTriviaList; - }; - - FixedWidthTokenWithNoTrivia.prototype.hasSkippedToken = function () { - return false; - }; - FixedWidthTokenWithNoTrivia.prototype.toJSON = function (key) { - return Syntax.tokenToJSON(this); - }; - FixedWidthTokenWithNoTrivia.prototype.firstToken = function () { - return this; - }; - FixedWidthTokenWithNoTrivia.prototype.lastToken = function () { - return this; - }; - FixedWidthTokenWithNoTrivia.prototype.isTypeScriptSpecific = function () { - return false; - }; - FixedWidthTokenWithNoTrivia.prototype.isIncrementallyUnusable = function () { - return this.fullWidth() === 0 || TypeScript.SyntaxFacts.isAnyDivideOrRegularExpressionToken(this.tokenKind); - }; - FixedWidthTokenWithNoTrivia.prototype.accept = function (visitor) { - return visitor.visitToken(this); - }; - FixedWidthTokenWithNoTrivia.prototype.realize = function () { - return Syntax.realizeToken(this); - }; - FixedWidthTokenWithNoTrivia.prototype.collectTextElements = function (elements) { - collectTokenTextElements(this, elements); - }; - - FixedWidthTokenWithNoTrivia.prototype.findTokenInternal = function (parent, position, fullStart) { - return new TypeScript.PositionedToken(parent, this, fullStart); - }; - - FixedWidthTokenWithNoTrivia.prototype.withLeadingTrivia = function (leadingTrivia) { - return this.realize().withLeadingTrivia(leadingTrivia); - }; - - FixedWidthTokenWithNoTrivia.prototype.withTrailingTrivia = function (trailingTrivia) { - return this.realize().withTrailingTrivia(trailingTrivia); - }; - return FixedWidthTokenWithNoTrivia; - })(); - Syntax.FixedWidthTokenWithNoTrivia = FixedWidthTokenWithNoTrivia; - - var FixedWidthTokenWithLeadingTrivia = (function () { - function FixedWidthTokenWithLeadingTrivia(sourceText, fullStart, kind, leadingTriviaInfo) { - this._sourceText = sourceText; - this._fullStart = fullStart; - this.tokenKind = kind; - this._leadingTriviaInfo = leadingTriviaInfo; - } - FixedWidthTokenWithLeadingTrivia.prototype.clone = function () { - return new FixedWidthTokenWithLeadingTrivia(this._sourceText, this._fullStart, this.tokenKind, this._leadingTriviaInfo); - }; - - FixedWidthTokenWithLeadingTrivia.prototype.isNode = function () { - return false; - }; - FixedWidthTokenWithLeadingTrivia.prototype.isToken = function () { - return true; - }; - FixedWidthTokenWithLeadingTrivia.prototype.isList = function () { - return false; - }; - FixedWidthTokenWithLeadingTrivia.prototype.isSeparatedList = function () { - return false; - }; - - FixedWidthTokenWithLeadingTrivia.prototype.kind = function () { - return this.tokenKind; - }; - - FixedWidthTokenWithLeadingTrivia.prototype.childCount = function () { - return 0; - }; - FixedWidthTokenWithLeadingTrivia.prototype.childAt = function (index) { - throw TypeScript.Errors.argumentOutOfRange('index'); - }; - - FixedWidthTokenWithLeadingTrivia.prototype.fullWidth = function () { - return getTriviaWidth(this._leadingTriviaInfo) + this.width(); - }; - FixedWidthTokenWithLeadingTrivia.prototype.start = function () { - return this._fullStart + getTriviaWidth(this._leadingTriviaInfo); - }; - FixedWidthTokenWithLeadingTrivia.prototype.end = function () { - return this.start() + this.width(); - }; - - FixedWidthTokenWithLeadingTrivia.prototype.width = function () { - return this.text().length; - }; - FixedWidthTokenWithLeadingTrivia.prototype.text = function () { - return TypeScript.SyntaxFacts.getText(this.tokenKind); - }; - FixedWidthTokenWithLeadingTrivia.prototype.fullText = function () { - return this._sourceText.substr(this._fullStart, this.fullWidth(), false); - }; - - FixedWidthTokenWithLeadingTrivia.prototype.value = function () { - return Syntax.value(this); - }; - FixedWidthTokenWithLeadingTrivia.prototype.valueText = function () { - return Syntax.valueText(this); - }; - FixedWidthTokenWithLeadingTrivia.prototype.hasLeadingTrivia = function () { - return true; - }; - FixedWidthTokenWithLeadingTrivia.prototype.hasLeadingComment = function () { - return hasTriviaComment(this._leadingTriviaInfo); - }; - FixedWidthTokenWithLeadingTrivia.prototype.hasLeadingNewLine = function () { - return hasTriviaNewLine(this._leadingTriviaInfo); - }; - FixedWidthTokenWithLeadingTrivia.prototype.hasLeadingSkippedText = function () { - return false; - }; - FixedWidthTokenWithLeadingTrivia.prototype.leadingTriviaWidth = function () { - return getTriviaWidth(this._leadingTriviaInfo); - }; - FixedWidthTokenWithLeadingTrivia.prototype.leadingTrivia = function () { - return TypeScript.Scanner.scanTrivia(this._sourceText, this._fullStart, getTriviaWidth(this._leadingTriviaInfo), false); - }; - - FixedWidthTokenWithLeadingTrivia.prototype.hasTrailingTrivia = function () { - return false; - }; - FixedWidthTokenWithLeadingTrivia.prototype.hasTrailingComment = function () { - return false; - }; - FixedWidthTokenWithLeadingTrivia.prototype.hasTrailingNewLine = function () { - return false; - }; - FixedWidthTokenWithLeadingTrivia.prototype.hasTrailingSkippedText = function () { - return false; - }; - FixedWidthTokenWithLeadingTrivia.prototype.trailingTriviaWidth = function () { - return 0; - }; - FixedWidthTokenWithLeadingTrivia.prototype.trailingTrivia = function () { - return TypeScript.Syntax.emptyTriviaList; - }; - - FixedWidthTokenWithLeadingTrivia.prototype.hasSkippedToken = function () { - return false; - }; - FixedWidthTokenWithLeadingTrivia.prototype.toJSON = function (key) { - return Syntax.tokenToJSON(this); - }; - FixedWidthTokenWithLeadingTrivia.prototype.firstToken = function () { - return this; - }; - FixedWidthTokenWithLeadingTrivia.prototype.lastToken = function () { - return this; - }; - FixedWidthTokenWithLeadingTrivia.prototype.isTypeScriptSpecific = function () { - return false; - }; - FixedWidthTokenWithLeadingTrivia.prototype.isIncrementallyUnusable = function () { - return this.fullWidth() === 0 || TypeScript.SyntaxFacts.isAnyDivideOrRegularExpressionToken(this.tokenKind); - }; - FixedWidthTokenWithLeadingTrivia.prototype.accept = function (visitor) { - return visitor.visitToken(this); - }; - FixedWidthTokenWithLeadingTrivia.prototype.realize = function () { - return Syntax.realizeToken(this); - }; - FixedWidthTokenWithLeadingTrivia.prototype.collectTextElements = function (elements) { - collectTokenTextElements(this, elements); - }; - - FixedWidthTokenWithLeadingTrivia.prototype.findTokenInternal = function (parent, position, fullStart) { - return new TypeScript.PositionedToken(parent, this, fullStart); - }; - - FixedWidthTokenWithLeadingTrivia.prototype.withLeadingTrivia = function (leadingTrivia) { - return this.realize().withLeadingTrivia(leadingTrivia); - }; - - FixedWidthTokenWithLeadingTrivia.prototype.withTrailingTrivia = function (trailingTrivia) { - return this.realize().withTrailingTrivia(trailingTrivia); - }; - return FixedWidthTokenWithLeadingTrivia; - })(); - Syntax.FixedWidthTokenWithLeadingTrivia = FixedWidthTokenWithLeadingTrivia; - - var FixedWidthTokenWithTrailingTrivia = (function () { - function FixedWidthTokenWithTrailingTrivia(sourceText, fullStart, kind, trailingTriviaInfo) { - this._sourceText = sourceText; - this._fullStart = fullStart; - this.tokenKind = kind; - this._trailingTriviaInfo = trailingTriviaInfo; - } - FixedWidthTokenWithTrailingTrivia.prototype.clone = function () { - return new FixedWidthTokenWithTrailingTrivia(this._sourceText, this._fullStart, this.tokenKind, this._trailingTriviaInfo); - }; - - FixedWidthTokenWithTrailingTrivia.prototype.isNode = function () { - return false; - }; - FixedWidthTokenWithTrailingTrivia.prototype.isToken = function () { - return true; - }; - FixedWidthTokenWithTrailingTrivia.prototype.isList = function () { - return false; - }; - FixedWidthTokenWithTrailingTrivia.prototype.isSeparatedList = function () { - return false; - }; - - FixedWidthTokenWithTrailingTrivia.prototype.kind = function () { - return this.tokenKind; - }; - - FixedWidthTokenWithTrailingTrivia.prototype.childCount = function () { - return 0; - }; - FixedWidthTokenWithTrailingTrivia.prototype.childAt = function (index) { - throw TypeScript.Errors.argumentOutOfRange('index'); - }; - - FixedWidthTokenWithTrailingTrivia.prototype.fullWidth = function () { - return this.width() + getTriviaWidth(this._trailingTriviaInfo); - }; - FixedWidthTokenWithTrailingTrivia.prototype.start = function () { - return this._fullStart; - }; - FixedWidthTokenWithTrailingTrivia.prototype.end = function () { - return this.start() + this.width(); - }; - - FixedWidthTokenWithTrailingTrivia.prototype.width = function () { - return this.text().length; - }; - FixedWidthTokenWithTrailingTrivia.prototype.text = function () { - return TypeScript.SyntaxFacts.getText(this.tokenKind); - }; - FixedWidthTokenWithTrailingTrivia.prototype.fullText = function () { - return this._sourceText.substr(this._fullStart, this.fullWidth(), false); - }; - - FixedWidthTokenWithTrailingTrivia.prototype.value = function () { - return Syntax.value(this); - }; - FixedWidthTokenWithTrailingTrivia.prototype.valueText = function () { - return Syntax.valueText(this); - }; - FixedWidthTokenWithTrailingTrivia.prototype.hasLeadingTrivia = function () { - return false; - }; - FixedWidthTokenWithTrailingTrivia.prototype.hasLeadingComment = function () { - return false; - }; - FixedWidthTokenWithTrailingTrivia.prototype.hasLeadingNewLine = function () { - return false; - }; - FixedWidthTokenWithTrailingTrivia.prototype.hasLeadingSkippedText = function () { - return false; - }; - FixedWidthTokenWithTrailingTrivia.prototype.leadingTriviaWidth = function () { - return 0; - }; - FixedWidthTokenWithTrailingTrivia.prototype.leadingTrivia = function () { - return TypeScript.Syntax.emptyTriviaList; - }; - - FixedWidthTokenWithTrailingTrivia.prototype.hasTrailingTrivia = function () { - return true; - }; - FixedWidthTokenWithTrailingTrivia.prototype.hasTrailingComment = function () { - return hasTriviaComment(this._trailingTriviaInfo); - }; - FixedWidthTokenWithTrailingTrivia.prototype.hasTrailingNewLine = function () { - return hasTriviaNewLine(this._trailingTriviaInfo); - }; - FixedWidthTokenWithTrailingTrivia.prototype.hasTrailingSkippedText = function () { - return false; - }; - FixedWidthTokenWithTrailingTrivia.prototype.trailingTriviaWidth = function () { - return getTriviaWidth(this._trailingTriviaInfo); - }; - FixedWidthTokenWithTrailingTrivia.prototype.trailingTrivia = function () { - return TypeScript.Scanner.scanTrivia(this._sourceText, this.end(), getTriviaWidth(this._trailingTriviaInfo), true); - }; - - FixedWidthTokenWithTrailingTrivia.prototype.hasSkippedToken = function () { - return false; - }; - FixedWidthTokenWithTrailingTrivia.prototype.toJSON = function (key) { - return Syntax.tokenToJSON(this); - }; - FixedWidthTokenWithTrailingTrivia.prototype.firstToken = function () { - return this; - }; - FixedWidthTokenWithTrailingTrivia.prototype.lastToken = function () { - return this; - }; - FixedWidthTokenWithTrailingTrivia.prototype.isTypeScriptSpecific = function () { - return false; - }; - FixedWidthTokenWithTrailingTrivia.prototype.isIncrementallyUnusable = function () { - return this.fullWidth() === 0 || TypeScript.SyntaxFacts.isAnyDivideOrRegularExpressionToken(this.tokenKind); - }; - FixedWidthTokenWithTrailingTrivia.prototype.accept = function (visitor) { - return visitor.visitToken(this); - }; - FixedWidthTokenWithTrailingTrivia.prototype.realize = function () { - return Syntax.realizeToken(this); - }; - FixedWidthTokenWithTrailingTrivia.prototype.collectTextElements = function (elements) { - collectTokenTextElements(this, elements); - }; - - FixedWidthTokenWithTrailingTrivia.prototype.findTokenInternal = function (parent, position, fullStart) { - return new TypeScript.PositionedToken(parent, this, fullStart); - }; - - FixedWidthTokenWithTrailingTrivia.prototype.withLeadingTrivia = function (leadingTrivia) { - return this.realize().withLeadingTrivia(leadingTrivia); - }; - - FixedWidthTokenWithTrailingTrivia.prototype.withTrailingTrivia = function (trailingTrivia) { - return this.realize().withTrailingTrivia(trailingTrivia); - }; - return FixedWidthTokenWithTrailingTrivia; - })(); - Syntax.FixedWidthTokenWithTrailingTrivia = FixedWidthTokenWithTrailingTrivia; - - var FixedWidthTokenWithLeadingAndTrailingTrivia = (function () { - function FixedWidthTokenWithLeadingAndTrailingTrivia(sourceText, fullStart, kind, leadingTriviaInfo, trailingTriviaInfo) { - this._sourceText = sourceText; - this._fullStart = fullStart; - this.tokenKind = kind; - this._leadingTriviaInfo = leadingTriviaInfo; - this._trailingTriviaInfo = trailingTriviaInfo; - } - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.clone = function () { - return new FixedWidthTokenWithLeadingAndTrailingTrivia(this._sourceText, this._fullStart, this.tokenKind, this._leadingTriviaInfo, this._trailingTriviaInfo); - }; - - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.isNode = function () { - return false; - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.isToken = function () { - return true; - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.isList = function () { - return false; - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.isSeparatedList = function () { - return false; - }; - - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.kind = function () { - return this.tokenKind; - }; - - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.childCount = function () { - return 0; - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.childAt = function (index) { - throw TypeScript.Errors.argumentOutOfRange('index'); - }; - - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.fullWidth = function () { - return getTriviaWidth(this._leadingTriviaInfo) + this.width() + getTriviaWidth(this._trailingTriviaInfo); - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.start = function () { - return this._fullStart + getTriviaWidth(this._leadingTriviaInfo); - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.end = function () { - return this.start() + this.width(); - }; - - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.width = function () { - return this.text().length; - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.text = function () { - return TypeScript.SyntaxFacts.getText(this.tokenKind); - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.fullText = function () { - return this._sourceText.substr(this._fullStart, this.fullWidth(), false); - }; - - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.value = function () { - return Syntax.value(this); - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.valueText = function () { - return Syntax.valueText(this); - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.hasLeadingTrivia = function () { - return true; - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.hasLeadingComment = function () { - return hasTriviaComment(this._leadingTriviaInfo); - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.hasLeadingNewLine = function () { - return hasTriviaNewLine(this._leadingTriviaInfo); - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.hasLeadingSkippedText = function () { - return false; - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.leadingTriviaWidth = function () { - return getTriviaWidth(this._leadingTriviaInfo); - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.leadingTrivia = function () { - return TypeScript.Scanner.scanTrivia(this._sourceText, this._fullStart, getTriviaWidth(this._leadingTriviaInfo), false); - }; - - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.hasTrailingTrivia = function () { - return true; - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.hasTrailingComment = function () { - return hasTriviaComment(this._trailingTriviaInfo); - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.hasTrailingNewLine = function () { - return hasTriviaNewLine(this._trailingTriviaInfo); - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.hasTrailingSkippedText = function () { - return false; - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.trailingTriviaWidth = function () { - return getTriviaWidth(this._trailingTriviaInfo); - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.trailingTrivia = function () { - return TypeScript.Scanner.scanTrivia(this._sourceText, this.end(), getTriviaWidth(this._trailingTriviaInfo), true); - }; - - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.hasSkippedToken = function () { - return false; - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.toJSON = function (key) { - return Syntax.tokenToJSON(this); - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.firstToken = function () { - return this; - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.lastToken = function () { - return this; - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.isTypeScriptSpecific = function () { - return false; - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.isIncrementallyUnusable = function () { - return this.fullWidth() === 0 || TypeScript.SyntaxFacts.isAnyDivideOrRegularExpressionToken(this.tokenKind); - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.accept = function (visitor) { - return visitor.visitToken(this); - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.realize = function () { - return Syntax.realizeToken(this); - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.collectTextElements = function (elements) { - collectTokenTextElements(this, elements); - }; - - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.findTokenInternal = function (parent, position, fullStart) { - return new TypeScript.PositionedToken(parent, this, fullStart); - }; - - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.withLeadingTrivia = function (leadingTrivia) { - return this.realize().withLeadingTrivia(leadingTrivia); - }; - - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.withTrailingTrivia = function (trailingTrivia) { - return this.realize().withTrailingTrivia(trailingTrivia); - }; - return FixedWidthTokenWithLeadingAndTrailingTrivia; - })(); - Syntax.FixedWidthTokenWithLeadingAndTrailingTrivia = FixedWidthTokenWithLeadingAndTrailingTrivia; - - function collectTokenTextElements(token, elements) { - token.leadingTrivia().collectTextElements(elements); - elements.push(token.text()); - token.trailingTrivia().collectTextElements(elements); - } - - function fixedWidthToken(sourceText, fullStart, kind, leadingTriviaInfo, trailingTriviaInfo) { - if (leadingTriviaInfo === 0) { - if (trailingTriviaInfo === 0) { - return new FixedWidthTokenWithNoTrivia(kind); - } else { - return new FixedWidthTokenWithTrailingTrivia(sourceText, fullStart, kind, trailingTriviaInfo); - } - } else if (trailingTriviaInfo === 0) { - return new FixedWidthTokenWithLeadingTrivia(sourceText, fullStart, kind, leadingTriviaInfo); - } else { - return new FixedWidthTokenWithLeadingAndTrailingTrivia(sourceText, fullStart, kind, leadingTriviaInfo, trailingTriviaInfo); - } - } - Syntax.fixedWidthToken = fixedWidthToken; - - function variableWidthToken(sourceText, fullStart, kind, leadingTriviaInfo, width, trailingTriviaInfo) { - if (leadingTriviaInfo === 0) { - if (trailingTriviaInfo === 0) { - return new VariableWidthTokenWithNoTrivia(sourceText, fullStart, kind, width); - } else { - return new VariableWidthTokenWithTrailingTrivia(sourceText, fullStart, kind, width, trailingTriviaInfo); - } - } else if (trailingTriviaInfo === 0) { - return new VariableWidthTokenWithLeadingTrivia(sourceText, fullStart, kind, leadingTriviaInfo, width); - } else { - return new VariableWidthTokenWithLeadingAndTrailingTrivia(sourceText, fullStart, kind, leadingTriviaInfo, width, trailingTriviaInfo); - } - } - Syntax.variableWidthToken = variableWidthToken; - - function getTriviaWidth(value) { - return value >>> 2 /* TriviaFullWidthShift */; - } - - function hasTriviaComment(value) { - return (value & 2 /* TriviaCommentMask */) !== 0; - } - - function hasTriviaNewLine(value) { - return (value & 1 /* TriviaNewLineMask */) !== 0; - } - })(TypeScript.Syntax || (TypeScript.Syntax = {})); - var Syntax = TypeScript.Syntax; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (Syntax) { - function realizeToken(token) { - return new RealizedToken(token.tokenKind, token.leadingTrivia(), token.text(), token.value(), token.valueText(), token.trailingTrivia()); - } - Syntax.realizeToken = realizeToken; - - function convertToIdentifierName(token) { - TypeScript.Debug.assert(TypeScript.SyntaxFacts.isAnyKeyword(token.tokenKind)); - return new RealizedToken(11 /* IdentifierName */, token.leadingTrivia(), token.text(), token.text(), token.text(), token.trailingTrivia()); - } - Syntax.convertToIdentifierName = convertToIdentifierName; - - function tokenToJSON(token) { - var result = {}; - - for (var name in TypeScript.SyntaxKind) { - if (TypeScript.SyntaxKind[name] === token.kind()) { - result.kind = name; - break; - } - } - - result.width = token.width(); - if (token.fullWidth() !== token.width()) { - result.fullWidth = token.fullWidth(); - } - - result.text = token.text(); - - var value = token.value(); - if (value !== null) { - result.value = value; - result.valueText = token.valueText(); - } - - if (token.hasLeadingTrivia()) { - result.hasLeadingTrivia = true; - } - - if (token.hasLeadingComment()) { - result.hasLeadingComment = true; - } - - if (token.hasLeadingNewLine()) { - result.hasLeadingNewLine = true; - } - - if (token.hasLeadingSkippedText()) { - result.hasLeadingSkippedText = true; - } - - if (token.hasTrailingTrivia()) { - result.hasTrailingTrivia = true; - } - - if (token.hasTrailingComment()) { - result.hasTrailingComment = true; - } - - if (token.hasTrailingNewLine()) { - result.hasTrailingNewLine = true; - } - - if (token.hasTrailingSkippedText()) { - result.hasTrailingSkippedText = true; - } - - var trivia = token.leadingTrivia(); - if (trivia.count() > 0) { - result.leadingTrivia = trivia; - } - - trivia = token.trailingTrivia(); - if (trivia.count() > 0) { - result.trailingTrivia = trivia; - } - - return result; - } - Syntax.tokenToJSON = tokenToJSON; - - function value(token) { - return value1(token.tokenKind, token.text()); - } - Syntax.value = value; - - function hexValue(text, start, length) { - var intChar = 0; - for (var i = 0; i < length; i++) { - var ch2 = text.charCodeAt(start + i); - if (!TypeScript.CharacterInfo.isHexDigit(ch2)) { - break; - } - - intChar = (intChar << 4) + TypeScript.CharacterInfo.hexValue(ch2); - } - - return intChar; - } - - var characterArray = []; - - function convertEscapes(text) { - characterArray.length = 0; - var result = ""; - - for (var i = 0, n = text.length; i < n; i++) { - var ch = text.charCodeAt(i); - - if (ch === 92 /* backslash */) { - i++; - if (i < n) { - ch = text.charCodeAt(i); - switch (ch) { - case 48 /* _0 */: - characterArray.push(0 /* nullCharacter */); - continue; - - case 98 /* b */: - characterArray.push(8 /* backspace */); - continue; - - case 102 /* f */: - characterArray.push(12 /* formFeed */); - continue; - - case 110 /* n */: - characterArray.push(10 /* lineFeed */); - continue; - - case 114 /* r */: - characterArray.push(13 /* carriageReturn */); - continue; - - case 116 /* t */: - characterArray.push(9 /* tab */); - continue; - - case 118 /* v */: - characterArray.push(11 /* verticalTab */); - continue; - - case 120 /* x */: - characterArray.push(hexValue(text, i + 1, 2)); - i += 2; - continue; - - case 117 /* u */: - characterArray.push(hexValue(text, i + 1, 4)); - i += 4; - continue; - - default: - } - } - } - - characterArray.push(ch); - - if (i && !(i % 1024)) { - result = result.concat(String.fromCharCode.apply(null, characterArray)); - characterArray.length = 0; - } - } - - if (characterArray.length) { - result = result.concat(String.fromCharCode.apply(null, characterArray)); - } - - return result; - } - - function massageEscapes(text) { - return text.indexOf("\\") >= 0 ? convertEscapes(text) : text; - } - - function value1(kind, text) { - if (kind === 11 /* IdentifierName */) { - return massageEscapes(text); - } - - switch (kind) { - case 37 /* TrueKeyword */: - return true; - case 24 /* FalseKeyword */: - return false; - case 32 /* NullKeyword */: - return null; - } - - if (TypeScript.SyntaxFacts.isAnyKeyword(kind) || TypeScript.SyntaxFacts.isAnyPunctuation(kind)) { - return TypeScript.SyntaxFacts.getText(kind); - } - - if (kind === 13 /* NumericLiteral */) { - return parseFloat(text); - } else if (kind === 14 /* StringLiteral */) { - if (text.length > 1 && text.charCodeAt(text.length - 1) === text.charCodeAt(0)) { - return massageEscapes(text.substr(1, text.length - 2)); - } else { - return massageEscapes(text.substr(1)); - } - } else if (kind === 12 /* RegularExpressionLiteral */) { - 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 null; - } - } else if (kind === 10 /* EndOfFileToken */ || kind === 9 /* ErrorToken */) { - return null; - } else { - throw TypeScript.Errors.invalidOperation(); - } - } - - function valueText1(kind, text) { - var value = value1(kind, text); - return value === null ? "" : value.toString(); - } - - function valueText(token) { - var value = token.value(); - return value === null ? "" : value.toString(); - } - Syntax.valueText = valueText; - - var EmptyToken = (function () { - function EmptyToken(kind) { - this.tokenKind = kind; - } - EmptyToken.prototype.clone = function () { - return new EmptyToken(this.tokenKind); - }; - - EmptyToken.prototype.kind = function () { - return this.tokenKind; - }; - - EmptyToken.prototype.isToken = function () { - return true; - }; - EmptyToken.prototype.isNode = function () { - return false; - }; - EmptyToken.prototype.isList = function () { - return false; - }; - EmptyToken.prototype.isSeparatedList = function () { - return false; - }; - - EmptyToken.prototype.childCount = function () { - return 0; - }; - - EmptyToken.prototype.childAt = function (index) { - throw TypeScript.Errors.argumentOutOfRange("index"); - }; - - EmptyToken.prototype.toJSON = function (key) { - return tokenToJSON(this); - }; - EmptyToken.prototype.accept = function (visitor) { - return visitor.visitToken(this); - }; - - EmptyToken.prototype.findTokenInternal = function (parent, position, fullStart) { - return new TypeScript.PositionedToken(parent, this, fullStart); - }; - - EmptyToken.prototype.firstToken = function () { - return this; - }; - EmptyToken.prototype.lastToken = function () { - return this; - }; - EmptyToken.prototype.isTypeScriptSpecific = function () { - return false; - }; - - EmptyToken.prototype.isIncrementallyUnusable = function () { - return true; - }; - - EmptyToken.prototype.fullWidth = function () { - return 0; - }; - EmptyToken.prototype.width = function () { - return 0; - }; - EmptyToken.prototype.text = function () { - return ""; - }; - EmptyToken.prototype.fullText = function () { - return ""; - }; - EmptyToken.prototype.value = function () { - return null; - }; - EmptyToken.prototype.valueText = function () { - return ""; - }; - - EmptyToken.prototype.hasLeadingTrivia = function () { - return false; - }; - EmptyToken.prototype.hasLeadingComment = function () { - return false; - }; - EmptyToken.prototype.hasLeadingNewLine = function () { - return false; - }; - EmptyToken.prototype.hasLeadingSkippedText = function () { - return false; - }; - EmptyToken.prototype.leadingTriviaWidth = function () { - return 0; - }; - EmptyToken.prototype.hasTrailingTrivia = function () { - return false; - }; - EmptyToken.prototype.hasTrailingComment = function () { - return false; - }; - EmptyToken.prototype.hasTrailingNewLine = function () { - return false; - }; - EmptyToken.prototype.hasTrailingSkippedText = function () { - return false; - }; - EmptyToken.prototype.hasSkippedToken = function () { - return false; - }; - - EmptyToken.prototype.trailingTriviaWidth = function () { - return 0; - }; - EmptyToken.prototype.leadingTrivia = function () { - return TypeScript.Syntax.emptyTriviaList; - }; - EmptyToken.prototype.trailingTrivia = function () { - return TypeScript.Syntax.emptyTriviaList; - }; - EmptyToken.prototype.realize = function () { - return realizeToken(this); - }; - EmptyToken.prototype.collectTextElements = function (elements) { - }; - - EmptyToken.prototype.withLeadingTrivia = function (leadingTrivia) { - return this.realize().withLeadingTrivia(leadingTrivia); - }; - - EmptyToken.prototype.withTrailingTrivia = function (trailingTrivia) { - return this.realize().withTrailingTrivia(trailingTrivia); - }; - return EmptyToken; - })(); - - function emptyToken(kind) { - return new EmptyToken(kind); - } - Syntax.emptyToken = emptyToken; - - var RealizedToken = (function () { - function RealizedToken(tokenKind, leadingTrivia, text, value, valueText, trailingTrivia) { - this.tokenKind = tokenKind; - this._leadingTrivia = leadingTrivia; - this._text = text; - this._value = value; - this._valueText = valueText; - this._trailingTrivia = trailingTrivia; - } - RealizedToken.prototype.clone = function () { - return new RealizedToken(this.tokenKind, this._leadingTrivia, this._text, this._value, this._valueText, this._trailingTrivia); - }; - - RealizedToken.prototype.kind = function () { - return this.tokenKind; - }; - RealizedToken.prototype.toJSON = function (key) { - return tokenToJSON(this); - }; - RealizedToken.prototype.firstToken = function () { - return this; - }; - RealizedToken.prototype.lastToken = function () { - return this; - }; - RealizedToken.prototype.isTypeScriptSpecific = function () { - return false; - }; - - RealizedToken.prototype.isIncrementallyUnusable = function () { - return true; - }; - - RealizedToken.prototype.accept = function (visitor) { - return visitor.visitToken(this); - }; - - RealizedToken.prototype.childCount = function () { - return 0; - }; - - RealizedToken.prototype.childAt = function (index) { - throw TypeScript.Errors.argumentOutOfRange("index"); - }; - - RealizedToken.prototype.isToken = function () { - return true; - }; - RealizedToken.prototype.isNode = function () { - return false; - }; - RealizedToken.prototype.isList = function () { - return false; - }; - RealizedToken.prototype.isSeparatedList = function () { - return false; - }; - RealizedToken.prototype.isTrivia = function () { - return false; - }; - RealizedToken.prototype.isTriviaList = function () { - return false; - }; - - RealizedToken.prototype.fullWidth = function () { - return this._leadingTrivia.fullWidth() + this.width() + this._trailingTrivia.fullWidth(); - }; - RealizedToken.prototype.width = function () { - return this.text().length; - }; - - RealizedToken.prototype.text = function () { - return this._text; - }; - RealizedToken.prototype.fullText = function () { - return this._leadingTrivia.fullText() + this.text() + this._trailingTrivia.fullText(); - }; - - RealizedToken.prototype.value = function () { - return this._value; - }; - RealizedToken.prototype.valueText = function () { - return this._valueText; - }; - - RealizedToken.prototype.hasLeadingTrivia = function () { - return this._leadingTrivia.count() > 0; - }; - RealizedToken.prototype.hasLeadingComment = function () { - return this._leadingTrivia.hasComment(); - }; - RealizedToken.prototype.hasLeadingNewLine = function () { - return this._leadingTrivia.hasNewLine(); - }; - RealizedToken.prototype.hasLeadingSkippedText = function () { - return this._leadingTrivia.hasSkippedToken(); - }; - RealizedToken.prototype.leadingTriviaWidth = function () { - return this._leadingTrivia.fullWidth(); - }; - - RealizedToken.prototype.hasTrailingTrivia = function () { - return this._trailingTrivia.count() > 0; - }; - RealizedToken.prototype.hasTrailingComment = function () { - return this._trailingTrivia.hasComment(); - }; - RealizedToken.prototype.hasTrailingNewLine = function () { - return this._trailingTrivia.hasNewLine(); - }; - RealizedToken.prototype.hasTrailingSkippedText = function () { - return this._trailingTrivia.hasSkippedToken(); - }; - RealizedToken.prototype.trailingTriviaWidth = function () { - return this._trailingTrivia.fullWidth(); - }; - - RealizedToken.prototype.hasSkippedToken = function () { - return this.hasLeadingSkippedText() || this.hasTrailingSkippedText(); - }; - - RealizedToken.prototype.leadingTrivia = function () { - return this._leadingTrivia; - }; - RealizedToken.prototype.trailingTrivia = function () { - return this._trailingTrivia; - }; - - RealizedToken.prototype.findTokenInternal = function (parent, position, fullStart) { - return new TypeScript.PositionedToken(parent, this, fullStart); - }; - - RealizedToken.prototype.collectTextElements = function (elements) { - this.leadingTrivia().collectTextElements(elements); - elements.push(this.text()); - this.trailingTrivia().collectTextElements(elements); - }; - - RealizedToken.prototype.withLeadingTrivia = function (leadingTrivia) { - return new RealizedToken(this.tokenKind, leadingTrivia, this._text, this._value, this._valueText, this._trailingTrivia); - }; - - RealizedToken.prototype.withTrailingTrivia = function (trailingTrivia) { - return new RealizedToken(this.tokenKind, this._leadingTrivia, this._text, this._value, this._valueText, trailingTrivia); - }; - return RealizedToken; - })(); - - function token(kind, info) { - if (typeof info === "undefined") { info = null; } - var text = (info !== null && info.text !== undefined) ? info.text : TypeScript.SyntaxFacts.getText(kind); - - return new RealizedToken(kind, TypeScript.Syntax.triviaList(info === null ? null : info.leadingTrivia), text, value1(kind, text), valueText1(kind, text), TypeScript.Syntax.triviaList(info === null ? null : info.trailingTrivia)); - } - Syntax.token = token; - - function identifier(text, info) { - if (typeof info === "undefined") { info = null; } - info = info || {}; - info.text = text; - return token(11 /* IdentifierName */, info); - } - Syntax.identifier = identifier; - })(TypeScript.Syntax || (TypeScript.Syntax = {})); - var Syntax = TypeScript.Syntax; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var SyntaxTokenReplacer = (function (_super) { - __extends(SyntaxTokenReplacer, _super); - function SyntaxTokenReplacer(token1, token2) { - _super.call(this); - this.token1 = token1; - this.token2 = token2; - } - SyntaxTokenReplacer.prototype.visitToken = function (token) { - if (token === this.token1) { - var result = this.token2; - this.token1 = null; - this.token2 = null; - - return result; - } - - return token; - }; - - SyntaxTokenReplacer.prototype.visitNode = function (node) { - if (this.token1 === null) { - return node; - } - - return _super.prototype.visitNode.call(this, node); - }; - - SyntaxTokenReplacer.prototype.visitList = function (list) { - if (this.token1 === null) { - return list; - } - - return _super.prototype.visitList.call(this, list); - }; - - SyntaxTokenReplacer.prototype.visitSeparatedList = function (list) { - if (this.token1 === null) { - return list; - } - - return _super.prototype.visitSeparatedList.call(this, list); - }; - return SyntaxTokenReplacer; - })(TypeScript.SyntaxRewriter); - TypeScript.SyntaxTokenReplacer = SyntaxTokenReplacer; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (Syntax) { - var SyntaxTrivia = (function () { - function SyntaxTrivia(kind, textOrToken) { - this._kind = kind; - this._textOrToken = textOrToken; - } - SyntaxTrivia.prototype.toJSON = function (key) { - var result = {}; - result.kind = TypeScript.SyntaxKind[this._kind]; - - if (this.isSkippedToken()) { - result.skippedToken = this._textOrToken; - } else { - result.text = this._textOrToken; - } - return result; - }; - - SyntaxTrivia.prototype.kind = function () { - return this._kind; - }; - - SyntaxTrivia.prototype.fullWidth = function () { - return this.fullText().length; - }; - - SyntaxTrivia.prototype.fullText = function () { - return this.isSkippedToken() ? this.skippedToken().fullText() : this._textOrToken; - }; - - SyntaxTrivia.prototype.isWhitespace = function () { - return this.kind() === 4 /* WhitespaceTrivia */; - }; - - SyntaxTrivia.prototype.isComment = function () { - return this.kind() === 7 /* SingleLineCommentTrivia */ || this.kind() === 6 /* MultiLineCommentTrivia */; - }; - - SyntaxTrivia.prototype.isNewLine = function () { - return this.kind() === 5 /* NewLineTrivia */; - }; - - SyntaxTrivia.prototype.isSkippedToken = function () { - return this.kind() === 8 /* SkippedTokenTrivia */; - }; - - SyntaxTrivia.prototype.skippedToken = function () { - TypeScript.Debug.assert(this.isSkippedToken()); - return this._textOrToken; - }; - - SyntaxTrivia.prototype.collectTextElements = function (elements) { - elements.push(this.fullText()); - }; - return SyntaxTrivia; - })(); - - function trivia(kind, text) { - return new SyntaxTrivia(kind, text); - } - Syntax.trivia = trivia; - - function skippedTokenTrivia(token) { - TypeScript.Debug.assert(!token.hasLeadingTrivia()); - TypeScript.Debug.assert(!token.hasTrailingTrivia()); - TypeScript.Debug.assert(token.fullWidth() > 0); - return new SyntaxTrivia(8 /* SkippedTokenTrivia */, token); - } - Syntax.skippedTokenTrivia = skippedTokenTrivia; - - function spaces(count) { - return trivia(4 /* WhitespaceTrivia */, TypeScript.StringUtilities.repeat(" ", count)); - } - Syntax.spaces = spaces; - - function whitespace(text) { - return trivia(4 /* WhitespaceTrivia */, text); - } - Syntax.whitespace = whitespace; - - function multiLineComment(text) { - return trivia(6 /* MultiLineCommentTrivia */, text); - } - Syntax.multiLineComment = multiLineComment; - - function singleLineComment(text) { - return trivia(7 /* SingleLineCommentTrivia */, text); - } - Syntax.singleLineComment = singleLineComment; - - Syntax.spaceTrivia = spaces(1); - Syntax.lineFeedTrivia = trivia(5 /* NewLineTrivia */, "\n"); - Syntax.carriageReturnTrivia = trivia(5 /* NewLineTrivia */, "\r"); - Syntax.carriageReturnLineFeedTrivia = trivia(5 /* NewLineTrivia */, "\r\n"); - - function splitMultiLineCommentTriviaIntoMultipleLines(trivia) { - var result = []; - - var triviaText = trivia.fullText(); - var currentIndex = 0; - - for (var i = 0; i < triviaText.length; i++) { - var ch = triviaText.charCodeAt(i); - - var isCarriageReturnLineFeed = false; - switch (ch) { - case 13 /* carriageReturn */: - if (i < triviaText.length - 1 && triviaText.charCodeAt(i + 1) === 10 /* lineFeed */) { - i++; - } - - case 10 /* lineFeed */: - case 8233 /* paragraphSeparator */: - case 8232 /* lineSeparator */: - result.push(triviaText.substring(currentIndex, i + 1)); - - currentIndex = i + 1; - continue; - } - } - - result.push(triviaText.substring(currentIndex)); - return result; - } - Syntax.splitMultiLineCommentTriviaIntoMultipleLines = splitMultiLineCommentTriviaIntoMultipleLines; - })(TypeScript.Syntax || (TypeScript.Syntax = {})); - var Syntax = TypeScript.Syntax; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (Syntax) { - Syntax.emptyTriviaList = { - kind: function () { - return 3 /* TriviaList */; - }, - count: function () { - return 0; - }, - syntaxTriviaAt: function (index) { - throw TypeScript.Errors.argumentOutOfRange("index"); - }, - last: function () { - throw TypeScript.Errors.argumentOutOfRange("index"); - }, - fullWidth: function () { - return 0; - }, - fullText: function () { - return ""; - }, - hasComment: function () { - return false; - }, - hasNewLine: function () { - return false; - }, - hasSkippedToken: function () { - return false; - }, - toJSON: function (key) { - return []; - }, - collectTextElements: function (elements) { - }, - toArray: function () { - return []; - }, - concat: function (trivia) { - return trivia; - } - }; - - function concatTrivia(list1, list2) { - if (list1.count() === 0) { - return list2; - } - - if (list2.count() === 0) { - return list1; - } - - var trivia = list1.toArray(); - trivia.push.apply(trivia, list2.toArray()); - - return triviaList(trivia); - } - - function isComment(trivia) { - return trivia.kind() === 6 /* MultiLineCommentTrivia */ || trivia.kind() === 7 /* SingleLineCommentTrivia */; - } - - var SingletonSyntaxTriviaList = (function () { - function SingletonSyntaxTriviaList(item) { - this.item = item; - } - SingletonSyntaxTriviaList.prototype.kind = function () { - return 3 /* TriviaList */; - }; - - SingletonSyntaxTriviaList.prototype.count = function () { - return 1; - }; - - SingletonSyntaxTriviaList.prototype.syntaxTriviaAt = function (index) { - if (index !== 0) { - throw TypeScript.Errors.argumentOutOfRange("index"); - } - - return this.item; - }; - - SingletonSyntaxTriviaList.prototype.last = function () { - return this.item; - }; - - SingletonSyntaxTriviaList.prototype.fullWidth = function () { - return this.item.fullWidth(); - }; - - SingletonSyntaxTriviaList.prototype.fullText = function () { - return this.item.fullText(); - }; - - SingletonSyntaxTriviaList.prototype.hasComment = function () { - return isComment(this.item); - }; - - SingletonSyntaxTriviaList.prototype.hasNewLine = function () { - return this.item.kind() === 5 /* NewLineTrivia */; - }; - - SingletonSyntaxTriviaList.prototype.hasSkippedToken = function () { - return this.item.kind() === 8 /* SkippedTokenTrivia */; - }; - - SingletonSyntaxTriviaList.prototype.toJSON = function (key) { - return [this.item]; - }; - - SingletonSyntaxTriviaList.prototype.collectTextElements = function (elements) { - (this.item).collectTextElements(elements); - }; - - SingletonSyntaxTriviaList.prototype.toArray = function () { - return [this.item]; - }; - - SingletonSyntaxTriviaList.prototype.concat = function (trivia) { - return concatTrivia(this, trivia); - }; - return SingletonSyntaxTriviaList; - })(); - - var NormalSyntaxTriviaList = (function () { - function NormalSyntaxTriviaList(trivia) { - this.trivia = trivia; - } - NormalSyntaxTriviaList.prototype.kind = function () { - return 3 /* TriviaList */; - }; - - NormalSyntaxTriviaList.prototype.count = function () { - return this.trivia.length; - }; - - NormalSyntaxTriviaList.prototype.syntaxTriviaAt = function (index) { - if (index < 0 || index >= this.trivia.length) { - throw TypeScript.Errors.argumentOutOfRange("index"); - } - - return this.trivia[index]; - }; - - NormalSyntaxTriviaList.prototype.last = function () { - return this.trivia[this.trivia.length - 1]; - }; - - NormalSyntaxTriviaList.prototype.fullWidth = function () { - return TypeScript.ArrayUtilities.sum(this.trivia, function (t) { - return t.fullWidth(); - }); - }; - - NormalSyntaxTriviaList.prototype.fullText = function () { - var result = ""; - - for (var i = 0, n = this.trivia.length; i < n; i++) { - result += this.trivia[i].fullText(); - } - - return result; - }; - - NormalSyntaxTriviaList.prototype.hasComment = function () { - for (var i = 0; i < this.trivia.length; i++) { - if (isComment(this.trivia[i])) { - return true; - } - } - - return false; - }; - - NormalSyntaxTriviaList.prototype.hasNewLine = function () { - for (var i = 0; i < this.trivia.length; i++) { - if (this.trivia[i].kind() === 5 /* NewLineTrivia */) { - return true; - } - } - - return false; - }; - - NormalSyntaxTriviaList.prototype.hasSkippedToken = function () { - for (var i = 0; i < this.trivia.length; i++) { - if (this.trivia[i].kind() === 8 /* SkippedTokenTrivia */) { - return true; - } - } - - return false; - }; - - NormalSyntaxTriviaList.prototype.toJSON = function (key) { - return this.trivia; - }; - - NormalSyntaxTriviaList.prototype.collectTextElements = function (elements) { - for (var i = 0; i < this.trivia.length; i++) { - (this.trivia[i]).collectTextElements(elements); - } - }; - - NormalSyntaxTriviaList.prototype.toArray = function () { - return this.trivia.slice(0); - }; - - NormalSyntaxTriviaList.prototype.concat = function (trivia) { - return concatTrivia(this, trivia); - }; - return NormalSyntaxTriviaList; - })(); - - function triviaList(trivia) { - if (trivia === undefined || trivia === null || trivia.length === 0) { - return TypeScript.Syntax.emptyTriviaList; - } - - if (trivia.length === 1) { - return new SingletonSyntaxTriviaList(trivia[0]); - } - - return new NormalSyntaxTriviaList(trivia); - } - Syntax.triviaList = triviaList; - - Syntax.spaceTriviaList = triviaList([TypeScript.Syntax.spaceTrivia]); - })(TypeScript.Syntax || (TypeScript.Syntax = {})); - var Syntax = TypeScript.Syntax; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var SyntaxUtilities = (function () { - function SyntaxUtilities() { - } - SyntaxUtilities.isAngleBracket = function (positionedElement) { - var element = positionedElement.element(); - var parent = positionedElement.parentElement(); - if (parent !== null && (element.kind() === 81 /* LessThanToken */ || element.kind() === 82 /* GreaterThanToken */)) { - switch (parent.kind()) { - case 227 /* TypeArgumentList */: - case 228 /* TypeParameterList */: - case 219 /* CastExpression */: - return true; - } - } - - return false; - }; - - SyntaxUtilities.getToken = function (list, kind) { - for (var i = 0, n = list.childCount(); i < n; i++) { - var token = list.childAt(i); - if (token.tokenKind === kind) { - return token; - } - } - - return null; - }; - - SyntaxUtilities.containsToken = function (list, kind) { - return SyntaxUtilities.getToken(list, kind) !== null; - }; - - SyntaxUtilities.hasExportKeyword = function (moduleElement) { - switch (moduleElement.kind()) { - case 130 /* ModuleDeclaration */: - case 131 /* ClassDeclaration */: - case 129 /* FunctionDeclaration */: - case 147 /* VariableStatement */: - case 132 /* EnumDeclaration */: - case 128 /* InterfaceDeclaration */: - return SyntaxUtilities.containsToken((moduleElement).modifiers, 47 /* ExportKeyword */); - } - - return false; - }; - - SyntaxUtilities.isAmbientDeclarationSyntax = function (positionNode) { - if (!positionNode) { - return false; - } - - var node = positionNode.node(); - switch (node.kind()) { - case 130 /* ModuleDeclaration */: - case 131 /* ClassDeclaration */: - case 129 /* FunctionDeclaration */: - case 147 /* VariableStatement */: - case 132 /* EnumDeclaration */: - if (SyntaxUtilities.containsToken((node).modifiers, 64 /* DeclareKeyword */)) { - return true; - } - - case 133 /* ImportDeclaration */: - case 137 /* ConstructorDeclaration */: - case 135 /* MemberFunctionDeclaration */: - case 138 /* GetMemberAccessorDeclaration */: - case 139 /* SetMemberAccessorDeclaration */: - case 136 /* MemberVariableDeclaration */: - if (node.isClassElement() || node.isModuleElement()) { - return SyntaxUtilities.isAmbientDeclarationSyntax(positionNode.containingNode()); - } - - case 243 /* EnumElement */: - return SyntaxUtilities.isAmbientDeclarationSyntax(positionNode.containingNode().containingNode()); - - default: - return SyntaxUtilities.isAmbientDeclarationSyntax(positionNode.containingNode()); - } - }; - return SyntaxUtilities; - })(); - TypeScript.SyntaxUtilities = SyntaxUtilities; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var SyntaxVisitor = (function () { - function SyntaxVisitor() { - } - SyntaxVisitor.prototype.defaultVisit = function (node) { - return null; - }; - - SyntaxVisitor.prototype.visitToken = function (token) { - return this.defaultVisit(token); - }; - - SyntaxVisitor.prototype.visitSourceUnit = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitExternalModuleReference = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitModuleNameModuleReference = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitImportDeclaration = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitExportAssignment = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitClassDeclaration = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitInterfaceDeclaration = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitHeritageClause = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitModuleDeclaration = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitFunctionDeclaration = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitVariableStatement = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitVariableDeclaration = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitVariableDeclarator = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitEqualsValueClause = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitPrefixUnaryExpression = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitArrayLiteralExpression = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitOmittedExpression = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitParenthesizedExpression = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitSimpleArrowFunctionExpression = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitParenthesizedArrowFunctionExpression = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitQualifiedName = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitTypeArgumentList = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitConstructorType = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitFunctionType = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitObjectType = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitArrayType = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitGenericType = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitTypeAnnotation = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitBlock = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitParameter = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitMemberAccessExpression = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitPostfixUnaryExpression = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitElementAccessExpression = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitInvocationExpression = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitArgumentList = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitBinaryExpression = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitConditionalExpression = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitConstructSignature = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitMethodSignature = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitIndexSignature = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitPropertySignature = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitCallSignature = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitParameterList = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitTypeParameterList = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitTypeParameter = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitConstraint = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitElseClause = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitIfStatement = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitExpressionStatement = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitConstructorDeclaration = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitMemberFunctionDeclaration = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitGetMemberAccessorDeclaration = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitSetMemberAccessorDeclaration = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitMemberVariableDeclaration = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitThrowStatement = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitReturnStatement = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitObjectCreationExpression = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitSwitchStatement = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitCaseSwitchClause = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitDefaultSwitchClause = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitBreakStatement = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitContinueStatement = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitForStatement = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitForInStatement = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitWhileStatement = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitWithStatement = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitEnumDeclaration = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitEnumElement = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitCastExpression = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitObjectLiteralExpression = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitSimplePropertyAssignment = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitFunctionPropertyAssignment = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitGetAccessorPropertyAssignment = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitSetAccessorPropertyAssignment = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitFunctionExpression = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitEmptyStatement = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitTryStatement = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitCatchClause = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitFinallyClause = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitLabeledStatement = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitDoStatement = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitTypeOfExpression = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitDeleteExpression = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitVoidExpression = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitDebuggerStatement = function (node) { - return this.defaultVisit(node); - }; - return SyntaxVisitor; - })(); - TypeScript.SyntaxVisitor = SyntaxVisitor; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var SyntaxWalker = (function () { - function SyntaxWalker() { - } - SyntaxWalker.prototype.visitToken = function (token) { - }; - - SyntaxWalker.prototype.visitNode = function (node) { - node.accept(this); - }; - - SyntaxWalker.prototype.visitNodeOrToken = function (nodeOrToken) { - if (nodeOrToken.isToken()) { - this.visitToken(nodeOrToken); - } else { - this.visitNode(nodeOrToken); - } - }; - - SyntaxWalker.prototype.visitOptionalToken = function (token) { - if (token === null) { - return; - } - - this.visitToken(token); - }; - - SyntaxWalker.prototype.visitOptionalNode = function (node) { - if (node === null) { - return; - } - - this.visitNode(node); - }; - - SyntaxWalker.prototype.visitOptionalNodeOrToken = function (nodeOrToken) { - if (nodeOrToken === null) { - return; - } - - this.visitNodeOrToken(nodeOrToken); - }; - - SyntaxWalker.prototype.visitList = function (list) { - for (var i = 0, n = list.childCount(); i < n; i++) { - this.visitNodeOrToken(list.childAt(i)); - } - }; - - SyntaxWalker.prototype.visitSeparatedList = function (list) { - for (var i = 0, n = list.childCount(); i < n; i++) { - var item = list.childAt(i); - this.visitNodeOrToken(item); - } - }; - - SyntaxWalker.prototype.visitSourceUnit = function (node) { - this.visitList(node.moduleElements); - this.visitToken(node.endOfFileToken); - }; - - SyntaxWalker.prototype.visitExternalModuleReference = function (node) { - this.visitToken(node.moduleOrRequireKeyword); - this.visitToken(node.openParenToken); - this.visitToken(node.stringLiteral); - this.visitToken(node.closeParenToken); - }; - - SyntaxWalker.prototype.visitModuleNameModuleReference = function (node) { - this.visitNodeOrToken(node.moduleName); - }; - - SyntaxWalker.prototype.visitImportDeclaration = function (node) { - this.visitToken(node.importKeyword); - this.visitToken(node.identifier); - this.visitToken(node.equalsToken); - this.visitNode(node.moduleReference); - this.visitToken(node.semicolonToken); - }; - - SyntaxWalker.prototype.visitExportAssignment = function (node) { - this.visitToken(node.exportKeyword); - this.visitToken(node.equalsToken); - this.visitToken(node.identifier); - this.visitToken(node.semicolonToken); - }; - - SyntaxWalker.prototype.visitClassDeclaration = function (node) { - this.visitList(node.modifiers); - this.visitToken(node.classKeyword); - this.visitToken(node.identifier); - this.visitOptionalNode(node.typeParameterList); - this.visitList(node.heritageClauses); - this.visitToken(node.openBraceToken); - this.visitList(node.classElements); - this.visitToken(node.closeBraceToken); - }; - - SyntaxWalker.prototype.visitInterfaceDeclaration = function (node) { - this.visitList(node.modifiers); - this.visitToken(node.interfaceKeyword); - this.visitToken(node.identifier); - this.visitOptionalNode(node.typeParameterList); - this.visitList(node.heritageClauses); - this.visitNode(node.body); - }; - - SyntaxWalker.prototype.visitHeritageClause = function (node) { - this.visitToken(node.extendsOrImplementsKeyword); - this.visitSeparatedList(node.typeNames); - }; - - SyntaxWalker.prototype.visitModuleDeclaration = function (node) { - this.visitList(node.modifiers); - this.visitToken(node.moduleKeyword); - this.visitOptionalNodeOrToken(node.moduleName); - this.visitOptionalToken(node.stringLiteral); - this.visitToken(node.openBraceToken); - this.visitList(node.moduleElements); - this.visitToken(node.closeBraceToken); - }; - - SyntaxWalker.prototype.visitFunctionDeclaration = function (node) { - this.visitList(node.modifiers); - this.visitToken(node.functionKeyword); - this.visitToken(node.identifier); - this.visitNode(node.callSignature); - this.visitOptionalNode(node.block); - this.visitOptionalToken(node.semicolonToken); - }; - - SyntaxWalker.prototype.visitVariableStatement = function (node) { - this.visitList(node.modifiers); - this.visitNode(node.variableDeclaration); - this.visitToken(node.semicolonToken); - }; - - SyntaxWalker.prototype.visitVariableDeclaration = function (node) { - this.visitToken(node.varKeyword); - this.visitSeparatedList(node.variableDeclarators); - }; - - SyntaxWalker.prototype.visitVariableDeclarator = function (node) { - this.visitToken(node.identifier); - this.visitOptionalNode(node.typeAnnotation); - this.visitOptionalNode(node.equalsValueClause); - }; - - SyntaxWalker.prototype.visitEqualsValueClause = function (node) { - this.visitToken(node.equalsToken); - this.visitNodeOrToken(node.value); - }; - - SyntaxWalker.prototype.visitPrefixUnaryExpression = function (node) { - this.visitToken(node.operatorToken); - this.visitNodeOrToken(node.operand); - }; - - SyntaxWalker.prototype.visitArrayLiteralExpression = function (node) { - this.visitToken(node.openBracketToken); - this.visitSeparatedList(node.expressions); - this.visitToken(node.closeBracketToken); - }; - - SyntaxWalker.prototype.visitOmittedExpression = function (node) { - }; - - SyntaxWalker.prototype.visitParenthesizedExpression = function (node) { - this.visitToken(node.openParenToken); - this.visitNodeOrToken(node.expression); - this.visitToken(node.closeParenToken); - }; - - SyntaxWalker.prototype.visitSimpleArrowFunctionExpression = function (node) { - this.visitToken(node.identifier); - this.visitToken(node.equalsGreaterThanToken); - this.visitNodeOrToken(node.body); - }; - - SyntaxWalker.prototype.visitParenthesizedArrowFunctionExpression = function (node) { - this.visitNode(node.callSignature); - this.visitToken(node.equalsGreaterThanToken); - this.visitNodeOrToken(node.body); - }; - - SyntaxWalker.prototype.visitQualifiedName = function (node) { - this.visitNodeOrToken(node.left); - this.visitToken(node.dotToken); - this.visitToken(node.right); - }; - - SyntaxWalker.prototype.visitTypeArgumentList = function (node) { - this.visitToken(node.lessThanToken); - this.visitSeparatedList(node.typeArguments); - this.visitToken(node.greaterThanToken); - }; - - SyntaxWalker.prototype.visitConstructorType = function (node) { - this.visitToken(node.newKeyword); - this.visitOptionalNode(node.typeParameterList); - this.visitNode(node.parameterList); - this.visitToken(node.equalsGreaterThanToken); - this.visitNodeOrToken(node.type); - }; - - SyntaxWalker.prototype.visitFunctionType = function (node) { - this.visitOptionalNode(node.typeParameterList); - this.visitNode(node.parameterList); - this.visitToken(node.equalsGreaterThanToken); - this.visitNodeOrToken(node.type); - }; - - SyntaxWalker.prototype.visitObjectType = function (node) { - this.visitToken(node.openBraceToken); - this.visitSeparatedList(node.typeMembers); - this.visitToken(node.closeBraceToken); - }; - - SyntaxWalker.prototype.visitArrayType = function (node) { - this.visitNodeOrToken(node.type); - this.visitToken(node.openBracketToken); - this.visitToken(node.closeBracketToken); - }; - - SyntaxWalker.prototype.visitGenericType = function (node) { - this.visitNodeOrToken(node.name); - this.visitNode(node.typeArgumentList); - }; - - SyntaxWalker.prototype.visitTypeAnnotation = function (node) { - this.visitToken(node.colonToken); - this.visitNodeOrToken(node.type); - }; - - SyntaxWalker.prototype.visitBlock = function (node) { - this.visitToken(node.openBraceToken); - this.visitList(node.statements); - this.visitToken(node.closeBraceToken); - }; - - SyntaxWalker.prototype.visitParameter = function (node) { - this.visitOptionalToken(node.dotDotDotToken); - this.visitOptionalToken(node.publicOrPrivateKeyword); - this.visitToken(node.identifier); - this.visitOptionalToken(node.questionToken); - this.visitOptionalNode(node.typeAnnotation); - this.visitOptionalNode(node.equalsValueClause); - }; - - SyntaxWalker.prototype.visitMemberAccessExpression = function (node) { - this.visitNodeOrToken(node.expression); - this.visitToken(node.dotToken); - this.visitToken(node.name); - }; - - SyntaxWalker.prototype.visitPostfixUnaryExpression = function (node) { - this.visitNodeOrToken(node.operand); - this.visitToken(node.operatorToken); - }; - - SyntaxWalker.prototype.visitElementAccessExpression = function (node) { - this.visitNodeOrToken(node.expression); - this.visitToken(node.openBracketToken); - this.visitNodeOrToken(node.argumentExpression); - this.visitToken(node.closeBracketToken); - }; - - SyntaxWalker.prototype.visitInvocationExpression = function (node) { - this.visitNodeOrToken(node.expression); - this.visitNode(node.argumentList); - }; - - SyntaxWalker.prototype.visitArgumentList = function (node) { - this.visitOptionalNode(node.typeArgumentList); - this.visitToken(node.openParenToken); - this.visitSeparatedList(node.arguments); - this.visitToken(node.closeParenToken); - }; - - SyntaxWalker.prototype.visitBinaryExpression = function (node) { - this.visitNodeOrToken(node.left); - this.visitToken(node.operatorToken); - this.visitNodeOrToken(node.right); - }; - - SyntaxWalker.prototype.visitConditionalExpression = function (node) { - this.visitNodeOrToken(node.condition); - this.visitToken(node.questionToken); - this.visitNodeOrToken(node.whenTrue); - this.visitToken(node.colonToken); - this.visitNodeOrToken(node.whenFalse); - }; - - SyntaxWalker.prototype.visitConstructSignature = function (node) { - this.visitToken(node.newKeyword); - this.visitNode(node.callSignature); - }; - - SyntaxWalker.prototype.visitMethodSignature = function (node) { - this.visitToken(node.propertyName); - this.visitOptionalToken(node.questionToken); - this.visitNode(node.callSignature); - }; - - SyntaxWalker.prototype.visitIndexSignature = function (node) { - this.visitToken(node.openBracketToken); - this.visitNode(node.parameter); - this.visitToken(node.closeBracketToken); - this.visitOptionalNode(node.typeAnnotation); - }; - - SyntaxWalker.prototype.visitPropertySignature = function (node) { - this.visitToken(node.propertyName); - this.visitOptionalToken(node.questionToken); - this.visitOptionalNode(node.typeAnnotation); - }; - - SyntaxWalker.prototype.visitCallSignature = function (node) { - this.visitOptionalNode(node.typeParameterList); - this.visitNode(node.parameterList); - this.visitOptionalNode(node.typeAnnotation); - }; - - SyntaxWalker.prototype.visitParameterList = function (node) { - this.visitToken(node.openParenToken); - this.visitSeparatedList(node.parameters); - this.visitToken(node.closeParenToken); - }; - - SyntaxWalker.prototype.visitTypeParameterList = function (node) { - this.visitToken(node.lessThanToken); - this.visitSeparatedList(node.typeParameters); - this.visitToken(node.greaterThanToken); - }; - - SyntaxWalker.prototype.visitTypeParameter = function (node) { - this.visitToken(node.identifier); - this.visitOptionalNode(node.constraint); - }; - - SyntaxWalker.prototype.visitConstraint = function (node) { - this.visitToken(node.extendsKeyword); - this.visitNodeOrToken(node.type); - }; - - SyntaxWalker.prototype.visitElseClause = function (node) { - this.visitToken(node.elseKeyword); - this.visitNodeOrToken(node.statement); - }; - - SyntaxWalker.prototype.visitIfStatement = function (node) { - this.visitToken(node.ifKeyword); - this.visitToken(node.openParenToken); - this.visitNodeOrToken(node.condition); - this.visitToken(node.closeParenToken); - this.visitNodeOrToken(node.statement); - this.visitOptionalNode(node.elseClause); - }; - - SyntaxWalker.prototype.visitExpressionStatement = function (node) { - this.visitNodeOrToken(node.expression); - this.visitToken(node.semicolonToken); - }; - - SyntaxWalker.prototype.visitConstructorDeclaration = function (node) { - this.visitToken(node.constructorKeyword); - this.visitNode(node.parameterList); - this.visitOptionalNode(node.block); - this.visitOptionalToken(node.semicolonToken); - }; - - SyntaxWalker.prototype.visitMemberFunctionDeclaration = function (node) { - this.visitList(node.modifiers); - this.visitToken(node.propertyName); - this.visitNode(node.callSignature); - this.visitOptionalNode(node.block); - this.visitOptionalToken(node.semicolonToken); - }; - - SyntaxWalker.prototype.visitGetMemberAccessorDeclaration = function (node) { - this.visitList(node.modifiers); - this.visitToken(node.getKeyword); - this.visitToken(node.propertyName); - this.visitNode(node.parameterList); - this.visitOptionalNode(node.typeAnnotation); - this.visitNode(node.block); - }; - - SyntaxWalker.prototype.visitSetMemberAccessorDeclaration = function (node) { - this.visitList(node.modifiers); - this.visitToken(node.setKeyword); - this.visitToken(node.propertyName); - this.visitNode(node.parameterList); - this.visitNode(node.block); - }; - - SyntaxWalker.prototype.visitMemberVariableDeclaration = function (node) { - this.visitList(node.modifiers); - this.visitNode(node.variableDeclarator); - this.visitToken(node.semicolonToken); - }; - - SyntaxWalker.prototype.visitThrowStatement = function (node) { - this.visitToken(node.throwKeyword); - this.visitNodeOrToken(node.expression); - this.visitToken(node.semicolonToken); - }; - - SyntaxWalker.prototype.visitReturnStatement = function (node) { - this.visitToken(node.returnKeyword); - this.visitOptionalNodeOrToken(node.expression); - this.visitToken(node.semicolonToken); - }; - - SyntaxWalker.prototype.visitObjectCreationExpression = function (node) { - this.visitToken(node.newKeyword); - this.visitNodeOrToken(node.expression); - this.visitOptionalNode(node.argumentList); - }; - - SyntaxWalker.prototype.visitSwitchStatement = function (node) { - this.visitToken(node.switchKeyword); - this.visitToken(node.openParenToken); - this.visitNodeOrToken(node.expression); - this.visitToken(node.closeParenToken); - this.visitToken(node.openBraceToken); - this.visitList(node.switchClauses); - this.visitToken(node.closeBraceToken); - }; - - SyntaxWalker.prototype.visitCaseSwitchClause = function (node) { - this.visitToken(node.caseKeyword); - this.visitNodeOrToken(node.expression); - this.visitToken(node.colonToken); - this.visitList(node.statements); - }; - - SyntaxWalker.prototype.visitDefaultSwitchClause = function (node) { - this.visitToken(node.defaultKeyword); - this.visitToken(node.colonToken); - this.visitList(node.statements); - }; - - SyntaxWalker.prototype.visitBreakStatement = function (node) { - this.visitToken(node.breakKeyword); - this.visitOptionalToken(node.identifier); - this.visitToken(node.semicolonToken); - }; - - SyntaxWalker.prototype.visitContinueStatement = function (node) { - this.visitToken(node.continueKeyword); - this.visitOptionalToken(node.identifier); - this.visitToken(node.semicolonToken); - }; - - SyntaxWalker.prototype.visitForStatement = function (node) { - this.visitToken(node.forKeyword); - this.visitToken(node.openParenToken); - this.visitOptionalNode(node.variableDeclaration); - this.visitOptionalNodeOrToken(node.initializer); - this.visitToken(node.firstSemicolonToken); - this.visitOptionalNodeOrToken(node.condition); - this.visitToken(node.secondSemicolonToken); - this.visitOptionalNodeOrToken(node.incrementor); - this.visitToken(node.closeParenToken); - this.visitNodeOrToken(node.statement); - }; - - SyntaxWalker.prototype.visitForInStatement = function (node) { - this.visitToken(node.forKeyword); - this.visitToken(node.openParenToken); - this.visitOptionalNode(node.variableDeclaration); - this.visitOptionalNodeOrToken(node.left); - this.visitToken(node.inKeyword); - this.visitNodeOrToken(node.expression); - this.visitToken(node.closeParenToken); - this.visitNodeOrToken(node.statement); - }; - - SyntaxWalker.prototype.visitWhileStatement = function (node) { - this.visitToken(node.whileKeyword); - this.visitToken(node.openParenToken); - this.visitNodeOrToken(node.condition); - this.visitToken(node.closeParenToken); - this.visitNodeOrToken(node.statement); - }; - - SyntaxWalker.prototype.visitWithStatement = function (node) { - this.visitToken(node.withKeyword); - this.visitToken(node.openParenToken); - this.visitNodeOrToken(node.condition); - this.visitToken(node.closeParenToken); - this.visitNodeOrToken(node.statement); - }; - - SyntaxWalker.prototype.visitEnumDeclaration = function (node) { - this.visitList(node.modifiers); - this.visitToken(node.enumKeyword); - this.visitToken(node.identifier); - this.visitToken(node.openBraceToken); - this.visitSeparatedList(node.enumElements); - this.visitToken(node.closeBraceToken); - }; - - SyntaxWalker.prototype.visitEnumElement = function (node) { - this.visitToken(node.propertyName); - this.visitOptionalNode(node.equalsValueClause); - }; - - SyntaxWalker.prototype.visitCastExpression = function (node) { - this.visitToken(node.lessThanToken); - this.visitNodeOrToken(node.type); - this.visitToken(node.greaterThanToken); - this.visitNodeOrToken(node.expression); - }; - - SyntaxWalker.prototype.visitObjectLiteralExpression = function (node) { - this.visitToken(node.openBraceToken); - this.visitSeparatedList(node.propertyAssignments); - this.visitToken(node.closeBraceToken); - }; - - SyntaxWalker.prototype.visitSimplePropertyAssignment = function (node) { - this.visitToken(node.propertyName); - this.visitToken(node.colonToken); - this.visitNodeOrToken(node.expression); - }; - - SyntaxWalker.prototype.visitFunctionPropertyAssignment = function (node) { - this.visitToken(node.propertyName); - this.visitNode(node.callSignature); - this.visitNode(node.block); - }; - - SyntaxWalker.prototype.visitGetAccessorPropertyAssignment = function (node) { - this.visitToken(node.getKeyword); - this.visitToken(node.propertyName); - this.visitToken(node.openParenToken); - this.visitToken(node.closeParenToken); - this.visitOptionalNode(node.typeAnnotation); - this.visitNode(node.block); - }; - - SyntaxWalker.prototype.visitSetAccessorPropertyAssignment = function (node) { - this.visitToken(node.setKeyword); - this.visitToken(node.propertyName); - this.visitToken(node.openParenToken); - this.visitNode(node.parameter); - this.visitToken(node.closeParenToken); - this.visitNode(node.block); - }; - - SyntaxWalker.prototype.visitFunctionExpression = function (node) { - this.visitToken(node.functionKeyword); - this.visitOptionalToken(node.identifier); - this.visitNode(node.callSignature); - this.visitNode(node.block); - }; - - SyntaxWalker.prototype.visitEmptyStatement = function (node) { - this.visitToken(node.semicolonToken); - }; - - SyntaxWalker.prototype.visitTryStatement = function (node) { - this.visitToken(node.tryKeyword); - this.visitNode(node.block); - this.visitOptionalNode(node.catchClause); - this.visitOptionalNode(node.finallyClause); - }; - - SyntaxWalker.prototype.visitCatchClause = function (node) { - this.visitToken(node.catchKeyword); - this.visitToken(node.openParenToken); - this.visitToken(node.identifier); - this.visitOptionalNode(node.typeAnnotation); - this.visitToken(node.closeParenToken); - this.visitNode(node.block); - }; - - SyntaxWalker.prototype.visitFinallyClause = function (node) { - this.visitToken(node.finallyKeyword); - this.visitNode(node.block); - }; - - SyntaxWalker.prototype.visitLabeledStatement = function (node) { - this.visitToken(node.identifier); - this.visitToken(node.colonToken); - this.visitNodeOrToken(node.statement); - }; - - SyntaxWalker.prototype.visitDoStatement = function (node) { - this.visitToken(node.doKeyword); - this.visitNodeOrToken(node.statement); - this.visitToken(node.whileKeyword); - this.visitToken(node.openParenToken); - this.visitNodeOrToken(node.condition); - this.visitToken(node.closeParenToken); - this.visitToken(node.semicolonToken); - }; - - SyntaxWalker.prototype.visitTypeOfExpression = function (node) { - this.visitToken(node.typeOfKeyword); - this.visitNodeOrToken(node.expression); - }; - - SyntaxWalker.prototype.visitDeleteExpression = function (node) { - this.visitToken(node.deleteKeyword); - this.visitNodeOrToken(node.expression); - }; - - SyntaxWalker.prototype.visitVoidExpression = function (node) { - this.visitToken(node.voidKeyword); - this.visitNodeOrToken(node.expression); - }; - - SyntaxWalker.prototype.visitDebuggerStatement = function (node) { - this.visitToken(node.debuggerKeyword); - this.visitToken(node.semicolonToken); - }; - return SyntaxWalker; - })(); - TypeScript.SyntaxWalker = SyntaxWalker; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var PositionTrackingWalker = (function (_super) { - __extends(PositionTrackingWalker, _super); - function PositionTrackingWalker() { - _super.apply(this, arguments); - this._position = 0; - } - PositionTrackingWalker.prototype.visitToken = function (token) { - this._position += token.fullWidth(); - }; - - PositionTrackingWalker.prototype.position = function () { - return this._position; - }; - - PositionTrackingWalker.prototype.skip = function (element) { - this._position += element.fullWidth(); - }; - return PositionTrackingWalker; - })(TypeScript.SyntaxWalker); - TypeScript.PositionTrackingWalker = PositionTrackingWalker; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var SyntaxInformationMap = (function (_super) { - __extends(SyntaxInformationMap, _super); - function SyntaxInformationMap(trackParents, trackPreviousToken) { - _super.call(this); - this.trackParents = trackParents; - this.trackPreviousToken = trackPreviousToken; - this.tokenToInformation = TypeScript.Collections.createHashTable(TypeScript.Collections.DefaultHashTableCapacity, TypeScript.Collections.identityHashCode); - this.elementToPosition = TypeScript.Collections.createHashTable(TypeScript.Collections.DefaultHashTableCapacity, TypeScript.Collections.identityHashCode); - this._previousToken = null; - this._previousTokenInformation = null; - this._currentPosition = 0; - this._elementToParent = TypeScript.Collections.createHashTable(TypeScript.Collections.DefaultHashTableCapacity, TypeScript.Collections.identityHashCode); - this._parentStack = []; - this._parentStack.push(null); - } - SyntaxInformationMap.create = function (node, trackParents, trackPreviousToken) { - var map = new SyntaxInformationMap(trackParents, trackPreviousToken); - map.visitNode(node); - return map; - }; - - SyntaxInformationMap.prototype.visitNode = function (node) { - this.trackParents && this._elementToParent.add(node, TypeScript.ArrayUtilities.last(this._parentStack)); - this.elementToPosition.add(node, this._currentPosition); - - this.trackParents && this._parentStack.push(node); - _super.prototype.visitNode.call(this, node); - this.trackParents && this._parentStack.pop(); - }; - - SyntaxInformationMap.prototype.visitToken = function (token) { - this.trackParents && this._elementToParent.add(token, TypeScript.ArrayUtilities.last(this._parentStack)); - - if (this.trackPreviousToken) { - var tokenInformation = { - previousToken: this._previousToken, - nextToken: null - }; - - if (this._previousTokenInformation !== null) { - this._previousTokenInformation.nextToken = token; - } - - this._previousToken = token; - this._previousTokenInformation = tokenInformation; - - this.tokenToInformation.add(token, tokenInformation); - } - - this.elementToPosition.add(token, this._currentPosition); - this._currentPosition += token.fullWidth(); - }; - - SyntaxInformationMap.prototype.parent = function (element) { - return this._elementToParent.get(element); - }; - - SyntaxInformationMap.prototype.fullStart = function (element) { - return this.elementToPosition.get(element); - }; - - SyntaxInformationMap.prototype.start = function (element) { - return this.fullStart(element) + element.leadingTriviaWidth(); - }; - - SyntaxInformationMap.prototype.end = function (element) { - return this.start(element) + element.width(); - }; - - SyntaxInformationMap.prototype.previousToken = function (token) { - return this.tokenInformation(token).previousToken; - }; - - SyntaxInformationMap.prototype.tokenInformation = function (token) { - return this.tokenToInformation.get(token); - }; - - SyntaxInformationMap.prototype.firstTokenInLineContainingToken = function (token) { - var current = token; - while (true) { - var information = this.tokenInformation(current); - if (this.isFirstTokenInLineWorker(information)) { - break; - } - - current = information.previousToken; - } - - return current; - }; - - SyntaxInformationMap.prototype.isFirstTokenInLine = function (token) { - var information = this.tokenInformation(token); - return this.isFirstTokenInLineWorker(information); - }; - - SyntaxInformationMap.prototype.isFirstTokenInLineWorker = function (information) { - return information.previousToken === null || information.previousToken.hasTrailingNewLine(); - }; - return SyntaxInformationMap; - })(TypeScript.SyntaxWalker); - TypeScript.SyntaxInformationMap = SyntaxInformationMap; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var SyntaxNodeInvariantsChecker = (function (_super) { - __extends(SyntaxNodeInvariantsChecker, _super); - function SyntaxNodeInvariantsChecker() { - _super.apply(this, arguments); - this.tokenTable = TypeScript.Collections.createHashTable(TypeScript.Collections.DefaultHashTableCapacity, TypeScript.Collections.identityHashCode); - } - SyntaxNodeInvariantsChecker.checkInvariants = function (node) { - node.accept(new SyntaxNodeInvariantsChecker()); - }; - - SyntaxNodeInvariantsChecker.prototype.visitToken = function (token) { - this.tokenTable.add(token, token); - }; - return SyntaxNodeInvariantsChecker; - })(TypeScript.SyntaxWalker); - TypeScript.SyntaxNodeInvariantsChecker = SyntaxNodeInvariantsChecker; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var DepthLimitedWalker = (function (_super) { - __extends(DepthLimitedWalker, _super); - function DepthLimitedWalker(maximumDepth) { - _super.call(this); - this._depth = 0; - this._maximumDepth = 0; - this._maximumDepth = maximumDepth; - } - DepthLimitedWalker.prototype.visitNode = function (node) { - if (this._depth < this._maximumDepth) { - this._depth++; - _super.prototype.visitNode.call(this, node); - this._depth--; - } else { - this.skip(node); - } - }; - return DepthLimitedWalker; - })(TypeScript.PositionTrackingWalker); - TypeScript.DepthLimitedWalker = DepthLimitedWalker; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (Parser) { - var ExpressionPrecedence; - (function (ExpressionPrecedence) { - ExpressionPrecedence[ExpressionPrecedence["CommaExpressionPrecedence"] = 1] = "CommaExpressionPrecedence"; - - ExpressionPrecedence[ExpressionPrecedence["AssignmentExpressionPrecedence"] = 2] = "AssignmentExpressionPrecedence"; - - ExpressionPrecedence[ExpressionPrecedence["ConditionalExpressionPrecedence"] = 3] = "ConditionalExpressionPrecedence"; - - ExpressionPrecedence[ExpressionPrecedence["ArrowFunctionPrecedence"] = 4] = "ArrowFunctionPrecedence"; - - ExpressionPrecedence[ExpressionPrecedence["LogicalOrExpressionPrecedence"] = 5] = "LogicalOrExpressionPrecedence"; - ExpressionPrecedence[ExpressionPrecedence["LogicalAndExpressionPrecedence"] = 6] = "LogicalAndExpressionPrecedence"; - ExpressionPrecedence[ExpressionPrecedence["BitwiseOrExpressionPrecedence"] = 7] = "BitwiseOrExpressionPrecedence"; - ExpressionPrecedence[ExpressionPrecedence["BitwiseExclusiveOrExpressionPrecedence"] = 8] = "BitwiseExclusiveOrExpressionPrecedence"; - ExpressionPrecedence[ExpressionPrecedence["BitwiseAndExpressionPrecedence"] = 9] = "BitwiseAndExpressionPrecedence"; - ExpressionPrecedence[ExpressionPrecedence["EqualityExpressionPrecedence"] = 10] = "EqualityExpressionPrecedence"; - ExpressionPrecedence[ExpressionPrecedence["RelationalExpressionPrecedence"] = 11] = "RelationalExpressionPrecedence"; - ExpressionPrecedence[ExpressionPrecedence["ShiftExpressionPrecdence"] = 12] = "ShiftExpressionPrecdence"; - ExpressionPrecedence[ExpressionPrecedence["AdditiveExpressionPrecedence"] = 13] = "AdditiveExpressionPrecedence"; - ExpressionPrecedence[ExpressionPrecedence["MultiplicativeExpressionPrecedence"] = 14] = "MultiplicativeExpressionPrecedence"; - - ExpressionPrecedence[ExpressionPrecedence["UnaryExpressionPrecedence"] = 15] = "UnaryExpressionPrecedence"; - })(ExpressionPrecedence || (ExpressionPrecedence = {})); - - var ListParsingState; - (function (ListParsingState) { - ListParsingState[ListParsingState["SourceUnit_ModuleElements"] = 1 << 0] = "SourceUnit_ModuleElements"; - ListParsingState[ListParsingState["ClassDeclaration_ClassElements"] = 1 << 1] = "ClassDeclaration_ClassElements"; - ListParsingState[ListParsingState["ModuleDeclaration_ModuleElements"] = 1 << 2] = "ModuleDeclaration_ModuleElements"; - ListParsingState[ListParsingState["SwitchStatement_SwitchClauses"] = 1 << 3] = "SwitchStatement_SwitchClauses"; - ListParsingState[ListParsingState["SwitchClause_Statements"] = 1 << 4] = "SwitchClause_Statements"; - ListParsingState[ListParsingState["Block_Statements"] = 1 << 5] = "Block_Statements"; - ListParsingState[ListParsingState["TryBlock_Statements"] = 1 << 6] = "TryBlock_Statements"; - ListParsingState[ListParsingState["CatchBlock_Statements"] = 1 << 7] = "CatchBlock_Statements"; - ListParsingState[ListParsingState["EnumDeclaration_EnumElements"] = 1 << 8] = "EnumDeclaration_EnumElements"; - ListParsingState[ListParsingState["ObjectType_TypeMembers"] = 1 << 9] = "ObjectType_TypeMembers"; - ListParsingState[ListParsingState["ClassOrInterfaceDeclaration_HeritageClauses"] = 1 << 10] = "ClassOrInterfaceDeclaration_HeritageClauses"; - ListParsingState[ListParsingState["HeritageClause_TypeNameList"] = 1 << 11] = "HeritageClause_TypeNameList"; - ListParsingState[ListParsingState["VariableDeclaration_VariableDeclarators_AllowIn"] = 1 << 12] = "VariableDeclaration_VariableDeclarators_AllowIn"; - ListParsingState[ListParsingState["VariableDeclaration_VariableDeclarators_DisallowIn"] = 1 << 13] = "VariableDeclaration_VariableDeclarators_DisallowIn"; - ListParsingState[ListParsingState["ArgumentList_AssignmentExpressions"] = 1 << 14] = "ArgumentList_AssignmentExpressions"; - ListParsingState[ListParsingState["ObjectLiteralExpression_PropertyAssignments"] = 1 << 15] = "ObjectLiteralExpression_PropertyAssignments"; - ListParsingState[ListParsingState["ArrayLiteralExpression_AssignmentExpressions"] = 1 << 16] = "ArrayLiteralExpression_AssignmentExpressions"; - ListParsingState[ListParsingState["ParameterList_Parameters"] = 1 << 17] = "ParameterList_Parameters"; - ListParsingState[ListParsingState["TypeArgumentList_Types"] = 1 << 18] = "TypeArgumentList_Types"; - ListParsingState[ListParsingState["TypeParameterList_TypeParameters"] = 1 << 19] = "TypeParameterList_TypeParameters"; - - ListParsingState[ListParsingState["FirstListParsingState"] = ListParsingState.SourceUnit_ModuleElements] = "FirstListParsingState"; - ListParsingState[ListParsingState["LastListParsingState"] = ListParsingState.TypeArgumentList_Types] = "LastListParsingState"; - })(ListParsingState || (ListParsingState = {})); - - var SyntaxCursor = (function () { - function SyntaxCursor(sourceUnit) { - this._elements = []; - this._index = 0; - this._pinCount = 0; - sourceUnit.insertChildrenInto(this._elements, 0); - } - SyntaxCursor.prototype.isFinished = function () { - return this._index === this._elements.length; - }; - - SyntaxCursor.prototype.currentElement = function () { - if (this.isFinished()) { - return null; - } - - return this._elements[this._index]; - }; - - SyntaxCursor.prototype.currentNode = function () { - var element = this.currentElement(); - return element !== null && element.isNode() ? element : null; - }; - - SyntaxCursor.prototype.moveToFirstChild = function () { - if (this.isFinished()) { - return; - } - - var element = this._elements[this._index]; - if (element.isToken()) { - return; - } - - var node = element; - - this._elements.splice(this._index, 1); - - node.insertChildrenInto(this._elements, this._index); - }; - - SyntaxCursor.prototype.moveToNextSibling = function () { - if (this.isFinished()) { - return; - } - - if (this._pinCount > 0) { - this._index++; - return; - } - - this._elements.shift(); - }; - - SyntaxCursor.prototype.getAndPinCursorIndex = function () { - this._pinCount++; - return this._index; - }; - - SyntaxCursor.prototype.releaseAndUnpinCursorIndex = function (index) { - this._pinCount--; - if (this._pinCount === 0) { - } - }; - - SyntaxCursor.prototype.rewindToPinnedCursorIndex = function (index) { - this._index = index; - }; - - SyntaxCursor.prototype.pinCount = function () { - return this._pinCount; - }; - - SyntaxCursor.prototype.moveToFirstToken = function () { - var element; - - while (!this.isFinished()) { - element = this.currentElement(); - if (element.isNode()) { - this.moveToFirstChild(); - continue; - } - - return; - } - }; - - SyntaxCursor.prototype.currentToken = function () { - this.moveToFirstToken(); - if (this.isFinished()) { - return null; - } - - var element = this.currentElement(); - - return element; - }; - - SyntaxCursor.prototype.peekToken = function (n) { - this.moveToFirstToken(); - var pin = this.getAndPinCursorIndex(); - try { - for (var i = 0; i < n; i++) { - this.moveToNextSibling(); - this.moveToFirstToken(); - } - - return this.currentToken(); - } finally { - this.rewindToPinnedCursorIndex(pin); - this.releaseAndUnpinCursorIndex(pin); - } - }; - return SyntaxCursor; - })(); - - var NormalParserSource = (function () { - function NormalParserSource(fileName, text, languageVersion) { - this._previousToken = null; - this._absolutePosition = 0; - this._tokenDiagnostics = []; - this.rewindPointPool = []; - this.rewindPointPoolCount = 0; - this.slidingWindow = new TypeScript.SlidingWindow(this, TypeScript.ArrayUtilities.createArray(32, null), null); - this.scanner = new TypeScript.Scanner(fileName, text, languageVersion); - } - NormalParserSource.prototype.languageVersion = function () { - return this.scanner.languageVersion(); - }; - - NormalParserSource.prototype.currentNode = function () { - return null; - }; - - NormalParserSource.prototype.moveToNextNode = function () { - throw TypeScript.Errors.invalidOperation(); - }; - - NormalParserSource.prototype.absolutePosition = function () { - return this._absolutePosition; - }; - - NormalParserSource.prototype.previousToken = function () { - return this._previousToken; - }; - - NormalParserSource.prototype.tokenDiagnostics = function () { - return this._tokenDiagnostics; - }; - - NormalParserSource.prototype.getOrCreateRewindPoint = function () { - if (this.rewindPointPoolCount === 0) { - return {}; - } - - this.rewindPointPoolCount--; - var result = this.rewindPointPool[this.rewindPointPoolCount]; - this.rewindPointPool[this.rewindPointPoolCount] = null; - return result; - }; - - NormalParserSource.prototype.getRewindPoint = function () { - var slidingWindowIndex = this.slidingWindow.getAndPinAbsoluteIndex(); - - var rewindPoint = this.getOrCreateRewindPoint(); - - rewindPoint.slidingWindowIndex = slidingWindowIndex; - rewindPoint.previousToken = this._previousToken; - rewindPoint.absolutePosition = this._absolutePosition; - - rewindPoint.pinCount = this.slidingWindow.pinCount(); - - return rewindPoint; - }; - - NormalParserSource.prototype.isPinned = function () { - return this.slidingWindow.pinCount() > 0; - }; - - NormalParserSource.prototype.rewind = function (rewindPoint) { - this.slidingWindow.rewindToPinnedIndex(rewindPoint.slidingWindowIndex); - - this._previousToken = rewindPoint.previousToken; - this._absolutePosition = rewindPoint.absolutePosition; - }; - - NormalParserSource.prototype.releaseRewindPoint = function (rewindPoint) { - this.slidingWindow.releaseAndUnpinAbsoluteIndex((rewindPoint).absoluteIndex); - - this.rewindPointPool[this.rewindPointPoolCount] = rewindPoint; - this.rewindPointPoolCount++; - }; - - NormalParserSource.prototype.fetchMoreItems = function (allowRegularExpression, sourceIndex, window, destinationIndex, spaceAvailable) { - window[destinationIndex] = this.scanner.scan(this._tokenDiagnostics, allowRegularExpression); - return 1; - }; - - NormalParserSource.prototype.peekToken = function (n) { - return this.slidingWindow.peekItemN(n); - }; - - NormalParserSource.prototype.moveToNextToken = function () { - var currentToken = this.currentToken(); - this._absolutePosition += currentToken.fullWidth(); - this._previousToken = currentToken; - - this.slidingWindow.moveToNextItem(); - }; - - NormalParserSource.prototype.currentToken = function () { - return this.slidingWindow.currentItem(false); - }; - - NormalParserSource.prototype.removeDiagnosticsOnOrAfterPosition = function (position) { - var tokenDiagnosticsLength = this._tokenDiagnostics.length; - while (tokenDiagnosticsLength > 0) { - var diagnostic = this._tokenDiagnostics[tokenDiagnosticsLength - 1]; - if (diagnostic.start() >= position) { - tokenDiagnosticsLength--; - } else { - break; - } - } - - this._tokenDiagnostics.length = tokenDiagnosticsLength; - }; - - NormalParserSource.prototype.resetToPosition = function (absolutePosition, previousToken) { - this._absolutePosition = absolutePosition; - this._previousToken = previousToken; - - this.removeDiagnosticsOnOrAfterPosition(absolutePosition); - - this.slidingWindow.disgardAllItemsFromCurrentIndexOnwards(); - - this.scanner.setAbsoluteIndex(absolutePosition); - }; - - NormalParserSource.prototype.currentTokenAllowingRegularExpression = function () { - this.resetToPosition(this._absolutePosition, this._previousToken); - - var token = this.slidingWindow.currentItem(true); - - return token; - }; - return NormalParserSource; - })(); - - var IncrementalParserSource = (function () { - function IncrementalParserSource(oldSyntaxTree, textChangeRange, newText) { - this._changeDelta = 0; - var oldSourceUnit = oldSyntaxTree.sourceUnit(); - this._oldSourceUnitCursor = new SyntaxCursor(oldSourceUnit); - - this._changeRange = IncrementalParserSource.extendToAffectedRange(textChangeRange, oldSourceUnit); - - this._normalParserSource = new NormalParserSource(oldSyntaxTree.fileName(), newText, oldSyntaxTree.languageVersion()); - } - IncrementalParserSource.extendToAffectedRange = function (changeRange, sourceUnit) { - var maxLookahead = 1; - - var start = changeRange.span().start(); - - for (var i = 0; start > 0 && i <= maxLookahead; i++) { - var token = sourceUnit.findToken(start); - - var position = token.fullStart(); - - start = TypeScript.MathPrototype.max(0, position - 1); - } - - var finalSpan = TypeScript.TextSpan.fromBounds(start, changeRange.span().end()); - var finalLength = changeRange.newLength() + (changeRange.span().start() - start); - - return new TypeScript.TextChangeRange(finalSpan, finalLength); - }; - - IncrementalParserSource.prototype.languageVersion = function () { - return this._normalParserSource.languageVersion(); - }; - - IncrementalParserSource.prototype.absolutePosition = function () { - return this._normalParserSource.absolutePosition(); - }; - - IncrementalParserSource.prototype.previousToken = function () { - return this._normalParserSource.previousToken(); - }; - - IncrementalParserSource.prototype.tokenDiagnostics = function () { - return this._normalParserSource.tokenDiagnostics(); - }; - - IncrementalParserSource.prototype.getRewindPoint = function () { - var rewindPoint = this._normalParserSource.getRewindPoint(); - var oldSourceUnitCursorIndex = this._oldSourceUnitCursor.getAndPinCursorIndex(); - - rewindPoint.changeDelta = this._changeDelta; - rewindPoint.changeRange = this._changeRange; - rewindPoint.oldSourceUnitCursorIndex = oldSourceUnitCursorIndex; - - return rewindPoint; - }; - - IncrementalParserSource.prototype.rewind = function (rewindPoint) { - this._changeRange = rewindPoint.changeRange; - this._changeDelta = rewindPoint.changeDelta; - this._oldSourceUnitCursor.rewindToPinnedCursorIndex(rewindPoint.oldSourceUnitCursorIndex); - - this._normalParserSource.rewind(rewindPoint); - }; - - IncrementalParserSource.prototype.releaseRewindPoint = function (rewindPoint) { - this._oldSourceUnitCursor.releaseAndUnpinCursorIndex(rewindPoint.oldSourceUnitCursorIndex); - this._normalParserSource.releaseRewindPoint(rewindPoint); - }; - - IncrementalParserSource.prototype.canReadFromOldSourceUnit = function () { - if (this._normalParserSource.isPinned()) { - return false; - } - - if (this._changeRange !== null && this._changeRange.newSpan().intersectsWithPosition(this.absolutePosition())) { - return false; - } - - this.syncCursorToNewTextIfBehind(); - - return this._changeDelta === 0 && !this._oldSourceUnitCursor.isFinished(); - }; - - IncrementalParserSource.prototype.currentNode = function () { - if (this.canReadFromOldSourceUnit()) { - return this.tryGetNodeFromOldSourceUnit(); - } - - return null; - }; - - IncrementalParserSource.prototype.currentToken = function () { - if (this.canReadFromOldSourceUnit()) { - var token = this.tryGetTokenFromOldSourceUnit(); - if (token !== null) { - return token; - } - } - - return this._normalParserSource.currentToken(); - }; - - IncrementalParserSource.prototype.currentTokenAllowingRegularExpression = function () { - return this._normalParserSource.currentTokenAllowingRegularExpression(); - }; - - IncrementalParserSource.prototype.syncCursorToNewTextIfBehind = function () { - while (true) { - if (this._oldSourceUnitCursor.isFinished()) { - break; - } - - if (this._changeDelta >= 0) { - break; - } - - var currentElement = this._oldSourceUnitCursor.currentElement(); - - if (currentElement.isNode() && (currentElement.fullWidth() > Math.abs(this._changeDelta))) { - this._oldSourceUnitCursor.moveToFirstChild(); - } else { - this._oldSourceUnitCursor.moveToNextSibling(); - - this._changeDelta += currentElement.fullWidth(); - } - } - }; - - IncrementalParserSource.prototype.intersectsWithChangeRangeSpanInOriginalText = function (start, length) { - return this._changeRange !== null && this._changeRange.span().intersectsWith(start, length); - }; - - IncrementalParserSource.prototype.tryGetNodeFromOldSourceUnit = function () { - while (true) { - var node = this._oldSourceUnitCursor.currentNode(); - if (node === null) { - return null; - } - - if (!this.intersectsWithChangeRangeSpanInOriginalText(this.absolutePosition(), node.fullWidth())) { - if (!node.isIncrementallyUnusable()) { - return node; - } - } - - this._oldSourceUnitCursor.moveToFirstChild(); - } - }; - - IncrementalParserSource.prototype.canReuseTokenFromOldSourceUnit = function (position, token) { - if (token !== null) { - if (!this.intersectsWithChangeRangeSpanInOriginalText(position, token.fullWidth())) { - if (!token.isIncrementallyUnusable()) { - return true; - } - } - } - - return false; - }; - - IncrementalParserSource.prototype.tryGetTokenFromOldSourceUnit = function () { - var token = this._oldSourceUnitCursor.currentToken(); - - return this.canReuseTokenFromOldSourceUnit(this.absolutePosition(), token) ? token : null; - }; - - IncrementalParserSource.prototype.peekToken = function (n) { - if (this.canReadFromOldSourceUnit()) { - var token = this.tryPeekTokenFromOldSourceUnit(n); - if (token !== null) { - return token; - } - } - - return this._normalParserSource.peekToken(n); - }; - - IncrementalParserSource.prototype.tryPeekTokenFromOldSourceUnit = function (n) { - var currentPosition = this.absolutePosition(); - for (var i = 0; i < n; i++) { - var interimToken = this._oldSourceUnitCursor.peekToken(i); - if (!this.canReuseTokenFromOldSourceUnit(currentPosition, interimToken)) { - return null; - } - - currentPosition += interimToken.fullWidth(); - } - - var token = this._oldSourceUnitCursor.peekToken(n); - return this.canReuseTokenFromOldSourceUnit(currentPosition, token) ? token : null; - }; - - IncrementalParserSource.prototype.moveToNextNode = function () { - var currentElement = this._oldSourceUnitCursor.currentElement(); - var currentNode = this._oldSourceUnitCursor.currentNode(); - - this._oldSourceUnitCursor.moveToNextSibling(); - - var absolutePosition = this.absolutePosition() + currentNode.fullWidth(); - var previousToken = currentNode.lastToken(); - this._normalParserSource.resetToPosition(absolutePosition, previousToken); - - if (this._changeRange !== null) { - } - }; - - IncrementalParserSource.prototype.moveToNextToken = function () { - var currentToken = this.currentToken(); - - if (this._oldSourceUnitCursor.currentToken() === currentToken) { - this._oldSourceUnitCursor.moveToNextSibling(); - - var absolutePosition = this.absolutePosition() + currentToken.fullWidth(); - var previousToken = currentToken; - this._normalParserSource.resetToPosition(absolutePosition, previousToken); - - if (this._changeRange !== null) { - } - } else { - this._changeDelta -= currentToken.fullWidth(); - - this._normalParserSource.moveToNextToken(); - - if (this._changeRange !== null) { - var changeRangeSpanInNewText = this._changeRange.newSpan(); - if (this.absolutePosition() >= changeRangeSpanInNewText.end()) { - this._changeDelta += this._changeRange.newLength() - this._changeRange.span().length(); - this._changeRange = null; - } - } - } - }; - return IncrementalParserSource; - })(); - - var ParserImpl = (function () { - function ParserImpl(fileName, lineMap, source, parseOptions) { - this.listParsingState = 0; - this.isInStrictMode = false; - this.diagnostics = []; - this.factory = TypeScript.Syntax.normalModeFactory; - this.mergeTokensStorage = []; - this.arrayPool = []; - this.fileName = fileName; - this.lineMap = lineMap; - this.source = source; - this.parseOptions = parseOptions; - } - ParserImpl.prototype.getRewindPoint = function () { - var rewindPoint = this.source.getRewindPoint(); - - rewindPoint.diagnosticsCount = this.diagnostics.length; - - rewindPoint.isInStrictMode = this.isInStrictMode; - rewindPoint.listParsingState = this.listParsingState; - - return rewindPoint; - }; - - ParserImpl.prototype.rewind = function (rewindPoint) { - this.source.rewind(rewindPoint); - - this.diagnostics.length = rewindPoint.diagnosticsCount; - }; - - ParserImpl.prototype.releaseRewindPoint = function (rewindPoint) { - this.source.releaseRewindPoint(rewindPoint); - }; - - ParserImpl.prototype.currentTokenStart = function () { - return this.source.absolutePosition() + this.currentToken().leadingTriviaWidth(); - }; - - ParserImpl.prototype.previousTokenStart = function () { - if (this.previousToken() === null) { - return 0; - } - - return this.source.absolutePosition() - this.previousToken().fullWidth() + this.previousToken().leadingTriviaWidth(); - }; - - ParserImpl.prototype.previousTokenEnd = function () { - if (this.previousToken() === null) { - return 0; - } - - return this.previousTokenStart() + this.previousToken().width(); - }; - - ParserImpl.prototype.currentNode = function () { - var node = this.source.currentNode(); - - if (node === null || node.parsedInStrictMode() !== this.isInStrictMode) { - return null; - } - - return node; - }; - - ParserImpl.prototype.currentToken = function () { - return this.source.currentToken(); - }; - - ParserImpl.prototype.currentTokenAllowingRegularExpression = function () { - return this.source.currentTokenAllowingRegularExpression(); - }; - - ParserImpl.prototype.peekToken = function (n) { - return this.source.peekToken(n); - }; - - ParserImpl.prototype.eatAnyToken = function () { - var token = this.currentToken(); - this.moveToNextToken(); - return token; - }; - - ParserImpl.prototype.moveToNextToken = function () { - this.source.moveToNextToken(); - }; - - ParserImpl.prototype.previousToken = function () { - return this.source.previousToken(); - }; - - ParserImpl.prototype.eatNode = function () { - var node = this.source.currentNode(); - this.source.moveToNextNode(); - return node; - }; - - ParserImpl.prototype.eatToken = function (kind) { - var token = this.currentToken(); - if (token.tokenKind === kind) { - this.moveToNextToken(); - return token; - } - - return this.createMissingToken(kind, token); - }; - - ParserImpl.prototype.tryEatToken = function (kind) { - if (this.currentToken().tokenKind === kind) { - return this.eatToken(kind); - } - - return null; - }; - - ParserImpl.prototype.tryEatKeyword = function (kind) { - if (this.currentToken().tokenKind === kind) { - return this.eatKeyword(kind); - } - - return null; - }; - - ParserImpl.prototype.eatKeyword = function (kind) { - var token = this.currentToken(); - if (token.tokenKind === kind) { - this.moveToNextToken(); - return token; - } - - return this.createMissingToken(kind, token); - }; - - ParserImpl.prototype.isIdentifier = function (token) { - var tokenKind = token.tokenKind; - - if (tokenKind === 11 /* IdentifierName */) { - return true; - } - - if (tokenKind >= 51 /* FirstFutureReservedStrictKeyword */) { - if (tokenKind <= 59 /* LastFutureReservedStrictKeyword */) { - return !this.isInStrictMode; - } - - return tokenKind <= 70 /* LastTypeScriptKeyword */; - } - - return false; - }; - - ParserImpl.prototype.eatIdentifierNameToken = function () { - var token = this.currentToken(); - - if (token.tokenKind === 11 /* IdentifierName */) { - this.moveToNextToken(); - return token; - } - - if (TypeScript.SyntaxFacts.isAnyKeyword(token.tokenKind)) { - this.moveToNextToken(); - return TypeScript.Syntax.convertToIdentifierName(token); - } - - return this.createMissingToken(11 /* IdentifierName */, token); - }; - - ParserImpl.prototype.eatIdentifierToken = function () { - var token = this.currentToken(); - if (this.isIdentifier(token)) { - this.moveToNextToken(); - - if (token.tokenKind === 11 /* IdentifierName */) { - return token; - } - - return TypeScript.Syntax.convertToIdentifierName(token); - } - - return this.createMissingToken(11 /* IdentifierName */, token); - }; - - ParserImpl.prototype.canEatAutomaticSemicolon = function (allowWithoutNewLine) { - var token = this.currentToken(); - - if (token.tokenKind === 10 /* EndOfFileToken */) { - return true; - } - - if (token.tokenKind === 72 /* CloseBraceToken */) { - return true; - } - - if (allowWithoutNewLine) { - return true; - } - - if (this.previousToken() !== null && this.previousToken().hasTrailingNewLine()) { - return true; - } - - return false; - }; - - ParserImpl.prototype.canEatExplicitOrAutomaticSemicolon = function (allowWithoutNewline) { - var token = this.currentToken(); - - if (token.tokenKind === 79 /* SemicolonToken */) { - return true; - } - - return this.canEatAutomaticSemicolon(allowWithoutNewline); - }; - - ParserImpl.prototype.eatExplicitOrAutomaticSemicolon = function (allowWithoutNewline) { - var token = this.currentToken(); - - if (token.tokenKind === 79 /* SemicolonToken */) { - return this.eatToken(79 /* SemicolonToken */); - } - - if (this.canEatAutomaticSemicolon(allowWithoutNewline)) { - var semicolonToken = TypeScript.Syntax.emptyToken(79 /* SemicolonToken */); - - if (!this.parseOptions.allowAutomaticSemicolonInsertion()) { - this.addDiagnostic(new TypeScript.SyntaxDiagnostic(this.fileName, this.previousTokenEnd(), 0, 11 /* Automatic_semicolon_insertion_not_allowed */, null)); - } - - return semicolonToken; - } - - return this.eatToken(79 /* SemicolonToken */); - }; - - ParserImpl.prototype.isKeyword = function (kind) { - if (kind >= TypeScript.SyntaxKind.FirstKeyword) { - if (kind <= 50 /* LastFutureReservedKeyword */) { - return true; - } - - if (this.isInStrictMode) { - return kind <= 59 /* LastFutureReservedStrictKeyword */; - } - } - - return false; - }; - - ParserImpl.prototype.createMissingToken = function (expectedKind, actual) { - var diagnostic = this.getExpectedTokenDiagnostic(expectedKind, actual); - this.addDiagnostic(diagnostic); - - return TypeScript.Syntax.emptyToken(expectedKind); - }; - - ParserImpl.prototype.getExpectedTokenDiagnostic = function (expectedKind, actual) { - var token = this.currentToken(); - - if (TypeScript.SyntaxFacts.isAnyKeyword(expectedKind) || TypeScript.SyntaxFacts.isAnyPunctuation(expectedKind)) { - return new TypeScript.SyntaxDiagnostic(this.fileName, this.currentTokenStart(), token.width(), 9 /* _0_expected */, [TypeScript.SyntaxFacts.getText(expectedKind)]); - } else { - if (actual !== null && TypeScript.SyntaxFacts.isAnyKeyword(actual.tokenKind)) { - return new TypeScript.SyntaxDiagnostic(this.fileName, this.currentTokenStart(), token.width(), 10 /* Identifier_expected__0__is_a_keyword */, [TypeScript.SyntaxFacts.getText(actual.tokenKind)]); - } else { - return new TypeScript.SyntaxDiagnostic(this.fileName, this.currentTokenStart(), token.width(), 7 /* Identifier_expected */, null); - } - } - }; - - ParserImpl.getPrecedence = function (expressionKind) { - switch (expressionKind) { - case 172 /* CommaExpression */: - return 1 /* CommaExpressionPrecedence */; - - case 173 /* AssignmentExpression */: - case 174 /* AddAssignmentExpression */: - case 175 /* SubtractAssignmentExpression */: - case 176 /* MultiplyAssignmentExpression */: - case 177 /* DivideAssignmentExpression */: - case 178 /* ModuloAssignmentExpression */: - case 179 /* AndAssignmentExpression */: - case 180 /* ExclusiveOrAssignmentExpression */: - case 181 /* OrAssignmentExpression */: - case 182 /* LeftShiftAssignmentExpression */: - case 183 /* SignedRightShiftAssignmentExpression */: - case 184 /* UnsignedRightShiftAssignmentExpression */: - return 2 /* AssignmentExpressionPrecedence */; - - case 185 /* ConditionalExpression */: - return 3 /* ConditionalExpressionPrecedence */; - - case 186 /* LogicalOrExpression */: - return 5 /* LogicalOrExpressionPrecedence */; - - case 187 /* LogicalAndExpression */: - return 6 /* LogicalAndExpressionPrecedence */; - - case 188 /* BitwiseOrExpression */: - return 7 /* BitwiseOrExpressionPrecedence */; - - case 189 /* BitwiseExclusiveOrExpression */: - return 8 /* BitwiseExclusiveOrExpressionPrecedence */; - - case 190 /* BitwiseAndExpression */: - return 9 /* BitwiseAndExpressionPrecedence */; - - case 191 /* EqualsWithTypeConversionExpression */: - case 192 /* NotEqualsWithTypeConversionExpression */: - case 193 /* EqualsExpression */: - case 194 /* NotEqualsExpression */: - return 10 /* EqualityExpressionPrecedence */; - - case 195 /* LessThanExpression */: - case 196 /* GreaterThanExpression */: - case 197 /* LessThanOrEqualExpression */: - case 198 /* GreaterThanOrEqualExpression */: - case 199 /* InstanceOfExpression */: - case 200 /* InExpression */: - return 11 /* RelationalExpressionPrecedence */; - - case 201 /* LeftShiftExpression */: - case 202 /* SignedRightShiftExpression */: - case 203 /* UnsignedRightShiftExpression */: - return 12 /* ShiftExpressionPrecdence */; - - case 207 /* AddExpression */: - case 208 /* SubtractExpression */: - return 13 /* AdditiveExpressionPrecedence */; - - case 204 /* MultiplyExpression */: - case 205 /* DivideExpression */: - case 206 /* ModuloExpression */: - return 14 /* MultiplicativeExpressionPrecedence */; - - case 163 /* PlusExpression */: - case 164 /* NegateExpression */: - case 165 /* BitwiseNotExpression */: - case 166 /* LogicalNotExpression */: - case 169 /* DeleteExpression */: - case 170 /* TypeOfExpression */: - case 171 /* VoidExpression */: - case 167 /* PreIncrementExpression */: - case 168 /* PreDecrementExpression */: - return 15 /* UnaryExpressionPrecedence */; - } - - throw TypeScript.Errors.invalidOperation(); - }; - - ParserImpl.prototype.addSkippedTokenAfterNodeOrToken = function (nodeOrToken, skippedToken) { - if (nodeOrToken.isToken()) { - return this.addSkippedTokenAfterToken(nodeOrToken, skippedToken); - } else if (nodeOrToken.isNode()) { - return this.addSkippedTokenAfterNode(nodeOrToken, skippedToken); - } else { - throw TypeScript.Errors.invalidOperation(); - } - }; - - ParserImpl.prototype.addSkippedTokenAfterNode = function (node, skippedToken) { - var oldToken = node.lastToken(); - var newToken = this.addSkippedTokenAfterToken(oldToken, skippedToken); - - return node.replaceToken(oldToken, newToken); - }; - - ParserImpl.prototype.addSkippedTokensBeforeNode = function (node, skippedTokens) { - if (skippedTokens.length > 0) { - var oldToken = node.firstToken(); - var newToken = this.addSkippedTokensBeforeToken(oldToken, skippedTokens); - - return node.replaceToken(oldToken, newToken); - } - - return node; - }; - - ParserImpl.prototype.addSkippedTokensBeforeToken = function (token, skippedTokens) { - var leadingTrivia = []; - for (var i = 0, n = skippedTokens.length; i < n; i++) { - this.addSkippedTokenToTriviaArray(leadingTrivia, skippedTokens[i]); - } - - this.addTriviaTo(token.leadingTrivia(), leadingTrivia); - - this.returnArray(skippedTokens); - return token.withLeadingTrivia(TypeScript.Syntax.triviaList(leadingTrivia)); - }; - - ParserImpl.prototype.addSkippedTokensAfterToken = function (token, skippedTokens) { - if (skippedTokens.length === 0) { - this.returnArray(skippedTokens); - return token; - } - - var trailingTrivia = token.trailingTrivia().toArray(); - - for (var i = 0, n = skippedTokens.length; i < n; i++) { - this.addSkippedTokenToTriviaArray(trailingTrivia, skippedTokens[i]); - } - - this.returnArray(skippedTokens); - return token.withTrailingTrivia(TypeScript.Syntax.triviaList(trailingTrivia)); - }; - - ParserImpl.prototype.addSkippedTokenAfterToken = function (token, skippedToken) { - var trailingTrivia = token.trailingTrivia().toArray(); - this.addSkippedTokenToTriviaArray(trailingTrivia, skippedToken); - - return token.withTrailingTrivia(TypeScript.Syntax.triviaList(trailingTrivia)); - }; - - ParserImpl.prototype.addSkippedTokenToTriviaArray = function (array, skippedToken) { - this.addTriviaTo(skippedToken.leadingTrivia(), array); - - var trimmedToken = skippedToken.withLeadingTrivia(TypeScript.Syntax.emptyTriviaList).withTrailingTrivia(TypeScript.Syntax.emptyTriviaList); - array.push(TypeScript.Syntax.skippedTokenTrivia(trimmedToken)); - - this.addTriviaTo(skippedToken.trailingTrivia(), array); - }; - - ParserImpl.prototype.addTriviaTo = function (list, array) { - for (var i = 0, n = list.count(); i < n; i++) { - array.push(list.syntaxTriviaAt(i)); - } - }; - - ParserImpl.prototype.parseSyntaxTree = function (isDeclaration) { - var sourceUnit = this.parseSourceUnit(); - - var allDiagnostics = this.source.tokenDiagnostics().concat(this.diagnostics); - allDiagnostics.sort(function (a, b) { - return a.start() - b.start(); - }); - - return new TypeScript.SyntaxTree(sourceUnit, isDeclaration, allDiagnostics, this.fileName, this.lineMap, this.source.languageVersion(), this.parseOptions); - }; - - ParserImpl.prototype.setStrictMode = function (isInStrictMode) { - this.isInStrictMode = isInStrictMode; - this.factory = isInStrictMode ? TypeScript.Syntax.strictModeFactory : TypeScript.Syntax.normalModeFactory; - }; - - ParserImpl.prototype.parseSourceUnit = function () { - var savedIsInStrictMode = this.isInStrictMode; - - var result = this.parseSyntaxList(1 /* SourceUnit_ModuleElements */, ParserImpl.updateStrictModeState); - var moduleElements = result.list; - - this.setStrictMode(savedIsInStrictMode); - - var sourceUnit = this.factory.sourceUnit(moduleElements, this.currentToken()); - sourceUnit = this.addSkippedTokensBeforeNode(sourceUnit, result.skippedTokens); - - return sourceUnit; - }; - - ParserImpl.updateStrictModeState = function (parser, items) { - if (!parser.isInStrictMode) { - for (var i = 0; i < items.length; i++) { - var item = items[i]; - if (!TypeScript.SyntaxFacts.isDirectivePrologueElement(item)) { - return; - } - } - - parser.setStrictMode(TypeScript.SyntaxFacts.isUseStrictDirective(items[items.length - 1])); - } - }; - - ParserImpl.prototype.isModuleElement = function (inErrorRecovery) { - if (this.currentNode() !== null && this.currentNode().isModuleElement()) { - return true; - } - - return this.isImportDeclaration() || this.isExportAssignment() || this.isModuleDeclaration() || this.isInterfaceDeclaration() || this.isClassDeclaration() || this.isEnumDeclaration() || this.isStatement(inErrorRecovery); - }; - - ParserImpl.prototype.parseModuleElement = function () { - if (this.currentNode() !== null && this.currentNode().isModuleElement()) { - return this.eatNode(); - } - - if (this.isImportDeclaration()) { - return this.parseImportDeclaration(); - } else if (this.isExportAssignment()) { - return this.parseExportAssignment(); - } else if (this.isModuleDeclaration()) { - return this.parseModuleDeclaration(); - } else if (this.isInterfaceDeclaration()) { - return this.parseInterfaceDeclaration(); - } else if (this.isClassDeclaration()) { - return this.parseClassDeclaration(); - } else if (this.isEnumDeclaration()) { - return this.parseEnumDeclaration(); - } else if (this.isStatement(false)) { - return this.parseStatement(); - } else { - throw TypeScript.Errors.invalidOperation(); - } - }; - - ParserImpl.prototype.isImportDeclaration = function () { - return this.currentToken().tokenKind === 49 /* ImportKeyword */; - }; - - ParserImpl.prototype.parseImportDeclaration = function () { - var importKeyword = this.eatKeyword(49 /* ImportKeyword */); - var identifier = this.eatIdentifierToken(); - var equalsToken = this.eatToken(108 /* EqualsToken */); - var moduleReference = this.parseModuleReference(); - var semicolonToken = this.eatExplicitOrAutomaticSemicolon(false); - - return this.factory.importDeclaration(importKeyword, identifier, equalsToken, moduleReference, semicolonToken); - }; - - ParserImpl.prototype.isExportAssignment = function () { - return this.currentToken().tokenKind === 47 /* ExportKeyword */ && this.peekToken(1).tokenKind === 108 /* EqualsToken */; - }; - - ParserImpl.prototype.parseExportAssignment = function () { - var exportKeyword = this.eatKeyword(47 /* ExportKeyword */); - var equalsToken = this.eatToken(108 /* EqualsToken */); - var identifier = this.eatIdentifierToken(); - var semicolonToken = this.eatExplicitOrAutomaticSemicolon(false); - - return this.factory.exportAssignment(exportKeyword, equalsToken, identifier, semicolonToken); - }; - - ParserImpl.prototype.parseModuleReference = function () { - if (this.isExternalModuleReference()) { - return this.parseExternalModuleReference(); - } else { - return this.parseModuleNameModuleReference(); - } - }; - - ParserImpl.prototype.isExternalModuleReference = function () { - var token0 = this.currentToken(); - if (token0.tokenKind === 66 /* ModuleKeyword */ || token0.tokenKind === 67 /* RequireKeyword */) { - return this.peekToken(1).tokenKind === 73 /* OpenParenToken */; - } - - return false; - }; - - ParserImpl.prototype.parseExternalModuleReference = function () { - var moduleOrRequireKeyword = this.eatAnyToken(); - var openParenToken = this.eatToken(73 /* OpenParenToken */); - var stringLiteral = this.eatToken(14 /* StringLiteral */); - var closeParenToken = this.eatToken(74 /* CloseParenToken */); - - return this.factory.externalModuleReference(moduleOrRequireKeyword, openParenToken, stringLiteral, closeParenToken); - }; - - ParserImpl.prototype.parseModuleNameModuleReference = function () { - var name = this.parseName(); - return this.factory.moduleNameModuleReference(name); - }; - - ParserImpl.prototype.parseIdentifierName = function () { - var identifierName = this.eatIdentifierNameToken(); - return identifierName; - }; - - ParserImpl.prototype.isName = function () { - return this.isIdentifier(this.currentToken()); - }; - - ParserImpl.prototype.tryParseTypeArgumentList = function (inExpression) { - if (this.currentToken().kind() !== 81 /* LessThanToken */) { - return null; - } - - var lessThanToken; - var greaterThanToken; - var result; - var typeArguments; - - if (!inExpression) { - lessThanToken = this.eatToken(81 /* LessThanToken */); - - result = this.parseSeparatedSyntaxList(262144 /* TypeArgumentList_Types */); - typeArguments = result.list; - lessThanToken = this.addSkippedTokensAfterToken(lessThanToken, result.skippedTokens); - - greaterThanToken = this.eatToken(82 /* GreaterThanToken */); - - return this.factory.typeArgumentList(lessThanToken, typeArguments, greaterThanToken); - } - - var rewindPoint = this.getRewindPoint(); - try { - lessThanToken = this.eatToken(81 /* LessThanToken */); - - result = this.parseSeparatedSyntaxList(262144 /* TypeArgumentList_Types */); - typeArguments = result.list; - lessThanToken = this.addSkippedTokensAfterToken(lessThanToken, result.skippedTokens); - - greaterThanToken = this.eatToken(82 /* GreaterThanToken */); - - if (greaterThanToken.fullWidth() === 0 || !this.canFollowTypeArgumentListInExpression(this.currentToken().kind())) { - this.rewind(rewindPoint); - return null; - } - - return this.factory.typeArgumentList(lessThanToken, typeArguments, greaterThanToken); - } finally { - this.releaseRewindPoint(rewindPoint); - } - }; - - ParserImpl.prototype.canFollowTypeArgumentListInExpression = function (kind) { - switch (kind) { - case 73 /* OpenParenToken */: - case 77 /* DotToken */: - - case 74 /* CloseParenToken */: - case 76 /* CloseBracketToken */: - case 107 /* ColonToken */: - case 79 /* SemicolonToken */: - case 80 /* CommaToken */: - case 106 /* QuestionToken */: - case 85 /* EqualsEqualsToken */: - case 88 /* EqualsEqualsEqualsToken */: - case 87 /* ExclamationEqualsToken */: - case 89 /* ExclamationEqualsEqualsToken */: - case 104 /* AmpersandAmpersandToken */: - case 105 /* BarBarToken */: - case 101 /* CaretToken */: - case 99 /* AmpersandToken */: - case 100 /* BarToken */: - case 72 /* CloseBraceToken */: - case 10 /* EndOfFileToken */: - return true; - - default: - return false; - } - }; - - ParserImpl.prototype.parseName = function () { - var shouldContinue = this.isIdentifier(this.currentToken()); - var current = this.eatIdentifierToken(); - - while (shouldContinue && this.currentToken().tokenKind === 77 /* DotToken */) { - var dotToken = this.eatToken(77 /* DotToken */); - - var currentToken = this.currentToken(); - var identifierName; - - if (TypeScript.SyntaxFacts.isAnyKeyword(currentToken.tokenKind) && this.previousToken().hasTrailingNewLine() && !currentToken.hasTrailingNewLine() && TypeScript.SyntaxFacts.isIdentifierNameOrAnyKeyword(this.peekToken(1))) { - identifierName = this.createMissingToken(11 /* IdentifierName */, currentToken); - } else { - identifierName = this.eatIdentifierNameToken(); - } - - current = this.factory.qualifiedName(current, dotToken, identifierName); - - shouldContinue = identifierName.fullWidth() > 0; - } - - return current; - }; - - ParserImpl.prototype.isEnumDeclaration = function () { - var index = this.modifierCount(); - - if (index > 0 && this.peekToken(index).tokenKind === 46 /* EnumKeyword */) { - return true; - } - - return this.currentToken().tokenKind === 46 /* EnumKeyword */ && this.isIdentifier(this.peekToken(1)); - }; - - ParserImpl.prototype.parseEnumDeclaration = function () { - var modifiers = this.parseModifiers(); - var enumKeyword = this.eatKeyword(46 /* EnumKeyword */); - var identifier = this.eatIdentifierToken(); - - var openBraceToken = this.eatToken(71 /* OpenBraceToken */); - var enumElements = TypeScript.Syntax.emptySeparatedList; - - if (openBraceToken.width() > 0) { - var result = this.parseSeparatedSyntaxList(256 /* EnumDeclaration_EnumElements */); - enumElements = result.list; - openBraceToken = this.addSkippedTokensAfterToken(openBraceToken, result.skippedTokens); - } - - var closeBraceToken = this.eatToken(72 /* CloseBraceToken */); - - return this.factory.enumDeclaration(modifiers, enumKeyword, identifier, openBraceToken, enumElements, closeBraceToken); - }; - - ParserImpl.prototype.isEnumElement = function (inErrorRecovery) { - if (this.currentNode() !== null && this.currentNode().kind() === 243 /* EnumElement */) { - return true; - } - - return this.isPropertyName(this.currentToken(), inErrorRecovery); - }; - - ParserImpl.prototype.parseEnumElement = function () { - if (this.currentNode() !== null && this.currentNode().kind() === 243 /* EnumElement */) { - return this.eatNode(); - } - - var propertyName = this.eatPropertyName(); - var equalsValueClause = null; - if (this.isEqualsValueClause(false)) { - equalsValueClause = this.parseEqualsValueClause(true); - } - - return this.factory.enumElement(propertyName, equalsValueClause); - }; - - ParserImpl.isModifier = function (token) { - switch (token.tokenKind) { - case 57 /* PublicKeyword */: - case 55 /* PrivateKeyword */: - case 58 /* StaticKeyword */: - case 47 /* ExportKeyword */: - case 64 /* DeclareKeyword */: - return true; - - default: - return false; - } - }; - - ParserImpl.prototype.modifierCount = function () { - var modifierCount = 0; - while (true) { - if (ParserImpl.isModifier(this.peekToken(modifierCount))) { - modifierCount++; - continue; - } - - break; - } - - return modifierCount; - }; - - ParserImpl.prototype.parseModifiers = function () { - var tokens = this.getArray(); - - while (true) { - if (ParserImpl.isModifier(this.currentToken())) { - tokens.push(this.eatAnyToken()); - continue; - } - - break; - } - - var result = TypeScript.Syntax.list(tokens); - - this.returnZeroOrOneLengthArray(tokens); - - return result; - }; - - ParserImpl.prototype.isClassDeclaration = function () { - var index = this.modifierCount(); - - if (index > 0 && this.peekToken(index).tokenKind === 44 /* ClassKeyword */) { - return true; - } - - return this.currentToken().tokenKind === 44 /* ClassKeyword */ && this.isIdentifier(this.peekToken(1)); - }; - - ParserImpl.prototype.parseHeritageClauses = function () { - var heritageClauses = TypeScript.Syntax.emptyList; - - if (this.isHeritageClause()) { - var result = this.parseSyntaxList(1024 /* ClassOrInterfaceDeclaration_HeritageClauses */); - heritageClauses = result.list; - TypeScript.Debug.assert(result.skippedTokens.length === 0); - } - - return heritageClauses; - }; - - ParserImpl.prototype.parseClassDeclaration = function () { - var modifiers = this.parseModifiers(); - - var classKeyword = this.eatKeyword(44 /* ClassKeyword */); - var identifier = this.eatIdentifierToken(); - var typeParameterList = this.parseOptionalTypeParameterList(false); - var heritageClauses = this.parseHeritageClauses(); - var openBraceToken = this.eatToken(71 /* OpenBraceToken */); - var classElements = TypeScript.Syntax.emptyList; - - if (openBraceToken.width() > 0) { - var result = this.parseSyntaxList(2 /* ClassDeclaration_ClassElements */); - - classElements = result.list; - openBraceToken = this.addSkippedTokensAfterToken(openBraceToken, result.skippedTokens); - } - - var closeBraceToken = this.eatToken(72 /* CloseBraceToken */); - return this.factory.classDeclaration(modifiers, classKeyword, identifier, typeParameterList, heritageClauses, openBraceToken, classElements, closeBraceToken); - }; - - ParserImpl.prototype.isConstructorDeclaration = function () { - return this.currentToken().tokenKind === 63 /* ConstructorKeyword */; - }; - - ParserImpl.isPublicOrPrivateKeyword = function (token) { - return token.tokenKind === 57 /* PublicKeyword */ || token.tokenKind === 55 /* PrivateKeyword */; - }; - - ParserImpl.prototype.isMemberAccessorDeclaration = function (inErrorRecovery) { - var index = this.modifierCount(); - - if (this.peekToken(index).tokenKind !== 65 /* GetKeyword */ && this.peekToken(index).tokenKind !== 69 /* SetKeyword */) { - return false; - } - - index++; - return this.isPropertyName(this.peekToken(index), inErrorRecovery); - }; - - ParserImpl.prototype.parseMemberAccessorDeclaration = function () { - var modifiers = this.parseModifiers(); - - if (this.currentToken().tokenKind === 65 /* GetKeyword */) { - return this.parseGetMemberAccessorDeclaration(modifiers); - } else if (this.currentToken().tokenKind === 69 /* SetKeyword */) { - return this.parseSetMemberAccessorDeclaration(modifiers); - } else { - throw TypeScript.Errors.invalidOperation(); - } - }; - - ParserImpl.prototype.parseGetMemberAccessorDeclaration = function (modifiers) { - var getKeyword = this.eatKeyword(65 /* GetKeyword */); - var propertyName = this.eatPropertyName(); - var parameterList = this.parseParameterList(); - var typeAnnotation = this.parseOptionalTypeAnnotation(false); - var block = this.parseBlock(false, false); - - return this.factory.getMemberAccessorDeclaration(modifiers, getKeyword, propertyName, parameterList, typeAnnotation, block); - }; - - ParserImpl.prototype.parseSetMemberAccessorDeclaration = function (modifiers) { - var setKeyword = this.eatKeyword(69 /* SetKeyword */); - var propertyName = this.eatPropertyName(); - var parameterList = this.parseParameterList(); - var block = this.parseBlock(false, false); - - return this.factory.setMemberAccessorDeclaration(modifiers, setKeyword, propertyName, parameterList, block); - }; - - ParserImpl.prototype.isClassElement = function (inErrorRecovery) { - if (this.currentNode() !== null && this.currentNode().isClassElement()) { - return true; - } - - return this.isConstructorDeclaration() || this.isMemberFunctionDeclaration(inErrorRecovery) || this.isMemberAccessorDeclaration(inErrorRecovery) || this.isMemberVariableDeclaration(inErrorRecovery) || this.isIndexSignature(); - }; - - ParserImpl.prototype.parseConstructorDeclaration = function () { - var constructorKeyword = this.eatKeyword(63 /* ConstructorKeyword */); - var parameterList = this.parseParameterList(); - - var semicolonToken = null; - var block = null; - - if (this.isBlock()) { - block = this.parseBlock(false, true); - } else { - semicolonToken = this.eatExplicitOrAutomaticSemicolon(false); - } - - return this.factory.constructorDeclaration(constructorKeyword, parameterList, block, semicolonToken); - }; - - ParserImpl.prototype.isMemberFunctionDeclaration = function (inErrorRecovery) { - var index = 0; - - while (true) { - var token = this.peekToken(index); - if (this.isPropertyName(token, inErrorRecovery) && this.isCallSignature(index + 1)) { - return true; - } - - if (ParserImpl.isModifier(token)) { - index++; - continue; - } - - return false; - } - }; - - ParserImpl.prototype.parseMemberFunctionDeclaration = function () { - var modifierArray = this.getArray(); - - while (true) { - var currentToken = this.currentToken(); - if (this.isPropertyName(currentToken, false) && this.isCallSignature(1)) { - break; - } - - TypeScript.Debug.assert(ParserImpl.isModifier(currentToken)); - modifierArray.push(this.eatAnyToken()); - } - - var modifiers = TypeScript.Syntax.list(modifierArray); - this.returnZeroOrOneLengthArray(modifierArray); - - var propertyName = this.eatPropertyName(); - var callSignature = this.parseCallSignature(false); - - var newCallSignature = this.tryAddUnexpectedEqualsGreaterThanToken(callSignature); - var parseBlockEvenWithNoOpenBrace = callSignature !== newCallSignature; - callSignature = newCallSignature; - - var block = null; - var semicolon = null; - - if (parseBlockEvenWithNoOpenBrace || this.isBlock()) { - block = this.parseBlock(parseBlockEvenWithNoOpenBrace, true); - } else { - semicolon = this.eatExplicitOrAutomaticSemicolon(false); - } - - return this.factory.memberFunctionDeclaration(modifiers, propertyName, callSignature, block, semicolon); - }; - - ParserImpl.prototype.isDefinitelyMemberVariablePropertyName = function (index) { - if (TypeScript.SyntaxFacts.isAnyKeyword(this.peekToken(index).tokenKind)) { - switch (this.peekToken(index + 1).tokenKind) { - case 79 /* SemicolonToken */: - case 108 /* EqualsToken */: - case 107 /* ColonToken */: - case 72 /* CloseBraceToken */: - case 10 /* EndOfFileToken */: - return true; - default: - return false; - } - } else { - return true; - } - }; - - ParserImpl.prototype.isMemberVariableDeclaration = function (inErrorRecovery) { - var index = 0; - - while (true) { - var token = this.peekToken(index); - if (this.isPropertyName(token, inErrorRecovery) && this.isDefinitelyMemberVariablePropertyName(index)) { - return true; - } - - if (ParserImpl.isModifier(this.peekToken(index))) { - index++; - continue; - } - - return false; - } - }; - - ParserImpl.prototype.parseMemberVariableDeclaration = function () { - var modifierArray = this.getArray(); - - while (true) { - var currentToken = this.currentToken(); - if (this.isPropertyName(currentToken, false) && this.isDefinitelyMemberVariablePropertyName(0)) { - break; - } - - TypeScript.Debug.assert(ParserImpl.isModifier(currentToken)); - modifierArray.push(this.eatAnyToken()); - } - - var modifiers = TypeScript.Syntax.list(modifierArray); - this.returnZeroOrOneLengthArray(modifierArray); - - var variableDeclarator = this.parseVariableDeclarator(true, true); - var semicolon = this.eatExplicitOrAutomaticSemicolon(false); - - return this.factory.memberVariableDeclaration(modifiers, variableDeclarator, semicolon); - }; - - ParserImpl.prototype.parseClassElement = function (inErrorRecovery) { - if (this.currentNode() !== null && this.currentNode().isClassElement()) { - return this.eatNode(); - } - - if (this.isConstructorDeclaration()) { - return this.parseConstructorDeclaration(); - } else if (this.isMemberFunctionDeclaration(inErrorRecovery)) { - return this.parseMemberFunctionDeclaration(); - } else if (this.isMemberAccessorDeclaration(inErrorRecovery)) { - return this.parseMemberAccessorDeclaration(); - } else if (this.isMemberVariableDeclaration(inErrorRecovery)) { - return this.parseMemberVariableDeclaration(); - } else if (this.isIndexSignature()) { - return this.parseIndexSignature(); - } else { - throw TypeScript.Errors.invalidOperation(); - } - }; - - ParserImpl.prototype.tryAddUnexpectedEqualsGreaterThanToken = function (callSignature) { - var token0 = this.currentToken(); - - var hasEqualsGreaterThanToken = token0.tokenKind === 86 /* EqualsGreaterThanToken */; - if (hasEqualsGreaterThanToken) { - var diagnostic = new TypeScript.SyntaxDiagnostic(this.fileName, this.currentTokenStart(), token0.width(), 16 /* Unexpected_token_ */, []); - this.addDiagnostic(diagnostic); - - var token = this.eatAnyToken(); - return this.addSkippedTokenAfterNode(callSignature, token0); - } - - return callSignature; - }; - - ParserImpl.prototype.isFunctionDeclaration = function () { - var index = this.modifierCount(); - return this.peekToken(index).tokenKind === 27 /* FunctionKeyword */; - }; - - ParserImpl.prototype.parseFunctionDeclaration = function () { - var modifiers = this.parseModifiers(); - var functionKeyword = this.eatKeyword(27 /* FunctionKeyword */); - var identifier = this.eatIdentifierToken(); - var callSignature = this.parseCallSignature(false); - - var newCallSignature = this.tryAddUnexpectedEqualsGreaterThanToken(callSignature); - var parseBlockEvenWithNoOpenBrace = callSignature !== newCallSignature; - callSignature = newCallSignature; - - var semicolonToken = null; - var block = null; - - if (parseBlockEvenWithNoOpenBrace || this.isBlock()) { - block = this.parseBlock(parseBlockEvenWithNoOpenBrace, true); - } else { - semicolonToken = this.eatExplicitOrAutomaticSemicolon(false); - } - - return this.factory.functionDeclaration(modifiers, functionKeyword, identifier, callSignature, block, semicolonToken); - }; - - ParserImpl.prototype.isModuleDeclaration = function () { - var index = this.modifierCount(); - - if (index > 0 && this.peekToken(index).tokenKind === 66 /* ModuleKeyword */) { - return true; - } - - if (this.currentToken().tokenKind === 66 /* ModuleKeyword */) { - var token1 = this.peekToken(1); - return this.isIdentifier(token1) || token1.tokenKind === 14 /* StringLiteral */; - } - - return false; - }; - - ParserImpl.prototype.parseModuleDeclaration = function () { - var modifiers = this.parseModifiers(); - var moduleKeyword = this.eatKeyword(66 /* ModuleKeyword */); - - var moduleName = null; - var stringLiteral = null; - - if (this.currentToken().tokenKind === 14 /* StringLiteral */) { - stringLiteral = this.eatToken(14 /* StringLiteral */); - } else { - moduleName = this.parseName(); - } - - var openBraceToken = this.eatToken(71 /* OpenBraceToken */); - - var moduleElements = TypeScript.Syntax.emptyList; - if (openBraceToken.width() > 0) { - var result = this.parseSyntaxList(4 /* ModuleDeclaration_ModuleElements */); - moduleElements = result.list; - openBraceToken = this.addSkippedTokensAfterToken(openBraceToken, result.skippedTokens); - } - - var closeBraceToken = this.eatToken(72 /* CloseBraceToken */); - - return this.factory.moduleDeclaration(modifiers, moduleKeyword, moduleName, stringLiteral, openBraceToken, moduleElements, closeBraceToken); - }; - - ParserImpl.prototype.isInterfaceDeclaration = function () { - var index = this.modifierCount(); - - if (index > 0 && this.peekToken(index).tokenKind === 52 /* InterfaceKeyword */) { - return true; - } - - return this.currentToken().tokenKind === 52 /* InterfaceKeyword */ && this.isIdentifier(this.peekToken(1)); - }; - - ParserImpl.prototype.parseInterfaceDeclaration = function () { - var modifiers = this.parseModifiers(); - var interfaceKeyword = this.eatKeyword(52 /* InterfaceKeyword */); - var identifier = this.eatIdentifierToken(); - var typeParameterList = this.parseOptionalTypeParameterList(false); - var heritageClauses = this.parseHeritageClauses(); - - var objectType = this.parseObjectType(); - return this.factory.interfaceDeclaration(modifiers, interfaceKeyword, identifier, typeParameterList, heritageClauses, objectType); - }; - - ParserImpl.prototype.parseObjectType = function () { - var openBraceToken = this.eatToken(71 /* OpenBraceToken */); - - var typeMembers = TypeScript.Syntax.emptySeparatedList; - if (openBraceToken.width() > 0) { - var result = this.parseSeparatedSyntaxList(512 /* ObjectType_TypeMembers */); - typeMembers = result.list; - openBraceToken = this.addSkippedTokensAfterToken(openBraceToken, result.skippedTokens); - } - - var closeBraceToken = this.eatToken(72 /* CloseBraceToken */); - return this.factory.objectType(openBraceToken, typeMembers, closeBraceToken); - }; - - ParserImpl.prototype.isTypeMember = function (inErrorRecovery) { - if (this.currentNode() !== null && this.currentNode().isTypeMember()) { - return true; - } - - return this.isCallSignature(0) || this.isConstructSignature() || this.isIndexSignature() || this.isMethodSignature(inErrorRecovery) || this.isPropertySignature(inErrorRecovery); - }; - - ParserImpl.prototype.parseTypeMember = function () { - if (this.currentNode() !== null && this.currentNode().isTypeMember()) { - return this.eatNode(); - } - - if (this.isCallSignature(0)) { - return this.parseCallSignature(false); - } else if (this.isConstructSignature()) { - return this.parseConstructSignature(); - } else if (this.isIndexSignature()) { - return this.parseIndexSignature(); - } else if (this.isMethodSignature(false)) { - return this.parseMethodSignature(); - } else if (this.isPropertySignature(false)) { - return this.parsePropertySignature(); - } else { - throw TypeScript.Errors.invalidOperation(); - } - }; - - ParserImpl.prototype.parseConstructSignature = function () { - var newKeyword = this.eatKeyword(31 /* NewKeyword */); - var callSignature = this.parseCallSignature(false); - - return this.factory.constructSignature(newKeyword, callSignature); - }; - - ParserImpl.prototype.parseIndexSignature = function () { - var openBracketToken = this.eatToken(75 /* OpenBracketToken */); - var parameter = this.parseParameter(); - var closeBracketToken = this.eatToken(76 /* CloseBracketToken */); - var typeAnnotation = this.parseOptionalTypeAnnotation(false); - - return this.factory.indexSignature(openBracketToken, parameter, closeBracketToken, typeAnnotation); - }; - - ParserImpl.prototype.parseMethodSignature = function () { - var propertyName = this.eatPropertyName(); - var questionToken = this.tryEatToken(106 /* QuestionToken */); - var callSignature = this.parseCallSignature(false); - - return this.factory.methodSignature(propertyName, questionToken, callSignature); - }; - - ParserImpl.prototype.parsePropertySignature = function () { - var propertyName = this.eatPropertyName(); - var questionToken = this.tryEatToken(106 /* QuestionToken */); - var typeAnnotation = this.parseOptionalTypeAnnotation(false); - - return this.factory.propertySignature(propertyName, questionToken, typeAnnotation); - }; - - ParserImpl.prototype.isCallSignature = function (tokenIndex) { - var tokenKind = this.peekToken(tokenIndex).tokenKind; - return tokenKind === 73 /* OpenParenToken */ || tokenKind === 81 /* LessThanToken */; - }; - - ParserImpl.prototype.isConstructSignature = function () { - if (this.currentToken().tokenKind !== 31 /* NewKeyword */) { - return false; - } - - var token1 = this.peekToken(1); - return token1.tokenKind === 81 /* LessThanToken */ || token1.tokenKind === 73 /* OpenParenToken */; - }; - - ParserImpl.prototype.isIndexSignature = function () { - return this.currentToken().tokenKind === 75 /* OpenBracketToken */; - }; - - ParserImpl.prototype.isMethodSignature = function (inErrorRecovery) { - if (this.isPropertyName(this.currentToken(), inErrorRecovery)) { - if (this.isCallSignature(1)) { - return true; - } - - if (this.peekToken(1).tokenKind === 106 /* QuestionToken */ && this.isCallSignature(2)) { - return true; - } - } - - return false; - }; - - ParserImpl.prototype.isPropertySignature = function (inErrorRecovery) { - var currentToken = this.currentToken(); - - if (ParserImpl.isModifier(currentToken) && !currentToken.hasTrailingNewLine() && this.isPropertyName(this.peekToken(1), inErrorRecovery)) { - return false; - } - - return this.isPropertyName(currentToken, inErrorRecovery); - }; - - ParserImpl.prototype.isHeritageClause = function () { - var token0 = this.currentToken(); - return token0.tokenKind === 48 /* ExtendsKeyword */ || token0.tokenKind === 51 /* ImplementsKeyword */; - }; - - ParserImpl.prototype.isNotHeritageClauseTypeName = function () { - if (this.currentToken().tokenKind === 51 /* ImplementsKeyword */ || this.currentToken().tokenKind === 48 /* ExtendsKeyword */) { - return this.isIdentifier(this.peekToken(1)); - } - - return false; - }; - - ParserImpl.prototype.isHeritageClauseTypeName = function () { - if (this.isName()) { - return !this.isNotHeritageClauseTypeName(); - } - - return false; - }; - - ParserImpl.prototype.parseHeritageClause = function () { - var extendsOrImplementsKeyword = this.eatAnyToken(); - TypeScript.Debug.assert(extendsOrImplementsKeyword.tokenKind === 48 /* ExtendsKeyword */ || extendsOrImplementsKeyword.tokenKind === 51 /* ImplementsKeyword */); - - var result = this.parseSeparatedSyntaxList(2048 /* HeritageClause_TypeNameList */); - var typeNames = result.list; - extendsOrImplementsKeyword = this.addSkippedTokensAfterToken(extendsOrImplementsKeyword, result.skippedTokens); - - return this.factory.heritageClause(extendsOrImplementsKeyword, typeNames); - }; - - ParserImpl.prototype.isStatement = function (inErrorRecovery) { - if (this.currentNode() !== null && this.currentNode().isStatement()) { - return true; - } - - switch (this.currentToken().tokenKind) { - case 57 /* PublicKeyword */: - case 55 /* PrivateKeyword */: - case 58 /* StaticKeyword */: - var token1 = this.peekToken(1); - if (TypeScript.SyntaxFacts.isIdentifierNameOrAnyKeyword(token1)) { - return false; - } - } - - return this.isVariableStatement() || this.isLabeledStatement() || this.isFunctionDeclaration() || this.isIfStatement() || this.isBlock() || this.isExpressionStatement() || this.isReturnStatement() || this.isSwitchStatement() || this.isThrowStatement() || this.isBreakStatement() || this.isContinueStatement() || this.isForOrForInStatement() || this.isEmptyStatement(inErrorRecovery) || this.isWhileStatement() || this.isWithStatement() || this.isDoStatement() || this.isTryStatement() || this.isDebuggerStatement(); - }; - - ParserImpl.prototype.parseStatement = function () { - if (this.currentNode() !== null && this.currentNode().isStatement()) { - return this.eatNode(); - } - - if (this.isVariableStatement()) { - return this.parseVariableStatement(); - } else if (this.isLabeledStatement()) { - return this.parseLabeledStatement(); - } else if (this.isFunctionDeclaration()) { - return this.parseFunctionDeclaration(); - } else if (this.isIfStatement()) { - return this.parseIfStatement(); - } else if (this.isBlock()) { - return this.parseBlock(false, false); - } else if (this.isReturnStatement()) { - return this.parseReturnStatement(); - } else if (this.isSwitchStatement()) { - return this.parseSwitchStatement(); - } else if (this.isThrowStatement()) { - return this.parseThrowStatement(); - } else if (this.isBreakStatement()) { - return this.parseBreakStatement(); - } else if (this.isContinueStatement()) { - return this.parseContinueStatement(); - } else if (this.isForOrForInStatement()) { - return this.parseForOrForInStatement(); - } else if (this.isEmptyStatement(false)) { - return this.parseEmptyStatement(); - } else if (this.isWhileStatement()) { - return this.parseWhileStatement(); - } else if (this.isWithStatement()) { - return this.parseWithStatement(); - } else if (this.isDoStatement()) { - return this.parseDoStatement(); - } else if (this.isTryStatement()) { - return this.parseTryStatement(); - } else if (this.isDebuggerStatement()) { - return this.parseDebuggerStatement(); - } else { - return this.parseExpressionStatement(); - } - }; - - ParserImpl.prototype.isDebuggerStatement = function () { - return this.currentToken().tokenKind === 19 /* DebuggerKeyword */; - }; - - ParserImpl.prototype.parseDebuggerStatement = function () { - var debuggerKeyword = this.eatKeyword(19 /* DebuggerKeyword */); - var semicolonToken = this.eatExplicitOrAutomaticSemicolon(false); - - return this.factory.debuggerStatement(debuggerKeyword, semicolonToken); - }; - - ParserImpl.prototype.isDoStatement = function () { - return this.currentToken().tokenKind === 22 /* DoKeyword */; - }; - - ParserImpl.prototype.parseDoStatement = function () { - var doKeyword = this.eatKeyword(22 /* DoKeyword */); - var statement = this.parseStatement(); - var whileKeyword = this.eatKeyword(42 /* WhileKeyword */); - var openParenToken = this.eatToken(73 /* OpenParenToken */); - var condition = this.parseExpression(true); - var closeParenToken = this.eatToken(74 /* CloseParenToken */); - - var semicolonToken = this.eatExplicitOrAutomaticSemicolon(true); - - return this.factory.doStatement(doKeyword, statement, whileKeyword, openParenToken, condition, closeParenToken, semicolonToken); - }; - - ParserImpl.prototype.isLabeledStatement = function () { - return this.isIdentifier(this.currentToken()) && this.peekToken(1).tokenKind === 107 /* ColonToken */; - }; - - ParserImpl.prototype.parseLabeledStatement = function () { - var identifier = this.eatIdentifierToken(); - var colonToken = this.eatToken(107 /* ColonToken */); - var statement = this.parseStatement(); - - return this.factory.labeledStatement(identifier, colonToken, statement); - }; - - ParserImpl.prototype.isTryStatement = function () { - return this.currentToken().tokenKind === 38 /* TryKeyword */; - }; - - ParserImpl.prototype.parseTryStatement = function () { - var tryKeyword = this.eatKeyword(38 /* TryKeyword */); - - var savedListParsingState = this.listParsingState; - this.listParsingState |= 64 /* TryBlock_Statements */; - var block = this.parseBlock(false, false); - this.listParsingState = savedListParsingState; - - var catchClause = null; - if (this.isCatchClause()) { - catchClause = this.parseCatchClause(); - } - - var finallyClause = null; - if (catchClause === null || this.isFinallyClause()) { - finallyClause = this.parseFinallyClause(); - } - - return this.factory.tryStatement(tryKeyword, block, catchClause, finallyClause); - }; - - ParserImpl.prototype.isCatchClause = function () { - return this.currentToken().tokenKind === 17 /* CatchKeyword */; - }; - - ParserImpl.prototype.parseCatchClause = function () { - var catchKeyword = this.eatKeyword(17 /* CatchKeyword */); - var openParenToken = this.eatToken(73 /* OpenParenToken */); - var identifier = this.eatIdentifierToken(); - var typeAnnotation = this.parseOptionalTypeAnnotation(false); - var closeParenToken = this.eatToken(74 /* CloseParenToken */); - - var savedListParsingState = this.listParsingState; - this.listParsingState |= 128 /* CatchBlock_Statements */; - var block = this.parseBlock(false, false); - this.listParsingState = savedListParsingState; - - return this.factory.catchClause(catchKeyword, openParenToken, identifier, typeAnnotation, closeParenToken, block); - }; - - ParserImpl.prototype.isFinallyClause = function () { - return this.currentToken().tokenKind === 25 /* FinallyKeyword */; - }; - - ParserImpl.prototype.parseFinallyClause = function () { - var finallyKeyword = this.eatKeyword(25 /* FinallyKeyword */); - var block = this.parseBlock(false, false); - - return this.factory.finallyClause(finallyKeyword, block); - }; - - ParserImpl.prototype.isWithStatement = function () { - return this.currentToken().tokenKind === 43 /* WithKeyword */; - }; - - ParserImpl.prototype.parseWithStatement = function () { - var withKeyword = this.eatKeyword(43 /* WithKeyword */); - var openParenToken = this.eatToken(73 /* OpenParenToken */); - var condition = this.parseExpression(true); - var closeParenToken = this.eatToken(74 /* CloseParenToken */); - var statement = this.parseStatement(); - - return this.factory.withStatement(withKeyword, openParenToken, condition, closeParenToken, statement); - }; - - ParserImpl.prototype.isWhileStatement = function () { - return this.currentToken().tokenKind === 42 /* WhileKeyword */; - }; - - ParserImpl.prototype.parseWhileStatement = function () { - var whileKeyword = this.eatKeyword(42 /* WhileKeyword */); - var openParenToken = this.eatToken(73 /* OpenParenToken */); - var condition = this.parseExpression(true); - var closeParenToken = this.eatToken(74 /* CloseParenToken */); - var statement = this.parseStatement(); - - return this.factory.whileStatement(whileKeyword, openParenToken, condition, closeParenToken, statement); - }; - - ParserImpl.prototype.isEmptyStatement = function (inErrorRecovery) { - if (inErrorRecovery) { - return false; - } - - return this.currentToken().tokenKind === 79 /* SemicolonToken */; - }; - - ParserImpl.prototype.parseEmptyStatement = function () { - var semicolonToken = this.eatToken(79 /* SemicolonToken */); - return this.factory.emptyStatement(semicolonToken); - }; - - ParserImpl.prototype.isForOrForInStatement = function () { - return this.currentToken().tokenKind === 26 /* ForKeyword */; - }; - - ParserImpl.prototype.parseForOrForInStatement = function () { - var forKeyword = this.eatKeyword(26 /* ForKeyword */); - var openParenToken = this.eatToken(73 /* OpenParenToken */); - - var currentToken = this.currentToken(); - if (currentToken.tokenKind === 40 /* VarKeyword */) { - return this.parseForOrForInStatementWithVariableDeclaration(forKeyword, openParenToken); - } else if (currentToken.tokenKind === 79 /* SemicolonToken */) { - return this.parseForStatement(forKeyword, openParenToken); - } else { - return this.parseForOrForInStatementWithInitializer(forKeyword, openParenToken); - } - }; - - ParserImpl.prototype.parseForOrForInStatementWithVariableDeclaration = function (forKeyword, openParenToken) { - var variableDeclaration = this.parseVariableDeclaration(false); - - if (this.currentToken().tokenKind === 29 /* InKeyword */) { - return this.parseForInStatementWithVariableDeclarationOrInitializer(forKeyword, openParenToken, variableDeclaration, null); - } - - return this.parseForStatementWithVariableDeclarationOrInitializer(forKeyword, openParenToken, variableDeclaration, null); - }; - - ParserImpl.prototype.parseForInStatementWithVariableDeclarationOrInitializer = function (forKeyword, openParenToken, variableDeclaration, initializer) { - var inKeyword = this.eatKeyword(29 /* InKeyword */); - var expression = this.parseExpression(true); - var closeParenToken = this.eatToken(74 /* CloseParenToken */); - var statement = this.parseStatement(); - - return this.factory.forInStatement(forKeyword, openParenToken, variableDeclaration, initializer, inKeyword, expression, closeParenToken, statement); - }; - - ParserImpl.prototype.parseForOrForInStatementWithInitializer = function (forKeyword, openParenToken) { - var initializer = this.parseExpression(false); - if (this.currentToken().tokenKind === 29 /* InKeyword */) { - return this.parseForInStatementWithVariableDeclarationOrInitializer(forKeyword, openParenToken, null, initializer); - } else { - return this.parseForStatementWithVariableDeclarationOrInitializer(forKeyword, openParenToken, null, initializer); - } - }; - - ParserImpl.prototype.parseForStatement = function (forKeyword, openParenToken) { - var initializer = null; - - if (this.currentToken().tokenKind !== 79 /* SemicolonToken */ && this.currentToken().tokenKind !== 74 /* CloseParenToken */ && this.currentToken().tokenKind !== 10 /* EndOfFileToken */) { - initializer = this.parseExpression(false); - } - - return this.parseForStatementWithVariableDeclarationOrInitializer(forKeyword, openParenToken, null, initializer); - }; - - ParserImpl.prototype.parseForStatementWithVariableDeclarationOrInitializer = function (forKeyword, openParenToken, variableDeclaration, initializer) { - var firstSemicolonToken = this.eatToken(79 /* SemicolonToken */); - - var condition = null; - if (this.currentToken().tokenKind !== 79 /* SemicolonToken */ && this.currentToken().tokenKind !== 74 /* CloseParenToken */ && this.currentToken().tokenKind !== 10 /* EndOfFileToken */) { - condition = this.parseExpression(true); - } - - var secondSemicolonToken = this.eatToken(79 /* SemicolonToken */); - - var incrementor = null; - if (this.currentToken().tokenKind !== 74 /* CloseParenToken */ && this.currentToken().tokenKind !== 10 /* EndOfFileToken */) { - incrementor = this.parseExpression(true); - } - - var closeParenToken = this.eatToken(74 /* CloseParenToken */); - var statement = this.parseStatement(); - - return this.factory.forStatement(forKeyword, openParenToken, variableDeclaration, initializer, firstSemicolonToken, condition, secondSemicolonToken, incrementor, closeParenToken, statement); - }; - - ParserImpl.prototype.isBreakStatement = function () { - return this.currentToken().tokenKind === 15 /* BreakKeyword */; - }; - - ParserImpl.prototype.parseBreakStatement = function () { - var breakKeyword = this.eatKeyword(15 /* BreakKeyword */); - - var identifier = null; - if (!this.canEatExplicitOrAutomaticSemicolon(false)) { - if (this.isIdentifier(this.currentToken())) { - identifier = this.eatIdentifierToken(); - } - } - - var semicolon = this.eatExplicitOrAutomaticSemicolon(false); - return this.factory.breakStatement(breakKeyword, identifier, semicolon); - }; - - ParserImpl.prototype.isContinueStatement = function () { - return this.currentToken().tokenKind === 18 /* ContinueKeyword */; - }; - - ParserImpl.prototype.parseContinueStatement = function () { - var continueKeyword = this.eatKeyword(18 /* ContinueKeyword */); - - var identifier = null; - if (!this.canEatExplicitOrAutomaticSemicolon(false)) { - if (this.isIdentifier(this.currentToken())) { - identifier = this.eatIdentifierToken(); - } - } - - var semicolon = this.eatExplicitOrAutomaticSemicolon(false); - return this.factory.continueStatement(continueKeyword, identifier, semicolon); - }; - - ParserImpl.prototype.isSwitchStatement = function () { - return this.currentToken().tokenKind === 34 /* SwitchKeyword */; - }; - - ParserImpl.prototype.parseSwitchStatement = function () { - var switchKeyword = this.eatKeyword(34 /* SwitchKeyword */); - var openParenToken = this.eatToken(73 /* OpenParenToken */); - var expression = this.parseExpression(true); - var closeParenToken = this.eatToken(74 /* CloseParenToken */); - - var openBraceToken = this.eatToken(71 /* OpenBraceToken */); - - var switchClauses = TypeScript.Syntax.emptyList; - if (openBraceToken.width() > 0) { - var result = this.parseSyntaxList(8 /* SwitchStatement_SwitchClauses */); - switchClauses = result.list; - openBraceToken = this.addSkippedTokensAfterToken(openBraceToken, result.skippedTokens); - } - - var closeBraceToken = this.eatToken(72 /* CloseBraceToken */); - return this.factory.switchStatement(switchKeyword, openParenToken, expression, closeParenToken, openBraceToken, switchClauses, closeBraceToken); - }; - - ParserImpl.prototype.isCaseSwitchClause = function () { - return this.currentToken().tokenKind === 16 /* CaseKeyword */; - }; - - ParserImpl.prototype.isDefaultSwitchClause = function () { - return this.currentToken().tokenKind === 20 /* DefaultKeyword */; - }; - - ParserImpl.prototype.isSwitchClause = function () { - if (this.currentNode() !== null && this.currentNode().isSwitchClause()) { - return true; - } - - return this.isCaseSwitchClause() || this.isDefaultSwitchClause(); - }; - - ParserImpl.prototype.parseSwitchClause = function () { - if (this.currentNode() !== null && this.currentNode().isSwitchClause()) { - return this.eatNode(); - } - - if (this.isCaseSwitchClause()) { - return this.parseCaseSwitchClause(); - } else if (this.isDefaultSwitchClause()) { - return this.parseDefaultSwitchClause(); - } else { - throw TypeScript.Errors.invalidOperation(); - } - }; - - ParserImpl.prototype.parseCaseSwitchClause = function () { - var caseKeyword = this.eatKeyword(16 /* CaseKeyword */); - var expression = this.parseExpression(true); - var colonToken = this.eatToken(107 /* ColonToken */); - var statements = TypeScript.Syntax.emptyList; - - if (colonToken.fullWidth() > 0) { - var result = this.parseSyntaxList(16 /* SwitchClause_Statements */); - statements = result.list; - colonToken = this.addSkippedTokensAfterToken(colonToken, result.skippedTokens); - } - - return this.factory.caseSwitchClause(caseKeyword, expression, colonToken, statements); - }; - - ParserImpl.prototype.parseDefaultSwitchClause = function () { - var defaultKeyword = this.eatKeyword(20 /* DefaultKeyword */); - var colonToken = this.eatToken(107 /* ColonToken */); - var statements = TypeScript.Syntax.emptyList; - - if (colonToken.fullWidth() > 0) { - var result = this.parseSyntaxList(16 /* SwitchClause_Statements */); - statements = result.list; - colonToken = this.addSkippedTokensAfterToken(colonToken, result.skippedTokens); - } - - return this.factory.defaultSwitchClause(defaultKeyword, colonToken, statements); - }; - - ParserImpl.prototype.isThrowStatement = function () { - return this.currentToken().tokenKind === 36 /* ThrowKeyword */; - }; - - ParserImpl.prototype.parseThrowStatement = function () { - var throwKeyword = this.eatKeyword(36 /* ThrowKeyword */); - - var expression = null; - if (this.canEatExplicitOrAutomaticSemicolon(false)) { - var token = this.createMissingToken(11 /* IdentifierName */, null); - expression = token; - } else { - expression = this.parseExpression(true); - } - - var semicolonToken = this.eatExplicitOrAutomaticSemicolon(false); - - return this.factory.throwStatement(throwKeyword, expression, semicolonToken); - }; - - ParserImpl.prototype.isReturnStatement = function () { - return this.currentToken().tokenKind === 33 /* ReturnKeyword */; - }; - - ParserImpl.prototype.parseReturnStatement = function () { - var returnKeyword = this.eatKeyword(33 /* ReturnKeyword */); - - var expression = null; - if (!this.canEatExplicitOrAutomaticSemicolon(false)) { - expression = this.parseExpression(true); - } - - var semicolonToken = this.eatExplicitOrAutomaticSemicolon(false); - - return this.factory.returnStatement(returnKeyword, expression, semicolonToken); - }; - - ParserImpl.prototype.isExpressionStatement = function () { - var currentToken = this.currentToken(); - - var kind = currentToken.tokenKind; - if (kind === 71 /* OpenBraceToken */ || kind === 27 /* FunctionKeyword */) { - return false; - } - - return this.isExpression(); - }; - - ParserImpl.prototype.isAssignmentOrOmittedExpression = function () { - if (this.currentToken().tokenKind === 80 /* CommaToken */) { - return true; - } - - return this.isExpression(); - }; - - ParserImpl.prototype.parseAssignmentOrOmittedExpression = function () { - if (this.currentToken().tokenKind === 80 /* CommaToken */) { - return this.factory.omittedExpression(); - } - - return this.parseAssignmentExpression(true); - }; - - ParserImpl.prototype.isExpression = function () { - var currentToken = this.currentToken(); - var kind = currentToken.tokenKind; - - switch (kind) { - case 13 /* NumericLiteral */: - case 14 /* StringLiteral */: - case 12 /* RegularExpressionLiteral */: - return true; - - case 75 /* OpenBracketToken */: - case 73 /* OpenParenToken */: - return true; - - case 81 /* LessThanToken */: - return true; - - case 94 /* PlusPlusToken */: - case 95 /* MinusMinusToken */: - case 90 /* PlusToken */: - case 91 /* MinusToken */: - case 103 /* TildeToken */: - case 102 /* ExclamationToken */: - return true; - - case 71 /* OpenBraceToken */: - return true; - - case 86 /* EqualsGreaterThanToken */: - return true; - - case 119 /* SlashToken */: - case 120 /* SlashEqualsToken */: - return true; - - case 50 /* SuperKeyword */: - case 35 /* ThisKeyword */: - case 37 /* TrueKeyword */: - case 24 /* FalseKeyword */: - case 32 /* NullKeyword */: - return true; - - case 31 /* NewKeyword */: - return true; - - case 21 /* DeleteKeyword */: - case 41 /* VoidKeyword */: - case 39 /* TypeOfKeyword */: - return true; - - case 27 /* FunctionKeyword */: - return true; - } - - if (this.isIdentifier(this.currentToken())) { - return true; - } - - return false; - }; - - ParserImpl.prototype.parseExpressionStatement = function () { - var expression = this.parseExpression(true); - - var semicolon = this.eatExplicitOrAutomaticSemicolon(false); - - return this.factory.expressionStatement(expression, semicolon); - }; - - ParserImpl.prototype.isIfStatement = function () { - return this.currentToken().tokenKind === 28 /* IfKeyword */; - }; - - ParserImpl.prototype.parseIfStatement = function () { - var ifKeyword = this.eatKeyword(28 /* IfKeyword */); - var openParenToken = this.eatToken(73 /* OpenParenToken */); - var condition = this.parseExpression(true); - var closeParenToken = this.eatToken(74 /* CloseParenToken */); - var statement = this.parseStatement(); - - var elseClause = null; - if (this.isElseClause()) { - elseClause = this.parseElseClause(); - } - - return this.factory.ifStatement(ifKeyword, openParenToken, condition, closeParenToken, statement, elseClause); - }; - - ParserImpl.prototype.isElseClause = function () { - return this.currentToken().tokenKind === 23 /* ElseKeyword */; - }; - - ParserImpl.prototype.parseElseClause = function () { - var elseKeyword = this.eatKeyword(23 /* ElseKeyword */); - var statement = this.parseStatement(); - - return this.factory.elseClause(elseKeyword, statement); - }; - - ParserImpl.prototype.isVariableStatement = function () { - var index = this.modifierCount(); - return this.peekToken(index).tokenKind === 40 /* VarKeyword */; - }; - - ParserImpl.prototype.parseVariableStatement = function () { - var modifiers = this.parseModifiers(); - var variableDeclaration = this.parseVariableDeclaration(true); - var semicolonToken = this.eatExplicitOrAutomaticSemicolon(false); - - return this.factory.variableStatement(modifiers, variableDeclaration, semicolonToken); - }; - - ParserImpl.prototype.parseVariableDeclaration = function (allowIn) { - var varKeyword = this.eatKeyword(40 /* VarKeyword */); - - var listParsingState = allowIn ? 4096 /* VariableDeclaration_VariableDeclarators_AllowIn */ : 8192 /* VariableDeclaration_VariableDeclarators_DisallowIn */; - - var result = this.parseSeparatedSyntaxList(listParsingState); - var variableDeclarators = result.list; - varKeyword = this.addSkippedTokensAfterToken(varKeyword, result.skippedTokens); - - return this.factory.variableDeclaration(varKeyword, variableDeclarators); - }; - - ParserImpl.prototype.isVariableDeclarator = function () { - if (this.currentNode() !== null && this.currentNode().kind() === 224 /* VariableDeclarator */) { - return true; - } - - return this.isIdentifier(this.currentToken()); - }; - - ParserImpl.prototype.canReuseVariableDeclaratorNode = function (node) { - if (node === null || node.kind() !== 224 /* VariableDeclarator */) { - return false; - } - - var variableDeclarator = node; - return variableDeclarator.equalsValueClause === null; - }; - - ParserImpl.prototype.parseVariableDeclarator = function (allowIn, allowPropertyName) { - if (this.canReuseVariableDeclaratorNode(this.currentNode())) { - return this.eatNode(); - } - - var propertyName = allowPropertyName ? this.eatPropertyName() : this.eatIdentifierToken(); - var equalsValueClause = null; - var typeAnnotation = null; - - if (propertyName.width() > 0) { - typeAnnotation = this.parseOptionalTypeAnnotation(false); - - if (this.isEqualsValueClause(false)) { - equalsValueClause = this.parseEqualsValueClause(allowIn); - } - } - - return this.factory.variableDeclarator(propertyName, typeAnnotation, equalsValueClause); - }; - - ParserImpl.prototype.isColonValueClause = function () { - return this.currentToken().tokenKind === 107 /* ColonToken */; - }; - - ParserImpl.prototype.isEqualsValueClause = function (inParameter) { - var token0 = this.currentToken(); - if (token0.tokenKind === 108 /* EqualsToken */) { - return true; - } - - if (!this.previousToken().hasTrailingNewLine()) { - if (token0.tokenKind === 86 /* EqualsGreaterThanToken */) { - return false; - } - - if (token0.tokenKind === 71 /* OpenBraceToken */ && inParameter) { - return false; - } - - return this.isExpression(); - } - - return false; - }; - - ParserImpl.prototype.parseEqualsValueClause = function (allowIn) { - var equalsToken = this.eatToken(108 /* EqualsToken */); - var value = this.parseAssignmentExpression(allowIn); - - return this.factory.equalsValueClause(equalsToken, value); - }; - - ParserImpl.prototype.parseExpression = function (allowIn) { - return this.parseSubExpression(0, allowIn); - }; - - ParserImpl.prototype.parseAssignmentExpression = function (allowIn) { - return this.parseSubExpression(2 /* AssignmentExpressionPrecedence */, allowIn); - }; - - ParserImpl.prototype.parseUnaryExpression = function () { - var currentTokenKind = this.currentToken().tokenKind; - if (TypeScript.SyntaxFacts.isPrefixUnaryExpressionOperatorToken(currentTokenKind)) { - var operatorKind = TypeScript.SyntaxFacts.getPrefixUnaryExpressionFromOperatorToken(currentTokenKind); - - var operatorToken = this.eatAnyToken(); - - var operand = this.parseUnaryExpression(); - return this.factory.prefixUnaryExpression(operatorKind, operatorToken, operand); - } else { - return this.parseTerm(false); - } - }; - - ParserImpl.prototype.parseSubExpression = function (precedence, allowIn) { - var leftOperand = this.parseUnaryExpression(); - leftOperand = this.parseBinaryOrConditionalExpressions(precedence, allowIn, leftOperand); - - return leftOperand; - }; - - ParserImpl.prototype.parseBinaryOrConditionalExpressions = function (precedence, allowIn, leftOperand) { - while (true) { - var token0 = this.currentToken(); - var token0Kind = token0.tokenKind; - - if (TypeScript.SyntaxFacts.isBinaryExpressionOperatorToken(token0Kind)) { - if (token0Kind === 29 /* InKeyword */ && !allowIn) { - break; - } - - var mergedToken = this.tryMergeBinaryExpressionTokens(); - var tokenKind = mergedToken === null ? token0Kind : mergedToken.syntaxKind; - - var binaryExpressionKind = TypeScript.SyntaxFacts.getBinaryExpressionFromOperatorToken(tokenKind); - var newPrecedence = ParserImpl.getPrecedence(binaryExpressionKind); - - if (newPrecedence < precedence) { - break; - } - - if (newPrecedence === precedence && !this.isRightAssociative(binaryExpressionKind)) { - break; - } - - var operatorToken = mergedToken === null ? token0 : TypeScript.Syntax.token(mergedToken.syntaxKind).withLeadingTrivia(token0.leadingTrivia()).withTrailingTrivia(this.peekToken(mergedToken.tokenCount - 1).trailingTrivia()); - - var skipCount = mergedToken === null ? 1 : mergedToken.tokenCount; - for (var i = 0; i < skipCount; i++) { - this.eatAnyToken(); - } - - leftOperand = this.factory.binaryExpression(binaryExpressionKind, leftOperand, operatorToken, this.parseSubExpression(newPrecedence, allowIn)); - continue; - } - - if (token0Kind === 106 /* QuestionToken */ && precedence <= 3 /* ConditionalExpressionPrecedence */) { - var questionToken = this.eatToken(106 /* QuestionToken */); - - var whenTrueExpression = this.parseAssignmentExpression(allowIn); - var colon = this.eatToken(107 /* ColonToken */); - - var whenFalseExpression = this.parseAssignmentExpression(allowIn); - leftOperand = this.factory.conditionalExpression(leftOperand, questionToken, whenTrueExpression, colon, whenFalseExpression); - continue; - } - - break; - } - - return leftOperand; - }; - - ParserImpl.prototype.tryMergeBinaryExpressionTokens = function () { - var token0 = this.currentToken(); - - if (token0.tokenKind === 82 /* GreaterThanToken */ && !token0.hasTrailingTrivia()) { - var storage = this.mergeTokensStorage; - storage[0] = 0 /* None */; - storage[1] = 0 /* None */; - storage[2] = 0 /* None */; - - for (var i = 0; i < storage.length; i++) { - var nextToken = this.peekToken(i + 1); - - if (!nextToken.hasLeadingTrivia()) { - storage[i] = nextToken.tokenKind; - } - - if (nextToken.hasTrailingTrivia()) { - break; - } - } - - if (storage[0] === 82 /* GreaterThanToken */) { - if (storage[1] === 82 /* GreaterThanToken */) { - if (storage[2] === 108 /* EqualsToken */) { - return { tokenCount: 4, syntaxKind: 115 /* GreaterThanGreaterThanGreaterThanEqualsToken */ }; - } else { - return { tokenCount: 3, syntaxKind: 98 /* GreaterThanGreaterThanGreaterThanToken */ }; - } - } else if (storage[1] === 108 /* EqualsToken */) { - return { tokenCount: 3, syntaxKind: 114 /* GreaterThanGreaterThanEqualsToken */ }; - } else { - return { tokenCount: 2, syntaxKind: 97 /* GreaterThanGreaterThanToken */ }; - } - } else if (storage[0] === 108 /* EqualsToken */) { - return { tokenCount: 2, syntaxKind: 84 /* GreaterThanEqualsToken */ }; - } - } - - return null; - }; - - ParserImpl.prototype.isRightAssociative = function (expressionKind) { - switch (expressionKind) { - case 173 /* AssignmentExpression */: - case 174 /* AddAssignmentExpression */: - case 175 /* SubtractAssignmentExpression */: - case 176 /* MultiplyAssignmentExpression */: - case 177 /* DivideAssignmentExpression */: - case 178 /* ModuloAssignmentExpression */: - case 179 /* AndAssignmentExpression */: - case 180 /* ExclusiveOrAssignmentExpression */: - case 181 /* OrAssignmentExpression */: - case 182 /* LeftShiftAssignmentExpression */: - case 183 /* SignedRightShiftAssignmentExpression */: - case 184 /* UnsignedRightShiftAssignmentExpression */: - return true; - default: - return false; - } - }; - - ParserImpl.prototype.parseTerm = function (inObjectCreation) { - var term = this.parseTermWorker(); - if (term === null) { - return this.eatIdentifierToken(); - } - - return this.parsePostFixExpression(term, inObjectCreation); - }; - - ParserImpl.prototype.parsePostFixExpression = function (expression, inObjectCreation) { - while (true) { - var currentTokenKind = this.currentToken().tokenKind; - switch (currentTokenKind) { - case 73 /* OpenParenToken */: - if (inObjectCreation) { - return expression; - } - - expression = this.factory.invocationExpression(expression, this.parseArgumentList(null)); - continue; - - case 81 /* LessThanToken */: - if (inObjectCreation) { - return expression; - } - - var argumentList = this.tryParseArgumentList(); - if (argumentList !== null) { - expression = this.factory.invocationExpression(expression, argumentList); - continue; - } - - break; - - case 75 /* OpenBracketToken */: - expression = this.parseElementAccessExpression(expression, inObjectCreation); - continue; - - case 94 /* PlusPlusToken */: - case 95 /* MinusMinusToken */: - if (this.previousToken() !== null && this.previousToken().hasTrailingNewLine()) { - break; - } - - expression = this.factory.postfixUnaryExpression(TypeScript.SyntaxFacts.getPostfixUnaryExpressionFromOperatorToken(currentTokenKind), expression, this.eatAnyToken()); - continue; - - case 77 /* DotToken */: - expression = this.factory.memberAccessExpression(expression, this.eatToken(77 /* DotToken */), this.eatIdentifierNameToken()); - continue; - } - - return expression; - } - }; - - ParserImpl.prototype.tryParseArgumentList = function () { - var typeArgumentList = null; - - if (this.currentToken().tokenKind === 81 /* LessThanToken */) { - var rewindPoint = this.getRewindPoint(); - try { - typeArgumentList = this.tryParseTypeArgumentList(true); - var token0 = this.currentToken(); - - var isOpenParen = token0.tokenKind === 73 /* OpenParenToken */; - var isDot = token0.tokenKind === 77 /* DotToken */; - var isOpenParenOrDot = isOpenParen || isDot; - if (typeArgumentList === null || !isOpenParenOrDot) { - this.rewind(rewindPoint); - return null; - } - - if (isDot) { - var diagnostic = new TypeScript.SyntaxDiagnostic(this.fileName, this.currentTokenStart(), token0.width(), 138 /* A_parameter_list_must_follow_a_generic_type_argument_list______expected */, null); - this.addDiagnostic(diagnostic); - - return this.factory.argumentList(typeArgumentList, TypeScript.Syntax.emptyToken(73 /* OpenParenToken */), TypeScript.Syntax.emptySeparatedList, TypeScript.Syntax.emptyToken(74 /* CloseParenToken */)); - } - } finally { - this.releaseRewindPoint(rewindPoint); - } - } - - if (this.currentToken().tokenKind === 73 /* OpenParenToken */) { - return this.parseArgumentList(typeArgumentList); - } - - return null; - }; - - ParserImpl.prototype.parseArgumentList = function (typeArgumentList) { - var openParenToken = this.eatToken(73 /* OpenParenToken */); - var arguments = TypeScript.Syntax.emptySeparatedList; - - if (openParenToken.fullWidth() > 0) { - var result = this.parseSeparatedSyntaxList(16384 /* ArgumentList_AssignmentExpressions */); - arguments = result.list; - openParenToken = this.addSkippedTokensAfterToken(openParenToken, result.skippedTokens); - } - - var closeParenToken = this.eatToken(74 /* CloseParenToken */); - - return this.factory.argumentList(typeArgumentList, openParenToken, arguments, closeParenToken); - }; - - ParserImpl.prototype.parseElementAccessExpression = function (expression, inObjectCreation) { - var start = this.currentTokenStart(); - var openBracketToken = this.eatToken(75 /* OpenBracketToken */); - var argumentExpression; - - if (this.currentToken().tokenKind === 76 /* CloseBracketToken */ && inObjectCreation) { - var end = this.currentTokenStart() + this.currentToken().width(); - var diagnostic = new TypeScript.SyntaxDiagnostic(this.fileName, start, end - start, 137 /* _new_T____cannot_be_used_to_create_an_array__Use__new_Array_T_____instead */, null); - this.addDiagnostic(diagnostic); - - argumentExpression = TypeScript.Syntax.emptyToken(11 /* IdentifierName */); - } else { - argumentExpression = this.parseExpression(true); - } - - var closeBracketToken = this.eatToken(76 /* CloseBracketToken */); - - return this.factory.elementAccessExpression(expression, openBracketToken, argumentExpression, closeBracketToken); - }; - - ParserImpl.prototype.parseTermWorker = function () { - var currentToken = this.currentToken(); - - if (currentToken.tokenKind === 86 /* EqualsGreaterThanToken */) { - return this.parseSimpleArrowFunctionExpression(); - } - - if (this.isIdentifier(currentToken)) { - if (this.isSimpleArrowFunctionExpression()) { - return this.parseSimpleArrowFunctionExpression(); - } else { - var identifier = this.eatIdentifierToken(); - return identifier; - } - } - - var currentTokenKind = currentToken.tokenKind; - switch (currentTokenKind) { - case 35 /* ThisKeyword */: - return this.parseThisExpression(); - - case 37 /* TrueKeyword */: - case 24 /* FalseKeyword */: - return this.parseLiteralExpression(); - - case 32 /* NullKeyword */: - return this.parseLiteralExpression(); - - case 31 /* NewKeyword */: - return this.parseObjectCreationExpression(); - - case 27 /* FunctionKeyword */: - return this.parseFunctionExpression(); - - case 50 /* SuperKeyword */: - return this.parseSuperExpression(); - - case 39 /* TypeOfKeyword */: - return this.parseTypeOfExpression(); - - case 21 /* DeleteKeyword */: - return this.parseDeleteExpression(); - - case 41 /* VoidKeyword */: - return this.parseVoidExpression(); - - case 13 /* NumericLiteral */: - return this.parseLiteralExpression(); - - case 12 /* RegularExpressionLiteral */: - return this.parseLiteralExpression(); - - case 14 /* StringLiteral */: - return this.parseLiteralExpression(); - - case 75 /* OpenBracketToken */: - return this.parseArrayLiteralExpression(); - - case 71 /* OpenBraceToken */: - return this.parseObjectLiteralExpression(); - - case 73 /* OpenParenToken */: - return this.parseParenthesizedOrArrowFunctionExpression(); - - case 81 /* LessThanToken */: - return this.parseCastOrArrowFunctionExpression(); - - case 119 /* SlashToken */: - case 120 /* SlashEqualsToken */: - var result = this.tryReparseDivideAsRegularExpression(); - if (result !== null) { - return result; - } - break; - } - - return null; - }; - - ParserImpl.prototype.tryReparseDivideAsRegularExpression = function () { - var currentToken = this.currentToken(); - - if (this.previousToken() !== null) { - var previousTokenKind = this.previousToken().tokenKind; - switch (previousTokenKind) { - case 11 /* IdentifierName */: - return null; - - case 35 /* ThisKeyword */: - case 37 /* TrueKeyword */: - case 24 /* FalseKeyword */: - return null; - - case 14 /* StringLiteral */: - case 13 /* NumericLiteral */: - case 12 /* RegularExpressionLiteral */: - case 94 /* PlusPlusToken */: - case 95 /* MinusMinusToken */: - case 76 /* CloseBracketToken */: - case 72 /* CloseBraceToken */: - return null; - } - } - - currentToken = this.currentTokenAllowingRegularExpression(); - - if (currentToken.tokenKind === 119 /* SlashToken */ || currentToken.tokenKind === 120 /* SlashEqualsToken */) { - return null; - } else if (currentToken.tokenKind === 12 /* RegularExpressionLiteral */) { - return this.parseLiteralExpression(); - } else { - throw TypeScript.Errors.invalidOperation(); - } - }; - - ParserImpl.prototype.parseTypeOfExpression = function () { - var typeOfKeyword = this.eatKeyword(39 /* TypeOfKeyword */); - var expression = this.parseUnaryExpression(); - - return this.factory.typeOfExpression(typeOfKeyword, expression); - }; - - ParserImpl.prototype.parseDeleteExpression = function () { - var deleteKeyword = this.eatKeyword(21 /* DeleteKeyword */); - var expression = this.parseUnaryExpression(); - - return this.factory.deleteExpression(deleteKeyword, expression); - }; - - ParserImpl.prototype.parseVoidExpression = function () { - var voidKeyword = this.eatKeyword(41 /* VoidKeyword */); - var expression = this.parseUnaryExpression(); - - return this.factory.voidExpression(voidKeyword, expression); - }; - - ParserImpl.prototype.parseSuperExpression = function () { - var superKeyword = this.eatKeyword(50 /* SuperKeyword */); - return superKeyword; - }; - - ParserImpl.prototype.parseFunctionExpression = function () { - var functionKeyword = this.eatKeyword(27 /* FunctionKeyword */); - var identifier = null; - - if (this.isIdentifier(this.currentToken())) { - identifier = this.eatIdentifierToken(); - } - - var callSignature = this.parseCallSignature(false); - var block = this.parseBlock(false, true); - - return this.factory.functionExpression(functionKeyword, identifier, callSignature, block); - }; - - ParserImpl.prototype.parseObjectCreationExpression = function () { - var newKeyword = this.eatKeyword(31 /* NewKeyword */); - - var expression = this.parseTerm(true); - var argumentList = this.tryParseArgumentList(); - - return this.factory.objectCreationExpression(newKeyword, expression, argumentList); - }; - - ParserImpl.prototype.parseCastOrArrowFunctionExpression = function () { - var rewindPoint = this.getRewindPoint(); - try { - var arrowFunction = this.tryParseArrowFunctionExpression(); - if (arrowFunction !== null) { - return arrowFunction; - } - - this.rewind(rewindPoint); - return this.parseCastExpression(); - } finally { - this.releaseRewindPoint(rewindPoint); - } - }; - - ParserImpl.prototype.parseCastExpression = function () { - var lessThanToken = this.eatToken(81 /* LessThanToken */); - var type = this.parseType(); - var greaterThanToken = this.eatToken(82 /* GreaterThanToken */); - var expression = this.parseUnaryExpression(); - - return this.factory.castExpression(lessThanToken, type, greaterThanToken, expression); - }; - - ParserImpl.prototype.parseParenthesizedOrArrowFunctionExpression = function () { - var result = this.tryParseArrowFunctionExpression(); - if (result !== null) { - return result; - } - - var openParenToken = this.eatToken(73 /* OpenParenToken */); - var expression = this.parseExpression(true); - var closeParenToken = this.eatToken(74 /* CloseParenToken */); - - return this.factory.parenthesizedExpression(openParenToken, expression, closeParenToken); - }; - - ParserImpl.prototype.tryParseArrowFunctionExpression = function () { - var tokenKind = this.currentToken().tokenKind; - - if (this.isDefinitelyArrowFunctionExpression()) { - return this.parseParenthesizedArrowFunctionExpression(false); - } - - if (!this.isPossiblyArrowFunctionExpression()) { - return null; - } - - var rewindPoint = this.getRewindPoint(); - try { - var arrowFunction = this.parseParenthesizedArrowFunctionExpression(true); - if (arrowFunction === null) { - this.rewind(rewindPoint); - } - return arrowFunction; - } finally { - this.releaseRewindPoint(rewindPoint); - } - }; - - ParserImpl.prototype.parseParenthesizedArrowFunctionExpression = function (requireArrow) { - var currentToken = this.currentToken(); - - var callSignature = this.parseCallSignature(true); - - if (requireArrow && this.currentToken().tokenKind !== 86 /* EqualsGreaterThanToken */) { - return null; - } - - var equalsGreaterThanToken = this.eatToken(86 /* EqualsGreaterThanToken */); - var body = this.parseArrowFunctionBody(); - - return this.factory.parenthesizedArrowFunctionExpression(callSignature, equalsGreaterThanToken, body); - }; - - ParserImpl.prototype.parseArrowFunctionBody = function () { - if (this.isBlock()) { - return this.parseBlock(false, false); - } else { - return this.parseAssignmentExpression(true); - } - }; - - ParserImpl.prototype.isSimpleArrowFunctionExpression = function () { - if (this.currentToken().tokenKind === 86 /* EqualsGreaterThanToken */) { - return true; - } - - return this.isIdentifier(this.currentToken()) && this.peekToken(1).tokenKind === 86 /* EqualsGreaterThanToken */; - }; - - ParserImpl.prototype.parseSimpleArrowFunctionExpression = function () { - var identifier = this.eatIdentifierToken(); - var equalsGreaterThanToken = this.eatToken(86 /* EqualsGreaterThanToken */); - var body = this.parseArrowFunctionBody(); - - return this.factory.simpleArrowFunctionExpression(identifier, equalsGreaterThanToken, body); - }; - - ParserImpl.prototype.isBlock = function () { - return this.currentToken().tokenKind === 71 /* OpenBraceToken */; - }; - - ParserImpl.prototype.isDefinitelyArrowFunctionExpression = function () { - var token0 = this.currentToken(); - if (token0.tokenKind !== 73 /* OpenParenToken */) { - return false; - } - - var token1 = this.peekToken(1); - var token2; - - if (token1.tokenKind === 74 /* CloseParenToken */) { - token2 = this.peekToken(2); - return token2.tokenKind === 107 /* ColonToken */ || token2.tokenKind === 86 /* EqualsGreaterThanToken */ || token2.tokenKind === 71 /* OpenBraceToken */; - } - - if (token1.tokenKind === 78 /* DotDotDotToken */) { - return true; - } - - if (!this.isIdentifier(token1)) { - return false; - } - - token2 = this.peekToken(2); - if (token2.tokenKind === 107 /* ColonToken */) { - return true; - } - - var token3 = this.peekToken(3); - if (token2.tokenKind === 106 /* QuestionToken */) { - if (token3.tokenKind === 107 /* ColonToken */ || token3.tokenKind === 74 /* CloseParenToken */ || token3.tokenKind === 80 /* CommaToken */) { - return true; - } - } - - if (token2.tokenKind === 74 /* CloseParenToken */) { - if (token3.tokenKind === 86 /* EqualsGreaterThanToken */) { - return true; - } - } - - return false; - }; - - ParserImpl.prototype.isPossiblyArrowFunctionExpression = function () { - var token0 = this.currentToken(); - if (token0.tokenKind !== 73 /* OpenParenToken */) { - return true; - } - - var token1 = this.peekToken(1); - - if (!this.isIdentifier(token1)) { - return false; - } - - var token2 = this.peekToken(2); - if (token2.tokenKind === 108 /* EqualsToken */) { - return true; - } - - if (token2.tokenKind === 80 /* CommaToken */) { - return true; - } - - if (token2.tokenKind === 74 /* CloseParenToken */) { - var token3 = this.peekToken(3); - if (token3.tokenKind === 107 /* ColonToken */) { - return true; - } - } - - return false; - }; - - ParserImpl.prototype.parseObjectLiteralExpression = function () { - var openBraceToken = this.eatToken(71 /* OpenBraceToken */); - - var result = this.parseSeparatedSyntaxList(32768 /* ObjectLiteralExpression_PropertyAssignments */); - var propertyAssignments = result.list; - openBraceToken = this.addSkippedTokensAfterToken(openBraceToken, result.skippedTokens); - - var closeBraceToken = this.eatToken(72 /* CloseBraceToken */); - - return this.factory.objectLiteralExpression(openBraceToken, propertyAssignments, closeBraceToken); - }; - - ParserImpl.prototype.parsePropertyAssignment = function () { - if (this.isGetAccessorPropertyAssignment(false)) { - return this.parseGetAccessorPropertyAssignment(); - } else if (this.isSetAccessorPropertyAssignment(false)) { - return this.parseSetAccessorPropertyAssignment(); - } else if (this.isFunctionPropertyAssignment(false)) { - return this.parseFunctionPropertyAssignment(); - } else if (this.isSimplePropertyAssignment(false)) { - return this.parseSimplePropertyAssignment(); - } else { - throw TypeScript.Errors.invalidOperation(); - } - }; - - ParserImpl.prototype.isPropertyAssignment = function (inErrorRecovery) { - return this.isGetAccessorPropertyAssignment(inErrorRecovery) || this.isSetAccessorPropertyAssignment(inErrorRecovery) || this.isFunctionPropertyAssignment(inErrorRecovery) || this.isSimplePropertyAssignment(inErrorRecovery); - }; - - ParserImpl.prototype.isGetAccessorPropertyAssignment = function (inErrorRecovery) { - return this.currentToken().tokenKind === 65 /* GetKeyword */ && this.isPropertyName(this.peekToken(1), inErrorRecovery); - }; - - ParserImpl.prototype.parseGetAccessorPropertyAssignment = function () { - var getKeyword = this.eatKeyword(65 /* GetKeyword */); - var propertyName = this.eatPropertyName(); - var openParenToken = this.eatToken(73 /* OpenParenToken */); - var closeParenToken = this.eatToken(74 /* CloseParenToken */); - var typeAnnotation = this.parseOptionalTypeAnnotation(false); - var block = this.parseBlock(false, true); - - return this.factory.getAccessorPropertyAssignment(getKeyword, propertyName, openParenToken, closeParenToken, typeAnnotation, block); - }; - - ParserImpl.prototype.isSetAccessorPropertyAssignment = function (inErrorRecovery) { - return this.currentToken().tokenKind === 69 /* SetKeyword */ && this.isPropertyName(this.peekToken(1), inErrorRecovery); - }; - - ParserImpl.prototype.parseSetAccessorPropertyAssignment = function () { - var setKeyword = this.eatKeyword(69 /* SetKeyword */); - var propertyName = this.eatPropertyName(); - var openParenToken = this.eatToken(73 /* OpenParenToken */); - var parameter = this.parseParameter(); - var closeParenToken = this.eatToken(74 /* CloseParenToken */); - var block = this.parseBlock(false, true); - - return this.factory.setAccessorPropertyAssignment(setKeyword, propertyName, openParenToken, parameter, closeParenToken, block); - }; - - ParserImpl.prototype.eatPropertyName = function () { - return TypeScript.SyntaxFacts.isIdentifierNameOrAnyKeyword(this.currentToken()) ? this.eatIdentifierNameToken() : this.eatAnyToken(); - }; - - ParserImpl.prototype.isFunctionPropertyAssignment = function (inErrorRecovery) { - return this.isPropertyName(this.currentToken(), inErrorRecovery) && this.isCallSignature(1); - }; - - ParserImpl.prototype.parseFunctionPropertyAssignment = function () { - var propertyName = this.eatPropertyName(); - var callSignature = this.parseCallSignature(false); - var block = this.parseBlock(false, true); - - return this.factory.functionPropertyAssignment(propertyName, callSignature, block); - }; - - ParserImpl.prototype.isSimplePropertyAssignment = function (inErrorRecovery) { - return this.isPropertyName(this.currentToken(), inErrorRecovery); - }; - - ParserImpl.prototype.parseSimplePropertyAssignment = function () { - var propertyName = this.eatPropertyName(); - var colonToken = this.eatToken(107 /* ColonToken */); - var expression = this.parseAssignmentExpression(true); - - return this.factory.simplePropertyAssignment(propertyName, colonToken, expression); - }; - - ParserImpl.prototype.isPropertyName = function (token, inErrorRecovery) { - if (TypeScript.SyntaxFacts.isIdentifierNameOrAnyKeyword(token)) { - if (inErrorRecovery) { - return this.isIdentifier(token); - } else { - return true; - } - } - - switch (token.tokenKind) { - case 14 /* StringLiteral */: - case 13 /* NumericLiteral */: - return true; - - default: - return false; - } - }; - - ParserImpl.prototype.parseArrayLiteralExpression = function () { - var openBracketToken = this.eatToken(75 /* OpenBracketToken */); - - var result = this.parseSeparatedSyntaxList(65536 /* ArrayLiteralExpression_AssignmentExpressions */); - var expressions = result.list; - openBracketToken = this.addSkippedTokensAfterToken(openBracketToken, result.skippedTokens); - - var closeBracketToken = this.eatToken(76 /* CloseBracketToken */); - - return this.factory.arrayLiteralExpression(openBracketToken, expressions, closeBracketToken); - }; - - ParserImpl.prototype.parseLiteralExpression = function () { - return this.eatAnyToken(); - }; - - ParserImpl.prototype.parseThisExpression = function () { - var thisKeyword = this.eatKeyword(35 /* ThisKeyword */); - return thisKeyword; - }; - - ParserImpl.prototype.parseBlock = function (parseBlockEvenWithNoOpenBrace, checkForStrictMode) { - var openBraceToken = this.eatToken(71 /* OpenBraceToken */); - - var statements = TypeScript.Syntax.emptyList; - - if (parseBlockEvenWithNoOpenBrace || openBraceToken.width() > 0) { - var savedIsInStrictMode = this.isInStrictMode; - - var processItems = checkForStrictMode ? ParserImpl.updateStrictModeState : null; - var result = this.parseSyntaxList(32 /* Block_Statements */, processItems); - statements = result.list; - openBraceToken = this.addSkippedTokensAfterToken(openBraceToken, result.skippedTokens); - - this.setStrictMode(savedIsInStrictMode); - } - - var closeBraceToken = this.eatToken(72 /* CloseBraceToken */); - - return this.factory.block(openBraceToken, statements, closeBraceToken); - }; - - ParserImpl.prototype.parseCallSignature = function (requireCompleteTypeParameterList) { - var typeParameterList = this.parseOptionalTypeParameterList(requireCompleteTypeParameterList); - var parameterList = this.parseParameterList(); - var typeAnnotation = this.parseOptionalTypeAnnotation(false); - - return this.factory.callSignature(typeParameterList, parameterList, typeAnnotation); - }; - - ParserImpl.prototype.parseOptionalTypeParameterList = function (requireCompleteTypeParameterList) { - if (this.currentToken().tokenKind !== 81 /* LessThanToken */) { - return null; - } - - var rewindPoint = this.getRewindPoint(); - try { - var lessThanToken = this.eatToken(81 /* LessThanToken */); - - var result = this.parseSeparatedSyntaxList(524288 /* TypeParameterList_TypeParameters */); - var typeParameterList = result.list; - lessThanToken = this.addSkippedTokensAfterToken(lessThanToken, result.skippedTokens); - - var greaterThanToken = this.eatToken(82 /* GreaterThanToken */); - - if (requireCompleteTypeParameterList && greaterThanToken.fullWidth() === 0) { - this.rewind(rewindPoint); - return null; - } - - return this.factory.typeParameterList(lessThanToken, typeParameterList, greaterThanToken); - } finally { - this.releaseRewindPoint(rewindPoint); - } - }; - - ParserImpl.prototype.isTypeParameter = function () { - return this.isIdentifier(this.currentToken()); - }; - - ParserImpl.prototype.parseTypeParameter = function () { - var identifier = this.eatIdentifierToken(); - var constraint = this.parseOptionalConstraint(); - - return this.factory.typeParameter(identifier, constraint); - }; - - ParserImpl.prototype.parseOptionalConstraint = function () { - if (this.currentToken().kind() !== 48 /* ExtendsKeyword */) { - return null; - } - - var extendsKeyword = this.eatKeyword(48 /* ExtendsKeyword */); - var type = this.parseType(); - - return this.factory.constraint(extendsKeyword, type); - }; - - ParserImpl.prototype.parseParameterList = function () { - var openParenToken = this.eatToken(73 /* OpenParenToken */); - var parameters = TypeScript.Syntax.emptySeparatedList; - - if (openParenToken.width() > 0) { - var result = this.parseSeparatedSyntaxList(131072 /* ParameterList_Parameters */); - parameters = result.list; - openParenToken = this.addSkippedTokensAfterToken(openParenToken, result.skippedTokens); - } - - var closeParenToken = this.eatToken(74 /* CloseParenToken */); - return this.factory.parameterList(openParenToken, parameters, closeParenToken); - }; - - ParserImpl.prototype.isTypeAnnotation = function () { - return this.currentToken().tokenKind === 107 /* ColonToken */; - }; - - ParserImpl.prototype.parseOptionalTypeAnnotation = function (allowStringLiteral) { - return this.isTypeAnnotation() ? this.parseTypeAnnotation(allowStringLiteral) : null; - }; - - ParserImpl.prototype.parseTypeAnnotation = function (allowStringLiteral) { - var colonToken = this.eatToken(107 /* ColonToken */); - var type = allowStringLiteral && this.currentToken().tokenKind === 14 /* StringLiteral */ ? this.eatToken(14 /* StringLiteral */) : this.parseType(); - - return this.factory.typeAnnotation(colonToken, type); - }; - - ParserImpl.prototype.isType = function () { - return this.isPredefinedType() || this.isTypeLiteral() || this.isName(); - }; - - ParserImpl.prototype.parseType = function () { - var type = this.parseNonArrayType(); - - while (this.currentToken().tokenKind === 75 /* OpenBracketToken */) { - var openBracketToken = this.eatToken(75 /* OpenBracketToken */); - var closeBracketToken = this.eatToken(76 /* CloseBracketToken */); - - type = this.factory.arrayType(type, openBracketToken, closeBracketToken); - } - - return type; - }; - - ParserImpl.prototype.parseNonArrayType = function () { - if (this.isPredefinedType()) { - return this.parsePredefinedType(); - } else if (this.isTypeLiteral()) { - return this.parseTypeLiteral(); - } else { - return this.parseNameOrGenericType(); - } - }; - - ParserImpl.prototype.parseNameOrGenericType = function () { - var name = this.parseName(); - var typeArgumentList = this.tryParseTypeArgumentList(false); - - return typeArgumentList === null ? name : this.factory.genericType(name, typeArgumentList); - }; - - ParserImpl.prototype.parseTypeLiteral = function () { - if (this.isObjectType()) { - return this.parseObjectType(); - } else if (this.isFunctionType()) { - return this.parseFunctionType(); - } else if (this.isConstructorType()) { - return this.parseConstructorType(); - } else { - throw TypeScript.Errors.invalidOperation(); - } - }; - - ParserImpl.prototype.parseFunctionType = function () { - var typeParameterList = this.parseOptionalTypeParameterList(false); - var parameterList = this.parseParameterList(); - var equalsGreaterThanToken = this.eatToken(86 /* EqualsGreaterThanToken */); - var returnType = this.parseType(); - - return this.factory.functionType(typeParameterList, parameterList, equalsGreaterThanToken, returnType); - }; - - ParserImpl.prototype.parseConstructorType = function () { - var newKeyword = this.eatKeyword(31 /* NewKeyword */); - var parameterList = this.parseParameterList(); - var equalsGreaterThanToken = this.eatToken(86 /* EqualsGreaterThanToken */); - var type = this.parseType(); - - return this.factory.constructorType(newKeyword, null, parameterList, equalsGreaterThanToken, type); - }; - - ParserImpl.prototype.isTypeLiteral = function () { - return this.isObjectType() || this.isFunctionType() || this.isConstructorType(); - }; - - ParserImpl.prototype.isObjectType = function () { - return this.currentToken().tokenKind === 71 /* OpenBraceToken */; - }; - - ParserImpl.prototype.isFunctionType = function () { - var tokenKind = this.currentToken().tokenKind; - return tokenKind === 73 /* OpenParenToken */ || tokenKind === 81 /* LessThanToken */; - }; - - ParserImpl.prototype.isConstructorType = function () { - return this.currentToken().tokenKind === 31 /* NewKeyword */; - }; - - ParserImpl.prototype.parsePredefinedType = function () { - return this.eatAnyToken(); - }; - - ParserImpl.prototype.isPredefinedType = function () { - switch (this.currentToken().tokenKind) { - case 60 /* AnyKeyword */: - case 68 /* NumberKeyword */: - case 61 /* BooleanKeyword */: - case 62 /* BoolKeyword */: - case 70 /* StringKeyword */: - case 41 /* VoidKeyword */: - return true; - } - - return false; - }; - - ParserImpl.prototype.isParameter = function () { - if (this.currentNode() !== null && this.currentNode().kind() === 242 /* Parameter */) { - return true; - } - - var token = this.currentToken(); - if (token.tokenKind === 78 /* DotDotDotToken */) { - return true; - } - - if (ParserImpl.isPublicOrPrivateKeyword(token)) { - return true; - } - - return this.isIdentifier(token); - }; - - ParserImpl.prototype.parseParameter = function () { - if (this.currentNode() !== null && this.currentNode().kind() === 242 /* Parameter */) { - return this.eatNode(); - } - - var dotDotDotToken = this.tryEatToken(78 /* DotDotDotToken */); - - var publicOrPrivateToken = null; - if (ParserImpl.isPublicOrPrivateKeyword(this.currentToken())) { - publicOrPrivateToken = this.eatAnyToken(); - } - - var identifier = this.eatIdentifierToken(); - var questionToken = this.tryEatToken(106 /* QuestionToken */); - var typeAnnotation = this.parseOptionalTypeAnnotation(true); - - var equalsValueClause = null; - if (this.isEqualsValueClause(true)) { - equalsValueClause = this.parseEqualsValueClause(true); - } - - return this.factory.parameter(dotDotDotToken, publicOrPrivateToken, identifier, questionToken, typeAnnotation, equalsValueClause); - }; - - ParserImpl.prototype.parseSyntaxList = function (currentListType, processItems) { - if (typeof processItems === "undefined") { processItems = null; } - var savedListParsingState = this.listParsingState; - this.listParsingState |= currentListType; - - var result = this.parseSyntaxListWorker(currentListType, processItems); - - this.listParsingState = savedListParsingState; - - return result; - }; - - ParserImpl.prototype.parseSeparatedSyntaxList = function (currentListType) { - var savedListParsingState = this.listParsingState; - this.listParsingState |= currentListType; - - var result = this.parseSeparatedSyntaxListWorker(currentListType); - - this.listParsingState = savedListParsingState; - - return result; - }; - - ParserImpl.prototype.abortParsingListOrMoveToNextToken = function (currentListType, items, skippedTokens) { - this.reportUnexpectedTokenDiagnostic(currentListType); - - for (var state = 262144 /* LastListParsingState */; state >= 1 /* FirstListParsingState */; state >>= 1) { - if ((this.listParsingState & state) !== 0) { - if (this.isExpectedListTerminator(state) || this.isExpectedListItem(state, true)) { - return true; - } - } - } - - var skippedToken = this.currentToken(); - - this.moveToNextToken(); - - this.addSkippedTokenToList(items, skippedTokens, skippedToken); - - return false; - }; - - ParserImpl.prototype.addSkippedTokenToList = function (items, skippedTokens, skippedToken) { - for (var i = items.length - 1; i >= 0; i--) { - var item = items[i]; - var lastToken = item.lastToken(); - if (lastToken.fullWidth() > 0) { - items[i] = this.addSkippedTokenAfterNodeOrToken(item, skippedToken); - return; - } - } - - skippedTokens.push(skippedToken); - }; - - ParserImpl.prototype.tryParseExpectedListItem = function (currentListType, inErrorRecovery, items, processItems) { - if (this.isExpectedListItem(currentListType, inErrorRecovery)) { - var item = this.parseExpectedListItem(currentListType); - - items.push(item); - - if (processItems !== null) { - processItems(this, items); - } - } - }; - - ParserImpl.prototype.listIsTerminated = function (currentListType) { - return this.isExpectedListTerminator(currentListType) || this.currentToken().tokenKind === 10 /* EndOfFileToken */; - }; - - ParserImpl.prototype.getArray = function () { - if (this.arrayPool.length > 0) { - return this.arrayPool.pop(); - } - - return []; - }; - - ParserImpl.prototype.returnZeroOrOneLengthArray = function (array) { - if (array.length <= 1) { - this.returnArray(array); - } - }; - - ParserImpl.prototype.returnArray = function (array) { - array.length = 0; - this.arrayPool.push(array); - }; - - ParserImpl.prototype.parseSyntaxListWorker = function (currentListType, processItems) { - var items = this.getArray(); - var skippedTokens = this.getArray(); - - while (true) { - var oldItemsCount = items.length; - this.tryParseExpectedListItem(currentListType, false, items, processItems); - - var newItemsCount = items.length; - if (newItemsCount === oldItemsCount) { - if (this.listIsTerminated(currentListType)) { - break; - } - - var abort = this.abortParsingListOrMoveToNextToken(currentListType, items, skippedTokens); - if (abort) { - break; - } - } - } - - var result = TypeScript.Syntax.list(items); - - this.returnZeroOrOneLengthArray(items); - - return { skippedTokens: skippedTokens, list: result }; - }; - - ParserImpl.prototype.parseSeparatedSyntaxListWorker = function (currentListType) { - var items = this.getArray(); - var skippedTokens = this.getArray(); - TypeScript.Debug.assert(items.length === 0); - TypeScript.Debug.assert(skippedTokens.length === 0); - TypeScript.Debug.assert(skippedTokens !== items); - - var separatorKind = this.separatorKind(currentListType); - var allowAutomaticSemicolonInsertion = separatorKind === 79 /* SemicolonToken */; - - var inErrorRecovery = false; - var listWasTerminated = false; - while (true) { - var oldItemsCount = items.length; - - this.tryParseExpectedListItem(currentListType, inErrorRecovery, items, null); - - var newItemsCount = items.length; - if (newItemsCount === oldItemsCount) { - if (this.listIsTerminated(currentListType)) { - listWasTerminated = true; - break; - } - - var abort = this.abortParsingListOrMoveToNextToken(currentListType, items, skippedTokens); - if (abort) { - break; - } else { - inErrorRecovery = true; - continue; - } - } - - inErrorRecovery = false; - - var currentToken = this.currentToken(); - if (currentToken.tokenKind === separatorKind || currentToken.tokenKind === 80 /* CommaToken */) { - items.push(this.eatAnyToken()); - continue; - } - - if (this.listIsTerminated(currentListType)) { - listWasTerminated = true; - break; - } - - if (allowAutomaticSemicolonInsertion && this.canEatAutomaticSemicolon(false)) { - items.push(this.eatExplicitOrAutomaticSemicolon(false)); - - continue; - } - - items.push(this.eatToken(separatorKind)); - - inErrorRecovery = true; - } - - var result = TypeScript.Syntax.separatedList(items); - - this.returnZeroOrOneLengthArray(items); - - return { skippedTokens: skippedTokens, list: result }; - }; - - ParserImpl.prototype.separatorKind = function (currentListType) { - switch (currentListType) { - case 2048 /* HeritageClause_TypeNameList */: - case 16384 /* ArgumentList_AssignmentExpressions */: - case 256 /* EnumDeclaration_EnumElements */: - case 4096 /* VariableDeclaration_VariableDeclarators_AllowIn */: - case 8192 /* VariableDeclaration_VariableDeclarators_DisallowIn */: - case 32768 /* ObjectLiteralExpression_PropertyAssignments */: - case 131072 /* ParameterList_Parameters */: - case 65536 /* ArrayLiteralExpression_AssignmentExpressions */: - case 262144 /* TypeArgumentList_Types */: - case 524288 /* TypeParameterList_TypeParameters */: - return 80 /* CommaToken */; - - case 512 /* ObjectType_TypeMembers */: - return 79 /* SemicolonToken */; - - case 1 /* SourceUnit_ModuleElements */: - case 1024 /* ClassOrInterfaceDeclaration_HeritageClauses */: - case 2 /* ClassDeclaration_ClassElements */: - case 4 /* ModuleDeclaration_ModuleElements */: - case 8 /* SwitchStatement_SwitchClauses */: - case 16 /* SwitchClause_Statements */: - case 32 /* Block_Statements */: - default: - throw TypeScript.Errors.notYetImplemented(); - } - }; - - ParserImpl.prototype.reportUnexpectedTokenDiagnostic = function (listType) { - var token = this.currentToken(); - - var diagnostic = new TypeScript.SyntaxDiagnostic(this.fileName, this.currentTokenStart(), token.width(), 12 /* Unexpected_token__0_expected */, [this.getExpectedListElementType(listType)]); - this.addDiagnostic(diagnostic); - }; - - ParserImpl.prototype.addDiagnostic = function (diagnostic) { - if (this.diagnostics.length > 0 && this.diagnostics[this.diagnostics.length - 1].start() === diagnostic.start()) { - return; - } - - this.diagnostics.push(diagnostic); - }; - - ParserImpl.prototype.isExpectedListTerminator = function (currentListType) { - switch (currentListType) { - case 1 /* SourceUnit_ModuleElements */: - return this.isExpectedSourceUnit_ModuleElementsTerminator(); - - case 1024 /* ClassOrInterfaceDeclaration_HeritageClauses */: - return this.isExpectedClassOrInterfaceDeclaration_HeritageClausesTerminator(); - - case 2 /* ClassDeclaration_ClassElements */: - return this.isExpectedClassDeclaration_ClassElementsTerminator(); - - case 4 /* ModuleDeclaration_ModuleElements */: - return this.isExpectedModuleDeclaration_ModuleElementsTerminator(); - - case 8 /* SwitchStatement_SwitchClauses */: - return this.isExpectedSwitchStatement_SwitchClausesTerminator(); - - case 16 /* SwitchClause_Statements */: - return this.isExpectedSwitchClause_StatementsTerminator(); - - case 32 /* Block_Statements */: - return this.isExpectedBlock_StatementsTerminator(); - - case 64 /* TryBlock_Statements */: - return this.isExpectedTryBlock_StatementsTerminator(); - - case 128 /* CatchBlock_Statements */: - return this.isExpectedCatchBlock_StatementsTerminator(); - - case 256 /* EnumDeclaration_EnumElements */: - return this.isExpectedEnumDeclaration_EnumElementsTerminator(); - - case 512 /* ObjectType_TypeMembers */: - return this.isExpectedObjectType_TypeMembersTerminator(); - - case 16384 /* ArgumentList_AssignmentExpressions */: - return this.isExpectedArgumentList_AssignmentExpressionsTerminator(); - - case 2048 /* HeritageClause_TypeNameList */: - return this.isExpectedHeritageClause_TypeNameListTerminator(); - - case 4096 /* VariableDeclaration_VariableDeclarators_AllowIn */: - return this.isExpectedVariableDeclaration_VariableDeclarators_AllowInTerminator(); - - case 8192 /* VariableDeclaration_VariableDeclarators_DisallowIn */: - return this.isExpectedVariableDeclaration_VariableDeclarators_DisallowInTerminator(); - - case 32768 /* ObjectLiteralExpression_PropertyAssignments */: - return this.isExpectedObjectLiteralExpression_PropertyAssignmentsTerminator(); - - case 131072 /* ParameterList_Parameters */: - return this.isExpectedParameterList_ParametersTerminator(); - - case 262144 /* TypeArgumentList_Types */: - return this.isExpectedTypeArgumentList_TypesTerminator(); - - case 524288 /* TypeParameterList_TypeParameters */: - return this.isExpectedTypeParameterList_TypeParametersTerminator(); - - case 65536 /* ArrayLiteralExpression_AssignmentExpressions */: - return this.isExpectedLiteralExpression_AssignmentExpressionsTerminator(); - - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ParserImpl.prototype.isExpectedSourceUnit_ModuleElementsTerminator = function () { - return this.currentToken().tokenKind === 10 /* EndOfFileToken */; - }; - - ParserImpl.prototype.isExpectedEnumDeclaration_EnumElementsTerminator = function () { - return this.currentToken().tokenKind === 72 /* CloseBraceToken */; - }; - - ParserImpl.prototype.isExpectedModuleDeclaration_ModuleElementsTerminator = function () { - return this.currentToken().tokenKind === 72 /* CloseBraceToken */; - }; - - ParserImpl.prototype.isExpectedObjectType_TypeMembersTerminator = function () { - return this.currentToken().tokenKind === 72 /* CloseBraceToken */; - }; - - ParserImpl.prototype.isExpectedObjectLiteralExpression_PropertyAssignmentsTerminator = function () { - return this.currentToken().tokenKind === 72 /* CloseBraceToken */; - }; - - ParserImpl.prototype.isExpectedLiteralExpression_AssignmentExpressionsTerminator = function () { - return this.currentToken().tokenKind === 76 /* CloseBracketToken */; - }; - - ParserImpl.prototype.isExpectedTypeArgumentList_TypesTerminator = function () { - var token = this.currentToken(); - if (token.tokenKind === 82 /* GreaterThanToken */) { - return true; - } - - if (this.canFollowTypeArgumentListInExpression(token.tokenKind)) { - return true; - } - - return false; - }; - - ParserImpl.prototype.isExpectedTypeParameterList_TypeParametersTerminator = function () { - var token = this.currentToken(); - if (token.tokenKind === 82 /* GreaterThanToken */) { - return true; - } - - if (token.tokenKind === 73 /* OpenParenToken */ || token.tokenKind === 71 /* OpenBraceToken */ || token.tokenKind === 48 /* ExtendsKeyword */ || token.tokenKind === 51 /* ImplementsKeyword */) { - return true; - } - - return false; - }; - - ParserImpl.prototype.isExpectedParameterList_ParametersTerminator = function () { - var token = this.currentToken(); - if (token.tokenKind === 74 /* CloseParenToken */) { - return true; - } - - if (token.tokenKind === 71 /* OpenBraceToken */) { - return true; - } - - if (token.tokenKind === 86 /* EqualsGreaterThanToken */) { - return true; - } - - return false; - }; - - ParserImpl.prototype.isExpectedVariableDeclaration_VariableDeclarators_DisallowInTerminator = function () { - if (this.currentToken().tokenKind === 79 /* SemicolonToken */ || this.currentToken().tokenKind === 74 /* CloseParenToken */) { - return true; - } - - if (this.currentToken().tokenKind === 29 /* InKeyword */) { - return true; - } - - return false; - }; - - ParserImpl.prototype.isExpectedVariableDeclaration_VariableDeclarators_AllowInTerminator = function () { - if (this.previousToken().tokenKind === 80 /* CommaToken */) { - return false; - } - - if (this.currentToken().tokenKind === 86 /* EqualsGreaterThanToken */) { - return true; - } - - return this.canEatExplicitOrAutomaticSemicolon(false); - }; - - ParserImpl.prototype.isExpectedClassOrInterfaceDeclaration_HeritageClausesTerminator = function () { - var token0 = this.currentToken(); - if (token0.tokenKind === 71 /* OpenBraceToken */ || token0.tokenKind === 72 /* CloseBraceToken */) { - return true; - } - - return false; - }; - - ParserImpl.prototype.isExpectedHeritageClause_TypeNameListTerminator = function () { - var token0 = this.currentToken(); - if (token0.tokenKind === 48 /* ExtendsKeyword */ || token0.tokenKind === 51 /* ImplementsKeyword */) { - return true; - } - - if (this.isExpectedClassOrInterfaceDeclaration_HeritageClausesTerminator()) { - return true; - } - - return false; - }; - - ParserImpl.prototype.isExpectedArgumentList_AssignmentExpressionsTerminator = function () { - var token0 = this.currentToken(); - return token0.tokenKind === 74 /* CloseParenToken */ || token0.tokenKind === 79 /* SemicolonToken */; - }; - - ParserImpl.prototype.isExpectedClassDeclaration_ClassElementsTerminator = function () { - return this.currentToken().tokenKind === 72 /* CloseBraceToken */; - }; - - ParserImpl.prototype.isExpectedSwitchStatement_SwitchClausesTerminator = function () { - return this.currentToken().tokenKind === 72 /* CloseBraceToken */; - }; - - ParserImpl.prototype.isExpectedSwitchClause_StatementsTerminator = function () { - return this.currentToken().tokenKind === 72 /* CloseBraceToken */ || this.isSwitchClause(); - }; - - ParserImpl.prototype.isExpectedBlock_StatementsTerminator = function () { - return this.currentToken().tokenKind === 72 /* CloseBraceToken */; - }; - - ParserImpl.prototype.isExpectedTryBlock_StatementsTerminator = function () { - return this.currentToken().tokenKind === 17 /* CatchKeyword */ || this.currentToken().tokenKind === 25 /* FinallyKeyword */; - }; - - ParserImpl.prototype.isExpectedCatchBlock_StatementsTerminator = function () { - return this.currentToken().tokenKind === 25 /* FinallyKeyword */; - }; - - ParserImpl.prototype.isExpectedListItem = function (currentListType, inErrorRecovery) { - switch (currentListType) { - case 1 /* SourceUnit_ModuleElements */: - return this.isModuleElement(inErrorRecovery); - - case 1024 /* ClassOrInterfaceDeclaration_HeritageClauses */: - return this.isHeritageClause(); - - case 2 /* ClassDeclaration_ClassElements */: - return this.isClassElement(inErrorRecovery); - - case 4 /* ModuleDeclaration_ModuleElements */: - return this.isModuleElement(inErrorRecovery); - - case 8 /* SwitchStatement_SwitchClauses */: - return this.isSwitchClause(); - - case 16 /* SwitchClause_Statements */: - return this.isStatement(inErrorRecovery); - - case 32 /* Block_Statements */: - return this.isStatement(inErrorRecovery); - - case 64 /* TryBlock_Statements */: - case 128 /* CatchBlock_Statements */: - return false; - - case 256 /* EnumDeclaration_EnumElements */: - return this.isEnumElement(inErrorRecovery); - - case 4096 /* VariableDeclaration_VariableDeclarators_AllowIn */: - case 8192 /* VariableDeclaration_VariableDeclarators_DisallowIn */: - return this.isVariableDeclarator(); - - case 512 /* ObjectType_TypeMembers */: - return this.isTypeMember(inErrorRecovery); - - case 16384 /* ArgumentList_AssignmentExpressions */: - return this.isExpectedArgumentList_AssignmentExpression(); - - case 2048 /* HeritageClause_TypeNameList */: - return this.isHeritageClauseTypeName(); - - case 32768 /* ObjectLiteralExpression_PropertyAssignments */: - return this.isPropertyAssignment(inErrorRecovery); - - case 131072 /* ParameterList_Parameters */: - return this.isParameter(); - - case 262144 /* TypeArgumentList_Types */: - return this.isType(); - - case 524288 /* TypeParameterList_TypeParameters */: - return this.isTypeParameter(); - - case 65536 /* ArrayLiteralExpression_AssignmentExpressions */: - return this.isAssignmentOrOmittedExpression(); - - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ParserImpl.prototype.isExpectedArgumentList_AssignmentExpression = function () { - if (this.isExpression()) { - return true; - } - - if (this.currentToken().tokenKind === 80 /* CommaToken */) { - return true; - } - - return false; - }; - - ParserImpl.prototype.parseExpectedListItem = function (currentListType) { - switch (currentListType) { - case 1 /* SourceUnit_ModuleElements */: - return this.parseModuleElement(); - - case 1024 /* ClassOrInterfaceDeclaration_HeritageClauses */: - return this.parseHeritageClause(); - - case 2 /* ClassDeclaration_ClassElements */: - return this.parseClassElement(false); - - case 4 /* ModuleDeclaration_ModuleElements */: - return this.parseModuleElement(); - - case 8 /* SwitchStatement_SwitchClauses */: - return this.parseSwitchClause(); - - case 16 /* SwitchClause_Statements */: - return this.parseStatement(); - - case 32 /* Block_Statements */: - return this.parseStatement(); - - case 256 /* EnumDeclaration_EnumElements */: - return this.parseEnumElement(); - - case 512 /* ObjectType_TypeMembers */: - return this.parseTypeMember(); - - case 16384 /* ArgumentList_AssignmentExpressions */: - return this.parseAssignmentExpression(true); - - case 2048 /* HeritageClause_TypeNameList */: - return this.parseNameOrGenericType(); - - case 4096 /* VariableDeclaration_VariableDeclarators_AllowIn */: - return this.parseVariableDeclarator(true, false); - - case 8192 /* VariableDeclaration_VariableDeclarators_DisallowIn */: - return this.parseVariableDeclarator(false, false); - - case 32768 /* ObjectLiteralExpression_PropertyAssignments */: - return this.parsePropertyAssignment(); - - case 65536 /* ArrayLiteralExpression_AssignmentExpressions */: - return this.parseAssignmentOrOmittedExpression(); - - case 131072 /* ParameterList_Parameters */: - return this.parseParameter(); - - case 262144 /* TypeArgumentList_Types */: - return this.parseType(); - - case 524288 /* TypeParameterList_TypeParameters */: - return this.parseTypeParameter(); - - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ParserImpl.prototype.getExpectedListElementType = function (currentListType) { - switch (currentListType) { - case 1 /* SourceUnit_ModuleElements */: - return TypeScript.Strings.module__class__interface__enum__import_or_statement; - - case 1024 /* ClassOrInterfaceDeclaration_HeritageClauses */: - return '{'; - - case 2 /* ClassDeclaration_ClassElements */: - return TypeScript.Strings.constructor__function__accessor_or_variable; - - case 4 /* ModuleDeclaration_ModuleElements */: - return TypeScript.Strings.module__class__interface__enum__import_or_statement; - - case 8 /* SwitchStatement_SwitchClauses */: - return TypeScript.Strings.case_or_default_clause; - - case 16 /* SwitchClause_Statements */: - return TypeScript.Strings.statement; - - case 32 /* Block_Statements */: - return TypeScript.Strings.statement; - - case 4096 /* VariableDeclaration_VariableDeclarators_AllowIn */: - case 8192 /* VariableDeclaration_VariableDeclarators_DisallowIn */: - return TypeScript.Strings.identifier; - - case 256 /* EnumDeclaration_EnumElements */: - return TypeScript.Strings.identifier; - - case 512 /* ObjectType_TypeMembers */: - return TypeScript.Strings.call__construct__index__property_or_function_signature; - - case 16384 /* ArgumentList_AssignmentExpressions */: - return TypeScript.Strings.expression; - - case 2048 /* HeritageClause_TypeNameList */: - return TypeScript.Strings.type_name; - - case 32768 /* ObjectLiteralExpression_PropertyAssignments */: - return TypeScript.Strings.property_or_accessor; - - case 131072 /* ParameterList_Parameters */: - return TypeScript.Strings.parameter; - - case 262144 /* TypeArgumentList_Types */: - return TypeScript.Strings.type; - - case 524288 /* TypeParameterList_TypeParameters */: - return TypeScript.Strings.type_parameter; - - case 65536 /* ArrayLiteralExpression_AssignmentExpressions */: - return TypeScript.Strings.expression; - - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - return ParserImpl; - })(); - - function parse(fileName, text, isDeclaration, languageVersion, options) { - var source = new NormalParserSource(fileName, text, languageVersion); - - return new ParserImpl(fileName, text.lineMap(), source, options).parseSyntaxTree(isDeclaration); - } - Parser.parse = parse; - - function incrementalParse(oldSyntaxTree, textChangeRange, newText) { - if (textChangeRange.isUnchanged()) { - return oldSyntaxTree; - } - - var source = new IncrementalParserSource(oldSyntaxTree, textChangeRange, newText); - - return new ParserImpl(oldSyntaxTree.fileName(), newText.lineMap(), source, oldSyntaxTree.parseOptions()).parseSyntaxTree(oldSyntaxTree.isDeclaration()); - } - Parser.incrementalParse = incrementalParse; - })(TypeScript.Parser || (TypeScript.Parser = {})); - var Parser = TypeScript.Parser; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var SyntaxTree = (function () { - function SyntaxTree(sourceUnit, isDeclaration, diagnostics, fileName, lineMap, languageVersion, parseOtions) { - this._allDiagnostics = null; - this._sourceUnit = sourceUnit; - this._isDeclaration = isDeclaration; - this._parserDiagnostics = diagnostics; - this._fileName = fileName; - this._lineMap = lineMap; - this._languageVersion = languageVersion; - this._parseOptions = parseOtions; - } - SyntaxTree.prototype.toJSON = function (key) { - var result = {}; - - result.isDeclaration = this._isDeclaration; - result.languageVersion = TypeScript.LanguageVersion[this._languageVersion]; - result.parseOptions = this._parseOptions; - - if (this.diagnostics().length > 0) { - result.diagnostics = this.diagnostics(); - } - - result.sourceUnit = this._sourceUnit; - result.lineMap = this._lineMap; - - return result; - }; - - SyntaxTree.prototype.sourceUnit = function () { - return this._sourceUnit; - }; - - SyntaxTree.prototype.isDeclaration = function () { - return this._isDeclaration; - }; - - SyntaxTree.prototype.computeDiagnostics = function () { - if (this._parserDiagnostics.length > 0) { - return this._parserDiagnostics; - } - - var diagnostics = []; - this.sourceUnit().accept(new GrammarCheckerWalker(this, diagnostics)); - - return diagnostics; - }; - - SyntaxTree.prototype.diagnostics = function () { - if (this._allDiagnostics === null) { - this._allDiagnostics = this.computeDiagnostics(); - } - - return this._allDiagnostics; - }; - - SyntaxTree.prototype.fileName = function () { - return this._fileName; - }; - - SyntaxTree.prototype.lineMap = function () { - return this._lineMap; - }; - - SyntaxTree.prototype.languageVersion = function () { - return this._languageVersion; - }; - - SyntaxTree.prototype.parseOptions = function () { - return this._parseOptions; - }; - - SyntaxTree.prototype.structuralEquals = function (tree) { - return TypeScript.ArrayUtilities.sequenceEquals(this.diagnostics(), tree.diagnostics(), TypeScript.SyntaxDiagnostic.equals) && this.sourceUnit().structuralEquals(tree.sourceUnit()); - }; - return SyntaxTree; - })(); - TypeScript.SyntaxTree = SyntaxTree; - - var GrammarCheckerWalker = (function (_super) { - __extends(GrammarCheckerWalker, _super); - function GrammarCheckerWalker(syntaxTree, diagnostics) { - _super.call(this); - this.syntaxTree = syntaxTree; - this.diagnostics = diagnostics; - this.inAmbientDeclaration = false; - this.inBlock = false; - this.currentConstructor = null; - } - GrammarCheckerWalker.prototype.childFullStart = function (parent, child) { - return this.position() + TypeScript.Syntax.childOffset(parent, child); - }; - - GrammarCheckerWalker.prototype.childStart = function (parent, child) { - return this.childFullStart(parent, child) + child.leadingTriviaWidth(); - }; - - GrammarCheckerWalker.prototype.pushDiagnostic = function (start, length, diagnosticCode, args) { - if (typeof args === "undefined") { args = null; } - this.diagnostics.push(new TypeScript.SyntaxDiagnostic(this.syntaxTree.fileName(), start, length, diagnosticCode, args)); - }; - - GrammarCheckerWalker.prototype.pushDiagnostic1 = function (elementFullStart, element, diagnosticCode, args) { - if (typeof args === "undefined") { args = null; } - this.diagnostics.push(new TypeScript.SyntaxDiagnostic(this.syntaxTree.fileName(), elementFullStart + element.leadingTriviaWidth(), element.width(), diagnosticCode, args)); - }; - - GrammarCheckerWalker.prototype.visitCatchClause = function (node) { - if (node.typeAnnotation) { - this.pushDiagnostic(this.childStart(node, node.typeAnnotation), node.typeAnnotation.width(), 17 /* A_catch_clause_variable_cannot_have_a_type_annotation */); - } - - _super.prototype.visitCatchClause.call(this, node); - }; - - GrammarCheckerWalker.prototype.checkParameterListOrder = function (node) { - var parameterFullStart = this.childFullStart(node, node.parameters); - - var seenOptionalParameter = false; - var parameterCount = node.parameters.nonSeparatorCount(); - - for (var i = 0, n = node.parameters.childCount(); i < n; i++) { - var nodeOrToken = node.parameters.childAt(i); - if (i % 2 === 0) { - var parameterIndex = i / 2; - var parameter = node.parameters.childAt(i); - - if (parameter.dotDotDotToken) { - if (parameterIndex !== (parameterCount - 1)) { - this.pushDiagnostic1(parameterFullStart, parameter, 18 /* Rest_parameter_must_be_last_in_list */); - return true; - } - - if (parameter.questionToken) { - this.pushDiagnostic1(parameterFullStart, parameter, 56 /* Rest_parameter_cannot_be_optional */); - return true; - } - - if (parameter.equalsValueClause) { - this.pushDiagnostic1(parameterFullStart, parameter, 57 /* Rest_parameter_cannot_have_initializer */); - return true; - } - } else if (parameter.questionToken || parameter.equalsValueClause) { - seenOptionalParameter = true; - - if (parameter.questionToken && parameter.equalsValueClause) { - this.pushDiagnostic1(parameterFullStart, parameter, 19 /* Parameter_cannot_have_question_mark_and_initializer */); - return true; - } - } else { - if (seenOptionalParameter) { - this.pushDiagnostic1(parameterFullStart, parameter, 20 /* Required_parameter_cannot_follow_optional_parameter */); - return true; - } - } - } - - parameterFullStart += nodeOrToken.fullWidth(); - } - - return false; - }; - - GrammarCheckerWalker.prototype.checkParameterListAcessibilityModifiers = function (node) { - if (this.currentConstructor !== null && this.currentConstructor.parameterList === node && this.currentConstructor.block && !this.inAmbientDeclaration) { - return false; - } - - var parameterFullStart = this.childFullStart(node, node.parameters); - - for (var i = 0, n = node.parameters.childCount(); i < n; i++) { - var nodeOrToken = node.parameters.childAt(i); - if (i % 2 === 0) { - var parameter = node.parameters.childAt(i); - - if (parameter.publicOrPrivateKeyword) { - var keywordFullStart = parameterFullStart + TypeScript.Syntax.childOffset(parameter, parameter.publicOrPrivateKeyword); - this.pushDiagnostic1(keywordFullStart, parameter.publicOrPrivateKeyword, 43 /* Overload_and_ambient_signatures_cannot_specify_parameter_properties */); - } - } - - parameterFullStart += nodeOrToken.fullWidth(); - } - - return false; - }; - - GrammarCheckerWalker.prototype.checkForTrailingSeparator = function (parent, list) { - if (list.childCount() === 0 || list.childCount() % 2 === 1) { - return false; - } - - var currentElementFullStart = this.childFullStart(parent, list); - - for (var i = 0, n = list.childCount(); i < n; i++) { - var child = list.childAt(i); - if (i === n - 1) { - this.pushDiagnostic1(currentElementFullStart, child, 13 /* Trailing_separator_not_allowed */); - } - - currentElementFullStart += child.fullWidth(); - } - - return true; - }; - - GrammarCheckerWalker.prototype.checkForAtLeastOneElement = function (parent, list, expected) { - if (list.childCount() > 0) { - return false; - } - - var listFullStart = this.childFullStart(parent, list); - var tokenAtStart = this.syntaxTree.sourceUnit().findToken(listFullStart); - - this.pushDiagnostic1(listFullStart, tokenAtStart.token(), 12 /* Unexpected_token__0_expected */, [expected]); - - return true; - }; - - GrammarCheckerWalker.prototype.visitParameterList = function (node) { - if (this.checkParameterListAcessibilityModifiers(node) || this.checkParameterListOrder(node) || this.checkForTrailingSeparator(node, node.parameters)) { - this.skip(node); - return; - } - - _super.prototype.visitParameterList.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitHeritageClause = function (node) { - if (this.checkForTrailingSeparator(node, node.typeNames) || this.checkForAtLeastOneElement(node, node.typeNames, TypeScript.Strings.type_name)) { - this.skip(node); - return; - } - - _super.prototype.visitHeritageClause.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitArgumentList = function (node) { - if (this.checkForTrailingSeparator(node, node.arguments)) { - this.skip(node); - return; - } - - _super.prototype.visitArgumentList.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitVariableDeclaration = function (node) { - if (this.checkForTrailingSeparator(node, node.variableDeclarators) || this.checkForAtLeastOneElement(node, node.variableDeclarators, TypeScript.Strings.identifier)) { - this.skip(node); - return; - } - - _super.prototype.visitVariableDeclaration.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitTypeArgumentList = function (node) { - if (this.checkForTrailingSeparator(node, node.typeArguments) || this.checkForAtLeastOneElement(node, node.typeArguments, TypeScript.Strings.identifier)) { - this.skip(node); - return; - } - - _super.prototype.visitTypeArgumentList.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitTypeParameterList = function (node) { - if (this.checkForTrailingSeparator(node, node.typeParameters) || this.checkForAtLeastOneElement(node, node.typeParameters, TypeScript.Strings.identifier)) { - this.skip(node); - return; - } - - _super.prototype.visitTypeParameterList.call(this, node); - }; - - GrammarCheckerWalker.prototype.checkIndexSignatureParameter = function (node) { - var parameterFullStart = this.childFullStart(node, node.parameter); - var parameter = node.parameter; - - if (parameter.dotDotDotToken) { - this.pushDiagnostic1(parameterFullStart, parameter, 21 /* Index_signatures_cannot_have_rest_parameters */); - return true; - } else if (parameter.publicOrPrivateKeyword) { - this.pushDiagnostic1(parameterFullStart, parameter, 22 /* Index_signature_parameter_cannot_have_accessibility_modifiers */); - return true; - } else if (parameter.questionToken) { - this.pushDiagnostic1(parameterFullStart, parameter, 23 /* Index_signature_parameter_cannot_have_a_question_mark */); - return true; - } else if (parameter.equalsValueClause) { - this.pushDiagnostic1(parameterFullStart, parameter, 24 /* Index_signature_parameter_cannot_have_an_initializer */); - return true; - } else if (!parameter.typeAnnotation) { - this.pushDiagnostic1(parameterFullStart, parameter, 26 /* Index_signature_parameter_must_have_a_type_annotation */); - return true; - } else if (parameter.typeAnnotation.type.kind() !== 70 /* StringKeyword */ && parameter.typeAnnotation.type.kind() !== 68 /* NumberKeyword */) { - this.pushDiagnostic1(parameterFullStart, parameter, 27 /* Index_signature_parameter_type_must_be__string__or__number_ */); - return true; - } - - return false; - }; - - GrammarCheckerWalker.prototype.visitIndexSignature = function (node) { - if (this.checkIndexSignatureParameter(node)) { - this.skip(node); - return; - } - - if (!node.typeAnnotation) { - this.pushDiagnostic1(this.position(), node, 25 /* Index_signature_must_have_a_type_annotation */); - this.skip(node); - return; - } - - _super.prototype.visitIndexSignature.call(this, node); - }; - - GrammarCheckerWalker.prototype.checkClassDeclarationHeritageClauses = function (node) { - var heritageClauseFullStart = this.childFullStart(node, node.heritageClauses); - - var seenExtendsClause = false; - var seenImplementsClause = false; - - for (var i = 0, n = node.heritageClauses.childCount(); i < n; i++) { - TypeScript.Debug.assert(i <= 2); - var heritageClause = node.heritageClauses.childAt(i); - - if (heritageClause.extendsOrImplementsKeyword.tokenKind === 48 /* ExtendsKeyword */) { - if (seenExtendsClause) { - this.pushDiagnostic1(heritageClauseFullStart, heritageClause, 28 /* _extends__clause_already_seen */); - return true; - } - - if (seenImplementsClause) { - this.pushDiagnostic1(heritageClauseFullStart, heritageClause, 29 /* _extends__clause_must_precede__implements__clause */); - return true; - } - - if (heritageClause.typeNames.nonSeparatorCount() > 1) { - this.pushDiagnostic1(heritageClauseFullStart, heritageClause, 30 /* Class_can_only_extend_single_type */); - return true; - } - - seenExtendsClause = true; - } else { - TypeScript.Debug.assert(heritageClause.extendsOrImplementsKeyword.tokenKind === 51 /* ImplementsKeyword */); - if (seenImplementsClause) { - this.pushDiagnostic1(heritageClauseFullStart, heritageClause, 31 /* _implements__clause_already_seen */); - return true; - } - - seenImplementsClause = true; - } - - heritageClauseFullStart += heritageClause.fullWidth(); - } - - return false; - }; - - GrammarCheckerWalker.prototype.checkForDisallowedDeclareModifier = function (modifiers) { - if (this.inAmbientDeclaration) { - var declareToken = TypeScript.SyntaxUtilities.getToken(modifiers, 64 /* DeclareKeyword */); - - if (declareToken) { - this.pushDiagnostic1(this.childFullStart(modifiers, declareToken), declareToken, 41 /* _declare__modifier_not_allowed_for_code_already_in_an_ambient_context */); - return true; - } - } - - return false; - }; - - GrammarCheckerWalker.prototype.checkForRequiredDeclareModifier = function (moduleElement, typeKeyword, modifiers) { - if (!this.inAmbientDeclaration && this.syntaxTree.isDeclaration()) { - if (!TypeScript.SyntaxUtilities.containsToken(modifiers, 64 /* DeclareKeyword */)) { - this.pushDiagnostic1(this.childFullStart(moduleElement, typeKeyword), typeKeyword.firstToken(), 49 /* _declare__modifier_required_for_top_level_element */); - return true; - } - } - }; - - GrammarCheckerWalker.prototype.checkFunctionOverloads = function (node, moduleElements) { - if (!this.inAmbientDeclaration && !this.syntaxTree.isDeclaration()) { - var moduleElementFullStart = this.childFullStart(node, moduleElements); - - var inFunctionOverloadChain = false; - var functionOverloadChainName = null; - - for (var i = 0, n = moduleElements.childCount(); i < n; i++) { - var moduleElement = moduleElements.childAt(i); - var lastElement = i === (n - 1); - - if (inFunctionOverloadChain) { - if (moduleElement.kind() !== 129 /* FunctionDeclaration */) { - this.pushDiagnostic1(moduleElementFullStart, moduleElement.firstToken(), 44 /* Function_implementation_expected */); - return true; - } - - var functionDeclaration = moduleElement; - if (functionDeclaration.identifier.valueText() !== functionOverloadChainName) { - var identifierFullStart = moduleElementFullStart + TypeScript.Syntax.childOffset(moduleElement, functionDeclaration.identifier); - this.pushDiagnostic1(identifierFullStart, functionDeclaration.identifier, 46 /* Function_overload_name_must_be__0_ */, [functionOverloadChainName]); - return true; - } - } - - if (moduleElement.kind() === 129 /* FunctionDeclaration */) { - functionDeclaration = moduleElement; - if (!TypeScript.SyntaxUtilities.containsToken(functionDeclaration.modifiers, 64 /* DeclareKeyword */)) { - inFunctionOverloadChain = functionDeclaration.block === null; - functionOverloadChainName = functionDeclaration.identifier.valueText(); - - if (lastElement && inFunctionOverloadChain) { - this.pushDiagnostic1(moduleElementFullStart, moduleElement.firstToken(), 44 /* Function_implementation_expected */); - return true; - } - } else { - inFunctionOverloadChain = false; - functionOverloadChainName = ""; - } - } - - moduleElementFullStart += moduleElement.fullWidth(); - } - } - - return false; - }; - - GrammarCheckerWalker.prototype.checkClassOverloads = function (node) { - if (!this.inAmbientDeclaration && !TypeScript.SyntaxUtilities.containsToken(node.modifiers, 64 /* DeclareKeyword */)) { - var classElementFullStart = this.childFullStart(node, node.classElements); - - var inFunctionOverloadChain = false; - var inConstructorOverloadChain = false; - - var functionOverloadChainName = null; - var memberFunctionDeclaration = null; - - for (var i = 0, n = node.classElements.childCount(); i < n; i++) { - var classElement = node.classElements.childAt(i); - var lastElement = i === (n - 1); - - if (inFunctionOverloadChain) { - if (classElement.kind() !== 135 /* MemberFunctionDeclaration */) { - this.pushDiagnostic1(classElementFullStart, classElement.firstToken(), 44 /* Function_implementation_expected */); - return true; - } - - memberFunctionDeclaration = classElement; - if (memberFunctionDeclaration.propertyName.valueText() !== functionOverloadChainName) { - var propertyNameFullStart = classElementFullStart + TypeScript.Syntax.childOffset(classElement, memberFunctionDeclaration.propertyName); - this.pushDiagnostic1(propertyNameFullStart, memberFunctionDeclaration.propertyName, 46 /* Function_overload_name_must_be__0_ */, [functionOverloadChainName]); - return true; - } - } else if (inConstructorOverloadChain) { - if (classElement.kind() !== 137 /* ConstructorDeclaration */) { - this.pushDiagnostic1(classElementFullStart, classElement.firstToken(), 45 /* Constructor_implementation_expected */); - return true; - } - } - - if (classElement.kind() === 135 /* MemberFunctionDeclaration */) { - memberFunctionDeclaration = classElement; - - inFunctionOverloadChain = memberFunctionDeclaration.block === null; - functionOverloadChainName = memberFunctionDeclaration.propertyName.valueText(); - - if (lastElement && inFunctionOverloadChain) { - this.pushDiagnostic1(classElementFullStart, classElement.firstToken(), 44 /* Function_implementation_expected */); - return true; - } - } else if (classElement.kind() === 137 /* ConstructorDeclaration */) { - var constructorDeclaration = classElement; - - inConstructorOverloadChain = constructorDeclaration.block === null; - if (lastElement && inConstructorOverloadChain) { - this.pushDiagnostic1(classElementFullStart, classElement.firstToken(), 45 /* Constructor_implementation_expected */); - return true; - } - } - - classElementFullStart += classElement.fullWidth(); - } - } - - return false; - }; - - GrammarCheckerWalker.prototype.checkForReservedName = function (parent, name, code) { - var nameFullStart = this.childFullStart(parent, name); - var token; - var tokenFullStart; - - var current = name; - while (current !== null) { - if (current.kind() === 122 /* QualifiedName */) { - var qualifiedName = current; - token = qualifiedName.right; - tokenFullStart = nameFullStart + this.childFullStart(qualifiedName, token); - current = qualifiedName.left; - } else { - TypeScript.Debug.assert(current.kind() === 11 /* IdentifierName */); - token = current; - tokenFullStart = nameFullStart; - current = null; - } - - switch (token.valueText()) { - case "any": - case "number": - case "bool": - case "string": - case "void": - this.pushDiagnostic(tokenFullStart + token.leadingTriviaWidth(), token.width(), code, [token.valueText()]); - return true; - } - } - - return false; - }; - - GrammarCheckerWalker.prototype.visitClassDeclaration = function (node) { - if (this.checkForReservedName(node, node.identifier, 60 /* Class_name_cannot_be__0_ */) || this.checkForDisallowedDeclareModifier(node.modifiers) || this.checkForRequiredDeclareModifier(node, node.classKeyword, node.modifiers) || this.checkModuleElementModifiers(node.modifiers) || this.checkClassDeclarationHeritageClauses(node) || this.checkClassOverloads(node)) { - this.skip(node); - return; - } - - var savedInAmbientDeclaration = this.inAmbientDeclaration; - this.inAmbientDeclaration = this.inAmbientDeclaration || this.syntaxTree.isDeclaration() || TypeScript.SyntaxUtilities.containsToken(node.modifiers, 64 /* DeclareKeyword */); - _super.prototype.visitClassDeclaration.call(this, node); - this.inAmbientDeclaration = savedInAmbientDeclaration; - }; - - GrammarCheckerWalker.prototype.checkInterfaceDeclarationHeritageClauses = function (node) { - var heritageClauseFullStart = this.childFullStart(node, node.heritageClauses); - - var seenExtendsClause = false; - - for (var i = 0, n = node.heritageClauses.childCount(); i < n; i++) { - TypeScript.Debug.assert(i <= 1); - var heritageClause = node.heritageClauses.childAt(i); - - if (heritageClause.extendsOrImplementsKeyword.tokenKind === 48 /* ExtendsKeyword */) { - if (seenExtendsClause) { - this.pushDiagnostic1(heritageClauseFullStart, heritageClause, 28 /* _extends__clause_already_seen */); - return true; - } - - seenExtendsClause = true; - } else { - TypeScript.Debug.assert(heritageClause.extendsOrImplementsKeyword.tokenKind === 51 /* ImplementsKeyword */); - this.pushDiagnostic1(heritageClauseFullStart, heritageClause, 36 /* Interface_declaration_cannot_have__implements__clause */); - return true; - } - - heritageClauseFullStart += heritageClause.fullWidth(); - } - - return false; - }; - - GrammarCheckerWalker.prototype.checkInterfaceModifiers = function (modifiers) { - var modifierFullStart = this.position(); - - for (var i = 0, n = modifiers.childCount(); i < n; i++) { - var modifier = modifiers.childAt(i); - if (modifier.tokenKind === 64 /* DeclareKeyword */) { - this.pushDiagnostic1(modifierFullStart, modifier, 48 /* _declare__modifier_cannot_appear_on_an_interface_declaration */); - return true; - } - - modifierFullStart += modifier.fullWidth(); - } - - return false; - }; - - GrammarCheckerWalker.prototype.visitInterfaceDeclaration = function (node) { - if (this.checkForReservedName(node, node.identifier, 61 /* Interface_name_cannot_be__0_ */) || this.checkInterfaceModifiers(node.modifiers) || this.checkModuleElementModifiers(node.modifiers) || this.checkInterfaceDeclarationHeritageClauses(node)) { - this.skip(node); - return; - } - - _super.prototype.visitInterfaceDeclaration.call(this, node); - }; - - GrammarCheckerWalker.prototype.checkClassElementModifiers = function (list) { - var modifierFullStart = this.position(); - - var seenAccessibilityModifier = false; - var seenStaticModifier = false; - - for (var i = 0, n = list.childCount(); i < n; i++) { - var modifier = list.childAt(i); - if (modifier.tokenKind === 57 /* PublicKeyword */ || modifier.tokenKind === 55 /* PrivateKeyword */) { - if (seenAccessibilityModifier) { - this.pushDiagnostic1(modifierFullStart, modifier, 32 /* Accessibility_modifier_already_seen */); - return true; - } - - if (seenStaticModifier) { - var previousToken = list.childAt(i - 1); - this.pushDiagnostic1(modifierFullStart, modifier, 33 /* _0__modifier_must_precede__1__modifier */, [modifier.text(), previousToken.text()]); - return true; - } - - seenAccessibilityModifier = true; - } else if (modifier.tokenKind === 58 /* StaticKeyword */) { - if (seenStaticModifier) { - this.pushDiagnostic1(modifierFullStart, modifier, 34 /* _0__modifier_already_seen */, [modifier.text()]); - return true; - } - - seenStaticModifier = true; - } else { - this.pushDiagnostic1(modifierFullStart, modifier, 35 /* _0__modifier_cannot_appear_on_a_class_element */, [modifier.text()]); - return true; - } - - modifierFullStart += modifier.fullWidth(); - } - - return false; - }; - - GrammarCheckerWalker.prototype.visitMemberVariableDeclaration = function (node) { - if (this.checkClassElementModifiers(node.modifiers)) { - this.skip(node); - return; - } - - _super.prototype.visitMemberVariableDeclaration.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitMemberFunctionDeclaration = function (node) { - if (this.checkClassElementModifiers(node.modifiers)) { - this.skip(node); - return; - } - - _super.prototype.visitMemberFunctionDeclaration.call(this, node); - }; - - GrammarCheckerWalker.prototype.checkGetMemberAccessorParameter = function (node) { - var getKeywordFullStart = this.childFullStart(node, node.getKeyword); - if (node.parameterList.parameters.childCount() !== 0) { - this.pushDiagnostic1(getKeywordFullStart, node.getKeyword, 55 /* _get__accessor_cannot_have_parameters */); - return true; - } - - return false; - }; - - GrammarCheckerWalker.prototype.checkEcmaScriptVersionIsAtLeast = function (parent, node, languageVersion, code) { - if (this.syntaxTree.languageVersion() < languageVersion) { - var nodeFullStart = this.childFullStart(parent, node); - this.pushDiagnostic1(nodeFullStart, node, code); - return true; - } - - return false; - }; - - GrammarCheckerWalker.prototype.visitGetMemberAccessorDeclaration = function (node) { - if (this.checkEcmaScriptVersionIsAtLeast(node, node.getKeyword, 1 /* EcmaScript5 */, 59 /* Accessors_are_only_available_when_targeting_EcmaScript5_and_higher */) || this.checkClassElementModifiers(node.modifiers) || this.checkGetMemberAccessorParameter(node)) { - this.skip(node); - return; - } - - _super.prototype.visitGetMemberAccessorDeclaration.call(this, node); - }; - - GrammarCheckerWalker.prototype.checkSetMemberAccessorParameter = function (node) { - var setKeywordFullStart = this.childFullStart(node, node.setKeyword); - if (node.parameterList.parameters.childCount() !== 1) { - this.pushDiagnostic1(setKeywordFullStart, node.setKeyword, 50 /* _set__accessor_must_have_only_one_parameter */); - return true; - } - - var parameterListFullStart = this.childFullStart(node, node.parameterList); - var parameterFullStart = parameterListFullStart + TypeScript.Syntax.childOffset(node.parameterList, node.parameterList.openParenToken); - var parameter = node.parameterList.parameters.childAt(0); - - if (parameter.publicOrPrivateKeyword) { - this.pushDiagnostic1(parameterFullStart, parameter, 51 /* _set__accessor_parameter_cannot_have_accessibility_modifier */); - return true; - } - - if (parameter.questionToken) { - this.pushDiagnostic1(parameterFullStart, parameter, 52 /* _set__accessor_parameter_cannot_be_optional */); - return true; - } - - if (parameter.equalsValueClause) { - this.pushDiagnostic1(parameterFullStart, parameter, 53 /* _set__accessor_parameter_cannot_have_initializer */); - return true; - } - - if (parameter.dotDotDotToken) { - this.pushDiagnostic1(parameterFullStart, parameter, 54 /* _set__accessor_cannot_have_rest_parameter */); - return true; - } - - return false; - }; - - GrammarCheckerWalker.prototype.visitSetMemberAccessorDeclaration = function (node) { - if (this.checkEcmaScriptVersionIsAtLeast(node, node.setKeyword, 1 /* EcmaScript5 */, 59 /* Accessors_are_only_available_when_targeting_EcmaScript5_and_higher */) || this.checkClassElementModifiers(node.modifiers) || this.checkSetMemberAccessorParameter(node)) { - this.skip(node); - return; - } - - _super.prototype.visitSetMemberAccessorDeclaration.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitGetAccessorPropertyAssignment = function (node) { - if (this.checkEcmaScriptVersionIsAtLeast(node, node.getKeyword, 1 /* EcmaScript5 */, 59 /* Accessors_are_only_available_when_targeting_EcmaScript5_and_higher */)) { - this.skip(node); - return; - } - - _super.prototype.visitGetAccessorPropertyAssignment.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitSetAccessorPropertyAssignment = function (node) { - if (this.checkEcmaScriptVersionIsAtLeast(node, node.setKeyword, 1 /* EcmaScript5 */, 59 /* Accessors_are_only_available_when_targeting_EcmaScript5_and_higher */)) { - this.skip(node); - return; - } - - _super.prototype.visitSetAccessorPropertyAssignment.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitEnumDeclaration = function (node) { - if (this.checkForReservedName(node, node.identifier, 62 /* Enum_name_cannot_be__0_ */) || this.checkForDisallowedDeclareModifier(node.modifiers) || this.checkForRequiredDeclareModifier(node, node.enumKeyword, node.modifiers) || this.checkModuleElementModifiers(node.modifiers), this.checkEnumElements(node)) { - this.skip(node); - return; - } - - var savedInAmbientDeclaration = this.inAmbientDeclaration; - this.inAmbientDeclaration = this.inAmbientDeclaration || this.syntaxTree.isDeclaration() || TypeScript.SyntaxUtilities.containsToken(node.modifiers, 64 /* DeclareKeyword */); - _super.prototype.visitEnumDeclaration.call(this, node); - this.inAmbientDeclaration = savedInAmbientDeclaration; - }; - - GrammarCheckerWalker.prototype.checkEnumElements = function (node) { - var enumElementFullStart = this.childFullStart(node, node.enumElements); - - var seenComputedValue = false; - for (var i = 0, n = node.enumElements.childCount(); i < n; i++) { - var child = node.enumElements.childAt(i); - - if (i % 2 === 0) { - var enumElement = child; - - if (!enumElement.equalsValueClause && seenComputedValue) { - this.pushDiagnostic1(enumElementFullStart, enumElement, 64 /* Enum_member_must_have_initializer */, null); - return true; - } - - if (enumElement.equalsValueClause) { - var value = enumElement.equalsValueClause.value; - if (value.kind() !== 13 /* NumericLiteral */) { - seenComputedValue = true; - } - } - } - - enumElementFullStart += child.fullWidth(); - } - - return false; - }; - - GrammarCheckerWalker.prototype.visitInvocationExpression = function (node) { - if (node.expression.kind() === 50 /* SuperKeyword */ && node.argumentList.typeArgumentList !== null) { - this.pushDiagnostic1(this.position(), node, 37 /* _super__invocation_cannot_have_type_arguments */); - } - - _super.prototype.visitInvocationExpression.call(this, node); - }; - - GrammarCheckerWalker.prototype.checkModuleElementModifiers = function (modifiers) { - var modifierFullStart = this.position(); - var seenExportModifier = false; - var seenDeclareModifier = false; - - for (var i = 0, n = modifiers.childCount(); i < n; i++) { - var modifier = modifiers.childAt(i); - if (modifier.tokenKind === 57 /* PublicKeyword */ || modifier.tokenKind === 55 /* PrivateKeyword */ || modifier.tokenKind === 58 /* StaticKeyword */) { - this.pushDiagnostic1(modifierFullStart, modifier, 47 /* _0__modifier_cannot_appear_on_a_module_element */, [modifier.text()]); - return true; - } - - if (modifier.tokenKind === 64 /* DeclareKeyword */) { - if (seenDeclareModifier) { - this.pushDiagnostic1(modifierFullStart, modifier, 32 /* Accessibility_modifier_already_seen */); - return; - } - - seenDeclareModifier = true; - } else if (modifier.tokenKind === 47 /* ExportKeyword */) { - if (seenExportModifier) { - this.pushDiagnostic1(modifierFullStart, modifier, 34 /* _0__modifier_already_seen */, [modifier.text()]); - return; - } - - if (seenDeclareModifier) { - this.pushDiagnostic1(modifierFullStart, modifier, 33 /* _0__modifier_must_precede__1__modifier */, [TypeScript.SyntaxFacts.getText(47 /* ExportKeyword */), TypeScript.SyntaxFacts.getText(64 /* DeclareKeyword */)]); - return; - } - - seenExportModifier = true; - } - - modifierFullStart += modifier.fullWidth(); - } - - return false; - }; - - GrammarCheckerWalker.prototype.checkForDisallowedImportDeclaration = function (node) { - if (node.stringLiteral === null) { - var currentElementFullStart = this.childFullStart(node, node.moduleElements); - - for (var i = 0, n = node.moduleElements.childCount(); i < n; i++) { - var child = node.moduleElements.childAt(i); - if (child.kind() === 133 /* ImportDeclaration */) { - var importDeclaration = child; - if (importDeclaration.moduleReference.kind() === 245 /* ExternalModuleReference */) { - this.pushDiagnostic1(currentElementFullStart, importDeclaration, 201 /* Import_declarations_in_an_internal_module_cannot_reference_an_external_module */, null); - } - } - - currentElementFullStart += child.fullWidth(); - } - } - - return false; - }; - - GrammarCheckerWalker.prototype.visitModuleDeclaration = function (node) { - if (this.checkForReservedName(node, node.moduleName, 63 /* Module_name_cannot_be__0_ */) || this.checkForDisallowedDeclareModifier(node.modifiers) || this.checkForRequiredDeclareModifier(node, node.moduleKeyword, node.modifiers) || this.checkModuleElementModifiers(node.modifiers) || this.checkForDisallowedImportDeclaration(node) || this.checkForDisallowedExports(node, node.moduleElements) || this.checkForMultipleExportAssignments(node, node.moduleElements)) { - this.skip(node); - return; - } - - if (!TypeScript.SyntaxUtilities.containsToken(node.modifiers, 64 /* DeclareKeyword */) && this.checkFunctionOverloads(node, node.moduleElements)) { - this.skip(node); - return; - } - - if (node.stringLiteral && !this.inAmbientDeclaration && !TypeScript.SyntaxUtilities.containsToken(node.modifiers, 64 /* DeclareKeyword */)) { - var stringLiteralFullStart = this.childFullStart(node, node.stringLiteral); - this.pushDiagnostic1(stringLiteralFullStart, node.stringLiteral, 38 /* Non_ambient_modules_cannot_use_quoted_names */); - this.skip(node); - return; - } - - if (!node.stringLiteral && this.checkForDisallowedExportAssignment(node)) { - this.skip(node); - return; - } - - var savedInAmbientDeclaration = this.inAmbientDeclaration; - this.inAmbientDeclaration = this.inAmbientDeclaration || this.syntaxTree.isDeclaration() || TypeScript.SyntaxUtilities.containsToken(node.modifiers, 64 /* DeclareKeyword */); - _super.prototype.visitModuleDeclaration.call(this, node); - this.inAmbientDeclaration = savedInAmbientDeclaration; - }; - - GrammarCheckerWalker.prototype.checkForDisallowedExports = function (node, moduleElements) { - var seenExportedElement = false; - for (var i = 0, n = moduleElements.childCount(); i < n; i++) { - var child = moduleElements.childAt(i); - - if (TypeScript.SyntaxUtilities.hasExportKeyword(child)) { - seenExportedElement = true; - break; - } - } - - var moduleElementFullStart = this.childFullStart(node, moduleElements); - if (seenExportedElement) { - for (var i = 0, n = moduleElements.childCount(); i < n; i++) { - var child = moduleElements.childAt(i); - - if (child.kind() === 134 /* ExportAssignment */) { - this.pushDiagnostic1(moduleElementFullStart, child, 67 /* Export_assignment_not_allowed_in_module_with_exported_element */); - return true; - } - - moduleElementFullStart += child.fullWidth(); - } - } - - return false; - }; - - GrammarCheckerWalker.prototype.checkForMultipleExportAssignments = function (node, moduleElements) { - var moduleElementFullStart = this.childFullStart(node, moduleElements); - var seenExportAssignment = false; - var errorFound = false; - for (var i = 0, n = moduleElements.childCount(); i < n; i++) { - var child = moduleElements.childAt(i); - if (child.kind() === 134 /* ExportAssignment */) { - if (seenExportAssignment) { - this.pushDiagnostic1(moduleElementFullStart, child, 68 /* Module_cannot_have_multiple_export_assignments */); - errorFound = true; - } - seenExportAssignment = true; - } - - moduleElementFullStart += child.fullWidth(); - } - - return errorFound; - }; - - GrammarCheckerWalker.prototype.checkForDisallowedExportAssignment = function (node) { - var moduleElementFullStart = this.childFullStart(node, node.moduleElements); - - for (var i = 0, n = node.moduleElements.childCount(); i < n; i++) { - var child = node.moduleElements.childAt(i); - - if (child.kind() === 134 /* ExportAssignment */) { - this.pushDiagnostic1(moduleElementFullStart, child, 66 /* Export_assignments_cannot_be_used_in_internal_modules */); - - return true; - } - - moduleElementFullStart += child.fullWidth(); - } - - return false; - }; - - GrammarCheckerWalker.prototype.visitBlock = function (node) { - if (this.inAmbientDeclaration || this.syntaxTree.isDeclaration()) { - this.pushDiagnostic1(this.position(), node.firstToken(), 40 /* Implementations_are_not_allowed_in_ambient_contexts */); - this.skip(node); - return; - } - - if (this.checkFunctionOverloads(node, node.statements)) { - this.skip(node); - return; - } - - var savedInBlock = this.inBlock; - this.inBlock = true; - _super.prototype.visitBlock.call(this, node); - this.inBlock = savedInBlock; - }; - - GrammarCheckerWalker.prototype.checkForStatementInAmbientContxt = function (node) { - if (this.inAmbientDeclaration || this.syntaxTree.isDeclaration()) { - this.pushDiagnostic1(this.position(), node.firstToken(), 39 /* Statements_are_not_allowed_in_ambient_contexts */); - return true; - } - - return false; - }; - - GrammarCheckerWalker.prototype.visitBreakStatement = function (node) { - if (this.checkForStatementInAmbientContxt(node)) { - this.skip(node); - return; - } - - _super.prototype.visitBreakStatement.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitContinueStatement = function (node) { - if (this.checkForStatementInAmbientContxt(node)) { - this.skip(node); - return; - } - - _super.prototype.visitContinueStatement.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitDebuggerStatement = function (node) { - if (this.checkForStatementInAmbientContxt(node)) { - this.skip(node); - return; - } - - _super.prototype.visitDebuggerStatement.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitDoStatement = function (node) { - if (this.checkForStatementInAmbientContxt(node)) { - this.skip(node); - return; - } - - _super.prototype.visitDoStatement.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitEmptyStatement = function (node) { - if (this.checkForStatementInAmbientContxt(node)) { - this.skip(node); - return; - } - - _super.prototype.visitEmptyStatement.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitExpressionStatement = function (node) { - if (this.checkForStatementInAmbientContxt(node)) { - this.skip(node); - return; - } - - _super.prototype.visitExpressionStatement.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitForInStatement = function (node) { - if (this.checkForStatementInAmbientContxt(node)) { - this.skip(node); - return; - } - - _super.prototype.visitForInStatement.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitForStatement = function (node) { - if (this.checkForStatementInAmbientContxt(node)) { - this.skip(node); - return; - } - - _super.prototype.visitForStatement.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitIfStatement = function (node) { - if (this.checkForStatementInAmbientContxt(node)) { - this.skip(node); - return; - } - - _super.prototype.visitIfStatement.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitLabeledStatement = function (node) { - if (this.checkForStatementInAmbientContxt(node)) { - this.skip(node); - return; - } - - _super.prototype.visitLabeledStatement.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitReturnStatement = function (node) { - if (this.checkForStatementInAmbientContxt(node)) { - this.skip(node); - return; - } - - _super.prototype.visitReturnStatement.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitSwitchStatement = function (node) { - if (this.checkForStatementInAmbientContxt(node)) { - this.skip(node); - return; - } - - _super.prototype.visitSwitchStatement.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitThrowStatement = function (node) { - if (this.checkForStatementInAmbientContxt(node)) { - this.skip(node); - return; - } - - _super.prototype.visitThrowStatement.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitTryStatement = function (node) { - if (this.checkForStatementInAmbientContxt(node)) { - this.skip(node); - return; - } - - _super.prototype.visitTryStatement.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitWhileStatement = function (node) { - if (this.checkForStatementInAmbientContxt(node)) { - this.skip(node); - return; - } - - _super.prototype.visitWhileStatement.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitWithStatement = function (node) { - if (this.checkForStatementInAmbientContxt(node)) { - this.skip(node); - return; - } - - _super.prototype.visitWithStatement.call(this, node); - }; - - GrammarCheckerWalker.prototype.checkForDisallowedModifiers = function (parent, modifiers) { - if (this.inBlock && modifiers.childCount() > 0) { - var modifierFullStart = this.childFullStart(parent, modifiers); - this.pushDiagnostic1(modifierFullStart, modifiers.childAt(0), 58 /* Modifiers_cannot_appear_here */); - return true; - } - - return false; - }; - - GrammarCheckerWalker.prototype.visitFunctionDeclaration = function (node) { - if (this.checkForDisallowedDeclareModifier(node.modifiers) || this.checkForDisallowedModifiers(node, node.modifiers) || this.checkForRequiredDeclareModifier(node, node.functionKeyword, node.modifiers) || this.checkModuleElementModifiers(node.modifiers)) { - this.skip(node); - return; - } - - var savedInAmbientDeclaration = this.inAmbientDeclaration; - this.inAmbientDeclaration = this.inAmbientDeclaration || this.syntaxTree.isDeclaration() || TypeScript.SyntaxUtilities.containsToken(node.modifiers, 64 /* DeclareKeyword */); - _super.prototype.visitFunctionDeclaration.call(this, node); - this.inAmbientDeclaration = savedInAmbientDeclaration; - }; - - GrammarCheckerWalker.prototype.visitVariableStatement = function (node) { - if (this.checkForDisallowedDeclareModifier(node.modifiers) || this.checkForDisallowedModifiers(node, node.modifiers) || this.checkForRequiredDeclareModifier(node, node.variableDeclaration, node.modifiers) || this.checkModuleElementModifiers(node.modifiers)) { - this.skip(node); - return; - } - - var savedInAmbientDeclaration = this.inAmbientDeclaration; - this.inAmbientDeclaration = this.inAmbientDeclaration || this.syntaxTree.isDeclaration() || TypeScript.SyntaxUtilities.containsToken(node.modifiers, 64 /* DeclareKeyword */); - _super.prototype.visitVariableStatement.call(this, node); - this.inAmbientDeclaration = savedInAmbientDeclaration; - }; - - GrammarCheckerWalker.prototype.checkListSeparators = function (parent, list, kind) { - var currentElementFullStart = this.childFullStart(parent, list); - - for (var i = 0, n = list.childCount(); i < n; i++) { - var child = list.childAt(i); - if (i % 2 === 1 && child.kind() !== kind) { - this.pushDiagnostic1(currentElementFullStart, child, 9 /* _0_expected */, [TypeScript.SyntaxFacts.getText(kind)]); - } - - currentElementFullStart += child.fullWidth(); - } - - return false; - }; - - GrammarCheckerWalker.prototype.visitObjectType = function (node) { - if (this.checkListSeparators(node, node.typeMembers, 79 /* SemicolonToken */)) { - this.skip(node); - return; - } - - var savedInAmbientDeclaration = this.inAmbientDeclaration; - this.inAmbientDeclaration = true; - _super.prototype.visitObjectType.call(this, node); - this.inAmbientDeclaration = savedInAmbientDeclaration; - }; - - GrammarCheckerWalker.prototype.visitArrayType = function (node) { - var savedInAmbientDeclaration = this.inAmbientDeclaration; - this.inAmbientDeclaration = true; - _super.prototype.visitArrayType.call(this, node); - this.inAmbientDeclaration = savedInAmbientDeclaration; - }; - - GrammarCheckerWalker.prototype.visitFunctionType = function (node) { - var savedInAmbientDeclaration = this.inAmbientDeclaration; - this.inAmbientDeclaration = true; - _super.prototype.visitFunctionType.call(this, node); - this.inAmbientDeclaration = savedInAmbientDeclaration; - }; - - GrammarCheckerWalker.prototype.visitConstructorType = function (node) { - var savedInAmbientDeclaration = this.inAmbientDeclaration; - this.inAmbientDeclaration = true; - _super.prototype.visitConstructorType.call(this, node); - this.inAmbientDeclaration = savedInAmbientDeclaration; - }; - - GrammarCheckerWalker.prototype.visitEqualsValueClause = function (node) { - if (this.inAmbientDeclaration) { - this.pushDiagnostic1(this.position(), node.firstToken(), 42 /* Initializers_are_not_allowed_in_ambient_contexts */); - this.skip(node); - return; - } - - _super.prototype.visitEqualsValueClause.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitConstructorDeclaration = function (node) { - var savedCurrentConstructor = this.currentConstructor; - this.currentConstructor = node; - _super.prototype.visitConstructorDeclaration.call(this, node); - this.currentConstructor = savedCurrentConstructor; - }; - - GrammarCheckerWalker.prototype.visitSourceUnit = function (node) { - if (this.checkFunctionOverloads(node, node.moduleElements) || this.checkForDisallowedExports(node, node.moduleElements) || this.checkForMultipleExportAssignments(node, node.moduleElements)) { - this.skip(node); - return; - } - - _super.prototype.visitSourceUnit.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitExternalModuleReference = function (node) { - if (node.moduleOrRequireKeyword.tokenKind === 66 /* ModuleKeyword */ && !this.syntaxTree.parseOptions().allowModuleKeywordInExternalModuleReference()) { - this.pushDiagnostic1(this.position(), node.moduleOrRequireKeyword, 65 /* _module_______is_deprecated__Use__require_______instead */); - this.skip(node); - return; - } - - _super.prototype.visitExternalModuleReference.call(this, node); - }; - return GrammarCheckerWalker; - })(TypeScript.PositionTrackingWalker); -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var TextSpanWalker = (function (_super) { - __extends(TextSpanWalker, _super); - function TextSpanWalker(textSpan) { - _super.call(this); - this.textSpan = textSpan; - this._position = 0; - } - TextSpanWalker.prototype.visitToken = function (token) { - this._position += token.fullWidth(); - }; - - TextSpanWalker.prototype.visitNode = function (node) { - var nodeSpan = new TypeScript.TextSpan(this.position(), node.fullWidth()); - - if (nodeSpan.intersectsWithTextSpan(this.textSpan)) { - node.accept(this); - } else { - this._position += node.fullWidth(); - } - }; - - TextSpanWalker.prototype.position = function () { - return this._position; - }; - return TextSpanWalker; - })(TypeScript.SyntaxWalker); -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var Unicode = (function () { - function Unicode() { - } - Unicode.lookupInUnicodeMap = function (code, map) { - if (code < map[0]) { - return false; - } - - var lo = 0; - var hi = map.length; - var mid; - - while (lo + 1 < hi) { - mid = lo + (hi - lo) / 2; - - mid -= mid % 2; - if (map[mid] <= code && code <= map[mid + 1]) { - return true; - } - - if (code < map[mid]) { - hi = mid; - } else { - lo = mid + 2; - } - } - - return false; - }; - - Unicode.isIdentifierStart = function (code, languageVersion) { - if (languageVersion === 0 /* EcmaScript3 */) { - return Unicode.lookupInUnicodeMap(code, Unicode.unicodeES3IdentifierStart); - } else if (languageVersion === 1 /* EcmaScript5 */) { - return Unicode.lookupInUnicodeMap(code, Unicode.unicodeES5IdentifierStart); - } else { - throw TypeScript.Errors.argumentOutOfRange("languageVersion"); - } - }; - - Unicode.isIdentifierPart = function (code, languageVersion) { - if (languageVersion === 0 /* EcmaScript3 */) { - return Unicode.lookupInUnicodeMap(code, Unicode.unicodeES3IdentifierPart); - } else if (languageVersion === 1 /* EcmaScript5 */) { - return Unicode.lookupInUnicodeMap(code, Unicode.unicodeES5IdentifierPart); - } else { - throw TypeScript.Errors.argumentOutOfRange("languageVersion"); - } - }; - Unicode.unicodeES3IdentifierStart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 543, 546, 563, 592, 685, 688, 696, 699, 705, 720, 721, 736, 740, 750, 750, 890, 890, 902, 902, 904, 906, 908, 908, 910, 929, 931, 974, 976, 983, 986, 1011, 1024, 1153, 1164, 1220, 1223, 1224, 1227, 1228, 1232, 1269, 1272, 1273, 1329, 1366, 1369, 1369, 1377, 1415, 1488, 1514, 1520, 1522, 1569, 1594, 1600, 1610, 1649, 1747, 1749, 1749, 1765, 1766, 1786, 1788, 1808, 1808, 1810, 1836, 1920, 1957, 2309, 2361, 2365, 2365, 2384, 2384, 2392, 2401, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2524, 2525, 2527, 2529, 2544, 2545, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2649, 2652, 2654, 2654, 2674, 2676, 2693, 2699, 2701, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2749, 2749, 2768, 2768, 2784, 2784, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2870, 2873, 2877, 2877, 2908, 2909, 2911, 2913, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 2997, 2999, 3001, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3168, 3169, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3294, 3294, 3296, 3297, 3333, 3340, 3342, 3344, 3346, 3368, 3370, 3385, 3424, 3425, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3585, 3632, 3634, 3635, 3648, 3654, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3760, 3762, 3763, 3773, 3773, 3776, 3780, 3782, 3782, 3804, 3805, 3840, 3840, 3904, 3911, 3913, 3946, 3976, 3979, 4096, 4129, 4131, 4135, 4137, 4138, 4176, 4181, 4256, 4293, 4304, 4342, 4352, 4441, 4447, 4514, 4520, 4601, 4608, 4614, 4616, 4678, 4680, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4742, 4744, 4744, 4746, 4749, 4752, 4782, 4784, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4814, 4816, 4822, 4824, 4846, 4848, 4878, 4880, 4880, 4882, 4885, 4888, 4894, 4896, 4934, 4936, 4954, 5024, 5108, 5121, 5740, 5743, 5750, 5761, 5786, 5792, 5866, 6016, 6067, 6176, 6263, 6272, 6312, 7680, 7835, 7840, 7929, 7936, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8319, 8319, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8497, 8499, 8505, 8544, 8579, 12293, 12295, 12321, 12329, 12337, 12341, 12344, 12346, 12353, 12436, 12445, 12446, 12449, 12538, 12540, 12542, 12549, 12588, 12593, 12686, 12704, 12727, 13312, 19893, 19968, 40869, 40960, 42124, 44032, 55203, 63744, 64045, 64256, 64262, 64275, 64279, 64285, 64285, 64287, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65136, 65138, 65140, 65140, 65142, 65276, 65313, 65338, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500]; - Unicode.unicodeES3IdentifierPart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 543, 546, 563, 592, 685, 688, 696, 699, 705, 720, 721, 736, 740, 750, 750, 768, 846, 864, 866, 890, 890, 902, 902, 904, 906, 908, 908, 910, 929, 931, 974, 976, 983, 986, 1011, 1024, 1153, 1155, 1158, 1164, 1220, 1223, 1224, 1227, 1228, 1232, 1269, 1272, 1273, 1329, 1366, 1369, 1369, 1377, 1415, 1425, 1441, 1443, 1465, 1467, 1469, 1471, 1471, 1473, 1474, 1476, 1476, 1488, 1514, 1520, 1522, 1569, 1594, 1600, 1621, 1632, 1641, 1648, 1747, 1749, 1756, 1759, 1768, 1770, 1773, 1776, 1788, 1808, 1836, 1840, 1866, 1920, 1968, 2305, 2307, 2309, 2361, 2364, 2381, 2384, 2388, 2392, 2403, 2406, 2415, 2433, 2435, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2492, 2492, 2494, 2500, 2503, 2504, 2507, 2509, 2519, 2519, 2524, 2525, 2527, 2531, 2534, 2545, 2562, 2562, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2620, 2620, 2622, 2626, 2631, 2632, 2635, 2637, 2649, 2652, 2654, 2654, 2662, 2676, 2689, 2691, 2693, 2699, 2701, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2748, 2757, 2759, 2761, 2763, 2765, 2768, 2768, 2784, 2784, 2790, 2799, 2817, 2819, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2870, 2873, 2876, 2883, 2887, 2888, 2891, 2893, 2902, 2903, 2908, 2909, 2911, 2913, 2918, 2927, 2946, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 2997, 2999, 3001, 3006, 3010, 3014, 3016, 3018, 3021, 3031, 3031, 3047, 3055, 3073, 3075, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3134, 3140, 3142, 3144, 3146, 3149, 3157, 3158, 3168, 3169, 3174, 3183, 3202, 3203, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3262, 3268, 3270, 3272, 3274, 3277, 3285, 3286, 3294, 3294, 3296, 3297, 3302, 3311, 3330, 3331, 3333, 3340, 3342, 3344, 3346, 3368, 3370, 3385, 3390, 3395, 3398, 3400, 3402, 3405, 3415, 3415, 3424, 3425, 3430, 3439, 3458, 3459, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3530, 3530, 3535, 3540, 3542, 3542, 3544, 3551, 3570, 3571, 3585, 3642, 3648, 3662, 3664, 3673, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3769, 3771, 3773, 3776, 3780, 3782, 3782, 3784, 3789, 3792, 3801, 3804, 3805, 3840, 3840, 3864, 3865, 3872, 3881, 3893, 3893, 3895, 3895, 3897, 3897, 3902, 3911, 3913, 3946, 3953, 3972, 3974, 3979, 3984, 3991, 3993, 4028, 4038, 4038, 4096, 4129, 4131, 4135, 4137, 4138, 4140, 4146, 4150, 4153, 4160, 4169, 4176, 4185, 4256, 4293, 4304, 4342, 4352, 4441, 4447, 4514, 4520, 4601, 4608, 4614, 4616, 4678, 4680, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4742, 4744, 4744, 4746, 4749, 4752, 4782, 4784, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4814, 4816, 4822, 4824, 4846, 4848, 4878, 4880, 4880, 4882, 4885, 4888, 4894, 4896, 4934, 4936, 4954, 4969, 4977, 5024, 5108, 5121, 5740, 5743, 5750, 5761, 5786, 5792, 5866, 6016, 6099, 6112, 6121, 6160, 6169, 6176, 6263, 6272, 6313, 7680, 7835, 7840, 7929, 7936, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8255, 8256, 8319, 8319, 8400, 8412, 8417, 8417, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8497, 8499, 8505, 8544, 8579, 12293, 12295, 12321, 12335, 12337, 12341, 12344, 12346, 12353, 12436, 12441, 12442, 12445, 12446, 12449, 12542, 12549, 12588, 12593, 12686, 12704, 12727, 13312, 19893, 19968, 40869, 40960, 42124, 44032, 55203, 63744, 64045, 64256, 64262, 64275, 64279, 64285, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65056, 65059, 65075, 65076, 65101, 65103, 65136, 65138, 65140, 65140, 65142, 65276, 65296, 65305, 65313, 65338, 65343, 65343, 65345, 65370, 65381, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500]; - - Unicode.unicodeES5IdentifierStart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 705, 710, 721, 736, 740, 748, 748, 750, 750, 880, 884, 886, 887, 890, 893, 902, 902, 904, 906, 908, 908, 910, 929, 931, 1013, 1015, 1153, 1162, 1319, 1329, 1366, 1369, 1369, 1377, 1415, 1488, 1514, 1520, 1522, 1568, 1610, 1646, 1647, 1649, 1747, 1749, 1749, 1765, 1766, 1774, 1775, 1786, 1788, 1791, 1791, 1808, 1808, 1810, 1839, 1869, 1957, 1969, 1969, 1994, 2026, 2036, 2037, 2042, 2042, 2048, 2069, 2074, 2074, 2084, 2084, 2088, 2088, 2112, 2136, 2208, 2208, 2210, 2220, 2308, 2361, 2365, 2365, 2384, 2384, 2392, 2401, 2417, 2423, 2425, 2431, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2493, 2493, 2510, 2510, 2524, 2525, 2527, 2529, 2544, 2545, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2649, 2652, 2654, 2654, 2674, 2676, 2693, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2749, 2749, 2768, 2768, 2784, 2785, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2869, 2873, 2877, 2877, 2908, 2909, 2911, 2913, 2929, 2929, 2947, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 3001, 3024, 3024, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3133, 3133, 3160, 3161, 3168, 3169, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3261, 3261, 3294, 3294, 3296, 3297, 3313, 3314, 3333, 3340, 3342, 3344, 3346, 3386, 3389, 3389, 3406, 3406, 3424, 3425, 3450, 3455, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3585, 3632, 3634, 3635, 3648, 3654, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3760, 3762, 3763, 3773, 3773, 3776, 3780, 3782, 3782, 3804, 3807, 3840, 3840, 3904, 3911, 3913, 3948, 3976, 3980, 4096, 4138, 4159, 4159, 4176, 4181, 4186, 4189, 4193, 4193, 4197, 4198, 4206, 4208, 4213, 4225, 4238, 4238, 4256, 4293, 4295, 4295, 4301, 4301, 4304, 4346, 4348, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4744, 4746, 4749, 4752, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4822, 4824, 4880, 4882, 4885, 4888, 4954, 4992, 5007, 5024, 5108, 5121, 5740, 5743, 5759, 5761, 5786, 5792, 5866, 5870, 5872, 5888, 5900, 5902, 5905, 5920, 5937, 5952, 5969, 5984, 5996, 5998, 6000, 6016, 6067, 6103, 6103, 6108, 6108, 6176, 6263, 6272, 6312, 6314, 6314, 6320, 6389, 6400, 6428, 6480, 6509, 6512, 6516, 6528, 6571, 6593, 6599, 6656, 6678, 6688, 6740, 6823, 6823, 6917, 6963, 6981, 6987, 7043, 7072, 7086, 7087, 7098, 7141, 7168, 7203, 7245, 7247, 7258, 7293, 7401, 7404, 7406, 7409, 7413, 7414, 7424, 7615, 7680, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8305, 8305, 8319, 8319, 8336, 8348, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8505, 8508, 8511, 8517, 8521, 8526, 8526, 8544, 8584, 11264, 11310, 11312, 11358, 11360, 11492, 11499, 11502, 11506, 11507, 11520, 11557, 11559, 11559, 11565, 11565, 11568, 11623, 11631, 11631, 11648, 11670, 11680, 11686, 11688, 11694, 11696, 11702, 11704, 11710, 11712, 11718, 11720, 11726, 11728, 11734, 11736, 11742, 11823, 11823, 12293, 12295, 12321, 12329, 12337, 12341, 12344, 12348, 12353, 12438, 12445, 12447, 12449, 12538, 12540, 12543, 12549, 12589, 12593, 12686, 12704, 12730, 12784, 12799, 13312, 19893, 19968, 40908, 40960, 42124, 42192, 42237, 42240, 42508, 42512, 42527, 42538, 42539, 42560, 42606, 42623, 42647, 42656, 42735, 42775, 42783, 42786, 42888, 42891, 42894, 42896, 42899, 42912, 42922, 43000, 43009, 43011, 43013, 43015, 43018, 43020, 43042, 43072, 43123, 43138, 43187, 43250, 43255, 43259, 43259, 43274, 43301, 43312, 43334, 43360, 43388, 43396, 43442, 43471, 43471, 43520, 43560, 43584, 43586, 43588, 43595, 43616, 43638, 43642, 43642, 43648, 43695, 43697, 43697, 43701, 43702, 43705, 43709, 43712, 43712, 43714, 43714, 43739, 43741, 43744, 43754, 43762, 43764, 43777, 43782, 43785, 43790, 43793, 43798, 43808, 43814, 43816, 43822, 43968, 44002, 44032, 55203, 55216, 55238, 55243, 55291, 63744, 64109, 64112, 64217, 64256, 64262, 64275, 64279, 64285, 64285, 64287, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65136, 65140, 65142, 65276, 65313, 65338, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500]; - Unicode.unicodeES5IdentifierPart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 705, 710, 721, 736, 740, 748, 748, 750, 750, 768, 884, 886, 887, 890, 893, 902, 902, 904, 906, 908, 908, 910, 929, 931, 1013, 1015, 1153, 1155, 1159, 1162, 1319, 1329, 1366, 1369, 1369, 1377, 1415, 1425, 1469, 1471, 1471, 1473, 1474, 1476, 1477, 1479, 1479, 1488, 1514, 1520, 1522, 1552, 1562, 1568, 1641, 1646, 1747, 1749, 1756, 1759, 1768, 1770, 1788, 1791, 1791, 1808, 1866, 1869, 1969, 1984, 2037, 2042, 2042, 2048, 2093, 2112, 2139, 2208, 2208, 2210, 2220, 2276, 2302, 2304, 2403, 2406, 2415, 2417, 2423, 2425, 2431, 2433, 2435, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2492, 2500, 2503, 2504, 2507, 2510, 2519, 2519, 2524, 2525, 2527, 2531, 2534, 2545, 2561, 2563, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2620, 2620, 2622, 2626, 2631, 2632, 2635, 2637, 2641, 2641, 2649, 2652, 2654, 2654, 2662, 2677, 2689, 2691, 2693, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2748, 2757, 2759, 2761, 2763, 2765, 2768, 2768, 2784, 2787, 2790, 2799, 2817, 2819, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2869, 2873, 2876, 2884, 2887, 2888, 2891, 2893, 2902, 2903, 2908, 2909, 2911, 2915, 2918, 2927, 2929, 2929, 2946, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 3001, 3006, 3010, 3014, 3016, 3018, 3021, 3024, 3024, 3031, 3031, 3046, 3055, 3073, 3075, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3133, 3140, 3142, 3144, 3146, 3149, 3157, 3158, 3160, 3161, 3168, 3171, 3174, 3183, 3202, 3203, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3260, 3268, 3270, 3272, 3274, 3277, 3285, 3286, 3294, 3294, 3296, 3299, 3302, 3311, 3313, 3314, 3330, 3331, 3333, 3340, 3342, 3344, 3346, 3386, 3389, 3396, 3398, 3400, 3402, 3406, 3415, 3415, 3424, 3427, 3430, 3439, 3450, 3455, 3458, 3459, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3530, 3530, 3535, 3540, 3542, 3542, 3544, 3551, 3570, 3571, 3585, 3642, 3648, 3662, 3664, 3673, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3769, 3771, 3773, 3776, 3780, 3782, 3782, 3784, 3789, 3792, 3801, 3804, 3807, 3840, 3840, 3864, 3865, 3872, 3881, 3893, 3893, 3895, 3895, 3897, 3897, 3902, 3911, 3913, 3948, 3953, 3972, 3974, 3991, 3993, 4028, 4038, 4038, 4096, 4169, 4176, 4253, 4256, 4293, 4295, 4295, 4301, 4301, 4304, 4346, 4348, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4744, 4746, 4749, 4752, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4822, 4824, 4880, 4882, 4885, 4888, 4954, 4957, 4959, 4992, 5007, 5024, 5108, 5121, 5740, 5743, 5759, 5761, 5786, 5792, 5866, 5870, 5872, 5888, 5900, 5902, 5908, 5920, 5940, 5952, 5971, 5984, 5996, 5998, 6000, 6002, 6003, 6016, 6099, 6103, 6103, 6108, 6109, 6112, 6121, 6155, 6157, 6160, 6169, 6176, 6263, 6272, 6314, 6320, 6389, 6400, 6428, 6432, 6443, 6448, 6459, 6470, 6509, 6512, 6516, 6528, 6571, 6576, 6601, 6608, 6617, 6656, 6683, 6688, 6750, 6752, 6780, 6783, 6793, 6800, 6809, 6823, 6823, 6912, 6987, 6992, 7001, 7019, 7027, 7040, 7155, 7168, 7223, 7232, 7241, 7245, 7293, 7376, 7378, 7380, 7414, 7424, 7654, 7676, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8204, 8205, 8255, 8256, 8276, 8276, 8305, 8305, 8319, 8319, 8336, 8348, 8400, 8412, 8417, 8417, 8421, 8432, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8505, 8508, 8511, 8517, 8521, 8526, 8526, 8544, 8584, 11264, 11310, 11312, 11358, 11360, 11492, 11499, 11507, 11520, 11557, 11559, 11559, 11565, 11565, 11568, 11623, 11631, 11631, 11647, 11670, 11680, 11686, 11688, 11694, 11696, 11702, 11704, 11710, 11712, 11718, 11720, 11726, 11728, 11734, 11736, 11742, 11744, 11775, 11823, 11823, 12293, 12295, 12321, 12335, 12337, 12341, 12344, 12348, 12353, 12438, 12441, 12442, 12445, 12447, 12449, 12538, 12540, 12543, 12549, 12589, 12593, 12686, 12704, 12730, 12784, 12799, 13312, 19893, 19968, 40908, 40960, 42124, 42192, 42237, 42240, 42508, 42512, 42539, 42560, 42607, 42612, 42621, 42623, 42647, 42655, 42737, 42775, 42783, 42786, 42888, 42891, 42894, 42896, 42899, 42912, 42922, 43000, 43047, 43072, 43123, 43136, 43204, 43216, 43225, 43232, 43255, 43259, 43259, 43264, 43309, 43312, 43347, 43360, 43388, 43392, 43456, 43471, 43481, 43520, 43574, 43584, 43597, 43600, 43609, 43616, 43638, 43642, 43643, 43648, 43714, 43739, 43741, 43744, 43759, 43762, 43766, 43777, 43782, 43785, 43790, 43793, 43798, 43808, 43814, 43816, 43822, 43968, 44010, 44012, 44013, 44016, 44025, 44032, 55203, 55216, 55238, 55243, 55291, 63744, 64109, 64112, 64217, 64256, 64262, 64275, 64279, 64285, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65024, 65039, 65056, 65062, 65075, 65076, 65101, 65103, 65136, 65140, 65142, 65276, 65296, 65305, 65313, 65338, 65343, 65343, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500]; - return Unicode; - })(); - TypeScript.Unicode = Unicode; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - function hasFlag(val, flag) { - return (val & flag) !== 0; - } - TypeScript.hasFlag = hasFlag; - - function withoutFlag(val, flag) { - return val & ~flag; - } - TypeScript.withoutFlag = withoutFlag; - - (function (ASTFlags) { - ASTFlags[ASTFlags["None"] = 0] = "None"; - ASTFlags[ASTFlags["SingleLine"] = 1 << 1] = "SingleLine"; - ASTFlags[ASTFlags["OptionalName"] = 1 << 2] = "OptionalName"; - ASTFlags[ASTFlags["TypeReference"] = 1 << 3] = "TypeReference"; - ASTFlags[ASTFlags["EnumElement"] = 1 << 4] = "EnumElement"; - ASTFlags[ASTFlags["EnumMapElement"] = 1 << 5] = "EnumMapElement"; - })(TypeScript.ASTFlags || (TypeScript.ASTFlags = {})); - var ASTFlags = TypeScript.ASTFlags; - - (function (DeclFlags) { - DeclFlags[DeclFlags["None"] = 0] = "None"; - DeclFlags[DeclFlags["Exported"] = 1] = "Exported"; - DeclFlags[DeclFlags["Private"] = 1 << 1] = "Private"; - DeclFlags[DeclFlags["Public"] = 1 << 2] = "Public"; - DeclFlags[DeclFlags["Ambient"] = 1 << 3] = "Ambient"; - DeclFlags[DeclFlags["Static"] = 1 << 4] = "Static"; - })(TypeScript.DeclFlags || (TypeScript.DeclFlags = {})); - var DeclFlags = TypeScript.DeclFlags; - - (function (ModuleFlags) { - ModuleFlags[ModuleFlags["None"] = 0] = "None"; - ModuleFlags[ModuleFlags["Exported"] = 1] = "Exported"; - ModuleFlags[ModuleFlags["Private"] = 1 << 1] = "Private"; - ModuleFlags[ModuleFlags["Public"] = 1 << 2] = "Public"; - ModuleFlags[ModuleFlags["Ambient"] = 1 << 3] = "Ambient"; - ModuleFlags[ModuleFlags["Static"] = 1 << 4] = "Static"; - ModuleFlags[ModuleFlags["IsEnum"] = 1 << 7] = "IsEnum"; - ModuleFlags[ModuleFlags["IsWholeFile"] = 1 << 8] = "IsWholeFile"; - ModuleFlags[ModuleFlags["IsDynamic"] = 1 << 9] = "IsDynamic"; - })(TypeScript.ModuleFlags || (TypeScript.ModuleFlags = {})); - var ModuleFlags = TypeScript.ModuleFlags; - - (function (VariableFlags) { - VariableFlags[VariableFlags["None"] = 0] = "None"; - VariableFlags[VariableFlags["Exported"] = 1] = "Exported"; - VariableFlags[VariableFlags["Private"] = 1 << 1] = "Private"; - VariableFlags[VariableFlags["Public"] = 1 << 2] = "Public"; - VariableFlags[VariableFlags["Ambient"] = 1 << 3] = "Ambient"; - VariableFlags[VariableFlags["Static"] = 1 << 4] = "Static"; - VariableFlags[VariableFlags["Property"] = 1 << 8] = "Property"; - VariableFlags[VariableFlags["ClassProperty"] = 1 << 11] = "ClassProperty"; - VariableFlags[VariableFlags["Constant"] = 1 << 12] = "Constant"; - - VariableFlags[VariableFlags["EnumElement"] = 1 << 13] = "EnumElement"; - })(TypeScript.VariableFlags || (TypeScript.VariableFlags = {})); - var VariableFlags = TypeScript.VariableFlags; - - (function (FunctionFlags) { - FunctionFlags[FunctionFlags["None"] = 0] = "None"; - FunctionFlags[FunctionFlags["Exported"] = 1] = "Exported"; - FunctionFlags[FunctionFlags["Private"] = 1 << 1] = "Private"; - FunctionFlags[FunctionFlags["Public"] = 1 << 2] = "Public"; - FunctionFlags[FunctionFlags["Ambient"] = 1 << 3] = "Ambient"; - FunctionFlags[FunctionFlags["Static"] = 1 << 4] = "Static"; - FunctionFlags[FunctionFlags["GetAccessor"] = 1 << 5] = "GetAccessor"; - FunctionFlags[FunctionFlags["SetAccessor"] = 1 << 6] = "SetAccessor"; - FunctionFlags[FunctionFlags["Signature"] = 1 << 7] = "Signature"; - FunctionFlags[FunctionFlags["Method"] = 1 << 8] = "Method"; - FunctionFlags[FunctionFlags["CallMember"] = 1 << 9] = "CallMember"; - FunctionFlags[FunctionFlags["ConstructMember"] = 1 << 10] = "ConstructMember"; - FunctionFlags[FunctionFlags["IsFatArrowFunction"] = 1 << 11] = "IsFatArrowFunction"; - FunctionFlags[FunctionFlags["IndexerMember"] = 1 << 12] = "IndexerMember"; - FunctionFlags[FunctionFlags["IsFunctionExpression"] = 1 << 13] = "IsFunctionExpression"; - FunctionFlags[FunctionFlags["IsFunctionProperty"] = 1 << 14] = "IsFunctionProperty"; - })(TypeScript.FunctionFlags || (TypeScript.FunctionFlags = {})); - var FunctionFlags = TypeScript.FunctionFlags; - - function ToDeclFlags(fncOrVarOrModuleFlags) { - return fncOrVarOrModuleFlags; - } - TypeScript.ToDeclFlags = ToDeclFlags; - - (function (TypeRelationshipFlags) { - TypeRelationshipFlags[TypeRelationshipFlags["SuccessfulComparison"] = 0] = "SuccessfulComparison"; - TypeRelationshipFlags[TypeRelationshipFlags["RequiredPropertyIsMissing"] = 1 << 1] = "RequiredPropertyIsMissing"; - TypeRelationshipFlags[TypeRelationshipFlags["IncompatibleSignatures"] = 1 << 2] = "IncompatibleSignatures"; - TypeRelationshipFlags[TypeRelationshipFlags["SourceSignatureHasTooManyParameters"] = 3] = "SourceSignatureHasTooManyParameters"; - TypeRelationshipFlags[TypeRelationshipFlags["IncompatibleReturnTypes"] = 1 << 4] = "IncompatibleReturnTypes"; - TypeRelationshipFlags[TypeRelationshipFlags["IncompatiblePropertyTypes"] = 1 << 5] = "IncompatiblePropertyTypes"; - TypeRelationshipFlags[TypeRelationshipFlags["IncompatibleParameterTypes"] = 1 << 6] = "IncompatibleParameterTypes"; - TypeRelationshipFlags[TypeRelationshipFlags["InconsistantPropertyAccesibility"] = 1 << 7] = "InconsistantPropertyAccesibility"; - })(TypeScript.TypeRelationshipFlags || (TypeScript.TypeRelationshipFlags = {})); - var TypeRelationshipFlags = TypeScript.TypeRelationshipFlags; - - (function (ModuleGenTarget) { - ModuleGenTarget[ModuleGenTarget["Synchronous"] = 0] = "Synchronous"; - ModuleGenTarget[ModuleGenTarget["Asynchronous"] = 1] = "Asynchronous"; - })(TypeScript.ModuleGenTarget || (TypeScript.ModuleGenTarget = {})); - var ModuleGenTarget = TypeScript.ModuleGenTarget; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (NodeType) { - NodeType[NodeType["None"] = 0] = "None"; - NodeType[NodeType["List"] = 1] = "List"; - NodeType[NodeType["Script"] = 2] = "Script"; - - NodeType[NodeType["TrueLiteral"] = 3] = "TrueLiteral"; - NodeType[NodeType["FalseLiteral"] = 4] = "FalseLiteral"; - NodeType[NodeType["StringLiteral"] = 5] = "StringLiteral"; - NodeType[NodeType["RegularExpressionLiteral"] = 6] = "RegularExpressionLiteral"; - NodeType[NodeType["NumericLiteral"] = 7] = "NumericLiteral"; - NodeType[NodeType["NullLiteral"] = 8] = "NullLiteral"; - - NodeType[NodeType["TypeParameter"] = 9] = "TypeParameter"; - NodeType[NodeType["GenericType"] = 10] = "GenericType"; - NodeType[NodeType["TypeRef"] = 11] = "TypeRef"; - - NodeType[NodeType["FunctionDeclaration"] = 12] = "FunctionDeclaration"; - NodeType[NodeType["ClassDeclaration"] = 13] = "ClassDeclaration"; - NodeType[NodeType["InterfaceDeclaration"] = 14] = "InterfaceDeclaration"; - NodeType[NodeType["ModuleDeclaration"] = 15] = "ModuleDeclaration"; - NodeType[NodeType["ImportDeclaration"] = 16] = "ImportDeclaration"; - NodeType[NodeType["VariableDeclarator"] = 17] = "VariableDeclarator"; - NodeType[NodeType["VariableDeclaration"] = 18] = "VariableDeclaration"; - NodeType[NodeType["Parameter"] = 19] = "Parameter"; - - NodeType[NodeType["Name"] = 20] = "Name"; - NodeType[NodeType["ArrayLiteralExpression"] = 21] = "ArrayLiteralExpression"; - NodeType[NodeType["ObjectLiteralExpression"] = 22] = "ObjectLiteralExpression"; - NodeType[NodeType["OmittedExpression"] = 23] = "OmittedExpression"; - NodeType[NodeType["VoidExpression"] = 24] = "VoidExpression"; - NodeType[NodeType["CommaExpression"] = 25] = "CommaExpression"; - NodeType[NodeType["PlusExpression"] = 26] = "PlusExpression"; - NodeType[NodeType["NegateExpression"] = 27] = "NegateExpression"; - NodeType[NodeType["DeleteExpression"] = 28] = "DeleteExpression"; - NodeType[NodeType["ThisExpression"] = 29] = "ThisExpression"; - NodeType[NodeType["SuperExpression"] = 30] = "SuperExpression"; - NodeType[NodeType["InExpression"] = 31] = "InExpression"; - NodeType[NodeType["MemberAccessExpression"] = 32] = "MemberAccessExpression"; - NodeType[NodeType["InstanceOfExpression"] = 33] = "InstanceOfExpression"; - NodeType[NodeType["TypeOfExpression"] = 34] = "TypeOfExpression"; - NodeType[NodeType["ElementAccessExpression"] = 35] = "ElementAccessExpression"; - NodeType[NodeType["InvocationExpression"] = 36] = "InvocationExpression"; - NodeType[NodeType["ObjectCreationExpression"] = 37] = "ObjectCreationExpression"; - NodeType[NodeType["AssignmentExpression"] = 38] = "AssignmentExpression"; - NodeType[NodeType["AddAssignmentExpression"] = 39] = "AddAssignmentExpression"; - NodeType[NodeType["SubtractAssignmentExpression"] = 40] = "SubtractAssignmentExpression"; - NodeType[NodeType["DivideAssignmentExpression"] = 41] = "DivideAssignmentExpression"; - NodeType[NodeType["MultiplyAssignmentExpression"] = 42] = "MultiplyAssignmentExpression"; - NodeType[NodeType["ModuloAssignmentExpression"] = 43] = "ModuloAssignmentExpression"; - NodeType[NodeType["AndAssignmentExpression"] = 44] = "AndAssignmentExpression"; - NodeType[NodeType["ExclusiveOrAssignmentExpression"] = 45] = "ExclusiveOrAssignmentExpression"; - NodeType[NodeType["OrAssignmentExpression"] = 46] = "OrAssignmentExpression"; - NodeType[NodeType["LeftShiftAssignmentExpression"] = 47] = "LeftShiftAssignmentExpression"; - NodeType[NodeType["SignedRightShiftAssignmentExpression"] = 48] = "SignedRightShiftAssignmentExpression"; - NodeType[NodeType["UnsignedRightShiftAssignmentExpression"] = 49] = "UnsignedRightShiftAssignmentExpression"; - NodeType[NodeType["ConditionalExpression"] = 50] = "ConditionalExpression"; - NodeType[NodeType["LogicalOrExpression"] = 51] = "LogicalOrExpression"; - NodeType[NodeType["LogicalAndExpression"] = 52] = "LogicalAndExpression"; - NodeType[NodeType["BitwiseOrExpression"] = 53] = "BitwiseOrExpression"; - NodeType[NodeType["BitwiseExclusiveOrExpression"] = 54] = "BitwiseExclusiveOrExpression"; - NodeType[NodeType["BitwiseAndExpression"] = 55] = "BitwiseAndExpression"; - NodeType[NodeType["EqualsWithTypeConversionExpression"] = 56] = "EqualsWithTypeConversionExpression"; - NodeType[NodeType["NotEqualsWithTypeConversionExpression"] = 57] = "NotEqualsWithTypeConversionExpression"; - NodeType[NodeType["EqualsExpression"] = 58] = "EqualsExpression"; - NodeType[NodeType["NotEqualsExpression"] = 59] = "NotEqualsExpression"; - NodeType[NodeType["LessThanExpression"] = 60] = "LessThanExpression"; - NodeType[NodeType["LessThanOrEqualExpression"] = 61] = "LessThanOrEqualExpression"; - NodeType[NodeType["GreaterThanExpression"] = 62] = "GreaterThanExpression"; - NodeType[NodeType["GreaterThanOrEqualExpression"] = 63] = "GreaterThanOrEqualExpression"; - NodeType[NodeType["AddExpression"] = 64] = "AddExpression"; - NodeType[NodeType["SubtractExpression"] = 65] = "SubtractExpression"; - NodeType[NodeType["MultiplyExpression"] = 66] = "MultiplyExpression"; - NodeType[NodeType["DivideExpression"] = 67] = "DivideExpression"; - NodeType[NodeType["ModuloExpression"] = 68] = "ModuloExpression"; - NodeType[NodeType["LeftShiftExpression"] = 69] = "LeftShiftExpression"; - NodeType[NodeType["SignedRightShiftExpression"] = 70] = "SignedRightShiftExpression"; - NodeType[NodeType["UnsignedRightShiftExpression"] = 71] = "UnsignedRightShiftExpression"; - NodeType[NodeType["BitwiseNotExpression"] = 72] = "BitwiseNotExpression"; - NodeType[NodeType["LogicalNotExpression"] = 73] = "LogicalNotExpression"; - NodeType[NodeType["PreIncrementExpression"] = 74] = "PreIncrementExpression"; - NodeType[NodeType["PreDecrementExpression"] = 75] = "PreDecrementExpression"; - NodeType[NodeType["PostIncrementExpression"] = 76] = "PostIncrementExpression"; - NodeType[NodeType["PostDecrementExpression"] = 77] = "PostDecrementExpression"; - NodeType[NodeType["CastExpression"] = 78] = "CastExpression"; - NodeType[NodeType["ParenthesizedExpression"] = 79] = "ParenthesizedExpression"; - NodeType[NodeType["Member"] = 80] = "Member"; - - NodeType[NodeType["Block"] = 81] = "Block"; - NodeType[NodeType["BreakStatement"] = 82] = "BreakStatement"; - NodeType[NodeType["ContinueStatement"] = 83] = "ContinueStatement"; - NodeType[NodeType["DebuggerStatement"] = 84] = "DebuggerStatement"; - NodeType[NodeType["DoStatement"] = 85] = "DoStatement"; - NodeType[NodeType["EmptyStatement"] = 86] = "EmptyStatement"; - NodeType[NodeType["ExportAssignment"] = 87] = "ExportAssignment"; - NodeType[NodeType["ExpressionStatement"] = 88] = "ExpressionStatement"; - NodeType[NodeType["ForInStatement"] = 89] = "ForInStatement"; - NodeType[NodeType["ForStatement"] = 90] = "ForStatement"; - NodeType[NodeType["IfStatement"] = 91] = "IfStatement"; - NodeType[NodeType["LabeledStatement"] = 92] = "LabeledStatement"; - NodeType[NodeType["ReturnStatement"] = 93] = "ReturnStatement"; - NodeType[NodeType["SwitchStatement"] = 94] = "SwitchStatement"; - NodeType[NodeType["ThrowStatement"] = 95] = "ThrowStatement"; - NodeType[NodeType["TryStatement"] = 96] = "TryStatement"; - NodeType[NodeType["VariableStatement"] = 97] = "VariableStatement"; - NodeType[NodeType["WhileStatement"] = 98] = "WhileStatement"; - NodeType[NodeType["WithStatement"] = 99] = "WithStatement"; - - NodeType[NodeType["CaseClause"] = 100] = "CaseClause"; - NodeType[NodeType["CatchClause"] = 101] = "CatchClause"; - - NodeType[NodeType["Comment"] = 102] = "Comment"; - })(TypeScript.NodeType || (TypeScript.NodeType = {})); - var NodeType = TypeScript.NodeType; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var BlockIntrinsics = (function () { - function BlockIntrinsics() { - this.prototype = undefined; - this.toString = undefined; - this.toLocaleString = undefined; - this.valueOf = undefined; - this.hasOwnProperty = undefined; - this.propertyIsEnumerable = undefined; - this.isPrototypeOf = undefined; - this["constructor"] = undefined; - } - return BlockIntrinsics; - })(); - TypeScript.BlockIntrinsics = BlockIntrinsics; - - var StringHashTable = (function () { - function StringHashTable() { - this.itemCount = 0; - this.table = (new BlockIntrinsics()); - } - StringHashTable.prototype.getAllKeys = function () { - var result = []; - - for (var k in this.table) { - if (this.table[k] !== undefined) { - result.push(k); - } - } - - return result; - }; - - StringHashTable.prototype.add = function (key, data) { - if (this.table[key] !== undefined) { - return false; - } - - this.table[key] = data; - this.itemCount++; - return true; - }; - - StringHashTable.prototype.addOrUpdate = function (key, data) { - if (this.table[key] !== undefined) { - this.table[key] = data; - return false; - } - - this.table[key] = data; - this.itemCount++; - return true; - }; - - StringHashTable.prototype.map = function (fn, context) { - for (var k in this.table) { - var data = this.table[k]; - - if (data !== undefined) { - fn(k, this.table[k], context); - } - } - }; - - StringHashTable.prototype.every = function (fn, context) { - 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; - }; - - StringHashTable.prototype.some = function (fn, context) { - 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; - }; - - StringHashTable.prototype.count = function () { - return this.itemCount; - }; - - StringHashTable.prototype.lookup = function (key) { - var data = this.table[key]; - return data === undefined ? null : data; - }; - return StringHashTable; - })(); - TypeScript.StringHashTable = StringHashTable; - - var IdentiferNameHashTable = (function (_super) { - __extends(IdentiferNameHashTable, _super); - function IdentiferNameHashTable() { - _super.apply(this, arguments); - } - IdentiferNameHashTable.prototype.getAllKeys = function () { - var result = []; - - _super.prototype.map.call(this, function (k, v, c) { - if (v !== undefined) { - result.push(k.substring(1)); - } - }, null); - - return result; - }; - - IdentiferNameHashTable.prototype.add = function (key, data) { - return _super.prototype.add.call(this, "#" + key, data); - }; - - IdentiferNameHashTable.prototype.addOrUpdate = function (key, data) { - return _super.prototype.addOrUpdate.call(this, "#" + key, data); - }; - - IdentiferNameHashTable.prototype.map = function (fn, context) { - return _super.prototype.map.call(this, function (k, v, c) { - return fn(k.substring(1), v, c); - }, context); - }; - - IdentiferNameHashTable.prototype.every = function (fn, context) { - return _super.prototype.every.call(this, function (k, v, c) { - return fn(k.substring(1), v, c); - }, context); - }; - - IdentiferNameHashTable.prototype.some = function (fn, context) { - return _super.prototype.some.call(this, function (k, v, c) { - return fn(k.substring(1), v, c); - }, context); - }; - - IdentiferNameHashTable.prototype.lookup = function (key) { - return _super.prototype.lookup.call(this, "#" + key); - }; - return IdentiferNameHashTable; - })(StringHashTable); - TypeScript.IdentiferNameHashTable = IdentiferNameHashTable; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var ASTSpan = (function () { - function ASTSpan() { - this.minChar = -1; - this.limChar = -1; - this.trailingTriviaWidth = 0; - } - return ASTSpan; - })(); - TypeScript.ASTSpan = ASTSpan; - - TypeScript.astID = 0; - - function structuralEqualsNotIncludingPosition(ast1, ast2) { - return structuralEquals(ast1, ast2, false); - } - TypeScript.structuralEqualsNotIncludingPosition = structuralEqualsNotIncludingPosition; - - function structuralEqualsIncludingPosition(ast1, ast2) { - return structuralEquals(ast1, ast2, true); - } - TypeScript.structuralEqualsIncludingPosition = structuralEqualsIncludingPosition; - - function structuralEquals(ast1, ast2, includingPosition) { - if (ast1 === ast2) { - return true; - } - - return ast1 !== null && ast2 !== null && ast1.nodeType === ast2.nodeType && ast1.structuralEquals(ast2, includingPosition); - } - - function astArrayStructuralEquals(array1, array2, includingPosition) { - return TypeScript.ArrayUtilities.sequenceEquals(array1, array2, includingPosition ? structuralEqualsIncludingPosition : structuralEqualsNotIncludingPosition); - } - - var AST = (function () { - function AST(nodeType) { - this.nodeType = nodeType; - this.minChar = -1; - this.limChar = -1; - this.trailingTriviaWidth = 0; - this._flags = 0 /* None */; - this.typeCheckPhase = -1; - this.astID = TypeScript.astID++; - this.passCreated = TypeScript.CompilerDiagnostics.analysisPass; - this.preComments = null; - this.postComments = null; - this.docComments = null; - } - AST.prototype.shouldEmit = function () { - return true; - }; - - AST.prototype.isExpression = function () { - return false; - }; - AST.prototype.isStatementOrExpression = function () { - return false; - }; - - AST.prototype.getFlags = function () { - return this._flags; - }; - - AST.prototype.setFlags = function (flags) { - this._flags = flags; - }; - - AST.prototype.getLength = function () { - return this.limChar - this.minChar; - }; - - AST.prototype.getID = function () { - return this.astID; - }; - - AST.prototype.isDeclaration = function () { - return false; - }; - - AST.prototype.isStatement = function () { - return false; - }; - - AST.prototype.emit = function (emitter) { - emitter.emitComments(this, true); - emitter.recordSourceMappingStart(this); - this.emitWorker(emitter); - emitter.recordSourceMappingEnd(this); - emitter.emitComments(this, false); - }; - - AST.prototype.emitWorker = function (emitter) { - throw new Error("please implement in derived class"); - }; - - AST.prototype.getDocComments = function () { - if (!this.isDeclaration() || !this.preComments || this.preComments.length === 0) { - return []; - } - - if (!this.docComments) { - var preCommentsLength = this.preComments.length; - var docComments = []; - for (var i = preCommentsLength - 1; i >= 0; i--) { - if (this.preComments[i].isDocComment()) { - var prevDocComment = docComments.length > 0 ? docComments[docComments.length - 1] : null; - if (prevDocComment === null || (this.preComments[i].limLine === prevDocComment.minLine || this.preComments[i].limLine + 1 === prevDocComment.minLine)) { - docComments.push(this.preComments[i]); - continue; - } - } - break; - } - - this.docComments = docComments.reverse(); - } - - return this.docComments; - }; - - AST.prototype.structuralEquals = function (ast, includingPosition) { - if (includingPosition) { - if (this.minChar !== ast.minChar || this.limChar !== ast.limChar) { - return false; - } - } - - return this._flags === ast._flags && astArrayStructuralEquals(this.preComments, ast.preComments, includingPosition) && astArrayStructuralEquals(this.postComments, ast.postComments, includingPosition); - }; - return AST; - })(); - TypeScript.AST = AST; - - var ASTList = (function (_super) { - __extends(ASTList, _super); - function ASTList() { - _super.call(this, 1 /* List */); - this.members = []; - } - ASTList.prototype.append = function (ast) { - this.members[this.members.length] = ast; - return this; - }; - - ASTList.prototype.emit = function (emitter) { - emitter.recordSourceMappingStart(this); - emitter.emitModuleElements(this); - emitter.recordSourceMappingEnd(this); - }; - - ASTList.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && astArrayStructuralEquals(this.members, ast.members, includingPosition); - }; - return ASTList; - })(AST); - TypeScript.ASTList = ASTList; - - var Expression = (function (_super) { - __extends(Expression, _super); - function Expression(nodeType) { - _super.call(this, nodeType); - } - return Expression; - })(AST); - TypeScript.Expression = Expression; - - var Identifier = (function (_super) { - __extends(Identifier, _super); - function Identifier(actualText) { - _super.call(this, 20 /* Name */); - this.actualText = actualText; - this.setText(actualText); - } - Identifier.prototype.setText = function (actualText) { - this.actualText = actualText; - this.text = actualText; - }; - - Identifier.prototype.isMissing = function () { - return false; - }; - - Identifier.prototype.emit = function (emitter) { - emitter.emitName(this, true); - }; - - Identifier.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && this.text === ast.text && this.actualText === ast.actualText && this.isMissing() === ast.isMissing(); - }; - return Identifier; - })(Expression); - TypeScript.Identifier = Identifier; - - var MissingIdentifier = (function (_super) { - __extends(MissingIdentifier, _super); - function MissingIdentifier() { - _super.call(this, "__missing"); - } - MissingIdentifier.prototype.isMissing = function () { - return true; - }; - - MissingIdentifier.prototype.emit = function (emitter) { - }; - return MissingIdentifier; - })(Identifier); - TypeScript.MissingIdentifier = MissingIdentifier; - - var LiteralExpression = (function (_super) { - __extends(LiteralExpression, _super); - function LiteralExpression(nodeType) { - _super.call(this, nodeType); - } - LiteralExpression.prototype.emitWorker = function (emitter) { - switch (this.nodeType) { - case 8 /* NullLiteral */: - emitter.writeToOutput("null"); - break; - case 4 /* FalseLiteral */: - emitter.writeToOutput("false"); - break; - case 3 /* TrueLiteral */: - emitter.writeToOutput("true"); - break; - default: - throw new Error("please implement in derived class"); - } - }; - - LiteralExpression.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition); - }; - return LiteralExpression; - })(Expression); - TypeScript.LiteralExpression = LiteralExpression; - - var ThisExpression = (function (_super) { - __extends(ThisExpression, _super); - function ThisExpression() { - _super.call(this, 29 /* ThisExpression */); - } - ThisExpression.prototype.emitWorker = function (emitter) { - if (emitter.thisFunctionDeclaration && (TypeScript.hasFlag(emitter.thisFunctionDeclaration.getFunctionFlags(), 2048 /* IsFatArrowFunction */))) { - emitter.writeToOutput("_this"); - } else { - emitter.writeToOutput("this"); - } - }; - - ThisExpression.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition); - }; - return ThisExpression; - })(Expression); - TypeScript.ThisExpression = ThisExpression; - - var SuperExpression = (function (_super) { - __extends(SuperExpression, _super); - function SuperExpression() { - _super.call(this, 30 /* SuperExpression */); - } - SuperExpression.prototype.emitWorker = function (emitter) { - emitter.emitSuperReference(); - }; - - SuperExpression.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition); - }; - return SuperExpression; - })(Expression); - TypeScript.SuperExpression = SuperExpression; - - var ParenthesizedExpression = (function (_super) { - __extends(ParenthesizedExpression, _super); - function ParenthesizedExpression(expression) { - _super.call(this, 79 /* ParenthesizedExpression */); - this.expression = expression; - } - ParenthesizedExpression.prototype.emitWorker = function (emitter) { - emitter.writeToOutput("("); - this.expression.emit(emitter); - emitter.writeToOutput(")"); - }; - - ParenthesizedExpression.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.expression, ast.expression, includingPosition); - }; - return ParenthesizedExpression; - })(Expression); - TypeScript.ParenthesizedExpression = ParenthesizedExpression; - - var UnaryExpression = (function (_super) { - __extends(UnaryExpression, _super); - function UnaryExpression(nodeType, operand) { - _super.call(this, nodeType); - this.operand = operand; - this.castTerm = null; - } - UnaryExpression.prototype.emitWorker = function (emitter) { - switch (this.nodeType) { - case 76 /* PostIncrementExpression */: - this.operand.emit(emitter); - emitter.writeToOutput("++"); - break; - case 73 /* LogicalNotExpression */: - emitter.writeToOutput("!"); - this.operand.emit(emitter); - break; - case 77 /* PostDecrementExpression */: - this.operand.emit(emitter); - emitter.writeToOutput("--"); - break; - case 22 /* ObjectLiteralExpression */: - emitter.emitObjectLiteral(this); - break; - case 21 /* ArrayLiteralExpression */: - emitter.emitArrayLiteral(this); - break; - case 72 /* BitwiseNotExpression */: - emitter.writeToOutput("~"); - this.operand.emit(emitter); - break; - case 27 /* NegateExpression */: - emitter.writeToOutput("-"); - if (this.operand.nodeType === 27 /* NegateExpression */ || this.operand.nodeType === 75 /* PreDecrementExpression */) { - emitter.writeToOutput(" "); - } - this.operand.emit(emitter); - break; - case 26 /* PlusExpression */: - emitter.writeToOutput("+"); - if (this.operand.nodeType === 26 /* PlusExpression */ || this.operand.nodeType === 74 /* PreIncrementExpression */) { - emitter.writeToOutput(" "); - } - this.operand.emit(emitter); - break; - case 74 /* PreIncrementExpression */: - emitter.writeToOutput("++"); - this.operand.emit(emitter); - break; - case 75 /* PreDecrementExpression */: - emitter.writeToOutput("--"); - this.operand.emit(emitter); - break; - case 34 /* TypeOfExpression */: - emitter.writeToOutput("typeof "); - this.operand.emit(emitter); - break; - case 28 /* DeleteExpression */: - emitter.writeToOutput("delete "); - this.operand.emit(emitter); - break; - case 24 /* VoidExpression */: - emitter.writeToOutput("void "); - this.operand.emit(emitter); - break; - case 78 /* CastExpression */: - this.operand.emit(emitter); - break; - default: - throw new Error("please implement in derived class"); - } - }; - - UnaryExpression.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.castTerm, ast.castTerm, includingPosition) && structuralEquals(this.operand, ast.operand, includingPosition); - }; - return UnaryExpression; - })(Expression); - TypeScript.UnaryExpression = UnaryExpression; - - var CallExpression = (function (_super) { - __extends(CallExpression, _super); - function CallExpression(nodeType, target, typeArguments, arguments) { - _super.call(this, nodeType); - this.target = target; - this.typeArguments = typeArguments; - this.arguments = arguments; - } - CallExpression.prototype.emitWorker = function (emitter) { - if (this.nodeType === 37 /* ObjectCreationExpression */) { - emitter.emitNew(this.target, this.arguments); - } else { - emitter.emitCall(this, this.target, this.arguments); - } - }; - - CallExpression.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.target, ast.target, includingPosition) && structuralEquals(this.typeArguments, ast.typeArguments, includingPosition) && structuralEquals(this.arguments, ast.arguments, includingPosition); - }; - return CallExpression; - })(Expression); - TypeScript.CallExpression = CallExpression; - - var BinaryExpression = (function (_super) { - __extends(BinaryExpression, _super); - function BinaryExpression(nodeType, operand1, operand2) { - _super.call(this, nodeType); - this.operand1 = operand1; - this.operand2 = operand2; - } - BinaryExpression.getTextForBinaryToken = function (nodeType) { - switch (nodeType) { - case 25 /* CommaExpression */: - return ","; - case 38 /* AssignmentExpression */: - return "="; - case 39 /* AddAssignmentExpression */: - return "+="; - case 40 /* SubtractAssignmentExpression */: - return "-="; - case 42 /* MultiplyAssignmentExpression */: - return "*="; - case 41 /* DivideAssignmentExpression */: - return "/="; - case 43 /* ModuloAssignmentExpression */: - return "%="; - case 44 /* AndAssignmentExpression */: - return "&="; - case 45 /* ExclusiveOrAssignmentExpression */: - return "^="; - case 46 /* OrAssignmentExpression */: - return "|="; - case 47 /* LeftShiftAssignmentExpression */: - return "<<="; - case 48 /* SignedRightShiftAssignmentExpression */: - return ">>="; - case 49 /* UnsignedRightShiftAssignmentExpression */: - return ">>>="; - case 51 /* LogicalOrExpression */: - return "||"; - case 52 /* LogicalAndExpression */: - return "&&"; - case 53 /* BitwiseOrExpression */: - return "|"; - case 54 /* BitwiseExclusiveOrExpression */: - return "^"; - case 55 /* BitwiseAndExpression */: - return "&"; - case 56 /* EqualsWithTypeConversionExpression */: - return "=="; - case 57 /* NotEqualsWithTypeConversionExpression */: - return "!="; - case 58 /* EqualsExpression */: - return "==="; - case 59 /* NotEqualsExpression */: - return "!=="; - case 60 /* LessThanExpression */: - return "<"; - case 62 /* GreaterThanExpression */: - return ">"; - case 61 /* LessThanOrEqualExpression */: - return "<="; - case 63 /* GreaterThanOrEqualExpression */: - return ">="; - case 33 /* InstanceOfExpression */: - return "instanceof"; - case 31 /* InExpression */: - return "in"; - case 69 /* LeftShiftExpression */: - return "<<"; - case 70 /* SignedRightShiftExpression */: - return ">>"; - case 71 /* UnsignedRightShiftExpression */: - return ">>>"; - case 66 /* MultiplyExpression */: - return "*"; - case 67 /* DivideExpression */: - return "/"; - case 68 /* ModuloExpression */: - return "%"; - case 64 /* AddExpression */: - return "+"; - case 65 /* SubtractExpression */: - return "-"; - } - - throw TypeScript.Errors.invalidOperation(); - }; - - BinaryExpression.prototype.emitWorker = function (emitter) { - switch (this.nodeType) { - case 32 /* MemberAccessExpression */: - if (!emitter.tryEmitConstant(this)) { - this.operand1.emit(emitter); - emitter.writeToOutput("."); - emitter.emitName(this.operand2, false); - } - break; - case 35 /* ElementAccessExpression */: - emitter.emitIndex(this.operand1, this.operand2); - break; - - case 80 /* Member */: - if (this.operand2.nodeType === 12 /* FunctionDeclaration */ && (this.operand2).isAccessor()) { - var funcDecl = this.operand2; - if (TypeScript.hasFlag(funcDecl.getFunctionFlags(), 32 /* GetAccessor */)) { - emitter.writeToOutput("get "); - } else { - emitter.writeToOutput("set "); - } - this.operand1.emit(emitter); - } else { - this.operand1.emit(emitter); - emitter.writeToOutputTrimmable(": "); - } - this.operand2.emit(emitter); - break; - case 25 /* CommaExpression */: - this.operand1.emit(emitter); - emitter.writeToOutput(", "); - this.operand2.emit(emitter); - break; - default: { - this.operand1.emit(emitter); - var binOp = BinaryExpression.getTextForBinaryToken(this.nodeType); - if (binOp === "instanceof") { - emitter.writeToOutput(" instanceof "); - } else if (binOp === "in") { - emitter.writeToOutput(" in "); - } else { - emitter.writeToOutputTrimmable(" " + binOp + " "); - } - this.operand2.emit(emitter); - } - } - }; - - BinaryExpression.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.operand1, ast.operand1, includingPosition) && structuralEquals(this.operand2, ast.operand2, includingPosition); - }; - return BinaryExpression; - })(Expression); - TypeScript.BinaryExpression = BinaryExpression; - - var ConditionalExpression = (function (_super) { - __extends(ConditionalExpression, _super); - function ConditionalExpression(operand1, operand2, operand3) { - _super.call(this, 50 /* ConditionalExpression */); - this.operand1 = operand1; - this.operand2 = operand2; - this.operand3 = operand3; - } - ConditionalExpression.prototype.emitWorker = function (emitter) { - this.operand1.emit(emitter); - emitter.writeToOutput(" ? "); - this.operand2.emit(emitter); - emitter.writeToOutput(" : "); - this.operand3.emit(emitter); - }; - - ConditionalExpression.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.operand1, ast.operand1, includingPosition) && structuralEquals(this.operand2, ast.operand2, includingPosition) && structuralEquals(this.operand3, ast.operand3, includingPosition); - }; - return ConditionalExpression; - })(Expression); - TypeScript.ConditionalExpression = ConditionalExpression; - - var NumberLiteral = (function (_super) { - __extends(NumberLiteral, _super); - function NumberLiteral(value, text) { - _super.call(this, 7 /* NumericLiteral */); - this.value = value; - this.text = text; - } - NumberLiteral.prototype.emitWorker = function (emitter) { - emitter.writeToOutput(this.text); - }; - - NumberLiteral.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && this.value === ast.value && this.text === ast.text; - }; - return NumberLiteral; - })(Expression); - TypeScript.NumberLiteral = NumberLiteral; - - var RegexLiteral = (function (_super) { - __extends(RegexLiteral, _super); - function RegexLiteral(text) { - _super.call(this, 6 /* RegularExpressionLiteral */); - this.text = text; - } - RegexLiteral.prototype.emitWorker = function (emitter) { - emitter.writeToOutput(this.text); - }; - - RegexLiteral.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && this.text === ast.text; - }; - return RegexLiteral; - })(Expression); - TypeScript.RegexLiteral = RegexLiteral; - - var StringLiteral = (function (_super) { - __extends(StringLiteral, _super); - function StringLiteral(actualText, text) { - _super.call(this, 5 /* StringLiteral */); - this.actualText = actualText; - this.text = text; - } - StringLiteral.prototype.emitWorker = function (emitter) { - emitter.writeToOutput(this.actualText); - }; - - StringLiteral.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && this.actualText === ast.actualText; - }; - return StringLiteral; - })(Expression); - TypeScript.StringLiteral = StringLiteral; - - var ImportDeclaration = (function (_super) { - __extends(ImportDeclaration, _super); - function ImportDeclaration(id, alias) { - _super.call(this, 16 /* ImportDeclaration */); - this.id = id; - this.alias = alias; - this.isDynamicImport = false; - } - ImportDeclaration.prototype.isStatementOrExpression = function () { - return true; - }; - - ImportDeclaration.prototype.isDeclaration = function () { - return true; - }; - - ImportDeclaration.prototype.emit = function (emitter) { - if (emitter.importStatementShouldBeEmitted(this)) { - var prevModAliasId = emitter.modAliasId; - var prevFirstModAlias = emitter.firstModAlias; - - emitter.recordSourceMappingStart(this); - emitter.emitComments(this, true); - emitter.writeToOutput("var " + this.id.actualText + " = "); - emitter.modAliasId = this.id.actualText; - emitter.firstModAlias = this.firstAliasedModToString(); - var aliasAST = this.alias.nodeType === 11 /* TypeRef */ ? (this.alias).term : this.alias; - - emitter.emitJavascript(aliasAST, false); - emitter.writeToOutput(";"); - - emitter.emitComments(this, false); - emitter.recordSourceMappingEnd(this); - - emitter.modAliasId = prevModAliasId; - emitter.firstModAlias = prevFirstModAlias; - } - }; - - ImportDeclaration.prototype.getAliasName = function (aliasAST) { - if (typeof aliasAST === "undefined") { aliasAST = this.alias; } - if (aliasAST.nodeType === 20 /* Name */) { - return (aliasAST).actualText; - } else { - var dotExpr = aliasAST; - return this.getAliasName(dotExpr.operand1) + "." + this.getAliasName(dotExpr.operand2); - } - }; - - ImportDeclaration.prototype.firstAliasedModToString = function () { - if (this.alias.nodeType === 20 /* Name */) { - return (this.alias).actualText; - } else { - var dotExpr = this.alias; - var firstMod = (dotExpr.term).operand1; - return firstMod.actualText; - } - }; - - ImportDeclaration.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.id, ast.id, includingPosition) && structuralEquals(this.alias, ast.alias, includingPosition); - }; - return ImportDeclaration; - })(AST); - TypeScript.ImportDeclaration = ImportDeclaration; - - var ExportAssignment = (function (_super) { - __extends(ExportAssignment, _super); - function ExportAssignment(id) { - _super.call(this, 87 /* ExportAssignment */); - this.id = id; - } - ExportAssignment.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.id, ast.id, includingPosition); - }; - - ExportAssignment.prototype.emit = function (emitter) { - emitter.setExportAssignmentIdentifier(this.id.actualText); - }; - return ExportAssignment; - })(AST); - TypeScript.ExportAssignment = ExportAssignment; - - var BoundDecl = (function (_super) { - __extends(BoundDecl, _super); - function BoundDecl(id, nodeType) { - _super.call(this, nodeType); - this.id = id; - this.init = null; - this.isImplicitlyInitialized = false; - this.typeExpr = null; - this._varFlags = 0 /* None */; - } - BoundDecl.prototype.isDeclaration = function () { - return true; - }; - BoundDecl.prototype.isStatementOrExpression = function () { - return true; - }; - - BoundDecl.prototype.getVarFlags = function () { - return this._varFlags; - }; - - BoundDecl.prototype.setVarFlags = function (flags) { - this._varFlags = flags; - }; - - BoundDecl.prototype.isProperty = function () { - return TypeScript.hasFlag(this.getVarFlags(), 256 /* Property */); - }; - - BoundDecl.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && this._varFlags === ast._varFlags && structuralEquals(this.init, ast.init, includingPosition) && structuralEquals(this.typeExpr, ast.typeExpr, includingPosition) && structuralEquals(this.id, ast.id, includingPosition); - }; - return BoundDecl; - })(AST); - TypeScript.BoundDecl = BoundDecl; - - var VariableDeclarator = (function (_super) { - __extends(VariableDeclarator, _super); - function VariableDeclarator(id) { - _super.call(this, id, 17 /* VariableDeclarator */); - } - VariableDeclarator.prototype.isExported = function () { - return TypeScript.hasFlag(this.getVarFlags(), 1 /* Exported */); - }; - - VariableDeclarator.prototype.isStatic = function () { - return TypeScript.hasFlag(this.getVarFlags(), 16 /* Static */); - }; - - VariableDeclarator.prototype.emit = function (emitter) { - emitter.emitVariableDeclarator(this); - }; - return VariableDeclarator; - })(BoundDecl); - TypeScript.VariableDeclarator = VariableDeclarator; - - var Parameter = (function (_super) { - __extends(Parameter, _super); - function Parameter(id) { - _super.call(this, id, 19 /* Parameter */); - this.isOptional = false; - } - Parameter.prototype.isOptionalArg = function () { - return this.isOptional || this.init; - }; - - Parameter.prototype.emitWorker = function (emitter) { - emitter.writeToOutput(this.id.actualText); - }; - - Parameter.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && this.isOptional === ast.isOptional; - }; - return Parameter; - })(BoundDecl); - TypeScript.Parameter = Parameter; - - var FunctionDeclaration = (function (_super) { - __extends(FunctionDeclaration, _super); - function FunctionDeclaration(name, block, isConstructor, typeArguments, arguments, nodeType) { - _super.call(this, nodeType); - this.name = name; - this.block = block; - this.isConstructor = isConstructor; - this.typeArguments = typeArguments; - this.arguments = arguments; - this.hint = null; - this._functionFlags = 0 /* None */; - this.returnTypeAnnotation = null; - this.variableArgList = false; - this.classDecl = null; - } - FunctionDeclaration.prototype.isDeclaration = function () { - return true; - }; - - FunctionDeclaration.prototype.getFunctionFlags = function () { - return this._functionFlags; - }; - - FunctionDeclaration.prototype.setFunctionFlags = function (flags) { - this._functionFlags = flags; - }; - - FunctionDeclaration.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && this._functionFlags === ast._functionFlags && this.hint === ast.hint && this.variableArgList === ast.variableArgList && structuralEquals(this.name, ast.name, includingPosition) && structuralEquals(this.block, ast.block, includingPosition) && this.isConstructor === ast.isConstructor && structuralEquals(this.typeArguments, ast.typeArguments, includingPosition) && structuralEquals(this.arguments, ast.arguments, includingPosition); - }; - - FunctionDeclaration.prototype.shouldEmit = function () { - return !TypeScript.hasFlag(this.getFunctionFlags(), 128 /* Signature */) && !TypeScript.hasFlag(this.getFunctionFlags(), 8 /* Ambient */); - }; - - FunctionDeclaration.prototype.emit = function (emitter) { - emitter.emitFunction(this); - }; - - FunctionDeclaration.prototype.getNameText = function () { - if (this.name) { - return this.name.actualText; - } else { - return this.hint; - } - }; - - FunctionDeclaration.prototype.isMethod = function () { - return (this.getFunctionFlags() & 256 /* Method */) !== 0 /* None */; - }; - - FunctionDeclaration.prototype.isCallMember = function () { - return TypeScript.hasFlag(this.getFunctionFlags(), 512 /* CallMember */); - }; - FunctionDeclaration.prototype.isConstructMember = function () { - return TypeScript.hasFlag(this.getFunctionFlags(), 1024 /* ConstructMember */); - }; - FunctionDeclaration.prototype.isIndexerMember = function () { - return TypeScript.hasFlag(this.getFunctionFlags(), 4096 /* IndexerMember */); - }; - FunctionDeclaration.prototype.isSpecialFn = function () { - return this.isCallMember() || this.isIndexerMember() || this.isConstructMember(); - }; - FunctionDeclaration.prototype.isAccessor = function () { - return TypeScript.hasFlag(this.getFunctionFlags(), 32 /* GetAccessor */) || TypeScript.hasFlag(this.getFunctionFlags(), 64 /* SetAccessor */); - }; - FunctionDeclaration.prototype.isGetAccessor = function () { - return TypeScript.hasFlag(this.getFunctionFlags(), 32 /* GetAccessor */); - }; - FunctionDeclaration.prototype.isSetAccessor = function () { - return TypeScript.hasFlag(this.getFunctionFlags(), 64 /* SetAccessor */); - }; - FunctionDeclaration.prototype.isStatic = function () { - return TypeScript.hasFlag(this.getFunctionFlags(), 16 /* Static */); - }; - - FunctionDeclaration.prototype.isSignature = function () { - return (this.getFunctionFlags() & 128 /* Signature */) !== 0 /* None */; - }; - return FunctionDeclaration; - })(AST); - TypeScript.FunctionDeclaration = FunctionDeclaration; - - var Script = (function (_super) { - __extends(Script, _super); - function Script() { - _super.call(this, 2 /* Script */); - this.moduleElements = null; - this.referencedFiles = []; - this.requiresExtendsBlock = false; - this.isDeclareFile = false; - this.topLevelMod = null; - this.containsUnicodeChar = false; - this.containsUnicodeCharInComment = false; - } - Script.prototype.emit = function (emitter) { - if (!this.isDeclareFile) { - emitter.emitScriptElements(this, this.requiresExtendsBlock); - } - }; - - Script.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.moduleElements, ast.moduleElements, includingPosition); - }; - return Script; - })(AST); - TypeScript.Script = Script; - - var NamedDeclaration = (function (_super) { - __extends(NamedDeclaration, _super); - function NamedDeclaration(nodeType, name, members) { - _super.call(this, nodeType); - this.name = name; - this.members = members; - } - NamedDeclaration.prototype.isDeclaration = function () { - return true; - }; - - NamedDeclaration.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.name, ast.name, includingPosition) && structuralEquals(this.members, ast.members, includingPosition); - }; - return NamedDeclaration; - })(AST); - TypeScript.NamedDeclaration = NamedDeclaration; - - var ModuleDeclaration = (function (_super) { - __extends(ModuleDeclaration, _super); - function ModuleDeclaration(name, members, endingToken) { - _super.call(this, 15 /* ModuleDeclaration */, name, members); - this.endingToken = endingToken; - this._moduleFlags = 0 /* None */; - this.amdDependencies = []; - this.containsUnicodeChar = false; - this.containsUnicodeCharInComment = false; - - this.prettyName = this.name.actualText; - } - ModuleDeclaration.prototype.getModuleFlags = function () { - return this._moduleFlags; - }; - - ModuleDeclaration.prototype.setModuleFlags = function (flags) { - this._moduleFlags = flags; - }; - - ModuleDeclaration.prototype.structuralEquals = function (ast, includePosition) { - if (_super.prototype.structuralEquals.call(this, ast, includePosition)) { - return this._moduleFlags === ast._moduleFlags; - } - - return false; - }; - - ModuleDeclaration.prototype.isEnum = function () { - return TypeScript.hasFlag(this.getModuleFlags(), 128 /* IsEnum */); - }; - ModuleDeclaration.prototype.isWholeFile = function () { - return TypeScript.hasFlag(this.getModuleFlags(), 256 /* IsWholeFile */); - }; - - ModuleDeclaration.prototype.shouldEmit = function () { - if (TypeScript.hasFlag(this.getModuleFlags(), 8 /* Ambient */)) { - return false; - } - - if (TypeScript.hasFlag(this.getModuleFlags(), 128 /* IsEnum */)) { - return true; - } - - for (var i = 0, n = this.members.members.length; i < n; i++) { - var member = this.members.members[i]; - - if (member.nodeType === 15 /* ModuleDeclaration */) { - if ((member).shouldEmit()) { - return true; - } - } else if (member.nodeType !== 14 /* InterfaceDeclaration */) { - return true; - } - } - - return false; - }; - - ModuleDeclaration.prototype.emit = function (emitter) { - if (this.shouldEmit()) { - emitter.emitComments(this, true); - emitter.emitModule(this); - emitter.emitComments(this, false); - } - }; - return ModuleDeclaration; - })(NamedDeclaration); - TypeScript.ModuleDeclaration = ModuleDeclaration; - - var TypeDeclaration = (function (_super) { - __extends(TypeDeclaration, _super); - function TypeDeclaration(nodeType, name, typeParameters, extendsList, implementsList, members) { - _super.call(this, nodeType, name, members); - this.typeParameters = typeParameters; - this.extendsList = extendsList; - this.implementsList = implementsList; - this._varFlags = 0 /* None */; - } - TypeDeclaration.prototype.getVarFlags = function () { - return this._varFlags; - }; - - TypeDeclaration.prototype.setVarFlags = function (flags) { - this._varFlags = flags; - }; - - TypeDeclaration.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && this._varFlags === ast._varFlags && structuralEquals(this.typeParameters, ast.typeParameters, includingPosition) && structuralEquals(this.extendsList, ast.extendsList, includingPosition) && structuralEquals(this.implementsList, ast.implementsList, includingPosition); - }; - return TypeDeclaration; - })(NamedDeclaration); - TypeScript.TypeDeclaration = TypeDeclaration; - - var ClassDeclaration = (function (_super) { - __extends(ClassDeclaration, _super); - function ClassDeclaration(name, typeParameters, members, extendsList, implementsList) { - _super.call(this, 13 /* ClassDeclaration */, name, typeParameters, extendsList, implementsList, members); - this.constructorDecl = null; - this.endingToken = null; - } - ClassDeclaration.prototype.shouldEmit = function () { - return !TypeScript.hasFlag(this.getVarFlags(), 8 /* Ambient */); - }; - - ClassDeclaration.prototype.emit = function (emitter) { - emitter.emitClass(this); - }; - return ClassDeclaration; - })(TypeDeclaration); - TypeScript.ClassDeclaration = ClassDeclaration; - - var InterfaceDeclaration = (function (_super) { - __extends(InterfaceDeclaration, _super); - function InterfaceDeclaration(name, typeParameters, members, extendsList, implementsList) { - _super.call(this, 14 /* InterfaceDeclaration */, name, typeParameters, extendsList, implementsList, members); - } - InterfaceDeclaration.prototype.shouldEmit = function () { - return false; - }; - return InterfaceDeclaration; - })(TypeDeclaration); - TypeScript.InterfaceDeclaration = InterfaceDeclaration; - - var Statement = (function (_super) { - __extends(Statement, _super); - function Statement(nodeType) { - _super.call(this, nodeType); - } - Statement.prototype.isStatement = function () { - return true; - }; - - Statement.prototype.isStatementOrExpression = function () { - return true; - }; - return Statement; - })(AST); - TypeScript.Statement = Statement; - - var ThrowStatement = (function (_super) { - __extends(ThrowStatement, _super); - function ThrowStatement(expression) { - _super.call(this, 95 /* ThrowStatement */); - this.expression = expression; - } - ThrowStatement.prototype.emitWorker = function (emitter) { - emitter.writeToOutput("throw "); - this.expression.emit(emitter); - emitter.writeToOutput(";"); - }; - - ThrowStatement.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.expression, ast.expression, includingPosition); - }; - return ThrowStatement; - })(Statement); - TypeScript.ThrowStatement = ThrowStatement; - - var ExpressionStatement = (function (_super) { - __extends(ExpressionStatement, _super); - function ExpressionStatement(expression) { - _super.call(this, 88 /* ExpressionStatement */); - this.expression = expression; - } - ExpressionStatement.prototype.emitWorker = function (emitter) { - this.expression.emit(emitter); - emitter.writeToOutput(";"); - }; - - ExpressionStatement.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.expression, ast.expression, includingPosition); - }; - return ExpressionStatement; - })(Statement); - TypeScript.ExpressionStatement = ExpressionStatement; - - var LabeledStatement = (function (_super) { - __extends(LabeledStatement, _super); - function LabeledStatement(identifier, statement) { - _super.call(this, 92 /* LabeledStatement */); - this.identifier = identifier; - this.statement = statement; - } - LabeledStatement.prototype.emitWorker = function (emitter) { - emitter.recordSourceMappingStart(this.identifier); - emitter.writeToOutput(this.identifier.actualText); - emitter.recordSourceMappingEnd(this.identifier); - emitter.writeLineToOutput(":"); - emitter.emitJavascript(this.statement, true); - }; - - LabeledStatement.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.identifier, ast.identifier, includingPosition) && structuralEquals(this.statement, ast.statement, includingPosition); - }; - return LabeledStatement; - })(Statement); - TypeScript.LabeledStatement = LabeledStatement; - - var VariableDeclaration = (function (_super) { - __extends(VariableDeclaration, _super); - function VariableDeclaration(declarators) { - _super.call(this, 18 /* VariableDeclaration */); - this.declarators = declarators; - } - VariableDeclaration.prototype.emit = function (emitter) { - emitter.emitVariableDeclaration(this); - }; - - VariableDeclaration.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.declarators, ast.declarators, includingPosition); - }; - return VariableDeclaration; - })(AST); - TypeScript.VariableDeclaration = VariableDeclaration; - - var VariableStatement = (function (_super) { - __extends(VariableStatement, _super); - function VariableStatement(declaration) { - _super.call(this, 97 /* VariableStatement */); - this.declaration = declaration; - } - VariableStatement.prototype.shouldEmit = function () { - if (TypeScript.hasFlag(this.getFlags(), 32 /* EnumMapElement */)) { - return false; - } - - var varDecl = this.declaration.declarators.members[0]; - return !TypeScript.hasFlag(varDecl.getVarFlags(), 8 /* Ambient */) || varDecl.init !== null; - }; - - VariableStatement.prototype.emitWorker = function (emitter) { - if (TypeScript.hasFlag(this.getFlags(), 16 /* EnumElement */)) { - emitter.emitEnumElement(this.declaration.declarators.members[0]); - } else { - this.declaration.emit(emitter); - emitter.writeToOutput(";"); - } - }; - - VariableStatement.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.declaration, ast.declaration, includingPosition); - }; - return VariableStatement; - })(Statement); - TypeScript.VariableStatement = VariableStatement; - - var Block = (function (_super) { - __extends(Block, _super); - function Block(statements) { - _super.call(this, 81 /* Block */); - this.statements = statements; - this.closeBraceSpan = null; - } - Block.prototype.emitWorker = function (emitter) { - emitter.writeLineToOutput(" {"); - emitter.indenter.increaseIndent(); - if (this.statements) { - emitter.emitModuleElements(this.statements); - } - emitter.indenter.decreaseIndent(); - emitter.emitIndent(); - emitter.writeToOutput("}"); - }; - - Block.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.statements, ast.statements, includingPosition); - }; - return Block; - })(Statement); - TypeScript.Block = Block; - - var Jump = (function (_super) { - __extends(Jump, _super); - function Jump(nodeType) { - _super.call(this, nodeType); - this.target = null; - this.resolvedTarget = null; - } - Jump.prototype.hasExplicitTarget = function () { - return (this.target); - }; - - Jump.prototype.emitWorker = function (emitter) { - if (this.nodeType === 82 /* BreakStatement */) { - emitter.writeToOutput("break"); - } else { - emitter.writeToOutput("continue"); - } - if (this.hasExplicitTarget()) { - emitter.writeToOutput(" " + this.target); - } - emitter.writeToOutput(";"); - }; - - Jump.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && this.target === ast.target; - }; - return Jump; - })(Statement); - TypeScript.Jump = Jump; - - var WhileStatement = (function (_super) { - __extends(WhileStatement, _super); - function WhileStatement(cond, body) { - _super.call(this, 98 /* WhileStatement */); - this.cond = cond; - this.body = body; - } - WhileStatement.prototype.emitWorker = function (emitter) { - emitter.writeToOutput("while ("); - this.cond.emit(emitter); - emitter.writeToOutput(")"); - emitter.emitBlockOrStatement(this.body); - }; - - WhileStatement.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.cond, ast.cond, includingPosition) && structuralEquals(this.body, ast.body, includingPosition); - }; - return WhileStatement; - })(Statement); - TypeScript.WhileStatement = WhileStatement; - - var DoStatement = (function (_super) { - __extends(DoStatement, _super); - function DoStatement(body, cond) { - _super.call(this, 85 /* DoStatement */); - this.body = body; - this.cond = cond; - this.whileSpan = null; - } - DoStatement.prototype.emitWorker = function (emitter) { - emitter.writeToOutput("do"); - emitter.emitBlockOrStatement(this.body); - emitter.recordSourceMappingStart(this.whileSpan); - emitter.writeToOutput(" while"); - emitter.recordSourceMappingEnd(this.whileSpan); - emitter.writeToOutput('('); - this.cond.emit(emitter); - emitter.writeToOutput(")"); - emitter.writeToOutput(";"); - }; - - DoStatement.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.body, ast.body, includingPosition) && structuralEquals(this.cond, ast.cond, includingPosition); - }; - return DoStatement; - })(Statement); - TypeScript.DoStatement = DoStatement; - - var IfStatement = (function (_super) { - __extends(IfStatement, _super); - function IfStatement(cond, thenBod, elseBod) { - _super.call(this, 91 /* IfStatement */); - this.cond = cond; - this.thenBod = thenBod; - this.elseBod = elseBod; - this.statement = new ASTSpan(); - } - IfStatement.prototype.emitWorker = function (emitter) { - emitter.recordSourceMappingStart(this.statement); - emitter.writeToOutput("if ("); - this.cond.emit(emitter); - emitter.writeToOutput(")"); - emitter.recordSourceMappingEnd(this.statement); - - emitter.emitBlockOrStatement(this.thenBod); - - if (this.elseBod) { - if (this.elseBod.nodeType === 91 /* IfStatement */) { - emitter.writeToOutput(" else "); - this.elseBod.emit(emitter); - } else { - emitter.writeToOutput(" else"); - emitter.emitBlockOrStatement(this.elseBod); - } - } - }; - - IfStatement.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.cond, ast.cond, includingPosition) && structuralEquals(this.thenBod, ast.thenBod, includingPosition) && structuralEquals(this.elseBod, ast.elseBod, includingPosition); - }; - return IfStatement; - })(Statement); - TypeScript.IfStatement = IfStatement; - - var ReturnStatement = (function (_super) { - __extends(ReturnStatement, _super); - function ReturnStatement(returnExpression) { - _super.call(this, 93 /* ReturnStatement */); - this.returnExpression = returnExpression; - } - ReturnStatement.prototype.emitWorker = function (emitter) { - if (this.returnExpression) { - emitter.writeToOutput("return "); - this.returnExpression.emit(emitter); - emitter.writeToOutput(";"); - } else { - emitter.writeToOutput("return;"); - } - }; - - ReturnStatement.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.returnExpression, ast.returnExpression, includingPosition); - }; - return ReturnStatement; - })(Statement); - TypeScript.ReturnStatement = ReturnStatement; - - var ForInStatement = (function (_super) { - __extends(ForInStatement, _super); - function ForInStatement(lval, obj, body) { - _super.call(this, 89 /* ForInStatement */); - this.lval = lval; - this.obj = obj; - this.body = body; - this.statement = new ASTSpan(); - } - ForInStatement.prototype.emitWorker = function (emitter) { - emitter.recordSourceMappingStart(this.statement); - emitter.writeToOutput("for ("); - this.lval.emit(emitter); - emitter.writeToOutput(" in "); - this.obj.emit(emitter); - emitter.writeToOutput(")"); - emitter.recordSourceMappingEnd(this.statement); - emitter.emitBlockOrStatement(this.body); - }; - - ForInStatement.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.lval, ast.lval, includingPosition) && structuralEquals(this.obj, ast.obj, includingPosition) && structuralEquals(this.body, ast.body, includingPosition); - }; - return ForInStatement; - })(Statement); - TypeScript.ForInStatement = ForInStatement; - - var ForStatement = (function (_super) { - __extends(ForStatement, _super); - function ForStatement(init, cond, incr, body) { - _super.call(this, 90 /* ForStatement */); - this.init = init; - this.cond = cond; - this.incr = incr; - this.body = body; - } - ForStatement.prototype.emitWorker = function (emitter) { - emitter.writeToOutput("for ("); - if (this.init) { - if (this.init.nodeType !== 1 /* List */) { - this.init.emit(emitter); - } else { - emitter.setInVarBlock((this.init).members.length); - emitter.emitCommaSeparatedList(this.init); - } - } - - emitter.writeToOutput("; "); - emitter.emitJavascript(this.cond, false); - emitter.writeToOutput("; "); - emitter.emitJavascript(this.incr, false); - emitter.writeToOutput(")"); - emitter.emitBlockOrStatement(this.body); - }; - - ForStatement.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.init, ast.init, includingPosition) && structuralEquals(this.cond, ast.cond, includingPosition) && structuralEquals(this.incr, ast.incr, includingPosition) && structuralEquals(this.body, ast.body, includingPosition); - }; - return ForStatement; - })(Statement); - TypeScript.ForStatement = ForStatement; - - var WithStatement = (function (_super) { - __extends(WithStatement, _super); - function WithStatement(expr, body) { - _super.call(this, 99 /* WithStatement */); - this.expr = expr; - this.body = body; - } - WithStatement.prototype.emitWorker = function (emitter) { - emitter.writeToOutput("with ("); - if (this.expr) { - this.expr.emit(emitter); - } - - emitter.writeToOutput(")"); - emitter.emitBlockOrStatement(this.body); - }; - - WithStatement.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.expr, ast.expr, includingPosition) && structuralEquals(this.body, ast.body, includingPosition); - }; - return WithStatement; - })(Statement); - TypeScript.WithStatement = WithStatement; - - var SwitchStatement = (function (_super) { - __extends(SwitchStatement, _super); - function SwitchStatement(val) { - _super.call(this, 94 /* SwitchStatement */); - this.val = val; - this.defaultCase = null; - this.statement = new ASTSpan(); - } - SwitchStatement.prototype.emitWorker = function (emitter) { - emitter.recordSourceMappingStart(this.statement); - emitter.writeToOutput("switch ("); - this.val.emit(emitter); - emitter.writeToOutput(")"); - emitter.recordSourceMappingEnd(this.statement); - emitter.writeLineToOutput(" {"); - emitter.indenter.increaseIndent(); - - var lastEmittedNode = null; - for (var i = 0, n = this.caseList.members.length; i < n; i++) { - var caseExpr = this.caseList.members[i]; - - emitter.emitSpaceBetweenConstructs(lastEmittedNode, caseExpr); - emitter.emitJavascript(caseExpr, true); - - lastEmittedNode = caseExpr; - } - emitter.indenter.decreaseIndent(); - emitter.emitIndent(); - emitter.writeToOutput("}"); - }; - - SwitchStatement.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.caseList, ast.caseList, includingPosition) && structuralEquals(this.val, ast.val, includingPosition); - }; - return SwitchStatement; - })(Statement); - TypeScript.SwitchStatement = SwitchStatement; - - var CaseClause = (function (_super) { - __extends(CaseClause, _super); - function CaseClause() { - _super.call(this, 100 /* CaseClause */); - this.expr = null; - this.colonSpan = new ASTSpan(); - } - CaseClause.prototype.emitWorker = function (emitter) { - if (this.expr) { - emitter.writeToOutput("case "); - this.expr.emit(emitter); - } else { - emitter.writeToOutput("default"); - } - emitter.recordSourceMappingStart(this.colonSpan); - emitter.writeToOutput(":"); - emitter.recordSourceMappingEnd(this.colonSpan); - - if (this.body.members.length === 1 && this.body.members[0].nodeType === 81 /* Block */) { - this.body.members[0].emit(emitter); - emitter.writeLineToOutput(""); - } else { - emitter.writeLineToOutput(""); - emitter.indenter.increaseIndent(); - this.body.emit(emitter); - emitter.indenter.decreaseIndent(); - } - }; - - CaseClause.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.expr, ast.expr, includingPosition) && structuralEquals(this.body, ast.body, includingPosition); - }; - return CaseClause; - })(AST); - TypeScript.CaseClause = CaseClause; - - var TypeParameter = (function (_super) { - __extends(TypeParameter, _super); - function TypeParameter(name, constraint) { - _super.call(this, 9 /* TypeParameter */); - this.name = name; - this.constraint = constraint; - } - TypeParameter.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.name, ast.name, includingPosition) && structuralEquals(this.constraint, ast.constraint, includingPosition); - }; - return TypeParameter; - })(AST); - TypeScript.TypeParameter = TypeParameter; - - var GenericType = (function (_super) { - __extends(GenericType, _super); - function GenericType(name, typeArguments) { - _super.call(this, 10 /* GenericType */); - this.name = name; - this.typeArguments = typeArguments; - } - GenericType.prototype.emit = function (emitter) { - this.name.emit(emitter); - }; - - GenericType.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.name, ast.name, includingPosition) && structuralEquals(this.typeArguments, ast.typeArguments, includingPosition); - }; - return GenericType; - })(AST); - TypeScript.GenericType = GenericType; - - var TypeReference = (function (_super) { - __extends(TypeReference, _super); - function TypeReference(term, arrayCount) { - _super.call(this, 11 /* TypeRef */); - this.term = term; - this.arrayCount = arrayCount; - } - TypeReference.prototype.emit = function (emitter) { - throw new Error("should not emit a type ref"); - }; - - TypeReference.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.term, ast.term, includingPosition) && this.arrayCount === ast.arrayCount; - }; - return TypeReference; - })(AST); - TypeScript.TypeReference = TypeReference; - - var TryStatement = (function (_super) { - __extends(TryStatement, _super); - function TryStatement(tryBody, catchClause, finallyBody) { - _super.call(this, 96 /* TryStatement */); - this.tryBody = tryBody; - this.catchClause = catchClause; - this.finallyBody = finallyBody; - } - TryStatement.prototype.emitWorker = function (emitter) { - emitter.writeToOutput("try "); - this.tryBody.emit(emitter); - emitter.emitJavascript(this.catchClause, false); - - if (this.finallyBody) { - emitter.writeToOutput(" finally"); - this.finallyBody.emit(emitter); - } - }; - - TryStatement.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.tryBody, ast.tryBody, includingPosition) && structuralEquals(this.catchClause, ast.catchClause, includingPosition) && structuralEquals(this.finallyBody, ast.finallyBody, includingPosition); - }; - return TryStatement; - })(Statement); - TypeScript.TryStatement = TryStatement; - - var CatchClause = (function (_super) { - __extends(CatchClause, _super); - function CatchClause(param, body) { - _super.call(this, 101 /* CatchClause */); - this.param = param; - this.body = body; - this.statement = new ASTSpan(); - } - CatchClause.prototype.emitWorker = function (emitter) { - emitter.writeToOutput(" "); - emitter.recordSourceMappingStart(this.statement); - emitter.writeToOutput("catch ("); - this.param.id.emit(emitter); - emitter.writeToOutput(")"); - emitter.recordSourceMappingEnd(this.statement); - this.body.emit(emitter); - }; - - CatchClause.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.param, ast.param, includingPosition) && structuralEquals(this.body, ast.body, includingPosition); - }; - return CatchClause; - })(AST); - TypeScript.CatchClause = CatchClause; - - var DebuggerStatement = (function (_super) { - __extends(DebuggerStatement, _super); - function DebuggerStatement() { - _super.call(this, 84 /* DebuggerStatement */); - } - DebuggerStatement.prototype.emitWorker = function (emitter) { - emitter.writeToOutput("debugger;"); - }; - return DebuggerStatement; - })(Statement); - TypeScript.DebuggerStatement = DebuggerStatement; - - var OmittedExpression = (function (_super) { - __extends(OmittedExpression, _super); - function OmittedExpression() { - _super.call(this, 23 /* OmittedExpression */); - } - OmittedExpression.prototype.emitWorker = function (emitter) { - }; - - OmittedExpression.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition); - }; - return OmittedExpression; - })(Expression); - TypeScript.OmittedExpression = OmittedExpression; - - var EmptyStatement = (function (_super) { - __extends(EmptyStatement, _super); - function EmptyStatement() { - _super.call(this, 86 /* EmptyStatement */); - } - EmptyStatement.prototype.emitWorker = function (emitter) { - emitter.writeToOutput(";"); - }; - - EmptyStatement.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition); - }; - return EmptyStatement; - })(Statement); - TypeScript.EmptyStatement = EmptyStatement; - - var Comment = (function (_super) { - __extends(Comment, _super); - function Comment(content, isBlockComment, endsLine) { - _super.call(this, 102 /* Comment */); - this.content = content; - this.isBlockComment = isBlockComment; - this.endsLine = endsLine; - this.text = null; - this.docCommentText = null; - } - Comment.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && this.minLine === ast.minLine && this.content === ast.content && this.isBlockComment === ast.isBlockComment && this.endsLine === ast.endsLine; - }; - - Comment.prototype.getText = function () { - if (this.text === null) { - if (this.isBlockComment) { - this.text = this.content.split("\n"); - for (var i = 0; i < this.text.length; i++) { - this.text[i] = this.text[i].replace(/^\s+|\s+$/g, ''); - } - } else { - this.text = [(this.content.replace(/^\s+|\s+$/g, ''))]; - } - } - - return this.text; - }; - - Comment.prototype.isDocComment = function () { - if (this.isBlockComment) { - return this.content.charAt(2) === "*" && this.content.charAt(3) !== "/"; - } - - return false; - }; - - Comment.prototype.getDocCommentTextValue = function () { - if (this.docCommentText === null) { - this.docCommentText = Comment.cleanJSDocComment(this.content); - } - - return this.docCommentText; - }; - - Comment.consumeLeadingSpace = function (line, startIndex, maxSpacesToRemove) { - var endIndex = line.length; - if (maxSpacesToRemove !== undefined) { - endIndex = TypeScript.min(startIndex + maxSpacesToRemove, endIndex); - } - - for (; startIndex < endIndex; startIndex++) { - var charCode = line.charCodeAt(startIndex); - if (charCode !== 32 /* space */ && charCode !== 9 /* tab */) { - return startIndex; - } - } - - if (endIndex !== line.length) { - return endIndex; - } - - return -1; - }; - - Comment.isSpaceChar = function (line, index) { - var length = line.length; - if (index < length) { - var charCode = line.charCodeAt(index); - - return charCode === 32 /* space */ || charCode === 9 /* tab */; - } - - return index === length; - }; - - Comment.cleanDocCommentLine = function (line, jsDocStyleComment, jsDocLineSpaceToRemove) { - var nonSpaceIndex = Comment.consumeLeadingSpace(line, 0); - if (nonSpaceIndex !== -1) { - var jsDocSpacesRemoved = nonSpaceIndex; - if (jsDocStyleComment && line.charAt(nonSpaceIndex) === '*') { - var startIndex = nonSpaceIndex + 1; - nonSpaceIndex = Comment.consumeLeadingSpace(line, startIndex, jsDocLineSpaceToRemove); - - if (nonSpaceIndex !== -1) { - jsDocSpacesRemoved = nonSpaceIndex - startIndex; - } else { - return null; - } - } - - return { - minChar: nonSpaceIndex, - limChar: line.charAt(line.length - 1) === "\r" ? line.length - 1 : line.length, - jsDocSpacesRemoved: jsDocSpacesRemoved - }; - } - - return null; - }; - - Comment.cleanJSDocComment = function (content, spacesToRemove) { - var docCommentLines = []; - content = content.replace("/**", ""); - if (content.length >= 2 && content.charAt(content.length - 1) === "/" && content.charAt(content.length - 2) === "*") { - content = content.substring(0, content.length - 2); - } - var lines = content.split("\n"); - var inParamTag = false; - for (var l = 0; l < lines.length; l++) { - var line = lines[l]; - var cleanLinePos = Comment.cleanDocCommentLine(line, true, spacesToRemove); - if (!cleanLinePos) { - continue; - } - - var docCommentText = ""; - var prevPos = cleanLinePos.minChar; - for (var i = line.indexOf("@", cleanLinePos.minChar); 0 <= i && i < cleanLinePos.limChar; i = line.indexOf("@", i + 1)) { - var wasInParamtag = inParamTag; - - if (line.indexOf("param", i + 1) === i + 1 && Comment.isSpaceChar(line, i + 6)) { - if (!wasInParamtag) { - docCommentText += line.substring(prevPos, i); - } - - prevPos = i; - inParamTag = true; - } else if (wasInParamtag) { - prevPos = i; - inParamTag = false; - } - } - - if (!inParamTag) { - docCommentText += line.substring(prevPos, cleanLinePos.limChar); - } - - var newCleanPos = Comment.cleanDocCommentLine(docCommentText, false); - if (newCleanPos) { - if (spacesToRemove === undefined) { - spacesToRemove = cleanLinePos.jsDocSpacesRemoved; - } - docCommentLines.push(docCommentText); - } - } - - return docCommentLines.join("\n"); - }; - - Comment.getDocCommentText = function (comments) { - var docCommentText = []; - for (var c = 0; c < comments.length; c++) { - var commentText = comments[c].getDocCommentTextValue(); - if (commentText !== "") { - docCommentText.push(commentText); - } - } - return docCommentText.join("\n"); - }; - - Comment.getParameterDocCommentText = function (param, fncDocComments) { - if (fncDocComments.length === 0 || !fncDocComments[0].isBlockComment) { - return ""; - } - - for (var i = 0; i < fncDocComments.length; i++) { - var commentContents = fncDocComments[i].content; - for (var j = commentContents.indexOf("@param", 0); 0 <= j; j = commentContents.indexOf("@param", j)) { - j += 6; - if (!Comment.isSpaceChar(commentContents, j)) { - continue; - } - - j = Comment.consumeLeadingSpace(commentContents, j); - if (j === -1) { - break; - } - - if (commentContents.charCodeAt(j) === 123 /* openBrace */) { - j++; - - var charCode = 0; - for (var curlies = 1; j < commentContents.length; j++) { - charCode = commentContents.charCodeAt(j); - - if (charCode === 123 /* openBrace */) { - curlies++; - continue; - } - - if (charCode === 125 /* closeBrace */) { - curlies--; - if (curlies === 0) { - break; - } else { - continue; - } - } - - if (charCode === 64 /* at */) { - break; - } - } - - if (j === commentContents.length) { - break; - } - - if (charCode === 64 /* at */) { - continue; - } - - j = Comment.consumeLeadingSpace(commentContents, j + 1); - if (j === -1) { - break; - } - } - - if (param !== commentContents.substr(j, param.length) || !Comment.isSpaceChar(commentContents, j + param.length)) { - continue; - } - - j = Comment.consumeLeadingSpace(commentContents, j + param.length); - if (j === -1) { - return ""; - } - - var endOfParam = commentContents.indexOf("@", j); - var paramHelpString = commentContents.substring(j, endOfParam < 0 ? commentContents.length : endOfParam); - - var paramSpacesToRemove = undefined; - var paramLineIndex = commentContents.substring(0, j).lastIndexOf("\n") + 1; - if (paramLineIndex !== 0) { - if (paramLineIndex < j && commentContents.charAt(paramLineIndex + 1) === "\r") { - paramLineIndex++; - } - } - var startSpaceRemovalIndex = Comment.consumeLeadingSpace(commentContents, paramLineIndex); - if (startSpaceRemovalIndex !== j && commentContents.charAt(startSpaceRemovalIndex) === "*") { - paramSpacesToRemove = j - startSpaceRemovalIndex - 1; - } - - return Comment.cleanJSDocComment(paramHelpString, paramSpacesToRemove); - } - } - - return ""; - }; - return Comment; - })(AST); - TypeScript.Comment = Comment; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var AstWalkOptions = (function () { - function AstWalkOptions() { - this.goChildren = true; - } - return AstWalkOptions; - })(); - TypeScript.AstWalkOptions = AstWalkOptions; - - var AstWalker = (function () { - function AstWalker(childrenWalkers, pre, post, options, state) { - this.childrenWalkers = childrenWalkers; - this.pre = pre; - this.post = post; - this.options = options; - this.state = state; - } - AstWalker.prototype.walk = function (ast, parent) { - var preAst = this.pre(ast, parent, this); - if (preAst === undefined) { - preAst = ast; - } - if (this.options.goChildren) { - this.childrenWalkers[ast.nodeType](ast, parent, this); - } else { - this.options.goChildren = true; - } - - if (this.post) { - var postAst = this.post(preAst, parent, this); - if (postAst === undefined) { - postAst = preAst; - } - return postAst; - } else { - return preAst; - } - }; - return AstWalker; - })(); - - var AstWalkerFactory = (function () { - function AstWalkerFactory() { - this.childrenWalkers = []; - this.initChildrenWalkers(); - } - AstWalkerFactory.prototype.walk = function (ast, pre, post, options, state) { - return this.getWalker(pre, post, options, state).walk(ast, null); - }; - - AstWalkerFactory.prototype.getWalker = function (pre, post, options, state) { - return this.getSlowWalker(pre, post, options, state); - }; - - AstWalkerFactory.prototype.getSlowWalker = function (pre, post, options, state) { - if (!options) { - options = new AstWalkOptions(); - } - - return new AstWalker(this.childrenWalkers, pre, post, options, state); - }; - - AstWalkerFactory.prototype.initChildrenWalkers = function () { - this.childrenWalkers[0 /* None */] = ChildrenWalkers.walkNone; - this.childrenWalkers[86 /* EmptyStatement */] = ChildrenWalkers.walkNone; - this.childrenWalkers[23 /* OmittedExpression */] = ChildrenWalkers.walkNone; - this.childrenWalkers[3 /* TrueLiteral */] = ChildrenWalkers.walkNone; - this.childrenWalkers[4 /* FalseLiteral */] = ChildrenWalkers.walkNone; - this.childrenWalkers[29 /* ThisExpression */] = ChildrenWalkers.walkNone; - this.childrenWalkers[30 /* SuperExpression */] = ChildrenWalkers.walkNone; - this.childrenWalkers[5 /* StringLiteral */] = ChildrenWalkers.walkNone; - this.childrenWalkers[6 /* RegularExpressionLiteral */] = ChildrenWalkers.walkNone; - this.childrenWalkers[8 /* NullLiteral */] = ChildrenWalkers.walkNone; - this.childrenWalkers[21 /* ArrayLiteralExpression */] = ChildrenWalkers.walkUnaryExpressionChildren; - this.childrenWalkers[22 /* ObjectLiteralExpression */] = ChildrenWalkers.walkUnaryExpressionChildren; - this.childrenWalkers[24 /* VoidExpression */] = ChildrenWalkers.walkUnaryExpressionChildren; - this.childrenWalkers[25 /* CommaExpression */] = ChildrenWalkers.walkBinaryExpressionChildren; - this.childrenWalkers[26 /* PlusExpression */] = ChildrenWalkers.walkUnaryExpressionChildren; - this.childrenWalkers[27 /* NegateExpression */] = ChildrenWalkers.walkUnaryExpressionChildren; - this.childrenWalkers[28 /* DeleteExpression */] = ChildrenWalkers.walkUnaryExpressionChildren; - this.childrenWalkers[31 /* InExpression */] = ChildrenWalkers.walkBinaryExpressionChildren; - this.childrenWalkers[32 /* MemberAccessExpression */] = ChildrenWalkers.walkBinaryExpressionChildren; - this.childrenWalkers[33 /* InstanceOfExpression */] = ChildrenWalkers.walkBinaryExpressionChildren; - this.childrenWalkers[34 /* TypeOfExpression */] = ChildrenWalkers.walkUnaryExpressionChildren; - this.childrenWalkers[7 /* NumericLiteral */] = ChildrenWalkers.walkNone; - this.childrenWalkers[20 /* Name */] = ChildrenWalkers.walkNone; - this.childrenWalkers[9 /* TypeParameter */] = ChildrenWalkers.walkTypeParameterChildren; - this.childrenWalkers[10 /* GenericType */] = ChildrenWalkers.walkGenericTypeChildren; - this.childrenWalkers[11 /* TypeRef */] = ChildrenWalkers.walkTypeReferenceChildren; - this.childrenWalkers[35 /* ElementAccessExpression */] = ChildrenWalkers.walkBinaryExpressionChildren; - this.childrenWalkers[36 /* InvocationExpression */] = ChildrenWalkers.walkCallExpressionChildren; - this.childrenWalkers[37 /* ObjectCreationExpression */] = ChildrenWalkers.walkCallExpressionChildren; - this.childrenWalkers[38 /* AssignmentExpression */] = ChildrenWalkers.walkBinaryExpressionChildren; - this.childrenWalkers[39 /* AddAssignmentExpression */] = ChildrenWalkers.walkBinaryExpressionChildren; - this.childrenWalkers[40 /* SubtractAssignmentExpression */] = ChildrenWalkers.walkBinaryExpressionChildren; - this.childrenWalkers[41 /* DivideAssignmentExpression */] = ChildrenWalkers.walkBinaryExpressionChildren; - this.childrenWalkers[42 /* MultiplyAssignmentExpression */] = ChildrenWalkers.walkBinaryExpressionChildren; - this.childrenWalkers[43 /* ModuloAssignmentExpression */] = ChildrenWalkers.walkBinaryExpressionChildren; - this.childrenWalkers[44 /* AndAssignmentExpression */] = ChildrenWalkers.walkBinaryExpressionChildren; - this.childrenWalkers[45 /* ExclusiveOrAssignmentExpression */] = ChildrenWalkers.walkBinaryExpressionChildren; - this.childrenWalkers[46 /* OrAssignmentExpression */] = ChildrenWalkers.walkBinaryExpressionChildren; - this.childrenWalkers[47 /* LeftShiftAssignmentExpression */] = ChildrenWalkers.walkBinaryExpressionChildren; - this.childrenWalkers[48 /* SignedRightShiftAssignmentExpression */] = ChildrenWalkers.walkBinaryExpressionChildren; - this.childrenWalkers[49 /* UnsignedRightShiftAssignmentExpression */] = ChildrenWalkers.walkBinaryExpressionChildren; - this.childrenWalkers[50 /* ConditionalExpression */] = ChildrenWalkers.walkTrinaryExpressionChildren; - this.childrenWalkers[51 /* LogicalOrExpression */] = ChildrenWalkers.walkBinaryExpressionChildren; - this.childrenWalkers[52 /* LogicalAndExpression */] = ChildrenWalkers.walkBinaryExpressionChildren; - this.childrenWalkers[53 /* BitwiseOrExpression */] = ChildrenWalkers.walkBinaryExpressionChildren; - this.childrenWalkers[54 /* BitwiseExclusiveOrExpression */] = ChildrenWalkers.walkBinaryExpressionChildren; - this.childrenWalkers[55 /* BitwiseAndExpression */] = ChildrenWalkers.walkBinaryExpressionChildren; - this.childrenWalkers[56 /* EqualsWithTypeConversionExpression */] = ChildrenWalkers.walkBinaryExpressionChildren; - this.childrenWalkers[57 /* NotEqualsWithTypeConversionExpression */] = ChildrenWalkers.walkBinaryExpressionChildren; - this.childrenWalkers[58 /* EqualsExpression */] = ChildrenWalkers.walkBinaryExpressionChildren; - this.childrenWalkers[59 /* NotEqualsExpression */] = ChildrenWalkers.walkBinaryExpressionChildren; - this.childrenWalkers[60 /* LessThanExpression */] = ChildrenWalkers.walkBinaryExpressionChildren; - this.childrenWalkers[61 /* LessThanOrEqualExpression */] = ChildrenWalkers.walkBinaryExpressionChildren; - this.childrenWalkers[62 /* GreaterThanExpression */] = ChildrenWalkers.walkBinaryExpressionChildren; - this.childrenWalkers[63 /* GreaterThanOrEqualExpression */] = ChildrenWalkers.walkBinaryExpressionChildren; - this.childrenWalkers[64 /* AddExpression */] = ChildrenWalkers.walkBinaryExpressionChildren; - this.childrenWalkers[65 /* SubtractExpression */] = ChildrenWalkers.walkBinaryExpressionChildren; - this.childrenWalkers[66 /* MultiplyExpression */] = ChildrenWalkers.walkBinaryExpressionChildren; - this.childrenWalkers[67 /* DivideExpression */] = ChildrenWalkers.walkBinaryExpressionChildren; - this.childrenWalkers[68 /* ModuloExpression */] = ChildrenWalkers.walkBinaryExpressionChildren; - this.childrenWalkers[69 /* LeftShiftExpression */] = ChildrenWalkers.walkBinaryExpressionChildren; - this.childrenWalkers[70 /* SignedRightShiftExpression */] = ChildrenWalkers.walkBinaryExpressionChildren; - this.childrenWalkers[71 /* UnsignedRightShiftExpression */] = ChildrenWalkers.walkBinaryExpressionChildren; - this.childrenWalkers[72 /* BitwiseNotExpression */] = ChildrenWalkers.walkUnaryExpressionChildren; - this.childrenWalkers[73 /* LogicalNotExpression */] = ChildrenWalkers.walkUnaryExpressionChildren; - this.childrenWalkers[74 /* PreIncrementExpression */] = ChildrenWalkers.walkUnaryExpressionChildren; - this.childrenWalkers[75 /* PreDecrementExpression */] = ChildrenWalkers.walkUnaryExpressionChildren; - this.childrenWalkers[76 /* PostIncrementExpression */] = ChildrenWalkers.walkUnaryExpressionChildren; - this.childrenWalkers[77 /* PostDecrementExpression */] = ChildrenWalkers.walkUnaryExpressionChildren; - this.childrenWalkers[78 /* CastExpression */] = ChildrenWalkers.walkUnaryExpressionChildren; - this.childrenWalkers[79 /* ParenthesizedExpression */] = ChildrenWalkers.walkParenthesizedExpressionChildren; - this.childrenWalkers[12 /* FunctionDeclaration */] = ChildrenWalkers.walkFuncDeclChildren; - this.childrenWalkers[80 /* Member */] = ChildrenWalkers.walkBinaryExpressionChildren; - this.childrenWalkers[17 /* VariableDeclarator */] = ChildrenWalkers.walkBoundDeclChildren; - this.childrenWalkers[18 /* VariableDeclaration */] = ChildrenWalkers.walkVariableDeclarationChildren; - this.childrenWalkers[19 /* Parameter */] = ChildrenWalkers.walkBoundDeclChildren; - this.childrenWalkers[93 /* ReturnStatement */] = ChildrenWalkers.walkReturnStatementChildren; - this.childrenWalkers[82 /* BreakStatement */] = ChildrenWalkers.walkNone; - this.childrenWalkers[83 /* ContinueStatement */] = ChildrenWalkers.walkNone; - this.childrenWalkers[95 /* ThrowStatement */] = ChildrenWalkers.walkThrowStatementChildren; - this.childrenWalkers[90 /* ForStatement */] = ChildrenWalkers.walkForStatementChildren; - this.childrenWalkers[89 /* ForInStatement */] = ChildrenWalkers.walkForInStatementChildren; - this.childrenWalkers[91 /* IfStatement */] = ChildrenWalkers.walkIfStatementChildren; - this.childrenWalkers[98 /* WhileStatement */] = ChildrenWalkers.walkWhileStatementChildren; - this.childrenWalkers[85 /* DoStatement */] = ChildrenWalkers.walkDoStatementChildren; - this.childrenWalkers[81 /* Block */] = ChildrenWalkers.walkBlockChildren; - this.childrenWalkers[100 /* CaseClause */] = ChildrenWalkers.walkCaseClauseChildren; - this.childrenWalkers[94 /* SwitchStatement */] = ChildrenWalkers.walkSwitchStatementChildren; - this.childrenWalkers[96 /* TryStatement */] = ChildrenWalkers.walkTryStatementChildren; - this.childrenWalkers[101 /* CatchClause */] = ChildrenWalkers.walkCatchClauseChildren; - this.childrenWalkers[1 /* List */] = ChildrenWalkers.walkListChildren; - this.childrenWalkers[2 /* Script */] = ChildrenWalkers.walkScriptChildren; - this.childrenWalkers[13 /* ClassDeclaration */] = ChildrenWalkers.walkClassDeclChildren; - this.childrenWalkers[14 /* InterfaceDeclaration */] = ChildrenWalkers.walkTypeDeclChildren; - this.childrenWalkers[15 /* ModuleDeclaration */] = ChildrenWalkers.walkModuleDeclChildren; - this.childrenWalkers[16 /* ImportDeclaration */] = ChildrenWalkers.walkImportDeclChildren; - this.childrenWalkers[87 /* ExportAssignment */] = ChildrenWalkers.walkExportAssignmentChildren; - this.childrenWalkers[99 /* WithStatement */] = ChildrenWalkers.walkWithStatementChildren; - this.childrenWalkers[88 /* ExpressionStatement */] = ChildrenWalkers.walkExpressionStatementChildren; - this.childrenWalkers[92 /* LabeledStatement */] = ChildrenWalkers.walkLabeledStatementChildren; - this.childrenWalkers[97 /* VariableStatement */] = ChildrenWalkers.walkVariableStatementChildren; - this.childrenWalkers[102 /* Comment */] = ChildrenWalkers.walkNone; - this.childrenWalkers[84 /* DebuggerStatement */] = ChildrenWalkers.walkNone; - - for (var e in TypeScript.NodeType) { - if (TypeScript.NodeType.hasOwnProperty(e) && TypeScript.StringUtilities.isString(TypeScript.NodeType[e])) { - if (this.childrenWalkers[e] === undefined) { - throw new Error("initWalkers function is not up to date with enum content!"); - } - } - } - }; - return AstWalkerFactory; - })(); - TypeScript.AstWalkerFactory = AstWalkerFactory; - - var globalAstWalkerFactory; - - function getAstWalkerFactory() { - if (!globalAstWalkerFactory) { - globalAstWalkerFactory = new AstWalkerFactory(); - } - return globalAstWalkerFactory; - } - TypeScript.getAstWalkerFactory = getAstWalkerFactory; - - var ChildrenWalkers; - (function (ChildrenWalkers) { - function walkNone(preAst, parent, walker) { - } - ChildrenWalkers.walkNone = walkNone; - - function walkListChildren(preAst, parent, walker) { - var len = preAst.members.length; - - for (var i = 0; i < len; i++) { - preAst.members[i] = walker.walk(preAst.members[i], preAst); - } - } - ChildrenWalkers.walkListChildren = walkListChildren; - - function walkThrowStatementChildren(preAst, parent, walker) { - if (preAst.expression) { - preAst.expression = walker.walk(preAst.expression, preAst); - } - } - ChildrenWalkers.walkThrowStatementChildren = walkThrowStatementChildren; - - function walkUnaryExpressionChildren(preAst, parent, walker) { - if (preAst.castTerm) { - preAst.castTerm = walker.walk(preAst.castTerm, preAst); - } - if (preAst.operand) { - preAst.operand = walker.walk(preAst.operand, preAst); - } - } - ChildrenWalkers.walkUnaryExpressionChildren = walkUnaryExpressionChildren; - - function walkParenthesizedExpressionChildren(preAst, parent, walker) { - if (preAst.expression) { - preAst.expression = walker.walk(preAst.expression, preAst); - } - } - ChildrenWalkers.walkParenthesizedExpressionChildren = walkParenthesizedExpressionChildren; - - function walkBinaryExpressionChildren(preAst, parent, walker) { - if (preAst.operand1) { - preAst.operand1 = walker.walk(preAst.operand1, preAst); - } - if (preAst.operand2) { - preAst.operand2 = walker.walk(preAst.operand2, preAst); - } - } - ChildrenWalkers.walkBinaryExpressionChildren = walkBinaryExpressionChildren; - - function walkTypeParameterChildren(preAst, parent, walker) { - if (preAst.name) { - preAst.name = walker.walk(preAst.name, preAst); - } - - if (preAst.constraint) { - preAst.constraint = walker.walk(preAst.constraint, preAst); - } - } - ChildrenWalkers.walkTypeParameterChildren = walkTypeParameterChildren; - - function walkGenericTypeChildren(preAst, parent, walker) { - if (preAst.name) { - preAst.name = walker.walk(preAst.name, preAst); - } - - if (preAst.typeArguments) { - preAst.typeArguments = walker.walk(preAst.typeArguments, preAst); - } - } - ChildrenWalkers.walkGenericTypeChildren = walkGenericTypeChildren; - - function walkTypeReferenceChildren(preAst, parent, walker) { - if (preAst.term) { - preAst.term = walker.walk(preAst.term, preAst); - } - } - ChildrenWalkers.walkTypeReferenceChildren = walkTypeReferenceChildren; - - function walkCallExpressionChildren(preAst, parent, walker) { - preAst.target = walker.walk(preAst.target, preAst); - - if (preAst.typeArguments) { - preAst.typeArguments = walker.walk(preAst.typeArguments, preAst); - } - - if (preAst.arguments) { - preAst.arguments = walker.walk(preAst.arguments, preAst); - } - } - ChildrenWalkers.walkCallExpressionChildren = walkCallExpressionChildren; - - function walkTrinaryExpressionChildren(preAst, parent, walker) { - if (preAst.operand1) { - preAst.operand1 = walker.walk(preAst.operand1, preAst); - } - if (preAst.operand2) { - preAst.operand2 = walker.walk(preAst.operand2, preAst); - } - if (preAst.operand3) { - preAst.operand3 = walker.walk(preAst.operand3, preAst); - } - } - ChildrenWalkers.walkTrinaryExpressionChildren = walkTrinaryExpressionChildren; - - function walkFuncDeclChildren(preAst, parent, walker) { - if (preAst.name) { - preAst.name = walker.walk(preAst.name, preAst); - } - if (preAst.typeArguments) { - preAst.typeArguments = walker.walk(preAst.typeArguments, preAst); - } - if (preAst.arguments) { - preAst.arguments = walker.walk(preAst.arguments, preAst); - } - if (preAst.returnTypeAnnotation) { - preAst.returnTypeAnnotation = walker.walk(preAst.returnTypeAnnotation, preAst); - } - if (preAst.block) { - preAst.block = walker.walk(preAst.block, preAst); - } - } - ChildrenWalkers.walkFuncDeclChildren = walkFuncDeclChildren; - - function walkBoundDeclChildren(preAst, parent, walker) { - if (preAst.id) { - preAst.id = walker.walk(preAst.id, preAst); - } - if (preAst.init) { - preAst.init = walker.walk(preAst.init, preAst); - } - if (preAst.typeExpr) { - preAst.typeExpr = walker.walk(preAst.typeExpr, preAst); - } - } - ChildrenWalkers.walkBoundDeclChildren = walkBoundDeclChildren; - - function walkReturnStatementChildren(preAst, parent, walker) { - if (preAst.returnExpression) { - preAst.returnExpression = walker.walk(preAst.returnExpression, preAst); - } - } - ChildrenWalkers.walkReturnStatementChildren = walkReturnStatementChildren; - - function walkForStatementChildren(preAst, parent, walker) { - if (preAst.init) { - preAst.init = walker.walk(preAst.init, preAst); - } - - if (preAst.cond) { - preAst.cond = walker.walk(preAst.cond, preAst); - } - - if (preAst.incr) { - preAst.incr = walker.walk(preAst.incr, preAst); - } - - if (preAst.body) { - preAst.body = walker.walk(preAst.body, preAst); - } - } - ChildrenWalkers.walkForStatementChildren = walkForStatementChildren; - - function walkForInStatementChildren(preAst, parent, walker) { - preAst.lval = walker.walk(preAst.lval, preAst); - preAst.obj = walker.walk(preAst.obj, preAst); - - if (preAst.body) { - preAst.body = walker.walk(preAst.body, preAst); - } - } - ChildrenWalkers.walkForInStatementChildren = walkForInStatementChildren; - - function walkIfStatementChildren(preAst, parent, walker) { - preAst.cond = walker.walk(preAst.cond, preAst); - if (preAst.thenBod) { - preAst.thenBod = walker.walk(preAst.thenBod, preAst); - } - if (preAst.elseBod) { - preAst.elseBod = walker.walk(preAst.elseBod, preAst); - } - } - ChildrenWalkers.walkIfStatementChildren = walkIfStatementChildren; - - function walkWhileStatementChildren(preAst, parent, walker) { - preAst.cond = walker.walk(preAst.cond, preAst); - if (preAst.body) { - preAst.body = walker.walk(preAst.body, preAst); - } - } - ChildrenWalkers.walkWhileStatementChildren = walkWhileStatementChildren; - - function walkDoStatementChildren(preAst, parent, walker) { - preAst.cond = walker.walk(preAst.cond, preAst); - if (preAst.body) { - preAst.body = walker.walk(preAst.body, preAst); - } - } - ChildrenWalkers.walkDoStatementChildren = walkDoStatementChildren; - - function walkBlockChildren(preAst, parent, walker) { - if (preAst.statements) { - preAst.statements = walker.walk(preAst.statements, preAst); - } - } - ChildrenWalkers.walkBlockChildren = walkBlockChildren; - - function walkVariableDeclarationChildren(preAst, parent, walker) { - if (preAst.declarators) { - preAst.declarators = walker.walk(preAst.declarators, preAst); - } - } - ChildrenWalkers.walkVariableDeclarationChildren = walkVariableDeclarationChildren; - - function walkCaseClauseChildren(preAst, parent, walker) { - if (preAst.expr) { - preAst.expr = walker.walk(preAst.expr, preAst); - } - - if (preAst.body) { - preAst.body = walker.walk(preAst.body, preAst); - } - } - ChildrenWalkers.walkCaseClauseChildren = walkCaseClauseChildren; - - function walkSwitchStatementChildren(preAst, parent, walker) { - if (preAst.val) { - preAst.val = walker.walk(preAst.val, preAst); - } - - if (preAst.caseList) { - preAst.caseList = walker.walk(preAst.caseList, preAst); - } - } - ChildrenWalkers.walkSwitchStatementChildren = walkSwitchStatementChildren; - - function walkTryStatementChildren(preAst, parent, walker) { - if (preAst.tryBody) { - preAst.tryBody = walker.walk(preAst.tryBody, preAst); - } - if (preAst.catchClause) { - preAst.catchClause = walker.walk(preAst.catchClause, preAst); - } - if (preAst.finallyBody) { - preAst.finallyBody = walker.walk(preAst.finallyBody, preAst); - } - } - ChildrenWalkers.walkTryStatementChildren = walkTryStatementChildren; - - function walkCatchClauseChildren(preAst, parent, walker) { - if (preAst.param) { - preAst.param = walker.walk(preAst.param, preAst); - } - - if (preAst.body) { - preAst.body = walker.walk(preAst.body, preAst); - } - } - ChildrenWalkers.walkCatchClauseChildren = walkCatchClauseChildren; - - function walkRecordChildren(preAst, parent, walker) { - preAst.name = walker.walk(preAst.name, preAst); - if (preAst.members) { - preAst.members = walker.walk(preAst.members, preAst); - } - } - ChildrenWalkers.walkRecordChildren = walkRecordChildren; - - function walkNamedTypeChildren(preAst, parent, walker) { - walkRecordChildren(preAst, parent, walker); - } - ChildrenWalkers.walkNamedTypeChildren = walkNamedTypeChildren; - - function walkClassDeclChildren(preAst, parent, walker) { - walkNamedTypeChildren(preAst, parent, walker); - - if (preAst.typeParameters) { - preAst.typeParameters = walker.walk(preAst.typeParameters, preAst); - } - - if (preAst.extendsList) { - preAst.extendsList = walker.walk(preAst.extendsList, preAst); - } - - if (preAst.implementsList) { - preAst.implementsList = walker.walk(preAst.implementsList, preAst); - } - } - ChildrenWalkers.walkClassDeclChildren = walkClassDeclChildren; - - function walkScriptChildren(preAst, parent, walker) { - if (preAst.moduleElements) { - preAst.moduleElements = walker.walk(preAst.moduleElements, preAst); - } - } - ChildrenWalkers.walkScriptChildren = walkScriptChildren; - - function walkTypeDeclChildren(preAst, parent, walker) { - walkNamedTypeChildren(preAst, parent, walker); - - if (preAst.typeParameters) { - preAst.typeParameters = walker.walk(preAst.typeParameters, preAst); - } - - if (preAst.extendsList) { - preAst.extendsList = walker.walk(preAst.extendsList, preAst); - } - - if (preAst.implementsList) { - preAst.implementsList = walker.walk(preAst.implementsList, preAst); - } - } - ChildrenWalkers.walkTypeDeclChildren = walkTypeDeclChildren; - - function walkModuleDeclChildren(preAst, parent, walker) { - walkRecordChildren(preAst, parent, walker); - } - ChildrenWalkers.walkModuleDeclChildren = walkModuleDeclChildren; - - function walkImportDeclChildren(preAst, parent, walker) { - if (preAst.id) { - preAst.id = walker.walk(preAst.id, preAst); - } - if (preAst.alias) { - preAst.alias = walker.walk(preAst.alias, preAst); - } - } - ChildrenWalkers.walkImportDeclChildren = walkImportDeclChildren; - - function walkExportAssignmentChildren(preAst, parent, walker) { - if (preAst.id) { - preAst.id = walker.walk(preAst.id, preAst); - } - } - ChildrenWalkers.walkExportAssignmentChildren = walkExportAssignmentChildren; - - function walkWithStatementChildren(preAst, parent, walker) { - if (preAst.expr) { - preAst.expr = walker.walk(preAst.expr, preAst); - } - - if (preAst.body) { - preAst.body = walker.walk(preAst.body, preAst); - } - } - ChildrenWalkers.walkWithStatementChildren = walkWithStatementChildren; - - function walkExpressionStatementChildren(preAst, parent, walker) { - preAst.expression = walker.walk(preAst.expression, preAst); - } - ChildrenWalkers.walkExpressionStatementChildren = walkExpressionStatementChildren; - - function walkLabeledStatementChildren(preAst, parent, walker) { - preAst.identifier = walker.walk(preAst.identifier, preAst); - preAst.statement = walker.walk(preAst.statement, preAst); - } - ChildrenWalkers.walkLabeledStatementChildren = walkLabeledStatementChildren; - - function walkVariableStatementChildren(preAst, parent, walker) { - preAst.declaration = walker.walk(preAst.declaration, preAst); - } - ChildrenWalkers.walkVariableStatementChildren = walkVariableStatementChildren; - })(ChildrenWalkers || (ChildrenWalkers = {})); -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (AstWalkerWithDetailCallback) { - function walk(script, callback) { - var pre = function (cur, parent) { - walker.options.goChildren = AstWalkerCallback(true, cur, callback); - return cur; - }; - - var post = function (cur, parent) { - AstWalkerCallback(false, cur, callback); - return cur; - }; - - var walker = TypeScript.getAstWalkerFactory().getWalker(pre, post); - walker.walk(script, null); - } - AstWalkerWithDetailCallback.walk = walk; - - function AstWalkerCallback(pre, ast, callback) { - var nodeType = ast.nodeType; - var callbackString = TypeScript.NodeType[nodeType] + "Callback"; - if (callback[callbackString]) { - return callback[callbackString](pre, ast); - } - - if (callback.DefaultCallback) { - return callback.DefaultCallback(pre, ast); - } - - return true; - } - })(TypeScript.AstWalkerWithDetailCallback || (TypeScript.AstWalkerWithDetailCallback = {})); - var AstWalkerWithDetailCallback = TypeScript.AstWalkerWithDetailCallback; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - function max(a, b) { - return a >= b ? a : b; - } - TypeScript.max = max; - - function min(a, b) { - return a <= b ? a : b; - } - TypeScript.min = min; - - var AstPath = (function () { - function AstPath() { - this.asts = []; - this.top = -1; - } - AstPath.reverseIndexOf = function (items, index) { - return (items === null || items.length <= index) ? null : items[items.length - index - 1]; - }; - - AstPath.prototype.clone = function () { - var clone = new AstPath(); - clone.asts = this.asts.map(function (value) { - return value; - }); - clone.top = this.top; - return clone; - }; - - AstPath.prototype.pop = function () { - var head = this.ast(); - this.up(); - - while (this.asts.length > this.count()) { - this.asts.pop(); - } - return head; - }; - - AstPath.prototype.push = function (ast) { - while (this.asts.length > this.count()) { - this.asts.pop(); - } - this.top = this.asts.length; - this.asts.push(ast); - }; - - AstPath.prototype.up = function () { - if (this.top <= -1) - throw new Error("Invalid call to 'up'"); - this.top--; - }; - - AstPath.prototype.down = function () { - if (this.top === this.ast.length - 1) - throw new Error("Invalid call to 'down'"); - this.top++; - }; - - AstPath.prototype.nodeType = function () { - if (this.ast() === null) - return 0 /* None */; - return this.ast().nodeType; - }; - - AstPath.prototype.ast = function () { - return AstPath.reverseIndexOf(this.asts, this.asts.length - (this.top + 1)); - }; - - AstPath.prototype.parent = function () { - return AstPath.reverseIndexOf(this.asts, this.asts.length - this.top); - }; - - AstPath.prototype.count = function () { - return this.top + 1; - }; - - AstPath.prototype.get = function (index) { - return this.asts[index]; - }; - - AstPath.prototype.isNameOfClass = function () { - if (this.ast() === null || this.parent() === null) - return false; - - return (this.ast().nodeType === 20 /* Name */) && (this.parent().nodeType === 13 /* ClassDeclaration */) && ((this.parent()).name === this.ast()); - }; - - AstPath.prototype.isNameOfInterface = function () { - if (this.ast() === null || this.parent() === null) - return false; - - return (this.ast().nodeType === 20 /* Name */) && (this.parent().nodeType === 14 /* InterfaceDeclaration */) && ((this.parent()).name === this.ast()); - }; - - AstPath.prototype.isNameOfArgument = function () { - if (this.ast() === null || this.parent() === null) - return false; - - return (this.ast().nodeType === 20 /* Name */) && (this.parent().nodeType === 19 /* Parameter */) && ((this.parent()).id === this.ast()); - }; - - AstPath.prototype.isNameOfVariable = function () { - if (this.ast() === null || this.parent() === null) - return false; - - return (this.ast().nodeType === 20 /* Name */) && (this.parent().nodeType === 17 /* VariableDeclarator */) && ((this.parent()).id === this.ast()); - }; - - AstPath.prototype.isNameOfModule = function () { - if (this.ast() === null || this.parent() === null) - return false; - - return (this.ast().nodeType === 20 /* Name */) && (this.parent().nodeType === 15 /* ModuleDeclaration */) && ((this.parent()).name === this.ast()); - }; - - AstPath.prototype.isNameOfFunction = function () { - if (this.ast() === null || this.parent() === null) - return false; - - return (this.ast().nodeType === 20 /* Name */) && (this.parent().nodeType === 12 /* FunctionDeclaration */) && ((this.parent()).name === this.ast()); - }; - - AstPath.prototype.isBodyOfFunction = function () { - return this.count() >= 2 && this.asts[this.top - 1].nodeType === 12 /* FunctionDeclaration */ && (this.asts[this.top - 1]).block === this.asts[this.top - 0]; - }; - - AstPath.prototype.isArgumentListOfFunction = function () { - return this.count() >= 2 && this.asts[this.top - 0].nodeType === 1 /* List */ && this.asts[this.top - 1].nodeType === 12 /* FunctionDeclaration */ && (this.asts[this.top - 1]).arguments === this.asts[this.top - 0]; - }; - - AstPath.prototype.isTargetOfCall = function () { - return this.count() >= 2 && this.asts[this.top - 1].nodeType === 36 /* InvocationExpression */ && (this.asts[this.top - 1]).target === this.asts[this.top]; - }; - - AstPath.prototype.isTargetOfNew = function () { - return this.count() >= 2 && this.asts[this.top - 1].nodeType === 37 /* ObjectCreationExpression */ && (this.asts[this.top - 1]).target === this.asts[this.top]; - }; - - AstPath.prototype.isInClassImplementsList = function () { - if (this.ast() === null || this.parent() === null) - return false; - - return (this.parent().nodeType === 13 /* ClassDeclaration */) && (this.isMemberOfList((this.parent()).implementsList, this.ast())); - }; - - AstPath.prototype.isInInterfaceExtendsList = function () { - if (this.ast() === null || this.parent() === null) - return false; - - return (this.parent().nodeType === 14 /* InterfaceDeclaration */) && (this.isMemberOfList((this.parent()).extendsList, this.ast())); - }; - - AstPath.prototype.isMemberOfMemberAccessExpression = function () { - if (this.count() > 1 && this.parent().nodeType === 32 /* MemberAccessExpression */ && (this.parent()).operand2 === this.asts[this.top]) { - return true; - } - - return false; - }; - - AstPath.prototype.isCallExpression = function () { - return this.count() >= 1 && (this.asts[this.top - 0].nodeType === 36 /* InvocationExpression */ || this.asts[this.top - 0].nodeType === 37 /* ObjectCreationExpression */); - }; - - AstPath.prototype.isCallExpressionTarget = function () { - if (this.count() < 2) { - return false; - } - - var current = this.top; - - var nodeType = this.asts[current].nodeType; - if (nodeType === 29 /* ThisExpression */ || nodeType === 30 /* SuperExpression */ || nodeType === 20 /* Name */) { - current--; - } - - while (current >= 0) { - if (current < this.top && this.asts[current].nodeType === 32 /* MemberAccessExpression */ && (this.asts[current]).operand2 === this.asts[current + 1]) { - current--; - continue; - } - - break; - } - - return current < this.top && (this.asts[current].nodeType === 36 /* InvocationExpression */ || this.asts[current].nodeType === 37 /* ObjectCreationExpression */) && this.asts[current + 1] === (this.asts[current]).target; - }; - - AstPath.prototype.isDeclaration = function () { - if (this.ast() !== null) { - switch (this.ast().nodeType) { - case 13 /* ClassDeclaration */: - case 14 /* InterfaceDeclaration */: - case 15 /* ModuleDeclaration */: - case 12 /* FunctionDeclaration */: - case 17 /* VariableDeclarator */: - return true; - } - } - - return false; - }; - - AstPath.prototype.isMemberOfList = function (list, item) { - if (list && list.members) { - for (var i = 0, n = list.members.length; i < n; i++) { - if (list.members[i] === item) { - return true; - } - } - } - - return false; - }; - return AstPath; - })(); - TypeScript.AstPath = AstPath; - - function isValidAstNode(ast) { - if (ast === null) - return false; - - if (ast.minChar === -1 || ast.limChar === -1) - return false; - - return true; - } - TypeScript.isValidAstNode = isValidAstNode; - - var AstPathContext = (function () { - function AstPathContext() { - this.path = new TypeScript.AstPath(); - } - return AstPathContext; - })(); - TypeScript.AstPathContext = AstPathContext; - - (function (GetAstPathOptions) { - GetAstPathOptions[GetAstPathOptions["Default"] = 0] = "Default"; - GetAstPathOptions[GetAstPathOptions["EdgeInclusive"] = 1] = "EdgeInclusive"; - - GetAstPathOptions[GetAstPathOptions["DontPruneSearchBasedOnPosition"] = 1 << 1] = "DontPruneSearchBasedOnPosition"; - })(TypeScript.GetAstPathOptions || (TypeScript.GetAstPathOptions = {})); - var GetAstPathOptions = TypeScript.GetAstPathOptions; - - function getAstPathToPosition(script, pos, useTrailingTriviaAsLimChar, options) { - if (typeof useTrailingTriviaAsLimChar === "undefined") { useTrailingTriviaAsLimChar = true; } - if (typeof options === "undefined") { options = 0 /* Default */; } - var lookInComments = function (comments) { - if (comments && comments.length > 0) { - for (var i = 0; i < comments.length; i++) { - var minChar = comments[i].minChar; - var limChar = comments[i].limChar + (useTrailingTriviaAsLimChar ? comments[i].trailingTriviaWidth : 0); - if (!comments[i].isBlockComment) { - limChar++; - } - if (pos >= minChar && pos < limChar) { - ctx.path.push(comments[i]); - } - } - } - }; - - var pre = function (cur, parent, walker) { - if (isValidAstNode(cur)) { - var inclusive = TypeScript.hasFlag(options, 1 /* EdgeInclusive */) || cur.nodeType === 20 /* Name */ || cur.nodeType === 32 /* MemberAccessExpression */ || cur.nodeType === 11 /* TypeRef */ || pos === script.limChar + script.trailingTriviaWidth; - - var minChar = cur.minChar; - var limChar = cur.limChar + (useTrailingTriviaAsLimChar ? cur.trailingTriviaWidth : 0) + (inclusive ? 1 : 0); - if (pos >= minChar && pos < limChar) { - var previous = ctx.path.ast(); - if (previous === null || (cur.minChar >= previous.minChar && (cur.limChar + (useTrailingTriviaAsLimChar ? cur.trailingTriviaWidth : 0)) <= (previous.limChar + (useTrailingTriviaAsLimChar ? previous.trailingTriviaWidth : 0)))) { - ctx.path.push(cur); - } else { - } - } - - if (pos < limChar) { - lookInComments(cur.preComments); - } - if (pos >= minChar) { - lookInComments(cur.postComments); - } - - if (!TypeScript.hasFlag(options, 2 /* DontPruneSearchBasedOnPosition */)) { - walker.options.goChildren = (minChar <= pos && pos <= limChar); - } - } - return cur; - }; - - var ctx = new AstPathContext(); - TypeScript.getAstWalkerFactory().walk(script, pre, null, null, ctx); - return ctx.path; - } - TypeScript.getAstPathToPosition = getAstPathToPosition; - - function walkAST(ast, callback) { - var pre = function (cur, parent, walker) { - var path = walker.state; - path.push(cur); - callback(path, walker); - return cur; - }; - var post = function (cur, parent, walker) { - var path = walker.state; - path.pop(); - return cur; - }; - - var path = new AstPath(); - TypeScript.getAstWalkerFactory().walk(ast, pre, post, null, path); - } - TypeScript.walkAST = walkAST; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var Base64Format = (function () { - function Base64Format() { - } - Base64Format.encode = function (inValue) { - if (inValue < 64) { - return Base64Format.encodedValues.charAt(inValue); - } - throw TypeError(inValue + ": not a 64 based value"); - }; - - Base64Format.decodeChar = function (inChar) { - if (inChar.length === 1) { - return Base64Format.encodedValues.indexOf(inChar); - } else { - throw TypeError('"' + inChar + '" must have length 1'); - } - }; - Base64Format.encodedValues = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'; - return Base64Format; - })(); - - var Base64VLQFormat = (function () { - function Base64VLQFormat() { - } - Base64VLQFormat.encode = function (inValue) { - if (inValue < 0) { - inValue = ((-inValue) << 1) + 1; - } else { - inValue = inValue << 1; - } - - var encodedStr = ""; - do { - var currentDigit = inValue & 31; - inValue = inValue >> 5; - if (inValue > 0) { - currentDigit = currentDigit | 32; - } - encodedStr = encodedStr + Base64Format.encode(currentDigit); - } while(inValue > 0); - - return encodedStr; - }; - - Base64VLQFormat.decode = function (inString) { - var result = 0; - var negative = false; - - var shift = 0; - for (var i = 0; i < inString.length; i++) { - var byte = Base64Format.decodeChar(inString[i]); - if (i === 0) { - if ((byte & 1) === 1) { - negative = true; - } - result = (byte >> 1) & 15; - } else { - result = result | ((byte & 31) << shift); - } - - shift += (i === 0) ? 4 : 5; - - if ((byte & 32) === 32) { - } else { - return { value: negative ? -(result) : result, rest: inString.substr(i + 1) }; - } - } - - throw new Error('Base64 value "' + inString + '" finished with a continuation bit'); - }; - return Base64VLQFormat; - })(); - TypeScript.Base64VLQFormat = Base64VLQFormat; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var SourceMapPosition = (function () { - function SourceMapPosition() { - } - return SourceMapPosition; - })(); - TypeScript.SourceMapPosition = SourceMapPosition; - - var SourceMapping = (function () { - function SourceMapping() { - this.start = new SourceMapPosition(); - this.end = new SourceMapPosition(); - this.nameIndex = -1; - this.childMappings = []; - } - return SourceMapping; - })(); - TypeScript.SourceMapping = SourceMapping; - - var SourceMapper = (function () { - function SourceMapper(tsFileName, jsFileName, sourceMapFileName, jsFile, sourceMapOut, emitFullPathOfSourceMap) { - this.sourceMapFileName = sourceMapFileName; - this.jsFile = jsFile; - this.sourceMapOut = sourceMapOut; - this.sourceMappings = []; - this.currentMappings = []; - this.names = []; - this.currentNameIndex = []; - this.currentMappings.push(this.sourceMappings); - - jsFileName = TypeScript.switchToForwardSlashes(jsFileName); - this.jsFileName = TypeScript.getPrettyName(jsFileName, false, true); - - var removalIndex = jsFileName.lastIndexOf(this.jsFileName); - var fixedPath = jsFileName.substring(0, removalIndex); - - if (emitFullPathOfSourceMap) { - if (jsFileName.indexOf("://") === -1) { - jsFileName = "file:///" + jsFileName; - } - this.jsFileName = jsFileName; - } - - this.tsFileName = TypeScript.getRelativePathToFixedPath(fixedPath, tsFileName); - } - SourceMapper.emitSourceMapping = function (allSourceMappers) { - var sourceMapper = allSourceMappers[0]; - sourceMapper.jsFile.WriteLine("//@ sourceMappingURL=" + sourceMapper.jsFileName + SourceMapper.MapFileExtension); - - var sourceMapOut = sourceMapper.sourceMapOut; - var mappingsString = ""; - var tsFiles = []; - - var prevEmittedColumn = 0; - var prevEmittedLine = 0; - var prevSourceColumn = 0; - var prevSourceLine = 0; - var prevSourceIndex = 0; - var prevNameIndex = 0; - var namesList = []; - var namesCount = 0; - var emitComma = false; - - var recordedPosition = null; - for (var sourceMapperIndex = 0; sourceMapperIndex < allSourceMappers.length; sourceMapperIndex++) { - sourceMapper = allSourceMappers[sourceMapperIndex]; - - var currentSourceIndex = tsFiles.length; - tsFiles.push(sourceMapper.tsFileName); - - if (sourceMapper.names.length > 0) { - namesList.push.apply(namesList, sourceMapper.names); - } - - var recordSourceMapping = function (mappedPosition, nameIndex) { - if (recordedPosition !== null && recordedPosition.emittedColumn === mappedPosition.emittedColumn && recordedPosition.emittedLine === mappedPosition.emittedLine) { - return; - } - - if (prevEmittedLine !== mappedPosition.emittedLine) { - while (prevEmittedLine < mappedPosition.emittedLine) { - prevEmittedColumn = 0; - mappingsString = mappingsString + ";"; - prevEmittedLine++; - } - emitComma = false; - } else if (emitComma) { - mappingsString = mappingsString + ","; - } - - mappingsString = mappingsString + TypeScript.Base64VLQFormat.encode(mappedPosition.emittedColumn - prevEmittedColumn); - prevEmittedColumn = mappedPosition.emittedColumn; - - mappingsString = mappingsString + TypeScript.Base64VLQFormat.encode(currentSourceIndex - prevSourceIndex); - prevSourceIndex = currentSourceIndex; - - mappingsString = mappingsString + TypeScript.Base64VLQFormat.encode(mappedPosition.sourceLine - 1 - prevSourceLine); - prevSourceLine = mappedPosition.sourceLine - 1; - - mappingsString = mappingsString + TypeScript.Base64VLQFormat.encode(mappedPosition.sourceColumn - prevSourceColumn); - prevSourceColumn = mappedPosition.sourceColumn; - - if (nameIndex >= 0) { - mappingsString = mappingsString + TypeScript.Base64VLQFormat.encode(namesCount + nameIndex - prevNameIndex); - prevNameIndex = namesCount + nameIndex; - } - - emitComma = true; - recordedPosition = mappedPosition; - }; - - var recordSourceMappingSiblings = function (sourceMappings) { - 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(sourceMapper.sourceMappings); - namesCount = namesCount + sourceMapper.names.length; - } - - sourceMapOut.Write(JSON.stringify({ - version: 3, - file: sourceMapper.jsFileName, - sources: tsFiles, - names: namesList, - mappings: mappingsString - })); - - sourceMapOut.Close(); - }; - SourceMapper.MapFileExtension = ".map"; - return SourceMapper; - })(); - TypeScript.SourceMapper = SourceMapper; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (EmitContainer) { - EmitContainer[EmitContainer["Prog"] = 0] = "Prog"; - EmitContainer[EmitContainer["Module"] = 1] = "Module"; - EmitContainer[EmitContainer["DynamicModule"] = 2] = "DynamicModule"; - EmitContainer[EmitContainer["Class"] = 3] = "Class"; - EmitContainer[EmitContainer["Constructor"] = 4] = "Constructor"; - EmitContainer[EmitContainer["Function"] = 5] = "Function"; - EmitContainer[EmitContainer["Args"] = 6] = "Args"; - EmitContainer[EmitContainer["Interface"] = 7] = "Interface"; - })(TypeScript.EmitContainer || (TypeScript.EmitContainer = {})); - var EmitContainer = TypeScript.EmitContainer; - - var EmitState = (function () { - function EmitState() { - this.column = 0; - this.line = 0; - this.container = 0 /* Prog */; - } - return EmitState; - })(); - TypeScript.EmitState = EmitState; - - var EmitOptions = (function () { - function EmitOptions(compilationSettings) { - this.compilationSettings = compilationSettings; - this.ioHost = null; - this.outputMany = true; - this.commonDirectoryPath = ""; - } - EmitOptions.prototype.mapOutputFileName = function (fileName, extensionChanger) { - if (this.outputMany) { - var updatedFileName = fileName; - if (this.compilationSettings.outputOption !== "") { - updatedFileName = fileName.replace(this.commonDirectoryPath, ""); - updatedFileName = this.compilationSettings.outputOption + updatedFileName; - } - return extensionChanger(updatedFileName, false); - } else { - return extensionChanger(this.compilationSettings.outputOption, true); - } - }; - return EmitOptions; - })(); - TypeScript.EmitOptions = EmitOptions; - - var Indenter = (function () { - function Indenter() { - this.indentAmt = 0; - } - Indenter.prototype.increaseIndent = function () { - this.indentAmt += Indenter.indentStep; - }; - - Indenter.prototype.decreaseIndent = function () { - this.indentAmt -= Indenter.indentStep; - }; - - Indenter.prototype.getIndent = function () { - var indentString = Indenter.indentStrings[this.indentAmt]; - if (indentString === undefined) { - indentString = ""; - for (var i = 0; i < this.indentAmt; i = i + Indenter.indentStep) { - indentString += Indenter.indentStepString; - } - Indenter.indentStrings[this.indentAmt] = indentString; - } - return indentString; - }; - Indenter.indentStep = 4; - Indenter.indentStepString = " "; - Indenter.indentStrings = []; - return Indenter; - })(); - TypeScript.Indenter = Indenter; - - var Emitter = (function () { - function Emitter(emittingFileName, outfile, emitOptions, semanticInfoChain) { - this.emittingFileName = emittingFileName; - this.outfile = outfile; - this.emitOptions = emitOptions; - this.semanticInfoChain = semanticInfoChain; - this.globalThisCapturePrologueEmitted = false; - this.extendsPrologueEmitted = false; - this.thisClassNode = null; - this.thisFunctionDeclaration = null; - this.moduleName = ""; - this.emitState = new EmitState(); - this.indenter = new Indenter(); - this.modAliasId = null; - this.firstModAlias = null; - this.allSourceMappers = []; - this.sourceMapper = null; - this.captureThisStmtString = "var _this = this;"; - this.varListCountStack = [0]; - this.pullTypeChecker = null; - this.declStack = []; - this.resolvingContext = new TypeScript.PullTypeResolutionContext(); - this.exportAssignmentIdentifier = null; - this.document = null; - TypeScript.globalSemanticInfoChain = semanticInfoChain; - TypeScript.globalBinder.semanticInfoChain = semanticInfoChain; - this.pullTypeChecker = new TypeScript.PullTypeChecker(emitOptions.compilationSettings, semanticInfoChain); - } - Emitter.prototype.pushDecl = function (decl) { - if (decl) { - this.declStack[this.declStack.length] = decl; - } - }; - - Emitter.prototype.popDecl = function (decl) { - if (decl) { - this.declStack.length--; - } - }; - - Emitter.prototype.getEnclosingDecl = function () { - var declStackLen = this.declStack.length; - var enclosingDecl = declStackLen > 0 ? this.declStack[declStackLen - 1] : null; - return enclosingDecl; - }; - - Emitter.prototype.setTypeCheckerUnit = function (fileName) { - if (!this.pullTypeChecker.resolver) { - this.pullTypeChecker.setUnit(fileName); - return; - } - - this.pullTypeChecker.resolver.setUnitPath(fileName); - }; - - Emitter.prototype.setExportAssignmentIdentifier = function (id) { - this.exportAssignmentIdentifier = id; - }; - - Emitter.prototype.getExportAssignmentIdentifier = function () { - return this.exportAssignmentIdentifier; - }; - - Emitter.prototype.setDocument = function (document) { - this.document = document; - }; - - Emitter.prototype.importStatementShouldBeEmitted = function (importDeclAST, unitPath) { - if (!importDeclAST.isDynamicImport) { - return true; - } - - var importDecl = this.semanticInfoChain.getDeclForAST(importDeclAST, this.document.fileName); - var pullSymbol = importDecl.getSymbol(); - return pullSymbol.getIsUsedAsValue(); - }; - - Emitter.prototype.setSourceMappings = function (mapper) { - this.allSourceMappers.push(mapper); - this.sourceMapper = mapper; - }; - - Emitter.prototype.writeToOutput = function (s) { - this.outfile.Write(s); - - this.emitState.column += s.length; - }; - - Emitter.prototype.writeToOutputTrimmable = function (s) { - if (this.emitOptions.compilationSettings.minWhitespace) { - s = s.replace(/[\s]*/g, ''); - } - this.writeToOutput(s); - }; - - Emitter.prototype.writeLineToOutput = function (s) { - if (this.emitOptions.compilationSettings.minWhitespace) { - this.writeToOutput(s); - var c = s.charCodeAt(s.length - 1); - if (!((c === 32 /* space */) || (c === 59 /* semicolon */) || (c === 91 /* openBracket */))) { - this.writeToOutput(' '); - } - } else { - this.outfile.WriteLine(s); - this.emitState.column = 0; - this.emitState.line++; - } - }; - - Emitter.prototype.writeCaptureThisStatement = function (ast) { - this.emitIndent(); - this.recordSourceMappingStart(ast); - this.writeToOutput(this.captureThisStmtString); - this.recordSourceMappingEnd(ast); - this.writeLineToOutput(""); - }; - - Emitter.prototype.setInVarBlock = function (count) { - this.varListCountStack[this.varListCountStack.length - 1] = count; - }; - - Emitter.prototype.setContainer = function (c) { - var temp = this.emitState.container; - this.emitState.container = c; - return temp; - }; - - Emitter.prototype.getIndentString = function () { - if (this.emitOptions.compilationSettings.minWhitespace) { - return ""; - } else { - return this.indenter.getIndent(); - } - }; - - Emitter.prototype.emitIndent = function () { - this.writeToOutput(this.getIndentString()); - }; - - Emitter.prototype.emitCommentInPlace = function (comment) { - var text = comment.getText(); - var hadNewLine = false; - - if (comment.isBlockComment) { - if (this.emitState.column === 0) { - this.emitIndent(); - } - this.recordSourceMappingStart(comment); - this.writeToOutput(text[0]); - - if (text.length > 1 || comment.endsLine) { - for (var i = 1; i < text.length; i++) { - this.writeLineToOutput(""); - this.emitIndent(); - this.writeToOutput(text[i]); - } - this.recordSourceMappingEnd(comment); - this.writeLineToOutput(""); - hadNewLine = true; - } else { - this.recordSourceMappingEnd(comment); - } - } else { - if (this.emitState.column === 0) { - this.emitIndent(); - } - this.recordSourceMappingStart(comment); - this.writeToOutput(text[0]); - this.recordSourceMappingEnd(comment); - this.writeLineToOutput(""); - hadNewLine = true; - } - - if (hadNewLine) { - this.emitIndent(); - } else { - this.writeToOutput(" "); - } - }; - - Emitter.prototype.emitComments = function (ast, pre) { - var comments = pre ? ast.preComments : ast.postComments; - - if (this.emitOptions.compilationSettings.emitComments && comments && comments.length !== 0) { - for (var i = 0; i < comments.length; i++) { - this.emitCommentInPlace(comments[i]); - } - } - }; - - Emitter.prototype.emitObjectLiteral = function (objectLiteral) { - var useNewLines = !TypeScript.hasFlag(objectLiteral.getFlags(), 2 /* SingleLine */); - - this.writeToOutput("{"); - var list = objectLiteral.operand; - if (list.members.length > 0) { - if (useNewLines) { - this.writeLineToOutput(""); - } else { - this.writeToOutput(" "); - } - - this.indenter.increaseIndent(); - this.emitCommaSeparatedList(list, useNewLines); - this.indenter.decreaseIndent(); - if (useNewLines) { - this.emitIndent(); - } else { - this.writeToOutput(" "); - } - } - this.writeToOutput("}"); - }; - - Emitter.prototype.emitArrayLiteral = function (arrayLiteral) { - var useNewLines = !TypeScript.hasFlag(arrayLiteral.getFlags(), 2 /* SingleLine */); - - this.writeToOutput("["); - var list = arrayLiteral.operand; - if (list.members.length > 0) { - if (useNewLines) { - this.writeLineToOutput(""); - } - - this.indenter.increaseIndent(); - this.emitCommaSeparatedList(list, useNewLines); - this.indenter.decreaseIndent(); - if (useNewLines) { - this.emitIndent(); - } - } - this.writeToOutput("]"); - }; - - Emitter.prototype.emitNew = function (target, args) { - this.writeToOutput("new "); - if (target.nodeType === 11 /* TypeRef */) { - var typeRef = target; - if (typeRef.arrayCount) { - this.writeToOutput("Array()"); - } else { - typeRef.term.emit(this); - this.writeToOutput("()"); - } - } else { - target.emit(this); - this.recordSourceMappingStart(args); - this.writeToOutput("("); - this.emitCommaSeparatedList(args); - this.writeToOutput(")"); - this.recordSourceMappingEnd(args); - } - }; - - Emitter.prototype.getVarDeclFromIdentifier = function (boundDeclInfo) { - TypeScript.CompilerDiagnostics.assert(boundDeclInfo.boundDecl && boundDeclInfo.boundDecl.init && boundDeclInfo.boundDecl.init.nodeType === 20 /* Name */, "The init expression of bound declaration when emitting as constant has to be indentifier"); - - var init = boundDeclInfo.boundDecl.init; - var ident = init; - - this.setTypeCheckerUnit(this.document.fileName); - var pullSymbol = this.resolvingContext.resolvingTypeReference ? this.pullTypeChecker.resolver.resolveTypeNameExpression(ident, boundDeclInfo.pullDecl.getParentDecl(), this.resolvingContext).symbol : this.pullTypeChecker.resolver.resolveNameExpression(ident, boundDeclInfo.pullDecl.getParentDecl(), this.resolvingContext).symbol; - if (pullSymbol) { - var pullDecls = pullSymbol.getDeclarations(); - if (pullDecls.length === 1) { - var pullDecl = pullDecls[0]; - var ast = this.semanticInfoChain.getASTForDecl(pullDecl); - if (ast && ast.nodeType === 17 /* VariableDeclarator */) { - return { boundDecl: ast, pullDecl: pullDecl }; - } - } - } - - return null; - }; - - Emitter.prototype.getConstantValue = function (boundDeclInfo) { - var init = boundDeclInfo.boundDecl.init; - if (init) { - if (init.nodeType === 7 /* NumericLiteral */) { - var numLit = init; - return numLit.value; - } else if (init.nodeType === 69 /* LeftShiftExpression */) { - var binop = init; - if (binop.operand1.nodeType === 7 /* NumericLiteral */ && binop.operand2.nodeType === 7 /* NumericLiteral */) { - return (binop.operand1).value << (binop.operand2).value; - } - } else if (init.nodeType === 20 /* Name */) { - var varDeclInfo = this.getVarDeclFromIdentifier(boundDeclInfo); - if (varDeclInfo) { - return this.getConstantValue(varDeclInfo); - } - } - } - - return null; - }; - - Emitter.prototype.getConstantDecl = function (dotExpr) { - this.setTypeCheckerUnit(this.document.fileName); - var pullSymbol = this.pullTypeChecker.resolver.resolveDottedNameExpression(dotExpr, this.getEnclosingDecl(), this.resolvingContext).symbol; - if (pullSymbol && pullSymbol.hasFlag(524288 /* Constant */)) { - var pullDecls = pullSymbol.getDeclarations(); - if (pullDecls.length === 1) { - var pullDecl = pullDecls[0]; - var ast = this.semanticInfoChain.getASTForDecl(pullDecl); - if (ast && ast.nodeType === 17 /* VariableDeclarator */) { - return { boundDecl: ast, pullDecl: pullDecl }; - } - } - } - - return null; - }; - - Emitter.prototype.tryEmitConstant = function (dotExpr) { - if (!this.emitOptions.compilationSettings.propagateConstants) { - return false; - } - var propertyName = dotExpr.operand2; - var boundDeclInfo = this.getConstantDecl(dotExpr); - if (boundDeclInfo) { - var value = this.getConstantValue(boundDeclInfo); - if (value !== null) { - this.writeToOutput(value.toString()); - var comment = " /* "; - comment += propertyName.actualText; - comment += " */"; - this.writeToOutput(comment); - return true; - } - } - - return false; - }; - - Emitter.prototype.emitCall = function (callNode, target, args) { - if (!this.emitSuperCall(callNode)) { - if (target.nodeType === 12 /* FunctionDeclaration */) { - this.writeToOutput("("); - } - if (callNode.target.nodeType === 30 /* SuperExpression */ && this.emitState.container === 4 /* Constructor */) { - this.writeToOutput("_super.call"); - } else { - this.emitJavascript(target, false); - } - if (target.nodeType === 12 /* FunctionDeclaration */) { - this.writeToOutput(")"); - } - this.recordSourceMappingStart(args); - this.writeToOutput("("); - if (callNode.target.nodeType === 30 /* SuperExpression */ && this.emitState.container === 4 /* Constructor */) { - this.writeToOutput("this"); - if (args && args.members.length) { - this.writeToOutput(", "); - } - } - this.emitCommaSeparatedList(args); - this.writeToOutput(")"); - this.recordSourceMappingEnd(args); - } - }; - - Emitter.prototype.emitInnerFunction = function (funcDecl, printName, includePreComments) { - if (typeof includePreComments === "undefined") { includePreComments = true; } - var pullDecl = this.semanticInfoChain.getDeclForAST(funcDecl, this.document.fileName); - this.pushDecl(pullDecl); - - var shouldParenthesize = false; - - if (includePreComments) { - this.emitComments(funcDecl, true); - } - - if (shouldParenthesize) { - this.writeToOutput("("); - } - this.recordSourceMappingStart(funcDecl); - var accessorSymbol = funcDecl.isAccessor() ? TypeScript.PullHelpers.getAccessorSymbol(funcDecl, this.semanticInfoChain, this.document.fileName) : null; - var container = accessorSymbol ? accessorSymbol.getContainer() : null; - var containerKind = container ? container.getKind() : 0 /* None */; - if (!(funcDecl.isAccessor() && containerKind !== 8 /* Class */ && containerKind !== 33554432 /* ConstructorType */)) { - this.writeToOutput("function "); - } - - if (funcDecl.isConstructor) { - this.writeToOutput(this.thisClassNode.name.actualText); - } - - if (printName) { - var id = funcDecl.getNameText(); - if (id && !funcDecl.isAccessor()) { - if (funcDecl.name) { - this.recordSourceMappingStart(funcDecl.name); - } - this.writeToOutput(id); - if (funcDecl.name) { - this.recordSourceMappingEnd(funcDecl.name); - } - } - } - - this.writeToOutput("("); - var argsLen = 0; - if (funcDecl.arguments) { - this.emitComments(funcDecl.arguments, true); - - var tempContainer = this.setContainer(6 /* Args */); - argsLen = funcDecl.arguments.members.length; - var printLen = argsLen; - if (funcDecl.variableArgList) { - printLen--; - } - for (var i = 0; i < printLen; i++) { - var arg = funcDecl.arguments.members[i]; - arg.emit(this); - - if (i < (printLen - 1)) { - this.writeToOutput(", "); - } - } - this.setContainer(tempContainer); - - this.emitComments(funcDecl.arguments, false); - } - this.writeLineToOutput(") {"); - - if (funcDecl.isConstructor) { - this.recordSourceMappingNameStart("constructor"); - } else if (funcDecl.isGetAccessor()) { - this.recordSourceMappingNameStart("get_" + funcDecl.getNameText()); - } else if (funcDecl.isSetAccessor()) { - this.recordSourceMappingNameStart("set_" + funcDecl.getNameText()); - } else { - this.recordSourceMappingNameStart(funcDecl.getNameText()); - } - this.indenter.increaseIndent(); - - this.emitDefaultValueAssignments(funcDecl); - this.emitRestParameterInitializer(funcDecl); - - if (this.shouldCaptureThis(funcDecl)) { - this.writeCaptureThisStatement(funcDecl); - } - - if (funcDecl.isConstructor) { - this.emitConstructorStatements(funcDecl); - } else { - this.emitModuleElements(funcDecl.block.statements); - } - - this.indenter.decreaseIndent(); - this.emitIndent(); - this.recordSourceMappingStart(funcDecl.block.closeBraceSpan); - this.writeToOutput("}"); - - this.recordSourceMappingNameEnd(); - this.recordSourceMappingEnd(funcDecl.block.closeBraceSpan); - this.recordSourceMappingEnd(funcDecl); - - if (shouldParenthesize) { - this.writeToOutput(")"); - } - - this.recordSourceMappingEnd(funcDecl); - - this.emitComments(funcDecl, false); - - this.popDecl(pullDecl); - }; - - Emitter.prototype.emitDefaultValueAssignments = function (funcDecl) { - var n = funcDecl.arguments.members.length; - if (funcDecl.variableArgList) { - n--; - } - - for (var i = 0; i < n; i++) { - var arg = funcDecl.arguments.members[i]; - if (arg.init) { - this.emitIndent(); - this.recordSourceMappingStart(arg); - this.writeToOutput("if (typeof " + arg.id.actualText + " === \"undefined\") { "); - this.recordSourceMappingStart(arg.id); - this.writeToOutput(arg.id.actualText); - this.recordSourceMappingEnd(arg.id); - this.writeToOutput(" = "); - this.emitJavascript(arg.init, false); - this.writeLineToOutput("; }"); - this.recordSourceMappingEnd(arg); - } - } - }; - - Emitter.prototype.emitRestParameterInitializer = function (funcDecl) { - if (funcDecl.variableArgList) { - var n = funcDecl.arguments.members.length; - var lastArg = funcDecl.arguments.members[n - 1]; - this.emitIndent(); - this.recordSourceMappingStart(lastArg); - this.writeToOutput("var "); - this.recordSourceMappingStart(lastArg.id); - this.writeToOutput(lastArg.id.actualText); - this.recordSourceMappingEnd(lastArg.id); - this.writeLineToOutput(" = [];"); - this.recordSourceMappingEnd(lastArg); - this.emitIndent(); - this.writeToOutput("for ("); - this.recordSourceMappingStart(lastArg); - this.writeToOutput("var _i = 0;"); - this.recordSourceMappingEnd(lastArg); - this.writeToOutput(" "); - this.recordSourceMappingStart(lastArg); - this.writeToOutput("_i < (arguments.length - " + (n - 1) + ")"); - this.recordSourceMappingEnd(lastArg); - this.writeToOutput("; "); - this.recordSourceMappingStart(lastArg); - this.writeToOutput("_i++"); - this.recordSourceMappingEnd(lastArg); - this.writeLineToOutput(") {"); - this.indenter.increaseIndent(); - this.emitIndent(); - - this.recordSourceMappingStart(lastArg); - this.writeToOutput(lastArg.id.actualText + "[_i] = arguments[_i + " + (n - 1) + "];"); - this.recordSourceMappingEnd(lastArg); - this.writeLineToOutput(""); - this.indenter.decreaseIndent(); - this.emitIndent(); - this.writeLineToOutput("}"); - } - }; - - Emitter.prototype.getImportDecls = function (fileName) { - var semanticInfo = this.semanticInfoChain.getUnit(this.document.fileName); - var result = []; - - var queue = semanticInfo.getTopLevelDecls(); - - while (queue.length > 0) { - var decl = queue.shift(); - - if (decl.getKind() & 256 /* TypeAlias */) { - var importStatementAST = semanticInfo.getASTForDecl(decl); - if (importStatementAST.alias.nodeType === 20 /* Name */) { - var text = (importStatementAST.alias).actualText; - if (TypeScript.isQuoted(text)) { - var symbol = decl.getSymbol(); - var typeSymbol = symbol && symbol.getType(); - if (typeSymbol && typeSymbol !== this.semanticInfoChain.anyTypeSymbol && !typeSymbol.isError()) { - result.push(decl); - } - } - } - } - - queue = queue.concat(decl.getChildDecls()); - } - - return result; - }; - - Emitter.prototype.getModuleImportAndDependencyList = function (moduleDecl) { - var importList = ""; - var dependencyList = ""; - - var semanticInfo = this.semanticInfoChain.getUnit(this.document.fileName); - var importDecls = this.getImportDecls(this.document.fileName); - - if (importDecls.length) { - for (var i = 0; i < importDecls.length; i++) { - var importStatementDecl = importDecls[i]; - var importStatementSymbol = importStatementDecl.getSymbol(); - var importStatementAST = semanticInfo.getASTForDecl(importStatementDecl); - - if (importStatementSymbol.getIsUsedAsValue()) { - if (i <= importDecls.length - 1) { - dependencyList += ", "; - importList += ", "; - } - - importList += "__" + importStatementDecl.getName() + "__"; - dependencyList += importStatementAST.firstAliasedModToString(); - } - } - } - - for (var i = 0; i < moduleDecl.amdDependencies.length; i++) { - dependencyList += ", \"" + moduleDecl.amdDependencies[i] + "\""; - } - - return { - importList: importList, - dependencyList: dependencyList - }; - }; - - Emitter.prototype.shouldCaptureThis = function (ast) { - if (ast.nodeType === 2 /* Script */) { - var scriptDecl = this.semanticInfoChain.getUnit(this.document.fileName).getTopLevelDecls()[0]; - return (scriptDecl.getFlags() & 262144 /* MustCaptureThis */) === 262144 /* MustCaptureThis */; - } - - var decl = this.semanticInfoChain.getDeclForAST(ast, this.document.fileName); - if (decl) { - return (decl.getFlags() & 262144 /* MustCaptureThis */) === 262144 /* MustCaptureThis */; - } - - return false; - }; - - Emitter.prototype.emitModule = function (moduleDecl) { - var pullDecl = this.semanticInfoChain.getDeclForAST(moduleDecl, this.document.fileName); - this.pushDecl(pullDecl); - - var modName = moduleDecl.name.actualText; - if (TypeScript.isTSFile(modName)) { - moduleDecl.name.setText(modName.substring(0, modName.length - 3)); - } - - var isDynamicMod = TypeScript.hasFlag(moduleDecl.getModuleFlags(), 512 /* IsDynamic */); - var prevOutFile = this.outfile; - var prevOutFileName = this.emittingFileName; - var prevAllSourceMappers = this.allSourceMappers; - var prevSourceMapper = this.sourceMapper; - var prevColumn = this.emitState.column; - var prevLine = this.emitState.line; - var temp = this.setContainer(1 /* Module */); - var svModuleName = this.moduleName; - var isExported = TypeScript.hasFlag(moduleDecl.getModuleFlags(), 1 /* Exported */); - var isWholeFile = TypeScript.hasFlag(moduleDecl.getModuleFlags(), 256 /* IsWholeFile */); - this.moduleName = moduleDecl.name.actualText; - - if (isDynamicMod) { - this.setExportAssignmentIdentifier(null); - this.setContainer(2 /* DynamicModule */); - - this.recordSourceMappingStart(moduleDecl); - if (this.emitOptions.compilationSettings.moduleGenTarget === 1 /* Asynchronous */) { - var dependencyList = "[\"require\", \"exports\""; - var importList = "require, exports"; - - var importAndDependencyList = this.getModuleImportAndDependencyList(moduleDecl); - importList += importAndDependencyList.importList; - dependencyList += importAndDependencyList.dependencyList + "]"; - - this.writeLineToOutput("define(" + dependencyList + "," + " function(" + importList + ") {"); - } - } else { - if (!isExported) { - this.recordSourceMappingStart(moduleDecl); - this.writeToOutput("var "); - this.recordSourceMappingStart(moduleDecl.name); - this.writeToOutput(this.moduleName); - this.recordSourceMappingEnd(moduleDecl.name); - this.writeLineToOutput(";"); - this.recordSourceMappingEnd(moduleDecl); - this.emitIndent(); - } - - this.writeToOutput("("); - this.recordSourceMappingStart(moduleDecl); - this.writeToOutput("function ("); - this.recordSourceMappingStart(moduleDecl.name); - this.writeToOutput(this.moduleName); - this.recordSourceMappingEnd(moduleDecl.name); - this.writeLineToOutput(") {"); - } - - if (!isWholeFile) { - this.recordSourceMappingNameStart(this.moduleName); - } - - if (!isDynamicMod || this.emitOptions.compilationSettings.moduleGenTarget === 1 /* Asynchronous */) { - this.indenter.increaseIndent(); - } - - if (this.shouldCaptureThis(moduleDecl)) { - this.writeCaptureThisStatement(moduleDecl); - } - - this.emitModuleElements(moduleDecl.members); - if (!isDynamicMod || this.emitOptions.compilationSettings.moduleGenTarget === 1 /* Asynchronous */) { - this.indenter.decreaseIndent(); - } - this.emitIndent(); - - if (isDynamicMod) { - var exportAssignmentIdentifier = this.getExportAssignmentIdentifier(); - var exportAssignmentValueSymbol = (pullDecl.getSymbol()).getExportAssignedValueSymbol(); - - if (this.emitOptions.compilationSettings.moduleGenTarget === 1 /* Asynchronous */) { - if (exportAssignmentIdentifier && exportAssignmentValueSymbol && !(exportAssignmentValueSymbol.getKind() & TypeScript.PullElementKind.SomeTypeReference)) { - this.indenter.increaseIndent(); - this.emitIndent(); - this.writeLineToOutput("return " + exportAssignmentIdentifier + ";"); - this.indenter.decreaseIndent(); - } - this.writeToOutput("});"); - } else if (exportAssignmentIdentifier && exportAssignmentValueSymbol && !(exportAssignmentValueSymbol.getKind() & TypeScript.PullElementKind.SomeTypeReference)) { - this.emitIndent(); - this.writeLineToOutput("module.exports = " + exportAssignmentIdentifier + ";"); - } - - if (!isWholeFile) { - this.recordSourceMappingNameEnd(); - } - this.recordSourceMappingEnd(moduleDecl); - - if (this.outfile !== prevOutFile) { - this.emitSourceMapsAndClose(); - if (prevSourceMapper !== null) { - this.allSourceMappers = prevAllSourceMappers; - this.sourceMapper = prevSourceMapper; - this.emitState.column = prevColumn; - this.emitState.line = prevLine; - } - this.outfile = prevOutFile; - this.emittingFileName = prevOutFileName; - } - } else { - var parentIsDynamic = temp === 2 /* DynamicModule */; - this.recordSourceMappingStart(moduleDecl.endingToken); - if (temp === 0 /* Prog */ && isExported) { - this.writeToOutput("}"); - if (!isWholeFile) { - this.recordSourceMappingNameEnd(); - } - this.recordSourceMappingEnd(moduleDecl.endingToken); - this.writeToOutput(")(this." + this.moduleName + " || (this." + this.moduleName + " = {}));"); - } else if (isExported || temp === 0 /* Prog */) { - var dotMod = svModuleName !== "" ? (parentIsDynamic ? "exports" : svModuleName) + "." : svModuleName; - this.writeToOutput("}"); - if (!isWholeFile) { - this.recordSourceMappingNameEnd(); - } - this.recordSourceMappingEnd(moduleDecl.endingToken); - this.writeToOutput(")(" + dotMod + this.moduleName + " || (" + dotMod + this.moduleName + " = {}));"); - } else if (!isExported && temp !== 0 /* Prog */) { - this.writeToOutput("}"); - if (!isWholeFile) { - this.recordSourceMappingNameEnd(); - } - this.recordSourceMappingEnd(moduleDecl.endingToken); - this.writeToOutput(")(" + this.moduleName + " || (" + this.moduleName + " = {}));"); - } else { - this.writeToOutput("}"); - if (!isWholeFile) { - this.recordSourceMappingNameEnd(); - } - this.recordSourceMappingEnd(moduleDecl.endingToken); - this.writeToOutput(")();"); - } - - this.recordSourceMappingEnd(moduleDecl); - if (temp !== 0 /* Prog */ && isExported) { - this.recordSourceMappingStart(moduleDecl); - if (parentIsDynamic) { - this.writeLineToOutput(""); - this.emitIndent(); - this.writeToOutput("var " + this.moduleName + " = exports." + this.moduleName + ";"); - } else { - this.writeLineToOutput(""); - this.emitIndent(); - this.writeToOutput("var " + this.moduleName + " = " + svModuleName + "." + this.moduleName + ";"); - } - this.recordSourceMappingEnd(moduleDecl); - } - } - - this.setContainer(temp); - this.moduleName = svModuleName; - - this.popDecl(pullDecl); - }; - - Emitter.prototype.emitEnumElement = function (varDecl) { - this.writeToOutput(this.moduleName); - this.writeToOutput('['); - this.writeToOutput(this.moduleName); - this.writeToOutput('["'); - this.writeToOutput(varDecl.id.text); - this.writeToOutput('"] = '); - varDecl.init.emit(this); - this.writeToOutput('] = "'); - this.writeToOutput(varDecl.id.text); - this.writeToOutput('";'); - }; - - Emitter.prototype.emitIndex = function (operand1, operand2) { - operand1.emit(this); - this.writeToOutput("["); - operand2.emit(this); - this.writeToOutput("]"); - }; - - Emitter.prototype.emitFunction = function (funcDecl) { - if (TypeScript.hasFlag(funcDecl.getFunctionFlags(), 128 /* Signature */)) { - return; - } - var temp; - var tempFnc = this.thisFunctionDeclaration; - this.thisFunctionDeclaration = funcDecl; - - if (funcDecl.isConstructor) { - temp = this.setContainer(4 /* Constructor */); - } else { - temp = this.setContainer(5 /* Function */); - } - - var funcName = funcDecl.getNameText(); - - if (((temp !== 4 /* Constructor */) || ((funcDecl.getFunctionFlags() & 256 /* Method */) === 0 /* None */))) { - this.recordSourceMappingStart(funcDecl); - this.emitInnerFunction(funcDecl, (funcDecl.name && !funcDecl.name.isMissing())); - } - this.setContainer(temp); - this.thisFunctionDeclaration = tempFnc; - - if (!TypeScript.hasFlag(funcDecl.getFunctionFlags(), 128 /* Signature */)) { - if (TypeScript.hasFlag(funcDecl.getFunctionFlags(), 16 /* Static */)) { - if (this.thisClassNode) { - this.writeLineToOutput(""); - if (funcDecl.isAccessor()) { - this.emitPropertyAccessor(funcDecl, this.thisClassNode.name.actualText, false); - } else { - this.emitIndent(); - this.recordSourceMappingStart(funcDecl); - this.writeToOutput(this.thisClassNode.name.actualText + "." + funcName + " = " + funcName + ";"); - this.recordSourceMappingEnd(funcDecl); - } - } - } else if ((this.emitState.container === 1 /* Module */ || this.emitState.container === 2 /* DynamicModule */) && TypeScript.hasFlag(funcDecl.getFunctionFlags(), 1 /* Exported */)) { - this.writeLineToOutput(""); - this.emitIndent(); - var modName = this.emitState.container === 1 /* Module */ ? this.moduleName : "exports"; - this.recordSourceMappingStart(funcDecl); - this.writeToOutput(modName + "." + funcName + " = " + funcName + ";"); - this.recordSourceMappingEnd(funcDecl); - } - } - }; - - Emitter.prototype.emitAmbientVarDecl = function (varDecl) { - if (varDecl.init) { - this.emitComments(varDecl, true); - this.recordSourceMappingStart(varDecl); - this.recordSourceMappingStart(varDecl.id); - this.writeToOutput(varDecl.id.actualText); - this.recordSourceMappingEnd(varDecl.id); - this.writeToOutput(" = "); - this.emitJavascript(varDecl.init, false); - this.recordSourceMappingEnd(varDecl); - this.emitComments(varDecl, false); - } - }; - - Emitter.prototype.varListCount = function () { - return this.varListCountStack[this.varListCountStack.length - 1]; - }; - - Emitter.prototype.emitVarDeclVar = function () { - if (this.varListCount() >= 0) { - this.writeToOutput("var "); - this.setInVarBlock(-this.varListCount()); - } - return true; - }; - - Emitter.prototype.onEmitVar = function () { - if (this.varListCount() > 0) { - this.setInVarBlock(this.varListCount() - 1); - } else if (this.varListCount() < 0) { - this.setInVarBlock(this.varListCount() + 1); - } - }; - - Emitter.prototype.emitVariableDeclaration = function (declaration) { - var varDecl = declaration.declarators.members[0]; - - var symbolAndDiagnostics = this.semanticInfoChain.getSymbolAndDiagnosticsForAST(varDecl, this.document.fileName); - var symbol = symbolAndDiagnostics && symbolAndDiagnostics.symbol; - - var parentSymbol = symbol ? symbol.getContainer() : null; - var parentKind = parentSymbol ? parentSymbol.getKind() : 0 /* None */; - var inClass = parentKind === 8 /* Class */; - - this.emitComments(declaration, true); - this.recordSourceMappingStart(declaration); - this.setInVarBlock(declaration.declarators.members.length); - - var isAmbientWithoutInit = TypeScript.hasFlag(varDecl.getVarFlags(), 8 /* Ambient */) && varDecl.init === null; - if (!isAmbientWithoutInit) { - for (var i = 0, n = declaration.declarators.members.length; i < n; i++) { - var declarator = declaration.declarators.members[i]; - - if (i > 0) { - if (inClass) { - this.writeToOutputTrimmable(";"); - } else { - this.writeToOutputTrimmable(", "); - } - } - - declarator.emit(this); - } - } - - this.recordSourceMappingEnd(declaration); - this.emitComments(declaration, false); - }; - - Emitter.prototype.emitVariableDeclarator = function (varDecl) { - var pullDecl = this.semanticInfoChain.getDeclForAST(varDecl, this.document.fileName); - this.pushDecl(pullDecl); - if ((varDecl.getVarFlags() & 8 /* Ambient */) === 8 /* Ambient */) { - this.emitAmbientVarDecl(varDecl); - this.onEmitVar(); - } else { - this.emitComments(varDecl, true); - this.recordSourceMappingStart(varDecl); - - var symbolAndDiagnostics = this.semanticInfoChain.getSymbolAndDiagnosticsForAST(varDecl, this.document.fileName); - var symbol = symbolAndDiagnostics && symbolAndDiagnostics.symbol; - var parentSymbol = symbol ? symbol.getContainer() : null; - var parentKind = parentSymbol ? parentSymbol.getKind() : 0 /* None */; - var associatedParentSymbol = parentSymbol ? parentSymbol.getAssociatedContainerType() : null; - var associatedParentSymbolKind = associatedParentSymbol ? associatedParentSymbol.getKind() : 0 /* None */; - if (parentKind === 8 /* Class */) { - if (this.emitState.container !== 6 /* Args */) { - if (varDecl.isStatic()) { - this.writeToOutput(parentSymbol.getName() + "."); - } else { - this.writeToOutput("this."); - } - } - } else if (parentKind === 64 /* Enum */ || parentKind === 32 /* DynamicModule */ || associatedParentSymbolKind === 4 /* Container */ || associatedParentSymbolKind === 32 /* DynamicModule */ || associatedParentSymbolKind === 64 /* Enum */) { - if (!varDecl.isExported() && !varDecl.isProperty()) { - this.emitVarDeclVar(); - } else { - if (this.emitState.container === 2 /* DynamicModule */) { - this.writeToOutput("exports."); - } else { - this.writeToOutput(this.moduleName + "."); - } - } - } else { - this.emitVarDeclVar(); - } - - this.recordSourceMappingStart(varDecl.id); - this.writeToOutput(varDecl.id.actualText); - this.recordSourceMappingEnd(varDecl.id); - var hasInitializer = (varDecl.init !== null); - if (hasInitializer) { - this.writeToOutputTrimmable(" = "); - - this.varListCountStack.push(0); - varDecl.init.emit(this); - this.varListCountStack.pop(); - } - - if (parentKind === 8 /* Class */) { - if (this.emitState.container !== 6 /* Args */) { - this.writeToOutput(";"); - } - } - - this.onEmitVar(); - - this.recordSourceMappingEnd(varDecl); - this.emitComments(varDecl, false); - } - this.popDecl(pullDecl); - }; - - Emitter.prototype.symbolIsUsedInItsEnclosingContainer = function (symbol, dynamic) { - if (typeof dynamic === "undefined") { dynamic = false; } - var symDecls = symbol.getDeclarations(); - - if (symDecls.length) { - var enclosingDecl = this.getEnclosingDecl(); - if (enclosingDecl) { - var parentDecl = symDecls[0].getParentDecl(); - if (parentDecl) { - var symbolDeclarationEnclosingContainer = parentDecl; - var enclosingContainer = enclosingDecl; - - while (symbolDeclarationEnclosingContainer) { - if (symbolDeclarationEnclosingContainer.getKind() === (dynamic ? 32 /* DynamicModule */ : 4 /* Container */)) { - break; - } - symbolDeclarationEnclosingContainer = symbolDeclarationEnclosingContainer.getParentDecl(); - } - - if (symbolDeclarationEnclosingContainer) { - while (enclosingContainer) { - if (enclosingContainer.getKind() === (dynamic ? 32 /* DynamicModule */ : 4 /* Container */)) { - break; - } - - enclosingContainer = enclosingContainer.getParentDecl(); - } - } - - if (symbolDeclarationEnclosingContainer && enclosingContainer) { - var same = symbolDeclarationEnclosingContainer === enclosingContainer; - - if (!same && symbol.hasFlag(32768 /* InitializedModule */)) { - same = symbolDeclarationEnclosingContainer === enclosingContainer.getParentDecl(); - } - - return same; - } - } - } - } - - return false; - }; - - Emitter.prototype.emitName = function (name, addThis) { - this.emitComments(name, true); - this.recordSourceMappingStart(name); - if (!name.isMissing()) { - this.setTypeCheckerUnit(this.document.fileName); - var pullSymbolAndDiagnostics = this.resolvingContext.resolvingTypeReference ? this.pullTypeChecker.resolver.resolveTypeNameExpression(name, this.getEnclosingDecl(), this.resolvingContext) : this.pullTypeChecker.resolver.resolveNameExpression(name, this.getEnclosingDecl(), this.resolvingContext); - var pullSymbol = pullSymbolAndDiagnostics.symbol; - var pullSymbolAlias = pullSymbolAndDiagnostics.symbolAlias; - var pullSymbolKind = pullSymbol.getKind(); - var isLocalAlias = pullSymbolAlias && (pullSymbolAlias.getDeclarations()[0].getParentDecl() == this.getEnclosingDecl()); - if (addThis && (this.emitState.container !== 6 /* Args */) && pullSymbol) { - var pullSymbolContainer = pullSymbol.getContainer(); - - if (pullSymbolContainer) { - var pullSymbolContainerKind = pullSymbolContainer.getKind(); - - if (pullSymbolContainerKind === 8 /* Class */) { - if (pullSymbol.hasFlag(16 /* Static */)) { - this.writeToOutput(pullSymbolContainer.getName() + "."); - } else if (pullSymbolKind === 4096 /* Property */) { - this.emitThis(); - this.writeToOutput("."); - } - } else if (pullSymbolContainerKind === 4 /* Container */ || pullSymbolContainerKind === 64 /* Enum */ || pullSymbolContainer.hasFlag(32768 /* InitializedModule */ | 131072 /* InitializedEnum */)) { - if (pullSymbolKind === 4096 /* Property */ || pullSymbolKind === 67108864 /* EnumMember */) { - this.writeToOutput(pullSymbolContainer.getName() + "."); - } else if (pullSymbol.hasFlag(1 /* Exported */) && pullSymbolKind === 1024 /* Variable */ && !pullSymbol.hasFlag(32768 /* InitializedModule */ | 131072 /* InitializedEnum */)) { - this.writeToOutput(pullSymbolContainer.getName() + "."); - } else if (pullSymbol.hasFlag(1 /* Exported */) && !this.symbolIsUsedInItsEnclosingContainer(pullSymbol)) { - this.writeToOutput(pullSymbolContainer.getName() + "."); - } - } else if (pullSymbolContainerKind === 32 /* DynamicModule */ || pullSymbolContainer.hasFlag(65536 /* InitializedDynamicModule */)) { - if (pullSymbolKind === 4096 /* Property */) { - this.writeToOutput("exports."); - } else if (pullSymbol.hasFlag(1 /* Exported */) && !isLocalAlias && !pullSymbol.hasFlag(TypeScript.PullElementFlags.ImplicitVariable) && pullSymbol.getKind() !== 32768 /* ConstructorMethod */ && pullSymbol.getKind() !== 8 /* Class */ && pullSymbol.getKind() !== 64 /* Enum */) { - this.writeToOutput("exports."); - } - } else if (pullSymbolKind === 4096 /* Property */) { - if (pullSymbolContainer.getKind() === 8 /* Class */) { - this.emitThis(); - this.writeToOutput("."); - } - } else { - var pullDecls = pullSymbol.getDeclarations(); - var emitContainerName = true; - for (var i = 0; i < pullDecls.length; i++) { - if (pullDecls[i].getScriptName() === this.document.fileName) { - emitContainerName = false; - } - } - if (emitContainerName) { - this.writeToOutput(pullSymbolContainer.getName() + "."); - } - } - } - } - - if (pullSymbol && pullSymbolKind === 32 /* DynamicModule */) { - if (this.emitOptions.compilationSettings.moduleGenTarget === 1 /* Asynchronous */) { - this.writeToOutput("__" + this.modAliasId + "__"); - } else { - var moduleDecl = this.semanticInfoChain.getASTForSymbol(pullSymbol, this.document.fileName); - var modPath = name.actualText; - var isAmbient = pullSymbol.hasFlag(8 /* Ambient */); - modPath = isAmbient ? modPath : this.firstModAlias ? this.firstModAlias : TypeScript.quoteBaseName(modPath); - modPath = isAmbient ? modPath : (!TypeScript.isRelative(TypeScript.stripQuotes(modPath)) ? TypeScript.quoteStr("./" + TypeScript.stripQuotes(modPath)) : modPath); - this.writeToOutput("require(" + modPath + ")"); - } - } else { - this.writeToOutput(name.actualText); - } - } - - this.recordSourceMappingEnd(name); - this.emitComments(name, false); - }; - - Emitter.prototype.recordSourceMappingNameStart = function (name) { - if (this.sourceMapper) { - var finalName = name; - if (!name) { - finalName = ""; - } else if (this.sourceMapper.currentNameIndex.length > 0) { - finalName = this.sourceMapper.names[this.sourceMapper.currentNameIndex[this.sourceMapper.currentNameIndex.length - 1]] + "." + name; - } - - this.sourceMapper.names.push(finalName); - this.sourceMapper.currentNameIndex.push(this.sourceMapper.names.length - 1); - } - }; - - Emitter.prototype.recordSourceMappingNameEnd = function () { - if (this.sourceMapper) { - this.sourceMapper.currentNameIndex.pop(); - } - }; - - Emitter.prototype.recordSourceMappingStart = function (ast) { - if (this.sourceMapper && TypeScript.isValidAstNode(ast)) { - var lineCol = { line: -1, character: -1 }; - var sourceMapping = new TypeScript.SourceMapping(); - sourceMapping.start.emittedColumn = this.emitState.column; - sourceMapping.start.emittedLine = this.emitState.line; - - var lineMap = this.document.lineMap; - lineMap.fillLineAndCharacterFromPosition(ast.minChar, lineCol); - sourceMapping.start.sourceColumn = lineCol.character; - sourceMapping.start.sourceLine = lineCol.line + 1; - lineMap.fillLineAndCharacterFromPosition(ast.limChar, lineCol); - sourceMapping.end.sourceColumn = lineCol.character; - sourceMapping.end.sourceLine = lineCol.line + 1; - if (this.sourceMapper.currentNameIndex.length > 0) { - sourceMapping.nameIndex = this.sourceMapper.currentNameIndex[this.sourceMapper.currentNameIndex.length - 1]; - } - - var siblings = this.sourceMapper.currentMappings[this.sourceMapper.currentMappings.length - 1]; - siblings.push(sourceMapping); - this.sourceMapper.currentMappings.push(sourceMapping.childMappings); - } - }; - - Emitter.prototype.recordSourceMappingEnd = function (ast) { - if (this.sourceMapper && TypeScript.isValidAstNode(ast)) { - this.sourceMapper.currentMappings.pop(); - - var siblings = this.sourceMapper.currentMappings[this.sourceMapper.currentMappings.length - 1]; - var sourceMapping = siblings[siblings.length - 1]; - - sourceMapping.end.emittedColumn = this.emitState.column; - sourceMapping.end.emittedLine = this.emitState.line; - } - }; - - Emitter.prototype.emitSourceMapsAndClose = function () { - if (this.sourceMapper !== null) { - TypeScript.SourceMapper.emitSourceMapping(this.allSourceMappers); - } - - try { - this.outfile.Close(); - } catch (e) { - Emitter.throwEmitterError(e); - } - }; - - Emitter.prototype.emitParameterPropertyAndMemberVariableAssignments = function () { - var constructorDecl = this.thisClassNode.constructorDecl; - - if (constructorDecl && constructorDecl.arguments) { - for (var i = 0, n = constructorDecl.arguments.members.length; i < n; i++) { - var arg = constructorDecl.arguments.members[i]; - if ((arg.getVarFlags() & 256 /* Property */) !== 0 /* None */) { - this.emitIndent(); - this.recordSourceMappingStart(arg); - this.recordSourceMappingStart(arg.id); - this.writeToOutput("this." + arg.id.actualText); - this.recordSourceMappingEnd(arg.id); - this.writeToOutput(" = "); - this.recordSourceMappingStart(arg.id); - this.writeToOutput(arg.id.actualText); - this.recordSourceMappingEnd(arg.id); - this.writeLineToOutput(";"); - this.recordSourceMappingEnd(arg); - } - } - } - - for (var i = 0, n = this.thisClassNode.members.members.length; i < n; i++) { - if (this.thisClassNode.members.members[i].nodeType === 17 /* VariableDeclarator */) { - var varDecl = this.thisClassNode.members.members[i]; - if (!TypeScript.hasFlag(varDecl.getVarFlags(), 16 /* Static */) && varDecl.init) { - this.emitIndent(); - this.emitVariableDeclarator(varDecl); - this.writeLineToOutput(""); - } - } - } - }; - - Emitter.prototype.emitCommaSeparatedList = function (list, startLine) { - if (typeof startLine === "undefined") { startLine = false; } - if (list === null) { - return; - } else { - for (var i = 0, n = list.members.length; i < n; i++) { - var emitNode = list.members[i]; - this.emitJavascript(emitNode, startLine); - - if (i < (n - 1)) { - this.writeToOutput(startLine ? "," : ", "); - } - - if (startLine) { - this.writeLineToOutput(""); - } - } - } - }; - - Emitter.prototype.emitModuleElements = function (list) { - if (list === null) { - return; - } - - this.emitComments(list, true); - var lastEmittedNode = null; - - for (var i = 0, n = list.members.length; i < n; i++) { - var node = list.members[i]; - - if (node.shouldEmit()) { - this.emitSpaceBetweenConstructs(lastEmittedNode, node); - - this.emitJavascript(node, true); - this.writeLineToOutput(""); - - lastEmittedNode = node; - } - } - - this.emitComments(list, false); - }; - - Emitter.prototype.isDirectivePrologueElement = function (node) { - if (node.nodeType === 88 /* ExpressionStatement */) { - var exprStatement = node; - return exprStatement.expression.nodeType === 5 /* StringLiteral */; - } - - return false; - }; - - Emitter.prototype.emitSpaceBetweenConstructs = function (node1, node2) { - if (node1 === null || node2 === null) { - return; - } - - if (node1.minChar === -1 || node1.limChar === -1 || node2.minChar === -1 || node2.limChar === -1) { - return; - } - - var lineMap = this.document.lineMap; - var node1EndLine = lineMap.getLineNumberFromPosition(node1.limChar); - var node2StartLine = lineMap.getLineNumberFromPosition(node2.minChar); - - if ((node2StartLine - node1EndLine) > 1) { - this.writeLineToOutput(""); - } - }; - - Emitter.prototype.emitScriptElements = function (script, requiresExtendsBlock) { - var list = script.moduleElements; - this.emitComments(list, true); - - for (var i = 0, n = list.members.length; i < n; i++) { - var node = list.members[i]; - - if (!this.isDirectivePrologueElement(node)) { - break; - } - - this.emitJavascript(node, true); - this.writeLineToOutput(""); - } - - this.emitPrologue(script, requiresExtendsBlock); - var lastEmittedNode = null; - - for (; i < n; i++) { - var node = list.members[i]; - - if (node.shouldEmit()) { - this.emitSpaceBetweenConstructs(lastEmittedNode, node); - - this.emitJavascript(node, true); - this.writeLineToOutput(""); - - lastEmittedNode = node; - } - } - - this.emitComments(list, false); - }; - - Emitter.prototype.emitConstructorStatements = function (funcDecl) { - var list = funcDecl.block.statements; - - if (list === null) { - return; - } - - this.emitComments(list, true); - - var emitPropertyAssignmentsAfterSuperCall = this.thisClassNode.extendsList && this.thisClassNode.extendsList.members.length > 0; - var propertyAssignmentIndex = emitPropertyAssignmentsAfterSuperCall ? 1 : 0; - var lastEmittedNode = null; - - for (var i = 0, n = list.members.length; i < n; i++) { - if (i === propertyAssignmentIndex) { - this.emitParameterPropertyAndMemberVariableAssignments(); - } - - var node = list.members[i]; - - if (node.shouldEmit()) { - this.emitSpaceBetweenConstructs(lastEmittedNode, node); - - this.emitJavascript(node, true); - this.writeLineToOutput(""); - - lastEmittedNode = node; - } - } - - if (i === propertyAssignmentIndex) { - this.emitParameterPropertyAndMemberVariableAssignments(); - } - - this.emitComments(list, false); - }; - - Emitter.prototype.emitJavascript = function (ast, startLine) { - if (ast === null) { - return; - } - - if (startLine && this.indenter.indentAmt > 0) { - this.emitIndent(); - } - - ast.emit(this); - }; - - Emitter.prototype.emitPropertyAccessor = function (funcDecl, className, isProto) { - if (!TypeScript.hasFlag(funcDecl.getFunctionFlags(), 32 /* GetAccessor */)) { - var accessorSymbol = TypeScript.PullHelpers.getAccessorSymbol(funcDecl, this.semanticInfoChain, this.document.fileName); - if (accessorSymbol.getGetter()) { - return; - } - } - - this.emitIndent(); - this.recordSourceMappingStart(funcDecl); - this.writeLineToOutput("Object.defineProperty(" + className + (isProto ? ".prototype, \"" : ", \"") + funcDecl.name.actualText + "\"" + ", {"); - this.indenter.increaseIndent(); - - var accessors = TypeScript.PullHelpers.getGetterAndSetterFunction(funcDecl, this.semanticInfoChain, this.document.fileName); - if (accessors.getter) { - this.emitIndent(); - this.recordSourceMappingStart(accessors.getter); - this.writeToOutput("get: "); - this.emitInnerFunction(accessors.getter, false); - this.writeLineToOutput(","); - } - - if (accessors.setter) { - this.emitIndent(); - this.recordSourceMappingStart(accessors.setter); - this.writeToOutput("set: "); - this.emitInnerFunction(accessors.setter, false); - this.writeLineToOutput(","); - } - - this.emitIndent(); - this.writeLineToOutput("enumerable: true,"); - this.emitIndent(); - this.writeLineToOutput("configurable: true"); - this.indenter.decreaseIndent(); - this.emitIndent(); - this.writeLineToOutput("});"); - this.recordSourceMappingEnd(funcDecl); - }; - - Emitter.prototype.emitPrototypeMember = function (funcDecl, className) { - if (funcDecl.isAccessor()) { - this.emitPropertyAccessor(funcDecl, className, true); - } else { - this.emitIndent(); - this.recordSourceMappingStart(funcDecl); - this.emitComments(funcDecl, true); - this.writeToOutput(className + ".prototype." + funcDecl.getNameText() + " = "); - this.emitInnerFunction(funcDecl, false, false); - this.writeLineToOutput(";"); - } - }; - - Emitter.prototype.emitClass = function (classDecl) { - var pullDecl = this.semanticInfoChain.getDeclForAST(classDecl, this.document.fileName); - this.pushDecl(pullDecl); - - var svClassNode = this.thisClassNode; - this.thisClassNode = classDecl; - var className = classDecl.name.actualText; - this.emitComments(classDecl, true); - var temp = this.setContainer(3 /* Class */); - - this.recordSourceMappingStart(classDecl); - this.writeToOutput("var " + className); - - var hasBaseClass = classDecl.extendsList && classDecl.extendsList.members.length; - var baseNameDecl = null; - var baseName = null; - var varDecl = null; - - if (hasBaseClass) { - this.writeLineToOutput(" = (function (_super) {"); - } else { - this.writeLineToOutput(" = (function () {"); - } - - this.recordSourceMappingNameStart(className); - this.indenter.increaseIndent(); - - if (hasBaseClass) { - baseNameDecl = classDecl.extendsList.members[0]; - baseName = baseNameDecl.nodeType === 36 /* InvocationExpression */ ? (baseNameDecl).target : baseNameDecl; - this.emitIndent(); - this.writeLineToOutput("__extends(" + className + ", _super);"); - } - - this.emitIndent(); - - var constrDecl = classDecl.constructorDecl; - - if (constrDecl) { - constrDecl.emit(this); - this.writeLineToOutput(""); - } else { - this.recordSourceMappingStart(classDecl); - - this.indenter.increaseIndent(); - this.writeLineToOutput("function " + classDecl.name.actualText + "() {"); - this.recordSourceMappingNameStart("constructor"); - if (hasBaseClass) { - this.emitIndent(); - this.writeLineToOutput("_super.apply(this, arguments);"); - } - - this.emitParameterPropertyAndMemberVariableAssignments(); - - this.indenter.decreaseIndent(); - this.emitIndent(); - this.writeLineToOutput("}"); - - this.recordSourceMappingNameEnd(); - this.recordSourceMappingEnd(classDecl); - } - - this.emitClassMembers(classDecl); - - this.emitIndent(); - this.recordSourceMappingStart(classDecl.endingToken); - this.writeLineToOutput("return " + className + ";"); - this.recordSourceMappingEnd(classDecl.endingToken); - this.indenter.decreaseIndent(); - this.emitIndent(); - this.recordSourceMappingStart(classDecl.endingToken); - this.writeToOutput("}"); - this.recordSourceMappingNameEnd(); - this.recordSourceMappingEnd(classDecl.endingToken); - this.recordSourceMappingStart(classDecl); - this.writeToOutput(")("); - if (hasBaseClass) { - this.resolvingContext.resolvingTypeReference = true; - this.emitJavascript(baseName, false); - this.resolvingContext.resolvingTypeReference = false; - } - this.writeToOutput(");"); - this.recordSourceMappingEnd(classDecl); - - if ((temp === 1 /* Module */ || temp === 2 /* DynamicModule */) && TypeScript.hasFlag(classDecl.getVarFlags(), 1 /* Exported */)) { - this.writeLineToOutput(""); - this.emitIndent(); - var modName = temp === 1 /* Module */ ? this.moduleName : "exports"; - this.recordSourceMappingStart(classDecl); - this.writeToOutput(modName + "." + className + " = " + className + ";"); - this.recordSourceMappingEnd(classDecl); - } - - this.recordSourceMappingEnd(classDecl); - this.emitComments(classDecl, false); - this.setContainer(temp); - this.thisClassNode = svClassNode; - - this.popDecl(pullDecl); - }; - - Emitter.prototype.emitClassMembers = function (classDecl) { - var lastEmittedMember = null; - - for (var i = 0, n = classDecl.members.members.length; i < n; i++) { - var memberDecl = classDecl.members.members[i]; - - if (memberDecl.nodeType === 12 /* FunctionDeclaration */) { - var fn = memberDecl; - - if (TypeScript.hasFlag(fn.getFunctionFlags(), 256 /* Method */) && !fn.isSignature()) { - this.emitSpaceBetweenConstructs(lastEmittedMember, fn); - - if (!TypeScript.hasFlag(fn.getFunctionFlags(), 16 /* Static */)) { - this.emitPrototypeMember(fn, classDecl.name.actualText); - } else { - if (fn.isAccessor()) { - this.emitPropertyAccessor(fn, this.thisClassNode.name.actualText, false); - } else { - this.emitIndent(); - this.recordSourceMappingStart(fn); - this.writeToOutput(classDecl.name.actualText + "." + fn.name.actualText + " = "); - this.emitInnerFunction(fn, false); - this.writeLineToOutput(";"); - } - } - - lastEmittedMember = fn; - } - } - } - - for (var i = 0, n = classDecl.members.members.length; i < n; i++) { - var memberDecl = classDecl.members.members[i]; - - if (memberDecl.nodeType === 17 /* VariableDeclarator */) { - var varDecl = memberDecl; - - if (TypeScript.hasFlag(varDecl.getVarFlags(), 16 /* Static */) && varDecl.init) { - this.emitSpaceBetweenConstructs(lastEmittedMember, varDecl); - - this.emitIndent(); - this.recordSourceMappingStart(varDecl); - this.writeToOutput(classDecl.name.actualText + "." + varDecl.id.actualText + " = "); - varDecl.init.emit(this); - - this.writeLineToOutput(";"); - this.recordSourceMappingEnd(varDecl); - - lastEmittedMember = varDecl; - } - } - } - }; - - Emitter.prototype.emitPrologue = function (script, requiresExtendsBlock) { - if (!this.extendsPrologueEmitted) { - if (requiresExtendsBlock) { - this.extendsPrologueEmitted = true; - this.writeLineToOutput("var __extends = this.__extends || function (d, b) {"); - this.writeLineToOutput(" for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];"); - this.writeLineToOutput(" function __() { this.constructor = d; }"); - this.writeLineToOutput(" __.prototype = b.prototype;"); - this.writeLineToOutput(" d.prototype = new __();"); - this.writeLineToOutput("};"); - } - } - - if (!this.globalThisCapturePrologueEmitted) { - if (this.shouldCaptureThis(script)) { - this.globalThisCapturePrologueEmitted = true; - this.writeLineToOutput(this.captureThisStmtString); - } - } - }; - - Emitter.prototype.emitSuperReference = function () { - this.writeToOutput("_super.prototype"); - }; - - Emitter.prototype.emitSuperCall = function (callEx) { - if (callEx.target.nodeType === 32 /* MemberAccessExpression */) { - var dotNode = callEx.target; - if (dotNode.operand1.nodeType === 30 /* SuperExpression */) { - dotNode.emit(this); - this.writeToOutput(".call("); - this.emitThis(); - if (callEx.arguments && callEx.arguments.members.length > 0) { - this.writeToOutput(", "); - this.emitCommaSeparatedList(callEx.arguments); - } - this.writeToOutput(")"); - return true; - } - } - return false; - }; - - Emitter.prototype.emitThis = function () { - if (this.thisFunctionDeclaration && !this.thisFunctionDeclaration.isMethod() && (!this.thisFunctionDeclaration.isConstructor)) { - this.writeToOutput("_this"); - } else { - this.writeToOutput("this"); - } - }; - - Emitter.prototype.emitBlockOrStatement = function (node) { - if (node.nodeType === 81 /* Block */) { - node.emit(this); - } else { - this.writeLineToOutput(""); - this.indenter.increaseIndent(); - this.emitJavascript(node, true); - this.indenter.decreaseIndent(); - } - }; - - Emitter.throwEmitterError = function (e) { - var error = new Error(e.message); - error.isEmitterError = true; - throw error; - }; - - Emitter.handleEmitterError = function (fileName, e) { - if ((e).isEmitterError === true) { - return [new TypeScript.Diagnostic(fileName, 0, 0, 275 /* Emit_Error__0 */, [e.message])]; - } - - throw e; - }; - return Emitter; - })(); - TypeScript.Emitter = Emitter; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var MemberName = (function () { - function MemberName() { - this.prefix = ""; - this.suffix = ""; - } - MemberName.prototype.isString = function () { - return false; - }; - MemberName.prototype.isArray = function () { - return false; - }; - MemberName.prototype.isMarker = function () { - return !this.isString() && !this.isArray(); - }; - - MemberName.prototype.toString = function () { - return MemberName.memberNameToString(this); - }; - - MemberName.memberNameToString = function (memberName, markerInfo, markerBaseLength) { - if (typeof markerBaseLength === "undefined") { markerBaseLength = 0; } - var result = memberName.prefix; - - if (memberName.isString()) { - result += (memberName).text; - } else if (memberName.isArray()) { - var ar = memberName; - for (var index = 0; index < ar.entries.length; index++) { - if (ar.entries[index].isMarker()) { - if (markerInfo) { - markerInfo.push(markerBaseLength + result.length); - } - continue; - } - - result += MemberName.memberNameToString(ar.entries[index], markerInfo, markerBaseLength + result.length); - result += ar.delim; - } - } - - result += memberName.suffix; - return result; - }; - - MemberName.create = function (arg1, arg2, arg3) { - if (typeof arg1 === "string") { - return new MemberNameString(arg1); - } else { - var result = new MemberNameArray(); - if (arg2) - result.prefix = arg2; - if (arg3) - result.suffix = arg3; - result.entries.push(arg1); - return result; - } - }; - return MemberName; - })(); - TypeScript.MemberName = MemberName; - - var MemberNameString = (function (_super) { - __extends(MemberNameString, _super); - function MemberNameString(text) { - _super.call(this); - this.text = text; - } - MemberNameString.prototype.isString = function () { - return true; - }; - return MemberNameString; - })(MemberName); - TypeScript.MemberNameString = MemberNameString; - - var MemberNameArray = (function (_super) { - __extends(MemberNameArray, _super); - function MemberNameArray() { - _super.call(this); - this.delim = ""; - this.entries = []; - } - MemberNameArray.prototype.isArray = function () { - return true; - }; - - MemberNameArray.prototype.add = function (entry) { - this.entries.push(entry); - }; - - MemberNameArray.prototype.addAll = function (entries) { - for (var i = 0; i < entries.length; i++) { - this.entries.push(entries[i]); - } - }; - return MemberNameArray; - })(MemberName); - TypeScript.MemberNameArray = MemberNameArray; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - function stripQuotes(str) { - return str.replace(/"/g, "").replace(/'/g, ""); - } - TypeScript.stripQuotes = stripQuotes; - - function isSingleQuoted(str) { - return str.indexOf("'") !== -1; - } - TypeScript.isSingleQuoted = isSingleQuoted; - - function isQuoted(str) { - return str.indexOf("\"") !== -1 || isSingleQuoted(str); - } - TypeScript.isQuoted = isQuoted; - - function quoteStr(str) { - return "\"" + str + "\""; - } - TypeScript.quoteStr = quoteStr; - - function swapQuotes(str) { - if (str.indexOf("\"") !== -1) { - str = str.replace("\"", "'"); - str = str.replace("\"", "'"); - } else { - str = str.replace("'", "\""); - str = str.replace("'", "\""); - } - - return str; - } - TypeScript.swapQuotes = swapQuotes; - - function switchToForwardSlashes(path) { - return path.replace(/\\/g, "/"); - } - TypeScript.switchToForwardSlashes = switchToForwardSlashes; - - function trimModName(modName) { - if (modName.length > 5 && modName.substring(modName.length - 5, modName.length) === ".d.ts") { - return modName.substring(0, modName.length - 5); - } - if (modName.length > 3 && modName.substring(modName.length - 3, modName.length) === ".ts") { - return modName.substring(0, modName.length - 3); - } - - if (modName.length > 3 && modName.substring(modName.length - 3, modName.length) === ".js") { - return modName.substring(0, modName.length - 3); - } - - return modName; - } - TypeScript.trimModName = trimModName; - - function getDeclareFilePath(fname) { - return isTSFile(fname) ? changePathToDTS(fname) : changePathToDTS(fname); - } - TypeScript.getDeclareFilePath = getDeclareFilePath; - - function isFileOfExtension(fname, ext) { - var invariantFname = fname.toLocaleUpperCase(); - var invariantExt = ext.toLocaleUpperCase(); - var extLength = invariantExt.length; - return invariantFname.length > extLength && invariantFname.substring(invariantFname.length - extLength, invariantFname.length) === invariantExt; - } - - function isJSFile(fname) { - return isFileOfExtension(fname, ".js"); - } - TypeScript.isJSFile = isJSFile; - - function isTSFile(fname) { - return isFileOfExtension(fname, ".ts"); - } - TypeScript.isTSFile = isTSFile; - - function isDTSFile(fname) { - return isFileOfExtension(fname, ".d.ts"); - } - TypeScript.isDTSFile = isDTSFile; - - function getPrettyName(modPath, quote, treatAsFileName) { - if (typeof quote === "undefined") { quote = true; } - if (typeof treatAsFileName === "undefined") { treatAsFileName = false; } - var modName = treatAsFileName ? switchToForwardSlashes(modPath) : trimModName(stripQuotes(modPath)); - var components = this.getPathComponents(modName); - return components.length ? (quote ? quoteStr(components[components.length - 1]) : components[components.length - 1]) : modPath; - } - TypeScript.getPrettyName = getPrettyName; - - function getPathComponents(path) { - return path.split("/"); - } - TypeScript.getPathComponents = getPathComponents; - - function getRelativePathToFixedPath(fixedModFilePath, absoluteModPath) { - absoluteModPath = switchToForwardSlashes(absoluteModPath); - - var modComponents = this.getPathComponents(absoluteModPath); - var fixedModComponents = this.getPathComponents(fixedModFilePath); - - var joinStartIndex = 0; - for (; joinStartIndex < modComponents.length && joinStartIndex < fixedModComponents.length; joinStartIndex++) { - if (fixedModComponents[joinStartIndex] !== modComponents[joinStartIndex]) { - break; - } - } - - if (joinStartIndex !== 0) { - var relativePath = ""; - var relativePathComponents = modComponents.slice(joinStartIndex, modComponents.length); - for (; joinStartIndex < fixedModComponents.length; joinStartIndex++) { - if (fixedModComponents[joinStartIndex] !== "") { - relativePath = relativePath + "../"; - } - } - - return relativePath + relativePathComponents.join("/"); - } - - return absoluteModPath; - } - TypeScript.getRelativePathToFixedPath = getRelativePathToFixedPath; - - function quoteBaseName(modPath) { - var modName = trimModName(stripQuotes(modPath)); - var path = getRootFilePath(modName); - if (path === "") { - return modPath; - } else { - var components = modName.split(path); - var fileIndex = components.length > 1 ? 1 : 0; - return quoteStr(components[fileIndex]); - } - } - TypeScript.quoteBaseName = quoteBaseName; - - function changePathToDTS(modPath) { - return trimModName(stripQuotes(modPath)) + ".d.ts"; - } - TypeScript.changePathToDTS = changePathToDTS; - - function isRelative(path) { - return path.charAt(0) === "."; - } - TypeScript.isRelative = isRelative; - function isRooted(path) { - return path.charAt(0) === "\\" || path.charAt(0) === "/" || (path.indexOf(":\\") !== -1) || (path.indexOf(":/") !== -1); - } - TypeScript.isRooted = isRooted; - - function getRootFilePath(outFname) { - if (outFname === "") { - return outFname; - } else { - var isPath = outFname.indexOf("/") !== -1; - return isPath ? filePath(outFname) : ""; - } - } - TypeScript.getRootFilePath = getRootFilePath; - - function filePathComponents(fullPath) { - fullPath = switchToForwardSlashes(fullPath); - var components = getPathComponents(fullPath); - return components.slice(0, components.length - 1); - } - TypeScript.filePathComponents = filePathComponents; - - function filePath(fullPath) { - var path = filePathComponents(fullPath); - return path.join("/") + "/"; - } - TypeScript.filePath = filePath; - - function normalizePath(path) { - if (/^\\\\[^\\]/.test(path)) { - path = "file:" + path; - } - var parts = this.getPathComponents(switchToForwardSlashes(path)); - var normalizedParts = []; - - for (var i = 0; i < parts.length; i++) { - var part = parts[i]; - if (part === ".") { - continue; - } - - if (normalizedParts.length > 0 && TypeScript.ArrayUtilities.last(normalizedParts) !== ".." && part === "..") { - normalizedParts.pop(); - continue; - } - - normalizedParts.push(part); - } - - return normalizedParts.join("/"); - } - TypeScript.normalizePath = normalizePath; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var SourceUnit = (function () { - function SourceUnit(path, fileInformation) { - this.path = path; - this.fileInformation = fileInformation; - this.referencedFiles = null; - this.lineStarts = null; - } - SourceUnit.prototype.getText = function (start, end) { - return this.fileInformation.contents().substring(start, end); - }; - - SourceUnit.prototype.getLength = function () { - return this.fileInformation.contents().length; - }; - - SourceUnit.prototype.getLineStartPositions = function () { - if (this.lineStarts === null) { - this.lineStarts = TypeScript.LineMap.fromString(this.fileInformation.contents()).lineStarts(); - } - - return this.lineStarts; - }; - - SourceUnit.prototype.getTextChangeRangeSinceVersion = function (scriptVersion) { - throw TypeScript.Errors.notYetImplemented(); - }; - return SourceUnit; - })(); - TypeScript.SourceUnit = SourceUnit; - - var CompilationEnvironment = (function () { - function CompilationEnvironment(compilationSettings, ioHost) { - this.compilationSettings = compilationSettings; - this.ioHost = ioHost; - this.code = []; - this.inputFileNameToOutputFileName = new TypeScript.StringHashTable(); - } - CompilationEnvironment.prototype.getSourceUnit = function (path) { - var normalizedPath = TypeScript.switchToForwardSlashes(path.toUpperCase()); - for (var i = 0, n = this.code.length; i < n; i++) { - var sourceUnit = this.code[i]; - var soruceUnitNormalizedPath = TypeScript.switchToForwardSlashes(sourceUnit.path.toUpperCase()); - if (normalizedPath === soruceUnitNormalizedPath) { - return sourceUnit; - } - } - - return null; - }; - return CompilationEnvironment; - })(); - TypeScript.CompilationEnvironment = CompilationEnvironment; - - var CodeResolver = (function () { - function CodeResolver(environment) { - this.environment = environment; - this.visited = {}; - } - CodeResolver.prototype.resolveCode = function (referencePath, parentPath, performSearch, resolutionDispatcher) { - var resolvedFile = { fileInformation: null, path: referencePath }; - - var ioHost = this.environment.ioHost; - - var isRelativePath = TypeScript.isRelative(referencePath); - var isRootedPath = isRelativePath ? false : TypeScript.isRooted(referencePath); - var normalizedPath = isRelativePath ? ioHost.resolvePath(parentPath + "/" + referencePath) : (isRootedPath || !parentPath || performSearch ? referencePath : parentPath + "/" + referencePath); - - if (!TypeScript.isTSFile(normalizedPath)) { - normalizedPath += ".ts"; - } - - normalizedPath = TypeScript.switchToForwardSlashes(TypeScript.stripQuotes(normalizedPath)); - var absoluteModuleID = this.environment.compilationSettings.useCaseSensitiveFileResolution ? normalizedPath : normalizedPath.toLocaleUpperCase(); - - if (!this.visited[absoluteModuleID]) { - if (isRelativePath || isRootedPath || !performSearch) { - try { - TypeScript.CompilerDiagnostics.debugPrint(" Reading code from " + normalizedPath); - - try { - resolvedFile.fileInformation = ioHost.readFile(normalizedPath); - } catch (err1) { - if (TypeScript.isTSFile(normalizedPath)) { - normalizedPath = TypeScript.changePathToDTS(normalizedPath); - TypeScript.CompilerDiagnostics.debugPrint(" Reading code from " + normalizedPath); - resolvedFile.fileInformation = ioHost.readFile(normalizedPath); - } - } - TypeScript.CompilerDiagnostics.debugPrint(" Found code at " + normalizedPath); - - resolvedFile.path = normalizedPath; - this.visited[absoluteModuleID] = true; - } catch (err4) { - TypeScript.CompilerDiagnostics.debugPrint(" Did not find code for " + referencePath); - - return false; - } - } else { - try { - resolvedFile = ioHost.findFile(parentPath, normalizedPath); - - if (!resolvedFile) { - if (TypeScript.isTSFile(normalizedPath)) { - normalizedPath = TypeScript.changePathToDTS(normalizedPath); - resolvedFile = ioHost.findFile(parentPath, normalizedPath); - } - } - } catch (e) { - TypeScript.CompilerDiagnostics.debugPrint(" Did not find code for " + normalizedPath); - - return false; - } - - if (resolvedFile) { - resolvedFile.path = TypeScript.switchToForwardSlashes(TypeScript.stripQuotes(resolvedFile.path)); - TypeScript.CompilerDiagnostics.debugPrint(referencePath + " resolved to: " + resolvedFile.path); - resolvedFile.fileInformation = resolvedFile.fileInformation; - this.visited[absoluteModuleID] = true; - } else { - TypeScript.CompilerDiagnostics.debugPrint("Could not find " + referencePath); - } - } - - if (resolvedFile && resolvedFile.fileInformation !== null) { - var rootDir = ioHost.dirName(resolvedFile.path); - var sourceUnit = new SourceUnit(resolvedFile.path, resolvedFile.fileInformation); - var preProcessedFileInfo = TypeScript.preProcessFile(resolvedFile.path, sourceUnit, this.environment.compilationSettings); - var resolvedFilePath = ioHost.resolvePath(resolvedFile.path); - var resolutionResult; - - sourceUnit.referencedFiles = preProcessedFileInfo.referencedFiles; - - for (var i = 0; i < preProcessedFileInfo.referencedFiles.length; i++) { - var fileReference = preProcessedFileInfo.referencedFiles[i]; - - normalizedPath = TypeScript.isRooted(fileReference.path) ? fileReference.path : rootDir + "/" + fileReference.path; - normalizedPath = ioHost.resolvePath(normalizedPath); - - if (resolvedFilePath === normalizedPath) { - resolutionDispatcher.errorReporter.addDiagnostic(new TypeScript.Diagnostic(normalizedPath, fileReference.position, fileReference.length, 270 /* A_file_cannot_have_a_reference_itself */, null)); - continue; - } - - resolutionResult = this.resolveCode(fileReference.path, rootDir, false, resolutionDispatcher); - - if (!resolutionResult) { - resolutionDispatcher.errorReporter.addDiagnostic(new TypeScript.Diagnostic(resolvedFilePath, fileReference.position, fileReference.length, 271 /* Cannot_resolve_referenced_file___0_ */, [fileReference.path])); - } - } - - for (var i = 0; i < preProcessedFileInfo.importedFiles.length; i++) { - var fileImport = preProcessedFileInfo.importedFiles[i]; - - resolutionResult = this.resolveCode(fileImport.path, rootDir, true, resolutionDispatcher); - - if (!resolutionResult) { - resolutionDispatcher.errorReporter.addDiagnostic(new TypeScript.Diagnostic(resolvedFilePath, fileImport.position, fileImport.length, 272 /* Cannot_resolve_imported_file___0_ */, [fileImport.path])); - } - } - - resolutionDispatcher.postResolution(sourceUnit.path, sourceUnit); - } - } - return true; - }; - return CodeResolver; - })(); - TypeScript.CodeResolver = CodeResolver; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var CompilationSettings = (function () { - function CompilationSettings() { - this.propagateConstants = false; - this.minWhitespace = false; - this.emitComments = false; - this.watch = false; - this.exec = false; - this.resolve = true; - this.disallowBool = false; - this.allowAutomaticSemicolonInsertion = true; - this.allowModuleKeywordInExternalModuleReference = true; - this.useDefaultLib = true; - this.codeGenTarget = 0 /* EcmaScript3 */; - this.moduleGenTarget = 0 /* Synchronous */; - this.outputOption = ""; - this.mapSourceFiles = false; - this.emitFullSourceMapPath = false; - this.generateDeclarationFiles = false; - this.useCaseSensitiveFileResolution = false; - this.gatherDiagnostics = false; - this.updateTC = false; - this.implicitAny = false; - } - return CompilationSettings; - })(); - TypeScript.CompilationSettings = CompilationSettings; - - function getFileReferenceFromReferencePath(comment) { - var referencesRegEx = /^(\/\/\/\s*/gim; - var match = referencesRegEx.exec(comment); - - if (match) { - var path = TypeScript.normalizePath(match[3]); - var adjustedPath = TypeScript.normalizePath(path); - - var isResident = match.length >= 7 && match[6] === "true"; - if (isResident) { - TypeScript.CompilerDiagnostics.debugPrint(path + " is resident"); - } - return { - line: 0, - character: 0, - position: 0, - length: 0, - path: TypeScript.switchToForwardSlashes(adjustedPath), - isResident: isResident - }; - } else { - return null; - } - } - - function getImplicitImport(comment) { - var implicitImportRegEx = /^(\/\/\/\s*/gim; - var match = implicitImportRegEx.exec(comment); - - if (match) { - return true; - } - - return false; - } - TypeScript.getImplicitImport = getImplicitImport; - - function getReferencedFiles(fileName, sourceText) { - var preProcessInfo = preProcessFile(fileName, sourceText, null, false); - return preProcessInfo.referencedFiles; - } - TypeScript.getReferencedFiles = getReferencedFiles; - - var scannerWindow = TypeScript.ArrayUtilities.createArray(2048, 0); - var scannerDiagnostics = []; - - function processImports(lineMap, scanner, token, importedFiles) { - var position = 0; - var lineChar = { line: -1, character: -1 }; - - while (token.tokenKind !== 10 /* EndOfFileToken */) { - if (token.tokenKind === 49 /* ImportKeyword */) { - var importStart = position + token.leadingTriviaWidth(); - token = scanner.scan(scannerDiagnostics, false); - - if (TypeScript.SyntaxFacts.isIdentifierNameOrAnyKeyword(token)) { - token = scanner.scan(scannerDiagnostics, false); - - if (token.tokenKind === 108 /* EqualsToken */) { - token = scanner.scan(scannerDiagnostics, false); - - if (token.tokenKind === 66 /* ModuleKeyword */ || token.tokenKind === 67 /* RequireKeyword */) { - token = scanner.scan(scannerDiagnostics, false); - - if (token.tokenKind === 73 /* OpenParenToken */) { - var afterOpenParenPosition = scanner.absoluteIndex(); - token = scanner.scan(scannerDiagnostics, false); - - lineMap.fillLineAndCharacterFromPosition(importStart, lineChar); - - if (token.tokenKind === 14 /* StringLiteral */) { - var ref = { - line: lineChar.line, - character: lineChar.character, - position: afterOpenParenPosition + token.leadingTriviaWidth(), - length: token.width(), - path: TypeScript.stripQuotes(TypeScript.switchToForwardSlashes(token.text())), - isResident: false - }; - importedFiles.push(ref); - } - } - } - } - } - } - - position = scanner.absoluteIndex(); - token = scanner.scan(scannerDiagnostics, false); - } - } - - function processTripleSlashDirectives(lineMap, firstToken, settings, referencedFiles) { - var leadingTrivia = firstToken.leadingTrivia(); - - var position = 0; - var lineChar = { line: -1, character: -1 }; - var noDefaultLib = false; - - for (var i = 0, n = leadingTrivia.count(); i < n; i++) { - var trivia = leadingTrivia.syntaxTriviaAt(i); - - if (trivia.kind() === 7 /* SingleLineCommentTrivia */) { - var triviaText = trivia.fullText(); - var referencedCode = getFileReferenceFromReferencePath(triviaText); - - if (referencedCode) { - lineMap.fillLineAndCharacterFromPosition(position, lineChar); - referencedCode.position = position; - referencedCode.length = trivia.fullWidth(); - referencedCode.line = lineChar.line; - referencedCode.character = lineChar.character; - - referencedFiles.push(referencedCode); - } - - if (settings) { - var isNoDefaultLibRegex = /^(\/\/\/\s*/gim; - var isNoDefaultLibMatch = isNoDefaultLibRegex.exec(triviaText); - if (isNoDefaultLibMatch) { - noDefaultLib = (isNoDefaultLibMatch[3] === "true"); - } - } - } - - position += trivia.fullWidth(); - } - - return { noDefaultLib: noDefaultLib }; - } - - function preProcessFile(fileName, sourceText, settings, readImportFiles) { - if (typeof readImportFiles === "undefined") { readImportFiles = true; } - settings = settings || new CompilationSettings(); - var text = TypeScript.SimpleText.fromScriptSnapshot(sourceText); - var scanner = new TypeScript.Scanner(fileName, text, settings.codeGenTarget, scannerWindow); - - var firstToken = scanner.scan(scannerDiagnostics, false); - - var importedFiles = []; - if (readImportFiles) { - processImports(text.lineMap(), scanner, firstToken, importedFiles); - } - - var referencedFiles = []; - var properties = processTripleSlashDirectives(text.lineMap(), firstToken, settings, referencedFiles); - - scannerDiagnostics.length = 0; - return { settings: settings, referencedFiles: referencedFiles, importedFiles: importedFiles, isLibFile: properties.noDefaultLib }; - } - TypeScript.preProcessFile = preProcessFile; - - function getParseOptions(settings) { - return new TypeScript.ParseOptions(settings.allowAutomaticSemicolonInsertion, settings.allowModuleKeywordInExternalModuleReference); - } - TypeScript.getParseOptions = getParseOptions; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var TextWriter = (function () { - function TextWriter(ioHost, path, writeByteOrderMark) { - this.ioHost = ioHost; - this.path = path; - this.writeByteOrderMark = writeByteOrderMark; - this.contents = ""; - this.onNewLine = true; - } - TextWriter.prototype.Write = function (s) { - this.contents += s; - this.onNewLine = false; - }; - - TextWriter.prototype.WriteLine = function (s) { - this.contents += s; - this.contents += "\r\n"; - this.onNewLine = true; - }; - - TextWriter.prototype.Close = function () { - try { - this.ioHost.writeFile(this.path, this.contents, this.writeByteOrderMark); - } catch (e) { - TypeScript.Emitter.throwEmitterError(e); - } - }; - return TextWriter; - })(); - TypeScript.TextWriter = TextWriter; - - var DeclarationEmitter = (function () { - function DeclarationEmitter(emittingFileName, semanticInfoChain, emitOptions, writeByteOrderMark) { - this.emittingFileName = emittingFileName; - this.semanticInfoChain = semanticInfoChain; - this.emitOptions = emitOptions; - this.writeByteOrderMark = writeByteOrderMark; - this.fileName = null; - this.declFile = null; - this.indenter = new TypeScript.Indenter(); - this.declarationContainerStack = []; - this.isDottedModuleName = []; - this.ignoreCallbackAst = null; - this.singleDeclFile = null; - this.varListCount = 0; - this.declFile = new TextWriter(emitOptions.ioHost, emittingFileName, writeByteOrderMark); - } - DeclarationEmitter.prototype.widenType = function (type) { - if (type === this.semanticInfoChain.undefinedTypeSymbol || type === this.semanticInfoChain.nullTypeSymbol) { - return this.semanticInfoChain.anyTypeSymbol; - } - - return type; - }; - - DeclarationEmitter.prototype.close = function () { - try { - this.declFile.Close(); - } catch (e) { - TypeScript.Emitter.throwEmitterError(e); - } - }; - - DeclarationEmitter.prototype.emitDeclarations = function (script) { - TypeScript.AstWalkerWithDetailCallback.walk(script, this); - }; - - DeclarationEmitter.prototype.getAstDeclarationContainer = function () { - return this.declarationContainerStack[this.declarationContainerStack.length - 1]; - }; - - DeclarationEmitter.prototype.emitDottedModuleName = function () { - return (this.isDottedModuleName.length === 0) ? false : this.isDottedModuleName[this.isDottedModuleName.length - 1]; - }; - - DeclarationEmitter.prototype.getIndentString = function (declIndent) { - if (typeof declIndent === "undefined") { declIndent = false; } - if (this.emitOptions.compilationSettings.minWhitespace) { - return ""; - } else { - return this.indenter.getIndent(); - } - }; - - DeclarationEmitter.prototype.emitIndent = function () { - this.declFile.Write(this.getIndentString()); - }; - - DeclarationEmitter.prototype.canEmitSignature = function (declFlags, declAST, canEmitGlobalAmbientDecl, useDeclarationContainerTop) { - if (typeof canEmitGlobalAmbientDecl === "undefined") { canEmitGlobalAmbientDecl = true; } - if (typeof useDeclarationContainerTop === "undefined") { useDeclarationContainerTop = true; } - var container; - if (useDeclarationContainerTop) { - container = this.getAstDeclarationContainer(); - } else { - container = this.declarationContainerStack[this.declarationContainerStack.length - 2]; - } - - if (container.nodeType === 15 /* ModuleDeclaration */ && !TypeScript.hasFlag(declFlags, 1 /* Exported */)) { - var declSymbol = this.semanticInfoChain.getSymbolAndDiagnosticsForAST(declAST, this.fileName).symbol; - return declSymbol && declSymbol.isExternallyVisible(); - } - - if (!canEmitGlobalAmbientDecl && container.nodeType === 2 /* Script */ && TypeScript.hasFlag(declFlags, 8 /* Ambient */)) { - return false; - } - - return true; - }; - - DeclarationEmitter.prototype.canEmitPrePostAstSignature = function (declFlags, astWithPrePostCallback, preCallback) { - if (this.ignoreCallbackAst) { - TypeScript.CompilerDiagnostics.assert(this.ignoreCallbackAst !== astWithPrePostCallback, "Ignore Callback AST mismatch"); - this.ignoreCallbackAst = null; - return false; - } else if (preCallback && !this.canEmitSignature(declFlags, astWithPrePostCallback, true, preCallback)) { - this.ignoreCallbackAst = astWithPrePostCallback; - return false; - } - - return true; - }; - - DeclarationEmitter.prototype.getDeclFlagsString = function (declFlags, typeString) { - var result = this.getIndentString(); - - if (TypeScript.hasFlag(declFlags, 16 /* Static */)) { - if (TypeScript.hasFlag(declFlags, 2 /* Private */)) { - result += "private "; - } - result += "static "; - } else { - if (TypeScript.hasFlag(declFlags, 2 /* Private */)) { - result += "private "; - } else if (TypeScript.hasFlag(declFlags, 4 /* Public */)) { - result += "public "; - } else { - var emitDeclare = !TypeScript.hasFlag(declFlags, 1 /* Exported */); - - var container = this.getAstDeclarationContainer(); - if (container.nodeType === 15 /* ModuleDeclaration */ && TypeScript.hasFlag((container).getModuleFlags(), 256 /* IsWholeFile */) && TypeScript.hasFlag(declFlags, 1 /* Exported */)) { - result += "export "; - emitDeclare = true; - } - - if (emitDeclare && typeString !== "interface") { - result += "declare "; - } - - result += typeString + " "; - } - } - - return result; - }; - - DeclarationEmitter.prototype.emitDeclFlags = function (declFlags, typeString) { - this.declFile.Write(this.getDeclFlagsString(declFlags, typeString)); - }; - - DeclarationEmitter.prototype.canEmitTypeAnnotationSignature = function (declFlag) { - if (typeof declFlag === "undefined") { declFlag = 0 /* None */; } - return !TypeScript.hasFlag(declFlag, 2 /* Private */); - }; - - DeclarationEmitter.prototype.pushDeclarationContainer = function (ast) { - this.declarationContainerStack.push(ast); - }; - - DeclarationEmitter.prototype.popDeclarationContainer = function (ast) { - TypeScript.CompilerDiagnostics.assert(ast !== this.getAstDeclarationContainer(), 'Declaration container mismatch'); - this.declarationContainerStack.pop(); - }; - - DeclarationEmitter.prototype.emitTypeNamesMember = function (memberName, emitIndent) { - if (typeof emitIndent === "undefined") { emitIndent = false; } - if (memberName.prefix === "{ ") { - if (emitIndent) { - this.emitIndent(); - } - - this.declFile.WriteLine("{"); - this.indenter.increaseIndent(); - emitIndent = true; - } else if (memberName.prefix !== "") { - if (emitIndent) { - this.emitIndent(); - } - - this.declFile.Write(memberName.prefix); - emitIndent = false; - } - - if (memberName.isString()) { - if (emitIndent) { - this.emitIndent(); - } - - this.declFile.Write((memberName).text); - } else if (memberName.isArray()) { - var ar = memberName; - for (var index = 0; index < ar.entries.length; index++) { - this.emitTypeNamesMember(ar.entries[index], emitIndent); - if (ar.delim === "; ") { - this.declFile.WriteLine(";"); - } - } - } - - if (memberName.suffix === "}") { - this.indenter.decreaseIndent(); - this.emitIndent(); - this.declFile.Write(memberName.suffix); - } else { - this.declFile.Write(memberName.suffix); - } - }; - - DeclarationEmitter.prototype.emitTypeSignature = function (type) { - var declarationContainerAst = this.getAstDeclarationContainer(); - var declarationContainerDecl = this.semanticInfoChain.getDeclForAST(declarationContainerAst, this.fileName); - var declarationPullSymbol = declarationContainerDecl.getSymbol(); - var typeNameMembers = type.getScopedNameEx(declarationPullSymbol); - this.emitTypeNamesMember(typeNameMembers); - }; - - DeclarationEmitter.prototype.emitComment = function (comment) { - var text = comment.getText(); - if (this.declFile.onNewLine) { - this.emitIndent(); - } else if (!comment.isBlockComment) { - this.declFile.WriteLine(""); - this.emitIndent(); - } - - this.declFile.Write(text[0]); - - for (var i = 1; i < text.length; i++) { - this.declFile.WriteLine(""); - this.emitIndent(); - this.declFile.Write(text[i]); - } - - if (comment.endsLine || !comment.isBlockComment) { - this.declFile.WriteLine(""); - } else { - this.declFile.Write(" "); - } - }; - - DeclarationEmitter.prototype.emitDeclarationComments = function (astOrSymbol, endLine) { - if (typeof endLine === "undefined") { endLine = true; } - if (!this.emitOptions.compilationSettings.emitComments) { - return; - } - - var declComments = astOrSymbol.getDocComments(); - this.writeDeclarationComments(declComments, endLine); - }; - - DeclarationEmitter.prototype.writeDeclarationComments = function (declComments, endLine) { - if (typeof endLine === "undefined") { endLine = true; } - if (declComments.length > 0) { - for (var i = 0; i < declComments.length; i++) { - this.emitComment(declComments[i]); - } - - if (endLine) { - if (!this.declFile.onNewLine) { - this.declFile.WriteLine(""); - } - } else { - if (this.declFile.onNewLine) { - this.emitIndent(); - } - } - } - }; - - DeclarationEmitter.prototype.emitTypeOfBoundDecl = function (boundDecl) { - var decl = this.semanticInfoChain.getDeclForAST(boundDecl, this.fileName); - var pullSymbol = decl.getSymbol(); - var type = this.widenType(pullSymbol.getType()); - if (!type) { - return; - } - - if (boundDecl.typeExpr || (boundDecl.init && type !== this.semanticInfoChain.anyTypeSymbol)) { - this.declFile.Write(": "); - this.emitTypeSignature(type); - } - }; - - DeclarationEmitter.prototype.VariableDeclaratorCallback = function (pre, varDecl) { - if (pre && this.canEmitSignature(TypeScript.ToDeclFlags(varDecl.getVarFlags()), varDecl, false)) { - var interfaceMember = (this.getAstDeclarationContainer().nodeType === 14 /* InterfaceDeclaration */); - this.emitDeclarationComments(varDecl); - if (!interfaceMember) { - if (this.varListCount >= 0) { - this.emitDeclFlags(TypeScript.ToDeclFlags(varDecl.getVarFlags()), "var"); - this.varListCount = -this.varListCount; - } - - this.declFile.Write(varDecl.id.actualText); - } else { - this.emitIndent(); - this.declFile.Write(varDecl.id.actualText); - if (TypeScript.hasFlag(varDecl.id.getFlags(), 4 /* OptionalName */)) { - this.declFile.Write("?"); - } - } - - if (this.canEmitTypeAnnotationSignature(TypeScript.ToDeclFlags(varDecl.getVarFlags()))) { - this.emitTypeOfBoundDecl(varDecl); - } - - if (this.varListCount > 0) { - this.varListCount--; - } else if (this.varListCount < 0) { - this.varListCount++; - } - - if (this.varListCount < 0) { - this.declFile.Write(", "); - } else { - this.declFile.WriteLine(";"); - } - } - return false; - }; - - DeclarationEmitter.prototype.BlockCallback = function (pre, block) { - return false; - }; - - DeclarationEmitter.prototype.VariableStatementCallback = function (pre, variableDeclaration) { - return true; - }; - - DeclarationEmitter.prototype.VariableDeclarationCallback = function (pre, variableDeclaration) { - if (pre) { - this.varListCount = variableDeclaration.declarators.members.length; - } else { - this.varListCount = 0; - } - return true; - }; - - DeclarationEmitter.prototype.emitArgDecl = function (argDecl, funcDecl) { - this.indenter.increaseIndent(); - - this.emitDeclarationComments(argDecl, false); - this.declFile.Write(argDecl.id.actualText); - if (argDecl.isOptionalArg()) { - this.declFile.Write("?"); - } - - this.indenter.decreaseIndent(); - - if (this.canEmitTypeAnnotationSignature(TypeScript.ToDeclFlags(funcDecl.getFunctionFlags()))) { - this.emitTypeOfBoundDecl(argDecl); - } - }; - - DeclarationEmitter.prototype.isOverloadedCallSignature = function (funcDecl) { - var functionDecl = this.semanticInfoChain.getDeclForAST(funcDecl, this.fileName); - var funcSymbol = functionDecl.getSymbol(); - var funcTypeSymbol = funcSymbol.getType(); - var signatures = funcTypeSymbol.getCallSignatures(); - return signatures && signatures.length > 1; - }; - - DeclarationEmitter.prototype.FunctionDeclarationCallback = function (pre, funcDecl) { - if (!pre) { - return false; - } - - if (funcDecl.isAccessor()) { - return this.emitPropertyAccessorSignature(funcDecl); - } - - var isInterfaceMember = (this.getAstDeclarationContainer().nodeType === 14 /* InterfaceDeclaration */); - - var funcSymbol = this.semanticInfoChain.getSymbolAndDiagnosticsForAST(funcDecl, this.fileName).symbol; - var funcTypeSymbol = funcSymbol.getType(); - if (funcDecl.block) { - var constructSignatures = funcTypeSymbol.getConstructSignatures(); - if (constructSignatures && constructSignatures.length > 1) { - return false; - } else if (this.isOverloadedCallSignature(funcDecl)) { - return false; - } - } else if (!isInterfaceMember && TypeScript.hasFlag(funcDecl.getFunctionFlags(), 2 /* Private */) && this.isOverloadedCallSignature(funcDecl)) { - var callSignatures = funcTypeSymbol.getCallSignatures(); - TypeScript.Debug.assert(callSignatures && callSignatures.length > 1); - var firstSignature = callSignatures[0].isDefinition() ? callSignatures[1] : callSignatures[0]; - var firstSignatureDecl = firstSignature.getDeclarations()[0]; - var firstFuncDecl = this.semanticInfoChain.getASTForDecl(firstSignatureDecl); - if (firstFuncDecl !== funcDecl) { - return false; - } - } - - if (!this.canEmitSignature(TypeScript.ToDeclFlags(funcDecl.getFunctionFlags()), funcDecl, false)) { - return false; - } - - var funcSignature = this.semanticInfoChain.getDeclForAST(funcDecl, this.fileName).getSignatureSymbol(); - this.emitDeclarationComments(funcDecl); - if (funcDecl.isConstructor) { - this.emitIndent(); - this.declFile.Write("constructor"); - this.emitTypeParameters(funcDecl.typeArguments, funcSignature); - } else { - var id = funcDecl.getNameText(); - if (!isInterfaceMember) { - this.emitDeclFlags(TypeScript.ToDeclFlags(funcDecl.getFunctionFlags()), "function"); - if (id !== "__missing" || !funcDecl.name || !funcDecl.name.isMissing()) { - this.declFile.Write(id); - } else if (funcDecl.isConstructMember()) { - this.declFile.Write("new"); - } - - this.emitTypeParameters(funcDecl.typeArguments, funcSignature); - } else { - this.emitIndent(); - if (funcDecl.isConstructMember()) { - this.declFile.Write("new"); - this.emitTypeParameters(funcDecl.typeArguments, funcSignature); - } else if (!funcDecl.isCallMember() && !funcDecl.isIndexerMember()) { - this.declFile.Write(id); - this.emitTypeParameters(funcDecl.typeArguments, funcSignature); - if (TypeScript.hasFlag(funcDecl.name.getFlags(), 4 /* OptionalName */)) { - this.declFile.Write("? "); - } - } else { - this.emitTypeParameters(funcDecl.typeArguments, funcSignature); - } - } - } - - if (!funcDecl.isIndexerMember()) { - this.declFile.Write("("); - } else { - this.declFile.Write("["); - } - - if (funcDecl.arguments) { - var argsLen = funcDecl.arguments.members.length; - if (funcDecl.variableArgList) { - argsLen--; - } - - for (var i = 0; i < argsLen; i++) { - var argDecl = funcDecl.arguments.members[i]; - this.emitArgDecl(argDecl, funcDecl); - if (i < (argsLen - 1)) { - this.declFile.Write(", "); - } - } - } - - if (funcDecl.variableArgList) { - var lastArg = funcDecl.arguments.members[funcDecl.arguments.members.length - 1]; - if (funcDecl.arguments.members.length > 1) { - this.declFile.Write(", ..."); - } else { - this.declFile.Write("..."); - } - - this.emitArgDecl(lastArg, funcDecl); - } - - if (!funcDecl.isIndexerMember()) { - this.declFile.Write(")"); - } else { - this.declFile.Write("]"); - } - - if (!funcDecl.isConstructor && this.canEmitTypeAnnotationSignature(TypeScript.ToDeclFlags(funcDecl.getFunctionFlags()))) { - var returnType = funcSignature.getReturnType(); - if (funcDecl.returnTypeAnnotation || (returnType && returnType !== this.semanticInfoChain.anyTypeSymbol)) { - this.declFile.Write(": "); - this.emitTypeSignature(returnType); - } - } - - this.declFile.WriteLine(";"); - - return false; - }; - - DeclarationEmitter.prototype.emitBaseExpression = function (bases, index) { - var baseTypeAndDiagnostics = this.semanticInfoChain.getSymbolAndDiagnosticsForAST(bases.members[index], this.fileName); - var baseType = baseTypeAndDiagnostics && baseTypeAndDiagnostics.symbol; - this.emitTypeSignature(baseType); - }; - - DeclarationEmitter.prototype.emitBaseList = function (typeDecl, useExtendsList) { - var bases = useExtendsList ? typeDecl.extendsList : typeDecl.implementsList; - if (bases && (bases.members.length > 0)) { - var qual = useExtendsList ? "extends" : "implements"; - this.declFile.Write(" " + qual + " "); - var basesLen = bases.members.length; - for (var i = 0; i < basesLen; i++) { - if (i > 0) { - this.declFile.Write(", "); - } - this.emitBaseExpression(bases, i); - } - } - }; - - DeclarationEmitter.prototype.emitAccessorDeclarationComments = function (funcDecl) { - if (!this.emitOptions.compilationSettings.emitComments) { - return; - } - - var accessors = TypeScript.PullHelpers.getGetterAndSetterFunction(funcDecl, this.semanticInfoChain, this.fileName); - var comments = []; - if (accessors.getter) { - comments = comments.concat(accessors.getter.getDocComments()); - } - if (accessors.setter) { - comments = comments.concat(accessors.setter.getDocComments()); - } - this.writeDeclarationComments(comments); - }; - - DeclarationEmitter.prototype.emitPropertyAccessorSignature = function (funcDecl) { - var accessorSymbol = TypeScript.PullHelpers.getAccessorSymbol(funcDecl, this.semanticInfoChain, this.fileName); - if (!TypeScript.hasFlag(funcDecl.getFunctionFlags(), 32 /* GetAccessor */) && accessorSymbol.getGetter()) { - return false; - } - - this.emitAccessorDeclarationComments(funcDecl); - this.emitDeclFlags(TypeScript.ToDeclFlags(funcDecl.getFunctionFlags()), "var"); - this.declFile.Write(funcDecl.name.actualText); - if (this.canEmitTypeAnnotationSignature(TypeScript.ToDeclFlags(funcDecl.getFunctionFlags()))) { - this.declFile.Write(" : "); - var type = accessorSymbol.getType(); - this.emitTypeSignature(type); - } - this.declFile.WriteLine(";"); - - return false; - }; - - DeclarationEmitter.prototype.emitClassMembersFromConstructorDefinition = function (funcDecl) { - if (funcDecl.arguments) { - var argsLen = funcDecl.arguments.members.length; - if (funcDecl.variableArgList) { - argsLen--; - } - - for (var i = 0; i < argsLen; i++) { - var argDecl = funcDecl.arguments.members[i]; - if (TypeScript.hasFlag(argDecl.getVarFlags(), 256 /* Property */)) { - this.emitDeclarationComments(argDecl); - this.emitDeclFlags(TypeScript.ToDeclFlags(argDecl.getVarFlags()), "var"); - this.declFile.Write(argDecl.id.actualText); - - if (this.canEmitTypeAnnotationSignature(TypeScript.ToDeclFlags(argDecl.getVarFlags()))) { - this.emitTypeOfBoundDecl(argDecl); - } - this.declFile.WriteLine(";"); - } - } - } - }; - - DeclarationEmitter.prototype.ClassDeclarationCallback = function (pre, classDecl) { - if (!this.canEmitPrePostAstSignature(TypeScript.ToDeclFlags(classDecl.getVarFlags()), classDecl, pre)) { - return false; - } - - if (pre) { - var className = classDecl.name.actualText; - this.emitDeclarationComments(classDecl); - this.emitDeclFlags(TypeScript.ToDeclFlags(classDecl.getVarFlags()), "class"); - this.declFile.Write(className); - this.pushDeclarationContainer(classDecl); - this.emitTypeParameters(classDecl.typeParameters); - this.emitBaseList(classDecl, true); - this.emitBaseList(classDecl, false); - this.declFile.WriteLine(" {"); - - this.indenter.increaseIndent(); - if (classDecl.constructorDecl) { - this.emitClassMembersFromConstructorDefinition(classDecl.constructorDecl); - } - } else { - this.indenter.decreaseIndent(); - this.popDeclarationContainer(classDecl); - - this.emitIndent(); - this.declFile.WriteLine("}"); - } - - return true; - }; - - DeclarationEmitter.prototype.emitTypeParameters = function (typeParams, funcSignature) { - if (!typeParams || !typeParams.members.length) { - return; - } - - this.declFile.Write("<"); - var containerAst = this.getAstDeclarationContainer(); - var containerDecl = this.semanticInfoChain.getDeclForAST(containerAst, this.fileName); - var containerSymbol = containerDecl.getSymbol(); - var typars; - if (funcSignature) { - typars = funcSignature.getTypeParameters(); - } else { - typars = containerSymbol.getTypeArguments(); - if (!typars || !typars.length) { - typars = containerSymbol.getTypeParameters(); - } - } - - for (var i = 0; i < typars.length; i++) { - if (i) { - this.declFile.Write(", "); - } - - var memberName = typars[i].getScopedNameEx(containerSymbol, true); - this.emitTypeNamesMember(memberName); - } - - this.declFile.Write(">"); - }; - - DeclarationEmitter.prototype.InterfaceDeclarationCallback = function (pre, interfaceDecl) { - if (!this.canEmitPrePostAstSignature(TypeScript.ToDeclFlags(interfaceDecl.getVarFlags()), interfaceDecl, pre)) { - return false; - } - - if (pre) { - var interfaceName = interfaceDecl.name.actualText; - this.emitDeclarationComments(interfaceDecl); - this.emitDeclFlags(TypeScript.ToDeclFlags(interfaceDecl.getVarFlags()), "interface"); - this.declFile.Write(interfaceName); - this.pushDeclarationContainer(interfaceDecl); - this.emitTypeParameters(interfaceDecl.typeParameters); - this.emitBaseList(interfaceDecl, true); - this.declFile.WriteLine(" {"); - - this.indenter.increaseIndent(); - } else { - this.indenter.decreaseIndent(); - this.popDeclarationContainer(interfaceDecl); - - this.emitIndent(); - this.declFile.WriteLine("}"); - } - - return true; - }; - - DeclarationEmitter.prototype.ImportDeclarationCallback = function (pre, importDeclAST) { - if (pre) { - var importDecl = this.semanticInfoChain.getDeclForAST(importDeclAST, this.fileName); - var importSymbol = importDecl.getSymbol(); - if (importSymbol.getTypeUsedExternally() || TypeScript.PullContainerTypeSymbol.usedAsSymbol(importSymbol.getContainer(), importSymbol)) { - this.emitDeclarationComments(importDeclAST); - this.emitIndent(); - this.declFile.Write("import "); - - this.declFile.Write(importDeclAST.id.actualText + " = "); - if (importDeclAST.isDynamicImport) { - this.declFile.WriteLine("require(" + importDeclAST.getAliasName() + ");"); - } else { - this.declFile.WriteLine(importDeclAST.getAliasName() + ";"); - } - } - } - - return false; - }; - - DeclarationEmitter.prototype.emitEnumSignature = function (moduleDecl) { - if (!this.canEmitSignature(TypeScript.ToDeclFlags(moduleDecl.getModuleFlags()), moduleDecl)) { - return false; - } - - this.emitDeclarationComments(moduleDecl); - this.emitDeclFlags(TypeScript.ToDeclFlags(moduleDecl.getModuleFlags()), "enum"); - this.declFile.WriteLine(moduleDecl.name.actualText + " {"); - - this.indenter.increaseIndent(); - var membersLen = moduleDecl.members.members.length; - for (var j = 0; j < membersLen; j++) { - var memberDecl = moduleDecl.members.members[j]; - if (memberDecl.nodeType === 97 /* VariableStatement */ && !TypeScript.hasFlag(memberDecl.getFlags(), 32 /* EnumMapElement */)) { - var variableStatement = memberDecl; - this.emitDeclarationComments(memberDecl); - this.emitIndent(); - this.declFile.WriteLine((variableStatement.declaration.declarators.members[0]).id.actualText + ","); - } - } - this.indenter.decreaseIndent(); - - this.emitIndent(); - this.declFile.WriteLine("}"); - - return false; - }; - - DeclarationEmitter.prototype.ModuleDeclarationCallback = function (pre, moduleDecl) { - if (TypeScript.hasFlag(moduleDecl.getModuleFlags(), 256 /* IsWholeFile */)) { - if (TypeScript.hasFlag(moduleDecl.getModuleFlags(), 512 /* IsDynamic */)) { - if (pre) { - if (!this.emitOptions.outputMany) { - this.singleDeclFile = this.declFile; - TypeScript.CompilerDiagnostics.assert(this.indenter.indentAmt === 0, "Indent has to be 0 when outputing new file"); - - var declareFileName = this.emitOptions.mapOutputFileName(this.fileName, TypeScript.TypeScriptCompiler.mapToDTSFileName); - var useUTF8InOutputfile = moduleDecl.containsUnicodeChar || (this.emitOptions.compilationSettings.emitComments && moduleDecl.containsUnicodeCharInComment); - - this.declFile = new TextWriter(this.emitOptions.ioHost, declareFileName, this.writeByteOrderMark); - } - this.pushDeclarationContainer(moduleDecl); - } else { - if (!this.emitOptions.outputMany) { - TypeScript.CompilerDiagnostics.assert(this.singleDeclFile !== this.declFile, "singleDeclFile cannot be null as we are going to revert back to it"); - TypeScript.CompilerDiagnostics.assert(this.indenter.indentAmt === 0, "Indent has to be 0 when outputing new file"); - - try { - this.declFile.Close(); - } catch (e) { - TypeScript.Emitter.throwEmitterError(e); - } - - this.declFile = this.singleDeclFile; - } - - this.popDeclarationContainer(moduleDecl); - } - } - - return true; - } - - if (moduleDecl.isEnum()) { - if (pre) { - this.emitEnumSignature(moduleDecl); - } - return false; - } - - if (!this.canEmitPrePostAstSignature(TypeScript.ToDeclFlags(moduleDecl.getModuleFlags()), moduleDecl, pre)) { - return false; - } - - if (pre) { - if (this.emitDottedModuleName()) { - this.dottedModuleEmit += "."; - } else { - this.dottedModuleEmit = this.getDeclFlagsString(TypeScript.ToDeclFlags(moduleDecl.getModuleFlags()), "module"); - } - - this.dottedModuleEmit += moduleDecl.name.actualText; - - var isCurrentModuleDotted = (moduleDecl.members.members.length === 1 && moduleDecl.members.members[0].nodeType === 15 /* ModuleDeclaration */ && !(moduleDecl.members.members[0]).isEnum() && TypeScript.hasFlag((moduleDecl.members.members[0]).getModuleFlags(), 1 /* Exported */)); - - var moduleDeclComments = moduleDecl.getDocComments(); - isCurrentModuleDotted = isCurrentModuleDotted && (moduleDeclComments === null || moduleDeclComments.length === 0); - - this.isDottedModuleName.push(isCurrentModuleDotted); - this.pushDeclarationContainer(moduleDecl); - - if (!isCurrentModuleDotted) { - this.emitDeclarationComments(moduleDecl); - this.declFile.Write(this.dottedModuleEmit); - this.declFile.WriteLine(" {"); - this.indenter.increaseIndent(); - } - } else { - if (!this.emitDottedModuleName()) { - this.indenter.decreaseIndent(); - this.emitIndent(); - this.declFile.WriteLine("}"); - } - - this.popDeclarationContainer(moduleDecl); - this.isDottedModuleName.pop(); - } - - return true; - }; - - DeclarationEmitter.prototype.ExportAssignmentCallback = function (pre, ast) { - if (pre) { - this.emitIndent(); - this.declFile.Write("export = "); - this.declFile.Write((ast).id.actualText); - this.declFile.WriteLine(";"); - } - - return false; - }; - - DeclarationEmitter.prototype.ScriptCallback = function (pre, script) { - if (pre) { - if (this.emitOptions.outputMany) { - for (var i = 0; i < script.referencedFiles.length; i++) { - var referencePath = script.referencedFiles[i].path; - var declareFileName; - if (TypeScript.isRooted(referencePath)) { - declareFileName = this.emitOptions.mapOutputFileName(referencePath, TypeScript.TypeScriptCompiler.mapToDTSFileName); - } else { - declareFileName = TypeScript.getDeclareFilePath(script.referencedFiles[i].path); - } - this.declFile.WriteLine('/// '); - } - } - this.pushDeclarationContainer(script); - } else { - this.popDeclarationContainer(script); - } - return true; - }; - - DeclarationEmitter.prototype.DefaultCallback = function (pre, ast) { - return !ast.isStatement(); - }; - return DeclarationEmitter; - })(); - TypeScript.DeclarationEmitter = DeclarationEmitter; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var BloomFilter = (function () { - function BloomFilter(expectedCount) { - var m = Math.max(1, BloomFilter.computeM(expectedCount)); - var k = Math.max(1, BloomFilter.computeK(expectedCount)); - ; - - var sizeInEvenBytes = (m + 7) & ~7; - - this.bitArray = []; - for (var i = 0, len = sizeInEvenBytes; i < len; i++) { - this.bitArray[i] = false; - } - this.hashFunctionCount = k; - } - BloomFilter.computeM = function (expectedCount) { - var p = BloomFilter.falsePositiveProbability; - var n = expectedCount; - - var numerator = n * Math.log(p); - var denominator = Math.log(1.0 / Math.pow(2.0, Math.log(2.0))); - return Math.ceil(numerator / denominator); - }; - - BloomFilter.computeK = function (expectedCount) { - var n = expectedCount; - var m = BloomFilter.computeM(expectedCount); - - var temp = Math.log(2.0) * m / n; - return Math.round(temp); - }; - - BloomFilter.prototype.computeHash = function (key, seed) { - var m = 0x5bd1e995; - var r = 24; - - var numberOfCharsLeft = key.length; - var h = Math.abs(seed ^ numberOfCharsLeft); - - var index = 0; - while (numberOfCharsLeft >= 2) { - var c1 = this.getCharacter(key, index); - var c2 = this.getCharacter(key, index + 1); - - var k = Math.abs(c1 | (c2 << 16)); - - k = TypeScript.IntegerUtilities.integerMultiplyLow32Bits(k, m); - k ^= k >> r; - k = TypeScript.IntegerUtilities.integerMultiplyLow32Bits(k, m); - - h = TypeScript.IntegerUtilities.integerMultiplyLow32Bits(h, m); - h ^= k; - - index += 2; - numberOfCharsLeft -= 2; - } - - if (numberOfCharsLeft == 1) { - h ^= this.getCharacter(key, index); - h = TypeScript.IntegerUtilities.integerMultiplyLow32Bits(h, m); - } - - h ^= h >> 13; - h = TypeScript.IntegerUtilities.integerMultiplyLow32Bits(h, m); - h ^= h >> 15; - - return Math.round(h); - }; - - BloomFilter.prototype.getCharacter = function (key, index) { - return key.charCodeAt(index); - }; - - BloomFilter.prototype.addKeys = function (keys) { - for (var name in keys) { - this.add(name); - } - }; - - BloomFilter.prototype.add = function (value) { - for (var i = 0; i < this.hashFunctionCount; i++) { - var hash = this.computeHash(value, i); - hash = hash % this.bitArray.length; - this.bitArray[Math.abs(hash)] = true; - } - }; - - BloomFilter.prototype.probablyContains = function (value) { - for (var i = 0; i < this.hashFunctionCount; i++) { - var hash = this.computeHash(value, i); - hash = hash % this.bitArray.length; - if (!this.bitArray[Math.abs(hash)]) { - return false; - } - } - - return true; - }; - - BloomFilter.prototype.isEquivalent = function (filter) { - return BloomFilter.isEquivalent(this.bitArray, filter.bitArray) && this.hashFunctionCount == filter.hashFunctionCount; - }; - - BloomFilter.isEquivalent = function (array1, array2) { - if (array1.length != array2.length) { - return false; - } - - for (var i = 0; i < array1.length; i++) { - if (array1[i] != array2[i]) { - return false; - } - } - - return true; - }; - BloomFilter.falsePositiveProbability = 0.0001; - return BloomFilter; - })(); - TypeScript.BloomFilter = BloomFilter; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var IdentifierWalker = (function (_super) { - __extends(IdentifierWalker, _super); - function IdentifierWalker(list) { - _super.call(this); - this.list = list; - } - IdentifierWalker.prototype.visitToken = function (token) { - this.list[token.text()] = true; - }; - return IdentifierWalker; - })(TypeScript.SyntaxWalker); - TypeScript.IdentifierWalker = IdentifierWalker; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var DataMap = (function () { - function DataMap() { - this.map = {}; - } - DataMap.prototype.link = function (id, data) { - this.map[id] = data; - }; - - DataMap.prototype.unlink = function (id) { - this.map[id] = undefined; - }; - - DataMap.prototype.read = function (id) { - return this.map[id]; - }; - - DataMap.prototype.flush = function () { - this.map = {}; - }; - - DataMap.prototype.unpatch = function () { - return null; - }; - return DataMap; - })(); - TypeScript.DataMap = DataMap; - - var PatchedDataMap = (function (_super) { - __extends(PatchedDataMap, _super); - function PatchedDataMap(parent) { - _super.call(this); - this.parent = parent; - this.diffs = {}; - } - PatchedDataMap.prototype.link = function (id, data) { - this.diffs[id] = data; - }; - - PatchedDataMap.prototype.unlink = function (id) { - this.diffs[id] = undefined; - }; - - PatchedDataMap.prototype.read = function (id) { - var data = this.diffs[id]; - - if (data) { - return data; - } - - return this.parent.read(id); - }; - - PatchedDataMap.prototype.flush = function () { - this.diffs = {}; - }; - - PatchedDataMap.prototype.unpatch = function () { - this.flush(); - return this.parent; - }; - return PatchedDataMap; - })(DataMap); - TypeScript.PatchedDataMap = PatchedDataMap; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (PullElementFlags) { - PullElementFlags[PullElementFlags["None"] = 0] = "None"; - PullElementFlags[PullElementFlags["Exported"] = 1] = "Exported"; - PullElementFlags[PullElementFlags["Private"] = 1 << 1] = "Private"; - PullElementFlags[PullElementFlags["Public"] = 1 << 2] = "Public"; - PullElementFlags[PullElementFlags["Ambient"] = 1 << 3] = "Ambient"; - PullElementFlags[PullElementFlags["Static"] = 1 << 4] = "Static"; - PullElementFlags[PullElementFlags["GetAccessor"] = 1 << 5] = "GetAccessor"; - PullElementFlags[PullElementFlags["SetAccessor"] = 1 << 6] = "SetAccessor"; - PullElementFlags[PullElementFlags["Optional"] = 1 << 7] = "Optional"; - PullElementFlags[PullElementFlags["Call"] = 1 << 8] = "Call"; - PullElementFlags[PullElementFlags["Constructor"] = 1 << 9] = "Constructor"; - PullElementFlags[PullElementFlags["Index"] = 1 << 10] = "Index"; - PullElementFlags[PullElementFlags["Signature"] = 1 << 11] = "Signature"; - PullElementFlags[PullElementFlags["Enum"] = 1 << 12] = "Enum"; - PullElementFlags[PullElementFlags["FatArrow"] = 1 << 13] = "FatArrow"; - - PullElementFlags[PullElementFlags["ClassConstructorVariable"] = 1 << 14] = "ClassConstructorVariable"; - PullElementFlags[PullElementFlags["InitializedModule"] = 1 << 15] = "InitializedModule"; - PullElementFlags[PullElementFlags["InitializedDynamicModule"] = 1 << 16] = "InitializedDynamicModule"; - PullElementFlags[PullElementFlags["InitializedEnum"] = 1 << 17] = "InitializedEnum"; - - PullElementFlags[PullElementFlags["MustCaptureThis"] = 1 << 18] = "MustCaptureThis"; - PullElementFlags[PullElementFlags["Constant"] = 1 << 19] = "Constant"; - - PullElementFlags[PullElementFlags["ExpressionElement"] = 1 << 20] = "ExpressionElement"; - - PullElementFlags[PullElementFlags["DeclaredInAWithBlock"] = 1 << 21] = "DeclaredInAWithBlock"; - - PullElementFlags[PullElementFlags["ImplicitVariable"] = PullElementFlags.ClassConstructorVariable | PullElementFlags.InitializedModule | PullElementFlags.InitializedDynamicModule | PullElementFlags.InitializedEnum] = "ImplicitVariable"; - PullElementFlags[PullElementFlags["SomeInitializedModule"] = PullElementFlags.InitializedModule | PullElementFlags.InitializedDynamicModule | PullElementFlags.InitializedEnum] = "SomeInitializedModule"; - })(TypeScript.PullElementFlags || (TypeScript.PullElementFlags = {})); - var PullElementFlags = TypeScript.PullElementFlags; - - (function (PullElementKind) { - PullElementKind[PullElementKind["None"] = 0] = "None"; - PullElementKind[PullElementKind["Global"] = 0] = "Global"; - - PullElementKind[PullElementKind["Script"] = 1] = "Script"; - PullElementKind[PullElementKind["Primitive"] = 1 << 1] = "Primitive"; - - PullElementKind[PullElementKind["Container"] = 1 << 2] = "Container"; - PullElementKind[PullElementKind["Class"] = 1 << 3] = "Class"; - PullElementKind[PullElementKind["Interface"] = 1 << 4] = "Interface"; - PullElementKind[PullElementKind["DynamicModule"] = 1 << 5] = "DynamicModule"; - PullElementKind[PullElementKind["Enum"] = 1 << 6] = "Enum"; - PullElementKind[PullElementKind["Array"] = 1 << 7] = "Array"; - PullElementKind[PullElementKind["TypeAlias"] = 1 << 8] = "TypeAlias"; - PullElementKind[PullElementKind["ObjectLiteral"] = 1 << 9] = "ObjectLiteral"; - - PullElementKind[PullElementKind["Variable"] = 1 << 10] = "Variable"; - PullElementKind[PullElementKind["Parameter"] = 1 << 11] = "Parameter"; - PullElementKind[PullElementKind["Property"] = 1 << 12] = "Property"; - PullElementKind[PullElementKind["TypeParameter"] = 1 << 13] = "TypeParameter"; - - PullElementKind[PullElementKind["Function"] = 1 << 14] = "Function"; - PullElementKind[PullElementKind["ConstructorMethod"] = 1 << 15] = "ConstructorMethod"; - PullElementKind[PullElementKind["Method"] = 1 << 16] = "Method"; - PullElementKind[PullElementKind["FunctionExpression"] = 1 << 17] = "FunctionExpression"; - - PullElementKind[PullElementKind["GetAccessor"] = 1 << 18] = "GetAccessor"; - PullElementKind[PullElementKind["SetAccessor"] = 1 << 19] = "SetAccessor"; - - PullElementKind[PullElementKind["CallSignature"] = 1 << 20] = "CallSignature"; - PullElementKind[PullElementKind["ConstructSignature"] = 1 << 21] = "ConstructSignature"; - PullElementKind[PullElementKind["IndexSignature"] = 1 << 22] = "IndexSignature"; - - PullElementKind[PullElementKind["ObjectType"] = 1 << 23] = "ObjectType"; - PullElementKind[PullElementKind["FunctionType"] = 1 << 24] = "FunctionType"; - PullElementKind[PullElementKind["ConstructorType"] = 1 << 25] = "ConstructorType"; - - PullElementKind[PullElementKind["EnumMember"] = 1 << 26] = "EnumMember"; - PullElementKind[PullElementKind["ErrorType"] = 1 << 27] = "ErrorType"; - - PullElementKind[PullElementKind["Expression"] = 1 << 28] = "Expression"; - - PullElementKind[PullElementKind["WithBlock"] = 1 << 29] = "WithBlock"; - PullElementKind[PullElementKind["CatchBlock"] = 1 << 30] = "CatchBlock"; - - PullElementKind[PullElementKind["All"] = PullElementKind.Script | PullElementKind.Global | PullElementKind.Primitive | PullElementKind.Container | PullElementKind.Class | PullElementKind.Interface | PullElementKind.DynamicModule | PullElementKind.Enum | PullElementKind.Array | PullElementKind.TypeAlias | PullElementKind.ObjectLiteral | PullElementKind.Variable | PullElementKind.Parameter | PullElementKind.Property | PullElementKind.TypeParameter | PullElementKind.Function | PullElementKind.ConstructorMethod | PullElementKind.Method | PullElementKind.FunctionExpression | PullElementKind.GetAccessor | PullElementKind.SetAccessor | PullElementKind.CallSignature | PullElementKind.ConstructSignature | PullElementKind.IndexSignature | PullElementKind.ObjectType | PullElementKind.FunctionType | PullElementKind.ConstructorType | PullElementKind.EnumMember | PullElementKind.ErrorType | PullElementKind.Expression | PullElementKind.WithBlock | PullElementKind.CatchBlock] = "All"; - - PullElementKind[PullElementKind["SomeFunction"] = PullElementKind.Function | PullElementKind.ConstructorMethod | PullElementKind.Method | PullElementKind.FunctionExpression | PullElementKind.GetAccessor | PullElementKind.SetAccessor | PullElementKind.CallSignature | PullElementKind.ConstructSignature | PullElementKind.IndexSignature] = "SomeFunction"; - - PullElementKind[PullElementKind["SomeValue"] = PullElementKind.Variable | PullElementKind.Parameter | PullElementKind.Property | PullElementKind.EnumMember | PullElementKind.SomeFunction] = "SomeValue"; - - PullElementKind[PullElementKind["SomeType"] = PullElementKind.Script | PullElementKind.Global | PullElementKind.Primitive | PullElementKind.Class | PullElementKind.Interface | PullElementKind.Enum | PullElementKind.Array | PullElementKind.ObjectType | PullElementKind.FunctionType | PullElementKind.ConstructorType | PullElementKind.TypeParameter | PullElementKind.ErrorType] = "SomeType"; - - PullElementKind[PullElementKind["AcceptableAlias"] = PullElementKind.Variable | PullElementKind.SomeFunction | PullElementKind.Class | PullElementKind.Interface | PullElementKind.Enum | PullElementKind.Container | PullElementKind.ObjectType | PullElementKind.FunctionType | PullElementKind.ConstructorType] = "AcceptableAlias"; - - PullElementKind[PullElementKind["SomeContainer"] = PullElementKind.Container | PullElementKind.DynamicModule | PullElementKind.TypeAlias] = "SomeContainer"; - - PullElementKind[PullElementKind["SomeBlock"] = PullElementKind.WithBlock | PullElementKind.CatchBlock] = "SomeBlock"; - - PullElementKind[PullElementKind["SomeSignature"] = PullElementKind.CallSignature | PullElementKind.ConstructSignature | PullElementKind.IndexSignature] = "SomeSignature"; - - PullElementKind[PullElementKind["SomeAccessor"] = PullElementKind.GetAccessor | PullElementKind.SetAccessor] = "SomeAccessor"; - - PullElementKind[PullElementKind["SomeTypeReference"] = PullElementKind.Interface | PullElementKind.ObjectType | PullElementKind.FunctionType | PullElementKind.ConstructorType] = "SomeTypeReference"; - - PullElementKind[PullElementKind["SomeLHS"] = PullElementKind.Variable | PullElementKind.Property | PullElementKind.Parameter | PullElementKind.SetAccessor | PullElementKind.Method] = "SomeLHS"; - - PullElementKind[PullElementKind["InterfaceTypeExtension"] = PullElementKind.Interface | PullElementKind.Class | PullElementKind.Enum] = "InterfaceTypeExtension"; - PullElementKind[PullElementKind["ClassTypeExtension"] = PullElementKind.Interface | PullElementKind.Class] = "ClassTypeExtension"; - PullElementKind[PullElementKind["EnumTypeExtension"] = PullElementKind.Interface | PullElementKind.Enum] = "EnumTypeExtension"; - })(TypeScript.PullElementKind || (TypeScript.PullElementKind = {})); - var PullElementKind = TypeScript.PullElementKind; - - (function (SymbolLinkKind) { - SymbolLinkKind[SymbolLinkKind["TypedAs"] = 0] = "TypedAs"; - SymbolLinkKind[SymbolLinkKind["ContextuallyTypedAs"] = 1] = "ContextuallyTypedAs"; - SymbolLinkKind[SymbolLinkKind["ProvidesInferredType"] = 2] = "ProvidesInferredType"; - SymbolLinkKind[SymbolLinkKind["ArrayType"] = 3] = "ArrayType"; - - SymbolLinkKind[SymbolLinkKind["ArrayOf"] = 4] = "ArrayOf"; - - SymbolLinkKind[SymbolLinkKind["PublicMember"] = 5] = "PublicMember"; - SymbolLinkKind[SymbolLinkKind["PrivateMember"] = 6] = "PrivateMember"; - - SymbolLinkKind[SymbolLinkKind["ConstructorMethod"] = 7] = "ConstructorMethod"; - - SymbolLinkKind[SymbolLinkKind["Aliases"] = 8] = "Aliases"; - SymbolLinkKind[SymbolLinkKind["ExportAliases"] = 9] = "ExportAliases"; - - SymbolLinkKind[SymbolLinkKind["ContainedBy"] = 10] = "ContainedBy"; - - SymbolLinkKind[SymbolLinkKind["Extends"] = 11] = "Extends"; - SymbolLinkKind[SymbolLinkKind["Implements"] = 12] = "Implements"; - - SymbolLinkKind[SymbolLinkKind["Parameter"] = 13] = "Parameter"; - SymbolLinkKind[SymbolLinkKind["ReturnType"] = 14] = "ReturnType"; - - SymbolLinkKind[SymbolLinkKind["CallSignature"] = 15] = "CallSignature"; - SymbolLinkKind[SymbolLinkKind["ConstructSignature"] = 16] = "ConstructSignature"; - SymbolLinkKind[SymbolLinkKind["IndexSignature"] = 17] = "IndexSignature"; - - SymbolLinkKind[SymbolLinkKind["TypeParameter"] = 18] = "TypeParameter"; - SymbolLinkKind[SymbolLinkKind["TypeArgument"] = 19] = "TypeArgument"; - SymbolLinkKind[SymbolLinkKind["TypeParameterSpecializedTo"] = 20] = "TypeParameterSpecializedTo"; - SymbolLinkKind[SymbolLinkKind["SpecializedTo"] = 21] = "SpecializedTo"; - - SymbolLinkKind[SymbolLinkKind["TypeConstraint"] = 22] = "TypeConstraint"; - - SymbolLinkKind[SymbolLinkKind["ContributesToExpression"] = 23] = "ContributesToExpression"; - - SymbolLinkKind[SymbolLinkKind["GetterFunction"] = 24] = "GetterFunction"; - SymbolLinkKind[SymbolLinkKind["SetterFunction"] = 25] = "SetterFunction"; - })(TypeScript.SymbolLinkKind || (TypeScript.SymbolLinkKind = {})); - var SymbolLinkKind = TypeScript.SymbolLinkKind; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - TypeScript.pullDeclID = 0; - TypeScript.lastBoundPullDeclId = 0; - - var PullDecl = (function () { - function PullDecl(declName, displayName, declType, declFlags, span, scriptName) { - this.symbol = null; - this.declGroups = new TypeScript.BlockIntrinsics(); - this.signatureSymbol = null; - this.specializingSignatureSymbol = null; - this.childDecls = []; - this.typeParameters = []; - this.childDeclTypeCache = new TypeScript.BlockIntrinsics(); - this.childDeclValueCache = new TypeScript.BlockIntrinsics(); - this.childDeclNamespaceCache = new TypeScript.BlockIntrinsics(); - this.childDeclTypeParameterCache = new TypeScript.BlockIntrinsics(); - this.declID = TypeScript.pullDeclID++; - this.declFlags = 0 /* None */; - this.diagnostics = null; - this.parentDecl = null; - this._parentPath = null; - this._isBound = false; - this.synthesizedValDecl = null; - this.declName = declName; - this.declType = declType; - this.declFlags = declFlags; - this.span = span; - this.scriptName = scriptName; - - if (displayName !== this.declName) { - this.declDisplayName = displayName; - } - } - PullDecl.prototype.getDeclID = function () { - return this.declID; - }; - - PullDecl.prototype.getName = function () { - return this.declName; - }; - PullDecl.prototype.getKind = function () { - return this.declType; - }; - - PullDecl.prototype.getDisplayName = function () { - return this.declDisplayName === undefined ? this.declName : this.declDisplayName; - }; - - PullDecl.prototype.setSymbol = function (symbol) { - this.symbol = symbol; - }; - - PullDecl.prototype.ensureSymbolIsBound = function (bindSignatureSymbol) { - if (typeof bindSignatureSymbol === "undefined") { bindSignatureSymbol = false; } - if (!((bindSignatureSymbol && this.signatureSymbol) || this.symbol) && !this._isBound && this.declType != 1 /* Script */) { - var prevUnit = TypeScript.globalBinder.semanticInfo; - TypeScript.globalBinder.setUnit(this.scriptName); - TypeScript.globalBinder.bindDeclToPullSymbol(this); - if (prevUnit) { - TypeScript.globalBinder.setUnit(prevUnit.getPath()); - } - } - }; - - PullDecl.prototype.getSymbol = function () { - if (this.declType == 1 /* Script */) { - return null; - } - - this.ensureSymbolIsBound(); - - return this.symbol; - }; - - PullDecl.prototype.hasSymbol = function () { - return this.symbol != null; - }; - - PullDecl.prototype.setSignatureSymbol = function (signature) { - this.signatureSymbol = signature; - }; - PullDecl.prototype.getSignatureSymbol = function () { - this.ensureSymbolIsBound(true); - - return this.signatureSymbol; - }; - - PullDecl.prototype.hasSignature = function () { - return this.signatureSymbol != null; - }; - - PullDecl.prototype.setSpecializingSignatureSymbol = function (signature) { - this.specializingSignatureSymbol = signature; - }; - PullDecl.prototype.getSpecializingSignatureSymbol = function () { - if (this.specializingSignatureSymbol) { - return this.specializingSignatureSymbol; - } - - return this.signatureSymbol; - }; - - PullDecl.prototype.getFlags = function () { - return this.declFlags; - }; - PullDecl.prototype.setFlags = function (flags) { - this.declFlags = flags; - }; - - PullDecl.prototype.getSpan = function () { - return this.span; - }; - PullDecl.prototype.setSpan = function (span) { - this.span = span; - }; - - PullDecl.prototype.getScriptName = function () { - return this.scriptName; - }; - - PullDecl.prototype.setValueDecl = function (valDecl) { - this.synthesizedValDecl = valDecl; - }; - PullDecl.prototype.getValueDecl = function () { - return this.synthesizedValDecl; - }; - - PullDecl.prototype.isEqual = function (other) { - return (this.declName === other.declName) && (this.declType === other.declType) && (this.declFlags === other.declFlags) && (this.scriptName === other.scriptName) && (this.span.start() === other.span.start()) && (this.span.end() === other.span.end()); - }; - - PullDecl.prototype.getParentDecl = function () { - return this.parentDecl; - }; - - PullDecl.prototype.setParentDecl = function (parentDecl) { - this.parentDecl = parentDecl; - }; - - PullDecl.prototype.addDiagnostic = function (diagnostic) { - if (diagnostic) { - if (!this.diagnostics) { - this.diagnostics = []; - } - - this.diagnostics[this.diagnostics.length] = diagnostic; - } - }; - - PullDecl.prototype.getDiagnostics = function () { - return this.diagnostics; - }; - - PullDecl.prototype.setErrors = function (diagnostics) { - if (diagnostics) { - this.diagnostics = []; - - for (var i = 0; i < diagnostics.length; i++) { - diagnostics[i].adjustOffset(this.span.start()); - this.diagnostics[this.diagnostics.length] = diagnostics[i]; - } - } - }; - - PullDecl.prototype.resetErrors = function () { - this.diagnostics = []; - }; - - PullDecl.prototype.getChildDeclCache = function (declKind) { - return declKind === 8192 /* TypeParameter */ ? this.childDeclTypeParameterCache : TypeScript.hasFlag(declKind, TypeScript.PullElementKind.SomeContainer) ? this.childDeclNamespaceCache : TypeScript.hasFlag(declKind, TypeScript.PullElementKind.SomeType) ? this.childDeclTypeCache : this.childDeclValueCache; - }; - - PullDecl.prototype.addChildDecl = function (childDecl) { - if (childDecl.getKind() === 8192 /* TypeParameter */) { - this.typeParameters[this.typeParameters.length] = childDecl; - } else { - this.childDecls[this.childDecls.length] = childDecl; - } - - var declName = childDecl.getName(); - var cache = this.getChildDeclCache(childDecl.getKind()); - var childrenOfName = cache[declName]; - if (!childrenOfName) { - childrenOfName = []; - } - - childrenOfName.push(childDecl); - cache[declName] = childrenOfName; - }; - - PullDecl.prototype.searchChildDecls = function (declName, searchKind) { - var cache = (searchKind & TypeScript.PullElementKind.SomeType) ? this.childDeclTypeCache : (searchKind & TypeScript.PullElementKind.SomeContainer) ? this.childDeclNamespaceCache : this.childDeclValueCache; - - var cacheVal = cache[declName]; - - if (cacheVal) { - return cacheVal; - } else { - if (searchKind & TypeScript.PullElementKind.SomeType) { - cacheVal = this.childDeclTypeParameterCache[declName]; - - if (cacheVal) { - return cacheVal; - } - } - - return []; - } - }; - - PullDecl.prototype.getChildDecls = function () { - return this.childDecls; - }; - PullDecl.prototype.getTypeParameters = function () { - return this.typeParameters; - }; - - PullDecl.prototype.addVariableDeclToGroup = function (decl) { - var declGroup = this.declGroups[decl.getName()]; - if (declGroup) { - declGroup.addDecl(decl); - } else { - declGroup = new PullDeclGroup(decl.getName()); - declGroup.addDecl(decl); - this.declGroups[decl.getName()] = declGroup; - } - }; - - PullDecl.prototype.getVariableDeclGroups = function () { - var declGroups = []; - - for (var declName in this.declGroups) { - if (this.declGroups[declName]) { - declGroups[declGroups.length] = this.declGroups[declName].getDecls(); - } - } - - return declGroups; - }; - - PullDecl.prototype.getParentPath = function () { - return this._parentPath; - }; - - PullDecl.prototype.setParentPath = function (path) { - this._parentPath = path; - }; - - PullDecl.prototype.setIsBound = function (isBinding) { - this._isBound = isBinding; - }; - - PullDecl.prototype.isBound = function () { - return this._isBound; - }; - return PullDecl; - })(); - TypeScript.PullDecl = PullDecl; - - var PullFunctionExpressionDecl = (function (_super) { - __extends(PullFunctionExpressionDecl, _super); - function PullFunctionExpressionDecl(expressionName, declFlags, span, scriptName) { - _super.call(this, "", "", 131072 /* FunctionExpression */, declFlags, span, scriptName); - this.functionExpressionName = expressionName; - } - PullFunctionExpressionDecl.prototype.getFunctionExpressionName = function () { - return this.functionExpressionName; - }; - return PullFunctionExpressionDecl; - })(PullDecl); - TypeScript.PullFunctionExpressionDecl = PullFunctionExpressionDecl; - - var PullDeclGroup = (function () { - function PullDeclGroup(name) { - this.name = name; - this._decls = []; - } - PullDeclGroup.prototype.addDecl = function (decl) { - if (decl.getName() === this.name) { - this._decls[this._decls.length] = decl; - } - }; - - PullDeclGroup.prototype.getDecls = function () { - return this._decls; - }; - return PullDeclGroup; - })(); - TypeScript.PullDeclGroup = PullDeclGroup; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - TypeScript.pullSymbolID = 0; - TypeScript.lastBoundPullSymbolID = 0; - TypeScript.globalTyvarID = 0; - - var PullSymbol = (function () { - function PullSymbol(name, declKind) { - this.pullSymbolID = TypeScript.pullSymbolID++; - this.outgoingLinks = new TypeScript.LinkList(); - this.incomingLinks = new TypeScript.LinkList(); - this.declarations = new TypeScript.LinkList(); - this.cachedPathIDs = {}; - this.cachedContainerLink = null; - this.cachedTypeLink = null; - this.cachedDeclarations = null; - this.hasBeenResolved = false; - this.isOptional = false; - this.inResolution = false; - this.isSynthesized = false; - this.isBound = false; - this.rebindingID = 0; - this.isVarArg = false; - this.isSpecialized = false; - this.isBeingSpecialized = false; - this.rootSymbol = null; - this.typeChangeUpdateVersion = -1; - this.addUpdateVersion = -1; - this.removeUpdateVersion = -1; - this.docComments = null; - this.isPrinting = false; - this.name = name; - this.declKind = declKind; - } - PullSymbol.prototype.getSymbolID = function () { - return this.pullSymbolID; - }; - - PullSymbol.prototype.isType = function () { - return (this.declKind & TypeScript.PullElementKind.SomeType) != 0; - }; - - PullSymbol.prototype.isSignature = function () { - return (this.declKind & TypeScript.PullElementKind.SomeSignature) != 0; - }; - - PullSymbol.prototype.isArray = function () { - return (this.declKind & 128 /* Array */) != 0; - }; - - PullSymbol.prototype.isPrimitive = function () { - return this.declKind === 2 /* Primitive */; - }; - - PullSymbol.prototype.isAccessor = function () { - return false; - }; - - PullSymbol.prototype.isError = function () { - return false; - }; - - PullSymbol.prototype.isAlias = function () { - return false; - }; - PullSymbol.prototype.isContainer = function () { - return false; - }; - - PullSymbol.prototype.findAliasedType = function (decls) { - for (var i = 0; i < decls.length; i++) { - var childDecls = decls[i].getChildDecls(); - for (var j = 0; j < childDecls.length; j++) { - if (childDecls[j].getKind() === 256 /* TypeAlias */) { - var symbol = childDecls[j].getSymbol(); - if (PullContainerTypeSymbol.usedAsSymbol(symbol, this)) { - return symbol; - } - } - } - } - - return null; - }; - - PullSymbol.prototype.getAliasedSymbol = function (scopeSymbol) { - if (!scopeSymbol) { - return null; - } - - var scopePath = scopeSymbol.pathToRoot(); - if (scopePath.length && scopePath[scopePath.length - 1].getKind() === 32 /* DynamicModule */) { - var decls = scopePath[scopePath.length - 1].getDeclarations(); - var symbol = this.findAliasedType(decls); - return symbol; - } - - return null; - }; - - PullSymbol.prototype.getName = function (scopeSymbol, useConstraintInName) { - var symbol = this.getAliasedSymbol(scopeSymbol); - if (symbol) { - return symbol.getName(); - } - - return this.name; - }; - - PullSymbol.prototype.getDisplayName = function (scopeSymbol, useConstraintInName) { - var symbol = this.getAliasedSymbol(scopeSymbol); - if (symbol) { - return symbol.getDisplayName(); - } - - return this.getDeclarations()[0].getDisplayName(); - }; - - PullSymbol.prototype.getKind = function () { - return this.declKind; - }; - PullSymbol.prototype.setKind = function (declType) { - this.declKind = declType; - }; - - PullSymbol.prototype.setIsOptional = function () { - this.isOptional = true; - }; - PullSymbol.prototype.getIsOptional = function () { - return this.isOptional; - }; - - PullSymbol.prototype.getIsVarArg = function () { - return this.isVarArg; - }; - PullSymbol.prototype.setIsVarArg = function () { - this.isVarArg = true; - }; - - PullSymbol.prototype.setIsSynthesized = function () { - this.isSynthesized = true; - }; - PullSymbol.prototype.getIsSynthesized = function () { - return this.isSynthesized; - }; - - PullSymbol.prototype.setIsSpecialized = function () { - this.isSpecialized = true; - this.isBeingSpecialized = false; - }; - PullSymbol.prototype.getIsSpecialized = function () { - return this.isSpecialized; - }; - PullSymbol.prototype.currentlyBeingSpecialized = function () { - return this.isBeingSpecialized; - }; - PullSymbol.prototype.setIsBeingSpecialized = function () { - this.isBeingSpecialized = true; - }; - PullSymbol.prototype.setValueIsBeingSpecialized = function (val) { - this.isBeingSpecialized = val; - }; - - PullSymbol.prototype.getRootSymbol = function () { - if (!this.rootSymbol) { - return this; - } - return this.rootSymbol; - }; - PullSymbol.prototype.setRootSymbol = function (symbol) { - this.rootSymbol = symbol; - }; - - PullSymbol.prototype.setIsBound = function (rebindingID) { - this.isBound = true; - this.rebindingID = rebindingID; - }; - - PullSymbol.prototype.getRebindingID = function () { - return this.rebindingID; - }; - - PullSymbol.prototype.getIsBound = function () { - return this.isBound; - }; - - PullSymbol.prototype.addCacheID = function (cacheID) { - if (!this.cachedPathIDs[cacheID]) { - this.cachedPathIDs[cacheID] = true; - } - }; - - PullSymbol.prototype.invalidateCachedIDs = function (cache) { - for (var id in this.cachedPathIDs) { - if (cache[id]) { - cache[id] = undefined; - } - } - }; - - PullSymbol.prototype.addDeclaration = function (decl) { - TypeScript.Debug.assert(!!decl); - - if (this.rootSymbol) { - return; - } - - this.declarations.addItem(decl); - - if (!this.cachedDeclarations) { - this.cachedDeclarations = [decl]; - } else { - this.cachedDeclarations[this.cachedDeclarations.length] = decl; - } - }; - - PullSymbol.prototype.getDeclarations = function () { - if (this.rootSymbol) { - return this.rootSymbol.getDeclarations(); - } - - if (!this.cachedDeclarations) { - this.cachedDeclarations = []; - } - - return this.cachedDeclarations; - }; - - PullSymbol.prototype.removeDeclaration = function (decl) { - if (this.rootSymbol) { - return; - } - - this.declarations.remove(function (d) { - return d === decl; - }); - this.cachedDeclarations = this.declarations.find(function (d) { - return d; - }); - }; - - PullSymbol.prototype.updateDeclarations = function (map, context) { - if (this.rootSymbol) { - return; - } - - this.declarations.update(map, context); - }; - - PullSymbol.prototype.addOutgoingLink = function (linkTo, kind) { - var link = new TypeScript.PullSymbolLink(this, linkTo, kind); - this.outgoingLinks.addItem(link); - linkTo.incomingLinks.addItem(link); - - return link; - }; - - PullSymbol.prototype.findOutgoingLinks = function (p) { - return this.outgoingLinks.find(p); - }; - - PullSymbol.prototype.findIncomingLinks = function (p) { - return this.incomingLinks.find(p); - }; - - PullSymbol.prototype.removeOutgoingLink = function (link) { - if (link) { - this.outgoingLinks.remove(function (p) { - return p === link; - }); - - if (link.end.incomingLinks) { - link.end.incomingLinks.remove(function (p) { - return p === link; - }); - } - } - }; - - PullSymbol.prototype.updateOutgoingLinks = function (map, context) { - if (this.outgoingLinks) { - this.outgoingLinks.update(map, context); - } - }; - - PullSymbol.prototype.updateIncomingLinks = function (map, context) { - if (this.incomingLinks) { - this.incomingLinks.update(map, context); - } - }; - - PullSymbol.prototype.removeAllLinks = function () { - var _this = this; - this.updateOutgoingLinks(function (item) { - return _this.removeOutgoingLink(item); - }, null); - this.updateIncomingLinks(function (item) { - return item.start.removeOutgoingLink(item); - }, null); - }; - - PullSymbol.prototype.setContainer = function (containerSymbol) { - var link = this.addOutgoingLink(containerSymbol, 10 /* ContainedBy */); - this.cachedContainerLink = link; - - containerSymbol.addContainedByLink(link); - }; - - PullSymbol.prototype.getContainer = function () { - if (this.cachedContainerLink) { - return this.cachedContainerLink.end; - } - - if (this.getIsSpecialized()) { - var specializations = this.findIncomingLinks(function (symbolLink) { - return symbolLink.kind == 21 /* SpecializedTo */; - }); - if (specializations.length == 1) { - return specializations[0].start.getContainer(); - } - } - - return null; - }; - - PullSymbol.prototype.unsetContainer = function () { - if (this.cachedContainerLink) { - this.removeOutgoingLink(this.cachedContainerLink); - } - - this.invalidate(); - }; - - PullSymbol.prototype.setType = function (typeRef) { - if (this.cachedTypeLink) { - this.unsetType(); - } - - this.cachedTypeLink = this.addOutgoingLink(typeRef, 0 /* TypedAs */); - }; - - PullSymbol.prototype.getType = function () { - if (this.cachedTypeLink) { - return this.cachedTypeLink.end; - } - - return null; - }; - - PullSymbol.prototype.unsetType = function () { - var foundType = false; - - if (this.cachedTypeLink) { - this.removeOutgoingLink(this.cachedTypeLink); - foundType = true; - } - - if (foundType) { - this.invalidate(); - } - }; - - PullSymbol.prototype.isTyped = function () { - return this.getType() != null; - }; - - PullSymbol.prototype.setResolved = function () { - this.hasBeenResolved = true; - this.inResolution = false; - }; - PullSymbol.prototype.isResolved = function () { - return this.hasBeenResolved; - }; - - PullSymbol.prototype.startResolving = function () { - this.inResolution = true; - }; - PullSymbol.prototype.isResolving = function () { - return this.inResolution; - }; - - PullSymbol.prototype.setUnresolved = function () { - this.hasBeenResolved = false; - this.isBound = false; - this.inResolution = false; - }; - - PullSymbol.prototype.invalidate = function () { - this.docComments = null; - - this.hasBeenResolved = false; - this.isBound = false; - - this.declarations.update(function (pullDecl) { - return pullDecl.resetErrors(); - }, null); - }; - - PullSymbol.prototype.hasFlag = function (flag) { - var declarations = this.getDeclarations(); - for (var i = 0, n = declarations.length; i < n; i++) { - if ((declarations[i].getFlags() & flag) !== 0 /* None */) { - return true; - } - } - return false; - }; - - PullSymbol.prototype.allDeclsHaveFlag = function (flag) { - var declarations = this.getDeclarations(); - for (var i = 0, n = declarations.length; i < n; i++) { - if (!((declarations[i].getFlags() & flag) !== 0 /* None */)) { - return false; - } - } - return true; - }; - - PullSymbol.prototype.pathToRoot = function () { - var path = []; - var node = this; - while (node) { - if (node.isType()) { - var associatedContainerSymbol = (node).getAssociatedContainerType(); - if (associatedContainerSymbol) { - node = associatedContainerSymbol; - } - } - path[path.length] = node; - node = node.getContainer(); - } - return path; - }; - - PullSymbol.prototype.findCommonAncestorPath = function (b) { - var aPath = this.pathToRoot(); - if (aPath.length === 1) { - return aPath; - } - - var bPath; - if (b) { - bPath = b.pathToRoot(); - } else { - return aPath; - } - - var commonNodeIndex = -1; - for (var i = 0, aLen = aPath.length; i < aLen; i++) { - var aNode = aPath[i]; - for (var j = 0, bLen = bPath.length; j < bLen; j++) { - var bNode = bPath[j]; - if (aNode === bNode) { - var aDecl = null; - if (i > 0) { - var decls = aPath[i - 1].getDeclarations(); - if (decls.length) { - aDecl = decls[0].getParentDecl(); - } - } - var bDecl = null; - if (j > 0) { - var decls = bPath[j - 1].getDeclarations(); - if (decls.length) { - bDecl = decls[0].getParentDecl(); - } - } - if (!aDecl || !bDecl || aDecl == bDecl) { - commonNodeIndex = i; - break; - } - } - } - if (commonNodeIndex >= 0) { - break; - } - } - - if (commonNodeIndex >= 0) { - return aPath.slice(0, commonNodeIndex); - } else { - return aPath; - } - }; - - PullSymbol.prototype.toString = function (useConstraintInName) { - var str = this.getNameAndTypeName(); - return str; - }; - - PullSymbol.prototype.getNamePartForFullName = function () { - return this.getDisplayName(null, true); - }; - - PullSymbol.prototype.fullName = function (scopeSymbol) { - var path = this.pathToRoot(); - var fullName = ""; - var aliasedSymbol = this.getAliasedSymbol(scopeSymbol); - if (aliasedSymbol) { - return aliasedSymbol.getDisplayName(); - } - - for (var i = 1; i < path.length; i++) { - aliasedSymbol = path[i].getAliasedSymbol(scopeSymbol); - if (aliasedSymbol) { - fullName = aliasedSymbol.getDisplayName() + "." + fullName; - break; - } else { - var scopedName = path[i].getNamePartForFullName(); - if (path[i].getKind() == 32 /* DynamicModule */ && !TypeScript.isQuoted(scopedName)) { - break; - } - - if (scopedName === "") { - break; - } - - fullName = scopedName + "." + fullName; - } - } - - fullName = fullName + this.getNamePartForFullName(); - return fullName; - }; - - PullSymbol.prototype.getScopedName = function (scopeSymbol, useConstraintInName) { - var path = this.findCommonAncestorPath(scopeSymbol); - var fullName = ""; - var aliasedSymbol = this.getAliasedSymbol(scopeSymbol); - if (aliasedSymbol) { - return aliasedSymbol.getDisplayName(); - } - - for (var i = 1; i < path.length; i++) { - var kind = path[i].getKind(); - if (kind === 4 /* Container */ || kind === 32 /* DynamicModule */) { - aliasedSymbol = path[i].getAliasedSymbol(scopeSymbol); - if (aliasedSymbol) { - fullName = aliasedSymbol.getDisplayName() + "." + fullName; - break; - } else if (kind === 4 /* Container */) { - fullName = path[i].getDisplayName() + "." + fullName; - } else { - var displayName = path[i].getDisplayName(); - if (TypeScript.isQuoted(displayName)) { - fullName = displayName + "." + fullName; - } - break; - } - } else { - break; - } - } - fullName = fullName + this.getDisplayName(scopeSymbol, useConstraintInName); - return fullName; - }; - - PullSymbol.prototype.getScopedNameEx = function (scopeSymbol, useConstraintInName, getPrettyTypeName, getTypeParamMarkerInfo) { - var name = this.getScopedName(scopeSymbol, useConstraintInName); - return TypeScript.MemberName.create(name); - }; - - PullSymbol.prototype.getTypeName = function (scopeSymbol, getPrettyTypeName) { - var memberName = this.getTypeNameEx(scopeSymbol, getPrettyTypeName); - return memberName.toString(); - }; - - PullSymbol.prototype.getTypeNameEx = function (scopeSymbol, getPrettyTypeName) { - var type = this.getType(); - if (type) { - var memberName = getPrettyTypeName ? this.getTypeNameForFunctionSignature("", scopeSymbol, getPrettyTypeName) : null; - if (!memberName) { - memberName = type.getScopedNameEx(scopeSymbol, true, getPrettyTypeName); - } - - return memberName; - } - return TypeScript.MemberName.create(""); - }; - - PullSymbol.prototype.getTypeNameForFunctionSignature = function (prefix, scopeSymbol, getPrettyTypeName) { - var type = this.getType(); - if (type && !type.isNamedTypeSymbol() && this.declKind != 4096 /* Property */ && this.declKind != 1024 /* Variable */ && this.declKind != 2048 /* Parameter */) { - var signatures = type.getCallSignatures(); - var typeName = new TypeScript.MemberNameArray(); - var signatureName = PullSignatureSymbol.getSignaturesTypeNameEx(signatures, prefix, false, false, scopeSymbol, getPrettyTypeName); - typeName.addAll(signatureName); - return typeName; - } - - return null; - }; - - PullSymbol.prototype.getNameAndTypeName = function (scopeSymbol) { - var nameAndTypeName = this.getNameAndTypeNameEx(scopeSymbol); - return nameAndTypeName.toString(); - }; - - PullSymbol.prototype.getNameAndTypeNameEx = function (scopeSymbol) { - var type = this.getType(); - var nameEx = this.getScopedNameEx(scopeSymbol); - if (type) { - var nameStr = nameEx.toString() + (this.getIsOptional() ? "?" : ""); - var memberName = this.getTypeNameForFunctionSignature(nameStr, scopeSymbol); - if (!memberName) { - var typeNameEx = type.getScopedNameEx(scopeSymbol); - memberName = TypeScript.MemberName.create(typeNameEx, nameStr + ": ", ""); - } - return memberName; - } - return nameEx; - }; - - PullSymbol.getTypeParameterString = function (typars, scopeSymbol, useContraintInName) { - return PullSymbol.getTypeParameterStringEx(typars, scopeSymbol, undefined, useContraintInName).toString(); - }; - - PullSymbol.getTypeParameterStringEx = function (typeParameters, scopeSymbol, getTypeParamMarkerInfo, useContraintInName) { - var builder = new TypeScript.MemberNameArray(); - builder.prefix = ""; - - if (typeParameters && typeParameters.length) { - builder.add(TypeScript.MemberName.create("<")); - - for (var i = 0; i < typeParameters.length; i++) { - if (i) { - builder.add(TypeScript.MemberName.create(", ")); - } - - if (getTypeParamMarkerInfo) { - builder.add(new TypeScript.MemberName()); - } - - builder.add(typeParameters[i].getScopedNameEx(scopeSymbol, useContraintInName)); - - if (getTypeParamMarkerInfo) { - builder.add(new TypeScript.MemberName()); - } - } - - builder.add(TypeScript.MemberName.create(">")); - } - - return builder; - }; - - PullSymbol.getIsExternallyVisible = function (symbol, fromIsExternallyVisibleSymbol, inIsExternallyVisibleSymbols) { - if (inIsExternallyVisibleSymbols) { - for (var i = 0; i < inIsExternallyVisibleSymbols.length; i++) { - if (inIsExternallyVisibleSymbols[i] === symbol) { - return true; - } - } - } else { - inIsExternallyVisibleSymbols = []; - } - - if (fromIsExternallyVisibleSymbol === symbol) { - return true; - } - inIsExternallyVisibleSymbols = inIsExternallyVisibleSymbols.concat(fromIsExternallyVisibleSymbol); - - return symbol.isExternallyVisible(inIsExternallyVisibleSymbols); - }; - - PullSymbol.prototype.isExternallyVisible = function (inIsExternallyVisibleSymbols) { - var kind = this.getKind(); - if (kind === 2 /* Primitive */) { - return true; - } - - if (this.isType()) { - var associatedContainerSymbol = (this).getAssociatedContainerType(); - if (associatedContainerSymbol) { - return PullSymbol.getIsExternallyVisible(associatedContainerSymbol, this, inIsExternallyVisibleSymbols); - } - } - - if (this.hasFlag(2 /* Private */)) { - return false; - } - - var container = this.getContainer(); - if (container === null) { - return true; - } - - if (container.getKind() == 32 /* DynamicModule */ || (container.getAssociatedContainerType() && container.getAssociatedContainerType().getKind() == 32 /* DynamicModule */)) { - var containerTypeSymbol = container.getKind() == 32 /* DynamicModule */ ? container : container.getAssociatedContainerType(); - if (PullContainerTypeSymbol.usedAsSymbol(containerTypeSymbol, this)) { - return true; - } - } - - if (!this.hasFlag(1 /* Exported */) && kind != 4096 /* Property */ && kind != 65536 /* Method */) { - return false; - } - - return PullSymbol.getIsExternallyVisible(container, this, inIsExternallyVisibleSymbols); - }; - return PullSymbol; - })(); - TypeScript.PullSymbol = PullSymbol; - - var PullExpressionSymbol = (function (_super) { - __extends(PullExpressionSymbol, _super); - function PullExpressionSymbol() { - _super.call(this, "", 268435456 /* Expression */); - this.contributingSymbols = []; - } - PullExpressionSymbol.prototype.addContributingSymbol = function (symbol) { - var link = this.addOutgoingLink(symbol, 23 /* ContributesToExpression */); - - this.contributingSymbols[this.contributingSymbols.length] = symbol; - }; - - PullExpressionSymbol.prototype.getContributingSymbols = function () { - return this.contributingSymbols; - }; - return PullExpressionSymbol; - })(PullSymbol); - TypeScript.PullExpressionSymbol = PullExpressionSymbol; - - var PullSignatureSymbol = (function (_super) { - __extends(PullSignatureSymbol, _super); - function PullSignatureSymbol(kind) { - _super.call(this, "", kind); - this.parameterLinks = null; - this.typeParameterLinks = null; - this.returnTypeLink = null; - this.hasOptionalParam = false; - this.nonOptionalParamCount = 0; - this.hasVarArgs = false; - this.specializationCache = {}; - this.memberTypeParameterNameCache = null; - this.hasAGenericParameter = false; - this.stringConstantOverload = undefined; - } - PullSignatureSymbol.prototype.isDefinition = function () { - return false; - }; - - PullSignatureSymbol.prototype.hasVariableParamList = function () { - return this.hasVarArgs; - }; - PullSignatureSymbol.prototype.setHasVariableParamList = function () { - this.hasVarArgs = true; - }; - - PullSignatureSymbol.prototype.setHasGenericParameter = function () { - this.hasAGenericParameter = true; - }; - PullSignatureSymbol.prototype.hasGenericParameter = function () { - return this.hasAGenericParameter; - }; - - PullSignatureSymbol.prototype.isGeneric = function () { - return this.hasAGenericParameter || (this.typeParameterLinks && this.typeParameterLinks.length != 0); - }; - - PullSignatureSymbol.prototype.addParameter = function (parameter, isOptional) { - if (typeof isOptional === "undefined") { isOptional = false; } - if (!this.parameterLinks) { - this.parameterLinks = []; - } - - var link = this.addOutgoingLink(parameter, 13 /* Parameter */); - this.parameterLinks[this.parameterLinks.length] = link; - this.hasOptionalParam = isOptional; - - if (!isOptional) { - this.nonOptionalParamCount++; - } - }; - - PullSignatureSymbol.prototype.addSpecialization = function (signature, typeArguments) { - if (typeArguments && typeArguments.length) { - this.specializationCache[getIDForTypeSubstitutions(typeArguments)] = signature; - } - }; - - PullSignatureSymbol.prototype.getSpecialization = function (typeArguments) { - if (typeArguments) { - var sig = this.specializationCache[getIDForTypeSubstitutions(typeArguments)]; - - if (sig) { - return sig; - } - } - - return null; - }; - - PullSignatureSymbol.prototype.addTypeParameter = function (parameter) { - if (!this.typeParameterLinks) { - this.typeParameterLinks = []; - } - - if (!this.memberTypeParameterNameCache) { - this.memberTypeParameterNameCache = new TypeScript.BlockIntrinsics(); - } - - var link = this.addOutgoingLink(parameter, 18 /* TypeParameter */); - this.typeParameterLinks[this.typeParameterLinks.length] = link; - - this.memberTypeParameterNameCache[link.end.getName()] = link.end; - }; - - PullSignatureSymbol.prototype.getNonOptionalParameterCount = function () { - return this.nonOptionalParamCount; - }; - - PullSignatureSymbol.prototype.setReturnType = function (returnType) { - if (returnType) { - if (this.returnTypeLink) { - this.removeOutgoingLink(this.returnTypeLink); - } - this.returnTypeLink = this.addOutgoingLink(returnType, 14 /* ReturnType */); - } - }; - - PullSignatureSymbol.prototype.getParameters = function () { - var params = []; - - if (this.parameterLinks) { - for (var i = 0; i < this.parameterLinks.length; i++) { - params[params.length] = this.parameterLinks[i].end; - } - } - - return params; - }; - - PullSignatureSymbol.prototype.getTypeParameters = function () { - var params = []; - - if (this.typeParameterLinks) { - for (var i = 0; i < this.typeParameterLinks.length; i++) { - params[params.length] = this.typeParameterLinks[i].end; - } - } - - return params; - }; - - PullSignatureSymbol.prototype.findTypeParameter = function (name) { - var memberSymbol; - - if (!this.memberTypeParameterNameCache) { - this.memberTypeParameterNameCache = new TypeScript.BlockIntrinsics(); - - if (this.typeParameterLinks) { - for (var i = 0; i < this.typeParameterLinks.length; i++) { - this.memberTypeParameterNameCache[this.typeParameterLinks[i].end.getName()] = this.typeParameterLinks[i].end; - } - } - } - - memberSymbol = this.memberTypeParameterNameCache[name]; - - return memberSymbol; - }; - - PullSignatureSymbol.prototype.removeParameter = function (parameterSymbol) { - var paramLink; - - if (this.parameterLinks) { - for (var i = 0; i < this.parameterLinks.length; i++) { - if (parameterSymbol === this.parameterLinks[i].end) { - paramLink = this.parameterLinks[i]; - this.removeOutgoingLink(paramLink); - break; - } - } - } - - this.invalidate(); - }; - - PullSignatureSymbol.prototype.mimicSignature = function (signature, resolver) { - var typeParameters = signature.getTypeParameters(); - var typeParameter; - - if (typeParameters) { - for (var i = 0; i < typeParameters.length; i++) { - this.addTypeParameter(typeParameters[i]); - } - } - - var parameters = signature.getParameters(); - var parameter; - - if (parameters) { - for (var j = 0; j < parameters.length; j++) { - parameter = new PullSymbol(parameters[j].getName(), 2048 /* Parameter */); - parameter.setRootSymbol(parameters[j]); - - if (parameters[j].getIsOptional()) { - parameter.setIsOptional(); - } - if (parameters[j].getIsVarArg()) { - parameter.setIsVarArg(); - this.setHasVariableParamList(); - } - this.addParameter(parameter); - } - } - - var returnType = signature.getReturnType(); - - if (!resolver.isTypeArgumentOrWrapper(returnType)) { - this.setReturnType(returnType); - } - }; - - PullSignatureSymbol.prototype.getReturnType = function () { - if (this.returnTypeLink) { - return this.returnTypeLink.end; - } else { - var rtl = this.findOutgoingLinks(function (p) { - return p.kind === 14 /* ReturnType */; - }); - - if (rtl.length) { - this.returnTypeLink = rtl[0]; - return this.returnTypeLink.end; - } - - return null; - } - }; - - PullSignatureSymbol.prototype.parametersAreFixed = function () { - if (!this.isGeneric()) { - return true; - } - - if (this.parameterLinks) { - var paramType; - for (var i = 0; i < this.parameterLinks.length; i++) { - paramType = this.parameterLinks[i].end.getType(); - - if (paramType && !paramType.isFixed()) { - return false; - } - } - } - - return true; - }; - - PullSignatureSymbol.prototype.isFixed = function () { - if (!this.isGeneric()) { - return true; - } - - if (this.parameterLinks) { - var parameterType = null; - - for (var i = 0; i < this.parameterLinks.length; i++) { - parameterType = this.parameterLinks[i].end.getType(); - - if (parameterType && !parameterType.isFixed()) { - return false; - } - } - } - - if (this.returnTypeLink) { - var returnType = this.returnTypeLink.end; - - return returnType.isFixed(); - } - - return true; - }; - - PullSignatureSymbol.prototype.invalidate = function () { - this.parameterLinks = this.findOutgoingLinks(function (psl) { - return psl.kind === 13 /* Parameter */; - }); - this.nonOptionalParamCount = 0; - this.hasOptionalParam = false; - this.hasAGenericParameter = false; - this.stringConstantOverload = undefined; - - if (this.parameterLinks) { - for (var i = 0; i < this.parameterLinks.length; i++) { - this.parameterLinks[i].end.invalidate(); - - if (!this.parameterLinks[i].end.getIsOptional()) { - this.nonOptionalParamCount++; - } else { - this.hasOptionalParam; - break; - } - } - } - - _super.prototype.invalidate.call(this); - }; - - PullSignatureSymbol.prototype.isStringConstantOverloadSignature = function () { - if (this.stringConstantOverload === undefined) { - var params = this.getParameters(); - this.stringConstantOverload = false; - for (var i = 0; i < params.length; i++) { - var paramType = params[i].getType(); - if (paramType && paramType.isPrimitive() && (paramType).isStringConstant()) { - this.stringConstantOverload = true; - } - } - } - - return this.stringConstantOverload; - }; - - PullSignatureSymbol.getSignatureTypeMemberName = function (candidateSignature, signatures, scopeSymbol) { - var allMemberNames = new TypeScript.MemberNameArray(); - var signatureMemberName = PullSignatureSymbol.getSignaturesTypeNameEx(signatures, "", false, false, scopeSymbol, true, candidateSignature); - allMemberNames.addAll(signatureMemberName); - return allMemberNames; - }; - - PullSignatureSymbol.getSignaturesTypeNameEx = function (signatures, prefix, shortform, brackets, scopeSymbol, getPrettyTypeName, candidateSignature) { - var result = []; - var len = signatures.length; - if (!getPrettyTypeName && len > 1) { - shortform = false; - } - - var foundDefinition = false; - if (candidateSignature && candidateSignature.isDefinition() && len > 1) { - candidateSignature = null; - } - - for (var i = 0; i < len; i++) { - if (len > 1 && signatures[i].isDefinition()) { - foundDefinition = true; - continue; - } - - var signature = signatures[i]; - if (getPrettyTypeName && candidateSignature) { - signature = candidateSignature; - } - - result.push(signature.getSignatureTypeNameEx(prefix, shortform, brackets, scopeSymbol)); - if (getPrettyTypeName) { - break; - } - } - - if (getPrettyTypeName && result.length && len > 1) { - var lastMemberName = result[result.length - 1]; - for (var i = i + 1; i < len; i++) { - if (signatures[i].isDefinition()) { - foundDefinition = true; - break; - } - } - var overloadString = " (+ " + (foundDefinition ? len - 2 : len - 1) + " overload(s))"; - lastMemberName.add(TypeScript.MemberName.create(overloadString)); - } - - return result; - }; - - PullSignatureSymbol.prototype.toString = function (useConstraintInName) { - var s = this.getSignatureTypeNameEx(this.getScopedNameEx().toString(), false, false, undefined, undefined, useConstraintInName).toString(); - return s; - }; - - PullSignatureSymbol.prototype.getSignatureTypeNameEx = function (prefix, shortform, brackets, scopeSymbol, getParamMarkerInfo, getTypeParamMarkerInfo) { - var typeParamterBuilder = new TypeScript.MemberNameArray(); - - typeParamterBuilder.add(PullSymbol.getTypeParameterStringEx(this.getTypeParameters(), scopeSymbol, getTypeParamMarkerInfo, true)); - - if (brackets) { - typeParamterBuilder.add(TypeScript.MemberName.create("[")); - } else { - typeParamterBuilder.add(TypeScript.MemberName.create("(")); - } - - var builder = new TypeScript.MemberNameArray(); - builder.prefix = prefix; - - if (getTypeParamMarkerInfo) { - builder.prefix = prefix; - builder.addAll(typeParamterBuilder.entries); - } else { - builder.prefix = prefix + typeParamterBuilder.toString(); - } - - var params = this.getParameters(); - var paramLen = params.length; - for (var i = 0; i < paramLen; i++) { - var paramType = params[i].getType(); - var typeString = paramType ? ": " : ""; - var paramIsVarArg = params[i].getIsVarArg(); - var varArgPrefix = paramIsVarArg ? "..." : ""; - var optionalString = (!paramIsVarArg && params[i].getIsOptional()) ? "?" : ""; - if (getParamMarkerInfo) { - builder.add(new TypeScript.MemberName()); - } - builder.add(TypeScript.MemberName.create(varArgPrefix + params[i].getScopedNameEx(scopeSymbol).toString() + optionalString + typeString)); - if (paramType) { - builder.add(paramType.getScopedNameEx(scopeSymbol)); - } - if (getParamMarkerInfo) { - builder.add(new TypeScript.MemberName()); - } - if (i < paramLen - 1) { - builder.add(TypeScript.MemberName.create(", ")); - } - } - - if (shortform) { - if (brackets) { - builder.add(TypeScript.MemberName.create("] => ")); - } else { - builder.add(TypeScript.MemberName.create(") => ")); - } - } else { - if (brackets) { - builder.add(TypeScript.MemberName.create("]: ")); - } else { - builder.add(TypeScript.MemberName.create("): ")); - } - } - - var returnType = this.getReturnType(); - - if (returnType) { - builder.add(returnType.getScopedNameEx(scopeSymbol)); - } else { - builder.add(TypeScript.MemberName.create("any")); - } - - return builder; - }; - return PullSignatureSymbol; - })(PullSymbol); - TypeScript.PullSignatureSymbol = PullSignatureSymbol; - - var PullTypeSymbol = (function (_super) { - __extends(PullTypeSymbol, _super); - function PullTypeSymbol() { - _super.apply(this, arguments); - this.memberLinks = null; - this.typeParameterLinks = null; - this.specializationLinks = null; - this.containedByLinks = null; - this.memberNameCache = null; - this.memberTypeNameCache = null; - this.memberTypeParameterNameCache = null; - this.containedMemberCache = null; - this.typeArguments = null; - this.specializedTypeCache = null; - this.memberCache = null; - this.implementedTypeLinks = null; - this.extendedTypeLinks = null; - this.callSignatureLinks = null; - this.constructSignatureLinks = null; - this.indexSignatureLinks = null; - this.arrayType = null; - this.hasGenericSignature = false; - this.hasGenericMember = false; - this.knownBaseTypeCount = 0; - this._hasBaseTypeConflict = false; - this.invalidatedSpecializations = false; - this.associatedContainerTypeSymbol = null; - this.constructorMethod = null; - this.hasDefaultConstructor = false; - } - PullTypeSymbol.prototype.getKnownBaseTypeCount = function () { - return this.knownBaseTypeCount; - }; - PullTypeSymbol.prototype.resetKnownBaseTypeCount = function () { - this.knownBaseTypeCount = 0; - }; - PullTypeSymbol.prototype.incrementKnownBaseCount = function () { - this.knownBaseTypeCount++; - }; - PullTypeSymbol.prototype.setHasBaseTypeConflict = function () { - this._hasBaseTypeConflict = true; - }; - PullTypeSymbol.prototype.hasBaseTypeConflict = function () { - return this._hasBaseTypeConflict; - }; - - PullTypeSymbol.prototype.setUnresolved = function () { - _super.prototype.setUnresolved.call(this); - - var specializations = this.getKnownSpecializations(); - - for (var i = 0; i < specializations.length; i++) { - specializations[i].setUnresolved(); - } - }; - - PullTypeSymbol.prototype.isType = function () { - return true; - }; - PullTypeSymbol.prototype.isClass = function () { - return this.getKind() == 8 /* Class */ || (this.constructorMethod != null); - }; - - PullTypeSymbol.prototype.hasMembers = function () { - var thisHasMembers = this.memberLinks && this.memberLinks.length != 0; - - if (thisHasMembers) { - return true; - } - - var parents = this.getExtendedTypes(); - - for (var i = 0; i < parents.length; i++) { - if (parents[i].hasMembers()) { - return true; - } - } - - return false; - }; - PullTypeSymbol.prototype.isFunction = function () { - return false; - }; - PullTypeSymbol.prototype.isConstructor = function () { - return false; - }; - PullTypeSymbol.prototype.isTypeParameter = function () { - return false; - }; - PullTypeSymbol.prototype.isTypeVariable = function () { - return false; - }; - PullTypeSymbol.prototype.isError = function () { - return false; - }; - - PullTypeSymbol.prototype.setHasGenericSignature = function () { - this.hasGenericSignature = true; - }; - PullTypeSymbol.prototype.getHasGenericSignature = function () { - return this.hasGenericSignature; - }; - - PullTypeSymbol.prototype.setHasGenericMember = function () { - this.hasGenericMember = true; - }; - PullTypeSymbol.prototype.getHasGenericMember = function () { - return this.hasGenericMember; - }; - - PullTypeSymbol.prototype.setAssociatedContainerType = function (type) { - this.associatedContainerTypeSymbol = type; - }; - - PullTypeSymbol.prototype.getAssociatedContainerType = function () { - return this.associatedContainerTypeSymbol; - }; - - PullTypeSymbol.prototype.getType = function () { - return this; - }; - - PullTypeSymbol.prototype.getArrayType = function () { - return this.arrayType; - }; - - PullTypeSymbol.prototype.getElementType = function () { - var arrayOfLinks = this.findOutgoingLinks(function (link) { - return link.kind === 4 /* ArrayOf */; - }); - - if (arrayOfLinks.length) { - return arrayOfLinks[0].end; - } - - return null; - }; - PullTypeSymbol.prototype.setArrayType = function (arrayType) { - this.arrayType = arrayType; - - arrayType.addOutgoingLink(this, 4 /* ArrayOf */); - }; - - PullTypeSymbol.prototype.addContainedByLink = function (containedByLink) { - if (!this.containedByLinks) { - this.containedByLinks = []; - } - - if (!this.containedMemberCache) { - this.containedMemberCache = new TypeScript.BlockIntrinsics(); - } - - this.containedByLinks[this.containedByLinks.length] = containedByLink; - this.containedMemberCache[containedByLink.start.getName()] = containedByLink.start; - }; - - PullTypeSymbol.prototype.findContainedMember = function (name) { - if (!this.containedByLinks) { - this.containedByLinks = this.findIncomingLinks(function (psl) { - return psl.kind === 10 /* ContainedBy */; - }); - this.containedMemberCache = new TypeScript.BlockIntrinsics(); - - for (var i = 0; i < this.containedByLinks.length; i++) { - this.containedMemberCache[this.containedByLinks[i].start.getName()] = this.containedByLinks[i].start; - } - } - - return this.containedMemberCache[name]; - }; - - PullTypeSymbol.prototype.addMember = function (memberSymbol, linkKind, doNotChangeContainer) { - var link = this.addOutgoingLink(memberSymbol, linkKind); - - if (!doNotChangeContainer) { - memberSymbol.setContainer(this); - } - - if (!this.memberLinks) { - this.memberLinks = []; - } - - if (!this.memberCache || !this.memberNameCache) { - this.populateMemberCache(); - } - - if (!memberSymbol.isType()) { - this.memberLinks[this.memberLinks.length] = link; - - this.memberCache[this.memberCache.length] = memberSymbol; - - if (!this.memberNameCache) { - this.populateMemberCache(); - } - this.memberNameCache[memberSymbol.getName()] = memberSymbol; - } else { - if ((memberSymbol).isTypeParameter()) { - if (!this.typeParameterLinks) { - this.typeParameterLinks = []; - } - if (!this.memberTypeParameterNameCache) { - this.memberTypeParameterNameCache = new TypeScript.BlockIntrinsics(); - } - this.typeParameterLinks[this.typeParameterLinks.length] = link; - this.memberTypeParameterNameCache[memberSymbol.getName()] = memberSymbol; - } else { - if (!this.memberTypeNameCache) { - this.memberTypeNameCache = new TypeScript.BlockIntrinsics(); - } - this.memberLinks[this.memberLinks.length] = link; - this.memberTypeNameCache[memberSymbol.getName()] = memberSymbol; - this.memberCache[this.memberCache.length] = memberSymbol; - } - } - }; - - PullTypeSymbol.prototype.removeMember = function (memberSymbol) { - var memberLink; - var child; - - var links = (memberSymbol.isType() && (memberSymbol).isTypeParameter()) ? this.typeParameterLinks : this.memberLinks; - - if (links) { - for (var i = 0; i < links.length; i++) { - if (memberSymbol === links[i].end) { - memberLink = links[i]; - child = memberLink.end; - child.unsetContainer(); - this.removeOutgoingLink(memberLink); - break; - } - } - } - - this.invalidate(); - }; - - PullTypeSymbol.prototype.getMembers = function () { - if (this.memberCache) { - return this.memberCache; - } else { - var members = []; - - if (this.memberLinks) { - for (var i = 0; i < this.memberLinks.length; i++) { - members[members.length] = this.memberLinks[i].end; - } - } - - if (members.length) { - this.memberCache = members; - } - - return members; - } - }; - - PullTypeSymbol.prototype.setHasDefaultConstructor = function (hasOne) { - if (typeof hasOne === "undefined") { hasOne = true; } - this.hasDefaultConstructor = hasOne; - }; - - PullTypeSymbol.prototype.getHasDefaultConstructor = function () { - return this.hasDefaultConstructor; - }; - - PullTypeSymbol.prototype.getConstructorMethod = function () { - return this.constructorMethod; - }; - - PullTypeSymbol.prototype.setConstructorMethod = function (constructorMethod) { - this.constructorMethod = constructorMethod; - }; - - PullTypeSymbol.prototype.getTypeParameters = function () { - var members = []; - - if (this.typeParameterLinks) { - for (var i = 0; i < this.typeParameterLinks.length; i++) { - members[members.length] = this.typeParameterLinks[i].end; - } - } - - return members; - }; - - PullTypeSymbol.prototype.isGeneric = function () { - return (this.typeParameterLinks && this.typeParameterLinks.length != 0) || this.hasGenericSignature || this.hasGenericMember || (this.typeArguments && this.typeArguments.length); - }; - - PullTypeSymbol.prototype.isFixed = function () { - if (!this.isGeneric()) { - return true; - } - - if (this.typeParameterLinks && this.typeArguments) { - if (!this.typeArguments.length || this.typeArguments.length < this.typeParameterLinks.length) { - return false; - } - - for (var i = 0; i < this.typeArguments.length; i++) { - if (!this.typeArguments[i].isFixed()) { - return false; - } - } - - return true; - } - - return false; - }; - - PullTypeSymbol.prototype.addSpecialization = function (specializedVersionOfThisType, substitutingTypes) { - if (!substitutingTypes || !substitutingTypes.length) { - return; - } - - if (!this.specializedTypeCache) { - this.specializedTypeCache = new TypeScript.BlockIntrinsics(); - } - - if (!this.specializationLinks) { - this.specializationLinks = []; - } - - this.specializationLinks[this.specializationLinks.length] = this.addOutgoingLink(specializedVersionOfThisType, 21 /* SpecializedTo */); - - this.specializedTypeCache[getIDForTypeSubstitutions(substitutingTypes)] = specializedVersionOfThisType; - }; - - PullTypeSymbol.prototype.getSpecialization = function (substitutingTypes) { - if (!substitutingTypes || !substitutingTypes.length) { - return null; - } - - if (!this.specializedTypeCache) { - this.specializedTypeCache = new TypeScript.BlockIntrinsics(); - - return null; - } - - var specialization = this.specializedTypeCache[getIDForTypeSubstitutions(substitutingTypes)]; - - if (!specialization) { - return null; - } - - return specialization; - }; - - PullTypeSymbol.prototype.getKnownSpecializations = function () { - var specializations = []; - - if (this.specializedTypeCache) { - for (var specializationID in this.specializedTypeCache) { - if (this.specializedTypeCache[specializationID]) { - specializations[specializations.length] = this.specializedTypeCache[specializationID]; - } - } - } - - return specializations; - }; - - PullTypeSymbol.prototype.invalidateSpecializations = function () { - if (this.invalidatedSpecializations) { - return; - } - - var specializations = this.getKnownSpecializations(); - - for (var i = 0; i < specializations.length; i++) { - specializations[i].invalidate(); - } - - if (this.specializationLinks && this.specializationLinks.length) { - for (var i = 0; i < this.specializationLinks.length; i++) { - this.removeOutgoingLink(this.specializationLinks[i]); - } - } - - this.specializationLinks = null; - - this.specializedTypeCache = null; - - this.invalidatedSpecializations = true; - }; - - PullTypeSymbol.prototype.removeSpecialization = function (specializationType) { - if (this.specializationLinks && this.specializationLinks.length) { - for (var i = 0; i < this.specializationLinks.length; i++) { - if (this.specializationLinks[i].end === specializationType) { - this.removeOutgoingLink(this.specializationLinks[i]); - break; - } - } - } - - if (this.specializedTypeCache) { - for (var specializationID in this.specializedTypeCache) { - if (this.specializedTypeCache[specializationID] === specializationType) { - this.specializedTypeCache[specializationID] = undefined; - } - } - } - }; - - PullTypeSymbol.prototype.getTypeArguments = function () { - return this.typeArguments; - }; - PullTypeSymbol.prototype.setTypeArguments = function (typeArgs) { - this.typeArguments = typeArgs; - }; - - PullTypeSymbol.prototype.addCallSignature = function (callSignature) { - if (!this.callSignatureLinks) { - this.callSignatureLinks = []; - } - - var link = this.addOutgoingLink(callSignature, 15 /* CallSignature */); - this.callSignatureLinks[this.callSignatureLinks.length] = link; - - if (callSignature.isGeneric()) { - this.hasGenericSignature = true; - } - }; - - PullTypeSymbol.prototype.addCallSignatures = function (callSignatures) { - if (!this.callSignatureLinks) { - this.callSignatureLinks = []; - } - - for (var i = 0; i < callSignatures.length; i++) { - this.addCallSignature(callSignatures[i]); - } - }; - - PullTypeSymbol.prototype.addConstructSignature = function (constructSignature) { - if (!this.constructSignatureLinks) { - this.constructSignatureLinks = []; - } - - var link = this.addOutgoingLink(constructSignature, 16 /* ConstructSignature */); - this.constructSignatureLinks[this.constructSignatureLinks.length] = link; - - if (constructSignature.isGeneric()) { - this.hasGenericSignature = true; - } - }; - - PullTypeSymbol.prototype.addConstructSignatures = function (constructSignatures) { - if (!this.constructSignatureLinks) { - this.constructSignatureLinks = []; - } - - for (var i = 0; i < constructSignatures.length; i++) { - this.addConstructSignature(constructSignatures[i]); - } - }; - - PullTypeSymbol.prototype.addIndexSignature = function (indexSignature) { - if (!this.indexSignatureLinks) { - this.indexSignatureLinks = []; - } - - var link = this.addOutgoingLink(indexSignature, 17 /* IndexSignature */); - this.indexSignatureLinks[this.indexSignatureLinks.length] = link; - - if (indexSignature.isGeneric()) { - this.hasGenericSignature = true; - } - }; - - PullTypeSymbol.prototype.addIndexSignatures = function (indexSignatures) { - if (!this.indexSignatureLinks) { - this.indexSignatureLinks = []; - } - - for (var i = 0; i < indexSignatures.length; i++) { - this.addIndexSignature(indexSignatures[i]); - } - }; - - PullTypeSymbol.prototype.hasOwnCallSignatures = function () { - return !!this.callSignatureLinks; - }; - - PullTypeSymbol.prototype.getCallSignatures = function (collectBaseSignatures) { - if (typeof collectBaseSignatures === "undefined") { collectBaseSignatures = true; } - var members = []; - - if (this.callSignatureLinks) { - for (var i = 0; i < this.callSignatureLinks.length; i++) { - members[members.length] = this.callSignatureLinks[i].end; - } - } - - if (collectBaseSignatures) { - var extendedTypes = this.getExtendedTypes(); - - for (var i = 0; i < extendedTypes.length; i++) { - if (extendedTypes[i].hasBase(this)) { - continue; - } - members = members.concat(extendedTypes[i].getCallSignatures()); - } - } - - return members; - }; - - PullTypeSymbol.prototype.hasOwnConstructSignatures = function () { - return !!this.constructSignatureLinks; - }; - - PullTypeSymbol.prototype.getConstructSignatures = function (collectBaseSignatures) { - if (typeof collectBaseSignatures === "undefined") { collectBaseSignatures = true; } - var members = []; - - if (this.constructSignatureLinks) { - for (var i = 0; i < this.constructSignatureLinks.length; i++) { - members[members.length] = this.constructSignatureLinks[i].end; - } - } - - if (collectBaseSignatures) { - if (!(this.getKind() == 33554432 /* ConstructorType */)) { - var extendedTypes = this.getExtendedTypes(); - - for (var i = 0; i < extendedTypes.length; i++) { - if (extendedTypes[i].hasBase(this)) { - continue; - } - members = members.concat(extendedTypes[i].getConstructSignatures()); - } - } - } - - return members; - }; - - PullTypeSymbol.prototype.hasOwnIndexSignatures = function () { - return !!this.indexSignatureLinks; - }; - - PullTypeSymbol.prototype.getIndexSignatures = function (collectBaseSignatures) { - if (typeof collectBaseSignatures === "undefined") { collectBaseSignatures = true; } - var members = []; - - if (this.indexSignatureLinks) { - for (var i = 0; i < this.indexSignatureLinks.length; i++) { - members[members.length] = this.indexSignatureLinks[i].end; - } - } - - if (collectBaseSignatures) { - var extendedTypes = this.getExtendedTypes(); - - for (var i = 0; i < extendedTypes.length; i++) { - if (extendedTypes[i].hasBase(this)) { - continue; - } - members = members.concat(extendedTypes[i].getIndexSignatures()); - } - } - - return members; - }; - - PullTypeSymbol.prototype.removeCallSignature = function (signature, invalidate) { - if (typeof invalidate === "undefined") { invalidate = true; } - var signatureLink; - - if (this.callSignatureLinks) { - for (var i = 0; i < this.callSignatureLinks.length; i++) { - if (signature === this.callSignatureLinks[i].end) { - signatureLink = this.callSignatureLinks[i]; - this.removeOutgoingLink(signatureLink); - break; - } - } - } - - if (invalidate) { - this.invalidate(); - } - }; - - PullTypeSymbol.prototype.recomputeCallSignatures = function () { - this.callSignatureLinks = this.findOutgoingLinks(function (psl) { - return psl.kind === 15 /* CallSignature */; - }); - }; - - PullTypeSymbol.prototype.removeConstructSignature = function (signature, invalidate) { - if (typeof invalidate === "undefined") { invalidate = true; } - var signatureLink; - - if (this.constructSignatureLinks) { - for (var i = 0; i < this.constructSignatureLinks.length; i++) { - if (signature === this.constructSignatureLinks[i].end) { - signatureLink = this.constructSignatureLinks[i]; - this.removeOutgoingLink(signatureLink); - break; - } - } - } - - if (invalidate) { - this.invalidate(); - } - }; - - PullTypeSymbol.prototype.recomputeConstructSignatures = function () { - this.constructSignatureLinks = this.findOutgoingLinks(function (psl) { - return psl.kind === 16 /* ConstructSignature */; - }); - }; - - PullTypeSymbol.prototype.removeIndexSignature = function (signature, invalidate) { - if (typeof invalidate === "undefined") { invalidate = true; } - var signatureLink; - - if (this.indexSignatureLinks) { - for (var i = 0; i < this.indexSignatureLinks.length; i++) { - if (signature === this.indexSignatureLinks[i].end) { - signatureLink = this.indexSignatureLinks[i]; - this.removeOutgoingLink(signatureLink); - break; - } - } - } - - if (invalidate) { - this.invalidate(); - } - }; - - PullTypeSymbol.prototype.recomputeIndexSignatures = function () { - this.indexSignatureLinks = this.findOutgoingLinks(function (psl) { - return psl.kind === 17 /* IndexSignature */; - }); - }; - - PullTypeSymbol.prototype.addImplementedType = function (interfaceType) { - if (!this.implementedTypeLinks) { - this.implementedTypeLinks = []; - } - - var link = this.addOutgoingLink(interfaceType, 12 /* Implements */); - this.implementedTypeLinks[this.implementedTypeLinks.length] = link; - }; - - PullTypeSymbol.prototype.getImplementedTypes = function () { - var members = []; - - if (this.implementedTypeLinks) { - for (var i = 0; i < this.implementedTypeLinks.length; i++) { - members[members.length] = this.implementedTypeLinks[i].end; - } - } - - return members; - }; - - PullTypeSymbol.prototype.removeImplementedType = function (implementedType) { - var typeLink; - - if (this.implementedTypeLinks) { - for (var i = 0; i < this.implementedTypeLinks.length; i++) { - if (implementedType === this.implementedTypeLinks[i].end) { - typeLink = this.implementedTypeLinks[i]; - this.removeOutgoingLink(typeLink); - break; - } - } - } - - this.invalidate(); - }; - - PullTypeSymbol.prototype.addExtendedType = function (extendedType) { - if (!this.extendedTypeLinks) { - this.extendedTypeLinks = []; - } - - var link = this.addOutgoingLink(extendedType, 11 /* Extends */); - this.extendedTypeLinks[this.extendedTypeLinks.length] = link; - }; - - PullTypeSymbol.prototype.getExtendedTypes = function () { - var members = []; - - if (this.extendedTypeLinks) { - for (var i = 0; i < this.extendedTypeLinks.length; i++) { - members[members.length] = this.extendedTypeLinks[i].end; - } - } - - return members; - }; - - PullTypeSymbol.prototype.hasBase = function (potentialBase, origin) { - if (typeof origin === "undefined") { origin = null; } - if (this === potentialBase) { - return true; - } - - if (origin && (this === origin || this.getRootSymbol() === origin)) { - return true; - } - - if (!origin) { - origin = this; - } - - var extendedTypes = this.getExtendedTypes(); - - for (var i = 0; i < extendedTypes.length; i++) { - if (extendedTypes[i].hasBase(potentialBase, origin)) { - return true; - } - } - - var implementedTypes = this.getImplementedTypes(); - - for (var i = 0; i < implementedTypes.length; i++) { - if (implementedTypes[i].hasBase(potentialBase, origin)) { - return true; - } - } - - return false; - }; - - PullTypeSymbol.prototype.isValidBaseKind = function (baseType, isExtendedType) { - if (baseType.isError()) { - return false; - } - - var thisIsClass = this.isClass(); - if (isExtendedType) { - if (thisIsClass) { - return baseType.getKind() === 8 /* Class */; - } - } else { - if (!thisIsClass) { - return false; - } - } - - return !!(baseType.getKind() & (16 /* Interface */ | 8 /* Class */ | 128 /* Array */)); - }; - - PullTypeSymbol.prototype.removeExtendedType = function (extendedType) { - var typeLink; - - if (this.extendedTypeLinks) { - for (var i = 0; i < this.extendedTypeLinks.length; i++) { - if (extendedType === this.extendedTypeLinks[i].end) { - typeLink = this.extendedTypeLinks[i]; - this.removeOutgoingLink(typeLink); - break; - } - } - } - - this.invalidate(); - }; - - PullTypeSymbol.prototype.findMember = function (name, lookInParent) { - if (typeof lookInParent === "undefined") { lookInParent = true; } - var memberSymbol; - - if (!this.memberNameCache) { - this.populateMemberCache(); - } - - memberSymbol = this.memberNameCache[name]; - - if (!lookInParent) { - return memberSymbol; - } else if (memberSymbol) { - return memberSymbol; - } - - if (!memberSymbol && this.extendedTypeLinks) { - for (var i = 0; i < this.extendedTypeLinks.length; i++) { - memberSymbol = (this.extendedTypeLinks[i].end).findMember(name); - - if (memberSymbol) { - return memberSymbol; - } - } - } - - return this.findNestedType(name); - }; - - PullTypeSymbol.prototype.findNestedType = function (name, kind) { - if (typeof kind === "undefined") { kind = 0 /* None */; } - var memberSymbol; - - if (!this.memberTypeNameCache) { - this.populateMemberTypeCache(); - } - - memberSymbol = this.memberTypeNameCache[name]; - - if (memberSymbol && kind != 0 /* None */) { - memberSymbol = ((memberSymbol.getKind() & kind) != 0) ? memberSymbol : null; - } - - return memberSymbol; - }; - - PullTypeSymbol.prototype.populateMemberCache = function () { - if (!this.memberNameCache || !this.memberCache) { - this.memberNameCache = new TypeScript.BlockIntrinsics(); - this.memberCache = []; - - if (this.memberLinks) { - for (var i = 0; i < this.memberLinks.length; i++) { - this.memberNameCache[this.memberLinks[i].end.getName()] = this.memberLinks[i].end; - this.memberCache[this.memberCache.length] = this.memberLinks[i].end; - } - } - } - }; - - PullTypeSymbol.prototype.populateMemberTypeCache = function () { - if (!this.memberTypeNameCache) { - this.memberTypeNameCache = new TypeScript.BlockIntrinsics(); - - var setAll = false; - - if (!this.memberCache) { - this.memberCache = []; - this.memberNameCache = new TypeScript.BlockIntrinsics(); - setAll = true; - } - - if (this.memberLinks) { - for (var i = 0; i < this.memberLinks.length; i++) { - if (this.memberLinks[i].end.isType()) { - this.memberTypeNameCache[this.memberLinks[i].end.getName()] = this.memberLinks[i].end; - this.memberCache[this.memberCache.length] = this.memberLinks[i].end; - } else if (setAll) { - this.memberNameCache[this.memberLinks[i].end.getName()] = this.memberLinks[i].end; - this.memberCache[this.memberCache.length] = this.memberLinks[i].end; - } - } - } - } - }; - - PullTypeSymbol.prototype.getAllMembers = function (searchDeclKind, includePrivate) { - var allMembers = []; - var i = 0; - var j = 0; - var m = 0; - var n = 0; - - if (!this.memberCache) { - this.populateMemberCache(); - } - - if (!this.memberTypeNameCache) { - this.populateMemberTypeCache(); - } - - if (!this.memberNameCache) { - this.populateMemberCache(); - } - - for (var i = 0, n = this.memberCache.length; i < n; i++) { - var member = this.memberCache[i]; - if ((member.getKind() & searchDeclKind) && (includePrivate || !member.hasFlag(2 /* Private */))) { - allMembers[allMembers.length] = member; - } - } - - if (this.extendedTypeLinks) { - for (var i = 0, n = this.extendedTypeLinks.length; i < n; i++) { - var extendedMembers = (this.extendedTypeLinks[i].end).getAllMembers(searchDeclKind, includePrivate); - - for (var j = 0, m = extendedMembers.length; j < m; j++) { - var extendedMember = extendedMembers[j]; - if (!this.memberNameCache[extendedMember.getName()]) { - allMembers[allMembers.length] = extendedMember; - } - } - } - } - - return allMembers; - }; - - PullTypeSymbol.prototype.findTypeParameter = function (name) { - var memberSymbol; - - if (!this.memberTypeParameterNameCache) { - this.memberTypeParameterNameCache = new TypeScript.BlockIntrinsics(); - - if (this.typeParameterLinks) { - for (var i = 0; i < this.typeParameterLinks.length; i++) { - this.memberTypeParameterNameCache[this.typeParameterLinks[i].end.getName()] = this.typeParameterLinks[i].end; - } - } - } - - memberSymbol = this.memberTypeParameterNameCache[name]; - - return memberSymbol; - }; - - PullTypeSymbol.prototype.cleanTypeParameters = function () { - if (this.typeParameterLinks) { - for (var i = 0; i < this.typeParameterLinks.length; i++) { - this.removeOutgoingLink(this.typeParameterLinks[i]); - } - } - - this.typeParameterLinks = null; - this.memberTypeParameterNameCache = null; - }; - - PullTypeSymbol.prototype.setResolved = function () { - this.invalidatedSpecializations = true; - _super.prototype.setResolved.call(this); - }; - - PullTypeSymbol.prototype.invalidate = function () { - if (this.constructorMethod) { - this.constructorMethod.invalidate(); - } - - this.memberNameCache = null; - this.memberCache = null; - this.memberTypeNameCache = null; - this.containedMemberCache = null; - - this.invalidatedSpecializations = false; - - this.containedByLinks = null; - - this.memberLinks = this.findOutgoingLinks(function (psl) { - return psl.kind === 6 /* PrivateMember */ || psl.kind === 5 /* PublicMember */; - }); - - this.typeParameterLinks = this.findOutgoingLinks(function (psl) { - return psl.kind === 18 /* TypeParameter */; - }); - - this.callSignatureLinks = this.findOutgoingLinks(function (psl) { - return psl.kind === 15 /* CallSignature */; - }); - - this.constructSignatureLinks = this.findOutgoingLinks(function (psl) { - return psl.kind === 16 /* ConstructSignature */; - }); - - this.indexSignatureLinks = this.findOutgoingLinks(function (psl) { - return psl.kind === 17 /* IndexSignature */; - }); - - this.implementedTypeLinks = this.findOutgoingLinks(function (psl) { - return psl.kind === 12 /* Implements */; - }); - - this.extendedTypeLinks = this.findOutgoingLinks(function (psl) { - return psl.kind === 11 /* Extends */; - }); - - this.knownBaseTypeCount = 0; - - _super.prototype.invalidate.call(this); - }; - - PullTypeSymbol.prototype.getNamePartForFullName = function () { - var name = _super.prototype.getNamePartForFullName.call(this); - - var typars = this.getTypeArguments(); - if (!typars || !typars.length) { - typars = this.getTypeParameters(); - } - - var typarString = PullSymbol.getTypeParameterString(typars, this, true); - return name + typarString; - }; - - PullTypeSymbol.prototype.getScopedName = function (scopeSymbol, useConstraintInName) { - return this.getScopedNameEx(scopeSymbol, useConstraintInName).toString(); - }; - - PullTypeSymbol.prototype.isNamedTypeSymbol = function () { - var kind = this.getKind(); - if (kind === 2 /* Primitive */ || kind === 8 /* Class */ || kind === 4 /* Container */ || kind === 32 /* DynamicModule */ || kind === 256 /* TypeAlias */ || kind === 64 /* Enum */ || kind === 8192 /* TypeParameter */ || ((kind === 16 /* Interface */ || kind === 8388608 /* ObjectType */) && this.getName() != "")) { - return true; - } - - return false; - }; - - PullTypeSymbol.prototype.toString = function (useConstraintInName) { - var s = this.getScopedNameEx(null, useConstraintInName).toString(); - return s; - }; - - PullTypeSymbol.prototype.getScopedNameEx = function (scopeSymbol, useConstraintInName, getPrettyTypeName, getTypeParamMarkerInfo) { - if (!this.isNamedTypeSymbol()) { - return this.getMemberTypeNameEx(true, scopeSymbol, getPrettyTypeName); - } - - var builder = new TypeScript.MemberNameArray(); - builder.prefix = _super.prototype.getScopedName.call(this, scopeSymbol, useConstraintInName); - - var typars = this.getTypeArguments(); - if (!typars || !typars.length) { - typars = this.getTypeParameters(); - } - - builder.add(PullSymbol.getTypeParameterStringEx(typars, this, getTypeParamMarkerInfo, useConstraintInName)); - - return builder; - }; - - PullTypeSymbol.prototype.hasOnlyOverloadCallSignatures = function () { - var members = this.getMembers(); - var callSignatures = this.getCallSignatures(); - var constructSignatures = this.getConstructSignatures(); - return members.length === 0 && constructSignatures.length === 0 && callSignatures.length > 1; - }; - - PullTypeSymbol.prototype.getMemberTypeNameEx = function (topLevel, scopeSymbol, getPrettyTypeName) { - var members = this.getMembers(); - var callSignatures = this.getCallSignatures(); - var constructSignatures = this.getConstructSignatures(); - var indexSignatures = this.getIndexSignatures(); - - if (members.length > 0 || callSignatures.length > 0 || constructSignatures.length > 0 || indexSignatures.length > 0) { - var allMemberNames = new TypeScript.MemberNameArray(); - var curlies = !topLevel || indexSignatures.length != 0; - var delim = "; "; - for (var i = 0; i < members.length; i++) { - var memberTypeName = members[i].getNameAndTypeNameEx(scopeSymbol); - - if (memberTypeName.isArray() && (memberTypeName).delim === delim) { - allMemberNames.addAll((memberTypeName).entries); - } else { - allMemberNames.add(memberTypeName); - } - curlies = true; - } - - var getPrettyFunctionOverload = getPrettyTypeName && !curlies && this.hasOnlyOverloadCallSignatures(); - - var signatureCount = callSignatures.length + constructSignatures.length + indexSignatures.length; - if (signatureCount != 0 || members.length != 0) { - var useShortFormSignature = !curlies && (signatureCount === 1); - var signatureMemberName; - - if (callSignatures.length > 0) { - signatureMemberName = PullSignatureSymbol.getSignaturesTypeNameEx(callSignatures, "", useShortFormSignature, false, scopeSymbol, getPrettyFunctionOverload); - allMemberNames.addAll(signatureMemberName); - } - - if (constructSignatures.length > 0) { - signatureMemberName = PullSignatureSymbol.getSignaturesTypeNameEx(constructSignatures, "new", useShortFormSignature, false, scopeSymbol); - allMemberNames.addAll(signatureMemberName); - } - - if (indexSignatures.length > 0) { - signatureMemberName = PullSignatureSymbol.getSignaturesTypeNameEx(indexSignatures, "", useShortFormSignature, true, scopeSymbol); - allMemberNames.addAll(signatureMemberName); - } - - if ((curlies) || (!getPrettyFunctionOverload && (signatureCount > 1) && topLevel)) { - allMemberNames.prefix = "{ "; - allMemberNames.suffix = "}"; - allMemberNames.delim = delim; - } else if (allMemberNames.entries.length > 1) { - allMemberNames.delim = delim; - } - - return allMemberNames; - } - } - - return TypeScript.MemberName.create("{}"); - }; - - PullTypeSymbol.prototype.isExternallyVisible = function (inIsExternallyVisibleSymbols) { - var isVisible = _super.prototype.isExternallyVisible.call(this, inIsExternallyVisibleSymbols); - if (isVisible) { - var typars = this.getTypeArguments(); - if (!typars || !typars.length) { - typars = this.getTypeParameters(); - } - - if (typars) { - for (var i = 0; i < typars.length; i++) { - isVisible = PullSymbol.getIsExternallyVisible(typars[i], this, inIsExternallyVisibleSymbols); - if (!isVisible) { - break; - } - } - } - } - - return isVisible; - }; - - PullTypeSymbol.prototype.setType = function (type) { - TypeScript.Debug.assert(false, "tried to set type of type"); - }; - return PullTypeSymbol; - })(PullSymbol); - TypeScript.PullTypeSymbol = PullTypeSymbol; - - var PullPrimitiveTypeSymbol = (function (_super) { - __extends(PullPrimitiveTypeSymbol, _super); - function PullPrimitiveTypeSymbol(name) { - _super.call(this, name, 2 /* Primitive */); - } - PullPrimitiveTypeSymbol.prototype.isResolved = function () { - return true; - }; - - PullPrimitiveTypeSymbol.prototype.isStringConstant = function () { - return false; - }; - - PullPrimitiveTypeSymbol.prototype.isFixed = function () { - return true; - }; - - PullPrimitiveTypeSymbol.prototype.invalidate = function () { - }; - return PullPrimitiveTypeSymbol; - })(PullTypeSymbol); - TypeScript.PullPrimitiveTypeSymbol = PullPrimitiveTypeSymbol; - - var PullStringConstantTypeSymbol = (function (_super) { - __extends(PullStringConstantTypeSymbol, _super); - function PullStringConstantTypeSymbol(name) { - _super.call(this, name); - } - PullStringConstantTypeSymbol.prototype.isStringConstant = function () { - return true; - }; - return PullStringConstantTypeSymbol; - })(PullPrimitiveTypeSymbol); - TypeScript.PullStringConstantTypeSymbol = PullStringConstantTypeSymbol; - - var PullErrorTypeSymbol = (function (_super) { - __extends(PullErrorTypeSymbol, _super); - function PullErrorTypeSymbol(diagnostic, delegateType, _data) { - if (typeof _data === "undefined") { _data = null; } - _super.call(this, "error"); - this.diagnostic = diagnostic; - this.delegateType = delegateType; - this._data = _data; - } - PullErrorTypeSymbol.prototype.isError = function () { - return true; - }; - - PullErrorTypeSymbol.prototype.getDiagnostic = function () { - return this.diagnostic; - }; - - PullErrorTypeSymbol.prototype.getName = function (scopeSymbol, useConstraintInName) { - return this.delegateType.getName(scopeSymbol, useConstraintInName); - }; - - PullErrorTypeSymbol.prototype.getDisplayName = function (scopeSymbol, useConstraintInName) { - return this.delegateType.getDisplayName(scopeSymbol, useConstraintInName); - }; - - PullErrorTypeSymbol.prototype.toString = function () { - return this.delegateType.toString(); - }; - - PullErrorTypeSymbol.prototype.isResolved = function () { - return false; - }; - - PullErrorTypeSymbol.prototype.setData = function (data) { - this._data = data; - }; - - PullErrorTypeSymbol.prototype.getData = function () { - return this._data; - }; - return PullErrorTypeSymbol; - })(PullPrimitiveTypeSymbol); - TypeScript.PullErrorTypeSymbol = PullErrorTypeSymbol; - - var PullClassTypeSymbol = (function (_super) { - __extends(PullClassTypeSymbol, _super); - function PullClassTypeSymbol(name) { - _super.call(this, name, 8 /* Class */); - } - return PullClassTypeSymbol; - })(PullTypeSymbol); - TypeScript.PullClassTypeSymbol = PullClassTypeSymbol; - - var PullContainerTypeSymbol = (function (_super) { - __extends(PullContainerTypeSymbol, _super); - function PullContainerTypeSymbol(name, kind) { - if (typeof kind === "undefined") { kind = 4 /* Container */; } - _super.call(this, name, kind); - this.instanceSymbol = null; - this._exportAssignedValueSymbol = null; - this._exportAssignedTypeSymbol = null; - this._exportAssignedContainerSymbol = null; - } - PullContainerTypeSymbol.prototype.isContainer = function () { - return true; - }; - - PullContainerTypeSymbol.prototype.setInstanceSymbol = function (symbol) { - this.instanceSymbol = symbol; - }; - - PullContainerTypeSymbol.prototype.getInstanceSymbol = function () { - return this.instanceSymbol; - }; - - PullContainerTypeSymbol.prototype.invalidate = function () { - if (this.instanceSymbol) { - this.instanceSymbol.invalidate(); - } - - _super.prototype.invalidate.call(this); - }; - - PullContainerTypeSymbol.prototype.setExportAssignedValueSymbol = function (symbol) { - this._exportAssignedValueSymbol = symbol; - }; - PullContainerTypeSymbol.prototype.getExportAssignedValueSymbol = function () { - return this._exportAssignedValueSymbol; - }; - - PullContainerTypeSymbol.prototype.setExportAssignedTypeSymbol = function (type) { - this._exportAssignedTypeSymbol = type; - }; - PullContainerTypeSymbol.prototype.getExportAssignedTypeSymbol = function () { - return this._exportAssignedTypeSymbol; - }; - - PullContainerTypeSymbol.prototype.setExportAssignedContainerSymbol = function (container) { - this._exportAssignedContainerSymbol = container; - }; - PullContainerTypeSymbol.prototype.getExportAssignedContainerSymbol = function () { - return this._exportAssignedContainerSymbol; - }; - - PullContainerTypeSymbol.prototype.resetExportAssignedSymbols = function () { - this._exportAssignedContainerSymbol = null; - this._exportAssignedTypeSymbol = null; - this._exportAssignedValueSymbol = null; - }; - - PullContainerTypeSymbol.usedAsSymbol = function (containerSymbol, symbol) { - if (!containerSymbol || !containerSymbol.isContainer()) { - return false; - } - - if (containerSymbol.getType() == symbol) { - return true; - } - - var containerTypeSymbol = containerSymbol; - var valueExportSymbol = containerTypeSymbol.getExportAssignedValueSymbol(); - var typeExportSymbol = containerTypeSymbol.getExportAssignedTypeSymbol(); - var containerExportSymbol = containerTypeSymbol.getExportAssignedContainerSymbol(); - if (valueExportSymbol || typeExportSymbol || containerExportSymbol) { - return valueExportSymbol == symbol || typeExportSymbol == symbol || containerExportSymbol == symbol || PullContainerTypeSymbol.usedAsSymbol(containerExportSymbol, symbol); - } - - return false; - }; - return PullContainerTypeSymbol; - })(PullTypeSymbol); - TypeScript.PullContainerTypeSymbol = PullContainerTypeSymbol; - - var PullTypeAliasSymbol = (function (_super) { - __extends(PullTypeAliasSymbol, _super); - function PullTypeAliasSymbol(name) { - _super.call(this, name, 256 /* TypeAlias */); - this.typeAliasLink = null; - this.isUsedAsValue = false; - this.typeUsedExternally = false; - this.retrievingExportAssignment = false; - } - PullTypeAliasSymbol.prototype.isAlias = function () { - return true; - }; - PullTypeAliasSymbol.prototype.isContainer = function () { - return true; - }; - - PullTypeAliasSymbol.prototype.setAliasedType = function (type) { - TypeScript.Debug.assert(!type.isError(), "Attempted to alias an error"); - if (this.typeAliasLink) { - this.removeOutgoingLink(this.typeAliasLink); - } - - this.typeAliasLink = this.addOutgoingLink(type, 8 /* Aliases */); - }; - - PullTypeAliasSymbol.prototype.getExportAssignedValueSymbol = function () { - if (!this.typeAliasLink) { - return null; - } - - if (this.retrievingExportAssignment) { - return null; - } - - if (this.typeAliasLink.end.isContainer()) { - this.retrievingExportAssignment = true; - var sym = (this.typeAliasLink.end).getExportAssignedValueSymbol(); - this.retrievingExportAssignment = false; - return sym; - } - - return null; - }; - - PullTypeAliasSymbol.prototype.getExportAssignedTypeSymbol = function () { - if (!this.typeAliasLink) { - return null; - } - - if (this.retrievingExportAssignment) { - return null; - } - - if (this.typeAliasLink.end.isContainer()) { - this.retrievingExportAssignment = true; - var sym = (this.typeAliasLink.end).getExportAssignedTypeSymbol(); - this.retrievingExportAssignment = false; - return sym; - } - - return null; - }; - - PullTypeAliasSymbol.prototype.getExportAssignedContainerSymbol = function () { - if (!this.typeAliasLink) { - return null; - } - - if (this.retrievingExportAssignment) { - return null; - } - - if (this.typeAliasLink.end.isContainer()) { - this.retrievingExportAssignment = true; - var sym = (this.typeAliasLink.end).getExportAssignedContainerSymbol(); - this.retrievingExportAssignment = false; - return sym; - } - - return null; - }; - - PullTypeAliasSymbol.prototype.getType = function () { - if (this.typeAliasLink) { - return this.typeAliasLink.end; - } - - return null; - }; - - PullTypeAliasSymbol.prototype.setType = function (type) { - this.setAliasedType(type); - }; - - PullTypeAliasSymbol.prototype.setIsUsedAsValue = function () { - this.isUsedAsValue = true; - }; - - PullTypeAliasSymbol.prototype.getIsUsedAsValue = function () { - return this.isUsedAsValue; - }; - - PullTypeAliasSymbol.prototype.setIsTypeUsedExternally = function () { - this.typeUsedExternally = true; - }; - - PullTypeAliasSymbol.prototype.getTypeUsedExternally = function () { - return this.typeUsedExternally; - }; - - PullTypeAliasSymbol.prototype.getMembers = function () { - if (this.typeAliasLink) { - return (this.typeAliasLink.end).getMembers(); - } - - return []; - }; - - PullTypeAliasSymbol.prototype.getCallSignatures = function () { - if (this.typeAliasLink) { - return (this.typeAliasLink.end).getCallSignatures(); - } - - return []; - }; - - PullTypeAliasSymbol.prototype.getConstructSignatures = function () { - if (this.typeAliasLink) { - return (this.typeAliasLink.end).getConstructSignatures(); - } - - return []; - }; - - PullTypeAliasSymbol.prototype.getIndexSignatures = function () { - if (this.typeAliasLink) { - return (this.typeAliasLink.end).getIndexSignatures(); - } - - return []; - }; - - PullTypeAliasSymbol.prototype.findMember = function (name) { - if (this.typeAliasLink) { - return (this.typeAliasLink.end).findMember(name); - } - - return null; - }; - - PullTypeAliasSymbol.prototype.findNestedType = function (name) { - if (this.typeAliasLink) { - return (this.typeAliasLink.end).findNestedType(name); - } - - return null; - }; - - PullTypeAliasSymbol.prototype.getAllMembers = function (searchDeclKind, includePrivate) { - if (this.typeAliasLink) { - return (this.typeAliasLink.end).getAllMembers(searchDeclKind, includePrivate); - } - - return []; - }; - - PullTypeAliasSymbol.prototype.invalidate = function () { - this.isUsedAsValue = false; - - _super.prototype.invalidate.call(this); - }; - return PullTypeAliasSymbol; - })(PullTypeSymbol); - TypeScript.PullTypeAliasSymbol = PullTypeAliasSymbol; - - var PullDefinitionSignatureSymbol = (function (_super) { - __extends(PullDefinitionSignatureSymbol, _super); - function PullDefinitionSignatureSymbol() { - _super.apply(this, arguments); - } - PullDefinitionSignatureSymbol.prototype.isDefinition = function () { - return true; - }; - return PullDefinitionSignatureSymbol; - })(PullSignatureSymbol); - TypeScript.PullDefinitionSignatureSymbol = PullDefinitionSignatureSymbol; - - var PullFunctionTypeSymbol = (function (_super) { - __extends(PullFunctionTypeSymbol, _super); - function PullFunctionTypeSymbol() { - _super.call(this, "", 16777216 /* FunctionType */); - this.definitionSignature = null; - } - PullFunctionTypeSymbol.prototype.isFunction = function () { - return true; - }; - - PullFunctionTypeSymbol.prototype.invalidate = function () { - var callSignatures = this.getCallSignatures(); - - if (callSignatures.length) { - for (var i = 0; i < callSignatures.length; i++) { - callSignatures[i].invalidate(); - } - } - - this.definitionSignature = null; - - _super.prototype.invalidate.call(this); - }; - - PullFunctionTypeSymbol.prototype.addSignature = function (signature) { - this.addCallSignature(signature); - - if (signature.isDefinition()) { - this.definitionSignature = signature; - } - }; - - PullFunctionTypeSymbol.prototype.getDefinitionSignature = function () { - return this.definitionSignature; - }; - return PullFunctionTypeSymbol; - })(PullTypeSymbol); - TypeScript.PullFunctionTypeSymbol = PullFunctionTypeSymbol; - - var PullConstructorTypeSymbol = (function (_super) { - __extends(PullConstructorTypeSymbol, _super); - function PullConstructorTypeSymbol() { - _super.call(this, "", 33554432 /* ConstructorType */); - this.definitionSignature = null; - } - PullConstructorTypeSymbol.prototype.isFunction = function () { - return true; - }; - PullConstructorTypeSymbol.prototype.isConstructor = function () { - return true; - }; - - PullConstructorTypeSymbol.prototype.invalidate = function () { - this.definitionSignature = null; - - _super.prototype.invalidate.call(this); - }; - - PullConstructorTypeSymbol.prototype.addSignature = function (signature) { - this.addConstructSignature(signature); - - if (signature.isDefinition()) { - this.definitionSignature = signature; - } - }; - - PullConstructorTypeSymbol.prototype.addTypeParameter = function (typeParameter, doNotChangeContainer) { - this.addMember(typeParameter, 18 /* TypeParameter */, doNotChangeContainer); - - var constructSignatures = this.getConstructSignatures(); - - for (var i = 0; i < constructSignatures.length; i++) { - constructSignatures[i].addTypeParameter(typeParameter); - } - }; - - PullConstructorTypeSymbol.prototype.getDefinitionSignature = function () { - return this.definitionSignature; - }; - return PullConstructorTypeSymbol; - })(PullTypeSymbol); - TypeScript.PullConstructorTypeSymbol = PullConstructorTypeSymbol; - - var PullTypeParameterSymbol = (function (_super) { - __extends(PullTypeParameterSymbol, _super); - function PullTypeParameterSymbol(name, _isFunctionTypeParameter) { - _super.call(this, name, 8192 /* TypeParameter */); - this._isFunctionTypeParameter = _isFunctionTypeParameter; - this.constraintLink = null; - } - PullTypeParameterSymbol.prototype.isTypeParameter = function () { - return true; - }; - PullTypeParameterSymbol.prototype.isFunctionTypeParameter = function () { - return this._isFunctionTypeParameter; - }; - - PullTypeParameterSymbol.prototype.isFixed = function () { - return false; - }; - - PullTypeParameterSymbol.prototype.setConstraint = function (constraintType) { - if (this.constraintLink) { - this.removeOutgoingLink(this.constraintLink); - } - - this.constraintLink = this.addOutgoingLink(constraintType, 22 /* TypeConstraint */); - }; - - PullTypeParameterSymbol.prototype.getConstraint = function () { - if (this.constraintLink) { - return this.constraintLink.end; - } - - return null; - }; - - PullTypeParameterSymbol.prototype.isGeneric = function () { - return true; - }; - - PullTypeParameterSymbol.prototype.fullName = function (scopeSymbol) { - var name = this.getDisplayName(scopeSymbol); - var container = this.getContainer(); - if (container) { - var containerName = container.fullName(scopeSymbol); - name = name + " in " + containerName; - } - - return name; - }; - - PullTypeParameterSymbol.prototype.getName = function (scopeSymbol, useConstraintInName) { - var name = _super.prototype.getName.call(this, scopeSymbol); - - if (this.isPrinting) { - return name; - } - - this.isPrinting = true; - - if (useConstraintInName && this.constraintLink) { - name += " extends " + this.constraintLink.end.toString(); - } - - this.isPrinting = false; - - return name; - }; - - PullTypeParameterSymbol.prototype.getDisplayName = function (scopeSymbol, useConstraintInName) { - var name = _super.prototype.getDisplayName.call(this, scopeSymbol, useConstraintInName); - - if (this.isPrinting) { - return name; - } - - this.isPrinting = true; - - if (useConstraintInName && this.constraintLink) { - name += " extends " + this.constraintLink.end.toString(); - } - - this.isPrinting = false; - - return name; - }; - - PullTypeParameterSymbol.prototype.isExternallyVisible = function (inIsExternallyVisibleSymbols) { - var constraint = this.getConstraint(); - if (constraint) { - return PullSymbol.getIsExternallyVisible(constraint, this, inIsExternallyVisibleSymbols); - } - - return true; - }; - return PullTypeParameterSymbol; - })(PullTypeSymbol); - TypeScript.PullTypeParameterSymbol = PullTypeParameterSymbol; - - var PullTypeVariableSymbol = (function (_super) { - __extends(PullTypeVariableSymbol, _super); - function PullTypeVariableSymbol(name, isFunctionTypeParameter) { - _super.call(this, name, isFunctionTypeParameter); - this.tyvarID = TypeScript.globalTyvarID++; - } - PullTypeVariableSymbol.prototype.isTypeParameter = function () { - return true; - }; - PullTypeVariableSymbol.prototype.isTypeVariable = function () { - return true; - }; - return PullTypeVariableSymbol; - })(PullTypeParameterSymbol); - TypeScript.PullTypeVariableSymbol = PullTypeVariableSymbol; - - var PullAccessorSymbol = (function (_super) { - __extends(PullAccessorSymbol, _super); - function PullAccessorSymbol(name) { - _super.call(this, name, 4096 /* Property */); - this.getterSymbolLink = null; - this.setterSymbolLink = null; - } - PullAccessorSymbol.prototype.isAccessor = function () { - return true; - }; - - PullAccessorSymbol.prototype.setSetter = function (setter) { - this.setterSymbolLink = this.addOutgoingLink(setter, 25 /* SetterFunction */); - }; - - PullAccessorSymbol.prototype.getSetter = function () { - var setter = null; - - if (this.setterSymbolLink) { - setter = this.setterSymbolLink.end; - } - - return setter; - }; - - PullAccessorSymbol.prototype.removeSetter = function () { - if (this.setterSymbolLink) { - this.removeOutgoingLink(this.setterSymbolLink); - } - }; - - PullAccessorSymbol.prototype.setGetter = function (getter) { - this.getterSymbolLink = this.addOutgoingLink(getter, 24 /* GetterFunction */); - }; - - PullAccessorSymbol.prototype.getGetter = function () { - var getter = null; - - if (this.getterSymbolLink) { - getter = this.getterSymbolLink.end; - } - - return getter; - }; - - PullAccessorSymbol.prototype.removeGetter = function () { - if (this.getterSymbolLink) { - this.removeOutgoingLink(this.getterSymbolLink); - } - }; - - PullAccessorSymbol.prototype.invalidate = function () { - if (this.getterSymbolLink) { - this.getterSymbolLink.end.invalidate(); - } - - if (this.setterSymbolLink) { - this.setterSymbolLink.end.invalidate(); - } - - _super.prototype.invalidate.call(this); - }; - return PullAccessorSymbol; - })(PullSymbol); - TypeScript.PullAccessorSymbol = PullAccessorSymbol; - - var PullArrayTypeSymbol = (function (_super) { - __extends(PullArrayTypeSymbol, _super); - function PullArrayTypeSymbol() { - _super.call(this, "Array", 128 /* Array */); - this.elementType = null; - } - PullArrayTypeSymbol.prototype.isArray = function () { - return true; - }; - PullArrayTypeSymbol.prototype.getElementType = function () { - return this.elementType; - }; - PullArrayTypeSymbol.prototype.isGeneric = function () { - return true; - }; - - PullArrayTypeSymbol.prototype.setElementType = function (type) { - this.elementType = type; - }; - - PullArrayTypeSymbol.prototype.getScopedNameEx = function (scopeSymbol, useConstraintInName, getPrettyTypeName, getTypeParamMarkerInfo) { - var elementMemberName = this.elementType ? (this.elementType.isArray() || this.elementType.isNamedTypeSymbol() ? this.elementType.getScopedNameEx(scopeSymbol, false, getPrettyTypeName, getTypeParamMarkerInfo) : this.elementType.getMemberTypeNameEx(false, scopeSymbol, getPrettyTypeName)) : TypeScript.MemberName.create("any"); - return TypeScript.MemberName.create(elementMemberName, "", "[]"); - }; - - PullArrayTypeSymbol.prototype.getMemberTypeNameEx = function (topLevel, scopeSymbol, getPrettyTypeName) { - var elementMemberName = this.elementType ? this.elementType.getMemberTypeNameEx(false, scopeSymbol, getPrettyTypeName) : TypeScript.MemberName.create("any"); - return TypeScript.MemberName.create(elementMemberName, "", "[]"); - }; - return PullArrayTypeSymbol; - })(PullTypeSymbol); - TypeScript.PullArrayTypeSymbol = PullArrayTypeSymbol; - - function specializeToArrayType(typeToReplace, typeToSpecializeTo, resolver, context) { - var arrayInterfaceType = resolver.getCachedArrayType(); - - if (!arrayInterfaceType || (arrayInterfaceType.getKind() & 16 /* Interface */) === 0) { - return null; - } - - if (arrayInterfaceType.isGeneric()) { - var enclosingDecl = arrayInterfaceType.getDeclarations()[0]; - return specializeType(arrayInterfaceType, [typeToSpecializeTo], resolver, enclosingDecl, context); - } - - if (typeToSpecializeTo.getArrayType()) { - return typeToSpecializeTo.getArrayType(); - } - - var newArrayType = new PullArrayTypeSymbol(); - newArrayType.addDeclaration(arrayInterfaceType.getDeclarations()[0]); - - typeToSpecializeTo.setArrayType(newArrayType); - newArrayType.addOutgoingLink(typeToSpecializeTo, 4 /* ArrayOf */); - - var field = null; - var newField = null; - var fieldType = null; - - var method = null; - var methodType = null; - var newMethod = null; - var newMethodType = null; - - var signatures = null; - var newSignature = null; - - var parameters = null; - var newParameter = null; - var parameterType = null; - - var returnType = null; - var newReturnType = null; - - var members = arrayInterfaceType.getMembers(); - - for (var i = 0; i < members.length; i++) { - resolver.resolveDeclaredSymbol(members[i], null, context); - - if (members[i].getKind() === 65536 /* Method */) { - method = members[i]; - - resolver.resolveDeclaredSymbol(method, null, context); - - methodType = method.getType(); - - newMethod = new PullSymbol(method.getName(), 65536 /* Method */); - newMethodType = new PullFunctionTypeSymbol(); - newMethod.setType(newMethodType); - - newMethod.addDeclaration(method.getDeclarations()[0]); - - signatures = methodType.getCallSignatures(); - - for (var j = 0; j < signatures.length; j++) { - newSignature = new PullSignatureSymbol(1048576 /* CallSignature */); - newSignature.addDeclaration(signatures[j].getDeclarations()[0]); - - parameters = signatures[j].getParameters(); - returnType = signatures[j].getReturnType(); - - if (returnType === typeToReplace) { - newSignature.setReturnType(typeToSpecializeTo); - } else { - newSignature.setReturnType(returnType); - } - - for (var k = 0; k < parameters.length; k++) { - newParameter = new PullSymbol(parameters[k].getName(), parameters[k].getKind()); - - parameterType = parameters[k].getType(); - - if (parameterType === null) { - continue; - } - - if (parameterType === typeToReplace) { - newParameter.setType(typeToSpecializeTo); - } else { - newParameter.setType(parameterType); - } - - newSignature.addParameter(newParameter); - } - - newMethodType.addSignature(newSignature); - } - - newArrayType.addMember(newMethod, 5 /* PublicMember */); - } else { - field = members[i]; - - newField = new PullSymbol(field.getName(), field.getKind()); - newField.addDeclaration(field.getDeclarations()[0]); - - fieldType = field.getType(); - - if (fieldType === typeToReplace) { - newField.setType(typeToSpecializeTo); - } else { - newField.setType(fieldType); - } - - newArrayType.addMember(newField, 5 /* PublicMember */); - } - } - newArrayType.addOutgoingLink(arrayInterfaceType, 3 /* ArrayType */); - return newArrayType; - } - TypeScript.specializeToArrayType = specializeToArrayType; - - function typeWrapsTypeParameter(type, typeParameter) { - if (type.isTypeParameter()) { - return type == typeParameter; - } - - var typeArguments = type.getTypeArguments(); - - if (typeArguments) { - for (var i = 0; i < typeArguments.length; i++) { - if (typeWrapsTypeParameter(typeArguments[i], typeParameter)) { - return true; - } - } - } - - return false; - } - TypeScript.typeWrapsTypeParameter = typeWrapsTypeParameter; - - function getRootType(typeToSpecialize) { - var decl = typeToSpecialize.getDeclarations()[0]; - - if (!typeToSpecialize.isGeneric()) { - return typeToSpecialize; - } - - return (typeToSpecialize.getKind() & (8 /* Class */ | 16 /* Interface */)) ? decl.getSymbol().getType() : typeToSpecialize; - } - TypeScript.getRootType = getRootType; - - TypeScript.nSpecializationsCreated = 0; - TypeScript.nSpecializedSignaturesCreated = 0; - - function shouldSpecializeTypeParameterForTypeParameter(specialization, typeToSpecialize) { - if (specialization == typeToSpecialize) { - return false; - } - - if (!(specialization.isTypeParameter() && typeToSpecialize.isTypeParameter())) { - return true; - } - - var parent = specialization.getDeclarations()[0].getParentDecl(); - var targetParent = typeToSpecialize.getDeclarations()[0].getParentDecl(); - - if (parent == targetParent) { - return true; - } - - while (parent) { - if (parent.getFlags() & 16 /* Static */) { - return true; - } - - if (parent == targetParent) { - return false; - } - - parent = parent.getParentDecl(); - } - - return true; - } - TypeScript.shouldSpecializeTypeParameterForTypeParameter = shouldSpecializeTypeParameterForTypeParameter; - - function specializeType(typeToSpecialize, typeArguments, resolver, enclosingDecl, context, ast) { - if (typeToSpecialize.isPrimitive() || !typeToSpecialize.isGeneric()) { - return typeToSpecialize; - } - - var searchForExistingSpecialization = typeArguments != null; - - if (typeArguments === null || (context.specializingToAny && typeArguments.length)) { - typeArguments = []; - } - - if (typeToSpecialize.isTypeParameter()) { - if (context.specializingToAny) { - return resolver.semanticInfoChain.anyTypeSymbol; - } - - var substitution = context.findSpecializationForType(typeToSpecialize); - - if (substitution != typeToSpecialize) { - if (shouldSpecializeTypeParameterForTypeParameter(substitution, typeToSpecialize)) { - return substitution; - } - } - - if (typeArguments && typeArguments.length) { - if (shouldSpecializeTypeParameterForTypeParameter(typeArguments[0], typeToSpecialize)) { - return typeArguments[0]; - } - } - - return typeToSpecialize; - } - - if (typeToSpecialize.isArray()) { - if (typeToSpecialize.currentlyBeingSpecialized()) { - return typeToSpecialize; - } - - var newElementType = null; - - if (!context.specializingToAny) { - var elementType = (typeToSpecialize).getElementType(); - - newElementType = specializeType(elementType, typeArguments, resolver, enclosingDecl, context, ast); - } else { - newElementType = resolver.semanticInfoChain.anyTypeSymbol; - } - - var newArrayType = specializeType(resolver.getCachedArrayType(), [newElementType], resolver, enclosingDecl, context); - - return newArrayType; - } - - var typeParameters = typeToSpecialize.getTypeParameters(); - - if (!context.specializingToAny && searchForExistingSpecialization && (typeParameters.length > typeArguments.length)) { - searchForExistingSpecialization = false; - } - - var newType = null; - - var newTypeDecl = typeToSpecialize.getDeclarations()[0]; - - var rootType = getRootType(typeToSpecialize); - - var isArray = typeToSpecialize === resolver.getCachedArrayType() || typeToSpecialize.isArray(); - - if (searchForExistingSpecialization || context.specializingToAny) { - if (!typeArguments.length || context.specializingToAny) { - for (var i = 0; i < typeParameters.length; i++) { - typeArguments[typeArguments.length] = resolver.semanticInfoChain.anyTypeSymbol; - } - } - - if (isArray) { - newType = typeArguments[0].getArrayType(); - } else if (typeArguments.length) { - newType = rootType.getSpecialization(typeArguments); - } - - if (!newType && !typeParameters.length && context.specializingToAny) { - newType = rootType.getSpecialization([resolver.semanticInfoChain.anyTypeSymbol]); - } - - for (var i = 0; i < typeArguments.length; i++) { - if (!typeArguments[i].isTypeParameter() && (typeArguments[i] == rootType || typeWrapsTypeParameter(typeArguments[i], typeParameters[i]))) { - declAST = resolver.semanticInfoChain.getASTForDecl(newTypeDecl); - if (declAST && typeArguments[i] != resolver.getCachedArrayType()) { - diagnostic = context.postError(enclosingDecl.getScriptName(), declAST.minChar, declAST.getLength(), 225 /* A_generic_type_may_not_reference_itself_with_its_own_type_parameters */, null, enclosingDecl, true); - return resolver.getNewErrorTypeSymbol(diagnostic); - } else { - return resolver.semanticInfoChain.anyTypeSymbol; - } - } - } - } else { - var knownTypeArguments = typeToSpecialize.getTypeArguments(); - var typesToReplace = knownTypeArguments ? knownTypeArguments : typeParameters; - var diagnostic; - var declAST; - - for (var i = 0; i < typesToReplace.length; i++) { - if (!typesToReplace[i].isTypeParameter() && (typeArguments[i] == rootType || typeWrapsTypeParameter(typesToReplace[i], typeParameters[i]))) { - declAST = resolver.semanticInfoChain.getASTForDecl(newTypeDecl); - if (declAST && typeArguments[i] != resolver.getCachedArrayType()) { - diagnostic = context.postError(enclosingDecl.getScriptName(), declAST.minChar, declAST.getLength(), 225 /* A_generic_type_may_not_reference_itself_with_its_own_type_parameters */, null, enclosingDecl, true); - return resolver.getNewErrorTypeSymbol(diagnostic); - } else { - return resolver.semanticInfoChain.anyTypeSymbol; - } - } - - substitution = specializeType(typesToReplace[i], null, resolver, enclosingDecl, context, ast); - - typeArguments[i] = substitution != null ? substitution : typesToReplace[i]; - } - - newType = rootType.getSpecialization(typeArguments); - } - - var rootTypeParameters = rootType.getTypeParameters(); - - if (rootTypeParameters.length && (rootTypeParameters.length == typeArguments.length)) { - for (var i = 0; i < typeArguments.length; i++) { - if (typeArguments[i] != rootTypeParameters[i]) { - break; - } - } - - if (i == rootTypeParameters.length) { - return rootType; - } - } - - if (newType) { - if (!newType.isResolved() && !newType.currentlyBeingSpecialized()) { - typeToSpecialize.invalidateSpecializations(); - } else { - return newType; - } - } - - var prevInSpecialization = context.inSpecialization; - context.inSpecialization = true; - - TypeScript.nSpecializationsCreated++; - - newType = typeToSpecialize.isClass() ? new PullClassTypeSymbol(typeToSpecialize.getName()) : isArray ? new PullArrayTypeSymbol() : typeToSpecialize.isTypeParameter() ? new PullTypeVariableSymbol(typeToSpecialize.getName(), (typeToSpecialize).isFunctionTypeParameter()) : new PullTypeSymbol(typeToSpecialize.getName(), typeToSpecialize.getKind()); - newType.setRootSymbol(rootType); - - newType.setIsBeingSpecialized(); - - newType.setTypeArguments(typeArguments); - - rootType.addSpecialization(newType, typeArguments); - - if (isArray) { - (newType).setElementType(typeArguments[0]); - typeArguments[0].setArrayType(newType); - } - - if (typeToSpecialize.currentlyBeingSpecialized()) { - return newType; - } - - var prevCurrentlyBeingSpecialized = typeToSpecialize.currentlyBeingSpecialized(); - if (typeToSpecialize.getKind() == 33554432 /* ConstructorType */) { - typeToSpecialize.setIsBeingSpecialized(); - } - - var typeReplacementMap = {}; - - for (var i = 0; i < typeParameters.length; i++) { - if (typeParameters[i] != typeArguments[i]) { - typeReplacementMap[typeParameters[i].getSymbolID().toString()] = typeArguments[i]; - } - newType.addMember(typeParameters[i], 18 /* TypeParameter */, true); - } - - var extendedTypesToSpecialize = typeToSpecialize.getExtendedTypes(); - var typeDecl; - var typeAST; - var unitPath; - var decls = typeToSpecialize.getDeclarations(); - - if (extendedTypesToSpecialize.length) { - for (var i = 0; i < decls.length; i++) { - typeDecl = decls[i]; - typeAST = resolver.semanticInfoChain.getASTForDecl(typeDecl); - - if (typeAST.extendsList) { - unitPath = resolver.getUnitPath(); - resolver.setUnitPath(typeDecl.getScriptName()); - context.pushTypeSpecializationCache(typeReplacementMap); - var extendTypeSymbol = resolver.resolveTypeReference(new TypeScript.TypeReference(typeAST.extendsList.members[0], 0), typeDecl, context).symbol; - resolver.setUnitPath(unitPath); - context.popTypeSpecializationCache(); - - newType.addExtendedType(extendTypeSymbol); - } - } - } - - var implementedTypesToSpecialize = typeToSpecialize.getImplementedTypes(); - - if (implementedTypesToSpecialize.length) { - for (var i = 0; i < decls.length; i++) { - typeDecl = decls[i]; - typeAST = resolver.semanticInfoChain.getASTForDecl(typeDecl); - - if (typeAST.implementsList) { - unitPath = resolver.getUnitPath(); - resolver.setUnitPath(typeDecl.getScriptName()); - context.pushTypeSpecializationCache(typeReplacementMap); - var implementedTypeSymbol = resolver.resolveTypeReference(new TypeScript.TypeReference(typeAST.implementsList.members[0], 0), typeDecl, context).symbol; - resolver.setUnitPath(unitPath); - context.popTypeSpecializationCache(); - - newType.addImplementedType(implementedTypeSymbol); - } - } - } - - var callSignatures = typeToSpecialize.getCallSignatures(false); - var constructSignatures = typeToSpecialize.getConstructSignatures(false); - var indexSignatures = typeToSpecialize.getIndexSignatures(false); - var members = typeToSpecialize.getMembers(); - - var newSignature; - var signature; - - var decl = null; - var declAST = null; - var parameters; - var newParameters; - var returnType = null; - var prevSpecializationSignature = null; - - for (var i = 0; i < callSignatures.length; i++) { - signature = callSignatures[i]; - - if (!signature.currentlyBeingSpecialized()) { - context.pushTypeSpecializationCache(typeReplacementMap); - - decl = signature.getDeclarations()[0]; - unitPath = resolver.getUnitPath(); - resolver.setUnitPath(decl.getScriptName()); - - newSignature = new PullSignatureSymbol(signature.getKind()); - TypeScript.nSpecializedSignaturesCreated++; - newSignature.mimicSignature(signature, resolver); - declAST = resolver.semanticInfoChain.getASTForDecl(decl); - - TypeScript.Debug.assert(declAST != null, "Call signature for type '" + typeToSpecialize.toString() + "' could not be specialized because of a stale declaration"); - - prevSpecializationSignature = decl.getSpecializingSignatureSymbol(); - decl.setSpecializingSignatureSymbol(newSignature); - resolver.resolveAST(declAST, false, newTypeDecl, context); - decl.setSpecializingSignatureSymbol(prevSpecializationSignature); - - parameters = signature.getParameters(); - newParameters = newSignature.getParameters(); - - for (var p = 0; p < parameters.length; p++) { - newParameters[p].setType(parameters[p].getType()); - } - newSignature.setResolved(); - - resolver.setUnitPath(unitPath); - - returnType = newSignature.getReturnType(); - - if (!returnType) { - newSignature.setReturnType(signature.getReturnType()); - } - - signature.setIsBeingSpecialized(); - newSignature.setRootSymbol(signature); - newSignature = specializeSignature(newSignature, true, typeReplacementMap, null, resolver, newTypeDecl, context); - signature.setIsSpecialized(); - - context.popTypeSpecializationCache(); - - if (!newSignature) { - context.inSpecialization = prevInSpecialization; - typeToSpecialize.setValueIsBeingSpecialized(prevCurrentlyBeingSpecialized); - TypeScript.Debug.assert(false, "returning from call"); - return resolver.semanticInfoChain.anyTypeSymbol; - } - } else { - newSignature = signature; - } - - newType.addCallSignature(newSignature); - - if (newSignature.hasGenericParameter()) { - newType.setHasGenericSignature(); - } - } - - for (var i = 0; i < constructSignatures.length; i++) { - signature = constructSignatures[i]; - - if (!signature.currentlyBeingSpecialized()) { - context.pushTypeSpecializationCache(typeReplacementMap); - - decl = signature.getDeclarations()[0]; - unitPath = resolver.getUnitPath(); - resolver.setUnitPath(decl.getScriptName()); - - newSignature = new PullSignatureSymbol(signature.getKind()); - TypeScript.nSpecializedSignaturesCreated++; - newSignature.mimicSignature(signature, resolver); - declAST = resolver.semanticInfoChain.getASTForDecl(decl); - - TypeScript.Debug.assert(declAST != null, "Construct signature for type '" + typeToSpecialize.toString() + "' could not be specialized because of a stale declaration"); - - prevSpecializationSignature = decl.getSpecializingSignatureSymbol(); - decl.setSpecializingSignatureSymbol(newSignature); - resolver.resolveAST(declAST, false, newTypeDecl, context); - decl.setSpecializingSignatureSymbol(prevSpecializationSignature); - - parameters = signature.getParameters(); - newParameters = newSignature.getParameters(); - - for (var p = 0; p < parameters.length; p++) { - newParameters[p].setType(parameters[p].getType()); - } - newSignature.setResolved(); - - resolver.setUnitPath(unitPath); - - returnType = newSignature.getReturnType(); - - if (!returnType) { - newSignature.setReturnType(signature.getReturnType()); - } - - signature.setIsBeingSpecialized(); - newSignature.setRootSymbol(signature); - newSignature = specializeSignature(newSignature, true, typeReplacementMap, null, resolver, newTypeDecl, context); - signature.setIsSpecialized(); - - context.popTypeSpecializationCache(); - - if (!newSignature) { - context.inSpecialization = prevInSpecialization; - typeToSpecialize.setValueIsBeingSpecialized(prevCurrentlyBeingSpecialized); - TypeScript.Debug.assert(false, "returning from construct"); - return resolver.semanticInfoChain.anyTypeSymbol; - } - } else { - newSignature = signature; - } - - newType.addConstructSignature(newSignature); - - if (newSignature.hasGenericParameter()) { - newType.setHasGenericSignature(); - } - } - - for (var i = 0; i < indexSignatures.length; i++) { - signature = indexSignatures[i]; - - if (!signature.currentlyBeingSpecialized()) { - context.pushTypeSpecializationCache(typeReplacementMap); - - decl = signature.getDeclarations()[0]; - unitPath = resolver.getUnitPath(); - resolver.setUnitPath(decl.getScriptName()); - - newSignature = new PullSignatureSymbol(signature.getKind()); - TypeScript.nSpecializedSignaturesCreated++; - newSignature.mimicSignature(signature, resolver); - declAST = resolver.semanticInfoChain.getASTForDecl(decl); - - TypeScript.Debug.assert(declAST != null, "Index signature for type '" + typeToSpecialize.toString() + "' could not be specialized because of a stale declaration"); - - prevSpecializationSignature = decl.getSpecializingSignatureSymbol(); - decl.setSpecializingSignatureSymbol(newSignature); - resolver.resolveAST(declAST, false, newTypeDecl, context); - decl.setSpecializingSignatureSymbol(prevSpecializationSignature); - - parameters = signature.getParameters(); - newParameters = newSignature.getParameters(); - - for (var p = 0; p < parameters.length; p++) { - newParameters[p].setType(parameters[p].getType()); - } - newSignature.setResolved(); - - resolver.setUnitPath(unitPath); - - returnType = newSignature.getReturnType(); - - if (!returnType) { - newSignature.setReturnType(signature.getReturnType()); - } - - signature.setIsBeingSpecialized(); - newSignature.setRootSymbol(signature); - newSignature = specializeSignature(newSignature, true, typeReplacementMap, null, resolver, newTypeDecl, context); - signature.setIsSpecialized(); - - context.popTypeSpecializationCache(); - - if (!newSignature) { - context.inSpecialization = prevInSpecialization; - typeToSpecialize.setValueIsBeingSpecialized(prevCurrentlyBeingSpecialized); - TypeScript.Debug.assert(false, "returning from index"); - return resolver.semanticInfoChain.anyTypeSymbol; - } - } else { - newSignature = signature; - } - - newType.addIndexSignature(newSignature); - - if (newSignature.hasGenericParameter()) { - newType.setHasGenericSignature(); - } - } - - var field = null; - var newField = null; - - var fieldType = null; - var newFieldType = null; - var replacementType = null; - - var fieldSignatureSymbol = null; - - for (var i = 0; i < members.length; i++) { - field = members[i]; - field.setIsBeingSpecialized(); - - decls = field.getDeclarations(); - - newField = new PullSymbol(field.getName(), field.getKind()); - - newField.setRootSymbol(field); - - if (field.getIsOptional()) { - newField.setIsOptional(); - } - - if (!field.isResolved()) { - resolver.resolveDeclaredSymbol(field, newTypeDecl, context); - } - - fieldType = field.getType(); - - if (!fieldType) { - fieldType = newType; - } - - replacementType = typeReplacementMap[fieldType.getSymbolID().toString()]; - - if (replacementType) { - newField.setType(replacementType); - } else { - if (fieldType.isGeneric() && !fieldType.isFixed()) { - unitPath = resolver.getUnitPath(); - resolver.setUnitPath(decls[0].getScriptName()); - - context.pushTypeSpecializationCache(typeReplacementMap); - - newFieldType = specializeType(fieldType, !fieldType.getIsSpecialized() ? typeArguments : null, resolver, newTypeDecl, context, ast); - - resolver.setUnitPath(unitPath); - - context.popTypeSpecializationCache(); - - newField.setType(newFieldType); - } else { - newField.setType(fieldType); - } - } - field.setIsSpecialized(); - newType.addMember(newField, (field.hasFlag(2 /* Private */)) ? 6 /* PrivateMember */ : 5 /* PublicMember */); - } - - if (typeToSpecialize.isClass()) { - var constructorMethod = (typeToSpecialize).getConstructorMethod(); - - if (!constructorMethod.isResolved()) { - var prevIsSpecializingConstructorMethod = context.isSpecializingConstructorMethod; - context.isSpecializingConstructorMethod = true; - resolver.resolveDeclaredSymbol(constructorMethod, enclosingDecl, context); - context.isSpecializingConstructorMethod = prevIsSpecializingConstructorMethod; - } - - var newConstructorMethod = new PullSymbol(constructorMethod.getName(), 32768 /* ConstructorMethod */); - var newConstructorType = specializeType(constructorMethod.getType(), typeArguments, resolver, newTypeDecl, context, ast); - - newConstructorMethod.setType(newConstructorType); - - var constructorDecls = constructorMethod.getDeclarations(); - - newConstructorMethod.setRootSymbol(constructorMethod); - - (newType).setConstructorMethod(newConstructorMethod); - } - - newType.setIsSpecialized(); - - newType.setResolved(); - typeToSpecialize.setValueIsBeingSpecialized(prevCurrentlyBeingSpecialized); - context.inSpecialization = prevInSpecialization; - return newType; - } - TypeScript.specializeType = specializeType; - - function specializeSignature(signature, skipLocalTypeParameters, typeReplacementMap, typeArguments, resolver, enclosingDecl, context, ast) { - if (signature.currentlyBeingSpecialized()) { - return signature; - } - - if (!signature.isResolved() && !signature.isResolving()) { - resolver.resolveDeclaredSymbol(signature, enclosingDecl, context); - } - - var newSignature = signature.getSpecialization(typeArguments); - - if (newSignature) { - return newSignature; - } - - signature.setIsBeingSpecialized(); - - var prevInSpecialization = context.inSpecialization; - context.inSpecialization = true; - - newSignature = new PullSignatureSymbol(signature.getKind()); - TypeScript.nSpecializedSignaturesCreated++; - newSignature.setRootSymbol(signature); - - if (signature.hasVariableParamList()) { - newSignature.setHasVariableParamList(); - } - - if (signature.hasGenericParameter()) { - newSignature.setHasGenericParameter(); - } - - signature.addSpecialization(newSignature, typeArguments); - - var parameters = signature.getParameters(); - var typeParameters = signature.getTypeParameters(); - var returnType = signature.getReturnType(); - - for (var i = 0; i < typeParameters.length; i++) { - newSignature.addTypeParameter(typeParameters[i]); - } - - if (signature.hasGenericParameter()) { - newSignature.setHasGenericParameter(); - } - - var newParameter; - var newParameterType; - var newParameterElementType; - var parameterType; - var replacementParameterType; - var localTypeParameters = new TypeScript.BlockIntrinsics(); - var localSkipMap = null; - - if (skipLocalTypeParameters) { - for (var i = 0; i < typeParameters.length; i++) { - localTypeParameters[typeParameters[i].getName()] = true; - if (!localSkipMap) { - localSkipMap = {}; - } - localSkipMap[typeParameters[i].getSymbolID().toString()] = typeParameters[i]; - } - } - - context.pushTypeSpecializationCache(typeReplacementMap); - - if (skipLocalTypeParameters && localSkipMap) { - context.pushTypeSpecializationCache(localSkipMap); - } - var newReturnType = (!localTypeParameters[returnType.getName()]) ? specializeType(returnType, null, resolver, enclosingDecl, context, ast) : returnType; - if (skipLocalTypeParameters && localSkipMap) { - context.popTypeSpecializationCache(); - } - context.popTypeSpecializationCache(); - - newSignature.setReturnType(newReturnType); - - for (var k = 0; k < parameters.length; k++) { - newParameter = new PullSymbol(parameters[k].getName(), parameters[k].getKind()); - newParameter.setRootSymbol(parameters[k]); - - parameterType = parameters[k].getType(); - - context.pushTypeSpecializationCache(typeReplacementMap); - if (skipLocalTypeParameters && localSkipMap) { - context.pushTypeSpecializationCache(localSkipMap); - } - newParameterType = !localTypeParameters[parameterType.getName()] ? specializeType(parameterType, null, resolver, enclosingDecl, context, ast) : parameterType; - if (skipLocalTypeParameters && localSkipMap) { - context.popTypeSpecializationCache(); - } - context.popTypeSpecializationCache(); - - if (parameters[k].getIsOptional()) { - newParameter.setIsOptional(); - } - - if (parameters[k].getIsVarArg()) { - newParameter.setIsVarArg(); - newSignature.setHasVariableParamList(); - } - - if (resolver.isTypeArgumentOrWrapper(newParameterType)) { - newSignature.setHasGenericParameter(); - } - - newParameter.setType(newParameterType); - newSignature.addParameter(newParameter, newParameter.getIsOptional()); - } - - signature.setIsSpecialized(); - - context.inSpecialization = prevInSpecialization; - - return newSignature; - } - TypeScript.specializeSignature = specializeSignature; - - function getIDForTypeSubstitutions(types) { - var substitution = ""; - - for (var i = 0; i < types.length; i++) { - substitution += types[i].getSymbolID().toString() + "#"; - } - - return substitution; - } - TypeScript.getIDForTypeSubstitutions = getIDForTypeSubstitutions; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var PullSymbolBindingContext = (function () { - function PullSymbolBindingContext(semanticInfoChain, scriptName) { - this.semanticInfoChain = semanticInfoChain; - this.scriptName = scriptName; - this.parentChain = []; - this.declPath = []; - this.reBindingAfterChange = false; - this.startingDeclForRebind = TypeScript.pullDeclID; - this.semanticInfo = this.semanticInfoChain.getUnit(this.scriptName); - } - PullSymbolBindingContext.prototype.getParent = function (n) { - if (typeof n === "undefined") { n = 0; } - return this.parentChain ? this.parentChain[this.parentChain.length - 1 - n] : null; - }; - PullSymbolBindingContext.prototype.getDeclPath = function () { - return this.declPath; - }; - - PullSymbolBindingContext.prototype.pushParent = function (parentDecl) { - if (parentDecl) { - this.parentChain[this.parentChain.length] = parentDecl; - this.declPath[this.declPath.length] = parentDecl.getName(); - } - }; - - PullSymbolBindingContext.prototype.popParent = function () { - if (this.parentChain.length) { - this.parentChain.length--; - this.declPath.length--; - } - }; - return PullSymbolBindingContext; - })(); - TypeScript.PullSymbolBindingContext = PullSymbolBindingContext; - - TypeScript.time_in_findSymbol = 0; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var CandidateInferenceInfo = (function () { - function CandidateInferenceInfo() { - this.typeParameter = null; - this.isFixed = false; - this.inferenceCandidates = []; - } - CandidateInferenceInfo.prototype.addCandidate = function (candidate) { - if (!this.isFixed) { - this.inferenceCandidates[this.inferenceCandidates.length] = candidate; - } - }; - return CandidateInferenceInfo; - })(); - TypeScript.CandidateInferenceInfo = CandidateInferenceInfo; - - var ArgumentInferenceContext = (function () { - function ArgumentInferenceContext() { - this.inferenceCache = {}; - this.candidateCache = {}; - } - ArgumentInferenceContext.prototype.alreadyRelatingTypes = function (objectType, parameterType) { - var comboID = objectType.getSymbolID().toString() + "#" + parameterType.getSymbolID().toString(); - - if (this.inferenceCache[comboID]) { - return true; - } else { - this.inferenceCache[comboID] = true; - return false; - } - }; - - ArgumentInferenceContext.prototype.resetRelationshipCache = function () { - this.inferenceCache = {}; - }; - - ArgumentInferenceContext.prototype.addInferenceRoot = function (param) { - var info = this.candidateCache[param.getSymbolID().toString()]; - - if (!info) { - info = new CandidateInferenceInfo(); - info.typeParameter = param; - this.candidateCache[param.getSymbolID().toString()] = info; - } - }; - - ArgumentInferenceContext.prototype.getInferenceInfo = function (param) { - return this.candidateCache[param.getSymbolID().toString()]; - }; - - ArgumentInferenceContext.prototype.addCandidateForInference = function (param, candidate, fix) { - var info = this.getInferenceInfo(param); - - if (info) { - if (candidate) { - info.addCandidate(candidate); - } - - if (!info.isFixed) { - info.isFixed = fix; - } - } - }; - - ArgumentInferenceContext.prototype.getInferenceCandidates = function () { - var inferenceCandidates = []; - var info; - var val; - - for (var infoKey in this.candidateCache) { - info = this.candidateCache[infoKey]; - - for (var i = 0; i < info.inferenceCandidates.length; i++) { - val = {}; - val[info.typeParameter.getSymbolID().toString()] = info.inferenceCandidates[i]; - inferenceCandidates[inferenceCandidates.length] = val; - } - } - - return inferenceCandidates; - }; - - ArgumentInferenceContext.prototype.inferArgumentTypes = function (resolver, context) { - var info = null; - - var collection; - - var bestCommonType; - - var results = []; - - var unfit = false; - - for (var infoKey in this.candidateCache) { - info = this.candidateCache[infoKey]; - - if (!info.inferenceCandidates.length) { - results[results.length] = { param: info.typeParameter, type: resolver.semanticInfoChain.anyTypeSymbol }; - continue; - } - - collection = { - getLength: function () { - return info.inferenceCandidates.length; - }, - setTypeAtIndex: function (index, type) { - }, - getTypeAtIndex: function (index) { - return info.inferenceCandidates[index].getType(); - } - }; - - bestCommonType = resolver.widenType(resolver.findBestCommonType(info.inferenceCandidates[0], null, collection, context, new TypeScript.TypeComparisonInfo())); - - if (!bestCommonType) { - unfit = true; - } else { - for (var i = 0; i < results.length; i++) { - if (results[i].type == info.typeParameter) { - results[i].type = bestCommonType; - } - } - } - - results[results.length] = { param: info.typeParameter, type: bestCommonType }; - } - - return { results: results, unfit: unfit }; - }; - return ArgumentInferenceContext; - })(); - TypeScript.ArgumentInferenceContext = ArgumentInferenceContext; - - var PullContextualTypeContext = (function () { - function PullContextualTypeContext(contextualType, provisional, substitutions) { - this.contextualType = contextualType; - this.provisional = provisional; - this.substitutions = substitutions; - this.provisionallyTypedSymbols = []; - this.provisionalDiagnostic = []; - } - PullContextualTypeContext.prototype.recordProvisionallyTypedSymbol = function (symbol) { - this.provisionallyTypedSymbols[this.provisionallyTypedSymbols.length] = symbol; - }; - - PullContextualTypeContext.prototype.invalidateProvisionallyTypedSymbols = function () { - for (var i = 0; i < this.provisionallyTypedSymbols.length; i++) { - this.provisionallyTypedSymbols[i].invalidate(); - } - }; - - PullContextualTypeContext.prototype.postDiagnostic = function (error) { - this.provisionalDiagnostic[this.provisionalDiagnostic.length] = error; - }; - - PullContextualTypeContext.prototype.hadProvisionalErrors = function () { - return this.provisionalDiagnostic.length > 0; - }; - return PullContextualTypeContext; - })(); - TypeScript.PullContextualTypeContext = PullContextualTypeContext; - - var PullTypeResolutionContext = (function () { - function PullTypeResolutionContext() { - this.contextStack = []; - this.typeSpecializationStack = []; - this.genericASTResolutionStack = []; - this.resolvingTypeReference = false; - this.resolvingNamespaceMemberAccess = false; - this.resolveAggressively = false; - this.canUseTypeSymbol = false; - this.specializingToAny = false; - this.specializingToObject = false; - this.isResolvingClassExtendedType = false; - this.isSpecializingSignatureAtCallSite = false; - this.isSpecializingConstructorMethod = false; - this.isComparingSpecializedSignatures = false; - this.inSpecialization = false; - this.suppressErrors = false; - this.inBaseTypeResolution = false; - } - PullTypeResolutionContext.prototype.pushContextualType = function (type, provisional, substitutions) { - this.contextStack.push(new PullContextualTypeContext(type, provisional, substitutions)); - }; - - PullTypeResolutionContext.prototype.popContextualType = function () { - var tc = this.contextStack.pop(); - - tc.invalidateProvisionallyTypedSymbols(); - - return tc; - }; - - PullTypeResolutionContext.prototype.findSubstitution = function (type) { - var substitution = null; - - if (this.contextStack.length) { - for (var i = this.contextStack.length - 1; i >= 0; i--) { - if (this.contextStack[i].substitutions) { - substitution = this.contextStack[i].substitutions[type.getSymbolID().toString()]; - - if (substitution) { - break; - } - } - } - } - - return substitution; - }; - - PullTypeResolutionContext.prototype.getContextualType = function () { - var context = !this.contextStack.length ? null : this.contextStack[this.contextStack.length - 1]; - - if (context) { - var type = context.contextualType; - - if (!type) { - return null; - } - - if (type.isTypeParameter() && (type).getConstraint()) { - type = (type).getConstraint(); - } - - var substitution = this.findSubstitution(type); - - return substitution ? substitution : type; - } - - return null; - }; - - PullTypeResolutionContext.prototype.inProvisionalResolution = function () { - return (!this.contextStack.length ? false : this.contextStack[this.contextStack.length - 1].provisional); - }; - - PullTypeResolutionContext.prototype.isInBaseTypeResolution = function () { - return this.inBaseTypeResolution; - }; - - PullTypeResolutionContext.prototype.startBaseTypeResolution = function () { - var wasInBaseTypeResoltion = this.inBaseTypeResolution; - this.inBaseTypeResolution = true; - return wasInBaseTypeResoltion; - }; - - PullTypeResolutionContext.prototype.doneBaseTypeResolution = function (wasInBaseTypeResolution) { - this.inBaseTypeResolution = wasInBaseTypeResolution; - }; - - PullTypeResolutionContext.prototype.setTypeInContext = function (symbol, type) { - var substitution = this.findSubstitution(type); - - symbol.setType(substitution ? substitution : type); - - if (this.contextStack.length && this.inProvisionalResolution()) { - this.contextStack[this.contextStack.length - 1].recordProvisionallyTypedSymbol(symbol); - } - }; - - PullTypeResolutionContext.prototype.pushTypeSpecializationCache = function (cache) { - this.typeSpecializationStack[this.typeSpecializationStack.length] = cache; - }; - - PullTypeResolutionContext.prototype.popTypeSpecializationCache = function () { - if (this.typeSpecializationStack.length) { - this.typeSpecializationStack.length--; - } - }; - - PullTypeResolutionContext.prototype.findSpecializationForType = function (type) { - var specialization = null; - - for (var i = this.typeSpecializationStack.length - 1; i >= 0; i--) { - specialization = (this.typeSpecializationStack[i])[type.getSymbolID().toString()]; - - if (specialization) { - return specialization; - } - } - - return type; - }; - - PullTypeResolutionContext.prototype.postError = function (fileName, offset, length, diagnosticCode, arguments, enclosingDecl, addToDecl) { - if (typeof arguments === "undefined") { arguments = null; } - if (typeof enclosingDecl === "undefined") { enclosingDecl = null; } - if (typeof addToDecl === "undefined") { addToDecl = false; } - var diagnostic = new TypeScript.SemanticDiagnostic(fileName, offset, length, diagnosticCode, arguments); - this.postDiagnostic(diagnostic, enclosingDecl, addToDecl); - - return diagnostic; - }; - - PullTypeResolutionContext.prototype.postDiagnostic = function (diagnostic, enclosingDecl, addToDecl) { - if (this.inProvisionalResolution()) { - (this.contextStack[this.contextStack.length - 1]).postDiagnostic(diagnostic); - } else if (!this.suppressErrors && enclosingDecl && addToDecl) { - enclosingDecl.addDiagnostic(diagnostic); - } - }; - - PullTypeResolutionContext.prototype.startResolvingTypeArguments = function (ast) { - this.genericASTResolutionStack[this.genericASTResolutionStack.length] = ast; - }; - - PullTypeResolutionContext.prototype.isResolvingTypeArguments = function (ast) { - for (var i = 0; i < this.genericASTResolutionStack.length; i++) { - if (this.genericASTResolutionStack[i].getID() === ast.getID()) { - return true; - } - } - - return false; - }; - - PullTypeResolutionContext.prototype.doneResolvingTypeArguments = function () { - this.genericASTResolutionStack.length--; - }; - return PullTypeResolutionContext; - })(); - TypeScript.PullTypeResolutionContext = PullTypeResolutionContext; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var SymbolAndDiagnostics = (function () { - function SymbolAndDiagnostics(symbol, symbolAlias, diagnostics) { - this.symbol = symbol; - this.symbolAlias = symbolAlias; - this.diagnostics = diagnostics; - } - SymbolAndDiagnostics.create = function (symbol, diagnostics) { - return new SymbolAndDiagnostics(symbol, null, diagnostics); - }; - - SymbolAndDiagnostics.empty = function () { - return SymbolAndDiagnostics._empty; - }; - - SymbolAndDiagnostics.fromSymbol = function (symbol) { - return new SymbolAndDiagnostics(symbol, null, null); - }; - - SymbolAndDiagnostics.fromAlias = function (symbol, alias) { - return new SymbolAndDiagnostics(symbol, alias, null); - }; - - SymbolAndDiagnostics.prototype.addDiagnostic = function (diagnostic) { - TypeScript.Debug.assert(this !== SymbolAndDiagnostics._empty); - - if (this.diagnostics === null) { - this.diagnostics = []; - } - - this.diagnostics.push(diagnostic); - }; - - SymbolAndDiagnostics.prototype.withoutDiagnostics = function () { - if (!this.diagnostics) { - return this; - } - - return SymbolAndDiagnostics.fromSymbol(this.symbol); - }; - SymbolAndDiagnostics._empty = new SymbolAndDiagnostics(null, null, null); - return SymbolAndDiagnostics; - })(); - TypeScript.SymbolAndDiagnostics = SymbolAndDiagnostics; - - var PullResolutionDataCache = (function () { - function PullResolutionDataCache() { - this.cacheSize = 16; - this.rdCache = []; - this.nextUp = 0; - for (var i = 0; i < this.cacheSize; i++) { - this.rdCache[i] = { - actuals: [], - exactCandidates: [], - conversionCandidates: [], - id: i - }; - } - } - PullResolutionDataCache.prototype.getResolutionData = function () { - var rd = null; - - if (this.nextUp < this.cacheSize) { - rd = this.rdCache[this.nextUp]; - } - - if (rd === null) { - this.cacheSize++; - rd = { - actuals: [], - exactCandidates: [], - conversionCandidates: [], - id: this.cacheSize - }; - this.rdCache[this.cacheSize] = rd; - } - - this.nextUp++; - - return rd; - }; - - PullResolutionDataCache.prototype.returnResolutionData = function (rd) { - rd.actuals.length = 0; - rd.exactCandidates.length = 0; - rd.conversionCandidates.length = 0; - - this.nextUp = rd.id; - }; - return PullResolutionDataCache; - })(); - TypeScript.PullResolutionDataCache = PullResolutionDataCache; - - var PullAdditionalCallResolutionData = (function () { - function PullAdditionalCallResolutionData() { - this.targetSymbol = null; - this.targetTypeSymbol = null; - this.resolvedSignatures = null; - this.candidateSignature = null; - this.actualParametersContextTypeSymbols = null; - } - return PullAdditionalCallResolutionData; - })(); - TypeScript.PullAdditionalCallResolutionData = PullAdditionalCallResolutionData; - - var PullAdditionalObjectLiteralResolutionData = (function () { - function PullAdditionalObjectLiteralResolutionData() { - this.membersContextTypeSymbols = null; - } - return PullAdditionalObjectLiteralResolutionData; - })(); - TypeScript.PullAdditionalObjectLiteralResolutionData = PullAdditionalObjectLiteralResolutionData; - - var PullTypeResolver = (function () { - function PullTypeResolver(compilationSettings, semanticInfoChain, unitPath) { - this.compilationSettings = compilationSettings; - this.semanticInfoChain = semanticInfoChain; - this.unitPath = unitPath; - this._cachedArrayInterfaceType = null; - this._cachedNumberInterfaceType = null; - this._cachedStringInterfaceType = null; - this._cachedBooleanInterfaceType = null; - this._cachedObjectInterfaceType = null; - this._cachedFunctionInterfaceType = null; - this._cachedIArgumentsInterfaceType = null; - this._cachedRegExpInterfaceType = null; - this.cachedFunctionArgumentsSymbol = null; - this.assignableCache = {}; - this.subtypeCache = {}; - this.identicalCache = {}; - this.resolutionDataCache = new PullResolutionDataCache(); - this.currentUnit = null; - this.cachedFunctionArgumentsSymbol = new TypeScript.PullSymbol("arguments", 1024 /* Variable */); - this.cachedFunctionArgumentsSymbol.setType(this.cachedIArgumentsInterfaceType() ? this.cachedIArgumentsInterfaceType() : this.semanticInfoChain.anyTypeSymbol); - this.cachedFunctionArgumentsSymbol.setResolved(); - - var functionArgumentsDecl = new TypeScript.PullDecl("arguments", "arguments", 2048 /* Parameter */, 0 /* None */, new TypeScript.TextSpan(0, 0), unitPath); - functionArgumentsDecl.setSymbol(this.cachedFunctionArgumentsSymbol); - this.cachedFunctionArgumentsSymbol.addDeclaration(functionArgumentsDecl); - - this.currentUnit = this.semanticInfoChain.getUnit(unitPath); - } - PullTypeResolver.prototype.cleanCachedGlobals = function () { - this._cachedArrayInterfaceType = null; - this._cachedNumberInterfaceType = null; - this._cachedStringInterfaceType = null; - this._cachedBooleanInterfaceType = null; - this._cachedObjectInterfaceType = null; - this._cachedFunctionInterfaceType = null; - this._cachedIArgumentsInterfaceType = null; - this._cachedRegExpInterfaceType = null; - this.cachedFunctionArgumentsSymbol = null; - - this.identicalCache = {}; - this.subtypeCache = {}; - this.assignableCache = {}; - }; - - PullTypeResolver.prototype.cachedArrayInterfaceType = function () { - if (!this._cachedArrayInterfaceType) { - this._cachedArrayInterfaceType = this.getSymbolFromDeclPath("Array", [], 16 /* Interface */); - } - - if (!this._cachedArrayInterfaceType) { - this._cachedArrayInterfaceType = this.semanticInfoChain.anyTypeSymbol; - } - - if (!this._cachedArrayInterfaceType.isResolved()) { - this.resolveDeclaredSymbol(this._cachedArrayInterfaceType, null, new TypeScript.PullTypeResolutionContext()); - } - - return this._cachedArrayInterfaceType; - }; - - PullTypeResolver.prototype.getCachedArrayType = function () { - return this.cachedArrayInterfaceType(); - }; - - PullTypeResolver.prototype.cachedNumberInterfaceType = function () { - if (!this._cachedNumberInterfaceType) { - this._cachedNumberInterfaceType = this.getSymbolFromDeclPath("Number", [], 16 /* Interface */); - } - - if (this._cachedNumberInterfaceType && !this._cachedNumberInterfaceType.isResolved()) { - this.resolveDeclaredSymbol(this._cachedNumberInterfaceType, null, new TypeScript.PullTypeResolutionContext()); - } - - return this._cachedNumberInterfaceType; - }; - - PullTypeResolver.prototype.cachedStringInterfaceType = function () { - if (!this._cachedStringInterfaceType) { - this._cachedStringInterfaceType = this.getSymbolFromDeclPath("String", [], 16 /* Interface */); - } - - if (this._cachedStringInterfaceType && !this._cachedStringInterfaceType.isResolved()) { - this.resolveDeclaredSymbol(this._cachedStringInterfaceType, null, new TypeScript.PullTypeResolutionContext()); - } - - return this._cachedStringInterfaceType; - }; - - PullTypeResolver.prototype.cachedBooleanInterfaceType = function () { - if (!this._cachedBooleanInterfaceType) { - this._cachedBooleanInterfaceType = this.getSymbolFromDeclPath("Boolean", [], 16 /* Interface */); - } - - if (this._cachedBooleanInterfaceType && !this._cachedBooleanInterfaceType.isResolved()) { - this.resolveDeclaredSymbol(this._cachedBooleanInterfaceType, null, new TypeScript.PullTypeResolutionContext()); - } - - return this._cachedBooleanInterfaceType; - }; - - PullTypeResolver.prototype.cachedObjectInterfaceType = function () { - if (!this._cachedObjectInterfaceType) { - this._cachedObjectInterfaceType = this.getSymbolFromDeclPath("Object", [], 16 /* Interface */); - } - - if (!this._cachedObjectInterfaceType) { - this._cachedObjectInterfaceType = this.semanticInfoChain.anyTypeSymbol; - } - - if (!this._cachedObjectInterfaceType.isResolved()) { - this.resolveDeclaredSymbol(this._cachedObjectInterfaceType, null, new TypeScript.PullTypeResolutionContext()); - } - - return this._cachedObjectInterfaceType; - }; - - PullTypeResolver.prototype.cachedFunctionInterfaceType = function () { - if (!this._cachedFunctionInterfaceType) { - this._cachedFunctionInterfaceType = this.getSymbolFromDeclPath("Function", [], 16 /* Interface */); - } - - if (this._cachedFunctionInterfaceType && !this._cachedFunctionInterfaceType.isResolved()) { - this.resolveDeclaredSymbol(this._cachedFunctionInterfaceType, null, new TypeScript.PullTypeResolutionContext()); - } - - return this._cachedFunctionInterfaceType; - }; - - PullTypeResolver.prototype.cachedIArgumentsInterfaceType = function () { - if (!this._cachedIArgumentsInterfaceType) { - this._cachedIArgumentsInterfaceType = this.getSymbolFromDeclPath("IArguments", [], 16 /* Interface */); - } - - if (this._cachedIArgumentsInterfaceType && !this._cachedIArgumentsInterfaceType.isResolved()) { - this.resolveDeclaredSymbol(this._cachedIArgumentsInterfaceType, null, new TypeScript.PullTypeResolutionContext()); - } - - return this._cachedIArgumentsInterfaceType; - }; - - PullTypeResolver.prototype.cachedRegExpInterfaceType = function () { - if (!this._cachedRegExpInterfaceType) { - this._cachedRegExpInterfaceType = this.getSymbolFromDeclPath("RegExp", [], 16 /* Interface */); - } - - if (!this._cachedRegExpInterfaceType.isResolved()) { - this.resolveDeclaredSymbol(this._cachedRegExpInterfaceType, null, new TypeScript.PullTypeResolutionContext()); - } - - return this._cachedRegExpInterfaceType; - }; - - PullTypeResolver.prototype.getUnitPath = function () { - return this.unitPath; - }; - - PullTypeResolver.prototype.setUnitPath = function (unitPath) { - this.unitPath = unitPath; - - this.currentUnit = this.semanticInfoChain.getUnit(unitPath); - }; - - PullTypeResolver.prototype.getDeclForAST = function (ast) { - return this.semanticInfoChain.getDeclForAST(ast, this.unitPath); - }; - - PullTypeResolver.prototype.getSymbolAndDiagnosticsForAST = function (ast) { - return this.semanticInfoChain.getSymbolAndDiagnosticsForAST(ast, this.unitPath); - }; - - PullTypeResolver.prototype.setSymbolAndDiagnosticsForAST = function (ast, symbolAndDiagnostics, context) { - if (context && (context.inProvisionalResolution() || context.inSpecialization)) { - return; - } - - this.semanticInfoChain.setSymbolAndDiagnosticsForAST(ast, symbolAndDiagnostics, this.unitPath); - }; - - PullTypeResolver.prototype.getASTForSymbol = function (symbol) { - return this.semanticInfoChain.getASTForSymbol(symbol, this.unitPath); - }; - - PullTypeResolver.prototype.getASTForDecl = function (decl) { - return this.semanticInfoChain.getASTForDecl(decl); - }; - - PullTypeResolver.prototype.getNewErrorTypeSymbol = function (diagnostic, data) { - return new TypeScript.PullErrorTypeSymbol(diagnostic, this.semanticInfoChain.anyTypeSymbol, data); - }; - - PullTypeResolver.prototype.getEnclosingDecl = function (decl) { - var declPath = TypeScript.getPathToDecl(decl); - - if (!declPath.length) { - return null; - } else if (declPath.length > 1 && declPath[declPath.length - 1] === decl) { - return declPath[declPath.length - 2]; - } else { - return declPath[declPath.length - 1]; - } - }; - - PullTypeResolver.prototype.getExportedMemberSymbol = function (symbol, parent) { - if (!(symbol.getKind() & (65536 /* Method */ | 4096 /* Property */))) { - var containerType = !parent.isContainer() ? parent.getAssociatedContainerType() : parent; - - if (containerType && containerType.isContainer() && !TypeScript.PullHelpers.symbolIsEnum(parent)) { - if (symbol.hasFlag(1 /* Exported */)) { - return symbol; - } - - return null; - } - } - - return symbol; - }; - - PullTypeResolver.prototype.getMemberSymbol = function (symbolName, declSearchKind, parent, searchContainedMembers) { - if (typeof searchContainedMembers === "undefined") { searchContainedMembers = false; } - var member = null; - - if (declSearchKind & TypeScript.PullElementKind.SomeValue) { - member = parent.findMember(symbolName); - } else { - member = parent.findNestedType(symbolName); - } - - if (member) { - return this.getExportedMemberSymbol(member, parent); - } - - var containerType = parent.getAssociatedContainerType(); - - if (containerType) { - if (containerType.isClass()) { - return null; - } - - parent = containerType; - } - - if (declSearchKind & TypeScript.PullElementKind.SomeValue) { - member = parent.findMember(symbolName); - } else { - member = parent.findNestedType(symbolName); - } - - if (member) { - return this.getExportedMemberSymbol(member, parent); - } - - var typeDeclarations = parent.getDeclarations(); - var childDecls = null; - - for (var j = 0; j < typeDeclarations.length; j++) { - childDecls = typeDeclarations[j].searchChildDecls(symbolName, declSearchKind); - - if (childDecls.length) { - return this.getExportedMemberSymbol(childDecls[0].getSymbol(), parent); - } - } - }; - - PullTypeResolver.prototype.getSymbolFromDeclPath = function (symbolName, declPath, declSearchKind) { - var symbol = null; - - var decl = null; - var childDecls; - var declSymbol = null; - var declMembers; - var pathDeclKind; - var valDecl = null; - var kind; - var instanceSymbol = null; - var instanceType = null; - var childSymbol = null; - - for (var i = declPath.length - 1; i >= 0; i--) { - decl = declPath[i]; - pathDeclKind = decl.getKind(); - - if (decl.getFlags() & 2097152 /* DeclaredInAWithBlock */) { - return this.semanticInfoChain.anyTypeSymbol; - } - - if (pathDeclKind & (4 /* Container */ | 32 /* DynamicModule */)) { - childDecls = decl.searchChildDecls(symbolName, declSearchKind); - - if (childDecls.length) { - return childDecls[0].getSymbol(); - } - - if (declSearchKind & TypeScript.PullElementKind.SomeValue) { - childDecls = decl.searchChildDecls(symbolName, declSearchKind); - - if (childDecls.length) { - valDecl = childDecls[0]; - - if (valDecl) { - return valDecl.getSymbol(); - } - } - - instanceSymbol = (decl.getSymbol()).getInstanceSymbol(); - - if (instanceSymbol) { - instanceType = instanceSymbol.getType(); - - childSymbol = this.getMemberSymbol(symbolName, declSearchKind, instanceType); - - if (childSymbol && (childSymbol.getKind() & declSearchKind)) { - return childSymbol; - } - } - - childDecls = decl.searchChildDecls(symbolName, 256 /* TypeAlias */); - - if (childDecls.length) { - var sym = childDecls[0].getSymbol(); - - if (sym.isAlias()) { - return sym; - } - } - - valDecl = decl.getValueDecl(); - - if (valDecl) { - decl = valDecl; - } - } - - declSymbol = decl.getSymbol().getType(); - - var childSymbol = this.getMemberSymbol(symbolName, declSearchKind, declSymbol); - - if (childSymbol) { - return childSymbol; - } - } else if ((declSearchKind & (TypeScript.PullElementKind.SomeType | TypeScript.PullElementKind.SomeContainer)) || !(pathDeclKind & 8 /* Class */)) { - var candidateSymbol = null; - - if (pathDeclKind === 131072 /* FunctionExpression */ && symbolName === (decl).getFunctionExpressionName()) { - candidateSymbol = decl.getSymbol(); - } - - childDecls = decl.searchChildDecls(symbolName, declSearchKind); - - if (childDecls.length) { - if (decl.getKind() & TypeScript.PullElementKind.SomeFunction) { - decl.ensureSymbolIsBound(); - } - return childDecls[0].getSymbol(); - } - - if (candidateSymbol) { - return candidateSymbol; - } - - if (declSearchKind & TypeScript.PullElementKind.SomeValue) { - childDecls = decl.searchChildDecls(symbolName, 256 /* TypeAlias */); - - if (childDecls.length) { - var sym = childDecls[0].getSymbol(); - - if (sym.isAlias()) { - return sym; - } - } - } - } - } - - symbol = this.semanticInfoChain.findSymbol([symbolName], declSearchKind); - - return symbol; - }; - - PullTypeResolver.prototype.getVisibleDeclsFromDeclPath = function (declPath, declSearchKind) { - var result = []; - var decl = null; - var childDecls; - var pathDeclKind; - var parameters; - - for (var i = declPath.length - 1; i >= 0; i--) { - decl = declPath[i]; - pathDeclKind = decl.getKind(); - var declSymbol = decl.getSymbol(); - var declKind = decl.getKind(); - - if (declKind !== 8 /* Class */ && declKind !== 16 /* Interface */) { - this.addFilteredDecls(decl.getChildDecls(), declSearchKind, result); - } - - switch (declKind) { - case 4 /* Container */: - case 32 /* DynamicModule */: - if (declSymbol) { - var otherDecls = declSymbol.getDeclarations(); - for (var j = 0, m = otherDecls.length; j < m; j++) { - var otherDecl = otherDecls[j]; - if (otherDecl === decl) { - continue; - } - - var otherDeclChildren = otherDecl.getChildDecls(); - for (var k = 0, s = otherDeclChildren.length; k < s; k++) { - var otherDeclChild = otherDeclChildren[k]; - if ((otherDeclChild.getFlags() & 1 /* Exported */) && (otherDeclChild.getKind() & declSearchKind)) { - result.push(otherDeclChild); - } - } - } - } - - break; - - case 8 /* Class */: - case 16 /* Interface */: - if (declSymbol && declSymbol.isGeneric()) { - parameters = declSymbol.getTypeParameters(); - for (var k = 0; k < parameters.length; k++) { - result.push(parameters[k].getDeclarations()[0]); - } - } - - break; - - case 131072 /* FunctionExpression */: - var functionExpressionName = (decl).getFunctionExpressionName(); - if (declSymbol && functionExpressionName) { - result.push(declSymbol.getDeclarations()[0]); - } - - case 16384 /* Function */: - case 32768 /* ConstructorMethod */: - case 65536 /* Method */: - if (declSymbol) { - var functionType = declSymbol.getType(); - if (functionType.getHasGenericSignature()) { - var signatures = (pathDeclKind === 32768 /* ConstructorMethod */) ? functionType.getConstructSignatures() : functionType.getCallSignatures(); - if (signatures && signatures.length) { - for (var j = 0; j < signatures.length; j++) { - var signature = signatures[j]; - if (signature.isGeneric()) { - parameters = signature.getTypeParameters(); - for (var k = 0; k < parameters.length; k++) { - result.push(parameters[k].getDeclarations()[0]); - } - } - } - } - } - } - - break; - } - } - - var units = this.semanticInfoChain.units; - for (var i = 0, n = units.length; i < n; i++) { - var unit = units[i]; - if (unit === this.currentUnit && declPath.length != 0) { - continue; - } - var topLevelDecls = unit.getTopLevelDecls(); - if (topLevelDecls.length) { - for (var j = 0, m = topLevelDecls.length; j < m; j++) { - var topLevelDecl = topLevelDecls[j]; - if (topLevelDecl.getKind() === 1 /* Script */ || topLevelDecl.getKind() === 0 /* Global */) { - this.addFilteredDecls(topLevelDecl.getChildDecls(), declSearchKind, result); - } - } - } - } - - return result; - }; - - PullTypeResolver.prototype.addFilteredDecls = function (decls, declSearchKind, result) { - if (decls.length) { - for (var i = 0, n = decls.length; i < n; i++) { - var decl = decls[i]; - if (decl.getKind() & declSearchKind) { - result.push(decl); - } - } - } - }; - - PullTypeResolver.prototype.getVisibleDecls = function (enclosingDecl, context) { - var declPath = enclosingDecl !== null ? TypeScript.getPathToDecl(enclosingDecl) : []; - - if (enclosingDecl && !declPath.length) { - declPath = [enclosingDecl]; - } - - var declSearchKind = TypeScript.PullElementKind.SomeType | TypeScript.PullElementKind.SomeContainer | TypeScript.PullElementKind.SomeValue; - - return this.getVisibleDeclsFromDeclPath(declPath, declSearchKind); - }; - - PullTypeResolver.prototype.getVisibleContextSymbols = function (enclosingDecl, context) { - var contextualTypeSymbol = context.getContextualType(); - if (!contextualTypeSymbol || this.isAnyOrEquivalent(contextualTypeSymbol)) { - return null; - } - - var declSearchKind = TypeScript.PullElementKind.SomeType | TypeScript.PullElementKind.SomeContainer | TypeScript.PullElementKind.SomeValue; - var members = contextualTypeSymbol.getAllMembers(declSearchKind, false); - - for (var i = 0; i < members.length; i++) { - members[i].setUnresolved(); - } - - return members; - }; - - PullTypeResolver.prototype.getVisibleMembersFromExpression = function (expression, enclosingDecl, context) { - var prevCanUseTypeSymbol = context.canUseTypeSymbol; - context.canUseTypeSymbol = true; - var lhs = this.resolveAST(expression, false, enclosingDecl, context).symbol; - context.canUseTypeSymbol = prevCanUseTypeSymbol; - var lhsType = lhs.getType(); - - if (!lhsType) { - return null; - } - - if (this.isAnyOrEquivalent(lhsType)) { - return null; - } - - if (!lhsType.isResolved()) { - this.resolveDeclaredSymbol(lhsType, enclosingDecl, context); - } - - var includePrivate = false; - var containerSymbol = lhsType; - if (containerSymbol.getKind() === 33554432 /* ConstructorType */) { - containerSymbol = containerSymbol.getConstructSignatures()[0].getReturnType(); - } - - if (containerSymbol && containerSymbol.isClass()) { - var declPath = TypeScript.getPathToDecl(enclosingDecl); - if (declPath && declPath.length) { - var declarations = containerSymbol.getDeclarations(); - for (var i = 0, n = declarations.length; i < n; i++) { - var declaration = declarations[i]; - if (declPath.indexOf(declaration) >= 0) { - includePrivate = true; - break; - } - } - } - } - - var declSearchKind = TypeScript.PullElementKind.SomeType | TypeScript.PullElementKind.SomeContainer | TypeScript.PullElementKind.SomeValue; - - var members = []; - - if (lhsType.isContainer()) { - if ((lhsType).getExportAssignedContainerSymbol()) { - lhsType = (lhsType).getExportAssignedContainerSymbol(); - } - } - - if (lhsType.isTypeParameter()) { - var constraint = (lhsType).getConstraint(); - - if (constraint) { - lhsType = constraint; - members = lhsType.getAllMembers(declSearchKind, false); - } - } else { - if (lhs.getKind() == 67108864 /* EnumMember */) { - lhsType = this.semanticInfoChain.numberTypeSymbol; - } - - if (lhsType === this.semanticInfoChain.numberTypeSymbol && this.cachedNumberInterfaceType()) { - lhsType = this.cachedNumberInterfaceType(); - } else if (lhsType === this.semanticInfoChain.stringTypeSymbol && this.cachedStringInterfaceType()) { - lhsType = this.cachedStringInterfaceType(); - } else if (lhsType === this.semanticInfoChain.booleanTypeSymbol && this.cachedBooleanInterfaceType()) { - lhsType = this.cachedBooleanInterfaceType(); - } - - if (!lhsType.isResolved()) { - var potentiallySpecializedType = this.resolveDeclaredSymbol(lhsType, enclosingDecl, context); - - if (potentiallySpecializedType != lhsType) { - if (!lhs.isType()) { - context.setTypeInContext(lhs, potentiallySpecializedType); - } - - lhsType = potentiallySpecializedType; - } - } - - members = lhsType.getAllMembers(declSearchKind, includePrivate); - - if (lhsType.isContainer()) { - var associatedInstance = (lhsType).getInstanceSymbol(); - if (associatedInstance) { - var instanceType = associatedInstance.getType(); - if (!instanceType.isResolved()) { - this.resolveDeclaredSymbol(instanceType, enclosingDecl, context); - } - var instanceMembers = instanceType.getAllMembers(declSearchKind, includePrivate); - members = members.concat(instanceMembers); - } - } else if (lhsType.isConstructor()) { - var prototypeStr = "prototype"; - var prototypeSymbol = new TypeScript.PullSymbol(prototypeStr, 4096 /* Property */); - var parentDecl = lhsType.getDeclarations()[0]; - var prototypeDecl = new TypeScript.PullDecl(prototypeStr, prototypeStr, parentDecl.getKind(), parentDecl.getFlags(), parentDecl.getSpan(), parentDecl.getScriptName()); - this.currentUnit.addSynthesizedDecl(prototypeDecl); - prototypeDecl.setParentDecl(parentDecl); - prototypeSymbol.addDeclaration(prototypeDecl); - - members.push(prototypeSymbol); - } else { - var associatedContainerSymbol = lhsType.getAssociatedContainerType(); - if (associatedContainerSymbol) { - var containerType = associatedContainerSymbol.getType(); - if (!containerType.isResolved()) { - this.resolveDeclaredSymbol(containerType, enclosingDecl, context); - } - var containerMembers = containerType.getAllMembers(declSearchKind, includePrivate); - members = members.concat(containerMembers); - } - } - } - - if (lhsType.getCallSignatures().length && this.cachedFunctionInterfaceType()) { - members = members.concat(this.cachedFunctionInterfaceType().getAllMembers(declSearchKind, false)); - } - - for (var i = 0; i < members.length; i++) { - if (!members[i].isResolved()) { - this.resolveDeclaredSymbol(members[i], enclosingDecl, context); - } - members[i].setUnresolved(); - } - - return members; - }; - - PullTypeResolver.prototype.isAnyOrEquivalent = function (type) { - return (type === this.semanticInfoChain.anyTypeSymbol) || type.isError(); - }; - - PullTypeResolver.prototype.isNumberOrEquivalent = function (type) { - return (type === this.semanticInfoChain.numberTypeSymbol) || (this.cachedNumberInterfaceType() && type === this.cachedNumberInterfaceType()); - }; - - PullTypeResolver.prototype.isTypeArgumentOrWrapper = function (type) { - if (!type) { - return false; - } - - if (!type.isGeneric()) { - return false; - } - - if (type.isTypeParameter()) { - return true; - } - - if (type.isArray()) { - return this.isTypeArgumentOrWrapper((type).getElementType()); - } - - var typeArguments = type.getTypeArguments(); - - if (typeArguments) { - for (var i = 0; i < typeArguments.length; i++) { - if (this.isTypeArgumentOrWrapper(typeArguments[i])) { - return true; - } - } - } else { - return true; - } - - return false; - }; - - PullTypeResolver.prototype.isArrayOrEquivalent = function (type) { - return (type.isArray() && (type).getElementType()) || type == this.cachedArrayInterfaceType(); - }; - - PullTypeResolver.prototype.findTypeSymbolForDynamicModule = function (idText, currentFileName, search) { - var originalIdText = idText; - var symbol = search(idText); - - if (symbol === null) { - if (!symbol) { - idText = TypeScript.swapQuotes(originalIdText); - symbol = search(idText); - } - - if (!symbol) { - idText = TypeScript.stripQuotes(originalIdText) + ".ts"; - symbol = search(idText); - } - - if (!symbol) { - idText = TypeScript.stripQuotes(originalIdText) + ".d.ts"; - symbol = search(idText); - } - - if (!symbol && !TypeScript.isRelative(originalIdText)) { - idText = originalIdText; - - var strippedIdText = TypeScript.stripQuotes(idText); - - var path = TypeScript.getRootFilePath(TypeScript.switchToForwardSlashes(currentFileName)); - - while (symbol === null && path != "") { - idText = TypeScript.normalizePath(path + strippedIdText + ".ts"); - symbol = search(idText); - - if (symbol === null) { - idText = TypeScript.changePathToDTS(idText); - symbol = search(idText); - } - - if (symbol === null) { - if (path === '/') { - path = ''; - } else { - path = TypeScript.normalizePath(path + ".."); - path = path && path != '/' ? path + '/' : path; - } - } - } - } - } - - return symbol; - }; - - PullTypeResolver.prototype.resolveDeclaredSymbol = function (symbol, enclosingDecl, context) { - var savedResolvingTypeReference = context.resolvingTypeReference; - context.resolvingTypeReference = false; - - var result = this.resolveDeclaredSymbolWorker(symbol, enclosingDecl, context); - context.resolvingTypeReference = savedResolvingTypeReference; - - return result; - }; - - PullTypeResolver.prototype.resolveDeclaredSymbolWorker = function (symbol, enclosingDecl, context) { - if (!symbol || symbol.isResolved()) { - return symbol; - } - - if (symbol.isResolving()) { - if (!symbol.currentlyBeingSpecialized()) { - if (!symbol.isType()) { - symbol.setType(this.semanticInfoChain.anyTypeSymbol); - } - - return symbol; - } - } - - var thisUnit = this.unitPath; - - var decls = symbol.getDeclarations(); - - var ast = null; - - for (var i = 0; i < decls.length; i++) { - var decl = decls[i]; - - ast = this.semanticInfoChain.getASTForDecl(decl); - - if (!ast || ast.nodeType === 80 /* Member */) { - this.setUnitPath(thisUnit); - return symbol; - } - - this.setUnitPath(decl.getScriptName()); - this.resolveAST(ast, false, enclosingDecl, context); - } - - var typeArgs = symbol.isType() ? (symbol).getTypeArguments() : null; - - if (typeArgs && typeArgs.length) { - var typeParameters = (symbol).getTypeParameters(); - var typeCache = {}; - - for (var i = 0; i < typeParameters.length; i++) { - typeCache[typeParameters[i].getSymbolID().toString()] = typeArgs[i]; - } - - context.pushTypeSpecializationCache(typeCache); - var rootType = TypeScript.getRootType(symbol.getType()); - - var specializedSymbol = TypeScript.specializeType(rootType, typeArgs, this, enclosingDecl, context, ast); - - context.popTypeSpecializationCache(); - - symbol = specializedSymbol; - } - - this.setUnitPath(thisUnit); - - return symbol; - }; - - PullTypeResolver.prototype.resolveModuleDeclaration = function (ast, context) { - var containerDecl = this.getDeclForAST(ast); - var containerSymbol = containerDecl.getSymbol(); - - if (containerSymbol.isResolved()) { - return containerSymbol; - } - - containerSymbol.setResolved(); - - var containerDecls = containerSymbol.getDeclarations(); - - for (var i = 0; i < containerDecls.length; i++) { - var childDecls = containerDecls[i].getChildDecls(); - - for (var j = 0; j < childDecls.length; j++) { - childDecls[j].ensureSymbolIsBound(); - } - } - - if (containerDecl.getKind() != 64 /* Enum */) { - var instanceSymbol = containerSymbol.getInstanceSymbol(); - - if (instanceSymbol) { - this.resolveDeclaredSymbol(instanceSymbol, containerDecl.getParentDecl(), context); - } - - var members = ast.members.members; - - for (var i = 0; i < members.length; i++) { - if (members[i].nodeType == 87 /* ExportAssignment */) { - this.resolveExportAssignmentStatement(members[i], containerDecl, context); - break; - } - } - } - - return containerSymbol; - }; - - PullTypeResolver.prototype.isTypeRefWithoutTypeArgs = function (typeRef) { - if (typeRef.nodeType != 11 /* TypeRef */) { - return false; - } - - if (typeRef.term.nodeType == 20 /* Name */) { - return true; - } else if (typeRef.term.nodeType == 32 /* MemberAccessExpression */) { - var binex = typeRef.term; - - if (binex.operand2.nodeType == 20 /* Name */) { - return true; - } - } - - return false; - }; - - PullTypeResolver.prototype.resolveReferenceTypeDeclaration = function (typeDeclAST, context) { - var typeDecl = this.getDeclForAST(typeDeclAST); - var enclosingDecl = this.getEnclosingDecl(typeDecl); - var typeDeclSymbol = typeDecl.getSymbol(); - var typeDeclIsClass = typeDeclAST.nodeType === 13 /* ClassDeclaration */; - var hasVisited = this.getSymbolAndDiagnosticsForAST(typeDeclAST) != null; - var extendedTypes = []; - var implementedTypes = []; - - if ((typeDeclSymbol.isResolved() && hasVisited) || (typeDeclSymbol.isResolving() && !context.isInBaseTypeResolution())) { - return typeDeclSymbol; - } - - var wasResolving = typeDeclSymbol.isResolving(); - typeDeclSymbol.startResolving(); - - if (!typeDeclSymbol.isResolved()) { - var typeDeclTypeParameters = typeDeclSymbol.getTypeParameters(); - for (var i = 0; i < typeDeclTypeParameters.length; i++) { - this.resolveDeclaredSymbol(typeDeclTypeParameters[i], typeDecl, context); - } - } - - var typeRefDecls = typeDeclSymbol.getDeclarations(); - - for (var i = 0; i < typeRefDecls.length; i++) { - var childDecls = typeRefDecls[i].getChildDecls(); - - for (var j = 0; j < childDecls.length; j++) { - childDecls[j].ensureSymbolIsBound(); - } - } - - var wasInBaseTypeResolution = context.startBaseTypeResolution(); - - if (!typeDeclIsClass && !hasVisited) { - typeDeclSymbol.resetKnownBaseTypeCount(); - } - - if (typeDeclAST.extendsList) { - var savedIsResolvingClassExtendedType = context.isResolvingClassExtendedType; - if (typeDeclIsClass) { - context.isResolvingClassExtendedType = true; - } - - for (var i = typeDeclSymbol.getKnownBaseTypeCount(); i < typeDeclAST.extendsList.members.length; i = typeDeclSymbol.getKnownBaseTypeCount()) { - typeDeclSymbol.incrementKnownBaseCount(); - var parentType = this.resolveTypeReference(new TypeScript.TypeReference(typeDeclAST.extendsList.members[i], 0), typeDecl, context).symbol; - - if (typeDeclSymbol.isValidBaseKind(parentType, true)) { - var resolvedParentType = parentType; - extendedTypes[extendedTypes.length] = parentType; - if (parentType.isGeneric() && parentType.isResolved() && !parentType.getIsSpecialized()) { - parentType = this.specializeTypeToAny(parentType, enclosingDecl, context); - typeDecl.addDiagnostic(new TypeScript.Diagnostic(typeDecl.getScriptName(), typeDeclAST.minChar, typeDeclAST.getLength(), 239 /* Generic_type_references_must_include_all_type_arguments */)); - } - if (!typeDeclSymbol.hasBase(parentType)) { - this.setSymbolAndDiagnosticsForAST(typeDeclAST.extendsList.members[i], SymbolAndDiagnostics.fromSymbol(resolvedParentType), context); - typeDeclSymbol.addExtendedType(parentType); - - var specializations = typeDeclSymbol.getKnownSpecializations(); - - for (var j = 0; j < specializations.length; j++) { - specializations[j].addExtendedType(parentType); - } - } - } - } - - context.isResolvingClassExtendedType = savedIsResolvingClassExtendedType; - } - - if (!typeDeclSymbol.isResolved() && !wasResolving) { - var baseTypeSymbols = typeDeclSymbol.getExtendedTypes(); - for (var i = 0; i < baseTypeSymbols.length; i++) { - var baseType = baseTypeSymbols[i]; - - for (var j = 0; j < extendedTypes.length; j++) { - if (baseType == extendedTypes[j]) { - break; - } - } - - if (j == extendedTypes.length) { - typeDeclSymbol.removeExtendedType(baseType); - } - } - } - - if (typeDeclAST.implementsList && typeDeclIsClass) { - var extendsCount = typeDeclAST.extendsList ? typeDeclAST.extendsList.members.length : 0; - for (var i = typeDeclSymbol.getKnownBaseTypeCount(); ((i - extendsCount) >= 0) && ((i - extendsCount) < typeDeclAST.implementsList.members.length); i = typeDeclSymbol.getKnownBaseTypeCount()) { - typeDeclSymbol.incrementKnownBaseCount(); - var implementedType = this.resolveTypeReference(new TypeScript.TypeReference(typeDeclAST.implementsList.members[i - extendsCount], 0), typeDecl, context).symbol; - - if (typeDeclSymbol.isValidBaseKind(implementedType, false)) { - var resolvedImplementedType = implementedType; - implementedTypes[implementedTypes.length] = implementedType; - if (implementedType.isGeneric() && implementedType.isResolved() && !implementedType.getIsSpecialized()) { - implementedType = this.specializeTypeToAny(implementedType, enclosingDecl, context); - typeDecl.addDiagnostic(new TypeScript.Diagnostic(typeDecl.getScriptName(), typeDeclAST.minChar, typeDeclAST.getLength(), 239 /* Generic_type_references_must_include_all_type_arguments */)); - this.setSymbolAndDiagnosticsForAST(typeDeclAST.implementsList.members[i - extendsCount], SymbolAndDiagnostics.fromSymbol(implementedType), context); - typeDeclSymbol.addImplementedType(implementedType); - } else if (!typeDeclSymbol.hasBase(implementedType)) { - this.setSymbolAndDiagnosticsForAST(typeDeclAST.implementsList.members[i - extendsCount], SymbolAndDiagnostics.fromSymbol(resolvedImplementedType), context); - typeDeclSymbol.addImplementedType(implementedType); - } - } - } - } - - if (!typeDeclSymbol.isResolved() && !wasResolving) { - var baseTypeSymbols = typeDeclSymbol.getImplementedTypes(); - for (var i = 0; i < baseTypeSymbols.length; i++) { - var baseType = baseTypeSymbols[i]; - - for (var j = 0; j < implementedTypes.length; j++) { - if (baseType == implementedTypes[j]) { - break; - } - } - - if (j == implementedTypes.length) { - typeDeclSymbol.removeImplementedType(baseType); - } - } - } - - context.doneBaseTypeResolution(wasInBaseTypeResolution); - if (wasInBaseTypeResolution && (typeDeclAST.implementsList || typeDeclAST.extendsList)) { - return typeDeclSymbol; - } - - if (!typeDeclSymbol.isResolved()) { - var typeDeclMembers = typeDeclSymbol.getMembers(); - for (var i = 0; i < typeDeclMembers.length; i++) { - this.resolveDeclaredSymbol(typeDeclMembers[i], typeDecl, context); - } - - if (!typeDeclIsClass) { - var callSignatures = typeDeclSymbol.getCallSignatures(); - for (var i = 0; i < callSignatures.length; i++) { - this.resolveDeclaredSymbol(callSignatures[i], typeDecl, context); - } - - var constructSignatures = typeDeclSymbol.getConstructSignatures(); - for (var i = 0; i < constructSignatures.length; i++) { - this.resolveDeclaredSymbol(constructSignatures[i], typeDecl, context); - } - - var indexSignatures = typeDeclSymbol.getIndexSignatures(); - for (var i = 0; i < indexSignatures.length; i++) { - this.resolveDeclaredSymbol(indexSignatures[i], typeDecl, context); - } - } - } - - this.setSymbolAndDiagnosticsForAST(typeDeclAST.name, SymbolAndDiagnostics.fromSymbol(typeDeclSymbol), context); - this.setSymbolAndDiagnosticsForAST(typeDeclAST, SymbolAndDiagnostics.fromSymbol(typeDeclSymbol), context); - - typeDeclSymbol.setResolved(); - - return typeDeclSymbol; - }; - - PullTypeResolver.prototype.resolveClassDeclaration = function (classDeclAST, context) { - var classDecl = this.getDeclForAST(classDeclAST); - var classDeclSymbol = classDecl.getSymbol(); - if (classDeclSymbol.isResolved()) { - return classDeclSymbol; - } - - this.resolveReferenceTypeDeclaration(classDeclAST, context); - - var constructorMethod = classDeclSymbol.getConstructorMethod(); - var extendedTypes = classDeclSymbol.getExtendedTypes(); - var parentType = extendedTypes.length ? extendedTypes[0] : null; - - if (constructorMethod) { - var constructorTypeSymbol = constructorMethod.getType(); - - var constructSignatures = constructorTypeSymbol.getConstructSignatures(); - - if (!constructSignatures.length) { - var constructorSignature; - - if (parentType) { - var parentClass = parentType; - var parentConstructor = parentClass.getConstructorMethod(); - var parentConstructorType = parentConstructor.getType(); - var parentConstructSignatures = parentConstructorType.getConstructSignatures(); - - var parentConstructSignature; - var parentParameters; - for (var i = 0; i < parentConstructSignatures.length; i++) { - parentConstructSignature = parentConstructSignatures[i]; - parentParameters = parentConstructSignature.getParameters(); - - constructorSignature = parentConstructSignature.isDefinition() ? new TypeScript.PullDefinitionSignatureSymbol(2097152 /* ConstructSignature */) : new TypeScript.PullSignatureSymbol(2097152 /* ConstructSignature */); - constructorSignature.setReturnType(classDeclSymbol); - - for (var j = 0; j < parentParameters.length; j++) { - constructorSignature.addParameter(parentParameters[j], parentParameters[j].getIsOptional()); - } - - var typeParameters = constructorTypeSymbol.getTypeParameters(); - - for (var j = 0; j < typeParameters.length; j++) { - constructorSignature.addTypeParameter(typeParameters[j]); - } - - constructorTypeSymbol.addConstructSignature(constructorSignature); - constructorSignature.addDeclaration(classDecl); - } - } else { - constructorSignature = new TypeScript.PullSignatureSymbol(2097152 /* ConstructSignature */); - constructorSignature.setReturnType(classDeclSymbol); - constructorTypeSymbol.addConstructSignature(constructorSignature); - constructorSignature.addDeclaration(classDecl); - - var typeParameters = constructorTypeSymbol.getTypeParameters(); - - for (var i = 0; i < typeParameters.length; i++) { - constructorSignature.addTypeParameter(typeParameters[i]); - } - } - } - - if (!classDeclSymbol.isResolved()) { - return classDeclSymbol; - } - - var constructorMembers = constructorTypeSymbol.getMembers(); - - this.resolveDeclaredSymbol(constructorMethod, classDecl, context); - - for (var i = 0; i < constructorMembers.length; i++) { - this.resolveDeclaredSymbol(constructorMembers[i], classDecl, context); - } - - if (parentType) { - var parentConstructorSymbol = (parentType).getConstructorMethod(); - var parentConstructorTypeSymbol = parentConstructorSymbol.getType(); - - if (!constructorTypeSymbol.hasBase(parentConstructorTypeSymbol)) { - constructorTypeSymbol.addExtendedType(parentConstructorTypeSymbol); - } - } - } - - return classDeclSymbol; - }; - - PullTypeResolver.prototype.resolveInterfaceDeclaration = function (interfaceDeclAST, context) { - var interfaceDecl = this.getDeclForAST(interfaceDeclAST); - var interfaceDeclSymbol = interfaceDecl.getSymbol(); - - this.resolveReferenceTypeDeclaration(interfaceDeclAST, context); - return interfaceDeclSymbol; - }; - - PullTypeResolver.prototype.resolveImportDeclaration = function (importStatementAST, context) { - var _this = this; - var importDecl = this.getDeclForAST(importStatementAST); - var enclosingDecl = this.getEnclosingDecl(importDecl); - var importDeclSymbol = importDecl.getSymbol(); - - var aliasName = importStatementAST.id.text; - var aliasedType = null; - - if (importDeclSymbol.isResolved()) { - return importDeclSymbol; - } - - importDeclSymbol.startResolving(); - - if (importStatementAST.alias.nodeType === 11 /* TypeRef */) { - aliasedType = this.resolveTypeReference(importStatementAST.alias, enclosingDecl, context).symbol; - } else if (importStatementAST.alias.nodeType === 20 /* Name */) { - var text = (importStatementAST.alias).actualText; - - if (!TypeScript.isQuoted(text)) { - aliasedType = this.resolveTypeReference(new TypeScript.TypeReference(importStatementAST.alias, 0), enclosingDecl, context).symbol; - } else { - var modPath = (importStatementAST.alias).actualText; - var declPath = TypeScript.getPathToDecl(enclosingDecl); - - importStatementAST.isDynamicImport = true; - - aliasedType = this.findTypeSymbolForDynamicModule(modPath, importDecl.getScriptName(), function (s) { - return _this.getSymbolFromDeclPath(s, declPath, TypeScript.PullElementKind.SomeContainer); - }); - - if (!aliasedType) { - importDecl.addDiagnostic(new TypeScript.SemanticDiagnostic(this.currentUnit.getPath(), importStatementAST.minChar, importStatementAST.getLength(), 140 /* Unable_to_resolve_external_module__0_ */, [text])); - aliasedType = this.semanticInfoChain.anyTypeSymbol; - } - } - } - - if (aliasedType) { - if (!aliasedType.isContainer()) { - importDecl.addDiagnostic(new TypeScript.Diagnostic(this.currentUnit.getPath(), importStatementAST.minChar, importStatementAST.getLength(), 141 /* Module_cannot_be_aliased_to_a_non_module_type */)); - aliasedType = this.semanticInfoChain.anyTypeSymbol; - } else if ((aliasedType).getExportAssignedValueSymbol()) { - importDeclSymbol.setIsUsedAsValue(); - } - - importDeclSymbol.setAliasedType(aliasedType); - importDeclSymbol.setResolved(); - - this.semanticInfoChain.setSymbolAndDiagnosticsForAST(importStatementAST.alias, SymbolAndDiagnostics.fromSymbol(aliasedType), this.unitPath); - } - - return importDeclSymbol; - }; - - PullTypeResolver.prototype.resolveExportAssignmentStatement = function (exportAssignmentAST, enclosingDecl, context) { - var id = exportAssignmentAST.id.text; - var valueSymbol = null; - var typeSymbol = null; - var containerSymbol = null; - - var parentSymbol = enclosingDecl.getSymbol(); - - if (!parentSymbol.isType() && (parentSymbol).isContainer()) { - enclosingDecl.addDiagnostic(new TypeScript.Diagnostic(enclosingDecl.getScriptName(), exportAssignmentAST.minChar, exportAssignmentAST.getLength(), 230 /* Export_assignments_may_only_be_used_in_External_modules */)); - return SymbolAndDiagnostics.fromSymbol(this.semanticInfoChain.anyTypeSymbol); - } - - var declPath = enclosingDecl !== null ? [enclosingDecl] : []; - - containerSymbol = this.getSymbolFromDeclPath(id, declPath, TypeScript.PullElementKind.SomeContainer); - - var acceptableAlias = true; - - if (containerSymbol) { - acceptableAlias = (containerSymbol.getKind() & TypeScript.PullElementKind.AcceptableAlias) != 0; - } - - if (!acceptableAlias && containerSymbol && containerSymbol.getKind() == 256 /* TypeAlias */) { - if (!containerSymbol.isResolved()) { - this.resolveDeclaredSymbol(containerSymbol, enclosingDecl, context); - } - var aliasedType = (containerSymbol).getType(); - - if (aliasedType.getKind() != 32 /* DynamicModule */) { - acceptableAlias = true; - } else { - var aliasedAssignedValue = (containerSymbol).getExportAssignedValueSymbol(); - var aliasedAssignedType = (containerSymbol).getExportAssignedTypeSymbol(); - var aliasedAssignedContainer = (containerSymbol).getExportAssignedContainerSymbol(); - - if (aliasedAssignedValue || aliasedAssignedType || aliasedAssignedContainer) { - if (aliasedAssignedValue) { - valueSymbol = aliasedAssignedValue; - } - if (aliasedAssignedType) { - typeSymbol = aliasedAssignedType; - } - if (aliasedAssignedContainer) { - containerSymbol = aliasedAssignedContainer; - } - acceptableAlias = true; - } - } - } - - if (!acceptableAlias) { - enclosingDecl.addDiagnostic(new TypeScript.Diagnostic(enclosingDecl.getScriptName(), exportAssignmentAST.minChar, exportAssignmentAST.getLength(), 231 /* Export_assignments_may_only_be_made_with_acceptable_kinds */)); - return SymbolAndDiagnostics.fromSymbol(this.semanticInfoChain.voidTypeSymbol); - } - - if (!valueSymbol) { - valueSymbol = this.getSymbolFromDeclPath(id, declPath, TypeScript.PullElementKind.SomeValue); - } - if (!typeSymbol) { - typeSymbol = this.getSymbolFromDeclPath(id, declPath, TypeScript.PullElementKind.SomeType); - } - - if (!valueSymbol && !typeSymbol && !containerSymbol) { - return SymbolAndDiagnostics.create(this.semanticInfoChain.voidTypeSymbol, [context.postError(enclosingDecl.getScriptName(), exportAssignmentAST.minChar, exportAssignmentAST.getLength(), 164 /* Could_not_find_symbol__0_ */, [id])]); - } - - if (valueSymbol) { - if (!valueSymbol.isResolved()) { - this.resolveDeclaredSymbol(valueSymbol, enclosingDecl, context); - } - (parentSymbol).setExportAssignedValueSymbol(valueSymbol); - } - if (typeSymbol) { - if (!typeSymbol.isResolved()) { - this.resolveDeclaredSymbol(typeSymbol, enclosingDecl, context); - } - - (parentSymbol).setExportAssignedTypeSymbol(typeSymbol); - } - if (containerSymbol) { - if (!containerSymbol.isResolved()) { - this.resolveDeclaredSymbol(containerSymbol, enclosingDecl, context); - } - - (parentSymbol).setExportAssignedContainerSymbol(containerSymbol); - } - - return SymbolAndDiagnostics.fromSymbol(this.semanticInfoChain.voidTypeSymbol); - }; - - PullTypeResolver.prototype.resolveFunctionTypeSignature = function (funcDeclAST, enclosingDecl, context) { - var funcDeclSymbol = null; - - var functionDecl = this.getDeclForAST(funcDeclAST); - - if (!functionDecl || !functionDecl.hasSymbol()) { - var semanticInfo = this.semanticInfoChain.getUnit(this.unitPath); - var declCollectionContext = new TypeScript.DeclCollectionContext(semanticInfo); - - declCollectionContext.scriptName = this.unitPath; - - if (enclosingDecl) { - declCollectionContext.pushParent(enclosingDecl); - } - - TypeScript.getAstWalkerFactory().walk(funcDeclAST, TypeScript.preCollectDecls, TypeScript.postCollectDecls, null, declCollectionContext); - - functionDecl = this.getDeclForAST(funcDeclAST); - this.currentUnit.addSynthesizedDecl(functionDecl); - - var binder = new TypeScript.PullSymbolBinder(this.semanticInfoChain); - binder.setUnit(this.unitPath); - if (functionDecl.getKind() === 33554432 /* ConstructorType */) { - binder.bindConstructorTypeDeclarationToPullSymbol(functionDecl); - } else { - binder.bindFunctionTypeDeclarationToPullSymbol(functionDecl); - } - } - - funcDeclSymbol = functionDecl.getSymbol(); - - var signature = funcDeclSymbol.getKind() === 33554432 /* ConstructorType */ ? funcDeclSymbol.getConstructSignatures()[0] : funcDeclSymbol.getCallSignatures()[0]; - - if (funcDeclAST.returnTypeAnnotation) { - var returnTypeSymbol = this.resolveTypeReference(funcDeclAST.returnTypeAnnotation, enclosingDecl, context).symbol; - - signature.setReturnType(returnTypeSymbol); - - if (this.isTypeArgumentOrWrapper(returnTypeSymbol)) { - signature.setHasGenericParameter(); - - if (funcDeclSymbol) { - funcDeclSymbol.getType().setHasGenericSignature(); - } - } - } else { - signature.setReturnType(this.semanticInfoChain.anyTypeSymbol); - } - - if (funcDeclAST.arguments) { - for (var i = 0; i < funcDeclAST.arguments.members.length; i++) { - this.resolveFunctionTypeSignatureParameter(funcDeclAST.arguments.members[i], signature, enclosingDecl, context); - } - } - - if (funcDeclSymbol && signature.hasGenericParameter()) { - funcDeclSymbol.getType().setHasGenericSignature(); - } - - if (signature.hasGenericParameter()) { - if (funcDeclSymbol) { - funcDeclSymbol.getType().setHasGenericSignature(); - } - } - - funcDeclSymbol.setResolved(); - - return funcDeclSymbol; - }; - - PullTypeResolver.prototype.resolveFunctionTypeSignatureParameter = function (argDeclAST, signature, enclosingDecl, context) { - var paramDecl = this.getDeclForAST(argDeclAST); - var paramSymbol = paramDecl.getSymbol(); - - if (argDeclAST.typeExpr) { - var typeRef = this.resolveTypeReference(argDeclAST.typeExpr, enclosingDecl, context).symbol; - - if (paramSymbol.getIsVarArg() && !(typeRef.isArray() || typeRef == this.cachedArrayInterfaceType())) { - var diagnostic = context.postError(this.unitPath, argDeclAST.minChar, argDeclAST.getLength(), 228 /* Rest_parameters_must_be_array_types */, null, enclosingDecl); - typeRef = this.getNewErrorTypeSymbol(diagnostic); - } - - context.setTypeInContext(paramSymbol, typeRef); - - if (this.isTypeArgumentOrWrapper(typeRef)) { - signature.setHasGenericParameter(); - } - } else { - if (paramSymbol.getIsVarArg() && paramSymbol.getType()) { - if (this.cachedArrayInterfaceType()) { - context.setTypeInContext(paramSymbol, TypeScript.specializeToArrayType(this.cachedArrayInterfaceType(), paramSymbol.getType(), this, context)); - } else { - context.setTypeInContext(paramSymbol, paramSymbol.getType()); - } - } else { - context.setTypeInContext(paramSymbol, this.semanticInfoChain.anyTypeSymbol); - } - } - - paramSymbol.setResolved(); - }; - - PullTypeResolver.prototype.resolveFunctionExpressionParameter = function (argDeclAST, contextParam, enclosingDecl, context) { - var paramDecl = this.getDeclForAST(argDeclAST); - var paramSymbol = paramDecl.getSymbol(); - - if (argDeclAST.typeExpr) { - var typeRef = this.resolveTypeReference(argDeclAST.typeExpr, enclosingDecl, context).symbol; - - if (paramSymbol.getIsVarArg() && !(typeRef.isArray() || typeRef == this.cachedArrayInterfaceType())) { - var diagnostic = context.postError(this.unitPath, argDeclAST.minChar, argDeclAST.getLength(), 228 /* Rest_parameters_must_be_array_types */, null, enclosingDecl); - typeRef = this.getNewErrorTypeSymbol(diagnostic); - } - - context.setTypeInContext(paramSymbol, typeRef); - } else { - if (paramSymbol.getIsVarArg() && paramSymbol.getType()) { - if (this.cachedArrayInterfaceType()) { - context.setTypeInContext(paramSymbol, TypeScript.specializeToArrayType(this.cachedArrayInterfaceType(), paramSymbol.getType(), this, context)); - } else { - context.setTypeInContext(paramSymbol, paramSymbol.getType()); - } - } else if (contextParam) { - context.setTypeInContext(paramSymbol, contextParam.getType()); - } else { - context.setTypeInContext(paramSymbol, this.semanticInfoChain.anyTypeSymbol); - } - } - - paramSymbol.setResolved(); - }; - - PullTypeResolver.prototype.resolveInterfaceTypeReference = function (interfaceDeclAST, enclosingDecl, context) { - var interfaceSymbol = null; - - var interfaceDecl = this.getDeclForAST(interfaceDeclAST); - - if (!interfaceDecl) { - var semanticInfo = this.semanticInfoChain.getUnit(this.unitPath); - var declCollectionContext = new TypeScript.DeclCollectionContext(semanticInfo); - - declCollectionContext.scriptName = this.unitPath; - - if (enclosingDecl) { - declCollectionContext.pushParent(enclosingDecl); - } - - TypeScript.getAstWalkerFactory().walk(interfaceDeclAST, TypeScript.preCollectDecls, TypeScript.postCollectDecls, null, declCollectionContext); - - var interfaceDecl = this.getDeclForAST(interfaceDeclAST); - this.currentUnit.addSynthesizedDecl(interfaceDecl); - - var binder = new TypeScript.PullSymbolBinder(this.semanticInfoChain); - - binder.setUnit(this.unitPath); - binder.bindObjectTypeDeclarationToPullSymbol(interfaceDecl); - } - - interfaceSymbol = interfaceDecl.getSymbol(); - - if (interfaceDeclAST.members) { - var memberDecl = null; - var memberSymbol = null; - var memberType = null; - var typeMembers = interfaceDeclAST.members; - - for (var i = 0; i < typeMembers.members.length; i++) { - memberDecl = this.getDeclForAST(typeMembers.members[i]); - memberSymbol = (memberDecl.getKind() & TypeScript.PullElementKind.SomeSignature) ? memberDecl.getSignatureSymbol() : memberDecl.getSymbol(); - - this.resolveDeclaredSymbol(memberSymbol, enclosingDecl, context); - - memberType = memberSymbol.getType(); - - if ((memberType && memberType.isGeneric()) || (memberSymbol.isSignature() && (memberSymbol).isGeneric())) { - interfaceSymbol.setHasGenericMember(); - } - } - } - - interfaceSymbol.setResolved(); - - return interfaceSymbol; - }; - - PullTypeResolver.prototype.resolveTypeReference = function (typeRef, enclosingDecl, context) { - if (typeRef === null) { - return null; - } - - var symbolAndDiagnostics = this.getSymbolAndDiagnosticsForAST(typeRef); - if (!symbolAndDiagnostics) { - symbolAndDiagnostics = this.computeTypeReferenceSymbol(typeRef, enclosingDecl, context); - - if (!symbolAndDiagnostics.symbol.isGeneric()) { - this.setSymbolAndDiagnosticsForAST(typeRef, symbolAndDiagnostics, context); - } - } - - return symbolAndDiagnostics; - }; - - PullTypeResolver.prototype.computeTypeReferenceSymbol = function (typeRef, enclosingDecl, context) { - var typeDeclSymbol = null; - var diagnostic = null; - var symbolAndDiagnostic = null; - - if (typeRef.term.nodeType === 20 /* Name */) { - var prevResolvingTypeReference = context.resolvingTypeReference; - context.resolvingTypeReference = true; - symbolAndDiagnostic = this.resolveTypeNameExpression(typeRef.term, enclosingDecl, context); - typeDeclSymbol = symbolAndDiagnostic.symbol; - - context.resolvingTypeReference = prevResolvingTypeReference; - } else if (typeRef.term.nodeType === 12 /* FunctionDeclaration */) { - typeDeclSymbol = this.resolveFunctionTypeSignature(typeRef.term, enclosingDecl, context); - } else if (typeRef.term.nodeType === 14 /* InterfaceDeclaration */) { - typeDeclSymbol = this.resolveInterfaceTypeReference(typeRef.term, enclosingDecl, context); - } else if (typeRef.term.nodeType === 10 /* GenericType */) { - symbolAndDiagnostic = this.resolveGenericTypeReference(typeRef.term, enclosingDecl, context); - typeDeclSymbol = symbolAndDiagnostic.symbol; - } else if (typeRef.term.nodeType === 32 /* MemberAccessExpression */) { - var dottedName = typeRef.term; - - prevResolvingTypeReference = context.resolvingTypeReference; - symbolAndDiagnostic = this.resolveDottedTypeNameExpression(dottedName, enclosingDecl, context); - typeDeclSymbol = symbolAndDiagnostic.symbol; - context.resolvingTypeReference = prevResolvingTypeReference; - } else if (typeRef.term.nodeType === 5 /* StringLiteral */) { - var stringConstantAST = typeRef.term; - typeDeclSymbol = new TypeScript.PullStringConstantTypeSymbol(stringConstantAST.actualText); - var decl = new TypeScript.PullDecl(stringConstantAST.actualText, stringConstantAST.actualText, typeDeclSymbol.getKind(), null, new TypeScript.TextSpan(stringConstantAST.minChar, stringConstantAST.getLength()), enclosingDecl.getScriptName()); - this.currentUnit.addSynthesizedDecl(decl); - typeDeclSymbol.addDeclaration(decl); - } - - if (!typeDeclSymbol) { - return SymbolAndDiagnostics.create(this.getNewErrorTypeSymbol(null), [context.postError(this.unitPath, typeRef.term.minChar, typeRef.term.getLength(), 146 /* Unable_to_resolve_type */)]); - } - - if (typeDeclSymbol.isError()) { - return SymbolAndDiagnostics.fromSymbol(typeDeclSymbol); - } - - if (typeRef.arrayCount) { - var arraySymbol = typeDeclSymbol.getArrayType(); - - if (!arraySymbol) { - if (!this.cachedArrayInterfaceType().isResolved()) { - this.resolveDeclaredSymbol(this.cachedArrayInterfaceType(), enclosingDecl, context); - } - - if (typeDeclSymbol.isNamedTypeSymbol() && typeDeclSymbol.isGeneric() && !typeDeclSymbol.isTypeParameter() && typeDeclSymbol.isResolved() && !typeDeclSymbol.getIsSpecialized() && typeDeclSymbol.getTypeParameters().length && (typeDeclSymbol.getTypeArguments() == null && !this.isArrayOrEquivalent(typeDeclSymbol)) && this.isTypeRefWithoutTypeArgs(typeRef)) { - context.postError(this.unitPath, typeRef.minChar, typeRef.getLength(), 239 /* Generic_type_references_must_include_all_type_arguments */, null, enclosingDecl, true); - typeDeclSymbol = this.specializeTypeToAny(typeDeclSymbol, enclosingDecl, context); - } - - arraySymbol = TypeScript.specializeToArrayType(this.semanticInfoChain.elementTypeSymbol, typeDeclSymbol, this, context); - - if (!arraySymbol) { - arraySymbol = this.semanticInfoChain.anyTypeSymbol; - } - } - - if (typeRef.arrayCount > 1) { - for (var arity = typeRef.arrayCount - 1; arity > 0; arity--) { - var existingArraySymbol = arraySymbol.getArrayType(); - - if (!existingArraySymbol) { - arraySymbol = TypeScript.specializeToArrayType(this.semanticInfoChain.elementTypeSymbol, arraySymbol, this, context); - } else { - arraySymbol = existingArraySymbol; - } - } - } - - typeDeclSymbol = arraySymbol; - } - - return SymbolAndDiagnostics.fromSymbol(typeDeclSymbol); - }; - - PullTypeResolver.prototype.resolveVariableDeclaration = function (varDecl, context, enclosingDecl) { - var decl = this.getDeclForAST(varDecl); - - if (enclosingDecl && decl.getKind() == 2048 /* Parameter */) { - enclosingDecl.ensureSymbolIsBound(); - } - - var declSymbol = decl.getSymbol(); - var declParameterSymbol = decl.getValueDecl() ? decl.getValueDecl().getSymbol() : null; - - if (declSymbol.isResolved()) { - var declType = declSymbol.getType(); - var valDecl = decl.getValueDecl(); - - if (valDecl) { - var valSymbol = valDecl.getSymbol(); - - if (valSymbol && !valSymbol.isResolved()) { - valSymbol.setType(declType); - valSymbol.setResolved(); - } - } - - return declType; - } - - if (declSymbol.isResolving()) { - if (!context.inSpecialization) { - declSymbol.setType(this.semanticInfoChain.anyTypeSymbol); - declSymbol.setResolved(); - return declSymbol; - } - } - - declSymbol.startResolving(); - - var wrapperDecl = this.getEnclosingDecl(decl); - wrapperDecl = wrapperDecl ? wrapperDecl : enclosingDecl; - - var diagnostic = null; - - if (varDecl.typeExpr) { - var typeExprSymbol = this.resolveTypeReference(varDecl.typeExpr, wrapperDecl, context).symbol; - - if (!typeExprSymbol) { - diagnostic = context.postError(this.unitPath, varDecl.minChar, varDecl.getLength(), 147 /* Unable_to_resolve_type_of__0_ */, [varDecl.id.actualText], decl); - declSymbol.setType(this.getNewErrorTypeSymbol(diagnostic)); - - if (declParameterSymbol) { - context.setTypeInContext(declParameterSymbol, this.semanticInfoChain.anyTypeSymbol); - } - } else if (typeExprSymbol.isError()) { - context.setTypeInContext(declSymbol, typeExprSymbol); - } else { - if (typeExprSymbol.isNamedTypeSymbol() && typeExprSymbol.isGeneric() && !typeExprSymbol.isTypeParameter() && typeExprSymbol.isResolved() && !typeExprSymbol.getIsSpecialized() && typeExprSymbol.getTypeParameters().length && (typeExprSymbol.getTypeArguments() == null && !this.isArrayOrEquivalent(typeExprSymbol)) && this.isTypeRefWithoutTypeArgs(varDecl.typeExpr)) { - context.postError(this.unitPath, varDecl.typeExpr.minChar, varDecl.typeExpr.getLength(), 239 /* Generic_type_references_must_include_all_type_arguments */, null, enclosingDecl, true); - typeExprSymbol = this.specializeTypeToAny(typeExprSymbol, enclosingDecl, context); - } - - if (typeExprSymbol.isContainer()) { - var exportedTypeSymbol = (typeExprSymbol).getExportAssignedTypeSymbol(); - - if (exportedTypeSymbol) { - typeExprSymbol = exportedTypeSymbol; - } else { - var instanceSymbol = (typeExprSymbol.getType()).getInstanceSymbol(); - - if (!instanceSymbol || !TypeScript.PullHelpers.symbolIsEnum(instanceSymbol)) { - typeExprSymbol = this.getNewErrorTypeSymbol(diagnostic); - } else { - typeExprSymbol = instanceSymbol.getType(); - } - } - } else if (declSymbol.getIsVarArg() && !(typeExprSymbol.isArray() || typeExprSymbol == this.cachedArrayInterfaceType())) { - var diagnostic = context.postError(this.unitPath, varDecl.minChar, varDecl.getLength(), 228 /* Rest_parameters_must_be_array_types */, null, enclosingDecl); - typeExprSymbol = this.getNewErrorTypeSymbol(diagnostic); - } - - context.setTypeInContext(declSymbol, typeExprSymbol); - - if (declParameterSymbol) { - declParameterSymbol.setType(typeExprSymbol); - } - - if ((varDecl.nodeType === 19 /* Parameter */) && enclosingDecl && ((typeExprSymbol.isGeneric() && !typeExprSymbol.isArray()) || this.isTypeArgumentOrWrapper(typeExprSymbol))) { - var signature = enclosingDecl.getSpecializingSignatureSymbol(); - - if (signature) { - signature.setHasGenericParameter(); - } - } - } - } else if (varDecl.init) { - var initExprSymbolAndDiagnostics = this.resolveAST(varDecl.init, false, wrapperDecl, context); - var initExprSymbol = initExprSymbolAndDiagnostics && initExprSymbolAndDiagnostics.symbol; - - if (!initExprSymbol) { - diagnostic = context.postError(this.unitPath, varDecl.minChar, varDecl.getLength(), 147 /* Unable_to_resolve_type_of__0_ */, [varDecl.id.actualText], decl); - - context.setTypeInContext(declSymbol, this.getNewErrorTypeSymbol(diagnostic)); - - if (declParameterSymbol) { - context.setTypeInContext(declParameterSymbol, this.semanticInfoChain.anyTypeSymbol); - } - } else { - context.setTypeInContext(declSymbol, this.widenType(initExprSymbol.getType())); - initExprSymbol.addOutgoingLink(declSymbol, 2 /* ProvidesInferredType */); - - if (declParameterSymbol) { - context.setTypeInContext(declParameterSymbol, initExprSymbol.getType()); - initExprSymbol.addOutgoingLink(declParameterSymbol, 2 /* ProvidesInferredType */); - } - } - } else if (declSymbol.getKind() === 4 /* Container */) { - instanceSymbol = (declSymbol).getInstanceSymbol(); - var instanceType = instanceSymbol.getType(); - - if (instanceType) { - context.setTypeInContext(declSymbol, instanceType); - } else { - context.setTypeInContext(declSymbol, this.semanticInfoChain.anyTypeSymbol); - } - } else { - var defaultType = this.semanticInfoChain.anyTypeSymbol; - - if (declSymbol.getIsVarArg()) { - defaultType = TypeScript.specializeToArrayType(this.cachedArrayInterfaceType(), defaultType, this, context); - } - - context.setTypeInContext(declSymbol, defaultType); - - if (declParameterSymbol) { - declParameterSymbol.setType(defaultType); - } - } - - declSymbol.setResolved(); - - if (declParameterSymbol) { - declParameterSymbol.setResolved(); - } - - return declSymbol; - }; - - PullTypeResolver.prototype.resolveTypeParameterDeclaration = function (typeParameterAST, context) { - var typeParameterDecl = this.getDeclForAST(typeParameterAST); - var typeParameterSymbol = typeParameterDecl.getSymbol(); - - if (typeParameterSymbol.isResolved() || typeParameterSymbol.isResolving()) { - return typeParameterSymbol; - } - - typeParameterSymbol.startResolving(); - - if (typeParameterAST.constraint) { - var enclosingDecl = this.getEnclosingDecl(typeParameterDecl); - var constraintTypeSymbol = this.resolveTypeReference(typeParameterAST.constraint, enclosingDecl, context).symbol; - - if (constraintTypeSymbol.isNamedTypeSymbol() && constraintTypeSymbol.isGeneric() && !constraintTypeSymbol.isTypeParameter() && constraintTypeSymbol.getTypeParameters().length && (constraintTypeSymbol.getTypeArguments() == null && !this.isArrayOrEquivalent(constraintTypeSymbol)) && constraintTypeSymbol.isResolved() && this.isTypeRefWithoutTypeArgs(typeParameterAST.constraint)) { - context.postError(this.unitPath, typeParameterAST.constraint.minChar, typeParameterAST.constraint.getLength(), 239 /* Generic_type_references_must_include_all_type_arguments */, null, enclosingDecl, true); - constraintTypeSymbol = this.specializeTypeToAny(constraintTypeSymbol, enclosingDecl, context); - } - - if (constraintTypeSymbol) { - typeParameterSymbol.setConstraint(constraintTypeSymbol); - } - } - - typeParameterSymbol.setResolved(); - - return typeParameterSymbol; - }; - - PullTypeResolver.prototype.resolveFunctionBodyReturnTypes = function (funcDeclAST, signature, useContextualType, enclosingDecl, context) { - var _this = this; - var returnStatements = []; - - var enclosingDeclStack = [enclosingDecl]; - - var preFindReturnExpressionTypes = function (ast, parent, walker) { - var go = true; - - switch (ast.nodeType) { - case 12 /* FunctionDeclaration */: - go = false; - break; - - case 93 /* ReturnStatement */: - var returnStatement = ast; - returnStatements[returnStatements.length] = { returnStatement: returnStatement, enclosingDecl: enclosingDeclStack[enclosingDeclStack.length - 1] }; - go = false; - break; - - case 101 /* CatchClause */: - case 99 /* WithStatement */: - enclosingDeclStack[enclosingDeclStack.length] = _this.getDeclForAST(ast); - break; - - default: - break; - } - - walker.options.goChildren = go; - - return ast; - }; - - var postFindReturnExpressionEnclosingDecls = function (ast, parent, walker) { - switch (ast.nodeType) { - case 101 /* CatchClause */: - case 99 /* WithStatement */: - enclosingDeclStack.length--; - break; - default: - break; - } - - walker.options.goChildren = true; - - return ast; - }; - - TypeScript.getAstWalkerFactory().walk(funcDeclAST.block, preFindReturnExpressionTypes, postFindReturnExpressionEnclosingDecls); - - if (!returnStatements.length) { - signature.setReturnType(this.semanticInfoChain.voidTypeSymbol); - } else { - var returnExpressionSymbols = []; - var returnType; - - for (var i = 0; i < returnStatements.length; i++) { - if (returnStatements[i].returnStatement.returnExpression) { - returnType = this.resolveAST(returnStatements[i].returnStatement.returnExpression, useContextualType, returnStatements[i].enclosingDecl, context).symbol.getType(); - - if (returnType.isError()) { - signature.setReturnType(returnType); - return; - } - - returnExpressionSymbols[returnExpressionSymbols.length] = returnType; - } - } - - if (!returnExpressionSymbols.length) { - signature.setReturnType(this.semanticInfoChain.voidTypeSymbol); - } else { - var collection = { - getLength: function () { - return returnExpressionSymbols.length; - }, - setTypeAtIndex: function (index, type) { - }, - getTypeAtIndex: function (index) { - return returnExpressionSymbols[index].getType(); - } - }; - - returnType = this.findBestCommonType(returnExpressionSymbols[0], null, collection, context, new TypeScript.TypeComparisonInfo()); - - if (useContextualType && returnType == this.semanticInfoChain.anyTypeSymbol) { - var contextualType = context.getContextualType(); - - if (contextualType) { - returnType = contextualType; - } - } - - signature.setReturnType(returnType ? this.widenType(returnType) : this.semanticInfoChain.anyTypeSymbol); - - if (this.isTypeArgumentOrWrapper(returnType)) { - var functionDecl = this.getDeclForAST(funcDeclAST); - var functionSymbol = functionDecl.getSymbol(); - - if (functionSymbol) { - functionSymbol.getType().setHasGenericSignature(); - } - } - - for (var i = 0; i < returnExpressionSymbols.length; i++) { - returnExpressionSymbols[i].addOutgoingLink(signature, 2 /* ProvidesInferredType */); - } - } - } - }; - - PullTypeResolver.prototype.resolveFunctionDeclaration = function (funcDeclAST, context) { - var funcDecl = this.getDeclForAST(funcDeclAST); - - var funcSymbol = funcDecl.getSymbol(); - - var signature = funcDecl.getSpecializingSignatureSymbol(); - - var hadError = false; - - var isConstructor = funcDeclAST.isConstructor || TypeScript.hasFlag(funcDeclAST.getFunctionFlags(), 1024 /* ConstructMember */); - - if (signature) { - if (signature.isResolved()) { - return funcSymbol; - } - - if (isConstructor && !signature.isResolving()) { - var classAST = funcDeclAST.classDecl; - - if (classAST) { - var classDecl = this.getDeclForAST(classAST); - var classSymbol = classDecl.getSymbol(); - - if (!classSymbol.isResolved() && !classSymbol.isResolving()) { - this.resolveDeclaredSymbol(classSymbol, this.getEnclosingDecl(classDecl), context); - } - } - } - - var diagnostic; - - if (signature.isResolving()) { - if (funcDeclAST.returnTypeAnnotation) { - var returnTypeSymbol = this.resolveTypeReference(funcDeclAST.returnTypeAnnotation, funcDecl, context).symbol; - if (!returnTypeSymbol) { - diagnostic = context.postError(this.unitPath, funcDeclAST.returnTypeAnnotation.minChar, funcDeclAST.returnTypeAnnotation.getLength(), 197 /* Cannot_resolve_return_type_reference */, null, funcDecl); - signature.setReturnType(this.getNewErrorTypeSymbol(diagnostic)); - hadError = true; - } else { - if (this.isTypeArgumentOrWrapper(returnTypeSymbol)) { - signature.setHasGenericParameter(); - if (funcSymbol) { - funcSymbol.getType().setHasGenericSignature(); - } - } - signature.setReturnType(returnTypeSymbol); - - if (isConstructor && returnTypeSymbol === this.semanticInfoChain.voidTypeSymbol) { - context.postError(this.unitPath, funcDeclAST.minChar, funcDeclAST.getLength(), 198 /* Constructors_cannot_have_a_return_type_of__void_ */, null, funcDecl, true); - } - } - } else { - signature.setReturnType(this.semanticInfoChain.anyTypeSymbol); - } - - signature.setResolved(); - return funcSymbol; - } - - signature.startResolving(); - - if (funcDeclAST.typeArguments) { - for (var i = 0; i < funcDeclAST.typeArguments.members.length; i++) { - this.resolveTypeParameterDeclaration(funcDeclAST.typeArguments.members[i], context); - } - } - - if (funcDeclAST.arguments) { - for (var i = 0; i < funcDeclAST.arguments.members.length; i++) { - this.resolveVariableDeclaration(funcDeclAST.arguments.members[i], context, funcDecl); - } - } - - if (signature.isGeneric()) { - if (funcSymbol) { - funcSymbol.getType().setHasGenericSignature(); - } - } - - if (funcDeclAST.returnTypeAnnotation) { - var prevReturnTypeSymbol = signature.getReturnType(); - - returnTypeSymbol = this.resolveTypeReference(funcDeclAST.returnTypeAnnotation, funcDecl, context).symbol; - - if (!returnTypeSymbol) { - diagnostic = context.postError(this.unitPath, funcDeclAST.returnTypeAnnotation.minChar, funcDeclAST.returnTypeAnnotation.getLength(), 197 /* Cannot_resolve_return_type_reference */, null, funcDecl); - signature.setReturnType(this.getNewErrorTypeSymbol(diagnostic)); - - hadError = true; - } else if (!(this.isTypeArgumentOrWrapper(returnTypeSymbol) && prevReturnTypeSymbol && !this.isTypeArgumentOrWrapper(prevReturnTypeSymbol))) { - if (this.isTypeArgumentOrWrapper(returnTypeSymbol)) { - signature.setHasGenericParameter(); - - if (funcSymbol) { - funcSymbol.getType().setHasGenericSignature(); - } - } - - signature.setReturnType(returnTypeSymbol); - - if (isConstructor && returnTypeSymbol === this.semanticInfoChain.voidTypeSymbol) { - context.postError(this.unitPath, funcDeclAST.minChar, funcDeclAST.getLength(), 198 /* Constructors_cannot_have_a_return_type_of__void_ */, null, funcDecl, true); - } - } - } else if (!funcDeclAST.isConstructor) { - if (funcDeclAST.isSignature()) { - signature.setReturnType(this.semanticInfoChain.anyTypeSymbol); - } else { - this.resolveFunctionBodyReturnTypes(funcDeclAST, signature, false, funcDecl, context); - } - } - - if (!hadError) { - signature.setResolved(); - } - } - - return funcSymbol; - }; - - PullTypeResolver.prototype.resolveGetAccessorDeclaration = function (funcDeclAST, context) { - var funcDecl = this.getDeclForAST(funcDeclAST); - var accessorSymbol = funcDecl.getSymbol(); - - var getterSymbol = accessorSymbol.getGetter(); - var getterTypeSymbol = getterSymbol.getType(); - - var signature = getterTypeSymbol.getCallSignatures()[0]; - - var hadError = false; - var diagnostic; - - if (signature) { - if (signature.isResolved()) { - return accessorSymbol; - } - - if (signature.isResolving()) { - signature.setReturnType(this.semanticInfoChain.anyTypeSymbol); - signature.setResolved(); - - return accessorSymbol; - } - - signature.startResolving(); - - if (funcDeclAST.arguments) { - for (var i = 0; i < funcDeclAST.arguments.members.length; i++) { - this.resolveVariableDeclaration(funcDeclAST.arguments.members[i], context, funcDecl); - } - } - - if (signature.hasGenericParameter()) { - if (getterSymbol) { - getterTypeSymbol.setHasGenericSignature(); - } - } - - if (funcDeclAST.returnTypeAnnotation) { - var returnTypeSymbol = this.resolveTypeReference(funcDeclAST.returnTypeAnnotation, funcDecl, context).symbol; - - if (!returnTypeSymbol) { - diagnostic = context.postError(this.unitPath, funcDeclAST.returnTypeAnnotation.minChar, funcDeclAST.returnTypeAnnotation.getLength(), 197 /* Cannot_resolve_return_type_reference */, null, funcDecl); - signature.setReturnType(this.getNewErrorTypeSymbol(diagnostic)); - - hadError = true; - } else { - if (this.isTypeArgumentOrWrapper(returnTypeSymbol)) { - signature.setHasGenericParameter(); - - if (getterSymbol) { - getterTypeSymbol.setHasGenericSignature(); - } - } - - signature.setReturnType(returnTypeSymbol); - } - } else { - if (funcDeclAST.isSignature()) { - signature.setReturnType(this.semanticInfoChain.anyTypeSymbol); - } else { - this.resolveFunctionBodyReturnTypes(funcDeclAST, signature, false, funcDecl, context); - } - } - - if (!hadError) { - signature.setResolved(); - } - } - - var accessorType = signature.getReturnType(); - - var setter = accessorSymbol.getSetter(); - - if (setter) { - var setterType = setter.getType(); - var setterSig = setterType.getCallSignatures()[0]; - - if (setterSig.isResolved()) { - var setterParameters = setterSig.getParameters(); - - if (setterParameters.length) { - var setterParameter = setterParameters[0]; - var setterParameterType = setterParameter.getType(); - - if (!this.typesAreIdentical(accessorType, setterParameterType)) { - diagnostic = context.postError(this.unitPath, funcDeclAST.minChar, funcDeclAST.getLength(), 165 /* _get__and__set__accessor_must_have_the_same_type */, null, this.getEnclosingDecl(funcDecl)); - accessorSymbol.setType(this.getNewErrorTypeSymbol(diagnostic)); - } - } - } else { - accessorSymbol.setType(accessorType); - } - } else { - accessorSymbol.setType(accessorType); - } - - return accessorSymbol; - }; - - PullTypeResolver.prototype.resolveSetAccessorDeclaration = function (funcDeclAST, context) { - var funcDecl = this.getDeclForAST(funcDeclAST); - var accessorSymbol = funcDecl.getSymbol(); - - var setterSymbol = accessorSymbol.getSetter(); - var setterTypeSymbol = setterSymbol.getType(); - - var signature = setterTypeSymbol.getCallSignatures()[0]; - - var hadError = false; - - if (signature) { - if (signature.isResolved()) { - return accessorSymbol; - } - - if (signature.isResolving()) { - signature.setReturnType(this.semanticInfoChain.anyTypeSymbol); - signature.setResolved(); - - return accessorSymbol; - } - - signature.startResolving(); - - if (funcDeclAST.arguments) { - for (var i = 0; i < funcDeclAST.arguments.members.length; i++) { - this.resolveVariableDeclaration(funcDeclAST.arguments.members[i], context, funcDecl); - } - } - - if (signature.hasGenericParameter()) { - if (setterSymbol) { - setterTypeSymbol.setHasGenericSignature(); - } - } - - if (!hadError) { - signature.setResolved(); - } - } - - var parameters = signature.getParameters(); - - var getter = accessorSymbol.getGetter(); - - var accessorType = parameters.length ? parameters[0].getType() : getter ? getter.getType() : this.semanticInfoChain.undefinedTypeSymbol; - - if (getter) { - var getterType = getter.getType(); - var getterSig = getterType.getCallSignatures()[0]; - - if (accessorType == this.semanticInfoChain.undefinedTypeSymbol) { - accessorType = getterType; - } - - if (getterSig.isResolved()) { - var getterReturnType = getterSig.getReturnType(); - - if (!this.typesAreIdentical(accessorType, getterReturnType)) { - if (this.isAnyOrEquivalent(accessorType)) { - accessorSymbol.setType(getterReturnType); - if (!accessorType.isError()) { - parameters[0].setType(getterReturnType); - } - } else { - var diagnostic = context.postError(this.unitPath, funcDeclAST.minChar, funcDeclAST.getLength(), 165 /* _get__and__set__accessor_must_have_the_same_type */, null, this.getEnclosingDecl(funcDecl)); - accessorSymbol.setType(this.getNewErrorTypeSymbol(diagnostic)); - } - } - } else { - accessorSymbol.setType(accessorType); - } - } else { - accessorSymbol.setType(accessorType); - } - - return accessorSymbol; - }; - - PullTypeResolver.prototype.resolveAST = function (ast, inContextuallyTypedAssignment, enclosingDecl, context) { - TypeScript.globalSemanticInfoChain = this.semanticInfoChain; - - if (TypeScript.globalBinder) { - TypeScript.globalBinder.semanticInfoChain = this.semanticInfoChain; - } - - switch (ast.nodeType) { - case 101 /* CatchClause */: - case 99 /* WithStatement */: - case 2 /* Script */: - return SymbolAndDiagnostics.fromSymbol(null); - - case 15 /* ModuleDeclaration */: - return SymbolAndDiagnostics.fromSymbol(this.resolveModuleDeclaration(ast, context)); - - case 14 /* InterfaceDeclaration */: - return SymbolAndDiagnostics.fromSymbol(this.resolveInterfaceDeclaration(ast, context)); - - case 13 /* ClassDeclaration */: - return SymbolAndDiagnostics.fromSymbol(this.resolveClassDeclaration(ast, context)); - - case 17 /* VariableDeclarator */: - case 19 /* Parameter */: - return SymbolAndDiagnostics.fromSymbol(this.resolveVariableDeclaration(ast, context, enclosingDecl)); - - case 9 /* TypeParameter */: - return SymbolAndDiagnostics.fromSymbol(this.resolveTypeParameterDeclaration(ast, context)); - - case 16 /* ImportDeclaration */: - return SymbolAndDiagnostics.fromSymbol(this.resolveImportDeclaration(ast, context)); - - case 22 /* ObjectLiteralExpression */: - return this.resolveObjectLiteralExpression(ast, inContextuallyTypedAssignment, enclosingDecl, context); - - case 10 /* GenericType */: - return this.resolveGenericTypeReference(ast, enclosingDecl, context); - - case 20 /* Name */: - if (context.resolvingTypeReference) { - return this.resolveTypeNameExpression(ast, enclosingDecl, context); - } else { - return this.resolveNameExpression(ast, enclosingDecl, context); - } - - case 32 /* MemberAccessExpression */: - if (context.resolvingTypeReference) { - return this.resolveDottedTypeNameExpression(ast, enclosingDecl, context); - } else { - return this.resolveDottedNameExpression(ast, enclosingDecl, context); - } - - case 10 /* GenericType */: - return this.resolveGenericTypeReference(ast, enclosingDecl, context); - - case 12 /* FunctionDeclaration */: { - var funcDecl = ast; - - if (funcDecl.isGetAccessor()) { - return SymbolAndDiagnostics.fromSymbol(this.resolveGetAccessorDeclaration(funcDecl, context)); - } else if (funcDecl.isSetAccessor()) { - return SymbolAndDiagnostics.fromSymbol(this.resolveSetAccessorDeclaration(funcDecl, context)); - } else if (inContextuallyTypedAssignment || (funcDecl.getFunctionFlags() & 8192 /* IsFunctionExpression */) || (funcDecl.getFunctionFlags() & 2048 /* IsFatArrowFunction */) || (funcDecl.getFunctionFlags() & 16384 /* IsFunctionProperty */)) { - return SymbolAndDiagnostics.fromSymbol(this.resolveFunctionExpression(funcDecl, inContextuallyTypedAssignment, enclosingDecl, context)); - } else { - return SymbolAndDiagnostics.fromSymbol(this.resolveFunctionDeclaration(funcDecl, context)); - } - } - - case 21 /* ArrayLiteralExpression */: - return this.resolveArrayLiteralExpression(ast, inContextuallyTypedAssignment, enclosingDecl, context); - - case 29 /* ThisExpression */: - return this.resolveThisExpression(ast, enclosingDecl, context); - - case 30 /* SuperExpression */: - return this.resolveSuperExpression(ast, enclosingDecl, context); - - case 36 /* InvocationExpression */: - return this.resolveCallExpression(ast, inContextuallyTypedAssignment, enclosingDecl, context); - - case 37 /* ObjectCreationExpression */: - return this.resolveNewExpression(ast, inContextuallyTypedAssignment, enclosingDecl, context); - - case 78 /* CastExpression */: - return this.resolveTypeAssertionExpression(ast, inContextuallyTypedAssignment, enclosingDecl, context); - - case 11 /* TypeRef */: - return this.resolveTypeReference(ast, enclosingDecl, context); - - case 87 /* ExportAssignment */: - return this.resolveExportAssignmentStatement(ast, enclosingDecl, context); - - case 7 /* NumericLiteral */: - return SymbolAndDiagnostics.fromSymbol(this.semanticInfoChain.numberTypeSymbol); - case 5 /* StringLiteral */: - return SymbolAndDiagnostics.fromSymbol(this.semanticInfoChain.stringTypeSymbol); - case 8 /* NullLiteral */: - return SymbolAndDiagnostics.fromSymbol(this.semanticInfoChain.nullTypeSymbol); - case 3 /* TrueLiteral */: - case 4 /* FalseLiteral */: - return SymbolAndDiagnostics.fromSymbol(this.semanticInfoChain.booleanTypeSymbol); - case 24 /* VoidExpression */: - return SymbolAndDiagnostics.fromSymbol(this.semanticInfoChain.voidTypeSymbol); - - case 38 /* AssignmentExpression */: - return this.resolveAssignmentStatement(ast, inContextuallyTypedAssignment, enclosingDecl, context); - - case 73 /* LogicalNotExpression */: - case 57 /* NotEqualsWithTypeConversionExpression */: - case 56 /* EqualsWithTypeConversionExpression */: - case 58 /* EqualsExpression */: - case 59 /* NotEqualsExpression */: - case 60 /* LessThanExpression */: - case 61 /* LessThanOrEqualExpression */: - case 63 /* GreaterThanOrEqualExpression */: - case 62 /* GreaterThanExpression */: - return SymbolAndDiagnostics.fromSymbol(this.semanticInfoChain.booleanTypeSymbol); - - case 64 /* AddExpression */: - case 39 /* AddAssignmentExpression */: - return this.resolveArithmeticExpression(ast, inContextuallyTypedAssignment, enclosingDecl, context); - - case 40 /* SubtractAssignmentExpression */: - case 42 /* MultiplyAssignmentExpression */: - case 41 /* DivideAssignmentExpression */: - case 43 /* ModuloAssignmentExpression */: - case 46 /* OrAssignmentExpression */: - case 44 /* AndAssignmentExpression */: - - case 72 /* BitwiseNotExpression */: - case 65 /* SubtractExpression */: - case 66 /* MultiplyExpression */: - case 67 /* DivideExpression */: - case 68 /* ModuloExpression */: - case 53 /* BitwiseOrExpression */: - case 55 /* BitwiseAndExpression */: - case 26 /* PlusExpression */: - case 27 /* NegateExpression */: - case 76 /* PostIncrementExpression */: - case 74 /* PreIncrementExpression */: - case 77 /* PostDecrementExpression */: - case 75 /* PreDecrementExpression */: - return SymbolAndDiagnostics.fromSymbol(this.semanticInfoChain.numberTypeSymbol); - - case 69 /* LeftShiftExpression */: - case 70 /* SignedRightShiftExpression */: - case 71 /* UnsignedRightShiftExpression */: - case 47 /* LeftShiftAssignmentExpression */: - case 48 /* SignedRightShiftAssignmentExpression */: - case 49 /* UnsignedRightShiftAssignmentExpression */: - return SymbolAndDiagnostics.fromSymbol(this.semanticInfoChain.numberTypeSymbol); - - case 35 /* ElementAccessExpression */: - return this.resolveIndexExpression(ast, inContextuallyTypedAssignment, enclosingDecl, context); - - case 51 /* LogicalOrExpression */: - return this.resolveLogicalOrExpression(ast, inContextuallyTypedAssignment, enclosingDecl, context); - - case 52 /* LogicalAndExpression */: - return this.resolveLogicalAndExpression(ast, inContextuallyTypedAssignment, enclosingDecl, context); - - case 34 /* TypeOfExpression */: - return SymbolAndDiagnostics.fromSymbol(this.semanticInfoChain.stringTypeSymbol); - - case 95 /* ThrowStatement */: - return SymbolAndDiagnostics.fromSymbol(this.semanticInfoChain.voidTypeSymbol); - - case 28 /* DeleteExpression */: - return SymbolAndDiagnostics.fromSymbol(this.semanticInfoChain.booleanTypeSymbol); - - case 50 /* ConditionalExpression */: - return this.resolveConditionalExpression(ast, enclosingDecl, context); - - case 6 /* RegularExpressionLiteral */: - return this.resolveRegularExpressionLiteral(); - - case 79 /* ParenthesizedExpression */: - return this.resolveParenthesizedExpression(ast, enclosingDecl, context); - - case 88 /* ExpressionStatement */: - return this.resolveExpressionStatement(ast, inContextuallyTypedAssignment, enclosingDecl, context); - - case 33 /* InstanceOfExpression */: - return SymbolAndDiagnostics.fromSymbol(this.semanticInfoChain.booleanTypeSymbol); - } - - return SymbolAndDiagnostics.fromSymbol(this.semanticInfoChain.anyTypeSymbol); - }; - - PullTypeResolver.prototype.resolveRegularExpressionLiteral = function () { - if (this.cachedRegExpInterfaceType()) { - return SymbolAndDiagnostics.fromSymbol(this.cachedRegExpInterfaceType()); - } else { - return SymbolAndDiagnostics.fromSymbol(this.semanticInfoChain.anyTypeSymbol); - } - }; - - PullTypeResolver.prototype.isNameOrMemberAccessExpression = function (ast) { - var checkAST = ast; - - while (checkAST) { - if (checkAST.nodeType === 88 /* ExpressionStatement */) { - checkAST = (checkAST).expression; - } else if (checkAST.nodeType === 79 /* ParenthesizedExpression */) { - checkAST = (checkAST).expression; - } else if (checkAST.nodeType === 20 /* Name */) { - return true; - } else if (checkAST.nodeType === 32 /* MemberAccessExpression */) { - return true; - } else { - return false; - } - } - }; - - PullTypeResolver.prototype.resolveNameSymbol = function (nameSymbol, context) { - if (nameSymbol && !context.canUseTypeSymbol && nameSymbol != this.semanticInfoChain.undefinedTypeSymbol && nameSymbol != this.semanticInfoChain.nullTypeSymbol && (nameSymbol.isPrimitive() || !(nameSymbol.getKind() & TypeScript.PullElementKind.SomeValue))) { - nameSymbol = null; - } - - return nameSymbol; - }; - - PullTypeResolver.prototype.resolveNameExpression = function (nameAST, enclosingDecl, context) { - var nameSymbolAndDiagnostics = this.getSymbolAndDiagnosticsForAST(nameAST); - var foundCached = nameSymbolAndDiagnostics != null; - - if (!foundCached) { - nameSymbolAndDiagnostics = this.computeNameExpression(nameAST, enclosingDecl, context); - } - - var nameSymbol = nameSymbolAndDiagnostics.symbol; - if (!nameSymbol.isResolved()) { - this.resolveDeclaredSymbol(nameSymbol, enclosingDecl, context); - } - - if (!foundCached && !this.isAnyOrEquivalent(nameSymbol.getType())) { - this.setSymbolAndDiagnosticsForAST(nameAST, nameSymbolAndDiagnostics, context); - } - - return nameSymbolAndDiagnostics; - }; - - PullTypeResolver.prototype.computeNameExpression = function (nameAST, enclosingDecl, context) { - if (nameAST.isMissing()) { - return SymbolAndDiagnostics.fromSymbol(this.semanticInfoChain.anyTypeSymbol); - } - - var id = nameAST.text; - - var declPath = enclosingDecl !== null ? TypeScript.getPathToDecl(enclosingDecl) : []; - - if (enclosingDecl && !declPath.length) { - declPath = [enclosingDecl]; - } - - var aliasSymbol = null; - var nameSymbol = this.getSymbolFromDeclPath(id, declPath, TypeScript.PullElementKind.SomeValue); - - if (!nameSymbol && id === "arguments" && enclosingDecl && (enclosingDecl.getKind() & TypeScript.PullElementKind.SomeFunction)) { - nameSymbol = this.cachedFunctionArgumentsSymbol; - - if (this.cachedIArgumentsInterfaceType() && !this.cachedIArgumentsInterfaceType().isResolved()) { - this.resolveDeclaredSymbol(this.cachedIArgumentsInterfaceType(), enclosingDecl, context); - } - } - - if (!nameSymbol) { - return SymbolAndDiagnostics.create(this.getNewErrorTypeSymbol(null, id), [context.postError(this.unitPath, nameAST.minChar, nameAST.getLength(), 164 /* Could_not_find_symbol__0_ */, [nameAST.actualText])]); - } - - if (nameSymbol.isType() && nameSymbol.isAlias()) { - aliasSymbol = nameSymbol; - - (aliasSymbol).setIsUsedAsValue(); - - if (!nameSymbol.isResolved()) { - this.resolveDeclaredSymbol(nameSymbol, enclosingDecl, context); - } - - var exportAssignmentSymbol = (nameSymbol).getExportAssignedValueSymbol(); - - if (exportAssignmentSymbol) { - nameSymbol = exportAssignmentSymbol; - } else { - aliasSymbol = null; - } - } - - return SymbolAndDiagnostics.fromAlias(nameSymbol, aliasSymbol); - }; - - PullTypeResolver.prototype.resolveDottedNameExpression = function (dottedNameAST, enclosingDecl, context) { - var symbolAndDiagnostics = this.getSymbolAndDiagnosticsForAST(dottedNameAST); - var foundCached = symbolAndDiagnostics != null; - - if (!foundCached) { - symbolAndDiagnostics = this.computeDottedNameExpressionSymbol(dottedNameAST, enclosingDecl, context); - } - - var symbol = symbolAndDiagnostics && symbolAndDiagnostics.symbol; - if (symbol && !symbol.isResolved()) { - this.resolveDeclaredSymbol(symbol, enclosingDecl, context); - } - - if (!foundCached && !this.isAnyOrEquivalent(symbol.getType())) { - this.setSymbolAndDiagnosticsForAST(dottedNameAST, symbolAndDiagnostics, context); - this.setSymbolAndDiagnosticsForAST(dottedNameAST.operand2, symbolAndDiagnostics, context); - } - - return symbolAndDiagnostics; - }; - - PullTypeResolver.prototype.isPrototypeMember = function (dottedNameAST, enclosingDecl, context) { - var rhsName = (dottedNameAST.operand2).text; - if (rhsName === "prototype") { - var prevCanUseTypeSymbol = context.canUseTypeSymbol; - context.canUseTypeSymbol = true; - var lhsType = this.resolveAST(dottedNameAST.operand1, false, enclosingDecl, context).symbol.getType(); - context.canUseTypeSymbol = prevCanUseTypeSymbol; - - if (lhsType) { - if (lhsType.isClass() || lhsType.isConstructor()) { - return true; - } else { - var classInstanceType = lhsType.getAssociatedContainerType(); - - if (classInstanceType && classInstanceType.isClass()) { - return true; - } - } - } - } - - return false; - }; - - PullTypeResolver.prototype.computeDottedNameExpressionSymbol = function (dottedNameAST, enclosingDecl, context) { - if ((dottedNameAST.operand2).isMissing()) { - return SymbolAndDiagnostics.fromSymbol(this.semanticInfoChain.anyTypeSymbol); - } - - var rhsName = (dottedNameAST.operand2).text; - var prevCanUseTypeSymbol = context.canUseTypeSymbol; - context.canUseTypeSymbol = true; - var lhs = this.resolveAST(dottedNameAST.operand1, false, enclosingDecl, context).symbol; - context.canUseTypeSymbol = prevCanUseTypeSymbol; - var lhsType = lhs.getType(); - - if (lhs.isAlias()) { - (lhs).setIsUsedAsValue(); - } - - if (this.isAnyOrEquivalent(lhsType)) { - return SymbolAndDiagnostics.fromSymbol(lhsType); - } - - if (!lhsType) { - return SymbolAndDiagnostics.create(this.getNewErrorTypeSymbol(null), [context.postError(this.unitPath, dottedNameAST.operand2.minChar, dottedNameAST.operand2.getLength(), 162 /* Could_not_find_enclosing_symbol_for_dotted_name__0_ */, [(dottedNameAST.operand2).actualText])]); - } - - if ((lhsType === this.semanticInfoChain.numberTypeSymbol || (lhs.getKind() == 67108864 /* EnumMember */)) && this.cachedNumberInterfaceType()) { - lhsType = this.cachedNumberInterfaceType(); - } else if (lhsType === this.semanticInfoChain.stringTypeSymbol && this.cachedStringInterfaceType()) { - lhsType = this.cachedStringInterfaceType(); - } else if (lhsType === this.semanticInfoChain.booleanTypeSymbol && this.cachedBooleanInterfaceType()) { - lhsType = this.cachedBooleanInterfaceType(); - } - - if (!lhsType.isResolved()) { - var potentiallySpecializedType = this.resolveDeclaredSymbol(lhsType, enclosingDecl, context); - - if (potentiallySpecializedType != lhsType) { - if (!lhs.isType()) { - context.setTypeInContext(lhs, potentiallySpecializedType); - } - - lhsType = potentiallySpecializedType; - } - } - - if (lhsType.isContainer() && !lhsType.isAlias()) { - var instanceSymbol = (lhsType).getInstanceSymbol(); - - if (instanceSymbol) { - lhsType = instanceSymbol.getType(); - } - } - - if (this.isPrototypeMember(dottedNameAST, enclosingDecl, context)) { - if (lhsType.isClass()) { - return SymbolAndDiagnostics.fromSymbol(lhsType); - } else { - var classInstanceType = lhsType.getAssociatedContainerType(); - - if (classInstanceType && classInstanceType.isClass()) { - return SymbolAndDiagnostics.fromSymbol(classInstanceType); - } - } - } - - if (lhsType.isTypeParameter()) { - lhsType = this.substituteUpperBoundForType(lhsType); - } - - var nameSymbol = null; - if (!(lhs.isType() && (lhs).isClass() && this.isNameOrMemberAccessExpression(dottedNameAST.operand1)) && !nameSymbol) { - nameSymbol = this.getMemberSymbol(rhsName, TypeScript.PullElementKind.SomeValue, lhsType); - nameSymbol = this.resolveNameSymbol(nameSymbol, context); - } - - if (!nameSymbol) { - if (lhsType.isClass()) { - var staticType = (lhsType).getConstructorMethod().getType(); - - nameSymbol = this.getMemberSymbol(rhsName, TypeScript.PullElementKind.SomeValue, staticType); - - if (!nameSymbol) { - nameSymbol = this.getMemberSymbol(rhsName, TypeScript.PullElementKind.SomeValue, lhsType); - } - } else if ((lhsType.getCallSignatures().length || lhsType.getConstructSignatures().length) && this.cachedFunctionInterfaceType()) { - nameSymbol = this.getMemberSymbol(rhsName, TypeScript.PullElementKind.SomeValue, this.cachedFunctionInterfaceType()); - } else if (lhsType.isContainer()) { - var containerType = (lhsType.isAlias() ? (lhsType).getType() : lhsType); - var associatedInstance = containerType.getInstanceSymbol(); - - if (associatedInstance) { - var instanceType = associatedInstance.getType(); - - nameSymbol = this.getMemberSymbol(rhsName, TypeScript.PullElementKind.SomeValue, instanceType); - } - } else { - var associatedType = lhsType.getAssociatedContainerType(); - - if (associatedType && !associatedType.isClass()) { - nameSymbol = this.getMemberSymbol(rhsName, TypeScript.PullElementKind.SomeValue, associatedType); - } - } - - nameSymbol = this.resolveNameSymbol(nameSymbol, context); - - if (!nameSymbol && !lhsType.isPrimitive() && this.cachedObjectInterfaceType()) { - nameSymbol = this.getMemberSymbol(rhsName, TypeScript.PullElementKind.SomeValue, this.cachedObjectInterfaceType()); - } - - if (!nameSymbol) { - return SymbolAndDiagnostics.create(this.getNewErrorTypeSymbol(null, rhsName), [context.postError(this.unitPath, dottedNameAST.operand2.minChar, dottedNameAST.operand2.getLength(), 163 /* The_property__0__does_not_exist_on_value_of_type__1__ */, [(dottedNameAST.operand2).actualText, lhsType.getDisplayName()])]); - } - } - - return SymbolAndDiagnostics.fromSymbol(nameSymbol); - }; - - PullTypeResolver.prototype.resolveTypeNameExpression = function (nameAST, enclosingDecl, context) { - var typeNameSymbolAndDiagnostics = this.getSymbolAndDiagnosticsForAST(nameAST); - - if (!typeNameSymbolAndDiagnostics || !typeNameSymbolAndDiagnostics.symbol.isType()) { - typeNameSymbolAndDiagnostics = this.computeTypeNameExpression(nameAST, enclosingDecl, context); - this.setSymbolAndDiagnosticsForAST(nameAST, typeNameSymbolAndDiagnostics, context); - } - - var typeNameSymbol = typeNameSymbolAndDiagnostics && typeNameSymbolAndDiagnostics.symbol; - if (!typeNameSymbol.isResolved()) { - var savedResolvingNamespaceMemberAccess = context.resolvingNamespaceMemberAccess; - context.resolvingNamespaceMemberAccess = false; - this.resolveDeclaredSymbol(typeNameSymbol, enclosingDecl, context); - context.resolvingNamespaceMemberAccess = savedResolvingNamespaceMemberAccess; - } - - if (typeNameSymbol && !(typeNameSymbol.isTypeParameter() && (typeNameSymbol).isFunctionTypeParameter() && context.isSpecializingSignatureAtCallSite && !context.isSpecializingConstructorMethod)) { - var substitution = context.findSpecializationForType(typeNameSymbol); - - if (typeNameSymbol.isTypeParameter() && (substitution != typeNameSymbol)) { - if (TypeScript.shouldSpecializeTypeParameterForTypeParameter(substitution, typeNameSymbol)) { - typeNameSymbol = substitution; - } - } - - if (typeNameSymbol != typeNameSymbolAndDiagnostics.symbol) { - return SymbolAndDiagnostics.fromSymbol(typeNameSymbol); - } - } - - return typeNameSymbolAndDiagnostics; - }; - - PullTypeResolver.prototype.computeTypeNameExpression = function (nameAST, enclosingDecl, context) { - if (nameAST.isMissing()) { - return SymbolAndDiagnostics.fromSymbol(this.semanticInfoChain.anyTypeSymbol); - } - - var id = nameAST.text; - - if (id === "any") { - return SymbolAndDiagnostics.fromSymbol(this.semanticInfoChain.anyTypeSymbol); - } else if (id === "string") { - return SymbolAndDiagnostics.fromSymbol(this.semanticInfoChain.stringTypeSymbol); - } else if (id === "number") { - return SymbolAndDiagnostics.fromSymbol(this.semanticInfoChain.numberTypeSymbol); - } else if (id === "bool") { - if (this.compilationSettings.disallowBool && !this.currentUnit.getProperties().unitContainsBool) { - this.currentUnit.getProperties().unitContainsBool = true; - return SymbolAndDiagnostics.create(this.semanticInfoChain.booleanTypeSymbol, [context.postError(this.unitPath, nameAST.minChar, nameAST.getLength(), 167 /* Use_of_deprecated__bool__type__Use__boolean__instead */)]); - } else { - return SymbolAndDiagnostics.fromSymbol(this.semanticInfoChain.booleanTypeSymbol); - } - } else if (id === "boolean") { - return SymbolAndDiagnostics.fromSymbol(this.semanticInfoChain.booleanTypeSymbol); - } else if (id === "void") { - return SymbolAndDiagnostics.fromSymbol(this.semanticInfoChain.voidTypeSymbol); - } else { - var declPath = enclosingDecl !== null ? TypeScript.getPathToDecl(enclosingDecl) : []; - - if (enclosingDecl && !declPath.length) { - declPath = [enclosingDecl]; - } - - var kindToCheckFirst = context.resolvingNamespaceMemberAccess ? TypeScript.PullElementKind.SomeContainer : TypeScript.PullElementKind.SomeType; - var kindToCheckSecond = context.resolvingNamespaceMemberAccess ? TypeScript.PullElementKind.SomeType : TypeScript.PullElementKind.SomeContainer; - - var typeNameSymbol = this.getSymbolFromDeclPath(id, declPath, kindToCheckFirst); - - if (!typeNameSymbol) { - typeNameSymbol = this.getSymbolFromDeclPath(id, declPath, kindToCheckSecond); - } - - if (!typeNameSymbol) { - return SymbolAndDiagnostics.create(this.getNewErrorTypeSymbol(null, id), [context.postError(this.unitPath, nameAST.minChar, nameAST.getLength(), 164 /* Could_not_find_symbol__0_ */, [nameAST.actualText])]); - } - - if (typeNameSymbol.isAlias()) { - if (!typeNameSymbol.isResolved()) { - var savedResolvingNamespaceMemberAccess = context.resolvingNamespaceMemberAccess; - context.resolvingNamespaceMemberAccess = false; - this.resolveDeclaredSymbol(typeNameSymbol, enclosingDecl, context); - context.resolvingNamespaceMemberAccess = savedResolvingNamespaceMemberAccess; - } - - var aliasedType = (typeNameSymbol).getType(); - - if (aliasedType && !aliasedType.isResolved()) { - this.resolveDeclaredSymbol(aliasedType, enclosingDecl, context); - } - - var exportAssignmentSymbol = (typeNameSymbol).getExportAssignedTypeSymbol(); - - if (exportAssignmentSymbol) { - typeNameSymbol = exportAssignmentSymbol; - } - } - - if (typeNameSymbol.isTypeParameter()) { - if (enclosingDecl && (enclosingDecl.getKind() & TypeScript.PullElementKind.SomeFunction) && (enclosingDecl.getFlags() & 16 /* Static */)) { - var parentDecl = typeNameSymbol.getDeclarations()[0].getParentDecl(); - - if (parentDecl.getKind() == 8 /* Class */) { - return SymbolAndDiagnostics.create(this.getNewErrorTypeSymbol(null), [context.postError(this.unitPath, nameAST.minChar, nameAST.getLength(), 226 /* Static_methods_cannot_reference_class_type_parameters */)]); - } - } - } - } - - return SymbolAndDiagnostics.fromSymbol(typeNameSymbol); - }; - - PullTypeResolver.prototype.addDiagnostic = function (diagnostics, diagnostic) { - if (!diagnostics) { - diagnostics = []; - } - - diagnostics.push(diagnostic); - return diagnostics; - }; - - PullTypeResolver.prototype.resolveGenericTypeReference = function (genericTypeAST, enclosingDecl, context) { - var savedResolvingTypeReference = context.resolvingTypeReference; - context.resolvingTypeReference = true; - var genericTypeSymbol = this.resolveAST(genericTypeAST.name, false, enclosingDecl, context).symbol.getType(); - context.resolvingTypeReference = savedResolvingTypeReference; - - if (genericTypeSymbol.isError()) { - return SymbolAndDiagnostics.fromSymbol(genericTypeSymbol); - } - - if (!genericTypeSymbol.isResolving() && !genericTypeSymbol.isResolved()) { - this.resolveDeclaredSymbol(genericTypeSymbol, enclosingDecl, context); - } - - var typeArgs = []; - - if (!context.isResolvingTypeArguments(genericTypeAST)) { - context.startResolvingTypeArguments(genericTypeAST); - - if (genericTypeAST.typeArguments && genericTypeAST.typeArguments.members.length) { - for (var i = 0; i < genericTypeAST.typeArguments.members.length; i++) { - var typeArg = this.resolveTypeReference(genericTypeAST.typeArguments.members[i], enclosingDecl, context).symbol; - - if (typeArg.isNamedTypeSymbol() && typeArg.isGeneric() && !typeArg.isTypeParameter() && typeArg.isResolved() && !typeArg.getIsSpecialized() && typeArg.getTypeParameters().length && (typeArg.getTypeArguments() == null && !this.isArrayOrEquivalent(typeArg)) && this.isTypeRefWithoutTypeArgs(genericTypeAST.typeArguments.members[i])) { - context.postError(this.unitPath, genericTypeAST.typeArguments.members[i].minChar, genericTypeAST.typeArguments.members[i].getLength(), 239 /* Generic_type_references_must_include_all_type_arguments */, null, enclosingDecl, true); - typeArg = this.specializeTypeToAny(typeArg, enclosingDecl, context); - } - - typeArgs[i] = context.findSpecializationForType(typeArg); - } - } - - context.doneResolvingTypeArguments(); - } - - var typeParameters = genericTypeSymbol.getTypeParameters(); - - if (typeArgs.length && typeArgs.length != typeParameters.length) { - return SymbolAndDiagnostics.create(this.getNewErrorTypeSymbol(null), [context.postError(this.unitPath, genericTypeAST.minChar, genericTypeAST.getLength(), 159 /* Generic_type__0__requires_1_type_argument_s_ */, [genericTypeSymbol.toString(), genericTypeSymbol.getTypeParameters().length])]); - } - - var specializedSymbol = TypeScript.specializeType(genericTypeSymbol, typeArgs, this, enclosingDecl, context, genericTypeAST); - - var typeConstraint = null; - var upperBound = null; - var diagnostics = null; - - for (var iArg = 0; (iArg < typeArgs.length) && (iArg < typeParameters.length); iArg++) { - typeArg = typeArgs[iArg]; - typeConstraint = typeParameters[iArg].getConstraint(); - - if (typeConstraint) { - if (typeConstraint.isTypeParameter()) { - for (var j = 0; j < typeParameters.length && j < typeArgs.length; j++) { - if (typeParameters[j] == typeConstraint) { - typeConstraint = typeArgs[j]; - } - } - } - - if (typeArg.isTypeParameter()) { - upperBound = (typeArg).getConstraint(); - - if (upperBound) { - typeArg = upperBound; - } - } - - if (typeArg.isResolving()) { - return SymbolAndDiagnostics.fromSymbol(specializedSymbol); - } - if (!this.sourceIsAssignableToTarget(typeArg, typeConstraint, context)) { - diagnostics = this.addDiagnostic(diagnostics, context.postError(this.unitPath, genericTypeAST.minChar, genericTypeAST.getLength(), 155 /* Type__0__does_not_satisfy_the_constraint__1__for_type_parameter__2_ */, [typeArg.toString(true), typeConstraint.toString(true), typeParameters[iArg].toString(true)])); - } - } - } - - return SymbolAndDiagnostics.create(specializedSymbol, diagnostics); - }; - - PullTypeResolver.prototype.resolveDottedTypeNameExpression = function (dottedNameAST, enclosingDecl, context) { - var symbolAndDiagnostics = this.getSymbolAndDiagnosticsForAST(dottedNameAST); - if (!symbolAndDiagnostics) { - symbolAndDiagnostics = this.computeDottedTypeNameExpression(dottedNameAST, enclosingDecl, context); - this.setSymbolAndDiagnosticsForAST(dottedNameAST, symbolAndDiagnostics, context); - } - - var symbol = symbolAndDiagnostics.symbol; - if (!symbol.isResolved()) { - this.resolveDeclaredSymbol(symbol, enclosingDecl, context); - } - - return symbolAndDiagnostics; - }; - - PullTypeResolver.prototype.computeDottedTypeNameExpression = function (dottedNameAST, enclosingDecl, context) { - if ((dottedNameAST.operand2).isMissing()) { - return SymbolAndDiagnostics.fromSymbol(this.semanticInfoChain.anyTypeSymbol); - } - - var rhsName = (dottedNameAST.operand2).text; - - var savedResolvingTypeReference = context.resolvingTypeReference; - var savedResolvingNamespaceMemberAccess = context.resolvingNamespaceMemberAccess; - context.resolvingNamespaceMemberAccess = true; - context.resolvingTypeReference = true; - var lhs = this.resolveAST(dottedNameAST.operand1, false, enclosingDecl, context).symbol; - context.resolvingTypeReference = savedResolvingTypeReference; - context.resolvingNamespaceMemberAccess = savedResolvingNamespaceMemberAccess; - - var lhsType = lhs.getType(); - - if (context.isResolvingClassExtendedType) { - if (lhs.isAlias()) { - (lhs).setIsUsedAsValue(); - } - } - - if (this.isAnyOrEquivalent(lhsType)) { - return SymbolAndDiagnostics.fromSymbol(lhsType); - } - - if (!lhsType) { - return SymbolAndDiagnostics.create(this.getNewErrorTypeSymbol(null), [context.postError(this.unitPath, dottedNameAST.operand2.minChar, dottedNameAST.operand2.getLength(), 162 /* Could_not_find_enclosing_symbol_for_dotted_name__0_ */, [(dottedNameAST.operand2).actualText])]); - } - - var childTypeSymbol = this.getMemberSymbol(rhsName, TypeScript.PullElementKind.SomeType, lhsType); - - if (!childTypeSymbol && lhsType.isContainer()) { - var exportedContainer = (lhsType).getExportAssignedContainerSymbol(); - - if (exportedContainer) { - childTypeSymbol = this.getMemberSymbol(rhsName, TypeScript.PullElementKind.SomeType, exportedContainer); - } - } - - if (!childTypeSymbol && enclosingDecl) { - var parentDecl = enclosingDecl; - - while (parentDecl) { - if (parentDecl.getKind() & TypeScript.PullElementKind.SomeContainer) { - break; - } - - parentDecl = parentDecl.getParentDecl(); - } - - if (parentDecl) { - var enclosingSymbolType = parentDecl.getSymbol().getType(); - - if (enclosingSymbolType === lhsType) { - childTypeSymbol = this.getMemberSymbol(rhsName, TypeScript.PullElementKind.SomeType, lhsType); - } - } - } - - if (!childTypeSymbol) { - return SymbolAndDiagnostics.create(this.getNewErrorTypeSymbol(null, rhsName), [context.postError(this.unitPath, dottedNameAST.operand2.minChar, dottedNameAST.operand2.getLength(), 163 /* The_property__0__does_not_exist_on_value_of_type__1__ */, [(dottedNameAST.operand2).actualText, lhsType.getName()])]); - } - - return SymbolAndDiagnostics.fromSymbol(childTypeSymbol); - }; - - PullTypeResolver.prototype.resolveFunctionExpression = function (funcDeclAST, inContextuallyTypedAssignment, enclosingDecl, context) { - var funcDeclSymbol = null; - var functionDecl = this.getDeclForAST(funcDeclAST); - - if (functionDecl && functionDecl.hasSymbol()) { - funcDeclSymbol = functionDecl.getSymbol(); - if (funcDeclSymbol.isResolved()) { - return funcDeclSymbol; - } - } - - var shouldContextuallyType = inContextuallyTypedAssignment; - - var assigningFunctionTypeSymbol = null; - var assigningFunctionSignature = null; - - if (funcDeclAST.returnTypeAnnotation) { - shouldContextuallyType = false; - } - - if (shouldContextuallyType && funcDeclAST.arguments) { - for (var i = 0; i < funcDeclAST.arguments.members.length; i++) { - if ((funcDeclAST.arguments.members[i]).typeExpr) { - shouldContextuallyType = false; - break; - } - } - } - - if (shouldContextuallyType) { - assigningFunctionTypeSymbol = context.getContextualType(); - - if (assigningFunctionTypeSymbol) { - this.resolveDeclaredSymbol(assigningFunctionTypeSymbol, enclosingDecl, context); - - if (assigningFunctionTypeSymbol) { - assigningFunctionSignature = assigningFunctionTypeSymbol.getCallSignatures()[0]; - } - } - } - - var semanticInfo = this.semanticInfoChain.getUnit(this.unitPath); - var declCollectionContext = new TypeScript.DeclCollectionContext(semanticInfo); - - declCollectionContext.scriptName = this.unitPath; - - if (enclosingDecl) { - declCollectionContext.pushParent(enclosingDecl); - } - - TypeScript.getAstWalkerFactory().walk(funcDeclAST, TypeScript.preCollectDecls, TypeScript.postCollectDecls, null, declCollectionContext); - - var functionDecl = this.getDeclForAST(funcDeclAST); - this.currentUnit.addSynthesizedDecl(functionDecl); - - var binder = new TypeScript.PullSymbolBinder(this.semanticInfoChain); - binder.setUnit(this.unitPath); - binder.bindFunctionExpressionToPullSymbol(functionDecl); - - funcDeclSymbol = functionDecl.getSymbol(); - - var signature = funcDeclSymbol.getType().getCallSignatures()[0]; - - if (funcDeclAST.arguments) { - var contextParams = []; - var contextParam = null; - - if (assigningFunctionSignature) { - contextParams = assigningFunctionSignature.getParameters(); - } - - for (var i = 0; i < funcDeclAST.arguments.members.length; i++) { - if ((i < contextParams.length) && !contextParams[i].getIsVarArg()) { - contextParam = contextParams[i]; - } else if (contextParams.length && contextParams[contextParams.length - 1].getIsVarArg()) { - contextParam = (contextParams[contextParams.length - 1].getType()).getElementType(); - } - - this.resolveFunctionExpressionParameter(funcDeclAST.arguments.members[i], contextParam, functionDecl, context); - } - } - - if (funcDeclAST.returnTypeAnnotation) { - var returnTypeSymbol = this.resolveTypeReference(funcDeclAST.returnTypeAnnotation, functionDecl, context).symbol; - - signature.setReturnType(returnTypeSymbol); - } else { - if (assigningFunctionSignature) { - var returnType = assigningFunctionSignature.getReturnType(); - - if (returnType) { - context.pushContextualType(returnType, context.inProvisionalResolution(), null); - - this.resolveFunctionBodyReturnTypes(funcDeclAST, signature, true, functionDecl, context); - context.popContextualType(); - } else { - signature.setReturnType(this.semanticInfoChain.anyTypeSymbol); - } - } else { - this.resolveFunctionBodyReturnTypes(funcDeclAST, signature, false, functionDecl, context); - } - } - - if (assigningFunctionTypeSymbol) { - funcDeclSymbol.addOutgoingLink(assigningFunctionTypeSymbol, 1 /* ContextuallyTypedAs */); - } - - funcDeclSymbol.setResolved(); - - return funcDeclSymbol; - }; - - PullTypeResolver.prototype.resolveThisExpression = function (ast, enclosingDecl, context) { - var symbolAndDiagnostics = this.getSymbolAndDiagnosticsForAST(ast); - - if (!symbolAndDiagnostics) { - symbolAndDiagnostics = this.computeThisExpressionSymbol(ast, enclosingDecl, context); - this.setSymbolAndDiagnosticsForAST(ast, symbolAndDiagnostics, context); - } - - return symbolAndDiagnostics; - }; - - PullTypeResolver.prototype.computeThisExpressionSymbol = function (ast, enclosingDecl, context) { - if (enclosingDecl) { - var enclosingDeclKind = enclosingDecl.getKind(); - var diagnostics; - - if (enclosingDeclKind === 4 /* Container */) { - return SymbolAndDiagnostics.create(this.getNewErrorTypeSymbol(null), [context.postError(this.currentUnit.getPath(), ast.minChar, ast.getLength(), 176 /* _this__cannot_be_referenced_within_module_bodies */)]); - } else if (!(enclosingDeclKind & (TypeScript.PullElementKind.SomeFunction | 1 /* Script */ | TypeScript.PullElementKind.SomeBlock))) { - return SymbolAndDiagnostics.create(this.getNewErrorTypeSymbol(null), [context.postError(this.currentUnit.getPath(), ast.minChar, ast.getLength(), 177 /* _this__must_only_be_used_inside_a_function_or_script_context */)]); - } else { - var declPath = TypeScript.getPathToDecl(enclosingDecl); - - if (declPath.length) { - for (var i = declPath.length - 1; i >= 0; i--) { - var decl = declPath[i]; - var declKind = decl.getKind(); - var declFlags = decl.getFlags(); - - if (declFlags & 16 /* Static */) { - break; - } else if (declKind === 131072 /* FunctionExpression */ && !TypeScript.hasFlag(declFlags, 8192 /* FatArrow */)) { - break; - } else if (declKind === 16384 /* Function */) { - break; - } else if (declKind === 8 /* Class */) { - var classSymbol = decl.getSymbol(); - return SymbolAndDiagnostics.fromSymbol(classSymbol); - } - } - } - } - } - - return SymbolAndDiagnostics.fromSymbol(this.semanticInfoChain.anyTypeSymbol); - }; - - PullTypeResolver.prototype.resolveSuperExpression = function (ast, enclosingDecl, context) { - if (!enclosingDecl) { - return SymbolAndDiagnostics.fromSymbol(this.semanticInfoChain.anyTypeSymbol); - } - - var declPath = enclosingDecl !== null ? TypeScript.getPathToDecl(enclosingDecl) : []; - var classSymbol = null; - - if (declPath.length) { - for (var i = declPath.length - 1; i >= 0; i--) { - var decl = declPath[i]; - var declFlags = decl.getFlags(); - - if (decl.getKind() === 131072 /* FunctionExpression */ && !(declFlags & 8192 /* FatArrow */)) { - break; - } else if (declFlags & 16 /* Static */) { - break; - } else if (decl.getKind() === 8 /* Class */) { - classSymbol = decl.getSymbol(); - - break; - } - } - } - - if (classSymbol) { - if (!classSymbol.isResolved()) { - this.resolveDeclaredSymbol(classSymbol, enclosingDecl, context); - } - - var parents = classSymbol.getExtendedTypes(); - - if (parents.length) { - return SymbolAndDiagnostics.fromSymbol(parents[0]); - } - } - - return SymbolAndDiagnostics.fromSymbol(this.semanticInfoChain.anyTypeSymbol); - }; - - PullTypeResolver.prototype.resolveObjectLiteralExpression = function (expressionAST, inContextuallyTypedAssignment, enclosingDecl, context, additionalResults) { - var symbolAndDiagnostics = this.getSymbolAndDiagnosticsForAST(expressionAST); - - if (!symbolAndDiagnostics || additionalResults) { - symbolAndDiagnostics = this.computeObjectLiteralExpression(expressionAST, inContextuallyTypedAssignment, enclosingDecl, context, additionalResults); - this.setSymbolAndDiagnosticsForAST(expressionAST, symbolAndDiagnostics, context); - } - - return symbolAndDiagnostics; - }; - - PullTypeResolver.prototype.computeObjectLiteralExpression = function (expressionAST, inContextuallyTypedAssignment, enclosingDecl, context, additionalResults) { - var objectLitAST = expressionAST; - var span = TypeScript.TextSpan.fromBounds(objectLitAST.minChar, objectLitAST.limChar); - - var objectLitDecl = new TypeScript.PullDecl("", "", 512 /* ObjectLiteral */, 0 /* None */, span, this.unitPath); - this.currentUnit.addSynthesizedDecl(objectLitDecl); - - if (enclosingDecl) { - objectLitDecl.setParentDecl(enclosingDecl); - } - - this.currentUnit.setDeclForAST(objectLitAST, objectLitDecl); - this.currentUnit.setASTForDecl(objectLitDecl, objectLitAST); - - var typeSymbol = new TypeScript.PullTypeSymbol("", 16 /* Interface */); - typeSymbol.addDeclaration(objectLitDecl); - objectLitDecl.setSymbol(typeSymbol); - - var memberDecls = objectLitAST.operand; - - var contextualType = null; - - if (inContextuallyTypedAssignment) { - contextualType = context.getContextualType(); - - this.resolveDeclaredSymbol(contextualType, enclosingDecl, context); - } - - if (memberDecls) { - var binex; - var memberSymbol; - var assigningSymbol = null; - var acceptedContextualType = false; - - if (additionalResults) { - additionalResults.membersContextTypeSymbols = []; - } - - for (var i = 0, len = memberDecls.members.length; i < len; i++) { - binex = memberDecls.members[i]; - - var id = binex.operand1; - var text; - var actualText; - - if (id.nodeType === 20 /* Name */) { - actualText = (id).actualText; - text = (id).text; - } else if (id.nodeType === 5 /* StringLiteral */) { - actualText = (id).actualText; - text = (id).text; - } else { - return SymbolAndDiagnostics.fromSymbol(this.semanticInfoChain.anyTypeSymbol); - } - - span = TypeScript.TextSpan.fromBounds(binex.minChar, binex.limChar); - - var decl = new TypeScript.PullDecl(text, actualText, 4096 /* Property */, 4 /* Public */, span, this.unitPath); - this.currentUnit.addSynthesizedDecl(decl); - - objectLitDecl.addChildDecl(decl); - decl.setParentDecl(objectLitDecl); - - this.semanticInfoChain.getUnit(this.unitPath).setDeclForAST(binex, decl); - this.semanticInfoChain.getUnit(this.unitPath).setASTForDecl(decl, binex); - - memberSymbol = new TypeScript.PullSymbol(text, 4096 /* Property */); - - memberSymbol.addDeclaration(decl); - decl.setSymbol(memberSymbol); - - if (contextualType) { - assigningSymbol = this.getMemberSymbol(text, TypeScript.PullElementKind.SomeValue, contextualType); - - if (assigningSymbol) { - this.resolveDeclaredSymbol(assigningSymbol, enclosingDecl, context); - - context.pushContextualType(assigningSymbol.getType(), context.inProvisionalResolution(), null); - - acceptedContextualType = true; - - if (additionalResults) { - additionalResults.membersContextTypeSymbols[i] = assigningSymbol.getType(); - } - } - } - - if (binex.operand2.nodeType === 12 /* FunctionDeclaration */) { - var funcDeclAST = binex.operand2; - - if (funcDeclAST.isAccessor()) { - var semanticInfo = this.semanticInfoChain.getUnit(this.unitPath); - var declCollectionContext = new TypeScript.DeclCollectionContext(semanticInfo); - - declCollectionContext.scriptName = this.unitPath; - - declCollectionContext.pushParent(objectLitDecl); - - TypeScript.getAstWalkerFactory().walk(funcDeclAST, TypeScript.preCollectDecls, TypeScript.postCollectDecls, null, declCollectionContext); - - var functionDecl = this.getDeclForAST(funcDeclAST); - this.currentUnit.addSynthesizedDecl(functionDecl); - - var binder = new TypeScript.PullSymbolBinder(this.semanticInfoChain); - binder.setUnit(this.unitPath); - - if (funcDeclAST.isGetAccessor()) { - binder.bindGetAccessorDeclarationToPullSymbol(functionDecl); - } else { - binder.bindSetAccessorDeclarationToPullSymbol(functionDecl); - } - } - } - - var memberExprType = this.resolveAST(binex.operand2, assigningSymbol != null, enclosingDecl, context).symbol; - - if (acceptedContextualType) { - context.popContextualType(); - acceptedContextualType = false; - } - - context.setTypeInContext(memberSymbol, memberExprType.getType()); - - memberSymbol.setResolved(); - - this.setSymbolAndDiagnosticsForAST(binex.operand1, SymbolAndDiagnostics.fromSymbol(memberSymbol), context); - - typeSymbol.addMember(memberSymbol, 5 /* PublicMember */); - } - } - - typeSymbol.setResolved(); - return SymbolAndDiagnostics.fromSymbol(typeSymbol); - }; - - PullTypeResolver.prototype.resolveArrayLiteralExpression = function (arrayLit, inContextuallyTypedAssignment, enclosingDecl, context) { - var symbolAndDiagnostics = this.getSymbolAndDiagnosticsForAST(arrayLit); - if (!symbolAndDiagnostics) { - symbolAndDiagnostics = this.computeArrayLiteralExpressionSymbol(arrayLit, inContextuallyTypedAssignment, enclosingDecl, context); - this.setSymbolAndDiagnosticsForAST(arrayLit, symbolAndDiagnostics, context); - } - - return symbolAndDiagnostics; - }; - - PullTypeResolver.prototype.computeArrayLiteralExpressionSymbol = function (arrayLit, inContextuallyTypedAssignment, enclosingDecl, context) { - var elements = arrayLit.operand; - var elementType = this.semanticInfoChain.anyTypeSymbol; - var elementTypes = []; - var comparisonInfo = new TypeScript.TypeComparisonInfo(); - var contextualElementType = null; - comparisonInfo.onlyCaptureFirstError = true; - - if (inContextuallyTypedAssignment) { - var contextualType = context.getContextualType(); - - this.resolveDeclaredSymbol(contextualType, enclosingDecl, context); - - if (contextualType && contextualType.isArray()) { - contextualElementType = contextualType.getElementType(); - } - } - - if (elements) { - if (inContextuallyTypedAssignment) { - context.pushContextualType(contextualElementType, context.inProvisionalResolution(), null); - } - - for (var i = 0; i < elements.members.length; i++) { - elementTypes[elementTypes.length] = this.resolveAST(elements.members[i], inContextuallyTypedAssignment, enclosingDecl, context).symbol.getType(); - } - - if (inContextuallyTypedAssignment) { - context.popContextualType(); - } - } - - if (contextualElementType && !contextualElementType.isTypeParameter()) { - elementType = contextualElementType; - - for (var i = 0; i < elementTypes.length; i++) { - var comparisonInfo = new TypeScript.TypeComparisonInfo(); - var currentElementType = elementTypes[i]; - var currentElementAST = elements.members[i]; - if (!this.sourceIsAssignableToTarget(currentElementType, contextualElementType, context, comparisonInfo)) { - var message; - if (comparisonInfo.message) { - message = context.postError(this.getUnitPath(), currentElementAST.minChar, currentElementAST.getLength(), 81 /* Cannot_convert__0__to__1__NL__2 */, [currentElementType.toString(), contextualElementType.toString(), comparisonInfo.message]); - } else { - message = context.postError(this.getUnitPath(), currentElementAST.minChar, currentElementAST.getLength(), 80 /* Cannot_convert__0__to__1_ */, [currentElementType.toString(), contextualElementType.toString()]); - } - - return SymbolAndDiagnostics.create(this.getNewErrorTypeSymbol(null), [message]); - } - } - } else { - if (elementTypes.length) { - elementType = elementTypes[0]; - } else if (contextualElementType) { - elementType = contextualElementType; - } - - var collection = { - getLength: function () { - return elements.members.length; - }, - setTypeAtIndex: function (index, type) { - elementTypes[index] = type; - }, - getTypeAtIndex: function (index) { - return elementTypes[index]; - } - }; - - elementType = this.findBestCommonType(elementType, null, collection, context, comparisonInfo); - - if (elementType === this.semanticInfoChain.undefinedTypeSymbol || elementType === this.semanticInfoChain.nullTypeSymbol) { - elementType = this.semanticInfoChain.anyTypeSymbol; - } - - if (!elementType) { - elementType = this.semanticInfoChain.anyTypeSymbol; - } else if (contextualType && !contextualType.isTypeParameter()) { - if (this.sourceIsAssignableToTarget(elementType, contextualType, context)) { - elementType = contextualType; - } - } - } - - var arraySymbol = elementType.getArrayType(); - - if (!arraySymbol) { - if (!this.cachedArrayInterfaceType().isResolved()) { - this.resolveDeclaredSymbol(this.cachedArrayInterfaceType(), enclosingDecl, context); - } - - arraySymbol = TypeScript.specializeToArrayType(this.semanticInfoChain.elementTypeSymbol, elementType, this, context); - - if (!arraySymbol) { - arraySymbol = this.semanticInfoChain.anyTypeSymbol; - } - } - - return SymbolAndDiagnostics.fromSymbol(arraySymbol); - }; - - PullTypeResolver.prototype.resolveIndexExpression = function (callEx, inContextuallyTypedAssignment, enclosingDecl, context) { - var symbolAndDiagnostics = this.getSymbolAndDiagnosticsForAST(callEx); - if (!symbolAndDiagnostics) { - symbolAndDiagnostics = this.computeIndexExpressionSymbol(callEx, inContextuallyTypedAssignment, enclosingDecl, context); - this.setSymbolAndDiagnosticsForAST(callEx, symbolAndDiagnostics, context); - } - - return symbolAndDiagnostics; - }; - - PullTypeResolver.prototype.computeIndexExpressionSymbol = function (callEx, inContextuallyTypedAssignment, enclosingDecl, context) { - var targetSymbol = this.resolveAST(callEx.operand1, inContextuallyTypedAssignment, enclosingDecl, context).symbol; - - var targetTypeSymbol = targetSymbol.getType(); - - if (this.isAnyOrEquivalent(targetTypeSymbol)) { - return SymbolAndDiagnostics.fromSymbol(targetTypeSymbol); - } - - var elementType = targetTypeSymbol.getElementType(); - - var indexType = this.resolveAST(callEx.operand2, inContextuallyTypedAssignment, enclosingDecl, context).symbol.getType(); - - var isNumberIndex = indexType === this.semanticInfoChain.numberTypeSymbol || TypeScript.PullHelpers.symbolIsEnum(indexType); - - if (elementType && isNumberIndex) { - return SymbolAndDiagnostics.fromSymbol(elementType); - } - - if (callEx.operand2.nodeType === 5 /* StringLiteral */ || callEx.operand2.nodeType === 7 /* NumericLiteral */) { - var memberName = callEx.operand2.nodeType === 5 /* StringLiteral */ ? TypeScript.stripQuotes((callEx.operand2).actualText) : TypeScript.quoteStr((callEx.operand2).value.toString()); - - var member = this.getMemberSymbol(memberName, TypeScript.PullElementKind.SomeValue, targetTypeSymbol); - - if (member) { - return SymbolAndDiagnostics.fromSymbol(member.getType()); - } - } - - var signatures = targetTypeSymbol.getIndexSignatures(); - - var stringSignature = null; - var numberSignature = null; - var signature = null; - var paramSymbols; - var paramType; - - for (var i = 0; i < signatures.length; i++) { - if (stringSignature && numberSignature) { - break; - } - - signature = signatures[i]; - - paramSymbols = signature.getParameters(); - - if (paramSymbols.length) { - paramType = paramSymbols[0].getType(); - - if (paramType === this.semanticInfoChain.stringTypeSymbol) { - stringSignature = signatures[i]; - continue; - } else if (paramType === this.semanticInfoChain.numberTypeSymbol || paramType.getKind() === 64 /* Enum */) { - numberSignature = signatures[i]; - continue; - } - } - } - - if (numberSignature && (isNumberIndex || indexType === this.semanticInfoChain.anyTypeSymbol)) { - var returnType = numberSignature.getReturnType(); - - if (!returnType) { - returnType = this.semanticInfoChain.anyTypeSymbol; - } - - return SymbolAndDiagnostics.fromSymbol(returnType); - } else if (stringSignature && (isNumberIndex || indexType === this.semanticInfoChain.anyTypeSymbol || indexType === this.semanticInfoChain.stringTypeSymbol)) { - var returnType = stringSignature.getReturnType(); - - if (!returnType) { - returnType = this.semanticInfoChain.anyTypeSymbol; - } - - return SymbolAndDiagnostics.fromSymbol(returnType); - } else if (isNumberIndex || indexType === this.semanticInfoChain.anyTypeSymbol || indexType === this.semanticInfoChain.stringTypeSymbol) { - var returnType = this.semanticInfoChain.anyTypeSymbol; - return SymbolAndDiagnostics.fromSymbol(returnType); - } else { - return SymbolAndDiagnostics.create(this.getNewErrorTypeSymbol(null), [context.postError(this.getUnitPath(), callEx.minChar, callEx.getLength(), 77 /* Value_of_type__0__is_not_indexable_by_type__1_ */, [targetTypeSymbol.toString(false), indexType.toString(false)])]); - } - }; - - PullTypeResolver.prototype.resolveBitwiseOperator = function (expressionAST, inContextuallyTypedAssignment, enclosingDecl, context) { - var binex = expressionAST; - - var leftType = this.resolveAST(binex.operand1, inContextuallyTypedAssignment, enclosingDecl, context).symbol.getType(); - var rightType = this.resolveAST(binex.operand2, inContextuallyTypedAssignment, enclosingDecl, context).symbol.getType(); - - if (this.sourceIsSubtypeOfTarget(leftType, this.semanticInfoChain.numberTypeSymbol, context) && this.sourceIsSubtypeOfTarget(rightType, this.semanticInfoChain.numberTypeSymbol, context)) { - return this.semanticInfoChain.numberTypeSymbol; - } else if ((leftType === this.semanticInfoChain.booleanTypeSymbol) && (rightType === this.semanticInfoChain.booleanTypeSymbol)) { - return this.semanticInfoChain.booleanTypeSymbol; - } else if (this.isAnyOrEquivalent(leftType)) { - if ((this.isAnyOrEquivalent(rightType) || (rightType === this.semanticInfoChain.numberTypeSymbol) || (rightType === this.semanticInfoChain.booleanTypeSymbol))) { - return this.semanticInfoChain.anyTypeSymbol; - } - } else if (this.isAnyOrEquivalent(rightType)) { - if ((leftType === this.semanticInfoChain.numberTypeSymbol) || (leftType === this.semanticInfoChain.booleanTypeSymbol)) { - return this.semanticInfoChain.anyTypeSymbol; - } - } - - return this.semanticInfoChain.anyTypeSymbol; - }; - - PullTypeResolver.prototype.resolveArithmeticExpression = function (binex, inContextuallyTypedAssignment, enclosingDecl, context) { - var leftType = this.resolveAST(binex.operand1, inContextuallyTypedAssignment, enclosingDecl, context).symbol.getType(); - var rightType = this.resolveAST(binex.operand2, inContextuallyTypedAssignment, enclosingDecl, context).symbol.getType(); - - if (this.isNullOrUndefinedType(leftType)) { - leftType = rightType; - } - if (this.isNullOrUndefinedType(rightType)) { - rightType = leftType; - } - - leftType = this.widenType(leftType); - rightType = this.widenType(rightType); - - if (binex.nodeType === 64 /* AddExpression */ || binex.nodeType === 39 /* AddAssignmentExpression */) { - if (leftType === this.semanticInfoChain.stringTypeSymbol || rightType === this.semanticInfoChain.stringTypeSymbol) { - return SymbolAndDiagnostics.fromSymbol(this.semanticInfoChain.stringTypeSymbol); - } else if (leftType === this.semanticInfoChain.numberTypeSymbol && rightType === this.semanticInfoChain.numberTypeSymbol) { - return SymbolAndDiagnostics.fromSymbol(this.semanticInfoChain.numberTypeSymbol); - } else if (this.sourceIsSubtypeOfTarget(leftType, this.semanticInfoChain.numberTypeSymbol, context) && this.sourceIsSubtypeOfTarget(rightType, this.semanticInfoChain.numberTypeSymbol, context)) { - return SymbolAndDiagnostics.fromSymbol(this.semanticInfoChain.numberTypeSymbol); - } else { - return SymbolAndDiagnostics.fromSymbol(this.semanticInfoChain.anyTypeSymbol); - } - } else { - if (leftType === this.semanticInfoChain.numberTypeSymbol && rightType === this.semanticInfoChain.numberTypeSymbol) { - return SymbolAndDiagnostics.fromSymbol(this.semanticInfoChain.numberTypeSymbol); - } else if (this.sourceIsSubtypeOfTarget(leftType, this.semanticInfoChain.numberTypeSymbol, context) && this.sourceIsSubtypeOfTarget(rightType, this.semanticInfoChain.numberTypeSymbol, context)) { - return SymbolAndDiagnostics.fromSymbol(this.semanticInfoChain.numberTypeSymbol); - } else if (this.isAnyOrEquivalent(leftType) || this.isAnyOrEquivalent(rightType)) { - return SymbolAndDiagnostics.fromSymbol(this.semanticInfoChain.numberTypeSymbol); - } else { - return SymbolAndDiagnostics.fromSymbol(this.semanticInfoChain.anyTypeSymbol); - } - } - }; - - PullTypeResolver.prototype.resolveLogicalOrExpression = function (binex, inContextuallyTypedAssignment, enclosingDecl, context) { - var symbolAndDiagnostics = this.getSymbolAndDiagnosticsForAST(binex); - if (!symbolAndDiagnostics) { - symbolAndDiagnostics = this.computeLogicalOrExpressionSymbol(binex, inContextuallyTypedAssignment, enclosingDecl, context); - this.setSymbolAndDiagnosticsForAST(binex, symbolAndDiagnostics, context); - } - - return symbolAndDiagnostics; - }; - - PullTypeResolver.prototype.computeLogicalOrExpressionSymbol = function (binex, inContextuallyTypedAssignment, enclosingDecl, context) { - var leftType = this.resolveAST(binex.operand1, inContextuallyTypedAssignment, enclosingDecl, context).symbol.getType(); - var rightType = this.resolveAST(binex.operand2, inContextuallyTypedAssignment, enclosingDecl, context).symbol.getType(); - - if (this.isAnyOrEquivalent(leftType) || this.isAnyOrEquivalent(rightType)) { - return SymbolAndDiagnostics.fromSymbol(this.semanticInfoChain.anyTypeSymbol); - } else if (leftType === this.semanticInfoChain.booleanTypeSymbol) { - if (rightType === this.semanticInfoChain.booleanTypeSymbol) { - return SymbolAndDiagnostics.fromSymbol(this.semanticInfoChain.booleanTypeSymbol); - } else { - return SymbolAndDiagnostics.fromSymbol(this.semanticInfoChain.anyTypeSymbol); - } - } else if (leftType === this.semanticInfoChain.numberTypeSymbol) { - if (rightType === this.semanticInfoChain.numberTypeSymbol) { - return SymbolAndDiagnostics.fromSymbol(this.semanticInfoChain.numberTypeSymbol); - } else { - return SymbolAndDiagnostics.fromSymbol(this.semanticInfoChain.anyTypeSymbol); - } - } else if (leftType === this.semanticInfoChain.stringTypeSymbol) { - if (rightType === this.semanticInfoChain.stringTypeSymbol) { - return SymbolAndDiagnostics.fromSymbol(this.semanticInfoChain.stringTypeSymbol); - } else { - return SymbolAndDiagnostics.fromSymbol(this.semanticInfoChain.anyTypeSymbol); - } - } else if (this.sourceIsSubtypeOfTarget(leftType, rightType, context)) { - return SymbolAndDiagnostics.fromSymbol(rightType); - } else if (this.sourceIsSubtypeOfTarget(rightType, leftType, context)) { - return SymbolAndDiagnostics.fromSymbol(leftType); - } - - return SymbolAndDiagnostics.fromSymbol(this.semanticInfoChain.anyTypeSymbol); - }; - - PullTypeResolver.prototype.resolveLogicalAndExpression = function (binex, inContextuallyTypedAssignment, enclosingDecl, context) { - return SymbolAndDiagnostics.fromSymbol(this.resolveAST(binex.operand2, inContextuallyTypedAssignment, enclosingDecl, context).symbol.getType()); - }; - - PullTypeResolver.prototype.resolveConditionalExpression = function (trinex, enclosingDecl, context) { - var symbolAndDiagnostics = this.getSymbolAndDiagnosticsForAST(trinex); - if (!symbolAndDiagnostics) { - symbolAndDiagnostics = this.computeConditionalExpressionSymbol(trinex, enclosingDecl, context); - this.setSymbolAndDiagnosticsForAST(trinex, symbolAndDiagnostics, context); - } - - return symbolAndDiagnostics; - }; - - PullTypeResolver.prototype.computeConditionalExpressionSymbol = function (trinex, enclosingDecl, context) { - var leftType = this.resolveAST(trinex.operand2, false, enclosingDecl, context).symbol.getType(); - var rightType = this.resolveAST(trinex.operand3, false, enclosingDecl, context).symbol.getType(); - - var symbol = null; - if (this.typesAreIdentical(leftType, rightType)) { - symbol = leftType; - } else if (this.sourceIsSubtypeOfTarget(leftType, rightType, context) || this.sourceIsSubtypeOfTarget(rightType, leftType, context)) { - var collection = { - getLength: function () { - return 2; - }, - setTypeAtIndex: function (index, type) { - }, - getTypeAtIndex: function (index) { - return rightType; - } - }; - - var bestCommonType = this.findBestCommonType(leftType, null, collection, context); - - if (bestCommonType) { - symbol = bestCommonType; - } - } - - if (!symbol) { - return SymbolAndDiagnostics.create(this.getNewErrorTypeSymbol(null), [context.postError(this.getUnitPath(), trinex.minChar, trinex.getLength(), 160 /* Type_of_conditional_expression_cannot_be_determined__Best_common_type_could_not_be_found_between__0__and__1_ */, [leftType.toString(false), rightType.toString(false)])]); - } - - return SymbolAndDiagnostics.fromSymbol(symbol); - }; - - PullTypeResolver.prototype.resolveParenthesizedExpression = function (ast, enclosingDecl, context) { - return this.resolveAST(ast.expression, false, enclosingDecl, context).withoutDiagnostics(); - }; - - PullTypeResolver.prototype.resolveExpressionStatement = function (ast, inContextuallyTypedAssignment, enclosingDecl, context) { - return this.resolveAST(ast.expression, inContextuallyTypedAssignment, enclosingDecl, context).withoutDiagnostics(); - }; - - PullTypeResolver.prototype.resolveCallExpression = function (callEx, inContextuallyTypedAssignment, enclosingDecl, context, additionalResults) { - if (additionalResults) { - return this.computeCallExpressionSymbol(callEx, inContextuallyTypedAssignment, enclosingDecl, context, additionalResults); - } - - var symbolAndDiagnostics = this.getSymbolAndDiagnosticsForAST(callEx); - if (!symbolAndDiagnostics || !symbolAndDiagnostics.symbol.isResolved()) { - symbolAndDiagnostics = this.computeCallExpressionSymbol(callEx, inContextuallyTypedAssignment, enclosingDecl, context, null); - this.setSymbolAndDiagnosticsForAST(callEx, symbolAndDiagnostics, context); - } - - return symbolAndDiagnostics; - }; - - PullTypeResolver.prototype.computeCallExpressionSymbol = function (callEx, inContextuallyTypedAssignment, enclosingDecl, context, additionalResults) { - var targetSymbol = this.resolveAST(callEx.target, inContextuallyTypedAssignment, enclosingDecl, context).symbol; - var targetAST = this.getLastIdentifierInTarget(callEx); - - var targetTypeSymbol = targetSymbol.getType(); - if (this.isAnyOrEquivalent(targetTypeSymbol)) { - if (callEx.typeArguments) { - return SymbolAndDiagnostics.create(this.getNewErrorTypeSymbol(null), [context.postError(this.unitPath, targetAST.minChar, targetAST.getLength(), 223 /* Untyped_function_calls_may_not_accept_type_arguments */)]); - } - - return SymbolAndDiagnostics.fromSymbol(this.semanticInfoChain.anyTypeSymbol); - } - - var diagnostics = []; - var isSuperCall = false; - - if (callEx.target.nodeType === 30 /* SuperExpression */) { - isSuperCall = true; - - if (targetTypeSymbol.isClass()) { - targetSymbol = (targetTypeSymbol).getConstructorMethod(); - targetTypeSymbol = targetSymbol.getType(); - } else { - diagnostics = this.addDiagnostic(diagnostics, context.postError(this.unitPath, targetAST.minChar, targetAST.getLength(), 158 /* Calls_to__super__are_only_valid_inside_a_class */)); - return SymbolAndDiagnostics.create(this.getNewErrorTypeSymbol(null), diagnostics); - } - } - - var signatures = isSuperCall ? (targetTypeSymbol).getConstructSignatures() : (targetTypeSymbol).getCallSignatures(); - - if (!signatures.length && (targetTypeSymbol.getKind() == 33554432 /* ConstructorType */)) { - diagnostics = this.addDiagnostic(diagnostics, context.postError(this.unitPath, targetAST.minChar, targetAST.getLength(), 227 /* Value_of_type__0__is_not_callable__Did_you_mean_to_include__new___ */, [targetTypeSymbol.toString()])); - } - - var typeArgs = null; - var typeReplacementMap = null; - var couldNotFindGenericOverload = false; - var couldNotAssignToConstraint; - - if (callEx.typeArguments) { - typeArgs = []; - - if (callEx.typeArguments && callEx.typeArguments.members.length) { - for (var i = 0; i < callEx.typeArguments.members.length; i++) { - var typeArg = this.resolveTypeReference(callEx.typeArguments.members[i], enclosingDecl, context).symbol; - typeArgs[i] = context.findSpecializationForType(typeArg); - } - } - } else if (isSuperCall && targetTypeSymbol.isGeneric()) { - typeArgs = targetTypeSymbol.getTypeArguments(); - } - - if (targetTypeSymbol.isGeneric()) { - var resolvedSignatures = []; - var inferredTypeArgs; - var specializedSignature; - var typeParameters; - var typeConstraint = null; - var prevSpecializingToAny = context.specializingToAny; - var prevSpecializing = context.isSpecializingSignatureAtCallSite; - var beforeResolutionSignatures = signatures; - var triedToInferTypeArgs; - - for (var i = 0; i < signatures.length; i++) { - typeParameters = signatures[i].getTypeParameters(); - couldNotAssignToConstraint = false; - triedToInferTypeArgs = false; - - if (signatures[i].isGeneric() && typeParameters.length && !signatures[i].isFixed()) { - if (typeArgs) { - inferredTypeArgs = typeArgs; - } else if (callEx.arguments) { - inferredTypeArgs = this.inferArgumentTypesForSignature(signatures[i], callEx.arguments, new TypeScript.TypeComparisonInfo(), enclosingDecl, context); - triedToInferTypeArgs = true; - } - - if (inferredTypeArgs) { - typeReplacementMap = {}; - - if (inferredTypeArgs.length) { - if (inferredTypeArgs.length != typeParameters.length) { - continue; - } - - for (var j = 0; j < typeParameters.length; j++) { - typeReplacementMap[typeParameters[j].getSymbolID().toString()] = inferredTypeArgs[j]; - } - for (var j = 0; j < typeParameters.length; j++) { - typeConstraint = typeParameters[j].getConstraint(); - - if (typeConstraint) { - if (typeConstraint.isTypeParameter()) { - for (var k = 0; k < typeParameters.length && k < inferredTypeArgs.length; k++) { - if (typeParameters[k] == typeConstraint) { - typeConstraint = inferredTypeArgs[k]; - } - } - } - if (typeConstraint.isTypeParameter()) { - context.pushTypeSpecializationCache(typeReplacementMap); - typeConstraint = TypeScript.specializeType(typeConstraint, null, this, enclosingDecl, context); - context.popTypeSpecializationCache(); - } - context.isComparingSpecializedSignatures = true; - if (!this.sourceIsAssignableToTarget(inferredTypeArgs[j], typeConstraint, context)) { - diagnostics = this.addDiagnostic(diagnostics, context.postError(this.unitPath, targetAST.minChar, targetAST.getLength(), 155 /* Type__0__does_not_satisfy_the_constraint__1__for_type_parameter__2_ */, [inferredTypeArgs[j].toString(true), typeConstraint.toString(true), typeParameters[j].toString(true)])); - couldNotAssignToConstraint = true; - } - context.isComparingSpecializedSignatures = false; - - if (couldNotAssignToConstraint) { - break; - } - } - } - } else { - if (triedToInferTypeArgs) { - if (signatures[i].parametersAreFixed()) { - if (signatures[i].hasGenericParameter()) { - context.specializingToAny = true; - } else { - resolvedSignatures[resolvedSignatures.length] = signatures[i]; - } - } else { - continue; - } - } - - context.specializingToAny = true; - } - - if (couldNotAssignToConstraint) { - continue; - } - - context.isSpecializingSignatureAtCallSite = true; - specializedSignature = TypeScript.specializeSignature(signatures[i], false, typeReplacementMap, inferredTypeArgs, this, enclosingDecl, context); - - context.isSpecializingSignatureAtCallSite = prevSpecializing; - context.specializingToAny = prevSpecializingToAny; - - if (specializedSignature) { - resolvedSignatures[resolvedSignatures.length] = specializedSignature; - } - } - } else { - if (!(callEx.typeArguments && callEx.typeArguments.members.length)) { - resolvedSignatures[resolvedSignatures.length] = signatures[i]; - } - } - } - - if (signatures.length && !resolvedSignatures.length) { - couldNotFindGenericOverload = true; - } - - signatures = resolvedSignatures; - } - - var errorCondition = null; - - if (!signatures.length) { - if (additionalResults) { - additionalResults.targetSymbol = targetSymbol; - additionalResults.targetTypeSymbol = targetTypeSymbol; - additionalResults.resolvedSignatures = beforeResolutionSignatures; - additionalResults.candidateSignature = beforeResolutionSignatures && beforeResolutionSignatures.length ? beforeResolutionSignatures[0] : null; - - additionalResults.actualParametersContextTypeSymbols = actualParametersContextTypeSymbols; - } - - if (!couldNotFindGenericOverload) { - if (this.cachedFunctionInterfaceType() && this.sourceIsSubtypeOfTarget(targetTypeSymbol, this.cachedFunctionInterfaceType(), context)) { - return SymbolAndDiagnostics.create(this.semanticInfoChain.anyTypeSymbol, diagnostics); - } - - diagnostics = this.addDiagnostic(diagnostics, context.postError(this.unitPath, callEx.minChar, callEx.getLength(), 157 /* Unable_to_invoke_type_with_no_call_signatures */)); - errorCondition = this.getNewErrorTypeSymbol(null); - } else { - diagnostics = this.addDiagnostic(diagnostics, context.postError(this.unitPath, callEx.minChar, callEx.getLength(), 156 /* Could_not_select_overload_for__call__expression */)); - errorCondition = this.getNewErrorTypeSymbol(null); - } - - return SymbolAndDiagnostics.create(errorCondition, diagnostics); - } - - var signature = this.resolveOverloads(callEx, signatures, enclosingDecl, callEx.typeArguments != null, context, diagnostics); - var useBeforeResolutionSignatures = signature == null; - - if (!signature) { - diagnostics = this.addDiagnostic(diagnostics, context.postError(this.unitPath, targetAST.minChar, targetAST.getLength(), 156 /* Could_not_select_overload_for__call__expression */)); - - errorCondition = this.getNewErrorTypeSymbol(null); - - if (!signatures.length) { - return SymbolAndDiagnostics.create(errorCondition, diagnostics); - } - - signature = signatures[0]; - - if (callEx.arguments) { - for (var k = 0, n = callEx.arguments.members.length; k < n; k++) { - var arg = callEx.arguments.members[k]; - var argSymbolAndDiagnostics = this.getSymbolAndDiagnosticsForAST(arg); - var argSymbol = argSymbolAndDiagnostics && argSymbolAndDiagnostics.symbol; - - if (argSymbol) { - var argType = argSymbol.getType(); - if (arg.nodeType === 12 /* FunctionDeclaration */) { - if (!this.canApplyContextualTypeToFunction(argType, arg, true)) { - continue; - } - } - - argSymbol.invalidate(); - } - } - } - } - - if (!signature.isGeneric() && callEx.typeArguments) { - diagnostics = this.addDiagnostic(diagnostics, context.postError(this.unitPath, targetAST.minChar, targetAST.getLength(), 224 /* Non_generic_functions_may_not_accept_type_arguments */)); - } - - var returnType = signature.getReturnType(); - - var actualParametersContextTypeSymbols = []; - if (callEx.arguments) { - var len = callEx.arguments.members.length; - var params = signature.getParameters(); - var contextualType = null; - var signatureDecl = signature.getDeclarations()[0]; - - for (var i = 0; i < len; i++) { - if (params.length) { - if (i < params.length - 1 || (i < params.length && !signature.hasVariableParamList())) { - if (typeReplacementMap) { - context.pushTypeSpecializationCache(typeReplacementMap); - } - this.resolveDeclaredSymbol(params[i], signatureDecl, context); - if (typeReplacementMap) { - context.popTypeSpecializationCache(); - } - contextualType = params[i].getType(); - } else if (signature.hasVariableParamList()) { - contextualType = params[params.length - 1].getType(); - if (contextualType.isArray()) { - contextualType = contextualType.getElementType(); - } - } - } - - if (contextualType) { - context.pushContextualType(contextualType, context.inProvisionalResolution(), null); - actualParametersContextTypeSymbols[i] = contextualType; - } - - this.resolveAST(callEx.arguments.members[i], contextualType != null, enclosingDecl, context); - - if (contextualType) { - context.popContextualType(); - contextualType = null; - } - } - } - - if (additionalResults) { - additionalResults.targetSymbol = targetSymbol; - additionalResults.targetTypeSymbol = targetTypeSymbol; - if (useBeforeResolutionSignatures && beforeResolutionSignatures) { - additionalResults.resolvedSignatures = beforeResolutionSignatures; - additionalResults.candidateSignature = beforeResolutionSignatures[0]; - } else { - additionalResults.resolvedSignatures = signatures; - additionalResults.candidateSignature = signature; - } - additionalResults.actualParametersContextTypeSymbols = actualParametersContextTypeSymbols; - } - - if (errorCondition) { - return SymbolAndDiagnostics.create(errorCondition, diagnostics); - } - - if (!returnType) { - returnType = this.semanticInfoChain.anyTypeSymbol; - } - - return SymbolAndDiagnostics.fromSymbol(returnType); - }; - - PullTypeResolver.prototype.resolveNewExpression = function (callEx, inContextuallyTypedAssignment, enclosingDecl, context, additionalResults) { - if (additionalResults) { - return this.computeNewExpressionSymbol(callEx, inContextuallyTypedAssignment, enclosingDecl, context, additionalResults); - } - - var symbolAndDiagnostics = this.getSymbolAndDiagnosticsForAST(callEx); - if (!symbolAndDiagnostics || !symbolAndDiagnostics.symbol.isResolved()) { - symbolAndDiagnostics = this.computeNewExpressionSymbol(callEx, inContextuallyTypedAssignment, enclosingDecl, context, null); - this.setSymbolAndDiagnosticsForAST(callEx, symbolAndDiagnostics, context); - } - - return symbolAndDiagnostics; - }; - - PullTypeResolver.prototype.computeNewExpressionSymbol = function (callEx, inContextuallyTypedAssignment, enclosingDecl, context, additionalResults) { - var returnType = null; - - var targetSymbol = this.resolveAST(callEx.target, inContextuallyTypedAssignment, enclosingDecl, context).symbol; - var targetTypeSymbol = targetSymbol.isType() ? targetSymbol : targetSymbol.getType(); - - var targetAST = this.getLastIdentifierInTarget(callEx); - - if (targetTypeSymbol.isClass()) { - targetTypeSymbol = (targetTypeSymbol).getConstructorMethod().getType(); - } - - var constructSignatures = targetTypeSymbol.getConstructSignatures(); - - var typeArgs = null; - var typeReplacementMap = null; - var usedCallSignaturesInstead = false; - var couldNotAssignToConstraint; - - if (this.isAnyOrEquivalent(targetTypeSymbol)) { - return SymbolAndDiagnostics.fromSymbol(targetTypeSymbol); - } - - if (!constructSignatures.length) { - constructSignatures = targetTypeSymbol.getCallSignatures(); - usedCallSignaturesInstead = true; - } - - var diagnostics = []; - if (constructSignatures.length) { - if (callEx.typeArguments) { - typeArgs = []; - - if (callEx.typeArguments && callEx.typeArguments.members.length) { - for (var i = 0; i < callEx.typeArguments.members.length; i++) { - var typeArg = this.resolveTypeReference(callEx.typeArguments.members[i], enclosingDecl, context).symbol; - typeArgs[i] = context.findSpecializationForType(typeArg); - } - } - } - - if (targetTypeSymbol.isGeneric()) { - var resolvedSignatures = []; - var inferredTypeArgs; - var specializedSignature; - var typeParameters; - var typeConstraint = null; - var prevSpecializingToAny = context.specializingToAny; - var prevIsSpecializing = context.isSpecializingSignatureAtCallSite = true; - var triedToInferTypeArgs; - - for (var i = 0; i < constructSignatures.length; i++) { - couldNotAssignToConstraint = false; - - if (constructSignatures[i].isGeneric() && !constructSignatures[i].isFixed()) { - if (typeArgs) { - inferredTypeArgs = typeArgs; - } else if (callEx.arguments) { - inferredTypeArgs = this.inferArgumentTypesForSignature(constructSignatures[i], callEx.arguments, new TypeScript.TypeComparisonInfo(), enclosingDecl, context); - triedToInferTypeArgs = true; - } - - if (inferredTypeArgs) { - typeParameters = constructSignatures[i].getTypeParameters(); - - typeReplacementMap = {}; - - if (inferredTypeArgs.length) { - if (inferredTypeArgs.length < typeParameters.length) { - continue; - } - - for (var j = 0; j < typeParameters.length; j++) { - typeReplacementMap[typeParameters[j].getSymbolID().toString()] = inferredTypeArgs[j]; - } - for (var j = 0; j < typeParameters.length; j++) { - typeConstraint = typeParameters[j].getConstraint(); - - if (typeConstraint) { - if (typeConstraint.isTypeParameter()) { - for (var k = 0; k < typeParameters.length && k < inferredTypeArgs.length; k++) { - if (typeParameters[k] == typeConstraint) { - typeConstraint = inferredTypeArgs[k]; - } - } - } - if (typeConstraint.isTypeParameter()) { - context.pushTypeSpecializationCache(typeReplacementMap); - typeConstraint = TypeScript.specializeType(typeConstraint, null, this, enclosingDecl, context); - context.popTypeSpecializationCache(); - } - - context.isComparingSpecializedSignatures = true; - if (!this.sourceIsAssignableToTarget(inferredTypeArgs[j], typeConstraint, context)) { - diagnostics = this.addDiagnostic(diagnostics, context.postError(this.unitPath, targetAST.minChar, targetAST.getLength(), 155 /* Type__0__does_not_satisfy_the_constraint__1__for_type_parameter__2_ */, [inferredTypeArgs[j].toString(true), typeConstraint.toString(true), typeParameters[j].toString(true)])); - couldNotAssignToConstraint = true; - } - context.isComparingSpecializedSignatures = false; - - if (couldNotAssignToConstraint) { - break; - } - } - } - } else { - if (triedToInferTypeArgs) { - if (constructSignatures[i].parametersAreFixed()) { - if (constructSignatures[i].hasGenericParameter()) { - context.specializingToAny = true; - } else { - resolvedSignatures[resolvedSignatures.length] = constructSignatures[i]; - } - } else { - continue; - } - } - - context.specializingToAny = true; - } - - if (couldNotAssignToConstraint) { - continue; - } - - context.isSpecializingSignatureAtCallSite = true; - specializedSignature = TypeScript.specializeSignature(constructSignatures[i], false, typeReplacementMap, inferredTypeArgs, this, enclosingDecl, context); - - context.specializingToAny = prevSpecializingToAny; - context.isSpecializingSignatureAtCallSite = prevIsSpecializing; - - if (specializedSignature) { - resolvedSignatures[resolvedSignatures.length] = specializedSignature; - } - } - } else { - if (!(callEx.typeArguments && callEx.typeArguments.members.length)) { - resolvedSignatures[resolvedSignatures.length] = constructSignatures[i]; - } - } - } - - constructSignatures = resolvedSignatures; - } - - var signature = this.resolveOverloads(callEx, constructSignatures, enclosingDecl, callEx.typeArguments != null, context, diagnostics); - - if (additionalResults) { - additionalResults.targetSymbol = targetSymbol; - additionalResults.targetTypeSymbol = targetTypeSymbol; - additionalResults.resolvedSignatures = constructSignatures; - additionalResults.candidateSignature = signature; - additionalResults.actualParametersContextTypeSymbols = []; - } - - if (!constructSignatures.length && diagnostics) { - var result = this.getNewErrorTypeSymbol(null); - return SymbolAndDiagnostics.create(result, diagnostics); - } - - var errorCondition = null; - - if (!signature) { - diagnostics = this.addDiagnostic(diagnostics, context.postError(this.unitPath, targetAST.minChar, targetAST.getLength(), 154 /* Could_not_select_overload_for__new__expression */)); - - errorCondition = this.getNewErrorTypeSymbol(null); - - if (!constructSignatures.length) { - return SymbolAndDiagnostics.create(errorCondition, diagnostics); - } - - signature = constructSignatures[0]; - - if (callEx.arguments) { - for (var k = 0, n = callEx.arguments.members.length; k < n; k++) { - var arg = callEx.arguments.members[k]; - var argSymbolAndDiagnostics = this.getSymbolAndDiagnosticsForAST(arg); - var argSymbol = argSymbolAndDiagnostics && argSymbolAndDiagnostics.symbol; - - if (argSymbol) { - var argType = argSymbol.getType(); - if (arg.nodeType === 12 /* FunctionDeclaration */) { - if (!this.canApplyContextualTypeToFunction(argType, arg, true)) { - continue; - } - } - - argSymbol.invalidate(); - } - } - } - } - - returnType = signature.getReturnType(); - - if (returnType && !signature.isGeneric() && returnType.isGeneric() && !returnType.getIsSpecialized()) { - if (typeArgs && typeArgs.length) { - returnType = TypeScript.specializeType(returnType, typeArgs, this, enclosingDecl, context, callEx); - } else { - returnType = this.specializeTypeToAny(returnType, enclosingDecl, context); - } - } - - if (usedCallSignaturesInstead) { - if (returnType != this.semanticInfoChain.voidTypeSymbol) { - diagnostics = this.addDiagnostic(diagnostics, context.postError(this.unitPath, targetAST.minChar, targetAST.getLength(), 153 /* Call_signatures_used_in_a__new__expression_must_have_a__void__return_type */)); - return SymbolAndDiagnostics.create(this.getNewErrorTypeSymbol(null), diagnostics); - } else { - returnType = this.semanticInfoChain.anyTypeSymbol; - } - } - - if (!returnType) { - returnType = signature.getReturnType(); - - if (!returnType) { - returnType = targetTypeSymbol; - } - } - - var actualParametersContextTypeSymbols = []; - if (callEx.arguments) { - var len = callEx.arguments.members.length; - var params = signature.getParameters(); - var contextualType = null; - var signatureDecl = signature.getDeclarations()[0]; - - for (var i = 0; i < len; i++) { - if (params.length) { - if (i < params.length - 1 || (i < params.length && !signature.hasVariableParamList())) { - if (typeReplacementMap) { - context.pushTypeSpecializationCache(typeReplacementMap); - } - this.resolveDeclaredSymbol(params[i], signatureDecl, context); - if (typeReplacementMap) { - context.popTypeSpecializationCache(); - } - contextualType = params[i].getType(); - } else if (signature.hasVariableParamList()) { - contextualType = params[params.length - 1].getType(); - if (contextualType.isArray()) { - contextualType = contextualType.getElementType(); - } - } - } - - if (contextualType) { - context.pushContextualType(contextualType, context.inProvisionalResolution(), null); - actualParametersContextTypeSymbols[i] = contextualType; - } - - this.resolveAST(callEx.arguments.members[i], contextualType != null, enclosingDecl, context); - - if (contextualType) { - context.popContextualType(); - contextualType = null; - } - } - } - - if (additionalResults) { - additionalResults.targetSymbol = targetSymbol; - additionalResults.targetTypeSymbol = targetTypeSymbol; - additionalResults.resolvedSignatures = constructSignatures; - additionalResults.candidateSignature = signature; - additionalResults.actualParametersContextTypeSymbols = actualParametersContextTypeSymbols; - } - - if (errorCondition) { - return SymbolAndDiagnostics.create(errorCondition, diagnostics); - } - - if (!returnType) { - returnType = this.semanticInfoChain.anyTypeSymbol; - } - - return SymbolAndDiagnostics.fromSymbol(returnType); - } else if (targetTypeSymbol.isClass()) { - return SymbolAndDiagnostics.fromSymbol(returnType); - } - - diagnostics = this.addDiagnostic(diagnostics, context.postError(this.unitPath, targetAST.minChar, targetAST.getLength(), 152 /* Invalid__new__expression */)); - - return SymbolAndDiagnostics.create(this.getNewErrorTypeSymbol(null), diagnostics); - }; - - PullTypeResolver.prototype.resolveTypeAssertionExpression = function (assertionExpression, inContextuallyTypedAssignment, enclosingDecl, context) { - return this.resolveTypeReference(assertionExpression.castTerm, enclosingDecl, context); - }; - - PullTypeResolver.prototype.resolveAssignmentStatement = function (binex, inContextuallyTypedAssignment, enclosingDecl, context) { - var symbolAndDiagnostics = this.getSymbolAndDiagnosticsForAST(binex); - - if (!symbolAndDiagnostics) { - symbolAndDiagnostics = this.computeAssignmentStatementSymbol(binex, inContextuallyTypedAssignment, enclosingDecl, context); - this.setSymbolAndDiagnosticsForAST(binex, symbolAndDiagnostics, context); - } - - return symbolAndDiagnostics; - }; - - PullTypeResolver.prototype.computeAssignmentStatementSymbol = function (binex, inContextuallyTypedAssignment, enclosingDecl, context) { - var leftType = this.resolveAST(binex.operand1, inContextuallyTypedAssignment, enclosingDecl, context).symbol.getType(); - - context.pushContextualType(leftType, context.inProvisionalResolution(), null); - this.resolveAST(binex.operand2, true, enclosingDecl, context); - context.popContextualType(); - - return SymbolAndDiagnostics.fromSymbol(leftType); - }; - - PullTypeResolver.prototype.resolveBoundDecls = function (decl, context) { - if (!decl) { - return; - } - - switch (decl.getKind()) { - case 1 /* Script */: - var childDecls = decl.getChildDecls(); - for (var i = 0; i < childDecls.length; i++) { - this.resolveBoundDecls(childDecls[i], context); - } - break; - case 32 /* DynamicModule */: - case 4 /* Container */: - case 64 /* Enum */: - var moduleDecl = this.semanticInfoChain.getASTForDecl(decl); - this.resolveModuleDeclaration(moduleDecl, context); - break; - case 16 /* Interface */: - var interfaceDecl = this.semanticInfoChain.getASTForDecl(decl); - this.resolveInterfaceDeclaration(interfaceDecl, context); - break; - case 8 /* Class */: - var classDecl = this.semanticInfoChain.getASTForDecl(decl); - this.resolveClassDeclaration(classDecl, context); - break; - case 65536 /* Method */: - case 16384 /* Function */: - var funcDecl = this.semanticInfoChain.getASTForDecl(decl); - this.resolveFunctionDeclaration(funcDecl, context); - break; - case 262144 /* GetAccessor */: - funcDecl = this.semanticInfoChain.getASTForDecl(decl); - this.resolveGetAccessorDeclaration(funcDecl, context); - break; - case 524288 /* SetAccessor */: - funcDecl = this.semanticInfoChain.getASTForDecl(decl); - this.resolveSetAccessorDeclaration(funcDecl, context); - break; - case 4096 /* Property */: - case 1024 /* Variable */: - case 2048 /* Parameter */: - var varDecl = this.semanticInfoChain.getASTForDecl(decl); - - if (varDecl) { - this.resolveVariableDeclaration(varDecl, context); - } - break; - } - }; - - PullTypeResolver.prototype.mergeOrdered = function (a, b, context, comparisonInfo) { - if (this.isAnyOrEquivalent(a) || this.isAnyOrEquivalent(b)) { - return this.semanticInfoChain.anyTypeSymbol; - } else if (a === b) { - return a; - } else if ((b === this.semanticInfoChain.nullTypeSymbol) && a != this.semanticInfoChain.nullTypeSymbol) { - return a; - } else if ((a === this.semanticInfoChain.nullTypeSymbol) && (b != this.semanticInfoChain.nullTypeSymbol)) { - return b; - } else if ((a === this.semanticInfoChain.voidTypeSymbol) && (b === this.semanticInfoChain.voidTypeSymbol || b === this.semanticInfoChain.undefinedTypeSymbol || b === this.semanticInfoChain.nullTypeSymbol)) { - return a; - } else if ((a === this.semanticInfoChain.voidTypeSymbol) && (b === this.semanticInfoChain.anyTypeSymbol)) { - return b; - } else if ((b === this.semanticInfoChain.undefinedTypeSymbol) && a != this.semanticInfoChain.voidTypeSymbol) { - return a; - } else if ((a === this.semanticInfoChain.undefinedTypeSymbol) && (b != this.semanticInfoChain.undefinedTypeSymbol)) { - return b; - } else if (a.isTypeParameter() && !b.isTypeParameter()) { - return b; - } else if (!a.isTypeParameter() && b.isTypeParameter()) { - return a; - } else if (a.isArray() && b.isArray()) { - if (a.getElementType() === b.getElementType()) { - return a; - } else { - var mergedET = this.mergeOrdered(a.getElementType(), b.getElementType(), context, comparisonInfo); - if (mergedET) { - var mergedArrayType = mergedET.getArrayType(); - - if (!mergedArrayType) { - mergedArrayType = TypeScript.specializeToArrayType(this.semanticInfoChain.elementTypeSymbol, mergedET, this, context); - } - - return mergedArrayType; - } - } - } else if (this.sourceIsSubtypeOfTarget(a, b, context, comparisonInfo)) { - return b; - } else if (this.sourceIsSubtypeOfTarget(b, a, context, comparisonInfo)) { - return a; - } - - return null; - }; - - PullTypeResolver.prototype.widenType = function (type) { - if (type === this.semanticInfoChain.undefinedTypeSymbol || type === this.semanticInfoChain.nullTypeSymbol || type.isError()) { - return this.semanticInfoChain.anyTypeSymbol; - } - - return type; - }; - - PullTypeResolver.prototype.isNullOrUndefinedType = function (type) { - return type === this.semanticInfoChain.nullTypeSymbol || type === this.semanticInfoChain.undefinedTypeSymbol; - }; - - PullTypeResolver.prototype.canApplyContextualType = function (type) { - if (!type) { - return true; - } - - var kind = type.getKind(); - - if ((kind & 8388608 /* ObjectType */) != 0) { - return true; - } - if ((kind & 16 /* Interface */) != 0) { - return true; - } else if ((kind & TypeScript.PullElementKind.SomeFunction) != 0) { - return this.canApplyContextualTypeToFunction(type, this.semanticInfoChain.getASTForDecl(type.getDeclarations[0]), true); - } else if ((kind & 128 /* Array */) != 0) { - return true; - } else if (type == this.semanticInfoChain.anyTypeSymbol || kind != 2 /* Primitive */) { - return true; - } - - return false; - }; - - PullTypeResolver.prototype.findBestCommonType = function (initialType, targetType, collection, context, comparisonInfo) { - var len = collection.getLength(); - var nlastChecked = 0; - var bestCommonType = initialType; - - if (targetType && this.canApplyContextualType(bestCommonType)) { - if (bestCommonType) { - bestCommonType = this.mergeOrdered(bestCommonType, targetType, context); - } else { - bestCommonType = targetType; - } - } - - var convergenceType = bestCommonType; - - while (nlastChecked < len) { - for (var i = 0; i < len; i++) { - if (i === nlastChecked) { - continue; - } - - if (convergenceType && (bestCommonType = this.mergeOrdered(convergenceType, collection.getTypeAtIndex(i), context, comparisonInfo))) { - convergenceType = bestCommonType; - } - - if (bestCommonType === null || this.isAnyOrEquivalent(bestCommonType)) { - break; - } else if (targetType && !(bestCommonType.isTypeParameter() || targetType.isTypeParameter())) { - collection.setTypeAtIndex(i, targetType); - } - } - - if (convergenceType && bestCommonType) { - break; - } - - nlastChecked++; - if (nlastChecked < len) { - convergenceType = collection.getTypeAtIndex(nlastChecked); - } - } - - if (!bestCommonType) { - var emptyTypeDecl = new TypeScript.PullDecl("{}", "{}", 8388608 /* ObjectType */, 0 /* None */, new TypeScript.TextSpan(0, 0), this.currentUnit.getPath()); - var emptyType = new TypeScript.PullTypeSymbol("{}", 8388608 /* ObjectType */); - - emptyTypeDecl.setSymbol(emptyType); - emptyType.addDeclaration(emptyTypeDecl); - - bestCommonType = emptyType; - } - - return bestCommonType; - }; - - PullTypeResolver.prototype.typesAreIdentical = function (t1, t2, val) { - if (t1 === t2) { - return true; - } - - if (!t1 || !t2) { - return false; - } - - if (val && t1.isPrimitive() && (t1).isStringConstant() && t2 === this.semanticInfoChain.stringTypeSymbol) { - return (val.nodeType === 5 /* StringLiteral */) && (TypeScript.stripQuotes((val).actualText) === TypeScript.stripQuotes(t1.getName())); - } - - if (val && t2.isPrimitive() && (t2).isStringConstant() && t2 === this.semanticInfoChain.stringTypeSymbol) { - return (val.nodeType === 5 /* StringLiteral */) && (TypeScript.stripQuotes((val).actualText) === TypeScript.stripQuotes(t2.getName())); - } - - if (t1.isPrimitive() && (t1).isStringConstant() && t2.isPrimitive() && (t2).isStringConstant()) { - return TypeScript.stripQuotes(t1.getName()) === TypeScript.stripQuotes(t2.getName()); - } - - if (t1.isPrimitive() || t2.isPrimitive()) { - return false; - } - - if (t1.isClass()) { - return false; - } - - if (t1.isError() && t2.isError()) { - return true; - } - - if (t1.isTypeParameter()) { - if (!t2.isTypeParameter()) { - return false; - } - - var t1ParentDeclaration = t1.getDeclarations()[0].getParentDecl(); - var t2ParentDeclaration = t2.getDeclarations()[0].getParentDecl(); - - if (t1ParentDeclaration === t2ParentDeclaration) { - return this.symbolsShareDeclaration(t1, t2); - } else { - return true; - } - } - - var comboId = t2.getSymbolID().toString() + "#" + t1.getSymbolID().toString(); - - if (this.identicalCache[comboId] != undefined) { - return true; - } - - if ((t1.getKind() & 64 /* Enum */) || (t2.getKind() & 64 /* Enum */)) { - return t1.getAssociatedContainerType() === t2 || t2.getAssociatedContainerType() === t1; - } - - if (t1.isArray() || t2.isArray()) { - if (!(t1.isArray() && t2.isArray())) { - return false; - } - this.identicalCache[comboId] = false; - var ret = this.typesAreIdentical(t1.getElementType(), t2.getElementType()); - if (ret) { - this.identicalCache[comboId] = true; - } else { - this.identicalCache[comboId] = undefined; - } - - return ret; - } - - if (t1.isPrimitive() != t2.isPrimitive()) { - return false; - } - - this.identicalCache[comboId] = false; - - if (t1.hasMembers() && t2.hasMembers()) { - var t1Members = t1.getMembers(); - var t2Members = t2.getMembers(); - - if (t1Members.length != t2Members.length) { - this.identicalCache[comboId] = undefined; - return false; - } - - var t1MemberSymbol = null; - var t2MemberSymbol = null; - - var t1MemberType = null; - var t2MemberType = null; - - for (var iMember = 0; iMember < t1Members.length; iMember++) { - t1MemberSymbol = t1Members[iMember]; - t2MemberSymbol = this.getMemberSymbol(t1MemberSymbol.getName(), TypeScript.PullElementKind.SomeValue, t2); - - if (!t2MemberSymbol || (t1MemberSymbol.getIsOptional() != t2MemberSymbol.getIsOptional())) { - this.identicalCache[comboId] = undefined; - return false; - } - - t1MemberType = t1MemberSymbol.getType(); - t2MemberType = t2MemberSymbol.getType(); - - if (t1MemberType && t2MemberType && (this.identicalCache[t2MemberType.getSymbolID().toString() + "#" + t1MemberType.getSymbolID().toString()] != undefined)) { - continue; - } - - if (!this.typesAreIdentical(t1MemberType, t2MemberType)) { - this.identicalCache[comboId] = undefined; - return false; - } - } - } else if (t1.hasMembers() || t2.hasMembers()) { - this.identicalCache[comboId] = undefined; - return false; - } - - var t1CallSigs = t1.getCallSignatures(); - var t2CallSigs = t2.getCallSignatures(); - - var t1ConstructSigs = t1.getConstructSignatures(); - var t2ConstructSigs = t2.getConstructSignatures(); - - var t1IndexSigs = t1.getIndexSignatures(); - var t2IndexSigs = t2.getIndexSignatures(); - - if (!this.signatureGroupsAreIdentical(t1CallSigs, t2CallSigs)) { - this.identicalCache[comboId] = undefined; - return false; - } - - if (!this.signatureGroupsAreIdentical(t1ConstructSigs, t2ConstructSigs)) { - this.identicalCache[comboId] = undefined; - return false; - } - - if (!this.signatureGroupsAreIdentical(t1IndexSigs, t2IndexSigs)) { - this.identicalCache[comboId] = undefined; - return false; - } - - this.identicalCache[comboId] = true; - return true; - }; - - PullTypeResolver.prototype.signatureGroupsAreIdentical = function (sg1, sg2) { - if (sg1 === sg2) { - return true; - } - - if (!sg1 || !sg2) { - return false; - } - - if (sg1.length != sg2.length) { - return false; - } - - var sig1 = null; - var sig2 = null; - var sigsMatch = false; - - for (var iSig1 = 0; iSig1 < sg1.length; iSig1++) { - sig1 = sg1[iSig1]; - - for (var iSig2 = 0; iSig2 < sg2.length; iSig2++) { - sig2 = sg2[iSig2]; - - if (this.signaturesAreIdentical(sig1, sig2)) { - sigsMatch = true; - break; - } - } - - if (sigsMatch) { - sigsMatch = false; - continue; - } - - return false; - } - - return true; - }; - - PullTypeResolver.prototype.signaturesAreIdentical = function (s1, s2) { - if (s1.hasVariableParamList() != s2.hasVariableParamList()) { - return false; - } - - if (s1.getNonOptionalParameterCount() != s2.getNonOptionalParameterCount()) { - return false; - } - - var s1Params = s1.getParameters(); - var s2Params = s2.getParameters(); - - if (s1Params.length != s2Params.length) { - return false; - } - - if (!this.typesAreIdentical(s1.getReturnType(), s2.getReturnType())) { - return false; - } - - for (var iParam = 0; iParam < s1Params.length; iParam++) { - if (!this.typesAreIdentical(s1Params[iParam].getType(), s2Params[iParam].getType())) { - return false; - } - } - - return true; - }; - - PullTypeResolver.prototype.substituteUpperBoundForType = function (type) { - if (!type || !type.isTypeParameter()) { - return type; - } - - var constraint = (type).getConstraint(); - - if (constraint) { - return this.substituteUpperBoundForType(constraint); - } - - if (this.cachedObjectInterfaceType()) { - return this.cachedObjectInterfaceType(); - } - - return type; - }; - - PullTypeResolver.prototype.symbolsShareDeclaration = function (symbol1, symbol2) { - var decls1 = symbol1.getDeclarations(); - var decls2 = symbol2.getDeclarations(); - - if (decls1.length && decls2.length) { - return decls1[0].isEqual(decls2[0]); - } - - return false; - }; - - PullTypeResolver.prototype.sourceIsSubtypeOfTarget = function (source, target, context, comparisonInfo) { - return this.sourceIsRelatableToTarget(source, target, false, this.subtypeCache, context, comparisonInfo); - }; - - PullTypeResolver.prototype.sourceMembersAreSubtypeOfTargetMembers = function (source, target, context, comparisonInfo) { - return this.sourceMembersAreRelatableToTargetMembers(source, target, false, this.subtypeCache, context, comparisonInfo); - }; - - PullTypeResolver.prototype.sourcePropertyIsSubtypeOfTargetProperty = function (source, target, sourceProp, targetProp, context, comparisonInfo) { - return this.sourcePropertyIsRelatableToTargetProperty(source, target, sourceProp, targetProp, false, this.subtypeCache, context, comparisonInfo); - }; - - PullTypeResolver.prototype.sourceCallSignaturesAreSubtypeOfTargetCallSignatures = function (source, target, context, comparisonInfo) { - return this.sourceCallSignaturesAreRelatableToTargetCallSignatures(source, target, false, this.subtypeCache, context, comparisonInfo); - }; - - PullTypeResolver.prototype.sourceConstructSignaturesAreSubtypeOfTargetConstructSignatures = function (source, target, context, comparisonInfo) { - return this.sourceConstructSignaturesAreRelatableToTargetConstructSignatures(source, target, false, this.subtypeCache, context, comparisonInfo); - }; - - PullTypeResolver.prototype.sourceIndexSignaturesAreSubtypeOfTargetIndexSignatures = function (source, target, context, comparisonInfo) { - return this.sourceIndexSignaturesAreRelatableToTargetIndexSignatures(source, target, false, this.subtypeCache, context, comparisonInfo); - }; - - PullTypeResolver.prototype.typeIsSubtypeOfFunction = function (source, context) { - var callSignatures = source.getCallSignatures(); - - if (callSignatures.length) { - return true; - } - - var constructSignatures = source.getConstructSignatures(); - - if (constructSignatures.length) { - return true; - } - - if (this.cachedFunctionInterfaceType()) { - return this.sourceIsSubtypeOfTarget(source, this.cachedFunctionInterfaceType(), context); - } - - return false; - }; - - PullTypeResolver.prototype.signatureGroupIsSubtypeOfTarget = function (sg1, sg2, context, comparisonInfo) { - return this.signatureGroupIsRelatableToTarget(sg1, sg2, false, this.subtypeCache, context, comparisonInfo); - }; - - PullTypeResolver.prototype.signatureIsSubtypeOfTarget = function (s1, s2, context, comparisonInfo) { - return this.signatureIsRelatableToTarget(s1, s2, false, this.subtypeCache, context, comparisonInfo); - }; - - PullTypeResolver.prototype.sourceIsAssignableToTarget = function (source, target, context, comparisonInfo, isInProvisionalResolution) { - if (typeof isInProvisionalResolution === "undefined") { isInProvisionalResolution = false; } - var cache = isInProvisionalResolution ? {} : this.assignableCache; - return this.sourceIsRelatableToTarget(source, target, true, cache, context, comparisonInfo); - }; - - PullTypeResolver.prototype.signatureGroupIsAssignableToTarget = function (sg1, sg2, context, comparisonInfo) { - return this.signatureGroupIsRelatableToTarget(sg1, sg2, true, this.assignableCache, context, comparisonInfo); - }; - - PullTypeResolver.prototype.signatureIsAssignableToTarget = function (s1, s2, context, comparisonInfo) { - return this.signatureIsRelatableToTarget(s1, s2, true, this.assignableCache, context, comparisonInfo); - }; - - PullTypeResolver.prototype.sourceIsRelatableToTarget = function (source, target, assignableTo, comparisonCache, context, comparisonInfo) { - if (source === target) { - return true; - } - - if (!(source && target)) { - return true; - } - - if (context.specializingToAny && (target.isTypeParameter() || source.isTypeParameter())) { - return true; - } - - if (context.specializingToObject) { - if (target.isTypeParameter()) { - target = this.cachedObjectInterfaceType(); - } - if (source.isTypeParameter()) { - target = this.cachedObjectInterfaceType(); - } - } - - var sourceSubstitution = source; - - if (source == this.semanticInfoChain.stringTypeSymbol && this.cachedStringInterfaceType()) { - if (!this.cachedStringInterfaceType().isResolved()) { - this.resolveDeclaredSymbol(this.cachedStringInterfaceType(), null, context); - } - sourceSubstitution = this.cachedStringInterfaceType(); - } else if (source == this.semanticInfoChain.numberTypeSymbol && this.cachedNumberInterfaceType()) { - if (!this.cachedNumberInterfaceType().isResolved()) { - this.resolveDeclaredSymbol(this.cachedNumberInterfaceType(), null, context); - } - sourceSubstitution = this.cachedNumberInterfaceType(); - } else if (source == this.semanticInfoChain.booleanTypeSymbol && this.cachedBooleanInterfaceType()) { - if (!this.cachedBooleanInterfaceType().isResolved()) { - this.resolveDeclaredSymbol(this.cachedBooleanInterfaceType(), null, context); - } - sourceSubstitution = this.cachedBooleanInterfaceType(); - } else if (TypeScript.PullHelpers.symbolIsEnum(source) && this.cachedNumberInterfaceType()) { - sourceSubstitution = this.cachedNumberInterfaceType(); - } else if (source.isTypeParameter()) { - sourceSubstitution = this.substituteUpperBoundForType(source); - } - - var comboId = source.getSymbolID().toString() + "#" + target.getSymbolID().toString(); - - if (comparisonCache[comboId] != undefined) { - return true; - } - - if (assignableTo) { - if (this.isAnyOrEquivalent(source) || this.isAnyOrEquivalent(target)) { - return true; - } - - if (source === this.semanticInfoChain.stringTypeSymbol && target.isPrimitive() && (target).isStringConstant()) { - return comparisonInfo && comparisonInfo.stringConstantVal && (comparisonInfo.stringConstantVal.nodeType === 5 /* StringLiteral */) && (TypeScript.stripQuotes((comparisonInfo.stringConstantVal).actualText) === TypeScript.stripQuotes(target.getName())); - } - } else { - if (this.isAnyOrEquivalent(target)) { - return true; - } - - if (target === this.semanticInfoChain.stringTypeSymbol && source.isPrimitive() && (source).isStringConstant()) { - return true; - } - } - - if (source.isPrimitive() && (source).isStringConstant() && target.isPrimitive() && (target).isStringConstant()) { - return TypeScript.stripQuotes(source.getName()) === TypeScript.stripQuotes(target.getName()); - } - - if (source === this.semanticInfoChain.undefinedTypeSymbol) { - return true; - } - - if ((source === this.semanticInfoChain.nullTypeSymbol) && (target != this.semanticInfoChain.undefinedTypeSymbol && target != this.semanticInfoChain.voidTypeSymbol)) { - return true; - } - - if (target == this.semanticInfoChain.voidTypeSymbol) { - if (source == this.semanticInfoChain.anyTypeSymbol || source == this.semanticInfoChain.undefinedTypeSymbol || source == this.semanticInfoChain.nullTypeSymbol) { - return true; - } - - return false; - } else if (source == this.semanticInfoChain.voidTypeSymbol) { - if (target == this.semanticInfoChain.anyTypeSymbol) { - return true; - } - - return false; - } - - if (target === this.semanticInfoChain.numberTypeSymbol && TypeScript.PullHelpers.symbolIsEnum(source)) { - return true; - } - - if (source === this.semanticInfoChain.numberTypeSymbol && TypeScript.PullHelpers.symbolIsEnum(target)) { - return true; - } - - if (TypeScript.PullHelpers.symbolIsEnum(target) && TypeScript.PullHelpers.symbolIsEnum(source)) { - return this.symbolsShareDeclaration(target, source); - } - - if ((source.getKind() & 64 /* Enum */) || (target.getKind() & 64 /* Enum */)) { - return false; - } - - if (source.isArray() && target.isArray()) { - comparisonCache[comboId] = false; - var ret = this.sourceIsRelatableToTarget(source.getElementType(), target.getElementType(), assignableTo, comparisonCache, context, comparisonInfo); - if (ret) { - comparisonCache[comboId] = true; - } else { - comparisonCache[comboId] = undefined; - } - - return ret; - } else if (source.isArray() && target == this.cachedArrayInterfaceType()) { - return true; - } else if (target.isArray() && source == this.cachedArrayInterfaceType()) { - return true; - } - - if (source.isPrimitive() && target.isPrimitive()) { - return false; - } else if (source.isPrimitive() != target.isPrimitive()) { - if (target.isPrimitive()) { - return false; - } - } - - if (target.isTypeParameter()) { - if (source.isTypeParameter() && (source == sourceSubstitution)) { - var targetParentDeclaration = target.getDeclarations()[0].getParentDecl(); - var sourceParentDeclaration = source.getDeclarations()[0].getParentDecl(); - - if (targetParentDeclaration !== sourceParentDeclaration) { - return this.symbolsShareDeclaration(target, source); - } else { - return true; - } - } else { - if (context.isComparingSpecializedSignatures) { - target = this.substituteUpperBoundForType(target); - } else { - return false; - } - } - } - - comparisonCache[comboId] = false; - - if (sourceSubstitution.hasBase(target)) { - comparisonCache[comboId] = true; - return true; - } - - if (this.cachedObjectInterfaceType() && target === this.cachedObjectInterfaceType()) { - return true; - } - - if (this.cachedFunctionInterfaceType() && (sourceSubstitution.getCallSignatures().length || sourceSubstitution.getConstructSignatures().length) && target === this.cachedFunctionInterfaceType()) { - return true; - } - - if (target.hasMembers() && !this.sourceMembersAreRelatableToTargetMembers(sourceSubstitution, target, assignableTo, comparisonCache, context, comparisonInfo)) { - comparisonCache[comboId] = undefined; - return false; - } - - if (!this.sourceCallSignaturesAreRelatableToTargetCallSignatures(sourceSubstitution, target, assignableTo, comparisonCache, context, comparisonInfo)) { - comparisonCache[comboId] = undefined; - return false; - } - - if (!this.sourceConstructSignaturesAreRelatableToTargetConstructSignatures(sourceSubstitution, target, assignableTo, comparisonCache, context, comparisonInfo)) { - comparisonCache[comboId] = undefined; - return false; - } - - if (!this.sourceIndexSignaturesAreRelatableToTargetIndexSignatures(sourceSubstitution, target, assignableTo, comparisonCache, context, comparisonInfo)) { - comparisonCache[comboId] = undefined; - return false; - } - - comparisonCache[comboId] = true; - return true; - }; - - PullTypeResolver.prototype.sourceMembersAreRelatableToTargetMembers = function (source, target, assignableTo, comparisonCache, context, comparisonInfo) { - var targetProps = target.getAllMembers(TypeScript.PullElementKind.SomeValue, true); - - for (var itargetProp = 0; itargetProp < targetProps.length; itargetProp++) { - var targetProp = targetProps[itargetProp]; - var sourceProp = this.getMemberSymbol(targetProp.getName(), TypeScript.PullElementKind.SomeValue, source); - - if (!targetProp.isResolved()) { - this.resolveDeclaredSymbol(targetProp, null, context); - } - - var targetPropType = targetProp.getType(); - - if (!sourceProp) { - if (this.cachedObjectInterfaceType()) { - sourceProp = this.getMemberSymbol(targetProp.getName(), TypeScript.PullElementKind.SomeValue, this.cachedObjectInterfaceType()); - } - - if (!sourceProp) { - if (this.cachedFunctionInterfaceType() && (targetPropType.getCallSignatures().length || targetPropType.getConstructSignatures().length)) { - sourceProp = this.getMemberSymbol(targetProp.getName(), TypeScript.PullElementKind.SomeValue, this.cachedFunctionInterfaceType()); - } - - if (!sourceProp) { - if (!(targetProp.getIsOptional())) { - if (comparisonInfo) { - comparisonInfo.flags |= 2 /* RequiredPropertyIsMissing */; - comparisonInfo.addMessage(TypeScript.getDiagnosticMessage(240 /* Type__0__is_missing_property__1__from_type__2_ */, [source.toString(), targetProp.getScopedNameEx().toString(), target.toString()])); - } - return false; - } - continue; - } - } - } - - if (!this.sourcePropertyIsRelatableToTargetProperty(source, target, sourceProp, targetProp, assignableTo, comparisonCache, context, comparisonInfo)) { - return false; - } - } - - return true; - }; - - PullTypeResolver.prototype.sourcePropertyIsRelatableToTargetProperty = function (source, target, sourceProp, targetProp, assignableTo, comparisonCache, context, comparisonInfo) { - var targetPropIsPrivate = targetProp.hasFlag(2 /* Private */); - var sourcePropIsPrivate = sourceProp.hasFlag(2 /* Private */); - - if (targetPropIsPrivate != sourcePropIsPrivate) { - if (comparisonInfo) { - if (targetPropIsPrivate) { - comparisonInfo.addMessage(TypeScript.getDiagnosticMessage(244 /* Property__0__defined_as_public_in_type__1__is_defined_as_private_in_type__2_ */, [targetProp.getScopedNameEx().toString(), sourceProp.getContainer().toString(), targetProp.getContainer().toString()])); - } else { - comparisonInfo.addMessage(TypeScript.getDiagnosticMessage(243 /* Property__0__defined_as_private_in_type__1__is_defined_as_public_in_type__2_ */, [targetProp.getScopedNameEx().toString(), sourceProp.getContainer().toString(), targetProp.getContainer().toString()])); - } - comparisonInfo.flags |= 128 /* InconsistantPropertyAccesibility */; - } - return false; - } else if (sourcePropIsPrivate && targetPropIsPrivate) { - var targetDecl = targetProp.getDeclarations()[0]; - var sourceDecl = sourceProp.getDeclarations()[0]; - - if (!targetDecl.isEqual(sourceDecl)) { - if (comparisonInfo) { - comparisonInfo.flags |= 128 /* InconsistantPropertyAccesibility */; - comparisonInfo.addMessage(TypeScript.getDiagnosticMessage(245 /* Types__0__and__1__define_property__2__as_private */, [sourceProp.getContainer().toString(), targetProp.getContainer().toString(), targetProp.getScopedNameEx().toString()])); - } - return false; - } - } - - if (!sourceProp.isResolved()) { - this.resolveDeclaredSymbol(sourceProp, null, context); - } - - var sourcePropType = sourceProp.getType(); - var targetPropType = targetProp.getType(); - - if (targetPropType && sourcePropType && (comparisonCache[sourcePropType.getSymbolID().toString() + "#" + targetPropType.getSymbolID().toString()] != undefined)) { - return true; - } - - var comparisonInfoPropertyTypeCheck = null; - if (comparisonInfo && !comparisonInfo.onlyCaptureFirstError) { - comparisonInfoPropertyTypeCheck = new TypeScript.TypeComparisonInfo(comparisonInfo); - } - if (!this.sourceIsRelatableToTarget(sourcePropType, targetPropType, assignableTo, comparisonCache, context, comparisonInfoPropertyTypeCheck)) { - if (comparisonInfo) { - comparisonInfo.flags |= 32 /* IncompatiblePropertyTypes */; - var message; - if (comparisonInfoPropertyTypeCheck && comparisonInfoPropertyTypeCheck.message) { - message = TypeScript.getDiagnosticMessage(242 /* Types_of_property__0__of_types__1__and__2__are_incompatible__NL__3 */, [targetProp.getScopedNameEx().toString(), source.toString(), target.toString(), comparisonInfoPropertyTypeCheck.message]); - } else { - message = TypeScript.getDiagnosticMessage(241 /* Types_of_property__0__of_types__1__and__2__are_incompatible */, [targetProp.getScopedNameEx().toString(), source.toString(), target.toString()]); - } - comparisonInfo.addMessage(message); - } - - return false; - } - - return true; - }; - - PullTypeResolver.prototype.sourceCallSignaturesAreRelatableToTargetCallSignatures = function (source, target, assignableTo, comparisonCache, context, comparisonInfo) { - var targetCallSigs = target.getCallSignatures(); - - if (targetCallSigs.length) { - var comparisonInfoSignatuesTypeCheck = null; - if (comparisonInfo && !comparisonInfo.onlyCaptureFirstError) { - comparisonInfoSignatuesTypeCheck = new TypeScript.TypeComparisonInfo(comparisonInfo); - } - - var sourceCallSigs = source.getCallSignatures(); - if (!this.signatureGroupIsRelatableToTarget(sourceCallSigs, targetCallSigs, assignableTo, comparisonCache, context, comparisonInfoSignatuesTypeCheck)) { - if (comparisonInfo) { - var message; - if (sourceCallSigs.length && targetCallSigs.length) { - if (comparisonInfoSignatuesTypeCheck && comparisonInfoSignatuesTypeCheck.message) { - message = TypeScript.getDiagnosticMessage(247 /* Call_signatures_of_types__0__and__1__are_incompatible__NL__2 */, [source.toString(), target.toString(), comparisonInfoSignatuesTypeCheck.message]); - } else { - message = TypeScript.getDiagnosticMessage(246 /* Call_signatures_of_types__0__and__1__are_incompatible */, [source.toString(), target.toString()]); - } - } else { - var hasSig = targetCallSigs.length ? target.toString() : source.toString(); - var lacksSig = !targetCallSigs.length ? target.toString() : source.toString(); - message = TypeScript.getDiagnosticMessage(248 /* Type__0__requires_a_call_signature__but_Type__1__lacks_one */, [hasSig, lacksSig]); - } - comparisonInfo.flags |= 4 /* IncompatibleSignatures */; - comparisonInfo.addMessage(message); - } - return false; - } - } - - return true; - }; - - PullTypeResolver.prototype.sourceConstructSignaturesAreRelatableToTargetConstructSignatures = function (source, target, assignableTo, comparisonCache, context, comparisonInfo) { - var targetConstructSigs = target.getConstructSignatures(); - if (targetConstructSigs.length) { - var comparisonInfoSignatuesTypeCheck = null; - if (comparisonInfo && !comparisonInfo.onlyCaptureFirstError) { - comparisonInfoSignatuesTypeCheck = new TypeScript.TypeComparisonInfo(comparisonInfo); - } - - var sourceConstructSigs = source.getConstructSignatures(); - if (!this.signatureGroupIsRelatableToTarget(sourceConstructSigs, targetConstructSigs, assignableTo, comparisonCache, context, comparisonInfoSignatuesTypeCheck)) { - if (comparisonInfo) { - var message; - if (sourceConstructSigs.length && targetConstructSigs.length) { - if (comparisonInfoSignatuesTypeCheck && comparisonInfoSignatuesTypeCheck.message) { - message = TypeScript.getDiagnosticMessage(250 /* Construct_signatures_of_types__0__and__1__are_incompatible__NL__2 */, [source.toString(), target.toString(), comparisonInfoSignatuesTypeCheck.message]); - } else { - message = TypeScript.getDiagnosticMessage(249 /* Construct_signatures_of_types__0__and__1__are_incompatible */, [source.toString(), target.toString()]); - } - } else { - var hasSig = targetConstructSigs.length ? target.toString() : source.toString(); - var lacksSig = !targetConstructSigs.length ? target.toString() : source.toString(); - message = TypeScript.getDiagnosticMessage(251 /* Type__0__requires_a_construct_signature__but_Type__1__lacks_one */, [hasSig, lacksSig]); - } - comparisonInfo.flags |= 4 /* IncompatibleSignatures */; - comparisonInfo.addMessage(message); - } - return false; - } - } - - return true; - }; - - PullTypeResolver.prototype.sourceIndexSignaturesAreRelatableToTargetIndexSignatures = function (source, target, assignableTo, comparisonCache, context, comparisonInfo) { - var targetIndexSigs = target.getIndexSignatures(); - - if (targetIndexSigs.length) { - var sourceIndexSigs = source.getIndexSignatures(); - - var targetIndex = !targetIndexSigs.length && this.cachedObjectInterfaceType() ? this.cachedObjectInterfaceType().getIndexSignatures() : targetIndexSigs; - var sourceIndex = !sourceIndexSigs.length && this.cachedObjectInterfaceType() ? this.cachedObjectInterfaceType().getIndexSignatures() : sourceIndexSigs; - - var sourceStringSig = null; - var sourceNumberSig = null; - - var targetStringSig = null; - var targetNumberSig = null; - - var params; - - for (var i = 0; i < targetIndex.length; i++) { - if (targetStringSig && targetNumberSig) { - break; - } - - params = targetIndex[i].getParameters(); - - if (params.length) { - if (!targetStringSig && params[0].getType() === this.semanticInfoChain.stringTypeSymbol) { - targetStringSig = targetIndex[i]; - continue; - } else if (!targetNumberSig && params[0].getType() === this.semanticInfoChain.numberTypeSymbol) { - targetNumberSig = targetIndex[i]; - continue; - } - } - } - - for (var i = 0; i < sourceIndex.length; i++) { - if (sourceStringSig && sourceNumberSig) { - break; - } - - params = sourceIndex[i].getParameters(); - - if (params.length) { - if (!sourceStringSig && params[0].getType() === this.semanticInfoChain.stringTypeSymbol) { - sourceStringSig = sourceIndex[i]; - continue; - } else if (!sourceNumberSig && params[0].getType() === this.semanticInfoChain.numberTypeSymbol) { - sourceNumberSig = sourceIndex[i]; - continue; - } - } - } - - var comparable = true; - var comparisonInfoSignatuesTypeCheck = null; - if (comparisonInfo && !comparisonInfo.onlyCaptureFirstError) { - comparisonInfoSignatuesTypeCheck = new TypeScript.TypeComparisonInfo(comparisonInfo); - } - - if (targetStringSig) { - if (sourceStringSig) { - comparable = this.signatureIsAssignableToTarget(sourceStringSig, targetStringSig, context, comparisonInfoSignatuesTypeCheck); - } else { - comparable = false; - } - } - - if (comparable && targetNumberSig) { - if (sourceNumberSig) { - comparable = this.signatureIsAssignableToTarget(sourceNumberSig, targetNumberSig, context, comparisonInfoSignatuesTypeCheck); - } else if (sourceStringSig) { - comparable = this.sourceIsAssignableToTarget(sourceStringSig.getReturnType(), targetNumberSig.getReturnType(), context, comparisonInfoSignatuesTypeCheck); - } else { - comparable = false; - } - } - - if (!comparable) { - if (comparisonInfo) { - var message; - if (comparisonInfoSignatuesTypeCheck && comparisonInfoSignatuesTypeCheck.message) { - message = TypeScript.getDiagnosticMessage(253 /* Index_signatures_of_types__0__and__1__are_incompatible__NL__2 */, [source.toString(), target.toString(), comparisonInfoSignatuesTypeCheck.message]); - } else { - message = TypeScript.getDiagnosticMessage(252 /* Index_signatures_of_types__0__and__1__are_incompatible */, [source.toString(), target.toString()]); - } - comparisonInfo.flags |= 4 /* IncompatibleSignatures */; - comparisonInfo.addMessage(message); - } - return false; - } - } - - if (targetStringSig && !source.isNamedTypeSymbol() && source.hasMembers()) { - var targetReturnType = targetStringSig.getReturnType(); - var sourceMembers = source.getMembers(); - - for (var i = 0; i < sourceMembers.length; i++) { - if (!this.sourceIsRelatableToTarget(sourceMembers[i].getType(), targetReturnType, assignableTo, comparisonCache, context, comparisonInfo)) { - return false; - } - } - } - - return true; - }; - - PullTypeResolver.prototype.signatureGroupIsRelatableToTarget = function (sourceSG, targetSG, assignableTo, comparisonCache, context, comparisonInfo) { - if (sourceSG === targetSG) { - return true; - } - - if (!(sourceSG.length && targetSG.length)) { - return false; - } - - var mSig = null; - var nSig = null; - var foundMatch = false; - - for (var iMSig = 0; iMSig < targetSG.length; iMSig++) { - mSig = targetSG[iMSig]; - - if (mSig.isStringConstantOverloadSignature()) { - continue; - } - - for (var iNSig = 0; iNSig < sourceSG.length; iNSig++) { - nSig = sourceSG[iNSig]; - - if (nSig.isStringConstantOverloadSignature()) { - continue; - } - - if (this.signatureIsRelatableToTarget(nSig, mSig, assignableTo, comparisonCache, context, comparisonInfo)) { - foundMatch = true; - break; - } - } - - if (foundMatch) { - foundMatch = false; - continue; - } - return false; - } - - return true; - }; - - PullTypeResolver.prototype.signatureIsRelatableToTarget = function (sourceSig, targetSig, assignableTo, comparisonCache, context, comparisonInfo) { - var sourceParameters = sourceSig.getParameters(); - var targetParameters = targetSig.getParameters(); - - if (!sourceParameters || !targetParameters) { - return false; - } - - var targetVarArgCount = targetSig.getNonOptionalParameterCount(); - var sourceVarArgCount = sourceSig.getNonOptionalParameterCount(); - - if (sourceVarArgCount > targetVarArgCount && !targetSig.hasVariableParamList()) { - if (comparisonInfo) { - comparisonInfo.flags |= 3 /* SourceSignatureHasTooManyParameters */; - comparisonInfo.addMessage(TypeScript.getDiagnosticMessage(254 /* Call_signature_expects__0__or_fewer_parameters */, [targetVarArgCount])); - } - return false; - } - - var sourceReturnType = sourceSig.getReturnType(); - var targetReturnType = targetSig.getReturnType(); - - var prevSpecializingToObject = context.specializingToObject; - context.specializingToObject = true; - - if (targetReturnType != this.semanticInfoChain.voidTypeSymbol) { - if (!this.sourceIsRelatableToTarget(sourceReturnType, targetReturnType, assignableTo, comparisonCache, context, comparisonInfo)) { - if (comparisonInfo) { - comparisonInfo.flags |= 16 /* IncompatibleReturnTypes */; - } - context.specializingToObject = prevSpecializingToObject; - return false; - } - } - - var len = (sourceVarArgCount < targetVarArgCount && (sourceSig.hasVariableParamList() || (sourceParameters.length > sourceVarArgCount))) ? targetVarArgCount : sourceVarArgCount; - var sourceParamType = null; - var targetParamType = null; - var sourceParamName = ""; - var targetParamName = ""; - - for (var iSource = 0, iTarget = 0; iSource < len; iSource++, iTarget++) { - if (iSource < sourceParameters.length && (!sourceSig.hasVariableParamList() || iSource < sourceVarArgCount)) { - sourceParamType = sourceParameters[iSource].getType(); - sourceParamName = sourceParameters[iSource].getName(); - } else if (iSource === sourceVarArgCount) { - sourceParamType = sourceParameters[iSource].getType(); - if (sourceParamType.isArray()) { - sourceParamType = sourceParamType.getElementType(); - } - sourceParamName = sourceParameters[iSource].getName(); - } - - if (iTarget < targetParameters.length && iTarget < targetVarArgCount) { - targetParamType = targetParameters[iTarget].getType(); - targetParamName = targetParameters[iTarget].getName(); - } else if (targetSig.hasVariableParamList() && iTarget === targetVarArgCount) { - targetParamType = targetParameters[iTarget].getType(); - - if (targetParamType.isArray()) { - targetParamType = targetParamType.getElementType(); - } - targetParamName = targetParameters[iTarget].getName(); - } - - if (sourceParamType && sourceParamType.isTypeParameter() && this.cachedObjectInterfaceType()) { - sourceParamType = this.cachedObjectInterfaceType(); - } - if (targetParamType && targetParamType.isTypeParameter() && this.cachedObjectInterfaceType()) { - targetParamType = this.cachedObjectInterfaceType(); - } - - if (!(this.sourceIsRelatableToTarget(sourceParamType, targetParamType, assignableTo, comparisonCache, context, comparisonInfo) || this.sourceIsRelatableToTarget(targetParamType, sourceParamType, assignableTo, comparisonCache, context, comparisonInfo))) { - if (comparisonInfo) { - comparisonInfo.flags |= 64 /* IncompatibleParameterTypes */; - } - context.specializingToObject = prevSpecializingToObject; - return false; - } - } - context.specializingToObject = prevSpecializingToObject; - return true; - }; - - PullTypeResolver.prototype.resolveOverloads = function (application, group, enclosingDecl, haveTypeArgumentsAtCallSite, context, diagnostics) { - var rd = this.resolutionDataCache.getResolutionData(); - var actuals = rd.actuals; - var exactCandidates = rd.exactCandidates; - var conversionCandidates = rd.conversionCandidates; - var candidate = null; - var hasOverloads = group.length > 1; - var comparisonInfo = new TypeScript.TypeComparisonInfo(); - var args = null; - var target = null; - - if (application.nodeType === 36 /* InvocationExpression */ || application.nodeType === 37 /* ObjectCreationExpression */) { - var callEx = application; - - args = callEx.arguments; - target = this.getLastIdentifierInTarget(callEx); - - if (callEx.arguments) { - var len = callEx.arguments.members.length; - - for (var i = 0; i < len; i++) { - var argSym = this.resolveAST(callEx.arguments.members[i], false, enclosingDecl, context).symbol; - actuals[i] = argSym.getType(); - } - } - } else if (application.nodeType === 35 /* ElementAccessExpression */) { - var binExp = application; - target = binExp.operand1; - args = new TypeScript.ASTList(); - args.members[0] = binExp.operand2; - var argSym = this.resolveAST(args.members[0], false, enclosingDecl, context).symbol; - actuals[0] = argSym.getType(); - } - - var signature; - var returnType; - var candidateInfo; - - for (var j = 0, groupLen = group.length; j < groupLen; j++) { - signature = group[j]; - if ((hasOverloads && signature.isDefinition()) || (haveTypeArgumentsAtCallSite && !signature.isGeneric())) { - continue; - } - - returnType = signature.getReturnType(); - - this.getCandidateSignatures(signature, actuals, args, exactCandidates, conversionCandidates, enclosingDecl, context, comparisonInfo); - } - if (exactCandidates.length === 0) { - var applicableCandidates = this.getApplicableSignaturesFromCandidates(conversionCandidates, args, comparisonInfo, enclosingDecl, context); - if (applicableCandidates.length > 0) { - candidateInfo = this.findMostApplicableSignature(applicableCandidates, args, enclosingDecl, context); - - candidate = candidateInfo.sig; - } else { - if (comparisonInfo.message) { - diagnostics.push(context.postError(this.unitPath, target.minChar, target.getLength(), 151 /* Supplied_parameters_do_not_match_any_signature_of_call_target__NL__0 */, [comparisonInfo.message])); - } else { - diagnostics.push(context.postError(this.unitPath, target.minChar, target.getLength(), 150 /* Supplied_parameters_do_not_match_any_signature_of_call_target */, null)); - } - } - } else { - if (exactCandidates.length > 1) { - var applicableSigs = []; - for (var i = 0; i < exactCandidates.length; i++) { - applicableSigs[i] = { signature: exactCandidates[i], hadProvisionalErrors: false }; - } - candidateInfo = this.findMostApplicableSignature(applicableSigs, args, enclosingDecl, context); - - candidate = candidateInfo.sig; - } else { - candidate = exactCandidates[0]; - } - } - - this.resolutionDataCache.returnResolutionData(rd); - return candidate; - }; - - PullTypeResolver.prototype.getLastIdentifierInTarget = function (callEx) { - return (callEx.target.nodeType === 32 /* MemberAccessExpression */) ? (callEx.target).operand2 : callEx.target; - }; - - PullTypeResolver.prototype.getCandidateSignatures = function (signature, actuals, args, exactCandidates, conversionCandidates, enclosingDecl, context, comparisonInfo) { - var parameters = signature.getParameters(); - var lowerBound = signature.getNonOptionalParameterCount(); - var upperBound = parameters.length; - var formalLen = lowerBound; - var acceptable = false; - - if ((actuals.length >= lowerBound) && (signature.hasVariableParamList() || actuals.length <= upperBound)) { - formalLen = (signature.hasVariableParamList() ? parameters.length : actuals.length); - acceptable = true; - } - - var repeatType = null; - - if (acceptable) { - if (signature.hasVariableParamList()) { - formalLen -= 1; - repeatType = parameters[formalLen].getType(); - repeatType = repeatType.getElementType(); - acceptable = actuals.length >= (formalLen < lowerBound ? formalLen : lowerBound); - } - var len = actuals.length; - - var exact = acceptable; - var convert = acceptable; - - var typeA; - var typeB; - - for (var i = 0; i < len; i++) { - if (i < formalLen) { - typeA = parameters[i].getType(); - } else { - typeA = repeatType; - } - - typeB = actuals[i]; - - if (typeA && !typeA.isResolved()) { - this.resolveDeclaredSymbol(typeA, enclosingDecl, context); - } - - if (typeB && !typeB.isResolved()) { - this.resolveDeclaredSymbol(typeB, enclosingDecl, context); - } - - if (!typeA || !typeB || !(this.typesAreIdentical(typeA, typeB, args.members[i]))) { - exact = false; - } - - comparisonInfo.stringConstantVal = args.members[i]; - - if (!this.sourceIsAssignableToTarget(typeB, typeA, context, comparisonInfo)) { - convert = false; - } - - comparisonInfo.stringConstantVal = null; - - if (!(exact || convert)) { - break; - } - } - if (exact) { - exactCandidates[exactCandidates.length] = signature; - } else if (convert && (exactCandidates.length === 0)) { - conversionCandidates[conversionCandidates.length] = signature; - } - } - }; - - PullTypeResolver.prototype.getApplicableSignaturesFromCandidates = function (candidateSignatures, args, comparisonInfo, enclosingDecl, context) { - var applicableSigs = []; - var memberType = null; - var miss = false; - var cxt = null; - var hadProvisionalErrors = false; - - var parameters; - var signature; - var argSym; - - for (var i = 0; i < candidateSignatures.length; i++) { - miss = false; - - signature = candidateSignatures[i]; - parameters = signature.getParameters(); - - for (var j = 0; j < args.members.length; j++) { - if (j >= parameters.length) { - continue; - } - - if (!parameters[j].isResolved()) { - this.resolveDeclaredSymbol(parameters[j], enclosingDecl, context); - } - - memberType = parameters[j].getType(); - - if (signature.hasVariableParamList() && (j >= signature.getNonOptionalParameterCount()) && memberType.isArray()) { - memberType = memberType.getElementType(); - } - - if (this.isAnyOrEquivalent(memberType)) { - continue; - } else if (args.members[j].nodeType === 12 /* FunctionDeclaration */) { - if (this.cachedFunctionInterfaceType() && memberType === this.cachedFunctionInterfaceType()) { - continue; - } - - argSym = this.resolveFunctionExpression(args.members[j], false, enclosingDecl, context); - - if (!this.canApplyContextualTypeToFunction(memberType, args.members[j], true)) { - if (this.canApplyContextualTypeToFunction(memberType, args.members[j], false)) { - if (!this.sourceIsAssignableToTarget(argSym.getType(), memberType, context, comparisonInfo, true)) { - break; - } - } else { - break; - } - } else { - argSym.invalidate(); - context.pushContextualType(memberType, true, null); - - argSym = this.resolveFunctionExpression(args.members[j], true, enclosingDecl, context); - - if (!this.sourceIsAssignableToTarget(argSym.getType(), memberType, context, comparisonInfo, true)) { - if (comparisonInfo) { - comparisonInfo.setMessage(TypeScript.getDiagnosticMessage(255 /* Could_not_apply_type__0__to_argument__1__which_is_of_type__2_ */, [memberType.toString(), (j + 1), argSym.getTypeName()])); - } - miss = true; - } - argSym.invalidate(); - cxt = context.popContextualType(); - hadProvisionalErrors = cxt.hadProvisionalErrors(); - - if (miss) { - break; - } - } - } else if (args.members[j].nodeType === 22 /* ObjectLiteralExpression */) { - if (this.cachedObjectInterfaceType() && memberType === this.cachedObjectInterfaceType()) { - continue; - } - - context.pushContextualType(memberType, true, null); - argSym = this.resolveObjectLiteralExpression(args.members[j], true, enclosingDecl, context).symbol; - - if (!this.sourceIsAssignableToTarget(argSym.getType(), memberType, context, comparisonInfo, true)) { - if (comparisonInfo) { - comparisonInfo.setMessage(TypeScript.getDiagnosticMessage(255 /* Could_not_apply_type__0__to_argument__1__which_is_of_type__2_ */, [memberType.toString(), (j + 1), argSym.getTypeName()])); - } - - miss = true; - } - - argSym.invalidate(); - cxt = context.popContextualType(); - hadProvisionalErrors = cxt.hadProvisionalErrors(); - - if (miss) { - break; - } - } else if (args.members[j].nodeType === 21 /* ArrayLiteralExpression */) { - if (memberType === this.cachedArrayInterfaceType()) { - continue; - } - - context.pushContextualType(memberType, true, null); - var argSym = this.resolveArrayLiteralExpression(args.members[j], true, enclosingDecl, context).symbol; - - if (!this.sourceIsAssignableToTarget(argSym.getType(), memberType, context, comparisonInfo, true)) { - if (comparisonInfo) { - comparisonInfo.setMessage(TypeScript.getDiagnosticMessage(255 /* Could_not_apply_type__0__to_argument__1__which_is_of_type__2_ */, [memberType.toString(), (j + 1), argSym.getTypeName()])); - } - break; - } - - argSym.invalidate(); - cxt = context.popContextualType(); - - hadProvisionalErrors = cxt.hadProvisionalErrors(); - - if (miss) { - break; - } - } - } - - if (j === args.members.length) { - applicableSigs[applicableSigs.length] = { signature: candidateSignatures[i], hadProvisionalErrors: hadProvisionalErrors }; - } - - hadProvisionalErrors = false; - } - - return applicableSigs; - }; - - PullTypeResolver.prototype.findMostApplicableSignature = function (signatures, args, enclosingDecl, context) { - if (signatures.length === 1) { - return { sig: signatures[0].signature, ambiguous: false }; - } - - var best = signatures[0]; - var Q = null; - - var AType = null; - var PType = null; - var QType = null; - - var ambiguous = false; - - var bestParams; - var qParams; - - for (var qSig = 1; qSig < signatures.length; qSig++) { - Q = signatures[qSig]; - - for (var i = 0; args && i < args.members.length; i++) { - var argSym = this.resolveAST(args.members[i], false, enclosingDecl, context).symbol; - - AType = argSym.getType(); - - argSym.invalidate(); - - bestParams = best.signature.getParameters(); - qParams = Q.signature.getParameters(); - - PType = i < bestParams.length ? bestParams[i].getType() : bestParams[bestParams.length - 1].getType().getElementType(); - QType = i < qParams.length ? qParams[i].getType() : qParams[qParams.length - 1].getType().getElementType(); - - if (this.typesAreIdentical(PType, QType) && !(QType.isPrimitive() && (QType).isStringConstant())) { - continue; - } else if (PType.isPrimitive() && (PType).isStringConstant() && args.members[i].nodeType === 5 /* StringLiteral */ && TypeScript.stripQuotes((args.members[i]).actualText) === TypeScript.stripQuotes((PType).getName())) { - break; - } else if (QType.isPrimitive() && (QType).isStringConstant() && args.members[i].nodeType === 5 /* StringLiteral */ && TypeScript.stripQuotes((args.members[i]).actualText) === TypeScript.stripQuotes((QType).getName())) { - best = Q; - } else if (this.typesAreIdentical(AType, PType)) { - break; - } else if (this.typesAreIdentical(AType, QType)) { - best = Q; - break; - } else if (this.sourceIsSubtypeOfTarget(PType, QType, context)) { - break; - } else if (this.sourceIsSubtypeOfTarget(QType, PType, context)) { - best = Q; - break; - } else if (Q.hadProvisionalErrors) { - break; - } else if (best.hadProvisionalErrors) { - best = Q; - break; - } - } - - if (!args || i === args.members.length) { - var collection = { - getLength: function () { - return 2; - }, - setTypeAtIndex: function (index, type) { - }, - getTypeAtIndex: function (index) { - return index ? Q.signature.getReturnType() : best.signature.getReturnType(); - } - }; - var bct = this.findBestCommonType(best.signature.getReturnType(), null, collection, context); - ambiguous = !bct; - } else { - ambiguous = false; - } - } - - return { sig: best.signature, ambiguous: ambiguous }; - }; - - PullTypeResolver.prototype.canApplyContextualTypeToFunction = function (candidateType, funcDecl, beStringent) { - if (funcDecl.isMethod() || beStringent && funcDecl.returnTypeAnnotation) { - return false; - } - - beStringent = beStringent || (this.cachedFunctionInterfaceType() === candidateType); - - if (!beStringent) { - return true; - } - var functionSymbol = this.getDeclForAST(funcDecl).getSymbol(); - var signature = functionSymbol.getType().getCallSignatures()[0]; - var parameters = signature.getParameters(); - var paramLen = parameters.length; - - for (var i = 0; i < paramLen; i++) { - var param = parameters[i]; - var argDecl = this.getASTForDecl(param.getDeclarations()[0]); - - if (beStringent && argDecl.typeExpr) { - return false; - } - } - - if (candidateType.getConstructSignatures().length && candidateType.getCallSignatures().length) { - return false; - } - - var candidateSigs = candidateType.getConstructSignatures().length ? candidateType.getConstructSignatures() : candidateType.getCallSignatures(); - - if (!candidateSigs || candidateSigs.length > 1) { - return false; - } - - return true; - }; - - PullTypeResolver.prototype.inferArgumentTypesForSignature = function (signature, args, comparisonInfo, enclosingDecl, context) { - var cxt = null; - var hadProvisionalErrors = false; - - var parameters = signature.getParameters(); - var typeParameters = signature.getTypeParameters(); - var argContext = new TypeScript.ArgumentInferenceContext(); - - var parameterType = null; - - for (var i = 0; i < typeParameters.length; i++) { - argContext.addInferenceRoot(typeParameters[i]); - } - - var substitutions; - var inferenceCandidates; - var inferenceCandidate; - - for (var i = 0; i < args.members.length; i++) { - if (i >= parameters.length) { - break; - } - - parameterType = parameters[i].getType(); - - if (signature.hasVariableParamList() && (i >= signature.getNonOptionalParameterCount() - 1) && parameterType.isArray()) { - parameterType = parameterType.getElementType(); - } - - inferenceCandidates = argContext.getInferenceCandidates(); - substitutions = {}; - - if (inferenceCandidates.length) { - for (var j = 0; j < inferenceCandidates.length; j++) { - argContext.resetRelationshipCache(); - - inferenceCandidate = inferenceCandidates[j]; - - substitutions = inferenceCandidates[j]; - - context.pushContextualType(parameterType, true, substitutions); - - var argSym = this.resolveAST(args.members[i], true, enclosingDecl, context).symbol; - - this.relateTypeToTypeParameters(argSym.getType(), parameterType, false, argContext, enclosingDecl, context); - - cxt = context.popContextualType(); - - argSym.invalidate(); - - hadProvisionalErrors = cxt.hadProvisionalErrors(); - } - } else { - context.pushContextualType(parameterType, true, {}); - var argSym = this.resolveAST(args.members[i], true, enclosingDecl, context).symbol; - - this.relateTypeToTypeParameters(argSym.getType(), parameterType, false, argContext, enclosingDecl, context); - - cxt = context.popContextualType(); - - argSym.invalidate(); - - hadProvisionalErrors = cxt.hadProvisionalErrors(); - } - } - - hadProvisionalErrors = false; - - var inferenceResults = argContext.inferArgumentTypes(this, context); - - if (inferenceResults.unfit) { - return null; - } - - var resultTypes = []; - - for (var i = 0; i < typeParameters.length; i++) { - for (var j = 0; j < inferenceResults.results.length; j++) { - if (inferenceResults.results[j].param == typeParameters[i]) { - resultTypes[resultTypes.length] = inferenceResults.results[j].type; - break; - } - } - } - - if (!args.members.length && !resultTypes.length && typeParameters.length) { - for (var i = 0; i < typeParameters.length; i++) { - resultTypes[resultTypes.length] = this.semanticInfoChain.anyTypeSymbol; - } - } else if (resultTypes.length && resultTypes.length < typeParameters.length) { - for (var i = resultTypes.length; i < typeParameters.length; i++) { - resultTypes[i] = this.semanticInfoChain.anyTypeSymbol; - } - } - - return resultTypes; - }; - - PullTypeResolver.prototype.relateTypeToTypeParameters = function (expressionType, parameterType, shouldFix, argContext, enclosingDecl, context) { - if (!expressionType || !parameterType) { - return; - } - - if (expressionType.isError()) { - expressionType = this.semanticInfoChain.anyTypeSymbol; - } - - if (parameterType === expressionType) { - return; - } - - if (parameterType.isTypeParameter()) { - if (expressionType.isGeneric() && !expressionType.isFixed()) { - expressionType = this.specializeTypeToAny(expressionType, enclosingDecl, context); - } - argContext.addCandidateForInference(parameterType, expressionType, shouldFix); - return; - } - var parameterDeclarations = parameterType.getDeclarations(); - var expressionDeclarations = expressionType.getDeclarations(); - if (!parameterType.isArray() && parameterDeclarations.length && expressionDeclarations.length && (parameterDeclarations[0].isEqual(expressionDeclarations[0]) || (expressionType.isGeneric() && parameterType.isGeneric() && this.sourceIsSubtypeOfTarget(expressionType, parameterType, context, null))) && expressionType.isGeneric()) { - var typeParameters = parameterType.getIsSpecialized() ? parameterType.getTypeArguments() : parameterType.getTypeParameters(); - var typeArguments = expressionType.getTypeArguments(); - - if (!typeArguments) { - typeParameters = parameterType.getTypeArguments(); - typeArguments = expressionType.getIsSpecialized() ? expressionType.getTypeArguments() : expressionType.getTypeParameters(); - } - - if (typeParameters && typeArguments && typeParameters.length === typeArguments.length) { - for (var i = 0; i < typeParameters.length; i++) { - if (typeArguments[i] != typeParameters[i]) { - this.relateTypeToTypeParameters(typeArguments[i], typeParameters[i], true, argContext, enclosingDecl, context); - } - } - } - } - - var prevSpecializingToAny = context.specializingToAny; - context.specializingToAny = true; - - if (!this.sourceIsAssignableToTarget(expressionType, parameterType, context)) { - context.specializingToAny = prevSpecializingToAny; - return; - } - context.specializingToAny = prevSpecializingToAny; - - if (expressionType.isArray() && parameterType.isArray()) { - this.relateArrayTypeToTypeParameters(expressionType, parameterType, shouldFix, argContext, enclosingDecl, context); - - return; - } - - this.relateObjectTypeToTypeParameters(expressionType, parameterType, shouldFix, argContext, enclosingDecl, context); - }; - - PullTypeResolver.prototype.relateFunctionSignatureToTypeParameters = function (expressionSignature, parameterSignature, argContext, enclosingDecl, context) { - var expressionParams = expressionSignature.getParameters(); - var expressionReturnType = expressionSignature.getReturnType(); - - var parameterParams = parameterSignature.getParameters(); - var parameterReturnType = parameterSignature.getReturnType(); - - var len = parameterParams.length < expressionParams.length ? parameterParams.length : expressionParams.length; - - for (var i = 0; i < len; i++) { - this.relateTypeToTypeParameters(expressionParams[i].getType(), parameterParams[i].getType(), true, argContext, enclosingDecl, context); - } - - this.relateTypeToTypeParameters(expressionReturnType, parameterReturnType, false, argContext, enclosingDecl, context); - }; - - PullTypeResolver.prototype.relateObjectTypeToTypeParameters = function (objectType, parameterType, shouldFix, argContext, enclosingDecl, context) { - var parameterTypeMembers = parameterType.getMembers(); - var parameterSignatures; - var parameterSignature; - - var objectMember; - var objectSignatures; - - if (argContext.alreadyRelatingTypes(objectType, parameterType)) { - return; - } - - var objectTypeArguments = objectType.getTypeArguments(); - var parameterTypeParameters = parameterType.getTypeParameters(); - - if (objectTypeArguments && (objectTypeArguments.length === parameterTypeParameters.length)) { - for (var i = 0; i < objectTypeArguments.length; i++) { - argContext.addCandidateForInference(parameterTypeParameters[i], objectTypeArguments[i], shouldFix); - } - } - - for (var i = 0; i < parameterTypeMembers.length; i++) { - objectMember = this.getMemberSymbol(parameterTypeMembers[i].getName(), TypeScript.PullElementKind.SomeValue, objectType); - - if (objectMember) { - this.relateTypeToTypeParameters(objectMember.getType(), parameterTypeMembers[i].getType(), shouldFix, argContext, enclosingDecl, context); - } - } - - parameterSignatures = parameterType.getCallSignatures(); - objectSignatures = objectType.getCallSignatures(); - - for (var i = 0; i < parameterSignatures.length; i++) { - parameterSignature = parameterSignatures[i]; - - for (var j = 0; j < objectSignatures.length; j++) { - this.relateFunctionSignatureToTypeParameters(objectSignatures[j], parameterSignature, argContext, enclosingDecl, context); - } - } - - parameterSignatures = parameterType.getConstructSignatures(); - objectSignatures = objectType.getConstructSignatures(); - - for (var i = 0; i < parameterSignatures.length; i++) { - parameterSignature = parameterSignatures[i]; - - for (var j = 0; j < objectSignatures.length; j++) { - this.relateFunctionSignatureToTypeParameters(objectSignatures[j], parameterSignature, argContext, enclosingDecl, context); - } - } - - parameterSignatures = parameterType.getIndexSignatures(); - objectSignatures = objectType.getIndexSignatures(); - - for (var i = 0; i < parameterSignatures.length; i++) { - parameterSignature = parameterSignatures[i]; - - for (var j = 0; j < objectSignatures.length; j++) { - this.relateFunctionSignatureToTypeParameters(objectSignatures[j], parameterSignature, argContext, enclosingDecl, context); - } - } - }; - - PullTypeResolver.prototype.relateArrayTypeToTypeParameters = function (argArrayType, parameterArrayType, shouldFix, argContext, enclosingDecl, context) { - var argElement = argArrayType.getElementType(); - var paramElement = parameterArrayType.getElementType(); - - this.relateTypeToTypeParameters(argElement, paramElement, shouldFix, argContext, enclosingDecl, context); - }; - - PullTypeResolver.prototype.specializeTypeToAny = function (typeToSpecialize, enclosingDecl, context) { - var prevSpecialize = context.specializingToAny; - - context.specializingToAny = true; - - var rootType = TypeScript.getRootType(typeToSpecialize); - - var type = TypeScript.specializeType(rootType, [], this, enclosingDecl, context); - - context.specializingToAny = prevSpecialize; - - return type; - }; - - PullTypeResolver.prototype.specializeSignatureToAny = function (signatureToSpecialize, enclosingDecl, context) { - var typeParameters = signatureToSpecialize.getTypeParameters(); - var typeReplacementMap = {}; - var typeArguments = []; - - for (var i = 0; i < typeParameters.length; i++) { - typeArguments[i] = this.semanticInfoChain.anyTypeSymbol; - typeReplacementMap[typeParameters[i].getSymbolID().toString()] = typeArguments[i]; - } - if (!typeArguments.length) { - typeArguments[0] = this.semanticInfoChain.anyTypeSymbol; - } - - var prevSpecialize = context.specializingToAny; - - context.specializingToAny = true; - - var sig = TypeScript.specializeSignature(signatureToSpecialize, false, typeReplacementMap, typeArguments, this, enclosingDecl, context); - context.specializingToAny = prevSpecialize; - - return sig; - }; - return PullTypeResolver; - })(); - TypeScript.PullTypeResolver = PullTypeResolver; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var PullTypeResolver2 = (function () { - function PullTypeResolver2() { - } - return PullTypeResolver2; - })(); - TypeScript.PullTypeResolver2 = PullTypeResolver2; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var TypeComparisonInfo = (function () { - function TypeComparisonInfo(sourceComparisonInfo) { - this.onlyCaptureFirstError = false; - this.flags = 0 /* SuccessfulComparison */; - this.message = ""; - this.stringConstantVal = null; - this.indent = 1; - if (sourceComparisonInfo) { - this.flags = sourceComparisonInfo.flags; - this.onlyCaptureFirstError = sourceComparisonInfo.onlyCaptureFirstError; - this.stringConstantVal = sourceComparisonInfo.stringConstantVal; - this.indent = sourceComparisonInfo.indent + 1; - } - } - TypeComparisonInfo.prototype.addMessage = function (message) { - if (!this.onlyCaptureFirstError && this.message) { - this.message = TypeScript.getDiagnosticMessage(2 /* _0__NL__1_TB__2 */, [this.message, this.indent, message]); - } else { - this.message = TypeScript.getDiagnosticMessage(3 /* _0_TB__1 */, [this.indent, message]); - } - }; - - TypeComparisonInfo.prototype.setMessage = function (message) { - this.message = TypeScript.getDiagnosticMessage(3 /* _0_TB__1 */, [this.indent, message]); - }; - return TypeComparisonInfo; - })(); - TypeScript.TypeComparisonInfo = TypeComparisonInfo; - - var PullTypeCheckContext = (function () { - function PullTypeCheckContext(compiler, script, scriptName) { - this.compiler = compiler; - this.script = script; - this.scriptName = scriptName; - this.enclosingDeclStack = []; - this.enclosingDeclReturnStack = []; - this.semanticInfo = null; - this.inSuperConstructorCall = false; - this.inSuperConstructorTarget = false; - this.seenSuperConstructorCall = false; - this.inConstructorArguments = false; - this.inImportDeclaration = false; - } - PullTypeCheckContext.prototype.pushEnclosingDecl = function (decl) { - this.enclosingDeclStack[this.enclosingDeclStack.length] = decl; - this.enclosingDeclReturnStack[this.enclosingDeclReturnStack.length] = false; - }; - - PullTypeCheckContext.prototype.popEnclosingDecl = function () { - this.enclosingDeclStack.length--; - this.enclosingDeclReturnStack.length--; - }; - - PullTypeCheckContext.prototype.getEnclosingDecl = function (kind) { - if (typeof kind === "undefined") { kind = TypeScript.PullElementKind.All; } - for (var i = this.enclosingDeclStack.length - 1; i >= 0; i--) { - var decl = this.enclosingDeclStack[i]; - if (decl.getKind() & kind) { - return decl; - } - } - - return null; - }; - - PullTypeCheckContext.prototype.getEnclosingNonLambdaDecl = function () { - for (var i = this.enclosingDeclStack.length - 1; i >= 0; i--) { - var decl = this.enclosingDeclStack[i]; - if (!(decl.getKind() === 131072 /* FunctionExpression */ && (decl.getFlags() & 8192 /* FatArrow */))) { - return decl; - } - } - - return null; - }; - - PullTypeCheckContext.prototype.getEnclosingClassDecl = function () { - return this.getEnclosingDecl(8 /* Class */); - }; - - PullTypeCheckContext.prototype.getEnclosingDeclHasReturn = function () { - return this.enclosingDeclReturnStack[this.enclosingDeclReturnStack.length - 1]; - }; - - PullTypeCheckContext.prototype.setEnclosingDeclHasReturn = function () { - return this.enclosingDeclReturnStack[this.enclosingDeclReturnStack.length - 1] = true; - }; - return PullTypeCheckContext; - })(); - TypeScript.PullTypeCheckContext = PullTypeCheckContext; - - var PullTypeChecker = (function () { - function PullTypeChecker(compilationSettings, semanticInfoChain) { - this.compilationSettings = compilationSettings; - this.semanticInfoChain = semanticInfoChain; - this.resolver = null; - this.context = new TypeScript.PullTypeResolutionContext(); - } - PullTypeChecker.prototype.setUnit = function (unitPath) { - this.resolver = new TypeScript.PullTypeResolver(this.compilationSettings, this.semanticInfoChain, unitPath); - }; - - PullTypeChecker.prototype.getScriptDecl = function (fileName) { - return this.semanticInfoChain.getUnit(fileName).getTopLevelDecls()[0]; - }; - - PullTypeChecker.prototype.checkForResolutionError = function (typeSymbol, decl) { - if (typeSymbol && typeSymbol.isError()) { - decl.addDiagnostic((typeSymbol).getDiagnostic()); - } - }; - - PullTypeChecker.prototype.postError = function (offset, length, fileName, diagnosticCode, arguments, enclosingDecl) { - enclosingDecl.addDiagnostic(new TypeScript.SemanticDiagnostic(fileName, offset, length, diagnosticCode, arguments)); - }; - - PullTypeChecker.prototype.validateVariableDeclarationGroups = function (enclosingDecl, typeCheckContext) { - var declGroups = enclosingDecl.getVariableDeclGroups(); - var decl; - var firstSymbol; - var symbol; - var boundDeclAST; - - for (var i = 0; i < declGroups.length; i++) { - for (var j = 0; j < declGroups[i].length; j++) { - decl = declGroups[i][j]; - symbol = decl.getSymbol(); - boundDeclAST = this.semanticInfoChain.getASTForDecl(decl); - this.resolver.resolveAST(boundDeclAST, false, enclosingDecl, this.context); - if (!j) { - firstSymbol = decl.getSymbol(); - - if (this.resolver.isAnyOrEquivalent(this.resolver.widenType(firstSymbol.getType()))) { - return; - } - continue; - } - - if (!this.resolver.typesAreIdentical(symbol.getType(), firstSymbol.getType())) { - this.postError(boundDeclAST.minChar, boundDeclAST.getLength(), typeCheckContext.scriptName, 199 /* Subsequent_variable_declarations_must_have_the_same_type___Variable__0__must_be_of_type__1___but_here_has_type___2_ */, [symbol.getDisplayName(), firstSymbol.getType().toString(), symbol.getType().toString()], enclosingDecl); - } - } - } - }; - - PullTypeChecker.prototype.typeCheckAST = function (ast, typeCheckContext, inContextuallyTypedAssignment) { - if (!ast) { - return null; - } - - if (ast.typeCheckPhase >= PullTypeChecker.globalPullTypeCheckPhase) { - return null; - } else { - ast.typeCheckPhase = PullTypeChecker.globalPullTypeCheckPhase; - } - - switch (ast.nodeType) { - case 1 /* List */: - return this.typeCheckList(ast, typeCheckContext); - - case 17 /* VariableDeclarator */: - case 19 /* Parameter */: - return this.typeCheckBoundDecl(ast, typeCheckContext); - - case 12 /* FunctionDeclaration */: - return this.typeCheckFunction(ast, typeCheckContext, inContextuallyTypedAssignment); - - case 13 /* ClassDeclaration */: - return this.typeCheckClass(ast, typeCheckContext); - - case 14 /* InterfaceDeclaration */: - return this.typeCheckInterface(ast, typeCheckContext); - - case 15 /* ModuleDeclaration */: - return this.typeCheckModule(ast, typeCheckContext); - - case 9 /* TypeParameter */: - return this.typeCheckTypeParameter(ast, typeCheckContext); - - case 16 /* ImportDeclaration */: - return this.typeCheckImportDeclaration(ast, typeCheckContext); - - case 38 /* AssignmentExpression */: - return this.typeCheckAssignment(ast, typeCheckContext); - - case 10 /* GenericType */: - return this.typeCheckGenericType(ast, typeCheckContext); - - case 22 /* ObjectLiteralExpression */: - return this.typeCheckObjectLiteral(ast, typeCheckContext, inContextuallyTypedAssignment); - - case 21 /* ArrayLiteralExpression */: - return this.typeCheckArrayLiteral(ast, typeCheckContext, inContextuallyTypedAssignment); - - case 29 /* ThisExpression */: - return this.typeCheckThisExpression(ast, typeCheckContext); - - case 30 /* SuperExpression */: - return this.typeCheckSuperExpression(ast, typeCheckContext); - - case 36 /* InvocationExpression */: - return this.typeCheckCallExpression(ast, typeCheckContext); - - case 37 /* ObjectCreationExpression */: - return this.typeCheckObjectCreationExpression(ast, typeCheckContext); - - case 78 /* CastExpression */: - return this.typeCheckTypeAssertion(ast, typeCheckContext); - - case 11 /* TypeRef */: - return this.typeCheckTypeReference(ast, typeCheckContext); - - case 87 /* ExportAssignment */: - return this.typeCheckExportAssignment(ast, typeCheckContext); - - case 57 /* NotEqualsWithTypeConversionExpression */: - case 56 /* EqualsWithTypeConversionExpression */: - case 58 /* EqualsExpression */: - case 59 /* NotEqualsExpression */: - case 60 /* LessThanExpression */: - case 61 /* LessThanOrEqualExpression */: - case 63 /* GreaterThanOrEqualExpression */: - case 62 /* GreaterThanExpression */: - return this.typeCheckLogicalOperation(ast, typeCheckContext); - - case 25 /* CommaExpression */: - return this.typeCheckCommaExpression(ast, typeCheckContext); - - case 64 /* AddExpression */: - case 39 /* AddAssignmentExpression */: - return this.typeCheckBinaryAdditionOperation(ast, typeCheckContext); - - case 65 /* SubtractExpression */: - case 66 /* MultiplyExpression */: - case 67 /* DivideExpression */: - case 68 /* ModuloExpression */: - case 53 /* BitwiseOrExpression */: - case 55 /* BitwiseAndExpression */: - case 69 /* LeftShiftExpression */: - case 70 /* SignedRightShiftExpression */: - case 71 /* UnsignedRightShiftExpression */: - case 54 /* BitwiseExclusiveOrExpression */: - case 45 /* ExclusiveOrAssignmentExpression */: - case 47 /* LeftShiftAssignmentExpression */: - case 48 /* SignedRightShiftAssignmentExpression */: - case 49 /* UnsignedRightShiftAssignmentExpression */: - case 40 /* SubtractAssignmentExpression */: - case 42 /* MultiplyAssignmentExpression */: - case 41 /* DivideAssignmentExpression */: - case 43 /* ModuloAssignmentExpression */: - case 46 /* OrAssignmentExpression */: - case 44 /* AndAssignmentExpression */: - return this.typeCheckBinaryArithmeticOperation(ast, typeCheckContext); - - case 26 /* PlusExpression */: - case 27 /* NegateExpression */: - case 72 /* BitwiseNotExpression */: - case 76 /* PostIncrementExpression */: - case 74 /* PreIncrementExpression */: - case 77 /* PostDecrementExpression */: - case 75 /* PreDecrementExpression */: - return this.typeCheckUnaryArithmeticOperation(ast, typeCheckContext, inContextuallyTypedAssignment); - - case 35 /* ElementAccessExpression */: - return this.typeCheckElementAccessExpression(ast, typeCheckContext); - - case 73 /* LogicalNotExpression */: - return this.typeCheckLogicalNotExpression(ast, typeCheckContext, inContextuallyTypedAssignment); - - case 51 /* LogicalOrExpression */: - case 52 /* LogicalAndExpression */: - return this.typeCheckLogicalAndOrExpression(ast, typeCheckContext); - - case 34 /* TypeOfExpression */: - return this.typeCheckTypeOf(ast, typeCheckContext); - - case 50 /* ConditionalExpression */: - return this.typeCheckConditionalExpression(ast, typeCheckContext); - - case 24 /* VoidExpression */: - return this.typeCheckVoidExpression(ast, typeCheckContext); - - case 95 /* ThrowStatement */: - return this.typeCheckThrowStatement(ast, typeCheckContext); - - case 28 /* DeleteExpression */: - return this.typeCheckDeleteExpression(ast, typeCheckContext); - - case 6 /* RegularExpressionLiteral */: - return this.typeCheckRegExpExpression(ast, typeCheckContext); - - case 31 /* InExpression */: - return this.typeCheckInExpression(ast, typeCheckContext); - - case 33 /* InstanceOfExpression */: - return this.typeCheckInstanceOfExpression(ast, typeCheckContext); - - case 79 /* ParenthesizedExpression */: - return this.typeCheckParenthesizedExpression(ast, typeCheckContext); - - case 90 /* ForStatement */: - return this.typeCheckForStatement(ast, typeCheckContext); - - case 89 /* ForInStatement */: - return this.typeCheckForInStatement(ast, typeCheckContext); - - case 98 /* WhileStatement */: - return this.typeCheckWhileStatement(ast, typeCheckContext); - - case 85 /* DoStatement */: - return this.typeCheckDoStatement(ast, typeCheckContext); - - case 91 /* IfStatement */: - return this.typeCheckIfStatement(ast, typeCheckContext); - - case 81 /* Block */: - return this.typeCheckBlock(ast, typeCheckContext); - - case 18 /* VariableDeclaration */: - return this.typeCheckVariableDeclaration(ast, typeCheckContext); - - case 97 /* VariableStatement */: - return this.typeCheckVariableStatement(ast, typeCheckContext); - - case 99 /* WithStatement */: - return this.typeCheckWithStatement(ast, typeCheckContext); - - case 96 /* TryStatement */: - return this.typeCheckTryStatement(ast, typeCheckContext); - - case 101 /* CatchClause */: - return this.typeCheckCatchClause(ast, typeCheckContext); - - case 93 /* ReturnStatement */: - return this.typeCheckReturnStatement(ast, typeCheckContext); - - case 20 /* Name */: - return this.typeCheckNameExpression(ast, typeCheckContext); - - case 32 /* MemberAccessExpression */: - return this.typeCheckMemberAccessExpression(ast, typeCheckContext); - - case 94 /* SwitchStatement */: - return this.typeCheckSwitchStatement(ast, typeCheckContext); - - case 88 /* ExpressionStatement */: - return this.typeCheckExpressionStatement(ast, typeCheckContext, inContextuallyTypedAssignment); - - case 100 /* CaseClause */: - return this.typeCheckCaseClause(ast, typeCheckContext); - - case 92 /* LabeledStatement */: - return this.typeCheckLabeledStatement(ast, typeCheckContext); - - case 7 /* NumericLiteral */: - return this.semanticInfoChain.numberTypeSymbol; - - case 5 /* StringLiteral */: - return this.semanticInfoChain.stringTypeSymbol; - - case 8 /* NullLiteral */: - return this.semanticInfoChain.nullTypeSymbol; - - case 3 /* TrueLiteral */: - case 4 /* FalseLiteral */: - return this.semanticInfoChain.booleanTypeSymbol; - - case 9 /* TypeParameter */: - return this.typeCheckTypeParameter(ast, typeCheckContext); - - default: - break; - } - - return null; - }; - - PullTypeChecker.prototype.typeCheckScript = function (script, scriptName, compiler) { - var unit = this.semanticInfoChain.getUnit(scriptName); - - if (unit.getTypeChecked()) { - return; - } - - var typeCheckContext = new PullTypeCheckContext(compiler, script, scriptName); - - this.setUnit(scriptName); - - typeCheckContext.semanticInfo = typeCheckContext.compiler.semanticInfoChain.getUnit(typeCheckContext.scriptName); - var scriptDecl = typeCheckContext.semanticInfo.getTopLevelDecls()[0]; - typeCheckContext.pushEnclosingDecl(scriptDecl); - - PullTypeChecker.globalPullTypeCheckPhase++; - - this.typeCheckAST(script.moduleElements, typeCheckContext, false); - - this.validateVariableDeclarationGroups(scriptDecl, typeCheckContext); - - typeCheckContext.popEnclosingDecl(); - - unit.setTypeChecked(); - }; - - PullTypeChecker.prototype.typeCheckList = function (list, typeCheckContext) { - if (!list) { - return null; - } - - for (var i = 0; i < list.members.length; i++) { - this.typeCheckAST(list.members[i], typeCheckContext, false); - } - }; - - PullTypeChecker.prototype.reportDiagnostics = function (symbolAndDiagnostics, enclosingDecl) { - if (symbolAndDiagnostics && symbolAndDiagnostics.diagnostics) { - for (var i = 0, n = symbolAndDiagnostics.diagnostics.length; i < n; i++) { - this.context.postDiagnostic(symbolAndDiagnostics.diagnostics[i], enclosingDecl, true); - } - } - }; - - PullTypeChecker.prototype.resolveSymbolAndReportDiagnostics = function (ast, inContextuallyTypedAssignment, enclosingDecl) { - var symbolAndDiagnostics = this.resolver.resolveAST(ast, inContextuallyTypedAssignment, enclosingDecl, this.context); - - this.reportDiagnostics(symbolAndDiagnostics, enclosingDecl); - return symbolAndDiagnostics && symbolAndDiagnostics.symbol; - }; - - PullTypeChecker.prototype.typeCheckBoundDecl = function (ast, typeCheckContext) { - var _this = this; - var boundDeclAST = ast; - - var enclosingDecl = typeCheckContext.getEnclosingDecl(); - - var typeExprSymbol = null; - - if (boundDeclAST.typeExpr) { - typeExprSymbol = this.typeCheckAST(boundDeclAST.typeExpr, typeCheckContext, false); - - if (typeExprSymbol.isNamedTypeSymbol() && typeExprSymbol.isGeneric() && !typeExprSymbol.isTypeParameter() && !this.resolver.isArrayOrEquivalent(typeExprSymbol) && typeExprSymbol.isResolved() && typeExprSymbol.getTypeParameters().length && typeExprSymbol.getTypeArguments() == null && !typeExprSymbol.getIsSpecialized() && this.resolver.isTypeRefWithoutTypeArgs(boundDeclAST.typeExpr)) { - this.postError(boundDeclAST.typeExpr.minChar, boundDeclAST.typeExpr.getLength(), typeCheckContext.scriptName, 239 /* Generic_type_references_must_include_all_type_arguments */, null, enclosingDecl); - typeExprSymbol = this.resolver.specializeTypeToAny(typeExprSymbol, enclosingDecl, this.context); - } - } - - if (boundDeclAST.init) { - if (typeExprSymbol) { - this.context.pushContextualType(typeExprSymbol, this.context.inProvisionalResolution(), null); - } - - var initTypeSymbol = this.typeCheckAST(boundDeclAST.init, typeCheckContext, !!typeExprSymbol); - - if (typeExprSymbol) { - this.context.popContextualType(); - } - - if (typeExprSymbol && typeExprSymbol.isContainer()) { - var exportedTypeSymbol = (typeExprSymbol).getExportAssignedTypeSymbol(); - - if (exportedTypeSymbol) { - typeExprSymbol = exportedTypeSymbol; - } else { - var instanceTypeSymbol = (typeExprSymbol.getType()).getInstanceSymbol().getType(); - - if (!instanceTypeSymbol || !TypeScript.PullHelpers.symbolIsEnum(instanceTypeSymbol)) { - this.postError(boundDeclAST.minChar, boundDeclAST.getLength(), typeCheckContext.scriptName, 190 /* Tried_to_set_variable_type_to_module_type__0__ */, [typeExprSymbol.toString()], enclosingDecl); - typeExprSymbol = null; - } else { - typeExprSymbol = instanceTypeSymbol.getType(); - } - } - } - - if (initTypeSymbol && initTypeSymbol.isContainer()) { - instanceTypeSymbol = (initTypeSymbol.getType()).getInstanceSymbol().getType(); - - if (!instanceTypeSymbol) { - this.postError(boundDeclAST.minChar, boundDeclAST.getLength(), typeCheckContext.scriptName, 191 /* Tried_to_set_variable_type_to_uninitialized_module_type__0__ */, [initTypeSymbol.toString()], enclosingDecl); - initTypeSymbol = null; - } else { - initTypeSymbol = instanceTypeSymbol.getType(); - } - } - - if (initTypeSymbol && typeExprSymbol) { - var comparisonInfo = new TypeComparisonInfo(); - - var isAssignable = this.resolver.sourceIsAssignableToTarget(initTypeSymbol, typeExprSymbol, this.context, comparisonInfo); - - if (!isAssignable) { - if (comparisonInfo.message) { - this.postError(boundDeclAST.minChar, boundDeclAST.getLength(), typeCheckContext.scriptName, 81 /* Cannot_convert__0__to__1__NL__2 */, [initTypeSymbol.toString(), typeExprSymbol.toString(), comparisonInfo.message], enclosingDecl); - } else { - this.postError(boundDeclAST.minChar, boundDeclAST.getLength(), typeCheckContext.scriptName, 80 /* Cannot_convert__0__to__1_ */, [initTypeSymbol.toString(), typeExprSymbol.toString()], enclosingDecl); - } - } - } - } - - var prevSupressErrors = this.context.suppressErrors; - this.context.suppressErrors = true; - var decl = this.resolver.getDeclForAST(boundDeclAST); - - var varTypeSymbol = this.resolveSymbolAndReportDiagnostics(boundDeclAST, false, enclosingDecl).getType(); - - if (typeExprSymbol && typeExprSymbol.isContainer() && varTypeSymbol.isError()) { - this.checkForResolutionError(varTypeSymbol, decl); - } - - this.context.suppressErrors = prevSupressErrors; - - var declSymbol = decl.getSymbol(); - - if (declSymbol.getKind() != 2048 /* Parameter */ && (declSymbol.getKind() != 4096 /* Property */ || declSymbol.getContainer().isNamedTypeSymbol())) { - this.checkTypePrivacy(declSymbol, varTypeSymbol, typeCheckContext, function (typeSymbol) { - return _this.variablePrivacyErrorReporter(declSymbol, typeSymbol, typeCheckContext); - }); - } - - return varTypeSymbol; - }; - - PullTypeChecker.prototype.typeCheckImportDeclaration = function (importDeclaration, typeCheckContext) { - var result = this.resolveSymbolAndReportDiagnostics(importDeclaration, false, typeCheckContext.getEnclosingDecl()); - - var savedInImportDeclaration = typeCheckContext.inImportDeclaration; - typeCheckContext.inImportDeclaration = true; - this.typeCheckAST(importDeclaration.alias, typeCheckContext, false); - typeCheckContext.inImportDeclaration = savedInImportDeclaration; - - return result; - }; - - PullTypeChecker.prototype.typeCheckFunction = function (funcDeclAST, typeCheckContext, inContextuallyTypedAssignment) { - if (funcDeclAST.isConstructor || TypeScript.hasFlag(funcDeclAST.getFunctionFlags(), 1024 /* ConstructMember */)) { - return this.typeCheckConstructor(funcDeclAST, typeCheckContext, inContextuallyTypedAssignment); - } else if (TypeScript.hasFlag(funcDeclAST.getFunctionFlags(), 4096 /* IndexerMember */)) { - return this.typeCheckIndexer(funcDeclAST, typeCheckContext, inContextuallyTypedAssignment); - } else if (funcDeclAST.isAccessor()) { - return this.typeCheckAccessor(funcDeclAST, typeCheckContext, inContextuallyTypedAssignment); - } - - var enclosingDecl = typeCheckContext.getEnclosingDecl(); - - var functionSymbol = this.resolveSymbolAndReportDiagnostics(funcDeclAST, inContextuallyTypedAssignment, enclosingDecl); - var functionDecl = typeCheckContext.semanticInfo.getDeclForAST(funcDeclAST); - - typeCheckContext.pushEnclosingDecl(functionDecl); - - this.typeCheckAST(funcDeclAST.typeArguments, typeCheckContext, inContextuallyTypedAssignment); - this.typeCheckAST(funcDeclAST.arguments, typeCheckContext, inContextuallyTypedAssignment); - this.typeCheckAST(funcDeclAST.returnTypeAnnotation, typeCheckContext, false); - this.typeCheckAST(funcDeclAST.block, typeCheckContext, false); - - var hasReturn = typeCheckContext.getEnclosingDeclHasReturn(); - - this.validateVariableDeclarationGroups(functionDecl, typeCheckContext); - - typeCheckContext.popEnclosingDecl(); - - var functionSignature = functionDecl.getSignatureSymbol(); - - var parameters = functionSignature.getParameters(); - - if (parameters.length) { - for (var i = 0; i < parameters.length; i++) { - this.checkForResolutionError(parameters[i].getType(), enclosingDecl); - } - } - - var returnType = functionSignature.getReturnType(); - - this.checkForResolutionError(returnType, enclosingDecl); - - if (funcDeclAST.block && funcDeclAST.returnTypeAnnotation != null && !hasReturn) { - var isVoidOrAny = this.resolver.isAnyOrEquivalent(returnType) || returnType === this.semanticInfoChain.voidTypeSymbol; - - if (!isVoidOrAny && !(funcDeclAST.block.statements.members.length > 0 && funcDeclAST.block.statements.members[0].nodeType === 95 /* ThrowStatement */)) { - var funcName = functionDecl.getDisplayName(); - funcName = funcName ? "'" + funcName + "'" : "expression"; - - this.postError(funcDeclAST.returnTypeAnnotation.minChar, funcDeclAST.returnTypeAnnotation.getLength(), typeCheckContext.scriptName, 192 /* Function__0__declared_a_non_void_return_type__but_has_no_return_expression */, [funcName], typeCheckContext.getEnclosingDecl()); - } - } - - this.typeCheckFunctionOverloads(funcDeclAST, typeCheckContext); - this.checkFunctionTypePrivacy(funcDeclAST, inContextuallyTypedAssignment, typeCheckContext); - - return functionSymbol ? functionSymbol.getType() : null; - }; - - PullTypeChecker.prototype.typeCheckFunctionOverloads = function (funcDecl, typeCheckContext, signature, allSignatures) { - if (!signature) { - var functionSignatureInfo = TypeScript.PullHelpers.getSignatureForFuncDecl(funcDecl, typeCheckContext.semanticInfo); - signature = functionSignatureInfo.signature; - allSignatures = functionSignatureInfo.allSignatures; - } - var functionDeclaration = typeCheckContext.semanticInfo.getDeclForAST(funcDecl); - var funcSymbol = functionDeclaration.getSymbol(); - - var definitionSignature = null; - for (var i = allSignatures.length - 1; i >= 0; i--) { - if (allSignatures[i].isDefinition()) { - definitionSignature = allSignatures[i]; - break; - } - } - - if (!signature.isDefinition()) { - for (var i = 0; i < allSignatures.length; i++) { - if (allSignatures[i] === signature) { - break; - } - - if (this.resolver.signaturesAreIdentical(allSignatures[i], signature)) { - if (funcDecl.isConstructor) { - this.postError(funcDecl.minChar, funcDecl.getLength(), typeCheckContext.scriptName, 210 /* Duplicate_constructor_overload_signature */, null, typeCheckContext.getEnclosingDecl()); - } else if (funcDecl.isConstructMember()) { - this.postError(funcDecl.minChar, funcDecl.getLength(), typeCheckContext.scriptName, 212 /* Duplicate_overload_construct_signature */, null, typeCheckContext.getEnclosingDecl()); - } else if (funcDecl.isCallMember()) { - this.postError(funcDecl.minChar, funcDecl.getLength(), typeCheckContext.scriptName, 211 /* Duplicate_overload_call_signature */, null, typeCheckContext.getEnclosingDecl()); - } else { - this.postError(funcDecl.minChar, funcDecl.getLength(), typeCheckContext.scriptName, 209 /* Duplicate_overload_signature_for__0_ */, [funcSymbol.getScopedNameEx().toString()], typeCheckContext.getEnclosingDecl()); - } - - break; - } - } - } - - var isConstantOverloadSignature = signature.isStringConstantOverloadSignature(); - if (isConstantOverloadSignature) { - if (signature.isDefinition()) { - this.postError(funcDecl.minChar, funcDecl.getLength(), typeCheckContext.scriptName, 229 /* Overload_signature_implementation_cannot_use_specialized_type */, null, typeCheckContext.getEnclosingDecl()); - } else { - var resolutionContext = new TypeScript.PullTypeResolutionContext(); - var foundSubtypeSignature = false; - for (var i = 0; i < allSignatures.length; i++) { - if (allSignatures[i].isDefinition() || allSignatures[i] === signature) { - continue; - } - - if (!allSignatures[i].isResolved()) { - this.resolver.resolveDeclaredSymbol(allSignatures[i], typeCheckContext.getEnclosingDecl(), resolutionContext); - } - - if (allSignatures[i].isStringConstantOverloadSignature()) { - continue; - } - - if (this.resolver.signatureIsSubtypeOfTarget(signature, allSignatures[i], resolutionContext)) { - foundSubtypeSignature = true; - break; - } - } - - if (!foundSubtypeSignature) { - this.postError(funcDecl.minChar, funcDecl.getLength(), typeCheckContext.scriptName, 219 /* Specialized_overload_signature_is_not_subtype_of_any_non_specialized_signature */, null, typeCheckContext.getEnclosingDecl()); - } - } - } else if (definitionSignature && definitionSignature != signature) { - var comparisonInfo = new TypeComparisonInfo(); - var resolutionContext = new TypeScript.PullTypeResolutionContext(); - if (!definitionSignature.isResolved()) { - this.resolver.resolveDeclaredSymbol(definitionSignature, typeCheckContext.getEnclosingDecl(), resolutionContext); - } - - if (!this.resolver.signatureIsAssignableToTarget(definitionSignature, signature, resolutionContext, comparisonInfo)) { - if (comparisonInfo.message) { - this.postError(funcDecl.minChar, funcDecl.getLength(), typeCheckContext.scriptName, 214 /* Overload_signature_is_not_compatible_with_function_definition__NL__0 */, [comparisonInfo.message], typeCheckContext.getEnclosingDecl()); - } else { - this.postError(funcDecl.minChar, funcDecl.getLength(), typeCheckContext.scriptName, 213 /* Overload_signature_is_not_compatible_with_function_definition */, null, typeCheckContext.getEnclosingDecl()); - } - } - } - - var signatureForVisibilityCheck = definitionSignature; - if (!definitionSignature) { - if (allSignatures[0] === signature) { - return; - } - signatureForVisibilityCheck = allSignatures[0]; - } - - if (!funcDecl.isConstructor && !funcDecl.isConstructMember() && signature != signatureForVisibilityCheck) { - var errorCode; - - if (signatureForVisibilityCheck.hasFlag(2 /* Private */) != signature.hasFlag(2 /* Private */)) { - errorCode = 215 /* Overload_signatures_must_all_be_public_or_private */; - } else if (signatureForVisibilityCheck.hasFlag(1 /* Exported */) != signature.hasFlag(1 /* Exported */)) { - errorCode = 216 /* Overload_signatures_must_all_be_exported_or_local */; - } else if (signatureForVisibilityCheck.hasFlag(8 /* Ambient */) != signature.hasFlag(8 /* Ambient */)) { - errorCode = 217 /* Overload_signatures_must_all_be_ambient_or_non_ambient */; - } else if (signatureForVisibilityCheck.hasFlag(128 /* Optional */) != signature.hasFlag(128 /* Optional */)) { - errorCode = 218 /* Overload_signatures_must_all_be_optional_or_required */; - } - - if (errorCode) { - this.postError(funcDecl.minChar, funcDecl.getLength(), typeCheckContext.scriptName, errorCode, null, typeCheckContext.getEnclosingDecl()); - } - } - }; - - PullTypeChecker.prototype.typeCheckTypeParameter = function (typeParameter, typeCheckContext) { - if (typeParameter.constraint) { - var constraintType = this.typeCheckAST(typeParameter.constraint, typeCheckContext, false); - - if (constraintType && !constraintType.isError() && constraintType.isPrimitive()) { - this.postError(typeParameter.constraint.minChar, typeParameter.constraint.getLength(), typeCheckContext.scriptName, 149 /* Type_parameter_constraint_cannot_be_a_primitive_type */, null, typeCheckContext.getEnclosingDecl()); - } - } - - return this.resolveSymbolAndReportDiagnostics(typeParameter, false, typeCheckContext.getEnclosingDecl()); - }; - - PullTypeChecker.prototype.typeCheckAccessor = function (ast, typeCheckContext, inContextuallyTypedAssignment) { - var funcDeclAST = ast; - - var enclosingDecl = typeCheckContext.getEnclosingDecl(); - - var accessorSymbol = this.resolveSymbolAndReportDiagnostics(ast, inContextuallyTypedAssignment, enclosingDecl); - this.checkForResolutionError(accessorSymbol.getType(), enclosingDecl); - - var isGetter = TypeScript.hasFlag(funcDeclAST.getFunctionFlags(), 32 /* GetAccessor */); - var isSetter = !isGetter; - - var getter = accessorSymbol.getGetter(); - var setter = accessorSymbol.getSetter(); - - var functionDecl = typeCheckContext.semanticInfo.getDeclForAST(funcDeclAST); - typeCheckContext.pushEnclosingDecl(functionDecl); - - this.typeCheckAST(funcDeclAST.arguments, typeCheckContext, inContextuallyTypedAssignment); - - this.typeCheckAST(funcDeclAST.block, typeCheckContext, false); - - var hasReturn = typeCheckContext.getEnclosingDeclHasReturn(); - - this.validateVariableDeclarationGroups(functionDecl, typeCheckContext); - - typeCheckContext.popEnclosingDecl(); - - var functionSignature = functionDecl.getSignatureSymbol(); - - var parameters = functionSignature.getParameters(); - - var returnType = functionSignature.getReturnType(); - - this.checkForResolutionError(returnType, enclosingDecl); - - var funcNameAST = funcDeclAST.name; - - if (isGetter && !hasReturn) { - if (!(funcDeclAST.block.statements.members.length > 0 && funcDeclAST.block.statements.members[0].nodeType === 95 /* ThrowStatement */)) { - this.postError(funcNameAST.minChar, funcNameAST.getLength(), typeCheckContext.scriptName, 193 /* Getters_must_return_a_value */, null, typeCheckContext.getEnclosingDecl()); - } - } - - if (getter && setter) { - var getterDecl = getter.getDeclarations()[0]; - var setterDecl = setter.getDeclarations()[0]; - - var getterIsPrivate = getterDecl.getFlags() & 2 /* Private */; - var setterIsPrivate = setterDecl.getFlags() & 2 /* Private */; - - if (getterIsPrivate != setterIsPrivate) { - this.postError(funcNameAST.minChar, funcNameAST.getLength(), typeCheckContext.scriptName, 194 /* Getter_and_setter_accessors_do_not_agree_in_visibility */, null, typeCheckContext.getEnclosingDecl()); - } - } - - this.checkFunctionTypePrivacy(funcDeclAST, inContextuallyTypedAssignment, typeCheckContext); - - return null; - }; - - PullTypeChecker.prototype.typeCheckConstructor = function (funcDeclAST, typeCheckContext, inContextuallyTypedAssignment) { - var enclosingDecl = typeCheckContext.getEnclosingDecl(); - - var functionSymbol = this.resolveSymbolAndReportDiagnostics(funcDeclAST, inContextuallyTypedAssignment, enclosingDecl); - - var functionDecl = typeCheckContext.semanticInfo.getDeclForAST(funcDeclAST); - typeCheckContext.pushEnclosingDecl(functionDecl); - - this.typeCheckAST(funcDeclAST.typeArguments, typeCheckContext, inContextuallyTypedAssignment); - - typeCheckContext.inConstructorArguments = true; - this.typeCheckAST(funcDeclAST.arguments, typeCheckContext, inContextuallyTypedAssignment); - typeCheckContext.inConstructorArguments = false; - - typeCheckContext.seenSuperConstructorCall = false; - - this.typeCheckAST(funcDeclAST.returnTypeAnnotation, typeCheckContext, false); - - this.typeCheckAST(funcDeclAST.block, typeCheckContext, false); - - this.validateVariableDeclarationGroups(functionDecl, typeCheckContext); - - typeCheckContext.popEnclosingDecl(); - - var constructorSignature = functionDecl.getSignatureSymbol(); - - var parameters = constructorSignature.getParameters(); - - if (parameters.length) { - for (var i = 0, n = parameters.length; i < n; i++) { - this.checkForResolutionError(parameters[i].getType(), enclosingDecl); - } - } - - this.checkForResolutionError(constructorSignature.getReturnType(), enclosingDecl); - - if (functionDecl.getSignatureSymbol() && functionDecl.getSignatureSymbol().isDefinition() && this.enclosingClassIsDerived(typeCheckContext)) { - if (!typeCheckContext.seenSuperConstructorCall) { - this.postError(funcDeclAST.minChar, 11, typeCheckContext.scriptName, 173 /* Constructors_for_derived_classes_must_contain_a__super__call */, null, enclosingDecl); - } else if (this.superCallMustBeFirstStatementInConstructor(functionDecl, enclosingDecl)) { - var firstStatement = this.getFirstStatementFromFunctionDeclAST(funcDeclAST); - if (!firstStatement || !this.isSuperCallNode(firstStatement)) { - this.postError(funcDeclAST.minChar, 11, typeCheckContext.scriptName, 172 /* A__super__call_must_be_the_first_statement_in_the_constructor_when_a_class_contains_intialized_properties_or_has_parameter_properties */, null, enclosingDecl); - } - } - } - - this.typeCheckFunctionOverloads(funcDeclAST, typeCheckContext); - this.checkFunctionTypePrivacy(funcDeclAST, inContextuallyTypedAssignment, typeCheckContext); - return functionSymbol ? functionSymbol.getType() : null; - }; - - PullTypeChecker.prototype.typeCheckIndexer = function (ast, typeCheckContext, inContextuallyTypedAssignment) { - var enclosingDecl = typeCheckContext.getEnclosingDecl(); - - this.resolver.resolveAST(ast, inContextuallyTypedAssignment, enclosingDecl, this.context); - - var funcDeclAST = ast; - - var functionDecl = typeCheckContext.semanticInfo.getDeclForAST(funcDeclAST); - typeCheckContext.pushEnclosingDecl(functionDecl); - - this.typeCheckAST(funcDeclAST.arguments, typeCheckContext, false); - - this.typeCheckAST(funcDeclAST.returnTypeAnnotation, typeCheckContext, false); - - typeCheckContext.popEnclosingDecl(); - - var indexSignature = functionDecl.getSignatureSymbol(); - var parameters = indexSignature.getParameters(); - - if (parameters.length) { - var parameterType = null; - - for (var i = 0; i < parameters.length; i++) { - this.checkForResolutionError(parameters[i].getType(), enclosingDecl); - } - } - - this.checkForResolutionError(indexSignature.getReturnType(), enclosingDecl); - this.checkFunctionTypePrivacy(funcDeclAST, inContextuallyTypedAssignment, typeCheckContext); - - var isNumericIndexer = parameters[0].getType() === this.semanticInfoChain.numberTypeSymbol; - - var allIndexSignatures = enclosingDecl.getSymbol().getType().getIndexSignatures(); - for (var i = 0; i < allIndexSignatures.length; i++) { - if (!allIndexSignatures[i].isResolved()) { - this.resolver.resolveDeclaredSymbol(allIndexSignatures[i], allIndexSignatures[i].getDeclarations()[0].getParentDecl(), this.context); - } - if (allIndexSignatures[i].getParameters()[0].getType() !== parameters[0].getType()) { - var stringIndexSignature; - var numberIndexSignature; - if (isNumericIndexer) { - numberIndexSignature = indexSignature; - stringIndexSignature = allIndexSignatures[i]; - } else { - numberIndexSignature = allIndexSignatures[i]; - stringIndexSignature = indexSignature; - - if (enclosingDecl.getSymbol() === numberIndexSignature.getDeclarations()[0].getParentDecl().getSymbol()) { - break; - } - } - var comparisonInfo = new TypeComparisonInfo(); - var resolutionContext = new TypeScript.PullTypeResolutionContext(); - if (!this.resolver.sourceIsSubtypeOfTarget(numberIndexSignature.getReturnType(), stringIndexSignature.getReturnType(), resolutionContext, comparisonInfo)) { - if (comparisonInfo.message) { - this.postError(funcDeclAST.minChar, funcDeclAST.getLength(), typeCheckContext.scriptName, 234 /* Numeric_indexer_type___0___must_be_a_subtype_of_string_indexer_type___1____NL__2 */, [numberIndexSignature.getReturnType().toString(), stringIndexSignature.getReturnType().toString(), comparisonInfo.message], typeCheckContext.getEnclosingDecl()); - } else { - this.postError(funcDeclAST.minChar, funcDeclAST.getLength(), typeCheckContext.scriptName, 233 /* Numeric_indexer_type___0___must_be_a_subtype_of_string_indexer_type___1__ */, [numberIndexSignature.getReturnType().toString(), stringIndexSignature.getReturnType().toString()], typeCheckContext.getEnclosingDecl()); - } - } - break; - } - } - - var allMembers = enclosingDecl.getSymbol().getType().getAllMembers(TypeScript.PullElementKind.All, true); - for (var i = 0; i < allMembers.length; i++) { - var name = allMembers[i].getName(); - if (name) { - if (!allMembers[i].isResolved()) { - this.resolver.resolveDeclaredSymbol(allMembers[i], allMembers[i].getDeclarations()[0].getParentDecl(), this.context); - } - - if (enclosingDecl.getSymbol() !== allMembers[i].getContainer()) { - var isMemberNumeric = isFinite(+name); - if (isNumericIndexer === isMemberNumeric) { - this.checkThatMemberIsSubtypeOfIndexer(allMembers[i], indexSignature, funcDeclAST, typeCheckContext, isNumericIndexer); - } - } - } - } - - return null; - }; - - PullTypeChecker.prototype.typeCheckMembersAgainstIndexer = function (containerType, typeCheckContext) { - var indexSignatures = containerType.getIndexSignatures(); - if (indexSignatures.length > 0) { - var members = typeCheckContext.getEnclosingDecl().getChildDecls(); - for (var i = 0; i < members.length; i++) { - var member = members[i]; - if (!member.getName() || member.getKind() & TypeScript.PullElementKind.SomeSignature) { - continue; - } - - var isMemberNumeric = isFinite(+member.getName()); - for (var j = 0; j < indexSignatures.length; j++) { - if (!indexSignatures[j].isResolved()) { - this.resolver.resolveDeclaredSymbol(indexSignatures[j], indexSignatures[j].getDeclarations()[0].getParentDecl(), this.context); - } - if ((indexSignatures[j].getParameters()[0].getType() === this.semanticInfoChain.numberTypeSymbol) === isMemberNumeric) { - this.checkThatMemberIsSubtypeOfIndexer(member.getSymbol(), indexSignatures[j], this.semanticInfoChain.getASTForDecl(member), typeCheckContext, isMemberNumeric); - break; - } - } - } - } - }; - - PullTypeChecker.prototype.checkThatMemberIsSubtypeOfIndexer = function (member, indexSignature, astForError, typeCheckContext, isNumeric) { - var comparisonInfo = new TypeComparisonInfo(); - var resolutionContext = new TypeScript.PullTypeResolutionContext(); - if (!this.resolver.sourceIsSubtypeOfTarget(member.getType(), indexSignature.getReturnType(), resolutionContext, comparisonInfo)) { - if (isNumeric) { - if (comparisonInfo.message) { - this.postError(astForError.minChar, astForError.getLength(), typeCheckContext.scriptName, 236 /* All_numerically_named_properties_must_be_subtypes_of_numeric_indexer_type___0____NL__1 */, [indexSignature.getReturnType().toString(), comparisonInfo.message], typeCheckContext.getEnclosingDecl()); - } else { - this.postError(astForError.minChar, astForError.getLength(), typeCheckContext.scriptName, 235 /* All_numerically_named_properties_must_be_subtypes_of_numeric_indexer_type___0__ */, [indexSignature.getReturnType().toString()], typeCheckContext.getEnclosingDecl()); - } - } else { - if (comparisonInfo.message) { - this.postError(astForError.minChar, astForError.getLength(), typeCheckContext.scriptName, 238 /* All_named_properties_must_be_subtypes_of_string_indexer_type___0____NL__1 */, [indexSignature.getReturnType().toString(), comparisonInfo.message], typeCheckContext.getEnclosingDecl()); - } else { - this.postError(astForError.minChar, astForError.getLength(), typeCheckContext.scriptName, 237 /* All_named_properties_must_be_subtypes_of_string_indexer_type___0__ */, [indexSignature.getReturnType().toString()], typeCheckContext.getEnclosingDecl()); - } - } - } - }; - - PullTypeChecker.prototype.typeCheckIfTypeMemberPropertyOkToOverride = function (typeSymbol, extendedType, typeMember, extendedTypeMember, comparisonInfo) { - if (!typeSymbol.isClass()) { - return true; - } - - var typeMemberKind = typeMember.getKind(); - var extendedMemberKind = extendedTypeMember.getKind(); - - if (typeMemberKind === extendedMemberKind) { - return true; - } - - var errorCode; - if (typeMemberKind === 4096 /* Property */) { - if (typeMember.isAccessor()) { - errorCode = 256 /* Class__0__defines_instance_member_accessor__1___but_extended_class__2__defines_it_as_instance_member_function */; - } else { - errorCode = 257 /* Class__0__defines_instance_member_property__1___but_extended_class__2__defines_it_as_instance_member_function */; - } - } else if (typeMemberKind === 65536 /* Method */) { - if (extendedTypeMember.isAccessor()) { - errorCode = 258 /* Class__0__defines_instance_member_function__1___but_extended_class__2__defines_it_as_instance_member_accessor */; - } else { - errorCode = 259 /* Class__0__defines_instance_member_function__1___but_extended_class__2__defines_it_as_instance_member_property */; - } - } - - var message = TypeScript.getDiagnosticMessage(errorCode, [typeSymbol.toString(), typeMember.getScopedNameEx().toString(), extendedType.toString()]); - comparisonInfo.addMessage(message); - return false; - }; - - PullTypeChecker.prototype.typeCheckIfTypeExtendsType = function (typeDecl, typeSymbol, extendedType, typeCheckContext) { - var typeMembers = typeSymbol.getMembers(); - - var resolutionContext = new TypeScript.PullTypeResolutionContext(); - var comparisonInfo = new TypeComparisonInfo(); - var foundError = false; - - for (var i = 0; i < typeMembers.length; i++) { - var propName = typeMembers[i].getName(); - var extendedTypeProp = extendedType.findMember(propName); - if (extendedTypeProp) { - foundError = !this.typeCheckIfTypeMemberPropertyOkToOverride(typeSymbol, extendedType, typeMembers[i], extendedTypeProp, comparisonInfo); - - if (!foundError) { - foundError = !this.resolver.sourcePropertyIsSubtypeOfTargetProperty(typeSymbol, extendedType, typeMembers[i], extendedTypeProp, resolutionContext, comparisonInfo); - } - - if (foundError) { - break; - } - } - } - - if (!foundError && typeSymbol.hasOwnCallSignatures()) { - foundError = !this.resolver.sourceCallSignaturesAreSubtypeOfTargetCallSignatures(typeSymbol, extendedType, resolutionContext, comparisonInfo); - } - - if (!foundError && typeSymbol.hasOwnConstructSignatures()) { - foundError = !this.resolver.sourceConstructSignaturesAreSubtypeOfTargetConstructSignatures(typeSymbol, extendedType, resolutionContext, comparisonInfo); - } - - if (!foundError && typeSymbol.hasOwnIndexSignatures()) { - foundError = !this.resolver.sourceIndexSignaturesAreSubtypeOfTargetIndexSignatures(typeSymbol, extendedType, resolutionContext, comparisonInfo); - } - - if (!foundError && typeSymbol.isClass()) { - var typeConstructorType = (typeSymbol).getConstructorMethod().getType(); - var typeConstructorTypeMembers = typeConstructorType.getMembers(); - if (typeConstructorTypeMembers.length) { - var extendedConstructorType = (extendedType).getConstructorMethod().getType(); - var comparisonInfoForPropTypeCheck = new TypeComparisonInfo(comparisonInfo); - - for (var i = 0; i < typeConstructorTypeMembers.length; i++) { - var propName = typeConstructorTypeMembers[i].getName(); - var extendedConstructorTypeProp = extendedConstructorType.findMember(propName); - if (extendedConstructorTypeProp) { - if (!extendedConstructorTypeProp.isResolved()) { - var extendedClassAst = typeCheckContext.semanticInfo.getASTForSymbol(extendedType); - var extendedClassDecl = typeCheckContext.semanticInfo.getDeclForAST(extendedClassAst); - this.resolver.resolveDeclaredSymbol(extendedConstructorTypeProp, extendedClassDecl, resolutionContext); - } - - var typeConstructorTypePropType = typeConstructorTypeMembers[i].getType(); - var extendedConstructorTypePropType = extendedConstructorTypeProp.getType(); - if (!this.resolver.sourceIsSubtypeOfTarget(typeConstructorTypePropType, extendedConstructorTypePropType, resolutionContext, comparisonInfoForPropTypeCheck)) { - var propMessage; - if (comparisonInfoForPropTypeCheck.message) { - propMessage = TypeScript.getDiagnosticMessage(261 /* Types_of_static_property__0__of_class__1__and_class__2__are_incompatible__NL__3 */, [extendedConstructorTypeProp.getScopedNameEx().toString(), typeSymbol.toString(), extendedType.toString(), comparisonInfoForPropTypeCheck.message]); - } else { - propMessage = TypeScript.getDiagnosticMessage(260 /* Types_of_static_property__0__of_class__1__and_class__2__are_incompatible */, [extendedConstructorTypeProp.getScopedNameEx().toString(), typeSymbol.toString(), extendedType.toString()]); - } - comparisonInfo.addMessage(propMessage); - foundError = true; - break; - } - } - } - } - } - - if (foundError) { - var errorCode; - if (typeSymbol.isClass()) { - errorCode = 206 /* Class__0__cannot_extend_class__1__NL__2 */; - } else { - if (extendedType.isClass()) { - errorCode = 207 /* Interface__0__cannot_extend_class__1__NL__2 */; - } else { - errorCode = 208 /* Interface__0__cannot_extend_interface__1__NL__2 */; - } - } - - this.postError(typeDecl.name.minChar, typeDecl.name.getLength(), typeCheckContext.scriptName, errorCode, [typeSymbol.getScopedName(), extendedType.getScopedName(), comparisonInfo.message], typeCheckContext.getEnclosingDecl()); - } - }; - - PullTypeChecker.prototype.typeCheckIfClassImplementsType = function (classDecl, classSymbol, implementedType, typeCheckContext) { - var resolutionContext = new TypeScript.PullTypeResolutionContext(); - var comparisonInfo = new TypeComparisonInfo(); - var foundError = !this.resolver.sourceMembersAreSubtypeOfTargetMembers(classSymbol, implementedType, resolutionContext, comparisonInfo); - if (!foundError) { - foundError = !this.resolver.sourceCallSignaturesAreSubtypeOfTargetCallSignatures(classSymbol, implementedType, resolutionContext, comparisonInfo); - if (!foundError) { - foundError = !this.resolver.sourceConstructSignaturesAreSubtypeOfTargetConstructSignatures(classSymbol, implementedType, resolutionContext, comparisonInfo); - if (!foundError) { - foundError = !this.resolver.sourceIndexSignaturesAreSubtypeOfTargetIndexSignatures(classSymbol, implementedType, resolutionContext, comparisonInfo); - } - } - } - - if (foundError) { - var errorCode = implementedType.isClass() ? 203 /* Class__0__declares_class__1__but_does_not_implement_it__NL__2 */ : 202 /* Class__0__declares_interface__1__but_does_not_implement_it__NL__2 */; - - this.postError(classDecl.name.minChar, classDecl.name.getLength(), typeCheckContext.scriptName, errorCode, [classSymbol.getScopedName(), implementedType.getScopedName(), comparisonInfo.message], typeCheckContext.getEnclosingDecl()); - } - }; - - PullTypeChecker.prototype.typeCheckBase = function (typeDeclAst, typeSymbol, baseDeclAST, isExtendedType, typeCheckContext) { - var _this = this; - var typeDecl = typeCheckContext.semanticInfo.getDeclForAST(typeDeclAst); - var contextForBaseTypeResolution = new TypeScript.PullTypeResolutionContext(); - contextForBaseTypeResolution.isResolvingClassExtendedType = true; - - var baseType = this.typeCheckAST(new TypeScript.TypeReference(baseDeclAST, 0), typeCheckContext, false); - contextForBaseTypeResolution.isResolvingClassExtendedType = false; - - var typeDeclIsClass = typeSymbol.isClass(); - - if (!typeSymbol.isValidBaseKind(baseType, isExtendedType)) { - if (baseType.isError()) { - var error = (baseType).getDiagnostic(); - if (error) { - this.postError(baseDeclAST.minChar, baseDeclAST.getLength(), typeCheckContext.scriptName, error.diagnosticCode(), error.arguments(), typeCheckContext.getEnclosingDecl()); - } - } else if (isExtendedType) { - if (typeDeclIsClass) { - this.postError(baseDeclAST.minChar, baseDeclAST.getLength(), typeCheckContext.scriptName, 142 /* A_class_may_only_extend_another_class */, null, typeCheckContext.getEnclosingDecl()); - } else { - this.postError(baseDeclAST.minChar, baseDeclAST.getLength(), typeCheckContext.scriptName, 144 /* An_interface_may_only_extend_another_class_or_interface */, null, typeCheckContext.getEnclosingDecl()); - } - } else { - this.postError(baseDeclAST.minChar, baseDeclAST.getLength(), typeCheckContext.scriptName, 143 /* A_class_may_only_implement_another_class_or_interface */, null, typeCheckContext.getEnclosingDecl()); - } - return; - } - - if ((baseType.getRootSymbol()).hasBase(typeSymbol.getRootSymbol())) { - typeSymbol.setHasBaseTypeConflict(); - baseType.setHasBaseTypeConflict(); - - this.postError(typeDeclAst.name.minChar, typeDeclAst.name.getLength(), typeCheckContext.scriptName, typeDeclIsClass ? 168 /* Class__0__is_recursively_referenced_as_a_base_type_of_itself */ : 169 /* Interface__0__is_recursively_referenced_as_a_base_type_of_itself */, [typeSymbol.getScopedName()], typeCheckContext.getEnclosingDecl()); - return; - } - - if (isExtendedType) { - this.typeCheckIfTypeExtendsType(typeDeclAst, typeSymbol, baseType, typeCheckContext); - } else { - this.typeCheckIfClassImplementsType(typeDeclAst, typeSymbol, baseType, typeCheckContext); - } - - this.checkTypePrivacy(typeSymbol, baseType, typeCheckContext, function (errorTypeSymbol) { - return _this.baseListPrivacyErrorReporter(typeDeclAst, typeSymbol, baseDeclAST, isExtendedType, errorTypeSymbol, typeCheckContext); - }); - }; - - PullTypeChecker.prototype.typeCheckBases = function (typeDeclAst, typeSymbol, typeCheckContext) { - if (!typeDeclAst.extendsList && !typeDeclAst.implementsList) { - return; - } - - for (var i = 0; i < typeDeclAst.extendsList.members.length; i++) { - this.typeCheckBase(typeDeclAst, typeSymbol, typeDeclAst.extendsList.members[i], true, typeCheckContext); - } - - if (typeSymbol.isClass()) { - for (var i = 0; i < typeDeclAst.implementsList.members.length; i++) { - this.typeCheckBase(typeDeclAst, typeSymbol, typeDeclAst.implementsList.members[i], false, typeCheckContext); - } - } else if (typeDeclAst.implementsList) { - this.postError(typeDeclAst.implementsList.minChar, typeDeclAst.implementsList.getLength(), typeCheckContext.scriptName, 145 /* An_interface_cannot_implement_another_type */, null, typeCheckContext.getEnclosingDecl()); - } - }; - - PullTypeChecker.prototype.typeCheckClass = function (ast, typeCheckContext) { - var classAST = ast; - - var classSymbol = this.resolveSymbolAndReportDiagnostics(ast, false, typeCheckContext.getEnclosingDecl()).getType(); - this.checkForResolutionError(classSymbol, typeCheckContext.getEnclosingDecl()); - - this.typeCheckAST(classAST.typeParameters, typeCheckContext, false); - - var classDecl = typeCheckContext.semanticInfo.getDeclForAST(classAST); - typeCheckContext.pushEnclosingDecl(classDecl); - - this.typeCheckAST(classAST.typeParameters, typeCheckContext, false); - - this.typeCheckBases(classAST, classSymbol, typeCheckContext); - - this.typeCheckAST(classAST.members, typeCheckContext, false); - - if (!classSymbol.hasBaseTypeConflict()) { - this.typeCheckMembersAgainstIndexer(classSymbol, typeCheckContext); - } - - typeCheckContext.popEnclosingDecl(); - - return classSymbol; - }; - - PullTypeChecker.prototype.typeCheckInterface = function (ast, typeCheckContext) { - var interfaceAST = ast; - - var interfaceType = this.resolveSymbolAndReportDiagnostics(ast, false, typeCheckContext.getEnclosingDecl()).getType(); - this.checkForResolutionError(interfaceType, typeCheckContext.getEnclosingDecl()); - - var interfaceDecl = typeCheckContext.semanticInfo.getDeclForAST(interfaceAST); - typeCheckContext.pushEnclosingDecl(interfaceDecl); - - this.typeCheckAST(interfaceAST.typeParameters, typeCheckContext, false); - - this.typeCheckBases(ast, interfaceType, typeCheckContext); - - this.typeCheckAST(interfaceAST.members, typeCheckContext, false); - - if (!interfaceType.hasBaseTypeConflict()) { - this.typeCheckMembersAgainstIndexer(interfaceType, typeCheckContext); - } - - typeCheckContext.popEnclosingDecl(); - - return interfaceType; - }; - - PullTypeChecker.prototype.typeCheckModule = function (ast, typeCheckContext) { - var moduleDeclAST = ast; - var moduleType = this.resolveSymbolAndReportDiagnostics(ast, false, typeCheckContext.getEnclosingDecl()); - - this.checkForResolutionError(moduleType, typeCheckContext.getEnclosingDecl()); - - var moduleDecl = typeCheckContext.semanticInfo.getDeclForAST(moduleDeclAST); - typeCheckContext.pushEnclosingDecl(moduleDecl); - - var modName = (moduleDeclAST.name).text; - var isDynamic = TypeScript.isQuoted(modName) || TypeScript.hasFlag(moduleDeclAST.getModuleFlags(), 512 /* IsDynamic */); - - if (isDynamic && moduleDeclAST.members && moduleDeclAST.members.members) { - for (var i = moduleDeclAST.members.members.length - 1; i >= 0; i--) { - if (moduleDeclAST.members.members[i] && moduleDeclAST.members.members[i].nodeType == 87 /* ExportAssignment */) { - this.typeCheckAST(moduleDeclAST.members.members[i], typeCheckContext, false); - break; - } - } - } - this.typeCheckAST(moduleDeclAST.members, typeCheckContext, false); - - this.validateVariableDeclarationGroups(moduleDecl, typeCheckContext); - - typeCheckContext.popEnclosingDecl(); - - return moduleType; - }; - - PullTypeChecker.prototype.checkAssignability = function (ast, source, target, typeCheckContext) { - var comparisonInfo = new TypeComparisonInfo(); - - var isAssignable = this.resolver.sourceIsAssignableToTarget(source, target, this.context, comparisonInfo); - - if (!isAssignable) { - var enclosingDecl = typeCheckContext.getEnclosingDecl(); - if (comparisonInfo.message) { - this.postError(ast.minChar, ast.getLength(), typeCheckContext.scriptName, 81 /* Cannot_convert__0__to__1__NL__2 */, [source.toString(), target.toString(), comparisonInfo.message], enclosingDecl); - } else { - this.postError(ast.minChar, ast.getLength(), typeCheckContext.scriptName, 80 /* Cannot_convert__0__to__1_ */, [source.toString(), target.toString()], enclosingDecl); - } - } - }; - - PullTypeChecker.prototype.isValidLHS = function (ast, expressionSymbol) { - var expressionTypeSymbol = expressionSymbol.getType(); - - if (ast.nodeType === 35 /* ElementAccessExpression */ || this.resolver.isAnyOrEquivalent(expressionTypeSymbol)) { - return true; - } else if (!expressionSymbol.isType() || expressionTypeSymbol.isArray()) { - return ((expressionSymbol.getKind() & TypeScript.PullElementKind.SomeLHS) != 0) && !expressionSymbol.hasFlag(4096 /* Enum */); - } - - return false; - }; - - PullTypeChecker.prototype.typeCheckAssignment = function (binaryExpression, typeCheckContext) { - var enclosingDecl = typeCheckContext.getEnclosingDecl(); - - this.typeCheckAST(binaryExpression.operand1, typeCheckContext, false); - - var leftExpr = this.resolveSymbolAndReportDiagnostics(binaryExpression.operand1, false, typeCheckContext.getEnclosingDecl()); - var leftType = leftExpr.getType(); - this.checkForResolutionError(leftType, enclosingDecl); - leftType = this.resolver.widenType(leftExpr.getType()); - - this.context.pushContextualType(leftType, this.context.inProvisionalResolution(), null); - var rightType = this.resolver.widenType(this.typeCheckAST(binaryExpression.operand2, typeCheckContext, true)); - this.context.popContextualType(); - - if (!this.isValidLHS(binaryExpression.operand1, leftExpr)) { - this.postError(binaryExpression.operand1.minChar, binaryExpression.operand1.getLength(), typeCheckContext.scriptName, 195 /* Invalid_left_hand_side_of_assignment_expression */, null, enclosingDecl); - } - - this.checkAssignability(binaryExpression.operand1, rightType, leftType, typeCheckContext); - return rightType; - }; - - PullTypeChecker.prototype.typeCheckGenericType = function (genericType, typeCheckContext) { - var savedResolvingTypeReference = this.context.resolvingTypeReference; - this.context.resolvingTypeReference = true; - this.typeCheckAST(genericType.name, typeCheckContext, false); - this.context.resolvingTypeReference = savedResolvingTypeReference; - - this.typeCheckAST(genericType.typeArguments, typeCheckContext, false); - - return this.resolveSymbolAndReportDiagnostics(genericType, false, typeCheckContext.getEnclosingDecl()).getType(); - }; - - PullTypeChecker.prototype.typeCheckObjectLiteral = function (ast, typeCheckContext, inContextuallyTypedAssignment) { - var objectLitAST = ast; - var enclosingDecl = typeCheckContext.getEnclosingDecl(); - - var objectLitType = this.resolveSymbolAndReportDiagnostics(ast, inContextuallyTypedAssignment, enclosingDecl).getType(); - var memberDecls = objectLitAST.operand; - - var contextualType = this.context.getContextualType(); - var memberType; - - if (memberDecls) { - var member = null; - - for (var i = 0; i < memberDecls.members.length; i++) { - var binex = memberDecls.members[i]; - - if (contextualType) { - var text; - if (binex.operand1.nodeType === 20 /* Name */) { - text = (binex.operand1).text; - } else if (binex.operand1.nodeType === 5 /* StringLiteral */) { - text = (binex.operand1).text; - } - - member = contextualType.findMember(text); - - if (member) { - this.context.pushContextualType(member.getType(), this.context.inProvisionalResolution(), null); - } - } - - this.typeCheckAST(binex.operand2, typeCheckContext, member != null); - - if (member) { - this.context.popContextualType(); - member = null; - } - } - } - - this.checkForResolutionError(objectLitType, enclosingDecl); - - return objectLitType; - }; - - PullTypeChecker.prototype.typeCheckArrayLiteral = function (ast, typeCheckContext, inContextuallyTypedAssignment) { - var arrayLiteralAST = ast; - var enclosingDecl = typeCheckContext.getEnclosingDecl(); - - var type = this.resolveSymbolAndReportDiagnostics(ast, inContextuallyTypedAssignment, enclosingDecl).getType(); - var memberASTs = arrayLiteralAST.operand; - - var contextualType = this.context.getContextualType(); - var contextualMemberType = null; - if (contextualType && contextualType.isArray()) { - contextualMemberType = contextualType.getElementType(); - } - - if (memberASTs && memberASTs.members && memberASTs.members.length) { - var elementTypes = []; - - if (contextualMemberType) { - this.context.pushContextualType(contextualMemberType, this.context.inProvisionalResolution(), null); - } - - for (var i = 0; i < memberASTs.members.length; i++) { - elementTypes[elementTypes.length] = this.typeCheckAST(memberASTs.members[i], typeCheckContext, false); - } - - if (contextualMemberType) { - this.context.popContextualType(); - } - } - - this.checkForResolutionError(type, enclosingDecl); - - return type; - }; - - PullTypeChecker.prototype.enclosingClassIsDerived = function (typeCheckContext) { - var enclosingClass = typeCheckContext.getEnclosingDecl(8 /* Class */); - - if (enclosingClass) { - var classSymbol = enclosingClass.getSymbol(); - if (classSymbol.getExtendedTypes().length > 0) { - return true; - } - } - - return false; - }; - - PullTypeChecker.prototype.isSuperCallNode = function (node) { - if (node && node.nodeType === 88 /* ExpressionStatement */) { - var expressionStatement = node; - if (expressionStatement.expression && expressionStatement.expression.nodeType === 36 /* InvocationExpression */) { - var callExpression = expressionStatement.expression; - if (callExpression.target && callExpression.target.nodeType === 30 /* SuperExpression */) { - return true; - } - } - } - return false; - }; - - PullTypeChecker.prototype.getFirstStatementFromFunctionDeclAST = function (funcDeclAST) { - if (funcDeclAST.block && funcDeclAST.block.statements && funcDeclAST.block.statements.members) { - return funcDeclAST.block.statements.members[0]; - } - - return null; - }; - - PullTypeChecker.prototype.superCallMustBeFirstStatementInConstructor = function (enclosingConstructor, enclosingClass) { - if (enclosingConstructor && enclosingClass) { - var classSymbol = enclosingClass.getSymbol(); - if (classSymbol.getExtendedTypes().length === 0) { - return false; - } - - var classMembers = classSymbol.getMembers(); - for (var i = 0, n1 = classMembers.length; i < n1; i++) { - var member = classMembers[i]; - - if (member.getKind() === 4096 /* Property */) { - var declarations = member.getDeclarations(); - for (var j = 0, n2 = declarations.length; j < n2; j++) { - var declaration = declarations[j]; - var ast = this.semanticInfoChain.getASTForDecl(declaration); - if (ast.nodeType === 19 /* Parameter */) { - return true; - } - - if (ast.nodeType === 17 /* VariableDeclarator */) { - var variableDeclarator = ast; - if (variableDeclarator.init) { - return true; - } - } - } - } - } - } - - return false; - }; - - PullTypeChecker.prototype.checkForThisOrSuperCaptureInArrowFunction = function (expression, typeCheckContext) { - var enclosingDecl = typeCheckContext.getEnclosingDecl(); - - var declPath = typeCheckContext.enclosingDeclStack; - - if (declPath.length) { - var inFatArrow = false; - for (var i = declPath.length - 1; i >= 0; i--) { - var decl = declPath[i]; - var declKind = decl.getKind(); - var declFlags = decl.getFlags(); - - if (declKind === 131072 /* FunctionExpression */ && TypeScript.hasFlag(declFlags, 8192 /* FatArrow */)) { - inFatArrow = true; - continue; - } - - if (inFatArrow) { - if (declKind === 16384 /* Function */ || declKind === 65536 /* Method */ || declKind === 32768 /* ConstructorMethod */ || declKind === 262144 /* GetAccessor */ || declKind === 524288 /* SetAccessor */ || declKind === 131072 /* FunctionExpression */ || declKind === 8 /* Class */ || declKind === 4 /* Container */ || declKind === 32 /* DynamicModule */ || declKind === 1 /* Script */) { - decl.setFlags(decl.getFlags() | 262144 /* MustCaptureThis */); - - if (declKind === 8 /* Class */) { - decl.getChildDecls().filter(function (d) { - return d.getKind() === 32768 /* ConstructorMethod */; - }).map(function (d) { - return d.setFlags(d.getFlags() | 262144 /* MustCaptureThis */); - }); - } - break; - } - } - } - } - }; - - PullTypeChecker.prototype.typeCheckThisExpression = function (thisExpressionAST, typeCheckContext) { - var enclosingDecl = typeCheckContext.getEnclosingDecl(); - var enclosingNonLambdaDecl = typeCheckContext.getEnclosingNonLambdaDecl(); - - if (typeCheckContext.inSuperConstructorCall && this.superCallMustBeFirstStatementInConstructor(typeCheckContext.getEnclosingDecl(32768 /* ConstructorMethod */), typeCheckContext.getEnclosingDecl(8 /* Class */))) { - this.postError(thisExpressionAST.minChar, thisExpressionAST.getLength(), typeCheckContext.scriptName, 166 /* _this__cannot_be_referenced_in_current_location */, null, enclosingDecl); - } else if (enclosingNonLambdaDecl) { - if (enclosingNonLambdaDecl.getKind() === 8 /* Class */) { - this.postError(thisExpressionAST.minChar, thisExpressionAST.getLength(), typeCheckContext.scriptName, 205 /* _this__cannot_be_referenced_in_initializers_in_a_class_body */, null, enclosingDecl); - } else if (enclosingNonLambdaDecl.getKind() === 4 /* Container */ || enclosingNonLambdaDecl.getKind() === 32 /* DynamicModule */) { - this.postError(thisExpressionAST.minChar, thisExpressionAST.getLength(), typeCheckContext.scriptName, 176 /* _this__cannot_be_referenced_within_module_bodies */, null, enclosingDecl); - } else if (typeCheckContext.inConstructorArguments) { - this.postError(thisExpressionAST.minChar, thisExpressionAST.getLength(), typeCheckContext.scriptName, 220 /* _this__cannot_be_referenced_in_constructor_arguments */, null, enclosingDecl); - } - } - - this.checkForThisOrSuperCaptureInArrowFunction(thisExpressionAST, typeCheckContext); - - return this.resolveSymbolAndReportDiagnostics(thisExpressionAST, false, enclosingDecl).getType(); - }; - - PullTypeChecker.prototype.typeCheckSuperExpression = function (ast, typeCheckContext) { - var enclosingDecl = typeCheckContext.getEnclosingDecl(); - var nonLambdaEnclosingDecl = typeCheckContext.getEnclosingNonLambdaDecl(); - var nonLambdaEnclosingDeclKind = nonLambdaEnclosingDecl.getKind(); - var inSuperConstructorTarget = typeCheckContext.inSuperConstructorTarget; - - if (inSuperConstructorTarget && enclosingDecl.getKind() !== 32768 /* ConstructorMethod */) { - this.postError(ast.minChar, ast.getLength(), typeCheckContext.scriptName, 174 /* Super_calls_are_not_permitted_outside_constructors_or_in_local_functions_inside_constructors */, null, enclosingDecl); - } else if ((nonLambdaEnclosingDeclKind !== 65536 /* Method */ && nonLambdaEnclosingDeclKind !== 262144 /* GetAccessor */ && nonLambdaEnclosingDeclKind !== 524288 /* SetAccessor */ && nonLambdaEnclosingDeclKind !== 32768 /* ConstructorMethod */) || ((nonLambdaEnclosingDecl.getFlags() & 16 /* Static */) !== 0)) { - this.postError(ast.minChar, ast.getLength(), typeCheckContext.scriptName, 170 /* _super__property_access_is_permitted_only_in_a_constructor__instance_member_function__or_instance_member_accessor_of_a_derived_class */, null, enclosingDecl); - } else if (!this.enclosingClassIsDerived(typeCheckContext)) { - this.postError(ast.minChar, ast.getLength(), typeCheckContext.scriptName, 171 /* _super__cannot_be_referenced_in_non_derived_classes */, null, enclosingDecl); - } - - this.checkForThisOrSuperCaptureInArrowFunction(ast, typeCheckContext); - - return this.resolveSymbolAndReportDiagnostics(ast, false, enclosingDecl).getType(); - }; - - PullTypeChecker.prototype.typeCheckCallExpression = function (callExpression, typeCheckContext) { - var enclosingDecl = typeCheckContext.getEnclosingDecl(); - var inSuperConstructorCall = (callExpression.target.nodeType === 30 /* SuperExpression */); - - var callResolutionData = new TypeScript.PullAdditionalCallResolutionData(); - var resultTypeAndDiagnostics = this.resolver.resolveCallExpression(callExpression, false, enclosingDecl, this.context, callResolutionData); - this.reportDiagnostics(resultTypeAndDiagnostics, enclosingDecl); - var resultType = resultTypeAndDiagnostics.symbol.getType(); - - this.typeCheckAST(callExpression.typeArguments, typeCheckContext, false); - - if (!resultType.isError()) { - var savedInSuperConstructorTarget = typeCheckContext.inSuperConstructorTarget; - if (inSuperConstructorCall) { - typeCheckContext.inSuperConstructorTarget = true; - } - - this.typeCheckAST(callExpression.target, typeCheckContext, false); - - typeCheckContext.inSuperConstructorTarget = savedInSuperConstructorTarget; - } - - if (inSuperConstructorCall && enclosingDecl.getKind() === 32768 /* ConstructorMethod */) { - typeCheckContext.seenSuperConstructorCall = true; - } - - var savedInSuperConstructorCall = typeCheckContext.inSuperConstructorCall; - if (inSuperConstructorCall) { - typeCheckContext.inSuperConstructorCall = true; - } - - var contextTypes = callResolutionData.actualParametersContextTypeSymbols; - if (callExpression.arguments) { - var argumentASTs = callExpression.arguments.members; - for (var i = 0, n = argumentASTs.length; i < n; i++) { - var argumentAST = argumentASTs[i]; - - if (contextTypes && contextTypes[i]) { - this.context.pushContextualType(contextTypes[i], this.context.inProvisionalResolution(), null); - } - - this.typeCheckAST(argumentAST, typeCheckContext, false); - - if (contextTypes && contextTypes[i]) { - this.context.popContextualType(); - } - } - } - - typeCheckContext.inSuperConstructorCall = savedInSuperConstructorCall; - - return resultType; - }; - - PullTypeChecker.prototype.typeCheckObjectCreationExpression = function (callExpression, typeCheckContext) { - var enclosingDecl = typeCheckContext.getEnclosingDecl(); - - var callResolutionData = new TypeScript.PullAdditionalCallResolutionData(); - var resultAndDiagnostics = this.resolver.resolveNewExpression(callExpression, false, enclosingDecl, this.context, callResolutionData); - this.reportDiagnostics(resultAndDiagnostics, typeCheckContext.getEnclosingDecl()); - - var result = resultAndDiagnostics.symbol.getType(); - - this.typeCheckAST(callExpression.target, typeCheckContext, false); - - this.typeCheckAST(callExpression.typeArguments, typeCheckContext, false); - - var contextTypes = callResolutionData.actualParametersContextTypeSymbols; - if (callExpression.arguments) { - var argumentASTs = callExpression.arguments.members; - for (var i = 0, n = argumentASTs.length; i < n; i++) { - var argumentAST = argumentASTs[i]; - - if (contextTypes && contextTypes[i]) { - this.context.pushContextualType(contextTypes[i], this.context.inProvisionalResolution(), null); - } - - this.typeCheckAST(argumentAST, typeCheckContext, false); - - if (contextTypes && contextTypes[i]) { - this.context.popContextualType(); - } - } - } - - return result; - }; - - PullTypeChecker.prototype.typeCheckTypeAssertion = function (ast, typeCheckContext) { - var enclosingDecl = typeCheckContext.getEnclosingDecl(); - - var returnType = this.resolveSymbolAndReportDiagnostics(ast, false, enclosingDecl).getType(); - - if (returnType.isError()) { - var symbolName = (returnType).getData(); - this.postError(ast.minChar, ast.getLength(), typeCheckContext.scriptName, 164 /* Could_not_find_symbol__0_ */, [symbolName], typeCheckContext.getEnclosingDecl()); - } - - this.context.pushContextualType(returnType, this.context.inProvisionalResolution(), null); - var exprType = this.typeCheckAST(ast.operand, typeCheckContext, true); - this.context.popContextualType(); - - var comparisonInfo = new TypeComparisonInfo(); - - var isAssignable = this.resolver.sourceIsAssignableToTarget(returnType, exprType, this.context, comparisonInfo) || this.resolver.sourceIsAssignableToTarget(exprType, returnType, this.context, comparisonInfo); - - if (!isAssignable) { - var message; - if (comparisonInfo.message) { - this.postError(ast.minChar, ast.getLength(), typeCheckContext.scriptName, 81 /* Cannot_convert__0__to__1__NL__2 */, [exprType.toString(), returnType.toString(), comparisonInfo.message], typeCheckContext.getEnclosingDecl()); - } else { - this.postError(ast.minChar, ast.getLength(), typeCheckContext.scriptName, 80 /* Cannot_convert__0__to__1_ */, [exprType.toString(), returnType.toString()], typeCheckContext.getEnclosingDecl()); - } - } - - return returnType; - }; - - PullTypeChecker.prototype.typeCheckLogicalOperation = function (binex, typeCheckContext) { - var leftType = this.typeCheckAST(binex.operand1, typeCheckContext, false); - var rightType = this.typeCheckAST(binex.operand2, typeCheckContext, false); - - var comparisonInfo = new TypeComparisonInfo(); - if (!this.resolver.sourceIsAssignableToTarget(leftType, rightType, this.context, comparisonInfo) && !this.resolver.sourceIsAssignableToTarget(rightType, leftType, this.context, comparisonInfo)) { - this.postError(binex.minChar, binex.getLength(), typeCheckContext.scriptName, 78 /* Operator__0__cannot_be_applied_to_types__1__and__2_ */, [TypeScript.BinaryExpression.getTextForBinaryToken(binex.nodeType), leftType.toString(), rightType.toString()], typeCheckContext.getEnclosingDecl()); - } - - return this.resolveSymbolAndReportDiagnostics(binex, false, typeCheckContext.getEnclosingDecl()).getType(); - }; - - PullTypeChecker.prototype.typeCheckLogicalAndOrExpression = function (binex, typeCheckContext) { - this.typeCheckAST(binex.operand1, typeCheckContext, false); - this.typeCheckAST(binex.operand2, typeCheckContext, false); - - return this.resolveSymbolAndReportDiagnostics(binex, false, typeCheckContext.getEnclosingDecl()).getType(); - }; - - PullTypeChecker.prototype.typeCheckCommaExpression = function (binex, typeCheckContext) { - this.typeCheckAST(binex.operand1, typeCheckContext, false); - this.typeCheckAST(binex.operand2, typeCheckContext, false); - - return this.resolveSymbolAndReportDiagnostics(binex, false, typeCheckContext.getEnclosingDecl()).getType(); - }; - - PullTypeChecker.prototype.typeCheckBinaryAdditionOperation = function (binaryExpression, typeCheckContext) { - var enclosingDecl = typeCheckContext.getEnclosingDecl(); - - this.resolveSymbolAndReportDiagnostics(binaryExpression, false, enclosingDecl).getType(); - - var lhsType = this.typeCheckAST(binaryExpression.operand1, typeCheckContext, false); - var rhsType = this.typeCheckAST(binaryExpression.operand2, typeCheckContext, false); - - if (TypeScript.PullHelpers.symbolIsEnum(lhsType)) { - lhsType = this.semanticInfoChain.numberTypeSymbol; - } else if (lhsType === this.semanticInfoChain.nullTypeSymbol || lhsType === this.semanticInfoChain.undefinedTypeSymbol) { - if (rhsType != this.semanticInfoChain.nullTypeSymbol && rhsType != this.semanticInfoChain.undefinedTypeSymbol) { - lhsType = rhsType; - } else { - lhsType = this.semanticInfoChain.anyTypeSymbol; - } - } - - if (TypeScript.PullHelpers.symbolIsEnum(rhsType)) { - rhsType = this.semanticInfoChain.numberTypeSymbol; - } else if (rhsType === this.semanticInfoChain.nullTypeSymbol || rhsType === this.semanticInfoChain.undefinedTypeSymbol) { - if (lhsType != this.semanticInfoChain.nullTypeSymbol && lhsType != this.semanticInfoChain.undefinedTypeSymbol) { - rhsType = lhsType; - } else { - rhsType = this.semanticInfoChain.anyTypeSymbol; - } - } - - var exprType = null; - - if (lhsType === this.semanticInfoChain.stringTypeSymbol || rhsType === this.semanticInfoChain.stringTypeSymbol) { - exprType = this.semanticInfoChain.stringTypeSymbol; - } else if (this.resolver.isAnyOrEquivalent(lhsType) || this.resolver.isAnyOrEquivalent(rhsType)) { - exprType = this.semanticInfoChain.anyTypeSymbol; - } else if (rhsType === this.semanticInfoChain.numberTypeSymbol && lhsType === this.semanticInfoChain.numberTypeSymbol) { - exprType = this.semanticInfoChain.numberTypeSymbol; - } - - if (exprType) { - if (binaryExpression.nodeType === 39 /* AddAssignmentExpression */) { - var lhsExpression = this.resolveSymbolAndReportDiagnostics(binaryExpression.operand1, false, typeCheckContext.getEnclosingDecl()); - if (!this.isValidLHS(binaryExpression.operand1, lhsExpression)) { - this.postError(binaryExpression.operand1.minChar, binaryExpression.operand1.getLength(), typeCheckContext.scriptName, 195 /* Invalid_left_hand_side_of_assignment_expression */, null, enclosingDecl); - } - - this.checkAssignability(binaryExpression.operand1, exprType, lhsType, typeCheckContext); - } - } else { - this.postError(binaryExpression.operand1.minChar, binaryExpression.operand1.getLength(), typeCheckContext.scriptName, 178 /* Invalid__addition__expression___types_do_not_agree */, null, typeCheckContext.getEnclosingDecl()); - exprType = this.semanticInfoChain.anyTypeSymbol; - } - - return exprType; - }; - - PullTypeChecker.prototype.typeCheckBinaryArithmeticOperation = function (binaryExpression, typeCheckContext) { - var enclosingDecl = typeCheckContext.getEnclosingDecl(); - - this.resolveSymbolAndReportDiagnostics(binaryExpression, false, enclosingDecl).getType(); - - var lhsType = this.typeCheckAST(binaryExpression.operand1, typeCheckContext, false); - var rhsType = this.typeCheckAST(binaryExpression.operand2, typeCheckContext, false); - - var lhsIsFit = this.resolver.isAnyOrEquivalent(lhsType) || lhsType === this.semanticInfoChain.numberTypeSymbol || TypeScript.PullHelpers.symbolIsEnum(lhsType); - var rhsIsFit = this.resolver.isAnyOrEquivalent(rhsType) || rhsType === this.semanticInfoChain.numberTypeSymbol || TypeScript.PullHelpers.symbolIsEnum(rhsType); - - if (!rhsIsFit) { - this.postError(binaryExpression.operand1.minChar, binaryExpression.operand1.getLength(), typeCheckContext.scriptName, 179 /* The_right_hand_side_of_an_arithmetic_operation_must_be_of_type__any____number__or_an_enum_type */, null, typeCheckContext.getEnclosingDecl()); - } - - if (!lhsIsFit) { - this.postError(binaryExpression.operand2.minChar, binaryExpression.operand2.getLength(), typeCheckContext.scriptName, 180 /* The_left_hand_side_of_an_arithmetic_operation_must_be_of_type__any____number__or_an_enum_type */, null, typeCheckContext.getEnclosingDecl()); - } - - if (rhsIsFit && lhsIsFit) { - switch (binaryExpression.nodeType) { - case 47 /* LeftShiftAssignmentExpression */: - case 48 /* SignedRightShiftAssignmentExpression */: - case 49 /* UnsignedRightShiftAssignmentExpression */: - case 40 /* SubtractAssignmentExpression */: - case 42 /* MultiplyAssignmentExpression */: - case 41 /* DivideAssignmentExpression */: - case 43 /* ModuloAssignmentExpression */: - case 46 /* OrAssignmentExpression */: - case 44 /* AndAssignmentExpression */: - case 45 /* ExclusiveOrAssignmentExpression */: - var lhsExpression = this.resolveSymbolAndReportDiagnostics(binaryExpression.operand1, false, typeCheckContext.getEnclosingDecl()); - if (!this.isValidLHS(binaryExpression.operand1, lhsExpression)) { - this.postError(binaryExpression.operand1.minChar, binaryExpression.operand1.getLength(), typeCheckContext.scriptName, 195 /* Invalid_left_hand_side_of_assignment_expression */, null, enclosingDecl); - } - - this.checkAssignability(binaryExpression.operand1, rhsType, lhsType, typeCheckContext); - break; - } - } - - return this.semanticInfoChain.numberTypeSymbol; - }; - - PullTypeChecker.prototype.typeCheckLogicalNotExpression = function (unaryExpression, typeCheckContext, inContextuallyTypedAssignment) { - this.typeCheckAST(unaryExpression.operand, typeCheckContext, inContextuallyTypedAssignment); - return this.semanticInfoChain.booleanTypeSymbol; - }; - - PullTypeChecker.prototype.typeCheckUnaryArithmeticOperation = function (unaryExpression, typeCheckContext, inContextuallyTypedAssignment) { - var operandType = this.typeCheckAST(unaryExpression.operand, typeCheckContext, inContextuallyTypedAssignment); - - switch (unaryExpression.nodeType) { - case 26 /* PlusExpression */: - case 27 /* NegateExpression */: - case 72 /* BitwiseNotExpression */: - return this.semanticInfoChain.numberTypeSymbol; - } - - var operandIsFit = this.resolver.isAnyOrEquivalent(operandType) || operandType === this.semanticInfoChain.numberTypeSymbol || TypeScript.PullHelpers.symbolIsEnum(operandType); - - if (!operandIsFit) { - this.postError(unaryExpression.operand.minChar, unaryExpression.operand.getLength(), typeCheckContext.scriptName, 181 /* The_type_of_a_unary_arithmetic_operation_operand_must_be_of_type__any____number__or_an_enum_type */, null, typeCheckContext.getEnclosingDecl()); - } - - switch (unaryExpression.nodeType) { - case 76 /* PostIncrementExpression */: - case 74 /* PreIncrementExpression */: - case 77 /* PostDecrementExpression */: - case 75 /* PreDecrementExpression */: - var expression = this.resolveSymbolAndReportDiagnostics(unaryExpression.operand, false, typeCheckContext.getEnclosingDecl()); - if (!this.isValidLHS(unaryExpression.operand, expression)) { - this.postError(unaryExpression.operand.minChar, unaryExpression.operand.getLength(), typeCheckContext.scriptName, 204 /* The_operand_of_an_increment_or_decrement_operator_must_be_a_variable__property_or_indexer */, null, typeCheckContext.getEnclosingDecl()); - } - - break; - } - - return operandType; - }; - - PullTypeChecker.prototype.typeCheckElementAccessExpression = function (binaryExpression, typeCheckContext) { - this.typeCheckAST(binaryExpression.operand1, typeCheckContext, false); - this.typeCheckAST(binaryExpression.operand2, typeCheckContext, false); - - return this.resolveSymbolAndReportDiagnostics(binaryExpression, false, typeCheckContext.getEnclosingDecl()).getType(); - }; - - PullTypeChecker.prototype.typeCheckTypeOf = function (ast, typeCheckContext) { - this.typeCheckAST((ast).operand, typeCheckContext, false); - - return this.semanticInfoChain.stringTypeSymbol; - }; - - PullTypeChecker.prototype.typeCheckTypeReference = function (typeRef, typeCheckContext) { - if (typeRef.term.nodeType === 12 /* FunctionDeclaration */) { - this.typeCheckFunctionTypeSignature(typeRef.term, typeCheckContext.getEnclosingDecl(), typeCheckContext); - } else if (typeRef.term.nodeType === 14 /* InterfaceDeclaration */) { - this.typeCheckInterfaceTypeReference(typeRef.term, typeCheckContext.getEnclosingDecl(), typeCheckContext); - } else { - var savedResolvingTypeReference = this.context.resolvingTypeReference; - this.context.resolvingTypeReference = true; - var type = this.typeCheckAST(typeRef.term, typeCheckContext, false); - - if (type && !type.isError() && !typeCheckContext.inImportDeclaration) { - if ((type.getKind() & TypeScript.PullElementKind.SomeType) === 0) { - if (type.getKind() & TypeScript.PullElementKind.SomeContainer) { - this.postError(typeRef.minChar, typeRef.getLength(), typeCheckContext.scriptName, 262 /* Type_reference_cannot_refer_to_container__0_ */, [type.toString()], typeCheckContext.getEnclosingDecl()); - } else { - this.postError(typeRef.minChar, typeRef.getLength(), typeCheckContext.scriptName, 263 /* Type_reference_must_refer_to_type */, null, typeCheckContext.getEnclosingDecl()); - } - } - } - - this.context.resolvingTypeReference = savedResolvingTypeReference; - } - - return this.resolveSymbolAndReportDiagnostics(typeRef, false, typeCheckContext.getEnclosingDecl()).getType(); - }; - - PullTypeChecker.prototype.typeCheckExportAssignment = function (ast, typeCheckContext) { - return this.resolveSymbolAndReportDiagnostics(ast, false, typeCheckContext.getEnclosingDecl()).getType(); - }; - - PullTypeChecker.prototype.typeCheckFunctionTypeSignature = function (funcDeclAST, enclosingDecl, typeCheckContext) { - var funcDeclSymbolAndDiagnostics = this.resolver.getSymbolAndDiagnosticsForAST(funcDeclAST); - var funcDeclSymbol = funcDeclSymbolAndDiagnostics && funcDeclSymbolAndDiagnostics.symbol; - if (!funcDeclSymbol) { - funcDeclSymbol = this.resolver.resolveFunctionTypeSignature(funcDeclAST, enclosingDecl, this.context); - } - var functionDecl = typeCheckContext.semanticInfo.getDeclForAST(funcDeclAST); - - typeCheckContext.pushEnclosingDecl(functionDecl); - this.typeCheckAST(funcDeclAST.arguments, typeCheckContext, false); - typeCheckContext.popEnclosingDecl(); - - var functionSignature = funcDeclSymbol.getKind() === 33554432 /* ConstructorType */ ? funcDeclSymbol.getConstructSignatures()[0] : funcDeclSymbol.getCallSignatures()[0]; - var parameters = functionSignature.getParameters(); - for (var i = 0; i < parameters.length; i++) { - this.checkForResolutionError(parameters[i].getType(), enclosingDecl); - } - - if (funcDeclAST.returnTypeAnnotation) { - var returnType = functionSignature.getReturnType(); - this.checkForResolutionError(returnType, enclosingDecl); - } - - this.typeCheckFunctionOverloads(funcDeclAST, typeCheckContext, functionSignature, [functionSignature]); - return funcDeclSymbol; - }; - - PullTypeChecker.prototype.typeCheckInterfaceTypeReference = function (interfaceAST, enclosingDecl, typeCheckContext) { - var interfaceSymbolAndDiagnostics = this.resolver.getSymbolAndDiagnosticsForAST(interfaceAST); - var interfaceSymbol = interfaceSymbolAndDiagnostics && interfaceSymbolAndDiagnostics.symbol; - if (!interfaceSymbol) { - interfaceSymbol = this.resolver.resolveInterfaceTypeReference(interfaceAST, enclosingDecl, this.context); - } - - var interfaceDecl = typeCheckContext.semanticInfo.getDeclForAST(interfaceAST); - typeCheckContext.pushEnclosingDecl(interfaceDecl); - this.typeCheckAST(interfaceAST.members, typeCheckContext, false); - this.typeCheckMembersAgainstIndexer(interfaceSymbol, typeCheckContext); - typeCheckContext.popEnclosingDecl(); - - return interfaceSymbol; - }; - - PullTypeChecker.prototype.typeCheckConditionalExpression = function (conditionalExpression, typeCheckContext) { - this.typeCheckAST(conditionalExpression.operand1, typeCheckContext, false); - this.typeCheckAST(conditionalExpression.operand2, typeCheckContext, false); - this.typeCheckAST(conditionalExpression.operand3, typeCheckContext, false); - - return this.resolveSymbolAndReportDiagnostics(conditionalExpression, false, typeCheckContext.getEnclosingDecl()).getType(); - }; - - PullTypeChecker.prototype.typeCheckThrowStatement = function (throwStatement, typeCheckContext) { - this.typeCheckAST(throwStatement.expression, typeCheckContext, false); - - var type = this.resolveSymbolAndReportDiagnostics(throwStatement.expression, false, typeCheckContext.getEnclosingDecl()).getType(); - this.checkForResolutionError(type, typeCheckContext.getEnclosingDecl()); - return this.semanticInfoChain.voidTypeSymbol; - }; - - PullTypeChecker.prototype.typeCheckDeleteExpression = function (unaryExpression, typeCheckContext) { - this.typeCheckAST(unaryExpression.operand, typeCheckContext, false); - - var enclosingDecl = typeCheckContext.getEnclosingDecl(); - var type = this.resolveSymbolAndReportDiagnostics(unaryExpression, false, enclosingDecl).getType(); - this.checkForResolutionError(type, enclosingDecl); - - return type; - }; - - PullTypeChecker.prototype.typeCheckVoidExpression = function (unaryExpression, typeCheckContext) { - this.typeCheckAST(unaryExpression.operand, typeCheckContext, false); - - var enclosingDecl = typeCheckContext.getEnclosingDecl(); - var type = this.resolveSymbolAndReportDiagnostics(unaryExpression, false, enclosingDecl).getType(); - this.checkForResolutionError(type, enclosingDecl); - - return type; - }; - - PullTypeChecker.prototype.typeCheckRegExpExpression = function (ast, typeCheckContext) { - var type = this.resolveSymbolAndReportDiagnostics(ast, false, typeCheckContext.getEnclosingDecl()).getType(); - this.checkForResolutionError(type, typeCheckContext.getEnclosingDecl()); - return type; - }; - - PullTypeChecker.prototype.typeCheckForStatement = function (forStatement, typeCheckContext) { - this.typeCheckAST(forStatement.init, typeCheckContext, false); - this.typeCheckAST(forStatement.cond, typeCheckContext, false); - this.typeCheckAST(forStatement.body, typeCheckContext, false); - - return this.semanticInfoChain.voidTypeSymbol; - }; - - PullTypeChecker.prototype.typeCheckForInStatement = function (ast, typeCheckContext) { - var forInStatement = ast; - - var rhsType = this.resolver.widenType(this.typeCheckAST(forInStatement.obj, typeCheckContext, false)); - var lval = forInStatement.lval; - - if (lval.nodeType === 18 /* VariableDeclaration */) { - var declaration = forInStatement.lval; - var varDecl = declaration.declarators.members[0]; - - if (varDecl.typeExpr) { - this.postError(lval.minChar, lval.getLength(), typeCheckContext.scriptName, 182 /* Variable_declarations_for_for_in_expressions_cannot_contain_a_type_annotation */, null, typeCheckContext.getEnclosingDecl()); - } - } - - var varSym = this.resolveSymbolAndReportDiagnostics(forInStatement.lval, false, typeCheckContext.getEnclosingDecl()); - this.checkForResolutionError(varSym.getType(), typeCheckContext.getEnclosingDecl()); - - var isStringOrNumber = varSym.getType() === this.semanticInfoChain.stringTypeSymbol || this.resolver.isAnyOrEquivalent(varSym.getType()); - - var isValidRHS = rhsType && (this.resolver.isAnyOrEquivalent(rhsType) || !rhsType.isPrimitive()); - - if (!isStringOrNumber) { - this.postError(lval.minChar, lval.getLength(), typeCheckContext.scriptName, 183 /* Variable_declarations_for_for_in_expressions_must_be_of_types__string__or__any_ */, null, typeCheckContext.getEnclosingDecl()); - } - - if (!isValidRHS) { - this.postError(forInStatement.obj.minChar, forInStatement.obj.getLength(), typeCheckContext.scriptName, 184 /* The_right_operand_of_a_for_in_expression_must_be_of_type__any____an_object_type_or_a_type_parameter */, null, typeCheckContext.getEnclosingDecl()); - } - - this.typeCheckAST(forInStatement.body, typeCheckContext, false); - - return this.semanticInfoChain.voidTypeSymbol; - }; - - PullTypeChecker.prototype.typeCheckInExpression = function (binaryExpression, typeCheckContext) { - var lhsType = this.resolver.widenType(this.typeCheckAST(binaryExpression.operand1, typeCheckContext, false)); - var rhsType = this.resolver.widenType(this.typeCheckAST(binaryExpression.operand2, typeCheckContext, false)); - - var isStringAnyOrNumber = lhsType.getType() === this.semanticInfoChain.stringTypeSymbol || this.resolver.isAnyOrEquivalent(lhsType.getType()) || this.resolver.isNumberOrEquivalent(lhsType.getType()); - var isValidRHS = rhsType && (this.resolver.isAnyOrEquivalent(rhsType) || !rhsType.isPrimitive()); - - if (!isStringAnyOrNumber) { - this.postError(binaryExpression.operand1.minChar, binaryExpression.operand1.getLength(), typeCheckContext.scriptName, 185 /* The_left_hand_side_of_an__in__expression_must_be_of_types__string__or__any_ */, null, typeCheckContext.getEnclosingDecl()); - } - - if (!isValidRHS) { - this.postError(binaryExpression.operand1.minChar, binaryExpression.operand1.getLength(), typeCheckContext.scriptName, 186 /* The_right_hand_side_of_an__in__expression_must_be_of_type__any___an_object_type_or_a_type_parameter */, null, typeCheckContext.getEnclosingDecl()); - } - - return this.semanticInfoChain.booleanTypeSymbol; - }; - - PullTypeChecker.prototype.typeCheckInstanceOfExpression = function (binaryExpression, typeCheckContext) { - var lhsType = this.resolver.widenType(this.typeCheckAST(binaryExpression.operand1, typeCheckContext, false)); - var rhsType = this.typeCheckAST(binaryExpression.operand2, typeCheckContext, false); - - var isValidLHS = lhsType && (this.resolver.isAnyOrEquivalent(lhsType) || !lhsType.isPrimitive()); - var isValidRHS = rhsType && (this.resolver.isAnyOrEquivalent(rhsType) || rhsType.isClass() || this.resolver.typeIsSubtypeOfFunction(rhsType, this.context)); - - if (!isValidLHS) { - this.postError(binaryExpression.operand1.minChar, binaryExpression.operand1.getLength(), typeCheckContext.scriptName, 187 /* The_left_hand_side_of_an__instanceOf__expression_must_be_of_type__any___an_object_type_or_a_type_parameter */, null, typeCheckContext.getEnclosingDecl()); - } - - if (!isValidRHS) { - this.postError(binaryExpression.operand1.minChar, binaryExpression.operand1.getLength(), typeCheckContext.scriptName, 188 /* The_right_hand_side_of_an__instanceOf__expression_must_be_of_type__any__or_a_subtype_of_the__Function__interface_type */, null, typeCheckContext.getEnclosingDecl()); - } - - return this.semanticInfoChain.booleanTypeSymbol; - }; - - PullTypeChecker.prototype.typeCheckParenthesizedExpression = function (parenthesizedExpression, typeCheckContext) { - return this.typeCheckAST(parenthesizedExpression.expression, typeCheckContext, false); - }; - - PullTypeChecker.prototype.typeCheckWhileStatement = function (whileStatement, typeCheckContext) { - this.typeCheckAST(whileStatement.cond, typeCheckContext, false); - this.typeCheckAST(whileStatement.body, typeCheckContext, false); - - return this.semanticInfoChain.voidTypeSymbol; - }; - - PullTypeChecker.prototype.typeCheckDoStatement = function (doStatement, typeCheckContext) { - this.typeCheckAST(doStatement.cond, typeCheckContext, false); - this.typeCheckAST(doStatement.body, typeCheckContext, false); - - return this.semanticInfoChain.voidTypeSymbol; - }; - - PullTypeChecker.prototype.typeCheckIfStatement = function (ifStatement, typeCheckContext) { - this.typeCheckAST(ifStatement.cond, typeCheckContext, false); - this.typeCheckAST(ifStatement.thenBod, typeCheckContext, false); - this.typeCheckAST(ifStatement.elseBod, typeCheckContext, false); - - return this.semanticInfoChain.voidTypeSymbol; - }; - - PullTypeChecker.prototype.typeCheckBlock = function (block, typeCheckContext) { - this.typeCheckAST(block.statements, typeCheckContext, false); - - return this.semanticInfoChain.voidTypeSymbol; - }; - - PullTypeChecker.prototype.typeCheckVariableDeclaration = function (variableDeclaration, typeCheckContext) { - this.typeCheckAST(variableDeclaration.declarators, typeCheckContext, false); - - return this.semanticInfoChain.voidTypeSymbol; - }; - - PullTypeChecker.prototype.typeCheckVariableStatement = function (variableStatement, typeCheckContext) { - this.typeCheckAST(variableStatement.declaration, typeCheckContext, false); - - return this.semanticInfoChain.voidTypeSymbol; - }; - - PullTypeChecker.prototype.typeCheckWithStatement = function (withStatement, typeCheckContext) { - this.postError(withStatement.expr.minChar, withStatement.expr.getLength(), typeCheckContext.scriptName, 200 /* All_symbols_within_a__with__block_will_be_resolved_to__any__ */, null, typeCheckContext.getEnclosingDecl()); - - return this.semanticInfoChain.voidTypeSymbol; - }; - - PullTypeChecker.prototype.typeCheckTryStatement = function (tryStatement, typeCheckContext) { - this.typeCheckAST(tryStatement.tryBody, typeCheckContext, false); - this.typeCheckAST(tryStatement.catchClause, typeCheckContext, false); - this.typeCheckAST(tryStatement.finallyBody, typeCheckContext, false); - - return this.semanticInfoChain.voidTypeSymbol; - }; - - PullTypeChecker.prototype.typeCheckCatchClause = function (catchClause, typeCheckContext) { - var catchDecl = this.resolver.getDeclForAST(catchClause); - - typeCheckContext.pushEnclosingDecl(catchDecl); - this.typeCheckAST(catchClause.body, typeCheckContext, false); - typeCheckContext.popEnclosingDecl(); - - return this.semanticInfoChain.voidTypeSymbol; - }; - - PullTypeChecker.prototype.typeCheckReturnStatement = function (returnAST, typeCheckContext) { - typeCheckContext.setEnclosingDeclHasReturn(); - - var returnExpr = returnAST.returnExpression; - var enclosingDecl = typeCheckContext.getEnclosingDecl(); - - var inContextuallyTypedAssignment = false; - var enclosingDeclAST; - - if (enclosingDecl.getKind() & TypeScript.PullElementKind.SomeFunction) { - enclosingDeclAST = this.resolver.getASTForDecl(enclosingDecl); - if (enclosingDeclAST.returnTypeAnnotation) { - var returnTypeAnnotationSymbol = this.resolver.resolveTypeReference(enclosingDeclAST.returnTypeAnnotation, enclosingDecl, this.context).symbol; - if (returnTypeAnnotationSymbol) { - inContextuallyTypedAssignment = true; - this.context.pushContextualType(returnTypeAnnotationSymbol, this.context.inProvisionalResolution(), null); - } - } else { - var currentContextualType = this.context.getContextualType(); - if (currentContextualType && currentContextualType.isFunction()) { - var currentContextualTypeSignatureSymbol = currentContextualType.getDeclarations()[0].getSignatureSymbol(); - var currentContextualTypeReturnTypeSymbol = currentContextualTypeSignatureSymbol.getReturnType(); - if (currentContextualTypeReturnTypeSymbol) { - inContextuallyTypedAssignment = true; - this.context.pushContextualType(currentContextualTypeReturnTypeSymbol, this.context.inProvisionalResolution(), null); - } - } - } - } - - var returnType = this.typeCheckAST(returnExpr, typeCheckContext, inContextuallyTypedAssignment); - - if (inContextuallyTypedAssignment) { - this.context.popContextualType(); - } - - if (enclosingDecl.getKind() === 524288 /* SetAccessor */ && returnExpr) { - this.postError(returnExpr.minChar, returnExpr.getLength(), typeCheckContext.scriptName, 189 /* Setters_cannot_return_a_value */, null, typeCheckContext.getEnclosingDecl()); - } - - if (enclosingDecl.getKind() & TypeScript.PullElementKind.SomeFunction) { - enclosingDeclAST = this.resolver.getASTForDecl(enclosingDecl); - - if (enclosingDeclAST.returnTypeAnnotation) { - var signatureSymbol = enclosingDecl.getSignatureSymbol(); - var sigReturnType = signatureSymbol.getReturnType(); - - if (returnType && sigReturnType) { - var comparisonInfo = new TypeComparisonInfo(); - var upperBound = null; - - if (returnType.isTypeParameter()) { - upperBound = (returnType).getConstraint(); - - if (upperBound) { - returnType = upperBound; - } - } - - if (sigReturnType.isTypeParameter()) { - upperBound = (sigReturnType).getConstraint(); - - if (upperBound) { - sigReturnType = upperBound; - } - } - - if (!returnType.isResolved()) { - this.resolver.resolveDeclaredSymbol(returnType, enclosingDecl, this.context); - } - - if (!sigReturnType.isResolved()) { - this.resolver.resolveDeclaredSymbol(sigReturnType, enclosingDecl, this.context); - } - - var isAssignable = this.resolver.sourceIsAssignableToTarget(returnType, sigReturnType, this.context, comparisonInfo); - - if (!isAssignable) { - if (comparisonInfo.message) { - this.postError(returnExpr.minChar, returnExpr.getLength(), typeCheckContext.scriptName, 81 /* Cannot_convert__0__to__1__NL__2 */, [returnType.toString(), sigReturnType.toString(), comparisonInfo.message], enclosingDecl); - } else { - this.postError(returnExpr.minChar, returnExpr.getLength(), typeCheckContext.scriptName, 80 /* Cannot_convert__0__to__1_ */, [returnType.toString(), sigReturnType.toString()], enclosingDecl); - } - } - } - } - } - - return returnType; - }; - - PullTypeChecker.prototype.typeCheckNameExpression = function (ast, typeCheckContext) { - var enclosingDecl = typeCheckContext.getEnclosingDecl(); - var type = this.resolveSymbolAndReportDiagnostics(ast, false, enclosingDecl).getType(); - this.checkForResolutionError(type, enclosingDecl); - return type; - }; - - PullTypeChecker.prototype.checkForSuperMemberAccess = function (memberAccessExpression, typeCheckContext, resolvedName) { - var enclosingDecl = typeCheckContext.getEnclosingDecl(); - if (resolvedName) { - if (memberAccessExpression.operand1.nodeType === 30 /* SuperExpression */ && !resolvedName.isError() && resolvedName.getKind() !== 65536 /* Method */) { - this.postError(memberAccessExpression.operand2.minChar, memberAccessExpression.operand2.getLength(), typeCheckContext.scriptName, 232 /* Only_public_instance_methods_of_the_base_class_are_accessible_via_the_super_keyword */, [], enclosingDecl); - return true; - } - } - - return false; - }; - - PullTypeChecker.prototype.checkForPrivateMemberAccess = function (memberAccessExpression, typeCheckContext, expressionType, resolvedName) { - var enclosingDecl = typeCheckContext.getEnclosingDecl(); - if (resolvedName) { - if (resolvedName.hasFlag(2 /* Private */)) { - var memberContainer = resolvedName.getContainer(); - if (memberContainer && memberContainer.getKind() === 33554432 /* ConstructorType */) { - memberContainer = memberContainer.getAssociatedContainerType(); - } - - if (memberContainer && memberContainer.isClass()) { - var containingClass = typeCheckContext.getEnclosingClassDecl(); - if (!containingClass || containingClass.getSymbol() !== memberContainer) { - var name = memberAccessExpression.operand2; - this.postError(name.minChar, name.getLength(), typeCheckContext.scriptName, 175 /* _0_1__is_inaccessible */, [memberContainer.toString(false), name.actualText], enclosingDecl); - return true; - } - } - } - } - - return false; - }; - - PullTypeChecker.prototype.checkForStaticMemberAccess = function (memberAccessExpression, typeCheckContext, expressionType, resolvedName) { - if (expressionType && resolvedName && !resolvedName.isError()) { - if (expressionType.isClass() || expressionType.getKind() === 33554432 /* ConstructorType */) { - var name = memberAccessExpression.operand2; - var enclosingDecl = typeCheckContext.getEnclosingDecl(); - - if (resolvedName.hasFlag(16 /* Static */) || this.resolver.isPrototypeMember(memberAccessExpression, enclosingDecl, this.context)) { - if (expressionType.getKind() !== 33554432 /* ConstructorType */) { - var enclosingDecl = typeCheckContext.getEnclosingDecl(); - this.postError(name.minChar, name.getLength(), typeCheckContext.scriptName, 221 /* Static_member_cannot_be_accessed_off_an_instance_variable */, null, enclosingDecl); - return true; - } - } - } - } - - return false; - }; - - PullTypeChecker.prototype.typeCheckMemberAccessExpression = function (memberAccessExpression, typeCheckContext) { - var enclosingDecl = typeCheckContext.getEnclosingDecl(); - var resolvedName = this.resolveSymbolAndReportDiagnostics(memberAccessExpression, false, enclosingDecl); - var type = resolvedName.getType(); - - this.checkForResolutionError(type, enclosingDecl); - var prevCanUseTypeSymbol = this.context.canUseTypeSymbol; - this.context.canUseTypeSymbol = true; - var expressionType = this.typeCheckAST(memberAccessExpression.operand1, typeCheckContext, false); - this.context.canUseTypeSymbol = prevCanUseTypeSymbol; - - this.checkForSuperMemberAccess(memberAccessExpression, typeCheckContext, resolvedName) || this.checkForPrivateMemberAccess(memberAccessExpression, typeCheckContext, expressionType, resolvedName) || this.checkForStaticMemberAccess(memberAccessExpression, typeCheckContext, expressionType, resolvedName); - - return type; - }; - - PullTypeChecker.prototype.typeCheckSwitchStatement = function (switchStatement, typeCheckContext) { - this.typeCheckAST(switchStatement.val, typeCheckContext, false); - this.typeCheckAST(switchStatement.caseList, typeCheckContext, false); - this.typeCheckAST(switchStatement.defaultCase, typeCheckContext, false); - - return this.semanticInfoChain.voidTypeSymbol; - }; - - PullTypeChecker.prototype.typeCheckExpressionStatement = function (ast, typeCheckContext, inContextuallyTypedAssignment) { - return this.typeCheckAST(ast.expression, typeCheckContext, inContextuallyTypedAssignment); - }; - - PullTypeChecker.prototype.typeCheckCaseClause = function (caseClause, typeCheckContext) { - this.typeCheckAST(caseClause.expr, typeCheckContext, false); - this.typeCheckAST(caseClause.body, typeCheckContext, false); - - return this.semanticInfoChain.voidTypeSymbol; - }; - - PullTypeChecker.prototype.typeCheckLabeledStatement = function (labeledStatement, typeCheckContext) { - return this.typeCheckAST(labeledStatement.statement, typeCheckContext, false); - }; - - PullTypeChecker.prototype.checkTypePrivacy = function (declSymbol, typeSymbol, typeCheckContext, privacyErrorReporter) { - if (!typeSymbol || typeSymbol.getKind() === 2 /* Primitive */) { - return; - } - - if (typeSymbol.isArray()) { - this.checkTypePrivacy(declSymbol, (typeSymbol).getElementType(), typeCheckContext, privacyErrorReporter); - return; - } - - if (!typeSymbol.isNamedTypeSymbol()) { - var members = typeSymbol.getMembers(); - for (var i = 0; i < members.length; i++) { - this.checkTypePrivacy(declSymbol, members[i].getType(), typeCheckContext, privacyErrorReporter); - } - - this.checkTypePrivacyOfSignatures(declSymbol, typeSymbol.getCallSignatures(), typeCheckContext, privacyErrorReporter); - this.checkTypePrivacyOfSignatures(declSymbol, typeSymbol.getConstructSignatures(), typeCheckContext, privacyErrorReporter); - this.checkTypePrivacyOfSignatures(declSymbol, typeSymbol.getIndexSignatures(), typeCheckContext, privacyErrorReporter); - - return; - } - - if (declSymbol.isExternallyVisible()) { - var typeSymbolIsVisible = typeSymbol.isExternallyVisible(); - - if (typeSymbolIsVisible) { - var typeSymbolPath = typeSymbol.pathToRoot(); - if (typeSymbolPath.length && typeSymbolPath[typeSymbolPath.length - 1].getKind() === 32 /* DynamicModule */) { - var declSymbolPath = declSymbol.pathToRoot(); - if (declSymbolPath.length && declSymbolPath[declSymbolPath.length - 1] != typeSymbolPath[typeSymbolPath.length - 1]) { - typeSymbolIsVisible = false; - for (var i = typeSymbolPath.length - 1; i >= 0; i--) { - var aliasSymbol = typeSymbolPath[i].getAliasedSymbol(declSymbol); - if (aliasSymbol) { - TypeScript.CompilerDiagnostics.assert(aliasSymbol.getKind() === 256 /* TypeAlias */, "dynamic module need to be referenced by type alias"); - (aliasSymbol).setIsTypeUsedExternally(); - typeSymbolIsVisible = true; - break; - } - } - } - } - } - - if (!typeSymbolIsVisible) { - privacyErrorReporter(typeSymbol); - } - } - }; - - PullTypeChecker.prototype.checkTypePrivacyOfSignatures = function (declSymbol, signatures, typeCheckContext, privacyErrorReporter) { - for (var i = 0; i < signatures.length; i++) { - var signature = signatures[i]; - if (signatures.length && signature.isDefinition()) { - continue; - } - - var typeParams = signature.getTypeParameters(); - for (var j = 0; j < typeParams.length; j++) { - this.checkTypePrivacy(declSymbol, typeParams[j], typeCheckContext, privacyErrorReporter); - } - - var params = signature.getParameters(); - for (var j = 0; j < params.length; j++) { - var paramType = params[j].getType(); - this.checkTypePrivacy(declSymbol, paramType, typeCheckContext, privacyErrorReporter); - } - - var returnType = signature.getReturnType(); - this.checkTypePrivacy(declSymbol, returnType, typeCheckContext, privacyErrorReporter); - } - }; - - PullTypeChecker.prototype.baseListPrivacyErrorReporter = function (declAST, declSymbol, baseAst, isExtendedType, typeSymbol, typeCheckContext) { - var decl = this.resolver.getDeclForAST(declAST); - var enclosingDecl = typeCheckContext.getEnclosingDecl(); - var messageCode; - var messageArguments; - - var typeSymbolName = typeSymbol.getScopedName(); - if (typeSymbol.isContainer()) { - if (!TypeScript.isQuoted(typeSymbolName)) { - typeSymbolName = "'" + typeSymbolName + "'"; - } - if (declAST.nodeType === 13 /* ClassDeclaration */) { - if (isExtendedType) { - messageCode = 90 /* Exported_class__0__extends_class_from_inaccessible_module__1_ */; - messageArguments = [declSymbol.getScopedName(), typeSymbolName]; - } else { - messageCode = 91 /* Exported_class__0__implements_interface_from_inaccessible_module__1_ */; - messageArguments = [declSymbol.getScopedName(), typeSymbolName]; - } - } else { - messageCode = 92 /* Exported_interface__0__extends_interface_from_inaccessible_module__1_ */; - messageArguments = [declSymbol.getDisplayName(), typeSymbolName]; - } - } else { - if (declAST.nodeType === 13 /* ClassDeclaration */) { - if (isExtendedType) { - messageCode = 87 /* Exported_class__0__extends_private_class__1_ */; - messageArguments = [declSymbol.getScopedName(), typeSymbolName]; - } else { - messageCode = 88 /* Exported_class__0__implements_private_interface__1_ */; - messageArguments = [declSymbol.getScopedName(), typeSymbolName]; - } - } else { - messageCode = 89 /* Exported_interface__0__extends_private_interface__1_ */; - messageArguments = [declSymbol.getDisplayName(), typeSymbolName]; - } - } - - this.context.postError(typeCheckContext.scriptName, baseAst.minChar, baseAst.getLength(), messageCode, messageArguments, enclosingDecl, true); - }; - - PullTypeChecker.prototype.variablePrivacyErrorReporter = function (declSymbol, typeSymbol, typeCheckContext) { - var declAST = this.resolver.getASTForSymbol(declSymbol); - var enclosingDecl = typeCheckContext.getEnclosingDecl(); - - var isProperty = declSymbol.getKind() === 4096 /* Property */; - var isPropertyOfClass = false; - var declParent = declSymbol.getContainer(); - if (declParent && (declParent.getKind() === 8 /* Class */ || declParent.getKind() === 32768 /* ConstructorMethod */)) { - isPropertyOfClass = true; - } - - var messageCode; - var messageArguments; - var typeSymbolName = typeSymbol.getScopedName(); - if (typeSymbol.isContainer()) { - if (!TypeScript.isQuoted(typeSymbolName)) { - typeSymbolName = "'" + typeSymbolName + "'"; - } - - if (declSymbol.hasFlag(16 /* Static */)) { - messageCode = 97 /* Public_static_property__0__of__exported_class_is_using_inaccessible_module__1_ */; - messageArguments = [declSymbol.getScopedName(), typeSymbolName]; - } else if (isProperty) { - if (isPropertyOfClass) { - messageCode = 98 /* Public_property__0__of__exported_class_is_using_inaccessible_module__1_ */; - messageArguments = [declSymbol.getScopedName(), typeSymbolName]; - } else { - messageCode = 99 /* Property__0__of__exported_interface_is_using_inaccessible_module__1_ */; - messageArguments = [declSymbol.getScopedName(), typeSymbolName]; - } - } else { - messageCode = 100 /* Exported_variable__0__is_using_inaccessible_module__1_ */; - messageArguments = [declSymbol.getScopedName(), typeSymbolName]; - } - } else { - if (declSymbol.hasFlag(16 /* Static */)) { - messageCode = 93 /* Public_static_property__0__of__exported_class_has_or_is_using_private_type__1_ */; - messageArguments = [declSymbol.getScopedName(), typeSymbolName]; - } else if (isProperty) { - if (isPropertyOfClass) { - messageCode = 94 /* Public_property__0__of__exported_class_has_or_is_using_private_type__1_ */; - messageArguments = [declSymbol.getScopedName(), typeSymbolName]; - } else { - messageCode = 95 /* Property__0__of__exported_interface_has_or_is_using_private_type__1_ */; - messageArguments = [declSymbol.getScopedName(), typeSymbolName]; - } - } else { - messageCode = 96 /* Exported_variable__0__has_or_is_using_private_type__1_ */; - messageArguments = [declSymbol.getScopedName(), typeSymbolName]; - } - } - - this.context.postError(typeCheckContext.scriptName, declAST.minChar, declAST.getLength(), messageCode, messageArguments, enclosingDecl, true); - }; - - PullTypeChecker.prototype.checkFunctionTypePrivacy = function (funcDeclAST, inContextuallyTypedAssignment, typeCheckContext) { - var _this = this; - if (inContextuallyTypedAssignment || (funcDeclAST.getFunctionFlags() & 8192 /* IsFunctionExpression */) || (funcDeclAST.getFunctionFlags() & 16384 /* IsFunctionProperty */)) { - return; - } - - var functionDecl = typeCheckContext.semanticInfo.getDeclForAST(funcDeclAST); - var functionSymbol = functionDecl.getSymbol(); - ; - var functionSignature; - - var isGetter = funcDeclAST.isGetAccessor(); - var isSetter = funcDeclAST.isSetAccessor(); - - if (isGetter || isSetter) { - var accessorSymbol = functionSymbol; - functionSignature = (isGetter ? accessorSymbol.getGetter() : accessorSymbol.getSetter()).getType().getCallSignatures()[0]; - } else { - if (!functionSymbol) { - var parentDecl = functionDecl.getParentDecl(); - functionSymbol = parentDecl.getSymbol(); - if (functionSymbol && functionSymbol.isType() && !(functionSymbol).isNamedTypeSymbol()) { - return; - } - } else if (functionSymbol.getKind() == 65536 /* Method */ && !functionSymbol.getContainer().isNamedTypeSymbol()) { - return; - } - functionSignature = functionDecl.getSignatureSymbol(); - } - - if (!isGetter) { - var funcParams = functionSignature.getParameters(); - for (var i = 0; i < funcParams.length; i++) { - this.checkTypePrivacy(functionSymbol, funcParams[i].getType(), typeCheckContext, function (typeSymbol) { - return _this.functionArgumentTypePrivacyErrorReporter(funcDeclAST, i, funcParams[i], typeSymbol, typeCheckContext); - }); - } - } - - if (!isSetter) { - this.checkTypePrivacy(functionSymbol, functionSignature.getReturnType(), typeCheckContext, function (typeSymbol) { - return _this.functionReturnTypePrivacyErrorReporter(funcDeclAST, functionSignature.getReturnType(), typeSymbol, typeCheckContext); - }); - } - }; - - PullTypeChecker.prototype.functionArgumentTypePrivacyErrorReporter = function (declAST, argIndex, paramSymbol, typeSymbol, typeCheckContext) { - var decl = this.resolver.getDeclForAST(declAST); - var enclosingDecl = typeCheckContext.getEnclosingDecl(); - - var isGetter = declAST.isAccessor() && TypeScript.hasFlag(declAST.getFunctionFlags(), 32 /* GetAccessor */); - var isSetter = declAST.isAccessor() && TypeScript.hasFlag(declAST.getFunctionFlags(), 64 /* SetAccessor */); - var isStatic = (decl.getFlags() & 16 /* Static */) === 16 /* Static */; - var isMethod = decl.getKind() === 65536 /* Method */; - var isMethodOfClass = false; - var declParent = decl.getParentDecl(); - if (declParent && (declParent.getKind() === 8 /* Class */ || declParent.getKind() === 32768 /* ConstructorMethod */)) { - isMethodOfClass = true; - } - - var start = declAST.arguments.members[argIndex].minChar; - var length = declAST.arguments.members[argIndex].getLength(); - - var typeSymbolName = typeSymbol.getScopedName(); - if (typeSymbol.isContainer()) { - if (!TypeScript.isQuoted(typeSymbolName)) { - typeSymbolName = "'" + typeSymbolName + "'"; - } - - if (declAST.isConstructor) { - this.context.postError(typeCheckContext.scriptName, start, length, 110 /* Parameter__0__of_constructor_from_exported_class_is_using_inaccessible_module__1_ */, [paramSymbol.getScopedName(), typeSymbolName], enclosingDecl, true); - } else if (isSetter) { - if (isStatic) { - this.context.postError(typeCheckContext.scriptName, start, length, 111 /* Parameter__0__of_public_static_property_setter_from_exported_class_is_using_inaccessible_module__1_ */, [paramSymbol.getScopedName(), typeSymbolName], enclosingDecl, true); - } else { - this.context.postError(typeCheckContext.scriptName, start, length, 112 /* Parameter__0__of_public_property_setter_from_exported_class_is_using_inaccessible_module__1_ */, [paramSymbol.getScopedName(), typeSymbolName], enclosingDecl, true); - } - } else if (declAST.isConstructMember()) { - this.context.postError(typeCheckContext.scriptName, start, length, 113 /* Parameter__0__of_constructor_signature_from_exported_interface_is_using_inaccessible_module__1_ */, [paramSymbol.getScopedName(), typeSymbolName], enclosingDecl, true); - } else if (declAST.isCallMember()) { - this.context.postError(typeCheckContext.scriptName, start, length, 114 /* Parameter__0__of_call_signature_from_exported_interface_is_using_inaccessible_module__1_ */, [paramSymbol.getScopedName(), typeSymbolName], enclosingDecl, true); - } else if (isMethod) { - if (isStatic) { - this.context.postError(typeCheckContext.scriptName, start, length, 115 /* Parameter__0__of_public_static_method_from_exported_class_is_using_inaccessible_module__1_ */, [paramSymbol.getScopedName(), typeSymbolName], enclosingDecl, true); - } else if (isMethodOfClass) { - this.context.postError(typeCheckContext.scriptName, start, length, 116 /* Parameter__0__of_public_method_from_exported_class_is_using_inaccessible_module__1_ */, [paramSymbol.getScopedName(), typeSymbolName], enclosingDecl, true); - } else { - this.context.postError(typeCheckContext.scriptName, start, length, 117 /* Parameter__0__of_method_from_exported_interface_is_using_inaccessible_module__1_ */, [paramSymbol.getScopedName(), typeSymbolName], enclosingDecl, true); - } - } else if (!isGetter) { - this.context.postError(typeCheckContext.scriptName, start, length, 118 /* Parameter__0__of_exported_function_is_using_inaccessible_module__1_ */, [paramSymbol.getScopedName(), typeSymbolName], enclosingDecl, true); - } - } else { - if (declAST.isConstructor) { - this.context.postError(typeCheckContext.scriptName, start, length, 101 /* Parameter__0__of_constructor_from_exported_class_has_or_is_using_private_type__1_ */, [paramSymbol.getScopedName(), typeSymbolName], enclosingDecl, true); - } else if (isSetter) { - if (isStatic) { - this.context.postError(typeCheckContext.scriptName, start, length, 102 /* Parameter__0__of_public_static_property_setter_from_exported_class_has_or_is_using_private_type__1_ */, [paramSymbol.getScopedName(), typeSymbolName], enclosingDecl, true); - } else { - this.context.postError(typeCheckContext.scriptName, start, length, 103 /* Parameter__0__of_public_property_setter_from_exported_class_has_or_is_using_private_type__1_ */, [paramSymbol.getScopedName(), typeSymbolName], enclosingDecl, true); - } - } else if (declAST.isConstructMember()) { - this.context.postError(typeCheckContext.scriptName, start, length, 104 /* Parameter__0__of_constructor_signature_from_exported_interface_has_or_is_using_private_type__1_ */, [paramSymbol.getScopedName(), typeSymbolName], enclosingDecl, true); - } else if (declAST.isCallMember()) { - this.context.postError(typeCheckContext.scriptName, start, length, 105 /* Parameter__0__of_call_signature_from_exported_interface_has_or_is_using_private_type__1_ */, [paramSymbol.getScopedName(), typeSymbolName], enclosingDecl, true); - } else if (isMethod) { - if (isStatic) { - this.context.postError(typeCheckContext.scriptName, start, length, 106 /* Parameter__0__of_public_static_method_from_exported_class_has_or_is_using_private_type__1_ */, [paramSymbol.getScopedName(), typeSymbolName], enclosingDecl, true); - } else if (isMethodOfClass) { - this.context.postError(typeCheckContext.scriptName, start, length, 107 /* Parameter__0__of_public_method_from_exported_class_has_or_is_using_private_type__1_ */, [paramSymbol.getScopedName(), typeSymbolName], enclosingDecl, true); - } else { - this.context.postError(typeCheckContext.scriptName, start, length, 108 /* Parameter__0__of_method_from_exported_interface_has_or_is_using_private_type__1_ */, [paramSymbol.getScopedName(), typeSymbolName], enclosingDecl, true); - } - } else if (!isGetter && !declAST.isIndexerMember()) { - this.context.postError(typeCheckContext.scriptName, start, length, 109 /* Parameter__0__of_exported_function_has_or_is_using_private_type__1_ */, [paramSymbol.getScopedName(), typeSymbolName], enclosingDecl, true); - } - } - }; - - PullTypeChecker.prototype.functionReturnTypePrivacyErrorReporter = function (declAST, funcReturnType, typeSymbol, typeCheckContext) { - var _this = this; - var decl = this.resolver.getDeclForAST(declAST); - var enclosingDecl = typeCheckContext.getEnclosingDecl(); - - var isGetter = declAST.isAccessor() && TypeScript.hasFlag(declAST.getFunctionFlags(), 32 /* GetAccessor */); - var isSetter = declAST.isAccessor() && TypeScript.hasFlag(declAST.getFunctionFlags(), 64 /* SetAccessor */); - var isStatic = (decl.getFlags() & 16 /* Static */) === 16 /* Static */; - var isMethod = decl.getKind() === 65536 /* Method */; - var isMethodOfClass = false; - var declParent = decl.getParentDecl(); - if (declParent && (declParent.getKind() === 8 /* Class */ || declParent.getKind() === 32768 /* ConstructorMethod */)) { - isMethodOfClass = true; - } - - var messageCode = null; - var messageArguments; - var typeSymbolName = typeSymbol.getScopedName(); - if (typeSymbol.isContainer()) { - if (!TypeScript.isQuoted(typeSymbolName)) { - typeSymbolName = "'" + typeSymbolName + "'"; - } - - if (isGetter) { - if (isStatic) { - messageCode = 128 /* Return_type_of_public_static_property_getter_from_exported_class_is_using_inaccessible_module__0_ */; - messageArguments = [typeSymbolName]; - } else { - messageCode = 129 /* Return_type_of_public_property_getter_from_exported_class_is_using_inaccessible_module__0_ */; - messageArguments = [typeSymbolName]; - } - } else if (declAST.isConstructMember()) { - messageCode = 130 /* Return_type_of_constructor_signature_from_exported_interface_is_using_inaccessible_module__0_ */; - messageArguments = [typeSymbolName]; - } else if (declAST.isCallMember()) { - messageCode = 131 /* Return_type_of_call_signature_from_exported_interface_is_using_inaccessible_module__0_ */; - messageArguments = [typeSymbolName]; - } else if (declAST.isIndexerMember()) { - messageCode = 132 /* Return_type_of_index_signature_from_exported_interface_is_using_inaccessible_module__0_ */; - messageArguments = [typeSymbolName]; - } else if (isMethod) { - if (isStatic) { - messageCode = 133 /* Return_type_of_public_static_method_from_exported_class_is_using_inaccessible_module__0_ */; - messageArguments = [typeSymbolName]; - } else if (isMethodOfClass) { - messageCode = 134 /* Return_type_of_public_method_from_exported_class_is_using_inaccessible_module__0_ */; - messageArguments = [typeSymbolName]; - } else { - messageCode = 135 /* Return_type_of_method_from_exported_interface_is_using_inaccessible_module__0_ */; - messageArguments = [typeSymbolName]; - } - } else if (!isSetter && !declAST.isConstructor) { - messageCode = 136 /* Return_type_of_exported_function_is_using_inaccessible_module__0_ */; - messageArguments = [typeSymbolName]; - } - } else { - if (isGetter) { - if (isStatic) { - messageCode = 119 /* Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_private_type__0_ */; - messageArguments = [typeSymbolName]; - } else { - messageCode = 120 /* Return_type_of_public_property_getter_from_exported_class_has_or_is_using_private_type__0_ */; - messageArguments = [typeSymbolName]; - } - } else if (declAST.isConstructMember()) { - messageCode = 121 /* Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_private_type__0_ */; - messageArguments = [typeSymbolName]; - } else if (declAST.isCallMember()) { - messageCode = 122 /* Return_type_of_call_signature_from_exported_interface_has_or_is_using_private_type__0_ */; - messageArguments = [typeSymbolName]; - } else if (declAST.isIndexerMember()) { - messageCode = 123 /* Return_type_of_index_signature_from_exported_interface_has_or_is_using_private_type__0_ */; - messageArguments = [typeSymbolName]; - } else if (isMethod) { - if (isStatic) { - messageCode = 124 /* Return_type_of_public_static_method_from_exported_class_has_or_is_using_private_type__0_ */; - messageArguments = [typeSymbolName]; - } else if (isMethodOfClass) { - messageCode = 125 /* Return_type_of_public_method_from_exported_class_has_or_is_using_private_type__0_ */; - messageArguments = [typeSymbolName]; - } else { - messageCode = 126 /* Return_type_of_method_from_exported_interface_has_or_is_using_private_type__0_ */; - messageArguments = [typeSymbolName]; - } - } else if (!isSetter && !declAST.isConstructor) { - messageCode = 127 /* Return_type_of_exported_function_has_or_is_using_private_type__0_ */; - messageArguments = [typeSymbolName]; - } - } - - if (messageCode) { - var reportOnFuncDecl = false; - var contextForReturnTypeResolution = new TypeScript.PullTypeResolutionContext(); - if (declAST.returnTypeAnnotation) { - var returnExpressionSymbolAndDiagnostics = this.resolver.resolveTypeReference(declAST.returnTypeAnnotation, decl, contextForReturnTypeResolution); - var returnExpressionSymbol = returnExpressionSymbolAndDiagnostics && returnExpressionSymbolAndDiagnostics.symbol; - if (returnExpressionSymbol === funcReturnType) { - this.context.postError(typeCheckContext.scriptName, declAST.returnTypeAnnotation.minChar, declAST.returnTypeAnnotation.getLength(), messageCode, messageArguments, enclosingDecl, true); - } - } - - if (declAST.block) { - var reportErrorOnReturnExpressions = function (ast, parent, walker) { - var go = true; - switch (ast.nodeType) { - case 12 /* FunctionDeclaration */: - go = false; - break; - - case 93 /* ReturnStatement */: - var returnStatement = ast; - var returnExpressionSymbol = _this.resolver.resolveAST(returnStatement.returnExpression, false, decl, contextForReturnTypeResolution).symbol.getType(); - - if (returnExpressionSymbol === funcReturnType) { - _this.context.postError(typeCheckContext.scriptName, returnStatement.minChar, returnStatement.getLength(), messageCode, messageArguments, enclosingDecl, true); - } else { - reportOnFuncDecl = true; - } - go = false; - break; - - default: - break; - } - - walker.options.goChildren = go; - return ast; - }; - - TypeScript.getAstWalkerFactory().walk(declAST.block, reportErrorOnReturnExpressions); - } - - if (reportOnFuncDecl) { - this.context.postError(typeCheckContext.scriptName, declAST.minChar, declAST.getLength(), messageCode, messageArguments, enclosingDecl, true); - } - } - }; - PullTypeChecker.globalPullTypeCheckPhase = 0; - return PullTypeChecker; - })(); - TypeScript.PullTypeChecker = PullTypeChecker; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (PullDeclEdit) { - PullDeclEdit[PullDeclEdit["NoChanges"] = 0] = "NoChanges"; - PullDeclEdit[PullDeclEdit["DeclAdded"] = 1] = "DeclAdded"; - PullDeclEdit[PullDeclEdit["DeclRemoved"] = 2] = "DeclRemoved"; - PullDeclEdit[PullDeclEdit["DeclChanged"] = 3] = "DeclChanged"; - })(TypeScript.PullDeclEdit || (TypeScript.PullDeclEdit = {})); - var PullDeclEdit = TypeScript.PullDeclEdit; - - var PullDeclDiff = (function () { - function PullDeclDiff(oldDecl, newDecl, kind) { - this.oldDecl = oldDecl; - this.newDecl = newDecl; - this.kind = kind; - } - return PullDeclDiff; - })(); - TypeScript.PullDeclDiff = PullDeclDiff; - - var PullDeclDiffer = (function () { - function PullDeclDiffer(oldSemanticInfo, newSemanticInfo) { - this.oldSemanticInfo = oldSemanticInfo; - this.newSemanticInfo = newSemanticInfo; - this.differences = []; - } - PullDeclDiffer.diffDecls = function (oldDecl, oldSemanticInfo, newDecl, newSemanticInfo) { - var declDiffer = new PullDeclDiffer(oldSemanticInfo, newSemanticInfo); - declDiffer.diff(oldDecl, newDecl); - return declDiffer.differences; - }; - - PullDeclDiffer.prototype.diff = function (oldDecl, newDecl) { - TypeScript.Debug.assert(oldDecl.getName() === newDecl.getName()); - TypeScript.Debug.assert(oldDecl.getKind() === newDecl.getKind()); - - var oldAST = this.oldSemanticInfo.getASTForDecl(oldDecl); - var newAST = this.newSemanticInfo.getASTForDecl(newDecl); - TypeScript.Debug.assert(oldAST !== undefined); - TypeScript.Debug.assert(newAST !== undefined); - - if (oldAST === newAST) { - return; - } - - this.diff1(oldDecl, newDecl, oldAST, newAST, oldDecl.childDeclTypeCache, newDecl.childDeclTypeCache); - this.diff1(oldDecl, newDecl, oldAST, newAST, oldDecl.childDeclTypeParameterCache, newDecl.childDeclTypeParameterCache); - this.diff1(oldDecl, newDecl, oldAST, newAST, oldDecl.childDeclValueCache, newDecl.childDeclValueCache); - this.diff1(oldDecl, newDecl, oldAST, newAST, oldDecl.childDeclNamespaceCache, newDecl.childDeclNamespaceCache); - - if (!this.isEquivalent(oldAST, newAST)) { - this.differences.push(new PullDeclDiff(oldDecl, newDecl, 3 /* DeclChanged */)); - } - }; - - PullDeclDiffer.prototype.diff1 = function (oldDecl, newDecl, oldAST, newAST, oldNameToDecls, newNameToDecls) { - var oldChildrenOfName; - var newChildrenOfName; - var oldChild; - var newChild; - - for (var name in oldNameToDecls) { - oldChildrenOfName = oldNameToDecls[name] || PullDeclDiffer.emptyDeclArray; - newChildrenOfName = newNameToDecls[name] || PullDeclDiffer.emptyDeclArray; - - for (var i = 0, n = oldChildrenOfName.length; i < n; i++) { - oldChild = oldChildrenOfName[i]; - - switch (oldChild.getKind()) { - case 131072 /* FunctionExpression */: - case 512 /* ObjectLiteral */: - case 8388608 /* ObjectType */: - case 16777216 /* FunctionType */: - case 33554432 /* ConstructorType */: - continue; - } - - if (i < newChildrenOfName.length) { - newChild = newChildrenOfName[i]; - - if (oldChild.getKind() === newChild.getKind()) { - this.diff(oldChild, newChildrenOfName[i]); - } else { - this.differences.push(new PullDeclDiff(oldChild, null, 2 /* DeclRemoved */)); - this.differences.push(new PullDeclDiff(oldDecl, newChild, 1 /* DeclAdded */)); - } - } else { - this.differences.push(new PullDeclDiff(oldChild, null, 2 /* DeclRemoved */)); - } - } - } - - for (var name in newNameToDecls) { - oldChildrenOfName = oldNameToDecls[name] || PullDeclDiffer.emptyDeclArray; - newChildrenOfName = newNameToDecls[name] || PullDeclDiffer.emptyDeclArray; - - for (var i = oldChildrenOfName.length, n = newChildrenOfName.length; i < n; i++) { - newChild = newChildrenOfName[i]; - this.differences.push(new PullDeclDiff(oldDecl, newChild, 1 /* DeclAdded */)); - } - } - }; - - PullDeclDiffer.prototype.isEquivalent = function (oldAST, newAST) { - TypeScript.Debug.assert(oldAST !== null); - TypeScript.Debug.assert(newAST !== null); - TypeScript.Debug.assert(oldAST !== newAST); - - if (oldAST.nodeType !== newAST.nodeType || oldAST.getFlags() !== newAST.getFlags()) { - return false; - } - - switch (oldAST.nodeType) { - case 16 /* ImportDeclaration */: - return this.importDeclarationIsEquivalent(oldAST, newAST); - case 15 /* ModuleDeclaration */: - return this.moduleDeclarationIsEquivalent(oldAST, newAST); - case 13 /* ClassDeclaration */: - return this.classDeclarationIsEquivalent(oldAST, newAST); - case 14 /* InterfaceDeclaration */: - return this.interfaceDeclarationIsEquivalent(oldAST, newAST); - case 19 /* Parameter */: - return this.argumentDeclarationIsEquivalent(oldAST, newAST); - case 17 /* VariableDeclarator */: - return this.variableDeclarationIsEquivalent(oldAST, newAST); - case 9 /* TypeParameter */: - return this.typeParameterIsEquivalent(oldAST, newAST); - case 12 /* FunctionDeclaration */: - return this.functionDeclarationIsEquivalent(oldAST, newAST); - case 101 /* CatchClause */: - return this.catchClauseIsEquivalent(oldAST, newAST); - case 99 /* WithStatement */: - return this.withStatementIsEquivalent(oldAST, newAST); - case 2 /* Script */: - return this.scriptIsEquivalent(oldAST, newAST); - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - PullDeclDiffer.prototype.importDeclarationIsEquivalent = function (decl1, decl2) { - return TypeScript.structuralEqualsNotIncludingPosition(decl1.alias, decl2.alias); - }; - - PullDeclDiffer.prototype.typeDeclarationIsEquivalent = function (decl1, decl2) { - return decl1.getVarFlags() === decl2.getVarFlags() && TypeScript.structuralEqualsNotIncludingPosition(decl1.typeParameters, decl2.typeParameters) && TypeScript.structuralEqualsNotIncludingPosition(decl1.extendsList, decl2.extendsList) && TypeScript.structuralEqualsNotIncludingPosition(decl1.implementsList, decl2.implementsList); - }; - - PullDeclDiffer.prototype.classDeclarationIsEquivalent = function (decl1, decl2) { - return this.typeDeclarationIsEquivalent(decl1, decl2); - }; - - PullDeclDiffer.prototype.interfaceDeclarationIsEquivalent = function (decl1, decl2) { - return this.typeDeclarationIsEquivalent(decl1, decl2); - }; - - PullDeclDiffer.prototype.typeParameterIsEquivalent = function (decl1, decl2) { - return TypeScript.structuralEqualsNotIncludingPosition(decl1.constraint, decl2.constraint); - }; - - PullDeclDiffer.prototype.boundDeclarationIsEquivalent = function (decl1, decl2) { - if (decl1.getVarFlags() === decl2.getVarFlags() && TypeScript.structuralEqualsNotIncludingPosition(decl1.typeExpr, decl2.typeExpr)) { - if (decl1.typeExpr === null) { - return TypeScript.structuralEqualsNotIncludingPosition(decl1.init, decl2.init); - } else { - return true; - } - } - - return false; - }; - - PullDeclDiffer.prototype.argumentDeclarationIsEquivalent = function (decl1, decl2) { - return this.boundDeclarationIsEquivalent(decl1, decl2) && decl1.isOptional === decl2.isOptional; - }; - - PullDeclDiffer.prototype.variableDeclarationIsEquivalent = function (decl1, decl2) { - return this.boundDeclarationIsEquivalent(decl1, decl2); - }; - - PullDeclDiffer.prototype.functionDeclarationIsEquivalent = function (decl1, decl2) { - if (decl1.hint === decl2.hint && decl1.getFunctionFlags() === decl2.getFunctionFlags() && decl1.variableArgList === decl2.variableArgList && decl1.isConstructor === decl2.isConstructor && TypeScript.structuralEqualsNotIncludingPosition(decl1.returnTypeAnnotation, decl2.returnTypeAnnotation) && TypeScript.structuralEqualsNotIncludingPosition(decl1.typeArguments, decl2.typeArguments) && TypeScript.structuralEqualsNotIncludingPosition(decl1.arguments, decl2.arguments)) { - if (decl1.returnTypeAnnotation === null) { - return TypeScript.structuralEqualsNotIncludingPosition(decl1.block, decl2.block); - } else { - return true; - } - } - - return false; - }; - - PullDeclDiffer.prototype.catchClauseIsEquivalent = function (decl1, decl2) { - return TypeScript.structuralEqualsNotIncludingPosition(decl1.param, decl2.param) && TypeScript.structuralEqualsNotIncludingPosition(decl1.body, decl2.body); - }; - - PullDeclDiffer.prototype.withStatementIsEquivalent = function (decl1, decl2) { - return TypeScript.structuralEqualsNotIncludingPosition(decl1.expr, decl2.expr) && TypeScript.structuralEqualsNotIncludingPosition(decl1.body, decl2.body); - }; - - PullDeclDiffer.prototype.scriptIsEquivalent = function (decl1, decl2) { - return true; - }; - - PullDeclDiffer.prototype.moduleDeclarationIsEquivalent = function (decl1, decl2) { - return decl1.getModuleFlags() === decl2.getModuleFlags() && decl2.prettyName === decl2.prettyName && TypeScript.ArrayUtilities.sequenceEquals(decl1.amdDependencies, decl2.amdDependencies, TypeScript.StringUtilities.stringEquals); - }; - PullDeclDiffer.emptyDeclArray = []; - return PullDeclDiffer; - })(); - TypeScript.PullDeclDiffer = PullDeclDiffer; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - TypeScript.declCacheHit = 0; - TypeScript.declCacheMiss = 0; - TypeScript.symbolCacheHit = 0; - TypeScript.symbolCacheMiss = 0; - - var SemanticInfo = (function () { - function SemanticInfo(compilationUnitPath) { - this.topLevelDecls = []; - this.topLevelSynthesizedDecls = []; - this.astDeclMap = new TypeScript.DataMap(); - this.declASTMap = new TypeScript.DataMap(); - this.syntaxElementDeclMap = new TypeScript.DataMap(); - this.declSyntaxElementMap = new TypeScript.DataMap(); - this.astSymbolMap = new TypeScript.DataMap(); - this.symbolASTMap = new TypeScript.DataMap(); - this.syntaxElementSymbolMap = new TypeScript.DataMap(); - this.symbolSyntaxElementMap = new TypeScript.DataMap(); - this.properties = new SemanticInfoProperties(); - this.hasBeenTypeChecked = false; - this.compilationUnitPath = compilationUnitPath; - } - SemanticInfo.prototype.addTopLevelDecl = function (decl) { - this.topLevelDecls[this.topLevelDecls.length] = decl; - }; - - SemanticInfo.prototype.setTypeChecked = function () { - this.hasBeenTypeChecked = true; - }; - SemanticInfo.prototype.getTypeChecked = function () { - return this.hasBeenTypeChecked; - }; - SemanticInfo.prototype.invalidate = function () { - this.astSymbolMap = new TypeScript.DataMap(); - this.symbolASTMap = new TypeScript.DataMap(); - }; - - SemanticInfo.prototype.getTopLevelDecls = function () { - return this.topLevelDecls; - }; - - SemanticInfo.prototype.getPath = function () { - return this.compilationUnitPath; - }; - - SemanticInfo.prototype.addSynthesizedDecl = function (decl) { - this.topLevelSynthesizedDecls[this.topLevelSynthesizedDecls.length] = decl; - }; - SemanticInfo.prototype.getSynthesizedDecls = function () { - return this.topLevelSynthesizedDecls; - }; - - SemanticInfo.prototype.getDeclForAST = function (ast) { - return this.astDeclMap.read(ast.getID().toString()); - }; - - SemanticInfo.prototype.setDeclForAST = function (ast, decl) { - this.astDeclMap.link(ast.getID().toString(), decl); - }; - - SemanticInfo.prototype.getDeclKey = function (decl) { - var decl1 = decl; - - if (!decl1.__declKey) { - decl1.__declKey = decl.getDeclID().toString() + "-" + decl.getKind().toString(); - } - - return decl1.__declKey; - }; - - SemanticInfo.prototype.getASTForDecl = function (decl) { - return this.declASTMap.read(this.getDeclKey(decl)); - }; - - SemanticInfo.prototype.setASTForDecl = function (decl, ast) { - this.declASTMap.link(this.getDeclKey(decl), ast); - }; - - SemanticInfo.prototype.setSymbolAndDiagnosticsForAST = function (ast, symbolAndDiagnostics) { - this.astSymbolMap.link(ast.getID().toString(), symbolAndDiagnostics); - this.symbolASTMap.link(symbolAndDiagnostics.symbol.getSymbolID().toString(), ast); - }; - - SemanticInfo.prototype.getSymbolAndDiagnosticsForAST = function (ast) { - return this.astSymbolMap.read(ast.getID().toString()); - }; - - SemanticInfo.prototype.getASTForSymbol = function (symbol) { - return this.symbolASTMap.read(symbol.getSymbolID().toString()); - }; - - SemanticInfo.prototype.getSyntaxElementForDecl = function (decl) { - return this.declSyntaxElementMap.read(this.getDeclKey(decl)); - }; - - SemanticInfo.prototype.setSyntaxElementForDecl = function (decl, syntaxElement) { - this.declSyntaxElementMap.link(this.getDeclKey(decl), syntaxElement); - }; - - SemanticInfo.prototype.getDeclForSyntaxElement = function (syntaxElement) { - return this.syntaxElementDeclMap.read(TypeScript.Collections.identityHashCode(syntaxElement).toString()); - }; - - SemanticInfo.prototype.setDeclForSyntaxElement = function (syntaxElement, decl) { - this.syntaxElementDeclMap.link(TypeScript.Collections.identityHashCode(syntaxElement).toString(), decl); - }; - - SemanticInfo.prototype.getSyntaxElementForSymbol = function (symbol) { - return this.symbolSyntaxElementMap.read(symbol.getSymbolID().toString()); - }; - - SemanticInfo.prototype.getSymbolForSyntaxElement = function (syntaxElement) { - return this.syntaxElementSymbolMap.read(TypeScript.Collections.identityHashCode(syntaxElement).toString()); - }; - - SemanticInfo.prototype.setSymbolForSyntaxElement = function (syntaxElement, symbol) { - this.syntaxElementSymbolMap.link(TypeScript.Collections.identityHashCode(syntaxElement).toString(), symbol); - this.symbolSyntaxElementMap.link(symbol.getSymbolID().toString(), syntaxElement); - }; - - SemanticInfo.prototype.getDiagnostics = function (semanticErrors) { - for (var i = 0; i < this.topLevelDecls.length; i++) { - TypeScript.getDiagnosticsFromEnclosingDecl(this.topLevelDecls[i], semanticErrors); - } - }; - - SemanticInfo.prototype.getProperties = function () { - return this.properties; - }; - return SemanticInfo; - })(); - TypeScript.SemanticInfo = SemanticInfo; - - var SemanticInfoProperties = (function () { - function SemanticInfoProperties() { - this.unitContainsBool = false; - } - return SemanticInfoProperties; - })(); - TypeScript.SemanticInfoProperties = SemanticInfoProperties; - - var SemanticInfoChain = (function () { - function SemanticInfoChain() { - this.units = [new SemanticInfo("")]; - this.declCache = new TypeScript.BlockIntrinsics(); - this.symbolCache = new TypeScript.BlockIntrinsics(); - this.unitCache = new TypeScript.BlockIntrinsics(); - this.declSymbolMap = new TypeScript.DataMap(); - this.anyTypeSymbol = null; - this.booleanTypeSymbol = null; - this.numberTypeSymbol = null; - this.stringTypeSymbol = null; - this.nullTypeSymbol = null; - this.undefinedTypeSymbol = null; - this.elementTypeSymbol = null; - this.voidTypeSymbol = null; - if (TypeScript.globalBinder) { - TypeScript.globalBinder.semanticInfoChain = this; - } - - var globalDecl = this.getGlobalDecl(); - var globalInfo = this.units[0]; - globalInfo.addTopLevelDecl(globalDecl); - } - SemanticInfoChain.prototype.addPrimitiveType = function (name, globalDecl) { - var span = new TypeScript.TextSpan(0, 0); - var decl = new TypeScript.PullDecl(name, name, 2 /* Primitive */, 0 /* None */, span, ""); - var symbol = new TypeScript.PullPrimitiveTypeSymbol(name); - - symbol.addDeclaration(decl); - decl.setSymbol(symbol); - - symbol.setResolved(); - - if (globalDecl) { - globalDecl.addChildDecl(decl); - } - - return symbol; - }; - - SemanticInfoChain.prototype.addPrimitiveValue = function (name, type, globalDecl) { - var span = new TypeScript.TextSpan(0, 0); - var decl = new TypeScript.PullDecl(name, name, 1024 /* Variable */, 8 /* Ambient */, span, ""); - var symbol = new TypeScript.PullSymbol(name, 1024 /* Variable */); - - symbol.addDeclaration(decl); - decl.setSymbol(symbol); - symbol.setType(type); - symbol.setResolved(); - - globalDecl.addChildDecl(decl); - }; - - SemanticInfoChain.prototype.getGlobalDecl = function () { - var span = new TypeScript.TextSpan(0, 0); - var globalDecl = new TypeScript.PullDecl("", "", 0 /* Global */, 0 /* None */, span, ""); - - this.anyTypeSymbol = this.addPrimitiveType("any", globalDecl); - this.booleanTypeSymbol = this.addPrimitiveType("boolean", globalDecl); - this.numberTypeSymbol = this.addPrimitiveType("number", globalDecl); - this.stringTypeSymbol = this.addPrimitiveType("string", globalDecl); - this.voidTypeSymbol = this.addPrimitiveType("void", globalDecl); - this.elementTypeSymbol = this.addPrimitiveType("_element", globalDecl); - - this.nullTypeSymbol = this.addPrimitiveType("null", null); - this.undefinedTypeSymbol = this.addPrimitiveType("undefined", null); - this.addPrimitiveValue("undefined", this.undefinedTypeSymbol, globalDecl); - this.addPrimitiveValue("null", this.nullTypeSymbol, globalDecl); - - return globalDecl; - }; - - SemanticInfoChain.prototype.addUnit = function (unit) { - this.units[this.units.length] = unit; - this.unitCache[unit.getPath()] = unit; - }; - - SemanticInfoChain.prototype.getUnit = function (compilationUnitPath) { - for (var i = 0; i < this.units.length; i++) { - if (this.units[i].getPath() === compilationUnitPath) { - return this.units[i]; - } - } - - return null; - }; - - SemanticInfoChain.prototype.updateUnit = function (oldUnit, newUnit) { - for (var i = 0; i < this.units.length; i++) { - if (this.units[i].getPath() === oldUnit.getPath()) { - this.units[i] = newUnit; - this.unitCache[oldUnit.getPath()] = newUnit; - return; - } - } - }; - - SemanticInfoChain.prototype.collectAllTopLevelDecls = function () { - var decls = []; - var unitDecls; - - for (var i = 0; i < this.units.length; i++) { - unitDecls = this.units[i].getTopLevelDecls(); - for (var j = 0; j < unitDecls.length; j++) { - decls[decls.length] = unitDecls[j]; - } - } - - return decls; - }; - - SemanticInfoChain.prototype.collectAllSynthesizedDecls = function () { - var decls = []; - var synthDecls; - - for (var i = 0; i < this.units.length; i++) { - synthDecls = this.units[i].getSynthesizedDecls(); - for (var j = 0; j < synthDecls.length; j++) { - decls[decls.length] = synthDecls[j]; - } - } - - return decls; - }; - - SemanticInfoChain.prototype.getDeclPathCacheID = function (declPath, declKind) { - var cacheID = ""; - - for (var i = 0; i < declPath.length; i++) { - cacheID += "#" + declPath[i]; - } - - return cacheID + "#" + declKind.toString(); - }; - - SemanticInfoChain.prototype.findDecls = function (declPath, declKind) { - var cacheID = this.getDeclPathCacheID(declPath, declKind); - - if (declPath.length) { - var cachedDecls = this.declCache[cacheID]; - - if (cachedDecls && cachedDecls.length) { - TypeScript.declCacheHit++; - return cachedDecls; - } - } - - TypeScript.declCacheMiss++; - - var declsToSearch = this.collectAllTopLevelDecls(); - - var decls = []; - var path; - var foundDecls = []; - var keepSearching = (declKind & 4 /* Container */) || (declKind & 16 /* Interface */); - - for (var i = 0; i < declPath.length; i++) { - path = declPath[i]; - decls = []; - - for (var j = 0; j < declsToSearch.length; j++) { - foundDecls = declsToSearch[j].searchChildDecls(path, declKind); - - for (var k = 0; k < foundDecls.length; k++) { - decls[decls.length] = foundDecls[k]; - } - - if (foundDecls.length && !keepSearching) { - break; - } - } - - declsToSearch = decls; - - if (!declsToSearch) { - break; - } - } - - if (decls.length) { - this.declCache[cacheID] = decls; - } - - return decls; - }; - - SemanticInfoChain.prototype.findSymbol = function (declPath, declType) { - var cacheID = this.getDeclPathCacheID(declPath, declType); - - if (declPath.length) { - var cachedSymbol = this.symbolCache[cacheID]; - - if (cachedSymbol) { - TypeScript.symbolCacheHit++; - return cachedSymbol; - } - } - - TypeScript.symbolCacheMiss++; - - var decls = this.findDecls(declPath, declType); - var symbol = null; - - if (decls.length) { - symbol = decls[0].getSymbol(); - - if (symbol) { - this.symbolCache[cacheID] = symbol; - - symbol.addCacheID(cacheID); - } - } - - return symbol; - }; - - SemanticInfoChain.prototype.cacheGlobalSymbol = function (symbol, kind) { - var cacheID1 = this.getDeclPathCacheID([symbol.getName()], kind); - var cacheID2 = this.getDeclPathCacheID([symbol.getName()], symbol.getKind()); - - if (!this.symbolCache[cacheID1]) { - this.symbolCache[cacheID1] = symbol; - symbol.addCacheID(cacheID1); - } - - if (!this.symbolCache[cacheID2]) { - this.symbolCache[cacheID2] = symbol; - symbol.addCacheID(cacheID2); - } - }; - - SemanticInfoChain.prototype.cleanDecl = function (decl) { - decl.setSymbol(null); - decl.setSignatureSymbol(null); - decl.setSpecializingSignatureSymbol(null); - decl.setIsBound(false); - - var children = decl.getChildDecls(); - - for (var i = 0; i < children.length; i++) { - this.cleanDecl(children[i]); - } - - var typeParameters = decl.getTypeParameters(); - - for (var i = 0; i < typeParameters.length; i++) { - this.cleanDecl(typeParameters[i]); - } - - var valueDecl = decl.getValueDecl(); - - if (valueDecl) { - this.cleanDecl(valueDecl); - } - }; - - SemanticInfoChain.prototype.cleanAllDecls = function () { - var topLevelDecls = this.collectAllTopLevelDecls(); - - for (var i = 1; i < topLevelDecls.length; i++) { - this.cleanDecl(topLevelDecls[i]); - } - - var synthesizedDecls = this.collectAllSynthesizedDecls(); - - for (var i = 0; i < synthesizedDecls.length; i++) { - this.cleanDecl(synthesizedDecls[i]); - } - }; - - SemanticInfoChain.prototype.update = function () { - this.declCache = new TypeScript.BlockIntrinsics(); - this.symbolCache = new TypeScript.BlockIntrinsics(); - this.units[0] = new SemanticInfo(""); - this.units[0].addTopLevelDecl(this.getGlobalDecl()); - this.cleanAllDecls(); - - for (var unit in this.unitCache) { - if (this.unitCache[unit]) { - this.unitCache[unit].invalidate(); - } - } - }; - - SemanticInfoChain.prototype.invalidateUnit = function (compilationUnitPath) { - var unit = this.unitCache[compilationUnitPath]; - if (unit) { - unit.invalidate(); - } - }; - - SemanticInfoChain.prototype.getDeclForAST = function (ast, unitPath) { - var unit = this.unitCache[unitPath]; - - if (unit) { - return unit.getDeclForAST(ast); - } - - return null; - }; - - SemanticInfoChain.prototype.getASTForDecl = function (decl) { - var unit = this.unitCache[decl.getScriptName()]; - - if (unit) { - return unit.getASTForDecl(decl); - } - - return null; - }; - - SemanticInfoChain.prototype.getSymbolAndDiagnosticsForAST = function (ast, unitPath) { - var unit = this.unitCache[unitPath]; - - if (unit) { - return unit.getSymbolAndDiagnosticsForAST(ast); - } - - return null; - }; - - SemanticInfoChain.prototype.getASTForSymbol = function (symbol, unitPath) { - var unit = this.unitCache[unitPath]; - - if (unit) { - return unit.getASTForSymbol(symbol); - } - - return null; - }; - - SemanticInfoChain.prototype.setSymbolAndDiagnosticsForAST = function (ast, symbolAndDiagnostics, unitPath) { - var unit = this.unitCache[unitPath]; - - if (unit) { - unit.setSymbolAndDiagnosticsForAST(ast, symbolAndDiagnostics); - } - }; - - SemanticInfoChain.prototype.setSymbolForDecl = function (decl, symbol) { - this.declSymbolMap.link(decl.getDeclID().toString(), symbol); - }; - SemanticInfoChain.prototype.getSymbolForDecl = function (decl) { - return this.declSymbolMap.read(decl.getDeclID().toString()); - }; - - SemanticInfoChain.prototype.removeSymbolFromCache = function (symbol) { - var path = [symbol.getName()]; - var kind = (symbol.getKind() & TypeScript.PullElementKind.SomeType) !== 0 ? TypeScript.PullElementKind.SomeType : TypeScript.PullElementKind.SomeValue; - - var kindID = this.getDeclPathCacheID(path, kind); - var symID = this.getDeclPathCacheID(path, symbol.getKind()); - - symbol.addCacheID(kindID); - symbol.addCacheID(symID); - - symbol.invalidateCachedIDs(this.symbolCache); - }; - - SemanticInfoChain.prototype.postDiagnostics = function () { - var errors = []; - - for (var i = 1; i < this.units.length; i++) { - this.units[i].getDiagnostics(errors); - } - - return errors; - }; - return SemanticInfoChain; - })(); - TypeScript.SemanticInfoChain = SemanticInfoChain; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var DeclCollectionContext = (function () { - function DeclCollectionContext(semanticInfo, scriptName) { - if (typeof scriptName === "undefined") { scriptName = ""; } - this.semanticInfo = semanticInfo; - this.scriptName = scriptName; - this.parentChain = []; - this.foundValueDecl = false; - } - DeclCollectionContext.prototype.getParent = function () { - return this.parentChain ? this.parentChain[this.parentChain.length - 1] : null; - }; - - DeclCollectionContext.prototype.pushParent = function (parentDecl) { - if (parentDecl) { - this.parentChain[this.parentChain.length] = parentDecl; - } - }; - - DeclCollectionContext.prototype.popParent = function () { - this.parentChain.length--; - }; - return DeclCollectionContext; - })(); - TypeScript.DeclCollectionContext = DeclCollectionContext; - - function preCollectImportDecls(ast, parentAST, context) { - var importDecl = ast; - var declFlags = 0 /* None */; - var span = TypeScript.TextSpan.fromBounds(importDecl.minChar, importDecl.limChar); - - var parent = context.getParent(); - - if (parent && (parent.getKind() === 536870912 /* WithBlock */ || (parent.getFlags() & 2097152 /* DeclaredInAWithBlock */))) { - declFlags |= 2097152 /* DeclaredInAWithBlock */; - } - - var decl = new TypeScript.PullDecl(importDecl.id.text, importDecl.id.actualText, 256 /* TypeAlias */, declFlags, span, context.scriptName); - context.semanticInfo.setDeclForAST(ast, decl); - context.semanticInfo.setASTForDecl(decl, ast); - - parent.addChildDecl(decl); - decl.setParentDecl(parent); - - return false; - } - TypeScript.preCollectImportDecls = preCollectImportDecls; - - function preCollectModuleDecls(ast, parentAST, context) { - var moduleDecl = ast; - var declFlags = 0 /* None */; - var modName = (moduleDecl.name).text; - var isDynamic = TypeScript.isQuoted(modName) || TypeScript.hasFlag(moduleDecl.getModuleFlags(), 512 /* IsDynamic */); - var kind = 4 /* Container */; - - if (TypeScript.hasFlag(moduleDecl.getModuleFlags(), 8 /* Ambient */)) { - declFlags |= 8 /* Ambient */; - } - - if (TypeScript.hasFlag(moduleDecl.getModuleFlags(), 1 /* Exported */)) { - declFlags |= 1 /* Exported */; - } - - if (TypeScript.hasFlag(moduleDecl.getModuleFlags(), 128 /* IsEnum */)) { - declFlags |= (4096 /* Enum */ | 131072 /* InitializedEnum */); - kind = 64 /* Enum */; - } else { - kind = isDynamic ? 32 /* DynamicModule */ : 4 /* Container */; - } - - var span = TypeScript.TextSpan.fromBounds(moduleDecl.minChar, moduleDecl.limChar); - - var decl = new TypeScript.PullDecl(modName, (moduleDecl.name).actualText, kind, declFlags, span, context.scriptName); - context.semanticInfo.setDeclForAST(ast, decl); - context.semanticInfo.setASTForDecl(decl, ast); - - var parent = context.getParent(); - parent.addChildDecl(decl); - decl.setParentDecl(parent); - - context.pushParent(decl); - - return true; - } - TypeScript.preCollectModuleDecls = preCollectModuleDecls; - - function preCollectClassDecls(classDecl, parentAST, context) { - var declFlags = 0 /* None */; - var constructorDeclKind = 1024 /* Variable */; - - if (TypeScript.hasFlag(classDecl.getVarFlags(), 8 /* Ambient */)) { - declFlags |= 8 /* Ambient */; - } - - if (TypeScript.hasFlag(classDecl.getVarFlags(), 1 /* Exported */)) { - declFlags |= 1 /* Exported */; - } - - var span = TypeScript.TextSpan.fromBounds(classDecl.minChar, classDecl.limChar); - - var decl = new TypeScript.PullDecl(classDecl.name.text, classDecl.name.actualText, 8 /* Class */, declFlags, span, context.scriptName); - - var constructorDecl = new TypeScript.PullDecl(classDecl.name.text, classDecl.name.actualText, constructorDeclKind, declFlags | 16384 /* ClassConstructorVariable */, span, context.scriptName); - - decl.setValueDecl(constructorDecl); - - var parent = context.getParent(); - parent.addChildDecl(decl); - parent.addChildDecl(constructorDecl); - decl.setParentDecl(parent); - constructorDecl.setParentDecl(parent); - - context.pushParent(decl); - - context.semanticInfo.setDeclForAST(classDecl, decl); - context.semanticInfo.setASTForDecl(decl, classDecl); - context.semanticInfo.setASTForDecl(constructorDecl, classDecl); - - return true; - } - TypeScript.preCollectClassDecls = preCollectClassDecls; - - function createObjectTypeDeclaration(interfaceDecl, context) { - var declFlags = 0 /* None */; - - var span = TypeScript.TextSpan.fromBounds(interfaceDecl.minChar, interfaceDecl.limChar); - - var parent = context.getParent(); - - if (parent && (parent.getKind() === 536870912 /* WithBlock */ || (parent.getFlags() & 2097152 /* DeclaredInAWithBlock */))) { - declFlags |= 2097152 /* DeclaredInAWithBlock */; - } - - var decl = new TypeScript.PullDecl("", "", 8388608 /* ObjectType */, declFlags, span, context.scriptName); - context.semanticInfo.setDeclForAST(interfaceDecl, decl); - context.semanticInfo.setASTForDecl(decl, interfaceDecl); - - if (parent) { - parent.addChildDecl(decl); - decl.setParentDecl(parent); - } - - context.pushParent(decl); - - return true; - } - TypeScript.createObjectTypeDeclaration = createObjectTypeDeclaration; - - function preCollectInterfaceDecls(interfaceDecl, parentAST, context) { - var declFlags = 0 /* None */; - - if (interfaceDecl.getFlags() & 8 /* TypeReference */) { - return createObjectTypeDeclaration(interfaceDecl, context); - } - - if (TypeScript.hasFlag(interfaceDecl.getVarFlags(), 1 /* Exported */)) { - declFlags |= 1 /* Exported */; - } - - var span = TypeScript.TextSpan.fromBounds(interfaceDecl.minChar, interfaceDecl.limChar); - - var decl = new TypeScript.PullDecl(interfaceDecl.name.text, interfaceDecl.name.actualText, 16 /* Interface */, declFlags, span, context.scriptName); - context.semanticInfo.setDeclForAST(interfaceDecl, decl); - context.semanticInfo.setASTForDecl(decl, interfaceDecl); - - var parent = context.getParent(); - - if (parent) { - parent.addChildDecl(decl); - decl.setParentDecl(parent); - } - - context.pushParent(decl); - - return true; - } - TypeScript.preCollectInterfaceDecls = preCollectInterfaceDecls; - - function preCollectParameterDecl(argDecl, parentAST, context) { - var declFlags = 0 /* None */; - - if (TypeScript.hasFlag(argDecl.getVarFlags(), 2 /* Private */)) { - declFlags |= 2 /* Private */; - } else { - declFlags |= 4 /* Public */; - } - - if (TypeScript.hasFlag(argDecl.getFlags(), 4 /* OptionalName */) || TypeScript.hasFlag(argDecl.id.getFlags(), 4 /* OptionalName */)) { - declFlags |= 128 /* Optional */; - } - - var parent = context.getParent(); - - if (parent && (parent.getKind() === 536870912 /* WithBlock */ || (parent.getFlags() & 2097152 /* DeclaredInAWithBlock */))) { - declFlags |= 2097152 /* DeclaredInAWithBlock */; - } - - var span = TypeScript.TextSpan.fromBounds(argDecl.minChar, argDecl.limChar); - - var decl = new TypeScript.PullDecl(argDecl.id.text, argDecl.id.actualText, 2048 /* Parameter */, declFlags, span, context.scriptName); - - parent.addChildDecl(decl); - decl.setParentDecl(parent); - - if (TypeScript.hasFlag(argDecl.getVarFlags(), 256 /* Property */)) { - var propDecl = new TypeScript.PullDecl(argDecl.id.text, argDecl.id.actualText, 4096 /* Property */, declFlags, span, context.scriptName); - propDecl.setValueDecl(decl); - context.parentChain[context.parentChain.length - 2].addChildDecl(propDecl); - propDecl.setParentDecl(context.parentChain[context.parentChain.length - 2]); - context.semanticInfo.setASTForDecl(decl, argDecl); - context.semanticInfo.setASTForDecl(propDecl, argDecl); - context.semanticInfo.setDeclForAST(argDecl, propDecl); - } else { - context.semanticInfo.setASTForDecl(decl, argDecl); - context.semanticInfo.setDeclForAST(argDecl, decl); - } - - if (argDecl.typeExpr && ((argDecl.typeExpr).term.nodeType === 14 /* InterfaceDeclaration */ || (argDecl.typeExpr).term.nodeType === 12 /* FunctionDeclaration */)) { - var declCollectionContext = new DeclCollectionContext(context.semanticInfo); - - if (parent) { - declCollectionContext.pushParent(parent); - } - - declCollectionContext.scriptName = context.scriptName; - - TypeScript.getAstWalkerFactory().walk((argDecl.typeExpr).term, preCollectDecls, postCollectDecls, null, declCollectionContext); - } - - return false; - } - TypeScript.preCollectParameterDecl = preCollectParameterDecl; - - function preCollectTypeParameterDecl(typeParameterDecl, parentAST, context) { - var declFlags = 0 /* None */; - - var span = TypeScript.TextSpan.fromBounds(typeParameterDecl.minChar, typeParameterDecl.limChar); - - var parent = context.getParent(); - - if (parent && (parent.getKind() === 536870912 /* WithBlock */ || (parent.getFlags() & 2097152 /* DeclaredInAWithBlock */))) { - declFlags |= 2097152 /* DeclaredInAWithBlock */; - } - - var decl = new TypeScript.PullDecl(typeParameterDecl.name.text, typeParameterDecl.name.actualText, 8192 /* TypeParameter */, declFlags, span, context.scriptName); - context.semanticInfo.setASTForDecl(decl, typeParameterDecl); - context.semanticInfo.setDeclForAST(typeParameterDecl, decl); - - parent.addChildDecl(decl); - decl.setParentDecl(parent); - - if (typeParameterDecl.constraint && ((typeParameterDecl.constraint).term.nodeType === 14 /* InterfaceDeclaration */ || (typeParameterDecl.constraint).term.nodeType === 12 /* FunctionDeclaration */)) { - var declCollectionContext = new DeclCollectionContext(context.semanticInfo); - - if (parent) { - declCollectionContext.pushParent(parent); - } - - declCollectionContext.scriptName = context.scriptName; - - TypeScript.getAstWalkerFactory().walk((typeParameterDecl.constraint).term, preCollectDecls, postCollectDecls, null, declCollectionContext); - } - - return true; - } - TypeScript.preCollectTypeParameterDecl = preCollectTypeParameterDecl; - - function createPropertySignature(propertyDecl, context) { - var declFlags = 4 /* Public */; - var parent = context.getParent(); - var declType = parent.getKind() === 64 /* Enum */ ? 67108864 /* EnumMember */ : 4096 /* Property */; - - if (TypeScript.hasFlag(propertyDecl.id.getFlags(), 4 /* OptionalName */)) { - declFlags |= 128 /* Optional */; - } - - if (TypeScript.hasFlag(propertyDecl.getVarFlags(), 4096 /* Constant */)) { - declFlags |= 524288 /* Constant */; - } - - var span = TypeScript.TextSpan.fromBounds(propertyDecl.minChar, propertyDecl.limChar); - - var decl = new TypeScript.PullDecl(propertyDecl.id.text, propertyDecl.id.actualText, declType, declFlags, span, context.scriptName); - context.semanticInfo.setDeclForAST(propertyDecl, decl); - context.semanticInfo.setASTForDecl(decl, propertyDecl); - - parent.addChildDecl(decl); - decl.setParentDecl(parent); - - if (propertyDecl.typeExpr && ((propertyDecl.typeExpr).term.nodeType === 14 /* InterfaceDeclaration */ || (propertyDecl.typeExpr).term.nodeType === 12 /* FunctionDeclaration */)) { - var declCollectionContext = new DeclCollectionContext(context.semanticInfo); - - if (parent) { - declCollectionContext.pushParent(parent); - } - - declCollectionContext.scriptName = context.scriptName; - - TypeScript.getAstWalkerFactory().walk((propertyDecl.typeExpr).term, preCollectDecls, postCollectDecls, null, declCollectionContext); - } - - return false; - } - TypeScript.createPropertySignature = createPropertySignature; - - function createMemberVariableDeclaration(memberDecl, context) { - var declFlags = 0 /* None */; - var declType = 4096 /* Property */; - - if (TypeScript.hasFlag(memberDecl.getVarFlags(), 2 /* Private */)) { - declFlags |= 2 /* Private */; - } else { - declFlags |= 4 /* Public */; - } - - if (TypeScript.hasFlag(memberDecl.getVarFlags(), 16 /* Static */)) { - declFlags |= 16 /* Static */; - } - - var span = TypeScript.TextSpan.fromBounds(memberDecl.minChar, memberDecl.limChar); - - var decl = new TypeScript.PullDecl(memberDecl.id.text, memberDecl.id.actualText, declType, declFlags, span, context.scriptName); - context.semanticInfo.setDeclForAST(memberDecl, decl); - context.semanticInfo.setASTForDecl(decl, memberDecl); - - var parent = context.getParent(); - parent.addChildDecl(decl); - decl.setParentDecl(parent); - - if (memberDecl.typeExpr && ((memberDecl.typeExpr).term.nodeType === 14 /* InterfaceDeclaration */ || (memberDecl.typeExpr).term.nodeType === 12 /* FunctionDeclaration */)) { - var declCollectionContext = new DeclCollectionContext(context.semanticInfo); - - if (parent) { - declCollectionContext.pushParent(parent); - } - - declCollectionContext.scriptName = context.scriptName; - - TypeScript.getAstWalkerFactory().walk((memberDecl.typeExpr).term, preCollectDecls, postCollectDecls, null, declCollectionContext); - } - - return false; - } - TypeScript.createMemberVariableDeclaration = createMemberVariableDeclaration; - - function createVariableDeclaration(varDecl, context) { - var declFlags = 0 /* None */; - var declType = 1024 /* Variable */; - - if (TypeScript.hasFlag(varDecl.getVarFlags(), 8 /* Ambient */)) { - declFlags |= 8 /* Ambient */; - } - - if (TypeScript.hasFlag(varDecl.getVarFlags(), 1 /* Exported */)) { - declFlags |= 1 /* Exported */; - } - - var span = TypeScript.TextSpan.fromBounds(varDecl.minChar, varDecl.limChar); - - var parent = context.getParent(); - - if (parent && (parent.getKind() === 536870912 /* WithBlock */ || (parent.getFlags() & 2097152 /* DeclaredInAWithBlock */))) { - declFlags |= 2097152 /* DeclaredInAWithBlock */; - } - - var decl = new TypeScript.PullDecl(varDecl.id.text, varDecl.id.actualText, declType, declFlags, span, context.scriptName); - context.semanticInfo.setDeclForAST(varDecl, decl); - context.semanticInfo.setASTForDecl(decl, varDecl); - - parent.addChildDecl(decl); - decl.setParentDecl(parent); - - if (varDecl.typeExpr && ((varDecl.typeExpr).term.nodeType === 14 /* InterfaceDeclaration */ || (varDecl.typeExpr).term.nodeType === 12 /* FunctionDeclaration */)) { - var declCollectionContext = new DeclCollectionContext(context.semanticInfo); - - if (parent) { - declCollectionContext.pushParent(parent); - } - - declCollectionContext.scriptName = context.scriptName; - - TypeScript.getAstWalkerFactory().walk((varDecl.typeExpr).term, preCollectDecls, postCollectDecls, null, declCollectionContext); - } - - return false; - } - TypeScript.createVariableDeclaration = createVariableDeclaration; - - function preCollectVarDecls(ast, parentAST, context) { - var varDecl = ast; - var declFlags = 0 /* None */; - var declType = 1024 /* Variable */; - var isProperty = false; - var isStatic = false; - - if (TypeScript.hasFlag(varDecl.getVarFlags(), 2048 /* ClassProperty */)) { - return createMemberVariableDeclaration(varDecl, context); - } else if (TypeScript.hasFlag(varDecl.getVarFlags(), 256 /* Property */)) { - return createPropertySignature(varDecl, context); - } - - return createVariableDeclaration(varDecl, context); - } - TypeScript.preCollectVarDecls = preCollectVarDecls; - - function createFunctionTypeDeclaration(functionTypeDeclAST, context) { - var declFlags = 2048 /* Signature */; - var declType = 16777216 /* FunctionType */; - - var span = TypeScript.TextSpan.fromBounds(functionTypeDeclAST.minChar, functionTypeDeclAST.limChar); - - var parent = context.getParent(); - - if (parent && (parent.getKind() === 536870912 /* WithBlock */ || (parent.getFlags() & 2097152 /* DeclaredInAWithBlock */))) { - declFlags |= 2097152 /* DeclaredInAWithBlock */; - } - - var decl = new TypeScript.PullDecl("", "", declType, declFlags, span, context.semanticInfo.getPath()); - context.semanticInfo.setDeclForAST(functionTypeDeclAST, decl); - context.semanticInfo.setASTForDecl(decl, functionTypeDeclAST); - - if (parent) { - parent.addChildDecl(decl); - decl.setParentDecl(parent); - } - - context.pushParent(decl); - - if (functionTypeDeclAST.returnTypeAnnotation && ((functionTypeDeclAST.returnTypeAnnotation).term.nodeType === 14 /* InterfaceDeclaration */ || (functionTypeDeclAST.returnTypeAnnotation).term.nodeType === 12 /* FunctionDeclaration */)) { - var declCollectionContext = new DeclCollectionContext(context.semanticInfo); - - if (parent) { - declCollectionContext.pushParent(parent); - } - - declCollectionContext.scriptName = context.scriptName; - - TypeScript.getAstWalkerFactory().walk((functionTypeDeclAST.returnTypeAnnotation).term, preCollectDecls, postCollectDecls, null, declCollectionContext); - } - - return true; - } - TypeScript.createFunctionTypeDeclaration = createFunctionTypeDeclaration; - - function createConstructorTypeDeclaration(constructorTypeDeclAST, context) { - var declFlags = 0 /* None */; - var declType = 33554432 /* ConstructorType */; - - var span = TypeScript.TextSpan.fromBounds(constructorTypeDeclAST.minChar, constructorTypeDeclAST.limChar); - - var parent = context.getParent(); - - if (parent && (parent.getKind() === 536870912 /* WithBlock */ || (parent.getFlags() & 2097152 /* DeclaredInAWithBlock */))) { - declFlags |= 2097152 /* DeclaredInAWithBlock */; - } - - var decl = new TypeScript.PullDecl("{new}", "{new}", declType, declFlags, span, context.semanticInfo.getPath()); - context.semanticInfo.setDeclForAST(constructorTypeDeclAST, decl); - context.semanticInfo.setASTForDecl(decl, constructorTypeDeclAST); - - if (parent) { - parent.addChildDecl(decl); - decl.setParentDecl(parent); - } - - context.pushParent(decl); - - if (constructorTypeDeclAST.returnTypeAnnotation && ((constructorTypeDeclAST.returnTypeAnnotation).term.nodeType === 14 /* InterfaceDeclaration */ || (constructorTypeDeclAST.returnTypeAnnotation).term.nodeType === 12 /* FunctionDeclaration */)) { - var declCollectionContext = new DeclCollectionContext(context.semanticInfo); - - if (parent) { - declCollectionContext.pushParent(parent); - } - - declCollectionContext.scriptName = context.scriptName; - - TypeScript.getAstWalkerFactory().walk((constructorTypeDeclAST.returnTypeAnnotation).term, preCollectDecls, postCollectDecls, null, declCollectionContext); - } - - return true; - } - TypeScript.createConstructorTypeDeclaration = createConstructorTypeDeclaration; - - function createFunctionDeclaration(funcDeclAST, context) { - var declFlags = 0 /* None */; - var declType = 16384 /* Function */; - - if (TypeScript.hasFlag(funcDeclAST.getFunctionFlags(), 8 /* Ambient */)) { - declFlags |= 8 /* Ambient */; - } - - if (TypeScript.hasFlag(funcDeclAST.getFunctionFlags(), 1 /* Exported */)) { - declFlags |= 1 /* Exported */; - } - - if (!funcDeclAST.block) { - declFlags |= 2048 /* Signature */; - } - - var span = TypeScript.TextSpan.fromBounds(funcDeclAST.minChar, funcDeclAST.limChar); - - var parent = context.getParent(); - - if (parent && (parent.getKind() === 536870912 /* WithBlock */ || (parent.getFlags() & 2097152 /* DeclaredInAWithBlock */))) { - declFlags |= 2097152 /* DeclaredInAWithBlock */; - } - - var decl = new TypeScript.PullDecl(funcDeclAST.name.text, funcDeclAST.name.actualText, declType, declFlags, span, context.scriptName); - context.semanticInfo.setDeclForAST(funcDeclAST, decl); - context.semanticInfo.setASTForDecl(decl, funcDeclAST); - - if (parent) { - parent.addChildDecl(decl); - decl.setParentDecl(parent); - } - - context.pushParent(decl); - - if (funcDeclAST.returnTypeAnnotation && ((funcDeclAST.returnTypeAnnotation).term.nodeType === 14 /* InterfaceDeclaration */ || (funcDeclAST.returnTypeAnnotation).term.nodeType === 12 /* FunctionDeclaration */)) { - var declCollectionContext = new DeclCollectionContext(context.semanticInfo); - - if (parent) { - declCollectionContext.pushParent(parent); - } - - declCollectionContext.scriptName = context.scriptName; - - TypeScript.getAstWalkerFactory().walk((funcDeclAST.returnTypeAnnotation).term, preCollectDecls, postCollectDecls, null, declCollectionContext); - } - - return true; - } - TypeScript.createFunctionDeclaration = createFunctionDeclaration; - - function createFunctionExpressionDeclaration(functionExpressionDeclAST, context) { - var declFlags = 0 /* None */; - - if (TypeScript.hasFlag(functionExpressionDeclAST.getFunctionFlags(), 2048 /* IsFatArrowFunction */)) { - declFlags |= 8192 /* FatArrow */; - } - - var span = TypeScript.TextSpan.fromBounds(functionExpressionDeclAST.minChar, functionExpressionDeclAST.limChar); - - var parent = context.getParent(); - - if (parent && (parent.getKind() === 536870912 /* WithBlock */ || (parent.getFlags() & 2097152 /* DeclaredInAWithBlock */))) { - declFlags |= 2097152 /* DeclaredInAWithBlock */; - } - - var name = functionExpressionDeclAST.name ? functionExpressionDeclAST.name.actualText : ""; - var decl = new TypeScript.PullFunctionExpressionDecl(name, declFlags, span, context.scriptName); - context.semanticInfo.setDeclForAST(functionExpressionDeclAST, decl); - context.semanticInfo.setASTForDecl(decl, functionExpressionDeclAST); - - if (parent) { - parent.addChildDecl(decl); - decl.setParentDecl(parent); - } - - context.pushParent(decl); - - if (functionExpressionDeclAST.returnTypeAnnotation && ((functionExpressionDeclAST.returnTypeAnnotation).term.nodeType === 14 /* InterfaceDeclaration */ || (functionExpressionDeclAST.returnTypeAnnotation).term.nodeType === 12 /* FunctionDeclaration */)) { - var declCollectionContext = new DeclCollectionContext(context.semanticInfo); - - declCollectionContext.scriptName = context.scriptName; - - if (parent) { - declCollectionContext.pushParent(parent); - } - - TypeScript.getAstWalkerFactory().walk((functionExpressionDeclAST.returnTypeAnnotation).term, preCollectDecls, postCollectDecls, null, declCollectionContext); - } - - return true; - } - TypeScript.createFunctionExpressionDeclaration = createFunctionExpressionDeclaration; - - function createMemberFunctionDeclaration(memberFunctionDeclAST, context) { - var declFlags = 0 /* None */; - var declType = 65536 /* Method */; - - if (TypeScript.hasFlag(memberFunctionDeclAST.getFunctionFlags(), 16 /* Static */)) { - declFlags |= 16 /* Static */; - } - - if (TypeScript.hasFlag(memberFunctionDeclAST.getFunctionFlags(), 2 /* Private */)) { - declFlags |= 2 /* Private */; - } else { - declFlags |= 4 /* Public */; - } - - if (!memberFunctionDeclAST.block) { - declFlags |= 2048 /* Signature */; - } - - if (TypeScript.hasFlag(memberFunctionDeclAST.name.getFlags(), 4 /* OptionalName */)) { - declFlags |= 128 /* Optional */; - } - - var span = TypeScript.TextSpan.fromBounds(memberFunctionDeclAST.minChar, memberFunctionDeclAST.limChar); - - var decl = new TypeScript.PullDecl(memberFunctionDeclAST.name.text, memberFunctionDeclAST.name.actualText, declType, declFlags, span, context.scriptName); - context.semanticInfo.setDeclForAST(memberFunctionDeclAST, decl); - context.semanticInfo.setASTForDecl(decl, memberFunctionDeclAST); - - var parent = context.getParent(); - - if (parent) { - parent.addChildDecl(decl); - decl.setParentDecl(parent); - } - - context.pushParent(decl); - - if (memberFunctionDeclAST.returnTypeAnnotation && ((memberFunctionDeclAST.returnTypeAnnotation).term.nodeType === 14 /* InterfaceDeclaration */ || (memberFunctionDeclAST.returnTypeAnnotation).term.nodeType === 12 /* FunctionDeclaration */)) { - var declCollectionContext = new DeclCollectionContext(context.semanticInfo); - - declCollectionContext.scriptName = context.scriptName; - - if (parent) { - declCollectionContext.pushParent(parent); - } - - TypeScript.getAstWalkerFactory().walk((memberFunctionDeclAST.returnTypeAnnotation).term, preCollectDecls, postCollectDecls, null, declCollectionContext); - } - - return true; - } - TypeScript.createMemberFunctionDeclaration = createMemberFunctionDeclaration; - - function createIndexSignatureDeclaration(indexSignatureDeclAST, context) { - var declFlags = 2048 /* Signature */ | 1024 /* Index */; - var declType = 4194304 /* IndexSignature */; - - var span = TypeScript.TextSpan.fromBounds(indexSignatureDeclAST.minChar, indexSignatureDeclAST.limChar); - - var parent = context.getParent(); - - if (parent && (parent.getKind() === 536870912 /* WithBlock */ || (parent.getFlags() & 2097152 /* DeclaredInAWithBlock */))) { - declFlags |= 2097152 /* DeclaredInAWithBlock */; - } - - var decl = new TypeScript.PullDecl("[]", "[]", declType, declFlags, span, context.scriptName); - context.semanticInfo.setDeclForAST(indexSignatureDeclAST, decl); - context.semanticInfo.setASTForDecl(decl, indexSignatureDeclAST); - - if (parent) { - parent.addChildDecl(decl); - decl.setParentDecl(parent); - } - - context.pushParent(decl); - - if (indexSignatureDeclAST.returnTypeAnnotation && ((indexSignatureDeclAST.returnTypeAnnotation).term.nodeType === 14 /* InterfaceDeclaration */ || (indexSignatureDeclAST.returnTypeAnnotation).term.nodeType === 12 /* FunctionDeclaration */)) { - var declCollectionContext = new DeclCollectionContext(context.semanticInfo); - - if (parent) { - declCollectionContext.pushParent(parent); - } - - declCollectionContext.scriptName = context.scriptName; - - TypeScript.getAstWalkerFactory().walk((indexSignatureDeclAST.returnTypeAnnotation).term, preCollectDecls, postCollectDecls, null, declCollectionContext); - } - - return true; - } - TypeScript.createIndexSignatureDeclaration = createIndexSignatureDeclaration; - - function createCallSignatureDeclaration(callSignatureDeclAST, context) { - var declFlags = 2048 /* Signature */ | 256 /* Call */; - var declType = 1048576 /* CallSignature */; - - var span = TypeScript.TextSpan.fromBounds(callSignatureDeclAST.minChar, callSignatureDeclAST.limChar); - - var parent = context.getParent(); - - if (parent && (parent.getKind() === 536870912 /* WithBlock */ || (parent.getFlags() & 2097152 /* DeclaredInAWithBlock */))) { - declFlags |= 2097152 /* DeclaredInAWithBlock */; - } - - var decl = new TypeScript.PullDecl("()", "()", declType, declFlags, span, context.scriptName); - context.semanticInfo.setDeclForAST(callSignatureDeclAST, decl); - context.semanticInfo.setASTForDecl(decl, callSignatureDeclAST); - - if (parent) { - parent.addChildDecl(decl); - decl.setParentDecl(parent); - } - - context.pushParent(decl); - - if (callSignatureDeclAST.returnTypeAnnotation && ((callSignatureDeclAST.returnTypeAnnotation).term.nodeType === 14 /* InterfaceDeclaration */ || (callSignatureDeclAST.returnTypeAnnotation).term.nodeType === 12 /* FunctionDeclaration */)) { - var declCollectionContext = new DeclCollectionContext(context.semanticInfo); - - declCollectionContext.scriptName = context.scriptName; - - if (parent) { - declCollectionContext.pushParent(parent); - } - - TypeScript.getAstWalkerFactory().walk((callSignatureDeclAST.returnTypeAnnotation).term, preCollectDecls, postCollectDecls, null, declCollectionContext); - } - - return true; - } - TypeScript.createCallSignatureDeclaration = createCallSignatureDeclaration; - - function createConstructSignatureDeclaration(constructSignatureDeclAST, context) { - var declFlags = 2048 /* Signature */ | 256 /* Call */; - var declType = 2097152 /* ConstructSignature */; - - var span = TypeScript.TextSpan.fromBounds(constructSignatureDeclAST.minChar, constructSignatureDeclAST.limChar); - - var parent = context.getParent(); - - if (parent && (parent.getKind() === 536870912 /* WithBlock */ || (parent.getFlags() & 2097152 /* DeclaredInAWithBlock */))) { - declFlags |= 2097152 /* DeclaredInAWithBlock */; - } - - var decl = new TypeScript.PullDecl("new", "new", declType, declFlags, span, context.scriptName); - context.semanticInfo.setDeclForAST(constructSignatureDeclAST, decl); - context.semanticInfo.setASTForDecl(decl, constructSignatureDeclAST); - - if (parent) { - parent.addChildDecl(decl); - decl.setParentDecl(parent); - } - - context.pushParent(decl); - - if (constructSignatureDeclAST.returnTypeAnnotation && ((constructSignatureDeclAST.returnTypeAnnotation).term.nodeType === 14 /* InterfaceDeclaration */ || (constructSignatureDeclAST.returnTypeAnnotation).term.nodeType === 12 /* FunctionDeclaration */)) { - var declCollectionContext = new DeclCollectionContext(context.semanticInfo); - - declCollectionContext.scriptName = context.scriptName; - - if (parent) { - declCollectionContext.pushParent(parent); - } - - TypeScript.getAstWalkerFactory().walk((constructSignatureDeclAST.returnTypeAnnotation).term, preCollectDecls, postCollectDecls, null, declCollectionContext); - } - - return true; - } - TypeScript.createConstructSignatureDeclaration = createConstructSignatureDeclaration; - - function createClassConstructorDeclaration(constructorDeclAST, context) { - var declFlags = 512 /* Constructor */; - var declType = 32768 /* ConstructorMethod */; - - if (!constructorDeclAST.block) { - declFlags |= 2048 /* Signature */; - } - - var span = TypeScript.TextSpan.fromBounds(constructorDeclAST.minChar, constructorDeclAST.limChar); - - var parent = context.getParent(); - - if (parent) { - var parentFlags = parent.getFlags(); - - if (parentFlags & 1 /* Exported */) { - declFlags |= 1 /* Exported */; - } - } - - var decl = new TypeScript.PullDecl(parent.getName(), parent.getDisplayName(), declType, declFlags, span, context.scriptName); - context.semanticInfo.setDeclForAST(constructorDeclAST, decl); - context.semanticInfo.setASTForDecl(decl, constructorDeclAST); - - if (parent) { - parent.addChildDecl(decl); - decl.setParentDecl(parent); - } - - context.pushParent(decl); - - if (constructorDeclAST.returnTypeAnnotation && ((constructorDeclAST.returnTypeAnnotation).term.nodeType === 14 /* InterfaceDeclaration */ || (constructorDeclAST.returnTypeAnnotation).term.nodeType === 12 /* FunctionDeclaration */)) { - var declCollectionContext = new DeclCollectionContext(context.semanticInfo); - - declCollectionContext.scriptName = context.scriptName; - - if (parent) { - declCollectionContext.pushParent(parent); - } - - TypeScript.getAstWalkerFactory().walk((constructorDeclAST.returnTypeAnnotation).term, preCollectDecls, postCollectDecls, null, declCollectionContext); - } - - return true; - } - TypeScript.createClassConstructorDeclaration = createClassConstructorDeclaration; - - function createGetAccessorDeclaration(getAccessorDeclAST, context) { - var declFlags = 4 /* Public */; - var declType = 262144 /* GetAccessor */; - - if (TypeScript.hasFlag(getAccessorDeclAST.getFunctionFlags(), 16 /* Static */)) { - declFlags |= 16 /* Static */; - } - - if (TypeScript.hasFlag(getAccessorDeclAST.name.getFlags(), 4 /* OptionalName */)) { - declFlags |= 128 /* Optional */; - } - - if (TypeScript.hasFlag(getAccessorDeclAST.getFunctionFlags(), 2 /* Private */)) { - declFlags |= 2 /* Private */; - } else { - declFlags |= 4 /* Public */; - } - - var span = TypeScript.TextSpan.fromBounds(getAccessorDeclAST.minChar, getAccessorDeclAST.limChar); - - var parent = context.getParent(); - - if (parent && (parent.getKind() === 536870912 /* WithBlock */ || (parent.getFlags() & 2097152 /* DeclaredInAWithBlock */))) { - declFlags |= 2097152 /* DeclaredInAWithBlock */; - } - - var decl = new TypeScript.PullDecl(getAccessorDeclAST.name.text, getAccessorDeclAST.name.actualText, declType, declFlags, span, context.scriptName); - context.semanticInfo.setDeclForAST(getAccessorDeclAST, decl); - context.semanticInfo.setASTForDecl(decl, getAccessorDeclAST); - - if (parent) { - parent.addChildDecl(decl); - decl.setParentDecl(parent); - } - - context.pushParent(decl); - - if (getAccessorDeclAST.returnTypeAnnotation && ((getAccessorDeclAST.returnTypeAnnotation).term.nodeType === 14 /* InterfaceDeclaration */ || (getAccessorDeclAST.returnTypeAnnotation).term.nodeType === 12 /* FunctionDeclaration */)) { - var declCollectionContext = new DeclCollectionContext(context.semanticInfo); - - declCollectionContext.scriptName = context.scriptName; - - if (parent) { - declCollectionContext.pushParent(parent); - } - - TypeScript.getAstWalkerFactory().walk((getAccessorDeclAST.returnTypeAnnotation).term, preCollectDecls, postCollectDecls, null, declCollectionContext); - } - - return true; - } - TypeScript.createGetAccessorDeclaration = createGetAccessorDeclaration; - - function createSetAccessorDeclaration(setAccessorDeclAST, context) { - var declFlags = 4 /* Public */; - var declType = 524288 /* SetAccessor */; - - if (TypeScript.hasFlag(setAccessorDeclAST.getFunctionFlags(), 16 /* Static */)) { - declFlags |= 16 /* Static */; - } - - if (TypeScript.hasFlag(setAccessorDeclAST.name.getFlags(), 4 /* OptionalName */)) { - declFlags |= 128 /* Optional */; - } - - if (TypeScript.hasFlag(setAccessorDeclAST.getFunctionFlags(), 2 /* Private */)) { - declFlags |= 2 /* Private */; - } else { - declFlags |= 4 /* Public */; - } - - var span = TypeScript.TextSpan.fromBounds(setAccessorDeclAST.minChar, setAccessorDeclAST.limChar); - - var parent = context.getParent(); - - if (parent && (parent.getKind() === 536870912 /* WithBlock */ || (parent.getFlags() & 2097152 /* DeclaredInAWithBlock */))) { - declFlags |= 2097152 /* DeclaredInAWithBlock */; - } - - var decl = new TypeScript.PullDecl(setAccessorDeclAST.name.actualText, setAccessorDeclAST.name.actualText, declType, declFlags, span, context.scriptName); - context.semanticInfo.setDeclForAST(setAccessorDeclAST, decl); - context.semanticInfo.setASTForDecl(decl, setAccessorDeclAST); - - if (parent) { - parent.addChildDecl(decl); - decl.setParentDecl(parent); - } - - context.pushParent(decl); - - return true; - } - TypeScript.createSetAccessorDeclaration = createSetAccessorDeclaration; - - function preCollectCatchDecls(ast, parentAST, context) { - var declFlags = 0 /* None */; - var declType = 1073741824 /* CatchBlock */; - - var span = TypeScript.TextSpan.fromBounds(ast.minChar, ast.limChar); - - var parent = context.getParent(); - - if (parent && (parent.getKind() === 536870912 /* WithBlock */ || (parent.getFlags() & 2097152 /* DeclaredInAWithBlock */))) { - declFlags |= 2097152 /* DeclaredInAWithBlock */; - } - - var decl = new TypeScript.PullDecl("", "", declType, declFlags, span, context.scriptName); - context.semanticInfo.setDeclForAST(ast, decl); - context.semanticInfo.setASTForDecl(decl, ast); - - if (parent) { - parent.addChildDecl(decl); - decl.setParentDecl(parent); - } - - context.pushParent(decl); - - return true; - } - TypeScript.preCollectCatchDecls = preCollectCatchDecls; - - function preCollectWithDecls(ast, parentAST, context) { - var declFlags = 0 /* None */; - var declType = 536870912 /* WithBlock */; - - var span = TypeScript.TextSpan.fromBounds(ast.minChar, ast.limChar); - - var parent = context.getParent(); - - var decl = new TypeScript.PullDecl("", "", declType, declFlags, span, context.scriptName); - context.semanticInfo.setDeclForAST(ast, decl); - context.semanticInfo.setASTForDecl(decl, ast); - - if (parent) { - parent.addChildDecl(decl); - decl.setParentDecl(parent); - } - - context.pushParent(decl); - - return true; - } - TypeScript.preCollectWithDecls = preCollectWithDecls; - - function preCollectFuncDecls(ast, parentAST, context) { - var funcDecl = ast; - - if (funcDecl.isConstructor) { - return createClassConstructorDeclaration(funcDecl, context); - } else if (funcDecl.isGetAccessor()) { - return createGetAccessorDeclaration(funcDecl, context); - } else if (funcDecl.isSetAccessor()) { - return createSetAccessorDeclaration(funcDecl, context); - } else if (TypeScript.hasFlag(funcDecl.getFunctionFlags(), 1024 /* ConstructMember */)) { - return TypeScript.hasFlag(funcDecl.getFlags(), 8 /* TypeReference */) ? createConstructorTypeDeclaration(funcDecl, context) : createConstructSignatureDeclaration(funcDecl, context); - } else if (TypeScript.hasFlag(funcDecl.getFunctionFlags(), 512 /* CallMember */)) { - return createCallSignatureDeclaration(funcDecl, context); - } else if (TypeScript.hasFlag(funcDecl.getFunctionFlags(), 4096 /* IndexerMember */)) { - return createIndexSignatureDeclaration(funcDecl, context); - } else if (TypeScript.hasFlag(funcDecl.getFlags(), 8 /* TypeReference */)) { - return createFunctionTypeDeclaration(funcDecl, context); - } else if (TypeScript.hasFlag(funcDecl.getFunctionFlags(), 256 /* Method */)) { - return createMemberFunctionDeclaration(funcDecl, context); - } else if (TypeScript.hasFlag(funcDecl.getFunctionFlags(), (8192 /* IsFunctionExpression */ | 2048 /* IsFatArrowFunction */ | 16384 /* IsFunctionProperty */))) { - return createFunctionExpressionDeclaration(funcDecl, context); - } - - return createFunctionDeclaration(funcDecl, context); - } - TypeScript.preCollectFuncDecls = preCollectFuncDecls; - - function preCollectDecls(ast, parentAST, walker) { - var context = walker.state; - var go = false; - - if (ast.nodeType === 2 /* Script */) { - var script = ast; - var span = TypeScript.TextSpan.fromBounds(script.minChar, script.limChar); - - var decl = new TypeScript.PullDecl(context.scriptName, context.scriptName, 1 /* Script */, 0 /* None */, span, context.scriptName); - context.semanticInfo.setDeclForAST(ast, decl); - context.semanticInfo.setASTForDecl(decl, ast); - - context.pushParent(decl); - - go = true; - } else if (ast.nodeType === 1 /* List */) { - go = true; - } else if (ast.nodeType === 81 /* Block */) { - go = true; - } else if (ast.nodeType === 18 /* VariableDeclaration */) { - go = true; - } else if (ast.nodeType === 97 /* VariableStatement */) { - go = true; - } else if (ast.nodeType === 15 /* ModuleDeclaration */) { - go = preCollectModuleDecls(ast, parentAST, context); - } else if (ast.nodeType === 13 /* ClassDeclaration */) { - go = preCollectClassDecls(ast, parentAST, context); - } else if (ast.nodeType === 14 /* InterfaceDeclaration */) { - go = preCollectInterfaceDecls(ast, parentAST, context); - } else if (ast.nodeType === 19 /* Parameter */) { - go = preCollectParameterDecl(ast, parentAST, context); - } else if (ast.nodeType === 17 /* VariableDeclarator */) { - go = preCollectVarDecls(ast, parentAST, context); - } else if (ast.nodeType === 12 /* FunctionDeclaration */) { - go = preCollectFuncDecls(ast, parentAST, context); - } else if (ast.nodeType === 16 /* ImportDeclaration */) { - go = preCollectImportDecls(ast, parentAST, context); - } else if (ast.nodeType === 9 /* TypeParameter */) { - go = preCollectTypeParameterDecl(ast, parentAST, context); - } else if (ast.nodeType === 91 /* IfStatement */) { - go = true; - } else if (ast.nodeType === 90 /* ForStatement */) { - go = true; - } else if (ast.nodeType === 89 /* ForInStatement */) { - go = true; - } else if (ast.nodeType === 98 /* WhileStatement */) { - go = true; - } else if (ast.nodeType === 85 /* DoStatement */) { - go = true; - } else if (ast.nodeType === 25 /* CommaExpression */) { - go = true; - } else if (ast.nodeType === 93 /* ReturnStatement */) { - go = true; - } else if (ast.nodeType === 94 /* SwitchStatement */ || ast.nodeType === 100 /* CaseClause */) { - go = true; - } else if (ast.nodeType === 36 /* InvocationExpression */) { - go = true; - } else if (ast.nodeType === 37 /* ObjectCreationExpression */) { - go = true; - } else if (ast.nodeType === 96 /* TryStatement */) { - go = true; - } else if (ast.nodeType === 92 /* LabeledStatement */) { - go = true; - } else if (ast.nodeType === 101 /* CatchClause */) { - go = preCollectCatchDecls(ast, parentAST, context); - } else if (ast.nodeType === 99 /* WithStatement */) { - go = preCollectWithDecls(ast, parentAST, context); - } - - walker.options.goChildren = go; - - return ast; - } - TypeScript.preCollectDecls = preCollectDecls; - - function isContainer(decl) { - return decl.getKind() === 4 /* Container */ || decl.getKind() === 32 /* DynamicModule */ || decl.getKind() === 64 /* Enum */; - } - - function getInitializationFlag(decl) { - if (decl.getKind() & 4 /* Container */) { - return 32768 /* InitializedModule */; - } else if (decl.getKind() & 64 /* Enum */) { - return 131072 /* InitializedEnum */; - } else if (decl.getKind() & 32 /* DynamicModule */) { - return 65536 /* InitializedDynamicModule */; - } - - return 0 /* None */; - } - - function hasInitializationFlag(decl) { - var kind = decl.getKind(); - - if (kind & 4 /* Container */) { - return (decl.getFlags() & 32768 /* InitializedModule */) !== 0; - } else if (kind & 64 /* Enum */) { - return (decl.getFlags() & 131072 /* InitializedEnum */) != 0; - } else if (kind & 32 /* DynamicModule */) { - return (decl.getFlags() & 65536 /* InitializedDynamicModule */) !== 0; - } - - return false; - } - - function postCollectDecls(ast, parentAST, walker) { - var context = walker.state; - var parentDecl; - var initFlag = 0 /* None */; - - if (ast.nodeType === 15 /* ModuleDeclaration */) { - var thisModule = context.getParent(); - context.popParent(); - parentDecl = context.getParent(); - - if (hasInitializationFlag(thisModule)) { - if (parentDecl && isContainer(parentDecl)) { - initFlag = getInitializationFlag(parentDecl); - parentDecl.setFlags(parentDecl.getFlags() | initFlag); - } - - var valueDecl = new TypeScript.PullDecl(thisModule.getName(), thisModule.getDisplayName(), 1024 /* Variable */, thisModule.getFlags(), thisModule.getSpan(), context.scriptName); - - thisModule.setValueDecl(valueDecl); - - context.semanticInfo.setASTForDecl(valueDecl, ast); - - if (parentDecl) { - parentDecl.addChildDecl(valueDecl); - valueDecl.setParentDecl(parentDecl); - } - } - } else if (ast.nodeType === 13 /* ClassDeclaration */) { - context.popParent(); - - parentDecl = context.getParent(); - - if (parentDecl && isContainer(parentDecl)) { - initFlag = getInitializationFlag(parentDecl); - parentDecl.setFlags(parentDecl.getFlags() | initFlag); - } - } else if (ast.nodeType === 14 /* InterfaceDeclaration */) { - context.popParent(); - } else if (ast.nodeType === 12 /* FunctionDeclaration */) { - context.popParent(); - - parentDecl = context.getParent(); - - if (parentDecl && isContainer(parentDecl)) { - initFlag = getInitializationFlag(parentDecl); - parentDecl.setFlags(parentDecl.getFlags() | initFlag); - } - } else if (ast.nodeType === 17 /* VariableDeclarator */) { - parentDecl = context.getParent(); - - if (parentDecl && isContainer(parentDecl)) { - initFlag = getInitializationFlag(parentDecl); - parentDecl.setFlags(parentDecl.getFlags() | initFlag); - } - } else if (ast.nodeType === 101 /* CatchClause */) { - parentDecl = context.getParent(); - - if (parentDecl && isContainer(parentDecl)) { - initFlag = getInitializationFlag(parentDecl); - parentDecl.setFlags(parentDecl.getFlags() | initFlag); - } - - context.popParent(); - } else if (ast.nodeType === 99 /* WithStatement */) { - parentDecl = context.getParent(); - - if (parentDecl && isContainer(parentDecl)) { - initFlag = getInitializationFlag(parentDecl); - parentDecl.setFlags(parentDecl.getFlags() | initFlag); - } - - context.popParent(); - } - - return ast; - } - TypeScript.postCollectDecls = postCollectDecls; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - TypeScript.globalBindingPhase = 0; - - function getPathToDecl(decl) { - if (!decl) { - return []; - } - - var decls = decl.getParentPath(); - - if (decls) { - return decls; - } else { - decls = [decl]; - } - - var parentDecl = decl.getParentDecl(); - - while (parentDecl) { - if (parentDecl && decls[decls.length - 1] != parentDecl && !(parentDecl.getKind() & 512 /* ObjectLiteral */)) { - decls[decls.length] = parentDecl; - } - parentDecl = parentDecl.getParentDecl(); - } - - decls = decls.reverse(); - - decl.setParentPath(decls); - - return decls; - } - TypeScript.getPathToDecl = getPathToDecl; - - function findSymbolInContext(name, declKind, startingDecl) { - var startTime = new Date().getTime(); - var contextSymbolPath = getPathToDecl(startingDecl); - var copyOfContextSymbolPath = []; - var symbol = null; - - var endTime = 0; - - if (contextSymbolPath.length) { - for (var i = 0; i < contextSymbolPath.length; i++) { - copyOfContextSymbolPath[copyOfContextSymbolPath.length] = contextSymbolPath[i].getName(); - } - - copyOfContextSymbolPath[copyOfContextSymbolPath.length] = name; - - while (copyOfContextSymbolPath.length >= 2) { - symbol = TypeScript.globalSemanticInfoChain.findSymbol(copyOfContextSymbolPath, declKind); - - if (symbol) { - endTime = new Date().getTime(); - TypeScript.time_in_findSymbol += endTime - startTime; - - return symbol; - } - copyOfContextSymbolPath.length -= 2; - copyOfContextSymbolPath[copyOfContextSymbolPath.length] = name; - } - } - - symbol = TypeScript.globalSemanticInfoChain.findSymbol([name], declKind); - - endTime = new Date().getTime(); - TypeScript.time_in_findSymbol += endTime - startTime; - - return symbol; - } - TypeScript.findSymbolInContext = findSymbolInContext; - - var PullSymbolBinder = (function () { - function PullSymbolBinder(semanticInfoChain) { - this.semanticInfoChain = semanticInfoChain; - this.bindingPhase = TypeScript.globalBindingPhase++; - this.functionTypeParameterCache = new TypeScript.BlockIntrinsics(); - this.reBindingAfterChange = false; - this.startingDeclForRebind = TypeScript.pullDeclID; - this.startingSymbolForRebind = TypeScript.pullSymbolID; - } - PullSymbolBinder.prototype.findTypeParameterInCache = function (name) { - return this.functionTypeParameterCache[name]; - }; - - PullSymbolBinder.prototype.addTypeParameterToCache = function (typeParameter) { - this.functionTypeParameterCache[typeParameter.getName()] = typeParameter; - }; - - PullSymbolBinder.prototype.resetTypeParameterCache = function () { - this.functionTypeParameterCache = new TypeScript.BlockIntrinsics(); - }; - - PullSymbolBinder.prototype.setUnit = function (fileName) { - this.semanticInfo = this.semanticInfoChain.getUnit(fileName); - }; - - PullSymbolBinder.prototype.getParent = function (decl, returnInstanceType) { - if (typeof returnInstanceType === "undefined") { returnInstanceType = false; } - var parentDecl = decl.getParentDecl(); - - if (parentDecl.getKind() == 1 /* Script */) { - return null; - } - - var parent = parentDecl.getSymbol(); - - if (!parent && parentDecl && !parentDecl.isBound()) { - this.bindDeclToPullSymbol(parentDecl); - } - - parent = parentDecl.getSymbol(); - - if (parent) { - if (returnInstanceType && parent.isType() && parent.isContainer()) { - var instanceSymbol = (parent).getInstanceSymbol(); - - if (instanceSymbol) { - return instanceSymbol.getType(); - } - } - - return parent.getType(); - } - - return null; - }; - - PullSymbolBinder.prototype.findDeclsInContext = function (startingDecl, declKind, searchGlobally) { - if (!searchGlobally) { - var parentDecl = startingDecl.getParentDecl(); - return parentDecl.searchChildDecls(startingDecl.getName(), declKind); - } - - var contextSymbolPath = getPathToDecl(startingDecl); - - if (contextSymbolPath.length) { - var copyOfContextSymbolPath = []; - - for (var i = 0; i < contextSymbolPath.length; i++) { - if (contextSymbolPath[i].getKind() & 1 /* Script */) { - continue; - } - copyOfContextSymbolPath[copyOfContextSymbolPath.length] = contextSymbolPath[i].getName(); - } - - return this.semanticInfoChain.findDecls(copyOfContextSymbolPath, declKind); - } - - return this.semanticInfoChain.findDecls([name], declKind); - }; - - PullSymbolBinder.prototype.symbolIsRedeclaration = function (sym) { - var symID = sym.getSymbolID(); - return (symID >= this.startingSymbolForRebind) || ((sym.getRebindingID() === this.bindingPhase) && (symID !== this.startingSymbolForRebind)); - }; - - PullSymbolBinder.prototype.bindModuleDeclarationToPullSymbol = function (moduleContainerDecl) { - var modName = moduleContainerDecl.getName(); - - var moduleContainerTypeSymbol = null; - var moduleInstanceSymbol = null; - var moduleInstanceTypeSymbol = null; - - var moduleInstanceDecl = moduleContainerDecl.getValueDecl(); - - var moduleKind = moduleContainerDecl.getKind(); - - var parent = this.getParent(moduleContainerDecl); - var parentInstanceSymbol = this.getParent(moduleContainerDecl, true); - var parentDecl = moduleContainerDecl.getParentDecl(); - var moduleAST = this.semanticInfo.getASTForDecl(moduleContainerDecl); - - var isExported = moduleContainerDecl.getFlags() & 1 /* Exported */; - var isEnum = (moduleKind & 64 /* Enum */) != 0; - var searchKind = isEnum ? 64 /* Enum */ : TypeScript.PullElementKind.SomeContainer; - var isInitializedModule = (moduleContainerDecl.getFlags() & TypeScript.PullElementFlags.SomeInitializedModule) != 0; - - var createdNewSymbol = false; - - if (parent) { - if (isExported) { - moduleContainerTypeSymbol = parent.findNestedType(modName, searchKind); - } else { - moduleContainerTypeSymbol = parent.findContainedMember(modName); - - if (moduleContainerTypeSymbol && !(moduleContainerTypeSymbol.getKind() & searchKind)) { - moduleContainerTypeSymbol = null; - } - } - } else if (!isExported || moduleContainerDecl.getKind() === 32 /* DynamicModule */) { - moduleContainerTypeSymbol = findSymbolInContext(modName, searchKind, moduleContainerDecl); - } - - if (moduleContainerTypeSymbol && moduleContainerTypeSymbol.getKind() !== moduleKind) { - if (isInitializedModule) { - moduleContainerDecl.addDiagnostic(new TypeScript.SemanticDiagnostic(this.semanticInfo.getPath(), moduleAST.minChar, moduleAST.getLength(), 69 /* Duplicate_identifier__0_ */, [moduleContainerDecl.getDisplayName()])); - } - - moduleContainerTypeSymbol = null; - } - - if (moduleContainerTypeSymbol) { - moduleInstanceSymbol = moduleContainerTypeSymbol.getInstanceSymbol(); - } else { - moduleContainerTypeSymbol = new TypeScript.PullContainerTypeSymbol(modName, moduleKind); - createdNewSymbol = true; - - if (!parent) { - this.semanticInfoChain.cacheGlobalSymbol(moduleContainerTypeSymbol, searchKind); - } - } - - if (!moduleInstanceSymbol && isInitializedModule) { - var variableSymbol = null; - if (!isEnum) { - if (parentInstanceSymbol) { - if (isExported) { - variableSymbol = parentInstanceSymbol.findMember(modName, false); - - if (!variableSymbol) { - variableSymbol = parentInstanceSymbol.findContainedMember(modName); - } - } else { - variableSymbol = parentInstanceSymbol.findContainedMember(modName); - - if (!variableSymbol) { - variableSymbol = parentInstanceSymbol.findMember(modName, false); - } - } - - if (variableSymbol) { - var declarations = variableSymbol.getDeclarations(); - - if (declarations.length) { - var variableSymbolParent = declarations[0].getParentDecl(); - - if ((parentDecl !== variableSymbolParent) && (!this.reBindingAfterChange || (variableSymbolParent.getDeclID() >= this.startingDeclForRebind))) { - variableSymbol = null; - } - } - } - } else if (!(moduleContainerDecl.getFlags() & 1 /* Exported */)) { - var siblingDecls = parentDecl.getChildDecls(); - var augmentedDecl = null; - - for (var i = 0; i < siblingDecls.length; i++) { - if (siblingDecls[i] == moduleContainerDecl) { - break; - } - - if ((siblingDecls[i].getName() == modName) && (siblingDecls[i].getKind() & (8 /* Class */ | TypeScript.PullElementKind.SomeFunction))) { - augmentedDecl = siblingDecls[i]; - break; - } - } - - if (augmentedDecl) { - variableSymbol = augmentedDecl.getSymbol(); - - if (variableSymbol && variableSymbol.isType()) { - variableSymbol = (variableSymbol).getConstructorMethod(); - } - } - } - } - - if (variableSymbol) { - var prevKind = variableSymbol.getKind(); - var acceptableRedeclaration = (prevKind == 16384 /* Function */) || (prevKind == 32768 /* ConstructorMethod */) || variableSymbol.hasFlag(TypeScript.PullElementFlags.ImplicitVariable); - - if (acceptableRedeclaration) { - moduleInstanceTypeSymbol = variableSymbol.getType(); - } else { - variableSymbol = null; - } - } - - if (!moduleInstanceTypeSymbol) { - moduleInstanceTypeSymbol = new TypeScript.PullTypeSymbol(modName, 8388608 /* ObjectType */); - } - - moduleInstanceTypeSymbol.addDeclaration(moduleContainerDecl); - - moduleInstanceTypeSymbol.setAssociatedContainerType(moduleContainerTypeSymbol); - - if (variableSymbol) { - moduleInstanceSymbol = variableSymbol; - } else { - moduleInstanceSymbol = new TypeScript.PullSymbol(modName, 1024 /* Variable */); - moduleInstanceSymbol.setType(moduleInstanceTypeSymbol); - } - - moduleContainerTypeSymbol.setInstanceSymbol(moduleInstanceSymbol); - } - - moduleContainerTypeSymbol.addDeclaration(moduleContainerDecl); - moduleContainerDecl.setSymbol(moduleContainerTypeSymbol); - - this.semanticInfo.setSymbolAndDiagnosticsForAST(moduleAST.name, TypeScript.SymbolAndDiagnostics.fromSymbol(moduleContainerTypeSymbol)); - this.semanticInfo.setSymbolAndDiagnosticsForAST(moduleAST, TypeScript.SymbolAndDiagnostics.fromSymbol(moduleContainerTypeSymbol)); - - var moduleDeclarations = moduleContainerTypeSymbol.getDeclarations(); - if (isEnum && moduleDeclarations.length > 1 && moduleAST.members.members.length > 0) { - var multipleEnums = TypeScript.ArrayUtilities.where(moduleDeclarations, function (d) { - return d.getKind() === 64 /* Enum */; - }).length > 1; - if (multipleEnums) { - var firstVariable = moduleAST.members.members[0]; - var firstVariableDeclarator = firstVariable.declaration.declarators.members[0]; - if (firstVariableDeclarator.isImplicitlyInitialized) { - moduleContainerDecl.addDiagnostic(new TypeScript.SemanticDiagnostic(this.semanticInfo.getPath(), firstVariableDeclarator.minChar, firstVariableDeclarator.getLength(), 264 /* Enums_with_multiple_declarations_must_provide_an_initializer_for_the_first_enum_element */, null)); - } - } - } - - if (createdNewSymbol) { - if (parent) { - var linkKind = moduleContainerDecl.getFlags() & 1 /* Exported */ ? 5 /* PublicMember */ : 6 /* PrivateMember */; - - if (linkKind === 5 /* PublicMember */) { - parent.addMember(moduleContainerTypeSymbol, linkKind); - } else { - moduleContainerTypeSymbol.setContainer(parent); - } - } - } else if (this.reBindingAfterChange) { - var decls = moduleContainerTypeSymbol.getDeclarations(); - var scriptName = moduleContainerDecl.getScriptName(); - - for (var i = 0; i < decls.length; i++) { - if (decls[i].getScriptName() === scriptName && decls[i].getDeclID() < this.startingDeclForRebind) { - moduleContainerTypeSymbol.removeDeclaration(decls[i]); - } - } - - moduleContainerTypeSymbol.invalidate(); - - moduleInstanceSymbol = moduleContainerTypeSymbol.getInstanceSymbol(); - - if (moduleInstanceSymbol) { - var moduleInstanceTypeSymbol = moduleInstanceSymbol.getType(); - decls = moduleInstanceTypeSymbol.getDeclarations(); - - for (var i = 0; i < decls.length; i++) { - if (decls[i].getScriptName() === scriptName && decls[i].getDeclID() < this.startingDeclForRebind) { - moduleInstanceTypeSymbol.removeDeclaration(decls[i]); - } - } - - moduleInstanceTypeSymbol.addDeclaration(moduleContainerDecl); - moduleInstanceTypeSymbol.invalidate(); - } - } - - if (isEnum) { - moduleInstanceTypeSymbol = moduleContainerTypeSymbol.getInstanceSymbol().getType(); - - if (this.reBindingAfterChange) { - var existingIndexSigs = moduleInstanceTypeSymbol.getIndexSignatures(); - - for (var i = 0; i < existingIndexSigs.length; i++) { - moduleInstanceTypeSymbol.removeIndexSignature(existingIndexSigs[i]); - } - } - - var enumIndexSignature = new TypeScript.PullSignatureSymbol(4194304 /* IndexSignature */); - var enumIndexParameterSymbol = new TypeScript.PullSymbol("x", 2048 /* Parameter */); - enumIndexParameterSymbol.setType(this.semanticInfoChain.numberTypeSymbol); - enumIndexSignature.addParameter(enumIndexParameterSymbol); - enumIndexSignature.setReturnType(this.semanticInfoChain.stringTypeSymbol); - - moduleInstanceTypeSymbol.addIndexSignature(enumIndexSignature); - - moduleInstanceTypeSymbol.recomputeIndexSignatures(); - } - - var valueDecl = moduleContainerDecl.getValueDecl(); - - if (valueDecl) { - valueDecl.ensureSymbolIsBound(); - } - - var otherDecls = this.findDeclsInContext(moduleContainerDecl, moduleContainerDecl.getKind(), true); - - if (otherDecls && otherDecls.length) { - for (var i = 0; i < otherDecls.length; i++) { - otherDecls[i].ensureSymbolIsBound(); - } - } - }; - - PullSymbolBinder.prototype.bindImportDeclaration = function (importDeclaration) { - var declFlags = importDeclaration.getFlags(); - var declKind = importDeclaration.getKind(); - var importDeclAST = this.semanticInfo.getASTForDecl(importDeclaration); - - var isExported = false; - var linkKind = 6 /* PrivateMember */; - var importSymbol = null; - var declName = importDeclaration.getName(); - var parentHadSymbol = false; - var parent = this.getParent(importDeclaration); - - if (parent) { - importSymbol = parent.findMember(declName, false); - - if (!importSymbol) { - importSymbol = parent.findContainedMember(declName); - - if (importSymbol) { - var declarations = importSymbol.getDeclarations(); - - if (declarations.length) { - var importSymbolParent = declarations[0].getParentDecl(); - - if ((importSymbolParent !== importDeclaration.getParentDecl()) && (!this.reBindingAfterChange || (importSymbolParent.getDeclID() >= this.startingDeclForRebind))) { - importSymbol = null; - } - } - } - } - } else if (!(importDeclaration.getFlags() & 1 /* Exported */)) { - importSymbol = findSymbolInContext(declName, TypeScript.PullElementKind.SomeContainer, importDeclaration); - } - - if (importSymbol) { - parentHadSymbol = true; - } - - if (importSymbol && this.symbolIsRedeclaration(importSymbol)) { - importDeclaration.addDiagnostic(new TypeScript.SemanticDiagnostic(this.semanticInfo.getPath(), importDeclAST.minChar, importDeclAST.getLength(), 69 /* Duplicate_identifier__0_ */, [importDeclaration.getDisplayName()])); - importSymbol = null; - } - - if (this.reBindingAfterChange && importSymbol) { - var decls = importSymbol.getDeclarations(); - var scriptName = importDeclaration.getScriptName(); - - for (var j = 0; j < decls.length; j++) { - if (decls[j].getScriptName() === scriptName && decls[j].getDeclID() < this.startingDeclForRebind) { - importSymbol.removeDeclaration(decls[j]); - } - } - - importSymbol.setUnresolved(); - } - - if (!importSymbol) { - importSymbol = new TypeScript.PullTypeAliasSymbol(declName); - - if (!parent) { - this.semanticInfoChain.cacheGlobalSymbol(importSymbol, TypeScript.PullElementKind.SomeContainer); - } - } - - importSymbol.addDeclaration(importDeclaration); - importDeclaration.setSymbol(importSymbol); - - this.semanticInfo.setSymbolAndDiagnosticsForAST(importDeclAST, TypeScript.SymbolAndDiagnostics.fromSymbol(importSymbol)); - - if (parent && !parentHadSymbol) { - if (declFlags & 1 /* Exported */) { - parent.addMember(importSymbol, 5 /* PublicMember */); - } else { - importSymbol.setContainer(parent); - } - } - - importSymbol.setIsBound(this.bindingPhase); - }; - - PullSymbolBinder.prototype.cleanInterfaceSignatures = function (interfaceSymbol) { - var callSigs = interfaceSymbol.getCallSignatures(); - var constructSigs = interfaceSymbol.getConstructSignatures(); - var indexSigs = interfaceSymbol.getIndexSignatures(); - - for (var i = 0; i < callSigs.length; i++) { - if (callSigs[i].getSymbolID() < this.startingSymbolForRebind) { - interfaceSymbol.removeCallSignature(callSigs[i], false); - } - } - for (var i = 0; i < constructSigs.length; i++) { - if (constructSigs[i].getSymbolID() < this.startingSymbolForRebind) { - interfaceSymbol.removeConstructSignature(constructSigs[i], false); - } - } - for (var i = 0; i < indexSigs.length; i++) { - if (indexSigs[i].getSymbolID() < this.startingSymbolForRebind) { - interfaceSymbol.removeIndexSignature(indexSigs[i], false); - } - } - - interfaceSymbol.recomputeCallSignatures(); - interfaceSymbol.recomputeConstructSignatures(); - interfaceSymbol.recomputeIndexSignatures(); - }; - - PullSymbolBinder.prototype.cleanClassSignatures = function (classSymbol) { - var callSigs = classSymbol.getCallSignatures(); - var constructSigs = classSymbol.getConstructSignatures(); - var indexSigs = classSymbol.getIndexSignatures(); - - for (var i = 0; i < callSigs.length; i++) { - classSymbol.removeCallSignature(callSigs[i], false); - } - for (var i = 0; i < constructSigs.length; i++) { - classSymbol.removeConstructSignature(constructSigs[i], false); - } - for (var i = 0; i < indexSigs.length; i++) { - classSymbol.removeIndexSignature(indexSigs[i], false); - } - - classSymbol.recomputeCallSignatures(); - classSymbol.recomputeConstructSignatures(); - classSymbol.recomputeIndexSignatures(); - - var constructorSymbol = classSymbol.getConstructorMethod(); - var constructorTypeSymbol = (constructorSymbol ? constructorSymbol.getType() : null); - - if (constructorTypeSymbol) { - constructSigs = constructorTypeSymbol.getConstructSignatures(); - - for (var i = 0; i < constructSigs.length; i++) { - constructorTypeSymbol.removeConstructSignature(constructSigs[i], false); - } - - constructorTypeSymbol.recomputeConstructSignatures(); - constructorTypeSymbol.invalidate(); - constructorSymbol.invalidate(); - } - - classSymbol.invalidate(); - }; - - PullSymbolBinder.prototype.bindClassDeclarationToPullSymbol = function (classDecl) { - var className = classDecl.getName(); - var classSymbol = null; - - var constructorSymbol = null; - var constructorTypeSymbol = null; - - var classAST = this.semanticInfo.getASTForDecl(classDecl); - var parentHadSymbol = false; - - var parent = this.getParent(classDecl); - var parentDecl = classDecl.getParentDecl(); - var cleanedPreviousDecls = false; - var isExported = classDecl.getFlags() & 1 /* Exported */; - var isGeneric = false; - - var acceptableSharedKind = 8 /* Class */; - - if (parent) { - if (isExported) { - classSymbol = parent.findNestedType(className); - - if (!classSymbol) { - classSymbol = parent.findMember(className, false); - } - } else { - classSymbol = parent.findContainedMember(className); - - if (classSymbol && (classSymbol.getKind() & acceptableSharedKind)) { - var declarations = classSymbol.getDeclarations(); - - if (declarations.length) { - var classSymbolParent = declarations[0].getParentDecl(); - - if ((classSymbolParent !== parentDecl) && (!this.reBindingAfterChange || (classSymbolParent.getDeclID() >= this.startingDeclForRebind))) { - classSymbol = null; - } - } - } else { - classSymbol = null; - } - } - } else { - classSymbol = findSymbolInContext(className, acceptableSharedKind, classDecl); - } - - if (classSymbol && (!(classSymbol.getKind() & acceptableSharedKind) || !this.reBindingAfterChange || this.symbolIsRedeclaration(classSymbol))) { - classDecl.addDiagnostic(new TypeScript.SemanticDiagnostic(this.semanticInfo.getPath(), classAST.minChar, classAST.getLength(), 69 /* Duplicate_identifier__0_ */, [classDecl.getDisplayName()])); - classSymbol = null; - } else if (classSymbol) { - parentHadSymbol = true; - } - - var decls; - - if (this.reBindingAfterChange && classSymbol) { - decls = classSymbol.getDeclarations(); - var scriptName = classDecl.getScriptName(); - - for (var j = 0; j < decls.length; j++) { - if (decls[j].getScriptName() === scriptName && decls[j].getDeclID() < this.startingDeclForRebind) { - classSymbol.removeDeclaration(decls[j]); - - cleanedPreviousDecls = true; - } - } - - constructorSymbol = classSymbol.getConstructorMethod(); - constructorTypeSymbol = constructorSymbol.getType(); - - decls = constructorSymbol.getDeclarations(); - - for (var j = 0; j < decls.length; j++) { - if (decls[j].getScriptName() === scriptName && decls[j].getDeclID() < this.startingDeclForRebind) { - constructorSymbol.removeDeclaration(decls[j]); - - cleanedPreviousDecls = true; - } - } - - if (constructorSymbol.getIsSynthesized()) { - classSymbol.setConstructorMethod(null); - } - - if (classSymbol.isGeneric()) { - isGeneric = true; - - var specializations = classSymbol.getKnownSpecializations(); - var specialization = null; - - for (var i = 0; i < specializations.length; i++) { - specializations[i].setUnresolved(); - specializations[i].invalidate(); - } - - classSymbol.cleanTypeParameters(); - constructorTypeSymbol.cleanTypeParameters(); - } - - classSymbol.setUnresolved(); - constructorSymbol.setUnresolved(); - constructorTypeSymbol.setUnresolved(); - } - - if (!parentHadSymbol) { - classSymbol = new TypeScript.PullClassTypeSymbol(className); - - if (!parent) { - this.semanticInfoChain.cacheGlobalSymbol(classSymbol, acceptableSharedKind); - } - } - - classSymbol.addDeclaration(classDecl); - - classDecl.setSymbol(classSymbol); - - this.semanticInfo.setSymbolAndDiagnosticsForAST(classAST.name, TypeScript.SymbolAndDiagnostics.fromSymbol(classSymbol)); - this.semanticInfo.setSymbolAndDiagnosticsForAST(classAST, TypeScript.SymbolAndDiagnostics.fromSymbol(classSymbol)); - - if (parent && !parentHadSymbol) { - var linkKind = classDecl.getFlags() & 1 /* Exported */ ? 5 /* PublicMember */ : 6 /* PrivateMember */; - - if (linkKind === 5 /* PublicMember */) { - parent.addMember(classSymbol, linkKind); - } else { - classSymbol.setContainer(parent); - } - } - - if (parentHadSymbol && cleanedPreviousDecls) { - this.cleanClassSignatures(classSymbol); - - if (isGeneric) { - specializations = classSymbol.getKnownSpecializations(); - - for (var i = 0; i < specializations.length; i++) { - this.cleanClassSignatures(specializations[i]); - } - } - } - - this.resetTypeParameterCache(); - - this.resetTypeParameterCache(); - - constructorSymbol = classSymbol.getConstructorMethod(); - constructorTypeSymbol = (constructorSymbol ? constructorSymbol.getType() : null); - - if (!constructorSymbol) { - constructorSymbol = new TypeScript.PullSymbol(className, 32768 /* ConstructorMethod */); - constructorTypeSymbol = new TypeScript.PullConstructorTypeSymbol(); - - constructorSymbol.setIsSynthesized(); - - constructorSymbol.setType(constructorTypeSymbol); - constructorSymbol.addDeclaration(classDecl.getValueDecl()); - classSymbol.setConstructorMethod(constructorSymbol); - - constructorTypeSymbol.addDeclaration(classDecl); - - classSymbol.setHasDefaultConstructor(); - } - - constructorTypeSymbol.setAssociatedContainerType(classSymbol); - - var typeParameters = classDecl.getTypeParameters(); - var typeParameter; - var typeParameterDecls = null; - - for (var i = 0; i < typeParameters.length; i++) { - typeParameter = classSymbol.findTypeParameter(typeParameters[i].getName()); - - if (!typeParameter) { - typeParameter = new TypeScript.PullTypeParameterSymbol(typeParameters[i].getName(), false); - - classSymbol.addMember(typeParameter, 18 /* TypeParameter */); - constructorTypeSymbol.addTypeParameter(typeParameter, true); - } else { - typeParameterDecls = typeParameter.getDeclarations(); - - if (this.symbolIsRedeclaration(typeParameter)) { - var typeParameterAST = this.semanticInfoChain.getASTForDecl(typeParameterDecls[0]); - classDecl.addDiagnostic(new TypeScript.SemanticDiagnostic(this.semanticInfo.getPath(), typeParameterAST.minChar, typeParameterAST.getLength(), 69 /* Duplicate_identifier__0_ */, [typeParameter.getName()])); - } - - for (var j = 0; j < typeParameterDecls.length; j++) { - if (typeParameterDecls[j].getDeclID() < this.startingDeclForRebind) { - typeParameter.removeDeclaration(typeParameterDecls[j]); - } - } - } - - typeParameter.addDeclaration(typeParameters[i]); - typeParameters[i].setSymbol(typeParameter); - } - - var valueDecl = classDecl.getValueDecl(); - - if (valueDecl) { - valueDecl.ensureSymbolIsBound(); - } - - classSymbol.setIsBound(this.bindingPhase); - }; - - PullSymbolBinder.prototype.bindInterfaceDeclarationToPullSymbol = function (interfaceDecl) { - var interfaceName = interfaceDecl.getName(); - var interfaceSymbol = findSymbolInContext(interfaceName, TypeScript.PullElementKind.SomeType, interfaceDecl); - - var interfaceAST = this.semanticInfo.getASTForDecl(interfaceDecl); - var createdNewSymbol = false; - var parent = this.getParent(interfaceDecl); - - var acceptableSharedKind = 16 /* Interface */; - - if (parent) { - interfaceSymbol = parent.findNestedType(interfaceName); - } else if (!(interfaceDecl.getFlags() & 1 /* Exported */)) { - interfaceSymbol = findSymbolInContext(interfaceName, acceptableSharedKind, interfaceDecl); - } - - if (interfaceSymbol && !(interfaceSymbol.getKind() & acceptableSharedKind)) { - interfaceDecl.addDiagnostic(new TypeScript.SemanticDiagnostic(this.semanticInfo.getPath(), interfaceAST.minChar, interfaceAST.getLength(), 69 /* Duplicate_identifier__0_ */, [interfaceDecl.getDisplayName()])); - interfaceSymbol = null; - } - - if (!interfaceSymbol) { - interfaceSymbol = new TypeScript.PullTypeSymbol(interfaceName, 16 /* Interface */); - createdNewSymbol = true; - - if (!parent) { - this.semanticInfoChain.cacheGlobalSymbol(interfaceSymbol, acceptableSharedKind); - } - } - - interfaceSymbol.addDeclaration(interfaceDecl); - interfaceDecl.setSymbol(interfaceSymbol); - - if (createdNewSymbol) { - if (parent) { - var linkKind = interfaceDecl.getFlags() & 1 /* Exported */ ? 5 /* PublicMember */ : 6 /* PrivateMember */; - - if (linkKind === 5 /* PublicMember */) { - parent.addMember(interfaceSymbol, linkKind); - } else { - interfaceSymbol.setContainer(parent); - } - } - } else if (this.reBindingAfterChange) { - var decls = interfaceSymbol.getDeclarations(); - var scriptName = interfaceDecl.getScriptName(); - - for (var i = 0; i < decls.length; i++) { - if (decls[i].getScriptName() === scriptName && decls[i].getDeclID() < this.startingDeclForRebind) { - interfaceSymbol.removeDeclaration(decls[i]); - } - } - - if (interfaceSymbol.isGeneric()) { - var specializations = interfaceSymbol.getKnownSpecializations(); - var specialization = null; - - for (var i = 0; i < specializations.length; i++) { - specialization = specializations[i]; - - this.cleanInterfaceSignatures(specialization); - specialization.invalidate(); - } - - interfaceSymbol.cleanTypeParameters(); - } - - this.cleanInterfaceSignatures(interfaceSymbol); - interfaceSymbol.invalidate(); - } - - this.resetTypeParameterCache(); - - this.resetTypeParameterCache(); - - var typeParameters = interfaceDecl.getTypeParameters(); - var typeParameter; - var typeParameterDecls = null; - - for (var i = 0; i < typeParameters.length; i++) { - typeParameter = interfaceSymbol.findTypeParameter(typeParameters[i].getName()); - - if (!typeParameter) { - typeParameter = new TypeScript.PullTypeParameterSymbol(typeParameters[i].getName(), false); - - interfaceSymbol.addMember(typeParameter, 18 /* TypeParameter */); - } else { - typeParameterDecls = typeParameter.getDeclarations(); - - if (this.symbolIsRedeclaration(typeParameter)) { - for (var j = 0; j < typeParameterDecls.length; j++) { - var typeParameterDeclParent = typeParameterDecls[j].getParentDecl(); - - if (typeParameterDeclParent && typeParameterDeclParent === interfaceDecl) { - var typeParameterAST = this.semanticInfoChain.getASTForDecl(typeParameterDecls[0]); - interfaceDecl.addDiagnostic(new TypeScript.SemanticDiagnostic(this.semanticInfo.getPath(), typeParameterAST.minChar, typeParameterAST.getLength(), 69 /* Duplicate_identifier__0_ */, [typeParameter.getName()])); - - break; - } - } - } - - for (var j = 0; j < typeParameterDecls.length; j++) { - if (typeParameterDecls[j].getDeclID() < this.startingDeclForRebind) { - typeParameter.removeDeclaration(typeParameterDecls[j]); - } - } - } - - typeParameter.addDeclaration(typeParameters[i]); - typeParameters[i].setSymbol(typeParameter); - } - - var otherDecls = this.findDeclsInContext(interfaceDecl, interfaceDecl.getKind(), true); - - if (otherDecls && otherDecls.length) { - for (var i = 0; i < otherDecls.length; i++) { - otherDecls[i].ensureSymbolIsBound(); - } - } - }; - - PullSymbolBinder.prototype.bindObjectTypeDeclarationToPullSymbol = function (objectDecl) { - var objectSymbolAST = this.semanticInfo.getASTForDecl(objectDecl); - - var objectSymbol = new TypeScript.PullTypeSymbol("", 8388608 /* ObjectType */); - - objectSymbol.addDeclaration(objectDecl); - objectDecl.setSymbol(objectSymbol); - - this.semanticInfo.setSymbolAndDiagnosticsForAST(objectSymbolAST, TypeScript.SymbolAndDiagnostics.fromSymbol(objectSymbol)); - - var childDecls = objectDecl.getChildDecls(); - - for (var i = 0; i < childDecls.length; i++) { - this.bindDeclToPullSymbol(childDecls[i]); - } - - var typeParameters = objectDecl.getTypeParameters(); - var typeParameter; - var typeParameterDecls = null; - - for (var i = 0; i < typeParameters.length; i++) { - typeParameter = objectSymbol.findTypeParameter(typeParameters[i].getName()); - - if (!typeParameter) { - typeParameter = new TypeScript.PullTypeParameterSymbol(typeParameters[i].getName(), false); - - objectSymbol.addMember(typeParameter, 18 /* TypeParameter */); - } else { - typeParameterDecls = typeParameter.getDeclarations(); - - if (this.symbolIsRedeclaration(typeParameter)) { - var typeParameterAST = this.semanticInfoChain.getASTForDecl(typeParameterDecls[0]); - objectDecl.addDiagnostic(new TypeScript.SemanticDiagnostic(this.semanticInfo.getPath(), typeParameterAST.minChar, typeParameterAST.getLength(), 69 /* Duplicate_identifier__0_ */, [typeParameter.getName()])); - } - - for (var j = 0; j < typeParameterDecls.length; j++) { - if (typeParameterDecls[j].getDeclID() < this.startingDeclForRebind) { - typeParameter.removeDeclaration(typeParameterDecls[j]); - } - } - } - - typeParameter.addDeclaration(typeParameters[i]); - typeParameters[i].setSymbol(typeParameter); - } - }; - - PullSymbolBinder.prototype.bindConstructorTypeDeclarationToPullSymbol = function (constructorTypeDeclaration) { - var declKind = constructorTypeDeclaration.getKind(); - var declFlags = constructorTypeDeclaration.getFlags(); - var constructorTypeAST = this.semanticInfo.getASTForDecl(constructorTypeDeclaration); - - var constructorTypeSymbol = new TypeScript.PullConstructorTypeSymbol(); - - constructorTypeDeclaration.setSymbol(constructorTypeSymbol); - constructorTypeSymbol.addDeclaration(constructorTypeDeclaration); - this.semanticInfo.setSymbolAndDiagnosticsForAST(constructorTypeAST, TypeScript.SymbolAndDiagnostics.fromSymbol(constructorTypeSymbol)); - - var signature = new TypeScript.PullDefinitionSignatureSymbol(2097152 /* ConstructSignature */); - - if ((constructorTypeAST).variableArgList) { - signature.setHasVariableParamList(); - } - - signature.addDeclaration(constructorTypeDeclaration); - constructorTypeDeclaration.setSignatureSymbol(signature); - - this.bindParameterSymbols(this.semanticInfo.getASTForDecl(constructorTypeDeclaration), constructorTypeSymbol, signature); - - constructorTypeSymbol.addSignature(signature); - - var typeParameters = constructorTypeDeclaration.getTypeParameters(); - var typeParameter; - var typeParameterDecls = null; - - for (var i = 0; i < typeParameters.length; i++) { - typeParameter = constructorTypeSymbol.findTypeParameter(typeParameters[i].getName()); - - if (!typeParameter) { - typeParameter = new TypeScript.PullTypeParameterSymbol(typeParameters[i].getName(), false); - - constructorTypeSymbol.addTypeParameter(typeParameter); - } else { - typeParameterDecls = typeParameter.getDeclarations(); - - if (this.symbolIsRedeclaration(typeParameter)) { - var typeParameterAST = this.semanticInfoChain.getASTForDecl(typeParameterDecls[0]); - constructorTypeDeclaration.addDiagnostic(new TypeScript.SemanticDiagnostic(this.semanticInfo.getPath(), typeParameterAST.minChar, typeParameterAST.getLength(), 69 /* Duplicate_identifier__0_ */, [typeParameter.getName()])); - } - - for (var j = 0; j < typeParameterDecls.length; j++) { - if (typeParameterDecls[j].getDeclID() < this.startingDeclForRebind) { - typeParameter.removeDeclaration(typeParameterDecls[j]); - } - } - } - - typeParameter.addDeclaration(typeParameters[i]); - typeParameters[i].setSymbol(typeParameter); - } - }; - - PullSymbolBinder.prototype.bindVariableDeclarationToPullSymbol = function (variableDeclaration) { - var declFlags = variableDeclaration.getFlags(); - var declKind = variableDeclaration.getKind(); - var varDeclAST = this.semanticInfo.getASTForDecl(variableDeclaration); - - var isExported = (declFlags & 1 /* Exported */) !== 0; - - var linkKind = 6 /* PrivateMember */; - - var variableSymbol = null; - - var declName = variableDeclaration.getName(); - - var parentHadSymbol = false; - - var parent = this.getParent(variableDeclaration, true); - - var parentDecl = variableDeclaration.getParentDecl(); - - var isImplicit = (declFlags & TypeScript.PullElementFlags.ImplicitVariable) !== 0; - var isModuleValue = (declFlags & (32768 /* InitializedModule */ | 65536 /* InitializedDynamicModule */ | 131072 /* InitializedEnum */)) != 0; - var isEnumValue = (declFlags & 131072 /* InitializedEnum */) != 0; - var isClassConstructorVariable = (declFlags & 16384 /* ClassConstructorVariable */) != 0; - - if (parentDecl && !isImplicit) { - parentDecl.addVariableDeclToGroup(variableDeclaration); - } - - if (parent) { - if (isExported) { - variableSymbol = parent.findMember(declName, false); - } else { - variableSymbol = parent.findContainedMember(declName); - } - - if (variableSymbol) { - var declarations = variableSymbol.getDeclarations(); - - if (declarations.length) { - var variableSymbolParent = declarations[0].getParentDecl(); - - if ((parentDecl !== variableSymbolParent) && (!this.reBindingAfterChange || (variableSymbolParent.getDeclID() >= this.startingDeclForRebind))) { - variableSymbol = null; - } - } - } - } else if (!(variableDeclaration.getFlags() & 1 /* Exported */)) { - variableSymbol = findSymbolInContext(declName, TypeScript.PullElementKind.SomeValue, variableDeclaration); - } - - if (variableSymbol && !variableSymbol.isType()) { - parentHadSymbol = true; - } - - var span; - var decl; - var decls; - var ast; - var members; - - if (variableSymbol && this.symbolIsRedeclaration(variableSymbol)) { - var prevKind = variableSymbol.getKind(); - var prevIsAmbient = variableSymbol.hasFlag(8 /* Ambient */); - var prevIsEnum = variableSymbol.hasFlag(131072 /* InitializedEnum */); - var prevIsClass = prevKind == 32768 /* ConstructorMethod */; - var prevIsContainer = variableSymbol.hasFlag(32768 /* InitializedModule */ | 65536 /* InitializedDynamicModule */); - var onlyOneIsEnum = (isEnumValue || prevIsEnum) && !(isEnumValue && prevIsEnum); - var isAmbient = (variableDeclaration.getFlags() & 8 /* Ambient */) != 0; - var isClass = variableDeclaration.getKind() == 32768 /* ConstructorMethod */; - - var acceptableRedeclaration = isImplicit && ((!isEnumValue && !isClassConstructorVariable && prevKind == 16384 /* Function */) || (!isModuleValue && prevIsContainer && isAmbient) || (!isModuleValue && prevIsClass) || variableSymbol.hasFlag(TypeScript.PullElementFlags.ImplicitVariable)); - - if (acceptableRedeclaration && prevIsClass && !prevIsAmbient) { - if (variableSymbol.getDeclarations()[0].getScriptName() != variableDeclaration.getScriptName()) { - acceptableRedeclaration = false; - } - } - - if ((!isModuleValue && !isClass && !isAmbient) || !acceptableRedeclaration || onlyOneIsEnum) { - span = variableDeclaration.getSpan(); - if (!parent || variableSymbol.getIsSynthesized()) { - var errorDecl = isImplicit ? variableSymbol.getDeclarations()[0] : variableDeclaration; - errorDecl.addDiagnostic(new TypeScript.SemanticDiagnostic(this.semanticInfo.getPath(), span.start(), span.length(), 69 /* Duplicate_identifier__0_ */, [variableDeclaration.getDisplayName()])); - } - - variableSymbol = null; - parentHadSymbol = false; - } - } else if (variableSymbol && (variableSymbol.getKind() !== 1024 /* Variable */) && !isImplicit) { - span = variableDeclaration.getSpan(); - - variableDeclaration.addDiagnostic(new TypeScript.SemanticDiagnostic(this.semanticInfo.getPath(), span.start(), span.length(), 69 /* Duplicate_identifier__0_ */, [variableDeclaration.getDisplayName()])); - variableSymbol = null; - parentHadSymbol = false; - } - - if (this.reBindingAfterChange && variableSymbol && !variableSymbol.isType()) { - decls = variableSymbol.getDeclarations(); - var scriptName = variableDeclaration.getScriptName(); - - for (var j = 0; j < decls.length; j++) { - if (decls[j].getScriptName() === scriptName && decls[j].getDeclID() < this.startingDeclForRebind) { - variableSymbol.removeDeclaration(decls[j]); - } - } - - variableSymbol.invalidate(); - } - - var replaceProperty = false; - var previousProperty = null; - - if ((declFlags & TypeScript.PullElementFlags.ImplicitVariable) === 0) { - if (!variableSymbol) { - variableSymbol = new TypeScript.PullSymbol(declName, declKind); - } - - variableSymbol.addDeclaration(variableDeclaration); - variableDeclaration.setSymbol(variableSymbol); - - this.semanticInfo.setSymbolAndDiagnosticsForAST(varDeclAST.id, TypeScript.SymbolAndDiagnostics.fromSymbol(variableSymbol)); - this.semanticInfo.setSymbolAndDiagnosticsForAST(varDeclAST, TypeScript.SymbolAndDiagnostics.fromSymbol(variableSymbol)); - } else if (!parentHadSymbol) { - if (isClassConstructorVariable) { - var classTypeSymbol = variableSymbol; - - if (parent) { - members = parent.getMembers(); - - for (var i = 0; i < members.length; i++) { - if ((members[i].getName() === declName) && (members[i].getKind() === 8 /* Class */)) { - classTypeSymbol = members[i]; - break; - } - } - } - - if (!classTypeSymbol) { - var parentDecl = variableDeclaration.getParentDecl(); - - if (parentDecl) { - var childDecls = parentDecl.searchChildDecls(declName, TypeScript.PullElementKind.SomeType); - - if (childDecls.length) { - for (var i = 0; i < childDecls.length; i++) { - if (childDecls[i].getValueDecl() === variableDeclaration) { - classTypeSymbol = childDecls[i].getSymbol(); - } - } - } - } - - if (!classTypeSymbol) { - classTypeSymbol = findSymbolInContext(declName, TypeScript.PullElementKind.SomeType, variableDeclaration); - } - } - - if (classTypeSymbol && (classTypeSymbol.getKind() !== 8 /* Class */)) { - classTypeSymbol = null; - } - - if (classTypeSymbol && classTypeSymbol.isClass()) { - replaceProperty = variableSymbol && variableSymbol.getIsSynthesized(); - - if (replaceProperty) { - previousProperty = variableSymbol; - } - - variableSymbol = classTypeSymbol.getConstructorMethod(); - variableDeclaration.setSymbol(variableSymbol); - - decls = classTypeSymbol.getDeclarations(); - - if (decls.length) { - decl = decls[decls.length - 1]; - ast = this.semanticInfo.getASTForDecl(decl); - - if (ast) { - this.semanticInfo.setASTForDecl(variableDeclaration, ast); - } - } - } else { - if (!variableSymbol) { - variableSymbol = new TypeScript.PullSymbol(declName, declKind); - } - - variableSymbol.addDeclaration(variableDeclaration); - variableDeclaration.setSymbol(variableSymbol); - - variableSymbol.setType(this.semanticInfoChain.anyTypeSymbol); - } - } else if (declFlags & TypeScript.PullElementFlags.SomeInitializedModule) { - var moduleContainerTypeSymbol = null; - var moduleParent = this.getParent(variableDeclaration); - - if (moduleParent) { - members = moduleParent.getMembers(); - - for (var i = 0; i < members.length; i++) { - if ((members[i].getName() === declName) && (members[i].isContainer())) { - moduleContainerTypeSymbol = members[i]; - break; - } - } - } - - if (!moduleContainerTypeSymbol) { - var parentDecl = variableDeclaration.getParentDecl(); - - if (parentDecl) { - var searchKind = (declFlags & (32768 /* InitializedModule */ | 65536 /* InitializedDynamicModule */)) ? TypeScript.PullElementKind.SomeContainer : 64 /* Enum */; - var childDecls = parentDecl.searchChildDecls(declName, searchKind); - - if (childDecls.length) { - for (var i = 0; i < childDecls.length; i++) { - if (childDecls[i].getValueDecl() === variableDeclaration) { - moduleContainerTypeSymbol = childDecls[i].getSymbol(); - } - } - } - } - if (!moduleContainerTypeSymbol) { - moduleContainerTypeSymbol = findSymbolInContext(declName, TypeScript.PullElementKind.SomeContainer, variableDeclaration); - - if (!moduleContainerTypeSymbol) { - moduleContainerTypeSymbol = findSymbolInContext(declName, 64 /* Enum */, variableDeclaration); - } - } - } - - if (moduleContainerTypeSymbol && (!moduleContainerTypeSymbol.isContainer())) { - moduleContainerTypeSymbol = null; - } - - if (moduleContainerTypeSymbol) { - variableSymbol = moduleContainerTypeSymbol.getInstanceSymbol(); - - variableSymbol.addDeclaration(variableDeclaration); - variableDeclaration.setSymbol(variableSymbol); - - decls = moduleContainerTypeSymbol.getDeclarations(); - - if (decls.length) { - decl = decls[decls.length - 1]; - ast = this.semanticInfo.getASTForDecl(decl); - - if (ast) { - this.semanticInfo.setASTForDecl(variableDeclaration, ast); - } - } - } else { - TypeScript.Debug.assert(false, "Attempted to bind invalid implicit variable symbol"); - } - } - } else { - variableSymbol.addDeclaration(variableDeclaration); - variableDeclaration.setSymbol(variableSymbol); - } - - if (parent && !parentHadSymbol) { - if (declFlags & 1 /* Exported */) { - parent.addMember(variableSymbol, 5 /* PublicMember */); - } else { - variableSymbol.setContainer(parent); - } - } else if (replaceProperty) { - parent.removeMember(previousProperty); - parent.addMember(variableSymbol, linkKind); - } - - variableSymbol.setIsBound(this.bindingPhase); - }; - - PullSymbolBinder.prototype.bindPropertyDeclarationToPullSymbol = function (propertyDeclaration) { - var declFlags = propertyDeclaration.getFlags(); - var declKind = propertyDeclaration.getKind(); - var propDeclAST = this.semanticInfo.getASTForDecl(propertyDeclaration); - - var isStatic = false; - var isOptional = false; - - var linkKind = 5 /* PublicMember */; - - var propertySymbol = null; - - if (TypeScript.hasFlag(declFlags, 16 /* Static */)) { - isStatic = true; - } - - if (TypeScript.hasFlag(declFlags, 2 /* Private */)) { - linkKind = 6 /* PrivateMember */; - } - - if (TypeScript.hasFlag(declFlags, 128 /* Optional */)) { - isOptional = true; - } - - var declName = propertyDeclaration.getName(); - - var parentHadSymbol = false; - - var parent = this.getParent(propertyDeclaration, true); - - if (parent.isClass() && isStatic) { - parent = (parent).getConstructorMethod().getType(); - } - - propertySymbol = parent.findMember(declName, false); - - if (propertySymbol && (!this.reBindingAfterChange || this.symbolIsRedeclaration(propertySymbol))) { - var span = propertyDeclaration.getSpan(); - - propertyDeclaration.addDiagnostic(new TypeScript.SemanticDiagnostic(this.semanticInfo.getPath(), span.start(), span.length(), 69 /* Duplicate_identifier__0_ */, [propertyDeclaration.getDisplayName()])); - - propertySymbol = null; - } - - if (propertySymbol) { - parentHadSymbol = true; - } - - if (this.reBindingAfterChange && propertySymbol) { - var decls = propertySymbol.getDeclarations(); - var scriptName = propertyDeclaration.getScriptName(); - - for (var j = 0; j < decls.length; j++) { - if (decls[j].getScriptName() === scriptName && decls[j].getDeclID() < this.startingDeclForRebind) { - propertySymbol.removeDeclaration(decls[j]); - } - } - - propertySymbol.setUnresolved(); - } - - var classTypeSymbol; - - if (!parentHadSymbol) { - propertySymbol = new TypeScript.PullSymbol(declName, declKind); - } - - propertySymbol.addDeclaration(propertyDeclaration); - propertyDeclaration.setSymbol(propertySymbol); - - this.semanticInfo.setSymbolAndDiagnosticsForAST(propDeclAST.id, TypeScript.SymbolAndDiagnostics.fromSymbol(propertySymbol)); - this.semanticInfo.setSymbolAndDiagnosticsForAST(propDeclAST, TypeScript.SymbolAndDiagnostics.fromSymbol(propertySymbol)); - - if (isOptional) { - propertySymbol.setIsOptional(); - } - - if (parent && !parentHadSymbol) { - if (parent.isClass()) { - classTypeSymbol = parent; - - classTypeSymbol.addMember(propertySymbol, linkKind); - } else { - parent.addMember(propertySymbol, linkKind); - } - } - - propertySymbol.setIsBound(this.bindingPhase); - }; - - PullSymbolBinder.prototype.bindParameterSymbols = function (funcDecl, funcType, signatureSymbol) { - var parameters = []; - var decl = null; - var argDecl = null; - var parameterSymbol = null; - var isProperty = false; - var params = new TypeScript.BlockIntrinsics(); - - if (funcDecl.arguments) { - for (var i = 0; i < funcDecl.arguments.members.length; i++) { - argDecl = funcDecl.arguments.members[i]; - decl = this.semanticInfo.getDeclForAST(argDecl); - isProperty = TypeScript.hasFlag(argDecl.getVarFlags(), 256 /* Property */); - parameterSymbol = new TypeScript.PullSymbol(argDecl.id.text, 2048 /* Parameter */); - - if (funcDecl.variableArgList && i === funcDecl.arguments.members.length - 1) { - parameterSymbol.setIsVarArg(); - } - - if (decl.getFlags() & 128 /* Optional */) { - parameterSymbol.setIsOptional(); - } - - if (params[argDecl.id.text]) { - decl.addDiagnostic(new TypeScript.SemanticDiagnostic(this.semanticInfo.getPath(), argDecl.minChar, argDecl.getLength(), 69 /* Duplicate_identifier__0_ */, [argDecl.id.actualText])); - } else { - params[argDecl.id.text] = true; - } - if (decl) { - if (isProperty) { - decl.ensureSymbolIsBound(); - var valDecl = decl.getValueDecl(); - - if (valDecl) { - valDecl.setSymbol(parameterSymbol); - parameterSymbol.addDeclaration(valDecl); - } - } else { - parameterSymbol.addDeclaration(decl); - decl.setSymbol(parameterSymbol); - } - } - - signatureSymbol.addParameter(parameterSymbol, parameterSymbol.getIsOptional()); - - if (signatureSymbol.isDefinition()) { - parameterSymbol.setContainer(funcType); - } - } - } - }; - - PullSymbolBinder.prototype.bindFunctionDeclarationToPullSymbol = function (functionDeclaration) { - var declKind = functionDeclaration.getKind(); - var declFlags = functionDeclaration.getFlags(); - var funcDeclAST = this.semanticInfo.getASTForDecl(functionDeclaration); - - var isExported = (declFlags & 1 /* Exported */) !== 0; - - var funcName = functionDeclaration.getName(); - - var isSignature = (declFlags & 2048 /* Signature */) !== 0; - - var parent = this.getParent(functionDeclaration, true); - var parentDecl = functionDeclaration.getParentDecl(); - var parentHadSymbol = false; - var cleanedPreviousDecls = false; - - var functionSymbol = null; - var functionTypeSymbol = null; - - if (parent) { - functionSymbol = parent.findMember(funcName, false); - - if (!functionSymbol) { - functionSymbol = parent.findContainedMember(funcName); - - if (functionSymbol) { - var declarations = functionSymbol.getDeclarations(); - - if (declarations.length) { - var funcSymbolParent = declarations[0].getParentDecl(); - - if ((parentDecl !== funcSymbolParent) && (!this.reBindingAfterChange || (funcSymbolParent.getDeclID() >= this.startingDeclForRebind))) { - functionSymbol = null; - } - } - } - } - } else if (!(functionDeclaration.getFlags() & 1 /* Exported */)) { - functionSymbol = findSymbolInContext(funcName, TypeScript.PullElementKind.SomeValue, functionDeclaration); - } - - if (functionSymbol && (functionSymbol.getKind() !== 16384 /* Function */ || (this.symbolIsRedeclaration(functionSymbol) && !isSignature && !functionSymbol.allDeclsHaveFlag(2048 /* Signature */)))) { - functionDeclaration.addDiagnostic(new TypeScript.SemanticDiagnostic(this.semanticInfo.getPath(), funcDeclAST.minChar, funcDeclAST.getLength(), 69 /* Duplicate_identifier__0_ */, [functionDeclaration.getDisplayName()])); - functionSymbol = null; - } - - if (functionSymbol) { - functionTypeSymbol = functionSymbol.getType(); - parentHadSymbol = true; - } - - if (this.reBindingAfterChange && functionSymbol) { - var decls = functionSymbol.getDeclarations(); - var scriptName = functionDeclaration.getScriptName(); - var isGeneric = functionTypeSymbol.isGeneric(); - - for (var j = 0; j < decls.length; j++) { - if (decls[j].getScriptName() === scriptName && decls[j].getDeclID() < this.startingDeclForRebind) { - functionSymbol.removeDeclaration(decls[j]); - - cleanedPreviousDecls = true; - } - } - - decls = functionTypeSymbol.getDeclarations(); - - for (var j = 0; j < decls.length; j++) { - if (decls[j].getScriptName() === scriptName && decls[j].getDeclID() < this.startingDeclForRebind) { - functionTypeSymbol.removeDeclaration(decls[j]); - - cleanedPreviousDecls = true; - } - } - - if (isGeneric) { - var specializations = functionTypeSymbol.getKnownSpecializations(); - - for (var i = 0; i < specializations.length; i++) { - specializations[i].invalidate(); - } - } - - functionSymbol.invalidate(); - functionTypeSymbol.invalidate(); - } - - if (!functionSymbol) { - functionSymbol = new TypeScript.PullSymbol(funcName, 16384 /* Function */); - } - - if (!functionTypeSymbol) { - functionTypeSymbol = new TypeScript.PullFunctionTypeSymbol(); - functionSymbol.setType(functionTypeSymbol); - } - - functionDeclaration.setSymbol(functionSymbol); - functionSymbol.addDeclaration(functionDeclaration); - functionTypeSymbol.addDeclaration(functionDeclaration); - - this.semanticInfo.setSymbolAndDiagnosticsForAST(funcDeclAST.name, TypeScript.SymbolAndDiagnostics.fromSymbol(functionSymbol)); - this.semanticInfo.setSymbolAndDiagnosticsForAST(funcDeclAST, TypeScript.SymbolAndDiagnostics.fromSymbol(functionSymbol)); - - if (parent && !parentHadSymbol) { - if (isExported) { - parent.addMember(functionSymbol, 5 /* PublicMember */); - } else { - functionSymbol.setContainer(parent); - } - } - - if (parentHadSymbol && cleanedPreviousDecls) { - var callSigs = functionTypeSymbol.getCallSignatures(); - - for (var i = 0; i < callSigs.length; i++) { - functionTypeSymbol.removeCallSignature(callSigs[i], false); - } - - functionSymbol.invalidate(); - functionTypeSymbol.invalidate(); - functionTypeSymbol.recomputeCallSignatures(); - - if (isGeneric) { - var specializations = functionTypeSymbol.getKnownSpecializations(); - - for (var j = 0; j < specializations.length; j++) { - callSigs = specializations[j].getCallSignatures(); - - for (var i = 0; i < callSigs.length; i++) { - callSigs[i].invalidate(); - } - } - } - } - - var signature = isSignature ? new TypeScript.PullSignatureSymbol(1048576 /* CallSignature */) : new TypeScript.PullDefinitionSignatureSymbol(1048576 /* CallSignature */); - - signature.addDeclaration(functionDeclaration); - functionDeclaration.setSignatureSymbol(signature); - - if (funcDeclAST.variableArgList) { - signature.setHasVariableParamList(); - } - - this.bindParameterSymbols(this.semanticInfo.getASTForDecl(functionDeclaration), functionTypeSymbol, signature); - - var typeParameters = functionDeclaration.getTypeParameters(); - var typeParameter; - var typeParameterDecls = null; - - for (var i = 0; i < typeParameters.length; i++) { - typeParameter = signature.findTypeParameter(typeParameters[i].getName()); - - if (!typeParameter) { - typeParameter = new TypeScript.PullTypeParameterSymbol(typeParameters[i].getName(), true); - - signature.addTypeParameter(typeParameter); - } else { - typeParameterDecls = typeParameter.getDeclarations(); - - if (this.symbolIsRedeclaration(typeParameter)) { - var typeParameterAST = this.semanticInfoChain.getASTForDecl(typeParameterDecls[0]); - functionDeclaration.addDiagnostic(new TypeScript.SemanticDiagnostic(this.semanticInfo.getPath(), typeParameterAST.minChar, typeParameterAST.getLength(), 69 /* Duplicate_identifier__0_ */, [typeParameter.getName()])); - } - - for (var j = 0; j < typeParameterDecls.length; j++) { - if (typeParameterDecls[j].getDeclID() < this.startingDeclForRebind) { - typeParameter.removeDeclaration(typeParameterDecls[j]); - } - } - } - - typeParameter.addDeclaration(typeParameters[i]); - typeParameters[i].setSymbol(typeParameter); - } - - functionTypeSymbol.addCallSignature(signature); - - if (!isSignature) { - } - - functionSymbol.setIsBound(this.bindingPhase); - - var otherDecls = this.findDeclsInContext(functionDeclaration, functionDeclaration.getKind(), false); - - if (otherDecls && otherDecls.length) { - for (var i = 0; i < otherDecls.length; i++) { - otherDecls[i].ensureSymbolIsBound(); - } - } - }; - - PullSymbolBinder.prototype.bindFunctionExpressionToPullSymbol = function (functionExpressionDeclaration) { - var declKind = functionExpressionDeclaration.getKind(); - var declFlags = functionExpressionDeclaration.getFlags(); - var funcExpAST = this.semanticInfo.getASTForDecl(functionExpressionDeclaration); - - var functionName = declKind == 131072 /* FunctionExpression */ ? (functionExpressionDeclaration).getFunctionExpressionName() : functionExpressionDeclaration.getName(); - var functionSymbol = new TypeScript.PullSymbol(functionName, 16384 /* Function */); - var functionTypeSymbol = new TypeScript.PullFunctionTypeSymbol(); - - functionSymbol.setType(functionTypeSymbol); - - functionExpressionDeclaration.setSymbol(functionSymbol); - functionSymbol.addDeclaration(functionExpressionDeclaration); - functionTypeSymbol.addDeclaration(functionExpressionDeclaration); - - if (funcExpAST.name) { - this.semanticInfo.setSymbolAndDiagnosticsForAST(funcExpAST.name, TypeScript.SymbolAndDiagnostics.fromSymbol(functionSymbol)); - } - this.semanticInfo.setSymbolAndDiagnosticsForAST(funcExpAST, TypeScript.SymbolAndDiagnostics.fromSymbol(functionSymbol)); - - var signature = new TypeScript.PullDefinitionSignatureSymbol(1048576 /* CallSignature */); - - if (funcExpAST.variableArgList) { - signature.setHasVariableParamList(); - } - - var typeParameters = functionExpressionDeclaration.getTypeParameters(); - var typeParameter; - var typeParameterDecls = null; - - for (var i = 0; i < typeParameters.length; i++) { - typeParameter = signature.findTypeParameter(typeParameters[i].getName()); - - if (!typeParameter) { - typeParameter = new TypeScript.PullTypeParameterSymbol(typeParameters[i].getName(), true); - - signature.addTypeParameter(typeParameter); - } else { - typeParameterDecls = typeParameter.getDeclarations(); - - if (this.symbolIsRedeclaration(typeParameter)) { - var typeParameterAST = this.semanticInfoChain.getASTForDecl(typeParameterDecls[0]); - functionExpressionDeclaration.addDiagnostic(new TypeScript.SemanticDiagnostic(this.semanticInfo.getPath(), typeParameterAST.minChar, typeParameterAST.getLength(), 69 /* Duplicate_identifier__0_ */, [typeParameter.getName()])); - } - - typeParameterDecls = typeParameter.getDeclarations(); - - for (var j = 0; j < typeParameterDecls.length; j++) { - if (typeParameterDecls[j].getDeclID() < this.startingDeclForRebind) { - typeParameter.removeDeclaration(typeParameterDecls[j]); - } - } - } - - typeParameter.addDeclaration(typeParameters[i]); - typeParameters[i].setSymbol(typeParameter); - } - - signature.addDeclaration(functionExpressionDeclaration); - functionExpressionDeclaration.setSignatureSymbol(signature); - - this.bindParameterSymbols(this.semanticInfo.getASTForDecl(functionExpressionDeclaration), functionTypeSymbol, signature); - - functionTypeSymbol.addSignature(signature); - }; - - PullSymbolBinder.prototype.bindFunctionTypeDeclarationToPullSymbol = function (functionTypeDeclaration) { - var declKind = functionTypeDeclaration.getKind(); - var declFlags = functionTypeDeclaration.getFlags(); - var funcTypeAST = this.semanticInfo.getASTForDecl(functionTypeDeclaration); - - var functionTypeSymbol = new TypeScript.PullFunctionTypeSymbol(); - - functionTypeDeclaration.setSymbol(functionTypeSymbol); - functionTypeSymbol.addDeclaration(functionTypeDeclaration); - this.semanticInfo.setSymbolAndDiagnosticsForAST(funcTypeAST, TypeScript.SymbolAndDiagnostics.fromSymbol(functionTypeSymbol)); - - var isSignature = (declFlags & 2048 /* Signature */) !== 0; - var signature = isSignature ? new TypeScript.PullSignatureSymbol(1048576 /* CallSignature */) : new TypeScript.PullDefinitionSignatureSymbol(1048576 /* CallSignature */); - - if (funcTypeAST.variableArgList) { - signature.setHasVariableParamList(); - } - - var typeParameters = functionTypeDeclaration.getTypeParameters(); - var typeParameter; - var typeParameterDecls = null; - - for (var i = 0; i < typeParameters.length; i++) { - typeParameter = signature.findTypeParameter(typeParameters[i].getName()); - - if (!typeParameter) { - typeParameter = new TypeScript.PullTypeParameterSymbol(typeParameters[i].getName(), true); - - signature.addTypeParameter(typeParameter); - } else { - typeParameterDecls = typeParameter.getDeclarations(); - - if (this.symbolIsRedeclaration(typeParameter)) { - var typeParameterAST = this.semanticInfoChain.getASTForDecl(typeParameterDecls[0]); - functionTypeDeclaration.addDiagnostic(new TypeScript.SemanticDiagnostic(this.semanticInfo.getPath(), typeParameterAST.minChar, typeParameterAST.getLength(), 69 /* Duplicate_identifier__0_ */, [typeParameter.getName()])); - } - - typeParameterDecls = typeParameter.getDeclarations(); - - for (var j = 0; j < typeParameterDecls.length; j++) { - if (typeParameterDecls[j].getDeclID() < this.startingDeclForRebind) { - typeParameter.removeDeclaration(typeParameterDecls[j]); - } - } - } - - typeParameter.addDeclaration(typeParameters[i]); - typeParameters[i].setSymbol(typeParameter); - } - - signature.addDeclaration(functionTypeDeclaration); - functionTypeDeclaration.setSignatureSymbol(signature); - - this.bindParameterSymbols(this.semanticInfo.getASTForDecl(functionTypeDeclaration), functionTypeSymbol, signature); - - functionTypeSymbol.addSignature(signature); - }; - - PullSymbolBinder.prototype.bindMethodDeclarationToPullSymbol = function (methodDeclaration) { - var declKind = methodDeclaration.getKind(); - var declFlags = methodDeclaration.getFlags(); - var methodAST = this.semanticInfo.getASTForDecl(methodDeclaration); - - var isPrivate = (declFlags & 2 /* Private */) !== 0; - var isStatic = (declFlags & 16 /* Static */) !== 0; - var isOptional = (declFlags & 128 /* Optional */) !== 0; - - var methodName = methodDeclaration.getName(); - - var isSignature = (declFlags & 2048 /* Signature */) !== 0; - - var parent = this.getParent(methodDeclaration, true); - var parentHadSymbol = false; - - var cleanedPreviousDecls = false; - - var methodSymbol = null; - var methodTypeSymbol = null; - - var linkKind = isPrivate ? 6 /* PrivateMember */ : 5 /* PublicMember */; - - if (parent.isClass() && isStatic) { - parent = (parent).getConstructorMethod().getType(); - } - - methodSymbol = parent.findMember(methodName, false); - - if (methodSymbol && (methodSymbol.getKind() !== 65536 /* Method */ || (this.symbolIsRedeclaration(methodSymbol) && !isSignature && !methodSymbol.allDeclsHaveFlag(2048 /* Signature */)))) { - methodDeclaration.addDiagnostic(new TypeScript.SemanticDiagnostic(this.semanticInfo.getPath(), methodAST.minChar, methodAST.getLength(), 69 /* Duplicate_identifier__0_ */, [methodDeclaration.getDisplayName()])); - methodSymbol = null; - } - - if (methodSymbol) { - methodTypeSymbol = methodSymbol.getType(); - parentHadSymbol = true; - } - - if (this.reBindingAfterChange && methodSymbol) { - var decls = methodSymbol.getDeclarations(); - var scriptName = methodDeclaration.getScriptName(); - var isGeneric = methodTypeSymbol.isGeneric(); - - for (var j = 0; j < decls.length; j++) { - if (decls[j].getScriptName() === scriptName && decls[j].getDeclID() < this.startingDeclForRebind) { - methodSymbol.removeDeclaration(decls[j]); - - cleanedPreviousDecls = true; - } - } - - decls = methodTypeSymbol.getDeclarations(); - for (var j = 0; j < decls.length; j++) { - if (decls[j].getScriptName() === scriptName && decls[j].getDeclID() < this.startingDeclForRebind) { - methodTypeSymbol.removeDeclaration(decls[j]); - - cleanedPreviousDecls = true; - } - } - - if (isGeneric) { - var specializations = methodTypeSymbol.getKnownSpecializations(); - - for (var i = 0; i < specializations.length; i++) { - specializations[i].invalidate(); - } - } - - methodSymbol.invalidate(); - methodTypeSymbol.invalidate(); - } - - if (!methodSymbol) { - methodSymbol = new TypeScript.PullSymbol(methodName, 65536 /* Method */); - } - - if (!methodTypeSymbol) { - methodTypeSymbol = new TypeScript.PullFunctionTypeSymbol(); - methodSymbol.setType(methodTypeSymbol); - } - - methodDeclaration.setSymbol(methodSymbol); - methodSymbol.addDeclaration(methodDeclaration); - methodTypeSymbol.addDeclaration(methodDeclaration); - this.semanticInfo.setSymbolAndDiagnosticsForAST(methodAST.name, TypeScript.SymbolAndDiagnostics.fromSymbol(methodSymbol)); - this.semanticInfo.setSymbolAndDiagnosticsForAST(methodAST, TypeScript.SymbolAndDiagnostics.fromSymbol(methodSymbol)); - - if (isOptional) { - methodSymbol.setIsOptional(); - } - - if (!parentHadSymbol) { - parent.addMember(methodSymbol, linkKind); - } - - if (parentHadSymbol && cleanedPreviousDecls) { - var callSigs = methodTypeSymbol.getCallSignatures(); - var constructSigs = methodTypeSymbol.getConstructSignatures(); - var indexSigs = methodTypeSymbol.getIndexSignatures(); - - for (var i = 0; i < callSigs.length; i++) { - methodTypeSymbol.removeCallSignature(callSigs[i], false); - } - for (var i = 0; i < constructSigs.length; i++) { - methodTypeSymbol.removeConstructSignature(constructSigs[i], false); - } - for (var i = 0; i < indexSigs.length; i++) { - methodTypeSymbol.removeIndexSignature(indexSigs[i], false); - } - - methodSymbol.invalidate(); - methodTypeSymbol.invalidate(); - methodTypeSymbol.recomputeCallSignatures(); - methodTypeSymbol.recomputeConstructSignatures(); - methodTypeSymbol.recomputeIndexSignatures(); - - if (isGeneric) { - var specializations = methodTypeSymbol.getKnownSpecializations(); - - for (var j = 0; j < specializations.length; j++) { - callSigs = specializations[j].getCallSignatures(); - - for (var i = 0; i < callSigs.length; i++) { - callSigs[i].invalidate(); - } - } - } - } - - var sigKind = 1048576 /* CallSignature */; - - var signature = isSignature ? new TypeScript.PullSignatureSymbol(sigKind) : new TypeScript.PullDefinitionSignatureSymbol(sigKind); - - if (methodAST.variableArgList) { - signature.setHasVariableParamList(); - } - - var typeParameters = methodDeclaration.getTypeParameters(); - var typeParameter; - var typeParameterDecls = null; - var typeParameterName; - var typeParameterAST; - - for (var i = 0; i < typeParameters.length; i++) { - typeParameterName = typeParameters[i].getName(); - typeParameterAST = this.semanticInfo.getASTForDecl(typeParameters[i]); - - typeParameter = signature.findTypeParameter(typeParameterName); - - if (!typeParameter) { - if (!typeParameterAST.constraint) { - typeParameter = this.findTypeParameterInCache(typeParameterName); - } - - if (!typeParameter) { - typeParameter = new TypeScript.PullTypeParameterSymbol(typeParameterName, true); - - if (!typeParameterAST.constraint) { - this.addTypeParameterToCache(typeParameter); - } - } - - signature.addTypeParameter(typeParameter); - } else { - typeParameterDecls = typeParameter.getDeclarations(); - - if (this.symbolIsRedeclaration(typeParameter)) { - typeParameterAST = this.semanticInfoChain.getASTForDecl(typeParameterDecls[0]); - methodDeclaration.addDiagnostic(new TypeScript.SemanticDiagnostic(this.semanticInfo.getPath(), typeParameterAST.minChar, typeParameterAST.getLength(), 69 /* Duplicate_identifier__0_ */, [typeParameter.getName()])); - } - - typeParameterDecls = typeParameter.getDeclarations(); - - for (var j = 0; j < typeParameterDecls.length; j++) { - if (typeParameterDecls[j].getDeclID() < this.startingDeclForRebind) { - typeParameter.removeDeclaration(typeParameterDecls[j]); - } - } - } - - typeParameter.addDeclaration(typeParameters[i]); - typeParameters[i].setSymbol(typeParameter); - } - - signature.addDeclaration(methodDeclaration); - methodDeclaration.setSignatureSymbol(signature); - - this.bindParameterSymbols(this.semanticInfo.getASTForDecl(methodDeclaration), methodTypeSymbol, signature); - - methodTypeSymbol.addSignature(signature); - - if (!isSignature) { - } - - var otherDecls = this.findDeclsInContext(methodDeclaration, methodDeclaration.getKind(), false); - - if (otherDecls && otherDecls.length) { - for (var i = 0; i < otherDecls.length; i++) { - otherDecls[i].ensureSymbolIsBound(); - } - } - }; - - PullSymbolBinder.prototype.bindConstructorDeclarationToPullSymbol = function (constructorDeclaration) { - var declKind = constructorDeclaration.getKind(); - var declFlags = constructorDeclaration.getFlags(); - var constructorAST = this.semanticInfo.getASTForDecl(constructorDeclaration); - - var constructorName = constructorDeclaration.getName(); - - var isSignature = (declFlags & 2048 /* Signature */) !== 0; - - var parent = this.getParent(constructorDeclaration, true); - - var parentHadSymbol = false; - var cleanedPreviousDecls = false; - - var constructorSymbol = parent.getConstructorMethod(); - var constructorTypeSymbol = null; - - var linkKind = 7 /* ConstructorMethod */; - - if (constructorSymbol && (constructorSymbol.getKind() !== 32768 /* ConstructorMethod */ || (!isSignature && constructorSymbol.getType() && constructorSymbol.getType().hasOwnConstructSignatures() && (constructorSymbol.getType()).getDefinitionSignature() && !constructorSymbol.allDeclsHaveFlag(2048 /* Signature */)))) { - constructorDeclaration.addDiagnostic(new TypeScript.SemanticDiagnostic(this.semanticInfo.getPath(), constructorAST.minChar, constructorAST.getLength(), 139 /* Multiple_constructor_implementations_are_not_allowed */, null)); - - constructorSymbol = null; - } - - if (constructorSymbol) { - constructorTypeSymbol = constructorSymbol.getType(); - - if (this.reBindingAfterChange) { - var decls = constructorSymbol.getDeclarations(); - var scriptName = constructorDeclaration.getScriptName(); - var isGeneric = constructorTypeSymbol.isGeneric(); - - for (var j = 0; j < decls.length; j++) { - if (decls[j].getScriptName() === scriptName && decls[j].getDeclID() < this.startingDeclForRebind) { - constructorSymbol.removeDeclaration(decls[j]); - - cleanedPreviousDecls = true; - } - } - - decls = constructorTypeSymbol.getDeclarations(); - - for (var j = 0; j < decls.length; j++) { - if (decls[j].getScriptName() === scriptName && decls[j].getDeclID() < this.startingDeclForRebind) { - constructorTypeSymbol.removeDeclaration(decls[j]); - - cleanedPreviousDecls = true; - } - } - - if (isGeneric) { - var specializations = constructorTypeSymbol.getKnownSpecializations(); - - for (var i = 0; i < specializations.length; i++) { - specializations[i].invalidate(); - } - } - - constructorSymbol.invalidate(); - constructorTypeSymbol.invalidate(); - } - } - - if (!constructorSymbol) { - constructorSymbol = new TypeScript.PullSymbol(constructorName, 32768 /* ConstructorMethod */); - constructorTypeSymbol = new TypeScript.PullConstructorTypeSymbol(); - } - - parent.setConstructorMethod(constructorSymbol); - constructorSymbol.setType(constructorTypeSymbol); - - constructorDeclaration.setSymbol(constructorSymbol); - constructorSymbol.addDeclaration(constructorDeclaration); - constructorTypeSymbol.addDeclaration(constructorDeclaration); - this.semanticInfo.setSymbolAndDiagnosticsForAST(constructorAST, TypeScript.SymbolAndDiagnostics.fromSymbol(constructorSymbol)); - - if (parentHadSymbol && cleanedPreviousDecls) { - var constructSigs = constructorTypeSymbol.getConstructSignatures(); - - for (var i = 0; i < constructSigs.length; i++) { - constructorTypeSymbol.removeConstructSignature(constructSigs[i]); - } - - constructorSymbol.invalidate(); - constructorTypeSymbol.invalidate(); - constructorTypeSymbol.recomputeConstructSignatures(); - - if (isGeneric) { - var specializations = constructorTypeSymbol.getKnownSpecializations(); - - for (var j = 0; j < specializations.length; j++) { - constructSigs = specializations[j].getConstructSignatures(); - - for (var i = 0; i < constructSigs.length; i++) { - constructSigs[i].invalidate(); - } - } - } - } - - var constructSignature = isSignature ? new TypeScript.PullSignatureSymbol(2097152 /* ConstructSignature */) : new TypeScript.PullDefinitionSignatureSymbol(2097152 /* ConstructSignature */); - - constructSignature.setReturnType(parent); - - constructSignature.addDeclaration(constructorDeclaration); - constructorDeclaration.setSignatureSymbol(constructSignature); - - this.bindParameterSymbols(constructorAST, constructorTypeSymbol, constructSignature); - - var typeParameters = constructorTypeSymbol.getTypeParameters(); - - for (var i = 0; i < typeParameters.length; i++) { - constructSignature.addTypeParameter(typeParameters[i]); - } - - if (constructorAST.variableArgList) { - constructSignature.setHasVariableParamList(); - } - - constructorTypeSymbol.addSignature(constructSignature); - - if (!isSignature) { - } - - var otherDecls = this.findDeclsInContext(constructorDeclaration, constructorDeclaration.getKind(), false); - - if (otherDecls && otherDecls.length) { - for (var i = 0; i < otherDecls.length; i++) { - otherDecls[i].ensureSymbolIsBound(); - } - } - }; - - PullSymbolBinder.prototype.bindConstructSignatureDeclarationToPullSymbol = function (constructSignatureDeclaration) { - var parent = this.getParent(constructSignatureDeclaration, true); - var constructorAST = this.semanticInfo.getASTForDecl(constructSignatureDeclaration); - - var constructSigs = parent.getConstructSignatures(); - - for (var i = 0; i < constructSigs.length; i++) { - if (constructSigs[i].getSymbolID() < this.startingSymbolForRebind) { - parent.removeConstructSignature(constructSigs[i], false); - } - } - - parent.recomputeConstructSignatures(); - var constructSignature = new TypeScript.PullSignatureSymbol(2097152 /* ConstructSignature */); - - if (constructorAST.variableArgList) { - constructSignature.setHasVariableParamList(); - } - - var typeParameters = constructSignatureDeclaration.getTypeParameters(); - var typeParameter; - var typeParameterDecls = null; - - for (var i = 0; i < typeParameters.length; i++) { - typeParameter = constructSignature.findTypeParameter(typeParameters[i].getName()); - - if (!typeParameter) { - typeParameter = new TypeScript.PullTypeParameterSymbol(typeParameters[i].getName(), true); - - constructSignature.addTypeParameter(typeParameter); - } else { - typeParameterDecls = typeParameter.getDeclarations(); - - if (this.symbolIsRedeclaration(typeParameter)) { - var typeParameterAST = this.semanticInfoChain.getASTForDecl(typeParameterDecls[0]); - constructSignatureDeclaration.addDiagnostic(new TypeScript.SemanticDiagnostic(this.semanticInfo.getPath(), typeParameterAST.minChar, typeParameterAST.getLength(), 69 /* Duplicate_identifier__0_ */, [typeParameter.getName()])); - } - - for (var j = 0; j < typeParameterDecls.length; j++) { - if (typeParameterDecls[j].getDeclID() < this.startingDeclForRebind) { - typeParameter.removeDeclaration(typeParameterDecls[j]); - } - } - } - - typeParameter.addDeclaration(typeParameters[i]); - typeParameters[i].setSymbol(typeParameter); - } - - constructSignature.addDeclaration(constructSignatureDeclaration); - constructSignatureDeclaration.setSignatureSymbol(constructSignature); - - this.bindParameterSymbols(this.semanticInfo.getASTForDecl(constructSignatureDeclaration), null, constructSignature); - - this.semanticInfo.setSymbolAndDiagnosticsForAST(this.semanticInfo.getASTForDecl(constructSignatureDeclaration), TypeScript.SymbolAndDiagnostics.fromSymbol(constructSignature)); - - parent.addConstructSignature(constructSignature); - }; - - PullSymbolBinder.prototype.bindCallSignatureDeclarationToPullSymbol = function (callSignatureDeclaration) { - var parent = this.getParent(callSignatureDeclaration, true); - var callSignatureAST = this.semanticInfo.getASTForDecl(callSignatureDeclaration); - - var callSigs = parent.getCallSignatures(); - - for (var i = 0; i < callSigs.length; i++) { - if (callSigs[i].getSymbolID() < this.startingSymbolForRebind) { - parent.removeCallSignature(callSigs[i], false); - } - } - - parent.recomputeCallSignatures(); - - var callSignature = new TypeScript.PullSignatureSymbol(1048576 /* CallSignature */); - - if (callSignatureAST.variableArgList) { - callSignature.setHasVariableParamList(); - } - - var typeParameters = callSignatureDeclaration.getTypeParameters(); - var typeParameter; - var typeParameterDecls = null; - - for (var i = 0; i < typeParameters.length; i++) { - typeParameter = callSignature.findTypeParameter(typeParameters[i].getName()); - - if (!typeParameter) { - typeParameter = new TypeScript.PullTypeParameterSymbol(typeParameters[i].getName(), true); - - callSignature.addTypeParameter(typeParameter); - } else { - typeParameterDecls = typeParameter.getDeclarations(); - - if (this.symbolIsRedeclaration(typeParameter)) { - var typeParameterAST = this.semanticInfoChain.getASTForDecl(typeParameterDecls[0]); - callSignatureDeclaration.addDiagnostic(new TypeScript.SemanticDiagnostic(this.semanticInfo.getPath(), typeParameterAST.minChar, typeParameterAST.getLength(), 69 /* Duplicate_identifier__0_ */, [typeParameter.getName()])); - } - - for (var j = 0; j < typeParameterDecls.length; j++) { - if (typeParameterDecls[j].getDeclID() < this.startingDeclForRebind) { - typeParameter.removeDeclaration(typeParameterDecls[j]); - } - } - } - - typeParameter.addDeclaration(typeParameters[i]); - typeParameters[i].setSymbol(typeParameter); - } - - callSignature.addDeclaration(callSignatureDeclaration); - callSignatureDeclaration.setSignatureSymbol(callSignature); - - this.bindParameterSymbols(this.semanticInfo.getASTForDecl(callSignatureDeclaration), null, callSignature); - - this.semanticInfo.setSymbolAndDiagnosticsForAST(this.semanticInfo.getASTForDecl(callSignatureDeclaration), TypeScript.SymbolAndDiagnostics.fromSymbol(callSignature)); - - parent.addCallSignature(callSignature); - }; - - PullSymbolBinder.prototype.bindIndexSignatureDeclarationToPullSymbol = function (indexSignatureDeclaration) { - var parent = this.getParent(indexSignatureDeclaration, true); - - var indexSigs = parent.getIndexSignatures(); - - for (var i = 0; i < indexSigs.length; i++) { - if (indexSigs[i].getSymbolID() < this.startingSymbolForRebind) { - parent.removeIndexSignature(indexSigs[i], false); - } - } - - parent.recomputeIndexSignatures(); - - var indexSignature = new TypeScript.PullSignatureSymbol(4194304 /* IndexSignature */); - - var typeParameters = indexSignatureDeclaration.getTypeParameters(); - var typeParameter; - var typeParameterDecls = null; - - for (var i = 0; i < typeParameters.length; i++) { - typeParameter = indexSignature.findTypeParameter(typeParameters[i].getName()); - - if (!typeParameter) { - typeParameter = new TypeScript.PullTypeParameterSymbol(typeParameters[i].getName(), true); - - indexSignature.addTypeParameter(typeParameter); - } else { - typeParameterDecls = typeParameter.getDeclarations(); - - if (this.symbolIsRedeclaration(typeParameter)) { - var typeParameterAST = this.semanticInfoChain.getASTForDecl(typeParameterDecls[0]); - indexSignatureDeclaration.addDiagnostic(new TypeScript.SemanticDiagnostic(this.semanticInfo.getPath(), typeParameterAST.minChar, typeParameterAST.getLength(), 69 /* Duplicate_identifier__0_ */, [typeParameter.getName()])); - } - - typeParameterDecls = typeParameter.getDeclarations(); - - for (var j = 0; j < typeParameterDecls.length; j++) { - if (typeParameterDecls[j].getDeclID() < this.startingDeclForRebind) { - typeParameter.removeDeclaration(typeParameterDecls[j]); - } - } - } - - typeParameter.addDeclaration(typeParameters[i]); - typeParameters[i].setSymbol(typeParameter); - } - - indexSignature.addDeclaration(indexSignatureDeclaration); - indexSignatureDeclaration.setSignatureSymbol(indexSignature); - - this.bindParameterSymbols(this.semanticInfo.getASTForDecl(indexSignatureDeclaration), null, indexSignature); - - this.semanticInfo.setSymbolAndDiagnosticsForAST(this.semanticInfo.getASTForDecl(indexSignatureDeclaration), TypeScript.SymbolAndDiagnostics.fromSymbol(indexSignature)); - - parent.addIndexSignature(indexSignature); - }; - - PullSymbolBinder.prototype.bindGetAccessorDeclarationToPullSymbol = function (getAccessorDeclaration) { - var declKind = getAccessorDeclaration.getKind(); - var declFlags = getAccessorDeclaration.getFlags(); - var funcDeclAST = this.semanticInfo.getASTForDecl(getAccessorDeclaration); - - var isExported = (declFlags & 1 /* Exported */) !== 0; - - var funcName = getAccessorDeclaration.getName(); - - var isSignature = (declFlags & 2048 /* Signature */) !== 0; - var isStatic = false; - var linkKind = 5 /* PublicMember */; - - if (TypeScript.hasFlag(declFlags, 16 /* Static */)) { - isStatic = true; - } - - if (TypeScript.hasFlag(declFlags, 2 /* Private */)) { - linkKind = 6 /* PrivateMember */; - } - - var parent = this.getParent(getAccessorDeclaration, true); - var parentHadSymbol = false; - var cleanedPreviousDecls = false; - - var accessorSymbol = null; - var getterSymbol = null; - var getterTypeSymbol = null; - - if (isStatic) { - parent = (parent).getConstructorMethod().getType(); - } - - accessorSymbol = parent.findMember(funcName, false); - - if (accessorSymbol) { - if (!accessorSymbol.isAccessor()) { - getAccessorDeclaration.addDiagnostic(new TypeScript.SemanticDiagnostic(this.semanticInfo.getPath(), funcDeclAST.minChar, funcDeclAST.getLength(), 69 /* Duplicate_identifier__0_ */, [getAccessorDeclaration.getDisplayName()])); - accessorSymbol = null; - } else { - getterSymbol = accessorSymbol.getGetter(); - - if (getterSymbol && (!this.reBindingAfterChange || this.symbolIsRedeclaration(getterSymbol))) { - getAccessorDeclaration.addDiagnostic(new TypeScript.SemanticDiagnostic(this.semanticInfo.getPath(), funcDeclAST.minChar, funcDeclAST.getLength(), 84 /* Getter__0__already_declared */, [getAccessorDeclaration.getDisplayName()])); - accessorSymbol = null; - getterSymbol = null; - } - } - } - - if (accessorSymbol) { - parentHadSymbol = true; - } - - if (accessorSymbol && getterSymbol) { - getterTypeSymbol = getterSymbol.getType(); - } - - if (this.reBindingAfterChange && accessorSymbol) { - var decls = accessorSymbol.getDeclarations(); - var scriptName = getAccessorDeclaration.getScriptName(); - - for (var j = 0; j < decls.length; j++) { - if (decls[j].getScriptName() === scriptName && decls[j].getDeclID() < this.startingDeclForRebind) { - accessorSymbol.removeDeclaration(decls[j]); - - cleanedPreviousDecls = true; - } - } - - if (getterSymbol) { - decls = getterSymbol.getDeclarations(); - - for (var j = 0; j < decls.length; j++) { - if (decls[j].getScriptName() === scriptName && decls[j].getDeclID() < this.startingDeclForRebind) { - getterSymbol.removeDeclaration(decls[j]); - - cleanedPreviousDecls = true; - } - } - } - - accessorSymbol.invalidate(); - } - - if (!accessorSymbol) { - accessorSymbol = new TypeScript.PullAccessorSymbol(funcName); - } - - if (!getterSymbol) { - getterSymbol = new TypeScript.PullSymbol(funcName, 16384 /* Function */); - getterTypeSymbol = new TypeScript.PullFunctionTypeSymbol(); - - getterSymbol.setType(getterTypeSymbol); - - accessorSymbol.setGetter(getterSymbol); - } - - getAccessorDeclaration.setSymbol(accessorSymbol); - accessorSymbol.addDeclaration(getAccessorDeclaration); - getterSymbol.addDeclaration(getAccessorDeclaration); - - this.semanticInfo.setSymbolAndDiagnosticsForAST(funcDeclAST.name, TypeScript.SymbolAndDiagnostics.fromSymbol(getterSymbol)); - this.semanticInfo.setSymbolAndDiagnosticsForAST(funcDeclAST, TypeScript.SymbolAndDiagnostics.fromSymbol(getterSymbol)); - - if (!parentHadSymbol) { - parent.addMember(accessorSymbol, linkKind); - } - - if (parentHadSymbol && cleanedPreviousDecls) { - var callSigs = getterTypeSymbol.getCallSignatures(); - - for (var i = 0; i < callSigs.length; i++) { - getterTypeSymbol.removeCallSignature(callSigs[i], false); - } - - getterSymbol.invalidate(); - getterTypeSymbol.invalidate(); - getterTypeSymbol.recomputeCallSignatures(); - } - - var signature = isSignature ? new TypeScript.PullSignatureSymbol(1048576 /* CallSignature */) : new TypeScript.PullDefinitionSignatureSymbol(1048576 /* CallSignature */); - - signature.addDeclaration(getAccessorDeclaration); - getAccessorDeclaration.setSignatureSymbol(signature); - - this.bindParameterSymbols(this.semanticInfo.getASTForDecl(getAccessorDeclaration), getterTypeSymbol, signature); - - var typeParameters = getAccessorDeclaration.getTypeParameters(); - - if (typeParameters.length) { - getAccessorDeclaration.addDiagnostic(new TypeScript.SemanticDiagnostic(this.semanticInfo.getPath(), funcDeclAST.minChar, funcDeclAST.getLength(), 86 /* Accessor_cannot_have_type_parameters */, null)); - } - - getterTypeSymbol.addSignature(signature); - - if (!isSignature) { - } - - getterSymbol.setIsBound(this.bindingPhase); - }; - - PullSymbolBinder.prototype.bindSetAccessorDeclarationToPullSymbol = function (setAccessorDeclaration) { - var declKind = setAccessorDeclaration.getKind(); - var declFlags = setAccessorDeclaration.getFlags(); - var funcDeclAST = this.semanticInfo.getASTForDecl(setAccessorDeclaration); - - var isExported = (declFlags & 1 /* Exported */) !== 0; - - var funcName = setAccessorDeclaration.getName(); - - var isSignature = (declFlags & 2048 /* Signature */) !== 0; - var isStatic = false; - var linkKind = 5 /* PublicMember */; - - if (TypeScript.hasFlag(declFlags, 16 /* Static */)) { - isStatic = true; - } - - if (TypeScript.hasFlag(declFlags, 2 /* Private */)) { - linkKind = 6 /* PrivateMember */; - } - - var parent = this.getParent(setAccessorDeclaration, true); - var parentHadSymbol = false; - var cleanedPreviousDecls = false; - - var accessorSymbol = null; - var setterSymbol = null; - var setterTypeSymbol = null; - - if (isStatic) { - parent = (parent).getConstructorMethod().getType(); - } - - accessorSymbol = parent.findMember(funcName, false); - - if (accessorSymbol) { - if (!accessorSymbol.isAccessor()) { - setAccessorDeclaration.addDiagnostic(new TypeScript.SemanticDiagnostic(this.semanticInfo.getPath(), funcDeclAST.minChar, funcDeclAST.getLength(), 69 /* Duplicate_identifier__0_ */, [setAccessorDeclaration.getDisplayName()])); - accessorSymbol = null; - } else { - setterSymbol = accessorSymbol.getSetter(); - - if (setterSymbol && (!this.reBindingAfterChange || this.symbolIsRedeclaration(setterSymbol))) { - setAccessorDeclaration.addDiagnostic(new TypeScript.SemanticDiagnostic(this.semanticInfo.getPath(), funcDeclAST.minChar, funcDeclAST.getLength(), 85 /* Setter__0__already_declared */, [setAccessorDeclaration.getDisplayName()])); - accessorSymbol = null; - setterSymbol = null; - } - } - } - - if (accessorSymbol) { - parentHadSymbol = true; - } - - if (accessorSymbol && setterSymbol) { - setterTypeSymbol = setterSymbol.getType(); - } - - if (this.reBindingAfterChange && accessorSymbol) { - var decls = accessorSymbol.getDeclarations(); - var scriptName = setAccessorDeclaration.getScriptName(); - - for (var j = 0; j < decls.length; j++) { - if (decls[j].getScriptName() === scriptName && decls[j].getDeclID() < this.startingDeclForRebind) { - accessorSymbol.removeDeclaration(decls[j]); - - cleanedPreviousDecls = true; - } - } - - if (setterSymbol) { - decls = setterSymbol.getDeclarations(); - - for (var j = 0; j < decls.length; j++) { - if (decls[j].getScriptName() === scriptName && decls[j].getDeclID() < this.startingDeclForRebind) { - setterSymbol.removeDeclaration(decls[j]); - - cleanedPreviousDecls = true; - } - } - } - - accessorSymbol.invalidate(); - } - - if (!accessorSymbol) { - accessorSymbol = new TypeScript.PullAccessorSymbol(funcName); - } - - if (!setterSymbol) { - setterSymbol = new TypeScript.PullSymbol(funcName, 16384 /* Function */); - setterTypeSymbol = new TypeScript.PullFunctionTypeSymbol(); - - setterSymbol.setType(setterTypeSymbol); - - accessorSymbol.setSetter(setterSymbol); - } - - setAccessorDeclaration.setSymbol(accessorSymbol); - accessorSymbol.addDeclaration(setAccessorDeclaration); - setterSymbol.addDeclaration(setAccessorDeclaration); - - this.semanticInfo.setSymbolAndDiagnosticsForAST(funcDeclAST.name, TypeScript.SymbolAndDiagnostics.fromSymbol(setterSymbol)); - this.semanticInfo.setSymbolAndDiagnosticsForAST(funcDeclAST, TypeScript.SymbolAndDiagnostics.fromSymbol(setterSymbol)); - - if (!parentHadSymbol) { - parent.addMember(accessorSymbol, linkKind); - } - - if (parentHadSymbol && cleanedPreviousDecls) { - var callSigs = setterTypeSymbol.getCallSignatures(); - - for (var i = 0; i < callSigs.length; i++) { - setterTypeSymbol.removeCallSignature(callSigs[i], false); - } - - setterSymbol.invalidate(); - setterTypeSymbol.invalidate(); - setterTypeSymbol.recomputeCallSignatures(); - } - - var signature = isSignature ? new TypeScript.PullSignatureSymbol(1048576 /* CallSignature */) : new TypeScript.PullDefinitionSignatureSymbol(1048576 /* CallSignature */); - - signature.addDeclaration(setAccessorDeclaration); - setAccessorDeclaration.setSignatureSymbol(signature); - - this.bindParameterSymbols(this.semanticInfo.getASTForDecl(setAccessorDeclaration), setterTypeSymbol, signature); - - var typeParameters = setAccessorDeclaration.getTypeParameters(); - - if (typeParameters.length) { - setAccessorDeclaration.addDiagnostic(new TypeScript.SemanticDiagnostic(this.semanticInfo.getPath(), funcDeclAST.minChar, funcDeclAST.getLength(), 86 /* Accessor_cannot_have_type_parameters */, null)); - } - - setterTypeSymbol.addSignature(signature); - - if (!isSignature) { - } - - setterSymbol.setIsBound(this.bindingPhase); - }; - - PullSymbolBinder.prototype.bindCatchBlockPullSymbols = function (catchBlockDecl) { - }; - - PullSymbolBinder.prototype.bindWithBlockPullSymbols = function (withBlockDecl) { - }; - - PullSymbolBinder.prototype.bindDeclToPullSymbol = function (decl, rebind) { - if (typeof rebind === "undefined") { rebind = false; } - if (rebind) { - this.startingDeclForRebind = TypeScript.lastBoundPullDeclId; - this.startingSymbolForRebind = TypeScript.lastBoundPullSymbolID; - this.reBindingAfterChange = true; - } - - if (decl.isBound()) { - return; - } - - decl.setIsBound(true); - - switch (decl.getKind()) { - case 1 /* Script */: - var childDecls = decl.getChildDecls(); - for (var i = 0; i < childDecls.length; i++) { - this.bindDeclToPullSymbol(childDecls[i]); - } - break; - - case 64 /* Enum */: - case 32 /* DynamicModule */: - case 4 /* Container */: - this.bindModuleDeclarationToPullSymbol(decl); - break; - - case 16 /* Interface */: - this.bindInterfaceDeclarationToPullSymbol(decl); - break; - - case 8 /* Class */: - this.bindClassDeclarationToPullSymbol(decl); - break; - - case 16384 /* Function */: - this.bindFunctionDeclarationToPullSymbol(decl); - break; - - case 1024 /* Variable */: - this.bindVariableDeclarationToPullSymbol(decl); - break; - - case 67108864 /* EnumMember */: - case 4096 /* Property */: - this.bindPropertyDeclarationToPullSymbol(decl); - break; - - case 65536 /* Method */: - this.bindMethodDeclarationToPullSymbol(decl); - break; - - case 32768 /* ConstructorMethod */: - this.bindConstructorDeclarationToPullSymbol(decl); - break; - - case 1048576 /* CallSignature */: - this.bindCallSignatureDeclarationToPullSymbol(decl); - break; - - case 2097152 /* ConstructSignature */: - this.bindConstructSignatureDeclarationToPullSymbol(decl); - break; - - case 4194304 /* IndexSignature */: - this.bindIndexSignatureDeclarationToPullSymbol(decl); - break; - - case 262144 /* GetAccessor */: - this.bindGetAccessorDeclarationToPullSymbol(decl); - break; - - case 524288 /* SetAccessor */: - this.bindSetAccessorDeclarationToPullSymbol(decl); - break; - - case 8388608 /* ObjectType */: - this.bindObjectTypeDeclarationToPullSymbol(decl); - break; - - case 16777216 /* FunctionType */: - this.bindFunctionTypeDeclarationToPullSymbol(decl); - break; - - case 33554432 /* ConstructorType */: - this.bindConstructorTypeDeclarationToPullSymbol(decl); - break; - - case 131072 /* FunctionExpression */: - this.bindFunctionExpressionToPullSymbol(decl); - break; - - case 256 /* TypeAlias */: - this.bindImportDeclaration(decl); - break; - - case 2048 /* Parameter */: - case 8192 /* TypeParameter */: - break; - - case 1073741824 /* CatchBlock */: - this.bindCatchBlockPullSymbols(decl); - - case 536870912 /* WithBlock */: - this.bindWithBlockPullSymbols(decl); - break; - - default: - throw new Error("Unrecognized type declaration"); - } - }; - - PullSymbolBinder.prototype.bindDeclsForUnit = function (filePath, rebind) { - if (typeof rebind === "undefined") { rebind = false; } - this.setUnit(filePath); - - var topLevelDecls = this.semanticInfo.getTopLevelDecls(); - - for (var i = 0; i < topLevelDecls.length; i++) { - this.bindDeclToPullSymbol(topLevelDecls[i], rebind); - } - }; - return PullSymbolBinder; - })(); - TypeScript.PullSymbolBinder = PullSymbolBinder; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - TypeScript.linkID = 0; - - var IListItem = (function () { - function IListItem(value) { - this.value = value; - this.next = null; - this.prev = null; - } - return IListItem; - })(); - TypeScript.IListItem = IListItem; - - var LinkList = (function () { - function LinkList() { - this.head = null; - this.last = null; - this.length = 0; - } - LinkList.prototype.addItem = function (item) { - if (!this.head) { - this.head = new IListItem(item); - this.last = this.head; - } else { - this.last.next = new IListItem(item); - this.last.next.prev = this.last; - this.last = this.last.next; - } - - this.length++; - }; - - LinkList.prototype.find = function (p) { - var node = this.head; - var vals = []; - - while (node) { - if (p(node.value)) { - vals[vals.length] = node.value; - } - node = node.next; - } - - return vals; - }; - - LinkList.prototype.remove = function (p) { - var node = this.head; - var prev = null; - var next = null; - - while (node) { - if (p(node.value)) { - if (node === this.head) { - if (this.last === this.head) { - this.last = null; - } - - this.head = this.head.next; - - if (this.head) { - this.head.prev = null; - } - } else { - prev = node.prev; - next = node.next; - - if (prev) { - prev.next = next; - } - if (next) { - next.prev = prev; - } - - if (node === this.last) { - this.last = prev; - } - } - - this.length--; - } - node = node.next; - } - }; - - LinkList.prototype.update = function (map, context) { - var node = this.head; - - while (node) { - map(node.value, context); - - node = node.next; - } - }; - return LinkList; - })(); - TypeScript.LinkList = LinkList; - - var PullSymbolLink = (function () { - function PullSymbolLink(start, end, kind) { - this.start = start; - this.end = end; - this.kind = kind; - this.id = TypeScript.linkID++; - } - return PullSymbolLink; - })(); - TypeScript.PullSymbolLink = PullSymbolLink; - - (function (GraphUpdateKind) { - GraphUpdateKind[GraphUpdateKind["NoUpdate"] = 0] = "NoUpdate"; - - GraphUpdateKind[GraphUpdateKind["SymbolRemoved"] = 1] = "SymbolRemoved"; - GraphUpdateKind[GraphUpdateKind["SymbolAdded"] = 2] = "SymbolAdded"; - - GraphUpdateKind[GraphUpdateKind["TypeChanged"] = 3] = "TypeChanged"; - })(TypeScript.GraphUpdateKind || (TypeScript.GraphUpdateKind = {})); - var GraphUpdateKind = TypeScript.GraphUpdateKind; - - var PullSymbolUpdate = (function () { - function PullSymbolUpdate(updateKind, symbolToUpdate, updater) { - this.updateKind = updateKind; - this.symbolToUpdate = symbolToUpdate; - this.updater = updater; - } - return PullSymbolUpdate; - })(); - TypeScript.PullSymbolUpdate = PullSymbolUpdate; - - TypeScript.updateVersion = 0; - - var PullSymbolGraphUpdater = (function () { - function PullSymbolGraphUpdater(semanticInfoChain) { - this.semanticInfoChain = semanticInfoChain; - } - PullSymbolGraphUpdater.prototype.removeDecl = function (declToRemove) { - var declSymbol = declToRemove.getSymbol(); - - if (declSymbol) { - declSymbol.removeDeclaration(declToRemove); - - var childDecls = declToRemove.getChildDecls(); - - for (var i = 0; i < childDecls.length; i++) { - this.removeDecl(childDecls[i]); - } - - var remainingDecls = declSymbol.getDeclarations(); - - if (!remainingDecls.length) { - this.removeSymbol(declSymbol); - - this.semanticInfoChain.removeSymbolFromCache(declSymbol); - } else { - declSymbol.invalidate(); - } - } - - var valDecl = declToRemove.getValueDecl(); - - if (valDecl) { - this.removeDecl(valDecl); - } - - TypeScript.updateVersion++; - }; - - PullSymbolGraphUpdater.prototype.addDecl = function (declToAdd) { - var symbolToAdd = declToAdd.getSymbol(); - - if (symbolToAdd) { - this.addSymbol(symbolToAdd); - } - - TypeScript.updateVersion++; - }; - - PullSymbolGraphUpdater.prototype.removeSymbol = function (symbolToRemove) { - if (symbolToRemove.removeUpdateVersion === TypeScript.updateVersion) { - return; - } - - symbolToRemove.removeUpdateVersion = TypeScript.updateVersion; - - symbolToRemove.updateOutgoingLinks(propagateRemovalToOutgoingLinks, new PullSymbolUpdate(1 /* SymbolRemoved */, symbolToRemove, this)); - - symbolToRemove.updateIncomingLinks(propagateRemovalToIncomingLinks, new PullSymbolUpdate(1 /* SymbolRemoved */, symbolToRemove, this)); - - symbolToRemove.unsetContainer(); - - this.semanticInfoChain.removeSymbolFromCache(symbolToRemove); - - var container = symbolToRemove.getContainer(); - - if (container) { - container.removeMember(symbolToRemove); - this.semanticInfoChain.removeSymbolFromCache(symbolToRemove); - } - - if (symbolToRemove.isAccessor()) { - var getterSymbol = (symbolToRemove).getGetter(); - var setterSymbol = (symbolToRemove).getSetter(); - - if (getterSymbol) { - this.removeSymbol(getterSymbol); - } - - if (setterSymbol) { - this.removeSymbol(setterSymbol); - } - } - - symbolToRemove.removeAllLinks(); - }; - - PullSymbolGraphUpdater.prototype.addSymbol = function (symbolToAdd) { - if (symbolToAdd.addUpdateVersion === TypeScript.updateVersion) { - return; - } - - symbolToAdd.addUpdateVersion = TypeScript.updateVersion; - - symbolToAdd.updateOutgoingLinks(propagateAdditionToOutgoingLinks, new PullSymbolUpdate(2 /* SymbolAdded */, symbolToAdd, this)); - - symbolToAdd.updateIncomingLinks(propagateAdditionToIncomingLinks, new PullSymbolUpdate(2 /* SymbolAdded */, symbolToAdd, this)); - }; - - PullSymbolGraphUpdater.prototype.invalidateType = function (symbolWhoseTypeChanged) { - if (!symbolWhoseTypeChanged) { - return; - } - - if (symbolWhoseTypeChanged.isPrimitive()) { - return; - } - - if (symbolWhoseTypeChanged.typeChangeUpdateVersion === TypeScript.updateVersion) { - return; - } - - symbolWhoseTypeChanged.typeChangeUpdateVersion = TypeScript.updateVersion; - - symbolWhoseTypeChanged.updateOutgoingLinks(propagateChangedTypeToOutgoingLinks, new PullSymbolUpdate(3 /* TypeChanged */, symbolWhoseTypeChanged, this)); - - symbolWhoseTypeChanged.updateIncomingLinks(propagateChangedTypeToIncomingLinks, new PullSymbolUpdate(3 /* TypeChanged */, symbolWhoseTypeChanged, this)); - - if (symbolWhoseTypeChanged.getKind() === 4 /* Container */) { - var instanceSymbol = (symbolWhoseTypeChanged).getInstanceSymbol(); - - this.invalidateType(instanceSymbol); - } - - if (symbolWhoseTypeChanged.isResolved()) { - symbolWhoseTypeChanged.invalidate(); - } - - this.invalidateUnitsForSymbol(symbolWhoseTypeChanged); - }; - - PullSymbolGraphUpdater.prototype.invalidateUnitsForSymbol = function (symbol) { - var declarations = symbol.getDeclarations(); - - for (var i = 0; i < declarations.length; i++) { - this.semanticInfoChain.invalidateUnit(declarations[i].getScriptName()); - } - }; - return PullSymbolGraphUpdater; - })(); - TypeScript.PullSymbolGraphUpdater = PullSymbolGraphUpdater; - - function propagateRemovalToOutgoingLinks(link, update) { - var symbolToRemove = update.symbolToUpdate; - var affectedSymbol = link.end; - - if (affectedSymbol.removeUpdateVersion === TypeScript.updateVersion || affectedSymbol.isPrimitive()) { - return; - } - - if (link.kind === 2 /* ProvidesInferredType */) { - update.updater.invalidateType(affectedSymbol); - } else if (link.kind === 21 /* SpecializedTo */) { - (symbolToRemove).removeSpecialization(affectedSymbol); - update.updater.removeSymbol(affectedSymbol); - update.updater.invalidateType(affectedSymbol); - } else if (link.kind === 5 /* PublicMember */) { - update.updater.removeSymbol(affectedSymbol); - } else if (link.kind === 6 /* PrivateMember */) { - update.updater.removeSymbol(affectedSymbol); - } else if (link.kind === 7 /* ConstructorMethod */) { - update.updater.invalidateType(affectedSymbol); - } else if (link.kind === 10 /* ContainedBy */) { - (affectedSymbol).removeMember(symbolToRemove); - update.updater.invalidateType(affectedSymbol); - } else if (link.kind === 13 /* Parameter */) { - update.updater.removeSymbol(affectedSymbol); - } else if (link.kind === 15 /* CallSignature */) { - update.updater.invalidateType(affectedSymbol); - } else if (link.kind === 16 /* ConstructSignature */) { - update.updater.invalidateType(affectedSymbol); - } else if (link.kind === 17 /* IndexSignature */) { - update.updater.invalidateType(affectedSymbol); - } - - symbolToRemove.removeOutgoingLink(link); - } - TypeScript.propagateRemovalToOutgoingLinks = propagateRemovalToOutgoingLinks; - - function propagateRemovalToIncomingLinks(link, update) { - var symbolToRemove = update.symbolToUpdate; - var affectedSymbol = link.start; - - if (affectedSymbol.removeUpdateVersion === TypeScript.updateVersion || affectedSymbol.isPrimitive()) { - return; - } - - if (link.kind === 0 /* TypedAs */) { - update.updater.invalidateType(affectedSymbol); - } else if (link.kind === 1 /* ContextuallyTypedAs */) { - update.updater.invalidateType(affectedSymbol); - } else if (link.kind === 18 /* TypeParameter */) { - update.updater.invalidateType(affectedSymbol); - } else if (link.kind === 19 /* TypeArgument */) { - update.updater.invalidateType(affectedSymbol); - } else if (link.kind === 21 /* SpecializedTo */) { - (affectedSymbol).removeSpecialization(symbolToRemove); - } else if (link.kind === 22 /* TypeConstraint */) { - update.updater.invalidateType(affectedSymbol); - } else if (link.kind === 5 /* PublicMember */) { - (affectedSymbol).removeMember(symbolToRemove); - update.updater.invalidateType(affectedSymbol); - } else if (link.kind === 6 /* PrivateMember */) { - (affectedSymbol).removeMember(symbolToRemove); - update.updater.invalidateType(affectedSymbol); - } else if (link.kind === 7 /* ConstructorMethod */) { - update.updater.invalidateType(affectedSymbol); - } else if (link.kind === 10 /* ContainedBy */) { - update.updater.invalidateType(affectedSymbol); - } else if (link.kind === 11 /* Extends */) { - update.updater.invalidateType(affectedSymbol); - } else if (link.kind === 12 /* Implements */) { - update.updater.invalidateType(affectedSymbol); - } else if (link.kind === 13 /* Parameter */) { - update.updater.invalidateType(affectedSymbol); - } else if (link.kind === 14 /* ReturnType */) { - update.updater.invalidateType(affectedSymbol); - } else if (link.kind === 15 /* CallSignature */) { - update.updater.invalidateType(affectedSymbol); - } else if (link.kind === 16 /* ConstructSignature */) { - update.updater.invalidateType(affectedSymbol); - } else if (link.kind === 17 /* IndexSignature */) { - update.updater.invalidateType(affectedSymbol); - } else if (link.kind === 8 /* Aliases */) { - update.updater.invalidateType(affectedSymbol); - } else if (link.kind === 9 /* ExportAliases */) { - update.updater.invalidateType(affectedSymbol); - } - } - TypeScript.propagateRemovalToIncomingLinks = propagateRemovalToIncomingLinks; - - function propagateAdditionToOutgoingLinks(link, update) { - var symbolToAdd = update.symbolToUpdate; - var affectedSymbol = link.end; - - if (affectedSymbol.addUpdateVersion === TypeScript.updateVersion || affectedSymbol.isPrimitive()) { - return; - } - - if (link.kind === 10 /* ContainedBy */) { - update.updater.invalidateType(affectedSymbol); - } else if (link.kind === 2 /* ProvidesInferredType */) { - update.updater.invalidateType(affectedSymbol); - } else if (link.kind === 18 /* TypeParameter */) { - update.updater.invalidateType(affectedSymbol); - } else if (link.kind === 19 /* TypeArgument */) { - update.updater.invalidateType(affectedSymbol); - } else if (link.kind === 21 /* SpecializedTo */) { - update.updater.invalidateType(affectedSymbol); - } else if (link.kind === 22 /* TypeConstraint */) { - update.updater.invalidateType(affectedSymbol); - } else if (link.kind === 5 /* PublicMember */) { - update.updater.invalidateType(affectedSymbol); - } else if (link.kind === 7 /* ConstructorMethod */) { - update.updater.invalidateType(affectedSymbol); - } else if (link.kind === 14 /* ReturnType */) { - update.updater.invalidateType(affectedSymbol); - } else if (link.kind === 15 /* CallSignature */) { - update.updater.invalidateType(affectedSymbol); - } else if (link.kind === 16 /* ConstructSignature */) { - update.updater.invalidateType(affectedSymbol); - } else if (link.kind === 17 /* IndexSignature */) { - update.updater.invalidateType(affectedSymbol); - } - } - TypeScript.propagateAdditionToOutgoingLinks = propagateAdditionToOutgoingLinks; - - function propagateAdditionToIncomingLinks(link, update) { - var symbolToAdd = update.symbolToUpdate; - var affectedSymbol = link.start; - - if (affectedSymbol.addUpdateVersion === TypeScript.updateVersion || affectedSymbol.isPrimitive()) { - return; - } - - if (link.kind === 0 /* TypedAs */) { - update.updater.invalidateType(affectedSymbol); - } else if (link.kind === 1 /* ContextuallyTypedAs */) { - update.updater.invalidateType(affectedSymbol); - } else if (link.kind === 18 /* TypeParameter */) { - update.updater.invalidateType(affectedSymbol); - } else if (link.kind === 19 /* TypeArgument */) { - update.updater.invalidateType(affectedSymbol); - } else if (link.kind === 22 /* TypeConstraint */) { - update.updater.invalidateType(affectedSymbol); - } else if (link.kind === 5 /* PublicMember */) { - update.updater.invalidateType(affectedSymbol); - } else if (link.kind === 7 /* ConstructorMethod */) { - update.updater.invalidateType(affectedSymbol); - } else if (link.kind === 11 /* Extends */) { - update.updater.invalidateType(affectedSymbol); - } else if (link.kind === 12 /* Implements */) { - update.updater.invalidateType(affectedSymbol); - } else if (link.kind === 14 /* ReturnType */) { - update.updater.invalidateType(affectedSymbol); - } else if (link.kind === 8 /* Aliases */) { - update.updater.invalidateType(affectedSymbol); - } else if (link.kind === 9 /* ExportAliases */) { - update.updater.invalidateType(affectedSymbol); - } - } - TypeScript.propagateAdditionToIncomingLinks = propagateAdditionToIncomingLinks; - - function propagateChangedTypeToOutgoingLinks(link, update) { - var symbolWhoseTypeChanged = update.symbolToUpdate; - var affectedSymbol = link.end; - - if (affectedSymbol.typeChangeUpdateVersion === TypeScript.updateVersion || affectedSymbol.isPrimitive()) { - return; - } - - if (link.kind === 2 /* ProvidesInferredType */) { - update.updater.invalidateType(affectedSymbol); - } else if (link.kind === 10 /* ContainedBy */) { - update.updater.invalidateType(affectedSymbol); - } else if (link.kind === 18 /* TypeParameter */) { - update.updater.invalidateType(affectedSymbol); - } else if (link.kind === 19 /* TypeArgument */) { - update.updater.invalidateType(affectedSymbol); - } else if (link.kind === 21 /* SpecializedTo */) { - update.updater.invalidateType(affectedSymbol); - } else if (link.kind === 22 /* TypeConstraint */) { - update.updater.invalidateType(affectedSymbol); - } else if (link.kind === 5 /* PublicMember */) { - update.updater.invalidateType(affectedSymbol); - } else if (link.kind === 15 /* CallSignature */) { - update.updater.invalidateType(affectedSymbol); - } else if (link.kind === 7 /* ConstructorMethod */) { - update.updater.invalidateType(affectedSymbol); - } else if (link.kind === 16 /* ConstructSignature */) { - update.updater.invalidateType(affectedSymbol); - } else if (link.kind === 17 /* IndexSignature */) { - update.updater.invalidateType(affectedSymbol); - } - } - TypeScript.propagateChangedTypeToOutgoingLinks = propagateChangedTypeToOutgoingLinks; - - function propagateChangedTypeToIncomingLinks(link, update) { - var symbolWhoseTypeChanged = update.symbolToUpdate; - var affectedSymbol = link.start; - - if (affectedSymbol.typeChangeUpdateVersion === TypeScript.updateVersion || affectedSymbol.isPrimitive()) { - return; - } - - if (link.kind === 0 /* TypedAs */) { - update.updater.invalidateType(affectedSymbol); - } else if (link.kind === 1 /* ContextuallyTypedAs */) { - update.updater.invalidateType(affectedSymbol); - } else if (link.kind === 18 /* TypeParameter */) { - update.updater.invalidateType(affectedSymbol); - } else if (link.kind === 19 /* TypeArgument */) { - update.updater.invalidateType(affectedSymbol); - } else if (link.kind === 22 /* TypeConstraint */) { - update.updater.invalidateType(affectedSymbol); - } else if (link.kind === 5 /* PublicMember */) { - update.updater.invalidateType(affectedSymbol); - } else if (link.kind === 17 /* IndexSignature */) { - update.updater.invalidateType(affectedSymbol); - } else if (link.kind === 11 /* Extends */) { - update.updater.invalidateType(affectedSymbol); - } else if (link.kind === 12 /* Implements */) { - update.updater.invalidateType(affectedSymbol); - } else if (link.kind === 14 /* ReturnType */) { - update.updater.invalidateType(affectedSymbol); - } else if (link.kind === 8 /* Aliases */) { - update.updater.invalidateType(affectedSymbol); - } else if (link.kind === 9 /* ExportAliases */) { - update.updater.invalidateType(affectedSymbol); - } - } - TypeScript.propagateChangedTypeToIncomingLinks = propagateChangedTypeToIncomingLinks; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var SemanticDiagnostic = (function (_super) { - __extends(SemanticDiagnostic, _super); - function SemanticDiagnostic() { - _super.apply(this, arguments); - } - SemanticDiagnostic.equals = function (diagnostic1, diagnostic2) { - return TypeScript.Diagnostic.equals(diagnostic1, diagnostic2); - }; - return SemanticDiagnostic; - })(TypeScript.Diagnostic); - TypeScript.SemanticDiagnostic = SemanticDiagnostic; - - function getDiagnosticsFromEnclosingDecl(enclosingDecl, errors) { - var declErrors = enclosingDecl.getDiagnostics(); - - if (declErrors) { - for (var i = 0; i < declErrors.length; i++) { - errors[errors.length] = declErrors[i]; - } - } - - var childDecls = enclosingDecl.getChildDecls(); - - for (var i = 0; i < childDecls.length; i++) { - getDiagnosticsFromEnclosingDecl(childDecls[i], errors); - } - } - TypeScript.getDiagnosticsFromEnclosingDecl = getDiagnosticsFromEnclosingDecl; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (PullHelpers) { - function getSignatureForFuncDecl(funcDecl, semanticInfo) { - var functionDecl = semanticInfo.getDeclForAST(funcDecl); - var funcSymbol = functionDecl.getSymbol(); - - if (!funcSymbol) { - funcSymbol = functionDecl.getSignatureSymbol(); - } - - var functionSignature = null; - var typeSymbolWithAllSignatures = null; - if (funcSymbol.isSignature()) { - functionSignature = funcSymbol; - var parent = functionDecl.getParentDecl(); - typeSymbolWithAllSignatures = parent.getSymbol().getType(); - } else { - functionSignature = functionDecl.getSignatureSymbol(); - typeSymbolWithAllSignatures = funcSymbol.getType(); - } - var signatures; - if (funcDecl.isConstructor || funcDecl.isConstructMember()) { - signatures = typeSymbolWithAllSignatures.getConstructSignatures(); - } else if (funcDecl.isIndexerMember()) { - signatures = typeSymbolWithAllSignatures.getIndexSignatures(); - } else { - signatures = typeSymbolWithAllSignatures.getCallSignatures(); - } - return { - signature: functionSignature, - allSignatures: signatures - }; - } - PullHelpers.getSignatureForFuncDecl = getSignatureForFuncDecl; - - function getAccessorSymbol(getterOrSetter, semanticInfoChain, unitPath) { - var functionDecl = semanticInfoChain.getDeclForAST(getterOrSetter, unitPath); - var getterOrSetterSymbol = functionDecl.getSymbol(); - - return getterOrSetterSymbol; - } - PullHelpers.getAccessorSymbol = getAccessorSymbol; - - function getGetterAndSetterFunction(funcDecl, semanticInfoChain, unitPath) { - var accessorSymbol = PullHelpers.getAccessorSymbol(funcDecl, semanticInfoChain, unitPath); - var result = { - getter: null, - setter: null - }; - var getter = accessorSymbol.getGetter(); - if (getter) { - var getterDecl = getter.getDeclarations()[0]; - result.getter = semanticInfoChain.getASTForDecl(getterDecl); - } - var setter = accessorSymbol.getSetter(); - if (setter) { - var setterDecl = setter.getDeclarations()[0]; - result.setter = semanticInfoChain.getASTForDecl(setterDecl); - } - - return result; - } - PullHelpers.getGetterAndSetterFunction = getGetterAndSetterFunction; - - function symbolIsEnum(source) { - return source && ((source.getKind() & (64 /* Enum */ | 67108864 /* EnumMember */)) || source.hasFlag(131072 /* InitializedEnum */)); - } - PullHelpers.symbolIsEnum = symbolIsEnum; - })(TypeScript.PullHelpers || (TypeScript.PullHelpers = {})); - var PullHelpers = TypeScript.PullHelpers; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var incrementalAst = true; - var SyntaxPositionMap = (function () { - function SyntaxPositionMap(node) { - this.position = 0; - this.elementToPosition = TypeScript.Collections.createHashTable(2048, TypeScript.Collections.identityHashCode); - this.process(node); - } - SyntaxPositionMap.prototype.process = function (element) { - if (element !== null) { - if (element.isToken()) { - this.elementToPosition.add(element, this.position); - this.position += element.fullWidth(); - } else { - if (element.isNode() || (element.isList() && (element).childCount() > 0) || (element.isSeparatedList() && (element).childCount() > 0)) { - this.elementToPosition.add(element, this.position); - } - - for (var i = 0, n = element.childCount(); i < n; i++) { - this.process(element.childAt(i)); - } - } - } - }; - - SyntaxPositionMap.create = function (node) { - var map = new SyntaxPositionMap(node); - return map; - }; - - SyntaxPositionMap.prototype.fullStart = function (element) { - return this.elementToPosition.get(element); - }; - - SyntaxPositionMap.prototype.start = function (element) { - return this.fullStart(element) + element.leadingTriviaWidth(); - }; - - SyntaxPositionMap.prototype.end = function (element) { - return this.start(element) + element.width(); - }; - - SyntaxPositionMap.prototype.fullEnd = function (element) { - return this.fullStart(element) + element.fullWidth(); - }; - return SyntaxPositionMap; - })(); - TypeScript.SyntaxPositionMap = SyntaxPositionMap; - - var SyntaxTreeToAstVisitor = (function () { - function SyntaxTreeToAstVisitor(syntaxPositionMap, fileName, lineMap, compilationSettings) { - this.syntaxPositionMap = syntaxPositionMap; - this.fileName = fileName; - this.lineMap = lineMap; - this.compilationSettings = compilationSettings; - this.position = 0; - this.requiresExtendsBlock = false; - this.previousTokenTrailingComments = null; - this.isParsingAmbientModule = false; - this.containingModuleHasExportAssignment = false; - this.isParsingDeclareFile = TypeScript.isDTSFile(fileName); - } - SyntaxTreeToAstVisitor.visit = function (syntaxTree, fileName, compilationSettings) { - var map = SyntaxTreeToAstVisitor.checkPositions ? SyntaxPositionMap.create(syntaxTree.sourceUnit()) : null; - var visitor = new SyntaxTreeToAstVisitor(map, fileName, syntaxTree.lineMap(), compilationSettings); - return syntaxTree.sourceUnit().accept(visitor); - }; - - SyntaxTreeToAstVisitor.prototype.assertElementAtPosition = function (element) { - if (SyntaxTreeToAstVisitor.checkPositions) { - TypeScript.Debug.assert(this.position === this.syntaxPositionMap.fullStart(element)); - } - }; - - SyntaxTreeToAstVisitor.prototype.movePast = function (element) { - if (element !== null) { - this.assertElementAtPosition(element); - this.position += element.fullWidth(); - } - }; - - SyntaxTreeToAstVisitor.prototype.moveTo = function (element1, element2) { - if (element2 !== null) { - this.position += TypeScript.Syntax.childOffset(element1, element2); - } - }; - - SyntaxTreeToAstVisitor.prototype.applyDelta = function (ast, delta) { - var _this = this; - if (delta === 0) { - return; - } - - var applyDelta = function (ast) { - if (ast.minChar !== -1) { - ast.minChar += delta; - } - if (ast.limChar !== -1) { - ast.limChar += delta; - } - }; - - var applyDeltaToComments = function (comments) { - if (comments && comments.length > 0) { - for (var i = 0; i < comments.length; i++) { - var comment = comments[i]; - applyDelta(comment); - comment.minLine = _this.lineMap.getLineNumberFromPosition(comment.minChar); - comment.limLine = _this.lineMap.getLineNumberFromPosition(comment.limChar); - } - } - }; - - var pre = function (cur, parent, walker) { - applyDelta(cur); - applyDeltaToComments(cur.preComments); - applyDeltaToComments(cur.postComments); - - return cur; - }; - - TypeScript.getAstWalkerFactory().walk(ast, pre); - }; - - SyntaxTreeToAstVisitor.prototype.setSpan = function (span, fullStart, element) { - var desiredMinChar = fullStart + element.leadingTriviaWidth(); - var desiredLimChar = desiredMinChar + element.width(); - - this.setSpanExplicit(span, desiredMinChar, desiredLimChar); - - span.trailingTriviaWidth = element.trailingTriviaWidth(); - }; - - SyntaxTreeToAstVisitor.prototype.setSpanExplicit = function (span, start, end) { - if (span.minChar !== -1) { - TypeScript.Debug.assert(span.limChar !== -1); - TypeScript.Debug.assert((span).nodeType !== undefined); - - var delta = start - span.minChar; - this.applyDelta(span, delta); - - span.limChar = end; - - TypeScript.Debug.assert(span.minChar === start); - TypeScript.Debug.assert(span.limChar === end); - } else { - TypeScript.Debug.assert(span.limChar === -1); - - span.minChar = start; - span.limChar = end; - } - - TypeScript.Debug.assert(!isNaN(span.minChar)); - TypeScript.Debug.assert(!isNaN(span.limChar)); - TypeScript.Debug.assert(span.minChar !== -1); - TypeScript.Debug.assert(span.limChar !== -1); - }; - - SyntaxTreeToAstVisitor.prototype.identifierFromToken = function (token, isOptional, useValueText) { - this.assertElementAtPosition(token); - - var result = null; - if (token.fullWidth() === 0) { - result = new TypeScript.MissingIdentifier(); - } else { - result = new TypeScript.Identifier(token.text()); - result.text = useValueText ? token.valueText() : result.text; - if (result.text == SyntaxTreeToAstVisitor.protoString) { - result.text = SyntaxTreeToAstVisitor.protoSubstitutionString; - } - } - - if (isOptional) { - result.setFlags(result.getFlags() | 4 /* OptionalName */); - } - - var start = this.position + token.leadingTriviaWidth(); - this.setSpanExplicit(result, start, start + token.width()); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.getAST = function (element) { - if (this.previousTokenTrailingComments !== null) { - return null; - } - - if (incrementalAst) { - var result = (element)._ast; - return result ? result : null; - } else { - return null; - } - }; - - SyntaxTreeToAstVisitor.prototype.setAST = function (element, ast) { - if (incrementalAst) { - (element)._ast = ast; - } - }; - - SyntaxTreeToAstVisitor.prototype.visitSyntaxList = function (list) { - var start = this.position; - var result = this.getAST(list); - if (result) { - this.movePast(list); - } else { - result = new TypeScript.ASTList(); - - for (var i = 0, n = list.childCount(); i < n; i++) { - result.append(list.childAt(i).accept(this)); - } - - if (n > 0) { - this.setAST(list, result); - } - } - - this.setSpan(result, start, list); - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitSeparatedSyntaxList = function (list) { - var start = this.position; - var result = this.getAST(list); - if (result) { - this.movePast(list); - } else { - result = new TypeScript.ASTList(); - - for (var i = 0, n = list.childCount(); i < n; i++) { - if (i % 2 === 0) { - result.append(list.childAt(i).accept(this)); - this.previousTokenTrailingComments = null; - } else { - var separatorToken = list.childAt(i); - this.previousTokenTrailingComments = this.convertTokenTrailingComments(separatorToken, this.position + separatorToken.leadingTriviaWidth() + separatorToken.width()); - this.movePast(separatorToken); - } - } - - result.postComments = this.previousTokenTrailingComments; - this.previousTokenTrailingComments = null; - - if (n > 0) { - this.setAST(list, result); - } - } - - this.setSpan(result, start, list); - return result; - }; - - SyntaxTreeToAstVisitor.prototype.createRef = function (text, minChar) { - var id = new TypeScript.Identifier(text); - id.minChar = minChar; - return id; - }; - - SyntaxTreeToAstVisitor.prototype.convertComment = function (trivia, commentStartPosition, hasTrailingNewLine) { - var comment = new TypeScript.Comment(trivia.fullText(), trivia.kind() === 6 /* MultiLineCommentTrivia */, hasTrailingNewLine); - - comment.minChar = commentStartPosition; - comment.limChar = commentStartPosition + trivia.fullWidth(); - comment.minLine = this.lineMap.getLineNumberFromPosition(comment.minChar); - comment.limLine = this.lineMap.getLineNumberFromPosition(comment.limChar); - - return comment; - }; - - SyntaxTreeToAstVisitor.prototype.convertComments = function (triviaList, commentStartPosition) { - var result = []; - - for (var i = 0, n = triviaList.count(); i < n; i++) { - var trivia = triviaList.syntaxTriviaAt(i); - - if (trivia.isComment()) { - var hasTrailingNewLine = ((i + 1) < n) && triviaList.syntaxTriviaAt(i + 1).isNewLine(); - result.push(this.convertComment(trivia, commentStartPosition, hasTrailingNewLine)); - } - - commentStartPosition += trivia.fullWidth(); - } - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.mergeComments = function (comments1, comments2) { - if (comments1 === null) { - return comments2; - } - - if (comments2 === null) { - return comments1; - } - - return comments1.concat(comments2); - }; - - SyntaxTreeToAstVisitor.prototype.convertTokenLeadingComments = function (token, commentStartPosition) { - if (token === null) { - return null; - } - - var preComments = token.hasLeadingComment() ? this.convertComments(token.leadingTrivia(), commentStartPosition) : null; - - var previousTokenTrailingComments = this.previousTokenTrailingComments; - this.previousTokenTrailingComments = null; - - return this.mergeComments(previousTokenTrailingComments, preComments); - }; - - SyntaxTreeToAstVisitor.prototype.convertTokenTrailingComments = function (token, commentStartPosition) { - if (token === null || !token.hasTrailingComment() || token.hasTrailingNewLine()) { - return null; - } - - return this.convertComments(token.trailingTrivia(), commentStartPosition); - }; - - SyntaxTreeToAstVisitor.prototype.convertNodeLeadingComments = function (node, nodeStart) { - return this.convertTokenLeadingComments(node.firstToken(), nodeStart); - }; - - SyntaxTreeToAstVisitor.prototype.convertNodeTrailingComments = function (node, nodeStart) { - return this.convertTokenTrailingComments(node.lastToken(), nodeStart + node.leadingTriviaWidth() + node.width()); - }; - - SyntaxTreeToAstVisitor.prototype.visitToken = function (token) { - this.assertElementAtPosition(token); - - var result = this.getAST(token); - var fullStart = this.position; - - if (result) { - this.movePast(token); - } else { - if (token.kind() === 35 /* ThisKeyword */) { - result = new TypeScript.ThisExpression(); - } else if (token.kind() === 50 /* SuperKeyword */) { - result = new TypeScript.SuperExpression(); - } else if (token.kind() === 37 /* TrueKeyword */) { - result = new TypeScript.LiteralExpression(3 /* TrueLiteral */); - } else if (token.kind() === 24 /* FalseKeyword */) { - result = new TypeScript.LiteralExpression(4 /* FalseLiteral */); - } else if (token.kind() === 32 /* NullKeyword */) { - result = new TypeScript.LiteralExpression(8 /* NullLiteral */); - } else if (token.kind() === 14 /* StringLiteral */) { - result = new TypeScript.StringLiteral(token.text(), token.valueText()); - } else if (token.kind() === 12 /* RegularExpressionLiteral */) { - result = new TypeScript.RegexLiteral(token.text()); - } else if (token.kind() === 13 /* NumericLiteral */) { - var preComments = this.convertTokenLeadingComments(token, fullStart); - - var value = token.text().indexOf(".") > 0 ? parseFloat(token.text()) : parseInt(token.text()); - result = new TypeScript.NumberLiteral(value, token.text()); - - result.preComments = preComments; - } else { - result = this.identifierFromToken(token, false, true); - } - - this.movePast(token); - } - - var start = fullStart + token.leadingTriviaWidth(); - this.setAST(token, result); - this.setSpanExplicit(result, start, start + token.width()); - return result; - }; - - SyntaxTreeToAstVisitor.prototype.getLeadingComments = function (node) { - var firstToken = node.firstToken(); - var result = []; - - if (firstToken.hasLeadingComment()) { - var leadingTrivia = firstToken.leadingTrivia(); - - for (var i = 0, n = leadingTrivia.count(); i < n; i++) { - var trivia = leadingTrivia.syntaxTriviaAt(i); - - if (trivia.isComment()) { - result.push(trivia); - } - } - } - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.hasTopLevelImportOrExport = function (node) { - var firstToken; - - for (var i = 0, n = node.moduleElements.childCount(); i < n; i++) { - var moduleElement = node.moduleElements.childAt(i); - - firstToken = moduleElement.firstToken(); - if (firstToken !== null && firstToken.kind() === 47 /* ExportKeyword */) { - return true; - } - - if (moduleElement.kind() === 133 /* ImportDeclaration */) { - var importDecl = moduleElement; - if (importDecl.moduleReference.kind() === 245 /* ExternalModuleReference */) { - return true; - } - } - } - - var leadingComments = this.getLeadingComments(node); - for (var i = 0, n = leadingComments.length; i < n; i++) { - var trivia = leadingComments[i]; - - if (TypeScript.getImplicitImport(trivia.fullText())) { - return true; - } - } - - return false; - }; - - SyntaxTreeToAstVisitor.prototype.getAmdDependency = function (comment) { - var amdDependencyRegEx = /^\/\/\/\s* 0; - - if (!this.containingModuleHasExportAssignment && (TypeScript.SyntaxUtilities.containsToken(node.modifiers, 47 /* ExportKeyword */) || this.isParsingAmbientModule)) { - result.setVarFlags(result.getVarFlags() | 1 /* Exported */); - } else { - result.setVarFlags(result.getVarFlags() & ~1 /* Exported */); - } - - if (TypeScript.SyntaxUtilities.containsToken(node.modifiers, 64 /* DeclareKeyword */) || this.isParsingAmbientModule || this.isParsingDeclareFile) { - result.setVarFlags(result.getVarFlags() | 8 /* Ambient */); - } else { - result.setVarFlags(result.getVarFlags() & ~8 /* Ambient */); - } - - this.setAST(node, result); - this.setSpan(result, start, node); - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitInterfaceDeclaration = function (node) { - this.assertElementAtPosition(node); - - var start = this.position; - var result = this.getAST(node); - if (result) { - this.movePast(node); - } else { - var preComments = this.convertNodeLeadingComments(node, start); - var postComments = this.convertNodeTrailingComments(node, start); - this.moveTo(node, node.identifier); - var name = this.identifierFromToken(node.identifier, false, true); - this.movePast(node.identifier); - var typeParameters = node.typeParameterList === null ? null : node.typeParameterList.accept(this); - - var extendsList = null; - - for (var i = 0, n = node.heritageClauses.childCount(); i < n; i++) { - var heritageClause = node.heritageClauses.childAt(i); - if (i === 0) { - extendsList = heritageClause.accept(this); - } else { - this.movePast(heritageClause); - } - } - - this.movePast(node.body.openBraceToken); - var members = this.visitSeparatedSyntaxList(node.body.typeMembers); - - this.movePast(node.body.closeBraceToken); - - result = new TypeScript.InterfaceDeclaration(name, typeParameters, members, extendsList, null); - - result.preComments = preComments; - result.postComments = postComments; - } - - if (!this.containingModuleHasExportAssignment && (TypeScript.SyntaxUtilities.containsToken(node.modifiers, 47 /* ExportKeyword */) || this.isParsingAmbientModule)) { - result.setVarFlags(result.getVarFlags() | 1 /* Exported */); - } else { - result.setVarFlags(result.getVarFlags() & ~1 /* Exported */); - } - - this.setAST(node, result); - this.setSpan(result, start, node); - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitHeritageClause = function (node) { - this.assertElementAtPosition(node); - - var start = this.position; - var result = this.getAST(node); - if (result) { - this.movePast(node); - } else { - result = new TypeScript.ASTList(); - - this.movePast(node.extendsOrImplementsKeyword); - for (var i = 0, n = node.typeNames.childCount(); i < n; i++) { - if (i % 2 === 1) { - this.movePast(node.typeNames.childAt(i)); - } else { - var type = this.visitType(node.typeNames.childAt(i)).term; - result.append(type); - } - } - } - - this.setAST(node, result); - this.setSpan(result, start, node); - return result; - }; - - SyntaxTreeToAstVisitor.prototype.getModuleNames = function (node) { - var result = []; - - if (node.stringLiteral !== null) { - result.push(this.identifierFromToken(node.stringLiteral, false, false)); - this.movePast(node.stringLiteral); - } else { - this.getModuleNamesHelper(node.moduleName, result); - } - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.getModuleNamesHelper = function (name, result) { - this.assertElementAtPosition(name); - - if (name.kind() === 122 /* QualifiedName */) { - var qualifiedName = name; - this.getModuleNamesHelper(qualifiedName.left, result); - this.movePast(qualifiedName.dotToken); - result.push(this.identifierFromToken(qualifiedName.right, false, false)); - this.movePast(qualifiedName.right); - } else { - result.push(this.identifierFromToken(name, false, false)); - this.movePast(name); - } - }; - - SyntaxTreeToAstVisitor.prototype.visitModuleDeclaration = function (node) { - this.assertElementAtPosition(node); - - var start = this.position; - var result = this.getAST(node); - if (result) { - this.movePast(node); - } else { - var preComments = this.convertNodeLeadingComments(node, start); - var postComments = this.convertNodeTrailingComments(node, start); - - this.moveTo(node, node.moduleKeyword); - this.movePast(node.moduleKeyword); - var names = this.getModuleNames(node); - this.movePast(node.openBraceToken); - - var savedIsParsingAmbientModule = this.isParsingAmbientModule; - if (TypeScript.SyntaxUtilities.containsToken(node.modifiers, 64 /* DeclareKeyword */) || this.isParsingDeclareFile) { - this.isParsingAmbientModule = true; - } - - var savedContainingModuleHasExportAssignment = this.containingModuleHasExportAssignment; - this.containingModuleHasExportAssignment = TypeScript.ArrayUtilities.any(node.moduleElements.toArray(), function (m) { - return m.kind() === 134 /* ExportAssignment */; - }); - - var members = this.visitSyntaxList(node.moduleElements); - - this.isParsingAmbientModule = savedIsParsingAmbientModule; - this.containingModuleHasExportAssignment = savedContainingModuleHasExportAssignment; - - var closeBracePosition = this.position; - this.movePast(node.closeBraceToken); - var closeBraceSpan = new TypeScript.ASTSpan(); - this.setSpan(closeBraceSpan, closeBracePosition, node.closeBraceToken); - - for (var i = names.length - 1; i >= 0; i--) { - var innerName = names[i]; - - result = new TypeScript.ModuleDeclaration(innerName, members, closeBraceSpan); - this.setSpan(result, start, node); - - result.preComments = preComments; - result.postComments = postComments; - - preComments = null; - postComments = null; - - if (i) { - result.setModuleFlags(result.getModuleFlags() | 1 /* Exported */); - } else if (!this.containingModuleHasExportAssignment && (TypeScript.SyntaxUtilities.containsToken(node.modifiers, 47 /* ExportKeyword */) || this.isParsingAmbientModule)) { - result.setModuleFlags(result.getModuleFlags() | 1 /* Exported */); - } - - members = new TypeScript.ASTList(); - members.append(result); - } - } - - if (TypeScript.SyntaxUtilities.containsToken(node.modifiers, 64 /* DeclareKeyword */) || this.isParsingAmbientModule || this.isParsingDeclareFile) { - result.setModuleFlags(result.getModuleFlags() | 8 /* Ambient */); - } else { - result.setModuleFlags(result.getModuleFlags() & ~8 /* Ambient */); - } - - this.setAST(node, result); - this.setSpan(result, start, node); - return result; - }; - - SyntaxTreeToAstVisitor.prototype.hasDotDotDotParameter = function (parameters) { - for (var i = 0, n = parameters.nonSeparatorCount(); i < n; i++) { - if ((parameters.nonSeparatorAt(i)).dotDotDotToken) { - return true; - } - } - - return false; - }; - - SyntaxTreeToAstVisitor.prototype.visitFunctionDeclaration = function (node) { - this.assertElementAtPosition(node); - - var start = this.position; - var result = this.getAST(node); - if (result) { - this.movePast(node); - } else { - var preComments = this.convertNodeLeadingComments(node, start); - var postComments = this.convertNodeTrailingComments(node, start); - - this.moveTo(node, node.identifier); - var name = this.identifierFromToken(node.identifier, false, true); - - this.movePast(node.identifier); - - var typeParameters = node.callSignature.typeParameterList === null ? null : node.callSignature.typeParameterList.accept(this); - var parameters = node.callSignature.parameterList.accept(this); - - var returnType = node.callSignature.typeAnnotation ? node.callSignature.typeAnnotation.accept(this) : null; - - var block = node.block ? node.block.accept(this) : null; - - this.movePast(node.semicolonToken); - - result = new TypeScript.FunctionDeclaration(name, block, false, typeParameters, parameters, 12 /* FunctionDeclaration */); - - result.preComments = preComments; - result.postComments = postComments; - result.variableArgList = this.hasDotDotDotParameter(node.callSignature.parameterList.parameters); - result.returnTypeAnnotation = returnType; - - if (node.semicolonToken) { - result.setFunctionFlags(result.getFunctionFlags() | 128 /* Signature */); - } - } - - if (!this.containingModuleHasExportAssignment && (TypeScript.SyntaxUtilities.containsToken(node.modifiers, 47 /* ExportKeyword */) || this.isParsingAmbientModule)) { - result.setFunctionFlags(result.getFunctionFlags() | 1 /* Exported */); - } else { - result.setFunctionFlags(result.getFunctionFlags() & ~1 /* Exported */); - } - - if (TypeScript.SyntaxUtilities.containsToken(node.modifiers, 64 /* DeclareKeyword */) || this.isParsingAmbientModule || this.isParsingDeclareFile) { - result.setFunctionFlags(result.getFunctionFlags() | 8 /* Ambient */); - } else { - result.setFunctionFlags(result.getFunctionFlags() & ~8 /* Ambient */); - } - - this.setAST(node, result); - this.setSpan(result, start, node); - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitEnumDeclaration = function (node) { - this.assertElementAtPosition(node); - - var start = this.position; - - var preComments = this.convertNodeLeadingComments(node, start); - var postComments = this.convertNodeTrailingComments(node, start); - - this.moveTo(node, node.identifier); - var name = this.identifierFromToken(node.identifier, false, true); - this.movePast(node.identifier); - - this.movePast(node.openBraceToken); - var members = new TypeScript.ASTList(); - - var lastValue = null; - var memberNames = []; - var memberName; - - for (var i = 0, n = node.enumElements.childCount(); i < n; i++) { - if (i % 2 === 1) { - this.movePast(node.enumElements.childAt(i)); - } else { - var enumElement = node.enumElements.childAt(i); - - var memberValue = null; - - memberName = this.identifierFromToken(enumElement.propertyName, false, true); - this.movePast(enumElement.propertyName); - - if (enumElement.equalsValueClause !== null) { - memberValue = enumElement.equalsValueClause.accept(this); - lastValue = null; - } - - var memberStart = this.position; - - if (memberValue === null) { - if (lastValue === null) { - memberValue = new TypeScript.NumberLiteral(0, "0"); - lastValue = memberValue; - } else { - var nextValue = lastValue.value + 1; - memberValue = new TypeScript.NumberLiteral(nextValue, nextValue.toString()); - lastValue = memberValue; - } - } - - var declarator = new TypeScript.VariableDeclarator(memberName); - declarator.init = memberValue; - declarator.isImplicitlyInitialized = enumElement.equalsValueClause === null; - - declarator.typeExpr = new TypeScript.TypeReference(this.createRef(name.actualText, -1), 0); - declarator.setVarFlags(declarator.getVarFlags() | 256 /* Property */); - this.setSpanExplicit(declarator, memberStart, this.position); - - if (memberValue.nodeType === 7 /* NumericLiteral */) { - declarator.setVarFlags(declarator.getVarFlags() | 4096 /* Constant */); - } else if (memberValue.nodeType === 69 /* LeftShiftExpression */) { - var binop = memberValue; - if (binop.operand1.nodeType === 7 /* NumericLiteral */ && binop.operand2.nodeType === 7 /* NumericLiteral */) { - declarator.setVarFlags(declarator.getVarFlags() | 4096 /* Constant */); - } - } else if (memberValue.nodeType === 20 /* Name */) { - var nameNode = memberValue; - for (var j = 0; j < memberNames.length; j++) { - memberName = memberNames[j]; - if (memberName.text === nameNode.text) { - declarator.setVarFlags(declarator.getVarFlags() | 4096 /* Constant */); - break; - } - } - } - - var declarators = new TypeScript.ASTList(); - declarators.append(declarator); - var declaration = new TypeScript.VariableDeclaration(declarators); - this.setSpanExplicit(declaration, memberStart, this.position); - - var statement = new TypeScript.VariableStatement(declaration); - statement.setFlags(16 /* EnumElement */); - this.setSpanExplicit(statement, memberStart, this.position); - - members.append(statement); - memberNames.push(memberName); - - declarator.setVarFlags(declarator.getVarFlags() | 1 /* Exported */); - } - } - - var closeBracePosition = this.position; - this.movePast(node.closeBraceToken); - var closeBraceSpan = new TypeScript.ASTSpan(); - this.setSpan(closeBraceSpan, closeBracePosition, node.closeBraceToken); - - var modDecl = new TypeScript.ModuleDeclaration(name, members, closeBraceSpan); - this.setSpan(modDecl, start, node); - - modDecl.preComments = preComments; - modDecl.postComments = postComments; - modDecl.setModuleFlags(modDecl.getModuleFlags() | 128 /* IsEnum */); - - if (!this.containingModuleHasExportAssignment && (TypeScript.SyntaxUtilities.containsToken(node.modifiers, 47 /* ExportKeyword */) || this.isParsingAmbientModule)) { - modDecl.setModuleFlags(modDecl.getModuleFlags() | 1 /* Exported */); - } - - return modDecl; - }; - - SyntaxTreeToAstVisitor.prototype.visitEnumElement = function (node) { - throw TypeScript.Errors.invalidOperation(); - }; - - SyntaxTreeToAstVisitor.prototype.visitImportDeclaration = function (node) { - this.assertElementAtPosition(node); - - var start = this.position; - var result = this.getAST(node); - if (result) { - this.movePast(node); - } else { - var preComments = this.convertNodeLeadingComments(node, start); - var postComments = this.convertNodeTrailingComments(node, start); - - this.moveTo(node, node.identifier); - var name = this.identifierFromToken(node.identifier, false, true); - this.movePast(node.identifier); - this.movePast(node.equalsToken); - var alias = node.moduleReference.accept(this); - this.movePast(node.semicolonToken); - - result = new TypeScript.ImportDeclaration(name, alias); - - result.preComments = preComments; - result.postComments = postComments; - result.isDynamicImport = node.moduleReference.kind() === 245 /* ExternalModuleReference */; - } - - this.setAST(node, result); - this.setSpan(result, start, node); - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitExportAssignment = function (node) { - this.assertElementAtPosition(node); - - var start = this.position; - var result = this.getAST(node); - if (result) { - this.movePast(node); - } else { - this.moveTo(node, node.identifier); - var name = this.identifierFromToken(node.identifier, false, true); - this.movePast(node.identifier); - this.movePast(node.semicolonToken); - - result = new TypeScript.ExportAssignment(name); - } - - this.setAST(node, result); - this.setSpan(result, start, node); - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitVariableStatement = function (node) { - this.assertElementAtPosition(node); - - var start = this.position; - - var preComments = null; - if (node.modifiers.childCount() > 0) { - preComments = this.convertTokenLeadingComments(node.modifiers.firstToken(), start); - } - - this.moveTo(node, node.variableDeclaration); - - var declaration = node.variableDeclaration.accept(this); - this.movePast(node.semicolonToken); - - for (var i = 0, n = declaration.declarators.members.length; i < n; i++) { - var varDecl = declaration.declarators.members[i]; - - if (i === 0) { - varDecl.preComments = this.mergeComments(preComments, varDecl.preComments); - } - - if (!this.containingModuleHasExportAssignment && (TypeScript.SyntaxUtilities.containsToken(node.modifiers, 47 /* ExportKeyword */) || this.isParsingAmbientModule)) { - varDecl.setVarFlags(varDecl.getVarFlags() | 1 /* Exported */); - } else { - varDecl.setVarFlags(varDecl.getVarFlags() & ~1 /* Exported */); - } - - if (TypeScript.SyntaxUtilities.containsToken(node.modifiers, 64 /* DeclareKeyword */) || this.isParsingAmbientModule || this.isParsingDeclareFile) { - varDecl.setVarFlags(varDecl.getVarFlags() | 8 /* Ambient */); - } else { - varDecl.setVarFlags(varDecl.getVarFlags() & ~8 /* Ambient */); - } - } - - var result = new TypeScript.VariableStatement(declaration); - - this.setSpan(result, start, node); - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitVariableDeclaration = function (node) { - this.assertElementAtPosition(node); - - var start = this.position; - - var preComments = this.convertNodeLeadingComments(node, start); - var postComments = this.convertNodeTrailingComments(node, start); - - this.moveTo(node, node.variableDeclarators); - var variableDecls = this.visitSeparatedSyntaxList(node.variableDeclarators); - - for (var i = 0; i < variableDecls.members.length; i++) { - if (i === 0) { - variableDecls.members[i].preComments = preComments; - variableDecls.members[i].postComments = postComments; - } - } - - var result = new TypeScript.VariableDeclaration(variableDecls); - this.setSpan(result, start, node); - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitVariableDeclarator = function (node) { - this.assertElementAtPosition(node); - - var start = this.position; - var name = this.identifierFromToken(node.identifier, false, true); - this.movePast(node.identifier); - var typeExpr = node.typeAnnotation ? node.typeAnnotation.accept(this) : null; - var init = node.equalsValueClause ? node.equalsValueClause.accept(this) : null; - - var result = new TypeScript.VariableDeclarator(name); - this.setSpan(result, start, node); - - result.typeExpr = typeExpr; - result.init = init; - if (init && init.nodeType === 12 /* FunctionDeclaration */) { - var funcDecl = init; - funcDecl.hint = name.actualText; - } - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitEqualsValueClause = function (node) { - this.assertElementAtPosition(node); - - this.previousTokenTrailingComments = this.convertTokenTrailingComments(node.equalsToken, this.position + node.equalsToken.leadingTriviaWidth() + node.equalsToken.width()); - - this.movePast(node.equalsToken); - var result = node.value.accept(this); - - this.previousTokenTrailingComments = null; - return result; - }; - - SyntaxTreeToAstVisitor.prototype.getUnaryExpressionNodeType = function (kind) { - switch (kind) { - case 163 /* PlusExpression */: - return 26 /* PlusExpression */; - case 164 /* NegateExpression */: - return 27 /* NegateExpression */; - case 165 /* BitwiseNotExpression */: - return 72 /* BitwiseNotExpression */; - case 166 /* LogicalNotExpression */: - return 73 /* LogicalNotExpression */; - case 167 /* PreIncrementExpression */: - return 74 /* PreIncrementExpression */; - case 168 /* PreDecrementExpression */: - return 75 /* PreDecrementExpression */; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - SyntaxTreeToAstVisitor.prototype.visitPrefixUnaryExpression = function (node) { - this.assertElementAtPosition(node); - - var start = this.position; - var result = this.getAST(node); - if (result) { - this.movePast(node); - } else { - this.movePast(node.operatorToken); - var operand = node.operand.accept(this); - - result = new TypeScript.UnaryExpression(this.getUnaryExpressionNodeType(node.kind()), operand); - } - - this.setAST(node, result); - this.setSpan(result, start, node); - return result; - }; - - SyntaxTreeToAstVisitor.prototype.isOnSingleLine = function (start, end) { - return this.lineMap.getLineNumberFromPosition(start) === this.lineMap.getLineNumberFromPosition(end); - }; - - SyntaxTreeToAstVisitor.prototype.visitArrayLiteralExpression = function (node) { - this.assertElementAtPosition(node); - - var start = this.position; - var result = this.getAST(node); - if (result) { - this.movePast(node); - } else { - var openStart = this.position + node.openBracketToken.leadingTriviaWidth(); - this.movePast(node.openBracketToken); - - var expressions = this.visitSeparatedSyntaxList(node.expressions); - - var closeStart = this.position + node.closeBracketToken.leadingTriviaWidth(); - this.movePast(node.closeBracketToken); - - TypeScript.Debug.assert(expressions !== null); - result = new TypeScript.UnaryExpression(21 /* ArrayLiteralExpression */, expressions); - - if (this.isOnSingleLine(openStart, closeStart)) { - result.setFlags(result.getFlags() | 2 /* SingleLine */); - } - } - - this.setAST(node, result); - this.setSpan(result, start, node); - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitOmittedExpression = function (node) { - this.assertElementAtPosition(node); - - var start = this.position; - var result = this.getAST(node); - if (result) { - this.movePast(node); - } else { - result = new TypeScript.OmittedExpression(); - } - - this.setAST(node, result); - this.setSpan(result, start, node); - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitParenthesizedExpression = function (node) { - this.assertElementAtPosition(node); - - var start = this.position; - var result = this.getAST(node); - if (result) { - this.movePast(node); - } else { - this.movePast(node.openParenToken); - var expr = node.expression.accept(this); - this.movePast(node.closeParenToken); - - result = new TypeScript.ParenthesizedExpression(expr); - } - - this.setAST(node, result); - this.setSpan(result, start, node); - return result; - }; - - SyntaxTreeToAstVisitor.prototype.getArrowFunctionStatements = function (body) { - if (body.kind() === 145 /* Block */) { - return body.accept(this); - } else { - var statements = new TypeScript.ASTList(); - var expression = body.accept(this); - var returnStatement = new TypeScript.ReturnStatement(expression); - - returnStatement.preComments = expression.preComments; - expression.preComments = null; - - statements.append(returnStatement); - var block = new TypeScript.Block(statements); - block.closeBraceSpan = statements.members[0]; - return block; - } - }; - - SyntaxTreeToAstVisitor.prototype.visitSimpleArrowFunctionExpression = function (node) { - this.assertElementAtPosition(node); - - var start = this.position; - var result = this.getAST(node); - if (result) { - this.movePast(node); - } else { - var identifier = this.identifierFromToken(node.identifier, false, true); - this.movePast(node.identifier); - this.movePast(node.equalsGreaterThanToken); - - var parameters = new TypeScript.ASTList(); - - var parameter = new TypeScript.Parameter(identifier); - this.setSpanExplicit(parameter, identifier.minChar, identifier.limChar); - - parameters.append(parameter); - - var statements = this.getArrowFunctionStatements(node.body); - - result = new TypeScript.FunctionDeclaration(null, statements, false, null, parameters, 12 /* FunctionDeclaration */); - - result.returnTypeAnnotation = null; - result.setFunctionFlags(result.getFunctionFlags() | 8192 /* IsFunctionExpression */); - result.setFunctionFlags(result.getFunctionFlags() | 2048 /* IsFatArrowFunction */); - } - - this.setAST(node, result); - this.setSpan(result, start, node); - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitParenthesizedArrowFunctionExpression = function (node) { - this.assertElementAtPosition(node); - - var start = this.position; - var result = this.getAST(node); - if (result) { - this.movePast(node); - } else { - var preComments = this.convertNodeLeadingComments(node, start); - - var typeParameters = node.callSignature.typeParameterList === null ? null : node.callSignature.typeParameterList.accept(this); - var parameters = node.callSignature.parameterList.accept(this); - var returnType = node.callSignature.typeAnnotation ? node.callSignature.typeAnnotation.accept(this) : null; - this.movePast(node.equalsGreaterThanToken); - - var block = this.getArrowFunctionStatements(node.body); - - result = new TypeScript.FunctionDeclaration(null, block, false, typeParameters, parameters, 12 /* FunctionDeclaration */); - - result.preComments = preComments; - result.returnTypeAnnotation = returnType; - result.setFunctionFlags(result.getFunctionFlags() | 8192 /* IsFunctionExpression */); - result.setFunctionFlags(result.getFunctionFlags() | 2048 /* IsFatArrowFunction */); - result.variableArgList = this.hasDotDotDotParameter(node.callSignature.parameterList.parameters); - } - - this.setAST(node, result); - this.setSpan(result, start, node); - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitType = function (type) { - this.assertElementAtPosition(type); - - var result; - if (type.isToken()) { - var start = this.position; - result = new TypeScript.TypeReference(type.accept(this), 0); - this.setSpan(result, start, type); - } else { - result = type.accept(this); - } - - TypeScript.Debug.assert(result.nodeType === 11 /* TypeRef */); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitQualifiedName = function (node) { - this.assertElementAtPosition(node); - - var start = this.position; - var result = this.getAST(node); - if (result) { - this.movePast(node); - } else { - var left = this.visitType(node.left).term; - this.movePast(node.dotToken); - var right = this.identifierFromToken(node.right, false, true); - this.movePast(node.right); - - var term = new TypeScript.BinaryExpression(32 /* MemberAccessExpression */, left, right); - this.setSpan(term, start, node); - - result = new TypeScript.TypeReference(term, 0); - } - - this.setAST(node, result); - this.setSpan(result, start, node); - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitTypeArgumentList = function (node) { - this.assertElementAtPosition(node); - - var result = new TypeScript.ASTList(); - - this.movePast(node.lessThanToken); - - var start = this.position; - - for (var i = 0, n = node.typeArguments.childCount(); i < n; i++) { - if (i % 2 === 1) { - this.movePast(node.typeArguments.childAt(i)); - } else { - result.append(this.visitType(node.typeArguments.childAt(i))); - } - } - this.movePast(node.greaterThanToken); - - this.setSpan(result, start, node.typeArguments); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitConstructorType = function (node) { - this.assertElementAtPosition(node); - - var start = this.position; - var result = this.getAST(node); - if (result) { - this.movePast(node); - } else { - this.movePast(node.newKeyword); - var typeParameters = node.typeParameterList === null ? null : node.typeParameterList.accept(this); - var parameters = node.parameterList.accept(this); - this.movePast(node.equalsGreaterThanToken); - var returnType = node.type ? this.visitType(node.type) : null; - - var funcDecl = new TypeScript.FunctionDeclaration(null, null, false, typeParameters, parameters, 12 /* FunctionDeclaration */); - this.setSpan(funcDecl, start, node); - - funcDecl.returnTypeAnnotation = returnType; - funcDecl.setFunctionFlags(funcDecl.getFunctionFlags() | 128 /* Signature */); - funcDecl.variableArgList = this.hasDotDotDotParameter(node.parameterList.parameters); - - funcDecl.setFunctionFlags(funcDecl.getFunctionFlags() | 1024 /* ConstructMember */); - funcDecl.setFlags(funcDecl.getFlags() | 8 /* TypeReference */); - funcDecl.hint = "_construct"; - funcDecl.classDecl = null; - - result = new TypeScript.TypeReference(funcDecl, 0); - } - - this.setAST(node, result); - this.setSpan(result, start, node); - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitFunctionType = function (node) { - this.assertElementAtPosition(node); - - var start = this.position; - var result = this.getAST(node); - if (result) { - this.movePast(node); - } else { - var typeParameters = node.typeParameterList === null ? null : node.typeParameterList.accept(this); - var parameters = node.parameterList.accept(this); - this.movePast(node.equalsGreaterThanToken); - var returnType = node.type ? this.visitType(node.type) : null; - - var funcDecl = new TypeScript.FunctionDeclaration(null, null, false, typeParameters, parameters, 12 /* FunctionDeclaration */); - this.setSpan(funcDecl, start, node); - - funcDecl.returnTypeAnnotation = returnType; - - funcDecl.setFlags(funcDecl.getFunctionFlags() | 128 /* Signature */); - funcDecl.setFlags(funcDecl.getFlags() | 8 /* TypeReference */); - funcDecl.variableArgList = this.hasDotDotDotParameter(node.parameterList.parameters); - - result = new TypeScript.TypeReference(funcDecl, 0); - } - - this.setAST(node, result); - this.setSpan(result, start, node); - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitObjectType = function (node) { - this.assertElementAtPosition(node); - - var start = this.position; - var result = this.getAST(node); - if (result) { - this.movePast(node); - } else { - this.movePast(node.openBraceToken); - var typeMembers = this.visitSeparatedSyntaxList(node.typeMembers); - this.movePast(node.closeBraceToken); - - var interfaceDecl = new TypeScript.InterfaceDeclaration(new TypeScript.Identifier("__anonymous"), null, typeMembers, null, null); - this.setSpan(interfaceDecl, start, node); - - interfaceDecl.setFlags(interfaceDecl.getFlags() | 8 /* TypeReference */); - - result = new TypeScript.TypeReference(interfaceDecl, 0); - } - - this.setAST(node, result); - this.setSpan(result, start, node); - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitArrayType = function (node) { - this.assertElementAtPosition(node); - - var start = this.position; - var result = this.getAST(node); - if (result) { - this.movePast(node); - } else { - var underlying = this.visitType(node.type); - this.movePast(node.openBracketToken); - this.movePast(node.closeBracketToken); - - if (underlying.nodeType === 11 /* TypeRef */) { - result = underlying; - result.arrayCount++; - } else { - result = new TypeScript.TypeReference(underlying, 1); - } - - result.setFlags(result.getFlags() | 8 /* TypeReference */); - } - - this.setAST(node, result); - this.setSpan(result, start, node); - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitGenericType = function (node) { - this.assertElementAtPosition(node); - - var start = this.position; - var result = this.getAST(node); - if (result) { - this.movePast(node); - } else { - var underlying = this.visitType(node.name).term; - var typeArguments = node.typeArgumentList.accept(this); - - var genericType = new TypeScript.GenericType(underlying, typeArguments); - this.setSpan(genericType, start, node); - - genericType.setFlags(genericType.getFlags() | 8 /* TypeReference */); - - result = new TypeScript.TypeReference(genericType, 0); - } - - this.setAST(node, result); - this.setSpan(result, start, node); - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitTypeAnnotation = function (node) { - this.assertElementAtPosition(node); - - this.movePast(node.colonToken); - return this.visitType(node.type); - }; - - SyntaxTreeToAstVisitor.prototype.visitBlock = function (node) { - this.assertElementAtPosition(node); - - var start = this.position; - var result = this.getAST(node); - if (result) { - this.movePast(node); - } else { - this.movePast(node.openBraceToken); - var statements = this.visitSyntaxList(node.statements); - var closeBracePosition = this.position; - this.movePast(node.closeBraceToken); - var closeBraceSpan = new TypeScript.ASTSpan(); - this.setSpan(closeBraceSpan, closeBracePosition, node.closeBraceToken); - - result = new TypeScript.Block(statements); - result.closeBraceSpan = closeBraceSpan; - } - - this.setAST(node, result); - this.setSpan(result, start, node); - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitParameter = function (node) { - this.assertElementAtPosition(node); - - var start = this.position; - var result = this.getAST(node); - if (result) { - this.movePast(node); - } else { - var preComments = this.convertNodeLeadingComments(node, start); - var postComments = this.convertNodeTrailingComments(node, start); - - this.moveTo(node, node.identifier); - var identifier = this.identifierFromToken(node.identifier, !!node.questionToken, true); - this.movePast(node.identifier); - this.movePast(node.questionToken); - var typeExpr = node.typeAnnotation ? node.typeAnnotation.accept(this) : null; - var init = node.equalsValueClause ? node.equalsValueClause.accept(this) : null; - - result = new TypeScript.Parameter(identifier); - - result.preComments = preComments; - result.postComments = postComments; - result.isOptional = !!node.questionToken; - result.init = init; - result.typeExpr = typeExpr; - - if (node.publicOrPrivateKeyword) { - result.setVarFlags(result.getVarFlags() | 256 /* Property */); - - if (node.publicOrPrivateKeyword.kind() === 57 /* PublicKeyword */) { - result.setVarFlags(result.getVarFlags() | 4 /* Public */); - } else { - result.setVarFlags(result.getVarFlags() | 2 /* Private */); - } - } - - if (node.equalsValueClause || node.dotDotDotToken) { - result.setFlags(result.getFlags() | 4 /* OptionalName */); - } - } - - this.setAST(node, result); - this.setSpan(result, start, node); - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitMemberAccessExpression = function (node) { - this.assertElementAtPosition(node); - - var start = this.position; - var result = this.getAST(node); - if (result) { - this.movePast(node); - } else { - var expression = node.expression.accept(this); - this.movePast(node.dotToken); - var name = this.identifierFromToken(node.name, false, true); - this.movePast(node.name); - - result = new TypeScript.BinaryExpression(32 /* MemberAccessExpression */, expression, name); - } - - this.setAST(node, result); - this.setSpan(result, start, node); - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitPostfixUnaryExpression = function (node) { - this.assertElementAtPosition(node); - - var start = this.position; - var result = this.getAST(node); - if (result) { - this.movePast(node); - } else { - var operand = node.operand.accept(this); - this.movePast(node.operatorToken); - - result = new TypeScript.UnaryExpression(node.kind() === 209 /* PostIncrementExpression */ ? 76 /* PostIncrementExpression */ : 77 /* PostDecrementExpression */, operand); - } - - this.setAST(node, result); - this.setSpan(result, start, node); - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitElementAccessExpression = function (node) { - this.assertElementAtPosition(node); - - var start = this.position; - var result = this.getAST(node); - if (result) { - this.movePast(node); - } else { - var expression = node.expression.accept(this); - this.movePast(node.openBracketToken); - var argumentExpression = node.argumentExpression.accept(this); - this.movePast(node.closeBracketToken); - - result = new TypeScript.BinaryExpression(35 /* ElementAccessExpression */, expression, argumentExpression); - } - - this.setAST(node, result); - this.setSpan(result, start, node); - return result; - }; - - SyntaxTreeToAstVisitor.prototype.convertArgumentListArguments = function (node) { - if (node === null) { - return null; - } - - var start = this.position; - - this.movePast(node.openParenToken); - - var result = this.visitSeparatedSyntaxList(node.arguments); - - if (node.arguments.fullWidth() === 0 && node.closeParenToken.fullWidth() === 0) { - var openParenTokenEnd = start + node.openParenToken.leadingTriviaWidth() + node.openParenToken.width(); - this.setSpanExplicit(result, openParenTokenEnd, openParenTokenEnd + node.openParenToken.trailingTriviaWidth()); - } - - this.movePast(node.closeParenToken); - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitInvocationExpression = function (node) { - this.assertElementAtPosition(node); - - var start = this.position; - var result = this.getAST(node); - if (result) { - this.movePast(node); - } else { - var expression = node.expression.accept(this); - var typeArguments = node.argumentList.typeArgumentList !== null ? node.argumentList.typeArgumentList.accept(this) : null; - var argumentList = this.convertArgumentListArguments(node.argumentList); - - result = new TypeScript.CallExpression(36 /* InvocationExpression */, expression, typeArguments, argumentList); - } - - this.setAST(node, result); - this.setSpan(result, start, node); - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitArgumentList = function (node) { - throw TypeScript.Errors.invalidOperation(); - }; - - SyntaxTreeToAstVisitor.prototype.getBinaryExpressionNodeType = function (node) { - switch (node.kind()) { - case 172 /* CommaExpression */: - return 25 /* CommaExpression */; - case 173 /* AssignmentExpression */: - return 38 /* AssignmentExpression */; - case 174 /* AddAssignmentExpression */: - return 39 /* AddAssignmentExpression */; - case 175 /* SubtractAssignmentExpression */: - return 40 /* SubtractAssignmentExpression */; - case 176 /* MultiplyAssignmentExpression */: - return 42 /* MultiplyAssignmentExpression */; - case 177 /* DivideAssignmentExpression */: - return 41 /* DivideAssignmentExpression */; - case 178 /* ModuloAssignmentExpression */: - return 43 /* ModuloAssignmentExpression */; - case 179 /* AndAssignmentExpression */: - return 44 /* AndAssignmentExpression */; - case 180 /* ExclusiveOrAssignmentExpression */: - return 45 /* ExclusiveOrAssignmentExpression */; - case 181 /* OrAssignmentExpression */: - return 46 /* OrAssignmentExpression */; - case 182 /* LeftShiftAssignmentExpression */: - return 47 /* LeftShiftAssignmentExpression */; - case 183 /* SignedRightShiftAssignmentExpression */: - return 48 /* SignedRightShiftAssignmentExpression */; - case 184 /* UnsignedRightShiftAssignmentExpression */: - return 49 /* UnsignedRightShiftAssignmentExpression */; - case 186 /* LogicalOrExpression */: - return 51 /* LogicalOrExpression */; - case 187 /* LogicalAndExpression */: - return 52 /* LogicalAndExpression */; - case 188 /* BitwiseOrExpression */: - return 53 /* BitwiseOrExpression */; - case 189 /* BitwiseExclusiveOrExpression */: - return 54 /* BitwiseExclusiveOrExpression */; - case 190 /* BitwiseAndExpression */: - return 55 /* BitwiseAndExpression */; - case 191 /* EqualsWithTypeConversionExpression */: - return 56 /* EqualsWithTypeConversionExpression */; - case 192 /* NotEqualsWithTypeConversionExpression */: - return 57 /* NotEqualsWithTypeConversionExpression */; - case 193 /* EqualsExpression */: - return 58 /* EqualsExpression */; - case 194 /* NotEqualsExpression */: - return 59 /* NotEqualsExpression */; - case 195 /* LessThanExpression */: - return 60 /* LessThanExpression */; - case 196 /* GreaterThanExpression */: - return 62 /* GreaterThanExpression */; - case 197 /* LessThanOrEqualExpression */: - return 61 /* LessThanOrEqualExpression */; - case 198 /* GreaterThanOrEqualExpression */: - return 63 /* GreaterThanOrEqualExpression */; - case 199 /* InstanceOfExpression */: - return 33 /* InstanceOfExpression */; - case 200 /* InExpression */: - return 31 /* InExpression */; - case 201 /* LeftShiftExpression */: - return 69 /* LeftShiftExpression */; - case 202 /* SignedRightShiftExpression */: - return 70 /* SignedRightShiftExpression */; - case 203 /* UnsignedRightShiftExpression */: - return 71 /* UnsignedRightShiftExpression */; - case 204 /* MultiplyExpression */: - return 66 /* MultiplyExpression */; - case 205 /* DivideExpression */: - return 67 /* DivideExpression */; - case 206 /* ModuloExpression */: - return 68 /* ModuloExpression */; - case 207 /* AddExpression */: - return 64 /* AddExpression */; - case 208 /* SubtractExpression */: - return 65 /* SubtractExpression */; - } - - throw TypeScript.Errors.invalidOperation(); - }; - - SyntaxTreeToAstVisitor.prototype.visitBinaryExpression = function (node) { - this.assertElementAtPosition(node); - - var start = this.position; - var result = this.getAST(node); - if (result) { - this.movePast(node); - } else { - var nodeType = this.getBinaryExpressionNodeType(node); - var left = node.left.accept(this); - this.movePast(node.operatorToken); - var right = node.right.accept(this); - - result = new TypeScript.BinaryExpression(nodeType, left, right); - - if (right.nodeType === 12 /* FunctionDeclaration */) { - var id = left.nodeType === 32 /* MemberAccessExpression */ ? (left).operand2 : left; - var idHint = id.nodeType === 20 /* Name */ ? id.actualText : null; - - var funcDecl = right; - funcDecl.hint = idHint; - } - } - - this.setAST(node, result); - this.setSpan(result, start, node); - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitConditionalExpression = function (node) { - this.assertElementAtPosition(node); - - var start = this.position; - var result = this.getAST(node); - if (result) { - this.movePast(node); - } else { - var condition = node.condition.accept(this); - this.movePast(node.questionToken); - var whenTrue = node.whenTrue.accept(this); - this.movePast(node.colonToken); - var whenFalse = node.whenFalse.accept(this); - - result = new TypeScript.ConditionalExpression(condition, whenTrue, whenFalse); - } - - this.setAST(node, result); - this.setSpan(result, start, node); - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitConstructSignature = function (node) { - this.assertElementAtPosition(node); - - var start = this.position; - var result = this.getAST(node); - if (result) { - this.movePast(node); - } else { - var preComments = this.convertNodeLeadingComments(node, start); - - this.movePast(node.newKeyword); - var typeParameters = node.callSignature.typeParameterList === null ? null : node.callSignature.typeParameterList.accept(this); - var parameters = node.callSignature.parameterList.accept(this); - var returnType = node.callSignature.typeAnnotation ? node.callSignature.typeAnnotation.accept(this) : null; - - result = new TypeScript.FunctionDeclaration(null, null, false, typeParameters, parameters, 12 /* FunctionDeclaration */); - - result.preComments = preComments; - result.returnTypeAnnotation = returnType; - - result.hint = "_construct"; - result.setFunctionFlags(result.getFunctionFlags() | 1024 /* ConstructMember */); - result.setFunctionFlags(result.getFunctionFlags() | 256 /* Method */); - result.setFunctionFlags(result.getFunctionFlags() | 128 /* Signature */); - result.variableArgList = this.hasDotDotDotParameter(node.callSignature.parameterList.parameters); - } - - this.setAST(node, result); - this.setSpan(result, start, node); - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitMethodSignature = function (node) { - this.assertElementAtPosition(node); - - var start = this.position; - var result = this.getAST(node); - if (result) { - this.movePast(node); - } else { - var preComments = this.convertNodeLeadingComments(node, start); - - var name = this.identifierFromToken(node.propertyName, !!node.questionToken, true); - this.movePast(node.propertyName); - this.movePast(node.questionToken); - - var typeParameters = node.callSignature.typeParameterList ? node.callSignature.typeParameterList.accept(this) : null; - var parameters = node.callSignature.parameterList.accept(this); - var returnType = node.callSignature.typeAnnotation ? node.callSignature.typeAnnotation.accept(this) : null; - - result = new TypeScript.FunctionDeclaration(name, null, false, typeParameters, parameters, 12 /* FunctionDeclaration */); - - result.preComments = preComments; - result.variableArgList = this.hasDotDotDotParameter(node.callSignature.parameterList.parameters); - result.returnTypeAnnotation = returnType; - result.setFunctionFlags(result.getFunctionFlags() | 256 /* Method */); - result.setFunctionFlags(result.getFunctionFlags() | 128 /* Signature */); - } - - this.setAST(node, result); - this.setSpan(result, start, node); - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitIndexSignature = function (node) { - this.assertElementAtPosition(node); - - var start = this.position; - var result = this.getAST(node); - if (result) { - this.movePast(node); - } else { - var preComments = this.convertNodeLeadingComments(node, start); - - this.movePast(node.openBracketToken); - - var parameter = node.parameter.accept(this); - - this.movePast(node.closeBracketToken); - var returnType = node.typeAnnotation ? node.typeAnnotation.accept(this) : null; - - var name = new TypeScript.Identifier("__item"); - this.setSpanExplicit(name, start, start); - - var parameters = new TypeScript.ASTList(); - parameters.append(parameter); - - result = new TypeScript.FunctionDeclaration(name, null, false, null, parameters, 12 /* FunctionDeclaration */); - - result.preComments = preComments; - result.variableArgList = false; - result.returnTypeAnnotation = returnType; - - result.setFunctionFlags(result.getFunctionFlags() | 4096 /* IndexerMember */); - result.setFunctionFlags(result.getFunctionFlags() | 256 /* Method */); - result.setFunctionFlags(result.getFunctionFlags() | 128 /* Signature */); - } - - this.setAST(node, result); - this.setSpan(result, start, node); - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitPropertySignature = function (node) { - this.assertElementAtPosition(node); - - var start = this.position; - var result = this.getAST(node); - if (result) { - this.movePast(node); - } else { - var preComments = this.convertNodeLeadingComments(node, start); - - var name = this.identifierFromToken(node.propertyName, !!node.questionToken, true); - this.movePast(node.propertyName); - this.movePast(node.questionToken); - var typeExpr = node.typeAnnotation ? node.typeAnnotation.accept(this) : null; - - result = new TypeScript.VariableDeclarator(name); - - result.preComments = preComments; - result.typeExpr = typeExpr; - result.setVarFlags(result.getVarFlags() | 256 /* Property */); - } - - this.setAST(node, result); - this.setSpan(result, start, node); - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitParameterList = function (node) { - this.assertElementAtPosition(node); - - var start = this.position; - - var openParenToken = node.openParenToken; - this.previousTokenTrailingComments = this.convertTokenTrailingComments(openParenToken, start + openParenToken.leadingTriviaWidth() + openParenToken.width()); - - this.movePast(node.openParenToken); - var result = this.visitSeparatedSyntaxList(node.parameters); - this.movePast(node.closeParenToken); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitCallSignature = function (node) { - this.assertElementAtPosition(node); - - var start = this.position; - var result = this.getAST(node); - if (result) { - this.movePast(node); - } else { - var preComments = this.convertNodeLeadingComments(node, start); - - var typeParameters = node.typeParameterList === null ? null : node.typeParameterList.accept(this); - var parameters = node.parameterList.accept(this); - var returnType = node.typeAnnotation ? node.typeAnnotation.accept(this) : null; - - result = new TypeScript.FunctionDeclaration(null, null, false, typeParameters, parameters, 12 /* FunctionDeclaration */); - - result.preComments = preComments; - result.variableArgList = this.hasDotDotDotParameter(node.parameterList.parameters); - result.returnTypeAnnotation = returnType; - - result.hint = "_call"; - result.setFunctionFlags(result.getFunctionFlags() | 512 /* CallMember */); - result.setFunctionFlags(result.getFunctionFlags() | 256 /* Method */); - result.setFunctionFlags(result.getFunctionFlags() | 128 /* Signature */); - } - - this.setAST(node, result); - this.setSpan(result, start, node); - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitTypeParameterList = function (node) { - this.assertElementAtPosition(node); - - this.movePast(node.lessThanToken); - var result = this.visitSeparatedSyntaxList(node.typeParameters); - this.movePast(node.greaterThanToken); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitTypeParameter = function (node) { - this.assertElementAtPosition(node); - - var start = this.position; - var result = this.getAST(node); - if (result) { - this.movePast(node); - } else { - var identifier = this.identifierFromToken(node.identifier, false, true); - this.movePast(node.identifier); - var constraint = node.constraint ? node.constraint.accept(this) : null; - - result = new TypeScript.TypeParameter(identifier, constraint); - } - - this.setAST(node, result); - this.setSpan(result, start, node); - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitConstraint = function (node) { - this.assertElementAtPosition(node); - - this.movePast(node.extendsKeyword); - return this.visitType(node.type); - }; - - SyntaxTreeToAstVisitor.prototype.visitIfStatement = function (node) { - this.assertElementAtPosition(node); - - var start = this.position; - var result = this.getAST(node); - if (result) { - this.movePast(node); - } else { - this.moveTo(node, node.condition); - var condition = node.condition.accept(this); - this.movePast(node.closeParenToken); - var thenBod = node.statement.accept(this); - var elseBod = node.elseClause ? node.elseClause.accept(this) : null; - - result = new TypeScript.IfStatement(condition, thenBod, elseBod); - } - - this.setAST(node, result); - this.setSpan(result, start, node); - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitElseClause = function (node) { - this.assertElementAtPosition(node); - - this.movePast(node.elseKeyword); - return node.statement.accept(this); - }; - - SyntaxTreeToAstVisitor.prototype.visitExpressionStatement = function (node) { - this.assertElementAtPosition(node); - - var start = this.position; - var result = this.getAST(node); - if (result) { - this.movePast(node); - } else { - var preComments = this.convertNodeLeadingComments(node, start); - var postComments = this.convertNodeTrailingComments(node, start); - - var expression = node.expression.accept(this); - this.movePast(node.semicolonToken); - - result = new TypeScript.ExpressionStatement(expression); - result.preComments = preComments; - result.postComments = postComments; - } - - this.setAST(node, result); - this.setSpan(result, start, node); - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitConstructorDeclaration = function (node) { - this.assertElementAtPosition(node); - - var start = this.position; - var result = this.getAST(node); - if (result) { - this.movePast(node); - } else { - var preComments = this.convertNodeLeadingComments(node, start); - var postComments = this.convertNodeTrailingComments(node, start); - - this.moveTo(node, node.parameterList); - var parameters = node.parameterList.accept(this); - - var block = node.block ? node.block.accept(this) : null; - - this.movePast(node.semicolonToken); - - result = new TypeScript.FunctionDeclaration(null, block, true, null, parameters, 12 /* FunctionDeclaration */); - - result.preComments = preComments; - result.postComments = postComments; - result.variableArgList = this.hasDotDotDotParameter(node.parameterList.parameters); - - if (node.semicolonToken) { - result.setFunctionFlags(result.getFunctionFlags() | 128 /* Signature */); - } - } - - this.setAST(node, result); - this.setSpan(result, start, node); - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitMemberFunctionDeclaration = function (node) { - this.assertElementAtPosition(node); - - var start = this.position; - var result = this.getAST(node); - if (result) { - this.movePast(node); - } else { - var preComments = this.convertNodeLeadingComments(node, start); - var postComments = this.convertNodeTrailingComments(node, start); - - this.moveTo(node, node.propertyName); - var name = this.identifierFromToken(node.propertyName, false, true); - - this.movePast(node.propertyName); - - var typeParameters = node.callSignature.typeParameterList === null ? null : node.callSignature.typeParameterList.accept(this); - var parameters = node.callSignature.parameterList.accept(this); - var returnType = node.callSignature.typeAnnotation ? node.callSignature.typeAnnotation.accept(this) : null; - - var block = node.block ? node.block.accept(this) : null; - this.movePast(node.semicolonToken); - - result = new TypeScript.FunctionDeclaration(name, block, false, typeParameters, parameters, 12 /* FunctionDeclaration */); - - result.preComments = preComments; - result.postComments = postComments; - result.variableArgList = this.hasDotDotDotParameter(node.callSignature.parameterList.parameters); - result.returnTypeAnnotation = returnType; - - if (node.semicolonToken) { - result.setFunctionFlags(result.getFunctionFlags() | 128 /* Signature */); - } - - if (TypeScript.SyntaxUtilities.containsToken(node.modifiers, 55 /* PrivateKeyword */)) { - result.setFunctionFlags(result.getFunctionFlags() | 2 /* Private */); - } else { - result.setFunctionFlags(result.getFunctionFlags() | 4 /* Public */); - } - - if (TypeScript.SyntaxUtilities.containsToken(node.modifiers, 58 /* StaticKeyword */)) { - result.setFunctionFlags(result.getFunctionFlags() | 16 /* Static */); - } - - result.setFunctionFlags(result.getFunctionFlags() | 256 /* Method */); - } - - this.setAST(node, result); - this.setSpan(result, start, node); - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitMemberAccessorDeclaration = function (node, typeAnnotation) { - this.assertElementAtPosition(node); - - var start = this.position; - var result = this.getAST(node); - if (result) { - this.movePast(node); - } else { - var preComments = this.convertNodeLeadingComments(node, start); - var postComments = this.convertNodeTrailingComments(node, start); - - this.moveTo(node, node.propertyName); - var name = this.identifierFromToken(node.propertyName, false, true); - this.movePast(node.propertyName); - var parameters = node.parameterList.accept(this); - var returnType = typeAnnotation ? typeAnnotation.accept(this) : null; - - var block = node.block ? node.block.accept(this) : null; - result = new TypeScript.FunctionDeclaration(name, block, false, null, parameters, 12 /* FunctionDeclaration */); - - result.preComments = preComments; - result.postComments = postComments; - result.variableArgList = this.hasDotDotDotParameter(node.parameterList.parameters); - result.returnTypeAnnotation = returnType; - - if (TypeScript.SyntaxUtilities.containsToken(node.modifiers, 55 /* PrivateKeyword */)) { - result.setFunctionFlags(result.getFunctionFlags() | 2 /* Private */); - } else { - result.setFunctionFlags(result.getFunctionFlags() | 4 /* Public */); - } - - if (TypeScript.SyntaxUtilities.containsToken(node.modifiers, 58 /* StaticKeyword */)) { - result.setFunctionFlags(result.getFunctionFlags() | 16 /* Static */); - } - - result.setFunctionFlags(result.getFunctionFlags() | 256 /* Method */); - } - - this.setAST(node, result); - this.setSpan(result, start, node); - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitGetMemberAccessorDeclaration = function (node) { - this.assertElementAtPosition(node); - - var result = this.visitMemberAccessorDeclaration(node, node.typeAnnotation); - - result.setFunctionFlags(result.getFunctionFlags() | 32 /* GetAccessor */); - result.hint = "get" + result.name.actualText; - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitSetMemberAccessorDeclaration = function (node) { - this.assertElementAtPosition(node); - - var result = this.visitMemberAccessorDeclaration(node, null); - - result.setFunctionFlags(result.getFunctionFlags() | 64 /* SetAccessor */); - result.hint = "set" + result.name.actualText; - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitMemberVariableDeclaration = function (node) { - this.assertElementAtPosition(node); - - var start = this.position; - var result = this.getAST(node); - if (result) { - this.movePast(node); - } else { - var preComments = this.convertNodeLeadingComments(node, start); - var postComments = this.convertNodeTrailingComments(node, start); - - this.moveTo(node, node.variableDeclarator); - this.moveTo(node.variableDeclarator, node.variableDeclarator.identifier); - - var name = this.identifierFromToken(node.variableDeclarator.identifier, false, true); - this.movePast(node.variableDeclarator.identifier); - var typeExpr = node.variableDeclarator.typeAnnotation ? node.variableDeclarator.typeAnnotation.accept(this) : null; - var init = node.variableDeclarator.equalsValueClause ? node.variableDeclarator.equalsValueClause.accept(this) : null; - this.movePast(node.semicolonToken); - - result = new TypeScript.VariableDeclarator(name); - - result.preComments = preComments; - result.postComments = postComments; - result.typeExpr = typeExpr; - result.init = init; - - if (TypeScript.SyntaxUtilities.containsToken(node.modifiers, 58 /* StaticKeyword */)) { - result.setVarFlags(result.getVarFlags() | 16 /* Static */); - } - - if (TypeScript.SyntaxUtilities.containsToken(node.modifiers, 55 /* PrivateKeyword */)) { - result.setVarFlags(result.getVarFlags() | 2 /* Private */); - } else { - result.setVarFlags(result.getVarFlags() | 4 /* Public */); - } - - result.setVarFlags(result.getVarFlags() | 2048 /* ClassProperty */); - } - - this.setAST(node, result); - this.setSpan(result, start, node); - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitThrowStatement = function (node) { - this.assertElementAtPosition(node); - - var start = this.position; - var result = this.getAST(node); - if (result) { - this.movePast(node); - } else { - this.movePast(node.throwKeyword); - var expression = node.expression.accept(this); - this.movePast(node.semicolonToken); - - result = new TypeScript.ThrowStatement(expression); - } - - this.setAST(node, result); - this.setSpan(result, start, node); - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitReturnStatement = function (node) { - this.assertElementAtPosition(node); - - var start = this.position; - - var result = this.getAST(node); - if (result) { - this.movePast(node); - } else { - var preComments = this.convertNodeLeadingComments(node, start); - var postComments = this.convertNodeTrailingComments(node, start); - - this.movePast(node.returnKeyword); - var expression = node.expression ? node.expression.accept(this) : null; - this.movePast(node.semicolonToken); - - result = new TypeScript.ReturnStatement(expression); - result.preComments = preComments; - result.postComments = postComments; - } - - this.setAST(node, result); - this.setSpan(result, start, node); - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitObjectCreationExpression = function (node) { - this.assertElementAtPosition(node); - - var start = this.position; - var result = this.getAST(node); - if (result) { - this.movePast(node); - } else { - this.movePast(node.newKeyword); - var expression = node.expression.accept(this); - var typeArgumentList = node.argumentList === null || node.argumentList.typeArgumentList === null ? null : node.argumentList.typeArgumentList.accept(this); - var argumentList = this.convertArgumentListArguments(node.argumentList); - - result = new TypeScript.CallExpression(37 /* ObjectCreationExpression */, expression, typeArgumentList, argumentList); - - if (expression.nodeType === 11 /* TypeRef */) { - var typeRef = expression; - - if (typeRef.arrayCount === 0) { - var term = typeRef.term; - if (term.nodeType === 32 /* MemberAccessExpression */ || term.nodeType === 20 /* Name */) { - expression = term; - } - } - } - } - - this.setAST(node, result); - this.setSpan(result, start, node); - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitSwitchStatement = function (node) { - this.assertElementAtPosition(node); - - var start = this.position; - var result = this.getAST(node); - if (result) { - this.movePast(node); - } else { - this.movePast(node.switchKeyword); - this.movePast(node.openParenToken); - var expression = node.expression.accept(this); - this.movePast(node.closeParenToken); - var closeParenPosition = this.position; - this.movePast(node.openBraceToken); - - result = new TypeScript.SwitchStatement(expression); - - result.statement.minChar = start; - result.statement.limChar = closeParenPosition; - - result.caseList = new TypeScript.ASTList(); - - for (var i = 0, n = node.switchClauses.childCount(); i < n; i++) { - var switchClause = node.switchClauses.childAt(i); - var translated = switchClause.accept(this); - - if (switchClause.kind() === 232 /* DefaultSwitchClause */) { - result.defaultCase = translated; - } - - result.caseList.append(translated); - } - - this.movePast(node.closeBraceToken); - } - - this.setAST(node, result); - this.setSpan(result, start, node); - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitCaseSwitchClause = function (node) { - this.assertElementAtPosition(node); - - var start = this.position; - var result = this.getAST(node); - if (result) { - this.movePast(node); - } else { - this.movePast(node.caseKeyword); - var expression = node.expression.accept(this); - this.movePast(node.colonToken); - var statements = this.visitSyntaxList(node.statements); - - result = new TypeScript.CaseClause(); - - result.expr = expression; - result.body = statements; - } - - this.setAST(node, result); - this.setSpan(result, start, node); - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitDefaultSwitchClause = function (node) { - this.assertElementAtPosition(node); - - var start = this.position; - var result = this.getAST(node); - if (result) { - this.movePast(node); - } else { - this.movePast(node.defaultKeyword); - this.movePast(node.colonToken); - var statements = this.visitSyntaxList(node.statements); - - result = new TypeScript.CaseClause(); - result.body = statements; - } - - this.setAST(node, result); - this.setSpan(result, start, node); - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitBreakStatement = function (node) { - this.assertElementAtPosition(node); - - var start = this.position; - var result = this.getAST(node); - if (result) { - this.movePast(node); - } else { - this.movePast(node.breakKeyword); - this.movePast(node.identifier); - this.movePast(node.semicolonToken); - - result = new TypeScript.Jump(82 /* BreakStatement */); - - if (node.identifier !== null) { - result.target = node.identifier.valueText(); - } - } - - this.setAST(node, result); - this.setSpan(result, start, node); - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitContinueStatement = function (node) { - this.assertElementAtPosition(node); - - var start = this.position; - var result = this.getAST(node); - if (result) { - this.movePast(node); - } else { - this.movePast(node.continueKeyword); - this.movePast(node.identifier); - this.movePast(node.semicolonToken); - - result = new TypeScript.Jump(83 /* ContinueStatement */); - - if (node.identifier !== null) { - result.target = node.identifier.valueText(); - } - } - - this.setAST(node, result); - this.setSpan(result, start, node); - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitForStatement = function (node) { - this.assertElementAtPosition(node); - - var start = this.position; - var result = this.getAST(node); - if (result) { - this.movePast(node); - } else { - this.movePast(node.forKeyword); - this.movePast(node.openParenToken); - var init = node.variableDeclaration ? node.variableDeclaration.accept(this) : node.initializer ? node.initializer.accept(this) : null; - this.movePast(node.firstSemicolonToken); - var cond = node.condition ? node.condition.accept(this) : null; - this.movePast(node.secondSemicolonToken); - var incr = node.incrementor ? node.incrementor.accept(this) : null; - this.movePast(node.closeParenToken); - var body = node.statement.accept(this); - - result = new TypeScript.ForStatement(init, cond, incr, body); - } - - this.setAST(node, result); - this.setSpan(result, start, node); - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitForInStatement = function (node) { - this.assertElementAtPosition(node); - - var start = this.position; - var result = this.getAST(node); - if (result) { - this.movePast(node); - } else { - this.movePast(node.forKeyword); - this.movePast(node.openParenToken); - var init = node.variableDeclaration ? node.variableDeclaration.accept(this) : node.left.accept(this); - this.movePast(node.inKeyword); - var expression = node.expression.accept(this); - this.movePast(node.closeParenToken); - var body = node.statement.accept(this); - - result = new TypeScript.ForInStatement(init, expression, body); - } - - this.setAST(node, result); - this.setSpan(result, start, node); - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitWhileStatement = function (node) { - this.assertElementAtPosition(node); - - var start = this.position; - var result = this.getAST(node); - if (result) { - this.movePast(node); - } else { - this.moveTo(node, node.condition); - var condition = node.condition.accept(this); - this.movePast(node.closeParenToken); - var statement = node.statement.accept(this); - - result = new TypeScript.WhileStatement(condition, statement); - } - - this.setAST(node, result); - this.setSpan(result, start, node); - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitWithStatement = function (node) { - this.assertElementAtPosition(node); - - var start = this.position; - var result = this.getAST(node); - if (result) { - this.movePast(node); - } else { - this.moveTo(node, node.condition); - var condition = node.condition.accept(this); - this.movePast(node.closeParenToken); - var statement = node.statement.accept(this); - - result = new TypeScript.WithStatement(condition, statement); - } - - this.setAST(node, result); - this.setSpan(result, start, node); - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitCastExpression = function (node) { - this.assertElementAtPosition(node); - - var start = this.position; - var result = this.getAST(node); - if (result) { - this.movePast(node); - } else { - this.movePast(node.lessThanToken); - var castTerm = this.visitType(node.type); - this.movePast(node.greaterThanToken); - var expression = node.expression.accept(this); - - result = new TypeScript.UnaryExpression(78 /* CastExpression */, expression); - result.castTerm = castTerm; - } - - this.setAST(node, result); - this.setSpan(result, start, node); - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitObjectLiteralExpression = function (node) { - this.assertElementAtPosition(node); - - var start = this.position; - var result = this.getAST(node); - if (result) { - this.movePast(node); - } else { - var preComments = this.convertNodeLeadingComments(node, start); - - var openStart = this.position + node.openBraceToken.leadingTriviaWidth(); - this.movePast(node.openBraceToken); - - var propertyAssignments = this.visitSeparatedSyntaxList(node.propertyAssignments); - - var closeStart = this.position + node.closeBraceToken.leadingTriviaWidth(); - this.movePast(node.closeBraceToken); - - result = new TypeScript.UnaryExpression(22 /* ObjectLiteralExpression */, propertyAssignments); - result.preComments = preComments; - - if (this.isOnSingleLine(openStart, closeStart)) { - result.setFlags(result.getFlags() | 2 /* SingleLine */); - } - } - - this.setAST(node, result); - this.setSpan(result, start, node); - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitSimplePropertyAssignment = function (node) { - this.assertElementAtPosition(node); - - var start = this.position; - var result = this.getAST(node); - if (result) { - this.movePast(node); - } else { - var preComments = this.convertNodeLeadingComments(node, start); - - var left = node.propertyName.accept(this); - - this.previousTokenTrailingComments = this.convertTokenTrailingComments(node.colonToken, this.position + node.colonToken.leadingTriviaWidth() + node.colonToken.width()); - - this.movePast(node.colonToken); - var right = node.expression.accept(this); - - result = new TypeScript.BinaryExpression(80 /* Member */, left, right); - result.preComments = preComments; - - if (right.nodeType === 12 /* FunctionDeclaration */) { - var funcDecl = right; - funcDecl.hint = left.text; - } - } - - this.setAST(node, result); - this.setSpan(result, start, node); - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitFunctionPropertyAssignment = function (node) { - this.assertElementAtPosition(node); - - var start = this.position; - var result = this.getAST(node); - if (result) { - this.movePast(node); - } else { - var left = node.propertyName.accept(this); - var functionDeclaration = node.callSignature.accept(this); - var block = node.block.accept(this); - - functionDeclaration.hint = left.text; - functionDeclaration.block = block; - functionDeclaration.setFunctionFlags(16384 /* IsFunctionProperty */); - - result = new TypeScript.BinaryExpression(80 /* Member */, left, functionDeclaration); - } - - this.setAST(node, result); - this.setSpan(result, start, node); - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitGetAccessorPropertyAssignment = function (node) { - this.assertElementAtPosition(node); - - var start = this.position; - var result = this.getAST(node); - if (result) { - this.movePast(node); - } else { - this.moveTo(node, node.propertyName); - var name = this.identifierFromToken(node.propertyName, false, true); - var functionName = this.identifierFromToken(node.propertyName, false, true); - this.movePast(node.propertyName); - this.movePast(node.openParenToken); - this.movePast(node.closeParenToken); - var returnType = node.typeAnnotation ? node.typeAnnotation.accept(this) : null; - - var block = node.block ? node.block.accept(this) : null; - - var funcDecl = new TypeScript.FunctionDeclaration(functionName, block, false, null, new TypeScript.ASTList(), 12 /* FunctionDeclaration */); - this.setSpan(funcDecl, start, node); - - funcDecl.setFunctionFlags(funcDecl.getFunctionFlags() | 32 /* GetAccessor */); - funcDecl.setFunctionFlags(funcDecl.getFunctionFlags() | 8192 /* IsFunctionExpression */); - funcDecl.hint = "get" + node.propertyName.valueText(); - funcDecl.returnTypeAnnotation = returnType; - - result = new TypeScript.BinaryExpression(80 /* Member */, name, funcDecl); - } - - this.setAST(node, result); - this.setSpan(result, start, node); - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitSetAccessorPropertyAssignment = function (node) { - this.assertElementAtPosition(node); - - var start = this.position; - var result = this.getAST(node); - if (result) { - this.movePast(node); - } else { - this.moveTo(node, node.propertyName); - var name = this.identifierFromToken(node.propertyName, false, true); - var functionName = this.identifierFromToken(node.propertyName, false, true); - this.movePast(node.propertyName); - this.movePast(node.openParenToken); - var parameter = node.parameter.accept(this); - this.movePast(node.closeParenToken); - - var parameters = new TypeScript.ASTList(); - parameters.append(parameter); - - var block = node.block ? node.block.accept(this) : null; - - var funcDecl = new TypeScript.FunctionDeclaration(functionName, block, false, null, parameters, 12 /* FunctionDeclaration */); - this.setSpan(funcDecl, start, node); - - funcDecl.setFunctionFlags(funcDecl.getFunctionFlags() | 64 /* SetAccessor */); - funcDecl.setFunctionFlags(funcDecl.getFunctionFlags() | 8192 /* IsFunctionExpression */); - funcDecl.hint = "set" + node.propertyName.valueText(); - - result = new TypeScript.BinaryExpression(80 /* Member */, name, funcDecl); - } - - this.setAST(node, result); - this.setSpan(result, start, node); - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitFunctionExpression = function (node) { - this.assertElementAtPosition(node); - - var start = this.position; - var result = this.getAST(node); - if (result) { - this.movePast(node); - } else { - var preComments = this.convertNodeLeadingComments(node, start); - - this.movePast(node.functionKeyword); - var name = node.identifier === null ? null : this.identifierFromToken(node.identifier, false, true); - this.movePast(node.identifier); - var typeParameters = node.callSignature.typeParameterList === null ? null : node.callSignature.typeParameterList.accept(this); - var parameters = node.callSignature.parameterList.accept(this); - var returnType = node.callSignature.typeAnnotation ? node.callSignature.typeAnnotation.accept(this) : null; - - var block = node.block ? node.block.accept(this) : null; - - result = new TypeScript.FunctionDeclaration(name, block, false, typeParameters, parameters, 12 /* FunctionDeclaration */); - - result.preComments = preComments; - result.variableArgList = this.hasDotDotDotParameter(node.callSignature.parameterList.parameters); - result.returnTypeAnnotation = returnType; - result.setFunctionFlags(result.getFunctionFlags() | 8192 /* IsFunctionExpression */); - } - - this.setAST(node, result); - this.setSpan(result, start, node); - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitEmptyStatement = function (node) { - this.assertElementAtPosition(node); - - var start = this.position; - var result = this.getAST(node); - if (result) { - this.movePast(node); - } else { - this.movePast(node.semicolonToken); - - result = new TypeScript.EmptyStatement(); - } - - this.setAST(node, result); - this.setSpan(result, start, node); - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitTryStatement = function (node) { - this.assertElementAtPosition(node); - - var start = this.position; - var result = this.getAST(node); - if (result) { - this.movePast(node); - } else { - this.movePast(node.tryKeyword); - var tryBody = node.block.accept(this); - - var catchClause = null; - if (node.catchClause !== null) { - catchClause = node.catchClause.accept(this); - } - - var finallyBody = null; - if (node.finallyClause !== null) { - finallyBody = node.finallyClause.accept(this); - } - - result = new TypeScript.TryStatement(tryBody, catchClause, finallyBody); - } - - TypeScript.Debug.assert(result !== null); - this.setAST(node, result); - this.setSpan(result, start, node); - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitCatchClause = function (node) { - this.assertElementAtPosition(node); - - var start = this.position; - var result = this.getAST(node); - if (result) { - this.movePast(node); - } else { - this.movePast(node.catchKeyword); - this.movePast(node.openParenToken); - var identifier = this.identifierFromToken(node.identifier, false, true); - this.movePast(node.identifier); - var typeExpr = node.typeAnnotation ? node.typeAnnotation.accept(this) : null; - this.movePast(node.closeParenToken); - var block = node.block.accept(this); - - var varDecl = new TypeScript.VariableDeclarator(identifier); - this.setSpanExplicit(varDecl, identifier.minChar, identifier.limChar); - - varDecl.typeExpr = typeExpr; - - result = new TypeScript.CatchClause(varDecl, block); - } - - this.setAST(node, result); - this.setSpan(result, start, node); - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitFinallyClause = function (node) { - this.movePast(node.finallyKeyword); - return node.block.accept(this); - }; - - SyntaxTreeToAstVisitor.prototype.visitLabeledStatement = function (node) { - this.assertElementAtPosition(node); - - var start = this.position; - var result = this.getAST(node); - if (result) { - this.movePast(node); - } else { - var identifier = this.identifierFromToken(node.identifier, false, true); - this.movePast(node.identifier); - this.movePast(node.colonToken); - var statement = node.statement.accept(this); - - result = new TypeScript.LabeledStatement(identifier, statement); - } - - this.setAST(node, result); - this.setSpan(result, start, node); - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitDoStatement = function (node) { - this.assertElementAtPosition(node); - - var start = this.position; - var result = this.getAST(node); - if (result) { - this.movePast(node); - } else { - this.movePast(node.doKeyword); - var statement = node.statement.accept(this); - var whileSpan = new TypeScript.ASTSpan(); - this.setSpan(whileSpan, this.position, node.whileKeyword); - - this.movePast(node.whileKeyword); - this.movePast(node.openParenToken); - var condition = node.condition.accept(this); - this.movePast(node.closeParenToken); - this.movePast(node.semicolonToken); - - result = new TypeScript.DoStatement(statement, condition); - result.whileSpan = whileSpan; - } - - this.setAST(node, result); - this.setSpan(result, start, node); - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitTypeOfExpression = function (node) { - this.assertElementAtPosition(node); - - var start = this.position; - var result = this.getAST(node); - if (result) { - this.movePast(node); - } else { - this.movePast(node.typeOfKeyword); - var expression = node.expression.accept(this); - - result = new TypeScript.UnaryExpression(34 /* TypeOfExpression */, expression); - } - - this.setAST(node, result); - this.setSpan(result, start, node); - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitDeleteExpression = function (node) { - this.assertElementAtPosition(node); - - var start = this.position; - var result = this.getAST(node); - if (result) { - this.movePast(node); - } else { - this.movePast(node.deleteKeyword); - var expression = node.expression.accept(this); - - result = new TypeScript.UnaryExpression(28 /* DeleteExpression */, expression); - } - - this.setAST(node, result); - this.setSpan(result, start, node); - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitVoidExpression = function (node) { - this.assertElementAtPosition(node); - - var start = this.position; - var result = this.getAST(node); - if (result) { - this.movePast(node); - } else { - this.movePast(node.voidKeyword); - var expression = node.expression.accept(this); - - result = new TypeScript.UnaryExpression(24 /* VoidExpression */, expression); - } - - this.setAST(node, result); - this.setSpan(result, start, node); - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitDebuggerStatement = function (node) { - this.assertElementAtPosition(node); - - var start = this.position; - var result = this.getAST(node); - if (result) { - this.movePast(node); - } else { - this.movePast(node.debuggerKeyword); - this.movePast(node.semicolonToken); - - result = new TypeScript.DebuggerStatement(); - } - - this.setAST(node, result); - this.setSpan(result, start, node); - return result; - }; - SyntaxTreeToAstVisitor.checkPositions = false; - - SyntaxTreeToAstVisitor.protoString = "__proto__"; - SyntaxTreeToAstVisitor.protoSubstitutionString = "#__proto__"; - return SyntaxTreeToAstVisitor; - })(); - TypeScript.SyntaxTreeToAstVisitor = SyntaxTreeToAstVisitor; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var Document = (function () { - function Document(fileName, compilationSettings, scriptSnapshot, byteOrderMark, version, isOpen, syntaxTree) { - this.fileName = fileName; - this.compilationSettings = compilationSettings; - this.scriptSnapshot = scriptSnapshot; - this.byteOrderMark = byteOrderMark; - this.version = version; - this.isOpen = isOpen; - this._diagnostics = null; - this._syntaxTree = null; - this._bloomFilter = null; - if (isOpen) { - this._syntaxTree = syntaxTree; - } else { - this._diagnostics = syntaxTree.diagnostics(); - } - - var identifiers = new TypeScript.BlockIntrinsics(); - - var identifierWalker = new TypeScript.IdentifierWalker(identifiers); - syntaxTree.sourceUnit().accept(identifierWalker); - - var identifierCount = 0; - for (var name in identifiers) { - identifierCount++; - } - this._bloomFilter = new TypeScript.BloomFilter(identifierCount); - this._bloomFilter.addKeys(identifiers); - - this.lineMap = syntaxTree.lineMap(); - this.script = TypeScript.SyntaxTreeToAstVisitor.visit(syntaxTree, fileName, compilationSettings); - } - Document.prototype.diagnostics = function () { - if (this._diagnostics === null) { - this._diagnostics = this._syntaxTree.diagnostics(); - } - - return this._diagnostics; - }; - - Document.prototype.syntaxTree = function () { - if (this._syntaxTree) { - return this._syntaxTree; - } - - return TypeScript.Parser.parse(this.fileName, TypeScript.SimpleText.fromScriptSnapshot(this.scriptSnapshot), TypeScript.isDTSFile(this.fileName), this.compilationSettings.codeGenTarget, TypeScript.getParseOptions(this.compilationSettings)); - }; - - Document.prototype.bloomFilter = function () { - return this._bloomFilter; - }; - - Document.prototype.update = function (scriptSnapshot, version, isOpen, textChangeRange, settings) { - var oldScript = this.script; - var oldSyntaxTree = this._syntaxTree; - - var text = TypeScript.SimpleText.fromScriptSnapshot(scriptSnapshot); - - var newSyntaxTree = textChangeRange === null || oldSyntaxTree === null ? TypeScript.Parser.parse(this.fileName, text, TypeScript.isDTSFile(this.fileName), settings.codeGenTarget, TypeScript.getParseOptions(this.compilationSettings)) : TypeScript.Parser.incrementalParse(oldSyntaxTree, textChangeRange, text); - - return new Document(this.fileName, this.compilationSettings, scriptSnapshot, this.byteOrderMark, version, isOpen, newSyntaxTree); - }; - - Document.create = function (fileName, scriptSnapshot, byteOrderMark, version, isOpen, referencedFiles, compilationSettings) { - var syntaxTree = TypeScript.Parser.parse(fileName, TypeScript.SimpleText.fromScriptSnapshot(scriptSnapshot), TypeScript.isDTSFile(fileName), compilationSettings.codeGenTarget, TypeScript.getParseOptions(compilationSettings)); - - var document = new Document(fileName, compilationSettings, scriptSnapshot, byteOrderMark, version, isOpen, syntaxTree); - document.script.referencedFiles = referencedFiles; - - return document; - }; - return Document; - })(); - TypeScript.Document = Document; - - TypeScript.globalSemanticInfoChain = null; - TypeScript.globalBinder = null; - TypeScript.globalLogger = null; - var TypeScriptCompiler = (function () { - function TypeScriptCompiler(logger, settings, diagnosticMessages) { - if (typeof logger === "undefined") { logger = new TypeScript.NullLogger(); } - if (typeof settings === "undefined") { settings = new TypeScript.CompilationSettings(); } - if (typeof diagnosticMessages === "undefined") { diagnosticMessages = null; } - this.logger = logger; - this.settings = settings; - this.diagnosticMessages = diagnosticMessages; - this.pullTypeChecker = null; - this.semanticInfoChain = null; - this.fileNameToDocument = new TypeScript.StringHashTable(); - this.emitOptions = new TypeScript.EmitOptions(this.settings); - TypeScript.globalLogger = logger; - if (this.diagnosticMessages) { - TypeScript.diagnosticMessages = this.diagnosticMessages; - } - } - TypeScriptCompiler.prototype.getDocument = function (fileName) { - return this.fileNameToDocument.lookup(fileName); - }; - - TypeScriptCompiler.prototype.timeFunction = function (funcDescription, func) { - return TypeScript.timeFunction(this.logger, funcDescription, func); - }; - - TypeScriptCompiler.prototype.addSourceUnit = function (fileName, scriptSnapshot, byteOrderMark, version, isOpen, referencedFiles) { - if (typeof referencedFiles === "undefined") { referencedFiles = []; } - var _this = this; - return this.timeFunction("addSourceUnit(" + fileName + ")", function () { - var document = Document.create(fileName, scriptSnapshot, byteOrderMark, version, isOpen, referencedFiles, _this.emitOptions.compilationSettings); - _this.fileNameToDocument.addOrUpdate(fileName, document); - - return document; - }); - }; - - TypeScriptCompiler.prototype.updateSourceUnit = function (fileName, scriptSnapshot, version, isOpen, textChangeRange) { - var _this = this; - return this.timeFunction("pullUpdateUnit(" + fileName + ")", function () { - var document = _this.getDocument(fileName); - var updatedDocument = document.update(scriptSnapshot, version, isOpen, textChangeRange, _this.settings); - - _this.fileNameToDocument.addOrUpdate(fileName, updatedDocument); - - _this.pullUpdateScript(document, updatedDocument); - - return updatedDocument; - }); - }; - - TypeScriptCompiler.prototype.isDynamicModuleCompilation = function () { - var fileNames = this.fileNameToDocument.getAllKeys(); - for (var i = 0, n = fileNames.length; i < n; i++) { - var document = this.getDocument(fileNames[i]); - var script = document.script; - if (!script.isDeclareFile && script.topLevelMod !== null) { - return true; - } - } - return false; - }; - - TypeScriptCompiler.prototype.updateCommonDirectoryPath = function () { - var commonComponents = []; - var commonComponentsLength = -1; - - var fileNames = this.fileNameToDocument.getAllKeys(); - for (var i = 0, len = fileNames.length; i < len; i++) { - var fileName = fileNames[i]; - var document = this.getDocument(fileNames[i]); - var script = document.script; - - if (!script.isDeclareFile) { - var fileComponents = TypeScript.filePathComponents(fileName); - if (commonComponentsLength === -1) { - commonComponents = fileComponents; - commonComponentsLength = commonComponents.length; - } else { - var updatedPath = false; - for (var j = 0; j < commonComponentsLength && j < fileComponents.length; j++) { - if (commonComponents[j] !== fileComponents[j]) { - commonComponentsLength = j; - updatedPath = true; - - if (j === 0) { - return new TypeScript.Diagnostic(null, 0, 0, 273 /* Cannot_find_the_common_subdirectory_path_for_the_input_files */, null); - } - - break; - } - } - - if (!updatedPath && fileComponents.length < commonComponentsLength) { - commonComponentsLength = fileComponents.length; - } - } - } - } - - this.emitOptions.commonDirectoryPath = commonComponents.slice(0, commonComponentsLength).join("/") + "/"; - if (this.emitOptions.compilationSettings.outputOption.charAt(this.emitOptions.compilationSettings.outputOption.length - 1) !== "/") { - this.emitOptions.compilationSettings.outputOption += "/"; - } - - return null; - }; - - TypeScriptCompiler.prototype.parseEmitOption = function (ioHost) { - this.emitOptions.ioHost = ioHost; - if (this.emitOptions.compilationSettings.outputOption === "") { - this.emitOptions.outputMany = true; - this.emitOptions.commonDirectoryPath = ""; - return null; - } - - this.emitOptions.compilationSettings.outputOption = TypeScript.switchToForwardSlashes(this.emitOptions.ioHost.resolvePath(this.emitOptions.compilationSettings.outputOption)); - - if (this.emitOptions.ioHost.directoryExists(this.emitOptions.compilationSettings.outputOption)) { - this.emitOptions.outputMany = true; - } else if (this.emitOptions.ioHost.fileExists(this.emitOptions.compilationSettings.outputOption)) { - this.emitOptions.outputMany = false; - } else { - this.emitOptions.outputMany = !TypeScript.isJSFile(this.emitOptions.compilationSettings.outputOption); - } - - if (this.isDynamicModuleCompilation() && !this.emitOptions.outputMany) { - return new TypeScript.Diagnostic(null, 0, 0, 274 /* Cannot_compile_dynamic_modules_when_emitting_into_single_file */, null); - } - - if (this.emitOptions.outputMany) { - return this.updateCommonDirectoryPath(); - } - - return null; - }; - - TypeScriptCompiler.prototype.getScripts = function () { - var result = []; - var fileNames = this.fileNameToDocument.getAllKeys(); - - for (var i = 0, n = fileNames.length; i < n; i++) { - var document = this.getDocument(fileNames[i]); - result.push(document.script); - } - - return result; - }; - - TypeScriptCompiler.prototype.writeByteOrderMarkForDocument = function (document) { - if (this.emitOptions.outputMany) { - return document.byteOrderMark !== 0 /* None */; - } else { - var fileNames = this.fileNameToDocument.getAllKeys(); - - for (var i = 0, n = fileNames.length; i < n; i++) { - var document = this.getDocument(fileNames[i]); - if (document.byteOrderMark !== 0 /* None */) { - return true; - } - } - - return false; - } - }; - - TypeScriptCompiler.mapToDTSFileName = function (fileName, wholeFileNameReplaced) { - return TypeScript.getDeclareFilePath(fileName); - }; - - TypeScriptCompiler.prototype.canEmitDeclarations = function (script) { - if (!this.settings.generateDeclarationFiles) { - return false; - } - - if (!!script && (script.isDeclareFile || script.moduleElements === null)) { - return false; - } - - return true; - }; - - TypeScriptCompiler.prototype.emitDeclarations = function (document, declarationEmitter) { - var script = document.script; - if (this.canEmitDeclarations(script)) { - if (!declarationEmitter) { - var declareFileName = this.emitOptions.mapOutputFileName(document.fileName, TypeScriptCompiler.mapToDTSFileName); - declarationEmitter = new TypeScript.DeclarationEmitter(declareFileName, this.semanticInfoChain, this.emitOptions, document.byteOrderMark !== 0 /* None */); - } - - declarationEmitter.fileName = document.fileName; - declarationEmitter.emitDeclarations(script); - } - - return declarationEmitter; - }; - - TypeScriptCompiler.prototype.emitAllDeclarations = function () { - if (this.canEmitDeclarations()) { - var sharedEmitter = null; - var fileNames = this.fileNameToDocument.getAllKeys(); - - for (var i = 0, n = fileNames.length; i < n; i++) { - var fileName = fileNames[i]; - - try { - var document = this.getDocument(fileNames[i]); - - if (this.emitOptions.outputMany) { - var singleEmitter = this.emitDeclarations(document); - if (singleEmitter) { - singleEmitter.close(); - } - } else { - sharedEmitter = this.emitDeclarations(document, sharedEmitter); - } - } catch (ex1) { - return TypeScript.Emitter.handleEmitterError(fileName, ex1); - } - } - - if (sharedEmitter) { - try { - sharedEmitter.close(); - } catch (ex2) { - return TypeScript.Emitter.handleEmitterError(sharedEmitter.fileName, ex2); - } - } - } - - return []; - }; - - TypeScriptCompiler.prototype.emitUnitDeclarations = function (fileName) { - if (this.canEmitDeclarations()) { - if (this.emitOptions.outputMany) { - try { - var document = this.getDocument(fileName); - var emitter = this.emitDeclarations(document); - if (emitter) { - emitter.close(); - } - } catch (ex1) { - return TypeScript.Emitter.handleEmitterError(fileName, ex1); - } - } else { - return this.emitAllDeclarations(); - } - } - - return []; - }; - - TypeScriptCompiler.mapToFileNameExtension = function (extension, fileName, wholeFileNameReplaced) { - if (wholeFileNameReplaced) { - return fileName; - } else { - var splitFname = fileName.split("."); - splitFname.pop(); - return splitFname.join(".") + extension; - } - }; - - TypeScriptCompiler.mapToJSFileName = function (fileName, wholeFileNameReplaced) { - return TypeScriptCompiler.mapToFileNameExtension(".js", fileName, wholeFileNameReplaced); - }; - - TypeScriptCompiler.prototype.emit = function (document, inputOutputMapper, emitter) { - var script = document.script; - if (!script.isDeclareFile) { - var typeScriptFileName = document.fileName; - if (!emitter) { - var javaScriptFileName = this.emitOptions.mapOutputFileName(typeScriptFileName, TypeScriptCompiler.mapToJSFileName); - var outFile = this.createFile(javaScriptFileName, this.writeByteOrderMarkForDocument(document)); - - emitter = new TypeScript.Emitter(javaScriptFileName, outFile, this.emitOptions, this.semanticInfoChain); - - if (this.settings.mapSourceFiles) { - var sourceMapFileName = javaScriptFileName + TypeScript.SourceMapper.MapFileExtension; - emitter.setSourceMappings(new TypeScript.SourceMapper(typeScriptFileName, javaScriptFileName, sourceMapFileName, outFile, this.createFile(sourceMapFileName, false), this.settings.emitFullSourceMapPath)); - } - - if (inputOutputMapper) { - inputOutputMapper(typeScriptFileName, javaScriptFileName); - } - } else if (this.settings.mapSourceFiles) { - emitter.setSourceMappings(new TypeScript.SourceMapper(typeScriptFileName, emitter.emittingFileName, emitter.sourceMapper.sourceMapFileName, emitter.outfile, emitter.sourceMapper.sourceMapOut, this.settings.emitFullSourceMapPath)); - } - - emitter.setDocument(document); - emitter.emitJavascript(script, false); - } - - return emitter; - }; - - TypeScriptCompiler.prototype.emitAll = function (ioHost, inputOutputMapper) { - var optionsDiagnostic = this.parseEmitOption(ioHost); - if (optionsDiagnostic) { - return [optionsDiagnostic]; - } - - var startEmitTime = (new Date()).getTime(); - - var fileNames = this.fileNameToDocument.getAllKeys(); - var sharedEmitter = null; - - for (var i = 0, n = fileNames.length; i < n; i++) { - var fileName = fileNames[i]; - - var document = this.getDocument(fileName); - - try { - if (this.emitOptions.outputMany) { - var singleEmitter = this.emit(document, inputOutputMapper); - - if (singleEmitter) { - singleEmitter.emitSourceMapsAndClose(); - } - } else { - sharedEmitter = this.emit(document, inputOutputMapper, sharedEmitter); - } - } catch (ex1) { - return TypeScript.Emitter.handleEmitterError(fileName, ex1); - } - } - - this.logger.log("Emit: " + ((new Date()).getTime() - startEmitTime)); - - if (sharedEmitter) { - try { - sharedEmitter.emitSourceMapsAndClose(); - } catch (ex2) { - return TypeScript.Emitter.handleEmitterError(sharedEmitter.document.fileName, ex2); - } - } - - return []; - }; - - TypeScriptCompiler.prototype.emitUnit = function (fileName, ioHost, inputOutputMapper) { - var optionsDiagnostic = this.parseEmitOption(ioHost); - if (optionsDiagnostic) { - return [optionsDiagnostic]; - } - - if (this.emitOptions.outputMany) { - var document = this.getDocument(fileName); - try { - var emitter = this.emit(document, inputOutputMapper); - - if (emitter) { - emitter.emitSourceMapsAndClose(); - } - } catch (ex1) { - return TypeScript.Emitter.handleEmitterError(fileName, ex1); - } - - return []; - } else { - return this.emitAll(ioHost, inputOutputMapper); - } - }; - - TypeScriptCompiler.prototype.createFile = function (fileName, writeByteOrderMark) { - return new TypeScript.TextWriter(this.emitOptions.ioHost, fileName, writeByteOrderMark); - }; - - TypeScriptCompiler.prototype.getSyntacticDiagnostics = function (fileName) { - return this.getDocument(fileName).diagnostics(); - }; - - TypeScriptCompiler.prototype.getSyntaxTree = function (fileName) { - return this.getDocument(fileName).syntaxTree(); - }; - TypeScriptCompiler.prototype.getScript = function (fileName) { - return this.getDocument(fileName).script; - }; - - TypeScriptCompiler.prototype.getSemanticDiagnostics = function (fileName) { - var errors = []; - var unit = this.semanticInfoChain.getUnit(fileName); - - TypeScript.globalSemanticInfoChain = this.semanticInfoChain; - if (TypeScript.globalBinder) { - TypeScript.globalBinder.semanticInfoChain = this.semanticInfoChain; - } - - if (unit) { - var document = this.getDocument(fileName); - var script = document.script; - - if (script) { - this.pullTypeChecker.typeCheckScript(script, fileName, this); - - unit.getDiagnostics(errors); - } - } - - return errors; - }; - - TypeScriptCompiler.prototype.pullTypeCheck = function () { - var _this = this; - return this.timeFunction("pullTypeCheck()", function () { - _this.semanticInfoChain = new TypeScript.SemanticInfoChain(); - TypeScript.globalSemanticInfoChain = _this.semanticInfoChain; - _this.pullTypeChecker = new TypeScript.PullTypeChecker(_this.settings, _this.semanticInfoChain); - - var declCollectionContext = null; - var i, n; - - var createDeclsStartTime = new Date().getTime(); - - var fileNames = _this.fileNameToDocument.getAllKeys(); - for (var i = 0, n = fileNames.length; i < n; i++) { - var fileName = fileNames[i]; - var document = _this.getDocument(fileName); - var semanticInfo = new TypeScript.SemanticInfo(fileName); - - declCollectionContext = new TypeScript.DeclCollectionContext(semanticInfo); - declCollectionContext.scriptName = fileName; - - TypeScript.getAstWalkerFactory().walk(document.script, TypeScript.preCollectDecls, TypeScript.postCollectDecls, null, declCollectionContext); - - semanticInfo.addTopLevelDecl(declCollectionContext.getParent()); - - _this.semanticInfoChain.addUnit(semanticInfo); - } - - var createDeclsEndTime = new Date().getTime(); - - var bindStartTime = new Date().getTime(); - - var binder = new TypeScript.PullSymbolBinder(_this.semanticInfoChain); - TypeScript.globalBinder = binder; - - var bindEndTime = new Date().getTime(); - - _this.logger.log("Decl creation: " + (createDeclsEndTime - createDeclsStartTime)); - _this.logger.log("Binding: " + (bindEndTime - bindStartTime)); - _this.logger.log(" Time in findSymbol: " + TypeScript.time_in_findSymbol); - _this.logger.log("Number of symbols created: " + TypeScript.pullSymbolID); - _this.logger.log("Number of specialized types created: " + TypeScript.nSpecializationsCreated); - _this.logger.log("Number of specialized signatures created: " + TypeScript.nSpecializedSignaturesCreated); - }); - }; - - TypeScriptCompiler.prototype.pullUpdateScript = function (oldDocument, newDocument) { - var _this = this; - this.timeFunction("pullUpdateScript: ", function () { - var oldScript = oldDocument.script; - var newScript = newDocument.script; - - var newScriptSemanticInfo = new TypeScript.SemanticInfo(oldDocument.fileName); - var oldScriptSemanticInfo = _this.semanticInfoChain.getUnit(oldDocument.fileName); - - TypeScript.lastBoundPullDeclId = TypeScript.pullDeclID; - TypeScript.lastBoundPullSymbolID = TypeScript.pullSymbolID; - - var declCollectionContext = new TypeScript.DeclCollectionContext(newScriptSemanticInfo); - - declCollectionContext.scriptName = oldDocument.fileName; - - TypeScript.getAstWalkerFactory().walk(newScript, TypeScript.preCollectDecls, TypeScript.postCollectDecls, null, declCollectionContext); - - var oldTopLevelDecl = oldScriptSemanticInfo.getTopLevelDecls()[0]; - var newTopLevelDecl = declCollectionContext.getParent(); - - newScriptSemanticInfo.addTopLevelDecl(newTopLevelDecl); - - if (_this.pullTypeChecker && _this.pullTypeChecker.resolver) { - _this.pullTypeChecker.resolver.cleanCachedGlobals(); - } - - _this.semanticInfoChain.updateUnit(oldScriptSemanticInfo, newScriptSemanticInfo); - - _this.logger.log("Cleaning symbols..."); - var cleanStart = new Date().getTime(); - _this.semanticInfoChain.update(); - var cleanEnd = new Date().getTime(); - _this.logger.log(" time to clean: " + (cleanEnd - cleanStart)); - - if (_this.pullTypeChecker && _this.pullTypeChecker.resolver) { - _this.pullTypeChecker.resolver.setUnitPath(oldDocument.fileName); - } - }); - }; - - TypeScriptCompiler.prototype.getSymbolOfDeclaration = function (decl) { - if (!decl) { - return null; - } - var ast = this.pullTypeChecker.resolver.getASTForDecl(decl); - if (!ast) { - return null; - } - var enlosingDecl = this.pullTypeChecker.resolver.getEnclosingDecl(decl); - if (ast.nodeType === 80 /* Member */) { - return this.getSymbolOfDeclaration(enlosingDecl); - } - var resolutionContext = new TypeScript.PullTypeResolutionContext(); - return this.pullTypeChecker.resolver.resolveAST(ast, false, enlosingDecl, resolutionContext).symbol; - }; - - TypeScriptCompiler.prototype.resolvePosition = function (pos, document) { - var declStack = []; - var resultASTs = []; - var script = document.script; - var scriptName = document.fileName; - - var semanticInfo = this.semanticInfoChain.getUnit(scriptName); - var lastDeclAST = null; - var foundAST = null; - var symbol = null; - var candidateSignature = null; - var callSignatures = null; - - var lambdaAST = null; - var declarationInitASTs = []; - var objectLitAST = null; - var asgAST = null; - var typeAssertionASTs = []; - var resolutionContext = new TypeScript.PullTypeResolutionContext(); - var inTypeReference = false; - var enclosingDecl = null; - var isConstructorCall = false; - - TypeScript.globalSemanticInfoChain = this.semanticInfoChain; - if (TypeScript.globalBinder) { - TypeScript.globalBinder.semanticInfoChain = this.semanticInfoChain; - } - - var pre = function (cur, parent) { - if (TypeScript.isValidAstNode(cur)) { - if (pos >= cur.minChar && pos <= cur.limChar) { - var previous = resultASTs[resultASTs.length - 1]; - - if (previous === undefined || (cur.minChar >= previous.minChar && cur.limChar <= previous.limChar)) { - var decl = semanticInfo.getDeclForAST(cur); - - if (decl) { - declStack[declStack.length] = decl; - lastDeclAST = cur; - } - - if (cur.nodeType === 12 /* FunctionDeclaration */ && TypeScript.hasFlag((cur).getFunctionFlags(), 8192 /* IsFunctionExpression */)) { - lambdaAST = cur; - } else if (cur.nodeType === 17 /* VariableDeclarator */) { - declarationInitASTs[declarationInitASTs.length] = cur; - } else if (cur.nodeType === 22 /* ObjectLiteralExpression */) { - objectLitAST = cur; - } else if (cur.nodeType === 78 /* CastExpression */) { - typeAssertionASTs[typeAssertionASTs.length] = cur; - } else if (cur.nodeType === 38 /* AssignmentExpression */) { - asgAST = cur; - } else if (cur.nodeType === 11 /* TypeRef */) { - inTypeReference = true; - } - - resultASTs[resultASTs.length] = cur; - } - } - } - return cur; - }; - - TypeScript.getAstWalkerFactory().walk(script, pre); - - if (resultASTs.length) { - this.pullTypeChecker.setUnit(scriptName); - - foundAST = resultASTs[resultASTs.length - 1]; - - if (foundAST.nodeType === 20 /* Name */ && resultASTs.length > 1) { - var previousAST = resultASTs[resultASTs.length - 2]; - switch (previousAST.nodeType) { - case 14 /* InterfaceDeclaration */: - case 13 /* ClassDeclaration */: - case 15 /* ModuleDeclaration */: - if (foundAST === (previousAST).name) { - foundAST = previousAST; - } - break; - - case 17 /* VariableDeclarator */: - if (foundAST === (previousAST).id) { - foundAST = previousAST; - } - break; - - case 12 /* FunctionDeclaration */: - if (foundAST === (previousAST).name) { - foundAST = previousAST; - } - break; - } - } - - var funcDecl = null; - if (lastDeclAST === foundAST) { - symbol = declStack[declStack.length - 1].getSymbol(); - this.pullTypeChecker.resolver.resolveDeclaredSymbol(symbol, null, resolutionContext); - symbol.setUnresolved(); - enclosingDecl = declStack[declStack.length - 1].getParentDecl(); - if (foundAST.nodeType === 12 /* FunctionDeclaration */) { - funcDecl = foundAST; - } - } else { - for (var i = declStack.length - 1; i >= 0; i--) { - if (!(declStack[i].getKind() & (1024 /* Variable */ | 2048 /* Parameter */))) { - enclosingDecl = declStack[i]; - break; - } - } - - var callExpression = null; - if ((foundAST.nodeType === 30 /* SuperExpression */ || foundAST.nodeType === 29 /* ThisExpression */ || foundAST.nodeType === 20 /* Name */) && resultASTs.length > 1) { - for (var i = resultASTs.length - 2; i >= 0; i--) { - if (resultASTs[i].nodeType === 32 /* MemberAccessExpression */ && (resultASTs[i]).operand2 === resultASTs[i + 1]) { - foundAST = resultASTs[i]; - } else if ((resultASTs[i].nodeType === 36 /* InvocationExpression */ || resultASTs[i].nodeType === 37 /* ObjectCreationExpression */) && (resultASTs[i]).target === resultASTs[i + 1]) { - callExpression = resultASTs[i]; - break; - } else if (resultASTs[i].nodeType === 12 /* FunctionDeclaration */ && (resultASTs[i]).name === resultASTs[i + 1]) { - funcDecl = resultASTs[i]; - break; - } else { - break; - } - } - } - - if (foundAST.nodeType === 1 /* List */) { - for (var i = 0; i < (foundAST).members.length; i++) { - if ((foundAST).members[i].minChar > pos) { - foundAST = (foundAST).members[i]; - break; - } - } - } - - resolutionContext.resolvingTypeReference = inTypeReference; - - var inContextuallyTypedAssignment = false; - - if (declarationInitASTs.length) { - var assigningAST; - - for (var i = 0; i < declarationInitASTs.length; i++) { - assigningAST = declarationInitASTs[i]; - inContextuallyTypedAssignment = (assigningAST !== null) && (assigningAST.typeExpr !== null); - - this.pullTypeChecker.resolver.resolveAST(assigningAST, false, null, resolutionContext); - var varSymbolAndDiagnostics = this.semanticInfoChain.getSymbolAndDiagnosticsForAST(assigningAST, scriptName); - var varSymbol = varSymbolAndDiagnostics && varSymbolAndDiagnostics.symbol; - - if (varSymbol && inContextuallyTypedAssignment) { - var contextualType = varSymbol.getType(); - resolutionContext.pushContextualType(contextualType, false, null); - } - - if (assigningAST.init) { - this.pullTypeChecker.resolver.resolveAST(assigningAST.init, inContextuallyTypedAssignment, enclosingDecl, resolutionContext); - } - } - } - - if (typeAssertionASTs.length) { - for (var i = 0; i < typeAssertionASTs.length; i++) { - this.pullTypeChecker.resolver.resolveAST(typeAssertionASTs[i], inContextuallyTypedAssignment, enclosingDecl, resolutionContext); - } - } - - if (asgAST) { - this.pullTypeChecker.resolver.resolveAST(asgAST, inContextuallyTypedAssignment, enclosingDecl, resolutionContext); - } - - if (objectLitAST) { - this.pullTypeChecker.resolver.resolveAST(objectLitAST, inContextuallyTypedAssignment, enclosingDecl, resolutionContext); - } - - if (lambdaAST) { - this.pullTypeChecker.resolver.resolveAST(lambdaAST, true, enclosingDecl, resolutionContext); - enclosingDecl = semanticInfo.getDeclForAST(lambdaAST); - } - - symbol = this.pullTypeChecker.resolver.resolveAST(foundAST, inContextuallyTypedAssignment, enclosingDecl, resolutionContext).symbol; - if (callExpression) { - var isPropertyOrVar = symbol.getKind() === 4096 /* Property */ || symbol.getKind() === 1024 /* Variable */; - var typeSymbol = symbol.getType(); - if (isPropertyOrVar) { - isPropertyOrVar = (typeSymbol.getKind() !== 16 /* Interface */ && typeSymbol.getKind() !== 8388608 /* ObjectType */) || typeSymbol.getName() === ""; - } - - if (!isPropertyOrVar) { - isConstructorCall = foundAST.nodeType === 30 /* SuperExpression */ || callExpression.nodeType === 37 /* ObjectCreationExpression */; - - if (foundAST.nodeType === 30 /* SuperExpression */) { - if (symbol.getKind() === 8 /* Class */) { - callSignatures = (symbol).getConstructorMethod().getType().getConstructSignatures(); - } - } else { - callSignatures = callExpression.nodeType === 36 /* InvocationExpression */ ? typeSymbol.getCallSignatures() : typeSymbol.getConstructSignatures(); - } - - var callResolutionResults = new TypeScript.PullAdditionalCallResolutionData(); - if (callExpression.nodeType === 36 /* InvocationExpression */) { - this.pullTypeChecker.resolver.resolveCallExpression(callExpression, inContextuallyTypedAssignment, enclosingDecl, resolutionContext, callResolutionResults); - } else { - this.pullTypeChecker.resolver.resolveNewExpression(callExpression, inContextuallyTypedAssignment, enclosingDecl, resolutionContext, callResolutionResults); - } - - if (callResolutionResults.candidateSignature) { - candidateSignature = callResolutionResults.candidateSignature; - } - if (callResolutionResults.targetSymbol && callResolutionResults.targetSymbol.getName() !== "") { - symbol = callResolutionResults.targetSymbol; - } - foundAST = callExpression; - } - } - } - - if (funcDecl) { - if (symbol && symbol.getKind() !== 4096 /* Property */) { - var signatureInfo = TypeScript.PullHelpers.getSignatureForFuncDecl(funcDecl, this.semanticInfoChain.getUnit(scriptName)); - candidateSignature = signatureInfo.signature; - callSignatures = signatureInfo.allSignatures; - } - } else if (!callSignatures && symbol && (symbol.getKind() === 65536 /* Method */ || symbol.getKind() === 16384 /* Function */)) { - var typeSym = symbol.getType(); - if (typeSym) { - callSignatures = typeSym.getCallSignatures(); - } - } - } - - var enclosingScopeSymbol = this.getSymbolOfDeclaration(enclosingDecl); - - return { - symbol: symbol, - ast: foundAST, - enclosingScopeSymbol: enclosingScopeSymbol, - candidateSignature: candidateSignature, - callSignatures: callSignatures, - isConstructorCall: isConstructorCall - }; - }; - - TypeScriptCompiler.prototype.extractResolutionContextFromPath = function (path, document) { - var script = document.script; - var scriptName = document.fileName; - - var semanticInfo = this.semanticInfoChain.getUnit(scriptName); - var enclosingDecl = null; - var enclosingDeclAST = null; - var inContextuallyTypedAssignment = false; - - TypeScript.globalSemanticInfoChain = this.semanticInfoChain; - if (TypeScript.globalBinder) { - TypeScript.globalBinder.semanticInfoChain = this.semanticInfoChain; - } - - var resolutionContext = new TypeScript.PullTypeResolutionContext(); - resolutionContext.resolveAggressively = true; - - if (path.count() === 0) { - return null; - } - - this.pullTypeChecker.setUnit(semanticInfo.getPath()); - - for (var i = 0, n = path.count(); i < n; i++) { - var current = path.asts[i]; - - switch (current.nodeType) { - case 12 /* FunctionDeclaration */: - if (TypeScript.hasFlag((current).getFunctionFlags(), 8192 /* IsFunctionExpression */)) { - this.pullTypeChecker.resolver.resolveAST((current), true, enclosingDecl, resolutionContext); - } - - break; - - case 17 /* VariableDeclarator */: - var assigningAST = current; - inContextuallyTypedAssignment = (assigningAST.typeExpr !== null); - - this.pullTypeChecker.resolver.resolveAST(assigningAST, false, null, resolutionContext); - var varSymbolAndDiagnostics = this.semanticInfoChain.getSymbolAndDiagnosticsForAST(assigningAST, scriptName); - var varSymbol = varSymbolAndDiagnostics && varSymbolAndDiagnostics.symbol; - - var contextualType = null; - if (varSymbol && inContextuallyTypedAssignment) { - contextualType = varSymbol.getType(); - } - - resolutionContext.pushContextualType(contextualType, false, null); - - if (assigningAST.init) { - this.pullTypeChecker.resolver.resolveAST(assigningAST.init, inContextuallyTypedAssignment, enclosingDecl, resolutionContext); - } - - break; - - case 36 /* InvocationExpression */: - case 37 /* ObjectCreationExpression */: - var isNew = current.nodeType === 37 /* ObjectCreationExpression */; - var callExpression = current; - var contextualType = null; - - if ((i + 1 < n) && callExpression.arguments === path.asts[i + 1]) { - var callResolutionResults = new TypeScript.PullAdditionalCallResolutionData(); - if (isNew) { - this.pullTypeChecker.resolver.resolveNewExpression(callExpression, inContextuallyTypedAssignment, enclosingDecl, resolutionContext, callResolutionResults); - } else { - this.pullTypeChecker.resolver.resolveCallExpression(callExpression, inContextuallyTypedAssignment, enclosingDecl, resolutionContext, callResolutionResults); - } - - if (callResolutionResults.actualParametersContextTypeSymbols) { - var argExpression = (path.asts[i + 1] && path.asts[i + 1].nodeType === 1 /* List */) ? path.asts[i + 2] : path.asts[i + 1]; - if (argExpression) { - for (var j = 0, m = callExpression.arguments.members.length; j < m; j++) { - if (callExpression.arguments.members[j] === argExpression) { - var callContextualType = callResolutionResults.actualParametersContextTypeSymbols[j]; - if (callContextualType) { - contextualType = callContextualType; - break; - } - } - } - } - } - } else { - if (isNew) { - this.pullTypeChecker.resolver.resolveNewExpression(callExpression, inContextuallyTypedAssignment, enclosingDecl, resolutionContext); - } else { - this.pullTypeChecker.resolver.resolveCallExpression(callExpression, inContextuallyTypedAssignment, enclosingDecl, resolutionContext); - } - } - - resolutionContext.pushContextualType(contextualType, false, null); - - break; - - case 21 /* ArrayLiteralExpression */: - this.pullTypeChecker.resolver.resolveAST(current, inContextuallyTypedAssignment, enclosingDecl, resolutionContext); - - var contextualType = null; - var currentContextualType = resolutionContext.getContextualType(); - if (currentContextualType && currentContextualType.isArray()) { - contextualType = currentContextualType.getElementType(); - } - - resolutionContext.pushContextualType(contextualType, false, null); - - break; - - case 22 /* ObjectLiteralExpression */: - var objectLiteralExpression = current; - var objectLiteralResolutionContext = new TypeScript.PullAdditionalObjectLiteralResolutionData(); - this.pullTypeChecker.resolver.resolveObjectLiteralExpression(objectLiteralExpression, inContextuallyTypedAssignment, enclosingDecl, resolutionContext, objectLiteralResolutionContext); - - var memeberAST = (path.asts[i + 1] && path.asts[i + 1].nodeType === 1 /* List */) ? path.asts[i + 2] : path.asts[i + 1]; - if (memeberAST) { - var contextualType = null; - var memberDecls = objectLiteralExpression.operand; - if (memberDecls && objectLiteralResolutionContext.membersContextTypeSymbols) { - for (var j = 0, m = memberDecls.members.length; j < m; j++) { - if (memberDecls.members[j] === memeberAST) { - var memberContextualType = objectLiteralResolutionContext.membersContextTypeSymbols[j]; - if (memberContextualType) { - contextualType = memberContextualType; - break; - } - } - } - } - - resolutionContext.pushContextualType(contextualType, false, null); - } - - break; - - case 38 /* AssignmentExpression */: - var assignmentExpression = current; - var contextualType = null; - - if (path.asts[i + 1] && path.asts[i + 1] === assignmentExpression.operand2) { - var leftType = this.pullTypeChecker.resolver.resolveAST(assignmentExpression.operand1, inContextuallyTypedAssignment, enclosingDecl, resolutionContext).symbol.getType(); - if (leftType) { - inContextuallyTypedAssignment = true; - contextualType = leftType; - } - } - - resolutionContext.pushContextualType(contextualType, false, null); - - break; - - case 78 /* CastExpression */: - var castExpression = current; - var contextualType = null; - - if (i + 1 < n && path.asts[i + 1] === castExpression.castTerm) { - resolutionContext.resolvingTypeReference = true; - } - - var typeSymbol = this.pullTypeChecker.resolver.resolveTypeAssertionExpression(castExpression, inContextuallyTypedAssignment, enclosingDecl, resolutionContext).symbol; - - if (typeSymbol) { - inContextuallyTypedAssignment = true; - contextualType = typeSymbol; - } - - resolutionContext.pushContextualType(contextualType, false, null); - - break; - - case 93 /* ReturnStatement */: - var returnStatement = current; - var contextualType = null; - - if (enclosingDecl && (enclosingDecl.getKind() & TypeScript.PullElementKind.SomeFunction)) { - var functionDeclaration = enclosingDeclAST; - if (functionDeclaration.returnTypeAnnotation) { - var currentResolvingTypeReference = resolutionContext.resolvingTypeReference; - resolutionContext.resolvingTypeReference = true; - var returnTypeSymbol = this.pullTypeChecker.resolver.resolveTypeReference(functionDeclaration.returnTypeAnnotation, enclosingDecl, resolutionContext).symbol; - resolutionContext.resolvingTypeReference = currentResolvingTypeReference; - if (returnTypeSymbol) { - inContextuallyTypedAssignment = true; - contextualType = returnTypeSymbol; - } - } else { - var currentContextualType = resolutionContext.getContextualType(); - if (currentContextualType && currentContextualType.isFunction()) { - var currentContextualTypeSignatureSymbol = currentContextualType.getDeclarations()[0].getSignatureSymbol(); - var currentContextualTypeReturnTypeSymbol = currentContextualTypeSignatureSymbol.getReturnType(); - if (currentContextualTypeReturnTypeSymbol) { - inContextuallyTypedAssignment = true; - contextualType = currentContextualTypeReturnTypeSymbol; - } - } - } - } - - resolutionContext.pushContextualType(contextualType, false, null); - - break; - - case 11 /* TypeRef */: - case 9 /* TypeParameter */: - resolutionContext.resolvingTypeReference = true; - break; - } - - var decl = semanticInfo.getDeclForAST(current); - if (decl && !(decl.getKind() & (1024 /* Variable */ | 2048 /* Parameter */ | 8192 /* TypeParameter */))) { - enclosingDecl = decl; - enclosingDeclAST = current; - } - } - - if (path.isNameOfInterface() || path.isInClassImplementsList() || path.isInInterfaceExtendsList()) { - resolutionContext.resolvingTypeReference = true; - } - - if (path.ast().nodeType === 20 /* Name */ && path.count() > 1) { - for (var i = path.count() - 1; i >= 0; i--) { - if (path.asts[path.top - 1].nodeType === 32 /* MemberAccessExpression */ && (path.asts[path.top - 1]).operand2 === path.asts[path.top]) { - path.pop(); - } else { - break; - } - } - } - - return { - ast: path.ast(), - enclosingDecl: enclosingDecl, - resolutionContext: resolutionContext, - inContextuallyTypedAssignment: inContextuallyTypedAssignment - }; - }; - - TypeScriptCompiler.prototype.pullGetSymbolInformationFromPath = function (path, document) { - var context = this.extractResolutionContextFromPath(path, document); - if (!context) { - return null; - } - - TypeScript.globalSemanticInfoChain = this.semanticInfoChain; - if (TypeScript.globalBinder) { - TypeScript.globalBinder.semanticInfoChain = this.semanticInfoChain; - } - - var symbolAndDiagnostics = this.pullTypeChecker.resolver.resolveAST(path.ast(), context.inContextuallyTypedAssignment, context.enclosingDecl, context.resolutionContext); - var symbol = symbolAndDiagnostics && symbolAndDiagnostics.symbol; - - return { - symbol: symbol, - ast: path.ast(), - enclosingScopeSymbol: this.getSymbolOfDeclaration(context.enclosingDecl) - }; - }; - - TypeScriptCompiler.prototype.pullGetDeclarationSymbolInformation = function (path, document) { - var script = document.script; - var scriptName = document.fileName; - - var ast = path.ast(); - - if (ast.nodeType !== 13 /* ClassDeclaration */ && ast.nodeType !== 14 /* InterfaceDeclaration */ && ast.nodeType !== 15 /* ModuleDeclaration */ && ast.nodeType !== 12 /* FunctionDeclaration */ && ast.nodeType !== 17 /* VariableDeclarator */) { - return null; - } - - var context = this.extractResolutionContextFromPath(path, document); - if (!context) { - return null; - } - - TypeScript.globalSemanticInfoChain = this.semanticInfoChain; - if (TypeScript.globalBinder) { - TypeScript.globalBinder.semanticInfoChain = this.semanticInfoChain; - } - - var semanticInfo = this.semanticInfoChain.getUnit(scriptName); - var decl = semanticInfo.getDeclForAST(ast); - var symbol = (decl.getKind() & TypeScript.PullElementKind.SomeSignature) ? decl.getSignatureSymbol() : decl.getSymbol(); - this.pullTypeChecker.resolver.resolveDeclaredSymbol(symbol, null, context.resolutionContext); - - symbol.setUnresolved(); - - return { - symbol: symbol, - ast: path.ast(), - enclosingScopeSymbol: this.getSymbolOfDeclaration(context.enclosingDecl) - }; - }; - - TypeScriptCompiler.prototype.pullGetCallInformationFromPath = function (path, document) { - if (path.ast().nodeType !== 36 /* InvocationExpression */ && path.ast().nodeType !== 37 /* ObjectCreationExpression */) { - return null; - } - - var isNew = (path.ast().nodeType === 37 /* ObjectCreationExpression */); - - var context = this.extractResolutionContextFromPath(path, document); - if (!context) { - return null; - } - - TypeScript.globalSemanticInfoChain = this.semanticInfoChain; - if (TypeScript.globalBinder) { - TypeScript.globalBinder.semanticInfoChain = this.semanticInfoChain; - } - - var callResolutionResults = new TypeScript.PullAdditionalCallResolutionData(); - - if (isNew) { - this.pullTypeChecker.resolver.resolveNewExpression(path.ast(), context.inContextuallyTypedAssignment, context.enclosingDecl, context.resolutionContext, callResolutionResults); - } else { - this.pullTypeChecker.resolver.resolveCallExpression(path.ast(), context.inContextuallyTypedAssignment, context.enclosingDecl, context.resolutionContext, callResolutionResults); - } - - return { - targetSymbol: callResolutionResults.targetSymbol, - resolvedSignatures: callResolutionResults.resolvedSignatures, - candidateSignature: callResolutionResults.candidateSignature, - ast: path.ast(), - enclosingScopeSymbol: this.getSymbolOfDeclaration(context.enclosingDecl), - isConstructorCall: isNew - }; - }; - - TypeScriptCompiler.prototype.pullGetVisibleMemberSymbolsFromPath = function (path, document) { - TypeScript.globalSemanticInfoChain = this.semanticInfoChain; - if (TypeScript.globalBinder) { - TypeScript.globalBinder.semanticInfoChain = this.semanticInfoChain; - } - - var context = this.extractResolutionContextFromPath(path, document); - if (!context) { - return null; - } - - var symbols = this.pullTypeChecker.resolver.getVisibleMembersFromExpression(path.ast(), context.enclosingDecl, context.resolutionContext); - if (!symbols) { - return null; - } - - return { - symbols: symbols, - enclosingScopeSymbol: this.getSymbolOfDeclaration(context.enclosingDecl) - }; - }; - - TypeScriptCompiler.prototype.pullGetVisibleDeclsFromPath = function (path, document) { - TypeScript.globalSemanticInfoChain = this.semanticInfoChain; - if (TypeScript.globalBinder) { - TypeScript.globalBinder.semanticInfoChain = this.semanticInfoChain; - } - - var context = this.extractResolutionContextFromPath(path, document); - if (!context) { - return null; - } - - var symbols = null; - - return this.pullTypeChecker.resolver.getVisibleDecls(context.enclosingDecl, context.resolutionContext); - }; - - TypeScriptCompiler.prototype.pullGetContextualMembersFromPath = function (path, document) { - TypeScript.globalSemanticInfoChain = this.semanticInfoChain; - if (TypeScript.globalBinder) { - TypeScript.globalBinder.semanticInfoChain = this.semanticInfoChain; - } - - if (path.ast().nodeType !== 22 /* ObjectLiteralExpression */) { - return null; - } - - var context = this.extractResolutionContextFromPath(path, document); - if (!context) { - return null; - } - - var members = this.pullTypeChecker.resolver.getVisibleContextSymbols(context.enclosingDecl, context.resolutionContext); - - return { - symbols: members, - enclosingScopeSymbol: this.getSymbolOfDeclaration(context.enclosingDecl) - }; - }; - - TypeScriptCompiler.prototype.pullGetDeclInformation = function (decl, path, document) { - var context = this.extractResolutionContextFromPath(path, document); - if (!context) { - return null; - } - - TypeScript.globalSemanticInfoChain = this.semanticInfoChain; - if (TypeScript.globalBinder) { - TypeScript.globalBinder.semanticInfoChain = this.semanticInfoChain; - } - - var symbol = decl.getSymbol(); - this.pullTypeChecker.resolver.resolveDeclaredSymbol(symbol, context.enclosingDecl, context.resolutionContext); - symbol.setUnresolved(); - - return { - symbol: symbol, - ast: path.ast(), - enclosingScopeSymbol: this.getSymbolOfDeclaration(context.enclosingDecl) - }; - }; - - TypeScriptCompiler.prototype.pullGetTypeInfoAtPosition = function (pos, document) { - var _this = this; - return this.timeFunction("pullGetTypeInfoAtPosition for pos " + pos + ":", function () { - return _this.resolvePosition(pos, document); - }); - }; - - TypeScriptCompiler.prototype.getTopLevelDeclarations = function (scriptName) { - var unit = this.semanticInfoChain.getUnit(scriptName); - - if (!unit) { - return null; - } - - return unit.getTopLevelDecls(); - }; - - TypeScriptCompiler.prototype.reportDiagnostics = function (errors, errorReporter) { - for (var i = 0; i < errors.length; i++) { - errorReporter.addDiagnostic(errors[i]); - } - }; - return TypeScriptCompiler; - })(); - TypeScript.TypeScriptCompiler = TypeScriptCompiler; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (CompilerDiagnostics) { - CompilerDiagnostics.debug = false; - - CompilerDiagnostics.diagnosticWriter = null; - - CompilerDiagnostics.analysisPass = 0; - - function Alert(output) { - if (CompilerDiagnostics.diagnosticWriter) { - CompilerDiagnostics.diagnosticWriter.Alert(output); - } - } - CompilerDiagnostics.Alert = Alert; - - function debugPrint(s) { - if (CompilerDiagnostics.debug) { - Alert(s); - } - } - CompilerDiagnostics.debugPrint = debugPrint; - - function assert(condition, s) { - if (CompilerDiagnostics.debug) { - if (!condition) { - Alert(s); - } - } - } - CompilerDiagnostics.assert = assert; - })(TypeScript.CompilerDiagnostics || (TypeScript.CompilerDiagnostics = {})); - var CompilerDiagnostics = TypeScript.CompilerDiagnostics; - - var NullLogger = (function () { - function NullLogger() { - } - NullLogger.prototype.information = function () { - return false; - }; - NullLogger.prototype.debug = function () { - return false; - }; - NullLogger.prototype.warning = function () { - return false; - }; - NullLogger.prototype.error = function () { - return false; - }; - NullLogger.prototype.fatal = function () { - return false; - }; - NullLogger.prototype.log = function (s) { - }; - return NullLogger; - })(); - TypeScript.NullLogger = NullLogger; - - function timeFunction(logger, funcDescription, func) { - var start = (new Date()).getTime(); - var result = func(); - var end = (new Date()).getTime(); - logger.log(funcDescription + " completed in " + (end - start) + " msec"); - return result; - } - TypeScript.timeFunction = timeFunction; -})(TypeScript || (TypeScript = {})); +/*! ***************************************************************************** +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 + +THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED +WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, +MERCHANTABLITY OR NON-INFRINGEMENT. + +See the Apache Version 2.0 License for specific language governing permissions +and limitations under the License. +***************************************************************************** */ + +var TypeScript; +(function (TypeScript) { + TypeScript.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}.", + Missing_close_quote_character: "Missing close quote character.", + 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_separator_not_allowed: "Trailing separator not allowed.", + AsteriskSlash_expected: "'*/' expected.", + 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.", + Rest_parameter_must_be_last_in_list: "Rest parameter must be last in list.", + Parameter_cannot_have_question_mark_and_initializer: "Parameter cannot have question mark and initializer.", + Required_parameter_cannot_follow_optional_parameter: "Required parameter cannot follow optional parameter.", + Index_signatures_cannot_have_rest_parameters: "Index signatures cannot have rest parameters.", + Index_signature_parameter_cannot_have_accessibility_modifiers: "Index signature parameter cannot have accessibility 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.", + Implementations_are_not_allowed_in_ambient_contexts: "Implementations are not allowed in ambient contexts.", + declare_modifier_not_allowed_for_code_already_in_an_ambient_context: "'declare' modifier not allowed for code already in an ambient context.", + Initializers_are_not_allowed_in_ambient_contexts: "Initializers are not allowed in ambient contexts.", + Parameter_property_declarations_can_only_be_used_in_constructors: "Parameter property declarations can only be used in constructors.", + Function_implementation_expected: "Function implementation expected.", + Constructor_implementation_expected: "Constructor implementation expected.", + Function_overload_name_must_be_0: "Function overload name must be '{0}'.", + _0_modifier_cannot_appear_on_a_module_element: "'{0}' modifier cannot appear on a module element.", + declare_modifier_cannot_appear_on_an_interface_declaration: "'declare' modifier cannot appear on an interface declaration.", + declare_modifier_required_for_top_level_element: "'declare' modifier required for top level element.", + Rest_parameter_cannot_be_optional: "Rest parameter cannot be optional.", + Rest_parameter_cannot_have_an_initializer: "Rest parameter cannot have an initializer.", + set_accessor_must_have_one_and_only_one_parameter: "'set' accessor must have one and only one parameter.", + set_accessor_parameter_cannot_have_accessibility_modifier: "'set' accessor parameter cannot have accessibility modifier.", + 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.", + 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}'.", + Module_name_cannot_be_0: "Module name cannot be '{0}'.", + 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.", + Export_assignment_not_allowed_in_module_with_exported_element: "Export assignment not allowed in module with exported element.", + Module_cannot_have_multiple_export_assignments: "Module cannot have multiple export assignments.", + 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", + declare_modifier_not_allowed_on_import_declaration: "'declare' modifier not allowed on import declaration.", + Function_overload_must_be_static: "Function overload must be static", + Function_overload_must_not_be_static: "Function overload must not be static", + Parameter_property_declarations_cannot_be_used_in_an_ambient_context: "Parameter property declarations cannot be used in an ambient context.", + Parameter_property_declarations_cannot_be_used_in_a_constructor_overload: "Parameter property declarations cannot be used in a constructor overload.", + 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.", + Value_of_type_0_is_not_indexable_by_type_1: "Value of type '{0}' is not indexable by type '{1}'.", + Operator_0_cannot_be_applied_to_types_1_and_2: "Operator '{0}' cannot be applied to types '{1}' and '{2}'.", + Operator_0_cannot_be_applied_to_types_1_and_2_3: "Operator '{0}' cannot be applied to types '{1}' and '{2}': {3}", + Cannot_convert_0_to_1: "Cannot convert '{0}' to '{1}'.", + Cannot_convert_0_to_1_NL_2: "Cannot convert '{0}' to '{1}':{NL}{2}", + Expected_var_class_interface_or_module: "Expected var, class, interface, or module.", + Operator_0_cannot_be_applied_to_type_1: "Operator '{0}' cannot be applied to type '{1}'.", + Getter_0_already_declared: "Getter '{0}' already declared.", + Setter_0_already_declared: "Setter '{0}' already declared.", + Accessors_cannot_have_type_parameters: "Accessors cannot have type parameters.", + 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()' 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.", + Unable_to_resolve_external_module_0: "Unable to resolve 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_another_class_or_interface: "An interface may only extend another class or interface.", + An_interface_cannot_implement_another_type: "An interface cannot implement another type.", + 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}", + Invalid_new_expression: "Invalid 'new' expression.", + Call_signatures_used_in_a_new_expression_must_have_a_void_return_type: "Call signatures used in a 'new' expression must have a 'void' return type.", + Could_not_select_overload_for_new_expression: "Could not select overload for 'new' expression.", + Type_0_does_not_satisfy_the_constraint_1_for_type_parameter_2: "Type '{0}' does not satisfy the constraint '{1}' for type parameter '{2}'.", + 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_conditional_expression_cannot_be_determined_Best_common_type_could_not_be_found_between_0_and_1: "Type of conditional expression cannot be determined. Best common type could not be found between '{0}' and '{1}'.", + 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}'.", + The_property_0_does_not_exist_on_value_of_type_1: "The property '{0}' does not exist on value of type '{1}'.", + Could_not_find_symbol_0: "Could not find symbol '{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_methods_cannot_reference_class_type_parameters: "Static methods cannot reference class type parameters.", + Class_0_is_recursively_referenced_as_a_base_type_of_itself: "Class '{0}' is recursively referenced as a base type of itself.", + Interface_0_is_recursively_referenced_as_a_base_type_of_itself: "Interface '{0}' is recursively referenced as a base type of itself.", + super_property_access_is_permitted_only_in_a_constructor_instance_member_function_or_instance_member_accessor_of_a_derived_class: "'super' property access is permitted only in a constructor, instance member function, or instance member accessor of a derived class.", + super_cannot_be_referenced_in_non_derived_classes: "'super' cannot be referenced in non-derived classes.", + 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_local_functions_inside_constructors: "Super calls are not permitted outside constructors or in local functions inside constructors.", + _0_1_is_inaccessible: "'{0}.{1}' is inaccessible.", + this_cannot_be_referenced_within_module_bodies: "'this' cannot be referenced within module bodies.", + 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.", + The_type_of_a_unary_arithmetic_operation_operand_must_be_of_type_any_number_or_an_enum_type: "The type of a unary arithmetic operation 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_string_or_any: "The left-hand side of an 'in' expression must be of types 'string' or 'any'.", + 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_a_subtype_of_the_Function_interface_type: "The right-hand side of an 'instanceof' expression must be of type 'any' or a subtype of 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}'.", + Function_0_declared_a_non_void_return_type_but_has_no_return_expression: "Function '{0}' declared a non-void return type, but has no return expression.", + 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_static_initializers_in_a_class_body: "'this' cannot be referenced in static initializers in a class body.", + 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}", + Duplicate_overload_signature_for_0: "Duplicate overload signature for '{0}'.", + Duplicate_constructor_overload_signature: "Duplicate constructor overload signature.", + Duplicate_overload_call_signature: "Duplicate overload call signature.", + Duplicate_overload_construct_signature: "Duplicate overload construct signature.", + 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_local: "Overload signatures must all be exported or local.", + 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_subtype_of_any_non_specialized_signature: "Specialized overload signature is not subtype of any non-specialized signature.", + this_cannot_be_referenced_in_constructor_arguments: "'this' cannot be referenced in constructor arguments.", + Static_member_cannot_be_accessed_off_an_instance_variable: "Static member cannot be accessed off an instance variable.", + 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.", + Rest_parameters_must_be_array_types: "Rest parameters must be array types.", + 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_instance_methods_of_the_base_class_are_accessible_via_the_super_keyword: "Only public instance methods of the base class are accessible via the 'super' keyword.", + Numeric_indexer_type_0_must_be_a_subtype_of_string_indexer_type_1: "Numeric indexer type '{0}' must be a subtype of string indexer type '{1}'.", + Numeric_indexer_type_0_must_be_a_subtype_of_string_indexer_type_1_NL_2: "Numeric indexer type '{0}' must be a subtype of string indexer type '{1}':{NL}{2}", + All_numerically_named_properties_must_be_subtypes_of_numeric_indexer_type_0: "All numerically named properties must be subtypes of numeric indexer type '{0}'.", + All_numerically_named_properties_must_be_subtypes_of_numeric_indexer_type_0_NL_1: "All numerically named properties must be subtypes of numeric indexer type '{0}':{NL}{1}", + All_named_properties_must_be_subtypes_of_string_indexer_type_0: "All named properties must be subtypes of string indexer type '{0}'.", + All_named_properties_must_be_subtypes_of_string_indexer_type_0_NL_1: "All named properties must be subtypes of string indexer type '{0}':{NL}{1}", + Generic_type_references_must_include_all_type_arguments: "Generic type references must include all type arguments.", + Default_arguments_are_not_allowed_in_an_overload_parameter: "Default arguments are not allowed in an overload parameter.", + Overloads_cannot_differ_only_by_return_type: "Overloads cannot differ only by return type.", + 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.", + Could_not_find_symbol_0_in_module_1: "Could not find symbol '{0}' in module '{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_reference_0_in_extends_clause_doesn_t_reference_constructor_function_for_1: "Type reference '{0}' in extends clause doesn't reference constructor function for '{1}'.", + Internal_module_reference_0_in_import_declaration_doesn_t_reference_module_instance_for_1: "Internal module reference '{0}' in import declaration doesn't reference module instance for '{1}'.", + 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.", + Enums_with_multiple_declarations_must_provide_an_initializer_for_the_first_enum_element: "Enums with multiple declarations must provide an initializer for the first enum element.", + _0_overload_s: " (+ {0} overload(s))", + Current_host_does_not_support_0_option: "Current host does not support '{0}' option.", + ECMAScript_target_version_0_not_supported_Using_default_1_code_generation: "ECMAScript target version '{0}' not supported. Using default '{1}' code generation.", + Module_code_generation_0_not_supported: "Module code generation '{0}' not supported.", + 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 or -. For example '{0}' or '{1}'.", + Unsupported_locale_0: "Unsupported locale: '{0}'.", + Execution_Failed_NL: "Execution Failed.{NL}", + Should_not_emit_a_type_query: "Should not emit a type query", + Should_not_emit_a_type_reference: "Should not emit a type reference", + 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", + Key_was_already_in_table: "Key was already in table", + Unknown_option_0: "Unknown 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}", + Invalid_argument_0_1: "Invalid argument: {0}. {1}", + Invalid_argument_0: "Invalid argument: {0}.", + Argument_out_of_range_0: "Argument out of range: {0}.", + Argument_null_0: "Argument null: {0}.", + Operation_not_implemented_properly_by_subclass: "Operation not implemented properly by subclass.", + Not_yet_implemented: "Not yet implemented.", + Invalid_operation_0: "Invalid operation: {0}", + Invalid_operation: "Invalid operation.", + 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.", + Concatenate_and_emit_output_to_single_file: "Concatenate and emit output to single file", + Generates_corresponding_0_file: "Generates corresponding {0} 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", + Skip_resolution_and_preprocessing: "Skip resolution and preprocessing", + Specify_ECMAScript_target_version_0_default_or_1: "Specify ECMAScript target version: \"{0}\" (default), or \"{1}\"", + Specify_module_code_generation_0_or_1: "Specify module code generation: \"{0}\" or \"{1}\"", + Print_this_message: "Print this message", + Print_the_compiler_s_version_0: "Print the compiler's version: {0}", + Allow_use_of_deprecated_0_keyword_when_referencing_an_external_module: "Allow use of deprecated \"{0}\" keyword when referencing an external module", + Specify_locale_for_errors_and_messages_For_example_0_or_1: "Specify locale for errors and messages. For example '{0}' or '{1}'", + Syntax_0: "Syntax: {0}", + options: "options", + file: "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", + FILE: "FILE", + VERSION: "VERSION", + LOCATION: "LOCATION", + DIRECTORY: "DIRECTORY", + This_version_of_the_Javascript_runtime_does_not_support_the_0_function: "This version of the Javascript runtime does not support the '{0}' function.", + Looking_up_path_for_identifier_token_did_not_result_in_an_identifer: "Looking up path for identifier token did not result in an identifer.", + Unknown_rule: "Unknown rule", + Invalid_line_number_0: "Invalid line number ({0})", + Warn_on_expressions_and_declarations_with_an_implied_any_type: "Warn 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." + }; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var ArrayUtilities = (function () { + function ArrayUtilities() { + } + ArrayUtilities.isArray = function (value) { + return Object.prototype.toString.apply(value, []) === '[object Array]'; + }; + + ArrayUtilities.sequenceEquals = function (array1, array2, equals) { + if (array1 === array2) { + return true; + } + + if (array1 === null || array2 === null) { + 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; + }; + + ArrayUtilities.contains = function (array, value) { + for (var i = 0; i < array.length; i++) { + if (array[i] === value) { + return true; + } + } + + return false; + }; + + ArrayUtilities.groupBy = function (array, func) { + var result = {}; + + for (var i = 0, n = array.length; i < n; i++) { + var v = array[i]; + var k = func(v); + + var list = result[k] || []; + list.push(v); + result[k] = list; + } + + return result; + }; + + ArrayUtilities.min = function (array, func) { + var min = func(array[0]); + + for (var i = 1; i < array.length; i++) { + var next = func(array[i]); + if (next < min) { + min = next; + } + } + + return min; + }; + + ArrayUtilities.max = function (array, func) { + var max = func(array[0]); + + for (var i = 1; i < array.length; i++) { + var next = func(array[i]); + if (next > max) { + max = next; + } + } + + return max; + }; + + ArrayUtilities.last = function (array) { + if (array.length === 0) { + throw TypeScript.Errors.argumentOutOfRange('array'); + } + + return array[array.length - 1]; + }; + + ArrayUtilities.firstOrDefault = function (array, func) { + for (var i = 0, n = array.length; i < n; i++) { + var value = array[i]; + if (func(value)) { + return value; + } + } + + return null; + }; + + ArrayUtilities.sum = function (array, func) { + var result = 0; + + for (var i = 0, n = array.length; i < n; i++) { + result += func(array[i]); + } + + return result; + }; + + ArrayUtilities.whereNotNull = function (array) { + var result = []; + for (var i = 0; i < array.length; i++) { + var value = array[i]; + if (value !== null) { + result.push(value); + } + } + + return result; + }; + + ArrayUtilities.select = function (values, func) { + var result = new Array(values.length); + + for (var i = 0; i < values.length; i++) { + result[i] = func(values[i]); + } + + return result; + }; + + ArrayUtilities.where = function (values, func) { + var result = new Array(); + + for (var i = 0; i < values.length; i++) { + if (func(values[i])) { + result.push(values[i]); + } + } + + return result; + }; + + ArrayUtilities.any = function (array, func) { + for (var i = 0, n = array.length; i < n; i++) { + if (func(array[i])) { + return true; + } + } + + return false; + }; + + ArrayUtilities.all = function (array, func) { + for (var i = 0, n = array.length; i < n; i++) { + if (!func(array[i])) { + return false; + } + } + + return true; + }; + + ArrayUtilities.binarySearch = function (array, value) { + 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; + }; + + ArrayUtilities.createArray = function (length, defaultValue) { + var result = new Array(length); + for (var i = 0; i < length; i++) { + result[i] = defaultValue; + } + + return result; + }; + + ArrayUtilities.grow = function (array, length, defaultValue) { + var count = length - array.length; + for (var i = 0; i < count; i++) { + array.push(defaultValue); + } + }; + + ArrayUtilities.copy = function (sourceArray, sourceIndex, destinationArray, destinationIndex, length) { + for (var i = 0; i < length; i++) { + destinationArray[destinationIndex + i] = sourceArray[sourceIndex + i]; + } + }; + return ArrayUtilities; + })(); + TypeScript.ArrayUtilities = ArrayUtilities; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (Constants) { + Constants[Constants["Max31BitInteger"] = 1073741823] = "Max31BitInteger"; + Constants[Constants["Min31BitInteger"] = -1073741824] = "Min31BitInteger"; + })(TypeScript.Constants || (TypeScript.Constants = {})); + var Constants = TypeScript.Constants; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var Debug = (function () { + function Debug() { + } + Debug.assert = function (expression, message) { + if (!expression) { + throw new Error("Debug Failure. False expression: " + (message ? message : "")); + } + }; + return Debug; + })(); + TypeScript.Debug = Debug; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var Errors = (function () { + function Errors() { + } + Errors.argument = function (argument, message) { + return new Error(message ? TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Invalid_argument_0_1, [argument, message]) : TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Invalid_argument_0, [argument])); + }; + + Errors.argumentOutOfRange = function (argument) { + return new Error(TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Argument_out_of_range_0, [argument])); + }; + + Errors.argumentNull = function (argument) { + return new Error(TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Argument_null_0, [argument])); + }; + + Errors.abstract = function () { + return new Error(TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Operation_not_implemented_properly_by_subclass, null)); + }; + + Errors.notYetImplemented = function () { + return new Error(TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Not_yet_implemented, null)); + }; + + Errors.invalidOperation = function (message) { + return new Error(message ? TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Invalid_operation_0, [message]) : TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Invalid_operation, null)); + }; + return Errors; + })(); + TypeScript.Errors = Errors; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var Hash = (function () { + function Hash() { + } + Hash.computeFnv1aCharArrayHashCode = function (text, start, len) { + var hashCode = Hash.FNV_BASE; + var end = start + len; + + for (var i = start; i < end; i++) { + hashCode = TypeScript.IntegerUtilities.integerMultiplyLow32Bits(hashCode ^ text[i], Hash.FNV_PRIME); + } + + return hashCode; + }; + + Hash.computeSimple31BitCharArrayHashCode = function (key, start, len) { + var hash = 0; + + for (var i = 0; i < len; i++) { + var ch = key[start + i]; + + hash = ((((hash << 5) - hash) | 0) + ch) | 0; + } + + return hash & 0x7FFFFFFF; + }; + + Hash.computeSimple31BitStringHashCode = function (key) { + var hash = 0; + + var start = 0; + var len = key.length; + + for (var i = 0; i < len; i++) { + var ch = key.charCodeAt(start + i); + + hash = ((((hash << 5) - hash) | 0) + ch) | 0; + } + + return hash & 0x7FFFFFFF; + }; + + Hash.computeMurmur2StringHashCode = function (key, seed) { + var m = 0x5bd1e995; + var r = 24; + + var numberOfCharsLeft = key.length; + var h = Math.abs(seed ^ numberOfCharsLeft); + + var index = 0; + while (numberOfCharsLeft >= 2) { + var c1 = key.charCodeAt(index); + var c2 = key.charCodeAt(index + 1); + + var k = Math.abs(c1 | (c2 << 16)); + + k = TypeScript.IntegerUtilities.integerMultiplyLow32Bits(k, m); + k ^= k >> r; + k = TypeScript.IntegerUtilities.integerMultiplyLow32Bits(k, m); + + h = TypeScript.IntegerUtilities.integerMultiplyLow32Bits(h, m); + h ^= k; + + index += 2; + numberOfCharsLeft -= 2; + } + + if (numberOfCharsLeft == 1) { + h ^= key.charCodeAt(index); + h = TypeScript.IntegerUtilities.integerMultiplyLow32Bits(h, m); + } + + h ^= h >> 13; + h = TypeScript.IntegerUtilities.integerMultiplyLow32Bits(h, m); + h ^= h >> 15; + + return h; + }; + + Hash.getPrime = function (min) { + for (var i = 0; i < Hash.primes.length; i++) { + var num = Hash.primes[i]; + if (num >= min) { + return num; + } + } + + throw TypeScript.Errors.notYetImplemented(); + }; + + Hash.expandPrime = function (oldSize) { + var num = oldSize << 1; + if (num > 2146435069 && 2146435069 > oldSize) { + return 2146435069; + } + return Hash.getPrime(num); + }; + + Hash.combine = function (value, currentHash) { + return (((currentHash << 5) + currentHash) + value) & 0x7FFFFFFF; + }; + Hash.FNV_BASE = 2166136261; + Hash.FNV_PRIME = 16777619; + + Hash.primes = [ + 3, + 7, + 11, + 17, + 23, + 29, + 37, + 47, + 59, + 71, + 89, + 107, + 131, + 163, + 197, + 239, + 293, + 353, + 431, + 521, + 631, + 761, + 919, + 1103, + 1327, + 1597, + 1931, + 2333, + 2801, + 3371, + 4049, + 4861, + 5839, + 7013, + 8419, + 10103, + 12143, + 14591, + 17519, + 21023, + 25229, + 30293, + 36353, + 43627, + 52361, + 62851, + 75431, + 90523, + 108631, + 130363, + 156437, + 187751, + 225307, + 270371, + 324449, + 389357, + 467237, + 560689, + 672827, + 807403, + 968897, + 1162687, + 1395263, + 1674319, + 2009191, + 2411033, + 2893249, + 3471899, + 4166287, + 4999559, + 5999471, + 7199369 + ]; + return Hash; + })(); + TypeScript.Hash = Hash; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (Collections) { + Collections.DefaultHashTableCapacity = 1024; + + var HashTableEntry = (function () { + function HashTableEntry(Key, Value, HashCode, Next) { + this.Key = Key; + this.Value = Value; + this.HashCode = HashCode; + this.Next = Next; + } + return HashTableEntry; + })(); + + var HashTable = (function () { + function HashTable(capacity, hash) { + this.hash = hash; + this.count = 0; + var size = TypeScript.Hash.getPrime(capacity); + this.entries = TypeScript.ArrayUtilities.createArray(size, null); + } + HashTable.prototype.set = function (key, value) { + this.addOrSet(key, value, false); + }; + + HashTable.prototype.add = function (key, value) { + this.addOrSet(key, value, true); + }; + + HashTable.prototype.containsKey = function (key) { + var hashCode = this.computeHashCode(key); + var entry = this.findEntry(key, hashCode); + return entry !== null; + }; + + HashTable.prototype.get = function (key) { + var hashCode = this.computeHashCode(key); + var entry = this.findEntry(key, hashCode); + + return entry === null ? null : entry.Value; + }; + + HashTable.prototype.computeHashCode = function (key) { + var hashCode = this.hash === null ? (key).hashCode : this.hash(key); + + hashCode = hashCode & 0x7FFFFFFF; + TypeScript.Debug.assert(hashCode >= 0); + + return hashCode; + }; + + HashTable.prototype.addOrSet = function (key, value, throwOnExistingEntry) { + var hashCode = this.computeHashCode(key); + + var entry = this.findEntry(key, hashCode); + if (entry !== null) { + if (throwOnExistingEntry) { + throw TypeScript.Errors.argument('key', TypeScript.getLocalizedText(TypeScript.DiagnosticCode.Key_was_already_in_table, null)); + } + + entry.Key = key; + entry.Value = value; + return; + } + + return this.addEntry(key, value, hashCode); + }; + + HashTable.prototype.findEntry = function (key, hashCode) { + for (var e = this.entries[hashCode % this.entries.length]; e !== null; e = e.Next) { + if (e.HashCode === hashCode && key === e.Key) { + return e; + } + } + + return null; + }; + + HashTable.prototype.addEntry = function (key, value, hashCode) { + var index = hashCode % this.entries.length; + + var e = new HashTableEntry(key, value, hashCode, this.entries[index]); + + this.entries[index] = e; + + if (this.count >= (this.entries.length / 2)) { + this.grow(); + } + + this.count++; + return e.Key; + }; + + HashTable.prototype.grow = function () { + var newSize = TypeScript.Hash.expandPrime(this.entries.length); + + var oldEntries = this.entries; + var newEntries = TypeScript.ArrayUtilities.createArray(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; + } + } + }; + return HashTable; + })(); + Collections.HashTable = HashTable; + + function createHashTable(capacity, hash) { + if (typeof capacity === "undefined") { capacity = Collections.DefaultHashTableCapacity; } + if (typeof hash === "undefined") { hash = null; } + return new HashTable(capacity, hash); + } + Collections.createHashTable = createHashTable; + + var currentHashCode = 1; + function identityHashCode(value) { + if (value.__hash === undefined) { + value.__hash = currentHashCode; + currentHashCode++; + } + + return value.__hash; + } + Collections.identityHashCode = identityHashCode; + })(TypeScript.Collections || (TypeScript.Collections = {})); + var Collections = TypeScript.Collections; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + TypeScript.LocalizedDiagnosticMessages = null; + + function newLine() { + return Environment ? Environment.newLine : "\r\n"; + } + TypeScript.newLine = newLine; + + var Diagnostic = (function () { + function Diagnostic(fileName, start, length, diagnosticKey, arguments) { + if (typeof arguments === "undefined") { arguments = null; } + this._diagnosticKey = diagnosticKey; + this._arguments = (arguments && arguments.length > 0) ? arguments : null; + this._fileName = fileName; + this._start = start; + this._length = length; + } + Diagnostic.prototype.toJSON = function (key) { + var result = {}; + result.start = this.start(); + result.length = this.length(); + + result.diagnosticCode = this._diagnosticKey; + + var arguments = (this).arguments(); + if (arguments && arguments.length > 0) { + result.arguments = arguments; + } + + return result; + }; + + Diagnostic.prototype.fileName = function () { + return this._fileName; + }; + + Diagnostic.prototype.start = function () { + return this._start; + }; + + Diagnostic.prototype.length = function () { + return this._length; + }; + + Diagnostic.prototype.diagnosticKey = function () { + return this._diagnosticKey; + }; + + Diagnostic.prototype.arguments = function () { + return this._arguments; + }; + + Diagnostic.prototype.text = function () { + return TypeScript.getLocalizedText(this._diagnosticKey, this._arguments); + }; + + Diagnostic.prototype.message = function () { + return TypeScript.getDiagnosticMessage(this._diagnosticKey, this._arguments); + }; + + Diagnostic.prototype.additionalLocations = function () { + return []; + }; + + Diagnostic.equals = function (diagnostic1, diagnostic2) { + return diagnostic1._fileName === diagnostic2._fileName && diagnostic1._start === diagnostic2._start && diagnostic1._length === diagnostic2._length && diagnostic1._diagnosticKey === diagnostic2._diagnosticKey && TypeScript.ArrayUtilities.sequenceEquals(diagnostic1._arguments, diagnostic2._arguments, function (v1, v2) { + return v1 === v2; + }); + }; + return Diagnostic; + })(); + TypeScript.Diagnostic = Diagnostic; + + function getLargestIndex(diagnostic) { + var largest = -1; + var regex = /\{(\d+)\}/g; + + var match; + while ((match = regex.exec(diagnostic)) != null) { + var val = parseInt(match[1]); + if (!isNaN(val) && val > largest) { + largest = val; + } + } + + return largest; + } + + function getDiagnosticInfoFromKey(diagnosticKey) { + var result = TypeScript.diagnosticInformationMap[diagnosticKey]; + TypeScript.Debug.assert(result !== undefined && result !== null); + return result; + } + TypeScript.getDiagnosticInfoFromKey = getDiagnosticInfoFromKey; + + function getLocalizedText(diagnosticKey, args) { + if (TypeScript.LocalizedDiagnosticMessages) { + TypeScript.Debug.assert(TypeScript.LocalizedDiagnosticMessages.hasOwnProperty(diagnosticKey)); + } + + var diagnosticMessageText = TypeScript.LocalizedDiagnosticMessages ? TypeScript.LocalizedDiagnosticMessages[diagnosticKey] : diagnosticKey; + TypeScript.Debug.assert(diagnosticMessageText !== undefined && diagnosticMessageText !== null); + + var actualCount = args ? args.length : 0; + + var expectedCount = 1 + getLargestIndex(diagnosticKey); + + if (expectedCount !== actualCount) { + throw new Error(getLocalizedText(TypeScript.DiagnosticCode.Expected_0_arguments_to_message_got_1_instead, [expectedCount, actualCount])); + } + + var valueCount = 1 + getLargestIndex(diagnosticMessageText); + if (valueCount !== expectedCount) { + throw new Error(getLocalizedText(TypeScript.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; + } + TypeScript.getLocalizedText = getLocalizedText; + + function getDiagnosticMessage(diagnosticKey, args) { + var diagnostic = getDiagnosticInfoFromKey(diagnosticKey); + var diagnosticMessageText = getLocalizedText(diagnosticKey, args); + + var message; + if (diagnostic.category === 1 /* Error */) { + message = getLocalizedText(TypeScript.DiagnosticCode.error_TS_0_1, [diagnostic.code, diagnosticMessageText]); + } else if (diagnostic.category === 0 /* Warning */) { + message = getLocalizedText(TypeScript.DiagnosticCode.warning_TS_0_1, [diagnostic.code, diagnosticMessageText]); + } else { + message = diagnosticMessageText; + } + + return message; + } + TypeScript.getDiagnosticMessage = getDiagnosticMessage; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + TypeScript.nodeMakeDirectoryTime = 0; + TypeScript.nodeCreateBufferTime = 0; + TypeScript.nodeWriteFileSyncTime = 0; +})(TypeScript || (TypeScript = {})); + +var ByteOrderMark; +(function (ByteOrderMark) { + ByteOrderMark[ByteOrderMark["None"] = 0] = "None"; + ByteOrderMark[ByteOrderMark["Utf8"] = 1] = "Utf8"; + ByteOrderMark[ByteOrderMark["Utf16BigEndian"] = 2] = "Utf16BigEndian"; + ByteOrderMark[ByteOrderMark["Utf16LittleEndian"] = 3] = "Utf16LittleEndian"; +})(ByteOrderMark || (ByteOrderMark = {})); + +var FileInformation = (function () { + function FileInformation(contents, byteOrderMark) { + this.contents = contents; + this.byteOrderMark = byteOrderMark; + } + return FileInformation; +})(); + +var Environment = (function () { + function getWindowsScriptHostEnvironment() { + try { + var fso = new ActiveXObject("Scripting.FileSystemObject"); + } catch (e) { + return null; + } + + var streamObjectPool = []; + + function getStreamObject() { + if (streamObjectPool.length > 0) { + return streamObjectPool.pop(); + } else { + return new ActiveXObject("ADODB.Stream"); + } + } + + function releaseStreamObject(obj) { + streamObjectPool.push(obj); + } + + var args = []; + for (var i = 0; i < WScript.Arguments.length; i++) { + args[i] = WScript.Arguments.Item(i); + } + + return { + newLine: "\r\n", + currentDirectory: function () { + return (WScript).CreateObject("WScript.Shell").CurrentDirectory; + }, + readFile: function (path) { + try { + var streamObj = getStreamObject(); + streamObj.Open(); + streamObj.Type = 2; + + streamObj.Charset = 'x-ansi'; + + streamObj.LoadFromFile(path); + var bomChar = streamObj.ReadText(2); + + streamObj.Position = 0; + + var byteOrderMark = 0 /* None */; + + if (bomChar.charCodeAt(0) === 0xFE && bomChar.charCodeAt(1) === 0xFF) { + streamObj.Charset = 'unicode'; + byteOrderMark = 2 /* Utf16BigEndian */; + } else if (bomChar.charCodeAt(0) === 0xFF && bomChar.charCodeAt(1) === 0xFE) { + streamObj.Charset = 'unicode'; + byteOrderMark = 3 /* Utf16LittleEndian */; + } else if (bomChar.charCodeAt(0) === 0xEF && bomChar.charCodeAt(1) === 0xBB) { + streamObj.Charset = 'utf-8'; + byteOrderMark = 1 /* Utf8 */; + } else { + streamObj.Charset = 'utf-8'; + } + + var contents = streamObj.ReadText(-1); + streamObj.Close(); + releaseStreamObject(streamObj); + return new FileInformation(contents, byteOrderMark); + } catch (err) { + var message; + if (err.number === -2147024809) { + message = TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Unsupported_file_encoding, null); + } else { + message = TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Cannot_read_file_0_1, [path, err.message]); + } + + throw new Error(message); + } + }, + writeFile: function (path, contents, writeByteOrderMark) { + var textStream = getStreamObject(); + textStream.Charset = 'utf-8'; + textStream.Open(); + textStream.WriteText(contents, 0); + + if (!writeByteOrderMark) { + textStream.Position = 3; + } else { + textStream.Position = 0; + } + + var fileStream = getStreamObject(); + fileStream.Type = 1; + fileStream.Open(); + + textStream.CopyTo(fileStream); + + fileStream.Flush(); + fileStream.SaveToFile(path, 2); + fileStream.Close(); + + textStream.Flush(); + textStream.Close(); + }, + fileExists: function (path) { + return fso.FileExists(path); + }, + deleteFile: function (path) { + if (fso.FileExists(path)) { + fso.DeleteFile(path, true); + } + }, + directoryExists: function (path) { + return fso.FolderExists(path); + }, + listFiles: function (path, spec, options) { + options = options || {}; + function filesInFolder(folder, root) { + var paths = []; + var fc; + + if (options.recursive) { + fc = new Enumerator(folder.subfolders); + + for (; !fc.atEnd(); fc.moveNext()) { + paths = paths.concat(filesInFolder(fc.item(), root + "\\" + fc.item().Name)); + } + } + + fc = new Enumerator(folder.files); + + for (; !fc.atEnd(); fc.moveNext()) { + if (!spec || fc.item().Name.match(spec)) { + paths.push(root + "\\" + fc.item().Name); + } + } + + return paths; + } + + var folder = fso.GetFolder(path); + var paths = []; + + return filesInFolder(folder, path); + }, + arguments: args, + standardOut: WScript.StdOut + }; + } + ; + + function getNodeEnvironment() { + var _fs = require('fs'); + var _path = require('path'); + var _module = require('module'); + var _os = require('os'); + + return { + newLine: _os.EOL, + currentDirectory: function () { + return (process).cwd(); + }, + readFile: function (file) { + var buffer = _fs.readFileSync(file); + switch (buffer[0]) { + case 0xFE: + if (buffer[1] === 0xFF) { + var i = 0; + while ((i + 1) < buffer.length) { + var temp = buffer[i]; + buffer[i] = buffer[i + 1]; + buffer[i + 1] = temp; + i += 2; + } + return new FileInformation(buffer.toString("ucs2", 2), 2 /* Utf16BigEndian */); + } + break; + case 0xFF: + if (buffer[1] === 0xFE) { + return new FileInformation(buffer.toString("ucs2", 2), 3 /* Utf16LittleEndian */); + } + break; + case 0xEF: + if (buffer[1] === 0xBB) { + return new FileInformation(buffer.toString("utf8", 3), 1 /* Utf8 */); + } + } + + return new FileInformation(buffer.toString("utf8", 0), 0 /* None */); + }, + writeFile: function (path, contents, writeByteOrderMark) { + function mkdirRecursiveSync(path) { + var stats = _fs.statSync(path); + if (stats.isFile()) { + throw "\"" + path + "\" exists but isn't a directory."; + } else if (stats.isDirectory()) { + return; + } else { + mkdirRecursiveSync(_path.dirname(path)); + _fs.mkdirSync(path, 0775); + } + } + var start = new Date().getTime(); + mkdirRecursiveSync(_path.dirname(path)); + TypeScript.nodeMakeDirectoryTime += new Date().getTime() - start; + + if (writeByteOrderMark) { + contents = '\uFEFF' + contents; + } + + var start = new Date().getTime(); + + var chunkLength = 4 * 1024; + var fileDescriptor = _fs.openSync(path, "w"); + try { + for (var index = 0; index < contents.length; index += chunkLength) { + var bufferStart = new Date().getTime(); + var buffer = new Buffer(contents.substr(index, chunkLength), "utf8"); + TypeScript.nodeCreateBufferTime += new Date().getTime() - bufferStart; + + _fs.writeSync(fileDescriptor, buffer, 0, buffer.length, null); + } + } finally { + _fs.closeSync(fileDescriptor); + } + + TypeScript.nodeWriteFileSyncTime += new Date().getTime() - start; + }, + fileExists: function (path) { + return _fs.existsSync(path); + }, + deleteFile: function (path) { + try { + _fs.unlinkSync(path); + } catch (e) { + } + }, + directoryExists: function (path) { + return _fs.existsSync(path) && _fs.statSync(path).isDirectory(); + }, + listFiles: function dir(path, spec, options) { + options = options || {}; + + function filesInFolder(folder) { + var paths = []; + + var files = _fs.readdirSync(folder); + for (var i = 0; i < files.length; i++) { + var stat = _fs.statSync(folder + "\\" + files[i]); + if (options.recursive && stat.isDirectory()) { + paths = paths.concat(filesInFolder(folder + "\\" + files[i])); + } else if (stat.isFile() && (!spec || files[i].match(spec))) { + paths.push(folder + "\\" + files[i]); + } + } + + return paths; + } + + return filesInFolder(path); + }, + arguments: process.argv.slice(2), + standardOut: { + Write: function (str) { + process.stdout.write(str); + }, + WriteLine: function (str) { + process.stdout.write(str + '\n'); + }, + Close: function () { + } + } + }; + } + ; + + if (typeof WScript !== "undefined" && typeof ActiveXObject === "function") { + return getWindowsScriptHostEnvironment(); + } else if (typeof module !== 'undefined' && module.exports) { + return getNodeEnvironment(); + } else { + return null; + } +})(); +var TypeScript; +(function (TypeScript) { + var IntegerUtilities = (function () { + function IntegerUtilities() { + } + IntegerUtilities.integerDivide = function (numerator, denominator) { + return (numerator / denominator) >> 0; + }; + + IntegerUtilities.integerMultiplyLow32Bits = function (n1, n2) { + var n1Low16 = n1 & 0x0000ffff; + var n1High16 = n1 >>> 16; + + var n2Low16 = n2 & 0x0000ffff; + var n2High16 = n2 >>> 16; + + var resultLow32 = (((n1 & 0xffff0000) * n2) >>> 0) + (((n1 & 0x0000ffff) * n2) >>> 0) >>> 0; + return resultLow32; + }; + + IntegerUtilities.integerMultiplyHigh32Bits = function (n1, n2) { + var n1Low16 = n1 & 0x0000ffff; + var n1High16 = n1 >>> 16; + + var n2Low16 = n2 & 0x0000ffff; + var n2High16 = n2 >>> 16; + + var resultHigh32 = n1High16 * n2High16 + ((((n1Low16 * n2Low16) >>> 17) + n1Low16 * n2High16) >>> 15); + return resultHigh32; + }; + return IntegerUtilities; + })(); + TypeScript.IntegerUtilities = IntegerUtilities; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var MathPrototype = (function () { + function MathPrototype() { + } + MathPrototype.max = function (a, b) { + return a >= b ? a : b; + }; + + MathPrototype.min = function (a, b) { + return a <= b ? a : b; + }; + return MathPrototype; + })(); + TypeScript.MathPrototype = MathPrototype; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (Collections) { + Collections.DefaultStringTableCapacity = 256; + + var StringTableEntry = (function () { + function StringTableEntry(Text, HashCode, Next) { + this.Text = Text; + this.HashCode = HashCode; + this.Next = Next; + } + return StringTableEntry; + })(); + + var StringTable = (function () { + function StringTable(capacity) { + this.count = 0; + var size = TypeScript.Hash.getPrime(capacity); + this.entries = TypeScript.ArrayUtilities.createArray(size, null); + } + StringTable.prototype.addCharArray = function (key, start, len) { + var hashCode = TypeScript.Hash.computeSimple31BitCharArrayHashCode(key, start, len) & 0x7FFFFFFF; + + var entry = this.findCharArrayEntry(key, start, len, hashCode); + if (entry !== null) { + return entry.Text; + } + + var slice = key.slice(start, start + len); + return this.addEntry(TypeScript.StringUtilities.fromCharCodeArray(slice), hashCode); + }; + + StringTable.prototype.findCharArrayEntry = function (key, start, len, hashCode) { + 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; + }; + + StringTable.prototype.addEntry = function (text, hashCode) { + var index = hashCode % this.entries.length; + + var e = new StringTableEntry(text, hashCode, this.entries[index]); + + this.entries[index] = e; + + if (this.count === this.entries.length) { + this.grow(); + } + + this.count++; + return e.Text; + }; + + StringTable.prototype.grow = function () { + var newSize = TypeScript.Hash.expandPrime(this.entries.length); + + var oldEntries = this.entries; + var newEntries = TypeScript.ArrayUtilities.createArray(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; + } + } + }; + + StringTable.textCharArrayEquals = function (text, array, start, length) { + 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; + }; + return StringTable; + })(); + Collections.StringTable = StringTable; + + Collections.DefaultStringTable = new StringTable(Collections.DefaultStringTableCapacity); + })(TypeScript.Collections || (TypeScript.Collections = {})); + var Collections = TypeScript.Collections; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var StringUtilities = (function () { + function StringUtilities() { + } + StringUtilities.isString = function (value) { + return Object.prototype.toString.apply(value, []) === '[object String]'; + }; + + StringUtilities.fromCharCodeArray = function (array) { + return String.fromCharCode.apply(null, array); + }; + + StringUtilities.endsWith = function (string, value) { + return string.substring(string.length - value.length, string.length) === value; + }; + + StringUtilities.startsWith = function (string, value) { + return string.substr(0, value.length) === value; + }; + + StringUtilities.copyTo = function (source, sourceIndex, destination, destinationIndex, count) { + for (var i = 0; i < count; i++) { + destination[destinationIndex + i] = source.charCodeAt(sourceIndex + i); + } + }; + + StringUtilities.repeat = function (value, count) { + return Array(count + 1).join(value); + }; + + StringUtilities.stringEquals = function (val1, val2) { + return val1 === val2; + }; + return StringUtilities; + })(); + TypeScript.StringUtilities = StringUtilities; +})(TypeScript || (TypeScript = {})); +var global = Function("return this").call(null); + +var TypeScript; +(function (TypeScript) { + var Clock; + (function (Clock) { + Clock.now; + Clock.resolution; + + if (typeof WScript !== "undefined" && typeof global['WScript'].InitializeProjection !== "undefined") { + global['WScript'].InitializeProjection(); + + Clock.now = function () { + return TestUtilities.QueryPerformanceCounter(); + }; + + Clock.resolution = TestUtilities.QueryPerformanceFrequency(); + } else { + Clock.now = function () { + return Date.now(); + }; + + Clock.resolution = 1000; + } + })(Clock || (Clock = {})); + + var Timer = (function () { + function Timer() { + this.time = 0; + } + Timer.prototype.start = function () { + this.time = 0; + this.startTime = Clock.now(); + }; + + Timer.prototype.end = function () { + this.time = (Clock.now() - this.startTime); + }; + return Timer; + })(); + TypeScript.Timer = Timer; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (DiagnosticCategory) { + DiagnosticCategory[DiagnosticCategory["Warning"] = 0] = "Warning"; + DiagnosticCategory[DiagnosticCategory["Error"] = 1] = "Error"; + DiagnosticCategory[DiagnosticCategory["Message"] = 2] = "Message"; + DiagnosticCategory[DiagnosticCategory["NoPrefix"] = 3] = "NoPrefix"; + })(TypeScript.DiagnosticCategory || (TypeScript.DiagnosticCategory = {})); + var DiagnosticCategory = TypeScript.DiagnosticCategory; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + TypeScript.diagnosticInformationMap = { + "error TS{0}: {1}": { + "code": 0, + "category": 3 /* NoPrefix */ + }, + "warning TS{0}: {1}": { + "code": 1, + "category": 3 /* NoPrefix */ + }, + "Unrecognized escape sequence.": { + "code": 1000, + "category": 1 /* Error */ + }, + "Unexpected character {0}.": { + "code": 1001, + "category": 1 /* Error */ + }, + "Missing close quote character.": { + "code": 1002, + "category": 1 /* Error */ + }, + "Identifier expected.": { + "code": 1003, + "category": 1 /* Error */ + }, + "'{0}' keyword expected.": { + "code": 1004, + "category": 1 /* Error */ + }, + "'{0}' expected.": { + "code": 1005, + "category": 1 /* Error */ + }, + "Identifier expected; '{0}' is a keyword.": { + "code": 1006, + "category": 1 /* Error */ + }, + "Automatic semicolon insertion not allowed.": { + "code": 1007, + "category": 1 /* Error */ + }, + "Unexpected token; '{0}' expected.": { + "code": 1008, + "category": 1 /* Error */ + }, + "Trailing separator not allowed.": { + "code": 1009, + "category": 1 /* Error */ + }, + "'*/' expected.": { + "code": 1010, + "category": 1 /* Error */ + }, + "'public' or 'private' modifier must precede 'static'.": { + "code": 1011, + "category": 1 /* Error */ + }, + "Unexpected token.": { + "code": 1012, + "category": 1 /* Error */ + }, + "Catch clause parameter cannot have a type annotation.": { + "code": 1013, + "category": 1 /* Error */ + }, + "Rest parameter must be last in list.": { + "code": 1014, + "category": 1 /* Error */ + }, + "Parameter cannot have question mark and initializer.": { + "code": 1015, + "category": 1 /* Error */ + }, + "Required parameter cannot follow optional parameter.": { + "code": 1016, + "category": 1 /* Error */ + }, + "Index signatures cannot have rest parameters.": { + "code": 1017, + "category": 1 /* Error */ + }, + "Index signature parameter cannot have accessibility modifiers.": { + "code": 1018, + "category": 1 /* Error */ + }, + "Index signature parameter cannot have a question mark.": { + "code": 1019, + "category": 1 /* Error */ + }, + "Index signature parameter cannot have an initializer.": { + "code": 1020, + "category": 1 /* Error */ + }, + "Index signature must have a type annotation.": { + "code": 1021, + "category": 1 /* Error */ + }, + "Index signature parameter must have a type annotation.": { + "code": 1022, + "category": 1 /* Error */ + }, + "Index signature parameter type must be 'string' or 'number'.": { + "code": 1023, + "category": 1 /* Error */ + }, + "'extends' clause already seen.": { + "code": 1024, + "category": 1 /* Error */ + }, + "'extends' clause must precede 'implements' clause.": { + "code": 1025, + "category": 1 /* Error */ + }, + "Classes can only extend a single class.": { + "code": 1026, + "category": 1 /* Error */ + }, + "'implements' clause already seen.": { + "code": 1027, + "category": 1 /* Error */ + }, + "Accessibility modifier already seen.": { + "code": 1028, + "category": 1 /* Error */ + }, + "'{0}' modifier must precede '{1}' modifier.": { + "code": 1029, + "category": 1 /* Error */ + }, + "'{0}' modifier already seen.": { + "code": 1030, + "category": 1 /* Error */ + }, + "'{0}' modifier cannot appear on a class element.": { + "code": 1031, + "category": 1 /* Error */ + }, + "Interface declaration cannot have 'implements' clause.": { + "code": 1032, + "category": 1 /* Error */ + }, + "'super' invocation cannot have type arguments.": { + "code": 1034, + "category": 1 /* Error */ + }, + "Only ambient modules can use quoted names.": { + "code": 1035, + "category": 1 /* Error */ + }, + "Statements are not allowed in ambient contexts.": { + "code": 1036, + "category": 1 /* Error */ + }, + "Implementations are not allowed in ambient contexts.": { + "code": 1037, + "category": 1 /* Error */ + }, + "'declare' modifier not allowed for code already in an ambient context.": { + "code": 1038, + "category": 1 /* Error */ + }, + "Initializers are not allowed in ambient contexts.": { + "code": 1039, + "category": 1 /* Error */ + }, + "Parameter property declarations can only be used in constructors.": { + "code": 1040, + "category": 1 /* Error */ + }, + "Function implementation expected.": { + "code": 1041, + "category": 1 /* Error */ + }, + "Constructor implementation expected.": { + "code": 1042, + "category": 1 /* Error */ + }, + "Function overload name must be '{0}'.": { + "code": 1043, + "category": 1 /* Error */ + }, + "'{0}' modifier cannot appear on a module element.": { + "code": 1044, + "category": 1 /* Error */ + }, + "'declare' modifier cannot appear on an interface declaration.": { + "code": 1045, + "category": 1 /* Error */ + }, + "'declare' modifier required for top level element.": { + "code": 1046, + "category": 1 /* Error */ + }, + "Rest parameter cannot be optional.": { + "code": 1047, + "category": 1 /* Error */ + }, + "Rest parameter cannot have an initializer.": { + "code": 1048, + "category": 1 /* Error */ + }, + "'set' accessor must have one and only one parameter.": { + "code": 1049, + "category": 1 /* Error */ + }, + "'set' accessor parameter cannot have accessibility modifier.": { + "code": 1050, + "category": 1 /* Error */ + }, + "'set' accessor parameter cannot be optional.": { + "code": 1051, + "category": 1 /* Error */ + }, + "'set' accessor parameter cannot have an initializer.": { + "code": 1052, + "category": 1 /* Error */ + }, + "'set' accessor cannot have rest parameter.": { + "code": 1053, + "category": 1 /* Error */ + }, + "'get' accessor cannot have parameters.": { + "code": 1054, + "category": 1 /* Error */ + }, + "Modifiers cannot appear here.": { + "code": 1055, + "category": 1 /* Error */ + }, + "Accessors are only available when targeting ECMAScript 5 and higher.": { + "code": 1056, + "category": 1 /* Error */ + }, + "Class name cannot be '{0}'.": { + "code": 1057, + "category": 1 /* Error */ + }, + "Interface name cannot be '{0}'.": { + "code": 1058, + "category": 1 /* Error */ + }, + "Enum name cannot be '{0}'.": { + "code": 1059, + "category": 1 /* Error */ + }, + "Module name cannot be '{0}'.": { + "code": 1060, + "category": 1 /* Error */ + }, + "Enum member must have initializer.": { + "code": 1061, + "category": 1 /* Error */ + }, + "Export assignment cannot be used in internal modules.": { + "code": 1063, + "category": 1 /* Error */ + }, + "Export assignment not allowed in module with exported element.": { + "code": 1064, + "category": 1 /* Error */ + }, + "Module cannot have multiple export assignments.": { + "code": 1065, + "category": 1 /* Error */ + }, + "Ambient enum elements can only have integer literal initializers.": { + "code": 1066, + "category": 1 /* Error */ + }, + "module, class, interface, enum, import or statement": { + "code": 1067, + "category": 3 /* NoPrefix */ + }, + "constructor, function, accessor or variable": { + "code": 1068, + "category": 3 /* NoPrefix */ + }, + "statement": { + "code": 1069, + "category": 3 /* NoPrefix */ + }, + "case or default clause": { + "code": 1070, + "category": 3 /* NoPrefix */ + }, + "identifier": { + "code": 1071, + "category": 3 /* NoPrefix */ + }, + "call, construct, index, property or function signature": { + "code": 1072, + "category": 3 /* NoPrefix */ + }, + "expression": { + "code": 1073, + "category": 3 /* NoPrefix */ + }, + "type name": { + "code": 1074, + "category": 3 /* NoPrefix */ + }, + "property or accessor": { + "code": 1075, + "category": 3 /* NoPrefix */ + }, + "parameter": { + "code": 1076, + "category": 3 /* NoPrefix */ + }, + "type": { + "code": 1077, + "category": 3 /* NoPrefix */ + }, + "type parameter": { + "code": 1078, + "category": 3 /* NoPrefix */ + }, + "'declare' modifier not allowed on import declaration.": { + "code": 1079, + "category": 1 /* Error */ + }, + "Function overload must be static": { + "code": 1080, + "category": 1 /* Error */ + }, + "Function overload must not be static": { + "code": 1081, + "category": 1 /* Error */ + }, + "Parameter property declarations cannot be used in an ambient context.": { + "code": 1082, + "category": 1 /* Error */ + }, + "Parameter property declarations cannot be used in a constructor overload.": { + "code": 1083, + "category": 1 /* Error */ + }, + "Duplicate identifier '{0}'.": { + "code": 2000, + "category": 1 /* Error */ + }, + "The name '{0}' does not exist in the current scope.": { + "code": 2001, + "category": 1 /* Error */ + }, + "The name '{0}' does not refer to a value.": { + "code": 2002, + "category": 1 /* Error */ + }, + "'super' can only be used inside a class instance method.": { + "code": 2003, + "category": 1 /* Error */ + }, + "The left-hand side of an assignment expression must be a variable, property or indexer.": { + "code": 2004, + "category": 1 /* Error */ + }, + "Value of type '{0}' is not callable. Did you mean to include 'new'?": { + "code": 2161, + "category": 1 /* Error */ + }, + "Value of type '{0}' is not callable.": { + "code": 2006, + "category": 1 /* Error */ + }, + "Value of type '{0}' is not newable.": { + "code": 2007, + "category": 1 /* Error */ + }, + "Value of type '{0}' is not indexable by type '{1}'.": { + "code": 2008, + "category": 1 /* Error */ + }, + "Operator '{0}' cannot be applied to types '{1}' and '{2}'.": { + "code": 2009, + "category": 1 /* Error */ + }, + "Operator '{0}' cannot be applied to types '{1}' and '{2}': {3}": { + "code": 2010, + "category": 1 /* Error */ + }, + "Cannot convert '{0}' to '{1}'.": { + "code": 2011, + "category": 1 /* Error */ + }, + "Cannot convert '{0}' to '{1}':{NL}{2}": { + "code": 2012, + "category": 1 /* Error */ + }, + "Expected var, class, interface, or module.": { + "code": 2013, + "category": 1 /* Error */ + }, + "Operator '{0}' cannot be applied to type '{1}'.": { + "code": 2014, + "category": 1 /* Error */ + }, + "Getter '{0}' already declared.": { + "code": 2015, + "category": 1 /* Error */ + }, + "Setter '{0}' already declared.": { + "code": 2016, + "category": 1 /* Error */ + }, + "Accessors cannot have type parameters.": { + "code": 2017, + "category": 1 /* Error */ + }, + "Exported class '{0}' extends private class '{1}'.": { + "code": 2018, + "category": 1 /* Error */ + }, + "Exported class '{0}' implements private interface '{1}'.": { + "code": 2019, + "category": 1 /* Error */ + }, + "Exported interface '{0}' extends private interface '{1}'.": { + "code": 2020, + "category": 1 /* Error */ + }, + "Exported class '{0}' extends class from inaccessible module {1}.": { + "code": 2021, + "category": 1 /* Error */ + }, + "Exported class '{0}' implements interface from inaccessible module {1}.": { + "code": 2022, + "category": 1 /* Error */ + }, + "Exported interface '{0}' extends interface from inaccessible module {1}.": { + "code": 2023, + "category": 1 /* Error */ + }, + "Public static property '{0}' of exported class has or is using private type '{1}'.": { + "code": 2024, + "category": 1 /* Error */ + }, + "Public property '{0}' of exported class has or is using private type '{1}'.": { + "code": 2025, + "category": 1 /* Error */ + }, + "Property '{0}' of exported interface has or is using private type '{1}'.": { + "code": 2026, + "category": 1 /* Error */ + }, + "Exported variable '{0}' has or is using private type '{1}'.": { + "code": 2027, + "category": 1 /* Error */ + }, + "Public static property '{0}' of exported class is using inaccessible module {1}.": { + "code": 2028, + "category": 1 /* Error */ + }, + "Public property '{0}' of exported class is using inaccessible module {1}.": { + "code": 2029, + "category": 1 /* Error */ + }, + "Property '{0}' of exported interface is using inaccessible module {1}.": { + "code": 2030, + "category": 1 /* Error */ + }, + "Exported variable '{0}' is using inaccessible module {1}.": { + "code": 2031, + "category": 1 /* Error */ + }, + "Parameter '{0}' of constructor from exported class has or is using private type '{1}'.": { + "code": 2032, + "category": 1 /* Error */ + }, + "Parameter '{0}' of public static property setter from exported class has or is using private type '{1}'.": { + "code": 2033, + "category": 1 /* Error */ + }, + "Parameter '{0}' of public property setter from exported class has or is using private type '{1}'.": { + "code": 2034, + "category": 1 /* Error */ + }, + "Parameter '{0}' of constructor signature from exported interface has or is using private type '{1}'.": { + "code": 2035, + "category": 1 /* Error */ + }, + "Parameter '{0}' of call signature from exported interface has or is using private type '{1}'.": { + "code": 2036, + "category": 1 /* Error */ + }, + "Parameter '{0}' of public static method from exported class has or is using private type '{1}'.": { + "code": 2037, + "category": 1 /* Error */ + }, + "Parameter '{0}' of public method from exported class has or is using private type '{1}'.": { + "code": 2038, + "category": 1 /* Error */ + }, + "Parameter '{0}' of method from exported interface has or is using private type '{1}'.": { + "code": 2039, + "category": 1 /* Error */ + }, + "Parameter '{0}' of exported function has or is using private type '{1}'.": { + "code": 2040, + "category": 1 /* Error */ + }, + "Parameter '{0}' of constructor from exported class is using inaccessible module {1}.": { + "code": 2041, + "category": 1 /* Error */ + }, + "Parameter '{0}' of public static property setter from exported class is using inaccessible module {1}.": { + "code": 2042, + "category": 1 /* Error */ + }, + "Parameter '{0}' of public property setter from exported class is using inaccessible module {1}.": { + "code": 2043, + "category": 1 /* Error */ + }, + "Parameter '{0}' of constructor signature from exported interface is using inaccessible module {1}.": { + "code": 2044, + "category": 1 /* Error */ + }, + "Parameter '{0}' of call signature from exported interface is using inaccessible module {1}": { + "code": 2045, + "category": 1 /* Error */ + }, + "Parameter '{0}' of public static method from exported class is using inaccessible module {1}.": { + "code": 2046, + "category": 1 /* Error */ + }, + "Parameter '{0}' of public method from exported class is using inaccessible module {1}.": { + "code": 2047, + "category": 1 /* Error */ + }, + "Parameter '{0}' of method from exported interface is using inaccessible module {1}.": { + "code": 2048, + "category": 1 /* Error */ + }, + "Parameter '{0}' of exported function is using inaccessible module {1}.": { + "code": 2049, + "category": 1 /* Error */ + }, + "Return type of public static property getter from exported class has or is using private type '{0}'.": { + "code": 2050, + "category": 1 /* Error */ + }, + "Return type of public property getter from exported class has or is using private type '{0}'.": { + "code": 2051, + "category": 1 /* Error */ + }, + "Return type of constructor signature from exported interface has or is using private type '{0}'.": { + "code": 2052, + "category": 1 /* Error */ + }, + "Return type of call signature from exported interface has or is using private type '{0}'.": { + "code": 2053, + "category": 1 /* Error */ + }, + "Return type of index signature from exported interface has or is using private type '{0}'.": { + "code": 2054, + "category": 1 /* Error */ + }, + "Return type of public static method from exported class has or is using private type '{0}'.": { + "code": 2055, + "category": 1 /* Error */ + }, + "Return type of public method from exported class has or is using private type '{0}'.": { + "code": 2056, + "category": 1 /* Error */ + }, + "Return type of method from exported interface has or is using private type '{0}'.": { + "code": 2057, + "category": 1 /* Error */ + }, + "Return type of exported function has or is using private type '{0}'.": { + "code": 2058, + "category": 1 /* Error */ + }, + "Return type of public static property getter from exported class is using inaccessible module {0}.": { + "code": 2059, + "category": 1 /* Error */ + }, + "Return type of public property getter from exported class is using inaccessible module {0}.": { + "code": 2060, + "category": 1 /* Error */ + }, + "Return type of constructor signature from exported interface is using inaccessible module {0}.": { + "code": 2061, + "category": 1 /* Error */ + }, + "Return type of call signature from exported interface is using inaccessible module {0}.": { + "code": 2062, + "category": 1 /* Error */ + }, + "Return type of index signature from exported interface is using inaccessible module {0}.": { + "code": 2063, + "category": 1 /* Error */ + }, + "Return type of public static method from exported class is using inaccessible module {0}.": { + "code": 2064, + "category": 1 /* Error */ + }, + "Return type of public method from exported class is using inaccessible module {0}.": { + "code": 2065, + "category": 1 /* Error */ + }, + "Return type of method from exported interface is using inaccessible module {0}.": { + "code": 2066, + "category": 1 /* Error */ + }, + "Return type of exported function is using inaccessible module {0}.": { + "code": 2067, + "category": 1 /* Error */ + }, + "'new T[]' cannot be used to create an array. Use 'new Array()' instead.": { + "code": 2068, + "category": 1 /* Error */ + }, + "A parameter list must follow a generic type argument list. '(' expected.": { + "code": 2069, + "category": 1 /* Error */ + }, + "Multiple constructor implementations are not allowed.": { + "code": 2070, + "category": 1 /* Error */ + }, + "Unable to resolve external module '{0}'.": { + "code": 2071, + "category": 1 /* Error */ + }, + "Module cannot be aliased to a non-module type.": { + "code": 2072, + "category": 1 /* Error */ + }, + "A class may only extend another class.": { + "code": 2073, + "category": 1 /* Error */ + }, + "A class may only implement another class or interface.": { + "code": 2074, + "category": 1 /* Error */ + }, + "An interface may only extend another class or interface.": { + "code": 2075, + "category": 1 /* Error */ + }, + "An interface cannot implement another type.": { + "code": 2076, + "category": 1 /* Error */ + }, + "Unable to resolve type.": { + "code": 2077, + "category": 1 /* Error */ + }, + "Unable to resolve type of '{0}'.": { + "code": 2078, + "category": 1 /* Error */ + }, + "Unable to resolve type parameter constraint.": { + "code": 2079, + "category": 1 /* Error */ + }, + "Type parameter constraint cannot be a primitive type.": { + "code": 2080, + "category": 1 /* Error */ + }, + "Supplied parameters do not match any signature of call target.": { + "code": 2081, + "category": 1 /* Error */ + }, + "Supplied parameters do not match any signature of call target:{NL}{0}": { + "code": 2082, + "category": 1 /* Error */ + }, + "Invalid 'new' expression.": { + "code": 2083, + "category": 1 /* Error */ + }, + "Call signatures used in a 'new' expression must have a 'void' return type.": { + "code": 2084, + "category": 1 /* Error */ + }, + "Could not select overload for 'new' expression.": { + "code": 2085, + "category": 1 /* Error */ + }, + "Type '{0}' does not satisfy the constraint '{1}' for type parameter '{2}'.": { + "code": 2086, + "category": 1 /* Error */ + }, + "Could not select overload for 'call' expression.": { + "code": 2087, + "category": 1 /* Error */ + }, + "Cannot invoke an expression whose type lacks a call signature.": { + "code": 2088, + "category": 1 /* Error */ + }, + "Calls to 'super' are only valid inside a class.": { + "code": 2089, + "category": 1 /* Error */ + }, + "Generic type '{0}' requires {1} type argument(s).": { + "code": 2090, + "category": 1 /* Error */ + }, + "Type of conditional expression cannot be determined. Best common type could not be found between '{0}' and '{1}'.": { + "code": 2091, + "category": 1 /* Error */ + }, + "Type of array literal cannot be determined. Best common type could not be found for array elements.": { + "code": 2092, + "category": 1 /* Error */ + }, + "Could not find enclosing symbol for dotted name '{0}'.": { + "code": 2093, + "category": 1 /* Error */ + }, + "The property '{0}' does not exist on value of type '{1}'.": { + "code": 2094, + "category": 1 /* Error */ + }, + "Could not find symbol '{0}'.": { + "code": 2095, + "category": 1 /* Error */ + }, + "'get' and 'set' accessor must have the same type.": { + "code": 2096, + "category": 1 /* Error */ + }, + "'this' cannot be referenced in current location.": { + "code": 2097, + "category": 1 /* Error */ + }, + "Static methods cannot reference class type parameters.": { + "code": 2099, + "category": 1 /* Error */ + }, + "Class '{0}' is recursively referenced as a base type of itself.": { + "code": 2100, + "category": 1 /* Error */ + }, + "Interface '{0}' is recursively referenced as a base type of itself.": { + "code": 2101, + "category": 1 /* Error */ + }, + "'super' property access is permitted only in a constructor, instance member function, or instance member accessor of a derived class.": { + "code": 2102, + "category": 1 /* Error */ + }, + "'super' cannot be referenced in non-derived classes.": { + "code": 2103, + "category": 1 /* 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": 1 /* Error */ + }, + "Constructors for derived classes must contain a 'super' call.": { + "code": 2105, + "category": 1 /* Error */ + }, + "Super calls are not permitted outside constructors or in local functions inside constructors.": { + "code": 2106, + "category": 1 /* Error */ + }, + "'{0}.{1}' is inaccessible.": { + "code": 2107, + "category": 1 /* Error */ + }, + "'this' cannot be referenced within module bodies.": { + "code": 2108, + "category": 1 /* Error */ + }, + "Invalid '+' expression - types not known to support the addition operator.": { + "code": 2111, + "category": 1 /* Error */ + }, + "The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.": { + "code": 2112, + "category": 1 /* Error */ + }, + "The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.": { + "code": 2113, + "category": 1 /* Error */ + }, + "The type of a unary arithmetic operation operand must be of type 'any', 'number' or an enum type.": { + "code": 2114, + "category": 1 /* Error */ + }, + "Variable declarations of a 'for' statement cannot use a type annotation.": { + "code": 2115, + "category": 1 /* Error */ + }, + "Variable declarations of a 'for' statement must be of types 'string' or 'any'.": { + "code": 2116, + "category": 1 /* 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": 1 /* Error */ + }, + "The left-hand side of an 'in' expression must be of types 'string' or 'any'.": { + "code": 2118, + "category": 1 /* Error */ + }, + "The right-hand side of an 'in' expression must be of type 'any', an object type or a type parameter.": { + "code": 2119, + "category": 1 /* Error */ + }, + "The left-hand side of an 'instanceof' expression must be of type 'any', an object type or a type parameter.": { + "code": 2120, + "category": 1 /* Error */ + }, + "The right-hand side of an 'instanceof' expression must be of type 'any' or a subtype of the 'Function' interface type.": { + "code": 2121, + "category": 1 /* Error */ + }, + "Setters cannot return a value.": { + "code": 2122, + "category": 1 /* Error */ + }, + "Tried to query type of uninitialized module '{0}'.": { + "code": 2123, + "category": 1 /* Error */ + }, + "Tried to set variable type to uninitialized module type '{0}'.": { + "code": 2124, + "category": 1 /* Error */ + }, + "Function '{0}' declared a non-void return type, but has no return expression.": { + "code": 2125, + "category": 1 /* Error */ + }, + "Getters must return a value.": { + "code": 2126, + "category": 1 /* Error */ + }, + "Getter and setter accessors do not agree in visibility.": { + "code": 2127, + "category": 1 /* Error */ + }, + "Invalid left-hand side of assignment expression.": { + "code": 2130, + "category": 1 /* Error */ + }, + "Function declared a non-void return type, but has no return expression.": { + "code": 2131, + "category": 1 /* Error */ + }, + "Cannot resolve return type reference.": { + "code": 2132, + "category": 1 /* Error */ + }, + "Constructors cannot have a return type of 'void'.": { + "code": 2133, + "category": 1 /* Error */ + }, + "Subsequent variable declarations must have the same type. Variable '{0}' must be of type '{1}', but here has type '{2}'.": { + "code": 2134, + "category": 1 /* Error */ + }, + "All symbols within a with block will be resolved to 'any'.": { + "code": 2135, + "category": 1 /* Error */ + }, + "Import declarations in an internal module cannot reference an external module.": { + "code": 2136, + "category": 1 /* Error */ + }, + "Class {0} declares interface {1} but does not implement it:{NL}{2}": { + "code": 2137, + "category": 1 /* Error */ + }, + "Class {0} declares class {1} as an interface but does not implement it:{NL}{2}": { + "code": 2138, + "category": 1 /* Error */ + }, + "The operand of an increment or decrement operator must be a variable, property or indexer.": { + "code": 2139, + "category": 1 /* Error */ + }, + "'this' cannot be referenced in static initializers in a class body.": { + "code": 2140, + "category": 1 /* Error */ + }, + "Class '{0}' cannot extend class '{1}':{NL}{2}": { + "code": 2141, + "category": 1 /* Error */ + }, + "Interface '{0}' cannot extend class '{1}':{NL}{2}": { + "code": 2142, + "category": 1 /* Error */ + }, + "Interface '{0}' cannot extend interface '{1}':{NL}{2}": { + "code": 2143, + "category": 1 /* Error */ + }, + "Duplicate overload signature for '{0}'.": { + "code": 2144, + "category": 1 /* Error */ + }, + "Duplicate constructor overload signature.": { + "code": 2145, + "category": 1 /* Error */ + }, + "Duplicate overload call signature.": { + "code": 2146, + "category": 1 /* Error */ + }, + "Duplicate overload construct signature.": { + "code": 2147, + "category": 1 /* Error */ + }, + "Overload signature is not compatible with function definition.": { + "code": 2148, + "category": 1 /* Error */ + }, + "Overload signature is not compatible with function definition:{NL}{0}": { + "code": 2149, + "category": 1 /* Error */ + }, + "Overload signatures must all be public or private.": { + "code": 2150, + "category": 1 /* Error */ + }, + "Overload signatures must all be exported or local.": { + "code": 2151, + "category": 1 /* Error */ + }, + "Overload signatures must all be ambient or non-ambient.": { + "code": 2152, + "category": 1 /* Error */ + }, + "Overload signatures must all be optional or required.": { + "code": 2153, + "category": 1 /* Error */ + }, + "Specialized overload signature is not subtype of any non-specialized signature.": { + "code": 2154, + "category": 1 /* Error */ + }, + "'this' cannot be referenced in constructor arguments.": { + "code": 2155, + "category": 1 /* Error */ + }, + "Static member cannot be accessed off an instance variable.": { + "code": 2156, + "category": 1 /* Error */ + }, + "Instance member cannot be accessed off a class.": { + "code": 2157, + "category": 1 /* Error */ + }, + "Untyped function calls may not accept type arguments.": { + "code": 2158, + "category": 1 /* Error */ + }, + "Non-generic functions may not accept type arguments.": { + "code": 2159, + "category": 1 /* Error */ + }, + "A generic type may not reference itself with a wrapped form of its own type parameters.": { + "code": 2160, + "category": 1 /* Error */ + }, + "Rest parameters must be array types.": { + "code": 2162, + "category": 1 /* Error */ + }, + "Overload signature implementation cannot use specialized type.": { + "code": 2163, + "category": 1 /* Error */ + }, + "Export assignments may only be used at the top-level of external modules.": { + "code": 2164, + "category": 1 /* Error */ + }, + "Export assignments may only be made with variables, functions, classes, interfaces, enums and internal modules": { + "code": 2165, + "category": 1 /* Error */ + }, + "Only public instance methods of the base class are accessible via the 'super' keyword.": { + "code": 2166, + "category": 1 /* Error */ + }, + "Numeric indexer type '{0}' must be a subtype of string indexer type '{1}'.": { + "code": 2167, + "category": 1 /* Error */ + }, + "Numeric indexer type '{0}' must be a subtype of string indexer type '{1}':{NL}{2}": { + "code": 2168, + "category": 1 /* Error */ + }, + "All numerically named properties must be subtypes of numeric indexer type '{0}'.": { + "code": 2169, + "category": 1 /* Error */ + }, + "All numerically named properties must be subtypes of numeric indexer type '{0}':{NL}{1}": { + "code": 2170, + "category": 1 /* Error */ + }, + "All named properties must be subtypes of string indexer type '{0}'.": { + "code": 2171, + "category": 1 /* Error */ + }, + "All named properties must be subtypes of string indexer type '{0}':{NL}{1}": { + "code": 2172, + "category": 1 /* Error */ + }, + "Generic type references must include all type arguments.": { + "code": 2173, + "category": 1 /* Error */ + }, + "Default arguments are not allowed in an overload parameter.": { + "code": 2174, + "category": 1 /* Error */ + }, + "Overloads cannot differ only by return type.": { + "code": 2175, + "category": 1 /* Error */ + }, + "Function expression declared a non-void return type, but has no return expression.": { + "code": 2176, + "category": 1 /* Error */ + }, + "Import declaration referencing identifier from internal module can only be made with variables, functions, classes, interfaces, enums and internal modules.": { + "code": 2177, + "category": 1 /* Error */ + }, + "Could not find symbol '{0}' in module '{1}'.": { + "code": 2178, + "category": 1 /* Error */ + }, + "Unable to resolve module reference '{0}'.": { + "code": 2179, + "category": 1 /* Error */ + }, + "Could not find module '{0}' in module '{1}'.": { + "code": 2180, + "category": 1 /* Error */ + }, + "Exported import declaration '{0}' is assigned value with type that has or is using private type '{1}'.": { + "code": 2181, + "category": 1 /* Error */ + }, + "Exported import declaration '{0}' is assigned value with type that is using inaccessible module '{1}'.": { + "code": 2182, + "category": 1 /* Error */ + }, + "Exported import declaration '{0}' is assigned type that has or is using private type '{1}'.": { + "code": 2183, + "category": 1 /* Error */ + }, + "Exported import declaration '{0}' is assigned type that is using inaccessible module '{1}'.": { + "code": 2184, + "category": 1 /* Error */ + }, + "Exported import declaration '{0}' is assigned container that is or is using inaccessible module '{1}'.": { + "code": 2185, + "category": 1 /* Error */ + }, + "Type reference '{0}' in extends clause doesn't reference constructor function for '{1}'.": { + "code": 2186, + "category": 1 /* Error */ + }, + "Internal module reference '{0}' in import declaration doesn't reference module instance for '{1}'.": { + "code": 2187, + "category": 1 /* Error */ + }, + "Type '{0}' is missing property '{1}' from type '{2}'.": { + "code": 4000, + "category": 3 /* NoPrefix */ + }, + "Types of property '{0}' of types '{1}' and '{2}' are incompatible.": { + "code": 4001, + "category": 3 /* NoPrefix */ + }, + "Types of property '{0}' of types '{1}' and '{2}' are incompatible:{NL}{3}": { + "code": 4002, + "category": 3 /* NoPrefix */ + }, + "Property '{0}' defined as private in type '{1}' is defined as public in type '{2}'.": { + "code": 4003, + "category": 3 /* NoPrefix */ + }, + "Property '{0}' defined as public in type '{1}' is defined as private in type '{2}'.": { + "code": 4004, + "category": 3 /* NoPrefix */ + }, + "Types '{0}' and '{1}' define property '{2}' as private.": { + "code": 4005, + "category": 3 /* NoPrefix */ + }, + "Call signatures of types '{0}' and '{1}' are incompatible.": { + "code": 4006, + "category": 3 /* NoPrefix */ + }, + "Call signatures of types '{0}' and '{1}' are incompatible:{NL}{2}": { + "code": 4007, + "category": 3 /* NoPrefix */ + }, + "Type '{0}' requires a call signature, but type '{1}' lacks one.": { + "code": 4008, + "category": 3 /* NoPrefix */ + }, + "Construct signatures of types '{0}' and '{1}' are incompatible.": { + "code": 4009, + "category": 3 /* NoPrefix */ + }, + "Construct signatures of types '{0}' and '{1}' are incompatible:{NL}{2}": { + "code": 40010, + "category": 3 /* NoPrefix */ + }, + "Type '{0}' requires a construct signature, but type '{1}' lacks one.": { + "code": 4011, + "category": 3 /* NoPrefix */ + }, + "Index signatures of types '{0}' and '{1}' are incompatible.": { + "code": 4012, + "category": 3 /* NoPrefix */ + }, + "Index signatures of types '{0}' and '{1}' are incompatible:{NL}{2}": { + "code": 4013, + "category": 3 /* NoPrefix */ + }, + "Call signature expects {0} or fewer parameters.": { + "code": 4014, + "category": 3 /* NoPrefix */ + }, + "Could not apply type '{0}' to argument {1} which is of type '{2}'.": { + "code": 4015, + "category": 3 /* NoPrefix */ + }, + "Class '{0}' defines instance member accessor '{1}', but extended class '{2}' defines it as instance member function.": { + "code": 4016, + "category": 3 /* NoPrefix */ + }, + "Class '{0}' defines instance member property '{1}', but extended class '{2}' defines it as instance member function.": { + "code": 4017, + "category": 3 /* NoPrefix */ + }, + "Class '{0}' defines instance member function '{1}', but extended class '{2}' defines it as instance member accessor.": { + "code": 4018, + "category": 3 /* NoPrefix */ + }, + "Class '{0}' defines instance member function '{1}', but extended class '{2}' defines it as instance member property.": { + "code": 4019, + "category": 3 /* NoPrefix */ + }, + "Types of static property '{0}' of class '{1}' and class '{2}' are incompatible.": { + "code": 4020, + "category": 3 /* NoPrefix */ + }, + "Types of static property '{0}' of class '{1}' and class '{2}' are incompatible:{NL}{3}": { + "code": 4021, + "category": 3 /* NoPrefix */ + }, + "Type reference cannot refer to container '{0}'.": { + "code": 4022, + "category": 1 /* Error */ + }, + "Type reference must refer to type.": { + "code": 4023, + "category": 1 /* Error */ + }, + "Enums with multiple declarations must provide an initializer for the first enum element.": { + "code": 4024, + "category": 1 /* Error */ + }, + " (+ {0} overload(s))": { + "code": 4025, + "category": 2 /* Message */ + }, + "Current host does not support '{0}' option.": { + "code": 5001, + "category": 1 /* Error */ + }, + "ECMAScript target version '{0}' not supported. Using default '{1}' code generation.": { + "code": 5002, + "category": 0 /* Warning */ + }, + "Module code generation '{0}' not supported.": { + "code": 5003, + "category": 0 /* Warning */ + }, + "Could not find file: '{0}'.": { + "code": 5004, + "category": 1 /* Error */ + }, + "A file cannot have a reference to itself.": { + "code": 5006, + "category": 1 /* Error */ + }, + "Cannot resolve referenced file: '{0}'.": { + "code": 5007, + "category": 1 /* Error */ + }, + "Cannot find the common subdirectory path for the input files.": { + "code": 5009, + "category": 1 /* Error */ + }, + "Emit Error: {0}.": { + "code": 5011, + "category": 1 /* Error */ + }, + "Cannot read file '{0}': {1}": { + "code": 5012, + "category": 1 /* Error */ + }, + "Unsupported file encoding.": { + "code": 5013, + "category": 3 /* NoPrefix */ + }, + "Locale must be of the form or -. For example '{0}' or '{1}'.": { + "code": 5014, + "category": 1 /* Error */ + }, + "Unsupported locale: '{0}'.": { + "code": 5015, + "category": 1 /* Error */ + }, + "Execution Failed.{NL}": { + "code": 5016, + "category": 1 /* Error */ + }, + "Should not emit a type query": { + "code": 5017, + "category": 1 /* Error */ + }, + "Should not emit a type reference": { + "code": 5018, + "category": 1 /* Error */ + }, + "Invalid call to 'up'": { + "code": 5019, + "category": 1 /* Error */ + }, + "Invalid call to 'down'": { + "code": 5020, + "category": 1 /* Error */ + }, + "Base64 value '{0}' finished with a continuation bit": { + "code": 5021, + "category": 1 /* Error */ + }, + "Key was already in table": { + "code": 5022, + "category": 1 /* Error */ + }, + "Unknown option '{0}'": { + "code": 5023, + "category": 1 /* Error */ + }, + "Expected {0} arguments to message, got {1} instead": { + "code": 5024, + "category": 1 /* Error */ + }, + "Expected the message '{0}' to have {1} arguments, but it had {2}": { + "code": 5025, + "category": 1 /* Error */ + }, + "Invalid argument: {0}. {1}": { + "code": 5026, + "category": 1 /* Error */ + }, + "Invalid argument: {0}.": { + "code": 5027, + "category": 1 /* Error */ + }, + "Argument out of range: {0}.": { + "code": 5028, + "category": 1 /* Error */ + }, + "Argument null: {0}.": { + "code": 5029, + "category": 1 /* Error */ + }, + "Operation not implemented properly by subclass.": { + "code": 5030, + "category": 1 /* Error */ + }, + "Not yet implemented.": { + "code": 5031, + "category": 1 /* Error */ + }, + "Invalid operation: {0}": { + "code": 5032, + "category": 1 /* Error */ + }, + "Invalid operation.": { + "code": 5033, + "category": 1 /* Error */ + }, + "Could not delete file '{0}'": { + "code": 5034, + "category": 1 /* Error */ + }, + "Could not create directory '{0}'": { + "code": 5035, + "category": 1 /* Error */ + }, + "Error while executing file '{0}': ": { + "code": 5036, + "category": 1 /* Error */ + }, + "Cannot compile external modules unless the '--module' flag is provided.": { + "code": 5037, + "category": 1 /* Error */ + }, + "Option mapRoot cannot be specified without specifying sourcemap option.": { + "code": 5038, + "category": 1 /* Error */ + }, + "Option sourceRoot cannot be specified without specifying sourcemap option.": { + "code": 5039, + "category": 1 /* Error */ + }, + "Options mapRoot and sourceRoot cannot be specified without specifying sourcemap option.": { + "code": 5040, + "category": 1 /* Error */ + }, + "Concatenate and emit output to single file": { + "code": 6001, + "category": 2 /* Message */ + }, + "Generates corresponding {0} file": { + "code": 6002, + "category": 2 /* Message */ + }, + "Specifies the location where debugger should locate map files instead of generated locations.": { + "code": 6003, + "category": 2 /* Message */ + }, + "Specifies the location where debugger should locate TypeScript files instead of source locations.": { + "code": 6004, + "category": 2 /* Message */ + }, + "Watch input files": { + "code": 6005, + "category": 2 /* Message */ + }, + "Redirect output structure to the directory": { + "code": 6006, + "category": 2 /* Message */ + }, + "Do not emit comments to output": { + "code": 6009, + "category": 2 /* Message */ + }, + "Skip resolution and preprocessing": { + "code": 6010, + "category": 2 /* Message */ + }, + "Specify ECMAScript target version: \"{0}\" (default), or \"{1}\"": { + "code": 6015, + "category": 2 /* Message */ + }, + "Specify module code generation: \"{0}\" or \"{1}\"": { + "code": 6016, + "category": 2 /* Message */ + }, + "Print this message": { + "code": 6017, + "category": 2 /* Message */ + }, + "Print the compiler's version: {0}": { + "code": 6019, + "category": 2 /* Message */ + }, + "Allow use of deprecated \"{0}\" keyword when referencing an external module": { + "code": 6021, + "category": 2 /* Message */ + }, + "Specify locale for errors and messages. For example '{0}' or '{1}'": { + "code": 6022, + "category": 2 /* Message */ + }, + "Syntax: {0}": { + "code": 6023, + "category": 2 /* Message */ + }, + "options": { + "code": 6024, + "category": 2 /* Message */ + }, + "file": { + "code": 6025, + "category": 2 /* Message */ + }, + "Examples:": { + "code": 6026, + "category": 2 /* Message */ + }, + "Options:": { + "code": 6027, + "category": 2 /* Message */ + }, + "Insert command line options and files from a file.": { + "code": 6030, + "category": 2 /* Message */ + }, + "Version {0}": { + "code": 6029, + "category": 2 /* Message */ + }, + "Use the '{0}' flag to see options": { + "code": 6031, + "category": 2 /* Message */ + }, + "{NL}Recompiling ({0}):": { + "code": 6032, + "category": 2 /* Message */ + }, + "STRING": { + "code": 6033, + "category": 2 /* Message */ + }, + "KIND": { + "code": 6034, + "category": 2 /* Message */ + }, + "FILE": { + "code": 6035, + "category": 2 /* Message */ + }, + "VERSION": { + "code": 6036, + "category": 2 /* Message */ + }, + "LOCATION": { + "code": 6037, + "category": 2 /* Message */ + }, + "DIRECTORY": { + "code": 6038, + "category": 2 /* Message */ + }, + "This version of the Javascript runtime does not support the '{0}' function.": { + "code": 7000, + "category": 1 /* Error */ + }, + "Looking up path for identifier token did not result in an identifer.": { + "code": 7001, + "category": 1 /* Error */ + }, + "Unknown rule": { + "code": 7002, + "category": 1 /* Error */ + }, + "Invalid line number ({0})": { + "code": 7003, + "category": 1 /* Error */ + }, + "Warn on expressions and declarations with an implied 'any' type.": { + "code": 7004, + "category": 2 /* Message */ + }, + "Variable '{0}' implicitly has an 'any' type.": { + "code": 7005, + "category": 1 /* Error */ + }, + "Parameter '{0}' of '{1}' implicitly has an 'any' type.": { + "code": 7006, + "category": 1 /* Error */ + }, + "Parameter '{0}' of function type implicitly has an 'any' type.": { + "code": 7007, + "category": 1 /* Error */ + }, + "Member '{0}' of object type implicitly has an 'any' type.": { + "code": 7008, + "category": 1 /* Error */ + }, + "\"New\" expression, which lacks a constructor signature, implicitly has an 'any' type.": { + "code": 7009, + "category": 1 /* Error */ + }, + "'{0}', which lacks return-type annotation, implicitly has an 'any' return type.": { + "code": 7010, + "category": 1 /* Error */ + }, + "Function expression, which lacks return-type annotation, implicitly has an 'any' return type.": { + "code": 7011, + "category": 1 /* Error */ + }, + "Parameter '{0}' of lambda function implicitly has an 'any' type.": { + "code": 7012, + "category": 1 /* Error */ + }, + "Constructor signature, which lacks return-type annotation, implicitly has an 'any' return type.": { + "code": 7013, + "category": 1 /* Error */ + }, + "Lambda Function, which lacks return-type annotation, implicitly has an 'any' return type.": { + "code": 7014, + "category": 1 /* Error */ + }, + "Array Literal implicitly has an 'any' type from widening.": { + "code": 7014, + "category": 1 /* Error */ + } + }; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (CharacterCodes) { + CharacterCodes[CharacterCodes["nullCharacter"] = 0] = "nullCharacter"; + CharacterCodes[CharacterCodes["maxAsciiCharacter"] = 127] = "maxAsciiCharacter"; + + CharacterCodes[CharacterCodes["lineFeed"] = 10] = "lineFeed"; + CharacterCodes[CharacterCodes["carriageReturn"] = 13] = "carriageReturn"; + CharacterCodes[CharacterCodes["lineSeparator"] = 0x2028] = "lineSeparator"; + CharacterCodes[CharacterCodes["paragraphSeparator"] = 0x2029] = "paragraphSeparator"; + + CharacterCodes[CharacterCodes["nextLine"] = 0x0085] = "nextLine"; + + CharacterCodes[CharacterCodes["space"] = 0x0020] = "space"; + CharacterCodes[CharacterCodes["nonBreakingSpace"] = 0x00A0] = "nonBreakingSpace"; + CharacterCodes[CharacterCodes["enQuad"] = 0x2000] = "enQuad"; + CharacterCodes[CharacterCodes["emQuad"] = 0x2001] = "emQuad"; + CharacterCodes[CharacterCodes["enSpace"] = 0x2002] = "enSpace"; + CharacterCodes[CharacterCodes["emSpace"] = 0x2003] = "emSpace"; + CharacterCodes[CharacterCodes["threePerEmSpace"] = 0x2004] = "threePerEmSpace"; + CharacterCodes[CharacterCodes["fourPerEmSpace"] = 0x2005] = "fourPerEmSpace"; + CharacterCodes[CharacterCodes["sixPerEmSpace"] = 0x2006] = "sixPerEmSpace"; + CharacterCodes[CharacterCodes["figureSpace"] = 0x2007] = "figureSpace"; + CharacterCodes[CharacterCodes["punctuationSpace"] = 0x2008] = "punctuationSpace"; + CharacterCodes[CharacterCodes["thinSpace"] = 0x2009] = "thinSpace"; + CharacterCodes[CharacterCodes["hairSpace"] = 0x200A] = "hairSpace"; + CharacterCodes[CharacterCodes["zeroWidthSpace"] = 0x200B] = "zeroWidthSpace"; + CharacterCodes[CharacterCodes["narrowNoBreakSpace"] = 0x202F] = "narrowNoBreakSpace"; + CharacterCodes[CharacterCodes["ideographicSpace"] = 0x3000] = "ideographicSpace"; + + CharacterCodes[CharacterCodes["_"] = 95] = "_"; + CharacterCodes[CharacterCodes["$"] = 36] = "$"; + + CharacterCodes[CharacterCodes["_0"] = 48] = "_0"; + CharacterCodes[CharacterCodes["_9"] = 57] = "_9"; + + CharacterCodes[CharacterCodes["a"] = 97] = "a"; + CharacterCodes[CharacterCodes["b"] = 98] = "b"; + CharacterCodes[CharacterCodes["c"] = 99] = "c"; + CharacterCodes[CharacterCodes["d"] = 100] = "d"; + CharacterCodes[CharacterCodes["e"] = 101] = "e"; + CharacterCodes[CharacterCodes["f"] = 102] = "f"; + CharacterCodes[CharacterCodes["g"] = 103] = "g"; + CharacterCodes[CharacterCodes["h"] = 104] = "h"; + CharacterCodes[CharacterCodes["i"] = 105] = "i"; + CharacterCodes[CharacterCodes["k"] = 107] = "k"; + CharacterCodes[CharacterCodes["l"] = 108] = "l"; + CharacterCodes[CharacterCodes["m"] = 109] = "m"; + CharacterCodes[CharacterCodes["n"] = 110] = "n"; + CharacterCodes[CharacterCodes["o"] = 111] = "o"; + CharacterCodes[CharacterCodes["p"] = 112] = "p"; + CharacterCodes[CharacterCodes["q"] = 113] = "q"; + CharacterCodes[CharacterCodes["r"] = 114] = "r"; + CharacterCodes[CharacterCodes["s"] = 115] = "s"; + CharacterCodes[CharacterCodes["t"] = 116] = "t"; + CharacterCodes[CharacterCodes["u"] = 117] = "u"; + CharacterCodes[CharacterCodes["v"] = 118] = "v"; + CharacterCodes[CharacterCodes["w"] = 119] = "w"; + CharacterCodes[CharacterCodes["x"] = 120] = "x"; + CharacterCodes[CharacterCodes["y"] = 121] = "y"; + CharacterCodes[CharacterCodes["z"] = 122] = "z"; + + CharacterCodes[CharacterCodes["A"] = 65] = "A"; + CharacterCodes[CharacterCodes["E"] = 69] = "E"; + CharacterCodes[CharacterCodes["F"] = 70] = "F"; + CharacterCodes[CharacterCodes["X"] = 88] = "X"; + CharacterCodes[CharacterCodes["Z"] = 90] = "Z"; + + CharacterCodes[CharacterCodes["ampersand"] = 38] = "ampersand"; + CharacterCodes[CharacterCodes["asterisk"] = 42] = "asterisk"; + CharacterCodes[CharacterCodes["at"] = 64] = "at"; + CharacterCodes[CharacterCodes["backslash"] = 92] = "backslash"; + CharacterCodes[CharacterCodes["bar"] = 124] = "bar"; + CharacterCodes[CharacterCodes["caret"] = 94] = "caret"; + CharacterCodes[CharacterCodes["closeBrace"] = 125] = "closeBrace"; + CharacterCodes[CharacterCodes["closeBracket"] = 93] = "closeBracket"; + CharacterCodes[CharacterCodes["closeParen"] = 41] = "closeParen"; + CharacterCodes[CharacterCodes["colon"] = 58] = "colon"; + CharacterCodes[CharacterCodes["comma"] = 44] = "comma"; + CharacterCodes[CharacterCodes["dot"] = 46] = "dot"; + CharacterCodes[CharacterCodes["doubleQuote"] = 34] = "doubleQuote"; + CharacterCodes[CharacterCodes["equals"] = 61] = "equals"; + CharacterCodes[CharacterCodes["exclamation"] = 33] = "exclamation"; + CharacterCodes[CharacterCodes["greaterThan"] = 62] = "greaterThan"; + CharacterCodes[CharacterCodes["lessThan"] = 60] = "lessThan"; + CharacterCodes[CharacterCodes["minus"] = 45] = "minus"; + CharacterCodes[CharacterCodes["openBrace"] = 123] = "openBrace"; + CharacterCodes[CharacterCodes["openBracket"] = 91] = "openBracket"; + CharacterCodes[CharacterCodes["openParen"] = 40] = "openParen"; + CharacterCodes[CharacterCodes["percent"] = 37] = "percent"; + CharacterCodes[CharacterCodes["plus"] = 43] = "plus"; + CharacterCodes[CharacterCodes["question"] = 63] = "question"; + CharacterCodes[CharacterCodes["semicolon"] = 59] = "semicolon"; + CharacterCodes[CharacterCodes["singleQuote"] = 39] = "singleQuote"; + CharacterCodes[CharacterCodes["slash"] = 47] = "slash"; + CharacterCodes[CharacterCodes["tilde"] = 126] = "tilde"; + + CharacterCodes[CharacterCodes["backspace"] = 8] = "backspace"; + CharacterCodes[CharacterCodes["formFeed"] = 12] = "formFeed"; + CharacterCodes[CharacterCodes["byteOrderMark"] = 0xFEFF] = "byteOrderMark"; + CharacterCodes[CharacterCodes["tab"] = 9] = "tab"; + CharacterCodes[CharacterCodes["verticalTab"] = 11] = "verticalTab"; + })(TypeScript.CharacterCodes || (TypeScript.CharacterCodes = {})); + var CharacterCodes = TypeScript.CharacterCodes; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (ScriptSnapshot) { + var StringScriptSnapshot = (function () { + function StringScriptSnapshot(text) { + this.text = text; + } + StringScriptSnapshot.prototype.getText = function (start, end) { + return this.text.substring(start, end); + }; + + StringScriptSnapshot.prototype.getLength = function () { + return this.text.length; + }; + + StringScriptSnapshot.prototype.getLineStartPositions = function () { + return TypeScript.TextUtilities.parseLineStarts(TypeScript.SimpleText.fromString(this.text)); + }; + + StringScriptSnapshot.prototype.getTextChangeRangeSinceVersion = function (scriptVersion) { + throw TypeScript.Errors.notYetImplemented(); + }; + return StringScriptSnapshot; + })(); + + function fromString(text) { + return new StringScriptSnapshot(text); + } + ScriptSnapshot.fromString = fromString; + })(TypeScript.ScriptSnapshot || (TypeScript.ScriptSnapshot = {})); + var ScriptSnapshot = TypeScript.ScriptSnapshot; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var LineMap = (function () { + function LineMap(_lineStarts, length) { + this._lineStarts = _lineStarts; + this.length = length; + } + LineMap.prototype.toJSON = function (key) { + return { lineStarts: this._lineStarts, length: this.length }; + }; + + LineMap.prototype.equals = function (other) { + return this.length === other.length && TypeScript.ArrayUtilities.sequenceEquals(this.lineStarts(), other.lineStarts(), function (v1, v2) { + return v1 === v2; + }); + }; + + LineMap.prototype.lineStarts = function () { + return this._lineStarts; + }; + + LineMap.prototype.lineCount = function () { + return this.lineStarts().length; + }; + + LineMap.prototype.getPosition = function (line, character) { + return this.lineStarts()[line] + character; + }; + + LineMap.prototype.getLineNumberFromPosition = function (position) { + if (position < 0 || position > this.length) { + throw TypeScript.Errors.argumentOutOfRange("position"); + } + + if (position === this.length) { + return this.lineCount() - 1; + } + + var lineNumber = TypeScript.ArrayUtilities.binarySearch(this.lineStarts(), position); + if (lineNumber < 0) { + lineNumber = (~lineNumber) - 1; + } + + return lineNumber; + }; + + LineMap.prototype.getLineStartPosition = function (lineNumber) { + return this.lineStarts()[lineNumber]; + }; + + LineMap.prototype.fillLineAndCharacterFromPosition = function (position, lineAndCharacter) { + if (position < 0 || position > this.length) { + throw TypeScript.Errors.argumentOutOfRange("position"); + } + + var lineNumber = this.getLineNumberFromPosition(position); + lineAndCharacter.line = lineNumber; + lineAndCharacter.character = position - this.lineStarts()[lineNumber]; + }; + + LineMap.prototype.getLineAndCharacterFromPosition = function (position) { + if (position < 0 || position > this.length) { + throw TypeScript.Errors.argumentOutOfRange("position"); + } + + var lineNumber = this.getLineNumberFromPosition(position); + + return new TypeScript.LineAndCharacter(lineNumber, position - this.lineStarts()[lineNumber]); + }; + + LineMap.fromSimpleText = function (text) { + var lineStarts = TypeScript.TextUtilities.parseLineStarts(text); + + return new LineMap(lineStarts, text.length()); + }; + + LineMap.fromScriptSnapshot = function (scriptSnapshot) { + return new LineMap(scriptSnapshot.getLineStartPositions(), scriptSnapshot.getLength()); + }; + + LineMap.fromString = function (text) { + return LineMap.fromSimpleText(TypeScript.SimpleText.fromString(text)); + }; + LineMap.empty = new LineMap([0], 0); + return LineMap; + })(); + TypeScript.LineMap = LineMap; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var LineAndCharacter = (function () { + function LineAndCharacter(line, character) { + this._line = 0; + this._character = 0; + if (line < 0) { + throw TypeScript.Errors.argumentOutOfRange("line"); + } + + if (character < 0) { + throw TypeScript.Errors.argumentOutOfRange("character"); + } + + this._line = line; + this._character = character; + } + LineAndCharacter.prototype.line = function () { + return this._line; + }; + + LineAndCharacter.prototype.character = function () { + return this._character; + }; + return LineAndCharacter; + })(); + TypeScript.LineAndCharacter = LineAndCharacter; +})(TypeScript || (TypeScript = {})); +var __extends = this.__extends || function (d, b) { + for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; + function __() { this.constructor = d; } + __.prototype = b.prototype; + d.prototype = new __(); +}; +var TypeScript; +(function (TypeScript) { + (function (TextFactory) { + function getStartAndLengthOfLineBreakEndingAt(text, index, info) { + var c = text.charCodeAt(index); + if (c === 10 /* lineFeed */) { + if (index > 0 && text.charCodeAt(index - 1) === 13 /* carriageReturn */) { + info.startPosition = index - 1; + info.length = 2; + } else { + info.startPosition = index; + info.length = 1; + } + } else if (TypeScript.TextUtilities.isAnyLineBreakCharacter(c)) { + info.startPosition = index; + info.length = 1; + } else { + info.startPosition = index + 1; + info.length = 0; + } + } + + var LinebreakInfo = (function () { + function LinebreakInfo(startPosition, length) { + this.startPosition = startPosition; + this.length = length; + } + return LinebreakInfo; + })(); + + var TextLine = (function () { + function TextLine(text, body, lineBreakLength, lineNumber) { + this._text = null; + this._textSpan = null; + if (text === null) { + throw TypeScript.Errors.argumentNull('text'); + } + TypeScript.Debug.assert(lineBreakLength >= 0); + TypeScript.Debug.assert(lineNumber >= 0); + this._text = text; + this._textSpan = body; + this._lineBreakLength = lineBreakLength; + this._lineNumber = lineNumber; + } + TextLine.prototype.start = function () { + return this._textSpan.start(); + }; + + TextLine.prototype.end = function () { + return this._textSpan.end(); + }; + + TextLine.prototype.endIncludingLineBreak = function () { + return this.end() + this._lineBreakLength; + }; + + TextLine.prototype.extent = function () { + return this._textSpan; + }; + + TextLine.prototype.extentIncludingLineBreak = function () { + return TypeScript.TextSpan.fromBounds(this.start(), this.endIncludingLineBreak()); + }; + + TextLine.prototype.toString = function () { + return this._text.toString(this._textSpan); + }; + + TextLine.prototype.lineNumber = function () { + return this._lineNumber; + }; + return TextLine; + })(); + + var TextBase = (function () { + function TextBase() { + this.lazyLineStarts = null; + this.linebreakInfo = new LinebreakInfo(0, 0); + this.lastLineFoundForPosition = null; + } + TextBase.prototype.length = function () { + throw TypeScript.Errors.abstract(); + }; + + TextBase.prototype.charCodeAt = function (position) { + throw TypeScript.Errors.abstract(); + }; + + TextBase.prototype.checkSubSpan = function (span) { + if (span.start() < 0 || span.start() > this.length() || span.end() > this.length()) { + throw TypeScript.Errors.argumentOutOfRange("span"); + } + }; + + TextBase.prototype.toString = function (span) { + if (typeof span === "undefined") { span = null; } + throw TypeScript.Errors.abstract(); + }; + + TextBase.prototype.subText = function (span) { + this.checkSubSpan(span); + + return new SubText(this, span); + }; + + TextBase.prototype.substr = function (start, length, intern) { + throw TypeScript.Errors.abstract(); + }; + + TextBase.prototype.copyTo = function (sourceIndex, destination, destinationIndex, count) { + throw TypeScript.Errors.abstract(); + }; + + TextBase.prototype.lineCount = function () { + return this.lineStarts().length; + }; + + TextBase.prototype.lines = function () { + var lines = []; + + var length = this.lineCount(); + for (var i = 0; i < length; ++i) { + lines[i] = this.getLineFromLineNumber(i); + } + + return lines; + }; + + TextBase.prototype.lineMap = function () { + return new TypeScript.LineMap(this.lineStarts(), this.length()); + }; + + TextBase.prototype.lineStarts = function () { + if (this.lazyLineStarts === null) { + this.lazyLineStarts = TypeScript.TextUtilities.parseLineStarts(this); + } + + return this.lazyLineStarts; + }; + + TextBase.prototype.getLineFromLineNumber = function (lineNumber) { + var lineStarts = this.lineStarts(); + + if (lineNumber < 0 || lineNumber >= lineStarts.length) { + throw TypeScript.Errors.argumentOutOfRange("lineNumber"); + } + + var first = lineStarts[lineNumber]; + if (lineNumber === lineStarts.length - 1) { + return new TextLine(this, new TypeScript.TextSpan(first, this.length() - first), 0, lineNumber); + } else { + getStartAndLengthOfLineBreakEndingAt(this, lineStarts[lineNumber + 1] - 1, this.linebreakInfo); + return new TextLine(this, new TypeScript.TextSpan(first, this.linebreakInfo.startPosition - first), this.linebreakInfo.length, lineNumber); + } + }; + + TextBase.prototype.getLineFromPosition = function (position) { + var lastFound = this.lastLineFoundForPosition; + if (lastFound !== null && lastFound.start() <= position && lastFound.endIncludingLineBreak() > position) { + return lastFound; + } + + var lineNumber = this.getLineNumberFromPosition(position); + + var result = this.getLineFromLineNumber(lineNumber); + this.lastLineFoundForPosition = result; + return result; + }; + + TextBase.prototype.getLineNumberFromPosition = function (position) { + if (position < 0 || position > this.length()) { + throw TypeScript.Errors.argumentOutOfRange("position"); + } + + if (position === this.length()) { + return this.lineCount() - 1; + } + + var lineNumber = TypeScript.ArrayUtilities.binarySearch(this.lineStarts(), position); + if (lineNumber < 0) { + lineNumber = (~lineNumber) - 1; + } + + return lineNumber; + }; + + TextBase.prototype.getLinePosition = function (position) { + if (position < 0 || position > this.length()) { + throw TypeScript.Errors.argumentOutOfRange("position"); + } + + var lineNumber = this.getLineNumberFromPosition(position); + + return new TypeScript.LineAndCharacter(lineNumber, position - this.lineStarts()[lineNumber]); + }; + return TextBase; + })(); + + var SubText = (function (_super) { + __extends(SubText, _super); + function SubText(text, span) { + _super.call(this); + + if (text === null) { + throw TypeScript.Errors.argumentNull("text"); + } + + if (span.start() < 0 || span.start() >= text.length() || span.end() < 0 || span.end() > text.length()) { + throw TypeScript.Errors.argument("span"); + } + + this.text = text; + this.span = span; + } + SubText.prototype.length = function () { + return this.span.length(); + }; + + SubText.prototype.charCodeAt = function (position) { + if (position < 0 || position > this.length()) { + throw TypeScript.Errors.argumentOutOfRange("position"); + } + + return this.text.charCodeAt(this.span.start() + position); + }; + + SubText.prototype.subText = function (span) { + this.checkSubSpan(span); + + return new SubText(this.text, this.getCompositeSpan(span.start(), span.length())); + }; + + SubText.prototype.copyTo = function (sourceIndex, destination, destinationIndex, count) { + var span = this.getCompositeSpan(sourceIndex, count); + this.text.copyTo(span.start(), destination, destinationIndex, span.length()); + }; + + SubText.prototype.getCompositeSpan = function (start, length) { + var compositeStart = TypeScript.MathPrototype.min(this.text.length(), this.span.start() + start); + var compositeEnd = TypeScript.MathPrototype.min(this.text.length(), compositeStart + length); + return new TypeScript.TextSpan(compositeStart, compositeEnd - compositeStart); + }; + return SubText; + })(TextBase); + + var StringText = (function (_super) { + __extends(StringText, _super); + function StringText(data) { + _super.call(this); + this.source = null; + + if (data === null) { + throw TypeScript.Errors.argumentNull("data"); + } + + this.source = data; + } + StringText.prototype.length = function () { + return this.source.length; + }; + + StringText.prototype.charCodeAt = function (position) { + if (position < 0 || position >= this.source.length) { + throw TypeScript.Errors.argumentOutOfRange("position"); + } + + return this.source.charCodeAt(position); + }; + + StringText.prototype.substr = function (start, length, intern) { + return this.source.substr(start, length); + }; + + StringText.prototype.toString = function (span) { + if (typeof span === "undefined") { span = null; } + if (span === null) { + span = new TypeScript.TextSpan(0, this.length()); + } + + this.checkSubSpan(span); + + if (span.start() === 0 && span.length() === this.length()) { + return this.source; + } + + return this.source.substr(span.start(), span.length()); + }; + + StringText.prototype.copyTo = function (sourceIndex, destination, destinationIndex, count) { + TypeScript.StringUtilities.copyTo(this.source, sourceIndex, destination, destinationIndex, count); + }; + return StringText; + })(TextBase); + + function createText(value) { + return new StringText(value); + } + TextFactory.createText = createText; + })(TypeScript.TextFactory || (TypeScript.TextFactory = {})); + var TextFactory = TypeScript.TextFactory; +})(TypeScript || (TypeScript = {})); + +var TypeScript; +(function (TypeScript) { + (function (SimpleText) { + var SimpleSubText = (function () { + function SimpleSubText(text, span) { + this.text = null; + this.span = null; + if (text === null) { + throw TypeScript.Errors.argumentNull("text"); + } + + if (span.start() < 0 || span.start() >= text.length() || span.end() < 0 || span.end() > text.length()) { + throw TypeScript.Errors.argument("span"); + } + + this.text = text; + this.span = span; + } + SimpleSubText.prototype.checkSubSpan = function (span) { + if (span.start() < 0 || span.start() > this.length() || span.end() > this.length()) { + throw TypeScript.Errors.argumentOutOfRange("span"); + } + }; + + SimpleSubText.prototype.checkSubPosition = function (position) { + if (position < 0 || position >= this.length()) { + throw TypeScript.Errors.argumentOutOfRange("position"); + } + }; + + SimpleSubText.prototype.length = function () { + return this.span.length(); + }; + + SimpleSubText.prototype.subText = function (span) { + this.checkSubSpan(span); + + return new SimpleSubText(this.text, this.getCompositeSpan(span.start(), span.length())); + }; + + SimpleSubText.prototype.copyTo = function (sourceIndex, destination, destinationIndex, count) { + var span = this.getCompositeSpan(sourceIndex, count); + this.text.copyTo(span.start(), destination, destinationIndex, span.length()); + }; + + SimpleSubText.prototype.substr = function (start, length, intern) { + var span = this.getCompositeSpan(start, length); + return this.text.substr(span.start(), span.length(), intern); + }; + + SimpleSubText.prototype.getCompositeSpan = function (start, length) { + var compositeStart = TypeScript.MathPrototype.min(this.text.length(), this.span.start() + start); + var compositeEnd = TypeScript.MathPrototype.min(this.text.length(), compositeStart + length); + return new TypeScript.TextSpan(compositeStart, compositeEnd - compositeStart); + }; + + SimpleSubText.prototype.charCodeAt = function (index) { + this.checkSubPosition(index); + return this.text.charCodeAt(this.span.start() + index); + }; + + SimpleSubText.prototype.lineMap = function () { + return TypeScript.LineMap.fromSimpleText(this); + }; + return SimpleSubText; + })(); + + var SimpleStringText = (function () { + function SimpleStringText(value) { + this.value = value; + } + SimpleStringText.prototype.length = function () { + return this.value.length; + }; + + SimpleStringText.prototype.copyTo = function (sourceIndex, destination, destinationIndex, count) { + TypeScript.StringUtilities.copyTo(this.value, sourceIndex, destination, destinationIndex, count); + }; + + SimpleStringText.prototype.substr = function (start, length, intern) { + if (intern) { + var array = length <= SimpleStringText.charArray.length ? SimpleStringText.charArray : TypeScript.ArrayUtilities.createArray(length, 0); + this.copyTo(start, array, 0, length); + return TypeScript.Collections.DefaultStringTable.addCharArray(array, 0, length); + } + + return this.value.substr(start, length); + }; + + SimpleStringText.prototype.subText = function (span) { + return new SimpleSubText(this, span); + }; + + SimpleStringText.prototype.charCodeAt = function (index) { + return this.value.charCodeAt(index); + }; + + SimpleStringText.prototype.lineMap = function () { + return TypeScript.LineMap.fromSimpleText(this); + }; + SimpleStringText.charArray = TypeScript.ArrayUtilities.createArray(1024, 0); + return SimpleStringText; + })(); + + var SimpleScriptSnapshotText = (function () { + function SimpleScriptSnapshotText(scriptSnapshot) { + this.scriptSnapshot = scriptSnapshot; + } + SimpleScriptSnapshotText.prototype.charCodeAt = function (index) { + return this.scriptSnapshot.getText(index, index + 1).charCodeAt(0); + }; + + SimpleScriptSnapshotText.prototype.length = function () { + return this.scriptSnapshot.getLength(); + }; + + SimpleScriptSnapshotText.prototype.copyTo = function (sourceIndex, destination, destinationIndex, count) { + var text = this.scriptSnapshot.getText(sourceIndex, sourceIndex + count); + TypeScript.StringUtilities.copyTo(text, 0, destination, destinationIndex, count); + }; + + SimpleScriptSnapshotText.prototype.substr = function (start, length, intern) { + return this.scriptSnapshot.getText(start, start + length); + }; + + SimpleScriptSnapshotText.prototype.subText = function (span) { + return new SimpleSubText(this, span); + }; + + SimpleScriptSnapshotText.prototype.lineMap = function () { + var lineStartPositions = this.scriptSnapshot.getLineStartPositions(); + return new TypeScript.LineMap(lineStartPositions, this.length()); + }; + return SimpleScriptSnapshotText; + })(); + + function fromString(value) { + return new SimpleStringText(value); + } + SimpleText.fromString = fromString; + + function fromScriptSnapshot(scriptSnapshot) { + return new SimpleScriptSnapshotText(scriptSnapshot); + } + SimpleText.fromScriptSnapshot = fromScriptSnapshot; + })(TypeScript.SimpleText || (TypeScript.SimpleText = {})); + var SimpleText = TypeScript.SimpleText; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (TextUtilities) { + function parseLineStarts(text) { + var length = text.length(); + + if (0 === length) { + var result = new Array(); + result.push(0); + return result; + } + + var position = 0; + var index = 0; + var arrayBuilder = new Array(); + var lineNumber = 0; + + while (index < length) { + var c = text.charCodeAt(index); + var lineBreakLength; + + if (c > 13 /* carriageReturn */ && c <= 127) { + index++; + continue; + } else if (c === 13 /* carriageReturn */ && index + 1 < length && text.charCodeAt(index + 1) === 10 /* lineFeed */) { + lineBreakLength = 2; + } else if (c === 10 /* lineFeed */) { + lineBreakLength = 1; + } else { + lineBreakLength = TextUtilities.getLengthOfLineBreak(text, index); + } + + if (0 === lineBreakLength) { + index++; + } else { + arrayBuilder.push(position); + index += lineBreakLength; + position = index; + lineNumber++; + } + } + + arrayBuilder.push(position); + + return arrayBuilder; + } + TextUtilities.parseLineStarts = parseLineStarts; + + function getLengthOfLineBreakSlow(text, index, c) { + if (c === 13 /* carriageReturn */) { + var next = index + 1; + return (next < text.length()) && 10 /* lineFeed */ === text.charCodeAt(next) ? 2 : 1; + } else if (isAnyLineBreakCharacter(c)) { + return 1; + } else { + return 0; + } + } + TextUtilities.getLengthOfLineBreakSlow = getLengthOfLineBreakSlow; + + function getLengthOfLineBreak(text, index) { + var c = text.charCodeAt(index); + + if (c > 13 /* carriageReturn */ && c <= 127) { + return 0; + } + + return getLengthOfLineBreakSlow(text, index, c); + } + TextUtilities.getLengthOfLineBreak = getLengthOfLineBreak; + + function isAnyLineBreakCharacter(c) { + return c === 10 /* lineFeed */ || c === 13 /* carriageReturn */ || c === 133 /* nextLine */ || c === 8232 /* lineSeparator */ || c === 8233 /* paragraphSeparator */; + } + TextUtilities.isAnyLineBreakCharacter = isAnyLineBreakCharacter; + })(TypeScript.TextUtilities || (TypeScript.TextUtilities = {})); + var TextUtilities = TypeScript.TextUtilities; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var TextSpan = (function () { + function TextSpan(start, length) { + if (start < 0) { + TypeScript.Errors.argument("start"); + } + + if (length < 0) { + TypeScript.Errors.argument("length"); + } + + this._start = start; + this._length = length; + } + TextSpan.prototype.start = function () { + return this._start; + }; + + TextSpan.prototype.length = function () { + return this._length; + }; + + TextSpan.prototype.end = function () { + return this._start + this._length; + }; + + TextSpan.prototype.isEmpty = function () { + return this._length === 0; + }; + + TextSpan.prototype.containsPosition = function (position) { + return position >= this._start && position < this.end(); + }; + + TextSpan.prototype.containsTextSpan = function (span) { + return span._start >= this._start && span.end() <= this.end(); + }; + + TextSpan.prototype.overlapsWith = function (span) { + var overlapStart = TypeScript.MathPrototype.max(this._start, span._start); + var overlapEnd = TypeScript.MathPrototype.min(this.end(), span.end()); + + return overlapStart < overlapEnd; + }; + + TextSpan.prototype.overlap = function (span) { + var overlapStart = TypeScript.MathPrototype.max(this._start, span._start); + var overlapEnd = TypeScript.MathPrototype.min(this.end(), span.end()); + + if (overlapStart < overlapEnd) { + return TextSpan.fromBounds(overlapStart, overlapEnd); + } + + return null; + }; + + TextSpan.prototype.intersectsWithTextSpan = function (span) { + return span._start <= this.end() && span.end() >= this._start; + }; + + TextSpan.prototype.intersectsWith = function (start, length) { + var end = start + length; + return start <= this.end() && end >= this._start; + }; + + TextSpan.prototype.intersectsWithPosition = function (position) { + return position <= this.end() && position >= this._start; + }; + + TextSpan.prototype.intersection = function (span) { + var intersectStart = TypeScript.MathPrototype.max(this._start, span._start); + var intersectEnd = TypeScript.MathPrototype.min(this.end(), span.end()); + + if (intersectStart <= intersectEnd) { + return TextSpan.fromBounds(intersectStart, intersectEnd); + } + + return null; + }; + + TextSpan.fromBounds = function (start, end) { + TypeScript.Debug.assert(start >= 0); + TypeScript.Debug.assert(end - start >= 0); + return new TextSpan(start, end - start); + }; + return TextSpan; + })(); + TypeScript.TextSpan = TextSpan; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var TextChangeRange = (function () { + function TextChangeRange(span, newLength) { + if (newLength < 0) { + throw TypeScript.Errors.argumentOutOfRange("newLength"); + } + + this._span = span; + this._newLength = newLength; + } + TextChangeRange.prototype.span = function () { + return this._span; + }; + + TextChangeRange.prototype.newLength = function () { + return this._newLength; + }; + + TextChangeRange.prototype.newSpan = function () { + return new TypeScript.TextSpan(this.span().start(), this.newLength()); + }; + + TextChangeRange.prototype.isUnchanged = function () { + return this.span().isEmpty() && this.newLength() === 0; + }; + + TextChangeRange.collapseChangesFromSingleVersion = function (changes) { + var diff = 0; + var start = 1073741823 /* Max31BitInteger */; + var end = 0; + + for (var i = 0; i < changes.length; i++) { + var change = changes[i]; + diff += change.newLength() - change.span().length(); + + if (change.span().start() < start) { + start = change.span().start(); + } + + if (change.span().end() > end) { + end = change.span().end(); + } + } + + if (start > end) { + return null; + } + + var combined = TypeScript.TextSpan.fromBounds(start, end); + var newLen = combined.length() + diff; + + return new TextChangeRange(combined, newLen); + }; + + TextChangeRange.collapseChangesAcrossMultipleVersions = function (changes) { + if (changes.length === 0) { + return TextChangeRange.unchanged; + } + + if (changes.length === 1) { + return changes[0]; + } + + 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]; + + 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 = TypeScript.MathPrototype.min(oldStart1, oldStart2); + oldEndN = TypeScript.MathPrototype.max(oldEnd1, oldEnd1 + (oldEnd2 - newEnd1)); + newEndN = TypeScript.MathPrototype.max(newEnd2, newEnd2 + (newEnd1 - oldEnd2)); + } + + return new TextChangeRange(TypeScript.TextSpan.fromBounds(oldStartN, oldEndN), newEndN - oldStartN); + }; + TextChangeRange.unchanged = new TextChangeRange(new TypeScript.TextSpan(0, 0), 0); + return TextChangeRange; + })(); + TypeScript.TextChangeRange = TextChangeRange; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var CharacterInfo = (function () { + function CharacterInfo() { + } + CharacterInfo.isDecimalDigit = function (c) { + return c >= 48 /* _0 */ && c <= 57 /* _9 */; + }; + + CharacterInfo.isHexDigit = function (c) { + return CharacterInfo.isDecimalDigit(c) || (c >= 65 /* A */ && c <= 70 /* F */) || (c >= 97 /* a */ && c <= 102 /* f */); + }; + + CharacterInfo.hexValue = function (c) { + return CharacterInfo.isDecimalDigit(c) ? (c - 48 /* _0 */) : (c >= 65 /* A */ && c <= 70 /* F */) ? c - 65 /* A */ + 10 : c - 97 /* a */ + 10; + }; + + CharacterInfo.isWhitespace = function (ch) { + switch (ch) { + case 32 /* space */: + case 160 /* nonBreakingSpace */: + case 8192 /* enQuad */: + case 8193 /* emQuad */: + case 8194 /* enSpace */: + case 8195 /* emSpace */: + case 8196 /* threePerEmSpace */: + case 8197 /* fourPerEmSpace */: + case 8198 /* sixPerEmSpace */: + case 8199 /* figureSpace */: + case 8200 /* punctuationSpace */: + case 8201 /* thinSpace */: + case 8202 /* hairSpace */: + case 8203 /* zeroWidthSpace */: + case 8239 /* narrowNoBreakSpace */: + case 12288 /* ideographicSpace */: + + case 9 /* tab */: + case 11 /* verticalTab */: + case 12 /* formFeed */: + case 65279 /* byteOrderMark */: + return true; + } + + return false; + }; + + CharacterInfo.isLineTerminator = function (ch) { + switch (ch) { + case 13 /* carriageReturn */: + case 10 /* lineFeed */: + case 8233 /* paragraphSeparator */: + case 8232 /* lineSeparator */: + return true; + } + + return false; + }; + return CharacterInfo; + })(); + TypeScript.CharacterInfo = CharacterInfo; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (SyntaxConstants) { + SyntaxConstants[SyntaxConstants["TriviaNewLineMask"] = 0x00000001] = "TriviaNewLineMask"; + SyntaxConstants[SyntaxConstants["TriviaCommentMask"] = 0x00000002] = "TriviaCommentMask"; + SyntaxConstants[SyntaxConstants["TriviaFullWidthShift"] = 2] = "TriviaFullWidthShift"; + + SyntaxConstants[SyntaxConstants["NodeDataComputed"] = 0x00000001] = "NodeDataComputed"; + SyntaxConstants[SyntaxConstants["NodeIncrementallyUnusableMask"] = 0x00000002] = "NodeIncrementallyUnusableMask"; + SyntaxConstants[SyntaxConstants["NodeParsedInStrictModeMask"] = 0x00000004] = "NodeParsedInStrictModeMask"; + SyntaxConstants[SyntaxConstants["NodeFullWidthShift"] = 3] = "NodeFullWidthShift"; + })(TypeScript.SyntaxConstants || (TypeScript.SyntaxConstants = {})); + var SyntaxConstants = TypeScript.SyntaxConstants; +})(TypeScript || (TypeScript = {})); +var FormattingOptions = (function () { + function FormattingOptions(useTabs, spacesPerTab, indentSpaces, newLineCharacter) { + this.useTabs = useTabs; + this.spacesPerTab = spacesPerTab; + this.indentSpaces = indentSpaces; + this.newLineCharacter = newLineCharacter; + } + FormattingOptions.defaultOptions = new FormattingOptions(false, 4, 4, "\r\n"); + return FormattingOptions; +})(); +var TypeScript; +(function (TypeScript) { + (function (Indentation) { + function columnForEndOfToken(token, syntaxInformationMap, options) { + return columnForStartOfToken(token, syntaxInformationMap, options) + token.width(); + } + Indentation.columnForEndOfToken = columnForEndOfToken; + + function columnForStartOfToken(token, syntaxInformationMap, options) { + var firstTokenInLine = syntaxInformationMap.firstTokenInLineContainingToken(token); + var leadingTextInReverse = []; + + var current = token; + while (current !== firstTokenInLine) { + current = syntaxInformationMap.previousToken(current); + + if (current === firstTokenInLine) { + leadingTextInReverse.push(current.trailingTrivia().fullText()); + leadingTextInReverse.push(current.text()); + } else { + leadingTextInReverse.push(current.fullText()); + } + } + + collectLeadingTriviaTextToStartOfLine(firstTokenInLine, leadingTextInReverse); + + return columnForLeadingTextInReverse(leadingTextInReverse, options); + } + Indentation.columnForStartOfToken = columnForStartOfToken; + + function columnForStartOfFirstTokenInLineContainingToken(token, syntaxInformationMap, options) { + var firstTokenInLine = syntaxInformationMap.firstTokenInLineContainingToken(token); + var leadingTextInReverse = []; + + collectLeadingTriviaTextToStartOfLine(firstTokenInLine, leadingTextInReverse); + + return columnForLeadingTextInReverse(leadingTextInReverse, options); + } + Indentation.columnForStartOfFirstTokenInLineContainingToken = columnForStartOfFirstTokenInLineContainingToken; + + function collectLeadingTriviaTextToStartOfLine(firstTokenInLine, leadingTextInReverse) { + var leadingTrivia = firstTokenInLine.leadingTrivia(); + + for (var i = leadingTrivia.count() - 1; i >= 0; i--) { + var trivia = leadingTrivia.syntaxTriviaAt(i); + if (trivia.kind() === 5 /* NewLineTrivia */) { + break; + } + + if (trivia.kind() === 6 /* MultiLineCommentTrivia */) { + var lineSegments = TypeScript.Syntax.splitMultiLineCommentTriviaIntoMultipleLines(trivia); + leadingTextInReverse.push(TypeScript.ArrayUtilities.last(lineSegments)); + + if (lineSegments.length > 0) { + break; + } + } + + leadingTextInReverse.push(trivia.fullText()); + } + } + + function columnForLeadingTextInReverse(leadingTextInReverse, options) { + var column = 0; + + for (var i = leadingTextInReverse.length - 1; i >= 0; i--) { + var text = leadingTextInReverse[i]; + column = columnForPositionInStringWorker(text, text.length, column, options); + } + + return column; + } + + function columnForPositionInString(input, position, options) { + return columnForPositionInStringWorker(input, position, 0, options); + } + Indentation.columnForPositionInString = columnForPositionInString; + + function columnForPositionInStringWorker(input, position, startColumn, options) { + var column = startColumn; + var spacesPerTab = options.spacesPerTab; + + for (var j = 0; j < position; j++) { + var ch = input.charCodeAt(j); + + if (ch === 9 /* tab */) { + column += spacesPerTab - column % spacesPerTab; + } else { + column++; + } + } + + return column; + } + + function indentationString(column, options) { + var numberOfTabs = 0; + var numberOfSpaces = TypeScript.MathPrototype.max(0, column); + + if (options.useTabs) { + numberOfTabs = Math.floor(column / options.spacesPerTab); + numberOfSpaces -= numberOfTabs * options.spacesPerTab; + } + + return TypeScript.StringUtilities.repeat('\t', numberOfTabs) + TypeScript.StringUtilities.repeat(' ', numberOfSpaces); + } + Indentation.indentationString = indentationString; + + function indentationTrivia(column, options) { + return TypeScript.Syntax.whitespace(this.indentationString(column, options)); + } + Indentation.indentationTrivia = indentationTrivia; + + function firstNonWhitespacePosition(value) { + for (var i = 0; i < value.length; i++) { + var ch = value.charCodeAt(i); + if (!TypeScript.CharacterInfo.isWhitespace(ch)) { + return i; + } + } + + return value.length; + } + Indentation.firstNonWhitespacePosition = firstNonWhitespacePosition; + })(TypeScript.Indentation || (TypeScript.Indentation = {})); + var Indentation = TypeScript.Indentation; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (LanguageVersion) { + LanguageVersion[LanguageVersion["EcmaScript3"] = 0] = "EcmaScript3"; + LanguageVersion[LanguageVersion["EcmaScript5"] = 1] = "EcmaScript5"; + })(TypeScript.LanguageVersion || (TypeScript.LanguageVersion = {})); + var LanguageVersion = TypeScript.LanguageVersion; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var ParseOptions = (function () { + function ParseOptions(languageVersion, allowAutomaticSemicolonInsertion) { + this._languageVersion = languageVersion; + this._allowAutomaticSemicolonInsertion = allowAutomaticSemicolonInsertion; + } + ParseOptions.prototype.toJSON = function (key) { + return { allowAutomaticSemicolonInsertion: this._allowAutomaticSemicolonInsertion }; + }; + + ParseOptions.prototype.languageVersion = function () { + return this._languageVersion; + }; + + ParseOptions.prototype.allowAutomaticSemicolonInsertion = function () { + return this._allowAutomaticSemicolonInsertion; + }; + return ParseOptions; + })(); + TypeScript.ParseOptions = ParseOptions; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var PositionedElement = (function () { + function PositionedElement(parent, element, fullStart) { + this._parent = parent; + this._element = element; + this._fullStart = fullStart; + } + PositionedElement.create = function (parent, element, fullStart) { + if (element === null) { + return null; + } + + if (element.isNode()) { + return new PositionedNode(parent, element, fullStart); + } else if (element.isToken()) { + return new PositionedToken(parent, element, fullStart); + } else if (element.isList()) { + return new PositionedList(parent, element, fullStart); + } else if (element.isSeparatedList()) { + return new PositionedSeparatedList(parent, element, fullStart); + } else { + throw TypeScript.Errors.invalidOperation(); + } + }; + + PositionedElement.prototype.parent = function () { + return this._parent; + }; + + PositionedElement.prototype.parentElement = function () { + return this._parent && this._parent._element; + }; + + PositionedElement.prototype.element = function () { + return this._element; + }; + + PositionedElement.prototype.kind = function () { + return this.element().kind(); + }; + + PositionedElement.prototype.childIndex = function (child) { + return TypeScript.Syntax.childIndex(this.element(), child); + }; + + PositionedElement.prototype.childCount = function () { + return this.element().childCount(); + }; + + PositionedElement.prototype.childAt = function (index) { + var offset = TypeScript.Syntax.childOffsetAt(this.element(), index); + return PositionedElement.create(this, this.element().childAt(index), this.fullStart() + offset); + }; + + PositionedElement.prototype.childStart = function (child) { + var offset = TypeScript.Syntax.childOffset(this.element(), child); + return this.fullStart() + offset + child.leadingTriviaWidth(); + }; + + PositionedElement.prototype.childEnd = function (child) { + var offset = TypeScript.Syntax.childOffset(this.element(), child); + return this.fullStart() + offset + child.leadingTriviaWidth() + child.width(); + }; + + PositionedElement.prototype.childStartAt = function (index) { + var offset = TypeScript.Syntax.childOffsetAt(this.element(), index); + var child = this.element().childAt(index); + return this.fullStart() + offset + child.leadingTriviaWidth(); + }; + + PositionedElement.prototype.childEndAt = function (index) { + var offset = TypeScript.Syntax.childOffsetAt(this.element(), index); + var child = this.element().childAt(index); + return this.fullStart() + offset + child.leadingTriviaWidth() + child.width(); + }; + + PositionedElement.prototype.getPositionedChild = function (child) { + var offset = TypeScript.Syntax.childOffset(this.element(), child); + return PositionedElement.create(this, child, this.fullStart() + offset); + }; + + PositionedElement.prototype.fullStart = function () { + return this._fullStart; + }; + + PositionedElement.prototype.fullEnd = function () { + return this.fullStart() + this.element().fullWidth(); + }; + + PositionedElement.prototype.fullWidth = function () { + return this.element().fullWidth(); + }; + + PositionedElement.prototype.start = function () { + return this.fullStart() + this.element().leadingTriviaWidth(); + }; + + PositionedElement.prototype.end = function () { + return this.fullStart() + this.element().leadingTriviaWidth() + this.element().width(); + }; + + PositionedElement.prototype.root = function () { + var current = this; + while (current.parent() !== null) { + current = current.parent(); + } + + return current; + }; + + PositionedElement.prototype.containingNode = function () { + var current = this.parent(); + + while (current !== null && !current.element().isNode()) { + current = current.parent(); + } + + return current; + }; + return PositionedElement; + })(); + TypeScript.PositionedElement = PositionedElement; + + var PositionedNodeOrToken = (function (_super) { + __extends(PositionedNodeOrToken, _super); + function PositionedNodeOrToken(parent, nodeOrToken, fullStart) { + _super.call(this, parent, nodeOrToken, fullStart); + } + PositionedNodeOrToken.prototype.nodeOrToken = function () { + return this.element(); + }; + return PositionedNodeOrToken; + })(PositionedElement); + TypeScript.PositionedNodeOrToken = PositionedNodeOrToken; + + var PositionedNode = (function (_super) { + __extends(PositionedNode, _super); + function PositionedNode(parent, node, fullStart) { + _super.call(this, parent, node, fullStart); + } + PositionedNode.prototype.node = function () { + return this.element(); + }; + return PositionedNode; + })(PositionedNodeOrToken); + TypeScript.PositionedNode = PositionedNode; + + var PositionedToken = (function (_super) { + __extends(PositionedToken, _super); + function PositionedToken(parent, token, fullStart) { + _super.call(this, parent, token, fullStart); + } + PositionedToken.prototype.token = function () { + return this.element(); + }; + + PositionedToken.prototype.previousToken = function (includeSkippedTokens) { + if (typeof includeSkippedTokens === "undefined") { includeSkippedTokens = false; } + var triviaList = this.token().leadingTrivia(); + if (includeSkippedTokens && triviaList && triviaList.hasSkippedToken()) { + var currentTriviaEndPosition = this.start(); + for (var i = triviaList.count() - 1; i >= 0; i--) { + var trivia = triviaList.syntaxTriviaAt(i); + if (trivia.isSkippedToken()) { + return new PositionedSkippedToken(this, trivia.skippedToken(), currentTriviaEndPosition - trivia.fullWidth()); + } + + currentTriviaEndPosition -= trivia.fullWidth(); + } + } + + var start = this.fullStart(); + if (start === 0) { + return null; + } + + return this.root().node().findToken(start - 1, includeSkippedTokens); + }; + + PositionedToken.prototype.nextToken = function (includeSkippedTokens) { + if (typeof includeSkippedTokens === "undefined") { includeSkippedTokens = false; } + if (this.token().tokenKind === 10 /* EndOfFileToken */) { + return null; + } + + var triviaList = this.token().trailingTrivia(); + if (includeSkippedTokens && triviaList && triviaList.hasSkippedToken()) { + var fullStart = this.end(); + for (var i = 0, n = triviaList.count(); i < n; i++) { + var trivia = triviaList.syntaxTriviaAt(i); + if (trivia.isSkippedToken()) { + return new PositionedSkippedToken(this, trivia.skippedToken(), fullStart); + } + + fullStart += trivia.fullWidth(); + } + } + + return this.root().node().findToken(this.fullEnd(), includeSkippedTokens); + }; + return PositionedToken; + })(PositionedNodeOrToken); + TypeScript.PositionedToken = PositionedToken; + + var PositionedList = (function (_super) { + __extends(PositionedList, _super); + function PositionedList(parent, list, fullStart) { + _super.call(this, parent, list, fullStart); + } + PositionedList.prototype.list = function () { + return this.element(); + }; + return PositionedList; + })(PositionedElement); + TypeScript.PositionedList = PositionedList; + + var PositionedSeparatedList = (function (_super) { + __extends(PositionedSeparatedList, _super); + function PositionedSeparatedList(parent, list, fullStart) { + _super.call(this, parent, list, fullStart); + } + PositionedSeparatedList.prototype.list = function () { + return this.element(); + }; + return PositionedSeparatedList; + })(PositionedElement); + TypeScript.PositionedSeparatedList = PositionedSeparatedList; + + var PositionedSkippedToken = (function (_super) { + __extends(PositionedSkippedToken, _super); + function PositionedSkippedToken(parentToken, token, fullStart) { + _super.call(this, parentToken.parent(), token, fullStart); + this._parentToken = parentToken; + } + PositionedSkippedToken.prototype.parentToken = function () { + return this._parentToken; + }; + + PositionedSkippedToken.prototype.previousToken = function (includeSkippedTokens) { + if (typeof includeSkippedTokens === "undefined") { includeSkippedTokens = false; } + var start = this.fullStart(); + + if (includeSkippedTokens) { + var previousToken; + + if (start >= this.parentToken().end()) { + previousToken = TypeScript.Syntax.findSkippedTokenInTrailingTriviaList(this.parentToken(), start - 1); + + if (previousToken) { + return previousToken; + } + + return this.parentToken(); + } else { + previousToken = TypeScript.Syntax.findSkippedTokenInLeadingTriviaList(this.parentToken(), start - 1); + + if (previousToken) { + return previousToken; + } + } + } + + var start = this.parentToken().fullStart(); + if (start === 0) { + return null; + } + + return this.root().node().findToken(start - 1, includeSkippedTokens); + }; + + PositionedSkippedToken.prototype.nextToken = function (includeSkippedTokens) { + if (typeof includeSkippedTokens === "undefined") { includeSkippedTokens = false; } + if (this.token().tokenKind === 10 /* EndOfFileToken */) { + return null; + } + + if (includeSkippedTokens) { + var end = this.end(); + var nextToken; + + if (end <= this.parentToken().start()) { + nextToken = TypeScript.Syntax.findSkippedTokenInLeadingTriviaList(this.parentToken(), end); + + if (nextToken) { + return nextToken; + } + + return this.parentToken(); + } else { + nextToken = TypeScript.Syntax.findSkippedTokenInTrailingTriviaList(this.parentToken(), end); + + if (nextToken) { + return nextToken; + } + } + } + + return this.root().node().findToken(this.parentToken().fullEnd(), includeSkippedTokens); + }; + return PositionedSkippedToken; + })(PositionedToken); + TypeScript.PositionedSkippedToken = PositionedSkippedToken; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (SyntaxKind) { + SyntaxKind[SyntaxKind["None"] = 0] = "None"; + SyntaxKind[SyntaxKind["List"] = 1] = "List"; + SyntaxKind[SyntaxKind["SeparatedList"] = 2] = "SeparatedList"; + SyntaxKind[SyntaxKind["TriviaList"] = 3] = "TriviaList"; + + SyntaxKind[SyntaxKind["WhitespaceTrivia"] = 4] = "WhitespaceTrivia"; + SyntaxKind[SyntaxKind["NewLineTrivia"] = 5] = "NewLineTrivia"; + SyntaxKind[SyntaxKind["MultiLineCommentTrivia"] = 6] = "MultiLineCommentTrivia"; + SyntaxKind[SyntaxKind["SingleLineCommentTrivia"] = 7] = "SingleLineCommentTrivia"; + SyntaxKind[SyntaxKind["SkippedTokenTrivia"] = 8] = "SkippedTokenTrivia"; + + SyntaxKind[SyntaxKind["ErrorToken"] = 9] = "ErrorToken"; + SyntaxKind[SyntaxKind["EndOfFileToken"] = 10] = "EndOfFileToken"; + + SyntaxKind[SyntaxKind["IdentifierName"] = 11] = "IdentifierName"; + + SyntaxKind[SyntaxKind["RegularExpressionLiteral"] = 12] = "RegularExpressionLiteral"; + SyntaxKind[SyntaxKind["NumericLiteral"] = 13] = "NumericLiteral"; + SyntaxKind[SyntaxKind["StringLiteral"] = 14] = "StringLiteral"; + + SyntaxKind[SyntaxKind["BreakKeyword"] = 15] = "BreakKeyword"; + SyntaxKind[SyntaxKind["CaseKeyword"] = 16] = "CaseKeyword"; + SyntaxKind[SyntaxKind["CatchKeyword"] = 17] = "CatchKeyword"; + SyntaxKind[SyntaxKind["ContinueKeyword"] = 18] = "ContinueKeyword"; + SyntaxKind[SyntaxKind["DebuggerKeyword"] = 19] = "DebuggerKeyword"; + SyntaxKind[SyntaxKind["DefaultKeyword"] = 20] = "DefaultKeyword"; + SyntaxKind[SyntaxKind["DeleteKeyword"] = 21] = "DeleteKeyword"; + SyntaxKind[SyntaxKind["DoKeyword"] = 22] = "DoKeyword"; + SyntaxKind[SyntaxKind["ElseKeyword"] = 23] = "ElseKeyword"; + SyntaxKind[SyntaxKind["FalseKeyword"] = 24] = "FalseKeyword"; + SyntaxKind[SyntaxKind["FinallyKeyword"] = 25] = "FinallyKeyword"; + SyntaxKind[SyntaxKind["ForKeyword"] = 26] = "ForKeyword"; + SyntaxKind[SyntaxKind["FunctionKeyword"] = 27] = "FunctionKeyword"; + SyntaxKind[SyntaxKind["IfKeyword"] = 28] = "IfKeyword"; + SyntaxKind[SyntaxKind["InKeyword"] = 29] = "InKeyword"; + SyntaxKind[SyntaxKind["InstanceOfKeyword"] = 30] = "InstanceOfKeyword"; + SyntaxKind[SyntaxKind["NewKeyword"] = 31] = "NewKeyword"; + SyntaxKind[SyntaxKind["NullKeyword"] = 32] = "NullKeyword"; + SyntaxKind[SyntaxKind["ReturnKeyword"] = 33] = "ReturnKeyword"; + SyntaxKind[SyntaxKind["SwitchKeyword"] = 34] = "SwitchKeyword"; + SyntaxKind[SyntaxKind["ThisKeyword"] = 35] = "ThisKeyword"; + SyntaxKind[SyntaxKind["ThrowKeyword"] = 36] = "ThrowKeyword"; + SyntaxKind[SyntaxKind["TrueKeyword"] = 37] = "TrueKeyword"; + SyntaxKind[SyntaxKind["TryKeyword"] = 38] = "TryKeyword"; + SyntaxKind[SyntaxKind["TypeOfKeyword"] = 39] = "TypeOfKeyword"; + SyntaxKind[SyntaxKind["VarKeyword"] = 40] = "VarKeyword"; + SyntaxKind[SyntaxKind["VoidKeyword"] = 41] = "VoidKeyword"; + SyntaxKind[SyntaxKind["WhileKeyword"] = 42] = "WhileKeyword"; + SyntaxKind[SyntaxKind["WithKeyword"] = 43] = "WithKeyword"; + + SyntaxKind[SyntaxKind["ClassKeyword"] = 44] = "ClassKeyword"; + SyntaxKind[SyntaxKind["ConstKeyword"] = 45] = "ConstKeyword"; + SyntaxKind[SyntaxKind["EnumKeyword"] = 46] = "EnumKeyword"; + SyntaxKind[SyntaxKind["ExportKeyword"] = 47] = "ExportKeyword"; + SyntaxKind[SyntaxKind["ExtendsKeyword"] = 48] = "ExtendsKeyword"; + SyntaxKind[SyntaxKind["ImportKeyword"] = 49] = "ImportKeyword"; + SyntaxKind[SyntaxKind["SuperKeyword"] = 50] = "SuperKeyword"; + + SyntaxKind[SyntaxKind["ImplementsKeyword"] = 51] = "ImplementsKeyword"; + SyntaxKind[SyntaxKind["InterfaceKeyword"] = 52] = "InterfaceKeyword"; + SyntaxKind[SyntaxKind["LetKeyword"] = 53] = "LetKeyword"; + SyntaxKind[SyntaxKind["PackageKeyword"] = 54] = "PackageKeyword"; + SyntaxKind[SyntaxKind["PrivateKeyword"] = 55] = "PrivateKeyword"; + SyntaxKind[SyntaxKind["ProtectedKeyword"] = 56] = "ProtectedKeyword"; + SyntaxKind[SyntaxKind["PublicKeyword"] = 57] = "PublicKeyword"; + SyntaxKind[SyntaxKind["StaticKeyword"] = 58] = "StaticKeyword"; + SyntaxKind[SyntaxKind["YieldKeyword"] = 59] = "YieldKeyword"; + + SyntaxKind[SyntaxKind["AnyKeyword"] = 60] = "AnyKeyword"; + SyntaxKind[SyntaxKind["BooleanKeyword"] = 61] = "BooleanKeyword"; + SyntaxKind[SyntaxKind["ConstructorKeyword"] = 62] = "ConstructorKeyword"; + SyntaxKind[SyntaxKind["DeclareKeyword"] = 63] = "DeclareKeyword"; + SyntaxKind[SyntaxKind["GetKeyword"] = 64] = "GetKeyword"; + SyntaxKind[SyntaxKind["ModuleKeyword"] = 65] = "ModuleKeyword"; + SyntaxKind[SyntaxKind["RequireKeyword"] = 66] = "RequireKeyword"; + SyntaxKind[SyntaxKind["NumberKeyword"] = 67] = "NumberKeyword"; + SyntaxKind[SyntaxKind["SetKeyword"] = 68] = "SetKeyword"; + SyntaxKind[SyntaxKind["StringKeyword"] = 69] = "StringKeyword"; + + SyntaxKind[SyntaxKind["OpenBraceToken"] = 70] = "OpenBraceToken"; + SyntaxKind[SyntaxKind["CloseBraceToken"] = 71] = "CloseBraceToken"; + SyntaxKind[SyntaxKind["OpenParenToken"] = 72] = "OpenParenToken"; + SyntaxKind[SyntaxKind["CloseParenToken"] = 73] = "CloseParenToken"; + SyntaxKind[SyntaxKind["OpenBracketToken"] = 74] = "OpenBracketToken"; + SyntaxKind[SyntaxKind["CloseBracketToken"] = 75] = "CloseBracketToken"; + SyntaxKind[SyntaxKind["DotToken"] = 76] = "DotToken"; + SyntaxKind[SyntaxKind["DotDotDotToken"] = 77] = "DotDotDotToken"; + SyntaxKind[SyntaxKind["SemicolonToken"] = 78] = "SemicolonToken"; + SyntaxKind[SyntaxKind["CommaToken"] = 79] = "CommaToken"; + SyntaxKind[SyntaxKind["LessThanToken"] = 80] = "LessThanToken"; + SyntaxKind[SyntaxKind["GreaterThanToken"] = 81] = "GreaterThanToken"; + SyntaxKind[SyntaxKind["LessThanEqualsToken"] = 82] = "LessThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanEqualsToken"] = 83] = "GreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["EqualsEqualsToken"] = 84] = "EqualsEqualsToken"; + SyntaxKind[SyntaxKind["EqualsGreaterThanToken"] = 85] = "EqualsGreaterThanToken"; + SyntaxKind[SyntaxKind["ExclamationEqualsToken"] = 86] = "ExclamationEqualsToken"; + SyntaxKind[SyntaxKind["EqualsEqualsEqualsToken"] = 87] = "EqualsEqualsEqualsToken"; + SyntaxKind[SyntaxKind["ExclamationEqualsEqualsToken"] = 88] = "ExclamationEqualsEqualsToken"; + SyntaxKind[SyntaxKind["PlusToken"] = 89] = "PlusToken"; + SyntaxKind[SyntaxKind["MinusToken"] = 90] = "MinusToken"; + SyntaxKind[SyntaxKind["AsteriskToken"] = 91] = "AsteriskToken"; + SyntaxKind[SyntaxKind["PercentToken"] = 92] = "PercentToken"; + SyntaxKind[SyntaxKind["PlusPlusToken"] = 93] = "PlusPlusToken"; + SyntaxKind[SyntaxKind["MinusMinusToken"] = 94] = "MinusMinusToken"; + SyntaxKind[SyntaxKind["LessThanLessThanToken"] = 95] = "LessThanLessThanToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanToken"] = 96] = "GreaterThanGreaterThanToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanToken"] = 97] = "GreaterThanGreaterThanGreaterThanToken"; + SyntaxKind[SyntaxKind["AmpersandToken"] = 98] = "AmpersandToken"; + SyntaxKind[SyntaxKind["BarToken"] = 99] = "BarToken"; + SyntaxKind[SyntaxKind["CaretToken"] = 100] = "CaretToken"; + SyntaxKind[SyntaxKind["ExclamationToken"] = 101] = "ExclamationToken"; + SyntaxKind[SyntaxKind["TildeToken"] = 102] = "TildeToken"; + SyntaxKind[SyntaxKind["AmpersandAmpersandToken"] = 103] = "AmpersandAmpersandToken"; + SyntaxKind[SyntaxKind["BarBarToken"] = 104] = "BarBarToken"; + SyntaxKind[SyntaxKind["QuestionToken"] = 105] = "QuestionToken"; + SyntaxKind[SyntaxKind["ColonToken"] = 106] = "ColonToken"; + SyntaxKind[SyntaxKind["EqualsToken"] = 107] = "EqualsToken"; + SyntaxKind[SyntaxKind["PlusEqualsToken"] = 108] = "PlusEqualsToken"; + SyntaxKind[SyntaxKind["MinusEqualsToken"] = 109] = "MinusEqualsToken"; + SyntaxKind[SyntaxKind["AsteriskEqualsToken"] = 110] = "AsteriskEqualsToken"; + SyntaxKind[SyntaxKind["PercentEqualsToken"] = 111] = "PercentEqualsToken"; + SyntaxKind[SyntaxKind["LessThanLessThanEqualsToken"] = 112] = "LessThanLessThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanEqualsToken"] = 113] = "GreaterThanGreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanEqualsToken"] = 114] = "GreaterThanGreaterThanGreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["AmpersandEqualsToken"] = 115] = "AmpersandEqualsToken"; + SyntaxKind[SyntaxKind["BarEqualsToken"] = 116] = "BarEqualsToken"; + SyntaxKind[SyntaxKind["CaretEqualsToken"] = 117] = "CaretEqualsToken"; + SyntaxKind[SyntaxKind["SlashToken"] = 118] = "SlashToken"; + SyntaxKind[SyntaxKind["SlashEqualsToken"] = 119] = "SlashEqualsToken"; + + SyntaxKind[SyntaxKind["SourceUnit"] = 120] = "SourceUnit"; + + SyntaxKind[SyntaxKind["QualifiedName"] = 121] = "QualifiedName"; + + SyntaxKind[SyntaxKind["ObjectType"] = 122] = "ObjectType"; + SyntaxKind[SyntaxKind["FunctionType"] = 123] = "FunctionType"; + SyntaxKind[SyntaxKind["ArrayType"] = 124] = "ArrayType"; + SyntaxKind[SyntaxKind["ConstructorType"] = 125] = "ConstructorType"; + SyntaxKind[SyntaxKind["GenericType"] = 126] = "GenericType"; + SyntaxKind[SyntaxKind["TypeQuery"] = 127] = "TypeQuery"; + + SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 128] = "InterfaceDeclaration"; + SyntaxKind[SyntaxKind["FunctionDeclaration"] = 129] = "FunctionDeclaration"; + SyntaxKind[SyntaxKind["ModuleDeclaration"] = 130] = "ModuleDeclaration"; + SyntaxKind[SyntaxKind["ClassDeclaration"] = 131] = "ClassDeclaration"; + SyntaxKind[SyntaxKind["EnumDeclaration"] = 132] = "EnumDeclaration"; + SyntaxKind[SyntaxKind["ImportDeclaration"] = 133] = "ImportDeclaration"; + SyntaxKind[SyntaxKind["ExportAssignment"] = 134] = "ExportAssignment"; + + SyntaxKind[SyntaxKind["MemberFunctionDeclaration"] = 135] = "MemberFunctionDeclaration"; + SyntaxKind[SyntaxKind["MemberVariableDeclaration"] = 136] = "MemberVariableDeclaration"; + SyntaxKind[SyntaxKind["ConstructorDeclaration"] = 137] = "ConstructorDeclaration"; + SyntaxKind[SyntaxKind["GetMemberAccessorDeclaration"] = 138] = "GetMemberAccessorDeclaration"; + SyntaxKind[SyntaxKind["SetMemberAccessorDeclaration"] = 139] = "SetMemberAccessorDeclaration"; + + SyntaxKind[SyntaxKind["PropertySignature"] = 140] = "PropertySignature"; + SyntaxKind[SyntaxKind["CallSignature"] = 141] = "CallSignature"; + SyntaxKind[SyntaxKind["ConstructSignature"] = 142] = "ConstructSignature"; + SyntaxKind[SyntaxKind["IndexSignature"] = 143] = "IndexSignature"; + SyntaxKind[SyntaxKind["MethodSignature"] = 144] = "MethodSignature"; + + SyntaxKind[SyntaxKind["Block"] = 145] = "Block"; + SyntaxKind[SyntaxKind["IfStatement"] = 146] = "IfStatement"; + SyntaxKind[SyntaxKind["VariableStatement"] = 147] = "VariableStatement"; + SyntaxKind[SyntaxKind["ExpressionStatement"] = 148] = "ExpressionStatement"; + SyntaxKind[SyntaxKind["ReturnStatement"] = 149] = "ReturnStatement"; + SyntaxKind[SyntaxKind["SwitchStatement"] = 150] = "SwitchStatement"; + SyntaxKind[SyntaxKind["BreakStatement"] = 151] = "BreakStatement"; + SyntaxKind[SyntaxKind["ContinueStatement"] = 152] = "ContinueStatement"; + SyntaxKind[SyntaxKind["ForStatement"] = 153] = "ForStatement"; + SyntaxKind[SyntaxKind["ForInStatement"] = 154] = "ForInStatement"; + SyntaxKind[SyntaxKind["EmptyStatement"] = 155] = "EmptyStatement"; + SyntaxKind[SyntaxKind["ThrowStatement"] = 156] = "ThrowStatement"; + SyntaxKind[SyntaxKind["WhileStatement"] = 157] = "WhileStatement"; + SyntaxKind[SyntaxKind["TryStatement"] = 158] = "TryStatement"; + SyntaxKind[SyntaxKind["LabeledStatement"] = 159] = "LabeledStatement"; + SyntaxKind[SyntaxKind["DoStatement"] = 160] = "DoStatement"; + SyntaxKind[SyntaxKind["DebuggerStatement"] = 161] = "DebuggerStatement"; + SyntaxKind[SyntaxKind["WithStatement"] = 162] = "WithStatement"; + + SyntaxKind[SyntaxKind["PlusExpression"] = 163] = "PlusExpression"; + SyntaxKind[SyntaxKind["NegateExpression"] = 164] = "NegateExpression"; + SyntaxKind[SyntaxKind["BitwiseNotExpression"] = 165] = "BitwiseNotExpression"; + SyntaxKind[SyntaxKind["LogicalNotExpression"] = 166] = "LogicalNotExpression"; + SyntaxKind[SyntaxKind["PreIncrementExpression"] = 167] = "PreIncrementExpression"; + SyntaxKind[SyntaxKind["PreDecrementExpression"] = 168] = "PreDecrementExpression"; + SyntaxKind[SyntaxKind["DeleteExpression"] = 169] = "DeleteExpression"; + SyntaxKind[SyntaxKind["TypeOfExpression"] = 170] = "TypeOfExpression"; + SyntaxKind[SyntaxKind["VoidExpression"] = 171] = "VoidExpression"; + SyntaxKind[SyntaxKind["CommaExpression"] = 172] = "CommaExpression"; + SyntaxKind[SyntaxKind["AssignmentExpression"] = 173] = "AssignmentExpression"; + SyntaxKind[SyntaxKind["AddAssignmentExpression"] = 174] = "AddAssignmentExpression"; + SyntaxKind[SyntaxKind["SubtractAssignmentExpression"] = 175] = "SubtractAssignmentExpression"; + SyntaxKind[SyntaxKind["MultiplyAssignmentExpression"] = 176] = "MultiplyAssignmentExpression"; + SyntaxKind[SyntaxKind["DivideAssignmentExpression"] = 177] = "DivideAssignmentExpression"; + SyntaxKind[SyntaxKind["ModuloAssignmentExpression"] = 178] = "ModuloAssignmentExpression"; + SyntaxKind[SyntaxKind["AndAssignmentExpression"] = 179] = "AndAssignmentExpression"; + SyntaxKind[SyntaxKind["ExclusiveOrAssignmentExpression"] = 180] = "ExclusiveOrAssignmentExpression"; + SyntaxKind[SyntaxKind["OrAssignmentExpression"] = 181] = "OrAssignmentExpression"; + SyntaxKind[SyntaxKind["LeftShiftAssignmentExpression"] = 182] = "LeftShiftAssignmentExpression"; + SyntaxKind[SyntaxKind["SignedRightShiftAssignmentExpression"] = 183] = "SignedRightShiftAssignmentExpression"; + SyntaxKind[SyntaxKind["UnsignedRightShiftAssignmentExpression"] = 184] = "UnsignedRightShiftAssignmentExpression"; + SyntaxKind[SyntaxKind["ConditionalExpression"] = 185] = "ConditionalExpression"; + SyntaxKind[SyntaxKind["LogicalOrExpression"] = 186] = "LogicalOrExpression"; + SyntaxKind[SyntaxKind["LogicalAndExpression"] = 187] = "LogicalAndExpression"; + SyntaxKind[SyntaxKind["BitwiseOrExpression"] = 188] = "BitwiseOrExpression"; + SyntaxKind[SyntaxKind["BitwiseExclusiveOrExpression"] = 189] = "BitwiseExclusiveOrExpression"; + SyntaxKind[SyntaxKind["BitwiseAndExpression"] = 190] = "BitwiseAndExpression"; + SyntaxKind[SyntaxKind["EqualsWithTypeConversionExpression"] = 191] = "EqualsWithTypeConversionExpression"; + SyntaxKind[SyntaxKind["NotEqualsWithTypeConversionExpression"] = 192] = "NotEqualsWithTypeConversionExpression"; + SyntaxKind[SyntaxKind["EqualsExpression"] = 193] = "EqualsExpression"; + SyntaxKind[SyntaxKind["NotEqualsExpression"] = 194] = "NotEqualsExpression"; + SyntaxKind[SyntaxKind["LessThanExpression"] = 195] = "LessThanExpression"; + SyntaxKind[SyntaxKind["GreaterThanExpression"] = 196] = "GreaterThanExpression"; + SyntaxKind[SyntaxKind["LessThanOrEqualExpression"] = 197] = "LessThanOrEqualExpression"; + SyntaxKind[SyntaxKind["GreaterThanOrEqualExpression"] = 198] = "GreaterThanOrEqualExpression"; + SyntaxKind[SyntaxKind["InstanceOfExpression"] = 199] = "InstanceOfExpression"; + SyntaxKind[SyntaxKind["InExpression"] = 200] = "InExpression"; + SyntaxKind[SyntaxKind["LeftShiftExpression"] = 201] = "LeftShiftExpression"; + SyntaxKind[SyntaxKind["SignedRightShiftExpression"] = 202] = "SignedRightShiftExpression"; + SyntaxKind[SyntaxKind["UnsignedRightShiftExpression"] = 203] = "UnsignedRightShiftExpression"; + SyntaxKind[SyntaxKind["MultiplyExpression"] = 204] = "MultiplyExpression"; + SyntaxKind[SyntaxKind["DivideExpression"] = 205] = "DivideExpression"; + SyntaxKind[SyntaxKind["ModuloExpression"] = 206] = "ModuloExpression"; + SyntaxKind[SyntaxKind["AddExpression"] = 207] = "AddExpression"; + SyntaxKind[SyntaxKind["SubtractExpression"] = 208] = "SubtractExpression"; + SyntaxKind[SyntaxKind["PostIncrementExpression"] = 209] = "PostIncrementExpression"; + SyntaxKind[SyntaxKind["PostDecrementExpression"] = 210] = "PostDecrementExpression"; + SyntaxKind[SyntaxKind["MemberAccessExpression"] = 211] = "MemberAccessExpression"; + SyntaxKind[SyntaxKind["InvocationExpression"] = 212] = "InvocationExpression"; + SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 213] = "ArrayLiteralExpression"; + SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 214] = "ObjectLiteralExpression"; + SyntaxKind[SyntaxKind["ObjectCreationExpression"] = 215] = "ObjectCreationExpression"; + SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 216] = "ParenthesizedExpression"; + SyntaxKind[SyntaxKind["ParenthesizedArrowFunctionExpression"] = 217] = "ParenthesizedArrowFunctionExpression"; + SyntaxKind[SyntaxKind["SimpleArrowFunctionExpression"] = 218] = "SimpleArrowFunctionExpression"; + SyntaxKind[SyntaxKind["CastExpression"] = 219] = "CastExpression"; + SyntaxKind[SyntaxKind["ElementAccessExpression"] = 220] = "ElementAccessExpression"; + SyntaxKind[SyntaxKind["FunctionExpression"] = 221] = "FunctionExpression"; + SyntaxKind[SyntaxKind["OmittedExpression"] = 222] = "OmittedExpression"; + + SyntaxKind[SyntaxKind["VariableDeclaration"] = 223] = "VariableDeclaration"; + SyntaxKind[SyntaxKind["VariableDeclarator"] = 224] = "VariableDeclarator"; + + SyntaxKind[SyntaxKind["ArgumentList"] = 225] = "ArgumentList"; + SyntaxKind[SyntaxKind["ParameterList"] = 226] = "ParameterList"; + SyntaxKind[SyntaxKind["TypeArgumentList"] = 227] = "TypeArgumentList"; + SyntaxKind[SyntaxKind["TypeParameterList"] = 228] = "TypeParameterList"; + + SyntaxKind[SyntaxKind["HeritageClause"] = 229] = "HeritageClause"; + SyntaxKind[SyntaxKind["EqualsValueClause"] = 230] = "EqualsValueClause"; + SyntaxKind[SyntaxKind["CaseSwitchClause"] = 231] = "CaseSwitchClause"; + SyntaxKind[SyntaxKind["DefaultSwitchClause"] = 232] = "DefaultSwitchClause"; + SyntaxKind[SyntaxKind["ElseClause"] = 233] = "ElseClause"; + SyntaxKind[SyntaxKind["CatchClause"] = 234] = "CatchClause"; + SyntaxKind[SyntaxKind["FinallyClause"] = 235] = "FinallyClause"; + + SyntaxKind[SyntaxKind["TypeParameter"] = 236] = "TypeParameter"; + SyntaxKind[SyntaxKind["Constraint"] = 237] = "Constraint"; + + SyntaxKind[SyntaxKind["SimplePropertyAssignment"] = 238] = "SimplePropertyAssignment"; + SyntaxKind[SyntaxKind["GetAccessorPropertyAssignment"] = 239] = "GetAccessorPropertyAssignment"; + SyntaxKind[SyntaxKind["SetAccessorPropertyAssignment"] = 240] = "SetAccessorPropertyAssignment"; + SyntaxKind[SyntaxKind["FunctionPropertyAssignment"] = 241] = "FunctionPropertyAssignment"; + + SyntaxKind[SyntaxKind["Parameter"] = 242] = "Parameter"; + SyntaxKind[SyntaxKind["EnumElement"] = 243] = "EnumElement"; + SyntaxKind[SyntaxKind["TypeAnnotation"] = 244] = "TypeAnnotation"; + SyntaxKind[SyntaxKind["ExternalModuleReference"] = 245] = "ExternalModuleReference"; + SyntaxKind[SyntaxKind["ModuleNameModuleReference"] = 246] = "ModuleNameModuleReference"; + + SyntaxKind[SyntaxKind["FirstStandardKeyword"] = SyntaxKind.BreakKeyword] = "FirstStandardKeyword"; + SyntaxKind[SyntaxKind["LastStandardKeyword"] = SyntaxKind.WithKeyword] = "LastStandardKeyword"; + + SyntaxKind[SyntaxKind["FirstFutureReservedKeyword"] = SyntaxKind.ClassKeyword] = "FirstFutureReservedKeyword"; + SyntaxKind[SyntaxKind["LastFutureReservedKeyword"] = SyntaxKind.SuperKeyword] = "LastFutureReservedKeyword"; + + SyntaxKind[SyntaxKind["FirstFutureReservedStrictKeyword"] = SyntaxKind.ImplementsKeyword] = "FirstFutureReservedStrictKeyword"; + SyntaxKind[SyntaxKind["LastFutureReservedStrictKeyword"] = SyntaxKind.YieldKeyword] = "LastFutureReservedStrictKeyword"; + + SyntaxKind[SyntaxKind["FirstTypeScriptKeyword"] = SyntaxKind.AnyKeyword] = "FirstTypeScriptKeyword"; + SyntaxKind[SyntaxKind["LastTypeScriptKeyword"] = SyntaxKind.StringKeyword] = "LastTypeScriptKeyword"; + + SyntaxKind[SyntaxKind["FirstKeyword"] = SyntaxKind.FirstStandardKeyword] = "FirstKeyword"; + SyntaxKind[SyntaxKind["LastKeyword"] = SyntaxKind.LastTypeScriptKeyword] = "LastKeyword"; + + SyntaxKind[SyntaxKind["FirstToken"] = SyntaxKind.ErrorToken] = "FirstToken"; + SyntaxKind[SyntaxKind["LastToken"] = SyntaxKind.SlashEqualsToken] = "LastToken"; + + SyntaxKind[SyntaxKind["FirstPunctuation"] = SyntaxKind.OpenBraceToken] = "FirstPunctuation"; + SyntaxKind[SyntaxKind["LastPunctuation"] = SyntaxKind.SlashEqualsToken] = "LastPunctuation"; + + SyntaxKind[SyntaxKind["FirstFixedWidth"] = SyntaxKind.FirstKeyword] = "FirstFixedWidth"; + SyntaxKind[SyntaxKind["LastFixedWidth"] = SyntaxKind.LastPunctuation] = "LastFixedWidth"; + })(TypeScript.SyntaxKind || (TypeScript.SyntaxKind = {})); + var SyntaxKind = TypeScript.SyntaxKind; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (SyntaxFacts) { + var textToKeywordKind = { + "any": 60 /* AnyKeyword */, + "boolean": 61 /* BooleanKeyword */, + "break": 15 /* BreakKeyword */, + "case": 16 /* CaseKeyword */, + "catch": 17 /* CatchKeyword */, + "class": 44 /* ClassKeyword */, + "continue": 18 /* ContinueKeyword */, + "const": 45 /* ConstKeyword */, + "constructor": 62 /* ConstructorKeyword */, + "debugger": 19 /* DebuggerKeyword */, + "declare": 63 /* DeclareKeyword */, + "default": 20 /* DefaultKeyword */, + "delete": 21 /* DeleteKeyword */, + "do": 22 /* DoKeyword */, + "else": 23 /* ElseKeyword */, + "enum": 46 /* EnumKeyword */, + "export": 47 /* ExportKeyword */, + "extends": 48 /* ExtendsKeyword */, + "false": 24 /* FalseKeyword */, + "finally": 25 /* FinallyKeyword */, + "for": 26 /* ForKeyword */, + "function": 27 /* FunctionKeyword */, + "get": 64 /* GetKeyword */, + "if": 28 /* IfKeyword */, + "implements": 51 /* ImplementsKeyword */, + "import": 49 /* ImportKeyword */, + "in": 29 /* InKeyword */, + "instanceof": 30 /* InstanceOfKeyword */, + "interface": 52 /* InterfaceKeyword */, + "let": 53 /* LetKeyword */, + "module": 65 /* ModuleKeyword */, + "new": 31 /* NewKeyword */, + "null": 32 /* NullKeyword */, + "number": 67 /* NumberKeyword */, + "package": 54 /* PackageKeyword */, + "private": 55 /* PrivateKeyword */, + "protected": 56 /* ProtectedKeyword */, + "public": 57 /* PublicKeyword */, + "require": 66 /* RequireKeyword */, + "return": 33 /* ReturnKeyword */, + "set": 68 /* SetKeyword */, + "static": 58 /* StaticKeyword */, + "string": 69 /* StringKeyword */, + "super": 50 /* SuperKeyword */, + "switch": 34 /* SwitchKeyword */, + "this": 35 /* ThisKeyword */, + "throw": 36 /* ThrowKeyword */, + "true": 37 /* TrueKeyword */, + "try": 38 /* TryKeyword */, + "typeof": 39 /* TypeOfKeyword */, + "var": 40 /* VarKeyword */, + "void": 41 /* VoidKeyword */, + "while": 42 /* WhileKeyword */, + "with": 43 /* WithKeyword */, + "yield": 59 /* YieldKeyword */, + "{": 70 /* OpenBraceToken */, + "}": 71 /* CloseBraceToken */, + "(": 72 /* OpenParenToken */, + ")": 73 /* CloseParenToken */, + "[": 74 /* OpenBracketToken */, + "]": 75 /* CloseBracketToken */, + ".": 76 /* DotToken */, + "...": 77 /* DotDotDotToken */, + ";": 78 /* SemicolonToken */, + ",": 79 /* CommaToken */, + "<": 80 /* LessThanToken */, + ">": 81 /* GreaterThanToken */, + "<=": 82 /* LessThanEqualsToken */, + ">=": 83 /* GreaterThanEqualsToken */, + "==": 84 /* EqualsEqualsToken */, + "=>": 85 /* EqualsGreaterThanToken */, + "!=": 86 /* ExclamationEqualsToken */, + "===": 87 /* EqualsEqualsEqualsToken */, + "!==": 88 /* ExclamationEqualsEqualsToken */, + "+": 89 /* PlusToken */, + "-": 90 /* MinusToken */, + "*": 91 /* AsteriskToken */, + "%": 92 /* PercentToken */, + "++": 93 /* PlusPlusToken */, + "--": 94 /* MinusMinusToken */, + "<<": 95 /* LessThanLessThanToken */, + ">>": 96 /* GreaterThanGreaterThanToken */, + ">>>": 97 /* GreaterThanGreaterThanGreaterThanToken */, + "&": 98 /* AmpersandToken */, + "|": 99 /* BarToken */, + "^": 100 /* CaretToken */, + "!": 101 /* ExclamationToken */, + "~": 102 /* TildeToken */, + "&&": 103 /* AmpersandAmpersandToken */, + "||": 104 /* BarBarToken */, + "?": 105 /* QuestionToken */, + ":": 106 /* ColonToken */, + "=": 107 /* EqualsToken */, + "+=": 108 /* PlusEqualsToken */, + "-=": 109 /* MinusEqualsToken */, + "*=": 110 /* AsteriskEqualsToken */, + "%=": 111 /* PercentEqualsToken */, + "<<=": 112 /* LessThanLessThanEqualsToken */, + ">>=": 113 /* GreaterThanGreaterThanEqualsToken */, + ">>>=": 114 /* GreaterThanGreaterThanGreaterThanEqualsToken */, + "&=": 115 /* AmpersandEqualsToken */, + "|=": 116 /* BarEqualsToken */, + "^=": 117 /* CaretEqualsToken */, + "/": 118 /* SlashToken */, + "/=": 119 /* SlashEqualsToken */ + }; + + var kindToText = new Array(); + + for (var name in textToKeywordKind) { + if (textToKeywordKind.hasOwnProperty(name)) { + kindToText[textToKeywordKind[name]] = name; + } + } + + kindToText[62 /* ConstructorKeyword */] = "constructor"; + + function getTokenKind(text) { + if (textToKeywordKind.hasOwnProperty(text)) { + return textToKeywordKind[text]; + } + + return 0 /* None */; + } + SyntaxFacts.getTokenKind = getTokenKind; + + function getText(kind) { + var result = kindToText[kind]; + return result !== undefined ? result : null; + } + SyntaxFacts.getText = getText; + + function isTokenKind(kind) { + return kind >= 9 /* FirstToken */ && kind <= 119 /* LastToken */; + } + SyntaxFacts.isTokenKind = isTokenKind; + + function isAnyKeyword(kind) { + return kind >= 15 /* FirstKeyword */ && kind <= 69 /* LastKeyword */; + } + SyntaxFacts.isAnyKeyword = isAnyKeyword; + + function isStandardKeyword(kind) { + return kind >= 15 /* FirstStandardKeyword */ && kind <= 43 /* LastStandardKeyword */; + } + SyntaxFacts.isStandardKeyword = isStandardKeyword; + + function isFutureReservedKeyword(kind) { + return kind >= 44 /* FirstFutureReservedKeyword */ && kind <= 50 /* LastFutureReservedKeyword */; + } + SyntaxFacts.isFutureReservedKeyword = isFutureReservedKeyword; + + function isFutureReservedStrictKeyword(kind) { + return kind >= 51 /* FirstFutureReservedStrictKeyword */ && kind <= 59 /* LastFutureReservedStrictKeyword */; + } + SyntaxFacts.isFutureReservedStrictKeyword = isFutureReservedStrictKeyword; + + function isAnyPunctuation(kind) { + return kind >= 70 /* FirstPunctuation */ && kind <= 119 /* LastPunctuation */; + } + SyntaxFacts.isAnyPunctuation = isAnyPunctuation; + + function isPrefixUnaryExpressionOperatorToken(tokenKind) { + return getPrefixUnaryExpressionFromOperatorToken(tokenKind) !== 0 /* None */; + } + SyntaxFacts.isPrefixUnaryExpressionOperatorToken = isPrefixUnaryExpressionOperatorToken; + + function isBinaryExpressionOperatorToken(tokenKind) { + return getBinaryExpressionFromOperatorToken(tokenKind) !== 0 /* None */; + } + SyntaxFacts.isBinaryExpressionOperatorToken = isBinaryExpressionOperatorToken; + + function getPrefixUnaryExpressionFromOperatorToken(tokenKind) { + switch (tokenKind) { + case 89 /* PlusToken */: + return 163 /* PlusExpression */; + case 90 /* MinusToken */: + return 164 /* NegateExpression */; + case 102 /* TildeToken */: + return 165 /* BitwiseNotExpression */; + case 101 /* ExclamationToken */: + return 166 /* LogicalNotExpression */; + case 93 /* PlusPlusToken */: + return 167 /* PreIncrementExpression */; + case 94 /* MinusMinusToken */: + return 168 /* PreDecrementExpression */; + + default: + return 0 /* None */; + } + } + SyntaxFacts.getPrefixUnaryExpressionFromOperatorToken = getPrefixUnaryExpressionFromOperatorToken; + + function getPostfixUnaryExpressionFromOperatorToken(tokenKind) { + switch (tokenKind) { + case 93 /* PlusPlusToken */: + return 209 /* PostIncrementExpression */; + case 94 /* MinusMinusToken */: + return 210 /* PostDecrementExpression */; + default: + return 0 /* None */; + } + } + SyntaxFacts.getPostfixUnaryExpressionFromOperatorToken = getPostfixUnaryExpressionFromOperatorToken; + + function getBinaryExpressionFromOperatorToken(tokenKind) { + switch (tokenKind) { + case 91 /* AsteriskToken */: + return 204 /* MultiplyExpression */; + + case 118 /* SlashToken */: + return 205 /* DivideExpression */; + + case 92 /* PercentToken */: + return 206 /* ModuloExpression */; + + case 89 /* PlusToken */: + return 207 /* AddExpression */; + + case 90 /* MinusToken */: + return 208 /* SubtractExpression */; + + case 95 /* LessThanLessThanToken */: + return 201 /* LeftShiftExpression */; + + case 96 /* GreaterThanGreaterThanToken */: + return 202 /* SignedRightShiftExpression */; + + case 97 /* GreaterThanGreaterThanGreaterThanToken */: + return 203 /* UnsignedRightShiftExpression */; + + case 80 /* LessThanToken */: + return 195 /* LessThanExpression */; + + case 81 /* GreaterThanToken */: + return 196 /* GreaterThanExpression */; + + case 82 /* LessThanEqualsToken */: + return 197 /* LessThanOrEqualExpression */; + + case 83 /* GreaterThanEqualsToken */: + return 198 /* GreaterThanOrEqualExpression */; + + case 30 /* InstanceOfKeyword */: + return 199 /* InstanceOfExpression */; + + case 29 /* InKeyword */: + return 200 /* InExpression */; + + case 84 /* EqualsEqualsToken */: + return 191 /* EqualsWithTypeConversionExpression */; + + case 86 /* ExclamationEqualsToken */: + return 192 /* NotEqualsWithTypeConversionExpression */; + + case 87 /* EqualsEqualsEqualsToken */: + return 193 /* EqualsExpression */; + + case 88 /* ExclamationEqualsEqualsToken */: + return 194 /* NotEqualsExpression */; + + case 98 /* AmpersandToken */: + return 190 /* BitwiseAndExpression */; + + case 100 /* CaretToken */: + return 189 /* BitwiseExclusiveOrExpression */; + + case 99 /* BarToken */: + return 188 /* BitwiseOrExpression */; + + case 103 /* AmpersandAmpersandToken */: + return 187 /* LogicalAndExpression */; + + case 104 /* BarBarToken */: + return 186 /* LogicalOrExpression */; + + case 116 /* BarEqualsToken */: + return 181 /* OrAssignmentExpression */; + + case 115 /* AmpersandEqualsToken */: + return 179 /* AndAssignmentExpression */; + + case 117 /* CaretEqualsToken */: + return 180 /* ExclusiveOrAssignmentExpression */; + + case 112 /* LessThanLessThanEqualsToken */: + return 182 /* LeftShiftAssignmentExpression */; + + case 113 /* GreaterThanGreaterThanEqualsToken */: + return 183 /* SignedRightShiftAssignmentExpression */; + + case 114 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + return 184 /* UnsignedRightShiftAssignmentExpression */; + + case 108 /* PlusEqualsToken */: + return 174 /* AddAssignmentExpression */; + + case 109 /* MinusEqualsToken */: + return 175 /* SubtractAssignmentExpression */; + + case 110 /* AsteriskEqualsToken */: + return 176 /* MultiplyAssignmentExpression */; + + case 119 /* SlashEqualsToken */: + return 177 /* DivideAssignmentExpression */; + + case 111 /* PercentEqualsToken */: + return 178 /* ModuloAssignmentExpression */; + + case 107 /* EqualsToken */: + return 173 /* AssignmentExpression */; + + case 79 /* CommaToken */: + return 172 /* CommaExpression */; + + default: + return 0 /* None */; + } + } + SyntaxFacts.getBinaryExpressionFromOperatorToken = getBinaryExpressionFromOperatorToken; + + function isAnyDivideToken(kind) { + switch (kind) { + case 118 /* SlashToken */: + case 119 /* SlashEqualsToken */: + return true; + default: + return false; + } + } + SyntaxFacts.isAnyDivideToken = isAnyDivideToken; + + function isAnyDivideOrRegularExpressionToken(kind) { + switch (kind) { + case 118 /* SlashToken */: + case 119 /* SlashEqualsToken */: + case 12 /* RegularExpressionLiteral */: + return true; + default: + return false; + } + } + SyntaxFacts.isAnyDivideOrRegularExpressionToken = isAnyDivideOrRegularExpressionToken; + + function isParserGenerated(kind) { + switch (kind) { + case 96 /* GreaterThanGreaterThanToken */: + case 97 /* GreaterThanGreaterThanGreaterThanToken */: + case 83 /* GreaterThanEqualsToken */: + case 113 /* GreaterThanGreaterThanEqualsToken */: + case 114 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + return true; + default: + return false; + } + } + SyntaxFacts.isParserGenerated = isParserGenerated; + + function isAnyBinaryExpression(kind) { + switch (kind) { + case 172 /* CommaExpression */: + case 173 /* AssignmentExpression */: + case 174 /* AddAssignmentExpression */: + case 175 /* SubtractAssignmentExpression */: + case 176 /* MultiplyAssignmentExpression */: + case 177 /* DivideAssignmentExpression */: + case 178 /* ModuloAssignmentExpression */: + case 179 /* AndAssignmentExpression */: + case 180 /* ExclusiveOrAssignmentExpression */: + case 181 /* OrAssignmentExpression */: + case 182 /* LeftShiftAssignmentExpression */: + case 183 /* SignedRightShiftAssignmentExpression */: + case 184 /* UnsignedRightShiftAssignmentExpression */: + case 186 /* LogicalOrExpression */: + case 187 /* LogicalAndExpression */: + case 188 /* BitwiseOrExpression */: + case 189 /* BitwiseExclusiveOrExpression */: + case 190 /* BitwiseAndExpression */: + case 191 /* EqualsWithTypeConversionExpression */: + case 192 /* NotEqualsWithTypeConversionExpression */: + case 193 /* EqualsExpression */: + case 194 /* NotEqualsExpression */: + case 195 /* LessThanExpression */: + case 196 /* GreaterThanExpression */: + case 197 /* LessThanOrEqualExpression */: + case 198 /* GreaterThanOrEqualExpression */: + case 199 /* InstanceOfExpression */: + case 200 /* InExpression */: + case 201 /* LeftShiftExpression */: + case 202 /* SignedRightShiftExpression */: + case 203 /* UnsignedRightShiftExpression */: + case 204 /* MultiplyExpression */: + case 205 /* DivideExpression */: + case 206 /* ModuloExpression */: + case 207 /* AddExpression */: + case 208 /* SubtractExpression */: + return true; + } + + return false; + } + SyntaxFacts.isAnyBinaryExpression = isAnyBinaryExpression; + })(TypeScript.SyntaxFacts || (TypeScript.SyntaxFacts = {})); + var SyntaxFacts = TypeScript.SyntaxFacts; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var isKeywordStartCharacter = TypeScript.ArrayUtilities.createArray(127 /* maxAsciiCharacter */, false); + var isIdentifierStartCharacter = TypeScript.ArrayUtilities.createArray(127 /* maxAsciiCharacter */, false); + var isIdentifierPartCharacter = TypeScript.ArrayUtilities.createArray(127 /* maxAsciiCharacter */, false); + var isNumericLiteralStart = TypeScript.ArrayUtilities.createArray(127 /* maxAsciiCharacter */, false); + + for (var character = 0; character < 127 /* maxAsciiCharacter */; character++) { + if (character >= 97 /* a */ && character <= 122 /* z */) { + isIdentifierStartCharacter[character] = true; + isIdentifierPartCharacter[character] = true; + } else if ((character >= 65 /* A */ && character <= 90 /* Z */) || character === 95 /* _ */ || character === 36 /* $ */) { + isIdentifierStartCharacter[character] = true; + isIdentifierPartCharacter[character] = true; + } else if (character >= 48 /* _0 */ && character <= 57 /* _9 */) { + isIdentifierPartCharacter[character] = true; + isNumericLiteralStart[character] = true; + } + } + + isNumericLiteralStart[46 /* dot */] = true; + + for (var keywordKind = 15 /* FirstKeyword */; keywordKind <= 69 /* LastKeyword */; keywordKind++) { + var keyword = TypeScript.SyntaxFacts.getText(keywordKind); + isKeywordStartCharacter[keyword.charCodeAt(0)] = true; + } + + var Scanner = (function () { + function Scanner(fileName, text, languageVersion, window) { + if (typeof window === "undefined") { window = TypeScript.ArrayUtilities.createArray(2048, 0); } + this.slidingWindow = new TypeScript.SlidingWindow(this, window, 0, text.length()); + this.fileName = fileName; + this.text = text; + this._languageVersion = languageVersion; + } + Scanner.prototype.languageVersion = function () { + return this._languageVersion; + }; + + Scanner.prototype.fetchMoreItems = function (argument, sourceIndex, window, destinationIndex, spaceAvailable) { + var charactersRemaining = this.text.length() - sourceIndex; + var amountToRead = TypeScript.MathPrototype.min(charactersRemaining, spaceAvailable); + this.text.copyTo(sourceIndex, window, destinationIndex, amountToRead); + return amountToRead; + }; + + Scanner.prototype.currentCharCode = function () { + return this.slidingWindow.currentItem(null); + }; + + Scanner.prototype.absoluteIndex = function () { + return this.slidingWindow.absoluteIndex(); + }; + + Scanner.prototype.setAbsoluteIndex = function (index) { + this.slidingWindow.setAbsoluteIndex(index); + }; + + Scanner.prototype.scan = function (diagnostics, allowRegularExpression) { + var diagnosticsLength = diagnostics.length; + var fullStart = this.slidingWindow.absoluteIndex(); + var leadingTriviaInfo = this.scanTriviaInfo(diagnostics, false); + + var start = this.slidingWindow.absoluteIndex(); + var kind = this.scanSyntaxToken(diagnostics, allowRegularExpression); + var end = this.slidingWindow.absoluteIndex(); + + var trailingTriviaInfo = this.scanTriviaInfo(diagnostics, true); + + var token = this.createToken(fullStart, leadingTriviaInfo, start, kind, end, trailingTriviaInfo); + + return diagnosticsLength !== diagnostics.length ? TypeScript.Syntax.realizeToken(token) : token; + }; + + Scanner.prototype.createToken = function (fullStart, leadingTriviaInfo, start, kind, end, trailingTriviaInfo) { + if (kind >= 15 /* FirstFixedWidth */) { + if (leadingTriviaInfo === 0) { + if (trailingTriviaInfo === 0) { + return new TypeScript.Syntax.FixedWidthTokenWithNoTrivia(kind); + } else { + return new TypeScript.Syntax.FixedWidthTokenWithTrailingTrivia(this.text, fullStart, kind, trailingTriviaInfo); + } + } else if (trailingTriviaInfo === 0) { + return new TypeScript.Syntax.FixedWidthTokenWithLeadingTrivia(this.text, fullStart, kind, leadingTriviaInfo); + } else { + return new TypeScript.Syntax.FixedWidthTokenWithLeadingAndTrailingTrivia(this.text, fullStart, kind, leadingTriviaInfo, trailingTriviaInfo); + } + } else { + var width = end - start; + if (leadingTriviaInfo === 0) { + if (trailingTriviaInfo === 0) { + return new TypeScript.Syntax.VariableWidthTokenWithNoTrivia(this.text, fullStart, kind, width); + } else { + return new TypeScript.Syntax.VariableWidthTokenWithTrailingTrivia(this.text, fullStart, kind, width, trailingTriviaInfo); + } + } else if (trailingTriviaInfo === 0) { + return new TypeScript.Syntax.VariableWidthTokenWithLeadingTrivia(this.text, fullStart, kind, leadingTriviaInfo, width); + } else { + return new TypeScript.Syntax.VariableWidthTokenWithLeadingAndTrailingTrivia(this.text, fullStart, kind, leadingTriviaInfo, width, trailingTriviaInfo); + } + } + }; + + Scanner.scanTrivia = function (text, start, length, isTrailing) { + var scanner = new Scanner(null, text.subText(new TypeScript.TextSpan(start, length)), 1 /* EcmaScript5 */, Scanner.triviaWindow); + return scanner.scanTrivia(isTrailing); + }; + + Scanner.prototype.scanTrivia = function (isTrailing) { + var trivia = new Array(); + + while (true) { + if (!this.slidingWindow.isAtEndOfSource()) { + var ch = this.currentCharCode(); + + switch (ch) { + case 32 /* space */: + case 160 /* nonBreakingSpace */: + case 8192 /* enQuad */: + case 8193 /* emQuad */: + case 8194 /* enSpace */: + case 8195 /* emSpace */: + case 8196 /* threePerEmSpace */: + case 8197 /* fourPerEmSpace */: + case 8198 /* sixPerEmSpace */: + case 8199 /* figureSpace */: + case 8200 /* punctuationSpace */: + case 8201 /* thinSpace */: + case 8202 /* hairSpace */: + case 8203 /* zeroWidthSpace */: + case 8239 /* narrowNoBreakSpace */: + case 12288 /* ideographicSpace */: + + case 9 /* tab */: + case 11 /* verticalTab */: + case 12 /* formFeed */: + case 65279 /* byteOrderMark */: + trivia.push(this.scanWhitespaceTrivia()); + continue; + + case 47 /* slash */: + var ch2 = this.slidingWindow.peekItemN(1); + if (ch2 === 47 /* slash */) { + trivia.push(this.scanSingleLineCommentTrivia()); + continue; + } + + if (ch2 === 42 /* asterisk */) { + trivia.push(this.scanMultiLineCommentTrivia()); + continue; + } + + throw TypeScript.Errors.invalidOperation(); + + case 13 /* carriageReturn */: + case 10 /* lineFeed */: + case 8233 /* paragraphSeparator */: + case 8232 /* lineSeparator */: + trivia.push(this.scanLineTerminatorSequenceTrivia(ch)); + + if (!isTrailing) { + continue; + } + + break; + + default: + throw TypeScript.Errors.invalidOperation(); + } + } + + return TypeScript.Syntax.triviaList(trivia); + } + }; + + Scanner.prototype.scanTriviaInfo = function (diagnostics, isTrailing) { + var width = 0; + var hasCommentOrNewLine = 0; + + while (true) { + var ch = this.currentCharCode(); + + switch (ch) { + case 32 /* space */: + case 160 /* nonBreakingSpace */: + case 8192 /* enQuad */: + case 8193 /* emQuad */: + case 8194 /* enSpace */: + case 8195 /* emSpace */: + case 8196 /* threePerEmSpace */: + case 8197 /* fourPerEmSpace */: + case 8198 /* sixPerEmSpace */: + case 8199 /* figureSpace */: + case 8200 /* punctuationSpace */: + case 8201 /* thinSpace */: + case 8202 /* hairSpace */: + case 8203 /* zeroWidthSpace */: + case 8239 /* narrowNoBreakSpace */: + case 12288 /* ideographicSpace */: + + case 9 /* tab */: + case 11 /* verticalTab */: + case 12 /* formFeed */: + case 65279 /* byteOrderMark */: + this.slidingWindow.moveToNextItem(); + width++; + continue; + + case 47 /* slash */: + var ch2 = this.slidingWindow.peekItemN(1); + if (ch2 === 47 /* slash */) { + hasCommentOrNewLine |= 2 /* TriviaCommentMask */; + width += this.scanSingleLineCommentTriviaLength(); + continue; + } + + if (ch2 === 42 /* asterisk */) { + hasCommentOrNewLine |= 2 /* TriviaCommentMask */; + width += this.scanMultiLineCommentTriviaLength(diagnostics); + continue; + } + + break; + + case 13 /* carriageReturn */: + case 10 /* lineFeed */: + case 8233 /* paragraphSeparator */: + case 8232 /* lineSeparator */: + hasCommentOrNewLine |= 1 /* TriviaNewLineMask */; + width += this.scanLineTerminatorSequenceLength(ch); + + if (!isTrailing) { + continue; + } + + break; + } + + return (width << 2 /* TriviaFullWidthShift */) | hasCommentOrNewLine; + } + }; + + Scanner.prototype.isNewLineCharacter = function (ch) { + switch (ch) { + case 13 /* carriageReturn */: + case 10 /* lineFeed */: + case 8233 /* paragraphSeparator */: + case 8232 /* lineSeparator */: + return true; + default: + return false; + } + }; + + Scanner.prototype.scanWhitespaceTrivia = function () { + var absoluteStartIndex = this.slidingWindow.getAndPinAbsoluteIndex(); + + var width = 0; + while (true) { + var ch = this.currentCharCode(); + + switch (ch) { + case 32 /* space */: + case 160 /* nonBreakingSpace */: + case 8192 /* enQuad */: + case 8193 /* emQuad */: + case 8194 /* enSpace */: + case 8195 /* emSpace */: + case 8196 /* threePerEmSpace */: + case 8197 /* fourPerEmSpace */: + case 8198 /* sixPerEmSpace */: + case 8199 /* figureSpace */: + case 8200 /* punctuationSpace */: + case 8201 /* thinSpace */: + case 8202 /* hairSpace */: + case 8203 /* zeroWidthSpace */: + case 8239 /* narrowNoBreakSpace */: + case 12288 /* ideographicSpace */: + + case 9 /* tab */: + case 11 /* verticalTab */: + case 12 /* formFeed */: + case 65279 /* byteOrderMark */: + this.slidingWindow.moveToNextItem(); + width++; + continue; + } + + break; + } + + var text = this.substring(absoluteStartIndex, absoluteStartIndex + width, false); + this.slidingWindow.releaseAndUnpinAbsoluteIndex(absoluteStartIndex); + + return TypeScript.Syntax.whitespace(text); + }; + + Scanner.prototype.scanSingleLineCommentTrivia = function () { + var absoluteStartIndex = this.slidingWindow.getAndPinAbsoluteIndex(); + var width = this.scanSingleLineCommentTriviaLength(); + + var text = this.substring(absoluteStartIndex, absoluteStartIndex + width, false); + this.slidingWindow.releaseAndUnpinAbsoluteIndex(absoluteStartIndex); + + return TypeScript.Syntax.singleLineComment(text); + }; + + Scanner.prototype.scanSingleLineCommentTriviaLength = function () { + this.slidingWindow.moveToNextItem(); + this.slidingWindow.moveToNextItem(); + + var width = 2; + while (true) { + if (this.slidingWindow.isAtEndOfSource() || this.isNewLineCharacter(this.currentCharCode())) { + return width; + } + + this.slidingWindow.moveToNextItem(); + width++; + } + }; + + Scanner.prototype.scanMultiLineCommentTrivia = function () { + var absoluteStartIndex = this.slidingWindow.getAndPinAbsoluteIndex(); + var width = this.scanMultiLineCommentTriviaLength(null); + + var text = this.substring(absoluteStartIndex, absoluteStartIndex + width, false); + this.slidingWindow.releaseAndUnpinAbsoluteIndex(absoluteStartIndex); + + return TypeScript.Syntax.multiLineComment(text); + }; + + Scanner.prototype.scanMultiLineCommentTriviaLength = function (diagnostics) { + this.slidingWindow.moveToNextItem(); + this.slidingWindow.moveToNextItem(); + + var width = 2; + while (true) { + if (this.slidingWindow.isAtEndOfSource()) { + if (diagnostics !== null) { + diagnostics.push(new TypeScript.Diagnostic(this.fileName, this.slidingWindow.absoluteIndex(), 0, TypeScript.DiagnosticCode.AsteriskSlash_expected, null)); + } + + return width; + } + + var ch = this.currentCharCode(); + if (ch === 42 /* asterisk */ && this.slidingWindow.peekItemN(1) === 47 /* slash */) { + this.slidingWindow.moveToNextItem(); + this.slidingWindow.moveToNextItem(); + width += 2; + return width; + } + + this.slidingWindow.moveToNextItem(); + width++; + } + }; + + Scanner.prototype.scanLineTerminatorSequenceTrivia = function (ch) { + var absoluteStartIndex = this.slidingWindow.getAndPinAbsoluteIndex(); + var width = this.scanLineTerminatorSequenceLength(ch); + + var text = this.substring(absoluteStartIndex, absoluteStartIndex + width, false); + this.slidingWindow.releaseAndUnpinAbsoluteIndex(absoluteStartIndex); + + return TypeScript.Syntax.trivia(5 /* NewLineTrivia */, text); + }; + + Scanner.prototype.scanLineTerminatorSequenceLength = function (ch) { + this.slidingWindow.moveToNextItem(); + + if (ch === 13 /* carriageReturn */ && this.currentCharCode() === 10 /* lineFeed */) { + this.slidingWindow.moveToNextItem(); + return 2; + } else { + return 1; + } + }; + + Scanner.prototype.scanSyntaxToken = function (diagnostics, allowRegularExpression) { + if (this.slidingWindow.isAtEndOfSource()) { + return 10 /* EndOfFileToken */; + } + + var character = this.currentCharCode(); + + switch (character) { + case 34 /* doubleQuote */: + case 39 /* singleQuote */: + return this.scanStringLiteral(diagnostics); + + case 47 /* slash */: + return this.scanSlashToken(allowRegularExpression); + + case 46 /* dot */: + return this.scanDotToken(); + + case 45 /* minus */: + return this.scanMinusToken(); + + case 33 /* exclamation */: + return this.scanExclamationToken(); + + case 61 /* equals */: + return this.scanEqualsToken(); + + case 124 /* bar */: + return this.scanBarToken(); + + case 42 /* asterisk */: + return this.scanAsteriskToken(); + + case 43 /* plus */: + return this.scanPlusToken(); + + case 37 /* percent */: + return this.scanPercentToken(); + + case 38 /* ampersand */: + return this.scanAmpersandToken(); + + case 94 /* caret */: + return this.scanCaretToken(); + + case 60 /* lessThan */: + return this.scanLessThanToken(); + + case 62 /* greaterThan */: + return this.advanceAndSetTokenKind(81 /* GreaterThanToken */); + + case 44 /* comma */: + return this.advanceAndSetTokenKind(79 /* CommaToken */); + + case 58 /* colon */: + return this.advanceAndSetTokenKind(106 /* ColonToken */); + + case 59 /* semicolon */: + return this.advanceAndSetTokenKind(78 /* SemicolonToken */); + + case 126 /* tilde */: + return this.advanceAndSetTokenKind(102 /* TildeToken */); + + case 40 /* openParen */: + return this.advanceAndSetTokenKind(72 /* OpenParenToken */); + + case 41 /* closeParen */: + return this.advanceAndSetTokenKind(73 /* CloseParenToken */); + + case 123 /* openBrace */: + return this.advanceAndSetTokenKind(70 /* OpenBraceToken */); + + case 125 /* closeBrace */: + return this.advanceAndSetTokenKind(71 /* CloseBraceToken */); + + case 91 /* openBracket */: + return this.advanceAndSetTokenKind(74 /* OpenBracketToken */); + + case 93 /* closeBracket */: + return this.advanceAndSetTokenKind(75 /* CloseBracketToken */); + + case 63 /* question */: + return this.advanceAndSetTokenKind(105 /* QuestionToken */); + } + + if (isNumericLiteralStart[character]) { + return this.scanNumericLiteral(); + } + + if (isIdentifierStartCharacter[character]) { + var result = this.tryFastScanIdentifierOrKeyword(character); + if (result !== 0 /* None */) { + return result; + } + } + + if (this.isIdentifierStart(this.peekCharOrUnicodeEscape())) { + return this.slowScanIdentifier(diagnostics); + } + + return this.scanDefaultCharacter(character, diagnostics); + }; + + Scanner.prototype.isIdentifierStart = function (interpretedChar) { + if (isIdentifierStartCharacter[interpretedChar]) { + return true; + } + + return interpretedChar > 127 /* maxAsciiCharacter */ && TypeScript.Unicode.isIdentifierStart(interpretedChar, this._languageVersion); + }; + + Scanner.prototype.isIdentifierPart = function (interpretedChar) { + if (isIdentifierPartCharacter[interpretedChar]) { + return true; + } + + return interpretedChar > 127 /* maxAsciiCharacter */ && TypeScript.Unicode.isIdentifierPart(interpretedChar, this._languageVersion); + }; + + Scanner.prototype.tryFastScanIdentifierOrKeyword = function (firstCharacter) { + var startIndex = this.slidingWindow.getAndPinAbsoluteIndex(); + + while (true) { + var character = this.currentCharCode(); + if (isIdentifierPartCharacter[character]) { + this.slidingWindow.moveToNextItem(); + } else if (character === 92 /* backslash */ || character > 127 /* maxAsciiCharacter */) { + this.slidingWindow.rewindToPinnedIndex(startIndex); + this.slidingWindow.releaseAndUnpinAbsoluteIndex(startIndex); + return 0 /* None */; + } else { + var endIndex = this.slidingWindow.absoluteIndex(); + + var kind; + if (isKeywordStartCharacter[firstCharacter]) { + var offset = startIndex - this.slidingWindow.windowAbsoluteStartIndex; + kind = TypeScript.ScannerUtilities.identifierKind(this.slidingWindow.window, offset, endIndex - startIndex); + } else { + kind = 11 /* IdentifierName */; + } + + this.slidingWindow.releaseAndUnpinAbsoluteIndex(startIndex); + return kind; + } + } + }; + + Scanner.prototype.slowScanIdentifier = function (diagnostics) { + var startIndex = this.slidingWindow.absoluteIndex(); + + do { + this.scanCharOrUnicodeEscape(diagnostics); + } while(this.isIdentifierPart(this.peekCharOrUnicodeEscape())); + + return 11 /* IdentifierName */; + }; + + Scanner.prototype.scanNumericLiteral = function () { + if (this.isHexNumericLiteral()) { + return this.scanHexNumericLiteral(); + } else { + return this.scanDecimalNumericLiteral(); + } + }; + + Scanner.prototype.scanDecimalNumericLiteral = function () { + while (TypeScript.CharacterInfo.isDecimalDigit(this.currentCharCode())) { + this.slidingWindow.moveToNextItem(); + } + + if (this.currentCharCode() === 46 /* dot */) { + this.slidingWindow.moveToNextItem(); + } + + while (TypeScript.CharacterInfo.isDecimalDigit(this.currentCharCode())) { + this.slidingWindow.moveToNextItem(); + } + + var ch = this.currentCharCode(); + if (ch === 101 /* e */ || ch === 69 /* E */) { + this.slidingWindow.moveToNextItem(); + + ch = this.currentCharCode(); + if (ch === 45 /* minus */ || ch === 43 /* plus */) { + if (TypeScript.CharacterInfo.isDecimalDigit(this.slidingWindow.peekItemN(1))) { + this.slidingWindow.moveToNextItem(); + } + } + } + + while (TypeScript.CharacterInfo.isDecimalDigit(this.currentCharCode())) { + this.slidingWindow.moveToNextItem(); + } + + return 13 /* NumericLiteral */; + }; + + Scanner.prototype.scanHexNumericLiteral = function () { + this.slidingWindow.moveToNextItem(); + this.slidingWindow.moveToNextItem(); + + while (TypeScript.CharacterInfo.isHexDigit(this.currentCharCode())) { + this.slidingWindow.moveToNextItem(); + } + + return 13 /* NumericLiteral */; + }; + + Scanner.prototype.isHexNumericLiteral = function () { + if (this.currentCharCode() === 48 /* _0 */) { + var ch = this.slidingWindow.peekItemN(1); + + if (ch === 120 /* x */ || ch === 88 /* X */) { + ch = this.slidingWindow.peekItemN(2); + + return TypeScript.CharacterInfo.isHexDigit(ch); + } + } + + return false; + }; + + Scanner.prototype.advanceAndSetTokenKind = function (kind) { + this.slidingWindow.moveToNextItem(); + return kind; + }; + + Scanner.prototype.scanLessThanToken = function () { + this.slidingWindow.moveToNextItem(); + if (this.currentCharCode() === 61 /* equals */) { + this.slidingWindow.moveToNextItem(); + return 82 /* LessThanEqualsToken */; + } else if (this.currentCharCode() === 60 /* lessThan */) { + this.slidingWindow.moveToNextItem(); + if (this.currentCharCode() === 61 /* equals */) { + this.slidingWindow.moveToNextItem(); + return 112 /* LessThanLessThanEqualsToken */; + } else { + return 95 /* LessThanLessThanToken */; + } + } else { + return 80 /* LessThanToken */; + } + }; + + Scanner.prototype.scanBarToken = function () { + this.slidingWindow.moveToNextItem(); + if (this.currentCharCode() === 61 /* equals */) { + this.slidingWindow.moveToNextItem(); + return 116 /* BarEqualsToken */; + } else if (this.currentCharCode() === 124 /* bar */) { + this.slidingWindow.moveToNextItem(); + return 104 /* BarBarToken */; + } else { + return 99 /* BarToken */; + } + }; + + Scanner.prototype.scanCaretToken = function () { + this.slidingWindow.moveToNextItem(); + if (this.currentCharCode() === 61 /* equals */) { + this.slidingWindow.moveToNextItem(); + return 117 /* CaretEqualsToken */; + } else { + return 100 /* CaretToken */; + } + }; + + Scanner.prototype.scanAmpersandToken = function () { + this.slidingWindow.moveToNextItem(); + var character = this.currentCharCode(); + if (character === 61 /* equals */) { + this.slidingWindow.moveToNextItem(); + return 115 /* AmpersandEqualsToken */; + } else if (this.currentCharCode() === 38 /* ampersand */) { + this.slidingWindow.moveToNextItem(); + return 103 /* AmpersandAmpersandToken */; + } else { + return 98 /* AmpersandToken */; + } + }; + + Scanner.prototype.scanPercentToken = function () { + this.slidingWindow.moveToNextItem(); + if (this.currentCharCode() === 61 /* equals */) { + this.slidingWindow.moveToNextItem(); + return 111 /* PercentEqualsToken */; + } else { + return 92 /* PercentToken */; + } + }; + + Scanner.prototype.scanMinusToken = function () { + this.slidingWindow.moveToNextItem(); + var character = this.currentCharCode(); + + if (character === 61 /* equals */) { + this.slidingWindow.moveToNextItem(); + return 109 /* MinusEqualsToken */; + } else if (character === 45 /* minus */) { + this.slidingWindow.moveToNextItem(); + return 94 /* MinusMinusToken */; + } else { + return 90 /* MinusToken */; + } + }; + + Scanner.prototype.scanPlusToken = function () { + this.slidingWindow.moveToNextItem(); + var character = this.currentCharCode(); + if (character === 61 /* equals */) { + this.slidingWindow.moveToNextItem(); + return 108 /* PlusEqualsToken */; + } else if (character === 43 /* plus */) { + this.slidingWindow.moveToNextItem(); + return 93 /* PlusPlusToken */; + } else { + return 89 /* PlusToken */; + } + }; + + Scanner.prototype.scanAsteriskToken = function () { + this.slidingWindow.moveToNextItem(); + if (this.currentCharCode() === 61 /* equals */) { + this.slidingWindow.moveToNextItem(); + return 110 /* AsteriskEqualsToken */; + } else { + return 91 /* AsteriskToken */; + } + }; + + Scanner.prototype.scanEqualsToken = function () { + this.slidingWindow.moveToNextItem(); + var character = this.currentCharCode(); + if (character === 61 /* equals */) { + this.slidingWindow.moveToNextItem(); + + if (this.currentCharCode() === 61 /* equals */) { + this.slidingWindow.moveToNextItem(); + + return 87 /* EqualsEqualsEqualsToken */; + } else { + return 84 /* EqualsEqualsToken */; + } + } else if (character === 62 /* greaterThan */) { + this.slidingWindow.moveToNextItem(); + return 85 /* EqualsGreaterThanToken */; + } else { + return 107 /* EqualsToken */; + } + }; + + Scanner.prototype.isDotPrefixedNumericLiteral = function () { + if (this.currentCharCode() === 46 /* dot */) { + var ch = this.slidingWindow.peekItemN(1); + return TypeScript.CharacterInfo.isDecimalDigit(ch); + } + + return false; + }; + + Scanner.prototype.scanDotToken = function () { + if (this.isDotPrefixedNumericLiteral()) { + return this.scanNumericLiteral(); + } + + this.slidingWindow.moveToNextItem(); + if (this.currentCharCode() === 46 /* dot */ && this.slidingWindow.peekItemN(1) === 46 /* dot */) { + this.slidingWindow.moveToNextItem(); + this.slidingWindow.moveToNextItem(); + return 77 /* DotDotDotToken */; + } else { + return 76 /* DotToken */; + } + }; + + Scanner.prototype.scanSlashToken = function (allowRegularExpression) { + if (allowRegularExpression) { + var result = this.tryScanRegularExpressionToken(); + if (result !== 0 /* None */) { + return result; + } + } + + this.slidingWindow.moveToNextItem(); + if (this.currentCharCode() === 61 /* equals */) { + this.slidingWindow.moveToNextItem(); + return 119 /* SlashEqualsToken */; + } else { + return 118 /* SlashToken */; + } + }; + + Scanner.prototype.tryScanRegularExpressionToken = function () { + var startIndex = this.slidingWindow.getAndPinAbsoluteIndex(); + try { + this.slidingWindow.moveToNextItem(); + + var inEscape = false; + var inCharacterClass = false; + while (true) { + var ch = this.currentCharCode(); + if (this.isNewLineCharacter(ch) || this.slidingWindow.isAtEndOfSource()) { + this.slidingWindow.rewindToPinnedIndex(startIndex); + return 0 /* None */; + } + + this.slidingWindow.moveToNextItem(); + if (inEscape) { + inEscape = false; + continue; + } + + switch (ch) { + case 92 /* backslash */: + inEscape = true; + continue; + + case 91 /* openBracket */: + inCharacterClass = true; + continue; + + case 93 /* closeBracket */: + inCharacterClass = false; + continue; + + case 47 /* slash */: + if (inCharacterClass) { + continue; + } + + break; + + default: + continue; + } + + break; + } + + while (isIdentifierPartCharacter[this.currentCharCode()]) { + this.slidingWindow.moveToNextItem(); + } + + return 12 /* RegularExpressionLiteral */; + } finally { + this.slidingWindow.releaseAndUnpinAbsoluteIndex(startIndex); + } + }; + + Scanner.prototype.scanExclamationToken = function () { + this.slidingWindow.moveToNextItem(); + if (this.currentCharCode() === 61 /* equals */) { + this.slidingWindow.moveToNextItem(); + + if (this.currentCharCode() === 61 /* equals */) { + this.slidingWindow.moveToNextItem(); + + return 88 /* ExclamationEqualsEqualsToken */; + } else { + return 86 /* ExclamationEqualsToken */; + } + } else { + return 101 /* ExclamationToken */; + } + }; + + Scanner.prototype.scanDefaultCharacter = function (character, diagnostics) { + var position = this.slidingWindow.absoluteIndex(); + this.slidingWindow.moveToNextItem(); + + var text = String.fromCharCode(character); + var messageText = this.getErrorMessageText(text); + diagnostics.push(new TypeScript.Diagnostic(this.fileName, position, 1, TypeScript.DiagnosticCode.Unexpected_character_0, [messageText])); + + return 9 /* ErrorToken */; + }; + + Scanner.prototype.getErrorMessageText = function (text) { + if (text === "\\") { + return '"\\"'; + } + + return JSON.stringify(text); + }; + + Scanner.prototype.skipEscapeSequence = function (diagnostics) { + var rewindPoint = this.slidingWindow.getAndPinAbsoluteIndex(); + try { + this.slidingWindow.moveToNextItem(); + + var ch = this.currentCharCode(); + this.slidingWindow.moveToNextItem(); + switch (ch) { + case 120 /* x */: + case 117 /* u */: + this.slidingWindow.rewindToPinnedIndex(rewindPoint); + var value = this.scanUnicodeOrHexEscape(diagnostics); + return; + + case 13 /* carriageReturn */: + if (this.currentCharCode() === 10 /* lineFeed */) { + this.slidingWindow.moveToNextItem(); + } + return; + + default: + return; + } + } finally { + this.slidingWindow.releaseAndUnpinAbsoluteIndex(rewindPoint); + } + }; + + Scanner.prototype.scanStringLiteral = function (diagnostics) { + var quoteCharacter = this.currentCharCode(); + + this.slidingWindow.moveToNextItem(); + + while (true) { + var ch = this.currentCharCode(); + if (ch === 92 /* backslash */) { + this.skipEscapeSequence(diagnostics); + } else if (ch === quoteCharacter) { + this.slidingWindow.moveToNextItem(); + break; + } else if (this.isNewLineCharacter(ch) || this.slidingWindow.isAtEndOfSource()) { + diagnostics.push(new TypeScript.Diagnostic(this.fileName, this.slidingWindow.absoluteIndex(), 1, TypeScript.DiagnosticCode.Missing_close_quote_character, null)); + break; + } else { + this.slidingWindow.moveToNextItem(); + } + } + + return 14 /* StringLiteral */; + }; + + Scanner.prototype.isUnicodeOrHexEscape = function (character) { + return this.isUnicodeEscape(character) || this.isHexEscape(character); + }; + + Scanner.prototype.isUnicodeEscape = function (character) { + if (character === 92 /* backslash */) { + var ch2 = this.slidingWindow.peekItemN(1); + if (ch2 === 117 /* u */) { + return true; + } + } + + return false; + }; + + Scanner.prototype.isHexEscape = function (character) { + if (character === 92 /* backslash */) { + var ch2 = this.slidingWindow.peekItemN(1); + if (ch2 === 120 /* x */) { + return true; + } + } + + return false; + }; + + Scanner.prototype.peekCharOrUnicodeOrHexEscape = function () { + var character = this.currentCharCode(); + if (this.isUnicodeOrHexEscape(character)) { + return this.peekUnicodeOrHexEscape(); + } else { + return character; + } + }; + + Scanner.prototype.peekCharOrUnicodeEscape = function () { + var character = this.currentCharCode(); + if (this.isUnicodeEscape(character)) { + return this.peekUnicodeOrHexEscape(); + } else { + return character; + } + }; + + Scanner.prototype.peekUnicodeOrHexEscape = function () { + var startIndex = this.slidingWindow.getAndPinAbsoluteIndex(); + + var ch = this.scanUnicodeOrHexEscape(null); + + this.slidingWindow.rewindToPinnedIndex(startIndex); + this.slidingWindow.releaseAndUnpinAbsoluteIndex(startIndex); + + return ch; + }; + + Scanner.prototype.scanCharOrUnicodeEscape = function (errors) { + var ch = this.currentCharCode(); + if (ch === 92 /* backslash */) { + var ch2 = this.slidingWindow.peekItemN(1); + if (ch2 === 117 /* u */) { + return this.scanUnicodeOrHexEscape(errors); + } + } + + this.slidingWindow.moveToNextItem(); + return ch; + }; + + Scanner.prototype.scanCharOrUnicodeOrHexEscape = function (errors) { + var ch = this.currentCharCode(); + if (ch === 92 /* backslash */) { + var ch2 = this.slidingWindow.peekItemN(1); + if (ch2 === 117 /* u */ || ch2 === 120 /* x */) { + return this.scanUnicodeOrHexEscape(errors); + } + } + + this.slidingWindow.moveToNextItem(); + return ch; + }; + + Scanner.prototype.scanUnicodeOrHexEscape = function (errors) { + var start = this.slidingWindow.absoluteIndex(); + var character = this.currentCharCode(); + + this.slidingWindow.moveToNextItem(); + + character = this.currentCharCode(); + + var intChar = 0; + this.slidingWindow.moveToNextItem(); + + var count = character === 117 /* u */ ? 4 : 2; + + for (var i = 0; i < count; i++) { + var ch2 = this.currentCharCode(); + if (!TypeScript.CharacterInfo.isHexDigit(ch2)) { + if (errors !== null) { + var end = this.slidingWindow.absoluteIndex(); + var info = this.createIllegalEscapeDiagnostic(start, end); + errors.push(info); + } + + break; + } + + intChar = (intChar << 4) + TypeScript.CharacterInfo.hexValue(ch2); + this.slidingWindow.moveToNextItem(); + } + + return intChar; + }; + + Scanner.prototype.substring = function (start, end, intern) { + var length = end - start; + var offset = start - this.slidingWindow.windowAbsoluteStartIndex; + + if (intern) { + return TypeScript.Collections.DefaultStringTable.addCharArray(this.slidingWindow.window, offset, length); + } else { + return TypeScript.StringUtilities.fromCharCodeArray(this.slidingWindow.window.slice(offset, offset + length)); + } + }; + + Scanner.prototype.createIllegalEscapeDiagnostic = function (start, end) { + return new TypeScript.Diagnostic(this.fileName, start, end - start, TypeScript.DiagnosticCode.Unrecognized_escape_sequence, null); + }; + + Scanner.isValidIdentifier = function (text, languageVersion) { + var scanner = new Scanner(null, text, TypeScript.LanguageVersion, Scanner.triviaWindow); + var errors = new Array(); + var token = scanner.scan(errors, false); + + return errors.length === 0 && TypeScript.SyntaxFacts.isIdentifierNameOrAnyKeyword(token) && token.width() === text.length(); + }; + Scanner.triviaWindow = TypeScript.ArrayUtilities.createArray(2048, 0); + return Scanner; + })(); + TypeScript.Scanner = Scanner; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var ScannerUtilities = (function () { + function ScannerUtilities() { + } + ScannerUtilities.identifierKind = function (array, startIndex, length) { + switch (length) { + case 2: + switch (array[startIndex]) { + case 100 /* d */: + return (array[startIndex + 1] === 111 /* o */) ? 22 /* DoKeyword */ : 11 /* IdentifierName */; + case 105 /* i */: + switch (array[startIndex + 1]) { + case 102 /* f */: + return 28 /* IfKeyword */; + case 110 /* n */: + return 29 /* InKeyword */; + default: + return 11 /* IdentifierName */; + } + + default: + return 11 /* IdentifierName */; + } + + case 3: + switch (array[startIndex]) { + case 102 /* f */: + return (array[startIndex + 1] === 111 /* o */ && array[startIndex + 2] === 114 /* r */) ? 26 /* ForKeyword */ : 11 /* IdentifierName */; + case 110 /* n */: + return (array[startIndex + 1] === 101 /* e */ && array[startIndex + 2] === 119 /* w */) ? 31 /* NewKeyword */ : 11 /* IdentifierName */; + case 116 /* t */: + return (array[startIndex + 1] === 114 /* r */ && array[startIndex + 2] === 121 /* y */) ? 38 /* TryKeyword */ : 11 /* IdentifierName */; + case 118 /* v */: + return (array[startIndex + 1] === 97 /* a */ && array[startIndex + 2] === 114 /* r */) ? 40 /* VarKeyword */ : 11 /* IdentifierName */; + case 108 /* l */: + return (array[startIndex + 1] === 101 /* e */ && array[startIndex + 2] === 116 /* t */) ? 53 /* LetKeyword */ : 11 /* IdentifierName */; + case 97 /* a */: + return (array[startIndex + 1] === 110 /* n */ && array[startIndex + 2] === 121 /* y */) ? 60 /* AnyKeyword */ : 11 /* IdentifierName */; + case 103 /* g */: + return (array[startIndex + 1] === 101 /* e */ && array[startIndex + 2] === 116 /* t */) ? 64 /* GetKeyword */ : 11 /* IdentifierName */; + case 115 /* s */: + return (array[startIndex + 1] === 101 /* e */ && array[startIndex + 2] === 116 /* t */) ? 68 /* SetKeyword */ : 11 /* IdentifierName */; + default: + return 11 /* IdentifierName */; + } + + case 4: + switch (array[startIndex]) { + case 99 /* c */: + return (array[startIndex + 1] === 97 /* a */ && array[startIndex + 2] === 115 /* s */ && array[startIndex + 3] === 101 /* e */) ? 16 /* CaseKeyword */ : 11 /* IdentifierName */; + case 101 /* e */: + switch (array[startIndex + 1]) { + case 108 /* l */: + return (array[startIndex + 2] === 115 /* s */ && array[startIndex + 3] === 101 /* e */) ? 23 /* ElseKeyword */ : 11 /* IdentifierName */; + case 110 /* n */: + return (array[startIndex + 2] === 117 /* u */ && array[startIndex + 3] === 109 /* m */) ? 46 /* EnumKeyword */ : 11 /* IdentifierName */; + default: + return 11 /* IdentifierName */; + } + + case 110 /* n */: + return (array[startIndex + 1] === 117 /* u */ && array[startIndex + 2] === 108 /* l */ && array[startIndex + 3] === 108 /* l */) ? 32 /* NullKeyword */ : 11 /* IdentifierName */; + case 116 /* t */: + switch (array[startIndex + 1]) { + case 104 /* h */: + return (array[startIndex + 2] === 105 /* i */ && array[startIndex + 3] === 115 /* s */) ? 35 /* ThisKeyword */ : 11 /* IdentifierName */; + case 114 /* r */: + return (array[startIndex + 2] === 117 /* u */ && array[startIndex + 3] === 101 /* e */) ? 37 /* TrueKeyword */ : 11 /* IdentifierName */; + default: + return 11 /* IdentifierName */; + } + + case 118 /* v */: + return (array[startIndex + 1] === 111 /* o */ && array[startIndex + 2] === 105 /* i */ && array[startIndex + 3] === 100 /* d */) ? 41 /* VoidKeyword */ : 11 /* IdentifierName */; + case 119 /* w */: + return (array[startIndex + 1] === 105 /* i */ && array[startIndex + 2] === 116 /* t */ && array[startIndex + 3] === 104 /* h */) ? 43 /* WithKeyword */ : 11 /* IdentifierName */; + default: + return 11 /* IdentifierName */; + } + + case 5: + switch (array[startIndex]) { + case 98 /* b */: + return (array[startIndex + 1] === 114 /* r */ && array[startIndex + 2] === 101 /* e */ && array[startIndex + 3] === 97 /* a */ && array[startIndex + 4] === 107 /* k */) ? 15 /* BreakKeyword */ : 11 /* IdentifierName */; + case 99 /* c */: + switch (array[startIndex + 1]) { + case 97 /* a */: + return (array[startIndex + 2] === 116 /* t */ && array[startIndex + 3] === 99 /* c */ && array[startIndex + 4] === 104 /* h */) ? 17 /* CatchKeyword */ : 11 /* IdentifierName */; + case 108 /* l */: + return (array[startIndex + 2] === 97 /* a */ && array[startIndex + 3] === 115 /* s */ && array[startIndex + 4] === 115 /* s */) ? 44 /* ClassKeyword */ : 11 /* IdentifierName */; + case 111 /* o */: + return (array[startIndex + 2] === 110 /* n */ && array[startIndex + 3] === 115 /* s */ && array[startIndex + 4] === 116 /* t */) ? 45 /* ConstKeyword */ : 11 /* IdentifierName */; + default: + return 11 /* IdentifierName */; + } + + case 102 /* f */: + return (array[startIndex + 1] === 97 /* a */ && array[startIndex + 2] === 108 /* l */ && array[startIndex + 3] === 115 /* s */ && array[startIndex + 4] === 101 /* e */) ? 24 /* FalseKeyword */ : 11 /* IdentifierName */; + case 116 /* t */: + return (array[startIndex + 1] === 104 /* h */ && array[startIndex + 2] === 114 /* r */ && array[startIndex + 3] === 111 /* o */ && array[startIndex + 4] === 119 /* w */) ? 36 /* ThrowKeyword */ : 11 /* IdentifierName */; + case 119 /* w */: + return (array[startIndex + 1] === 104 /* h */ && array[startIndex + 2] === 105 /* i */ && array[startIndex + 3] === 108 /* l */ && array[startIndex + 4] === 101 /* e */) ? 42 /* WhileKeyword */ : 11 /* IdentifierName */; + case 115 /* s */: + return (array[startIndex + 1] === 117 /* u */ && array[startIndex + 2] === 112 /* p */ && array[startIndex + 3] === 101 /* e */ && array[startIndex + 4] === 114 /* r */) ? 50 /* SuperKeyword */ : 11 /* IdentifierName */; + case 121 /* y */: + return (array[startIndex + 1] === 105 /* i */ && array[startIndex + 2] === 101 /* e */ && array[startIndex + 3] === 108 /* l */ && array[startIndex + 4] === 100 /* d */) ? 59 /* YieldKeyword */ : 11 /* IdentifierName */; + default: + return 11 /* IdentifierName */; + } + + case 6: + switch (array[startIndex]) { + case 100 /* d */: + return (array[startIndex + 1] === 101 /* e */ && array[startIndex + 2] === 108 /* l */ && array[startIndex + 3] === 101 /* e */ && array[startIndex + 4] === 116 /* t */ && array[startIndex + 5] === 101 /* e */) ? 21 /* DeleteKeyword */ : 11 /* IdentifierName */; + case 114 /* r */: + return (array[startIndex + 1] === 101 /* e */ && array[startIndex + 2] === 116 /* t */ && array[startIndex + 3] === 117 /* u */ && array[startIndex + 4] === 114 /* r */ && array[startIndex + 5] === 110 /* n */) ? 33 /* ReturnKeyword */ : 11 /* IdentifierName */; + case 115 /* s */: + switch (array[startIndex + 1]) { + case 119 /* w */: + return (array[startIndex + 2] === 105 /* i */ && array[startIndex + 3] === 116 /* t */ && array[startIndex + 4] === 99 /* c */ && array[startIndex + 5] === 104 /* h */) ? 34 /* SwitchKeyword */ : 11 /* IdentifierName */; + case 116 /* t */: + switch (array[startIndex + 2]) { + case 97 /* a */: + return (array[startIndex + 3] === 116 /* t */ && array[startIndex + 4] === 105 /* i */ && array[startIndex + 5] === 99 /* c */) ? 58 /* StaticKeyword */ : 11 /* IdentifierName */; + case 114 /* r */: + return (array[startIndex + 3] === 105 /* i */ && array[startIndex + 4] === 110 /* n */ && array[startIndex + 5] === 103 /* g */) ? 69 /* StringKeyword */ : 11 /* IdentifierName */; + default: + return 11 /* IdentifierName */; + } + + default: + return 11 /* IdentifierName */; + } + + case 116 /* t */: + return (array[startIndex + 1] === 121 /* y */ && array[startIndex + 2] === 112 /* p */ && array[startIndex + 3] === 101 /* e */ && array[startIndex + 4] === 111 /* o */ && array[startIndex + 5] === 102 /* f */) ? 39 /* TypeOfKeyword */ : 11 /* IdentifierName */; + case 101 /* e */: + return (array[startIndex + 1] === 120 /* x */ && array[startIndex + 2] === 112 /* p */ && array[startIndex + 3] === 111 /* o */ && array[startIndex + 4] === 114 /* r */ && array[startIndex + 5] === 116 /* t */) ? 47 /* ExportKeyword */ : 11 /* IdentifierName */; + case 105 /* i */: + return (array[startIndex + 1] === 109 /* m */ && array[startIndex + 2] === 112 /* p */ && array[startIndex + 3] === 111 /* o */ && array[startIndex + 4] === 114 /* r */ && array[startIndex + 5] === 116 /* t */) ? 49 /* ImportKeyword */ : 11 /* IdentifierName */; + case 112 /* p */: + return (array[startIndex + 1] === 117 /* u */ && array[startIndex + 2] === 98 /* b */ && array[startIndex + 3] === 108 /* l */ && array[startIndex + 4] === 105 /* i */ && array[startIndex + 5] === 99 /* c */) ? 57 /* PublicKeyword */ : 11 /* IdentifierName */; + case 109 /* m */: + return (array[startIndex + 1] === 111 /* o */ && array[startIndex + 2] === 100 /* d */ && array[startIndex + 3] === 117 /* u */ && array[startIndex + 4] === 108 /* l */ && array[startIndex + 5] === 101 /* e */) ? 65 /* ModuleKeyword */ : 11 /* IdentifierName */; + case 110 /* n */: + return (array[startIndex + 1] === 117 /* u */ && array[startIndex + 2] === 109 /* m */ && array[startIndex + 3] === 98 /* b */ && array[startIndex + 4] === 101 /* e */ && array[startIndex + 5] === 114 /* r */) ? 67 /* NumberKeyword */ : 11 /* IdentifierName */; + default: + return 11 /* IdentifierName */; + } + + case 7: + switch (array[startIndex]) { + case 100 /* d */: + switch (array[startIndex + 1]) { + case 101 /* e */: + switch (array[startIndex + 2]) { + case 102 /* f */: + return (array[startIndex + 3] === 97 /* a */ && array[startIndex + 4] === 117 /* u */ && array[startIndex + 5] === 108 /* l */ && array[startIndex + 6] === 116 /* t */) ? 20 /* DefaultKeyword */ : 11 /* IdentifierName */; + case 99 /* c */: + return (array[startIndex + 3] === 108 /* l */ && array[startIndex + 4] === 97 /* a */ && array[startIndex + 5] === 114 /* r */ && array[startIndex + 6] === 101 /* e */) ? 63 /* DeclareKeyword */ : 11 /* IdentifierName */; + default: + return 11 /* IdentifierName */; + } + + default: + return 11 /* IdentifierName */; + } + + case 102 /* f */: + return (array[startIndex + 1] === 105 /* i */ && array[startIndex + 2] === 110 /* n */ && array[startIndex + 3] === 97 /* a */ && array[startIndex + 4] === 108 /* l */ && array[startIndex + 5] === 108 /* l */ && array[startIndex + 6] === 121 /* y */) ? 25 /* FinallyKeyword */ : 11 /* IdentifierName */; + case 101 /* e */: + return (array[startIndex + 1] === 120 /* x */ && array[startIndex + 2] === 116 /* t */ && array[startIndex + 3] === 101 /* e */ && array[startIndex + 4] === 110 /* n */ && array[startIndex + 5] === 100 /* d */ && array[startIndex + 6] === 115 /* s */) ? 48 /* ExtendsKeyword */ : 11 /* IdentifierName */; + case 112 /* p */: + switch (array[startIndex + 1]) { + case 97 /* a */: + return (array[startIndex + 2] === 99 /* c */ && array[startIndex + 3] === 107 /* k */ && array[startIndex + 4] === 97 /* a */ && array[startIndex + 5] === 103 /* g */ && array[startIndex + 6] === 101 /* e */) ? 54 /* PackageKeyword */ : 11 /* IdentifierName */; + case 114 /* r */: + return (array[startIndex + 2] === 105 /* i */ && array[startIndex + 3] === 118 /* v */ && array[startIndex + 4] === 97 /* a */ && array[startIndex + 5] === 116 /* t */ && array[startIndex + 6] === 101 /* e */) ? 55 /* PrivateKeyword */ : 11 /* IdentifierName */; + default: + return 11 /* IdentifierName */; + } + + case 98 /* b */: + return (array[startIndex + 1] === 111 /* o */ && array[startIndex + 2] === 111 /* o */ && array[startIndex + 3] === 108 /* l */ && array[startIndex + 4] === 101 /* e */ && array[startIndex + 5] === 97 /* a */ && array[startIndex + 6] === 110 /* n */) ? 61 /* BooleanKeyword */ : 11 /* IdentifierName */; + case 114 /* r */: + return (array[startIndex + 1] === 101 /* e */ && array[startIndex + 2] === 113 /* q */ && array[startIndex + 3] === 117 /* u */ && array[startIndex + 4] === 105 /* i */ && array[startIndex + 5] === 114 /* r */ && array[startIndex + 6] === 101 /* e */) ? 66 /* RequireKeyword */ : 11 /* IdentifierName */; + default: + return 11 /* IdentifierName */; + } + + case 8: + switch (array[startIndex]) { + case 99 /* c */: + return (array[startIndex + 1] === 111 /* o */ && array[startIndex + 2] === 110 /* n */ && array[startIndex + 3] === 116 /* t */ && array[startIndex + 4] === 105 /* i */ && array[startIndex + 5] === 110 /* n */ && array[startIndex + 6] === 117 /* u */ && array[startIndex + 7] === 101 /* e */) ? 18 /* ContinueKeyword */ : 11 /* IdentifierName */; + case 100 /* d */: + return (array[startIndex + 1] === 101 /* e */ && array[startIndex + 2] === 98 /* b */ && array[startIndex + 3] === 117 /* u */ && array[startIndex + 4] === 103 /* g */ && array[startIndex + 5] === 103 /* g */ && array[startIndex + 6] === 101 /* e */ && array[startIndex + 7] === 114 /* r */) ? 19 /* DebuggerKeyword */ : 11 /* IdentifierName */; + case 102 /* f */: + return (array[startIndex + 1] === 117 /* u */ && array[startIndex + 2] === 110 /* n */ && array[startIndex + 3] === 99 /* c */ && array[startIndex + 4] === 116 /* t */ && array[startIndex + 5] === 105 /* i */ && array[startIndex + 6] === 111 /* o */ && array[startIndex + 7] === 110 /* n */) ? 27 /* FunctionKeyword */ : 11 /* IdentifierName */; + default: + return 11 /* IdentifierName */; + } + + case 9: + switch (array[startIndex]) { + case 105 /* i */: + return (array[startIndex + 1] === 110 /* n */ && array[startIndex + 2] === 116 /* t */ && array[startIndex + 3] === 101 /* e */ && array[startIndex + 4] === 114 /* r */ && array[startIndex + 5] === 102 /* f */ && array[startIndex + 6] === 97 /* a */ && array[startIndex + 7] === 99 /* c */ && array[startIndex + 8] === 101 /* e */) ? 52 /* InterfaceKeyword */ : 11 /* IdentifierName */; + case 112 /* p */: + return (array[startIndex + 1] === 114 /* r */ && array[startIndex + 2] === 111 /* o */ && array[startIndex + 3] === 116 /* t */ && array[startIndex + 4] === 101 /* e */ && array[startIndex + 5] === 99 /* c */ && array[startIndex + 6] === 116 /* t */ && array[startIndex + 7] === 101 /* e */ && array[startIndex + 8] === 100 /* d */) ? 56 /* ProtectedKeyword */ : 11 /* IdentifierName */; + default: + return 11 /* IdentifierName */; + } + + case 10: + switch (array[startIndex]) { + case 105 /* i */: + switch (array[startIndex + 1]) { + case 110 /* n */: + return (array[startIndex + 2] === 115 /* s */ && array[startIndex + 3] === 116 /* t */ && array[startIndex + 4] === 97 /* a */ && array[startIndex + 5] === 110 /* n */ && array[startIndex + 6] === 99 /* c */ && array[startIndex + 7] === 101 /* e */ && array[startIndex + 8] === 111 /* o */ && array[startIndex + 9] === 102 /* f */) ? 30 /* InstanceOfKeyword */ : 11 /* IdentifierName */; + case 109 /* m */: + return (array[startIndex + 2] === 112 /* p */ && array[startIndex + 3] === 108 /* l */ && array[startIndex + 4] === 101 /* e */ && array[startIndex + 5] === 109 /* m */ && array[startIndex + 6] === 101 /* e */ && array[startIndex + 7] === 110 /* n */ && array[startIndex + 8] === 116 /* t */ && array[startIndex + 9] === 115 /* s */) ? 51 /* ImplementsKeyword */ : 11 /* IdentifierName */; + default: + return 11 /* IdentifierName */; + } + + default: + return 11 /* IdentifierName */; + } + + case 11: + return (array[startIndex] === 99 /* c */ && array[startIndex + 1] === 111 /* o */ && array[startIndex + 2] === 110 /* n */ && array[startIndex + 3] === 115 /* s */ && array[startIndex + 4] === 116 /* t */ && array[startIndex + 5] === 114 /* r */ && array[startIndex + 6] === 117 /* u */ && array[startIndex + 7] === 99 /* c */ && array[startIndex + 8] === 116 /* t */ && array[startIndex + 9] === 111 /* o */ && array[startIndex + 10] === 114 /* r */) ? 62 /* ConstructorKeyword */ : 11 /* IdentifierName */; + default: + return 11 /* IdentifierName */; + } + }; + return ScannerUtilities; + })(); + TypeScript.ScannerUtilities = ScannerUtilities; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (Syntax) { + var EmptySeparatedSyntaxList = (function () { + function EmptySeparatedSyntaxList() { + } + EmptySeparatedSyntaxList.prototype.kind = function () { + return 2 /* SeparatedList */; + }; + + EmptySeparatedSyntaxList.prototype.isNode = function () { + return false; + }; + + EmptySeparatedSyntaxList.prototype.isToken = function () { + return false; + }; + + EmptySeparatedSyntaxList.prototype.isList = function () { + return false; + }; + + EmptySeparatedSyntaxList.prototype.isSeparatedList = function () { + return true; + }; + + EmptySeparatedSyntaxList.prototype.toJSON = function (key) { + return []; + }; + + EmptySeparatedSyntaxList.prototype.childCount = function () { + return 0; + }; + + EmptySeparatedSyntaxList.prototype.nonSeparatorCount = function () { + return 0; + }; + + EmptySeparatedSyntaxList.prototype.separatorCount = function () { + return 0; + }; + + EmptySeparatedSyntaxList.prototype.toArray = function () { + return []; + }; + + EmptySeparatedSyntaxList.prototype.toNonSeparatorArray = function () { + return []; + }; + + EmptySeparatedSyntaxList.prototype.childAt = function (index) { + throw TypeScript.Errors.argumentOutOfRange("index"); + }; + + EmptySeparatedSyntaxList.prototype.nonSeparatorAt = function (index) { + throw TypeScript.Errors.argumentOutOfRange("index"); + }; + + EmptySeparatedSyntaxList.prototype.separatorAt = function (index) { + throw TypeScript.Errors.argumentOutOfRange("index"); + }; + + EmptySeparatedSyntaxList.prototype.collectTextElements = function (elements) { + }; + + EmptySeparatedSyntaxList.prototype.firstToken = function () { + return null; + }; + + EmptySeparatedSyntaxList.prototype.lastToken = function () { + return null; + }; + + EmptySeparatedSyntaxList.prototype.fullWidth = function () { + return 0; + }; + + EmptySeparatedSyntaxList.prototype.fullText = function () { + return ""; + }; + + EmptySeparatedSyntaxList.prototype.width = function () { + return 0; + }; + + EmptySeparatedSyntaxList.prototype.isTypeScriptSpecific = function () { + return false; + }; + + EmptySeparatedSyntaxList.prototype.isIncrementallyUnusable = function () { + return false; + }; + + EmptySeparatedSyntaxList.prototype.findTokenInternal = function (parent, position, fullStart) { + throw TypeScript.Errors.invalidOperation(); + }; + + EmptySeparatedSyntaxList.prototype.insertChildrenInto = function (array, index) { + }; + + EmptySeparatedSyntaxList.prototype.leadingTrivia = function () { + return Syntax.emptyTriviaList; + }; + + EmptySeparatedSyntaxList.prototype.trailingTrivia = function () { + return Syntax.emptyTriviaList; + }; + + EmptySeparatedSyntaxList.prototype.leadingTriviaWidth = function () { + return 0; + }; + + EmptySeparatedSyntaxList.prototype.trailingTriviaWidth = function () { + return 0; + }; + return EmptySeparatedSyntaxList; + })(); + + Syntax.emptySeparatedList = new EmptySeparatedSyntaxList(); + + var SingletonSeparatedSyntaxList = (function () { + function SingletonSeparatedSyntaxList(item) { + this.item = item; + } + SingletonSeparatedSyntaxList.prototype.toJSON = function (key) { + return [this.item]; + }; + + SingletonSeparatedSyntaxList.prototype.kind = function () { + return 2 /* SeparatedList */; + }; + + SingletonSeparatedSyntaxList.prototype.isNode = function () { + return false; + }; + SingletonSeparatedSyntaxList.prototype.isToken = function () { + return false; + }; + SingletonSeparatedSyntaxList.prototype.isList = function () { + return false; + }; + SingletonSeparatedSyntaxList.prototype.isSeparatedList = function () { + return true; + }; + + SingletonSeparatedSyntaxList.prototype.childCount = function () { + return 1; + }; + SingletonSeparatedSyntaxList.prototype.nonSeparatorCount = function () { + return 1; + }; + SingletonSeparatedSyntaxList.prototype.separatorCount = function () { + return 0; + }; + + SingletonSeparatedSyntaxList.prototype.toArray = function () { + return [this.item]; + }; + SingletonSeparatedSyntaxList.prototype.toNonSeparatorArray = function () { + return [this.item]; + }; + + SingletonSeparatedSyntaxList.prototype.childAt = function (index) { + if (index !== 0) { + throw TypeScript.Errors.argumentOutOfRange("index"); + } + + return this.item; + }; + + SingletonSeparatedSyntaxList.prototype.nonSeparatorAt = function (index) { + if (index !== 0) { + throw TypeScript.Errors.argumentOutOfRange("index"); + } + + return this.item; + }; + + SingletonSeparatedSyntaxList.prototype.separatorAt = function (index) { + throw TypeScript.Errors.argumentOutOfRange("index"); + }; + + SingletonSeparatedSyntaxList.prototype.collectTextElements = function (elements) { + this.item.collectTextElements(elements); + }; + + SingletonSeparatedSyntaxList.prototype.firstToken = function () { + return this.item.firstToken(); + }; + + SingletonSeparatedSyntaxList.prototype.lastToken = function () { + return this.item.lastToken(); + }; + + SingletonSeparatedSyntaxList.prototype.fullWidth = function () { + return this.item.fullWidth(); + }; + + SingletonSeparatedSyntaxList.prototype.width = function () { + return this.item.width(); + }; + + SingletonSeparatedSyntaxList.prototype.fullText = function () { + return this.item.fullText(); + }; + + SingletonSeparatedSyntaxList.prototype.leadingTrivia = function () { + return this.item.leadingTrivia(); + }; + + SingletonSeparatedSyntaxList.prototype.trailingTrivia = function () { + return this.item.trailingTrivia(); + }; + + SingletonSeparatedSyntaxList.prototype.leadingTriviaWidth = function () { + return this.item.leadingTriviaWidth(); + }; + + SingletonSeparatedSyntaxList.prototype.trailingTriviaWidth = function () { + return this.item.trailingTriviaWidth(); + }; + + SingletonSeparatedSyntaxList.prototype.isTypeScriptSpecific = function () { + return this.item.isTypeScriptSpecific(); + }; + + SingletonSeparatedSyntaxList.prototype.isIncrementallyUnusable = function () { + return this.item.isIncrementallyUnusable(); + }; + + SingletonSeparatedSyntaxList.prototype.findTokenInternal = function (parent, position, fullStart) { + return (this.item).findTokenInternal(new TypeScript.PositionedSeparatedList(parent, this, fullStart), position, fullStart); + }; + + SingletonSeparatedSyntaxList.prototype.insertChildrenInto = function (array, index) { + array.splice(index, 0, this.item); + }; + return SingletonSeparatedSyntaxList; + })(); + + var NormalSeparatedSyntaxList = (function () { + function NormalSeparatedSyntaxList(elements) { + this._data = 0; + this.elements = elements; + } + NormalSeparatedSyntaxList.prototype.kind = function () { + return 2 /* SeparatedList */; + }; + + NormalSeparatedSyntaxList.prototype.isToken = function () { + return false; + }; + NormalSeparatedSyntaxList.prototype.isNode = function () { + return false; + }; + NormalSeparatedSyntaxList.prototype.isList = function () { + return false; + }; + NormalSeparatedSyntaxList.prototype.isSeparatedList = function () { + return true; + }; + NormalSeparatedSyntaxList.prototype.toJSON = function (key) { + return this.elements; + }; + + NormalSeparatedSyntaxList.prototype.childCount = function () { + return this.elements.length; + }; + NormalSeparatedSyntaxList.prototype.nonSeparatorCount = function () { + return TypeScript.IntegerUtilities.integerDivide(this.elements.length + 1, 2); + }; + NormalSeparatedSyntaxList.prototype.separatorCount = function () { + return TypeScript.IntegerUtilities.integerDivide(this.elements.length, 2); + }; + + NormalSeparatedSyntaxList.prototype.toArray = function () { + return this.elements.slice(0); + }; + + NormalSeparatedSyntaxList.prototype.toNonSeparatorArray = function () { + var result = []; + for (var i = 0, n = this.nonSeparatorCount(); i < n; i++) { + result.push(this.nonSeparatorAt(i)); + } + + return result; + }; + + NormalSeparatedSyntaxList.prototype.childAt = function (index) { + if (index < 0 || index >= this.elements.length) { + throw TypeScript.Errors.argumentOutOfRange("index"); + } + + return this.elements[index]; + }; + + NormalSeparatedSyntaxList.prototype.nonSeparatorAt = function (index) { + var value = index * 2; + if (value < 0 || value >= this.elements.length) { + throw TypeScript.Errors.argumentOutOfRange("index"); + } + + return this.elements[value]; + }; + + NormalSeparatedSyntaxList.prototype.separatorAt = function (index) { + var value = index * 2 + 1; + if (value < 0 || value >= this.elements.length) { + throw TypeScript.Errors.argumentOutOfRange("index"); + } + + return this.elements[value]; + }; + + NormalSeparatedSyntaxList.prototype.firstToken = function () { + var token; + for (var i = 0, n = this.elements.length; i < n; i++) { + if (i % 2 === 0) { + var nodeOrToken = this.elements[i]; + token = nodeOrToken.firstToken(); + if (token !== null) { + return token; + } + } else { + token = this.elements[i]; + if (token.width() > 0) { + return token; + } + } + } + + return null; + }; + + NormalSeparatedSyntaxList.prototype.lastToken = function () { + var token; + for (var i = this.elements.length - 1; i >= 0; i--) { + if (i % 2 === 0) { + var nodeOrToken = this.elements[i]; + token = nodeOrToken.lastToken(); + if (token !== null) { + return token; + } + } else { + token = this.elements[i]; + if (token.width() > 0) { + return token; + } + } + } + + return null; + }; + + NormalSeparatedSyntaxList.prototype.fullText = function () { + var elements = []; + this.collectTextElements(elements); + return elements.join(""); + }; + + NormalSeparatedSyntaxList.prototype.isTypeScriptSpecific = function () { + for (var i = 0, n = this.nonSeparatorCount(); i < n; i++) { + if (this.nonSeparatorAt(i).isTypeScriptSpecific()) { + return true; + } + } + + return false; + }; + + NormalSeparatedSyntaxList.prototype.isIncrementallyUnusable = function () { + return (this.data() & 2 /* NodeIncrementallyUnusableMask */) !== 0; + }; + + NormalSeparatedSyntaxList.prototype.fullWidth = function () { + return this.data() >>> 3 /* NodeFullWidthShift */; + }; + + NormalSeparatedSyntaxList.prototype.width = function () { + var fullWidth = this.fullWidth(); + return fullWidth - this.leadingTriviaWidth() - this.trailingTriviaWidth(); + }; + + NormalSeparatedSyntaxList.prototype.leadingTrivia = function () { + return this.firstToken().leadingTrivia(); + }; + + NormalSeparatedSyntaxList.prototype.trailingTrivia = function () { + return this.lastToken().trailingTrivia(); + }; + + NormalSeparatedSyntaxList.prototype.leadingTriviaWidth = function () { + return this.firstToken().leadingTriviaWidth(); + }; + + NormalSeparatedSyntaxList.prototype.trailingTriviaWidth = function () { + return this.lastToken().trailingTriviaWidth(); + }; + + NormalSeparatedSyntaxList.prototype.computeData = function () { + var fullWidth = 0; + var isIncrementallyUnusable = false; + + for (var i = 0, n = this.elements.length; i < n; i++) { + var element = this.elements[i]; + + var childWidth = element.fullWidth(); + fullWidth += childWidth; + + isIncrementallyUnusable = isIncrementallyUnusable || element.isIncrementallyUnusable(); + } + + return (fullWidth << 3 /* NodeFullWidthShift */) | (isIncrementallyUnusable ? 2 /* NodeIncrementallyUnusableMask */ : 0) | 1 /* NodeDataComputed */; + }; + + NormalSeparatedSyntaxList.prototype.data = function () { + if ((this._data & 1 /* NodeDataComputed */) === 0) { + this._data = this.computeData(); + } + + return this._data; + }; + + NormalSeparatedSyntaxList.prototype.findTokenInternal = function (parent, position, fullStart) { + parent = new TypeScript.PositionedSeparatedList(parent, this, fullStart); + for (var i = 0, n = this.elements.length; i < n; i++) { + var element = this.elements[i]; + + var childWidth = element.fullWidth(); + if (position < childWidth) { + return (element).findTokenInternal(parent, position, fullStart); + } + + position -= childWidth; + fullStart += childWidth; + } + + throw TypeScript.Errors.invalidOperation(); + }; + + NormalSeparatedSyntaxList.prototype.collectTextElements = function (elements) { + for (var i = 0, n = this.elements.length; i < n; i++) { + var element = this.elements[i]; + element.collectTextElements(elements); + } + }; + + NormalSeparatedSyntaxList.prototype.insertChildrenInto = function (array, index) { + if (index === 0) { + array.unshift.apply(array, this.elements); + } else { + array.splice.apply(array, [index, 0].concat(this.elements)); + } + }; + return NormalSeparatedSyntaxList; + })(); + + function separatedList(nodes) { + return separatedListAndValidate(nodes, false); + } + Syntax.separatedList = separatedList; + + function separatedListAndValidate(nodes, validate) { + if (nodes === undefined || nodes === null || nodes.length === 0) { + return Syntax.emptySeparatedList; + } + + if (validate) { + for (var i = 0; i < nodes.length; i++) { + var item = nodes[i]; + + if (i % 2 === 1) { + } + } + } + + if (nodes.length === 1) { + return new SingletonSeparatedSyntaxList(nodes[0]); + } + + return new NormalSeparatedSyntaxList(nodes); + } + })(TypeScript.Syntax || (TypeScript.Syntax = {})); + var Syntax = TypeScript.Syntax; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var SlidingWindow = (function () { + function SlidingWindow(source, window, defaultValue, sourceLength) { + if (typeof sourceLength === "undefined") { sourceLength = -1; } + this.source = source; + this.window = window; + this.defaultValue = defaultValue; + this.sourceLength = sourceLength; + this.windowCount = 0; + this.windowAbsoluteStartIndex = 0; + this.currentRelativeItemIndex = 0; + this._pinCount = 0; + this.firstPinnedAbsoluteIndex = -1; + } + SlidingWindow.prototype.windowAbsoluteEndIndex = function () { + return this.windowAbsoluteStartIndex + this.windowCount; + }; + + SlidingWindow.prototype.addMoreItemsToWindow = function (argument) { + if (this.sourceLength >= 0 && this.absoluteIndex() >= this.sourceLength) { + return false; + } + + if (this.windowCount >= this.window.length) { + this.tryShiftOrGrowWindow(); + } + + var spaceAvailable = this.window.length - this.windowCount; + var amountFetched = this.source.fetchMoreItems(argument, this.windowAbsoluteEndIndex(), this.window, this.windowCount, spaceAvailable); + + this.windowCount += amountFetched; + return amountFetched > 0; + }; + + SlidingWindow.prototype.tryShiftOrGrowWindow = function () { + var currentIndexIsPastWindowHalfwayPoint = this.currentRelativeItemIndex > (this.window.length >>> 1); + + var isAllowedToShift = this.firstPinnedAbsoluteIndex === -1 || this.firstPinnedAbsoluteIndex > this.windowAbsoluteStartIndex; + + if (currentIndexIsPastWindowHalfwayPoint && isAllowedToShift) { + var shiftStartIndex = this.firstPinnedAbsoluteIndex === -1 ? this.currentRelativeItemIndex : this.firstPinnedAbsoluteIndex - this.windowAbsoluteStartIndex; + + var shiftCount = this.windowCount - shiftStartIndex; + + if (shiftCount > 0) { + TypeScript.ArrayUtilities.copy(this.window, shiftStartIndex, this.window, 0, shiftCount); + } + + this.windowAbsoluteStartIndex += shiftStartIndex; + + this.windowCount -= shiftStartIndex; + + this.currentRelativeItemIndex -= shiftStartIndex; + } else { + TypeScript.ArrayUtilities.grow(this.window, this.window.length * 2, this.defaultValue); + } + }; + + SlidingWindow.prototype.absoluteIndex = function () { + return this.windowAbsoluteStartIndex + this.currentRelativeItemIndex; + }; + + SlidingWindow.prototype.isAtEndOfSource = function () { + return this.absoluteIndex() >= this.sourceLength; + }; + + SlidingWindow.prototype.getAndPinAbsoluteIndex = function () { + var absoluteIndex = this.absoluteIndex(); + var pinCount = this._pinCount++; + if (pinCount === 0) { + this.firstPinnedAbsoluteIndex = absoluteIndex; + } + + return absoluteIndex; + }; + + SlidingWindow.prototype.releaseAndUnpinAbsoluteIndex = function (absoluteIndex) { + this._pinCount--; + if (this._pinCount === 0) { + this.firstPinnedAbsoluteIndex = -1; + } + }; + + SlidingWindow.prototype.rewindToPinnedIndex = function (absoluteIndex) { + var relativeIndex = absoluteIndex - this.windowAbsoluteStartIndex; + + this.currentRelativeItemIndex = relativeIndex; + }; + + SlidingWindow.prototype.currentItem = function (argument) { + if (this.currentRelativeItemIndex >= this.windowCount) { + if (!this.addMoreItemsToWindow(argument)) { + return this.defaultValue; + } + } + + return this.window[this.currentRelativeItemIndex]; + }; + + SlidingWindow.prototype.peekItemN = function (n) { + while (this.currentRelativeItemIndex + n >= this.windowCount) { + if (!this.addMoreItemsToWindow(null)) { + return this.defaultValue; + } + } + + return this.window[this.currentRelativeItemIndex + n]; + }; + + SlidingWindow.prototype.moveToNextItem = function () { + this.currentRelativeItemIndex++; + }; + + SlidingWindow.prototype.disgardAllItemsFromCurrentIndexOnwards = function () { + this.windowCount = this.currentRelativeItemIndex; + }; + + SlidingWindow.prototype.setAbsoluteIndex = function (absoluteIndex) { + if (this.absoluteIndex() === absoluteIndex) { + return; + } + + if (this._pinCount > 0) { + } + + if (absoluteIndex >= this.windowAbsoluteStartIndex && absoluteIndex < this.windowAbsoluteEndIndex()) { + this.currentRelativeItemIndex = (absoluteIndex - this.windowAbsoluteStartIndex); + } else { + this.windowAbsoluteStartIndex = absoluteIndex; + + this.windowCount = 0; + + this.currentRelativeItemIndex = 0; + } + }; + + SlidingWindow.prototype.pinCount = function () { + return this._pinCount; + }; + return SlidingWindow; + })(); + TypeScript.SlidingWindow = SlidingWindow; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (Syntax) { + function emptySourceUnit() { + return TypeScript.Syntax.normalModeFactory.sourceUnit(TypeScript.Syntax.emptyList, TypeScript.Syntax.token(10 /* EndOfFileToken */, { text: "" })); + } + Syntax.emptySourceUnit = emptySourceUnit; + + function getStandaloneExpression(positionedToken) { + var token = positionedToken.token(); + if (positionedToken !== null && positionedToken.kind() === 11 /* IdentifierName */) { + var parentPositionedNode = positionedToken.containingNode(); + var parentNode = parentPositionedNode.node(); + + if (parentNode.kind() === 121 /* QualifiedName */ && (parentNode).right === token) { + return parentPositionedNode; + } else if (parentNode.kind() === 211 /* MemberAccessExpression */ && (parentNode).name === token) { + return parentPositionedNode; + } + } + + return positionedToken; + } + Syntax.getStandaloneExpression = getStandaloneExpression; + + function isInModuleOrTypeContext(positionedToken) { + if (positionedToken !== null) { + var positionedNodeOrToken = TypeScript.Syntax.getStandaloneExpression(positionedToken); + var parent = positionedNodeOrToken.containingNode(); + + if (parent !== null) { + switch (parent.kind()) { + case 246 /* ModuleNameModuleReference */: + return true; + case 121 /* QualifiedName */: + return true; + default: + return isInTypeOnlyContext(positionedToken); + } + } + } + + return false; + } + Syntax.isInModuleOrTypeContext = isInModuleOrTypeContext; + + function isInTypeOnlyContext(positionedToken) { + var positionedNodeOrToken = TypeScript.Syntax.getStandaloneExpression(positionedToken); + var positionedParent = positionedNodeOrToken.containingNode(); + + var parent = positionedParent.node(); + var nodeOrToken = positionedNodeOrToken.nodeOrToken(); + + if (parent !== null) { + switch (parent.kind()) { + case 124 /* ArrayType */: + return (parent).type === nodeOrToken; + case 219 /* CastExpression */: + return (parent).type === nodeOrToken; + case 244 /* TypeAnnotation */: + case 229 /* HeritageClause */: + case 227 /* TypeArgumentList */: + return true; + } + } + + return false; + } + Syntax.isInTypeOnlyContext = isInTypeOnlyContext; + + function childOffset(parent, child) { + var offset = 0; + for (var i = 0, n = parent.childCount(); i < n; i++) { + var current = parent.childAt(i); + if (current === child) { + return offset; + } + + if (current !== null) { + offset += current.fullWidth(); + } + } + + throw TypeScript.Errors.invalidOperation(); + } + Syntax.childOffset = childOffset; + + function childOffsetAt(parent, index) { + var offset = 0; + for (var i = 0; i < index; i++) { + var current = parent.childAt(i); + if (current !== null) { + offset += current.fullWidth(); + } + } + + return offset; + } + Syntax.childOffsetAt = childOffsetAt; + + function childIndex(parent, child) { + for (var i = 0, n = parent.childCount(); i < n; i++) { + var current = parent.childAt(i); + if (current === child) { + return i; + } + } + + throw TypeScript.Errors.invalidOperation(); + } + Syntax.childIndex = childIndex; + + function nodeStructuralEquals(node1, node2) { + if (node1 === null) { + return node2 === null; + } + + return node1.structuralEquals(node2); + } + Syntax.nodeStructuralEquals = nodeStructuralEquals; + + function nodeOrTokenStructuralEquals(node1, node2) { + if (node1 === node2) { + return true; + } + + if (node1 === null || node2 === null) { + return false; + } + + if (node1.isToken()) { + return node2.isToken() ? tokenStructuralEquals(node1, node2) : false; + } + + return node2.isNode() ? nodeStructuralEquals(node1, node2) : false; + } + Syntax.nodeOrTokenStructuralEquals = nodeOrTokenStructuralEquals; + + function tokenStructuralEquals(token1, token2) { + if (token1 === token2) { + return true; + } + + if (token1 === null || token2 === null) { + return false; + } + + return token1.kind() === token2.kind() && token1.width() === token2.width() && token1.fullWidth() === token2.fullWidth() && token1.text() === token2.text() && TypeScript.Syntax.triviaListStructuralEquals(token1.leadingTrivia(), token2.leadingTrivia()) && TypeScript.Syntax.triviaListStructuralEquals(token1.trailingTrivia(), token2.trailingTrivia()); + } + Syntax.tokenStructuralEquals = tokenStructuralEquals; + + function triviaListStructuralEquals(triviaList1, triviaList2) { + if (triviaList1.count() !== triviaList2.count()) { + return false; + } + + for (var i = 0, n = triviaList1.count(); i < n; i++) { + if (!TypeScript.Syntax.triviaStructuralEquals(triviaList1.syntaxTriviaAt(i), triviaList2.syntaxTriviaAt(i))) { + return false; + } + } + + return true; + } + Syntax.triviaListStructuralEquals = triviaListStructuralEquals; + + function triviaStructuralEquals(trivia1, trivia2) { + return trivia1.kind() === trivia2.kind() && trivia1.fullWidth() === trivia2.fullWidth() && trivia1.fullText() === trivia2.fullText(); + } + Syntax.triviaStructuralEquals = triviaStructuralEquals; + + function listStructuralEquals(list1, list2) { + if (list1.childCount() !== list2.childCount()) { + return false; + } + + for (var i = 0, n = list1.childCount(); i < n; i++) { + var child1 = list1.childAt(i); + var child2 = list2.childAt(i); + + if (!TypeScript.Syntax.nodeOrTokenStructuralEquals(child1, child2)) { + return false; + } + } + + return true; + } + Syntax.listStructuralEquals = listStructuralEquals; + + function separatedListStructuralEquals(list1, list2) { + if (list1.childCount() !== list2.childCount()) { + return false; + } + + for (var i = 0, n = list1.childCount(); i < n; i++) { + var element1 = list1.childAt(i); + var element2 = list2.childAt(i); + if (!TypeScript.Syntax.nodeOrTokenStructuralEquals(element1, element2)) { + return false; + } + } + + return true; + } + Syntax.separatedListStructuralEquals = separatedListStructuralEquals; + + function elementStructuralEquals(element1, element2) { + if (element1 === element2) { + return true; + } + + if (element1 === null || element2 === null) { + return false; + } + + if (element2.kind() !== element2.kind()) { + return false; + } + + if (element1.isToken()) { + return tokenStructuralEquals(element1, element2); + } else if (element1.isNode()) { + return nodeStructuralEquals(element1, element2); + } else if (element1.isList()) { + return listStructuralEquals(element1, element2); + } else if (element1.isSeparatedList()) { + return separatedListStructuralEquals(element1, element2); + } + + throw TypeScript.Errors.invalidOperation(); + } + Syntax.elementStructuralEquals = elementStructuralEquals; + + function identifierName(text, info) { + if (typeof info === "undefined") { info = null; } + return Syntax.identifier(text); + } + Syntax.identifierName = identifierName; + + function trueExpression() { + return TypeScript.Syntax.token(37 /* TrueKeyword */); + } + Syntax.trueExpression = trueExpression; + + function falseExpression() { + return TypeScript.Syntax.token(24 /* FalseKeyword */); + } + Syntax.falseExpression = falseExpression; + + function numericLiteralExpression(text) { + return TypeScript.Syntax.token(13 /* NumericLiteral */, { text: text }); + } + Syntax.numericLiteralExpression = numericLiteralExpression; + + function stringLiteralExpression(text) { + return TypeScript.Syntax.token(14 /* StringLiteral */, { text: text }); + } + Syntax.stringLiteralExpression = stringLiteralExpression; + + function isSuperInvocationExpression(node) { + return node.kind() === 212 /* InvocationExpression */ && (node).expression.kind() === 50 /* SuperKeyword */; + } + Syntax.isSuperInvocationExpression = isSuperInvocationExpression; + + function isSuperInvocationExpressionStatement(node) { + return node.kind() === 148 /* ExpressionStatement */ && isSuperInvocationExpression((node).expression); + } + Syntax.isSuperInvocationExpressionStatement = isSuperInvocationExpressionStatement; + + function isSuperMemberAccessExpression(node) { + return node.kind() === 211 /* MemberAccessExpression */ && (node).expression.kind() === 50 /* SuperKeyword */; + } + Syntax.isSuperMemberAccessExpression = isSuperMemberAccessExpression; + + function isSuperMemberAccessInvocationExpression(node) { + return node.kind() === 212 /* InvocationExpression */ && isSuperMemberAccessExpression((node).expression); + } + Syntax.isSuperMemberAccessInvocationExpression = isSuperMemberAccessInvocationExpression; + + function assignmentExpression(left, token, right) { + return TypeScript.Syntax.normalModeFactory.binaryExpression(173 /* AssignmentExpression */, left, token, right); + } + Syntax.assignmentExpression = assignmentExpression; + + function nodeHasSkippedOrMissingTokens(node) { + for (var i = 0; i < node.childCount(); i++) { + var child = node.childAt(i); + if (child !== null && child.isToken()) { + var token = child; + + if (token.hasSkippedToken() || (token.width() === 0 && token.kind() !== 10 /* EndOfFileToken */)) { + return true; + } + } + } + return false; + } + Syntax.nodeHasSkippedOrMissingTokens = nodeHasSkippedOrMissingTokens; + + function isUnterminatedStringLiteral(token) { + if (token && token.kind() === 14 /* StringLiteral */) { + var text = token.text(); + return text.length < 2 || text.charCodeAt(text.length - 1) !== text.charCodeAt(0); + } + + return false; + } + Syntax.isUnterminatedStringLiteral = isUnterminatedStringLiteral; + + function isUnterminatedMultilineCommentTrivia(trivia) { + if (trivia && trivia.kind() === 6 /* MultiLineCommentTrivia */) { + var text = trivia.fullText(); + return text.length < 4 || text.substring(text.length - 2) !== "*/"; + } + return false; + } + Syntax.isUnterminatedMultilineCommentTrivia = isUnterminatedMultilineCommentTrivia; + + function isEntirelyInsideCommentTrivia(trivia, fullStart, position) { + if (trivia && trivia.isComment() && position > fullStart) { + var end = fullStart + trivia.fullWidth(); + if (position < end) { + return true; + } else if (position === end) { + return trivia.kind() === 7 /* SingleLineCommentTrivia */ || isUnterminatedMultilineCommentTrivia(trivia); + } + } + + return false; + } + Syntax.isEntirelyInsideCommentTrivia = isEntirelyInsideCommentTrivia; + + function isEntirelyInsideComment(sourceUnit, position) { + var positionedToken = sourceUnit.findToken(position); + var fullStart = positionedToken.fullStart(); + var triviaList = null; + var lastTriviaBeforeToken = null; + + if (positionedToken.kind() === 10 /* EndOfFileToken */) { + if (positionedToken.token().hasLeadingTrivia()) { + triviaList = positionedToken.token().leadingTrivia(); + } else { + positionedToken = positionedToken.previousToken(); + if (positionedToken) { + if (positionedToken && positionedToken.token().hasTrailingTrivia()) { + triviaList = positionedToken.token().trailingTrivia(); + fullStart = positionedToken.end(); + } + } + } + } else { + if (position <= (fullStart + positionedToken.token().leadingTriviaWidth())) { + triviaList = positionedToken.token().leadingTrivia(); + } else if (position >= (fullStart + positionedToken.token().width())) { + triviaList = positionedToken.token().trailingTrivia(); + fullStart = positionedToken.end(); + } + } + + if (triviaList) { + for (var i = 0, n = triviaList.count(); i < n; i++) { + var trivia = triviaList.syntaxTriviaAt(i); + if (position <= fullStart) { + break; + } else if (position <= fullStart + trivia.fullWidth() && trivia.isComment()) { + lastTriviaBeforeToken = trivia; + break; + } + + fullStart += trivia.fullWidth(); + } + } + + return lastTriviaBeforeToken && isEntirelyInsideCommentTrivia(lastTriviaBeforeToken, fullStart, position); + } + Syntax.isEntirelyInsideComment = isEntirelyInsideComment; + + function isEntirelyInStringOrRegularExpressionLiteral(sourceUnit, position) { + var positionedToken = sourceUnit.findToken(position); + + if (positionedToken) { + if (positionedToken.kind() === 10 /* EndOfFileToken */) { + positionedToken = positionedToken.previousToken(); + return positionedToken && positionedToken.token().trailingTriviaWidth() === 0 && isUnterminatedStringLiteral(positionedToken.token()); + } else if (position > positionedToken.start()) { + return (position < positionedToken.end() && (positionedToken.kind() === 14 /* StringLiteral */ || positionedToken.kind() === 12 /* RegularExpressionLiteral */)) || (position <= positionedToken.end() && isUnterminatedStringLiteral(positionedToken.token())); + } + } + + return false; + } + Syntax.isEntirelyInStringOrRegularExpressionLiteral = isEntirelyInStringOrRegularExpressionLiteral; + + function findSkippedTokenInTriviaList(positionedToken, position, lookInLeadingTriviaList) { + var triviaList = null; + var fullStart; + + if (lookInLeadingTriviaList) { + triviaList = positionedToken.token().leadingTrivia(); + fullStart = positionedToken.fullStart(); + } else { + triviaList = positionedToken.token().trailingTrivia(); + fullStart = positionedToken.end(); + } + + if (triviaList && triviaList.hasSkippedToken()) { + for (var i = 0, n = triviaList.count(); i < n; i++) { + var trivia = triviaList.syntaxTriviaAt(i); + var triviaWidth = trivia.fullWidth(); + + if (trivia.isSkippedToken() && position >= fullStart && position <= fullStart + triviaWidth) { + return new TypeScript.PositionedSkippedToken(positionedToken, trivia.skippedToken(), fullStart); + } + + fullStart += triviaWidth; + } + } + + return null; + } + + function findSkippedTokenOnLeftInTriviaList(positionedToken, position, lookInLeadingTriviaList) { + var triviaList = null; + var fullEnd; + + if (lookInLeadingTriviaList) { + triviaList = positionedToken.token().leadingTrivia(); + fullEnd = positionedToken.fullStart() + triviaList.fullWidth(); + } else { + triviaList = positionedToken.token().trailingTrivia(); + fullEnd = positionedToken.fullEnd(); + } + + if (triviaList && triviaList.hasSkippedToken()) { + for (var i = triviaList.count() - 1; i >= 0; i--) { + var trivia = triviaList.syntaxTriviaAt(i); + var triviaWidth = trivia.fullWidth(); + + if (trivia.isSkippedToken() && position >= fullEnd) { + return new TypeScript.PositionedSkippedToken(positionedToken, trivia.skippedToken(), fullEnd - triviaWidth); + } + + fullEnd -= triviaWidth; + } + } + + return null; + } + + function findSkippedTokenInLeadingTriviaList(positionedToken, position) { + return findSkippedTokenInTriviaList(positionedToken, position, true); + } + Syntax.findSkippedTokenInLeadingTriviaList = findSkippedTokenInLeadingTriviaList; + + function findSkippedTokenInTrailingTriviaList(positionedToken, position) { + return findSkippedTokenInTriviaList(positionedToken, position, false); + } + Syntax.findSkippedTokenInTrailingTriviaList = findSkippedTokenInTrailingTriviaList; + + function findSkippedTokenInPositionedToken(positionedToken, position) { + var positionInLeadingTriviaList = (position < positionedToken.start()); + return findSkippedTokenInTriviaList(positionedToken, position, positionInLeadingTriviaList); + } + Syntax.findSkippedTokenInPositionedToken = findSkippedTokenInPositionedToken; + + function findSkippedTokenOnLeft(positionedToken, position) { + var positionInLeadingTriviaList = (position < positionedToken.start()); + return findSkippedTokenOnLeftInTriviaList(positionedToken, position, positionInLeadingTriviaList); + } + Syntax.findSkippedTokenOnLeft = findSkippedTokenOnLeft; + + function getAncestorOfKind(positionedToken, kind) { + while (positionedToken && positionedToken.parent()) { + if (positionedToken.parent().kind() === kind) { + return positionedToken.parent(); + } + + positionedToken = positionedToken.parent(); + } + + return null; + } + Syntax.getAncestorOfKind = getAncestorOfKind; + + function hasAncestorOfKind(positionedToken, kind) { + return TypeScript.Syntax.getAncestorOfKind(positionedToken, kind) !== null; + } + Syntax.hasAncestorOfKind = hasAncestorOfKind; + + function isIntegerLiteral(expression) { + if (expression) { + switch (expression.kind()) { + case 163 /* PlusExpression */: + case 164 /* NegateExpression */: + expression = (expression).operand; + return isInteger((expression).text()); + + case 13 /* NumericLiteral */: + var text = (expression).text(); + return isInteger(text) || isHexInteger(text); + } + } + + return false; + } + Syntax.isIntegerLiteral = isIntegerLiteral; + + function isInteger(text) { + return /^[0-9]+$/.test(text); + } + + function isHexInteger(text) { + return /^0(x|X)[0-9a-fA-F]+$/.test(text); + } + Syntax.isHexInteger = isHexInteger; + })(TypeScript.Syntax || (TypeScript.Syntax = {})); + var Syntax = TypeScript.Syntax; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (Syntax) { + var NormalModeFactory = (function () { + function NormalModeFactory() { + } + NormalModeFactory.prototype.sourceUnit = function (moduleElements, endOfFileToken) { + return new TypeScript.SourceUnitSyntax(moduleElements, endOfFileToken, false); + }; + NormalModeFactory.prototype.externalModuleReference = function (requireKeyword, openParenToken, stringLiteral, closeParenToken) { + return new TypeScript.ExternalModuleReferenceSyntax(requireKeyword, openParenToken, stringLiteral, closeParenToken, false); + }; + NormalModeFactory.prototype.moduleNameModuleReference = function (moduleName) { + return new TypeScript.ModuleNameModuleReferenceSyntax(moduleName, false); + }; + NormalModeFactory.prototype.importDeclaration = function (modifiers, importKeyword, identifier, equalsToken, moduleReference, semicolonToken) { + return new TypeScript.ImportDeclarationSyntax(modifiers, importKeyword, identifier, equalsToken, moduleReference, semicolonToken, false); + }; + NormalModeFactory.prototype.exportAssignment = function (exportKeyword, equalsToken, identifier, semicolonToken) { + return new TypeScript.ExportAssignmentSyntax(exportKeyword, equalsToken, identifier, semicolonToken, false); + }; + NormalModeFactory.prototype.classDeclaration = function (modifiers, classKeyword, identifier, typeParameterList, heritageClauses, openBraceToken, classElements, closeBraceToken) { + return new TypeScript.ClassDeclarationSyntax(modifiers, classKeyword, identifier, typeParameterList, heritageClauses, openBraceToken, classElements, closeBraceToken, false); + }; + NormalModeFactory.prototype.interfaceDeclaration = function (modifiers, interfaceKeyword, identifier, typeParameterList, heritageClauses, body) { + return new TypeScript.InterfaceDeclarationSyntax(modifiers, interfaceKeyword, identifier, typeParameterList, heritageClauses, body, false); + }; + NormalModeFactory.prototype.heritageClause = function (extendsOrImplementsKeyword, typeNames) { + return new TypeScript.HeritageClauseSyntax(extendsOrImplementsKeyword, typeNames, false); + }; + NormalModeFactory.prototype.moduleDeclaration = function (modifiers, moduleKeyword, moduleName, stringLiteral, openBraceToken, moduleElements, closeBraceToken) { + return new TypeScript.ModuleDeclarationSyntax(modifiers, moduleKeyword, moduleName, stringLiteral, openBraceToken, moduleElements, closeBraceToken, false); + }; + NormalModeFactory.prototype.functionDeclaration = function (modifiers, functionKeyword, identifier, callSignature, block, semicolonToken) { + return new TypeScript.FunctionDeclarationSyntax(modifiers, functionKeyword, identifier, callSignature, block, semicolonToken, false); + }; + NormalModeFactory.prototype.variableStatement = function (modifiers, variableDeclaration, semicolonToken) { + return new TypeScript.VariableStatementSyntax(modifiers, variableDeclaration, semicolonToken, false); + }; + NormalModeFactory.prototype.variableDeclaration = function (varKeyword, variableDeclarators) { + return new TypeScript.VariableDeclarationSyntax(varKeyword, variableDeclarators, false); + }; + NormalModeFactory.prototype.variableDeclarator = function (identifier, typeAnnotation, equalsValueClause) { + return new TypeScript.VariableDeclaratorSyntax(identifier, typeAnnotation, equalsValueClause, false); + }; + NormalModeFactory.prototype.equalsValueClause = function (equalsToken, value) { + return new TypeScript.EqualsValueClauseSyntax(equalsToken, value, false); + }; + NormalModeFactory.prototype.prefixUnaryExpression = function (kind, operatorToken, operand) { + return new TypeScript.PrefixUnaryExpressionSyntax(kind, operatorToken, operand, false); + }; + NormalModeFactory.prototype.arrayLiteralExpression = function (openBracketToken, expressions, closeBracketToken) { + return new TypeScript.ArrayLiteralExpressionSyntax(openBracketToken, expressions, closeBracketToken, false); + }; + NormalModeFactory.prototype.omittedExpression = function () { + return new TypeScript.OmittedExpressionSyntax(false); + }; + NormalModeFactory.prototype.parenthesizedExpression = function (openParenToken, expression, closeParenToken) { + return new TypeScript.ParenthesizedExpressionSyntax(openParenToken, expression, closeParenToken, false); + }; + NormalModeFactory.prototype.simpleArrowFunctionExpression = function (identifier, equalsGreaterThanToken, body) { + return new TypeScript.SimpleArrowFunctionExpressionSyntax(identifier, equalsGreaterThanToken, body, false); + }; + NormalModeFactory.prototype.parenthesizedArrowFunctionExpression = function (callSignature, equalsGreaterThanToken, body) { + return new TypeScript.ParenthesizedArrowFunctionExpressionSyntax(callSignature, equalsGreaterThanToken, body, false); + }; + NormalModeFactory.prototype.qualifiedName = function (left, dotToken, right) { + return new TypeScript.QualifiedNameSyntax(left, dotToken, right, false); + }; + NormalModeFactory.prototype.typeArgumentList = function (lessThanToken, typeArguments, greaterThanToken) { + return new TypeScript.TypeArgumentListSyntax(lessThanToken, typeArguments, greaterThanToken, false); + }; + NormalModeFactory.prototype.constructorType = function (newKeyword, typeParameterList, parameterList, equalsGreaterThanToken, type) { + return new TypeScript.ConstructorTypeSyntax(newKeyword, typeParameterList, parameterList, equalsGreaterThanToken, type, false); + }; + NormalModeFactory.prototype.functionType = function (typeParameterList, parameterList, equalsGreaterThanToken, type) { + return new TypeScript.FunctionTypeSyntax(typeParameterList, parameterList, equalsGreaterThanToken, type, false); + }; + NormalModeFactory.prototype.objectType = function (openBraceToken, typeMembers, closeBraceToken) { + return new TypeScript.ObjectTypeSyntax(openBraceToken, typeMembers, closeBraceToken, false); + }; + NormalModeFactory.prototype.arrayType = function (type, openBracketToken, closeBracketToken) { + return new TypeScript.ArrayTypeSyntax(type, openBracketToken, closeBracketToken, false); + }; + NormalModeFactory.prototype.genericType = function (name, typeArgumentList) { + return new TypeScript.GenericTypeSyntax(name, typeArgumentList, false); + }; + NormalModeFactory.prototype.typeQuery = function (typeOfKeyword, name) { + return new TypeScript.TypeQuerySyntax(typeOfKeyword, name, false); + }; + NormalModeFactory.prototype.typeAnnotation = function (colonToken, type) { + return new TypeScript.TypeAnnotationSyntax(colonToken, type, false); + }; + NormalModeFactory.prototype.block = function (openBraceToken, statements, closeBraceToken) { + return new TypeScript.BlockSyntax(openBraceToken, statements, closeBraceToken, false); + }; + NormalModeFactory.prototype.parameter = function (dotDotDotToken, publicOrPrivateKeyword, identifier, questionToken, typeAnnotation, equalsValueClause) { + return new TypeScript.ParameterSyntax(dotDotDotToken, publicOrPrivateKeyword, identifier, questionToken, typeAnnotation, equalsValueClause, false); + }; + NormalModeFactory.prototype.memberAccessExpression = function (expression, dotToken, name) { + return new TypeScript.MemberAccessExpressionSyntax(expression, dotToken, name, false); + }; + NormalModeFactory.prototype.postfixUnaryExpression = function (kind, operand, operatorToken) { + return new TypeScript.PostfixUnaryExpressionSyntax(kind, operand, operatorToken, false); + }; + NormalModeFactory.prototype.elementAccessExpression = function (expression, openBracketToken, argumentExpression, closeBracketToken) { + return new TypeScript.ElementAccessExpressionSyntax(expression, openBracketToken, argumentExpression, closeBracketToken, false); + }; + NormalModeFactory.prototype.invocationExpression = function (expression, argumentList) { + return new TypeScript.InvocationExpressionSyntax(expression, argumentList, false); + }; + NormalModeFactory.prototype.argumentList = function (typeArgumentList, openParenToken, _arguments, closeParenToken) { + return new TypeScript.ArgumentListSyntax(typeArgumentList, openParenToken, _arguments, closeParenToken, false); + }; + NormalModeFactory.prototype.binaryExpression = function (kind, left, operatorToken, right) { + return new TypeScript.BinaryExpressionSyntax(kind, left, operatorToken, right, false); + }; + NormalModeFactory.prototype.conditionalExpression = function (condition, questionToken, whenTrue, colonToken, whenFalse) { + return new TypeScript.ConditionalExpressionSyntax(condition, questionToken, whenTrue, colonToken, whenFalse, false); + }; + NormalModeFactory.prototype.constructSignature = function (newKeyword, callSignature) { + return new TypeScript.ConstructSignatureSyntax(newKeyword, callSignature, false); + }; + NormalModeFactory.prototype.methodSignature = function (propertyName, questionToken, callSignature) { + return new TypeScript.MethodSignatureSyntax(propertyName, questionToken, callSignature, false); + }; + NormalModeFactory.prototype.indexSignature = function (openBracketToken, parameter, closeBracketToken, typeAnnotation) { + return new TypeScript.IndexSignatureSyntax(openBracketToken, parameter, closeBracketToken, typeAnnotation, false); + }; + NormalModeFactory.prototype.propertySignature = function (propertyName, questionToken, typeAnnotation) { + return new TypeScript.PropertySignatureSyntax(propertyName, questionToken, typeAnnotation, false); + }; + NormalModeFactory.prototype.callSignature = function (typeParameterList, parameterList, typeAnnotation) { + return new TypeScript.CallSignatureSyntax(typeParameterList, parameterList, typeAnnotation, false); + }; + NormalModeFactory.prototype.parameterList = function (openParenToken, parameters, closeParenToken) { + return new TypeScript.ParameterListSyntax(openParenToken, parameters, closeParenToken, false); + }; + NormalModeFactory.prototype.typeParameterList = function (lessThanToken, typeParameters, greaterThanToken) { + return new TypeScript.TypeParameterListSyntax(lessThanToken, typeParameters, greaterThanToken, false); + }; + NormalModeFactory.prototype.typeParameter = function (identifier, constraint) { + return new TypeScript.TypeParameterSyntax(identifier, constraint, false); + }; + NormalModeFactory.prototype.constraint = function (extendsKeyword, type) { + return new TypeScript.ConstraintSyntax(extendsKeyword, type, false); + }; + NormalModeFactory.prototype.elseClause = function (elseKeyword, statement) { + return new TypeScript.ElseClauseSyntax(elseKeyword, statement, false); + }; + NormalModeFactory.prototype.ifStatement = function (ifKeyword, openParenToken, condition, closeParenToken, statement, elseClause) { + return new TypeScript.IfStatementSyntax(ifKeyword, openParenToken, condition, closeParenToken, statement, elseClause, false); + }; + NormalModeFactory.prototype.expressionStatement = function (expression, semicolonToken) { + return new TypeScript.ExpressionStatementSyntax(expression, semicolonToken, false); + }; + NormalModeFactory.prototype.constructorDeclaration = function (constructorKeyword, parameterList, block, semicolonToken) { + return new TypeScript.ConstructorDeclarationSyntax(constructorKeyword, parameterList, block, semicolonToken, false); + }; + NormalModeFactory.prototype.memberFunctionDeclaration = function (modifiers, propertyName, callSignature, block, semicolonToken) { + return new TypeScript.MemberFunctionDeclarationSyntax(modifiers, propertyName, callSignature, block, semicolonToken, false); + }; + NormalModeFactory.prototype.getMemberAccessorDeclaration = function (modifiers, getKeyword, propertyName, parameterList, typeAnnotation, block) { + return new TypeScript.GetMemberAccessorDeclarationSyntax(modifiers, getKeyword, propertyName, parameterList, typeAnnotation, block, false); + }; + NormalModeFactory.prototype.setMemberAccessorDeclaration = function (modifiers, setKeyword, propertyName, parameterList, block) { + return new TypeScript.SetMemberAccessorDeclarationSyntax(modifiers, setKeyword, propertyName, parameterList, block, false); + }; + NormalModeFactory.prototype.memberVariableDeclaration = function (modifiers, variableDeclarator, semicolonToken) { + return new TypeScript.MemberVariableDeclarationSyntax(modifiers, variableDeclarator, semicolonToken, false); + }; + NormalModeFactory.prototype.throwStatement = function (throwKeyword, expression, semicolonToken) { + return new TypeScript.ThrowStatementSyntax(throwKeyword, expression, semicolonToken, false); + }; + NormalModeFactory.prototype.returnStatement = function (returnKeyword, expression, semicolonToken) { + return new TypeScript.ReturnStatementSyntax(returnKeyword, expression, semicolonToken, false); + }; + NormalModeFactory.prototype.objectCreationExpression = function (newKeyword, expression, argumentList) { + return new TypeScript.ObjectCreationExpressionSyntax(newKeyword, expression, argumentList, false); + }; + NormalModeFactory.prototype.switchStatement = function (switchKeyword, openParenToken, expression, closeParenToken, openBraceToken, switchClauses, closeBraceToken) { + return new TypeScript.SwitchStatementSyntax(switchKeyword, openParenToken, expression, closeParenToken, openBraceToken, switchClauses, closeBraceToken, false); + }; + NormalModeFactory.prototype.caseSwitchClause = function (caseKeyword, expression, colonToken, statements) { + return new TypeScript.CaseSwitchClauseSyntax(caseKeyword, expression, colonToken, statements, false); + }; + NormalModeFactory.prototype.defaultSwitchClause = function (defaultKeyword, colonToken, statements) { + return new TypeScript.DefaultSwitchClauseSyntax(defaultKeyword, colonToken, statements, false); + }; + NormalModeFactory.prototype.breakStatement = function (breakKeyword, identifier, semicolonToken) { + return new TypeScript.BreakStatementSyntax(breakKeyword, identifier, semicolonToken, false); + }; + NormalModeFactory.prototype.continueStatement = function (continueKeyword, identifier, semicolonToken) { + return new TypeScript.ContinueStatementSyntax(continueKeyword, identifier, semicolonToken, false); + }; + NormalModeFactory.prototype.forStatement = function (forKeyword, openParenToken, variableDeclaration, initializer, firstSemicolonToken, condition, secondSemicolonToken, incrementor, closeParenToken, statement) { + return new TypeScript.ForStatementSyntax(forKeyword, openParenToken, variableDeclaration, initializer, firstSemicolonToken, condition, secondSemicolonToken, incrementor, closeParenToken, statement, false); + }; + NormalModeFactory.prototype.forInStatement = function (forKeyword, openParenToken, variableDeclaration, left, inKeyword, expression, closeParenToken, statement) { + return new TypeScript.ForInStatementSyntax(forKeyword, openParenToken, variableDeclaration, left, inKeyword, expression, closeParenToken, statement, false); + }; + NormalModeFactory.prototype.whileStatement = function (whileKeyword, openParenToken, condition, closeParenToken, statement) { + return new TypeScript.WhileStatementSyntax(whileKeyword, openParenToken, condition, closeParenToken, statement, false); + }; + NormalModeFactory.prototype.withStatement = function (withKeyword, openParenToken, condition, closeParenToken, statement) { + return new TypeScript.WithStatementSyntax(withKeyword, openParenToken, condition, closeParenToken, statement, false); + }; + NormalModeFactory.prototype.enumDeclaration = function (modifiers, enumKeyword, identifier, openBraceToken, enumElements, closeBraceToken) { + return new TypeScript.EnumDeclarationSyntax(modifiers, enumKeyword, identifier, openBraceToken, enumElements, closeBraceToken, false); + }; + NormalModeFactory.prototype.enumElement = function (propertyName, equalsValueClause) { + return new TypeScript.EnumElementSyntax(propertyName, equalsValueClause, false); + }; + NormalModeFactory.prototype.castExpression = function (lessThanToken, type, greaterThanToken, expression) { + return new TypeScript.CastExpressionSyntax(lessThanToken, type, greaterThanToken, expression, false); + }; + NormalModeFactory.prototype.objectLiteralExpression = function (openBraceToken, propertyAssignments, closeBraceToken) { + return new TypeScript.ObjectLiteralExpressionSyntax(openBraceToken, propertyAssignments, closeBraceToken, false); + }; + NormalModeFactory.prototype.simplePropertyAssignment = function (propertyName, colonToken, expression) { + return new TypeScript.SimplePropertyAssignmentSyntax(propertyName, colonToken, expression, false); + }; + NormalModeFactory.prototype.functionPropertyAssignment = function (propertyName, callSignature, block) { + return new TypeScript.FunctionPropertyAssignmentSyntax(propertyName, callSignature, block, false); + }; + NormalModeFactory.prototype.getAccessorPropertyAssignment = function (getKeyword, propertyName, openParenToken, closeParenToken, typeAnnotation, block) { + return new TypeScript.GetAccessorPropertyAssignmentSyntax(getKeyword, propertyName, openParenToken, closeParenToken, typeAnnotation, block, false); + }; + NormalModeFactory.prototype.setAccessorPropertyAssignment = function (setKeyword, propertyName, openParenToken, parameter, closeParenToken, block) { + return new TypeScript.SetAccessorPropertyAssignmentSyntax(setKeyword, propertyName, openParenToken, parameter, closeParenToken, block, false); + }; + NormalModeFactory.prototype.functionExpression = function (functionKeyword, identifier, callSignature, block) { + return new TypeScript.FunctionExpressionSyntax(functionKeyword, identifier, callSignature, block, false); + }; + NormalModeFactory.prototype.emptyStatement = function (semicolonToken) { + return new TypeScript.EmptyStatementSyntax(semicolonToken, false); + }; + NormalModeFactory.prototype.tryStatement = function (tryKeyword, block, catchClause, finallyClause) { + return new TypeScript.TryStatementSyntax(tryKeyword, block, catchClause, finallyClause, false); + }; + NormalModeFactory.prototype.catchClause = function (catchKeyword, openParenToken, identifier, typeAnnotation, closeParenToken, block) { + return new TypeScript.CatchClauseSyntax(catchKeyword, openParenToken, identifier, typeAnnotation, closeParenToken, block, false); + }; + NormalModeFactory.prototype.finallyClause = function (finallyKeyword, block) { + return new TypeScript.FinallyClauseSyntax(finallyKeyword, block, false); + }; + NormalModeFactory.prototype.labeledStatement = function (identifier, colonToken, statement) { + return new TypeScript.LabeledStatementSyntax(identifier, colonToken, statement, false); + }; + NormalModeFactory.prototype.doStatement = function (doKeyword, statement, whileKeyword, openParenToken, condition, closeParenToken, semicolonToken) { + return new TypeScript.DoStatementSyntax(doKeyword, statement, whileKeyword, openParenToken, condition, closeParenToken, semicolonToken, false); + }; + NormalModeFactory.prototype.typeOfExpression = function (typeOfKeyword, expression) { + return new TypeScript.TypeOfExpressionSyntax(typeOfKeyword, expression, false); + }; + NormalModeFactory.prototype.deleteExpression = function (deleteKeyword, expression) { + return new TypeScript.DeleteExpressionSyntax(deleteKeyword, expression, false); + }; + NormalModeFactory.prototype.voidExpression = function (voidKeyword, expression) { + return new TypeScript.VoidExpressionSyntax(voidKeyword, expression, false); + }; + NormalModeFactory.prototype.debuggerStatement = function (debuggerKeyword, semicolonToken) { + return new TypeScript.DebuggerStatementSyntax(debuggerKeyword, semicolonToken, false); + }; + return NormalModeFactory; + })(); + Syntax.NormalModeFactory = NormalModeFactory; + + var StrictModeFactory = (function () { + function StrictModeFactory() { + } + StrictModeFactory.prototype.sourceUnit = function (moduleElements, endOfFileToken) { + return new TypeScript.SourceUnitSyntax(moduleElements, endOfFileToken, true); + }; + StrictModeFactory.prototype.externalModuleReference = function (requireKeyword, openParenToken, stringLiteral, closeParenToken) { + return new TypeScript.ExternalModuleReferenceSyntax(requireKeyword, openParenToken, stringLiteral, closeParenToken, true); + }; + StrictModeFactory.prototype.moduleNameModuleReference = function (moduleName) { + return new TypeScript.ModuleNameModuleReferenceSyntax(moduleName, true); + }; + StrictModeFactory.prototype.importDeclaration = function (modifiers, importKeyword, identifier, equalsToken, moduleReference, semicolonToken) { + return new TypeScript.ImportDeclarationSyntax(modifiers, importKeyword, identifier, equalsToken, moduleReference, semicolonToken, true); + }; + StrictModeFactory.prototype.exportAssignment = function (exportKeyword, equalsToken, identifier, semicolonToken) { + return new TypeScript.ExportAssignmentSyntax(exportKeyword, equalsToken, identifier, semicolonToken, true); + }; + StrictModeFactory.prototype.classDeclaration = function (modifiers, classKeyword, identifier, typeParameterList, heritageClauses, openBraceToken, classElements, closeBraceToken) { + return new TypeScript.ClassDeclarationSyntax(modifiers, classKeyword, identifier, typeParameterList, heritageClauses, openBraceToken, classElements, closeBraceToken, true); + }; + StrictModeFactory.prototype.interfaceDeclaration = function (modifiers, interfaceKeyword, identifier, typeParameterList, heritageClauses, body) { + return new TypeScript.InterfaceDeclarationSyntax(modifiers, interfaceKeyword, identifier, typeParameterList, heritageClauses, body, true); + }; + StrictModeFactory.prototype.heritageClause = function (extendsOrImplementsKeyword, typeNames) { + return new TypeScript.HeritageClauseSyntax(extendsOrImplementsKeyword, typeNames, true); + }; + StrictModeFactory.prototype.moduleDeclaration = function (modifiers, moduleKeyword, moduleName, stringLiteral, openBraceToken, moduleElements, closeBraceToken) { + return new TypeScript.ModuleDeclarationSyntax(modifiers, moduleKeyword, moduleName, stringLiteral, openBraceToken, moduleElements, closeBraceToken, true); + }; + StrictModeFactory.prototype.functionDeclaration = function (modifiers, functionKeyword, identifier, callSignature, block, semicolonToken) { + return new TypeScript.FunctionDeclarationSyntax(modifiers, functionKeyword, identifier, callSignature, block, semicolonToken, true); + }; + StrictModeFactory.prototype.variableStatement = function (modifiers, variableDeclaration, semicolonToken) { + return new TypeScript.VariableStatementSyntax(modifiers, variableDeclaration, semicolonToken, true); + }; + StrictModeFactory.prototype.variableDeclaration = function (varKeyword, variableDeclarators) { + return new TypeScript.VariableDeclarationSyntax(varKeyword, variableDeclarators, true); + }; + StrictModeFactory.prototype.variableDeclarator = function (identifier, typeAnnotation, equalsValueClause) { + return new TypeScript.VariableDeclaratorSyntax(identifier, typeAnnotation, equalsValueClause, true); + }; + StrictModeFactory.prototype.equalsValueClause = function (equalsToken, value) { + return new TypeScript.EqualsValueClauseSyntax(equalsToken, value, true); + }; + StrictModeFactory.prototype.prefixUnaryExpression = function (kind, operatorToken, operand) { + return new TypeScript.PrefixUnaryExpressionSyntax(kind, operatorToken, operand, true); + }; + StrictModeFactory.prototype.arrayLiteralExpression = function (openBracketToken, expressions, closeBracketToken) { + return new TypeScript.ArrayLiteralExpressionSyntax(openBracketToken, expressions, closeBracketToken, true); + }; + StrictModeFactory.prototype.omittedExpression = function () { + return new TypeScript.OmittedExpressionSyntax(true); + }; + StrictModeFactory.prototype.parenthesizedExpression = function (openParenToken, expression, closeParenToken) { + return new TypeScript.ParenthesizedExpressionSyntax(openParenToken, expression, closeParenToken, true); + }; + StrictModeFactory.prototype.simpleArrowFunctionExpression = function (identifier, equalsGreaterThanToken, body) { + return new TypeScript.SimpleArrowFunctionExpressionSyntax(identifier, equalsGreaterThanToken, body, true); + }; + StrictModeFactory.prototype.parenthesizedArrowFunctionExpression = function (callSignature, equalsGreaterThanToken, body) { + return new TypeScript.ParenthesizedArrowFunctionExpressionSyntax(callSignature, equalsGreaterThanToken, body, true); + }; + StrictModeFactory.prototype.qualifiedName = function (left, dotToken, right) { + return new TypeScript.QualifiedNameSyntax(left, dotToken, right, true); + }; + StrictModeFactory.prototype.typeArgumentList = function (lessThanToken, typeArguments, greaterThanToken) { + return new TypeScript.TypeArgumentListSyntax(lessThanToken, typeArguments, greaterThanToken, true); + }; + StrictModeFactory.prototype.constructorType = function (newKeyword, typeParameterList, parameterList, equalsGreaterThanToken, type) { + return new TypeScript.ConstructorTypeSyntax(newKeyword, typeParameterList, parameterList, equalsGreaterThanToken, type, true); + }; + StrictModeFactory.prototype.functionType = function (typeParameterList, parameterList, equalsGreaterThanToken, type) { + return new TypeScript.FunctionTypeSyntax(typeParameterList, parameterList, equalsGreaterThanToken, type, true); + }; + StrictModeFactory.prototype.objectType = function (openBraceToken, typeMembers, closeBraceToken) { + return new TypeScript.ObjectTypeSyntax(openBraceToken, typeMembers, closeBraceToken, true); + }; + StrictModeFactory.prototype.arrayType = function (type, openBracketToken, closeBracketToken) { + return new TypeScript.ArrayTypeSyntax(type, openBracketToken, closeBracketToken, true); + }; + StrictModeFactory.prototype.genericType = function (name, typeArgumentList) { + return new TypeScript.GenericTypeSyntax(name, typeArgumentList, true); + }; + StrictModeFactory.prototype.typeQuery = function (typeOfKeyword, name) { + return new TypeScript.TypeQuerySyntax(typeOfKeyword, name, true); + }; + StrictModeFactory.prototype.typeAnnotation = function (colonToken, type) { + return new TypeScript.TypeAnnotationSyntax(colonToken, type, true); + }; + StrictModeFactory.prototype.block = function (openBraceToken, statements, closeBraceToken) { + return new TypeScript.BlockSyntax(openBraceToken, statements, closeBraceToken, true); + }; + StrictModeFactory.prototype.parameter = function (dotDotDotToken, publicOrPrivateKeyword, identifier, questionToken, typeAnnotation, equalsValueClause) { + return new TypeScript.ParameterSyntax(dotDotDotToken, publicOrPrivateKeyword, identifier, questionToken, typeAnnotation, equalsValueClause, true); + }; + StrictModeFactory.prototype.memberAccessExpression = function (expression, dotToken, name) { + return new TypeScript.MemberAccessExpressionSyntax(expression, dotToken, name, true); + }; + StrictModeFactory.prototype.postfixUnaryExpression = function (kind, operand, operatorToken) { + return new TypeScript.PostfixUnaryExpressionSyntax(kind, operand, operatorToken, true); + }; + StrictModeFactory.prototype.elementAccessExpression = function (expression, openBracketToken, argumentExpression, closeBracketToken) { + return new TypeScript.ElementAccessExpressionSyntax(expression, openBracketToken, argumentExpression, closeBracketToken, true); + }; + StrictModeFactory.prototype.invocationExpression = function (expression, argumentList) { + return new TypeScript.InvocationExpressionSyntax(expression, argumentList, true); + }; + StrictModeFactory.prototype.argumentList = function (typeArgumentList, openParenToken, _arguments, closeParenToken) { + return new TypeScript.ArgumentListSyntax(typeArgumentList, openParenToken, _arguments, closeParenToken, true); + }; + StrictModeFactory.prototype.binaryExpression = function (kind, left, operatorToken, right) { + return new TypeScript.BinaryExpressionSyntax(kind, left, operatorToken, right, true); + }; + StrictModeFactory.prototype.conditionalExpression = function (condition, questionToken, whenTrue, colonToken, whenFalse) { + return new TypeScript.ConditionalExpressionSyntax(condition, questionToken, whenTrue, colonToken, whenFalse, true); + }; + StrictModeFactory.prototype.constructSignature = function (newKeyword, callSignature) { + return new TypeScript.ConstructSignatureSyntax(newKeyword, callSignature, true); + }; + StrictModeFactory.prototype.methodSignature = function (propertyName, questionToken, callSignature) { + return new TypeScript.MethodSignatureSyntax(propertyName, questionToken, callSignature, true); + }; + StrictModeFactory.prototype.indexSignature = function (openBracketToken, parameter, closeBracketToken, typeAnnotation) { + return new TypeScript.IndexSignatureSyntax(openBracketToken, parameter, closeBracketToken, typeAnnotation, true); + }; + StrictModeFactory.prototype.propertySignature = function (propertyName, questionToken, typeAnnotation) { + return new TypeScript.PropertySignatureSyntax(propertyName, questionToken, typeAnnotation, true); + }; + StrictModeFactory.prototype.callSignature = function (typeParameterList, parameterList, typeAnnotation) { + return new TypeScript.CallSignatureSyntax(typeParameterList, parameterList, typeAnnotation, true); + }; + StrictModeFactory.prototype.parameterList = function (openParenToken, parameters, closeParenToken) { + return new TypeScript.ParameterListSyntax(openParenToken, parameters, closeParenToken, true); + }; + StrictModeFactory.prototype.typeParameterList = function (lessThanToken, typeParameters, greaterThanToken) { + return new TypeScript.TypeParameterListSyntax(lessThanToken, typeParameters, greaterThanToken, true); + }; + StrictModeFactory.prototype.typeParameter = function (identifier, constraint) { + return new TypeScript.TypeParameterSyntax(identifier, constraint, true); + }; + StrictModeFactory.prototype.constraint = function (extendsKeyword, type) { + return new TypeScript.ConstraintSyntax(extendsKeyword, type, true); + }; + StrictModeFactory.prototype.elseClause = function (elseKeyword, statement) { + return new TypeScript.ElseClauseSyntax(elseKeyword, statement, true); + }; + StrictModeFactory.prototype.ifStatement = function (ifKeyword, openParenToken, condition, closeParenToken, statement, elseClause) { + return new TypeScript.IfStatementSyntax(ifKeyword, openParenToken, condition, closeParenToken, statement, elseClause, true); + }; + StrictModeFactory.prototype.expressionStatement = function (expression, semicolonToken) { + return new TypeScript.ExpressionStatementSyntax(expression, semicolonToken, true); + }; + StrictModeFactory.prototype.constructorDeclaration = function (constructorKeyword, parameterList, block, semicolonToken) { + return new TypeScript.ConstructorDeclarationSyntax(constructorKeyword, parameterList, block, semicolonToken, true); + }; + StrictModeFactory.prototype.memberFunctionDeclaration = function (modifiers, propertyName, callSignature, block, semicolonToken) { + return new TypeScript.MemberFunctionDeclarationSyntax(modifiers, propertyName, callSignature, block, semicolonToken, true); + }; + StrictModeFactory.prototype.getMemberAccessorDeclaration = function (modifiers, getKeyword, propertyName, parameterList, typeAnnotation, block) { + return new TypeScript.GetMemberAccessorDeclarationSyntax(modifiers, getKeyword, propertyName, parameterList, typeAnnotation, block, true); + }; + StrictModeFactory.prototype.setMemberAccessorDeclaration = function (modifiers, setKeyword, propertyName, parameterList, block) { + return new TypeScript.SetMemberAccessorDeclarationSyntax(modifiers, setKeyword, propertyName, parameterList, block, true); + }; + StrictModeFactory.prototype.memberVariableDeclaration = function (modifiers, variableDeclarator, semicolonToken) { + return new TypeScript.MemberVariableDeclarationSyntax(modifiers, variableDeclarator, semicolonToken, true); + }; + StrictModeFactory.prototype.throwStatement = function (throwKeyword, expression, semicolonToken) { + return new TypeScript.ThrowStatementSyntax(throwKeyword, expression, semicolonToken, true); + }; + StrictModeFactory.prototype.returnStatement = function (returnKeyword, expression, semicolonToken) { + return new TypeScript.ReturnStatementSyntax(returnKeyword, expression, semicolonToken, true); + }; + StrictModeFactory.prototype.objectCreationExpression = function (newKeyword, expression, argumentList) { + return new TypeScript.ObjectCreationExpressionSyntax(newKeyword, expression, argumentList, true); + }; + StrictModeFactory.prototype.switchStatement = function (switchKeyword, openParenToken, expression, closeParenToken, openBraceToken, switchClauses, closeBraceToken) { + return new TypeScript.SwitchStatementSyntax(switchKeyword, openParenToken, expression, closeParenToken, openBraceToken, switchClauses, closeBraceToken, true); + }; + StrictModeFactory.prototype.caseSwitchClause = function (caseKeyword, expression, colonToken, statements) { + return new TypeScript.CaseSwitchClauseSyntax(caseKeyword, expression, colonToken, statements, true); + }; + StrictModeFactory.prototype.defaultSwitchClause = function (defaultKeyword, colonToken, statements) { + return new TypeScript.DefaultSwitchClauseSyntax(defaultKeyword, colonToken, statements, true); + }; + StrictModeFactory.prototype.breakStatement = function (breakKeyword, identifier, semicolonToken) { + return new TypeScript.BreakStatementSyntax(breakKeyword, identifier, semicolonToken, true); + }; + StrictModeFactory.prototype.continueStatement = function (continueKeyword, identifier, semicolonToken) { + return new TypeScript.ContinueStatementSyntax(continueKeyword, identifier, semicolonToken, true); + }; + StrictModeFactory.prototype.forStatement = function (forKeyword, openParenToken, variableDeclaration, initializer, firstSemicolonToken, condition, secondSemicolonToken, incrementor, closeParenToken, statement) { + return new TypeScript.ForStatementSyntax(forKeyword, openParenToken, variableDeclaration, initializer, firstSemicolonToken, condition, secondSemicolonToken, incrementor, closeParenToken, statement, true); + }; + StrictModeFactory.prototype.forInStatement = function (forKeyword, openParenToken, variableDeclaration, left, inKeyword, expression, closeParenToken, statement) { + return new TypeScript.ForInStatementSyntax(forKeyword, openParenToken, variableDeclaration, left, inKeyword, expression, closeParenToken, statement, true); + }; + StrictModeFactory.prototype.whileStatement = function (whileKeyword, openParenToken, condition, closeParenToken, statement) { + return new TypeScript.WhileStatementSyntax(whileKeyword, openParenToken, condition, closeParenToken, statement, true); + }; + StrictModeFactory.prototype.withStatement = function (withKeyword, openParenToken, condition, closeParenToken, statement) { + return new TypeScript.WithStatementSyntax(withKeyword, openParenToken, condition, closeParenToken, statement, true); + }; + StrictModeFactory.prototype.enumDeclaration = function (modifiers, enumKeyword, identifier, openBraceToken, enumElements, closeBraceToken) { + return new TypeScript.EnumDeclarationSyntax(modifiers, enumKeyword, identifier, openBraceToken, enumElements, closeBraceToken, true); + }; + StrictModeFactory.prototype.enumElement = function (propertyName, equalsValueClause) { + return new TypeScript.EnumElementSyntax(propertyName, equalsValueClause, true); + }; + StrictModeFactory.prototype.castExpression = function (lessThanToken, type, greaterThanToken, expression) { + return new TypeScript.CastExpressionSyntax(lessThanToken, type, greaterThanToken, expression, true); + }; + StrictModeFactory.prototype.objectLiteralExpression = function (openBraceToken, propertyAssignments, closeBraceToken) { + return new TypeScript.ObjectLiteralExpressionSyntax(openBraceToken, propertyAssignments, closeBraceToken, true); + }; + StrictModeFactory.prototype.simplePropertyAssignment = function (propertyName, colonToken, expression) { + return new TypeScript.SimplePropertyAssignmentSyntax(propertyName, colonToken, expression, true); + }; + StrictModeFactory.prototype.functionPropertyAssignment = function (propertyName, callSignature, block) { + return new TypeScript.FunctionPropertyAssignmentSyntax(propertyName, callSignature, block, true); + }; + StrictModeFactory.prototype.getAccessorPropertyAssignment = function (getKeyword, propertyName, openParenToken, closeParenToken, typeAnnotation, block) { + return new TypeScript.GetAccessorPropertyAssignmentSyntax(getKeyword, propertyName, openParenToken, closeParenToken, typeAnnotation, block, true); + }; + StrictModeFactory.prototype.setAccessorPropertyAssignment = function (setKeyword, propertyName, openParenToken, parameter, closeParenToken, block) { + return new TypeScript.SetAccessorPropertyAssignmentSyntax(setKeyword, propertyName, openParenToken, parameter, closeParenToken, block, true); + }; + StrictModeFactory.prototype.functionExpression = function (functionKeyword, identifier, callSignature, block) { + return new TypeScript.FunctionExpressionSyntax(functionKeyword, identifier, callSignature, block, true); + }; + StrictModeFactory.prototype.emptyStatement = function (semicolonToken) { + return new TypeScript.EmptyStatementSyntax(semicolonToken, true); + }; + StrictModeFactory.prototype.tryStatement = function (tryKeyword, block, catchClause, finallyClause) { + return new TypeScript.TryStatementSyntax(tryKeyword, block, catchClause, finallyClause, true); + }; + StrictModeFactory.prototype.catchClause = function (catchKeyword, openParenToken, identifier, typeAnnotation, closeParenToken, block) { + return new TypeScript.CatchClauseSyntax(catchKeyword, openParenToken, identifier, typeAnnotation, closeParenToken, block, true); + }; + StrictModeFactory.prototype.finallyClause = function (finallyKeyword, block) { + return new TypeScript.FinallyClauseSyntax(finallyKeyword, block, true); + }; + StrictModeFactory.prototype.labeledStatement = function (identifier, colonToken, statement) { + return new TypeScript.LabeledStatementSyntax(identifier, colonToken, statement, true); + }; + StrictModeFactory.prototype.doStatement = function (doKeyword, statement, whileKeyword, openParenToken, condition, closeParenToken, semicolonToken) { + return new TypeScript.DoStatementSyntax(doKeyword, statement, whileKeyword, openParenToken, condition, closeParenToken, semicolonToken, true); + }; + StrictModeFactory.prototype.typeOfExpression = function (typeOfKeyword, expression) { + return new TypeScript.TypeOfExpressionSyntax(typeOfKeyword, expression, true); + }; + StrictModeFactory.prototype.deleteExpression = function (deleteKeyword, expression) { + return new TypeScript.DeleteExpressionSyntax(deleteKeyword, expression, true); + }; + StrictModeFactory.prototype.voidExpression = function (voidKeyword, expression) { + return new TypeScript.VoidExpressionSyntax(voidKeyword, expression, true); + }; + StrictModeFactory.prototype.debuggerStatement = function (debuggerKeyword, semicolonToken) { + return new TypeScript.DebuggerStatementSyntax(debuggerKeyword, semicolonToken, true); + }; + return StrictModeFactory; + })(); + Syntax.StrictModeFactory = StrictModeFactory; + + Syntax.normalModeFactory = new NormalModeFactory(); + Syntax.strictModeFactory = new StrictModeFactory(); + })(TypeScript.Syntax || (TypeScript.Syntax = {})); + var Syntax = TypeScript.Syntax; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (SyntaxFacts) { + function isDirectivePrologueElement(node) { + if (node.kind() === 148 /* ExpressionStatement */) { + var expressionStatement = node; + var expression = expressionStatement.expression; + + if (expression.kind() === 14 /* StringLiteral */) { + return true; + } + } + + return false; + } + SyntaxFacts.isDirectivePrologueElement = isDirectivePrologueElement; + + function isUseStrictDirective(node) { + var expressionStatement = node; + var stringLiteral = expressionStatement.expression; + + var text = stringLiteral.text(); + return text === '"use strict"' || text === "'use strict'"; + } + SyntaxFacts.isUseStrictDirective = isUseStrictDirective; + + function isIdentifierNameOrAnyKeyword(token) { + var tokenKind = token.tokenKind; + return tokenKind === 11 /* IdentifierName */ || TypeScript.SyntaxFacts.isAnyKeyword(tokenKind); + } + SyntaxFacts.isIdentifierNameOrAnyKeyword = isIdentifierNameOrAnyKeyword; + })(TypeScript.SyntaxFacts || (TypeScript.SyntaxFacts = {})); + var SyntaxFacts = TypeScript.SyntaxFacts; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (Syntax) { + var EmptySyntaxList = (function () { + function EmptySyntaxList() { + } + EmptySyntaxList.prototype.kind = function () { + return 1 /* List */; + }; + + EmptySyntaxList.prototype.isNode = function () { + return false; + }; + EmptySyntaxList.prototype.isToken = function () { + return false; + }; + EmptySyntaxList.prototype.isList = function () { + return true; + }; + EmptySyntaxList.prototype.isSeparatedList = function () { + return false; + }; + + EmptySyntaxList.prototype.toJSON = function (key) { + return []; + }; + + EmptySyntaxList.prototype.childCount = function () { + return 0; + }; + + EmptySyntaxList.prototype.childAt = function (index) { + throw TypeScript.Errors.argumentOutOfRange("index"); + }; + + EmptySyntaxList.prototype.toArray = function () { + return []; + }; + + EmptySyntaxList.prototype.collectTextElements = function (elements) { + }; + + EmptySyntaxList.prototype.firstToken = function () { + return null; + }; + + EmptySyntaxList.prototype.lastToken = function () { + return null; + }; + + EmptySyntaxList.prototype.fullWidth = function () { + return 0; + }; + + EmptySyntaxList.prototype.width = function () { + return 0; + }; + + EmptySyntaxList.prototype.leadingTrivia = function () { + return TypeScript.Syntax.emptyTriviaList; + }; + + EmptySyntaxList.prototype.trailingTrivia = function () { + return TypeScript.Syntax.emptyTriviaList; + }; + + EmptySyntaxList.prototype.leadingTriviaWidth = function () { + return 0; + }; + + EmptySyntaxList.prototype.trailingTriviaWidth = function () { + return 0; + }; + + EmptySyntaxList.prototype.fullText = function () { + return ""; + }; + + EmptySyntaxList.prototype.isTypeScriptSpecific = function () { + return false; + }; + + EmptySyntaxList.prototype.isIncrementallyUnusable = function () { + return false; + }; + + EmptySyntaxList.prototype.findTokenInternal = function (parent, position, fullStart) { + throw TypeScript.Errors.invalidOperation(); + }; + + EmptySyntaxList.prototype.insertChildrenInto = function (array, index) { + }; + return EmptySyntaxList; + })(); + Syntax.EmptySyntaxList = EmptySyntaxList; + + Syntax.emptyList = new EmptySyntaxList(); + + var SingletonSyntaxList = (function () { + function SingletonSyntaxList(item) { + this.item = item; + } + SingletonSyntaxList.prototype.kind = function () { + return 1 /* List */; + }; + + SingletonSyntaxList.prototype.isToken = function () { + return false; + }; + SingletonSyntaxList.prototype.isNode = function () { + return false; + }; + SingletonSyntaxList.prototype.isList = function () { + return true; + }; + SingletonSyntaxList.prototype.isSeparatedList = function () { + return false; + }; + + SingletonSyntaxList.prototype.toJSON = function (key) { + return [this.item]; + }; + + SingletonSyntaxList.prototype.childCount = function () { + return 1; + }; + + SingletonSyntaxList.prototype.childAt = function (index) { + if (index !== 0) { + throw TypeScript.Errors.argumentOutOfRange("index"); + } + + return this.item; + }; + + SingletonSyntaxList.prototype.toArray = function () { + return [this.item]; + }; + + SingletonSyntaxList.prototype.collectTextElements = function (elements) { + this.item.collectTextElements(elements); + }; + + SingletonSyntaxList.prototype.firstToken = function () { + return this.item.firstToken(); + }; + + SingletonSyntaxList.prototype.lastToken = function () { + return this.item.lastToken(); + }; + + SingletonSyntaxList.prototype.fullWidth = function () { + return this.item.fullWidth(); + }; + + SingletonSyntaxList.prototype.width = function () { + return this.item.width(); + }; + + SingletonSyntaxList.prototype.leadingTrivia = function () { + return this.item.leadingTrivia(); + }; + + SingletonSyntaxList.prototype.trailingTrivia = function () { + return this.item.trailingTrivia(); + }; + + SingletonSyntaxList.prototype.leadingTriviaWidth = function () { + return this.item.leadingTriviaWidth(); + }; + + SingletonSyntaxList.prototype.trailingTriviaWidth = function () { + return this.item.trailingTriviaWidth(); + }; + + SingletonSyntaxList.prototype.fullText = function () { + return this.item.fullText(); + }; + + SingletonSyntaxList.prototype.isTypeScriptSpecific = function () { + return this.item.isTypeScriptSpecific(); + }; + + SingletonSyntaxList.prototype.isIncrementallyUnusable = function () { + return this.item.isIncrementallyUnusable(); + }; + + SingletonSyntaxList.prototype.findTokenInternal = function (parent, position, fullStart) { + return (this.item).findTokenInternal(new TypeScript.PositionedList(parent, this, fullStart), position, fullStart); + }; + + SingletonSyntaxList.prototype.insertChildrenInto = function (array, index) { + array.splice(index, 0, this.item); + }; + return SingletonSyntaxList; + })(); + + var NormalSyntaxList = (function () { + function NormalSyntaxList(nodeOrTokens) { + this._data = 0; + this.nodeOrTokens = nodeOrTokens; + } + NormalSyntaxList.prototype.kind = function () { + return 1 /* List */; + }; + + NormalSyntaxList.prototype.isNode = function () { + return false; + }; + NormalSyntaxList.prototype.isToken = function () { + return false; + }; + NormalSyntaxList.prototype.isList = function () { + return true; + }; + NormalSyntaxList.prototype.isSeparatedList = function () { + return false; + }; + + NormalSyntaxList.prototype.toJSON = function (key) { + return this.nodeOrTokens; + }; + + NormalSyntaxList.prototype.childCount = function () { + return this.nodeOrTokens.length; + }; + + NormalSyntaxList.prototype.childAt = function (index) { + if (index < 0 || index >= this.nodeOrTokens.length) { + throw TypeScript.Errors.argumentOutOfRange("index"); + } + + return this.nodeOrTokens[index]; + }; + + NormalSyntaxList.prototype.toArray = function () { + return this.nodeOrTokens.slice(0); + }; + + NormalSyntaxList.prototype.collectTextElements = function (elements) { + for (var i = 0, n = this.nodeOrTokens.length; i < n; i++) { + var element = this.nodeOrTokens[i]; + element.collectTextElements(elements); + } + }; + + NormalSyntaxList.prototype.firstToken = function () { + for (var i = 0, n = this.nodeOrTokens.length; i < n; i++) { + var token = this.nodeOrTokens[i].firstToken(); + if (token !== null) { + return token; + } + } + + return null; + }; + + NormalSyntaxList.prototype.lastToken = function () { + for (var i = this.nodeOrTokens.length - 1; i >= 0; i--) { + var token = this.nodeOrTokens[i].lastToken(); + if (token !== null) { + return token; + } + } + + return null; + }; + + NormalSyntaxList.prototype.fullText = function () { + var elements = new Array(); + this.collectTextElements(elements); + return elements.join(""); + }; + + NormalSyntaxList.prototype.isTypeScriptSpecific = function () { + for (var i = 0, n = this.nodeOrTokens.length; i < n; i++) { + if (this.nodeOrTokens[i].isTypeScriptSpecific()) { + return true; + } + } + + return false; + }; + + NormalSyntaxList.prototype.isIncrementallyUnusable = function () { + return (this.data() & 2 /* NodeIncrementallyUnusableMask */) !== 0; + }; + + NormalSyntaxList.prototype.fullWidth = function () { + return this.data() >>> 3 /* NodeFullWidthShift */; + }; + + NormalSyntaxList.prototype.width = function () { + var fullWidth = this.fullWidth(); + return fullWidth - this.leadingTriviaWidth() - this.trailingTriviaWidth(); + }; + + NormalSyntaxList.prototype.leadingTrivia = function () { + return this.firstToken().leadingTrivia(); + }; + + NormalSyntaxList.prototype.trailingTrivia = function () { + return this.lastToken().trailingTrivia(); + }; + + NormalSyntaxList.prototype.leadingTriviaWidth = function () { + return this.firstToken().leadingTriviaWidth(); + }; + + NormalSyntaxList.prototype.trailingTriviaWidth = function () { + return this.lastToken().trailingTriviaWidth(); + }; + + NormalSyntaxList.prototype.computeData = function () { + var fullWidth = 0; + var isIncrementallyUnusable = false; + + for (var i = 0, n = this.nodeOrTokens.length; i < n; i++) { + var node = this.nodeOrTokens[i]; + fullWidth += node.fullWidth(); + isIncrementallyUnusable = isIncrementallyUnusable || node.isIncrementallyUnusable(); + } + + return (fullWidth << 3 /* NodeFullWidthShift */) | (isIncrementallyUnusable ? 2 /* NodeIncrementallyUnusableMask */ : 0) | 1 /* NodeDataComputed */; + }; + + NormalSyntaxList.prototype.data = function () { + if ((this._data & 1 /* NodeDataComputed */) === 0) { + this._data = this.computeData(); + } + + return this._data; + }; + + NormalSyntaxList.prototype.findTokenInternal = function (parent, position, fullStart) { + parent = new TypeScript.PositionedList(parent, this, fullStart); + for (var i = 0, n = this.nodeOrTokens.length; i < n; i++) { + var nodeOrToken = this.nodeOrTokens[i]; + + var childWidth = nodeOrToken.fullWidth(); + if (position < childWidth) { + return (nodeOrToken).findTokenInternal(parent, position, fullStart); + } + + position -= childWidth; + fullStart += childWidth; + } + + throw TypeScript.Errors.invalidOperation(); + }; + + NormalSyntaxList.prototype.insertChildrenInto = function (array, index) { + if (index === 0) { + array.unshift.apply(array, this.nodeOrTokens); + } else { + array.splice.apply(array, [index, 0].concat(this.nodeOrTokens)); + } + }; + return NormalSyntaxList; + })(); + + function list(nodes) { + if (nodes === undefined || nodes === null || nodes.length === 0) { + return Syntax.emptyList; + } + + if (nodes.length === 1) { + var item = nodes[0]; + return new SingletonSyntaxList(item); + } + + return new NormalSyntaxList(nodes); + } + Syntax.list = list; + })(TypeScript.Syntax || (TypeScript.Syntax = {})); + var Syntax = TypeScript.Syntax; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var SyntaxNode = (function () { + function SyntaxNode(parsedInStrictMode) { + this._data = parsedInStrictMode ? 4 /* NodeParsedInStrictModeMask */ : 0; + } + SyntaxNode.prototype.isNode = function () { + return true; + }; + SyntaxNode.prototype.isToken = function () { + return false; + }; + SyntaxNode.prototype.isList = function () { + return false; + }; + SyntaxNode.prototype.isSeparatedList = function () { + return false; + }; + + SyntaxNode.prototype.kind = function () { + throw TypeScript.Errors.abstract(); + }; + + SyntaxNode.prototype.childCount = function () { + throw TypeScript.Errors.abstract(); + }; + + SyntaxNode.prototype.childAt = function (slot) { + throw TypeScript.Errors.abstract(); + }; + + SyntaxNode.prototype.firstToken = function () { + for (var i = 0, n = this.childCount(); i < n; i++) { + var element = this.childAt(i); + + if (element !== null) { + if (element.fullWidth() > 0 || element.kind() === 10 /* EndOfFileToken */) { + return element.firstToken(); + } + } + } + + return null; + }; + + SyntaxNode.prototype.lastToken = function () { + for (var i = this.childCount() - 1; i >= 0; i--) { + var element = this.childAt(i); + + if (element !== null) { + if (element.fullWidth() > 0 || element.kind() === 10 /* EndOfFileToken */) { + return element.lastToken(); + } + } + } + + return null; + }; + + SyntaxNode.prototype.insertChildrenInto = function (array, index) { + for (var i = this.childCount() - 1; i >= 0; i--) { + var element = this.childAt(i); + + if (element !== null) { + if (element.isNode() || element.isToken()) { + array.splice(index, 0, element); + } else if (element.isList()) { + (element).insertChildrenInto(array, index); + } else if (element.isSeparatedList()) { + (element).insertChildrenInto(array, index); + } else { + throw TypeScript.Errors.invalidOperation(); + } + } + } + }; + + SyntaxNode.prototype.leadingTrivia = function () { + return this.firstToken().leadingTrivia(); + }; + + SyntaxNode.prototype.trailingTrivia = function () { + return this.lastToken().trailingTrivia(); + }; + + SyntaxNode.prototype.toJSON = function (key) { + var result = { + kind: TypeScript.SyntaxKind[this.kind()], + fullWidth: this.fullWidth() + }; + + if (this.isIncrementallyUnusable()) { + result.isIncrementallyUnusable = true; + } + + if (this.parsedInStrictMode()) { + result.parsedInStrictMode = true; + } + + for (var i = 0, n = this.childCount(); i < n; i++) { + var value = this.childAt(i); + + if (value) { + for (var name in this) { + if (value === this[name]) { + result[name] = value; + break; + } + } + } + } + + return result; + }; + + SyntaxNode.prototype.accept = function (visitor) { + throw TypeScript.Errors.abstract(); + }; + + SyntaxNode.prototype.fullText = function () { + var elements = []; + this.collectTextElements(elements); + return elements.join(""); + }; + + SyntaxNode.prototype.collectTextElements = function (elements) { + for (var i = 0, n = this.childCount(); i < n; i++) { + var element = this.childAt(i); + + if (element !== null) { + element.collectTextElements(elements); + } + } + }; + + SyntaxNode.prototype.replaceToken = function (token1, token2) { + if (token1 === token2) { + return this; + } + + return this.accept(new TypeScript.SyntaxTokenReplacer(token1, token2)); + }; + + SyntaxNode.prototype.withLeadingTrivia = function (trivia) { + return this.replaceToken(this.firstToken(), this.firstToken().withLeadingTrivia(trivia)); + }; + + SyntaxNode.prototype.withTrailingTrivia = function (trivia) { + return this.replaceToken(this.lastToken(), this.lastToken().withTrailingTrivia(trivia)); + }; + + SyntaxNode.prototype.hasLeadingTrivia = function () { + return this.lastToken().hasLeadingTrivia(); + }; + + SyntaxNode.prototype.hasTrailingTrivia = function () { + return this.lastToken().hasTrailingTrivia(); + }; + + SyntaxNode.prototype.isTypeScriptSpecific = function () { + return false; + }; + + SyntaxNode.prototype.isIncrementallyUnusable = function () { + return (this.data() & 2 /* NodeIncrementallyUnusableMask */) !== 0; + }; + + SyntaxNode.prototype.parsedInStrictMode = function () { + return (this.data() & 4 /* NodeParsedInStrictModeMask */) !== 0; + }; + + SyntaxNode.prototype.fullWidth = function () { + return this.data() >>> 3 /* NodeFullWidthShift */; + }; + + SyntaxNode.prototype.computeData = function () { + var slotCount = this.childCount(); + + var fullWidth = 0; + var childWidth = 0; + + var isIncrementallyUnusable = ((this._data & 2 /* NodeIncrementallyUnusableMask */) !== 0) || slotCount === 0; + + for (var i = 0, n = slotCount; i < n; i++) { + var element = this.childAt(i); + + if (element !== null) { + childWidth = element.fullWidth(); + fullWidth += childWidth; + + if (!isIncrementallyUnusable) { + isIncrementallyUnusable = element.isIncrementallyUnusable(); + } + } + } + + return (fullWidth << 3 /* NodeFullWidthShift */) | (isIncrementallyUnusable ? 2 /* NodeIncrementallyUnusableMask */ : 0) | 1 /* NodeDataComputed */; + }; + + SyntaxNode.prototype.data = function () { + if ((this._data & 1 /* NodeDataComputed */) === 0) { + this._data |= this.computeData(); + } + + return this._data; + }; + + SyntaxNode.prototype.findToken = function (position, includeSkippedTokens) { + if (typeof includeSkippedTokens === "undefined") { includeSkippedTokens = false; } + var endOfFileToken = this.tryGetEndOfFileAt(position); + if (endOfFileToken !== null) { + return endOfFileToken; + } + + if (position < 0 || position >= this.fullWidth()) { + throw TypeScript.Errors.argumentOutOfRange("position"); + } + + var positionedToken = this.findTokenInternal(null, position, 0); + + if (includeSkippedTokens) { + return TypeScript.Syntax.findSkippedTokenInPositionedToken(positionedToken, position) || positionedToken; + } + + return positionedToken; + }; + + SyntaxNode.prototype.tryGetEndOfFileAt = function (position) { + if (this.kind() === 120 /* SourceUnit */ && position === this.fullWidth()) { + var sourceUnit = this; + return new TypeScript.PositionedToken(new TypeScript.PositionedNode(null, sourceUnit, 0), sourceUnit.endOfFileToken, sourceUnit.moduleElements.fullWidth()); + } + + return null; + }; + + SyntaxNode.prototype.findTokenInternal = function (parent, position, fullStart) { + parent = new TypeScript.PositionedNode(parent, this, fullStart); + for (var i = 0, n = this.childCount(); i < n; i++) { + var element = this.childAt(i); + + if (element !== null) { + var childWidth = element.fullWidth(); + + if (position < childWidth) { + return (element).findTokenInternal(parent, position, fullStart); + } + + position -= childWidth; + fullStart += childWidth; + } + } + + throw TypeScript.Errors.invalidOperation(); + }; + + SyntaxNode.prototype.findTokenOnLeft = function (position, includeSkippedTokens) { + if (typeof includeSkippedTokens === "undefined") { includeSkippedTokens = false; } + var positionedToken = this.findToken(position, false); + var start = positionedToken.start(); + + if (includeSkippedTokens) { + positionedToken = TypeScript.Syntax.findSkippedTokenOnLeft(positionedToken, position) || positionedToken; + } + + if (position > start) { + return positionedToken; + } + + if (positionedToken.fullStart() === 0) { + return null; + } + + return positionedToken.previousToken(includeSkippedTokens); + }; + + SyntaxNode.prototype.findCompleteTokenOnLeft = function (position, includeSkippedTokens) { + if (typeof includeSkippedTokens === "undefined") { includeSkippedTokens = false; } + var positionedToken = this.findToken(position, false); + + if (includeSkippedTokens) { + positionedToken = TypeScript.Syntax.findSkippedTokenOnLeft(positionedToken, position) || positionedToken; + } + + if (positionedToken.token().width() > 0 && position >= positionedToken.end()) { + return positionedToken; + } + + return positionedToken.previousToken(includeSkippedTokens); + }; + + SyntaxNode.prototype.isModuleElement = function () { + return false; + }; + + SyntaxNode.prototype.isClassElement = function () { + return false; + }; + + SyntaxNode.prototype.isTypeMember = function () { + return false; + }; + + SyntaxNode.prototype.isStatement = function () { + return false; + }; + + SyntaxNode.prototype.isSwitchClause = function () { + return false; + }; + + SyntaxNode.prototype.structuralEquals = function (node) { + if (this === node) { + return true; + } + if (node === null) { + return false; + } + if (this.kind() !== node.kind()) { + return false; + } + + for (var i = 0, n = this.childCount(); i < n; i++) { + var element1 = this.childAt(i); + var element2 = node.childAt(i); + + if (!TypeScript.Syntax.elementStructuralEquals(element1, element2)) { + return false; + } + } + + return true; + }; + + SyntaxNode.prototype.width = function () { + return this.fullWidth() - this.leadingTriviaWidth() - this.trailingTriviaWidth(); + }; + + SyntaxNode.prototype.leadingTriviaWidth = function () { + var firstToken = this.firstToken(); + return firstToken === null ? 0 : firstToken.leadingTriviaWidth(); + }; + + SyntaxNode.prototype.trailingTriviaWidth = function () { + var lastToken = this.lastToken(); + return lastToken === null ? 0 : lastToken.trailingTriviaWidth(); + }; + return SyntaxNode; + })(); + TypeScript.SyntaxNode = SyntaxNode; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var SourceUnitSyntax = (function (_super) { + __extends(SourceUnitSyntax, _super); + function SourceUnitSyntax(moduleElements, endOfFileToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.moduleElements = moduleElements; + this.endOfFileToken = endOfFileToken; + } + SourceUnitSyntax.prototype.accept = function (visitor) { + return visitor.visitSourceUnit(this); + }; + + SourceUnitSyntax.prototype.kind = function () { + return 120 /* SourceUnit */; + }; + + SourceUnitSyntax.prototype.childCount = function () { + return 2; + }; + + SourceUnitSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.moduleElements; + case 1: + return this.endOfFileToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + SourceUnitSyntax.prototype.update = function (moduleElements, endOfFileToken) { + if (this.moduleElements === moduleElements && this.endOfFileToken === endOfFileToken) { + return this; + } + + return new SourceUnitSyntax(moduleElements, endOfFileToken, this.parsedInStrictMode()); + }; + + SourceUnitSyntax.create = function (endOfFileToken) { + return new SourceUnitSyntax(TypeScript.Syntax.emptyList, endOfFileToken, false); + }; + + SourceUnitSyntax.create1 = function (endOfFileToken) { + return new SourceUnitSyntax(TypeScript.Syntax.emptyList, endOfFileToken, false); + }; + + SourceUnitSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + SourceUnitSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + SourceUnitSyntax.prototype.withModuleElements = function (moduleElements) { + return this.update(moduleElements, this.endOfFileToken); + }; + + SourceUnitSyntax.prototype.withModuleElement = function (moduleElement) { + return this.withModuleElements(TypeScript.Syntax.list([moduleElement])); + }; + + SourceUnitSyntax.prototype.withEndOfFileToken = function (endOfFileToken) { + return this.update(this.moduleElements, endOfFileToken); + }; + + SourceUnitSyntax.prototype.isTypeScriptSpecific = function () { + if (this.moduleElements.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return SourceUnitSyntax; + })(TypeScript.SyntaxNode); + TypeScript.SourceUnitSyntax = SourceUnitSyntax; + + var ModuleReferenceSyntax = (function (_super) { + __extends(ModuleReferenceSyntax, _super); + function ModuleReferenceSyntax(parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + } + ModuleReferenceSyntax.prototype.isModuleReference = function () { + return true; + }; + + ModuleReferenceSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ModuleReferenceSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ModuleReferenceSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return ModuleReferenceSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ModuleReferenceSyntax = ModuleReferenceSyntax; + + var ExternalModuleReferenceSyntax = (function (_super) { + __extends(ExternalModuleReferenceSyntax, _super); + function ExternalModuleReferenceSyntax(requireKeyword, openParenToken, stringLiteral, closeParenToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.requireKeyword = requireKeyword; + this.openParenToken = openParenToken; + this.stringLiteral = stringLiteral; + this.closeParenToken = closeParenToken; + } + ExternalModuleReferenceSyntax.prototype.accept = function (visitor) { + return visitor.visitExternalModuleReference(this); + }; + + ExternalModuleReferenceSyntax.prototype.kind = function () { + return 245 /* ExternalModuleReference */; + }; + + ExternalModuleReferenceSyntax.prototype.childCount = function () { + return 4; + }; + + ExternalModuleReferenceSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.requireKeyword; + case 1: + return this.openParenToken; + case 2: + return this.stringLiteral; + case 3: + return this.closeParenToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ExternalModuleReferenceSyntax.prototype.update = function (requireKeyword, openParenToken, stringLiteral, closeParenToken) { + if (this.requireKeyword === requireKeyword && this.openParenToken === openParenToken && this.stringLiteral === stringLiteral && this.closeParenToken === closeParenToken) { + return this; + } + + return new ExternalModuleReferenceSyntax(requireKeyword, openParenToken, stringLiteral, closeParenToken, this.parsedInStrictMode()); + }; + + ExternalModuleReferenceSyntax.create1 = function (stringLiteral) { + return new ExternalModuleReferenceSyntax(TypeScript.Syntax.token(66 /* RequireKeyword */), TypeScript.Syntax.token(72 /* OpenParenToken */), stringLiteral, TypeScript.Syntax.token(73 /* CloseParenToken */), false); + }; + + ExternalModuleReferenceSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ExternalModuleReferenceSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ExternalModuleReferenceSyntax.prototype.withRequireKeyword = function (requireKeyword) { + return this.update(requireKeyword, this.openParenToken, this.stringLiteral, this.closeParenToken); + }; + + ExternalModuleReferenceSyntax.prototype.withOpenParenToken = function (openParenToken) { + return this.update(this.requireKeyword, openParenToken, this.stringLiteral, this.closeParenToken); + }; + + ExternalModuleReferenceSyntax.prototype.withStringLiteral = function (stringLiteral) { + return this.update(this.requireKeyword, this.openParenToken, stringLiteral, this.closeParenToken); + }; + + ExternalModuleReferenceSyntax.prototype.withCloseParenToken = function (closeParenToken) { + return this.update(this.requireKeyword, this.openParenToken, this.stringLiteral, closeParenToken); + }; + + ExternalModuleReferenceSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return ExternalModuleReferenceSyntax; + })(ModuleReferenceSyntax); + TypeScript.ExternalModuleReferenceSyntax = ExternalModuleReferenceSyntax; + + var ModuleNameModuleReferenceSyntax = (function (_super) { + __extends(ModuleNameModuleReferenceSyntax, _super); + function ModuleNameModuleReferenceSyntax(moduleName, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.moduleName = moduleName; + } + ModuleNameModuleReferenceSyntax.prototype.accept = function (visitor) { + return visitor.visitModuleNameModuleReference(this); + }; + + ModuleNameModuleReferenceSyntax.prototype.kind = function () { + return 246 /* ModuleNameModuleReference */; + }; + + ModuleNameModuleReferenceSyntax.prototype.childCount = function () { + return 1; + }; + + ModuleNameModuleReferenceSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.moduleName; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ModuleNameModuleReferenceSyntax.prototype.update = function (moduleName) { + if (this.moduleName === moduleName) { + return this; + } + + return new ModuleNameModuleReferenceSyntax(moduleName, this.parsedInStrictMode()); + }; + + ModuleNameModuleReferenceSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ModuleNameModuleReferenceSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ModuleNameModuleReferenceSyntax.prototype.withModuleName = function (moduleName) { + return this.update(moduleName); + }; + + ModuleNameModuleReferenceSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return ModuleNameModuleReferenceSyntax; + })(ModuleReferenceSyntax); + TypeScript.ModuleNameModuleReferenceSyntax = ModuleNameModuleReferenceSyntax; + + var ImportDeclarationSyntax = (function (_super) { + __extends(ImportDeclarationSyntax, _super); + function ImportDeclarationSyntax(modifiers, importKeyword, identifier, equalsToken, moduleReference, semicolonToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.modifiers = modifiers; + this.importKeyword = importKeyword; + this.identifier = identifier; + this.equalsToken = equalsToken; + this.moduleReference = moduleReference; + this.semicolonToken = semicolonToken; + } + ImportDeclarationSyntax.prototype.accept = function (visitor) { + return visitor.visitImportDeclaration(this); + }; + + ImportDeclarationSyntax.prototype.kind = function () { + return 133 /* ImportDeclaration */; + }; + + ImportDeclarationSyntax.prototype.childCount = function () { + return 6; + }; + + ImportDeclarationSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.modifiers; + case 1: + return this.importKeyword; + case 2: + return this.identifier; + case 3: + return this.equalsToken; + case 4: + return this.moduleReference; + case 5: + return this.semicolonToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ImportDeclarationSyntax.prototype.isModuleElement = function () { + return true; + }; + + ImportDeclarationSyntax.prototype.update = function (modifiers, importKeyword, identifier, equalsToken, moduleReference, semicolonToken) { + if (this.modifiers === modifiers && this.importKeyword === importKeyword && this.identifier === identifier && this.equalsToken === equalsToken && this.moduleReference === moduleReference && this.semicolonToken === semicolonToken) { + return this; + } + + return new ImportDeclarationSyntax(modifiers, importKeyword, identifier, equalsToken, moduleReference, semicolonToken, this.parsedInStrictMode()); + }; + + ImportDeclarationSyntax.create = function (importKeyword, identifier, equalsToken, moduleReference, semicolonToken) { + return new ImportDeclarationSyntax(TypeScript.Syntax.emptyList, importKeyword, identifier, equalsToken, moduleReference, semicolonToken, false); + }; + + ImportDeclarationSyntax.create1 = function (identifier, moduleReference) { + return new ImportDeclarationSyntax(TypeScript.Syntax.emptyList, TypeScript.Syntax.token(49 /* ImportKeyword */), identifier, TypeScript.Syntax.token(107 /* EqualsToken */), moduleReference, TypeScript.Syntax.token(78 /* SemicolonToken */), false); + }; + + ImportDeclarationSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ImportDeclarationSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ImportDeclarationSyntax.prototype.withModifiers = function (modifiers) { + return this.update(modifiers, this.importKeyword, this.identifier, this.equalsToken, this.moduleReference, this.semicolonToken); + }; + + ImportDeclarationSyntax.prototype.withModifier = function (modifier) { + return this.withModifiers(TypeScript.Syntax.list([modifier])); + }; + + ImportDeclarationSyntax.prototype.withImportKeyword = function (importKeyword) { + return this.update(this.modifiers, importKeyword, this.identifier, this.equalsToken, this.moduleReference, this.semicolonToken); + }; + + ImportDeclarationSyntax.prototype.withIdentifier = function (identifier) { + return this.update(this.modifiers, this.importKeyword, identifier, this.equalsToken, this.moduleReference, this.semicolonToken); + }; + + ImportDeclarationSyntax.prototype.withEqualsToken = function (equalsToken) { + return this.update(this.modifiers, this.importKeyword, this.identifier, equalsToken, this.moduleReference, this.semicolonToken); + }; + + ImportDeclarationSyntax.prototype.withModuleReference = function (moduleReference) { + return this.update(this.modifiers, this.importKeyword, this.identifier, this.equalsToken, moduleReference, this.semicolonToken); + }; + + ImportDeclarationSyntax.prototype.withSemicolonToken = function (semicolonToken) { + return this.update(this.modifiers, this.importKeyword, this.identifier, this.equalsToken, this.moduleReference, semicolonToken); + }; + + ImportDeclarationSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return ImportDeclarationSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ImportDeclarationSyntax = ImportDeclarationSyntax; + + var ExportAssignmentSyntax = (function (_super) { + __extends(ExportAssignmentSyntax, _super); + function ExportAssignmentSyntax(exportKeyword, equalsToken, identifier, semicolonToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.exportKeyword = exportKeyword; + this.equalsToken = equalsToken; + this.identifier = identifier; + this.semicolonToken = semicolonToken; + } + ExportAssignmentSyntax.prototype.accept = function (visitor) { + return visitor.visitExportAssignment(this); + }; + + ExportAssignmentSyntax.prototype.kind = function () { + return 134 /* ExportAssignment */; + }; + + ExportAssignmentSyntax.prototype.childCount = function () { + return 4; + }; + + ExportAssignmentSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.exportKeyword; + case 1: + return this.equalsToken; + case 2: + return this.identifier; + case 3: + return this.semicolonToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ExportAssignmentSyntax.prototype.isModuleElement = function () { + return true; + }; + + ExportAssignmentSyntax.prototype.update = function (exportKeyword, equalsToken, identifier, semicolonToken) { + if (this.exportKeyword === exportKeyword && this.equalsToken === equalsToken && this.identifier === identifier && this.semicolonToken === semicolonToken) { + return this; + } + + return new ExportAssignmentSyntax(exportKeyword, equalsToken, identifier, semicolonToken, this.parsedInStrictMode()); + }; + + ExportAssignmentSyntax.create1 = function (identifier) { + return new ExportAssignmentSyntax(TypeScript.Syntax.token(47 /* ExportKeyword */), TypeScript.Syntax.token(107 /* EqualsToken */), identifier, TypeScript.Syntax.token(78 /* SemicolonToken */), false); + }; + + ExportAssignmentSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ExportAssignmentSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ExportAssignmentSyntax.prototype.withExportKeyword = function (exportKeyword) { + return this.update(exportKeyword, this.equalsToken, this.identifier, this.semicolonToken); + }; + + ExportAssignmentSyntax.prototype.withEqualsToken = function (equalsToken) { + return this.update(this.exportKeyword, equalsToken, this.identifier, this.semicolonToken); + }; + + ExportAssignmentSyntax.prototype.withIdentifier = function (identifier) { + return this.update(this.exportKeyword, this.equalsToken, identifier, this.semicolonToken); + }; + + ExportAssignmentSyntax.prototype.withSemicolonToken = function (semicolonToken) { + return this.update(this.exportKeyword, this.equalsToken, this.identifier, semicolonToken); + }; + + ExportAssignmentSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return ExportAssignmentSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ExportAssignmentSyntax = ExportAssignmentSyntax; + + var ClassDeclarationSyntax = (function (_super) { + __extends(ClassDeclarationSyntax, _super); + function ClassDeclarationSyntax(modifiers, classKeyword, identifier, typeParameterList, heritageClauses, openBraceToken, classElements, closeBraceToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.modifiers = modifiers; + this.classKeyword = classKeyword; + this.identifier = identifier; + this.typeParameterList = typeParameterList; + this.heritageClauses = heritageClauses; + this.openBraceToken = openBraceToken; + this.classElements = classElements; + this.closeBraceToken = closeBraceToken; + } + ClassDeclarationSyntax.prototype.accept = function (visitor) { + return visitor.visitClassDeclaration(this); + }; + + ClassDeclarationSyntax.prototype.kind = function () { + return 131 /* ClassDeclaration */; + }; + + ClassDeclarationSyntax.prototype.childCount = function () { + return 8; + }; + + ClassDeclarationSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.modifiers; + case 1: + return this.classKeyword; + case 2: + return this.identifier; + case 3: + return this.typeParameterList; + case 4: + return this.heritageClauses; + case 5: + return this.openBraceToken; + case 6: + return this.classElements; + case 7: + return this.closeBraceToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ClassDeclarationSyntax.prototype.isModuleElement = function () { + return true; + }; + + ClassDeclarationSyntax.prototype.update = function (modifiers, classKeyword, identifier, typeParameterList, heritageClauses, openBraceToken, classElements, closeBraceToken) { + if (this.modifiers === modifiers && this.classKeyword === classKeyword && this.identifier === identifier && this.typeParameterList === typeParameterList && this.heritageClauses === heritageClauses && this.openBraceToken === openBraceToken && this.classElements === classElements && this.closeBraceToken === closeBraceToken) { + return this; + } + + return new ClassDeclarationSyntax(modifiers, classKeyword, identifier, typeParameterList, heritageClauses, openBraceToken, classElements, closeBraceToken, this.parsedInStrictMode()); + }; + + ClassDeclarationSyntax.create = function (classKeyword, identifier, openBraceToken, closeBraceToken) { + return new ClassDeclarationSyntax(TypeScript.Syntax.emptyList, classKeyword, identifier, null, TypeScript.Syntax.emptyList, openBraceToken, TypeScript.Syntax.emptyList, closeBraceToken, false); + }; + + ClassDeclarationSyntax.create1 = function (identifier) { + return new ClassDeclarationSyntax(TypeScript.Syntax.emptyList, TypeScript.Syntax.token(44 /* ClassKeyword */), identifier, null, TypeScript.Syntax.emptyList, TypeScript.Syntax.token(70 /* OpenBraceToken */), TypeScript.Syntax.emptyList, TypeScript.Syntax.token(71 /* CloseBraceToken */), false); + }; + + ClassDeclarationSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ClassDeclarationSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ClassDeclarationSyntax.prototype.withModifiers = function (modifiers) { + return this.update(modifiers, this.classKeyword, this.identifier, this.typeParameterList, this.heritageClauses, this.openBraceToken, this.classElements, this.closeBraceToken); + }; + + ClassDeclarationSyntax.prototype.withModifier = function (modifier) { + return this.withModifiers(TypeScript.Syntax.list([modifier])); + }; + + ClassDeclarationSyntax.prototype.withClassKeyword = function (classKeyword) { + return this.update(this.modifiers, classKeyword, this.identifier, this.typeParameterList, this.heritageClauses, this.openBraceToken, this.classElements, this.closeBraceToken); + }; + + ClassDeclarationSyntax.prototype.withIdentifier = function (identifier) { + return this.update(this.modifiers, this.classKeyword, identifier, this.typeParameterList, this.heritageClauses, this.openBraceToken, this.classElements, this.closeBraceToken); + }; + + ClassDeclarationSyntax.prototype.withTypeParameterList = function (typeParameterList) { + return this.update(this.modifiers, this.classKeyword, this.identifier, typeParameterList, this.heritageClauses, this.openBraceToken, this.classElements, this.closeBraceToken); + }; + + ClassDeclarationSyntax.prototype.withHeritageClauses = function (heritageClauses) { + return this.update(this.modifiers, this.classKeyword, this.identifier, this.typeParameterList, heritageClauses, this.openBraceToken, this.classElements, this.closeBraceToken); + }; + + ClassDeclarationSyntax.prototype.withHeritageClause = function (heritageClause) { + return this.withHeritageClauses(TypeScript.Syntax.list([heritageClause])); + }; + + ClassDeclarationSyntax.prototype.withOpenBraceToken = function (openBraceToken) { + return this.update(this.modifiers, this.classKeyword, this.identifier, this.typeParameterList, this.heritageClauses, openBraceToken, this.classElements, this.closeBraceToken); + }; + + ClassDeclarationSyntax.prototype.withClassElements = function (classElements) { + return this.update(this.modifiers, this.classKeyword, this.identifier, this.typeParameterList, this.heritageClauses, this.openBraceToken, classElements, this.closeBraceToken); + }; + + ClassDeclarationSyntax.prototype.withClassElement = function (classElement) { + return this.withClassElements(TypeScript.Syntax.list([classElement])); + }; + + ClassDeclarationSyntax.prototype.withCloseBraceToken = function (closeBraceToken) { + return this.update(this.modifiers, this.classKeyword, this.identifier, this.typeParameterList, this.heritageClauses, this.openBraceToken, this.classElements, closeBraceToken); + }; + + ClassDeclarationSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return ClassDeclarationSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ClassDeclarationSyntax = ClassDeclarationSyntax; + + var InterfaceDeclarationSyntax = (function (_super) { + __extends(InterfaceDeclarationSyntax, _super); + function InterfaceDeclarationSyntax(modifiers, interfaceKeyword, identifier, typeParameterList, heritageClauses, body, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.modifiers = modifiers; + this.interfaceKeyword = interfaceKeyword; + this.identifier = identifier; + this.typeParameterList = typeParameterList; + this.heritageClauses = heritageClauses; + this.body = body; + } + InterfaceDeclarationSyntax.prototype.accept = function (visitor) { + return visitor.visitInterfaceDeclaration(this); + }; + + InterfaceDeclarationSyntax.prototype.kind = function () { + return 128 /* InterfaceDeclaration */; + }; + + InterfaceDeclarationSyntax.prototype.childCount = function () { + return 6; + }; + + InterfaceDeclarationSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.modifiers; + case 1: + return this.interfaceKeyword; + case 2: + return this.identifier; + case 3: + return this.typeParameterList; + case 4: + return this.heritageClauses; + case 5: + return this.body; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + InterfaceDeclarationSyntax.prototype.isModuleElement = function () { + return true; + }; + + InterfaceDeclarationSyntax.prototype.update = function (modifiers, interfaceKeyword, identifier, typeParameterList, heritageClauses, body) { + if (this.modifiers === modifiers && this.interfaceKeyword === interfaceKeyword && this.identifier === identifier && this.typeParameterList === typeParameterList && this.heritageClauses === heritageClauses && this.body === body) { + return this; + } + + return new InterfaceDeclarationSyntax(modifiers, interfaceKeyword, identifier, typeParameterList, heritageClauses, body, this.parsedInStrictMode()); + }; + + InterfaceDeclarationSyntax.create = function (interfaceKeyword, identifier, body) { + return new InterfaceDeclarationSyntax(TypeScript.Syntax.emptyList, interfaceKeyword, identifier, null, TypeScript.Syntax.emptyList, body, false); + }; + + InterfaceDeclarationSyntax.create1 = function (identifier) { + return new InterfaceDeclarationSyntax(TypeScript.Syntax.emptyList, TypeScript.Syntax.token(52 /* InterfaceKeyword */), identifier, null, TypeScript.Syntax.emptyList, ObjectTypeSyntax.create1(), false); + }; + + InterfaceDeclarationSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + InterfaceDeclarationSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + InterfaceDeclarationSyntax.prototype.withModifiers = function (modifiers) { + return this.update(modifiers, this.interfaceKeyword, this.identifier, this.typeParameterList, this.heritageClauses, this.body); + }; + + InterfaceDeclarationSyntax.prototype.withModifier = function (modifier) { + return this.withModifiers(TypeScript.Syntax.list([modifier])); + }; + + InterfaceDeclarationSyntax.prototype.withInterfaceKeyword = function (interfaceKeyword) { + return this.update(this.modifiers, interfaceKeyword, this.identifier, this.typeParameterList, this.heritageClauses, this.body); + }; + + InterfaceDeclarationSyntax.prototype.withIdentifier = function (identifier) { + return this.update(this.modifiers, this.interfaceKeyword, identifier, this.typeParameterList, this.heritageClauses, this.body); + }; + + InterfaceDeclarationSyntax.prototype.withTypeParameterList = function (typeParameterList) { + return this.update(this.modifiers, this.interfaceKeyword, this.identifier, typeParameterList, this.heritageClauses, this.body); + }; + + InterfaceDeclarationSyntax.prototype.withHeritageClauses = function (heritageClauses) { + return this.update(this.modifiers, this.interfaceKeyword, this.identifier, this.typeParameterList, heritageClauses, this.body); + }; + + InterfaceDeclarationSyntax.prototype.withHeritageClause = function (heritageClause) { + return this.withHeritageClauses(TypeScript.Syntax.list([heritageClause])); + }; + + InterfaceDeclarationSyntax.prototype.withBody = function (body) { + return this.update(this.modifiers, this.interfaceKeyword, this.identifier, this.typeParameterList, this.heritageClauses, body); + }; + + InterfaceDeclarationSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return InterfaceDeclarationSyntax; + })(TypeScript.SyntaxNode); + TypeScript.InterfaceDeclarationSyntax = InterfaceDeclarationSyntax; + + var HeritageClauseSyntax = (function (_super) { + __extends(HeritageClauseSyntax, _super); + function HeritageClauseSyntax(extendsOrImplementsKeyword, typeNames, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.extendsOrImplementsKeyword = extendsOrImplementsKeyword; + this.typeNames = typeNames; + } + HeritageClauseSyntax.prototype.accept = function (visitor) { + return visitor.visitHeritageClause(this); + }; + + HeritageClauseSyntax.prototype.kind = function () { + return 229 /* HeritageClause */; + }; + + HeritageClauseSyntax.prototype.childCount = function () { + return 2; + }; + + HeritageClauseSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.extendsOrImplementsKeyword; + case 1: + return this.typeNames; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + HeritageClauseSyntax.prototype.update = function (extendsOrImplementsKeyword, typeNames) { + if (this.extendsOrImplementsKeyword === extendsOrImplementsKeyword && this.typeNames === typeNames) { + return this; + } + + return new HeritageClauseSyntax(extendsOrImplementsKeyword, typeNames, this.parsedInStrictMode()); + }; + + HeritageClauseSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + HeritageClauseSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + HeritageClauseSyntax.prototype.withExtendsOrImplementsKeyword = function (extendsOrImplementsKeyword) { + return this.update(extendsOrImplementsKeyword, this.typeNames); + }; + + HeritageClauseSyntax.prototype.withTypeNames = function (typeNames) { + return this.update(this.extendsOrImplementsKeyword, typeNames); + }; + + HeritageClauseSyntax.prototype.withTypeName = function (typeName) { + return this.withTypeNames(TypeScript.Syntax.separatedList([typeName])); + }; + + HeritageClauseSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return HeritageClauseSyntax; + })(TypeScript.SyntaxNode); + TypeScript.HeritageClauseSyntax = HeritageClauseSyntax; + + var ModuleDeclarationSyntax = (function (_super) { + __extends(ModuleDeclarationSyntax, _super); + function ModuleDeclarationSyntax(modifiers, moduleKeyword, moduleName, stringLiteral, openBraceToken, moduleElements, closeBraceToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.modifiers = modifiers; + this.moduleKeyword = moduleKeyword; + this.moduleName = moduleName; + this.stringLiteral = stringLiteral; + this.openBraceToken = openBraceToken; + this.moduleElements = moduleElements; + this.closeBraceToken = closeBraceToken; + } + ModuleDeclarationSyntax.prototype.accept = function (visitor) { + return visitor.visitModuleDeclaration(this); + }; + + ModuleDeclarationSyntax.prototype.kind = function () { + return 130 /* ModuleDeclaration */; + }; + + ModuleDeclarationSyntax.prototype.childCount = function () { + return 7; + }; + + ModuleDeclarationSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.modifiers; + case 1: + return this.moduleKeyword; + case 2: + return this.moduleName; + case 3: + return this.stringLiteral; + case 4: + return this.openBraceToken; + case 5: + return this.moduleElements; + case 6: + return this.closeBraceToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ModuleDeclarationSyntax.prototype.isModuleElement = function () { + return true; + }; + + ModuleDeclarationSyntax.prototype.update = function (modifiers, moduleKeyword, moduleName, stringLiteral, openBraceToken, moduleElements, closeBraceToken) { + if (this.modifiers === modifiers && this.moduleKeyword === moduleKeyword && this.moduleName === moduleName && this.stringLiteral === stringLiteral && this.openBraceToken === openBraceToken && this.moduleElements === moduleElements && this.closeBraceToken === closeBraceToken) { + return this; + } + + return new ModuleDeclarationSyntax(modifiers, moduleKeyword, moduleName, stringLiteral, openBraceToken, moduleElements, closeBraceToken, this.parsedInStrictMode()); + }; + + ModuleDeclarationSyntax.create = function (moduleKeyword, openBraceToken, closeBraceToken) { + return new ModuleDeclarationSyntax(TypeScript.Syntax.emptyList, moduleKeyword, null, null, openBraceToken, TypeScript.Syntax.emptyList, closeBraceToken, false); + }; + + ModuleDeclarationSyntax.create1 = function () { + return new ModuleDeclarationSyntax(TypeScript.Syntax.emptyList, TypeScript.Syntax.token(65 /* ModuleKeyword */), null, null, TypeScript.Syntax.token(70 /* OpenBraceToken */), TypeScript.Syntax.emptyList, TypeScript.Syntax.token(71 /* CloseBraceToken */), false); + }; + + ModuleDeclarationSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ModuleDeclarationSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ModuleDeclarationSyntax.prototype.withModifiers = function (modifiers) { + return this.update(modifiers, this.moduleKeyword, this.moduleName, this.stringLiteral, this.openBraceToken, this.moduleElements, this.closeBraceToken); + }; + + ModuleDeclarationSyntax.prototype.withModifier = function (modifier) { + return this.withModifiers(TypeScript.Syntax.list([modifier])); + }; + + ModuleDeclarationSyntax.prototype.withModuleKeyword = function (moduleKeyword) { + return this.update(this.modifiers, moduleKeyword, this.moduleName, this.stringLiteral, this.openBraceToken, this.moduleElements, this.closeBraceToken); + }; + + ModuleDeclarationSyntax.prototype.withModuleName = function (moduleName) { + return this.update(this.modifiers, this.moduleKeyword, moduleName, this.stringLiteral, this.openBraceToken, this.moduleElements, this.closeBraceToken); + }; + + ModuleDeclarationSyntax.prototype.withStringLiteral = function (stringLiteral) { + return this.update(this.modifiers, this.moduleKeyword, this.moduleName, stringLiteral, this.openBraceToken, this.moduleElements, this.closeBraceToken); + }; + + ModuleDeclarationSyntax.prototype.withOpenBraceToken = function (openBraceToken) { + return this.update(this.modifiers, this.moduleKeyword, this.moduleName, this.stringLiteral, openBraceToken, this.moduleElements, this.closeBraceToken); + }; + + ModuleDeclarationSyntax.prototype.withModuleElements = function (moduleElements) { + return this.update(this.modifiers, this.moduleKeyword, this.moduleName, this.stringLiteral, this.openBraceToken, moduleElements, this.closeBraceToken); + }; + + ModuleDeclarationSyntax.prototype.withModuleElement = function (moduleElement) { + return this.withModuleElements(TypeScript.Syntax.list([moduleElement])); + }; + + ModuleDeclarationSyntax.prototype.withCloseBraceToken = function (closeBraceToken) { + return this.update(this.modifiers, this.moduleKeyword, this.moduleName, this.stringLiteral, this.openBraceToken, this.moduleElements, closeBraceToken); + }; + + ModuleDeclarationSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return ModuleDeclarationSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ModuleDeclarationSyntax = ModuleDeclarationSyntax; + + var FunctionDeclarationSyntax = (function (_super) { + __extends(FunctionDeclarationSyntax, _super); + function FunctionDeclarationSyntax(modifiers, functionKeyword, identifier, callSignature, block, semicolonToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.modifiers = modifiers; + this.functionKeyword = functionKeyword; + this.identifier = identifier; + this.callSignature = callSignature; + this.block = block; + this.semicolonToken = semicolonToken; + } + FunctionDeclarationSyntax.prototype.accept = function (visitor) { + return visitor.visitFunctionDeclaration(this); + }; + + FunctionDeclarationSyntax.prototype.kind = function () { + return 129 /* FunctionDeclaration */; + }; + + FunctionDeclarationSyntax.prototype.childCount = function () { + return 6; + }; + + FunctionDeclarationSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.modifiers; + case 1: + return this.functionKeyword; + case 2: + return this.identifier; + case 3: + return this.callSignature; + case 4: + return this.block; + case 5: + return this.semicolonToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + FunctionDeclarationSyntax.prototype.isStatement = function () { + return true; + }; + + FunctionDeclarationSyntax.prototype.isModuleElement = function () { + return true; + }; + + FunctionDeclarationSyntax.prototype.update = function (modifiers, functionKeyword, identifier, callSignature, block, semicolonToken) { + if (this.modifiers === modifiers && this.functionKeyword === functionKeyword && this.identifier === identifier && this.callSignature === callSignature && this.block === block && this.semicolonToken === semicolonToken) { + return this; + } + + return new FunctionDeclarationSyntax(modifiers, functionKeyword, identifier, callSignature, block, semicolonToken, this.parsedInStrictMode()); + }; + + FunctionDeclarationSyntax.create = function (functionKeyword, identifier, callSignature) { + return new FunctionDeclarationSyntax(TypeScript.Syntax.emptyList, functionKeyword, identifier, callSignature, null, null, false); + }; + + FunctionDeclarationSyntax.create1 = function (identifier) { + return new FunctionDeclarationSyntax(TypeScript.Syntax.emptyList, TypeScript.Syntax.token(27 /* FunctionKeyword */), identifier, CallSignatureSyntax.create1(), null, null, false); + }; + + FunctionDeclarationSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + FunctionDeclarationSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + FunctionDeclarationSyntax.prototype.withModifiers = function (modifiers) { + return this.update(modifiers, this.functionKeyword, this.identifier, this.callSignature, this.block, this.semicolonToken); + }; + + FunctionDeclarationSyntax.prototype.withModifier = function (modifier) { + return this.withModifiers(TypeScript.Syntax.list([modifier])); + }; + + FunctionDeclarationSyntax.prototype.withFunctionKeyword = function (functionKeyword) { + return this.update(this.modifiers, functionKeyword, this.identifier, this.callSignature, this.block, this.semicolonToken); + }; + + FunctionDeclarationSyntax.prototype.withIdentifier = function (identifier) { + return this.update(this.modifiers, this.functionKeyword, identifier, this.callSignature, this.block, this.semicolonToken); + }; + + FunctionDeclarationSyntax.prototype.withCallSignature = function (callSignature) { + return this.update(this.modifiers, this.functionKeyword, this.identifier, callSignature, this.block, this.semicolonToken); + }; + + FunctionDeclarationSyntax.prototype.withBlock = function (block) { + return this.update(this.modifiers, this.functionKeyword, this.identifier, this.callSignature, block, this.semicolonToken); + }; + + FunctionDeclarationSyntax.prototype.withSemicolonToken = function (semicolonToken) { + return this.update(this.modifiers, this.functionKeyword, this.identifier, this.callSignature, this.block, semicolonToken); + }; + + FunctionDeclarationSyntax.prototype.isTypeScriptSpecific = function () { + if (this.modifiers.isTypeScriptSpecific()) { + return true; + } + if (this.callSignature.isTypeScriptSpecific()) { + return true; + } + if (this.block !== null && this.block.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return FunctionDeclarationSyntax; + })(TypeScript.SyntaxNode); + TypeScript.FunctionDeclarationSyntax = FunctionDeclarationSyntax; + + var VariableStatementSyntax = (function (_super) { + __extends(VariableStatementSyntax, _super); + function VariableStatementSyntax(modifiers, variableDeclaration, semicolonToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.modifiers = modifiers; + this.variableDeclaration = variableDeclaration; + this.semicolonToken = semicolonToken; + } + VariableStatementSyntax.prototype.accept = function (visitor) { + return visitor.visitVariableStatement(this); + }; + + VariableStatementSyntax.prototype.kind = function () { + return 147 /* VariableStatement */; + }; + + VariableStatementSyntax.prototype.childCount = function () { + return 3; + }; + + VariableStatementSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.modifiers; + case 1: + return this.variableDeclaration; + case 2: + return this.semicolonToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + VariableStatementSyntax.prototype.isStatement = function () { + return true; + }; + + VariableStatementSyntax.prototype.isModuleElement = function () { + return true; + }; + + VariableStatementSyntax.prototype.update = function (modifiers, variableDeclaration, semicolonToken) { + if (this.modifiers === modifiers && this.variableDeclaration === variableDeclaration && this.semicolonToken === semicolonToken) { + return this; + } + + return new VariableStatementSyntax(modifiers, variableDeclaration, semicolonToken, this.parsedInStrictMode()); + }; + + VariableStatementSyntax.create = function (variableDeclaration, semicolonToken) { + return new VariableStatementSyntax(TypeScript.Syntax.emptyList, variableDeclaration, semicolonToken, false); + }; + + VariableStatementSyntax.create1 = function (variableDeclaration) { + return new VariableStatementSyntax(TypeScript.Syntax.emptyList, variableDeclaration, TypeScript.Syntax.token(78 /* SemicolonToken */), false); + }; + + VariableStatementSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + VariableStatementSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + VariableStatementSyntax.prototype.withModifiers = function (modifiers) { + return this.update(modifiers, this.variableDeclaration, this.semicolonToken); + }; + + VariableStatementSyntax.prototype.withModifier = function (modifier) { + return this.withModifiers(TypeScript.Syntax.list([modifier])); + }; + + VariableStatementSyntax.prototype.withVariableDeclaration = function (variableDeclaration) { + return this.update(this.modifiers, variableDeclaration, this.semicolonToken); + }; + + VariableStatementSyntax.prototype.withSemicolonToken = function (semicolonToken) { + return this.update(this.modifiers, this.variableDeclaration, semicolonToken); + }; + + VariableStatementSyntax.prototype.isTypeScriptSpecific = function () { + if (this.modifiers.isTypeScriptSpecific()) { + return true; + } + if (this.variableDeclaration.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return VariableStatementSyntax; + })(TypeScript.SyntaxNode); + TypeScript.VariableStatementSyntax = VariableStatementSyntax; + + var VariableDeclarationSyntax = (function (_super) { + __extends(VariableDeclarationSyntax, _super); + function VariableDeclarationSyntax(varKeyword, variableDeclarators, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.varKeyword = varKeyword; + this.variableDeclarators = variableDeclarators; + } + VariableDeclarationSyntax.prototype.accept = function (visitor) { + return visitor.visitVariableDeclaration(this); + }; + + VariableDeclarationSyntax.prototype.kind = function () { + return 223 /* VariableDeclaration */; + }; + + VariableDeclarationSyntax.prototype.childCount = function () { + return 2; + }; + + VariableDeclarationSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.varKeyword; + case 1: + return this.variableDeclarators; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + VariableDeclarationSyntax.prototype.update = function (varKeyword, variableDeclarators) { + if (this.varKeyword === varKeyword && this.variableDeclarators === variableDeclarators) { + return this; + } + + return new VariableDeclarationSyntax(varKeyword, variableDeclarators, this.parsedInStrictMode()); + }; + + VariableDeclarationSyntax.create1 = function (variableDeclarators) { + return new VariableDeclarationSyntax(TypeScript.Syntax.token(40 /* VarKeyword */), variableDeclarators, false); + }; + + VariableDeclarationSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + VariableDeclarationSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + VariableDeclarationSyntax.prototype.withVarKeyword = function (varKeyword) { + return this.update(varKeyword, this.variableDeclarators); + }; + + VariableDeclarationSyntax.prototype.withVariableDeclarators = function (variableDeclarators) { + return this.update(this.varKeyword, variableDeclarators); + }; + + VariableDeclarationSyntax.prototype.withVariableDeclarator = function (variableDeclarator) { + return this.withVariableDeclarators(TypeScript.Syntax.separatedList([variableDeclarator])); + }; + + VariableDeclarationSyntax.prototype.isTypeScriptSpecific = function () { + if (this.variableDeclarators.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return VariableDeclarationSyntax; + })(TypeScript.SyntaxNode); + TypeScript.VariableDeclarationSyntax = VariableDeclarationSyntax; + + var VariableDeclaratorSyntax = (function (_super) { + __extends(VariableDeclaratorSyntax, _super); + function VariableDeclaratorSyntax(identifier, typeAnnotation, equalsValueClause, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.identifier = identifier; + this.typeAnnotation = typeAnnotation; + this.equalsValueClause = equalsValueClause; + } + VariableDeclaratorSyntax.prototype.accept = function (visitor) { + return visitor.visitVariableDeclarator(this); + }; + + VariableDeclaratorSyntax.prototype.kind = function () { + return 224 /* VariableDeclarator */; + }; + + VariableDeclaratorSyntax.prototype.childCount = function () { + return 3; + }; + + VariableDeclaratorSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.identifier; + case 1: + return this.typeAnnotation; + case 2: + return this.equalsValueClause; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + VariableDeclaratorSyntax.prototype.update = function (identifier, typeAnnotation, equalsValueClause) { + if (this.identifier === identifier && this.typeAnnotation === typeAnnotation && this.equalsValueClause === equalsValueClause) { + return this; + } + + return new VariableDeclaratorSyntax(identifier, typeAnnotation, equalsValueClause, this.parsedInStrictMode()); + }; + + VariableDeclaratorSyntax.create = function (identifier) { + return new VariableDeclaratorSyntax(identifier, null, null, false); + }; + + VariableDeclaratorSyntax.create1 = function (identifier) { + return new VariableDeclaratorSyntax(identifier, null, null, false); + }; + + VariableDeclaratorSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + VariableDeclaratorSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + VariableDeclaratorSyntax.prototype.withIdentifier = function (identifier) { + return this.update(identifier, this.typeAnnotation, this.equalsValueClause); + }; + + VariableDeclaratorSyntax.prototype.withTypeAnnotation = function (typeAnnotation) { + return this.update(this.identifier, typeAnnotation, this.equalsValueClause); + }; + + VariableDeclaratorSyntax.prototype.withEqualsValueClause = function (equalsValueClause) { + return this.update(this.identifier, this.typeAnnotation, equalsValueClause); + }; + + VariableDeclaratorSyntax.prototype.isTypeScriptSpecific = function () { + if (this.typeAnnotation !== null) { + return true; + } + if (this.equalsValueClause !== null && this.equalsValueClause.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return VariableDeclaratorSyntax; + })(TypeScript.SyntaxNode); + TypeScript.VariableDeclaratorSyntax = VariableDeclaratorSyntax; + + var EqualsValueClauseSyntax = (function (_super) { + __extends(EqualsValueClauseSyntax, _super); + function EqualsValueClauseSyntax(equalsToken, value, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.equalsToken = equalsToken; + this.value = value; + } + EqualsValueClauseSyntax.prototype.accept = function (visitor) { + return visitor.visitEqualsValueClause(this); + }; + + EqualsValueClauseSyntax.prototype.kind = function () { + return 230 /* EqualsValueClause */; + }; + + EqualsValueClauseSyntax.prototype.childCount = function () { + return 2; + }; + + EqualsValueClauseSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.equalsToken; + case 1: + return this.value; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + EqualsValueClauseSyntax.prototype.update = function (equalsToken, value) { + if (this.equalsToken === equalsToken && this.value === value) { + return this; + } + + return new EqualsValueClauseSyntax(equalsToken, value, this.parsedInStrictMode()); + }; + + EqualsValueClauseSyntax.create1 = function (value) { + return new EqualsValueClauseSyntax(TypeScript.Syntax.token(107 /* EqualsToken */), value, false); + }; + + EqualsValueClauseSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + EqualsValueClauseSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + EqualsValueClauseSyntax.prototype.withEqualsToken = function (equalsToken) { + return this.update(equalsToken, this.value); + }; + + EqualsValueClauseSyntax.prototype.withValue = function (value) { + return this.update(this.equalsToken, value); + }; + + EqualsValueClauseSyntax.prototype.isTypeScriptSpecific = function () { + if (this.value.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return EqualsValueClauseSyntax; + })(TypeScript.SyntaxNode); + TypeScript.EqualsValueClauseSyntax = EqualsValueClauseSyntax; + + var PrefixUnaryExpressionSyntax = (function (_super) { + __extends(PrefixUnaryExpressionSyntax, _super); + function PrefixUnaryExpressionSyntax(kind, operatorToken, operand, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.operatorToken = operatorToken; + this.operand = operand; + + this._kind = kind; + } + PrefixUnaryExpressionSyntax.prototype.accept = function (visitor) { + return visitor.visitPrefixUnaryExpression(this); + }; + + PrefixUnaryExpressionSyntax.prototype.childCount = function () { + return 2; + }; + + PrefixUnaryExpressionSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.operatorToken; + case 1: + return this.operand; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + PrefixUnaryExpressionSyntax.prototype.isUnaryExpression = function () { + return true; + }; + + PrefixUnaryExpressionSyntax.prototype.isExpression = function () { + return true; + }; + + PrefixUnaryExpressionSyntax.prototype.kind = function () { + return this._kind; + }; + + PrefixUnaryExpressionSyntax.prototype.update = function (kind, operatorToken, operand) { + if (this._kind === kind && this.operatorToken === operatorToken && this.operand === operand) { + return this; + } + + return new PrefixUnaryExpressionSyntax(kind, operatorToken, operand, this.parsedInStrictMode()); + }; + + PrefixUnaryExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + PrefixUnaryExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + PrefixUnaryExpressionSyntax.prototype.withKind = function (kind) { + return this.update(kind, this.operatorToken, this.operand); + }; + + PrefixUnaryExpressionSyntax.prototype.withOperatorToken = function (operatorToken) { + return this.update(this._kind, operatorToken, this.operand); + }; + + PrefixUnaryExpressionSyntax.prototype.withOperand = function (operand) { + return this.update(this._kind, this.operatorToken, operand); + }; + + PrefixUnaryExpressionSyntax.prototype.isTypeScriptSpecific = function () { + if (this.operand.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return PrefixUnaryExpressionSyntax; + })(TypeScript.SyntaxNode); + TypeScript.PrefixUnaryExpressionSyntax = PrefixUnaryExpressionSyntax; + + var ArrayLiteralExpressionSyntax = (function (_super) { + __extends(ArrayLiteralExpressionSyntax, _super); + function ArrayLiteralExpressionSyntax(openBracketToken, expressions, closeBracketToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.openBracketToken = openBracketToken; + this.expressions = expressions; + this.closeBracketToken = closeBracketToken; + } + ArrayLiteralExpressionSyntax.prototype.accept = function (visitor) { + return visitor.visitArrayLiteralExpression(this); + }; + + ArrayLiteralExpressionSyntax.prototype.kind = function () { + return 213 /* ArrayLiteralExpression */; + }; + + ArrayLiteralExpressionSyntax.prototype.childCount = function () { + return 3; + }; + + ArrayLiteralExpressionSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.openBracketToken; + case 1: + return this.expressions; + case 2: + return this.closeBracketToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ArrayLiteralExpressionSyntax.prototype.isUnaryExpression = function () { + return true; + }; + + ArrayLiteralExpressionSyntax.prototype.isExpression = function () { + return true; + }; + + ArrayLiteralExpressionSyntax.prototype.update = function (openBracketToken, expressions, closeBracketToken) { + if (this.openBracketToken === openBracketToken && this.expressions === expressions && this.closeBracketToken === closeBracketToken) { + return this; + } + + return new ArrayLiteralExpressionSyntax(openBracketToken, expressions, closeBracketToken, this.parsedInStrictMode()); + }; + + ArrayLiteralExpressionSyntax.create = function (openBracketToken, closeBracketToken) { + return new ArrayLiteralExpressionSyntax(openBracketToken, TypeScript.Syntax.emptySeparatedList, closeBracketToken, false); + }; + + ArrayLiteralExpressionSyntax.create1 = function () { + return new ArrayLiteralExpressionSyntax(TypeScript.Syntax.token(74 /* OpenBracketToken */), TypeScript.Syntax.emptySeparatedList, TypeScript.Syntax.token(75 /* CloseBracketToken */), false); + }; + + ArrayLiteralExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ArrayLiteralExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ArrayLiteralExpressionSyntax.prototype.withOpenBracketToken = function (openBracketToken) { + return this.update(openBracketToken, this.expressions, this.closeBracketToken); + }; + + ArrayLiteralExpressionSyntax.prototype.withExpressions = function (expressions) { + return this.update(this.openBracketToken, expressions, this.closeBracketToken); + }; + + ArrayLiteralExpressionSyntax.prototype.withExpression = function (expression) { + return this.withExpressions(TypeScript.Syntax.separatedList([expression])); + }; + + ArrayLiteralExpressionSyntax.prototype.withCloseBracketToken = function (closeBracketToken) { + return this.update(this.openBracketToken, this.expressions, closeBracketToken); + }; + + ArrayLiteralExpressionSyntax.prototype.isTypeScriptSpecific = function () { + if (this.expressions.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return ArrayLiteralExpressionSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ArrayLiteralExpressionSyntax = ArrayLiteralExpressionSyntax; + + var OmittedExpressionSyntax = (function (_super) { + __extends(OmittedExpressionSyntax, _super); + function OmittedExpressionSyntax(parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + } + OmittedExpressionSyntax.prototype.accept = function (visitor) { + return visitor.visitOmittedExpression(this); + }; + + OmittedExpressionSyntax.prototype.kind = function () { + return 222 /* OmittedExpression */; + }; + + OmittedExpressionSyntax.prototype.childCount = function () { + return 0; + }; + + OmittedExpressionSyntax.prototype.childAt = function (slot) { + throw TypeScript.Errors.invalidOperation(); + }; + + OmittedExpressionSyntax.prototype.isExpression = function () { + return true; + }; + + OmittedExpressionSyntax.prototype.update = function () { + return this; + }; + + OmittedExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + OmittedExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + OmittedExpressionSyntax.prototype.isTypeScriptSpecific = function () { + return false; + }; + return OmittedExpressionSyntax; + })(TypeScript.SyntaxNode); + TypeScript.OmittedExpressionSyntax = OmittedExpressionSyntax; + + var ParenthesizedExpressionSyntax = (function (_super) { + __extends(ParenthesizedExpressionSyntax, _super); + function ParenthesizedExpressionSyntax(openParenToken, expression, closeParenToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.openParenToken = openParenToken; + this.expression = expression; + this.closeParenToken = closeParenToken; + } + ParenthesizedExpressionSyntax.prototype.accept = function (visitor) { + return visitor.visitParenthesizedExpression(this); + }; + + ParenthesizedExpressionSyntax.prototype.kind = function () { + return 216 /* ParenthesizedExpression */; + }; + + ParenthesizedExpressionSyntax.prototype.childCount = function () { + return 3; + }; + + ParenthesizedExpressionSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.openParenToken; + case 1: + return this.expression; + case 2: + return this.closeParenToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ParenthesizedExpressionSyntax.prototype.isUnaryExpression = function () { + return true; + }; + + ParenthesizedExpressionSyntax.prototype.isExpression = function () { + return true; + }; + + ParenthesizedExpressionSyntax.prototype.update = function (openParenToken, expression, closeParenToken) { + if (this.openParenToken === openParenToken && this.expression === expression && this.closeParenToken === closeParenToken) { + return this; + } + + return new ParenthesizedExpressionSyntax(openParenToken, expression, closeParenToken, this.parsedInStrictMode()); + }; + + ParenthesizedExpressionSyntax.create1 = function (expression) { + return new ParenthesizedExpressionSyntax(TypeScript.Syntax.token(72 /* OpenParenToken */), expression, TypeScript.Syntax.token(73 /* CloseParenToken */), false); + }; + + ParenthesizedExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ParenthesizedExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ParenthesizedExpressionSyntax.prototype.withOpenParenToken = function (openParenToken) { + return this.update(openParenToken, this.expression, this.closeParenToken); + }; + + ParenthesizedExpressionSyntax.prototype.withExpression = function (expression) { + return this.update(this.openParenToken, expression, this.closeParenToken); + }; + + ParenthesizedExpressionSyntax.prototype.withCloseParenToken = function (closeParenToken) { + return this.update(this.openParenToken, this.expression, closeParenToken); + }; + + ParenthesizedExpressionSyntax.prototype.isTypeScriptSpecific = function () { + if (this.expression.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return ParenthesizedExpressionSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ParenthesizedExpressionSyntax = ParenthesizedExpressionSyntax; + + var ArrowFunctionExpressionSyntax = (function (_super) { + __extends(ArrowFunctionExpressionSyntax, _super); + function ArrowFunctionExpressionSyntax(equalsGreaterThanToken, body, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.equalsGreaterThanToken = equalsGreaterThanToken; + this.body = body; + } + ArrowFunctionExpressionSyntax.prototype.isUnaryExpression = function () { + return true; + }; + + ArrowFunctionExpressionSyntax.prototype.isExpression = function () { + return true; + }; + + ArrowFunctionExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ArrowFunctionExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ArrowFunctionExpressionSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return ArrowFunctionExpressionSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ArrowFunctionExpressionSyntax = ArrowFunctionExpressionSyntax; + + var SimpleArrowFunctionExpressionSyntax = (function (_super) { + __extends(SimpleArrowFunctionExpressionSyntax, _super); + function SimpleArrowFunctionExpressionSyntax(identifier, equalsGreaterThanToken, body, parsedInStrictMode) { + _super.call(this, equalsGreaterThanToken, body, parsedInStrictMode); + this.identifier = identifier; + } + SimpleArrowFunctionExpressionSyntax.prototype.accept = function (visitor) { + return visitor.visitSimpleArrowFunctionExpression(this); + }; + + SimpleArrowFunctionExpressionSyntax.prototype.kind = function () { + return 218 /* SimpleArrowFunctionExpression */; + }; + + SimpleArrowFunctionExpressionSyntax.prototype.childCount = function () { + return 3; + }; + + SimpleArrowFunctionExpressionSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.identifier; + case 1: + return this.equalsGreaterThanToken; + case 2: + return this.body; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + SimpleArrowFunctionExpressionSyntax.prototype.update = function (identifier, equalsGreaterThanToken, body) { + if (this.identifier === identifier && this.equalsGreaterThanToken === equalsGreaterThanToken && this.body === body) { + return this; + } + + return new SimpleArrowFunctionExpressionSyntax(identifier, equalsGreaterThanToken, body, this.parsedInStrictMode()); + }; + + SimpleArrowFunctionExpressionSyntax.create1 = function (identifier, body) { + return new SimpleArrowFunctionExpressionSyntax(identifier, TypeScript.Syntax.token(85 /* EqualsGreaterThanToken */), body, false); + }; + + SimpleArrowFunctionExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + SimpleArrowFunctionExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + SimpleArrowFunctionExpressionSyntax.prototype.withIdentifier = function (identifier) { + return this.update(identifier, this.equalsGreaterThanToken, this.body); + }; + + SimpleArrowFunctionExpressionSyntax.prototype.withEqualsGreaterThanToken = function (equalsGreaterThanToken) { + return this.update(this.identifier, equalsGreaterThanToken, this.body); + }; + + SimpleArrowFunctionExpressionSyntax.prototype.withBody = function (body) { + return this.update(this.identifier, this.equalsGreaterThanToken, body); + }; + + SimpleArrowFunctionExpressionSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return SimpleArrowFunctionExpressionSyntax; + })(ArrowFunctionExpressionSyntax); + TypeScript.SimpleArrowFunctionExpressionSyntax = SimpleArrowFunctionExpressionSyntax; + + var ParenthesizedArrowFunctionExpressionSyntax = (function (_super) { + __extends(ParenthesizedArrowFunctionExpressionSyntax, _super); + function ParenthesizedArrowFunctionExpressionSyntax(callSignature, equalsGreaterThanToken, body, parsedInStrictMode) { + _super.call(this, equalsGreaterThanToken, body, parsedInStrictMode); + this.callSignature = callSignature; + } + ParenthesizedArrowFunctionExpressionSyntax.prototype.accept = function (visitor) { + return visitor.visitParenthesizedArrowFunctionExpression(this); + }; + + ParenthesizedArrowFunctionExpressionSyntax.prototype.kind = function () { + return 217 /* ParenthesizedArrowFunctionExpression */; + }; + + ParenthesizedArrowFunctionExpressionSyntax.prototype.childCount = function () { + return 3; + }; + + ParenthesizedArrowFunctionExpressionSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.callSignature; + case 1: + return this.equalsGreaterThanToken; + case 2: + return this.body; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ParenthesizedArrowFunctionExpressionSyntax.prototype.update = function (callSignature, equalsGreaterThanToken, body) { + if (this.callSignature === callSignature && this.equalsGreaterThanToken === equalsGreaterThanToken && this.body === body) { + return this; + } + + return new ParenthesizedArrowFunctionExpressionSyntax(callSignature, equalsGreaterThanToken, body, this.parsedInStrictMode()); + }; + + ParenthesizedArrowFunctionExpressionSyntax.create1 = function (body) { + return new ParenthesizedArrowFunctionExpressionSyntax(CallSignatureSyntax.create1(), TypeScript.Syntax.token(85 /* EqualsGreaterThanToken */), body, false); + }; + + ParenthesizedArrowFunctionExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ParenthesizedArrowFunctionExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ParenthesizedArrowFunctionExpressionSyntax.prototype.withCallSignature = function (callSignature) { + return this.update(callSignature, this.equalsGreaterThanToken, this.body); + }; + + ParenthesizedArrowFunctionExpressionSyntax.prototype.withEqualsGreaterThanToken = function (equalsGreaterThanToken) { + return this.update(this.callSignature, equalsGreaterThanToken, this.body); + }; + + ParenthesizedArrowFunctionExpressionSyntax.prototype.withBody = function (body) { + return this.update(this.callSignature, this.equalsGreaterThanToken, body); + }; + + ParenthesizedArrowFunctionExpressionSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return ParenthesizedArrowFunctionExpressionSyntax; + })(ArrowFunctionExpressionSyntax); + TypeScript.ParenthesizedArrowFunctionExpressionSyntax = ParenthesizedArrowFunctionExpressionSyntax; + + var QualifiedNameSyntax = (function (_super) { + __extends(QualifiedNameSyntax, _super); + function QualifiedNameSyntax(left, dotToken, right, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.left = left; + this.dotToken = dotToken; + this.right = right; + } + QualifiedNameSyntax.prototype.accept = function (visitor) { + return visitor.visitQualifiedName(this); + }; + + QualifiedNameSyntax.prototype.kind = function () { + return 121 /* QualifiedName */; + }; + + QualifiedNameSyntax.prototype.childCount = function () { + return 3; + }; + + QualifiedNameSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.left; + case 1: + return this.dotToken; + case 2: + return this.right; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + QualifiedNameSyntax.prototype.isName = function () { + return true; + }; + + QualifiedNameSyntax.prototype.isType = function () { + return true; + }; + + QualifiedNameSyntax.prototype.isUnaryExpression = function () { + return true; + }; + + QualifiedNameSyntax.prototype.isExpression = function () { + return true; + }; + + QualifiedNameSyntax.prototype.update = function (left, dotToken, right) { + if (this.left === left && this.dotToken === dotToken && this.right === right) { + return this; + } + + return new QualifiedNameSyntax(left, dotToken, right, this.parsedInStrictMode()); + }; + + QualifiedNameSyntax.create1 = function (left, right) { + return new QualifiedNameSyntax(left, TypeScript.Syntax.token(76 /* DotToken */), right, false); + }; + + QualifiedNameSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + QualifiedNameSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + QualifiedNameSyntax.prototype.withLeft = function (left) { + return this.update(left, this.dotToken, this.right); + }; + + QualifiedNameSyntax.prototype.withDotToken = function (dotToken) { + return this.update(this.left, dotToken, this.right); + }; + + QualifiedNameSyntax.prototype.withRight = function (right) { + return this.update(this.left, this.dotToken, right); + }; + + QualifiedNameSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return QualifiedNameSyntax; + })(TypeScript.SyntaxNode); + TypeScript.QualifiedNameSyntax = QualifiedNameSyntax; + + var TypeArgumentListSyntax = (function (_super) { + __extends(TypeArgumentListSyntax, _super); + function TypeArgumentListSyntax(lessThanToken, typeArguments, greaterThanToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.lessThanToken = lessThanToken; + this.typeArguments = typeArguments; + this.greaterThanToken = greaterThanToken; + } + TypeArgumentListSyntax.prototype.accept = function (visitor) { + return visitor.visitTypeArgumentList(this); + }; + + TypeArgumentListSyntax.prototype.kind = function () { + return 227 /* TypeArgumentList */; + }; + + TypeArgumentListSyntax.prototype.childCount = function () { + return 3; + }; + + TypeArgumentListSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.lessThanToken; + case 1: + return this.typeArguments; + case 2: + return this.greaterThanToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + TypeArgumentListSyntax.prototype.update = function (lessThanToken, typeArguments, greaterThanToken) { + if (this.lessThanToken === lessThanToken && this.typeArguments === typeArguments && this.greaterThanToken === greaterThanToken) { + return this; + } + + return new TypeArgumentListSyntax(lessThanToken, typeArguments, greaterThanToken, this.parsedInStrictMode()); + }; + + TypeArgumentListSyntax.create = function (lessThanToken, greaterThanToken) { + return new TypeArgumentListSyntax(lessThanToken, TypeScript.Syntax.emptySeparatedList, greaterThanToken, false); + }; + + TypeArgumentListSyntax.create1 = function () { + return new TypeArgumentListSyntax(TypeScript.Syntax.token(80 /* LessThanToken */), TypeScript.Syntax.emptySeparatedList, TypeScript.Syntax.token(81 /* GreaterThanToken */), false); + }; + + TypeArgumentListSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + TypeArgumentListSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + TypeArgumentListSyntax.prototype.withLessThanToken = function (lessThanToken) { + return this.update(lessThanToken, this.typeArguments, this.greaterThanToken); + }; + + TypeArgumentListSyntax.prototype.withTypeArguments = function (typeArguments) { + return this.update(this.lessThanToken, typeArguments, this.greaterThanToken); + }; + + TypeArgumentListSyntax.prototype.withTypeArgument = function (typeArgument) { + return this.withTypeArguments(TypeScript.Syntax.separatedList([typeArgument])); + }; + + TypeArgumentListSyntax.prototype.withGreaterThanToken = function (greaterThanToken) { + return this.update(this.lessThanToken, this.typeArguments, greaterThanToken); + }; + + TypeArgumentListSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return TypeArgumentListSyntax; + })(TypeScript.SyntaxNode); + TypeScript.TypeArgumentListSyntax = TypeArgumentListSyntax; + + var ConstructorTypeSyntax = (function (_super) { + __extends(ConstructorTypeSyntax, _super); + function ConstructorTypeSyntax(newKeyword, typeParameterList, parameterList, equalsGreaterThanToken, type, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.newKeyword = newKeyword; + this.typeParameterList = typeParameterList; + this.parameterList = parameterList; + this.equalsGreaterThanToken = equalsGreaterThanToken; + this.type = type; + } + ConstructorTypeSyntax.prototype.accept = function (visitor) { + return visitor.visitConstructorType(this); + }; + + ConstructorTypeSyntax.prototype.kind = function () { + return 125 /* ConstructorType */; + }; + + ConstructorTypeSyntax.prototype.childCount = function () { + return 5; + }; + + ConstructorTypeSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.newKeyword; + case 1: + return this.typeParameterList; + case 2: + return this.parameterList; + case 3: + return this.equalsGreaterThanToken; + case 4: + return this.type; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ConstructorTypeSyntax.prototype.isType = function () { + return true; + }; + + ConstructorTypeSyntax.prototype.isUnaryExpression = function () { + return true; + }; + + ConstructorTypeSyntax.prototype.isExpression = function () { + return true; + }; + + ConstructorTypeSyntax.prototype.update = function (newKeyword, typeParameterList, parameterList, equalsGreaterThanToken, type) { + if (this.newKeyword === newKeyword && this.typeParameterList === typeParameterList && this.parameterList === parameterList && this.equalsGreaterThanToken === equalsGreaterThanToken && this.type === type) { + return this; + } + + return new ConstructorTypeSyntax(newKeyword, typeParameterList, parameterList, equalsGreaterThanToken, type, this.parsedInStrictMode()); + }; + + ConstructorTypeSyntax.create = function (newKeyword, parameterList, equalsGreaterThanToken, type) { + return new ConstructorTypeSyntax(newKeyword, null, parameterList, equalsGreaterThanToken, type, false); + }; + + ConstructorTypeSyntax.create1 = function (type) { + return new ConstructorTypeSyntax(TypeScript.Syntax.token(31 /* NewKeyword */), null, ParameterListSyntax.create1(), TypeScript.Syntax.token(85 /* EqualsGreaterThanToken */), type, false); + }; + + ConstructorTypeSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ConstructorTypeSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ConstructorTypeSyntax.prototype.withNewKeyword = function (newKeyword) { + return this.update(newKeyword, this.typeParameterList, this.parameterList, this.equalsGreaterThanToken, this.type); + }; + + ConstructorTypeSyntax.prototype.withTypeParameterList = function (typeParameterList) { + return this.update(this.newKeyword, typeParameterList, this.parameterList, this.equalsGreaterThanToken, this.type); + }; + + ConstructorTypeSyntax.prototype.withParameterList = function (parameterList) { + return this.update(this.newKeyword, this.typeParameterList, parameterList, this.equalsGreaterThanToken, this.type); + }; + + ConstructorTypeSyntax.prototype.withEqualsGreaterThanToken = function (equalsGreaterThanToken) { + return this.update(this.newKeyword, this.typeParameterList, this.parameterList, equalsGreaterThanToken, this.type); + }; + + ConstructorTypeSyntax.prototype.withType = function (type) { + return this.update(this.newKeyword, this.typeParameterList, this.parameterList, this.equalsGreaterThanToken, type); + }; + + ConstructorTypeSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return ConstructorTypeSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ConstructorTypeSyntax = ConstructorTypeSyntax; + + var FunctionTypeSyntax = (function (_super) { + __extends(FunctionTypeSyntax, _super); + function FunctionTypeSyntax(typeParameterList, parameterList, equalsGreaterThanToken, type, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.typeParameterList = typeParameterList; + this.parameterList = parameterList; + this.equalsGreaterThanToken = equalsGreaterThanToken; + this.type = type; + } + FunctionTypeSyntax.prototype.accept = function (visitor) { + return visitor.visitFunctionType(this); + }; + + FunctionTypeSyntax.prototype.kind = function () { + return 123 /* FunctionType */; + }; + + FunctionTypeSyntax.prototype.childCount = function () { + return 4; + }; + + FunctionTypeSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.typeParameterList; + case 1: + return this.parameterList; + case 2: + return this.equalsGreaterThanToken; + case 3: + return this.type; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + FunctionTypeSyntax.prototype.isType = function () { + return true; + }; + + FunctionTypeSyntax.prototype.isUnaryExpression = function () { + return true; + }; + + FunctionTypeSyntax.prototype.isExpression = function () { + return true; + }; + + FunctionTypeSyntax.prototype.update = function (typeParameterList, parameterList, equalsGreaterThanToken, type) { + if (this.typeParameterList === typeParameterList && this.parameterList === parameterList && this.equalsGreaterThanToken === equalsGreaterThanToken && this.type === type) { + return this; + } + + return new FunctionTypeSyntax(typeParameterList, parameterList, equalsGreaterThanToken, type, this.parsedInStrictMode()); + }; + + FunctionTypeSyntax.create = function (parameterList, equalsGreaterThanToken, type) { + return new FunctionTypeSyntax(null, parameterList, equalsGreaterThanToken, type, false); + }; + + FunctionTypeSyntax.create1 = function (type) { + return new FunctionTypeSyntax(null, ParameterListSyntax.create1(), TypeScript.Syntax.token(85 /* EqualsGreaterThanToken */), type, false); + }; + + FunctionTypeSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + FunctionTypeSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + FunctionTypeSyntax.prototype.withTypeParameterList = function (typeParameterList) { + return this.update(typeParameterList, this.parameterList, this.equalsGreaterThanToken, this.type); + }; + + FunctionTypeSyntax.prototype.withParameterList = function (parameterList) { + return this.update(this.typeParameterList, parameterList, this.equalsGreaterThanToken, this.type); + }; + + FunctionTypeSyntax.prototype.withEqualsGreaterThanToken = function (equalsGreaterThanToken) { + return this.update(this.typeParameterList, this.parameterList, equalsGreaterThanToken, this.type); + }; + + FunctionTypeSyntax.prototype.withType = function (type) { + return this.update(this.typeParameterList, this.parameterList, this.equalsGreaterThanToken, type); + }; + + FunctionTypeSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return FunctionTypeSyntax; + })(TypeScript.SyntaxNode); + TypeScript.FunctionTypeSyntax = FunctionTypeSyntax; + + var ObjectTypeSyntax = (function (_super) { + __extends(ObjectTypeSyntax, _super); + function ObjectTypeSyntax(openBraceToken, typeMembers, closeBraceToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.openBraceToken = openBraceToken; + this.typeMembers = typeMembers; + this.closeBraceToken = closeBraceToken; + } + ObjectTypeSyntax.prototype.accept = function (visitor) { + return visitor.visitObjectType(this); + }; + + ObjectTypeSyntax.prototype.kind = function () { + return 122 /* ObjectType */; + }; + + ObjectTypeSyntax.prototype.childCount = function () { + return 3; + }; + + ObjectTypeSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.openBraceToken; + case 1: + return this.typeMembers; + case 2: + return this.closeBraceToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ObjectTypeSyntax.prototype.isType = function () { + return true; + }; + + ObjectTypeSyntax.prototype.isUnaryExpression = function () { + return true; + }; + + ObjectTypeSyntax.prototype.isExpression = function () { + return true; + }; + + ObjectTypeSyntax.prototype.update = function (openBraceToken, typeMembers, closeBraceToken) { + if (this.openBraceToken === openBraceToken && this.typeMembers === typeMembers && this.closeBraceToken === closeBraceToken) { + return this; + } + + return new ObjectTypeSyntax(openBraceToken, typeMembers, closeBraceToken, this.parsedInStrictMode()); + }; + + ObjectTypeSyntax.create = function (openBraceToken, closeBraceToken) { + return new ObjectTypeSyntax(openBraceToken, TypeScript.Syntax.emptySeparatedList, closeBraceToken, false); + }; + + ObjectTypeSyntax.create1 = function () { + return new ObjectTypeSyntax(TypeScript.Syntax.token(70 /* OpenBraceToken */), TypeScript.Syntax.emptySeparatedList, TypeScript.Syntax.token(71 /* CloseBraceToken */), false); + }; + + ObjectTypeSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ObjectTypeSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ObjectTypeSyntax.prototype.withOpenBraceToken = function (openBraceToken) { + return this.update(openBraceToken, this.typeMembers, this.closeBraceToken); + }; + + ObjectTypeSyntax.prototype.withTypeMembers = function (typeMembers) { + return this.update(this.openBraceToken, typeMembers, this.closeBraceToken); + }; + + ObjectTypeSyntax.prototype.withTypeMember = function (typeMember) { + return this.withTypeMembers(TypeScript.Syntax.separatedList([typeMember])); + }; + + ObjectTypeSyntax.prototype.withCloseBraceToken = function (closeBraceToken) { + return this.update(this.openBraceToken, this.typeMembers, closeBraceToken); + }; + + ObjectTypeSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return ObjectTypeSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ObjectTypeSyntax = ObjectTypeSyntax; + + var ArrayTypeSyntax = (function (_super) { + __extends(ArrayTypeSyntax, _super); + function ArrayTypeSyntax(type, openBracketToken, closeBracketToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.type = type; + this.openBracketToken = openBracketToken; + this.closeBracketToken = closeBracketToken; + } + ArrayTypeSyntax.prototype.accept = function (visitor) { + return visitor.visitArrayType(this); + }; + + ArrayTypeSyntax.prototype.kind = function () { + return 124 /* ArrayType */; + }; + + ArrayTypeSyntax.prototype.childCount = function () { + return 3; + }; + + ArrayTypeSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.type; + case 1: + return this.openBracketToken; + case 2: + return this.closeBracketToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ArrayTypeSyntax.prototype.isType = function () { + return true; + }; + + ArrayTypeSyntax.prototype.isUnaryExpression = function () { + return true; + }; + + ArrayTypeSyntax.prototype.isExpression = function () { + return true; + }; + + ArrayTypeSyntax.prototype.update = function (type, openBracketToken, closeBracketToken) { + if (this.type === type && this.openBracketToken === openBracketToken && this.closeBracketToken === closeBracketToken) { + return this; + } + + return new ArrayTypeSyntax(type, openBracketToken, closeBracketToken, this.parsedInStrictMode()); + }; + + ArrayTypeSyntax.create1 = function (type) { + return new ArrayTypeSyntax(type, TypeScript.Syntax.token(74 /* OpenBracketToken */), TypeScript.Syntax.token(75 /* CloseBracketToken */), false); + }; + + ArrayTypeSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ArrayTypeSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ArrayTypeSyntax.prototype.withType = function (type) { + return this.update(type, this.openBracketToken, this.closeBracketToken); + }; + + ArrayTypeSyntax.prototype.withOpenBracketToken = function (openBracketToken) { + return this.update(this.type, openBracketToken, this.closeBracketToken); + }; + + ArrayTypeSyntax.prototype.withCloseBracketToken = function (closeBracketToken) { + return this.update(this.type, this.openBracketToken, closeBracketToken); + }; + + ArrayTypeSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return ArrayTypeSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ArrayTypeSyntax = ArrayTypeSyntax; + + var GenericTypeSyntax = (function (_super) { + __extends(GenericTypeSyntax, _super); + function GenericTypeSyntax(name, typeArgumentList, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.name = name; + this.typeArgumentList = typeArgumentList; + } + GenericTypeSyntax.prototype.accept = function (visitor) { + return visitor.visitGenericType(this); + }; + + GenericTypeSyntax.prototype.kind = function () { + return 126 /* GenericType */; + }; + + GenericTypeSyntax.prototype.childCount = function () { + return 2; + }; + + GenericTypeSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.name; + case 1: + return this.typeArgumentList; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + GenericTypeSyntax.prototype.isType = function () { + return true; + }; + + GenericTypeSyntax.prototype.isUnaryExpression = function () { + return true; + }; + + GenericTypeSyntax.prototype.isExpression = function () { + return true; + }; + + GenericTypeSyntax.prototype.update = function (name, typeArgumentList) { + if (this.name === name && this.typeArgumentList === typeArgumentList) { + return this; + } + + return new GenericTypeSyntax(name, typeArgumentList, this.parsedInStrictMode()); + }; + + GenericTypeSyntax.create1 = function (name) { + return new GenericTypeSyntax(name, TypeArgumentListSyntax.create1(), false); + }; + + GenericTypeSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + GenericTypeSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + GenericTypeSyntax.prototype.withName = function (name) { + return this.update(name, this.typeArgumentList); + }; + + GenericTypeSyntax.prototype.withTypeArgumentList = function (typeArgumentList) { + return this.update(this.name, typeArgumentList); + }; + + GenericTypeSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return GenericTypeSyntax; + })(TypeScript.SyntaxNode); + TypeScript.GenericTypeSyntax = GenericTypeSyntax; + + var TypeQuerySyntax = (function (_super) { + __extends(TypeQuerySyntax, _super); + function TypeQuerySyntax(typeOfKeyword, name, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.typeOfKeyword = typeOfKeyword; + this.name = name; + } + TypeQuerySyntax.prototype.accept = function (visitor) { + return visitor.visitTypeQuery(this); + }; + + TypeQuerySyntax.prototype.kind = function () { + return 127 /* TypeQuery */; + }; + + TypeQuerySyntax.prototype.childCount = function () { + return 2; + }; + + TypeQuerySyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.typeOfKeyword; + case 1: + return this.name; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + TypeQuerySyntax.prototype.isType = function () { + return true; + }; + + TypeQuerySyntax.prototype.isUnaryExpression = function () { + return true; + }; + + TypeQuerySyntax.prototype.isExpression = function () { + return true; + }; + + TypeQuerySyntax.prototype.update = function (typeOfKeyword, name) { + if (this.typeOfKeyword === typeOfKeyword && this.name === name) { + return this; + } + + return new TypeQuerySyntax(typeOfKeyword, name, this.parsedInStrictMode()); + }; + + TypeQuerySyntax.create1 = function (name) { + return new TypeQuerySyntax(TypeScript.Syntax.token(39 /* TypeOfKeyword */), name, false); + }; + + TypeQuerySyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + TypeQuerySyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + TypeQuerySyntax.prototype.withTypeOfKeyword = function (typeOfKeyword) { + return this.update(typeOfKeyword, this.name); + }; + + TypeQuerySyntax.prototype.withName = function (name) { + return this.update(this.typeOfKeyword, name); + }; + + TypeQuerySyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return TypeQuerySyntax; + })(TypeScript.SyntaxNode); + TypeScript.TypeQuerySyntax = TypeQuerySyntax; + + var TypeAnnotationSyntax = (function (_super) { + __extends(TypeAnnotationSyntax, _super); + function TypeAnnotationSyntax(colonToken, type, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.colonToken = colonToken; + this.type = type; + } + TypeAnnotationSyntax.prototype.accept = function (visitor) { + return visitor.visitTypeAnnotation(this); + }; + + TypeAnnotationSyntax.prototype.kind = function () { + return 244 /* TypeAnnotation */; + }; + + TypeAnnotationSyntax.prototype.childCount = function () { + return 2; + }; + + TypeAnnotationSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.colonToken; + case 1: + return this.type; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + TypeAnnotationSyntax.prototype.update = function (colonToken, type) { + if (this.colonToken === colonToken && this.type === type) { + return this; + } + + return new TypeAnnotationSyntax(colonToken, type, this.parsedInStrictMode()); + }; + + TypeAnnotationSyntax.create1 = function (type) { + return new TypeAnnotationSyntax(TypeScript.Syntax.token(106 /* ColonToken */), type, false); + }; + + TypeAnnotationSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + TypeAnnotationSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + TypeAnnotationSyntax.prototype.withColonToken = function (colonToken) { + return this.update(colonToken, this.type); + }; + + TypeAnnotationSyntax.prototype.withType = function (type) { + return this.update(this.colonToken, type); + }; + + TypeAnnotationSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return TypeAnnotationSyntax; + })(TypeScript.SyntaxNode); + TypeScript.TypeAnnotationSyntax = TypeAnnotationSyntax; + + var BlockSyntax = (function (_super) { + __extends(BlockSyntax, _super); + function BlockSyntax(openBraceToken, statements, closeBraceToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.openBraceToken = openBraceToken; + this.statements = statements; + this.closeBraceToken = closeBraceToken; + } + BlockSyntax.prototype.accept = function (visitor) { + return visitor.visitBlock(this); + }; + + BlockSyntax.prototype.kind = function () { + return 145 /* Block */; + }; + + BlockSyntax.prototype.childCount = function () { + return 3; + }; + + BlockSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.openBraceToken; + case 1: + return this.statements; + case 2: + return this.closeBraceToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + BlockSyntax.prototype.isStatement = function () { + return true; + }; + + BlockSyntax.prototype.isModuleElement = function () { + return true; + }; + + BlockSyntax.prototype.update = function (openBraceToken, statements, closeBraceToken) { + if (this.openBraceToken === openBraceToken && this.statements === statements && this.closeBraceToken === closeBraceToken) { + return this; + } + + return new BlockSyntax(openBraceToken, statements, closeBraceToken, this.parsedInStrictMode()); + }; + + BlockSyntax.create = function (openBraceToken, closeBraceToken) { + return new BlockSyntax(openBraceToken, TypeScript.Syntax.emptyList, closeBraceToken, false); + }; + + BlockSyntax.create1 = function () { + return new BlockSyntax(TypeScript.Syntax.token(70 /* OpenBraceToken */), TypeScript.Syntax.emptyList, TypeScript.Syntax.token(71 /* CloseBraceToken */), false); + }; + + BlockSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + BlockSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + BlockSyntax.prototype.withOpenBraceToken = function (openBraceToken) { + return this.update(openBraceToken, this.statements, this.closeBraceToken); + }; + + BlockSyntax.prototype.withStatements = function (statements) { + return this.update(this.openBraceToken, statements, this.closeBraceToken); + }; + + BlockSyntax.prototype.withStatement = function (statement) { + return this.withStatements(TypeScript.Syntax.list([statement])); + }; + + BlockSyntax.prototype.withCloseBraceToken = function (closeBraceToken) { + return this.update(this.openBraceToken, this.statements, closeBraceToken); + }; + + BlockSyntax.prototype.isTypeScriptSpecific = function () { + if (this.statements.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return BlockSyntax; + })(TypeScript.SyntaxNode); + TypeScript.BlockSyntax = BlockSyntax; + + var ParameterSyntax = (function (_super) { + __extends(ParameterSyntax, _super); + function ParameterSyntax(dotDotDotToken, publicOrPrivateKeyword, identifier, questionToken, typeAnnotation, equalsValueClause, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.dotDotDotToken = dotDotDotToken; + this.publicOrPrivateKeyword = publicOrPrivateKeyword; + this.identifier = identifier; + this.questionToken = questionToken; + this.typeAnnotation = typeAnnotation; + this.equalsValueClause = equalsValueClause; + } + ParameterSyntax.prototype.accept = function (visitor) { + return visitor.visitParameter(this); + }; + + ParameterSyntax.prototype.kind = function () { + return 242 /* Parameter */; + }; + + ParameterSyntax.prototype.childCount = function () { + return 6; + }; + + ParameterSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.dotDotDotToken; + case 1: + return this.publicOrPrivateKeyword; + case 2: + return this.identifier; + case 3: + return this.questionToken; + case 4: + return this.typeAnnotation; + case 5: + return this.equalsValueClause; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ParameterSyntax.prototype.update = function (dotDotDotToken, publicOrPrivateKeyword, identifier, questionToken, typeAnnotation, equalsValueClause) { + if (this.dotDotDotToken === dotDotDotToken && this.publicOrPrivateKeyword === publicOrPrivateKeyword && this.identifier === identifier && this.questionToken === questionToken && this.typeAnnotation === typeAnnotation && this.equalsValueClause === equalsValueClause) { + return this; + } + + return new ParameterSyntax(dotDotDotToken, publicOrPrivateKeyword, identifier, questionToken, typeAnnotation, equalsValueClause, this.parsedInStrictMode()); + }; + + ParameterSyntax.create = function (identifier) { + return new ParameterSyntax(null, null, identifier, null, null, null, false); + }; + + ParameterSyntax.create1 = function (identifier) { + return new ParameterSyntax(null, null, identifier, null, null, null, false); + }; + + ParameterSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ParameterSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ParameterSyntax.prototype.withDotDotDotToken = function (dotDotDotToken) { + return this.update(dotDotDotToken, this.publicOrPrivateKeyword, this.identifier, this.questionToken, this.typeAnnotation, this.equalsValueClause); + }; + + ParameterSyntax.prototype.withPublicOrPrivateKeyword = function (publicOrPrivateKeyword) { + return this.update(this.dotDotDotToken, publicOrPrivateKeyword, this.identifier, this.questionToken, this.typeAnnotation, this.equalsValueClause); + }; + + ParameterSyntax.prototype.withIdentifier = function (identifier) { + return this.update(this.dotDotDotToken, this.publicOrPrivateKeyword, identifier, this.questionToken, this.typeAnnotation, this.equalsValueClause); + }; + + ParameterSyntax.prototype.withQuestionToken = function (questionToken) { + return this.update(this.dotDotDotToken, this.publicOrPrivateKeyword, this.identifier, questionToken, this.typeAnnotation, this.equalsValueClause); + }; + + ParameterSyntax.prototype.withTypeAnnotation = function (typeAnnotation) { + return this.update(this.dotDotDotToken, this.publicOrPrivateKeyword, this.identifier, this.questionToken, typeAnnotation, this.equalsValueClause); + }; + + ParameterSyntax.prototype.withEqualsValueClause = function (equalsValueClause) { + return this.update(this.dotDotDotToken, this.publicOrPrivateKeyword, this.identifier, this.questionToken, this.typeAnnotation, equalsValueClause); + }; + + ParameterSyntax.prototype.isTypeScriptSpecific = function () { + if (this.dotDotDotToken !== null) { + return true; + } + if (this.publicOrPrivateKeyword !== null) { + return true; + } + if (this.questionToken !== null) { + return true; + } + if (this.typeAnnotation !== null) { + return true; + } + if (this.equalsValueClause !== null) { + return true; + } + return false; + }; + return ParameterSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ParameterSyntax = ParameterSyntax; + + var MemberAccessExpressionSyntax = (function (_super) { + __extends(MemberAccessExpressionSyntax, _super); + function MemberAccessExpressionSyntax(expression, dotToken, name, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.expression = expression; + this.dotToken = dotToken; + this.name = name; + } + MemberAccessExpressionSyntax.prototype.accept = function (visitor) { + return visitor.visitMemberAccessExpression(this); + }; + + MemberAccessExpressionSyntax.prototype.kind = function () { + return 211 /* MemberAccessExpression */; + }; + + MemberAccessExpressionSyntax.prototype.childCount = function () { + return 3; + }; + + MemberAccessExpressionSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.expression; + case 1: + return this.dotToken; + case 2: + return this.name; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + MemberAccessExpressionSyntax.prototype.isUnaryExpression = function () { + return true; + }; + + MemberAccessExpressionSyntax.prototype.isExpression = function () { + return true; + }; + + MemberAccessExpressionSyntax.prototype.update = function (expression, dotToken, name) { + if (this.expression === expression && this.dotToken === dotToken && this.name === name) { + return this; + } + + return new MemberAccessExpressionSyntax(expression, dotToken, name, this.parsedInStrictMode()); + }; + + MemberAccessExpressionSyntax.create1 = function (expression, name) { + return new MemberAccessExpressionSyntax(expression, TypeScript.Syntax.token(76 /* DotToken */), name, false); + }; + + MemberAccessExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + MemberAccessExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + MemberAccessExpressionSyntax.prototype.withExpression = function (expression) { + return this.update(expression, this.dotToken, this.name); + }; + + MemberAccessExpressionSyntax.prototype.withDotToken = function (dotToken) { + return this.update(this.expression, dotToken, this.name); + }; + + MemberAccessExpressionSyntax.prototype.withName = function (name) { + return this.update(this.expression, this.dotToken, name); + }; + + MemberAccessExpressionSyntax.prototype.isTypeScriptSpecific = function () { + if (this.expression.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return MemberAccessExpressionSyntax; + })(TypeScript.SyntaxNode); + TypeScript.MemberAccessExpressionSyntax = MemberAccessExpressionSyntax; + + var PostfixUnaryExpressionSyntax = (function (_super) { + __extends(PostfixUnaryExpressionSyntax, _super); + function PostfixUnaryExpressionSyntax(kind, operand, operatorToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.operand = operand; + this.operatorToken = operatorToken; + + this._kind = kind; + } + PostfixUnaryExpressionSyntax.prototype.accept = function (visitor) { + return visitor.visitPostfixUnaryExpression(this); + }; + + PostfixUnaryExpressionSyntax.prototype.childCount = function () { + return 2; + }; + + PostfixUnaryExpressionSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.operand; + case 1: + return this.operatorToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + PostfixUnaryExpressionSyntax.prototype.isUnaryExpression = function () { + return true; + }; + + PostfixUnaryExpressionSyntax.prototype.isExpression = function () { + return true; + }; + + PostfixUnaryExpressionSyntax.prototype.kind = function () { + return this._kind; + }; + + PostfixUnaryExpressionSyntax.prototype.update = function (kind, operand, operatorToken) { + if (this._kind === kind && this.operand === operand && this.operatorToken === operatorToken) { + return this; + } + + return new PostfixUnaryExpressionSyntax(kind, operand, operatorToken, this.parsedInStrictMode()); + }; + + PostfixUnaryExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + PostfixUnaryExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + PostfixUnaryExpressionSyntax.prototype.withKind = function (kind) { + return this.update(kind, this.operand, this.operatorToken); + }; + + PostfixUnaryExpressionSyntax.prototype.withOperand = function (operand) { + return this.update(this._kind, operand, this.operatorToken); + }; + + PostfixUnaryExpressionSyntax.prototype.withOperatorToken = function (operatorToken) { + return this.update(this._kind, this.operand, operatorToken); + }; + + PostfixUnaryExpressionSyntax.prototype.isTypeScriptSpecific = function () { + if (this.operand.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return PostfixUnaryExpressionSyntax; + })(TypeScript.SyntaxNode); + TypeScript.PostfixUnaryExpressionSyntax = PostfixUnaryExpressionSyntax; + + var ElementAccessExpressionSyntax = (function (_super) { + __extends(ElementAccessExpressionSyntax, _super); + function ElementAccessExpressionSyntax(expression, openBracketToken, argumentExpression, closeBracketToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.expression = expression; + this.openBracketToken = openBracketToken; + this.argumentExpression = argumentExpression; + this.closeBracketToken = closeBracketToken; + } + ElementAccessExpressionSyntax.prototype.accept = function (visitor) { + return visitor.visitElementAccessExpression(this); + }; + + ElementAccessExpressionSyntax.prototype.kind = function () { + return 220 /* ElementAccessExpression */; + }; + + ElementAccessExpressionSyntax.prototype.childCount = function () { + return 4; + }; + + ElementAccessExpressionSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.expression; + case 1: + return this.openBracketToken; + case 2: + return this.argumentExpression; + case 3: + return this.closeBracketToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ElementAccessExpressionSyntax.prototype.isUnaryExpression = function () { + return true; + }; + + ElementAccessExpressionSyntax.prototype.isExpression = function () { + return true; + }; + + ElementAccessExpressionSyntax.prototype.update = function (expression, openBracketToken, argumentExpression, closeBracketToken) { + if (this.expression === expression && this.openBracketToken === openBracketToken && this.argumentExpression === argumentExpression && this.closeBracketToken === closeBracketToken) { + return this; + } + + return new ElementAccessExpressionSyntax(expression, openBracketToken, argumentExpression, closeBracketToken, this.parsedInStrictMode()); + }; + + ElementAccessExpressionSyntax.create1 = function (expression, argumentExpression) { + return new ElementAccessExpressionSyntax(expression, TypeScript.Syntax.token(74 /* OpenBracketToken */), argumentExpression, TypeScript.Syntax.token(75 /* CloseBracketToken */), false); + }; + + ElementAccessExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ElementAccessExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ElementAccessExpressionSyntax.prototype.withExpression = function (expression) { + return this.update(expression, this.openBracketToken, this.argumentExpression, this.closeBracketToken); + }; + + ElementAccessExpressionSyntax.prototype.withOpenBracketToken = function (openBracketToken) { + return this.update(this.expression, openBracketToken, this.argumentExpression, this.closeBracketToken); + }; + + ElementAccessExpressionSyntax.prototype.withArgumentExpression = function (argumentExpression) { + return this.update(this.expression, this.openBracketToken, argumentExpression, this.closeBracketToken); + }; + + ElementAccessExpressionSyntax.prototype.withCloseBracketToken = function (closeBracketToken) { + return this.update(this.expression, this.openBracketToken, this.argumentExpression, closeBracketToken); + }; + + ElementAccessExpressionSyntax.prototype.isTypeScriptSpecific = function () { + if (this.expression.isTypeScriptSpecific()) { + return true; + } + if (this.argumentExpression.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return ElementAccessExpressionSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ElementAccessExpressionSyntax = ElementAccessExpressionSyntax; + + var InvocationExpressionSyntax = (function (_super) { + __extends(InvocationExpressionSyntax, _super); + function InvocationExpressionSyntax(expression, argumentList, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.expression = expression; + this.argumentList = argumentList; + } + InvocationExpressionSyntax.prototype.accept = function (visitor) { + return visitor.visitInvocationExpression(this); + }; + + InvocationExpressionSyntax.prototype.kind = function () { + return 212 /* InvocationExpression */; + }; + + InvocationExpressionSyntax.prototype.childCount = function () { + return 2; + }; + + InvocationExpressionSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.expression; + case 1: + return this.argumentList; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + InvocationExpressionSyntax.prototype.isUnaryExpression = function () { + return true; + }; + + InvocationExpressionSyntax.prototype.isExpression = function () { + return true; + }; + + InvocationExpressionSyntax.prototype.update = function (expression, argumentList) { + if (this.expression === expression && this.argumentList === argumentList) { + return this; + } + + return new InvocationExpressionSyntax(expression, argumentList, this.parsedInStrictMode()); + }; + + InvocationExpressionSyntax.create1 = function (expression) { + return new InvocationExpressionSyntax(expression, ArgumentListSyntax.create1(), false); + }; + + InvocationExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + InvocationExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + InvocationExpressionSyntax.prototype.withExpression = function (expression) { + return this.update(expression, this.argumentList); + }; + + InvocationExpressionSyntax.prototype.withArgumentList = function (argumentList) { + return this.update(this.expression, argumentList); + }; + + InvocationExpressionSyntax.prototype.isTypeScriptSpecific = function () { + if (this.expression.isTypeScriptSpecific()) { + return true; + } + if (this.argumentList.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return InvocationExpressionSyntax; + })(TypeScript.SyntaxNode); + TypeScript.InvocationExpressionSyntax = InvocationExpressionSyntax; + + var ArgumentListSyntax = (function (_super) { + __extends(ArgumentListSyntax, _super); + function ArgumentListSyntax(typeArgumentList, openParenToken, arguments, closeParenToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.typeArgumentList = typeArgumentList; + this.openParenToken = openParenToken; + this.arguments = arguments; + this.closeParenToken = closeParenToken; + } + ArgumentListSyntax.prototype.accept = function (visitor) { + return visitor.visitArgumentList(this); + }; + + ArgumentListSyntax.prototype.kind = function () { + return 225 /* ArgumentList */; + }; + + ArgumentListSyntax.prototype.childCount = function () { + return 4; + }; + + ArgumentListSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.typeArgumentList; + case 1: + return this.openParenToken; + case 2: + return this.arguments; + case 3: + return this.closeParenToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ArgumentListSyntax.prototype.update = function (typeArgumentList, openParenToken, _arguments, closeParenToken) { + if (this.typeArgumentList === typeArgumentList && this.openParenToken === openParenToken && this.arguments === _arguments && this.closeParenToken === closeParenToken) { + return this; + } + + return new ArgumentListSyntax(typeArgumentList, openParenToken, _arguments, closeParenToken, this.parsedInStrictMode()); + }; + + ArgumentListSyntax.create = function (openParenToken, closeParenToken) { + return new ArgumentListSyntax(null, openParenToken, TypeScript.Syntax.emptySeparatedList, closeParenToken, false); + }; + + ArgumentListSyntax.create1 = function () { + return new ArgumentListSyntax(null, TypeScript.Syntax.token(72 /* OpenParenToken */), TypeScript.Syntax.emptySeparatedList, TypeScript.Syntax.token(73 /* CloseParenToken */), false); + }; + + ArgumentListSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ArgumentListSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ArgumentListSyntax.prototype.withTypeArgumentList = function (typeArgumentList) { + return this.update(typeArgumentList, this.openParenToken, this.arguments, this.closeParenToken); + }; + + ArgumentListSyntax.prototype.withOpenParenToken = function (openParenToken) { + return this.update(this.typeArgumentList, openParenToken, this.arguments, this.closeParenToken); + }; + + ArgumentListSyntax.prototype.withArguments = function (_arguments) { + return this.update(this.typeArgumentList, this.openParenToken, _arguments, this.closeParenToken); + }; + + ArgumentListSyntax.prototype.withArgument = function (_argument) { + return this.withArguments(TypeScript.Syntax.separatedList([_argument])); + }; + + ArgumentListSyntax.prototype.withCloseParenToken = function (closeParenToken) { + return this.update(this.typeArgumentList, this.openParenToken, this.arguments, closeParenToken); + }; + + ArgumentListSyntax.prototype.isTypeScriptSpecific = function () { + if (this.typeArgumentList !== null && this.typeArgumentList.isTypeScriptSpecific()) { + return true; + } + if (this.arguments.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return ArgumentListSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ArgumentListSyntax = ArgumentListSyntax; + + var BinaryExpressionSyntax = (function (_super) { + __extends(BinaryExpressionSyntax, _super); + function BinaryExpressionSyntax(kind, left, operatorToken, right, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.left = left; + this.operatorToken = operatorToken; + this.right = right; + + this._kind = kind; + } + BinaryExpressionSyntax.prototype.accept = function (visitor) { + return visitor.visitBinaryExpression(this); + }; + + BinaryExpressionSyntax.prototype.childCount = function () { + return 3; + }; + + BinaryExpressionSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.left; + case 1: + return this.operatorToken; + case 2: + return this.right; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + BinaryExpressionSyntax.prototype.isExpression = function () { + return true; + }; + + BinaryExpressionSyntax.prototype.kind = function () { + return this._kind; + }; + + BinaryExpressionSyntax.prototype.update = function (kind, left, operatorToken, right) { + if (this._kind === kind && this.left === left && this.operatorToken === operatorToken && this.right === right) { + return this; + } + + return new BinaryExpressionSyntax(kind, left, operatorToken, right, this.parsedInStrictMode()); + }; + + BinaryExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + BinaryExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + BinaryExpressionSyntax.prototype.withKind = function (kind) { + return this.update(kind, this.left, this.operatorToken, this.right); + }; + + BinaryExpressionSyntax.prototype.withLeft = function (left) { + return this.update(this._kind, left, this.operatorToken, this.right); + }; + + BinaryExpressionSyntax.prototype.withOperatorToken = function (operatorToken) { + return this.update(this._kind, this.left, operatorToken, this.right); + }; + + BinaryExpressionSyntax.prototype.withRight = function (right) { + return this.update(this._kind, this.left, this.operatorToken, right); + }; + + BinaryExpressionSyntax.prototype.isTypeScriptSpecific = function () { + if (this.left.isTypeScriptSpecific()) { + return true; + } + if (this.right.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return BinaryExpressionSyntax; + })(TypeScript.SyntaxNode); + TypeScript.BinaryExpressionSyntax = BinaryExpressionSyntax; + + var ConditionalExpressionSyntax = (function (_super) { + __extends(ConditionalExpressionSyntax, _super); + function ConditionalExpressionSyntax(condition, questionToken, whenTrue, colonToken, whenFalse, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.condition = condition; + this.questionToken = questionToken; + this.whenTrue = whenTrue; + this.colonToken = colonToken; + this.whenFalse = whenFalse; + } + ConditionalExpressionSyntax.prototype.accept = function (visitor) { + return visitor.visitConditionalExpression(this); + }; + + ConditionalExpressionSyntax.prototype.kind = function () { + return 185 /* ConditionalExpression */; + }; + + ConditionalExpressionSyntax.prototype.childCount = function () { + return 5; + }; + + ConditionalExpressionSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.condition; + case 1: + return this.questionToken; + case 2: + return this.whenTrue; + case 3: + return this.colonToken; + case 4: + return this.whenFalse; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ConditionalExpressionSyntax.prototype.isExpression = function () { + return true; + }; + + ConditionalExpressionSyntax.prototype.update = function (condition, questionToken, whenTrue, colonToken, whenFalse) { + if (this.condition === condition && this.questionToken === questionToken && this.whenTrue === whenTrue && this.colonToken === colonToken && this.whenFalse === whenFalse) { + return this; + } + + return new ConditionalExpressionSyntax(condition, questionToken, whenTrue, colonToken, whenFalse, this.parsedInStrictMode()); + }; + + ConditionalExpressionSyntax.create1 = function (condition, whenTrue, whenFalse) { + return new ConditionalExpressionSyntax(condition, TypeScript.Syntax.token(105 /* QuestionToken */), whenTrue, TypeScript.Syntax.token(106 /* ColonToken */), whenFalse, false); + }; + + ConditionalExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ConditionalExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ConditionalExpressionSyntax.prototype.withCondition = function (condition) { + return this.update(condition, this.questionToken, this.whenTrue, this.colonToken, this.whenFalse); + }; + + ConditionalExpressionSyntax.prototype.withQuestionToken = function (questionToken) { + return this.update(this.condition, questionToken, this.whenTrue, this.colonToken, this.whenFalse); + }; + + ConditionalExpressionSyntax.prototype.withWhenTrue = function (whenTrue) { + return this.update(this.condition, this.questionToken, whenTrue, this.colonToken, this.whenFalse); + }; + + ConditionalExpressionSyntax.prototype.withColonToken = function (colonToken) { + return this.update(this.condition, this.questionToken, this.whenTrue, colonToken, this.whenFalse); + }; + + ConditionalExpressionSyntax.prototype.withWhenFalse = function (whenFalse) { + return this.update(this.condition, this.questionToken, this.whenTrue, this.colonToken, whenFalse); + }; + + ConditionalExpressionSyntax.prototype.isTypeScriptSpecific = function () { + if (this.condition.isTypeScriptSpecific()) { + return true; + } + if (this.whenTrue.isTypeScriptSpecific()) { + return true; + } + if (this.whenFalse.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return ConditionalExpressionSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ConditionalExpressionSyntax = ConditionalExpressionSyntax; + + var ConstructSignatureSyntax = (function (_super) { + __extends(ConstructSignatureSyntax, _super); + function ConstructSignatureSyntax(newKeyword, callSignature, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.newKeyword = newKeyword; + this.callSignature = callSignature; + } + ConstructSignatureSyntax.prototype.accept = function (visitor) { + return visitor.visitConstructSignature(this); + }; + + ConstructSignatureSyntax.prototype.kind = function () { + return 142 /* ConstructSignature */; + }; + + ConstructSignatureSyntax.prototype.childCount = function () { + return 2; + }; + + ConstructSignatureSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.newKeyword; + case 1: + return this.callSignature; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ConstructSignatureSyntax.prototype.isTypeMember = function () { + return true; + }; + + ConstructSignatureSyntax.prototype.update = function (newKeyword, callSignature) { + if (this.newKeyword === newKeyword && this.callSignature === callSignature) { + return this; + } + + return new ConstructSignatureSyntax(newKeyword, callSignature, this.parsedInStrictMode()); + }; + + ConstructSignatureSyntax.create1 = function () { + return new ConstructSignatureSyntax(TypeScript.Syntax.token(31 /* NewKeyword */), CallSignatureSyntax.create1(), false); + }; + + ConstructSignatureSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ConstructSignatureSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ConstructSignatureSyntax.prototype.withNewKeyword = function (newKeyword) { + return this.update(newKeyword, this.callSignature); + }; + + ConstructSignatureSyntax.prototype.withCallSignature = function (callSignature) { + return this.update(this.newKeyword, callSignature); + }; + + ConstructSignatureSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return ConstructSignatureSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ConstructSignatureSyntax = ConstructSignatureSyntax; + + var MethodSignatureSyntax = (function (_super) { + __extends(MethodSignatureSyntax, _super); + function MethodSignatureSyntax(propertyName, questionToken, callSignature, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.propertyName = propertyName; + this.questionToken = questionToken; + this.callSignature = callSignature; + } + MethodSignatureSyntax.prototype.accept = function (visitor) { + return visitor.visitMethodSignature(this); + }; + + MethodSignatureSyntax.prototype.kind = function () { + return 144 /* MethodSignature */; + }; + + MethodSignatureSyntax.prototype.childCount = function () { + return 3; + }; + + MethodSignatureSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.propertyName; + case 1: + return this.questionToken; + case 2: + return this.callSignature; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + MethodSignatureSyntax.prototype.isTypeMember = function () { + return true; + }; + + MethodSignatureSyntax.prototype.update = function (propertyName, questionToken, callSignature) { + if (this.propertyName === propertyName && this.questionToken === questionToken && this.callSignature === callSignature) { + return this; + } + + return new MethodSignatureSyntax(propertyName, questionToken, callSignature, this.parsedInStrictMode()); + }; + + MethodSignatureSyntax.create = function (propertyName, callSignature) { + return new MethodSignatureSyntax(propertyName, null, callSignature, false); + }; + + MethodSignatureSyntax.create1 = function (propertyName) { + return new MethodSignatureSyntax(propertyName, null, CallSignatureSyntax.create1(), false); + }; + + MethodSignatureSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + MethodSignatureSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + MethodSignatureSyntax.prototype.withPropertyName = function (propertyName) { + return this.update(propertyName, this.questionToken, this.callSignature); + }; + + MethodSignatureSyntax.prototype.withQuestionToken = function (questionToken) { + return this.update(this.propertyName, questionToken, this.callSignature); + }; + + MethodSignatureSyntax.prototype.withCallSignature = function (callSignature) { + return this.update(this.propertyName, this.questionToken, callSignature); + }; + + MethodSignatureSyntax.prototype.isTypeScriptSpecific = function () { + if (this.callSignature.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return MethodSignatureSyntax; + })(TypeScript.SyntaxNode); + TypeScript.MethodSignatureSyntax = MethodSignatureSyntax; + + var IndexSignatureSyntax = (function (_super) { + __extends(IndexSignatureSyntax, _super); + function IndexSignatureSyntax(openBracketToken, parameter, closeBracketToken, typeAnnotation, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.openBracketToken = openBracketToken; + this.parameter = parameter; + this.closeBracketToken = closeBracketToken; + this.typeAnnotation = typeAnnotation; + } + IndexSignatureSyntax.prototype.accept = function (visitor) { + return visitor.visitIndexSignature(this); + }; + + IndexSignatureSyntax.prototype.kind = function () { + return 143 /* IndexSignature */; + }; + + IndexSignatureSyntax.prototype.childCount = function () { + return 4; + }; + + IndexSignatureSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.openBracketToken; + case 1: + return this.parameter; + case 2: + return this.closeBracketToken; + case 3: + return this.typeAnnotation; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + IndexSignatureSyntax.prototype.isTypeMember = function () { + return true; + }; + + IndexSignatureSyntax.prototype.isClassElement = function () { + return true; + }; + + IndexSignatureSyntax.prototype.update = function (openBracketToken, parameter, closeBracketToken, typeAnnotation) { + if (this.openBracketToken === openBracketToken && this.parameter === parameter && this.closeBracketToken === closeBracketToken && this.typeAnnotation === typeAnnotation) { + return this; + } + + return new IndexSignatureSyntax(openBracketToken, parameter, closeBracketToken, typeAnnotation, this.parsedInStrictMode()); + }; + + IndexSignatureSyntax.create = function (openBracketToken, parameter, closeBracketToken) { + return new IndexSignatureSyntax(openBracketToken, parameter, closeBracketToken, null, false); + }; + + IndexSignatureSyntax.create1 = function (parameter) { + return new IndexSignatureSyntax(TypeScript.Syntax.token(74 /* OpenBracketToken */), parameter, TypeScript.Syntax.token(75 /* CloseBracketToken */), null, false); + }; + + IndexSignatureSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + IndexSignatureSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + IndexSignatureSyntax.prototype.withOpenBracketToken = function (openBracketToken) { + return this.update(openBracketToken, this.parameter, this.closeBracketToken, this.typeAnnotation); + }; + + IndexSignatureSyntax.prototype.withParameter = function (parameter) { + return this.update(this.openBracketToken, parameter, this.closeBracketToken, this.typeAnnotation); + }; + + IndexSignatureSyntax.prototype.withCloseBracketToken = function (closeBracketToken) { + return this.update(this.openBracketToken, this.parameter, closeBracketToken, this.typeAnnotation); + }; + + IndexSignatureSyntax.prototype.withTypeAnnotation = function (typeAnnotation) { + return this.update(this.openBracketToken, this.parameter, this.closeBracketToken, typeAnnotation); + }; + + IndexSignatureSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return IndexSignatureSyntax; + })(TypeScript.SyntaxNode); + TypeScript.IndexSignatureSyntax = IndexSignatureSyntax; + + var PropertySignatureSyntax = (function (_super) { + __extends(PropertySignatureSyntax, _super); + function PropertySignatureSyntax(propertyName, questionToken, typeAnnotation, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.propertyName = propertyName; + this.questionToken = questionToken; + this.typeAnnotation = typeAnnotation; + } + PropertySignatureSyntax.prototype.accept = function (visitor) { + return visitor.visitPropertySignature(this); + }; + + PropertySignatureSyntax.prototype.kind = function () { + return 140 /* PropertySignature */; + }; + + PropertySignatureSyntax.prototype.childCount = function () { + return 3; + }; + + PropertySignatureSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.propertyName; + case 1: + return this.questionToken; + case 2: + return this.typeAnnotation; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + PropertySignatureSyntax.prototype.isTypeMember = function () { + return true; + }; + + PropertySignatureSyntax.prototype.update = function (propertyName, questionToken, typeAnnotation) { + if (this.propertyName === propertyName && this.questionToken === questionToken && this.typeAnnotation === typeAnnotation) { + return this; + } + + return new PropertySignatureSyntax(propertyName, questionToken, typeAnnotation, this.parsedInStrictMode()); + }; + + PropertySignatureSyntax.create = function (propertyName) { + return new PropertySignatureSyntax(propertyName, null, null, false); + }; + + PropertySignatureSyntax.create1 = function (propertyName) { + return new PropertySignatureSyntax(propertyName, null, null, false); + }; + + PropertySignatureSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + PropertySignatureSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + PropertySignatureSyntax.prototype.withPropertyName = function (propertyName) { + return this.update(propertyName, this.questionToken, this.typeAnnotation); + }; + + PropertySignatureSyntax.prototype.withQuestionToken = function (questionToken) { + return this.update(this.propertyName, questionToken, this.typeAnnotation); + }; + + PropertySignatureSyntax.prototype.withTypeAnnotation = function (typeAnnotation) { + return this.update(this.propertyName, this.questionToken, typeAnnotation); + }; + + PropertySignatureSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return PropertySignatureSyntax; + })(TypeScript.SyntaxNode); + TypeScript.PropertySignatureSyntax = PropertySignatureSyntax; + + var CallSignatureSyntax = (function (_super) { + __extends(CallSignatureSyntax, _super); + function CallSignatureSyntax(typeParameterList, parameterList, typeAnnotation, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.typeParameterList = typeParameterList; + this.parameterList = parameterList; + this.typeAnnotation = typeAnnotation; + } + CallSignatureSyntax.prototype.accept = function (visitor) { + return visitor.visitCallSignature(this); + }; + + CallSignatureSyntax.prototype.kind = function () { + return 141 /* CallSignature */; + }; + + CallSignatureSyntax.prototype.childCount = function () { + return 3; + }; + + CallSignatureSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.typeParameterList; + case 1: + return this.parameterList; + case 2: + return this.typeAnnotation; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + CallSignatureSyntax.prototype.isTypeMember = function () { + return true; + }; + + CallSignatureSyntax.prototype.update = function (typeParameterList, parameterList, typeAnnotation) { + if (this.typeParameterList === typeParameterList && this.parameterList === parameterList && this.typeAnnotation === typeAnnotation) { + return this; + } + + return new CallSignatureSyntax(typeParameterList, parameterList, typeAnnotation, this.parsedInStrictMode()); + }; + + CallSignatureSyntax.create = function (parameterList) { + return new CallSignatureSyntax(null, parameterList, null, false); + }; + + CallSignatureSyntax.create1 = function () { + return new CallSignatureSyntax(null, ParameterListSyntax.create1(), null, false); + }; + + CallSignatureSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + CallSignatureSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + CallSignatureSyntax.prototype.withTypeParameterList = function (typeParameterList) { + return this.update(typeParameterList, this.parameterList, this.typeAnnotation); + }; + + CallSignatureSyntax.prototype.withParameterList = function (parameterList) { + return this.update(this.typeParameterList, parameterList, this.typeAnnotation); + }; + + CallSignatureSyntax.prototype.withTypeAnnotation = function (typeAnnotation) { + return this.update(this.typeParameterList, this.parameterList, typeAnnotation); + }; + + CallSignatureSyntax.prototype.isTypeScriptSpecific = function () { + if (this.typeParameterList !== null) { + return true; + } + if (this.parameterList.isTypeScriptSpecific()) { + return true; + } + if (this.typeAnnotation !== null) { + return true; + } + return false; + }; + return CallSignatureSyntax; + })(TypeScript.SyntaxNode); + TypeScript.CallSignatureSyntax = CallSignatureSyntax; + + var ParameterListSyntax = (function (_super) { + __extends(ParameterListSyntax, _super); + function ParameterListSyntax(openParenToken, parameters, closeParenToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.openParenToken = openParenToken; + this.parameters = parameters; + this.closeParenToken = closeParenToken; + } + ParameterListSyntax.prototype.accept = function (visitor) { + return visitor.visitParameterList(this); + }; + + ParameterListSyntax.prototype.kind = function () { + return 226 /* ParameterList */; + }; + + ParameterListSyntax.prototype.childCount = function () { + return 3; + }; + + ParameterListSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.openParenToken; + case 1: + return this.parameters; + case 2: + return this.closeParenToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ParameterListSyntax.prototype.update = function (openParenToken, parameters, closeParenToken) { + if (this.openParenToken === openParenToken && this.parameters === parameters && this.closeParenToken === closeParenToken) { + return this; + } + + return new ParameterListSyntax(openParenToken, parameters, closeParenToken, this.parsedInStrictMode()); + }; + + ParameterListSyntax.create = function (openParenToken, closeParenToken) { + return new ParameterListSyntax(openParenToken, TypeScript.Syntax.emptySeparatedList, closeParenToken, false); + }; + + ParameterListSyntax.create1 = function () { + return new ParameterListSyntax(TypeScript.Syntax.token(72 /* OpenParenToken */), TypeScript.Syntax.emptySeparatedList, TypeScript.Syntax.token(73 /* CloseParenToken */), false); + }; + + ParameterListSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ParameterListSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ParameterListSyntax.prototype.withOpenParenToken = function (openParenToken) { + return this.update(openParenToken, this.parameters, this.closeParenToken); + }; + + ParameterListSyntax.prototype.withParameters = function (parameters) { + return this.update(this.openParenToken, parameters, this.closeParenToken); + }; + + ParameterListSyntax.prototype.withParameter = function (parameter) { + return this.withParameters(TypeScript.Syntax.separatedList([parameter])); + }; + + ParameterListSyntax.prototype.withCloseParenToken = function (closeParenToken) { + return this.update(this.openParenToken, this.parameters, closeParenToken); + }; + + ParameterListSyntax.prototype.isTypeScriptSpecific = function () { + if (this.parameters.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return ParameterListSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ParameterListSyntax = ParameterListSyntax; + + var TypeParameterListSyntax = (function (_super) { + __extends(TypeParameterListSyntax, _super); + function TypeParameterListSyntax(lessThanToken, typeParameters, greaterThanToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.lessThanToken = lessThanToken; + this.typeParameters = typeParameters; + this.greaterThanToken = greaterThanToken; + } + TypeParameterListSyntax.prototype.accept = function (visitor) { + return visitor.visitTypeParameterList(this); + }; + + TypeParameterListSyntax.prototype.kind = function () { + return 228 /* TypeParameterList */; + }; + + TypeParameterListSyntax.prototype.childCount = function () { + return 3; + }; + + TypeParameterListSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.lessThanToken; + case 1: + return this.typeParameters; + case 2: + return this.greaterThanToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + TypeParameterListSyntax.prototype.update = function (lessThanToken, typeParameters, greaterThanToken) { + if (this.lessThanToken === lessThanToken && this.typeParameters === typeParameters && this.greaterThanToken === greaterThanToken) { + return this; + } + + return new TypeParameterListSyntax(lessThanToken, typeParameters, greaterThanToken, this.parsedInStrictMode()); + }; + + TypeParameterListSyntax.create = function (lessThanToken, greaterThanToken) { + return new TypeParameterListSyntax(lessThanToken, TypeScript.Syntax.emptySeparatedList, greaterThanToken, false); + }; + + TypeParameterListSyntax.create1 = function () { + return new TypeParameterListSyntax(TypeScript.Syntax.token(80 /* LessThanToken */), TypeScript.Syntax.emptySeparatedList, TypeScript.Syntax.token(81 /* GreaterThanToken */), false); + }; + + TypeParameterListSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + TypeParameterListSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + TypeParameterListSyntax.prototype.withLessThanToken = function (lessThanToken) { + return this.update(lessThanToken, this.typeParameters, this.greaterThanToken); + }; + + TypeParameterListSyntax.prototype.withTypeParameters = function (typeParameters) { + return this.update(this.lessThanToken, typeParameters, this.greaterThanToken); + }; + + TypeParameterListSyntax.prototype.withTypeParameter = function (typeParameter) { + return this.withTypeParameters(TypeScript.Syntax.separatedList([typeParameter])); + }; + + TypeParameterListSyntax.prototype.withGreaterThanToken = function (greaterThanToken) { + return this.update(this.lessThanToken, this.typeParameters, greaterThanToken); + }; + + TypeParameterListSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return TypeParameterListSyntax; + })(TypeScript.SyntaxNode); + TypeScript.TypeParameterListSyntax = TypeParameterListSyntax; + + var TypeParameterSyntax = (function (_super) { + __extends(TypeParameterSyntax, _super); + function TypeParameterSyntax(identifier, constraint, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.identifier = identifier; + this.constraint = constraint; + } + TypeParameterSyntax.prototype.accept = function (visitor) { + return visitor.visitTypeParameter(this); + }; + + TypeParameterSyntax.prototype.kind = function () { + return 236 /* TypeParameter */; + }; + + TypeParameterSyntax.prototype.childCount = function () { + return 2; + }; + + TypeParameterSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.identifier; + case 1: + return this.constraint; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + TypeParameterSyntax.prototype.update = function (identifier, constraint) { + if (this.identifier === identifier && this.constraint === constraint) { + return this; + } + + return new TypeParameterSyntax(identifier, constraint, this.parsedInStrictMode()); + }; + + TypeParameterSyntax.create = function (identifier) { + return new TypeParameterSyntax(identifier, null, false); + }; + + TypeParameterSyntax.create1 = function (identifier) { + return new TypeParameterSyntax(identifier, null, false); + }; + + TypeParameterSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + TypeParameterSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + TypeParameterSyntax.prototype.withIdentifier = function (identifier) { + return this.update(identifier, this.constraint); + }; + + TypeParameterSyntax.prototype.withConstraint = function (constraint) { + return this.update(this.identifier, constraint); + }; + + TypeParameterSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return TypeParameterSyntax; + })(TypeScript.SyntaxNode); + TypeScript.TypeParameterSyntax = TypeParameterSyntax; + + var ConstraintSyntax = (function (_super) { + __extends(ConstraintSyntax, _super); + function ConstraintSyntax(extendsKeyword, type, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.extendsKeyword = extendsKeyword; + this.type = type; + } + ConstraintSyntax.prototype.accept = function (visitor) { + return visitor.visitConstraint(this); + }; + + ConstraintSyntax.prototype.kind = function () { + return 237 /* Constraint */; + }; + + ConstraintSyntax.prototype.childCount = function () { + return 2; + }; + + ConstraintSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.extendsKeyword; + case 1: + return this.type; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ConstraintSyntax.prototype.update = function (extendsKeyword, type) { + if (this.extendsKeyword === extendsKeyword && this.type === type) { + return this; + } + + return new ConstraintSyntax(extendsKeyword, type, this.parsedInStrictMode()); + }; + + ConstraintSyntax.create1 = function (type) { + return new ConstraintSyntax(TypeScript.Syntax.token(48 /* ExtendsKeyword */), type, false); + }; + + ConstraintSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ConstraintSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ConstraintSyntax.prototype.withExtendsKeyword = function (extendsKeyword) { + return this.update(extendsKeyword, this.type); + }; + + ConstraintSyntax.prototype.withType = function (type) { + return this.update(this.extendsKeyword, type); + }; + + ConstraintSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return ConstraintSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ConstraintSyntax = ConstraintSyntax; + + var ElseClauseSyntax = (function (_super) { + __extends(ElseClauseSyntax, _super); + function ElseClauseSyntax(elseKeyword, statement, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.elseKeyword = elseKeyword; + this.statement = statement; + } + ElseClauseSyntax.prototype.accept = function (visitor) { + return visitor.visitElseClause(this); + }; + + ElseClauseSyntax.prototype.kind = function () { + return 233 /* ElseClause */; + }; + + ElseClauseSyntax.prototype.childCount = function () { + return 2; + }; + + ElseClauseSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.elseKeyword; + case 1: + return this.statement; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ElseClauseSyntax.prototype.update = function (elseKeyword, statement) { + if (this.elseKeyword === elseKeyword && this.statement === statement) { + return this; + } + + return new ElseClauseSyntax(elseKeyword, statement, this.parsedInStrictMode()); + }; + + ElseClauseSyntax.create1 = function (statement) { + return new ElseClauseSyntax(TypeScript.Syntax.token(23 /* ElseKeyword */), statement, false); + }; + + ElseClauseSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ElseClauseSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ElseClauseSyntax.prototype.withElseKeyword = function (elseKeyword) { + return this.update(elseKeyword, this.statement); + }; + + ElseClauseSyntax.prototype.withStatement = function (statement) { + return this.update(this.elseKeyword, statement); + }; + + ElseClauseSyntax.prototype.isTypeScriptSpecific = function () { + if (this.statement.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return ElseClauseSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ElseClauseSyntax = ElseClauseSyntax; + + var IfStatementSyntax = (function (_super) { + __extends(IfStatementSyntax, _super); + function IfStatementSyntax(ifKeyword, openParenToken, condition, closeParenToken, statement, elseClause, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.ifKeyword = ifKeyword; + this.openParenToken = openParenToken; + this.condition = condition; + this.closeParenToken = closeParenToken; + this.statement = statement; + this.elseClause = elseClause; + } + IfStatementSyntax.prototype.accept = function (visitor) { + return visitor.visitIfStatement(this); + }; + + IfStatementSyntax.prototype.kind = function () { + return 146 /* IfStatement */; + }; + + IfStatementSyntax.prototype.childCount = function () { + return 6; + }; + + IfStatementSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.ifKeyword; + case 1: + return this.openParenToken; + case 2: + return this.condition; + case 3: + return this.closeParenToken; + case 4: + return this.statement; + case 5: + return this.elseClause; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + IfStatementSyntax.prototype.isStatement = function () { + return true; + }; + + IfStatementSyntax.prototype.isModuleElement = function () { + return true; + }; + + IfStatementSyntax.prototype.update = function (ifKeyword, openParenToken, condition, closeParenToken, statement, elseClause) { + if (this.ifKeyword === ifKeyword && this.openParenToken === openParenToken && this.condition === condition && this.closeParenToken === closeParenToken && this.statement === statement && this.elseClause === elseClause) { + return this; + } + + return new IfStatementSyntax(ifKeyword, openParenToken, condition, closeParenToken, statement, elseClause, this.parsedInStrictMode()); + }; + + IfStatementSyntax.create = function (ifKeyword, openParenToken, condition, closeParenToken, statement) { + return new IfStatementSyntax(ifKeyword, openParenToken, condition, closeParenToken, statement, null, false); + }; + + IfStatementSyntax.create1 = function (condition, statement) { + return new IfStatementSyntax(TypeScript.Syntax.token(28 /* IfKeyword */), TypeScript.Syntax.token(72 /* OpenParenToken */), condition, TypeScript.Syntax.token(73 /* CloseParenToken */), statement, null, false); + }; + + IfStatementSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + IfStatementSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + IfStatementSyntax.prototype.withIfKeyword = function (ifKeyword) { + return this.update(ifKeyword, this.openParenToken, this.condition, this.closeParenToken, this.statement, this.elseClause); + }; + + IfStatementSyntax.prototype.withOpenParenToken = function (openParenToken) { + return this.update(this.ifKeyword, openParenToken, this.condition, this.closeParenToken, this.statement, this.elseClause); + }; + + IfStatementSyntax.prototype.withCondition = function (condition) { + return this.update(this.ifKeyword, this.openParenToken, condition, this.closeParenToken, this.statement, this.elseClause); + }; + + IfStatementSyntax.prototype.withCloseParenToken = function (closeParenToken) { + return this.update(this.ifKeyword, this.openParenToken, this.condition, closeParenToken, this.statement, this.elseClause); + }; + + IfStatementSyntax.prototype.withStatement = function (statement) { + return this.update(this.ifKeyword, this.openParenToken, this.condition, this.closeParenToken, statement, this.elseClause); + }; + + IfStatementSyntax.prototype.withElseClause = function (elseClause) { + return this.update(this.ifKeyword, this.openParenToken, this.condition, this.closeParenToken, this.statement, elseClause); + }; + + IfStatementSyntax.prototype.isTypeScriptSpecific = function () { + if (this.condition.isTypeScriptSpecific()) { + return true; + } + if (this.statement.isTypeScriptSpecific()) { + return true; + } + if (this.elseClause !== null && this.elseClause.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return IfStatementSyntax; + })(TypeScript.SyntaxNode); + TypeScript.IfStatementSyntax = IfStatementSyntax; + + var ExpressionStatementSyntax = (function (_super) { + __extends(ExpressionStatementSyntax, _super); + function ExpressionStatementSyntax(expression, semicolonToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.expression = expression; + this.semicolonToken = semicolonToken; + } + ExpressionStatementSyntax.prototype.accept = function (visitor) { + return visitor.visitExpressionStatement(this); + }; + + ExpressionStatementSyntax.prototype.kind = function () { + return 148 /* ExpressionStatement */; + }; + + ExpressionStatementSyntax.prototype.childCount = function () { + return 2; + }; + + ExpressionStatementSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.expression; + case 1: + return this.semicolonToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ExpressionStatementSyntax.prototype.isStatement = function () { + return true; + }; + + ExpressionStatementSyntax.prototype.isModuleElement = function () { + return true; + }; + + ExpressionStatementSyntax.prototype.update = function (expression, semicolonToken) { + if (this.expression === expression && this.semicolonToken === semicolonToken) { + return this; + } + + return new ExpressionStatementSyntax(expression, semicolonToken, this.parsedInStrictMode()); + }; + + ExpressionStatementSyntax.create1 = function (expression) { + return new ExpressionStatementSyntax(expression, TypeScript.Syntax.token(78 /* SemicolonToken */), false); + }; + + ExpressionStatementSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ExpressionStatementSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ExpressionStatementSyntax.prototype.withExpression = function (expression) { + return this.update(expression, this.semicolonToken); + }; + + ExpressionStatementSyntax.prototype.withSemicolonToken = function (semicolonToken) { + return this.update(this.expression, semicolonToken); + }; + + ExpressionStatementSyntax.prototype.isTypeScriptSpecific = function () { + if (this.expression.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return ExpressionStatementSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ExpressionStatementSyntax = ExpressionStatementSyntax; + + var ConstructorDeclarationSyntax = (function (_super) { + __extends(ConstructorDeclarationSyntax, _super); + function ConstructorDeclarationSyntax(constructorKeyword, parameterList, block, semicolonToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.constructorKeyword = constructorKeyword; + this.parameterList = parameterList; + this.block = block; + this.semicolonToken = semicolonToken; + } + ConstructorDeclarationSyntax.prototype.accept = function (visitor) { + return visitor.visitConstructorDeclaration(this); + }; + + ConstructorDeclarationSyntax.prototype.kind = function () { + return 137 /* ConstructorDeclaration */; + }; + + ConstructorDeclarationSyntax.prototype.childCount = function () { + return 4; + }; + + ConstructorDeclarationSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.constructorKeyword; + case 1: + return this.parameterList; + case 2: + return this.block; + case 3: + return this.semicolonToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ConstructorDeclarationSyntax.prototype.isClassElement = function () { + return true; + }; + + ConstructorDeclarationSyntax.prototype.update = function (constructorKeyword, parameterList, block, semicolonToken) { + if (this.constructorKeyword === constructorKeyword && this.parameterList === parameterList && this.block === block && this.semicolonToken === semicolonToken) { + return this; + } + + return new ConstructorDeclarationSyntax(constructorKeyword, parameterList, block, semicolonToken, this.parsedInStrictMode()); + }; + + ConstructorDeclarationSyntax.create = function (constructorKeyword, parameterList) { + return new ConstructorDeclarationSyntax(constructorKeyword, parameterList, null, null, false); + }; + + ConstructorDeclarationSyntax.create1 = function () { + return new ConstructorDeclarationSyntax(TypeScript.Syntax.token(62 /* ConstructorKeyword */), ParameterListSyntax.create1(), null, null, false); + }; + + ConstructorDeclarationSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ConstructorDeclarationSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ConstructorDeclarationSyntax.prototype.withConstructorKeyword = function (constructorKeyword) { + return this.update(constructorKeyword, this.parameterList, this.block, this.semicolonToken); + }; + + ConstructorDeclarationSyntax.prototype.withParameterList = function (parameterList) { + return this.update(this.constructorKeyword, parameterList, this.block, this.semicolonToken); + }; + + ConstructorDeclarationSyntax.prototype.withBlock = function (block) { + return this.update(this.constructorKeyword, this.parameterList, block, this.semicolonToken); + }; + + ConstructorDeclarationSyntax.prototype.withSemicolonToken = function (semicolonToken) { + return this.update(this.constructorKeyword, this.parameterList, this.block, semicolonToken); + }; + + ConstructorDeclarationSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return ConstructorDeclarationSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ConstructorDeclarationSyntax = ConstructorDeclarationSyntax; + + var MemberFunctionDeclarationSyntax = (function (_super) { + __extends(MemberFunctionDeclarationSyntax, _super); + function MemberFunctionDeclarationSyntax(modifiers, propertyName, callSignature, block, semicolonToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.modifiers = modifiers; + this.propertyName = propertyName; + this.callSignature = callSignature; + this.block = block; + this.semicolonToken = semicolonToken; + } + MemberFunctionDeclarationSyntax.prototype.accept = function (visitor) { + return visitor.visitMemberFunctionDeclaration(this); + }; + + MemberFunctionDeclarationSyntax.prototype.kind = function () { + return 135 /* MemberFunctionDeclaration */; + }; + + MemberFunctionDeclarationSyntax.prototype.childCount = function () { + return 5; + }; + + MemberFunctionDeclarationSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.modifiers; + case 1: + return this.propertyName; + case 2: + return this.callSignature; + case 3: + return this.block; + case 4: + return this.semicolonToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + MemberFunctionDeclarationSyntax.prototype.isMemberDeclaration = function () { + return true; + }; + + MemberFunctionDeclarationSyntax.prototype.isClassElement = function () { + return true; + }; + + MemberFunctionDeclarationSyntax.prototype.update = function (modifiers, propertyName, callSignature, block, semicolonToken) { + if (this.modifiers === modifiers && this.propertyName === propertyName && this.callSignature === callSignature && this.block === block && this.semicolonToken === semicolonToken) { + return this; + } + + return new MemberFunctionDeclarationSyntax(modifiers, propertyName, callSignature, block, semicolonToken, this.parsedInStrictMode()); + }; + + MemberFunctionDeclarationSyntax.create = function (propertyName, callSignature) { + return new MemberFunctionDeclarationSyntax(TypeScript.Syntax.emptyList, propertyName, callSignature, null, null, false); + }; + + MemberFunctionDeclarationSyntax.create1 = function (propertyName) { + return new MemberFunctionDeclarationSyntax(TypeScript.Syntax.emptyList, propertyName, CallSignatureSyntax.create1(), null, null, false); + }; + + MemberFunctionDeclarationSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + MemberFunctionDeclarationSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + MemberFunctionDeclarationSyntax.prototype.withModifiers = function (modifiers) { + return this.update(modifiers, this.propertyName, this.callSignature, this.block, this.semicolonToken); + }; + + MemberFunctionDeclarationSyntax.prototype.withModifier = function (modifier) { + return this.withModifiers(TypeScript.Syntax.list([modifier])); + }; + + MemberFunctionDeclarationSyntax.prototype.withPropertyName = function (propertyName) { + return this.update(this.modifiers, propertyName, this.callSignature, this.block, this.semicolonToken); + }; + + MemberFunctionDeclarationSyntax.prototype.withCallSignature = function (callSignature) { + return this.update(this.modifiers, this.propertyName, callSignature, this.block, this.semicolonToken); + }; + + MemberFunctionDeclarationSyntax.prototype.withBlock = function (block) { + return this.update(this.modifiers, this.propertyName, this.callSignature, block, this.semicolonToken); + }; + + MemberFunctionDeclarationSyntax.prototype.withSemicolonToken = function (semicolonToken) { + return this.update(this.modifiers, this.propertyName, this.callSignature, this.block, semicolonToken); + }; + + MemberFunctionDeclarationSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return MemberFunctionDeclarationSyntax; + })(TypeScript.SyntaxNode); + TypeScript.MemberFunctionDeclarationSyntax = MemberFunctionDeclarationSyntax; + + var MemberAccessorDeclarationSyntax = (function (_super) { + __extends(MemberAccessorDeclarationSyntax, _super); + function MemberAccessorDeclarationSyntax(modifiers, propertyName, parameterList, block, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.modifiers = modifiers; + this.propertyName = propertyName; + this.parameterList = parameterList; + this.block = block; + } + MemberAccessorDeclarationSyntax.prototype.isMemberDeclaration = function () { + return true; + }; + + MemberAccessorDeclarationSyntax.prototype.isClassElement = function () { + return true; + }; + + MemberAccessorDeclarationSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + MemberAccessorDeclarationSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + MemberAccessorDeclarationSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return MemberAccessorDeclarationSyntax; + })(TypeScript.SyntaxNode); + TypeScript.MemberAccessorDeclarationSyntax = MemberAccessorDeclarationSyntax; + + var GetMemberAccessorDeclarationSyntax = (function (_super) { + __extends(GetMemberAccessorDeclarationSyntax, _super); + function GetMemberAccessorDeclarationSyntax(modifiers, getKeyword, propertyName, parameterList, typeAnnotation, block, parsedInStrictMode) { + _super.call(this, modifiers, propertyName, parameterList, block, parsedInStrictMode); + this.getKeyword = getKeyword; + this.typeAnnotation = typeAnnotation; + } + GetMemberAccessorDeclarationSyntax.prototype.accept = function (visitor) { + return visitor.visitGetMemberAccessorDeclaration(this); + }; + + GetMemberAccessorDeclarationSyntax.prototype.kind = function () { + return 138 /* GetMemberAccessorDeclaration */; + }; + + GetMemberAccessorDeclarationSyntax.prototype.childCount = function () { + return 6; + }; + + GetMemberAccessorDeclarationSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.modifiers; + case 1: + return this.getKeyword; + case 2: + return this.propertyName; + case 3: + return this.parameterList; + case 4: + return this.typeAnnotation; + case 5: + return this.block; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + GetMemberAccessorDeclarationSyntax.prototype.update = function (modifiers, getKeyword, propertyName, parameterList, typeAnnotation, block) { + if (this.modifiers === modifiers && this.getKeyword === getKeyword && this.propertyName === propertyName && this.parameterList === parameterList && this.typeAnnotation === typeAnnotation && this.block === block) { + return this; + } + + return new GetMemberAccessorDeclarationSyntax(modifiers, getKeyword, propertyName, parameterList, typeAnnotation, block, this.parsedInStrictMode()); + }; + + GetMemberAccessorDeclarationSyntax.create = function (getKeyword, propertyName, parameterList, block) { + return new GetMemberAccessorDeclarationSyntax(TypeScript.Syntax.emptyList, getKeyword, propertyName, parameterList, null, block, false); + }; + + GetMemberAccessorDeclarationSyntax.create1 = function (propertyName) { + return new GetMemberAccessorDeclarationSyntax(TypeScript.Syntax.emptyList, TypeScript.Syntax.token(64 /* GetKeyword */), propertyName, ParameterListSyntax.create1(), null, BlockSyntax.create1(), false); + }; + + GetMemberAccessorDeclarationSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + GetMemberAccessorDeclarationSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + GetMemberAccessorDeclarationSyntax.prototype.withModifiers = function (modifiers) { + return this.update(modifiers, this.getKeyword, this.propertyName, this.parameterList, this.typeAnnotation, this.block); + }; + + GetMemberAccessorDeclarationSyntax.prototype.withModifier = function (modifier) { + return this.withModifiers(TypeScript.Syntax.list([modifier])); + }; + + GetMemberAccessorDeclarationSyntax.prototype.withGetKeyword = function (getKeyword) { + return this.update(this.modifiers, getKeyword, this.propertyName, this.parameterList, this.typeAnnotation, this.block); + }; + + GetMemberAccessorDeclarationSyntax.prototype.withPropertyName = function (propertyName) { + return this.update(this.modifiers, this.getKeyword, propertyName, this.parameterList, this.typeAnnotation, this.block); + }; + + GetMemberAccessorDeclarationSyntax.prototype.withParameterList = function (parameterList) { + return this.update(this.modifiers, this.getKeyword, this.propertyName, parameterList, this.typeAnnotation, this.block); + }; + + GetMemberAccessorDeclarationSyntax.prototype.withTypeAnnotation = function (typeAnnotation) { + return this.update(this.modifiers, this.getKeyword, this.propertyName, this.parameterList, typeAnnotation, this.block); + }; + + GetMemberAccessorDeclarationSyntax.prototype.withBlock = function (block) { + return this.update(this.modifiers, this.getKeyword, this.propertyName, this.parameterList, this.typeAnnotation, block); + }; + + GetMemberAccessorDeclarationSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return GetMemberAccessorDeclarationSyntax; + })(MemberAccessorDeclarationSyntax); + TypeScript.GetMemberAccessorDeclarationSyntax = GetMemberAccessorDeclarationSyntax; + + var SetMemberAccessorDeclarationSyntax = (function (_super) { + __extends(SetMemberAccessorDeclarationSyntax, _super); + function SetMemberAccessorDeclarationSyntax(modifiers, setKeyword, propertyName, parameterList, block, parsedInStrictMode) { + _super.call(this, modifiers, propertyName, parameterList, block, parsedInStrictMode); + this.setKeyword = setKeyword; + } + SetMemberAccessorDeclarationSyntax.prototype.accept = function (visitor) { + return visitor.visitSetMemberAccessorDeclaration(this); + }; + + SetMemberAccessorDeclarationSyntax.prototype.kind = function () { + return 139 /* SetMemberAccessorDeclaration */; + }; + + SetMemberAccessorDeclarationSyntax.prototype.childCount = function () { + return 5; + }; + + SetMemberAccessorDeclarationSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.modifiers; + case 1: + return this.setKeyword; + case 2: + return this.propertyName; + case 3: + return this.parameterList; + case 4: + return this.block; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + SetMemberAccessorDeclarationSyntax.prototype.update = function (modifiers, setKeyword, propertyName, parameterList, block) { + if (this.modifiers === modifiers && this.setKeyword === setKeyword && this.propertyName === propertyName && this.parameterList === parameterList && this.block === block) { + return this; + } + + return new SetMemberAccessorDeclarationSyntax(modifiers, setKeyword, propertyName, parameterList, block, this.parsedInStrictMode()); + }; + + SetMemberAccessorDeclarationSyntax.create = function (setKeyword, propertyName, parameterList, block) { + return new SetMemberAccessorDeclarationSyntax(TypeScript.Syntax.emptyList, setKeyword, propertyName, parameterList, block, false); + }; + + SetMemberAccessorDeclarationSyntax.create1 = function (propertyName) { + return new SetMemberAccessorDeclarationSyntax(TypeScript.Syntax.emptyList, TypeScript.Syntax.token(68 /* SetKeyword */), propertyName, ParameterListSyntax.create1(), BlockSyntax.create1(), false); + }; + + SetMemberAccessorDeclarationSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + SetMemberAccessorDeclarationSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + SetMemberAccessorDeclarationSyntax.prototype.withModifiers = function (modifiers) { + return this.update(modifiers, this.setKeyword, this.propertyName, this.parameterList, this.block); + }; + + SetMemberAccessorDeclarationSyntax.prototype.withModifier = function (modifier) { + return this.withModifiers(TypeScript.Syntax.list([modifier])); + }; + + SetMemberAccessorDeclarationSyntax.prototype.withSetKeyword = function (setKeyword) { + return this.update(this.modifiers, setKeyword, this.propertyName, this.parameterList, this.block); + }; + + SetMemberAccessorDeclarationSyntax.prototype.withPropertyName = function (propertyName) { + return this.update(this.modifiers, this.setKeyword, propertyName, this.parameterList, this.block); + }; + + SetMemberAccessorDeclarationSyntax.prototype.withParameterList = function (parameterList) { + return this.update(this.modifiers, this.setKeyword, this.propertyName, parameterList, this.block); + }; + + SetMemberAccessorDeclarationSyntax.prototype.withBlock = function (block) { + return this.update(this.modifiers, this.setKeyword, this.propertyName, this.parameterList, block); + }; + + SetMemberAccessorDeclarationSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return SetMemberAccessorDeclarationSyntax; + })(MemberAccessorDeclarationSyntax); + TypeScript.SetMemberAccessorDeclarationSyntax = SetMemberAccessorDeclarationSyntax; + + var MemberVariableDeclarationSyntax = (function (_super) { + __extends(MemberVariableDeclarationSyntax, _super); + function MemberVariableDeclarationSyntax(modifiers, variableDeclarator, semicolonToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.modifiers = modifiers; + this.variableDeclarator = variableDeclarator; + this.semicolonToken = semicolonToken; + } + MemberVariableDeclarationSyntax.prototype.accept = function (visitor) { + return visitor.visitMemberVariableDeclaration(this); + }; + + MemberVariableDeclarationSyntax.prototype.kind = function () { + return 136 /* MemberVariableDeclaration */; + }; + + MemberVariableDeclarationSyntax.prototype.childCount = function () { + return 3; + }; + + MemberVariableDeclarationSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.modifiers; + case 1: + return this.variableDeclarator; + case 2: + return this.semicolonToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + MemberVariableDeclarationSyntax.prototype.isMemberDeclaration = function () { + return true; + }; + + MemberVariableDeclarationSyntax.prototype.isClassElement = function () { + return true; + }; + + MemberVariableDeclarationSyntax.prototype.update = function (modifiers, variableDeclarator, semicolonToken) { + if (this.modifiers === modifiers && this.variableDeclarator === variableDeclarator && this.semicolonToken === semicolonToken) { + return this; + } + + return new MemberVariableDeclarationSyntax(modifiers, variableDeclarator, semicolonToken, this.parsedInStrictMode()); + }; + + MemberVariableDeclarationSyntax.create = function (variableDeclarator, semicolonToken) { + return new MemberVariableDeclarationSyntax(TypeScript.Syntax.emptyList, variableDeclarator, semicolonToken, false); + }; + + MemberVariableDeclarationSyntax.create1 = function (variableDeclarator) { + return new MemberVariableDeclarationSyntax(TypeScript.Syntax.emptyList, variableDeclarator, TypeScript.Syntax.token(78 /* SemicolonToken */), false); + }; + + MemberVariableDeclarationSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + MemberVariableDeclarationSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + MemberVariableDeclarationSyntax.prototype.withModifiers = function (modifiers) { + return this.update(modifiers, this.variableDeclarator, this.semicolonToken); + }; + + MemberVariableDeclarationSyntax.prototype.withModifier = function (modifier) { + return this.withModifiers(TypeScript.Syntax.list([modifier])); + }; + + MemberVariableDeclarationSyntax.prototype.withVariableDeclarator = function (variableDeclarator) { + return this.update(this.modifiers, variableDeclarator, this.semicolonToken); + }; + + MemberVariableDeclarationSyntax.prototype.withSemicolonToken = function (semicolonToken) { + return this.update(this.modifiers, this.variableDeclarator, semicolonToken); + }; + + MemberVariableDeclarationSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return MemberVariableDeclarationSyntax; + })(TypeScript.SyntaxNode); + TypeScript.MemberVariableDeclarationSyntax = MemberVariableDeclarationSyntax; + + var ThrowStatementSyntax = (function (_super) { + __extends(ThrowStatementSyntax, _super); + function ThrowStatementSyntax(throwKeyword, expression, semicolonToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.throwKeyword = throwKeyword; + this.expression = expression; + this.semicolonToken = semicolonToken; + } + ThrowStatementSyntax.prototype.accept = function (visitor) { + return visitor.visitThrowStatement(this); + }; + + ThrowStatementSyntax.prototype.kind = function () { + return 156 /* ThrowStatement */; + }; + + ThrowStatementSyntax.prototype.childCount = function () { + return 3; + }; + + ThrowStatementSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.throwKeyword; + case 1: + return this.expression; + case 2: + return this.semicolonToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ThrowStatementSyntax.prototype.isStatement = function () { + return true; + }; + + ThrowStatementSyntax.prototype.isModuleElement = function () { + return true; + }; + + ThrowStatementSyntax.prototype.update = function (throwKeyword, expression, semicolonToken) { + if (this.throwKeyword === throwKeyword && this.expression === expression && this.semicolonToken === semicolonToken) { + return this; + } + + return new ThrowStatementSyntax(throwKeyword, expression, semicolonToken, this.parsedInStrictMode()); + }; + + ThrowStatementSyntax.create1 = function (expression) { + return new ThrowStatementSyntax(TypeScript.Syntax.token(36 /* ThrowKeyword */), expression, TypeScript.Syntax.token(78 /* SemicolonToken */), false); + }; + + ThrowStatementSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ThrowStatementSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ThrowStatementSyntax.prototype.withThrowKeyword = function (throwKeyword) { + return this.update(throwKeyword, this.expression, this.semicolonToken); + }; + + ThrowStatementSyntax.prototype.withExpression = function (expression) { + return this.update(this.throwKeyword, expression, this.semicolonToken); + }; + + ThrowStatementSyntax.prototype.withSemicolonToken = function (semicolonToken) { + return this.update(this.throwKeyword, this.expression, semicolonToken); + }; + + ThrowStatementSyntax.prototype.isTypeScriptSpecific = function () { + if (this.expression.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return ThrowStatementSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ThrowStatementSyntax = ThrowStatementSyntax; + + var ReturnStatementSyntax = (function (_super) { + __extends(ReturnStatementSyntax, _super); + function ReturnStatementSyntax(returnKeyword, expression, semicolonToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.returnKeyword = returnKeyword; + this.expression = expression; + this.semicolonToken = semicolonToken; + } + ReturnStatementSyntax.prototype.accept = function (visitor) { + return visitor.visitReturnStatement(this); + }; + + ReturnStatementSyntax.prototype.kind = function () { + return 149 /* ReturnStatement */; + }; + + ReturnStatementSyntax.prototype.childCount = function () { + return 3; + }; + + ReturnStatementSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.returnKeyword; + case 1: + return this.expression; + case 2: + return this.semicolonToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ReturnStatementSyntax.prototype.isStatement = function () { + return true; + }; + + ReturnStatementSyntax.prototype.isModuleElement = function () { + return true; + }; + + ReturnStatementSyntax.prototype.update = function (returnKeyword, expression, semicolonToken) { + if (this.returnKeyword === returnKeyword && this.expression === expression && this.semicolonToken === semicolonToken) { + return this; + } + + return new ReturnStatementSyntax(returnKeyword, expression, semicolonToken, this.parsedInStrictMode()); + }; + + ReturnStatementSyntax.create = function (returnKeyword, semicolonToken) { + return new ReturnStatementSyntax(returnKeyword, null, semicolonToken, false); + }; + + ReturnStatementSyntax.create1 = function () { + return new ReturnStatementSyntax(TypeScript.Syntax.token(33 /* ReturnKeyword */), null, TypeScript.Syntax.token(78 /* SemicolonToken */), false); + }; + + ReturnStatementSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ReturnStatementSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ReturnStatementSyntax.prototype.withReturnKeyword = function (returnKeyword) { + return this.update(returnKeyword, this.expression, this.semicolonToken); + }; + + ReturnStatementSyntax.prototype.withExpression = function (expression) { + return this.update(this.returnKeyword, expression, this.semicolonToken); + }; + + ReturnStatementSyntax.prototype.withSemicolonToken = function (semicolonToken) { + return this.update(this.returnKeyword, this.expression, semicolonToken); + }; + + ReturnStatementSyntax.prototype.isTypeScriptSpecific = function () { + if (this.expression !== null && this.expression.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return ReturnStatementSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ReturnStatementSyntax = ReturnStatementSyntax; + + var ObjectCreationExpressionSyntax = (function (_super) { + __extends(ObjectCreationExpressionSyntax, _super); + function ObjectCreationExpressionSyntax(newKeyword, expression, argumentList, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.newKeyword = newKeyword; + this.expression = expression; + this.argumentList = argumentList; + } + ObjectCreationExpressionSyntax.prototype.accept = function (visitor) { + return visitor.visitObjectCreationExpression(this); + }; + + ObjectCreationExpressionSyntax.prototype.kind = function () { + return 215 /* ObjectCreationExpression */; + }; + + ObjectCreationExpressionSyntax.prototype.childCount = function () { + return 3; + }; + + ObjectCreationExpressionSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.newKeyword; + case 1: + return this.expression; + case 2: + return this.argumentList; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ObjectCreationExpressionSyntax.prototype.isUnaryExpression = function () { + return true; + }; + + ObjectCreationExpressionSyntax.prototype.isExpression = function () { + return true; + }; + + ObjectCreationExpressionSyntax.prototype.update = function (newKeyword, expression, argumentList) { + if (this.newKeyword === newKeyword && this.expression === expression && this.argumentList === argumentList) { + return this; + } + + return new ObjectCreationExpressionSyntax(newKeyword, expression, argumentList, this.parsedInStrictMode()); + }; + + ObjectCreationExpressionSyntax.create = function (newKeyword, expression) { + return new ObjectCreationExpressionSyntax(newKeyword, expression, null, false); + }; + + ObjectCreationExpressionSyntax.create1 = function (expression) { + return new ObjectCreationExpressionSyntax(TypeScript.Syntax.token(31 /* NewKeyword */), expression, null, false); + }; + + ObjectCreationExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ObjectCreationExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ObjectCreationExpressionSyntax.prototype.withNewKeyword = function (newKeyword) { + return this.update(newKeyword, this.expression, this.argumentList); + }; + + ObjectCreationExpressionSyntax.prototype.withExpression = function (expression) { + return this.update(this.newKeyword, expression, this.argumentList); + }; + + ObjectCreationExpressionSyntax.prototype.withArgumentList = function (argumentList) { + return this.update(this.newKeyword, this.expression, argumentList); + }; + + ObjectCreationExpressionSyntax.prototype.isTypeScriptSpecific = function () { + if (this.expression.isTypeScriptSpecific()) { + return true; + } + if (this.argumentList !== null && this.argumentList.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return ObjectCreationExpressionSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ObjectCreationExpressionSyntax = ObjectCreationExpressionSyntax; + + var SwitchStatementSyntax = (function (_super) { + __extends(SwitchStatementSyntax, _super); + function SwitchStatementSyntax(switchKeyword, openParenToken, expression, closeParenToken, openBraceToken, switchClauses, closeBraceToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.switchKeyword = switchKeyword; + this.openParenToken = openParenToken; + this.expression = expression; + this.closeParenToken = closeParenToken; + this.openBraceToken = openBraceToken; + this.switchClauses = switchClauses; + this.closeBraceToken = closeBraceToken; + } + SwitchStatementSyntax.prototype.accept = function (visitor) { + return visitor.visitSwitchStatement(this); + }; + + SwitchStatementSyntax.prototype.kind = function () { + return 150 /* SwitchStatement */; + }; + + SwitchStatementSyntax.prototype.childCount = function () { + return 7; + }; + + SwitchStatementSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.switchKeyword; + case 1: + return this.openParenToken; + case 2: + return this.expression; + case 3: + return this.closeParenToken; + case 4: + return this.openBraceToken; + case 5: + return this.switchClauses; + case 6: + return this.closeBraceToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + SwitchStatementSyntax.prototype.isStatement = function () { + return true; + }; + + SwitchStatementSyntax.prototype.isModuleElement = function () { + return true; + }; + + SwitchStatementSyntax.prototype.update = function (switchKeyword, openParenToken, expression, closeParenToken, openBraceToken, switchClauses, closeBraceToken) { + if (this.switchKeyword === switchKeyword && this.openParenToken === openParenToken && this.expression === expression && this.closeParenToken === closeParenToken && this.openBraceToken === openBraceToken && this.switchClauses === switchClauses && this.closeBraceToken === closeBraceToken) { + return this; + } + + return new SwitchStatementSyntax(switchKeyword, openParenToken, expression, closeParenToken, openBraceToken, switchClauses, closeBraceToken, this.parsedInStrictMode()); + }; + + SwitchStatementSyntax.create = function (switchKeyword, openParenToken, expression, closeParenToken, openBraceToken, closeBraceToken) { + return new SwitchStatementSyntax(switchKeyword, openParenToken, expression, closeParenToken, openBraceToken, TypeScript.Syntax.emptyList, closeBraceToken, false); + }; + + SwitchStatementSyntax.create1 = function (expression) { + return new SwitchStatementSyntax(TypeScript.Syntax.token(34 /* SwitchKeyword */), TypeScript.Syntax.token(72 /* OpenParenToken */), expression, TypeScript.Syntax.token(73 /* CloseParenToken */), TypeScript.Syntax.token(70 /* OpenBraceToken */), TypeScript.Syntax.emptyList, TypeScript.Syntax.token(71 /* CloseBraceToken */), false); + }; + + SwitchStatementSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + SwitchStatementSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + SwitchStatementSyntax.prototype.withSwitchKeyword = function (switchKeyword) { + return this.update(switchKeyword, this.openParenToken, this.expression, this.closeParenToken, this.openBraceToken, this.switchClauses, this.closeBraceToken); + }; + + SwitchStatementSyntax.prototype.withOpenParenToken = function (openParenToken) { + return this.update(this.switchKeyword, openParenToken, this.expression, this.closeParenToken, this.openBraceToken, this.switchClauses, this.closeBraceToken); + }; + + SwitchStatementSyntax.prototype.withExpression = function (expression) { + return this.update(this.switchKeyword, this.openParenToken, expression, this.closeParenToken, this.openBraceToken, this.switchClauses, this.closeBraceToken); + }; + + SwitchStatementSyntax.prototype.withCloseParenToken = function (closeParenToken) { + return this.update(this.switchKeyword, this.openParenToken, this.expression, closeParenToken, this.openBraceToken, this.switchClauses, this.closeBraceToken); + }; + + SwitchStatementSyntax.prototype.withOpenBraceToken = function (openBraceToken) { + return this.update(this.switchKeyword, this.openParenToken, this.expression, this.closeParenToken, openBraceToken, this.switchClauses, this.closeBraceToken); + }; + + SwitchStatementSyntax.prototype.withSwitchClauses = function (switchClauses) { + return this.update(this.switchKeyword, this.openParenToken, this.expression, this.closeParenToken, this.openBraceToken, switchClauses, this.closeBraceToken); + }; + + SwitchStatementSyntax.prototype.withSwitchClause = function (switchClause) { + return this.withSwitchClauses(TypeScript.Syntax.list([switchClause])); + }; + + SwitchStatementSyntax.prototype.withCloseBraceToken = function (closeBraceToken) { + return this.update(this.switchKeyword, this.openParenToken, this.expression, this.closeParenToken, this.openBraceToken, this.switchClauses, closeBraceToken); + }; + + SwitchStatementSyntax.prototype.isTypeScriptSpecific = function () { + if (this.expression.isTypeScriptSpecific()) { + return true; + } + if (this.switchClauses.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return SwitchStatementSyntax; + })(TypeScript.SyntaxNode); + TypeScript.SwitchStatementSyntax = SwitchStatementSyntax; + + var SwitchClauseSyntax = (function (_super) { + __extends(SwitchClauseSyntax, _super); + function SwitchClauseSyntax(colonToken, statements, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.colonToken = colonToken; + this.statements = statements; + } + SwitchClauseSyntax.prototype.isSwitchClause = function () { + return true; + }; + + SwitchClauseSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + SwitchClauseSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + SwitchClauseSyntax.prototype.isTypeScriptSpecific = function () { + return false; + }; + return SwitchClauseSyntax; + })(TypeScript.SyntaxNode); + TypeScript.SwitchClauseSyntax = SwitchClauseSyntax; + + var CaseSwitchClauseSyntax = (function (_super) { + __extends(CaseSwitchClauseSyntax, _super); + function CaseSwitchClauseSyntax(caseKeyword, expression, colonToken, statements, parsedInStrictMode) { + _super.call(this, colonToken, statements, parsedInStrictMode); + this.caseKeyword = caseKeyword; + this.expression = expression; + } + CaseSwitchClauseSyntax.prototype.accept = function (visitor) { + return visitor.visitCaseSwitchClause(this); + }; + + CaseSwitchClauseSyntax.prototype.kind = function () { + return 231 /* CaseSwitchClause */; + }; + + CaseSwitchClauseSyntax.prototype.childCount = function () { + return 4; + }; + + CaseSwitchClauseSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.caseKeyword; + case 1: + return this.expression; + case 2: + return this.colonToken; + case 3: + return this.statements; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + CaseSwitchClauseSyntax.prototype.update = function (caseKeyword, expression, colonToken, statements) { + if (this.caseKeyword === caseKeyword && this.expression === expression && this.colonToken === colonToken && this.statements === statements) { + return this; + } + + return new CaseSwitchClauseSyntax(caseKeyword, expression, colonToken, statements, this.parsedInStrictMode()); + }; + + CaseSwitchClauseSyntax.create = function (caseKeyword, expression, colonToken) { + return new CaseSwitchClauseSyntax(caseKeyword, expression, colonToken, TypeScript.Syntax.emptyList, false); + }; + + CaseSwitchClauseSyntax.create1 = function (expression) { + return new CaseSwitchClauseSyntax(TypeScript.Syntax.token(16 /* CaseKeyword */), expression, TypeScript.Syntax.token(106 /* ColonToken */), TypeScript.Syntax.emptyList, false); + }; + + CaseSwitchClauseSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + CaseSwitchClauseSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + CaseSwitchClauseSyntax.prototype.withCaseKeyword = function (caseKeyword) { + return this.update(caseKeyword, this.expression, this.colonToken, this.statements); + }; + + CaseSwitchClauseSyntax.prototype.withExpression = function (expression) { + return this.update(this.caseKeyword, expression, this.colonToken, this.statements); + }; + + CaseSwitchClauseSyntax.prototype.withColonToken = function (colonToken) { + return this.update(this.caseKeyword, this.expression, colonToken, this.statements); + }; + + CaseSwitchClauseSyntax.prototype.withStatements = function (statements) { + return this.update(this.caseKeyword, this.expression, this.colonToken, statements); + }; + + CaseSwitchClauseSyntax.prototype.withStatement = function (statement) { + return this.withStatements(TypeScript.Syntax.list([statement])); + }; + + CaseSwitchClauseSyntax.prototype.isTypeScriptSpecific = function () { + if (this.expression.isTypeScriptSpecific()) { + return true; + } + if (this.statements.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return CaseSwitchClauseSyntax; + })(SwitchClauseSyntax); + TypeScript.CaseSwitchClauseSyntax = CaseSwitchClauseSyntax; + + var DefaultSwitchClauseSyntax = (function (_super) { + __extends(DefaultSwitchClauseSyntax, _super); + function DefaultSwitchClauseSyntax(defaultKeyword, colonToken, statements, parsedInStrictMode) { + _super.call(this, colonToken, statements, parsedInStrictMode); + this.defaultKeyword = defaultKeyword; + } + DefaultSwitchClauseSyntax.prototype.accept = function (visitor) { + return visitor.visitDefaultSwitchClause(this); + }; + + DefaultSwitchClauseSyntax.prototype.kind = function () { + return 232 /* DefaultSwitchClause */; + }; + + DefaultSwitchClauseSyntax.prototype.childCount = function () { + return 3; + }; + + DefaultSwitchClauseSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.defaultKeyword; + case 1: + return this.colonToken; + case 2: + return this.statements; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + DefaultSwitchClauseSyntax.prototype.update = function (defaultKeyword, colonToken, statements) { + if (this.defaultKeyword === defaultKeyword && this.colonToken === colonToken && this.statements === statements) { + return this; + } + + return new DefaultSwitchClauseSyntax(defaultKeyword, colonToken, statements, this.parsedInStrictMode()); + }; + + DefaultSwitchClauseSyntax.create = function (defaultKeyword, colonToken) { + return new DefaultSwitchClauseSyntax(defaultKeyword, colonToken, TypeScript.Syntax.emptyList, false); + }; + + DefaultSwitchClauseSyntax.create1 = function () { + return new DefaultSwitchClauseSyntax(TypeScript.Syntax.token(20 /* DefaultKeyword */), TypeScript.Syntax.token(106 /* ColonToken */), TypeScript.Syntax.emptyList, false); + }; + + DefaultSwitchClauseSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + DefaultSwitchClauseSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + DefaultSwitchClauseSyntax.prototype.withDefaultKeyword = function (defaultKeyword) { + return this.update(defaultKeyword, this.colonToken, this.statements); + }; + + DefaultSwitchClauseSyntax.prototype.withColonToken = function (colonToken) { + return this.update(this.defaultKeyword, colonToken, this.statements); + }; + + DefaultSwitchClauseSyntax.prototype.withStatements = function (statements) { + return this.update(this.defaultKeyword, this.colonToken, statements); + }; + + DefaultSwitchClauseSyntax.prototype.withStatement = function (statement) { + return this.withStatements(TypeScript.Syntax.list([statement])); + }; + + DefaultSwitchClauseSyntax.prototype.isTypeScriptSpecific = function () { + if (this.statements.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return DefaultSwitchClauseSyntax; + })(SwitchClauseSyntax); + TypeScript.DefaultSwitchClauseSyntax = DefaultSwitchClauseSyntax; + + var BreakStatementSyntax = (function (_super) { + __extends(BreakStatementSyntax, _super); + function BreakStatementSyntax(breakKeyword, identifier, semicolonToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.breakKeyword = breakKeyword; + this.identifier = identifier; + this.semicolonToken = semicolonToken; + } + BreakStatementSyntax.prototype.accept = function (visitor) { + return visitor.visitBreakStatement(this); + }; + + BreakStatementSyntax.prototype.kind = function () { + return 151 /* BreakStatement */; + }; + + BreakStatementSyntax.prototype.childCount = function () { + return 3; + }; + + BreakStatementSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.breakKeyword; + case 1: + return this.identifier; + case 2: + return this.semicolonToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + BreakStatementSyntax.prototype.isStatement = function () { + return true; + }; + + BreakStatementSyntax.prototype.isModuleElement = function () { + return true; + }; + + BreakStatementSyntax.prototype.update = function (breakKeyword, identifier, semicolonToken) { + if (this.breakKeyword === breakKeyword && this.identifier === identifier && this.semicolonToken === semicolonToken) { + return this; + } + + return new BreakStatementSyntax(breakKeyword, identifier, semicolonToken, this.parsedInStrictMode()); + }; + + BreakStatementSyntax.create = function (breakKeyword, semicolonToken) { + return new BreakStatementSyntax(breakKeyword, null, semicolonToken, false); + }; + + BreakStatementSyntax.create1 = function () { + return new BreakStatementSyntax(TypeScript.Syntax.token(15 /* BreakKeyword */), null, TypeScript.Syntax.token(78 /* SemicolonToken */), false); + }; + + BreakStatementSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + BreakStatementSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + BreakStatementSyntax.prototype.withBreakKeyword = function (breakKeyword) { + return this.update(breakKeyword, this.identifier, this.semicolonToken); + }; + + BreakStatementSyntax.prototype.withIdentifier = function (identifier) { + return this.update(this.breakKeyword, identifier, this.semicolonToken); + }; + + BreakStatementSyntax.prototype.withSemicolonToken = function (semicolonToken) { + return this.update(this.breakKeyword, this.identifier, semicolonToken); + }; + + BreakStatementSyntax.prototype.isTypeScriptSpecific = function () { + return false; + }; + return BreakStatementSyntax; + })(TypeScript.SyntaxNode); + TypeScript.BreakStatementSyntax = BreakStatementSyntax; + + var ContinueStatementSyntax = (function (_super) { + __extends(ContinueStatementSyntax, _super); + function ContinueStatementSyntax(continueKeyword, identifier, semicolonToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.continueKeyword = continueKeyword; + this.identifier = identifier; + this.semicolonToken = semicolonToken; + } + ContinueStatementSyntax.prototype.accept = function (visitor) { + return visitor.visitContinueStatement(this); + }; + + ContinueStatementSyntax.prototype.kind = function () { + return 152 /* ContinueStatement */; + }; + + ContinueStatementSyntax.prototype.childCount = function () { + return 3; + }; + + ContinueStatementSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.continueKeyword; + case 1: + return this.identifier; + case 2: + return this.semicolonToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ContinueStatementSyntax.prototype.isStatement = function () { + return true; + }; + + ContinueStatementSyntax.prototype.isModuleElement = function () { + return true; + }; + + ContinueStatementSyntax.prototype.update = function (continueKeyword, identifier, semicolonToken) { + if (this.continueKeyword === continueKeyword && this.identifier === identifier && this.semicolonToken === semicolonToken) { + return this; + } + + return new ContinueStatementSyntax(continueKeyword, identifier, semicolonToken, this.parsedInStrictMode()); + }; + + ContinueStatementSyntax.create = function (continueKeyword, semicolonToken) { + return new ContinueStatementSyntax(continueKeyword, null, semicolonToken, false); + }; + + ContinueStatementSyntax.create1 = function () { + return new ContinueStatementSyntax(TypeScript.Syntax.token(18 /* ContinueKeyword */), null, TypeScript.Syntax.token(78 /* SemicolonToken */), false); + }; + + ContinueStatementSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ContinueStatementSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ContinueStatementSyntax.prototype.withContinueKeyword = function (continueKeyword) { + return this.update(continueKeyword, this.identifier, this.semicolonToken); + }; + + ContinueStatementSyntax.prototype.withIdentifier = function (identifier) { + return this.update(this.continueKeyword, identifier, this.semicolonToken); + }; + + ContinueStatementSyntax.prototype.withSemicolonToken = function (semicolonToken) { + return this.update(this.continueKeyword, this.identifier, semicolonToken); + }; + + ContinueStatementSyntax.prototype.isTypeScriptSpecific = function () { + return false; + }; + return ContinueStatementSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ContinueStatementSyntax = ContinueStatementSyntax; + + var IterationStatementSyntax = (function (_super) { + __extends(IterationStatementSyntax, _super); + function IterationStatementSyntax(openParenToken, closeParenToken, statement, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.openParenToken = openParenToken; + this.closeParenToken = closeParenToken; + this.statement = statement; + } + IterationStatementSyntax.prototype.isStatement = function () { + return true; + }; + + IterationStatementSyntax.prototype.isModuleElement = function () { + return true; + }; + + IterationStatementSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + IterationStatementSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + IterationStatementSyntax.prototype.isTypeScriptSpecific = function () { + return false; + }; + return IterationStatementSyntax; + })(TypeScript.SyntaxNode); + TypeScript.IterationStatementSyntax = IterationStatementSyntax; + + var BaseForStatementSyntax = (function (_super) { + __extends(BaseForStatementSyntax, _super); + function BaseForStatementSyntax(forKeyword, openParenToken, variableDeclaration, closeParenToken, statement, parsedInStrictMode) { + _super.call(this, openParenToken, closeParenToken, statement, parsedInStrictMode); + this.forKeyword = forKeyword; + this.variableDeclaration = variableDeclaration; + } + BaseForStatementSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + BaseForStatementSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + BaseForStatementSyntax.prototype.isTypeScriptSpecific = function () { + return false; + }; + return BaseForStatementSyntax; + })(IterationStatementSyntax); + TypeScript.BaseForStatementSyntax = BaseForStatementSyntax; + + var ForStatementSyntax = (function (_super) { + __extends(ForStatementSyntax, _super); + function ForStatementSyntax(forKeyword, openParenToken, variableDeclaration, initializer, firstSemicolonToken, condition, secondSemicolonToken, incrementor, closeParenToken, statement, parsedInStrictMode) { + _super.call(this, forKeyword, openParenToken, variableDeclaration, closeParenToken, statement, parsedInStrictMode); + this.initializer = initializer; + this.firstSemicolonToken = firstSemicolonToken; + this.condition = condition; + this.secondSemicolonToken = secondSemicolonToken; + this.incrementor = incrementor; + } + ForStatementSyntax.prototype.accept = function (visitor) { + return visitor.visitForStatement(this); + }; + + ForStatementSyntax.prototype.kind = function () { + return 153 /* ForStatement */; + }; + + ForStatementSyntax.prototype.childCount = function () { + return 10; + }; + + ForStatementSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.forKeyword; + case 1: + return this.openParenToken; + case 2: + return this.variableDeclaration; + case 3: + return this.initializer; + case 4: + return this.firstSemicolonToken; + case 5: + return this.condition; + case 6: + return this.secondSemicolonToken; + case 7: + return this.incrementor; + case 8: + return this.closeParenToken; + case 9: + return this.statement; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ForStatementSyntax.prototype.update = function (forKeyword, openParenToken, variableDeclaration, initializer, firstSemicolonToken, condition, secondSemicolonToken, incrementor, closeParenToken, statement) { + if (this.forKeyword === forKeyword && this.openParenToken === openParenToken && this.variableDeclaration === variableDeclaration && this.initializer === initializer && this.firstSemicolonToken === firstSemicolonToken && this.condition === condition && this.secondSemicolonToken === secondSemicolonToken && this.incrementor === incrementor && this.closeParenToken === closeParenToken && this.statement === statement) { + return this; + } + + return new ForStatementSyntax(forKeyword, openParenToken, variableDeclaration, initializer, firstSemicolonToken, condition, secondSemicolonToken, incrementor, closeParenToken, statement, this.parsedInStrictMode()); + }; + + ForStatementSyntax.create = function (forKeyword, openParenToken, firstSemicolonToken, secondSemicolonToken, closeParenToken, statement) { + return new ForStatementSyntax(forKeyword, openParenToken, null, null, firstSemicolonToken, null, secondSemicolonToken, null, closeParenToken, statement, false); + }; + + ForStatementSyntax.create1 = function (statement) { + return new ForStatementSyntax(TypeScript.Syntax.token(26 /* ForKeyword */), TypeScript.Syntax.token(72 /* OpenParenToken */), null, null, TypeScript.Syntax.token(78 /* SemicolonToken */), null, TypeScript.Syntax.token(78 /* SemicolonToken */), null, TypeScript.Syntax.token(73 /* CloseParenToken */), statement, false); + }; + + ForStatementSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ForStatementSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ForStatementSyntax.prototype.withForKeyword = function (forKeyword) { + return this.update(forKeyword, this.openParenToken, this.variableDeclaration, this.initializer, this.firstSemicolonToken, this.condition, this.secondSemicolonToken, this.incrementor, this.closeParenToken, this.statement); + }; + + ForStatementSyntax.prototype.withOpenParenToken = function (openParenToken) { + return this.update(this.forKeyword, openParenToken, this.variableDeclaration, this.initializer, this.firstSemicolonToken, this.condition, this.secondSemicolonToken, this.incrementor, this.closeParenToken, this.statement); + }; + + ForStatementSyntax.prototype.withVariableDeclaration = function (variableDeclaration) { + return this.update(this.forKeyword, this.openParenToken, variableDeclaration, this.initializer, this.firstSemicolonToken, this.condition, this.secondSemicolonToken, this.incrementor, this.closeParenToken, this.statement); + }; + + ForStatementSyntax.prototype.withInitializer = function (initializer) { + return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, initializer, this.firstSemicolonToken, this.condition, this.secondSemicolonToken, this.incrementor, this.closeParenToken, this.statement); + }; + + ForStatementSyntax.prototype.withFirstSemicolonToken = function (firstSemicolonToken) { + return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, this.initializer, firstSemicolonToken, this.condition, this.secondSemicolonToken, this.incrementor, this.closeParenToken, this.statement); + }; + + ForStatementSyntax.prototype.withCondition = function (condition) { + return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, this.initializer, this.firstSemicolonToken, condition, this.secondSemicolonToken, this.incrementor, this.closeParenToken, this.statement); + }; + + ForStatementSyntax.prototype.withSecondSemicolonToken = function (secondSemicolonToken) { + return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, this.initializer, this.firstSemicolonToken, this.condition, secondSemicolonToken, this.incrementor, this.closeParenToken, this.statement); + }; + + ForStatementSyntax.prototype.withIncrementor = function (incrementor) { + return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, this.initializer, this.firstSemicolonToken, this.condition, this.secondSemicolonToken, incrementor, this.closeParenToken, this.statement); + }; + + ForStatementSyntax.prototype.withCloseParenToken = function (closeParenToken) { + return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, this.initializer, this.firstSemicolonToken, this.condition, this.secondSemicolonToken, this.incrementor, closeParenToken, this.statement); + }; + + ForStatementSyntax.prototype.withStatement = function (statement) { + return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, this.initializer, this.firstSemicolonToken, this.condition, this.secondSemicolonToken, this.incrementor, this.closeParenToken, statement); + }; + + ForStatementSyntax.prototype.isTypeScriptSpecific = function () { + if (this.variableDeclaration !== null && this.variableDeclaration.isTypeScriptSpecific()) { + return true; + } + if (this.initializer !== null && this.initializer.isTypeScriptSpecific()) { + return true; + } + if (this.condition !== null && this.condition.isTypeScriptSpecific()) { + return true; + } + if (this.incrementor !== null && this.incrementor.isTypeScriptSpecific()) { + return true; + } + if (this.statement.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return ForStatementSyntax; + })(BaseForStatementSyntax); + TypeScript.ForStatementSyntax = ForStatementSyntax; + + var ForInStatementSyntax = (function (_super) { + __extends(ForInStatementSyntax, _super); + function ForInStatementSyntax(forKeyword, openParenToken, variableDeclaration, left, inKeyword, expression, closeParenToken, statement, parsedInStrictMode) { + _super.call(this, forKeyword, openParenToken, variableDeclaration, closeParenToken, statement, parsedInStrictMode); + this.left = left; + this.inKeyword = inKeyword; + this.expression = expression; + } + ForInStatementSyntax.prototype.accept = function (visitor) { + return visitor.visitForInStatement(this); + }; + + ForInStatementSyntax.prototype.kind = function () { + return 154 /* ForInStatement */; + }; + + ForInStatementSyntax.prototype.childCount = function () { + return 8; + }; + + ForInStatementSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.forKeyword; + case 1: + return this.openParenToken; + case 2: + return this.variableDeclaration; + case 3: + return this.left; + case 4: + return this.inKeyword; + case 5: + return this.expression; + case 6: + return this.closeParenToken; + case 7: + return this.statement; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ForInStatementSyntax.prototype.update = function (forKeyword, openParenToken, variableDeclaration, left, inKeyword, expression, closeParenToken, statement) { + if (this.forKeyword === forKeyword && this.openParenToken === openParenToken && this.variableDeclaration === variableDeclaration && this.left === left && this.inKeyword === inKeyword && this.expression === expression && this.closeParenToken === closeParenToken && this.statement === statement) { + return this; + } + + return new ForInStatementSyntax(forKeyword, openParenToken, variableDeclaration, left, inKeyword, expression, closeParenToken, statement, this.parsedInStrictMode()); + }; + + ForInStatementSyntax.create = function (forKeyword, openParenToken, inKeyword, expression, closeParenToken, statement) { + return new ForInStatementSyntax(forKeyword, openParenToken, null, null, inKeyword, expression, closeParenToken, statement, false); + }; + + ForInStatementSyntax.create1 = function (expression, statement) { + return new ForInStatementSyntax(TypeScript.Syntax.token(26 /* ForKeyword */), TypeScript.Syntax.token(72 /* OpenParenToken */), null, null, TypeScript.Syntax.token(29 /* InKeyword */), expression, TypeScript.Syntax.token(73 /* CloseParenToken */), statement, false); + }; + + ForInStatementSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ForInStatementSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ForInStatementSyntax.prototype.withForKeyword = function (forKeyword) { + return this.update(forKeyword, this.openParenToken, this.variableDeclaration, this.left, this.inKeyword, this.expression, this.closeParenToken, this.statement); + }; + + ForInStatementSyntax.prototype.withOpenParenToken = function (openParenToken) { + return this.update(this.forKeyword, openParenToken, this.variableDeclaration, this.left, this.inKeyword, this.expression, this.closeParenToken, this.statement); + }; + + ForInStatementSyntax.prototype.withVariableDeclaration = function (variableDeclaration) { + return this.update(this.forKeyword, this.openParenToken, variableDeclaration, this.left, this.inKeyword, this.expression, this.closeParenToken, this.statement); + }; + + ForInStatementSyntax.prototype.withLeft = function (left) { + return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, left, this.inKeyword, this.expression, this.closeParenToken, this.statement); + }; + + ForInStatementSyntax.prototype.withInKeyword = function (inKeyword) { + return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, this.left, inKeyword, this.expression, this.closeParenToken, this.statement); + }; + + ForInStatementSyntax.prototype.withExpression = function (expression) { + return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, this.left, this.inKeyword, expression, this.closeParenToken, this.statement); + }; + + ForInStatementSyntax.prototype.withCloseParenToken = function (closeParenToken) { + return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, this.left, this.inKeyword, this.expression, closeParenToken, this.statement); + }; + + ForInStatementSyntax.prototype.withStatement = function (statement) { + return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, this.left, this.inKeyword, this.expression, this.closeParenToken, statement); + }; + + ForInStatementSyntax.prototype.isTypeScriptSpecific = function () { + if (this.variableDeclaration !== null && this.variableDeclaration.isTypeScriptSpecific()) { + return true; + } + if (this.left !== null && this.left.isTypeScriptSpecific()) { + return true; + } + if (this.expression.isTypeScriptSpecific()) { + return true; + } + if (this.statement.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return ForInStatementSyntax; + })(BaseForStatementSyntax); + TypeScript.ForInStatementSyntax = ForInStatementSyntax; + + var WhileStatementSyntax = (function (_super) { + __extends(WhileStatementSyntax, _super); + function WhileStatementSyntax(whileKeyword, openParenToken, condition, closeParenToken, statement, parsedInStrictMode) { + _super.call(this, openParenToken, closeParenToken, statement, parsedInStrictMode); + this.whileKeyword = whileKeyword; + this.condition = condition; + } + WhileStatementSyntax.prototype.accept = function (visitor) { + return visitor.visitWhileStatement(this); + }; + + WhileStatementSyntax.prototype.kind = function () { + return 157 /* WhileStatement */; + }; + + WhileStatementSyntax.prototype.childCount = function () { + return 5; + }; + + WhileStatementSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.whileKeyword; + case 1: + return this.openParenToken; + case 2: + return this.condition; + case 3: + return this.closeParenToken; + case 4: + return this.statement; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + WhileStatementSyntax.prototype.update = function (whileKeyword, openParenToken, condition, closeParenToken, statement) { + if (this.whileKeyword === whileKeyword && this.openParenToken === openParenToken && this.condition === condition && this.closeParenToken === closeParenToken && this.statement === statement) { + return this; + } + + return new WhileStatementSyntax(whileKeyword, openParenToken, condition, closeParenToken, statement, this.parsedInStrictMode()); + }; + + WhileStatementSyntax.create1 = function (condition, statement) { + return new WhileStatementSyntax(TypeScript.Syntax.token(42 /* WhileKeyword */), TypeScript.Syntax.token(72 /* OpenParenToken */), condition, TypeScript.Syntax.token(73 /* CloseParenToken */), statement, false); + }; + + WhileStatementSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + WhileStatementSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + WhileStatementSyntax.prototype.withWhileKeyword = function (whileKeyword) { + return this.update(whileKeyword, this.openParenToken, this.condition, this.closeParenToken, this.statement); + }; + + WhileStatementSyntax.prototype.withOpenParenToken = function (openParenToken) { + return this.update(this.whileKeyword, openParenToken, this.condition, this.closeParenToken, this.statement); + }; + + WhileStatementSyntax.prototype.withCondition = function (condition) { + return this.update(this.whileKeyword, this.openParenToken, condition, this.closeParenToken, this.statement); + }; + + WhileStatementSyntax.prototype.withCloseParenToken = function (closeParenToken) { + return this.update(this.whileKeyword, this.openParenToken, this.condition, closeParenToken, this.statement); + }; + + WhileStatementSyntax.prototype.withStatement = function (statement) { + return this.update(this.whileKeyword, this.openParenToken, this.condition, this.closeParenToken, statement); + }; + + WhileStatementSyntax.prototype.isTypeScriptSpecific = function () { + if (this.condition.isTypeScriptSpecific()) { + return true; + } + if (this.statement.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return WhileStatementSyntax; + })(IterationStatementSyntax); + TypeScript.WhileStatementSyntax = WhileStatementSyntax; + + var WithStatementSyntax = (function (_super) { + __extends(WithStatementSyntax, _super); + function WithStatementSyntax(withKeyword, openParenToken, condition, closeParenToken, statement, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.withKeyword = withKeyword; + this.openParenToken = openParenToken; + this.condition = condition; + this.closeParenToken = closeParenToken; + this.statement = statement; + } + WithStatementSyntax.prototype.accept = function (visitor) { + return visitor.visitWithStatement(this); + }; + + WithStatementSyntax.prototype.kind = function () { + return 162 /* WithStatement */; + }; + + WithStatementSyntax.prototype.childCount = function () { + return 5; + }; + + WithStatementSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.withKeyword; + case 1: + return this.openParenToken; + case 2: + return this.condition; + case 3: + return this.closeParenToken; + case 4: + return this.statement; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + WithStatementSyntax.prototype.isStatement = function () { + return true; + }; + + WithStatementSyntax.prototype.isModuleElement = function () { + return true; + }; + + WithStatementSyntax.prototype.update = function (withKeyword, openParenToken, condition, closeParenToken, statement) { + if (this.withKeyword === withKeyword && this.openParenToken === openParenToken && this.condition === condition && this.closeParenToken === closeParenToken && this.statement === statement) { + return this; + } + + return new WithStatementSyntax(withKeyword, openParenToken, condition, closeParenToken, statement, this.parsedInStrictMode()); + }; + + WithStatementSyntax.create1 = function (condition, statement) { + return new WithStatementSyntax(TypeScript.Syntax.token(43 /* WithKeyword */), TypeScript.Syntax.token(72 /* OpenParenToken */), condition, TypeScript.Syntax.token(73 /* CloseParenToken */), statement, false); + }; + + WithStatementSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + WithStatementSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + WithStatementSyntax.prototype.withWithKeyword = function (withKeyword) { + return this.update(withKeyword, this.openParenToken, this.condition, this.closeParenToken, this.statement); + }; + + WithStatementSyntax.prototype.withOpenParenToken = function (openParenToken) { + return this.update(this.withKeyword, openParenToken, this.condition, this.closeParenToken, this.statement); + }; + + WithStatementSyntax.prototype.withCondition = function (condition) { + return this.update(this.withKeyword, this.openParenToken, condition, this.closeParenToken, this.statement); + }; + + WithStatementSyntax.prototype.withCloseParenToken = function (closeParenToken) { + return this.update(this.withKeyword, this.openParenToken, this.condition, closeParenToken, this.statement); + }; + + WithStatementSyntax.prototype.withStatement = function (statement) { + return this.update(this.withKeyword, this.openParenToken, this.condition, this.closeParenToken, statement); + }; + + WithStatementSyntax.prototype.isTypeScriptSpecific = function () { + if (this.condition.isTypeScriptSpecific()) { + return true; + } + if (this.statement.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return WithStatementSyntax; + })(TypeScript.SyntaxNode); + TypeScript.WithStatementSyntax = WithStatementSyntax; + + var EnumDeclarationSyntax = (function (_super) { + __extends(EnumDeclarationSyntax, _super); + function EnumDeclarationSyntax(modifiers, enumKeyword, identifier, openBraceToken, enumElements, closeBraceToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.modifiers = modifiers; + this.enumKeyword = enumKeyword; + this.identifier = identifier; + this.openBraceToken = openBraceToken; + this.enumElements = enumElements; + this.closeBraceToken = closeBraceToken; + } + EnumDeclarationSyntax.prototype.accept = function (visitor) { + return visitor.visitEnumDeclaration(this); + }; + + EnumDeclarationSyntax.prototype.kind = function () { + return 132 /* EnumDeclaration */; + }; + + EnumDeclarationSyntax.prototype.childCount = function () { + return 6; + }; + + EnumDeclarationSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.modifiers; + case 1: + return this.enumKeyword; + case 2: + return this.identifier; + case 3: + return this.openBraceToken; + case 4: + return this.enumElements; + case 5: + return this.closeBraceToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + EnumDeclarationSyntax.prototype.isModuleElement = function () { + return true; + }; + + EnumDeclarationSyntax.prototype.update = function (modifiers, enumKeyword, identifier, openBraceToken, enumElements, closeBraceToken) { + if (this.modifiers === modifiers && this.enumKeyword === enumKeyword && this.identifier === identifier && this.openBraceToken === openBraceToken && this.enumElements === enumElements && this.closeBraceToken === closeBraceToken) { + return this; + } + + return new EnumDeclarationSyntax(modifiers, enumKeyword, identifier, openBraceToken, enumElements, closeBraceToken, this.parsedInStrictMode()); + }; + + EnumDeclarationSyntax.create = function (enumKeyword, identifier, openBraceToken, closeBraceToken) { + return new EnumDeclarationSyntax(TypeScript.Syntax.emptyList, enumKeyword, identifier, openBraceToken, TypeScript.Syntax.emptySeparatedList, closeBraceToken, false); + }; + + EnumDeclarationSyntax.create1 = function (identifier) { + return new EnumDeclarationSyntax(TypeScript.Syntax.emptyList, TypeScript.Syntax.token(46 /* EnumKeyword */), identifier, TypeScript.Syntax.token(70 /* OpenBraceToken */), TypeScript.Syntax.emptySeparatedList, TypeScript.Syntax.token(71 /* CloseBraceToken */), false); + }; + + EnumDeclarationSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + EnumDeclarationSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + EnumDeclarationSyntax.prototype.withModifiers = function (modifiers) { + return this.update(modifiers, this.enumKeyword, this.identifier, this.openBraceToken, this.enumElements, this.closeBraceToken); + }; + + EnumDeclarationSyntax.prototype.withModifier = function (modifier) { + return this.withModifiers(TypeScript.Syntax.list([modifier])); + }; + + EnumDeclarationSyntax.prototype.withEnumKeyword = function (enumKeyword) { + return this.update(this.modifiers, enumKeyword, this.identifier, this.openBraceToken, this.enumElements, this.closeBraceToken); + }; + + EnumDeclarationSyntax.prototype.withIdentifier = function (identifier) { + return this.update(this.modifiers, this.enumKeyword, identifier, this.openBraceToken, this.enumElements, this.closeBraceToken); + }; + + EnumDeclarationSyntax.prototype.withOpenBraceToken = function (openBraceToken) { + return this.update(this.modifiers, this.enumKeyword, this.identifier, openBraceToken, this.enumElements, this.closeBraceToken); + }; + + EnumDeclarationSyntax.prototype.withEnumElements = function (enumElements) { + return this.update(this.modifiers, this.enumKeyword, this.identifier, this.openBraceToken, enumElements, this.closeBraceToken); + }; + + EnumDeclarationSyntax.prototype.withEnumElement = function (enumElement) { + return this.withEnumElements(TypeScript.Syntax.separatedList([enumElement])); + }; + + EnumDeclarationSyntax.prototype.withCloseBraceToken = function (closeBraceToken) { + return this.update(this.modifiers, this.enumKeyword, this.identifier, this.openBraceToken, this.enumElements, closeBraceToken); + }; + + EnumDeclarationSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return EnumDeclarationSyntax; + })(TypeScript.SyntaxNode); + TypeScript.EnumDeclarationSyntax = EnumDeclarationSyntax; + + var EnumElementSyntax = (function (_super) { + __extends(EnumElementSyntax, _super); + function EnumElementSyntax(propertyName, equalsValueClause, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.propertyName = propertyName; + this.equalsValueClause = equalsValueClause; + } + EnumElementSyntax.prototype.accept = function (visitor) { + return visitor.visitEnumElement(this); + }; + + EnumElementSyntax.prototype.kind = function () { + return 243 /* EnumElement */; + }; + + EnumElementSyntax.prototype.childCount = function () { + return 2; + }; + + EnumElementSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.propertyName; + case 1: + return this.equalsValueClause; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + EnumElementSyntax.prototype.update = function (propertyName, equalsValueClause) { + if (this.propertyName === propertyName && this.equalsValueClause === equalsValueClause) { + return this; + } + + return new EnumElementSyntax(propertyName, equalsValueClause, this.parsedInStrictMode()); + }; + + EnumElementSyntax.create = function (propertyName) { + return new EnumElementSyntax(propertyName, null, false); + }; + + EnumElementSyntax.create1 = function (propertyName) { + return new EnumElementSyntax(propertyName, null, false); + }; + + EnumElementSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + EnumElementSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + EnumElementSyntax.prototype.withPropertyName = function (propertyName) { + return this.update(propertyName, this.equalsValueClause); + }; + + EnumElementSyntax.prototype.withEqualsValueClause = function (equalsValueClause) { + return this.update(this.propertyName, equalsValueClause); + }; + + EnumElementSyntax.prototype.isTypeScriptSpecific = function () { + if (this.equalsValueClause !== null && this.equalsValueClause.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return EnumElementSyntax; + })(TypeScript.SyntaxNode); + TypeScript.EnumElementSyntax = EnumElementSyntax; + + var CastExpressionSyntax = (function (_super) { + __extends(CastExpressionSyntax, _super); + function CastExpressionSyntax(lessThanToken, type, greaterThanToken, expression, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.lessThanToken = lessThanToken; + this.type = type; + this.greaterThanToken = greaterThanToken; + this.expression = expression; + } + CastExpressionSyntax.prototype.accept = function (visitor) { + return visitor.visitCastExpression(this); + }; + + CastExpressionSyntax.prototype.kind = function () { + return 219 /* CastExpression */; + }; + + CastExpressionSyntax.prototype.childCount = function () { + return 4; + }; + + CastExpressionSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.lessThanToken; + case 1: + return this.type; + case 2: + return this.greaterThanToken; + case 3: + return this.expression; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + CastExpressionSyntax.prototype.isUnaryExpression = function () { + return true; + }; + + CastExpressionSyntax.prototype.isExpression = function () { + return true; + }; + + CastExpressionSyntax.prototype.update = function (lessThanToken, type, greaterThanToken, expression) { + if (this.lessThanToken === lessThanToken && this.type === type && this.greaterThanToken === greaterThanToken && this.expression === expression) { + return this; + } + + return new CastExpressionSyntax(lessThanToken, type, greaterThanToken, expression, this.parsedInStrictMode()); + }; + + CastExpressionSyntax.create1 = function (type, expression) { + return new CastExpressionSyntax(TypeScript.Syntax.token(80 /* LessThanToken */), type, TypeScript.Syntax.token(81 /* GreaterThanToken */), expression, false); + }; + + CastExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + CastExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + CastExpressionSyntax.prototype.withLessThanToken = function (lessThanToken) { + return this.update(lessThanToken, this.type, this.greaterThanToken, this.expression); + }; + + CastExpressionSyntax.prototype.withType = function (type) { + return this.update(this.lessThanToken, type, this.greaterThanToken, this.expression); + }; + + CastExpressionSyntax.prototype.withGreaterThanToken = function (greaterThanToken) { + return this.update(this.lessThanToken, this.type, greaterThanToken, this.expression); + }; + + CastExpressionSyntax.prototype.withExpression = function (expression) { + return this.update(this.lessThanToken, this.type, this.greaterThanToken, expression); + }; + + CastExpressionSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return CastExpressionSyntax; + })(TypeScript.SyntaxNode); + TypeScript.CastExpressionSyntax = CastExpressionSyntax; + + var ObjectLiteralExpressionSyntax = (function (_super) { + __extends(ObjectLiteralExpressionSyntax, _super); + function ObjectLiteralExpressionSyntax(openBraceToken, propertyAssignments, closeBraceToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.openBraceToken = openBraceToken; + this.propertyAssignments = propertyAssignments; + this.closeBraceToken = closeBraceToken; + } + ObjectLiteralExpressionSyntax.prototype.accept = function (visitor) { + return visitor.visitObjectLiteralExpression(this); + }; + + ObjectLiteralExpressionSyntax.prototype.kind = function () { + return 214 /* ObjectLiteralExpression */; + }; + + ObjectLiteralExpressionSyntax.prototype.childCount = function () { + return 3; + }; + + ObjectLiteralExpressionSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.openBraceToken; + case 1: + return this.propertyAssignments; + case 2: + return this.closeBraceToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ObjectLiteralExpressionSyntax.prototype.isUnaryExpression = function () { + return true; + }; + + ObjectLiteralExpressionSyntax.prototype.isExpression = function () { + return true; + }; + + ObjectLiteralExpressionSyntax.prototype.update = function (openBraceToken, propertyAssignments, closeBraceToken) { + if (this.openBraceToken === openBraceToken && this.propertyAssignments === propertyAssignments && this.closeBraceToken === closeBraceToken) { + return this; + } + + return new ObjectLiteralExpressionSyntax(openBraceToken, propertyAssignments, closeBraceToken, this.parsedInStrictMode()); + }; + + ObjectLiteralExpressionSyntax.create = function (openBraceToken, closeBraceToken) { + return new ObjectLiteralExpressionSyntax(openBraceToken, TypeScript.Syntax.emptySeparatedList, closeBraceToken, false); + }; + + ObjectLiteralExpressionSyntax.create1 = function () { + return new ObjectLiteralExpressionSyntax(TypeScript.Syntax.token(70 /* OpenBraceToken */), TypeScript.Syntax.emptySeparatedList, TypeScript.Syntax.token(71 /* CloseBraceToken */), false); + }; + + ObjectLiteralExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ObjectLiteralExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ObjectLiteralExpressionSyntax.prototype.withOpenBraceToken = function (openBraceToken) { + return this.update(openBraceToken, this.propertyAssignments, this.closeBraceToken); + }; + + ObjectLiteralExpressionSyntax.prototype.withPropertyAssignments = function (propertyAssignments) { + return this.update(this.openBraceToken, propertyAssignments, this.closeBraceToken); + }; + + ObjectLiteralExpressionSyntax.prototype.withPropertyAssignment = function (propertyAssignment) { + return this.withPropertyAssignments(TypeScript.Syntax.separatedList([propertyAssignment])); + }; + + ObjectLiteralExpressionSyntax.prototype.withCloseBraceToken = function (closeBraceToken) { + return this.update(this.openBraceToken, this.propertyAssignments, closeBraceToken); + }; + + ObjectLiteralExpressionSyntax.prototype.isTypeScriptSpecific = function () { + if (this.propertyAssignments.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return ObjectLiteralExpressionSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ObjectLiteralExpressionSyntax = ObjectLiteralExpressionSyntax; + + var PropertyAssignmentSyntax = (function (_super) { + __extends(PropertyAssignmentSyntax, _super); + function PropertyAssignmentSyntax(propertyName, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.propertyName = propertyName; + } + PropertyAssignmentSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + PropertyAssignmentSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + PropertyAssignmentSyntax.prototype.isTypeScriptSpecific = function () { + return false; + }; + return PropertyAssignmentSyntax; + })(TypeScript.SyntaxNode); + TypeScript.PropertyAssignmentSyntax = PropertyAssignmentSyntax; + + var SimplePropertyAssignmentSyntax = (function (_super) { + __extends(SimplePropertyAssignmentSyntax, _super); + function SimplePropertyAssignmentSyntax(propertyName, colonToken, expression, parsedInStrictMode) { + _super.call(this, propertyName, parsedInStrictMode); + this.colonToken = colonToken; + this.expression = expression; + } + SimplePropertyAssignmentSyntax.prototype.accept = function (visitor) { + return visitor.visitSimplePropertyAssignment(this); + }; + + SimplePropertyAssignmentSyntax.prototype.kind = function () { + return 238 /* SimplePropertyAssignment */; + }; + + SimplePropertyAssignmentSyntax.prototype.childCount = function () { + return 3; + }; + + SimplePropertyAssignmentSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.propertyName; + case 1: + return this.colonToken; + case 2: + return this.expression; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + SimplePropertyAssignmentSyntax.prototype.update = function (propertyName, colonToken, expression) { + if (this.propertyName === propertyName && this.colonToken === colonToken && this.expression === expression) { + return this; + } + + return new SimplePropertyAssignmentSyntax(propertyName, colonToken, expression, this.parsedInStrictMode()); + }; + + SimplePropertyAssignmentSyntax.create1 = function (propertyName, expression) { + return new SimplePropertyAssignmentSyntax(propertyName, TypeScript.Syntax.token(106 /* ColonToken */), expression, false); + }; + + SimplePropertyAssignmentSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + SimplePropertyAssignmentSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + SimplePropertyAssignmentSyntax.prototype.withPropertyName = function (propertyName) { + return this.update(propertyName, this.colonToken, this.expression); + }; + + SimplePropertyAssignmentSyntax.prototype.withColonToken = function (colonToken) { + return this.update(this.propertyName, colonToken, this.expression); + }; + + SimplePropertyAssignmentSyntax.prototype.withExpression = function (expression) { + return this.update(this.propertyName, this.colonToken, expression); + }; + + SimplePropertyAssignmentSyntax.prototype.isTypeScriptSpecific = function () { + if (this.expression.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return SimplePropertyAssignmentSyntax; + })(PropertyAssignmentSyntax); + TypeScript.SimplePropertyAssignmentSyntax = SimplePropertyAssignmentSyntax; + + var FunctionPropertyAssignmentSyntax = (function (_super) { + __extends(FunctionPropertyAssignmentSyntax, _super); + function FunctionPropertyAssignmentSyntax(propertyName, callSignature, block, parsedInStrictMode) { + _super.call(this, propertyName, parsedInStrictMode); + this.callSignature = callSignature; + this.block = block; + } + FunctionPropertyAssignmentSyntax.prototype.accept = function (visitor) { + return visitor.visitFunctionPropertyAssignment(this); + }; + + FunctionPropertyAssignmentSyntax.prototype.kind = function () { + return 241 /* FunctionPropertyAssignment */; + }; + + FunctionPropertyAssignmentSyntax.prototype.childCount = function () { + return 3; + }; + + FunctionPropertyAssignmentSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.propertyName; + case 1: + return this.callSignature; + case 2: + return this.block; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + FunctionPropertyAssignmentSyntax.prototype.update = function (propertyName, callSignature, block) { + if (this.propertyName === propertyName && this.callSignature === callSignature && this.block === block) { + return this; + } + + return new FunctionPropertyAssignmentSyntax(propertyName, callSignature, block, this.parsedInStrictMode()); + }; + + FunctionPropertyAssignmentSyntax.create1 = function (propertyName) { + return new FunctionPropertyAssignmentSyntax(propertyName, CallSignatureSyntax.create1(), BlockSyntax.create1(), false); + }; + + FunctionPropertyAssignmentSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + FunctionPropertyAssignmentSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + FunctionPropertyAssignmentSyntax.prototype.withPropertyName = function (propertyName) { + return this.update(propertyName, this.callSignature, this.block); + }; + + FunctionPropertyAssignmentSyntax.prototype.withCallSignature = function (callSignature) { + return this.update(this.propertyName, callSignature, this.block); + }; + + FunctionPropertyAssignmentSyntax.prototype.withBlock = function (block) { + return this.update(this.propertyName, this.callSignature, block); + }; + + FunctionPropertyAssignmentSyntax.prototype.isTypeScriptSpecific = function () { + if (this.callSignature.isTypeScriptSpecific()) { + return true; + } + if (this.block.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return FunctionPropertyAssignmentSyntax; + })(PropertyAssignmentSyntax); + TypeScript.FunctionPropertyAssignmentSyntax = FunctionPropertyAssignmentSyntax; + + var AccessorPropertyAssignmentSyntax = (function (_super) { + __extends(AccessorPropertyAssignmentSyntax, _super); + function AccessorPropertyAssignmentSyntax(propertyName, openParenToken, closeParenToken, block, parsedInStrictMode) { + _super.call(this, propertyName, parsedInStrictMode); + this.openParenToken = openParenToken; + this.closeParenToken = closeParenToken; + this.block = block; + } + AccessorPropertyAssignmentSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + AccessorPropertyAssignmentSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + AccessorPropertyAssignmentSyntax.prototype.isTypeScriptSpecific = function () { + return false; + }; + return AccessorPropertyAssignmentSyntax; + })(PropertyAssignmentSyntax); + TypeScript.AccessorPropertyAssignmentSyntax = AccessorPropertyAssignmentSyntax; + + var GetAccessorPropertyAssignmentSyntax = (function (_super) { + __extends(GetAccessorPropertyAssignmentSyntax, _super); + function GetAccessorPropertyAssignmentSyntax(getKeyword, propertyName, openParenToken, closeParenToken, typeAnnotation, block, parsedInStrictMode) { + _super.call(this, propertyName, openParenToken, closeParenToken, block, parsedInStrictMode); + this.getKeyword = getKeyword; + this.typeAnnotation = typeAnnotation; + } + GetAccessorPropertyAssignmentSyntax.prototype.accept = function (visitor) { + return visitor.visitGetAccessorPropertyAssignment(this); + }; + + GetAccessorPropertyAssignmentSyntax.prototype.kind = function () { + return 239 /* GetAccessorPropertyAssignment */; + }; + + GetAccessorPropertyAssignmentSyntax.prototype.childCount = function () { + return 6; + }; + + GetAccessorPropertyAssignmentSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.getKeyword; + case 1: + return this.propertyName; + case 2: + return this.openParenToken; + case 3: + return this.closeParenToken; + case 4: + return this.typeAnnotation; + case 5: + return this.block; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + GetAccessorPropertyAssignmentSyntax.prototype.update = function (getKeyword, propertyName, openParenToken, closeParenToken, typeAnnotation, block) { + if (this.getKeyword === getKeyword && this.propertyName === propertyName && this.openParenToken === openParenToken && this.closeParenToken === closeParenToken && this.typeAnnotation === typeAnnotation && this.block === block) { + return this; + } + + return new GetAccessorPropertyAssignmentSyntax(getKeyword, propertyName, openParenToken, closeParenToken, typeAnnotation, block, this.parsedInStrictMode()); + }; + + GetAccessorPropertyAssignmentSyntax.create = function (getKeyword, propertyName, openParenToken, closeParenToken, block) { + return new GetAccessorPropertyAssignmentSyntax(getKeyword, propertyName, openParenToken, closeParenToken, null, block, false); + }; + + GetAccessorPropertyAssignmentSyntax.create1 = function (propertyName) { + return new GetAccessorPropertyAssignmentSyntax(TypeScript.Syntax.token(64 /* GetKeyword */), propertyName, TypeScript.Syntax.token(72 /* OpenParenToken */), TypeScript.Syntax.token(73 /* CloseParenToken */), null, BlockSyntax.create1(), false); + }; + + GetAccessorPropertyAssignmentSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + GetAccessorPropertyAssignmentSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + GetAccessorPropertyAssignmentSyntax.prototype.withGetKeyword = function (getKeyword) { + return this.update(getKeyword, this.propertyName, this.openParenToken, this.closeParenToken, this.typeAnnotation, this.block); + }; + + GetAccessorPropertyAssignmentSyntax.prototype.withPropertyName = function (propertyName) { + return this.update(this.getKeyword, propertyName, this.openParenToken, this.closeParenToken, this.typeAnnotation, this.block); + }; + + GetAccessorPropertyAssignmentSyntax.prototype.withOpenParenToken = function (openParenToken) { + return this.update(this.getKeyword, this.propertyName, openParenToken, this.closeParenToken, this.typeAnnotation, this.block); + }; + + GetAccessorPropertyAssignmentSyntax.prototype.withCloseParenToken = function (closeParenToken) { + return this.update(this.getKeyword, this.propertyName, this.openParenToken, closeParenToken, this.typeAnnotation, this.block); + }; + + GetAccessorPropertyAssignmentSyntax.prototype.withTypeAnnotation = function (typeAnnotation) { + return this.update(this.getKeyword, this.propertyName, this.openParenToken, this.closeParenToken, typeAnnotation, this.block); + }; + + GetAccessorPropertyAssignmentSyntax.prototype.withBlock = function (block) { + return this.update(this.getKeyword, this.propertyName, this.openParenToken, this.closeParenToken, this.typeAnnotation, block); + }; + + GetAccessorPropertyAssignmentSyntax.prototype.isTypeScriptSpecific = function () { + if (this.typeAnnotation !== null && this.typeAnnotation.isTypeScriptSpecific()) { + return true; + } + if (this.block.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return GetAccessorPropertyAssignmentSyntax; + })(AccessorPropertyAssignmentSyntax); + TypeScript.GetAccessorPropertyAssignmentSyntax = GetAccessorPropertyAssignmentSyntax; + + var SetAccessorPropertyAssignmentSyntax = (function (_super) { + __extends(SetAccessorPropertyAssignmentSyntax, _super); + function SetAccessorPropertyAssignmentSyntax(setKeyword, propertyName, openParenToken, parameter, closeParenToken, block, parsedInStrictMode) { + _super.call(this, propertyName, openParenToken, closeParenToken, block, parsedInStrictMode); + this.setKeyword = setKeyword; + this.parameter = parameter; + } + SetAccessorPropertyAssignmentSyntax.prototype.accept = function (visitor) { + return visitor.visitSetAccessorPropertyAssignment(this); + }; + + SetAccessorPropertyAssignmentSyntax.prototype.kind = function () { + return 240 /* SetAccessorPropertyAssignment */; + }; + + SetAccessorPropertyAssignmentSyntax.prototype.childCount = function () { + return 6; + }; + + SetAccessorPropertyAssignmentSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.setKeyword; + case 1: + return this.propertyName; + case 2: + return this.openParenToken; + case 3: + return this.parameter; + case 4: + return this.closeParenToken; + case 5: + return this.block; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + SetAccessorPropertyAssignmentSyntax.prototype.update = function (setKeyword, propertyName, openParenToken, parameter, closeParenToken, block) { + if (this.setKeyword === setKeyword && this.propertyName === propertyName && this.openParenToken === openParenToken && this.parameter === parameter && this.closeParenToken === closeParenToken && this.block === block) { + return this; + } + + return new SetAccessorPropertyAssignmentSyntax(setKeyword, propertyName, openParenToken, parameter, closeParenToken, block, this.parsedInStrictMode()); + }; + + SetAccessorPropertyAssignmentSyntax.create1 = function (propertyName, parameter) { + return new SetAccessorPropertyAssignmentSyntax(TypeScript.Syntax.token(68 /* SetKeyword */), propertyName, TypeScript.Syntax.token(72 /* OpenParenToken */), parameter, TypeScript.Syntax.token(73 /* CloseParenToken */), BlockSyntax.create1(), false); + }; + + SetAccessorPropertyAssignmentSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + SetAccessorPropertyAssignmentSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + SetAccessorPropertyAssignmentSyntax.prototype.withSetKeyword = function (setKeyword) { + return this.update(setKeyword, this.propertyName, this.openParenToken, this.parameter, this.closeParenToken, this.block); + }; + + SetAccessorPropertyAssignmentSyntax.prototype.withPropertyName = function (propertyName) { + return this.update(this.setKeyword, propertyName, this.openParenToken, this.parameter, this.closeParenToken, this.block); + }; + + SetAccessorPropertyAssignmentSyntax.prototype.withOpenParenToken = function (openParenToken) { + return this.update(this.setKeyword, this.propertyName, openParenToken, this.parameter, this.closeParenToken, this.block); + }; + + SetAccessorPropertyAssignmentSyntax.prototype.withParameter = function (parameter) { + return this.update(this.setKeyword, this.propertyName, this.openParenToken, parameter, this.closeParenToken, this.block); + }; + + SetAccessorPropertyAssignmentSyntax.prototype.withCloseParenToken = function (closeParenToken) { + return this.update(this.setKeyword, this.propertyName, this.openParenToken, this.parameter, closeParenToken, this.block); + }; + + SetAccessorPropertyAssignmentSyntax.prototype.withBlock = function (block) { + return this.update(this.setKeyword, this.propertyName, this.openParenToken, this.parameter, this.closeParenToken, block); + }; + + SetAccessorPropertyAssignmentSyntax.prototype.isTypeScriptSpecific = function () { + if (this.parameter.isTypeScriptSpecific()) { + return true; + } + if (this.block.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return SetAccessorPropertyAssignmentSyntax; + })(AccessorPropertyAssignmentSyntax); + TypeScript.SetAccessorPropertyAssignmentSyntax = SetAccessorPropertyAssignmentSyntax; + + var FunctionExpressionSyntax = (function (_super) { + __extends(FunctionExpressionSyntax, _super); + function FunctionExpressionSyntax(functionKeyword, identifier, callSignature, block, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.functionKeyword = functionKeyword; + this.identifier = identifier; + this.callSignature = callSignature; + this.block = block; + } + FunctionExpressionSyntax.prototype.accept = function (visitor) { + return visitor.visitFunctionExpression(this); + }; + + FunctionExpressionSyntax.prototype.kind = function () { + return 221 /* FunctionExpression */; + }; + + FunctionExpressionSyntax.prototype.childCount = function () { + return 4; + }; + + FunctionExpressionSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.functionKeyword; + case 1: + return this.identifier; + case 2: + return this.callSignature; + case 3: + return this.block; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + FunctionExpressionSyntax.prototype.isUnaryExpression = function () { + return true; + }; + + FunctionExpressionSyntax.prototype.isExpression = function () { + return true; + }; + + FunctionExpressionSyntax.prototype.update = function (functionKeyword, identifier, callSignature, block) { + if (this.functionKeyword === functionKeyword && this.identifier === identifier && this.callSignature === callSignature && this.block === block) { + return this; + } + + return new FunctionExpressionSyntax(functionKeyword, identifier, callSignature, block, this.parsedInStrictMode()); + }; + + FunctionExpressionSyntax.create = function (functionKeyword, callSignature, block) { + return new FunctionExpressionSyntax(functionKeyword, null, callSignature, block, false); + }; + + FunctionExpressionSyntax.create1 = function () { + return new FunctionExpressionSyntax(TypeScript.Syntax.token(27 /* FunctionKeyword */), null, CallSignatureSyntax.create1(), BlockSyntax.create1(), false); + }; + + FunctionExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + FunctionExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + FunctionExpressionSyntax.prototype.withFunctionKeyword = function (functionKeyword) { + return this.update(functionKeyword, this.identifier, this.callSignature, this.block); + }; + + FunctionExpressionSyntax.prototype.withIdentifier = function (identifier) { + return this.update(this.functionKeyword, identifier, this.callSignature, this.block); + }; + + FunctionExpressionSyntax.prototype.withCallSignature = function (callSignature) { + return this.update(this.functionKeyword, this.identifier, callSignature, this.block); + }; + + FunctionExpressionSyntax.prototype.withBlock = function (block) { + return this.update(this.functionKeyword, this.identifier, this.callSignature, block); + }; + + FunctionExpressionSyntax.prototype.isTypeScriptSpecific = function () { + if (this.callSignature.isTypeScriptSpecific()) { + return true; + } + if (this.block.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return FunctionExpressionSyntax; + })(TypeScript.SyntaxNode); + TypeScript.FunctionExpressionSyntax = FunctionExpressionSyntax; + + var EmptyStatementSyntax = (function (_super) { + __extends(EmptyStatementSyntax, _super); + function EmptyStatementSyntax(semicolonToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.semicolonToken = semicolonToken; + } + EmptyStatementSyntax.prototype.accept = function (visitor) { + return visitor.visitEmptyStatement(this); + }; + + EmptyStatementSyntax.prototype.kind = function () { + return 155 /* EmptyStatement */; + }; + + EmptyStatementSyntax.prototype.childCount = function () { + return 1; + }; + + EmptyStatementSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.semicolonToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + EmptyStatementSyntax.prototype.isStatement = function () { + return true; + }; + + EmptyStatementSyntax.prototype.isModuleElement = function () { + return true; + }; + + EmptyStatementSyntax.prototype.update = function (semicolonToken) { + if (this.semicolonToken === semicolonToken) { + return this; + } + + return new EmptyStatementSyntax(semicolonToken, this.parsedInStrictMode()); + }; + + EmptyStatementSyntax.create1 = function () { + return new EmptyStatementSyntax(TypeScript.Syntax.token(78 /* SemicolonToken */), false); + }; + + EmptyStatementSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + EmptyStatementSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + EmptyStatementSyntax.prototype.withSemicolonToken = function (semicolonToken) { + return this.update(semicolonToken); + }; + + EmptyStatementSyntax.prototype.isTypeScriptSpecific = function () { + return false; + }; + return EmptyStatementSyntax; + })(TypeScript.SyntaxNode); + TypeScript.EmptyStatementSyntax = EmptyStatementSyntax; + + var TryStatementSyntax = (function (_super) { + __extends(TryStatementSyntax, _super); + function TryStatementSyntax(tryKeyword, block, catchClause, finallyClause, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.tryKeyword = tryKeyword; + this.block = block; + this.catchClause = catchClause; + this.finallyClause = finallyClause; + } + TryStatementSyntax.prototype.accept = function (visitor) { + return visitor.visitTryStatement(this); + }; + + TryStatementSyntax.prototype.kind = function () { + return 158 /* TryStatement */; + }; + + TryStatementSyntax.prototype.childCount = function () { + return 4; + }; + + TryStatementSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.tryKeyword; + case 1: + return this.block; + case 2: + return this.catchClause; + case 3: + return this.finallyClause; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + TryStatementSyntax.prototype.isStatement = function () { + return true; + }; + + TryStatementSyntax.prototype.isModuleElement = function () { + return true; + }; + + TryStatementSyntax.prototype.update = function (tryKeyword, block, catchClause, finallyClause) { + if (this.tryKeyword === tryKeyword && this.block === block && this.catchClause === catchClause && this.finallyClause === finallyClause) { + return this; + } + + return new TryStatementSyntax(tryKeyword, block, catchClause, finallyClause, this.parsedInStrictMode()); + }; + + TryStatementSyntax.create = function (tryKeyword, block) { + return new TryStatementSyntax(tryKeyword, block, null, null, false); + }; + + TryStatementSyntax.create1 = function () { + return new TryStatementSyntax(TypeScript.Syntax.token(38 /* TryKeyword */), BlockSyntax.create1(), null, null, false); + }; + + TryStatementSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + TryStatementSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + TryStatementSyntax.prototype.withTryKeyword = function (tryKeyword) { + return this.update(tryKeyword, this.block, this.catchClause, this.finallyClause); + }; + + TryStatementSyntax.prototype.withBlock = function (block) { + return this.update(this.tryKeyword, block, this.catchClause, this.finallyClause); + }; + + TryStatementSyntax.prototype.withCatchClause = function (catchClause) { + return this.update(this.tryKeyword, this.block, catchClause, this.finallyClause); + }; + + TryStatementSyntax.prototype.withFinallyClause = function (finallyClause) { + return this.update(this.tryKeyword, this.block, this.catchClause, finallyClause); + }; + + TryStatementSyntax.prototype.isTypeScriptSpecific = function () { + if (this.block.isTypeScriptSpecific()) { + return true; + } + if (this.catchClause !== null && this.catchClause.isTypeScriptSpecific()) { + return true; + } + if (this.finallyClause !== null && this.finallyClause.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return TryStatementSyntax; + })(TypeScript.SyntaxNode); + TypeScript.TryStatementSyntax = TryStatementSyntax; + + var CatchClauseSyntax = (function (_super) { + __extends(CatchClauseSyntax, _super); + function CatchClauseSyntax(catchKeyword, openParenToken, identifier, typeAnnotation, closeParenToken, block, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.catchKeyword = catchKeyword; + this.openParenToken = openParenToken; + this.identifier = identifier; + this.typeAnnotation = typeAnnotation; + this.closeParenToken = closeParenToken; + this.block = block; + } + CatchClauseSyntax.prototype.accept = function (visitor) { + return visitor.visitCatchClause(this); + }; + + CatchClauseSyntax.prototype.kind = function () { + return 234 /* CatchClause */; + }; + + CatchClauseSyntax.prototype.childCount = function () { + return 6; + }; + + CatchClauseSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.catchKeyword; + case 1: + return this.openParenToken; + case 2: + return this.identifier; + case 3: + return this.typeAnnotation; + case 4: + return this.closeParenToken; + case 5: + return this.block; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + CatchClauseSyntax.prototype.update = function (catchKeyword, openParenToken, identifier, typeAnnotation, closeParenToken, block) { + if (this.catchKeyword === catchKeyword && this.openParenToken === openParenToken && this.identifier === identifier && this.typeAnnotation === typeAnnotation && this.closeParenToken === closeParenToken && this.block === block) { + return this; + } + + return new CatchClauseSyntax(catchKeyword, openParenToken, identifier, typeAnnotation, closeParenToken, block, this.parsedInStrictMode()); + }; + + CatchClauseSyntax.create = function (catchKeyword, openParenToken, identifier, closeParenToken, block) { + return new CatchClauseSyntax(catchKeyword, openParenToken, identifier, null, closeParenToken, block, false); + }; + + CatchClauseSyntax.create1 = function (identifier) { + return new CatchClauseSyntax(TypeScript.Syntax.token(17 /* CatchKeyword */), TypeScript.Syntax.token(72 /* OpenParenToken */), identifier, null, TypeScript.Syntax.token(73 /* CloseParenToken */), BlockSyntax.create1(), false); + }; + + CatchClauseSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + CatchClauseSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + CatchClauseSyntax.prototype.withCatchKeyword = function (catchKeyword) { + return this.update(catchKeyword, this.openParenToken, this.identifier, this.typeAnnotation, this.closeParenToken, this.block); + }; + + CatchClauseSyntax.prototype.withOpenParenToken = function (openParenToken) { + return this.update(this.catchKeyword, openParenToken, this.identifier, this.typeAnnotation, this.closeParenToken, this.block); + }; + + CatchClauseSyntax.prototype.withIdentifier = function (identifier) { + return this.update(this.catchKeyword, this.openParenToken, identifier, this.typeAnnotation, this.closeParenToken, this.block); + }; + + CatchClauseSyntax.prototype.withTypeAnnotation = function (typeAnnotation) { + return this.update(this.catchKeyword, this.openParenToken, this.identifier, typeAnnotation, this.closeParenToken, this.block); + }; + + CatchClauseSyntax.prototype.withCloseParenToken = function (closeParenToken) { + return this.update(this.catchKeyword, this.openParenToken, this.identifier, this.typeAnnotation, closeParenToken, this.block); + }; + + CatchClauseSyntax.prototype.withBlock = function (block) { + return this.update(this.catchKeyword, this.openParenToken, this.identifier, this.typeAnnotation, this.closeParenToken, block); + }; + + CatchClauseSyntax.prototype.isTypeScriptSpecific = function () { + if (this.typeAnnotation !== null && this.typeAnnotation.isTypeScriptSpecific()) { + return true; + } + if (this.block.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return CatchClauseSyntax; + })(TypeScript.SyntaxNode); + TypeScript.CatchClauseSyntax = CatchClauseSyntax; + + var FinallyClauseSyntax = (function (_super) { + __extends(FinallyClauseSyntax, _super); + function FinallyClauseSyntax(finallyKeyword, block, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.finallyKeyword = finallyKeyword; + this.block = block; + } + FinallyClauseSyntax.prototype.accept = function (visitor) { + return visitor.visitFinallyClause(this); + }; + + FinallyClauseSyntax.prototype.kind = function () { + return 235 /* FinallyClause */; + }; + + FinallyClauseSyntax.prototype.childCount = function () { + return 2; + }; + + FinallyClauseSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.finallyKeyword; + case 1: + return this.block; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + FinallyClauseSyntax.prototype.update = function (finallyKeyword, block) { + if (this.finallyKeyword === finallyKeyword && this.block === block) { + return this; + } + + return new FinallyClauseSyntax(finallyKeyword, block, this.parsedInStrictMode()); + }; + + FinallyClauseSyntax.create1 = function () { + return new FinallyClauseSyntax(TypeScript.Syntax.token(25 /* FinallyKeyword */), BlockSyntax.create1(), false); + }; + + FinallyClauseSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + FinallyClauseSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + FinallyClauseSyntax.prototype.withFinallyKeyword = function (finallyKeyword) { + return this.update(finallyKeyword, this.block); + }; + + FinallyClauseSyntax.prototype.withBlock = function (block) { + return this.update(this.finallyKeyword, block); + }; + + FinallyClauseSyntax.prototype.isTypeScriptSpecific = function () { + if (this.block.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return FinallyClauseSyntax; + })(TypeScript.SyntaxNode); + TypeScript.FinallyClauseSyntax = FinallyClauseSyntax; + + var LabeledStatementSyntax = (function (_super) { + __extends(LabeledStatementSyntax, _super); + function LabeledStatementSyntax(identifier, colonToken, statement, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.identifier = identifier; + this.colonToken = colonToken; + this.statement = statement; + } + LabeledStatementSyntax.prototype.accept = function (visitor) { + return visitor.visitLabeledStatement(this); + }; + + LabeledStatementSyntax.prototype.kind = function () { + return 159 /* LabeledStatement */; + }; + + LabeledStatementSyntax.prototype.childCount = function () { + return 3; + }; + + LabeledStatementSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.identifier; + case 1: + return this.colonToken; + case 2: + return this.statement; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + LabeledStatementSyntax.prototype.isStatement = function () { + return true; + }; + + LabeledStatementSyntax.prototype.isModuleElement = function () { + return true; + }; + + LabeledStatementSyntax.prototype.update = function (identifier, colonToken, statement) { + if (this.identifier === identifier && this.colonToken === colonToken && this.statement === statement) { + return this; + } + + return new LabeledStatementSyntax(identifier, colonToken, statement, this.parsedInStrictMode()); + }; + + LabeledStatementSyntax.create1 = function (identifier, statement) { + return new LabeledStatementSyntax(identifier, TypeScript.Syntax.token(106 /* ColonToken */), statement, false); + }; + + LabeledStatementSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + LabeledStatementSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + LabeledStatementSyntax.prototype.withIdentifier = function (identifier) { + return this.update(identifier, this.colonToken, this.statement); + }; + + LabeledStatementSyntax.prototype.withColonToken = function (colonToken) { + return this.update(this.identifier, colonToken, this.statement); + }; + + LabeledStatementSyntax.prototype.withStatement = function (statement) { + return this.update(this.identifier, this.colonToken, statement); + }; + + LabeledStatementSyntax.prototype.isTypeScriptSpecific = function () { + if (this.statement.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return LabeledStatementSyntax; + })(TypeScript.SyntaxNode); + TypeScript.LabeledStatementSyntax = LabeledStatementSyntax; + + var DoStatementSyntax = (function (_super) { + __extends(DoStatementSyntax, _super); + function DoStatementSyntax(doKeyword, statement, whileKeyword, openParenToken, condition, closeParenToken, semicolonToken, parsedInStrictMode) { + _super.call(this, openParenToken, closeParenToken, statement, parsedInStrictMode); + this.doKeyword = doKeyword; + this.whileKeyword = whileKeyword; + this.condition = condition; + this.semicolonToken = semicolonToken; + } + DoStatementSyntax.prototype.accept = function (visitor) { + return visitor.visitDoStatement(this); + }; + + DoStatementSyntax.prototype.kind = function () { + return 160 /* DoStatement */; + }; + + DoStatementSyntax.prototype.childCount = function () { + return 7; + }; + + DoStatementSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.doKeyword; + case 1: + return this.statement; + case 2: + return this.whileKeyword; + case 3: + return this.openParenToken; + case 4: + return this.condition; + case 5: + return this.closeParenToken; + case 6: + return this.semicolonToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + DoStatementSyntax.prototype.update = function (doKeyword, statement, whileKeyword, openParenToken, condition, closeParenToken, semicolonToken) { + if (this.doKeyword === doKeyword && this.statement === statement && this.whileKeyword === whileKeyword && this.openParenToken === openParenToken && this.condition === condition && this.closeParenToken === closeParenToken && this.semicolonToken === semicolonToken) { + return this; + } + + return new DoStatementSyntax(doKeyword, statement, whileKeyword, openParenToken, condition, closeParenToken, semicolonToken, this.parsedInStrictMode()); + }; + + DoStatementSyntax.create1 = function (statement, condition) { + return new DoStatementSyntax(TypeScript.Syntax.token(22 /* DoKeyword */), statement, TypeScript.Syntax.token(42 /* WhileKeyword */), TypeScript.Syntax.token(72 /* OpenParenToken */), condition, TypeScript.Syntax.token(73 /* CloseParenToken */), TypeScript.Syntax.token(78 /* SemicolonToken */), false); + }; + + DoStatementSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + DoStatementSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + DoStatementSyntax.prototype.withDoKeyword = function (doKeyword) { + return this.update(doKeyword, this.statement, this.whileKeyword, this.openParenToken, this.condition, this.closeParenToken, this.semicolonToken); + }; + + DoStatementSyntax.prototype.withStatement = function (statement) { + return this.update(this.doKeyword, statement, this.whileKeyword, this.openParenToken, this.condition, this.closeParenToken, this.semicolonToken); + }; + + DoStatementSyntax.prototype.withWhileKeyword = function (whileKeyword) { + return this.update(this.doKeyword, this.statement, whileKeyword, this.openParenToken, this.condition, this.closeParenToken, this.semicolonToken); + }; + + DoStatementSyntax.prototype.withOpenParenToken = function (openParenToken) { + return this.update(this.doKeyword, this.statement, this.whileKeyword, openParenToken, this.condition, this.closeParenToken, this.semicolonToken); + }; + + DoStatementSyntax.prototype.withCondition = function (condition) { + return this.update(this.doKeyword, this.statement, this.whileKeyword, this.openParenToken, condition, this.closeParenToken, this.semicolonToken); + }; + + DoStatementSyntax.prototype.withCloseParenToken = function (closeParenToken) { + return this.update(this.doKeyword, this.statement, this.whileKeyword, this.openParenToken, this.condition, closeParenToken, this.semicolonToken); + }; + + DoStatementSyntax.prototype.withSemicolonToken = function (semicolonToken) { + return this.update(this.doKeyword, this.statement, this.whileKeyword, this.openParenToken, this.condition, this.closeParenToken, semicolonToken); + }; + + DoStatementSyntax.prototype.isTypeScriptSpecific = function () { + if (this.statement.isTypeScriptSpecific()) { + return true; + } + if (this.condition.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return DoStatementSyntax; + })(IterationStatementSyntax); + TypeScript.DoStatementSyntax = DoStatementSyntax; + + var TypeOfExpressionSyntax = (function (_super) { + __extends(TypeOfExpressionSyntax, _super); + function TypeOfExpressionSyntax(typeOfKeyword, expression, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.typeOfKeyword = typeOfKeyword; + this.expression = expression; + } + TypeOfExpressionSyntax.prototype.accept = function (visitor) { + return visitor.visitTypeOfExpression(this); + }; + + TypeOfExpressionSyntax.prototype.kind = function () { + return 170 /* TypeOfExpression */; + }; + + TypeOfExpressionSyntax.prototype.childCount = function () { + return 2; + }; + + TypeOfExpressionSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.typeOfKeyword; + case 1: + return this.expression; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + TypeOfExpressionSyntax.prototype.isUnaryExpression = function () { + return true; + }; + + TypeOfExpressionSyntax.prototype.isExpression = function () { + return true; + }; + + TypeOfExpressionSyntax.prototype.update = function (typeOfKeyword, expression) { + if (this.typeOfKeyword === typeOfKeyword && this.expression === expression) { + return this; + } + + return new TypeOfExpressionSyntax(typeOfKeyword, expression, this.parsedInStrictMode()); + }; + + TypeOfExpressionSyntax.create1 = function (expression) { + return new TypeOfExpressionSyntax(TypeScript.Syntax.token(39 /* TypeOfKeyword */), expression, false); + }; + + TypeOfExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + TypeOfExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + TypeOfExpressionSyntax.prototype.withTypeOfKeyword = function (typeOfKeyword) { + return this.update(typeOfKeyword, this.expression); + }; + + TypeOfExpressionSyntax.prototype.withExpression = function (expression) { + return this.update(this.typeOfKeyword, expression); + }; + + TypeOfExpressionSyntax.prototype.isTypeScriptSpecific = function () { + if (this.expression.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return TypeOfExpressionSyntax; + })(TypeScript.SyntaxNode); + TypeScript.TypeOfExpressionSyntax = TypeOfExpressionSyntax; + + var DeleteExpressionSyntax = (function (_super) { + __extends(DeleteExpressionSyntax, _super); + function DeleteExpressionSyntax(deleteKeyword, expression, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.deleteKeyword = deleteKeyword; + this.expression = expression; + } + DeleteExpressionSyntax.prototype.accept = function (visitor) { + return visitor.visitDeleteExpression(this); + }; + + DeleteExpressionSyntax.prototype.kind = function () { + return 169 /* DeleteExpression */; + }; + + DeleteExpressionSyntax.prototype.childCount = function () { + return 2; + }; + + DeleteExpressionSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.deleteKeyword; + case 1: + return this.expression; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + DeleteExpressionSyntax.prototype.isUnaryExpression = function () { + return true; + }; + + DeleteExpressionSyntax.prototype.isExpression = function () { + return true; + }; + + DeleteExpressionSyntax.prototype.update = function (deleteKeyword, expression) { + if (this.deleteKeyword === deleteKeyword && this.expression === expression) { + return this; + } + + return new DeleteExpressionSyntax(deleteKeyword, expression, this.parsedInStrictMode()); + }; + + DeleteExpressionSyntax.create1 = function (expression) { + return new DeleteExpressionSyntax(TypeScript.Syntax.token(21 /* DeleteKeyword */), expression, false); + }; + + DeleteExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + DeleteExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + DeleteExpressionSyntax.prototype.withDeleteKeyword = function (deleteKeyword) { + return this.update(deleteKeyword, this.expression); + }; + + DeleteExpressionSyntax.prototype.withExpression = function (expression) { + return this.update(this.deleteKeyword, expression); + }; + + DeleteExpressionSyntax.prototype.isTypeScriptSpecific = function () { + if (this.expression.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return DeleteExpressionSyntax; + })(TypeScript.SyntaxNode); + TypeScript.DeleteExpressionSyntax = DeleteExpressionSyntax; + + var VoidExpressionSyntax = (function (_super) { + __extends(VoidExpressionSyntax, _super); + function VoidExpressionSyntax(voidKeyword, expression, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.voidKeyword = voidKeyword; + this.expression = expression; + } + VoidExpressionSyntax.prototype.accept = function (visitor) { + return visitor.visitVoidExpression(this); + }; + + VoidExpressionSyntax.prototype.kind = function () { + return 171 /* VoidExpression */; + }; + + VoidExpressionSyntax.prototype.childCount = function () { + return 2; + }; + + VoidExpressionSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.voidKeyword; + case 1: + return this.expression; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + VoidExpressionSyntax.prototype.isUnaryExpression = function () { + return true; + }; + + VoidExpressionSyntax.prototype.isExpression = function () { + return true; + }; + + VoidExpressionSyntax.prototype.update = function (voidKeyword, expression) { + if (this.voidKeyword === voidKeyword && this.expression === expression) { + return this; + } + + return new VoidExpressionSyntax(voidKeyword, expression, this.parsedInStrictMode()); + }; + + VoidExpressionSyntax.create1 = function (expression) { + return new VoidExpressionSyntax(TypeScript.Syntax.token(41 /* VoidKeyword */), expression, false); + }; + + VoidExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + VoidExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + VoidExpressionSyntax.prototype.withVoidKeyword = function (voidKeyword) { + return this.update(voidKeyword, this.expression); + }; + + VoidExpressionSyntax.prototype.withExpression = function (expression) { + return this.update(this.voidKeyword, expression); + }; + + VoidExpressionSyntax.prototype.isTypeScriptSpecific = function () { + if (this.expression.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return VoidExpressionSyntax; + })(TypeScript.SyntaxNode); + TypeScript.VoidExpressionSyntax = VoidExpressionSyntax; + + var DebuggerStatementSyntax = (function (_super) { + __extends(DebuggerStatementSyntax, _super); + function DebuggerStatementSyntax(debuggerKeyword, semicolonToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.debuggerKeyword = debuggerKeyword; + this.semicolonToken = semicolonToken; + } + DebuggerStatementSyntax.prototype.accept = function (visitor) { + return visitor.visitDebuggerStatement(this); + }; + + DebuggerStatementSyntax.prototype.kind = function () { + return 161 /* DebuggerStatement */; + }; + + DebuggerStatementSyntax.prototype.childCount = function () { + return 2; + }; + + DebuggerStatementSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.debuggerKeyword; + case 1: + return this.semicolonToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + DebuggerStatementSyntax.prototype.isStatement = function () { + return true; + }; + + DebuggerStatementSyntax.prototype.isModuleElement = function () { + return true; + }; + + DebuggerStatementSyntax.prototype.update = function (debuggerKeyword, semicolonToken) { + if (this.debuggerKeyword === debuggerKeyword && this.semicolonToken === semicolonToken) { + return this; + } + + return new DebuggerStatementSyntax(debuggerKeyword, semicolonToken, this.parsedInStrictMode()); + }; + + DebuggerStatementSyntax.create1 = function () { + return new DebuggerStatementSyntax(TypeScript.Syntax.token(19 /* DebuggerKeyword */), TypeScript.Syntax.token(78 /* SemicolonToken */), false); + }; + + DebuggerStatementSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + DebuggerStatementSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + DebuggerStatementSyntax.prototype.withDebuggerKeyword = function (debuggerKeyword) { + return this.update(debuggerKeyword, this.semicolonToken); + }; + + DebuggerStatementSyntax.prototype.withSemicolonToken = function (semicolonToken) { + return this.update(this.debuggerKeyword, semicolonToken); + }; + + DebuggerStatementSyntax.prototype.isTypeScriptSpecific = function () { + return false; + }; + return DebuggerStatementSyntax; + })(TypeScript.SyntaxNode); + TypeScript.DebuggerStatementSyntax = DebuggerStatementSyntax; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var SyntaxRewriter = (function () { + function SyntaxRewriter() { + } + SyntaxRewriter.prototype.visitToken = function (token) { + return token; + }; + + SyntaxRewriter.prototype.visitNode = function (node) { + return node.accept(this); + }; + + SyntaxRewriter.prototype.visitNodeOrToken = function (node) { + return node.isToken() ? this.visitToken(node) : this.visitNode(node); + }; + + SyntaxRewriter.prototype.visitList = function (list) { + var newItems = null; + + for (var i = 0, n = list.childCount(); i < n; i++) { + var item = list.childAt(i); + var newItem = this.visitNodeOrToken(item); + + if (item !== newItem && newItems === null) { + newItems = []; + for (var j = 0; j < i; j++) { + newItems.push(list.childAt(j)); + } + } + + if (newItems) { + newItems.push(newItem); + } + } + + return newItems === null ? list : TypeScript.Syntax.list(newItems); + }; + + SyntaxRewriter.prototype.visitSeparatedList = function (list) { + var newItems = null; + + for (var i = 0, n = list.childCount(); i < n; i++) { + var item = list.childAt(i); + var newItem = item.isToken() ? this.visitToken(item) : this.visitNode(item); + + if (item !== newItem && newItems === null) { + newItems = []; + for (var j = 0; j < i; j++) { + newItems.push(list.childAt(j)); + } + } + + if (newItems) { + newItems.push(newItem); + } + } + + return newItems === null ? list : TypeScript.Syntax.separatedList(newItems); + }; + + SyntaxRewriter.prototype.visitSourceUnit = function (node) { + return node.update(this.visitList(node.moduleElements), this.visitToken(node.endOfFileToken)); + }; + + SyntaxRewriter.prototype.visitExternalModuleReference = function (node) { + return node.update(this.visitToken(node.requireKeyword), this.visitToken(node.openParenToken), this.visitToken(node.stringLiteral), this.visitToken(node.closeParenToken)); + }; + + SyntaxRewriter.prototype.visitModuleNameModuleReference = function (node) { + return node.update(this.visitNodeOrToken(node.moduleName)); + }; + + SyntaxRewriter.prototype.visitImportDeclaration = function (node) { + return node.update(this.visitList(node.modifiers), this.visitToken(node.importKeyword), this.visitToken(node.identifier), this.visitToken(node.equalsToken), this.visitNode(node.moduleReference), this.visitToken(node.semicolonToken)); + }; + + SyntaxRewriter.prototype.visitExportAssignment = function (node) { + return node.update(this.visitToken(node.exportKeyword), this.visitToken(node.equalsToken), this.visitToken(node.identifier), this.visitToken(node.semicolonToken)); + }; + + SyntaxRewriter.prototype.visitClassDeclaration = function (node) { + return node.update(this.visitList(node.modifiers), this.visitToken(node.classKeyword), this.visitToken(node.identifier), node.typeParameterList === null ? null : this.visitNode(node.typeParameterList), this.visitList(node.heritageClauses), this.visitToken(node.openBraceToken), this.visitList(node.classElements), this.visitToken(node.closeBraceToken)); + }; + + SyntaxRewriter.prototype.visitInterfaceDeclaration = function (node) { + return node.update(this.visitList(node.modifiers), this.visitToken(node.interfaceKeyword), this.visitToken(node.identifier), node.typeParameterList === null ? null : this.visitNode(node.typeParameterList), this.visitList(node.heritageClauses), this.visitNode(node.body)); + }; + + SyntaxRewriter.prototype.visitHeritageClause = function (node) { + return node.update(this.visitToken(node.extendsOrImplementsKeyword), this.visitSeparatedList(node.typeNames)); + }; + + SyntaxRewriter.prototype.visitModuleDeclaration = function (node) { + return node.update(this.visitList(node.modifiers), this.visitToken(node.moduleKeyword), node.moduleName === null ? null : this.visitNodeOrToken(node.moduleName), node.stringLiteral === null ? null : this.visitToken(node.stringLiteral), this.visitToken(node.openBraceToken), this.visitList(node.moduleElements), this.visitToken(node.closeBraceToken)); + }; + + SyntaxRewriter.prototype.visitFunctionDeclaration = function (node) { + return node.update(this.visitList(node.modifiers), this.visitToken(node.functionKeyword), this.visitToken(node.identifier), this.visitNode(node.callSignature), node.block === null ? null : this.visitNode(node.block), node.semicolonToken === null ? null : this.visitToken(node.semicolonToken)); + }; + + SyntaxRewriter.prototype.visitVariableStatement = function (node) { + return node.update(this.visitList(node.modifiers), this.visitNode(node.variableDeclaration), this.visitToken(node.semicolonToken)); + }; + + SyntaxRewriter.prototype.visitVariableDeclaration = function (node) { + return node.update(this.visitToken(node.varKeyword), this.visitSeparatedList(node.variableDeclarators)); + }; + + SyntaxRewriter.prototype.visitVariableDeclarator = function (node) { + return node.update(this.visitToken(node.identifier), node.typeAnnotation === null ? null : this.visitNode(node.typeAnnotation), node.equalsValueClause === null ? null : this.visitNode(node.equalsValueClause)); + }; + + SyntaxRewriter.prototype.visitEqualsValueClause = function (node) { + return node.update(this.visitToken(node.equalsToken), this.visitNodeOrToken(node.value)); + }; + + SyntaxRewriter.prototype.visitPrefixUnaryExpression = function (node) { + return node.update(node.kind(), this.visitToken(node.operatorToken), this.visitNodeOrToken(node.operand)); + }; + + SyntaxRewriter.prototype.visitArrayLiteralExpression = function (node) { + return node.update(this.visitToken(node.openBracketToken), this.visitSeparatedList(node.expressions), this.visitToken(node.closeBracketToken)); + }; + + SyntaxRewriter.prototype.visitOmittedExpression = function (node) { + return node; + }; + + SyntaxRewriter.prototype.visitParenthesizedExpression = function (node) { + return node.update(this.visitToken(node.openParenToken), this.visitNodeOrToken(node.expression), this.visitToken(node.closeParenToken)); + }; + + SyntaxRewriter.prototype.visitSimpleArrowFunctionExpression = function (node) { + return node.update(this.visitToken(node.identifier), this.visitToken(node.equalsGreaterThanToken), this.visitNodeOrToken(node.body)); + }; + + SyntaxRewriter.prototype.visitParenthesizedArrowFunctionExpression = function (node) { + return node.update(this.visitNode(node.callSignature), this.visitToken(node.equalsGreaterThanToken), this.visitNodeOrToken(node.body)); + }; + + SyntaxRewriter.prototype.visitQualifiedName = function (node) { + return node.update(this.visitNodeOrToken(node.left), this.visitToken(node.dotToken), this.visitToken(node.right)); + }; + + SyntaxRewriter.prototype.visitTypeArgumentList = function (node) { + return node.update(this.visitToken(node.lessThanToken), this.visitSeparatedList(node.typeArguments), this.visitToken(node.greaterThanToken)); + }; + + SyntaxRewriter.prototype.visitConstructorType = function (node) { + return node.update(this.visitToken(node.newKeyword), node.typeParameterList === null ? null : this.visitNode(node.typeParameterList), this.visitNode(node.parameterList), this.visitToken(node.equalsGreaterThanToken), this.visitNodeOrToken(node.type)); + }; + + SyntaxRewriter.prototype.visitFunctionType = function (node) { + return node.update(node.typeParameterList === null ? null : this.visitNode(node.typeParameterList), this.visitNode(node.parameterList), this.visitToken(node.equalsGreaterThanToken), this.visitNodeOrToken(node.type)); + }; + + SyntaxRewriter.prototype.visitObjectType = function (node) { + return node.update(this.visitToken(node.openBraceToken), this.visitSeparatedList(node.typeMembers), this.visitToken(node.closeBraceToken)); + }; + + SyntaxRewriter.prototype.visitArrayType = function (node) { + return node.update(this.visitNodeOrToken(node.type), this.visitToken(node.openBracketToken), this.visitToken(node.closeBracketToken)); + }; + + SyntaxRewriter.prototype.visitGenericType = function (node) { + return node.update(this.visitNodeOrToken(node.name), this.visitNode(node.typeArgumentList)); + }; + + SyntaxRewriter.prototype.visitTypeQuery = function (node) { + return node.update(this.visitToken(node.typeOfKeyword), this.visitNodeOrToken(node.name)); + }; + + SyntaxRewriter.prototype.visitTypeAnnotation = function (node) { + return node.update(this.visitToken(node.colonToken), this.visitNodeOrToken(node.type)); + }; + + SyntaxRewriter.prototype.visitBlock = function (node) { + return node.update(this.visitToken(node.openBraceToken), this.visitList(node.statements), this.visitToken(node.closeBraceToken)); + }; + + SyntaxRewriter.prototype.visitParameter = function (node) { + return node.update(node.dotDotDotToken === null ? null : this.visitToken(node.dotDotDotToken), node.publicOrPrivateKeyword === null ? null : this.visitToken(node.publicOrPrivateKeyword), this.visitToken(node.identifier), node.questionToken === null ? null : this.visitToken(node.questionToken), node.typeAnnotation === null ? null : this.visitNode(node.typeAnnotation), node.equalsValueClause === null ? null : this.visitNode(node.equalsValueClause)); + }; + + SyntaxRewriter.prototype.visitMemberAccessExpression = function (node) { + return node.update(this.visitNodeOrToken(node.expression), this.visitToken(node.dotToken), this.visitToken(node.name)); + }; + + SyntaxRewriter.prototype.visitPostfixUnaryExpression = function (node) { + return node.update(node.kind(), this.visitNodeOrToken(node.operand), this.visitToken(node.operatorToken)); + }; + + SyntaxRewriter.prototype.visitElementAccessExpression = function (node) { + return node.update(this.visitNodeOrToken(node.expression), this.visitToken(node.openBracketToken), this.visitNodeOrToken(node.argumentExpression), this.visitToken(node.closeBracketToken)); + }; + + SyntaxRewriter.prototype.visitInvocationExpression = function (node) { + return node.update(this.visitNodeOrToken(node.expression), this.visitNode(node.argumentList)); + }; + + SyntaxRewriter.prototype.visitArgumentList = function (node) { + return node.update(node.typeArgumentList === null ? null : this.visitNode(node.typeArgumentList), this.visitToken(node.openParenToken), this.visitSeparatedList(node.arguments), this.visitToken(node.closeParenToken)); + }; + + SyntaxRewriter.prototype.visitBinaryExpression = function (node) { + return node.update(node.kind(), this.visitNodeOrToken(node.left), this.visitToken(node.operatorToken), this.visitNodeOrToken(node.right)); + }; + + SyntaxRewriter.prototype.visitConditionalExpression = function (node) { + return node.update(this.visitNodeOrToken(node.condition), this.visitToken(node.questionToken), this.visitNodeOrToken(node.whenTrue), this.visitToken(node.colonToken), this.visitNodeOrToken(node.whenFalse)); + }; + + SyntaxRewriter.prototype.visitConstructSignature = function (node) { + return node.update(this.visitToken(node.newKeyword), this.visitNode(node.callSignature)); + }; + + SyntaxRewriter.prototype.visitMethodSignature = function (node) { + return node.update(this.visitToken(node.propertyName), node.questionToken === null ? null : this.visitToken(node.questionToken), this.visitNode(node.callSignature)); + }; + + SyntaxRewriter.prototype.visitIndexSignature = function (node) { + return node.update(this.visitToken(node.openBracketToken), this.visitNode(node.parameter), this.visitToken(node.closeBracketToken), node.typeAnnotation === null ? null : this.visitNode(node.typeAnnotation)); + }; + + SyntaxRewriter.prototype.visitPropertySignature = function (node) { + return node.update(this.visitToken(node.propertyName), node.questionToken === null ? null : this.visitToken(node.questionToken), node.typeAnnotation === null ? null : this.visitNode(node.typeAnnotation)); + }; + + SyntaxRewriter.prototype.visitCallSignature = function (node) { + return node.update(node.typeParameterList === null ? null : this.visitNode(node.typeParameterList), this.visitNode(node.parameterList), node.typeAnnotation === null ? null : this.visitNode(node.typeAnnotation)); + }; + + SyntaxRewriter.prototype.visitParameterList = function (node) { + return node.update(this.visitToken(node.openParenToken), this.visitSeparatedList(node.parameters), this.visitToken(node.closeParenToken)); + }; + + SyntaxRewriter.prototype.visitTypeParameterList = function (node) { + return node.update(this.visitToken(node.lessThanToken), this.visitSeparatedList(node.typeParameters), this.visitToken(node.greaterThanToken)); + }; + + SyntaxRewriter.prototype.visitTypeParameter = function (node) { + return node.update(this.visitToken(node.identifier), node.constraint === null ? null : this.visitNode(node.constraint)); + }; + + SyntaxRewriter.prototype.visitConstraint = function (node) { + return node.update(this.visitToken(node.extendsKeyword), this.visitNodeOrToken(node.type)); + }; + + SyntaxRewriter.prototype.visitElseClause = function (node) { + return node.update(this.visitToken(node.elseKeyword), this.visitNodeOrToken(node.statement)); + }; + + SyntaxRewriter.prototype.visitIfStatement = function (node) { + return node.update(this.visitToken(node.ifKeyword), this.visitToken(node.openParenToken), this.visitNodeOrToken(node.condition), this.visitToken(node.closeParenToken), this.visitNodeOrToken(node.statement), node.elseClause === null ? null : this.visitNode(node.elseClause)); + }; + + SyntaxRewriter.prototype.visitExpressionStatement = function (node) { + return node.update(this.visitNodeOrToken(node.expression), this.visitToken(node.semicolonToken)); + }; + + SyntaxRewriter.prototype.visitConstructorDeclaration = function (node) { + return node.update(this.visitToken(node.constructorKeyword), this.visitNode(node.parameterList), node.block === null ? null : this.visitNode(node.block), node.semicolonToken === null ? null : this.visitToken(node.semicolonToken)); + }; + + SyntaxRewriter.prototype.visitMemberFunctionDeclaration = function (node) { + return node.update(this.visitList(node.modifiers), this.visitToken(node.propertyName), this.visitNode(node.callSignature), node.block === null ? null : this.visitNode(node.block), node.semicolonToken === null ? null : this.visitToken(node.semicolonToken)); + }; + + SyntaxRewriter.prototype.visitGetMemberAccessorDeclaration = function (node) { + return node.update(this.visitList(node.modifiers), this.visitToken(node.getKeyword), this.visitToken(node.propertyName), this.visitNode(node.parameterList), node.typeAnnotation === null ? null : this.visitNode(node.typeAnnotation), this.visitNode(node.block)); + }; + + SyntaxRewriter.prototype.visitSetMemberAccessorDeclaration = function (node) { + return node.update(this.visitList(node.modifiers), this.visitToken(node.setKeyword), this.visitToken(node.propertyName), this.visitNode(node.parameterList), this.visitNode(node.block)); + }; + + SyntaxRewriter.prototype.visitMemberVariableDeclaration = function (node) { + return node.update(this.visitList(node.modifiers), this.visitNode(node.variableDeclarator), this.visitToken(node.semicolonToken)); + }; + + SyntaxRewriter.prototype.visitThrowStatement = function (node) { + return node.update(this.visitToken(node.throwKeyword), this.visitNodeOrToken(node.expression), this.visitToken(node.semicolonToken)); + }; + + SyntaxRewriter.prototype.visitReturnStatement = function (node) { + return node.update(this.visitToken(node.returnKeyword), node.expression === null ? null : this.visitNodeOrToken(node.expression), this.visitToken(node.semicolonToken)); + }; + + SyntaxRewriter.prototype.visitObjectCreationExpression = function (node) { + return node.update(this.visitToken(node.newKeyword), this.visitNodeOrToken(node.expression), node.argumentList === null ? null : this.visitNode(node.argumentList)); + }; + + SyntaxRewriter.prototype.visitSwitchStatement = function (node) { + return node.update(this.visitToken(node.switchKeyword), this.visitToken(node.openParenToken), this.visitNodeOrToken(node.expression), this.visitToken(node.closeParenToken), this.visitToken(node.openBraceToken), this.visitList(node.switchClauses), this.visitToken(node.closeBraceToken)); + }; + + SyntaxRewriter.prototype.visitCaseSwitchClause = function (node) { + return node.update(this.visitToken(node.caseKeyword), this.visitNodeOrToken(node.expression), this.visitToken(node.colonToken), this.visitList(node.statements)); + }; + + SyntaxRewriter.prototype.visitDefaultSwitchClause = function (node) { + return node.update(this.visitToken(node.defaultKeyword), this.visitToken(node.colonToken), this.visitList(node.statements)); + }; + + SyntaxRewriter.prototype.visitBreakStatement = function (node) { + return node.update(this.visitToken(node.breakKeyword), node.identifier === null ? null : this.visitToken(node.identifier), this.visitToken(node.semicolonToken)); + }; + + SyntaxRewriter.prototype.visitContinueStatement = function (node) { + return node.update(this.visitToken(node.continueKeyword), node.identifier === null ? null : this.visitToken(node.identifier), this.visitToken(node.semicolonToken)); + }; + + SyntaxRewriter.prototype.visitForStatement = function (node) { + return node.update(this.visitToken(node.forKeyword), this.visitToken(node.openParenToken), node.variableDeclaration === null ? null : this.visitNode(node.variableDeclaration), node.initializer === null ? null : this.visitNodeOrToken(node.initializer), this.visitToken(node.firstSemicolonToken), node.condition === null ? null : this.visitNodeOrToken(node.condition), this.visitToken(node.secondSemicolonToken), node.incrementor === null ? null : this.visitNodeOrToken(node.incrementor), this.visitToken(node.closeParenToken), this.visitNodeOrToken(node.statement)); + }; + + SyntaxRewriter.prototype.visitForInStatement = function (node) { + return node.update(this.visitToken(node.forKeyword), this.visitToken(node.openParenToken), node.variableDeclaration === null ? null : this.visitNode(node.variableDeclaration), node.left === null ? null : this.visitNodeOrToken(node.left), this.visitToken(node.inKeyword), this.visitNodeOrToken(node.expression), this.visitToken(node.closeParenToken), this.visitNodeOrToken(node.statement)); + }; + + SyntaxRewriter.prototype.visitWhileStatement = function (node) { + return node.update(this.visitToken(node.whileKeyword), this.visitToken(node.openParenToken), this.visitNodeOrToken(node.condition), this.visitToken(node.closeParenToken), this.visitNodeOrToken(node.statement)); + }; + + SyntaxRewriter.prototype.visitWithStatement = function (node) { + return node.update(this.visitToken(node.withKeyword), this.visitToken(node.openParenToken), this.visitNodeOrToken(node.condition), this.visitToken(node.closeParenToken), this.visitNodeOrToken(node.statement)); + }; + + SyntaxRewriter.prototype.visitEnumDeclaration = function (node) { + return node.update(this.visitList(node.modifiers), this.visitToken(node.enumKeyword), this.visitToken(node.identifier), this.visitToken(node.openBraceToken), this.visitSeparatedList(node.enumElements), this.visitToken(node.closeBraceToken)); + }; + + SyntaxRewriter.prototype.visitEnumElement = function (node) { + return node.update(this.visitToken(node.propertyName), node.equalsValueClause === null ? null : this.visitNode(node.equalsValueClause)); + }; + + SyntaxRewriter.prototype.visitCastExpression = function (node) { + return node.update(this.visitToken(node.lessThanToken), this.visitNodeOrToken(node.type), this.visitToken(node.greaterThanToken), this.visitNodeOrToken(node.expression)); + }; + + SyntaxRewriter.prototype.visitObjectLiteralExpression = function (node) { + return node.update(this.visitToken(node.openBraceToken), this.visitSeparatedList(node.propertyAssignments), this.visitToken(node.closeBraceToken)); + }; + + SyntaxRewriter.prototype.visitSimplePropertyAssignment = function (node) { + return node.update(this.visitToken(node.propertyName), this.visitToken(node.colonToken), this.visitNodeOrToken(node.expression)); + }; + + SyntaxRewriter.prototype.visitFunctionPropertyAssignment = function (node) { + return node.update(this.visitToken(node.propertyName), this.visitNode(node.callSignature), this.visitNode(node.block)); + }; + + SyntaxRewriter.prototype.visitGetAccessorPropertyAssignment = function (node) { + return node.update(this.visitToken(node.getKeyword), this.visitToken(node.propertyName), this.visitToken(node.openParenToken), this.visitToken(node.closeParenToken), node.typeAnnotation === null ? null : this.visitNode(node.typeAnnotation), this.visitNode(node.block)); + }; + + SyntaxRewriter.prototype.visitSetAccessorPropertyAssignment = function (node) { + return node.update(this.visitToken(node.setKeyword), this.visitToken(node.propertyName), this.visitToken(node.openParenToken), this.visitNode(node.parameter), this.visitToken(node.closeParenToken), this.visitNode(node.block)); + }; + + SyntaxRewriter.prototype.visitFunctionExpression = function (node) { + return node.update(this.visitToken(node.functionKeyword), node.identifier === null ? null : this.visitToken(node.identifier), this.visitNode(node.callSignature), this.visitNode(node.block)); + }; + + SyntaxRewriter.prototype.visitEmptyStatement = function (node) { + return node.update(this.visitToken(node.semicolonToken)); + }; + + SyntaxRewriter.prototype.visitTryStatement = function (node) { + return node.update(this.visitToken(node.tryKeyword), this.visitNode(node.block), node.catchClause === null ? null : this.visitNode(node.catchClause), node.finallyClause === null ? null : this.visitNode(node.finallyClause)); + }; + + SyntaxRewriter.prototype.visitCatchClause = function (node) { + return node.update(this.visitToken(node.catchKeyword), this.visitToken(node.openParenToken), this.visitToken(node.identifier), node.typeAnnotation === null ? null : this.visitNode(node.typeAnnotation), this.visitToken(node.closeParenToken), this.visitNode(node.block)); + }; + + SyntaxRewriter.prototype.visitFinallyClause = function (node) { + return node.update(this.visitToken(node.finallyKeyword), this.visitNode(node.block)); + }; + + SyntaxRewriter.prototype.visitLabeledStatement = function (node) { + return node.update(this.visitToken(node.identifier), this.visitToken(node.colonToken), this.visitNodeOrToken(node.statement)); + }; + + SyntaxRewriter.prototype.visitDoStatement = function (node) { + return node.update(this.visitToken(node.doKeyword), this.visitNodeOrToken(node.statement), this.visitToken(node.whileKeyword), this.visitToken(node.openParenToken), this.visitNodeOrToken(node.condition), this.visitToken(node.closeParenToken), this.visitToken(node.semicolonToken)); + }; + + SyntaxRewriter.prototype.visitTypeOfExpression = function (node) { + return node.update(this.visitToken(node.typeOfKeyword), this.visitNodeOrToken(node.expression)); + }; + + SyntaxRewriter.prototype.visitDeleteExpression = function (node) { + return node.update(this.visitToken(node.deleteKeyword), this.visitNodeOrToken(node.expression)); + }; + + SyntaxRewriter.prototype.visitVoidExpression = function (node) { + return node.update(this.visitToken(node.voidKeyword), this.visitNodeOrToken(node.expression)); + }; + + SyntaxRewriter.prototype.visitDebuggerStatement = function (node) { + return node.update(this.visitToken(node.debuggerKeyword), this.visitToken(node.semicolonToken)); + }; + return SyntaxRewriter; + })(); + TypeScript.SyntaxRewriter = SyntaxRewriter; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var SyntaxDedenter = (function (_super) { + __extends(SyntaxDedenter, _super); + function SyntaxDedenter(dedentFirstToken, dedentationAmount, minimumIndent, options) { + _super.call(this); + this.dedentationAmount = dedentationAmount; + this.minimumIndent = minimumIndent; + this.options = options; + this.lastTriviaWasNewLine = dedentFirstToken; + } + SyntaxDedenter.prototype.abort = function () { + this.lastTriviaWasNewLine = false; + this.dedentationAmount = 0; + }; + + SyntaxDedenter.prototype.isAborted = function () { + return this.dedentationAmount === 0; + }; + + SyntaxDedenter.prototype.visitToken = function (token) { + if (token.width() === 0) { + return token; + } + + var result = token; + if (this.lastTriviaWasNewLine) { + result = token.withLeadingTrivia(this.dedentTriviaList(token.leadingTrivia())); + } + + if (this.isAborted()) { + return token; + } + + this.lastTriviaWasNewLine = token.hasTrailingNewLine(); + return result; + }; + + SyntaxDedenter.prototype.dedentTriviaList = function (triviaList) { + var result = []; + var dedentNextWhitespace = true; + + 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() === 4 /* WhitespaceTrivia */) { + var hasFollowingNewLine = (i < triviaList.count() - 1) && triviaList.syntaxTriviaAt(i + 1).kind() === 5 /* NewLineTrivia */; + result.push(this.dedentWhitespace(trivia, hasFollowingNewLine)); + continue; + } else if (trivia.kind() !== 5 /* NewLineTrivia */) { + this.abort(); + break; + } + } + + if (trivia.kind() === 6 /* MultiLineCommentTrivia */) { + result.push(this.dedentMultiLineComment(trivia)); + continue; + } + + result.push(trivia); + if (trivia.kind() === 5 /* NewLineTrivia */) { + dedentNextWhitespace = true; + } + } + + if (dedentNextWhitespace) { + this.abort(); + } + + if (this.isAborted()) { + return triviaList; + } + + return TypeScript.Syntax.triviaList(result); + }; + + SyntaxDedenter.prototype.dedentSegment = function (segment, hasFollowingNewLineTrivia) { + var firstNonWhitespacePosition = TypeScript.Indentation.firstNonWhitespacePosition(segment); + + if (firstNonWhitespacePosition === segment.length) { + if (hasFollowingNewLineTrivia) { + return ""; + } + } else if (TypeScript.CharacterInfo.isLineTerminator(segment.charCodeAt(firstNonWhitespacePosition))) { + return segment.substring(firstNonWhitespacePosition); + } + + var firstNonWhitespaceColumn = TypeScript.Indentation.columnForPositionInString(segment, firstNonWhitespacePosition, this.options); + + var newFirstNonWhitespaceColumn = TypeScript.MathPrototype.min(firstNonWhitespaceColumn, TypeScript.MathPrototype.max(firstNonWhitespaceColumn - this.dedentationAmount, this.minimumIndent)); + + if (newFirstNonWhitespaceColumn === firstNonWhitespaceColumn) { + this.abort(); + return segment; + } + + this.dedentationAmount = firstNonWhitespaceColumn - newFirstNonWhitespaceColumn; + TypeScript.Debug.assert(this.dedentationAmount >= 0); + + var indentationString = TypeScript.Indentation.indentationString(newFirstNonWhitespaceColumn, this.options); + + return indentationString + segment.substring(firstNonWhitespacePosition); + }; + + SyntaxDedenter.prototype.dedentWhitespace = function (trivia, hasFollowingNewLineTrivia) { + var newIndentation = this.dedentSegment(trivia.fullText(), hasFollowingNewLineTrivia); + return TypeScript.Syntax.whitespace(newIndentation); + }; + + SyntaxDedenter.prototype.dedentMultiLineComment = function (trivia) { + var segments = TypeScript.Syntax.splitMultiLineCommentTriviaIntoMultipleLines(trivia); + if (segments.length === 1) { + return trivia; + } + + for (var i = 1; i < segments.length; i++) { + var segment = segments[i]; + segments[i] = this.dedentSegment(segment, false); + } + + var result = segments.join(""); + + return TypeScript.Syntax.multiLineComment(result); + }; + + SyntaxDedenter.dedentNode = function (node, dedentFirstToken, dedentAmount, minimumIndent, options) { + var dedenter = new SyntaxDedenter(dedentFirstToken, dedentAmount, minimumIndent, options); + var result = node.accept(dedenter); + + if (dedenter.isAborted()) { + return node; + } + + return result; + }; + return SyntaxDedenter; + })(TypeScript.SyntaxRewriter); + TypeScript.SyntaxDedenter = SyntaxDedenter; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var SyntaxIndenter = (function (_super) { + __extends(SyntaxIndenter, _super); + function SyntaxIndenter(indentFirstToken, indentationAmount, options) { + _super.call(this); + this.indentationAmount = indentationAmount; + this.options = options; + this.lastTriviaWasNewLine = indentFirstToken; + this.indentationTrivia = TypeScript.Indentation.indentationTrivia(this.indentationAmount, this.options); + } + SyntaxIndenter.prototype.visitToken = function (token) { + if (token.width() === 0) { + return token; + } + + var result = token; + if (this.lastTriviaWasNewLine) { + result = token.withLeadingTrivia(this.indentTriviaList(token.leadingTrivia())); + } + + this.lastTriviaWasNewLine = token.hasTrailingNewLine(); + return result; + }; + + SyntaxIndenter.prototype.indentTriviaList = function (triviaList) { + var result = []; + + 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 6 /* MultiLineCommentTrivia */: + this.indentMultiLineComment(trivia, indentThisTrivia, result); + continue; + + case 7 /* SingleLineCommentTrivia */: + case 8 /* SkippedTokenTrivia */: + this.indentSingleLineOrSkippedText(trivia, indentThisTrivia, result); + continue; + + case 4 /* WhitespaceTrivia */: + this.indentWhitespace(trivia, indentThisTrivia, result); + continue; + + case 5 /* NewLineTrivia */: + result.push(trivia); + indentNextTrivia = true; + continue; + + default: + throw TypeScript.Errors.invalidOperation(); + } + } + + if (indentNextTrivia) { + result.push(this.indentationTrivia); + } + + return TypeScript.Syntax.triviaList(result); + }; + + SyntaxIndenter.prototype.indentSegment = function (segment) { + var firstNonWhitespacePosition = TypeScript.Indentation.firstNonWhitespacePosition(segment); + + if (firstNonWhitespacePosition < segment.length && TypeScript.CharacterInfo.isLineTerminator(segment.charCodeAt(firstNonWhitespacePosition))) { + return segment; + } + + var firstNonWhitespaceColumn = TypeScript.Indentation.columnForPositionInString(segment, firstNonWhitespacePosition, this.options); + + var newFirstNonWhitespaceColumn = firstNonWhitespaceColumn + this.indentationAmount; + + var indentationString = TypeScript.Indentation.indentationString(newFirstNonWhitespaceColumn, this.options); + + return indentationString + segment.substring(firstNonWhitespacePosition); + }; + + SyntaxIndenter.prototype.indentWhitespace = function (trivia, indentThisTrivia, result) { + if (!indentThisTrivia) { + result.push(trivia); + return; + } + + var newIndentation = this.indentSegment(trivia.fullText()); + result.push(TypeScript.Syntax.whitespace(newIndentation)); + }; + + SyntaxIndenter.prototype.indentSingleLineOrSkippedText = function (trivia, indentThisTrivia, result) { + if (indentThisTrivia) { + result.push(this.indentationTrivia); + } + + result.push(trivia); + }; + + SyntaxIndenter.prototype.indentMultiLineComment = function (trivia, indentThisTrivia, result) { + if (indentThisTrivia) { + result.push(this.indentationTrivia); + } + + var segments = TypeScript.Syntax.splitMultiLineCommentTriviaIntoMultipleLines(trivia); + + for (var i = 1; i < segments.length; i++) { + segments[i] = this.indentSegment(segments[i]); + } + + var newText = segments.join(""); + result.push(TypeScript.Syntax.multiLineComment(newText)); + }; + + SyntaxIndenter.indentNode = function (node, indentFirstToken, indentAmount, options) { + var indenter = new SyntaxIndenter(indentFirstToken, indentAmount, options); + return node.accept(indenter); + }; + + SyntaxIndenter.indentNodes = function (nodes, indentFirstToken, indentAmount, options) { + var indenter = new SyntaxIndenter(indentFirstToken, indentAmount, options); + var result = TypeScript.ArrayUtilities.select(nodes, function (n) { + return n.accept(indenter); + }); + + return result; + }; + return SyntaxIndenter; + })(TypeScript.SyntaxRewriter); + TypeScript.SyntaxIndenter = SyntaxIndenter; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (Syntax) { + var VariableWidthTokenWithNoTrivia = (function () { + function VariableWidthTokenWithNoTrivia(sourceText, fullStart, kind, textOrWidth) { + this._sourceText = sourceText; + this._fullStart = fullStart; + this.tokenKind = kind; + this._textOrWidth = textOrWidth; + } + VariableWidthTokenWithNoTrivia.prototype.clone = function () { + return new VariableWidthTokenWithNoTrivia(this._sourceText, this._fullStart, this.tokenKind, this._textOrWidth); + }; + + VariableWidthTokenWithNoTrivia.prototype.isNode = function () { + return false; + }; + VariableWidthTokenWithNoTrivia.prototype.isToken = function () { + return true; + }; + VariableWidthTokenWithNoTrivia.prototype.isList = function () { + return false; + }; + VariableWidthTokenWithNoTrivia.prototype.isSeparatedList = function () { + return false; + }; + + VariableWidthTokenWithNoTrivia.prototype.kind = function () { + return this.tokenKind; + }; + + VariableWidthTokenWithNoTrivia.prototype.childCount = function () { + return 0; + }; + VariableWidthTokenWithNoTrivia.prototype.childAt = function (index) { + throw TypeScript.Errors.argumentOutOfRange('index'); + }; + + VariableWidthTokenWithNoTrivia.prototype.fullWidth = function () { + return this.width(); + }; + VariableWidthTokenWithNoTrivia.prototype.start = function () { + return this._fullStart; + }; + VariableWidthTokenWithNoTrivia.prototype.end = function () { + return this.start() + this.width(); + }; + + VariableWidthTokenWithNoTrivia.prototype.width = function () { + return typeof this._textOrWidth === 'number' ? this._textOrWidth : this._textOrWidth.length; + }; + + VariableWidthTokenWithNoTrivia.prototype.text = function () { + if (typeof this._textOrWidth === 'number') { + this._textOrWidth = this._sourceText.substr(this.start(), this._textOrWidth, this.tokenKind === 11 /* IdentifierName */); + } + + return this._textOrWidth; + }; + + VariableWidthTokenWithNoTrivia.prototype.fullText = function () { + return this._sourceText.substr(this._fullStart, this.fullWidth(), false); + }; + + VariableWidthTokenWithNoTrivia.prototype.value = function () { + if ((this)._value === undefined) { + (this)._value = Syntax.value(this); + } + + return (this)._value; + }; + + VariableWidthTokenWithNoTrivia.prototype.valueText = function () { + if ((this)._valueText === undefined) { + (this)._valueText = Syntax.valueText(this); + } + + return (this)._valueText; + }; + + VariableWidthTokenWithNoTrivia.prototype.hasLeadingTrivia = function () { + return false; + }; + VariableWidthTokenWithNoTrivia.prototype.hasLeadingComment = function () { + return false; + }; + VariableWidthTokenWithNoTrivia.prototype.hasLeadingNewLine = function () { + return false; + }; + VariableWidthTokenWithNoTrivia.prototype.hasLeadingSkippedText = function () { + return false; + }; + VariableWidthTokenWithNoTrivia.prototype.leadingTriviaWidth = function () { + return 0; + }; + VariableWidthTokenWithNoTrivia.prototype.leadingTrivia = function () { + return TypeScript.Syntax.emptyTriviaList; + }; + + VariableWidthTokenWithNoTrivia.prototype.hasTrailingTrivia = function () { + return false; + }; + VariableWidthTokenWithNoTrivia.prototype.hasTrailingComment = function () { + return false; + }; + VariableWidthTokenWithNoTrivia.prototype.hasTrailingNewLine = function () { + return false; + }; + VariableWidthTokenWithNoTrivia.prototype.hasTrailingSkippedText = function () { + return false; + }; + VariableWidthTokenWithNoTrivia.prototype.trailingTriviaWidth = function () { + return 0; + }; + VariableWidthTokenWithNoTrivia.prototype.trailingTrivia = function () { + return TypeScript.Syntax.emptyTriviaList; + }; + + VariableWidthTokenWithNoTrivia.prototype.hasSkippedToken = function () { + return false; + }; + VariableWidthTokenWithNoTrivia.prototype.toJSON = function (key) { + return Syntax.tokenToJSON(this); + }; + VariableWidthTokenWithNoTrivia.prototype.firstToken = function () { + return this; + }; + VariableWidthTokenWithNoTrivia.prototype.lastToken = function () { + return this; + }; + VariableWidthTokenWithNoTrivia.prototype.isTypeScriptSpecific = function () { + return false; + }; + VariableWidthTokenWithNoTrivia.prototype.isIncrementallyUnusable = function () { + return this.fullWidth() === 0 || TypeScript.SyntaxFacts.isAnyDivideOrRegularExpressionToken(this.tokenKind); + }; + VariableWidthTokenWithNoTrivia.prototype.accept = function (visitor) { + return visitor.visitToken(this); + }; + VariableWidthTokenWithNoTrivia.prototype.realize = function () { + return Syntax.realizeToken(this); + }; + VariableWidthTokenWithNoTrivia.prototype.collectTextElements = function (elements) { + collectTokenTextElements(this, elements); + }; + + VariableWidthTokenWithNoTrivia.prototype.findTokenInternal = function (parent, position, fullStart) { + return new TypeScript.PositionedToken(parent, this, fullStart); + }; + + VariableWidthTokenWithNoTrivia.prototype.withLeadingTrivia = function (leadingTrivia) { + return this.realize().withLeadingTrivia(leadingTrivia); + }; + + VariableWidthTokenWithNoTrivia.prototype.withTrailingTrivia = function (trailingTrivia) { + return this.realize().withTrailingTrivia(trailingTrivia); + }; + return VariableWidthTokenWithNoTrivia; + })(); + Syntax.VariableWidthTokenWithNoTrivia = VariableWidthTokenWithNoTrivia; + + var VariableWidthTokenWithLeadingTrivia = (function () { + function VariableWidthTokenWithLeadingTrivia(sourceText, fullStart, kind, leadingTriviaInfo, textOrWidth) { + this._sourceText = sourceText; + this._fullStart = fullStart; + this.tokenKind = kind; + this._leadingTriviaInfo = leadingTriviaInfo; + this._textOrWidth = textOrWidth; + } + VariableWidthTokenWithLeadingTrivia.prototype.clone = function () { + return new VariableWidthTokenWithLeadingTrivia(this._sourceText, this._fullStart, this.tokenKind, this._leadingTriviaInfo, this._textOrWidth); + }; + + VariableWidthTokenWithLeadingTrivia.prototype.isNode = function () { + return false; + }; + VariableWidthTokenWithLeadingTrivia.prototype.isToken = function () { + return true; + }; + VariableWidthTokenWithLeadingTrivia.prototype.isList = function () { + return false; + }; + VariableWidthTokenWithLeadingTrivia.prototype.isSeparatedList = function () { + return false; + }; + + VariableWidthTokenWithLeadingTrivia.prototype.kind = function () { + return this.tokenKind; + }; + + VariableWidthTokenWithLeadingTrivia.prototype.childCount = function () { + return 0; + }; + VariableWidthTokenWithLeadingTrivia.prototype.childAt = function (index) { + throw TypeScript.Errors.argumentOutOfRange('index'); + }; + + VariableWidthTokenWithLeadingTrivia.prototype.fullWidth = function () { + return getTriviaWidth(this._leadingTriviaInfo) + this.width(); + }; + VariableWidthTokenWithLeadingTrivia.prototype.start = function () { + return this._fullStart + getTriviaWidth(this._leadingTriviaInfo); + }; + VariableWidthTokenWithLeadingTrivia.prototype.end = function () { + return this.start() + this.width(); + }; + + VariableWidthTokenWithLeadingTrivia.prototype.width = function () { + return typeof this._textOrWidth === 'number' ? this._textOrWidth : this._textOrWidth.length; + }; + + VariableWidthTokenWithLeadingTrivia.prototype.text = function () { + if (typeof this._textOrWidth === 'number') { + this._textOrWidth = this._sourceText.substr(this.start(), this._textOrWidth, this.tokenKind === 11 /* IdentifierName */); + } + + return this._textOrWidth; + }; + + VariableWidthTokenWithLeadingTrivia.prototype.fullText = function () { + return this._sourceText.substr(this._fullStart, this.fullWidth(), false); + }; + + VariableWidthTokenWithLeadingTrivia.prototype.value = function () { + if ((this)._value === undefined) { + (this)._value = Syntax.value(this); + } + + return (this)._value; + }; + + VariableWidthTokenWithLeadingTrivia.prototype.valueText = function () { + if ((this)._valueText === undefined) { + (this)._valueText = Syntax.valueText(this); + } + + return (this)._valueText; + }; + + VariableWidthTokenWithLeadingTrivia.prototype.hasLeadingTrivia = function () { + return true; + }; + VariableWidthTokenWithLeadingTrivia.prototype.hasLeadingComment = function () { + return hasTriviaComment(this._leadingTriviaInfo); + }; + VariableWidthTokenWithLeadingTrivia.prototype.hasLeadingNewLine = function () { + return hasTriviaNewLine(this._leadingTriviaInfo); + }; + VariableWidthTokenWithLeadingTrivia.prototype.hasLeadingSkippedText = function () { + return false; + }; + VariableWidthTokenWithLeadingTrivia.prototype.leadingTriviaWidth = function () { + return getTriviaWidth(this._leadingTriviaInfo); + }; + VariableWidthTokenWithLeadingTrivia.prototype.leadingTrivia = function () { + return TypeScript.Scanner.scanTrivia(this._sourceText, this._fullStart, getTriviaWidth(this._leadingTriviaInfo), false); + }; + + VariableWidthTokenWithLeadingTrivia.prototype.hasTrailingTrivia = function () { + return false; + }; + VariableWidthTokenWithLeadingTrivia.prototype.hasTrailingComment = function () { + return false; + }; + VariableWidthTokenWithLeadingTrivia.prototype.hasTrailingNewLine = function () { + return false; + }; + VariableWidthTokenWithLeadingTrivia.prototype.hasTrailingSkippedText = function () { + return false; + }; + VariableWidthTokenWithLeadingTrivia.prototype.trailingTriviaWidth = function () { + return 0; + }; + VariableWidthTokenWithLeadingTrivia.prototype.trailingTrivia = function () { + return TypeScript.Syntax.emptyTriviaList; + }; + + VariableWidthTokenWithLeadingTrivia.prototype.hasSkippedToken = function () { + return false; + }; + VariableWidthTokenWithLeadingTrivia.prototype.toJSON = function (key) { + return Syntax.tokenToJSON(this); + }; + VariableWidthTokenWithLeadingTrivia.prototype.firstToken = function () { + return this; + }; + VariableWidthTokenWithLeadingTrivia.prototype.lastToken = function () { + return this; + }; + VariableWidthTokenWithLeadingTrivia.prototype.isTypeScriptSpecific = function () { + return false; + }; + VariableWidthTokenWithLeadingTrivia.prototype.isIncrementallyUnusable = function () { + return this.fullWidth() === 0 || TypeScript.SyntaxFacts.isAnyDivideOrRegularExpressionToken(this.tokenKind); + }; + VariableWidthTokenWithLeadingTrivia.prototype.accept = function (visitor) { + return visitor.visitToken(this); + }; + VariableWidthTokenWithLeadingTrivia.prototype.realize = function () { + return Syntax.realizeToken(this); + }; + VariableWidthTokenWithLeadingTrivia.prototype.collectTextElements = function (elements) { + collectTokenTextElements(this, elements); + }; + + VariableWidthTokenWithLeadingTrivia.prototype.findTokenInternal = function (parent, position, fullStart) { + return new TypeScript.PositionedToken(parent, this, fullStart); + }; + + VariableWidthTokenWithLeadingTrivia.prototype.withLeadingTrivia = function (leadingTrivia) { + return this.realize().withLeadingTrivia(leadingTrivia); + }; + + VariableWidthTokenWithLeadingTrivia.prototype.withTrailingTrivia = function (trailingTrivia) { + return this.realize().withTrailingTrivia(trailingTrivia); + }; + return VariableWidthTokenWithLeadingTrivia; + })(); + Syntax.VariableWidthTokenWithLeadingTrivia = VariableWidthTokenWithLeadingTrivia; + + var VariableWidthTokenWithTrailingTrivia = (function () { + function VariableWidthTokenWithTrailingTrivia(sourceText, fullStart, kind, textOrWidth, trailingTriviaInfo) { + this._sourceText = sourceText; + this._fullStart = fullStart; + this.tokenKind = kind; + this._textOrWidth = textOrWidth; + this._trailingTriviaInfo = trailingTriviaInfo; + } + VariableWidthTokenWithTrailingTrivia.prototype.clone = function () { + return new VariableWidthTokenWithTrailingTrivia(this._sourceText, this._fullStart, this.tokenKind, this._textOrWidth, this._trailingTriviaInfo); + }; + + VariableWidthTokenWithTrailingTrivia.prototype.isNode = function () { + return false; + }; + VariableWidthTokenWithTrailingTrivia.prototype.isToken = function () { + return true; + }; + VariableWidthTokenWithTrailingTrivia.prototype.isList = function () { + return false; + }; + VariableWidthTokenWithTrailingTrivia.prototype.isSeparatedList = function () { + return false; + }; + + VariableWidthTokenWithTrailingTrivia.prototype.kind = function () { + return this.tokenKind; + }; + + VariableWidthTokenWithTrailingTrivia.prototype.childCount = function () { + return 0; + }; + VariableWidthTokenWithTrailingTrivia.prototype.childAt = function (index) { + throw TypeScript.Errors.argumentOutOfRange('index'); + }; + + VariableWidthTokenWithTrailingTrivia.prototype.fullWidth = function () { + return this.width() + getTriviaWidth(this._trailingTriviaInfo); + }; + VariableWidthTokenWithTrailingTrivia.prototype.start = function () { + return this._fullStart; + }; + VariableWidthTokenWithTrailingTrivia.prototype.end = function () { + return this.start() + this.width(); + }; + + VariableWidthTokenWithTrailingTrivia.prototype.width = function () { + return typeof this._textOrWidth === 'number' ? this._textOrWidth : this._textOrWidth.length; + }; + + VariableWidthTokenWithTrailingTrivia.prototype.text = function () { + if (typeof this._textOrWidth === 'number') { + this._textOrWidth = this._sourceText.substr(this.start(), this._textOrWidth, this.tokenKind === 11 /* IdentifierName */); + } + + return this._textOrWidth; + }; + + VariableWidthTokenWithTrailingTrivia.prototype.fullText = function () { + return this._sourceText.substr(this._fullStart, this.fullWidth(), false); + }; + + VariableWidthTokenWithTrailingTrivia.prototype.value = function () { + if ((this)._value === undefined) { + (this)._value = Syntax.value(this); + } + + return (this)._value; + }; + + VariableWidthTokenWithTrailingTrivia.prototype.valueText = function () { + if ((this)._valueText === undefined) { + (this)._valueText = Syntax.valueText(this); + } + + return (this)._valueText; + }; + + VariableWidthTokenWithTrailingTrivia.prototype.hasLeadingTrivia = function () { + return false; + }; + VariableWidthTokenWithTrailingTrivia.prototype.hasLeadingComment = function () { + return false; + }; + VariableWidthTokenWithTrailingTrivia.prototype.hasLeadingNewLine = function () { + return false; + }; + VariableWidthTokenWithTrailingTrivia.prototype.hasLeadingSkippedText = function () { + return false; + }; + VariableWidthTokenWithTrailingTrivia.prototype.leadingTriviaWidth = function () { + return 0; + }; + VariableWidthTokenWithTrailingTrivia.prototype.leadingTrivia = function () { + return TypeScript.Syntax.emptyTriviaList; + }; + + VariableWidthTokenWithTrailingTrivia.prototype.hasTrailingTrivia = function () { + return true; + }; + VariableWidthTokenWithTrailingTrivia.prototype.hasTrailingComment = function () { + return hasTriviaComment(this._trailingTriviaInfo); + }; + VariableWidthTokenWithTrailingTrivia.prototype.hasTrailingNewLine = function () { + return hasTriviaNewLine(this._trailingTriviaInfo); + }; + VariableWidthTokenWithTrailingTrivia.prototype.hasTrailingSkippedText = function () { + return false; + }; + VariableWidthTokenWithTrailingTrivia.prototype.trailingTriviaWidth = function () { + return getTriviaWidth(this._trailingTriviaInfo); + }; + VariableWidthTokenWithTrailingTrivia.prototype.trailingTrivia = function () { + return TypeScript.Scanner.scanTrivia(this._sourceText, this.end(), getTriviaWidth(this._trailingTriviaInfo), true); + }; + + VariableWidthTokenWithTrailingTrivia.prototype.hasSkippedToken = function () { + return false; + }; + VariableWidthTokenWithTrailingTrivia.prototype.toJSON = function (key) { + return Syntax.tokenToJSON(this); + }; + VariableWidthTokenWithTrailingTrivia.prototype.firstToken = function () { + return this; + }; + VariableWidthTokenWithTrailingTrivia.prototype.lastToken = function () { + return this; + }; + VariableWidthTokenWithTrailingTrivia.prototype.isTypeScriptSpecific = function () { + return false; + }; + VariableWidthTokenWithTrailingTrivia.prototype.isIncrementallyUnusable = function () { + return this.fullWidth() === 0 || TypeScript.SyntaxFacts.isAnyDivideOrRegularExpressionToken(this.tokenKind); + }; + VariableWidthTokenWithTrailingTrivia.prototype.accept = function (visitor) { + return visitor.visitToken(this); + }; + VariableWidthTokenWithTrailingTrivia.prototype.realize = function () { + return Syntax.realizeToken(this); + }; + VariableWidthTokenWithTrailingTrivia.prototype.collectTextElements = function (elements) { + collectTokenTextElements(this, elements); + }; + + VariableWidthTokenWithTrailingTrivia.prototype.findTokenInternal = function (parent, position, fullStart) { + return new TypeScript.PositionedToken(parent, this, fullStart); + }; + + VariableWidthTokenWithTrailingTrivia.prototype.withLeadingTrivia = function (leadingTrivia) { + return this.realize().withLeadingTrivia(leadingTrivia); + }; + + VariableWidthTokenWithTrailingTrivia.prototype.withTrailingTrivia = function (trailingTrivia) { + return this.realize().withTrailingTrivia(trailingTrivia); + }; + return VariableWidthTokenWithTrailingTrivia; + })(); + Syntax.VariableWidthTokenWithTrailingTrivia = VariableWidthTokenWithTrailingTrivia; + + var VariableWidthTokenWithLeadingAndTrailingTrivia = (function () { + function VariableWidthTokenWithLeadingAndTrailingTrivia(sourceText, fullStart, kind, leadingTriviaInfo, textOrWidth, trailingTriviaInfo) { + this._sourceText = sourceText; + this._fullStart = fullStart; + this.tokenKind = kind; + this._leadingTriviaInfo = leadingTriviaInfo; + this._textOrWidth = textOrWidth; + this._trailingTriviaInfo = trailingTriviaInfo; + } + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.clone = function () { + return new VariableWidthTokenWithLeadingAndTrailingTrivia(this._sourceText, this._fullStart, this.tokenKind, this._leadingTriviaInfo, this._textOrWidth, this._trailingTriviaInfo); + }; + + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.isNode = function () { + return false; + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.isToken = function () { + return true; + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.isList = function () { + return false; + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.isSeparatedList = function () { + return false; + }; + + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.kind = function () { + return this.tokenKind; + }; + + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.childCount = function () { + return 0; + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.childAt = function (index) { + throw TypeScript.Errors.argumentOutOfRange('index'); + }; + + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.fullWidth = function () { + return getTriviaWidth(this._leadingTriviaInfo) + this.width() + getTriviaWidth(this._trailingTriviaInfo); + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.start = function () { + return this._fullStart + getTriviaWidth(this._leadingTriviaInfo); + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.end = function () { + return this.start() + this.width(); + }; + + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.width = function () { + return typeof this._textOrWidth === 'number' ? this._textOrWidth : this._textOrWidth.length; + }; + + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.text = function () { + if (typeof this._textOrWidth === 'number') { + this._textOrWidth = this._sourceText.substr(this.start(), this._textOrWidth, this.tokenKind === 11 /* IdentifierName */); + } + + return this._textOrWidth; + }; + + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.fullText = function () { + return this._sourceText.substr(this._fullStart, this.fullWidth(), false); + }; + + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.value = function () { + if ((this)._value === undefined) { + (this)._value = Syntax.value(this); + } + + return (this)._value; + }; + + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.valueText = function () { + if ((this)._valueText === undefined) { + (this)._valueText = Syntax.valueText(this); + } + + return (this)._valueText; + }; + + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.hasLeadingTrivia = function () { + return true; + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.hasLeadingComment = function () { + return hasTriviaComment(this._leadingTriviaInfo); + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.hasLeadingNewLine = function () { + return hasTriviaNewLine(this._leadingTriviaInfo); + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.hasLeadingSkippedText = function () { + return false; + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.leadingTriviaWidth = function () { + return getTriviaWidth(this._leadingTriviaInfo); + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.leadingTrivia = function () { + return TypeScript.Scanner.scanTrivia(this._sourceText, this._fullStart, getTriviaWidth(this._leadingTriviaInfo), false); + }; + + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.hasTrailingTrivia = function () { + return true; + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.hasTrailingComment = function () { + return hasTriviaComment(this._trailingTriviaInfo); + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.hasTrailingNewLine = function () { + return hasTriviaNewLine(this._trailingTriviaInfo); + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.hasTrailingSkippedText = function () { + return false; + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.trailingTriviaWidth = function () { + return getTriviaWidth(this._trailingTriviaInfo); + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.trailingTrivia = function () { + return TypeScript.Scanner.scanTrivia(this._sourceText, this.end(), getTriviaWidth(this._trailingTriviaInfo), true); + }; + + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.hasSkippedToken = function () { + return false; + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.toJSON = function (key) { + return Syntax.tokenToJSON(this); + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.firstToken = function () { + return this; + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.lastToken = function () { + return this; + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.isTypeScriptSpecific = function () { + return false; + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.isIncrementallyUnusable = function () { + return this.fullWidth() === 0 || TypeScript.SyntaxFacts.isAnyDivideOrRegularExpressionToken(this.tokenKind); + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.accept = function (visitor) { + return visitor.visitToken(this); + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.realize = function () { + return Syntax.realizeToken(this); + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.collectTextElements = function (elements) { + collectTokenTextElements(this, elements); + }; + + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.findTokenInternal = function (parent, position, fullStart) { + return new TypeScript.PositionedToken(parent, this, fullStart); + }; + + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.withLeadingTrivia = function (leadingTrivia) { + return this.realize().withLeadingTrivia(leadingTrivia); + }; + + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.withTrailingTrivia = function (trailingTrivia) { + return this.realize().withTrailingTrivia(trailingTrivia); + }; + return VariableWidthTokenWithLeadingAndTrailingTrivia; + })(); + Syntax.VariableWidthTokenWithLeadingAndTrailingTrivia = VariableWidthTokenWithLeadingAndTrailingTrivia; + + var FixedWidthTokenWithNoTrivia = (function () { + function FixedWidthTokenWithNoTrivia(kind) { + this.tokenKind = kind; + } + FixedWidthTokenWithNoTrivia.prototype.clone = function () { + return new FixedWidthTokenWithNoTrivia(this.tokenKind); + }; + + FixedWidthTokenWithNoTrivia.prototype.isNode = function () { + return false; + }; + FixedWidthTokenWithNoTrivia.prototype.isToken = function () { + return true; + }; + FixedWidthTokenWithNoTrivia.prototype.isList = function () { + return false; + }; + FixedWidthTokenWithNoTrivia.prototype.isSeparatedList = function () { + return false; + }; + + FixedWidthTokenWithNoTrivia.prototype.kind = function () { + return this.tokenKind; + }; + + FixedWidthTokenWithNoTrivia.prototype.childCount = function () { + return 0; + }; + FixedWidthTokenWithNoTrivia.prototype.childAt = function (index) { + throw TypeScript.Errors.argumentOutOfRange('index'); + }; + + FixedWidthTokenWithNoTrivia.prototype.fullWidth = function () { + return this.width(); + }; + FixedWidthTokenWithNoTrivia.prototype.width = function () { + return this.text().length; + }; + FixedWidthTokenWithNoTrivia.prototype.text = function () { + return TypeScript.SyntaxFacts.getText(this.tokenKind); + }; + FixedWidthTokenWithNoTrivia.prototype.fullText = function () { + return this.text(); + }; + + FixedWidthTokenWithNoTrivia.prototype.value = function () { + return Syntax.value(this); + }; + FixedWidthTokenWithNoTrivia.prototype.valueText = function () { + return Syntax.valueText(this); + }; + FixedWidthTokenWithNoTrivia.prototype.hasLeadingTrivia = function () { + return false; + }; + FixedWidthTokenWithNoTrivia.prototype.hasLeadingComment = function () { + return false; + }; + FixedWidthTokenWithNoTrivia.prototype.hasLeadingNewLine = function () { + return false; + }; + FixedWidthTokenWithNoTrivia.prototype.hasLeadingSkippedText = function () { + return false; + }; + FixedWidthTokenWithNoTrivia.prototype.leadingTriviaWidth = function () { + return 0; + }; + FixedWidthTokenWithNoTrivia.prototype.leadingTrivia = function () { + return TypeScript.Syntax.emptyTriviaList; + }; + + FixedWidthTokenWithNoTrivia.prototype.hasTrailingTrivia = function () { + return false; + }; + FixedWidthTokenWithNoTrivia.prototype.hasTrailingComment = function () { + return false; + }; + FixedWidthTokenWithNoTrivia.prototype.hasTrailingNewLine = function () { + return false; + }; + FixedWidthTokenWithNoTrivia.prototype.hasTrailingSkippedText = function () { + return false; + }; + FixedWidthTokenWithNoTrivia.prototype.trailingTriviaWidth = function () { + return 0; + }; + FixedWidthTokenWithNoTrivia.prototype.trailingTrivia = function () { + return TypeScript.Syntax.emptyTriviaList; + }; + + FixedWidthTokenWithNoTrivia.prototype.hasSkippedToken = function () { + return false; + }; + FixedWidthTokenWithNoTrivia.prototype.toJSON = function (key) { + return Syntax.tokenToJSON(this); + }; + FixedWidthTokenWithNoTrivia.prototype.firstToken = function () { + return this; + }; + FixedWidthTokenWithNoTrivia.prototype.lastToken = function () { + return this; + }; + FixedWidthTokenWithNoTrivia.prototype.isTypeScriptSpecific = function () { + return false; + }; + FixedWidthTokenWithNoTrivia.prototype.isIncrementallyUnusable = function () { + return this.fullWidth() === 0 || TypeScript.SyntaxFacts.isAnyDivideOrRegularExpressionToken(this.tokenKind); + }; + FixedWidthTokenWithNoTrivia.prototype.accept = function (visitor) { + return visitor.visitToken(this); + }; + FixedWidthTokenWithNoTrivia.prototype.realize = function () { + return Syntax.realizeToken(this); + }; + FixedWidthTokenWithNoTrivia.prototype.collectTextElements = function (elements) { + collectTokenTextElements(this, elements); + }; + + FixedWidthTokenWithNoTrivia.prototype.findTokenInternal = function (parent, position, fullStart) { + return new TypeScript.PositionedToken(parent, this, fullStart); + }; + + FixedWidthTokenWithNoTrivia.prototype.withLeadingTrivia = function (leadingTrivia) { + return this.realize().withLeadingTrivia(leadingTrivia); + }; + + FixedWidthTokenWithNoTrivia.prototype.withTrailingTrivia = function (trailingTrivia) { + return this.realize().withTrailingTrivia(trailingTrivia); + }; + return FixedWidthTokenWithNoTrivia; + })(); + Syntax.FixedWidthTokenWithNoTrivia = FixedWidthTokenWithNoTrivia; + + var FixedWidthTokenWithLeadingTrivia = (function () { + function FixedWidthTokenWithLeadingTrivia(sourceText, fullStart, kind, leadingTriviaInfo) { + this._sourceText = sourceText; + this._fullStart = fullStart; + this.tokenKind = kind; + this._leadingTriviaInfo = leadingTriviaInfo; + } + FixedWidthTokenWithLeadingTrivia.prototype.clone = function () { + return new FixedWidthTokenWithLeadingTrivia(this._sourceText, this._fullStart, this.tokenKind, this._leadingTriviaInfo); + }; + + FixedWidthTokenWithLeadingTrivia.prototype.isNode = function () { + return false; + }; + FixedWidthTokenWithLeadingTrivia.prototype.isToken = function () { + return true; + }; + FixedWidthTokenWithLeadingTrivia.prototype.isList = function () { + return false; + }; + FixedWidthTokenWithLeadingTrivia.prototype.isSeparatedList = function () { + return false; + }; + + FixedWidthTokenWithLeadingTrivia.prototype.kind = function () { + return this.tokenKind; + }; + + FixedWidthTokenWithLeadingTrivia.prototype.childCount = function () { + return 0; + }; + FixedWidthTokenWithLeadingTrivia.prototype.childAt = function (index) { + throw TypeScript.Errors.argumentOutOfRange('index'); + }; + + FixedWidthTokenWithLeadingTrivia.prototype.fullWidth = function () { + return getTriviaWidth(this._leadingTriviaInfo) + this.width(); + }; + FixedWidthTokenWithLeadingTrivia.prototype.start = function () { + return this._fullStart + getTriviaWidth(this._leadingTriviaInfo); + }; + FixedWidthTokenWithLeadingTrivia.prototype.end = function () { + return this.start() + this.width(); + }; + + FixedWidthTokenWithLeadingTrivia.prototype.width = function () { + return this.text().length; + }; + FixedWidthTokenWithLeadingTrivia.prototype.text = function () { + return TypeScript.SyntaxFacts.getText(this.tokenKind); + }; + FixedWidthTokenWithLeadingTrivia.prototype.fullText = function () { + return this._sourceText.substr(this._fullStart, this.fullWidth(), false); + }; + + FixedWidthTokenWithLeadingTrivia.prototype.value = function () { + return Syntax.value(this); + }; + FixedWidthTokenWithLeadingTrivia.prototype.valueText = function () { + return Syntax.valueText(this); + }; + FixedWidthTokenWithLeadingTrivia.prototype.hasLeadingTrivia = function () { + return true; + }; + FixedWidthTokenWithLeadingTrivia.prototype.hasLeadingComment = function () { + return hasTriviaComment(this._leadingTriviaInfo); + }; + FixedWidthTokenWithLeadingTrivia.prototype.hasLeadingNewLine = function () { + return hasTriviaNewLine(this._leadingTriviaInfo); + }; + FixedWidthTokenWithLeadingTrivia.prototype.hasLeadingSkippedText = function () { + return false; + }; + FixedWidthTokenWithLeadingTrivia.prototype.leadingTriviaWidth = function () { + return getTriviaWidth(this._leadingTriviaInfo); + }; + FixedWidthTokenWithLeadingTrivia.prototype.leadingTrivia = function () { + return TypeScript.Scanner.scanTrivia(this._sourceText, this._fullStart, getTriviaWidth(this._leadingTriviaInfo), false); + }; + + FixedWidthTokenWithLeadingTrivia.prototype.hasTrailingTrivia = function () { + return false; + }; + FixedWidthTokenWithLeadingTrivia.prototype.hasTrailingComment = function () { + return false; + }; + FixedWidthTokenWithLeadingTrivia.prototype.hasTrailingNewLine = function () { + return false; + }; + FixedWidthTokenWithLeadingTrivia.prototype.hasTrailingSkippedText = function () { + return false; + }; + FixedWidthTokenWithLeadingTrivia.prototype.trailingTriviaWidth = function () { + return 0; + }; + FixedWidthTokenWithLeadingTrivia.prototype.trailingTrivia = function () { + return TypeScript.Syntax.emptyTriviaList; + }; + + FixedWidthTokenWithLeadingTrivia.prototype.hasSkippedToken = function () { + return false; + }; + FixedWidthTokenWithLeadingTrivia.prototype.toJSON = function (key) { + return Syntax.tokenToJSON(this); + }; + FixedWidthTokenWithLeadingTrivia.prototype.firstToken = function () { + return this; + }; + FixedWidthTokenWithLeadingTrivia.prototype.lastToken = function () { + return this; + }; + FixedWidthTokenWithLeadingTrivia.prototype.isTypeScriptSpecific = function () { + return false; + }; + FixedWidthTokenWithLeadingTrivia.prototype.isIncrementallyUnusable = function () { + return this.fullWidth() === 0 || TypeScript.SyntaxFacts.isAnyDivideOrRegularExpressionToken(this.tokenKind); + }; + FixedWidthTokenWithLeadingTrivia.prototype.accept = function (visitor) { + return visitor.visitToken(this); + }; + FixedWidthTokenWithLeadingTrivia.prototype.realize = function () { + return Syntax.realizeToken(this); + }; + FixedWidthTokenWithLeadingTrivia.prototype.collectTextElements = function (elements) { + collectTokenTextElements(this, elements); + }; + + FixedWidthTokenWithLeadingTrivia.prototype.findTokenInternal = function (parent, position, fullStart) { + return new TypeScript.PositionedToken(parent, this, fullStart); + }; + + FixedWidthTokenWithLeadingTrivia.prototype.withLeadingTrivia = function (leadingTrivia) { + return this.realize().withLeadingTrivia(leadingTrivia); + }; + + FixedWidthTokenWithLeadingTrivia.prototype.withTrailingTrivia = function (trailingTrivia) { + return this.realize().withTrailingTrivia(trailingTrivia); + }; + return FixedWidthTokenWithLeadingTrivia; + })(); + Syntax.FixedWidthTokenWithLeadingTrivia = FixedWidthTokenWithLeadingTrivia; + + var FixedWidthTokenWithTrailingTrivia = (function () { + function FixedWidthTokenWithTrailingTrivia(sourceText, fullStart, kind, trailingTriviaInfo) { + this._sourceText = sourceText; + this._fullStart = fullStart; + this.tokenKind = kind; + this._trailingTriviaInfo = trailingTriviaInfo; + } + FixedWidthTokenWithTrailingTrivia.prototype.clone = function () { + return new FixedWidthTokenWithTrailingTrivia(this._sourceText, this._fullStart, this.tokenKind, this._trailingTriviaInfo); + }; + + FixedWidthTokenWithTrailingTrivia.prototype.isNode = function () { + return false; + }; + FixedWidthTokenWithTrailingTrivia.prototype.isToken = function () { + return true; + }; + FixedWidthTokenWithTrailingTrivia.prototype.isList = function () { + return false; + }; + FixedWidthTokenWithTrailingTrivia.prototype.isSeparatedList = function () { + return false; + }; + + FixedWidthTokenWithTrailingTrivia.prototype.kind = function () { + return this.tokenKind; + }; + + FixedWidthTokenWithTrailingTrivia.prototype.childCount = function () { + return 0; + }; + FixedWidthTokenWithTrailingTrivia.prototype.childAt = function (index) { + throw TypeScript.Errors.argumentOutOfRange('index'); + }; + + FixedWidthTokenWithTrailingTrivia.prototype.fullWidth = function () { + return this.width() + getTriviaWidth(this._trailingTriviaInfo); + }; + FixedWidthTokenWithTrailingTrivia.prototype.start = function () { + return this._fullStart; + }; + FixedWidthTokenWithTrailingTrivia.prototype.end = function () { + return this.start() + this.width(); + }; + + FixedWidthTokenWithTrailingTrivia.prototype.width = function () { + return this.text().length; + }; + FixedWidthTokenWithTrailingTrivia.prototype.text = function () { + return TypeScript.SyntaxFacts.getText(this.tokenKind); + }; + FixedWidthTokenWithTrailingTrivia.prototype.fullText = function () { + return this._sourceText.substr(this._fullStart, this.fullWidth(), false); + }; + + FixedWidthTokenWithTrailingTrivia.prototype.value = function () { + return Syntax.value(this); + }; + FixedWidthTokenWithTrailingTrivia.prototype.valueText = function () { + return Syntax.valueText(this); + }; + FixedWidthTokenWithTrailingTrivia.prototype.hasLeadingTrivia = function () { + return false; + }; + FixedWidthTokenWithTrailingTrivia.prototype.hasLeadingComment = function () { + return false; + }; + FixedWidthTokenWithTrailingTrivia.prototype.hasLeadingNewLine = function () { + return false; + }; + FixedWidthTokenWithTrailingTrivia.prototype.hasLeadingSkippedText = function () { + return false; + }; + FixedWidthTokenWithTrailingTrivia.prototype.leadingTriviaWidth = function () { + return 0; + }; + FixedWidthTokenWithTrailingTrivia.prototype.leadingTrivia = function () { + return TypeScript.Syntax.emptyTriviaList; + }; + + FixedWidthTokenWithTrailingTrivia.prototype.hasTrailingTrivia = function () { + return true; + }; + FixedWidthTokenWithTrailingTrivia.prototype.hasTrailingComment = function () { + return hasTriviaComment(this._trailingTriviaInfo); + }; + FixedWidthTokenWithTrailingTrivia.prototype.hasTrailingNewLine = function () { + return hasTriviaNewLine(this._trailingTriviaInfo); + }; + FixedWidthTokenWithTrailingTrivia.prototype.hasTrailingSkippedText = function () { + return false; + }; + FixedWidthTokenWithTrailingTrivia.prototype.trailingTriviaWidth = function () { + return getTriviaWidth(this._trailingTriviaInfo); + }; + FixedWidthTokenWithTrailingTrivia.prototype.trailingTrivia = function () { + return TypeScript.Scanner.scanTrivia(this._sourceText, this.end(), getTriviaWidth(this._trailingTriviaInfo), true); + }; + + FixedWidthTokenWithTrailingTrivia.prototype.hasSkippedToken = function () { + return false; + }; + FixedWidthTokenWithTrailingTrivia.prototype.toJSON = function (key) { + return Syntax.tokenToJSON(this); + }; + FixedWidthTokenWithTrailingTrivia.prototype.firstToken = function () { + return this; + }; + FixedWidthTokenWithTrailingTrivia.prototype.lastToken = function () { + return this; + }; + FixedWidthTokenWithTrailingTrivia.prototype.isTypeScriptSpecific = function () { + return false; + }; + FixedWidthTokenWithTrailingTrivia.prototype.isIncrementallyUnusable = function () { + return this.fullWidth() === 0 || TypeScript.SyntaxFacts.isAnyDivideOrRegularExpressionToken(this.tokenKind); + }; + FixedWidthTokenWithTrailingTrivia.prototype.accept = function (visitor) { + return visitor.visitToken(this); + }; + FixedWidthTokenWithTrailingTrivia.prototype.realize = function () { + return Syntax.realizeToken(this); + }; + FixedWidthTokenWithTrailingTrivia.prototype.collectTextElements = function (elements) { + collectTokenTextElements(this, elements); + }; + + FixedWidthTokenWithTrailingTrivia.prototype.findTokenInternal = function (parent, position, fullStart) { + return new TypeScript.PositionedToken(parent, this, fullStart); + }; + + FixedWidthTokenWithTrailingTrivia.prototype.withLeadingTrivia = function (leadingTrivia) { + return this.realize().withLeadingTrivia(leadingTrivia); + }; + + FixedWidthTokenWithTrailingTrivia.prototype.withTrailingTrivia = function (trailingTrivia) { + return this.realize().withTrailingTrivia(trailingTrivia); + }; + return FixedWidthTokenWithTrailingTrivia; + })(); + Syntax.FixedWidthTokenWithTrailingTrivia = FixedWidthTokenWithTrailingTrivia; + + var FixedWidthTokenWithLeadingAndTrailingTrivia = (function () { + function FixedWidthTokenWithLeadingAndTrailingTrivia(sourceText, fullStart, kind, leadingTriviaInfo, trailingTriviaInfo) { + this._sourceText = sourceText; + this._fullStart = fullStart; + this.tokenKind = kind; + this._leadingTriviaInfo = leadingTriviaInfo; + this._trailingTriviaInfo = trailingTriviaInfo; + } + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.clone = function () { + return new FixedWidthTokenWithLeadingAndTrailingTrivia(this._sourceText, this._fullStart, this.tokenKind, this._leadingTriviaInfo, this._trailingTriviaInfo); + }; + + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.isNode = function () { + return false; + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.isToken = function () { + return true; + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.isList = function () { + return false; + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.isSeparatedList = function () { + return false; + }; + + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.kind = function () { + return this.tokenKind; + }; + + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.childCount = function () { + return 0; + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.childAt = function (index) { + throw TypeScript.Errors.argumentOutOfRange('index'); + }; + + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.fullWidth = function () { + return getTriviaWidth(this._leadingTriviaInfo) + this.width() + getTriviaWidth(this._trailingTriviaInfo); + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.start = function () { + return this._fullStart + getTriviaWidth(this._leadingTriviaInfo); + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.end = function () { + return this.start() + this.width(); + }; + + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.width = function () { + return this.text().length; + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.text = function () { + return TypeScript.SyntaxFacts.getText(this.tokenKind); + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.fullText = function () { + return this._sourceText.substr(this._fullStart, this.fullWidth(), false); + }; + + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.value = function () { + return Syntax.value(this); + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.valueText = function () { + return Syntax.valueText(this); + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.hasLeadingTrivia = function () { + return true; + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.hasLeadingComment = function () { + return hasTriviaComment(this._leadingTriviaInfo); + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.hasLeadingNewLine = function () { + return hasTriviaNewLine(this._leadingTriviaInfo); + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.hasLeadingSkippedText = function () { + return false; + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.leadingTriviaWidth = function () { + return getTriviaWidth(this._leadingTriviaInfo); + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.leadingTrivia = function () { + return TypeScript.Scanner.scanTrivia(this._sourceText, this._fullStart, getTriviaWidth(this._leadingTriviaInfo), false); + }; + + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.hasTrailingTrivia = function () { + return true; + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.hasTrailingComment = function () { + return hasTriviaComment(this._trailingTriviaInfo); + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.hasTrailingNewLine = function () { + return hasTriviaNewLine(this._trailingTriviaInfo); + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.hasTrailingSkippedText = function () { + return false; + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.trailingTriviaWidth = function () { + return getTriviaWidth(this._trailingTriviaInfo); + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.trailingTrivia = function () { + return TypeScript.Scanner.scanTrivia(this._sourceText, this.end(), getTriviaWidth(this._trailingTriviaInfo), true); + }; + + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.hasSkippedToken = function () { + return false; + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.toJSON = function (key) { + return Syntax.tokenToJSON(this); + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.firstToken = function () { + return this; + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.lastToken = function () { + return this; + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.isTypeScriptSpecific = function () { + return false; + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.isIncrementallyUnusable = function () { + return this.fullWidth() === 0 || TypeScript.SyntaxFacts.isAnyDivideOrRegularExpressionToken(this.tokenKind); + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.accept = function (visitor) { + return visitor.visitToken(this); + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.realize = function () { + return Syntax.realizeToken(this); + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.collectTextElements = function (elements) { + collectTokenTextElements(this, elements); + }; + + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.findTokenInternal = function (parent, position, fullStart) { + return new TypeScript.PositionedToken(parent, this, fullStart); + }; + + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.withLeadingTrivia = function (leadingTrivia) { + return this.realize().withLeadingTrivia(leadingTrivia); + }; + + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.withTrailingTrivia = function (trailingTrivia) { + return this.realize().withTrailingTrivia(trailingTrivia); + }; + return FixedWidthTokenWithLeadingAndTrailingTrivia; + })(); + Syntax.FixedWidthTokenWithLeadingAndTrailingTrivia = FixedWidthTokenWithLeadingAndTrailingTrivia; + + function collectTokenTextElements(token, elements) { + token.leadingTrivia().collectTextElements(elements); + elements.push(token.text()); + token.trailingTrivia().collectTextElements(elements); + } + + function fixedWidthToken(sourceText, fullStart, kind, leadingTriviaInfo, trailingTriviaInfo) { + if (leadingTriviaInfo === 0) { + if (trailingTriviaInfo === 0) { + return new FixedWidthTokenWithNoTrivia(kind); + } else { + return new FixedWidthTokenWithTrailingTrivia(sourceText, fullStart, kind, trailingTriviaInfo); + } + } else if (trailingTriviaInfo === 0) { + return new FixedWidthTokenWithLeadingTrivia(sourceText, fullStart, kind, leadingTriviaInfo); + } else { + return new FixedWidthTokenWithLeadingAndTrailingTrivia(sourceText, fullStart, kind, leadingTriviaInfo, trailingTriviaInfo); + } + } + Syntax.fixedWidthToken = fixedWidthToken; + + function variableWidthToken(sourceText, fullStart, kind, leadingTriviaInfo, width, trailingTriviaInfo) { + if (leadingTriviaInfo === 0) { + if (trailingTriviaInfo === 0) { + return new VariableWidthTokenWithNoTrivia(sourceText, fullStart, kind, width); + } else { + return new VariableWidthTokenWithTrailingTrivia(sourceText, fullStart, kind, width, trailingTriviaInfo); + } + } else if (trailingTriviaInfo === 0) { + return new VariableWidthTokenWithLeadingTrivia(sourceText, fullStart, kind, leadingTriviaInfo, width); + } else { + return new VariableWidthTokenWithLeadingAndTrailingTrivia(sourceText, fullStart, kind, leadingTriviaInfo, width, trailingTriviaInfo); + } + } + Syntax.variableWidthToken = variableWidthToken; + + function getTriviaWidth(value) { + return value >>> 2 /* TriviaFullWidthShift */; + } + + function hasTriviaComment(value) { + return (value & 2 /* TriviaCommentMask */) !== 0; + } + + function hasTriviaNewLine(value) { + return (value & 1 /* TriviaNewLineMask */) !== 0; + } + })(TypeScript.Syntax || (TypeScript.Syntax = {})); + var Syntax = TypeScript.Syntax; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (Syntax) { + function realizeToken(token) { + return new RealizedToken(token.tokenKind, token.leadingTrivia(), token.text(), token.value(), token.valueText(), token.trailingTrivia()); + } + Syntax.realizeToken = realizeToken; + + function convertToIdentifierName(token) { + TypeScript.Debug.assert(TypeScript.SyntaxFacts.isAnyKeyword(token.tokenKind)); + return new RealizedToken(11 /* IdentifierName */, token.leadingTrivia(), token.text(), token.text(), token.text(), token.trailingTrivia()); + } + Syntax.convertToIdentifierName = convertToIdentifierName; + + function tokenToJSON(token) { + var result = {}; + + for (var name in TypeScript.SyntaxKind) { + if (TypeScript.SyntaxKind[name] === token.kind()) { + result.kind = name; + break; + } + } + + result.width = token.width(); + if (token.fullWidth() !== token.width()) { + result.fullWidth = token.fullWidth(); + } + + result.text = token.text(); + + var value = token.value(); + if (value !== null) { + result.value = value; + result.valueText = token.valueText(); + } + + if (token.hasLeadingTrivia()) { + result.hasLeadingTrivia = true; + } + + if (token.hasLeadingComment()) { + result.hasLeadingComment = true; + } + + if (token.hasLeadingNewLine()) { + result.hasLeadingNewLine = true; + } + + if (token.hasLeadingSkippedText()) { + result.hasLeadingSkippedText = true; + } + + if (token.hasTrailingTrivia()) { + result.hasTrailingTrivia = true; + } + + if (token.hasTrailingComment()) { + result.hasTrailingComment = true; + } + + if (token.hasTrailingNewLine()) { + result.hasTrailingNewLine = true; + } + + if (token.hasTrailingSkippedText()) { + result.hasTrailingSkippedText = true; + } + + var trivia = token.leadingTrivia(); + if (trivia.count() > 0) { + result.leadingTrivia = trivia; + } + + trivia = token.trailingTrivia(); + if (trivia.count() > 0) { + result.trailingTrivia = trivia; + } + + return result; + } + Syntax.tokenToJSON = tokenToJSON; + + function value(token) { + return value1(token.tokenKind, token.text()); + } + Syntax.value = value; + + function hexValue(text, start, length) { + var intChar = 0; + for (var i = 0; i < length; i++) { + var ch2 = text.charCodeAt(start + i); + if (!TypeScript.CharacterInfo.isHexDigit(ch2)) { + break; + } + + intChar = (intChar << 4) + TypeScript.CharacterInfo.hexValue(ch2); + } + + return intChar; + } + + var characterArray = []; + + function convertEscapes(text) { + characterArray.length = 0; + var result = ""; + + for (var i = 0, n = text.length; i < n; i++) { + var ch = text.charCodeAt(i); + + if (ch === 92 /* backslash */) { + i++; + if (i < n) { + ch = text.charCodeAt(i); + switch (ch) { + case 48 /* _0 */: + characterArray.push(0 /* nullCharacter */); + continue; + + case 98 /* b */: + characterArray.push(8 /* backspace */); + continue; + + case 102 /* f */: + characterArray.push(12 /* formFeed */); + continue; + + case 110 /* n */: + characterArray.push(10 /* lineFeed */); + continue; + + case 114 /* r */: + characterArray.push(13 /* carriageReturn */); + continue; + + case 116 /* t */: + characterArray.push(9 /* tab */); + continue; + + case 118 /* v */: + characterArray.push(11 /* verticalTab */); + continue; + + case 120 /* x */: + characterArray.push(hexValue(text, i + 1, 2)); + i += 2; + continue; + + case 117 /* u */: + characterArray.push(hexValue(text, i + 1, 4)); + i += 4; + continue; + + default: + } + } + } + + characterArray.push(ch); + + if (i && !(i % 1024)) { + result = result.concat(String.fromCharCode.apply(null, characterArray)); + characterArray.length = 0; + } + } + + if (characterArray.length) { + result = result.concat(String.fromCharCode.apply(null, characterArray)); + } + + return result; + } + + function massageEscapes(text) { + return text.indexOf("\\") >= 0 ? convertEscapes(text) : text; + } + Syntax.massageEscapes = massageEscapes; + + function value1(kind, text) { + if (kind === 11 /* IdentifierName */) { + return massageEscapes(text); + } + + switch (kind) { + case 37 /* TrueKeyword */: + return true; + case 24 /* FalseKeyword */: + return false; + case 32 /* NullKeyword */: + return null; + } + + if (TypeScript.SyntaxFacts.isAnyKeyword(kind) || TypeScript.SyntaxFacts.isAnyPunctuation(kind)) { + return TypeScript.SyntaxFacts.getText(kind); + } + + if (kind === 13 /* NumericLiteral */) { + return Syntax.isHexInteger(text) ? parseInt(text, 16) : parseFloat(text); + } else if (kind === 14 /* StringLiteral */) { + if (text.length > 1 && text.charCodeAt(text.length - 1) === text.charCodeAt(0)) { + return massageEscapes(text.substr(1, text.length - 2)); + } else { + return massageEscapes(text.substr(1)); + } + } else if (kind === 12 /* RegularExpressionLiteral */) { + 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 null; + } + } else if (kind === 10 /* EndOfFileToken */ || kind === 9 /* ErrorToken */) { + return null; + } else { + throw TypeScript.Errors.invalidOperation(); + } + } + + function valueText1(kind, text) { + var value = value1(kind, text); + return value === null ? "" : value.toString(); + } + + function valueText(token) { + var value = token.value(); + return value === null ? "" : value.toString(); + } + Syntax.valueText = valueText; + + var EmptyToken = (function () { + function EmptyToken(kind) { + this.tokenKind = kind; + } + EmptyToken.prototype.clone = function () { + return new EmptyToken(this.tokenKind); + }; + + EmptyToken.prototype.kind = function () { + return this.tokenKind; + }; + + EmptyToken.prototype.isToken = function () { + return true; + }; + EmptyToken.prototype.isNode = function () { + return false; + }; + EmptyToken.prototype.isList = function () { + return false; + }; + EmptyToken.prototype.isSeparatedList = function () { + return false; + }; + + EmptyToken.prototype.childCount = function () { + return 0; + }; + + EmptyToken.prototype.childAt = function (index) { + throw TypeScript.Errors.argumentOutOfRange("index"); + }; + + EmptyToken.prototype.toJSON = function (key) { + return tokenToJSON(this); + }; + EmptyToken.prototype.accept = function (visitor) { + return visitor.visitToken(this); + }; + + EmptyToken.prototype.findTokenInternal = function (parent, position, fullStart) { + return new TypeScript.PositionedToken(parent, this, fullStart); + }; + + EmptyToken.prototype.firstToken = function () { + return this; + }; + EmptyToken.prototype.lastToken = function () { + return this; + }; + EmptyToken.prototype.isTypeScriptSpecific = function () { + return false; + }; + + EmptyToken.prototype.isIncrementallyUnusable = function () { + return true; + }; + + EmptyToken.prototype.fullWidth = function () { + return 0; + }; + EmptyToken.prototype.width = function () { + return 0; + }; + EmptyToken.prototype.text = function () { + return ""; + }; + EmptyToken.prototype.fullText = function () { + return ""; + }; + EmptyToken.prototype.value = function () { + return null; + }; + EmptyToken.prototype.valueText = function () { + return ""; + }; + + EmptyToken.prototype.hasLeadingTrivia = function () { + return false; + }; + EmptyToken.prototype.hasLeadingComment = function () { + return false; + }; + EmptyToken.prototype.hasLeadingNewLine = function () { + return false; + }; + EmptyToken.prototype.hasLeadingSkippedText = function () { + return false; + }; + EmptyToken.prototype.leadingTriviaWidth = function () { + return 0; + }; + EmptyToken.prototype.hasTrailingTrivia = function () { + return false; + }; + EmptyToken.prototype.hasTrailingComment = function () { + return false; + }; + EmptyToken.prototype.hasTrailingNewLine = function () { + return false; + }; + EmptyToken.prototype.hasTrailingSkippedText = function () { + return false; + }; + EmptyToken.prototype.hasSkippedToken = function () { + return false; + }; + + EmptyToken.prototype.trailingTriviaWidth = function () { + return 0; + }; + EmptyToken.prototype.leadingTrivia = function () { + return TypeScript.Syntax.emptyTriviaList; + }; + EmptyToken.prototype.trailingTrivia = function () { + return TypeScript.Syntax.emptyTriviaList; + }; + EmptyToken.prototype.realize = function () { + return realizeToken(this); + }; + EmptyToken.prototype.collectTextElements = function (elements) { + }; + + EmptyToken.prototype.withLeadingTrivia = function (leadingTrivia) { + return this.realize().withLeadingTrivia(leadingTrivia); + }; + + EmptyToken.prototype.withTrailingTrivia = function (trailingTrivia) { + return this.realize().withTrailingTrivia(trailingTrivia); + }; + return EmptyToken; + })(); + + function emptyToken(kind) { + return new EmptyToken(kind); + } + Syntax.emptyToken = emptyToken; + + var RealizedToken = (function () { + function RealizedToken(tokenKind, leadingTrivia, text, value, valueText, trailingTrivia) { + this.tokenKind = tokenKind; + this._leadingTrivia = leadingTrivia; + this._text = text; + this._value = value; + this._valueText = valueText; + this._trailingTrivia = trailingTrivia; + } + RealizedToken.prototype.clone = function () { + return new RealizedToken(this.tokenKind, this._leadingTrivia, this._text, this._value, this._valueText, this._trailingTrivia); + }; + + RealizedToken.prototype.kind = function () { + return this.tokenKind; + }; + RealizedToken.prototype.toJSON = function (key) { + return tokenToJSON(this); + }; + RealizedToken.prototype.firstToken = function () { + return this; + }; + RealizedToken.prototype.lastToken = function () { + return this; + }; + RealizedToken.prototype.isTypeScriptSpecific = function () { + return false; + }; + + RealizedToken.prototype.isIncrementallyUnusable = function () { + return true; + }; + + RealizedToken.prototype.accept = function (visitor) { + return visitor.visitToken(this); + }; + + RealizedToken.prototype.childCount = function () { + return 0; + }; + + RealizedToken.prototype.childAt = function (index) { + throw TypeScript.Errors.argumentOutOfRange("index"); + }; + + RealizedToken.prototype.isToken = function () { + return true; + }; + RealizedToken.prototype.isNode = function () { + return false; + }; + RealizedToken.prototype.isList = function () { + return false; + }; + RealizedToken.prototype.isSeparatedList = function () { + return false; + }; + RealizedToken.prototype.isTrivia = function () { + return false; + }; + RealizedToken.prototype.isTriviaList = function () { + return false; + }; + + RealizedToken.prototype.fullWidth = function () { + return this._leadingTrivia.fullWidth() + this.width() + this._trailingTrivia.fullWidth(); + }; + RealizedToken.prototype.width = function () { + return this.text().length; + }; + + RealizedToken.prototype.text = function () { + return this._text; + }; + RealizedToken.prototype.fullText = function () { + return this._leadingTrivia.fullText() + this.text() + this._trailingTrivia.fullText(); + }; + + RealizedToken.prototype.value = function () { + return this._value; + }; + RealizedToken.prototype.valueText = function () { + return this._valueText; + }; + + RealizedToken.prototype.hasLeadingTrivia = function () { + return this._leadingTrivia.count() > 0; + }; + RealizedToken.prototype.hasLeadingComment = function () { + return this._leadingTrivia.hasComment(); + }; + RealizedToken.prototype.hasLeadingNewLine = function () { + return this._leadingTrivia.hasNewLine(); + }; + RealizedToken.prototype.hasLeadingSkippedText = function () { + return this._leadingTrivia.hasSkippedToken(); + }; + RealizedToken.prototype.leadingTriviaWidth = function () { + return this._leadingTrivia.fullWidth(); + }; + + RealizedToken.prototype.hasTrailingTrivia = function () { + return this._trailingTrivia.count() > 0; + }; + RealizedToken.prototype.hasTrailingComment = function () { + return this._trailingTrivia.hasComment(); + }; + RealizedToken.prototype.hasTrailingNewLine = function () { + return this._trailingTrivia.hasNewLine(); + }; + RealizedToken.prototype.hasTrailingSkippedText = function () { + return this._trailingTrivia.hasSkippedToken(); + }; + RealizedToken.prototype.trailingTriviaWidth = function () { + return this._trailingTrivia.fullWidth(); + }; + + RealizedToken.prototype.hasSkippedToken = function () { + return this.hasLeadingSkippedText() || this.hasTrailingSkippedText(); + }; + + RealizedToken.prototype.leadingTrivia = function () { + return this._leadingTrivia; + }; + RealizedToken.prototype.trailingTrivia = function () { + return this._trailingTrivia; + }; + + RealizedToken.prototype.findTokenInternal = function (parent, position, fullStart) { + return new TypeScript.PositionedToken(parent, this, fullStart); + }; + + RealizedToken.prototype.collectTextElements = function (elements) { + this.leadingTrivia().collectTextElements(elements); + elements.push(this.text()); + this.trailingTrivia().collectTextElements(elements); + }; + + RealizedToken.prototype.withLeadingTrivia = function (leadingTrivia) { + return new RealizedToken(this.tokenKind, leadingTrivia, this._text, this._value, this._valueText, this._trailingTrivia); + }; + + RealizedToken.prototype.withTrailingTrivia = function (trailingTrivia) { + return new RealizedToken(this.tokenKind, this._leadingTrivia, this._text, this._value, this._valueText, trailingTrivia); + }; + return RealizedToken; + })(); + + function token(kind, info) { + if (typeof info === "undefined") { info = null; } + var text = (info !== null && info.text !== undefined) ? info.text : TypeScript.SyntaxFacts.getText(kind); + + return new RealizedToken(kind, TypeScript.Syntax.triviaList(info === null ? null : info.leadingTrivia), text, value1(kind, text), valueText1(kind, text), TypeScript.Syntax.triviaList(info === null ? null : info.trailingTrivia)); + } + Syntax.token = token; + + function identifier(text, info) { + if (typeof info === "undefined") { info = null; } + info = info || {}; + info.text = text; + return token(11 /* IdentifierName */, info); + } + Syntax.identifier = identifier; + })(TypeScript.Syntax || (TypeScript.Syntax = {})); + var Syntax = TypeScript.Syntax; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var SyntaxTokenReplacer = (function (_super) { + __extends(SyntaxTokenReplacer, _super); + function SyntaxTokenReplacer(token1, token2) { + _super.call(this); + this.token1 = token1; + this.token2 = token2; + } + SyntaxTokenReplacer.prototype.visitToken = function (token) { + if (token === this.token1) { + var result = this.token2; + this.token1 = null; + this.token2 = null; + + return result; + } + + return token; + }; + + SyntaxTokenReplacer.prototype.visitNode = function (node) { + if (this.token1 === null) { + return node; + } + + return _super.prototype.visitNode.call(this, node); + }; + + SyntaxTokenReplacer.prototype.visitList = function (list) { + if (this.token1 === null) { + return list; + } + + return _super.prototype.visitList.call(this, list); + }; + + SyntaxTokenReplacer.prototype.visitSeparatedList = function (list) { + if (this.token1 === null) { + return list; + } + + return _super.prototype.visitSeparatedList.call(this, list); + }; + return SyntaxTokenReplacer; + })(TypeScript.SyntaxRewriter); + TypeScript.SyntaxTokenReplacer = SyntaxTokenReplacer; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (Syntax) { + var SyntaxTrivia = (function () { + function SyntaxTrivia(kind, textOrToken) { + this._kind = kind; + this._textOrToken = textOrToken; + } + SyntaxTrivia.prototype.toJSON = function (key) { + var result = {}; + result.kind = TypeScript.SyntaxKind[this._kind]; + + if (this.isSkippedToken()) { + result.skippedToken = this._textOrToken; + } else { + result.text = this._textOrToken; + } + return result; + }; + + SyntaxTrivia.prototype.kind = function () { + return this._kind; + }; + + SyntaxTrivia.prototype.fullWidth = function () { + return this.fullText().length; + }; + + SyntaxTrivia.prototype.fullText = function () { + return this.isSkippedToken() ? this.skippedToken().fullText() : this._textOrToken; + }; + + SyntaxTrivia.prototype.isWhitespace = function () { + return this.kind() === 4 /* WhitespaceTrivia */; + }; + + SyntaxTrivia.prototype.isComment = function () { + return this.kind() === 7 /* SingleLineCommentTrivia */ || this.kind() === 6 /* MultiLineCommentTrivia */; + }; + + SyntaxTrivia.prototype.isNewLine = function () { + return this.kind() === 5 /* NewLineTrivia */; + }; + + SyntaxTrivia.prototype.isSkippedToken = function () { + return this.kind() === 8 /* SkippedTokenTrivia */; + }; + + SyntaxTrivia.prototype.skippedToken = function () { + TypeScript.Debug.assert(this.isSkippedToken()); + return this._textOrToken; + }; + + SyntaxTrivia.prototype.collectTextElements = function (elements) { + elements.push(this.fullText()); + }; + return SyntaxTrivia; + })(); + + function trivia(kind, text) { + return new SyntaxTrivia(kind, text); + } + Syntax.trivia = trivia; + + function skippedTokenTrivia(token) { + TypeScript.Debug.assert(!token.hasLeadingTrivia()); + TypeScript.Debug.assert(!token.hasTrailingTrivia()); + TypeScript.Debug.assert(token.fullWidth() > 0); + return new SyntaxTrivia(8 /* SkippedTokenTrivia */, token); + } + Syntax.skippedTokenTrivia = skippedTokenTrivia; + + function spaces(count) { + return trivia(4 /* WhitespaceTrivia */, TypeScript.StringUtilities.repeat(" ", count)); + } + Syntax.spaces = spaces; + + function whitespace(text) { + return trivia(4 /* WhitespaceTrivia */, text); + } + Syntax.whitespace = whitespace; + + function multiLineComment(text) { + return trivia(6 /* MultiLineCommentTrivia */, text); + } + Syntax.multiLineComment = multiLineComment; + + function singleLineComment(text) { + return trivia(7 /* SingleLineCommentTrivia */, text); + } + Syntax.singleLineComment = singleLineComment; + + Syntax.spaceTrivia = spaces(1); + Syntax.lineFeedTrivia = trivia(5 /* NewLineTrivia */, "\n"); + Syntax.carriageReturnTrivia = trivia(5 /* NewLineTrivia */, "\r"); + Syntax.carriageReturnLineFeedTrivia = trivia(5 /* NewLineTrivia */, "\r\n"); + + function splitMultiLineCommentTriviaIntoMultipleLines(trivia) { + var result = []; + + var triviaText = trivia.fullText(); + var currentIndex = 0; + + for (var i = 0; i < triviaText.length; i++) { + var ch = triviaText.charCodeAt(i); + + var isCarriageReturnLineFeed = false; + switch (ch) { + case 13 /* carriageReturn */: + if (i < triviaText.length - 1 && triviaText.charCodeAt(i + 1) === 10 /* lineFeed */) { + i++; + } + + case 10 /* lineFeed */: + case 8233 /* paragraphSeparator */: + case 8232 /* lineSeparator */: + result.push(triviaText.substring(currentIndex, i + 1)); + + currentIndex = i + 1; + continue; + } + } + + result.push(triviaText.substring(currentIndex)); + return result; + } + Syntax.splitMultiLineCommentTriviaIntoMultipleLines = splitMultiLineCommentTriviaIntoMultipleLines; + })(TypeScript.Syntax || (TypeScript.Syntax = {})); + var Syntax = TypeScript.Syntax; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (Syntax) { + Syntax.emptyTriviaList = { + kind: function () { + return 3 /* TriviaList */; + }, + count: function () { + return 0; + }, + syntaxTriviaAt: function (index) { + throw TypeScript.Errors.argumentOutOfRange("index"); + }, + last: function () { + throw TypeScript.Errors.argumentOutOfRange("index"); + }, + fullWidth: function () { + return 0; + }, + fullText: function () { + return ""; + }, + hasComment: function () { + return false; + }, + hasNewLine: function () { + return false; + }, + hasSkippedToken: function () { + return false; + }, + toJSON: function (key) { + return []; + }, + collectTextElements: function (elements) { + }, + toArray: function () { + return []; + }, + concat: function (trivia) { + return trivia; + } + }; + + function concatTrivia(list1, list2) { + if (list1.count() === 0) { + return list2; + } + + if (list2.count() === 0) { + return list1; + } + + var trivia = list1.toArray(); + trivia.push.apply(trivia, list2.toArray()); + + return triviaList(trivia); + } + + function isComment(trivia) { + return trivia.kind() === 6 /* MultiLineCommentTrivia */ || trivia.kind() === 7 /* SingleLineCommentTrivia */; + } + + var SingletonSyntaxTriviaList = (function () { + function SingletonSyntaxTriviaList(item) { + this.item = item; + } + SingletonSyntaxTriviaList.prototype.kind = function () { + return 3 /* TriviaList */; + }; + + SingletonSyntaxTriviaList.prototype.count = function () { + return 1; + }; + + SingletonSyntaxTriviaList.prototype.syntaxTriviaAt = function (index) { + if (index !== 0) { + throw TypeScript.Errors.argumentOutOfRange("index"); + } + + return this.item; + }; + + SingletonSyntaxTriviaList.prototype.last = function () { + return this.item; + }; + + SingletonSyntaxTriviaList.prototype.fullWidth = function () { + return this.item.fullWidth(); + }; + + SingletonSyntaxTriviaList.prototype.fullText = function () { + return this.item.fullText(); + }; + + SingletonSyntaxTriviaList.prototype.hasComment = function () { + return isComment(this.item); + }; + + SingletonSyntaxTriviaList.prototype.hasNewLine = function () { + return this.item.kind() === 5 /* NewLineTrivia */; + }; + + SingletonSyntaxTriviaList.prototype.hasSkippedToken = function () { + return this.item.kind() === 8 /* SkippedTokenTrivia */; + }; + + SingletonSyntaxTriviaList.prototype.toJSON = function (key) { + return [this.item]; + }; + + SingletonSyntaxTriviaList.prototype.collectTextElements = function (elements) { + (this.item).collectTextElements(elements); + }; + + SingletonSyntaxTriviaList.prototype.toArray = function () { + return [this.item]; + }; + + SingletonSyntaxTriviaList.prototype.concat = function (trivia) { + return concatTrivia(this, trivia); + }; + return SingletonSyntaxTriviaList; + })(); + + var NormalSyntaxTriviaList = (function () { + function NormalSyntaxTriviaList(trivia) { + this.trivia = trivia; + } + NormalSyntaxTriviaList.prototype.kind = function () { + return 3 /* TriviaList */; + }; + + NormalSyntaxTriviaList.prototype.count = function () { + return this.trivia.length; + }; + + NormalSyntaxTriviaList.prototype.syntaxTriviaAt = function (index) { + if (index < 0 || index >= this.trivia.length) { + throw TypeScript.Errors.argumentOutOfRange("index"); + } + + return this.trivia[index]; + }; + + NormalSyntaxTriviaList.prototype.last = function () { + return this.trivia[this.trivia.length - 1]; + }; + + NormalSyntaxTriviaList.prototype.fullWidth = function () { + return TypeScript.ArrayUtilities.sum(this.trivia, function (t) { + return t.fullWidth(); + }); + }; + + NormalSyntaxTriviaList.prototype.fullText = function () { + var result = ""; + + for (var i = 0, n = this.trivia.length; i < n; i++) { + result += this.trivia[i].fullText(); + } + + return result; + }; + + NormalSyntaxTriviaList.prototype.hasComment = function () { + for (var i = 0; i < this.trivia.length; i++) { + if (isComment(this.trivia[i])) { + return true; + } + } + + return false; + }; + + NormalSyntaxTriviaList.prototype.hasNewLine = function () { + for (var i = 0; i < this.trivia.length; i++) { + if (this.trivia[i].kind() === 5 /* NewLineTrivia */) { + return true; + } + } + + return false; + }; + + NormalSyntaxTriviaList.prototype.hasSkippedToken = function () { + for (var i = 0; i < this.trivia.length; i++) { + if (this.trivia[i].kind() === 8 /* SkippedTokenTrivia */) { + return true; + } + } + + return false; + }; + + NormalSyntaxTriviaList.prototype.toJSON = function (key) { + return this.trivia; + }; + + NormalSyntaxTriviaList.prototype.collectTextElements = function (elements) { + for (var i = 0; i < this.trivia.length; i++) { + (this.trivia[i]).collectTextElements(elements); + } + }; + + NormalSyntaxTriviaList.prototype.toArray = function () { + return this.trivia.slice(0); + }; + + NormalSyntaxTriviaList.prototype.concat = function (trivia) { + return concatTrivia(this, trivia); + }; + return NormalSyntaxTriviaList; + })(); + + function triviaList(trivia) { + if (trivia === undefined || trivia === null || trivia.length === 0) { + return TypeScript.Syntax.emptyTriviaList; + } + + if (trivia.length === 1) { + return new SingletonSyntaxTriviaList(trivia[0]); + } + + return new NormalSyntaxTriviaList(trivia); + } + Syntax.triviaList = triviaList; + + Syntax.spaceTriviaList = triviaList([TypeScript.Syntax.spaceTrivia]); + })(TypeScript.Syntax || (TypeScript.Syntax = {})); + var Syntax = TypeScript.Syntax; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var SyntaxUtilities = (function () { + function SyntaxUtilities() { + } + SyntaxUtilities.isAngleBracket = function (positionedElement) { + var element = positionedElement.element(); + var parent = positionedElement.parentElement(); + if (parent !== null && (element.kind() === 80 /* LessThanToken */ || element.kind() === 81 /* GreaterThanToken */)) { + switch (parent.kind()) { + case 227 /* TypeArgumentList */: + case 228 /* TypeParameterList */: + case 219 /* CastExpression */: + return true; + } + } + + return false; + }; + + SyntaxUtilities.getToken = function (list, kind) { + for (var i = 0, n = list.childCount(); i < n; i++) { + var token = list.childAt(i); + if (token.tokenKind === kind) { + return token; + } + } + + return null; + }; + + SyntaxUtilities.containsToken = function (list, kind) { + return SyntaxUtilities.getToken(list, kind) !== null; + }; + + SyntaxUtilities.hasExportKeyword = function (moduleElement) { + return SyntaxUtilities.getExportKeyword(moduleElement) !== null; + }; + + SyntaxUtilities.getExportKeyword = function (moduleElement) { + switch (moduleElement.kind()) { + case 130 /* ModuleDeclaration */: + case 131 /* ClassDeclaration */: + case 129 /* FunctionDeclaration */: + case 147 /* VariableStatement */: + case 132 /* EnumDeclaration */: + case 128 /* InterfaceDeclaration */: + case 133 /* ImportDeclaration */: + return SyntaxUtilities.getToken((moduleElement).modifiers, 47 /* ExportKeyword */); + default: + return null; + } + }; + + SyntaxUtilities.isAmbientDeclarationSyntax = function (positionNode) { + if (!positionNode) { + return false; + } + + var node = positionNode.node(); + switch (node.kind()) { + case 130 /* ModuleDeclaration */: + case 131 /* ClassDeclaration */: + case 129 /* FunctionDeclaration */: + case 147 /* VariableStatement */: + case 132 /* EnumDeclaration */: + if (SyntaxUtilities.containsToken((node).modifiers, 63 /* DeclareKeyword */)) { + return true; + } + + case 133 /* ImportDeclaration */: + case 137 /* ConstructorDeclaration */: + case 135 /* MemberFunctionDeclaration */: + case 138 /* GetMemberAccessorDeclaration */: + case 139 /* SetMemberAccessorDeclaration */: + case 136 /* MemberVariableDeclaration */: + if (node.isClassElement() || node.isModuleElement()) { + return SyntaxUtilities.isAmbientDeclarationSyntax(positionNode.containingNode()); + } + + case 243 /* EnumElement */: + return SyntaxUtilities.isAmbientDeclarationSyntax(positionNode.containingNode().containingNode()); + + default: + return SyntaxUtilities.isAmbientDeclarationSyntax(positionNode.containingNode()); + } + }; + return SyntaxUtilities; + })(); + TypeScript.SyntaxUtilities = SyntaxUtilities; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var SyntaxVisitor = (function () { + function SyntaxVisitor() { + } + SyntaxVisitor.prototype.defaultVisit = function (node) { + return null; + }; + + SyntaxVisitor.prototype.visitToken = function (token) { + return this.defaultVisit(token); + }; + + SyntaxVisitor.prototype.visitSourceUnit = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitExternalModuleReference = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitModuleNameModuleReference = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitImportDeclaration = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitExportAssignment = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitClassDeclaration = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitInterfaceDeclaration = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitHeritageClause = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitModuleDeclaration = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitFunctionDeclaration = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitVariableStatement = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitVariableDeclaration = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitVariableDeclarator = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitEqualsValueClause = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitPrefixUnaryExpression = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitArrayLiteralExpression = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitOmittedExpression = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitParenthesizedExpression = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitSimpleArrowFunctionExpression = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitParenthesizedArrowFunctionExpression = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitQualifiedName = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitTypeArgumentList = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitConstructorType = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitFunctionType = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitObjectType = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitArrayType = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitGenericType = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitTypeQuery = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitTypeAnnotation = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitBlock = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitParameter = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitMemberAccessExpression = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitPostfixUnaryExpression = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitElementAccessExpression = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitInvocationExpression = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitArgumentList = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitBinaryExpression = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitConditionalExpression = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitConstructSignature = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitMethodSignature = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitIndexSignature = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitPropertySignature = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitCallSignature = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitParameterList = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitTypeParameterList = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitTypeParameter = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitConstraint = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitElseClause = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitIfStatement = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitExpressionStatement = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitConstructorDeclaration = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitMemberFunctionDeclaration = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitGetMemberAccessorDeclaration = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitSetMemberAccessorDeclaration = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitMemberVariableDeclaration = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitThrowStatement = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitReturnStatement = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitObjectCreationExpression = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitSwitchStatement = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitCaseSwitchClause = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitDefaultSwitchClause = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitBreakStatement = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitContinueStatement = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitForStatement = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitForInStatement = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitWhileStatement = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitWithStatement = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitEnumDeclaration = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitEnumElement = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitCastExpression = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitObjectLiteralExpression = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitSimplePropertyAssignment = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitFunctionPropertyAssignment = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitGetAccessorPropertyAssignment = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitSetAccessorPropertyAssignment = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitFunctionExpression = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitEmptyStatement = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitTryStatement = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitCatchClause = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitFinallyClause = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitLabeledStatement = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitDoStatement = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitTypeOfExpression = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitDeleteExpression = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitVoidExpression = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitDebuggerStatement = function (node) { + return this.defaultVisit(node); + }; + return SyntaxVisitor; + })(); + TypeScript.SyntaxVisitor = SyntaxVisitor; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var SyntaxWalker = (function () { + function SyntaxWalker() { + } + SyntaxWalker.prototype.visitToken = function (token) { + }; + + SyntaxWalker.prototype.visitNode = function (node) { + node.accept(this); + }; + + SyntaxWalker.prototype.visitNodeOrToken = function (nodeOrToken) { + if (nodeOrToken.isToken()) { + this.visitToken(nodeOrToken); + } else { + this.visitNode(nodeOrToken); + } + }; + + SyntaxWalker.prototype.visitOptionalToken = function (token) { + if (token === null) { + return; + } + + this.visitToken(token); + }; + + SyntaxWalker.prototype.visitOptionalNode = function (node) { + if (node === null) { + return; + } + + this.visitNode(node); + }; + + SyntaxWalker.prototype.visitOptionalNodeOrToken = function (nodeOrToken) { + if (nodeOrToken === null) { + return; + } + + this.visitNodeOrToken(nodeOrToken); + }; + + SyntaxWalker.prototype.visitList = function (list) { + for (var i = 0, n = list.childCount(); i < n; i++) { + this.visitNodeOrToken(list.childAt(i)); + } + }; + + SyntaxWalker.prototype.visitSeparatedList = function (list) { + for (var i = 0, n = list.childCount(); i < n; i++) { + var item = list.childAt(i); + this.visitNodeOrToken(item); + } + }; + + SyntaxWalker.prototype.visitSourceUnit = function (node) { + this.visitList(node.moduleElements); + this.visitToken(node.endOfFileToken); + }; + + SyntaxWalker.prototype.visitExternalModuleReference = function (node) { + this.visitToken(node.requireKeyword); + this.visitToken(node.openParenToken); + this.visitToken(node.stringLiteral); + this.visitToken(node.closeParenToken); + }; + + SyntaxWalker.prototype.visitModuleNameModuleReference = function (node) { + this.visitNodeOrToken(node.moduleName); + }; + + SyntaxWalker.prototype.visitImportDeclaration = function (node) { + this.visitList(node.modifiers); + this.visitToken(node.importKeyword); + this.visitToken(node.identifier); + this.visitToken(node.equalsToken); + this.visitNode(node.moduleReference); + this.visitToken(node.semicolonToken); + }; + + SyntaxWalker.prototype.visitExportAssignment = function (node) { + this.visitToken(node.exportKeyword); + this.visitToken(node.equalsToken); + this.visitToken(node.identifier); + this.visitToken(node.semicolonToken); + }; + + SyntaxWalker.prototype.visitClassDeclaration = function (node) { + this.visitList(node.modifiers); + this.visitToken(node.classKeyword); + this.visitToken(node.identifier); + this.visitOptionalNode(node.typeParameterList); + this.visitList(node.heritageClauses); + this.visitToken(node.openBraceToken); + this.visitList(node.classElements); + this.visitToken(node.closeBraceToken); + }; + + SyntaxWalker.prototype.visitInterfaceDeclaration = function (node) { + this.visitList(node.modifiers); + this.visitToken(node.interfaceKeyword); + this.visitToken(node.identifier); + this.visitOptionalNode(node.typeParameterList); + this.visitList(node.heritageClauses); + this.visitNode(node.body); + }; + + SyntaxWalker.prototype.visitHeritageClause = function (node) { + this.visitToken(node.extendsOrImplementsKeyword); + this.visitSeparatedList(node.typeNames); + }; + + SyntaxWalker.prototype.visitModuleDeclaration = function (node) { + this.visitList(node.modifiers); + this.visitToken(node.moduleKeyword); + this.visitOptionalNodeOrToken(node.moduleName); + this.visitOptionalToken(node.stringLiteral); + this.visitToken(node.openBraceToken); + this.visitList(node.moduleElements); + this.visitToken(node.closeBraceToken); + }; + + SyntaxWalker.prototype.visitFunctionDeclaration = function (node) { + this.visitList(node.modifiers); + this.visitToken(node.functionKeyword); + this.visitToken(node.identifier); + this.visitNode(node.callSignature); + this.visitOptionalNode(node.block); + this.visitOptionalToken(node.semicolonToken); + }; + + SyntaxWalker.prototype.visitVariableStatement = function (node) { + this.visitList(node.modifiers); + this.visitNode(node.variableDeclaration); + this.visitToken(node.semicolonToken); + }; + + SyntaxWalker.prototype.visitVariableDeclaration = function (node) { + this.visitToken(node.varKeyword); + this.visitSeparatedList(node.variableDeclarators); + }; + + SyntaxWalker.prototype.visitVariableDeclarator = function (node) { + this.visitToken(node.identifier); + this.visitOptionalNode(node.typeAnnotation); + this.visitOptionalNode(node.equalsValueClause); + }; + + SyntaxWalker.prototype.visitEqualsValueClause = function (node) { + this.visitToken(node.equalsToken); + this.visitNodeOrToken(node.value); + }; + + SyntaxWalker.prototype.visitPrefixUnaryExpression = function (node) { + this.visitToken(node.operatorToken); + this.visitNodeOrToken(node.operand); + }; + + SyntaxWalker.prototype.visitArrayLiteralExpression = function (node) { + this.visitToken(node.openBracketToken); + this.visitSeparatedList(node.expressions); + this.visitToken(node.closeBracketToken); + }; + + SyntaxWalker.prototype.visitOmittedExpression = function (node) { + }; + + SyntaxWalker.prototype.visitParenthesizedExpression = function (node) { + this.visitToken(node.openParenToken); + this.visitNodeOrToken(node.expression); + this.visitToken(node.closeParenToken); + }; + + SyntaxWalker.prototype.visitSimpleArrowFunctionExpression = function (node) { + this.visitToken(node.identifier); + this.visitToken(node.equalsGreaterThanToken); + this.visitNodeOrToken(node.body); + }; + + SyntaxWalker.prototype.visitParenthesizedArrowFunctionExpression = function (node) { + this.visitNode(node.callSignature); + this.visitToken(node.equalsGreaterThanToken); + this.visitNodeOrToken(node.body); + }; + + SyntaxWalker.prototype.visitQualifiedName = function (node) { + this.visitNodeOrToken(node.left); + this.visitToken(node.dotToken); + this.visitToken(node.right); + }; + + SyntaxWalker.prototype.visitTypeArgumentList = function (node) { + this.visitToken(node.lessThanToken); + this.visitSeparatedList(node.typeArguments); + this.visitToken(node.greaterThanToken); + }; + + SyntaxWalker.prototype.visitConstructorType = function (node) { + this.visitToken(node.newKeyword); + this.visitOptionalNode(node.typeParameterList); + this.visitNode(node.parameterList); + this.visitToken(node.equalsGreaterThanToken); + this.visitNodeOrToken(node.type); + }; + + SyntaxWalker.prototype.visitFunctionType = function (node) { + this.visitOptionalNode(node.typeParameterList); + this.visitNode(node.parameterList); + this.visitToken(node.equalsGreaterThanToken); + this.visitNodeOrToken(node.type); + }; + + SyntaxWalker.prototype.visitObjectType = function (node) { + this.visitToken(node.openBraceToken); + this.visitSeparatedList(node.typeMembers); + this.visitToken(node.closeBraceToken); + }; + + SyntaxWalker.prototype.visitArrayType = function (node) { + this.visitNodeOrToken(node.type); + this.visitToken(node.openBracketToken); + this.visitToken(node.closeBracketToken); + }; + + SyntaxWalker.prototype.visitGenericType = function (node) { + this.visitNodeOrToken(node.name); + this.visitNode(node.typeArgumentList); + }; + + SyntaxWalker.prototype.visitTypeQuery = function (node) { + this.visitToken(node.typeOfKeyword); + this.visitNodeOrToken(node.name); + }; + + SyntaxWalker.prototype.visitTypeAnnotation = function (node) { + this.visitToken(node.colonToken); + this.visitNodeOrToken(node.type); + }; + + SyntaxWalker.prototype.visitBlock = function (node) { + this.visitToken(node.openBraceToken); + this.visitList(node.statements); + this.visitToken(node.closeBraceToken); + }; + + SyntaxWalker.prototype.visitParameter = function (node) { + this.visitOptionalToken(node.dotDotDotToken); + this.visitOptionalToken(node.publicOrPrivateKeyword); + this.visitToken(node.identifier); + this.visitOptionalToken(node.questionToken); + this.visitOptionalNode(node.typeAnnotation); + this.visitOptionalNode(node.equalsValueClause); + }; + + SyntaxWalker.prototype.visitMemberAccessExpression = function (node) { + this.visitNodeOrToken(node.expression); + this.visitToken(node.dotToken); + this.visitToken(node.name); + }; + + SyntaxWalker.prototype.visitPostfixUnaryExpression = function (node) { + this.visitNodeOrToken(node.operand); + this.visitToken(node.operatorToken); + }; + + SyntaxWalker.prototype.visitElementAccessExpression = function (node) { + this.visitNodeOrToken(node.expression); + this.visitToken(node.openBracketToken); + this.visitNodeOrToken(node.argumentExpression); + this.visitToken(node.closeBracketToken); + }; + + SyntaxWalker.prototype.visitInvocationExpression = function (node) { + this.visitNodeOrToken(node.expression); + this.visitNode(node.argumentList); + }; + + SyntaxWalker.prototype.visitArgumentList = function (node) { + this.visitOptionalNode(node.typeArgumentList); + this.visitToken(node.openParenToken); + this.visitSeparatedList(node.arguments); + this.visitToken(node.closeParenToken); + }; + + SyntaxWalker.prototype.visitBinaryExpression = function (node) { + this.visitNodeOrToken(node.left); + this.visitToken(node.operatorToken); + this.visitNodeOrToken(node.right); + }; + + SyntaxWalker.prototype.visitConditionalExpression = function (node) { + this.visitNodeOrToken(node.condition); + this.visitToken(node.questionToken); + this.visitNodeOrToken(node.whenTrue); + this.visitToken(node.colonToken); + this.visitNodeOrToken(node.whenFalse); + }; + + SyntaxWalker.prototype.visitConstructSignature = function (node) { + this.visitToken(node.newKeyword); + this.visitNode(node.callSignature); + }; + + SyntaxWalker.prototype.visitMethodSignature = function (node) { + this.visitToken(node.propertyName); + this.visitOptionalToken(node.questionToken); + this.visitNode(node.callSignature); + }; + + SyntaxWalker.prototype.visitIndexSignature = function (node) { + this.visitToken(node.openBracketToken); + this.visitNode(node.parameter); + this.visitToken(node.closeBracketToken); + this.visitOptionalNode(node.typeAnnotation); + }; + + SyntaxWalker.prototype.visitPropertySignature = function (node) { + this.visitToken(node.propertyName); + this.visitOptionalToken(node.questionToken); + this.visitOptionalNode(node.typeAnnotation); + }; + + SyntaxWalker.prototype.visitCallSignature = function (node) { + this.visitOptionalNode(node.typeParameterList); + this.visitNode(node.parameterList); + this.visitOptionalNode(node.typeAnnotation); + }; + + SyntaxWalker.prototype.visitParameterList = function (node) { + this.visitToken(node.openParenToken); + this.visitSeparatedList(node.parameters); + this.visitToken(node.closeParenToken); + }; + + SyntaxWalker.prototype.visitTypeParameterList = function (node) { + this.visitToken(node.lessThanToken); + this.visitSeparatedList(node.typeParameters); + this.visitToken(node.greaterThanToken); + }; + + SyntaxWalker.prototype.visitTypeParameter = function (node) { + this.visitToken(node.identifier); + this.visitOptionalNode(node.constraint); + }; + + SyntaxWalker.prototype.visitConstraint = function (node) { + this.visitToken(node.extendsKeyword); + this.visitNodeOrToken(node.type); + }; + + SyntaxWalker.prototype.visitElseClause = function (node) { + this.visitToken(node.elseKeyword); + this.visitNodeOrToken(node.statement); + }; + + SyntaxWalker.prototype.visitIfStatement = function (node) { + this.visitToken(node.ifKeyword); + this.visitToken(node.openParenToken); + this.visitNodeOrToken(node.condition); + this.visitToken(node.closeParenToken); + this.visitNodeOrToken(node.statement); + this.visitOptionalNode(node.elseClause); + }; + + SyntaxWalker.prototype.visitExpressionStatement = function (node) { + this.visitNodeOrToken(node.expression); + this.visitToken(node.semicolonToken); + }; + + SyntaxWalker.prototype.visitConstructorDeclaration = function (node) { + this.visitToken(node.constructorKeyword); + this.visitNode(node.parameterList); + this.visitOptionalNode(node.block); + this.visitOptionalToken(node.semicolonToken); + }; + + SyntaxWalker.prototype.visitMemberFunctionDeclaration = function (node) { + this.visitList(node.modifiers); + this.visitToken(node.propertyName); + this.visitNode(node.callSignature); + this.visitOptionalNode(node.block); + this.visitOptionalToken(node.semicolonToken); + }; + + SyntaxWalker.prototype.visitGetMemberAccessorDeclaration = function (node) { + this.visitList(node.modifiers); + this.visitToken(node.getKeyword); + this.visitToken(node.propertyName); + this.visitNode(node.parameterList); + this.visitOptionalNode(node.typeAnnotation); + this.visitNode(node.block); + }; + + SyntaxWalker.prototype.visitSetMemberAccessorDeclaration = function (node) { + this.visitList(node.modifiers); + this.visitToken(node.setKeyword); + this.visitToken(node.propertyName); + this.visitNode(node.parameterList); + this.visitNode(node.block); + }; + + SyntaxWalker.prototype.visitMemberVariableDeclaration = function (node) { + this.visitList(node.modifiers); + this.visitNode(node.variableDeclarator); + this.visitToken(node.semicolonToken); + }; + + SyntaxWalker.prototype.visitThrowStatement = function (node) { + this.visitToken(node.throwKeyword); + this.visitNodeOrToken(node.expression); + this.visitToken(node.semicolonToken); + }; + + SyntaxWalker.prototype.visitReturnStatement = function (node) { + this.visitToken(node.returnKeyword); + this.visitOptionalNodeOrToken(node.expression); + this.visitToken(node.semicolonToken); + }; + + SyntaxWalker.prototype.visitObjectCreationExpression = function (node) { + this.visitToken(node.newKeyword); + this.visitNodeOrToken(node.expression); + this.visitOptionalNode(node.argumentList); + }; + + SyntaxWalker.prototype.visitSwitchStatement = function (node) { + this.visitToken(node.switchKeyword); + this.visitToken(node.openParenToken); + this.visitNodeOrToken(node.expression); + this.visitToken(node.closeParenToken); + this.visitToken(node.openBraceToken); + this.visitList(node.switchClauses); + this.visitToken(node.closeBraceToken); + }; + + SyntaxWalker.prototype.visitCaseSwitchClause = function (node) { + this.visitToken(node.caseKeyword); + this.visitNodeOrToken(node.expression); + this.visitToken(node.colonToken); + this.visitList(node.statements); + }; + + SyntaxWalker.prototype.visitDefaultSwitchClause = function (node) { + this.visitToken(node.defaultKeyword); + this.visitToken(node.colonToken); + this.visitList(node.statements); + }; + + SyntaxWalker.prototype.visitBreakStatement = function (node) { + this.visitToken(node.breakKeyword); + this.visitOptionalToken(node.identifier); + this.visitToken(node.semicolonToken); + }; + + SyntaxWalker.prototype.visitContinueStatement = function (node) { + this.visitToken(node.continueKeyword); + this.visitOptionalToken(node.identifier); + this.visitToken(node.semicolonToken); + }; + + SyntaxWalker.prototype.visitForStatement = function (node) { + this.visitToken(node.forKeyword); + this.visitToken(node.openParenToken); + this.visitOptionalNode(node.variableDeclaration); + this.visitOptionalNodeOrToken(node.initializer); + this.visitToken(node.firstSemicolonToken); + this.visitOptionalNodeOrToken(node.condition); + this.visitToken(node.secondSemicolonToken); + this.visitOptionalNodeOrToken(node.incrementor); + this.visitToken(node.closeParenToken); + this.visitNodeOrToken(node.statement); + }; + + SyntaxWalker.prototype.visitForInStatement = function (node) { + this.visitToken(node.forKeyword); + this.visitToken(node.openParenToken); + this.visitOptionalNode(node.variableDeclaration); + this.visitOptionalNodeOrToken(node.left); + this.visitToken(node.inKeyword); + this.visitNodeOrToken(node.expression); + this.visitToken(node.closeParenToken); + this.visitNodeOrToken(node.statement); + }; + + SyntaxWalker.prototype.visitWhileStatement = function (node) { + this.visitToken(node.whileKeyword); + this.visitToken(node.openParenToken); + this.visitNodeOrToken(node.condition); + this.visitToken(node.closeParenToken); + this.visitNodeOrToken(node.statement); + }; + + SyntaxWalker.prototype.visitWithStatement = function (node) { + this.visitToken(node.withKeyword); + this.visitToken(node.openParenToken); + this.visitNodeOrToken(node.condition); + this.visitToken(node.closeParenToken); + this.visitNodeOrToken(node.statement); + }; + + SyntaxWalker.prototype.visitEnumDeclaration = function (node) { + this.visitList(node.modifiers); + this.visitToken(node.enumKeyword); + this.visitToken(node.identifier); + this.visitToken(node.openBraceToken); + this.visitSeparatedList(node.enumElements); + this.visitToken(node.closeBraceToken); + }; + + SyntaxWalker.prototype.visitEnumElement = function (node) { + this.visitToken(node.propertyName); + this.visitOptionalNode(node.equalsValueClause); + }; + + SyntaxWalker.prototype.visitCastExpression = function (node) { + this.visitToken(node.lessThanToken); + this.visitNodeOrToken(node.type); + this.visitToken(node.greaterThanToken); + this.visitNodeOrToken(node.expression); + }; + + SyntaxWalker.prototype.visitObjectLiteralExpression = function (node) { + this.visitToken(node.openBraceToken); + this.visitSeparatedList(node.propertyAssignments); + this.visitToken(node.closeBraceToken); + }; + + SyntaxWalker.prototype.visitSimplePropertyAssignment = function (node) { + this.visitToken(node.propertyName); + this.visitToken(node.colonToken); + this.visitNodeOrToken(node.expression); + }; + + SyntaxWalker.prototype.visitFunctionPropertyAssignment = function (node) { + this.visitToken(node.propertyName); + this.visitNode(node.callSignature); + this.visitNode(node.block); + }; + + SyntaxWalker.prototype.visitGetAccessorPropertyAssignment = function (node) { + this.visitToken(node.getKeyword); + this.visitToken(node.propertyName); + this.visitToken(node.openParenToken); + this.visitToken(node.closeParenToken); + this.visitOptionalNode(node.typeAnnotation); + this.visitNode(node.block); + }; + + SyntaxWalker.prototype.visitSetAccessorPropertyAssignment = function (node) { + this.visitToken(node.setKeyword); + this.visitToken(node.propertyName); + this.visitToken(node.openParenToken); + this.visitNode(node.parameter); + this.visitToken(node.closeParenToken); + this.visitNode(node.block); + }; + + SyntaxWalker.prototype.visitFunctionExpression = function (node) { + this.visitToken(node.functionKeyword); + this.visitOptionalToken(node.identifier); + this.visitNode(node.callSignature); + this.visitNode(node.block); + }; + + SyntaxWalker.prototype.visitEmptyStatement = function (node) { + this.visitToken(node.semicolonToken); + }; + + SyntaxWalker.prototype.visitTryStatement = function (node) { + this.visitToken(node.tryKeyword); + this.visitNode(node.block); + this.visitOptionalNode(node.catchClause); + this.visitOptionalNode(node.finallyClause); + }; + + SyntaxWalker.prototype.visitCatchClause = function (node) { + this.visitToken(node.catchKeyword); + this.visitToken(node.openParenToken); + this.visitToken(node.identifier); + this.visitOptionalNode(node.typeAnnotation); + this.visitToken(node.closeParenToken); + this.visitNode(node.block); + }; + + SyntaxWalker.prototype.visitFinallyClause = function (node) { + this.visitToken(node.finallyKeyword); + this.visitNode(node.block); + }; + + SyntaxWalker.prototype.visitLabeledStatement = function (node) { + this.visitToken(node.identifier); + this.visitToken(node.colonToken); + this.visitNodeOrToken(node.statement); + }; + + SyntaxWalker.prototype.visitDoStatement = function (node) { + this.visitToken(node.doKeyword); + this.visitNodeOrToken(node.statement); + this.visitToken(node.whileKeyword); + this.visitToken(node.openParenToken); + this.visitNodeOrToken(node.condition); + this.visitToken(node.closeParenToken); + this.visitToken(node.semicolonToken); + }; + + SyntaxWalker.prototype.visitTypeOfExpression = function (node) { + this.visitToken(node.typeOfKeyword); + this.visitNodeOrToken(node.expression); + }; + + SyntaxWalker.prototype.visitDeleteExpression = function (node) { + this.visitToken(node.deleteKeyword); + this.visitNodeOrToken(node.expression); + }; + + SyntaxWalker.prototype.visitVoidExpression = function (node) { + this.visitToken(node.voidKeyword); + this.visitNodeOrToken(node.expression); + }; + + SyntaxWalker.prototype.visitDebuggerStatement = function (node) { + this.visitToken(node.debuggerKeyword); + this.visitToken(node.semicolonToken); + }; + return SyntaxWalker; + })(); + TypeScript.SyntaxWalker = SyntaxWalker; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var PositionTrackingWalker = (function (_super) { + __extends(PositionTrackingWalker, _super); + function PositionTrackingWalker() { + _super.apply(this, arguments); + this._position = 0; + } + PositionTrackingWalker.prototype.visitToken = function (token) { + this._position += token.fullWidth(); + }; + + PositionTrackingWalker.prototype.position = function () { + return this._position; + }; + + PositionTrackingWalker.prototype.skip = function (element) { + this._position += element.fullWidth(); + }; + return PositionTrackingWalker; + })(TypeScript.SyntaxWalker); + TypeScript.PositionTrackingWalker = PositionTrackingWalker; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var SyntaxInformationMap = (function (_super) { + __extends(SyntaxInformationMap, _super); + function SyntaxInformationMap(trackParents, trackPreviousToken) { + _super.call(this); + this.trackParents = trackParents; + this.trackPreviousToken = trackPreviousToken; + this.tokenToInformation = TypeScript.Collections.createHashTable(TypeScript.Collections.DefaultHashTableCapacity, TypeScript.Collections.identityHashCode); + this.elementToPosition = TypeScript.Collections.createHashTable(TypeScript.Collections.DefaultHashTableCapacity, TypeScript.Collections.identityHashCode); + this._previousToken = null; + this._previousTokenInformation = null; + this._currentPosition = 0; + this._elementToParent = TypeScript.Collections.createHashTable(TypeScript.Collections.DefaultHashTableCapacity, TypeScript.Collections.identityHashCode); + this._parentStack = []; + this._parentStack.push(null); + } + SyntaxInformationMap.create = function (node, trackParents, trackPreviousToken) { + var map = new SyntaxInformationMap(trackParents, trackPreviousToken); + map.visitNode(node); + return map; + }; + + SyntaxInformationMap.prototype.visitNode = function (node) { + this.trackParents && this._elementToParent.add(node, TypeScript.ArrayUtilities.last(this._parentStack)); + this.elementToPosition.add(node, this._currentPosition); + + this.trackParents && this._parentStack.push(node); + _super.prototype.visitNode.call(this, node); + this.trackParents && this._parentStack.pop(); + }; + + SyntaxInformationMap.prototype.visitToken = function (token) { + this.trackParents && this._elementToParent.add(token, TypeScript.ArrayUtilities.last(this._parentStack)); + + if (this.trackPreviousToken) { + var tokenInformation = { + previousToken: this._previousToken, + nextToken: null + }; + + if (this._previousTokenInformation !== null) { + this._previousTokenInformation.nextToken = token; + } + + this._previousToken = token; + this._previousTokenInformation = tokenInformation; + + this.tokenToInformation.add(token, tokenInformation); + } + + this.elementToPosition.add(token, this._currentPosition); + this._currentPosition += token.fullWidth(); + }; + + SyntaxInformationMap.prototype.parent = function (element) { + return this._elementToParent.get(element); + }; + + SyntaxInformationMap.prototype.fullStart = function (element) { + return this.elementToPosition.get(element); + }; + + SyntaxInformationMap.prototype.start = function (element) { + return this.fullStart(element) + element.leadingTriviaWidth(); + }; + + SyntaxInformationMap.prototype.end = function (element) { + return this.start(element) + element.width(); + }; + + SyntaxInformationMap.prototype.previousToken = function (token) { + return this.tokenInformation(token).previousToken; + }; + + SyntaxInformationMap.prototype.tokenInformation = function (token) { + return this.tokenToInformation.get(token); + }; + + SyntaxInformationMap.prototype.firstTokenInLineContainingToken = function (token) { + var current = token; + while (true) { + var information = this.tokenInformation(current); + if (this.isFirstTokenInLineWorker(information)) { + break; + } + + current = information.previousToken; + } + + return current; + }; + + SyntaxInformationMap.prototype.isFirstTokenInLine = function (token) { + var information = this.tokenInformation(token); + return this.isFirstTokenInLineWorker(information); + }; + + SyntaxInformationMap.prototype.isFirstTokenInLineWorker = function (information) { + return information.previousToken === null || information.previousToken.hasTrailingNewLine(); + }; + return SyntaxInformationMap; + })(TypeScript.SyntaxWalker); + TypeScript.SyntaxInformationMap = SyntaxInformationMap; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var SyntaxNodeInvariantsChecker = (function (_super) { + __extends(SyntaxNodeInvariantsChecker, _super); + function SyntaxNodeInvariantsChecker() { + _super.apply(this, arguments); + this.tokenTable = TypeScript.Collections.createHashTable(TypeScript.Collections.DefaultHashTableCapacity, TypeScript.Collections.identityHashCode); + } + SyntaxNodeInvariantsChecker.checkInvariants = function (node) { + node.accept(new SyntaxNodeInvariantsChecker()); + }; + + SyntaxNodeInvariantsChecker.prototype.visitToken = function (token) { + this.tokenTable.add(token, token); + }; + return SyntaxNodeInvariantsChecker; + })(TypeScript.SyntaxWalker); + TypeScript.SyntaxNodeInvariantsChecker = SyntaxNodeInvariantsChecker; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var DepthLimitedWalker = (function (_super) { + __extends(DepthLimitedWalker, _super); + function DepthLimitedWalker(maximumDepth) { + _super.call(this); + this._depth = 0; + this._maximumDepth = 0; + this._maximumDepth = maximumDepth; + } + DepthLimitedWalker.prototype.visitNode = function (node) { + if (this._depth < this._maximumDepth) { + this._depth++; + _super.prototype.visitNode.call(this, node); + this._depth--; + } else { + this.skip(node); + } + }; + return DepthLimitedWalker; + })(TypeScript.PositionTrackingWalker); + TypeScript.DepthLimitedWalker = DepthLimitedWalker; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (Parser) { + var ExpressionPrecedence; + (function (ExpressionPrecedence) { + ExpressionPrecedence[ExpressionPrecedence["CommaExpressionPrecedence"] = 1] = "CommaExpressionPrecedence"; + + ExpressionPrecedence[ExpressionPrecedence["AssignmentExpressionPrecedence"] = 2] = "AssignmentExpressionPrecedence"; + + ExpressionPrecedence[ExpressionPrecedence["ConditionalExpressionPrecedence"] = 3] = "ConditionalExpressionPrecedence"; + + ExpressionPrecedence[ExpressionPrecedence["ArrowFunctionPrecedence"] = 4] = "ArrowFunctionPrecedence"; + + ExpressionPrecedence[ExpressionPrecedence["LogicalOrExpressionPrecedence"] = 5] = "LogicalOrExpressionPrecedence"; + ExpressionPrecedence[ExpressionPrecedence["LogicalAndExpressionPrecedence"] = 6] = "LogicalAndExpressionPrecedence"; + ExpressionPrecedence[ExpressionPrecedence["BitwiseOrExpressionPrecedence"] = 7] = "BitwiseOrExpressionPrecedence"; + ExpressionPrecedence[ExpressionPrecedence["BitwiseExclusiveOrExpressionPrecedence"] = 8] = "BitwiseExclusiveOrExpressionPrecedence"; + ExpressionPrecedence[ExpressionPrecedence["BitwiseAndExpressionPrecedence"] = 9] = "BitwiseAndExpressionPrecedence"; + ExpressionPrecedence[ExpressionPrecedence["EqualityExpressionPrecedence"] = 10] = "EqualityExpressionPrecedence"; + ExpressionPrecedence[ExpressionPrecedence["RelationalExpressionPrecedence"] = 11] = "RelationalExpressionPrecedence"; + ExpressionPrecedence[ExpressionPrecedence["ShiftExpressionPrecdence"] = 12] = "ShiftExpressionPrecdence"; + ExpressionPrecedence[ExpressionPrecedence["AdditiveExpressionPrecedence"] = 13] = "AdditiveExpressionPrecedence"; + ExpressionPrecedence[ExpressionPrecedence["MultiplicativeExpressionPrecedence"] = 14] = "MultiplicativeExpressionPrecedence"; + + ExpressionPrecedence[ExpressionPrecedence["UnaryExpressionPrecedence"] = 15] = "UnaryExpressionPrecedence"; + })(ExpressionPrecedence || (ExpressionPrecedence = {})); + + var ListParsingState; + (function (ListParsingState) { + ListParsingState[ListParsingState["SourceUnit_ModuleElements"] = 1 << 0] = "SourceUnit_ModuleElements"; + ListParsingState[ListParsingState["ClassDeclaration_ClassElements"] = 1 << 1] = "ClassDeclaration_ClassElements"; + ListParsingState[ListParsingState["ModuleDeclaration_ModuleElements"] = 1 << 2] = "ModuleDeclaration_ModuleElements"; + ListParsingState[ListParsingState["SwitchStatement_SwitchClauses"] = 1 << 3] = "SwitchStatement_SwitchClauses"; + ListParsingState[ListParsingState["SwitchClause_Statements"] = 1 << 4] = "SwitchClause_Statements"; + ListParsingState[ListParsingState["Block_Statements"] = 1 << 5] = "Block_Statements"; + ListParsingState[ListParsingState["TryBlock_Statements"] = 1 << 6] = "TryBlock_Statements"; + ListParsingState[ListParsingState["CatchBlock_Statements"] = 1 << 7] = "CatchBlock_Statements"; + ListParsingState[ListParsingState["EnumDeclaration_EnumElements"] = 1 << 8] = "EnumDeclaration_EnumElements"; + ListParsingState[ListParsingState["ObjectType_TypeMembers"] = 1 << 9] = "ObjectType_TypeMembers"; + ListParsingState[ListParsingState["ClassOrInterfaceDeclaration_HeritageClauses"] = 1 << 10] = "ClassOrInterfaceDeclaration_HeritageClauses"; + ListParsingState[ListParsingState["HeritageClause_TypeNameList"] = 1 << 11] = "HeritageClause_TypeNameList"; + ListParsingState[ListParsingState["VariableDeclaration_VariableDeclarators_AllowIn"] = 1 << 12] = "VariableDeclaration_VariableDeclarators_AllowIn"; + ListParsingState[ListParsingState["VariableDeclaration_VariableDeclarators_DisallowIn"] = 1 << 13] = "VariableDeclaration_VariableDeclarators_DisallowIn"; + ListParsingState[ListParsingState["ArgumentList_AssignmentExpressions"] = 1 << 14] = "ArgumentList_AssignmentExpressions"; + ListParsingState[ListParsingState["ObjectLiteralExpression_PropertyAssignments"] = 1 << 15] = "ObjectLiteralExpression_PropertyAssignments"; + ListParsingState[ListParsingState["ArrayLiteralExpression_AssignmentExpressions"] = 1 << 16] = "ArrayLiteralExpression_AssignmentExpressions"; + ListParsingState[ListParsingState["ParameterList_Parameters"] = 1 << 17] = "ParameterList_Parameters"; + ListParsingState[ListParsingState["TypeArgumentList_Types"] = 1 << 18] = "TypeArgumentList_Types"; + ListParsingState[ListParsingState["TypeParameterList_TypeParameters"] = 1 << 19] = "TypeParameterList_TypeParameters"; + + ListParsingState[ListParsingState["FirstListParsingState"] = ListParsingState.SourceUnit_ModuleElements] = "FirstListParsingState"; + ListParsingState[ListParsingState["LastListParsingState"] = ListParsingState.TypeArgumentList_Types] = "LastListParsingState"; + })(ListParsingState || (ListParsingState = {})); + + var SyntaxCursor = (function () { + function SyntaxCursor(sourceUnit) { + this._elements = []; + this._index = 0; + this._pinCount = 0; + sourceUnit.insertChildrenInto(this._elements, 0); + } + SyntaxCursor.prototype.isFinished = function () { + return this._index === this._elements.length; + }; + + SyntaxCursor.prototype.currentElement = function () { + if (this.isFinished()) { + return null; + } + + return this._elements[this._index]; + }; + + SyntaxCursor.prototype.currentNode = function () { + var element = this.currentElement(); + return element !== null && element.isNode() ? element : null; + }; + + SyntaxCursor.prototype.moveToFirstChild = function () { + if (this.isFinished()) { + return; + } + + var element = this._elements[this._index]; + if (element.isToken()) { + return; + } + + var node = element; + + this._elements.splice(this._index, 1); + + node.insertChildrenInto(this._elements, this._index); + }; + + SyntaxCursor.prototype.moveToNextSibling = function () { + if (this.isFinished()) { + return; + } + + if (this._pinCount > 0) { + this._index++; + return; + } + + this._elements.shift(); + }; + + SyntaxCursor.prototype.getAndPinCursorIndex = function () { + this._pinCount++; + return this._index; + }; + + SyntaxCursor.prototype.releaseAndUnpinCursorIndex = function (index) { + this._pinCount--; + if (this._pinCount === 0) { + } + }; + + SyntaxCursor.prototype.rewindToPinnedCursorIndex = function (index) { + this._index = index; + }; + + SyntaxCursor.prototype.pinCount = function () { + return this._pinCount; + }; + + SyntaxCursor.prototype.moveToFirstToken = function () { + var element; + + while (!this.isFinished()) { + element = this.currentElement(); + if (element.isNode()) { + this.moveToFirstChild(); + continue; + } + + return; + } + }; + + SyntaxCursor.prototype.currentToken = function () { + this.moveToFirstToken(); + if (this.isFinished()) { + return null; + } + + var element = this.currentElement(); + + return element; + }; + + SyntaxCursor.prototype.peekToken = function (n) { + this.moveToFirstToken(); + var pin = this.getAndPinCursorIndex(); + try { + for (var i = 0; i < n; i++) { + this.moveToNextSibling(); + this.moveToFirstToken(); + } + + return this.currentToken(); + } finally { + this.rewindToPinnedCursorIndex(pin); + this.releaseAndUnpinCursorIndex(pin); + } + }; + return SyntaxCursor; + })(); + + var NormalParserSource = (function () { + function NormalParserSource(fileName, text, languageVersion) { + this._previousToken = null; + this._absolutePosition = 0; + this._tokenDiagnostics = []; + this.rewindPointPool = []; + this.rewindPointPoolCount = 0; + this.slidingWindow = new TypeScript.SlidingWindow(this, TypeScript.ArrayUtilities.createArray(32, null), null); + this.scanner = new TypeScript.Scanner(fileName, text, languageVersion); + } + NormalParserSource.prototype.currentNode = function () { + return null; + }; + + NormalParserSource.prototype.moveToNextNode = function () { + throw TypeScript.Errors.invalidOperation(); + }; + + NormalParserSource.prototype.absolutePosition = function () { + return this._absolutePosition; + }; + + NormalParserSource.prototype.previousToken = function () { + return this._previousToken; + }; + + NormalParserSource.prototype.tokenDiagnostics = function () { + return this._tokenDiagnostics; + }; + + NormalParserSource.prototype.getOrCreateRewindPoint = function () { + if (this.rewindPointPoolCount === 0) { + return {}; + } + + this.rewindPointPoolCount--; + var result = this.rewindPointPool[this.rewindPointPoolCount]; + this.rewindPointPool[this.rewindPointPoolCount] = null; + return result; + }; + + NormalParserSource.prototype.getRewindPoint = function () { + var slidingWindowIndex = this.slidingWindow.getAndPinAbsoluteIndex(); + + var rewindPoint = this.getOrCreateRewindPoint(); + + rewindPoint.slidingWindowIndex = slidingWindowIndex; + rewindPoint.previousToken = this._previousToken; + rewindPoint.absolutePosition = this._absolutePosition; + + rewindPoint.pinCount = this.slidingWindow.pinCount(); + + return rewindPoint; + }; + + NormalParserSource.prototype.isPinned = function () { + return this.slidingWindow.pinCount() > 0; + }; + + NormalParserSource.prototype.rewind = function (rewindPoint) { + this.slidingWindow.rewindToPinnedIndex(rewindPoint.slidingWindowIndex); + + this._previousToken = rewindPoint.previousToken; + this._absolutePosition = rewindPoint.absolutePosition; + }; + + NormalParserSource.prototype.releaseRewindPoint = function (rewindPoint) { + this.slidingWindow.releaseAndUnpinAbsoluteIndex((rewindPoint).absoluteIndex); + + this.rewindPointPool[this.rewindPointPoolCount] = rewindPoint; + this.rewindPointPoolCount++; + }; + + NormalParserSource.prototype.fetchMoreItems = function (allowRegularExpression, sourceIndex, window, destinationIndex, spaceAvailable) { + window[destinationIndex] = this.scanner.scan(this._tokenDiagnostics, allowRegularExpression); + return 1; + }; + + NormalParserSource.prototype.peekToken = function (n) { + return this.slidingWindow.peekItemN(n); + }; + + NormalParserSource.prototype.moveToNextToken = function () { + var currentToken = this.currentToken(); + this._absolutePosition += currentToken.fullWidth(); + this._previousToken = currentToken; + + this.slidingWindow.moveToNextItem(); + }; + + NormalParserSource.prototype.currentToken = function () { + return this.slidingWindow.currentItem(false); + }; + + NormalParserSource.prototype.removeDiagnosticsOnOrAfterPosition = function (position) { + var tokenDiagnosticsLength = this._tokenDiagnostics.length; + while (tokenDiagnosticsLength > 0) { + var diagnostic = this._tokenDiagnostics[tokenDiagnosticsLength - 1]; + if (diagnostic.start() >= position) { + tokenDiagnosticsLength--; + } else { + break; + } + } + + this._tokenDiagnostics.length = tokenDiagnosticsLength; + }; + + NormalParserSource.prototype.resetToPosition = function (absolutePosition, previousToken) { + this._absolutePosition = absolutePosition; + this._previousToken = previousToken; + + this.removeDiagnosticsOnOrAfterPosition(absolutePosition); + + this.slidingWindow.disgardAllItemsFromCurrentIndexOnwards(); + + this.scanner.setAbsoluteIndex(absolutePosition); + }; + + NormalParserSource.prototype.currentTokenAllowingRegularExpression = function () { + this.resetToPosition(this._absolutePosition, this._previousToken); + + var token = this.slidingWindow.currentItem(true); + + return token; + }; + return NormalParserSource; + })(); + + var IncrementalParserSource = (function () { + function IncrementalParserSource(oldSyntaxTree, textChangeRange, newText) { + this._changeDelta = 0; + var oldSourceUnit = oldSyntaxTree.sourceUnit(); + this._oldSourceUnitCursor = new SyntaxCursor(oldSourceUnit); + + this._changeRange = IncrementalParserSource.extendToAffectedRange(textChangeRange, oldSourceUnit); + + this._normalParserSource = new NormalParserSource(oldSyntaxTree.fileName(), newText, oldSyntaxTree.parseOptions().languageVersion()); + } + IncrementalParserSource.extendToAffectedRange = function (changeRange, sourceUnit) { + var maxLookahead = 1; + + var start = changeRange.span().start(); + + for (var i = 0; start > 0 && i <= maxLookahead; i++) { + var token = sourceUnit.findToken(start); + + var position = token.fullStart(); + + start = TypeScript.MathPrototype.max(0, position - 1); + } + + var finalSpan = TypeScript.TextSpan.fromBounds(start, changeRange.span().end()); + var finalLength = changeRange.newLength() + (changeRange.span().start() - start); + + return new TypeScript.TextChangeRange(finalSpan, finalLength); + }; + + IncrementalParserSource.prototype.absolutePosition = function () { + return this._normalParserSource.absolutePosition(); + }; + + IncrementalParserSource.prototype.previousToken = function () { + return this._normalParserSource.previousToken(); + }; + + IncrementalParserSource.prototype.tokenDiagnostics = function () { + return this._normalParserSource.tokenDiagnostics(); + }; + + IncrementalParserSource.prototype.getRewindPoint = function () { + var rewindPoint = this._normalParserSource.getRewindPoint(); + var oldSourceUnitCursorIndex = this._oldSourceUnitCursor.getAndPinCursorIndex(); + + rewindPoint.changeDelta = this._changeDelta; + rewindPoint.changeRange = this._changeRange; + rewindPoint.oldSourceUnitCursorIndex = oldSourceUnitCursorIndex; + + return rewindPoint; + }; + + IncrementalParserSource.prototype.rewind = function (rewindPoint) { + this._changeRange = rewindPoint.changeRange; + this._changeDelta = rewindPoint.changeDelta; + this._oldSourceUnitCursor.rewindToPinnedCursorIndex(rewindPoint.oldSourceUnitCursorIndex); + + this._normalParserSource.rewind(rewindPoint); + }; + + IncrementalParserSource.prototype.releaseRewindPoint = function (rewindPoint) { + this._oldSourceUnitCursor.releaseAndUnpinCursorIndex(rewindPoint.oldSourceUnitCursorIndex); + this._normalParserSource.releaseRewindPoint(rewindPoint); + }; + + IncrementalParserSource.prototype.canReadFromOldSourceUnit = function () { + if (this._normalParserSource.isPinned()) { + return false; + } + + if (this._changeRange !== null && this._changeRange.newSpan().intersectsWithPosition(this.absolutePosition())) { + return false; + } + + this.syncCursorToNewTextIfBehind(); + + return this._changeDelta === 0 && !this._oldSourceUnitCursor.isFinished(); + }; + + IncrementalParserSource.prototype.currentNode = function () { + if (this.canReadFromOldSourceUnit()) { + return this.tryGetNodeFromOldSourceUnit(); + } + + return null; + }; + + IncrementalParserSource.prototype.currentToken = function () { + if (this.canReadFromOldSourceUnit()) { + var token = this.tryGetTokenFromOldSourceUnit(); + if (token !== null) { + return token; + } + } + + return this._normalParserSource.currentToken(); + }; + + IncrementalParserSource.prototype.currentTokenAllowingRegularExpression = function () { + return this._normalParserSource.currentTokenAllowingRegularExpression(); + }; + + IncrementalParserSource.prototype.syncCursorToNewTextIfBehind = function () { + while (true) { + if (this._oldSourceUnitCursor.isFinished()) { + break; + } + + if (this._changeDelta >= 0) { + break; + } + + var currentElement = this._oldSourceUnitCursor.currentElement(); + + if (currentElement.isNode() && (currentElement.fullWidth() > Math.abs(this._changeDelta))) { + this._oldSourceUnitCursor.moveToFirstChild(); + } else { + this._oldSourceUnitCursor.moveToNextSibling(); + + this._changeDelta += currentElement.fullWidth(); + } + } + }; + + IncrementalParserSource.prototype.intersectsWithChangeRangeSpanInOriginalText = function (start, length) { + return this._changeRange !== null && this._changeRange.span().intersectsWith(start, length); + }; + + IncrementalParserSource.prototype.tryGetNodeFromOldSourceUnit = function () { + while (true) { + var node = this._oldSourceUnitCursor.currentNode(); + if (node === null) { + return null; + } + + if (!this.intersectsWithChangeRangeSpanInOriginalText(this.absolutePosition(), node.fullWidth())) { + if (!node.isIncrementallyUnusable()) { + return node; + } + } + + this._oldSourceUnitCursor.moveToFirstChild(); + } + }; + + IncrementalParserSource.prototype.canReuseTokenFromOldSourceUnit = function (position, token) { + if (token !== null) { + if (!this.intersectsWithChangeRangeSpanInOriginalText(position, token.fullWidth())) { + if (!token.isIncrementallyUnusable()) { + return true; + } + } + } + + return false; + }; + + IncrementalParserSource.prototype.tryGetTokenFromOldSourceUnit = function () { + var token = this._oldSourceUnitCursor.currentToken(); + + return this.canReuseTokenFromOldSourceUnit(this.absolutePosition(), token) ? token : null; + }; + + IncrementalParserSource.prototype.peekToken = function (n) { + if (this.canReadFromOldSourceUnit()) { + var token = this.tryPeekTokenFromOldSourceUnit(n); + if (token !== null) { + return token; + } + } + + return this._normalParserSource.peekToken(n); + }; + + IncrementalParserSource.prototype.tryPeekTokenFromOldSourceUnit = function (n) { + var currentPosition = this.absolutePosition(); + for (var i = 0; i < n; i++) { + var interimToken = this._oldSourceUnitCursor.peekToken(i); + if (!this.canReuseTokenFromOldSourceUnit(currentPosition, interimToken)) { + return null; + } + + currentPosition += interimToken.fullWidth(); + } + + var token = this._oldSourceUnitCursor.peekToken(n); + return this.canReuseTokenFromOldSourceUnit(currentPosition, token) ? token : null; + }; + + IncrementalParserSource.prototype.moveToNextNode = function () { + var currentElement = this._oldSourceUnitCursor.currentElement(); + var currentNode = this._oldSourceUnitCursor.currentNode(); + + this._oldSourceUnitCursor.moveToNextSibling(); + + var absolutePosition = this.absolutePosition() + currentNode.fullWidth(); + var previousToken = currentNode.lastToken(); + this._normalParserSource.resetToPosition(absolutePosition, previousToken); + + if (this._changeRange !== null) { + } + }; + + IncrementalParserSource.prototype.moveToNextToken = function () { + var currentToken = this.currentToken(); + + if (this._oldSourceUnitCursor.currentToken() === currentToken) { + this._oldSourceUnitCursor.moveToNextSibling(); + + var absolutePosition = this.absolutePosition() + currentToken.fullWidth(); + var previousToken = currentToken; + this._normalParserSource.resetToPosition(absolutePosition, previousToken); + + if (this._changeRange !== null) { + } + } else { + this._changeDelta -= currentToken.fullWidth(); + + this._normalParserSource.moveToNextToken(); + + if (this._changeRange !== null) { + var changeRangeSpanInNewText = this._changeRange.newSpan(); + if (this.absolutePosition() >= changeRangeSpanInNewText.end()) { + this._changeDelta += this._changeRange.newLength() - this._changeRange.span().length(); + this._changeRange = null; + } + } + } + }; + return IncrementalParserSource; + })(); + + var ParserImpl = (function () { + function ParserImpl(fileName, lineMap, source, parseOptions) { + this.listParsingState = 0; + this.isInStrictMode = false; + this.diagnostics = []; + this.factory = TypeScript.Syntax.normalModeFactory; + this.mergeTokensStorage = []; + this.arrayPool = []; + this.fileName = fileName; + this.lineMap = lineMap; + this.source = source; + this.parseOptions = parseOptions; + } + ParserImpl.prototype.getRewindPoint = function () { + var rewindPoint = this.source.getRewindPoint(); + + rewindPoint.diagnosticsCount = this.diagnostics.length; + + rewindPoint.isInStrictMode = this.isInStrictMode; + rewindPoint.listParsingState = this.listParsingState; + + return rewindPoint; + }; + + ParserImpl.prototype.rewind = function (rewindPoint) { + this.source.rewind(rewindPoint); + + this.diagnostics.length = rewindPoint.diagnosticsCount; + }; + + ParserImpl.prototype.releaseRewindPoint = function (rewindPoint) { + this.source.releaseRewindPoint(rewindPoint); + }; + + ParserImpl.prototype.currentTokenStart = function () { + return this.source.absolutePosition() + this.currentToken().leadingTriviaWidth(); + }; + + ParserImpl.prototype.previousTokenStart = function () { + if (this.previousToken() === null) { + return 0; + } + + return this.source.absolutePosition() - this.previousToken().fullWidth() + this.previousToken().leadingTriviaWidth(); + }; + + ParserImpl.prototype.previousTokenEnd = function () { + if (this.previousToken() === null) { + return 0; + } + + return this.previousTokenStart() + this.previousToken().width(); + }; + + ParserImpl.prototype.currentNode = function () { + var node = this.source.currentNode(); + + if (node === null || node.parsedInStrictMode() !== this.isInStrictMode) { + return null; + } + + return node; + }; + + ParserImpl.prototype.currentToken = function () { + return this.source.currentToken(); + }; + + ParserImpl.prototype.currentTokenAllowingRegularExpression = function () { + return this.source.currentTokenAllowingRegularExpression(); + }; + + ParserImpl.prototype.peekToken = function (n) { + return this.source.peekToken(n); + }; + + ParserImpl.prototype.eatAnyToken = function () { + var token = this.currentToken(); + this.moveToNextToken(); + return token; + }; + + ParserImpl.prototype.moveToNextToken = function () { + this.source.moveToNextToken(); + }; + + ParserImpl.prototype.previousToken = function () { + return this.source.previousToken(); + }; + + ParserImpl.prototype.eatNode = function () { + var node = this.source.currentNode(); + this.source.moveToNextNode(); + return node; + }; + + ParserImpl.prototype.eatToken = function (kind) { + var token = this.currentToken(); + if (token.tokenKind === kind) { + this.moveToNextToken(); + return token; + } + + return this.createMissingToken(kind, token); + }; + + ParserImpl.prototype.tryEatToken = function (kind) { + if (this.currentToken().tokenKind === kind) { + return this.eatToken(kind); + } + + return null; + }; + + ParserImpl.prototype.tryEatKeyword = function (kind) { + if (this.currentToken().tokenKind === kind) { + return this.eatKeyword(kind); + } + + return null; + }; + + ParserImpl.prototype.eatKeyword = function (kind) { + var token = this.currentToken(); + if (token.tokenKind === kind) { + this.moveToNextToken(); + return token; + } + + return this.createMissingToken(kind, token); + }; + + ParserImpl.prototype.isIdentifier = function (token) { + var tokenKind = token.tokenKind; + + if (tokenKind === 11 /* IdentifierName */) { + return true; + } + + if (tokenKind >= 51 /* FirstFutureReservedStrictKeyword */) { + if (tokenKind <= 59 /* LastFutureReservedStrictKeyword */) { + return !this.isInStrictMode; + } + + return tokenKind <= 69 /* LastTypeScriptKeyword */; + } + + return false; + }; + + ParserImpl.prototype.eatIdentifierNameToken = function () { + var token = this.currentToken(); + + if (token.tokenKind === 11 /* IdentifierName */) { + this.moveToNextToken(); + return token; + } + + if (TypeScript.SyntaxFacts.isAnyKeyword(token.tokenKind)) { + this.moveToNextToken(); + return TypeScript.Syntax.convertToIdentifierName(token); + } + + return this.createMissingToken(11 /* IdentifierName */, token); + }; + + ParserImpl.prototype.eatIdentifierToken = function () { + var token = this.currentToken(); + if (this.isIdentifier(token)) { + this.moveToNextToken(); + + if (token.tokenKind === 11 /* IdentifierName */) { + return token; + } + + return TypeScript.Syntax.convertToIdentifierName(token); + } + + return this.createMissingToken(11 /* IdentifierName */, token); + }; + + ParserImpl.prototype.canEatAutomaticSemicolon = function (allowWithoutNewLine) { + var token = this.currentToken(); + + if (token.tokenKind === 10 /* EndOfFileToken */) { + return true; + } + + if (token.tokenKind === 71 /* CloseBraceToken */) { + return true; + } + + if (allowWithoutNewLine) { + return true; + } + + if (this.previousToken() !== null && this.previousToken().hasTrailingNewLine()) { + return true; + } + + return false; + }; + + ParserImpl.prototype.canEatExplicitOrAutomaticSemicolon = function (allowWithoutNewline) { + var token = this.currentToken(); + + if (token.tokenKind === 78 /* SemicolonToken */) { + return true; + } + + return this.canEatAutomaticSemicolon(allowWithoutNewline); + }; + + ParserImpl.prototype.eatExplicitOrAutomaticSemicolon = function (allowWithoutNewline) { + var token = this.currentToken(); + + if (token.tokenKind === 78 /* SemicolonToken */) { + return this.eatToken(78 /* SemicolonToken */); + } + + if (this.canEatAutomaticSemicolon(allowWithoutNewline)) { + var semicolonToken = TypeScript.Syntax.emptyToken(78 /* SemicolonToken */); + + if (!this.parseOptions.allowAutomaticSemicolonInsertion()) { + this.addDiagnostic(new TypeScript.Diagnostic(this.fileName, this.previousTokenEnd(), 0, TypeScript.DiagnosticCode.Automatic_semicolon_insertion_not_allowed, null)); + } + + return semicolonToken; + } + + return this.eatToken(78 /* SemicolonToken */); + }; + + ParserImpl.prototype.isKeyword = function (kind) { + if (kind >= 15 /* FirstKeyword */) { + if (kind <= 50 /* LastFutureReservedKeyword */) { + return true; + } + + if (this.isInStrictMode) { + return kind <= 59 /* LastFutureReservedStrictKeyword */; + } + } + + return false; + }; + + ParserImpl.prototype.createMissingToken = function (expectedKind, actual) { + var diagnostic = this.getExpectedTokenDiagnostic(expectedKind, actual); + this.addDiagnostic(diagnostic); + + return TypeScript.Syntax.emptyToken(expectedKind); + }; + + ParserImpl.prototype.getExpectedTokenDiagnostic = function (expectedKind, actual) { + var token = this.currentToken(); + + if (TypeScript.SyntaxFacts.isAnyKeyword(expectedKind) || TypeScript.SyntaxFacts.isAnyPunctuation(expectedKind)) { + return new TypeScript.Diagnostic(this.fileName, this.currentTokenStart(), token.width(), TypeScript.DiagnosticCode._0_expected, [TypeScript.SyntaxFacts.getText(expectedKind)]); + } else { + if (actual !== null && TypeScript.SyntaxFacts.isAnyKeyword(actual.tokenKind)) { + return new TypeScript.Diagnostic(this.fileName, this.currentTokenStart(), token.width(), TypeScript.DiagnosticCode.Identifier_expected_0_is_a_keyword, [TypeScript.SyntaxFacts.getText(actual.tokenKind)]); + } else { + return new TypeScript.Diagnostic(this.fileName, this.currentTokenStart(), token.width(), TypeScript.DiagnosticCode.Identifier_expected, null); + } + } + }; + + ParserImpl.getPrecedence = function (expressionKind) { + switch (expressionKind) { + case 172 /* CommaExpression */: + return 1 /* CommaExpressionPrecedence */; + + case 173 /* AssignmentExpression */: + case 174 /* AddAssignmentExpression */: + case 175 /* SubtractAssignmentExpression */: + case 176 /* MultiplyAssignmentExpression */: + case 177 /* DivideAssignmentExpression */: + case 178 /* ModuloAssignmentExpression */: + case 179 /* AndAssignmentExpression */: + case 180 /* ExclusiveOrAssignmentExpression */: + case 181 /* OrAssignmentExpression */: + case 182 /* LeftShiftAssignmentExpression */: + case 183 /* SignedRightShiftAssignmentExpression */: + case 184 /* UnsignedRightShiftAssignmentExpression */: + return 2 /* AssignmentExpressionPrecedence */; + + case 185 /* ConditionalExpression */: + return 3 /* ConditionalExpressionPrecedence */; + + case 186 /* LogicalOrExpression */: + return 5 /* LogicalOrExpressionPrecedence */; + + case 187 /* LogicalAndExpression */: + return 6 /* LogicalAndExpressionPrecedence */; + + case 188 /* BitwiseOrExpression */: + return 7 /* BitwiseOrExpressionPrecedence */; + + case 189 /* BitwiseExclusiveOrExpression */: + return 8 /* BitwiseExclusiveOrExpressionPrecedence */; + + case 190 /* BitwiseAndExpression */: + return 9 /* BitwiseAndExpressionPrecedence */; + + case 191 /* EqualsWithTypeConversionExpression */: + case 192 /* NotEqualsWithTypeConversionExpression */: + case 193 /* EqualsExpression */: + case 194 /* NotEqualsExpression */: + return 10 /* EqualityExpressionPrecedence */; + + case 195 /* LessThanExpression */: + case 196 /* GreaterThanExpression */: + case 197 /* LessThanOrEqualExpression */: + case 198 /* GreaterThanOrEqualExpression */: + case 199 /* InstanceOfExpression */: + case 200 /* InExpression */: + return 11 /* RelationalExpressionPrecedence */; + + case 201 /* LeftShiftExpression */: + case 202 /* SignedRightShiftExpression */: + case 203 /* UnsignedRightShiftExpression */: + return 12 /* ShiftExpressionPrecdence */; + + case 207 /* AddExpression */: + case 208 /* SubtractExpression */: + return 13 /* AdditiveExpressionPrecedence */; + + case 204 /* MultiplyExpression */: + case 205 /* DivideExpression */: + case 206 /* ModuloExpression */: + return 14 /* MultiplicativeExpressionPrecedence */; + + case 163 /* PlusExpression */: + case 164 /* NegateExpression */: + case 165 /* BitwiseNotExpression */: + case 166 /* LogicalNotExpression */: + case 169 /* DeleteExpression */: + case 170 /* TypeOfExpression */: + case 171 /* VoidExpression */: + case 167 /* PreIncrementExpression */: + case 168 /* PreDecrementExpression */: + return 15 /* UnaryExpressionPrecedence */; + } + + throw TypeScript.Errors.invalidOperation(); + }; + + ParserImpl.prototype.addSkippedTokenAfterNodeOrToken = function (nodeOrToken, skippedToken) { + if (nodeOrToken.isToken()) { + return this.addSkippedTokenAfterToken(nodeOrToken, skippedToken); + } else if (nodeOrToken.isNode()) { + return this.addSkippedTokenAfterNode(nodeOrToken, skippedToken); + } else { + throw TypeScript.Errors.invalidOperation(); + } + }; + + ParserImpl.prototype.addSkippedTokenAfterNode = function (node, skippedToken) { + var oldToken = node.lastToken(); + var newToken = this.addSkippedTokenAfterToken(oldToken, skippedToken); + + return node.replaceToken(oldToken, newToken); + }; + + ParserImpl.prototype.addSkippedTokensBeforeNode = function (node, skippedTokens) { + if (skippedTokens.length > 0) { + var oldToken = node.firstToken(); + var newToken = this.addSkippedTokensBeforeToken(oldToken, skippedTokens); + + return node.replaceToken(oldToken, newToken); + } + + return node; + }; + + ParserImpl.prototype.addSkippedTokensBeforeToken = function (token, skippedTokens) { + var leadingTrivia = []; + for (var i = 0, n = skippedTokens.length; i < n; i++) { + this.addSkippedTokenToTriviaArray(leadingTrivia, skippedTokens[i]); + } + + this.addTriviaTo(token.leadingTrivia(), leadingTrivia); + + this.returnArray(skippedTokens); + return token.withLeadingTrivia(TypeScript.Syntax.triviaList(leadingTrivia)); + }; + + ParserImpl.prototype.addSkippedTokensAfterToken = function (token, skippedTokens) { + if (skippedTokens.length === 0) { + this.returnArray(skippedTokens); + return token; + } + + var trailingTrivia = token.trailingTrivia().toArray(); + + for (var i = 0, n = skippedTokens.length; i < n; i++) { + this.addSkippedTokenToTriviaArray(trailingTrivia, skippedTokens[i]); + } + + this.returnArray(skippedTokens); + return token.withTrailingTrivia(TypeScript.Syntax.triviaList(trailingTrivia)); + }; + + ParserImpl.prototype.addSkippedTokenAfterToken = function (token, skippedToken) { + var trailingTrivia = token.trailingTrivia().toArray(); + this.addSkippedTokenToTriviaArray(trailingTrivia, skippedToken); + + return token.withTrailingTrivia(TypeScript.Syntax.triviaList(trailingTrivia)); + }; + + ParserImpl.prototype.addSkippedTokenToTriviaArray = function (array, skippedToken) { + this.addTriviaTo(skippedToken.leadingTrivia(), array); + + var trimmedToken = skippedToken.withLeadingTrivia(TypeScript.Syntax.emptyTriviaList).withTrailingTrivia(TypeScript.Syntax.emptyTriviaList); + array.push(TypeScript.Syntax.skippedTokenTrivia(trimmedToken)); + + this.addTriviaTo(skippedToken.trailingTrivia(), array); + }; + + ParserImpl.prototype.addTriviaTo = function (list, array) { + for (var i = 0, n = list.count(); i < n; i++) { + array.push(list.syntaxTriviaAt(i)); + } + }; + + ParserImpl.prototype.parseSyntaxTree = function (isDeclaration) { + var sourceUnit = this.parseSourceUnit(); + + var allDiagnostics = this.source.tokenDiagnostics().concat(this.diagnostics); + allDiagnostics.sort(function (a, b) { + return a.start() - b.start(); + }); + + return new TypeScript.SyntaxTree(sourceUnit, isDeclaration, allDiagnostics, this.fileName, this.lineMap, this.parseOptions); + }; + + ParserImpl.prototype.setStrictMode = function (isInStrictMode) { + this.isInStrictMode = isInStrictMode; + this.factory = isInStrictMode ? TypeScript.Syntax.strictModeFactory : TypeScript.Syntax.normalModeFactory; + }; + + ParserImpl.prototype.parseSourceUnit = function () { + var savedIsInStrictMode = this.isInStrictMode; + + var result = this.parseSyntaxList(1 /* SourceUnit_ModuleElements */, ParserImpl.updateStrictModeState); + var moduleElements = result.list; + + this.setStrictMode(savedIsInStrictMode); + + var sourceUnit = this.factory.sourceUnit(moduleElements, this.currentToken()); + sourceUnit = this.addSkippedTokensBeforeNode(sourceUnit, result.skippedTokens); + + return sourceUnit; + }; + + ParserImpl.updateStrictModeState = function (parser, items) { + if (!parser.isInStrictMode) { + for (var i = 0; i < items.length; i++) { + var item = items[i]; + if (!TypeScript.SyntaxFacts.isDirectivePrologueElement(item)) { + return; + } + } + + parser.setStrictMode(TypeScript.SyntaxFacts.isUseStrictDirective(items[items.length - 1])); + } + }; + + ParserImpl.prototype.isModuleElement = function (inErrorRecovery) { + if (this.currentNode() !== null && this.currentNode().isModuleElement()) { + return true; + } + + return this.isImportDeclaration() || this.isExportAssignment() || this.isModuleDeclaration() || this.isInterfaceDeclaration() || this.isClassDeclaration() || this.isEnumDeclaration() || this.isStatement(inErrorRecovery); + }; + + ParserImpl.prototype.parseModuleElement = function () { + if (this.currentNode() !== null && this.currentNode().isModuleElement()) { + return this.eatNode(); + } + + if (this.isImportDeclaration()) { + return this.parseImportDeclaration(); + } else if (this.isExportAssignment()) { + return this.parseExportAssignment(); + } else if (this.isModuleDeclaration()) { + return this.parseModuleDeclaration(); + } else if (this.isInterfaceDeclaration()) { + return this.parseInterfaceDeclaration(); + } else if (this.isClassDeclaration()) { + return this.parseClassDeclaration(); + } else if (this.isEnumDeclaration()) { + return this.parseEnumDeclaration(); + } else if (this.isStatement(false)) { + return this.parseStatement(); + } else { + throw TypeScript.Errors.invalidOperation(); + } + }; + + ParserImpl.prototype.isImportDeclaration = function () { + var index = this.modifierCount(); + + if (index > 0 && this.peekToken(index).tokenKind === 49 /* ImportKeyword */) { + return true; + } + + return this.currentToken().tokenKind === 49 /* ImportKeyword */ && this.isIdentifier(this.peekToken(1)); + }; + + ParserImpl.prototype.parseImportDeclaration = function () { + var modifiers = this.parseModifiers(); + var importKeyword = this.eatKeyword(49 /* ImportKeyword */); + var identifier = this.eatIdentifierToken(); + var equalsToken = this.eatToken(107 /* EqualsToken */); + var moduleReference = this.parseModuleReference(); + var semicolonToken = this.eatExplicitOrAutomaticSemicolon(false); + + return this.factory.importDeclaration(modifiers, importKeyword, identifier, equalsToken, moduleReference, semicolonToken); + }; + + ParserImpl.prototype.isExportAssignment = function () { + return this.currentToken().tokenKind === 47 /* ExportKeyword */ && this.peekToken(1).tokenKind === 107 /* EqualsToken */; + }; + + ParserImpl.prototype.parseExportAssignment = function () { + var exportKeyword = this.eatKeyword(47 /* ExportKeyword */); + var equalsToken = this.eatToken(107 /* EqualsToken */); + var identifier = this.eatIdentifierToken(); + var semicolonToken = this.eatExplicitOrAutomaticSemicolon(false); + + return this.factory.exportAssignment(exportKeyword, equalsToken, identifier, semicolonToken); + }; + + ParserImpl.prototype.parseModuleReference = function () { + if (this.isExternalModuleReference()) { + return this.parseExternalModuleReference(); + } else { + return this.parseModuleNameModuleReference(); + } + }; + + ParserImpl.prototype.isExternalModuleReference = function () { + var token0 = this.currentToken(); + if (token0.tokenKind === 66 /* RequireKeyword */) { + return this.peekToken(1).tokenKind === 72 /* OpenParenToken */; + } + + return false; + }; + + ParserImpl.prototype.parseExternalModuleReference = function () { + var requireKeyword = this.eatKeyword(66 /* RequireKeyword */); + var openParenToken = this.eatToken(72 /* OpenParenToken */); + var stringLiteral = this.eatToken(14 /* StringLiteral */); + var closeParenToken = this.eatToken(73 /* CloseParenToken */); + + return this.factory.externalModuleReference(requireKeyword, openParenToken, stringLiteral, closeParenToken); + }; + + ParserImpl.prototype.parseModuleNameModuleReference = function () { + var name = this.parseName(); + return this.factory.moduleNameModuleReference(name); + }; + + ParserImpl.prototype.parseIdentifierName = function () { + var identifierName = this.eatIdentifierNameToken(); + return identifierName; + }; + + ParserImpl.prototype.isName = function () { + return this.isIdentifier(this.currentToken()); + }; + + ParserImpl.prototype.tryParseTypeArgumentList = function (inExpression) { + if (this.currentToken().kind() !== 80 /* LessThanToken */) { + return null; + } + + var lessThanToken; + var greaterThanToken; + var result; + var typeArguments; + + if (!inExpression) { + lessThanToken = this.eatToken(80 /* LessThanToken */); + + result = this.parseSeparatedSyntaxList(262144 /* TypeArgumentList_Types */); + typeArguments = result.list; + lessThanToken = this.addSkippedTokensAfterToken(lessThanToken, result.skippedTokens); + + greaterThanToken = this.eatToken(81 /* GreaterThanToken */); + + return this.factory.typeArgumentList(lessThanToken, typeArguments, greaterThanToken); + } + + var rewindPoint = this.getRewindPoint(); + try { + lessThanToken = this.eatToken(80 /* LessThanToken */); + + result = this.parseSeparatedSyntaxList(262144 /* TypeArgumentList_Types */); + typeArguments = result.list; + lessThanToken = this.addSkippedTokensAfterToken(lessThanToken, result.skippedTokens); + + greaterThanToken = this.eatToken(81 /* GreaterThanToken */); + + if (greaterThanToken.fullWidth() === 0 || !this.canFollowTypeArgumentListInExpression(this.currentToken().kind())) { + this.rewind(rewindPoint); + return null; + } + + return this.factory.typeArgumentList(lessThanToken, typeArguments, greaterThanToken); + } finally { + this.releaseRewindPoint(rewindPoint); + } + }; + + ParserImpl.prototype.canFollowTypeArgumentListInExpression = function (kind) { + switch (kind) { + case 72 /* OpenParenToken */: + case 76 /* DotToken */: + + case 73 /* CloseParenToken */: + case 75 /* CloseBracketToken */: + case 106 /* ColonToken */: + case 78 /* SemicolonToken */: + case 79 /* CommaToken */: + case 105 /* QuestionToken */: + case 84 /* EqualsEqualsToken */: + case 87 /* EqualsEqualsEqualsToken */: + case 86 /* ExclamationEqualsToken */: + case 88 /* ExclamationEqualsEqualsToken */: + case 103 /* AmpersandAmpersandToken */: + case 104 /* BarBarToken */: + case 100 /* CaretToken */: + case 98 /* AmpersandToken */: + case 99 /* BarToken */: + case 71 /* CloseBraceToken */: + case 10 /* EndOfFileToken */: + return true; + + default: + return false; + } + }; + + ParserImpl.prototype.parseName = function () { + var shouldContinue = this.isIdentifier(this.currentToken()); + var current = this.eatIdentifierToken(); + + while (shouldContinue && this.currentToken().tokenKind === 76 /* DotToken */) { + var dotToken = this.eatToken(76 /* DotToken */); + + var currentToken = this.currentToken(); + var identifierName; + + if (TypeScript.SyntaxFacts.isAnyKeyword(currentToken.tokenKind) && this.previousToken().hasTrailingNewLine() && !currentToken.hasTrailingNewLine() && TypeScript.SyntaxFacts.isIdentifierNameOrAnyKeyword(this.peekToken(1))) { + identifierName = this.createMissingToken(11 /* IdentifierName */, currentToken); + } else { + identifierName = this.eatIdentifierNameToken(); + } + + current = this.factory.qualifiedName(current, dotToken, identifierName); + + shouldContinue = identifierName.fullWidth() > 0; + } + + return current; + }; + + ParserImpl.prototype.isEnumDeclaration = function () { + var index = this.modifierCount(); + + if (index > 0 && this.peekToken(index).tokenKind === 46 /* EnumKeyword */) { + return true; + } + + return this.currentToken().tokenKind === 46 /* EnumKeyword */ && this.isIdentifier(this.peekToken(1)); + }; + + ParserImpl.prototype.parseEnumDeclaration = function () { + var modifiers = this.parseModifiers(); + var enumKeyword = this.eatKeyword(46 /* EnumKeyword */); + var identifier = this.eatIdentifierToken(); + + var openBraceToken = this.eatToken(70 /* OpenBraceToken */); + var enumElements = TypeScript.Syntax.emptySeparatedList; + + if (openBraceToken.width() > 0) { + var result = this.parseSeparatedSyntaxList(256 /* EnumDeclaration_EnumElements */); + enumElements = result.list; + openBraceToken = this.addSkippedTokensAfterToken(openBraceToken, result.skippedTokens); + } + + var closeBraceToken = this.eatToken(71 /* CloseBraceToken */); + + return this.factory.enumDeclaration(modifiers, enumKeyword, identifier, openBraceToken, enumElements, closeBraceToken); + }; + + ParserImpl.prototype.isEnumElement = function (inErrorRecovery) { + if (this.currentNode() !== null && this.currentNode().kind() === 243 /* EnumElement */) { + return true; + } + + return this.isPropertyName(this.currentToken(), inErrorRecovery); + }; + + ParserImpl.prototype.parseEnumElement = function () { + if (this.currentNode() !== null && this.currentNode().kind() === 243 /* EnumElement */) { + return this.eatNode(); + } + + var propertyName = this.eatPropertyName(); + var equalsValueClause = null; + if (this.isEqualsValueClause(false)) { + equalsValueClause = this.parseEqualsValueClause(true); + } + + return this.factory.enumElement(propertyName, equalsValueClause); + }; + + ParserImpl.isModifier = function (token) { + switch (token.tokenKind) { + case 57 /* PublicKeyword */: + case 55 /* PrivateKeyword */: + case 58 /* StaticKeyword */: + case 47 /* ExportKeyword */: + case 63 /* DeclareKeyword */: + return true; + + default: + return false; + } + }; + + ParserImpl.prototype.modifierCount = function () { + var modifierCount = 0; + while (true) { + if (ParserImpl.isModifier(this.peekToken(modifierCount))) { + modifierCount++; + continue; + } + + break; + } + + return modifierCount; + }; + + ParserImpl.prototype.parseModifiers = function () { + var tokens = this.getArray(); + + while (true) { + if (ParserImpl.isModifier(this.currentToken())) { + tokens.push(this.eatAnyToken()); + continue; + } + + break; + } + + var result = TypeScript.Syntax.list(tokens); + + this.returnZeroOrOneLengthArray(tokens); + + return result; + }; + + ParserImpl.prototype.isClassDeclaration = function () { + var index = this.modifierCount(); + + if (index > 0 && this.peekToken(index).tokenKind === 44 /* ClassKeyword */) { + return true; + } + + return this.currentToken().tokenKind === 44 /* ClassKeyword */ && this.isIdentifier(this.peekToken(1)); + }; + + ParserImpl.prototype.parseHeritageClauses = function () { + var heritageClauses = TypeScript.Syntax.emptyList; + + if (this.isHeritageClause()) { + var result = this.parseSyntaxList(1024 /* ClassOrInterfaceDeclaration_HeritageClauses */); + heritageClauses = result.list; + TypeScript.Debug.assert(result.skippedTokens.length === 0); + } + + return heritageClauses; + }; + + ParserImpl.prototype.parseClassDeclaration = function () { + var modifiers = this.parseModifiers(); + + var classKeyword = this.eatKeyword(44 /* ClassKeyword */); + var identifier = this.eatIdentifierToken(); + var typeParameterList = this.parseOptionalTypeParameterList(false); + var heritageClauses = this.parseHeritageClauses(); + var openBraceToken = this.eatToken(70 /* OpenBraceToken */); + var classElements = TypeScript.Syntax.emptyList; + + if (openBraceToken.width() > 0) { + var result = this.parseSyntaxList(2 /* ClassDeclaration_ClassElements */); + + classElements = result.list; + openBraceToken = this.addSkippedTokensAfterToken(openBraceToken, result.skippedTokens); + } + + var closeBraceToken = this.eatToken(71 /* CloseBraceToken */); + return this.factory.classDeclaration(modifiers, classKeyword, identifier, typeParameterList, heritageClauses, openBraceToken, classElements, closeBraceToken); + }; + + ParserImpl.prototype.isConstructorDeclaration = function () { + return this.currentToken().tokenKind === 62 /* ConstructorKeyword */; + }; + + ParserImpl.isPublicOrPrivateKeyword = function (token) { + return token.tokenKind === 57 /* PublicKeyword */ || token.tokenKind === 55 /* PrivateKeyword */; + }; + + ParserImpl.prototype.isMemberAccessorDeclaration = function (inErrorRecovery) { + var index = this.modifierCount(); + + if (this.peekToken(index).tokenKind !== 64 /* GetKeyword */ && this.peekToken(index).tokenKind !== 68 /* SetKeyword */) { + return false; + } + + index++; + return this.isPropertyName(this.peekToken(index), inErrorRecovery); + }; + + ParserImpl.prototype.parseMemberAccessorDeclaration = function () { + var modifiers = this.parseModifiers(); + + if (this.currentToken().tokenKind === 64 /* GetKeyword */) { + return this.parseGetMemberAccessorDeclaration(modifiers); + } else if (this.currentToken().tokenKind === 68 /* SetKeyword */) { + return this.parseSetMemberAccessorDeclaration(modifiers); + } else { + throw TypeScript.Errors.invalidOperation(); + } + }; + + ParserImpl.prototype.parseGetMemberAccessorDeclaration = function (modifiers) { + var getKeyword = this.eatKeyword(64 /* GetKeyword */); + var propertyName = this.eatPropertyName(); + var parameterList = this.parseParameterList(); + var typeAnnotation = this.parseOptionalTypeAnnotation(false); + var block = this.parseBlock(false, false); + + return this.factory.getMemberAccessorDeclaration(modifiers, getKeyword, propertyName, parameterList, typeAnnotation, block); + }; + + ParserImpl.prototype.parseSetMemberAccessorDeclaration = function (modifiers) { + var setKeyword = this.eatKeyword(68 /* SetKeyword */); + var propertyName = this.eatPropertyName(); + var parameterList = this.parseParameterList(); + var block = this.parseBlock(false, false); + + return this.factory.setMemberAccessorDeclaration(modifiers, setKeyword, propertyName, parameterList, block); + }; + + ParserImpl.prototype.isClassElement = function (inErrorRecovery) { + if (this.currentNode() !== null && this.currentNode().isClassElement()) { + return true; + } + + return this.isConstructorDeclaration() || this.isMemberFunctionDeclaration(inErrorRecovery) || this.isMemberAccessorDeclaration(inErrorRecovery) || this.isMemberVariableDeclaration(inErrorRecovery) || this.isIndexSignature(); + }; + + ParserImpl.prototype.parseConstructorDeclaration = function () { + var constructorKeyword = this.eatKeyword(62 /* ConstructorKeyword */); + var parameterList = this.parseParameterList(); + + var semicolonToken = null; + var block = null; + + if (this.isBlock()) { + block = this.parseBlock(false, true); + } else { + semicolonToken = this.eatExplicitOrAutomaticSemicolon(false); + } + + return this.factory.constructorDeclaration(constructorKeyword, parameterList, block, semicolonToken); + }; + + ParserImpl.prototype.isMemberFunctionDeclaration = function (inErrorRecovery) { + var index = 0; + + while (true) { + var token = this.peekToken(index); + if (this.isPropertyName(token, inErrorRecovery) && this.isCallSignature(index + 1)) { + return true; + } + + if (ParserImpl.isModifier(token)) { + index++; + continue; + } + + return false; + } + }; + + ParserImpl.prototype.parseMemberFunctionDeclaration = function () { + var modifierArray = this.getArray(); + + while (true) { + var currentToken = this.currentToken(); + if (this.isPropertyName(currentToken, false) && this.isCallSignature(1)) { + break; + } + + TypeScript.Debug.assert(ParserImpl.isModifier(currentToken)); + modifierArray.push(this.eatAnyToken()); + } + + var modifiers = TypeScript.Syntax.list(modifierArray); + this.returnZeroOrOneLengthArray(modifierArray); + + var propertyName = this.eatPropertyName(); + var callSignature = this.parseCallSignature(false); + + var newCallSignature = this.tryAddUnexpectedEqualsGreaterThanToken(callSignature); + var parseBlockEvenWithNoOpenBrace = callSignature !== newCallSignature; + callSignature = newCallSignature; + + var block = null; + var semicolon = null; + + if (parseBlockEvenWithNoOpenBrace || this.isBlock()) { + block = this.parseBlock(parseBlockEvenWithNoOpenBrace, true); + } else { + semicolon = this.eatExplicitOrAutomaticSemicolon(false); + } + + return this.factory.memberFunctionDeclaration(modifiers, propertyName, callSignature, block, semicolon); + }; + + ParserImpl.prototype.isDefinitelyMemberVariablePropertyName = function (index) { + if (TypeScript.SyntaxFacts.isAnyKeyword(this.peekToken(index).tokenKind)) { + switch (this.peekToken(index + 1).tokenKind) { + case 78 /* SemicolonToken */: + case 107 /* EqualsToken */: + case 106 /* ColonToken */: + case 71 /* CloseBraceToken */: + case 10 /* EndOfFileToken */: + return true; + default: + return false; + } + } else { + return true; + } + }; + + ParserImpl.prototype.isMemberVariableDeclaration = function (inErrorRecovery) { + var index = 0; + + while (true) { + var token = this.peekToken(index); + if (this.isPropertyName(token, inErrorRecovery) && this.isDefinitelyMemberVariablePropertyName(index)) { + return true; + } + + if (ParserImpl.isModifier(this.peekToken(index))) { + index++; + continue; + } + + return false; + } + }; + + ParserImpl.prototype.parseMemberVariableDeclaration = function () { + var modifierArray = this.getArray(); + + while (true) { + var currentToken = this.currentToken(); + if (this.isPropertyName(currentToken, false) && this.isDefinitelyMemberVariablePropertyName(0)) { + break; + } + + TypeScript.Debug.assert(ParserImpl.isModifier(currentToken)); + modifierArray.push(this.eatAnyToken()); + } + + var modifiers = TypeScript.Syntax.list(modifierArray); + this.returnZeroOrOneLengthArray(modifierArray); + + var variableDeclarator = this.parseVariableDeclarator(true, true); + var semicolon = this.eatExplicitOrAutomaticSemicolon(false); + + return this.factory.memberVariableDeclaration(modifiers, variableDeclarator, semicolon); + }; + + ParserImpl.prototype.parseClassElement = function (inErrorRecovery) { + if (this.currentNode() !== null && this.currentNode().isClassElement()) { + return this.eatNode(); + } + + if (this.isConstructorDeclaration()) { + return this.parseConstructorDeclaration(); + } else if (this.isMemberFunctionDeclaration(inErrorRecovery)) { + return this.parseMemberFunctionDeclaration(); + } else if (this.isMemberAccessorDeclaration(inErrorRecovery)) { + return this.parseMemberAccessorDeclaration(); + } else if (this.isMemberVariableDeclaration(inErrorRecovery)) { + return this.parseMemberVariableDeclaration(); + } else if (this.isIndexSignature()) { + return this.parseIndexSignature(); + } else { + throw TypeScript.Errors.invalidOperation(); + } + }; + + ParserImpl.prototype.tryAddUnexpectedEqualsGreaterThanToken = function (callSignature) { + var token0 = this.currentToken(); + + var hasEqualsGreaterThanToken = token0.tokenKind === 85 /* EqualsGreaterThanToken */; + if (hasEqualsGreaterThanToken) { + var diagnostic = new TypeScript.Diagnostic(this.fileName, this.currentTokenStart(), token0.width(), TypeScript.DiagnosticCode.Unexpected_token_0_expected, [TypeScript.SyntaxFacts.getText(70 /* OpenBraceToken */)]); + this.addDiagnostic(diagnostic); + + var token = this.eatAnyToken(); + return this.addSkippedTokenAfterNode(callSignature, token0); + } + + return callSignature; + }; + + ParserImpl.prototype.isFunctionDeclaration = function () { + var index = this.modifierCount(); + return this.peekToken(index).tokenKind === 27 /* FunctionKeyword */; + }; + + ParserImpl.prototype.parseFunctionDeclaration = function () { + var modifiers = this.parseModifiers(); + var functionKeyword = this.eatKeyword(27 /* FunctionKeyword */); + var identifier = this.eatIdentifierToken(); + var callSignature = this.parseCallSignature(false); + + var newCallSignature = this.tryAddUnexpectedEqualsGreaterThanToken(callSignature); + var parseBlockEvenWithNoOpenBrace = callSignature !== newCallSignature; + callSignature = newCallSignature; + + var semicolonToken = null; + var block = null; + + if (parseBlockEvenWithNoOpenBrace || this.isBlock()) { + block = this.parseBlock(parseBlockEvenWithNoOpenBrace, true); + } else { + semicolonToken = this.eatExplicitOrAutomaticSemicolon(false); + } + + return this.factory.functionDeclaration(modifiers, functionKeyword, identifier, callSignature, block, semicolonToken); + }; + + ParserImpl.prototype.isModuleDeclaration = function () { + var index = this.modifierCount(); + + if (index > 0 && this.peekToken(index).tokenKind === 65 /* ModuleKeyword */) { + return true; + } + + if (this.currentToken().tokenKind === 65 /* ModuleKeyword */) { + var token1 = this.peekToken(1); + return this.isIdentifier(token1) || token1.tokenKind === 14 /* StringLiteral */; + } + + return false; + }; + + ParserImpl.prototype.parseModuleDeclaration = function () { + var modifiers = this.parseModifiers(); + var moduleKeyword = this.eatKeyword(65 /* ModuleKeyword */); + + var moduleName = null; + var stringLiteral = null; + + if (this.currentToken().tokenKind === 14 /* StringLiteral */) { + stringLiteral = this.eatToken(14 /* StringLiteral */); + } else { + moduleName = this.parseName(); + } + + var openBraceToken = this.eatToken(70 /* OpenBraceToken */); + + var moduleElements = TypeScript.Syntax.emptyList; + if (openBraceToken.width() > 0) { + var result = this.parseSyntaxList(4 /* ModuleDeclaration_ModuleElements */); + moduleElements = result.list; + openBraceToken = this.addSkippedTokensAfterToken(openBraceToken, result.skippedTokens); + } + + var closeBraceToken = this.eatToken(71 /* CloseBraceToken */); + + return this.factory.moduleDeclaration(modifiers, moduleKeyword, moduleName, stringLiteral, openBraceToken, moduleElements, closeBraceToken); + }; + + ParserImpl.prototype.isInterfaceDeclaration = function () { + var index = this.modifierCount(); + + if (index > 0 && this.peekToken(index).tokenKind === 52 /* InterfaceKeyword */) { + return true; + } + + return this.currentToken().tokenKind === 52 /* InterfaceKeyword */ && this.isIdentifier(this.peekToken(1)); + }; + + ParserImpl.prototype.parseInterfaceDeclaration = function () { + var modifiers = this.parseModifiers(); + var interfaceKeyword = this.eatKeyword(52 /* InterfaceKeyword */); + var identifier = this.eatIdentifierToken(); + var typeParameterList = this.parseOptionalTypeParameterList(false); + var heritageClauses = this.parseHeritageClauses(); + + var objectType = this.parseObjectType(); + return this.factory.interfaceDeclaration(modifiers, interfaceKeyword, identifier, typeParameterList, heritageClauses, objectType); + }; + + ParserImpl.prototype.parseObjectType = function () { + var openBraceToken = this.eatToken(70 /* OpenBraceToken */); + + var typeMembers = TypeScript.Syntax.emptySeparatedList; + if (openBraceToken.width() > 0) { + var result = this.parseSeparatedSyntaxList(512 /* ObjectType_TypeMembers */); + typeMembers = result.list; + openBraceToken = this.addSkippedTokensAfterToken(openBraceToken, result.skippedTokens); + } + + var closeBraceToken = this.eatToken(71 /* CloseBraceToken */); + return this.factory.objectType(openBraceToken, typeMembers, closeBraceToken); + }; + + ParserImpl.prototype.isTypeMember = function (inErrorRecovery) { + if (this.currentNode() !== null && this.currentNode().isTypeMember()) { + return true; + } + + return this.isCallSignature(0) || this.isConstructSignature() || this.isIndexSignature() || this.isMethodSignature(inErrorRecovery) || this.isPropertySignature(inErrorRecovery); + }; + + ParserImpl.prototype.parseTypeMember = function () { + if (this.currentNode() !== null && this.currentNode().isTypeMember()) { + return this.eatNode(); + } + + if (this.isCallSignature(0)) { + return this.parseCallSignature(false); + } else if (this.isConstructSignature()) { + return this.parseConstructSignature(); + } else if (this.isIndexSignature()) { + return this.parseIndexSignature(); + } else if (this.isMethodSignature(false)) { + return this.parseMethodSignature(); + } else if (this.isPropertySignature(false)) { + return this.parsePropertySignature(); + } else { + throw TypeScript.Errors.invalidOperation(); + } + }; + + ParserImpl.prototype.parseConstructSignature = function () { + var newKeyword = this.eatKeyword(31 /* NewKeyword */); + var callSignature = this.parseCallSignature(false); + + return this.factory.constructSignature(newKeyword, callSignature); + }; + + ParserImpl.prototype.parseIndexSignature = function () { + var openBracketToken = this.eatToken(74 /* OpenBracketToken */); + var parameter = this.parseParameter(); + var closeBracketToken = this.eatToken(75 /* CloseBracketToken */); + var typeAnnotation = this.parseOptionalTypeAnnotation(false); + + return this.factory.indexSignature(openBracketToken, parameter, closeBracketToken, typeAnnotation); + }; + + ParserImpl.prototype.parseMethodSignature = function () { + var propertyName = this.eatPropertyName(); + var questionToken = this.tryEatToken(105 /* QuestionToken */); + var callSignature = this.parseCallSignature(false); + + return this.factory.methodSignature(propertyName, questionToken, callSignature); + }; + + ParserImpl.prototype.parsePropertySignature = function () { + var propertyName = this.eatPropertyName(); + var questionToken = this.tryEatToken(105 /* QuestionToken */); + var typeAnnotation = this.parseOptionalTypeAnnotation(false); + + return this.factory.propertySignature(propertyName, questionToken, typeAnnotation); + }; + + ParserImpl.prototype.isCallSignature = function (tokenIndex) { + var tokenKind = this.peekToken(tokenIndex).tokenKind; + return tokenKind === 72 /* OpenParenToken */ || tokenKind === 80 /* LessThanToken */; + }; + + ParserImpl.prototype.isConstructSignature = function () { + if (this.currentToken().tokenKind !== 31 /* NewKeyword */) { + return false; + } + + var token1 = this.peekToken(1); + return token1.tokenKind === 80 /* LessThanToken */ || token1.tokenKind === 72 /* OpenParenToken */; + }; + + ParserImpl.prototype.isIndexSignature = function () { + return this.currentToken().tokenKind === 74 /* OpenBracketToken */; + }; + + ParserImpl.prototype.isMethodSignature = function (inErrorRecovery) { + if (this.isPropertyName(this.currentToken(), inErrorRecovery)) { + if (this.isCallSignature(1)) { + return true; + } + + if (this.peekToken(1).tokenKind === 105 /* QuestionToken */ && this.isCallSignature(2)) { + return true; + } + } + + return false; + }; + + ParserImpl.prototype.isPropertySignature = function (inErrorRecovery) { + var currentToken = this.currentToken(); + + if (ParserImpl.isModifier(currentToken) && !currentToken.hasTrailingNewLine() && this.isPropertyName(this.peekToken(1), inErrorRecovery)) { + return false; + } + + return this.isPropertyName(currentToken, inErrorRecovery); + }; + + ParserImpl.prototype.isHeritageClause = function () { + var token0 = this.currentToken(); + return token0.tokenKind === 48 /* ExtendsKeyword */ || token0.tokenKind === 51 /* ImplementsKeyword */; + }; + + ParserImpl.prototype.isNotHeritageClauseTypeName = function () { + if (this.currentToken().tokenKind === 51 /* ImplementsKeyword */ || this.currentToken().tokenKind === 48 /* ExtendsKeyword */) { + return this.isIdentifier(this.peekToken(1)); + } + + return false; + }; + + ParserImpl.prototype.isHeritageClauseTypeName = function () { + if (this.isName()) { + return !this.isNotHeritageClauseTypeName(); + } + + return false; + }; + + ParserImpl.prototype.parseHeritageClause = function () { + var extendsOrImplementsKeyword = this.eatAnyToken(); + TypeScript.Debug.assert(extendsOrImplementsKeyword.tokenKind === 48 /* ExtendsKeyword */ || extendsOrImplementsKeyword.tokenKind === 51 /* ImplementsKeyword */); + + var result = this.parseSeparatedSyntaxList(2048 /* HeritageClause_TypeNameList */); + var typeNames = result.list; + extendsOrImplementsKeyword = this.addSkippedTokensAfterToken(extendsOrImplementsKeyword, result.skippedTokens); + + return this.factory.heritageClause(extendsOrImplementsKeyword, typeNames); + }; + + ParserImpl.prototype.isStatement = function (inErrorRecovery) { + if (this.currentNode() !== null && this.currentNode().isStatement()) { + return true; + } + + switch (this.currentToken().tokenKind) { + case 57 /* PublicKeyword */: + case 55 /* PrivateKeyword */: + case 58 /* StaticKeyword */: + var token1 = this.peekToken(1); + if (TypeScript.SyntaxFacts.isIdentifierNameOrAnyKeyword(token1)) { + return false; + } + } + + return this.isVariableStatement() || this.isLabeledStatement() || this.isFunctionDeclaration() || this.isIfStatement() || this.isBlock() || this.isExpressionStatement() || this.isReturnStatement() || this.isSwitchStatement() || this.isThrowStatement() || this.isBreakStatement() || this.isContinueStatement() || this.isForOrForInStatement() || this.isEmptyStatement(inErrorRecovery) || this.isWhileStatement() || this.isWithStatement() || this.isDoStatement() || this.isTryStatement() || this.isDebuggerStatement(); + }; + + ParserImpl.prototype.parseStatement = function () { + if (this.currentNode() !== null && this.currentNode().isStatement()) { + return this.eatNode(); + } + + if (this.isVariableStatement()) { + return this.parseVariableStatement(); + } else if (this.isLabeledStatement()) { + return this.parseLabeledStatement(); + } else if (this.isFunctionDeclaration()) { + return this.parseFunctionDeclaration(); + } else if (this.isIfStatement()) { + return this.parseIfStatement(); + } else if (this.isBlock()) { + return this.parseBlock(false, false); + } else if (this.isReturnStatement()) { + return this.parseReturnStatement(); + } else if (this.isSwitchStatement()) { + return this.parseSwitchStatement(); + } else if (this.isThrowStatement()) { + return this.parseThrowStatement(); + } else if (this.isBreakStatement()) { + return this.parseBreakStatement(); + } else if (this.isContinueStatement()) { + return this.parseContinueStatement(); + } else if (this.isForOrForInStatement()) { + return this.parseForOrForInStatement(); + } else if (this.isEmptyStatement(false)) { + return this.parseEmptyStatement(); + } else if (this.isWhileStatement()) { + return this.parseWhileStatement(); + } else if (this.isWithStatement()) { + return this.parseWithStatement(); + } else if (this.isDoStatement()) { + return this.parseDoStatement(); + } else if (this.isTryStatement()) { + return this.parseTryStatement(); + } else if (this.isDebuggerStatement()) { + return this.parseDebuggerStatement(); + } else { + return this.parseExpressionStatement(); + } + }; + + ParserImpl.prototype.isDebuggerStatement = function () { + return this.currentToken().tokenKind === 19 /* DebuggerKeyword */; + }; + + ParserImpl.prototype.parseDebuggerStatement = function () { + var debuggerKeyword = this.eatKeyword(19 /* DebuggerKeyword */); + var semicolonToken = this.eatExplicitOrAutomaticSemicolon(false); + + return this.factory.debuggerStatement(debuggerKeyword, semicolonToken); + }; + + ParserImpl.prototype.isDoStatement = function () { + return this.currentToken().tokenKind === 22 /* DoKeyword */; + }; + + ParserImpl.prototype.parseDoStatement = function () { + var doKeyword = this.eatKeyword(22 /* DoKeyword */); + var statement = this.parseStatement(); + var whileKeyword = this.eatKeyword(42 /* WhileKeyword */); + var openParenToken = this.eatToken(72 /* OpenParenToken */); + var condition = this.parseExpression(true); + var closeParenToken = this.eatToken(73 /* CloseParenToken */); + + var semicolonToken = this.eatExplicitOrAutomaticSemicolon(true); + + return this.factory.doStatement(doKeyword, statement, whileKeyword, openParenToken, condition, closeParenToken, semicolonToken); + }; + + ParserImpl.prototype.isLabeledStatement = function () { + return this.isIdentifier(this.currentToken()) && this.peekToken(1).tokenKind === 106 /* ColonToken */; + }; + + ParserImpl.prototype.parseLabeledStatement = function () { + var identifier = this.eatIdentifierToken(); + var colonToken = this.eatToken(106 /* ColonToken */); + var statement = this.parseStatement(); + + return this.factory.labeledStatement(identifier, colonToken, statement); + }; + + ParserImpl.prototype.isTryStatement = function () { + return this.currentToken().tokenKind === 38 /* TryKeyword */; + }; + + ParserImpl.prototype.parseTryStatement = function () { + var tryKeyword = this.eatKeyword(38 /* TryKeyword */); + + var savedListParsingState = this.listParsingState; + this.listParsingState |= 64 /* TryBlock_Statements */; + var block = this.parseBlock(false, false); + this.listParsingState = savedListParsingState; + + var catchClause = null; + if (this.isCatchClause()) { + catchClause = this.parseCatchClause(); + } + + var finallyClause = null; + if (catchClause === null || this.isFinallyClause()) { + finallyClause = this.parseFinallyClause(); + } + + return this.factory.tryStatement(tryKeyword, block, catchClause, finallyClause); + }; + + ParserImpl.prototype.isCatchClause = function () { + return this.currentToken().tokenKind === 17 /* CatchKeyword */; + }; + + ParserImpl.prototype.parseCatchClause = function () { + var catchKeyword = this.eatKeyword(17 /* CatchKeyword */); + var openParenToken = this.eatToken(72 /* OpenParenToken */); + var identifier = this.eatIdentifierToken(); + var typeAnnotation = this.parseOptionalTypeAnnotation(false); + var closeParenToken = this.eatToken(73 /* CloseParenToken */); + + var savedListParsingState = this.listParsingState; + this.listParsingState |= 128 /* CatchBlock_Statements */; + var block = this.parseBlock(false, false); + this.listParsingState = savedListParsingState; + + return this.factory.catchClause(catchKeyword, openParenToken, identifier, typeAnnotation, closeParenToken, block); + }; + + ParserImpl.prototype.isFinallyClause = function () { + return this.currentToken().tokenKind === 25 /* FinallyKeyword */; + }; + + ParserImpl.prototype.parseFinallyClause = function () { + var finallyKeyword = this.eatKeyword(25 /* FinallyKeyword */); + var block = this.parseBlock(false, false); + + return this.factory.finallyClause(finallyKeyword, block); + }; + + ParserImpl.prototype.isWithStatement = function () { + return this.currentToken().tokenKind === 43 /* WithKeyword */; + }; + + ParserImpl.prototype.parseWithStatement = function () { + var withKeyword = this.eatKeyword(43 /* WithKeyword */); + var openParenToken = this.eatToken(72 /* OpenParenToken */); + var condition = this.parseExpression(true); + var closeParenToken = this.eatToken(73 /* CloseParenToken */); + var statement = this.parseStatement(); + + return this.factory.withStatement(withKeyword, openParenToken, condition, closeParenToken, statement); + }; + + ParserImpl.prototype.isWhileStatement = function () { + return this.currentToken().tokenKind === 42 /* WhileKeyword */; + }; + + ParserImpl.prototype.parseWhileStatement = function () { + var whileKeyword = this.eatKeyword(42 /* WhileKeyword */); + var openParenToken = this.eatToken(72 /* OpenParenToken */); + var condition = this.parseExpression(true); + var closeParenToken = this.eatToken(73 /* CloseParenToken */); + var statement = this.parseStatement(); + + return this.factory.whileStatement(whileKeyword, openParenToken, condition, closeParenToken, statement); + }; + + ParserImpl.prototype.isEmptyStatement = function (inErrorRecovery) { + if (inErrorRecovery) { + return false; + } + + return this.currentToken().tokenKind === 78 /* SemicolonToken */; + }; + + ParserImpl.prototype.parseEmptyStatement = function () { + var semicolonToken = this.eatToken(78 /* SemicolonToken */); + return this.factory.emptyStatement(semicolonToken); + }; + + ParserImpl.prototype.isForOrForInStatement = function () { + return this.currentToken().tokenKind === 26 /* ForKeyword */; + }; + + ParserImpl.prototype.parseForOrForInStatement = function () { + var forKeyword = this.eatKeyword(26 /* ForKeyword */); + var openParenToken = this.eatToken(72 /* OpenParenToken */); + + var currentToken = this.currentToken(); + if (currentToken.tokenKind === 40 /* VarKeyword */) { + return this.parseForOrForInStatementWithVariableDeclaration(forKeyword, openParenToken); + } else if (currentToken.tokenKind === 78 /* SemicolonToken */) { + return this.parseForStatement(forKeyword, openParenToken); + } else { + return this.parseForOrForInStatementWithInitializer(forKeyword, openParenToken); + } + }; + + ParserImpl.prototype.parseForOrForInStatementWithVariableDeclaration = function (forKeyword, openParenToken) { + var variableDeclaration = this.parseVariableDeclaration(false); + + if (this.currentToken().tokenKind === 29 /* InKeyword */) { + return this.parseForInStatementWithVariableDeclarationOrInitializer(forKeyword, openParenToken, variableDeclaration, null); + } + + return this.parseForStatementWithVariableDeclarationOrInitializer(forKeyword, openParenToken, variableDeclaration, null); + }; + + ParserImpl.prototype.parseForInStatementWithVariableDeclarationOrInitializer = function (forKeyword, openParenToken, variableDeclaration, initializer) { + var inKeyword = this.eatKeyword(29 /* InKeyword */); + var expression = this.parseExpression(true); + var closeParenToken = this.eatToken(73 /* CloseParenToken */); + var statement = this.parseStatement(); + + return this.factory.forInStatement(forKeyword, openParenToken, variableDeclaration, initializer, inKeyword, expression, closeParenToken, statement); + }; + + ParserImpl.prototype.parseForOrForInStatementWithInitializer = function (forKeyword, openParenToken) { + var initializer = this.parseExpression(false); + if (this.currentToken().tokenKind === 29 /* InKeyword */) { + return this.parseForInStatementWithVariableDeclarationOrInitializer(forKeyword, openParenToken, null, initializer); + } else { + return this.parseForStatementWithVariableDeclarationOrInitializer(forKeyword, openParenToken, null, initializer); + } + }; + + ParserImpl.prototype.parseForStatement = function (forKeyword, openParenToken) { + var initializer = null; + + if (this.currentToken().tokenKind !== 78 /* SemicolonToken */ && this.currentToken().tokenKind !== 73 /* CloseParenToken */ && this.currentToken().tokenKind !== 10 /* EndOfFileToken */) { + initializer = this.parseExpression(false); + } + + return this.parseForStatementWithVariableDeclarationOrInitializer(forKeyword, openParenToken, null, initializer); + }; + + ParserImpl.prototype.parseForStatementWithVariableDeclarationOrInitializer = function (forKeyword, openParenToken, variableDeclaration, initializer) { + var firstSemicolonToken = this.eatToken(78 /* SemicolonToken */); + + var condition = null; + if (this.currentToken().tokenKind !== 78 /* SemicolonToken */ && this.currentToken().tokenKind !== 73 /* CloseParenToken */ && this.currentToken().tokenKind !== 10 /* EndOfFileToken */) { + condition = this.parseExpression(true); + } + + var secondSemicolonToken = this.eatToken(78 /* SemicolonToken */); + + var incrementor = null; + if (this.currentToken().tokenKind !== 73 /* CloseParenToken */ && this.currentToken().tokenKind !== 10 /* EndOfFileToken */) { + incrementor = this.parseExpression(true); + } + + var closeParenToken = this.eatToken(73 /* CloseParenToken */); + var statement = this.parseStatement(); + + return this.factory.forStatement(forKeyword, openParenToken, variableDeclaration, initializer, firstSemicolonToken, condition, secondSemicolonToken, incrementor, closeParenToken, statement); + }; + + ParserImpl.prototype.isBreakStatement = function () { + return this.currentToken().tokenKind === 15 /* BreakKeyword */; + }; + + ParserImpl.prototype.parseBreakStatement = function () { + var breakKeyword = this.eatKeyword(15 /* BreakKeyword */); + + var identifier = null; + if (!this.canEatExplicitOrAutomaticSemicolon(false)) { + if (this.isIdentifier(this.currentToken())) { + identifier = this.eatIdentifierToken(); + } + } + + var semicolon = this.eatExplicitOrAutomaticSemicolon(false); + return this.factory.breakStatement(breakKeyword, identifier, semicolon); + }; + + ParserImpl.prototype.isContinueStatement = function () { + return this.currentToken().tokenKind === 18 /* ContinueKeyword */; + }; + + ParserImpl.prototype.parseContinueStatement = function () { + var continueKeyword = this.eatKeyword(18 /* ContinueKeyword */); + + var identifier = null; + if (!this.canEatExplicitOrAutomaticSemicolon(false)) { + if (this.isIdentifier(this.currentToken())) { + identifier = this.eatIdentifierToken(); + } + } + + var semicolon = this.eatExplicitOrAutomaticSemicolon(false); + return this.factory.continueStatement(continueKeyword, identifier, semicolon); + }; + + ParserImpl.prototype.isSwitchStatement = function () { + return this.currentToken().tokenKind === 34 /* SwitchKeyword */; + }; + + ParserImpl.prototype.parseSwitchStatement = function () { + var switchKeyword = this.eatKeyword(34 /* SwitchKeyword */); + var openParenToken = this.eatToken(72 /* OpenParenToken */); + var expression = this.parseExpression(true); + var closeParenToken = this.eatToken(73 /* CloseParenToken */); + + var openBraceToken = this.eatToken(70 /* OpenBraceToken */); + + var switchClauses = TypeScript.Syntax.emptyList; + if (openBraceToken.width() > 0) { + var result = this.parseSyntaxList(8 /* SwitchStatement_SwitchClauses */); + switchClauses = result.list; + openBraceToken = this.addSkippedTokensAfterToken(openBraceToken, result.skippedTokens); + } + + var closeBraceToken = this.eatToken(71 /* CloseBraceToken */); + return this.factory.switchStatement(switchKeyword, openParenToken, expression, closeParenToken, openBraceToken, switchClauses, closeBraceToken); + }; + + ParserImpl.prototype.isCaseSwitchClause = function () { + return this.currentToken().tokenKind === 16 /* CaseKeyword */; + }; + + ParserImpl.prototype.isDefaultSwitchClause = function () { + return this.currentToken().tokenKind === 20 /* DefaultKeyword */; + }; + + ParserImpl.prototype.isSwitchClause = function () { + if (this.currentNode() !== null && this.currentNode().isSwitchClause()) { + return true; + } + + return this.isCaseSwitchClause() || this.isDefaultSwitchClause(); + }; + + ParserImpl.prototype.parseSwitchClause = function () { + if (this.currentNode() !== null && this.currentNode().isSwitchClause()) { + return this.eatNode(); + } + + if (this.isCaseSwitchClause()) { + return this.parseCaseSwitchClause(); + } else if (this.isDefaultSwitchClause()) { + return this.parseDefaultSwitchClause(); + } else { + throw TypeScript.Errors.invalidOperation(); + } + }; + + ParserImpl.prototype.parseCaseSwitchClause = function () { + var caseKeyword = this.eatKeyword(16 /* CaseKeyword */); + var expression = this.parseExpression(true); + var colonToken = this.eatToken(106 /* ColonToken */); + var statements = TypeScript.Syntax.emptyList; + + if (colonToken.fullWidth() > 0) { + var result = this.parseSyntaxList(16 /* SwitchClause_Statements */); + statements = result.list; + colonToken = this.addSkippedTokensAfterToken(colonToken, result.skippedTokens); + } + + return this.factory.caseSwitchClause(caseKeyword, expression, colonToken, statements); + }; + + ParserImpl.prototype.parseDefaultSwitchClause = function () { + var defaultKeyword = this.eatKeyword(20 /* DefaultKeyword */); + var colonToken = this.eatToken(106 /* ColonToken */); + var statements = TypeScript.Syntax.emptyList; + + if (colonToken.fullWidth() > 0) { + var result = this.parseSyntaxList(16 /* SwitchClause_Statements */); + statements = result.list; + colonToken = this.addSkippedTokensAfterToken(colonToken, result.skippedTokens); + } + + return this.factory.defaultSwitchClause(defaultKeyword, colonToken, statements); + }; + + ParserImpl.prototype.isThrowStatement = function () { + return this.currentToken().tokenKind === 36 /* ThrowKeyword */; + }; + + ParserImpl.prototype.parseThrowStatement = function () { + var throwKeyword = this.eatKeyword(36 /* ThrowKeyword */); + + var expression = null; + if (this.canEatExplicitOrAutomaticSemicolon(false)) { + var token = this.createMissingToken(11 /* IdentifierName */, null); + expression = token; + } else { + expression = this.parseExpression(true); + } + + var semicolonToken = this.eatExplicitOrAutomaticSemicolon(false); + + return this.factory.throwStatement(throwKeyword, expression, semicolonToken); + }; + + ParserImpl.prototype.isReturnStatement = function () { + return this.currentToken().tokenKind === 33 /* ReturnKeyword */; + }; + + ParserImpl.prototype.parseReturnStatement = function () { + var returnKeyword = this.eatKeyword(33 /* ReturnKeyword */); + + var expression = null; + if (!this.canEatExplicitOrAutomaticSemicolon(false)) { + expression = this.parseExpression(true); + } + + var semicolonToken = this.eatExplicitOrAutomaticSemicolon(false); + + return this.factory.returnStatement(returnKeyword, expression, semicolonToken); + }; + + ParserImpl.prototype.isExpressionStatement = function () { + var currentToken = this.currentToken(); + + var kind = currentToken.tokenKind; + if (kind === 70 /* OpenBraceToken */ || kind === 27 /* FunctionKeyword */) { + return false; + } + + return this.isExpression(); + }; + + ParserImpl.prototype.isAssignmentOrOmittedExpression = function () { + if (this.currentToken().tokenKind === 79 /* CommaToken */) { + return true; + } + + return this.isExpression(); + }; + + ParserImpl.prototype.parseAssignmentOrOmittedExpression = function () { + if (this.currentToken().tokenKind === 79 /* CommaToken */) { + return this.factory.omittedExpression(); + } + + return this.parseAssignmentExpression(true); + }; + + ParserImpl.prototype.isExpression = function () { + var currentToken = this.currentToken(); + var kind = currentToken.tokenKind; + + switch (kind) { + case 13 /* NumericLiteral */: + case 14 /* StringLiteral */: + case 12 /* RegularExpressionLiteral */: + return true; + + case 74 /* OpenBracketToken */: + case 72 /* OpenParenToken */: + return true; + + case 80 /* LessThanToken */: + return true; + + case 93 /* PlusPlusToken */: + case 94 /* MinusMinusToken */: + case 89 /* PlusToken */: + case 90 /* MinusToken */: + case 102 /* TildeToken */: + case 101 /* ExclamationToken */: + return true; + + case 70 /* OpenBraceToken */: + return true; + + case 85 /* EqualsGreaterThanToken */: + return true; + + case 118 /* SlashToken */: + case 119 /* SlashEqualsToken */: + return true; + + case 50 /* SuperKeyword */: + case 35 /* ThisKeyword */: + case 37 /* TrueKeyword */: + case 24 /* FalseKeyword */: + case 32 /* NullKeyword */: + return true; + + case 31 /* NewKeyword */: + return true; + + case 21 /* DeleteKeyword */: + case 41 /* VoidKeyword */: + case 39 /* TypeOfKeyword */: + return true; + + case 27 /* FunctionKeyword */: + return true; + } + + if (this.isIdentifier(this.currentToken())) { + return true; + } + + return false; + }; + + ParserImpl.prototype.parseExpressionStatement = function () { + var expression = this.parseExpression(true); + + var semicolon = this.eatExplicitOrAutomaticSemicolon(false); + + return this.factory.expressionStatement(expression, semicolon); + }; + + ParserImpl.prototype.isIfStatement = function () { + return this.currentToken().tokenKind === 28 /* IfKeyword */; + }; + + ParserImpl.prototype.parseIfStatement = function () { + var ifKeyword = this.eatKeyword(28 /* IfKeyword */); + var openParenToken = this.eatToken(72 /* OpenParenToken */); + var condition = this.parseExpression(true); + var closeParenToken = this.eatToken(73 /* CloseParenToken */); + var statement = this.parseStatement(); + + var elseClause = null; + if (this.isElseClause()) { + elseClause = this.parseElseClause(); + } + + return this.factory.ifStatement(ifKeyword, openParenToken, condition, closeParenToken, statement, elseClause); + }; + + ParserImpl.prototype.isElseClause = function () { + return this.currentToken().tokenKind === 23 /* ElseKeyword */; + }; + + ParserImpl.prototype.parseElseClause = function () { + var elseKeyword = this.eatKeyword(23 /* ElseKeyword */); + var statement = this.parseStatement(); + + return this.factory.elseClause(elseKeyword, statement); + }; + + ParserImpl.prototype.isVariableStatement = function () { + var index = this.modifierCount(); + return this.peekToken(index).tokenKind === 40 /* VarKeyword */; + }; + + ParserImpl.prototype.parseVariableStatement = function () { + var modifiers = this.parseModifiers(); + var variableDeclaration = this.parseVariableDeclaration(true); + var semicolonToken = this.eatExplicitOrAutomaticSemicolon(false); + + return this.factory.variableStatement(modifiers, variableDeclaration, semicolonToken); + }; + + ParserImpl.prototype.parseVariableDeclaration = function (allowIn) { + var varKeyword = this.eatKeyword(40 /* VarKeyword */); + + var listParsingState = allowIn ? 4096 /* VariableDeclaration_VariableDeclarators_AllowIn */ : 8192 /* VariableDeclaration_VariableDeclarators_DisallowIn */; + + var result = this.parseSeparatedSyntaxList(listParsingState); + var variableDeclarators = result.list; + varKeyword = this.addSkippedTokensAfterToken(varKeyword, result.skippedTokens); + + return this.factory.variableDeclaration(varKeyword, variableDeclarators); + }; + + ParserImpl.prototype.isVariableDeclarator = function () { + if (this.currentNode() !== null && this.currentNode().kind() === 224 /* VariableDeclarator */) { + return true; + } + + return this.isIdentifier(this.currentToken()); + }; + + ParserImpl.prototype.canReuseVariableDeclaratorNode = function (node) { + if (node === null || node.kind() !== 224 /* VariableDeclarator */) { + return false; + } + + var variableDeclarator = node; + return variableDeclarator.equalsValueClause === null; + }; + + ParserImpl.prototype.parseVariableDeclarator = function (allowIn, allowPropertyName) { + if (this.canReuseVariableDeclaratorNode(this.currentNode())) { + return this.eatNode(); + } + + var propertyName = allowPropertyName ? this.eatPropertyName() : this.eatIdentifierToken(); + var equalsValueClause = null; + var typeAnnotation = null; + + if (propertyName.width() > 0) { + typeAnnotation = this.parseOptionalTypeAnnotation(false); + + if (this.isEqualsValueClause(false)) { + equalsValueClause = this.parseEqualsValueClause(allowIn); + } + } + + return this.factory.variableDeclarator(propertyName, typeAnnotation, equalsValueClause); + }; + + ParserImpl.prototype.isColonValueClause = function () { + return this.currentToken().tokenKind === 106 /* ColonToken */; + }; + + ParserImpl.prototype.isEqualsValueClause = function (inParameter) { + var token0 = this.currentToken(); + if (token0.tokenKind === 107 /* EqualsToken */) { + return true; + } + + if (!this.previousToken().hasTrailingNewLine()) { + if (token0.tokenKind === 85 /* EqualsGreaterThanToken */) { + return false; + } + + if (token0.tokenKind === 70 /* OpenBraceToken */ && inParameter) { + return false; + } + + return this.isExpression(); + } + + return false; + }; + + ParserImpl.prototype.parseEqualsValueClause = function (allowIn) { + var equalsToken = this.eatToken(107 /* EqualsToken */); + var value = this.parseAssignmentExpression(allowIn); + + return this.factory.equalsValueClause(equalsToken, value); + }; + + ParserImpl.prototype.parseExpression = function (allowIn) { + return this.parseSubExpression(0, allowIn); + }; + + ParserImpl.prototype.parseAssignmentExpression = function (allowIn) { + return this.parseSubExpression(2 /* AssignmentExpressionPrecedence */, allowIn); + }; + + ParserImpl.prototype.parseUnaryExpression = function () { + var currentTokenKind = this.currentToken().tokenKind; + if (TypeScript.SyntaxFacts.isPrefixUnaryExpressionOperatorToken(currentTokenKind)) { + var operatorKind = TypeScript.SyntaxFacts.getPrefixUnaryExpressionFromOperatorToken(currentTokenKind); + + var operatorToken = this.eatAnyToken(); + + var operand = this.parseUnaryExpression(); + return this.factory.prefixUnaryExpression(operatorKind, operatorToken, operand); + } else { + return this.parseTerm(false); + } + }; + + ParserImpl.prototype.parseSubExpression = function (precedence, allowIn) { + var leftOperand = this.parseUnaryExpression(); + leftOperand = this.parseBinaryOrConditionalExpressions(precedence, allowIn, leftOperand); + + return leftOperand; + }; + + ParserImpl.prototype.parseBinaryOrConditionalExpressions = function (precedence, allowIn, leftOperand) { + while (true) { + var token0 = this.currentToken(); + var token0Kind = token0.tokenKind; + + if (TypeScript.SyntaxFacts.isBinaryExpressionOperatorToken(token0Kind)) { + if (token0Kind === 29 /* InKeyword */ && !allowIn) { + break; + } + + var mergedToken = this.tryMergeBinaryExpressionTokens(); + var tokenKind = mergedToken === null ? token0Kind : mergedToken.syntaxKind; + + var binaryExpressionKind = TypeScript.SyntaxFacts.getBinaryExpressionFromOperatorToken(tokenKind); + var newPrecedence = ParserImpl.getPrecedence(binaryExpressionKind); + + if (newPrecedence < precedence) { + break; + } + + if (newPrecedence === precedence && !this.isRightAssociative(binaryExpressionKind)) { + break; + } + + var operatorToken = mergedToken === null ? token0 : TypeScript.Syntax.token(mergedToken.syntaxKind).withLeadingTrivia(token0.leadingTrivia()).withTrailingTrivia(this.peekToken(mergedToken.tokenCount - 1).trailingTrivia()); + + var skipCount = mergedToken === null ? 1 : mergedToken.tokenCount; + for (var i = 0; i < skipCount; i++) { + this.eatAnyToken(); + } + + leftOperand = this.factory.binaryExpression(binaryExpressionKind, leftOperand, operatorToken, this.parseSubExpression(newPrecedence, allowIn)); + continue; + } + + if (token0Kind === 105 /* QuestionToken */ && precedence <= 3 /* ConditionalExpressionPrecedence */) { + var questionToken = this.eatToken(105 /* QuestionToken */); + + var whenTrueExpression = this.parseAssignmentExpression(allowIn); + var colon = this.eatToken(106 /* ColonToken */); + + var whenFalseExpression = this.parseAssignmentExpression(allowIn); + leftOperand = this.factory.conditionalExpression(leftOperand, questionToken, whenTrueExpression, colon, whenFalseExpression); + continue; + } + + break; + } + + return leftOperand; + }; + + ParserImpl.prototype.tryMergeBinaryExpressionTokens = function () { + var token0 = this.currentToken(); + + if (token0.tokenKind === 81 /* GreaterThanToken */ && !token0.hasTrailingTrivia()) { + var storage = this.mergeTokensStorage; + storage[0] = 0 /* None */; + storage[1] = 0 /* None */; + storage[2] = 0 /* None */; + + for (var i = 0; i < storage.length; i++) { + var nextToken = this.peekToken(i + 1); + + if (!nextToken.hasLeadingTrivia()) { + storage[i] = nextToken.tokenKind; + } + + if (nextToken.hasTrailingTrivia()) { + break; + } + } + + if (storage[0] === 81 /* GreaterThanToken */) { + if (storage[1] === 81 /* GreaterThanToken */) { + if (storage[2] === 107 /* EqualsToken */) { + return { tokenCount: 4, syntaxKind: 114 /* GreaterThanGreaterThanGreaterThanEqualsToken */ }; + } else { + return { tokenCount: 3, syntaxKind: 97 /* GreaterThanGreaterThanGreaterThanToken */ }; + } + } else if (storage[1] === 107 /* EqualsToken */) { + return { tokenCount: 3, syntaxKind: 113 /* GreaterThanGreaterThanEqualsToken */ }; + } else { + return { tokenCount: 2, syntaxKind: 96 /* GreaterThanGreaterThanToken */ }; + } + } else if (storage[0] === 107 /* EqualsToken */) { + return { tokenCount: 2, syntaxKind: 83 /* GreaterThanEqualsToken */ }; + } + } + + return null; + }; + + ParserImpl.prototype.isRightAssociative = function (expressionKind) { + switch (expressionKind) { + case 173 /* AssignmentExpression */: + case 174 /* AddAssignmentExpression */: + case 175 /* SubtractAssignmentExpression */: + case 176 /* MultiplyAssignmentExpression */: + case 177 /* DivideAssignmentExpression */: + case 178 /* ModuloAssignmentExpression */: + case 179 /* AndAssignmentExpression */: + case 180 /* ExclusiveOrAssignmentExpression */: + case 181 /* OrAssignmentExpression */: + case 182 /* LeftShiftAssignmentExpression */: + case 183 /* SignedRightShiftAssignmentExpression */: + case 184 /* UnsignedRightShiftAssignmentExpression */: + return true; + default: + return false; + } + }; + + ParserImpl.prototype.parseTerm = function (inObjectCreation) { + var term = this.parseTermWorker(); + if (term === null) { + return this.eatIdentifierToken(); + } + + return this.parsePostFixExpression(term, inObjectCreation); + }; + + ParserImpl.prototype.parsePostFixExpression = function (expression, inObjectCreation) { + while (true) { + var currentTokenKind = this.currentToken().tokenKind; + switch (currentTokenKind) { + case 72 /* OpenParenToken */: + if (inObjectCreation) { + return expression; + } + + expression = this.factory.invocationExpression(expression, this.parseArgumentList(null)); + continue; + + case 80 /* LessThanToken */: + if (inObjectCreation) { + return expression; + } + + var argumentList = this.tryParseArgumentList(); + if (argumentList !== null) { + expression = this.factory.invocationExpression(expression, argumentList); + continue; + } + + break; + + case 74 /* OpenBracketToken */: + expression = this.parseElementAccessExpression(expression, inObjectCreation); + continue; + + case 93 /* PlusPlusToken */: + case 94 /* MinusMinusToken */: + if (this.previousToken() !== null && this.previousToken().hasTrailingNewLine()) { + break; + } + + expression = this.factory.postfixUnaryExpression(TypeScript.SyntaxFacts.getPostfixUnaryExpressionFromOperatorToken(currentTokenKind), expression, this.eatAnyToken()); + continue; + + case 76 /* DotToken */: + expression = this.factory.memberAccessExpression(expression, this.eatToken(76 /* DotToken */), this.eatIdentifierNameToken()); + continue; + } + + return expression; + } + }; + + ParserImpl.prototype.tryParseArgumentList = function () { + var typeArgumentList = null; + + if (this.currentToken().tokenKind === 80 /* LessThanToken */) { + var rewindPoint = this.getRewindPoint(); + try { + typeArgumentList = this.tryParseTypeArgumentList(true); + var token0 = this.currentToken(); + + var isOpenParen = token0.tokenKind === 72 /* OpenParenToken */; + var isDot = token0.tokenKind === 76 /* DotToken */; + var isOpenParenOrDot = isOpenParen || isDot; + if (typeArgumentList === null || !isOpenParenOrDot) { + this.rewind(rewindPoint); + return null; + } + + if (isDot) { + var diagnostic = new TypeScript.Diagnostic(this.fileName, this.currentTokenStart(), token0.width(), TypeScript.DiagnosticCode.A_parameter_list_must_follow_a_generic_type_argument_list_expected, null); + this.addDiagnostic(diagnostic); + + return this.factory.argumentList(typeArgumentList, TypeScript.Syntax.emptyToken(72 /* OpenParenToken */), TypeScript.Syntax.emptySeparatedList, TypeScript.Syntax.emptyToken(73 /* CloseParenToken */)); + } + } finally { + this.releaseRewindPoint(rewindPoint); + } + } + + if (this.currentToken().tokenKind === 72 /* OpenParenToken */) { + return this.parseArgumentList(typeArgumentList); + } + + return null; + }; + + ParserImpl.prototype.parseArgumentList = function (typeArgumentList) { + var openParenToken = this.eatToken(72 /* OpenParenToken */); + var arguments = TypeScript.Syntax.emptySeparatedList; + + if (openParenToken.fullWidth() > 0) { + var result = this.parseSeparatedSyntaxList(16384 /* ArgumentList_AssignmentExpressions */); + arguments = result.list; + openParenToken = this.addSkippedTokensAfterToken(openParenToken, result.skippedTokens); + } + + var closeParenToken = this.eatToken(73 /* CloseParenToken */); + + return this.factory.argumentList(typeArgumentList, openParenToken, arguments, closeParenToken); + }; + + ParserImpl.prototype.parseElementAccessExpression = function (expression, inObjectCreation) { + var start = this.currentTokenStart(); + var openBracketToken = this.eatToken(74 /* OpenBracketToken */); + var argumentExpression; + + if (this.currentToken().tokenKind === 75 /* CloseBracketToken */ && inObjectCreation) { + var end = this.currentTokenStart() + this.currentToken().width(); + var diagnostic = new TypeScript.Diagnostic(this.fileName, start, end - start, TypeScript.DiagnosticCode.new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead, null); + this.addDiagnostic(diagnostic); + + argumentExpression = TypeScript.Syntax.emptyToken(11 /* IdentifierName */); + } else { + argumentExpression = this.parseExpression(true); + } + + var closeBracketToken = this.eatToken(75 /* CloseBracketToken */); + + return this.factory.elementAccessExpression(expression, openBracketToken, argumentExpression, closeBracketToken); + }; + + ParserImpl.prototype.parseTermWorker = function () { + var currentToken = this.currentToken(); + + if (currentToken.tokenKind === 85 /* EqualsGreaterThanToken */) { + return this.parseSimpleArrowFunctionExpression(); + } + + if (this.isIdentifier(currentToken)) { + if (this.isSimpleArrowFunctionExpression()) { + return this.parseSimpleArrowFunctionExpression(); + } else { + var identifier = this.eatIdentifierToken(); + return identifier; + } + } + + var currentTokenKind = currentToken.tokenKind; + switch (currentTokenKind) { + case 35 /* ThisKeyword */: + return this.parseThisExpression(); + + case 37 /* TrueKeyword */: + case 24 /* FalseKeyword */: + return this.parseLiteralExpression(); + + case 32 /* NullKeyword */: + return this.parseLiteralExpression(); + + case 31 /* NewKeyword */: + return this.parseObjectCreationExpression(); + + case 27 /* FunctionKeyword */: + return this.parseFunctionExpression(); + + case 50 /* SuperKeyword */: + return this.parseSuperExpression(); + + case 39 /* TypeOfKeyword */: + return this.parseTypeOfExpression(); + + case 21 /* DeleteKeyword */: + return this.parseDeleteExpression(); + + case 41 /* VoidKeyword */: + return this.parseVoidExpression(); + + case 13 /* NumericLiteral */: + return this.parseLiteralExpression(); + + case 12 /* RegularExpressionLiteral */: + return this.parseLiteralExpression(); + + case 14 /* StringLiteral */: + return this.parseLiteralExpression(); + + case 74 /* OpenBracketToken */: + return this.parseArrayLiteralExpression(); + + case 70 /* OpenBraceToken */: + return this.parseObjectLiteralExpression(); + + case 72 /* OpenParenToken */: + return this.parseParenthesizedOrArrowFunctionExpression(); + + case 80 /* LessThanToken */: + return this.parseCastOrArrowFunctionExpression(); + + case 118 /* SlashToken */: + case 119 /* SlashEqualsToken */: + var result = this.tryReparseDivideAsRegularExpression(); + if (result !== null) { + return result; + } + break; + } + + return null; + }; + + ParserImpl.prototype.tryReparseDivideAsRegularExpression = function () { + var currentToken = this.currentToken(); + + if (this.previousToken() !== null) { + var previousTokenKind = this.previousToken().tokenKind; + switch (previousTokenKind) { + case 11 /* IdentifierName */: + return null; + + case 35 /* ThisKeyword */: + case 37 /* TrueKeyword */: + case 24 /* FalseKeyword */: + return null; + + case 14 /* StringLiteral */: + case 13 /* NumericLiteral */: + case 12 /* RegularExpressionLiteral */: + case 93 /* PlusPlusToken */: + case 94 /* MinusMinusToken */: + case 75 /* CloseBracketToken */: + case 71 /* CloseBraceToken */: + return null; + } + } + + currentToken = this.currentTokenAllowingRegularExpression(); + + if (currentToken.tokenKind === 118 /* SlashToken */ || currentToken.tokenKind === 119 /* SlashEqualsToken */) { + return null; + } else if (currentToken.tokenKind === 12 /* RegularExpressionLiteral */) { + return this.parseLiteralExpression(); + } else { + throw TypeScript.Errors.invalidOperation(); + } + }; + + ParserImpl.prototype.parseTypeOfExpression = function () { + var typeOfKeyword = this.eatKeyword(39 /* TypeOfKeyword */); + var expression = this.parseUnaryExpression(); + + return this.factory.typeOfExpression(typeOfKeyword, expression); + }; + + ParserImpl.prototype.parseDeleteExpression = function () { + var deleteKeyword = this.eatKeyword(21 /* DeleteKeyword */); + var expression = this.parseUnaryExpression(); + + return this.factory.deleteExpression(deleteKeyword, expression); + }; + + ParserImpl.prototype.parseVoidExpression = function () { + var voidKeyword = this.eatKeyword(41 /* VoidKeyword */); + var expression = this.parseUnaryExpression(); + + return this.factory.voidExpression(voidKeyword, expression); + }; + + ParserImpl.prototype.parseSuperExpression = function () { + var superKeyword = this.eatKeyword(50 /* SuperKeyword */); + return superKeyword; + }; + + ParserImpl.prototype.parseFunctionExpression = function () { + var functionKeyword = this.eatKeyword(27 /* FunctionKeyword */); + var identifier = null; + + if (this.isIdentifier(this.currentToken())) { + identifier = this.eatIdentifierToken(); + } + + var callSignature = this.parseCallSignature(false); + var block = this.parseBlock(false, true); + + return this.factory.functionExpression(functionKeyword, identifier, callSignature, block); + }; + + ParserImpl.prototype.parseObjectCreationExpression = function () { + var newKeyword = this.eatKeyword(31 /* NewKeyword */); + + var expression = this.parseTerm(true); + var argumentList = this.tryParseArgumentList(); + + return this.factory.objectCreationExpression(newKeyword, expression, argumentList); + }; + + ParserImpl.prototype.parseCastOrArrowFunctionExpression = function () { + var rewindPoint = this.getRewindPoint(); + try { + var arrowFunction = this.tryParseArrowFunctionExpression(); + if (arrowFunction !== null) { + return arrowFunction; + } + + this.rewind(rewindPoint); + return this.parseCastExpression(); + } finally { + this.releaseRewindPoint(rewindPoint); + } + }; + + ParserImpl.prototype.parseCastExpression = function () { + var lessThanToken = this.eatToken(80 /* LessThanToken */); + var type = this.parseType(); + var greaterThanToken = this.eatToken(81 /* GreaterThanToken */); + var expression = this.parseUnaryExpression(); + + return this.factory.castExpression(lessThanToken, type, greaterThanToken, expression); + }; + + ParserImpl.prototype.parseParenthesizedOrArrowFunctionExpression = function () { + var result = this.tryParseArrowFunctionExpression(); + if (result !== null) { + return result; + } + + var openParenToken = this.eatToken(72 /* OpenParenToken */); + var expression = this.parseExpression(true); + var closeParenToken = this.eatToken(73 /* CloseParenToken */); + + return this.factory.parenthesizedExpression(openParenToken, expression, closeParenToken); + }; + + ParserImpl.prototype.tryParseArrowFunctionExpression = function () { + var tokenKind = this.currentToken().tokenKind; + + if (this.isDefinitelyArrowFunctionExpression()) { + return this.parseParenthesizedArrowFunctionExpression(false); + } + + if (!this.isPossiblyArrowFunctionExpression()) { + return null; + } + + var rewindPoint = this.getRewindPoint(); + try { + var arrowFunction = this.parseParenthesizedArrowFunctionExpression(true); + if (arrowFunction === null) { + this.rewind(rewindPoint); + } + return arrowFunction; + } finally { + this.releaseRewindPoint(rewindPoint); + } + }; + + ParserImpl.prototype.parseParenthesizedArrowFunctionExpression = function (requireArrow) { + var currentToken = this.currentToken(); + + var callSignature = this.parseCallSignature(true); + + if (requireArrow && this.currentToken().tokenKind !== 85 /* EqualsGreaterThanToken */) { + return null; + } + + var equalsGreaterThanToken = this.eatToken(85 /* EqualsGreaterThanToken */); + var body = this.parseArrowFunctionBody(); + + return this.factory.parenthesizedArrowFunctionExpression(callSignature, equalsGreaterThanToken, body); + }; + + ParserImpl.prototype.parseArrowFunctionBody = function () { + if (this.isBlock()) { + return this.parseBlock(false, false); + } else { + return this.parseAssignmentExpression(true); + } + }; + + ParserImpl.prototype.isSimpleArrowFunctionExpression = function () { + if (this.currentToken().tokenKind === 85 /* EqualsGreaterThanToken */) { + return true; + } + + return this.isIdentifier(this.currentToken()) && this.peekToken(1).tokenKind === 85 /* EqualsGreaterThanToken */; + }; + + ParserImpl.prototype.parseSimpleArrowFunctionExpression = function () { + var identifier = this.eatIdentifierToken(); + var equalsGreaterThanToken = this.eatToken(85 /* EqualsGreaterThanToken */); + var body = this.parseArrowFunctionBody(); + + return this.factory.simpleArrowFunctionExpression(identifier, equalsGreaterThanToken, body); + }; + + ParserImpl.prototype.isBlock = function () { + return this.currentToken().tokenKind === 70 /* OpenBraceToken */; + }; + + ParserImpl.prototype.isDefinitelyArrowFunctionExpression = function () { + var token0 = this.currentToken(); + if (token0.tokenKind !== 72 /* OpenParenToken */) { + return false; + } + + var token1 = this.peekToken(1); + var token2; + + if (token1.tokenKind === 73 /* CloseParenToken */) { + token2 = this.peekToken(2); + return token2.tokenKind === 106 /* ColonToken */ || token2.tokenKind === 85 /* EqualsGreaterThanToken */ || token2.tokenKind === 70 /* OpenBraceToken */; + } + + if (token1.tokenKind === 77 /* DotDotDotToken */) { + return true; + } + + if (!this.isIdentifier(token1)) { + return false; + } + + token2 = this.peekToken(2); + if (token2.tokenKind === 106 /* ColonToken */) { + return true; + } + + var token3 = this.peekToken(3); + if (token2.tokenKind === 105 /* QuestionToken */) { + if (token3.tokenKind === 106 /* ColonToken */ || token3.tokenKind === 73 /* CloseParenToken */ || token3.tokenKind === 79 /* CommaToken */) { + return true; + } + } + + if (token2.tokenKind === 73 /* CloseParenToken */) { + if (token3.tokenKind === 85 /* EqualsGreaterThanToken */) { + return true; + } + } + + return false; + }; + + ParserImpl.prototype.isPossiblyArrowFunctionExpression = function () { + var token0 = this.currentToken(); + if (token0.tokenKind !== 72 /* OpenParenToken */) { + return true; + } + + var token1 = this.peekToken(1); + + if (!this.isIdentifier(token1)) { + return false; + } + + var token2 = this.peekToken(2); + if (token2.tokenKind === 107 /* EqualsToken */) { + return true; + } + + if (token2.tokenKind === 79 /* CommaToken */) { + return true; + } + + if (token2.tokenKind === 73 /* CloseParenToken */) { + var token3 = this.peekToken(3); + if (token3.tokenKind === 106 /* ColonToken */) { + return true; + } + } + + return false; + }; + + ParserImpl.prototype.parseObjectLiteralExpression = function () { + var openBraceToken = this.eatToken(70 /* OpenBraceToken */); + + var result = this.parseSeparatedSyntaxList(32768 /* ObjectLiteralExpression_PropertyAssignments */); + var propertyAssignments = result.list; + openBraceToken = this.addSkippedTokensAfterToken(openBraceToken, result.skippedTokens); + + var closeBraceToken = this.eatToken(71 /* CloseBraceToken */); + + return this.factory.objectLiteralExpression(openBraceToken, propertyAssignments, closeBraceToken); + }; + + ParserImpl.prototype.parsePropertyAssignment = function () { + if (this.isGetAccessorPropertyAssignment(false)) { + return this.parseGetAccessorPropertyAssignment(); + } else if (this.isSetAccessorPropertyAssignment(false)) { + return this.parseSetAccessorPropertyAssignment(); + } else if (this.isFunctionPropertyAssignment(false)) { + return this.parseFunctionPropertyAssignment(); + } else if (this.isSimplePropertyAssignment(false)) { + return this.parseSimplePropertyAssignment(); + } else { + throw TypeScript.Errors.invalidOperation(); + } + }; + + ParserImpl.prototype.isPropertyAssignment = function (inErrorRecovery) { + return this.isGetAccessorPropertyAssignment(inErrorRecovery) || this.isSetAccessorPropertyAssignment(inErrorRecovery) || this.isFunctionPropertyAssignment(inErrorRecovery) || this.isSimplePropertyAssignment(inErrorRecovery); + }; + + ParserImpl.prototype.isGetAccessorPropertyAssignment = function (inErrorRecovery) { + return this.currentToken().tokenKind === 64 /* GetKeyword */ && this.isPropertyName(this.peekToken(1), inErrorRecovery); + }; + + ParserImpl.prototype.parseGetAccessorPropertyAssignment = function () { + var getKeyword = this.eatKeyword(64 /* GetKeyword */); + var propertyName = this.eatPropertyName(); + var openParenToken = this.eatToken(72 /* OpenParenToken */); + var closeParenToken = this.eatToken(73 /* CloseParenToken */); + var typeAnnotation = this.parseOptionalTypeAnnotation(false); + var block = this.parseBlock(false, true); + + return this.factory.getAccessorPropertyAssignment(getKeyword, propertyName, openParenToken, closeParenToken, typeAnnotation, block); + }; + + ParserImpl.prototype.isSetAccessorPropertyAssignment = function (inErrorRecovery) { + return this.currentToken().tokenKind === 68 /* SetKeyword */ && this.isPropertyName(this.peekToken(1), inErrorRecovery); + }; + + ParserImpl.prototype.parseSetAccessorPropertyAssignment = function () { + var setKeyword = this.eatKeyword(68 /* SetKeyword */); + var propertyName = this.eatPropertyName(); + var openParenToken = this.eatToken(72 /* OpenParenToken */); + var parameter = this.parseParameter(); + var closeParenToken = this.eatToken(73 /* CloseParenToken */); + var block = this.parseBlock(false, true); + + return this.factory.setAccessorPropertyAssignment(setKeyword, propertyName, openParenToken, parameter, closeParenToken, block); + }; + + ParserImpl.prototype.eatPropertyName = function () { + return TypeScript.SyntaxFacts.isIdentifierNameOrAnyKeyword(this.currentToken()) ? this.eatIdentifierNameToken() : this.eatAnyToken(); + }; + + ParserImpl.prototype.isFunctionPropertyAssignment = function (inErrorRecovery) { + return this.isPropertyName(this.currentToken(), inErrorRecovery) && this.isCallSignature(1); + }; + + ParserImpl.prototype.parseFunctionPropertyAssignment = function () { + var propertyName = this.eatPropertyName(); + var callSignature = this.parseCallSignature(false); + var block = this.parseBlock(false, true); + + return this.factory.functionPropertyAssignment(propertyName, callSignature, block); + }; + + ParserImpl.prototype.isSimplePropertyAssignment = function (inErrorRecovery) { + return this.isPropertyName(this.currentToken(), inErrorRecovery); + }; + + ParserImpl.prototype.parseSimplePropertyAssignment = function () { + var propertyName = this.eatPropertyName(); + var colonToken = this.eatToken(106 /* ColonToken */); + var expression = this.parseAssignmentExpression(true); + + return this.factory.simplePropertyAssignment(propertyName, colonToken, expression); + }; + + ParserImpl.prototype.isPropertyName = function (token, inErrorRecovery) { + if (TypeScript.SyntaxFacts.isIdentifierNameOrAnyKeyword(token)) { + if (inErrorRecovery) { + return this.isIdentifier(token); + } else { + return true; + } + } + + switch (token.tokenKind) { + case 14 /* StringLiteral */: + case 13 /* NumericLiteral */: + return true; + + default: + return false; + } + }; + + ParserImpl.prototype.parseArrayLiteralExpression = function () { + var openBracketToken = this.eatToken(74 /* OpenBracketToken */); + + var result = this.parseSeparatedSyntaxList(65536 /* ArrayLiteralExpression_AssignmentExpressions */); + var expressions = result.list; + openBracketToken = this.addSkippedTokensAfterToken(openBracketToken, result.skippedTokens); + + var closeBracketToken = this.eatToken(75 /* CloseBracketToken */); + + return this.factory.arrayLiteralExpression(openBracketToken, expressions, closeBracketToken); + }; + + ParserImpl.prototype.parseLiteralExpression = function () { + return this.eatAnyToken(); + }; + + ParserImpl.prototype.parseThisExpression = function () { + var thisKeyword = this.eatKeyword(35 /* ThisKeyword */); + return thisKeyword; + }; + + ParserImpl.prototype.parseBlock = function (parseBlockEvenWithNoOpenBrace, checkForStrictMode) { + var openBraceToken = this.eatToken(70 /* OpenBraceToken */); + + var statements = TypeScript.Syntax.emptyList; + + if (parseBlockEvenWithNoOpenBrace || openBraceToken.width() > 0) { + var savedIsInStrictMode = this.isInStrictMode; + + var processItems = checkForStrictMode ? ParserImpl.updateStrictModeState : null; + var result = this.parseSyntaxList(32 /* Block_Statements */, processItems); + statements = result.list; + openBraceToken = this.addSkippedTokensAfterToken(openBraceToken, result.skippedTokens); + + this.setStrictMode(savedIsInStrictMode); + } + + var closeBraceToken = this.eatToken(71 /* CloseBraceToken */); + + return this.factory.block(openBraceToken, statements, closeBraceToken); + }; + + ParserImpl.prototype.parseCallSignature = function (requireCompleteTypeParameterList) { + var typeParameterList = this.parseOptionalTypeParameterList(requireCompleteTypeParameterList); + var parameterList = this.parseParameterList(); + var typeAnnotation = this.parseOptionalTypeAnnotation(false); + + return this.factory.callSignature(typeParameterList, parameterList, typeAnnotation); + }; + + ParserImpl.prototype.parseOptionalTypeParameterList = function (requireCompleteTypeParameterList) { + if (this.currentToken().tokenKind !== 80 /* LessThanToken */) { + return null; + } + + var rewindPoint = this.getRewindPoint(); + try { + var lessThanToken = this.eatToken(80 /* LessThanToken */); + + var result = this.parseSeparatedSyntaxList(524288 /* TypeParameterList_TypeParameters */); + var typeParameterList = result.list; + lessThanToken = this.addSkippedTokensAfterToken(lessThanToken, result.skippedTokens); + + var greaterThanToken = this.eatToken(81 /* GreaterThanToken */); + + if (requireCompleteTypeParameterList && greaterThanToken.fullWidth() === 0) { + this.rewind(rewindPoint); + return null; + } + + return this.factory.typeParameterList(lessThanToken, typeParameterList, greaterThanToken); + } finally { + this.releaseRewindPoint(rewindPoint); + } + }; + + ParserImpl.prototype.isTypeParameter = function () { + return this.isIdentifier(this.currentToken()); + }; + + ParserImpl.prototype.parseTypeParameter = function () { + var identifier = this.eatIdentifierToken(); + var constraint = this.parseOptionalConstraint(); + + return this.factory.typeParameter(identifier, constraint); + }; + + ParserImpl.prototype.parseOptionalConstraint = function () { + if (this.currentToken().kind() !== 48 /* ExtendsKeyword */) { + return null; + } + + var extendsKeyword = this.eatKeyword(48 /* ExtendsKeyword */); + var type = this.parseType(); + + return this.factory.constraint(extendsKeyword, type); + }; + + ParserImpl.prototype.parseParameterList = function () { + var openParenToken = this.eatToken(72 /* OpenParenToken */); + var parameters = TypeScript.Syntax.emptySeparatedList; + + if (openParenToken.width() > 0) { + var result = this.parseSeparatedSyntaxList(131072 /* ParameterList_Parameters */); + parameters = result.list; + openParenToken = this.addSkippedTokensAfterToken(openParenToken, result.skippedTokens); + } + + var closeParenToken = this.eatToken(73 /* CloseParenToken */); + return this.factory.parameterList(openParenToken, parameters, closeParenToken); + }; + + ParserImpl.prototype.isTypeAnnotation = function () { + return this.currentToken().tokenKind === 106 /* ColonToken */; + }; + + ParserImpl.prototype.parseOptionalTypeAnnotation = function (allowStringLiteral) { + return this.isTypeAnnotation() ? this.parseTypeAnnotation(allowStringLiteral) : null; + }; + + ParserImpl.prototype.parseTypeAnnotation = function (allowStringLiteral) { + var colonToken = this.eatToken(106 /* ColonToken */); + var type = allowStringLiteral && this.currentToken().tokenKind === 14 /* StringLiteral */ ? this.eatToken(14 /* StringLiteral */) : this.parseType(); + + return this.factory.typeAnnotation(colonToken, type); + }; + + ParserImpl.prototype.isType = function () { + return this.isPredefinedType() || this.isTypeLiteral() || this.isTypeQuery() || this.isName(); + }; + + ParserImpl.prototype.parseType = function () { + if (this.isTypeQuery()) { + return this.parseTypeQuery(); + } else { + var type = this.parseNonArrayType(); + + while (this.currentToken().tokenKind === 74 /* OpenBracketToken */) { + var openBracketToken = this.eatToken(74 /* OpenBracketToken */); + var closeBracketToken = this.eatToken(75 /* CloseBracketToken */); + + type = this.factory.arrayType(type, openBracketToken, closeBracketToken); + } + + return type; + } + }; + + ParserImpl.prototype.isTypeQuery = function () { + return this.currentToken().tokenKind === 39 /* TypeOfKeyword */; + }; + + ParserImpl.prototype.parseTypeQuery = function () { + var typeOfKeyword = this.eatToken(39 /* TypeOfKeyword */); + var name = this.parseName(); + + return this.factory.typeQuery(typeOfKeyword, name); + }; + + ParserImpl.prototype.parseNonArrayType = function () { + if (this.isPredefinedType()) { + return this.parsePredefinedType(); + } else if (this.isTypeLiteral()) { + return this.parseTypeLiteral(); + } else { + return this.parseNameOrGenericType(); + } + }; + + ParserImpl.prototype.parseNameOrGenericType = function () { + var name = this.parseName(); + var typeArgumentList = this.tryParseTypeArgumentList(false); + + return typeArgumentList === null ? name : this.factory.genericType(name, typeArgumentList); + }; + + ParserImpl.prototype.parseTypeLiteral = function () { + if (this.isObjectType()) { + return this.parseObjectType(); + } else if (this.isFunctionType()) { + return this.parseFunctionType(); + } else if (this.isConstructorType()) { + return this.parseConstructorType(); + } else { + throw TypeScript.Errors.invalidOperation(); + } + }; + + ParserImpl.prototype.parseFunctionType = function () { + var typeParameterList = this.parseOptionalTypeParameterList(false); + var parameterList = this.parseParameterList(); + var equalsGreaterThanToken = this.eatToken(85 /* EqualsGreaterThanToken */); + var returnType = this.parseType(); + + return this.factory.functionType(typeParameterList, parameterList, equalsGreaterThanToken, returnType); + }; + + ParserImpl.prototype.parseConstructorType = function () { + var newKeyword = this.eatKeyword(31 /* NewKeyword */); + var parameterList = this.parseParameterList(); + var equalsGreaterThanToken = this.eatToken(85 /* EqualsGreaterThanToken */); + var type = this.parseType(); + + return this.factory.constructorType(newKeyword, null, parameterList, equalsGreaterThanToken, type); + }; + + ParserImpl.prototype.isTypeLiteral = function () { + return this.isObjectType() || this.isFunctionType() || this.isConstructorType(); + }; + + ParserImpl.prototype.isObjectType = function () { + return this.currentToken().tokenKind === 70 /* OpenBraceToken */; + }; + + ParserImpl.prototype.isFunctionType = function () { + var tokenKind = this.currentToken().tokenKind; + return tokenKind === 72 /* OpenParenToken */ || tokenKind === 80 /* LessThanToken */; + }; + + ParserImpl.prototype.isConstructorType = function () { + return this.currentToken().tokenKind === 31 /* NewKeyword */; + }; + + ParserImpl.prototype.parsePredefinedType = function () { + return this.eatAnyToken(); + }; + + ParserImpl.prototype.isPredefinedType = function () { + switch (this.currentToken().tokenKind) { + case 60 /* AnyKeyword */: + case 67 /* NumberKeyword */: + case 61 /* BooleanKeyword */: + case 69 /* StringKeyword */: + case 41 /* VoidKeyword */: + return true; + } + + return false; + }; + + ParserImpl.prototype.isParameter = function () { + if (this.currentNode() !== null && this.currentNode().kind() === 242 /* Parameter */) { + return true; + } + + var token = this.currentToken(); + if (token.tokenKind === 77 /* DotDotDotToken */) { + return true; + } + + if (ParserImpl.isPublicOrPrivateKeyword(token)) { + return true; + } + + return this.isIdentifier(token); + }; + + ParserImpl.prototype.parseParameter = function () { + if (this.currentNode() !== null && this.currentNode().kind() === 242 /* Parameter */) { + return this.eatNode(); + } + + var dotDotDotToken = this.tryEatToken(77 /* DotDotDotToken */); + + var publicOrPrivateToken = null; + if (ParserImpl.isPublicOrPrivateKeyword(this.currentToken())) { + publicOrPrivateToken = this.eatAnyToken(); + } + + var identifier = this.eatIdentifierToken(); + var questionToken = this.tryEatToken(105 /* QuestionToken */); + var typeAnnotation = this.parseOptionalTypeAnnotation(true); + + var equalsValueClause = null; + if (this.isEqualsValueClause(true)) { + equalsValueClause = this.parseEqualsValueClause(true); + } + + return this.factory.parameter(dotDotDotToken, publicOrPrivateToken, identifier, questionToken, typeAnnotation, equalsValueClause); + }; + + ParserImpl.prototype.parseSyntaxList = function (currentListType, processItems) { + if (typeof processItems === "undefined") { processItems = null; } + var savedListParsingState = this.listParsingState; + this.listParsingState |= currentListType; + + var result = this.parseSyntaxListWorker(currentListType, processItems); + + this.listParsingState = savedListParsingState; + + return result; + }; + + ParserImpl.prototype.parseSeparatedSyntaxList = function (currentListType) { + var savedListParsingState = this.listParsingState; + this.listParsingState |= currentListType; + + var result = this.parseSeparatedSyntaxListWorker(currentListType); + + this.listParsingState = savedListParsingState; + + return result; + }; + + ParserImpl.prototype.abortParsingListOrMoveToNextToken = function (currentListType, items, skippedTokens) { + this.reportUnexpectedTokenDiagnostic(currentListType); + + for (var state = 262144 /* LastListParsingState */; state >= 1 /* FirstListParsingState */; state >>= 1) { + if ((this.listParsingState & state) !== 0) { + if (this.isExpectedListTerminator(state) || this.isExpectedListItem(state, true)) { + return true; + } + } + } + + var skippedToken = this.currentToken(); + + this.moveToNextToken(); + + this.addSkippedTokenToList(items, skippedTokens, skippedToken); + + return false; + }; + + ParserImpl.prototype.addSkippedTokenToList = function (items, skippedTokens, skippedToken) { + for (var i = items.length - 1; i >= 0; i--) { + var item = items[i]; + var lastToken = item.lastToken(); + if (lastToken.fullWidth() > 0) { + items[i] = this.addSkippedTokenAfterNodeOrToken(item, skippedToken); + return; + } + } + + skippedTokens.push(skippedToken); + }; + + ParserImpl.prototype.tryParseExpectedListItem = function (currentListType, inErrorRecovery, items, processItems) { + if (this.isExpectedListItem(currentListType, inErrorRecovery)) { + var item = this.parseExpectedListItem(currentListType); + + items.push(item); + + if (processItems !== null) { + processItems(this, items); + } + } + }; + + ParserImpl.prototype.listIsTerminated = function (currentListType) { + return this.isExpectedListTerminator(currentListType) || this.currentToken().tokenKind === 10 /* EndOfFileToken */; + }; + + ParserImpl.prototype.getArray = function () { + if (this.arrayPool.length > 0) { + return this.arrayPool.pop(); + } + + return []; + }; + + ParserImpl.prototype.returnZeroOrOneLengthArray = function (array) { + if (array.length <= 1) { + this.returnArray(array); + } + }; + + ParserImpl.prototype.returnArray = function (array) { + array.length = 0; + this.arrayPool.push(array); + }; + + ParserImpl.prototype.parseSyntaxListWorker = function (currentListType, processItems) { + var items = this.getArray(); + var skippedTokens = this.getArray(); + + while (true) { + var oldItemsCount = items.length; + this.tryParseExpectedListItem(currentListType, false, items, processItems); + + var newItemsCount = items.length; + if (newItemsCount === oldItemsCount) { + if (this.listIsTerminated(currentListType)) { + break; + } + + var abort = this.abortParsingListOrMoveToNextToken(currentListType, items, skippedTokens); + if (abort) { + break; + } + } + } + + var result = TypeScript.Syntax.list(items); + + this.returnZeroOrOneLengthArray(items); + + return { skippedTokens: skippedTokens, list: result }; + }; + + ParserImpl.prototype.parseSeparatedSyntaxListWorker = function (currentListType) { + var items = this.getArray(); + var skippedTokens = this.getArray(); + TypeScript.Debug.assert(items.length === 0); + TypeScript.Debug.assert(skippedTokens.length === 0); + TypeScript.Debug.assert(skippedTokens !== items); + + var separatorKind = this.separatorKind(currentListType); + var allowAutomaticSemicolonInsertion = separatorKind === 78 /* SemicolonToken */; + + var inErrorRecovery = false; + var listWasTerminated = false; + while (true) { + var oldItemsCount = items.length; + + this.tryParseExpectedListItem(currentListType, inErrorRecovery, items, null); + + var newItemsCount = items.length; + if (newItemsCount === oldItemsCount) { + if (this.listIsTerminated(currentListType)) { + listWasTerminated = true; + break; + } + + var abort = this.abortParsingListOrMoveToNextToken(currentListType, items, skippedTokens); + if (abort) { + break; + } else { + inErrorRecovery = true; + continue; + } + } + + inErrorRecovery = false; + + var currentToken = this.currentToken(); + if (currentToken.tokenKind === separatorKind || currentToken.tokenKind === 79 /* CommaToken */) { + items.push(this.eatAnyToken()); + continue; + } + + if (this.listIsTerminated(currentListType)) { + listWasTerminated = true; + break; + } + + if (allowAutomaticSemicolonInsertion && this.canEatAutomaticSemicolon(false)) { + items.push(this.eatExplicitOrAutomaticSemicolon(false)); + + continue; + } + + items.push(this.eatToken(separatorKind)); + + inErrorRecovery = true; + } + + var result = TypeScript.Syntax.separatedList(items); + + this.returnZeroOrOneLengthArray(items); + + return { skippedTokens: skippedTokens, list: result }; + }; + + ParserImpl.prototype.separatorKind = function (currentListType) { + switch (currentListType) { + case 2048 /* HeritageClause_TypeNameList */: + case 16384 /* ArgumentList_AssignmentExpressions */: + case 256 /* EnumDeclaration_EnumElements */: + case 4096 /* VariableDeclaration_VariableDeclarators_AllowIn */: + case 8192 /* VariableDeclaration_VariableDeclarators_DisallowIn */: + case 32768 /* ObjectLiteralExpression_PropertyAssignments */: + case 131072 /* ParameterList_Parameters */: + case 65536 /* ArrayLiteralExpression_AssignmentExpressions */: + case 262144 /* TypeArgumentList_Types */: + case 524288 /* TypeParameterList_TypeParameters */: + return 79 /* CommaToken */; + + case 512 /* ObjectType_TypeMembers */: + return 78 /* SemicolonToken */; + + case 1 /* SourceUnit_ModuleElements */: + case 1024 /* ClassOrInterfaceDeclaration_HeritageClauses */: + case 2 /* ClassDeclaration_ClassElements */: + case 4 /* ModuleDeclaration_ModuleElements */: + case 8 /* SwitchStatement_SwitchClauses */: + case 16 /* SwitchClause_Statements */: + case 32 /* Block_Statements */: + default: + throw TypeScript.Errors.notYetImplemented(); + } + }; + + ParserImpl.prototype.reportUnexpectedTokenDiagnostic = function (listType) { + var token = this.currentToken(); + + var diagnostic = new TypeScript.Diagnostic(this.fileName, this.currentTokenStart(), token.width(), TypeScript.DiagnosticCode.Unexpected_token_0_expected, [this.getExpectedListElementType(listType)]); + this.addDiagnostic(diagnostic); + }; + + ParserImpl.prototype.addDiagnostic = function (diagnostic) { + if (this.diagnostics.length > 0 && this.diagnostics[this.diagnostics.length - 1].start() === diagnostic.start()) { + return; + } + + this.diagnostics.push(diagnostic); + }; + + ParserImpl.prototype.isExpectedListTerminator = function (currentListType) { + switch (currentListType) { + case 1 /* SourceUnit_ModuleElements */: + return this.isExpectedSourceUnit_ModuleElementsTerminator(); + + case 1024 /* ClassOrInterfaceDeclaration_HeritageClauses */: + return this.isExpectedClassOrInterfaceDeclaration_HeritageClausesTerminator(); + + case 2 /* ClassDeclaration_ClassElements */: + return this.isExpectedClassDeclaration_ClassElementsTerminator(); + + case 4 /* ModuleDeclaration_ModuleElements */: + return this.isExpectedModuleDeclaration_ModuleElementsTerminator(); + + case 8 /* SwitchStatement_SwitchClauses */: + return this.isExpectedSwitchStatement_SwitchClausesTerminator(); + + case 16 /* SwitchClause_Statements */: + return this.isExpectedSwitchClause_StatementsTerminator(); + + case 32 /* Block_Statements */: + return this.isExpectedBlock_StatementsTerminator(); + + case 64 /* TryBlock_Statements */: + return this.isExpectedTryBlock_StatementsTerminator(); + + case 128 /* CatchBlock_Statements */: + return this.isExpectedCatchBlock_StatementsTerminator(); + + case 256 /* EnumDeclaration_EnumElements */: + return this.isExpectedEnumDeclaration_EnumElementsTerminator(); + + case 512 /* ObjectType_TypeMembers */: + return this.isExpectedObjectType_TypeMembersTerminator(); + + case 16384 /* ArgumentList_AssignmentExpressions */: + return this.isExpectedArgumentList_AssignmentExpressionsTerminator(); + + case 2048 /* HeritageClause_TypeNameList */: + return this.isExpectedHeritageClause_TypeNameListTerminator(); + + case 4096 /* VariableDeclaration_VariableDeclarators_AllowIn */: + return this.isExpectedVariableDeclaration_VariableDeclarators_AllowInTerminator(); + + case 8192 /* VariableDeclaration_VariableDeclarators_DisallowIn */: + return this.isExpectedVariableDeclaration_VariableDeclarators_DisallowInTerminator(); + + case 32768 /* ObjectLiteralExpression_PropertyAssignments */: + return this.isExpectedObjectLiteralExpression_PropertyAssignmentsTerminator(); + + case 131072 /* ParameterList_Parameters */: + return this.isExpectedParameterList_ParametersTerminator(); + + case 262144 /* TypeArgumentList_Types */: + return this.isExpectedTypeArgumentList_TypesTerminator(); + + case 524288 /* TypeParameterList_TypeParameters */: + return this.isExpectedTypeParameterList_TypeParametersTerminator(); + + case 65536 /* ArrayLiteralExpression_AssignmentExpressions */: + return this.isExpectedLiteralExpression_AssignmentExpressionsTerminator(); + + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ParserImpl.prototype.isExpectedSourceUnit_ModuleElementsTerminator = function () { + return this.currentToken().tokenKind === 10 /* EndOfFileToken */; + }; + + ParserImpl.prototype.isExpectedEnumDeclaration_EnumElementsTerminator = function () { + return this.currentToken().tokenKind === 71 /* CloseBraceToken */; + }; + + ParserImpl.prototype.isExpectedModuleDeclaration_ModuleElementsTerminator = function () { + return this.currentToken().tokenKind === 71 /* CloseBraceToken */; + }; + + ParserImpl.prototype.isExpectedObjectType_TypeMembersTerminator = function () { + return this.currentToken().tokenKind === 71 /* CloseBraceToken */; + }; + + ParserImpl.prototype.isExpectedObjectLiteralExpression_PropertyAssignmentsTerminator = function () { + return this.currentToken().tokenKind === 71 /* CloseBraceToken */; + }; + + ParserImpl.prototype.isExpectedLiteralExpression_AssignmentExpressionsTerminator = function () { + return this.currentToken().tokenKind === 75 /* CloseBracketToken */; + }; + + ParserImpl.prototype.isExpectedTypeArgumentList_TypesTerminator = function () { + var token = this.currentToken(); + if (token.tokenKind === 81 /* GreaterThanToken */) { + return true; + } + + if (this.canFollowTypeArgumentListInExpression(token.tokenKind)) { + return true; + } + + return false; + }; + + ParserImpl.prototype.isExpectedTypeParameterList_TypeParametersTerminator = function () { + var token = this.currentToken(); + if (token.tokenKind === 81 /* GreaterThanToken */) { + return true; + } + + if (token.tokenKind === 72 /* OpenParenToken */ || token.tokenKind === 70 /* OpenBraceToken */ || token.tokenKind === 48 /* ExtendsKeyword */ || token.tokenKind === 51 /* ImplementsKeyword */) { + return true; + } + + return false; + }; + + ParserImpl.prototype.isExpectedParameterList_ParametersTerminator = function () { + var token = this.currentToken(); + if (token.tokenKind === 73 /* CloseParenToken */) { + return true; + } + + if (token.tokenKind === 70 /* OpenBraceToken */) { + return true; + } + + if (token.tokenKind === 85 /* EqualsGreaterThanToken */) { + return true; + } + + return false; + }; + + ParserImpl.prototype.isExpectedVariableDeclaration_VariableDeclarators_DisallowInTerminator = function () { + if (this.currentToken().tokenKind === 78 /* SemicolonToken */ || this.currentToken().tokenKind === 73 /* CloseParenToken */) { + return true; + } + + if (this.currentToken().tokenKind === 29 /* InKeyword */) { + return true; + } + + return false; + }; + + ParserImpl.prototype.isExpectedVariableDeclaration_VariableDeclarators_AllowInTerminator = function () { + if (this.previousToken().tokenKind === 79 /* CommaToken */) { + return false; + } + + if (this.currentToken().tokenKind === 85 /* EqualsGreaterThanToken */) { + return true; + } + + return this.canEatExplicitOrAutomaticSemicolon(false); + }; + + ParserImpl.prototype.isExpectedClassOrInterfaceDeclaration_HeritageClausesTerminator = function () { + var token0 = this.currentToken(); + if (token0.tokenKind === 70 /* OpenBraceToken */ || token0.tokenKind === 71 /* CloseBraceToken */) { + return true; + } + + return false; + }; + + ParserImpl.prototype.isExpectedHeritageClause_TypeNameListTerminator = function () { + var token0 = this.currentToken(); + if (token0.tokenKind === 48 /* ExtendsKeyword */ || token0.tokenKind === 51 /* ImplementsKeyword */) { + return true; + } + + if (this.isExpectedClassOrInterfaceDeclaration_HeritageClausesTerminator()) { + return true; + } + + return false; + }; + + ParserImpl.prototype.isExpectedArgumentList_AssignmentExpressionsTerminator = function () { + var token0 = this.currentToken(); + return token0.tokenKind === 73 /* CloseParenToken */ || token0.tokenKind === 78 /* SemicolonToken */; + }; + + ParserImpl.prototype.isExpectedClassDeclaration_ClassElementsTerminator = function () { + return this.currentToken().tokenKind === 71 /* CloseBraceToken */; + }; + + ParserImpl.prototype.isExpectedSwitchStatement_SwitchClausesTerminator = function () { + return this.currentToken().tokenKind === 71 /* CloseBraceToken */; + }; + + ParserImpl.prototype.isExpectedSwitchClause_StatementsTerminator = function () { + return this.currentToken().tokenKind === 71 /* CloseBraceToken */ || this.isSwitchClause(); + }; + + ParserImpl.prototype.isExpectedBlock_StatementsTerminator = function () { + return this.currentToken().tokenKind === 71 /* CloseBraceToken */; + }; + + ParserImpl.prototype.isExpectedTryBlock_StatementsTerminator = function () { + return this.currentToken().tokenKind === 17 /* CatchKeyword */ || this.currentToken().tokenKind === 25 /* FinallyKeyword */; + }; + + ParserImpl.prototype.isExpectedCatchBlock_StatementsTerminator = function () { + return this.currentToken().tokenKind === 25 /* FinallyKeyword */; + }; + + ParserImpl.prototype.isExpectedListItem = function (currentListType, inErrorRecovery) { + switch (currentListType) { + case 1 /* SourceUnit_ModuleElements */: + return this.isModuleElement(inErrorRecovery); + + case 1024 /* ClassOrInterfaceDeclaration_HeritageClauses */: + return this.isHeritageClause(); + + case 2 /* ClassDeclaration_ClassElements */: + return this.isClassElement(inErrorRecovery); + + case 4 /* ModuleDeclaration_ModuleElements */: + return this.isModuleElement(inErrorRecovery); + + case 8 /* SwitchStatement_SwitchClauses */: + return this.isSwitchClause(); + + case 16 /* SwitchClause_Statements */: + return this.isStatement(inErrorRecovery); + + case 32 /* Block_Statements */: + return this.isStatement(inErrorRecovery); + + case 64 /* TryBlock_Statements */: + case 128 /* CatchBlock_Statements */: + return false; + + case 256 /* EnumDeclaration_EnumElements */: + return this.isEnumElement(inErrorRecovery); + + case 4096 /* VariableDeclaration_VariableDeclarators_AllowIn */: + case 8192 /* VariableDeclaration_VariableDeclarators_DisallowIn */: + return this.isVariableDeclarator(); + + case 512 /* ObjectType_TypeMembers */: + return this.isTypeMember(inErrorRecovery); + + case 16384 /* ArgumentList_AssignmentExpressions */: + return this.isExpectedArgumentList_AssignmentExpression(); + + case 2048 /* HeritageClause_TypeNameList */: + return this.isHeritageClauseTypeName(); + + case 32768 /* ObjectLiteralExpression_PropertyAssignments */: + return this.isPropertyAssignment(inErrorRecovery); + + case 131072 /* ParameterList_Parameters */: + return this.isParameter(); + + case 262144 /* TypeArgumentList_Types */: + return this.isType(); + + case 524288 /* TypeParameterList_TypeParameters */: + return this.isTypeParameter(); + + case 65536 /* ArrayLiteralExpression_AssignmentExpressions */: + return this.isAssignmentOrOmittedExpression(); + + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ParserImpl.prototype.isExpectedArgumentList_AssignmentExpression = function () { + if (this.isExpression()) { + return true; + } + + if (this.currentToken().tokenKind === 79 /* CommaToken */) { + return true; + } + + return false; + }; + + ParserImpl.prototype.parseExpectedListItem = function (currentListType) { + switch (currentListType) { + case 1 /* SourceUnit_ModuleElements */: + return this.parseModuleElement(); + + case 1024 /* ClassOrInterfaceDeclaration_HeritageClauses */: + return this.parseHeritageClause(); + + case 2 /* ClassDeclaration_ClassElements */: + return this.parseClassElement(false); + + case 4 /* ModuleDeclaration_ModuleElements */: + return this.parseModuleElement(); + + case 8 /* SwitchStatement_SwitchClauses */: + return this.parseSwitchClause(); + + case 16 /* SwitchClause_Statements */: + return this.parseStatement(); + + case 32 /* Block_Statements */: + return this.parseStatement(); + + case 256 /* EnumDeclaration_EnumElements */: + return this.parseEnumElement(); + + case 512 /* ObjectType_TypeMembers */: + return this.parseTypeMember(); + + case 16384 /* ArgumentList_AssignmentExpressions */: + return this.parseAssignmentExpression(true); + + case 2048 /* HeritageClause_TypeNameList */: + return this.parseNameOrGenericType(); + + case 4096 /* VariableDeclaration_VariableDeclarators_AllowIn */: + return this.parseVariableDeclarator(true, false); + + case 8192 /* VariableDeclaration_VariableDeclarators_DisallowIn */: + return this.parseVariableDeclarator(false, false); + + case 32768 /* ObjectLiteralExpression_PropertyAssignments */: + return this.parsePropertyAssignment(); + + case 65536 /* ArrayLiteralExpression_AssignmentExpressions */: + return this.parseAssignmentOrOmittedExpression(); + + case 131072 /* ParameterList_Parameters */: + return this.parseParameter(); + + case 262144 /* TypeArgumentList_Types */: + return this.parseType(); + + case 524288 /* TypeParameterList_TypeParameters */: + return this.parseTypeParameter(); + + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ParserImpl.prototype.getExpectedListElementType = function (currentListType) { + switch (currentListType) { + case 1 /* SourceUnit_ModuleElements */: + return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.module_class_interface_enum_import_or_statement, null); + + case 1024 /* ClassOrInterfaceDeclaration_HeritageClauses */: + return '{'; + + case 2 /* ClassDeclaration_ClassElements */: + return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.constructor_function_accessor_or_variable, null); + + case 4 /* ModuleDeclaration_ModuleElements */: + return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.module_class_interface_enum_import_or_statement, null); + + case 8 /* SwitchStatement_SwitchClauses */: + return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.case_or_default_clause, null); + + case 16 /* SwitchClause_Statements */: + return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.statement, null); + + case 32 /* Block_Statements */: + return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.statement, null); + + case 4096 /* VariableDeclaration_VariableDeclarators_AllowIn */: + case 8192 /* VariableDeclaration_VariableDeclarators_DisallowIn */: + return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.identifier, null); + + case 256 /* EnumDeclaration_EnumElements */: + return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.identifier, null); + + case 512 /* ObjectType_TypeMembers */: + return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.call_construct_index_property_or_function_signature, null); + + case 16384 /* ArgumentList_AssignmentExpressions */: + return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.expression, null); + + case 2048 /* HeritageClause_TypeNameList */: + return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.type_name, null); + + case 32768 /* ObjectLiteralExpression_PropertyAssignments */: + return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.property_or_accessor, null); + + case 131072 /* ParameterList_Parameters */: + return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.parameter, null); + + case 262144 /* TypeArgumentList_Types */: + return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.type, null); + + case 524288 /* TypeParameterList_TypeParameters */: + return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.type_parameter, null); + + case 65536 /* ArrayLiteralExpression_AssignmentExpressions */: + return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.expression, null); + + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + return ParserImpl; + })(); + + function parse(fileName, text, isDeclaration, options) { + var source = new NormalParserSource(fileName, text, options.languageVersion()); + + return new ParserImpl(fileName, text.lineMap(), source, options).parseSyntaxTree(isDeclaration); + } + Parser.parse = parse; + + function incrementalParse(oldSyntaxTree, textChangeRange, newText) { + if (textChangeRange.isUnchanged()) { + return oldSyntaxTree; + } + + var source = new IncrementalParserSource(oldSyntaxTree, textChangeRange, newText); + + return new ParserImpl(oldSyntaxTree.fileName(), newText.lineMap(), source, oldSyntaxTree.parseOptions()).parseSyntaxTree(oldSyntaxTree.isDeclaration()); + } + Parser.incrementalParse = incrementalParse; + })(TypeScript.Parser || (TypeScript.Parser = {})); + var Parser = TypeScript.Parser; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var SyntaxTree = (function () { + function SyntaxTree(sourceUnit, isDeclaration, diagnostics, fileName, lineMap, parseOtions) { + this._allDiagnostics = null; + this._sourceUnit = sourceUnit; + this._isDeclaration = isDeclaration; + this._parserDiagnostics = diagnostics; + this._fileName = fileName; + this._lineMap = lineMap; + this._parseOptions = parseOtions; + } + SyntaxTree.prototype.toJSON = function (key) { + var result = {}; + + result.isDeclaration = this._isDeclaration; + result.languageVersion = TypeScript.LanguageVersion[this._parseOptions.languageVersion()]; + result.parseOptions = this._parseOptions; + + if (this.diagnostics().length > 0) { + result.diagnostics = this.diagnostics(); + } + + result.sourceUnit = this._sourceUnit; + result.lineMap = this._lineMap; + + return result; + }; + + SyntaxTree.prototype.sourceUnit = function () { + return this._sourceUnit; + }; + + SyntaxTree.prototype.isDeclaration = function () { + return this._isDeclaration; + }; + + SyntaxTree.prototype.computeDiagnostics = function () { + if (this._parserDiagnostics.length > 0) { + return this._parserDiagnostics; + } + + var diagnostics = []; + this.sourceUnit().accept(new GrammarCheckerWalker(this, diagnostics)); + + return diagnostics; + }; + + SyntaxTree.prototype.diagnostics = function () { + if (this._allDiagnostics === null) { + this._allDiagnostics = this.computeDiagnostics(); + } + + return this._allDiagnostics; + }; + + SyntaxTree.prototype.fileName = function () { + return this._fileName; + }; + + SyntaxTree.prototype.lineMap = function () { + return this._lineMap; + }; + + SyntaxTree.prototype.parseOptions = function () { + return this._parseOptions; + }; + + SyntaxTree.prototype.structuralEquals = function (tree) { + return TypeScript.ArrayUtilities.sequenceEquals(this.diagnostics(), tree.diagnostics(), TypeScript.Diagnostic.equals) && this.sourceUnit().structuralEquals(tree.sourceUnit()); + }; + return SyntaxTree; + })(); + TypeScript.SyntaxTree = SyntaxTree; + + var GrammarCheckerWalker = (function (_super) { + __extends(GrammarCheckerWalker, _super); + function GrammarCheckerWalker(syntaxTree, diagnostics) { + _super.call(this); + this.syntaxTree = syntaxTree; + this.diagnostics = diagnostics; + this.inAmbientDeclaration = false; + this.inBlock = false; + this.currentConstructor = null; + } + GrammarCheckerWalker.prototype.childFullStart = function (parent, child) { + return this.position() + TypeScript.Syntax.childOffset(parent, child); + }; + + GrammarCheckerWalker.prototype.childStart = function (parent, child) { + return this.childFullStart(parent, child) + child.leadingTriviaWidth(); + }; + + GrammarCheckerWalker.prototype.pushDiagnostic = function (start, length, diagnosticKey, args) { + if (typeof args === "undefined") { args = null; } + this.diagnostics.push(new TypeScript.Diagnostic(this.syntaxTree.fileName(), start, length, diagnosticKey, args)); + }; + + GrammarCheckerWalker.prototype.pushDiagnostic1 = function (elementFullStart, element, diagnosticKey, args) { + if (typeof args === "undefined") { args = null; } + this.diagnostics.push(new TypeScript.Diagnostic(this.syntaxTree.fileName(), elementFullStart + element.leadingTriviaWidth(), element.width(), diagnosticKey, args)); + }; + + GrammarCheckerWalker.prototype.visitCatchClause = function (node) { + if (node.typeAnnotation) { + this.pushDiagnostic(this.childStart(node, node.typeAnnotation), node.typeAnnotation.width(), TypeScript.DiagnosticCode.Catch_clause_parameter_cannot_have_a_type_annotation); + } + + _super.prototype.visitCatchClause.call(this, node); + }; + + GrammarCheckerWalker.prototype.checkParameterListOrder = function (node) { + var parameterFullStart = this.childFullStart(node, node.parameters); + + var seenOptionalParameter = false; + var parameterCount = node.parameters.nonSeparatorCount(); + + for (var i = 0, n = node.parameters.childCount(); i < n; i++) { + var nodeOrToken = node.parameters.childAt(i); + if (i % 2 === 0) { + var parameterIndex = i / 2; + var parameter = node.parameters.childAt(i); + + if (parameter.dotDotDotToken) { + if (parameterIndex !== (parameterCount - 1)) { + this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.Rest_parameter_must_be_last_in_list); + return true; + } + + if (parameter.questionToken) { + this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.Rest_parameter_cannot_be_optional); + return true; + } + + if (parameter.equalsValueClause) { + this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.Rest_parameter_cannot_have_an_initializer); + return true; + } + } else if (parameter.questionToken || parameter.equalsValueClause) { + seenOptionalParameter = true; + + if (parameter.questionToken && parameter.equalsValueClause) { + this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.Parameter_cannot_have_question_mark_and_initializer); + return true; + } + } else { + if (seenOptionalParameter) { + this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.Required_parameter_cannot_follow_optional_parameter); + return true; + } + } + } + + parameterFullStart += nodeOrToken.fullWidth(); + } + + return false; + }; + + GrammarCheckerWalker.prototype.checkParameterListAcessibilityModifiers = function (node) { + if (this.currentConstructor !== null && this.currentConstructor.parameterList === node && this.currentConstructor.block && !this.inAmbientDeclaration) { + return false; + } + + var parameterFullStart = this.childFullStart(node, node.parameters); + + for (var i = 0, n = node.parameters.childCount(); i < n; i++) { + var nodeOrToken = node.parameters.childAt(i); + if (i % 2 === 0) { + var parameter = node.parameters.childAt(i); + + if (parameter.publicOrPrivateKeyword) { + var keywordFullStart = parameterFullStart + TypeScript.Syntax.childOffset(parameter, parameter.publicOrPrivateKeyword); + + if (this.inAmbientDeclaration) { + this.pushDiagnostic1(keywordFullStart, parameter.publicOrPrivateKeyword, TypeScript.DiagnosticCode.Parameter_property_declarations_cannot_be_used_in_an_ambient_context); + } else if (!this.currentConstructor.block) { + this.pushDiagnostic1(keywordFullStart, parameter.publicOrPrivateKeyword, TypeScript.DiagnosticCode.Parameter_property_declarations_cannot_be_used_in_a_constructor_overload); + } else { + this.pushDiagnostic1(keywordFullStart, parameter.publicOrPrivateKeyword, TypeScript.DiagnosticCode.Parameter_property_declarations_can_only_be_used_in_constructors); + } + } + } + + parameterFullStart += nodeOrToken.fullWidth(); + } + + return false; + }; + + GrammarCheckerWalker.prototype.checkForTrailingSeparator = function (parent, list) { + if (list.childCount() === 0 || list.childCount() % 2 === 1) { + return false; + } + + var currentElementFullStart = this.childFullStart(parent, list); + + for (var i = 0, n = list.childCount(); i < n; i++) { + var child = list.childAt(i); + if (i === n - 1) { + this.pushDiagnostic1(currentElementFullStart, child, TypeScript.DiagnosticCode.Trailing_separator_not_allowed); + } + + currentElementFullStart += child.fullWidth(); + } + + return true; + }; + + GrammarCheckerWalker.prototype.checkForAtLeastOneElement = function (parent, list, expected) { + if (list.childCount() > 0) { + return false; + } + + var listFullStart = this.childFullStart(parent, list); + var tokenAtStart = this.syntaxTree.sourceUnit().findToken(listFullStart); + + this.pushDiagnostic1(listFullStart, tokenAtStart.token(), TypeScript.DiagnosticCode.Unexpected_token_0_expected, [expected]); + + return true; + }; + + GrammarCheckerWalker.prototype.visitParameterList = function (node) { + if (this.checkParameterListAcessibilityModifiers(node) || this.checkParameterListOrder(node) || this.checkForTrailingSeparator(node, node.parameters)) { + this.skip(node); + return; + } + + _super.prototype.visitParameterList.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitHeritageClause = function (node) { + if (this.checkForTrailingSeparator(node, node.typeNames) || this.checkForAtLeastOneElement(node, node.typeNames, TypeScript.getLocalizedText(TypeScript.DiagnosticCode.type_name, null))) { + this.skip(node); + return; + } + + _super.prototype.visitHeritageClause.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitArgumentList = function (node) { + if (this.checkForTrailingSeparator(node, node.arguments)) { + this.skip(node); + return; + } + + _super.prototype.visitArgumentList.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitVariableDeclaration = function (node) { + if (this.checkForTrailingSeparator(node, node.variableDeclarators) || this.checkForAtLeastOneElement(node, node.variableDeclarators, TypeScript.getLocalizedText(TypeScript.DiagnosticCode.identifier, null))) { + this.skip(node); + return; + } + + _super.prototype.visitVariableDeclaration.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitTypeArgumentList = function (node) { + if (this.checkForTrailingSeparator(node, node.typeArguments) || this.checkForAtLeastOneElement(node, node.typeArguments, TypeScript.getLocalizedText(TypeScript.DiagnosticCode.identifier, null))) { + this.skip(node); + return; + } + + _super.prototype.visitTypeArgumentList.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitTypeParameterList = function (node) { + if (this.checkForTrailingSeparator(node, node.typeParameters) || this.checkForAtLeastOneElement(node, node.typeParameters, TypeScript.getLocalizedText(TypeScript.DiagnosticCode.identifier, null))) { + this.skip(node); + return; + } + + _super.prototype.visitTypeParameterList.call(this, node); + }; + + GrammarCheckerWalker.prototype.checkIndexSignatureParameter = function (node) { + var parameterFullStart = this.childFullStart(node, node.parameter); + var parameter = node.parameter; + + if (parameter.dotDotDotToken) { + this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.Index_signatures_cannot_have_rest_parameters); + return true; + } else if (parameter.publicOrPrivateKeyword) { + this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.Index_signature_parameter_cannot_have_accessibility_modifiers); + return true; + } else if (parameter.questionToken) { + this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.Index_signature_parameter_cannot_have_a_question_mark); + return true; + } else if (parameter.equalsValueClause) { + this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.Index_signature_parameter_cannot_have_an_initializer); + return true; + } else if (!parameter.typeAnnotation) { + this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.Index_signature_parameter_must_have_a_type_annotation); + return true; + } else if (parameter.typeAnnotation.type.kind() !== 69 /* StringKeyword */ && parameter.typeAnnotation.type.kind() !== 67 /* NumberKeyword */) { + this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.Index_signature_parameter_type_must_be_string_or_number); + return true; + } + + return false; + }; + + GrammarCheckerWalker.prototype.visitIndexSignature = function (node) { + if (this.checkIndexSignatureParameter(node)) { + this.skip(node); + return; + } + + if (!node.typeAnnotation) { + this.pushDiagnostic1(this.position(), node, TypeScript.DiagnosticCode.Index_signature_must_have_a_type_annotation); + this.skip(node); + return; + } + + _super.prototype.visitIndexSignature.call(this, node); + }; + + GrammarCheckerWalker.prototype.checkClassDeclarationHeritageClauses = function (node) { + var heritageClauseFullStart = this.childFullStart(node, node.heritageClauses); + + var seenExtendsClause = false; + var seenImplementsClause = false; + + for (var i = 0, n = node.heritageClauses.childCount(); i < n; i++) { + TypeScript.Debug.assert(i <= 2); + var heritageClause = node.heritageClauses.childAt(i); + + if (heritageClause.extendsOrImplementsKeyword.tokenKind === 48 /* ExtendsKeyword */) { + if (seenExtendsClause) { + this.pushDiagnostic1(heritageClauseFullStart, heritageClause, TypeScript.DiagnosticCode.extends_clause_already_seen); + return true; + } + + if (seenImplementsClause) { + this.pushDiagnostic1(heritageClauseFullStart, heritageClause, TypeScript.DiagnosticCode.extends_clause_must_precede_implements_clause); + return true; + } + + if (heritageClause.typeNames.nonSeparatorCount() > 1) { + this.pushDiagnostic1(heritageClauseFullStart, heritageClause, TypeScript.DiagnosticCode.Classes_can_only_extend_a_single_class); + return true; + } + + seenExtendsClause = true; + } else { + TypeScript.Debug.assert(heritageClause.extendsOrImplementsKeyword.tokenKind === 51 /* ImplementsKeyword */); + if (seenImplementsClause) { + this.pushDiagnostic1(heritageClauseFullStart, heritageClause, TypeScript.DiagnosticCode.implements_clause_already_seen); + return true; + } + + seenImplementsClause = true; + } + + heritageClauseFullStart += heritageClause.fullWidth(); + } + + return false; + }; + + GrammarCheckerWalker.prototype.checkForDisallowedDeclareModifier = function (modifiers) { + if (this.inAmbientDeclaration) { + var declareToken = TypeScript.SyntaxUtilities.getToken(modifiers, 63 /* DeclareKeyword */); + + if (declareToken) { + this.pushDiagnostic1(this.childFullStart(modifiers, declareToken), declareToken, TypeScript.DiagnosticCode.declare_modifier_not_allowed_for_code_already_in_an_ambient_context); + return true; + } + } + + return false; + }; + + GrammarCheckerWalker.prototype.checkForRequiredDeclareModifier = function (moduleElement, typeKeyword, modifiers) { + if (!this.inAmbientDeclaration && this.syntaxTree.isDeclaration()) { + if (!TypeScript.SyntaxUtilities.containsToken(modifiers, 63 /* DeclareKeyword */)) { + this.pushDiagnostic1(this.childFullStart(moduleElement, typeKeyword), typeKeyword.firstToken(), TypeScript.DiagnosticCode.declare_modifier_required_for_top_level_element); + return true; + } + } + }; + + GrammarCheckerWalker.prototype.checkFunctionOverloads = function (node, moduleElements) { + if (!this.inAmbientDeclaration && !this.syntaxTree.isDeclaration()) { + var moduleElementFullStart = this.childFullStart(node, moduleElements); + + var inFunctionOverloadChain = false; + var functionOverloadChainName = null; + + for (var i = 0, n = moduleElements.childCount(); i < n; i++) { + var moduleElement = moduleElements.childAt(i); + var lastElement = i === (n - 1); + + if (inFunctionOverloadChain) { + if (moduleElement.kind() !== 129 /* FunctionDeclaration */) { + this.pushDiagnostic1(moduleElementFullStart, moduleElement.firstToken(), TypeScript.DiagnosticCode.Function_implementation_expected); + return true; + } + + var functionDeclaration = moduleElement; + if (functionDeclaration.identifier.valueText() !== functionOverloadChainName) { + var identifierFullStart = moduleElementFullStart + TypeScript.Syntax.childOffset(moduleElement, functionDeclaration.identifier); + this.pushDiagnostic1(identifierFullStart, functionDeclaration.identifier, TypeScript.DiagnosticCode.Function_overload_name_must_be_0, [functionOverloadChainName]); + return true; + } + } + + if (moduleElement.kind() === 129 /* FunctionDeclaration */) { + functionDeclaration = moduleElement; + if (!TypeScript.SyntaxUtilities.containsToken(functionDeclaration.modifiers, 63 /* DeclareKeyword */)) { + inFunctionOverloadChain = functionDeclaration.block === null; + functionOverloadChainName = functionDeclaration.identifier.valueText(); + + if (lastElement && inFunctionOverloadChain) { + this.pushDiagnostic1(moduleElementFullStart, moduleElement.firstToken(), TypeScript.DiagnosticCode.Function_implementation_expected); + return true; + } + } else { + inFunctionOverloadChain = false; + functionOverloadChainName = ""; + } + } + + moduleElementFullStart += moduleElement.fullWidth(); + } + } + + return false; + }; + + GrammarCheckerWalker.prototype.checkClassOverloads = function (node) { + if (!this.inAmbientDeclaration && !TypeScript.SyntaxUtilities.containsToken(node.modifiers, 63 /* DeclareKeyword */)) { + var classElementFullStart = this.childFullStart(node, node.classElements); + + var inFunctionOverloadChain = false; + var inConstructorOverloadChain = false; + + var functionOverloadChainName = null; + var isInStaticOverloadChain = null; + var memberFunctionDeclaration = null; + + for (var i = 0, n = node.classElements.childCount(); i < n; i++) { + var classElement = node.classElements.childAt(i); + var lastElement = i === (n - 1); + var isStaticOverload = null; + + if (inFunctionOverloadChain) { + if (classElement.kind() !== 135 /* MemberFunctionDeclaration */) { + this.pushDiagnostic1(classElementFullStart, classElement.firstToken(), TypeScript.DiagnosticCode.Function_implementation_expected); + return true; + } + + memberFunctionDeclaration = classElement; + if (memberFunctionDeclaration.propertyName.valueText() !== functionOverloadChainName) { + var propertyNameFullStart = classElementFullStart + TypeScript.Syntax.childOffset(classElement, memberFunctionDeclaration.propertyName); + this.pushDiagnostic1(propertyNameFullStart, memberFunctionDeclaration.propertyName, TypeScript.DiagnosticCode.Function_overload_name_must_be_0, [functionOverloadChainName]); + return true; + } + isStaticOverload = TypeScript.SyntaxUtilities.containsToken(memberFunctionDeclaration.modifiers, 58 /* StaticKeyword */); + if (isStaticOverload !== isInStaticOverloadChain) { + propertyNameFullStart = classElementFullStart + TypeScript.Syntax.childOffset(classElement, memberFunctionDeclaration.propertyName); + var diagnostic = isInStaticOverloadChain ? TypeScript.DiagnosticCode.Function_overload_must_be_static : TypeScript.DiagnosticCode.Function_overload_must_not_be_static; + this.pushDiagnostic1(propertyNameFullStart, memberFunctionDeclaration.propertyName, diagnostic, null); + return true; + } + } else if (inConstructorOverloadChain) { + if (classElement.kind() !== 137 /* ConstructorDeclaration */) { + this.pushDiagnostic1(classElementFullStart, classElement.firstToken(), TypeScript.DiagnosticCode.Constructor_implementation_expected); + return true; + } + } + + if (classElement.kind() === 135 /* MemberFunctionDeclaration */) { + memberFunctionDeclaration = classElement; + + inFunctionOverloadChain = memberFunctionDeclaration.block === null; + functionOverloadChainName = memberFunctionDeclaration.propertyName.valueText(); + isInStaticOverloadChain = TypeScript.SyntaxUtilities.containsToken(memberFunctionDeclaration.modifiers, 58 /* StaticKeyword */); + + if (lastElement && inFunctionOverloadChain) { + this.pushDiagnostic1(classElementFullStart, classElement.firstToken(), TypeScript.DiagnosticCode.Function_implementation_expected); + return true; + } + } else if (classElement.kind() === 137 /* ConstructorDeclaration */) { + var constructorDeclaration = classElement; + + inConstructorOverloadChain = constructorDeclaration.block === null; + if (lastElement && inConstructorOverloadChain) { + this.pushDiagnostic1(classElementFullStart, classElement.firstToken(), TypeScript.DiagnosticCode.Constructor_implementation_expected); + return true; + } + } + + classElementFullStart += classElement.fullWidth(); + } + } + + return false; + }; + + GrammarCheckerWalker.prototype.checkForReservedName = function (parent, name, diagnosticKey) { + var nameFullStart = this.childFullStart(parent, name); + var token; + var tokenFullStart; + + var current = name; + while (current !== null) { + if (current.kind() === 121 /* QualifiedName */) { + var qualifiedName = current; + token = qualifiedName.right; + tokenFullStart = nameFullStart + this.childFullStart(qualifiedName, token); + current = qualifiedName.left; + } else { + TypeScript.Debug.assert(current.kind() === 11 /* IdentifierName */); + token = current; + tokenFullStart = nameFullStart; + current = null; + } + + switch (token.valueText()) { + case "any": + case "number": + case "boolean": + case "string": + case "void": + this.pushDiagnostic(tokenFullStart + token.leadingTriviaWidth(), token.width(), diagnosticKey, [token.valueText()]); + return true; + } + } + + return false; + }; + + GrammarCheckerWalker.prototype.visitClassDeclaration = function (node) { + if (this.checkForReservedName(node, node.identifier, TypeScript.DiagnosticCode.Class_name_cannot_be_0) || this.checkForDisallowedDeclareModifier(node.modifiers) || this.checkForRequiredDeclareModifier(node, node.classKeyword, node.modifiers) || this.checkModuleElementModifiers(node.modifiers) || this.checkClassDeclarationHeritageClauses(node) || this.checkClassOverloads(node)) { + this.skip(node); + return; + } + + var savedInAmbientDeclaration = this.inAmbientDeclaration; + this.inAmbientDeclaration = this.inAmbientDeclaration || this.syntaxTree.isDeclaration() || TypeScript.SyntaxUtilities.containsToken(node.modifiers, 63 /* DeclareKeyword */); + _super.prototype.visitClassDeclaration.call(this, node); + this.inAmbientDeclaration = savedInAmbientDeclaration; + }; + + GrammarCheckerWalker.prototype.checkInterfaceDeclarationHeritageClauses = function (node) { + var heritageClauseFullStart = this.childFullStart(node, node.heritageClauses); + + var seenExtendsClause = false; + + for (var i = 0, n = node.heritageClauses.childCount(); i < n; i++) { + TypeScript.Debug.assert(i <= 1); + var heritageClause = node.heritageClauses.childAt(i); + + if (heritageClause.extendsOrImplementsKeyword.tokenKind === 48 /* ExtendsKeyword */) { + if (seenExtendsClause) { + this.pushDiagnostic1(heritageClauseFullStart, heritageClause, TypeScript.DiagnosticCode.extends_clause_already_seen); + return true; + } + + seenExtendsClause = true; + } else { + TypeScript.Debug.assert(heritageClause.extendsOrImplementsKeyword.tokenKind === 51 /* ImplementsKeyword */); + this.pushDiagnostic1(heritageClauseFullStart, heritageClause, TypeScript.DiagnosticCode.Interface_declaration_cannot_have_implements_clause); + return true; + } + + heritageClauseFullStart += heritageClause.fullWidth(); + } + + return false; + }; + + GrammarCheckerWalker.prototype.checkInterfaceModifiers = function (modifiers) { + var modifierFullStart = this.position(); + + for (var i = 0, n = modifiers.childCount(); i < n; i++) { + var modifier = modifiers.childAt(i); + if (modifier.tokenKind === 63 /* DeclareKeyword */) { + this.pushDiagnostic1(modifierFullStart, modifier, TypeScript.DiagnosticCode.declare_modifier_cannot_appear_on_an_interface_declaration); + return true; + } + + modifierFullStart += modifier.fullWidth(); + } + + return false; + }; + + GrammarCheckerWalker.prototype.visitInterfaceDeclaration = function (node) { + if (this.checkForReservedName(node, node.identifier, TypeScript.DiagnosticCode.Interface_name_cannot_be_0) || this.checkInterfaceModifiers(node.modifiers) || this.checkModuleElementModifiers(node.modifiers) || this.checkInterfaceDeclarationHeritageClauses(node)) { + this.skip(node); + return; + } + + _super.prototype.visitInterfaceDeclaration.call(this, node); + }; + + GrammarCheckerWalker.prototype.checkClassElementModifiers = function (list) { + var modifierFullStart = this.position(); + + var seenAccessibilityModifier = false; + var seenStaticModifier = false; + + for (var i = 0, n = list.childCount(); i < n; i++) { + var modifier = list.childAt(i); + if (modifier.tokenKind === 57 /* PublicKeyword */ || modifier.tokenKind === 55 /* PrivateKeyword */) { + if (seenAccessibilityModifier) { + this.pushDiagnostic1(modifierFullStart, modifier, TypeScript.DiagnosticCode.Accessibility_modifier_already_seen); + return true; + } + + if (seenStaticModifier) { + var previousToken = list.childAt(i - 1); + this.pushDiagnostic1(modifierFullStart, modifier, TypeScript.DiagnosticCode._0_modifier_must_precede_1_modifier, [modifier.text(), previousToken.text()]); + return true; + } + + seenAccessibilityModifier = true; + } else if (modifier.tokenKind === 58 /* StaticKeyword */) { + if (seenStaticModifier) { + this.pushDiagnostic1(modifierFullStart, modifier, TypeScript.DiagnosticCode._0_modifier_already_seen, [modifier.text()]); + return true; + } + + seenStaticModifier = true; + } else { + this.pushDiagnostic1(modifierFullStart, modifier, TypeScript.DiagnosticCode._0_modifier_cannot_appear_on_a_class_element, [modifier.text()]); + return true; + } + + modifierFullStart += modifier.fullWidth(); + } + + return false; + }; + + GrammarCheckerWalker.prototype.visitMemberVariableDeclaration = function (node) { + if (this.checkClassElementModifiers(node.modifiers)) { + this.skip(node); + return; + } + + _super.prototype.visitMemberVariableDeclaration.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitMemberFunctionDeclaration = function (node) { + if (this.checkClassElementModifiers(node.modifiers)) { + this.skip(node); + return; + } + + _super.prototype.visitMemberFunctionDeclaration.call(this, node); + }; + + GrammarCheckerWalker.prototype.checkGetMemberAccessorParameter = function (node) { + var getKeywordFullStart = this.childFullStart(node, node.getKeyword); + if (node.parameterList.parameters.childCount() !== 0) { + this.pushDiagnostic1(getKeywordFullStart, node.getKeyword, TypeScript.DiagnosticCode.get_accessor_cannot_have_parameters); + return true; + } + + return false; + }; + + GrammarCheckerWalker.prototype.checkEcmaScriptVersionIsAtLeast = function (parent, node, languageVersion, diagnosticKey) { + if (this.syntaxTree.parseOptions().languageVersion() < languageVersion) { + var nodeFullStart = this.childFullStart(parent, node); + this.pushDiagnostic1(nodeFullStart, node, diagnosticKey); + return true; + } + + return false; + }; + + GrammarCheckerWalker.prototype.visitGetMemberAccessorDeclaration = function (node) { + if (this.checkEcmaScriptVersionIsAtLeast(node, node.getKeyword, 1 /* EcmaScript5 */, TypeScript.DiagnosticCode.Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher) || this.checkClassElementModifiers(node.modifiers) || this.checkGetMemberAccessorParameter(node)) { + this.skip(node); + return; + } + + _super.prototype.visitGetMemberAccessorDeclaration.call(this, node); + }; + + GrammarCheckerWalker.prototype.checkSetMemberAccessorParameter = function (node) { + var setKeywordFullStart = this.childFullStart(node, node.setKeyword); + if (node.parameterList.parameters.childCount() !== 1) { + this.pushDiagnostic1(setKeywordFullStart, node.setKeyword, TypeScript.DiagnosticCode.set_accessor_must_have_one_and_only_one_parameter); + return true; + } + + var parameterListFullStart = this.childFullStart(node, node.parameterList); + var parameterFullStart = parameterListFullStart + TypeScript.Syntax.childOffset(node.parameterList, node.parameterList.openParenToken); + var parameter = node.parameterList.parameters.childAt(0); + + if (parameter.publicOrPrivateKeyword) { + this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.set_accessor_parameter_cannot_have_accessibility_modifier); + return true; + } + + if (parameter.questionToken) { + this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.set_accessor_parameter_cannot_be_optional); + return true; + } + + if (parameter.equalsValueClause) { + this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.set_accessor_parameter_cannot_have_an_initializer); + return true; + } + + if (parameter.dotDotDotToken) { + this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.set_accessor_cannot_have_rest_parameter); + return true; + } + + return false; + }; + + GrammarCheckerWalker.prototype.visitSetMemberAccessorDeclaration = function (node) { + if (this.checkEcmaScriptVersionIsAtLeast(node, node.setKeyword, 1 /* EcmaScript5 */, TypeScript.DiagnosticCode.Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher) || this.checkClassElementModifiers(node.modifiers) || this.checkSetMemberAccessorParameter(node)) { + this.skip(node); + return; + } + + _super.prototype.visitSetMemberAccessorDeclaration.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitGetAccessorPropertyAssignment = function (node) { + if (this.checkEcmaScriptVersionIsAtLeast(node, node.getKeyword, 1 /* EcmaScript5 */, TypeScript.DiagnosticCode.Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher)) { + this.skip(node); + return; + } + + _super.prototype.visitGetAccessorPropertyAssignment.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitSetAccessorPropertyAssignment = function (node) { + if (this.checkEcmaScriptVersionIsAtLeast(node, node.setKeyword, 1 /* EcmaScript5 */, TypeScript.DiagnosticCode.Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher)) { + this.skip(node); + return; + } + + _super.prototype.visitSetAccessorPropertyAssignment.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitEnumDeclaration = function (node) { + if (this.checkForReservedName(node, node.identifier, TypeScript.DiagnosticCode.Enum_name_cannot_be_0) || this.checkForDisallowedDeclareModifier(node.modifiers) || this.checkForRequiredDeclareModifier(node, node.enumKeyword, node.modifiers) || this.checkModuleElementModifiers(node.modifiers), this.checkEnumElements(node)) { + this.skip(node); + return; + } + + var savedInAmbientDeclaration = this.inAmbientDeclaration; + this.inAmbientDeclaration = this.inAmbientDeclaration || this.syntaxTree.isDeclaration() || TypeScript.SyntaxUtilities.containsToken(node.modifiers, 63 /* DeclareKeyword */); + _super.prototype.visitEnumDeclaration.call(this, node); + this.inAmbientDeclaration = savedInAmbientDeclaration; + }; + + GrammarCheckerWalker.prototype.checkEnumElements = function (node) { + var enumElementFullStart = this.childFullStart(node, node.enumElements); + + var seenComputedValue = false; + for (var i = 0, n = node.enumElements.childCount(); i < n; i++) { + var child = node.enumElements.childAt(i); + + if (i % 2 === 0) { + var enumElement = child; + + if (!enumElement.equalsValueClause && seenComputedValue) { + this.pushDiagnostic1(enumElementFullStart, enumElement, TypeScript.DiagnosticCode.Enum_member_must_have_initializer, null); + return true; + } + + if (enumElement.equalsValueClause) { + var value = enumElement.equalsValueClause.value; + if (!TypeScript.Syntax.isIntegerLiteral(value)) { + seenComputedValue = true; + } + } + } + + enumElementFullStart += child.fullWidth(); + } + + return false; + }; + + GrammarCheckerWalker.prototype.visitEnumElement = function (node) { + if (this.inAmbientDeclaration && node.equalsValueClause) { + var expression = node.equalsValueClause.value; + if (!TypeScript.Syntax.isIntegerLiteral(expression)) { + this.pushDiagnostic1(this.childFullStart(node, node.equalsValueClause), node.equalsValueClause.firstToken(), TypeScript.DiagnosticCode.Ambient_enum_elements_can_only_have_integer_literal_initializers); + this.skip(node); + return; + } + } + + _super.prototype.visitEnumElement.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitInvocationExpression = function (node) { + if (node.expression.kind() === 50 /* SuperKeyword */ && node.argumentList.typeArgumentList !== null) { + this.pushDiagnostic1(this.position(), node, TypeScript.DiagnosticCode.super_invocation_cannot_have_type_arguments); + } + + _super.prototype.visitInvocationExpression.call(this, node); + }; + + GrammarCheckerWalker.prototype.checkModuleElementModifiers = function (modifiers) { + var modifierFullStart = this.position(); + var seenExportModifier = false; + var seenDeclareModifier = false; + + for (var i = 0, n = modifiers.childCount(); i < n; i++) { + var modifier = modifiers.childAt(i); + if (modifier.tokenKind === 57 /* PublicKeyword */ || modifier.tokenKind === 55 /* PrivateKeyword */ || modifier.tokenKind === 58 /* StaticKeyword */) { + this.pushDiagnostic1(modifierFullStart, modifier, TypeScript.DiagnosticCode._0_modifier_cannot_appear_on_a_module_element, [modifier.text()]); + return true; + } + + if (modifier.tokenKind === 63 /* DeclareKeyword */) { + if (seenDeclareModifier) { + this.pushDiagnostic1(modifierFullStart, modifier, TypeScript.DiagnosticCode.Accessibility_modifier_already_seen); + return; + } + + seenDeclareModifier = true; + } else if (modifier.tokenKind === 47 /* ExportKeyword */) { + if (seenExportModifier) { + this.pushDiagnostic1(modifierFullStart, modifier, TypeScript.DiagnosticCode._0_modifier_already_seen, [modifier.text()]); + return; + } + + if (seenDeclareModifier) { + this.pushDiagnostic1(modifierFullStart, modifier, TypeScript.DiagnosticCode._0_modifier_must_precede_1_modifier, [TypeScript.SyntaxFacts.getText(47 /* ExportKeyword */), TypeScript.SyntaxFacts.getText(63 /* DeclareKeyword */)]); + return; + } + + seenExportModifier = true; + } + + modifierFullStart += modifier.fullWidth(); + } + + return false; + }; + + GrammarCheckerWalker.prototype.checkForDisallowedImportDeclaration = function (node) { + if (node.stringLiteral === null) { + var currentElementFullStart = this.childFullStart(node, node.moduleElements); + + for (var i = 0, n = node.moduleElements.childCount(); i < n; i++) { + var child = node.moduleElements.childAt(i); + if (child.kind() === 133 /* ImportDeclaration */) { + var importDeclaration = child; + if (importDeclaration.moduleReference.kind() === 245 /* ExternalModuleReference */) { + this.pushDiagnostic1(currentElementFullStart, importDeclaration, TypeScript.DiagnosticCode.Import_declarations_in_an_internal_module_cannot_reference_an_external_module, null); + } + } + + currentElementFullStart += child.fullWidth(); + } + } + + return false; + }; + + GrammarCheckerWalker.prototype.checkForDisallowedDeclareModifierOnImportDeclaration = function (modifiers) { + var declareToken = TypeScript.SyntaxUtilities.getToken(modifiers, 63 /* DeclareKeyword */); + + if (declareToken) { + this.pushDiagnostic1(this.childFullStart(modifiers, declareToken), declareToken, TypeScript.DiagnosticCode.declare_modifier_not_allowed_on_import_declaration); + return true; + } + }; + + GrammarCheckerWalker.prototype.visitImportDeclaration = function (node) { + if (this.checkForDisallowedDeclareModifierOnImportDeclaration(node.modifiers) || this.checkModuleElementModifiers(node.modifiers)) { + this.skip(node); + return; + } + + _super.prototype.visitImportDeclaration.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitModuleDeclaration = function (node) { + if (this.checkForReservedName(node, node.moduleName, TypeScript.DiagnosticCode.Module_name_cannot_be_0) || this.checkForDisallowedDeclareModifier(node.modifiers) || this.checkForRequiredDeclareModifier(node, node.moduleKeyword, node.modifiers) || this.checkModuleElementModifiers(node.modifiers) || this.checkForDisallowedImportDeclaration(node) || this.checkForDisallowedExports(node, node.moduleElements) || this.checkForMultipleExportAssignments(node, node.moduleElements)) { + this.skip(node); + return; + } + + if (!TypeScript.SyntaxUtilities.containsToken(node.modifiers, 63 /* DeclareKeyword */) && this.checkFunctionOverloads(node, node.moduleElements)) { + this.skip(node); + return; + } + + if (node.stringLiteral) { + if (!this.inAmbientDeclaration && !TypeScript.SyntaxUtilities.containsToken(node.modifiers, 63 /* DeclareKeyword */)) { + var stringLiteralFullStart = this.childFullStart(node, node.stringLiteral); + this.pushDiagnostic1(stringLiteralFullStart, node.stringLiteral, TypeScript.DiagnosticCode.Only_ambient_modules_can_use_quoted_names); + this.skip(node); + return; + } + } + + if (!node.stringLiteral && this.checkForDisallowedExportAssignment(node)) { + this.skip(node); + return; + } + + var savedInAmbientDeclaration = this.inAmbientDeclaration; + this.inAmbientDeclaration = this.inAmbientDeclaration || this.syntaxTree.isDeclaration() || TypeScript.SyntaxUtilities.containsToken(node.modifiers, 63 /* DeclareKeyword */); + _super.prototype.visitModuleDeclaration.call(this, node); + this.inAmbientDeclaration = savedInAmbientDeclaration; + }; + + GrammarCheckerWalker.prototype.checkForDisallowedExports = function (node, moduleElements) { + var seenExportedElement = false; + for (var i = 0, n = moduleElements.childCount(); i < n; i++) { + var child = moduleElements.childAt(i); + + if (TypeScript.SyntaxUtilities.hasExportKeyword(child)) { + seenExportedElement = true; + break; + } + } + + var moduleElementFullStart = this.childFullStart(node, moduleElements); + if (seenExportedElement) { + for (var i = 0, n = moduleElements.childCount(); i < n; i++) { + var child = moduleElements.childAt(i); + + if (child.kind() === 134 /* ExportAssignment */) { + this.pushDiagnostic1(moduleElementFullStart, child, TypeScript.DiagnosticCode.Export_assignment_not_allowed_in_module_with_exported_element); + return true; + } + + moduleElementFullStart += child.fullWidth(); + } + } + + return false; + }; + + GrammarCheckerWalker.prototype.checkForMultipleExportAssignments = function (node, moduleElements) { + var moduleElementFullStart = this.childFullStart(node, moduleElements); + var seenExportAssignment = false; + var errorFound = false; + for (var i = 0, n = moduleElements.childCount(); i < n; i++) { + var child = moduleElements.childAt(i); + if (child.kind() === 134 /* ExportAssignment */) { + if (seenExportAssignment) { + this.pushDiagnostic1(moduleElementFullStart, child, TypeScript.DiagnosticCode.Module_cannot_have_multiple_export_assignments); + errorFound = true; + } + seenExportAssignment = true; + } + + moduleElementFullStart += child.fullWidth(); + } + + return errorFound; + }; + + GrammarCheckerWalker.prototype.checkForDisallowedExportAssignment = function (node) { + var moduleElementFullStart = this.childFullStart(node, node.moduleElements); + + for (var i = 0, n = node.moduleElements.childCount(); i < n; i++) { + var child = node.moduleElements.childAt(i); + + if (child.kind() === 134 /* ExportAssignment */) { + this.pushDiagnostic1(moduleElementFullStart, child, TypeScript.DiagnosticCode.Export_assignment_cannot_be_used_in_internal_modules); + + return true; + } + + moduleElementFullStart += child.fullWidth(); + } + + return false; + }; + + GrammarCheckerWalker.prototype.visitBlock = function (node) { + if (this.inAmbientDeclaration || this.syntaxTree.isDeclaration()) { + this.pushDiagnostic1(this.position(), node.firstToken(), TypeScript.DiagnosticCode.Implementations_are_not_allowed_in_ambient_contexts); + this.skip(node); + return; + } + + if (this.checkFunctionOverloads(node, node.statements)) { + this.skip(node); + return; + } + + var savedInBlock = this.inBlock; + this.inBlock = true; + _super.prototype.visitBlock.call(this, node); + this.inBlock = savedInBlock; + }; + + GrammarCheckerWalker.prototype.checkForStatementInAmbientContxt = function (node) { + if (this.inAmbientDeclaration || this.syntaxTree.isDeclaration()) { + this.pushDiagnostic1(this.position(), node.firstToken(), TypeScript.DiagnosticCode.Statements_are_not_allowed_in_ambient_contexts); + return true; + } + + return false; + }; + + GrammarCheckerWalker.prototype.visitBreakStatement = function (node) { + if (this.checkForStatementInAmbientContxt(node)) { + this.skip(node); + return; + } + + _super.prototype.visitBreakStatement.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitContinueStatement = function (node) { + if (this.checkForStatementInAmbientContxt(node)) { + this.skip(node); + return; + } + + _super.prototype.visitContinueStatement.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitDebuggerStatement = function (node) { + if (this.checkForStatementInAmbientContxt(node)) { + this.skip(node); + return; + } + + _super.prototype.visitDebuggerStatement.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitDoStatement = function (node) { + if (this.checkForStatementInAmbientContxt(node)) { + this.skip(node); + return; + } + + _super.prototype.visitDoStatement.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitEmptyStatement = function (node) { + if (this.checkForStatementInAmbientContxt(node)) { + this.skip(node); + return; + } + + _super.prototype.visitEmptyStatement.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitExpressionStatement = function (node) { + if (this.checkForStatementInAmbientContxt(node)) { + this.skip(node); + return; + } + + _super.prototype.visitExpressionStatement.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitForInStatement = function (node) { + if (this.checkForStatementInAmbientContxt(node)) { + this.skip(node); + return; + } + + _super.prototype.visitForInStatement.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitForStatement = function (node) { + if (this.checkForStatementInAmbientContxt(node)) { + this.skip(node); + return; + } + + _super.prototype.visitForStatement.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitIfStatement = function (node) { + if (this.checkForStatementInAmbientContxt(node)) { + this.skip(node); + return; + } + + _super.prototype.visitIfStatement.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitLabeledStatement = function (node) { + if (this.checkForStatementInAmbientContxt(node)) { + this.skip(node); + return; + } + + _super.prototype.visitLabeledStatement.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitReturnStatement = function (node) { + if (this.checkForStatementInAmbientContxt(node)) { + this.skip(node); + return; + } + + _super.prototype.visitReturnStatement.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitSwitchStatement = function (node) { + if (this.checkForStatementInAmbientContxt(node)) { + this.skip(node); + return; + } + + _super.prototype.visitSwitchStatement.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitThrowStatement = function (node) { + if (this.checkForStatementInAmbientContxt(node)) { + this.skip(node); + return; + } + + _super.prototype.visitThrowStatement.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitTryStatement = function (node) { + if (this.checkForStatementInAmbientContxt(node)) { + this.skip(node); + return; + } + + _super.prototype.visitTryStatement.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitWhileStatement = function (node) { + if (this.checkForStatementInAmbientContxt(node)) { + this.skip(node); + return; + } + + _super.prototype.visitWhileStatement.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitWithStatement = function (node) { + if (this.checkForStatementInAmbientContxt(node)) { + this.skip(node); + return; + } + + _super.prototype.visitWithStatement.call(this, node); + }; + + GrammarCheckerWalker.prototype.checkForDisallowedModifiers = function (parent, modifiers) { + if (this.inBlock && modifiers.childCount() > 0) { + var modifierFullStart = this.childFullStart(parent, modifiers); + this.pushDiagnostic1(modifierFullStart, modifiers.childAt(0), TypeScript.DiagnosticCode.Modifiers_cannot_appear_here); + return true; + } + + return false; + }; + + GrammarCheckerWalker.prototype.visitFunctionDeclaration = function (node) { + if (this.checkForDisallowedDeclareModifier(node.modifiers) || this.checkForDisallowedModifiers(node, node.modifiers) || this.checkForRequiredDeclareModifier(node, node.functionKeyword, node.modifiers) || this.checkModuleElementModifiers(node.modifiers)) { + this.skip(node); + return; + } + + var savedInAmbientDeclaration = this.inAmbientDeclaration; + this.inAmbientDeclaration = this.inAmbientDeclaration || this.syntaxTree.isDeclaration() || TypeScript.SyntaxUtilities.containsToken(node.modifiers, 63 /* DeclareKeyword */); + _super.prototype.visitFunctionDeclaration.call(this, node); + this.inAmbientDeclaration = savedInAmbientDeclaration; + }; + + GrammarCheckerWalker.prototype.visitVariableStatement = function (node) { + if (this.checkForDisallowedDeclareModifier(node.modifiers) || this.checkForDisallowedModifiers(node, node.modifiers) || this.checkForRequiredDeclareModifier(node, node.variableDeclaration, node.modifiers) || this.checkModuleElementModifiers(node.modifiers)) { + this.skip(node); + return; + } + + var savedInAmbientDeclaration = this.inAmbientDeclaration; + this.inAmbientDeclaration = this.inAmbientDeclaration || this.syntaxTree.isDeclaration() || TypeScript.SyntaxUtilities.containsToken(node.modifiers, 63 /* DeclareKeyword */); + _super.prototype.visitVariableStatement.call(this, node); + this.inAmbientDeclaration = savedInAmbientDeclaration; + }; + + GrammarCheckerWalker.prototype.checkListSeparators = function (parent, list, kind) { + var currentElementFullStart = this.childFullStart(parent, list); + + for (var i = 0, n = list.childCount(); i < n; i++) { + var child = list.childAt(i); + if (i % 2 === 1 && child.kind() !== kind) { + this.pushDiagnostic1(currentElementFullStart, child, TypeScript.DiagnosticCode._0_expected, [TypeScript.SyntaxFacts.getText(kind)]); + } + + currentElementFullStart += child.fullWidth(); + } + + return false; + }; + + GrammarCheckerWalker.prototype.visitObjectType = function (node) { + if (this.checkListSeparators(node, node.typeMembers, 78 /* SemicolonToken */)) { + this.skip(node); + return; + } + + var savedInAmbientDeclaration = this.inAmbientDeclaration; + this.inAmbientDeclaration = true; + _super.prototype.visitObjectType.call(this, node); + this.inAmbientDeclaration = savedInAmbientDeclaration; + }; + + GrammarCheckerWalker.prototype.visitArrayType = function (node) { + var savedInAmbientDeclaration = this.inAmbientDeclaration; + this.inAmbientDeclaration = true; + _super.prototype.visitArrayType.call(this, node); + this.inAmbientDeclaration = savedInAmbientDeclaration; + }; + + GrammarCheckerWalker.prototype.visitFunctionType = function (node) { + var savedInAmbientDeclaration = this.inAmbientDeclaration; + this.inAmbientDeclaration = true; + _super.prototype.visitFunctionType.call(this, node); + this.inAmbientDeclaration = savedInAmbientDeclaration; + }; + + GrammarCheckerWalker.prototype.visitConstructorType = function (node) { + var savedInAmbientDeclaration = this.inAmbientDeclaration; + this.inAmbientDeclaration = true; + _super.prototype.visitConstructorType.call(this, node); + this.inAmbientDeclaration = savedInAmbientDeclaration; + }; + + GrammarCheckerWalker.prototype.visitVariableDeclarator = function (node) { + if (this.inAmbientDeclaration && node.equalsValueClause) { + this.pushDiagnostic1(this.childFullStart(node, node.equalsValueClause), node.equalsValueClause.firstToken(), TypeScript.DiagnosticCode.Initializers_are_not_allowed_in_ambient_contexts); + this.skip(node); + return; + } + + _super.prototype.visitVariableDeclarator.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitConstructorDeclaration = function (node) { + var savedCurrentConstructor = this.currentConstructor; + this.currentConstructor = node; + _super.prototype.visitConstructorDeclaration.call(this, node); + this.currentConstructor = savedCurrentConstructor; + }; + + GrammarCheckerWalker.prototype.visitSourceUnit = function (node) { + if (this.checkFunctionOverloads(node, node.moduleElements) || this.checkForDisallowedExports(node, node.moduleElements) || this.checkForMultipleExportAssignments(node, node.moduleElements)) { + this.skip(node); + return; + } + + _super.prototype.visitSourceUnit.call(this, node); + }; + return GrammarCheckerWalker; + })(TypeScript.PositionTrackingWalker); +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var TextSpanWalker = (function (_super) { + __extends(TextSpanWalker, _super); + function TextSpanWalker(textSpan) { + _super.call(this); + this.textSpan = textSpan; + this._position = 0; + } + TextSpanWalker.prototype.visitToken = function (token) { + this._position += token.fullWidth(); + }; + + TextSpanWalker.prototype.visitNode = function (node) { + var nodeSpan = new TypeScript.TextSpan(this.position(), node.fullWidth()); + + if (nodeSpan.intersectsWithTextSpan(this.textSpan)) { + node.accept(this); + } else { + this._position += node.fullWidth(); + } + }; + + TextSpanWalker.prototype.position = function () { + return this._position; + }; + return TextSpanWalker; + })(TypeScript.SyntaxWalker); +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var Unicode = (function () { + function Unicode() { + } + Unicode.lookupInUnicodeMap = function (code, map) { + if (code < map[0]) { + return false; + } + + var lo = 0; + var hi = map.length; + var mid; + + while (lo + 1 < hi) { + mid = lo + (hi - lo) / 2; + + mid -= mid % 2; + if (map[mid] <= code && code <= map[mid + 1]) { + return true; + } + + if (code < map[mid]) { + hi = mid; + } else { + lo = mid + 2; + } + } + + return false; + }; + + Unicode.isIdentifierStart = function (code, languageVersion) { + if (languageVersion === 0 /* EcmaScript3 */) { + return Unicode.lookupInUnicodeMap(code, Unicode.unicodeES3IdentifierStart); + } else if (languageVersion === 1 /* EcmaScript5 */) { + return Unicode.lookupInUnicodeMap(code, Unicode.unicodeES5IdentifierStart); + } else { + throw TypeScript.Errors.argumentOutOfRange("languageVersion"); + } + }; + + Unicode.isIdentifierPart = function (code, languageVersion) { + if (languageVersion === 0 /* EcmaScript3 */) { + return Unicode.lookupInUnicodeMap(code, Unicode.unicodeES3IdentifierPart); + } else if (languageVersion === 1 /* EcmaScript5 */) { + return Unicode.lookupInUnicodeMap(code, Unicode.unicodeES5IdentifierPart); + } else { + throw TypeScript.Errors.argumentOutOfRange("languageVersion"); + } + }; + Unicode.unicodeES3IdentifierStart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 543, 546, 563, 592, 685, 688, 696, 699, 705, 720, 721, 736, 740, 750, 750, 890, 890, 902, 902, 904, 906, 908, 908, 910, 929, 931, 974, 976, 983, 986, 1011, 1024, 1153, 1164, 1220, 1223, 1224, 1227, 1228, 1232, 1269, 1272, 1273, 1329, 1366, 1369, 1369, 1377, 1415, 1488, 1514, 1520, 1522, 1569, 1594, 1600, 1610, 1649, 1747, 1749, 1749, 1765, 1766, 1786, 1788, 1808, 1808, 1810, 1836, 1920, 1957, 2309, 2361, 2365, 2365, 2384, 2384, 2392, 2401, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2524, 2525, 2527, 2529, 2544, 2545, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2649, 2652, 2654, 2654, 2674, 2676, 2693, 2699, 2701, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2749, 2749, 2768, 2768, 2784, 2784, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2870, 2873, 2877, 2877, 2908, 2909, 2911, 2913, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 2997, 2999, 3001, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3168, 3169, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3294, 3294, 3296, 3297, 3333, 3340, 3342, 3344, 3346, 3368, 3370, 3385, 3424, 3425, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3585, 3632, 3634, 3635, 3648, 3654, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3760, 3762, 3763, 3773, 3773, 3776, 3780, 3782, 3782, 3804, 3805, 3840, 3840, 3904, 3911, 3913, 3946, 3976, 3979, 4096, 4129, 4131, 4135, 4137, 4138, 4176, 4181, 4256, 4293, 4304, 4342, 4352, 4441, 4447, 4514, 4520, 4601, 4608, 4614, 4616, 4678, 4680, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4742, 4744, 4744, 4746, 4749, 4752, 4782, 4784, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4814, 4816, 4822, 4824, 4846, 4848, 4878, 4880, 4880, 4882, 4885, 4888, 4894, 4896, 4934, 4936, 4954, 5024, 5108, 5121, 5740, 5743, 5750, 5761, 5786, 5792, 5866, 6016, 6067, 6176, 6263, 6272, 6312, 7680, 7835, 7840, 7929, 7936, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8319, 8319, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8497, 8499, 8505, 8544, 8579, 12293, 12295, 12321, 12329, 12337, 12341, 12344, 12346, 12353, 12436, 12445, 12446, 12449, 12538, 12540, 12542, 12549, 12588, 12593, 12686, 12704, 12727, 13312, 19893, 19968, 40869, 40960, 42124, 44032, 55203, 63744, 64045, 64256, 64262, 64275, 64279, 64285, 64285, 64287, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65136, 65138, 65140, 65140, 65142, 65276, 65313, 65338, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500]; + Unicode.unicodeES3IdentifierPart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 543, 546, 563, 592, 685, 688, 696, 699, 705, 720, 721, 736, 740, 750, 750, 768, 846, 864, 866, 890, 890, 902, 902, 904, 906, 908, 908, 910, 929, 931, 974, 976, 983, 986, 1011, 1024, 1153, 1155, 1158, 1164, 1220, 1223, 1224, 1227, 1228, 1232, 1269, 1272, 1273, 1329, 1366, 1369, 1369, 1377, 1415, 1425, 1441, 1443, 1465, 1467, 1469, 1471, 1471, 1473, 1474, 1476, 1476, 1488, 1514, 1520, 1522, 1569, 1594, 1600, 1621, 1632, 1641, 1648, 1747, 1749, 1756, 1759, 1768, 1770, 1773, 1776, 1788, 1808, 1836, 1840, 1866, 1920, 1968, 2305, 2307, 2309, 2361, 2364, 2381, 2384, 2388, 2392, 2403, 2406, 2415, 2433, 2435, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2492, 2492, 2494, 2500, 2503, 2504, 2507, 2509, 2519, 2519, 2524, 2525, 2527, 2531, 2534, 2545, 2562, 2562, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2620, 2620, 2622, 2626, 2631, 2632, 2635, 2637, 2649, 2652, 2654, 2654, 2662, 2676, 2689, 2691, 2693, 2699, 2701, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2748, 2757, 2759, 2761, 2763, 2765, 2768, 2768, 2784, 2784, 2790, 2799, 2817, 2819, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2870, 2873, 2876, 2883, 2887, 2888, 2891, 2893, 2902, 2903, 2908, 2909, 2911, 2913, 2918, 2927, 2946, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 2997, 2999, 3001, 3006, 3010, 3014, 3016, 3018, 3021, 3031, 3031, 3047, 3055, 3073, 3075, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3134, 3140, 3142, 3144, 3146, 3149, 3157, 3158, 3168, 3169, 3174, 3183, 3202, 3203, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3262, 3268, 3270, 3272, 3274, 3277, 3285, 3286, 3294, 3294, 3296, 3297, 3302, 3311, 3330, 3331, 3333, 3340, 3342, 3344, 3346, 3368, 3370, 3385, 3390, 3395, 3398, 3400, 3402, 3405, 3415, 3415, 3424, 3425, 3430, 3439, 3458, 3459, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3530, 3530, 3535, 3540, 3542, 3542, 3544, 3551, 3570, 3571, 3585, 3642, 3648, 3662, 3664, 3673, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3769, 3771, 3773, 3776, 3780, 3782, 3782, 3784, 3789, 3792, 3801, 3804, 3805, 3840, 3840, 3864, 3865, 3872, 3881, 3893, 3893, 3895, 3895, 3897, 3897, 3902, 3911, 3913, 3946, 3953, 3972, 3974, 3979, 3984, 3991, 3993, 4028, 4038, 4038, 4096, 4129, 4131, 4135, 4137, 4138, 4140, 4146, 4150, 4153, 4160, 4169, 4176, 4185, 4256, 4293, 4304, 4342, 4352, 4441, 4447, 4514, 4520, 4601, 4608, 4614, 4616, 4678, 4680, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4742, 4744, 4744, 4746, 4749, 4752, 4782, 4784, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4814, 4816, 4822, 4824, 4846, 4848, 4878, 4880, 4880, 4882, 4885, 4888, 4894, 4896, 4934, 4936, 4954, 4969, 4977, 5024, 5108, 5121, 5740, 5743, 5750, 5761, 5786, 5792, 5866, 6016, 6099, 6112, 6121, 6160, 6169, 6176, 6263, 6272, 6313, 7680, 7835, 7840, 7929, 7936, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8255, 8256, 8319, 8319, 8400, 8412, 8417, 8417, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8497, 8499, 8505, 8544, 8579, 12293, 12295, 12321, 12335, 12337, 12341, 12344, 12346, 12353, 12436, 12441, 12442, 12445, 12446, 12449, 12542, 12549, 12588, 12593, 12686, 12704, 12727, 13312, 19893, 19968, 40869, 40960, 42124, 44032, 55203, 63744, 64045, 64256, 64262, 64275, 64279, 64285, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65056, 65059, 65075, 65076, 65101, 65103, 65136, 65138, 65140, 65140, 65142, 65276, 65296, 65305, 65313, 65338, 65343, 65343, 65345, 65370, 65381, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500]; + + Unicode.unicodeES5IdentifierStart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 705, 710, 721, 736, 740, 748, 748, 750, 750, 880, 884, 886, 887, 890, 893, 902, 902, 904, 906, 908, 908, 910, 929, 931, 1013, 1015, 1153, 1162, 1319, 1329, 1366, 1369, 1369, 1377, 1415, 1488, 1514, 1520, 1522, 1568, 1610, 1646, 1647, 1649, 1747, 1749, 1749, 1765, 1766, 1774, 1775, 1786, 1788, 1791, 1791, 1808, 1808, 1810, 1839, 1869, 1957, 1969, 1969, 1994, 2026, 2036, 2037, 2042, 2042, 2048, 2069, 2074, 2074, 2084, 2084, 2088, 2088, 2112, 2136, 2208, 2208, 2210, 2220, 2308, 2361, 2365, 2365, 2384, 2384, 2392, 2401, 2417, 2423, 2425, 2431, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2493, 2493, 2510, 2510, 2524, 2525, 2527, 2529, 2544, 2545, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2649, 2652, 2654, 2654, 2674, 2676, 2693, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2749, 2749, 2768, 2768, 2784, 2785, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2869, 2873, 2877, 2877, 2908, 2909, 2911, 2913, 2929, 2929, 2947, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 3001, 3024, 3024, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3133, 3133, 3160, 3161, 3168, 3169, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3261, 3261, 3294, 3294, 3296, 3297, 3313, 3314, 3333, 3340, 3342, 3344, 3346, 3386, 3389, 3389, 3406, 3406, 3424, 3425, 3450, 3455, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3585, 3632, 3634, 3635, 3648, 3654, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3760, 3762, 3763, 3773, 3773, 3776, 3780, 3782, 3782, 3804, 3807, 3840, 3840, 3904, 3911, 3913, 3948, 3976, 3980, 4096, 4138, 4159, 4159, 4176, 4181, 4186, 4189, 4193, 4193, 4197, 4198, 4206, 4208, 4213, 4225, 4238, 4238, 4256, 4293, 4295, 4295, 4301, 4301, 4304, 4346, 4348, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4744, 4746, 4749, 4752, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4822, 4824, 4880, 4882, 4885, 4888, 4954, 4992, 5007, 5024, 5108, 5121, 5740, 5743, 5759, 5761, 5786, 5792, 5866, 5870, 5872, 5888, 5900, 5902, 5905, 5920, 5937, 5952, 5969, 5984, 5996, 5998, 6000, 6016, 6067, 6103, 6103, 6108, 6108, 6176, 6263, 6272, 6312, 6314, 6314, 6320, 6389, 6400, 6428, 6480, 6509, 6512, 6516, 6528, 6571, 6593, 6599, 6656, 6678, 6688, 6740, 6823, 6823, 6917, 6963, 6981, 6987, 7043, 7072, 7086, 7087, 7098, 7141, 7168, 7203, 7245, 7247, 7258, 7293, 7401, 7404, 7406, 7409, 7413, 7414, 7424, 7615, 7680, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8305, 8305, 8319, 8319, 8336, 8348, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8505, 8508, 8511, 8517, 8521, 8526, 8526, 8544, 8584, 11264, 11310, 11312, 11358, 11360, 11492, 11499, 11502, 11506, 11507, 11520, 11557, 11559, 11559, 11565, 11565, 11568, 11623, 11631, 11631, 11648, 11670, 11680, 11686, 11688, 11694, 11696, 11702, 11704, 11710, 11712, 11718, 11720, 11726, 11728, 11734, 11736, 11742, 11823, 11823, 12293, 12295, 12321, 12329, 12337, 12341, 12344, 12348, 12353, 12438, 12445, 12447, 12449, 12538, 12540, 12543, 12549, 12589, 12593, 12686, 12704, 12730, 12784, 12799, 13312, 19893, 19968, 40908, 40960, 42124, 42192, 42237, 42240, 42508, 42512, 42527, 42538, 42539, 42560, 42606, 42623, 42647, 42656, 42735, 42775, 42783, 42786, 42888, 42891, 42894, 42896, 42899, 42912, 42922, 43000, 43009, 43011, 43013, 43015, 43018, 43020, 43042, 43072, 43123, 43138, 43187, 43250, 43255, 43259, 43259, 43274, 43301, 43312, 43334, 43360, 43388, 43396, 43442, 43471, 43471, 43520, 43560, 43584, 43586, 43588, 43595, 43616, 43638, 43642, 43642, 43648, 43695, 43697, 43697, 43701, 43702, 43705, 43709, 43712, 43712, 43714, 43714, 43739, 43741, 43744, 43754, 43762, 43764, 43777, 43782, 43785, 43790, 43793, 43798, 43808, 43814, 43816, 43822, 43968, 44002, 44032, 55203, 55216, 55238, 55243, 55291, 63744, 64109, 64112, 64217, 64256, 64262, 64275, 64279, 64285, 64285, 64287, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65136, 65140, 65142, 65276, 65313, 65338, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500]; + Unicode.unicodeES5IdentifierPart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 705, 710, 721, 736, 740, 748, 748, 750, 750, 768, 884, 886, 887, 890, 893, 902, 902, 904, 906, 908, 908, 910, 929, 931, 1013, 1015, 1153, 1155, 1159, 1162, 1319, 1329, 1366, 1369, 1369, 1377, 1415, 1425, 1469, 1471, 1471, 1473, 1474, 1476, 1477, 1479, 1479, 1488, 1514, 1520, 1522, 1552, 1562, 1568, 1641, 1646, 1747, 1749, 1756, 1759, 1768, 1770, 1788, 1791, 1791, 1808, 1866, 1869, 1969, 1984, 2037, 2042, 2042, 2048, 2093, 2112, 2139, 2208, 2208, 2210, 2220, 2276, 2302, 2304, 2403, 2406, 2415, 2417, 2423, 2425, 2431, 2433, 2435, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2492, 2500, 2503, 2504, 2507, 2510, 2519, 2519, 2524, 2525, 2527, 2531, 2534, 2545, 2561, 2563, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2620, 2620, 2622, 2626, 2631, 2632, 2635, 2637, 2641, 2641, 2649, 2652, 2654, 2654, 2662, 2677, 2689, 2691, 2693, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2748, 2757, 2759, 2761, 2763, 2765, 2768, 2768, 2784, 2787, 2790, 2799, 2817, 2819, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2869, 2873, 2876, 2884, 2887, 2888, 2891, 2893, 2902, 2903, 2908, 2909, 2911, 2915, 2918, 2927, 2929, 2929, 2946, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 3001, 3006, 3010, 3014, 3016, 3018, 3021, 3024, 3024, 3031, 3031, 3046, 3055, 3073, 3075, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3133, 3140, 3142, 3144, 3146, 3149, 3157, 3158, 3160, 3161, 3168, 3171, 3174, 3183, 3202, 3203, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3260, 3268, 3270, 3272, 3274, 3277, 3285, 3286, 3294, 3294, 3296, 3299, 3302, 3311, 3313, 3314, 3330, 3331, 3333, 3340, 3342, 3344, 3346, 3386, 3389, 3396, 3398, 3400, 3402, 3406, 3415, 3415, 3424, 3427, 3430, 3439, 3450, 3455, 3458, 3459, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3530, 3530, 3535, 3540, 3542, 3542, 3544, 3551, 3570, 3571, 3585, 3642, 3648, 3662, 3664, 3673, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3769, 3771, 3773, 3776, 3780, 3782, 3782, 3784, 3789, 3792, 3801, 3804, 3807, 3840, 3840, 3864, 3865, 3872, 3881, 3893, 3893, 3895, 3895, 3897, 3897, 3902, 3911, 3913, 3948, 3953, 3972, 3974, 3991, 3993, 4028, 4038, 4038, 4096, 4169, 4176, 4253, 4256, 4293, 4295, 4295, 4301, 4301, 4304, 4346, 4348, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4744, 4746, 4749, 4752, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4822, 4824, 4880, 4882, 4885, 4888, 4954, 4957, 4959, 4992, 5007, 5024, 5108, 5121, 5740, 5743, 5759, 5761, 5786, 5792, 5866, 5870, 5872, 5888, 5900, 5902, 5908, 5920, 5940, 5952, 5971, 5984, 5996, 5998, 6000, 6002, 6003, 6016, 6099, 6103, 6103, 6108, 6109, 6112, 6121, 6155, 6157, 6160, 6169, 6176, 6263, 6272, 6314, 6320, 6389, 6400, 6428, 6432, 6443, 6448, 6459, 6470, 6509, 6512, 6516, 6528, 6571, 6576, 6601, 6608, 6617, 6656, 6683, 6688, 6750, 6752, 6780, 6783, 6793, 6800, 6809, 6823, 6823, 6912, 6987, 6992, 7001, 7019, 7027, 7040, 7155, 7168, 7223, 7232, 7241, 7245, 7293, 7376, 7378, 7380, 7414, 7424, 7654, 7676, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8204, 8205, 8255, 8256, 8276, 8276, 8305, 8305, 8319, 8319, 8336, 8348, 8400, 8412, 8417, 8417, 8421, 8432, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8505, 8508, 8511, 8517, 8521, 8526, 8526, 8544, 8584, 11264, 11310, 11312, 11358, 11360, 11492, 11499, 11507, 11520, 11557, 11559, 11559, 11565, 11565, 11568, 11623, 11631, 11631, 11647, 11670, 11680, 11686, 11688, 11694, 11696, 11702, 11704, 11710, 11712, 11718, 11720, 11726, 11728, 11734, 11736, 11742, 11744, 11775, 11823, 11823, 12293, 12295, 12321, 12335, 12337, 12341, 12344, 12348, 12353, 12438, 12441, 12442, 12445, 12447, 12449, 12538, 12540, 12543, 12549, 12589, 12593, 12686, 12704, 12730, 12784, 12799, 13312, 19893, 19968, 40908, 40960, 42124, 42192, 42237, 42240, 42508, 42512, 42539, 42560, 42607, 42612, 42621, 42623, 42647, 42655, 42737, 42775, 42783, 42786, 42888, 42891, 42894, 42896, 42899, 42912, 42922, 43000, 43047, 43072, 43123, 43136, 43204, 43216, 43225, 43232, 43255, 43259, 43259, 43264, 43309, 43312, 43347, 43360, 43388, 43392, 43456, 43471, 43481, 43520, 43574, 43584, 43597, 43600, 43609, 43616, 43638, 43642, 43643, 43648, 43714, 43739, 43741, 43744, 43759, 43762, 43766, 43777, 43782, 43785, 43790, 43793, 43798, 43808, 43814, 43816, 43822, 43968, 44010, 44012, 44013, 44016, 44025, 44032, 55203, 55216, 55238, 55243, 55291, 63744, 64109, 64112, 64217, 64256, 64262, 64275, 64279, 64285, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65024, 65039, 65056, 65062, 65075, 65076, 65101, 65103, 65136, 65140, 65142, 65276, 65296, 65305, 65313, 65338, 65343, 65343, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500]; + return Unicode; + })(); + TypeScript.Unicode = Unicode; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (CompilerDiagnostics) { + CompilerDiagnostics.debug = false; + + CompilerDiagnostics.diagnosticWriter = null; + + CompilerDiagnostics.analysisPass = 0; + + function Alert(output) { + if (CompilerDiagnostics.diagnosticWriter) { + CompilerDiagnostics.diagnosticWriter.Alert(output); + } + } + CompilerDiagnostics.Alert = Alert; + + function debugPrint(s) { + if (CompilerDiagnostics.debug) { + Alert(s); + } + } + CompilerDiagnostics.debugPrint = debugPrint; + + function assert(condition, s) { + if (CompilerDiagnostics.debug) { + if (!condition) { + Alert(s); + } + } + } + CompilerDiagnostics.assert = assert; + })(TypeScript.CompilerDiagnostics || (TypeScript.CompilerDiagnostics = {})); + var CompilerDiagnostics = TypeScript.CompilerDiagnostics; + + var NullLogger = (function () { + function NullLogger() { + } + NullLogger.prototype.information = function () { + return false; + }; + NullLogger.prototype.debug = function () { + return false; + }; + NullLogger.prototype.warning = function () { + return false; + }; + NullLogger.prototype.error = function () { + return false; + }; + NullLogger.prototype.fatal = function () { + return false; + }; + NullLogger.prototype.log = function (s) { + }; + return NullLogger; + })(); + TypeScript.NullLogger = NullLogger; + + function timeFunction(logger, funcDescription, func) { + var start = (new Date()).getTime(); + var result = func(); + var end = (new Date()).getTime(); + logger.log(funcDescription + " completed in " + (end - start) + " msec"); + return result; + } + TypeScript.timeFunction = timeFunction; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + function hasFlag(val, flag) { + return (val & flag) !== 0; + } + TypeScript.hasFlag = hasFlag; + + function withoutFlag(val, flag) { + return val & ~flag; + } + TypeScript.withoutFlag = withoutFlag; + + (function (ASTFlags) { + ASTFlags[ASTFlags["None"] = 0] = "None"; + ASTFlags[ASTFlags["SingleLine"] = 1 << 1] = "SingleLine"; + ASTFlags[ASTFlags["OptionalName"] = 1 << 2] = "OptionalName"; + ASTFlags[ASTFlags["TypeReference"] = 1 << 3] = "TypeReference"; + ASTFlags[ASTFlags["EnumElement"] = 1 << 4] = "EnumElement"; + })(TypeScript.ASTFlags || (TypeScript.ASTFlags = {})); + var ASTFlags = TypeScript.ASTFlags; + + (function (DeclFlags) { + DeclFlags[DeclFlags["None"] = 0] = "None"; + DeclFlags[DeclFlags["Exported"] = 1] = "Exported"; + DeclFlags[DeclFlags["Private"] = 1 << 1] = "Private"; + DeclFlags[DeclFlags["Public"] = 1 << 2] = "Public"; + DeclFlags[DeclFlags["Ambient"] = 1 << 3] = "Ambient"; + DeclFlags[DeclFlags["Static"] = 1 << 4] = "Static"; + })(TypeScript.DeclFlags || (TypeScript.DeclFlags = {})); + var DeclFlags = TypeScript.DeclFlags; + + (function (ModuleFlags) { + ModuleFlags[ModuleFlags["None"] = 0] = "None"; + ModuleFlags[ModuleFlags["Exported"] = 1] = "Exported"; + ModuleFlags[ModuleFlags["Private"] = 1 << 1] = "Private"; + ModuleFlags[ModuleFlags["Public"] = 1 << 2] = "Public"; + ModuleFlags[ModuleFlags["Ambient"] = 1 << 3] = "Ambient"; + ModuleFlags[ModuleFlags["Static"] = 1 << 4] = "Static"; + ModuleFlags[ModuleFlags["IsEnum"] = 1 << 7] = "IsEnum"; + ModuleFlags[ModuleFlags["IsWholeFile"] = 1 << 8] = "IsWholeFile"; + ModuleFlags[ModuleFlags["IsDynamic"] = 1 << 9] = "IsDynamic"; + })(TypeScript.ModuleFlags || (TypeScript.ModuleFlags = {})); + var ModuleFlags = TypeScript.ModuleFlags; + + (function (VariableFlags) { + VariableFlags[VariableFlags["None"] = 0] = "None"; + VariableFlags[VariableFlags["Exported"] = 1] = "Exported"; + VariableFlags[VariableFlags["Private"] = 1 << 1] = "Private"; + VariableFlags[VariableFlags["Public"] = 1 << 2] = "Public"; + VariableFlags[VariableFlags["Ambient"] = 1 << 3] = "Ambient"; + VariableFlags[VariableFlags["Static"] = 1 << 4] = "Static"; + VariableFlags[VariableFlags["Property"] = 1 << 8] = "Property"; + VariableFlags[VariableFlags["ClassProperty"] = 1 << 11] = "ClassProperty"; + VariableFlags[VariableFlags["EnumElement"] = 1 << 13] = "EnumElement"; + VariableFlags[VariableFlags["ForInVariable"] = 1 << 14] = "ForInVariable"; + })(TypeScript.VariableFlags || (TypeScript.VariableFlags = {})); + var VariableFlags = TypeScript.VariableFlags; + + (function (FunctionFlags) { + FunctionFlags[FunctionFlags["None"] = 0] = "None"; + FunctionFlags[FunctionFlags["Exported"] = 1] = "Exported"; + FunctionFlags[FunctionFlags["Private"] = 1 << 1] = "Private"; + FunctionFlags[FunctionFlags["Public"] = 1 << 2] = "Public"; + FunctionFlags[FunctionFlags["Ambient"] = 1 << 3] = "Ambient"; + FunctionFlags[FunctionFlags["Static"] = 1 << 4] = "Static"; + FunctionFlags[FunctionFlags["GetAccessor"] = 1 << 5] = "GetAccessor"; + FunctionFlags[FunctionFlags["SetAccessor"] = 1 << 6] = "SetAccessor"; + FunctionFlags[FunctionFlags["Signature"] = 1 << 7] = "Signature"; + FunctionFlags[FunctionFlags["Method"] = 1 << 8] = "Method"; + FunctionFlags[FunctionFlags["CallMember"] = 1 << 9] = "CallMember"; + FunctionFlags[FunctionFlags["ConstructMember"] = 1 << 10] = "ConstructMember"; + FunctionFlags[FunctionFlags["IsFatArrowFunction"] = 1 << 11] = "IsFatArrowFunction"; + FunctionFlags[FunctionFlags["IndexerMember"] = 1 << 12] = "IndexerMember"; + FunctionFlags[FunctionFlags["IsFunctionExpression"] = 1 << 13] = "IsFunctionExpression"; + FunctionFlags[FunctionFlags["IsFunctionProperty"] = 1 << 14] = "IsFunctionProperty"; + })(TypeScript.FunctionFlags || (TypeScript.FunctionFlags = {})); + var FunctionFlags = TypeScript.FunctionFlags; + + function ToDeclFlags(fncOrVarOrModuleFlags) { + return fncOrVarOrModuleFlags; + } + TypeScript.ToDeclFlags = ToDeclFlags; + + (function (TypeRelationshipFlags) { + TypeRelationshipFlags[TypeRelationshipFlags["SuccessfulComparison"] = 0] = "SuccessfulComparison"; + TypeRelationshipFlags[TypeRelationshipFlags["RequiredPropertyIsMissing"] = 1 << 1] = "RequiredPropertyIsMissing"; + TypeRelationshipFlags[TypeRelationshipFlags["IncompatibleSignatures"] = 1 << 2] = "IncompatibleSignatures"; + TypeRelationshipFlags[TypeRelationshipFlags["SourceSignatureHasTooManyParameters"] = 3] = "SourceSignatureHasTooManyParameters"; + TypeRelationshipFlags[TypeRelationshipFlags["IncompatibleReturnTypes"] = 1 << 4] = "IncompatibleReturnTypes"; + TypeRelationshipFlags[TypeRelationshipFlags["IncompatiblePropertyTypes"] = 1 << 5] = "IncompatiblePropertyTypes"; + TypeRelationshipFlags[TypeRelationshipFlags["IncompatibleParameterTypes"] = 1 << 6] = "IncompatibleParameterTypes"; + TypeRelationshipFlags[TypeRelationshipFlags["InconsistantPropertyAccesibility"] = 1 << 7] = "InconsistantPropertyAccesibility"; + })(TypeScript.TypeRelationshipFlags || (TypeScript.TypeRelationshipFlags = {})); + var TypeRelationshipFlags = TypeScript.TypeRelationshipFlags; + + (function (ModuleGenTarget) { + ModuleGenTarget[ModuleGenTarget["Unspecified"] = 0] = "Unspecified"; + ModuleGenTarget[ModuleGenTarget["Synchronous"] = 1] = "Synchronous"; + ModuleGenTarget[ModuleGenTarget["Asynchronous"] = 2] = "Asynchronous"; + })(TypeScript.ModuleGenTarget || (TypeScript.ModuleGenTarget = {})); + var ModuleGenTarget = TypeScript.ModuleGenTarget; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (NodeType) { + NodeType[NodeType["None"] = 0] = "None"; + NodeType[NodeType["List"] = 1] = "List"; + NodeType[NodeType["Script"] = 2] = "Script"; + + NodeType[NodeType["TrueLiteral"] = 3] = "TrueLiteral"; + NodeType[NodeType["FalseLiteral"] = 4] = "FalseLiteral"; + NodeType[NodeType["StringLiteral"] = 5] = "StringLiteral"; + NodeType[NodeType["RegularExpressionLiteral"] = 6] = "RegularExpressionLiteral"; + NodeType[NodeType["NumericLiteral"] = 7] = "NumericLiteral"; + NodeType[NodeType["NullLiteral"] = 8] = "NullLiteral"; + + NodeType[NodeType["TypeParameter"] = 9] = "TypeParameter"; + NodeType[NodeType["GenericType"] = 10] = "GenericType"; + NodeType[NodeType["TypeRef"] = 11] = "TypeRef"; + NodeType[NodeType["TypeQuery"] = 12] = "TypeQuery"; + + NodeType[NodeType["FunctionDeclaration"] = 13] = "FunctionDeclaration"; + NodeType[NodeType["ClassDeclaration"] = 14] = "ClassDeclaration"; + NodeType[NodeType["InterfaceDeclaration"] = 15] = "InterfaceDeclaration"; + NodeType[NodeType["ModuleDeclaration"] = 16] = "ModuleDeclaration"; + NodeType[NodeType["ImportDeclaration"] = 17] = "ImportDeclaration"; + NodeType[NodeType["VariableDeclarator"] = 18] = "VariableDeclarator"; + NodeType[NodeType["VariableDeclaration"] = 19] = "VariableDeclaration"; + NodeType[NodeType["Parameter"] = 20] = "Parameter"; + + NodeType[NodeType["Name"] = 21] = "Name"; + NodeType[NodeType["ArrayLiteralExpression"] = 22] = "ArrayLiteralExpression"; + NodeType[NodeType["ObjectLiteralExpression"] = 23] = "ObjectLiteralExpression"; + NodeType[NodeType["OmittedExpression"] = 24] = "OmittedExpression"; + NodeType[NodeType["VoidExpression"] = 25] = "VoidExpression"; + NodeType[NodeType["CommaExpression"] = 26] = "CommaExpression"; + NodeType[NodeType["PlusExpression"] = 27] = "PlusExpression"; + NodeType[NodeType["NegateExpression"] = 28] = "NegateExpression"; + NodeType[NodeType["DeleteExpression"] = 29] = "DeleteExpression"; + NodeType[NodeType["ThisExpression"] = 30] = "ThisExpression"; + NodeType[NodeType["SuperExpression"] = 31] = "SuperExpression"; + NodeType[NodeType["InExpression"] = 32] = "InExpression"; + NodeType[NodeType["MemberAccessExpression"] = 33] = "MemberAccessExpression"; + NodeType[NodeType["InstanceOfExpression"] = 34] = "InstanceOfExpression"; + NodeType[NodeType["TypeOfExpression"] = 35] = "TypeOfExpression"; + NodeType[NodeType["ElementAccessExpression"] = 36] = "ElementAccessExpression"; + NodeType[NodeType["InvocationExpression"] = 37] = "InvocationExpression"; + NodeType[NodeType["ObjectCreationExpression"] = 38] = "ObjectCreationExpression"; + NodeType[NodeType["AssignmentExpression"] = 39] = "AssignmentExpression"; + NodeType[NodeType["AddAssignmentExpression"] = 40] = "AddAssignmentExpression"; + NodeType[NodeType["SubtractAssignmentExpression"] = 41] = "SubtractAssignmentExpression"; + NodeType[NodeType["DivideAssignmentExpression"] = 42] = "DivideAssignmentExpression"; + NodeType[NodeType["MultiplyAssignmentExpression"] = 43] = "MultiplyAssignmentExpression"; + NodeType[NodeType["ModuloAssignmentExpression"] = 44] = "ModuloAssignmentExpression"; + NodeType[NodeType["AndAssignmentExpression"] = 45] = "AndAssignmentExpression"; + NodeType[NodeType["ExclusiveOrAssignmentExpression"] = 46] = "ExclusiveOrAssignmentExpression"; + NodeType[NodeType["OrAssignmentExpression"] = 47] = "OrAssignmentExpression"; + NodeType[NodeType["LeftShiftAssignmentExpression"] = 48] = "LeftShiftAssignmentExpression"; + NodeType[NodeType["SignedRightShiftAssignmentExpression"] = 49] = "SignedRightShiftAssignmentExpression"; + NodeType[NodeType["UnsignedRightShiftAssignmentExpression"] = 50] = "UnsignedRightShiftAssignmentExpression"; + NodeType[NodeType["ConditionalExpression"] = 51] = "ConditionalExpression"; + NodeType[NodeType["LogicalOrExpression"] = 52] = "LogicalOrExpression"; + NodeType[NodeType["LogicalAndExpression"] = 53] = "LogicalAndExpression"; + NodeType[NodeType["BitwiseOrExpression"] = 54] = "BitwiseOrExpression"; + NodeType[NodeType["BitwiseExclusiveOrExpression"] = 55] = "BitwiseExclusiveOrExpression"; + NodeType[NodeType["BitwiseAndExpression"] = 56] = "BitwiseAndExpression"; + NodeType[NodeType["EqualsWithTypeConversionExpression"] = 57] = "EqualsWithTypeConversionExpression"; + NodeType[NodeType["NotEqualsWithTypeConversionExpression"] = 58] = "NotEqualsWithTypeConversionExpression"; + NodeType[NodeType["EqualsExpression"] = 59] = "EqualsExpression"; + NodeType[NodeType["NotEqualsExpression"] = 60] = "NotEqualsExpression"; + NodeType[NodeType["LessThanExpression"] = 61] = "LessThanExpression"; + NodeType[NodeType["LessThanOrEqualExpression"] = 62] = "LessThanOrEqualExpression"; + NodeType[NodeType["GreaterThanExpression"] = 63] = "GreaterThanExpression"; + NodeType[NodeType["GreaterThanOrEqualExpression"] = 64] = "GreaterThanOrEqualExpression"; + NodeType[NodeType["AddExpression"] = 65] = "AddExpression"; + NodeType[NodeType["SubtractExpression"] = 66] = "SubtractExpression"; + NodeType[NodeType["MultiplyExpression"] = 67] = "MultiplyExpression"; + NodeType[NodeType["DivideExpression"] = 68] = "DivideExpression"; + NodeType[NodeType["ModuloExpression"] = 69] = "ModuloExpression"; + NodeType[NodeType["LeftShiftExpression"] = 70] = "LeftShiftExpression"; + NodeType[NodeType["SignedRightShiftExpression"] = 71] = "SignedRightShiftExpression"; + NodeType[NodeType["UnsignedRightShiftExpression"] = 72] = "UnsignedRightShiftExpression"; + NodeType[NodeType["BitwiseNotExpression"] = 73] = "BitwiseNotExpression"; + NodeType[NodeType["LogicalNotExpression"] = 74] = "LogicalNotExpression"; + NodeType[NodeType["PreIncrementExpression"] = 75] = "PreIncrementExpression"; + NodeType[NodeType["PreDecrementExpression"] = 76] = "PreDecrementExpression"; + NodeType[NodeType["PostIncrementExpression"] = 77] = "PostIncrementExpression"; + NodeType[NodeType["PostDecrementExpression"] = 78] = "PostDecrementExpression"; + NodeType[NodeType["CastExpression"] = 79] = "CastExpression"; + NodeType[NodeType["ParenthesizedExpression"] = 80] = "ParenthesizedExpression"; + NodeType[NodeType["Member"] = 81] = "Member"; + + NodeType[NodeType["Block"] = 82] = "Block"; + NodeType[NodeType["BreakStatement"] = 83] = "BreakStatement"; + NodeType[NodeType["ContinueStatement"] = 84] = "ContinueStatement"; + NodeType[NodeType["DebuggerStatement"] = 85] = "DebuggerStatement"; + NodeType[NodeType["DoStatement"] = 86] = "DoStatement"; + NodeType[NodeType["EmptyStatement"] = 87] = "EmptyStatement"; + NodeType[NodeType["ExportAssignment"] = 88] = "ExportAssignment"; + NodeType[NodeType["ExpressionStatement"] = 89] = "ExpressionStatement"; + NodeType[NodeType["ForInStatement"] = 90] = "ForInStatement"; + NodeType[NodeType["ForStatement"] = 91] = "ForStatement"; + NodeType[NodeType["IfStatement"] = 92] = "IfStatement"; + NodeType[NodeType["LabeledStatement"] = 93] = "LabeledStatement"; + NodeType[NodeType["ReturnStatement"] = 94] = "ReturnStatement"; + NodeType[NodeType["SwitchStatement"] = 95] = "SwitchStatement"; + NodeType[NodeType["ThrowStatement"] = 96] = "ThrowStatement"; + NodeType[NodeType["TryStatement"] = 97] = "TryStatement"; + NodeType[NodeType["VariableStatement"] = 98] = "VariableStatement"; + NodeType[NodeType["WhileStatement"] = 99] = "WhileStatement"; + NodeType[NodeType["WithStatement"] = 100] = "WithStatement"; + + NodeType[NodeType["CaseClause"] = 101] = "CaseClause"; + NodeType[NodeType["CatchClause"] = 102] = "CatchClause"; + + NodeType[NodeType["Comment"] = 103] = "Comment"; + })(TypeScript.NodeType || (TypeScript.NodeType = {})); + var NodeType = TypeScript.NodeType; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var BlockIntrinsics = (function () { + function BlockIntrinsics() { + this.prototype = undefined; + this.toString = undefined; + this.toLocaleString = undefined; + this.valueOf = undefined; + this.hasOwnProperty = undefined; + this.propertyIsEnumerable = undefined; + this.isPrototypeOf = undefined; + this["constructor"] = undefined; + } + return BlockIntrinsics; + })(); + TypeScript.BlockIntrinsics = BlockIntrinsics; + + var StringHashTable = (function () { + function StringHashTable() { + this.itemCount = 0; + this.table = (new BlockIntrinsics()); + } + StringHashTable.prototype.getAllKeys = function () { + var result = []; + + for (var k in this.table) { + if (this.table[k] !== undefined) { + result.push(k); + } + } + + return result; + }; + + StringHashTable.prototype.add = function (key, data) { + if (this.table[key] !== undefined) { + return false; + } + + this.table[key] = data; + this.itemCount++; + return true; + }; + + StringHashTable.prototype.addOrUpdate = function (key, data) { + if (this.table[key] !== undefined) { + this.table[key] = data; + return false; + } + + this.table[key] = data; + this.itemCount++; + return true; + }; + + StringHashTable.prototype.map = function (fn, context) { + for (var k in this.table) { + var data = this.table[k]; + + if (data !== undefined) { + fn(k, this.table[k], context); + } + } + }; + + StringHashTable.prototype.every = function (fn, context) { + 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; + }; + + StringHashTable.prototype.some = function (fn, context) { + 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; + }; + + StringHashTable.prototype.count = function () { + return this.itemCount; + }; + + StringHashTable.prototype.lookup = function (key) { + var data = this.table[key]; + return data === undefined ? null : data; + }; + return StringHashTable; + })(); + TypeScript.StringHashTable = StringHashTable; + + var IdentiferNameHashTable = (function (_super) { + __extends(IdentiferNameHashTable, _super); + function IdentiferNameHashTable() { + _super.apply(this, arguments); + } + IdentiferNameHashTable.prototype.getAllKeys = function () { + var result = []; + + _super.prototype.map.call(this, function (k, v, c) { + if (v !== undefined) { + result.push(k.substring(1)); + } + }, null); + + return result; + }; + + IdentiferNameHashTable.prototype.add = function (key, data) { + return _super.prototype.add.call(this, "#" + key, data); + }; + + IdentiferNameHashTable.prototype.addOrUpdate = function (key, data) { + return _super.prototype.addOrUpdate.call(this, "#" + key, data); + }; + + IdentiferNameHashTable.prototype.map = function (fn, context) { + return _super.prototype.map.call(this, function (k, v, c) { + return fn(k.substring(1), v, c); + }, context); + }; + + IdentiferNameHashTable.prototype.every = function (fn, context) { + return _super.prototype.every.call(this, function (k, v, c) { + return fn(k.substring(1), v, c); + }, context); + }; + + IdentiferNameHashTable.prototype.some = function (fn, context) { + return _super.prototype.some.call(this, function (k, v, c) { + return fn(k.substring(1), v, c); + }, context); + }; + + IdentiferNameHashTable.prototype.lookup = function (key) { + return _super.prototype.lookup.call(this, "#" + key); + }; + return IdentiferNameHashTable; + })(StringHashTable); + TypeScript.IdentiferNameHashTable = IdentiferNameHashTable; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var AstWalkOptions = (function () { + function AstWalkOptions() { + this.goChildren = true; + } + return AstWalkOptions; + })(); + TypeScript.AstWalkOptions = AstWalkOptions; + + var AstWalker = (function () { + function AstWalker(childrenWalkers, pre, post, options, state) { + this.childrenWalkers = childrenWalkers; + this.pre = pre; + this.post = post; + this.options = options; + this.state = state; + } + AstWalker.prototype.walk = function (ast, parent) { + var preAst = this.pre(ast, parent, this); + if (preAst === undefined) { + preAst = ast; + } + if (this.options.goChildren) { + this.childrenWalkers[ast.nodeType()](ast, parent, this); + } else { + this.options.goChildren = true; + } + + if (this.post) { + var postAst = this.post(preAst, parent, this); + if (postAst === undefined) { + postAst = preAst; + } + return postAst; + } else { + return preAst; + } + }; + return AstWalker; + })(); + + var AstWalkerFactory = (function () { + function AstWalkerFactory() { + this.childrenWalkers = []; + this.initChildrenWalkers(); + } + AstWalkerFactory.prototype.walk = function (ast, pre, post, options, state) { + return this.getWalker(pre, post, options, state).walk(ast, null); + }; + + AstWalkerFactory.prototype.getWalker = function (pre, post, options, state) { + return this.getSlowWalker(pre, post, options, state); + }; + + AstWalkerFactory.prototype.getSlowWalker = function (pre, post, options, state) { + if (!options) { + options = new AstWalkOptions(); + } + + return new AstWalker(this.childrenWalkers, pre, post, options, state); + }; + + AstWalkerFactory.prototype.initChildrenWalkers = function () { + this.childrenWalkers[0 /* None */] = ChildrenWalkers.walkNone; + this.childrenWalkers[87 /* EmptyStatement */] = ChildrenWalkers.walkNone; + this.childrenWalkers[24 /* OmittedExpression */] = ChildrenWalkers.walkNone; + this.childrenWalkers[3 /* TrueLiteral */] = ChildrenWalkers.walkNone; + this.childrenWalkers[4 /* FalseLiteral */] = ChildrenWalkers.walkNone; + this.childrenWalkers[30 /* ThisExpression */] = ChildrenWalkers.walkNone; + this.childrenWalkers[31 /* SuperExpression */] = ChildrenWalkers.walkNone; + this.childrenWalkers[5 /* StringLiteral */] = ChildrenWalkers.walkNone; + this.childrenWalkers[6 /* RegularExpressionLiteral */] = ChildrenWalkers.walkNone; + this.childrenWalkers[8 /* NullLiteral */] = ChildrenWalkers.walkNone; + this.childrenWalkers[22 /* ArrayLiteralExpression */] = ChildrenWalkers.walkUnaryExpressionChildren; + this.childrenWalkers[23 /* ObjectLiteralExpression */] = ChildrenWalkers.walkUnaryExpressionChildren; + this.childrenWalkers[25 /* VoidExpression */] = ChildrenWalkers.walkUnaryExpressionChildren; + this.childrenWalkers[26 /* CommaExpression */] = ChildrenWalkers.walkBinaryExpressionChildren; + this.childrenWalkers[27 /* PlusExpression */] = ChildrenWalkers.walkUnaryExpressionChildren; + this.childrenWalkers[28 /* NegateExpression */] = ChildrenWalkers.walkUnaryExpressionChildren; + this.childrenWalkers[29 /* DeleteExpression */] = ChildrenWalkers.walkUnaryExpressionChildren; + this.childrenWalkers[32 /* InExpression */] = ChildrenWalkers.walkBinaryExpressionChildren; + this.childrenWalkers[33 /* MemberAccessExpression */] = ChildrenWalkers.walkBinaryExpressionChildren; + this.childrenWalkers[34 /* InstanceOfExpression */] = ChildrenWalkers.walkBinaryExpressionChildren; + this.childrenWalkers[35 /* TypeOfExpression */] = ChildrenWalkers.walkUnaryExpressionChildren; + this.childrenWalkers[7 /* NumericLiteral */] = ChildrenWalkers.walkNone; + this.childrenWalkers[21 /* Name */] = ChildrenWalkers.walkNone; + this.childrenWalkers[9 /* TypeParameter */] = ChildrenWalkers.walkTypeParameterChildren; + this.childrenWalkers[10 /* GenericType */] = ChildrenWalkers.walkGenericTypeChildren; + this.childrenWalkers[11 /* TypeRef */] = ChildrenWalkers.walkTypeReferenceChildren; + this.childrenWalkers[12 /* TypeQuery */] = ChildrenWalkers.walkTypeQueryChildren; + this.childrenWalkers[36 /* ElementAccessExpression */] = ChildrenWalkers.walkBinaryExpressionChildren; + this.childrenWalkers[37 /* InvocationExpression */] = ChildrenWalkers.walkInvocationExpressionChildren; + this.childrenWalkers[38 /* ObjectCreationExpression */] = ChildrenWalkers.walkObjectCreationExpressionChildren; + this.childrenWalkers[39 /* AssignmentExpression */] = ChildrenWalkers.walkBinaryExpressionChildren; + this.childrenWalkers[40 /* AddAssignmentExpression */] = ChildrenWalkers.walkBinaryExpressionChildren; + this.childrenWalkers[41 /* SubtractAssignmentExpression */] = ChildrenWalkers.walkBinaryExpressionChildren; + this.childrenWalkers[42 /* DivideAssignmentExpression */] = ChildrenWalkers.walkBinaryExpressionChildren; + this.childrenWalkers[43 /* MultiplyAssignmentExpression */] = ChildrenWalkers.walkBinaryExpressionChildren; + this.childrenWalkers[44 /* ModuloAssignmentExpression */] = ChildrenWalkers.walkBinaryExpressionChildren; + this.childrenWalkers[45 /* AndAssignmentExpression */] = ChildrenWalkers.walkBinaryExpressionChildren; + this.childrenWalkers[46 /* ExclusiveOrAssignmentExpression */] = ChildrenWalkers.walkBinaryExpressionChildren; + this.childrenWalkers[47 /* OrAssignmentExpression */] = ChildrenWalkers.walkBinaryExpressionChildren; + this.childrenWalkers[48 /* LeftShiftAssignmentExpression */] = ChildrenWalkers.walkBinaryExpressionChildren; + this.childrenWalkers[49 /* SignedRightShiftAssignmentExpression */] = ChildrenWalkers.walkBinaryExpressionChildren; + this.childrenWalkers[50 /* UnsignedRightShiftAssignmentExpression */] = ChildrenWalkers.walkBinaryExpressionChildren; + this.childrenWalkers[51 /* ConditionalExpression */] = ChildrenWalkers.walkTrinaryExpressionChildren; + this.childrenWalkers[52 /* LogicalOrExpression */] = ChildrenWalkers.walkBinaryExpressionChildren; + this.childrenWalkers[53 /* LogicalAndExpression */] = ChildrenWalkers.walkBinaryExpressionChildren; + this.childrenWalkers[54 /* BitwiseOrExpression */] = ChildrenWalkers.walkBinaryExpressionChildren; + this.childrenWalkers[55 /* BitwiseExclusiveOrExpression */] = ChildrenWalkers.walkBinaryExpressionChildren; + this.childrenWalkers[56 /* BitwiseAndExpression */] = ChildrenWalkers.walkBinaryExpressionChildren; + this.childrenWalkers[57 /* EqualsWithTypeConversionExpression */] = ChildrenWalkers.walkBinaryExpressionChildren; + this.childrenWalkers[58 /* NotEqualsWithTypeConversionExpression */] = ChildrenWalkers.walkBinaryExpressionChildren; + this.childrenWalkers[59 /* EqualsExpression */] = ChildrenWalkers.walkBinaryExpressionChildren; + this.childrenWalkers[60 /* NotEqualsExpression */] = ChildrenWalkers.walkBinaryExpressionChildren; + this.childrenWalkers[61 /* LessThanExpression */] = ChildrenWalkers.walkBinaryExpressionChildren; + this.childrenWalkers[62 /* LessThanOrEqualExpression */] = ChildrenWalkers.walkBinaryExpressionChildren; + this.childrenWalkers[63 /* GreaterThanExpression */] = ChildrenWalkers.walkBinaryExpressionChildren; + this.childrenWalkers[64 /* GreaterThanOrEqualExpression */] = ChildrenWalkers.walkBinaryExpressionChildren; + this.childrenWalkers[65 /* AddExpression */] = ChildrenWalkers.walkBinaryExpressionChildren; + this.childrenWalkers[66 /* SubtractExpression */] = ChildrenWalkers.walkBinaryExpressionChildren; + this.childrenWalkers[67 /* MultiplyExpression */] = ChildrenWalkers.walkBinaryExpressionChildren; + this.childrenWalkers[68 /* DivideExpression */] = ChildrenWalkers.walkBinaryExpressionChildren; + this.childrenWalkers[69 /* ModuloExpression */] = ChildrenWalkers.walkBinaryExpressionChildren; + this.childrenWalkers[70 /* LeftShiftExpression */] = ChildrenWalkers.walkBinaryExpressionChildren; + this.childrenWalkers[71 /* SignedRightShiftExpression */] = ChildrenWalkers.walkBinaryExpressionChildren; + this.childrenWalkers[72 /* UnsignedRightShiftExpression */] = ChildrenWalkers.walkBinaryExpressionChildren; + this.childrenWalkers[73 /* BitwiseNotExpression */] = ChildrenWalkers.walkUnaryExpressionChildren; + this.childrenWalkers[74 /* LogicalNotExpression */] = ChildrenWalkers.walkUnaryExpressionChildren; + this.childrenWalkers[75 /* PreIncrementExpression */] = ChildrenWalkers.walkUnaryExpressionChildren; + this.childrenWalkers[76 /* PreDecrementExpression */] = ChildrenWalkers.walkUnaryExpressionChildren; + this.childrenWalkers[77 /* PostIncrementExpression */] = ChildrenWalkers.walkUnaryExpressionChildren; + this.childrenWalkers[78 /* PostDecrementExpression */] = ChildrenWalkers.walkUnaryExpressionChildren; + this.childrenWalkers[79 /* CastExpression */] = ChildrenWalkers.walkUnaryExpressionChildren; + this.childrenWalkers[80 /* ParenthesizedExpression */] = ChildrenWalkers.walkParenthesizedExpressionChildren; + this.childrenWalkers[13 /* FunctionDeclaration */] = ChildrenWalkers.walkFuncDeclChildren; + this.childrenWalkers[81 /* Member */] = ChildrenWalkers.walkBinaryExpressionChildren; + this.childrenWalkers[18 /* VariableDeclarator */] = ChildrenWalkers.walkBoundDeclChildren; + this.childrenWalkers[19 /* VariableDeclaration */] = ChildrenWalkers.walkVariableDeclarationChildren; + this.childrenWalkers[20 /* Parameter */] = ChildrenWalkers.walkBoundDeclChildren; + this.childrenWalkers[94 /* ReturnStatement */] = ChildrenWalkers.walkReturnStatementChildren; + this.childrenWalkers[83 /* BreakStatement */] = ChildrenWalkers.walkNone; + this.childrenWalkers[84 /* ContinueStatement */] = ChildrenWalkers.walkNone; + this.childrenWalkers[96 /* ThrowStatement */] = ChildrenWalkers.walkThrowStatementChildren; + this.childrenWalkers[91 /* ForStatement */] = ChildrenWalkers.walkForStatementChildren; + this.childrenWalkers[90 /* ForInStatement */] = ChildrenWalkers.walkForInStatementChildren; + this.childrenWalkers[92 /* IfStatement */] = ChildrenWalkers.walkIfStatementChildren; + this.childrenWalkers[99 /* WhileStatement */] = ChildrenWalkers.walkWhileStatementChildren; + this.childrenWalkers[86 /* DoStatement */] = ChildrenWalkers.walkDoStatementChildren; + this.childrenWalkers[82 /* Block */] = ChildrenWalkers.walkBlockChildren; + this.childrenWalkers[101 /* CaseClause */] = ChildrenWalkers.walkCaseClauseChildren; + this.childrenWalkers[95 /* SwitchStatement */] = ChildrenWalkers.walkSwitchStatementChildren; + this.childrenWalkers[97 /* TryStatement */] = ChildrenWalkers.walkTryStatementChildren; + this.childrenWalkers[102 /* CatchClause */] = ChildrenWalkers.walkCatchClauseChildren; + this.childrenWalkers[1 /* List */] = ChildrenWalkers.walkListChildren; + this.childrenWalkers[2 /* Script */] = ChildrenWalkers.walkScriptChildren; + this.childrenWalkers[14 /* ClassDeclaration */] = ChildrenWalkers.walkClassDeclChildren; + this.childrenWalkers[15 /* InterfaceDeclaration */] = ChildrenWalkers.walkTypeDeclChildren; + this.childrenWalkers[16 /* ModuleDeclaration */] = ChildrenWalkers.walkModuleDeclChildren; + this.childrenWalkers[17 /* ImportDeclaration */] = ChildrenWalkers.walkImportDeclChildren; + this.childrenWalkers[88 /* ExportAssignment */] = ChildrenWalkers.walkExportAssignmentChildren; + this.childrenWalkers[100 /* WithStatement */] = ChildrenWalkers.walkWithStatementChildren; + this.childrenWalkers[89 /* ExpressionStatement */] = ChildrenWalkers.walkExpressionStatementChildren; + this.childrenWalkers[93 /* LabeledStatement */] = ChildrenWalkers.walkLabeledStatementChildren; + this.childrenWalkers[98 /* VariableStatement */] = ChildrenWalkers.walkVariableStatementChildren; + this.childrenWalkers[103 /* Comment */] = ChildrenWalkers.walkNone; + this.childrenWalkers[85 /* DebuggerStatement */] = ChildrenWalkers.walkNone; + + for (var e in TypeScript.NodeType) { + if (TypeScript.NodeType.hasOwnProperty(e) && TypeScript.StringUtilities.isString(TypeScript.NodeType[e])) { + TypeScript.CompilerDiagnostics.assert(this.childrenWalkers[e] !== undefined, "initWalkers function is not up to date with enum content!"); + } + } + }; + return AstWalkerFactory; + })(); + TypeScript.AstWalkerFactory = AstWalkerFactory; + + var globalAstWalkerFactory; + + function getAstWalkerFactory() { + if (!globalAstWalkerFactory) { + globalAstWalkerFactory = new AstWalkerFactory(); + } + return globalAstWalkerFactory; + } + TypeScript.getAstWalkerFactory = getAstWalkerFactory; + + var ChildrenWalkers; + (function (ChildrenWalkers) { + function walkNone(preAst, parent, walker) { + } + ChildrenWalkers.walkNone = walkNone; + + function walkListChildren(preAst, parent, walker) { + var len = preAst.members.length; + + for (var i = 0; i < len; i++) { + preAst.members[i] = walker.walk(preAst.members[i], preAst); + } + } + ChildrenWalkers.walkListChildren = walkListChildren; + + function walkThrowStatementChildren(preAst, parent, walker) { + if (preAst.expression) { + preAst.expression = walker.walk(preAst.expression, preAst); + } + } + ChildrenWalkers.walkThrowStatementChildren = walkThrowStatementChildren; + + function walkUnaryExpressionChildren(preAst, parent, walker) { + if (preAst.castTerm) { + preAst.castTerm = walker.walk(preAst.castTerm, preAst); + } + if (preAst.operand) { + preAst.operand = walker.walk(preAst.operand, preAst); + } + } + ChildrenWalkers.walkUnaryExpressionChildren = walkUnaryExpressionChildren; + + function walkParenthesizedExpressionChildren(preAst, parent, walker) { + if (preAst.expression) { + preAst.expression = walker.walk(preAst.expression, preAst); + } + } + ChildrenWalkers.walkParenthesizedExpressionChildren = walkParenthesizedExpressionChildren; + + function walkBinaryExpressionChildren(preAst, parent, walker) { + if (preAst.operand1) { + preAst.operand1 = walker.walk(preAst.operand1, preAst); + } + if (preAst.operand2) { + preAst.operand2 = walker.walk(preAst.operand2, preAst); + } + } + ChildrenWalkers.walkBinaryExpressionChildren = walkBinaryExpressionChildren; + + function walkTypeParameterChildren(preAst, parent, walker) { + if (preAst.name) { + preAst.name = walker.walk(preAst.name, preAst); + } + + if (preAst.constraint) { + preAst.constraint = walker.walk(preAst.constraint, preAst); + } + } + ChildrenWalkers.walkTypeParameterChildren = walkTypeParameterChildren; + + function walkGenericTypeChildren(preAst, parent, walker) { + if (preAst.name) { + preAst.name = walker.walk(preAst.name, preAst); + } + + if (preAst.typeArguments) { + preAst.typeArguments = walker.walk(preAst.typeArguments, preAst); + } + } + ChildrenWalkers.walkGenericTypeChildren = walkGenericTypeChildren; + + function walkTypeReferenceChildren(preAst, parent, walker) { + if (preAst.term) { + preAst.term = walker.walk(preAst.term, preAst); + } + } + ChildrenWalkers.walkTypeReferenceChildren = walkTypeReferenceChildren; + + function walkTypeQueryChildren(preAst, parent, walker) { + if (preAst.name) { + preAst.name = walker.walk(preAst.name, preAst); + } + } + ChildrenWalkers.walkTypeQueryChildren = walkTypeQueryChildren; + + function walkInvocationExpressionChildren(preAst, parent, walker) { + preAst.target = walker.walk(preAst.target, preAst); + + if (preAst.typeArguments) { + preAst.typeArguments = walker.walk(preAst.typeArguments, preAst); + } + + if (preAst.arguments) { + preAst.arguments = walker.walk(preAst.arguments, preAst); + } + } + ChildrenWalkers.walkInvocationExpressionChildren = walkInvocationExpressionChildren; + + function walkObjectCreationExpressionChildren(preAst, parent, walker) { + preAst.target = walker.walk(preAst.target, preAst); + + if (preAst.typeArguments) { + preAst.typeArguments = walker.walk(preAst.typeArguments, preAst); + } + + if (preAst.arguments) { + preAst.arguments = walker.walk(preAst.arguments, preAst); + } + } + ChildrenWalkers.walkObjectCreationExpressionChildren = walkObjectCreationExpressionChildren; + + function walkTrinaryExpressionChildren(preAst, parent, walker) { + if (preAst.operand1) { + preAst.operand1 = walker.walk(preAst.operand1, preAst); + } + if (preAst.operand2) { + preAst.operand2 = walker.walk(preAst.operand2, preAst); + } + if (preAst.operand3) { + preAst.operand3 = walker.walk(preAst.operand3, preAst); + } + } + ChildrenWalkers.walkTrinaryExpressionChildren = walkTrinaryExpressionChildren; + + function walkFuncDeclChildren(preAst, parent, walker) { + if (preAst.name) { + preAst.name = walker.walk(preAst.name, preAst); + } + if (preAst.typeArguments) { + preAst.typeArguments = walker.walk(preAst.typeArguments, preAst); + } + if (preAst.arguments) { + preAst.arguments = walker.walk(preAst.arguments, preAst); + } + if (preAst.returnTypeAnnotation) { + preAst.returnTypeAnnotation = walker.walk(preAst.returnTypeAnnotation, preAst); + } + if (preAst.block) { + preAst.block = walker.walk(preAst.block, preAst); + } + } + ChildrenWalkers.walkFuncDeclChildren = walkFuncDeclChildren; + + function walkBoundDeclChildren(preAst, parent, walker) { + if (preAst.id) { + preAst.id = walker.walk(preAst.id, preAst); + } + if (preAst.init) { + preAst.init = walker.walk(preAst.init, preAst); + } + if (preAst.typeExpr) { + preAst.typeExpr = walker.walk(preAst.typeExpr, preAst); + } + } + ChildrenWalkers.walkBoundDeclChildren = walkBoundDeclChildren; + + function walkReturnStatementChildren(preAst, parent, walker) { + if (preAst.returnExpression) { + preAst.returnExpression = walker.walk(preAst.returnExpression, preAst); + } + } + ChildrenWalkers.walkReturnStatementChildren = walkReturnStatementChildren; + + function walkForStatementChildren(preAst, parent, walker) { + if (preAst.init) { + preAst.init = walker.walk(preAst.init, preAst); + } + + if (preAst.cond) { + preAst.cond = walker.walk(preAst.cond, preAst); + } + + if (preAst.incr) { + preAst.incr = walker.walk(preAst.incr, preAst); + } + + if (preAst.body) { + preAst.body = walker.walk(preAst.body, preAst); + } + } + ChildrenWalkers.walkForStatementChildren = walkForStatementChildren; + + function walkForInStatementChildren(preAst, parent, walker) { + preAst.lval = walker.walk(preAst.lval, preAst); + preAst.obj = walker.walk(preAst.obj, preAst); + + if (preAst.body) { + preAst.body = walker.walk(preAst.body, preAst); + } + } + ChildrenWalkers.walkForInStatementChildren = walkForInStatementChildren; + + function walkIfStatementChildren(preAst, parent, walker) { + preAst.cond = walker.walk(preAst.cond, preAst); + if (preAst.thenBod) { + preAst.thenBod = walker.walk(preAst.thenBod, preAst); + } + if (preAst.elseBod) { + preAst.elseBod = walker.walk(preAst.elseBod, preAst); + } + } + ChildrenWalkers.walkIfStatementChildren = walkIfStatementChildren; + + function walkWhileStatementChildren(preAst, parent, walker) { + preAst.cond = walker.walk(preAst.cond, preAst); + if (preAst.body) { + preAst.body = walker.walk(preAst.body, preAst); + } + } + ChildrenWalkers.walkWhileStatementChildren = walkWhileStatementChildren; + + function walkDoStatementChildren(preAst, parent, walker) { + preAst.cond = walker.walk(preAst.cond, preAst); + if (preAst.body) { + preAst.body = walker.walk(preAst.body, preAst); + } + } + ChildrenWalkers.walkDoStatementChildren = walkDoStatementChildren; + + function walkBlockChildren(preAst, parent, walker) { + if (preAst.statements) { + preAst.statements = walker.walk(preAst.statements, preAst); + } + } + ChildrenWalkers.walkBlockChildren = walkBlockChildren; + + function walkVariableDeclarationChildren(preAst, parent, walker) { + if (preAst.declarators) { + preAst.declarators = walker.walk(preAst.declarators, preAst); + } + } + ChildrenWalkers.walkVariableDeclarationChildren = walkVariableDeclarationChildren; + + function walkCaseClauseChildren(preAst, parent, walker) { + if (preAst.expr) { + preAst.expr = walker.walk(preAst.expr, preAst); + } + + if (preAst.body) { + preAst.body = walker.walk(preAst.body, preAst); + } + } + ChildrenWalkers.walkCaseClauseChildren = walkCaseClauseChildren; + + function walkSwitchStatementChildren(preAst, parent, walker) { + if (preAst.val) { + preAst.val = walker.walk(preAst.val, preAst); + } + + if (preAst.caseList) { + preAst.caseList = walker.walk(preAst.caseList, preAst); + } + } + ChildrenWalkers.walkSwitchStatementChildren = walkSwitchStatementChildren; + + function walkTryStatementChildren(preAst, parent, walker) { + if (preAst.tryBody) { + preAst.tryBody = walker.walk(preAst.tryBody, preAst); + } + if (preAst.catchClause) { + preAst.catchClause = walker.walk(preAst.catchClause, preAst); + } + if (preAst.finallyBody) { + preAst.finallyBody = walker.walk(preAst.finallyBody, preAst); + } + } + ChildrenWalkers.walkTryStatementChildren = walkTryStatementChildren; + + function walkCatchClauseChildren(preAst, parent, walker) { + if (preAst.param) { + preAst.param = walker.walk(preAst.param, preAst); + } + + if (preAst.body) { + preAst.body = walker.walk(preAst.body, preAst); + } + } + ChildrenWalkers.walkCatchClauseChildren = walkCatchClauseChildren; + + function walkClassDeclChildren(preAst, parent, walker) { + preAst.name = walker.walk(preAst.name, preAst); + + if (preAst.members) { + preAst.members = walker.walk(preAst.members, preAst); + } + + if (preAst.typeParameters) { + preAst.typeParameters = walker.walk(preAst.typeParameters, preAst); + } + + if (preAst.extendsList) { + preAst.extendsList = walker.walk(preAst.extendsList, preAst); + } + + if (preAst.implementsList) { + preAst.implementsList = walker.walk(preAst.implementsList, preAst); + } + } + ChildrenWalkers.walkClassDeclChildren = walkClassDeclChildren; + + function walkScriptChildren(preAst, parent, walker) { + if (preAst.moduleElements) { + preAst.moduleElements = walker.walk(preAst.moduleElements, preAst); + } + } + ChildrenWalkers.walkScriptChildren = walkScriptChildren; + + function walkTypeDeclChildren(preAst, parent, walker) { + preAst.name = walker.walk(preAst.name, preAst); + if (preAst.members) { + preAst.members = walker.walk(preAst.members, preAst); + } + + if (preAst.typeParameters) { + preAst.typeParameters = walker.walk(preAst.typeParameters, preAst); + } + + if (preAst.extendsList) { + preAst.extendsList = walker.walk(preAst.extendsList, preAst); + } + + if (preAst.implementsList) { + preAst.implementsList = walker.walk(preAst.implementsList, preAst); + } + } + ChildrenWalkers.walkTypeDeclChildren = walkTypeDeclChildren; + + function walkModuleDeclChildren(preAst, parent, walker) { + preAst.name = walker.walk(preAst.name, preAst); + if (preAst.members) { + preAst.members = walker.walk(preAst.members, preAst); + } + } + ChildrenWalkers.walkModuleDeclChildren = walkModuleDeclChildren; + + function walkImportDeclChildren(preAst, parent, walker) { + if (preAst.id) { + preAst.id = walker.walk(preAst.id, preAst); + } + if (preAst.alias) { + preAst.alias = walker.walk(preAst.alias, preAst); + } + } + ChildrenWalkers.walkImportDeclChildren = walkImportDeclChildren; + + function walkExportAssignmentChildren(preAst, parent, walker) { + if (preAst.id) { + preAst.id = walker.walk(preAst.id, preAst); + } + } + ChildrenWalkers.walkExportAssignmentChildren = walkExportAssignmentChildren; + + function walkWithStatementChildren(preAst, parent, walker) { + if (preAst.expr) { + preAst.expr = walker.walk(preAst.expr, preAst); + } + + if (preAst.body) { + preAst.body = walker.walk(preAst.body, preAst); + } + } + ChildrenWalkers.walkWithStatementChildren = walkWithStatementChildren; + + function walkExpressionStatementChildren(preAst, parent, walker) { + preAst.expression = walker.walk(preAst.expression, preAst); + } + ChildrenWalkers.walkExpressionStatementChildren = walkExpressionStatementChildren; + + function walkLabeledStatementChildren(preAst, parent, walker) { + preAst.identifier = walker.walk(preAst.identifier, preAst); + preAst.statement = walker.walk(preAst.statement, preAst); + } + ChildrenWalkers.walkLabeledStatementChildren = walkLabeledStatementChildren; + + function walkVariableStatementChildren(preAst, parent, walker) { + preAst.declaration = walker.walk(preAst.declaration, preAst); + } + ChildrenWalkers.walkVariableStatementChildren = walkVariableStatementChildren; + })(ChildrenWalkers || (ChildrenWalkers = {})); +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + function max(a, b) { + return a >= b ? a : b; + } + TypeScript.max = max; + + function min(a, b) { + return a <= b ? a : b; + } + TypeScript.min = min; + + var AstPath = (function () { + function AstPath() { + this.asts = new Array(); + this.top = -1; + } + AstPath.reverseIndexOf = function (items, index) { + return (items === null || items.length <= index) ? null : items[items.length - index - 1]; + }; + + AstPath.prototype.clone = function () { + var clone = new AstPath(); + clone.asts = this.asts.map(function (value) { + return value; + }); + clone.top = this.top; + return clone; + }; + + AstPath.prototype.pop = function () { + var head = this.ast(); + this.up(); + + while (this.asts.length > this.count()) { + this.asts.pop(); + } + return head; + }; + + AstPath.prototype.push = function (ast) { + while (this.asts.length > this.count()) { + this.asts.pop(); + } + this.top = this.asts.length; + this.asts.push(ast); + }; + + AstPath.prototype.up = function () { + if (this.top <= -1) + throw TypeScript.Errors.invalidOperation(TypeScript.getLocalizedText(TypeScript.DiagnosticCode.Invalid_call_to_up, null)); + this.top--; + }; + + AstPath.prototype.down = function () { + if (this.top === this.ast.length - 1) + throw TypeScript.Errors.invalidOperation(TypeScript.getLocalizedText(TypeScript.DiagnosticCode.Invalid_call_to_down, null)); + this.top++; + }; + + AstPath.prototype.nodeType = function () { + if (this.ast() === null) + return 0 /* None */; + return this.ast().nodeType(); + }; + + AstPath.prototype.ast = function () { + return AstPath.reverseIndexOf(this.asts, this.asts.length - (this.top + 1)); + }; + + AstPath.prototype.parent = function () { + return AstPath.reverseIndexOf(this.asts, this.asts.length - this.top); + }; + + AstPath.prototype.count = function () { + return this.top + 1; + }; + + AstPath.prototype.get = function (index) { + return this.asts[index]; + }; + + AstPath.prototype.isNameOfClass = function () { + if (this.ast() === null || this.parent() === null) + return false; + + return (this.ast().nodeType() === 21 /* Name */) && (this.parent().nodeType() === 14 /* ClassDeclaration */) && ((this.parent()).name === this.ast()); + }; + + AstPath.prototype.isNameOfInterface = function () { + if (this.ast() === null || this.parent() === null) + return false; + + return (this.ast().nodeType() === 21 /* Name */) && (this.parent().nodeType() === 15 /* InterfaceDeclaration */) && ((this.parent()).name === this.ast()); + }; + + AstPath.prototype.isNameOfArgument = function () { + if (this.ast() === null || this.parent() === null) + return false; + + return (this.ast().nodeType() === 21 /* Name */) && (this.parent().nodeType() === 20 /* Parameter */) && ((this.parent()).id === this.ast()); + }; + + AstPath.prototype.isNameOfVariable = function () { + if (this.ast() === null || this.parent() === null) + return false; + + return (this.ast().nodeType() === 21 /* Name */) && (this.parent().nodeType() === 18 /* VariableDeclarator */) && ((this.parent()).id === this.ast()); + }; + + AstPath.prototype.isNameOfModule = function () { + if (this.ast() === null || this.parent() === null) + return false; + + return (this.ast().nodeType() === 21 /* Name */) && (this.parent().nodeType() === 16 /* ModuleDeclaration */) && ((this.parent()).name === this.ast()); + }; + + AstPath.prototype.isNameOfFunction = function () { + if (this.ast() === null || this.parent() === null) + return false; + + return (this.ast().nodeType() === 21 /* Name */) && (this.parent().nodeType() === 13 /* FunctionDeclaration */) && ((this.parent()).name === this.ast()); + }; + + AstPath.prototype.isBodyOfFunction = function () { + return this.count() >= 2 && this.asts[this.top - 1].nodeType() === 13 /* FunctionDeclaration */ && (this.asts[this.top - 1]).block === this.asts[this.top - 0]; + }; + + AstPath.prototype.isArgumentListOfFunction = function () { + return this.count() >= 2 && this.asts[this.top - 0].nodeType() === 1 /* List */ && this.asts[this.top - 1].nodeType() === 13 /* FunctionDeclaration */ && (this.asts[this.top - 1]).arguments === this.asts[this.top - 0]; + }; + + AstPath.prototype.isTargetOfCall = function () { + return this.count() >= 2 && this.asts[this.top - 1].nodeType() === 37 /* InvocationExpression */ && (this.asts[this.top - 1]).target === this.asts[this.top]; + }; + + AstPath.prototype.isTargetOfNew = function () { + return this.count() >= 2 && this.asts[this.top - 1].nodeType() === 38 /* ObjectCreationExpression */ && (this.asts[this.top - 1]).target === this.asts[this.top]; + }; + + AstPath.prototype.isInClassImplementsList = function () { + if (this.ast() === null || this.parent() === null) + return false; + + return (this.parent().nodeType() === 14 /* ClassDeclaration */) && (this.isMemberOfList((this.parent()).implementsList, this.ast())); + }; + + AstPath.prototype.isInInterfaceExtendsList = function () { + if (this.ast() === null || this.parent() === null) + return false; + + return (this.parent().nodeType() === 15 /* InterfaceDeclaration */) && (this.isMemberOfList((this.parent()).extendsList, this.ast())); + }; + + AstPath.prototype.isMemberOfMemberAccessExpression = function () { + if (this.count() > 1 && this.parent().nodeType() === 33 /* MemberAccessExpression */ && (this.parent()).operand2 === this.asts[this.top]) { + return true; + } + + return false; + }; + + AstPath.prototype.isCallExpression = function () { + return this.count() >= 1 && (this.asts[this.top - 0].nodeType() === 37 /* InvocationExpression */ || this.asts[this.top - 0].nodeType() === 38 /* ObjectCreationExpression */); + }; + + AstPath.prototype.isCallExpressionTarget = function () { + if (this.count() < 2) { + return false; + } + + var current = this.top; + + var nodeType = this.asts[current].nodeType(); + if (nodeType === 30 /* ThisExpression */ || nodeType === 31 /* SuperExpression */ || nodeType === 21 /* Name */) { + current--; + } + + while (current >= 0) { + if (current < this.top && this.asts[current].nodeType() === 33 /* MemberAccessExpression */ && (this.asts[current]).operand2 === this.asts[current + 1]) { + current--; + continue; + } + + break; + } + + return current < this.top && (this.asts[current].nodeType() === 37 /* InvocationExpression */ || this.asts[current].nodeType() === 38 /* ObjectCreationExpression */) && this.asts[current + 1] === (this.asts[current]).target; + }; + + AstPath.prototype.isDeclaration = function () { + if (this.ast() !== null) { + switch (this.ast().nodeType()) { + case 14 /* ClassDeclaration */: + case 15 /* InterfaceDeclaration */: + case 16 /* ModuleDeclaration */: + case 13 /* FunctionDeclaration */: + case 18 /* VariableDeclarator */: + return true; + } + } + + return false; + }; + + AstPath.prototype.isMemberOfList = function (list, item) { + if (list && list.members) { + for (var i = 0, n = list.members.length; i < n; i++) { + if (list.members[i] === item) { + return true; + } + } + } + + return false; + }; + return AstPath; + })(); + TypeScript.AstPath = AstPath; + + function isValidAstNode(ast) { + if (ast === null) + return false; + + if (ast.minChar === -1 || ast.limChar === -1) + return false; + + return true; + } + TypeScript.isValidAstNode = isValidAstNode; + + var AstPathContext = (function () { + function AstPathContext() { + this.path = new TypeScript.AstPath(); + } + return AstPathContext; + })(); + TypeScript.AstPathContext = AstPathContext; + + function getAstPathToPosition(script, pos, useTrailingTriviaAsLimChar) { + if (typeof useTrailingTriviaAsLimChar === "undefined") { useTrailingTriviaAsLimChar = true; } + var lookInComments = function (comments) { + if (comments && comments.length > 0) { + for (var i = 0; i < comments.length; i++) { + var minChar = comments[i].minChar; + var limChar = comments[i].limChar + (useTrailingTriviaAsLimChar ? comments[i].trailingTriviaWidth : 0); + if (!comments[i].isBlockComment) { + limChar++; + } + if (pos >= minChar && pos < limChar) { + ctx.path.push(comments[i]); + } + } + } + }; + + var pre = function (cur, parent, walker) { + if (isValidAstNode(cur)) { + var isInvalid1 = cur.nodeType() === 89 /* ExpressionStatement */ && cur.getLength() === 0; + + if (isInvalid1) { + walker.options.goChildren = false; + } else { + var inclusive = cur.nodeType() === 21 /* Name */ || cur.nodeType() === 33 /* MemberAccessExpression */ || cur.nodeType() === 11 /* TypeRef */ || cur.nodeType() === 19 /* VariableDeclaration */ || cur.nodeType() === 18 /* VariableDeclarator */ || cur.nodeType() === 37 /* InvocationExpression */ || pos === script.limChar + script.trailingTriviaWidth; + + var minChar = cur.minChar; + var limChar = cur.limChar + (useTrailingTriviaAsLimChar ? cur.trailingTriviaWidth : 0) + (inclusive ? 1 : 0); + if (pos >= minChar && pos < limChar) { + var previous = ctx.path.ast(); + if (previous === null || (cur.minChar >= previous.minChar && (cur.limChar + (useTrailingTriviaAsLimChar ? cur.trailingTriviaWidth : 0)) <= (previous.limChar + (useTrailingTriviaAsLimChar ? previous.trailingTriviaWidth : 0)))) { + ctx.path.push(cur); + } else { + } + } + + if (pos < limChar) { + lookInComments(cur.preComments()); + } + if (pos >= minChar) { + lookInComments(cur.postComments()); + } + + walker.options.goChildren = (minChar <= pos && pos <= limChar); + } + } + + return cur; + }; + + var ctx = new AstPathContext(); + TypeScript.getAstWalkerFactory().walk(script, pre, null, null, ctx); + return ctx.path; + } + TypeScript.getAstPathToPosition = getAstPathToPosition; + + function walkAST(ast, callback) { + var pre = function (cur, parent, walker) { + var path = walker.state; + path.push(cur); + callback(path, walker); + return cur; + }; + var post = function (cur, parent, walker) { + var path = walker.state; + path.pop(); + return cur; + }; + + var path = new AstPath(); + TypeScript.getAstWalkerFactory().walk(ast, pre, post, null, path); + } + TypeScript.walkAST = walkAST; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var Base64Format = (function () { + function Base64Format() { + } + Base64Format.encode = function (inValue) { + if (inValue < 64) { + return Base64Format.encodedValues.charAt(inValue); + } + throw TypeError(inValue + ": not a 64 based value"); + }; + + Base64Format.decodeChar = function (inChar) { + if (inChar.length === 1) { + return Base64Format.encodedValues.indexOf(inChar); + } else { + throw TypeError('"' + inChar + '" must have length 1'); + } + }; + Base64Format.encodedValues = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'; + return Base64Format; + })(); + + var Base64VLQFormat = (function () { + function Base64VLQFormat() { + } + Base64VLQFormat.encode = function (inValue) { + if (inValue < 0) { + inValue = ((-inValue) << 1) + 1; + } else { + inValue = inValue << 1; + } + + var encodedStr = ""; + do { + var currentDigit = inValue & 31; + inValue = inValue >> 5; + if (inValue > 0) { + currentDigit = currentDigit | 32; + } + encodedStr = encodedStr + Base64Format.encode(currentDigit); + } while(inValue > 0); + + return encodedStr; + }; + + Base64VLQFormat.decode = function (inString) { + var result = 0; + var negative = false; + + var shift = 0; + for (var i = 0; i < inString.length; i++) { + var byte = Base64Format.decodeChar(inString[i]); + if (i === 0) { + if ((byte & 1) === 1) { + negative = true; + } + result = (byte >> 1) & 15; + } else { + result = result | ((byte & 31) << shift); + } + + shift += (i === 0) ? 4 : 5; + + if ((byte & 32) === 32) { + } else { + return { value: negative ? -(result) : result, rest: inString.substr(i + 1) }; + } + } + + throw new Error(TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Base64_value_0_finished_with_a_continuation_bit, [inString])); + }; + return Base64VLQFormat; + })(); + TypeScript.Base64VLQFormat = Base64VLQFormat; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var SourceMapPosition = (function () { + function SourceMapPosition() { + } + return SourceMapPosition; + })(); + TypeScript.SourceMapPosition = SourceMapPosition; + + var SourceMapping = (function () { + function SourceMapping() { + this.start = new SourceMapPosition(); + this.end = new SourceMapPosition(); + this.nameIndex = -1; + this.childMappings = []; + } + return SourceMapping; + })(); + TypeScript.SourceMapping = SourceMapping; + + var SourceMapSourceInfo = (function () { + function SourceMapSourceInfo(oldSourceMapSourceInfo) { + if (oldSourceMapSourceInfo) { + this.jsFileName = oldSourceMapSourceInfo.jsFileName; + this.sourceMapPath = oldSourceMapSourceInfo.sourceMapPath; + this.sourceMapDirectory = oldSourceMapSourceInfo.sourceMapDirectory; + + this.sourceRoot = oldSourceMapSourceInfo.sourceRoot; + } + } + return SourceMapSourceInfo; + })(); + TypeScript.SourceMapSourceInfo = SourceMapSourceInfo; + + var SourceMapper = (function () { + function SourceMapper(jsFile, sourceMapOut, sourceMapSourceInfo) { + this.jsFile = jsFile; + this.sourceMapOut = sourceMapOut; + this.sourceMapSourceInfo = sourceMapSourceInfo; + this.sourceMappings = []; + this.currentMappings = []; + this.names = []; + this.currentNameIndex = []; + this.currentMappings.push(this.sourceMappings); + } + SourceMapper.emitSourceMapping = function (allSourceMappers) { + var sourceMapper = allSourceMappers[0]; + sourceMapper.jsFile.WriteLine("//# sourceMappingURL=" + sourceMapper.sourceMapSourceInfo.sourceMapPath); + + var sourceMapOut = sourceMapper.sourceMapOut; + var mappingsString = ""; + var tsFiles = []; + + var prevEmittedColumn = 0; + var prevEmittedLine = 0; + var prevSourceColumn = 0; + var prevSourceLine = 0; + var prevSourceIndex = 0; + var prevNameIndex = 0; + var namesList = []; + var namesCount = 0; + var emitComma = false; + + var recordedPosition = null; + for (var sourceMapperIndex = 0; sourceMapperIndex < allSourceMappers.length; sourceMapperIndex++) { + sourceMapper = allSourceMappers[sourceMapperIndex]; + + var currentSourceIndex = tsFiles.length; + tsFiles.push(sourceMapper.sourceMapSourceInfo.tsFilePath); + + if (sourceMapper.names.length > 0) { + namesList.push.apply(namesList, sourceMapper.names); + } + + var recordSourceMapping = function (mappedPosition, nameIndex) { + if (recordedPosition !== null && recordedPosition.emittedColumn === mappedPosition.emittedColumn && recordedPosition.emittedLine === mappedPosition.emittedLine) { + return; + } + + if (prevEmittedLine !== mappedPosition.emittedLine) { + while (prevEmittedLine < mappedPosition.emittedLine) { + prevEmittedColumn = 0; + mappingsString = mappingsString + ";"; + prevEmittedLine++; + } + emitComma = false; + } else if (emitComma) { + mappingsString = mappingsString + ","; + } + + mappingsString = mappingsString + TypeScript.Base64VLQFormat.encode(mappedPosition.emittedColumn - prevEmittedColumn); + prevEmittedColumn = mappedPosition.emittedColumn; + + mappingsString = mappingsString + TypeScript.Base64VLQFormat.encode(currentSourceIndex - prevSourceIndex); + prevSourceIndex = currentSourceIndex; + + mappingsString = mappingsString + TypeScript.Base64VLQFormat.encode(mappedPosition.sourceLine - 1 - prevSourceLine); + prevSourceLine = mappedPosition.sourceLine - 1; + + mappingsString = mappingsString + TypeScript.Base64VLQFormat.encode(mappedPosition.sourceColumn - prevSourceColumn); + prevSourceColumn = mappedPosition.sourceColumn; + + if (nameIndex >= 0) { + mappingsString = mappingsString + TypeScript.Base64VLQFormat.encode(namesCount + nameIndex - prevNameIndex); + prevNameIndex = namesCount + nameIndex; + } + + emitComma = true; + recordedPosition = mappedPosition; + }; + + var recordSourceMappingSiblings = function (sourceMappings) { + 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(sourceMapper.sourceMappings); + namesCount = namesCount + sourceMapper.names.length; + } + + sourceMapOut.Write(JSON.stringify({ + version: 3, + file: sourceMapper.sourceMapSourceInfo.jsFileName, + sourceRoot: sourceMapper.sourceMapSourceInfo.sourceRoot, + sources: tsFiles, + names: namesList, + mappings: mappingsString + })); + + sourceMapOut.Close(); + }; + SourceMapper.MapFileExtension = ".map"; + return SourceMapper; + })(); + TypeScript.SourceMapper = SourceMapper; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (EmitContainer) { + EmitContainer[EmitContainer["Prog"] = 0] = "Prog"; + EmitContainer[EmitContainer["Module"] = 1] = "Module"; + EmitContainer[EmitContainer["DynamicModule"] = 2] = "DynamicModule"; + EmitContainer[EmitContainer["Class"] = 3] = "Class"; + EmitContainer[EmitContainer["Constructor"] = 4] = "Constructor"; + EmitContainer[EmitContainer["Function"] = 5] = "Function"; + EmitContainer[EmitContainer["Args"] = 6] = "Args"; + EmitContainer[EmitContainer["Interface"] = 7] = "Interface"; + })(TypeScript.EmitContainer || (TypeScript.EmitContainer = {})); + var EmitContainer = TypeScript.EmitContainer; + + var EmitState = (function () { + function EmitState() { + this.column = 0; + this.line = 0; + this.container = 0 /* Prog */; + } + return EmitState; + })(); + TypeScript.EmitState = EmitState; + + var EmitOptions = (function () { + function EmitOptions(compilationSettings) { + this.compilationSettings = compilationSettings; + this.ioHost = null; + this.outputMany = true; + this.commonDirectoryPath = ""; + } + EmitOptions.prototype.mapOutputFileName = function (document, extensionChanger) { + if (this.outputMany || document.script.topLevelMod) { + var updatedFileName = document.fileName; + if (this.compilationSettings.outDirOption !== "") { + updatedFileName = document.fileName.replace(this.commonDirectoryPath, ""); + updatedFileName = this.compilationSettings.outDirOption + updatedFileName; + } + return extensionChanger(updatedFileName, false); + } else { + return extensionChanger(this.compilationSettings.outFileOption, true); + } + }; + + EmitOptions.prototype.decodeSourceMapOptions = function (document, jsFilePath, oldSourceMapSourceInfo) { + var sourceMapSourceInfo = new TypeScript.SourceMapSourceInfo(oldSourceMapSourceInfo); + + var tsFilePath = TypeScript.switchToForwardSlashes(document.fileName); + + if (!oldSourceMapSourceInfo) { + var prettyJsFileName = TypeScript.getPrettyName(jsFilePath, false, true); + var prettyMapFileName = prettyJsFileName + TypeScript.SourceMapper.MapFileExtension; + sourceMapSourceInfo.jsFileName = prettyJsFileName; + + if (this.compilationSettings.mapRoot) { + if (this.outputMany || document.script.topLevelMod) { + var sourceMapPath = tsFilePath.replace(this.commonDirectoryPath, ""); + sourceMapPath = this.compilationSettings.mapRoot + sourceMapPath; + sourceMapPath = TypeScript.TypeScriptCompiler.mapToJSFileName(sourceMapPath, false) + TypeScript.SourceMapper.MapFileExtension; + sourceMapSourceInfo.sourceMapPath = sourceMapPath; + + if (TypeScript.isRelative(sourceMapSourceInfo.sourceMapPath)) { + sourceMapPath = this.commonDirectoryPath + sourceMapSourceInfo.sourceMapPath; + } + sourceMapSourceInfo.sourceMapDirectory = TypeScript.getRootFilePath(sourceMapPath); + } else { + sourceMapSourceInfo.sourceMapPath = this.compilationSettings.mapRoot + prettyMapFileName; + sourceMapSourceInfo.sourceMapDirectory = this.compilationSettings.mapRoot; + if (TypeScript.isRelative(sourceMapSourceInfo.sourceMapDirectory)) { + sourceMapSourceInfo.sourceMapDirectory = TypeScript.getRootFilePath(jsFilePath) + this.compilationSettings.mapRoot; + } + } + } else { + sourceMapSourceInfo.sourceMapPath = prettyMapFileName; + sourceMapSourceInfo.sourceMapDirectory = TypeScript.getRootFilePath(jsFilePath); + } + sourceMapSourceInfo.sourceRoot = this.compilationSettings.sourceRoot; + } + + if (this.compilationSettings.sourceRoot) { + sourceMapSourceInfo.tsFilePath = TypeScript.getRelativePathToFixedPath(this.commonDirectoryPath, tsFilePath); + } else { + sourceMapSourceInfo.tsFilePath = TypeScript.getRelativePathToFixedPath(sourceMapSourceInfo.sourceMapDirectory, tsFilePath); + } + return sourceMapSourceInfo; + }; + return EmitOptions; + })(); + TypeScript.EmitOptions = EmitOptions; + + var Indenter = (function () { + function Indenter() { + this.indentAmt = 0; + } + Indenter.prototype.increaseIndent = function () { + this.indentAmt += Indenter.indentStep; + }; + + Indenter.prototype.decreaseIndent = function () { + this.indentAmt -= Indenter.indentStep; + }; + + Indenter.prototype.getIndent = function () { + var indentString = Indenter.indentStrings[this.indentAmt]; + if (indentString === undefined) { + indentString = ""; + for (var i = 0; i < this.indentAmt; i = i + Indenter.indentStep) { + indentString += Indenter.indentStepString; + } + Indenter.indentStrings[this.indentAmt] = indentString; + } + return indentString; + }; + Indenter.indentStep = 4; + Indenter.indentStepString = " "; + Indenter.indentStrings = []; + return Indenter; + })(); + TypeScript.Indenter = Indenter; + + var Emitter = (function () { + function Emitter(emittingFileName, outfile, emitOptions, semanticInfoChain) { + this.emittingFileName = emittingFileName; + this.outfile = outfile; + this.emitOptions = emitOptions; + this.semanticInfoChain = semanticInfoChain; + this.globalThisCapturePrologueEmitted = false; + this.extendsPrologueEmitted = false; + this.thisClassNode = null; + this.thisFunctionDeclaration = null; + this.moduleName = ""; + this.emitState = new EmitState(); + this.indenter = new Indenter(); + this.modAliasId = null; + this.firstModAlias = null; + this.allSourceMappers = []; + this.sourceMapper = null; + this.captureThisStmtString = "var _this = this;"; + this.varListCountStack = [0]; + this.declStack = []; + this.resolvingContext = new TypeScript.PullTypeResolutionContext(); + this.exportAssignmentIdentifier = null; + this.document = null; + this.copyrightElement = null; + TypeScript.globalSemanticInfoChain = semanticInfoChain; + TypeScript.globalBinder.semanticInfoChain = semanticInfoChain; + } + Emitter.prototype.pushDecl = function (decl) { + if (decl) { + this.declStack[this.declStack.length] = decl; + } + }; + + Emitter.prototype.popDecl = function (decl) { + if (decl) { + this.declStack.length--; + } + }; + + Emitter.prototype.getEnclosingDecl = function () { + var declStackLen = this.declStack.length; + var enclosingDecl = declStackLen > 0 ? this.declStack[declStackLen - 1] : null; + return enclosingDecl; + }; + + Emitter.prototype.setExportAssignmentIdentifier = function (id) { + this.exportAssignmentIdentifier = id; + }; + + Emitter.prototype.getExportAssignmentIdentifier = function () { + return this.exportAssignmentIdentifier; + }; + + Emitter.prototype.setDocument = function (document) { + this.document = document; + }; + + Emitter.prototype.importStatementShouldBeEmitted = function (importDeclAST, unitPath) { + var importDecl = this.semanticInfoChain.getDeclForAST(importDeclAST, this.document.fileName); + var pullSymbol = importDecl.getSymbol(); + if (!importDeclAST.isExternalImportDeclaration()) { + if (pullSymbol.getExportAssignedValueSymbol()) { + return true; + } + var containerSymbol = pullSymbol.getExportAssignedContainerSymbol(); + if (containerSymbol && containerSymbol.getInstanceSymbol()) { + return true; + } + } + + return pullSymbol.isUsedAsValue; + }; + + Emitter.prototype.emitImportDeclaration = function (importDeclAST) { + if (this.importStatementShouldBeEmitted(importDeclAST)) { + var prevModAliasId = this.modAliasId; + var prevFirstModAlias = this.firstModAlias; + + this.emitComments(importDeclAST, true); + + var importDecl = this.semanticInfoChain.getDeclForAST(importDeclAST, this.document.fileName); + var importSymbol = importDecl.getSymbol(); + + var parentSymbol = importSymbol.getContainer(); + var parentKind = parentSymbol ? parentSymbol.kind : 0 /* None */; + var associatedParentSymbol = parentSymbol ? parentSymbol.getAssociatedContainerType() : null; + var associatedParentSymbolKind = associatedParentSymbol ? associatedParentSymbol.kind : 0 /* None */; + + var needsPropertyAssignment = false; + var usePropertyAssignmentInsteadOfVarDecl = false; + var moduleNamePrefix; + + if (TypeScript.hasFlag(importDecl.flags, 1 /* Exported */) && (parentKind == 4 /* Container */ || parentKind === 32 /* DynamicModule */ || associatedParentSymbolKind === 4 /* Container */ || associatedParentSymbolKind === 32 /* DynamicModule */)) { + if (importSymbol.getExportAssignedTypeSymbol() || importSymbol.getExportAssignedContainerSymbol()) { + needsPropertyAssignment = true; + } else { + var valueSymbol = importSymbol.getExportAssignedValueSymbol(); + if (valueSymbol && (valueSymbol.kind == 65536 /* Method */ || valueSymbol.kind == 16384 /* Function */)) { + needsPropertyAssignment = true; + } else { + usePropertyAssignmentInsteadOfVarDecl = true; + } + } + + if (this.emitState.container === 2 /* DynamicModule */) { + moduleNamePrefix = "exports."; + } else { + moduleNamePrefix = this.moduleName + "."; + } + } + + this.recordSourceMappingStart(importDeclAST); + if (usePropertyAssignmentInsteadOfVarDecl) { + this.writeToOutput(moduleNamePrefix); + } else { + this.writeToOutput("var "); + } + this.writeToOutput(importDeclAST.id.actualText + " = "); + this.modAliasId = importDeclAST.id.actualText; + this.firstModAlias = importDeclAST.firstAliasedModToString(); + var aliasAST = importDeclAST.alias.nodeType() === 11 /* TypeRef */ ? (importDeclAST.alias).term : importDeclAST.alias; + + this.emitJavascript(aliasAST, false); + this.recordSourceMappingEnd(importDeclAST); + this.writeToOutput(";"); + + if (needsPropertyAssignment) { + this.writeLineToOutput(""); + this.emitIndent(); + this.recordSourceMappingStart(importDeclAST); + this.writeToOutput(moduleNamePrefix + importDeclAST.id.actualText + " = " + importDeclAST.id.actualText); + this.recordSourceMappingEnd(importDeclAST); + this.writeToOutput(";"); + } + this.emitComments(importDeclAST, false); + + this.modAliasId = prevModAliasId; + this.firstModAlias = prevFirstModAlias; + } + }; + + Emitter.prototype.setSourceMappings = function (mapper) { + this.allSourceMappers.push(mapper); + this.sourceMapper = mapper; + }; + + Emitter.prototype.updateLineAndColumn = function (s) { + var lineNumbers = TypeScript.TextUtilities.parseLineStarts(TypeScript.TextFactory.createText(s)); + if (lineNumbers.length > 1) { + this.emitState.line += lineNumbers.length - 1; + this.emitState.column = s.length - lineNumbers[lineNumbers.length - 1]; + } else { + this.emitState.column += s.length; + } + }; + + Emitter.prototype.writeToOutput = function (s) { + this.outfile.Write(s); + this.updateLineAndColumn(s); + }; + + Emitter.prototype.writeToOutputTrimmable = function (s) { + this.writeToOutput(s); + }; + + Emitter.prototype.writeLineToOutput = function (s) { + this.outfile.WriteLine(s); + this.updateLineAndColumn(s); + this.emitState.column = 0; + this.emitState.line++; + }; + + Emitter.prototype.writeCaptureThisStatement = function (ast) { + this.emitIndent(); + this.recordSourceMappingStart(ast); + this.writeToOutput(this.captureThisStmtString); + this.recordSourceMappingEnd(ast); + this.writeLineToOutput(""); + }; + + Emitter.prototype.setInVarBlock = function (count) { + this.varListCountStack[this.varListCountStack.length - 1] = count; + }; + + Emitter.prototype.setContainer = function (c) { + var temp = this.emitState.container; + this.emitState.container = c; + return temp; + }; + + Emitter.prototype.getIndentString = function () { + return this.indenter.getIndent(); + }; + + Emitter.prototype.emitIndent = function () { + this.writeToOutput(this.getIndentString()); + }; + + Emitter.prototype.emitComment = function (comment) { + if (this.emitOptions.compilationSettings.removeComments) { + return; + } + + var text = comment.getText(); + var emitColumn = this.emitState.column; + + if (emitColumn === 0) { + this.emitIndent(); + } + + if (comment.isBlockComment) { + this.recordSourceMappingStart(comment); + this.writeToOutput(text[0]); + + if (text.length > 1 || comment.endsLine) { + for (var i = 1; i < text.length; i++) { + this.writeLineToOutput(""); + this.emitIndent(); + this.writeToOutput(text[i]); + } + this.recordSourceMappingEnd(comment); + this.writeLineToOutput(""); + } else { + this.recordSourceMappingEnd(comment); + this.writeToOutput(" "); + return; + } + } else { + this.recordSourceMappingStart(comment); + this.writeToOutput(text[0]); + this.recordSourceMappingEnd(comment); + this.writeLineToOutput(""); + } + + if (emitColumn != 0) { + this.emitIndent(); + } + }; + + Emitter.prototype.emitComments = function (ast, pre) { + var comments; + if (pre) { + var preComments = ast.preComments(); + if (preComments && ast === this.copyrightElement) { + var copyrightComments = this.getCopyrightComments(); + comments = preComments.slice(copyrightComments.length); + } else { + comments = preComments; + } + } else { + comments = ast.postComments(); + } + + this.emitCommentsArray(comments); + }; + + Emitter.prototype.emitCommentsArray = function (comments) { + if (!this.emitOptions.compilationSettings.removeComments && comments) { + for (var i = 0, n = comments.length; i < n; i++) { + this.emitComment(comments[i]); + } + } + }; + + Emitter.prototype.emitObjectLiteral = function (objectLiteral) { + var useNewLines = !TypeScript.hasFlag(objectLiteral.getFlags(), 2 /* SingleLine */); + + this.writeToOutput("{"); + var list = objectLiteral.operand; + if (list.members.length > 0) { + if (useNewLines) { + this.writeLineToOutput(""); + } else { + this.writeToOutput(" "); + } + + this.indenter.increaseIndent(); + this.emitCommaSeparatedList(list, useNewLines); + this.indenter.decreaseIndent(); + if (useNewLines) { + this.emitIndent(); + } else { + this.writeToOutput(" "); + } + } + this.writeToOutput("}"); + }; + + Emitter.prototype.emitArrayLiteral = function (arrayLiteral) { + var useNewLines = !TypeScript.hasFlag(arrayLiteral.getFlags(), 2 /* SingleLine */); + + this.writeToOutput("["); + var list = arrayLiteral.operand; + if (list.members.length > 0) { + if (useNewLines) { + this.writeLineToOutput(""); + } + + this.indenter.increaseIndent(); + this.emitCommaSeparatedList(list, useNewLines); + this.indenter.decreaseIndent(); + if (useNewLines) { + this.emitIndent(); + } + } + this.writeToOutput("]"); + }; + + Emitter.prototype.emitNew = function (objectCreationExpression, target, args) { + this.writeToOutput("new "); + if (target.nodeType() === 11 /* TypeRef */) { + var typeRef = target; + if (typeRef.arrayCount) { + this.writeToOutput("Array()"); + } else { + typeRef.term.emit(this); + this.writeToOutput("()"); + } + } else { + target.emit(this); + this.recordSourceMappingStart(args); + this.writeToOutput("("); + this.emitCommaSeparatedList(args); + this.recordSourceMappingStart(objectCreationExpression.closeParenSpan); + this.writeToOutput(")"); + this.recordSourceMappingEnd(objectCreationExpression.closeParenSpan); + this.recordSourceMappingEnd(args); + } + }; + + Emitter.prototype.getVarDeclFromIdentifier = function (boundDeclInfo) { + TypeScript.CompilerDiagnostics.assert(boundDeclInfo.boundDecl && boundDeclInfo.boundDecl.init && boundDeclInfo.boundDecl.init.nodeType() === 21 /* Name */, "The init expression of bound declaration when emitting as constant has to be indentifier"); + + var init = boundDeclInfo.boundDecl.init; + var ident = init; + + var pullSymbol = this.semanticInfoChain.getSymbolForAST(boundDeclInfo.boundDecl, this.document.fileName); + + if (pullSymbol) { + var pullDecls = pullSymbol.getDeclarations(); + if (pullDecls.length === 1) { + var pullDecl = pullDecls[0]; + var ast = this.semanticInfoChain.getASTForDecl(pullDecl); + if (ast && ast.nodeType() === 18 /* VariableDeclarator */) { + return { boundDecl: ast, pullDecl: pullDecl }; + } + } + } + + return null; + }; + + Emitter.prototype.getConstantDecl = function (dotExpr) { + var pullSymbol = this.semanticInfoChain.getSymbolForAST(dotExpr, this.document.fileName); + if (pullSymbol && pullSymbol.hasFlag(524288 /* Constant */)) { + var pullDecls = pullSymbol.getDeclarations(); + if (pullDecls.length === 1) { + var pullDecl = pullDecls[0]; + var ast = this.semanticInfoChain.getASTForDecl(pullDecl); + if (ast && ast.nodeType() === 18 /* VariableDeclarator */) { + return { boundDecl: ast, pullDecl: pullDecl }; + } + } + } + + return null; + }; + + Emitter.prototype.tryEmitConstant = function (dotExpr) { + if (!this.emitOptions.compilationSettings.propagateEnumConstants) { + return false; + } + var propertyName = dotExpr.operand2; + var boundDeclInfo = this.getConstantDecl(dotExpr); + if (boundDeclInfo) { + var value = boundDeclInfo.boundDecl.constantValue; + if (value !== null) { + this.writeToOutput(value.toString()); + var comment = " /* "; + comment += propertyName.actualText; + comment += " */"; + this.writeToOutput(comment); + return true; + } + } + + return false; + }; + + Emitter.prototype.emitCall = function (callNode, target, args) { + if (!this.emitSuperCall(callNode)) { + if (target.nodeType() === 13 /* FunctionDeclaration */) { + this.writeToOutput("("); + } + if (callNode.target.nodeType() === 31 /* SuperExpression */ && this.emitState.container === 4 /* Constructor */) { + this.writeToOutput("_super.call"); + } else { + this.emitJavascript(target, false); + } + if (target.nodeType() === 13 /* FunctionDeclaration */) { + this.writeToOutput(")"); + } + this.recordSourceMappingStart(args); + this.writeToOutput("("); + if (callNode.target.nodeType() === 31 /* SuperExpression */ && this.emitState.container === 4 /* Constructor */) { + this.writeToOutput("this"); + if (args && args.members.length) { + this.writeToOutput(", "); + } + } + this.emitCommaSeparatedList(args); + this.recordSourceMappingStart(callNode.closeParenSpan); + this.writeToOutput(")"); + this.recordSourceMappingEnd(callNode.closeParenSpan); + this.recordSourceMappingEnd(args); + } + }; + + Emitter.prototype.emitInnerFunction = function (funcDecl, printName, includePreComments) { + if (typeof includePreComments === "undefined") { includePreComments = true; } + var pullDecl = this.semanticInfoChain.getDeclForAST(funcDecl, this.document.fileName); + this.pushDecl(pullDecl); + + var shouldParenthesize = false; + + if (includePreComments) { + this.emitComments(funcDecl, true); + } + + if (shouldParenthesize) { + this.writeToOutput("("); + } + this.recordSourceMappingStart(funcDecl); + var accessorSymbol = funcDecl.isAccessor() ? TypeScript.PullHelpers.getAccessorSymbol(funcDecl, this.semanticInfoChain, this.document.fileName) : null; + var container = accessorSymbol ? accessorSymbol.getContainer() : null; + var containerKind = container ? container.kind : 0 /* None */; + if (!(funcDecl.isAccessor() && containerKind !== 8 /* Class */ && containerKind !== 33554432 /* ConstructorType */)) { + this.writeToOutput("function "); + } + + if (funcDecl.isConstructor) { + this.writeToOutput(this.thisClassNode.name.actualText); + } + + if (printName) { + var id = funcDecl.getNameText(); + if (id && !funcDecl.isAccessor()) { + if (funcDecl.name) { + this.recordSourceMappingStart(funcDecl.name); + } + this.writeToOutput(id); + if (funcDecl.name) { + this.recordSourceMappingEnd(funcDecl.name); + } + } + } + + this.writeToOutput("("); + var argsLen = 0; + if (funcDecl.arguments) { + this.emitComments(funcDecl.arguments, true); + + var tempContainer = this.setContainer(6 /* Args */); + argsLen = funcDecl.arguments.members.length; + var printLen = argsLen; + if (funcDecl.variableArgList) { + printLen--; + } + for (var i = 0; i < printLen; i++) { + var arg = funcDecl.arguments.members[i]; + arg.emit(this); + + if (i < (printLen - 1)) { + this.writeToOutput(", "); + } + } + this.setContainer(tempContainer); + + this.emitComments(funcDecl.arguments, false); + } + this.writeLineToOutput(") {"); + + if (funcDecl.isConstructor) { + this.recordSourceMappingNameStart("constructor"); + } else if (funcDecl.isGetAccessor()) { + this.recordSourceMappingNameStart("get_" + funcDecl.getNameText()); + } else if (funcDecl.isSetAccessor()) { + this.recordSourceMappingNameStart("set_" + funcDecl.getNameText()); + } else { + this.recordSourceMappingNameStart(funcDecl.getNameText()); + } + this.indenter.increaseIndent(); + + this.emitDefaultValueAssignments(funcDecl); + this.emitRestParameterInitializer(funcDecl); + + if (this.shouldCaptureThis(funcDecl)) { + this.writeCaptureThisStatement(funcDecl); + } + + if (funcDecl.isConstructor) { + this.emitConstructorStatements(funcDecl); + } else { + this.emitModuleElements(funcDecl.block.statements); + } + + this.emitCommentsArray(funcDecl.block.closeBraceLeadingComments); + + this.indenter.decreaseIndent(); + this.emitIndent(); + this.recordSourceMappingStart(funcDecl.block.closeBraceSpan); + this.writeToOutput("}"); + + this.recordSourceMappingNameEnd(); + this.recordSourceMappingEnd(funcDecl.block.closeBraceSpan); + this.recordSourceMappingEnd(funcDecl); + + if (shouldParenthesize) { + this.writeToOutput(")"); + } + + this.recordSourceMappingEnd(funcDecl); + + this.emitComments(funcDecl, false); + + this.popDecl(pullDecl); + }; + + Emitter.prototype.emitDefaultValueAssignments = function (funcDecl) { + var n = funcDecl.arguments.members.length; + if (funcDecl.variableArgList) { + n--; + } + + for (var i = 0; i < n; i++) { + var arg = funcDecl.arguments.members[i]; + if (arg.init) { + this.emitIndent(); + this.recordSourceMappingStart(arg); + this.writeToOutput("if (typeof " + arg.id.actualText + " === \"undefined\") { "); + this.recordSourceMappingStart(arg.id); + this.writeToOutput(arg.id.actualText); + this.recordSourceMappingEnd(arg.id); + this.writeToOutput(" = "); + this.emitJavascript(arg.init, false); + this.writeLineToOutput("; }"); + this.recordSourceMappingEnd(arg); + } + } + }; + + Emitter.prototype.emitRestParameterInitializer = function (funcDecl) { + if (funcDecl.variableArgList) { + var n = funcDecl.arguments.members.length; + var lastArg = funcDecl.arguments.members[n - 1]; + this.emitIndent(); + this.recordSourceMappingStart(lastArg); + this.writeToOutput("var "); + this.recordSourceMappingStart(lastArg.id); + this.writeToOutput(lastArg.id.actualText); + this.recordSourceMappingEnd(lastArg.id); + this.writeLineToOutput(" = [];"); + this.recordSourceMappingEnd(lastArg); + this.emitIndent(); + this.writeToOutput("for ("); + this.recordSourceMappingStart(lastArg); + this.writeToOutput("var _i = 0;"); + this.recordSourceMappingEnd(lastArg); + this.writeToOutput(" "); + this.recordSourceMappingStart(lastArg); + this.writeToOutput("_i < (arguments.length - " + (n - 1) + ")"); + this.recordSourceMappingEnd(lastArg); + this.writeToOutput("; "); + this.recordSourceMappingStart(lastArg); + this.writeToOutput("_i++"); + this.recordSourceMappingEnd(lastArg); + this.writeLineToOutput(") {"); + this.indenter.increaseIndent(); + this.emitIndent(); + + this.recordSourceMappingStart(lastArg); + this.writeToOutput(lastArg.id.actualText + "[_i] = arguments[_i + " + (n - 1) + "];"); + this.recordSourceMappingEnd(lastArg); + this.writeLineToOutput(""); + this.indenter.decreaseIndent(); + this.emitIndent(); + this.writeLineToOutput("}"); + } + }; + + Emitter.prototype.getImportDecls = function (fileName) { + var semanticInfo = this.semanticInfoChain.getUnit(this.document.fileName); + var result = []; + + var queue = semanticInfo.getTopLevelDecls(); + + while (queue.length > 0) { + var decl = queue.shift(); + + if (decl.kind & 256 /* TypeAlias */) { + var importStatementAST = semanticInfo.getASTForDecl(decl); + if (importStatementAST.alias.nodeType() === 21 /* Name */) { + var text = (importStatementAST.alias).actualText; + if (TypeScript.isQuoted(text)) { + var symbol = decl.getSymbol(); + var typeSymbol = symbol && symbol.type; + if (typeSymbol && typeSymbol !== this.semanticInfoChain.anyTypeSymbol && !typeSymbol.isError()) { + result.push(decl); + } + } + } + } + + queue = queue.concat(decl.getChildDecls()); + } + + return result; + }; + + Emitter.prototype.getModuleImportAndDependencyList = function (moduleDecl) { + var importList = ""; + var dependencyList = ""; + + var semanticInfo = this.semanticInfoChain.getUnit(this.document.fileName); + var importDecls = this.getImportDecls(this.document.fileName); + + if (importDecls.length) { + for (var i = 0; i < importDecls.length; i++) { + var importStatementDecl = importDecls[i]; + var importStatementSymbol = importStatementDecl.getSymbol(); + var importStatementAST = semanticInfo.getASTForDecl(importStatementDecl); + + if (importStatementSymbol.isUsedAsValue) { + if (i <= importDecls.length - 1) { + dependencyList += ", "; + importList += ", "; + } + + importList += "__" + importStatementDecl.name + "__"; + dependencyList += importStatementAST.firstAliasedModToString(); + } + } + } + + for (var i = 0; i < moduleDecl.amdDependencies.length; i++) { + dependencyList += ", \"" + moduleDecl.amdDependencies[i] + "\""; + } + + return { + importList: importList, + dependencyList: dependencyList + }; + }; + + Emitter.prototype.shouldCaptureThis = function (ast) { + if (ast.nodeType() === 2 /* Script */) { + var scriptDecl = this.semanticInfoChain.getUnit(this.document.fileName).getTopLevelDecls()[0]; + return (scriptDecl.flags & 262144 /* MustCaptureThis */) === 262144 /* MustCaptureThis */; + } + + var decl = this.semanticInfoChain.getDeclForAST(ast, this.document.fileName); + if (decl) { + return (decl.flags & 262144 /* MustCaptureThis */) === 262144 /* MustCaptureThis */; + } + + return false; + }; + + Emitter.prototype.emitModule = function (moduleDecl) { + var pullDecl = this.semanticInfoChain.getDeclForAST(moduleDecl, this.document.fileName); + this.pushDecl(pullDecl); + + var svModuleName = this.moduleName; + this.moduleName = moduleDecl.name.actualText; + if (TypeScript.isTSFile(this.moduleName)) { + this.moduleName = this.moduleName.substring(0, this.moduleName.length - ".ts".length); + } + + var isDynamicMod = TypeScript.hasFlag(moduleDecl.getModuleFlags(), 512 /* IsDynamic */); + var prevOutFile = this.outfile; + var prevOutFileName = this.emittingFileName; + var prevAllSourceMappers = this.allSourceMappers; + var prevSourceMapper = this.sourceMapper; + var prevColumn = this.emitState.column; + var prevLine = this.emitState.line; + var temp = this.setContainer(1 /* Module */); + var isExported = TypeScript.hasFlag(pullDecl.flags, 1 /* Exported */); + var isWholeFile = TypeScript.hasFlag(moduleDecl.getModuleFlags(), 256 /* IsWholeFile */); + + if (isDynamicMod) { + this.setExportAssignmentIdentifier(null); + this.setContainer(2 /* DynamicModule */); + + this.recordSourceMappingStart(moduleDecl); + if (this.emitOptions.compilationSettings.moduleGenTarget === 2 /* Asynchronous */) { + var dependencyList = "[\"require\", \"exports\""; + var importList = "require, exports"; + + var importAndDependencyList = this.getModuleImportAndDependencyList(moduleDecl); + importList += importAndDependencyList.importList; + dependencyList += importAndDependencyList.dependencyList + "]"; + + this.writeLineToOutput("define(" + dependencyList + "," + " function(" + importList + ") {"); + } + } else { + if (!isExported) { + this.recordSourceMappingStart(moduleDecl); + this.writeToOutput("var "); + this.recordSourceMappingStart(moduleDecl.name); + this.writeToOutput(this.moduleName); + this.recordSourceMappingEnd(moduleDecl.name); + this.writeLineToOutput(";"); + this.recordSourceMappingEnd(moduleDecl); + this.emitIndent(); + } + + this.writeToOutput("("); + this.recordSourceMappingStart(moduleDecl); + this.writeToOutput("function ("); + this.recordSourceMappingStart(moduleDecl.name); + this.writeToOutput(this.moduleName); + this.recordSourceMappingEnd(moduleDecl.name); + this.writeLineToOutput(") {"); + } + + if (!isWholeFile) { + this.recordSourceMappingNameStart(this.moduleName); + } + + if (!isDynamicMod || this.emitOptions.compilationSettings.moduleGenTarget === 2 /* Asynchronous */) { + this.indenter.increaseIndent(); + } + + if (this.shouldCaptureThis(moduleDecl)) { + this.writeCaptureThisStatement(moduleDecl); + } + + this.emitModuleElements(moduleDecl.members); + if (!isDynamicMod || this.emitOptions.compilationSettings.moduleGenTarget === 2 /* Asynchronous */) { + this.indenter.decreaseIndent(); + } + this.emitIndent(); + + if (isDynamicMod) { + var exportAssignmentIdentifier = this.getExportAssignmentIdentifier(); + var exportAssignmentValueSymbol = (pullDecl.getSymbol()).getExportAssignedValueSymbol(); + + if (this.emitOptions.compilationSettings.moduleGenTarget === 2 /* Asynchronous */) { + if (exportAssignmentIdentifier && exportAssignmentValueSymbol && !(exportAssignmentValueSymbol.kind & TypeScript.PullElementKind.SomeTypeReference)) { + this.indenter.increaseIndent(); + this.emitIndent(); + this.writeLineToOutput("return " + exportAssignmentIdentifier + ";"); + this.indenter.decreaseIndent(); + } + this.writeToOutput("});"); + } else if (exportAssignmentIdentifier && exportAssignmentValueSymbol && !(exportAssignmentValueSymbol.kind & TypeScript.PullElementKind.SomeTypeReference)) { + this.emitIndent(); + this.writeLineToOutput("module.exports = " + exportAssignmentIdentifier + ";"); + } + + if (!isWholeFile) { + this.recordSourceMappingNameEnd(); + } + this.recordSourceMappingEnd(moduleDecl); + + if (this.outfile !== prevOutFile) { + this.emitSourceMapsAndClose(); + if (prevSourceMapper !== null) { + this.allSourceMappers = prevAllSourceMappers; + this.sourceMapper = prevSourceMapper; + this.emitState.column = prevColumn; + this.emitState.line = prevLine; + } + this.outfile = prevOutFile; + this.emittingFileName = prevOutFileName; + } + } else { + var parentIsDynamic = temp === 2 /* DynamicModule */; + this.recordSourceMappingStart(moduleDecl.endingToken); + if (temp === 0 /* Prog */ && isExported) { + this.writeToOutput("}"); + if (!isWholeFile) { + this.recordSourceMappingNameEnd(); + } + this.recordSourceMappingEnd(moduleDecl.endingToken); + this.writeToOutput(")(this." + this.moduleName + " || (this." + this.moduleName + " = {}));"); + } else if (isExported || temp === 0 /* Prog */) { + var dotMod = svModuleName !== "" ? (parentIsDynamic ? "exports" : svModuleName) + "." : svModuleName; + this.writeToOutput("}"); + if (!isWholeFile) { + this.recordSourceMappingNameEnd(); + } + this.recordSourceMappingEnd(moduleDecl.endingToken); + this.writeToOutput(")(" + dotMod + this.moduleName + " || (" + dotMod + this.moduleName + " = {}));"); + } else if (!isExported && temp !== 0 /* Prog */) { + this.writeToOutput("}"); + if (!isWholeFile) { + this.recordSourceMappingNameEnd(); + } + this.recordSourceMappingEnd(moduleDecl.endingToken); + this.writeToOutput(")(" + this.moduleName + " || (" + this.moduleName + " = {}));"); + } else { + this.writeToOutput("}"); + if (!isWholeFile) { + this.recordSourceMappingNameEnd(); + } + this.recordSourceMappingEnd(moduleDecl.endingToken); + this.writeToOutput(")();"); + } + + this.recordSourceMappingEnd(moduleDecl); + if (temp !== 0 /* Prog */ && isExported) { + this.recordSourceMappingStart(moduleDecl); + if (parentIsDynamic) { + this.writeLineToOutput(""); + this.emitIndent(); + this.writeToOutput("var " + this.moduleName + " = exports." + this.moduleName + ";"); + } else { + this.writeLineToOutput(""); + this.emitIndent(); + this.writeToOutput("var " + this.moduleName + " = " + svModuleName + "." + this.moduleName + ";"); + } + this.recordSourceMappingEnd(moduleDecl); + } + } + + this.setContainer(temp); + this.moduleName = svModuleName; + + this.popDecl(pullDecl); + }; + + Emitter.prototype.emitEnumElement = function (varDecl) { + this.emitComments(varDecl, true); + this.recordSourceMappingStart(varDecl); + var name = varDecl.id.actualText; + var quoted = TypeScript.isQuoted(name); + this.writeToOutput(this.moduleName); + this.writeToOutput('['); + this.writeToOutput(this.moduleName); + this.writeToOutput('['); + this.writeToOutput(quoted ? name : '"' + name + '"'); + this.writeToOutput('] = '); + + if (varDecl.init) { + varDecl.init.emit(this); + } else if (varDecl.constantValue !== null) { + this.writeToOutput(varDecl.constantValue.toString()); + } else { + this.writeToOutput("null"); + } + + this.writeToOutput('] = '); + this.writeToOutput(quoted ? name : '"' + name + '"'); + this.recordSourceMappingEnd(varDecl); + this.emitComments(varDecl, false); + this.writeToOutput(';'); + }; + + Emitter.prototype.emitIndex = function (operand1, operand2) { + operand1.emit(this); + this.writeToOutput("["); + operand2.emit(this); + this.writeToOutput("]"); + }; + + Emitter.prototype.emitFunction = function (funcDecl) { + if (TypeScript.hasFlag(funcDecl.getFunctionFlags(), 128 /* Signature */)) { + return; + } + var temp; + var tempFnc = this.thisFunctionDeclaration; + this.thisFunctionDeclaration = funcDecl; + + if (funcDecl.isConstructor) { + temp = this.setContainer(4 /* Constructor */); + } else { + temp = this.setContainer(5 /* Function */); + } + + var funcName = funcDecl.getNameText(); + + if (((temp !== 4 /* Constructor */) || ((funcDecl.getFunctionFlags() & 256 /* Method */) === 0 /* None */))) { + this.recordSourceMappingStart(funcDecl); + this.emitInnerFunction(funcDecl, (funcDecl.name && !funcDecl.name.isMissing())); + } + this.setContainer(temp); + this.thisFunctionDeclaration = tempFnc; + + if (!TypeScript.hasFlag(funcDecl.getFunctionFlags(), 128 /* Signature */)) { + var pullFunctionDecl = this.semanticInfoChain.getDeclForAST(funcDecl, this.document.fileName); + if (TypeScript.hasFlag(funcDecl.getFunctionFlags(), 16 /* Static */)) { + if (this.thisClassNode) { + this.writeLineToOutput(""); + if (funcDecl.isAccessor()) { + this.emitPropertyAccessor(funcDecl, this.thisClassNode.name.actualText, false); + } else { + this.emitIndent(); + this.recordSourceMappingStart(funcDecl); + this.writeToOutput(this.thisClassNode.name.actualText + "." + funcName + " = " + funcName + ";"); + this.recordSourceMappingEnd(funcDecl); + } + } + } else if ((this.emitState.container === 1 /* Module */ || this.emitState.container === 2 /* DynamicModule */) && TypeScript.hasFlag(pullFunctionDecl.flags, 1 /* Exported */)) { + this.writeLineToOutput(""); + this.emitIndent(); + var modName = this.emitState.container === 1 /* Module */ ? this.moduleName : "exports"; + this.recordSourceMappingStart(funcDecl); + this.writeToOutput(modName + "." + funcName + " = " + funcName + ";"); + this.recordSourceMappingEnd(funcDecl); + } + } + }; + + Emitter.prototype.emitAmbientVarDecl = function (varDecl) { + if (varDecl.init) { + this.emitComments(varDecl, true); + this.recordSourceMappingStart(varDecl); + this.recordSourceMappingStart(varDecl.id); + this.writeToOutput(varDecl.id.actualText); + this.recordSourceMappingEnd(varDecl.id); + this.writeToOutput(" = "); + this.emitJavascript(varDecl.init, false); + this.recordSourceMappingEnd(varDecl); + this.emitComments(varDecl, false); + } + }; + + Emitter.prototype.varListCount = function () { + return this.varListCountStack[this.varListCountStack.length - 1]; + }; + + Emitter.prototype.emitVarDeclVar = function () { + if (this.varListCount() >= 0) { + this.writeToOutput("var "); + this.setInVarBlock(-this.varListCount()); + } + return true; + }; + + Emitter.prototype.onEmitVar = function () { + if (this.varListCount() > 0) { + this.setInVarBlock(this.varListCount() - 1); + } else if (this.varListCount() < 0) { + this.setInVarBlock(this.varListCount() + 1); + } + }; + + Emitter.prototype.emitVariableDeclaration = function (declaration) { + var varDecl = declaration.declarators.members[0]; + + var symbol = this.semanticInfoChain.getSymbolForAST(varDecl, this.document.fileName); + + var parentSymbol = symbol ? symbol.getContainer() : null; + var parentKind = parentSymbol ? parentSymbol.kind : 0 /* None */; + var inClass = parentKind === 8 /* Class */; + + this.emitComments(declaration, true); + this.recordSourceMappingStart(declaration); + this.setInVarBlock(declaration.declarators.members.length); + + var pullVarDecl = this.semanticInfoChain.getDeclForAST(varDecl, this.document.fileName); + var isAmbientWithoutInit = pullVarDecl && TypeScript.hasFlag(pullVarDecl.flags, 8 /* Ambient */) && varDecl.init === null; + if (!isAmbientWithoutInit) { + for (var i = 0, n = declaration.declarators.members.length; i < n; i++) { + var declarator = declaration.declarators.members[i]; + + if (i > 0) { + if (inClass) { + this.writeToOutputTrimmable(";"); + } else { + this.writeToOutputTrimmable(", "); + } + } + + declarator.emit(this); + } + } + + this.recordSourceMappingEnd(declaration); + this.emitComments(declaration, false); + }; + + Emitter.prototype.emitVariableDeclarator = function (varDecl) { + var pullDecl = this.semanticInfoChain.getDeclForAST(varDecl, this.document.fileName); + this.pushDecl(pullDecl); + if ((pullDecl.flags & 8 /* Ambient */) === 8 /* Ambient */) { + this.emitAmbientVarDecl(varDecl); + this.onEmitVar(); + } else { + this.emitComments(varDecl, true); + this.recordSourceMappingStart(varDecl); + + var symbol = this.semanticInfoChain.getSymbolForAST(varDecl, this.document.fileName); + var parentSymbol = symbol ? symbol.getContainer() : null; + var parentKind = parentSymbol ? parentSymbol.kind : 0 /* None */; + var associatedParentSymbol = parentSymbol ? parentSymbol.getAssociatedContainerType() : null; + var associatedParentSymbolKind = associatedParentSymbol ? associatedParentSymbol.kind : 0 /* None */; + if (parentKind === 8 /* Class */) { + if (this.emitState.container !== 6 /* Args */) { + if (varDecl.isStatic()) { + this.writeToOutput(parentSymbol.getName() + "."); + } else { + this.writeToOutput("this."); + } + } + } else if (TypeScript.PullHelpers.symbolIsModule(parentSymbol) || TypeScript.PullHelpers.symbolIsEnum(parentSymbol) || TypeScript.PullHelpers.symbolIsModule(associatedParentSymbol) || TypeScript.PullHelpers.symbolIsEnum(associatedParentSymbol) || parentKind === 32 /* DynamicModule */ || associatedParentSymbolKind === 32 /* DynamicModule */) { + if (!TypeScript.hasFlag(pullDecl.flags, 1 /* Exported */) && !varDecl.isProperty()) { + this.emitVarDeclVar(); + } else { + if (this.emitState.container === 2 /* DynamicModule */) { + this.writeToOutput("exports."); + } else { + this.writeToOutput(this.moduleName + "."); + } + } + } else { + this.emitVarDeclVar(); + } + + this.recordSourceMappingStart(varDecl.id); + this.writeToOutput(varDecl.id.actualText); + this.recordSourceMappingEnd(varDecl.id); + var hasInitializer = (varDecl.init !== null); + if (hasInitializer) { + this.writeToOutputTrimmable(" = "); + + this.varListCountStack.push(0); + varDecl.init.emit(this); + this.varListCountStack.pop(); + } + + if (parentKind === 8 /* Class */) { + if (this.emitState.container !== 6 /* Args */) { + this.writeToOutput(";"); + } + } + + this.onEmitVar(); + + this.recordSourceMappingEnd(varDecl); + this.emitComments(varDecl, false); + } + this.popDecl(pullDecl); + }; + + Emitter.prototype.symbolIsUsedInItsEnclosingContainer = function (symbol, dynamic) { + if (typeof dynamic === "undefined") { dynamic = false; } + var symDecls = symbol.getDeclarations(); + + if (symDecls.length) { + var enclosingDecl = this.getEnclosingDecl(); + if (enclosingDecl) { + var parentDecl = symDecls[0].getParentDecl(); + if (parentDecl) { + var symbolDeclarationEnclosingContainer = parentDecl; + var enclosingContainer = enclosingDecl; + + while (symbolDeclarationEnclosingContainer) { + if (symbolDeclarationEnclosingContainer.kind === (dynamic ? 32 /* DynamicModule */ : 4 /* Container */)) { + break; + } + symbolDeclarationEnclosingContainer = symbolDeclarationEnclosingContainer.getParentDecl(); + } + + if (symbolDeclarationEnclosingContainer) { + while (enclosingContainer) { + if (enclosingContainer.kind === (dynamic ? 32 /* DynamicModule */ : 4 /* Container */)) { + break; + } + + enclosingContainer = enclosingContainer.getParentDecl(); + } + } + + if (symbolDeclarationEnclosingContainer && enclosingContainer) { + var same = symbolDeclarationEnclosingContainer === enclosingContainer; + + if (!same && symbol.hasFlag(32768 /* InitializedModule */)) { + same = symbolDeclarationEnclosingContainer === enclosingContainer.getParentDecl(); + } + + return same; + } + } + } + } + + return false; + }; + + Emitter.prototype.emitName = function (name, addThis) { + this.emitComments(name, true); + this.recordSourceMappingStart(name); + if (!name.isMissing()) { + var pullSymbol = this.semanticInfoChain.getSymbolForAST(name, this.document.fileName); + if (!pullSymbol) { + pullSymbol = this.semanticInfoChain.anyTypeSymbol; + } + var pullSymbolAlias = this.semanticInfoChain.getAliasSymbolForAST(name, this.document.fileName); + if (pullSymbol && pullSymbolAlias) { + var symbolToCompare = this.resolvingContext.resolvingTypeReference ? pullSymbolAlias.getExportAssignedTypeSymbol() : pullSymbolAlias.getExportAssignedValueSymbol(); + + if (pullSymbol == symbolToCompare) { + pullSymbol = pullSymbolAlias; + pullSymbolAlias = null; + } + } + + var pullSymbolKind = pullSymbol.kind; + var isLocalAlias = pullSymbolAlias && (pullSymbolAlias.getDeclarations()[0].getParentDecl() == this.getEnclosingDecl()); + if (addThis && (this.emitState.container !== 6 /* Args */) && pullSymbol) { + var pullSymbolContainer = pullSymbol.getContainer(); + + if (pullSymbolContainer) { + var pullSymbolContainerKind = pullSymbolContainer.kind; + + if (pullSymbolContainerKind === 8 /* Class */) { + if (pullSymbol.hasFlag(16 /* Static */)) { + this.writeToOutput(pullSymbolContainer.getName() + "."); + } else if (pullSymbolKind === 4096 /* Property */) { + this.emitThis(); + this.writeToOutput("."); + } + } else if (TypeScript.PullHelpers.symbolIsModule(pullSymbolContainer) || pullSymbolContainerKind === 64 /* Enum */ || pullSymbolContainer.hasFlag(32768 /* InitializedModule */ | 131072 /* InitializedEnum */)) { + if (pullSymbolKind === 4096 /* Property */ || pullSymbolKind === 67108864 /* EnumMember */) { + this.writeToOutput(pullSymbolContainer.getDisplayName() + "."); + } else if (pullSymbol.hasFlag(1 /* Exported */) && pullSymbolKind === 1024 /* Variable */ && !pullSymbol.hasFlag(32768 /* InitializedModule */ | 131072 /* InitializedEnum */)) { + this.writeToOutput(pullSymbolContainer.getDisplayName() + "."); + } else if (pullSymbol.hasFlag(1 /* Exported */) && !this.symbolIsUsedInItsEnclosingContainer(pullSymbol)) { + this.writeToOutput(pullSymbolContainer.getDisplayName() + "."); + } + } else if (pullSymbolContainerKind === 32 /* DynamicModule */ || pullSymbolContainer.hasFlag(65536 /* InitializedDynamicModule */)) { + if (pullSymbolKind === 4096 /* Property */) { + this.writeToOutput("exports."); + } else if (pullSymbol.hasFlag(1 /* Exported */) && !isLocalAlias && !pullSymbol.hasFlag(TypeScript.PullElementFlags.ImplicitVariable) && pullSymbol.kind !== 32768 /* ConstructorMethod */ && pullSymbol.kind !== 8 /* Class */ && pullSymbol.kind !== 64 /* Enum */) { + this.writeToOutput("exports."); + } + } else if (pullSymbolKind === 4096 /* Property */) { + if (pullSymbolContainer.kind === 8 /* Class */) { + this.emitThis(); + this.writeToOutput("."); + } + } else { + var pullDecls = pullSymbol.getDeclarations(); + var emitContainerName = true; + for (var i = 0; i < pullDecls.length; i++) { + if (pullDecls[i].getScriptName() === this.document.fileName) { + emitContainerName = false; + } + } + if (emitContainerName) { + this.writeToOutput(pullSymbolContainer.getName() + "."); + } + } + } + } + + if (pullSymbol && pullSymbolKind === 32 /* DynamicModule */) { + if (this.emitOptions.compilationSettings.moduleGenTarget === 2 /* Asynchronous */) { + this.writeToOutput("__" + this.modAliasId + "__"); + } else { + var moduleDecl = this.semanticInfoChain.getASTForSymbol(pullSymbol, this.document.fileName); + var modPath = name.actualText; + var isAmbient = pullSymbol.hasFlag(8 /* Ambient */); + modPath = isAmbient ? modPath : this.firstModAlias ? this.firstModAlias : TypeScript.quoteBaseName(modPath); + modPath = isAmbient ? modPath : (!TypeScript.isRelative(TypeScript.stripQuotes(modPath)) ? TypeScript.quoteStr("./" + TypeScript.stripQuotes(modPath)) : modPath); + this.writeToOutput("require(" + modPath + ")"); + } + } else { + this.writeToOutput(name.actualText); + } + } + + this.recordSourceMappingEnd(name); + this.emitComments(name, false); + }; + + Emitter.prototype.recordSourceMappingNameStart = function (name) { + if (this.sourceMapper) { + var finalName = name; + if (!name) { + finalName = ""; + } else if (this.sourceMapper.currentNameIndex.length > 0) { + finalName = this.sourceMapper.names[this.sourceMapper.currentNameIndex[this.sourceMapper.currentNameIndex.length - 1]] + "." + name; + } + + this.sourceMapper.names.push(finalName); + this.sourceMapper.currentNameIndex.push(this.sourceMapper.names.length - 1); + } + }; + + Emitter.prototype.recordSourceMappingNameEnd = function () { + if (this.sourceMapper) { + this.sourceMapper.currentNameIndex.pop(); + } + }; + + Emitter.prototype.recordSourceMappingStart = function (ast) { + if (this.sourceMapper && TypeScript.isValidAstNode(ast)) { + var lineCol = { line: -1, character: -1 }; + var sourceMapping = new TypeScript.SourceMapping(); + sourceMapping.start.emittedColumn = this.emitState.column; + sourceMapping.start.emittedLine = this.emitState.line; + + var lineMap = this.document.lineMap; + lineMap.fillLineAndCharacterFromPosition(ast.minChar, lineCol); + sourceMapping.start.sourceColumn = lineCol.character; + sourceMapping.start.sourceLine = lineCol.line + 1; + lineMap.fillLineAndCharacterFromPosition(ast.limChar, lineCol); + sourceMapping.end.sourceColumn = lineCol.character; + sourceMapping.end.sourceLine = lineCol.line + 1; + if (this.sourceMapper.currentNameIndex.length > 0) { + sourceMapping.nameIndex = this.sourceMapper.currentNameIndex[this.sourceMapper.currentNameIndex.length - 1]; + } + + var siblings = this.sourceMapper.currentMappings[this.sourceMapper.currentMappings.length - 1]; + siblings.push(sourceMapping); + this.sourceMapper.currentMappings.push(sourceMapping.childMappings); + } + }; + + Emitter.prototype.recordSourceMappingEnd = function (ast) { + if (this.sourceMapper && TypeScript.isValidAstNode(ast)) { + this.sourceMapper.currentMappings.pop(); + + var siblings = this.sourceMapper.currentMappings[this.sourceMapper.currentMappings.length - 1]; + var sourceMapping = siblings[siblings.length - 1]; + + sourceMapping.end.emittedColumn = this.emitState.column; + sourceMapping.end.emittedLine = this.emitState.line; + } + }; + + Emitter.prototype.emitSourceMapsAndClose = function () { + if (this.sourceMapper !== null) { + TypeScript.SourceMapper.emitSourceMapping(this.allSourceMappers); + } + + try { + this.outfile.Close(); + } catch (e) { + Emitter.throwEmitterError(e); + } + }; + + Emitter.prototype.emitParameterPropertyAndMemberVariableAssignments = function () { + var constructorDecl = this.thisClassNode.constructorDecl; + + if (constructorDecl && constructorDecl.arguments) { + for (var i = 0, n = constructorDecl.arguments.members.length; i < n; i++) { + var arg = constructorDecl.arguments.members[i]; + if ((arg.getVarFlags() & 256 /* Property */) !== 0 /* None */) { + this.emitIndent(); + this.recordSourceMappingStart(arg); + this.recordSourceMappingStart(arg.id); + this.writeToOutput("this." + arg.id.actualText); + this.recordSourceMappingEnd(arg.id); + this.writeToOutput(" = "); + this.recordSourceMappingStart(arg.id); + this.writeToOutput(arg.id.actualText); + this.recordSourceMappingEnd(arg.id); + this.writeLineToOutput(";"); + this.recordSourceMappingEnd(arg); + } + } + } + + for (var i = 0, n = this.thisClassNode.members.members.length; i < n; i++) { + if (this.thisClassNode.members.members[i].nodeType() === 18 /* VariableDeclarator */) { + var varDecl = this.thisClassNode.members.members[i]; + if (!TypeScript.hasFlag(varDecl.getVarFlags(), 16 /* Static */) && varDecl.init) { + this.emitIndent(); + this.emitVariableDeclarator(varDecl); + this.writeLineToOutput(""); + } + } + } + }; + + Emitter.prototype.emitCommaSeparatedList = function (list, startLine) { + if (typeof startLine === "undefined") { startLine = false; } + if (list === null) { + return; + } else { + for (var i = 0, n = list.members.length; i < n; i++) { + var emitNode = list.members[i]; + this.emitJavascript(emitNode, startLine); + + if (i < (n - 1)) { + this.writeToOutput(startLine ? "," : ", "); + } + + if (startLine) { + this.writeLineToOutput(""); + } + } + } + }; + + Emitter.prototype.emitModuleElements = function (list) { + if (list === null) { + return; + } + + this.emitComments(list, true); + var lastEmittedNode = null; + + for (var i = 0, n = list.members.length; i < n; i++) { + var node = list.members[i]; + + if (node.shouldEmit()) { + this.emitSpaceBetweenConstructs(lastEmittedNode, node); + + this.emitJavascript(node, true); + this.writeLineToOutput(""); + + lastEmittedNode = node; + } + } + + this.emitComments(list, false); + }; + + Emitter.prototype.isDirectivePrologueElement = function (node) { + if (node.nodeType() === 89 /* ExpressionStatement */) { + var exprStatement = node; + return exprStatement.expression.nodeType() === 5 /* StringLiteral */; + } + + return false; + }; + + Emitter.prototype.emitSpaceBetweenConstructs = function (node1, node2) { + if (node1 === null || node2 === null) { + return; + } + + if (node1.minChar === -1 || node1.limChar === -1 || node2.minChar === -1 || node2.limChar === -1) { + return; + } + + var lineMap = this.document.lineMap; + var node1EndLine = lineMap.getLineNumberFromPosition(node1.limChar); + var node2StartLine = lineMap.getLineNumberFromPosition(node2.minChar); + + if ((node2StartLine - node1EndLine) > 1) { + this.writeLineToOutput(""); + } + }; + + Emitter.prototype.getCopyrightComments = function () { + var preComments = this.copyrightElement.preComments(); + if (preComments) { + var lineMap = this.document.lineMap; + + var copyrightComments = []; + var lastComment = null; + + for (var i = 0, n = preComments.length; i < n; i++) { + var comment = preComments[i]; + + if (lastComment) { + var lastCommentLine = lineMap.getLineNumberFromPosition(lastComment.limChar); + var commentLine = lineMap.getLineNumberFromPosition(comment.minChar); + + if (commentLine >= lastCommentLine + 2) { + return copyrightComments; + } + } + + copyrightComments.push(comment); + lastComment = comment; + } + + var lastCommentLine = lineMap.getLineNumberFromPosition(TypeScript.ArrayUtilities.last(copyrightComments).limChar); + var astLine = lineMap.getLineNumberFromPosition(this.copyrightElement.minChar); + if (astLine >= lastCommentLine + 2) { + return copyrightComments; + } + } + + return []; + }; + + Emitter.prototype.emitPossibleCopyrightHeaders = function (script) { + var list = script.moduleElements; + if (list.members.length > 0) { + var firstElement = list.members[0]; + if (firstElement.nodeType() === 16 /* ModuleDeclaration */) { + var moduleDeclaration = firstElement; + if (moduleDeclaration.isWholeFile()) { + firstElement = moduleDeclaration.members.members[0]; + } + } + + this.copyrightElement = firstElement; + this.emitCommentsArray(this.getCopyrightComments()); + } + }; + + Emitter.prototype.emitScriptElements = function (script) { + var list = script.moduleElements; + + this.emitPossibleCopyrightHeaders(script); + + for (var i = 0, n = list.members.length; i < n; i++) { + var node = list.members[i]; + + if (!this.isDirectivePrologueElement(node)) { + break; + } + + this.emitJavascript(node, true); + this.writeLineToOutput(""); + } + + this.emitPrologue(script); + var lastEmittedNode = null; + + for (; i < n; i++) { + var node = list.members[i]; + + if (node.shouldEmit()) { + this.emitSpaceBetweenConstructs(lastEmittedNode, node); + + this.emitJavascript(node, true); + this.writeLineToOutput(""); + + lastEmittedNode = node; + } + } + }; + + Emitter.prototype.emitConstructorStatements = function (funcDecl) { + var list = funcDecl.block.statements; + + if (list === null) { + return; + } + + this.emitComments(list, true); + + var emitPropertyAssignmentsAfterSuperCall = this.thisClassNode.extendsList && this.thisClassNode.extendsList.members.length > 0; + var propertyAssignmentIndex = emitPropertyAssignmentsAfterSuperCall ? 1 : 0; + var lastEmittedNode = null; + + for (var i = 0, n = list.members.length; i < n; i++) { + if (i === propertyAssignmentIndex) { + this.emitParameterPropertyAndMemberVariableAssignments(); + } + + var node = list.members[i]; + + if (node.shouldEmit()) { + this.emitSpaceBetweenConstructs(lastEmittedNode, node); + + this.emitJavascript(node, true); + this.writeLineToOutput(""); + + lastEmittedNode = node; + } + } + + if (i === propertyAssignmentIndex) { + this.emitParameterPropertyAndMemberVariableAssignments(); + } + + this.emitComments(list, false); + }; + + Emitter.prototype.emitJavascript = function (ast, startLine) { + if (ast === null) { + return; + } + + if (startLine && this.indenter.indentAmt > 0) { + this.emitIndent(); + } + + ast.emit(this); + }; + + Emitter.prototype.emitPropertyAccessor = function (funcDecl, className, isProto) { + if (!TypeScript.hasFlag(funcDecl.getFunctionFlags(), 32 /* GetAccessor */)) { + var accessorSymbol = TypeScript.PullHelpers.getAccessorSymbol(funcDecl, this.semanticInfoChain, this.document.fileName); + if (accessorSymbol.getGetter()) { + return; + } + } + + this.emitIndent(); + this.recordSourceMappingStart(funcDecl); + this.writeLineToOutput("Object.defineProperty(" + className + (isProto ? ".prototype, \"" : ", \"") + funcDecl.name.actualText + "\"" + ", {"); + this.indenter.increaseIndent(); + + var accessors = TypeScript.PullHelpers.getGetterAndSetterFunction(funcDecl, this.semanticInfoChain, this.document.fileName); + if (accessors.getter) { + this.emitIndent(); + this.recordSourceMappingStart(accessors.getter); + this.writeToOutput("get: "); + this.emitInnerFunction(accessors.getter, false); + this.writeLineToOutput(","); + } + + if (accessors.setter) { + this.emitIndent(); + this.recordSourceMappingStart(accessors.setter); + this.writeToOutput("set: "); + this.emitInnerFunction(accessors.setter, false); + this.writeLineToOutput(","); + } + + this.emitIndent(); + this.writeLineToOutput("enumerable: true,"); + this.emitIndent(); + this.writeLineToOutput("configurable: true"); + this.indenter.decreaseIndent(); + this.emitIndent(); + this.writeLineToOutput("});"); + this.recordSourceMappingEnd(funcDecl); + }; + + Emitter.prototype.emitPrototypeMember = function (funcDecl, className) { + if (funcDecl.isAccessor()) { + this.emitPropertyAccessor(funcDecl, className, true); + } else { + this.emitIndent(); + this.recordSourceMappingStart(funcDecl); + this.emitComments(funcDecl, true); + this.writeToOutput(className + ".prototype." + funcDecl.getNameText() + " = "); + this.emitInnerFunction(funcDecl, false, false); + this.writeLineToOutput(";"); + } + }; + + Emitter.prototype.emitClass = function (classDecl) { + var pullDecl = this.semanticInfoChain.getDeclForAST(classDecl, this.document.fileName); + this.pushDecl(pullDecl); + + var svClassNode = this.thisClassNode; + this.thisClassNode = classDecl; + var className = classDecl.name.actualText; + this.emitComments(classDecl, true); + var temp = this.setContainer(3 /* Class */); + + this.recordSourceMappingStart(classDecl); + this.writeToOutput("var " + className); + + var hasBaseClass = classDecl.extendsList && classDecl.extendsList.members.length; + var baseNameDecl = null; + var baseName = null; + var varDecl = null; + + if (hasBaseClass) { + this.writeLineToOutput(" = (function (_super) {"); + } else { + this.writeLineToOutput(" = (function () {"); + } + + this.recordSourceMappingNameStart(className); + this.indenter.increaseIndent(); + + if (hasBaseClass) { + baseNameDecl = classDecl.extendsList.members[0]; + baseName = baseNameDecl.nodeType() === 37 /* InvocationExpression */ ? (baseNameDecl).target : baseNameDecl; + this.emitIndent(); + this.writeLineToOutput("__extends(" + className + ", _super);"); + } + + this.emitIndent(); + + var constrDecl = classDecl.constructorDecl; + + if (constrDecl) { + constrDecl.emit(this); + this.writeLineToOutput(""); + } else { + this.recordSourceMappingStart(classDecl); + + this.indenter.increaseIndent(); + this.writeLineToOutput("function " + classDecl.name.actualText + "() {"); + this.recordSourceMappingNameStart("constructor"); + if (hasBaseClass) { + this.emitIndent(); + this.writeLineToOutput("_super.apply(this, arguments);"); + } + + if (this.shouldCaptureThis(classDecl)) { + this.writeCaptureThisStatement(classDecl); + } + + this.emitParameterPropertyAndMemberVariableAssignments(); + + this.indenter.decreaseIndent(); + this.emitIndent(); + this.writeLineToOutput("}"); + + this.recordSourceMappingNameEnd(); + this.recordSourceMappingEnd(classDecl); + } + + this.emitClassMembers(classDecl); + + this.emitIndent(); + this.recordSourceMappingStart(classDecl.endingToken); + this.writeLineToOutput("return " + className + ";"); + this.recordSourceMappingEnd(classDecl.endingToken); + this.indenter.decreaseIndent(); + this.emitIndent(); + this.recordSourceMappingStart(classDecl.endingToken); + this.writeToOutput("}"); + this.recordSourceMappingNameEnd(); + this.recordSourceMappingEnd(classDecl.endingToken); + this.recordSourceMappingStart(classDecl); + this.writeToOutput(")("); + if (hasBaseClass) { + this.resolvingContext.resolvingTypeReference = true; + this.emitJavascript(baseName, false); + this.resolvingContext.resolvingTypeReference = false; + } + this.writeToOutput(");"); + this.recordSourceMappingEnd(classDecl); + + if ((temp === 1 /* Module */ || temp === 2 /* DynamicModule */) && TypeScript.hasFlag(pullDecl.flags, 1 /* Exported */)) { + this.writeLineToOutput(""); + this.emitIndent(); + var modName = temp === 1 /* Module */ ? this.moduleName : "exports"; + this.recordSourceMappingStart(classDecl); + this.writeToOutput(modName + "." + className + " = " + className + ";"); + this.recordSourceMappingEnd(classDecl); + } + + this.recordSourceMappingEnd(classDecl); + this.emitComments(classDecl, false); + this.setContainer(temp); + this.thisClassNode = svClassNode; + + this.popDecl(pullDecl); + }; + + Emitter.prototype.emitClassMembers = function (classDecl) { + var lastEmittedMember = null; + + for (var i = 0, n = classDecl.members.members.length; i < n; i++) { + var memberDecl = classDecl.members.members[i]; + + if (memberDecl.nodeType() === 13 /* FunctionDeclaration */) { + var fn = memberDecl; + + if (TypeScript.hasFlag(fn.getFunctionFlags(), 256 /* Method */) && !fn.isSignature()) { + this.emitSpaceBetweenConstructs(lastEmittedMember, fn); + + if (!TypeScript.hasFlag(fn.getFunctionFlags(), 16 /* Static */)) { + this.emitPrototypeMember(fn, classDecl.name.actualText); + } else { + if (fn.isAccessor()) { + this.emitPropertyAccessor(fn, this.thisClassNode.name.actualText, false); + } else { + this.emitIndent(); + this.recordSourceMappingStart(fn); + this.writeToOutput(classDecl.name.actualText + "." + fn.name.actualText + " = "); + this.emitInnerFunction(fn, false); + this.writeLineToOutput(";"); + } + } + + lastEmittedMember = fn; + } + } + } + + for (var i = 0, n = classDecl.members.members.length; i < n; i++) { + var memberDecl = classDecl.members.members[i]; + + if (memberDecl.nodeType() === 18 /* VariableDeclarator */) { + var varDecl = memberDecl; + + if (TypeScript.hasFlag(varDecl.getVarFlags(), 16 /* Static */) && varDecl.init) { + this.emitSpaceBetweenConstructs(lastEmittedMember, varDecl); + + this.emitIndent(); + this.recordSourceMappingStart(varDecl); + this.writeToOutput(classDecl.name.actualText + "." + varDecl.id.actualText + " = "); + varDecl.init.emit(this); + + this.writeLineToOutput(";"); + this.recordSourceMappingEnd(varDecl); + + lastEmittedMember = varDecl; + } + } + } + }; + + Emitter.prototype.requiresExtendsBlock = function (moduleElements) { + for (var i = 0, n = moduleElements.members.length; i < n; i++) { + var moduleElement = moduleElements.members[i]; + + if (moduleElement.nodeType() === 16 /* ModuleDeclaration */) { + if (this.requiresExtendsBlock((moduleElement).members)) { + return true; + } + } else if (moduleElement.nodeType() === 14 /* ClassDeclaration */) { + var classDeclaration = moduleElement; + + if (classDeclaration.extendsList && classDeclaration.extendsList.members.length > 0) { + return true; + } + } + } + + return false; + }; + + Emitter.prototype.emitPrologue = function (script) { + if (!this.extendsPrologueEmitted) { + if (this.requiresExtendsBlock(script.moduleElements)) { + this.extendsPrologueEmitted = true; + this.writeLineToOutput("var __extends = this.__extends || function (d, b) {"); + this.writeLineToOutput(" for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];"); + this.writeLineToOutput(" function __() { this.constructor = d; }"); + this.writeLineToOutput(" __.prototype = b.prototype;"); + this.writeLineToOutput(" d.prototype = new __();"); + this.writeLineToOutput("};"); + } + } + + if (!this.globalThisCapturePrologueEmitted) { + if (this.shouldCaptureThis(script)) { + this.globalThisCapturePrologueEmitted = true; + this.writeLineToOutput(this.captureThisStmtString); + } + } + }; + + Emitter.prototype.emitSuperReference = function () { + this.writeToOutput("_super.prototype"); + }; + + Emitter.prototype.emitSuperCall = function (callEx) { + if (callEx.target.nodeType() === 33 /* MemberAccessExpression */) { + var dotNode = callEx.target; + if (dotNode.operand1.nodeType() === 31 /* SuperExpression */) { + dotNode.emit(this); + this.writeToOutput(".call("); + this.emitThis(); + if (callEx.arguments && callEx.arguments.members.length > 0) { + this.writeToOutput(", "); + this.emitCommaSeparatedList(callEx.arguments); + } + this.writeToOutput(")"); + return true; + } + } + return false; + }; + + Emitter.prototype.emitThis = function () { + if (this.thisFunctionDeclaration && !this.thisFunctionDeclaration.isMethod() && (!this.thisFunctionDeclaration.isConstructor)) { + this.writeToOutput("_this"); + } else { + this.writeToOutput("this"); + } + }; + + Emitter.prototype.emitBlockOrStatement = function (node) { + if (node.nodeType() === 82 /* Block */) { + node.emit(this); + } else { + this.writeLineToOutput(""); + this.indenter.increaseIndent(); + this.emitJavascript(node, true); + this.indenter.decreaseIndent(); + } + }; + + Emitter.throwEmitterError = function (e) { + var error = new Error(e.message); + error.isEmitterError = true; + throw error; + }; + + Emitter.handleEmitterError = function (fileName, e) { + if ((e).isEmitterError === true) { + return [new TypeScript.Diagnostic(fileName, 0, 0, TypeScript.DiagnosticCode.Emit_Error_0, [e.message])]; + } + + throw e; + }; + return Emitter; + })(); + TypeScript.Emitter = Emitter; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var MemberName = (function () { + function MemberName() { + this.prefix = ""; + this.suffix = ""; + } + MemberName.prototype.isString = function () { + return false; + }; + MemberName.prototype.isArray = function () { + return false; + }; + MemberName.prototype.isMarker = function () { + return !this.isString() && !this.isArray(); + }; + + MemberName.prototype.toString = function () { + return MemberName.memberNameToString(this); + }; + + MemberName.memberNameToString = function (memberName, markerInfo, markerBaseLength) { + if (typeof markerBaseLength === "undefined") { markerBaseLength = 0; } + var result = memberName.prefix; + + if (memberName.isString()) { + result += (memberName).text; + } else if (memberName.isArray()) { + var ar = memberName; + for (var index = 0; index < ar.entries.length; index++) { + if (ar.entries[index].isMarker()) { + if (markerInfo) { + markerInfo.push(markerBaseLength + result.length); + } + continue; + } + + result += MemberName.memberNameToString(ar.entries[index], markerInfo, markerBaseLength + result.length); + result += ar.delim; + } + } + + result += memberName.suffix; + return result; + }; + + MemberName.create = function (arg1, arg2, arg3) { + if (typeof arg1 === "string") { + return new MemberNameString(arg1); + } else { + var result = new MemberNameArray(); + if (arg2) + result.prefix = arg2; + if (arg3) + result.suffix = arg3; + result.entries.push(arg1); + return result; + } + }; + return MemberName; + })(); + TypeScript.MemberName = MemberName; + + var MemberNameString = (function (_super) { + __extends(MemberNameString, _super); + function MemberNameString(text) { + _super.call(this); + this.text = text; + } + MemberNameString.prototype.isString = function () { + return true; + }; + return MemberNameString; + })(MemberName); + TypeScript.MemberNameString = MemberNameString; + + var MemberNameArray = (function (_super) { + __extends(MemberNameArray, _super); + function MemberNameArray() { + _super.call(this); + this.delim = ""; + this.entries = []; + } + MemberNameArray.prototype.isArray = function () { + return true; + }; + + MemberNameArray.prototype.add = function (entry) { + this.entries.push(entry); + }; + + MemberNameArray.prototype.addAll = function (entries) { + for (var i = 0; i < entries.length; i++) { + this.entries.push(entries[i]); + } + }; + return MemberNameArray; + })(MemberName); + TypeScript.MemberNameArray = MemberNameArray; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var quoteRegEx = /["']/g; + function stripQuotes(str) { + return str.replace(quoteRegEx, ""); + } + TypeScript.stripQuotes = stripQuotes; + + function isSingleQuoted(str) { + return str.indexOf("'") !== -1; + } + TypeScript.isSingleQuoted = isSingleQuoted; + + function isQuoted(str) { + return str.indexOf("\"") !== -1 || isSingleQuoted(str); + } + TypeScript.isQuoted = isQuoted; + + function quoteStr(str) { + return "\"" + str + "\""; + } + TypeScript.quoteStr = quoteStr; + + function swapQuotes(str) { + if (str.indexOf("\"") !== -1) { + str = str.replace("\"", "'"); + str = str.replace("\"", "'"); + } else { + str = str.replace("'", "\""); + str = str.replace("'", "\""); + } + + return str; + } + TypeScript.swapQuotes = swapQuotes; + + var switchToForwardSlashesRegEx = /\\/g; + function switchToForwardSlashes(path) { + return path.replace(switchToForwardSlashesRegEx, "/"); + } + TypeScript.switchToForwardSlashes = switchToForwardSlashes; + + function trimModName(modName) { + if (modName.length > 5 && modName.substring(modName.length - 5, modName.length) === ".d.ts") { + return modName.substring(0, modName.length - 5); + } + if (modName.length > 3 && modName.substring(modName.length - 3, modName.length) === ".ts") { + return modName.substring(0, modName.length - 3); + } + + if (modName.length > 3 && modName.substring(modName.length - 3, modName.length) === ".js") { + return modName.substring(0, modName.length - 3); + } + + return modName; + } + TypeScript.trimModName = trimModName; + + function getDeclareFilePath(fname) { + return isTSFile(fname) ? changePathToDTS(fname) : changePathToDTS(fname); + } + TypeScript.getDeclareFilePath = getDeclareFilePath; + + function isFileOfExtension(fname, ext) { + var invariantFname = fname.toLocaleUpperCase(); + var invariantExt = ext.toLocaleUpperCase(); + var extLength = invariantExt.length; + return invariantFname.length > extLength && invariantFname.substring(invariantFname.length - extLength, invariantFname.length) === invariantExt; + } + + function isJSFile(fname) { + return isFileOfExtension(fname, ".js"); + } + TypeScript.isJSFile = isJSFile; + + function isTSFile(fname) { + return isFileOfExtension(fname, ".ts"); + } + TypeScript.isTSFile = isTSFile; + + function isDTSFile(fname) { + return isFileOfExtension(fname, ".d.ts"); + } + TypeScript.isDTSFile = isDTSFile; + + function getPrettyName(modPath, quote, treatAsFileName) { + if (typeof quote === "undefined") { quote = true; } + if (typeof treatAsFileName === "undefined") { treatAsFileName = false; } + var modName = treatAsFileName ? switchToForwardSlashes(modPath) : trimModName(stripQuotes(modPath)); + var components = this.getPathComponents(modName); + return components.length ? (quote ? quoteStr(components[components.length - 1]) : components[components.length - 1]) : modPath; + } + TypeScript.getPrettyName = getPrettyName; + + function getPathComponents(path) { + return path.split("/"); + } + TypeScript.getPathComponents = getPathComponents; + + function getRelativePathToFixedPath(fixedModFilePath, absoluteModPath, isAbsoultePathURL) { + if (typeof isAbsoultePathURL === "undefined") { isAbsoultePathURL = true; } + absoluteModPath = switchToForwardSlashes(absoluteModPath); + + var modComponents = this.getPathComponents(absoluteModPath); + var fixedModComponents = this.getPathComponents(fixedModFilePath); + + var joinStartIndex = 0; + for (; joinStartIndex < modComponents.length && joinStartIndex < fixedModComponents.length; joinStartIndex++) { + if (fixedModComponents[joinStartIndex] !== modComponents[joinStartIndex]) { + break; + } + } + + if (joinStartIndex !== 0) { + var relativePath = ""; + var relativePathComponents = modComponents.slice(joinStartIndex, modComponents.length); + for (; joinStartIndex < fixedModComponents.length; joinStartIndex++) { + if (fixedModComponents[joinStartIndex] !== "") { + relativePath = relativePath + "../"; + } + } + + return relativePath + relativePathComponents.join("/"); + } + + if (isAbsoultePathURL && absoluteModPath.indexOf("://") === -1) { + absoluteModPath = "file:///" + absoluteModPath; + } + + return absoluteModPath; + } + TypeScript.getRelativePathToFixedPath = getRelativePathToFixedPath; + + function quoteBaseName(modPath) { + var modName = trimModName(stripQuotes(modPath)); + var path = getRootFilePath(modName); + if (path === "") { + return modPath; + } else { + var components = modName.split(path); + var fileIndex = components.length > 1 ? 1 : 0; + return quoteStr(components[fileIndex]); + } + } + TypeScript.quoteBaseName = quoteBaseName; + + function changePathToDTS(modPath) { + return trimModName(stripQuotes(modPath)) + ".d.ts"; + } + TypeScript.changePathToDTS = changePathToDTS; + + function isRelative(path) { + return path.length > 0 && path.charAt(0) === "."; + } + TypeScript.isRelative = isRelative; + function isRooted(path) { + return path.length > 0 && (path.charAt(0) === "\\" || path.charAt(0) === "/" || (path.indexOf(":\\") !== -1) || (path.indexOf(":/") !== -1)); + } + TypeScript.isRooted = isRooted; + + function getRootFilePath(outFname) { + if (outFname === "") { + return outFname; + } else { + var isPath = outFname.indexOf("/") !== -1; + return isPath ? filePath(outFname) : ""; + } + } + TypeScript.getRootFilePath = getRootFilePath; + + function filePathComponents(fullPath) { + fullPath = switchToForwardSlashes(fullPath); + var components = getPathComponents(fullPath); + return components.slice(0, components.length - 1); + } + TypeScript.filePathComponents = filePathComponents; + + function filePath(fullPath) { + var path = filePathComponents(fullPath); + return path.join("/") + "/"; + } + TypeScript.filePath = filePath; + + var normalizePathRegEx = /^\\\\[^\\]/; + function normalizePath(path) { + if (normalizePathRegEx.test(path)) { + path = "file:" + path; + } + var parts = this.getPathComponents(switchToForwardSlashes(path)); + var normalizedParts = []; + + for (var i = 0; i < parts.length; i++) { + var part = parts[i]; + if (part === ".") { + continue; + } + + if (normalizedParts.length > 0 && TypeScript.ArrayUtilities.last(normalizedParts) !== ".." && part === "..") { + normalizedParts.pop(); + continue; + } + + normalizedParts.push(part); + } + + return normalizedParts.join("/"); + } + TypeScript.normalizePath = normalizePath; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var CompilationSettings = (function () { + function CompilationSettings() { + this.propagateEnumConstants = false; + this.removeComments = false; + this.watch = false; + this.noResolve = false; + this.allowAutomaticSemicolonInsertion = true; + this.noImplicitAny = false; + this.noLib = false; + this.codeGenTarget = 0 /* EcmaScript3 */; + this.moduleGenTarget = 0 /* Unspecified */; + this.outFileOption = ""; + this.outDirOption = ""; + this.mapSourceFiles = false; + this.mapRoot = ""; + this.sourceRoot = ""; + this.generateDeclarationFiles = false; + this.useCaseSensitiveFileResolution = false; + this.gatherDiagnostics = false; + this.updateTC = false; + } + return CompilationSettings; + })(); + TypeScript.CompilationSettings = CompilationSettings; + + function getFileReferenceFromReferencePath(comment) { + var referencesRegEx = /^(\/\/\/\s*/gim; + var match = referencesRegEx.exec(comment); + + if (match) { + var path = TypeScript.normalizePath(match[3]); + var adjustedPath = TypeScript.normalizePath(path); + + var isResident = match.length >= 7 && match[6] === "true"; + if (isResident) { + TypeScript.CompilerDiagnostics.debugPrint(path + " is resident"); + } + return { + line: 0, + character: 0, + position: 0, + length: 0, + path: TypeScript.switchToForwardSlashes(adjustedPath), + isResident: isResident + }; + } else { + return null; + } + } + + function getImplicitImport(comment) { + var implicitImportRegEx = /^(\/\/\/\s*/gim; + var match = implicitImportRegEx.exec(comment); + + if (match) { + return true; + } + + return false; + } + TypeScript.getImplicitImport = getImplicitImport; + + function getReferencedFiles(fileName, sourceText) { + var preProcessInfo = preProcessFile(fileName, sourceText, null, false); + return preProcessInfo.referencedFiles; + } + TypeScript.getReferencedFiles = getReferencedFiles; + + var scannerWindow = TypeScript.ArrayUtilities.createArray(2048, 0); + var scannerDiagnostics = []; + + function processImports(lineMap, scanner, token, importedFiles) { + var position = 0; + var lineChar = { line: -1, character: -1 }; + + while (token.tokenKind !== 10 /* EndOfFileToken */) { + if (token.tokenKind === 49 /* ImportKeyword */) { + var importStart = position + token.leadingTriviaWidth(); + token = scanner.scan(scannerDiagnostics, false); + + if (TypeScript.SyntaxFacts.isIdentifierNameOrAnyKeyword(token)) { + token = scanner.scan(scannerDiagnostics, false); + + if (token.tokenKind === 107 /* EqualsToken */) { + token = scanner.scan(scannerDiagnostics, false); + + if (token.tokenKind === 65 /* ModuleKeyword */ || token.tokenKind === 66 /* RequireKeyword */) { + token = scanner.scan(scannerDiagnostics, false); + + if (token.tokenKind === 72 /* OpenParenToken */) { + var afterOpenParenPosition = scanner.absoluteIndex(); + token = scanner.scan(scannerDiagnostics, false); + + lineMap.fillLineAndCharacterFromPosition(importStart, lineChar); + + if (token.tokenKind === 14 /* StringLiteral */) { + var ref = { + line: lineChar.line, + character: lineChar.character, + position: afterOpenParenPosition + token.leadingTriviaWidth(), + length: token.width(), + path: TypeScript.stripQuotes(TypeScript.switchToForwardSlashes(token.text())), + isResident: false + }; + importedFiles.push(ref); + } + } + } + } + } + } + + position = scanner.absoluteIndex(); + token = scanner.scan(scannerDiagnostics, false); + } + } + + function processTripleSlashDirectives(lineMap, firstToken, settings, referencedFiles) { + var leadingTrivia = firstToken.leadingTrivia(); + + var position = 0; + var lineChar = { line: -1, character: -1 }; + var noDefaultLib = false; + + for (var i = 0, n = leadingTrivia.count(); i < n; i++) { + var trivia = leadingTrivia.syntaxTriviaAt(i); + + if (trivia.kind() === 7 /* SingleLineCommentTrivia */) { + var triviaText = trivia.fullText(); + var referencedCode = getFileReferenceFromReferencePath(triviaText); + + if (referencedCode) { + lineMap.fillLineAndCharacterFromPosition(position, lineChar); + referencedCode.position = position; + referencedCode.length = trivia.fullWidth(); + referencedCode.line = lineChar.line; + referencedCode.character = lineChar.character; + + referencedFiles.push(referencedCode); + } + + if (settings) { + var isNoDefaultLibRegex = /^(\/\/\/\s*/gim; + var isNoDefaultLibMatch = isNoDefaultLibRegex.exec(triviaText); + if (isNoDefaultLibMatch) { + noDefaultLib = (isNoDefaultLibMatch[3] === "true"); + } + } + } + + position += trivia.fullWidth(); + } + + return { noDefaultLib: noDefaultLib }; + } + + function preProcessFile(fileName, sourceText, settings, readImportFiles) { + if (typeof readImportFiles === "undefined") { readImportFiles = true; } + settings = settings || new CompilationSettings(); + + var text = TypeScript.SimpleText.fromScriptSnapshot(sourceText); + var scanner = new TypeScript.Scanner(fileName, text, settings.codeGenTarget, scannerWindow); + + var firstToken = scanner.scan(scannerDiagnostics, false); + + var importedFiles = []; + if (readImportFiles) { + processImports(text.lineMap(), scanner, firstToken, importedFiles); + } + + var referencedFiles = []; + var properties = processTripleSlashDirectives(text.lineMap(), firstToken, settings, referencedFiles); + + scannerDiagnostics.length = 0; + return { settings: settings, referencedFiles: referencedFiles, importedFiles: importedFiles, isLibFile: properties.noDefaultLib }; + } + TypeScript.preProcessFile = preProcessFile; + + function getParseOptions(settings) { + return new TypeScript.ParseOptions(settings.codeGenTarget, settings.allowAutomaticSemicolonInsertion); + } + TypeScript.getParseOptions = getParseOptions; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var ReferenceResolutionResult = (function () { + function ReferenceResolutionResult() { + this.resolvedFiles = []; + this.diagnostics = []; + this.seenNoDefaultLibTag = false; + } + return ReferenceResolutionResult; + })(); + TypeScript.ReferenceResolutionResult = ReferenceResolutionResult; + + var ReferenceLocation = (function () { + function ReferenceLocation(filePath, position, length, isImported) { + this.filePath = filePath; + this.position = position; + this.length = length; + this.isImported = isImported; + } + return ReferenceLocation; + })(); + + var ReferenceResolver = (function () { + function ReferenceResolver(inputFileNames, host, settings) { + this.inputFileNames = inputFileNames; + this.host = host; + this.settings = settings; + this.visited = {}; + } + ReferenceResolver.resolve = function (inputFileNames, host, settings) { + var resolver = new ReferenceResolver(inputFileNames, host, settings); + return resolver.resolveInputFiles(); + }; + + ReferenceResolver.prototype.resolveInputFiles = function () { + var result = new ReferenceResolutionResult(); + + if (!this.inputFileNames || this.inputFileNames.length <= 0) { + return result; + } + + var referenceLocation = new ReferenceLocation(null, 0, 0, false); + for (var i = 0, n = this.inputFileNames.length; i < n; i++) { + this.resolveIncludedFile(this.inputFileNames[i], referenceLocation, result); + } + + return result; + }; + + ReferenceResolver.prototype.resolveIncludedFile = function (path, referenceLocation, resolutionResult) { + var normalizedPath = this.getNormalizedFilePath(path, referenceLocation.filePath); + + if (this.isSameFile(normalizedPath, referenceLocation.filePath)) { + if (!referenceLocation.isImported) { + resolutionResult.diagnostics.push(new TypeScript.Diagnostic(referenceLocation.filePath, referenceLocation.position, referenceLocation.length, TypeScript.DiagnosticCode.A_file_cannot_have_a_reference_to_itself, null)); + } + + return normalizedPath; + } + + if (!TypeScript.isTSFile(normalizedPath) && !TypeScript.isDTSFile(normalizedPath)) { + var dtsFile = normalizedPath + ".d.ts"; + var tsFile = normalizedPath + ".ts"; + + if (this.host.fileExists(dtsFile)) { + normalizedPath = dtsFile; + } else { + normalizedPath = tsFile; + } + } + + if (!this.host.fileExists(normalizedPath)) { + if (!referenceLocation.isImported) { + resolutionResult.diagnostics.push(new TypeScript.Diagnostic(referenceLocation.filePath, referenceLocation.position, referenceLocation.length, TypeScript.DiagnosticCode.Cannot_resolve_referenced_file_0, [path])); + } + + return normalizedPath; + } + + return this.resolveFile(normalizedPath, resolutionResult); + }; + + ReferenceResolver.prototype.resolveImportedFile = function (path, referenceLocation, resolutionResult) { + var isRelativePath = TypeScript.isRelative(path); + var isRootedPath = isRelativePath ? false : TypeScript.isRooted(path); + + if (isRelativePath || isRootedPath) { + return this.resolveIncludedFile(path, referenceLocation, resolutionResult); + } else { + var parentDirectory = this.host.getParentDirectory(referenceLocation.filePath); + var searchFilePath = null; + var dtsFileName = path + ".d.ts"; + var tsFilePath = path + ".ts"; + + do { + var currentFilePath = this.host.resolveRelativePath(dtsFileName, parentDirectory); + if (this.host.fileExists(currentFilePath)) { + searchFilePath = currentFilePath; + break; + } + + currentFilePath = this.host.resolveRelativePath(tsFilePath, parentDirectory); + if (this.host.fileExists(currentFilePath)) { + searchFilePath = currentFilePath; + break; + } + + parentDirectory = this.host.getParentDirectory(parentDirectory); + } while(parentDirectory); + + if (!searchFilePath) { + return path; + } + + return this.resolveFile(searchFilePath, resolutionResult); + } + }; + + ReferenceResolver.prototype.resolveFile = function (normalizedPath, resolutionResult) { + var visitedPath = this.isVisited(normalizedPath); + if (!visitedPath) { + this.recordVisitedFile(normalizedPath); + + var preprocessedFileInformation = TypeScript.preProcessFile(normalizedPath, this.host.getScriptSnapshot(normalizedPath), this.settings); + + if (preprocessedFileInformation.isLibFile) { + resolutionResult.seenNoDefaultLibTag = true; + } + + var normalizedReferencePaths = []; + for (var i = 0, n = preprocessedFileInformation.referencedFiles.length; i < n; i++) { + var fileReference = preprocessedFileInformation.referencedFiles[i]; + var currentReferenceLocation = new ReferenceLocation(normalizedPath, fileReference.position, fileReference.length, false); + var normalizedReferencePath = this.resolveIncludedFile(fileReference.path, currentReferenceLocation, resolutionResult); + normalizedReferencePaths.push(normalizedReferencePath); + } + + var normalizedImportPaths = []; + for (var i = 0; i < preprocessedFileInformation.importedFiles.length; i++) { + var fileImport = preprocessedFileInformation.importedFiles[i]; + var currentReferenceLocation = new ReferenceLocation(normalizedPath, fileImport.position, fileImport.length, true); + var normalizedImportPath = this.resolveImportedFile(fileImport.path, currentReferenceLocation, resolutionResult); + normalizedImportPaths.push(normalizedImportPath); + } + + resolutionResult.resolvedFiles.push({ + path: normalizedPath, + referencedFiles: normalizedReferencePaths, + importedFiles: normalizedImportPaths + }); + } else { + normalizedPath = visitedPath; + } + + return normalizedPath; + }; + + ReferenceResolver.prototype.getNormalizedFilePath = function (path, parentFilePath) { + var parentFileDirectory = parentFilePath ? this.host.getParentDirectory(parentFilePath) : ""; + var normalizedPath = this.host.resolveRelativePath(path, parentFileDirectory); + return normalizedPath; + }; + + ReferenceResolver.prototype.getUniqueFileId = function (filePath) { + return this.settings.useCaseSensitiveFileResolution ? filePath : filePath.toLocaleUpperCase(); + }; + + ReferenceResolver.prototype.recordVisitedFile = function (filePath) { + this.visited[this.getUniqueFileId(filePath)] = filePath; + }; + + ReferenceResolver.prototype.isVisited = function (filePath) { + return this.visited[this.getUniqueFileId(filePath)]; + }; + + ReferenceResolver.prototype.isSameFile = function (filePath1, filePath2) { + if (!filePath1 || !filePath2) { + return false; + } + + if (this.settings.useCaseSensitiveFileResolution) { + return filePath1 === filePath2; + } else { + return filePath1.toLocaleUpperCase() === filePath2.toLocaleUpperCase(); + } + }; + return ReferenceResolver; + })(); + TypeScript.ReferenceResolver = ReferenceResolver; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var TextWriter = (function () { + function TextWriter(ioHost, path, writeByteOrderMark) { + this.ioHost = ioHost; + this.path = path; + this.writeByteOrderMark = writeByteOrderMark; + this.contents = ""; + this.onNewLine = true; + } + TextWriter.prototype.Write = function (s) { + this.contents += s; + this.onNewLine = false; + }; + + TextWriter.prototype.WriteLine = function (s) { + this.contents += s; + this.contents += TypeScript.newLine(); + this.onNewLine = true; + }; + + TextWriter.prototype.Close = function () { + try { + this.ioHost.writeFile(this.path, this.contents, this.writeByteOrderMark); + } catch (e) { + TypeScript.Emitter.throwEmitterError(e); + } + }; + return TextWriter; + })(); + TypeScript.TextWriter = TextWriter; + + var DeclarationEmitter = (function () { + function DeclarationEmitter(emittingFileName, document, compiler) { + this.emittingFileName = emittingFileName; + this.document = document; + this.compiler = compiler; + this.declFile = null; + this.indenter = new TypeScript.Indenter(); + this.declarationContainerStack = []; + this.isDottedModuleName = []; + this.ignoreCallbackAst = null; + this.varListCount = 0; + this.emittedReferencePaths = false; + this.declFile = new TextWriter(this.compiler.emitOptions.ioHost, emittingFileName, this.document.byteOrderMark !== 0 /* None */); + } + DeclarationEmitter.prototype.widenType = function (type) { + if (type === this.compiler.semanticInfoChain.undefinedTypeSymbol || type === this.compiler.semanticInfoChain.nullTypeSymbol) { + return this.compiler.semanticInfoChain.anyTypeSymbol; + } + + return type; + }; + + DeclarationEmitter.prototype.close = function () { + try { + this.declFile.Close(); + } catch (e) { + TypeScript.Emitter.throwEmitterError(e); + } + }; + + DeclarationEmitter.prototype.emitDeclarations = function (script) { + var _this = this; + var walk = function (pre, ast) { + switch (ast.nodeType()) { + case 98 /* VariableStatement */: + return _this.variableStatementCallback(pre, ast); + case 19 /* VariableDeclaration */: + return _this.variableDeclarationCallback(pre, ast); + case 18 /* VariableDeclarator */: + return _this.variableDeclaratorCallback(pre, ast); + case 82 /* Block */: + return _this.blockCallback(pre, ast); + case 13 /* FunctionDeclaration */: + return _this.functionDeclarationCallback(pre, ast); + case 14 /* ClassDeclaration */: + return _this.classDeclarationCallback(pre, ast); + case 15 /* InterfaceDeclaration */: + return _this.interfaceDeclarationCallback(pre, ast); + case 17 /* ImportDeclaration */: + return _this.importDeclarationCallback(pre, ast); + case 16 /* ModuleDeclaration */: + return _this.moduleDeclarationCallback(pre, ast); + case 88 /* ExportAssignment */: + return _this.exportAssignmentCallback(pre, ast); + case 2 /* Script */: + return _this.scriptCallback(pre, ast); + default: + return _this.defaultCallback(pre, ast); + } + }; + + TypeScript.getAstWalkerFactory().walk(script, function (ast, parent, walker) { + walker.options.goChildren = walk(true, ast); + return ast; + }, function (ast, parent, walker) { + walker.options.goChildren = walk(false, ast); + return ast; + }); + }; + + DeclarationEmitter.prototype.getAstDeclarationContainer = function () { + return this.declarationContainerStack[this.declarationContainerStack.length - 1]; + }; + + DeclarationEmitter.prototype.emitDottedModuleName = function () { + return (this.isDottedModuleName.length === 0) ? false : this.isDottedModuleName[this.isDottedModuleName.length - 1]; + }; + + DeclarationEmitter.prototype.getIndentString = function (declIndent) { + if (typeof declIndent === "undefined") { declIndent = false; } + return this.indenter.getIndent(); + }; + + DeclarationEmitter.prototype.emitIndent = function () { + this.declFile.Write(this.getIndentString()); + }; + + DeclarationEmitter.prototype.canEmitSignature = function (declFlags, declAST, canEmitGlobalAmbientDecl, useDeclarationContainerTop) { + if (typeof canEmitGlobalAmbientDecl === "undefined") { canEmitGlobalAmbientDecl = true; } + if (typeof useDeclarationContainerTop === "undefined") { useDeclarationContainerTop = true; } + var container; + if (useDeclarationContainerTop) { + container = this.getAstDeclarationContainer(); + } else { + container = this.declarationContainerStack[this.declarationContainerStack.length - 2]; + } + + var pullDecl = this.compiler.semanticInfoChain.getDeclForAST(declAST, this.document.fileName); + if (container.nodeType() === 16 /* ModuleDeclaration */) { + if (!TypeScript.hasFlag(pullDecl.flags, 1 /* Exported */)) { + var start = new Date().getTime(); + var declSymbol = this.compiler.semanticInfoChain.getSymbolForAST(declAST, this.document.fileName); + var result = declSymbol && declSymbol.isExternallyVisible(); + TypeScript.declarationEmitIsExternallyVisibleTime += new Date().getTime() - start; + + return result; + } + } + + if (!canEmitGlobalAmbientDecl && container.nodeType() === 2 /* Script */ && TypeScript.hasFlag(pullDecl.flags, 8 /* Ambient */)) { + return false; + } + + return true; + }; + + DeclarationEmitter.prototype.canEmitPrePostAstSignature = function (declFlags, astWithPrePostCallback, preCallback) { + if (this.ignoreCallbackAst) { + TypeScript.CompilerDiagnostics.assert(this.ignoreCallbackAst !== astWithPrePostCallback, "Ignore Callback AST mismatch"); + this.ignoreCallbackAst = null; + return false; + } else if (preCallback && !this.canEmitSignature(declFlags, astWithPrePostCallback, true, preCallback)) { + this.ignoreCallbackAst = astWithPrePostCallback; + return false; + } + + return true; + }; + + DeclarationEmitter.prototype.getDeclFlagsString = function (declFlags, pullDecl, typeString) { + var result = this.getIndentString(); + var pullFlags = pullDecl.flags; + + if (TypeScript.hasFlag(declFlags, 16 /* Static */)) { + if (TypeScript.hasFlag(declFlags, 2 /* Private */)) { + result += "private "; + } + result += "static "; + } else { + if (TypeScript.hasFlag(declFlags, 2 /* Private */)) { + result += "private "; + } else if (TypeScript.hasFlag(declFlags, 4 /* Public */)) { + result += "public "; + } else { + var emitDeclare = !TypeScript.hasFlag(pullFlags, 1 /* Exported */); + + var container = this.getAstDeclarationContainer(); + if (container.nodeType() === 16 /* ModuleDeclaration */ && TypeScript.hasFlag((container).getModuleFlags(), 256 /* IsWholeFile */) && TypeScript.hasFlag(pullFlags, 1 /* Exported */)) { + result += "export "; + emitDeclare = true; + } + + if (emitDeclare && typeString !== "interface" && typeString != "import") { + result += "declare "; + } + + result += typeString + " "; + } + } + + return result; + }; + + DeclarationEmitter.prototype.emitDeclFlags = function (declFlags, pullDecl, typeString) { + this.declFile.Write(this.getDeclFlagsString(declFlags, pullDecl, typeString)); + }; + + DeclarationEmitter.prototype.canEmitTypeAnnotationSignature = function (declFlag) { + if (typeof declFlag === "undefined") { declFlag = 0 /* None */; } + return !TypeScript.hasFlag(declFlag, 2 /* Private */); + }; + + DeclarationEmitter.prototype.pushDeclarationContainer = function (ast) { + this.declarationContainerStack.push(ast); + }; + + DeclarationEmitter.prototype.popDeclarationContainer = function (ast) { + TypeScript.CompilerDiagnostics.assert(ast !== this.getAstDeclarationContainer(), 'Declaration container mismatch'); + this.declarationContainerStack.pop(); + }; + + DeclarationEmitter.prototype.emitTypeNamesMember = function (memberName, emitIndent) { + if (typeof emitIndent === "undefined") { emitIndent = false; } + if (memberName.prefix === "{ ") { + if (emitIndent) { + this.emitIndent(); + } + + this.declFile.WriteLine("{"); + this.indenter.increaseIndent(); + emitIndent = true; + } else if (memberName.prefix !== "") { + if (emitIndent) { + this.emitIndent(); + } + + this.declFile.Write(memberName.prefix); + emitIndent = false; + } + + if (memberName.isString()) { + if (emitIndent) { + this.emitIndent(); + } + + this.declFile.Write((memberName).text); + } else if (memberName.isArray()) { + var ar = memberName; + for (var index = 0; index < ar.entries.length; index++) { + this.emitTypeNamesMember(ar.entries[index], emitIndent); + if (ar.delim === "; ") { + this.declFile.WriteLine(";"); + } + } + } + + if (memberName.suffix === "}") { + this.indenter.decreaseIndent(); + this.emitIndent(); + this.declFile.Write(memberName.suffix); + } else { + this.declFile.Write(memberName.suffix); + } + }; + + DeclarationEmitter.prototype.emitTypeSignature = function (type) { + var declarationContainerAst = this.getAstDeclarationContainer(); + + var start = new Date().getTime(); + var declarationContainerDecl = this.compiler.semanticInfoChain.getDeclForAST(declarationContainerAst, this.document.fileName); + var declarationPullSymbol = declarationContainerDecl.getSymbol(); + TypeScript.declarationEmitTypeSignatureTime += new Date().getTime() - start; + + var typeNameMembers = type.getScopedNameEx(declarationPullSymbol); + this.emitTypeNamesMember(typeNameMembers); + }; + + DeclarationEmitter.prototype.emitComment = function (comment) { + var text = comment.getText(); + if (this.declFile.onNewLine) { + this.emitIndent(); + } else if (!comment.isBlockComment) { + this.declFile.WriteLine(""); + this.emitIndent(); + } + + this.declFile.Write(text[0]); + + for (var i = 1; i < text.length; i++) { + this.declFile.WriteLine(""); + this.emitIndent(); + this.declFile.Write(text[i]); + } + + if (comment.endsLine || !comment.isBlockComment) { + this.declFile.WriteLine(""); + } else { + this.declFile.Write(" "); + } + }; + + DeclarationEmitter.prototype.emitDeclarationComments = function (astOrSymbol, endLine) { + if (typeof endLine === "undefined") { endLine = true; } + if (this.compiler.emitOptions.compilationSettings.removeComments) { + return; + } + + var declComments = astOrSymbol.docComments(); + this.writeDeclarationComments(declComments, endLine); + }; + + DeclarationEmitter.prototype.writeDeclarationComments = function (declComments, endLine) { + if (typeof endLine === "undefined") { endLine = true; } + if (declComments.length > 0) { + for (var i = 0; i < declComments.length; i++) { + this.emitComment(declComments[i]); + } + + if (endLine) { + if (!this.declFile.onNewLine) { + this.declFile.WriteLine(""); + } + } else { + if (this.declFile.onNewLine) { + this.emitIndent(); + } + } + } + }; + + DeclarationEmitter.prototype.emitTypeOfBoundDecl = function (boundDecl) { + var start = new Date().getTime(); + var decl = this.compiler.semanticInfoChain.getDeclForAST(boundDecl, this.document.fileName); + var pullSymbol = decl.getSymbol(); + TypeScript.declarationEmitGetBoundDeclTypeTime += new Date().getTime() - start; + + var type = this.widenType(pullSymbol.type); + if (!type) { + return; + } + + if (boundDecl.typeExpr || (boundDecl.init && type !== this.compiler.semanticInfoChain.anyTypeSymbol)) { + this.declFile.Write(": "); + this.emitTypeSignature(type); + } + }; + + DeclarationEmitter.prototype.variableDeclaratorCallback = function (pre, varDecl) { + if (pre && this.canEmitSignature(TypeScript.ToDeclFlags(varDecl.getVarFlags()), varDecl, false)) { + var interfaceMember = (this.getAstDeclarationContainer().nodeType() === 15 /* InterfaceDeclaration */); + this.emitDeclarationComments(varDecl); + if (!interfaceMember) { + if (this.varListCount >= 0) { + this.emitDeclFlags(TypeScript.ToDeclFlags(varDecl.getVarFlags()), this.compiler.semanticInfoChain.getDeclForAST(varDecl, this.document.fileName), "var"); + this.varListCount = -this.varListCount; + } + + this.declFile.Write(varDecl.id.actualText); + } else { + this.emitIndent(); + this.declFile.Write(varDecl.id.actualText); + if (TypeScript.hasFlag(varDecl.id.getFlags(), 4 /* OptionalName */)) { + this.declFile.Write("?"); + } + } + + if (this.canEmitTypeAnnotationSignature(TypeScript.ToDeclFlags(varDecl.getVarFlags()))) { + this.emitTypeOfBoundDecl(varDecl); + } + + if (this.varListCount > 0) { + this.varListCount--; + } else if (this.varListCount < 0) { + this.varListCount++; + } + + if (this.varListCount < 0) { + this.declFile.Write(", "); + } else { + this.declFile.WriteLine(";"); + } + } + return false; + }; + + DeclarationEmitter.prototype.blockCallback = function (pre, block) { + return false; + }; + + DeclarationEmitter.prototype.variableStatementCallback = function (pre, variableStatement) { + return true; + }; + + DeclarationEmitter.prototype.variableDeclarationCallback = function (pre, variableDeclaration) { + if (pre) { + this.varListCount = variableDeclaration.declarators.members.length; + } else { + this.varListCount = 0; + } + + return true; + }; + + DeclarationEmitter.prototype.emitArgDecl = function (argDecl, funcDecl) { + this.indenter.increaseIndent(); + + this.emitDeclarationComments(argDecl, false); + this.declFile.Write(argDecl.id.actualText); + if (argDecl.isOptionalArg()) { + this.declFile.Write("?"); + } + + this.indenter.decreaseIndent(); + + if (this.canEmitTypeAnnotationSignature(TypeScript.ToDeclFlags(funcDecl.getFunctionFlags()))) { + this.emitTypeOfBoundDecl(argDecl); + } + }; + + DeclarationEmitter.prototype.isOverloadedCallSignature = function (funcDecl) { + var start = new Date().getTime(); + var functionDecl = this.compiler.semanticInfoChain.getDeclForAST(funcDecl, this.document.fileName); + var funcSymbol = functionDecl.getSymbol(); + TypeScript.declarationEmitIsOverloadedCallSignatureTime += new Date().getTime() - start; + + var funcTypeSymbol = funcSymbol.type; + var signatures = funcTypeSymbol.getCallSignatures(); + var result = signatures && signatures.length > 1; + + return result; + }; + + DeclarationEmitter.prototype.functionDeclarationCallback = function (pre, funcDecl) { + if (!pre) { + return false; + } + + if (funcDecl.isAccessor()) { + return this.emitPropertyAccessorSignature(funcDecl); + } + + var isInterfaceMember = (this.getAstDeclarationContainer().nodeType() === 15 /* InterfaceDeclaration */); + + var start = new Date().getTime(); + var funcSymbol = this.compiler.semanticInfoChain.getSymbolForAST(funcDecl, this.document.fileName); + + TypeScript.declarationEmitFunctionDeclarationGetSymbolTime += new Date().getTime() - start; + + var funcTypeSymbol = funcSymbol.type; + if (funcDecl.block) { + var constructSignatures = funcTypeSymbol.getConstructSignatures(); + if (constructSignatures && constructSignatures.length > 1) { + return false; + } else if (this.isOverloadedCallSignature(funcDecl)) { + return false; + } + } else if (!isInterfaceMember && TypeScript.hasFlag(funcDecl.getFunctionFlags(), 2 /* Private */) && this.isOverloadedCallSignature(funcDecl)) { + var callSignatures = funcTypeSymbol.getCallSignatures(); + TypeScript.Debug.assert(callSignatures && callSignatures.length > 1); + var firstSignature = callSignatures[0].isDefinition() ? callSignatures[1] : callSignatures[0]; + var firstSignatureDecl = firstSignature.getDeclarations()[0]; + var firstFuncDecl = this.compiler.semanticInfoChain.getASTForDecl(firstSignatureDecl); + if (firstFuncDecl !== funcDecl) { + return false; + } + } + + if (!this.canEmitSignature(TypeScript.ToDeclFlags(funcDecl.getFunctionFlags()), funcDecl, false)) { + return false; + } + + var funcPullDecl = this.compiler.semanticInfoChain.getDeclForAST(funcDecl, this.document.fileName); + var funcSignature = funcPullDecl.getSignatureSymbol(); + this.emitDeclarationComments(funcDecl); + if (funcDecl.isConstructor) { + this.emitIndent(); + this.declFile.Write("constructor"); + this.emitTypeParameters(funcDecl.typeArguments, funcSignature); + } else { + var id = funcDecl.getNameText(); + if (!isInterfaceMember) { + this.emitDeclFlags(TypeScript.ToDeclFlags(funcDecl.getFunctionFlags()), funcPullDecl, "function"); + if (id !== "__missing" || !funcDecl.name || !funcDecl.name.isMissing()) { + this.declFile.Write(id); + } else if (funcDecl.isConstructMember()) { + this.declFile.Write("new"); + } + + this.emitTypeParameters(funcDecl.typeArguments, funcSignature); + } else { + this.emitIndent(); + if (funcDecl.isConstructMember()) { + this.declFile.Write("new"); + this.emitTypeParameters(funcDecl.typeArguments, funcSignature); + } else if (!funcDecl.isCallMember() && !funcDecl.isIndexerMember()) { + this.declFile.Write(id); + this.emitTypeParameters(funcDecl.typeArguments, funcSignature); + if (TypeScript.hasFlag(funcDecl.name.getFlags(), 4 /* OptionalName */)) { + this.declFile.Write("? "); + } + } else { + this.emitTypeParameters(funcDecl.typeArguments, funcSignature); + } + } + } + + if (!funcDecl.isIndexerMember()) { + this.declFile.Write("("); + } else { + this.declFile.Write("["); + } + + if (funcDecl.arguments) { + var argsLen = funcDecl.arguments.members.length; + if (funcDecl.variableArgList) { + argsLen--; + } + + for (var i = 0; i < argsLen; i++) { + var argDecl = funcDecl.arguments.members[i]; + this.emitArgDecl(argDecl, funcDecl); + if (i < (argsLen - 1)) { + this.declFile.Write(", "); + } + } + } + + if (funcDecl.variableArgList) { + var lastArg = funcDecl.arguments.members[funcDecl.arguments.members.length - 1]; + if (funcDecl.arguments.members.length > 1) { + this.declFile.Write(", ..."); + } else { + this.declFile.Write("..."); + } + + this.emitArgDecl(lastArg, funcDecl); + } + + if (!funcDecl.isIndexerMember()) { + this.declFile.Write(")"); + } else { + this.declFile.Write("]"); + } + + if (!funcDecl.isConstructor && this.canEmitTypeAnnotationSignature(TypeScript.ToDeclFlags(funcDecl.getFunctionFlags()))) { + var returnType = funcSignature.returnType; + if (funcDecl.returnTypeAnnotation || (returnType && returnType !== this.compiler.semanticInfoChain.anyTypeSymbol)) { + this.declFile.Write(": "); + this.emitTypeSignature(returnType); + } + } + + this.declFile.WriteLine(";"); + + return false; + }; + + DeclarationEmitter.prototype.emitBaseExpression = function (bases, index) { + var start = new Date().getTime(); + var baseTypeAndDiagnostics = this.compiler.semanticInfoChain.getSymbolForAST(bases.members[index], this.document.fileName); + TypeScript.declarationEmitGetBaseTypeTime += new Date().getTime() - start; + + var baseType = baseTypeAndDiagnostics && baseTypeAndDiagnostics; + this.emitTypeSignature(baseType); + }; + + DeclarationEmitter.prototype.emitBaseList = function (typeDecl, useExtendsList) { + var bases = useExtendsList ? typeDecl.extendsList : typeDecl.implementsList; + if (bases && (bases.members.length > 0)) { + var qual = useExtendsList ? "extends" : "implements"; + this.declFile.Write(" " + qual + " "); + var basesLen = bases.members.length; + for (var i = 0; i < basesLen; i++) { + if (i > 0) { + this.declFile.Write(", "); + } + this.emitBaseExpression(bases, i); + } + } + }; + + DeclarationEmitter.prototype.emitAccessorDeclarationComments = function (funcDecl) { + if (this.compiler.emitOptions.compilationSettings.removeComments) { + return; + } + + var start = new Date().getTime(); + var accessors = TypeScript.PullHelpers.getGetterAndSetterFunction(funcDecl, this.compiler.semanticInfoChain, this.document.fileName); + TypeScript.declarationEmitGetAccessorFunctionTime += new Date().getTime(); + + var comments = []; + if (accessors.getter) { + comments = comments.concat(accessors.getter.docComments()); + } + if (accessors.setter) { + comments = comments.concat(accessors.setter.docComments()); + } + + this.writeDeclarationComments(comments); + }; + + DeclarationEmitter.prototype.emitPropertyAccessorSignature = function (funcDecl) { + var start = new Date().getTime(); + var accessorSymbol = TypeScript.PullHelpers.getAccessorSymbol(funcDecl, this.compiler.semanticInfoChain, this.document.fileName); + TypeScript.declarationEmitGetAccessorFunctionTime += new Date().getTime(); + + if (!TypeScript.hasFlag(funcDecl.getFunctionFlags(), 32 /* GetAccessor */) && accessorSymbol.getGetter()) { + return false; + } + + this.emitAccessorDeclarationComments(funcDecl); + this.emitDeclFlags(TypeScript.ToDeclFlags(funcDecl.getFunctionFlags()), this.compiler.semanticInfoChain.getDeclForAST(funcDecl, this.document.fileName), "var"); + this.declFile.Write(funcDecl.name.actualText); + if (this.canEmitTypeAnnotationSignature(TypeScript.ToDeclFlags(funcDecl.getFunctionFlags()))) { + this.declFile.Write(" : "); + var type = accessorSymbol.type; + this.emitTypeSignature(type); + } + this.declFile.WriteLine(";"); + + return false; + }; + + DeclarationEmitter.prototype.emitClassMembersFromConstructorDefinition = function (funcDecl) { + if (funcDecl.arguments) { + var argsLen = funcDecl.arguments.members.length; + if (funcDecl.variableArgList) { + argsLen--; + } + + for (var i = 0; i < argsLen; i++) { + var argDecl = funcDecl.arguments.members[i]; + if (TypeScript.hasFlag(argDecl.getVarFlags(), 256 /* Property */)) { + var funcPullDecl = this.compiler.semanticInfoChain.getDeclForAST(funcDecl, this.document.fileName); + this.emitDeclarationComments(argDecl); + this.emitDeclFlags(TypeScript.ToDeclFlags(argDecl.getVarFlags()), funcPullDecl, "var"); + this.declFile.Write(argDecl.id.actualText); + + if (this.canEmitTypeAnnotationSignature(TypeScript.ToDeclFlags(argDecl.getVarFlags()))) { + this.emitTypeOfBoundDecl(argDecl); + } + this.declFile.WriteLine(";"); + } + } + } + }; + + DeclarationEmitter.prototype.classDeclarationCallback = function (pre, classDecl) { + if (!this.canEmitPrePostAstSignature(TypeScript.ToDeclFlags(classDecl.getVarFlags()), classDecl, pre)) { + return false; + } + + if (pre) { + var className = classDecl.name.actualText; + this.emitDeclarationComments(classDecl); + var classPullDecl = this.compiler.semanticInfoChain.getDeclForAST(classDecl, this.document.fileName); + this.emitDeclFlags(TypeScript.ToDeclFlags(classDecl.getVarFlags()), classPullDecl, "class"); + this.declFile.Write(className); + this.pushDeclarationContainer(classDecl); + this.emitTypeParameters(classDecl.typeParameters); + this.emitBaseList(classDecl, true); + this.emitBaseList(classDecl, false); + this.declFile.WriteLine(" {"); + + this.indenter.increaseIndent(); + if (classDecl.constructorDecl) { + this.emitClassMembersFromConstructorDefinition(classDecl.constructorDecl); + } + } else { + this.indenter.decreaseIndent(); + this.popDeclarationContainer(classDecl); + + this.emitIndent(); + this.declFile.WriteLine("}"); + } + + return true; + }; + + DeclarationEmitter.prototype.emitTypeParameters = function (typeParams, funcSignature) { + if (!typeParams || !typeParams.members.length) { + return; + } + + this.declFile.Write("<"); + var containerAst = this.getAstDeclarationContainer(); + + var start = new Date().getTime(); + var containerDecl = this.compiler.semanticInfoChain.getDeclForAST(containerAst, this.document.fileName); + var containerSymbol = containerDecl.getSymbol(); + TypeScript.declarationEmitGetTypeParameterSymbolTime += new Date().getTime() - start; + + var typars; + if (funcSignature) { + typars = funcSignature.getTypeParameters(); + } else { + typars = containerSymbol.getTypeArguments(); + if (!typars || !typars.length) { + typars = containerSymbol.getTypeParameters(); + } + } + + for (var i = 0; i < typars.length; i++) { + if (i) { + this.declFile.Write(", "); + } + + var memberName = typars[i].getScopedNameEx(containerSymbol, true); + this.emitTypeNamesMember(memberName); + } + + this.declFile.Write(">"); + }; + + DeclarationEmitter.prototype.interfaceDeclarationCallback = function (pre, interfaceDecl) { + if (!this.canEmitPrePostAstSignature(TypeScript.ToDeclFlags(interfaceDecl.getVarFlags()), interfaceDecl, pre)) { + return false; + } + + if (interfaceDecl.isObjectTypeLiteral) { + return false; + } + + if (pre) { + var interfaceName = interfaceDecl.name.actualText; + this.emitDeclarationComments(interfaceDecl); + var interfacePullDecl = this.compiler.semanticInfoChain.getDeclForAST(interfaceDecl, this.document.fileName); + this.emitDeclFlags(TypeScript.ToDeclFlags(interfaceDecl.getVarFlags()), interfacePullDecl, "interface"); + this.declFile.Write(interfaceName); + this.pushDeclarationContainer(interfaceDecl); + this.emitTypeParameters(interfaceDecl.typeParameters); + this.emitBaseList(interfaceDecl, true); + this.declFile.WriteLine(" {"); + + this.indenter.increaseIndent(); + } else { + this.indenter.decreaseIndent(); + this.popDeclarationContainer(interfaceDecl); + + this.emitIndent(); + this.declFile.WriteLine("}"); + } + + return true; + }; + + DeclarationEmitter.prototype.importDeclarationCallback = function (pre, importDeclAST) { + if (pre) { + var importDecl = this.compiler.semanticInfoChain.getDeclForAST(importDeclAST, this.document.fileName); + var importSymbol = importDecl.getSymbol(); + var isExportedImportDecl = TypeScript.hasFlag(importDeclAST.getVarFlags(), 1 /* Exported */); + + if (isExportedImportDecl || importSymbol.typeUsedExternally || TypeScript.PullContainerTypeSymbol.usedAsSymbol(importSymbol.getContainer(), importSymbol)) { + this.emitDeclarationComments(importDeclAST); + this.emitIndent(); + if (isExportedImportDecl) { + this.declFile.Write("export "); + } + this.declFile.Write("import "); + this.declFile.Write(importDeclAST.id.actualText + " = "); + if (importDeclAST.isExternalImportDeclaration()) { + this.declFile.WriteLine("require(" + importDeclAST.getAliasName() + ");"); + } else { + this.declFile.WriteLine(importDeclAST.getAliasName() + ";"); + } + } + } + + return false; + }; + + DeclarationEmitter.prototype.emitEnumSignature = function (moduleDecl) { + if (!this.canEmitSignature(TypeScript.ToDeclFlags(moduleDecl.getModuleFlags()), moduleDecl)) { + return false; + } + + this.emitDeclarationComments(moduleDecl); + var modulePullDecl = this.compiler.semanticInfoChain.getDeclForAST(moduleDecl, this.document.fileName); + this.emitDeclFlags(TypeScript.ToDeclFlags(moduleDecl.getModuleFlags()), modulePullDecl, "enum"); + this.declFile.WriteLine(moduleDecl.name.actualText + " {"); + + this.indenter.increaseIndent(); + var membersLen = moduleDecl.members.members.length; + for (var j = 0; j < membersLen; j++) { + var memberDecl = moduleDecl.members.members[j]; + var variableStatement = memberDecl; + var varDeclarator = variableStatement.declaration.declarators.members[0]; + this.emitDeclarationComments(varDeclarator); + this.emitIndent(); + this.declFile.Write(varDeclarator.id.actualText); + if (varDeclarator.init && varDeclarator.init.nodeType() == 7 /* NumericLiteral */) { + this.declFile.Write(" = " + (varDeclarator.init).text()); + } + this.declFile.WriteLine(","); + } + this.indenter.decreaseIndent(); + + this.emitIndent(); + this.declFile.WriteLine("}"); + + return false; + }; + + DeclarationEmitter.prototype.moduleDeclarationCallback = function (pre, moduleDecl) { + if (TypeScript.hasFlag(moduleDecl.getModuleFlags(), 256 /* IsWholeFile */)) { + if (TypeScript.hasFlag(moduleDecl.getModuleFlags(), 512 /* IsDynamic */)) { + if (pre) { + this.pushDeclarationContainer(moduleDecl); + } else { + this.popDeclarationContainer(moduleDecl); + } + } + + return true; + } + + if (moduleDecl.isEnum()) { + if (pre) { + this.emitEnumSignature(moduleDecl); + } + return false; + } + + if (!this.canEmitPrePostAstSignature(TypeScript.ToDeclFlags(moduleDecl.getModuleFlags()), moduleDecl, pre)) { + return false; + } + + if (pre) { + if (this.emitDottedModuleName()) { + this.dottedModuleEmit += "."; + } else { + var modulePullDecl = this.compiler.semanticInfoChain.getDeclForAST(moduleDecl, this.document.fileName); + this.dottedModuleEmit = this.getDeclFlagsString(TypeScript.ToDeclFlags(moduleDecl.getModuleFlags()), modulePullDecl, "module"); + } + + this.dottedModuleEmit += moduleDecl.name.actualText; + + var isCurrentModuleDotted = (moduleDecl.members.members.length === 1 && moduleDecl.members.members[0].nodeType() === 16 /* ModuleDeclaration */ && !(moduleDecl.members.members[0]).isEnum() && TypeScript.hasFlag((moduleDecl.members.members[0]).getModuleFlags(), 1 /* Exported */)); + + var moduleDeclComments = moduleDecl.docComments(); + isCurrentModuleDotted = isCurrentModuleDotted && (moduleDeclComments === null || moduleDeclComments.length === 0); + + this.isDottedModuleName.push(isCurrentModuleDotted); + this.pushDeclarationContainer(moduleDecl); + + if (!isCurrentModuleDotted) { + this.emitDeclarationComments(moduleDecl); + this.declFile.Write(this.dottedModuleEmit); + this.declFile.WriteLine(" {"); + this.indenter.increaseIndent(); + } + } else { + if (!this.emitDottedModuleName()) { + this.indenter.decreaseIndent(); + this.emitIndent(); + this.declFile.WriteLine("}"); + } + + this.popDeclarationContainer(moduleDecl); + this.isDottedModuleName.pop(); + } + + return true; + }; + + DeclarationEmitter.prototype.exportAssignmentCallback = function (pre, ast) { + if (pre) { + this.emitIndent(); + this.declFile.Write("export = "); + this.declFile.Write(ast.id.actualText); + this.declFile.WriteLine(";"); + } + + return false; + }; + + DeclarationEmitter.prototype.emitReferencePaths = function (script) { + if (this.emittedReferencePaths) { + return; + } + + var documents = []; + if (this.compiler.emitOptions.outputMany || script.topLevelMod) { + var scriptReferences = script.referencedFiles; + var addedGlobalDocument = false; + for (var j = 0; j < scriptReferences.length; j++) { + var currentReference = scriptReferences[j]; + var document = this.compiler.getDocument(currentReference); + + if (this.compiler.emitOptions.outputMany || document.script.isDeclareFile || document.script.topLevelMod || !addedGlobalDocument) { + documents = documents.concat(document); + if (!document.script.isDeclareFile && document.script.topLevelMod) { + addedGlobalDocument = true; + } + } + } + } else { + var allDocuments = this.compiler.getDocuments(); + for (var i = 0; i < allDocuments.length; i++) { + if (!allDocuments[i].script.isDeclareFile && !allDocuments[i].script.topLevelMod) { + var scriptReferences = allDocuments[i].script.referencedFiles; + for (var j = 0; j < scriptReferences.length; j++) { + var currentReference = scriptReferences[j]; + var document = this.compiler.getDocument(currentReference); + + if (document.script.isDeclareFile || document.script.topLevelMod) { + for (var k = 0; k < documents.length; k++) { + if (documents[k] == document) { + break; + } + } + + if (k == documents.length) { + documents = documents.concat(document); + } + } + } + } + } + } + + var emittingFilePath = documents.length ? TypeScript.getRootFilePath(this.emittingFileName) : null; + for (var i = 0; i < documents.length; i++) { + var document = documents[i]; + var declFileName; + if (document.script.isDeclareFile) { + declFileName = document.fileName; + } else { + declFileName = this.compiler.emitOptions.mapOutputFileName(document, TypeScript.TypeScriptCompiler.mapToDTSFileName); + } + + declFileName = TypeScript.getRelativePathToFixedPath(emittingFilePath, declFileName, false); + this.declFile.WriteLine('/// '); + } + + this.emittedReferencePaths = true; + }; + + DeclarationEmitter.prototype.scriptCallback = function (pre, script) { + if (pre) { + this.emitReferencePaths(script); + this.pushDeclarationContainer(script); + } else { + this.popDeclarationContainer(script); + } + return true; + }; + + DeclarationEmitter.prototype.defaultCallback = function (pre, ast) { + return !ast.isStatement(); + }; + return DeclarationEmitter; + })(); + TypeScript.DeclarationEmitter = DeclarationEmitter; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var BloomFilter = (function () { + function BloomFilter(expectedCount) { + var m = Math.max(1, BloomFilter.computeM(expectedCount)); + var k = Math.max(1, BloomFilter.computeK(expectedCount)); + ; + + var sizeInEvenBytes = (m + 7) & ~7; + + this.bitArray = []; + for (var i = 0, len = sizeInEvenBytes; i < len; i++) { + this.bitArray[i] = false; + } + this.hashFunctionCount = k; + } + BloomFilter.computeM = function (expectedCount) { + var p = BloomFilter.falsePositiveProbability; + var n = expectedCount; + + var numerator = n * Math.log(p); + var denominator = Math.log(1.0 / Math.pow(2.0, Math.log(2.0))); + return Math.ceil(numerator / denominator); + }; + + BloomFilter.computeK = function (expectedCount) { + var n = expectedCount; + var m = BloomFilter.computeM(expectedCount); + + var temp = Math.log(2.0) * m / n; + return Math.round(temp); + }; + + BloomFilter.prototype.computeHash = function (key, seed) { + return TypeScript.Hash.computeMurmur2StringHashCode(key, seed); + }; + + BloomFilter.prototype.addKeys = function (keys) { + for (var name in keys) { + if (keys[name]) { + this.add(name); + } + } + }; + + BloomFilter.prototype.add = function (value) { + for (var i = 0; i < this.hashFunctionCount; i++) { + var hash = this.computeHash(value, i); + hash = hash % this.bitArray.length; + this.bitArray[Math.abs(hash)] = true; + } + }; + + BloomFilter.prototype.probablyContains = function (value) { + for (var i = 0; i < this.hashFunctionCount; i++) { + var hash = this.computeHash(value, i); + hash = hash % this.bitArray.length; + if (!this.bitArray[Math.abs(hash)]) { + return false; + } + } + + return true; + }; + + BloomFilter.prototype.isEquivalent = function (filter) { + return BloomFilter.isEquivalent(this.bitArray, filter.bitArray) && this.hashFunctionCount == filter.hashFunctionCount; + }; + + BloomFilter.isEquivalent = function (array1, array2) { + if (array1.length != array2.length) { + return false; + } + + for (var i = 0; i < array1.length; i++) { + if (array1[i] != array2[i]) { + return false; + } + } + + return true; + }; + BloomFilter.falsePositiveProbability = 0.0001; + return BloomFilter; + })(); + TypeScript.BloomFilter = BloomFilter; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var IdentifierWalker = (function (_super) { + __extends(IdentifierWalker, _super); + function IdentifierWalker(list) { + _super.call(this); + this.list = list; + } + IdentifierWalker.prototype.visitToken = function (token) { + this.list[token.text()] = true; + }; + return IdentifierWalker; + })(TypeScript.SyntaxWalker); + TypeScript.IdentifierWalker = IdentifierWalker; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var DataMap = (function () { + function DataMap() { + this.map = {}; + } + DataMap.prototype.link = function (id, data) { + this.map[id] = data; + }; + + DataMap.prototype.unlink = function (id) { + this.map[id] = undefined; + }; + + DataMap.prototype.read = function (id) { + return this.map[id]; + }; + return DataMap; + })(); + TypeScript.DataMap = DataMap; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (PullElementFlags) { + PullElementFlags[PullElementFlags["None"] = 0] = "None"; + PullElementFlags[PullElementFlags["Exported"] = 1] = "Exported"; + PullElementFlags[PullElementFlags["Private"] = 1 << 1] = "Private"; + PullElementFlags[PullElementFlags["Public"] = 1 << 2] = "Public"; + PullElementFlags[PullElementFlags["Ambient"] = 1 << 3] = "Ambient"; + PullElementFlags[PullElementFlags["Static"] = 1 << 4] = "Static"; + PullElementFlags[PullElementFlags["GetAccessor"] = 1 << 5] = "GetAccessor"; + PullElementFlags[PullElementFlags["SetAccessor"] = 1 << 6] = "SetAccessor"; + PullElementFlags[PullElementFlags["Optional"] = 1 << 7] = "Optional"; + PullElementFlags[PullElementFlags["Call"] = 1 << 8] = "Call"; + PullElementFlags[PullElementFlags["Constructor"] = 1 << 9] = "Constructor"; + PullElementFlags[PullElementFlags["Index"] = 1 << 10] = "Index"; + PullElementFlags[PullElementFlags["Signature"] = 1 << 11] = "Signature"; + PullElementFlags[PullElementFlags["Enum"] = 1 << 12] = "Enum"; + PullElementFlags[PullElementFlags["FatArrow"] = 1 << 13] = "FatArrow"; + + PullElementFlags[PullElementFlags["ClassConstructorVariable"] = 1 << 14] = "ClassConstructorVariable"; + PullElementFlags[PullElementFlags["InitializedModule"] = 1 << 15] = "InitializedModule"; + PullElementFlags[PullElementFlags["InitializedDynamicModule"] = 1 << 16] = "InitializedDynamicModule"; + PullElementFlags[PullElementFlags["InitializedEnum"] = 1 << 17] = "InitializedEnum"; + + PullElementFlags[PullElementFlags["MustCaptureThis"] = 1 << 18] = "MustCaptureThis"; + PullElementFlags[PullElementFlags["Constant"] = 1 << 19] = "Constant"; + + PullElementFlags[PullElementFlags["ExpressionElement"] = 1 << 20] = "ExpressionElement"; + + PullElementFlags[PullElementFlags["DeclaredInAWithBlock"] = 1 << 21] = "DeclaredInAWithBlock"; + + PullElementFlags[PullElementFlags["HasReturnStatement"] = 1 << 22] = "HasReturnStatement"; + + PullElementFlags[PullElementFlags["PropertyParameter"] = 1 << 23] = "PropertyParameter"; + + PullElementFlags[PullElementFlags["IsAnnotatedWithAny"] = 1 << 24] = "IsAnnotatedWithAny"; + + PullElementFlags[PullElementFlags["ImplicitVariable"] = PullElementFlags.ClassConstructorVariable | PullElementFlags.InitializedModule | PullElementFlags.InitializedDynamicModule | PullElementFlags.InitializedEnum] = "ImplicitVariable"; + PullElementFlags[PullElementFlags["SomeInitializedModule"] = PullElementFlags.InitializedModule | PullElementFlags.InitializedDynamicModule | PullElementFlags.InitializedEnum] = "SomeInitializedModule"; + })(TypeScript.PullElementFlags || (TypeScript.PullElementFlags = {})); + var PullElementFlags = TypeScript.PullElementFlags; + + (function (PullElementKind) { + PullElementKind[PullElementKind["None"] = 0] = "None"; + PullElementKind[PullElementKind["Global"] = 0] = "Global"; + + PullElementKind[PullElementKind["Script"] = 1] = "Script"; + PullElementKind[PullElementKind["Primitive"] = 1 << 1] = "Primitive"; + + PullElementKind[PullElementKind["Container"] = 1 << 2] = "Container"; + PullElementKind[PullElementKind["Class"] = 1 << 3] = "Class"; + PullElementKind[PullElementKind["Interface"] = 1 << 4] = "Interface"; + PullElementKind[PullElementKind["DynamicModule"] = 1 << 5] = "DynamicModule"; + PullElementKind[PullElementKind["Enum"] = 1 << 6] = "Enum"; + PullElementKind[PullElementKind["Array"] = 1 << 7] = "Array"; + PullElementKind[PullElementKind["TypeAlias"] = 1 << 8] = "TypeAlias"; + PullElementKind[PullElementKind["ObjectLiteral"] = 1 << 9] = "ObjectLiteral"; + + PullElementKind[PullElementKind["Variable"] = 1 << 10] = "Variable"; + PullElementKind[PullElementKind["Parameter"] = 1 << 11] = "Parameter"; + PullElementKind[PullElementKind["Property"] = 1 << 12] = "Property"; + PullElementKind[PullElementKind["TypeParameter"] = 1 << 13] = "TypeParameter"; + + PullElementKind[PullElementKind["Function"] = 1 << 14] = "Function"; + PullElementKind[PullElementKind["ConstructorMethod"] = 1 << 15] = "ConstructorMethod"; + PullElementKind[PullElementKind["Method"] = 1 << 16] = "Method"; + PullElementKind[PullElementKind["FunctionExpression"] = 1 << 17] = "FunctionExpression"; + + PullElementKind[PullElementKind["GetAccessor"] = 1 << 18] = "GetAccessor"; + PullElementKind[PullElementKind["SetAccessor"] = 1 << 19] = "SetAccessor"; + + PullElementKind[PullElementKind["CallSignature"] = 1 << 20] = "CallSignature"; + PullElementKind[PullElementKind["ConstructSignature"] = 1 << 21] = "ConstructSignature"; + PullElementKind[PullElementKind["IndexSignature"] = 1 << 22] = "IndexSignature"; + + PullElementKind[PullElementKind["ObjectType"] = 1 << 23] = "ObjectType"; + PullElementKind[PullElementKind["FunctionType"] = 1 << 24] = "FunctionType"; + PullElementKind[PullElementKind["ConstructorType"] = 1 << 25] = "ConstructorType"; + + PullElementKind[PullElementKind["EnumMember"] = 1 << 26] = "EnumMember"; + PullElementKind[PullElementKind["ErrorType"] = 1 << 27] = "ErrorType"; + + PullElementKind[PullElementKind["Expression"] = 1 << 28] = "Expression"; + + PullElementKind[PullElementKind["WithBlock"] = 1 << 29] = "WithBlock"; + PullElementKind[PullElementKind["CatchBlock"] = 1 << 30] = "CatchBlock"; + + PullElementKind[PullElementKind["All"] = PullElementKind.Script | PullElementKind.Global | PullElementKind.Primitive | PullElementKind.Container | PullElementKind.Class | PullElementKind.Interface | PullElementKind.DynamicModule | PullElementKind.Enum | PullElementKind.Array | PullElementKind.TypeAlias | PullElementKind.ObjectLiteral | PullElementKind.Variable | PullElementKind.Parameter | PullElementKind.Property | PullElementKind.TypeParameter | PullElementKind.Function | PullElementKind.ConstructorMethod | PullElementKind.Method | PullElementKind.FunctionExpression | PullElementKind.GetAccessor | PullElementKind.SetAccessor | PullElementKind.CallSignature | PullElementKind.ConstructSignature | PullElementKind.IndexSignature | PullElementKind.ObjectType | PullElementKind.FunctionType | PullElementKind.ConstructorType | PullElementKind.EnumMember | PullElementKind.ErrorType | PullElementKind.Expression | PullElementKind.WithBlock | PullElementKind.CatchBlock] = "All"; + + PullElementKind[PullElementKind["SomeFunction"] = PullElementKind.Function | PullElementKind.ConstructorMethod | PullElementKind.Method | PullElementKind.FunctionExpression | PullElementKind.GetAccessor | PullElementKind.SetAccessor | PullElementKind.CallSignature | PullElementKind.ConstructSignature | PullElementKind.IndexSignature] = "SomeFunction"; + + PullElementKind[PullElementKind["SomeValue"] = PullElementKind.Variable | PullElementKind.Parameter | PullElementKind.Property | PullElementKind.EnumMember | PullElementKind.SomeFunction] = "SomeValue"; + + PullElementKind[PullElementKind["SomeType"] = PullElementKind.Script | PullElementKind.Global | PullElementKind.Primitive | PullElementKind.Class | PullElementKind.Interface | PullElementKind.Enum | PullElementKind.Array | PullElementKind.ObjectType | PullElementKind.FunctionType | PullElementKind.ConstructorType | PullElementKind.TypeParameter | PullElementKind.ErrorType] = "SomeType"; + + PullElementKind[PullElementKind["AcceptableAlias"] = PullElementKind.Variable | PullElementKind.SomeFunction | PullElementKind.Class | PullElementKind.Interface | PullElementKind.Enum | PullElementKind.Container | PullElementKind.ObjectType | PullElementKind.FunctionType | PullElementKind.ConstructorType] = "AcceptableAlias"; + + PullElementKind[PullElementKind["SomeContainer"] = PullElementKind.Container | PullElementKind.DynamicModule | PullElementKind.TypeAlias] = "SomeContainer"; + + PullElementKind[PullElementKind["SomeBlock"] = PullElementKind.WithBlock | PullElementKind.CatchBlock] = "SomeBlock"; + + PullElementKind[PullElementKind["SomeSignature"] = PullElementKind.CallSignature | PullElementKind.ConstructSignature | PullElementKind.IndexSignature] = "SomeSignature"; + + PullElementKind[PullElementKind["SomeAccessor"] = PullElementKind.GetAccessor | PullElementKind.SetAccessor] = "SomeAccessor"; + + PullElementKind[PullElementKind["SomeTypeReference"] = PullElementKind.Interface | PullElementKind.ObjectType | PullElementKind.FunctionType | PullElementKind.ConstructorType] = "SomeTypeReference"; + + PullElementKind[PullElementKind["SomeLHS"] = PullElementKind.Variable | PullElementKind.Property | PullElementKind.Parameter | PullElementKind.SetAccessor | PullElementKind.Method] = "SomeLHS"; + + PullElementKind[PullElementKind["InterfaceTypeExtension"] = PullElementKind.Interface | PullElementKind.Class | PullElementKind.Enum] = "InterfaceTypeExtension"; + PullElementKind[PullElementKind["ClassTypeExtension"] = PullElementKind.Interface | PullElementKind.Class] = "ClassTypeExtension"; + PullElementKind[PullElementKind["EnumTypeExtension"] = PullElementKind.Interface | PullElementKind.Enum] = "EnumTypeExtension"; + })(TypeScript.PullElementKind || (TypeScript.PullElementKind = {})); + var PullElementKind = TypeScript.PullElementKind; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + TypeScript.pullDeclID = 0; + TypeScript.lastBoundPullDeclId = 0; + var sentinelEmptyPullDeclArray = []; + + var PullDecl = (function () { + function PullDecl(declName, displayName, kind, declFlags, span, scriptName) { + this.symbol = null; + this.declGroups = new TypeScript.BlockIntrinsics(); + this.signatureSymbol = null; + this.specializingSignatureSymbol = null; + this.childDecls = null; + this.typeParameters = null; + this.childDeclTypeCache = new TypeScript.BlockIntrinsics(); + this.childDeclValueCache = new TypeScript.BlockIntrinsics(); + this.childDeclNamespaceCache = new TypeScript.BlockIntrinsics(); + this.childDeclTypeParameterCache = new TypeScript.BlockIntrinsics(); + this.declID = TypeScript.pullDeclID++; + this.declIDString = null; + this.flags = 0 /* None */; + this.diagnostics = null; + this.parentDecl = null; + this._parentPath = null; + this._isBound = false; + this.synthesizedValDecl = null; + this.hashCode = -1; + this.ast = null; + this.name = declName; + this.kind = kind; + this.flags = declFlags; + this.span = span; + this.scriptName = scriptName; + + if (displayName !== this.name) { + this.declDisplayName = displayName; + } + + this.hashCode = this.declID ^ this.kind; + this.declIDString = this.declID.toString(); + } + PullDecl.prototype.getDisplayName = function () { + return this.declDisplayName === undefined ? this.name : this.declDisplayName; + }; + + PullDecl.prototype.setSymbol = function (symbol) { + this.symbol = symbol; + }; + + PullDecl.prototype.ensureSymbolIsBound = function (bindSignatureSymbol) { + if (typeof bindSignatureSymbol === "undefined") { bindSignatureSymbol = false; } + if (!((bindSignatureSymbol && this.signatureSymbol) || this.symbol) && !this._isBound && this.kind != 1 /* Script */) { + var prevUnit = TypeScript.globalBinder.semanticInfo; + TypeScript.globalBinder.setUnit(this.scriptName); + TypeScript.globalBinder.bindDeclToPullSymbol(this); + if (prevUnit) { + TypeScript.globalBinder.setUnit(prevUnit.getPath()); + } + } + }; + + PullDecl.prototype.getSymbol = function () { + if (this.kind == 1 /* Script */) { + return null; + } + + this.ensureSymbolIsBound(); + + return this.symbol; + }; + + PullDecl.prototype.hasSymbol = function () { + return this.symbol != null; + }; + + PullDecl.prototype.setSignatureSymbol = function (signature) { + this.signatureSymbol = signature; + }; + PullDecl.prototype.getSignatureSymbol = function () { + this.ensureSymbolIsBound(true); + + return this.signatureSymbol; + }; + + PullDecl.prototype.hasSignature = function () { + return this.signatureSymbol != null; + }; + + PullDecl.prototype.setSpecializingSignatureSymbol = function (signature) { + this.specializingSignatureSymbol = signature; + }; + PullDecl.prototype.getSpecializingSignatureSymbol = function () { + if (this.specializingSignatureSymbol) { + return this.specializingSignatureSymbol; + } + + return this.signatureSymbol; + }; + + PullDecl.prototype.setFlags = function (flags) { + this.flags = flags; + }; + PullDecl.prototype.setFlag = function (flags) { + this.flags |= flags; + }; + + PullDecl.prototype.getSpan = function () { + return this.span; + }; + PullDecl.prototype.setSpan = function (span) { + this.span = span; + }; + + PullDecl.prototype.getScriptName = function () { + return this.scriptName; + }; + + PullDecl.prototype.setValueDecl = function (valDecl) { + this.synthesizedValDecl = valDecl; + }; + PullDecl.prototype.getValueDecl = function () { + return this.synthesizedValDecl; + }; + + PullDecl.prototype.isEqual = function (other) { + return (this.name === other.name) && (this.kind === other.kind) && (this.flags === other.flags) && (this.scriptName === other.scriptName) && (this.span.start() === other.span.start()) && (this.span.end() === other.span.end()); + }; + + PullDecl.prototype.getParentDecl = function () { + return this.parentDecl; + }; + + PullDecl.prototype.setParentDecl = function (parentDecl) { + this.parentDecl = parentDecl; + }; + + PullDecl.prototype.addDiagnostic = function (diagnostic) { + if (diagnostic) { + if (!this.diagnostics) { + this.diagnostics = []; + } + + this.diagnostics[this.diagnostics.length] = diagnostic; + } + }; + + PullDecl.prototype.getDiagnostics = function () { + return this.diagnostics ? this.diagnostics : sentinelEmptyPullDeclArray; + }; + + PullDecl.prototype.resetErrors = function () { + this.diagnostics = null; + }; + + PullDecl.prototype.getChildDeclCache = function (declKind) { + return declKind === 8192 /* TypeParameter */ ? this.childDeclTypeParameterCache : TypeScript.hasFlag(declKind, TypeScript.PullElementKind.SomeContainer) ? this.childDeclNamespaceCache : TypeScript.hasFlag(declKind, TypeScript.PullElementKind.SomeType) ? this.childDeclTypeCache : this.childDeclValueCache; + }; + + PullDecl.prototype.addChildDecl = function (childDecl) { + if (childDecl.kind === 8192 /* TypeParameter */) { + if (!this.typeParameters) { + this.typeParameters = []; + } + this.typeParameters[this.typeParameters.length] = childDecl; + } else { + if (!this.childDecls) { + this.childDecls = []; + } + this.childDecls[this.childDecls.length] = childDecl; + } + + var declName = childDecl.name; + var cache = this.getChildDeclCache(childDecl.kind); + var childrenOfName = cache[declName]; + if (!childrenOfName) { + childrenOfName = []; + } + + childrenOfName.push(childDecl); + cache[declName] = childrenOfName; + }; + + PullDecl.prototype.searchChildDecls = function (declName, searchKind) { + var cacheVal = null; + + if (searchKind & TypeScript.PullElementKind.SomeType) { + cacheVal = this.childDeclTypeCache[declName]; + } else if (searchKind & TypeScript.PullElementKind.SomeContainer) { + cacheVal = this.childDeclNamespaceCache[declName]; + } else { + cacheVal = this.childDeclValueCache[declName]; + } + + if (cacheVal) { + return cacheVal; + } else { + if (searchKind & TypeScript.PullElementKind.SomeType) { + cacheVal = this.childDeclTypeParameterCache[declName]; + + if (cacheVal) { + return cacheVal; + } + } + + return sentinelEmptyPullDeclArray; + } + }; + + PullDecl.prototype.getChildDecls = function () { + return this.childDecls ? this.childDecls : sentinelEmptyPullDeclArray; + }; + PullDecl.prototype.getTypeParameters = function () { + return this.typeParameters ? this.typeParameters : sentinelEmptyPullDeclArray; + }; + + PullDecl.prototype.addVariableDeclToGroup = function (decl) { + var declGroup = this.declGroups[decl.name]; + if (declGroup) { + declGroup.addDecl(decl); + } else { + declGroup = new PullDeclGroup(decl.name); + declGroup.addDecl(decl); + this.declGroups[decl.name] = declGroup; + } + }; + + PullDecl.prototype.getVariableDeclGroups = function () { + var declGroups = null; + + for (var declName in this.declGroups) { + if (this.declGroups[declName]) { + if (!declGroups) { + declGroups = []; + } + + declGroups[declGroups.length] = this.declGroups[declName].getDecls(); + } + } + + return declGroups ? declGroups : sentinelEmptyPullDeclArray; + }; + + PullDecl.prototype.getParentPath = function () { + return this._parentPath; + }; + + PullDecl.prototype.setParentPath = function (path) { + this._parentPath = path; + }; + + PullDecl.prototype.setIsBound = function (isBinding) { + this._isBound = isBinding; + }; + + PullDecl.prototype.isBound = function () { + return this._isBound; + }; + return PullDecl; + })(); + TypeScript.PullDecl = PullDecl; + + var PullFunctionExpressionDecl = (function (_super) { + __extends(PullFunctionExpressionDecl, _super); + function PullFunctionExpressionDecl(expressionName, declFlags, span, scriptName) { + _super.call(this, "", "", 131072 /* FunctionExpression */, declFlags, span, scriptName); + this.functionExpressionName = expressionName; + } + PullFunctionExpressionDecl.prototype.getFunctionExpressionName = function () { + return this.functionExpressionName; + }; + return PullFunctionExpressionDecl; + })(PullDecl); + TypeScript.PullFunctionExpressionDecl = PullFunctionExpressionDecl; + + var PullDeclGroup = (function () { + function PullDeclGroup(name) { + this.name = name; + this._decls = []; + } + PullDeclGroup.prototype.addDecl = function (decl) { + if (decl.name === this.name) { + this._decls[this._decls.length] = decl; + } + }; + + PullDeclGroup.prototype.getDecls = function () { + return this._decls; + }; + return PullDeclGroup; + })(); + TypeScript.PullDeclGroup = PullDeclGroup; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + TypeScript.pullSymbolID = 0; + TypeScript.globalTyvarID = 0; + TypeScript.sentinelEmptyArray = []; + + var PullSymbol = (function () { + function PullSymbol(name, declKind) { + this.pullSymbolID = TypeScript.pullSymbolID++; + this.pullSymbolIDString = null; + this.cachedPathIDs = {}; + this._container = null; + this.type = null; + this._declarations = null; + this.isResolved = false; + this.isOptional = false; + this.inResolution = false; + this.isSynthesized = false; + this.isVarArg = false; + this.isSpecialized = false; + this.isBeingSpecialized = false; + this.rootSymbol = null; + this._parentAccessorSymbol = null; + this._enclosingSignature = null; + this.docComments = null; + this.isPrinting = false; + this.ast = null; + this.name = name; + this.kind = declKind; + this.pullSymbolIDString = this.pullSymbolID.toString(); + } + PullSymbol.prototype.isType = function () { + return (this.kind & TypeScript.PullElementKind.SomeType) != 0; + }; + + PullSymbol.prototype.isSignature = function () { + return (this.kind & TypeScript.PullElementKind.SomeSignature) != 0; + }; + + PullSymbol.prototype.isArray = function () { + return (this.kind & 128 /* Array */) != 0; + }; + + PullSymbol.prototype.isPrimitive = function () { + return this.kind === 2 /* Primitive */; + }; + + PullSymbol.prototype.isAccessor = function () { + return false; + }; + + PullSymbol.prototype.isError = function () { + return false; + }; + + PullSymbol.prototype.isInterface = function () { + return this.kind === 16 /* Interface */; + }; + + PullSymbol.prototype.isMethod = function () { + return this.kind === 65536 /* Method */; + }; + + PullSymbol.prototype.isProperty = function () { + return this.kind === 4096 /* Property */; + }; + + PullSymbol.prototype.isAlias = function () { + return false; + }; + PullSymbol.prototype.isContainer = function () { + return false; + }; + + PullSymbol.prototype.setAccessorSymbol = function (accessor) { + this._parentAccessorSymbol = accessor; + }; + + PullSymbol.prototype.getAccessorySymbol = function () { + return this._parentAccessorSymbol; + }; + + PullSymbol.prototype.findAliasedType = function (decls) { + for (var i = 0; i < decls.length; i++) { + var childDecls = decls[i].getChildDecls(); + for (var j = 0; j < childDecls.length; j++) { + if (childDecls[j].kind === 256 /* TypeAlias */) { + var symbol = childDecls[j].getSymbol(); + if (PullContainerTypeSymbol.usedAsSymbol(symbol, this)) { + return symbol; + } + } + } + } + + return null; + }; + + PullSymbol.prototype.getAliasedSymbol = function (scopeSymbol) { + if (!scopeSymbol) { + return null; + } + + var scopePath = scopeSymbol.pathToRoot(); + if (scopePath.length && scopePath[scopePath.length - 1].kind === 32 /* DynamicModule */) { + var decls = scopePath[scopePath.length - 1].getDeclarations(); + var symbol = this.findAliasedType(decls); + return symbol; + } + + return null; + }; + + PullSymbol.prototype.getScopedDynamicModuleAlias = function (scopeSymbol) { + var aliasSymbol = this.getAliasedSymbol(scopeSymbol); + + if (aliasSymbol) { + if (aliasSymbol.assignedValue) { + return null; + } + + if (aliasSymbol.assignedType && aliasSymbol.assignedType != aliasSymbol.assignedContainer) { + return null; + } + + if (aliasSymbol.assignedContainer.kind != 32 /* DynamicModule */) { + return null; + } + } + return aliasSymbol; + }; + + PullSymbol.prototype.getName = function (scopeSymbol, useConstraintInName) { + var symbol = this.getScopedDynamicModuleAlias(scopeSymbol); + if (symbol) { + return symbol.getName(); + } + + return this.name; + }; + + PullSymbol.prototype.getDisplayName = function (scopeSymbol, useConstraintInName) { + var symbol = this.getScopedDynamicModuleAlias(scopeSymbol); + if (symbol) { + return symbol.getDisplayName(); + } + + var decls = this.getDeclarations(); + return decls.length ? this.getDeclarations()[0].getDisplayName() : this.name; + }; + + PullSymbol.prototype.setIsSpecialized = function () { + this.isSpecialized = true; + this.isBeingSpecialized = false; + }; + PullSymbol.prototype.getIsSpecialized = function () { + return this.isSpecialized; + }; + PullSymbol.prototype.currentlyBeingSpecialized = function () { + return this.isBeingSpecialized; + }; + PullSymbol.prototype.setIsBeingSpecialized = function () { + this.isBeingSpecialized = true; + }; + PullSymbol.prototype.setValueIsBeingSpecialized = function (val) { + this.isBeingSpecialized = val; + }; + + PullSymbol.prototype.getRootSymbol = function () { + if (!this.rootSymbol) { + return this; + } + return this.rootSymbol; + }; + PullSymbol.prototype.setRootSymbol = function (symbol) { + this.rootSymbol = symbol; + }; + + PullSymbol.prototype.setIsSynthesized = function (value) { + if (typeof value === "undefined") { value = true; } + this.isSynthesized = value; + }; + PullSymbol.prototype.getIsSynthesized = function () { + return this.isSynthesized; + }; + + PullSymbol.prototype.setEnclosingSignature = function (signature) { + this._enclosingSignature = signature; + }; + + PullSymbol.prototype.getEnclosingSignature = function () { + return this._enclosingSignature; + }; + + PullSymbol.prototype.addCacheID = function (cacheID) { + if (!this.cachedPathIDs[cacheID]) { + this.cachedPathIDs[cacheID] = true; + } + }; + + PullSymbol.prototype.invalidateCachedIDs = function (cache) { + for (var id in this.cachedPathIDs) { + if (cache[id]) { + cache[id] = undefined; + } + } + }; + + PullSymbol.prototype.addDeclaration = function (decl) { + TypeScript.Debug.assert(!!decl); + + if (this.rootSymbol) { + return; + } + + if (!this._declarations) { + this._declarations = [decl]; + } else { + this._declarations[this._declarations.length] = decl; + } + }; + + PullSymbol.prototype.getDeclarations = function () { + if (this.rootSymbol) { + return this.rootSymbol.getDeclarations(); + } + + if (!this._declarations) { + this._declarations = []; + } + + return this._declarations; + }; + + PullSymbol.prototype.setContainer = function (containerSymbol) { + if (this.rootSymbol) { + return; + } + + this._container = containerSymbol; + }; + + PullSymbol.prototype.getContainer = function () { + if (this.rootSymbol) { + return this.rootSymbol.getContainer(); + } + + return this._container; + }; + + PullSymbol.prototype.setResolved = function () { + this.isResolved = true; + this.inResolution = false; + }; + + PullSymbol.prototype.startResolving = function () { + this.inResolution = true; + }; + + PullSymbol.prototype.setUnresolved = function () { + this.isResolved = false; + this.inResolution = false; + }; + + PullSymbol.prototype.invalidate = function () { + this.isResolved = false; + + var declarations = this.getDeclarations(); + }; + + PullSymbol.prototype.hasFlag = function (flag) { + var declarations = this.getDeclarations(); + for (var i = 0, n = declarations.length; i < n; i++) { + if ((declarations[i].flags & flag) !== 0 /* None */) { + return true; + } + } + return false; + }; + + PullSymbol.prototype.allDeclsHaveFlag = function (flag) { + var declarations = this.getDeclarations(); + for (var i = 0, n = declarations.length; i < n; i++) { + if (!((declarations[i].flags & flag) !== 0 /* None */)) { + return false; + } + } + return true; + }; + + PullSymbol.prototype.pathToRoot = function () { + var path = []; + var node = this; + while (node) { + if (node.isType()) { + var associatedContainerSymbol = (node).getAssociatedContainerType(); + if (associatedContainerSymbol) { + node = associatedContainerSymbol; + } + } + path[path.length] = node; + var nodeKind = node.kind; + if (nodeKind == 2048 /* Parameter */) { + break; + } else { + node = node.getContainer(); + } + } + return path; + }; + + PullSymbol.prototype.findCommonAncestorPath = function (b) { + var aPath = this.pathToRoot(); + if (aPath.length === 1) { + return aPath; + } + + var bPath; + if (b) { + bPath = b.pathToRoot(); + } else { + return aPath; + } + + var commonNodeIndex = -1; + for (var i = 0, aLen = aPath.length; i < aLen; i++) { + var aNode = aPath[i]; + for (var j = 0, bLen = bPath.length; j < bLen; j++) { + var bNode = bPath[j]; + if (aNode === bNode) { + var aDecl = null; + if (i > 0) { + var decls = aPath[i - 1].getDeclarations(); + if (decls.length) { + aDecl = decls[0].getParentDecl(); + } + } + var bDecl = null; + if (j > 0) { + var decls = bPath[j - 1].getDeclarations(); + if (decls.length) { + bDecl = decls[0].getParentDecl(); + } + } + if (!aDecl || !bDecl || aDecl == bDecl) { + commonNodeIndex = i; + break; + } + } + } + if (commonNodeIndex >= 0) { + break; + } + } + + if (commonNodeIndex >= 0) { + return aPath.slice(0, commonNodeIndex); + } else { + return aPath; + } + }; + + PullSymbol.prototype.toString = function (scopeSymbol, useConstraintInName) { + var str = this.getNameAndTypeName(scopeSymbol); + return str; + }; + + PullSymbol.prototype.getNamePartForFullName = function () { + return this.getDisplayName(null, true); + }; + + PullSymbol.prototype.fullName = function (scopeSymbol) { + var path = this.pathToRoot(); + var fullName = ""; + var aliasedSymbol = this.getScopedDynamicModuleAlias(scopeSymbol); + if (aliasedSymbol) { + return aliasedSymbol.fullName(scopeSymbol); + } + + for (var i = 1; i < path.length; i++) { + aliasedSymbol = path[i].getScopedDynamicModuleAlias(scopeSymbol); + if (aliasedSymbol) { + fullName = aliasedSymbol.fullName(scopeSymbol) + "." + fullName; + break; + } else { + var scopedName = path[i].getNamePartForFullName(); + if (path[i].kind == 32 /* DynamicModule */ && !TypeScript.isQuoted(scopedName)) { + break; + } + + if (scopedName === "") { + break; + } + + fullName = scopedName + "." + fullName; + } + } + + fullName = fullName + this.getNamePartForFullName(); + return fullName; + }; + + PullSymbol.prototype.getScopedName = function (scopeSymbol, useConstraintInName) { + var path = this.findCommonAncestorPath(scopeSymbol); + var fullName = ""; + var aliasedSymbol = this.getScopedDynamicModuleAlias(scopeSymbol); + if (aliasedSymbol) { + return aliasedSymbol.getScopedName(scopeSymbol); + } + + for (var i = 1; i < path.length; i++) { + var kind = path[i].kind; + if (kind === 4 /* Container */ || kind === 32 /* DynamicModule */) { + aliasedSymbol = path[i].getScopedDynamicModuleAlias(scopeSymbol); + if (aliasedSymbol) { + fullName = aliasedSymbol.getScopedName(scopeSymbol) + "." + fullName; + break; + } else if (kind === 4 /* Container */) { + fullName = path[i].getDisplayName() + "." + fullName; + } else { + var displayName = path[i].getDisplayName(); + if (TypeScript.isQuoted(displayName)) { + fullName = displayName + "." + fullName; + } + break; + } + } else { + break; + } + } + fullName = fullName + this.getDisplayName(scopeSymbol, useConstraintInName); + return fullName; + }; + + PullSymbol.prototype.getScopedNameEx = function (scopeSymbol, useConstraintInName, getPrettyTypeName, getTypeParamMarkerInfo) { + var name = this.getScopedName(scopeSymbol, useConstraintInName); + return TypeScript.MemberName.create(name); + }; + + PullSymbol.prototype.getTypeName = function (scopeSymbol, getPrettyTypeName) { + var memberName = this.getTypeNameEx(scopeSymbol, getPrettyTypeName); + return memberName.toString(); + }; + + PullSymbol.prototype.getTypeNameEx = function (scopeSymbol, getPrettyTypeName) { + var type = this.type; + if (type) { + var memberName = getPrettyTypeName ? this.getTypeNameForFunctionSignature("", scopeSymbol, getPrettyTypeName) : null; + if (!memberName) { + memberName = type.getScopedNameEx(scopeSymbol, true, getPrettyTypeName); + } + + return memberName; + } + return TypeScript.MemberName.create(""); + }; + + PullSymbol.prototype.getTypeNameForFunctionSignature = function (prefix, scopeSymbol, getPrettyTypeName) { + var type = this.type; + if (type && !type.isNamedTypeSymbol() && this.kind != 4096 /* Property */ && this.kind != 1024 /* Variable */ && this.kind != 2048 /* Parameter */) { + var signatures = type.getCallSignatures(); + if (signatures.length == 1 || (getPrettyTypeName && signatures.length)) { + var typeName = new TypeScript.MemberNameArray(); + var signatureName = PullSignatureSymbol.getSignaturesTypeNameEx(signatures, prefix, false, false, scopeSymbol, getPrettyTypeName); + typeName.addAll(signatureName); + return typeName; + } + } + + return null; + }; + + PullSymbol.prototype.getNameAndTypeName = function (scopeSymbol) { + var nameAndTypeName = this.getNameAndTypeNameEx(scopeSymbol); + return nameAndTypeName.toString(); + }; + + PullSymbol.prototype.getNameAndTypeNameEx = function (scopeSymbol) { + var type = this.type; + var nameStr = this.getDisplayName(scopeSymbol); + if (type) { + nameStr = nameStr + (this.isOptional ? "?" : ""); + var memberName = this.getTypeNameForFunctionSignature(nameStr, scopeSymbol); + if (!memberName) { + var typeNameEx = type.getScopedNameEx(scopeSymbol); + memberName = TypeScript.MemberName.create(typeNameEx, nameStr + ": ", ""); + } + return memberName; + } + return TypeScript.MemberName.create(nameStr); + }; + + PullSymbol.getTypeParameterString = function (typars, scopeSymbol, useContraintInName) { + return PullSymbol.getTypeParameterStringEx(typars, scopeSymbol, undefined, useContraintInName).toString(); + }; + + PullSymbol.getTypeParameterStringEx = function (typeParameters, scopeSymbol, getTypeParamMarkerInfo, useContraintInName) { + var builder = new TypeScript.MemberNameArray(); + builder.prefix = ""; + + if (typeParameters && typeParameters.length) { + builder.add(TypeScript.MemberName.create("<")); + + for (var i = 0; i < typeParameters.length; i++) { + if (i) { + builder.add(TypeScript.MemberName.create(", ")); + } + + if (getTypeParamMarkerInfo) { + builder.add(new TypeScript.MemberName()); + } + + builder.add(typeParameters[i].getScopedNameEx(scopeSymbol, useContraintInName)); + + if (getTypeParamMarkerInfo) { + builder.add(new TypeScript.MemberName()); + } + } + + builder.add(TypeScript.MemberName.create(">")); + } + + return builder; + }; + + PullSymbol.getIsExternallyVisible = function (symbol, fromIsExternallyVisibleSymbol, inIsExternallyVisibleSymbols) { + if (inIsExternallyVisibleSymbols) { + for (var i = 0; i < inIsExternallyVisibleSymbols.length; i++) { + if (inIsExternallyVisibleSymbols[i] === symbol) { + return true; + } + } + } else { + inIsExternallyVisibleSymbols = []; + } + + if (fromIsExternallyVisibleSymbol === symbol) { + return true; + } + inIsExternallyVisibleSymbols = inIsExternallyVisibleSymbols.concat(fromIsExternallyVisibleSymbol); + + return symbol.isExternallyVisible(inIsExternallyVisibleSymbols); + }; + + PullSymbol.prototype.isExternallyVisible = function (inIsExternallyVisibleSymbols) { + var kind = this.kind; + if (kind === 2 /* Primitive */) { + return true; + } + + if (this.isType()) { + var associatedContainerSymbol = (this).getAssociatedContainerType(); + if (associatedContainerSymbol) { + return PullSymbol.getIsExternallyVisible(associatedContainerSymbol, this, inIsExternallyVisibleSymbols); + } + } + + if (this.hasFlag(2 /* Private */)) { + return false; + } + + var container = this.getContainer(); + if (container === null) { + return true; + } + + if (container.kind == 32 /* DynamicModule */ || (container.getAssociatedContainerType() && container.getAssociatedContainerType().kind == 32 /* DynamicModule */)) { + var containerTypeSymbol = container.kind == 32 /* DynamicModule */ ? container : container.getAssociatedContainerType(); + if (PullContainerTypeSymbol.usedAsSymbol(containerTypeSymbol, this)) { + return true; + } + } + + if (!this.hasFlag(1 /* Exported */) && kind != 4096 /* Property */ && kind != 65536 /* Method */) { + return false; + } + + return PullSymbol.getIsExternallyVisible(container, this, inIsExternallyVisibleSymbols); + }; + return PullSymbol; + })(); + TypeScript.PullSymbol = PullSymbol; + + var PullSignatureSymbol = (function (_super) { + __extends(PullSignatureSymbol, _super); + function PullSignatureSymbol(kind) { + _super.call(this, "", kind); + this.parameters = TypeScript.sentinelEmptyArray; + this.typeParameters = null; + this.returnType = null; + this.functionType = null; + this.hasOptionalParam = false; + this.nonOptionalParamCount = 0; + this.hasVarArgs = false; + this.specializationCache = {}; + this.memberTypeParameterNameCache = null; + this.hasAGenericParameter = false; + this.stringConstantOverload = undefined; + this.hasBeenChecked = false; + } + PullSignatureSymbol.prototype.isDefinition = function () { + return false; + }; + + PullSignatureSymbol.prototype.isGeneric = function () { + return this.hasAGenericParameter || (this.typeParameters && this.typeParameters.length != 0); + }; + + PullSignatureSymbol.prototype.addParameter = function (parameter, isOptional) { + if (typeof isOptional === "undefined") { isOptional = false; } + if (this.parameters == TypeScript.sentinelEmptyArray) { + this.parameters = []; + } + + this.parameters[this.parameters.length] = parameter; + this.hasOptionalParam = isOptional; + + if (!parameter.getEnclosingSignature()) { + parameter.setEnclosingSignature(this); + } + + if (!isOptional) { + this.nonOptionalParamCount++; + } + }; + + PullSignatureSymbol.prototype.addSpecialization = function (signature, typeArguments) { + if (typeArguments && typeArguments.length) { + this.specializationCache[getIDForTypeSubstitutions(typeArguments)] = signature; + } + }; + + PullSignatureSymbol.prototype.getSpecialization = function (typeArguments) { + if (typeArguments) { + var sig = this.specializationCache[getIDForTypeSubstitutions(typeArguments)]; + + if (sig) { + return sig; + } + } + + return null; + }; + + PullSignatureSymbol.prototype.addTypeParameter = function (typeParameter) { + if (!this.typeParameters) { + this.typeParameters = []; + } + + if (!this.memberTypeParameterNameCache) { + this.memberTypeParameterNameCache = new TypeScript.BlockIntrinsics(); + } + + this.typeParameters[this.typeParameters.length] = typeParameter; + + this.memberTypeParameterNameCache[typeParameter.getName()] = typeParameter; + }; + + PullSignatureSymbol.prototype.getTypeParameters = function () { + if (!this.typeParameters) { + this.typeParameters = []; + } + + return this.typeParameters; + }; + + PullSignatureSymbol.prototype.findTypeParameter = function (name) { + var memberSymbol; + + if (!this.memberTypeParameterNameCache) { + this.memberTypeParameterNameCache = new TypeScript.BlockIntrinsics(); + + if (this.typeParameters) { + for (var i = 0; i < this.typeParameters.length; i++) { + this.memberTypeParameterNameCache[this.typeParameters[i].getName()] = this.typeParameters[i]; + } + } + } + + memberSymbol = this.memberTypeParameterNameCache[name]; + + return memberSymbol; + }; + + PullSignatureSymbol.prototype.mimicSignature = function (signature, resolver) { + var typeParameters = signature.getTypeParameters(); + var typeParameter; + + if (typeParameters) { + for (var i = 0; i < typeParameters.length; i++) { + this.addTypeParameter(typeParameters[i]); + } + } + + var parameters = signature.parameters; + var parameter; + + if (parameters) { + for (var j = 0; j < parameters.length; j++) { + parameter = new PullSymbol(parameters[j].name, 2048 /* Parameter */); + parameter.setRootSymbol(parameters[j]); + + if (parameters[j].isOptional) { + parameter.isOptional = true; + } + if (parameters[j].isVarArg) { + parameter.isVarArg = true; + this.hasVarArgs = true; + } + this.addParameter(parameter); + } + } + + var returnType = signature.returnType; + + if (!resolver.isTypeArgumentOrWrapper(returnType)) { + this.returnType = returnType; + } + }; + + PullSignatureSymbol.prototype.isFixed = function () { + if (!this.isGeneric()) { + return true; + } + + if (this.parameters) { + var paramType; + for (var i = 0; i < this.parameters.length; i++) { + paramType = this.parameters[i].type; + + if (paramType && !paramType.isFixed()) { + return false; + } + } + } + + if (this.returnType) { + if (!this.returnType.isFixed()) { + return false; + } + } + + return true; + }; + + PullSignatureSymbol.prototype.invalidate = function () { + this.nonOptionalParamCount = 0; + this.hasOptionalParam = false; + this.hasAGenericParameter = false; + this.stringConstantOverload = undefined; + + _super.prototype.invalidate.call(this); + }; + + PullSignatureSymbol.prototype.isStringConstantOverloadSignature = function () { + if (this.stringConstantOverload === undefined) { + var params = this.parameters; + this.stringConstantOverload = false; + for (var i = 0; i < params.length; i++) { + var paramType = params[i].type; + if (paramType && paramType.isPrimitive() && (paramType).isStringConstant()) { + this.stringConstantOverload = true; + } + } + } + + return this.stringConstantOverload; + }; + + PullSignatureSymbol.getSignatureTypeMemberName = function (candidateSignature, signatures, scopeSymbol) { + var allMemberNames = new TypeScript.MemberNameArray(); + var signatureMemberName = PullSignatureSymbol.getSignaturesTypeNameEx(signatures, "", false, false, scopeSymbol, true, candidateSignature); + allMemberNames.addAll(signatureMemberName); + return allMemberNames; + }; + + PullSignatureSymbol.getSignaturesTypeNameEx = function (signatures, prefix, shortform, brackets, scopeSymbol, getPrettyTypeName, candidateSignature) { + var result = []; + if (!signatures) { + return result; + } + + var len = signatures.length; + if (!getPrettyTypeName && len > 1) { + shortform = false; + } + + var foundDefinition = false; + if (candidateSignature && candidateSignature.isDefinition() && len > 1) { + candidateSignature = null; + } + + for (var i = 0; i < len; i++) { + if (len > 1 && signatures[i].isDefinition()) { + foundDefinition = true; + continue; + } + + var signature = signatures[i]; + if (getPrettyTypeName && candidateSignature) { + signature = candidateSignature; + } + + result.push(signature.getSignatureTypeNameEx(prefix, shortform, brackets, scopeSymbol)); + if (getPrettyTypeName) { + break; + } + } + + if (getPrettyTypeName && result.length && len > 1) { + var lastMemberName = result[result.length - 1]; + for (var i = i + 1; i < len; i++) { + if (signatures[i].isDefinition()) { + foundDefinition = true; + break; + } + } + var overloadString = TypeScript.getLocalizedText(TypeScript.DiagnosticCode._0_overload_s, [foundDefinition ? len - 2 : len - 1]); + lastMemberName.add(TypeScript.MemberName.create(overloadString)); + } + + return result; + }; + + PullSignatureSymbol.prototype.toString = function (scopeSymbol, useConstraintInName) { + var s = this.getSignatureTypeNameEx(this.getScopedNameEx().toString(), false, false, scopeSymbol, undefined, useConstraintInName).toString(); + return s; + }; + + PullSignatureSymbol.prototype.getSignatureTypeNameEx = function (prefix, shortform, brackets, scopeSymbol, getParamMarkerInfo, getTypeParamMarkerInfo) { + var typeParamterBuilder = new TypeScript.MemberNameArray(); + + typeParamterBuilder.add(PullSymbol.getTypeParameterStringEx(this.getTypeParameters(), scopeSymbol, getTypeParamMarkerInfo, true)); + + if (brackets) { + typeParamterBuilder.add(TypeScript.MemberName.create("[")); + } else { + typeParamterBuilder.add(TypeScript.MemberName.create("(")); + } + + var builder = new TypeScript.MemberNameArray(); + builder.prefix = prefix; + + if (getTypeParamMarkerInfo) { + builder.prefix = prefix; + builder.addAll(typeParamterBuilder.entries); + } else { + builder.prefix = prefix + typeParamterBuilder.toString(); + } + + var params = this.parameters; + var paramLen = params.length; + for (var i = 0; i < paramLen; i++) { + var paramType = params[i].type; + var typeString = paramType ? ": " : ""; + var paramIsVarArg = params[i].isVarArg; + var varArgPrefix = paramIsVarArg ? "..." : ""; + var optionalString = (!paramIsVarArg && params[i].isOptional) ? "?" : ""; + if (getParamMarkerInfo) { + builder.add(new TypeScript.MemberName()); + } + builder.add(TypeScript.MemberName.create(varArgPrefix + params[i].getScopedNameEx(scopeSymbol).toString() + optionalString + typeString)); + if (paramType) { + builder.add(paramType.getScopedNameEx(scopeSymbol)); + } + if (getParamMarkerInfo) { + builder.add(new TypeScript.MemberName()); + } + if (i < paramLen - 1) { + builder.add(TypeScript.MemberName.create(", ")); + } + } + + if (shortform) { + if (brackets) { + builder.add(TypeScript.MemberName.create("] => ")); + } else { + builder.add(TypeScript.MemberName.create(") => ")); + } + } else { + if (brackets) { + builder.add(TypeScript.MemberName.create("]: ")); + } else { + builder.add(TypeScript.MemberName.create("): ")); + } + } + + if (this.returnType) { + builder.add(this.returnType.getScopedNameEx(scopeSymbol)); + } else { + builder.add(TypeScript.MemberName.create("any")); + } + + return builder; + }; + return PullSignatureSymbol; + })(PullSymbol); + TypeScript.PullSignatureSymbol = PullSignatureSymbol; + + var PullTypeSymbol = (function (_super) { + __extends(PullTypeSymbol, _super); + function PullTypeSymbol(name, kind) { + _super.call(this, name, kind); + this._members = TypeScript.sentinelEmptyArray; + this._enclosedMemberTypes = null; + this._typeParameters = null; + this._typeArguments = null; + this._containedNonMembers = null; + this._containedNonMemberTypes = null; + this._specializedVersionsOfThisType = null; + this._arrayVersionOfThisType = null; + this._implementedTypes = null; + this._extendedTypes = null; + this._typesThatExplicitlyImplementThisType = null; + this._typesThatExtendThisType = null; + this._callSignatures = null; + this._allCallSignatures = null; + this._constructSignatures = null; + this._allConstructSignatures = null; + this._indexSignatures = null; + this._allIndexSignatures = null; + this._elementType = null; + this._memberNameCache = null; + this._enclosedTypeNameCache = null; + this._typeParameterNameCache = null; + this._containedNonMemberNameCache = null; + this._containedNonMemberTypeNameCache = null; + this._specializedTypeIDCache = null; + this._hasGenericSignature = false; + this._hasGenericMember = false; + this._hasBaseTypeConflict = false; + this._knownBaseTypeCount = 0; + this._invalidatedSpecializations = false; + this._associatedContainerTypeSymbol = null; + this._constructorMethod = null; + this._hasDefaultConstructor = false; + this._functionSymbol = null; + this.hasRecursiveSpecializationError = false; + this.inMemberTypeNameEx = false; + this.inSymbolPrivacyCheck = false; + this.type = this; + } + PullTypeSymbol.prototype.isType = function () { + return true; + }; + PullTypeSymbol.prototype.isClass = function () { + return this.kind == 8 /* Class */ || (this._constructorMethod != null); + }; + PullTypeSymbol.prototype.isFunction = function () { + return (this.kind & (33554432 /* ConstructorType */ | 16777216 /* FunctionType */)) != 0; + }; + PullTypeSymbol.prototype.isConstructor = function () { + return this.kind == 33554432 /* ConstructorType */; + }; + PullTypeSymbol.prototype.isTypeParameter = function () { + return false; + }; + PullTypeSymbol.prototype.isTypeVariable = function () { + return false; + }; + PullTypeSymbol.prototype.isError = function () { + return false; + }; + PullTypeSymbol.prototype.isEnum = function () { + return this.kind == 64 /* Enum */; + }; + + PullTypeSymbol.prototype.getKnownBaseTypeCount = function () { + return this._knownBaseTypeCount; + }; + PullTypeSymbol.prototype.resetKnownBaseTypeCount = function () { + this._knownBaseTypeCount = 0; + }; + PullTypeSymbol.prototype.incrementKnownBaseCount = function () { + this._knownBaseTypeCount++; + }; + + PullTypeSymbol.prototype.setHasBaseTypeConflict = function () { + this._hasBaseTypeConflict = true; + }; + PullTypeSymbol.prototype.hasBaseTypeConflict = function () { + return this._hasBaseTypeConflict; + }; + + PullTypeSymbol.prototype.setUnresolved = function () { + _super.prototype.setUnresolved.call(this); + + this._invalidatedSpecializations = false; + + var specializations = this.getKnownSpecializations(); + + for (var i = 0; i < specializations.length; i++) { + specializations[i].setUnresolved(); + } + }; + + PullTypeSymbol.prototype.hasMembers = function () { + if (this._members != TypeScript.sentinelEmptyArray) { + return true; + } + + var parents = this.getExtendedTypes(); + + for (var i = 0; i < parents.length; i++) { + if (parents[i].hasMembers()) { + return true; + } + } + + return false; + }; + + PullTypeSymbol.prototype.setHasGenericSignature = function () { + this._hasGenericSignature = true; + }; + PullTypeSymbol.prototype.getHasGenericSignature = function () { + return this._hasGenericSignature; + }; + + PullTypeSymbol.prototype.setHasGenericMember = function () { + this._hasGenericMember = true; + }; + PullTypeSymbol.prototype.getHasGenericMember = function () { + return this._hasGenericMember; + }; + + PullTypeSymbol.prototype.setAssociatedContainerType = function (type) { + this._associatedContainerTypeSymbol = type; + }; + + PullTypeSymbol.prototype.getAssociatedContainerType = function () { + return this._associatedContainerTypeSymbol; + }; + + PullTypeSymbol.prototype.getArrayType = function () { + return this._arrayVersionOfThisType; + }; + + PullTypeSymbol.prototype.getElementType = function () { + return this._elementType; + }; + + PullTypeSymbol.prototype.setElementType = function (type) { + this._elementType = type; + }; + + PullTypeSymbol.prototype.setArrayType = function (arrayType) { + this._arrayVersionOfThisType = arrayType; + }; + + PullTypeSymbol.prototype.getFunctionSymbol = function () { + return this._functionSymbol; + }; + + PullTypeSymbol.prototype.setFunctionSymbol = function (symbol) { + if (symbol) { + this._functionSymbol = symbol; + } + }; + + PullTypeSymbol.prototype.addContainedNonMember = function (nonMember) { + if (!nonMember) { + return; + } + + if (!this._containedNonMembers) { + this._containedNonMembers = []; + } + + this._containedNonMembers[this._containedNonMembers.length] = nonMember; + + if (!this._containedNonMemberNameCache) { + this._containedNonMemberNameCache = new TypeScript.BlockIntrinsics(); + } + + this._containedNonMemberNameCache[nonMember.name] = nonMember; + }; + + PullTypeSymbol.prototype.findContainedNonMember = function (name) { + if (!this._containedNonMemberNameCache) { + return null; + } + + return this._containedNonMemberNameCache[name]; + }; + + PullTypeSymbol.prototype.findContainedNonMemberType = function (typeName) { + if (!this._containedNonMemberTypeNameCache) { + return null; + } + + return this._containedNonMemberTypeNameCache[typeName]; + }; + + PullTypeSymbol.prototype.addMember = function (memberSymbol) { + if (!memberSymbol) { + return; + } + + memberSymbol.setContainer(this); + + if (!this._memberNameCache) { + this._memberNameCache = new TypeScript.BlockIntrinsics(); + } + + if (this._members == TypeScript.sentinelEmptyArray) { + this._members = []; + } + + this._members[this._members.length] = memberSymbol; + this._memberNameCache[memberSymbol.name] = memberSymbol; + }; + + PullTypeSymbol.prototype.addEnclosedMemberType = function (enclosedType) { + if (!enclosedType) { + return; + } + + enclosedType.setContainer(this); + + if (!this._enclosedTypeNameCache) { + this._enclosedTypeNameCache = new TypeScript.BlockIntrinsics(); + } + + if (!this._enclosedMemberTypes) { + this._enclosedMemberTypes = []; + } + + this._enclosedMemberTypes[this._enclosedMemberTypes.length] = enclosedType; + this._enclosedTypeNameCache[enclosedType.name] = enclosedType; + }; + + PullTypeSymbol.prototype.addEnclosedNonMember = function (enclosedNonMember) { + if (!enclosedNonMember) { + return; + } + + enclosedNonMember.setContainer(this); + + if (!this._containedNonMemberNameCache) { + this._containedNonMemberNameCache = new TypeScript.BlockIntrinsics(); + } + + if (!this._containedNonMembers) { + this._containedNonMembers = []; + } + + this._containedNonMembers[this._containedNonMembers.length] = enclosedNonMember; + this._containedNonMemberNameCache[enclosedNonMember.name] = enclosedNonMember; + }; + + PullTypeSymbol.prototype.addEnclosedNonMemberType = function (enclosedNonMemberType) { + if (!enclosedNonMemberType) { + return; + } + + enclosedNonMemberType.setContainer(this); + + if (!this._containedNonMemberTypeNameCache) { + this._containedNonMemberTypeNameCache = new TypeScript.BlockIntrinsics(); + } + + if (!this._containedNonMemberTypes) { + this._containedNonMemberTypes = []; + } + + this._containedNonMemberTypes[this._containedNonMemberTypes.length] = enclosedNonMemberType; + this._containedNonMemberTypeNameCache[enclosedNonMemberType.name] = enclosedNonMemberType; + }; + + PullTypeSymbol.prototype.addTypeParameter = function (typeParameter) { + if (!typeParameter) { + return; + } + + if (!typeParameter.getContainer()) { + typeParameter.setContainer(this); + } + + if (!this._typeParameterNameCache) { + this._typeParameterNameCache = new TypeScript.BlockIntrinsics(); + } + + if (!this._typeParameters) { + this._typeParameters = []; + } + + this._typeParameters[this._typeParameters.length] = typeParameter; + this._typeParameterNameCache[typeParameter.getName()] = typeParameter; + }; + + PullTypeSymbol.prototype.addConstructorTypeParameter = function (typeParameter) { + this.addTypeParameter(typeParameter); + + var constructSignatures = this.getConstructSignatures(); + + for (var i = 0; i < constructSignatures.length; i++) { + constructSignatures[i].addTypeParameter(typeParameter); + } + }; + + PullTypeSymbol.prototype.getMembers = function () { + return this._members; + }; + + PullTypeSymbol.prototype.setHasDefaultConstructor = function (hasOne) { + if (typeof hasOne === "undefined") { hasOne = true; } + this._hasDefaultConstructor = hasOne; + }; + + PullTypeSymbol.prototype.getHasDefaultConstructor = function () { + return this._hasDefaultConstructor; + }; + + PullTypeSymbol.prototype.getConstructorMethod = function () { + return this._constructorMethod; + }; + + PullTypeSymbol.prototype.setConstructorMethod = function (constructorMethod) { + this._constructorMethod = constructorMethod; + }; + + PullTypeSymbol.prototype.getTypeParameters = function () { + if (!this._typeParameters) { + return TypeScript.sentinelEmptyArray; + } + + return this._typeParameters; + }; + + PullTypeSymbol.prototype.isGeneric = function () { + return (this._typeParameters && this._typeParameters.length != 0) || this._hasGenericSignature || this._hasGenericMember || (this._typeArguments && this._typeArguments.length) || this.isArray(); + }; + + PullTypeSymbol.prototype.isFixed = function () { + if (!this.isGeneric()) { + return true; + } + + if (this._typeParameters && this._typeArguments) { + if (!this._typeArguments.length || this._typeArguments.length < this._typeParameters.length) { + return false; + } + + for (var i = 0; i < this._typeArguments.length; i++) { + if (!this._typeArguments[i].isFixed()) { + return false; + } + } + + return true; + } else if (this._hasGenericMember) { + var members = this.getMembers(); + var memberType = null; + + for (var i = 0; i < members.length; i++) { + memberType = members[i].type; + + if (memberType && !memberType.isFixed()) { + return false; + } + } + + return true; + } + + return false; + }; + + PullTypeSymbol.prototype.addSpecialization = function (specializedVersionOfThisType, substitutingTypes) { + if (!substitutingTypes || !substitutingTypes.length) { + return; + } + + if (!this._specializedTypeIDCache) { + this._specializedTypeIDCache = new TypeScript.BlockIntrinsics(); + } + + if (!this._specializedVersionsOfThisType) { + this._specializedVersionsOfThisType = []; + } + + this._specializedVersionsOfThisType[this._specializedVersionsOfThisType.length] = specializedVersionOfThisType; + + this._specializedTypeIDCache[getIDForTypeSubstitutions(substitutingTypes)] = specializedVersionOfThisType; + }; + + PullTypeSymbol.prototype.getSpecialization = function (substitutingTypes) { + if (!substitutingTypes || !substitutingTypes.length) { + return null; + } + + if (!this._specializedTypeIDCache) { + this._specializedTypeIDCache = new TypeScript.BlockIntrinsics(); + + return null; + } + + var specialization = this._specializedTypeIDCache[getIDForTypeSubstitutions(substitutingTypes)]; + + if (!specialization) { + return null; + } + + return specialization; + }; + + PullTypeSymbol.prototype.getKnownSpecializations = function () { + if (!this._specializedVersionsOfThisType) { + return TypeScript.sentinelEmptyArray; + } + + return this._specializedVersionsOfThisType; + }; + + PullTypeSymbol.prototype.getTypeArguments = function () { + return this._typeArguments; + }; + PullTypeSymbol.prototype.setTypeArguments = function (typeArgs) { + this._typeArguments = typeArgs; + }; + + PullTypeSymbol.prototype.addCallSignature = function (callSignature) { + if (!this._callSignatures) { + this._callSignatures = []; + } + + this._callSignatures[this._callSignatures.length] = callSignature; + + if (callSignature.isGeneric()) { + this._hasGenericSignature = true; + } + + callSignature.functionType = this; + }; + + PullTypeSymbol.prototype.addConstructSignature = function (constructSignature) { + if (!this._constructSignatures) { + this._constructSignatures = []; + } + + this._constructSignatures[this._constructSignatures.length] = constructSignature; + + if (constructSignature.isGeneric()) { + this._hasGenericSignature = true; + } + + constructSignature.functionType = this; + }; + + PullTypeSymbol.prototype.addIndexSignature = function (indexSignature) { + if (!this._indexSignatures) { + this._indexSignatures = []; + } + + this._indexSignatures[this._indexSignatures.length] = indexSignature; + + if (indexSignature.isGeneric()) { + this._hasGenericSignature = true; + } + + indexSignature.functionType = this; + }; + + PullTypeSymbol.prototype.hasOwnCallSignatures = function () { + return !!this._callSignatures; + }; + + PullTypeSymbol.prototype.getCallSignatures = function (collectBaseSignatures) { + if (typeof collectBaseSignatures === "undefined") { collectBaseSignatures = true; } + if (!collectBaseSignatures) { + return this._callSignatures || []; + } + + if (this._allCallSignatures) { + return this._allCallSignatures; + } + + var signatures = []; + + if (this._callSignatures) { + signatures = signatures.concat(this._callSignatures); + } + + if (collectBaseSignatures && this._extendedTypes) { + for (var i = 0; i < this._extendedTypes.length; i++) { + if (this._extendedTypes[i].hasBase(this)) { + continue; + } + + signatures = signatures.concat(this._extendedTypes[i].getCallSignatures()); + } + } + + this._allCallSignatures = signatures; + + return signatures; + }; + + PullTypeSymbol.prototype.hasOwnConstructSignatures = function () { + return !!this._constructSignatures; + }; + + PullTypeSymbol.prototype.getConstructSignatures = function (collectBaseSignatures) { + if (typeof collectBaseSignatures === "undefined") { collectBaseSignatures = true; } + if (!collectBaseSignatures) { + return this._constructSignatures || []; + } + + var signatures = []; + + if (this._constructSignatures) { + signatures = signatures.concat(this._constructSignatures); + } + + if (collectBaseSignatures && this._extendedTypes && !(this.kind == 33554432 /* ConstructorType */)) { + for (var i = 0; i < this._extendedTypes.length; i++) { + if (this._extendedTypes[i].hasBase(this)) { + continue; + } + + signatures = signatures.concat(this._extendedTypes[i].getConstructSignatures()); + } + } + + return signatures; + }; + + PullTypeSymbol.prototype.hasOwnIndexSignatures = function () { + return !!this._indexSignatures; + }; + + PullTypeSymbol.prototype.getIndexSignatures = function (collectBaseSignatures) { + if (typeof collectBaseSignatures === "undefined") { collectBaseSignatures = true; } + if (!collectBaseSignatures) { + return this._indexSignatures || []; + } + + if (this._allIndexSignatures) { + return this._allIndexSignatures; + } + + var signatures = []; + + if (this._indexSignatures) { + signatures = signatures.concat(this._indexSignatures); + } + + if (collectBaseSignatures && this._extendedTypes) { + for (var i = 0; i < this._extendedTypes.length; i++) { + if (this._extendedTypes[i].hasBase(this)) { + continue; + } + + signatures = signatures.concat(this._extendedTypes[i].getIndexSignatures()); + } + } + + this._allIndexSignatures = signatures; + + return signatures; + }; + + PullTypeSymbol.prototype.addImplementedType = function (implementedType) { + if (!implementedType) { + return; + } + + if (!this._implementedTypes) { + this._implementedTypes = []; + } + + this._implementedTypes[this._implementedTypes.length] = implementedType; + + implementedType.addTypeThatExplicitlyImplementsThisType(this); + }; + + PullTypeSymbol.prototype.getImplementedTypes = function () { + if (!this._implementedTypes) { + return TypeScript.sentinelEmptyArray; + } + + return this._implementedTypes; + }; + + PullTypeSymbol.prototype.addExtendedType = function (extendedType) { + if (!extendedType) { + return; + } + + if (!this._extendedTypes) { + this._extendedTypes = []; + } + + this._extendedTypes[this._extendedTypes.length] = extendedType; + + extendedType.addTypeThatExtendsThisType(this); + }; + + PullTypeSymbol.prototype.getExtendedTypes = function () { + if (!this._extendedTypes) { + return TypeScript.sentinelEmptyArray; + } + + return this._extendedTypes; + }; + + PullTypeSymbol.prototype.addTypeThatExtendsThisType = function (type) { + if (!type) { + return; + } + + if (!this._typesThatExtendThisType) { + this._typesThatExtendThisType = []; + } + + this._typesThatExtendThisType[this._typesThatExtendThisType.length] = type; + }; + + PullTypeSymbol.prototype.getTypesThatExtendThisType = function () { + if (!this._typesThatExplicitlyImplementThisType) { + this._typesThatExplicitlyImplementThisType = []; + } + + return this._typesThatExtendThisType; + }; + + PullTypeSymbol.prototype.addTypeThatExplicitlyImplementsThisType = function (type) { + if (!type) { + return; + } + + if (!this._typesThatExplicitlyImplementThisType) { + this._typesThatExplicitlyImplementThisType = []; + } + + this._typesThatExplicitlyImplementThisType[this._typesThatExplicitlyImplementThisType.length] = type; + }; + + PullTypeSymbol.prototype.getTypesThatExplicitlyImplementThisType = function () { + if (!this._typesThatExplicitlyImplementThisType) { + this._typesThatExplicitlyImplementThisType = []; + } + + return this._typesThatExplicitlyImplementThisType; + }; + + PullTypeSymbol.prototype.hasBase = function (potentialBase, origin) { + if (typeof origin === "undefined") { origin = null; } + if (this === potentialBase) { + return true; + } + + if (origin && (this === origin || this.getRootSymbol() === origin)) { + return true; + } + + if (!origin) { + origin = this; + } + + var extendedTypes = this.getExtendedTypes(); + + for (var i = 0; i < extendedTypes.length; i++) { + if (extendedTypes[i].hasBase(potentialBase, origin)) { + return true; + } + } + + var implementedTypes = this.getImplementedTypes(); + + for (var i = 0; i < implementedTypes.length; i++) { + if (implementedTypes[i].hasBase(potentialBase, origin)) { + return true; + } + } + + return false; + }; + + PullTypeSymbol.prototype.isValidBaseKind = function (baseType, isExtendedType) { + if (baseType.isError()) { + return false; + } + + var thisIsClass = this.isClass(); + if (isExtendedType) { + if (thisIsClass) { + return baseType.kind === 8 /* Class */; + } + } else { + if (!thisIsClass) { + return false; + } + } + + return !!(baseType.kind & (16 /* Interface */ | 8 /* Class */ | 128 /* Array */)); + }; + + PullTypeSymbol.prototype.findMember = function (name, lookInParent) { + if (typeof lookInParent === "undefined") { lookInParent = true; } + var memberSymbol = null; + + if (this._memberNameCache) { + memberSymbol = this._memberNameCache[name]; + } + + if (!lookInParent) { + return memberSymbol; + } else if (memberSymbol) { + return memberSymbol; + } + + if (!memberSymbol && this._extendedTypes) { + for (var i = 0; i < this._extendedTypes.length; i++) { + memberSymbol = this._extendedTypes[i].findMember(name); + + if (memberSymbol) { + return memberSymbol; + } + } + } + + return null; + }; + + PullTypeSymbol.prototype.findNestedType = function (name, kind) { + if (typeof kind === "undefined") { kind = 0 /* None */; } + var memberSymbol; + + if (!this._enclosedTypeNameCache) { + return null; + } + + memberSymbol = this._enclosedTypeNameCache[name]; + + if (memberSymbol && kind != 0 /* None */) { + memberSymbol = ((memberSymbol.kind & kind) != 0) ? memberSymbol : null; + } + + return memberSymbol; + }; + + PullTypeSymbol.prototype.getAllMembers = function (searchDeclKind, includePrivate) { + var allMembers = []; + + var i = 0; + var j = 0; + var m = 0; + var n = 0; + + if (this._members != TypeScript.sentinelEmptyArray) { + for (var i = 0, n = this._members.length; i < n; i++) { + var member = this._members[i]; + if ((member.kind & searchDeclKind) && (includePrivate || !member.hasFlag(2 /* Private */))) { + allMembers[allMembers.length] = member; + } + } + } + + if (this._extendedTypes) { + for (var i = 0, n = this._extendedTypes.length; i < n; i++) { + var extendedMembers = this._extendedTypes[i].getAllMembers(searchDeclKind, includePrivate); + + for (var j = 0, m = extendedMembers.length; j < m; j++) { + var extendedMember = extendedMembers[j]; + if (!(this._memberNameCache && this._memberNameCache[extendedMember.name])) { + allMembers[allMembers.length] = extendedMember; + } + } + } + } + + if (this.isContainer() && this._enclosedMemberTypes) { + for (var i = 0; i < this._enclosedMemberTypes.length; i++) { + allMembers[allMembers.length] = this._enclosedMemberTypes[i]; + } + } + + return allMembers; + }; + + PullTypeSymbol.prototype.findTypeParameter = function (name) { + if (!this._typeParameterNameCache) { + return null; + } + + return this._typeParameterNameCache[name]; + }; + + PullTypeSymbol.prototype.setResolved = function () { + _super.prototype.setResolved.call(this); + }; + + PullTypeSymbol.prototype.invalidate = function () { + if (this._constructorMethod) { + this._constructorMethod.invalidate(); + } + + this._knownBaseTypeCount = 0; + + _super.prototype.invalidate.call(this); + }; + + PullTypeSymbol.prototype.getNamePartForFullName = function () { + var name = _super.prototype.getNamePartForFullName.call(this); + + var typars = this.getTypeArguments(); + if (!typars || !typars.length) { + typars = this.getTypeParameters(); + } + + var typarString = PullSymbol.getTypeParameterString(typars, this, true); + return name + typarString; + }; + + PullTypeSymbol.prototype.getScopedName = function (scopeSymbol, useConstraintInName) { + return this.getScopedNameEx(scopeSymbol, useConstraintInName).toString(); + }; + + PullTypeSymbol.prototype.isNamedTypeSymbol = function () { + if (this.isArray()) { + return false; + } + + var kind = this.kind; + if (kind === 2 /* Primitive */ || kind === 8 /* Class */ || kind === 4 /* Container */ || kind === 32 /* DynamicModule */ || kind === 256 /* TypeAlias */ || kind === 64 /* Enum */ || kind === 8192 /* TypeParameter */ || ((kind === 16 /* Interface */ || kind === 8388608 /* ObjectType */) && this.name != "")) { + return true; + } + + return false; + }; + + PullTypeSymbol.prototype.toString = function (scopeSymbol, useConstraintInName) { + var s = this.getScopedNameEx(scopeSymbol, useConstraintInName).toString(); + return s; + }; + + PullTypeSymbol.prototype.getScopedNameEx = function (scopeSymbol, useConstraintInName, getPrettyTypeName, getTypeParamMarkerInfo) { + if (this.isArray()) { + var elementMemberName = this._elementType ? (this._elementType.isArray() || this._elementType.isNamedTypeSymbol() ? this._elementType.getScopedNameEx(scopeSymbol, false, getPrettyTypeName, getTypeParamMarkerInfo) : this._elementType.getMemberTypeNameEx(false, scopeSymbol, getPrettyTypeName)) : TypeScript.MemberName.create("any"); + return TypeScript.MemberName.create(elementMemberName, "", "[]"); + } + + if (!this.isNamedTypeSymbol()) { + return this.getMemberTypeNameEx(true, scopeSymbol, getPrettyTypeName); + } + + var builder = new TypeScript.MemberNameArray(); + builder.prefix = _super.prototype.getScopedName.call(this, scopeSymbol, useConstraintInName); + + var typars = this.getTypeArguments(); + if (!typars || !typars.length) { + typars = this.getTypeParameters(); + } + + builder.add(PullSymbol.getTypeParameterStringEx(typars, scopeSymbol, getTypeParamMarkerInfo, useConstraintInName)); + + return builder; + }; + + PullTypeSymbol.prototype.hasOnlyOverloadCallSignatures = function () { + var members = this.getMembers(); + var callSignatures = this.getCallSignatures(); + var constructSignatures = this.getConstructSignatures(); + return members.length === 0 && constructSignatures.length === 0 && callSignatures.length > 1; + }; + + PullTypeSymbol.prototype.getMemberTypeNameEx = function (topLevel, scopeSymbol, getPrettyTypeName) { + var members = this.getMembers(); + var callSignatures = this.getCallSignatures(); + var constructSignatures = this.getConstructSignatures(); + var indexSignatures = this.getIndexSignatures(); + + if (members.length > 0 || callSignatures.length > 0 || constructSignatures.length > 0 || indexSignatures.length > 0) { + if (this.inMemberTypeNameEx) { + var associatedContainerType = this.getAssociatedContainerType(); + if (associatedContainerType && associatedContainerType.isNamedTypeSymbol()) { + var nameForTypeOf = associatedContainerType.getScopedNameEx(scopeSymbol); + return TypeScript.MemberName.create(nameForTypeOf, "typeof ", ""); + } else { + return TypeScript.MemberName.create("any"); + } + } + + this.inMemberTypeNameEx = true; + + var allMemberNames = new TypeScript.MemberNameArray(); + var curlies = !topLevel || indexSignatures.length != 0; + var delim = "; "; + for (var i = 0; i < members.length; i++) { + if (members[i].kind == 65536 /* Method */ && members[i].type.hasOnlyOverloadCallSignatures()) { + var methodCallSignatures = members[i].type.getCallSignatures(); + var nameStr = members[i].getDisplayName(scopeSymbol) + (members[i].isOptional ? "?" : ""); + ; + var methodMemberNames = PullSignatureSymbol.getSignaturesTypeNameEx(methodCallSignatures, nameStr, false, false, scopeSymbol); + allMemberNames.addAll(methodMemberNames); + } else { + var memberTypeName = members[i].getNameAndTypeNameEx(scopeSymbol); + if (memberTypeName.isArray() && (memberTypeName).delim === delim) { + allMemberNames.addAll((memberTypeName).entries); + } else { + allMemberNames.add(memberTypeName); + } + } + curlies = true; + } + + var getPrettyFunctionOverload = getPrettyTypeName && !curlies && this.hasOnlyOverloadCallSignatures(); + + var signatureCount = callSignatures.length + constructSignatures.length + indexSignatures.length; + var useShortFormSignature = !curlies && (signatureCount === 1); + var signatureMemberName; + + if (callSignatures.length > 0) { + signatureMemberName = PullSignatureSymbol.getSignaturesTypeNameEx(callSignatures, "", useShortFormSignature, false, scopeSymbol, getPrettyFunctionOverload); + allMemberNames.addAll(signatureMemberName); + } + + if (constructSignatures.length > 0) { + signatureMemberName = PullSignatureSymbol.getSignaturesTypeNameEx(constructSignatures, "new", useShortFormSignature, false, scopeSymbol); + allMemberNames.addAll(signatureMemberName); + } + + if (indexSignatures.length > 0) { + signatureMemberName = PullSignatureSymbol.getSignaturesTypeNameEx(indexSignatures, "", useShortFormSignature, true, scopeSymbol); + allMemberNames.addAll(signatureMemberName); + } + + if ((curlies) || (!getPrettyFunctionOverload && (signatureCount > 1) && topLevel)) { + allMemberNames.prefix = "{ "; + allMemberNames.suffix = "}"; + allMemberNames.delim = delim; + } else if (allMemberNames.entries.length > 1) { + allMemberNames.delim = delim; + } + + this.inMemberTypeNameEx = false; + + return allMemberNames; + } + + return TypeScript.MemberName.create("{}"); + }; + + PullTypeSymbol.prototype.isExternallyVisible = function (inIsExternallyVisibleSymbols) { + var isVisible = _super.prototype.isExternallyVisible.call(this, inIsExternallyVisibleSymbols); + if (isVisible) { + var typars = this.getTypeArguments(); + if (!typars || !typars.length) { + typars = this.getTypeParameters(); + } + + if (typars) { + for (var i = 0; i < typars.length; i++) { + isVisible = PullSymbol.getIsExternallyVisible(typars[i], this, inIsExternallyVisibleSymbols); + if (!isVisible) { + break; + } + } + } + } + + return isVisible; + }; + return PullTypeSymbol; + })(PullSymbol); + TypeScript.PullTypeSymbol = PullTypeSymbol; + + var PullPrimitiveTypeSymbol = (function (_super) { + __extends(PullPrimitiveTypeSymbol, _super); + function PullPrimitiveTypeSymbol(name) { + _super.call(this, name, 2 /* Primitive */); + + this.isResolved = true; + } + PullPrimitiveTypeSymbol.prototype.isStringConstant = function () { + return false; + }; + + PullPrimitiveTypeSymbol.prototype.isFixed = function () { + return true; + }; + + PullPrimitiveTypeSymbol.prototype.invalidate = function () { + }; + return PullPrimitiveTypeSymbol; + })(PullTypeSymbol); + TypeScript.PullPrimitiveTypeSymbol = PullPrimitiveTypeSymbol; + + var PullStringConstantTypeSymbol = (function (_super) { + __extends(PullStringConstantTypeSymbol, _super); + function PullStringConstantTypeSymbol(name) { + _super.call(this, name); + } + PullStringConstantTypeSymbol.prototype.isStringConstant = function () { + return true; + }; + return PullStringConstantTypeSymbol; + })(PullPrimitiveTypeSymbol); + TypeScript.PullStringConstantTypeSymbol = PullStringConstantTypeSymbol; + + var PullErrorTypeSymbol = (function (_super) { + __extends(PullErrorTypeSymbol, _super); + function PullErrorTypeSymbol(diagnostic, delegateType, _data) { + if (typeof _data === "undefined") { _data = null; } + _super.call(this, "error"); + this.diagnostic = diagnostic; + this.delegateType = delegateType; + this._data = _data; + + this.isResolved = true; + } + PullErrorTypeSymbol.prototype.isError = function () { + return true; + }; + + PullErrorTypeSymbol.prototype.getDiagnostic = function () { + return this.diagnostic; + }; + + PullErrorTypeSymbol.prototype.getName = function (scopeSymbol, useConstraintInName) { + return this.delegateType.getName(scopeSymbol, useConstraintInName); + }; + + PullErrorTypeSymbol.prototype.getDisplayName = function (scopeSymbol, useConstraintInName) { + return this.delegateType.getDisplayName(scopeSymbol, useConstraintInName); + }; + + PullErrorTypeSymbol.prototype.toString = function (scopeSymbol, useConstraintInName) { + return this.delegateType.toString(scopeSymbol, useConstraintInName); + }; + + PullErrorTypeSymbol.prototype.setData = function (data) { + this._data = data; + }; + + PullErrorTypeSymbol.prototype.getData = function () { + return this._data; + }; + return PullErrorTypeSymbol; + })(PullPrimitiveTypeSymbol); + TypeScript.PullErrorTypeSymbol = PullErrorTypeSymbol; + + var PullContainerTypeSymbol = (function (_super) { + __extends(PullContainerTypeSymbol, _super); + function PullContainerTypeSymbol(name, kind) { + if (typeof kind === "undefined") { kind = 4 /* Container */; } + _super.call(this, name, kind); + this.instanceSymbol = null; + this.assignedValue = null; + this.assignedType = null; + this.assignedContainer = null; + } + PullContainerTypeSymbol.prototype.isContainer = function () { + return true; + }; + + PullContainerTypeSymbol.prototype.setInstanceSymbol = function (symbol) { + this.instanceSymbol = symbol; + }; + + PullContainerTypeSymbol.prototype.getInstanceSymbol = function () { + return this.instanceSymbol; + }; + + PullContainerTypeSymbol.prototype.invalidate = function () { + if (this.instanceSymbol) { + this.instanceSymbol.invalidate(); + } + + _super.prototype.invalidate.call(this); + }; + + PullContainerTypeSymbol.prototype.setExportAssignedValueSymbol = function (symbol) { + this.assignedValue = symbol; + }; + PullContainerTypeSymbol.prototype.getExportAssignedValueSymbol = function () { + return this.assignedValue; + }; + + PullContainerTypeSymbol.prototype.setExportAssignedTypeSymbol = function (type) { + this.assignedType = type; + }; + + PullContainerTypeSymbol.prototype.getExportAssignedTypeSymbol = function () { + return this.assignedType; + }; + + PullContainerTypeSymbol.prototype.setExportAssignedContainerSymbol = function (container) { + this.assignedContainer = container; + }; + + PullContainerTypeSymbol.prototype.getExportAssignedContainerSymbol = function () { + return this.assignedContainer; + }; + + PullContainerTypeSymbol.prototype.resetExportAssignedSymbols = function () { + this.assignedValue = null; + this.assignedType = null; + this.assignedContainer = null; + }; + + PullContainerTypeSymbol.usedAsSymbol = function (containerSymbol, symbol) { + if (!containerSymbol || !containerSymbol.isContainer()) { + return false; + } + + if (!containerSymbol.isAlias() && containerSymbol.type == symbol) { + return true; + } + + var containerTypeSymbol = containerSymbol; + var valueExportSymbol = containerTypeSymbol.getExportAssignedValueSymbol(); + var typeExportSymbol = containerTypeSymbol.getExportAssignedTypeSymbol(); + var containerExportSymbol = containerTypeSymbol.getExportAssignedContainerSymbol(); + if (valueExportSymbol || typeExportSymbol || containerExportSymbol) { + return valueExportSymbol == symbol || typeExportSymbol == symbol || containerExportSymbol == symbol || PullContainerTypeSymbol.usedAsSymbol(containerExportSymbol, symbol); + } + + return false; + }; + + PullContainerTypeSymbol.prototype.getInstanceType = function () { + return this.instanceSymbol ? this.instanceSymbol.type : null; + }; + return PullContainerTypeSymbol; + })(PullTypeSymbol); + TypeScript.PullContainerTypeSymbol = PullContainerTypeSymbol; + + var PullTypeAliasSymbol = (function (_super) { + __extends(PullTypeAliasSymbol, _super); + function PullTypeAliasSymbol(name) { + _super.call(this, name, 256 /* TypeAlias */); + this.assignedValue = null; + this.assignedType = null; + this.assignedContainer = null; + this.isUsedAsValue = false; + this.typeUsedExternally = false; + this.retrievingExportAssignment = false; + } + PullTypeAliasSymbol.prototype.isAlias = function () { + return true; + }; + PullTypeAliasSymbol.prototype.isContainer = function () { + return true; + }; + + PullTypeAliasSymbol.prototype.setAssignedValueSymbol = function (symbol) { + this.assignedValue = symbol; + }; + + PullTypeAliasSymbol.prototype.getExportAssignedValueSymbol = function () { + if (this.assignedValue) { + return this.assignedValue; + } + + if (this.retrievingExportAssignment) { + return null; + } + + if (this.assignedContainer) { + this.retrievingExportAssignment = true; + var sym = this.assignedContainer.getExportAssignedValueSymbol(); + this.retrievingExportAssignment = false; + return sym; + } + + return null; + }; + + PullTypeAliasSymbol.prototype.setAssignedTypeSymbol = function (type) { + this.assignedType = type; + }; + + PullTypeAliasSymbol.prototype.getExportAssignedTypeSymbol = function () { + if (this.retrievingExportAssignment) { + return null; + } + + if (this.assignedType) { + if (this.assignedType.isAlias()) { + this.retrievingExportAssignment = true; + var sym = (this.assignedType).getExportAssignedTypeSymbol(); + this.retrievingExportAssignment = false; + } else if (this.assignedType != this.assignedContainer) { + return this.assignedType; + } + } + + if (this.assignedContainer) { + this.retrievingExportAssignment = true; + var sym = this.assignedContainer.getExportAssignedTypeSymbol(); + this.retrievingExportAssignment = false; + if (sym) { + return sym; + } + } + + return this.assignedContainer; + }; + + PullTypeAliasSymbol.prototype.setAssignedContainerSymbol = function (container) { + this.assignedContainer = container; + }; + + PullTypeAliasSymbol.prototype.getExportAssignedContainerSymbol = function () { + if (this.retrievingExportAssignment) { + return null; + } + + if (this.assignedContainer) { + this.retrievingExportAssignment = true; + var sym = this.assignedContainer.getExportAssignedContainerSymbol(); + this.retrievingExportAssignment = false; + if (sym) { + return sym; + } + } + + return this.assignedContainer; + }; + + PullTypeAliasSymbol.prototype.getMembers = function () { + if (this.assignedType) { + return this.assignedType.getMembers(); + } + + return TypeScript.sentinelEmptyArray; + }; + + PullTypeAliasSymbol.prototype.getCallSignatures = function () { + if (this.assignedType) { + return this.assignedType.getCallSignatures(); + } + + return TypeScript.sentinelEmptyArray; + }; + + PullTypeAliasSymbol.prototype.getConstructSignatures = function () { + if (this.assignedType) { + return this.assignedType.getConstructSignatures(); + } + + return TypeScript.sentinelEmptyArray; + }; + + PullTypeAliasSymbol.prototype.getIndexSignatures = function () { + if (this.assignedType) { + return this.assignedType.getIndexSignatures(); + } + + return TypeScript.sentinelEmptyArray; + }; + + PullTypeAliasSymbol.prototype.findMember = function (name) { + if (this.assignedType) { + return this.assignedType.findMember(name); + } + + return null; + }; + + PullTypeAliasSymbol.prototype.findNestedType = function (name) { + if (this.assignedType) { + return this.assignedType.findNestedType(name); + } + + return null; + }; + + PullTypeAliasSymbol.prototype.getAllMembers = function (searchDeclKind, includePrivate) { + if (this.assignedType) { + return this.assignedType.getAllMembers(searchDeclKind, includePrivate); + } + + return TypeScript.sentinelEmptyArray; + }; + + PullTypeAliasSymbol.prototype.invalidate = function () { + this.isUsedAsValue = false; + + _super.prototype.invalidate.call(this); + }; + return PullTypeAliasSymbol; + })(PullTypeSymbol); + TypeScript.PullTypeAliasSymbol = PullTypeAliasSymbol; + + var PullDefinitionSignatureSymbol = (function (_super) { + __extends(PullDefinitionSignatureSymbol, _super); + function PullDefinitionSignatureSymbol() { + _super.apply(this, arguments); + } + PullDefinitionSignatureSymbol.prototype.isDefinition = function () { + return true; + }; + return PullDefinitionSignatureSymbol; + })(PullSignatureSymbol); + TypeScript.PullDefinitionSignatureSymbol = PullDefinitionSignatureSymbol; + + var PullTypeParameterSymbol = (function (_super) { + __extends(PullTypeParameterSymbol, _super); + function PullTypeParameterSymbol(name, _isFunctionTypeParameter) { + _super.call(this, name, 8192 /* TypeParameter */); + this._isFunctionTypeParameter = _isFunctionTypeParameter; + this._constraint = null; + } + PullTypeParameterSymbol.prototype.isTypeParameter = function () { + return true; + }; + PullTypeParameterSymbol.prototype.isFunctionTypeParameter = function () { + return this._isFunctionTypeParameter; + }; + + PullTypeParameterSymbol.prototype.isFixed = function () { + return false; + }; + + PullTypeParameterSymbol.prototype.setConstraint = function (constraintType) { + this._constraint = constraintType; + }; + + PullTypeParameterSymbol.prototype.getConstraint = function () { + return this._constraint; + }; + + PullTypeParameterSymbol.prototype.isGeneric = function () { + return true; + }; + + PullTypeParameterSymbol.prototype.fullName = function (scopeSymbol) { + var name = this.getDisplayName(scopeSymbol); + var container = this.getContainer(); + if (container) { + var containerName = container.fullName(scopeSymbol); + name = name + " in " + containerName; + } + + return name; + }; + + PullTypeParameterSymbol.prototype.getName = function (scopeSymbol, useConstraintInName) { + var name = _super.prototype.getName.call(this, scopeSymbol); + + if (this.isPrinting) { + return name; + } + + this.isPrinting = true; + + if (useConstraintInName && this._constraint) { + name += " extends " + this._constraint.toString(scopeSymbol); + } + + this.isPrinting = false; + + return name; + }; + + PullTypeParameterSymbol.prototype.getDisplayName = function (scopeSymbol, useConstraintInName) { + var name = _super.prototype.getDisplayName.call(this, scopeSymbol, useConstraintInName); + + if (this.isPrinting) { + return name; + } + + this.isPrinting = true; + + if (useConstraintInName && this._constraint) { + name += " extends " + this._constraint.toString(scopeSymbol); + } + + this.isPrinting = false; + + return name; + }; + + PullTypeParameterSymbol.prototype.isExternallyVisible = function (inIsExternallyVisibleSymbols) { + var constraint = this.getConstraint(); + if (constraint) { + return PullSymbol.getIsExternallyVisible(constraint, this, inIsExternallyVisibleSymbols); + } + + return true; + }; + return PullTypeParameterSymbol; + })(PullTypeSymbol); + TypeScript.PullTypeParameterSymbol = PullTypeParameterSymbol; + + var PullTypeVariableSymbol = (function (_super) { + __extends(PullTypeVariableSymbol, _super); + function PullTypeVariableSymbol(name, isFunctionTypeParameter) { + _super.call(this, name, isFunctionTypeParameter); + this.tyvarID = TypeScript.globalTyvarID++; + } + PullTypeVariableSymbol.prototype.isTypeParameter = function () { + return true; + }; + PullTypeVariableSymbol.prototype.isTypeVariable = function () { + return true; + }; + return PullTypeVariableSymbol; + })(PullTypeParameterSymbol); + TypeScript.PullTypeVariableSymbol = PullTypeVariableSymbol; + + var PullAccessorSymbol = (function (_super) { + __extends(PullAccessorSymbol, _super); + function PullAccessorSymbol(name) { + _super.call(this, name, 4096 /* Property */); + this._getterSymbol = null; + this._setterSymbol = null; + } + PullAccessorSymbol.prototype.isAccessor = function () { + return true; + }; + + PullAccessorSymbol.prototype.setSetter = function (setter) { + if (!setter) { + return; + } + + this._setterSymbol = setter; + + setter.setAccessorSymbol(this); + }; + + PullAccessorSymbol.prototype.getSetter = function () { + return this._setterSymbol; + }; + + PullAccessorSymbol.prototype.setGetter = function (getter) { + if (!getter) { + return; + } + + this._getterSymbol = getter; + + getter.setAccessorSymbol(this); + }; + + PullAccessorSymbol.prototype.getGetter = function () { + return this._getterSymbol; + }; + + PullAccessorSymbol.prototype.invalidate = function () { + if (this._getterSymbol) { + this._getterSymbol.invalidate(); + } + + if (this._setterSymbol) { + this._setterSymbol.invalidate(); + } + + _super.prototype.invalidate.call(this); + }; + return PullAccessorSymbol; + })(PullSymbol); + TypeScript.PullAccessorSymbol = PullAccessorSymbol; + + function typeWrapsTypeParameter(type, typeParameter) { + if (type.isTypeParameter()) { + return type == typeParameter; + } + + var typeArguments = type.getTypeArguments(); + + if (typeArguments) { + for (var i = 0; i < typeArguments.length; i++) { + if (typeWrapsTypeParameter(typeArguments[i], typeParameter)) { + return true; + } + } + } + + return false; + } + TypeScript.typeWrapsTypeParameter = typeWrapsTypeParameter; + + function getRootType(typeToSpecialize) { + var decl = typeToSpecialize.getDeclarations()[0]; + + if (!typeToSpecialize.isGeneric()) { + return typeToSpecialize; + } + + return (typeToSpecialize.kind & (8 /* Class */ | 16 /* Interface */)) ? decl.getSymbol().type : typeToSpecialize; + } + TypeScript.getRootType = getRootType; + + TypeScript.nSpecializationsCreated = 0; + TypeScript.nSpecializedSignaturesCreated = 0; + + function shouldSpecializeTypeParameterForTypeParameter(specialization, typeToSpecialize) { + if (specialization == typeToSpecialize) { + return false; + } + + if (!(specialization.isTypeParameter() && typeToSpecialize.isTypeParameter())) { + return true; + } + + var parent = specialization.getDeclarations()[0].getParentDecl(); + var targetParent = typeToSpecialize.getDeclarations()[0].getParentDecl(); + + if (parent == targetParent) { + return true; + } + + while (parent) { + if (parent.flags & 16 /* Static */) { + return true; + } + + if (parent == targetParent) { + return false; + } + + parent = parent.getParentDecl(); + } + + return true; + } + TypeScript.shouldSpecializeTypeParameterForTypeParameter = shouldSpecializeTypeParameterForTypeParameter; + + function specializeType(typeToSpecialize, typeArguments, resolver, enclosingDecl, context, ast) { + if (typeToSpecialize.isPrimitive() || !typeToSpecialize.isGeneric()) { + return typeToSpecialize; + } + + var searchForExistingSpecialization = typeArguments != null; + + if (typeArguments === null || (context.specializingToAny && typeArguments.length)) { + typeArguments = []; + } + + if (typeToSpecialize.isTypeParameter()) { + if (context.specializingToAny) { + return resolver.semanticInfoChain.anyTypeSymbol; + } + + var substitution = context.findSpecializationForType(typeToSpecialize); + + if (substitution != typeToSpecialize) { + if (shouldSpecializeTypeParameterForTypeParameter(substitution, typeToSpecialize)) { + return substitution; + } + } + + if (typeArguments && typeArguments.length) { + if (shouldSpecializeTypeParameterForTypeParameter(typeArguments[0], typeToSpecialize)) { + return typeArguments[0]; + } + } + + return typeToSpecialize; + } + + if (typeToSpecialize.isArray()) { + if (typeToSpecialize.currentlyBeingSpecialized()) { + return typeToSpecialize; + } + + var newElementType = null; + + if (!context.specializingToAny) { + var elementType = typeToSpecialize.getElementType(); + + newElementType = specializeType(elementType, typeArguments, resolver, enclosingDecl, context, ast); + } else { + newElementType = resolver.semanticInfoChain.anyTypeSymbol; + } + + var newArrayType = specializeType(resolver.getCachedArrayType(), [newElementType], resolver, enclosingDecl, context); + + return newArrayType; + } + + var typeParameters = typeToSpecialize.getTypeParameters(); + + if (!context.specializingToAny && searchForExistingSpecialization && (typeParameters.length > typeArguments.length)) { + searchForExistingSpecialization = false; + } + + var newType = null; + + var newTypeDecl = typeToSpecialize.getDeclarations()[0]; + + var rootType = getRootType(typeToSpecialize); + + var isArray = typeToSpecialize === resolver.getCachedArrayType() || typeToSpecialize.isArray(); + + if (searchForExistingSpecialization || context.specializingToAny || typeToSpecialize.hasRecursiveSpecializationError) { + if (!typeArguments.length || context.specializingToAny || typeToSpecialize.hasRecursiveSpecializationError) { + for (var i = 0; i < typeParameters.length; i++) { + typeArguments[i] = resolver.semanticInfoChain.anyTypeSymbol; + } + } + + if (isArray) { + newType = typeArguments[0].getArrayType(); + } else if (typeArguments.length) { + newType = rootType.getSpecialization(typeArguments); + } + + if (!newType && !typeParameters.length && context.specializingToAny) { + newType = rootType.getSpecialization([resolver.semanticInfoChain.anyTypeSymbol]); + } + + for (var i = 0; i < typeArguments.length; i++) { + if (!typeArguments[i].isTypeParameter() && (typeArguments[i] == rootType || typeWrapsTypeParameter(typeArguments[i], typeParameters[i]))) { + declAST = resolver.semanticInfoChain.getASTForDecl(newTypeDecl); + if (declAST && typeArguments[i] != resolver.getCachedArrayType()) { + diagnostic = context.postError(enclosingDecl.getScriptName(), declAST.minChar, declAST.getLength(), TypeScript.DiagnosticCode.A_generic_type_may_not_reference_itself_with_a_wrapped_form_of_its_own_type_parameters, null, enclosingDecl); + typeToSpecialize.hasRecursiveSpecializationError = true; + return resolver.getNewErrorTypeSymbol(diagnostic); + } else { + return resolver.semanticInfoChain.anyTypeSymbol; + } + } + } + } else { + var knownTypeArguments = typeToSpecialize.getTypeArguments(); + var typesToReplace = knownTypeArguments ? knownTypeArguments : typeParameters; + var diagnostic; + var declAST; + + for (var i = 0; i < typesToReplace.length; i++) { + if (!typesToReplace[i].isTypeParameter() && (typeArguments[i] == rootType || typeWrapsTypeParameter(typesToReplace[i], typeParameters[i]))) { + declAST = resolver.semanticInfoChain.getASTForDecl(newTypeDecl); + if (declAST && typeArguments[i] != resolver.getCachedArrayType()) { + diagnostic = context.postError(enclosingDecl.getScriptName(), declAST.minChar, declAST.getLength(), TypeScript.DiagnosticCode.A_generic_type_may_not_reference_itself_with_a_wrapped_form_of_its_own_type_parameters, null, enclosingDecl); + typeToSpecialize.hasRecursiveSpecializationError = true; + return resolver.getNewErrorTypeSymbol(diagnostic); + } else { + return resolver.semanticInfoChain.anyTypeSymbol; + } + } + + substitution = specializeType(typesToReplace[i], null, resolver, enclosingDecl, context, ast); + + typeArguments[i] = substitution != null ? substitution : typesToReplace[i]; + } + + newType = rootType.getSpecialization(typeArguments); + } + + var rootTypeParameters = rootType.getTypeParameters(); + + if (rootTypeParameters.length && (rootTypeParameters.length == typeArguments.length)) { + for (var i = 0; i < typeArguments.length; i++) { + if (typeArguments[i] != rootTypeParameters[i]) { + break; + } + } + + if (i == rootTypeParameters.length) { + return rootType; + } + } + + if (newType) { + if (!newType.isResolved && !newType.currentlyBeingSpecialized()) { + } else { + return newType; + } + } + + var prevInSpecialization = context.inSpecialization; + context.inSpecialization = true; + + if (!newType) { + TypeScript.nSpecializationsCreated++; + + newType = typeToSpecialize.isClass() ? new PullTypeSymbol(typeToSpecialize.name, 8 /* Class */) : isArray ? new PullTypeSymbol("Array", 128 /* Array */) : typeToSpecialize.isTypeParameter() ? new PullTypeVariableSymbol(typeToSpecialize.name, (typeToSpecialize).isFunctionTypeParameter()) : new PullTypeSymbol(typeToSpecialize.name, typeToSpecialize.kind); + newType.setRootSymbol(rootType); + } + + newType.setIsBeingSpecialized(); + + newType.setTypeArguments(typeArguments); + + newType.hasRecursiveSpecializationError = typeToSpecialize.hasRecursiveSpecializationError; + + rootType.addSpecialization(newType, typeArguments); + + if (isArray) { + newType.setElementType(typeArguments[0]); + typeArguments[0].setArrayType(newType); + } + + if (typeToSpecialize.currentlyBeingSpecialized()) { + return newType; + } + + var prevCurrentlyBeingSpecialized = typeToSpecialize.currentlyBeingSpecialized(); + if (typeToSpecialize.kind == 33554432 /* ConstructorType */) { + typeToSpecialize.setIsBeingSpecialized(); + } + + var typeReplacementMap = {}; + + for (var i = 0; i < typeParameters.length; i++) { + if (typeParameters[i] != typeArguments[i]) { + typeReplacementMap[typeParameters[i].pullSymbolIDString] = typeArguments[i]; + } + newType.addTypeParameter(typeParameters[i]); + } + + var extendedTypesToSpecialize = typeToSpecialize.getExtendedTypes(); + var typeDecl; + var typeAST; + var unitPath; + var decls = typeToSpecialize.getDeclarations(); + var extendTypeSymbol = null; + var implementedTypeSymbol = null; + + if (extendedTypesToSpecialize.length) { + for (var i = 0; i < decls.length; i++) { + typeDecl = decls[i]; + typeAST = resolver.semanticInfoChain.getASTForDecl(typeDecl); + + if (typeAST.extendsList) { + unitPath = resolver.getUnitPath(); + resolver.setUnitPath(typeDecl.getScriptName()); + for (var j = 0; j < typeAST.extendsList.members.length; j++) { + context.pushTypeSpecializationCache(typeReplacementMap); + extendTypeSymbol = resolver.resolveTypeReference(new TypeScript.TypeReference(typeAST.extendsList.members[j], 0), typeDecl, context); + resolver.setUnitPath(unitPath); + context.popTypeSpecializationCache(); + + newType.addExtendedType(extendTypeSymbol); + } + } + } + } + + var implementedTypesToSpecialize = typeToSpecialize.getImplementedTypes(); + + if (implementedTypesToSpecialize.length) { + for (var i = 0; i < decls.length; i++) { + typeDecl = decls[i]; + typeAST = resolver.semanticInfoChain.getASTForDecl(typeDecl); + + if (typeAST.implementsList) { + unitPath = resolver.getUnitPath(); + resolver.setUnitPath(typeDecl.getScriptName()); + for (var j = 0; j < typeAST.implementsList.members.length; j++) { + context.pushTypeSpecializationCache(typeReplacementMap); + implementedTypeSymbol = resolver.resolveTypeReference(new TypeScript.TypeReference(typeAST.implementsList.members[j], 0), typeDecl, context); + resolver.setUnitPath(unitPath); + context.popTypeSpecializationCache(); + + newType.addImplementedType(implementedTypeSymbol); + } + } + } + } + + var callSignatures = typeToSpecialize.getCallSignatures(false); + var constructSignatures = typeToSpecialize.getConstructSignatures(false); + var indexSignatures = typeToSpecialize.getIndexSignatures(false); + var members = typeToSpecialize.getMembers(); + + var newSignature; + var placeHolderSignature; + var signature; + + var decl = null; + var declAST = null; + var parameters; + var newParameters; + var returnType = null; + var prevSpecializationSignature = null; + + for (var i = 0; i < callSignatures.length; i++) { + signature = callSignatures[i]; + + if (!signature.currentlyBeingSpecialized()) { + context.pushTypeSpecializationCache(typeReplacementMap); + + decl = signature.getDeclarations()[0]; + unitPath = resolver.getUnitPath(); + resolver.setUnitPath(decl.getScriptName()); + + newSignature = new PullSignatureSymbol(signature.kind); + TypeScript.nSpecializedSignaturesCreated++; + newSignature.mimicSignature(signature, resolver); + declAST = resolver.semanticInfoChain.getASTForDecl(decl); + + TypeScript.Debug.assert(declAST != null, "Call signature for type '" + typeToSpecialize.toString() + "' could not be specialized because of a stale declaration"); + + prevSpecializationSignature = decl.getSpecializingSignatureSymbol(); + decl.setSpecializingSignatureSymbol(newSignature); + + if (!(signature.isResolved || signature.inResolution)) { + resolver.resolveDeclaredSymbol(signature, enclosingDecl, new TypeScript.PullTypeResolutionContext()); + } + + resolver.resolveAST(declAST, false, newTypeDecl, context, true); + decl.setSpecializingSignatureSymbol(prevSpecializationSignature); + + parameters = signature.parameters; + newParameters = newSignature.parameters; + + for (var p = 0; p < parameters.length; p++) { + newParameters[p].type = parameters[p].type; + } + newSignature.setResolved(); + + resolver.setUnitPath(unitPath); + + returnType = newSignature.returnType; + + if (!returnType) { + newSignature.returnType = signature.returnType; + } + + signature.setIsBeingSpecialized(); + newSignature.setRootSymbol(signature); + placeHolderSignature = newSignature; + newSignature = specializeSignature(newSignature, true, typeReplacementMap, null, resolver, newTypeDecl, context); + signature.setIsSpecialized(); + + if (newSignature != placeHolderSignature) { + newSignature.setRootSymbol(signature); + } + + context.popTypeSpecializationCache(); + + if (!newSignature) { + context.inSpecialization = prevInSpecialization; + typeToSpecialize.setValueIsBeingSpecialized(prevCurrentlyBeingSpecialized); + TypeScript.Debug.assert(false, "returning from call"); + return resolver.semanticInfoChain.anyTypeSymbol; + } + } else { + newSignature = signature; + } + + newType.addCallSignature(newSignature); + + if (newSignature.hasAGenericParameter) { + newType.setHasGenericSignature(); + } + } + + for (var i = 0; i < constructSignatures.length; i++) { + signature = constructSignatures[i]; + + if (!signature.currentlyBeingSpecialized()) { + context.pushTypeSpecializationCache(typeReplacementMap); + + decl = signature.getDeclarations()[0]; + unitPath = resolver.getUnitPath(); + resolver.setUnitPath(decl.getScriptName()); + + newSignature = new PullSignatureSymbol(signature.kind); + TypeScript.nSpecializedSignaturesCreated++; + newSignature.mimicSignature(signature, resolver); + declAST = resolver.semanticInfoChain.getASTForDecl(decl); + + TypeScript.Debug.assert(declAST != null, "Construct signature for type '" + typeToSpecialize.toString() + "' could not be specialized because of a stale declaration"); + + prevSpecializationSignature = decl.getSpecializingSignatureSymbol(); + decl.setSpecializingSignatureSymbol(newSignature); + + if (!(signature.isResolved || signature.inResolution)) { + resolver.resolveDeclaredSymbol(signature, enclosingDecl, new TypeScript.PullTypeResolutionContext()); + } + + resolver.resolveAST(declAST, false, newTypeDecl, context, true); + decl.setSpecializingSignatureSymbol(prevSpecializationSignature); + + parameters = signature.parameters; + newParameters = newSignature.parameters; + + for (var p = 0; p < parameters.length; p++) { + newParameters[p].type = parameters[p].type; + } + newSignature.setResolved(); + + resolver.setUnitPath(unitPath); + + returnType = newSignature.returnType; + + if (!returnType) { + newSignature.returnType = signature.returnType; + } + + signature.setIsBeingSpecialized(); + newSignature.setRootSymbol(signature); + placeHolderSignature = newSignature; + newSignature = specializeSignature(newSignature, true, typeReplacementMap, null, resolver, newTypeDecl, context); + signature.setIsSpecialized(); + + if (newSignature != placeHolderSignature) { + newSignature.setRootSymbol(signature); + } + + context.popTypeSpecializationCache(); + + if (!newSignature) { + context.inSpecialization = prevInSpecialization; + typeToSpecialize.setValueIsBeingSpecialized(prevCurrentlyBeingSpecialized); + TypeScript.Debug.assert(false, "returning from construct"); + return resolver.semanticInfoChain.anyTypeSymbol; + } + } else { + newSignature = signature; + } + + newType.addConstructSignature(newSignature); + + if (newSignature.hasAGenericParameter) { + newType.setHasGenericSignature(); + } + } + + for (var i = 0; i < indexSignatures.length; i++) { + signature = indexSignatures[i]; + + if (!signature.currentlyBeingSpecialized()) { + context.pushTypeSpecializationCache(typeReplacementMap); + + decl = signature.getDeclarations()[0]; + unitPath = resolver.getUnitPath(); + resolver.setUnitPath(decl.getScriptName()); + + newSignature = new PullSignatureSymbol(signature.kind); + TypeScript.nSpecializedSignaturesCreated++; + newSignature.mimicSignature(signature, resolver); + declAST = resolver.semanticInfoChain.getASTForDecl(decl); + + TypeScript.Debug.assert(declAST != null, "Index signature for type '" + typeToSpecialize.toString() + "' could not be specialized because of a stale declaration"); + + prevSpecializationSignature = decl.getSpecializingSignatureSymbol(); + decl.setSpecializingSignatureSymbol(newSignature); + + if (!(signature.isResolved || signature.inResolution)) { + resolver.resolveDeclaredSymbol(signature, enclosingDecl, new TypeScript.PullTypeResolutionContext()); + } + + resolver.resolveAST(declAST, false, newTypeDecl, context, true); + decl.setSpecializingSignatureSymbol(prevSpecializationSignature); + + parameters = signature.parameters; + newParameters = newSignature.parameters; + + for (var p = 0; p < parameters.length; p++) { + newParameters[p].type = parameters[p].type; + } + newSignature.setResolved(); + + resolver.setUnitPath(unitPath); + + returnType = newSignature.returnType; + + if (!returnType) { + newSignature.returnType = signature.returnType; + } + + signature.setIsBeingSpecialized(); + newSignature.setRootSymbol(signature); + placeHolderSignature = newSignature; + newSignature = specializeSignature(newSignature, true, typeReplacementMap, null, resolver, newTypeDecl, context); + signature.setIsSpecialized(); + + if (newSignature != placeHolderSignature) { + newSignature.setRootSymbol(signature); + } + + context.popTypeSpecializationCache(); + + if (!newSignature) { + context.inSpecialization = prevInSpecialization; + typeToSpecialize.setValueIsBeingSpecialized(prevCurrentlyBeingSpecialized); + TypeScript.Debug.assert(false, "returning from index"); + return resolver.semanticInfoChain.anyTypeSymbol; + } + } else { + newSignature = signature; + } + + newType.addIndexSignature(newSignature); + + if (newSignature.hasAGenericParameter) { + newType.setHasGenericSignature(); + } + } + + var field = null; + var newField = null; + + var fieldType = null; + var newFieldType = null; + var replacementType = null; + + var fieldSignatureSymbol = null; + + for (var i = 0; i < members.length; i++) { + field = members[i]; + field.setIsBeingSpecialized(); + + decls = field.getDeclarations(); + + newField = new PullSymbol(field.name, field.kind); + + newField.setRootSymbol(field); + + if (field.isOptional) { + newField.isOptional = true; + } + + if (!field.isResolved) { + resolver.resolveDeclaredSymbol(field, newTypeDecl, context); + } + + fieldType = field.type; + + if (!fieldType) { + fieldType = newType; + } + + replacementType = typeReplacementMap[fieldType.pullSymbolIDString]; + + if (replacementType) { + newField.type = replacementType; + } else { + if (fieldType.isGeneric() && !fieldType.isFixed()) { + unitPath = resolver.getUnitPath(); + resolver.setUnitPath(decls[0].getScriptName()); + + context.pushTypeSpecializationCache(typeReplacementMap); + + newFieldType = specializeType(fieldType, !fieldType.getIsSpecialized() ? typeArguments : null, resolver, newTypeDecl, context, ast); + + resolver.setUnitPath(unitPath); + + context.popTypeSpecializationCache(); + + newField.type = newFieldType; + } else { + newField.type = fieldType; + } + } + field.setIsSpecialized(); + newType.addMember(newField); + } + + if (typeToSpecialize.isClass()) { + var constructorMethod = typeToSpecialize.getConstructorMethod(); + + if (!constructorMethod.isResolved) { + var prevIsSpecializingConstructorMethod = context.isSpecializingConstructorMethod; + context.isSpecializingConstructorMethod = true; + resolver.resolveDeclaredSymbol(constructorMethod, enclosingDecl, context); + context.isSpecializingConstructorMethod = prevIsSpecializingConstructorMethod; + } + + var newConstructorMethod = new PullSymbol(constructorMethod.name, 32768 /* ConstructorMethod */); + var newConstructorType = specializeType(constructorMethod.type, typeArguments, resolver, newTypeDecl, context, ast); + + newConstructorMethod.type = newConstructorType; + + var constructorDecls = constructorMethod.getDeclarations(); + + newConstructorMethod.setRootSymbol(constructorMethod); + + newType.setConstructorMethod(newConstructorMethod); + } + + newType.setIsSpecialized(); + + newType.setResolved(); + typeToSpecialize.setValueIsBeingSpecialized(prevCurrentlyBeingSpecialized); + context.inSpecialization = prevInSpecialization; + return newType; + } + TypeScript.specializeType = specializeType; + + function specializeSignature(signature, skipLocalTypeParameters, typeReplacementMap, typeArguments, resolver, enclosingDecl, context, ast) { + if (signature.currentlyBeingSpecialized()) { + return signature; + } + + if (!signature.isResolved && !signature.inResolution) { + resolver.resolveDeclaredSymbol(signature, enclosingDecl, context); + } + + var newSignature = signature.getSpecialization(typeArguments); + + if (newSignature) { + return newSignature; + } + + signature.setIsBeingSpecialized(); + + var prevInSpecialization = context.inSpecialization; + context.inSpecialization = true; + + newSignature = new PullSignatureSymbol(signature.kind); + TypeScript.nSpecializedSignaturesCreated++; + newSignature.setRootSymbol(signature); + + if (signature.hasVarArgs) { + newSignature.hasVarArgs = true; + } + + if (signature.hasAGenericParameter) { + newSignature.hasAGenericParameter = true; + } + + signature.addSpecialization(newSignature, typeArguments); + + var parameters = signature.parameters; + var typeParameters = signature.getTypeParameters(); + var returnType = signature.returnType; + + for (var i = 0; i < typeParameters.length; i++) { + newSignature.addTypeParameter(typeParameters[i]); + } + + if (signature.hasAGenericParameter) { + newSignature.hasAGenericParameter = true; + } + + var newParameter; + var newParameterType; + var newParameterElementType; + var parameterType; + var replacementParameterType; + var localTypeParameters = new TypeScript.BlockIntrinsics(); + var localSkipMap = null; + + if (skipLocalTypeParameters) { + for (var i = 0; i < typeParameters.length; i++) { + localTypeParameters[typeParameters[i].getName()] = true; + if (!localSkipMap) { + localSkipMap = {}; + } + localSkipMap[typeParameters[i].pullSymbolIDString] = typeParameters[i]; + } + } + + context.pushTypeSpecializationCache(typeReplacementMap); + + if (skipLocalTypeParameters && localSkipMap) { + context.pushTypeSpecializationCache(localSkipMap); + } + var newReturnType = (!localTypeParameters[returnType.name]) ? specializeType(returnType, null, resolver, enclosingDecl, context, ast) : returnType; + if (skipLocalTypeParameters && localSkipMap) { + context.popTypeSpecializationCache(); + } + context.popTypeSpecializationCache(); + + newSignature.returnType = newReturnType; + + for (var k = 0; k < parameters.length; k++) { + newParameter = new PullSymbol(parameters[k].name, parameters[k].kind); + newParameter.setRootSymbol(parameters[k]); + + parameterType = parameters[k].type; + + context.pushTypeSpecializationCache(typeReplacementMap); + if (skipLocalTypeParameters && localSkipMap) { + context.pushTypeSpecializationCache(localSkipMap); + } + newParameterType = !localTypeParameters[parameterType.name] ? specializeType(parameterType, null, resolver, enclosingDecl, context, ast) : parameterType; + if (skipLocalTypeParameters && localSkipMap) { + context.popTypeSpecializationCache(); + } + context.popTypeSpecializationCache(); + + if (parameters[k].isOptional) { + newParameter.isOptional = true; + } + + if (parameters[k].isVarArg) { + newParameter.isVarArg = true; + newSignature.hasVarArgs = true; + } + + if (resolver.isTypeArgumentOrWrapper(newParameterType)) { + newSignature.hasAGenericParameter = true; + } + + newParameter.type = newParameterType; + newSignature.addParameter(newParameter, newParameter.isOptional); + } + + signature.setIsSpecialized(); + + context.inSpecialization = prevInSpecialization; + + return newSignature; + } + TypeScript.specializeSignature = specializeSignature; + + function getIDForTypeSubstitutions(types) { + var substitution = ""; + + for (var i = 0; i < types.length; i++) { + substitution += types[i].pullSymbolIDString + "#"; + } + + return substitution; + } + TypeScript.getIDForTypeSubstitutions = getIDForTypeSubstitutions; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var PullSymbolBindingContext = (function () { + function PullSymbolBindingContext(semanticInfoChain, scriptName) { + this.semanticInfoChain = semanticInfoChain; + this.scriptName = scriptName; + this.parentChain = []; + this.declPath = []; + this.reBindingAfterChange = false; + this.startingDeclForRebind = TypeScript.pullDeclID; + this.semanticInfo = this.semanticInfoChain.getUnit(this.scriptName); + } + PullSymbolBindingContext.prototype.getParent = function (n) { + if (typeof n === "undefined") { n = 0; } + return this.parentChain ? this.parentChain[this.parentChain.length - 1 - n] : null; + }; + PullSymbolBindingContext.prototype.getDeclPath = function () { + return this.declPath; + }; + + PullSymbolBindingContext.prototype.pushParent = function (parentDecl) { + if (parentDecl) { + this.parentChain[this.parentChain.length] = parentDecl; + this.declPath[this.declPath.length] = parentDecl.name; + } + }; + + PullSymbolBindingContext.prototype.popParent = function () { + if (this.parentChain.length) { + this.parentChain.length--; + this.declPath.length--; + } + }; + return PullSymbolBindingContext; + })(); + TypeScript.PullSymbolBindingContext = PullSymbolBindingContext; + + TypeScript.time_in_findSymbol = 0; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var CandidateInferenceInfo = (function () { + function CandidateInferenceInfo() { + this.typeParameter = null; + this.isFixed = false; + this.inferenceCandidates = []; + } + CandidateInferenceInfo.prototype.addCandidate = function (candidate) { + if (!this.isFixed) { + this.inferenceCandidates[this.inferenceCandidates.length] = candidate; + } + }; + return CandidateInferenceInfo; + })(); + TypeScript.CandidateInferenceInfo = CandidateInferenceInfo; + + var ArgumentInferenceContext = (function () { + function ArgumentInferenceContext() { + this.inferenceCache = {}; + this.candidateCache = {}; + } + ArgumentInferenceContext.prototype.alreadyRelatingTypes = function (objectType, parameterType) { + var comboID = objectType.pullSymbolIDString + "#" + parameterType.pullSymbolIDString; + + if (this.inferenceCache[comboID]) { + return true; + } else { + this.inferenceCache[comboID] = true; + return false; + } + }; + + ArgumentInferenceContext.prototype.resetRelationshipCache = function () { + this.inferenceCache = {}; + }; + + ArgumentInferenceContext.prototype.addInferenceRoot = function (param) { + var info = this.candidateCache[param.pullSymbolIDString]; + + if (!info) { + info = new CandidateInferenceInfo(); + info.typeParameter = param; + this.candidateCache[param.pullSymbolIDString] = info; + } + }; + + ArgumentInferenceContext.prototype.getInferenceInfo = function (param) { + return this.candidateCache[param.pullSymbolIDString]; + }; + + ArgumentInferenceContext.prototype.addCandidateForInference = function (param, candidate, fix) { + var info = this.getInferenceInfo(param); + + if (info) { + if (candidate) { + info.addCandidate(candidate); + } + + if (!info.isFixed) { + info.isFixed = fix; + } + } + }; + + ArgumentInferenceContext.prototype.getInferenceCandidates = function () { + var inferenceCandidates = []; + var info; + var val; + + for (var infoKey in this.candidateCache) { + info = this.candidateCache[infoKey]; + + for (var i = 0; i < info.inferenceCandidates.length; i++) { + val = {}; + val[info.typeParameter.pullSymbolIDString] = info.inferenceCandidates[i]; + inferenceCandidates[inferenceCandidates.length] = val; + } + } + + return inferenceCandidates; + }; + + ArgumentInferenceContext.prototype.inferArgumentTypes = function (resolver, context) { + var info = null; + + var collection; + + var bestCommonType; + + var results = []; + + var unfit = false; + + for (var infoKey in this.candidateCache) { + info = this.candidateCache[infoKey]; + + if (!info.inferenceCandidates.length) { + results[results.length] = { param: info.typeParameter, type: resolver.semanticInfoChain.anyTypeSymbol }; + continue; + } + + collection = { + getLength: function () { + return info.inferenceCandidates.length; + }, + setTypeAtIndex: function (index, type) { + }, + getTypeAtIndex: function (index) { + return info.inferenceCandidates[index].type; + } + }; + + bestCommonType = resolver.widenType(resolver.findBestCommonType(info.inferenceCandidates[0], null, collection, context, new TypeScript.TypeComparisonInfo())); + + if (!bestCommonType) { + unfit = true; + } else { + for (var i = 0; i < results.length; i++) { + if (results[i].type == info.typeParameter) { + results[i].type = bestCommonType; + } + } + } + + results[results.length] = { param: info.typeParameter, type: bestCommonType }; + } + + return { results: results, unfit: unfit }; + }; + return ArgumentInferenceContext; + })(); + TypeScript.ArgumentInferenceContext = ArgumentInferenceContext; + + var PullContextualTypeContext = (function () { + function PullContextualTypeContext(contextualType, provisional, substitutions) { + this.contextualType = contextualType; + this.provisional = provisional; + this.substitutions = substitutions; + this.provisionallyTypedSymbols = []; + this.provisionalDiagnostic = []; + } + PullContextualTypeContext.prototype.recordProvisionallyTypedSymbol = function (symbol) { + this.provisionallyTypedSymbols[this.provisionallyTypedSymbols.length] = symbol; + }; + + PullContextualTypeContext.prototype.invalidateProvisionallyTypedSymbols = function () { + for (var i = 0; i < this.provisionallyTypedSymbols.length; i++) { + this.provisionallyTypedSymbols[i].invalidate(); + } + }; + + PullContextualTypeContext.prototype.postDiagnostic = function (error) { + this.provisionalDiagnostic[this.provisionalDiagnostic.length] = error; + }; + + PullContextualTypeContext.prototype.hadProvisionalErrors = function () { + return this.provisionalDiagnostic.length > 0; + }; + return PullContextualTypeContext; + })(); + TypeScript.PullContextualTypeContext = PullContextualTypeContext; + + var PullTypeResolutionContext = (function () { + function PullTypeResolutionContext(inTypeCheck) { + if (typeof inTypeCheck === "undefined") { inTypeCheck = false; } + this.inTypeCheck = inTypeCheck; + this.contextStack = []; + this.typeSpecializationStack = []; + this.genericASTResolutionStack = []; + this.resolvingTypeReference = false; + this.resolvingNamespaceMemberAccess = false; + this.resolveAggressively = false; + this.canUseTypeSymbol = false; + this.specializingToAny = false; + this.specializingToObject = false; + this.isResolvingClassExtendedType = false; + this.isSpecializingSignatureAtCallSite = false; + this.isSpecializingConstructorMethod = false; + this.isComparingSpecializedSignatures = false; + this.isResolvingSuperConstructorTarget = false; + this.inConstructorArguments = false; + this.inImportDeclaration = false; + this.isInStaticInitializer = false; + this.isInInvocationExpression = false; + this.resolvingTypeNameAsNameExpression = false; + this.inSpecialization = false; + this.suppressErrors = false; + this.inBaseTypeResolution = false; + } + PullTypeResolutionContext.prototype.pushContextualType = function (type, provisional, substitutions) { + this.contextStack.push(new PullContextualTypeContext(type, provisional, substitutions)); + }; + + PullTypeResolutionContext.prototype.popContextualType = function () { + var tc = this.contextStack.pop(); + + tc.invalidateProvisionallyTypedSymbols(); + + return tc; + }; + + PullTypeResolutionContext.prototype.findSubstitution = function (type) { + var substitution = null; + + if (this.contextStack.length) { + for (var i = this.contextStack.length - 1; i >= 0; i--) { + if (this.contextStack[i].substitutions) { + substitution = this.contextStack[i].substitutions[type.pullSymbolIDString]; + + if (substitution) { + break; + } + } + } + } + + return substitution; + }; + + PullTypeResolutionContext.prototype.getContextualType = function () { + var context = !this.contextStack.length ? null : this.contextStack[this.contextStack.length - 1]; + + if (context) { + var type = context.contextualType; + + if (!type) { + return null; + } + + if (type.isTypeParameter() && (type).getConstraint()) { + type = (type).getConstraint(); + } + + var substitution = this.findSubstitution(type); + + return substitution ? substitution : type; + } + + return null; + }; + + PullTypeResolutionContext.prototype.inProvisionalResolution = function () { + return (!this.contextStack.length ? false : this.contextStack[this.contextStack.length - 1].provisional); + }; + + PullTypeResolutionContext.prototype.isInBaseTypeResolution = function () { + return this.inBaseTypeResolution; + }; + + PullTypeResolutionContext.prototype.startBaseTypeResolution = function () { + var wasInBaseTypeResoltion = this.inBaseTypeResolution; + this.inBaseTypeResolution = true; + return wasInBaseTypeResoltion; + }; + + PullTypeResolutionContext.prototype.doneBaseTypeResolution = function (wasInBaseTypeResolution) { + this.inBaseTypeResolution = wasInBaseTypeResolution; + }; + + PullTypeResolutionContext.prototype.setTypeInContext = function (symbol, type) { + var substitution = this.findSubstitution(type); + + symbol.type = substitution ? substitution : type; + + if (this.contextStack.length && this.inProvisionalResolution()) { + this.contextStack[this.contextStack.length - 1].recordProvisionallyTypedSymbol(symbol); + } + }; + + PullTypeResolutionContext.prototype.pushTypeSpecializationCache = function (cache) { + this.typeSpecializationStack[this.typeSpecializationStack.length] = cache; + }; + + PullTypeResolutionContext.prototype.popTypeSpecializationCache = function () { + if (this.typeSpecializationStack.length) { + this.typeSpecializationStack.length--; + } + }; + + PullTypeResolutionContext.prototype.findSpecializationForType = function (type) { + var specialization = null; + + for (var i = this.typeSpecializationStack.length - 1; i >= 0; i--) { + specialization = (this.typeSpecializationStack[i])[type.pullSymbolIDString]; + + if (specialization) { + return specialization; + } + } + + return type; + }; + + PullTypeResolutionContext.prototype.postError = function (fileName, offset, length, diagnosticKey, arguments, enclosingDecl, post) { + if (typeof post === "undefined") { post = true; } + var diagnostic = new TypeScript.Diagnostic(fileName, offset, length, diagnosticKey, arguments); + + if (post) { + this.postDiagnostic(diagnostic, enclosingDecl); + } + + return diagnostic; + }; + + PullTypeResolutionContext.prototype.postDiagnostic = function (diagnostic, enclosingDecl) { + if (this.inProvisionalResolution()) { + (this.contextStack[this.contextStack.length - 1]).postDiagnostic(diagnostic); + } else if (this.inTypeCheck && !this.suppressErrors && enclosingDecl) { + enclosingDecl.addDiagnostic(diagnostic); + } + }; + + PullTypeResolutionContext.prototype.typeCheck = function () { + return this.inTypeCheck && !this.inSpecialization; + }; + + PullTypeResolutionContext.prototype.startResolvingTypeArguments = function (ast) { + this.genericASTResolutionStack[this.genericASTResolutionStack.length] = ast; + }; + + PullTypeResolutionContext.prototype.isResolvingTypeArguments = function (ast) { + for (var i = 0; i < this.genericASTResolutionStack.length; i++) { + if (this.genericASTResolutionStack[i].astID === ast.astID) { + return true; + } + } + + return false; + }; + + PullTypeResolutionContext.prototype.doneResolvingTypeArguments = function () { + this.genericASTResolutionStack.length--; + }; + return PullTypeResolutionContext; + })(); + TypeScript.PullTypeResolutionContext = PullTypeResolutionContext; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var PullResolutionDataCache = (function () { + function PullResolutionDataCache() { + this.cacheSize = 16; + this.rdCache = []; + this.nextUp = 0; + for (var i = 0; i < this.cacheSize; i++) { + this.rdCache[i] = { + actuals: [], + exactCandidates: [], + conversionCandidates: [], + id: i + }; + } + } + PullResolutionDataCache.prototype.getResolutionData = function () { + var rd = null; + + if (this.nextUp < this.cacheSize) { + rd = this.rdCache[this.nextUp]; + } + + if (rd === null) { + this.cacheSize++; + rd = { + actuals: [], + exactCandidates: [], + conversionCandidates: [], + id: this.cacheSize + }; + this.rdCache[this.cacheSize] = rd; + } + + this.nextUp++; + + return rd; + }; + + PullResolutionDataCache.prototype.returnResolutionData = function (rd) { + rd.actuals.length = 0; + rd.exactCandidates.length = 0; + rd.conversionCandidates.length = 0; + + this.nextUp = rd.id; + }; + return PullResolutionDataCache; + })(); + TypeScript.PullResolutionDataCache = PullResolutionDataCache; + + var PullAdditionalCallResolutionData = (function () { + function PullAdditionalCallResolutionData() { + this.targetSymbol = null; + this.targetTypeSymbol = null; + this.resolvedSignatures = null; + this.candidateSignature = null; + this.actualParametersContextTypeSymbols = null; + } + return PullAdditionalCallResolutionData; + })(); + TypeScript.PullAdditionalCallResolutionData = PullAdditionalCallResolutionData; + + var PullAdditionalObjectLiteralResolutionData = (function () { + function PullAdditionalObjectLiteralResolutionData() { + this.membersContextTypeSymbols = null; + } + return PullAdditionalObjectLiteralResolutionData; + })(); + TypeScript.PullAdditionalObjectLiteralResolutionData = PullAdditionalObjectLiteralResolutionData; + + var PullTypeResolver = (function () { + function PullTypeResolver(compilationSettings, semanticInfoChain, unitPath) { + this.compilationSettings = compilationSettings; + this.semanticInfoChain = semanticInfoChain; + this.unitPath = unitPath; + this._cachedArrayInterfaceType = null; + this._cachedNumberInterfaceType = null; + this._cachedStringInterfaceType = null; + this._cachedBooleanInterfaceType = null; + this._cachedObjectInterfaceType = null; + this._cachedFunctionInterfaceType = null; + this._cachedIArgumentsInterfaceType = null; + this._cachedRegExpInterfaceType = null; + this.cachedFunctionArgumentsSymbol = null; + this.seenSuperConstructorCall = false; + this.assignableCache = {}; + this.subtypeCache = {}; + this.identicalCache = {}; + this.resolutionDataCache = new PullResolutionDataCache(); + this.currentUnit = null; + this.lastExternalModulePath = ""; + this.cachedFunctionArgumentsSymbol = new TypeScript.PullSymbol("arguments", 1024 /* Variable */); + this.cachedFunctionArgumentsSymbol.type = this.cachedIArgumentsInterfaceType() ? this.cachedIArgumentsInterfaceType() : this.semanticInfoChain.anyTypeSymbol; + this.cachedFunctionArgumentsSymbol.setResolved(); + + var functionArgumentsDecl = new TypeScript.PullDecl("arguments", "arguments", 2048 /* Parameter */, 0 /* None */, new TypeScript.TextSpan(0, 0), unitPath); + functionArgumentsDecl.setSymbol(this.cachedFunctionArgumentsSymbol); + this.cachedFunctionArgumentsSymbol.addDeclaration(functionArgumentsDecl); + + this.currentUnit = this.semanticInfoChain.getUnit(unitPath); + } + PullTypeResolver.prototype.cleanCachedGlobals = function () { + this._cachedArrayInterfaceType = null; + this._cachedNumberInterfaceType = null; + this._cachedStringInterfaceType = null; + this._cachedBooleanInterfaceType = null; + this._cachedObjectInterfaceType = null; + this._cachedFunctionInterfaceType = null; + this._cachedIArgumentsInterfaceType = null; + this._cachedRegExpInterfaceType = null; + this.cachedFunctionArgumentsSymbol = null; + + this.identicalCache = {}; + this.subtypeCache = {}; + this.assignableCache = {}; + }; + + PullTypeResolver.prototype.cachedArrayInterfaceType = function () { + if (!this._cachedArrayInterfaceType) { + this._cachedArrayInterfaceType = this.getSymbolFromDeclPath("Array", [], 16 /* Interface */); + } + + if (!this._cachedArrayInterfaceType) { + this._cachedArrayInterfaceType = this.semanticInfoChain.anyTypeSymbol; + } + + if (!this._cachedArrayInterfaceType.isResolved) { + this.resolveDeclaredSymbol(this._cachedArrayInterfaceType, null, new TypeScript.PullTypeResolutionContext()); + } + + return this._cachedArrayInterfaceType; + }; + + PullTypeResolver.prototype.getCachedArrayType = function () { + return this.cachedArrayInterfaceType(); + }; + + PullTypeResolver.prototype.cachedNumberInterfaceType = function () { + if (!this._cachedNumberInterfaceType) { + this._cachedNumberInterfaceType = this.getSymbolFromDeclPath("Number", [], 16 /* Interface */); + } + + if (this._cachedNumberInterfaceType && !this._cachedNumberInterfaceType.isResolved) { + this.resolveDeclaredSymbol(this._cachedNumberInterfaceType, null, new TypeScript.PullTypeResolutionContext()); + } + + return this._cachedNumberInterfaceType; + }; + + PullTypeResolver.prototype.cachedStringInterfaceType = function () { + if (!this._cachedStringInterfaceType) { + this._cachedStringInterfaceType = this.getSymbolFromDeclPath("String", [], 16 /* Interface */); + } + + if (this._cachedStringInterfaceType && !this._cachedStringInterfaceType.isResolved) { + this.resolveDeclaredSymbol(this._cachedStringInterfaceType, null, new TypeScript.PullTypeResolutionContext()); + } + + return this._cachedStringInterfaceType; + }; + + PullTypeResolver.prototype.cachedBooleanInterfaceType = function () { + if (!this._cachedBooleanInterfaceType) { + this._cachedBooleanInterfaceType = this.getSymbolFromDeclPath("Boolean", [], 16 /* Interface */); + } + + if (this._cachedBooleanInterfaceType && !this._cachedBooleanInterfaceType.isResolved) { + this.resolveDeclaredSymbol(this._cachedBooleanInterfaceType, null, new TypeScript.PullTypeResolutionContext()); + } + + return this._cachedBooleanInterfaceType; + }; + + PullTypeResolver.prototype.cachedObjectInterfaceType = function () { + if (!this._cachedObjectInterfaceType) { + this._cachedObjectInterfaceType = this.getSymbolFromDeclPath("Object", [], 16 /* Interface */); + } + + if (!this._cachedObjectInterfaceType) { + this._cachedObjectInterfaceType = this.semanticInfoChain.anyTypeSymbol; + } + + if (!this._cachedObjectInterfaceType.isResolved) { + this.resolveDeclaredSymbol(this._cachedObjectInterfaceType, null, new TypeScript.PullTypeResolutionContext()); + } + + return this._cachedObjectInterfaceType; + }; + + PullTypeResolver.prototype.cachedFunctionInterfaceType = function () { + if (!this._cachedFunctionInterfaceType) { + this._cachedFunctionInterfaceType = this.getSymbolFromDeclPath("Function", [], 16 /* Interface */); + } + + if (this._cachedFunctionInterfaceType && !this._cachedFunctionInterfaceType.isResolved) { + this.resolveDeclaredSymbol(this._cachedFunctionInterfaceType, null, new TypeScript.PullTypeResolutionContext()); + } + + return this._cachedFunctionInterfaceType; + }; + + PullTypeResolver.prototype.cachedIArgumentsInterfaceType = function () { + if (!this._cachedIArgumentsInterfaceType) { + this._cachedIArgumentsInterfaceType = this.getSymbolFromDeclPath("IArguments", [], 16 /* Interface */); + } + + if (this._cachedIArgumentsInterfaceType && !this._cachedIArgumentsInterfaceType.isResolved) { + this.resolveDeclaredSymbol(this._cachedIArgumentsInterfaceType, null, new TypeScript.PullTypeResolutionContext()); + } + + return this._cachedIArgumentsInterfaceType; + }; + + PullTypeResolver.prototype.cachedRegExpInterfaceType = function () { + if (!this._cachedRegExpInterfaceType) { + this._cachedRegExpInterfaceType = this.getSymbolFromDeclPath("RegExp", [], 16 /* Interface */); + } + + if (!this._cachedRegExpInterfaceType.isResolved) { + this.resolveDeclaredSymbol(this._cachedRegExpInterfaceType, null, new TypeScript.PullTypeResolutionContext()); + } + + return this._cachedRegExpInterfaceType; + }; + + PullTypeResolver.prototype.getUnitPath = function () { + return this.unitPath; + }; + + PullTypeResolver.prototype.setUnitPath = function (unitPath) { + this.unitPath = unitPath; + + this.currentUnit = this.semanticInfoChain.getUnit(unitPath); + }; + + PullTypeResolver.prototype.getDeclForAST = function (ast) { + return this.semanticInfoChain.getDeclForAST(ast, this.unitPath); + }; + + PullTypeResolver.prototype.getSymbolForAST = function (ast) { + return this.semanticInfoChain.getSymbolForAST(ast, this.unitPath); + }; + + PullTypeResolver.prototype.setSymbolForAST = function (ast, symbol, context) { + if (context && (context.inProvisionalResolution() || context.inSpecialization)) { + return; + } + + this.semanticInfoChain.setSymbolForAST(ast, symbol, this.unitPath); + }; + + PullTypeResolver.prototype.getASTForSymbol = function (symbol) { + return this.semanticInfoChain.getASTForSymbol(symbol, this.unitPath); + }; + + PullTypeResolver.prototype.getASTForDecl = function (decl) { + return this.semanticInfoChain.getASTForDecl(decl); + }; + + PullTypeResolver.prototype.getNewErrorTypeSymbol = function (diagnostic, data) { + return new TypeScript.PullErrorTypeSymbol(diagnostic, this.semanticInfoChain.anyTypeSymbol, data); + }; + + PullTypeResolver.prototype.getEnclosingDecl = function (decl) { + var declPath = TypeScript.getPathToDecl(decl); + + if (!declPath.length) { + return null; + } else if (declPath.length > 1 && declPath[declPath.length - 1] === decl) { + return declPath[declPath.length - 2]; + } else { + return declPath[declPath.length - 1]; + } + }; + + PullTypeResolver.prototype.getExportedMemberSymbol = function (symbol, parent) { + if (!(symbol.kind & (65536 /* Method */ | 4096 /* Property */))) { + var isContainer = (parent.kind & (4 /* Container */ | 32 /* DynamicModule */)) != 0; + var containerType = !isContainer ? parent.getAssociatedContainerType() : parent; + + if (isContainer && containerType) { + if (symbol.hasFlag(1 /* Exported */)) { + return symbol; + } + + return null; + } + } + + return symbol; + }; + + PullTypeResolver.prototype.getMemberSymbol = function (symbolName, declSearchKind, parent) { + var member = null; + + if (declSearchKind & TypeScript.PullElementKind.SomeValue) { + member = parent.findMember(symbolName); + } else { + member = parent.findNestedType(symbolName); + } + + if (member) { + return this.getExportedMemberSymbol(member, parent); + } + + var containerType = parent.getAssociatedContainerType(); + + if (containerType) { + if (containerType.isClass()) { + return null; + } + + parent = containerType; + } + + if (declSearchKind & TypeScript.PullElementKind.SomeValue) { + member = parent.findMember(symbolName); + } else { + member = parent.findNestedType(symbolName); + } + + if (member) { + return this.getExportedMemberSymbol(member, parent); + } + + var typeDeclarations = parent.getDeclarations(); + var childDecls = null; + + for (var j = 0; j < typeDeclarations.length; j++) { + childDecls = typeDeclarations[j].searchChildDecls(symbolName, declSearchKind); + + if (childDecls.length) { + member = childDecls[0].getSymbol(); + + if (!member) { + member = childDecls[0].getSignatureSymbol(); + } + return this.getExportedMemberSymbol(member, parent); + } + + if ((declSearchKind & TypeScript.PullElementKind.SomeType) != 0 || (declSearchKind & TypeScript.PullElementKind.SomeValue) != 0) { + childDecls = typeDeclarations[j].searchChildDecls(symbolName, 256 /* TypeAlias */); + if (childDecls.length && childDecls[0].kind == 256 /* TypeAlias */) { + var aliasSymbol = this.getExportedMemberSymbol(childDecls[0].getSymbol(), parent); + if (aliasSymbol) { + if ((declSearchKind & TypeScript.PullElementKind.SomeType) != 0) { + var typeSymbol = aliasSymbol.getExportAssignedTypeSymbol(); + if (typeSymbol) { + return typeSymbol; + } + } else { + var valueSymbol = aliasSymbol.getExportAssignedValueSymbol(); + if (valueSymbol) { + return valueSymbol; + } + } + } + } + } + } + }; + + PullTypeResolver.prototype.getSymbolFromDeclPath = function (symbolName, declPath, declSearchKind) { + var symbol = null; + + var decl = null; + var childDecls; + var declSymbol = null; + var declMembers; + var pathDeclKind; + var valDecl = null; + var kind; + var instanceSymbol = null; + var instanceType = null; + var childSymbol = null; + + for (var i = declPath.length - 1; i >= 0; i--) { + decl = declPath[i]; + pathDeclKind = decl.kind; + + if (decl.flags & 2097152 /* DeclaredInAWithBlock */) { + return this.semanticInfoChain.anyTypeSymbol; + } + + if (pathDeclKind & (4 /* Container */ | 32 /* DynamicModule */)) { + childDecls = decl.searchChildDecls(symbolName, declSearchKind); + + if (childDecls.length) { + return childDecls[0].getSymbol(); + } + + if (declSearchKind & TypeScript.PullElementKind.SomeValue) { + instanceSymbol = (decl.getSymbol()).getInstanceSymbol(); + + childDecls = decl.searchChildDecls(symbolName, 256 /* TypeAlias */); + + if (childDecls.length) { + var sym = childDecls[0].getSymbol(); + + if (sym.isAlias()) { + return sym; + } + } + + if (instanceSymbol) { + instanceType = instanceSymbol.type; + + childSymbol = this.getMemberSymbol(symbolName, declSearchKind, instanceType); + + if (childSymbol && (childSymbol.kind & declSearchKind)) { + return childSymbol; + } + } + + valDecl = decl.getValueDecl(); + + if (valDecl) { + decl = valDecl; + } + } + + declSymbol = decl.getSymbol().type; + + var childSymbol = this.getMemberSymbol(symbolName, declSearchKind, declSymbol); + + if (childSymbol) { + return childSymbol; + } + } else if ((declSearchKind & (TypeScript.PullElementKind.SomeType | TypeScript.PullElementKind.SomeContainer)) || !(pathDeclKind & 8 /* Class */)) { + var candidateSymbol = null; + + if (pathDeclKind === 131072 /* FunctionExpression */ && symbolName === (decl).getFunctionExpressionName()) { + candidateSymbol = decl.getSymbol(); + } + + childDecls = decl.searchChildDecls(symbolName, declSearchKind); + + if (childDecls.length) { + if (decl.kind & TypeScript.PullElementKind.SomeFunction) { + decl.ensureSymbolIsBound(); + } + return childDecls[0].getSymbol(); + } + + if (candidateSymbol) { + return candidateSymbol; + } + + if (declSearchKind & TypeScript.PullElementKind.SomeValue) { + childDecls = decl.searchChildDecls(symbolName, 256 /* TypeAlias */); + + if (childDecls.length) { + var sym = childDecls[0].getSymbol(); + + if (sym.isAlias()) { + return sym; + } + } + } + } + } + + symbol = this.semanticInfoChain.findSymbol([symbolName], declSearchKind); + + return symbol; + }; + + PullTypeResolver.prototype.getVisibleDeclsFromDeclPath = function (declPath, declSearchKind) { + var result = []; + var decl = null; + var childDecls; + var pathDeclKind; + + for (var i = declPath.length - 1; i >= 0; i--) { + decl = declPath[i]; + pathDeclKind = decl.kind; + + var declKind = decl.kind; + + if (declKind !== 8 /* Class */ && declKind !== 16 /* Interface */) { + this.addFilteredDecls(decl.getChildDecls(), declSearchKind, result); + } + + switch (declKind) { + case 4 /* Container */: + case 32 /* DynamicModule */: + var otherDecls = this.semanticInfoChain.findDeclsFromPath(declPath.slice(0, i + 1), TypeScript.PullElementKind.SomeContainer); + for (var j = 0, m = otherDecls.length; j < m; j++) { + var otherDecl = otherDecls[j]; + if (otherDecl === decl) { + continue; + } + + var otherDeclChildren = otherDecl.getChildDecls(); + for (var k = 0, s = otherDeclChildren.length; k < s; k++) { + var otherDeclChild = otherDeclChildren[k]; + if ((otherDeclChild.flags & 1 /* Exported */) && (otherDeclChild.kind & declSearchKind)) { + result.push(otherDeclChild); + } + } + } + + break; + + case 8 /* Class */: + case 16 /* Interface */: + var parameters = decl.getTypeParameters(); + if (parameters && parameters.length) { + this.addFilteredDecls(parameters, declSearchKind, result); + } + + break; + + case 131072 /* FunctionExpression */: + var functionExpressionName = (decl).getFunctionExpressionName(); + if (functionExpressionName) { + result.push(decl); + } + + case 16384 /* Function */: + case 32768 /* ConstructorMethod */: + case 65536 /* Method */: + var parameters = decl.getTypeParameters(); + if (parameters && parameters.length) { + this.addFilteredDecls(parameters, declSearchKind, result); + } + + break; + } + } + + var units = this.semanticInfoChain.units; + for (var i = 0, n = units.length; i < n; i++) { + var unit = units[i]; + if (unit === this.currentUnit && declPath.length != 0) { + continue; + } + var topLevelDecls = unit.getTopLevelDecls(); + if (topLevelDecls.length) { + for (var j = 0, m = topLevelDecls.length; j < m; j++) { + var topLevelDecl = topLevelDecls[j]; + if (topLevelDecl.kind === 1 /* Script */ || topLevelDecl.kind === 0 /* Global */) { + this.addFilteredDecls(topLevelDecl.getChildDecls(), declSearchKind, result); + } + } + } + } + + return result; + }; + + PullTypeResolver.prototype.addFilteredDecls = function (decls, declSearchKind, result) { + if (decls.length) { + for (var i = 0, n = decls.length; i < n; i++) { + var decl = decls[i]; + if (decl.kind & declSearchKind) { + result.push(decl); + } + } + } + }; + + PullTypeResolver.prototype.getVisibleDecls = function (enclosingDecl, context) { + var declPath = enclosingDecl !== null ? TypeScript.getPathToDecl(enclosingDecl) : []; + + if (enclosingDecl && !declPath.length) { + declPath = [enclosingDecl]; + } + + var declSearchKind = TypeScript.PullElementKind.SomeType | TypeScript.PullElementKind.SomeContainer | TypeScript.PullElementKind.SomeValue; + + return this.getVisibleDeclsFromDeclPath(declPath, declSearchKind); + }; + + PullTypeResolver.prototype.getVisibleContextSymbols = function (enclosingDecl, context) { + var contextualTypeSymbol = context.getContextualType(); + if (!contextualTypeSymbol || this.isAnyOrEquivalent(contextualTypeSymbol)) { + return null; + } + + var declSearchKind = TypeScript.PullElementKind.SomeType | TypeScript.PullElementKind.SomeContainer | TypeScript.PullElementKind.SomeValue; + var members = contextualTypeSymbol.getAllMembers(declSearchKind, false); + + for (var i = 0; i < members.length; i++) { + members[i].setUnresolved(); + } + + return members; + }; + + PullTypeResolver.prototype.getVisibleMembersFromExpression = function (expression, enclosingDecl, context) { + var prevCanUseTypeSymbol = context.canUseTypeSymbol; + var prevResolvingNamespaceMemberAccess = context.resolvingNamespaceMemberAccess; + context.canUseTypeSymbol = true; + context.resolvingNamespaceMemberAccess = true; + var lhs = this.resolveAST(expression, false, enclosingDecl, context); + context.canUseTypeSymbol = prevCanUseTypeSymbol; + context.resolvingNamespaceMemberAccess = prevResolvingNamespaceMemberAccess; + + if (context.resolvingTypeReference && (lhs.kind === 8 /* Class */ || lhs.kind === 16 /* Interface */)) { + return null; + } + + var lhsType = lhs.type; + if (!lhsType) { + return null; + } + + if (this.isAnyOrEquivalent(lhsType)) { + return null; + } + + if (!lhsType.isResolved) { + this.resolveDeclaredSymbol(lhsType, enclosingDecl, context); + } + + var includePrivate = false; + var containerSymbol = lhsType; + if (containerSymbol.kind === 33554432 /* ConstructorType */) { + containerSymbol = containerSymbol.getConstructSignatures()[0].returnType; + } + + if (containerSymbol && containerSymbol.isClass()) { + var declPath = TypeScript.getPathToDecl(enclosingDecl); + if (declPath && declPath.length) { + var declarations = containerSymbol.getDeclarations(); + for (var i = 0, n = declarations.length; i < n; i++) { + var declaration = declarations[i]; + if (declPath.indexOf(declaration) >= 0) { + includePrivate = true; + break; + } + } + } + } + + var declSearchKind = TypeScript.PullElementKind.SomeType | TypeScript.PullElementKind.SomeContainer | TypeScript.PullElementKind.SomeValue; + + var members = []; + + if (lhsType.isContainer()) { + var exportedAssignedContainerSymbol = (lhsType).getExportAssignedContainerSymbol(); + if (exportedAssignedContainerSymbol) { + lhsType = exportedAssignedContainerSymbol; + } + } + + if (lhsType.isTypeParameter()) { + var constraint = (lhsType).getConstraint(); + + if (constraint) { + lhsType = constraint; + members = lhsType.getAllMembers(declSearchKind, false); + } + } else { + if (lhs.kind == 67108864 /* EnumMember */) { + lhsType = this.semanticInfoChain.numberTypeSymbol; + } + + if (lhsType === this.semanticInfoChain.numberTypeSymbol && this.cachedNumberInterfaceType()) { + lhsType = this.cachedNumberInterfaceType(); + } else if (lhsType === this.semanticInfoChain.stringTypeSymbol && this.cachedStringInterfaceType()) { + lhsType = this.cachedStringInterfaceType(); + } else if (lhsType === this.semanticInfoChain.booleanTypeSymbol && this.cachedBooleanInterfaceType()) { + lhsType = this.cachedBooleanInterfaceType(); + } + + if (!lhsType.isResolved) { + var potentiallySpecializedType = this.resolveDeclaredSymbol(lhsType, enclosingDecl, context); + + if (potentiallySpecializedType != lhsType) { + if (!lhs.isType()) { + context.setTypeInContext(lhs, potentiallySpecializedType); + } + + lhsType = potentiallySpecializedType; + } + } + + members = lhsType.getAllMembers(declSearchKind, includePrivate); + + if (lhsType.isContainer()) { + if (lhsType.isAlias()) { + lhsType = (lhsType).getExportAssignedTypeSymbol(); + } + var associatedInstance = (lhsType).getInstanceSymbol(); + if (associatedInstance) { + var instanceType = associatedInstance.type; + if (!instanceType.isResolved) { + this.resolveDeclaredSymbol(instanceType, enclosingDecl, context); + } + var instanceMembers = instanceType.getAllMembers(declSearchKind, includePrivate); + members = members.concat(instanceMembers); + } + + var exportedContainer = (lhsType).getExportAssignedContainerSymbol(); + if (exportedContainer) { + var exportedContainerMembers = exportedContainer.getAllMembers(declSearchKind, includePrivate); + members = members.concat(exportedContainerMembers); + } + } else if (lhsType.isConstructor()) { + var prototypeStr = "prototype"; + var prototypeSymbol = new TypeScript.PullSymbol(prototypeStr, 4096 /* Property */); + var parentDecl = lhsType.getDeclarations()[0]; + var prototypeDecl = new TypeScript.PullDecl(prototypeStr, prototypeStr, parentDecl.kind, parentDecl.flags, parentDecl.getSpan(), parentDecl.getScriptName()); + this.currentUnit.addSynthesizedDecl(prototypeDecl); + prototypeDecl.setParentDecl(parentDecl); + prototypeSymbol.addDeclaration(prototypeDecl); + prototypeSymbol.type = lhsType.getAssociatedContainerType(); + prototypeSymbol.isResolved = true; + members.push(prototypeSymbol); + } else { + var associatedContainerSymbol = lhsType.getAssociatedContainerType(); + if (associatedContainerSymbol) { + var containerType = associatedContainerSymbol.type; + if (!containerType.isResolved) { + this.resolveDeclaredSymbol(containerType, enclosingDecl, context); + } + var containerMembers = containerType.getAllMembers(declSearchKind, includePrivate); + members = members.concat(containerMembers); + } + } + } + + if (lhsType.getCallSignatures().length && this.cachedFunctionInterfaceType()) { + members = members.concat(this.cachedFunctionInterfaceType().getAllMembers(declSearchKind, false)); + } + + return members; + }; + + PullTypeResolver.prototype.isAnyOrEquivalent = function (type) { + return (type === this.semanticInfoChain.anyTypeSymbol) || type.isError(); + }; + + PullTypeResolver.prototype.isNumberOrEquivalent = function (type) { + return (type === this.semanticInfoChain.numberTypeSymbol) || (this.cachedNumberInterfaceType() && type === this.cachedNumberInterfaceType()); + }; + + PullTypeResolver.prototype.isTypeArgumentOrWrapper = function (type) { + if (!type) { + return false; + } + + if (!type.isGeneric()) { + return false; + } + + if (type.isTypeParameter()) { + return true; + } + + if (type.isArray()) { + return this.isTypeArgumentOrWrapper(type.getElementType()); + } + + var typeArguments = type.getTypeArguments(); + + if (typeArguments) { + for (var i = 0; i < typeArguments.length; i++) { + if (this.isTypeArgumentOrWrapper(typeArguments[i])) { + return true; + } + } + } else { + return true; + } + + return false; + }; + + PullTypeResolver.prototype.isArrayOrEquivalent = function (type) { + return (type.isArray() && type.getElementType()) || type == this.cachedArrayInterfaceType(); + }; + + PullTypeResolver.prototype.findTypeSymbolForDynamicModule = function (idText, currentFileName, search) { + var originalIdText = idText; + var symbol = null; + + if (!TypeScript.isRelative(originalIdText)) { + idText = originalIdText; + + var strippedIdText = TypeScript.stripQuotes(idText); + + if (this.lastExternalModulePath != "") { + idText = TypeScript.normalizePath(this.lastExternalModulePath + strippedIdText + ".ts"); + symbol = search(idText); + + if (symbol) { + return symbol; + } + + if (symbol === null) { + idText = TypeScript.normalizePath(this.lastExternalModulePath + strippedIdText + ".d.ts"); + symbol = search(idText); + } + + if (symbol) { + return symbol; + } + } + + var path = TypeScript.getRootFilePath(TypeScript.switchToForwardSlashes(currentFileName)); + + while (symbol === null && path != "") { + idText = TypeScript.normalizePath(path + strippedIdText + ".d.ts"); + symbol = search(idText); + + if (symbol === null) { + idText = TypeScript.normalizePath(path + strippedIdText + ".ts"); + symbol = search(idText); + } + + if (symbol === null) { + if (path === '/') { + path = ''; + } else { + path = TypeScript.normalizePath(path + ".."); + path = path && path != '/' ? path + '/' : path; + } + } + + if (symbol) { + this.lastExternalModulePath = path; + } + } + } + + symbol = search(originalIdText); + + if (symbol === null) { + if (!symbol) { + idText = TypeScript.swapQuotes(originalIdText); + symbol = search(idText); + } + + if (!symbol) { + idText = TypeScript.stripQuotes(originalIdText) + ".d.ts"; + symbol = search(idText); + } + + if (!symbol) { + idText = TypeScript.stripQuotes(originalIdText) + ".ts"; + symbol = search(idText); + } + } + + return symbol; + }; + + PullTypeResolver.prototype.resolveDeclaredSymbol = function (symbol, enclosingDecl, context) { + var savedResolvingTypeReference = context.resolvingTypeReference; + context.resolvingTypeReference = false; + + var result = this.resolveDeclaredSymbolWorker(symbol, enclosingDecl, context); + context.resolvingTypeReference = savedResolvingTypeReference; + + return result; + }; + + PullTypeResolver.prototype.resolveDeclaredSymbolWorker = function (symbol, enclosingDecl, context) { + if (!symbol || symbol.isResolved) { + return symbol; + } + + if (symbol.inResolution) { + if (!symbol.currentlyBeingSpecialized()) { + if (!symbol.isType()) { + symbol.type = this.semanticInfoChain.anyTypeSymbol; + } + + return symbol; + } + } + + var thisUnit = this.unitPath; + + var decls = symbol.getDeclarations(); + + var ast = null; + + for (var i = 0; i < decls.length; i++) { + var decl = decls[i]; + + ast = this.semanticInfoChain.getASTForDecl(decl); + + if (!ast || ast.nodeType() === 81 /* Member */) { + this.setUnitPath(thisUnit); + return symbol; + } + + this.setUnitPath(decl.getScriptName()); + var resolvedSymbol = this.resolveAST(ast, false, enclosingDecl, context); + + if (decl.kind == 2048 /* Parameter */ && !symbol.isResolved && !symbol.type && resolvedSymbol && symbol.hasFlag(8388608 /* PropertyParameter */)) { + symbol.type = resolvedSymbol.type; + symbol.setResolved(); + } + } + + var typeArgs = symbol.isType() ? (symbol).getTypeArguments() : null; + + if (typeArgs && typeArgs.length) { + var typeParameters = (symbol).getTypeParameters(); + var typeCache = {}; + + for (var i = 0; i < typeParameters.length; i++) { + typeCache[typeParameters[i].pullSymbolIDString] = typeArgs[i]; + } + + context.pushTypeSpecializationCache(typeCache); + var rootType = TypeScript.getRootType(symbol.type); + + var specializedSymbol = TypeScript.specializeType(rootType, typeArgs, this, enclosingDecl, context, ast); + + context.popTypeSpecializationCache(); + + symbol = specializedSymbol; + } + + this.setUnitPath(thisUnit); + + return symbol; + }; + + PullTypeResolver.prototype.resolveModuleDeclaration = function (ast, context) { + var containerDecl = this.getDeclForAST(ast); + var containerSymbol = containerDecl.getSymbol(); + + if (containerSymbol.isResolved || containerSymbol.inResolution) { + return containerSymbol; + } + + containerSymbol.inResolution = true; + + var containerDecls = containerSymbol.getDeclarations(); + + for (var i = 0; i < containerDecls.length; i++) { + var childDecls = containerDecls[i].getChildDecls(); + + for (var j = 0; j < childDecls.length; j++) { + childDecls[j].ensureSymbolIsBound(); + } + } + + var members = ast.members.members; + + if (containerDecl.kind != 64 /* Enum */) { + var instanceSymbol = containerSymbol.getInstanceSymbol(); + + if (instanceSymbol) { + this.resolveDeclaredSymbol(instanceSymbol, containerDecl.getParentDecl(), context); + } + + for (var i = 0; i < members.length; i++) { + if (members[i].nodeType() == 88 /* ExportAssignment */) { + this.resolveExportAssignmentStatement(members[i], containerDecl, context); + break; + } + } + } + + if (context.typeCheck()) { + var subModuleAST = null; + var currentPath = this.unitPath; + for (var i = 0; i < containerDecls.length; i++) { + subModuleAST = this.getASTForDecl(containerDecls[i]); + + if (subModuleAST) { + this.setUnitPath(containerDecls[i].getScriptName()); + this.resolveAST(subModuleAST.members, false, containerDecls[i], context); + } + } + + this.setUnitPath(currentPath); + + this.validateVariableDeclarationGroups(containerDecl, context); + } + + if (!context.isInBaseTypeResolution()) { + containerSymbol.setResolved(); + } else { + containerSymbol.inResolution = false; + } + + return containerSymbol; + }; + + PullTypeResolver.prototype.isTypeRefWithoutTypeArgs = function (typeRef) { + if (typeRef.nodeType() != 11 /* TypeRef */) { + return false; + } + + if (typeRef.term.nodeType() == 21 /* Name */) { + return true; + } else if (typeRef.term.nodeType() == 33 /* MemberAccessExpression */) { + var binex = typeRef.term; + + if (binex.operand2.nodeType() == 21 /* Name */) { + return true; + } + } + + return false; + }; + + PullTypeResolver.prototype.resolveReferenceTypeDeclaration = function (typeDeclAST, context) { + var typeDecl = this.getDeclForAST(typeDeclAST); + var enclosingDecl = this.getEnclosingDecl(typeDecl); + var typeDeclSymbol = typeDecl.getSymbol(); + var typeDeclIsClass = typeDeclAST.nodeType() === 14 /* ClassDeclaration */; + var hasVisited = this.getSymbolForAST(typeDeclAST) != null; + var extendedTypes = []; + var implementedTypes = []; + + if ((typeDeclSymbol.isResolved && hasVisited) || (typeDeclSymbol.inResolution && !context.isInBaseTypeResolution())) { + return typeDeclSymbol; + } + + var wasResolving = typeDeclSymbol.inResolution; + typeDeclSymbol.startResolving(); + + if (!typeDeclSymbol.isResolved) { + var typeDeclTypeParameters = typeDeclSymbol.getTypeParameters(); + for (var i = 0; i < typeDeclTypeParameters.length; i++) { + this.resolveDeclaredSymbol(typeDeclTypeParameters[i], typeDecl, context); + } + } + + var typeRefDecls = typeDeclSymbol.getDeclarations(); + + for (var i = 0; i < typeRefDecls.length; i++) { + var childDecls = typeRefDecls[i].getChildDecls(); + + for (var j = 0; j < childDecls.length; j++) { + childDecls[j].ensureSymbolIsBound(); + } + } + + var wasInBaseTypeResolution = context.startBaseTypeResolution(); + + if (!typeDeclIsClass && !hasVisited) { + typeDeclSymbol.resetKnownBaseTypeCount(); + } + + if (typeDeclAST.extendsList) { + var savedIsResolvingClassExtendedType = context.isResolvingClassExtendedType; + if (typeDeclIsClass) { + context.isResolvingClassExtendedType = true; + } + + for (var i = typeDeclSymbol.getKnownBaseTypeCount(); i < typeDeclAST.extendsList.members.length; i = typeDeclSymbol.getKnownBaseTypeCount()) { + typeDeclSymbol.incrementKnownBaseCount(); + var parentType = this.resolveTypeReference(new TypeScript.TypeReference(typeDeclAST.extendsList.members[i], 0), typeDecl, context); + + if (typeDeclSymbol.isValidBaseKind(parentType, true)) { + var resolvedParentType = parentType; + extendedTypes[extendedTypes.length] = parentType; + if (parentType.isGeneric() && parentType.isResolved && !parentType.getIsSpecialized()) { + parentType = this.specializeTypeToAny(parentType, enclosingDecl, context); + typeDecl.addDiagnostic(new TypeScript.Diagnostic(typeDecl.getScriptName(), typeDeclAST.minChar, typeDeclAST.getLength(), TypeScript.DiagnosticCode.Generic_type_references_must_include_all_type_arguments)); + } + if (!typeDeclSymbol.hasBase(parentType)) { + this.setSymbolForAST(typeDeclAST.extendsList.members[i], resolvedParentType, context); + typeDeclSymbol.addExtendedType(parentType); + + var specializations = typeDeclSymbol.getKnownSpecializations(); + + for (var j = 0; j < specializations.length; j++) { + specializations[j].addExtendedType(parentType); + } + } + } + } + + context.isResolvingClassExtendedType = savedIsResolvingClassExtendedType; + } + + if (typeDeclAST.implementsList && typeDeclIsClass) { + var extendsCount = typeDeclAST.extendsList ? typeDeclAST.extendsList.members.length : 0; + for (var i = typeDeclSymbol.getKnownBaseTypeCount(); ((i - extendsCount) >= 0) && ((i - extendsCount) < typeDeclAST.implementsList.members.length); i = typeDeclSymbol.getKnownBaseTypeCount()) { + typeDeclSymbol.incrementKnownBaseCount(); + var implementedType = this.resolveTypeReference(new TypeScript.TypeReference(typeDeclAST.implementsList.members[i - extendsCount], 0), typeDecl, context); + + if (typeDeclSymbol.isValidBaseKind(implementedType, false)) { + var resolvedImplementedType = implementedType; + implementedTypes[implementedTypes.length] = implementedType; + if (implementedType.isGeneric() && implementedType.isResolved && !implementedType.getIsSpecialized()) { + implementedType = this.specializeTypeToAny(implementedType, enclosingDecl, context); + typeDecl.addDiagnostic(new TypeScript.Diagnostic(typeDecl.getScriptName(), typeDeclAST.minChar, typeDeclAST.getLength(), TypeScript.DiagnosticCode.Generic_type_references_must_include_all_type_arguments)); + this.setSymbolForAST(typeDeclAST.implementsList.members[i - extendsCount], implementedType, context); + typeDeclSymbol.addImplementedType(implementedType); + } else if (!typeDeclSymbol.hasBase(implementedType)) { + this.setSymbolForAST(typeDeclAST.implementsList.members[i - extendsCount], resolvedImplementedType, context); + typeDeclSymbol.addImplementedType(implementedType); + } + } + } + } + + context.doneBaseTypeResolution(wasInBaseTypeResolution); + + if (wasInBaseTypeResolution) { + typeDeclSymbol.inResolution = false; + return typeDeclSymbol; + } + + if (!typeDeclSymbol.isResolved) { + var typeDeclMembers = typeDeclSymbol.getMembers(); + + if (TypeScript.globalBinder) { + TypeScript.globalBinder.resetTypeParameterCache(); + } + + if (context.typeCheck()) { + for (var i = 0; i < typeDeclMembers.length; i++) { + this.resolveDeclaredSymbol(typeDeclMembers[i], typeDecl, context); + } + } + + if (!typeDeclIsClass) { + var callSignatures = typeDeclSymbol.getCallSignatures(); + for (var i = 0; i < callSignatures.length; i++) { + this.resolveDeclaredSymbol(callSignatures[i], typeDecl, context); + } + + var constructSignatures = typeDeclSymbol.getConstructSignatures(); + for (var i = 0; i < constructSignatures.length; i++) { + this.resolveDeclaredSymbol(constructSignatures[i], typeDecl, context); + } + + var indexSignatures = typeDeclSymbol.getIndexSignatures(); + for (var i = 0; i < indexSignatures.length; i++) { + this.resolveDeclaredSymbol(indexSignatures[i], typeDecl, context); + } + + if (context.typeCheck()) { + this.typeCheckBases(typeDeclAST, typeDeclSymbol, enclosingDecl, context); + } + } + } + + this.setSymbolForAST(typeDeclAST.name, typeDeclSymbol, context); + this.setSymbolForAST(typeDeclAST, typeDeclSymbol, context); + + typeDeclSymbol.setResolved(); + + return typeDeclSymbol; + }; + + PullTypeResolver.prototype.resolveClassDeclaration = function (classDeclAST, context) { + var classDecl = this.getDeclForAST(classDeclAST); + var classDeclSymbol = classDecl.getSymbol(); + if (classDeclSymbol.isResolved) { + return classDeclSymbol; + } + + this.resolveReferenceTypeDeclaration(classDeclAST, context); + + var constructorMethod = classDeclSymbol.getConstructorMethod(); + var extendedTypes = classDeclSymbol.getExtendedTypes(); + var parentType = extendedTypes.length ? extendedTypes[0] : null; + + if (constructorMethod) { + var constructorTypeSymbol = constructorMethod.type; + + var constructSignatures = constructorTypeSymbol.getConstructSignatures(); + + if (!constructSignatures.length) { + var constructorSignature; + + if (parentType) { + var parentClass = parentType; + var parentConstructor = parentClass.getConstructorMethod(); + var parentConstructorType = parentConstructor.type; + var parentConstructSignatures = parentConstructorType.getConstructSignatures(); + + var parentConstructSignature; + var parentParameters; + for (var i = 0; i < parentConstructSignatures.length; i++) { + parentConstructSignature = parentConstructSignatures[i]; + parentParameters = parentConstructSignature.parameters; + + constructorSignature = parentConstructSignature.isDefinition() ? new TypeScript.PullDefinitionSignatureSymbol(2097152 /* ConstructSignature */) : new TypeScript.PullSignatureSymbol(2097152 /* ConstructSignature */); + constructorSignature.returnType = classDeclSymbol; + + for (var j = 0; j < parentParameters.length; j++) { + constructorSignature.addParameter(parentParameters[j], parentParameters[j].isOptional); + } + + var typeParameters = constructorTypeSymbol.getTypeParameters(); + + for (var j = 0; j < typeParameters.length; j++) { + constructorSignature.addTypeParameter(typeParameters[j]); + } + + constructorTypeSymbol.addConstructSignature(constructorSignature); + constructorSignature.addDeclaration(classDecl); + } + } else { + constructorSignature = new TypeScript.PullSignatureSymbol(2097152 /* ConstructSignature */); + constructorSignature.returnType = classDeclSymbol; + constructorTypeSymbol.addConstructSignature(constructorSignature); + constructorSignature.addDeclaration(classDecl); + + var typeParameters = constructorTypeSymbol.getTypeParameters(); + + for (var i = 0; i < typeParameters.length; i++) { + constructorSignature.addTypeParameter(typeParameters[i]); + } + } + } + + if (!classDeclSymbol.isResolved) { + return classDeclSymbol; + } + + if (context.typeCheck()) { + var constructorMembers = constructorTypeSymbol.getMembers(); + + this.resolveDeclaredSymbol(constructorMethod, classDecl, context); + + for (var i = 0; i < constructorMembers.length; i++) { + this.resolveDeclaredSymbol(constructorMembers[i], classDecl, context); + } + } + } + + if (parentType) { + var parentConstructorSymbol = parentType.getConstructorMethod(); + var parentConstructorTypeSymbol = parentConstructorSymbol.type; + + if (!constructorTypeSymbol.hasBase(parentConstructorTypeSymbol)) { + constructorTypeSymbol.addExtendedType(parentConstructorTypeSymbol); + } + } + + if (context.typeCheck()) { + this.typeCheckBases(classDeclAST, classDeclSymbol, this.getEnclosingDecl(classDecl), context); + if (classDeclSymbol.isResolved && !classDeclSymbol.hasBaseTypeConflict()) { + this.typeCheckMembersAgainstIndexer(classDeclSymbol, classDecl, context); + } + } + + return classDeclSymbol; + }; + + PullTypeResolver.prototype.resolveInterfaceDeclaration = function (interfaceDeclAST, context) { + var interfaceDecl = this.getDeclForAST(interfaceDeclAST); + var interfaceDeclSymbol = interfaceDecl.getSymbol(); + + this.resolveReferenceTypeDeclaration(interfaceDeclAST, context); + + if (context.typeCheck()) { + if (!interfaceDeclSymbol.hasBaseTypeConflict()) { + this.typeCheckMembersAgainstIndexer(interfaceDeclSymbol, interfaceDecl, context); + } + } + + return interfaceDeclSymbol; + }; + + PullTypeResolver.prototype.filterSymbol = function (symbol, kind) { + if (symbol) { + if (symbol.kind & kind) { + return symbol; + } + + if (symbol.isAlias()) { + var alias = symbol; + if (kind & TypeScript.PullElementKind.SomeContainer) { + return alias.getExportAssignedContainerSymbol(); + } else if (kind & TypeScript.PullElementKind.SomeType) { + return alias.getExportAssignedTypeSymbol(); + } else if (kind & TypeScript.PullElementKind.SomeValue) { + return alias.getExportAssignedValueSymbol(); + } + } + } + return null; + }; + + PullTypeResolver.prototype.getMemberSymbolOfKind = function (symbolName, kind, pullTypeSymbol) { + var symbol = this.getMemberSymbol(symbolName, kind, pullTypeSymbol); + + return this.filterSymbol(symbol, kind); + }; + + PullTypeResolver.prototype.resolveIdentifierOfInternalModuleReference = function (importDecl, identifier, moduleSymbol, enclosingDecl, context) { + if (identifier.isMissing()) { + return null; + } + + var moduleTypeSymbol = moduleSymbol.type; + var rhsName = identifier.text(); + var containerSymbol = this.getMemberSymbolOfKind(rhsName, TypeScript.PullElementKind.SomeContainer, moduleTypeSymbol); + var valueSymbol = null; + var typeSymbol = null; + + var acceptableAlias = true; + + if (containerSymbol) { + acceptableAlias = (containerSymbol.kind & TypeScript.PullElementKind.AcceptableAlias) != 0; + } + + if (!acceptableAlias && containerSymbol && containerSymbol.kind == 256 /* TypeAlias */) { + if (!containerSymbol.isResolved) { + this.resolveDeclaredSymbol(containerSymbol, enclosingDecl, context); + } + var aliasedAssignedValue = (containerSymbol).getExportAssignedValueSymbol(); + var aliasedAssignedType = (containerSymbol).getExportAssignedTypeSymbol(); + var aliasedAssignedContainer = (containerSymbol).getExportAssignedContainerSymbol(); + + if (aliasedAssignedValue || aliasedAssignedType || aliasedAssignedContainer) { + valueSymbol = aliasedAssignedValue; + typeSymbol = aliasedAssignedType; + containerSymbol = aliasedAssignedContainer; + acceptableAlias = true; + } + } + + if (!acceptableAlias) { + importDecl.addDiagnostic(new TypeScript.Diagnostic(importDecl.getScriptName(), identifier.minChar, identifier.getLength(), TypeScript.DiagnosticCode.Import_declaration_referencing_identifier_from_internal_module_can_only_be_made_with_variables_functions_classes_interfaces_enums_and_internal_modules)); + return null; + } + + if (!valueSymbol) { + if (moduleTypeSymbol.getInstanceSymbol()) { + valueSymbol = this.getMemberSymbolOfKind(rhsName, TypeScript.PullElementKind.SomeValue, moduleTypeSymbol.getInstanceSymbol().type); + } + } + if (!typeSymbol) { + typeSymbol = this.getMemberSymbolOfKind(rhsName, TypeScript.PullElementKind.SomeType, moduleTypeSymbol); + } + + if (!valueSymbol && !typeSymbol && !containerSymbol) { + importDecl.addDiagnostic(new TypeScript.Diagnostic(importDecl.getScriptName(), identifier.minChar, identifier.getLength(), TypeScript.DiagnosticCode.Could_not_find_symbol_0_in_module_1, [rhsName, moduleSymbol.toString()])); + return null; + } + + if (valueSymbol) { + if (!valueSymbol.isResolved) { + this.resolveDeclaredSymbol(valueSymbol, enclosingDecl, context); + } + } + if (typeSymbol) { + if (!typeSymbol.isResolved) { + this.resolveDeclaredSymbol(typeSymbol, enclosingDecl, context); + } + } + if (containerSymbol) { + if (!containerSymbol.isResolved) { + this.resolveDeclaredSymbol(containerSymbol, enclosingDecl, context); + } + } + + if (!typeSymbol && containerSymbol) { + typeSymbol = containerSymbol; + } + + return { + valueSymbol: valueSymbol, + typeSymbol: typeSymbol, + containerSymbol: containerSymbol + }; + }; + + PullTypeResolver.prototype.resolveModuleReference = function (importDecl, moduleNameExpr, context, declPath) { + TypeScript.CompilerDiagnostics.assert(moduleNameExpr.nodeType() == 33 /* MemberAccessExpression */ || moduleNameExpr.nodeType() == 21 /* Name */, "resolving module reference should always be either name or member reference"); + + var moduleSymbol = null; + var moduleName; + + if (moduleNameExpr.nodeType() == 33 /* MemberAccessExpression */) { + var dottedNameAST = moduleNameExpr; + var moduleContainer = this.resolveModuleReference(importDecl, dottedNameAST.operand1, context, declPath); + if (moduleContainer) { + moduleName = (dottedNameAST.operand2).text(); + moduleSymbol = this.getMemberSymbolOfKind(moduleName, 4 /* Container */, moduleContainer.type); + if (!moduleSymbol) { + importDecl.addDiagnostic(new TypeScript.Diagnostic(importDecl.getScriptName(), dottedNameAST.operand2.minChar, dottedNameAST.operand2.getLength(), TypeScript.DiagnosticCode.Could_not_find_module_0_in_module_1, [moduleName, moduleContainer.toString()])); + } + } + } else if (!(moduleNameExpr).isMissing()) { + moduleName = (moduleNameExpr).text(); + moduleSymbol = this.filterSymbol(this.getSymbolFromDeclPath(moduleName, declPath, 4 /* Container */), 4 /* Container */); + if (!moduleSymbol) { + importDecl.addDiagnostic(new TypeScript.Diagnostic(importDecl.getScriptName(), moduleNameExpr.minChar, moduleNameExpr.getLength(), TypeScript.DiagnosticCode.Unable_to_resolve_module_reference_0, [moduleName])); + } + } + + return moduleSymbol; + }; + + PullTypeResolver.prototype.resolveInternalModuleReference = function (importStatementAST, context) { + var importDecl = this.getDeclForAST(importStatementAST); + var enclosingDecl = this.getEnclosingDecl(importDecl); + + var aliasExpr = importStatementAST.alias.nodeType() == 11 /* TypeRef */ ? (importStatementAST.alias).term : importStatementAST.alias; + var declPath = enclosingDecl !== null ? TypeScript.getPathToDecl(enclosingDecl) : []; + var aliasedType = null; + + if (aliasExpr.nodeType() == 21 /* Name */) { + var moduleSymbol = this.resolveModuleReference(importDecl, aliasExpr, context, declPath); + if (moduleSymbol) { + aliasedType = moduleSymbol.type; + if (context.typeCheck() && aliasedType.hasFlag(32768 /* InitializedModule */)) { + var moduleName = (aliasExpr).text(); + var valueSymbol = this.getSymbolFromDeclPath(moduleName, declPath, TypeScript.PullElementKind.SomeValue); + var instanceSymbol = (aliasedType).getInstanceSymbol(); + if (valueSymbol && (instanceSymbol != valueSymbol || valueSymbol.type == aliasedType)) { + context.postError(this.unitPath, aliasExpr.minChar, aliasExpr.getLength(), TypeScript.DiagnosticCode.Internal_module_reference_0_in_import_declaration_doesn_t_reference_module_instance_for_1, [(aliasExpr).actualText, moduleSymbol.type.toString(enclosingDecl ? enclosingDecl.getSymbol() : null)], enclosingDecl); + } + } + } else { + aliasedType = this.semanticInfoChain.anyTypeSymbol; + } + } else if (aliasExpr.nodeType() == 33 /* MemberAccessExpression */) { + var importDeclSymbol = importDecl.getSymbol(); + var dottedNameAST = aliasExpr; + var moduleSymbol = this.resolveModuleReference(importDecl, dottedNameAST.operand1, context, declPath); + if (moduleSymbol) { + var identifierResolution = this.resolveIdentifierOfInternalModuleReference(importDecl, dottedNameAST.operand2, moduleSymbol, enclosingDecl, context); + if (identifierResolution) { + importDeclSymbol.setAssignedValueSymbol(identifierResolution.valueSymbol); + importDeclSymbol.setAssignedTypeSymbol(identifierResolution.typeSymbol); + importDeclSymbol.setAssignedContainerSymbol(identifierResolution.containerSymbol); + if (identifierResolution.valueSymbol) { + importDeclSymbol.isUsedAsValue = true; + } + this.semanticInfoChain.setSymbolForAST(importStatementAST.alias, importDeclSymbol, this.unitPath); + return null; + } + } + + importDeclSymbol.setAssignedTypeSymbol(this.semanticInfoChain.anyTypeSymbol); + } + + return aliasedType; + }; + + PullTypeResolver.prototype.resolveImportDeclaration = function (importStatementAST, context) { + var _this = this; + var importDecl = this.getDeclForAST(importStatementAST); + var enclosingDecl = this.getEnclosingDecl(importDecl); + var importDeclSymbol = importDecl.getSymbol(); + + var aliasedType = null; + + if (importDeclSymbol.isResolved) { + return importDeclSymbol; + } + + importDeclSymbol.startResolving(); + + var isExternalImportDeclaration = importStatementAST.isExternalImportDeclaration(); + + if (isExternalImportDeclaration) { + var modPath = (importStatementAST.alias).actualText; + var declPath = TypeScript.getPathToDecl(enclosingDecl); + + aliasedType = this.findTypeSymbolForDynamicModule(modPath, importDecl.getScriptName(), function (s) { + return _this.semanticInfoChain.findSymbol([s], 32 /* DynamicModule */); + }); + + if (!aliasedType) { + aliasedType = this.findTypeSymbolForDynamicModule(modPath, importDecl.getScriptName(), function (s) { + return _this.getSymbolFromDeclPath(s, declPath, 32 /* DynamicModule */); + }); + } + if (!aliasedType) { + importDecl.addDiagnostic(new TypeScript.Diagnostic(this.currentUnit.getPath(), importStatementAST.minChar, importStatementAST.getLength(), TypeScript.DiagnosticCode.Unable_to_resolve_external_module_0, [modPath])); + aliasedType = this.semanticInfoChain.anyTypeSymbol; + } + } else { + aliasedType = this.resolveInternalModuleReference(importStatementAST, context); + } + + if (aliasedType) { + if (!aliasedType.isContainer()) { + importDecl.addDiagnostic(new TypeScript.Diagnostic(this.currentUnit.getPath(), importStatementAST.minChar, importStatementAST.getLength(), TypeScript.DiagnosticCode.Module_cannot_be_aliased_to_a_non_module_type)); + aliasedType = this.semanticInfoChain.anyTypeSymbol; + } else if ((aliasedType).getExportAssignedValueSymbol()) { + importDeclSymbol.isUsedAsValue = true; + } + + if (aliasedType.isContainer()) { + importDeclSymbol.setAssignedContainerSymbol(aliasedType); + } + importDeclSymbol.setAssignedTypeSymbol(aliasedType); + + this.semanticInfoChain.setSymbolForAST(importStatementAST.alias, aliasedType, this.unitPath); + } + + importDeclSymbol.setResolved(); + + if (context.typeCheck()) { + var checkPrivacy; + if (isExternalImportDeclaration) { + var containerSymbol = importDeclSymbol.getExportAssignedContainerSymbol(); + var container = containerSymbol ? containerSymbol.getContainer() : null; + if (container && container.kind == 32 /* DynamicModule */) { + checkPrivacy = true; + } + } else { + checkPrivacy = true; + } + + if (checkPrivacy) { + var typeSymbol = importDeclSymbol.getExportAssignedTypeSymbol(); + var containerSymbol = importDeclSymbol.getExportAssignedContainerSymbol(); + var valueSymbol = importDeclSymbol.getExportAssignedValueSymbol(); + + this.checkSymbolPrivacy(importDeclSymbol, containerSymbol, context, function (symbol) { + var messageCode = TypeScript.DiagnosticCode.Exported_import_declaration_0_is_assigned_container_that_is_or_is_using_inaccessible_module_1; + var messageArguments = [importDeclSymbol.getScopedName(enclosingDecl ? enclosingDecl.getSymbol() : null), symbol.getScopedName(enclosingDecl ? enclosingDecl.getSymbol() : null)]; + context.postError(_this.unitPath, importStatementAST.minChar, importStatementAST.getLength(), messageCode, messageArguments, enclosingDecl); + }); + + if (typeSymbol != containerSymbol) { + this.checkSymbolPrivacy(importDeclSymbol, typeSymbol, context, function (symbol) { + var messageCode = symbol.isContainer() && !(symbol).isEnum() ? TypeScript.DiagnosticCode.Exported_import_declaration_0_is_assigned_type_that_is_using_inaccessible_module_1 : TypeScript.DiagnosticCode.Exported_import_declaration_0_is_assigned_type_that_has_or_is_using_private_type_1; + + var messageArguments = [importDeclSymbol.getScopedName(enclosingDecl ? enclosingDecl.getSymbol() : null), symbol.getScopedName(enclosingDecl ? enclosingDecl.getSymbol() : null)]; + context.postError(_this.unitPath, importStatementAST.minChar, importStatementAST.getLength(), messageCode, messageArguments, enclosingDecl); + }); + } + + if (valueSymbol) { + this.checkSymbolPrivacy(importDeclSymbol, valueSymbol.type, context, function (symbol) { + var messageCode = symbol.isContainer() && !(symbol).isEnum() ? TypeScript.DiagnosticCode.Exported_import_declaration_0_is_assigned_value_with_type_that_is_using_inaccessible_module_1 : TypeScript.DiagnosticCode.Exported_import_declaration_0_is_assigned_value_with_type_that_has_or_is_using_private_type_1; + var messageArguments = [importDeclSymbol.getScopedName(enclosingDecl ? enclosingDecl.getSymbol() : null), symbol.getScopedName(enclosingDecl ? enclosingDecl.getSymbol() : null)]; + context.postError(_this.unitPath, importStatementAST.minChar, importStatementAST.getLength(), messageCode, messageArguments, enclosingDecl); + }); + } + } + } + + return importDeclSymbol; + }; + + PullTypeResolver.prototype.resolveExportAssignmentStatement = function (exportAssignmentAST, enclosingDecl, context) { + var id = exportAssignmentAST.id.text(); + var valueSymbol = null; + var typeSymbol = null; + var containerSymbol = null; + + var parentSymbol = enclosingDecl.getSymbol(); + + if (!parentSymbol.isType() && (parentSymbol).isContainer()) { + enclosingDecl.addDiagnostic(new TypeScript.Diagnostic(enclosingDecl.getScriptName(), exportAssignmentAST.minChar, exportAssignmentAST.getLength(), TypeScript.DiagnosticCode.Export_assignments_may_only_be_used_at_the_top_level_of_external_modules)); + return this.semanticInfoChain.anyTypeSymbol; + } + + var declPath = enclosingDecl !== null ? [enclosingDecl] : []; + + containerSymbol = this.getSymbolFromDeclPath(id, declPath, TypeScript.PullElementKind.SomeContainer); + + var acceptableAlias = true; + + if (containerSymbol) { + acceptableAlias = (containerSymbol.kind & TypeScript.PullElementKind.AcceptableAlias) != 0; + } + + if (!acceptableAlias && containerSymbol && containerSymbol.kind == 256 /* TypeAlias */) { + if (!containerSymbol.isResolved) { + this.resolveDeclaredSymbol(containerSymbol, enclosingDecl, context); + } + + var aliasedAssignedValue = (containerSymbol).getExportAssignedValueSymbol(); + var aliasedAssignedType = (containerSymbol).getExportAssignedTypeSymbol(); + var aliasedAssignedContainer = (containerSymbol).getExportAssignedContainerSymbol(); + + if (aliasedAssignedValue || aliasedAssignedType || aliasedAssignedContainer) { + valueSymbol = aliasedAssignedValue; + typeSymbol = aliasedAssignedType; + containerSymbol = aliasedAssignedContainer; + acceptableAlias = true; + } + } + + if (!acceptableAlias) { + enclosingDecl.addDiagnostic(new TypeScript.Diagnostic(enclosingDecl.getScriptName(), exportAssignmentAST.minChar, exportAssignmentAST.getLength(), TypeScript.DiagnosticCode.Export_assignments_may_only_be_made_with_variables_functions_classes_interfaces_enums_and_internal_modules)); + return this.semanticInfoChain.voidTypeSymbol; + } + + if (!valueSymbol) { + valueSymbol = this.getSymbolFromDeclPath(id, declPath, TypeScript.PullElementKind.SomeValue); + } + if (!typeSymbol) { + typeSymbol = this.getSymbolFromDeclPath(id, declPath, TypeScript.PullElementKind.SomeType); + } + + if (!valueSymbol && !typeSymbol && !containerSymbol) { + context.postError(enclosingDecl.getScriptName(), exportAssignmentAST.minChar, exportAssignmentAST.getLength(), TypeScript.DiagnosticCode.Could_not_find_symbol_0, [id], enclosingDecl); + return this.semanticInfoChain.voidTypeSymbol; + } + + if (valueSymbol) { + (parentSymbol).setExportAssignedValueSymbol(valueSymbol); + } + if (typeSymbol) { + (parentSymbol).setExportAssignedTypeSymbol(typeSymbol); + } + if (containerSymbol) { + (parentSymbol).setExportAssignedContainerSymbol(containerSymbol); + } + + if (valueSymbol && !valueSymbol.isResolved) { + this.resolveDeclaredSymbol(valueSymbol, enclosingDecl, context); + } + if (typeSymbol && !typeSymbol.isResolved) { + this.resolveDeclaredSymbol(typeSymbol, enclosingDecl, context); + } + if (containerSymbol && !containerSymbol.isResolved) { + this.resolveDeclaredSymbol(containerSymbol, enclosingDecl, context); + } + + return this.semanticInfoChain.voidTypeSymbol; + }; + + PullTypeResolver.prototype.resolveFunctionTypeSignature = function (funcDeclAST, enclosingDecl, context) { + var funcDeclSymbol = null; + + var functionDecl = this.getDeclForAST(funcDeclAST); + + if (!functionDecl) { + var semanticInfo = this.semanticInfoChain.getUnit(this.unitPath); + var declCollectionContext = new TypeScript.DeclCollectionContext(semanticInfo, this.unitPath); + + if (enclosingDecl) { + declCollectionContext.pushParent(enclosingDecl); + } + + TypeScript.getAstWalkerFactory().walk(funcDeclAST, TypeScript.preCollectDecls, TypeScript.postCollectDecls, null, declCollectionContext); + + functionDecl = this.getDeclForAST(funcDeclAST); + this.currentUnit.addSynthesizedDecl(functionDecl); + } + + if (!functionDecl.hasSymbol()) { + var binder = new TypeScript.PullSymbolBinder(this.semanticInfoChain); + binder.setUnit(this.unitPath); + if (functionDecl.kind === 33554432 /* ConstructorType */) { + binder.bindConstructorTypeDeclarationToPullSymbol(functionDecl); + } else { + binder.bindFunctionTypeDeclarationToPullSymbol(functionDecl); + } + } + + funcDeclSymbol = functionDecl.getSymbol(); + + var signature = funcDeclSymbol.kind === 33554432 /* ConstructorType */ ? funcDeclSymbol.getConstructSignatures()[0] : funcDeclSymbol.getCallSignatures()[0]; + + if (funcDeclAST.returnTypeAnnotation) { + var returnTypeSymbol = this.resolveTypeReference(funcDeclAST.returnTypeAnnotation, functionDecl, context); + + signature.returnType = returnTypeSymbol; + + if (this.isTypeArgumentOrWrapper(returnTypeSymbol)) { + signature.hasAGenericParameter = true; + + if (funcDeclSymbol) { + funcDeclSymbol.type.setHasGenericSignature(); + } + } + } + + if (funcDeclAST.arguments) { + for (var i = 0; i < funcDeclAST.arguments.members.length; i++) { + this.resolveFunctionTypeSignatureParameter(funcDeclAST.arguments.members[i], signature, functionDecl, context); + } + } + + if (funcDeclSymbol && signature.hasAGenericParameter) { + funcDeclSymbol.type.setHasGenericSignature(); + } + + if (signature.hasAGenericParameter) { + if (funcDeclSymbol) { + funcDeclSymbol.type.setHasGenericSignature(); + } + } + + funcDeclSymbol.setResolved(); + + if (context.typeCheck()) { + this.typeCheckFunctionOverloads(funcDeclAST, context); + } + + return funcDeclSymbol; + }; + + PullTypeResolver.prototype.resolveFunctionTypeSignatureParameter = function (argDeclAST, signature, enclosingDecl, context) { + var paramDecl = this.getDeclForAST(argDeclAST); + var paramSymbol = paramDecl.getSymbol(); + + if (argDeclAST.typeExpr) { + var typeRef = this.resolveTypeReference(argDeclAST.typeExpr, enclosingDecl, context); + + if (paramSymbol.isVarArg && !(typeRef.isArray() || typeRef == this.cachedArrayInterfaceType())) { + var diagnostic = context.postError(this.unitPath, argDeclAST.minChar, argDeclAST.getLength(), TypeScript.DiagnosticCode.Rest_parameters_must_be_array_types, null, enclosingDecl); + typeRef = this.getNewErrorTypeSymbol(diagnostic); + } + + context.setTypeInContext(paramSymbol, typeRef); + + if (this.isTypeArgumentOrWrapper(typeRef)) { + signature.hasAGenericParameter = true; + } + } else { + if (paramSymbol.isVarArg && paramSymbol.type) { + if (this.cachedArrayInterfaceType()) { + context.setTypeInContext(paramSymbol, TypeScript.specializeType(this.cachedArrayInterfaceType(), [paramSymbol.type], this, this.cachedArrayInterfaceType().getDeclarations()[0], context)); + } else { + context.setTypeInContext(paramSymbol, paramSymbol.type); + } + } else { + context.setTypeInContext(paramSymbol, this.semanticInfoChain.anyTypeSymbol); + + if (this.compilationSettings.noImplicitAny && !context.isInInvocationExpression) { + context.postError(this.unitPath, argDeclAST.minChar, argDeclAST.getLength(), TypeScript.DiagnosticCode.Parameter_0_of_function_type_implicitly_has_an_any_type, [argDeclAST.id.actualText], enclosingDecl); + } + } + } + + paramSymbol.setResolved(); + }; + + PullTypeResolver.prototype.resolveFunctionExpressionParameter = function (argDeclAST, contextParam, enclosingDecl, context) { + var paramDecl = this.getDeclForAST(argDeclAST); + var paramSymbol = paramDecl.getSymbol(); + + if (argDeclAST.typeExpr) { + var typeRef = this.resolveTypeReference(argDeclAST.typeExpr, enclosingDecl, context); + + if (paramSymbol.isVarArg && !(typeRef.isArray() || typeRef == this.cachedArrayInterfaceType())) { + var diagnostic = context.postError(this.unitPath, argDeclAST.minChar, argDeclAST.getLength(), TypeScript.DiagnosticCode.Rest_parameters_must_be_array_types, null, enclosingDecl); + typeRef = this.getNewErrorTypeSymbol(diagnostic); + } + + context.setTypeInContext(paramSymbol, typeRef); + } else { + if (contextParam) { + context.setTypeInContext(paramSymbol, contextParam.type); + } else { + if (paramSymbol.isVarArg && this.cachedArrayInterfaceType()) { + context.setTypeInContext(paramSymbol, TypeScript.specializeType(this.cachedArrayInterfaceType(), [this.semanticInfoChain.anyTypeSymbol], this, this.cachedArrayInterfaceType().getDeclarations()[0], context)); + } else { + context.setTypeInContext(paramSymbol, this.semanticInfoChain.anyTypeSymbol); + } + + if (this.compilationSettings.noImplicitAny && !context.isInInvocationExpression) { + var functionExpressionName = (paramDecl.getParentDecl()).getFunctionExpressionName(); + if (functionExpressionName != "") { + context.postError(this.unitPath, argDeclAST.minChar, argDeclAST.getLength(), TypeScript.DiagnosticCode.Parameter_0_of_1_implicitly_has_an_any_type, [argDeclAST.id.actualText, functionExpressionName], enclosingDecl, true); + } else { + context.postError(this.unitPath, argDeclAST.minChar, argDeclAST.getLength(), TypeScript.DiagnosticCode.Parameter_0_of_lambda_function_implicitly_has_an_any_type, [argDeclAST.id.actualText], enclosingDecl, true); + } + } + } + } + + paramSymbol.setResolved(); + }; + + PullTypeResolver.prototype.resolveInterfaceTypeReference = function (interfaceDeclAST, enclosingDecl, context) { + var interfaceSymbol = null; + + var interfaceDecl = this.getDeclForAST(interfaceDeclAST); + + if (!interfaceDecl) { + var semanticInfo = this.semanticInfoChain.getUnit(this.unitPath); + var declCollectionContext = new TypeScript.DeclCollectionContext(semanticInfo, this.unitPath); + + if (enclosingDecl) { + declCollectionContext.pushParent(enclosingDecl); + } + + TypeScript.getAstWalkerFactory().walk(interfaceDeclAST, TypeScript.preCollectDecls, TypeScript.postCollectDecls, null, declCollectionContext); + + var interfaceDecl = this.getDeclForAST(interfaceDeclAST); + this.currentUnit.addSynthesizedDecl(interfaceDecl); + + var binder = new TypeScript.PullSymbolBinder(this.semanticInfoChain); + + binder.setUnit(this.unitPath); + binder.bindObjectTypeDeclarationToPullSymbol(interfaceDecl); + } + + interfaceSymbol = interfaceDecl.getSymbol(); + + if (interfaceDeclAST.members) { + var memberDecl = null; + var memberSymbol = null; + var memberType = null; + var typeMembers = interfaceDeclAST.members; + + for (var i = 0; i < typeMembers.members.length; i++) { + memberDecl = this.getDeclForAST(typeMembers.members[i]); + memberSymbol = (memberDecl.kind & TypeScript.PullElementKind.SomeSignature) ? memberDecl.getSignatureSymbol() : memberDecl.getSymbol(); + + this.resolveDeclaredSymbol(memberSymbol, enclosingDecl, context); + + memberType = memberSymbol.type; + + if ((memberType && memberType.isGeneric()) || (memberSymbol.isSignature() && (memberSymbol).isGeneric())) { + interfaceSymbol.setHasGenericMember(); + } + } + } + + interfaceSymbol.setResolved(); + + if (context.typeCheck()) { + if (!interfaceSymbol.hasBaseTypeConflict()) { + this.typeCheckMembersAgainstIndexer(interfaceSymbol, interfaceDecl, context); + } + } + + return interfaceSymbol; + }; + + PullTypeResolver.prototype.resolveTypeReference = function (typeRef, enclosingDecl, context) { + if (typeRef === null) { + return null; + } + + var type = this.getSymbolForAST(typeRef); + var aliasType = null; + if (!type) { + type = this.computeTypeReferenceSymbol(typeRef, enclosingDecl, context); + + if (type.kind == 4 /* Container */) { + var containerType = type; + var instanceSymbol = containerType.getInstanceSymbol(); + + if (instanceSymbol && (instanceSymbol.hasFlag(16384 /* ClassConstructorVariable */) || instanceSymbol.kind == 32768 /* ConstructorMethod */)) { + type = instanceSymbol.type.getAssociatedContainerType(); + } + } + + if (type && type.isAlias()) { + aliasType = type; + type = aliasType.getExportAssignedTypeSymbol(); + } + + if (type && !type.isGeneric()) { + this.setSymbolForAST(typeRef, type, context); + if (aliasType) { + this.currentUnit.setAliasSymbolForAST(typeRef, aliasType); + } + } + } + + if (type && !type.isError()) { + if ((type.kind & TypeScript.PullElementKind.SomeType) === 0) { + if (type.kind & TypeScript.PullElementKind.SomeContainer) { + context.postError(this.unitPath, typeRef.minChar, typeRef.getLength(), TypeScript.DiagnosticCode.Type_reference_cannot_refer_to_container_0, [aliasType ? aliasType.toString() : type.toString()], enclosingDecl); + } else { + context.postError(this.unitPath, typeRef.minChar, typeRef.getLength(), TypeScript.DiagnosticCode.Type_reference_must_refer_to_type, null, enclosingDecl); + } + } + } + + return type; + }; + + PullTypeResolver.prototype.computeTypeReferenceSymbol = function (typeRef, enclosingDecl, context) { + var typeDeclSymbol = null; + var diagnostic = null; + var typeSymbol = null; + + if (typeRef.term.nodeType() === 21 /* Name */) { + var prevResolvingTypeReference = context.resolvingTypeReference; + context.resolvingTypeReference = true; + typeSymbol = this.resolveTypeNameExpression(typeRef.term, enclosingDecl, context); + typeDeclSymbol = typeSymbol; + + context.resolvingTypeReference = prevResolvingTypeReference; + } else if (typeRef.term.nodeType() === 13 /* FunctionDeclaration */) { + typeDeclSymbol = this.resolveFunctionTypeSignature(typeRef.term, enclosingDecl, context); + } else if (typeRef.term.nodeType() === 15 /* InterfaceDeclaration */) { + typeDeclSymbol = this.resolveInterfaceTypeReference(typeRef.term, enclosingDecl, context); + } else if (typeRef.term.nodeType() === 10 /* GenericType */) { + typeSymbol = this.resolveGenericTypeReference(typeRef.term, enclosingDecl, context); + typeDeclSymbol = typeSymbol; + } else if (typeRef.term.nodeType() === 33 /* MemberAccessExpression */) { + var dottedName = typeRef.term; + + prevResolvingTypeReference = context.resolvingTypeReference; + typeSymbol = this.resolveDottedTypeNameExpression(dottedName, enclosingDecl, context); + typeDeclSymbol = typeSymbol; + context.resolvingTypeReference = prevResolvingTypeReference; + } else if (typeRef.term.nodeType() === 5 /* StringLiteral */) { + var stringConstantAST = typeRef.term; + typeDeclSymbol = new TypeScript.PullStringConstantTypeSymbol(stringConstantAST.actualText); + var decl = new TypeScript.PullDecl(stringConstantAST.actualText, stringConstantAST.actualText, typeDeclSymbol.kind, null, new TypeScript.TextSpan(stringConstantAST.minChar, stringConstantAST.getLength()), enclosingDecl.getScriptName()); + this.currentUnit.addSynthesizedDecl(decl); + typeDeclSymbol.addDeclaration(decl); + } else if (typeRef.term.nodeType() === 12 /* TypeQuery */) { + var typeQuery = typeRef.term; + + var typeQueryTerm = typeQuery.name; + if (typeQueryTerm.nodeType() === 11 /* TypeRef */) { + typeQueryTerm = (typeQueryTerm).term; + } + + var savedResolvingTypeReference = context.resolvingTypeReference; + context.resolvingTypeReference = false; + var valueSymbol = this.resolveAST(typeQueryTerm, false, enclosingDecl, context); + context.resolvingTypeReference = savedResolvingTypeReference; + + if (valueSymbol && valueSymbol.isAlias()) { + if ((valueSymbol).assignedValue) { + valueSymbol = (valueSymbol).assignedValue; + } else { + var containerSymbol = (valueSymbol).getExportAssignedContainerSymbol(); + valueSymbol = (containerSymbol && containerSymbol.isContainer() && !containerSymbol.isEnum()) ? containerSymbol.getInstanceSymbol() : null; + } + } + + if (valueSymbol) { + typeDeclSymbol = valueSymbol.type; + } else { + typeDeclSymbol = this.getNewErrorTypeSymbol(null); + } + } + + if (!typeDeclSymbol) { + context.postError(this.unitPath, typeRef.term.minChar, typeRef.term.getLength(), TypeScript.DiagnosticCode.Unable_to_resolve_type, null, enclosingDecl); + return this.getNewErrorTypeSymbol(null); + } + + if (typeDeclSymbol.isError()) { + return typeDeclSymbol; + } + + if (typeRef.arrayCount) { + var arraySymbol = typeDeclSymbol.getArrayType(); + + if (!arraySymbol) { + if (!this.cachedArrayInterfaceType().isResolved) { + this.resolveDeclaredSymbol(this.cachedArrayInterfaceType(), enclosingDecl, context); + } + + if (this.genericTypeIsUsedWithoutRequiredTypeArguments(typeDeclSymbol, typeRef, context)) { + context.postError(this.unitPath, typeRef.minChar, typeRef.getLength(), TypeScript.DiagnosticCode.Generic_type_references_must_include_all_type_arguments, null, enclosingDecl); + typeDeclSymbol = this.specializeTypeToAny(typeDeclSymbol, enclosingDecl, context); + } + + arraySymbol = TypeScript.specializeType(this.cachedArrayInterfaceType(), [typeDeclSymbol], this, this.cachedArrayInterfaceType().getDeclarations()[0], context, typeRef); + + if (!arraySymbol) { + arraySymbol = this.semanticInfoChain.anyTypeSymbol; + } + } + + if (typeRef.arrayCount > 1) { + for (var arity = typeRef.arrayCount - 1; arity > 0; arity--) { + var existingArraySymbol = arraySymbol.getArrayType(); + + if (!existingArraySymbol) { + arraySymbol = TypeScript.specializeType(this.cachedArrayInterfaceType(), [arraySymbol], this, this.cachedArrayInterfaceType().getDeclarations()[0], context, typeRef); + } else { + arraySymbol = existingArraySymbol; + } + } + } + + typeDeclSymbol = arraySymbol; + } + + return typeDeclSymbol; + }; + + PullTypeResolver.prototype.genericTypeIsUsedWithoutRequiredTypeArguments = function (typeSymbol, typeReference, context) { + return typeSymbol.isNamedTypeSymbol() && typeSymbol.isGeneric() && !typeSymbol.isTypeParameter() && (typeSymbol.isResolved || (typeSymbol.inResolution && !context.inSpecialization)) && !typeSymbol.getIsSpecialized() && typeSymbol.getTypeParameters().length && (typeSymbol.getTypeArguments() == null && !this.isArrayOrEquivalent(typeSymbol)) && this.isTypeRefWithoutTypeArgs(typeReference); + }; + + PullTypeResolver.prototype.resolveVariableDeclaration = function (varDecl, context, enclosingDecl) { + var _this = this; + var decl = this.getDeclForAST(varDecl); + + if (enclosingDecl && decl.kind == 2048 /* Parameter */) { + enclosingDecl.ensureSymbolIsBound(); + } + + var declSymbol = decl.getSymbol(); + var declParameterSymbol = decl.getValueDecl() ? decl.getValueDecl().getSymbol() : null; + + if (declSymbol.isResolved) { + var declType = declSymbol.type; + var valDecl = decl.getValueDecl(); + + if (valDecl) { + var valSymbol = valDecl.getSymbol(); + + if (valSymbol && !valSymbol.isResolved) { + valSymbol.type = declType; + valSymbol.setResolved(); + } + } + return declSymbol; + } + + if (declSymbol.inResolution) { + if (!context.inSpecialization) { + declSymbol.type = this.semanticInfoChain.anyTypeSymbol; + declSymbol.setResolved(); + return declSymbol; + } + } + + declSymbol.startResolving(); + + var wrapperDecl = this.getEnclosingDecl(decl); + wrapperDecl = wrapperDecl ? wrapperDecl : enclosingDecl; + + var typeExprSymbol = null; + var initExprSymbol = null; + var initTypeSymbol = null; + var inConstructorArgumentList = context.inConstructorArguments; + context.inConstructorArguments = false; + + if (varDecl.typeExpr) { + typeExprSymbol = this.resolveTypeReference(varDecl.typeExpr, wrapperDecl, context); + + if (!typeExprSymbol) { + diagnostic = context.postError(this.unitPath, varDecl.minChar, varDecl.getLength(), TypeScript.DiagnosticCode.Unable_to_resolve_type_of_0, [varDecl.id.actualText], decl); + declSymbol.type = this.getNewErrorTypeSymbol(diagnostic); + + if (declParameterSymbol) { + context.setTypeInContext(declParameterSymbol, this.semanticInfoChain.anyTypeSymbol); + } + } else if (typeExprSymbol.isError()) { + context.setTypeInContext(declSymbol, typeExprSymbol); + if (declParameterSymbol) { + context.setTypeInContext(declParameterSymbol, typeExprSymbol); + } + } else { + if (typeExprSymbol == this.semanticInfoChain.anyTypeSymbol) { + decl.setFlag(16777216 /* IsAnnotatedWithAny */); + } + + if (this.genericTypeIsUsedWithoutRequiredTypeArguments(typeExprSymbol, varDecl.typeExpr, context)) { + context.postError(this.unitPath, varDecl.typeExpr.minChar, varDecl.typeExpr.getLength(), TypeScript.DiagnosticCode.Generic_type_references_must_include_all_type_arguments, null, enclosingDecl); + + typeExprSymbol = this.specializeTypeToAny(typeExprSymbol, enclosingDecl, context); + } + + if (typeExprSymbol.isContainer()) { + var exportedTypeSymbol = (typeExprSymbol).getExportAssignedTypeSymbol(); + + if (exportedTypeSymbol) { + typeExprSymbol = exportedTypeSymbol; + } else { + typeExprSymbol = typeExprSymbol.type; + + if (typeExprSymbol.isAlias()) { + typeExprSymbol = (typeExprSymbol).getExportAssignedTypeSymbol(); + } + + if (typeExprSymbol && typeExprSymbol.isContainer() && !typeExprSymbol.isEnum()) { + var instanceSymbol = (typeExprSymbol).getInstanceSymbol(); + + if (!instanceSymbol || !TypeScript.PullHelpers.symbolIsEnum(instanceSymbol)) { + typeExprSymbol = this.getNewErrorTypeSymbol(diagnostic); + } else { + typeExprSymbol = instanceSymbol.type; + } + } + } + } else if (declSymbol.isVarArg && !(typeExprSymbol.isArray() || typeExprSymbol == this.cachedArrayInterfaceType())) { + var diagnostic = context.postError(this.unitPath, varDecl.minChar, varDecl.getLength(), TypeScript.DiagnosticCode.Rest_parameters_must_be_array_types, null, enclosingDecl); + typeExprSymbol = this.getNewErrorTypeSymbol(diagnostic); + } + + context.setTypeInContext(declSymbol, typeExprSymbol); + + if (declParameterSymbol) { + declParameterSymbol.type = typeExprSymbol; + } + + if (typeExprSymbol.kind == 16777216 /* FunctionType */) { + typeExprSymbol.setFunctionSymbol(declSymbol); + } + + if ((varDecl.nodeType() === 20 /* Parameter */) && enclosingDecl && ((typeExprSymbol.isGeneric() && !typeExprSymbol.isArray()) || this.isTypeArgumentOrWrapper(typeExprSymbol))) { + var signature = enclosingDecl.getSpecializingSignatureSymbol(); + + if (signature) { + signature.hasAGenericParameter = true; + } + } + } + } + + if (varDecl.init && (context.typeCheck() || !varDecl.typeExpr)) { + if (typeExprSymbol) { + context.pushContextualType(typeExprSymbol, context.inProvisionalResolution(), null); + } + + if (inConstructorArgumentList) { + context.inConstructorArguments = inConstructorArgumentList; + } + + context.isInStaticInitializer = (decl.flags & 16 /* Static */) != 0; + initExprSymbol = this.resolveAST(varDecl.init, typeExprSymbol != null, wrapperDecl, context); + context.isInStaticInitializer = false; + + context.inConstructorArguments = false; + + if (typeExprSymbol) { + context.popContextualType(); + } + + if (!initExprSymbol) { + diagnostic = context.postError(this.unitPath, varDecl.minChar, varDecl.getLength(), TypeScript.DiagnosticCode.Unable_to_resolve_type_of_0, [varDecl.id.actualText], decl); + + if (!varDecl.typeExpr) { + context.setTypeInContext(declSymbol, this.getNewErrorTypeSymbol(diagnostic)); + + if (declParameterSymbol) { + context.setTypeInContext(declParameterSymbol, this.semanticInfoChain.anyTypeSymbol); + } + } + } else { + initTypeSymbol = initExprSymbol.type; + + if (!varDecl.typeExpr) { + context.setTypeInContext(declSymbol, this.widenType(initTypeSymbol)); + + if (declParameterSymbol) { + context.setTypeInContext(declParameterSymbol, initTypeSymbol); + } + + if (this.compilationSettings.noImplicitAny) { + if ((declSymbol.type != initTypeSymbol) && (declSymbol.type == this.semanticInfoChain.anyTypeSymbol)) { + context.postError(this.unitPath, varDecl.minChar, varDecl.getLength(), TypeScript.DiagnosticCode.Variable_0_implicitly_has_an_any_type, [varDecl.id.actualText], enclosingDecl); + } + } + } + } + } + + if (!(varDecl.typeExpr || varDecl.init)) { + var defaultType = this.semanticInfoChain.anyTypeSymbol; + + if (this.compilationSettings.noImplicitAny && ((varDecl.getVarFlags() & 16384 /* ForInVariable */) === 0)) { + if (wrapperDecl.kind == 16384 /* Function */ || wrapperDecl.kind == 65536 /* Method */ || wrapperDecl.kind == 32768 /* ConstructorMethod */ || wrapperDecl.kind == 2097152 /* ConstructSignature */) { + context.postError(this.unitPath, varDecl.minChar, varDecl.getLength(), TypeScript.DiagnosticCode.Parameter_0_of_1_implicitly_has_an_any_type, [varDecl.id.actualText, enclosingDecl.name], enclosingDecl); + } else if (wrapperDecl.kind == 8388608 /* ObjectType */) { + context.postError(this.unitPath, varDecl.minChar, varDecl.getLength(), TypeScript.DiagnosticCode.Member_0_of_object_type_implicitly_has_an_any_type, [varDecl.id.actualText], enclosingDecl); + } else if (wrapperDecl.kind != 1073741824 /* CatchBlock */) { + context.postError(this.unitPath, varDecl.minChar, varDecl.getLength(), TypeScript.DiagnosticCode.Variable_0_implicitly_has_an_any_type, [varDecl.id.actualText], enclosingDecl); + } + } + + if (declSymbol.isVarArg) { + defaultType = TypeScript.specializeType(this.cachedArrayInterfaceType(), [defaultType], this, this.cachedArrayInterfaceType().getDeclarations()[0], context); + } + + context.setTypeInContext(declSymbol, defaultType); + + if (declParameterSymbol) { + declParameterSymbol.type = defaultType; + } + } else if (context.typeCheck()) { + if (typeExprSymbol && typeExprSymbol.isAlias()) { + typeExprSymbol = (typeExprSymbol).getExportAssignedTypeSymbol(); + } + + if (typeExprSymbol && typeExprSymbol.isContainer()) { + var exportedTypeSymbol = (typeExprSymbol).getExportAssignedTypeSymbol(); + + if (exportedTypeSymbol) { + typeExprSymbol = exportedTypeSymbol; + } else { + var instanceTypeSymbol = (typeExprSymbol).getInstanceType(); + + if (!instanceTypeSymbol || !TypeScript.PullHelpers.symbolIsEnum(instanceTypeSymbol)) { + context.postError(this.unitPath, varDecl.minChar, varDecl.getLength(), TypeScript.DiagnosticCode.Tried_to_set_variable_type_to_uninitialized_module_type_0, [typeExprSymbol.toString()], enclosingDecl); + typeExprSymbol = null; + } else { + typeExprSymbol = instanceTypeSymbol; + } + } + } + + initTypeSymbol = this.getInstanceTypeForAssignment(varDecl, initTypeSymbol, enclosingDecl, context); + + if (initTypeSymbol && typeExprSymbol) { + var comparisonInfo = new TypeComparisonInfo(); + + var isAssignable = this.sourceIsAssignableToTarget(initTypeSymbol, typeExprSymbol, context, comparisonInfo); + + if (!isAssignable) { + if (comparisonInfo.message) { + context.postError(this.unitPath, varDecl.minChar, varDecl.getLength(), TypeScript.DiagnosticCode.Cannot_convert_0_to_1_NL_2, [initTypeSymbol.toString(), typeExprSymbol.toString(), comparisonInfo.message], enclosingDecl); + } else { + context.postError(this.unitPath, varDecl.minChar, varDecl.getLength(), TypeScript.DiagnosticCode.Cannot_convert_0_to_1, [initTypeSymbol.toString(), typeExprSymbol.toString()], enclosingDecl); + } + } + } + } + + declSymbol.setResolved(); + + if (declParameterSymbol) { + declParameterSymbol.setResolved(); + } + + if (context.typeCheck()) { + if (varDecl.init && varDecl.nodeType() === 20 /* Parameter */) { + var containerSignature = enclosingDecl.getSignatureSymbol(); + if (containerSignature && !containerSignature.isDefinition()) { + context.postError(this.unitPath, varDecl.minChar, varDecl.getLength(), TypeScript.DiagnosticCode.Default_arguments_are_not_allowed_in_an_overload_parameter, [], enclosingDecl); + } + } + if (declSymbol.kind != 2048 /* Parameter */ && (declSymbol.kind != 4096 /* Property */ || declSymbol.getContainer().isNamedTypeSymbol())) { + this.checkSymbolPrivacy(declSymbol, declSymbol.type, context, function (symbol) { + return _this.variablePrivacyErrorReporter(declSymbol, symbol, context); + }); + } + } + + context.inConstructorArguments = inConstructorArgumentList; + + return declSymbol; + }; + + PullTypeResolver.prototype.resolveTypeParameterDeclaration = function (typeParameterAST, context) { + var typeParameterDecl = this.getDeclForAST(typeParameterAST); + var typeParameterSymbol = typeParameterDecl.getSymbol(); + + if (typeParameterSymbol.isResolved || typeParameterSymbol.inResolution) { + return typeParameterSymbol; + } + + typeParameterSymbol.startResolving(); + + if (typeParameterAST.constraint) { + var enclosingDecl = this.getEnclosingDecl(typeParameterDecl); + var constraintTypeSymbol = this.resolveTypeReference(typeParameterAST.constraint, enclosingDecl, context); + + if (constraintTypeSymbol && constraintTypeSymbol.isPrimitive() && !constraintTypeSymbol.isError()) { + context.postError(this.unitPath, typeParameterAST.minChar, typeParameterAST.getLength(), TypeScript.DiagnosticCode.Type_parameter_constraint_cannot_be_a_primitive_type, null, enclosingDecl); + constraintTypeSymbol = this.specializeTypeToAny(constraintTypeSymbol, enclosingDecl, context); + } else if (this.genericTypeIsUsedWithoutRequiredTypeArguments(constraintTypeSymbol, typeParameterAST.constraint, context)) { + context.postError(this.unitPath, typeParameterAST.constraint.minChar, typeParameterAST.constraint.getLength(), TypeScript.DiagnosticCode.Generic_type_references_must_include_all_type_arguments, null, enclosingDecl); + constraintTypeSymbol = this.specializeTypeToAny(constraintTypeSymbol, enclosingDecl, context); + } + + if (constraintTypeSymbol) { + typeParameterSymbol.setConstraint(constraintTypeSymbol); + } + } + + typeParameterSymbol.setResolved(); + + return typeParameterSymbol; + }; + + PullTypeResolver.prototype.resolveFunctionBodyReturnTypes = function (funcDeclAST, signature, useContextualType, enclosingDecl, context) { + var _this = this; + var returnStatements = []; + + var enclosingDeclStack = [enclosingDecl]; + + var preFindReturnExpressionTypes = function (ast, parent, walker) { + var go = true; + + switch (ast.nodeType()) { + case 13 /* FunctionDeclaration */: + go = false; + break; + + case 94 /* ReturnStatement */: + var returnStatement = ast; + enclosingDecl.setFlag(4194304 /* HasReturnStatement */); + returnStatements[returnStatements.length] = { returnStatement: returnStatement, enclosingDecl: enclosingDeclStack[enclosingDeclStack.length - 1] }; + go = false; + break; + + case 102 /* CatchClause */: + case 100 /* WithStatement */: + enclosingDeclStack[enclosingDeclStack.length] = _this.getDeclForAST(ast); + break; + + default: + break; + } + + walker.options.goChildren = go; + + return ast; + }; + + var postFindReturnExpressionEnclosingDecls = function (ast, parent, walker) { + switch (ast.nodeType()) { + case 102 /* CatchClause */: + case 100 /* WithStatement */: + enclosingDeclStack.length--; + break; + default: + break; + } + + walker.options.goChildren = true; + + return ast; + }; + + TypeScript.getAstWalkerFactory().walk(funcDeclAST.block, preFindReturnExpressionTypes, postFindReturnExpressionEnclosingDecls); + + if (!returnStatements.length) { + signature.returnType = this.semanticInfoChain.voidTypeSymbol; + } else { + var returnExpressionSymbols = []; + var returnType; + + for (var i = 0; i < returnStatements.length; i++) { + if (returnStatements[i].returnStatement.returnExpression) { + returnType = this.resolveAST(returnStatements[i].returnStatement.returnExpression, useContextualType, returnStatements[i].enclosingDecl, context).type; + + if (returnType.isError()) { + signature.returnType = returnType; + return; + } else { + this.setSymbolForAST(returnStatements[i].returnStatement, returnType, context); + } + + returnExpressionSymbols[returnExpressionSymbols.length] = returnType; + } + } + + if (!returnExpressionSymbols.length) { + signature.returnType = this.semanticInfoChain.voidTypeSymbol; + } else { + var collection = { + getLength: function () { + return returnExpressionSymbols.length; + }, + setTypeAtIndex: function (index, type) { + }, + getTypeAtIndex: function (index) { + return returnExpressionSymbols[index].type; + } + }; + + returnType = this.findBestCommonType(returnExpressionSymbols[0], null, collection, context, new TypeComparisonInfo()); + + if (useContextualType && returnType == this.semanticInfoChain.anyTypeSymbol) { + var contextualType = context.getContextualType(); + + if (contextualType) { + returnType = contextualType; + } + } + + var functionDecl = this.getDeclForAST(funcDeclAST); + var functionSymbol = functionDecl.getSymbol(); + + if (returnType) { + var previousReturnType = returnType; + var newReturnType = this.widenType(returnType); + signature.returnType = newReturnType; + + if (this.compilationSettings.noImplicitAny) { + if (previousReturnType !== newReturnType && newReturnType === this.semanticInfoChain.anyTypeSymbol) { + var functionName = enclosingDecl.name; + if (functionName == "") { + functionName = (enclosingDecl).getFunctionExpressionName(); + } + + if (functionName != "") { + context.postError(this.unitPath, funcDeclAST.minChar, funcDeclAST.getLength(), TypeScript.DiagnosticCode._0_which_lacks_return_type_annotation_implicitly_has_an_any_return_type, [functionName], enclosingDecl); + } else { + context.postError(this.unitPath, funcDeclAST.minChar, funcDeclAST.getLength(), TypeScript.DiagnosticCode.Function_expression_which_lacks_return_type_annotation_implicitly_has_an_any_return_type, [], enclosingDecl); + } + } + } + } + + if (this.isTypeArgumentOrWrapper(returnType) && functionSymbol) { + functionSymbol.type.setHasGenericSignature(); + } + } + } + }; + + PullTypeResolver.prototype.resolveFunctionDeclaration = function (funcDeclAST, context) { + var _this = this; + var funcDecl = this.getDeclForAST(funcDeclAST); + + var funcSymbol = funcDecl.getSymbol(); + + var signature = funcDecl.getSpecializingSignatureSymbol(); + + var hadError = false; + + var isConstructor = funcDeclAST.isConstructor || TypeScript.hasFlag(funcDeclAST.getFunctionFlags(), 1024 /* ConstructMember */); + + if (signature) { + if (signature.isResolved) { + return funcSymbol; + } + + if (isConstructor && !signature.inResolution) { + var classAST = funcDeclAST.classDecl; + + if (classAST) { + var classDecl = this.getDeclForAST(classAST); + var classSymbol = classDecl.getSymbol(); + + if (!classSymbol.isResolved && !classSymbol.inResolution) { + this.resolveDeclaredSymbol(classSymbol, this.getEnclosingDecl(classDecl), context); + } + } + } + + var diagnostic; + + var functionTypeSymbol = funcSymbol && funcSymbol.type; + + if (signature.inResolution) { + if (funcDeclAST.returnTypeAnnotation) { + var returnTypeSymbol = this.resolveTypeReference(funcDeclAST.returnTypeAnnotation, funcDecl, context); + if (!returnTypeSymbol) { + diagnostic = context.postError(this.unitPath, funcDeclAST.returnTypeAnnotation.minChar, funcDeclAST.returnTypeAnnotation.getLength(), TypeScript.DiagnosticCode.Cannot_resolve_return_type_reference, null, funcDecl); + signature.returnType = this.getNewErrorTypeSymbol(diagnostic); + hadError = true; + } else { + if (this.isTypeArgumentOrWrapper(returnTypeSymbol)) { + signature.hasAGenericParameter = true; + if (funcSymbol) { + funcSymbol.type.setHasGenericSignature(); + } + } + signature.returnType = returnTypeSymbol; + + if (isConstructor && returnTypeSymbol === this.semanticInfoChain.voidTypeSymbol) { + context.postError(this.unitPath, funcDeclAST.minChar, funcDeclAST.getLength(), TypeScript.DiagnosticCode.Constructors_cannot_have_a_return_type_of_void, null, funcDecl); + } + } + } else { + signature.returnType = this.semanticInfoChain.anyTypeSymbol; + } + + if (funcSymbol) { + funcSymbol.setUnresolved(); + if (funcSymbol.type === this.semanticInfoChain.anyTypeSymbol) { + funcSymbol.type = functionTypeSymbol; + } + } + signature.setResolved(); + return funcSymbol; + } + + if (funcSymbol) { + funcSymbol.startResolving(); + } + signature.startResolving(); + + if (funcDeclAST.typeArguments) { + for (var i = 0; i < funcDeclAST.typeArguments.members.length; i++) { + this.resolveTypeParameterDeclaration(funcDeclAST.typeArguments.members[i], context); + } + } + + if (funcDeclAST.arguments) { + var prevInConstructorArguments = context.inConstructorArguments; + context.inConstructorArguments = isConstructor; + for (var i = 0; i < funcDeclAST.arguments.members.length; i++) { + this.resolveVariableDeclaration(funcDeclAST.arguments.members[i], context, funcDecl); + } + context.inConstructorArguments = prevInConstructorArguments; + } + + if (signature.isGeneric()) { + if (funcSymbol) { + funcSymbol.type.setHasGenericSignature(); + } + } + + if (funcDeclAST.returnTypeAnnotation) { + var prevReturnTypeSymbol = signature.returnType; + + returnTypeSymbol = this.resolveTypeReference(funcDeclAST.returnTypeAnnotation, funcDecl, context); + + if (!returnTypeSymbol) { + diagnostic = context.postError(this.unitPath, funcDeclAST.returnTypeAnnotation.minChar, funcDeclAST.returnTypeAnnotation.getLength(), TypeScript.DiagnosticCode.Cannot_resolve_return_type_reference, null, funcDecl); + signature.returnType = this.getNewErrorTypeSymbol(diagnostic); + + hadError = true; + } else if (!(this.isTypeArgumentOrWrapper(returnTypeSymbol) && prevReturnTypeSymbol && !this.isTypeArgumentOrWrapper(prevReturnTypeSymbol))) { + if (this.isTypeArgumentOrWrapper(returnTypeSymbol)) { + signature.hasAGenericParameter = true; + + if (funcSymbol) { + funcSymbol.type.setHasGenericSignature(); + } + } + + signature.returnType = returnTypeSymbol; + + if (isConstructor && returnTypeSymbol === this.semanticInfoChain.voidTypeSymbol) { + context.postError(this.unitPath, funcDeclAST.minChar, funcDeclAST.getLength(), TypeScript.DiagnosticCode.Constructors_cannot_have_a_return_type_of_void, null, funcDecl); + } + } + } else if (!funcDeclAST.isConstructor && !funcDeclAST.isConstructMember()) { + if (funcDeclAST.isSignature()) { + signature.returnType = this.semanticInfoChain.anyTypeSymbol; + + if (this.compilationSettings.noImplicitAny) { + var funcDeclASTName = funcDeclAST.name; + if (funcDeclASTName) { + context.postError(this.unitPath, funcDeclAST.minChar, funcDeclAST.getLength(), TypeScript.DiagnosticCode._0_which_lacks_return_type_annotation_implicitly_has_an_any_return_type, [funcDeclASTName.actualText], funcDecl); + } else { + context.postError(this.unitPath, funcDeclAST.minChar, funcDeclAST.getLength(), TypeScript.DiagnosticCode.Lambda_Function_which_lacks_return_type_annotation_implicitly_has_an_any_return_type, [], funcDecl); + } + } + } else { + this.resolveFunctionBodyReturnTypes(funcDeclAST, signature, false, funcDecl, context); + } + } else if (funcDeclAST.isConstructMember()) { + if (funcDeclAST.isSignature()) { + signature.returnType = this.semanticInfoChain.anyTypeSymbol; + + if (this.compilationSettings.noImplicitAny) { + context.postError(this.unitPath, funcDeclAST.minChar, funcDeclAST.getLength(), TypeScript.DiagnosticCode.Constructor_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type, [], funcDecl); + } + } + } + + if (!hadError) { + if (funcSymbol) { + funcSymbol.setUnresolved(); + if (funcSymbol.type === this.semanticInfoChain.anyTypeSymbol) { + funcSymbol.type = functionTypeSymbol; + } + } + signature.setResolved(); + } + } + + if (context.inTypeCheck && (!context.inSpecialization || !signature.isGeneric())) { + var prevSeenSuperConstructorCall = this.seenSuperConstructorCall; + + PullTypeResolver.typeCheckCallBacks.push(function () { + if (signature.hasBeenChecked) { + return; + } + + _this.setUnitPath(funcDecl.getScriptName()); + _this.seenSuperConstructorCall = false; + + _this.resolveAST(funcDeclAST.block, false, funcDecl, context); + + _this.validateVariableDeclarationGroups(funcDecl, context); + + var enclosingDecl = _this.getEnclosingDecl(funcDecl); + + var hasReturn = (funcDecl.flags & (2048 /* Signature */ | 4194304 /* HasReturnStatement */)) != 0; + + var parameters = signature.parameters; + + if (funcDeclAST.isConstructor || TypeScript.hasFlag(funcDeclAST.getFunctionFlags(), 1024 /* ConstructMember */)) { + if (funcDecl.getSignatureSymbol() && funcDecl.getSignatureSymbol().isDefinition() && _this.enclosingClassIsDerived(funcDecl)) { + if (!_this.seenSuperConstructorCall) { + context.postError(_this.unitPath, funcDeclAST.minChar, 11, TypeScript.DiagnosticCode.Constructors_for_derived_classes_must_contain_a_super_call, null, enclosingDecl); + } else if (_this.superCallMustBeFirstStatementInConstructor(funcDecl, enclosingDecl)) { + var firstStatement = _this.getFirstStatementFromFunctionDeclAST(funcDeclAST); + if (!firstStatement || !_this.isSuperCallNode(firstStatement)) { + context.postError(_this.unitPath, funcDeclAST.minChar, 11, TypeScript.DiagnosticCode.A_super_call_must_be_the_first_statement_in_the_constructor_when_a_class_contains_initialized_properties_or_has_parameter_properties, null, enclosingDecl); + } + } + } + _this.typeCheckFunctionOverloads(funcDeclAST, context); + } else if (TypeScript.hasFlag(funcDeclAST.getFunctionFlags(), 4096 /* IndexerMember */)) { + var allIndexSignatures = enclosingDecl.getSymbol().type.getIndexSignatures(); + + for (var i = 0; i < allIndexSignatures.length; i++) { + if (!allIndexSignatures[i].isResolved) { + _this.resolveDeclaredSymbol(allIndexSignatures[i], allIndexSignatures[i].getDeclarations()[0].getParentDecl(), context); + } + + if (allIndexSignatures[i].parameters[0].type !== parameters[0].type) { + var stringIndexSignature = null; + var numberIndexSignature = null; + + var indexSignature = signature; + + var isNumericIndexer = parameters[0].type === _this.semanticInfoChain.numberTypeSymbol; + + if (isNumericIndexer) { + numberIndexSignature = indexSignature; + stringIndexSignature = allIndexSignatures[i]; + } else { + numberIndexSignature = allIndexSignatures[i]; + stringIndexSignature = indexSignature; + + if (enclosingDecl.getSymbol() === numberIndexSignature.getDeclarations()[0].getParentDecl().getSymbol()) { + break; + } + } + var comparisonInfo = new TypeComparisonInfo(); + var resolutionContext = new TypeScript.PullTypeResolutionContext(); + if (!_this.sourceIsSubtypeOfTarget(numberIndexSignature.returnType, stringIndexSignature.returnType, resolutionContext, comparisonInfo)) { + if (comparisonInfo.message) { + context.postError(_this.unitPath, funcDeclAST.minChar, funcDeclAST.getLength(), TypeScript.DiagnosticCode.Numeric_indexer_type_0_must_be_a_subtype_of_string_indexer_type_1_NL_2, [numberIndexSignature.returnType.toString(), stringIndexSignature.returnType.toString(), comparisonInfo.message], enclosingDecl); + } else { + context.postError(_this.unitPath, funcDeclAST.minChar, funcDeclAST.getLength(), TypeScript.DiagnosticCode.Numeric_indexer_type_0_must_be_a_subtype_of_string_indexer_type_1, [numberIndexSignature.returnType.toString(), stringIndexSignature.returnType.toString()], enclosingDecl); + } + } + break; + } + } + + var allMembers = enclosingDecl.getSymbol().type.getAllMembers(TypeScript.PullElementKind.All, true); + for (var i = 0; i < allMembers.length; i++) { + var name = allMembers[i].name; + if (name) { + if (!allMembers[i].isResolved) { + _this.resolveDeclaredSymbol(allMembers[i], allMembers[i].getDeclarations()[0].getParentDecl(), context); + } + + if (enclosingDecl.getSymbol() !== allMembers[i].getContainer()) { + var isMemberNumeric = isFinite(+name); + if (isNumericIndexer === isMemberNumeric) { + _this.checkThatMemberIsSubtypeOfIndexer(allMembers[i], indexSignature, funcDeclAST, context, enclosingDecl, isNumericIndexer); + } + } + } + } + } else { + if (funcDeclAST.block && funcDeclAST.returnTypeAnnotation != null && !hasReturn) { + var isVoidOrAny = _this.isAnyOrEquivalent(returnTypeSymbol) || returnTypeSymbol === _this.semanticInfoChain.voidTypeSymbol; + + if (!isVoidOrAny && !(funcDeclAST.block.statements.members.length > 0 && funcDeclAST.block.statements.members[0].nodeType() === 96 /* ThrowStatement */)) { + var funcName = funcDecl.getDisplayName(); + funcName = funcName ? funcName : "expression"; + + context.postError(_this.unitPath, funcDeclAST.returnTypeAnnotation.minChar, funcDeclAST.returnTypeAnnotation.getLength(), TypeScript.DiagnosticCode.Function_0_declared_a_non_void_return_type_but_has_no_return_expression, [funcName], enclosingDecl); + } + } + _this.typeCheckFunctionOverloads(funcDeclAST, context); + } + + _this.checkFunctionTypePrivacy(funcDeclAST, false, context); + _this.seenSuperConstructorCall = prevSeenSuperConstructorCall; + + signature.hasBeenChecked = true; + }); + } + + return funcSymbol; + }; + + PullTypeResolver.prototype.resolveGetAccessorDeclaration = function (funcDeclAST, context) { + var funcDecl = this.getDeclForAST(funcDeclAST); + var accessorSymbol = funcDecl.getSymbol(); + + var getterSymbol = accessorSymbol.getGetter(); + var getterTypeSymbol = getterSymbol.type; + + var signature = getterTypeSymbol.getCallSignatures()[0]; + + var hadError = false; + var diagnostic; + + if (signature) { + if (signature.isResolved) { + return accessorSymbol; + } + + if (signature.inResolution) { + signature.returnType = this.semanticInfoChain.anyTypeSymbol; + signature.setResolved(); + + return accessorSymbol; + } + + signature.startResolving(); + + if (funcDeclAST.arguments) { + for (var i = 0; i < funcDeclAST.arguments.members.length; i++) { + this.resolveVariableDeclaration(funcDeclAST.arguments.members[i], context, funcDecl); + } + } + + if (signature.hasAGenericParameter) { + if (getterSymbol) { + getterTypeSymbol.setHasGenericSignature(); + } + } + + if (funcDeclAST.returnTypeAnnotation) { + var returnTypeSymbol = this.resolveTypeReference(funcDeclAST.returnTypeAnnotation, funcDecl, context); + + if (!returnTypeSymbol) { + diagnostic = context.postError(this.unitPath, funcDeclAST.returnTypeAnnotation.minChar, funcDeclAST.returnTypeAnnotation.getLength(), TypeScript.DiagnosticCode.Cannot_resolve_return_type_reference, null, funcDecl); + signature.returnType = this.getNewErrorTypeSymbol(diagnostic); + + hadError = true; + } else { + if (this.isTypeArgumentOrWrapper(returnTypeSymbol)) { + signature.hasAGenericParameter = true; + + if (getterSymbol) { + getterTypeSymbol.setHasGenericSignature(); + } + } + + signature.returnType = returnTypeSymbol; + } + } else { + if (funcDeclAST.isSignature()) { + signature.returnType = this.semanticInfoChain.anyTypeSymbol; + } else { + this.resolveFunctionBodyReturnTypes(funcDeclAST, signature, false, funcDecl, context); + } + } + + if (!hadError) { + signature.setResolved(); + } + } + + var accessorType = signature.returnType; + + var setter = accessorSymbol.getSetter(); + + if (setter) { + var setterType = setter.type; + var setterSig = setterType.getCallSignatures()[0]; + + if (setterSig.isResolved) { + var setterParameters = setterSig.parameters; + + if (setterParameters.length) { + var setterParameter = setterParameters[0]; + var setterParameterType = setterParameter.type; + + if (!this.typesAreIdentical(accessorType, setterParameterType)) { + diagnostic = context.postError(this.unitPath, funcDeclAST.minChar, funcDeclAST.getLength(), TypeScript.DiagnosticCode.get_and_set_accessor_must_have_the_same_type, null, this.getEnclosingDecl(funcDecl)); + accessorSymbol.type = this.getNewErrorTypeSymbol(diagnostic); + } + } + } else { + accessorSymbol.type = accessorType; + } + } else { + accessorSymbol.type = accessorType; + } + + if (context.typeCheck()) { + var prevSeenSuperConstructorCall = this.seenSuperConstructorCall; + this.seenSuperConstructorCall = false; + + this.resolveAST(funcDeclAST.block, false, funcDecl, context); + + this.validateVariableDeclarationGroups(funcDecl, context); + + var enclosingDecl = this.getEnclosingDecl(funcDecl); + + var hasReturn = (funcDecl.flags & (2048 /* Signature */ | 4194304 /* HasReturnStatement */)) != 0; + + var isGetter = TypeScript.hasFlag(funcDeclAST.getFunctionFlags(), 32 /* GetAccessor */); + var isSetter = !isGetter; + + var getter = accessorSymbol.getGetter(); + var setter = accessorSymbol.getSetter(); + + var funcNameAST = funcDeclAST.name; + + if (!hasReturn) { + if (!(funcDeclAST.block.statements.members.length > 0 && funcDeclAST.block.statements.members[0].nodeType() === 96 /* ThrowStatement */)) { + context.postError(this.unitPath, funcNameAST.minChar, funcNameAST.getLength(), TypeScript.DiagnosticCode.Getters_must_return_a_value, null, enclosingDecl); + } + } + + if (getter && setter) { + var getterDecl = getter.getDeclarations()[0]; + var setterDecl = setter.getDeclarations()[0]; + + var getterIsPrivate = getterDecl.flags & 2 /* Private */; + var setterIsPrivate = setterDecl.flags & 2 /* Private */; + + if (getterIsPrivate != setterIsPrivate) { + context.postError(this.unitPath, funcNameAST.minChar, funcNameAST.getLength(), TypeScript.DiagnosticCode.Getter_and_setter_accessors_do_not_agree_in_visibility, null, enclosingDecl); + } + } + + this.checkFunctionTypePrivacy(funcDeclAST, false, context); + } + + return accessorSymbol; + }; + + PullTypeResolver.prototype.resolveSetAccessorDeclaration = function (funcDeclAST, context) { + var funcDecl = this.getDeclForAST(funcDeclAST); + var accessorSymbol = funcDecl.getSymbol(); + + var setterSymbol = accessorSymbol.getSetter(); + var setterTypeSymbol = setterSymbol.type; + + var signature = setterTypeSymbol.getCallSignatures()[0]; + + var hadError = false; + + if (signature) { + if (signature.isResolved) { + return accessorSymbol; + } + + if (signature.inResolution) { + signature.returnType = this.semanticInfoChain.anyTypeSymbol; + signature.setResolved(); + + return accessorSymbol; + } + + signature.startResolving(); + + if (funcDeclAST.arguments) { + for (var i = 0; i < funcDeclAST.arguments.members.length; i++) { + this.resolveVariableDeclaration(funcDeclAST.arguments.members[i], context, funcDecl); + } + } + + if (signature.hasAGenericParameter) { + if (setterSymbol) { + setterTypeSymbol.setHasGenericSignature(); + } + } + + if (!hadError) { + signature.setResolved(); + } + } + + var parameters = signature.parameters; + + var getter = accessorSymbol.getGetter(); + + var accessorType = parameters.length ? parameters[0].type : getter ? getter.type : this.semanticInfoChain.undefinedTypeSymbol; + + if (getter) { + var getterType = getter.type; + var getterSig = getterType.getCallSignatures()[0]; + + if (accessorType == this.semanticInfoChain.undefinedTypeSymbol) { + accessorType = getterType; + } + + if (getterSig.isResolved) { + var getterReturnType = getterSig.returnType; + + if (!this.typesAreIdentical(accessorType, getterReturnType)) { + if (this.isAnyOrEquivalent(accessorType)) { + accessorSymbol.type = getterReturnType; + if (!accessorType.isError()) { + parameters[0].type = getterReturnType; + } + } else { + var diagnostic = context.postError(this.unitPath, funcDeclAST.minChar, funcDeclAST.getLength(), TypeScript.DiagnosticCode.get_and_set_accessor_must_have_the_same_type, null, this.getEnclosingDecl(funcDecl)); + accessorSymbol.type = this.getNewErrorTypeSymbol(diagnostic); + } + } + } else { + accessorSymbol.type = accessorType; + } + } else { + accessorSymbol.type = accessorType; + + if (this.compilationSettings.noImplicitAny) { + if (accessorSymbol.type == this.semanticInfoChain.anyTypeSymbol) { + context.postError(this.unitPath, funcDeclAST.minChar, funcDeclAST.getLength(), TypeScript.DiagnosticCode._0_which_lacks_return_type_annotation_implicitly_has_an_any_return_type, [funcDeclAST.name.actualText], this.getEnclosingDecl(funcDecl)); + } + } + } + + if (context.typeCheck()) { + var prevSeenSuperConstructorCall = this.seenSuperConstructorCall; + this.seenSuperConstructorCall = false; + + this.resolveAST(funcDeclAST.block, false, funcDecl, context); + + this.validateVariableDeclarationGroups(funcDecl, context); + + var enclosingDecl = this.getEnclosingDecl(funcDecl); + + var hasReturn = (funcDecl.flags & (2048 /* Signature */ | 4194304 /* HasReturnStatement */)) != 0; + + var isGetter = TypeScript.hasFlag(funcDeclAST.getFunctionFlags(), 32 /* GetAccessor */); + var isSetter = !isGetter; + + var getter = accessorSymbol.getGetter(); + var setter = accessorSymbol.getSetter(); + + var funcNameAST = funcDeclAST.name; + + if (getter && setter) { + var getterDecl = getter.getDeclarations()[0]; + var setterDecl = setter.getDeclarations()[0]; + + var getterIsPrivate = getterDecl.flags & 2 /* Private */; + var setterIsPrivate = setterDecl.flags & 2 /* Private */; + + if (getterIsPrivate != setterIsPrivate) { + context.postError(this.unitPath, funcNameAST.minChar, funcNameAST.getLength(), TypeScript.DiagnosticCode.Getter_and_setter_accessors_do_not_agree_in_visibility, null, enclosingDecl); + } + } + + this.checkFunctionTypePrivacy(funcDeclAST, false, context); + } + + return accessorSymbol; + }; + + PullTypeResolver.prototype.resolveList = function (list, enclosingDecl, context) { + if (context.typeCheck()) { + for (var i = 0; i < list.members.length; i++) { + this.resolveAST(list.members[i], false, enclosingDecl, context); + } + } + + return this.semanticInfoChain.voidTypeSymbol; + }; + + PullTypeResolver.prototype.resolveVoidExpression = function (ast, enclosingDecl, context) { + if (context.typeCheck()) { + this.resolveAST((ast).operand, false, enclosingDecl, context); + } + + this.setSymbolForAST(ast, this.semanticInfoChain.voidTypeSymbol, context); + return this.semanticInfoChain.voidTypeSymbol; + }; + + PullTypeResolver.prototype.resolveLogicalOperation = function (ast, enclosingDecl, context) { + if (context.typeCheck()) { + var binex = ast; + + var leftType = this.resolveAST(binex.operand1, false, enclosingDecl, context).type; + var rightType = this.resolveAST(binex.operand2, false, enclosingDecl, context).type; + + var comparisonInfo = new TypeComparisonInfo(); + if (!this.sourceIsAssignableToTarget(leftType, rightType, context, comparisonInfo) && !this.sourceIsAssignableToTarget(rightType, leftType, context, comparisonInfo)) { + context.postError(this.unitPath, binex.minChar, binex.getLength(), TypeScript.DiagnosticCode.Operator_0_cannot_be_applied_to_types_1_and_2, [TypeScript.BinaryExpression.getTextForBinaryToken(binex.nodeType()), leftType.toString(), rightType.toString()], enclosingDecl); + } + } + + this.setSymbolForAST(ast, this.semanticInfoChain.booleanTypeSymbol, context); + return this.semanticInfoChain.booleanTypeSymbol; + }; + + PullTypeResolver.prototype.resolveUnaryLogicalOperation = function (ast, enclosingDecl, context) { + if (context.typeCheck()) { + this.resolveAST((ast).operand, false, enclosingDecl, context); + } + + this.setSymbolForAST(ast, this.semanticInfoChain.booleanTypeSymbol, context); + return this.semanticInfoChain.booleanTypeSymbol; + }; + + PullTypeResolver.prototype.resolveUnaryArithmeticOperation = function (ast, enclosingDecl, context) { + var nodeType = ast.nodeType(); + if (context.typeCheck()) { + var unaryExpression = ast; + var expression = this.resolveAST(unaryExpression.operand, false, enclosingDecl, context); + + if (nodeType == 27 /* PlusExpression */ || nodeType == 28 /* NegateExpression */ || nodeType == 73 /* BitwiseNotExpression */) { + return this.semanticInfoChain.numberTypeSymbol; + } + var operandType = expression.type; + + var operandIsFit = this.isAnyOrEquivalent(operandType) || operandType === this.semanticInfoChain.numberTypeSymbol || TypeScript.PullHelpers.symbolIsEnum(operandType); + + if (!operandIsFit) { + context.postError(this.unitPath, unaryExpression.operand.minChar, unaryExpression.operand.getLength(), TypeScript.DiagnosticCode.The_type_of_a_unary_arithmetic_operation_operand_must_be_of_type_any_number_or_an_enum_type, null, enclosingDecl); + } + + switch (unaryExpression.nodeType()) { + case 77 /* PostIncrementExpression */: + case 75 /* PreIncrementExpression */: + case 78 /* PostDecrementExpression */: + case 76 /* PreDecrementExpression */: + if (!this.isValidLHS(unaryExpression.operand, expression)) { + context.postError(this.unitPath, unaryExpression.operand.minChar, unaryExpression.operand.getLength(), TypeScript.DiagnosticCode.The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_property_or_indexer, null, enclosingDecl); + } + + break; + } + } + + this.setSymbolForAST(ast, this.semanticInfoChain.numberTypeSymbol, context); + return this.semanticInfoChain.numberTypeSymbol; + }; + + PullTypeResolver.prototype.resolveBinaryArithmeticExpression = function (ast, enclosingDecl, context) { + if (context.typeCheck()) { + var binaryExpression = ast; + + var lhsSymbol = this.resolveAST(binaryExpression.operand1, false, enclosingDecl, context); + + var lhsType = lhsSymbol.type; + var rhsType = this.resolveAST(binaryExpression.operand2, false, enclosingDecl, context).type; + + var lhsIsFit = this.isAnyOrEquivalent(lhsType) || lhsType === this.semanticInfoChain.numberTypeSymbol || TypeScript.PullHelpers.symbolIsEnum(lhsType); + var rhsIsFit = this.isAnyOrEquivalent(rhsType) || rhsType === this.semanticInfoChain.numberTypeSymbol || TypeScript.PullHelpers.symbolIsEnum(rhsType); + + if (!rhsIsFit) { + context.postError(this.unitPath, binaryExpression.operand1.minChar, binaryExpression.operand1.getLength(), TypeScript.DiagnosticCode.The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type, null, enclosingDecl); + } + + if (!lhsIsFit) { + context.postError(this.unitPath, binaryExpression.operand2.minChar, binaryExpression.operand2.getLength(), TypeScript.DiagnosticCode.The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type, null, enclosingDecl); + } + + if (rhsIsFit && lhsIsFit) { + switch (binaryExpression.nodeType()) { + case 48 /* LeftShiftAssignmentExpression */: + case 49 /* SignedRightShiftAssignmentExpression */: + case 50 /* UnsignedRightShiftAssignmentExpression */: + case 41 /* SubtractAssignmentExpression */: + case 43 /* MultiplyAssignmentExpression */: + case 42 /* DivideAssignmentExpression */: + case 44 /* ModuloAssignmentExpression */: + case 47 /* OrAssignmentExpression */: + case 45 /* AndAssignmentExpression */: + case 46 /* ExclusiveOrAssignmentExpression */: + if (!this.isValidLHS(binaryExpression.operand1, lhsSymbol)) { + context.postError(this.unitPath, binaryExpression.operand1.minChar, binaryExpression.operand1.getLength(), TypeScript.DiagnosticCode.Invalid_left_hand_side_of_assignment_expression, null, enclosingDecl); + } + + this.checkAssignability(binaryExpression.operand1, rhsType, lhsType, enclosingDecl, context); + break; + } + } + } + + this.setSymbolForAST(ast, this.semanticInfoChain.numberTypeSymbol, context); + return this.semanticInfoChain.numberTypeSymbol; + }; + + PullTypeResolver.prototype.resolveTypeOfExpression = function (ast, enclosingDecl, context) { + if (context.typeCheck()) { + this.resolveAST((ast).operand, false, enclosingDecl, context); + } + + this.setSymbolForAST(ast, this.semanticInfoChain.stringTypeSymbol, context); + return this.semanticInfoChain.stringTypeSymbol; + }; + + PullTypeResolver.prototype.resolveThrowStatement = function (ast, enclosingDecl, context) { + if (context.typeCheck()) { + this.resolveAST((ast).expression, false, enclosingDecl, context); + } + + this.setSymbolForAST(ast, this.semanticInfoChain.voidTypeSymbol, context); + return this.semanticInfoChain.voidTypeSymbol; + }; + + PullTypeResolver.prototype.resolveDeleteStatement = function (ast, enclosingDecl, context) { + if (context.typeCheck()) { + this.resolveAST((ast).operand, false, enclosingDecl, context); + } + + this.setSymbolForAST(ast, this.semanticInfoChain.booleanTypeSymbol, context); + return this.semanticInfoChain.booleanTypeSymbol; + }; + + PullTypeResolver.prototype.resolveInstanceOfExpression = function (ast, enclosingDecl, context) { + if (context.typeCheck()) { + var binaryExpression = ast; + + var lhsType = this.widenType(this.resolveAST(binaryExpression.operand1, false, enclosingDecl, context).type); + var rhsType = this.widenType(this.resolveAST(binaryExpression.operand2, false, enclosingDecl, context).type); + + var isValidLHS = lhsType && (this.isAnyOrEquivalent(lhsType) || !lhsType.isPrimitive()); + var isValidRHS = rhsType && (this.isAnyOrEquivalent(rhsType) || rhsType.isClass() || this.typeIsSubtypeOfFunction(rhsType, context)); + + if (!isValidLHS) { + context.postError(this.unitPath, binaryExpression.operand1.minChar, binaryExpression.operand1.getLength(), TypeScript.DiagnosticCode.The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter, null, enclosingDecl); + } + + if (!isValidRHS) { + context.postError(this.unitPath, binaryExpression.operand1.minChar, binaryExpression.operand1.getLength(), TypeScript.DiagnosticCode.The_right_hand_side_of_an_instanceof_expression_must_be_of_type_any_or_a_subtype_of_the_Function_interface_type, null, enclosingDecl); + } + } + + this.setSymbolForAST(ast, this.semanticInfoChain.booleanTypeSymbol, context); + return this.semanticInfoChain.booleanTypeSymbol; + }; + + PullTypeResolver.prototype.resolveCommaExpression = function (ast, enclosingDecl, context) { + if (context.typeCheck()) { + this.resolveAST((ast).operand1, false, enclosingDecl, context); + return this.resolveAST((ast).operand2, false, enclosingDecl, context); + } + + return this.semanticInfoChain.voidTypeSymbol; + }; + + PullTypeResolver.prototype.resolveInExpression = function (ast, enclosingDecl, context) { + if (context.typeCheck()) { + var binaryExpression = ast; + var lhsType = this.widenType(this.resolveAST(binaryExpression.operand1, false, enclosingDecl, context).type); + var rhsType = this.widenType(this.resolveAST(binaryExpression.operand2, false, enclosingDecl, context).type); + + var isStringAnyOrNumber = lhsType.type === this.semanticInfoChain.stringTypeSymbol || this.isAnyOrEquivalent(lhsType.type) || this.isNumberOrEquivalent(lhsType.type); + var isValidRHS = rhsType && (this.isAnyOrEquivalent(rhsType) || !rhsType.isPrimitive()); + + if (!isStringAnyOrNumber) { + context.postError(this.unitPath, binaryExpression.operand1.minChar, binaryExpression.operand1.getLength(), TypeScript.DiagnosticCode.The_left_hand_side_of_an_in_expression_must_be_of_types_string_or_any, null, enclosingDecl); + } + + if (!isValidRHS) { + context.postError(this.unitPath, binaryExpression.operand1.minChar, binaryExpression.operand1.getLength(), TypeScript.DiagnosticCode.The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter, null, enclosingDecl); + } + } + + this.setSymbolForAST(ast, this.semanticInfoChain.booleanTypeSymbol, context); + return this.semanticInfoChain.booleanTypeSymbol; + }; + + PullTypeResolver.prototype.resolveForStatement = function (ast, enclosingDecl, context) { + if (context.typeCheck()) { + this.resolveAST((ast).init, false, enclosingDecl, context); + this.resolveAST((ast).cond, false, enclosingDecl, context); + this.resolveAST((ast).incr, false, enclosingDecl, context); + this.resolveAST((ast).body, false, enclosingDecl, context); + } + + this.setSymbolForAST(ast, this.semanticInfoChain.voidTypeSymbol, context); + return this.semanticInfoChain.voidTypeSymbol; + }; + + PullTypeResolver.prototype.resolveForInStatement = function (ast, enclosingDecl, context) { + if (context.typeCheck()) { + var forInStatement = ast; + + var rhsType = this.widenType(this.resolveAST(forInStatement.obj, false, enclosingDecl, context).type); + var lval = forInStatement.lval; + + if (lval.nodeType() === 19 /* VariableDeclaration */) { + var declaration = forInStatement.lval; + var varDecl = declaration.declarators.members[0]; + + if (varDecl.typeExpr) { + context.postError(this.unitPath, lval.minChar, lval.getLength(), TypeScript.DiagnosticCode.Variable_declarations_of_a_for_statement_cannot_use_a_type_annotation, null, enclosingDecl); + } + } + + var varSym = this.resolveAST(forInStatement.lval, false, enclosingDecl, context); + + if (lval.nodeType() === 19 /* VariableDeclaration */) { + varSym = this.getSymbolForAST((forInStatement.lval).declarators.members[0]); + } + + var isStringOrNumber = varSym.type === this.semanticInfoChain.stringTypeSymbol || this.isAnyOrEquivalent(varSym.type); + + var isValidRHS = rhsType && (this.isAnyOrEquivalent(rhsType) || !rhsType.isPrimitive()); + + if (!isStringOrNumber) { + context.postError(this.unitPath, lval.minChar, lval.getLength(), TypeScript.DiagnosticCode.Variable_declarations_of_a_for_statement_must_be_of_types_string_or_any, null, enclosingDecl); + } + + if (!isValidRHS) { + context.postError(this.unitPath, forInStatement.obj.minChar, forInStatement.obj.getLength(), TypeScript.DiagnosticCode.The_right_hand_side_of_a_for_in_statement_must_be_of_type_any_an_object_type_or_a_type_parameter, null, enclosingDecl); + } + + this.resolveAST(forInStatement.body, false, enclosingDecl, context); + } + + this.setSymbolForAST(ast, this.semanticInfoChain.voidTypeSymbol, context); + return this.semanticInfoChain.voidTypeSymbol; + }; + + PullTypeResolver.prototype.resolveWhileStatement = function (ast, enclosingDecl, context) { + if (context.typeCheck()) { + this.resolveAST((ast).cond, false, enclosingDecl, context); + this.resolveAST((ast).body, false, enclosingDecl, context); + } + + this.setSymbolForAST(ast, this.semanticInfoChain.voidTypeSymbol, context); + return this.semanticInfoChain.voidTypeSymbol; + }; + + PullTypeResolver.prototype.resolveDoStatement = function (ast, enclosingDecl, context) { + if (context.typeCheck()) { + this.resolveAST((ast).cond, false, enclosingDecl, context); + this.resolveAST((ast).body, false, enclosingDecl, context); + } + + this.setSymbolForAST(ast, this.semanticInfoChain.voidTypeSymbol, context); + return this.semanticInfoChain.voidTypeSymbol; + }; + + PullTypeResolver.prototype.resolveIfStatement = function (ast, enclosingDecl, context) { + if (context.typeCheck()) { + this.resolveAST((ast).cond, false, enclosingDecl, context); + this.resolveAST((ast).thenBod, false, enclosingDecl, context); + this.resolveAST((ast).elseBod, false, enclosingDecl, context); + } + + this.setSymbolForAST(ast, this.semanticInfoChain.voidTypeSymbol, context); + return this.semanticInfoChain.voidTypeSymbol; + }; + + PullTypeResolver.prototype.resolveBlock = function (ast, enclosingDecl, context) { + if (context.typeCheck()) { + this.resolveAST((ast).statements, false, enclosingDecl, context); + } + + return this.semanticInfoChain.voidTypeSymbol; + }; + + PullTypeResolver.prototype.resolveVariableStatement = function (ast, enclosingDecl, context) { + if (context.typeCheck()) { + this.resolveAST((ast).declaration, false, enclosingDecl, context); + } + + return this.semanticInfoChain.voidTypeSymbol; + }; + + PullTypeResolver.prototype.resolveVariableDeclarationList = function (ast, enclosingDecl, context) { + if (context.typeCheck()) { + this.resolveAST((ast).declarators, false, enclosingDecl, context); + } + + return this.semanticInfoChain.voidTypeSymbol; + }; + + PullTypeResolver.prototype.resolveWithStatement = function (ast, enclosingDecl, context) { + if (context.typeCheck()) { + var withStatement = ast; + context.postError(this.unitPath, withStatement.expr.minChar, withStatement.expr.getLength(), TypeScript.DiagnosticCode.All_symbols_within_a_with_block_will_be_resolved_to_any, null, enclosingDecl); + } + + this.setSymbolForAST(ast, this.semanticInfoChain.voidTypeSymbol, context); + return this.semanticInfoChain.voidTypeSymbol; + }; + + PullTypeResolver.prototype.resolveTryStatement = function (ast, enclosingDecl, context) { + if (context.typeCheck()) { + var tryStatement = ast; + + this.resolveAST(tryStatement.tryBody, false, enclosingDecl, context); + this.resolveAST(tryStatement.catchClause, false, enclosingDecl, context); + this.resolveAST(tryStatement.finallyBody, false, enclosingDecl, context); + } + + this.setSymbolForAST(ast, this.semanticInfoChain.voidTypeSymbol, context); + return this.semanticInfoChain.voidTypeSymbol; + }; + + PullTypeResolver.prototype.resolveCatchClause = function (ast, enclosingDecl, context) { + if (context.typeCheck()) { + this.resolveAST((ast).body, false, this.getDeclForAST(ast), context); + } + + this.setSymbolForAST(ast, this.semanticInfoChain.voidTypeSymbol, context); + return this.semanticInfoChain.voidTypeSymbol; + }; + + PullTypeResolver.prototype.resolveReturnStatement = function (ast, inContextuallyTypedAssignment, enclosingDecl, context) { + var parentDecl = enclosingDecl; + var returnAST = ast; + var returnExpr = returnAST.returnExpression; + + while (parentDecl) { + if (parentDecl.kind & TypeScript.PullElementKind.SomeFunction) { + parentDecl.setFlag(4194304 /* HasReturnStatement */); + break; + } + + parentDecl = parentDecl.getParentDecl(); + } + + var inContextuallyTypedAssignment = false; + var enclosingDeclAST; + + if (enclosingDecl.kind & TypeScript.PullElementKind.SomeFunction) { + enclosingDeclAST = this.getASTForDecl(enclosingDecl); + if (enclosingDeclAST.returnTypeAnnotation) { + var returnTypeAnnotationSymbol = this.resolveTypeReference(enclosingDeclAST.returnTypeAnnotation, enclosingDecl, context); + if (returnTypeAnnotationSymbol) { + inContextuallyTypedAssignment = true; + context.pushContextualType(returnTypeAnnotationSymbol, context.inProvisionalResolution(), null); + } + } else { + var currentContextualType = context.getContextualType(); + if (currentContextualType && currentContextualType.isFunction()) { + var currentContextualTypeSignatureSymbol = currentContextualType.getDeclarations()[0].getSignatureSymbol(); + var currentContextualTypeReturnTypeSymbol = currentContextualTypeSignatureSymbol.returnType; + if (currentContextualTypeReturnTypeSymbol) { + inContextuallyTypedAssignment = true; + context.pushContextualType(currentContextualTypeReturnTypeSymbol, context.inProvisionalResolution(), null); + } + } + } + } + + var returnType = returnExpr ? this.resolveAST(returnExpr, inContextuallyTypedAssignment, enclosingDecl, context).type : this.semanticInfoChain.voidTypeSymbol; + + if (inContextuallyTypedAssignment) { + context.popContextualType(); + } + + if (context.typeCheck() && returnExpr) { + if (enclosingDecl.kind === 524288 /* SetAccessor */ && returnExpr) { + context.postError(this.unitPath, returnExpr.minChar, returnExpr.getLength(), TypeScript.DiagnosticCode.Setters_cannot_return_a_value, null, enclosingDecl); + } + + if (enclosingDecl.kind & TypeScript.PullElementKind.SomeFunction) { + enclosingDeclAST = this.getASTForDecl(enclosingDecl); + + if (enclosingDeclAST.returnTypeAnnotation) { + var signatureSymbol = enclosingDecl.getSignatureSymbol(); + var sigReturnType = signatureSymbol.returnType; + + if (returnType && sigReturnType) { + var comparisonInfo = new TypeComparisonInfo(); + var upperBound = null; + + if (returnType.isTypeParameter()) { + upperBound = (returnType).getConstraint(); + + if (upperBound) { + returnType = upperBound; + } + } + + if (sigReturnType.isTypeParameter()) { + upperBound = (sigReturnType).getConstraint(); + + if (upperBound) { + sigReturnType = upperBound; + } + } + + if (!returnType.isResolved) { + this.resolveDeclaredSymbol(returnType, enclosingDecl, context); + } + + if (!sigReturnType.isResolved) { + this.resolveDeclaredSymbol(sigReturnType, enclosingDecl, context); + } + + var isAssignable = this.sourceIsAssignableToTarget(returnType, sigReturnType, context, comparisonInfo); + + if (!isAssignable) { + if (comparisonInfo.message) { + context.postError(this.unitPath, returnExpr.minChar, returnExpr.getLength(), TypeScript.DiagnosticCode.Cannot_convert_0_to_1_NL_2, [returnType.toString(), sigReturnType.toString(), comparisonInfo.message], enclosingDecl); + } else { + context.postError(this.unitPath, returnExpr.minChar, returnExpr.getLength(), TypeScript.DiagnosticCode.Cannot_convert_0_to_1, [returnType.toString(), sigReturnType.toString()], enclosingDecl); + } + } + } + } + } + } + + this.setSymbolForAST(ast, returnType, context); + + return returnType; + }; + + PullTypeResolver.prototype.resolveSwitchStatement = function (ast, enclosingDecl, context) { + if (context.typeCheck()) { + var switchStatement = ast; + + var expressionType = this.resolveAST(switchStatement.val, false, enclosingDecl, context).type; + + this.resolveAST(switchStatement.caseList, false, enclosingDecl, context); + this.resolveAST(switchStatement.defaultCase, false, enclosingDecl, context); + + if (switchStatement.caseList && switchStatement.caseList.members) { + for (var i = 0, n = switchStatement.caseList.members.length; i < n; i++) { + var caseClause = switchStatement.caseList.members[i]; + if (caseClause !== switchStatement.defaultCase) { + var caseClauseExpressionType = this.resolveAST(caseClause.expr, false, enclosingDecl, context).type; + + var comparisonInfo = new TypeComparisonInfo(); + if (!this.sourceIsAssignableToTarget(expressionType, caseClauseExpressionType, context, comparisonInfo) && !this.sourceIsAssignableToTarget(caseClauseExpressionType, expressionType, context, comparisonInfo)) { + if (comparisonInfo.message) { + context.postError(this.unitPath, caseClause.expr.minChar, caseClause.expr.getLength(), TypeScript.DiagnosticCode.Cannot_convert_0_to_1_NL_2, [caseClauseExpressionType.toString(), expressionType.toString(), comparisonInfo.message], enclosingDecl); + } else { + context.postError(this.unitPath, caseClause.expr.minChar, caseClause.expr.getLength(), TypeScript.DiagnosticCode.Cannot_convert_0_to_1, [caseClauseExpressionType.toString(), expressionType.toString()], enclosingDecl); + } + } + } + } + } + } + + this.setSymbolForAST(ast, this.semanticInfoChain.voidTypeSymbol, context); + return this.semanticInfoChain.voidTypeSymbol; + }; + + PullTypeResolver.prototype.resolveCaseClause = function (ast, enclosingDecl, context) { + if (context.typeCheck()) { + this.resolveAST((ast).expr, false, enclosingDecl, context); + this.resolveAST((ast).body, false, enclosingDecl, context); + } + + this.setSymbolForAST(ast, this.semanticInfoChain.voidTypeSymbol, context); + return this.semanticInfoChain.voidTypeSymbol; + }; + + PullTypeResolver.prototype.resolveLabeledStatement = function (ast, enclosingDecl, context) { + return this.resolveAST((ast).statement, false, enclosingDecl, context); + }; + + PullTypeResolver.prototype.resolveAST = function (ast, inContextuallyTypedAssignment, enclosingDecl, context, specializingSignature) { + if (typeof specializingSignature === "undefined") { specializingSignature = false; } + TypeScript.globalSemanticInfoChain = this.semanticInfoChain; + + if (TypeScript.globalBinder) { + TypeScript.globalBinder.semanticInfoChain = this.semanticInfoChain; + } + + if (!ast) { + return; + } + + var symbol = specializingSignature ? null : this.semanticInfoChain.getSymbolForAST(ast, this.unitPath); + + if (symbol && symbol.type && (symbol.isResolved)) { + return symbol; + } + + var nodeType = ast.nodeType(); + + switch (nodeType) { + case 1 /* List */: + return this.resolveList(ast, enclosingDecl, context); + + case 2 /* Script */: + return null; + + case 16 /* ModuleDeclaration */: + return this.resolveModuleDeclaration(ast, context); + + case 15 /* InterfaceDeclaration */: + return this.resolveInterfaceDeclaration(ast, context); + + case 14 /* ClassDeclaration */: + return this.resolveClassDeclaration(ast, context); + + case 19 /* VariableDeclaration */: + return this.resolveVariableDeclarationList(ast, enclosingDecl, context); + + case 18 /* VariableDeclarator */: + case 20 /* Parameter */: + return this.resolveVariableDeclaration(ast, context, enclosingDecl); + + case 9 /* TypeParameter */: + return this.resolveTypeParameterDeclaration(ast, context); + + case 17 /* ImportDeclaration */: + return this.resolveImportDeclaration(ast, context); + + case 23 /* ObjectLiteralExpression */: + return this.resolveObjectLiteralExpression(ast, inContextuallyTypedAssignment, enclosingDecl, context); + + case 10 /* GenericType */: + return this.resolveGenericTypeReference(ast, enclosingDecl, context); + + case 21 /* Name */: + if (context.resolvingTypeReference) { + return this.resolveTypeNameExpression(ast, enclosingDecl, context); + } else { + return this.resolveNameExpression(ast, enclosingDecl, context); + } + + case 33 /* MemberAccessExpression */: + if (context.resolvingTypeReference) { + return this.resolveDottedTypeNameExpression(ast, enclosingDecl, context); + } else { + return this.resolveDottedNameExpression(ast, enclosingDecl, context); + } + + case 10 /* GenericType */: + return this.resolveGenericTypeReference(ast, enclosingDecl, context); + + case 13 /* FunctionDeclaration */: { + var funcDecl = ast; + + if (funcDecl.isGetAccessor()) { + return this.resolveGetAccessorDeclaration(funcDecl, context); + } else if (funcDecl.isSetAccessor()) { + return this.resolveSetAccessorDeclaration(funcDecl, context); + } else if (inContextuallyTypedAssignment || (funcDecl.getFunctionFlags() & 8192 /* IsFunctionExpression */) || (funcDecl.getFunctionFlags() & 2048 /* IsFatArrowFunction */) || (funcDecl.getFunctionFlags() & 16384 /* IsFunctionProperty */)) { + return this.resolveFunctionExpression(funcDecl, inContextuallyTypedAssignment, enclosingDecl, context); + } else { + return this.resolveFunctionDeclaration(funcDecl, context); + } + } + + case 18 /* VariableDeclarator */: + case 20 /* Parameter */: + return this.resolveVariableDeclaration(ast, context, enclosingDecl); + + case 9 /* TypeParameter */: + return this.resolveTypeParameterDeclaration(ast, context); + + case 17 /* ImportDeclaration */: + return this.resolveImportDeclaration(ast, context); + + case 23 /* ObjectLiteralExpression */: + return this.resolveObjectLiteralExpression(ast, inContextuallyTypedAssignment, enclosingDecl, context); + + case 10 /* GenericType */: + return this.resolveGenericTypeReference(ast, enclosingDecl, context); + + case 21 /* Name */: + if (context.resolvingTypeReference) { + return this.resolveTypeNameExpression(ast, enclosingDecl, context); + } else { + return this.resolveNameExpression(ast, enclosingDecl, context); + } + + case 33 /* MemberAccessExpression */: + if (context.resolvingTypeReference) { + return this.resolveDottedTypeNameExpression(ast, enclosingDecl, context); + } else { + return this.resolveDottedNameExpression(ast, enclosingDecl, context); + } + + case 10 /* GenericType */: + return this.resolveGenericTypeReference(ast, enclosingDecl, context); + + case 13 /* FunctionDeclaration */: { + var funcDecl = ast; + + if (funcDecl.isGetAccessor()) { + return this.resolveGetAccessorDeclaration(funcDecl, context); + } else if (funcDecl.isSetAccessor()) { + return this.resolveSetAccessorDeclaration(funcDecl, context); + } else if (inContextuallyTypedAssignment || (funcDecl.getFunctionFlags() & 8192 /* IsFunctionExpression */) || (funcDecl.getFunctionFlags() & 2048 /* IsFatArrowFunction */) || (funcDecl.getFunctionFlags() & 16384 /* IsFunctionProperty */)) { + return this.resolveFunctionExpression(funcDecl, inContextuallyTypedAssignment, enclosingDecl, context); + } else { + return this.resolveFunctionDeclaration(funcDecl, context); + } + } + + case 22 /* ArrayLiteralExpression */: + return this.resolveArrayLiteralExpression(ast, inContextuallyTypedAssignment, enclosingDecl, context); + + case 30 /* ThisExpression */: + return this.resolveThisExpression(ast, enclosingDecl, context); + + case 31 /* SuperExpression */: + return this.resolveSuperExpression(ast, enclosingDecl, context); + + case 37 /* InvocationExpression */: + return this.resolveInvocationExpression(ast, inContextuallyTypedAssignment, enclosingDecl, context); + + case 38 /* ObjectCreationExpression */: + return this.resolveObjectCreationExpression(ast, inContextuallyTypedAssignment, enclosingDecl, context); + + case 79 /* CastExpression */: + return this.resolveTypeAssertionExpression(ast, inContextuallyTypedAssignment, enclosingDecl, context); + + case 11 /* TypeRef */: + return this.resolveTypeReference(ast, enclosingDecl, context); + + case 88 /* ExportAssignment */: + return this.resolveExportAssignmentStatement(ast, enclosingDecl, context); + + case 7 /* NumericLiteral */: + return this.semanticInfoChain.numberTypeSymbol; + case 5 /* StringLiteral */: + return this.semanticInfoChain.stringTypeSymbol; + case 8 /* NullLiteral */: + return this.semanticInfoChain.nullTypeSymbol; + case 3 /* TrueLiteral */: + case 4 /* FalseLiteral */: + return this.semanticInfoChain.booleanTypeSymbol; + case 25 /* VoidExpression */: + return this.resolveVoidExpression(ast, enclosingDecl, context); + + case 39 /* AssignmentExpression */: + return this.resolveAssignmentStatement(ast, inContextuallyTypedAssignment, enclosingDecl, context); + + case 74 /* LogicalNotExpression */: + return this.resolveUnaryLogicalOperation(ast, enclosingDecl, context); + + case 58 /* NotEqualsWithTypeConversionExpression */: + case 57 /* EqualsWithTypeConversionExpression */: + case 59 /* EqualsExpression */: + case 60 /* NotEqualsExpression */: + case 61 /* LessThanExpression */: + case 62 /* LessThanOrEqualExpression */: + case 64 /* GreaterThanOrEqualExpression */: + case 63 /* GreaterThanExpression */: + return this.resolveLogicalOperation(ast, enclosingDecl, context); + + case 65 /* AddExpression */: + case 40 /* AddAssignmentExpression */: + return this.resolveBinaryAdditionOperation(ast, inContextuallyTypedAssignment, enclosingDecl, context); + + case 27 /* PlusExpression */: + case 28 /* NegateExpression */: + case 73 /* BitwiseNotExpression */: + case 77 /* PostIncrementExpression */: + case 75 /* PreIncrementExpression */: + case 78 /* PostDecrementExpression */: + case 76 /* PreDecrementExpression */: + return this.resolveUnaryArithmeticOperation(ast, enclosingDecl, context); + + case 66 /* SubtractExpression */: + case 67 /* MultiplyExpression */: + case 68 /* DivideExpression */: + case 69 /* ModuloExpression */: + case 54 /* BitwiseOrExpression */: + case 56 /* BitwiseAndExpression */: + case 70 /* LeftShiftExpression */: + case 71 /* SignedRightShiftExpression */: + case 72 /* UnsignedRightShiftExpression */: + case 55 /* BitwiseExclusiveOrExpression */: + case 46 /* ExclusiveOrAssignmentExpression */: + case 48 /* LeftShiftAssignmentExpression */: + case 49 /* SignedRightShiftAssignmentExpression */: + case 50 /* UnsignedRightShiftAssignmentExpression */: + case 41 /* SubtractAssignmentExpression */: + case 43 /* MultiplyAssignmentExpression */: + case 42 /* DivideAssignmentExpression */: + case 44 /* ModuloAssignmentExpression */: + case 47 /* OrAssignmentExpression */: + case 45 /* AndAssignmentExpression */: + return this.resolveBinaryArithmeticExpression(ast, enclosingDecl, context); + + case 36 /* ElementAccessExpression */: + return this.resolveIndexExpression(ast, inContextuallyTypedAssignment, enclosingDecl, context); + + case 52 /* LogicalOrExpression */: + return this.resolveLogicalOrExpression(ast, inContextuallyTypedAssignment, enclosingDecl, context); + + case 53 /* LogicalAndExpression */: + return this.resolveLogicalAndExpression(ast, inContextuallyTypedAssignment, enclosingDecl, context); + + case 35 /* TypeOfExpression */: + return this.resolveTypeOfExpression(ast, enclosingDecl, context); + + case 96 /* ThrowStatement */: + return this.resolveThrowStatement(ast, enclosingDecl, context); + + case 29 /* DeleteExpression */: + return this.resolveDeleteStatement(ast, enclosingDecl, context); + + case 51 /* ConditionalExpression */: + return this.resolveConditionalExpression(ast, enclosingDecl, context); + + case 6 /* RegularExpressionLiteral */: + return this.resolveRegularExpressionLiteral(); + + case 80 /* ParenthesizedExpression */: + return this.resolveParenthesizedExpression(ast, enclosingDecl, context); + + case 89 /* ExpressionStatement */: + return this.resolveExpressionStatement(ast, inContextuallyTypedAssignment, enclosingDecl, context); + + case 34 /* InstanceOfExpression */: + return this.resolveInstanceOfExpression(ast, enclosingDecl, context); + + case 26 /* CommaExpression */: + return this.resolveCommaExpression(ast, enclosingDecl, context); + + case 32 /* InExpression */: + return this.resolveInExpression(ast, enclosingDecl, context); + + case 91 /* ForStatement */: + return this.resolveForStatement(ast, enclosingDecl, context); + + case 90 /* ForInStatement */: + return this.resolveForInStatement(ast, enclosingDecl, context); + + case 99 /* WhileStatement */: + return this.resolveWhileStatement(ast, enclosingDecl, context); + + case 86 /* DoStatement */: + return this.resolveDoStatement(ast, enclosingDecl, context); + + case 92 /* IfStatement */: + return this.resolveIfStatement(ast, enclosingDecl, context); + + case 82 /* Block */: + return this.resolveBlock(ast, enclosingDecl, context); + + case 98 /* VariableStatement */: + return this.resolveVariableStatement(ast, enclosingDecl, context); + + case 100 /* WithStatement */: + return this.resolveWithStatement(ast, enclosingDecl, context); + + case 97 /* TryStatement */: + return this.resolveTryStatement(ast, enclosingDecl, context); + + case 102 /* CatchClause */: + return this.resolveCatchClause(ast, enclosingDecl, context); + + case 94 /* ReturnStatement */: + return this.resolveReturnStatement(ast, inContextuallyTypedAssignment, enclosingDecl, context); + + case 95 /* SwitchStatement */: + return this.resolveSwitchStatement(ast, enclosingDecl, context); + + case 101 /* CaseClause */: + return this.resolveCaseClause(ast, enclosingDecl, context); + + case 93 /* LabeledStatement */: + return this.resolveLabeledStatement(ast, enclosingDecl, context); + } + + return this.semanticInfoChain.anyTypeSymbol; + }; + + PullTypeResolver.prototype.resolveRegularExpressionLiteral = function () { + if (this.cachedRegExpInterfaceType()) { + return this.cachedRegExpInterfaceType(); + } else { + return this.semanticInfoChain.anyTypeSymbol; + } + }; + + PullTypeResolver.prototype.isNameOrMemberAccessExpression = function (ast) { + var checkAST = ast; + + while (checkAST) { + if (checkAST.nodeType() === 89 /* ExpressionStatement */) { + checkAST = (checkAST).expression; + } else if (checkAST.nodeType() === 80 /* ParenthesizedExpression */) { + checkAST = (checkAST).expression; + } else if (checkAST.nodeType() === 21 /* Name */) { + return true; + } else if (checkAST.nodeType() === 33 /* MemberAccessExpression */) { + return true; + } else { + return false; + } + } + }; + + PullTypeResolver.prototype.resolveNameSymbol = function (nameSymbol, context) { + if (nameSymbol && !context.canUseTypeSymbol && nameSymbol != this.semanticInfoChain.undefinedTypeSymbol && nameSymbol != this.semanticInfoChain.nullTypeSymbol && (nameSymbol.isPrimitive() || !(nameSymbol.kind & TypeScript.PullElementKind.SomeValue))) { + var valueSymbol = nameSymbol.isAlias() ? (nameSymbol).getExportAssignedValueSymbol() : null; + if (valueSymbol) { + nameSymbol = valueSymbol; + } else { + nameSymbol = null; + } + } + + return nameSymbol; + }; + + PullTypeResolver.prototype.resolveNameExpression = function (nameAST, enclosingDecl, context) { + var nameSymbol = this.getSymbolForAST(nameAST); + var foundCached = nameSymbol != null; + + if (!foundCached) { + nameSymbol = this.computeNameExpression(nameAST, enclosingDecl, context); + } + + if (!nameSymbol.isResolved) { + this.resolveDeclaredSymbol(nameSymbol, enclosingDecl, context); + } + + if (nameSymbol && (nameSymbol.type != this.semanticInfoChain.anyTypeSymbol || nameSymbol.hasFlag(16777216 /* IsAnnotatedWithAny */))) { + this.setSymbolForAST(nameAST, nameSymbol, context); + } + + return nameSymbol; + }; + + PullTypeResolver.prototype.computeNameExpression = function (nameAST, enclosingDecl, context) { + if (nameAST.isMissing()) { + return this.semanticInfoChain.anyTypeSymbol; + } + + var id = nameAST.text(); + + var declPath = enclosingDecl !== null ? TypeScript.getPathToDecl(enclosingDecl) : []; + + if (enclosingDecl && !declPath.length) { + declPath = [enclosingDecl]; + } + + var aliasSymbol = null; + var nameSymbol = this.getSymbolFromDeclPath(id, declPath, TypeScript.PullElementKind.SomeValue); + + if (!nameSymbol && id === "arguments" && enclosingDecl && (enclosingDecl.kind & TypeScript.PullElementKind.SomeFunction)) { + nameSymbol = this.cachedFunctionArgumentsSymbol; + + if (this.cachedIArgumentsInterfaceType() && !this.cachedIArgumentsInterfaceType().isResolved) { + this.resolveDeclaredSymbol(this.cachedIArgumentsInterfaceType(), enclosingDecl, context); + } + } + + if (!nameSymbol) { + nameSymbol = this.getSymbolFromDeclPath(id, declPath, 256 /* TypeAlias */); + + if (nameSymbol && !nameSymbol.isAlias()) { + nameSymbol = null; + } + } + + if (!nameSymbol) { + if (context.resolvingTypeNameAsNameExpression) { + return null; + } else { + context.postError(this.unitPath, nameAST.minChar, nameAST.getLength(), TypeScript.DiagnosticCode.Could_not_find_symbol_0, [nameAST.actualText], enclosingDecl); + return this.getNewErrorTypeSymbol(null, id); + } + } + + if (nameSymbol.isType() && nameSymbol.isAlias()) { + aliasSymbol = nameSymbol; + aliasSymbol.isUsedAsValue = true; + + if (!nameSymbol.isResolved) { + this.resolveDeclaredSymbol(nameSymbol, enclosingDecl, context); + } + + if (aliasSymbol.assignedValue) { + if (!aliasSymbol.assignedValue.isResolved) { + this.resolveDeclaredSymbol(aliasSymbol.assignedValue, enclosingDecl, context); + } + } else if (aliasSymbol.assignedContainer && !aliasSymbol.assignedContainer.isResolved) { + this.resolveDeclaredSymbol(aliasSymbol.assignedContainer, enclosingDecl, context); + } + + var exportAssignmentSymbol = (nameSymbol).getExportAssignedValueSymbol(); + + if (exportAssignmentSymbol) { + nameSymbol = exportAssignmentSymbol; + } else { + aliasSymbol = null; + } + } + + if (aliasSymbol) { + this.currentUnit.setAliasSymbolForAST(nameAST, aliasSymbol); + } + + return nameSymbol; + }; + + PullTypeResolver.prototype.resolveDottedNameExpression = function (dottedNameAST, enclosingDecl, context) { + var symbol = this.getSymbolForAST(dottedNameAST); + var foundCached = symbol != null; + + if (!foundCached) { + symbol = this.computeDottedNameExpressionSymbol(dottedNameAST, enclosingDecl, context); + } + + if (symbol && !symbol.isResolved) { + this.resolveDeclaredSymbol(symbol, enclosingDecl, context); + } + + if (symbol && (symbol.type != this.semanticInfoChain.anyTypeSymbol || symbol.hasFlag(16777216 /* IsAnnotatedWithAny */))) { + this.setSymbolForAST(dottedNameAST, symbol, context); + this.setSymbolForAST(dottedNameAST.operand2, symbol, context); + } + + return symbol; + }; + + PullTypeResolver.prototype.isPrototypeMember = function (dottedNameAST, enclosingDecl, context) { + var rhsName = (dottedNameAST.operand2).text(); + if (rhsName === "prototype") { + var prevCanUseTypeSymbol = context.canUseTypeSymbol; + context.canUseTypeSymbol = true; + var lhsType = this.resolveAST(dottedNameAST.operand1, false, enclosingDecl, context).type; + context.canUseTypeSymbol = prevCanUseTypeSymbol; + + if (lhsType) { + if (lhsType.isClass() || lhsType.isConstructor()) { + return true; + } else { + var classInstanceType = lhsType.getAssociatedContainerType(); + + if (classInstanceType && classInstanceType.isClass()) { + return true; + } + } + } + } + + return false; + }; + + PullTypeResolver.prototype.computeDottedNameExpressionSymbol = function (dottedNameAST, enclosingDecl, context) { + if ((dottedNameAST.operand2).isMissing()) { + return this.semanticInfoChain.anyTypeSymbol; + } + + var rhsName = (dottedNameAST.operand2).text(); + var prevCanUseTypeSymbol = context.canUseTypeSymbol; + context.canUseTypeSymbol = true; + var lhs = this.resolveAST(dottedNameAST.operand1, false, enclosingDecl, context); + context.canUseTypeSymbol = prevCanUseTypeSymbol; + var lhsType = lhs.type; + + if (lhs.isAlias()) { + (lhs).isUsedAsValue = true; + lhsType = (lhs).getExportAssignedTypeSymbol(); + } + + if (this.isAnyOrEquivalent(lhsType)) { + return lhsType; + } + + if (lhsType.isAlias()) { + lhsType = (lhsType).getExportAssignedTypeSymbol(); + } + + if (!lhsType) { + context.postError(this.unitPath, dottedNameAST.operand2.minChar, dottedNameAST.operand2.getLength(), TypeScript.DiagnosticCode.Could_not_find_enclosing_symbol_for_dotted_name_0, [(dottedNameAST.operand2).actualText], enclosingDecl); + return this.getNewErrorTypeSymbol(null); + } + + if ((lhsType === this.semanticInfoChain.numberTypeSymbol || (lhs.kind == 67108864 /* EnumMember */)) && this.cachedNumberInterfaceType()) { + lhsType = this.cachedNumberInterfaceType(); + } else if (lhsType === this.semanticInfoChain.stringTypeSymbol && this.cachedStringInterfaceType()) { + lhsType = this.cachedStringInterfaceType(); + } else if (lhsType === this.semanticInfoChain.booleanTypeSymbol && this.cachedBooleanInterfaceType()) { + lhsType = this.cachedBooleanInterfaceType(); + } + + if (!lhsType.isResolved) { + var potentiallySpecializedType = this.resolveDeclaredSymbol(lhsType, enclosingDecl, context); + + if (potentiallySpecializedType != lhsType) { + if (!lhs.isType()) { + context.setTypeInContext(lhs, potentiallySpecializedType); + } + + lhsType = potentiallySpecializedType; + } + } + + if (lhsType.isContainer() && !lhsType.isAlias()) { + var instanceSymbol = (lhsType).getInstanceSymbol(); + + if (instanceSymbol) { + lhsType = instanceSymbol.type; + } + } + + if (this.isPrototypeMember(dottedNameAST, enclosingDecl, context)) { + if (lhsType.isClass()) { + this.checkForStaticMemberAccess(dottedNameAST, lhsType, lhsType, enclosingDecl, context); + return lhsType; + } else { + var classInstanceType = lhsType.getAssociatedContainerType(); + + if (classInstanceType && classInstanceType.isClass()) { + this.checkForStaticMemberAccess(dottedNameAST, lhsType, classInstanceType, enclosingDecl, context); + return classInstanceType; + } + } + } + + if (lhsType.isTypeParameter()) { + lhsType = this.substituteUpperBoundForType(lhsType); + } + + var nameSymbol = null; + if (!(lhs.isType() && (lhs).isClass() && this.isNameOrMemberAccessExpression(dottedNameAST.operand1)) && !nameSymbol) { + nameSymbol = this.getMemberSymbol(rhsName, TypeScript.PullElementKind.SomeValue, lhsType); + nameSymbol = this.resolveNameSymbol(nameSymbol, context); + } + + if (!nameSymbol) { + if (lhsType.isClass()) { + var staticType = lhsType.getConstructorMethod().type; + + nameSymbol = this.getMemberSymbol(rhsName, TypeScript.PullElementKind.SomeValue, staticType); + + if (!nameSymbol) { + nameSymbol = this.getMemberSymbol(rhsName, TypeScript.PullElementKind.SomeValue, lhsType); + } + } else if ((lhsType.getCallSignatures().length || lhsType.getConstructSignatures().length) && this.cachedFunctionInterfaceType()) { + nameSymbol = this.getMemberSymbol(rhsName, TypeScript.PullElementKind.SomeValue, this.cachedFunctionInterfaceType()); + } else if (lhsType.isContainer()) { + var containerType = lhsType; + var associatedInstance = containerType.getInstanceSymbol(); + + if (associatedInstance) { + var instanceType = associatedInstance.type; + + nameSymbol = this.getMemberSymbol(rhsName, TypeScript.PullElementKind.SomeValue, instanceType); + } + } else { + var associatedType = lhsType.getAssociatedContainerType(); + + if (associatedType && !associatedType.isClass()) { + nameSymbol = this.getMemberSymbol(rhsName, TypeScript.PullElementKind.SomeValue, associatedType); + } + } + + nameSymbol = this.resolveNameSymbol(nameSymbol, context); + + if (!nameSymbol && !lhsType.isPrimitive() && this.cachedObjectInterfaceType()) { + nameSymbol = this.getMemberSymbol(rhsName, TypeScript.PullElementKind.SomeValue, this.cachedObjectInterfaceType()); + } + + if (!nameSymbol) { + context.postError(this.unitPath, dottedNameAST.operand2.minChar, dottedNameAST.operand2.getLength(), TypeScript.DiagnosticCode.The_property_0_does_not_exist_on_value_of_type_1, [(dottedNameAST.operand2).actualText, lhsType.toString(enclosingDecl ? enclosingDecl.getSymbol() : null)], enclosingDecl); + return this.getNewErrorTypeSymbol(null, rhsName); + } + } + + if (context.typeCheck()) { + this.checkForSuperMemberAccess(dottedNameAST, nameSymbol, enclosingDecl, context) || this.checkForPrivateMemberAccess(dottedNameAST, lhsType, nameSymbol, enclosingDecl, context) || this.checkForStaticMemberAccess(dottedNameAST, lhsType, nameSymbol, enclosingDecl, context); + } + + return nameSymbol; + }; + + PullTypeResolver.prototype.resolveTypeNameExpression = function (nameAST, enclosingDecl, context) { + var typeNameSymbol = this.getSymbolForAST(nameAST); + + if (!typeNameSymbol || !typeNameSymbol.isType()) { + typeNameSymbol = this.computeTypeNameExpression(nameAST, enclosingDecl, context); + this.setSymbolForAST(nameAST, typeNameSymbol, context); + } + + if (!typeNameSymbol.isResolved) { + var savedResolvingNamespaceMemberAccess = context.resolvingNamespaceMemberAccess; + context.resolvingNamespaceMemberAccess = false; + this.resolveDeclaredSymbol(typeNameSymbol, enclosingDecl, context); + context.resolvingNamespaceMemberAccess = savedResolvingNamespaceMemberAccess; + } + + if (typeNameSymbol && !(typeNameSymbol.isTypeParameter() && (typeNameSymbol).isFunctionTypeParameter() && context.isSpecializingSignatureAtCallSite && !context.isSpecializingConstructorMethod)) { + var substitution = context.findSpecializationForType(typeNameSymbol); + + if (typeNameSymbol.isTypeParameter() && (substitution != typeNameSymbol)) { + if (TypeScript.shouldSpecializeTypeParameterForTypeParameter(substitution, typeNameSymbol)) { + typeNameSymbol = substitution; + } + } + } + + return typeNameSymbol; + }; + + PullTypeResolver.prototype.computeTypeNameExpression = function (nameAST, enclosingDecl, context) { + if (nameAST.isMissing()) { + return this.semanticInfoChain.anyTypeSymbol; + } + + var id = nameAST.text(); + + if (id === "any") { + return this.semanticInfoChain.anyTypeSymbol; + } else if (id === "string") { + return this.semanticInfoChain.stringTypeSymbol; + } else if (id === "number") { + return this.semanticInfoChain.numberTypeSymbol; + } else if (id === "boolean") { + return this.semanticInfoChain.booleanTypeSymbol; + } else if (id === "void") { + return this.semanticInfoChain.voidTypeSymbol; + } else { + var declPath = enclosingDecl !== null ? TypeScript.getPathToDecl(enclosingDecl) : []; + + if (enclosingDecl && !declPath.length) { + declPath = [enclosingDecl]; + } + + var kindToCheckFirst = context.resolvingNamespaceMemberAccess ? TypeScript.PullElementKind.SomeContainer : TypeScript.PullElementKind.SomeType; + var kindToCheckSecond = context.resolvingNamespaceMemberAccess ? TypeScript.PullElementKind.SomeType : TypeScript.PullElementKind.SomeContainer; + + var typeNameSymbol = this.getSymbolFromDeclPath(id, declPath, kindToCheckFirst); + + if (!typeNameSymbol) { + typeNameSymbol = this.getSymbolFromDeclPath(id, declPath, kindToCheckSecond); + } + + if (!typeNameSymbol) { + context.postError(this.unitPath, nameAST.minChar, nameAST.getLength(), TypeScript.DiagnosticCode.Could_not_find_symbol_0, [nameAST.actualText], enclosingDecl); + return this.getNewErrorTypeSymbol(null, id); + } + + var typeNameSymbolAlias = null; + if (typeNameSymbol.isAlias()) { + typeNameSymbolAlias = typeNameSymbol; + if (!typeNameSymbol.isResolved) { + var savedResolvingNamespaceMemberAccess = context.resolvingNamespaceMemberAccess; + context.resolvingNamespaceMemberAccess = false; + this.resolveDeclaredSymbol(typeNameSymbol, enclosingDecl, context); + context.resolvingNamespaceMemberAccess = savedResolvingNamespaceMemberAccess; + } + + var aliasedType = typeNameSymbolAlias.getExportAssignedTypeSymbol(); + + if (aliasedType && !aliasedType.isResolved) { + this.resolveDeclaredSymbol(aliasedType, enclosingDecl, context); + } + } + + if (typeNameSymbol.isTypeParameter()) { + if (enclosingDecl && (enclosingDecl.kind & TypeScript.PullElementKind.SomeFunction) && (enclosingDecl.flags & 16 /* Static */)) { + var parentDecl = typeNameSymbol.getDeclarations()[0].getParentDecl(); + + if (parentDecl.kind == 8 /* Class */) { + context.postError(this.unitPath, nameAST.minChar, nameAST.getLength(), TypeScript.DiagnosticCode.Static_methods_cannot_reference_class_type_parameters, null, enclosingDecl); + return this.getNewErrorTypeSymbol(null); + } + } + } + } + + return typeNameSymbol; + }; + + PullTypeResolver.prototype.resolveGenericTypeReference = function (genericTypeAST, enclosingDecl, context) { + var savedResolvingTypeReference = context.resolvingTypeReference; + context.resolvingTypeReference = true; + var genericTypeSymbol = this.resolveAST(genericTypeAST.name, false, enclosingDecl, context).type; + context.resolvingTypeReference = savedResolvingTypeReference; + + if (genericTypeSymbol.isError()) { + return genericTypeSymbol; + } + + if (!genericTypeSymbol.inResolution && !genericTypeSymbol.isResolved) { + this.resolveDeclaredSymbol(genericTypeSymbol, enclosingDecl, context); + } + + if (genericTypeSymbol.isAlias()) { + genericTypeSymbol = (genericTypeSymbol).getExportAssignedTypeSymbol(); + } + + var typeArgs = []; + + if (!context.isResolvingTypeArguments(genericTypeAST)) { + context.startResolvingTypeArguments(genericTypeAST); + var savedIsResolvingClassExtendedType = context.isResolvingClassExtendedType; + context.isResolvingClassExtendedType = false; + + if (genericTypeAST.typeArguments && genericTypeAST.typeArguments.members.length) { + for (var i = 0; i < genericTypeAST.typeArguments.members.length; i++) { + var typeArg = this.resolveTypeReference(genericTypeAST.typeArguments.members[i], enclosingDecl, context); + + if (this.genericTypeIsUsedWithoutRequiredTypeArguments(typeArg, genericTypeAST.typeArguments.members[i], context)) { + context.postError(this.unitPath, genericTypeAST.typeArguments.members[i].minChar, genericTypeAST.typeArguments.members[i].getLength(), TypeScript.DiagnosticCode.Generic_type_references_must_include_all_type_arguments, null, enclosingDecl); + typeArg = this.specializeTypeToAny(typeArg, enclosingDecl, context); + } + + if (!(typeArg.isTypeParameter() && (typeArg).isFunctionTypeParameter() && context.isSpecializingSignatureAtCallSite && !context.isSpecializingConstructorMethod)) { + typeArgs[i] = context.findSpecializationForType(typeArg); + } else { + typeArgs[i] = typeArg; + } + } + } + context.isResolvingClassExtendedType = savedIsResolvingClassExtendedType; + context.doneResolvingTypeArguments(); + } + + var typeParameters = genericTypeSymbol.getTypeParameters(); + + if (typeArgs.length && typeArgs.length != typeParameters.length) { + context.postError(this.unitPath, genericTypeAST.minChar, genericTypeAST.getLength(), TypeScript.DiagnosticCode.Generic_type_0_requires_1_type_argument_s, [genericTypeSymbol.toString(), genericTypeSymbol.getTypeParameters().length], enclosingDecl); + return this.getNewErrorTypeSymbol(null); + } + + var specializedSymbol = TypeScript.specializeType(genericTypeSymbol, typeArgs, this, enclosingDecl, context, genericTypeAST); + + var typeConstraint = null; + var upperBound = null; + + for (var iArg = 0; (iArg < typeArgs.length) && (iArg < typeParameters.length); iArg++) { + typeArg = typeArgs[iArg]; + typeConstraint = typeParameters[iArg].getConstraint(); + + if (typeConstraint) { + if (typeConstraint.isTypeParameter()) { + for (var j = 0; j < typeParameters.length && j < typeArgs.length; j++) { + if (typeParameters[j] == typeConstraint) { + typeConstraint = typeArgs[j]; + } + } + } + + if (typeArg.isTypeParameter()) { + upperBound = (typeArg).getConstraint(); + + if (upperBound) { + typeArg = upperBound; + } + } + + if (typeArg.inResolution) { + return specializedSymbol; + } + if (!this.sourceIsAssignableToTarget(typeArg, typeConstraint, context)) { + context.postError(this.unitPath, genericTypeAST.minChar, genericTypeAST.getLength(), TypeScript.DiagnosticCode.Type_0_does_not_satisfy_the_constraint_1_for_type_parameter_2, [typeArg.toString(null, true), typeConstraint.toString(null, true), typeParameters[iArg].toString(null, true)], enclosingDecl); + } + } + } + + return specializedSymbol; + }; + + PullTypeResolver.prototype.resolveDottedTypeNameExpression = function (dottedNameAST, enclosingDecl, context) { + var symbol = this.getSymbolForAST(dottedNameAST); + if (!symbol) { + symbol = this.computeDottedTypeNameExpression(dottedNameAST, enclosingDecl, context); + this.setSymbolForAST(dottedNameAST, symbol, context); + } + + if (!symbol.isResolved) { + this.resolveDeclaredSymbol(symbol, enclosingDecl, context); + } + + return symbol; + }; + + PullTypeResolver.prototype.computeDottedTypeNameExpression = function (dottedNameAST, enclosingDecl, context) { + if ((dottedNameAST.operand2).isMissing()) { + return this.semanticInfoChain.anyTypeSymbol; + } + + var rhsName = (dottedNameAST.operand2).text(); + + var savedResolvingTypeReference = context.resolvingTypeReference; + var savedResolvingNamespaceMemberAccess = context.resolvingNamespaceMemberAccess; + context.resolvingNamespaceMemberAccess = true; + context.resolvingTypeReference = true; + var lhs = this.resolveAST(dottedNameAST.operand1, false, enclosingDecl, context); + context.resolvingTypeReference = savedResolvingTypeReference; + context.resolvingNamespaceMemberAccess = savedResolvingNamespaceMemberAccess; + + var lhsType = lhs.isAlias() ? (lhs).getExportAssignedTypeSymbol() : lhs.type; + + if (context.isResolvingClassExtendedType) { + if (lhs.isAlias()) { + (lhs).isUsedAsValue = true; + } + } + + if (this.isAnyOrEquivalent(lhsType)) { + return lhsType; + } + + if (!lhsType) { + context.postError(this.unitPath, dottedNameAST.operand2.minChar, dottedNameAST.operand2.getLength(), TypeScript.DiagnosticCode.Could_not_find_enclosing_symbol_for_dotted_name_0, [(dottedNameAST.operand2).actualText], enclosingDecl); + return this.getNewErrorTypeSymbol(null); + } + + var memberKind = context.resolvingNamespaceMemberAccess ? TypeScript.PullElementKind.SomeContainer : TypeScript.PullElementKind.SomeType; + var childTypeSymbol = this.getMemberSymbol(rhsName, memberKind, lhsType); + + if (!childTypeSymbol && lhsType.isContainer()) { + var exportedContainer = (lhsType).getExportAssignedContainerSymbol(); + + if (exportedContainer) { + childTypeSymbol = this.getMemberSymbol(rhsName, memberKind, exportedContainer); + } + } + + if (!childTypeSymbol && enclosingDecl) { + var parentDecl = enclosingDecl; + + while (parentDecl) { + if (parentDecl.kind & TypeScript.PullElementKind.SomeContainer) { + break; + } + + parentDecl = parentDecl.getParentDecl(); + } + + if (parentDecl) { + var enclosingSymbolType = parentDecl.getSymbol().type; + + if (enclosingSymbolType === lhsType) { + childTypeSymbol = this.getMemberSymbol(rhsName, memberKind, lhsType); + } + } + } + + if (!childTypeSymbol) { + context.postError(this.unitPath, dottedNameAST.operand2.minChar, dottedNameAST.operand2.getLength(), TypeScript.DiagnosticCode.The_property_0_does_not_exist_on_value_of_type_1, [(dottedNameAST.operand2).actualText, lhsType.toString(enclosingDecl ? enclosingDecl.getSymbol() : null)], enclosingDecl); + return this.getNewErrorTypeSymbol(null, rhsName); + } + + return childTypeSymbol; + }; + + PullTypeResolver.prototype.resolveFunctionExpression = function (funcDeclAST, inContextuallyTypedAssignment, enclosingDecl, context) { + var _this = this; + var funcDeclSymbol = null; + var functionDecl = this.getDeclForAST(funcDeclAST); + + if (functionDecl && functionDecl.hasSymbol()) { + funcDeclSymbol = functionDecl.getSymbol(); + if (funcDeclSymbol.isResolved) { + return funcDeclSymbol; + } + } + + var shouldContextuallyType = inContextuallyTypedAssignment; + + var assigningFunctionTypeSymbol = null; + var assigningFunctionSignature = null; + + if (funcDeclAST.returnTypeAnnotation) { + shouldContextuallyType = false; + } + + if (shouldContextuallyType && funcDeclAST.arguments) { + for (var i = 0; i < funcDeclAST.arguments.members.length; i++) { + var parameter = funcDeclAST.arguments.members[i]; + if (parameter.typeExpr) { + shouldContextuallyType = false; + break; + } + } + } + + if (shouldContextuallyType) { + assigningFunctionTypeSymbol = context.getContextualType(); + + if (assigningFunctionTypeSymbol) { + this.resolveDeclaredSymbol(assigningFunctionTypeSymbol, enclosingDecl, context); + + if (assigningFunctionTypeSymbol) { + assigningFunctionSignature = assigningFunctionTypeSymbol.getCallSignatures()[0]; + } + } + } + + if (!functionDecl) { + var semanticInfo = this.semanticInfoChain.getUnit(this.unitPath); + var declCollectionContext = new TypeScript.DeclCollectionContext(semanticInfo, this.unitPath); + + if (enclosingDecl) { + declCollectionContext.pushParent(enclosingDecl); + } + + TypeScript.getAstWalkerFactory().walk(funcDeclAST, TypeScript.preCollectDecls, TypeScript.postCollectDecls, null, declCollectionContext); + + functionDecl = this.getDeclForAST(funcDeclAST); + this.currentUnit.addSynthesizedDecl(functionDecl); + + var binder = new TypeScript.PullSymbolBinder(this.semanticInfoChain); + binder.setUnit(this.unitPath); + binder.bindFunctionExpressionToPullSymbol(functionDecl); + } + + funcDeclSymbol = functionDecl.getSymbol(); + var funcDeclType = funcDeclSymbol.type; + var signature = funcDeclType.getCallSignatures()[0]; + funcDeclSymbol.startResolving(); + + if (funcDeclAST.arguments) { + var contextParams = []; + + if (assigningFunctionSignature) { + contextParams = assigningFunctionSignature.parameters; + } + + var contextualParametersCount = contextParams.length; + for (var i = 0, n = funcDeclAST.arguments.members.length; i < n; i++) { + var actualParameter = funcDeclAST.arguments.members[i]; + + var actualParameterIsVarArgParameter = funcDeclAST.variableArgList && i === n - 1; + var correspondingContextualParameter = null; + var contextualParameterType = null; + + if (i < contextualParametersCount) { + correspondingContextualParameter = contextParams[i]; + } else if (contextualParametersCount && contextParams[contextualParametersCount - 1].isVarArg) { + correspondingContextualParameter = contextParams[contextualParametersCount - 1]; + } + + if (correspondingContextualParameter) { + if (correspondingContextualParameter.isVarArg === actualParameterIsVarArgParameter) { + contextualParameterType = correspondingContextualParameter.type; + } else if (correspondingContextualParameter.isVarArg) { + contextualParameterType = correspondingContextualParameter.type.getElementType(); + } + } + + this.resolveFunctionExpressionParameter(actualParameter, contextualParameterType, functionDecl, context); + } + } + + if (funcDeclAST.returnTypeAnnotation) { + var returnTypeSymbol = this.resolveTypeReference(funcDeclAST.returnTypeAnnotation, functionDecl, context); + + signature.returnType = returnTypeSymbol; + } else { + if (assigningFunctionSignature) { + var returnType = assigningFunctionSignature.returnType; + + if (returnType) { + context.pushContextualType(returnType, context.inProvisionalResolution(), null); + + this.resolveFunctionBodyReturnTypes(funcDeclAST, signature, true, functionDecl, context); + context.popContextualType(); + } else { + signature.returnType = this.semanticInfoChain.anyTypeSymbol; + + if (this.compilationSettings.noImplicitAny && !context.isInInvocationExpression) { + var functionExpressionName = (functionDecl).getFunctionExpressionName(); + + if (functionExpressionName != "") { + context.postError(this.unitPath, funcDeclAST.minChar, funcDeclAST.getLength(), TypeScript.DiagnosticCode._0_which_lacks_return_type_annotation_implicitly_has_an_any_return_type, [functionExpressionName], functionDecl); + } else { + context.postError(this.unitPath, funcDeclAST.minChar, funcDeclAST.getLength(), TypeScript.DiagnosticCode.Function_expression_which_lacks_return_type_annotation_implicitly_has_an_any_return_type, [], functionDecl); + } + } + } + } else { + this.resolveFunctionBodyReturnTypes(funcDeclAST, signature, false, functionDecl, context); + } + } + + funcDeclSymbol.type = funcDeclType; + funcDeclSymbol.setResolved(); + + if (context.typeCheck()) { + PullTypeResolver.typeCheckCallBacks.push(function () { + _this.setUnitPath(functionDecl.getScriptName()); + _this.seenSuperConstructorCall = false; + + _this.resolveAST(funcDeclAST.block, false, functionDecl, context); + + _this.validateVariableDeclarationGroups(functionDecl, context); + + var hasReturn = (functionDecl.flags & (2048 /* Signature */ | 4194304 /* HasReturnStatement */)) != 0; + + if (funcDeclAST.block && funcDeclAST.returnTypeAnnotation != null && !hasReturn) { + var isVoidOrAny = _this.isAnyOrEquivalent(returnTypeSymbol) || returnTypeSymbol === _this.semanticInfoChain.voidTypeSymbol; + + if (!isVoidOrAny && !(funcDeclAST.block.statements.members.length > 0 && funcDeclAST.block.statements.members[0].nodeType() === 96 /* ThrowStatement */)) { + var funcName = functionDecl.getDisplayName(); + funcName = funcName ? "'" + funcName + "'" : "expression"; + + context.postError(_this.unitPath, funcDeclAST.returnTypeAnnotation.minChar, funcDeclAST.returnTypeAnnotation.getLength(), TypeScript.DiagnosticCode.Function_0_declared_a_non_void_return_type_but_has_no_return_expression, [funcName], enclosingDecl); + } + } + + _this.typeCheckFunctionOverloads(funcDeclAST, context); + }); + } + + return funcDeclSymbol; + }; + + PullTypeResolver.prototype.resolveThisExpression = function (ast, enclosingDecl, context) { + var symbol = this.getSymbolForAST(ast); + + if (!symbol) { + symbol = this.computeThisExpressionSymbol(ast, enclosingDecl, context); + this.setSymbolForAST(ast, symbol, context); + } + + this.checkForThisOrSuperCaptureInArrowFunction(ast, enclosingDecl); + + return symbol; + }; + + PullTypeResolver.prototype.computeThisExpressionSymbol = function (ast, enclosingDecl, context) { + if (enclosingDecl) { + var enclosingDeclKind = enclosingDecl.kind; + var diagnostics; + var thisTypeSymbol = this.semanticInfoChain.anyTypeSymbol; + var classDecl = null; + + if (!(enclosingDeclKind & (TypeScript.PullElementKind.SomeFunction | 1 /* Script */ | TypeScript.PullElementKind.SomeBlock | 8 /* Class */))) { + thisTypeSymbol = this.getNewErrorTypeSymbol(null); + } else { + var declPath = TypeScript.getPathToDecl(enclosingDecl); + + if (declPath.length) { + var isStaticContext = false; + for (var i = declPath.length - 1; i >= 0; i--) { + var decl = declPath[i]; + var declKind = decl.kind; + var declFlags = decl.flags; + + if (declFlags & 16 /* Static */) { + isStaticContext = true; + } else if (declKind === 131072 /* FunctionExpression */ && !TypeScript.hasFlag(declFlags, 8192 /* FatArrow */)) { + break; + } else if (declKind === 16384 /* Function */) { + break; + } else if (declKind === 8 /* Class */) { + if (context.isInStaticInitializer) { + thisTypeSymbol = this.getNewErrorTypeSymbol(null); + } else { + var classSymbol = decl.getSymbol(); + classDecl = decl; + if (isStaticContext) { + var constructorSymbol = classSymbol.getConstructorMethod(); + thisTypeSymbol = constructorSymbol.type; + } else { + thisTypeSymbol = classSymbol; + } + } + break; + } + } + } + } + } + + if (context.typeCheck()) { + var thisExpressionAST = ast; + var enclosingNonLambdaDecl = this.getEnclosingNonLambdaDecl(enclosingDecl); + + if (context.isResolvingSuperConstructorTarget && this.superCallMustBeFirstStatementInConstructor(enclosingDecl, classDecl)) { + context.postError(this.unitPath, thisExpressionAST.minChar, thisExpressionAST.getLength(), TypeScript.DiagnosticCode.this_cannot_be_referenced_in_current_location, null, enclosingDecl); + } else if (enclosingNonLambdaDecl) { + if (enclosingNonLambdaDecl.kind === 8 /* Class */ && context.isInStaticInitializer) { + context.postError(this.unitPath, thisExpressionAST.minChar, thisExpressionAST.getLength(), TypeScript.DiagnosticCode.this_cannot_be_referenced_in_static_initializers_in_a_class_body, null, enclosingDecl); + } else if (enclosingNonLambdaDecl.kind === 4 /* Container */ || enclosingNonLambdaDecl.kind === 32 /* DynamicModule */) { + context.postError(this.unitPath, thisExpressionAST.minChar, thisExpressionAST.getLength(), TypeScript.DiagnosticCode.this_cannot_be_referenced_within_module_bodies, null, enclosingDecl); + } else if (context.inConstructorArguments) { + context.postError(this.unitPath, thisExpressionAST.minChar, thisExpressionAST.getLength(), TypeScript.DiagnosticCode.this_cannot_be_referenced_in_constructor_arguments, null, enclosingDecl); + } + } + } + + return thisTypeSymbol; + }; + + PullTypeResolver.prototype.getEnclosingNonLambdaDecl = function (enclosingDecl) { + var declPath = enclosingDecl !== null ? TypeScript.getPathToDecl(enclosingDecl) : []; + + if (declPath.length) { + for (var i = declPath.length - 1; i >= 0; i--) { + var decl = declPath[i]; + if (!(decl.kind === 131072 /* FunctionExpression */ && (decl.flags & 8192 /* FatArrow */))) { + return decl; + } + } + } + + return null; + }; + + PullTypeResolver.prototype.resolveSuperExpression = function (ast, enclosingDecl, context) { + if (!enclosingDecl) { + return this.semanticInfoChain.anyTypeSymbol; + } + + var declPath = enclosingDecl !== null ? TypeScript.getPathToDecl(enclosingDecl) : []; + var classSymbol = null; + var superType = this.semanticInfoChain.anyTypeSymbol; + + if (declPath.length) { + for (var i = declPath.length - 1; i >= 0; i--) { + var decl = declPath[i]; + var declFlags = decl.flags; + + if (decl.kind === 131072 /* FunctionExpression */ && !(declFlags & 8192 /* FatArrow */)) { + break; + } else if (declFlags & 16 /* Static */) { + break; + } else if (decl.kind === 8 /* Class */) { + classSymbol = decl.getSymbol(); + + break; + } + } + } + + if (classSymbol) { + if (!classSymbol.isResolved) { + this.resolveDeclaredSymbol(classSymbol, enclosingDecl, context); + } + + var parents = classSymbol.getExtendedTypes(); + + if (parents.length) { + superType = parents[0]; + } + } + + if (context.typeCheck()) { + var nonLambdaEnclosingDecl = this.getEnclosingNonLambdaDecl(enclosingDecl); + + if (nonLambdaEnclosingDecl) { + var nonLambdaEnclosingDeclKind = nonLambdaEnclosingDecl.kind; + var inSuperConstructorTarget = context.isResolvingSuperConstructorTarget; + + if (inSuperConstructorTarget && enclosingDecl.kind !== 32768 /* ConstructorMethod */) { + context.postError(this.unitPath, ast.minChar, ast.getLength(), TypeScript.DiagnosticCode.Super_calls_are_not_permitted_outside_constructors_or_in_local_functions_inside_constructors, null, enclosingDecl); + } else if ((nonLambdaEnclosingDeclKind !== 65536 /* Method */ && nonLambdaEnclosingDeclKind !== 262144 /* GetAccessor */ && nonLambdaEnclosingDeclKind !== 524288 /* SetAccessor */ && nonLambdaEnclosingDeclKind !== 32768 /* ConstructorMethod */) || ((nonLambdaEnclosingDecl.flags & 16 /* Static */) !== 0)) { + context.postError(this.unitPath, ast.minChar, ast.getLength(), TypeScript.DiagnosticCode.super_property_access_is_permitted_only_in_a_constructor_instance_member_function_or_instance_member_accessor_of_a_derived_class, null, enclosingDecl); + } else if (!this.enclosingClassIsDerived(enclosingDecl)) { + context.postError(this.unitPath, ast.minChar, ast.getLength(), TypeScript.DiagnosticCode.super_cannot_be_referenced_in_non_derived_classes, null, enclosingDecl); + } + } + } + + this.checkForThisOrSuperCaptureInArrowFunction(ast, enclosingDecl); + + return superType; + }; + + PullTypeResolver.prototype.resolveObjectLiteralExpression = function (expressionAST, inContextuallyTypedAssignment, enclosingDecl, context, additionalResults) { + var symbol = this.getSymbolForAST(expressionAST); + + if (!symbol || additionalResults) { + symbol = this.computeObjectLiteralExpression(expressionAST, inContextuallyTypedAssignment, enclosingDecl, context, additionalResults); + this.setSymbolForAST(expressionAST, symbol, context); + } + + return symbol; + }; + + PullTypeResolver.prototype.computeObjectLiteralExpression = function (expressionAST, inContextuallyTypedAssignment, enclosingDecl, context, additionalResults) { + var objectLitAST = expressionAST; + var span = TypeScript.TextSpan.fromBounds(objectLitAST.minChar, objectLitAST.limChar); + + var objectLitDecl = new TypeScript.PullDecl("", "", 512 /* ObjectLiteral */, 0 /* None */, span, this.unitPath); + this.currentUnit.addSynthesizedDecl(objectLitDecl); + + if (enclosingDecl) { + objectLitDecl.setParentDecl(enclosingDecl); + } + + this.currentUnit.setDeclForAST(objectLitAST, objectLitDecl); + this.currentUnit.setASTForDecl(objectLitDecl, objectLitAST); + + var typeSymbol = new TypeScript.PullTypeSymbol("", 16 /* Interface */); + typeSymbol.addDeclaration(objectLitDecl); + objectLitDecl.setSymbol(typeSymbol); + + var memberDecls = objectLitAST.operand; + + var contextualType = null; + + if (inContextuallyTypedAssignment) { + contextualType = context.getContextualType(); + + this.resolveDeclaredSymbol(contextualType, enclosingDecl, context); + } + + if (memberDecls) { + var binex; + var memberSymbol; + var assigningSymbol = null; + var acceptedContextualType = false; + + if (additionalResults) { + additionalResults.membersContextTypeSymbols = []; + } + + for (var i = 0, len = memberDecls.members.length; i < len; i++) { + binex = memberDecls.members[i]; + + var id = binex.operand1; + var text; + var actualText; + + if (id.nodeType() === 21 /* Name */) { + actualText = (id).actualText; + text = (id).text(); + } else if (id.nodeType() === 5 /* StringLiteral */) { + actualText = (id).actualText; + text = (id).text(); + } else if (id.nodeType() === 7 /* NumericLiteral */) { + actualText = text = (id).text(); + } else { + return this.semanticInfoChain.anyTypeSymbol; + } + + span = TypeScript.TextSpan.fromBounds(binex.minChar, binex.limChar); + + var isAccessor = binex.operand2.nodeType() === 13 /* FunctionDeclaration */ && (binex.operand2).isAccessor(); + + if (!isAccessor) { + var decl = new TypeScript.PullDecl(text, actualText, 4096 /* Property */, 4 /* Public */, span, this.unitPath); + this.currentUnit.addSynthesizedDecl(decl); + + objectLitDecl.addChildDecl(decl); + decl.setParentDecl(objectLitDecl); + + this.semanticInfoChain.getUnit(this.unitPath).setDeclForAST(binex, decl); + this.semanticInfoChain.getUnit(this.unitPath).setASTForDecl(decl, binex); + + memberSymbol = new TypeScript.PullSymbol(text, 4096 /* Property */); + + memberSymbol.addDeclaration(decl); + decl.setSymbol(memberSymbol); + } + + if (contextualType) { + assigningSymbol = this.getMemberSymbol(text, TypeScript.PullElementKind.SomeValue, contextualType); + + if (assigningSymbol) { + this.resolveDeclaredSymbol(assigningSymbol, enclosingDecl, context); + + context.pushContextualType(assigningSymbol.type, context.inProvisionalResolution(), null); + + acceptedContextualType = true; + + if (additionalResults) { + additionalResults.membersContextTypeSymbols[i] = assigningSymbol.type; + } + } + } + + if (isAccessor) { + var funcDeclAST = binex.operand2; + var semanticInfo = this.semanticInfoChain.getUnit(this.unitPath); + var declCollectionContext = new TypeScript.DeclCollectionContext(semanticInfo, this.unitPath); + + declCollectionContext.pushParent(objectLitDecl); + + TypeScript.getAstWalkerFactory().walk(funcDeclAST, TypeScript.preCollectDecls, TypeScript.postCollectDecls, null, declCollectionContext); + + var functionDecl = this.getDeclForAST(funcDeclAST); + this.currentUnit.addSynthesizedDecl(functionDecl); + + var binder = new TypeScript.PullSymbolBinder(this.semanticInfoChain); + binder.setUnit(this.unitPath); + + if (funcDeclAST.isGetAccessor()) { + binder.bindGetAccessorDeclarationToPullSymbol(functionDecl); + } else { + binder.bindSetAccessorDeclarationToPullSymbol(functionDecl); + } + } + + var memberExprType = this.resolveAST(binex.operand2, assigningSymbol != null, enclosingDecl, context); + + if (acceptedContextualType) { + context.popContextualType(); + acceptedContextualType = false; + } + + if (isAccessor) { + this.setSymbolForAST(binex.operand1, memberExprType, context); + } else { + context.setTypeInContext(memberSymbol, memberExprType.type); + memberSymbol.setResolved(); + + this.setSymbolForAST(binex.operand1, memberSymbol, context); + typeSymbol.addMember(memberSymbol); + } + } + } + + typeSymbol.setResolved(); + return typeSymbol; + }; + + PullTypeResolver.prototype.resolveArrayLiteralExpression = function (arrayLit, inContextuallyTypedAssignment, enclosingDecl, context) { + var symbol = this.getSymbolForAST(arrayLit); + if (!symbol) { + symbol = this.computeArrayLiteralExpressionSymbol(arrayLit, inContextuallyTypedAssignment, enclosingDecl, context); + this.setSymbolForAST(arrayLit, symbol, context); + } + + return symbol; + }; + + PullTypeResolver.prototype.computeArrayLiteralExpressionSymbol = function (arrayLit, inContextuallyTypedAssignment, enclosingDecl, context) { + var elements = arrayLit.operand; + var elementType = this.semanticInfoChain.anyTypeSymbol; + var elementTypes = []; + var comparisonInfo = new TypeComparisonInfo(); + var contextualElementType = null; + comparisonInfo.onlyCaptureFirstError = true; + + if (inContextuallyTypedAssignment) { + var contextualType = context.getContextualType(); + + this.resolveDeclaredSymbol(contextualType, enclosingDecl, context); + + if (contextualType) { + if (contextualType.isArray()) { + contextualElementType = contextualType.getElementType(); + } else { + var indexSignatures = contextualType.getIndexSignatures(); + for (var i = 0; i < indexSignatures.length; i++) { + var signature = indexSignatures[i]; + if (signature.parameters[0].type === this.semanticInfoChain.numberTypeSymbol) { + contextualElementType = signature.returnType; + break; + } + } + } + } + } + + if (elements) { + if (inContextuallyTypedAssignment) { + context.pushContextualType(contextualElementType, context.inProvisionalResolution(), null); + } + + for (var i = 0; i < elements.members.length; i++) { + elementTypes[elementTypes.length] = this.resolveAST(elements.members[i], inContextuallyTypedAssignment, enclosingDecl, context).type; + } + + if (inContextuallyTypedAssignment) { + context.popContextualType(); + } + } + + if (this.compilationSettings.noImplicitAny && !context.isInInvocationExpression) { + if (!inContextuallyTypedAssignment && elements.members.length == 0) { + context.postError(this.unitPath, arrayLit.minChar, arrayLit.getLength(), TypeScript.DiagnosticCode.Array_Literal_implicitly_has_an_any_type_from_widening, [], enclosingDecl); + } + } + + if (contextualElementType && !contextualElementType.isTypeParameter()) { + elementType = contextualElementType; + + for (var i = 0; i < elementTypes.length; i++) { + var comparisonInfo = new TypeComparisonInfo(); + var currentElementType = elementTypes[i]; + var currentElementAST = elements.members[i]; + if (!this.sourceIsAssignableToTarget(currentElementType, contextualElementType, context, comparisonInfo)) { + var message; + if (comparisonInfo.message) { + message = context.postError(this.getUnitPath(), currentElementAST.minChar, currentElementAST.getLength(), TypeScript.DiagnosticCode.Cannot_convert_0_to_1_NL_2, [currentElementType.toString(), contextualElementType.toString(), comparisonInfo.message], enclosingDecl); + } else { + message = context.postError(this.getUnitPath(), currentElementAST.minChar, currentElementAST.getLength(), TypeScript.DiagnosticCode.Cannot_convert_0_to_1, [currentElementType.toString(), contextualElementType.toString()], enclosingDecl); + } + + return this.getNewErrorTypeSymbol(null); + } + } + } else { + if (elementTypes.length) { + elementType = elementTypes[0]; + } else if (contextualElementType) { + elementType = contextualElementType; + } + + var collection = { + getLength: function () { + return elements.members.length; + }, + setTypeAtIndex: function (index, type) { + elementTypes[index] = type; + }, + getTypeAtIndex: function (index) { + return elementTypes[index]; + } + }; + + elementType = this.findBestCommonType(elementType, null, collection, context, comparisonInfo); + + if (elementType === this.semanticInfoChain.undefinedTypeSymbol || elementType === this.semanticInfoChain.nullTypeSymbol) { + elementType = this.semanticInfoChain.anyTypeSymbol; + + if (this.compilationSettings.noImplicitAny && !inContextuallyTypedAssignment && !context.isInInvocationExpression) { + context.postError(this.unitPath, arrayLit.minChar, arrayLit.getLength(), TypeScript.DiagnosticCode.Array_Literal_implicitly_has_an_any_type_from_widening, [], enclosingDecl); + } + } + + if (!elementType) { + elementType = this.semanticInfoChain.anyTypeSymbol; + + if (this.compilationSettings.noImplicitAny && !inContextuallyTypedAssignment && !context.isInInvocationExpression) { + context.postError(this.unitPath, arrayLit.minChar, arrayLit.getLength(), TypeScript.DiagnosticCode.Array_Literal_implicitly_has_an_any_type_from_widening, [], enclosingDecl); + } + } else if (contextualElementType && !contextualElementType.isTypeParameter()) { + if (this.sourceIsAssignableToTarget(elementType, contextualElementType, context)) { + elementType = contextualType; + } + } + } + + var arraySymbol = elementType.getArrayType(); + + if (!arraySymbol) { + if (!this.cachedArrayInterfaceType().isResolved) { + this.resolveDeclaredSymbol(this.cachedArrayInterfaceType(), enclosingDecl, context); + } + + arraySymbol = TypeScript.specializeType(this.cachedArrayInterfaceType(), [elementType], this, this.cachedArrayInterfaceType().getDeclarations()[0], context, arrayLit); + + if (!arraySymbol) { + arraySymbol = this.semanticInfoChain.anyTypeSymbol; + } + } + + return arraySymbol; + }; + + PullTypeResolver.prototype.resolveIndexExpression = function (callEx, inContextuallyTypedAssignment, enclosingDecl, context) { + var symbol = this.getSymbolForAST(callEx); + if (!symbol) { + symbol = this.computeIndexExpressionSymbol(callEx, inContextuallyTypedAssignment, enclosingDecl, context); + this.setSymbolForAST(callEx, symbol, context); + } + + return symbol; + }; + + PullTypeResolver.prototype.computeIndexExpressionSymbol = function (callEx, inContextuallyTypedAssignment, enclosingDecl, context) { + var targetSymbol = this.resolveAST(callEx.operand1, inContextuallyTypedAssignment, enclosingDecl, context); + + var targetTypeSymbol = targetSymbol.type; + + if (this.isAnyOrEquivalent(targetTypeSymbol)) { + return targetTypeSymbol; + } + + var elementType = targetTypeSymbol.getElementType(); + + var indexType = this.resolveAST(callEx.operand2, inContextuallyTypedAssignment, enclosingDecl, context).type; + + var isNumberIndex = indexType === this.semanticInfoChain.numberTypeSymbol || TypeScript.PullHelpers.symbolIsEnum(indexType); + + if (elementType && isNumberIndex) { + return elementType; + } + + if (callEx.operand2.nodeType() === 5 /* StringLiteral */ || callEx.operand2.nodeType() === 7 /* NumericLiteral */) { + var memberName = callEx.operand2.nodeType() === 5 /* StringLiteral */ ? TypeScript.stripQuotes((callEx.operand2).actualText) : (callEx.operand2).value.toString(); + + var member = this.getMemberSymbol(memberName, TypeScript.PullElementKind.SomeValue, targetTypeSymbol); + + if (member) { + return member.type; + } + } + + var signatures = targetTypeSymbol.getIndexSignatures(); + + var stringSignature = null; + var numberSignature = null; + var signature = null; + var paramSymbols; + var paramType; + + for (var i = 0; i < signatures.length; i++) { + if (stringSignature && numberSignature) { + break; + } + + signature = signatures[i]; + + paramSymbols = signature.parameters; + + if (paramSymbols.length) { + paramType = paramSymbols[0].type; + + if (paramType === this.semanticInfoChain.stringTypeSymbol) { + stringSignature = signatures[i]; + continue; + } else if (paramType === this.semanticInfoChain.numberTypeSymbol || paramType.kind === 64 /* Enum */) { + numberSignature = signatures[i]; + continue; + } + } + } + + if (numberSignature && (isNumberIndex || indexType === this.semanticInfoChain.anyTypeSymbol)) { + var returnType = numberSignature.returnType; + + if (!returnType) { + returnType = this.semanticInfoChain.anyTypeSymbol; + } + + return returnType; + } else if (stringSignature && (isNumberIndex || indexType === this.semanticInfoChain.anyTypeSymbol || indexType === this.semanticInfoChain.stringTypeSymbol)) { + var returnType = stringSignature.returnType; + + if (!returnType) { + returnType = this.semanticInfoChain.anyTypeSymbol; + } + + return returnType; + } else if (isNumberIndex || indexType === this.semanticInfoChain.anyTypeSymbol || indexType === this.semanticInfoChain.stringTypeSymbol) { + var returnType = this.semanticInfoChain.anyTypeSymbol; + return returnType; + } else { + context.postError(this.getUnitPath(), callEx.minChar, callEx.getLength(), TypeScript.DiagnosticCode.Value_of_type_0_is_not_indexable_by_type_1, [targetTypeSymbol.toString(), indexType.toString()], enclosingDecl); + return this.getNewErrorTypeSymbol(null); + } + }; + + PullTypeResolver.prototype.resolveBitwiseOperator = function (expressionAST, inContextuallyTypedAssignment, enclosingDecl, context) { + var binex = expressionAST; + + var leftType = this.resolveAST(binex.operand1, inContextuallyTypedAssignment, enclosingDecl, context).type; + var rightType = this.resolveAST(binex.operand2, inContextuallyTypedAssignment, enclosingDecl, context).type; + + if (this.sourceIsSubtypeOfTarget(leftType, this.semanticInfoChain.numberTypeSymbol, context) && this.sourceIsSubtypeOfTarget(rightType, this.semanticInfoChain.numberTypeSymbol, context)) { + return this.semanticInfoChain.numberTypeSymbol; + } else if ((leftType === this.semanticInfoChain.booleanTypeSymbol) && (rightType === this.semanticInfoChain.booleanTypeSymbol)) { + return this.semanticInfoChain.booleanTypeSymbol; + } else if (this.isAnyOrEquivalent(leftType)) { + if ((this.isAnyOrEquivalent(rightType) || (rightType === this.semanticInfoChain.numberTypeSymbol) || (rightType === this.semanticInfoChain.booleanTypeSymbol))) { + return this.semanticInfoChain.anyTypeSymbol; + } + } else if (this.isAnyOrEquivalent(rightType)) { + if ((leftType === this.semanticInfoChain.numberTypeSymbol) || (leftType === this.semanticInfoChain.booleanTypeSymbol)) { + return this.semanticInfoChain.anyTypeSymbol; + } + } + + return this.semanticInfoChain.anyTypeSymbol; + }; + + PullTypeResolver.prototype.resolveBinaryAdditionOperation = function (binaryExpression, inContextuallyTypedAssignment, enclosingDecl, context) { + var lhsType = this.resolveAST(binaryExpression.operand1, false, enclosingDecl, context).type; + var rhsType = this.resolveAST(binaryExpression.operand2, false, enclosingDecl, context).type; + + if (TypeScript.PullHelpers.symbolIsEnum(lhsType)) { + lhsType = this.semanticInfoChain.numberTypeSymbol; + } else if (lhsType === this.semanticInfoChain.nullTypeSymbol || lhsType === this.semanticInfoChain.undefinedTypeSymbol) { + if (rhsType != this.semanticInfoChain.nullTypeSymbol && rhsType != this.semanticInfoChain.undefinedTypeSymbol) { + lhsType = rhsType; + } else { + lhsType = this.semanticInfoChain.anyTypeSymbol; + } + } + + if (TypeScript.PullHelpers.symbolIsEnum(rhsType)) { + rhsType = this.semanticInfoChain.numberTypeSymbol; + } else if (rhsType === this.semanticInfoChain.nullTypeSymbol || rhsType === this.semanticInfoChain.undefinedTypeSymbol) { + if (lhsType != this.semanticInfoChain.nullTypeSymbol && lhsType != this.semanticInfoChain.undefinedTypeSymbol) { + rhsType = lhsType; + } else { + rhsType = this.semanticInfoChain.anyTypeSymbol; + } + } + + var exprType = null; + + if (lhsType === this.semanticInfoChain.stringTypeSymbol || rhsType === this.semanticInfoChain.stringTypeSymbol) { + exprType = this.semanticInfoChain.stringTypeSymbol; + } else if (this.isAnyOrEquivalent(lhsType) || this.isAnyOrEquivalent(rhsType)) { + exprType = this.semanticInfoChain.anyTypeSymbol; + } else if (rhsType === this.semanticInfoChain.numberTypeSymbol && lhsType === this.semanticInfoChain.numberTypeSymbol) { + exprType = this.semanticInfoChain.numberTypeSymbol; + } + + if (exprType) { + if (binaryExpression.nodeType() === 40 /* AddAssignmentExpression */) { + var lhsExpression = this.resolveAST(binaryExpression.operand1, false, enclosingDecl, context); + if (!this.isValidLHS(binaryExpression.operand1, lhsExpression)) { + context.postError(this.unitPath, binaryExpression.operand1.minChar, binaryExpression.operand1.getLength(), TypeScript.DiagnosticCode.Invalid_left_hand_side_of_assignment_expression, null, enclosingDecl); + } + + this.checkAssignability(binaryExpression.operand1, exprType, lhsType, enclosingDecl, context); + } + } else { + context.postError(this.unitPath, binaryExpression.operand1.minChar, binaryExpression.operand1.getLength(), TypeScript.DiagnosticCode.Invalid_expression_types_not_known_to_support_the_addition_operator, null, enclosingDecl); + exprType = this.semanticInfoChain.anyTypeSymbol; + } + + return exprType; + }; + + PullTypeResolver.prototype.resolveLogicalOrExpression = function (binex, inContextuallyTypedAssignment, enclosingDecl, context) { + var symbol = this.getSymbolForAST(binex); + if (!symbol) { + symbol = this.computeLogicalOrExpressionSymbol(binex, inContextuallyTypedAssignment, enclosingDecl, context); + this.setSymbolForAST(binex, symbol, context); + } + + return symbol; + }; + + PullTypeResolver.prototype.computeLogicalOrExpressionSymbol = function (binex, inContextuallyTypedAssignment, enclosingDecl, context) { + var leftType = this.resolveAST(binex.operand1, inContextuallyTypedAssignment, enclosingDecl, context).type; + var rightType = this.resolveAST(binex.operand2, inContextuallyTypedAssignment, enclosingDecl, context).type; + + if (this.isAnyOrEquivalent(leftType) || this.isAnyOrEquivalent(rightType)) { + return this.semanticInfoChain.anyTypeSymbol; + } else if (leftType === this.semanticInfoChain.booleanTypeSymbol) { + if (rightType === this.semanticInfoChain.booleanTypeSymbol) { + return this.semanticInfoChain.booleanTypeSymbol; + } else { + return this.semanticInfoChain.anyTypeSymbol; + } + } else if (leftType === this.semanticInfoChain.numberTypeSymbol) { + if (rightType === this.semanticInfoChain.numberTypeSymbol) { + return this.semanticInfoChain.numberTypeSymbol; + } else { + return this.semanticInfoChain.anyTypeSymbol; + } + } else if (leftType === this.semanticInfoChain.stringTypeSymbol) { + if (rightType === this.semanticInfoChain.stringTypeSymbol) { + return this.semanticInfoChain.stringTypeSymbol; + } else { + return this.semanticInfoChain.anyTypeSymbol; + } + } else if (this.sourceIsSubtypeOfTarget(leftType, rightType, context)) { + return rightType; + } else if (this.sourceIsSubtypeOfTarget(rightType, leftType, context)) { + return leftType; + } + + return this.semanticInfoChain.anyTypeSymbol; + }; + + PullTypeResolver.prototype.resolveLogicalAndExpression = function (binex, inContextuallyTypedAssignment, enclosingDecl, context) { + if (context.typeCheck()) { + this.resolveAST(binex.operand1, inContextuallyTypedAssignment, enclosingDecl, context); + } + + return this.resolveAST(binex.operand2, inContextuallyTypedAssignment, enclosingDecl, context).type; + }; + + PullTypeResolver.prototype.resolveConditionalExpression = function (trinex, enclosingDecl, context) { + var symbol = this.getSymbolForAST(trinex); + if (!symbol) { + symbol = this.computeConditionalExpressionSymbol(trinex, enclosingDecl, context); + this.setSymbolForAST(trinex, symbol, context); + } + + return symbol; + }; + + PullTypeResolver.prototype.computeConditionalExpressionSymbol = function (trinex, enclosingDecl, context) { + if (context.typeCheck()) { + this.resolveAST(trinex.operand1, false, enclosingDecl, context); + } + + var leftType = this.resolveAST(trinex.operand2, false, enclosingDecl, context).type; + var rightType = this.resolveAST(trinex.operand3, false, enclosingDecl, context).type; + + var symbol = null; + if (this.typesAreIdentical(leftType, rightType)) { + symbol = leftType; + } else if (this.sourceIsSubtypeOfTarget(leftType, rightType, context) || this.sourceIsSubtypeOfTarget(rightType, leftType, context)) { + var collection = { + getLength: function () { + return 2; + }, + setTypeAtIndex: function (index, type) { + }, + getTypeAtIndex: function (index) { + return rightType; + } + }; + + var bestCommonType = this.findBestCommonType(leftType, null, collection, context); + + if (bestCommonType) { + symbol = bestCommonType; + } + } + + if (!symbol) { + context.postError(this.getUnitPath(), trinex.minChar, trinex.getLength(), TypeScript.DiagnosticCode.Type_of_conditional_expression_cannot_be_determined_Best_common_type_could_not_be_found_between_0_and_1, [leftType.toString(), rightType.toString()], enclosingDecl); + return this.getNewErrorTypeSymbol(null); + } + + return symbol; + }; + + PullTypeResolver.prototype.resolveParenthesizedExpression = function (ast, enclosingDecl, context) { + return this.resolveAST(ast.expression, false, enclosingDecl, context); + }; + + PullTypeResolver.prototype.resolveExpressionStatement = function (ast, inContextuallyTypedAssignment, enclosingDecl, context) { + return this.resolveAST(ast.expression, inContextuallyTypedAssignment, enclosingDecl, context); + }; + + PullTypeResolver.prototype.resolveInvocationExpression = function (callEx, inContextuallyTypedAssignment, enclosingDecl, context, additionalResults) { + var symbol = this.getSymbolForAST(callEx); + var callResolutionData = this.currentUnit.getCallResolutionDataForAST(callEx); + + if (!symbol || !symbol.isResolved || (additionalResults && !callResolutionData)) { + symbol = this.computeInvocationExpressionSymbol(callEx, inContextuallyTypedAssignment, enclosingDecl, context, additionalResults); + if (symbol != this.semanticInfoChain.anyTypeSymbol) { + this.setSymbolForAST(callEx, symbol, context); + } + this.currentUnit.setCallResolutionDataForAST(callEx, additionalResults); + } else { + if (additionalResults && callResolutionData && (callResolutionData != additionalResults)) { + additionalResults.actualParametersContextTypeSymbols = callResolutionData.actualParametersContextTypeSymbols; + additionalResults.candidateSignature = callResolutionData.candidateSignature; + additionalResults.resolvedSignatures = callResolutionData.resolvedSignatures; + additionalResults.targetSymbol = callResolutionData.targetSymbol; + additionalResults.targetTypeSymbol = callResolutionData.targetTypeSymbol; + } + } + + return symbol; + }; + + PullTypeResolver.prototype.computeInvocationExpressionSymbol = function (callEx, inContextuallyTypedAssignment, enclosingDecl, context, additionalResults) { + var targetSymbol = this.resolveAST(callEx.target, inContextuallyTypedAssignment, enclosingDecl, context); + + var targetAST = this.getLastIdentifierInTarget(callEx); + + var targetTypeSymbol = targetSymbol.type; + if (this.isAnyOrEquivalent(targetTypeSymbol)) { + this.resolveAST(callEx.arguments, inContextuallyTypedAssignment, enclosingDecl, context); + + if (targetSymbol != this.semanticInfoChain.anyTypeSymbol && callEx.typeArguments) { + context.postError(this.unitPath, targetAST.minChar, targetAST.getLength(), TypeScript.DiagnosticCode.Untyped_function_calls_may_not_accept_type_arguments, null, enclosingDecl); + return this.getNewErrorTypeSymbol(null); + } + + return this.semanticInfoChain.anyTypeSymbol; + } + + var isSuperCall = false; + + if (callEx.target.nodeType() === 31 /* SuperExpression */) { + isSuperCall = true; + + if (targetTypeSymbol.isClass()) { + this.seenSuperConstructorCall = true; + targetSymbol = targetTypeSymbol.getConstructorMethod(); + targetTypeSymbol = targetSymbol.type; + } else { + context.postError(this.unitPath, targetAST.minChar, targetAST.getLength(), TypeScript.DiagnosticCode.Calls_to_super_are_only_valid_inside_a_class, null, enclosingDecl); + + return this.getNewErrorTypeSymbol(null); + } + } + + var signatures = isSuperCall ? targetTypeSymbol.getConstructSignatures() : targetTypeSymbol.getCallSignatures(); + + if (!signatures.length && (targetTypeSymbol.kind == 33554432 /* ConstructorType */)) { + context.postError(this.unitPath, targetAST.minChar, targetAST.getLength(), TypeScript.DiagnosticCode.Value_of_type_0_is_not_callable_Did_you_mean_to_include_new, [targetTypeSymbol.toString()], enclosingDecl); + } + + var typeArgs = null; + var typeReplacementMap = null; + var couldNotFindGenericOverload = false; + var couldNotAssignToConstraint; + var constraintDiagnostic = null; + var diagnostics = []; + + if (callEx.typeArguments) { + typeArgs = []; + + if (callEx.typeArguments && callEx.typeArguments.members.length) { + for (var i = 0; i < callEx.typeArguments.members.length; i++) { + var typeArg = this.resolveTypeReference(callEx.typeArguments.members[i], enclosingDecl, context); + typeArgs[i] = context.findSpecializationForType(typeArg); + } + } + } else if (isSuperCall && targetTypeSymbol.isGeneric()) { + typeArgs = targetTypeSymbol.getTypeArguments(); + } + + if (targetTypeSymbol.isGeneric()) { + var resolvedSignatures = []; + var inferredTypeArgs; + var specializedSignature; + var typeParameters; + var typeConstraint = null; + var prevSpecializingToAny = context.specializingToAny; + var prevSpecializing = context.isSpecializingSignatureAtCallSite; + var beforeResolutionSignatures = signatures; + var triedToInferTypeArgs; + + for (var i = 0; i < signatures.length; i++) { + typeParameters = signatures[i].getTypeParameters(); + couldNotAssignToConstraint = false; + triedToInferTypeArgs = false; + + if (signatures[i].isGeneric() && typeParameters.length && !signatures[i].isFixed()) { + if (typeArgs) { + inferredTypeArgs = typeArgs; + } else if (callEx.arguments) { + inferredTypeArgs = this.inferArgumentTypesForSignature(signatures[i], callEx.arguments, new TypeComparisonInfo(), enclosingDecl, context); + triedToInferTypeArgs = true; + } + + if (inferredTypeArgs) { + typeReplacementMap = {}; + + if (inferredTypeArgs.length) { + if (inferredTypeArgs.length != typeParameters.length) { + continue; + } + + for (var j = 0; j < typeParameters.length; j++) { + typeReplacementMap[typeParameters[j].pullSymbolIDString] = inferredTypeArgs[j]; + } + for (var j = 0; j < typeParameters.length; j++) { + typeConstraint = typeParameters[j].getConstraint(); + + if (typeConstraint) { + if (typeConstraint.isTypeParameter()) { + for (var k = 0; k < typeParameters.length && k < inferredTypeArgs.length; k++) { + if (typeParameters[k] == typeConstraint) { + typeConstraint = inferredTypeArgs[k]; + } + } + } + if (typeConstraint.isTypeParameter()) { + context.pushTypeSpecializationCache(typeReplacementMap); + typeConstraint = TypeScript.specializeType(typeConstraint, null, this, enclosingDecl, context); + context.popTypeSpecializationCache(); + } + context.isComparingSpecializedSignatures = true; + if (!this.sourceIsAssignableToTarget(inferredTypeArgs[j], typeConstraint, context)) { + constraintDiagnostic = context.postError(this.unitPath, targetAST.minChar, targetAST.getLength(), TypeScript.DiagnosticCode.Type_0_does_not_satisfy_the_constraint_1_for_type_parameter_2, [inferredTypeArgs[j].toString(null, true), typeConstraint.toString(null, true), typeParameters[j].toString(null, true)], enclosingDecl, false); + couldNotAssignToConstraint = true; + } + context.isComparingSpecializedSignatures = false; + + if (couldNotAssignToConstraint) { + break; + } + } + } + } else { + if (triedToInferTypeArgs) { + if (signatures[i].isFixed()) { + if (signatures[i].hasAGenericParameter) { + context.specializingToAny = true; + } else { + resolvedSignatures[resolvedSignatures.length] = signatures[i]; + } + } else { + continue; + } + } + + context.specializingToAny = true; + } + + if (couldNotAssignToConstraint) { + continue; + } + + context.isSpecializingSignatureAtCallSite = true; + specializedSignature = TypeScript.specializeSignature(signatures[i], false, typeReplacementMap, inferredTypeArgs, this, enclosingDecl, context); + + context.isSpecializingSignatureAtCallSite = prevSpecializing; + context.specializingToAny = prevSpecializingToAny; + + if (specializedSignature) { + resolvedSignatures[resolvedSignatures.length] = specializedSignature; + } + } + } else { + if (!(callEx.typeArguments && callEx.typeArguments.members.length)) { + resolvedSignatures[resolvedSignatures.length] = signatures[i]; + } + } + } + + if (signatures.length && !resolvedSignatures.length) { + couldNotFindGenericOverload = true; + } + + signatures = resolvedSignatures; + } + + var errorCondition = null; + + if (!signatures.length) { + if (additionalResults) { + additionalResults.targetSymbol = targetSymbol; + additionalResults.targetTypeSymbol = targetTypeSymbol; + additionalResults.resolvedSignatures = beforeResolutionSignatures; + additionalResults.candidateSignature = beforeResolutionSignatures && beforeResolutionSignatures.length ? beforeResolutionSignatures[0] : null; + + additionalResults.actualParametersContextTypeSymbols = actualParametersContextTypeSymbols; + } + + if (!couldNotFindGenericOverload) { + if (this.cachedFunctionInterfaceType() && this.sourceIsSubtypeOfTarget(targetTypeSymbol, this.cachedFunctionInterfaceType(), context)) { + return this.semanticInfoChain.anyTypeSymbol; + } + + context.postError(this.unitPath, callEx.minChar, callEx.getLength(), TypeScript.DiagnosticCode.Cannot_invoke_an_expression_whose_type_lacks_a_call_signature, null, enclosingDecl); + errorCondition = this.getNewErrorTypeSymbol(null); + } else { + context.postError(this.unitPath, callEx.minChar, callEx.getLength(), TypeScript.DiagnosticCode.Could_not_select_overload_for_call_expression, null, enclosingDecl); + errorCondition = this.getNewErrorTypeSymbol(null); + } + + if (constraintDiagnostic) { + context.postDiagnostic(constraintDiagnostic, enclosingDecl); + } + + return errorCondition; + } + + var prevIsResolvingSuperConstructorTarget = context.isResolvingSuperConstructorTarget; + + if (isSuperCall) { + context.isResolvingSuperConstructorTarget = true; + } + + var signature = this.resolveOverloads(callEx, signatures, enclosingDecl, callEx.typeArguments != null, context, diagnostics); + var useBeforeResolutionSignatures = signature == null; + + if (isSuperCall) { + context.isResolvingSuperConstructorTarget = prevIsResolvingSuperConstructorTarget; + } + + if (!signature) { + for (var i = 0; i < diagnostics.length; i++) { + context.postDiagnostic(diagnostics[i], enclosingDecl); + } + + context.postError(this.unitPath, targetAST.minChar, targetAST.getLength(), TypeScript.DiagnosticCode.Could_not_select_overload_for_call_expression, null, enclosingDecl); + + errorCondition = this.getNewErrorTypeSymbol(null); + + if (!signatures.length) { + return errorCondition; + } + + signature = signatures[0]; + + if (callEx.arguments) { + for (var k = 0, n = callEx.arguments.members.length; k < n; k++) { + var arg = callEx.arguments.members[k]; + var argSymbol = this.getSymbolForAST(arg); + + if (argSymbol) { + var argType = argSymbol.type; + if (arg.nodeType() === 13 /* FunctionDeclaration */) { + if (!this.canApplyContextualTypeToFunction(argType, arg, true)) { + continue; + } + } + + argSymbol.invalidate(); + } + } + } + } + + if (!signature.isGeneric() && callEx.typeArguments) { + context.postError(this.unitPath, targetAST.minChar, targetAST.getLength(), TypeScript.DiagnosticCode.Non_generic_functions_may_not_accept_type_arguments, null, enclosingDecl); + } + + var returnType = isSuperCall ? this.semanticInfoChain.voidTypeSymbol : signature.returnType; + + var actualParametersContextTypeSymbols = []; + if (callEx.arguments) { + var len = callEx.arguments.members.length; + var params = signature.parameters; + var contextualType = null; + var signatureDecl = signature.getDeclarations()[0]; + + for (var i = 0; i < len; i++) { + if (params.length) { + if (i < params.length - 1 || (i < params.length && !signature.hasVarArgs)) { + if (typeReplacementMap) { + context.pushTypeSpecializationCache(typeReplacementMap); + } + this.resolveDeclaredSymbol(params[i], signatureDecl, context); + if (typeReplacementMap) { + context.popTypeSpecializationCache(); + } + contextualType = params[i].type; + } else if (signature.hasVarArgs) { + contextualType = params[params.length - 1].type; + if (contextualType.isArray()) { + contextualType = contextualType.getElementType(); + } + } + } + + if (contextualType) { + context.pushContextualType(contextualType, context.inProvisionalResolution(), null); + actualParametersContextTypeSymbols[i] = contextualType; + } + + this.resolveAST(callEx.arguments.members[i], contextualType != null, enclosingDecl, context); + + if (contextualType) { + context.popContextualType(); + contextualType = null; + } + } + } + + if (additionalResults) { + additionalResults.targetSymbol = targetSymbol; + additionalResults.targetTypeSymbol = targetTypeSymbol; + if (useBeforeResolutionSignatures && beforeResolutionSignatures) { + additionalResults.resolvedSignatures = beforeResolutionSignatures; + additionalResults.candidateSignature = beforeResolutionSignatures[0]; + } else { + additionalResults.resolvedSignatures = signatures; + additionalResults.candidateSignature = signature; + } + additionalResults.actualParametersContextTypeSymbols = actualParametersContextTypeSymbols; + } + + if (errorCondition) { + return errorCondition; + } + + if (!returnType) { + returnType = this.semanticInfoChain.anyTypeSymbol; + } + + return returnType; + }; + + PullTypeResolver.prototype.resolveObjectCreationExpression = function (callEx, inContextuallyTypedAssignment, enclosingDecl, context, additionalResults) { + var symbol = this.getSymbolForAST(callEx); + var callResolutionData = this.currentUnit.getCallResolutionDataForAST(callEx); + + if (!symbol || !symbol.isResolved || (additionalResults && !callResolutionData)) { + symbol = this.computeObjectCreationExpressionSymbol(callEx, inContextuallyTypedAssignment, enclosingDecl, context, additionalResults); + this.setSymbolForAST(callEx, symbol, context); + this.currentUnit.setCallResolutionDataForAST(callEx, additionalResults); + } else { + if (additionalResults && callResolutionData && (callResolutionData != additionalResults)) { + additionalResults.actualParametersContextTypeSymbols = callResolutionData.actualParametersContextTypeSymbols; + additionalResults.candidateSignature = callResolutionData.candidateSignature; + additionalResults.resolvedSignatures = callResolutionData.resolvedSignatures; + additionalResults.targetSymbol = callResolutionData.targetSymbol; + additionalResults.targetTypeSymbol = callResolutionData.targetTypeSymbol; + } + } + + return symbol; + }; + + PullTypeResolver.prototype.computeObjectCreationExpressionSymbol = function (callEx, inContextuallyTypedAssignment, enclosingDecl, context, additionalResults) { + var returnType = null; + + var targetSymbol = this.resolveAST(callEx.target, inContextuallyTypedAssignment, enclosingDecl, context); + var targetTypeSymbol = targetSymbol.isType() ? targetSymbol : targetSymbol.type; + + var targetAST = this.getLastIdentifierInTarget(callEx); + + if (targetTypeSymbol.isClass()) { + targetTypeSymbol = targetTypeSymbol.getConstructorMethod().type; + } + + var constructSignatures = targetTypeSymbol.getConstructSignatures(); + + var typeArgs = null; + var typeReplacementMap = null; + var usedCallSignaturesInstead = false; + var couldNotAssignToConstraint; + var constraintDiagnostic = null; + var diagnostics = []; + + if (this.isAnyOrEquivalent(targetTypeSymbol)) { + this.resolveAST(callEx.arguments, inContextuallyTypedAssignment, enclosingDecl, context); + return targetTypeSymbol; + } + + if (!constructSignatures.length) { + constructSignatures = targetTypeSymbol.getCallSignatures(); + usedCallSignaturesInstead = true; + + if (this.compilationSettings.noImplicitAny) { + context.postError(this.unitPath, callEx.minChar, callEx.getLength(), TypeScript.DiagnosticCode.New_expression_which_lacks_a_constructor_signature_implicitly_has_an_any_type, [], enclosingDecl); + } + } + + if (constructSignatures.length) { + if (callEx.typeArguments) { + typeArgs = []; + + if (callEx.typeArguments && callEx.typeArguments.members.length) { + for (var i = 0; i < callEx.typeArguments.members.length; i++) { + var typeArg = this.resolveTypeReference(callEx.typeArguments.members[i], enclosingDecl, context); + typeArgs[i] = context.findSpecializationForType(typeArg); + } + } + } + + if (targetTypeSymbol.isGeneric()) { + var resolvedSignatures = []; + var inferredTypeArgs; + var specializedSignature; + var typeParameters; + var typeConstraint = null; + var prevSpecializingToAny = context.specializingToAny; + var prevIsSpecializing = context.isSpecializingSignatureAtCallSite = true; + var triedToInferTypeArgs; + + for (var i = 0; i < constructSignatures.length; i++) { + couldNotAssignToConstraint = false; + + if (constructSignatures[i].isGeneric() && !constructSignatures[i].isFixed()) { + if (typeArgs) { + inferredTypeArgs = typeArgs; + } else if (callEx.arguments) { + inferredTypeArgs = this.inferArgumentTypesForSignature(constructSignatures[i], callEx.arguments, new TypeComparisonInfo(), enclosingDecl, context); + triedToInferTypeArgs = true; + } + + if (inferredTypeArgs) { + typeParameters = constructSignatures[i].getTypeParameters(); + + typeReplacementMap = {}; + + if (inferredTypeArgs.length) { + if (inferredTypeArgs.length < typeParameters.length) { + continue; + } + + for (var j = 0; j < typeParameters.length; j++) { + typeReplacementMap[typeParameters[j].pullSymbolIDString] = inferredTypeArgs[j]; + } + for (var j = 0; j < typeParameters.length; j++) { + typeConstraint = typeParameters[j].getConstraint(); + + if (typeConstraint) { + if (typeConstraint.isTypeParameter()) { + for (var k = 0; k < typeParameters.length && k < inferredTypeArgs.length; k++) { + if (typeParameters[k] == typeConstraint) { + typeConstraint = inferredTypeArgs[k]; + } + } + } + if (typeConstraint.isTypeParameter()) { + context.pushTypeSpecializationCache(typeReplacementMap); + typeConstraint = TypeScript.specializeType(typeConstraint, null, this, enclosingDecl, context); + context.popTypeSpecializationCache(); + } + + context.isComparingSpecializedSignatures = true; + if (!this.sourceIsAssignableToTarget(inferredTypeArgs[j], typeConstraint, context)) { + constraintDiagnostic = context.postError(this.unitPath, targetAST.minChar, targetAST.getLength(), TypeScript.DiagnosticCode.Type_0_does_not_satisfy_the_constraint_1_for_type_parameter_2, [inferredTypeArgs[j].toString(null, true), typeConstraint.toString(null, true), typeParameters[j].toString(null, true)], enclosingDecl, false); + couldNotAssignToConstraint = true; + } + context.isComparingSpecializedSignatures = false; + + if (couldNotAssignToConstraint) { + break; + } + } + } + } else { + if (triedToInferTypeArgs) { + if (constructSignatures[i].isFixed()) { + if (!constructSignatures[i].hasAGenericParameter) { + resolvedSignatures[resolvedSignatures.length] = constructSignatures[i]; + } + } else { + continue; + } + } else { + context.specializingToAny = true; + } + } + + if (couldNotAssignToConstraint) { + continue; + } + + context.isSpecializingSignatureAtCallSite = true; + specializedSignature = TypeScript.specializeSignature(constructSignatures[i], false, typeReplacementMap, inferredTypeArgs, this, enclosingDecl, context); + + context.specializingToAny = prevSpecializingToAny; + context.isSpecializingSignatureAtCallSite = prevIsSpecializing; + + if (specializedSignature) { + resolvedSignatures[resolvedSignatures.length] = specializedSignature; + } + } + } else { + if (!(callEx.typeArguments && callEx.typeArguments.members.length)) { + resolvedSignatures[resolvedSignatures.length] = constructSignatures[i]; + } + } + } + + constructSignatures = resolvedSignatures; + } + + var signature = this.resolveOverloads(callEx, constructSignatures, enclosingDecl, callEx.typeArguments != null, context, diagnostics); + + if (additionalResults) { + additionalResults.targetSymbol = targetSymbol; + additionalResults.targetTypeSymbol = targetTypeSymbol; + additionalResults.resolvedSignatures = constructSignatures; + additionalResults.candidateSignature = signature; + additionalResults.actualParametersContextTypeSymbols = []; + } + + if (!constructSignatures.length) { + if (constraintDiagnostic) { + context.postDiagnostic(constraintDiagnostic, enclosingDecl); + } + + return this.getNewErrorTypeSymbol(null); + } + + var errorCondition = null; + + if (!signature) { + for (var i = 0; i < diagnostics.length; i++) { + context.postDiagnostic(diagnostics[i], enclosingDecl); + } + + context.postError(this.unitPath, targetAST.minChar, targetAST.getLength(), TypeScript.DiagnosticCode.Could_not_select_overload_for_new_expression, null, enclosingDecl); + + errorCondition = this.getNewErrorTypeSymbol(null); + + if (!constructSignatures.length) { + return errorCondition; + } + + signature = constructSignatures[0]; + + if (callEx.arguments) { + for (var k = 0, n = callEx.arguments.members.length; k < n; k++) { + var arg = callEx.arguments.members[k]; + var argSymbol = this.getSymbolForAST(arg); + + if (argSymbol) { + var argType = argSymbol.type; + if (arg.nodeType() === 13 /* FunctionDeclaration */) { + if (!this.canApplyContextualTypeToFunction(argType, arg, true)) { + continue; + } + } + + argSymbol.invalidate(); + } + } + } + } + + returnType = signature.returnType; + + if (returnType && !signature.isGeneric() && returnType.isGeneric() && !returnType.getIsSpecialized()) { + if (typeArgs && typeArgs.length) { + returnType = TypeScript.specializeType(returnType, typeArgs, this, enclosingDecl, context, callEx); + } else { + returnType = this.specializeTypeToAny(returnType, enclosingDecl, context); + } + } + + if (usedCallSignaturesInstead) { + if (returnType != this.semanticInfoChain.voidTypeSymbol) { + context.postError(this.unitPath, targetAST.minChar, targetAST.getLength(), TypeScript.DiagnosticCode.Call_signatures_used_in_a_new_expression_must_have_a_void_return_type, null, enclosingDecl); + + return this.getNewErrorTypeSymbol(null); + } else { + returnType = this.semanticInfoChain.anyTypeSymbol; + } + } + + if (!returnType) { + returnType = signature.returnType; + + if (!returnType) { + returnType = targetTypeSymbol; + } + } + + var actualParametersContextTypeSymbols = []; + if (callEx.arguments) { + var len = callEx.arguments.members.length; + var params = signature.parameters; + var contextualType = null; + var signatureDecl = signature.getDeclarations()[0]; + + for (var i = 0; i < len; i++) { + if (params.length) { + if (i < params.length - 1 || (i < params.length && !signature.hasVarArgs)) { + if (typeReplacementMap) { + context.pushTypeSpecializationCache(typeReplacementMap); + } + this.resolveDeclaredSymbol(params[i], signatureDecl, context); + if (typeReplacementMap) { + context.popTypeSpecializationCache(); + } + contextualType = params[i].type; + } else if (signature.hasVarArgs) { + contextualType = params[params.length - 1].type; + if (contextualType.isArray()) { + contextualType = contextualType.getElementType(); + } + } + } + + if (contextualType) { + context.pushContextualType(contextualType, context.inProvisionalResolution(), null); + actualParametersContextTypeSymbols[i] = contextualType; + } + + this.resolveAST(callEx.arguments.members[i], contextualType != null, enclosingDecl, context); + + if (contextualType) { + context.popContextualType(); + contextualType = null; + } + } + } + + if (additionalResults) { + additionalResults.targetSymbol = targetSymbol; + additionalResults.targetTypeSymbol = targetTypeSymbol; + additionalResults.resolvedSignatures = constructSignatures; + additionalResults.candidateSignature = signature; + additionalResults.actualParametersContextTypeSymbols = actualParametersContextTypeSymbols; + } + + if (errorCondition) { + return errorCondition; + } + + if (!returnType) { + returnType = this.semanticInfoChain.anyTypeSymbol; + } + + return returnType; + } else if (targetTypeSymbol.isClass()) { + return returnType; + } + + context.postError(this.unitPath, targetAST.minChar, targetAST.getLength(), TypeScript.DiagnosticCode.Invalid_new_expression, null, enclosingDecl); + + return this.getNewErrorTypeSymbol(null); + }; + + PullTypeResolver.prototype.resolveTypeAssertionExpression = function (assertionExpression, inContextuallyTypedAssignment, enclosingDecl, context) { + var returnType = this.resolveAST(assertionExpression.castTerm, false, enclosingDecl, context).type; + this.setSymbolForAST(assertionExpression, returnType, context); + + if (context.typeCheck()) { + if (returnType.isError()) { + var symbolName = (returnType).getData(); + context.postError(this.unitPath, assertionExpression.minChar, assertionExpression.getLength(), TypeScript.DiagnosticCode.Could_not_find_symbol_0, [symbolName], enclosingDecl); + } + + context.pushContextualType(returnType, context.inProvisionalResolution(), null); + var exprType = this.resolveAST(assertionExpression.operand, true, enclosingDecl, context).type; + context.popContextualType(); + + if (!exprType.isResolved) { + this.resolveDeclaredSymbol(exprType, enclosingDecl, context); + } + + var comparisonInfo = new TypeComparisonInfo(); + + var isAssignable = this.sourceIsAssignableToTarget(returnType, exprType, context, comparisonInfo) || this.sourceIsAssignableToTarget(exprType, returnType, context, comparisonInfo); + + if (!isAssignable) { + var message; + if (comparisonInfo.message) { + context.postError(this.unitPath, assertionExpression.minChar, assertionExpression.getLength(), TypeScript.DiagnosticCode.Cannot_convert_0_to_1_NL_2, [exprType.toString(), returnType.toString(), comparisonInfo.message], enclosingDecl); + } else { + context.postError(this.unitPath, assertionExpression.minChar, assertionExpression.getLength(), TypeScript.DiagnosticCode.Cannot_convert_0_to_1, [exprType.toString(), returnType.toString()], enclosingDecl); + } + } + } + + return returnType; + }; + + PullTypeResolver.prototype.resolveAssignmentStatement = function (binaryExpression, inContextuallyTypedAssignment, enclosingDecl, context) { + var leftExpr = this.resolveAST(binaryExpression.operand1, false, enclosingDecl, context); + var leftType = leftExpr.type; + + leftType = this.widenType(leftExpr.type); + + context.pushContextualType(leftType, context.inProvisionalResolution(), null); + var rightType = this.widenType(this.resolveAST(binaryExpression.operand2, true, enclosingDecl, context).type); + context.popContextualType(); + + rightType = this.getInstanceTypeForAssignment(binaryExpression.operand1, rightType, enclosingDecl, context); + + if (context.typeCheck()) { + if (!this.isValidLHS(binaryExpression.operand1, leftExpr)) { + context.postError(this.unitPath, binaryExpression.operand1.minChar, binaryExpression.operand1.getLength(), TypeScript.DiagnosticCode.Invalid_left_hand_side_of_assignment_expression, null, enclosingDecl); + } + + this.checkAssignability(binaryExpression.operand1, rightType, leftType, enclosingDecl, context); + } + return rightType; + }; + + PullTypeResolver.prototype.computeAssignmentStatementSymbol = function (binex, inContextuallyTypedAssignment, enclosingDecl, context) { + var leftType = this.resolveAST(binex.operand1, inContextuallyTypedAssignment, enclosingDecl, context).type; + + context.pushContextualType(leftType, context.inProvisionalResolution(), null); + this.resolveAST(binex.operand2, true, enclosingDecl, context); + context.popContextualType(); + + return leftType; + }; + + PullTypeResolver.prototype.getInstanceTypeForAssignment = function (lhs, type, enclosingDecl, context) { + var typeToReturn = type; + if (typeToReturn && typeToReturn.isAlias()) { + typeToReturn = (typeToReturn).getExportAssignedTypeSymbol(); + } + + if (typeToReturn && typeToReturn.isContainer()) { + var instanceTypeSymbol = (typeToReturn).getInstanceType(); + + if (!instanceTypeSymbol) { + context.postError(this.unitPath, lhs.minChar, lhs.getLength(), TypeScript.DiagnosticCode.Tried_to_set_variable_type_to_uninitialized_module_type_0, [type.toString()], enclosingDecl); + typeToReturn = null; + } else { + typeToReturn = instanceTypeSymbol; + } + } + + return typeToReturn; + }; + + PullTypeResolver.prototype.resolveBoundDecls = function (decl, context) { + if (!decl) { + return; + } + + switch (decl.kind) { + case 1 /* Script */: + var childDecls = decl.getChildDecls(); + for (var i = 0; i < childDecls.length; i++) { + this.resolveBoundDecls(childDecls[i], context); + } + break; + case 32 /* DynamicModule */: + case 4 /* Container */: + case 64 /* Enum */: + var moduleDecl = this.semanticInfoChain.getASTForDecl(decl); + this.resolveModuleDeclaration(moduleDecl, context); + break; + case 16 /* Interface */: + var interfaceDecl = this.semanticInfoChain.getASTForDecl(decl); + this.resolveInterfaceDeclaration(interfaceDecl, context); + break; + case 8 /* Class */: + var classDecl = this.semanticInfoChain.getASTForDecl(decl); + this.resolveClassDeclaration(classDecl, context); + break; + case 65536 /* Method */: + case 16384 /* Function */: + var funcDecl = this.semanticInfoChain.getASTForDecl(decl); + this.resolveFunctionDeclaration(funcDecl, context); + break; + case 262144 /* GetAccessor */: + funcDecl = this.semanticInfoChain.getASTForDecl(decl); + this.resolveGetAccessorDeclaration(funcDecl, context); + break; + case 524288 /* SetAccessor */: + funcDecl = this.semanticInfoChain.getASTForDecl(decl); + this.resolveSetAccessorDeclaration(funcDecl, context); + break; + case 4096 /* Property */: + case 1024 /* Variable */: + case 2048 /* Parameter */: + var varDecl = this.semanticInfoChain.getASTForDecl(decl); + + if (varDecl) { + this.resolveVariableDeclaration(varDecl, context); + } + break; + } + }; + + PullTypeResolver.prototype.mergeOrdered = function (a, b, context, comparisonInfo) { + if (this.isAnyOrEquivalent(a) || this.isAnyOrEquivalent(b)) { + return this.semanticInfoChain.anyTypeSymbol; + } else if (a === b) { + return a; + } else if ((b === this.semanticInfoChain.nullTypeSymbol) && a != this.semanticInfoChain.nullTypeSymbol) { + return a; + } else if ((a === this.semanticInfoChain.nullTypeSymbol) && (b != this.semanticInfoChain.nullTypeSymbol)) { + return b; + } else if ((a === this.semanticInfoChain.voidTypeSymbol) && (b === this.semanticInfoChain.voidTypeSymbol || b === this.semanticInfoChain.undefinedTypeSymbol || b === this.semanticInfoChain.nullTypeSymbol)) { + return a; + } else if ((a === this.semanticInfoChain.voidTypeSymbol) && (b === this.semanticInfoChain.anyTypeSymbol)) { + return b; + } else if ((b === this.semanticInfoChain.undefinedTypeSymbol) && a != this.semanticInfoChain.voidTypeSymbol) { + return a; + } else if ((a === this.semanticInfoChain.undefinedTypeSymbol) && (b != this.semanticInfoChain.undefinedTypeSymbol)) { + return b; + } else if (a.isTypeParameter() && !b.isTypeParameter()) { + return b; + } else if (!a.isTypeParameter() && b.isTypeParameter()) { + return a; + } else if (a.isArray() && b.isArray()) { + if (a.getElementType() === b.getElementType()) { + return a; + } else { + var mergedET = this.mergeOrdered(a.getElementType(), b.getElementType(), context, comparisonInfo); + if (mergedET) { + var mergedArrayType = mergedET.getArrayType(); + + if (!mergedArrayType) { + mergedArrayType = TypeScript.specializeType(this.cachedArrayInterfaceType(), [mergedET], this, this.cachedArrayInterfaceType().getDeclarations()[0], context); + } + + return mergedArrayType; + } + } + } else if (this.sourceIsSubtypeOfTarget(a, b, context, comparisonInfo)) { + return b; + } else if (this.sourceIsSubtypeOfTarget(b, a, context, comparisonInfo)) { + return a; + } + + return null; + }; + + PullTypeResolver.prototype.widenType = function (type) { + if (type === this.semanticInfoChain.undefinedTypeSymbol || type === this.semanticInfoChain.nullTypeSymbol || type.isError()) { + return this.semanticInfoChain.anyTypeSymbol; + } + + return type; + }; + + PullTypeResolver.prototype.isNullOrUndefinedType = function (type) { + return type === this.semanticInfoChain.nullTypeSymbol || type === this.semanticInfoChain.undefinedTypeSymbol; + }; + + PullTypeResolver.prototype.canApplyContextualType = function (type) { + if (!type) { + return true; + } + + var kind = type.kind; + + if ((kind & 8388608 /* ObjectType */) != 0) { + return true; + } + if ((kind & 16 /* Interface */) != 0) { + return true; + } else if ((kind & TypeScript.PullElementKind.SomeFunction) != 0) { + return this.canApplyContextualTypeToFunction(type, this.semanticInfoChain.getASTForDecl(type.getDeclarations[0]), true); + } else if ((kind & 128 /* Array */) != 0) { + return true; + } else if (type == this.semanticInfoChain.anyTypeSymbol || kind != 2 /* Primitive */) { + return true; + } + + return false; + }; + + PullTypeResolver.prototype.findBestCommonType = function (initialType, targetType, collection, context, comparisonInfo) { + var len = collection.getLength(); + var nlastChecked = 0; + var bestCommonType = initialType; + + if (targetType && this.canApplyContextualType(bestCommonType)) { + if (bestCommonType) { + bestCommonType = this.mergeOrdered(bestCommonType, targetType, context); + } else { + bestCommonType = targetType; + } + } + + var convergenceType = bestCommonType; + + while (nlastChecked < len) { + for (var i = 0; i < len; i++) { + if (i === nlastChecked) { + continue; + } + + if (convergenceType && (bestCommonType = this.mergeOrdered(convergenceType, collection.getTypeAtIndex(i), context, comparisonInfo))) { + convergenceType = bestCommonType; + } + + if (bestCommonType === null || this.isAnyOrEquivalent(bestCommonType)) { + break; + } else if (targetType && !(bestCommonType.isTypeParameter() || targetType.isTypeParameter())) { + collection.setTypeAtIndex(i, targetType); + } + } + + if (convergenceType && bestCommonType) { + break; + } + + nlastChecked++; + if (nlastChecked < len) { + convergenceType = collection.getTypeAtIndex(nlastChecked); + } + } + + if (!bestCommonType) { + var emptyTypeDecl = new TypeScript.PullDecl("{}", "{}", 8388608 /* ObjectType */, 0 /* None */, new TypeScript.TextSpan(0, 0), this.currentUnit.getPath()); + var emptyType = new TypeScript.PullTypeSymbol("{}", 8388608 /* ObjectType */); + + emptyTypeDecl.setSymbol(emptyType); + emptyType.addDeclaration(emptyTypeDecl); + + bestCommonType = emptyType; + } + + return bestCommonType; + }; + + PullTypeResolver.prototype.typesAreIdentical = function (t1, t2, val) { + if (t1 === t2) { + return true; + } + + if (!t1 || !t2) { + return false; + } + + if (val && t1.isPrimitive() && (t1).isStringConstant() && t2 === this.semanticInfoChain.stringTypeSymbol) { + return (val.nodeType() === 5 /* StringLiteral */) && (TypeScript.stripQuotes((val).actualText) === TypeScript.stripQuotes(t1.name)); + } + + if (val && t2.isPrimitive() && (t2).isStringConstant() && t2 === this.semanticInfoChain.stringTypeSymbol) { + return (val.nodeType() === 5 /* StringLiteral */) && (TypeScript.stripQuotes((val).actualText) === TypeScript.stripQuotes(t2.name)); + } + + if (t1.isPrimitive() && (t1).isStringConstant() && t2.isPrimitive() && (t2).isStringConstant()) { + return TypeScript.stripQuotes(t1.name) === TypeScript.stripQuotes(t2.name); + } + + if (t1.isPrimitive() || t2.isPrimitive()) { + return false; + } + + if (t1.isClass()) { + return false; + } + + if (t1.isError() && t2.isError()) { + return true; + } + + if (t1.isTypeParameter()) { + if (!t2.isTypeParameter()) { + return false; + } + + var t1ParentDeclaration = t1.getDeclarations()[0].getParentDecl(); + var t2ParentDeclaration = t2.getDeclarations()[0].getParentDecl(); + + if (t1ParentDeclaration === t2ParentDeclaration) { + return this.symbolsShareDeclaration(t1, t2); + } else { + return true; + } + } + + var comboId = t2.pullSymbolIDString + "#" + t1.pullSymbolIDString; + + if (this.identicalCache[comboId] != undefined) { + return true; + } + + if ((t1.kind & 64 /* Enum */) || (t2.kind & 64 /* Enum */)) { + return t1.getAssociatedContainerType() === t2 || t2.getAssociatedContainerType() === t1; + } + + if (t1.isArray() || t2.isArray()) { + if (!(t1.isArray() && t2.isArray())) { + return false; + } + this.identicalCache[comboId] = false; + var ret = this.typesAreIdentical(t1.getElementType(), t2.getElementType()); + if (ret) { + this.identicalCache[comboId] = true; + } else { + this.identicalCache[comboId] = undefined; + } + + return ret; + } + + if (t1.isPrimitive() != t2.isPrimitive()) { + return false; + } + + this.identicalCache[comboId] = false; + + if (t1.hasMembers() && t2.hasMembers()) { + var t1Members = t1.getMembers(); + var t2Members = t2.getMembers(); + + if (t1Members.length != t2Members.length) { + this.identicalCache[comboId] = undefined; + return false; + } + + var t1MemberSymbol = null; + var t2MemberSymbol = null; + + var t1MemberType = null; + var t2MemberType = null; + + for (var iMember = 0; iMember < t1Members.length; iMember++) { + t1MemberSymbol = t1Members[iMember]; + t2MemberSymbol = this.getMemberSymbol(t1MemberSymbol.name, TypeScript.PullElementKind.SomeValue, t2); + + if (!t2MemberSymbol || (t1MemberSymbol.isOptional != t2MemberSymbol.isOptional)) { + this.identicalCache[comboId] = undefined; + return false; + } + + t1MemberType = t1MemberSymbol.type; + t2MemberType = t2MemberSymbol.type; + + if (t1MemberType && t2MemberType && (this.identicalCache[t2MemberType.pullSymbolIDString + "#" + t1MemberType.pullSymbolIDString] != undefined)) { + continue; + } + + if (!this.typesAreIdentical(t1MemberType, t2MemberType)) { + this.identicalCache[comboId] = undefined; + return false; + } + } + } else if (t1.hasMembers() || t2.hasMembers()) { + this.identicalCache[comboId] = undefined; + return false; + } + + var t1CallSigs = t1.getCallSignatures(); + var t2CallSigs = t2.getCallSignatures(); + + var t1ConstructSigs = t1.getConstructSignatures(); + var t2ConstructSigs = t2.getConstructSignatures(); + + var t1IndexSigs = t1.getIndexSignatures(); + var t2IndexSigs = t2.getIndexSignatures(); + + if (!this.signatureGroupsAreIdentical(t1CallSigs, t2CallSigs)) { + this.identicalCache[comboId] = undefined; + return false; + } + + if (!this.signatureGroupsAreIdentical(t1ConstructSigs, t2ConstructSigs)) { + this.identicalCache[comboId] = undefined; + return false; + } + + if (!this.signatureGroupsAreIdentical(t1IndexSigs, t2IndexSigs)) { + this.identicalCache[comboId] = undefined; + return false; + } + + this.identicalCache[comboId] = true; + return true; + }; + + PullTypeResolver.prototype.signatureGroupsAreIdentical = function (sg1, sg2) { + if (sg1 === sg2) { + return true; + } + + if (!sg1 || !sg2) { + return false; + } + + if (sg1.length != sg2.length) { + return false; + } + + var sig1 = null; + var sig2 = null; + var sigsMatch = false; + + for (var iSig1 = 0; iSig1 < sg1.length; iSig1++) { + sig1 = sg1[iSig1]; + + for (var iSig2 = 0; iSig2 < sg2.length; iSig2++) { + sig2 = sg2[iSig2]; + + if (this.signaturesAreIdentical(sig1, sig2)) { + sigsMatch = true; + break; + } + } + + if (sigsMatch) { + sigsMatch = false; + continue; + } + + return false; + } + + return true; + }; + + PullTypeResolver.prototype.signaturesAreIdentical = function (s1, s2, includingReturnType) { + if (typeof includingReturnType === "undefined") { includingReturnType = true; } + if (s1.hasVarArgs != s2.hasVarArgs) { + return false; + } + + if (s1.nonOptionalParamCount != s2.nonOptionalParamCount) { + return false; + } + + if (s1.typeParameters && s2.typeParameters && (s1.typeParameters.length != s2.typeParameters.length)) { + return false; + } + + var s1Params = s1.parameters; + var s2Params = s2.parameters; + + if (s1Params.length != s2Params.length) { + return false; + } + + if (includingReturnType && !this.typesAreIdentical(s1.returnType, s2.returnType)) { + return false; + } + + for (var iParam = 0; iParam < s1Params.length; iParam++) { + if (!this.typesAreIdentical(s1Params[iParam].type, s2Params[iParam].type)) { + return false; + } + } + + return true; + }; + + PullTypeResolver.prototype.substituteUpperBoundForType = function (type) { + if (!type || !type.isTypeParameter()) { + return type; + } + + var constraint = (type).getConstraint(); + + if (constraint) { + return this.substituteUpperBoundForType(constraint); + } + + if (this.cachedObjectInterfaceType()) { + return this.cachedObjectInterfaceType(); + } + + return type; + }; + + PullTypeResolver.prototype.symbolsShareDeclaration = function (symbol1, symbol2) { + var decls1 = symbol1.getDeclarations(); + var decls2 = symbol2.getDeclarations(); + + if (decls1.length && decls2.length) { + return decls1[0].isEqual(decls2[0]); + } + + return false; + }; + + PullTypeResolver.prototype.sourceExtendsTarget = function (source, target, context) { + if (source.isGeneric() != target.isGeneric()) { + return false; + } + + if (source.hasBase(target)) { + return true; + } + + if (context.isInBaseTypeResolution() && (source.kind & (16 /* Interface */ | 8 /* Class */)) && (target.kind & (16 /* Interface */ | 8 /* Class */))) { + var sourceDecls = source.getDeclarations(); + var sourceAST = null; + var extendsSymbol = null; + var extendsList = null; + + for (var i = 0; i < sourceDecls.length; i++) { + sourceAST = this.semanticInfoChain.getASTForDecl(sourceDecls[i]); + extendsList = sourceAST.extendsList; + + if (extendsList && extendsList.members && extendsList.members.length) { + for (var j = 0; j < extendsList.members.length; j++) { + extendsSymbol = this.semanticInfoChain.getSymbolForAST(extendsList.members[j], sourceDecls[i].getScriptName()); + + if (extendsSymbol == target || this.sourceExtendsTarget(extendsSymbol, target, context)) { + return true; + } + } + } + } + + return false; + } + }; + + PullTypeResolver.prototype.sourceIsSubtypeOfTarget = function (source, target, context, comparisonInfo) { + return this.sourceIsRelatableToTarget(source, target, false, this.subtypeCache, context, comparisonInfo); + }; + + PullTypeResolver.prototype.sourceMembersAreSubtypeOfTargetMembers = function (source, target, context, comparisonInfo) { + return this.sourceMembersAreRelatableToTargetMembers(source, target, false, this.subtypeCache, context, comparisonInfo); + }; + + PullTypeResolver.prototype.sourcePropertyIsSubtypeOfTargetProperty = function (source, target, sourceProp, targetProp, context, comparisonInfo) { + return this.sourcePropertyIsRelatableToTargetProperty(source, target, sourceProp, targetProp, false, this.subtypeCache, context, comparisonInfo); + }; + + PullTypeResolver.prototype.sourceCallSignaturesAreSubtypeOfTargetCallSignatures = function (source, target, context, comparisonInfo) { + return this.sourceCallSignaturesAreRelatableToTargetCallSignatures(source, target, false, this.subtypeCache, context, comparisonInfo); + }; + + PullTypeResolver.prototype.sourceConstructSignaturesAreSubtypeOfTargetConstructSignatures = function (source, target, context, comparisonInfo) { + return this.sourceConstructSignaturesAreRelatableToTargetConstructSignatures(source, target, false, this.subtypeCache, context, comparisonInfo); + }; + + PullTypeResolver.prototype.sourceIndexSignaturesAreSubtypeOfTargetIndexSignatures = function (source, target, context, comparisonInfo) { + return this.sourceIndexSignaturesAreRelatableToTargetIndexSignatures(source, target, false, this.subtypeCache, context, comparisonInfo); + }; + + PullTypeResolver.prototype.typeIsSubtypeOfFunction = function (source, context) { + var callSignatures = source.getCallSignatures(); + + if (callSignatures.length) { + return true; + } + + var constructSignatures = source.getConstructSignatures(); + + if (constructSignatures.length) { + return true; + } + + if (this.cachedFunctionInterfaceType()) { + return this.sourceIsSubtypeOfTarget(source, this.cachedFunctionInterfaceType(), context); + } + + return false; + }; + + PullTypeResolver.prototype.signatureGroupIsSubtypeOfTarget = function (sg1, sg2, context, comparisonInfo) { + return this.signatureGroupIsRelatableToTarget(sg1, sg2, false, this.subtypeCache, context, comparisonInfo); + }; + + PullTypeResolver.prototype.signatureIsSubtypeOfTarget = function (s1, s2, context, comparisonInfo) { + return this.signatureIsRelatableToTarget(s1, s2, false, this.subtypeCache, context, comparisonInfo); + }; + + PullTypeResolver.prototype.sourceIsAssignableToTarget = function (source, target, context, comparisonInfo, isInProvisionalResolution) { + if (typeof isInProvisionalResolution === "undefined") { isInProvisionalResolution = false; } + var cache = isInProvisionalResolution ? {} : this.assignableCache; + return this.sourceIsRelatableToTarget(source, target, true, cache, context, comparisonInfo); + }; + + PullTypeResolver.prototype.signatureGroupIsAssignableToTarget = function (sg1, sg2, context, comparisonInfo) { + return this.signatureGroupIsRelatableToTarget(sg1, sg2, true, this.assignableCache, context, comparisonInfo); + }; + + PullTypeResolver.prototype.signatureIsAssignableToTarget = function (s1, s2, context, comparisonInfo) { + return this.signatureIsRelatableToTarget(s1, s2, true, this.assignableCache, context, comparisonInfo); + }; + + PullTypeResolver.prototype.sourceIsRelatableToTarget = function (source, target, assignableTo, comparisonCache, context, comparisonInfo) { + if (source === target) { + return true; + } + + if (!(source && target)) { + return true; + } + + if (context.specializingToAny && (target.isTypeParameter() || source.isTypeParameter())) { + return true; + } + + if (context.specializingToObject) { + if (target.isTypeParameter()) { + target = this.cachedObjectInterfaceType(); + } + if (source.isTypeParameter()) { + target = this.cachedObjectInterfaceType(); + } + } + + var sourceSubstitution = source; + + if (source == this.semanticInfoChain.stringTypeSymbol && this.cachedStringInterfaceType()) { + if (!this.cachedStringInterfaceType().isResolved) { + this.resolveDeclaredSymbol(this.cachedStringInterfaceType(), null, context); + } + sourceSubstitution = this.cachedStringInterfaceType(); + } else if (source == this.semanticInfoChain.numberTypeSymbol && this.cachedNumberInterfaceType()) { + if (!this.cachedNumberInterfaceType().isResolved) { + this.resolveDeclaredSymbol(this.cachedNumberInterfaceType(), null, context); + } + sourceSubstitution = this.cachedNumberInterfaceType(); + } else if (source == this.semanticInfoChain.booleanTypeSymbol && this.cachedBooleanInterfaceType()) { + if (!this.cachedBooleanInterfaceType().isResolved) { + this.resolveDeclaredSymbol(this.cachedBooleanInterfaceType(), null, context); + } + sourceSubstitution = this.cachedBooleanInterfaceType(); + } else if (TypeScript.PullHelpers.symbolIsEnum(source) && this.cachedNumberInterfaceType()) { + sourceSubstitution = this.cachedNumberInterfaceType(); + } else if (source.isTypeParameter()) { + sourceSubstitution = this.substituteUpperBoundForType(source); + } + + var comboId = source.pullSymbolIDString + "#" + target.pullSymbolIDString; + + if (comparisonCache[comboId] != undefined) { + return true; + } + + if (assignableTo) { + if (this.isAnyOrEquivalent(source) || this.isAnyOrEquivalent(target)) { + return true; + } + + if (source === this.semanticInfoChain.stringTypeSymbol && target.isPrimitive() && (target).isStringConstant()) { + return comparisonInfo && comparisonInfo.stringConstantVal && (comparisonInfo.stringConstantVal.nodeType() === 5 /* StringLiteral */) && (TypeScript.stripQuotes((comparisonInfo.stringConstantVal).actualText) === TypeScript.stripQuotes(target.name)); + } + } else { + if (this.isAnyOrEquivalent(target)) { + return true; + } + + if (target === this.semanticInfoChain.stringTypeSymbol && source.isPrimitive() && (source).isStringConstant()) { + return true; + } + } + + if (source.isPrimitive() && (source).isStringConstant() && target.isPrimitive() && (target).isStringConstant()) { + return TypeScript.stripQuotes(source.name) === TypeScript.stripQuotes(target.name); + } + + if (source === this.semanticInfoChain.undefinedTypeSymbol) { + return true; + } + + if ((source === this.semanticInfoChain.nullTypeSymbol) && (target != this.semanticInfoChain.undefinedTypeSymbol && target != this.semanticInfoChain.voidTypeSymbol)) { + return true; + } + + if (target == this.semanticInfoChain.voidTypeSymbol) { + if (source == this.semanticInfoChain.anyTypeSymbol || source == this.semanticInfoChain.undefinedTypeSymbol || source == this.semanticInfoChain.nullTypeSymbol) { + return true; + } + + return false; + } else if (source == this.semanticInfoChain.voidTypeSymbol) { + if (target == this.semanticInfoChain.anyTypeSymbol) { + return true; + } + + return false; + } + + if (target === this.semanticInfoChain.numberTypeSymbol && TypeScript.PullHelpers.symbolIsEnum(source)) { + return true; + } + + if (source === this.semanticInfoChain.numberTypeSymbol && TypeScript.PullHelpers.symbolIsEnum(target)) { + return true; + } + + if (TypeScript.PullHelpers.symbolIsEnum(target) && TypeScript.PullHelpers.symbolIsEnum(source)) { + return this.symbolsShareDeclaration(target, source); + } + + if ((source.kind & 64 /* Enum */) || (target.kind & 64 /* Enum */)) { + return false; + } + + if (source.isArray() && target.isArray()) { + comparisonCache[comboId] = false; + var ret = this.sourceIsRelatableToTarget(source.getElementType(), target.getElementType(), assignableTo, comparisonCache, context, comparisonInfo); + if (ret) { + comparisonCache[comboId] = true; + } else { + comparisonCache[comboId] = undefined; + } + + return ret; + } else if (source.isArray() && target == this.cachedArrayInterfaceType()) { + return true; + } else if (target.isArray() && source == this.cachedArrayInterfaceType()) { + return true; + } + + if (source.isPrimitive() && target.isPrimitive()) { + return false; + } else if (source.isPrimitive() != target.isPrimitive()) { + if (target.isPrimitive()) { + return false; + } + } + + if (target.isTypeParameter()) { + if (source.isTypeParameter() && (source == sourceSubstitution)) { + var targetParentDeclaration = target.getDeclarations()[0].getParentDecl(); + var sourceParentDeclaration = source.getDeclarations()[0].getParentDecl(); + + if (targetParentDeclaration !== sourceParentDeclaration) { + return this.symbolsShareDeclaration(target, source); + } else { + return true; + } + } else { + if (context.isComparingSpecializedSignatures) { + target = this.substituteUpperBoundForType(target); + } else { + return false; + } + } + } + + comparisonCache[comboId] = false; + + if (this.sourceExtendsTarget(source, target, context)) { + return true; + } + + if (this.cachedObjectInterfaceType() && target === this.cachedObjectInterfaceType()) { + return true; + } + + if (this.cachedFunctionInterfaceType() && (sourceSubstitution.getCallSignatures().length || sourceSubstitution.getConstructSignatures().length) && target === this.cachedFunctionInterfaceType()) { + return true; + } + + if (target.hasMembers() && !this.sourceMembersAreRelatableToTargetMembers(sourceSubstitution, target, assignableTo, comparisonCache, context, comparisonInfo)) { + comparisonCache[comboId] = undefined; + return false; + } + + if (!this.sourceCallSignaturesAreRelatableToTargetCallSignatures(sourceSubstitution, target, assignableTo, comparisonCache, context, comparisonInfo)) { + comparisonCache[comboId] = undefined; + return false; + } + + if (!this.sourceConstructSignaturesAreRelatableToTargetConstructSignatures(sourceSubstitution, target, assignableTo, comparisonCache, context, comparisonInfo)) { + comparisonCache[comboId] = undefined; + return false; + } + + if (!this.sourceIndexSignaturesAreRelatableToTargetIndexSignatures(sourceSubstitution, target, assignableTo, comparisonCache, context, comparisonInfo)) { + comparisonCache[comboId] = undefined; + return false; + } + + comparisonCache[comboId] = true; + return true; + }; + + PullTypeResolver.prototype.sourceMembersAreRelatableToTargetMembers = function (source, target, assignableTo, comparisonCache, context, comparisonInfo) { + var targetProps = target.getAllMembers(TypeScript.PullElementKind.SomeValue, true); + + for (var itargetProp = 0; itargetProp < targetProps.length; itargetProp++) { + var targetProp = targetProps[itargetProp]; + var sourceProp = this.getMemberSymbol(targetProp.name, TypeScript.PullElementKind.SomeValue, source); + + if (!targetProp.isResolved) { + this.resolveDeclaredSymbol(targetProp, null, context); + } + + var targetPropType = targetProp.type; + + if (!sourceProp) { + if (this.cachedObjectInterfaceType()) { + sourceProp = this.getMemberSymbol(targetProp.name, TypeScript.PullElementKind.SomeValue, this.cachedObjectInterfaceType()); + } + + if (!sourceProp) { + if (this.cachedFunctionInterfaceType() && (targetPropType.getCallSignatures().length || targetPropType.getConstructSignatures().length)) { + sourceProp = this.getMemberSymbol(targetProp.name, TypeScript.PullElementKind.SomeValue, this.cachedFunctionInterfaceType()); + } + + if (!sourceProp) { + if (!(targetProp.isOptional)) { + if (comparisonInfo) { + comparisonInfo.flags |= 2 /* RequiredPropertyIsMissing */; + comparisonInfo.addMessage(TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Type_0_is_missing_property_1_from_type_2, [source.toString(), targetProp.getScopedNameEx().toString(), target.toString()])); + } + return false; + } + continue; + } + } + } + + if (!this.sourcePropertyIsRelatableToTargetProperty(source, target, sourceProp, targetProp, assignableTo, comparisonCache, context, comparisonInfo)) { + return false; + } + } + + return true; + }; + + PullTypeResolver.prototype.sourcePropertyIsRelatableToTargetProperty = function (source, target, sourceProp, targetProp, assignableTo, comparisonCache, context, comparisonInfo) { + var targetPropIsPrivate = targetProp.hasFlag(2 /* Private */); + var sourcePropIsPrivate = sourceProp.hasFlag(2 /* Private */); + + if (targetPropIsPrivate != sourcePropIsPrivate) { + if (comparisonInfo) { + if (targetPropIsPrivate) { + comparisonInfo.addMessage(TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Property_0_defined_as_public_in_type_1_is_defined_as_private_in_type_2, [targetProp.getScopedNameEx().toString(), sourceProp.getContainer().toString(), targetProp.getContainer().toString()])); + } else { + comparisonInfo.addMessage(TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Property_0_defined_as_private_in_type_1_is_defined_as_public_in_type_2, [targetProp.getScopedNameEx().toString(), sourceProp.getContainer().toString(), targetProp.getContainer().toString()])); + } + comparisonInfo.flags |= 128 /* InconsistantPropertyAccesibility */; + } + return false; + } else if (sourcePropIsPrivate && targetPropIsPrivate) { + var targetDecl = targetProp.getDeclarations()[0]; + var sourceDecl = sourceProp.getDeclarations()[0]; + + if (!targetDecl.isEqual(sourceDecl)) { + if (comparisonInfo) { + comparisonInfo.flags |= 128 /* InconsistantPropertyAccesibility */; + comparisonInfo.addMessage(TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Types_0_and_1_define_property_2_as_private, [sourceProp.getContainer().toString(), targetProp.getContainer().toString(), targetProp.getScopedNameEx().toString()])); + } + + return false; + } + } + + if (!sourceProp.isResolved) { + this.resolveDeclaredSymbol(sourceProp, null, context); + } + + var sourcePropType = sourceProp.type; + var targetPropType = targetProp.type; + + if (targetPropType && sourcePropType && (comparisonCache[sourcePropType.pullSymbolIDString + "#" + targetPropType.pullSymbolIDString] != undefined)) { + return true; + } + + var comparisonInfoPropertyTypeCheck = null; + if (comparisonInfo && !comparisonInfo.onlyCaptureFirstError) { + comparisonInfoPropertyTypeCheck = new TypeComparisonInfo(comparisonInfo); + } + if (!this.sourceIsRelatableToTarget(sourcePropType, targetPropType, assignableTo, comparisonCache, context, comparisonInfoPropertyTypeCheck)) { + if (comparisonInfo) { + comparisonInfo.flags |= 32 /* IncompatiblePropertyTypes */; + var message; + if (comparisonInfoPropertyTypeCheck && comparisonInfoPropertyTypeCheck.message) { + message = TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Types_of_property_0_of_types_1_and_2_are_incompatible_NL_3, [targetProp.getScopedNameEx().toString(), source.toString(), target.toString(), comparisonInfoPropertyTypeCheck.message]); + } else { + message = TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Types_of_property_0_of_types_1_and_2_are_incompatible, [targetProp.getScopedNameEx().toString(), source.toString(), target.toString()]); + } + comparisonInfo.addMessage(message); + } + + return false; + } + + return true; + }; + + PullTypeResolver.prototype.sourceCallSignaturesAreRelatableToTargetCallSignatures = function (source, target, assignableTo, comparisonCache, context, comparisonInfo) { + var targetCallSigs = target.getCallSignatures(); + + if (targetCallSigs.length) { + var comparisonInfoSignatuesTypeCheck = null; + if (comparisonInfo && !comparisonInfo.onlyCaptureFirstError) { + comparisonInfoSignatuesTypeCheck = new TypeComparisonInfo(comparisonInfo); + } + + var sourceCallSigs = source.getCallSignatures(); + if (!this.signatureGroupIsRelatableToTarget(sourceCallSigs, targetCallSigs, assignableTo, comparisonCache, context, comparisonInfoSignatuesTypeCheck)) { + if (comparisonInfo) { + var message; + if (sourceCallSigs.length && targetCallSigs.length) { + if (comparisonInfoSignatuesTypeCheck && comparisonInfoSignatuesTypeCheck.message) { + message = TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Call_signatures_of_types_0_and_1_are_incompatible_NL_2, [source.toString(), target.toString(), comparisonInfoSignatuesTypeCheck.message]); + } else { + message = TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Call_signatures_of_types_0_and_1_are_incompatible, [source.toString(), target.toString()]); + } + } else { + var hasSig = targetCallSigs.length ? target.toString() : source.toString(); + var lacksSig = !targetCallSigs.length ? target.toString() : source.toString(); + message = TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Type_0_requires_a_call_signature_but_type_1_lacks_one, [hasSig, lacksSig]); + } + comparisonInfo.flags |= 4 /* IncompatibleSignatures */; + comparisonInfo.addMessage(message); + } + return false; + } + } + + return true; + }; + + PullTypeResolver.prototype.sourceConstructSignaturesAreRelatableToTargetConstructSignatures = function (source, target, assignableTo, comparisonCache, context, comparisonInfo) { + var targetConstructSigs = target.getConstructSignatures(); + if (targetConstructSigs.length) { + var comparisonInfoSignatuesTypeCheck = null; + if (comparisonInfo && !comparisonInfo.onlyCaptureFirstError) { + comparisonInfoSignatuesTypeCheck = new TypeComparisonInfo(comparisonInfo); + } + + var sourceConstructSigs = source.getConstructSignatures(); + if (!this.signatureGroupIsRelatableToTarget(sourceConstructSigs, targetConstructSigs, assignableTo, comparisonCache, context, comparisonInfoSignatuesTypeCheck)) { + if (comparisonInfo) { + var message; + if (sourceConstructSigs.length && targetConstructSigs.length) { + if (comparisonInfoSignatuesTypeCheck && comparisonInfoSignatuesTypeCheck.message) { + message = TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Construct_signatures_of_types_0_and_1_are_incompatible_NL_2, [source.toString(), target.toString(), comparisonInfoSignatuesTypeCheck.message]); + } else { + message = TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Construct_signatures_of_types_0_and_1_are_incompatible, [source.toString(), target.toString()]); + } + } else { + var hasSig = targetConstructSigs.length ? target.toString() : source.toString(); + var lacksSig = !targetConstructSigs.length ? target.toString() : source.toString(); + message = TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Type_0_requires_a_construct_signature_but_type_1_lacks_one, [hasSig, lacksSig]); + } + comparisonInfo.flags |= 4 /* IncompatibleSignatures */; + comparisonInfo.addMessage(message); + } + return false; + } + } + + return true; + }; + + PullTypeResolver.prototype.sourceIndexSignaturesAreRelatableToTargetIndexSignatures = function (source, target, assignableTo, comparisonCache, context, comparisonInfo) { + var targetIndexSigs = target.getIndexSignatures(); + + if (targetIndexSigs.length) { + var sourceIndexSigs = source.getIndexSignatures(); + + var targetIndex = !targetIndexSigs.length && this.cachedObjectInterfaceType() ? this.cachedObjectInterfaceType().getIndexSignatures() : targetIndexSigs; + var sourceIndex = !sourceIndexSigs.length && this.cachedObjectInterfaceType() ? this.cachedObjectInterfaceType().getIndexSignatures() : sourceIndexSigs; + + var sourceStringSig = null; + var sourceNumberSig = null; + + var targetStringSig = null; + var targetNumberSig = null; + + var params; + + for (var i = 0; i < targetIndex.length; i++) { + if (targetStringSig && targetNumberSig) { + break; + } + + params = targetIndex[i].parameters; + + if (params.length) { + if (!targetStringSig && params[0].type === this.semanticInfoChain.stringTypeSymbol) { + targetStringSig = targetIndex[i]; + continue; + } else if (!targetNumberSig && params[0].type === this.semanticInfoChain.numberTypeSymbol) { + targetNumberSig = targetIndex[i]; + continue; + } + } + } + + for (var i = 0; i < sourceIndex.length; i++) { + if (sourceStringSig && sourceNumberSig) { + break; + } + + params = sourceIndex[i].parameters; + + if (params.length) { + if (!sourceStringSig && params[0].type === this.semanticInfoChain.stringTypeSymbol) { + sourceStringSig = sourceIndex[i]; + continue; + } else if (!sourceNumberSig && params[0].type === this.semanticInfoChain.numberTypeSymbol) { + sourceNumberSig = sourceIndex[i]; + continue; + } + } + } + + var comparable = true; + var comparisonInfoSignatuesTypeCheck = null; + if (comparisonInfo && !comparisonInfo.onlyCaptureFirstError) { + comparisonInfoSignatuesTypeCheck = new TypeComparisonInfo(comparisonInfo); + } + + if (targetStringSig) { + if (sourceStringSig) { + comparable = this.signatureIsAssignableToTarget(sourceStringSig, targetStringSig, context, comparisonInfoSignatuesTypeCheck); + } else { + comparable = false; + } + } + + if (comparable && targetNumberSig) { + if (sourceNumberSig) { + comparable = this.signatureIsAssignableToTarget(sourceNumberSig, targetNumberSig, context, comparisonInfoSignatuesTypeCheck); + } else if (sourceStringSig) { + comparable = this.sourceIsAssignableToTarget(sourceStringSig.returnType, targetNumberSig.returnType, context, comparisonInfoSignatuesTypeCheck); + } else { + comparable = false; + } + } + + if (!comparable) { + if (comparisonInfo) { + var message; + if (comparisonInfoSignatuesTypeCheck && comparisonInfoSignatuesTypeCheck.message) { + message = TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Index_signatures_of_types_0_and_1_are_incompatible_NL_2, [source.toString(), target.toString(), comparisonInfoSignatuesTypeCheck.message]); + } else { + message = TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Index_signatures_of_types_0_and_1_are_incompatible, [source.toString(), target.toString()]); + } + comparisonInfo.flags |= 4 /* IncompatibleSignatures */; + comparisonInfo.addMessage(message); + } + return false; + } + } + + if (targetStringSig && !source.isNamedTypeSymbol() && source.hasMembers()) { + var targetReturnType = targetStringSig.returnType; + var sourceMembers = source.getMembers(); + + for (var i = 0; i < sourceMembers.length; i++) { + if (!this.sourceIsRelatableToTarget(sourceMembers[i].type, targetReturnType, assignableTo, comparisonCache, context, comparisonInfo)) { + return false; + } + } + } + + return true; + }; + + PullTypeResolver.prototype.signatureGroupIsRelatableToTarget = function (sourceSG, targetSG, assignableTo, comparisonCache, context, comparisonInfo) { + if (sourceSG === targetSG) { + return true; + } + + if (!(sourceSG.length && targetSG.length)) { + return false; + } + + var mSig = null; + var nSig = null; + var foundMatch = false; + + var targetExcludeDefinition = targetSG.length > 1; + var sourceExcludeDefinition = sourceSG.length > 1; + for (var iMSig = 0; iMSig < targetSG.length; iMSig++) { + mSig = targetSG[iMSig]; + + if (mSig.isStringConstantOverloadSignature() || (targetExcludeDefinition && mSig.isDefinition())) { + continue; + } + + for (var iNSig = 0; iNSig < sourceSG.length; iNSig++) { + nSig = sourceSG[iNSig]; + + if (nSig.isStringConstantOverloadSignature() || (sourceExcludeDefinition && nSig.isDefinition())) { + continue; + } + + if (this.signatureIsRelatableToTarget(nSig, mSig, assignableTo, comparisonCache, context, comparisonInfo)) { + foundMatch = true; + break; + } + } + + if (foundMatch) { + foundMatch = false; + continue; + } + return false; + } + + return true; + }; + + PullTypeResolver.prototype.signatureIsRelatableToTarget = function (sourceSig, targetSig, assignableTo, comparisonCache, context, comparisonInfo) { + var sourceParameters = sourceSig.parameters; + var targetParameters = targetSig.parameters; + + if (!sourceParameters || !targetParameters) { + return false; + } + + var targetVarArgCount = targetSig.nonOptionalParamCount; + var sourceVarArgCount = sourceSig.nonOptionalParamCount; + + if (sourceVarArgCount > targetVarArgCount && !targetSig.hasVarArgs) { + if (comparisonInfo) { + comparisonInfo.flags |= 3 /* SourceSignatureHasTooManyParameters */; + comparisonInfo.addMessage(TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Call_signature_expects_0_or_fewer_parameters, [targetVarArgCount])); + } + return false; + } + + var sourceReturnType = sourceSig.returnType; + var targetReturnType = targetSig.returnType; + + var prevSpecializingToObject = context.specializingToObject; + context.specializingToObject = true; + + if (targetReturnType != this.semanticInfoChain.voidTypeSymbol) { + if (!this.sourceIsRelatableToTarget(sourceReturnType, targetReturnType, assignableTo, comparisonCache, context, comparisonInfo)) { + if (comparisonInfo) { + comparisonInfo.flags |= 16 /* IncompatibleReturnTypes */; + } + context.specializingToObject = prevSpecializingToObject; + return false; + } + } + + var len = (sourceVarArgCount < targetVarArgCount && (sourceSig.hasVarArgs || (sourceParameters.length > sourceVarArgCount))) ? targetVarArgCount : sourceVarArgCount; + var sourceParamType = null; + var targetParamType = null; + var sourceParamName = ""; + var targetParamName = ""; + + for (var iSource = 0, iTarget = 0; iSource < len; iSource++, iTarget++) { + if (iSource < sourceParameters.length && (!sourceSig.hasVarArgs || iSource < sourceVarArgCount)) { + sourceParamType = sourceParameters[iSource].type; + sourceParamName = sourceParameters[iSource].name; + } else if (iSource === sourceVarArgCount) { + sourceParamType = sourceParameters[iSource].type; + if (sourceParamType.isArray()) { + sourceParamType = sourceParamType.getElementType(); + } + sourceParamName = sourceParameters[iSource].name; + } + + if (iTarget < targetParameters.length && iTarget < targetVarArgCount) { + targetParamType = targetParameters[iTarget].type; + targetParamName = targetParameters[iTarget].name; + } else if (targetSig.hasVarArgs && iTarget === targetVarArgCount) { + targetParamType = targetParameters[iTarget].type; + + if (targetParamType.isArray()) { + targetParamType = targetParamType.getElementType(); + } + targetParamName = targetParameters[iTarget].name; + } + + if (sourceParamType && sourceParamType.isTypeParameter() && this.cachedObjectInterfaceType()) { + sourceParamType = this.cachedObjectInterfaceType(); + } + if (targetParamType && targetParamType.isTypeParameter() && this.cachedObjectInterfaceType()) { + targetParamType = this.cachedObjectInterfaceType(); + } + + if (!(this.sourceIsRelatableToTarget(sourceParamType, targetParamType, assignableTo, comparisonCache, context, comparisonInfo) || this.sourceIsRelatableToTarget(targetParamType, sourceParamType, assignableTo, comparisonCache, context, comparisonInfo))) { + if (comparisonInfo) { + comparisonInfo.flags |= 64 /* IncompatibleParameterTypes */; + } + context.specializingToObject = prevSpecializingToObject; + return false; + } + } + context.specializingToObject = prevSpecializingToObject; + return true; + }; + + PullTypeResolver.prototype.resolveOverloads = function (application, group, enclosingDecl, haveTypeArgumentsAtCallSite, context, diagnostics) { + var rd = this.resolutionDataCache.getResolutionData(); + var actuals = rd.actuals; + var exactCandidates = rd.exactCandidates; + var conversionCandidates = rd.conversionCandidates; + var candidate = null; + var hasOverloads = group.length > 1; + var comparisonInfo = new TypeComparisonInfo(); + var args = null; + var target = null; + + if (application.nodeType() === 37 /* InvocationExpression */ || application.nodeType() === 38 /* ObjectCreationExpression */) { + var callEx = application; + + args = callEx.arguments; + target = this.getLastIdentifierInTarget(callEx); + + if (callEx.arguments) { + var len = callEx.arguments.members.length; + var originalIsInInvocationExpression = context.isInInvocationExpression; + context.isInInvocationExpression = true; + + for (var i = 0; i < len; i++) { + var argSym = this.resolveAST(callEx.arguments.members[i], false, enclosingDecl, context); + actuals[i] = argSym.type; + } + + context.isInInvocationExpression = originalIsInInvocationExpression; + } + } else if (application.nodeType() === 36 /* ElementAccessExpression */) { + var binExp = application; + target = binExp.operand1; + args = new TypeScript.ASTList([binExp.operand2]); + + var argSym = this.resolveAST(args.members[0], false, enclosingDecl, context); + actuals[0] = argSym.type; + } + + var signature; + var returnType; + var candidateInfo; + + for (var j = 0, groupLen = group.length; j < groupLen; j++) { + signature = group[j]; + if ((hasOverloads && signature.isDefinition()) || (haveTypeArgumentsAtCallSite && !signature.isGeneric())) { + continue; + } + + returnType = signature.returnType; + + this.getCandidateSignatures(signature, actuals, args, exactCandidates, conversionCandidates, enclosingDecl, context, comparisonInfo); + } + if (exactCandidates.length === 0) { + var applicableCandidates = this.getApplicableSignaturesFromCandidates(conversionCandidates, args, comparisonInfo, enclosingDecl, context); + if (applicableCandidates.length > 0) { + candidateInfo = this.findMostApplicableSignature(applicableCandidates, args, enclosingDecl, context); + + candidate = candidateInfo.sig; + } else { + if (comparisonInfo.message) { + diagnostics.push(context.postError(this.unitPath, target.minChar, target.getLength(), TypeScript.DiagnosticCode.Supplied_parameters_do_not_match_any_signature_of_call_target_NL_0, [comparisonInfo.message], enclosingDecl, false)); + } else { + diagnostics.push(context.postError(this.unitPath, target.minChar, target.getLength(), TypeScript.DiagnosticCode.Supplied_parameters_do_not_match_any_signature_of_call_target, null, enclosingDecl, false)); + } + } + } else { + if (exactCandidates.length > 1) { + var applicableSigs = []; + for (var i = 0; i < exactCandidates.length; i++) { + applicableSigs[i] = { signature: exactCandidates[i], hadProvisionalErrors: false }; + } + candidateInfo = this.findMostApplicableSignature(applicableSigs, args, enclosingDecl, context); + + candidate = candidateInfo.sig; + } else { + candidate = exactCandidates[0]; + } + } + + this.resolutionDataCache.returnResolutionData(rd); + return candidate; + }; + + PullTypeResolver.prototype.getLastIdentifierInTarget = function (callEx) { + return (callEx.target.nodeType() === 33 /* MemberAccessExpression */) ? (callEx.target).operand2 : callEx.target; + }; + + PullTypeResolver.prototype.getCandidateSignatures = function (signature, actuals, args, exactCandidates, conversionCandidates, enclosingDecl, context, comparisonInfo) { + var parameters = signature.parameters; + var lowerBound = signature.nonOptionalParamCount; + var upperBound = parameters.length; + var formalLen = lowerBound; + var acceptable = false; + + var actualsLength = args && actuals.length == args.separatorCount && actuals.length ? args.separatorCount + 1 : actuals.length; + if ((actualsLength >= lowerBound) && (signature.hasVarArgs || actualsLength <= upperBound)) { + formalLen = (signature.hasVarArgs ? parameters.length : actuals.length); + acceptable = true; + } + + var repeatType = null; + + if (acceptable) { + if (signature.hasVarArgs) { + formalLen -= 1; + repeatType = parameters[formalLen].type; + repeatType = repeatType.getElementType(); + acceptable = actualsLength >= (formalLen < lowerBound ? formalLen : lowerBound); + } + var len = actuals.length; + + var exact = acceptable; + var convert = acceptable; + + var typeA; + var typeB; + + for (var i = 0; i < len; i++) { + if (i < formalLen) { + typeA = parameters[i].type; + } else { + typeA = repeatType; + } + + typeB = actuals[i]; + + if (typeA && !typeA.isResolved) { + this.resolveDeclaredSymbol(typeA, enclosingDecl, context); + } + + if (typeB && !typeB.isResolved) { + this.resolveDeclaredSymbol(typeB, enclosingDecl, context); + } + + if (!typeA || !typeB || !(this.typesAreIdentical(typeA, typeB, args.members[i]))) { + exact = false; + } + + comparisonInfo.stringConstantVal = args.members[i]; + + if (!this.sourceIsAssignableToTarget(typeB, typeA, context, comparisonInfo)) { + convert = false; + } + + comparisonInfo.stringConstantVal = null; + + if (!(exact || convert)) { + break; + } + } + if (exact) { + exactCandidates[exactCandidates.length] = signature; + } else if (convert && (exactCandidates.length === 0)) { + conversionCandidates[conversionCandidates.length] = signature; + } + } + }; + + PullTypeResolver.prototype.getApplicableSignaturesFromCandidates = function (candidateSignatures, args, comparisonInfo, enclosingDecl, context) { + var applicableSigs = []; + var memberType = null; + var miss = false; + var cxt = null; + var hadProvisionalErrors = false; + + var parameters; + var signature; + var argSym; + + for (var i = 0; i < candidateSignatures.length; i++) { + miss = false; + + signature = candidateSignatures[i]; + parameters = signature.parameters; + + for (var j = 0; j < args.members.length; j++) { + if (j >= parameters.length) { + continue; + } + + if (!parameters[j].isResolved) { + this.resolveDeclaredSymbol(parameters[j], enclosingDecl, context); + } + + memberType = parameters[j].type; + + if (signature.hasVarArgs && (j >= signature.nonOptionalParamCount) && memberType.isArray()) { + memberType = memberType.getElementType(); + } + + if (this.isAnyOrEquivalent(memberType)) { + continue; + } else if (args.members[j].nodeType() === 13 /* FunctionDeclaration */) { + if (this.cachedFunctionInterfaceType() && memberType === this.cachedFunctionInterfaceType()) { + continue; + } + + argSym = this.resolveFunctionExpression(args.members[j], false, enclosingDecl, context); + + if (!this.canApplyContextualTypeToFunction(memberType, args.members[j], true)) { + if (this.canApplyContextualTypeToFunction(memberType, args.members[j], false)) { + if (!this.sourceIsAssignableToTarget(argSym.type, memberType, context, comparisonInfo, true)) { + break; + } + } else { + break; + } + } else { + argSym.invalidate(); + context.pushContextualType(memberType, true, null); + + argSym = this.resolveFunctionExpression(args.members[j], true, enclosingDecl, context); + + if (!this.sourceIsAssignableToTarget(argSym.type, memberType, context, comparisonInfo, true)) { + if (comparisonInfo) { + comparisonInfo.setMessage(TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Could_not_apply_type_0_to_argument_1_which_is_of_type_2, [memberType.toString(), (j + 1), argSym.getTypeName()])); + } + miss = true; + } + argSym.invalidate(); + cxt = context.popContextualType(); + hadProvisionalErrors = cxt.hadProvisionalErrors(); + + if (miss) { + break; + } + } + } else if (args.members[j].nodeType() === 23 /* ObjectLiteralExpression */) { + if (this.cachedObjectInterfaceType() && memberType === this.cachedObjectInterfaceType()) { + continue; + } + + context.pushContextualType(memberType, true, null); + argSym = this.resolveObjectLiteralExpression(args.members[j], true, enclosingDecl, context); + + if (!this.sourceIsAssignableToTarget(argSym.type, memberType, context, comparisonInfo, true)) { + if (comparisonInfo) { + comparisonInfo.setMessage(TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Could_not_apply_type_0_to_argument_1_which_is_of_type_2, [memberType.toString(), (j + 1), argSym.getTypeName()])); + } + + miss = true; + } + + argSym.invalidate(); + cxt = context.popContextualType(); + hadProvisionalErrors = cxt.hadProvisionalErrors(); + + if (miss) { + break; + } + } else if (args.members[j].nodeType() === 22 /* ArrayLiteralExpression */) { + if (memberType === this.cachedArrayInterfaceType()) { + continue; + } + + context.pushContextualType(memberType, true, null); + var argSym = this.resolveArrayLiteralExpression(args.members[j], true, enclosingDecl, context); + + if (!this.sourceIsAssignableToTarget(argSym.type, memberType, context, comparisonInfo, true)) { + if (comparisonInfo) { + comparisonInfo.setMessage(TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Could_not_apply_type_0_to_argument_1_which_is_of_type_2, [memberType.toString(), (j + 1), argSym.getTypeName()])); + } + break; + } + + argSym.invalidate(); + cxt = context.popContextualType(); + + hadProvisionalErrors = cxt.hadProvisionalErrors(); + + if (miss) { + break; + } + } + } + + if (j === args.members.length) { + applicableSigs[applicableSigs.length] = { signature: candidateSignatures[i], hadProvisionalErrors: hadProvisionalErrors }; + } + + hadProvisionalErrors = false; + } + + return applicableSigs; + }; + + PullTypeResolver.prototype.findMostApplicableSignature = function (signatures, args, enclosingDecl, context) { + if (signatures.length === 1) { + return { sig: signatures[0].signature, ambiguous: false }; + } + + var best = signatures[0]; + var Q = null; + + var AType = null; + var PType = null; + var QType = null; + + var ambiguous = false; + + var bestParams; + var qParams; + + for (var qSig = 1; qSig < signatures.length; qSig++) { + Q = signatures[qSig]; + + for (var i = 0; args && i < args.members.length; i++) { + var argSym = this.resolveAST(args.members[i], false, enclosingDecl, context); + + AType = argSym.type; + + argSym.invalidate(); + + bestParams = best.signature.parameters; + qParams = Q.signature.parameters; + + PType = i < bestParams.length ? bestParams[i].type : bestParams[bestParams.length - 1].type.getElementType(); + QType = i < qParams.length ? qParams[i].type : qParams[qParams.length - 1].type.getElementType(); + + if (this.typesAreIdentical(PType, QType) && !(QType.isPrimitive() && (QType).isStringConstant())) { + continue; + } else if (PType.isPrimitive() && (PType).isStringConstant() && args.members[i].nodeType() === 5 /* StringLiteral */ && TypeScript.stripQuotes((args.members[i]).actualText) === TypeScript.stripQuotes((PType).name)) { + break; + } else if (QType.isPrimitive() && (QType).isStringConstant() && args.members[i].nodeType() === 5 /* StringLiteral */ && TypeScript.stripQuotes((args.members[i]).actualText) === TypeScript.stripQuotes((QType).name)) { + best = Q; + } else if (this.typesAreIdentical(AType, PType)) { + break; + } else if (this.typesAreIdentical(AType, QType)) { + best = Q; + break; + } else if (this.sourceIsSubtypeOfTarget(PType, QType, context)) { + break; + } else if (this.sourceIsSubtypeOfTarget(QType, PType, context)) { + best = Q; + break; + } else if (Q.hadProvisionalErrors) { + break; + } else if (best.hadProvisionalErrors) { + best = Q; + break; + } + } + + if (!args || i === args.members.length) { + var collection = { + getLength: function () { + return 2; + }, + setTypeAtIndex: function (index, type) { + }, + getTypeAtIndex: function (index) { + return index ? Q.signature.returnType : best.signature.returnType; + } + }; + var bct = this.findBestCommonType(best.signature.returnType, null, collection, context); + ambiguous = !bct; + } else { + ambiguous = false; + } + } + + return { sig: best.signature, ambiguous: ambiguous }; + }; + + PullTypeResolver.prototype.canApplyContextualTypeToFunction = function (candidateType, funcDecl, beStringent) { + if (funcDecl.isMethod() || beStringent && funcDecl.returnTypeAnnotation) { + return false; + } + + beStringent = beStringent || (this.cachedFunctionInterfaceType() === candidateType); + + if (!beStringent) { + return true; + } + var functionSymbol = this.getDeclForAST(funcDecl).getSymbol(); + var signature = functionSymbol.type.getCallSignatures()[0]; + var parameters = signature.parameters; + var paramLen = parameters.length; + + for (var i = 0; i < paramLen; i++) { + var param = parameters[i]; + var argDecl = this.getASTForDecl(param.getDeclarations()[0]); + + if (beStringent && argDecl.typeExpr) { + return false; + } + } + + if (candidateType.getConstructSignatures().length && candidateType.getCallSignatures().length) { + return false; + } + + var candidateSigs = candidateType.getConstructSignatures().length ? candidateType.getConstructSignatures() : candidateType.getCallSignatures(); + + if (!candidateSigs || candidateSigs.length > 1) { + return false; + } + + return true; + }; + + PullTypeResolver.prototype.inferArgumentTypesForSignature = function (signature, args, comparisonInfo, enclosingDecl, context) { + var cxt = null; + var hadProvisionalErrors = false; + + var parameters = signature.parameters; + var typeParameters = signature.getTypeParameters(); + var argContext = new TypeScript.ArgumentInferenceContext(); + + var parameterType = null; + + for (var i = 0; i < typeParameters.length; i++) { + argContext.addInferenceRoot(typeParameters[i]); + } + + var substitutions; + var inferenceCandidates; + var inferenceCandidate; + + for (var i = 0; i < args.members.length; i++) { + if (i >= parameters.length) { + break; + } + + parameterType = parameters[i].type; + + if (signature.hasVarArgs && (i >= signature.nonOptionalParamCount - 1) && parameterType.isArray()) { + parameterType = parameterType.getElementType(); + } + + inferenceCandidates = argContext.getInferenceCandidates(); + substitutions = {}; + + if (inferenceCandidates.length) { + for (var j = 0; j < inferenceCandidates.length; j++) { + argContext.resetRelationshipCache(); + + inferenceCandidate = inferenceCandidates[j]; + + substitutions = inferenceCandidates[j]; + + context.pushContextualType(parameterType, true, substitutions); + + var argSym = this.resolveAST(args.members[i], true, enclosingDecl, context); + + this.relateTypeToTypeParameters(argSym.type, parameterType, false, argContext, enclosingDecl, context); + + cxt = context.popContextualType(); + + argSym.invalidate(); + + hadProvisionalErrors = cxt.hadProvisionalErrors(); + } + } else { + context.pushContextualType(parameterType, true, {}); + var argSym = this.resolveAST(args.members[i], true, enclosingDecl, context); + + this.relateTypeToTypeParameters(argSym.type, parameterType, false, argContext, enclosingDecl, context); + + cxt = context.popContextualType(); + + argSym.invalidate(); + + hadProvisionalErrors = cxt.hadProvisionalErrors(); + } + } + + hadProvisionalErrors = false; + + var inferenceResults = argContext.inferArgumentTypes(this, context); + + if (inferenceResults.unfit) { + return null; + } + + var resultTypes = []; + + for (var i = 0; i < typeParameters.length; i++) { + for (var j = 0; j < inferenceResults.results.length; j++) { + if (inferenceResults.results[j].param == typeParameters[i]) { + resultTypes[resultTypes.length] = inferenceResults.results[j].type; + break; + } + } + } + + if (!args.members.length && !resultTypes.length && typeParameters.length) { + for (var i = 0; i < typeParameters.length; i++) { + resultTypes[resultTypes.length] = this.semanticInfoChain.anyTypeSymbol; + } + } else if (resultTypes.length && resultTypes.length < typeParameters.length) { + for (var i = resultTypes.length; i < typeParameters.length; i++) { + resultTypes[i] = this.semanticInfoChain.anyTypeSymbol; + } + } + + return resultTypes; + }; + + PullTypeResolver.prototype.relateTypeToTypeParameters = function (expressionType, parameterType, shouldFix, argContext, enclosingDecl, context) { + if (!expressionType || !parameterType) { + return; + } + + if (expressionType.isError()) { + expressionType = this.semanticInfoChain.anyTypeSymbol; + } + + if (parameterType === expressionType) { + return; + } + + if (parameterType.isTypeParameter()) { + if (expressionType.isGeneric() && !expressionType.isFixed()) { + expressionType = this.specializeTypeToAny(expressionType, enclosingDecl, context); + } + argContext.addCandidateForInference(parameterType, expressionType, shouldFix); + return; + } + var parameterDeclarations = parameterType.getDeclarations(); + var expressionDeclarations = expressionType.getDeclarations(); + if (!parameterType.isArray() && parameterDeclarations.length && expressionDeclarations.length && (parameterDeclarations[0].isEqual(expressionDeclarations[0]) || (expressionType.isGeneric() && parameterType.isGeneric() && this.sourceIsSubtypeOfTarget(expressionType, parameterType, context, null))) && expressionType.isGeneric()) { + var typeParameters = parameterType.getIsSpecialized() ? parameterType.getTypeArguments() : parameterType.getTypeParameters(); + var typeArguments = expressionType.getTypeArguments(); + + if (!typeArguments) { + typeParameters = parameterType.getTypeArguments(); + typeArguments = expressionType.getIsSpecialized() ? expressionType.getTypeArguments() : expressionType.getTypeParameters(); + } + + if (typeParameters && typeArguments && typeParameters.length === typeArguments.length) { + for (var i = 0; i < typeParameters.length; i++) { + if (typeArguments[i] != typeParameters[i]) { + this.relateTypeToTypeParameters(typeArguments[i], typeParameters[i], true, argContext, enclosingDecl, context); + } + } + } + } + + var prevSpecializingToAny = context.specializingToAny; + context.specializingToAny = true; + + if (!this.sourceIsAssignableToTarget(expressionType, parameterType, context)) { + context.specializingToAny = prevSpecializingToAny; + return; + } + context.specializingToAny = prevSpecializingToAny; + + if (expressionType.isArray() && parameterType.isArray()) { + this.relateArrayTypeToTypeParameters(expressionType, parameterType, shouldFix, argContext, enclosingDecl, context); + + return; + } + + this.relateObjectTypeToTypeParameters(expressionType, parameterType, shouldFix, argContext, enclosingDecl, context); + }; + + PullTypeResolver.prototype.relateFunctionSignatureToTypeParameters = function (expressionSignature, parameterSignature, argContext, enclosingDecl, context) { + var expressionParams = expressionSignature.parameters; + var expressionReturnType = expressionSignature.returnType; + + var parameterParams = parameterSignature.parameters; + var parameterReturnType = parameterSignature.returnType; + + var len = parameterParams.length < expressionParams.length ? parameterParams.length : expressionParams.length; + + for (var i = 0; i < len; i++) { + this.relateTypeToTypeParameters(expressionParams[i].type, parameterParams[i].type, true, argContext, enclosingDecl, context); + } + + this.relateTypeToTypeParameters(expressionReturnType, parameterReturnType, false, argContext, enclosingDecl, context); + }; + + PullTypeResolver.prototype.relateObjectTypeToTypeParameters = function (objectType, parameterType, shouldFix, argContext, enclosingDecl, context) { + var parameterTypeMembers = parameterType.getMembers(); + var parameterSignatures; + var parameterSignature; + + var objectMember; + var objectSignatures; + + if (argContext.alreadyRelatingTypes(objectType, parameterType)) { + return; + } + + var objectTypeArguments = objectType.getTypeArguments(); + var parameterTypeParameters = parameterType.getTypeParameters(); + + if (objectTypeArguments && (objectTypeArguments.length === parameterTypeParameters.length)) { + for (var i = 0; i < objectTypeArguments.length; i++) { + argContext.addCandidateForInference(parameterTypeParameters[i], objectTypeArguments[i], shouldFix); + } + } + + for (var i = 0; i < parameterTypeMembers.length; i++) { + objectMember = this.getMemberSymbol(parameterTypeMembers[i].name, TypeScript.PullElementKind.SomeValue, objectType); + + if (objectMember) { + this.relateTypeToTypeParameters(objectMember.type, parameterTypeMembers[i].type, shouldFix, argContext, enclosingDecl, context); + } + } + + parameterSignatures = parameterType.getCallSignatures(); + objectSignatures = objectType.getCallSignatures(); + + for (var i = 0; i < parameterSignatures.length; i++) { + parameterSignature = parameterSignatures[i]; + + for (var j = 0; j < objectSignatures.length; j++) { + this.relateFunctionSignatureToTypeParameters(objectSignatures[j], parameterSignature, argContext, enclosingDecl, context); + } + } + + parameterSignatures = parameterType.getConstructSignatures(); + objectSignatures = objectType.getConstructSignatures(); + + for (var i = 0; i < parameterSignatures.length; i++) { + parameterSignature = parameterSignatures[i]; + + for (var j = 0; j < objectSignatures.length; j++) { + this.relateFunctionSignatureToTypeParameters(objectSignatures[j], parameterSignature, argContext, enclosingDecl, context); + } + } + + parameterSignatures = parameterType.getIndexSignatures(); + objectSignatures = objectType.getIndexSignatures(); + + for (var i = 0; i < parameterSignatures.length; i++) { + parameterSignature = parameterSignatures[i]; + + for (var j = 0; j < objectSignatures.length; j++) { + this.relateFunctionSignatureToTypeParameters(objectSignatures[j], parameterSignature, argContext, enclosingDecl, context); + } + } + }; + + PullTypeResolver.prototype.relateArrayTypeToTypeParameters = function (argArrayType, parameterArrayType, shouldFix, argContext, enclosingDecl, context) { + var argElement = argArrayType.getElementType(); + var paramElement = parameterArrayType.getElementType(); + + this.relateTypeToTypeParameters(argElement, paramElement, shouldFix, argContext, enclosingDecl, context); + }; + + PullTypeResolver.prototype.specializeTypeToAny = function (typeToSpecialize, enclosingDecl, context) { + var prevSpecialize = context.specializingToAny; + + context.specializingToAny = true; + + var rootType = TypeScript.getRootType(typeToSpecialize); + + var type = TypeScript.specializeType(rootType, [], this, enclosingDecl, context); + + context.specializingToAny = prevSpecialize; + + return type; + }; + + PullTypeResolver.prototype.specializeSignatureToAny = function (signatureToSpecialize, enclosingDecl, context) { + var typeParameters = signatureToSpecialize.getTypeParameters(); + var typeReplacementMap = {}; + var typeArguments = []; + + for (var i = 0; i < typeParameters.length; i++) { + typeArguments[i] = this.semanticInfoChain.anyTypeSymbol; + typeReplacementMap[typeParameters[i].pullSymbolIDString] = typeArguments[i]; + } + if (!typeArguments.length) { + typeArguments[0] = this.semanticInfoChain.anyTypeSymbol; + } + + var prevSpecialize = context.specializingToAny; + + context.specializingToAny = true; + + var sig = TypeScript.specializeSignature(signatureToSpecialize, false, typeReplacementMap, typeArguments, this, enclosingDecl, context); + context.specializingToAny = prevSpecialize; + + return sig; + }; + + PullTypeResolver.typeCheck = function (compilationSettings, semanticInfoChain, scriptName, script) { + var unit = semanticInfoChain.getUnit(scriptName); + + if (unit.getTypeChecked()) { + return; + } + + var scriptDecl = unit.getTopLevelDecls()[0]; + + var resolver = new PullTypeResolver(compilationSettings, semanticInfoChain, scriptName); + var context = new TypeScript.PullTypeResolutionContext(true); + + resolver.resolveAST(script.moduleElements, false, scriptDecl, context); + + resolver.validateVariableDeclarationGroups(scriptDecl, context); + + PullTypeResolver.globalTypeCheckPhase++; + var callBack = null; + + while (PullTypeResolver.typeCheckCallBacks.length) { + callBack = PullTypeResolver.typeCheckCallBacks[PullTypeResolver.typeCheckCallBacks.length - 1]; + PullTypeResolver.typeCheckCallBacks.pop(); + callBack(); + } + + unit.setTypeChecked(); + }; + + PullTypeResolver.prototype.validateVariableDeclarationGroups = function (enclosingDecl, context) { + var declGroups = enclosingDecl.getVariableDeclGroups(); + var decl; + var firstSymbol; + var firstSymbolType; + var symbol; + var symbolType; + var boundDeclAST; + + for (var i = 0; i < declGroups.length; i++) { + for (var j = 0; j < declGroups[i].length; j++) { + decl = declGroups[i][j]; + symbol = decl.getSymbol(); + boundDeclAST = this.semanticInfoChain.getASTForDecl(decl); + symbolType = this.resolveAST(boundDeclAST, false, enclosingDecl, context).type; + if (!j) { + firstSymbol = symbol; + firstSymbolType = symbolType; + continue; + } + + if (symbolType && firstSymbolType && !this.typesAreIdentical(symbolType, firstSymbolType)) { + context.postError(this.currentUnit.getPath(), boundDeclAST.minChar, boundDeclAST.getLength(), TypeScript.DiagnosticCode.Subsequent_variable_declarations_must_have_the_same_type_Variable_0_must_be_of_type_1_but_here_has_type_2, [symbol.getScopedName(), firstSymbolType.toString(), symbolType.toString()], enclosingDecl); + } + } + } + }; + + PullTypeResolver.prototype.typeCheckFunctionOverloads = function (funcDecl, context, signature, allSignatures) { + if (!signature) { + var functionSignatureInfo = TypeScript.PullHelpers.getSignatureForFuncDecl(funcDecl, this.currentUnit); + signature = functionSignatureInfo.signature; + allSignatures = functionSignatureInfo.allSignatures; + } + var functionDeclaration = this.currentUnit.getDeclForAST(funcDecl); + var funcSymbol = functionDeclaration.getSymbol(); + + var definitionSignature = null; + for (var i = allSignatures.length - 1; i >= 0; i--) { + if (allSignatures[i].isDefinition()) { + definitionSignature = allSignatures[i]; + break; + } + } + + if (!signature.isDefinition()) { + for (var i = 0; i < allSignatures.length; i++) { + if (allSignatures[i] === signature) { + break; + } + + if (this.signaturesAreIdentical(allSignatures[i], signature, false)) { + if (!this.typesAreIdentical(allSignatures[i].returnType, signature.returnType)) { + context.postError(this.unitPath, funcDecl.minChar, funcDecl.getLength(), TypeScript.DiagnosticCode.Overloads_cannot_differ_only_by_return_type, null, functionDeclaration); + } else if (funcDecl.isConstructor) { + context.postError(this.unitPath, funcDecl.minChar, funcDecl.getLength(), TypeScript.DiagnosticCode.Duplicate_constructor_overload_signature, null, functionDeclaration); + } else if (funcDecl.isConstructMember()) { + context.postError(this.unitPath, funcDecl.minChar, funcDecl.getLength(), TypeScript.DiagnosticCode.Duplicate_overload_construct_signature, null, functionDeclaration); + } else if (funcDecl.isCallMember()) { + context.postError(this.unitPath, funcDecl.minChar, funcDecl.getLength(), TypeScript.DiagnosticCode.Duplicate_overload_call_signature, null, functionDeclaration); + } else { + context.postError(this.unitPath, funcDecl.minChar, funcDecl.getLength(), TypeScript.DiagnosticCode.Duplicate_overload_signature_for_0, [funcSymbol.getScopedNameEx().toString()], functionDeclaration); + } + + break; + } + } + } + + var isConstantOverloadSignature = signature.isStringConstantOverloadSignature(); + if (isConstantOverloadSignature) { + if (signature.isDefinition()) { + context.postError(this.unitPath, funcDecl.minChar, funcDecl.getLength(), TypeScript.DiagnosticCode.Overload_signature_implementation_cannot_use_specialized_type, null, functionDeclaration); + } else { + var foundSubtypeSignature = false; + for (var i = 0; i < allSignatures.length; i++) { + if (allSignatures[i].isDefinition() || allSignatures[i] === signature) { + continue; + } + + if (!allSignatures[i].isResolved) { + this.resolveDeclaredSymbol(allSignatures[i], this.getEnclosingDecl(functionDeclaration), context); + } + + if (allSignatures[i].isStringConstantOverloadSignature()) { + continue; + } + + if (this.signatureIsSubtypeOfTarget(signature, allSignatures[i], context)) { + foundSubtypeSignature = true; + break; + } + } + + if (!foundSubtypeSignature) { + context.postError(this.unitPath, funcDecl.minChar, funcDecl.getLength(), TypeScript.DiagnosticCode.Specialized_overload_signature_is_not_subtype_of_any_non_specialized_signature, null, functionDeclaration); + } + } + } else if (definitionSignature && definitionSignature != signature) { + var comparisonInfo = new TypeComparisonInfo(); + + if (!definitionSignature.isResolved) { + this.resolveDeclaredSymbol(definitionSignature, this.getEnclosingDecl(functionDeclaration), context); + } + + if (!this.signatureIsAssignableToTarget(definitionSignature, signature, context, comparisonInfo)) { + if (comparisonInfo.message) { + context.postError(this.unitPath, funcDecl.minChar, funcDecl.getLength(), TypeScript.DiagnosticCode.Overload_signature_is_not_compatible_with_function_definition_NL_0, [comparisonInfo.message], functionDeclaration); + } else { + context.postError(this.unitPath, funcDecl.minChar, funcDecl.getLength(), TypeScript.DiagnosticCode.Overload_signature_is_not_compatible_with_function_definition, null, functionDeclaration); + } + } + } + + var signatureForVisibilityCheck = definitionSignature; + if (!definitionSignature) { + if (allSignatures[0] === signature) { + return; + } + signatureForVisibilityCheck = allSignatures[0]; + } + + if (!funcDecl.isConstructor && !funcDecl.isConstructMember() && signatureForVisibilityCheck && signature != signatureForVisibilityCheck) { + var errorCode; + + if (signatureForVisibilityCheck.hasFlag(2 /* Private */) != signature.hasFlag(2 /* Private */)) { + errorCode = TypeScript.DiagnosticCode.Overload_signatures_must_all_be_public_or_private; + } else if (signatureForVisibilityCheck.hasFlag(1 /* Exported */) != signature.hasFlag(1 /* Exported */)) { + errorCode = TypeScript.DiagnosticCode.Overload_signatures_must_all_be_exported_or_local; + } else if (signatureForVisibilityCheck.hasFlag(8 /* Ambient */) != signature.hasFlag(8 /* Ambient */)) { + errorCode = TypeScript.DiagnosticCode.Overload_signatures_must_all_be_ambient_or_non_ambient; + } else if (signatureForVisibilityCheck.hasFlag(128 /* Optional */) != signature.hasFlag(128 /* Optional */)) { + errorCode = TypeScript.DiagnosticCode.Overload_signatures_must_all_be_optional_or_required; + } + + if (errorCode) { + context.postError(this.unitPath, funcDecl.minChar, funcDecl.getLength(), errorCode, null, functionDeclaration); + } + } + }; + + PullTypeResolver.prototype.checkSymbolPrivacy = function (declSymbol, symbol, context, privacyErrorReporter) { + if (!symbol || symbol.kind === 2 /* Primitive */) { + return; + } + + if (symbol.isType()) { + var typeSymbol = symbol; + if (typeSymbol.isArray()) { + this.checkSymbolPrivacy(declSymbol, typeSymbol.getElementType(), context, privacyErrorReporter); + return; + } + + if (!typeSymbol.isNamedTypeSymbol()) { + if (typeSymbol.inSymbolPrivacyCheck) { + return; + } + + typeSymbol.inSymbolPrivacyCheck = true; + + var members = typeSymbol.getMembers(); + for (var i = 0; i < members.length; i++) { + this.checkSymbolPrivacy(declSymbol, members[i].type, context, privacyErrorReporter); + } + + this.checkTypePrivacyOfSignatures(declSymbol, typeSymbol.getCallSignatures(), context, privacyErrorReporter); + this.checkTypePrivacyOfSignatures(declSymbol, typeSymbol.getConstructSignatures(), context, privacyErrorReporter); + this.checkTypePrivacyOfSignatures(declSymbol, typeSymbol.getIndexSignatures(), context, privacyErrorReporter); + + typeSymbol.inSymbolPrivacyCheck = false; + + return; + } + } + + if (declSymbol.isExternallyVisible()) { + var symbolIsVisible = symbol.isExternallyVisible(); + + if (symbolIsVisible) { + var symbolPath = symbol.pathToRoot(); + if (symbolPath.length && symbolPath[symbolPath.length - 1].kind === 32 /* DynamicModule */) { + var declSymbolPath = declSymbol.pathToRoot(); + var verifyAlias = false; + if (declSymbolPath.length) { + if (declSymbolPath[declSymbolPath.length - 1] != symbolPath[symbolPath.length - 1]) { + verifyAlias = true; + } else if (symbolPath.length > 1 && symbolPath[symbolPath.length - 2].kind == 32 /* DynamicModule */) { + if (declSymbolPath.length < 2 || declSymbolPath[declSymbolPath.length - 2] != symbolPath[symbolPath.length - 2]) { + verifyAlias = true; + } + } + } + + if (verifyAlias) { + symbolIsVisible = false; + for (var i = symbolPath.length - 1; i >= 0; i--) { + var aliasSymbol = symbolPath[i].getAliasedSymbol(declSymbol); + if (aliasSymbol) { + symbolIsVisible = true; + aliasSymbol.typeUsedExternally = true; + break; + } + } + symbol = symbolPath[symbolPath.length - 1]; + } + } + } + + if (!symbolIsVisible) { + privacyErrorReporter(symbol); + } + } + }; + + PullTypeResolver.prototype.checkTypePrivacyOfSignatures = function (declSymbol, signatures, context, privacyErrorReporter) { + for (var i = 0; i < signatures.length; i++) { + var signature = signatures[i]; + if (signatures.length > 1 && signature.isDefinition()) { + continue; + } + + var typeParams = signature.getTypeParameters(); + for (var j = 0; j < typeParams.length; j++) { + this.checkSymbolPrivacy(declSymbol, typeParams[j], context, privacyErrorReporter); + } + + var params = signature.parameters; + for (var j = 0; j < params.length; j++) { + var paramType = params[j].type; + this.checkSymbolPrivacy(declSymbol, paramType, context, privacyErrorReporter); + } + + var returnType = signature.returnType; + this.checkSymbolPrivacy(declSymbol, returnType, context, privacyErrorReporter); + } + }; + + PullTypeResolver.prototype.baseListPrivacyErrorReporter = function (declAST, declSymbol, baseAst, isExtendedType, symbol, context) { + var decl = this.getDeclForAST(declAST); + var enclosingDecl = this.getEnclosingDecl(decl); + var enclosingSymbol = enclosingDecl ? enclosingDecl.getSymbol() : null; + var messageCode; + + var typeSymbol = symbol; + var typeSymbolName = typeSymbol.getScopedName(enclosingSymbol); + if (typeSymbol.isContainer() && !typeSymbol.isEnum()) { + if (!TypeScript.isQuoted(typeSymbolName)) { + typeSymbolName = "'" + typeSymbolName + "'"; + } + if (declAST.nodeType() === 14 /* ClassDeclaration */) { + if (isExtendedType) { + messageCode = TypeScript.DiagnosticCode.Exported_class_0_extends_class_from_inaccessible_module_1; + } else { + messageCode = TypeScript.DiagnosticCode.Exported_class_0_implements_interface_from_inaccessible_module_1; + } + } else { + messageCode = TypeScript.DiagnosticCode.Exported_interface_0_extends_interface_from_inaccessible_module_1; + } + } else { + if (declAST.nodeType() === 14 /* ClassDeclaration */) { + if (isExtendedType) { + messageCode = TypeScript.DiagnosticCode.Exported_class_0_extends_private_class_1; + } else { + messageCode = TypeScript.DiagnosticCode.Exported_class_0_implements_private_interface_1; + } + } else { + messageCode = TypeScript.DiagnosticCode.Exported_interface_0_extends_private_interface_1; + } + } + + var messageArguments = [declSymbol.getScopedName(enclosingSymbol), typeSymbolName]; + context.postError(this.unitPath, baseAst.minChar, baseAst.getLength(), messageCode, messageArguments, enclosingDecl); + }; + + PullTypeResolver.prototype.variablePrivacyErrorReporter = function (declSymbol, symbol, context) { + var typeSymbol = symbol; + var declAST = this.getASTForSymbol(declSymbol); + var enclosingDecl = this.getEnclosingDecl(declSymbol.getDeclarations()[0]); + var enclosingSymbol = enclosingDecl ? enclosingDecl.getSymbol() : null; + + var isProperty = declSymbol.kind === 4096 /* Property */; + var isPropertyOfClass = false; + var declParent = declSymbol.getContainer(); + if (declParent && (declParent.kind === 8 /* Class */ || declParent.kind === 32768 /* ConstructorMethod */)) { + isPropertyOfClass = true; + } + + var messageCode; + var typeSymbolName = typeSymbol.getScopedName(enclosingSymbol); + if (typeSymbol.isContainer() && !typeSymbol.isEnum()) { + if (!TypeScript.isQuoted(typeSymbolName)) { + typeSymbolName = "'" + typeSymbolName + "'"; + } + + if (declSymbol.hasFlag(16 /* Static */)) { + messageCode = TypeScript.DiagnosticCode.Public_static_property_0_of_exported_class_is_using_inaccessible_module_1; + } else if (isProperty) { + if (isPropertyOfClass) { + messageCode = TypeScript.DiagnosticCode.Public_property_0_of_exported_class_is_using_inaccessible_module_1; + } else { + messageCode = TypeScript.DiagnosticCode.Property_0_of_exported_interface_is_using_inaccessible_module_1; + } + } else { + messageCode = TypeScript.DiagnosticCode.Exported_variable_0_is_using_inaccessible_module_1; + } + } else { + if (declSymbol.hasFlag(16 /* Static */)) { + messageCode = TypeScript.DiagnosticCode.Public_static_property_0_of_exported_class_has_or_is_using_private_type_1; + } else if (isProperty) { + if (isPropertyOfClass) { + messageCode = TypeScript.DiagnosticCode.Public_property_0_of_exported_class_has_or_is_using_private_type_1; + } else { + messageCode = TypeScript.DiagnosticCode.Property_0_of_exported_interface_has_or_is_using_private_type_1; + } + } else { + messageCode = TypeScript.DiagnosticCode.Exported_variable_0_has_or_is_using_private_type_1; + } + } + + var messageArguments = [declSymbol.getScopedName(enclosingSymbol), typeSymbolName]; + context.postError(this.unitPath, declAST.minChar, declAST.getLength(), messageCode, messageArguments, enclosingDecl); + }; + + PullTypeResolver.prototype.checkFunctionTypePrivacy = function (funcDeclAST, inContextuallyTypedAssignment, context) { + var _this = this; + if (inContextuallyTypedAssignment || (funcDeclAST.getFunctionFlags() & 8192 /* IsFunctionExpression */) || (funcDeclAST.getFunctionFlags() & 16384 /* IsFunctionProperty */)) { + return; + } + + var functionDecl = this.currentUnit.getDeclForAST(funcDeclAST); + var functionSymbol = functionDecl.getSymbol(); + ; + var functionSignature; + + var isGetter = funcDeclAST.isGetAccessor(); + var isSetter = funcDeclAST.isSetAccessor(); + + if (isGetter || isSetter) { + var accessorSymbol = functionSymbol; + functionSignature = (isGetter ? accessorSymbol.getGetter() : accessorSymbol.getSetter()).type.getCallSignatures()[0]; + } else { + if (!functionSymbol) { + var parentDecl = functionDecl.getParentDecl(); + functionSymbol = parentDecl.getSymbol(); + if (functionSymbol && functionSymbol.isType() && !(functionSymbol).isNamedTypeSymbol()) { + return; + } + } else if (functionSymbol.kind == 65536 /* Method */ && !functionSymbol.getContainer().isNamedTypeSymbol()) { + return; + } + functionSignature = functionDecl.getSignatureSymbol(); + } + + if (!isGetter) { + var funcParams = functionSignature.parameters; + for (var i = 0; i < funcParams.length; i++) { + this.checkSymbolPrivacy(functionSymbol, funcParams[i].type, context, function (symbol) { + return _this.functionArgumentTypePrivacyErrorReporter(funcDeclAST, i, funcParams[i], symbol, context); + }); + } + } + + if (!isSetter) { + this.checkSymbolPrivacy(functionSymbol, functionSignature.returnType, context, function (symbol) { + return _this.functionReturnTypePrivacyErrorReporter(funcDeclAST, functionSignature.returnType, symbol, context); + }); + } + }; + + PullTypeResolver.prototype.functionArgumentTypePrivacyErrorReporter = function (declAST, argIndex, paramSymbol, symbol, context) { + var decl = this.getDeclForAST(declAST); + var enclosingDecl = this.getEnclosingDecl(decl); + var enclosingSymbol = enclosingDecl ? enclosingDecl.getSymbol() : null; + + var isGetter = declAST.isAccessor() && TypeScript.hasFlag(declAST.getFunctionFlags(), 32 /* GetAccessor */); + var isSetter = declAST.isAccessor() && TypeScript.hasFlag(declAST.getFunctionFlags(), 64 /* SetAccessor */); + var isStatic = (decl.flags & 16 /* Static */) === 16 /* Static */; + var isMethod = decl.kind === 65536 /* Method */; + var isMethodOfClass = false; + var declParent = decl.getParentDecl(); + if (declParent && (declParent.kind === 8 /* Class */ || declParent.kind === 32768 /* ConstructorMethod */)) { + isMethodOfClass = true; + } + + var start = declAST.arguments.members[argIndex].minChar; + var length = declAST.arguments.members[argIndex].getLength(); + + var typeSymbol = symbol; + var typeSymbolName = typeSymbol.getScopedName(enclosingSymbol); + var messageCode; + if (typeSymbol.isContainer() && !typeSymbol.isEnum()) { + if (!TypeScript.isQuoted(typeSymbolName)) { + typeSymbolName = "'" + typeSymbolName + "'"; + } + + if (declAST.isConstructor) { + messageCode = TypeScript.DiagnosticCode.Parameter_0_of_constructor_from_exported_class_is_using_inaccessible_module_1; + } else if (isSetter) { + if (isStatic) { + messageCode = TypeScript.DiagnosticCode.Parameter_0_of_public_static_property_setter_from_exported_class_is_using_inaccessible_module_1; + } else { + messageCode = TypeScript.DiagnosticCode.Parameter_0_of_public_property_setter_from_exported_class_is_using_inaccessible_module_1; + } + } else if (declAST.isConstructMember()) { + messageCode = TypeScript.DiagnosticCode.Parameter_0_of_constructor_signature_from_exported_interface_is_using_inaccessible_module_1; + } else if (declAST.isCallMember()) { + messageCode = TypeScript.DiagnosticCode.Parameter_0_of_call_signature_from_exported_interface_is_using_inaccessible_module_1; + } else if (isMethod) { + if (isStatic) { + messageCode = TypeScript.DiagnosticCode.Parameter_0_of_public_static_method_from_exported_class_is_using_inaccessible_module_1; + } else if (isMethodOfClass) { + messageCode = TypeScript.DiagnosticCode.Parameter_0_of_public_method_from_exported_class_is_using_inaccessible_module_1; + } else { + messageCode = TypeScript.DiagnosticCode.Parameter_0_of_method_from_exported_interface_is_using_inaccessible_module_1; + } + } else if (!isGetter) { + messageCode = TypeScript.DiagnosticCode.Parameter_0_of_exported_function_is_using_inaccessible_module_1; + } + } else { + if (declAST.isConstructor) { + messageCode = TypeScript.DiagnosticCode.Parameter_0_of_constructor_from_exported_class_has_or_is_using_private_type_1; + } else if (isSetter) { + if (isStatic) { + messageCode = TypeScript.DiagnosticCode.Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_private_type_1; + } else { + messageCode = TypeScript.DiagnosticCode.Parameter_0_of_public_property_setter_from_exported_class_has_or_is_using_private_type_1; + } + } else if (declAST.isConstructMember()) { + messageCode = TypeScript.DiagnosticCode.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_type_1; + } else if (declAST.isCallMember()) { + messageCode = TypeScript.DiagnosticCode.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_type_1; + } else if (isMethod) { + if (isStatic) { + messageCode = TypeScript.DiagnosticCode.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_type_1; + } else if (isMethodOfClass) { + messageCode = TypeScript.DiagnosticCode.Parameter_0_of_public_method_from_exported_class_has_or_is_using_private_type_1; + } else { + messageCode = TypeScript.DiagnosticCode.Parameter_0_of_method_from_exported_interface_has_or_is_using_private_type_1; + } + } else if (!isGetter && !declAST.isIndexerMember()) { + messageCode = TypeScript.DiagnosticCode.Parameter_0_of_exported_function_has_or_is_using_private_type_1; + } + } + + if (messageCode) { + var messageArgs = [paramSymbol.getScopedName(enclosingSymbol), typeSymbolName]; + context.postError(this.unitPath, start, length, messageCode, messageArgs, enclosingDecl); + } + }; + + PullTypeResolver.prototype.functionReturnTypePrivacyErrorReporter = function (declAST, funcReturnType, symbol, context) { + var _this = this; + var decl = this.getDeclForAST(declAST); + var enclosingDecl = this.getEnclosingDecl(decl); + + var isGetter = declAST.isAccessor() && TypeScript.hasFlag(declAST.getFunctionFlags(), 32 /* GetAccessor */); + var isSetter = declAST.isAccessor() && TypeScript.hasFlag(declAST.getFunctionFlags(), 64 /* SetAccessor */); + var isStatic = (decl.flags & 16 /* Static */) === 16 /* Static */; + var isMethod = decl.kind === 65536 /* Method */; + var isMethodOfClass = false; + var declParent = decl.getParentDecl(); + if (declParent && (declParent.kind === 8 /* Class */ || declParent.kind === 32768 /* ConstructorMethod */)) { + isMethodOfClass = true; + } + + var messageCode = null; + var typeSymbol = symbol; + var typeSymbolName = typeSymbol.getScopedName(enclosingDecl ? enclosingDecl.getSymbol() : null); + if (typeSymbol.isContainer() && !typeSymbol.isEnum()) { + if (!TypeScript.isQuoted(typeSymbolName)) { + typeSymbolName = "'" + typeSymbolName + "'"; + } + + if (isGetter) { + if (isStatic) { + messageCode = TypeScript.DiagnosticCode.Return_type_of_public_static_property_getter_from_exported_class_is_using_inaccessible_module_0; + } else { + messageCode = TypeScript.DiagnosticCode.Return_type_of_public_property_getter_from_exported_class_is_using_inaccessible_module_0; + } + } else if (declAST.isConstructMember()) { + messageCode = TypeScript.DiagnosticCode.Return_type_of_constructor_signature_from_exported_interface_is_using_inaccessible_module_0; + } else if (declAST.isCallMember()) { + messageCode = TypeScript.DiagnosticCode.Return_type_of_call_signature_from_exported_interface_is_using_inaccessible_module_0; + } else if (declAST.isIndexerMember()) { + messageCode = TypeScript.DiagnosticCode.Return_type_of_index_signature_from_exported_interface_is_using_inaccessible_module_0; + } else if (isMethod) { + if (isStatic) { + messageCode = TypeScript.DiagnosticCode.Return_type_of_public_static_method_from_exported_class_is_using_inaccessible_module_0; + } else if (isMethodOfClass) { + messageCode = TypeScript.DiagnosticCode.Return_type_of_public_method_from_exported_class_is_using_inaccessible_module_0; + } else { + messageCode = TypeScript.DiagnosticCode.Return_type_of_method_from_exported_interface_is_using_inaccessible_module_0; + } + } else if (!isSetter && !declAST.isConstructor) { + messageCode = TypeScript.DiagnosticCode.Return_type_of_exported_function_is_using_inaccessible_module_0; + } + } else { + if (isGetter) { + if (isStatic) { + messageCode = TypeScript.DiagnosticCode.Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_private_type_0; + } else { + messageCode = TypeScript.DiagnosticCode.Return_type_of_public_property_getter_from_exported_class_has_or_is_using_private_type_0; + } + } else if (declAST.isConstructMember()) { + messageCode = TypeScript.DiagnosticCode.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_private_type_0; + } else if (declAST.isCallMember()) { + messageCode = TypeScript.DiagnosticCode.Return_type_of_call_signature_from_exported_interface_has_or_is_using_private_type_0; + } else if (declAST.isIndexerMember()) { + messageCode = TypeScript.DiagnosticCode.Return_type_of_index_signature_from_exported_interface_has_or_is_using_private_type_0; + } else if (isMethod) { + if (isStatic) { + messageCode = TypeScript.DiagnosticCode.Return_type_of_public_static_method_from_exported_class_has_or_is_using_private_type_0; + } else if (isMethodOfClass) { + messageCode = TypeScript.DiagnosticCode.Return_type_of_public_method_from_exported_class_has_or_is_using_private_type_0; + } else { + messageCode = TypeScript.DiagnosticCode.Return_type_of_method_from_exported_interface_has_or_is_using_private_type_0; + } + } else if (!isSetter && !declAST.isConstructor) { + messageCode = TypeScript.DiagnosticCode.Return_type_of_exported_function_has_or_is_using_private_type_0; + } + } + + if (messageCode) { + var messageArguments = [typeSymbolName]; + var reportOnFuncDecl = false; + + if (declAST.returnTypeAnnotation) { + var returnExpressionSymbol = this.resolveTypeReference(declAST.returnTypeAnnotation, decl, context); + if (returnExpressionSymbol === funcReturnType) { + context.postError(this.unitPath, declAST.returnTypeAnnotation.minChar, declAST.returnTypeAnnotation.getLength(), messageCode, messageArguments, enclosingDecl); + } + } + + if (declAST.block) { + var reportErrorOnReturnExpressions = function (ast, parent, walker) { + var go = true; + switch (ast.nodeType()) { + case 13 /* FunctionDeclaration */: + go = false; + break; + + case 94 /* ReturnStatement */: + var returnStatement = ast; + var returnExpressionSymbol = _this.resolveAST(returnStatement.returnExpression, false, decl, context).type; + + if (returnExpressionSymbol === funcReturnType) { + context.postError(_this.unitPath, returnStatement.minChar, returnStatement.getLength(), messageCode, messageArguments, enclosingDecl); + } else { + reportOnFuncDecl = true; + } + go = false; + break; + + default: + break; + } + + walker.options.goChildren = go; + return ast; + }; + + TypeScript.getAstWalkerFactory().walk(declAST.block, reportErrorOnReturnExpressions); + } + + if (reportOnFuncDecl) { + context.postError(this.unitPath, declAST.minChar, declAST.getLength(), messageCode, messageArguments, enclosingDecl); + } + } + }; + + PullTypeResolver.prototype.enclosingClassIsDerived = function (decl) { + if (decl) { + var parentDecl = decl.getParentDecl(); + var classSymbol = null; + + while (parentDecl) { + if (parentDecl.kind == 8 /* Class */) { + classSymbol = parentDecl.getSymbol(); + if (classSymbol.getExtendedTypes().length > 0) { + return true; + } + + break; + } + parentDecl = parentDecl.getParentDecl(); + } + } + + return false; + }; + + PullTypeResolver.prototype.isSuperCallNode = function (node) { + if (node && node.nodeType() === 89 /* ExpressionStatement */) { + var expressionStatement = node; + if (expressionStatement.expression && expressionStatement.expression.nodeType() === 37 /* InvocationExpression */) { + var callExpression = expressionStatement.expression; + if (callExpression.target && callExpression.target.nodeType() === 31 /* SuperExpression */) { + return true; + } + } + } + return false; + }; + + PullTypeResolver.prototype.getFirstStatementFromFunctionDeclAST = function (funcDeclAST) { + if (funcDeclAST.block && funcDeclAST.block.statements && funcDeclAST.block.statements.members) { + return funcDeclAST.block.statements.members[0]; + } + + return null; + }; + + PullTypeResolver.prototype.superCallMustBeFirstStatementInConstructor = function (enclosingConstructor, enclosingClass) { + if (enclosingConstructor && enclosingClass) { + var classSymbol = enclosingClass.getSymbol(); + if (classSymbol.getExtendedTypes().length === 0) { + return false; + } + + var classMembers = classSymbol.getMembers(); + for (var i = 0, n1 = classMembers.length; i < n1; i++) { + var member = classMembers[i]; + + if (member.kind === 4096 /* Property */) { + var declarations = member.getDeclarations(); + for (var j = 0, n2 = declarations.length; j < n2; j++) { + var declaration = declarations[j]; + var ast = this.semanticInfoChain.getASTForDecl(declaration); + if (ast.nodeType() === 20 /* Parameter */) { + return true; + } + + if (ast.nodeType() === 18 /* VariableDeclarator */) { + var variableDeclarator = ast; + if (variableDeclarator.init) { + return true; + } + } + } + } + } + } + + return false; + }; + + PullTypeResolver.prototype.checkForThisOrSuperCaptureInArrowFunction = function (expression, enclosingDecl) { + var declPath = TypeScript.getPathToDecl(enclosingDecl); + + if (declPath.length) { + var inFatArrow = false; + for (var i = declPath.length - 1; i >= 0; i--) { + var decl = declPath[i]; + var declKind = decl.kind; + var declFlags = decl.flags; + + if (declKind === 131072 /* FunctionExpression */ && TypeScript.hasFlag(declFlags, 8192 /* FatArrow */)) { + inFatArrow = true; + continue; + } + + if (inFatArrow) { + if (declKind === 16384 /* Function */ || declKind === 65536 /* Method */ || declKind === 32768 /* ConstructorMethod */ || declKind === 262144 /* GetAccessor */ || declKind === 524288 /* SetAccessor */ || declKind === 131072 /* FunctionExpression */ || declKind === 8 /* Class */ || declKind === 4 /* Container */ || declKind === 32 /* DynamicModule */ || declKind === 1 /* Script */) { + decl.setFlags(decl.flags | 262144 /* MustCaptureThis */); + + if (declKind === 8 /* Class */) { + var constructorSymbol = (decl.getSymbol()).getConstructorMethod(); + var constructorDecls = constructorSymbol.getDeclarations(); + for (var i = 0; i < constructorDecls.length; i++) { + constructorDecls[i].flags = constructorDecls[i].flags | 262144 /* MustCaptureThis */; + } + } + break; + } + } else if (declKind === 16384 /* Function */ || declKind === 131072 /* FunctionExpression */) { + break; + } + } + } + }; + + PullTypeResolver.prototype.typeCheckMembersAgainstIndexer = function (containerType, containerTypeDecl, context) { + var indexSignatures = containerType.getIndexSignatures(); + + if (indexSignatures.length > 0) { + var members = containerTypeDecl.getChildDecls(); + for (var i = 0; i < members.length; i++) { + var member = members[i]; + if (!member.name || member.kind & TypeScript.PullElementKind.SomeSignature) { + continue; + } + + var isMemberNumeric = isFinite(+member.name); + for (var j = 0; j < indexSignatures.length; j++) { + if (!indexSignatures[j].isResolved) { + this.resolveDeclaredSymbol(indexSignatures[j], indexSignatures[j].getDeclarations()[0].getParentDecl(), context); + } + if ((indexSignatures[j].parameters[0].type === this.semanticInfoChain.numberTypeSymbol) === isMemberNumeric) { + this.checkThatMemberIsSubtypeOfIndexer(member.getSymbol(), indexSignatures[j], this.semanticInfoChain.getASTForDecl(member), context, containerTypeDecl, isMemberNumeric); + break; + } + } + } + } + }; + + PullTypeResolver.prototype.checkThatMemberIsSubtypeOfIndexer = function (member, indexSignature, astForError, context, enclosingDecl, isNumeric) { + var comparisonInfo = new TypeComparisonInfo(); + var resolutionContext = new TypeScript.PullTypeResolutionContext(); + + if (!this.sourceIsSubtypeOfTarget(member.type, indexSignature.returnType, resolutionContext, comparisonInfo)) { + if (isNumeric) { + if (comparisonInfo.message) { + context.postError(this.unitPath, astForError.minChar, astForError.getLength(), TypeScript.DiagnosticCode.All_numerically_named_properties_must_be_subtypes_of_numeric_indexer_type_0_NL_1, [indexSignature.returnType.toString(), comparisonInfo.message], enclosingDecl); + } else { + context.postError(this.unitPath, astForError.minChar, astForError.getLength(), TypeScript.DiagnosticCode.All_numerically_named_properties_must_be_subtypes_of_numeric_indexer_type_0, [indexSignature.returnType.toString()], enclosingDecl); + } + } else { + if (comparisonInfo.message) { + context.postError(this.unitPath, astForError.minChar, astForError.getLength(), TypeScript.DiagnosticCode.All_named_properties_must_be_subtypes_of_string_indexer_type_0_NL_1, [indexSignature.returnType.toString(), comparisonInfo.message], enclosingDecl); + } else { + context.postError(this.unitPath, astForError.minChar, astForError.getLength(), TypeScript.DiagnosticCode.All_named_properties_must_be_subtypes_of_string_indexer_type_0, [indexSignature.returnType.toString()], enclosingDecl); + } + } + } + }; + + PullTypeResolver.prototype.typeCheckIfTypeMemberPropertyOkToOverride = function (typeSymbol, extendedType, typeMember, extendedTypeMember, enclosingDecl, comparisonInfo) { + if (!typeSymbol.isClass()) { + return true; + } + + var typeMemberKind = typeMember.kind; + var extendedMemberKind = extendedTypeMember.kind; + + if (typeMemberKind === extendedMemberKind) { + return true; + } + + var errorCode; + if (typeMemberKind === 4096 /* Property */) { + if (typeMember.isAccessor()) { + errorCode = TypeScript.DiagnosticCode.Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_function; + } else { + errorCode = TypeScript.DiagnosticCode.Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_function; + } + } else if (typeMemberKind === 65536 /* Method */) { + if (extendedTypeMember.isAccessor()) { + errorCode = TypeScript.DiagnosticCode.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_accessor; + } else { + errorCode = TypeScript.DiagnosticCode.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_property; + } + } + + var message = TypeScript.getDiagnosticMessage(errorCode, [typeSymbol.toString(), typeMember.getScopedNameEx().toString(), extendedType.toString()]); + comparisonInfo.addMessage(message); + return false; + }; + + PullTypeResolver.prototype.typeCheckIfTypeExtendsType = function (typeDecl, typeSymbol, extendedType, enclosingDecl, context) { + var typeMembers = typeSymbol.getMembers(); + + var resolutionContext = new TypeScript.PullTypeResolutionContext(); + var comparisonInfo = new TypeComparisonInfo(); + var foundError = false; + + for (var i = 0; i < typeMembers.length; i++) { + var propName = typeMembers[i].name; + var extendedTypeProp = extendedType.findMember(propName); + if (extendedTypeProp) { + foundError = !this.typeCheckIfTypeMemberPropertyOkToOverride(typeSymbol, extendedType, typeMembers[i], extendedTypeProp, enclosingDecl, comparisonInfo); + + if (!foundError) { + foundError = !this.sourcePropertyIsSubtypeOfTargetProperty(typeSymbol, extendedType, typeMembers[i], extendedTypeProp, resolutionContext, comparisonInfo); + } + + if (foundError) { + break; + } + } + } + + if (!foundError && typeSymbol.hasOwnCallSignatures()) { + foundError = !this.sourceCallSignaturesAreSubtypeOfTargetCallSignatures(typeSymbol, extendedType, resolutionContext, comparisonInfo); + } + + if (!foundError && typeSymbol.hasOwnConstructSignatures()) { + foundError = !this.sourceConstructSignaturesAreSubtypeOfTargetConstructSignatures(typeSymbol, extendedType, resolutionContext, comparisonInfo); + } + + if (!foundError && typeSymbol.hasOwnIndexSignatures()) { + foundError = !this.sourceIndexSignaturesAreSubtypeOfTargetIndexSignatures(typeSymbol, extendedType, resolutionContext, comparisonInfo); + } + + if (!foundError && typeSymbol.isClass()) { + var typeConstructorType = typeSymbol.getConstructorMethod().type; + var typeConstructorTypeMembers = typeConstructorType.getMembers(); + if (typeConstructorTypeMembers.length) { + var extendedConstructorType = extendedType.getConstructorMethod().type; + var comparisonInfoForPropTypeCheck = new TypeComparisonInfo(comparisonInfo); + + for (var i = 0; i < typeConstructorTypeMembers.length; i++) { + var propName = typeConstructorTypeMembers[i].name; + var extendedConstructorTypeProp = extendedConstructorType.findMember(propName); + if (extendedConstructorTypeProp) { + if (!extendedConstructorTypeProp.isResolved) { + var extendedClassAst = this.currentUnit.getASTForSymbol(extendedType); + var extendedClassDecl = this.currentUnit.getDeclForAST(extendedClassAst); + this.resolveDeclaredSymbol(extendedConstructorTypeProp, extendedClassDecl, resolutionContext); + } + + var typeConstructorTypePropType = typeConstructorTypeMembers[i].type; + var extendedConstructorTypePropType = extendedConstructorTypeProp.type; + if (!this.sourceIsSubtypeOfTarget(typeConstructorTypePropType, extendedConstructorTypePropType, resolutionContext, comparisonInfoForPropTypeCheck)) { + var propMessage; + if (comparisonInfoForPropTypeCheck.message) { + propMessage = TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Types_of_static_property_0_of_class_1_and_class_2_are_incompatible_NL_3, [extendedConstructorTypeProp.getScopedNameEx().toString(), typeSymbol.toString(), extendedType.toString(), comparisonInfoForPropTypeCheck.message]); + } else { + propMessage = TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Types_of_static_property_0_of_class_1_and_class_2_are_incompatible, [extendedConstructorTypeProp.getScopedNameEx().toString(), typeSymbol.toString(), extendedType.toString()]); + } + comparisonInfo.addMessage(propMessage); + foundError = true; + break; + } + } + } + } + } + + if (foundError) { + var errorCode; + if (typeSymbol.isClass()) { + errorCode = TypeScript.DiagnosticCode.Class_0_cannot_extend_class_1_NL_2; + } else { + if (extendedType.isClass()) { + errorCode = TypeScript.DiagnosticCode.Interface_0_cannot_extend_class_1_NL_2; + } else { + errorCode = TypeScript.DiagnosticCode.Interface_0_cannot_extend_interface_1_NL_2; + } + } + + context.postError(this.unitPath, typeDecl.name.minChar, typeDecl.name.getLength(), errorCode, [typeSymbol.getScopedName(), extendedType.getScopedName(), comparisonInfo.message], enclosingDecl); + } + }; + + PullTypeResolver.prototype.typeCheckIfClassImplementsType = function (classDecl, classSymbol, implementedType, enclosingDecl, context) { + var resolutionContext = new TypeScript.PullTypeResolutionContext(); + var comparisonInfo = new TypeComparisonInfo(); + var foundError = !this.sourceMembersAreSubtypeOfTargetMembers(classSymbol, implementedType, resolutionContext, comparisonInfo); + if (!foundError) { + foundError = !this.sourceCallSignaturesAreSubtypeOfTargetCallSignatures(classSymbol, implementedType, resolutionContext, comparisonInfo); + if (!foundError) { + foundError = !this.sourceConstructSignaturesAreSubtypeOfTargetConstructSignatures(classSymbol, implementedType, resolutionContext, comparisonInfo); + if (!foundError) { + foundError = !this.sourceIndexSignaturesAreSubtypeOfTargetIndexSignatures(classSymbol, implementedType, resolutionContext, comparisonInfo); + } + } + } + + if (foundError) { + context.postError(this.unitPath, classDecl.name.minChar, classDecl.name.getLength(), TypeScript.DiagnosticCode.Class_0_declares_interface_1_but_does_not_implement_it_NL_2, [classSymbol.getScopedName(), implementedType.getScopedName(), comparisonInfo.message], enclosingDecl); + } + }; + + PullTypeResolver.prototype.hasClassTypeSymbolConflictAsValue = function (valueDeclAST, typeSymbol, enclosingDecl, context) { + var typeSymbolAlias = this.currentUnit.getAliasSymbolForAST(valueDeclAST); + var tempResolvingTypeNameAsNameExpression = context.resolvingTypeNameAsNameExpression; + context.resolvingTypeNameAsNameExpression = true; + var valueSymbol = this.computeNameExpression(valueDeclAST, enclosingDecl, context); + context.resolvingTypeNameAsNameExpression = tempResolvingTypeNameAsNameExpression; + var valueSymbolAlias = this.currentUnit.getAliasSymbolForAST(valueDeclAST); + + this.currentUnit.setAliasSymbolForAST(valueDeclAST, typeSymbolAlias); + + if (typeSymbolAlias && valueSymbolAlias) { + return typeSymbolAlias != valueSymbolAlias; + } + + if (!valueSymbol.hasFlag(16384 /* ClassConstructorVariable */)) { + return true; + } + + var associatedContainerType = valueSymbol.type ? valueSymbol.type.getAssociatedContainerType() : null; + if (associatedContainerType) { + return associatedContainerType != typeSymbol; + } + + return true; + }; + + PullTypeResolver.prototype.typeCheckBase = function (typeDeclAst, typeSymbol, baseDeclAST, isExtendedType, enclosingDecl, context) { + var _this = this; + var typeDecl = this.getDeclForAST(typeDeclAst); + var contextForBaseTypeResolution = new TypeScript.PullTypeResolutionContext(); + contextForBaseTypeResolution.isResolvingClassExtendedType = true; + + var baseType = this.resolveAST(baseDeclAST, false, enclosingDecl, context); + contextForBaseTypeResolution.isResolvingClassExtendedType = false; + + var typeDeclIsClass = typeSymbol.isClass(); + + if (!typeSymbol.isValidBaseKind(baseType, isExtendedType)) { + if (baseType.isError()) { + var error = (baseType).getDiagnostic(); + if (error) { + context.postError(this.unitPath, baseDeclAST.minChar, baseDeclAST.getLength(), error.diagnosticKey(), error.arguments(), enclosingDecl); + } + } else if (isExtendedType) { + if (typeDeclIsClass) { + context.postError(this.unitPath, baseDeclAST.minChar, baseDeclAST.getLength(), TypeScript.DiagnosticCode.A_class_may_only_extend_another_class, null, enclosingDecl); + } else { + context.postError(this.unitPath, baseDeclAST.minChar, baseDeclAST.getLength(), TypeScript.DiagnosticCode.An_interface_may_only_extend_another_class_or_interface, null, enclosingDecl); + } + } else { + context.postError(this.unitPath, baseDeclAST.minChar, baseDeclAST.getLength(), TypeScript.DiagnosticCode.A_class_may_only_implement_another_class_or_interface, null, enclosingDecl); + } + return; + } else if (typeDeclIsClass && isExtendedType && baseDeclAST.nodeType() == 21 /* Name */) { + if (this.hasClassTypeSymbolConflictAsValue(baseDeclAST, baseType, enclosingDecl, context)) { + context.postError(this.unitPath, baseDeclAST.minChar, baseDeclAST.getLength(), TypeScript.DiagnosticCode.Type_reference_0_in_extends_clause_doesn_t_reference_constructor_function_for_1, [(baseDeclAST).actualText, baseType.toString(enclosingDecl ? enclosingDecl.getSymbol() : null)], enclosingDecl); + } + } + + if ((baseType.getRootSymbol()).hasBase(typeSymbol.getRootSymbol())) { + typeSymbol.setHasBaseTypeConflict(); + baseType.setHasBaseTypeConflict(); + + context.postError(this.unitPath, typeDeclAst.name.minChar, typeDeclAst.name.getLength(), typeDeclIsClass ? TypeScript.DiagnosticCode.Class_0_is_recursively_referenced_as_a_base_type_of_itself : TypeScript.DiagnosticCode.Interface_0_is_recursively_referenced_as_a_base_type_of_itself, [typeSymbol.getScopedName()], enclosingDecl); + return; + } + + if (isExtendedType) { + this.typeCheckIfTypeExtendsType(typeDeclAst, typeSymbol, baseType, enclosingDecl, context); + } else { + this.typeCheckIfClassImplementsType(typeDeclAst, typeSymbol, baseType, enclosingDecl, context); + } + + this.checkSymbolPrivacy(typeSymbol, baseType, context, function (errorSymbol) { + return _this.baseListPrivacyErrorReporter(typeDeclAst, typeSymbol, baseDeclAST, isExtendedType, errorSymbol, context); + }); + }; + + PullTypeResolver.prototype.typeCheckBases = function (typeDeclAst, typeSymbol, enclosingDecl, context) { + if (!context.typeCheck()) { + return; + } + + if (!typeDeclAst.extendsList && !typeDeclAst.implementsList) { + return; + } + + if (typeDeclAst.extendsList) { + for (var i = 0; i < typeDeclAst.extendsList.members.length; i++) { + this.typeCheckBase(typeDeclAst, typeSymbol, typeDeclAst.extendsList.members[i], true, enclosingDecl, context); + } + } + + if (typeSymbol.isClass()) { + if (typeDeclAst.implementsList) { + for (var i = 0; i < typeDeclAst.implementsList.members.length; i++) { + this.typeCheckBase(typeDeclAst, typeSymbol, typeDeclAst.implementsList.members[i], false, enclosingDecl, context); + } + } + } else if (typeDeclAst.implementsList) { + context.postError(this.unitPath, typeDeclAst.implementsList.minChar, typeDeclAst.implementsList.getLength(), TypeScript.DiagnosticCode.An_interface_cannot_implement_another_type, null, enclosingDecl); + } + }; + + PullTypeResolver.prototype.checkAssignability = function (ast, source, target, enclosingDecl, context) { + var comparisonInfo = new TypeComparisonInfo(); + + var isAssignable = this.sourceIsAssignableToTarget(source, target, context, comparisonInfo); + + if (!isAssignable) { + if (comparisonInfo.message) { + context.postError(this.unitPath, ast.minChar, ast.getLength(), TypeScript.DiagnosticCode.Cannot_convert_0_to_1_NL_2, [source.toString(), target.toString(), comparisonInfo.message], enclosingDecl); + } else { + context.postError(this.unitPath, ast.minChar, ast.getLength(), TypeScript.DiagnosticCode.Cannot_convert_0_to_1, [source.toString(), target.toString()], enclosingDecl); + } + } + }; + + PullTypeResolver.prototype.isValidLHS = function (ast, expressionSymbol) { + var expressionTypeSymbol = expressionSymbol.type; + + if (ast.nodeType() === 36 /* ElementAccessExpression */ || this.isAnyOrEquivalent(expressionTypeSymbol)) { + return true; + } else if (!expressionSymbol.isType() || expressionTypeSymbol.isArray()) { + return ((expressionSymbol.kind & TypeScript.PullElementKind.SomeLHS) != 0) && !expressionSymbol.hasFlag(4096 /* Enum */); + } + + return false; + }; + + PullTypeResolver.prototype.checkForSuperMemberAccess = function (memberAccessExpression, resolvedName, enclosingDecl, context) { + if (resolvedName) { + if (memberAccessExpression.operand1.nodeType() === 31 /* SuperExpression */ && !resolvedName.isError() && resolvedName.kind !== 65536 /* Method */) { + context.postError(this.unitPath, memberAccessExpression.operand2.minChar, memberAccessExpression.operand2.getLength(), TypeScript.DiagnosticCode.Only_public_instance_methods_of_the_base_class_are_accessible_via_the_super_keyword, [], enclosingDecl); + return true; + } + } + + return false; + }; + + PullTypeResolver.prototype.checkForPrivateMemberAccess = function (memberAccessExpression, expressionType, resolvedName, enclosingDecl, context) { + if (resolvedName) { + if (resolvedName.hasFlag(2 /* Private */)) { + var memberContainer = resolvedName.getContainer(); + if (memberContainer && memberContainer.kind === 33554432 /* ConstructorType */) { + memberContainer = memberContainer.getAssociatedContainerType(); + } + + if (memberContainer && memberContainer.isClass()) { + var containingClass = enclosingDecl; + + while (containingClass && containingClass.kind != 8 /* Class */) { + containingClass = containingClass.getParentDecl(); + } + + if (!containingClass || containingClass.getSymbol() !== memberContainer) { + var name = memberAccessExpression.operand2; + context.postError(this.unitPath, name.minChar, name.getLength(), TypeScript.DiagnosticCode._0_1_is_inaccessible, [memberContainer.toString(null, false), name.actualText], enclosingDecl); + return true; + } + } + } + } + + return false; + }; + + PullTypeResolver.prototype.checkForStaticMemberAccess = function (memberAccessExpression, expressionType, resolvedName, enclosingDecl, context) { + if (expressionType && resolvedName && !resolvedName.isError()) { + if (expressionType.isClass() || expressionType.kind === 33554432 /* ConstructorType */) { + var name = memberAccessExpression.operand2; + + if (resolvedName.hasFlag(16 /* Static */) || this.isPrototypeMember(memberAccessExpression, enclosingDecl, context)) { + if (expressionType.kind !== 33554432 /* ConstructorType */) { + context.postError(this.unitPath, name.minChar, name.getLength(), TypeScript.DiagnosticCode.Static_member_cannot_be_accessed_off_an_instance_variable, null, enclosingDecl); + return true; + } + } + } + } + + return false; + }; + PullTypeResolver.typeCheckCallBacks = []; + + PullTypeResolver.globalTypeCheckPhase = 0; + return PullTypeResolver; + })(); + TypeScript.PullTypeResolver = PullTypeResolver; + + var TypeComparisonInfo = (function () { + function TypeComparisonInfo(sourceComparisonInfo) { + this.onlyCaptureFirstError = false; + this.flags = 0 /* SuccessfulComparison */; + this.message = ""; + this.stringConstantVal = null; + this.indent = 1; + if (sourceComparisonInfo) { + this.flags = sourceComparisonInfo.flags; + this.onlyCaptureFirstError = sourceComparisonInfo.onlyCaptureFirstError; + this.stringConstantVal = sourceComparisonInfo.stringConstantVal; + this.indent = sourceComparisonInfo.indent + 1; + } + } + TypeComparisonInfo.prototype.indentString = function () { + var result = ""; + + for (var i = 0; i < this.indent; i++) { + result += "\t"; + } + + return result; + }; + + TypeComparisonInfo.prototype.addMessage = function (message) { + if (!this.onlyCaptureFirstError && this.message) { + this.message = this.message + TypeScript.newLine() + this.indentString() + message; + } else { + this.message = this.indentString() + message; + } + }; + + TypeComparisonInfo.prototype.setMessage = function (message) { + this.message = this.indentString() + message; + }; + return TypeComparisonInfo; + })(); + TypeScript.TypeComparisonInfo = TypeComparisonInfo; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + TypeScript.declCacheHit = 0; + TypeScript.declCacheMiss = 0; + TypeScript.symbolCacheHit = 0; + TypeScript.symbolCacheMiss = 0; + + var sentinalEmptyArray = []; + + var SemanticInfo = (function () { + function SemanticInfo(compilationUnitPath) { + this.topLevelDecls = []; + this.topLevelSynthesizedDecls = []; + this.declASTMap = new TypeScript.DataMap(); + this.astDeclMap = new TypeScript.DataMap(); + this.astSymbolMap = new TypeScript.DataMap(); + this.astAliasSymbolMap = new TypeScript.DataMap(); + this.symbolASTMap = new TypeScript.DataMap(); + this.astCallResolutionDataMap = TypeScript.Collections.createHashTable(TypeScript.Collections.DefaultHashTableCapacity, function (k) { + return k; + }); + this.syntaxElementSymbolMap = new TypeScript.DataMap(); + this.symbolSyntaxElementMap = new TypeScript.DataMap(); + this.hasBeenTypeChecked = false; + this.compilationUnitPath = compilationUnitPath; + } + SemanticInfo.prototype.addTopLevelDecl = function (decl) { + this.topLevelDecls[this.topLevelDecls.length] = decl; + }; + + SemanticInfo.prototype.setTypeChecked = function (shouldTC) { + if (typeof shouldTC === "undefined") { shouldTC = true; } + this.hasBeenTypeChecked = shouldTC; + }; + SemanticInfo.prototype.getTypeChecked = function () { + return this.hasBeenTypeChecked; + }; + SemanticInfo.prototype.invalidate = function () { + this.astSymbolMap = new TypeScript.DataMap(); + this.symbolASTMap = new TypeScript.DataMap(); + }; + + SemanticInfo.prototype.getTopLevelDecls = function () { + return this.topLevelDecls; + }; + + SemanticInfo.prototype.getPath = function () { + return this.compilationUnitPath; + }; + + SemanticInfo.prototype.addSynthesizedDecl = function (decl) { + this.topLevelSynthesizedDecls[this.topLevelSynthesizedDecls.length] = decl; + }; + + SemanticInfo.prototype.getSynthesizedDecls = function () { + return this.topLevelSynthesizedDecls; + }; + + SemanticInfo.prototype.cleanSynthesizedDecls = function () { + this.topLevelSynthesizedDecls = []; + }; + + SemanticInfo.prototype.getDeclForAST = function (ast) { + if (TypeScript.useDirectTypeStorage) { + return ast.decl; + } + + return this.astDeclMap.read(ast.astIDString); + }; + + SemanticInfo.prototype.setDeclForAST = function (ast, decl) { + if (TypeScript.useDirectTypeStorage) { + ast.decl = decl; + return; + } + + this.astDeclMap.link(ast.astIDString, decl); + }; + + SemanticInfo.prototype.getASTForDecl = function (decl) { + if (TypeScript.useDirectTypeStorage) { + return decl.ast; + } + + return this.declASTMap.read(decl.declIDString); + }; + + SemanticInfo.prototype.setASTForDecl = function (decl, ast) { + if (TypeScript.useDirectTypeStorage) { + decl.ast = ast; + return; + } + + this.declASTMap.link(decl.declIDString, ast); + }; + + SemanticInfo.prototype.setSymbolForAST = function (ast, symbol) { + if (TypeScript.useDirectTypeStorage) { + ast.symbol = symbol; + symbol.ast = ast; + return; + } + + this.astSymbolMap.link(ast.astIDString, symbol); + this.symbolASTMap.link(symbol.pullSymbolIDString, ast); + }; + + SemanticInfo.prototype.getSymbolForAST = function (ast) { + if (TypeScript.useDirectTypeStorage) { + return (ast).symbol; + } + return this.astSymbolMap.read(ast.astIDString); + }; + + SemanticInfo.prototype.getASTForSymbol = function (symbol) { + if (TypeScript.useDirectTypeStorage) { + return symbol.ast; + } + return this.symbolASTMap.read(symbol.pullSymbolIDString); + }; + + SemanticInfo.prototype.setAliasSymbolForAST = function (ast, symbol) { + if (TypeScript.useDirectTypeStorage) { + ast.aliasSymbol = symbol; + return; + } + this.astAliasSymbolMap.link(ast.astIDString, symbol); + }; + + SemanticInfo.prototype.getAliasSymbolForAST = function (ast) { + if (TypeScript.useDirectTypeStorage) { + return (ast).aliasSymbol; + } + return this.astAliasSymbolMap.read(ast.astIDString); + }; + + SemanticInfo.prototype.getCallResolutionDataForAST = function (ast) { + if (TypeScript.useDirectTypeStorage) { + return (ast).callResolutionData; + } + return this.astCallResolutionDataMap.get(ast.astID); + }; + + SemanticInfo.prototype.setCallResolutionDataForAST = function (ast, callResolutionData) { + if (callResolutionData) { + if (TypeScript.useDirectTypeStorage) { + (ast).callResolutionData = callResolutionData; + return; + } + this.astCallResolutionDataMap.set(ast.astID, callResolutionData); + } + }; + + SemanticInfo.prototype.getDiagnostics = function (semanticErrors) { + for (var i = 0; i < this.topLevelDecls.length; i++) { + TypeScript.getDiagnosticsFromEnclosingDecl(this.topLevelDecls[i], semanticErrors); + } + }; + return SemanticInfo; + })(); + TypeScript.SemanticInfo = SemanticInfo; + + var SemanticInfoChain = (function () { + function SemanticInfoChain() { + this.units = [new SemanticInfo("")]; + this.declCache = new TypeScript.BlockIntrinsics(); + this.symbolCache = new TypeScript.BlockIntrinsics(); + this.unitCache = new TypeScript.BlockIntrinsics(); + this.topLevelDecls = []; + this.anyTypeSymbol = null; + this.booleanTypeSymbol = null; + this.numberTypeSymbol = null; + this.stringTypeSymbol = null; + this.nullTypeSymbol = null; + this.undefinedTypeSymbol = null; + this.voidTypeSymbol = null; + if (TypeScript.globalBinder) { + TypeScript.globalBinder.semanticInfoChain = this; + } + + var globalDecl = this.getGlobalDecl(); + var globalInfo = this.units[0]; + globalInfo.addTopLevelDecl(globalDecl); + } + SemanticInfoChain.prototype.addPrimitiveType = function (name, globalDecl) { + var span = new TypeScript.TextSpan(0, 0); + var decl = new TypeScript.PullDecl(name, name, 2 /* Primitive */, 0 /* None */, span, ""); + var symbol = new TypeScript.PullPrimitiveTypeSymbol(name); + + symbol.addDeclaration(decl); + decl.setSymbol(symbol); + + symbol.setResolved(); + + if (globalDecl) { + globalDecl.addChildDecl(decl); + } + + return symbol; + }; + + SemanticInfoChain.prototype.addPrimitiveValue = function (name, type, globalDecl) { + var span = new TypeScript.TextSpan(0, 0); + var decl = new TypeScript.PullDecl(name, name, 1024 /* Variable */, 8 /* Ambient */, span, ""); + var symbol = new TypeScript.PullSymbol(name, 1024 /* Variable */); + + symbol.addDeclaration(decl); + decl.setSymbol(symbol); + symbol.type = type; + symbol.setResolved(); + + globalDecl.addChildDecl(decl); + }; + + SemanticInfoChain.prototype.getGlobalDecl = function () { + var span = new TypeScript.TextSpan(0, 0); + var globalDecl = new TypeScript.PullDecl("", "", 0 /* Global */, 0 /* None */, span, ""); + + this.anyTypeSymbol = this.addPrimitiveType("any", globalDecl); + this.booleanTypeSymbol = this.addPrimitiveType("boolean", globalDecl); + this.numberTypeSymbol = this.addPrimitiveType("number", globalDecl); + this.stringTypeSymbol = this.addPrimitiveType("string", globalDecl); + this.voidTypeSymbol = this.addPrimitiveType("void", globalDecl); + + this.nullTypeSymbol = this.addPrimitiveType("null", null); + this.undefinedTypeSymbol = this.addPrimitiveType("undefined", null); + this.addPrimitiveValue("undefined", this.undefinedTypeSymbol, globalDecl); + this.addPrimitiveValue("null", this.nullTypeSymbol, globalDecl); + + return globalDecl; + }; + + SemanticInfoChain.prototype.addUnit = function (unit) { + this.units[this.units.length] = unit; + this.unitCache[unit.getPath()] = unit; + }; + + SemanticInfoChain.prototype.getUnit = function (compilationUnitPath) { + return this.unitCache[compilationUnitPath]; + }; + + SemanticInfoChain.prototype.updateUnit = function (oldUnit, newUnit) { + for (var i = 0; i < this.units.length; i++) { + if (this.units[i].getPath() === oldUnit.getPath()) { + this.units[i] = newUnit; + this.unitCache[oldUnit.getPath()] = newUnit; + return; + } + } + }; + + SemanticInfoChain.prototype.collectAllTopLevelDecls = function () { + if (this.topLevelDecls.length) { + return this.topLevelDecls; + } + + var unitDecls; + + for (var i = 0; i < this.units.length; i++) { + unitDecls = this.units[i].getTopLevelDecls(); + for (var j = 0; j < unitDecls.length; j++) { + this.topLevelDecls[this.topLevelDecls.length] = unitDecls[j]; + } + } + + return this.topLevelDecls; + }; + + SemanticInfoChain.prototype.collectAllSynthesizedDecls = function () { + var decls = []; + var synthDecls; + + for (var i = 0; i < this.units.length; i++) { + synthDecls = this.units[i].getSynthesizedDecls(); + for (var j = 0; j < synthDecls.length; j++) { + decls[decls.length] = synthDecls[j]; + } + } + + return decls; + }; + + SemanticInfoChain.prototype.getDeclPathCacheID = function (declPath, declKind) { + var cacheID = ""; + + for (var i = 0; i < declPath.length; i++) { + cacheID += "#" + declPath[i]; + } + + return cacheID + "#" + declKind.toString(); + }; + + SemanticInfoChain.prototype.findTopLevelSymbol = function (name, kind, stopAtFile) { + var cacheID = this.getDeclPathCacheID([name], kind); + + var symbol = this.symbolCache[name]; + + if (!symbol) { + var topLevelDecls = this.collectAllTopLevelDecls(); + var foundDecls = null; + + for (var i = 0; i < topLevelDecls.length; i++) { + foundDecls = topLevelDecls[i].searchChildDecls(name, kind); + + if (foundDecls.length) { + symbol = foundDecls[0].getSymbol(); + break; + } + + if (topLevelDecls[i].name == stopAtFile) { + break; + } + } + + if (symbol) { + this.symbolCache[cacheID] = symbol; + + symbol.addCacheID(cacheID); + } + } + + return symbol; + }; + + SemanticInfoChain.prototype.findDecls = function (declPath, declKind) { + var cacheID = this.getDeclPathCacheID(declPath, declKind); + + if (declPath.length) { + var cachedDecls = this.declCache[cacheID]; + + if (cachedDecls && cachedDecls.length) { + TypeScript.declCacheHit++; + return cachedDecls; + } + } + + TypeScript.declCacheMiss++; + + if (declKind == 32 /* DynamicModule */ && declPath.length == 1) { + var path = declPath[0]; + + if (TypeScript.isRooted(path)) { + var unit = this.unitCache[path]; + + if (unit) { + var decl = unit.getTopLevelDecls()[0].getChildDecls()[0]; + + if (decl.kind == 32 /* DynamicModule */) { + return [decl]; + } + } + + return TypeScript.sentinelEmptyArray; + } + } + + var declsToSearch = this.collectAllTopLevelDecls(); + + var decls = TypeScript.sentinelEmptyArray; + var path; + var foundDecls = TypeScript.sentinelEmptyArray; + var keepSearching = (declKind & TypeScript.PullElementKind.SomeContainer) || (declKind & 16 /* Interface */); + + for (var i = 0; i < declPath.length; i++) { + path = declPath[i]; + decls = TypeScript.sentinelEmptyArray; + + for (var j = 0; j < declsToSearch.length; j++) { + foundDecls = declsToSearch[j].searchChildDecls(path, declKind); + + for (var k = 0; k < foundDecls.length; k++) { + if (decls == TypeScript.sentinelEmptyArray) { + decls = []; + } + decls[decls.length] = foundDecls[k]; + } + + if (foundDecls.length && !keepSearching) { + break; + } + } + + declsToSearch = decls; + + if (!declsToSearch) { + break; + } + } + + if (decls.length) { + this.declCache[cacheID] = decls; + } + + return decls; + }; + + SemanticInfoChain.prototype.findDeclsFromPath = function (declPath, declKind) { + var declString = []; + + for (var i = 0, n = declPath.length; i < n; i++) { + if (declPath[i].kind & 1 /* Script */) { + continue; + } + + declString.push(declPath[i].name); + } + + return this.findDecls(declString, declKind); + }; + + SemanticInfoChain.prototype.findSymbol = function (declPath, declType) { + var cacheID = this.getDeclPathCacheID(declPath, declType); + + if (declPath.length) { + var cachedSymbol = this.symbolCache[cacheID]; + + if (cachedSymbol) { + TypeScript.symbolCacheHit++; + return cachedSymbol; + } + } + + TypeScript.symbolCacheMiss++; + + var decls = this.findDecls(declPath, declType); + var symbol = null; + + if (decls.length) { + symbol = decls[0].getSymbol(); + + if (symbol) { + this.symbolCache[cacheID] = symbol; + + symbol.addCacheID(cacheID); + } + } + + return symbol; + }; + + SemanticInfoChain.prototype.cacheGlobalSymbol = function (symbol, kind) { + var cacheID1 = this.getDeclPathCacheID([symbol.name], kind); + var cacheID2 = this.getDeclPathCacheID([symbol.name], symbol.kind); + + if (!this.symbolCache[cacheID1]) { + this.symbolCache[cacheID1] = symbol; + symbol.addCacheID(cacheID1); + } + + if (!this.symbolCache[cacheID2]) { + this.symbolCache[cacheID2] = symbol; + symbol.addCacheID(cacheID2); + } + }; + + SemanticInfoChain.prototype.cleanDecl = function (decl) { + decl.setSymbol(null); + decl.setSignatureSymbol(null); + decl.setSpecializingSignatureSymbol(null); + decl.setIsBound(false); + + var children = decl.getChildDecls(); + + for (var i = 0; i < children.length; i++) { + this.cleanDecl(children[i]); + } + + var typeParameters = decl.getTypeParameters(); + + for (var i = 0; i < typeParameters.length; i++) { + this.cleanDecl(typeParameters[i]); + } + + var valueDecl = decl.getValueDecl(); + + if (valueDecl) { + this.cleanDecl(valueDecl); + } + }; + + SemanticInfoChain.prototype.cleanAllDecls = function () { + var topLevelDecls = this.collectAllTopLevelDecls(); + + for (var i = 1; i < topLevelDecls.length; i++) { + this.cleanDecl(topLevelDecls[i]); + } + + var synthesizedDecls = this.collectAllSynthesizedDecls(); + + for (var i = 0; i < synthesizedDecls.length; i++) { + this.cleanDecl(synthesizedDecls[i]); + } + + this.cleanAllSynthesizedDecls(); + this.topLevelDecls = []; + }; + + SemanticInfoChain.prototype.cleanAllSynthesizedDecls = function () { + for (var i = 0; i < this.units.length; i++) { + this.units[i].cleanSynthesizedDecls(); + } + }; + + SemanticInfoChain.prototype.update = function () { + this.declCache = new TypeScript.BlockIntrinsics(); + this.symbolCache = new TypeScript.BlockIntrinsics(); + this.units[0] = new SemanticInfo(""); + this.units[0].addTopLevelDecl(this.getGlobalDecl()); + this.cleanAllDecls(); + + for (var unit in this.unitCache) { + if (this.unitCache[unit]) { + this.unitCache[unit].invalidate(); + } + } + }; + + SemanticInfoChain.prototype.invalidateUnit = function (compilationUnitPath) { + var unit = this.unitCache[compilationUnitPath]; + if (unit) { + unit.invalidate(); + } + }; + + SemanticInfoChain.prototype.forceTypeCheck = function (compilationUnitPath) { + var unit = this.unitCache[compilationUnitPath]; + if (unit) { + unit.setTypeChecked(false); + } + }; + + SemanticInfoChain.prototype.getDeclForAST = function (ast, unitPath) { + var unit = this.unitCache[unitPath]; + + if (unit) { + return unit.getDeclForAST(ast); + } + + return null; + }; + + SemanticInfoChain.prototype.getASTForDecl = function (decl) { + var unit = this.unitCache[decl.getScriptName()]; + + if (unit) { + return unit.getASTForDecl(decl); + } + + return null; + }; + + SemanticInfoChain.prototype.getSymbolForAST = function (ast, unitPath) { + if (TypeScript.useDirectTypeStorage) { + return (ast).symbol; + } + + var unit = this.unitCache[unitPath]; + + if (unit) { + return unit.getSymbolForAST(ast); + } + + return null; + }; + + SemanticInfoChain.prototype.getASTForSymbol = function (symbol, unitPath) { + if (TypeScript.useDirectTypeStorage) { + return symbol.ast; + } + + var unit = this.unitCache[unitPath]; + + if (unit) { + return unit.getASTForSymbol(symbol); + } + + return null; + }; + + SemanticInfoChain.prototype.setSymbolForAST = function (ast, symbol, unitPath) { + if (TypeScript.useDirectTypeStorage) { + ast.symbol = symbol; + return; + } + + var unit = this.unitCache[unitPath]; + + if (unit) { + unit.setSymbolForAST(ast, symbol); + } + }; + + SemanticInfoChain.prototype.getAliasSymbolForAST = function (ast, unitPath) { + if (TypeScript.useDirectTypeStorage) { + return (ast).aliasSymbol; + } + + var unit = this.unitCache[unitPath]; + + if (unit) { + return unit.getAliasSymbolForAST(ast); + } + + return null; + }; + + SemanticInfoChain.prototype.removeSymbolFromCache = function (symbol) { + var path = [symbol.name]; + var kind = (symbol.kind & TypeScript.PullElementKind.SomeType) !== 0 ? TypeScript.PullElementKind.SomeType : TypeScript.PullElementKind.SomeValue; + + var kindID = this.getDeclPathCacheID(path, kind); + var symID = this.getDeclPathCacheID(path, symbol.kind); + + symbol.addCacheID(kindID); + symbol.addCacheID(symID); + + symbol.invalidateCachedIDs(this.symbolCache); + }; + + SemanticInfoChain.prototype.postDiagnostics = function () { + var errors = []; + + for (var i = 1; i < this.units.length; i++) { + this.units[i].getDiagnostics(errors); + } + + return errors; + }; + return SemanticInfoChain; + })(); + TypeScript.SemanticInfoChain = SemanticInfoChain; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var DeclCollectionContext = (function () { + function DeclCollectionContext(semanticInfo, scriptName) { + this.semanticInfo = semanticInfo; + this.scriptName = scriptName; + this.isDeclareFile = false; + this.parentChain = new Array(); + this.containingModuleHasExportAssignmentArray = [false]; + this.isParsingAmbientModuleArray = [false]; + this.foundValueDecl = false; + } + DeclCollectionContext.prototype.getParent = function () { + return this.parentChain ? this.parentChain[this.parentChain.length - 1] : null; + }; + + DeclCollectionContext.prototype.pushParent = function (parentDecl) { + if (parentDecl) { + this.parentChain[this.parentChain.length] = parentDecl; + } + }; + + DeclCollectionContext.prototype.popParent = function () { + this.parentChain.length--; + }; + + DeclCollectionContext.prototype.containingModuleHasExportAssignment = function () { + TypeScript.Debug.assert(this.containingModuleHasExportAssignmentArray.length > 0); + return TypeScript.ArrayUtilities.last(this.containingModuleHasExportAssignmentArray); + }; + + DeclCollectionContext.prototype.isParsingAmbientModule = function () { + TypeScript.Debug.assert(this.isParsingAmbientModuleArray.length > 0); + return TypeScript.ArrayUtilities.last(this.isParsingAmbientModuleArray); + }; + return DeclCollectionContext; + })(); + TypeScript.DeclCollectionContext = DeclCollectionContext; + + function preCollectImportDecls(ast, parentAST, context) { + var importDecl = ast; + var declFlags = 0 /* None */; + var span = TypeScript.TextSpan.fromBounds(importDecl.minChar, importDecl.limChar); + + var parent = context.getParent(); + + if (!context.containingModuleHasExportAssignment() && TypeScript.hasFlag(importDecl.getVarFlags(), 1 /* Exported */)) { + declFlags |= 1 /* Exported */; + } + + if (parent && (parent.kind === 536870912 /* WithBlock */ || (parent.flags & 2097152 /* DeclaredInAWithBlock */))) { + declFlags |= 2097152 /* DeclaredInAWithBlock */; + } + + var decl = new TypeScript.PullDecl(importDecl.id.text(), importDecl.id.actualText, 256 /* TypeAlias */, declFlags, span, context.scriptName); + context.semanticInfo.setDeclForAST(ast, decl); + context.semanticInfo.setASTForDecl(decl, ast); + + parent.addChildDecl(decl); + decl.setParentDecl(parent); + + return false; + } + + function preCollectModuleDecls(ast, parentAST, context) { + var moduleDecl = ast; + var declFlags = 0 /* None */; + var modName = (moduleDecl.name).text(); + var isDynamic = TypeScript.isQuoted(modName) || TypeScript.hasFlag(moduleDecl.getModuleFlags(), 512 /* IsDynamic */); + var kind = 4 /* Container */; + + if (!context.containingModuleHasExportAssignment() && (TypeScript.hasFlag(moduleDecl.getModuleFlags(), 1 /* Exported */) || context.isParsingAmbientModule())) { + declFlags |= 1 /* Exported */; + } + + if (TypeScript.hasFlag(moduleDecl.getModuleFlags(), 8 /* Ambient */) || context.isParsingAmbientModule() || context.isDeclareFile) { + declFlags |= 8 /* Ambient */; + } + + if (TypeScript.hasFlag(moduleDecl.getModuleFlags(), 128 /* IsEnum */)) { + declFlags |= (4096 /* Enum */ | 131072 /* InitializedEnum */); + kind = 64 /* Enum */; + } else { + kind = isDynamic ? 32 /* DynamicModule */ : 4 /* Container */; + } + + var span = TypeScript.TextSpan.fromBounds(moduleDecl.minChar, moduleDecl.limChar); + + var decl = new TypeScript.PullDecl(modName, (moduleDecl.name).actualText, kind, declFlags, span, context.scriptName); + context.semanticInfo.setDeclForAST(ast, decl); + context.semanticInfo.setASTForDecl(decl, ast); + + var parent = context.getParent(); + parent.addChildDecl(decl); + decl.setParentDecl(parent); + + context.pushParent(decl); + + context.containingModuleHasExportAssignmentArray.push(TypeScript.ArrayUtilities.any(moduleDecl.members.members, function (m) { + return m.nodeType() === 88 /* ExportAssignment */; + })); + context.isParsingAmbientModuleArray.push(context.isDeclareFile || TypeScript.ArrayUtilities.last(context.isParsingAmbientModuleArray) || TypeScript.hasFlag(moduleDecl.getModuleFlags(), 8 /* Ambient */)); + + return true; + } + + function preCollectClassDecls(classDecl, parentAST, context) { + var declFlags = 0 /* None */; + var constructorDeclKind = 1024 /* Variable */; + + if (!context.containingModuleHasExportAssignment() && (TypeScript.hasFlag(classDecl.getVarFlags(), 1 /* Exported */) || context.isParsingAmbientModule())) { + declFlags |= 1 /* Exported */; + } + + if (TypeScript.hasFlag(classDecl.getVarFlags(), 8 /* Ambient */) || context.isParsingAmbientModule() || context.isDeclareFile) { + declFlags |= 8 /* Ambient */; + } + + var span = TypeScript.TextSpan.fromBounds(classDecl.minChar, classDecl.limChar); + + var decl = new TypeScript.PullDecl(classDecl.name.text(), classDecl.name.actualText, 8 /* Class */, declFlags, span, context.scriptName); + + var constructorDecl = new TypeScript.PullDecl(classDecl.name.text(), classDecl.name.actualText, constructorDeclKind, declFlags | 16384 /* ClassConstructorVariable */, span, context.scriptName); + + decl.setValueDecl(constructorDecl); + + var parent = context.getParent(); + parent.addChildDecl(decl); + parent.addChildDecl(constructorDecl); + decl.setParentDecl(parent); + constructorDecl.setParentDecl(parent); + + context.pushParent(decl); + + context.semanticInfo.setDeclForAST(classDecl, decl); + context.semanticInfo.setASTForDecl(decl, classDecl); + context.semanticInfo.setASTForDecl(constructorDecl, classDecl); + + return true; + } + + function createObjectTypeDeclaration(interfaceDecl, context) { + var declFlags = 0 /* None */; + + var span = TypeScript.TextSpan.fromBounds(interfaceDecl.minChar, interfaceDecl.limChar); + + var parent = context.getParent(); + + if (parent && (parent.kind === 536870912 /* WithBlock */ || (parent.flags & 2097152 /* DeclaredInAWithBlock */))) { + declFlags |= 2097152 /* DeclaredInAWithBlock */; + } + + var decl = new TypeScript.PullDecl("", "", 8388608 /* ObjectType */, declFlags, span, context.scriptName); + context.semanticInfo.setDeclForAST(interfaceDecl, decl); + context.semanticInfo.setASTForDecl(decl, interfaceDecl); + + if (parent) { + parent.addChildDecl(decl); + decl.setParentDecl(parent); + } + + context.pushParent(decl); + + return true; + } + + function preCollectInterfaceDecls(interfaceDecl, parentAST, context) { + var declFlags = 0 /* None */; + + if (interfaceDecl.getFlags() & 8 /* TypeReference */) { + return createObjectTypeDeclaration(interfaceDecl, context); + } + + if (!context.containingModuleHasExportAssignment() && (TypeScript.hasFlag(interfaceDecl.getVarFlags(), 1 /* Exported */) || context.isParsingAmbientModule())) { + declFlags |= 1 /* Exported */; + } + + var span = TypeScript.TextSpan.fromBounds(interfaceDecl.minChar, interfaceDecl.limChar); + + var decl = new TypeScript.PullDecl(interfaceDecl.name.text(), interfaceDecl.name.actualText, 16 /* Interface */, declFlags, span, context.scriptName); + context.semanticInfo.setDeclForAST(interfaceDecl, decl); + context.semanticInfo.setASTForDecl(decl, interfaceDecl); + + var parent = context.getParent(); + + if (parent) { + parent.addChildDecl(decl); + decl.setParentDecl(parent); + } + + context.pushParent(decl); + + return true; + } + + function preCollectParameterDecl(argDecl, parentAST, context) { + var declFlags = 0 /* None */; + + if (TypeScript.hasFlag(argDecl.getVarFlags(), 2 /* Private */)) { + declFlags |= 2 /* Private */; + } else { + declFlags |= 4 /* Public */; + } + + if (TypeScript.hasFlag(argDecl.getFlags(), 4 /* OptionalName */) || TypeScript.hasFlag(argDecl.id.getFlags(), 4 /* OptionalName */)) { + declFlags |= 128 /* Optional */; + } + + var parent = context.getParent(); + + if (parent && (parent.kind === 536870912 /* WithBlock */ || (parent.flags & 2097152 /* DeclaredInAWithBlock */))) { + declFlags |= 2097152 /* DeclaredInAWithBlock */; + } + + var span = TypeScript.TextSpan.fromBounds(argDecl.minChar, argDecl.limChar); + + var decl = new TypeScript.PullDecl(argDecl.id.text(), argDecl.id.actualText, 2048 /* Parameter */, declFlags, span, context.scriptName); + + parent.addChildDecl(decl); + decl.setParentDecl(parent); + + if (TypeScript.hasFlag(argDecl.getVarFlags(), 256 /* Property */)) { + var propDecl = new TypeScript.PullDecl(argDecl.id.text(), argDecl.id.actualText, 4096 /* Property */, declFlags, span, context.scriptName); + propDecl.setValueDecl(decl); + decl.setFlag(8388608 /* PropertyParameter */); + context.parentChain[context.parentChain.length - 2].addChildDecl(propDecl); + propDecl.setParentDecl(context.parentChain[context.parentChain.length - 2]); + context.semanticInfo.setASTForDecl(decl, argDecl); + context.semanticInfo.setASTForDecl(propDecl, argDecl); + context.semanticInfo.setDeclForAST(argDecl, propDecl); + } else { + context.semanticInfo.setASTForDecl(decl, argDecl); + context.semanticInfo.setDeclForAST(argDecl, decl); + } + + if (argDecl.typeExpr && ((argDecl.typeExpr).term.nodeType() === 15 /* InterfaceDeclaration */ || (argDecl.typeExpr).term.nodeType() === 13 /* FunctionDeclaration */)) { + var declCollectionContext = new DeclCollectionContext(context.semanticInfo, context.scriptName); + + if (parent) { + declCollectionContext.pushParent(parent); + } + + TypeScript.getAstWalkerFactory().walk((argDecl.typeExpr).term, preCollectDecls, postCollectDecls, null, declCollectionContext); + } + + return false; + } + + function preCollectTypeParameterDecl(typeParameterDecl, parentAST, context) { + var declFlags = 0 /* None */; + + var span = TypeScript.TextSpan.fromBounds(typeParameterDecl.minChar, typeParameterDecl.limChar); + + var parent = context.getParent(); + + if (parent && (parent.kind === 536870912 /* WithBlock */ || (parent.flags & 2097152 /* DeclaredInAWithBlock */))) { + declFlags |= 2097152 /* DeclaredInAWithBlock */; + } + + var decl = new TypeScript.PullDecl(typeParameterDecl.name.text(), typeParameterDecl.name.actualText, 8192 /* TypeParameter */, declFlags, span, context.scriptName); + context.semanticInfo.setASTForDecl(decl, typeParameterDecl); + context.semanticInfo.setDeclForAST(typeParameterDecl, decl); + + parent.addChildDecl(decl); + decl.setParentDecl(parent); + + if (typeParameterDecl.constraint && ((typeParameterDecl.constraint).term.nodeType() === 15 /* InterfaceDeclaration */ || (typeParameterDecl.constraint).term.nodeType() === 13 /* FunctionDeclaration */)) { + var declCollectionContext = new DeclCollectionContext(context.semanticInfo, context.scriptName); + + if (parent) { + declCollectionContext.pushParent(parent); + } + + TypeScript.getAstWalkerFactory().walk((typeParameterDecl.constraint).term, preCollectDecls, postCollectDecls, null, declCollectionContext); + } + + return true; + } + + function createPropertySignature(propertyDecl, context) { + var declFlags = 4 /* Public */; + var parent = context.getParent(); + var declType = parent.kind === 64 /* Enum */ ? 67108864 /* EnumMember */ : 4096 /* Property */; + + if (TypeScript.hasFlag(propertyDecl.id.getFlags(), 4 /* OptionalName */)) { + declFlags |= 128 /* Optional */; + } + + if (propertyDecl.constantValue !== null) { + declFlags |= 524288 /* Constant */; + } + + var span = TypeScript.TextSpan.fromBounds(propertyDecl.minChar, propertyDecl.limChar); + + var decl = new TypeScript.PullDecl(propertyDecl.id.text(), propertyDecl.id.actualText, declType, declFlags, span, context.scriptName); + context.semanticInfo.setDeclForAST(propertyDecl, decl); + context.semanticInfo.setASTForDecl(decl, propertyDecl); + + parent.addChildDecl(decl); + decl.setParentDecl(parent); + + if (propertyDecl.typeExpr && ((propertyDecl.typeExpr).term.nodeType() === 15 /* InterfaceDeclaration */ || (propertyDecl.typeExpr).term.nodeType() === 13 /* FunctionDeclaration */)) { + var declCollectionContext = new DeclCollectionContext(context.semanticInfo, context.scriptName); + + if (parent) { + declCollectionContext.pushParent(parent); + } + + TypeScript.getAstWalkerFactory().walk((propertyDecl.typeExpr).term, preCollectDecls, postCollectDecls, null, declCollectionContext); + } + + return false; + } + + function createMemberVariableDeclaration(memberDecl, context) { + var declFlags = 0 /* None */; + var declType = 4096 /* Property */; + + if (TypeScript.hasFlag(memberDecl.getVarFlags(), 2 /* Private */)) { + declFlags |= 2 /* Private */; + } else { + declFlags |= 4 /* Public */; + } + + if (TypeScript.hasFlag(memberDecl.getVarFlags(), 16 /* Static */)) { + declFlags |= 16 /* Static */; + } + + var span = TypeScript.TextSpan.fromBounds(memberDecl.minChar, memberDecl.limChar); + + var decl = new TypeScript.PullDecl(memberDecl.id.text(), memberDecl.id.actualText, declType, declFlags, span, context.scriptName); + context.semanticInfo.setDeclForAST(memberDecl, decl); + context.semanticInfo.setASTForDecl(decl, memberDecl); + + var parent = context.getParent(); + parent.addChildDecl(decl); + decl.setParentDecl(parent); + + if (memberDecl.typeExpr && ((memberDecl.typeExpr).term.nodeType() === 15 /* InterfaceDeclaration */ || (memberDecl.typeExpr).term.nodeType() === 13 /* FunctionDeclaration */)) { + var declCollectionContext = new DeclCollectionContext(context.semanticInfo, context.scriptName); + + if (parent) { + declCollectionContext.pushParent(parent); + } + + TypeScript.getAstWalkerFactory().walk((memberDecl.typeExpr).term, preCollectDecls, postCollectDecls, null, declCollectionContext); + } + + return false; + } + + function createVariableDeclaration(varDecl, context) { + var declFlags = 0 /* None */; + var declType = 1024 /* Variable */; + + if (!context.containingModuleHasExportAssignment() && (TypeScript.hasFlag(varDecl.getVarFlags(), 1 /* Exported */) || context.isParsingAmbientModule())) { + declFlags |= 1 /* Exported */; + } + + if (TypeScript.hasFlag(varDecl.getVarFlags(), 8 /* Ambient */) || context.isParsingAmbientModule() || context.isDeclareFile) { + declFlags |= 8 /* Ambient */; + } + + var span = TypeScript.TextSpan.fromBounds(varDecl.minChar, varDecl.limChar); + + var parent = context.getParent(); + + if (parent && (parent.kind === 536870912 /* WithBlock */ || (parent.flags & 2097152 /* DeclaredInAWithBlock */))) { + declFlags |= 2097152 /* DeclaredInAWithBlock */; + } + + var decl = new TypeScript.PullDecl(varDecl.id.text(), varDecl.id.actualText, declType, declFlags, span, context.scriptName); + context.semanticInfo.setDeclForAST(varDecl, decl); + context.semanticInfo.setASTForDecl(decl, varDecl); + + parent.addChildDecl(decl); + decl.setParentDecl(parent); + + if (varDecl.typeExpr && ((varDecl.typeExpr).term.nodeType() === 15 /* InterfaceDeclaration */ || (varDecl.typeExpr).term.nodeType() === 13 /* FunctionDeclaration */)) { + var declCollectionContext = new DeclCollectionContext(context.semanticInfo, context.scriptName); + + if (parent) { + declCollectionContext.pushParent(parent); + } + + TypeScript.getAstWalkerFactory().walk((varDecl.typeExpr).term, preCollectDecls, postCollectDecls, null, declCollectionContext); + } + + return false; + } + + function preCollectVarDecls(ast, parentAST, context) { + var varDecl = ast; + var declFlags = 0 /* None */; + var declType = 1024 /* Variable */; + var isProperty = false; + var isStatic = false; + + if (TypeScript.hasFlag(varDecl.getVarFlags(), 2048 /* ClassProperty */)) { + return createMemberVariableDeclaration(varDecl, context); + } else if (TypeScript.hasFlag(varDecl.getVarFlags(), 256 /* Property */)) { + return createPropertySignature(varDecl, context); + } + + return createVariableDeclaration(varDecl, context); + } + + function createFunctionTypeDeclaration(functionTypeDeclAST, context) { + var declFlags = 2048 /* Signature */; + var declType = 16777216 /* FunctionType */; + + var span = TypeScript.TextSpan.fromBounds(functionTypeDeclAST.minChar, functionTypeDeclAST.limChar); + + var parent = context.getParent(); + + if (parent && (parent.kind === 536870912 /* WithBlock */ || (parent.flags & 2097152 /* DeclaredInAWithBlock */))) { + declFlags |= 2097152 /* DeclaredInAWithBlock */; + } + + var decl = new TypeScript.PullDecl("", "", declType, declFlags, span, context.semanticInfo.getPath()); + context.semanticInfo.setDeclForAST(functionTypeDeclAST, decl); + context.semanticInfo.setASTForDecl(decl, functionTypeDeclAST); + + if (parent) { + parent.addChildDecl(decl); + decl.setParentDecl(parent); + } + + context.pushParent(decl); + + if (functionTypeDeclAST.returnTypeAnnotation && ((functionTypeDeclAST.returnTypeAnnotation).term.nodeType() === 15 /* InterfaceDeclaration */ || (functionTypeDeclAST.returnTypeAnnotation).term.nodeType() === 13 /* FunctionDeclaration */)) { + var declCollectionContext = new DeclCollectionContext(context.semanticInfo, context.scriptName); + + declCollectionContext.pushParent(decl); + + TypeScript.getAstWalkerFactory().walk((functionTypeDeclAST.returnTypeAnnotation).term, preCollectDecls, postCollectDecls, null, declCollectionContext); + } + + return true; + } + + function createConstructorTypeDeclaration(constructorTypeDeclAST, context) { + var declFlags = 0 /* None */; + var declType = 33554432 /* ConstructorType */; + + var span = TypeScript.TextSpan.fromBounds(constructorTypeDeclAST.minChar, constructorTypeDeclAST.limChar); + + var parent = context.getParent(); + + if (parent && (parent.kind === 536870912 /* WithBlock */ || (parent.flags & 2097152 /* DeclaredInAWithBlock */))) { + declFlags |= 2097152 /* DeclaredInAWithBlock */; + } + + var decl = new TypeScript.PullDecl("", "", declType, declFlags, span, context.semanticInfo.getPath()); + context.semanticInfo.setDeclForAST(constructorTypeDeclAST, decl); + context.semanticInfo.setASTForDecl(decl, constructorTypeDeclAST); + + if (parent) { + parent.addChildDecl(decl); + decl.setParentDecl(parent); + } + + context.pushParent(decl); + + if (constructorTypeDeclAST.returnTypeAnnotation && ((constructorTypeDeclAST.returnTypeAnnotation).term.nodeType() === 15 /* InterfaceDeclaration */ || (constructorTypeDeclAST.returnTypeAnnotation).term.nodeType() === 13 /* FunctionDeclaration */)) { + var declCollectionContext = new DeclCollectionContext(context.semanticInfo, context.scriptName); + + declCollectionContext.pushParent(decl); + + TypeScript.getAstWalkerFactory().walk((constructorTypeDeclAST.returnTypeAnnotation).term, preCollectDecls, postCollectDecls, null, declCollectionContext); + } + + return true; + } + + function createFunctionDeclaration(funcDeclAST, context) { + var declFlags = 0 /* None */; + var declType = 16384 /* Function */; + + if (!context.containingModuleHasExportAssignment() && (TypeScript.hasFlag(funcDeclAST.getFunctionFlags(), 1 /* Exported */) || context.isParsingAmbientModule())) { + declFlags |= 1 /* Exported */; + } + + if (TypeScript.hasFlag(funcDeclAST.getFunctionFlags(), 8 /* Ambient */) || context.isParsingAmbientModule() || context.isDeclareFile) { + declFlags |= 8 /* Ambient */; + } + + if (!funcDeclAST.block) { + declFlags |= 2048 /* Signature */; + } + + var span = TypeScript.TextSpan.fromBounds(funcDeclAST.minChar, funcDeclAST.limChar); + + var parent = context.getParent(); + + if (parent && (parent.kind === 536870912 /* WithBlock */ || (parent.flags & 2097152 /* DeclaredInAWithBlock */))) { + declFlags |= 2097152 /* DeclaredInAWithBlock */; + } + + var decl = new TypeScript.PullDecl(funcDeclAST.name.text(), funcDeclAST.name.actualText, declType, declFlags, span, context.scriptName); + context.semanticInfo.setDeclForAST(funcDeclAST, decl); + context.semanticInfo.setASTForDecl(decl, funcDeclAST); + + if (parent) { + parent.addChildDecl(decl); + decl.setParentDecl(parent); + } + + context.pushParent(decl); + + if (funcDeclAST.returnTypeAnnotation && ((funcDeclAST.returnTypeAnnotation).term.nodeType() === 15 /* InterfaceDeclaration */ || (funcDeclAST.returnTypeAnnotation).term.nodeType() === 13 /* FunctionDeclaration */)) { + var declCollectionContext = new DeclCollectionContext(context.semanticInfo, context.scriptName); + + declCollectionContext.pushParent(decl); + + TypeScript.getAstWalkerFactory().walk((funcDeclAST.returnTypeAnnotation).term, preCollectDecls, postCollectDecls, null, declCollectionContext); + } + + return true; + } + + function createFunctionExpressionDeclaration(functionExpressionDeclAST, context) { + var declFlags = 0 /* None */; + + if (TypeScript.hasFlag(functionExpressionDeclAST.getFunctionFlags(), 2048 /* IsFatArrowFunction */)) { + declFlags |= 8192 /* FatArrow */; + } + + var span = TypeScript.TextSpan.fromBounds(functionExpressionDeclAST.minChar, functionExpressionDeclAST.limChar); + + var parent = context.getParent(); + + if (parent && (parent.kind === 536870912 /* WithBlock */ || (parent.flags & 2097152 /* DeclaredInAWithBlock */))) { + declFlags |= 2097152 /* DeclaredInAWithBlock */; + } + + var name = functionExpressionDeclAST.name ? functionExpressionDeclAST.name.actualText : ""; + var decl = new TypeScript.PullFunctionExpressionDecl(name, declFlags, span, context.scriptName); + context.semanticInfo.setDeclForAST(functionExpressionDeclAST, decl); + context.semanticInfo.setASTForDecl(decl, functionExpressionDeclAST); + + if (parent) { + parent.addChildDecl(decl); + decl.setParentDecl(parent); + } + + context.pushParent(decl); + + if (functionExpressionDeclAST.returnTypeAnnotation && ((functionExpressionDeclAST.returnTypeAnnotation).term.nodeType() === 15 /* InterfaceDeclaration */ || (functionExpressionDeclAST.returnTypeAnnotation).term.nodeType() === 13 /* FunctionDeclaration */)) { + var declCollectionContext = new DeclCollectionContext(context.semanticInfo, context.scriptName); + + declCollectionContext.pushParent(decl); + + TypeScript.getAstWalkerFactory().walk((functionExpressionDeclAST.returnTypeAnnotation).term, preCollectDecls, postCollectDecls, null, declCollectionContext); + } + + return true; + } + + function createMemberFunctionDeclaration(memberFunctionDeclAST, context) { + var declFlags = 0 /* None */; + var declType = 65536 /* Method */; + + if (TypeScript.hasFlag(memberFunctionDeclAST.getFunctionFlags(), 16 /* Static */)) { + declFlags |= 16 /* Static */; + } + + if (TypeScript.hasFlag(memberFunctionDeclAST.getFunctionFlags(), 2 /* Private */)) { + declFlags |= 2 /* Private */; + } else { + declFlags |= 4 /* Public */; + } + + if (!memberFunctionDeclAST.block) { + declFlags |= 2048 /* Signature */; + } + + if (TypeScript.hasFlag(memberFunctionDeclAST.name.getFlags(), 4 /* OptionalName */)) { + declFlags |= 128 /* Optional */; + } + + var span = TypeScript.TextSpan.fromBounds(memberFunctionDeclAST.minChar, memberFunctionDeclAST.limChar); + + var decl = new TypeScript.PullDecl(memberFunctionDeclAST.name.text(), memberFunctionDeclAST.name.actualText, declType, declFlags, span, context.scriptName); + context.semanticInfo.setDeclForAST(memberFunctionDeclAST, decl); + context.semanticInfo.setASTForDecl(decl, memberFunctionDeclAST); + + var parent = context.getParent(); + + if (parent) { + parent.addChildDecl(decl); + decl.setParentDecl(parent); + } + + context.pushParent(decl); + + if (memberFunctionDeclAST.returnTypeAnnotation && ((memberFunctionDeclAST.returnTypeAnnotation).term.nodeType() === 15 /* InterfaceDeclaration */ || (memberFunctionDeclAST.returnTypeAnnotation).term.nodeType() === 13 /* FunctionDeclaration */)) { + var declCollectionContext = new DeclCollectionContext(context.semanticInfo, context.scriptName); + + declCollectionContext.pushParent(decl); + + TypeScript.getAstWalkerFactory().walk((memberFunctionDeclAST.returnTypeAnnotation).term, preCollectDecls, postCollectDecls, null, declCollectionContext); + } + + return true; + } + + function createIndexSignatureDeclaration(indexSignatureDeclAST, context) { + var declFlags = 2048 /* Signature */ | 1024 /* Index */; + var declType = 4194304 /* IndexSignature */; + + var span = TypeScript.TextSpan.fromBounds(indexSignatureDeclAST.minChar, indexSignatureDeclAST.limChar); + + var parent = context.getParent(); + + if (parent && (parent.kind === 536870912 /* WithBlock */ || (parent.flags & 2097152 /* DeclaredInAWithBlock */))) { + declFlags |= 2097152 /* DeclaredInAWithBlock */; + } + + var decl = new TypeScript.PullDecl("", "", declType, declFlags, span, context.scriptName); + context.semanticInfo.setDeclForAST(indexSignatureDeclAST, decl); + context.semanticInfo.setASTForDecl(decl, indexSignatureDeclAST); + + if (parent) { + parent.addChildDecl(decl); + decl.setParentDecl(parent); + } + + context.pushParent(decl); + + if (indexSignatureDeclAST.returnTypeAnnotation && ((indexSignatureDeclAST.returnTypeAnnotation).term.nodeType() === 15 /* InterfaceDeclaration */ || (indexSignatureDeclAST.returnTypeAnnotation).term.nodeType() === 13 /* FunctionDeclaration */)) { + var declCollectionContext = new DeclCollectionContext(context.semanticInfo, context.scriptName); + + if (parent) { + declCollectionContext.pushParent(parent); + } + + TypeScript.getAstWalkerFactory().walk((indexSignatureDeclAST.returnTypeAnnotation).term, preCollectDecls, postCollectDecls, null, declCollectionContext); + } + + return true; + } + + function createCallSignatureDeclaration(callSignatureDeclAST, context) { + var declFlags = 2048 /* Signature */ | 256 /* Call */; + var declType = 1048576 /* CallSignature */; + + var span = TypeScript.TextSpan.fromBounds(callSignatureDeclAST.minChar, callSignatureDeclAST.limChar); + + var parent = context.getParent(); + + if (parent && (parent.kind === 536870912 /* WithBlock */ || (parent.flags & 2097152 /* DeclaredInAWithBlock */))) { + declFlags |= 2097152 /* DeclaredInAWithBlock */; + } + + var decl = new TypeScript.PullDecl("", "", declType, declFlags, span, context.scriptName); + context.semanticInfo.setDeclForAST(callSignatureDeclAST, decl); + context.semanticInfo.setASTForDecl(decl, callSignatureDeclAST); + + if (parent) { + parent.addChildDecl(decl); + decl.setParentDecl(parent); + } + + context.pushParent(decl); + + if (callSignatureDeclAST.returnTypeAnnotation && ((callSignatureDeclAST.returnTypeAnnotation).term.nodeType() === 15 /* InterfaceDeclaration */ || (callSignatureDeclAST.returnTypeAnnotation).term.nodeType() === 13 /* FunctionDeclaration */)) { + var declCollectionContext = new DeclCollectionContext(context.semanticInfo, context.scriptName); + + declCollectionContext.pushParent(decl); + + TypeScript.getAstWalkerFactory().walk((callSignatureDeclAST.returnTypeAnnotation).term, preCollectDecls, postCollectDecls, null, declCollectionContext); + } + + return true; + } + + function createConstructSignatureDeclaration(constructSignatureDeclAST, context) { + var declFlags = 2048 /* Signature */ | 256 /* Call */; + var declType = 2097152 /* ConstructSignature */; + + var span = TypeScript.TextSpan.fromBounds(constructSignatureDeclAST.minChar, constructSignatureDeclAST.limChar); + + var parent = context.getParent(); + + if (parent && (parent.kind === 536870912 /* WithBlock */ || (parent.flags & 2097152 /* DeclaredInAWithBlock */))) { + declFlags |= 2097152 /* DeclaredInAWithBlock */; + } + + var decl = new TypeScript.PullDecl("", "", declType, declFlags, span, context.scriptName); + context.semanticInfo.setDeclForAST(constructSignatureDeclAST, decl); + context.semanticInfo.setASTForDecl(decl, constructSignatureDeclAST); + + if (parent) { + parent.addChildDecl(decl); + decl.setParentDecl(parent); + } + + context.pushParent(decl); + + if (constructSignatureDeclAST.returnTypeAnnotation && ((constructSignatureDeclAST.returnTypeAnnotation).term.nodeType() === 15 /* InterfaceDeclaration */ || (constructSignatureDeclAST.returnTypeAnnotation).term.nodeType() === 13 /* FunctionDeclaration */)) { + var declCollectionContext = new DeclCollectionContext(context.semanticInfo, context.scriptName); + + declCollectionContext.pushParent(decl); + + TypeScript.getAstWalkerFactory().walk((constructSignatureDeclAST.returnTypeAnnotation).term, preCollectDecls, postCollectDecls, null, declCollectionContext); + } + + return true; + } + + function createClassConstructorDeclaration(constructorDeclAST, context) { + var declFlags = 512 /* Constructor */; + var declType = 32768 /* ConstructorMethod */; + + if (!constructorDeclAST.block) { + declFlags |= 2048 /* Signature */; + } + + var span = TypeScript.TextSpan.fromBounds(constructorDeclAST.minChar, constructorDeclAST.limChar); + + var parent = context.getParent(); + + if (parent) { + var parentFlags = parent.flags; + + if (parentFlags & 1 /* Exported */) { + declFlags |= 1 /* Exported */; + } + } + + var decl = new TypeScript.PullDecl(parent.name, parent.getDisplayName(), declType, declFlags, span, context.scriptName); + context.semanticInfo.setDeclForAST(constructorDeclAST, decl); + context.semanticInfo.setASTForDecl(decl, constructorDeclAST); + + if (parent) { + parent.addChildDecl(decl); + decl.setParentDecl(parent); + } + + context.pushParent(decl); + + if (constructorDeclAST.returnTypeAnnotation && ((constructorDeclAST.returnTypeAnnotation).term.nodeType() === 15 /* InterfaceDeclaration */ || (constructorDeclAST.returnTypeAnnotation).term.nodeType() === 13 /* FunctionDeclaration */)) { + var declCollectionContext = new DeclCollectionContext(context.semanticInfo, context.scriptName); + + declCollectionContext.pushParent(decl); + + TypeScript.getAstWalkerFactory().walk((constructorDeclAST.returnTypeAnnotation).term, preCollectDecls, postCollectDecls, null, declCollectionContext); + } + + return true; + } + + function createGetAccessorDeclaration(getAccessorDeclAST, context) { + var declFlags = 4 /* Public */; + var declType = 262144 /* GetAccessor */; + + if (TypeScript.hasFlag(getAccessorDeclAST.getFunctionFlags(), 16 /* Static */)) { + declFlags |= 16 /* Static */; + } + + if (TypeScript.hasFlag(getAccessorDeclAST.name.getFlags(), 4 /* OptionalName */)) { + declFlags |= 128 /* Optional */; + } + + if (TypeScript.hasFlag(getAccessorDeclAST.getFunctionFlags(), 2 /* Private */)) { + declFlags |= 2 /* Private */; + } else { + declFlags |= 4 /* Public */; + } + + var span = TypeScript.TextSpan.fromBounds(getAccessorDeclAST.minChar, getAccessorDeclAST.limChar); + + var parent = context.getParent(); + + if (parent && (parent.kind === 536870912 /* WithBlock */ || (parent.flags & 2097152 /* DeclaredInAWithBlock */))) { + declFlags |= 2097152 /* DeclaredInAWithBlock */; + } + + var decl = new TypeScript.PullDecl(getAccessorDeclAST.name.text(), getAccessorDeclAST.name.actualText, declType, declFlags, span, context.scriptName); + context.semanticInfo.setDeclForAST(getAccessorDeclAST, decl); + context.semanticInfo.setASTForDecl(decl, getAccessorDeclAST); + + if (parent) { + parent.addChildDecl(decl); + decl.setParentDecl(parent); + } + + context.pushParent(decl); + + if (getAccessorDeclAST.returnTypeAnnotation && ((getAccessorDeclAST.returnTypeAnnotation).term.nodeType() === 15 /* InterfaceDeclaration */ || (getAccessorDeclAST.returnTypeAnnotation).term.nodeType() === 13 /* FunctionDeclaration */)) { + var declCollectionContext = new DeclCollectionContext(context.semanticInfo, context.scriptName); + + declCollectionContext.pushParent(decl); + + TypeScript.getAstWalkerFactory().walk((getAccessorDeclAST.returnTypeAnnotation).term, preCollectDecls, postCollectDecls, null, declCollectionContext); + } + + return true; + } + + function createSetAccessorDeclaration(setAccessorDeclAST, context) { + var declFlags = 4 /* Public */; + var declType = 524288 /* SetAccessor */; + + if (TypeScript.hasFlag(setAccessorDeclAST.getFunctionFlags(), 16 /* Static */)) { + declFlags |= 16 /* Static */; + } + + if (TypeScript.hasFlag(setAccessorDeclAST.name.getFlags(), 4 /* OptionalName */)) { + declFlags |= 128 /* Optional */; + } + + if (TypeScript.hasFlag(setAccessorDeclAST.getFunctionFlags(), 2 /* Private */)) { + declFlags |= 2 /* Private */; + } else { + declFlags |= 4 /* Public */; + } + + var span = TypeScript.TextSpan.fromBounds(setAccessorDeclAST.minChar, setAccessorDeclAST.limChar); + + var parent = context.getParent(); + + if (parent && (parent.kind === 536870912 /* WithBlock */ || (parent.flags & 2097152 /* DeclaredInAWithBlock */))) { + declFlags |= 2097152 /* DeclaredInAWithBlock */; + } + + var decl = new TypeScript.PullDecl(setAccessorDeclAST.name.actualText, setAccessorDeclAST.name.actualText, declType, declFlags, span, context.scriptName); + context.semanticInfo.setDeclForAST(setAccessorDeclAST, decl); + context.semanticInfo.setASTForDecl(decl, setAccessorDeclAST); + + if (parent) { + parent.addChildDecl(decl); + decl.setParentDecl(parent); + } + + context.pushParent(decl); + + return true; + } + + function preCollectCatchDecls(ast, parentAST, context) { + var declFlags = 0 /* None */; + var declType = 1073741824 /* CatchBlock */; + + var span = TypeScript.TextSpan.fromBounds(ast.minChar, ast.limChar); + + var parent = context.getParent(); + + if (parent && (parent.kind === 536870912 /* WithBlock */ || (parent.flags & 2097152 /* DeclaredInAWithBlock */))) { + declFlags |= 2097152 /* DeclaredInAWithBlock */; + } + + var decl = new TypeScript.PullDecl("", "", declType, declFlags, span, context.scriptName); + context.semanticInfo.setDeclForAST(ast, decl); + context.semanticInfo.setASTForDecl(decl, ast); + + if (parent) { + parent.addChildDecl(decl); + decl.setParentDecl(parent); + } + + context.pushParent(decl); + + return true; + } + + function preCollectWithDecls(ast, parentAST, context) { + var declFlags = 0 /* None */; + var declType = 536870912 /* WithBlock */; + + var span = TypeScript.TextSpan.fromBounds(ast.minChar, ast.limChar); + + var parent = context.getParent(); + + var decl = new TypeScript.PullDecl("", "", declType, declFlags, span, context.scriptName); + context.semanticInfo.setDeclForAST(ast, decl); + context.semanticInfo.setASTForDecl(decl, ast); + + if (parent) { + parent.addChildDecl(decl); + decl.setParentDecl(parent); + } + + context.pushParent(decl); + + return true; + } + + function preCollectFuncDecls(ast, parentAST, context) { + var funcDecl = ast; + + if (funcDecl.isConstructor) { + return createClassConstructorDeclaration(funcDecl, context); + } else if (funcDecl.isGetAccessor()) { + return createGetAccessorDeclaration(funcDecl, context); + } else if (funcDecl.isSetAccessor()) { + return createSetAccessorDeclaration(funcDecl, context); + } else if (TypeScript.hasFlag(funcDecl.getFunctionFlags(), 1024 /* ConstructMember */)) { + return TypeScript.hasFlag(funcDecl.getFlags(), 8 /* TypeReference */) ? createConstructorTypeDeclaration(funcDecl, context) : createConstructSignatureDeclaration(funcDecl, context); + } else if (TypeScript.hasFlag(funcDecl.getFunctionFlags(), 512 /* CallMember */)) { + return createCallSignatureDeclaration(funcDecl, context); + } else if (TypeScript.hasFlag(funcDecl.getFunctionFlags(), 4096 /* IndexerMember */)) { + return createIndexSignatureDeclaration(funcDecl, context); + } else if (TypeScript.hasFlag(funcDecl.getFlags(), 8 /* TypeReference */)) { + return createFunctionTypeDeclaration(funcDecl, context); + } else if (TypeScript.hasFlag(funcDecl.getFunctionFlags(), 256 /* Method */)) { + return createMemberFunctionDeclaration(funcDecl, context); + } else if (TypeScript.hasFlag(funcDecl.getFunctionFlags(), (8192 /* IsFunctionExpression */ | 2048 /* IsFatArrowFunction */ | 16384 /* IsFunctionProperty */))) { + return createFunctionExpressionDeclaration(funcDecl, context); + } + + return createFunctionDeclaration(funcDecl, context); + } + + function preCollectDecls(ast, parentAST, walker) { + var context = walker.state; + var go = false; + + if (ast.nodeType() === 2 /* Script */) { + var script = ast; + var span = TypeScript.TextSpan.fromBounds(script.minChar, script.limChar); + + var decl = new TypeScript.PullDecl(context.scriptName, context.scriptName, 1 /* Script */, 0 /* None */, span, context.scriptName); + context.semanticInfo.setDeclForAST(ast, decl); + context.semanticInfo.setASTForDecl(decl, ast); + + context.pushParent(decl); + context.isDeclareFile = script.isDeclareFile; + + go = true; + } else if (ast.nodeType() === 1 /* List */) { + go = true; + } else if (ast.nodeType() === 82 /* Block */) { + go = true; + } else if (ast.nodeType() === 19 /* VariableDeclaration */) { + go = true; + } else if (ast.nodeType() === 98 /* VariableStatement */) { + go = true; + } else if (ast.nodeType() === 16 /* ModuleDeclaration */) { + go = preCollectModuleDecls(ast, parentAST, context); + } else if (ast.nodeType() === 14 /* ClassDeclaration */) { + go = preCollectClassDecls(ast, parentAST, context); + } else if (ast.nodeType() === 15 /* InterfaceDeclaration */) { + go = preCollectInterfaceDecls(ast, parentAST, context); + } else if (ast.nodeType() === 20 /* Parameter */) { + go = preCollectParameterDecl(ast, parentAST, context); + } else if (ast.nodeType() === 18 /* VariableDeclarator */) { + go = preCollectVarDecls(ast, parentAST, context); + } else if (ast.nodeType() === 13 /* FunctionDeclaration */) { + go = preCollectFuncDecls(ast, parentAST, context); + } else if (ast.nodeType() === 17 /* ImportDeclaration */) { + go = preCollectImportDecls(ast, parentAST, context); + } else if (ast.nodeType() === 9 /* TypeParameter */) { + go = preCollectTypeParameterDecl(ast, parentAST, context); + } else if (ast.nodeType() === 92 /* IfStatement */) { + go = true; + } else if (ast.nodeType() === 91 /* ForStatement */) { + go = true; + } else if (ast.nodeType() === 90 /* ForInStatement */) { + go = true; + } else if (ast.nodeType() === 99 /* WhileStatement */) { + go = true; + } else if (ast.nodeType() === 86 /* DoStatement */) { + go = true; + } else if (ast.nodeType() === 26 /* CommaExpression */) { + go = true; + } else if (ast.nodeType() === 94 /* ReturnStatement */) { + go = true; + } else if (ast.nodeType() === 95 /* SwitchStatement */ || ast.nodeType() === 101 /* CaseClause */) { + go = true; + } else if (ast.nodeType() === 37 /* InvocationExpression */) { + go = true; + } else if (ast.nodeType() === 38 /* ObjectCreationExpression */) { + go = true; + } else if (ast.nodeType() === 97 /* TryStatement */) { + go = true; + } else if (ast.nodeType() === 93 /* LabeledStatement */) { + go = true; + } else if (ast.nodeType() === 102 /* CatchClause */) { + go = preCollectCatchDecls(ast, parentAST, context); + } else if (ast.nodeType() === 100 /* WithStatement */) { + go = preCollectWithDecls(ast, parentAST, context); + } + + walker.options.goChildren = go; + + return ast; + } + TypeScript.preCollectDecls = preCollectDecls; + + function isContainer(decl) { + return decl.kind === 4 /* Container */ || decl.kind === 32 /* DynamicModule */ || decl.kind === 64 /* Enum */; + } + + function getInitializationFlag(decl) { + if (decl.kind & 4 /* Container */) { + return 32768 /* InitializedModule */; + } else if (decl.kind & 64 /* Enum */) { + return 131072 /* InitializedEnum */; + } else if (decl.kind & 32 /* DynamicModule */) { + return 65536 /* InitializedDynamicModule */; + } + + return 0 /* None */; + } + + function hasInitializationFlag(decl) { + var kind = decl.kind; + + if (kind & 4 /* Container */) { + return (decl.flags & 32768 /* InitializedModule */) !== 0; + } else if (kind & 64 /* Enum */) { + return (decl.flags & 131072 /* InitializedEnum */) != 0; + } else if (kind & 32 /* DynamicModule */) { + return (decl.flags & 65536 /* InitializedDynamicModule */) !== 0; + } + + return false; + } + + function postCollectDecls(ast, parentAST, walker) { + var context = walker.state; + var parentDecl; + var initFlag = 0 /* None */; + + if (ast.nodeType() === 16 /* ModuleDeclaration */) { + var thisModule = context.getParent(); + context.popParent(); + context.containingModuleHasExportAssignmentArray.pop(); + context.isParsingAmbientModuleArray.pop(); + + parentDecl = context.getParent(); + + if (hasInitializationFlag(thisModule)) { + if (parentDecl && isContainer(parentDecl)) { + initFlag = getInitializationFlag(parentDecl); + parentDecl.setFlags(parentDecl.flags | initFlag); + } + + var valueDecl = new TypeScript.PullDecl(thisModule.name, thisModule.getDisplayName(), 1024 /* Variable */, thisModule.flags, thisModule.getSpan(), context.scriptName); + + thisModule.setValueDecl(valueDecl); + + context.semanticInfo.setASTForDecl(valueDecl, ast); + + if (parentDecl) { + parentDecl.addChildDecl(valueDecl); + valueDecl.setParentDecl(parentDecl); + } + } + } else if (ast.nodeType() === 14 /* ClassDeclaration */) { + context.popParent(); + + parentDecl = context.getParent(); + + if (parentDecl && isContainer(parentDecl)) { + initFlag = getInitializationFlag(parentDecl); + parentDecl.setFlags(parentDecl.flags | initFlag); + } + } else if (ast.nodeType() === 15 /* InterfaceDeclaration */) { + context.popParent(); + } else if (ast.nodeType() === 13 /* FunctionDeclaration */) { + context.popParent(); + + parentDecl = context.getParent(); + + if (parentDecl && isContainer(parentDecl)) { + initFlag = getInitializationFlag(parentDecl); + parentDecl.setFlags(parentDecl.flags | initFlag); + } + } else if (ast.nodeType() === 18 /* VariableDeclarator */) { + parentDecl = context.getParent(); + + if (parentDecl && isContainer(parentDecl)) { + initFlag = getInitializationFlag(parentDecl); + parentDecl.setFlags(parentDecl.flags | initFlag); + } + } else if (ast.nodeType() === 102 /* CatchClause */) { + parentDecl = context.getParent(); + + if (parentDecl && isContainer(parentDecl)) { + initFlag = getInitializationFlag(parentDecl); + parentDecl.setFlags(parentDecl.flags | initFlag); + } + + context.popParent(); + } else if (ast.nodeType() === 100 /* WithStatement */) { + parentDecl = context.getParent(); + + if (parentDecl && isContainer(parentDecl)) { + initFlag = getInitializationFlag(parentDecl); + parentDecl.setFlags(parentDecl.flags | initFlag); + } + + context.popParent(); + } + + return ast; + } + TypeScript.postCollectDecls = postCollectDecls; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + function getPathToDecl(decl) { + if (!decl) { + return []; + } + + var decls = decl.getParentPath(); + + if (decls) { + return decls; + } else { + decls = [decl]; + } + + var parentDecl = decl.getParentDecl(); + + while (parentDecl) { + if (parentDecl && decls[decls.length - 1] != parentDecl && !(parentDecl.kind & 512 /* ObjectLiteral */)) { + decls[decls.length] = parentDecl; + } + parentDecl = parentDecl.getParentDecl(); + } + + decls = decls.reverse(); + + decl.setParentPath(decls); + + return decls; + } + TypeScript.getPathToDecl = getPathToDecl; + + var PullSymbolBinder = (function () { + function PullSymbolBinder(semanticInfoChain) { + this.semanticInfoChain = semanticInfoChain; + this.functionTypeParameterCache = new TypeScript.BlockIntrinsics(); + this.semanticInfo = null; + } + PullSymbolBinder.prototype.findTypeParameterInCache = function (name) { + return this.functionTypeParameterCache[name]; + }; + + PullSymbolBinder.prototype.addTypeParameterToCache = function (typeParameter) { + this.functionTypeParameterCache[typeParameter.getName()] = typeParameter; + }; + + PullSymbolBinder.prototype.resetTypeParameterCache = function () { + this.functionTypeParameterCache = new TypeScript.BlockIntrinsics(); + }; + + PullSymbolBinder.prototype.setUnit = function (fileName) { + this.semanticInfo = this.semanticInfoChain.getUnit(fileName); + }; + + PullSymbolBinder.prototype.getParent = function (decl, returnInstanceType) { + if (typeof returnInstanceType === "undefined") { returnInstanceType = false; } + var parentDecl = decl.getParentDecl(); + + if (parentDecl.kind == 1 /* Script */) { + return null; + } + + var parent = parentDecl.getSymbol(); + + if (!parent && parentDecl && !parentDecl.isBound()) { + this.bindDeclToPullSymbol(parentDecl); + } + + parent = parentDecl.getSymbol(); + if (parent) { + var parentDeclKind = parentDecl.kind; + if (parentDeclKind == 262144 /* GetAccessor */) { + parent = (parent).getGetter(); + } else if (parentDeclKind == 524288 /* SetAccessor */) { + parent = (parent).getSetter(); + } + } + + if (parent) { + if (returnInstanceType && parent.isType() && parent.isContainer()) { + var instanceSymbol = (parent).getInstanceSymbol(); + + if (instanceSymbol) { + return instanceSymbol.type; + } + } + + return parent.type; + } + + return null; + }; + + PullSymbolBinder.prototype.findDeclsInContext = function (startingDecl, declKind, searchGlobally) { + if (!searchGlobally) { + var parentDecl = startingDecl.getParentDecl(); + return parentDecl.searchChildDecls(startingDecl.name, declKind); + } + + var contextSymbolPath = getPathToDecl(startingDecl); + + if (contextSymbolPath.length) { + var copyOfContextSymbolPath = []; + + for (var i = 0; i < contextSymbolPath.length; i++) { + if (contextSymbolPath[i].kind & 1 /* Script */) { + continue; + } + copyOfContextSymbolPath[copyOfContextSymbolPath.length] = contextSymbolPath[i].name; + } + + return this.semanticInfoChain.findDecls(copyOfContextSymbolPath, declKind); + } + + return this.semanticInfoChain.findDecls([name], declKind); + }; + + PullSymbolBinder.prototype.bindModuleDeclarationToPullSymbol = function (moduleContainerDecl) { + var modName = moduleContainerDecl.name; + + var moduleContainerTypeSymbol = null; + var moduleInstanceSymbol = null; + var moduleInstanceTypeSymbol = null; + + var moduleInstanceDecl = moduleContainerDecl.getValueDecl(); + + var moduleKind = moduleContainerDecl.kind; + + var parent = this.getParent(moduleContainerDecl); + var parentInstanceSymbol = this.getParent(moduleContainerDecl, true); + var parentDecl = moduleContainerDecl.getParentDecl(); + var moduleAST = this.semanticInfo.getASTForDecl(moduleContainerDecl); + + var isExported = moduleContainerDecl.flags & 1 /* Exported */; + var isEnum = (moduleKind & 64 /* Enum */) != 0; + var searchKind = isEnum ? 64 /* Enum */ : TypeScript.PullElementKind.SomeContainer; + var isInitializedModule = (moduleContainerDecl.flags & TypeScript.PullElementFlags.SomeInitializedModule) != 0; + + var createdNewSymbol = false; + + if (parent) { + if (isExported) { + moduleContainerTypeSymbol = parent.findNestedType(modName, searchKind); + } else { + moduleContainerTypeSymbol = parent.findContainedNonMemberType(modName); + + if (moduleContainerTypeSymbol && !(moduleContainerTypeSymbol.kind & searchKind)) { + moduleContainerTypeSymbol = null; + } + } + } else if (!isExported || moduleContainerDecl.kind === 32 /* DynamicModule */) { + moduleContainerTypeSymbol = this.semanticInfoChain.findTopLevelSymbol(modName, searchKind, this.semanticInfo.getPath()); + } + + if (moduleContainerTypeSymbol && moduleContainerTypeSymbol.kind !== moduleKind) { + if (isInitializedModule) { + moduleContainerDecl.addDiagnostic(new TypeScript.Diagnostic(this.semanticInfo.getPath(), moduleAST.minChar, moduleAST.getLength(), TypeScript.DiagnosticCode.Duplicate_identifier_0, [moduleContainerDecl.getDisplayName()])); + } + + moduleContainerTypeSymbol = null; + } + + if (moduleContainerTypeSymbol) { + moduleInstanceSymbol = moduleContainerTypeSymbol.getInstanceSymbol(); + } else { + moduleContainerTypeSymbol = new TypeScript.PullContainerTypeSymbol(modName, moduleKind); + createdNewSymbol = true; + + if (!parent) { + this.semanticInfoChain.cacheGlobalSymbol(moduleContainerTypeSymbol, searchKind); + } + } + + if (!moduleInstanceSymbol && isInitializedModule) { + var variableSymbol = null; + if (!isEnum) { + if (parentInstanceSymbol) { + if (isExported) { + variableSymbol = parentInstanceSymbol.findMember(modName, false); + + if (!variableSymbol) { + variableSymbol = parentInstanceSymbol.findContainedNonMember(modName); + } + } else { + variableSymbol = parentInstanceSymbol.findContainedNonMember(modName); + + if (!variableSymbol) { + variableSymbol = parentInstanceSymbol.findMember(modName, false); + } + } + + if (variableSymbol) { + var declarations = variableSymbol.getDeclarations(); + + if (declarations.length) { + var variableSymbolParentDecl = declarations[0].getParentDecl(); + + if (parentDecl !== variableSymbolParentDecl) { + variableSymbol = null; + } + } + } + } else if (!(moduleContainerDecl.flags & 1 /* Exported */)) { + var siblingDecls = parentDecl.getChildDecls(); + var augmentedDecl = null; + + for (var i = 0; i < siblingDecls.length; i++) { + if (siblingDecls[i] == moduleContainerDecl) { + break; + } + + if ((siblingDecls[i].name == modName) && (siblingDecls[i].kind & (8 /* Class */ | TypeScript.PullElementKind.SomeFunction))) { + augmentedDecl = siblingDecls[i]; + break; + } + } + + if (augmentedDecl) { + variableSymbol = augmentedDecl.getSymbol(); + + if (variableSymbol && variableSymbol.isType()) { + variableSymbol = (variableSymbol).getConstructorMethod(); + } + } + } + } + + if (variableSymbol) { + var prevKind = variableSymbol.kind; + var acceptableRedeclaration = (prevKind == 16384 /* Function */) || (prevKind == 32768 /* ConstructorMethod */) || variableSymbol.hasFlag(TypeScript.PullElementFlags.ImplicitVariable); + + if (acceptableRedeclaration) { + moduleInstanceTypeSymbol = variableSymbol.type; + } else { + variableSymbol = null; + } + } + + if (!moduleInstanceTypeSymbol) { + moduleInstanceTypeSymbol = new TypeScript.PullTypeSymbol("", 8388608 /* ObjectType */); + } + + moduleInstanceTypeSymbol.addDeclaration(moduleContainerDecl); + + if (!moduleInstanceTypeSymbol.getAssociatedContainerType()) { + moduleInstanceTypeSymbol.setAssociatedContainerType(moduleContainerTypeSymbol); + } + + if (variableSymbol) { + moduleInstanceSymbol = variableSymbol; + } else { + moduleInstanceSymbol = new TypeScript.PullSymbol(modName, 1024 /* Variable */); + moduleInstanceSymbol.type = moduleInstanceTypeSymbol; + } + + moduleContainerTypeSymbol.setInstanceSymbol(moduleInstanceSymbol); + } + + moduleContainerTypeSymbol.addDeclaration(moduleContainerDecl); + moduleContainerDecl.setSymbol(moduleContainerTypeSymbol); + + this.semanticInfo.setSymbolForAST(moduleAST.name, moduleContainerTypeSymbol); + this.semanticInfo.setSymbolForAST(moduleAST, moduleContainerTypeSymbol); + + var moduleDeclarations = moduleContainerTypeSymbol.getDeclarations(); + + if (isEnum && moduleDeclarations.length > 1 && moduleAST.members.members.length > 0) { + var multipleEnums = TypeScript.ArrayUtilities.where(moduleDeclarations, function (d) { + return d.kind === 64 /* Enum */; + }).length > 1; + if (multipleEnums) { + var firstVariable = moduleAST.members.members[0]; + var firstVariableDeclarator = firstVariable.declaration.declarators.members[0]; + if (!firstVariableDeclarator.init) { + moduleContainerDecl.addDiagnostic(new TypeScript.Diagnostic(this.semanticInfo.getPath(), firstVariableDeclarator.minChar, firstVariableDeclarator.getLength(), TypeScript.DiagnosticCode.Enums_with_multiple_declarations_must_provide_an_initializer_for_the_first_enum_element, null)); + } + } + } + + if (createdNewSymbol) { + if (parent) { + if (moduleContainerDecl.flags & 1 /* Exported */) { + parent.addEnclosedMemberType(moduleContainerTypeSymbol); + } else { + parent.addEnclosedNonMemberType(moduleContainerTypeSymbol); + } + } + } + + if (isEnum) { + moduleInstanceTypeSymbol = moduleContainerTypeSymbol.getInstanceSymbol().type; + + var enumIndexSignature = new TypeScript.PullSignatureSymbol(4194304 /* IndexSignature */); + var enumIndexParameterSymbol = new TypeScript.PullSymbol("x", 2048 /* Parameter */); + enumIndexParameterSymbol.type = this.semanticInfoChain.numberTypeSymbol; + enumIndexSignature.addParameter(enumIndexParameterSymbol); + enumIndexSignature.returnType = this.semanticInfoChain.stringTypeSymbol; + + moduleInstanceTypeSymbol.addIndexSignature(enumIndexSignature); + } + + var valueDecl = moduleContainerDecl.getValueDecl(); + + if (valueDecl) { + valueDecl.ensureSymbolIsBound(); + } + + var otherDecls = this.findDeclsInContext(moduleContainerDecl, moduleContainerDecl.kind, true); + + if (otherDecls && otherDecls.length) { + for (var i = 0; i < otherDecls.length; i++) { + otherDecls[i].ensureSymbolIsBound(); + } + } + }; + + PullSymbolBinder.prototype.bindImportDeclaration = function (importDeclaration) { + var declFlags = importDeclaration.flags; + var declKind = importDeclaration.kind; + var importDeclAST = this.semanticInfo.getASTForDecl(importDeclaration); + + var isExported = false; + var importSymbol = null; + var declName = importDeclaration.name; + var parentHadSymbol = false; + var parent = this.getParent(importDeclaration); + + if (parent) { + importSymbol = parent.findMember(declName, false); + + if (!importSymbol) { + importSymbol = parent.findContainedNonMemberType(declName); + + if (importSymbol) { + var declarations = importSymbol.getDeclarations(); + + if (declarations.length) { + var importSymbolParent = declarations[0].getParentDecl(); + + if (importSymbolParent !== importDeclaration.getParentDecl()) { + importSymbol = null; + } + } + } + } + } else if (!(importDeclaration.flags & 1 /* Exported */)) { + importSymbol = this.semanticInfoChain.findTopLevelSymbol(declName, TypeScript.PullElementKind.SomeContainer, this.semanticInfo.getPath()); + } + + if (importSymbol) { + parentHadSymbol = true; + } + + if (importSymbol) { + importDeclaration.addDiagnostic(new TypeScript.Diagnostic(this.semanticInfo.getPath(), importDeclAST.minChar, importDeclAST.getLength(), TypeScript.DiagnosticCode.Duplicate_identifier_0, [importDeclaration.getDisplayName()])); + importSymbol = null; + } + + if (!importSymbol) { + importSymbol = new TypeScript.PullTypeAliasSymbol(declName); + + if (!parent) { + this.semanticInfoChain.cacheGlobalSymbol(importSymbol, TypeScript.PullElementKind.SomeContainer); + } + } + + importSymbol.addDeclaration(importDeclaration); + importDeclaration.setSymbol(importSymbol); + + this.semanticInfo.setSymbolForAST(importDeclAST, importSymbol); + + if (parent && !parentHadSymbol) { + if (declFlags & 1 /* Exported */) { + parent.addEnclosedMemberType(importSymbol); + } else { + parent.addEnclosedNonMemberType(importSymbol); + } + } + }; + + PullSymbolBinder.prototype.bindClassDeclarationToPullSymbol = function (classDecl) { + var className = classDecl.name; + var classSymbol = null; + + var constructorSymbol = null; + var constructorTypeSymbol = null; + + var classAST = this.semanticInfo.getASTForDecl(classDecl); + + var parent = this.getParent(classDecl); + var parentDecl = classDecl.getParentDecl(); + var isExported = classDecl.flags & 1 /* Exported */; + var isGeneric = false; + + if (parent) { + if (isExported) { + classSymbol = parent.findNestedType(className); + + if (!classSymbol) { + classSymbol = parent.findMember(className, false); + } + } else { + classSymbol = parent.findContainedNonMemberType(className); + + if (classSymbol && (classSymbol.kind & 8 /* Class */)) { + var declarations = classSymbol.getDeclarations(); + + if (declarations.length) { + var classSymbolParentDecl = declarations[0].getParentDecl(); + + if (classSymbolParentDecl !== parentDecl) { + classSymbol = null; + } + } + } else { + classSymbol = null; + } + } + } else { + classSymbol = this.semanticInfoChain.findTopLevelSymbol(className, 8 /* Class */, this.semanticInfo.getPath()); + } + + if (classSymbol) { + classDecl.addDiagnostic(new TypeScript.Diagnostic(this.semanticInfo.getPath(), classAST.minChar, classAST.getLength(), TypeScript.DiagnosticCode.Duplicate_identifier_0, [classDecl.getDisplayName()])); + classSymbol = null; + } + + var decls; + + classSymbol = new TypeScript.PullTypeSymbol(className, 8 /* Class */); + + if (!parent) { + this.semanticInfoChain.cacheGlobalSymbol(classSymbol, 8 /* Class */); + } + + classSymbol.addDeclaration(classDecl); + + classDecl.setSymbol(classSymbol); + + this.semanticInfo.setSymbolForAST(classAST.name, classSymbol); + this.semanticInfo.setSymbolForAST(classAST, classSymbol); + + if (parent) { + if (classDecl.flags & 1 /* Exported */) { + parent.addEnclosedMemberType(classSymbol); + } else { + parent.addEnclosedNonMemberType(classSymbol); + } + } + + this.resetTypeParameterCache(); + + constructorSymbol = classSymbol.getConstructorMethod(); + constructorTypeSymbol = constructorSymbol ? constructorSymbol.type : null; + + if (!constructorSymbol) { + constructorSymbol = new TypeScript.PullSymbol(className, 32768 /* ConstructorMethod */); + constructorTypeSymbol = new TypeScript.PullTypeSymbol("", 33554432 /* ConstructorType */); + + constructorSymbol.setIsSynthesized(); + + constructorSymbol.type = constructorTypeSymbol; + classSymbol.setConstructorMethod(constructorSymbol); + + classSymbol.setHasDefaultConstructor(); + } + + if (constructorSymbol.getIsSynthesized()) { + constructorSymbol.addDeclaration(classDecl.getValueDecl()); + constructorTypeSymbol.addDeclaration(classDecl); + } else { + classSymbol.setHasDefaultConstructor(false); + } + + constructorTypeSymbol.setAssociatedContainerType(classSymbol); + + var typeParameters = classDecl.getTypeParameters(); + var typeParameter; + var typeParameterDecls = null; + + for (var i = 0; i < typeParameters.length; i++) { + typeParameter = classSymbol.findTypeParameter(typeParameters[i].name); + + if (!typeParameter) { + typeParameter = new TypeScript.PullTypeParameterSymbol(typeParameters[i].name, false); + + classSymbol.addTypeParameter(typeParameter); + constructorTypeSymbol.addConstructorTypeParameter(typeParameter); + } else { + typeParameterDecls = typeParameter.getDeclarations(); + + var typeParameterAST = this.semanticInfoChain.getASTForDecl(typeParameterDecls[0]); + classDecl.addDiagnostic(new TypeScript.Diagnostic(this.semanticInfo.getPath(), typeParameterAST.minChar, typeParameterAST.getLength(), TypeScript.DiagnosticCode.Duplicate_identifier_0, [typeParameter.getName()])); + } + + typeParameter.addDeclaration(typeParameters[i]); + typeParameters[i].setSymbol(typeParameter); + } + + var valueDecl = classDecl.getValueDecl(); + + if (valueDecl) { + valueDecl.ensureSymbolIsBound(); + } + }; + + PullSymbolBinder.prototype.bindInterfaceDeclarationToPullSymbol = function (interfaceDecl) { + var interfaceName = interfaceDecl.name; + var interfaceSymbol = null; + + var interfaceAST = this.semanticInfo.getASTForDecl(interfaceDecl); + var createdNewSymbol = false; + var parent = this.getParent(interfaceDecl); + + var acceptableSharedKind = 16 /* Interface */; + + if (parent) { + interfaceSymbol = parent.findNestedType(interfaceName, TypeScript.PullElementKind.SomeType); + } else if (!(interfaceDecl.flags & 1 /* Exported */)) { + interfaceSymbol = this.semanticInfoChain.findTopLevelSymbol(interfaceName, 16 /* Interface */, this.semanticInfo.getPath()); + } + + if (interfaceSymbol && !(interfaceSymbol.kind & acceptableSharedKind)) { + interfaceDecl.addDiagnostic(new TypeScript.Diagnostic(this.semanticInfo.getPath(), interfaceAST.minChar, interfaceAST.getLength(), TypeScript.DiagnosticCode.Duplicate_identifier_0, [interfaceDecl.getDisplayName()])); + interfaceSymbol = null; + } + + if (!interfaceSymbol) { + interfaceSymbol = new TypeScript.PullTypeSymbol(interfaceName, 16 /* Interface */); + createdNewSymbol = true; + + if (!parent) { + this.semanticInfoChain.cacheGlobalSymbol(interfaceSymbol, acceptableSharedKind); + } + } + + interfaceSymbol.addDeclaration(interfaceDecl); + interfaceDecl.setSymbol(interfaceSymbol); + + if (createdNewSymbol) { + if (parent) { + if (interfaceDecl.flags & 1 /* Exported */) { + parent.addEnclosedMemberType(interfaceSymbol); + } else { + parent.addEnclosedNonMemberType(interfaceSymbol); + } + } + } + + this.resetTypeParameterCache(); + + var typeParameters = interfaceDecl.getTypeParameters(); + var typeParameter; + var typeParameterDecls = null; + + for (var i = 0; i < typeParameters.length; i++) { + typeParameter = interfaceSymbol.findTypeParameter(typeParameters[i].name); + + if (!typeParameter) { + typeParameter = new TypeScript.PullTypeParameterSymbol(typeParameters[i].name, false); + + interfaceSymbol.addTypeParameter(typeParameter); + } else { + typeParameterDecls = typeParameter.getDeclarations(); + + for (var j = 0; j < typeParameterDecls.length; j++) { + var typeParameterDeclParent = typeParameterDecls[j].getParentDecl(); + + if (typeParameterDeclParent && typeParameterDeclParent === interfaceDecl) { + var typeParameterAST = this.semanticInfoChain.getASTForDecl(typeParameterDecls[0]); + interfaceDecl.addDiagnostic(new TypeScript.Diagnostic(this.semanticInfo.getPath(), typeParameterAST.minChar, typeParameterAST.getLength(), TypeScript.DiagnosticCode.Duplicate_identifier_0, [typeParameter.getName()])); + + break; + } + } + } + + typeParameter.addDeclaration(typeParameters[i]); + typeParameters[i].setSymbol(typeParameter); + } + + var otherDecls = this.findDeclsInContext(interfaceDecl, interfaceDecl.kind, true); + + if (otherDecls && otherDecls.length) { + for (var i = 0; i < otherDecls.length; i++) { + otherDecls[i].ensureSymbolIsBound(); + } + } + }; + + PullSymbolBinder.prototype.bindObjectTypeDeclarationToPullSymbol = function (objectDecl) { + var objectSymbolAST = this.semanticInfo.getASTForDecl(objectDecl); + + var objectSymbol = new TypeScript.PullTypeSymbol("", 8388608 /* ObjectType */); + + objectSymbol.addDeclaration(objectDecl); + objectDecl.setSymbol(objectSymbol); + + this.semanticInfo.setSymbolForAST(objectSymbolAST, objectSymbol); + + var childDecls = objectDecl.getChildDecls(); + + for (var i = 0; i < childDecls.length; i++) { + this.bindDeclToPullSymbol(childDecls[i]); + } + + var typeParameters = objectDecl.getTypeParameters(); + var typeParameter; + var typeParameterDecls = null; + + for (var i = 0; i < typeParameters.length; i++) { + typeParameter = objectSymbol.findTypeParameter(typeParameters[i].name); + + if (!typeParameter) { + typeParameter = new TypeScript.PullTypeParameterSymbol(typeParameters[i].name, false); + + objectSymbol.addTypeParameter(typeParameter); + } else { + typeParameterDecls = typeParameter.getDeclarations(); + + var typeParameterAST = this.semanticInfoChain.getASTForDecl(typeParameterDecls[0]); + objectDecl.addDiagnostic(new TypeScript.Diagnostic(this.semanticInfo.getPath(), typeParameterAST.minChar, typeParameterAST.getLength(), TypeScript.DiagnosticCode.Duplicate_identifier_0, [typeParameter.name])); + } + + typeParameter.addDeclaration(typeParameters[i]); + typeParameters[i].setSymbol(typeParameter); + } + }; + + PullSymbolBinder.prototype.bindConstructorTypeDeclarationToPullSymbol = function (constructorTypeDeclaration) { + var declKind = constructorTypeDeclaration.kind; + var declFlags = constructorTypeDeclaration.flags; + var constructorTypeAST = this.semanticInfo.getASTForDecl(constructorTypeDeclaration); + + var constructorTypeSymbol = new TypeScript.PullTypeSymbol("", 33554432 /* ConstructorType */); + + constructorTypeDeclaration.setSymbol(constructorTypeSymbol); + constructorTypeSymbol.addDeclaration(constructorTypeDeclaration); + this.semanticInfo.setSymbolForAST(constructorTypeAST, constructorTypeSymbol); + + var signature = new TypeScript.PullDefinitionSignatureSymbol(2097152 /* ConstructSignature */); + + if ((constructorTypeAST).variableArgList) { + signature.hasVarArgs = true; + } + + signature.addDeclaration(constructorTypeDeclaration); + constructorTypeDeclaration.setSignatureSymbol(signature); + + this.bindParameterSymbols(this.semanticInfo.getASTForDecl(constructorTypeDeclaration), constructorTypeSymbol, signature); + + constructorTypeSymbol.addConstructSignature(signature); + + var typeParameters = constructorTypeDeclaration.getTypeParameters(); + var typeParameter; + var typeParameterDecls = null; + + for (var i = 0; i < typeParameters.length; i++) { + typeParameter = constructorTypeSymbol.findTypeParameter(typeParameters[i].name); + + if (!typeParameter) { + typeParameter = new TypeScript.PullTypeParameterSymbol(typeParameters[i].name, false); + + constructorTypeSymbol.addConstructorTypeParameter(typeParameter); + } else { + typeParameterDecls = typeParameter.getDeclarations(); + + var typeParameterAST = this.semanticInfoChain.getASTForDecl(typeParameterDecls[0]); + constructorTypeDeclaration.addDiagnostic(new TypeScript.Diagnostic(this.semanticInfo.getPath(), typeParameterAST.minChar, typeParameterAST.getLength(), TypeScript.DiagnosticCode.Duplicate_identifier_0, [typeParameter.name])); + } + + typeParameter.addDeclaration(typeParameters[i]); + typeParameters[i].setSymbol(typeParameter); + } + }; + + PullSymbolBinder.prototype.bindVariableDeclarationToPullSymbol = function (variableDeclaration) { + var declFlags = variableDeclaration.flags; + var declKind = variableDeclaration.kind; + var varDeclAST = this.semanticInfo.getASTForDecl(variableDeclaration); + + var isExported = (declFlags & 1 /* Exported */) !== 0; + + var variableSymbol = null; + + var declName = variableDeclaration.name; + + var parentHadSymbol = false; + + var parent = this.getParent(variableDeclaration, true); + + var parentDecl = variableDeclaration.getParentDecl(); + + var isImplicit = (declFlags & TypeScript.PullElementFlags.ImplicitVariable) !== 0; + var isModuleValue = (declFlags & (TypeScript.PullElementFlags.SomeInitializedModule)) != 0; + var isEnumValue = (declFlags & 131072 /* InitializedEnum */) != 0; + var isClassConstructorVariable = (declFlags & 16384 /* ClassConstructorVariable */) != 0; + + if (parentDecl && !isImplicit) { + parentDecl.addVariableDeclToGroup(variableDeclaration); + } + + if (parent) { + if (isExported) { + variableSymbol = parent.findMember(declName, false); + } else { + variableSymbol = parent.findContainedNonMember(declName); + } + + if (variableSymbol) { + var declarations = variableSymbol.getDeclarations(); + + if (declarations.length) { + var variableSymbolParentDecl = declarations[0].getParentDecl(); + + if (parentDecl !== variableSymbolParentDecl) { + variableSymbol = null; + } + } + } + } else if (!(variableDeclaration.flags & 1 /* Exported */)) { + variableSymbol = this.semanticInfoChain.findTopLevelSymbol(declName, TypeScript.PullElementKind.SomeValue, this.semanticInfo.getPath()); + } + + if (variableSymbol && !variableSymbol.isType()) { + parentHadSymbol = true; + } + + var span; + var decl; + var decls; + var ast; + var members; + + if (variableSymbol) { + var prevKind = variableSymbol.kind; + var prevIsAmbient = variableSymbol.hasFlag(8 /* Ambient */); + var prevIsEnum = variableSymbol.hasFlag(131072 /* InitializedEnum */); + var prevIsClassConstructorVariable = variableSymbol.hasFlag(16384 /* ClassConstructorVariable */); + var prevIsModuleValue = variableSymbol.hasFlag(TypeScript.PullElementFlags.SomeInitializedModule); + var prevIsImplicit = variableSymbol.hasFlag(TypeScript.PullElementFlags.ImplicitVariable); + var onlyOneIsEnum = (isEnumValue || prevIsEnum) && !(isEnumValue && prevIsEnum); + var isAmbient = (variableDeclaration.flags & 8 /* Ambient */) != 0; + var prevDecl = variableSymbol.getDeclarations()[0]; + var bothAreGlobal = parentDecl && (parentDecl.kind == 1 /* Script */) && (declKind == prevKind); + var shareParent = bothAreGlobal || prevDecl.getParentDecl() == variableDeclaration.getParentDecl(); + var prevIsParam = shareParent && prevKind == 2048 /* Parameter */ && declKind == 1024 /* Variable */; + + var acceptableRedeclaration = (!shareParent || prevIsParam) || (isImplicit && ((!isEnumValue && !isClassConstructorVariable && prevKind == 16384 /* Function */) || (isModuleValue && prevIsModuleValue) || (isClassConstructorVariable && prevIsModuleValue && isAmbient) || (isModuleValue && prevIsClassConstructorVariable))); + + if (acceptableRedeclaration && prevIsClassConstructorVariable && !prevIsAmbient) { + if (prevDecl.getScriptName() != variableDeclaration.getScriptName()) { + acceptableRedeclaration = false; + } + } + + if (shareParent && !prevIsParam && (!acceptableRedeclaration || onlyOneIsEnum)) { + if (isImplicit || prevIsImplicit || (prevKind & TypeScript.PullElementKind.SomeFunction) !== 0) { + span = variableDeclaration.getSpan(); + var errorDecl = isImplicit ? variableSymbol.getDeclarations()[0] : variableDeclaration; + errorDecl.addDiagnostic(new TypeScript.Diagnostic(this.semanticInfo.getPath(), span.start(), span.length(), TypeScript.DiagnosticCode.Duplicate_identifier_0, [variableDeclaration.getDisplayName()])); + } + + variableSymbol = null; + parentHadSymbol = false; + } + } else if (variableSymbol && (variableSymbol.kind !== 1024 /* Variable */) && !isImplicit) { + span = variableDeclaration.getSpan(); + + variableDeclaration.addDiagnostic(new TypeScript.Diagnostic(this.semanticInfo.getPath(), span.start(), span.length(), TypeScript.DiagnosticCode.Duplicate_identifier_0, [variableDeclaration.getDisplayName()])); + variableSymbol = null; + parentHadSymbol = false; + } + + if ((declFlags & TypeScript.PullElementFlags.ImplicitVariable) === 0) { + if (!variableSymbol) { + variableSymbol = new TypeScript.PullSymbol(declName, declKind); + this.semanticInfoChain.cacheGlobalSymbol(variableSymbol, declKind); + } + + variableSymbol.addDeclaration(variableDeclaration); + variableDeclaration.setSymbol(variableSymbol); + + this.semanticInfo.setSymbolForAST(varDeclAST.id, variableSymbol); + this.semanticInfo.setSymbolForAST(varDeclAST, variableSymbol); + } else if (!parentHadSymbol) { + if (isClassConstructorVariable) { + var classTypeSymbol = variableSymbol; + + if (parent) { + members = parent.getMembers(); + + for (var i = 0; i < members.length; i++) { + if ((members[i].name === declName) && (members[i].kind === 8 /* Class */)) { + classTypeSymbol = members[i]; + break; + } + } + } + + if (!classTypeSymbol) { + var parentDecl = variableDeclaration.getParentDecl(); + + if (parentDecl) { + var childDecls = parentDecl.searchChildDecls(declName, TypeScript.PullElementKind.SomeType); + + if (childDecls.length) { + for (var i = 0; i < childDecls.length; i++) { + if (childDecls[i].getValueDecl() === variableDeclaration) { + classTypeSymbol = childDecls[i].getSymbol(); + } + } + } + } + + if (!classTypeSymbol) { + classTypeSymbol = this.semanticInfoChain.findTopLevelSymbol(declName, TypeScript.PullElementKind.SomeType, this.semanticInfo.getPath()); + } + } + + if (classTypeSymbol && (classTypeSymbol.kind !== 8 /* Class */)) { + classTypeSymbol = null; + } + + if (classTypeSymbol && classTypeSymbol.isClass()) { + variableSymbol = classTypeSymbol.getConstructorMethod(); + variableDeclaration.setSymbol(variableSymbol); + + decls = classTypeSymbol.getDeclarations(); + + if (decls.length) { + decl = decls[decls.length - 1]; + ast = this.semanticInfo.getASTForDecl(decl); + + if (ast) { + this.semanticInfo.setASTForDecl(variableDeclaration, ast); + } + } + } else { + if (!variableSymbol) { + variableSymbol = new TypeScript.PullSymbol(declName, declKind); + } + + variableSymbol.addDeclaration(variableDeclaration); + variableDeclaration.setSymbol(variableSymbol); + + variableSymbol.type = this.semanticInfoChain.anyTypeSymbol; + } + } else if (declFlags & TypeScript.PullElementFlags.SomeInitializedModule) { + var moduleContainerTypeSymbol = null; + var moduleParent = this.getParent(variableDeclaration); + + if (moduleParent) { + members = moduleParent.getMembers(); + + for (var i = 0; i < members.length; i++) { + if ((members[i].name === declName) && (members[i].isContainer())) { + moduleContainerTypeSymbol = members[i]; + break; + } + } + } + + if (!moduleContainerTypeSymbol) { + var parentDecl = variableDeclaration.getParentDecl(); + + if (parentDecl) { + var searchKind = (declFlags & (32768 /* InitializedModule */ | 65536 /* InitializedDynamicModule */)) ? TypeScript.PullElementKind.SomeContainer : 64 /* Enum */; + var childDecls = parentDecl.searchChildDecls(declName, searchKind); + + if (childDecls.length) { + for (var i = 0; i < childDecls.length; i++) { + if (childDecls[i].getValueDecl() === variableDeclaration) { + moduleContainerTypeSymbol = childDecls[i].getSymbol(); + } + } + } + } + if (!moduleContainerTypeSymbol) { + moduleContainerTypeSymbol = this.semanticInfoChain.findTopLevelSymbol(declName, TypeScript.PullElementKind.SomeContainer, this.semanticInfo.getPath()); + + if (!moduleContainerTypeSymbol) { + moduleContainerTypeSymbol = this.semanticInfoChain.findTopLevelSymbol(declName, 64 /* Enum */, this.semanticInfo.getPath()); + } + } + } + + if (moduleContainerTypeSymbol && (!moduleContainerTypeSymbol.isContainer())) { + moduleContainerTypeSymbol = null; + } + + if (moduleContainerTypeSymbol) { + variableSymbol = moduleContainerTypeSymbol.getInstanceSymbol(); + + variableSymbol.addDeclaration(variableDeclaration); + variableDeclaration.setSymbol(variableSymbol); + + decls = moduleContainerTypeSymbol.getDeclarations(); + + if (decls.length) { + decl = decls[decls.length - 1]; + ast = this.semanticInfo.getASTForDecl(decl); + + if (ast) { + this.semanticInfo.setASTForDecl(variableDeclaration, ast); + } + } + } else { + TypeScript.Debug.assert(false, "Attempted to bind invalid implicit variable symbol"); + } + } + } else { + variableSymbol.addDeclaration(variableDeclaration); + variableDeclaration.setSymbol(variableSymbol); + } + + if (parent && !parentHadSymbol) { + if (declFlags & 1 /* Exported */) { + parent.addMember(variableSymbol); + } else { + parent.addEnclosedNonMember(variableSymbol); + } + } + }; + + PullSymbolBinder.prototype.bindPropertyDeclarationToPullSymbol = function (propertyDeclaration) { + var declFlags = propertyDeclaration.flags; + var declKind = propertyDeclaration.kind; + var propDeclAST = this.semanticInfo.getASTForDecl(propertyDeclaration); + + var isStatic = false; + var isOptional = false; + + var propertySymbol = null; + + if (TypeScript.hasFlag(declFlags, 16 /* Static */)) { + isStatic = true; + } + + if (TypeScript.hasFlag(declFlags, 128 /* Optional */)) { + isOptional = true; + } + + var declName = propertyDeclaration.name; + + var parentHadSymbol = false; + + var parent = this.getParent(propertyDeclaration, true); + + if (parent.isClass() && isStatic) { + parent = parent.getConstructorMethod().type; + } + + propertySymbol = parent.findMember(declName, false); + + if (propertySymbol) { + var span = propertyDeclaration.getSpan(); + + propertyDeclaration.addDiagnostic(new TypeScript.Diagnostic(this.semanticInfo.getPath(), span.start(), span.length(), TypeScript.DiagnosticCode.Duplicate_identifier_0, [propertyDeclaration.getDisplayName()])); + + propertySymbol = null; + } + + if (propertySymbol) { + parentHadSymbol = true; + } + + var classTypeSymbol; + + if (!parentHadSymbol) { + propertySymbol = new TypeScript.PullSymbol(declName, declKind); + } + + propertySymbol.addDeclaration(propertyDeclaration); + propertyDeclaration.setSymbol(propertySymbol); + + this.semanticInfo.setSymbolForAST(propDeclAST.id, propertySymbol); + this.semanticInfo.setSymbolForAST(propDeclAST, propertySymbol); + + if (isOptional) { + propertySymbol.isOptional = true; + } + + if (parent && !parentHadSymbol) { + parent.addMember(propertySymbol); + } + }; + + PullSymbolBinder.prototype.bindParameterSymbols = function (funcDecl, funcType, signatureSymbol) { + var parameters = []; + var decl = null; + var argDecl = null; + var parameterSymbol = null; + var isProperty = false; + var params = new TypeScript.BlockIntrinsics(); + + if (funcDecl.arguments) { + for (var i = 0; i < funcDecl.arguments.members.length; i++) { + argDecl = funcDecl.arguments.members[i]; + decl = this.semanticInfo.getDeclForAST(argDecl); + isProperty = TypeScript.hasFlag(argDecl.getVarFlags(), 256 /* Property */); + parameterSymbol = new TypeScript.PullSymbol(argDecl.id.text(), 2048 /* Parameter */); + + if (funcDecl.variableArgList && i === funcDecl.arguments.members.length - 1) { + parameterSymbol.isVarArg = true; + } + + if (decl.flags & 128 /* Optional */) { + parameterSymbol.isOptional = true; + } + + if (params[argDecl.id.text()]) { + decl.addDiagnostic(new TypeScript.Diagnostic(this.semanticInfo.getPath(), argDecl.minChar, argDecl.getLength(), TypeScript.DiagnosticCode.Duplicate_identifier_0, [argDecl.id.actualText])); + } else { + params[argDecl.id.text()] = true; + } + if (decl) { + if (isProperty) { + decl.ensureSymbolIsBound(); + var valDecl = decl.getValueDecl(); + + if (valDecl) { + valDecl.setSymbol(parameterSymbol); + parameterSymbol.addDeclaration(valDecl); + } + } else { + parameterSymbol.addDeclaration(decl); + decl.setSymbol(parameterSymbol); + } + } + + signatureSymbol.addParameter(parameterSymbol, parameterSymbol.isOptional); + + if (signatureSymbol.isDefinition()) { + funcType.addEnclosedNonMember(parameterSymbol); + } + } + } + }; + + PullSymbolBinder.prototype.bindFunctionDeclarationToPullSymbol = function (functionDeclaration) { + var declKind = functionDeclaration.kind; + var declFlags = functionDeclaration.flags; + var funcDeclAST = this.semanticInfo.getASTForDecl(functionDeclaration); + + var isExported = (declFlags & 1 /* Exported */) !== 0; + + var funcName = functionDeclaration.name; + + var isSignature = (declFlags & 2048 /* Signature */) !== 0; + + var parent = this.getParent(functionDeclaration, true); + var parentDecl = functionDeclaration.getParentDecl(); + var parentHadSymbol = false; + + var functionSymbol = null; + var functionTypeSymbol = null; + + if (parent) { + functionSymbol = parent.findMember(funcName, false); + + if (!functionSymbol) { + functionSymbol = parent.findContainedNonMember(funcName); + + if (functionSymbol) { + var declarations = functionSymbol.getDeclarations(); + + if (declarations.length) { + var funcSymbolParentDecl = declarations[0].getParentDecl(); + + if (parentDecl !== funcSymbolParentDecl) { + functionSymbol = null; + } + } + } + } + } else if (!(functionDeclaration.flags & 1 /* Exported */)) { + functionSymbol = this.semanticInfoChain.findTopLevelSymbol(funcName, TypeScript.PullElementKind.SomeValue, this.semanticInfo.getPath()); + } + + if (functionSymbol && (functionSymbol.kind !== 16384 /* Function */ || (!isSignature && !functionSymbol.allDeclsHaveFlag(2048 /* Signature */)))) { + functionDeclaration.addDiagnostic(new TypeScript.Diagnostic(this.semanticInfo.getPath(), funcDeclAST.minChar, funcDeclAST.getLength(), TypeScript.DiagnosticCode.Duplicate_identifier_0, [functionDeclaration.getDisplayName()])); + functionSymbol = null; + } + + if (functionSymbol) { + functionTypeSymbol = functionSymbol.type; + parentHadSymbol = true; + } + + if (!functionSymbol) { + functionSymbol = new TypeScript.PullSymbol(funcName, 16384 /* Function */); + } + + if (!functionTypeSymbol) { + functionTypeSymbol = new TypeScript.PullTypeSymbol("", 16777216 /* FunctionType */); + functionSymbol.type = functionTypeSymbol; + functionTypeSymbol.setFunctionSymbol(functionSymbol); + } + + functionDeclaration.setSymbol(functionSymbol); + functionSymbol.addDeclaration(functionDeclaration); + functionTypeSymbol.addDeclaration(functionDeclaration); + + this.semanticInfo.setSymbolForAST(funcDeclAST.name, functionSymbol); + this.semanticInfo.setSymbolForAST(funcDeclAST, functionSymbol); + + if (parent && !parentHadSymbol) { + if (isExported) { + parent.addMember(functionSymbol); + } else { + parent.addEnclosedNonMember(functionSymbol); + } + } + + var signature = isSignature ? new TypeScript.PullSignatureSymbol(1048576 /* CallSignature */) : new TypeScript.PullDefinitionSignatureSymbol(1048576 /* CallSignature */); + + signature.addDeclaration(functionDeclaration); + functionDeclaration.setSignatureSymbol(signature); + + if (funcDeclAST.variableArgList) { + signature.hasVarArgs = true; + } + + this.bindParameterSymbols(this.semanticInfo.getASTForDecl(functionDeclaration), functionTypeSymbol, signature); + + var typeParameters = functionDeclaration.getTypeParameters(); + var typeParameter; + var typeParameterDecls = null; + + for (var i = 0; i < typeParameters.length; i++) { + typeParameter = signature.findTypeParameter(typeParameters[i].name); + + if (!typeParameter) { + typeParameter = new TypeScript.PullTypeParameterSymbol(typeParameters[i].name, true); + + signature.addTypeParameter(typeParameter); + } else { + typeParameterDecls = typeParameter.getDeclarations(); + + var typeParameterAST = this.semanticInfoChain.getASTForDecl(typeParameterDecls[0]); + functionDeclaration.addDiagnostic(new TypeScript.Diagnostic(this.semanticInfo.getPath(), typeParameterAST.minChar, typeParameterAST.getLength(), TypeScript.DiagnosticCode.Duplicate_identifier_0, [typeParameter.name])); + } + + typeParameter.addDeclaration(typeParameters[i]); + typeParameters[i].setSymbol(typeParameter); + } + + functionTypeSymbol.addCallSignature(signature); + + var otherDecls = this.findDeclsInContext(functionDeclaration, functionDeclaration.kind, false); + + if (otherDecls && otherDecls.length) { + for (var i = 0; i < otherDecls.length; i++) { + otherDecls[i].ensureSymbolIsBound(); + } + } + }; + + PullSymbolBinder.prototype.bindFunctionExpressionToPullSymbol = function (functionExpressionDeclaration) { + var declKind = functionExpressionDeclaration.kind; + var declFlags = functionExpressionDeclaration.flags; + var funcExpAST = this.semanticInfo.getASTForDecl(functionExpressionDeclaration); + + var functionName = declKind == 131072 /* FunctionExpression */ ? (functionExpressionDeclaration).getFunctionExpressionName() : functionExpressionDeclaration.name; + var functionSymbol = new TypeScript.PullSymbol(functionName, 16384 /* Function */); + var functionTypeSymbol = new TypeScript.PullTypeSymbol("", 16777216 /* FunctionType */); + functionTypeSymbol.setFunctionSymbol(functionSymbol); + + functionSymbol.type = functionTypeSymbol; + + functionExpressionDeclaration.setSymbol(functionSymbol); + functionSymbol.addDeclaration(functionExpressionDeclaration); + functionTypeSymbol.addDeclaration(functionExpressionDeclaration); + + if (funcExpAST.name) { + this.semanticInfo.setSymbolForAST(funcExpAST.name, functionSymbol); + } + this.semanticInfo.setSymbolForAST(funcExpAST, functionSymbol); + + var signature = new TypeScript.PullDefinitionSignatureSymbol(1048576 /* CallSignature */); + + if (funcExpAST.variableArgList) { + signature.hasVarArgs = true; + } + + var typeParameters = functionExpressionDeclaration.getTypeParameters(); + var typeParameter; + var typeParameterDecls = null; + + for (var i = 0; i < typeParameters.length; i++) { + typeParameter = signature.findTypeParameter(typeParameters[i].name); + + if (!typeParameter) { + typeParameter = new TypeScript.PullTypeParameterSymbol(typeParameters[i].name, true); + + signature.addTypeParameter(typeParameter); + } else { + typeParameterDecls = typeParameter.getDeclarations(); + + var typeParameterAST = this.semanticInfoChain.getASTForDecl(typeParameterDecls[0]); + functionExpressionDeclaration.addDiagnostic(new TypeScript.Diagnostic(this.semanticInfo.getPath(), typeParameterAST.minChar, typeParameterAST.getLength(), TypeScript.DiagnosticCode.Duplicate_identifier_0, [typeParameter.getName()])); + } + + typeParameter.addDeclaration(typeParameters[i]); + typeParameters[i].setSymbol(typeParameter); + } + + signature.addDeclaration(functionExpressionDeclaration); + functionExpressionDeclaration.setSignatureSymbol(signature); + + this.bindParameterSymbols(this.semanticInfo.getASTForDecl(functionExpressionDeclaration), functionTypeSymbol, signature); + + functionTypeSymbol.addCallSignature(signature); + }; + + PullSymbolBinder.prototype.bindFunctionTypeDeclarationToPullSymbol = function (functionTypeDeclaration) { + var declKind = functionTypeDeclaration.kind; + var declFlags = functionTypeDeclaration.flags; + var funcTypeAST = this.semanticInfo.getASTForDecl(functionTypeDeclaration); + + var functionTypeSymbol = new TypeScript.PullTypeSymbol("", 16777216 /* FunctionType */); + + functionTypeDeclaration.setSymbol(functionTypeSymbol); + functionTypeSymbol.addDeclaration(functionTypeDeclaration); + this.semanticInfo.setSymbolForAST(funcTypeAST, functionTypeSymbol); + + var isSignature = (declFlags & 2048 /* Signature */) !== 0; + var signature = isSignature ? new TypeScript.PullSignatureSymbol(1048576 /* CallSignature */) : new TypeScript.PullDefinitionSignatureSymbol(1048576 /* CallSignature */); + + if (funcTypeAST.variableArgList) { + signature.hasVarArgs = true; + } + + var typeParameters = functionTypeDeclaration.getTypeParameters(); + var typeParameter; + var typeParameterDecls = null; + + for (var i = 0; i < typeParameters.length; i++) { + typeParameter = signature.findTypeParameter(typeParameters[i].name); + + if (!typeParameter) { + typeParameter = new TypeScript.PullTypeParameterSymbol(typeParameters[i].name, true); + + signature.addTypeParameter(typeParameter); + } else { + var typeParameterAST = this.semanticInfoChain.getASTForDecl(typeParameterDecls[0]); + functionTypeDeclaration.addDiagnostic(new TypeScript.Diagnostic(this.semanticInfo.getPath(), typeParameterAST.minChar, typeParameterAST.getLength(), TypeScript.DiagnosticCode.Duplicate_identifier_0, [typeParameter.name])); + } + + typeParameter.addDeclaration(typeParameters[i]); + typeParameters[i].setSymbol(typeParameter); + } + + signature.addDeclaration(functionTypeDeclaration); + functionTypeDeclaration.setSignatureSymbol(signature); + + this.bindParameterSymbols(this.semanticInfo.getASTForDecl(functionTypeDeclaration), functionTypeSymbol, signature); + + functionTypeSymbol.addCallSignature(signature); + }; + + PullSymbolBinder.prototype.bindMethodDeclarationToPullSymbol = function (methodDeclaration) { + var declKind = methodDeclaration.kind; + var declFlags = methodDeclaration.flags; + var methodAST = this.semanticInfo.getASTForDecl(methodDeclaration); + + var isPrivate = (declFlags & 2 /* Private */) !== 0; + var isStatic = (declFlags & 16 /* Static */) !== 0; + var isOptional = (declFlags & 128 /* Optional */) !== 0; + + var methodName = methodDeclaration.name; + + var isSignature = (declFlags & 2048 /* Signature */) !== 0; + + var parent = this.getParent(methodDeclaration, true); + var parentHadSymbol = false; + + var methodSymbol = null; + var methodTypeSymbol = null; + + if (parent.isClass() && isStatic) { + parent = parent.getConstructorMethod().type; + } + + methodSymbol = parent.findMember(methodName, false); + + if (methodSymbol && (methodSymbol.kind !== 65536 /* Method */ || (!isSignature && !methodSymbol.allDeclsHaveFlag(2048 /* Signature */)))) { + methodDeclaration.addDiagnostic(new TypeScript.Diagnostic(this.semanticInfo.getPath(), methodAST.minChar, methodAST.getLength(), TypeScript.DiagnosticCode.Duplicate_identifier_0, [methodDeclaration.getDisplayName()])); + methodSymbol = null; + } + + if (methodSymbol) { + methodTypeSymbol = methodSymbol.type; + parentHadSymbol = true; + } + + if (!methodSymbol) { + methodSymbol = new TypeScript.PullSymbol(methodName, 65536 /* Method */); + } + + if (!methodTypeSymbol) { + methodTypeSymbol = new TypeScript.PullTypeSymbol("", 16777216 /* FunctionType */); + methodSymbol.type = methodTypeSymbol; + methodTypeSymbol.setFunctionSymbol(methodSymbol); + } + + methodDeclaration.setSymbol(methodSymbol); + methodSymbol.addDeclaration(methodDeclaration); + methodTypeSymbol.addDeclaration(methodDeclaration); + this.semanticInfo.setSymbolForAST(methodAST.name, methodSymbol); + this.semanticInfo.setSymbolForAST(methodAST, methodSymbol); + + if (isOptional) { + methodSymbol.isOptional = true; + } + + if (!parentHadSymbol) { + parent.addMember(methodSymbol); + } + + var sigKind = 1048576 /* CallSignature */; + + var signature = isSignature ? new TypeScript.PullSignatureSymbol(sigKind) : new TypeScript.PullDefinitionSignatureSymbol(sigKind); + + if (methodAST.variableArgList) { + signature.hasVarArgs = true; + } + + var typeParameters = methodDeclaration.getTypeParameters(); + var typeParameter; + var typeParameterDecls = null; + var typeParameterName; + var typeParameterAST; + + for (var i = 0; i < typeParameters.length; i++) { + typeParameterName = typeParameters[i].name; + typeParameterAST = this.semanticInfo.getASTForDecl(typeParameters[i]); + + typeParameter = signature.findTypeParameter(typeParameterName); + + if (!typeParameter) { + if (!typeParameterAST.constraint) { + typeParameter = this.findTypeParameterInCache(typeParameterName); + } + + if (!typeParameter) { + typeParameter = new TypeScript.PullTypeParameterSymbol(typeParameterName, true); + + if (!typeParameterAST.constraint) { + this.addTypeParameterToCache(typeParameter); + } + } + + signature.addTypeParameter(typeParameter); + } else { + typeParameterDecls = typeParameter.getDeclarations(); + + typeParameterAST = this.semanticInfoChain.getASTForDecl(typeParameterDecls[0]); + methodDeclaration.addDiagnostic(new TypeScript.Diagnostic(this.semanticInfo.getPath(), typeParameterAST.minChar, typeParameterAST.getLength(), TypeScript.DiagnosticCode.Duplicate_identifier_0, [typeParameter.getName()])); + } + + typeParameter.addDeclaration(typeParameters[i]); + typeParameters[i].setSymbol(typeParameter); + } + + signature.addDeclaration(methodDeclaration); + methodDeclaration.setSignatureSymbol(signature); + + this.bindParameterSymbols(this.semanticInfo.getASTForDecl(methodDeclaration), methodTypeSymbol, signature); + + methodTypeSymbol.addCallSignature(signature); + + var otherDecls = this.findDeclsInContext(methodDeclaration, methodDeclaration.kind, false); + + if (otherDecls && otherDecls.length) { + for (var i = 0; i < otherDecls.length; i++) { + otherDecls[i].ensureSymbolIsBound(); + } + } + }; + + PullSymbolBinder.prototype.bindConstructorDeclarationToPullSymbol = function (constructorDeclaration) { + var declKind = constructorDeclaration.kind; + var declFlags = constructorDeclaration.flags; + var constructorAST = this.semanticInfo.getASTForDecl(constructorDeclaration); + + var constructorName = constructorDeclaration.name; + + var isSignature = (declFlags & 2048 /* Signature */) !== 0; + + var parent = this.getParent(constructorDeclaration, true); + + var parentHadSymbol = false; + + var constructorSymbol = parent.getConstructorMethod(); + var constructorTypeSymbol = null; + + if (constructorSymbol && (constructorSymbol.kind !== 32768 /* ConstructorMethod */ || (!isSignature && constructorSymbol.type && constructorSymbol.type.hasOwnConstructSignatures()))) { + var hasDefinitionSignature = false; + var constructorSigs = constructorSymbol.type.getConstructSignatures(); + + for (var i = 0; i < constructorSigs.length; i++) { + if (!constructorSigs[i].hasFlag(2048 /* Signature */)) { + hasDefinitionSignature = true; + break; + } + } + + if (hasDefinitionSignature) { + constructorDeclaration.addDiagnostic(new TypeScript.Diagnostic(this.semanticInfo.getPath(), constructorAST.minChar, constructorAST.getLength(), TypeScript.DiagnosticCode.Multiple_constructor_implementations_are_not_allowed, null)); + + constructorSymbol = null; + } + } + + if (constructorSymbol) { + constructorTypeSymbol = constructorSymbol.type; + } else { + constructorSymbol = new TypeScript.PullSymbol(constructorName, 32768 /* ConstructorMethod */); + constructorTypeSymbol = new TypeScript.PullTypeSymbol("", 33554432 /* ConstructorType */); + } + + parent.setConstructorMethod(constructorSymbol); + constructorSymbol.type = constructorTypeSymbol; + + constructorDeclaration.setSymbol(constructorSymbol); + constructorSymbol.addDeclaration(constructorDeclaration); + constructorTypeSymbol.addDeclaration(constructorDeclaration); + constructorSymbol.setIsSynthesized(false); + this.semanticInfo.setSymbolForAST(constructorAST, constructorSymbol); + + var constructSignature = isSignature ? new TypeScript.PullSignatureSymbol(2097152 /* ConstructSignature */) : new TypeScript.PullDefinitionSignatureSymbol(2097152 /* ConstructSignature */); + + constructSignature.returnType = parent; + + constructSignature.addDeclaration(constructorDeclaration); + constructorDeclaration.setSignatureSymbol(constructSignature); + + this.bindParameterSymbols(constructorAST, constructorTypeSymbol, constructSignature); + + var typeParameters = constructorTypeSymbol.getTypeParameters(); + + for (var i = 0; i < typeParameters.length; i++) { + constructSignature.addTypeParameter(typeParameters[i]); + } + + if (constructorAST.variableArgList) { + constructSignature.hasVarArgs = true; + } + + constructorTypeSymbol.addConstructSignature(constructSignature); + + var otherDecls = this.findDeclsInContext(constructorDeclaration, constructorDeclaration.kind, false); + + if (otherDecls && otherDecls.length) { + for (var i = 0; i < otherDecls.length; i++) { + otherDecls[i].ensureSymbolIsBound(); + } + } + }; + + PullSymbolBinder.prototype.bindConstructSignatureDeclarationToPullSymbol = function (constructSignatureDeclaration) { + var parent = this.getParent(constructSignatureDeclaration, true); + var constructorAST = this.semanticInfo.getASTForDecl(constructSignatureDeclaration); + + var constructSignature = new TypeScript.PullSignatureSymbol(2097152 /* ConstructSignature */); + + if (constructorAST.variableArgList) { + constructSignature.hasVarArgs = true; + } + + var typeParameters = constructSignatureDeclaration.getTypeParameters(); + var typeParameter; + var typeParameterDecls = null; + + for (var i = 0; i < typeParameters.length; i++) { + typeParameter = constructSignature.findTypeParameter(typeParameters[i].name); + + if (!typeParameter) { + typeParameter = new TypeScript.PullTypeParameterSymbol(typeParameters[i].name, true); + + constructSignature.addTypeParameter(typeParameter); + } else { + typeParameterDecls = typeParameter.getDeclarations(); + + var typeParameterAST = this.semanticInfoChain.getASTForDecl(typeParameterDecls[0]); + constructSignatureDeclaration.addDiagnostic(new TypeScript.Diagnostic(this.semanticInfo.getPath(), typeParameterAST.minChar, typeParameterAST.getLength(), TypeScript.DiagnosticCode.Duplicate_identifier_0, [typeParameter.getName()])); + } + + typeParameter.addDeclaration(typeParameters[i]); + typeParameters[i].setSymbol(typeParameter); + } + + constructSignature.addDeclaration(constructSignatureDeclaration); + constructSignatureDeclaration.setSignatureSymbol(constructSignature); + + this.bindParameterSymbols(this.semanticInfo.getASTForDecl(constructSignatureDeclaration), null, constructSignature); + + this.semanticInfo.setSymbolForAST(this.semanticInfo.getASTForDecl(constructSignatureDeclaration), constructSignature); + + parent.addConstructSignature(constructSignature); + }; + + PullSymbolBinder.prototype.bindCallSignatureDeclarationToPullSymbol = function (callSignatureDeclaration) { + var parent = this.getParent(callSignatureDeclaration, true); + var callSignatureAST = this.semanticInfo.getASTForDecl(callSignatureDeclaration); + + var callSignature = new TypeScript.PullSignatureSymbol(1048576 /* CallSignature */); + + if (callSignatureAST.variableArgList) { + callSignature.hasVarArgs = true; + } + + var typeParameters = callSignatureDeclaration.getTypeParameters(); + var typeParameter; + var typeParameterDecls = null; + + for (var i = 0; i < typeParameters.length; i++) { + typeParameter = callSignature.findTypeParameter(typeParameters[i].name); + + if (!typeParameter) { + typeParameter = new TypeScript.PullTypeParameterSymbol(typeParameters[i].name, true); + + callSignature.addTypeParameter(typeParameter); + } else { + typeParameterDecls = typeParameter.getDeclarations(); + + var typeParameterAST = this.semanticInfoChain.getASTForDecl(typeParameterDecls[0]); + callSignatureDeclaration.addDiagnostic(new TypeScript.Diagnostic(this.semanticInfo.getPath(), typeParameterAST.minChar, typeParameterAST.getLength(), TypeScript.DiagnosticCode.Duplicate_identifier_0, [typeParameter.getName()])); + } + + typeParameter.addDeclaration(typeParameters[i]); + typeParameters[i].setSymbol(typeParameter); + } + + callSignature.addDeclaration(callSignatureDeclaration); + callSignatureDeclaration.setSignatureSymbol(callSignature); + + this.bindParameterSymbols(this.semanticInfo.getASTForDecl(callSignatureDeclaration), null, callSignature); + + this.semanticInfo.setSymbolForAST(this.semanticInfo.getASTForDecl(callSignatureDeclaration), callSignature); + + parent.addCallSignature(callSignature); + }; + + PullSymbolBinder.prototype.bindIndexSignatureDeclarationToPullSymbol = function (indexSignatureDeclaration) { + var parent = this.getParent(indexSignatureDeclaration, true); + + var indexSignature = new TypeScript.PullSignatureSymbol(4194304 /* IndexSignature */); + + var typeParameters = indexSignatureDeclaration.getTypeParameters(); + var typeParameter; + var typeParameterDecls = null; + + for (var i = 0; i < typeParameters.length; i++) { + typeParameter = indexSignature.findTypeParameter(typeParameters[i].name); + + if (!typeParameter) { + typeParameter = new TypeScript.PullTypeParameterSymbol(typeParameters[i].name, true); + + indexSignature.addTypeParameter(typeParameter); + } else { + typeParameterDecls = typeParameter.getDeclarations(); + + var typeParameterAST = this.semanticInfoChain.getASTForDecl(typeParameterDecls[0]); + indexSignatureDeclaration.addDiagnostic(new TypeScript.Diagnostic(this.semanticInfo.getPath(), typeParameterAST.minChar, typeParameterAST.getLength(), TypeScript.DiagnosticCode.Duplicate_identifier_0, [typeParameter.name])); + } + + typeParameter.addDeclaration(typeParameters[i]); + typeParameters[i].setSymbol(typeParameter); + } + + indexSignature.addDeclaration(indexSignatureDeclaration); + indexSignatureDeclaration.setSignatureSymbol(indexSignature); + + this.bindParameterSymbols(this.semanticInfo.getASTForDecl(indexSignatureDeclaration), null, indexSignature); + + this.semanticInfo.setSymbolForAST(this.semanticInfo.getASTForDecl(indexSignatureDeclaration), indexSignature); + + parent.addIndexSignature(indexSignature); + }; + + PullSymbolBinder.prototype.bindGetAccessorDeclarationToPullSymbol = function (getAccessorDeclaration) { + var declKind = getAccessorDeclaration.kind; + var declFlags = getAccessorDeclaration.flags; + var funcDeclAST = this.semanticInfo.getASTForDecl(getAccessorDeclaration); + + var isExported = (declFlags & 1 /* Exported */) !== 0; + + var funcName = getAccessorDeclaration.name; + + var isSignature = (declFlags & 2048 /* Signature */) !== 0; + var isStatic = false; + + if (TypeScript.hasFlag(declFlags, 16 /* Static */)) { + isStatic = true; + } + + var parent = this.getParent(getAccessorDeclaration, true); + var parentHadSymbol = false; + + var accessorSymbol = null; + var getterSymbol = null; + var getterTypeSymbol = null; + + if (isStatic) { + parent = parent.getConstructorMethod().type; + } + + accessorSymbol = parent.findMember(funcName, false); + + if (accessorSymbol) { + if (!accessorSymbol.isAccessor()) { + getAccessorDeclaration.addDiagnostic(new TypeScript.Diagnostic(this.semanticInfo.getPath(), funcDeclAST.minChar, funcDeclAST.getLength(), TypeScript.DiagnosticCode.Duplicate_identifier_0, [getAccessorDeclaration.getDisplayName()])); + accessorSymbol = null; + } else { + getterSymbol = accessorSymbol.getGetter(); + + if (getterSymbol) { + getAccessorDeclaration.addDiagnostic(new TypeScript.Diagnostic(this.semanticInfo.getPath(), funcDeclAST.minChar, funcDeclAST.getLength(), TypeScript.DiagnosticCode.Getter_0_already_declared, [getAccessorDeclaration.getDisplayName()])); + accessorSymbol = null; + getterSymbol = null; + } + } + } + + if (accessorSymbol) { + parentHadSymbol = true; + } + + if (accessorSymbol && getterSymbol) { + getterTypeSymbol = getterSymbol.type; + } + + if (!accessorSymbol) { + accessorSymbol = new TypeScript.PullAccessorSymbol(funcName); + } + + if (!getterSymbol) { + getterSymbol = new TypeScript.PullSymbol(funcName, 16384 /* Function */); + getterTypeSymbol = new TypeScript.PullTypeSymbol("", 16777216 /* FunctionType */); + getterTypeSymbol.setFunctionSymbol(getterSymbol); + + getterSymbol.type = getterTypeSymbol; + + accessorSymbol.setGetter(getterSymbol); + } + + getAccessorDeclaration.setSymbol(accessorSymbol); + accessorSymbol.addDeclaration(getAccessorDeclaration); + getterSymbol.addDeclaration(getAccessorDeclaration); + + this.semanticInfo.setSymbolForAST(funcDeclAST.name, getterSymbol); + this.semanticInfo.setSymbolForAST(funcDeclAST, getterSymbol); + + if (!parentHadSymbol) { + parent.addMember(accessorSymbol); + } + + var signature = isSignature ? new TypeScript.PullSignatureSymbol(1048576 /* CallSignature */) : new TypeScript.PullDefinitionSignatureSymbol(1048576 /* CallSignature */); + + signature.addDeclaration(getAccessorDeclaration); + getAccessorDeclaration.setSignatureSymbol(signature); + + this.bindParameterSymbols(this.semanticInfo.getASTForDecl(getAccessorDeclaration), getterTypeSymbol, signature); + + var typeParameters = getAccessorDeclaration.getTypeParameters(); + + if (typeParameters.length) { + getAccessorDeclaration.addDiagnostic(new TypeScript.Diagnostic(this.semanticInfo.getPath(), funcDeclAST.minChar, funcDeclAST.getLength(), TypeScript.DiagnosticCode.Accessors_cannot_have_type_parameters, null)); + } + + getterTypeSymbol.addCallSignature(signature); + }; + + PullSymbolBinder.prototype.bindSetAccessorDeclarationToPullSymbol = function (setAccessorDeclaration) { + var declKind = setAccessorDeclaration.kind; + var declFlags = setAccessorDeclaration.flags; + var funcDeclAST = this.semanticInfo.getASTForDecl(setAccessorDeclaration); + + var isExported = (declFlags & 1 /* Exported */) !== 0; + + var funcName = setAccessorDeclaration.name; + + var isSignature = (declFlags & 2048 /* Signature */) !== 0; + var isStatic = false; + + if (TypeScript.hasFlag(declFlags, 16 /* Static */)) { + isStatic = true; + } + + var parent = this.getParent(setAccessorDeclaration, true); + var parentHadSymbol = false; + + var accessorSymbol = null; + var setterSymbol = null; + var setterTypeSymbol = null; + + if (isStatic) { + parent = parent.getConstructorMethod().type; + } + + accessorSymbol = parent.findMember(funcName, false); + + if (accessorSymbol) { + if (!accessorSymbol.isAccessor()) { + setAccessorDeclaration.addDiagnostic(new TypeScript.Diagnostic(this.semanticInfo.getPath(), funcDeclAST.minChar, funcDeclAST.getLength(), TypeScript.DiagnosticCode.Duplicate_identifier_0, [setAccessorDeclaration.getDisplayName()])); + accessorSymbol = null; + } else { + setterSymbol = accessorSymbol.getSetter(); + + if (setterSymbol) { + setAccessorDeclaration.addDiagnostic(new TypeScript.Diagnostic(this.semanticInfo.getPath(), funcDeclAST.minChar, funcDeclAST.getLength(), TypeScript.DiagnosticCode.Setter_0_already_declared, [setAccessorDeclaration.getDisplayName()])); + accessorSymbol = null; + setterSymbol = null; + } + } + } + + if (accessorSymbol) { + parentHadSymbol = true; + + if (setterSymbol) { + setterTypeSymbol = setterSymbol.type; + } + } + + if (!accessorSymbol) { + accessorSymbol = new TypeScript.PullAccessorSymbol(funcName); + } + + if (!setterSymbol) { + setterSymbol = new TypeScript.PullSymbol(funcName, 16384 /* Function */); + setterTypeSymbol = new TypeScript.PullTypeSymbol("", 16777216 /* FunctionType */); + setterTypeSymbol.setFunctionSymbol(setterSymbol); + + setterSymbol.type = setterTypeSymbol; + + accessorSymbol.setSetter(setterSymbol); + } + + setAccessorDeclaration.setSymbol(accessorSymbol); + accessorSymbol.addDeclaration(setAccessorDeclaration); + setterSymbol.addDeclaration(setAccessorDeclaration); + + this.semanticInfo.setSymbolForAST(funcDeclAST.name, setterSymbol); + this.semanticInfo.setSymbolForAST(funcDeclAST, setterSymbol); + + if (!parentHadSymbol) { + parent.addMember(accessorSymbol); + } + + var signature = isSignature ? new TypeScript.PullSignatureSymbol(1048576 /* CallSignature */) : new TypeScript.PullDefinitionSignatureSymbol(1048576 /* CallSignature */); + + signature.addDeclaration(setAccessorDeclaration); + setAccessorDeclaration.setSignatureSymbol(signature); + + this.bindParameterSymbols(this.semanticInfo.getASTForDecl(setAccessorDeclaration), setterTypeSymbol, signature); + + var typeParameters = setAccessorDeclaration.getTypeParameters(); + + if (typeParameters.length) { + setAccessorDeclaration.addDiagnostic(new TypeScript.Diagnostic(this.semanticInfo.getPath(), funcDeclAST.minChar, funcDeclAST.getLength(), TypeScript.DiagnosticCode.Accessors_cannot_have_type_parameters, null)); + } + + setterTypeSymbol.addCallSignature(signature); + }; + + PullSymbolBinder.prototype.bindDeclToPullSymbol = function (decl) { + if (decl.isBound()) { + return; + } + + decl.setIsBound(true); + + switch (decl.kind) { + case 1 /* Script */: + var childDecls = decl.getChildDecls(); + for (var i = 0; i < childDecls.length; i++) { + this.bindDeclToPullSymbol(childDecls[i]); + } + break; + + case 64 /* Enum */: + case 32 /* DynamicModule */: + case 4 /* Container */: + this.bindModuleDeclarationToPullSymbol(decl); + break; + + case 16 /* Interface */: + this.bindInterfaceDeclarationToPullSymbol(decl); + break; + + case 8 /* Class */: + this.bindClassDeclarationToPullSymbol(decl); + break; + + case 16384 /* Function */: + this.bindFunctionDeclarationToPullSymbol(decl); + break; + + case 1024 /* Variable */: + this.bindVariableDeclarationToPullSymbol(decl); + break; + + case 67108864 /* EnumMember */: + case 4096 /* Property */: + this.bindPropertyDeclarationToPullSymbol(decl); + break; + + case 65536 /* Method */: + this.bindMethodDeclarationToPullSymbol(decl); + break; + + case 32768 /* ConstructorMethod */: + this.bindConstructorDeclarationToPullSymbol(decl); + break; + + case 1048576 /* CallSignature */: + this.bindCallSignatureDeclarationToPullSymbol(decl); + break; + + case 2097152 /* ConstructSignature */: + this.bindConstructSignatureDeclarationToPullSymbol(decl); + break; + + case 4194304 /* IndexSignature */: + this.bindIndexSignatureDeclarationToPullSymbol(decl); + break; + + case 262144 /* GetAccessor */: + this.bindGetAccessorDeclarationToPullSymbol(decl); + break; + + case 524288 /* SetAccessor */: + this.bindSetAccessorDeclarationToPullSymbol(decl); + break; + + case 8388608 /* ObjectType */: + this.bindObjectTypeDeclarationToPullSymbol(decl); + break; + + case 16777216 /* FunctionType */: + this.bindFunctionTypeDeclarationToPullSymbol(decl); + break; + + case 33554432 /* ConstructorType */: + this.bindConstructorTypeDeclarationToPullSymbol(decl); + break; + + case 131072 /* FunctionExpression */: + this.bindFunctionExpressionToPullSymbol(decl); + break; + + case 256 /* TypeAlias */: + this.bindImportDeclaration(decl); + break; + + case 2048 /* Parameter */: + case 8192 /* TypeParameter */: + break; + + case 1073741824 /* CatchBlock */: + case 536870912 /* WithBlock */: + break; + + default: + TypeScript.CompilerDiagnostics.assert(false, "Unrecognized type declaration"); + } + }; + + PullSymbolBinder.prototype.bindDeclsForUnit = function (filePath) { + this.setUnit(filePath); + + var topLevelDecls = this.semanticInfo.getTopLevelDecls(); + + for (var i = 0; i < topLevelDecls.length; i++) { + this.bindDeclToPullSymbol(topLevelDecls[i]); + } + }; + return PullSymbolBinder; + })(); + TypeScript.PullSymbolBinder = PullSymbolBinder; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + function getDiagnosticsFromEnclosingDecl(enclosingDecl, errors) { + var declErrors = enclosingDecl.getDiagnostics(); + + if (declErrors) { + for (var i = 0; i < declErrors.length; i++) { + errors[errors.length] = declErrors[i]; + } + } + + var childDecls = enclosingDecl.getChildDecls(); + + for (var i = 0; i < childDecls.length; i++) { + getDiagnosticsFromEnclosingDecl(childDecls[i], errors); + } + } + TypeScript.getDiagnosticsFromEnclosingDecl = getDiagnosticsFromEnclosingDecl; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (PullHelpers) { + function getSignatureForFuncDecl(funcDecl, semanticInfo) { + var functionDecl = semanticInfo.getDeclForAST(funcDecl); + var funcSymbol = functionDecl.getSymbol(); + + if (!funcSymbol) { + funcSymbol = functionDecl.getSignatureSymbol(); + } + + var functionSignature = null; + var typeSymbolWithAllSignatures = null; + if (funcSymbol.isSignature()) { + functionSignature = funcSymbol; + var parent = functionDecl.getParentDecl(); + typeSymbolWithAllSignatures = parent.getSymbol().type; + } else { + functionSignature = functionDecl.getSignatureSymbol(); + typeSymbolWithAllSignatures = funcSymbol.type; + } + var signatures; + if (funcDecl.isConstructor || funcDecl.isConstructMember()) { + signatures = typeSymbolWithAllSignatures.getConstructSignatures(); + } else if (funcDecl.isIndexerMember()) { + signatures = typeSymbolWithAllSignatures.getIndexSignatures(); + } else { + signatures = typeSymbolWithAllSignatures.getCallSignatures(); + } + return { + signature: functionSignature, + allSignatures: signatures + }; + } + PullHelpers.getSignatureForFuncDecl = getSignatureForFuncDecl; + + function getAccessorSymbol(getterOrSetter, semanticInfoChain, unitPath) { + var functionDecl = semanticInfoChain.getDeclForAST(getterOrSetter, unitPath); + var getterOrSetterSymbol = functionDecl.getSymbol(); + + return getterOrSetterSymbol; + } + PullHelpers.getAccessorSymbol = getAccessorSymbol; + + function getGetterAndSetterFunction(funcDecl, semanticInfoChain, unitPath) { + var accessorSymbol = PullHelpers.getAccessorSymbol(funcDecl, semanticInfoChain, unitPath); + var result = { + getter: null, + setter: null + }; + var getter = accessorSymbol.getGetter(); + if (getter) { + var getterDecl = getter.getDeclarations()[0]; + result.getter = semanticInfoChain.getASTForDecl(getterDecl); + } + var setter = accessorSymbol.getSetter(); + if (setter) { + var setterDecl = setter.getDeclarations()[0]; + result.setter = semanticInfoChain.getASTForDecl(setterDecl); + } + + return result; + } + PullHelpers.getGetterAndSetterFunction = getGetterAndSetterFunction; + + function symbolIsEnum(source) { + return source && ((source.kind & (64 /* Enum */ | 67108864 /* EnumMember */)) || source.hasFlag(131072 /* InitializedEnum */)); + } + PullHelpers.symbolIsEnum = symbolIsEnum; + + function symbolIsModule(symbol) { + return symbol && (symbol.kind == 4 /* Container */ || isOneDeclarationOfKind(symbol, 4 /* Container */)); + } + PullHelpers.symbolIsModule = symbolIsModule; + + function isOneDeclarationOfKind(symbol, kind) { + var decls = symbol.getDeclarations(); + for (var i = 0; i < decls.length; i++) { + if (decls[i].kind === kind) { + return true; + } + } + + return false; + } + })(TypeScript.PullHelpers || (TypeScript.PullHelpers = {})); + var PullHelpers = TypeScript.PullHelpers; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var SyntaxTreeToAstVisitor = (function () { + function SyntaxTreeToAstVisitor(fileName, lineMap, compilationSettings) { + this.fileName = fileName; + this.lineMap = lineMap; + this.compilationSettings = compilationSettings; + this.position = 0; + this.previousTokenTrailingComments = null; + } + SyntaxTreeToAstVisitor.visit = function (syntaxTree, fileName, compilationSettings, incrementalAST) { + var visitor = incrementalAST ? new SyntaxTreeToIncrementalAstVisitor(fileName, syntaxTree.lineMap(), compilationSettings) : new SyntaxTreeToAstVisitor(fileName, syntaxTree.lineMap(), compilationSettings); + return syntaxTree.sourceUnit().accept(visitor); + }; + + SyntaxTreeToAstVisitor.prototype.movePast = function (element) { + if (element !== null) { + this.position += element.fullWidth(); + } + }; + + SyntaxTreeToAstVisitor.prototype.moveTo = function (element1, element2) { + if (element2 !== null) { + this.position += TypeScript.Syntax.childOffset(element1, element2); + } + }; + + SyntaxTreeToAstVisitor.prototype.setCommentsAndSpan = function (ast, fullStart, node) { + var firstToken = node.firstToken(); + var lastToken = node.lastToken(); + + this.setSpan2(ast, fullStart, node, firstToken, lastToken); + ast.setPreComments(this.convertTokenLeadingComments(firstToken, fullStart)); + ast.setPostComments(this.convertNodeTrailingComments(node, lastToken, fullStart)); + }; + + SyntaxTreeToAstVisitor.prototype.copySpan = function (from, to) { + to.minChar = from.minChar; + to.limChar = from.limChar; + to.trailingTriviaWidth = from.trailingTriviaWidth; + }; + + SyntaxTreeToAstVisitor.prototype.setSpan = function (span, fullStart, element) { + this.setSpan2(span, fullStart, element, element.firstToken(), element.lastToken()); + }; + + SyntaxTreeToAstVisitor.prototype.setSpan2 = function (span, fullStart, element, firstToken, lastToken) { + var leadingTriviaWidth = firstToken ? firstToken.leadingTriviaWidth() : 0; + var trailingTriviaWidth = lastToken ? lastToken.trailingTriviaWidth() : 0; + + var desiredMinChar = fullStart + leadingTriviaWidth; + var desiredLimChar = fullStart + element.fullWidth() - trailingTriviaWidth; + + this.setSpanExplicit(span, desiredMinChar, desiredLimChar); + + span.trailingTriviaWidth = trailingTriviaWidth; + }; + + SyntaxTreeToAstVisitor.prototype.setSpanExplicit = function (span, start, end) { + span.minChar = start; + span.limChar = end; + }; + + SyntaxTreeToAstVisitor.prototype.identifierFromToken = function (token, isOptional) { + var result = null; + if (token.fullWidth() === 0) { + result = new TypeScript.MissingIdentifier(); + } else if (token.kind() === 11 /* IdentifierName */) { + var tokenText = token.text(); + var text = tokenText === SyntaxTreeToAstVisitor.protoString ? SyntaxTreeToAstVisitor.protoSubstitutionString : null; + + result = new TypeScript.Identifier(tokenText, text); + } else { + var tokenText = token.text(); + result = new TypeScript.Identifier(tokenText, tokenText); + } + + if (isOptional) { + result.setFlags(result.getFlags() | 4 /* OptionalName */); + } + + var start = this.position + token.leadingTriviaWidth(); + this.setSpanExplicit(result, start, start + token.width()); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitSyntaxList = function (node) { + var start = this.position; + var array = new Array(node.childCount()); + + for (var i = 0, n = node.childCount(); i < n; i++) { + array[i] = node.childAt(i).accept(this); + } + + var result = new TypeScript.ASTList(array); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitSeparatedSyntaxList = function (list) { + var start = this.position; + var array = new Array(list.nonSeparatorCount()); + + for (var i = 0, n = list.childCount(); i < n; i++) { + if (i % 2 === 0) { + array[i / 2] = list.childAt(i).accept(this); + this.previousTokenTrailingComments = null; + } else { + var separatorToken = list.childAt(i); + this.previousTokenTrailingComments = this.convertTokenTrailingComments(separatorToken, this.position + separatorToken.leadingTriviaWidth() + separatorToken.width()); + this.movePast(separatorToken); + } + } + + var result = new TypeScript.ASTList(array, list.separatorCount()); + this.setSpan(result, start, list); + + result.setPostComments(this.previousTokenTrailingComments); + this.previousTokenTrailingComments = null; + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.createRef = function (text, minChar) { + var id = new TypeScript.Identifier(text, null); + id.minChar = minChar; + return id; + }; + + SyntaxTreeToAstVisitor.prototype.convertComment = function (trivia, commentStartPosition, hasTrailingNewLine) { + var comment = new TypeScript.Comment(trivia.fullText(), trivia.kind() === 6 /* MultiLineCommentTrivia */, hasTrailingNewLine); + + comment.minChar = commentStartPosition; + comment.limChar = commentStartPosition + trivia.fullWidth(); + + return comment; + }; + + SyntaxTreeToAstVisitor.prototype.convertComments = function (triviaList, commentStartPosition) { + var result = []; + + for (var i = 0, n = triviaList.count(); i < n; i++) { + var trivia = triviaList.syntaxTriviaAt(i); + + if (trivia.isComment()) { + var hasTrailingNewLine = ((i + 1) < n) && triviaList.syntaxTriviaAt(i + 1).isNewLine(); + result.push(this.convertComment(trivia, commentStartPosition, hasTrailingNewLine)); + } + + commentStartPosition += trivia.fullWidth(); + } + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.mergeComments = function (comments1, comments2) { + if (comments1 === null) { + return comments2; + } + + if (comments2 === null) { + return comments1; + } + + return comments1.concat(comments2); + }; + + SyntaxTreeToAstVisitor.prototype.convertTokenLeadingComments = function (token, commentStartPosition) { + if (token === null) { + return null; + } + + var preComments = token.hasLeadingComment() ? this.convertComments(token.leadingTrivia(), commentStartPosition) : null; + + var previousTokenTrailingComments = this.previousTokenTrailingComments; + this.previousTokenTrailingComments = null; + + return this.mergeComments(previousTokenTrailingComments, preComments); + }; + + SyntaxTreeToAstVisitor.prototype.convertTokenTrailingComments = function (token, commentStartPosition) { + if (token === null || !token.hasTrailingComment() || token.hasTrailingNewLine()) { + return null; + } + + return this.convertComments(token.trailingTrivia(), commentStartPosition); + }; + + SyntaxTreeToAstVisitor.prototype.convertNodeTrailingComments = function (node, lastToken, nodeStart) { + if (lastToken === null || !lastToken.hasTrailingComment() || lastToken.hasTrailingNewLine()) { + return null; + } + + return this.convertComments(lastToken.trailingTrivia(), nodeStart + node.fullWidth() - lastToken.trailingTriviaWidth()); + }; + + SyntaxTreeToAstVisitor.prototype.visitToken = function (token) { + var fullStart = this.position; + + var result; + if (token.kind() === 35 /* ThisKeyword */) { + result = new TypeScript.ThisExpression(); + } else if (token.kind() === 50 /* SuperKeyword */) { + result = new TypeScript.SuperExpression(); + } else if (token.kind() === 37 /* TrueKeyword */) { + result = new TypeScript.LiteralExpression(3 /* TrueLiteral */); + } else if (token.kind() === 24 /* FalseKeyword */) { + result = new TypeScript.LiteralExpression(4 /* FalseLiteral */); + } else if (token.kind() === 32 /* NullKeyword */) { + result = new TypeScript.LiteralExpression(8 /* NullLiteral */); + } else if (token.kind() === 14 /* StringLiteral */) { + result = new TypeScript.StringLiteral(token.text(), token.valueText()); + } else if (token.kind() === 12 /* RegularExpressionLiteral */) { + result = new TypeScript.RegexLiteral(token.text()); + } else if (token.kind() === 13 /* NumericLiteral */) { + var preComments = this.convertTokenLeadingComments(token, fullStart); + + var value = token.text().indexOf(".") > 0 ? parseFloat(token.text()) : parseInt(token.text()); + result = new TypeScript.NumberLiteral(value, token.text()); + + result.setPreComments(preComments); + } else { + result = this.identifierFromToken(token, false); + } + + this.movePast(token); + + var start = fullStart + token.leadingTriviaWidth(); + this.setSpanExplicit(result, start, start + token.width()); + return result; + }; + + SyntaxTreeToAstVisitor.prototype.getLeadingComments = function (node) { + var firstToken = node.firstToken(); + var result = []; + + if (firstToken.hasLeadingComment()) { + var leadingTrivia = firstToken.leadingTrivia(); + + for (var i = 0, n = leadingTrivia.count(); i < n; i++) { + var trivia = leadingTrivia.syntaxTriviaAt(i); + + if (trivia.isComment()) { + result.push(trivia); + } + } + } + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.hasTopLevelImportOrExport = function (node) { + var firstToken; + + for (var i = 0, n = node.moduleElements.childCount(); i < n; i++) { + var moduleElement = node.moduleElements.childAt(i); + + firstToken = moduleElement.firstToken(); + if (firstToken !== null && firstToken.kind() === 47 /* ExportKeyword */) { + return true; + } + + if (moduleElement.kind() === 133 /* ImportDeclaration */) { + var importDecl = moduleElement; + if (importDecl.moduleReference.kind() === 245 /* ExternalModuleReference */) { + return true; + } + } + } + + var leadingComments = this.getLeadingComments(node); + for (var i = 0, n = leadingComments.length; i < n; i++) { + var trivia = leadingComments[i]; + + if (TypeScript.getImplicitImport(trivia.fullText())) { + return true; + } + } + + return false; + }; + + SyntaxTreeToAstVisitor.prototype.getAmdDependency = function (comment) { + var amdDependencyRegEx = /^\/\/\/\s*= 0; i--) { + var innerName = names[i]; + + var result = new TypeScript.ModuleDeclaration(innerName, members, closeBraceSpan); + this.setSpan(result, start, node); + + result.setPreComments(preComments); + result.setPostComments(postComments); + + preComments = null; + postComments = null; + + if (i || TypeScript.SyntaxUtilities.containsToken(node.modifiers, 47 /* ExportKeyword */)) { + result.setModuleFlags(result.getModuleFlags() | 1 /* Exported */); + } + + members = new TypeScript.ASTList([result]); + } + + this.completeModuleDeclaration(node, result); + + this.setSpan(result, start, node); + return result; + }; + + SyntaxTreeToAstVisitor.prototype.completeModuleDeclaration = function (node, result) { + if (TypeScript.SyntaxUtilities.containsToken(node.modifiers, 63 /* DeclareKeyword */)) { + result.setModuleFlags(result.getModuleFlags() | 8 /* Ambient */); + } + }; + + SyntaxTreeToAstVisitor.prototype.hasDotDotDotParameter = function (parameters) { + for (var i = 0, n = parameters.nonSeparatorCount(); i < n; i++) { + if ((parameters.nonSeparatorAt(i)).dotDotDotToken) { + return true; + } + } + + return false; + }; + + SyntaxTreeToAstVisitor.prototype.visitFunctionDeclaration = function (node) { + var start = this.position; + + this.moveTo(node, node.identifier); + var name = this.identifierFromToken(node.identifier, false); + + this.movePast(node.identifier); + + var typeParameters = node.callSignature.typeParameterList === null ? null : node.callSignature.typeParameterList.accept(this); + var parameters = node.callSignature.parameterList.accept(this); + + var returnType = node.callSignature.typeAnnotation ? node.callSignature.typeAnnotation.accept(this) : null; + + var block = node.block ? node.block.accept(this) : null; + + this.movePast(node.semicolonToken); + + var result = new TypeScript.FunctionDeclaration(name, block, false, typeParameters, parameters, returnType, this.hasDotDotDotParameter(node.callSignature.parameterList.parameters)); + this.setCommentsAndSpan(result, start, node); + + if (node.semicolonToken) { + result.setFunctionFlags(result.getFunctionFlags() | 128 /* Signature */); + } + + this.completeFunctionDeclaration(node, result); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.completeFunctionDeclaration = function (node, result) { + var flags = result.getFunctionFlags(); + if (TypeScript.SyntaxUtilities.containsToken(node.modifiers, 47 /* ExportKeyword */)) { + flags = flags | 1 /* Exported */; + } + + if (TypeScript.SyntaxUtilities.containsToken(node.modifiers, 63 /* DeclareKeyword */)) { + flags = flags | 8 /* Ambient */; + } + + result.setFunctionFlags(flags); + }; + + SyntaxTreeToAstVisitor.prototype.visitEnumDeclaration = function (node) { + var start = this.position; + + this.moveTo(node, node.identifier); + var name = this.identifierFromToken(node.identifier, false); + this.movePast(node.identifier); + + this.movePast(node.openBraceToken); + var array = new Array(node.enumElements.nonSeparatorCount()); + + var declarators = []; + + for (var i = 0, n = node.enumElements.childCount(); i < n; i++) { + if (i % 2 === 1) { + this.movePast(node.enumElements.childAt(i)); + } else { + var enumElement = node.enumElements.childAt(i); + var enumElementFullStart = this.position; + var memberStart = this.position + enumElement.leadingTriviaWidth(); + + var memberName = this.identifierFromToken(enumElement.propertyName, false); + this.movePast(enumElement.propertyName); + + var init = enumElement.equalsValueClause !== null ? enumElement.equalsValueClause.accept(this) : null; + + var declarator = new TypeScript.VariableDeclarator(memberName, new TypeScript.TypeReference(this.createRef(name.actualText, -1), 0), init); + declarator.constantValue = this.determineConstantValue(enumElement.equalsValueClause, declarators); + + declarator.setVarFlags(declarator.getVarFlags() | 256 /* Property */); + this.setSpanExplicit(declarator, memberStart, this.position); + declarator.setPreComments(this.convertTokenLeadingComments(enumElement.firstToken(), enumElementFullStart)); + declarator.setPostComments(this.convertNodeTrailingComments(enumElement, enumElement.lastToken(), enumElementFullStart)); + + declarators.push(declarator); + + var declaration = new TypeScript.VariableDeclaration(new TypeScript.ASTList([declarator])); + this.setSpanExplicit(declaration, memberStart, this.position); + + var statement = new TypeScript.VariableStatement(declaration); + statement.setFlags(16 /* EnumElement */); + this.setSpanExplicit(statement, memberStart, this.position); + + array[i / 2] = statement; + + declarator.setVarFlags(declarator.getVarFlags() | 1 /* Exported */); + } + } + + var members = new TypeScript.ASTList(array); + + var closeBracePosition = this.position; + this.movePast(node.closeBraceToken); + var closeBraceSpan = new TypeScript.ASTSpan(); + this.setSpan(closeBraceSpan, closeBracePosition, node.closeBraceToken); + + var result = new TypeScript.ModuleDeclaration(name, members, closeBraceSpan); + this.setCommentsAndSpan(result, start, node); + + var flags = result.getModuleFlags() | 128 /* IsEnum */; + + if (TypeScript.SyntaxUtilities.containsToken(node.modifiers, 47 /* ExportKeyword */)) { + flags = flags | 1 /* Exported */; + } + + result.setModuleFlags(flags); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.determineConstantValue = function (equalsValue, declarators) { + var value = equalsValue === null ? null : equalsValue.value; + if (value === null) { + if (declarators.length === 0) { + return 0; + } else { + var lastConstantValue = TypeScript.ArrayUtilities.last(declarators).constantValue; + return lastConstantValue !== null ? lastConstantValue + 1 : null; + } + } else { + return this.computeConstantValue(value, declarators); + } + }; + + SyntaxTreeToAstVisitor.prototype.computeConstantValue = function (expression, declarators) { + if (TypeScript.Syntax.isIntegerLiteral(expression)) { + var token; + switch (expression.kind()) { + case 163 /* PlusExpression */: + case 164 /* NegateExpression */: + token = (expression).operand; + break; + default: + token = expression; + } + + var value = token.value(); + return value && expression.kind() === 164 /* NegateExpression */ ? -value : value; + } else if (this.compilationSettings.propagateEnumConstants) { + switch (expression.kind()) { + case 11 /* IdentifierName */: + var variableDeclarator = TypeScript.ArrayUtilities.firstOrDefault(declarators, function (d) { + return d.id.text() === (expression).valueText(); + }); + return variableDeclarator ? variableDeclarator.constantValue : null; + + case 201 /* LeftShiftExpression */: + var binaryExpression = expression; + return this.computeConstantValue(binaryExpression.left, declarators) << this.computeConstantValue(binaryExpression.right, declarators); + } + + return null; + } else { + return null; + } + }; + + SyntaxTreeToAstVisitor.prototype.visitEnumElement = function (node) { + throw TypeScript.Errors.invalidOperation(); + }; + + SyntaxTreeToAstVisitor.prototype.visitImportDeclaration = function (node) { + var start = this.position; + + this.moveTo(node, node.identifier); + var name = this.identifierFromToken(node.identifier, false); + this.movePast(node.identifier); + this.movePast(node.equalsToken); + var alias = node.moduleReference.accept(this); + this.movePast(node.semicolonToken); + + var result = new TypeScript.ImportDeclaration(name, alias); + this.setCommentsAndSpan(result, start, node); + + var flags = result.getVarFlags(); + if (TypeScript.SyntaxUtilities.containsToken(node.modifiers, 47 /* ExportKeyword */)) { + flags = flags | 1 /* Exported */; + } + result.setVarFlags(flags); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitExportAssignment = function (node) { + var start = this.position; + + this.moveTo(node, node.identifier); + var name = this.identifierFromToken(node.identifier, false); + this.movePast(node.identifier); + this.movePast(node.semicolonToken); + + var result = new TypeScript.ExportAssignment(name); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitVariableStatement = function (node) { + var start = this.position; + + var preComments = null; + if (node.modifiers.childCount() > 0) { + preComments = this.convertTokenLeadingComments(node.modifiers.firstToken(), start); + } + + this.moveTo(node, node.variableDeclaration); + + var declaration = node.variableDeclaration.accept(this); + this.movePast(node.semicolonToken); + + for (var i = 0, n = declaration.declarators.members.length; i < n; i++) { + var varDecl = declaration.declarators.members[i]; + + if (i === 0) { + varDecl.setPreComments(this.mergeComments(preComments, varDecl.preComments())); + } + + var flags = varDecl.getVarFlags(); + if (TypeScript.SyntaxUtilities.containsToken(node.modifiers, 47 /* ExportKeyword */)) { + flags = flags | 1 /* Exported */; + } + + if (TypeScript.SyntaxUtilities.containsToken(node.modifiers, 63 /* DeclareKeyword */)) { + flags = flags | 8 /* Ambient */; + } + + varDecl.setVarFlags(flags); + } + + var result = new TypeScript.VariableStatement(declaration); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitVariableDeclaration = function (node) { + var start = this.position; + + var firstToken = node.firstToken(); + var preComments = this.convertTokenLeadingComments(firstToken, start); + var postComments = this.convertNodeTrailingComments(node, node.lastToken(), start); + + this.moveTo(node, node.variableDeclarators); + var variableDecls = this.visitSeparatedSyntaxList(node.variableDeclarators); + + for (var i = 0; i < variableDecls.members.length; i++) { + if (i === 0) { + variableDecls.members[i].setPreComments(preComments); + variableDecls.members[i].setPostComments(postComments); + } + } + + var result = new TypeScript.VariableDeclaration(variableDecls); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitVariableDeclarator = function (node) { + var start = this.position; + var name = this.identifierFromToken(node.identifier, false); + this.movePast(node.identifier); + var typeExpr = node.typeAnnotation ? node.typeAnnotation.accept(this) : null; + var init = node.equalsValueClause ? node.equalsValueClause.accept(this) : null; + + var result = new TypeScript.VariableDeclarator(name, typeExpr, init); + this.setSpan(result, start, node); + + if (init && init.nodeType() === 13 /* FunctionDeclaration */) { + var funcDecl = init; + funcDecl.hint = name.actualText; + } + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitEqualsValueClause = function (node) { + var afterEqualsComments = this.convertTokenTrailingComments(node.equalsToken, this.position + node.equalsToken.leadingTriviaWidth() + node.equalsToken.width()); + + this.movePast(node.equalsToken); + var result = node.value.accept(this); + result.setPreComments(this.mergeComments(afterEqualsComments, result.preComments())); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.getUnaryExpressionNodeType = function (kind) { + switch (kind) { + case 163 /* PlusExpression */: + return 27 /* PlusExpression */; + case 164 /* NegateExpression */: + return 28 /* NegateExpression */; + case 165 /* BitwiseNotExpression */: + return 73 /* BitwiseNotExpression */; + case 166 /* LogicalNotExpression */: + return 74 /* LogicalNotExpression */; + case 167 /* PreIncrementExpression */: + return 75 /* PreIncrementExpression */; + case 168 /* PreDecrementExpression */: + return 76 /* PreDecrementExpression */; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + SyntaxTreeToAstVisitor.prototype.visitPrefixUnaryExpression = function (node) { + var start = this.position; + + this.movePast(node.operatorToken); + var operand = node.operand.accept(this); + + var result = new TypeScript.UnaryExpression(this.getUnaryExpressionNodeType(node.kind()), operand, null); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.isOnSingleLine = function (start, end) { + return this.lineMap.getLineNumberFromPosition(start) === this.lineMap.getLineNumberFromPosition(end); + }; + + SyntaxTreeToAstVisitor.prototype.visitArrayLiteralExpression = function (node) { + var start = this.position; + var openStart = this.position + node.openBracketToken.leadingTriviaWidth(); + this.movePast(node.openBracketToken); + + var expressions = this.visitSeparatedSyntaxList(node.expressions); + + var closeStart = this.position + node.closeBracketToken.leadingTriviaWidth(); + this.movePast(node.closeBracketToken); + + var result = new TypeScript.UnaryExpression(22 /* ArrayLiteralExpression */, expressions, null); + this.setSpan(result, start, node); + + if (this.isOnSingleLine(openStart, closeStart)) { + result.setFlags(result.getFlags() | 2 /* SingleLine */); + } + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitOmittedExpression = function (node) { + var start = this.position; + + var result = new TypeScript.OmittedExpression(); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitParenthesizedExpression = function (node) { + var start = this.position; + + this.movePast(node.openParenToken); + var expr = node.expression.accept(this); + this.movePast(node.closeParenToken); + + var result = new TypeScript.ParenthesizedExpression(expr); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.getArrowFunctionStatements = function (body) { + if (body.kind() === 145 /* Block */) { + return body.accept(this); + } else { + var expression = body.accept(this); + var returnStatement = new TypeScript.ReturnStatement(expression); + + var preComments = expression.preComments(); + if (preComments) { + (body)._ast = undefined; + returnStatement.setPreComments(preComments); + expression.setPreComments(null); + } + + var statements = new TypeScript.ASTList([returnStatement]); + + var block = new TypeScript.Block(statements, statements.members[0]); + return block; + } + }; + + SyntaxTreeToAstVisitor.prototype.visitSimpleArrowFunctionExpression = function (node) { + var start = this.position; + + var identifier = this.identifierFromToken(node.identifier, false); + this.movePast(node.identifier); + this.movePast(node.equalsGreaterThanToken); + + var parameter = new TypeScript.Parameter(identifier, null, null, false); + this.setSpanExplicit(parameter, identifier.minChar, identifier.limChar); + + var parameters = new TypeScript.ASTList([parameter]); + + var statements = this.getArrowFunctionStatements(node.body); + + var result = new TypeScript.FunctionDeclaration(null, statements, false, null, parameters, null, false); + this.setSpan(result, start, node); + + result.setFunctionFlags(result.getFunctionFlags() | 8192 /* IsFunctionExpression */ | 2048 /* IsFatArrowFunction */); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitParenthesizedArrowFunctionExpression = function (node) { + var start = this.position; + + var typeParameters = node.callSignature.typeParameterList === null ? null : node.callSignature.typeParameterList.accept(this); + var parameters = node.callSignature.parameterList.accept(this); + var returnType = node.callSignature.typeAnnotation ? node.callSignature.typeAnnotation.accept(this) : null; + this.movePast(node.equalsGreaterThanToken); + + var block = this.getArrowFunctionStatements(node.body); + + var result = new TypeScript.FunctionDeclaration(null, block, false, typeParameters, parameters, returnType, this.hasDotDotDotParameter(node.callSignature.parameterList.parameters)); + this.setCommentsAndSpan(result, start, node); + + result.setFunctionFlags(result.getFunctionFlags() | 8192 /* IsFunctionExpression */ | 2048 /* IsFatArrowFunction */); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitType = function (type) { + var result; + if (type.isToken()) { + var start = this.position; + result = new TypeScript.TypeReference(type.accept(this), 0); + this.setSpan(result, start, type); + } else { + result = type.accept(this); + } + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitTypeQuery = function (node) { + var start = this.position; + this.movePast(node.typeOfKeyword); + var name = node.name.accept(this); + + var typeQuery = new TypeScript.TypeQuery(name); + this.setSpan(typeQuery, start, node); + + var result = new TypeScript.TypeReference(typeQuery, 0); + this.copySpan(typeQuery, result); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitQualifiedName = function (node) { + var start = this.position; + var left = this.visitType(node.left).term; + this.movePast(node.dotToken); + var right = this.identifierFromToken(node.right, false); + this.movePast(node.right); + + var term = new TypeScript.BinaryExpression(33 /* MemberAccessExpression */, left, right); + this.setSpan(term, start, node); + + var result = new TypeScript.TypeReference(term, 0); + this.copySpan(term, result); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitTypeArgumentList = function (node) { + var array = new Array(node.typeArguments.nonSeparatorCount()); + + this.movePast(node.lessThanToken); + + var start = this.position; + + for (var i = 0, n = node.typeArguments.childCount(); i < n; i++) { + if (i % 2 === 1) { + this.movePast(node.typeArguments.childAt(i)); + } else { + array[i / 2] = this.visitType(node.typeArguments.childAt(i)); + } + } + this.movePast(node.greaterThanToken); + + var result = new TypeScript.ASTList(array); + this.setSpan(result, start, node.typeArguments); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitConstructorType = function (node) { + var start = this.position; + + this.movePast(node.newKeyword); + var typeParameters = node.typeParameterList === null ? null : node.typeParameterList.accept(this); + var parameters = node.parameterList.accept(this); + this.movePast(node.equalsGreaterThanToken); + var returnType = node.type ? this.visitType(node.type) : null; + + var funcDecl = new TypeScript.FunctionDeclaration(null, null, false, typeParameters, parameters, returnType, this.hasDotDotDotParameter(node.parameterList.parameters)); + this.setSpan(funcDecl, start, node); + + funcDecl.setFunctionFlags(funcDecl.getFunctionFlags() | 128 /* Signature */ | 1024 /* ConstructMember */); + + funcDecl.setFlags(funcDecl.getFlags() | 8 /* TypeReference */); + funcDecl.hint = "_construct"; + funcDecl.classDecl = null; + + var result = new TypeScript.TypeReference(funcDecl, 0); + this.copySpan(funcDecl, result); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitFunctionType = function (node) { + var start = this.position; + var typeParameters = node.typeParameterList === null ? null : node.typeParameterList.accept(this); + var parameters = node.parameterList.accept(this); + this.movePast(node.equalsGreaterThanToken); + var returnType = node.type ? this.visitType(node.type) : null; + + var funcDecl = new TypeScript.FunctionDeclaration(null, null, false, typeParameters, parameters, returnType, this.hasDotDotDotParameter(node.parameterList.parameters)); + this.setSpan(funcDecl, start, node); + + funcDecl.setFlags(funcDecl.getFunctionFlags() | 128 /* Signature */); + funcDecl.setFlags(funcDecl.getFlags() | 8 /* TypeReference */); + + var result = new TypeScript.TypeReference(funcDecl, 0); + this.copySpan(funcDecl, result); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitObjectType = function (node) { + var start = this.position; + + this.movePast(node.openBraceToken); + var typeMembers = this.visitSeparatedSyntaxList(node.typeMembers); + this.movePast(node.closeBraceToken); + + var interfaceDecl = new TypeScript.InterfaceDeclaration(new TypeScript.Identifier("__anonymous", "__anonymous"), null, typeMembers, null, null, true); + this.setSpan(interfaceDecl, start, node); + + interfaceDecl.setFlags(interfaceDecl.getFlags() | 8 /* TypeReference */); + + var result = new TypeScript.TypeReference(interfaceDecl, 0); + this.copySpan(interfaceDecl, result); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitArrayType = function (node) { + var start = this.position; + + var result; + var underlying = this.visitType(node.type); + this.movePast(node.openBracketToken); + this.movePast(node.closeBracketToken); + + if (underlying.nodeType() === 11 /* TypeRef */) { + result = underlying; + result.arrayCount++; + } else { + result = new TypeScript.TypeReference(underlying, 1); + } + + result.setFlags(result.getFlags() | 8 /* TypeReference */); + + this.setSpan(result, start, node); + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitGenericType = function (node) { + var start = this.position; + + var underlying = this.visitType(node.name).term; + var typeArguments = node.typeArgumentList.accept(this); + + var genericType = new TypeScript.GenericType(underlying, typeArguments); + this.setSpan(genericType, start, node); + + genericType.setFlags(genericType.getFlags() | 8 /* TypeReference */); + + var result = new TypeScript.TypeReference(genericType, 0); + this.copySpan(genericType, result); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitTypeAnnotation = function (node) { + this.movePast(node.colonToken); + return this.visitType(node.type); + }; + + SyntaxTreeToAstVisitor.prototype.visitBlock = function (node) { + var start = this.position; + + this.movePast(node.openBraceToken); + var statements = this.visitSyntaxList(node.statements); + var closeBracePosition = this.position; + + var closeBraceLeadingComments = this.convertTokenLeadingComments(node.closeBraceToken, this.position); + this.movePast(node.closeBraceToken); + var closeBraceSpan = new TypeScript.ASTSpan(); + this.setSpan(closeBraceSpan, closeBracePosition, node.closeBraceToken); + + var result = new TypeScript.Block(statements, closeBraceSpan); + this.setSpan(result, start, node); + + result.closeBraceLeadingComments = closeBraceLeadingComments; + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitParameter = function (node) { + var start = this.position; + + this.moveTo(node, node.identifier); + var identifier = this.identifierFromToken(node.identifier, !!node.questionToken); + this.movePast(node.identifier); + this.movePast(node.questionToken); + var typeExpr = node.typeAnnotation ? node.typeAnnotation.accept(this) : null; + var init = node.equalsValueClause ? node.equalsValueClause.accept(this) : null; + + var result = new TypeScript.Parameter(identifier, typeExpr, init, !!node.questionToken); + this.setCommentsAndSpan(result, start, node); + + if (node.publicOrPrivateKeyword) { + if (node.publicOrPrivateKeyword.kind() === 57 /* PublicKeyword */) { + result.setVarFlags(result.getVarFlags() | 256 /* Property */ | 4 /* Public */); + } else { + result.setVarFlags(result.getVarFlags() | 256 /* Property */ | 2 /* Private */); + } + } + + if (node.equalsValueClause || node.dotDotDotToken) { + result.setFlags(result.getFlags() | 4 /* OptionalName */); + } + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitMemberAccessExpression = function (node) { + var start = this.position; + + var expression = node.expression.accept(this); + this.movePast(node.dotToken); + var name = this.identifierFromToken(node.name, false); + this.movePast(node.name); + + var result = new TypeScript.BinaryExpression(33 /* MemberAccessExpression */, expression, name); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitPostfixUnaryExpression = function (node) { + var start = this.position; + + var operand = node.operand.accept(this); + this.movePast(node.operatorToken); + + var result = new TypeScript.UnaryExpression(node.kind() === 209 /* PostIncrementExpression */ ? 77 /* PostIncrementExpression */ : 78 /* PostDecrementExpression */, operand, null); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitElementAccessExpression = function (node) { + var start = this.position; + + var expression = node.expression.accept(this); + this.movePast(node.openBracketToken); + var argumentExpression = node.argumentExpression.accept(this); + this.movePast(node.closeBracketToken); + + var result = new TypeScript.BinaryExpression(36 /* ElementAccessExpression */, expression, argumentExpression); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.convertArgumentListArguments = function (node) { + if (node === null) { + return null; + } + + var start = this.position; + + this.movePast(node.openParenToken); + + var result = this.visitSeparatedSyntaxList(node.arguments); + + if (node.arguments.fullWidth() === 0 && node.closeParenToken.fullWidth() === 0) { + var openParenTokenEnd = start + node.openParenToken.leadingTriviaWidth() + node.openParenToken.width(); + this.setSpanExplicit(result, openParenTokenEnd, openParenTokenEnd + node.openParenToken.trailingTriviaWidth()); + } + + var closeParenPos = this.position; + this.movePast(node.closeParenToken); + var closeParenSpan = new TypeScript.ASTSpan(); + this.setSpan(closeParenSpan, closeParenPos, node.closeParenToken); + + return { + argumentList: result, + closeParenSpan: closeParenSpan + }; + }; + + SyntaxTreeToAstVisitor.prototype.visitInvocationExpression = function (node) { + var start = this.position; + + var expression = node.expression.accept(this); + var typeArguments = node.argumentList.typeArgumentList !== null ? node.argumentList.typeArgumentList.accept(this) : null; + var argumentList = this.convertArgumentListArguments(node.argumentList); + + var result = new TypeScript.InvocationExpression(expression, typeArguments, argumentList ? argumentList.argumentList : null, argumentList ? argumentList.closeParenSpan : null); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitArgumentList = function (node) { + throw TypeScript.Errors.invalidOperation(); + }; + + SyntaxTreeToAstVisitor.prototype.getBinaryExpressionNodeType = function (node) { + switch (node.kind()) { + case 172 /* CommaExpression */: + return 26 /* CommaExpression */; + case 173 /* AssignmentExpression */: + return 39 /* AssignmentExpression */; + case 174 /* AddAssignmentExpression */: + return 40 /* AddAssignmentExpression */; + case 175 /* SubtractAssignmentExpression */: + return 41 /* SubtractAssignmentExpression */; + case 176 /* MultiplyAssignmentExpression */: + return 43 /* MultiplyAssignmentExpression */; + case 177 /* DivideAssignmentExpression */: + return 42 /* DivideAssignmentExpression */; + case 178 /* ModuloAssignmentExpression */: + return 44 /* ModuloAssignmentExpression */; + case 179 /* AndAssignmentExpression */: + return 45 /* AndAssignmentExpression */; + case 180 /* ExclusiveOrAssignmentExpression */: + return 46 /* ExclusiveOrAssignmentExpression */; + case 181 /* OrAssignmentExpression */: + return 47 /* OrAssignmentExpression */; + case 182 /* LeftShiftAssignmentExpression */: + return 48 /* LeftShiftAssignmentExpression */; + case 183 /* SignedRightShiftAssignmentExpression */: + return 49 /* SignedRightShiftAssignmentExpression */; + case 184 /* UnsignedRightShiftAssignmentExpression */: + return 50 /* UnsignedRightShiftAssignmentExpression */; + case 186 /* LogicalOrExpression */: + return 52 /* LogicalOrExpression */; + case 187 /* LogicalAndExpression */: + return 53 /* LogicalAndExpression */; + case 188 /* BitwiseOrExpression */: + return 54 /* BitwiseOrExpression */; + case 189 /* BitwiseExclusiveOrExpression */: + return 55 /* BitwiseExclusiveOrExpression */; + case 190 /* BitwiseAndExpression */: + return 56 /* BitwiseAndExpression */; + case 191 /* EqualsWithTypeConversionExpression */: + return 57 /* EqualsWithTypeConversionExpression */; + case 192 /* NotEqualsWithTypeConversionExpression */: + return 58 /* NotEqualsWithTypeConversionExpression */; + case 193 /* EqualsExpression */: + return 59 /* EqualsExpression */; + case 194 /* NotEqualsExpression */: + return 60 /* NotEqualsExpression */; + case 195 /* LessThanExpression */: + return 61 /* LessThanExpression */; + case 196 /* GreaterThanExpression */: + return 63 /* GreaterThanExpression */; + case 197 /* LessThanOrEqualExpression */: + return 62 /* LessThanOrEqualExpression */; + case 198 /* GreaterThanOrEqualExpression */: + return 64 /* GreaterThanOrEqualExpression */; + case 199 /* InstanceOfExpression */: + return 34 /* InstanceOfExpression */; + case 200 /* InExpression */: + return 32 /* InExpression */; + case 201 /* LeftShiftExpression */: + return 70 /* LeftShiftExpression */; + case 202 /* SignedRightShiftExpression */: + return 71 /* SignedRightShiftExpression */; + case 203 /* UnsignedRightShiftExpression */: + return 72 /* UnsignedRightShiftExpression */; + case 204 /* MultiplyExpression */: + return 67 /* MultiplyExpression */; + case 205 /* DivideExpression */: + return 68 /* DivideExpression */; + case 206 /* ModuloExpression */: + return 69 /* ModuloExpression */; + case 207 /* AddExpression */: + return 65 /* AddExpression */; + case 208 /* SubtractExpression */: + return 66 /* SubtractExpression */; + } + + throw TypeScript.Errors.invalidOperation(); + }; + + SyntaxTreeToAstVisitor.prototype.visitBinaryExpression = function (node) { + var start = this.position; + + var nodeType = this.getBinaryExpressionNodeType(node); + var left = node.left.accept(this); + this.movePast(node.operatorToken); + var right = node.right.accept(this); + + var result = new TypeScript.BinaryExpression(nodeType, left, right); + this.setSpan(result, start, node); + + if (right.nodeType() === 13 /* FunctionDeclaration */) { + var id = left.nodeType() === 33 /* MemberAccessExpression */ ? (left).operand2 : left; + var idHint = id.nodeType() === 21 /* Name */ ? id.actualText : null; + + var funcDecl = right; + funcDecl.hint = idHint; + } + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitConditionalExpression = function (node) { + var start = this.position; + + var condition = node.condition.accept(this); + this.movePast(node.questionToken); + var whenTrue = node.whenTrue.accept(this); + this.movePast(node.colonToken); + var whenFalse = node.whenFalse.accept(this); + + var result = new TypeScript.ConditionalExpression(condition, whenTrue, whenFalse); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitConstructSignature = function (node) { + var start = this.position; + + this.movePast(node.newKeyword); + var typeParameters = node.callSignature.typeParameterList === null ? null : node.callSignature.typeParameterList.accept(this); + var parameters = node.callSignature.parameterList.accept(this); + var returnType = node.callSignature.typeAnnotation ? node.callSignature.typeAnnotation.accept(this) : null; + + var result = new TypeScript.FunctionDeclaration(null, null, false, typeParameters, parameters, returnType, this.hasDotDotDotParameter(node.callSignature.parameterList.parameters)); + this.setCommentsAndSpan(result, start, node); + + result.hint = "_construct"; + result.setFunctionFlags(result.getFunctionFlags() | 1024 /* ConstructMember */ | 256 /* Method */ | 128 /* Signature */); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitMethodSignature = function (node) { + var start = this.position; + + var name = this.identifierFromToken(node.propertyName, !!node.questionToken); + this.movePast(node.propertyName); + this.movePast(node.questionToken); + + var typeParameters = node.callSignature.typeParameterList ? node.callSignature.typeParameterList.accept(this) : null; + var parameters = node.callSignature.parameterList.accept(this); + var returnType = node.callSignature.typeAnnotation ? node.callSignature.typeAnnotation.accept(this) : null; + + var result = new TypeScript.FunctionDeclaration(name, null, false, typeParameters, parameters, returnType, this.hasDotDotDotParameter(node.callSignature.parameterList.parameters)); + this.setCommentsAndSpan(result, start, node); + + result.setFunctionFlags(result.getFunctionFlags() | 256 /* Method */ | 128 /* Signature */); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitIndexSignature = function (node) { + var start = this.position; + + this.movePast(node.openBracketToken); + + var parameter = node.parameter.accept(this); + + this.movePast(node.closeBracketToken); + var returnType = node.typeAnnotation ? node.typeAnnotation.accept(this) : null; + + var name = new TypeScript.Identifier("__item", "__item"); + this.setSpanExplicit(name, start, start); + + var parameters = new TypeScript.ASTList([parameter]); + + var result = new TypeScript.FunctionDeclaration(name, null, false, null, parameters, returnType, false); + this.setCommentsAndSpan(result, start, node); + + result.setFunctionFlags(result.getFunctionFlags() | 4096 /* IndexerMember */ | 256 /* Method */ | 128 /* Signature */); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitPropertySignature = function (node) { + var start = this.position; + + var name = this.identifierFromToken(node.propertyName, !!node.questionToken); + this.movePast(node.propertyName); + this.movePast(node.questionToken); + var typeExpr = node.typeAnnotation ? node.typeAnnotation.accept(this) : null; + + var result = new TypeScript.VariableDeclarator(name, typeExpr, null); + this.setCommentsAndSpan(result, start, node); + + result.setVarFlags(result.getVarFlags() | 256 /* Property */); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitParameterList = function (node) { + var start = this.position; + + var openParenToken = node.openParenToken; + this.previousTokenTrailingComments = this.convertTokenTrailingComments(openParenToken, start + openParenToken.leadingTriviaWidth() + openParenToken.width()); + + this.movePast(node.openParenToken); + var result = this.visitSeparatedSyntaxList(node.parameters); + this.movePast(node.closeParenToken); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitCallSignature = function (node) { + var start = this.position; + + var typeParameters = node.typeParameterList === null ? null : node.typeParameterList.accept(this); + var parameters = node.parameterList.accept(this); + var returnType = node.typeAnnotation ? node.typeAnnotation.accept(this) : null; + + var result = new TypeScript.FunctionDeclaration(null, null, false, typeParameters, parameters, returnType, this.hasDotDotDotParameter(node.parameterList.parameters)); + this.setCommentsAndSpan(result, start, node); + + result.hint = "_call"; + result.setFunctionFlags(result.getFunctionFlags() | 512 /* CallMember */ | 256 /* Method */ | 128 /* Signature */); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitTypeParameterList = function (node) { + this.movePast(node.lessThanToken); + var result = this.visitSeparatedSyntaxList(node.typeParameters); + this.movePast(node.greaterThanToken); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitTypeParameter = function (node) { + var start = this.position; + + var identifier = this.identifierFromToken(node.identifier, false); + this.movePast(node.identifier); + var constraint = node.constraint ? node.constraint.accept(this) : null; + + var result = new TypeScript.TypeParameter(identifier, constraint); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitConstraint = function (node) { + this.movePast(node.extendsKeyword); + return this.visitType(node.type); + }; + + SyntaxTreeToAstVisitor.prototype.visitIfStatement = function (node) { + var start = this.position; + + this.moveTo(node, node.condition); + var condition = node.condition.accept(this); + this.movePast(node.closeParenToken); + var thenBod = node.statement.accept(this); + var elseBod = node.elseClause ? node.elseClause.accept(this) : null; + + var result = new TypeScript.IfStatement(condition, thenBod, elseBod); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitElseClause = function (node) { + this.movePast(node.elseKeyword); + return node.statement.accept(this); + }; + + SyntaxTreeToAstVisitor.prototype.visitExpressionStatement = function (node) { + var start = this.position; + + var expression = node.expression.accept(this); + this.movePast(node.semicolonToken); + + var result = new TypeScript.ExpressionStatement(expression); + this.setCommentsAndSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitConstructorDeclaration = function (node) { + var start = this.position; + + this.moveTo(node, node.parameterList); + var parameters = node.parameterList.accept(this); + + var block = node.block ? node.block.accept(this) : null; + + this.movePast(node.semicolonToken); + + var result = new TypeScript.FunctionDeclaration(null, block, true, null, parameters, null, this.hasDotDotDotParameter(node.parameterList.parameters)); + this.setCommentsAndSpan(result, start, node); + + if (node.semicolonToken) { + result.setFunctionFlags(result.getFunctionFlags() | 128 /* Signature */); + } + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitMemberFunctionDeclaration = function (node) { + var start = this.position; + + this.moveTo(node, node.propertyName); + var name = this.identifierFromToken(node.propertyName, false); + + this.movePast(node.propertyName); + + var typeParameters = node.callSignature.typeParameterList === null ? null : node.callSignature.typeParameterList.accept(this); + var parameters = node.callSignature.parameterList.accept(this); + var returnType = node.callSignature.typeAnnotation ? node.callSignature.typeAnnotation.accept(this) : null; + + var block = node.block ? node.block.accept(this) : null; + this.movePast(node.semicolonToken); + + var result = new TypeScript.FunctionDeclaration(name, block, false, typeParameters, parameters, returnType, this.hasDotDotDotParameter(node.callSignature.parameterList.parameters)); + this.setCommentsAndSpan(result, start, node); + + var flags = result.getFunctionFlags(); + if (node.semicolonToken) { + flags = flags | 128 /* Signature */; + } + + if (TypeScript.SyntaxUtilities.containsToken(node.modifiers, 55 /* PrivateKeyword */)) { + flags = flags | 2 /* Private */; + } else { + flags = flags | 4 /* Public */; + } + + if (TypeScript.SyntaxUtilities.containsToken(node.modifiers, 58 /* StaticKeyword */)) { + flags = flags | 16 /* Static */; + } + + flags = flags | 256 /* Method */; + result.setFunctionFlags(flags); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitMemberAccessorDeclaration = function (node, typeAnnotation) { + var start = this.position; + + this.moveTo(node, node.propertyName); + var name = this.identifierFromToken(node.propertyName, false); + this.movePast(node.propertyName); + var parameters = node.parameterList.accept(this); + var returnType = typeAnnotation ? typeAnnotation.accept(this) : null; + + var block = node.block ? node.block.accept(this) : null; + var result = new TypeScript.FunctionDeclaration(name, block, false, null, parameters, returnType, this.hasDotDotDotParameter(node.parameterList.parameters)); + this.setCommentsAndSpan(result, start, node); + + if (TypeScript.SyntaxUtilities.containsToken(node.modifiers, 55 /* PrivateKeyword */)) { + result.setFunctionFlags(result.getFunctionFlags() | 2 /* Private */); + } else { + result.setFunctionFlags(result.getFunctionFlags() | 4 /* Public */); + } + + if (TypeScript.SyntaxUtilities.containsToken(node.modifiers, 58 /* StaticKeyword */)) { + result.setFunctionFlags(result.getFunctionFlags() | 16 /* Static */); + } + + result.setFunctionFlags(result.getFunctionFlags() | 256 /* Method */); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitGetMemberAccessorDeclaration = function (node) { + var result = this.visitMemberAccessorDeclaration(node, node.typeAnnotation); + + result.setFunctionFlags(result.getFunctionFlags() | 32 /* GetAccessor */); + result.hint = "get" + result.name.actualText; + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitSetMemberAccessorDeclaration = function (node) { + var result = this.visitMemberAccessorDeclaration(node, null); + + result.setFunctionFlags(result.getFunctionFlags() | 64 /* SetAccessor */); + result.hint = "set" + result.name.actualText; + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitMemberVariableDeclaration = function (node) { + var start = this.position; + + this.moveTo(node, node.variableDeclarator); + this.moveTo(node.variableDeclarator, node.variableDeclarator.identifier); + + var name = this.identifierFromToken(node.variableDeclarator.identifier, false); + this.movePast(node.variableDeclarator.identifier); + var typeExpr = node.variableDeclarator.typeAnnotation ? node.variableDeclarator.typeAnnotation.accept(this) : null; + var init = node.variableDeclarator.equalsValueClause ? node.variableDeclarator.equalsValueClause.accept(this) : null; + this.movePast(node.semicolonToken); + + var result = new TypeScript.VariableDeclarator(name, typeExpr, init); + this.setCommentsAndSpan(result, start, node); + + if (TypeScript.SyntaxUtilities.containsToken(node.modifiers, 58 /* StaticKeyword */)) { + result.setVarFlags(result.getVarFlags() | 16 /* Static */); + } + + if (TypeScript.SyntaxUtilities.containsToken(node.modifiers, 55 /* PrivateKeyword */)) { + result.setVarFlags(result.getVarFlags() | 2 /* Private */); + } else { + result.setVarFlags(result.getVarFlags() | 4 /* Public */); + } + + result.setVarFlags(result.getVarFlags() | 2048 /* ClassProperty */); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitThrowStatement = function (node) { + var start = this.position; + + this.movePast(node.throwKeyword); + var expression = node.expression.accept(this); + this.movePast(node.semicolonToken); + + var result = new TypeScript.ThrowStatement(expression); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitReturnStatement = function (node) { + var start = this.position; + + this.movePast(node.returnKeyword); + var expression = node.expression ? node.expression.accept(this) : null; + this.movePast(node.semicolonToken); + + var result = new TypeScript.ReturnStatement(expression); + this.setCommentsAndSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitObjectCreationExpression = function (node) { + var start = this.position; + + this.movePast(node.newKeyword); + var expression = node.expression.accept(this); + var typeArgumentList = node.argumentList === null || node.argumentList.typeArgumentList === null ? null : node.argumentList.typeArgumentList.accept(this); + var argumentList = this.convertArgumentListArguments(node.argumentList); + + var result = new TypeScript.ObjectCreationExpression(expression, typeArgumentList, argumentList ? argumentList.argumentList : null, argumentList ? argumentList.closeParenSpan : null); + this.setSpan(result, start, node); + + if (expression.nodeType() === 11 /* TypeRef */) { + var typeRef = expression; + + if (typeRef.arrayCount === 0) { + var term = typeRef.term; + if (term.nodeType() === 33 /* MemberAccessExpression */ || term.nodeType() === 21 /* Name */) { + expression = term; + } + } + } + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitSwitchStatement = function (node) { + var start = this.position; + + this.movePast(node.switchKeyword); + this.movePast(node.openParenToken); + var expression = node.expression.accept(this); + this.movePast(node.closeParenToken); + var closeParenPosition = this.position; + this.movePast(node.openBraceToken); + + var array = new Array(node.switchClauses.childCount()); + var defaultCase = null; + + for (var i = 0, n = node.switchClauses.childCount(); i < n; i++) { + var switchClause = node.switchClauses.childAt(i); + var translated = switchClause.accept(this); + + if (switchClause.kind() === 232 /* DefaultSwitchClause */) { + defaultCase = translated; + } + + array[i] = translated; + } + + var span = new TypeScript.ASTSpan(); + span.minChar = start; + span.limChar = closeParenPosition; + + this.movePast(node.closeBraceToken); + + var result = new TypeScript.SwitchStatement(expression, new TypeScript.ASTList(array), defaultCase, span); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitCaseSwitchClause = function (node) { + var start = this.position; + + this.movePast(node.caseKeyword); + var expression = node.expression.accept(this); + this.movePast(node.colonToken); + var statements = this.visitSyntaxList(node.statements); + + var result = new TypeScript.CaseClause(expression, statements); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitDefaultSwitchClause = function (node) { + var start = this.position; + + this.movePast(node.defaultKeyword); + this.movePast(node.colonToken); + var statements = this.visitSyntaxList(node.statements); + + var result = new TypeScript.CaseClause(null, statements); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitBreakStatement = function (node) { + var start = this.position; + + this.movePast(node.breakKeyword); + this.movePast(node.identifier); + this.movePast(node.semicolonToken); + var identifier = node.identifier ? node.identifier.valueText() : null; + + var result = new TypeScript.Jump(83 /* BreakStatement */, identifier); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitContinueStatement = function (node) { + var start = this.position; + + this.movePast(node.continueKeyword); + this.movePast(node.identifier); + this.movePast(node.semicolonToken); + + var result = new TypeScript.Jump(84 /* ContinueStatement */, node.identifier ? node.identifier.valueText() : null); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitForStatement = function (node) { + var start = this.position; + + this.movePast(node.forKeyword); + this.movePast(node.openParenToken); + var init = node.variableDeclaration ? node.variableDeclaration.accept(this) : node.initializer ? node.initializer.accept(this) : null; + this.movePast(node.firstSemicolonToken); + var cond = node.condition ? node.condition.accept(this) : null; + this.movePast(node.secondSemicolonToken); + var incr = node.incrementor ? node.incrementor.accept(this) : null; + this.movePast(node.closeParenToken); + var body = node.statement.accept(this); + + var result = new TypeScript.ForStatement(init, cond, incr, body); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitForInStatement = function (node) { + var start = this.position; + + this.movePast(node.forKeyword); + this.movePast(node.openParenToken); + var init = node.variableDeclaration ? node.variableDeclaration.accept(this) : node.left.accept(this); + if (node.variableDeclaration) { + var variableDeclaration = init; + for (var i = 0, n = variableDeclaration.declarators.members.length; i < n; i++) { + var boundDecl = variableDeclaration.declarators.members[i]; + boundDecl.setVarFlags(boundDecl.getVarFlags() | 16384 /* ForInVariable */); + } + } + + this.movePast(node.inKeyword); + var expression = node.expression.accept(this); + this.movePast(node.closeParenToken); + var body = node.statement.accept(this); + + var result = new TypeScript.ForInStatement(init, expression, body); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitWhileStatement = function (node) { + var start = this.position; + + this.moveTo(node, node.condition); + var condition = node.condition.accept(this); + this.movePast(node.closeParenToken); + var statement = node.statement.accept(this); + + var result = new TypeScript.WhileStatement(condition, statement); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitWithStatement = function (node) { + var start = this.position; + + this.moveTo(node, node.condition); + var condition = node.condition.accept(this); + this.movePast(node.closeParenToken); + var statement = node.statement.accept(this); + + var result = new TypeScript.WithStatement(condition, statement); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitCastExpression = function (node) { + var start = this.position; + + this.movePast(node.lessThanToken); + var castTerm = this.visitType(node.type); + this.movePast(node.greaterThanToken); + var expression = node.expression.accept(this); + + var result = new TypeScript.UnaryExpression(79 /* CastExpression */, expression, castTerm); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitObjectLiteralExpression = function (node) { + var start = this.position; + + var openStart = this.position + node.openBraceToken.leadingTriviaWidth(); + this.movePast(node.openBraceToken); + + var propertyAssignments = this.visitSeparatedSyntaxList(node.propertyAssignments); + + var closeStart = this.position + node.closeBraceToken.leadingTriviaWidth(); + this.movePast(node.closeBraceToken); + + var result = new TypeScript.UnaryExpression(23 /* ObjectLiteralExpression */, propertyAssignments, null); + this.setCommentsAndSpan(result, start, node); + + if (this.isOnSingleLine(openStart, closeStart)) { + result.setFlags(result.getFlags() | 2 /* SingleLine */); + } + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitSimplePropertyAssignment = function (node) { + var start = this.position; + + var left = node.propertyName.accept(this); + + var afterColonComments = this.convertTokenTrailingComments(node.colonToken, this.position + node.colonToken.leadingTriviaWidth() + node.colonToken.width()); + + this.movePast(node.colonToken); + var right = node.expression.accept(this); + right.setPreComments(this.mergeComments(afterColonComments, right.preComments())); + + var result = new TypeScript.BinaryExpression(81 /* Member */, left, right); + this.setCommentsAndSpan(result, start, node); + + if (right.nodeType() === 13 /* FunctionDeclaration */) { + var funcDecl = right; + funcDecl.hint = left.text(); + } + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitFunctionPropertyAssignment = function (node) { + var start = this.position; + + var left = node.propertyName.accept(this); + var functionDeclaration = node.callSignature.accept(this); + var block = node.block.accept(this); + + functionDeclaration.hint = left.text(); + functionDeclaration.block = block; + functionDeclaration.setFunctionFlags(16384 /* IsFunctionProperty */); + + var result = new TypeScript.BinaryExpression(81 /* Member */, left, functionDeclaration); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitGetAccessorPropertyAssignment = function (node) { + var start = this.position; + + this.moveTo(node, node.propertyName); + var name = this.identifierFromToken(node.propertyName, false); + var functionName = this.identifierFromToken(node.propertyName, false); + this.movePast(node.propertyName); + this.movePast(node.openParenToken); + this.movePast(node.closeParenToken); + var returnType = node.typeAnnotation ? node.typeAnnotation.accept(this) : null; + + var block = node.block ? node.block.accept(this) : null; + + var funcDecl = new TypeScript.FunctionDeclaration(functionName, block, false, null, new TypeScript.ASTList([]), returnType, false); + this.setSpan(funcDecl, start, node); + + funcDecl.setFunctionFlags(funcDecl.getFunctionFlags() | 32 /* GetAccessor */ | 8192 /* IsFunctionExpression */); + funcDecl.hint = "get" + node.propertyName.valueText(); + + var result = new TypeScript.BinaryExpression(81 /* Member */, name, funcDecl); + this.copySpan(funcDecl, result); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitSetAccessorPropertyAssignment = function (node) { + var start = this.position; + + this.moveTo(node, node.propertyName); + var name = this.identifierFromToken(node.propertyName, false); + var functionName = this.identifierFromToken(node.propertyName, false); + this.movePast(node.propertyName); + this.movePast(node.openParenToken); + var parameter = node.parameter.accept(this); + this.movePast(node.closeParenToken); + + var parameters = new TypeScript.ASTList([parameter]); + + var block = node.block ? node.block.accept(this) : null; + + var funcDecl = new TypeScript.FunctionDeclaration(functionName, block, false, null, parameters, null, false); + this.setSpan(funcDecl, start, node); + + funcDecl.setFunctionFlags(funcDecl.getFunctionFlags() | 64 /* SetAccessor */ | 8192 /* IsFunctionExpression */); + funcDecl.hint = "set" + node.propertyName.valueText(); + + var result = new TypeScript.BinaryExpression(81 /* Member */, name, funcDecl); + this.copySpan(funcDecl, result); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitFunctionExpression = function (node) { + var start = this.position; + + this.movePast(node.functionKeyword); + var name = node.identifier === null ? null : this.identifierFromToken(node.identifier, false); + this.movePast(node.identifier); + var typeParameters = node.callSignature.typeParameterList === null ? null : node.callSignature.typeParameterList.accept(this); + var parameters = node.callSignature.parameterList.accept(this); + var returnType = node.callSignature.typeAnnotation ? node.callSignature.typeAnnotation.accept(this) : null; + + var block = node.block ? node.block.accept(this) : null; + + var result = new TypeScript.FunctionDeclaration(name, block, false, typeParameters, parameters, returnType, this.hasDotDotDotParameter(node.callSignature.parameterList.parameters)); + this.setCommentsAndSpan(result, start, node); + + result.setFunctionFlags(result.getFunctionFlags() | 8192 /* IsFunctionExpression */); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitEmptyStatement = function (node) { + var start = this.position; + + this.movePast(node.semicolonToken); + + var result = new TypeScript.EmptyStatement(); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitTryStatement = function (node) { + var start = this.position; + + this.movePast(node.tryKeyword); + var tryBody = node.block.accept(this); + + var catchClause = null; + if (node.catchClause !== null) { + catchClause = node.catchClause.accept(this); + } + + var finallyBody = null; + if (node.finallyClause !== null) { + finallyBody = node.finallyClause.accept(this); + } + + var result = new TypeScript.TryStatement(tryBody, catchClause, finallyBody); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitCatchClause = function (node) { + var start = this.position; + + this.movePast(node.catchKeyword); + this.movePast(node.openParenToken); + var identifier = this.identifierFromToken(node.identifier, false); + this.movePast(node.identifier); + var typeExpr = node.typeAnnotation ? node.typeAnnotation.accept(this) : null; + this.movePast(node.closeParenToken); + var block = node.block.accept(this); + + var varDecl = new TypeScript.VariableDeclarator(identifier, typeExpr, null); + this.setSpanExplicit(varDecl, identifier.minChar, identifier.limChar); + + var result = new TypeScript.CatchClause(varDecl, block); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitFinallyClause = function (node) { + this.movePast(node.finallyKeyword); + return node.block.accept(this); + }; + + SyntaxTreeToAstVisitor.prototype.visitLabeledStatement = function (node) { + var start = this.position; + + var identifier = this.identifierFromToken(node.identifier, false); + this.movePast(node.identifier); + this.movePast(node.colonToken); + var statement = node.statement.accept(this); + + var result = new TypeScript.LabeledStatement(identifier, statement); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitDoStatement = function (node) { + var start = this.position; + + this.movePast(node.doKeyword); + var statement = node.statement.accept(this); + var whileSpan = new TypeScript.ASTSpan(); + this.setSpan(whileSpan, this.position, node.whileKeyword); + + this.movePast(node.whileKeyword); + this.movePast(node.openParenToken); + var condition = node.condition.accept(this); + this.movePast(node.closeParenToken); + this.movePast(node.semicolonToken); + + var result = new TypeScript.DoStatement(statement, condition, whileSpan); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitTypeOfExpression = function (node) { + var start = this.position; + + this.movePast(node.typeOfKeyword); + var expression = node.expression.accept(this); + + var result = new TypeScript.UnaryExpression(35 /* TypeOfExpression */, expression, null); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitDeleteExpression = function (node) { + var start = this.position; + + this.movePast(node.deleteKeyword); + var expression = node.expression.accept(this); + + var result = new TypeScript.UnaryExpression(29 /* DeleteExpression */, expression, null); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitVoidExpression = function (node) { + var start = this.position; + + this.movePast(node.voidKeyword); + var expression = node.expression.accept(this); + + var result = new TypeScript.UnaryExpression(25 /* VoidExpression */, expression, null); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitDebuggerStatement = function (node) { + var start = this.position; + + this.movePast(node.debuggerKeyword); + this.movePast(node.semicolonToken); + + var result = new TypeScript.DebuggerStatement(); + this.setSpan(result, start, node); + + return result; + }; + SyntaxTreeToAstVisitor.protoString = "__proto__"; + SyntaxTreeToAstVisitor.protoSubstitutionString = "#__proto__"; + return SyntaxTreeToAstVisitor; + })(); + TypeScript.SyntaxTreeToAstVisitor = SyntaxTreeToAstVisitor; + + var SyntaxTreeToIncrementalAstVisitor = (function (_super) { + __extends(SyntaxTreeToIncrementalAstVisitor, _super); + function SyntaxTreeToIncrementalAstVisitor() { + _super.apply(this, arguments); + } + SyntaxTreeToIncrementalAstVisitor.prototype.applyDelta = function (ast, delta) { + if (delta === 0) { + return; + } + + var applyDelta = function (ast) { + if (ast.minChar !== -1) { + ast.minChar += delta; + } + if (ast.limChar !== -1) { + ast.limChar += delta; + } + }; + + var applyDeltaToComments = function (comments) { + if (comments && comments.length > 0) { + for (var i = 0; i < comments.length; i++) { + var comment = comments[i]; + applyDelta(comment); + } + } + }; + + var pre = function (cur, parent, walker) { + applyDelta(cur); + applyDeltaToComments(cur.preComments()); + applyDeltaToComments(cur.postComments()); + + return cur; + }; + + TypeScript.getAstWalkerFactory().walk(ast, pre); + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.setSpanExplicit = function (span, start, end) { + if (span.minChar !== -1) { + var delta = start - span.minChar; + this.applyDelta(span, delta); + + span.limChar = end; + } else { + _super.prototype.setSpanExplicit.call(this, span, start, end); + } + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.getAndMovePastAST = function (element) { + if (this.previousTokenTrailingComments !== null) { + return null; + } + + var result = (element)._ast; + if (!result) { + return null; + } + + var start = this.position; + this.movePast(element); + this.setSpan(result, start, element); + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.setAST = function (element, ast) { + (element)._ast = ast; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitSyntaxList = function (list) { + var result = this.getAndMovePastAST(list); + if (!result) { + result = _super.prototype.visitSyntaxList.call(this, list); + + if (list.childCount() > 0) { + this.setAST(list, result); + } + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitSeparatedSyntaxList = function (list) { + var result = this.getAndMovePastAST(list); + if (!result) { + result = _super.prototype.visitSeparatedSyntaxList.call(this, list); + + if (list.childCount() > 0) { + this.setAST(list, result); + } + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitToken = function (token) { + var result = this.getAndMovePastAST(token); + + if (!result) { + result = _super.prototype.visitToken.call(this, token); + this.setAST(token, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitClassDeclaration = function (node) { + var result = this.getAndMovePastAST(node); + if (result) { + this.completeClassDeclaration(node, result); + } else { + result = _super.prototype.visitClassDeclaration.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitInterfaceDeclaration = function (node) { + var result = this.getAndMovePastAST(node); + if (result) { + this.completeInterfaceDeclaration(node, result); + } else { + result = _super.prototype.visitInterfaceDeclaration.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitHeritageClause = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitHeritageClause.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitModuleDeclaration = function (node) { + var result = this.getAndMovePastAST(node); + if (result) { + this.completeModuleDeclaration(node, result); + } else { + result = _super.prototype.visitModuleDeclaration.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitFunctionDeclaration = function (node) { + var result = this.getAndMovePastAST(node); + if (result) { + this.completeFunctionDeclaration(node, result); + } else { + result = _super.prototype.visitFunctionDeclaration.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitImportDeclaration = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitImportDeclaration.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitExportAssignment = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitExportAssignment.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitPrefixUnaryExpression = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitPrefixUnaryExpression.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitArrayLiteralExpression = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitArrayLiteralExpression.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitOmittedExpression = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitOmittedExpression.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitParenthesizedExpression = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitParenthesizedExpression.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitSimpleArrowFunctionExpression = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitSimpleArrowFunctionExpression.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitParenthesizedArrowFunctionExpression = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitParenthesizedArrowFunctionExpression.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitQualifiedName = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + var result = _super.prototype.visitQualifiedName.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitConstructorType = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitConstructorType.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitFunctionType = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitFunctionType.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitObjectType = function (node) { + var start = this.position; + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitObjectType.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitArrayType = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitArrayType.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitGenericType = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitGenericType.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitBlock = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitBlock.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitParameter = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitParameter.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitMemberAccessExpression = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitMemberAccessExpression.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitPostfixUnaryExpression = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitPostfixUnaryExpression.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitElementAccessExpression = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitElementAccessExpression.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitInvocationExpression = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitInvocationExpression.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitBinaryExpression = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitBinaryExpression.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitConditionalExpression = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitConditionalExpression.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitConstructSignature = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitConstructSignature.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitMethodSignature = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitMethodSignature.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitIndexSignature = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitIndexSignature.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitPropertySignature = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitPropertySignature.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitCallSignature = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitCallSignature.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitTypeParameter = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitTypeParameter.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitIfStatement = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitIfStatement.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitExpressionStatement = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitExpressionStatement.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitConstructorDeclaration = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitConstructorDeclaration.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitMemberFunctionDeclaration = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitMemberFunctionDeclaration.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitMemberAccessorDeclaration = function (node, typeAnnotation) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitMemberAccessorDeclaration.call(this, node, typeAnnotation); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitMemberVariableDeclaration = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitMemberVariableDeclaration.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitThrowStatement = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitThrowStatement.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitReturnStatement = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitReturnStatement.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitObjectCreationExpression = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitObjectCreationExpression.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitSwitchStatement = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitSwitchStatement.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitCaseSwitchClause = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitCaseSwitchClause.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitDefaultSwitchClause = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitDefaultSwitchClause.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitBreakStatement = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitBreakStatement.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitContinueStatement = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitContinueStatement.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitForStatement = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitForStatement.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitForInStatement = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitForInStatement.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitWhileStatement = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitWhileStatement.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitWithStatement = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitWithStatement.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitCastExpression = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitCastExpression.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitObjectLiteralExpression = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitObjectLiteralExpression.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitSimplePropertyAssignment = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitSimplePropertyAssignment.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitFunctionPropertyAssignment = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitFunctionPropertyAssignment.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitGetAccessorPropertyAssignment = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitGetAccessorPropertyAssignment.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitSetAccessorPropertyAssignment = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitSetAccessorPropertyAssignment.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitFunctionExpression = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitFunctionExpression.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitEmptyStatement = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitEmptyStatement.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitTryStatement = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitTryStatement.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitCatchClause = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitCatchClause.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitLabeledStatement = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitLabeledStatement.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitDoStatement = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitDoStatement.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitTypeOfExpression = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitTypeOfExpression.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitDeleteExpression = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitDeleteExpression.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitVoidExpression = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitVoidExpression.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitDebuggerStatement = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitDebuggerStatement.call(this, node); + this.setAST(node, result); + } + + return result; + }; + return SyntaxTreeToIncrementalAstVisitor; + })(SyntaxTreeToAstVisitor); +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + TypeScript.fileResolutionTime = 0; + TypeScript.sourceCharactersCompiled = 0; + TypeScript.syntaxTreeParseTime = 0; + TypeScript.syntaxDiagnosticsTime = 0; + TypeScript.astTranslationTime = 0; + TypeScript.typeCheckTime = 0; + + TypeScript.emitTime = 0; + TypeScript.emitWriteFileTime = 0; + TypeScript.emitDirectoryExistsTime = 0; + TypeScript.emitFileExistsTime = 0; + TypeScript.emitResolvePathTime = 0; + + TypeScript.declarationEmitTime = 0; + TypeScript.declarationEmitIsExternallyVisibleTime = 0; + TypeScript.declarationEmitTypeSignatureTime = 0; + TypeScript.declarationEmitGetBoundDeclTypeTime = 0; + TypeScript.declarationEmitIsOverloadedCallSignatureTime = 0; + TypeScript.declarationEmitFunctionDeclarationGetSymbolTime = 0; + TypeScript.declarationEmitGetBaseTypeTime = 0; + TypeScript.declarationEmitGetAccessorFunctionTime = 0; + TypeScript.declarationEmitGetTypeParameterSymbolTime = 0; + TypeScript.declarationEmitGetImportDeclarationSymbolTime = 0; + + TypeScript.ioHostResolvePathTime = 0; + TypeScript.ioHostDirectoryNameTime = 0; + TypeScript.ioHostCreateDirectoryStructureTime = 0; + TypeScript.ioHostWriteFileTime = 0; + + var Document = (function () { + function Document(fileName, compilationSettings, scriptSnapshot, byteOrderMark, version, isOpen, syntaxTree) { + this.fileName = fileName; + this.compilationSettings = compilationSettings; + this.scriptSnapshot = scriptSnapshot; + this.byteOrderMark = byteOrderMark; + this.version = version; + this.isOpen = isOpen; + this._diagnostics = null; + this._syntaxTree = null; + this._bloomFilter = null; + if (isOpen) { + this._syntaxTree = syntaxTree; + } else { + var start = new Date().getTime(); + this._diagnostics = syntaxTree.diagnostics(); + TypeScript.syntaxDiagnosticsTime += new Date().getTime() - start; + } + + this.lineMap = syntaxTree.lineMap(); + + var start = new Date().getTime(); + this.script = TypeScript.SyntaxTreeToAstVisitor.visit(syntaxTree, fileName, compilationSettings, isOpen); + TypeScript.astTranslationTime += new Date().getTime() - start; + } + Document.prototype.diagnostics = function () { + if (this._diagnostics === null) { + this._diagnostics = this._syntaxTree.diagnostics(); + } + + return this._diagnostics; + }; + + Document.prototype.syntaxTree = function () { + if (this._syntaxTree) { + return this._syntaxTree; + } + + return TypeScript.Parser.parse(this.fileName, TypeScript.SimpleText.fromScriptSnapshot(this.scriptSnapshot), TypeScript.isDTSFile(this.fileName), TypeScript.getParseOptions(this.compilationSettings)); + }; + + Document.prototype.bloomFilter = function () { + if (!this._bloomFilter) { + var identifiers = new TypeScript.BlockIntrinsics(); + var pre = function (cur, parent, walker) { + if (TypeScript.isValidAstNode(cur)) { + if (cur.nodeType() === 21 /* Name */) { + var nodeText = (cur).text(); + + identifiers[nodeText] = true; + } + } + + return cur; + }; + + TypeScript.getAstWalkerFactory().walk(this.script, pre, null, null, identifiers); + + var identifierCount = 0; + for (var name in identifiers) { + if (identifiers[name]) { + identifierCount++; + } + } + + this._bloomFilter = new TypeScript.BloomFilter(identifierCount); + this._bloomFilter.addKeys(identifiers); + } + return this._bloomFilter; + }; + + Document.prototype.update = function (scriptSnapshot, version, isOpen, textChangeRange, settings) { + var oldScript = this.script; + var oldSyntaxTree = this._syntaxTree; + + var text = TypeScript.SimpleText.fromScriptSnapshot(scriptSnapshot); + + var newSyntaxTree = textChangeRange === null || oldSyntaxTree === null ? TypeScript.Parser.parse(this.fileName, text, TypeScript.isDTSFile(this.fileName), TypeScript.getParseOptions(this.compilationSettings)) : TypeScript.Parser.incrementalParse(oldSyntaxTree, textChangeRange, text); + + return new Document(this.fileName, this.compilationSettings, scriptSnapshot, this.byteOrderMark, version, isOpen, newSyntaxTree); + }; + + Document.create = function (fileName, scriptSnapshot, byteOrderMark, version, isOpen, referencedFiles, compilationSettings) { + var start = new Date().getTime(); + var syntaxTree = TypeScript.Parser.parse(fileName, TypeScript.SimpleText.fromScriptSnapshot(scriptSnapshot), TypeScript.isDTSFile(fileName), TypeScript.getParseOptions(compilationSettings)); + TypeScript.syntaxTreeParseTime += new Date().getTime() - start; + + var document = new Document(fileName, compilationSettings, scriptSnapshot, byteOrderMark, version, isOpen, syntaxTree); + document.script.referencedFiles = referencedFiles; + + return document; + }; + return Document; + })(); + TypeScript.Document = Document; + + TypeScript.globalSemanticInfoChain = null; + TypeScript.globalBinder = null; + TypeScript.globalLogger = null; + + TypeScript.useDirectTypeStorage = false; + + var TypeScriptCompiler = (function () { + function TypeScriptCompiler(logger, settings) { + if (typeof logger === "undefined") { logger = new TypeScript.NullLogger(); } + if (typeof settings === "undefined") { settings = new TypeScript.CompilationSettings(); } + this.logger = logger; + this.settings = settings; + this.resolver = null; + this.semanticInfoChain = null; + this.fileNameToDocument = new TypeScript.StringHashTable(); + this.emitOptions = new TypeScript.EmitOptions(this.settings); + TypeScript.globalLogger = logger; + } + TypeScriptCompiler.prototype.getDocument = function (fileName) { + return this.fileNameToDocument.lookup(TypeScript.switchToForwardSlashes(fileName)); + }; + + TypeScriptCompiler.prototype.timeFunction = function (funcDescription, func) { + return TypeScript.timeFunction(this.logger, funcDescription, func); + }; + + TypeScriptCompiler.prototype.addSourceUnit = function (fileName, scriptSnapshot, byteOrderMark, version, isOpen, referencedFiles) { + if (typeof referencedFiles === "undefined") { referencedFiles = []; } + fileName = TypeScript.switchToForwardSlashes(fileName); + + TypeScript.sourceCharactersCompiled += scriptSnapshot.getLength(); + + var document = Document.create(fileName, scriptSnapshot, byteOrderMark, version, isOpen, referencedFiles, this.emitOptions.compilationSettings); + this.fileNameToDocument.addOrUpdate(fileName, document); + + return document; + }; + + TypeScriptCompiler.prototype.updateSourceUnit = function (fileName, scriptSnapshot, version, isOpen, textChangeRange) { + var _this = this; + fileName = TypeScript.switchToForwardSlashes(fileName); + return this.timeFunction("pullUpdateUnit(" + fileName + ")", function () { + var document = _this.getDocument(fileName); + var updatedDocument = document.update(scriptSnapshot, version, isOpen, textChangeRange, _this.settings); + + _this.fileNameToDocument.addOrUpdate(fileName, updatedDocument); + + _this.pullUpdateScript(document, updatedDocument); + + return updatedDocument; + }); + }; + + TypeScriptCompiler.prototype.isDynamicModuleCompilation = function () { + var fileNames = this.fileNameToDocument.getAllKeys(); + for (var i = 0, n = fileNames.length; i < n; i++) { + var document = this.getDocument(fileNames[i]); + var script = document.script; + if (!script.isDeclareFile && script.topLevelMod !== null) { + return true; + } + } + return false; + }; + + TypeScriptCompiler.prototype.updateCommonDirectoryPath = function () { + var commonComponents = []; + var commonComponentsLength = -1; + + var fileNames = this.fileNameToDocument.getAllKeys(); + for (var i = 0, len = fileNames.length; i < len; i++) { + var fileName = fileNames[i]; + var document = this.getDocument(fileNames[i]); + var script = document.script; + + if (!script.isDeclareFile) { + var fileComponents = TypeScript.filePathComponents(fileName); + if (commonComponentsLength === -1) { + commonComponents = fileComponents; + commonComponentsLength = commonComponents.length; + } else { + var updatedPath = false; + for (var j = 0; j < commonComponentsLength && j < fileComponents.length; j++) { + if (commonComponents[j] !== fileComponents[j]) { + commonComponentsLength = j; + updatedPath = true; + + if (j === 0) { + if (this.emitOptions.compilationSettings.outDirOption || this.emitOptions.compilationSettings.sourceRoot) { + return new TypeScript.Diagnostic(null, 0, 0, TypeScript.DiagnosticCode.Cannot_find_the_common_subdirectory_path_for_the_input_files, null); + } else { + this.emitOptions.commonDirectoryPath = ""; + return null; + } + } + + break; + } + } + + if (!updatedPath && fileComponents.length < commonComponentsLength) { + commonComponentsLength = fileComponents.length; + } + } + } + } + + this.emitOptions.commonDirectoryPath = commonComponents.slice(0, commonComponentsLength).join("/") + "/"; + return null; + }; + + TypeScriptCompiler.prototype.convertToDirectoryPath = function (dirPath) { + if (dirPath && dirPath.charAt(dirPath.length - 1) !== "/") { + dirPath += "/"; + } + + return dirPath; + }; + + TypeScriptCompiler.prototype.setEmitOptions = function (ioHost) { + this.emitOptions.ioHost = ioHost; + + if (this.emitOptions.compilationSettings.moduleGenTarget === 0 /* Unspecified */ && this.isDynamicModuleCompilation()) { + return new TypeScript.Diagnostic(null, 0, 0, TypeScript.DiagnosticCode.Cannot_compile_external_modules_unless_the_module_flag_is_provided, null); + } + + if (!this.emitOptions.compilationSettings.mapSourceFiles) { + if (this.emitOptions.compilationSettings.mapRoot) { + if (this.emitOptions.compilationSettings.sourceRoot) { + return new TypeScript.Diagnostic(null, 0, 0, TypeScript.DiagnosticCode.Options_mapRoot_and_sourceRoot_cannot_be_specified_without_specifying_sourcemap_option, null); + } else { + return new TypeScript.Diagnostic(null, 0, 0, TypeScript.DiagnosticCode.Option_mapRoot_cannot_be_specified_without_specifying_sourcemap_option, null); + } + } else if (this.emitOptions.compilationSettings.sourceRoot) { + return new TypeScript.Diagnostic(null, 0, 0, TypeScript.DiagnosticCode.Option_sourceRoot_cannot_be_specified_without_specifying_sourcemap_option, null); + } + } + + this.emitOptions.compilationSettings.mapRoot = this.convertToDirectoryPath(TypeScript.switchToForwardSlashes(this.emitOptions.compilationSettings.mapRoot)); + this.emitOptions.compilationSettings.sourceRoot = this.convertToDirectoryPath(TypeScript.switchToForwardSlashes(this.emitOptions.compilationSettings.sourceRoot)); + + if (!this.emitOptions.compilationSettings.outFileOption && !this.emitOptions.compilationSettings.outDirOption && !this.emitOptions.compilationSettings.mapRoot && !this.emitOptions.compilationSettings.sourceRoot) { + this.emitOptions.outputMany = true; + this.emitOptions.commonDirectoryPath = ""; + return null; + } + + if (this.emitOptions.compilationSettings.outFileOption) { + this.emitOptions.compilationSettings.outFileOption = TypeScript.switchToForwardSlashes(this.emitOptions.ioHost.resolvePath(this.emitOptions.compilationSettings.outFileOption)); + this.emitOptions.outputMany = false; + } else { + this.emitOptions.outputMany = true; + } + + if (this.emitOptions.compilationSettings.outDirOption) { + this.emitOptions.compilationSettings.outDirOption = TypeScript.switchToForwardSlashes(this.emitOptions.ioHost.resolvePath(this.emitOptions.compilationSettings.outDirOption)); + this.emitOptions.compilationSettings.outDirOption = this.convertToDirectoryPath(this.emitOptions.compilationSettings.outDirOption); + } + + if (this.emitOptions.compilationSettings.outDirOption || this.emitOptions.compilationSettings.mapRoot || this.emitOptions.compilationSettings.sourceRoot) { + return this.updateCommonDirectoryPath(); + } + + return null; + }; + + TypeScriptCompiler.prototype.getScripts = function () { + var result = []; + var fileNames = this.fileNameToDocument.getAllKeys(); + + for (var i = 0, n = fileNames.length; i < n; i++) { + var document = this.getDocument(fileNames[i]); + result.push(document.script); + } + + return result; + }; + + TypeScriptCompiler.prototype.getDocuments = function () { + var result = []; + var fileNames = this.fileNameToDocument.getAllKeys(); + + for (var i = 0, n = fileNames.length; i < n; i++) { + var document = this.getDocument(fileNames[i]); + result.push(document); + } + + return result; + }; + + TypeScriptCompiler.prototype.writeByteOrderMarkForDocument = function (document) { + if (this.emitOptions.outputMany || document.script.topLevelMod) { + return document.byteOrderMark !== 0 /* None */; + } else { + var fileNames = this.fileNameToDocument.getAllKeys(); + + for (var i = 0, n = fileNames.length; i < n; i++) { + if (document.script.topLevelMod) { + continue; + } + var document = this.getDocument(fileNames[i]); + if (document.byteOrderMark !== 0 /* None */) { + return true; + } + } + + return false; + } + }; + + TypeScriptCompiler.mapToDTSFileName = function (fileName, wholeFileNameReplaced) { + return TypeScript.getDeclareFilePath(fileName); + }; + + TypeScriptCompiler.prototype.canEmitDeclarations = function (script) { + if (!this.settings.generateDeclarationFiles) { + return false; + } + + if (!!script && (script.isDeclareFile || script.moduleElements === null)) { + return false; + } + + return true; + }; + + TypeScriptCompiler.prototype.emitDeclarations = function (document, declarationEmitter) { + var script = document.script; + if (this.canEmitDeclarations(script)) { + if (declarationEmitter) { + declarationEmitter.document = document; + } else { + var declareFileName = this.emitOptions.mapOutputFileName(document, TypeScriptCompiler.mapToDTSFileName); + declarationEmitter = new TypeScript.DeclarationEmitter(declareFileName, document, this); + } + + declarationEmitter.emitDeclarations(script); + } + + return declarationEmitter; + }; + + TypeScriptCompiler.prototype.emitAllDeclarations = function () { + var start = new Date().getTime(); + + if (this.canEmitDeclarations()) { + var sharedEmitter = null; + var fileNames = this.fileNameToDocument.getAllKeys(); + + for (var i = 0, n = fileNames.length; i < n; i++) { + var fileName = fileNames[i]; + + try { + var document = this.getDocument(fileNames[i]); + + if (this.emitOptions.outputMany || document.script.topLevelMod) { + var singleEmitter = this.emitDeclarations(document); + if (singleEmitter) { + singleEmitter.close(); + } + } else { + sharedEmitter = this.emitDeclarations(document, sharedEmitter); + } + } catch (ex1) { + return TypeScript.Emitter.handleEmitterError(fileName, ex1); + } + } + + if (sharedEmitter) { + try { + sharedEmitter.close(); + } catch (ex2) { + return TypeScript.Emitter.handleEmitterError(sharedEmitter.document.fileName, ex2); + } + } + } + + TypeScript.declarationEmitTime += new Date().getTime() - start; + + return []; + }; + + TypeScriptCompiler.prototype.emitUnitDeclarations = function (fileName) { + if (this.canEmitDeclarations()) { + var document = this.getDocument(fileName); + + if (this.emitOptions.outputMany || document.script.topLevelMod) { + try { + var emitter = this.emitDeclarations(document); + if (emitter) { + emitter.close(); + } + } catch (ex1) { + return TypeScript.Emitter.handleEmitterError(fileName, ex1); + } + } else { + return this.emitAllDeclarations(); + } + } + + return []; + }; + + TypeScriptCompiler.mapToFileNameExtension = function (extension, fileName, wholeFileNameReplaced) { + if (wholeFileNameReplaced) { + return fileName; + } else { + var splitFname = fileName.split("."); + splitFname.pop(); + return splitFname.join(".") + extension; + } + }; + + TypeScriptCompiler.mapToJSFileName = function (fileName, wholeFileNameReplaced) { + return TypeScriptCompiler.mapToFileNameExtension(".js", fileName, wholeFileNameReplaced); + }; + + TypeScriptCompiler.prototype.emit = function (document, inputOutputMapper, emitter) { + var script = document.script; + if (!script.isDeclareFile) { + var typeScriptFileName = document.fileName; + if (!emitter) { + var javaScriptFileName = this.emitOptions.mapOutputFileName(document, TypeScriptCompiler.mapToJSFileName); + var outFile = this.createFile(javaScriptFileName, this.writeByteOrderMarkForDocument(document)); + + emitter = new TypeScript.Emitter(javaScriptFileName, outFile, this.emitOptions, this.semanticInfoChain); + + if (this.settings.mapSourceFiles) { + var sourceMapFile = this.createFile(javaScriptFileName + TypeScript.SourceMapper.MapFileExtension, false); + var sourceMapSourceInfo = this.emitOptions.decodeSourceMapOptions(document, javaScriptFileName); + emitter.setSourceMappings(new TypeScript.SourceMapper(outFile, sourceMapFile, sourceMapSourceInfo)); + } + + if (inputOutputMapper) { + inputOutputMapper(typeScriptFileName, javaScriptFileName); + } + } else if (this.settings.mapSourceFiles) { + var sourceMapSourceInfo = this.emitOptions.decodeSourceMapOptions(document, emitter.emittingFileName, emitter.sourceMapper.sourceMapSourceInfo); + emitter.setSourceMappings(new TypeScript.SourceMapper(emitter.outfile, emitter.sourceMapper.sourceMapOut, sourceMapSourceInfo)); + } + + emitter.setDocument(document); + emitter.emitJavascript(script, false); + } + + return emitter; + }; + + TypeScriptCompiler.prototype.emitAll = function (ioHost, inputOutputMapper) { + var start = new Date().getTime(); + + var optionsDiagnostic = this.setEmitOptions(ioHost); + if (optionsDiagnostic) { + return [optionsDiagnostic]; + } + + var fileNames = this.fileNameToDocument.getAllKeys(); + var sharedEmitter = null; + + for (var i = 0, n = fileNames.length; i < n; i++) { + var fileName = fileNames[i]; + + var document = this.getDocument(fileName); + + try { + if (this.emitOptions.outputMany || document.script.topLevelMod) { + var singleEmitter = this.emit(document, inputOutputMapper); + + if (singleEmitter) { + singleEmitter.emitSourceMapsAndClose(); + } + } else { + sharedEmitter = this.emit(document, inputOutputMapper, sharedEmitter); + } + } catch (ex1) { + return TypeScript.Emitter.handleEmitterError(fileName, ex1); + } + } + + if (sharedEmitter) { + try { + sharedEmitter.emitSourceMapsAndClose(); + } catch (ex2) { + return TypeScript.Emitter.handleEmitterError(sharedEmitter.document.fileName, ex2); + } + } + + TypeScript.emitTime += new Date().getTime() - start; + return []; + }; + + TypeScriptCompiler.prototype.emitUnit = function (fileName, ioHost, inputOutputMapper) { + var optionsDiagnostic = this.setEmitOptions(ioHost); + if (optionsDiagnostic) { + return [optionsDiagnostic]; + } + + var document = this.getDocument(fileName); + + if (this.emitOptions.outputMany || document.script.topLevelMod) { + try { + var emitter = this.emit(document, inputOutputMapper); + + if (emitter) { + emitter.emitSourceMapsAndClose(); + } + } catch (ex1) { + return TypeScript.Emitter.handleEmitterError(fileName, ex1); + } + + return []; + } else { + return this.emitAll(ioHost, inputOutputMapper); + } + }; + + TypeScriptCompiler.prototype.createFile = function (fileName, writeByteOrderMark) { + return new TypeScript.TextWriter(this.emitOptions.ioHost, fileName, writeByteOrderMark); + }; + + TypeScriptCompiler.prototype.pullResolveFile = function (fileName) { + var unit = this.semanticInfoChain.getUnit(fileName); + + if (!unit) { + return false; + } + + this.setUnit(fileName); + + this.resolver.resolveBoundDecls(unit.getTopLevelDecls()[0], new TypeScript.PullTypeResolutionContext()); + + return true; + }; + + TypeScriptCompiler.prototype.getSyntacticDiagnostics = function (fileName) { + return this.getDocument(fileName).diagnostics(); + }; + + TypeScriptCompiler.prototype.getSyntaxTree = function (fileName) { + return this.getDocument(fileName).syntaxTree(); + }; + TypeScriptCompiler.prototype.getScript = function (fileName) { + return this.getDocument(fileName).script; + }; + + TypeScriptCompiler.prototype.getSemanticDiagnostics = function (fileName) { + var errors = []; + var unit = this.semanticInfoChain.getUnit(fileName); + + TypeScript.globalSemanticInfoChain = this.semanticInfoChain; + if (TypeScript.globalBinder) { + TypeScript.globalBinder.semanticInfoChain = this.semanticInfoChain; + } + + if (unit) { + var document = this.getDocument(fileName); + var script = document.script; + + if (script) { + var startTime = (new Date()).getTime(); + TypeScript.PullTypeResolver.typeCheck(this.settings, this.semanticInfoChain, fileName, script); + var endTime = (new Date()).getTime(); + + TypeScript.typeCheckTime += endTime - startTime; + + unit.getDiagnostics(errors); + } + } + + return errors; + }; + + TypeScriptCompiler.prototype.resolveAllFiles = function () { + var fileNames = this.fileNameToDocument.getAllKeys(); + for (var i = 0, n = fileNames.length; i < n; i++) { + this.getSemanticDiagnostics(fileNames[i]); + } + }; + + TypeScriptCompiler.prototype.setUnit = function (unitPath) { + if (!this.resolver) { + this.resolver = new TypeScript.PullTypeResolver(this.settings, this.semanticInfoChain, unitPath); + } + + this.resolver.setUnitPath(unitPath); + }; + + TypeScriptCompiler.prototype.pullTypeCheck = function () { + var start = new Date().getTime(); + + this.semanticInfoChain = new TypeScript.SemanticInfoChain(); + TypeScript.globalSemanticInfoChain = this.semanticInfoChain; + + if (this.resolver) { + this.resolver.semanticInfoChain = this.semanticInfoChain; + } + + var declCollectionContext = null; + var i, n; + + var createDeclsStartTime = new Date().getTime(); + + var fileNames = this.fileNameToDocument.getAllKeys(); + var n = fileNames.length; + for (var i = 0; i < n; i++) { + var fileName = fileNames[i]; + var document = this.getDocument(fileName); + var semanticInfo = new TypeScript.SemanticInfo(fileName); + + declCollectionContext = new TypeScript.DeclCollectionContext(semanticInfo, fileName); + + TypeScript.getAstWalkerFactory().walk(document.script, TypeScript.preCollectDecls, TypeScript.postCollectDecls, null, declCollectionContext); + + semanticInfo.addTopLevelDecl(declCollectionContext.getParent()); + + this.semanticInfoChain.addUnit(semanticInfo); + } + + var createDeclsEndTime = new Date().getTime(); + + var bindStartTime = new Date().getTime(); + + var binder = new TypeScript.PullSymbolBinder(this.semanticInfoChain); + TypeScript.globalBinder = binder; + + for (var i = 1; i < this.semanticInfoChain.units.length; i++) { + binder.bindDeclsForUnit(this.semanticInfoChain.units[i].getPath()); + } + + var bindEndTime = new Date().getTime(); + + this.logger.log("Decl creation: " + (createDeclsEndTime - createDeclsStartTime)); + this.logger.log("Binding: " + (bindEndTime - bindStartTime)); + this.logger.log(" Time in findSymbol: " + TypeScript.time_in_findSymbol); + this.logger.log("Number of symbols created: " + TypeScript.pullSymbolID); + this.logger.log("Number of specialized types created: " + TypeScript.nSpecializationsCreated); + this.logger.log("Number of specialized signatures created: " + TypeScript.nSpecializedSignaturesCreated); + }; + + TypeScriptCompiler.prototype.pullUpdateScript = function (oldDocument, newDocument) { + var _this = this; + this.timeFunction("pullUpdateScript: ", function () { + var oldScript = oldDocument.script; + var newScript = newDocument.script; + + var newScriptSemanticInfo = new TypeScript.SemanticInfo(oldDocument.fileName); + var oldScriptSemanticInfo = _this.semanticInfoChain.getUnit(oldDocument.fileName); + + TypeScript.lastBoundPullDeclId = TypeScript.pullDeclID; + + var declCollectionContext = new TypeScript.DeclCollectionContext(newScriptSemanticInfo, oldDocument.fileName); + + TypeScript.getAstWalkerFactory().walk(newScript, TypeScript.preCollectDecls, TypeScript.postCollectDecls, null, declCollectionContext); + + var oldTopLevelDecl = oldScriptSemanticInfo.getTopLevelDecls()[0]; + var newTopLevelDecl = declCollectionContext.getParent(); + + newScriptSemanticInfo.addTopLevelDecl(newTopLevelDecl); + + if (_this.resolver) { + _this.resolver.cleanCachedGlobals(); + } + + _this.semanticInfoChain.updateUnit(oldScriptSemanticInfo, newScriptSemanticInfo); + + _this.logger.log("Cleaning symbols..."); + var cleanStart = new Date().getTime(); + _this.semanticInfoChain.update(); + var cleanEnd = new Date().getTime(); + _this.logger.log(" time to clean: " + (cleanEnd - cleanStart)); + + if (_this.resolver) { + _this.resolver.setUnitPath(oldDocument.fileName); + } + }); + }; + + TypeScriptCompiler.prototype.getSymbolOfDeclaration = function (decl) { + if (!decl) { + return null; + } + var ast = this.resolver.getASTForDecl(decl); + if (!ast) { + return null; + } + var enlosingDecl = this.resolver.getEnclosingDecl(decl); + if (ast.nodeType() === 81 /* Member */) { + return this.getSymbolOfDeclaration(enlosingDecl); + } + var resolutionContext = new TypeScript.PullTypeResolutionContext(); + return this.resolver.resolveAST(ast, false, enlosingDecl, resolutionContext); + }; + + TypeScriptCompiler.prototype.resolvePosition = function (pos, document) { + var declStack = []; + var resultASTs = []; + var script = document.script; + var scriptName = document.fileName; + + var semanticInfo = this.semanticInfoChain.getUnit(scriptName); + var lastDeclAST = null; + var foundAST = null; + var symbol = null; + var candidateSignature = null; + var callSignatures = null; + + var lambdaAST = null; + var declarationInitASTs = []; + var objectLitAST = null; + var asgAST = null; + var typeAssertionASTs = []; + var resolutionContext = new TypeScript.PullTypeResolutionContext(); + var inTypeReference = false; + var enclosingDecl = null; + var isConstructorCall = false; + + TypeScript.globalSemanticInfoChain = this.semanticInfoChain; + if (TypeScript.globalBinder) { + TypeScript.globalBinder.semanticInfoChain = this.semanticInfoChain; + } + + var pre = function (cur, parent) { + if (TypeScript.isValidAstNode(cur)) { + if (pos >= cur.minChar && pos <= cur.limChar) { + var previous = resultASTs[resultASTs.length - 1]; + + if (previous === undefined || (cur.minChar >= previous.minChar && cur.limChar <= previous.limChar)) { + var decl = semanticInfo.getDeclForAST(cur); + + if (decl) { + declStack[declStack.length] = decl; + lastDeclAST = cur; + } + + if (cur.nodeType() === 13 /* FunctionDeclaration */ && TypeScript.hasFlag((cur).getFunctionFlags(), 8192 /* IsFunctionExpression */)) { + lambdaAST = cur; + } else if (cur.nodeType() === 18 /* VariableDeclarator */) { + declarationInitASTs[declarationInitASTs.length] = cur; + } else if (cur.nodeType() === 23 /* ObjectLiteralExpression */) { + objectLitAST = cur; + } else if (cur.nodeType() === 79 /* CastExpression */) { + typeAssertionASTs[typeAssertionASTs.length] = cur; + } else if (cur.nodeType() === 39 /* AssignmentExpression */) { + asgAST = cur; + } else if (cur.nodeType() === 11 /* TypeRef */) { + inTypeReference = true; + } + + resultASTs[resultASTs.length] = cur; + } + } + } + return cur; + }; + + TypeScript.getAstWalkerFactory().walk(script, pre); + + if (resultASTs.length) { + this.setUnit(scriptName); + + foundAST = resultASTs[resultASTs.length - 1]; + + if (foundAST.nodeType() === 21 /* Name */ && resultASTs.length > 1) { + var previousAST = resultASTs[resultASTs.length - 2]; + switch (previousAST.nodeType()) { + case 15 /* InterfaceDeclaration */: + if (foundAST === (previousAST).name) { + foundAST = previousAST; + } + break; + case 14 /* ClassDeclaration */: + if (foundAST === (previousAST).name) { + foundAST = previousAST; + } + break; + case 16 /* ModuleDeclaration */: + if (foundAST === (previousAST).name) { + foundAST = previousAST; + } + break; + + case 18 /* VariableDeclarator */: + if (foundAST === (previousAST).id) { + foundAST = previousAST; + } + break; + + case 13 /* FunctionDeclaration */: + if (foundAST === (previousAST).name) { + foundAST = previousAST; + } + break; + } + } + + var funcDecl = null; + if (lastDeclAST === foundAST) { + symbol = declStack[declStack.length - 1].getSymbol(); + this.resolver.resolveDeclaredSymbol(symbol, null, resolutionContext); + symbol.setUnresolved(); + enclosingDecl = declStack[declStack.length - 1].getParentDecl(); + if (foundAST.nodeType() === 13 /* FunctionDeclaration */) { + funcDecl = foundAST; + } + } else { + for (var i = declStack.length - 1; i >= 0; i--) { + if (!(declStack[i].kind & (1024 /* Variable */ | 2048 /* Parameter */))) { + enclosingDecl = declStack[i]; + break; + } + } + + var callExpression = null; + if ((foundAST.nodeType() === 31 /* SuperExpression */ || foundAST.nodeType() === 30 /* ThisExpression */ || foundAST.nodeType() === 21 /* Name */) && resultASTs.length > 1) { + for (var i = resultASTs.length - 2; i >= 0; i--) { + if (resultASTs[i].nodeType() === 33 /* MemberAccessExpression */ && (resultASTs[i]).operand2 === resultASTs[i + 1]) { + foundAST = resultASTs[i]; + } else if ((resultASTs[i].nodeType() === 37 /* InvocationExpression */ || resultASTs[i].nodeType() === 38 /* ObjectCreationExpression */) && (resultASTs[i]).target === resultASTs[i + 1]) { + callExpression = resultASTs[i]; + break; + } else if (resultASTs[i].nodeType() === 13 /* FunctionDeclaration */ && (resultASTs[i]).name === resultASTs[i + 1]) { + funcDecl = resultASTs[i]; + break; + } else { + break; + } + } + } + + if (foundAST.nodeType() === 1 /* List */) { + for (var i = 0; i < (foundAST).members.length; i++) { + if ((foundAST).members[i].minChar > pos) { + foundAST = (foundAST).members[i]; + break; + } + } + } + + resolutionContext.resolvingTypeReference = inTypeReference; + + var inContextuallyTypedAssignment = false; + + if (declarationInitASTs.length) { + var assigningAST; + + for (var i = 0; i < declarationInitASTs.length; i++) { + assigningAST = declarationInitASTs[i]; + inContextuallyTypedAssignment = (assigningAST !== null) && (assigningAST.typeExpr !== null); + + this.resolver.resolveAST(assigningAST, false, null, resolutionContext); + var varSymbol = this.semanticInfoChain.getSymbolForAST(assigningAST, scriptName); + + if (varSymbol && inContextuallyTypedAssignment) { + var contextualType = varSymbol.type; + resolutionContext.pushContextualType(contextualType, false, null); + } + + if (assigningAST.init) { + this.resolver.resolveAST(assigningAST.init, inContextuallyTypedAssignment, enclosingDecl, resolutionContext); + } + } + } + + if (typeAssertionASTs.length) { + for (var i = 0; i < typeAssertionASTs.length; i++) { + this.resolver.resolveAST(typeAssertionASTs[i], inContextuallyTypedAssignment, enclosingDecl, resolutionContext); + } + } + + if (asgAST) { + this.resolver.resolveAST(asgAST, inContextuallyTypedAssignment, enclosingDecl, resolutionContext); + } + + if (objectLitAST) { + this.resolver.resolveAST(objectLitAST, inContextuallyTypedAssignment, enclosingDecl, resolutionContext); + } + + if (lambdaAST) { + this.resolver.resolveAST(lambdaAST, true, enclosingDecl, resolutionContext); + enclosingDecl = semanticInfo.getDeclForAST(lambdaAST); + } + + symbol = this.resolver.resolveAST(foundAST, inContextuallyTypedAssignment, enclosingDecl, resolutionContext); + if (callExpression) { + var isPropertyOrVar = symbol.kind === 4096 /* Property */ || symbol.kind === 1024 /* Variable */; + var typeSymbol = symbol.type; + if (isPropertyOrVar) { + isPropertyOrVar = (typeSymbol.kind !== 16 /* Interface */ && typeSymbol.kind !== 8388608 /* ObjectType */) || typeSymbol.name === ""; + } + + if (!isPropertyOrVar) { + isConstructorCall = foundAST.nodeType() === 31 /* SuperExpression */ || callExpression.nodeType() === 38 /* ObjectCreationExpression */; + + if (foundAST.nodeType() === 31 /* SuperExpression */) { + if (symbol.kind === 8 /* Class */) { + callSignatures = (symbol).getConstructorMethod().type.getConstructSignatures(); + } + } else { + callSignatures = callExpression.nodeType() === 37 /* InvocationExpression */ ? typeSymbol.getCallSignatures() : typeSymbol.getConstructSignatures(); + } + + var callResolutionResults = new TypeScript.PullAdditionalCallResolutionData(); + if (callExpression.nodeType() === 37 /* InvocationExpression */) { + this.resolver.resolveInvocationExpression(callExpression, inContextuallyTypedAssignment, enclosingDecl, resolutionContext, callResolutionResults); + } else { + this.resolver.resolveObjectCreationExpression(callExpression, inContextuallyTypedAssignment, enclosingDecl, resolutionContext, callResolutionResults); + } + + if (callResolutionResults.candidateSignature) { + candidateSignature = callResolutionResults.candidateSignature; + } + if (callResolutionResults.targetSymbol && callResolutionResults.targetSymbol.name !== "") { + symbol = callResolutionResults.targetSymbol; + } + foundAST = callExpression; + } + } + } + + if (funcDecl) { + if (symbol && symbol.kind !== 4096 /* Property */) { + var signatureInfo = TypeScript.PullHelpers.getSignatureForFuncDecl(funcDecl, this.semanticInfoChain.getUnit(scriptName)); + candidateSignature = signatureInfo.signature; + callSignatures = signatureInfo.allSignatures; + } + } else if (!callSignatures && symbol && (symbol.kind === 65536 /* Method */ || symbol.kind === 16384 /* Function */)) { + var typeSym = symbol.type; + if (typeSym) { + callSignatures = typeSym.getCallSignatures(); + } + } + } + + var enclosingScopeSymbol = this.getSymbolOfDeclaration(enclosingDecl); + + return { + symbol: symbol, + ast: foundAST, + enclosingScopeSymbol: enclosingScopeSymbol, + candidateSignature: candidateSignature, + callSignatures: callSignatures, + isConstructorCall: isConstructorCall + }; + }; + + TypeScriptCompiler.prototype.extractResolutionContextFromPath = function (path, document, propagateContextualTypes) { + var script = document.script; + var scriptName = document.fileName; + + var semanticInfo = this.semanticInfoChain.getUnit(scriptName); + var enclosingDecl = null; + var enclosingDeclAST = null; + var inContextuallyTypedAssignment = false; + + TypeScript.globalSemanticInfoChain = this.semanticInfoChain; + if (TypeScript.globalBinder) { + TypeScript.globalBinder.semanticInfoChain = this.semanticInfoChain; + } + + var resolutionContext = new TypeScript.PullTypeResolutionContext(); + resolutionContext.resolveAggressively = true; + + if (path.count() === 0) { + return null; + } + + this.setUnit(semanticInfo.getPath()); + + for (var i = 0, n = path.count(); i < n; i++) { + var current = path.asts[i]; + + switch (current.nodeType()) { + case 13 /* FunctionDeclaration */: + if (TypeScript.hasFlag((current).getFunctionFlags(), 8192 /* IsFunctionExpression */)) { + this.resolver.resolveAST((current), true, enclosingDecl, resolutionContext); + } + + break; + + case 18 /* VariableDeclarator */: + var assigningAST = current; + inContextuallyTypedAssignment = (assigningAST.typeExpr !== null); + + if (inContextuallyTypedAssignment) { + if (propagateContextualTypes) { + this.resolver.resolveAST(assigningAST, false, null, resolutionContext); + var varSymbol = this.semanticInfoChain.getSymbolForAST(assigningAST, scriptName); + + var contextualType = null; + if (varSymbol && inContextuallyTypedAssignment) { + contextualType = varSymbol.type; + } + + resolutionContext.pushContextualType(contextualType, false, null); + + if (assigningAST.init) { + this.resolver.resolveAST(assigningAST.init, inContextuallyTypedAssignment, enclosingDecl, resolutionContext); + } + } + } + + break; + + case 37 /* InvocationExpression */: + case 38 /* ObjectCreationExpression */: + if (propagateContextualTypes) { + var isNew = current.nodeType() === 38 /* ObjectCreationExpression */; + var callExpression = current; + var contextualType = null; + + if ((i + 1 < n) && callExpression.arguments === path.asts[i + 1]) { + var callResolutionResults = new TypeScript.PullAdditionalCallResolutionData(); + if (isNew) { + this.resolver.resolveObjectCreationExpression(callExpression, inContextuallyTypedAssignment, enclosingDecl, resolutionContext, callResolutionResults); + } else { + this.resolver.resolveInvocationExpression(callExpression, inContextuallyTypedAssignment, enclosingDecl, resolutionContext, callResolutionResults); + } + + if (callResolutionResults.actualParametersContextTypeSymbols) { + var argExpression = (path.asts[i + 1] && path.asts[i + 1].nodeType() === 1 /* List */) ? path.asts[i + 2] : path.asts[i + 1]; + if (argExpression) { + for (var j = 0, m = callExpression.arguments.members.length; j < m; j++) { + if (callExpression.arguments.members[j] === argExpression) { + var callContextualType = callResolutionResults.actualParametersContextTypeSymbols[j]; + if (callContextualType) { + contextualType = callContextualType; + break; + } + } + } + } + } + } else { + if (isNew) { + this.resolver.resolveObjectCreationExpression(callExpression, inContextuallyTypedAssignment, enclosingDecl, resolutionContext); + } else { + this.resolver.resolveInvocationExpression(callExpression, inContextuallyTypedAssignment, enclosingDecl, resolutionContext); + } + } + + resolutionContext.pushContextualType(contextualType, false, null); + } + + break; + + case 22 /* ArrayLiteralExpression */: + if (propagateContextualTypes) { + var contextualType = null; + var currentContextualType = resolutionContext.getContextualType(); + if (currentContextualType && currentContextualType.isArray()) { + contextualType = currentContextualType.getElementType(); + } + + resolutionContext.pushContextualType(contextualType, false, null); + } + + break; + + case 23 /* ObjectLiteralExpression */: + if (propagateContextualTypes) { + var objectLiteralExpression = current; + var objectLiteralResolutionContext = new TypeScript.PullAdditionalObjectLiteralResolutionData(); + this.resolver.resolveObjectLiteralExpression(objectLiteralExpression, inContextuallyTypedAssignment, enclosingDecl, resolutionContext, objectLiteralResolutionContext); + + var memeberAST = (path.asts[i + 1] && path.asts[i + 1].nodeType() === 1 /* List */) ? path.asts[i + 2] : path.asts[i + 1]; + if (memeberAST) { + var contextualType = null; + var memberDecls = objectLiteralExpression.operand; + if (memberDecls && objectLiteralResolutionContext.membersContextTypeSymbols) { + for (var j = 0, m = memberDecls.members.length; j < m; j++) { + if (memberDecls.members[j] === memeberAST) { + var memberContextualType = objectLiteralResolutionContext.membersContextTypeSymbols[j]; + if (memberContextualType) { + contextualType = memberContextualType; + break; + } + } + } + } + + resolutionContext.pushContextualType(contextualType, false, null); + } + } + + break; + + case 39 /* AssignmentExpression */: + if (propagateContextualTypes) { + var assignmentExpression = current; + var contextualType = null; + + if (path.asts[i + 1] && path.asts[i + 1] === assignmentExpression.operand2) { + var leftType = this.resolver.resolveAST(assignmentExpression.operand1, inContextuallyTypedAssignment, enclosingDecl, resolutionContext).type; + if (leftType) { + inContextuallyTypedAssignment = true; + contextualType = leftType; + } + } + + resolutionContext.pushContextualType(contextualType, false, null); + } + + break; + + case 79 /* CastExpression */: + var castExpression = current; + + if (i + 1 < n && path.asts[i + 1] === castExpression.castTerm) { + resolutionContext.resolvingTypeReference = true; + } else { + if (propagateContextualTypes) { + var contextualType = null; + var typeSymbol = this.resolver.resolveTypeAssertionExpression(castExpression, inContextuallyTypedAssignment, enclosingDecl, resolutionContext); + + if (typeSymbol) { + inContextuallyTypedAssignment = true; + contextualType = typeSymbol; + } + + resolutionContext.pushContextualType(contextualType, false, null); + } + } + + break; + + case 94 /* ReturnStatement */: + if (propagateContextualTypes) { + var returnStatement = current; + var contextualType = null; + + if (enclosingDecl && (enclosingDecl.kind & TypeScript.PullElementKind.SomeFunction)) { + var functionDeclaration = enclosingDeclAST; + if (functionDeclaration.returnTypeAnnotation) { + var currentResolvingTypeReference = resolutionContext.resolvingTypeReference; + resolutionContext.resolvingTypeReference = true; + var returnTypeSymbol = this.resolver.resolveTypeReference(functionDeclaration.returnTypeAnnotation, enclosingDecl, resolutionContext); + resolutionContext.resolvingTypeReference = currentResolvingTypeReference; + if (returnTypeSymbol) { + inContextuallyTypedAssignment = true; + contextualType = returnTypeSymbol; + } + } else { + var currentContextualType = resolutionContext.getContextualType(); + if (currentContextualType && currentContextualType.isFunction()) { + var currentContextualTypeSignatureSymbol = currentContextualType.getDeclarations()[0].getSignatureSymbol(); + var currentContextualTypeReturnTypeSymbol = currentContextualTypeSignatureSymbol.returnType; + if (currentContextualTypeReturnTypeSymbol) { + inContextuallyTypedAssignment = true; + contextualType = currentContextualTypeReturnTypeSymbol; + } + } + } + } + + resolutionContext.pushContextualType(contextualType, false, null); + } + + break; + + case 11 /* TypeRef */: + case 9 /* TypeParameter */: + resolutionContext.resolvingTypeReference = true; + break; + + case 14 /* ClassDeclaration */: + var classDeclaration = current; + if (path.asts[i + 1]) { + if (path.asts[i + 1] === classDeclaration.extendsList || path.asts[i + 1] === classDeclaration.implementsList) { + resolutionContext.resolvingTypeReference = true; + } + } + + break; + + case 15 /* InterfaceDeclaration */: + var interfaceDeclaration = current; + if (path.asts[i + 1]) { + if (path.asts[i + 1] === interfaceDeclaration.extendsList || path.asts[i + 1] === interfaceDeclaration.implementsList || path.asts[i + 1] === interfaceDeclaration.name) { + resolutionContext.resolvingTypeReference = true; + } + } + + break; + } + + var decl = semanticInfo.getDeclForAST(current); + if (decl && !(decl.kind & (1024 /* Variable */ | 2048 /* Parameter */ | 8192 /* TypeParameter */))) { + enclosingDecl = decl; + enclosingDeclAST = current; + } + } + + if (path.ast().nodeType() === 21 /* Name */ && path.count() > 1) { + for (var i = path.count() - 1; i >= 0; i--) { + if (path.asts[path.top - 1].nodeType() === 33 /* MemberAccessExpression */ && (path.asts[path.top - 1]).operand2 === path.asts[path.top]) { + path.pop(); + } else { + break; + } + } + } + + return { + ast: path.ast(), + enclosingDecl: enclosingDecl, + resolutionContext: resolutionContext, + inContextuallyTypedAssignment: inContextuallyTypedAssignment + }; + }; + + TypeScriptCompiler.prototype.pullGetSymbolInformationFromPath = function (path, document) { + var context = this.extractResolutionContextFromPath(path, document, true); + if (!context) { + return null; + } + + TypeScript.globalSemanticInfoChain = this.semanticInfoChain; + if (TypeScript.globalBinder) { + TypeScript.globalBinder.semanticInfoChain = this.semanticInfoChain; + } + + var symbol = this.resolver.resolveAST(path.ast(), context.inContextuallyTypedAssignment, context.enclosingDecl, context.resolutionContext); + + return { + symbol: symbol, + ast: path.ast(), + enclosingScopeSymbol: this.getSymbolOfDeclaration(context.enclosingDecl) + }; + }; + + TypeScriptCompiler.prototype.pullGetDeclarationSymbolInformation = function (path, document) { + var script = document.script; + var scriptName = document.fileName; + + var ast = path.ast(); + + if (ast.nodeType() !== 14 /* ClassDeclaration */ && ast.nodeType() !== 15 /* InterfaceDeclaration */ && ast.nodeType() !== 16 /* ModuleDeclaration */ && ast.nodeType() !== 13 /* FunctionDeclaration */ && ast.nodeType() !== 18 /* VariableDeclarator */) { + return null; + } + + var context = this.extractResolutionContextFromPath(path, document, true); + if (!context) { + return null; + } + + TypeScript.globalSemanticInfoChain = this.semanticInfoChain; + if (TypeScript.globalBinder) { + TypeScript.globalBinder.semanticInfoChain = this.semanticInfoChain; + } + + var semanticInfo = this.semanticInfoChain.getUnit(scriptName); + var decl = semanticInfo.getDeclForAST(ast); + var symbol = (decl.kind & TypeScript.PullElementKind.SomeSignature) ? decl.getSignatureSymbol() : decl.getSymbol(); + this.resolver.resolveDeclaredSymbol(symbol, null, context.resolutionContext); + + symbol.setUnresolved(); + + return { + symbol: symbol, + ast: path.ast(), + enclosingScopeSymbol: this.getSymbolOfDeclaration(context.enclosingDecl) + }; + }; + + TypeScriptCompiler.prototype.pullGetCallInformationFromPath = function (path, document) { + if (path.ast().nodeType() !== 37 /* InvocationExpression */ && path.ast().nodeType() !== 38 /* ObjectCreationExpression */) { + return null; + } + + var isNew = (path.ast().nodeType() === 38 /* ObjectCreationExpression */); + + var context = this.extractResolutionContextFromPath(path, document, true); + if (!context) { + return null; + } + + TypeScript.globalSemanticInfoChain = this.semanticInfoChain; + if (TypeScript.globalBinder) { + TypeScript.globalBinder.semanticInfoChain = this.semanticInfoChain; + } + + var callResolutionResults = new TypeScript.PullAdditionalCallResolutionData(); + + if (isNew) { + this.resolver.resolveObjectCreationExpression(path.ast(), context.inContextuallyTypedAssignment, context.enclosingDecl, context.resolutionContext, callResolutionResults); + } else { + this.resolver.resolveInvocationExpression(path.ast(), context.inContextuallyTypedAssignment, context.enclosingDecl, context.resolutionContext, callResolutionResults); + } + + return { + targetSymbol: callResolutionResults.targetSymbol, + resolvedSignatures: callResolutionResults.resolvedSignatures, + candidateSignature: callResolutionResults.candidateSignature, + ast: path.ast(), + enclosingScopeSymbol: this.getSymbolOfDeclaration(context.enclosingDecl), + isConstructorCall: isNew + }; + }; + + TypeScriptCompiler.prototype.pullGetVisibleMemberSymbolsFromPath = function (path, document) { + TypeScript.globalSemanticInfoChain = this.semanticInfoChain; + if (TypeScript.globalBinder) { + TypeScript.globalBinder.semanticInfoChain = this.semanticInfoChain; + } + + var context = this.extractResolutionContextFromPath(path, document, true); + if (!context) { + return null; + } + + var symbols = this.resolver.getVisibleMembersFromExpression(path.ast(), context.enclosingDecl, context.resolutionContext); + if (!symbols) { + return null; + } + + return { + symbols: symbols, + enclosingScopeSymbol: this.getSymbolOfDeclaration(context.enclosingDecl) + }; + }; + + TypeScriptCompiler.prototype.pullGetVisibleDeclsFromPath = function (path, document) { + TypeScript.globalSemanticInfoChain = this.semanticInfoChain; + if (TypeScript.globalBinder) { + TypeScript.globalBinder.semanticInfoChain = this.semanticInfoChain; + } + + var context = this.extractResolutionContextFromPath(path, document, false); + if (!context) { + return null; + } + + return this.resolver.getVisibleDecls(context.enclosingDecl, context.resolutionContext); + }; + + TypeScriptCompiler.prototype.pullGetContextualMembersFromPath = function (path, document) { + TypeScript.globalSemanticInfoChain = this.semanticInfoChain; + if (TypeScript.globalBinder) { + TypeScript.globalBinder.semanticInfoChain = this.semanticInfoChain; + } + + if (path.ast().nodeType() !== 23 /* ObjectLiteralExpression */) { + return null; + } + + var context = this.extractResolutionContextFromPath(path, document, true); + if (!context) { + return null; + } + + var members = this.resolver.getVisibleContextSymbols(context.enclosingDecl, context.resolutionContext); + + return { + symbols: members, + enclosingScopeSymbol: this.getSymbolOfDeclaration(context.enclosingDecl) + }; + }; + + TypeScriptCompiler.prototype.pullGetDeclInformation = function (decl, path, document) { + var context = this.extractResolutionContextFromPath(path, document, true); + if (!context) { + return null; + } + + TypeScript.globalSemanticInfoChain = this.semanticInfoChain; + if (TypeScript.globalBinder) { + TypeScript.globalBinder.semanticInfoChain = this.semanticInfoChain; + } + + var symbol = decl.getSymbol(); + this.resolver.resolveDeclaredSymbol(symbol, context.enclosingDecl, context.resolutionContext); + symbol.setUnresolved(); + + return { + symbol: symbol, + ast: path.ast(), + enclosingScopeSymbol: this.getSymbolOfDeclaration(context.enclosingDecl) + }; + }; + + TypeScriptCompiler.prototype.pullGetTypeInfoAtPosition = function (pos, document) { + var _this = this; + return this.timeFunction("pullGetTypeInfoAtPosition for pos " + pos + ":", function () { + return _this.resolvePosition(pos, document); + }); + }; + + TypeScriptCompiler.prototype.getTopLevelDeclarations = function (scriptName) { + var unit = this.semanticInfoChain.getUnit(scriptName); + + if (!unit) { + return null; + } + + return unit.getTopLevelDecls(); + }; + + TypeScriptCompiler.prototype.reportDiagnostics = function (errors, errorReporter) { + for (var i = 0; i < errors.length; i++) { + errorReporter.addDiagnostic(errors[i]); + } + }; + return TypeScriptCompiler; + })(); + TypeScript.TypeScriptCompiler = TypeScriptCompiler; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var ASTSpan = (function () { + function ASTSpan() { + this.minChar = -1; + this.limChar = -1; + this.trailingTriviaWidth = 0; + } + return ASTSpan; + })(); + TypeScript.ASTSpan = ASTSpan; + + var astID = 0; + + function structuralEqualsNotIncludingPosition(ast1, ast2) { + return structuralEquals(ast1, ast2, false); + } + TypeScript.structuralEqualsNotIncludingPosition = structuralEqualsNotIncludingPosition; + + function structuralEqualsIncludingPosition(ast1, ast2) { + return structuralEquals(ast1, ast2, true); + } + TypeScript.structuralEqualsIncludingPosition = structuralEqualsIncludingPosition; + + function structuralEquals(ast1, ast2, includingPosition) { + if (ast1 === ast2) { + return true; + } + + return ast1 !== null && ast2 !== null && ast1.nodeType() === ast2.nodeType() && ast1.structuralEquals(ast2, includingPosition); + } + + function astArrayStructuralEquals(array1, array2, includingPosition) { + return TypeScript.ArrayUtilities.sequenceEquals(array1, array2, includingPosition ? structuralEqualsIncludingPosition : structuralEqualsNotIncludingPosition); + } + + var AST = (function () { + function AST() { + this.minChar = -1; + this.limChar = -1; + this.trailingTriviaWidth = 0; + this._flags = 0 /* None */; + this.typeCheckPhase = -1; + this.astIDString = astID.toString(); + this.astID = astID++; + this.symbol = null; + this.aliasSymbol = null; + this.decl = null; + this._preComments = null; + this._postComments = null; + this._docComments = null; + } + AST.prototype.nodeType = function () { + throw TypeScript.Errors.abstract(); + }; + + AST.prototype.isStatement = function () { + return false; + }; + + AST.prototype.preComments = function () { + return this._preComments; + }; + + AST.prototype.postComments = function () { + return this._postComments; + }; + + AST.prototype.setPreComments = function (comments) { + if (comments && comments.length) { + this._preComments = comments; + } else if (this._preComments) { + this._preComments = null; + } + }; + + AST.prototype.setPostComments = function (comments) { + if (comments && comments.length) { + this._postComments = comments; + } else if (this._postComments) { + this._postComments = null; + } + }; + + AST.prototype.shouldEmit = function () { + return true; + }; + + AST.prototype.getFlags = function () { + return this._flags; + }; + + AST.prototype.setFlags = function (flags) { + this._flags = flags; + }; + + AST.prototype.getLength = function () { + return this.limChar - this.minChar; + }; + + AST.prototype.isDeclaration = function () { + return false; + }; + + AST.prototype.emit = function (emitter) { + emitter.emitComments(this, true); + emitter.recordSourceMappingStart(this); + this.emitWorker(emitter); + emitter.recordSourceMappingEnd(this); + emitter.emitComments(this, false); + }; + + AST.prototype.emitWorker = function (emitter) { + throw TypeScript.Errors.abstract(); + }; + + AST.prototype.docComments = function () { + if (!this.isDeclaration() || !this.preComments() || this.preComments().length === 0) { + return []; + } + + if (!this._docComments) { + var preComments = this.preComments(); + var preCommentsLength = preComments.length; + var docComments = new Array(); + for (var i = preCommentsLength - 1; i >= 0; i--) { + if (preComments[i].isDocComment()) { + docComments.push(preComments[i]); + continue; + } + break; + } + + this._docComments = docComments.reverse(); + } + + return this._docComments; + }; + + AST.prototype.structuralEquals = function (ast, includingPosition) { + if (includingPosition) { + if (this.minChar !== ast.minChar || this.limChar !== ast.limChar) { + return false; + } + } + + return this._flags === ast._flags && astArrayStructuralEquals(this.preComments(), ast.preComments(), includingPosition) && astArrayStructuralEquals(this.postComments(), ast.postComments(), includingPosition); + }; + return AST; + })(); + TypeScript.AST = AST; + + var ASTList = (function (_super) { + __extends(ASTList, _super); + function ASTList(members, separatorCount) { + _super.call(this); + this.members = members; + this.separatorCount = separatorCount; + } + ASTList.prototype.nodeType = function () { + return 1 /* List */; + }; + + ASTList.prototype.emit = function (emitter) { + emitter.recordSourceMappingStart(this); + emitter.emitModuleElements(this); + emitter.recordSourceMappingEnd(this); + }; + + ASTList.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && astArrayStructuralEquals(this.members, ast.members, includingPosition); + }; + return ASTList; + })(AST); + TypeScript.ASTList = ASTList; + + var Identifier = (function (_super) { + __extends(Identifier, _super); + function Identifier(actualText, text) { + _super.call(this); + this.actualText = actualText; + this._text = text; + } + Identifier.prototype.text = function () { + if (!this._text) { + this._text = TypeScript.Syntax.massageEscapes(this.actualText); + } + + return this._text; + }; + + Identifier.prototype.nodeType = function () { + return 21 /* Name */; + }; + + Identifier.prototype.isMissing = function () { + return false; + }; + + Identifier.prototype.emit = function (emitter) { + emitter.emitName(this, true); + }; + + Identifier.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && this.actualText === ast.actualText && this.isMissing() === ast.isMissing(); + }; + return Identifier; + })(AST); + TypeScript.Identifier = Identifier; + + var MissingIdentifier = (function (_super) { + __extends(MissingIdentifier, _super); + function MissingIdentifier() { + _super.call(this, "__missing", "__missing"); + } + MissingIdentifier.prototype.isMissing = function () { + return true; + }; + + MissingIdentifier.prototype.emit = function (emitter) { + }; + return MissingIdentifier; + })(Identifier); + TypeScript.MissingIdentifier = MissingIdentifier; + + var LiteralExpression = (function (_super) { + __extends(LiteralExpression, _super); + function LiteralExpression(_nodeType) { + _super.call(this); + this._nodeType = _nodeType; + } + LiteralExpression.prototype.nodeType = function () { + return this._nodeType; + }; + + LiteralExpression.prototype.emitWorker = function (emitter) { + switch (this.nodeType()) { + case 8 /* NullLiteral */: + emitter.writeToOutput("null"); + break; + case 4 /* FalseLiteral */: + emitter.writeToOutput("false"); + break; + case 3 /* TrueLiteral */: + emitter.writeToOutput("true"); + break; + default: + throw TypeScript.Errors.abstract(); + } + }; + + LiteralExpression.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition); + }; + return LiteralExpression; + })(AST); + TypeScript.LiteralExpression = LiteralExpression; + + var ThisExpression = (function (_super) { + __extends(ThisExpression, _super); + function ThisExpression() { + _super.apply(this, arguments); + } + ThisExpression.prototype.nodeType = function () { + return 30 /* ThisExpression */; + }; + + ThisExpression.prototype.emitWorker = function (emitter) { + if (emitter.thisFunctionDeclaration && (TypeScript.hasFlag(emitter.thisFunctionDeclaration.getFunctionFlags(), 2048 /* IsFatArrowFunction */))) { + emitter.writeToOutput("_this"); + } else { + emitter.writeToOutput("this"); + } + }; + + ThisExpression.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition); + }; + return ThisExpression; + })(AST); + TypeScript.ThisExpression = ThisExpression; + + var SuperExpression = (function (_super) { + __extends(SuperExpression, _super); + function SuperExpression() { + _super.apply(this, arguments); + } + SuperExpression.prototype.nodeType = function () { + return 31 /* SuperExpression */; + }; + + SuperExpression.prototype.emitWorker = function (emitter) { + emitter.emitSuperReference(); + }; + + SuperExpression.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition); + }; + return SuperExpression; + })(AST); + TypeScript.SuperExpression = SuperExpression; + + var ParenthesizedExpression = (function (_super) { + __extends(ParenthesizedExpression, _super); + function ParenthesizedExpression(expression) { + _super.call(this); + this.expression = expression; + } + ParenthesizedExpression.prototype.nodeType = function () { + return 80 /* ParenthesizedExpression */; + }; + + ParenthesizedExpression.prototype.emitWorker = function (emitter) { + emitter.writeToOutput("("); + this.expression.emit(emitter); + emitter.writeToOutput(")"); + }; + + ParenthesizedExpression.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.expression, ast.expression, includingPosition); + }; + return ParenthesizedExpression; + })(AST); + TypeScript.ParenthesizedExpression = ParenthesizedExpression; + + var UnaryExpression = (function (_super) { + __extends(UnaryExpression, _super); + function UnaryExpression(_nodeType, operand, castTerm) { + _super.call(this); + this._nodeType = _nodeType; + this.operand = operand; + this.castTerm = castTerm; + } + UnaryExpression.prototype.nodeType = function () { + return this._nodeType; + }; + + UnaryExpression.prototype.emitWorker = function (emitter) { + switch (this.nodeType()) { + case 77 /* PostIncrementExpression */: + this.operand.emit(emitter); + emitter.writeToOutput("++"); + break; + case 74 /* LogicalNotExpression */: + emitter.writeToOutput("!"); + this.operand.emit(emitter); + break; + case 78 /* PostDecrementExpression */: + this.operand.emit(emitter); + emitter.writeToOutput("--"); + break; + case 23 /* ObjectLiteralExpression */: + emitter.emitObjectLiteral(this); + break; + case 22 /* ArrayLiteralExpression */: + emitter.emitArrayLiteral(this); + break; + case 73 /* BitwiseNotExpression */: + emitter.writeToOutput("~"); + this.operand.emit(emitter); + break; + case 28 /* NegateExpression */: + emitter.writeToOutput("-"); + if (this.operand.nodeType() === 28 /* NegateExpression */ || this.operand.nodeType() === 76 /* PreDecrementExpression */) { + emitter.writeToOutput(" "); + } + this.operand.emit(emitter); + break; + case 27 /* PlusExpression */: + emitter.writeToOutput("+"); + if (this.operand.nodeType() === 27 /* PlusExpression */ || this.operand.nodeType() === 75 /* PreIncrementExpression */) { + emitter.writeToOutput(" "); + } + this.operand.emit(emitter); + break; + case 75 /* PreIncrementExpression */: + emitter.writeToOutput("++"); + this.operand.emit(emitter); + break; + case 76 /* PreDecrementExpression */: + emitter.writeToOutput("--"); + this.operand.emit(emitter); + break; + case 35 /* TypeOfExpression */: + emitter.writeToOutput("typeof "); + this.operand.emit(emitter); + break; + case 29 /* DeleteExpression */: + emitter.writeToOutput("delete "); + this.operand.emit(emitter); + break; + case 25 /* VoidExpression */: + emitter.writeToOutput("void "); + this.operand.emit(emitter); + break; + case 79 /* CastExpression */: + this.operand.emit(emitter); + break; + default: + throw TypeScript.Errors.abstract(); + } + }; + + UnaryExpression.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.castTerm, ast.castTerm, includingPosition) && structuralEquals(this.operand, ast.operand, includingPosition); + }; + return UnaryExpression; + })(AST); + TypeScript.UnaryExpression = UnaryExpression; + + var ObjectCreationExpression = (function (_super) { + __extends(ObjectCreationExpression, _super); + function ObjectCreationExpression(target, typeArguments, arguments, closeParenSpan) { + _super.call(this); + this.target = target; + this.typeArguments = typeArguments; + this.arguments = arguments; + this.closeParenSpan = closeParenSpan; + this.callResolutionData = null; + } + ObjectCreationExpression.prototype.nodeType = function () { + return 38 /* ObjectCreationExpression */; + }; + + ObjectCreationExpression.prototype.emitWorker = function (emitter) { + emitter.emitNew(this, this.target, this.arguments); + }; + + ObjectCreationExpression.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.target, ast.target, includingPosition) && structuralEquals(this.typeArguments, ast.typeArguments, includingPosition) && structuralEquals(this.arguments, ast.arguments, includingPosition); + }; + return ObjectCreationExpression; + })(AST); + TypeScript.ObjectCreationExpression = ObjectCreationExpression; + + var InvocationExpression = (function (_super) { + __extends(InvocationExpression, _super); + function InvocationExpression(target, typeArguments, arguments, closeParenSpan) { + _super.call(this); + this.target = target; + this.typeArguments = typeArguments; + this.arguments = arguments; + this.closeParenSpan = closeParenSpan; + this.callResolutionData = null; + } + InvocationExpression.prototype.nodeType = function () { + return 37 /* InvocationExpression */; + }; + + InvocationExpression.prototype.emitWorker = function (emitter) { + emitter.emitCall(this, this.target, this.arguments); + }; + + InvocationExpression.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.target, ast.target, includingPosition) && structuralEquals(this.typeArguments, ast.typeArguments, includingPosition) && structuralEquals(this.arguments, ast.arguments, includingPosition); + }; + return InvocationExpression; + })(AST); + TypeScript.InvocationExpression = InvocationExpression; + + var BinaryExpression = (function (_super) { + __extends(BinaryExpression, _super); + function BinaryExpression(_nodeType, operand1, operand2) { + _super.call(this); + this._nodeType = _nodeType; + this.operand1 = operand1; + this.operand2 = operand2; + } + BinaryExpression.prototype.nodeType = function () { + return this._nodeType; + }; + + BinaryExpression.getTextForBinaryToken = function (nodeType) { + switch (nodeType) { + case 26 /* CommaExpression */: + return ","; + case 39 /* AssignmentExpression */: + return "="; + case 40 /* AddAssignmentExpression */: + return "+="; + case 41 /* SubtractAssignmentExpression */: + return "-="; + case 43 /* MultiplyAssignmentExpression */: + return "*="; + case 42 /* DivideAssignmentExpression */: + return "/="; + case 44 /* ModuloAssignmentExpression */: + return "%="; + case 45 /* AndAssignmentExpression */: + return "&="; + case 46 /* ExclusiveOrAssignmentExpression */: + return "^="; + case 47 /* OrAssignmentExpression */: + return "|="; + case 48 /* LeftShiftAssignmentExpression */: + return "<<="; + case 49 /* SignedRightShiftAssignmentExpression */: + return ">>="; + case 50 /* UnsignedRightShiftAssignmentExpression */: + return ">>>="; + case 52 /* LogicalOrExpression */: + return "||"; + case 53 /* LogicalAndExpression */: + return "&&"; + case 54 /* BitwiseOrExpression */: + return "|"; + case 55 /* BitwiseExclusiveOrExpression */: + return "^"; + case 56 /* BitwiseAndExpression */: + return "&"; + case 57 /* EqualsWithTypeConversionExpression */: + return "=="; + case 58 /* NotEqualsWithTypeConversionExpression */: + return "!="; + case 59 /* EqualsExpression */: + return "==="; + case 60 /* NotEqualsExpression */: + return "!=="; + case 61 /* LessThanExpression */: + return "<"; + case 63 /* GreaterThanExpression */: + return ">"; + case 62 /* LessThanOrEqualExpression */: + return "<="; + case 64 /* GreaterThanOrEqualExpression */: + return ">="; + case 34 /* InstanceOfExpression */: + return "instanceof"; + case 32 /* InExpression */: + return "in"; + case 70 /* LeftShiftExpression */: + return "<<"; + case 71 /* SignedRightShiftExpression */: + return ">>"; + case 72 /* UnsignedRightShiftExpression */: + return ">>>"; + case 67 /* MultiplyExpression */: + return "*"; + case 68 /* DivideExpression */: + return "/"; + case 69 /* ModuloExpression */: + return "%"; + case 65 /* AddExpression */: + return "+"; + case 66 /* SubtractExpression */: + return "-"; + } + + throw TypeScript.Errors.invalidOperation(); + }; + + BinaryExpression.prototype.emitWorker = function (emitter) { + switch (this.nodeType()) { + case 33 /* MemberAccessExpression */: + if (!emitter.tryEmitConstant(this)) { + this.operand1.emit(emitter); + emitter.writeToOutput("."); + emitter.emitName(this.operand2, false); + } + break; + case 36 /* ElementAccessExpression */: + emitter.emitIndex(this.operand1, this.operand2); + break; + + case 81 /* Member */: + if (this.operand2.nodeType() === 13 /* FunctionDeclaration */ && (this.operand2).isAccessor()) { + var funcDecl = this.operand2; + if (TypeScript.hasFlag(funcDecl.getFunctionFlags(), 32 /* GetAccessor */)) { + emitter.writeToOutput("get "); + } else { + emitter.writeToOutput("set "); + } + this.operand1.emit(emitter); + } else { + this.operand1.emit(emitter); + emitter.writeToOutputTrimmable(": "); + } + this.operand2.emit(emitter); + break; + case 26 /* CommaExpression */: + this.operand1.emit(emitter); + emitter.writeToOutput(", "); + this.operand2.emit(emitter); + break; + default: { + this.operand1.emit(emitter); + var binOp = BinaryExpression.getTextForBinaryToken(this.nodeType()); + if (binOp === "instanceof") { + emitter.writeToOutput(" instanceof "); + } else if (binOp === "in") { + emitter.writeToOutput(" in "); + } else { + emitter.writeToOutputTrimmable(" " + binOp + " "); + } + this.operand2.emit(emitter); + } + } + }; + + BinaryExpression.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.operand1, ast.operand1, includingPosition) && structuralEquals(this.operand2, ast.operand2, includingPosition); + }; + return BinaryExpression; + })(AST); + TypeScript.BinaryExpression = BinaryExpression; + + var ConditionalExpression = (function (_super) { + __extends(ConditionalExpression, _super); + function ConditionalExpression(operand1, operand2, operand3) { + _super.call(this); + this.operand1 = operand1; + this.operand2 = operand2; + this.operand3 = operand3; + } + ConditionalExpression.prototype.nodeType = function () { + return 51 /* ConditionalExpression */; + }; + + ConditionalExpression.prototype.emitWorker = function (emitter) { + this.operand1.emit(emitter); + emitter.writeToOutput(" ? "); + this.operand2.emit(emitter); + emitter.writeToOutput(" : "); + this.operand3.emit(emitter); + }; + + ConditionalExpression.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.operand1, ast.operand1, includingPosition) && structuralEquals(this.operand2, ast.operand2, includingPosition) && structuralEquals(this.operand3, ast.operand3, includingPosition); + }; + return ConditionalExpression; + })(AST); + TypeScript.ConditionalExpression = ConditionalExpression; + + var NumberLiteral = (function (_super) { + __extends(NumberLiteral, _super); + function NumberLiteral(value, text) { + _super.call(this); + this.value = value; + this._text = text; + } + NumberLiteral.prototype.text = function () { + return this._text; + }; + + NumberLiteral.prototype.nodeType = function () { + return 7 /* NumericLiteral */; + }; + + NumberLiteral.prototype.emitWorker = function (emitter) { + emitter.writeToOutput(this._text); + }; + + NumberLiteral.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && this.value === ast.value && this._text === ast._text; + }; + return NumberLiteral; + })(AST); + TypeScript.NumberLiteral = NumberLiteral; + + var RegexLiteral = (function (_super) { + __extends(RegexLiteral, _super); + function RegexLiteral(text) { + _super.call(this); + this.text = text; + } + RegexLiteral.prototype.nodeType = function () { + return 6 /* RegularExpressionLiteral */; + }; + + RegexLiteral.prototype.emitWorker = function (emitter) { + emitter.writeToOutput(this.text); + }; + + RegexLiteral.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && this.text === ast.text; + }; + return RegexLiteral; + })(AST); + TypeScript.RegexLiteral = RegexLiteral; + + var StringLiteral = (function (_super) { + __extends(StringLiteral, _super); + function StringLiteral(actualText, text) { + _super.call(this); + this.actualText = actualText; + this._text = text; + } + StringLiteral.prototype.text = function () { + return this._text; + }; + + StringLiteral.prototype.nodeType = function () { + return 5 /* StringLiteral */; + }; + + StringLiteral.prototype.emitWorker = function (emitter) { + emitter.writeToOutput(this.actualText); + }; + + StringLiteral.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && this.actualText === ast.actualText; + }; + return StringLiteral; + })(AST); + TypeScript.StringLiteral = StringLiteral; + + var ImportDeclaration = (function (_super) { + __extends(ImportDeclaration, _super); + function ImportDeclaration(id, alias) { + _super.call(this); + this.id = id; + this.alias = alias; + this._varFlags = 0 /* None */; + } + ImportDeclaration.prototype.nodeType = function () { + return 17 /* ImportDeclaration */; + }; + + ImportDeclaration.prototype.isDeclaration = function () { + return true; + }; + + ImportDeclaration.prototype.getVarFlags = function () { + return this._varFlags; + }; + + ImportDeclaration.prototype.setVarFlags = function (flags) { + this._varFlags = flags; + }; + + ImportDeclaration.prototype.isExternalImportDeclaration = function () { + if (this.alias.nodeType() == 21 /* Name */) { + var text = (this.alias).actualText; + return TypeScript.isQuoted(text); + } + + return false; + }; + + ImportDeclaration.prototype.emit = function (emitter) { + emitter.emitImportDeclaration(this); + }; + + ImportDeclaration.prototype.getAliasName = function (aliasAST) { + if (typeof aliasAST === "undefined") { aliasAST = this.alias; } + if (aliasAST.nodeType() == 11 /* TypeRef */) { + aliasAST = (aliasAST).term; + } + + if (aliasAST.nodeType() === 21 /* Name */) { + return (aliasAST).actualText; + } else { + var dotExpr = aliasAST; + return this.getAliasName(dotExpr.operand1) + "." + this.getAliasName(dotExpr.operand2); + } + }; + + ImportDeclaration.prototype.firstAliasedModToString = function () { + if (this.alias.nodeType() === 21 /* Name */) { + return (this.alias).actualText; + } else { + var dotExpr = this.alias; + var firstMod = (dotExpr.term).operand1; + return firstMod.actualText; + } + }; + + ImportDeclaration.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && this._varFlags === ast._varFlags && structuralEquals(this.id, ast.id, includingPosition) && structuralEquals(this.alias, ast.alias, includingPosition); + }; + return ImportDeclaration; + })(AST); + TypeScript.ImportDeclaration = ImportDeclaration; + + var ExportAssignment = (function (_super) { + __extends(ExportAssignment, _super); + function ExportAssignment(id) { + _super.call(this); + this.id = id; + } + ExportAssignment.prototype.nodeType = function () { + return 88 /* ExportAssignment */; + }; + + ExportAssignment.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.id, ast.id, includingPosition); + }; + + ExportAssignment.prototype.emit = function (emitter) { + emitter.setExportAssignmentIdentifier(this.id.actualText); + }; + return ExportAssignment; + })(AST); + TypeScript.ExportAssignment = ExportAssignment; + + var BoundDecl = (function (_super) { + __extends(BoundDecl, _super); + function BoundDecl(id, typeExpr, init) { + _super.call(this); + this.id = id; + this.typeExpr = typeExpr; + this.init = init; + this.constantValue = null; + this._varFlags = 0 /* None */; + } + BoundDecl.prototype.isDeclaration = function () { + return true; + }; + + BoundDecl.prototype.getVarFlags = function () { + return this._varFlags; + }; + + BoundDecl.prototype.setVarFlags = function (flags) { + this._varFlags = flags; + }; + + BoundDecl.prototype.isProperty = function () { + return TypeScript.hasFlag(this.getVarFlags(), 256 /* Property */); + }; + + BoundDecl.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && this._varFlags === ast._varFlags && structuralEquals(this.init, ast.init, includingPosition) && structuralEquals(this.typeExpr, ast.typeExpr, includingPosition) && structuralEquals(this.id, ast.id, includingPosition); + }; + return BoundDecl; + })(AST); + TypeScript.BoundDecl = BoundDecl; + + var VariableDeclarator = (function (_super) { + __extends(VariableDeclarator, _super); + function VariableDeclarator(id, typeExpr, init) { + _super.call(this, id, typeExpr, init); + } + VariableDeclarator.prototype.nodeType = function () { + return 18 /* VariableDeclarator */; + }; + + VariableDeclarator.prototype.isStatic = function () { + return TypeScript.hasFlag(this.getVarFlags(), 16 /* Static */); + }; + + VariableDeclarator.prototype.emit = function (emitter) { + emitter.emitVariableDeclarator(this); + }; + return VariableDeclarator; + })(BoundDecl); + TypeScript.VariableDeclarator = VariableDeclarator; + + var Parameter = (function (_super) { + __extends(Parameter, _super); + function Parameter(id, typeExpr, init, isOptional) { + _super.call(this, id, typeExpr, init); + this.isOptional = isOptional; + } + Parameter.prototype.nodeType = function () { + return 20 /* Parameter */; + }; + + Parameter.prototype.isOptionalArg = function () { + return this.isOptional || this.init; + }; + + Parameter.prototype.emitWorker = function (emitter) { + emitter.writeToOutput(this.id.actualText); + }; + + Parameter.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && this.isOptional === ast.isOptional; + }; + return Parameter; + })(BoundDecl); + TypeScript.Parameter = Parameter; + + var FunctionDeclaration = (function (_super) { + __extends(FunctionDeclaration, _super); + function FunctionDeclaration(name, block, isConstructor, typeArguments, arguments, returnTypeAnnotation, variableArgList) { + _super.call(this); + this.name = name; + this.block = block; + this.isConstructor = isConstructor; + this.typeArguments = typeArguments; + this.arguments = arguments; + this.returnTypeAnnotation = returnTypeAnnotation; + this.variableArgList = variableArgList; + this.hint = null; + this._functionFlags = 0 /* None */; + this.classDecl = null; + } + FunctionDeclaration.prototype.isDeclaration = function () { + return true; + }; + + FunctionDeclaration.prototype.nodeType = function () { + return 13 /* FunctionDeclaration */; + }; + + FunctionDeclaration.prototype.getFunctionFlags = function () { + return this._functionFlags; + }; + + FunctionDeclaration.prototype.setFunctionFlags = function (flags) { + this._functionFlags = flags; + }; + + FunctionDeclaration.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && this._functionFlags === ast._functionFlags && this.hint === ast.hint && this.variableArgList === ast.variableArgList && structuralEquals(this.name, ast.name, includingPosition) && structuralEquals(this.block, ast.block, includingPosition) && this.isConstructor === ast.isConstructor && structuralEquals(this.typeArguments, ast.typeArguments, includingPosition) && structuralEquals(this.arguments, ast.arguments, includingPosition); + }; + + FunctionDeclaration.prototype.shouldEmit = function () { + return !TypeScript.hasFlag(this.getFunctionFlags(), 128 /* Signature */) && !TypeScript.hasFlag(this.getFunctionFlags(), 8 /* Ambient */); + }; + + FunctionDeclaration.prototype.emit = function (emitter) { + emitter.emitFunction(this); + }; + + FunctionDeclaration.prototype.getNameText = function () { + if (this.name) { + return this.name.actualText; + } else { + return this.hint; + } + }; + + FunctionDeclaration.prototype.isMethod = function () { + return (this.getFunctionFlags() & 256 /* Method */) !== 0 /* None */; + }; + + FunctionDeclaration.prototype.isCallMember = function () { + return TypeScript.hasFlag(this.getFunctionFlags(), 512 /* CallMember */); + }; + FunctionDeclaration.prototype.isConstructMember = function () { + return TypeScript.hasFlag(this.getFunctionFlags(), 1024 /* ConstructMember */); + }; + FunctionDeclaration.prototype.isIndexerMember = function () { + return TypeScript.hasFlag(this.getFunctionFlags(), 4096 /* IndexerMember */); + }; + FunctionDeclaration.prototype.isSpecialFn = function () { + return this.isCallMember() || this.isIndexerMember() || this.isConstructMember(); + }; + FunctionDeclaration.prototype.isAccessor = function () { + return TypeScript.hasFlag(this.getFunctionFlags(), 32 /* GetAccessor */) || TypeScript.hasFlag(this.getFunctionFlags(), 64 /* SetAccessor */); + }; + FunctionDeclaration.prototype.isGetAccessor = function () { + return TypeScript.hasFlag(this.getFunctionFlags(), 32 /* GetAccessor */); + }; + FunctionDeclaration.prototype.isSetAccessor = function () { + return TypeScript.hasFlag(this.getFunctionFlags(), 64 /* SetAccessor */); + }; + FunctionDeclaration.prototype.isStatic = function () { + return TypeScript.hasFlag(this.getFunctionFlags(), 16 /* Static */); + }; + + FunctionDeclaration.prototype.isSignature = function () { + return (this.getFunctionFlags() & 128 /* Signature */) !== 0 /* None */; + }; + return FunctionDeclaration; + })(AST); + TypeScript.FunctionDeclaration = FunctionDeclaration; + + var Script = (function (_super) { + __extends(Script, _super); + function Script() { + _super.apply(this, arguments); + this.moduleElements = null; + this.referencedFiles = new Array(); + this.isDeclareFile = false; + this.topLevelMod = null; + } + Script.prototype.nodeType = function () { + return 2 /* Script */; + }; + + Script.prototype.emit = function (emitter) { + if (!this.isDeclareFile) { + emitter.emitScriptElements(this); + } + }; + + Script.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.moduleElements, ast.moduleElements, includingPosition); + }; + return Script; + })(AST); + TypeScript.Script = Script; + + var ModuleDeclaration = (function (_super) { + __extends(ModuleDeclaration, _super); + function ModuleDeclaration(name, members, endingToken) { + _super.call(this); + this.name = name; + this.members = members; + this.endingToken = endingToken; + this._moduleFlags = 0 /* None */; + this.amdDependencies = new Array(); + + this.prettyName = this.name.actualText; + } + ModuleDeclaration.prototype.isDeclaration = function () { + return true; + }; + + ModuleDeclaration.prototype.nodeType = function () { + return 16 /* ModuleDeclaration */; + }; + + ModuleDeclaration.prototype.getModuleFlags = function () { + return this._moduleFlags; + }; + + ModuleDeclaration.prototype.setModuleFlags = function (flags) { + this._moduleFlags = flags; + }; + + ModuleDeclaration.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && this._moduleFlags === ast._moduleFlags && structuralEquals(this.name, ast.name, includingPosition) && structuralEquals(this.members, ast.members, includingPosition); + }; + + ModuleDeclaration.prototype.isEnum = function () { + return TypeScript.hasFlag(this.getModuleFlags(), 128 /* IsEnum */); + }; + ModuleDeclaration.prototype.isWholeFile = function () { + return TypeScript.hasFlag(this.getModuleFlags(), 256 /* IsWholeFile */); + }; + + ModuleDeclaration.prototype.shouldEmit = function () { + if (TypeScript.hasFlag(this.getModuleFlags(), 8 /* Ambient */)) { + return false; + } + + if (TypeScript.hasFlag(this.getModuleFlags(), 128 /* IsEnum */)) { + return true; + } + + for (var i = 0, n = this.members.members.length; i < n; i++) { + var member = this.members.members[i]; + + if (member.nodeType() === 16 /* ModuleDeclaration */) { + if ((member).shouldEmit()) { + return true; + } + } else if (member.nodeType() !== 15 /* InterfaceDeclaration */) { + return true; + } + } + + return false; + }; + + ModuleDeclaration.prototype.emit = function (emitter) { + if (this.shouldEmit()) { + emitter.emitComments(this, true); + emitter.emitModule(this); + emitter.emitComments(this, false); + } + }; + return ModuleDeclaration; + })(AST); + TypeScript.ModuleDeclaration = ModuleDeclaration; + + var TypeDeclaration = (function (_super) { + __extends(TypeDeclaration, _super); + function TypeDeclaration(name, typeParameters, extendsList, implementsList, members) { + _super.call(this); + this.name = name; + this.typeParameters = typeParameters; + this.extendsList = extendsList; + this.implementsList = implementsList; + this.members = members; + this._varFlags = 0 /* None */; + } + TypeDeclaration.prototype.isDeclaration = function () { + return true; + }; + + TypeDeclaration.prototype.getVarFlags = function () { + return this._varFlags; + }; + + TypeDeclaration.prototype.setVarFlags = function (flags) { + this._varFlags = flags; + }; + + TypeDeclaration.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && this._varFlags === ast._varFlags && structuralEquals(this.name, ast.name, includingPosition) && structuralEquals(this.members, ast.members, includingPosition) && structuralEquals(this.typeParameters, ast.typeParameters, includingPosition) && structuralEquals(this.extendsList, ast.extendsList, includingPosition) && structuralEquals(this.implementsList, ast.implementsList, includingPosition); + }; + return TypeDeclaration; + })(AST); + TypeScript.TypeDeclaration = TypeDeclaration; + + var ClassDeclaration = (function (_super) { + __extends(ClassDeclaration, _super); + function ClassDeclaration(name, typeParameters, members, extendsList, implementsList, endingToken) { + _super.call(this, name, typeParameters, extendsList, implementsList, members); + this.endingToken = endingToken; + this.constructorDecl = null; + } + ClassDeclaration.prototype.nodeType = function () { + return 14 /* ClassDeclaration */; + }; + + ClassDeclaration.prototype.shouldEmit = function () { + return !TypeScript.hasFlag(this.getVarFlags(), 8 /* Ambient */); + }; + + ClassDeclaration.prototype.emit = function (emitter) { + emitter.emitClass(this); + }; + return ClassDeclaration; + })(TypeDeclaration); + TypeScript.ClassDeclaration = ClassDeclaration; + + var InterfaceDeclaration = (function (_super) { + __extends(InterfaceDeclaration, _super); + function InterfaceDeclaration(name, typeParameters, members, extendsList, implementsList, isObjectTypeLiteral) { + _super.call(this, name, typeParameters, extendsList, implementsList, members); + this.isObjectTypeLiteral = isObjectTypeLiteral; + } + InterfaceDeclaration.prototype.nodeType = function () { + return 15 /* InterfaceDeclaration */; + }; + + InterfaceDeclaration.prototype.shouldEmit = function () { + return false; + }; + return InterfaceDeclaration; + })(TypeDeclaration); + TypeScript.InterfaceDeclaration = InterfaceDeclaration; + + var ThrowStatement = (function (_super) { + __extends(ThrowStatement, _super); + function ThrowStatement(expression) { + _super.call(this); + this.expression = expression; + } + ThrowStatement.prototype.nodeType = function () { + return 96 /* ThrowStatement */; + }; + + ThrowStatement.prototype.isStatement = function () { + return true; + }; + + ThrowStatement.prototype.emitWorker = function (emitter) { + emitter.writeToOutput("throw "); + this.expression.emit(emitter); + emitter.writeToOutput(";"); + }; + + ThrowStatement.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.expression, ast.expression, includingPosition); + }; + return ThrowStatement; + })(AST); + TypeScript.ThrowStatement = ThrowStatement; + + var ExpressionStatement = (function (_super) { + __extends(ExpressionStatement, _super); + function ExpressionStatement(expression) { + _super.call(this); + this.expression = expression; + } + ExpressionStatement.prototype.nodeType = function () { + return 89 /* ExpressionStatement */; + }; + + ExpressionStatement.prototype.isStatement = function () { + return true; + }; + + ExpressionStatement.prototype.emitWorker = function (emitter) { + var isArrowExpression = this.expression.nodeType() === 13 /* FunctionDeclaration */ && TypeScript.hasFlag((this.expression).getFunctionFlags(), 2048 /* IsFatArrowFunction */); + + if (isArrowExpression) { + emitter.writeToOutput("("); + } + + this.expression.emit(emitter); + + if (isArrowExpression) { + emitter.writeToOutput(")"); + } + + emitter.writeToOutput(";"); + }; + + ExpressionStatement.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.expression, ast.expression, includingPosition); + }; + return ExpressionStatement; + })(AST); + TypeScript.ExpressionStatement = ExpressionStatement; + + var LabeledStatement = (function (_super) { + __extends(LabeledStatement, _super); + function LabeledStatement(identifier, statement) { + _super.call(this); + this.identifier = identifier; + this.statement = statement; + } + LabeledStatement.prototype.nodeType = function () { + return 93 /* LabeledStatement */; + }; + + LabeledStatement.prototype.isStatement = function () { + return true; + }; + + LabeledStatement.prototype.emitWorker = function (emitter) { + emitter.recordSourceMappingStart(this.identifier); + emitter.writeToOutput(this.identifier.actualText); + emitter.recordSourceMappingEnd(this.identifier); + emitter.writeLineToOutput(":"); + emitter.emitJavascript(this.statement, true); + }; + + LabeledStatement.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.identifier, ast.identifier, includingPosition) && structuralEquals(this.statement, ast.statement, includingPosition); + }; + return LabeledStatement; + })(AST); + TypeScript.LabeledStatement = LabeledStatement; + + var VariableDeclaration = (function (_super) { + __extends(VariableDeclaration, _super); + function VariableDeclaration(declarators) { + _super.call(this); + this.declarators = declarators; + } + VariableDeclaration.prototype.nodeType = function () { + return 19 /* VariableDeclaration */; + }; + + VariableDeclaration.prototype.emit = function (emitter) { + emitter.emitVariableDeclaration(this); + }; + + VariableDeclaration.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.declarators, ast.declarators, includingPosition); + }; + return VariableDeclaration; + })(AST); + TypeScript.VariableDeclaration = VariableDeclaration; + + var VariableStatement = (function (_super) { + __extends(VariableStatement, _super); + function VariableStatement(declaration) { + _super.call(this); + this.declaration = declaration; + } + VariableStatement.prototype.nodeType = function () { + return 98 /* VariableStatement */; + }; + + VariableStatement.prototype.isStatement = function () { + return true; + }; + + VariableStatement.prototype.shouldEmit = function () { + var varDecl = this.declaration.declarators.members[0]; + return !TypeScript.hasFlag(varDecl.getVarFlags(), 8 /* Ambient */) || varDecl.init !== null; + }; + + VariableStatement.prototype.emitWorker = function (emitter) { + if (TypeScript.hasFlag(this.getFlags(), 16 /* EnumElement */)) { + emitter.emitEnumElement(this.declaration.declarators.members[0]); + } else { + this.declaration.emit(emitter); + emitter.writeToOutput(";"); + } + }; + + VariableStatement.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.declaration, ast.declaration, includingPosition); + }; + return VariableStatement; + })(AST); + TypeScript.VariableStatement = VariableStatement; + + var Block = (function (_super) { + __extends(Block, _super); + function Block(statements, closeBraceSpan) { + _super.call(this); + this.statements = statements; + this.closeBraceSpan = closeBraceSpan; + this.closeBraceLeadingComments = null; + } + Block.prototype.nodeType = function () { + return 82 /* Block */; + }; + + Block.prototype.isStatement = function () { + return true; + }; + + Block.prototype.emitWorker = function (emitter) { + emitter.writeLineToOutput(" {"); + emitter.indenter.increaseIndent(); + if (this.statements) { + emitter.emitModuleElements(this.statements); + } + emitter.emitCommentsArray(this.closeBraceLeadingComments); + emitter.indenter.decreaseIndent(); + emitter.emitIndent(); + emitter.writeToOutput("}"); + }; + + Block.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.statements, ast.statements, includingPosition); + }; + return Block; + })(AST); + TypeScript.Block = Block; + + var Jump = (function (_super) { + __extends(Jump, _super); + function Jump(_nodeType, target) { + _super.call(this); + this._nodeType = _nodeType; + this.target = target; + } + Jump.prototype.nodeType = function () { + return this._nodeType; + }; + + Jump.prototype.isStatement = function () { + return true; + }; + + Jump.prototype.hasExplicitTarget = function () { + return this.target; + }; + + Jump.prototype.emitWorker = function (emitter) { + if (this.nodeType() === 83 /* BreakStatement */) { + emitter.writeToOutput("break"); + } else { + emitter.writeToOutput("continue"); + } + if (this.hasExplicitTarget()) { + emitter.writeToOutput(" " + this.target); + } + emitter.writeToOutput(";"); + }; + + Jump.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && this.target === ast.target; + }; + return Jump; + })(AST); + TypeScript.Jump = Jump; + + var WhileStatement = (function (_super) { + __extends(WhileStatement, _super); + function WhileStatement(cond, body) { + _super.call(this); + this.cond = cond; + this.body = body; + } + WhileStatement.prototype.nodeType = function () { + return 99 /* WhileStatement */; + }; + + WhileStatement.prototype.isStatement = function () { + return true; + }; + + WhileStatement.prototype.emitWorker = function (emitter) { + emitter.writeToOutput("while ("); + this.cond.emit(emitter); + emitter.writeToOutput(")"); + emitter.emitBlockOrStatement(this.body); + }; + + WhileStatement.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.cond, ast.cond, includingPosition) && structuralEquals(this.body, ast.body, includingPosition); + }; + return WhileStatement; + })(AST); + TypeScript.WhileStatement = WhileStatement; + + var DoStatement = (function (_super) { + __extends(DoStatement, _super); + function DoStatement(body, cond, whileSpan) { + _super.call(this); + this.body = body; + this.cond = cond; + this.whileSpan = whileSpan; + } + DoStatement.prototype.nodeType = function () { + return 86 /* DoStatement */; + }; + + DoStatement.prototype.isStatement = function () { + return true; + }; + + DoStatement.prototype.emitWorker = function (emitter) { + emitter.writeToOutput("do"); + emitter.emitBlockOrStatement(this.body); + emitter.recordSourceMappingStart(this.whileSpan); + emitter.writeToOutput(" while"); + emitter.recordSourceMappingEnd(this.whileSpan); + emitter.writeToOutput('('); + this.cond.emit(emitter); + emitter.writeToOutput(")"); + emitter.writeToOutput(";"); + }; + + DoStatement.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.body, ast.body, includingPosition) && structuralEquals(this.cond, ast.cond, includingPosition); + }; + return DoStatement; + })(AST); + TypeScript.DoStatement = DoStatement; + + var IfStatement = (function (_super) { + __extends(IfStatement, _super); + function IfStatement(cond, thenBod, elseBod) { + _super.call(this); + this.cond = cond; + this.thenBod = thenBod; + this.elseBod = elseBod; + } + IfStatement.prototype.nodeType = function () { + return 92 /* IfStatement */; + }; + + IfStatement.prototype.isStatement = function () { + return true; + }; + + IfStatement.prototype.emitWorker = function (emitter) { + emitter.writeToOutput("if ("); + this.cond.emit(emitter); + emitter.writeToOutput(")"); + + emitter.emitBlockOrStatement(this.thenBod); + + if (this.elseBod) { + if (this.thenBod.nodeType() !== 82 /* Block */) { + emitter.writeLineToOutput(""); + } else { + emitter.writeToOutput(" "); + } + + if (this.elseBod.nodeType() === 92 /* IfStatement */) { + emitter.writeToOutput("else "); + this.elseBod.emit(emitter); + } else { + emitter.writeToOutput("else"); + emitter.emitBlockOrStatement(this.elseBod); + } + } + }; + + IfStatement.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.cond, ast.cond, includingPosition) && structuralEquals(this.thenBod, ast.thenBod, includingPosition) && structuralEquals(this.elseBod, ast.elseBod, includingPosition); + }; + return IfStatement; + })(AST); + TypeScript.IfStatement = IfStatement; + + var ReturnStatement = (function (_super) { + __extends(ReturnStatement, _super); + function ReturnStatement(returnExpression) { + _super.call(this); + this.returnExpression = returnExpression; + } + ReturnStatement.prototype.nodeType = function () { + return 94 /* ReturnStatement */; + }; + + ReturnStatement.prototype.isStatement = function () { + return true; + }; + + ReturnStatement.prototype.emitWorker = function (emitter) { + if (this.returnExpression) { + emitter.writeToOutput("return "); + this.returnExpression.emit(emitter); + emitter.writeToOutput(";"); + } else { + emitter.writeToOutput("return;"); + } + }; + + ReturnStatement.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.returnExpression, ast.returnExpression, includingPosition); + }; + return ReturnStatement; + })(AST); + TypeScript.ReturnStatement = ReturnStatement; + + var ForInStatement = (function (_super) { + __extends(ForInStatement, _super); + function ForInStatement(lval, obj, body) { + _super.call(this); + this.lval = lval; + this.obj = obj; + this.body = body; + } + ForInStatement.prototype.nodeType = function () { + return 90 /* ForInStatement */; + }; + + ForInStatement.prototype.isStatement = function () { + return true; + }; + + ForInStatement.prototype.emitWorker = function (emitter) { + emitter.writeToOutput("for ("); + this.lval.emit(emitter); + emitter.writeToOutput(" in "); + this.obj.emit(emitter); + emitter.writeToOutput(")"); + emitter.emitBlockOrStatement(this.body); + }; + + ForInStatement.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.lval, ast.lval, includingPosition) && structuralEquals(this.obj, ast.obj, includingPosition) && structuralEquals(this.body, ast.body, includingPosition); + }; + return ForInStatement; + })(AST); + TypeScript.ForInStatement = ForInStatement; + + var ForStatement = (function (_super) { + __extends(ForStatement, _super); + function ForStatement(init, cond, incr, body) { + _super.call(this); + this.init = init; + this.cond = cond; + this.incr = incr; + this.body = body; + } + ForStatement.prototype.nodeType = function () { + return 91 /* ForStatement */; + }; + + ForStatement.prototype.isStatement = function () { + return true; + }; + + ForStatement.prototype.emitWorker = function (emitter) { + emitter.writeToOutput("for ("); + if (this.init) { + if (this.init.nodeType() !== 1 /* List */) { + this.init.emit(emitter); + } else { + emitter.setInVarBlock((this.init).members.length); + emitter.emitCommaSeparatedList(this.init); + } + } + + emitter.writeToOutput("; "); + emitter.emitJavascript(this.cond, false); + emitter.writeToOutput(";"); + if (this.incr) { + emitter.writeToOutput(" "); + emitter.emitJavascript(this.incr, false); + } + emitter.writeToOutput(")"); + emitter.emitBlockOrStatement(this.body); + }; + + ForStatement.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.init, ast.init, includingPosition) && structuralEquals(this.cond, ast.cond, includingPosition) && structuralEquals(this.incr, ast.incr, includingPosition) && structuralEquals(this.body, ast.body, includingPosition); + }; + return ForStatement; + })(AST); + TypeScript.ForStatement = ForStatement; + + var WithStatement = (function (_super) { + __extends(WithStatement, _super); + function WithStatement(expr, body) { + _super.call(this); + this.expr = expr; + this.body = body; + } + WithStatement.prototype.nodeType = function () { + return 100 /* WithStatement */; + }; + + WithStatement.prototype.isStatement = function () { + return true; + }; + + WithStatement.prototype.emitWorker = function (emitter) { + emitter.writeToOutput("with ("); + if (this.expr) { + this.expr.emit(emitter); + } + + emitter.writeToOutput(")"); + emitter.emitBlockOrStatement(this.body); + }; + + WithStatement.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.expr, ast.expr, includingPosition) && structuralEquals(this.body, ast.body, includingPosition); + }; + return WithStatement; + })(AST); + TypeScript.WithStatement = WithStatement; + + var SwitchStatement = (function (_super) { + __extends(SwitchStatement, _super); + function SwitchStatement(val, caseList, defaultCase, statement) { + _super.call(this); + this.val = val; + this.caseList = caseList; + this.defaultCase = defaultCase; + this.statement = statement; + } + SwitchStatement.prototype.nodeType = function () { + return 95 /* SwitchStatement */; + }; + + SwitchStatement.prototype.isStatement = function () { + return true; + }; + + SwitchStatement.prototype.emitWorker = function (emitter) { + emitter.recordSourceMappingStart(this.statement); + emitter.writeToOutput("switch ("); + this.val.emit(emitter); + emitter.writeToOutput(")"); + emitter.recordSourceMappingEnd(this.statement); + emitter.writeLineToOutput(" {"); + emitter.indenter.increaseIndent(); + + var lastEmittedNode = null; + for (var i = 0, n = this.caseList.members.length; i < n; i++) { + var caseExpr = this.caseList.members[i]; + + emitter.emitSpaceBetweenConstructs(lastEmittedNode, caseExpr); + emitter.emitJavascript(caseExpr, true); + + lastEmittedNode = caseExpr; + } + emitter.indenter.decreaseIndent(); + emitter.emitIndent(); + emitter.writeToOutput("}"); + }; + + SwitchStatement.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.caseList, ast.caseList, includingPosition) && structuralEquals(this.val, ast.val, includingPosition); + }; + return SwitchStatement; + })(AST); + TypeScript.SwitchStatement = SwitchStatement; + + var CaseClause = (function (_super) { + __extends(CaseClause, _super); + function CaseClause(expr, body) { + _super.call(this); + this.expr = expr; + this.body = body; + } + CaseClause.prototype.nodeType = function () { + return 101 /* CaseClause */; + }; + + CaseClause.prototype.emitWorker = function (emitter) { + if (this.expr) { + emitter.writeToOutput("case "); + this.expr.emit(emitter); + } else { + emitter.writeToOutput("default"); + } + emitter.writeToOutput(":"); + + if (this.body.members.length === 1 && this.body.members[0].nodeType() === 82 /* Block */) { + this.body.members[0].emit(emitter); + emitter.writeLineToOutput(""); + } else { + emitter.writeLineToOutput(""); + emitter.indenter.increaseIndent(); + this.body.emit(emitter); + emitter.indenter.decreaseIndent(); + } + }; + + CaseClause.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.expr, ast.expr, includingPosition) && structuralEquals(this.body, ast.body, includingPosition); + }; + return CaseClause; + })(AST); + TypeScript.CaseClause = CaseClause; + + var TypeParameter = (function (_super) { + __extends(TypeParameter, _super); + function TypeParameter(name, constraint) { + _super.call(this); + this.name = name; + this.constraint = constraint; + } + TypeParameter.prototype.nodeType = function () { + return 9 /* TypeParameter */; + }; + + TypeParameter.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.name, ast.name, includingPosition) && structuralEquals(this.constraint, ast.constraint, includingPosition); + }; + return TypeParameter; + })(AST); + TypeScript.TypeParameter = TypeParameter; + + var GenericType = (function (_super) { + __extends(GenericType, _super); + function GenericType(name, typeArguments) { + _super.call(this); + this.name = name; + this.typeArguments = typeArguments; + } + GenericType.prototype.nodeType = function () { + return 10 /* GenericType */; + }; + + GenericType.prototype.emit = function (emitter) { + this.name.emit(emitter); + }; + + GenericType.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.name, ast.name, includingPosition) && structuralEquals(this.typeArguments, ast.typeArguments, includingPosition); + }; + return GenericType; + })(AST); + TypeScript.GenericType = GenericType; + + var TypeQuery = (function (_super) { + __extends(TypeQuery, _super); + function TypeQuery(name) { + _super.call(this); + this.name = name; + } + TypeQuery.prototype.nodeType = function () { + return 12 /* TypeQuery */; + }; + + TypeQuery.prototype.emit = function (emitter) { + TypeScript.Emitter.throwEmitterError(new Error(TypeScript.getLocalizedText(TypeScript.DiagnosticCode.Should_not_emit_a_type_query, null))); + }; + + TypeQuery.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.name, ast.name, includingPosition); + }; + return TypeQuery; + })(AST); + TypeScript.TypeQuery = TypeQuery; + + var TypeReference = (function (_super) { + __extends(TypeReference, _super); + function TypeReference(term, arrayCount) { + _super.call(this); + this.term = term; + this.arrayCount = arrayCount; + this.minChar = term.minChar; + this.limChar = term.limChar; + } + TypeReference.prototype.nodeType = function () { + return 11 /* TypeRef */; + }; + + TypeReference.prototype.emit = function (emitter) { + TypeScript.Emitter.throwEmitterError(new Error(TypeScript.getLocalizedText(TypeScript.DiagnosticCode.Should_not_emit_a_type_reference, null))); + }; + + TypeReference.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.term, ast.term, includingPosition) && this.arrayCount === ast.arrayCount; + }; + return TypeReference; + })(AST); + TypeScript.TypeReference = TypeReference; + + var TryStatement = (function (_super) { + __extends(TryStatement, _super); + function TryStatement(tryBody, catchClause, finallyBody) { + _super.call(this); + this.tryBody = tryBody; + this.catchClause = catchClause; + this.finallyBody = finallyBody; + } + TryStatement.prototype.nodeType = function () { + return 97 /* TryStatement */; + }; + + TryStatement.prototype.isStatement = function () { + return true; + }; + + TryStatement.prototype.emitWorker = function (emitter) { + emitter.writeToOutput("try "); + this.tryBody.emit(emitter); + emitter.emitJavascript(this.catchClause, false); + + if (this.finallyBody) { + emitter.writeToOutput(" finally"); + this.finallyBody.emit(emitter); + } + }; + + TryStatement.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.tryBody, ast.tryBody, includingPosition) && structuralEquals(this.catchClause, ast.catchClause, includingPosition) && structuralEquals(this.finallyBody, ast.finallyBody, includingPosition); + }; + return TryStatement; + })(AST); + TypeScript.TryStatement = TryStatement; + + var CatchClause = (function (_super) { + __extends(CatchClause, _super); + function CatchClause(param, body) { + _super.call(this); + this.param = param; + this.body = body; + } + CatchClause.prototype.nodeType = function () { + return 102 /* CatchClause */; + }; + + CatchClause.prototype.emitWorker = function (emitter) { + emitter.writeToOutput(" "); + emitter.writeToOutput("catch ("); + this.param.id.emit(emitter); + emitter.writeToOutput(")"); + this.body.emit(emitter); + }; + + CatchClause.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.param, ast.param, includingPosition) && structuralEquals(this.body, ast.body, includingPosition); + }; + return CatchClause; + })(AST); + TypeScript.CatchClause = CatchClause; + + var DebuggerStatement = (function (_super) { + __extends(DebuggerStatement, _super); + function DebuggerStatement() { + _super.apply(this, arguments); + } + DebuggerStatement.prototype.nodeType = function () { + return 85 /* DebuggerStatement */; + }; + + DebuggerStatement.prototype.isStatement = function () { + return true; + }; + + DebuggerStatement.prototype.emitWorker = function (emitter) { + emitter.writeToOutput("debugger;"); + }; + return DebuggerStatement; + })(AST); + TypeScript.DebuggerStatement = DebuggerStatement; + + var OmittedExpression = (function (_super) { + __extends(OmittedExpression, _super); + function OmittedExpression() { + _super.apply(this, arguments); + } + OmittedExpression.prototype.nodeType = function () { + return 24 /* OmittedExpression */; + }; + + OmittedExpression.prototype.emitWorker = function (emitter) { + }; + + OmittedExpression.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition); + }; + return OmittedExpression; + })(AST); + TypeScript.OmittedExpression = OmittedExpression; + + var EmptyStatement = (function (_super) { + __extends(EmptyStatement, _super); + function EmptyStatement() { + _super.apply(this, arguments); + } + EmptyStatement.prototype.nodeType = function () { + return 87 /* EmptyStatement */; + }; + + EmptyStatement.prototype.isStatement = function () { + return true; + }; + + EmptyStatement.prototype.emitWorker = function (emitter) { + emitter.writeToOutput(";"); + }; + + EmptyStatement.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition); + }; + return EmptyStatement; + })(AST); + TypeScript.EmptyStatement = EmptyStatement; + + var Comment = (function (_super) { + __extends(Comment, _super); + function Comment(content, isBlockComment, endsLine) { + _super.call(this); + this.content = content; + this.isBlockComment = isBlockComment; + this.endsLine = endsLine; + this.text = null; + this.docCommentText = null; + } + Comment.prototype.nodeType = function () { + return 103 /* Comment */; + }; + + Comment.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && this.content === ast.content && this.isBlockComment === ast.isBlockComment && this.endsLine === ast.endsLine; + }; + + Comment.prototype.getText = function () { + if (this.text === null) { + if (this.isBlockComment) { + this.text = this.content.split("\n"); + for (var i = 0; i < this.text.length; i++) { + this.text[i] = this.text[i].replace(/^\s+|\s+$/g, ''); + } + } else { + this.text = [(this.content.replace(/^\s+|\s+$/g, ''))]; + } + } + + return this.text; + }; + + Comment.prototype.isDocComment = function () { + if (this.isBlockComment) { + return this.content.charAt(2) === "*" && this.content.charAt(3) !== "/"; + } + + return false; + }; + + Comment.prototype.getDocCommentTextValue = function () { + if (this.docCommentText === null) { + this.docCommentText = Comment.cleanJSDocComment(this.content); + } + + return this.docCommentText; + }; + + Comment.consumeLeadingSpace = function (line, startIndex, maxSpacesToRemove) { + var endIndex = line.length; + if (maxSpacesToRemove !== undefined) { + endIndex = TypeScript.min(startIndex + maxSpacesToRemove, endIndex); + } + + for (; startIndex < endIndex; startIndex++) { + var charCode = line.charCodeAt(startIndex); + if (charCode !== 32 /* space */ && charCode !== 9 /* tab */) { + return startIndex; + } + } + + if (endIndex !== line.length) { + return endIndex; + } + + return -1; + }; + + Comment.isSpaceChar = function (line, index) { + var length = line.length; + if (index < length) { + var charCode = line.charCodeAt(index); + + return charCode === 32 /* space */ || charCode === 9 /* tab */; + } + + return index === length; + }; + + Comment.cleanDocCommentLine = function (line, jsDocStyleComment, jsDocLineSpaceToRemove) { + var nonSpaceIndex = Comment.consumeLeadingSpace(line, 0); + if (nonSpaceIndex !== -1) { + var jsDocSpacesRemoved = nonSpaceIndex; + if (jsDocStyleComment && line.charAt(nonSpaceIndex) === '*') { + var startIndex = nonSpaceIndex + 1; + nonSpaceIndex = Comment.consumeLeadingSpace(line, startIndex, jsDocLineSpaceToRemove); + + if (nonSpaceIndex !== -1) { + jsDocSpacesRemoved = nonSpaceIndex - startIndex; + } else { + return null; + } + } + + return { + minChar: nonSpaceIndex, + limChar: line.charAt(line.length - 1) === "\r" ? line.length - 1 : line.length, + jsDocSpacesRemoved: jsDocSpacesRemoved + }; + } + + return null; + }; + + Comment.cleanJSDocComment = function (content, spacesToRemove) { + var docCommentLines = new Array(); + content = content.replace("/**", ""); + if (content.length >= 2 && content.charAt(content.length - 1) === "/" && content.charAt(content.length - 2) === "*") { + content = content.substring(0, content.length - 2); + } + var lines = content.split("\n"); + var inParamTag = false; + for (var l = 0; l < lines.length; l++) { + var line = lines[l]; + var cleanLinePos = Comment.cleanDocCommentLine(line, true, spacesToRemove); + if (!cleanLinePos) { + continue; + } + + var docCommentText = ""; + var prevPos = cleanLinePos.minChar; + for (var i = line.indexOf("@", cleanLinePos.minChar); 0 <= i && i < cleanLinePos.limChar; i = line.indexOf("@", i + 1)) { + var wasInParamtag = inParamTag; + + if (line.indexOf("param", i + 1) === i + 1 && Comment.isSpaceChar(line, i + 6)) { + if (!wasInParamtag) { + docCommentText += line.substring(prevPos, i); + } + + prevPos = i; + inParamTag = true; + } else if (wasInParamtag) { + prevPos = i; + inParamTag = false; + } + } + + if (!inParamTag) { + docCommentText += line.substring(prevPos, cleanLinePos.limChar); + } + + var newCleanPos = Comment.cleanDocCommentLine(docCommentText, false); + if (newCleanPos) { + if (spacesToRemove === undefined) { + spacesToRemove = cleanLinePos.jsDocSpacesRemoved; + } + docCommentLines.push(docCommentText); + } + } + + return docCommentLines.join("\n"); + }; + + Comment.getDocCommentText = function (comments) { + var docCommentText = new Array(); + for (var c = 0; c < comments.length; c++) { + var commentText = comments[c].getDocCommentTextValue(); + if (commentText !== "") { + docCommentText.push(commentText); + } + } + return docCommentText.join("\n"); + }; + + Comment.getParameterDocCommentText = function (param, fncDocComments) { + if (fncDocComments.length === 0 || !fncDocComments[0].isBlockComment) { + return ""; + } + + for (var i = 0; i < fncDocComments.length; i++) { + var commentContents = fncDocComments[i].content; + for (var j = commentContents.indexOf("@param", 0); 0 <= j; j = commentContents.indexOf("@param", j)) { + j += 6; + if (!Comment.isSpaceChar(commentContents, j)) { + continue; + } + + j = Comment.consumeLeadingSpace(commentContents, j); + if (j === -1) { + break; + } + + if (commentContents.charCodeAt(j) === 123 /* openBrace */) { + j++; + + var charCode = 0; + for (var curlies = 1; j < commentContents.length; j++) { + charCode = commentContents.charCodeAt(j); + + if (charCode === 123 /* openBrace */) { + curlies++; + continue; + } + + if (charCode === 125 /* closeBrace */) { + curlies--; + if (curlies === 0) { + break; + } else { + continue; + } + } + + if (charCode === 64 /* at */) { + break; + } + } + + if (j === commentContents.length) { + break; + } + + if (charCode === 64 /* at */) { + continue; + } + + j = Comment.consumeLeadingSpace(commentContents, j + 1); + if (j === -1) { + break; + } + } + + if (param !== commentContents.substr(j, param.length) || !Comment.isSpaceChar(commentContents, j + param.length)) { + continue; + } + + j = Comment.consumeLeadingSpace(commentContents, j + param.length); + if (j === -1) { + return ""; + } + + var endOfParam = commentContents.indexOf("@", j); + var paramHelpString = commentContents.substring(j, endOfParam < 0 ? commentContents.length : endOfParam); + + var paramSpacesToRemove = undefined; + var paramLineIndex = commentContents.substring(0, j).lastIndexOf("\n") + 1; + if (paramLineIndex !== 0) { + if (paramLineIndex < j && commentContents.charAt(paramLineIndex + 1) === "\r") { + paramLineIndex++; + } + } + var startSpaceRemovalIndex = Comment.consumeLeadingSpace(commentContents, paramLineIndex); + if (startSpaceRemovalIndex !== j && commentContents.charAt(startSpaceRemovalIndex) === "*") { + paramSpacesToRemove = j - startSpaceRemovalIndex - 1; + } + + return Comment.cleanJSDocComment(paramHelpString, paramSpacesToRemove); + } + } + + return ""; + }; + return Comment; + })(AST); + TypeScript.Comment = Comment; +})(TypeScript || (TypeScript = {})); diff --git a/angularjs/angular-tests.ts b/angularjs/angular-tests.ts index eab0d6081..1994e2af4 100644 --- a/angularjs/angular-tests.ts +++ b/angularjs/angular-tests.ts @@ -9,148 +9,144 @@ https://github.com/witoldsz/angular-http-auth/blob/master/src/angular-http-auth. */ angular.module('http-auth-interceptor', []) - .provider('authService', function () { - /** - * Holds all the requests which failed due to 401 response, - * so they can be re-requested in future, once login is completed. - */ - var buffer = []; + .provider('authService', function () { + /** + * Holds all the requests which failed due to 401 response, + * so they can be re-requested in future, once login is completed. + */ + var buffer = []; - /** - * Required by HTTP interceptor. - * Function is attached to provider to be invisible for regular users of this service. - */ - this.pushToBuffer = function (config: ng.IRequestConfig, deferred: ng.IDeferred) { - buffer.push({ - config: config, - deferred: deferred - }); - } + /** + * Required by HTTP interceptor. + * Function is attached to provider to be invisible for regular users of this service. + */ + this.pushToBuffer = function (config: ng.IRequestConfig, deferred: ng.IDeferred) { + buffer.push({ + config: config, + deferred: deferred + }); + } this.$get = ['$rootScope', '$injector', function ($rootScope: ng.IScope, $injector: ng.auto.IInjectorService) { - var $http: ng.IHttpService; //initialized later because of circular dependency problem - function retry(config: ng.IRequestConfig, deferred: ng.IDeferred) { - $http = $http || $injector.get('$http'); - $http(config).then(function (response) { - deferred.resolve(response); - }); - } - function retryAll() { - for (var i = 0; i < buffer.length; ++i) { - retry(buffer[i].config, buffer[i].deferred); - } - buffer = []; - } + var $http: ng.IHttpService; //initialized later because of circular dependency problem + function retry(config: ng.IRequestConfig, deferred: ng.IDeferred) { + $http = $http || $injector.get('$http'); + $http(config).then(function (response) { + deferred.resolve(response); + }); + } + function retryAll() { + for (var i = 0; i < buffer.length; ++i) { + retry(buffer[i].config, buffer[i].deferred); + } + buffer = []; + } return { - loginConfirmed: function () { - $rootScope.$broadcast('event:auth-loginConfirmed'); - retryAll(); - } - } + loginConfirmed: function () { + $rootScope.$broadcast('event:auth-loginConfirmed'); + retryAll(); + } + } }] }) - /** - * $http interceptor. - * On 401 response - it stores the request and broadcasts 'event:angular-auth-loginRequired'. - */ - .config(['$httpProvider', 'authServiceProvider', function ($httpProvider: ng.IHttpProvider, authServiceProvider) { +/** + * $http interceptor. + * On 401 response - it stores the request and broadcasts 'event:angular-auth-loginRequired'. + */ + .config(['$httpProvider', 'authServiceProvider', function ($httpProvider: ng.IHttpProvider, authServiceProvider) { - var interceptor = ['$rootScope', '$q', function ($rootScope: ng.IScope, $q: ng.IQService) { - function success(response: ng.IHttpPromiseCallbackArg) { - return response; - } + var interceptor = ['$rootScope', '$q', function ($rootScope: ng.IScope, $q: ng.IQService) { + function success(response: ng.IHttpPromiseCallbackArg) { + return response; + } - function error(response: ng.IHttpPromiseCallbackArg) { - if (response.status === 401) { - var deferred = $q.defer(); - authServiceProvider.pushToBuffer(response.config, deferred); - $rootScope.$broadcast('event:auth-loginRequired'); - return deferred.promise; - } - // otherwise - return $q.reject(response); - } + function error(response: ng.IHttpPromiseCallbackArg) { + if (response.status === 401) { + var deferred = $q.defer(); + authServiceProvider.pushToBuffer(response.config, deferred); + $rootScope.$broadcast('event:auth-loginRequired'); + return deferred.promise; + } + // otherwise + return $q.reject(response); + } - return function (promise: ng.IHttpPromise) { - return promise.then(success, error); - } + return function (promise: ng.IHttpPromise) { + return promise.then(success, error); + } }]; - $httpProvider.responseInterceptors.push(interceptor); - }]); + $httpProvider.responseInterceptors.push(interceptor); + }]); module HttpAndRegularPromiseTests { - interface Person { - firstName: string; - lastName: string; - } + interface Person { + firstName: string; + lastName: string; + } - interface ExpectedResponse extends Person {} + interface ExpectedResponse extends Person { } - interface SomeControllerScope extends ng.IScope { - person: Person; - theAnswer: number; - letters: string[]; - } + interface SomeControllerScope extends ng.IScope { + person: Person; + theAnswer: number; + letters: string[]; + } - interface OurApiPromiseCallbackArg extends ng.IHttpPromiseCallbackArg { - data?: ExpectedResponse; - } + var someController: Function = ($scope: SomeControllerScope, $http: ng.IHttpService, $q: ng.IQService) => { + $http.get("http://somewhere/some/resource") + .success((data: ExpectedResponse) => { + $scope.person = data; + }); - var someController: Function = ($scope: SomeControllerScope, $http: ng.IHttpService, $q: ng.IQService) => { - $http.get("http://somewhere/some/resource") - .success((data: ExpectedResponse) => { - $scope.person = data; - }); + $http.get("http://somewhere/some/resource") + .then((response: ng.IHttpPromiseCallbackArg) => { + // typing lost, so something like + // var i: number = response.data + // would type check + $scope.person = response.data; + }); - $http.get("http://somewhere/some/resource") - .then((response: ng.IHttpPromiseCallbackArg) => { - // typing lost, so something like - // var i: number = response.data - // would type check - $scope.person = response.data; - }); + $http.get("http://somewhere/some/resource") + .then((response: ng.IHttpPromiseCallbackArg) => { + // typing lost, so something like + // var i: number = response.data + // would NOT type check + $scope.person = response.data; + }); - $http.get("http://somewhere/some/resource") - .then((response: OurApiPromiseCallbackArg) => { - // typing lost, so something like - // var i: number = response.data - // would NOT type check - $scope.person = response.data; - }); + var aPromise: ng.IPromise = $q.when({ firstName: "Jack", lastName: "Sparrow" }); + aPromise.then((person: Person) => { + $scope.person = person; + }); - var aPromise: ng.IPromise = $q.when({firstName: "Jack", lastName: "Sparrow"}); - aPromise.then((person: Person) => { - $scope.person = person; - }); + var bPromise: ng.IPromise = $q.when(42); + bPromise.then((answer: number) => { + $scope.theAnswer = answer; + }); - var bPromise: ng.IPromise = $q.when(42); - bPromise.then((answer: number) => { - $scope.theAnswer = answer; - }); - - var cPromise: ng.IPromise = $q.when(["a", "b", "c"]); - cPromise.then((letters: string[]) => { - $scope.letters = letters; - }); - } + var cPromise: ng.IPromise = $q.when(["a", "b", "c"]); + cPromise.then((letters: string[]) => { + $scope.letters = letters; + }); + } // Test that we can pass around a type-checked success/error Promise Callback var anotherController: Function = ($scope: SomeControllerScope, $http: - ng.IHttpService, $q: ng.IQService) => { + ng.IHttpService, $q: ng.IQService) => { - var buildFooData: Function = () => 42; + var buildFooData: Function = () => 42; - var doFoo: Function = (callback: ng.IHttpPromiseCallback) => { - $http.get('/foo', buildFooData()) - .success(callback); - } + var doFoo: Function = (callback: ng.IHttpPromiseCallback) => { + $http.get('/foo', buildFooData()) + .success(callback); + } doFoo((data) => console.log(data)); - } + } } // Test for AngularJS Syntac @@ -160,24 +156,24 @@ module My.Namespace { } // IModule Registering Test -var mod = angular.module('tests',[]); -mod.controller('name', function($scope : ng.IScope) {}) -mod.controller('name', ['$scope', function($scope : ng.IScope) {}]) +var mod = angular.module('tests', []); +mod.controller('name', function ($scope: ng.IScope) { }) +mod.controller('name', ['$scope', function ($scope: ng.IScope) { }]) mod.controller(My.Namespace); -mod.directive('name', function ($scope: ng.IScope) {}) -mod.directive('name', ['$scope', function($scope : ng.IScope) {}]) +mod.directive('name', function ($scope: ng.IScope) { }) +mod.directive('name', ['$scope', function ($scope: ng.IScope) { }]) mod.directive(My.Namespace); -mod.factory('name', function($scope : ng.IScope) {}) -mod.factory('name', ['$scope', function($scope : ng.IScope) {}]) +mod.factory('name', function ($scope: ng.IScope) { }) +mod.factory('name', ['$scope', function ($scope: ng.IScope) { }]) mod.factory(My.Namespace); -mod.filter('name', function($scope : ng.IScope) {}) -mod.filter('name', ['$scope', function($scope : ng.IScope) {}]) +mod.filter('name', function ($scope: ng.IScope) { }) +mod.filter('name', ['$scope', function ($scope: ng.IScope) { }]) mod.filter(My.Namespace); -mod.provider('name', function($scope : ng.IScope) {}) -mod.provider('name', ['$scope', function($scope : ng.IScope) {}]) +mod.provider('name', function ($scope: ng.IScope) { }) +mod.provider('name', ['$scope', function ($scope: ng.IScope) { }]) mod.provider(My.Namespace); -mod.service('name', function($scope : ng.IScope) {}) -mod.service('name', ['$scope', function($scope : ng.IScope) {}]) +mod.service('name', function ($scope: ng.IScope) { }) +mod.service('name', ['$scope', function ($scope: ng.IScope) { }]) mod.service(My.Namespace); mod.constant('name', 23); mod.constant('name', "23"); diff --git a/angularjs/angular.d.ts b/angularjs/angular.d.ts index 989c6d48d..bd58db401 100644 --- a/angularjs/angular.d.ts +++ b/angularjs/angular.d.ts @@ -8,6 +8,11 @@ declare var angular: ng.IAngularStatic; +// Support for painless dependency injection +interface Function { + $inject:string[]; +} + /////////////////////////////////////////////////////////////////////////////// // ng module (angular.js) /////////////////////////////////////////////////////////////////////////////// @@ -532,21 +537,21 @@ declare module ng { transformResponse?: any; } - interface IHttpPromiseCallback { - (data: any, status: number, headers: (headerName: string) => string, config: IRequestConfig): any; + interface IHttpPromiseCallback { + (data: T, status: number, headers: (headerName: string) => string, config: IRequestConfig): any; } - interface IHttpPromiseCallbackArg { - data?: any; + interface IHttpPromiseCallbackArg { + data?: T; status?: number; headers?: (headerName: string) => string; config?: IRequestConfig; } - interface IHttpPromise extends IPromise { - success(callback: IHttpPromiseCallback): IHttpPromise; - error(callback: IHttpPromiseCallback): IHttpPromise; - then(successCallback: (response: IHttpPromiseCallbackArg) => any, errorCallback?: (response: IHttpPromiseCallbackArg) => any): IPromise; + interface IHttpPromise extends IPromise { + success(callback: IHttpPromiseCallback): IHttpPromise; + error(callback: IHttpPromiseCallback): IHttpPromise; + then(successCallback: (response: IHttpPromiseCallbackArg) => any, errorCallback?: (response: IHttpPromiseCallbackArg) => any): IPromise; } interface IHttpProvider extends IServiceProvider { @@ -621,8 +626,9 @@ declare module ng { // see http://docs.angularjs.org/api/ng.$routeProvider#when for options explanations interface IRoute { controller?: any; + name?: string; template?: string; - templateUrl?: string; + templateUrl?: any; resolve?: any; redirectTo?: any; reloadOnSearch?: boolean; @@ -634,6 +640,8 @@ declare module ng { $scope: IScope; $template: string; }; + + params: any; } interface IRouteProvider extends IServiceProvider { @@ -688,6 +696,7 @@ declare module ng { constant(name: string, value: any): void; decorator(name: string, decorator: Function): void; + decorator(name: string, decoratorInline: any[]): void; factory(name: string, serviceFactoryFunction: Function): ng.IServiceProvider; provider(name: string, provider: ng.IServiceProvider): ng.IServiceProvider; provider(name: string, serviceProviderConstructor: Function): ng.IServiceProvider; diff --git a/bootstrap.timepicker/bootstrap.timepicker.d.ts b/bootstrap.timepicker/bootstrap.timepicker.d.ts new file mode 100644 index 000000000..868588276 --- /dev/null +++ b/bootstrap.timepicker/bootstrap.timepicker.d.ts @@ -0,0 +1,24 @@ + + +/// + +interface TimeickerOptions { + defaultTime?: string; + disableFocus?: boolean; + isOpen?: boolean; + minuteStep?: number; + modalBackdrop?: boolean; + secondStep?: number; + showSeconds?: boolean; + showInputs?: boolean; + showMeridian?: boolean; + template?: string; + appendWidgetTo?: string; +} + +interface JQuery { + timepicker(): JQuery; + timepicker(methodName: string): JQuery; + timepicker(methodName: string, params: any): JQuery; + timepicker(options: TimeickerOptions): JQuery; +} \ No newline at end of file diff --git a/bootstrap/bootstrap-tests.ts b/bootstrap/bootstrap-tests.ts index 80e638b26..71698101f 100644 --- a/bootstrap/bootstrap-tests.ts +++ b/bootstrap/bootstrap-tests.ts @@ -35,6 +35,11 @@ $('#myCollapsible').collapse({ toggle: false }); $('.carousel').carousel(); $('.carousel').carousel({ interval: 2000 }); -$('.typeahead').typeahead(); +$('.typeahead').typeahead({ + matcher: item => true, + sorter: (items: any[]) => items, + updater: item => item, + highlighter: item => "" +}); $('#navbar').affix(); \ No newline at end of file diff --git a/bootstrap/bootstrap.d.ts b/bootstrap/bootstrap.d.ts index 47ef378fd..c14bf61d4 100644 --- a/bootstrap/bootstrap.d.ts +++ b/bootstrap/bootstrap.d.ts @@ -32,6 +32,7 @@ interface TooltipOptions { title?: any; trigger?: string; delay?: any; + container?: any; } interface PopoverOptions { @@ -42,7 +43,8 @@ interface PopoverOptions { trigger?: string; title?: any; content?: any; - delay?: any; + delay?: any; + container?: any; } interface CollapseOptions { @@ -59,9 +61,10 @@ interface TypeaheadOptions { source?: any; items?: number; minLength?: number; - matcher?: () => any; - sorter?: () => any; - highlighter?: () => any; + matcher?: (item: any) => boolean; + sorter?: (items: any[]) => any[]; + updater?: (item: any) => any; + highlighter?: (item: any) => string; } interface AffixOptions { diff --git a/browser-harness/browser-harness-tests.ts b/browser-harness/browser-harness-tests.ts new file mode 100644 index 000000000..c36a186ca --- /dev/null +++ b/browser-harness/browser-harness-tests.ts @@ -0,0 +1,95 @@ +/// + +import harness = module('browser-harness'); + +harness.listen(4500); +harness.listen(4500, function(){}); +harness.config.retryMS = 50; +harness.config.timeoutMS = 1500; + +var browser = new harness.Browser({ type: 'chrome' }); +browser.open('http://localhost:8000/harness.html'); +browser.close(); + +harness.events.on('ready', function(driver){ + driver.events.on('console.log', function(text){ + console.log(text); + }); + + driver.events.on('console.warn', function(text){ + console.log(text); + }); + + driver.events.on('console.error', function(text){ + console.log(text); + }); + + driver.events.on('window.onerror', function(text){ + console.log(text); + }); + + driver.setUrl('http://localhost:8000'); + driver.setUrl('http://localhost:8000', function(){}); + + var element = driver.findElement('body'); + var html = element.html(); + element.addClass('test').click(); + + driver.findElements('div').removeClass('test'); + + driver.findVisible('html').findVisible('body').toggleClass('test'); + driver.findVisibles('div').hide().show(); + + driver.find('div').css('color', 'red', function(err, element){ + element.hide().show(); + }); + + driver.waitFor(function(){ + return false; + }); + + driver.waitFor(function(){ + return false; + }, function(){ + + }); + + driver.waitFor({ + condition: function(){ + + }, + + exec: function(){ + + }, + + timeoutMS: 1000 + }); + + driver.exec(function(){ + + }); + + driver.exec(function(){}, function(){}); + + driver.exec({ func: function(){}, args: [] }); + driver.exec({ func: function(){}, args: [] }, function(){}); +}); + +harness.events.once('ready', function(driver){ + driver.events.once('console.log', function(text){ + console.log(text); + }); + + driver.events.once('console.warn', function(text){ + console.log(text); + }); + + driver.events.once('console.error', function(text){ + console.log(text); + }); + + driver.events.once('window.onerror', function(text){ + console.log(text); + }); +}); \ No newline at end of file diff --git a/browser-harness/browser-harness.d.ts b/browser-harness/browser-harness.d.ts new file mode 100644 index 000000000..3a6389941 --- /dev/null +++ b/browser-harness/browser-harness.d.ts @@ -0,0 +1,133 @@ +// Type definitions for Browser Harness +// Project: https://github.com/scriby/browser-harness +// Definitions by: Chris Scribner +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare module "browser-harness" { + import events = module("events"); + + interface HarnessEvents extends events.NodeEventEmitter { + once(event: string, listener: (driver: Driver) => void); + once(event: 'ready', listener: (driver: Driver) => void); + + on(event: string, listener: (driver: Driver) => void); + on(event: 'ready', listener: (driver: Driver) => void); + } + + interface DriverEvents extends events.NodeEventEmitter { + once(event: string, listener: (text: string) => void); + once(event: 'console.log', listener: (text: string) => void); + once(event: 'console.warn', listener: (text: string) => void); + once(event: 'console.error', listener: (text: string) => void); + once(event: 'window.onerror', listener: (text: string) => void); + + on(event: string, listener: (text: string) => void); + on(event: 'console.log', listener: (text: string) => void); + on(event: 'console.warn', listener: (text: string) => void); + on(event: 'console.error', listener: (text: string) => void); + on(event: 'window.onerror', listener: (text: string) => void); + } + + export interface Driver { + exec(args: { func: Function; args?: any[]}, callback?: Function) : any; + exec(func: Function, callback?: Function) : any; + + setUrl(url: string, callback?: Function); + + waitFor(args: { condition: Function; exec?: Function; timeoutMS?: number }, callback?: Function); + waitFor(condition: Function, callback?: Function); + + findElement(selector: string, callback?: (err: Error, element: ElementProxy) => void): ElementProxy; + findElements(selector: string, callback?: (err: Error, elements: ElementProxy) => void): ElementProxy; + + findVisible(selector: string, callback?: (err: Error, element: ElementProxy) => void): ElementProxy; + findVisibles(selector: string, callback?: (err: Error, elements: ElementProxy) => void): ElementProxy; + find(selector: string, callback?: (err: Error, elements: ElementProxy) => void): ElementProxy; + + events: DriverEvents; + } + + export interface ElementProxy { + click(callback?: (err: Error, element: ElementProxy) => void) : ElementProxy + focus(callback?: (err: Error, element: ElementProxy) => void) : ElementProxy + blur(callback?: (err: Error, element: ElementProxy) => void) : ElementProxy + val(value?: string, callback?: (err: Error, element: ElementProxy) => void) : ElementProxy + attr(name: string, value?: string, callback?: (err: Error, element: ElementProxy) => void) : ElementProxy + removeAttr(name: string, callback?: (err: Error, element: ElementProxy) => void) : ElementProxy + prop(name: string, value?: string, callback?: (err: Error, element: ElementProxy) => void) : ElementProxy + removeProp(name: string, callback?: (err: Error, element: ElementProxy) => void) : ElementProxy + html(value?: string, callback?: (err: Error, element: ElementProxy) => void) : ElementProxy + text(value?: string, callback?: (err: Error, element: ElementProxy) => void) : ElementProxy + hasClass(className: string, callback?: (err: Error, element: ElementProxy) => void) : ElementProxy + addClass(className: string, callback?: (err: Error, element: ElementProxy) => void) : ElementProxy + removeClass(className: string, callback?: (err: Error, element: ElementProxy) => void) : ElementProxy + toggleClass(className: string, callback?: (err: Error, element: ElementProxy) => void) : ElementProxy + + trigger(event: string, extraParameters?: any, callback?: (err: Error, element: ElementProxy) => void) : ElementProxy + triggerHandler(event: string, extraParameters?: any, callback?: (err: Error, element: ElementProxy) => void) : ElementProxy + + css(name: string, value?: string, callback?: (err: Error, element: ElementProxy) => void) : ElementProxy + height(value?: any, callback?: (err: Error, element: ElementProxy) => void) : ElementProxy + innerHeight(value?: any, callback?: (err: Error, element: ElementProxy) => void) : ElementProxy + outerHeight(value?: any, callback?: (err: Error, element: ElementProxy) => void) : ElementProxy + width(value?: any, callback?: (err: Error, element: ElementProxy) => void) : ElementProxy + innerWidth(value?: any, callback?: (err: Error, element: ElementProxy) => void) : ElementProxy + outerWidth(value?: any, callback?: (err: Error, element: ElementProxy) => void) : ElementProxy + offset(value?: any, callback?: (err: Error, element: ElementProxy) => void) : ElementProxy + position(callback?: (err: Error, element: ElementProxy) => void) : ElementProxy + scrollLeft(value?: number, callback?: (err: Error, element: ElementProxy) => void) : ElementProxy + scrollTop(value?: number, callback?: (err: Error, element: ElementProxy) => void) : ElementProxy + + hide(callback?: (err: Error, element: ElementProxy) => void) : ElementProxy + show(callback?: (err: Error, element: ElementProxy) => void) : ElementProxy + toggle(callback?: (err: Error, element: ElementProxy) => void) : ElementProxy + + children(callback?: (err: Error, element: ElementProxy) => void) : ElementProxy + closest(callback?: (err: Error, element: ElementProxy) => void) : ElementProxy + contents(callback?: (err: Error, element: ElementProxy) => void) : ElementProxy + find(selector: string, callback?: (err: Error, element: ElementProxy) => void) : ElementProxy + findElements(selector: string, callback?: (err: Error, element: ElementProxy) => void) : ElementProxy + findElement(selector: string, callback?: (err: Error, element: ElementProxy) => void) : ElementProxy + findVisible(selector: string, callback?: (err: Error, element: ElementProxy) => void) : ElementProxy + findVisibles(selector: string, callback?: (err: Error, element: ElementProxy) => void) : ElementProxy + isActionable(callback?: (err: Error, element: ElementProxy) => void) : ElementProxy + first(callback?: (err: Error, element: ElementProxy) => void) : ElementProxy + has(arg: any, callback?: (err: Error, element: ElementProxy) => void) : ElementProxy + is(arg: any, callback?: (err: Error, element: ElementProxy) => void) : ElementProxy + last(callback?: (err: Error, element: ElementProxy) => void) : ElementProxy + next(selector?: string, callback?: (err: Error, element: ElementProxy) => void) : ElementProxy + nextAll(selector?: string, callback?: (err: Error, element: ElementProxy) => void) : ElementProxy + nextUntil(selector?: string, callback?: (err: Error, element: ElementProxy) => void) : ElementProxy + offsetParent(callback?: (err: Error, element: ElementProxy) => void) : ElementProxy + parent(selector?: string, callback?: (err: Error, element: ElementProxy) => void) : ElementProxy + parents(selector?: string, callback?: (err: Error, element: ElementProxy) => void) : ElementProxy + parentsUntil(selector?: string, callback?: (err: Error, element: ElementProxy) => void) : ElementProxy + prev(selector?: string, callback?: (err: Error, element: ElementProxy) => void) : ElementProxy + prevAll(selector?: string, callback?: (err: Error, element: ElementProxy) => void) : ElementProxy + prevUntil(selector?: string, callback?: (err: Error, element: ElementProxy) => void) : ElementProxy + siblings(selector?: string, callback?: (err: Error, element: ElementProxy) => void) : ElementProxy + + + data(name: string, value?: any, callback?: (err: Error, element: ElementProxy) => void) : ElementProxy + removeData(name: string, callback?: (err: Error, element: ElementProxy) => void) : ElementProxy + + filter(selector: any, callback?: (err: Error, element: ElementProxy) => void) : ElementProxy + } + + export class Browser { + //constructor(args: { type: string; location?: string; args?: string[] }); + constructor(args: { type: string; location?: string; args?: any; }); + + open(harnessUrl: string, serverUrl?: string); + close(); + } + + export function listen(port: number, callback?: Function) + export var events: HarnessEvents; + export var config: { + timeoutMS: number; + retryMS: number; + }; +} \ No newline at end of file diff --git a/greensock/greensock.d.ts b/greensock/greensock.d.ts index df8958be4..3cc3346af 100644 --- a/greensock/greensock.d.ts +++ b/greensock/greensock.d.ts @@ -1,139 +1,160 @@ // GreenSock Animation Platform (GSAP) - http://www.greensock.com/get-started-js/ // JavaScript Docs http://api.greensock.com/js/ -// Version 1.0 +// Version 1.1 (TypeScript 0.9) + +interface IDispatcher { + addEventListener(type:string, callback:Function, scope:Object, useParam:boolean, priority:number):void; + removeEventListener(type:string, callback:Function):void; +} //com.greensock.core -interface Animation { +declare class Animation { data:any; - ticker:any; + static ticker:IDispatcher; timeline:SimpleTimeline; vars:Object; - Animation(duration:number, vars?:Object); + constructor(duration?:number, vars?:Object); + delay(value:number):any; duration(value:number):any; eventCallback(type:string, callback?:Function, params?:any[], scope?:any):any; invalidate():any; kill(vars?:Object, target?:Object):any; - pause(atTime?:any, suppressEvents?:bool):any; - paused(value?:bool):any; - play(from?:any, suppressEvents?:bool):any; - restart(includeDelay?:bool, suppressEvents?:bool):any; - resume(from?:any, suppressEvents?:bool):any; - reverse(from?:any, suppressEvents?:bool):any; - reversed(value?:bool):any; - seek(time:any, suppressEvents?:bool):any; + pause(atTime?:any, suppressEvents?:boolean):any; + paused(value?:boolean):any; + play(from?:any, suppressEvents?:boolean):any; + restart(includeDelay?:boolean, suppressEvents?:boolean):any; + resume(from?:any, suppressEvents?:boolean):any; + reverse(from?:any, suppressEvents?:boolean):any; + reversed(value?:boolean):any; + seek(time:any, suppressEvents?:boolean):any; startTime(value:number):any; - time(value:number, suppressEvents?:bool):any; + time(value:number, suppressEvents?:boolean):any; timeScale(value:number):any; totalDuration(value:number):any; - totalTime(time:number, suppressEvents?:bool):any; + totalTime(time:number, suppressEvents?:boolean):any; } -interface SimpleTimeline extends Animation { - autoRemoveChildren:bool; - smoothChildTiming:bool; +declare class SimpleTimeline extends Animation { + autoRemoveChildren:boolean; + smoothChildTiming:boolean; + constructor(vars?:Object); + + add(value:any, position?:any, align?:string, stagger?:number):any; insert(tween:any, time:any):any; - render(time:number, suppressEvents?:bool, force?:bool):void; + render(time:number, suppressEvents?:boolean, force?:boolean):void; } //com.greensock -interface TimelineLite { - addLabel(label:string, time:number):any; - append(value:any, offset:number):any; - appendMultiple(tweens:any[], offset:number, align:string, stagger:number):any; - call(callback:Function, params?:any[], scope?:any, offset?:number, baseTimeOrLabel?:any):any; - clear(labels?:bool):any; - duration(value:number):any; - exportRoot(vars?:Object, omitDelayedCalls?:bool):TimelineLite; - from(target:Object, duration:number, vars:Object, offset:number, baseTimeOrLabel?:any):any; - fromTo(target:Object, duration:number, fromVars:Object, toVars:Object, offset:number, baseTimeOrLabel?:any):any; - getChildren(nested?:bool, tweens?:bool, timelines?:bool, ignoreBeforeTime?:number):any[]; - getLabelTime(label:string):number; - getTweensOf(target:Object, nested?:bool):any[]; - insert(value:any, timeOrLabel:any):any; - insertMultiple(tweens:any[], timeOrLabel:any, align:string, stagger:number):any; +declare class TweenLite extends Animation { + static defaultEase:Ease; + static defaultOverwrite:string; + static selector:any; + target:Object; + static ticker:IDispatcher; + timeline:SimpleTimeline; + vars:Object; + + constructor(target:Object, duration:number, vars:Object); + + static delayedCall(delay:number, callback:Function, params?:any[], scope?:any, useFrames?:boolean):TweenLite; + static from(target:Object, duration:number, vars:Object):TweenLite; + static fromTo(target:Object, duration:number, fromVars:Object, toVars:Object):TweenLite; + static getTweensOf(target:Object):any[]; invalidate():any; + static killDelayedCallsTo(func:Function):void; + static killTweensOf(target:Object, vars?:Object):void; + static set(target:Object, vars:Object):TweenLite; + static to(target:Object, duration:number, vars:Object):TweenLite; +} + +declare class TweenMax extends TweenLite { + static ticker:IDispatcher; + + constructor(target:Object, duration:number, vars:Object); + + static delayedCall(delay:number, callback:Function, params?:any[], scope?:any, useFrames?:boolean):TweenMax; + static from(target:Object, duration:number, vars:Object):TweenMax; + static fromTo(target:Object, duration:number, fromVars:Object, toVars:Object):TweenMax; + static getAllTweens(includeTimelines?:boolean):any[]; + static getTweensOf(target:Object):any[]; + invalidate():any; + static isTweening(target:Object):boolean; + static killAll(complete?:boolean, tweens?:boolean, delayedCalls?:boolean, timelines?:boolean):void; + static killChildTweensOf(parent:any, complete?:boolean):void; + static killDelayedCallsTo(func:Function):void; + static killTweensOf(target:Object, vars?:Object):void; + static pauseAll(tweens?:boolean, delayedCalls?:boolean, timelines?:boolean):void; + progress(value:number):any; + repeat(value:number):any; + repeatDelay(value:number):any; + static resumeAll(tweens?:boolean, delayedCalls?:boolean, timelines?:boolean):void; + static set(target:Object, vars:Object):TweenMax; + static staggerFrom(targets:Object[], duration:number, vars:Object, stagger:number, onCompleteAll?:Function, onCompleteAllParams?:any[], onCompleteAllScope?:any):any[]; + static staggerFromTo(targets:Object[], duration:number, fromVars:Object, toVars:Object, stagger:number, onCompleteAll?:Function, onCompleteAllParams?:any[], onCompleteAllScope?:any):any[]; + static staggerTo(targets:Object[], duration:number, vars:Object, stagger:number, onCompleteAll?:Function, onCompleteAllParams?:any[], onCompleteAllScope?:any):any[]; + time(value:number, suppressEvents?:boolean):any; + static to(target:Object, duration:number, vars:Object):TweenMax; + totalDuration(value:number):any; + totalProgress(value:number):any; + updateTo(vars:Object, resetDuration?:boolean):any; + yoyo(value?:boolean):any; +} + +declare class TimelineLite extends SimpleTimeline { + constructor(vars?:Object); + + add(value:any, position?:any, align?:string, stagger?:number):any + addLabel(label:string, position:any):any + addPause(position?:any, callback?:Function, params?:any[], scope?:any):any + append(value:any, offsetOrLabel?:any):any + appendMultiple(tweens:any[], offsetOrLabel?:any, align?:string, stagger?:number):any + call(callback:Function, params?:any[], scope?:any, position?:any):any + clear(labels?:boolean):any + duration(value:number):any + exportRoot(vars?:Object, omitDelayedCalls?:boolean):TimelineLite + fromTo(target:Object, duration:number, fromVars:Object, toVars:Object, position?:any):any + getChildren(nested?:boolean, tweens?:boolean, timelines?:boolean, ignoreBeforeTime?:number):any[]; + getLabelTime(label:string):number + getTweensOf(target:Object, nested?:boolean):any[]; + insert(value:any, timeOrLabel?:any):any + insertMultiple(tweens:any[], timeOrLabel?:any, align?:string, stagger?:number):any + invalidate():any progress(value:number):any; remove(value:any):any; removeLabel(label:string):any; - seek(timeOrLabel:any, suppressEvents?:bool):any; - set(target:Object, vars:Object, offset:number, baseTimeOrLabel?:any):any; - shiftChildren(amount:number, adjustLabels?:bool, ignoreBeforeTime?:number):any; - staggerFrom(targets:Object[], duration:number, vars:Object, stagger:number, offset:number, baseTimeOrLabel?:any, onCompleteAll?:Function, onCompleteAllParams?:any[], onCompleteAllScope?:any):any; - staggerFromTo(targets:Object[], duration:number, fromVars:Object, toVars:Object, stagger:number, offset:number, baseTimeOrLabel?:any, onCompleteAll?:Function, onCompleteAllParams?:any[], onCompleteAllScope?:any):any; - staggerTo(targets:Object[], duration:number, vars:Object, stagger:number, offset:number, baseTimeOrLabel?:any, onCompleteAll?:Function, onCompleteAllParams?:any[], onCompleteAllScope?:any):any; + seek(position:any, suppressEvents?:boolean):any; + shiftChildren(amount:number, adjustLabels?:boolean, ignoreBeforeTime?:number):any; + staggerFrom(targets:any[], duration:number, vars:Object, stagger?:number, position?:any, onCompleteAll?:Function, onCompleteAllParams?:any[], onCompleteScope?:any):any; + staggerFromTo(targets:any[], duration:number, fromVars:Object, toVars:Object, stagger?:number, position?:any, onCompleteAll?:Function, onCompleteAllParams?:any[], onCompleteAllScope?:any):any; + staggerTo(targets:any[], duration:number, vars:Object, stagger:number, position?:any, onCompleteAll?:Function, onCompleteAllParams?:any[], onCompleteAllScope?:any):any; stop():any; - to(target:Object, duration:number, vars:Object, offset:number, baseTimeOrLabel?:any):any; - totalDuration(value:number):any; - usesFrames():bool; + to(target:Object, duration:number, vars:Object, position?:any):any; + usesFrames():Boolean } -interface TimelineMax { - addCallback(callback:Function, timeOrLabel:any, params?:any[], scope?:any):TimelineMax; +declare class TimelineMax extends TimelineLite { + constructor(vars?:Object); + + addCallback(callback:Function, position:any, params?:any[], scope?:any):TimelineMax; currentLabel(value?:string):any; - getActive(nested?:bool, tweens?:bool, timelines?:bool):any[]; - getLabelAfter(time:number):string; - getLabelBefore(time:number):string; + getActive(nested?:boolean, tweens?:boolean, timelines?:boolean):any[]; + getLabelAfter(time:number):string + getLabelBefore(time:number):string getLabelsArray():any[]; invalidate():any; progress(value:number):any; - removeCallback(callback:Function, timeOrLabel?:any):TimelineMax; - repeat(value:number):any; - repeatDelay(value:number):any; - time(value:number, suppressEvents?:bool):any; + removeCallback(callback:Function, timeOrLabel?:any):TimelineMax + repeat(value?:number):any; + repeatDelay(value?:number):any; + time(value:number, suppressEvents?:boolean):any; totalDuration(value:number):any; totalProgress(value:number):any; - tweenFromTo(fromTimeOrLabel:any, toTimeOrLabel:any, vars?:Object):TweenLite; - tweenTo(timeOrLabel:any, vars?:Object):TweenLite; - yoyo(value?:bool):any; -} - -interface TweenLite extends Animation { - defaultEase:Ease; - defaultOverwrite:string; - target:Object; - ticker:any; - - delayedCall(delay:number, callback:Function, params?:any[], scope?:any, useFrames?:bool):TweenLite; - from(target:Object, duration:number, vars:Object):TweenLite; - fromTo(target:Object, duration:number, fromVars:Object, toVars:Object):TweenLite; - getTweensOf(target:Object):any[]; - invalidate():any; - killDelayedCallsTo(func:Function):void; - killTweensOf(target:Object, vars?:Object):void; - set(target:Object, vars:Object):TweenLite; - to(target:Object, duration:number, vars:Object):TweenLite; -} - -interface TweenMax extends TweenLite { - delayedCall(delay:number, callback:Function, params?:any[], scope?:any, useFrames?:bool):TweenMax; - from(target:Object, duration:number, vars:Object):TweenMax; - fromTo(target:Object, duration:number, fromVars:Object, toVars:Object):TweenMax; - getAllTweens(includeTimelines?:bool):any[]; - getTweensOf(target:Object):any[]; - invalidate():any; - isTweening(target:Object):bool; - killAll(complete?:bool, tweens?:bool, delayedCalls?:bool, timelines?:bool):void; - killChildTweensOf(parent:any, complete?:bool):void; - killDelayedCallsTo(func:Function):void; - killTweensOf(target:Object, vars?:Object):void; - pauseAll(tweens?:bool, delayedCalls?:bool, timelines?:bool):void; - progress(value:number):any; - repeat(value:number):any; - repeatDelay(value:number):any; - resumeAll(tweens?:bool, delayedCalls?:bool, timelines?:bool):void; - set(target:Object, vars:Object):TweenMax; - staggerFrom(targets:Object[], duration:number, vars:Object, stagger:number, onCompleteAll?:Function, onCompleteAllParams?:any[], onCompleteAllScope?:any):any[]; - staggerFromTo(targets:Object[], duration:number, fromVars:Object, toVars:Object, stagger:number, onCompleteAll?:Function, onCompleteAllParams?:any[], onCompleteAllScope?:any):any[]; - staggerTo(targets:Object[], duration:number, vars:Object, stagger:number, onCompleteAll?:Function, onCompleteAllParams?:any[], onCompleteAllScope?:any):any[]; - time(value:number, suppressEvents?:bool):any; - to(target:Object, duration:number, vars:Object):TweenMax; - totalDuration(value:number):any; - totalProgress(value:number):any; - updateTo(vars:Object, resetDuration?:bool):any; - yoyo(value?:bool):any; + tweenFromTo(fromPosition:any, toPosition:any, vars?:Object):TweenLite + tweenTo(position:any, vars?:Object):TweenLite + yoyo(value?:boolean):any; } //com.greensock.easing @@ -228,8 +249,8 @@ interface Sine { interface SlowMo { ease:SlowMo; - SlowMo(linearRatio:number, power:number, yoyoMode:bool); - config(linearRatio:number, power:number, yoyoMode:bool):SlowMo; + SlowMo(linearRatio:number, power:number, yoyoMode:boolean); + config(linearRatio:number, power:number, yoyoMode:boolean):SlowMo; getRatio(p:number):number; } interface SteppedEase { @@ -244,7 +265,7 @@ interface Strong { //com.greensock.plugins interface BezierPlugin extends TweenPlugin { - bezierThrough(values:any[], curviness?:number, quadratic?:bool, correlate?:string, prepend?:Object, calcDifs?:bool):Object; + bezierThrough(values:any[], curviness?:number, quadratic?:boolean, correlate?:string, prepend?:Object, calcDifs?:boolean):Object; cubicToQuadratic(a:number, b:number, c:number, d:number):any[]; quadraticToCubic(a:number, b:number, c:number):Object; } @@ -270,20 +291,9 @@ interface ScrollToPlugin extends TweenPlugin { } interface TweenPlugin { - activate(plugins:any[]):bool; + activate(plugins:any[]):boolean; } - -//com.greensock.core -declare var Animation:Animation; -declare var SimpleTimeline:SimpleTimeline; - -//com.greensock -declare var TimelineLite:TimelineLite; -declare var TimelineMax:TimelineMax; -declare var TweenLite:TweenLite; -declare var TweenMax:TweenMax; - //com.greensock.easing declare var Back:Back; declare var Bounce:Bounce; diff --git a/jquery/jquery.d.ts b/jquery/jquery.d.ts index e5ca2bd50..d3a4e04ce 100644 --- a/jquery/jquery.d.ts +++ b/jquery/jquery.d.ts @@ -411,7 +411,7 @@ interface JQuery { html(): string; html(htmlString: string): JQuery; html(htmlContent: (index: number, oldhtml: string) => string): JQuery; - html(JQuery): JQuery; + html(obj: JQuery): JQuery; prop(propertyName: string): any; prop(propertyName: string, value: any): JQuery; diff --git a/leaflet/leaflet.d.ts b/leaflet/leaflet.d.ts index 5d6825383..1b1ddfe8b 100644 --- a/leaflet/leaflet.d.ts +++ b/leaflet/leaflet.d.ts @@ -1538,7 +1538,7 @@ declare module L { /** * Function that will be used to decide whether to show a feature or not. */ - filter?: (featureData: any, layer: ILayer) => bool; + filter?: (featureData: any, layer: ILayer) => boolean; } @@ -2440,7 +2440,7 @@ declare module L { /** * Returns a function which always returns false. */ - static falseFn(): () => bool; + static falseFn(): () => boolean; /** * Returns the number num rounded to digits decimals. diff --git a/moment/moment.d.ts b/moment/moment.d.ts index e937f53df..3ad485934 100644 --- a/moment/moment.d.ts +++ b/moment/moment.d.ts @@ -68,8 +68,9 @@ interface Moment { subtract(soort: string, aantal: number): Moment; calendar(): string; + clone(): Moment; - valueOf(): string; + valueOf(): number; local(): Moment; // current date/time in local mode @@ -95,13 +96,13 @@ interface Moment { seconds(): number; milliseconds(ms: number): Moment; milliseconds(): number; - weekday(): Moment; + weekday(): number; weekday(d: number): Moment; - isoWeekday(): Moment; + isoWeekday(): number; isoWeekday(d: number): Moment; - weekYear(): Moment; + weekYear(): number; weekYear(d: number): Moment; - isoWeekYear(): Moment; + isoWeekYear(): number; isoWeekYear(d: number): Moment; from(f: Moment): string; @@ -232,7 +233,6 @@ interface MomentStatic { (date: number[]): Moment; (clone: Moment): Moment; - clone(): Moment; unix(timestamp: number): Moment; utc(): Moment; // current date/time in UTC mode diff --git a/node/node.d.ts b/node/node.d.ts index dfcbee7b7..d5d5e2d2e 100644 --- a/node/node.d.ts +++ b/node/node.d.ts @@ -72,7 +72,7 @@ interface EventEmitter { on(event: string, listener: Function); once(event: string, listener: Function): void; removeListener(event: string, listener: Function): void; - removeAllListener(event: string): void; + removeAllListeners(event?: string): void; setMaxListeners(n: number): void; listeners(event: string): { Function; }[]; emit(event: string, arg1?: any, arg2?: any): void; @@ -213,7 +213,7 @@ declare module "events" { on(event: string, listener: Function): any; once(event: string, listener: Function): void; removeListener(event: string, listener: Function): void; - removeAllListener(event: string): void; + removeAllListeners(event?: string): void; setMaxListeners(n: number): void; listeners(event: string): { Function; }[]; emit(event: string, arg1?: any, arg2?: any): void; @@ -224,7 +224,7 @@ declare module "events" { on(event: string, listener: Function): any; once(event: string, listener: Function): void; removeListener(event: string, listener: Function): void; - removeAllListener(event: string): void; + removeAllListener(sevent?: string): void; setMaxListeners(n: number): void; listeners(event: string): { Function; }[]; emit(event: string, arg1?: any, arg2?: any): void; @@ -333,7 +333,7 @@ declare module "cluster" { export function on(event: string, listener: Function): any; export function once(event: string, listener: Function): void; export function removeListener(event: string, listener: Function): void; - export function removeAllListener(event: string): void; + export function removeAllListeners(event?: string): void; export function setMaxListeners(n: number): void; export function listeners(event: string): { Function; }[]; export function emit(event: string, arg1?: any, arg2?: any): void; @@ -808,6 +808,7 @@ declare module "fs" { declare module "path" { export function normalize(p: string): string; export function join(...paths: any[]): string; + export function resolve(to: string); export function resolve(from: string, to: string): string; export function resolve(from: string, from2: string, to: string): string; export function resolve(from: string, from2: string, from3: string, to: string): string; diff --git a/persona/persona-tests.ts b/persona/persona-tests.ts new file mode 100644 index 000000000..1a62f1bc2 --- /dev/null +++ b/persona/persona-tests.ts @@ -0,0 +1,48 @@ +/// + + +// https://developer.mozilla.org/en-US/docs/Web/API/navigator.id.watch +navigator.id.watch({ + loggedInUser: 'bob@example.org', + onlogin: function(assertion: String) {}, + onlogout: function() {} +}); +navigator.id.watch({ + loggedInUser: 'bob@example.org', + onlogin: function(assertion: String) {}, + onlogout: function() {}, + onready: function() {} +}); + + +// https://developer.mozilla.org/en-US/docs/Web/API/navigator.id.request +navigator.id.request(); +navigator.id.request({siteName: 'Example Site', siteLogo: '/logo.png'}); +navigator.id.request({termsOfService: '/tos.html', privacyPolicy: '/privacy.html'}); +navigator.id.request({ + backgroundColor: '#rrggbb', + siteName: 'My Example Site', + siteLogo: '/logo.png', + termsOfService: '/tos.html', + privacyPolicy: '/privacy.html', + returnTo: '/welcome.html', + oncancel: function() {} +}); + + +// https://developer.mozilla.org/en-US/docs/Web/API/navigator.id.logout +navigator.id.logout(); + + +// https://developer.mozilla.org/en-US/docs/Web/API/navigator.id.get +var gotAssertion = function ( assertion: String ) {} +navigator.id.get(gotAssertion); +navigator.id.get(gotAssertion, {privacyPolicy: "/privacy.html", termsOfService: "/tos.html"}); +navigator.id.get(gotAssertion, { + backgroundColor: '#rrggbb', + siteName: 'My Example Site', + siteLogo: '/logo.png', + termsOfService: '/tos.html', + privacyPolicy: '/privacy.html' +}); + diff --git a/persona/persona.d.ts b/persona/persona.d.ts new file mode 100644 index 000000000..0e9dc15e3 --- /dev/null +++ b/persona/persona.d.ts @@ -0,0 +1,47 @@ +// Type definitions for Persona +// Project: http://www.mozilla.org/en-US/persona +// Definitions by: James Frasca +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare module Persona { + + export interface WatchOptions { + loggedInUser: String + onlogin: (String) => void + onlogout: () => void + onready?: () => void + } + + export interface RequestOptions { + backgroundColor?: String + siteName?: String + siteLogo?: String + termsOfService?: String + privacyPolicy?: String + returnTo?: String + oncancel?: () => void + } + + export interface GetOptions { + backgroundColor?: String + siteName?: String + siteLogo?: String + termsOfService?: String + privacyPolicy?: String + } + + export interface Persona { + watch( options: WatchOptions ): void + request( options: RequestOptions ): void + request(): void + logout(): void + get( gotAssertion: (String) => void ): void + get( gotAssertion: (String) => void, options: GetOptions ): void + } + +} + +interface Navigator { + id: Persona.Persona +} + diff --git a/requirejs/require.d.ts b/requirejs/require.d.ts index 711321b7d..109c0b1ae 100644 --- a/requirejs/require.d.ts +++ b/requirejs/require.d.ts @@ -81,11 +81,11 @@ interface RequireConfig { // If set to true, an error will be thrown if a script loads // that does not call define() or have shim exports string // value that can be checked. - enforceDefine?: bool; + enforceDefine?: boolean; // If set to true, document.createElementNS() will be used // to create script elements. - xhtml?: bool; + xhtml?: boolean; /** * Extra query string arguments appended to URLs that RequireJS @@ -204,7 +204,7 @@ interface RequireDefine { * Defines whether require js supports multiple versions of jQuery being loaded **/ amd: { - jQuery: bool; + jQuery: boolean; }; } @@ -212,4 +212,4 @@ interface RequireDefine { declare var require: Require; declare var requirejs: Require; declare var req: Require; -declare var define: RequireDefine; +declare var define: RequireDefine; diff --git a/restangular/restangular.d.ts b/restangular/restangular.d.ts index 96a74fd1e..770315ed8 100644 --- a/restangular/restangular.d.ts +++ b/restangular/restangular.d.ts @@ -8,9 +8,10 @@ interface Restangular extends RestangularCustom { one(route: string, id?: number): RestangularElement; + one(route: string, id?: string): RestangularElement; all(route: string): RestangularCollection; copy(fromElement: any): RestangularElement; - withConfig(configurer: any): RestangularElement; + withConfig(configurer: any): Restangular; } interface RestangularElement extends Restangular { @@ -31,6 +32,7 @@ interface RestangularElement extends Restangular { trace(queryParams?, headers?): ng.IPromise; options(queryParams?, headers?): ng.IPromise; patch(queryParams?, headers?): ng.IPromise; + getRestangularUrl(): string; } interface RestangularCollection extends Restangular { @@ -41,6 +43,7 @@ interface RestangularCollection extends Restangular { options(queryParams?, headers?): ng.IPromise; patch(queryParams?, headers?): ng.IPromise; putElement(idx, params, headers): ng.IPromise; + getRestangularUrl(): string; } interface RestangularCustom { @@ -67,4 +70,4 @@ interface RestangularProvider { } declare var Restangular: Restangular; -declare var RestangularProvider: RestangularProvider; \ No newline at end of file +declare var RestangularProvider: RestangularProvider; diff --git a/sharepoint/SharePoint.d.ts b/sharepoint/SharePoint.d.ts index 056087bed..00202da31 100644 --- a/sharepoint/SharePoint.d.ts +++ b/sharepoint/SharePoint.d.ts @@ -3,7 +3,6 @@ // Definitions by: Stanislav Vyshchepan and Andrey Markeev // Definitions: https://github.com/borisyankov/DefinitelyTyped - declare module Sys { export class EventArgs { static Empty: Sys.EventArgs; @@ -16,7 +15,7 @@ declare module Sys { /** Clears the contents of the string builder */ clear(): void; /** Indicates wherever the string builder is empty */ - isEmpty(): bool; + isEmpty(): boolean; /** Gets the contents of the string builder as a string */ toString(): string; } @@ -34,8 +33,86 @@ declare module Sys { } } module Net { - export class WebRequest { } - export class WebRequestExecutor { } + export class WebRequest { + get_url(): string; + set_url(value: string): void; + get_httpVerb(): string; + set_httpVerb(value: string): void; + get_timeout(): number; + set_timeout(value: number): void; + get_body(): string; + set_body(value: string): void; + get_headers(): { [key: string]: string; }; + get_userContext(): any; + set_userContext(value: any): void; + get_executor(): WebRequestExecutor; + set_executor(value: WebRequestExecutor): void; + + getResolvedUrl(); string; + invoke(): void; + completed(args: Sys.EventArgs): void; + + add_completed(handler: (executor: WebRequestExecutor, args: Sys.EventArgs) => void ): void; + remove_completed(handler: (executor: WebRequestExecutor, args: Sys.EventArgs) => void ): void; + } + + export class WebRequestExecutor { + get_aborted(): boolean; + get_responseAvailable(): boolean; + get_responseData(): string; + get_object(): any; + get_started(): boolean; + get_statusCode(): number; + get_statusText(): string; + get_timedOut(): boolean; + get_xml(): Document; + get_webRequest(): WebRequest; + abort(): void; + executeRequest(): void; + getAllResponseHeaders(): string; + getResponseHeader(key: string): string; + } + + export class NetworkRequestEventArgs extends EventArgs { + get_webRequest(): WebRequest; + } + + + export class WebRequestManager { + static get_defaultExecutorType(): string; + static set_defaultExecutorType(value: string): void; + static get_defaultTimeout(): number; + static set_defaultTimeout(value: number): void; + + static executeRequest(request: WebRequest):void; + static add_completedRequest(handler: (executor: WebRequestExecutor, args: Sys.EventArgs) => void ): void; + static remove_completedRequest(handler: (executor: WebRequestExecutor, args: Sys.EventArgs) => void ): void; + static add_invokingRequest(handler: (executor: WebRequestExecutor, args: NetworkRequestEventArgs) => void ): void; + static remove_invokingRequest(handler: (executor: WebRequestExecutor, args: NetworkRequestEventArgs ) => void ): void; + } + + export class WebServiceProxy { + static invoke( + servicePath: string, + methodName: string, + useGet?: boolean, + params?: any, + onSuccess?: (result: string, eventArgs: EventArgs) => void , + onFailure?: (error: WebServiceError) => void , + userContext?: any, + timeout?: number, + enableJsonp?: boolean, + jsonpCallbackParameter?: string): WebRequest; + } + + export class WebServiceError { + get_errorObject(): any; + get_exceptionType(): any; + get_message(): string; + get_stackTrace(): string; + get_statusCode(): number; + get_timedOut(): boolean; + } } interface IDisposable { dispose(): void; @@ -47,6 +124,139 @@ declare var $get: { (id: string): HTMLElement; }; declare var $addHandler: { (element: HTMLElement, eventName: string, handler: (e: Event) => void ): void; }; declare var $removeHandler: { (element: HTMLElement, eventName: string, handler: (e: Event) => void ): void; }; +declare module SP { + export class SOD { + static execute(fileName: string, functionName: string, ...args: any[]): void; + static executeFunc(fileName: string, typeName: string, fn: () => void ): void; + static executeOrDelayUntilEventNotified(func: Function, eventName: string): boolean; + static executeOrDelayUntilScriptLoaded(func: () => void , depScriptFileName: string): boolean; + static notifyScriptLoadedAndExecuteWaitingJobs(scriptFileName: string): void; + static notifyEventAndExecuteWaitingJobs(eventName: string, args?: any[]): void; + static registerSod(fileName: string, url: string): void; + static registerSodDep(fileName: string, dependentFileName: string): void; + static loadMultiple(keys: string[], fn: () => void , bSync?: boolean): void; + static delayUntilEventNotified(func: Function, eventName: string): void; + + static get_prefetch(): boolean; + static set_prefetch(value: boolean): void; + + static get_ribbonImagePrefetchEnabled(): boolean; + static set_ribbonImagePrefetchEnabled(value: boolean): void; + + + } +} + +/** Register function to rerun on partial update in MDS-enabled site.*/ +declare function RegisterModuleInit(scriptFileName: string, initFunc: () => void ): void; + +/** Provides access to url and query string parts.*/ +declare class JSRequest { + /** Query string parts.*/ + static QueryString: { [parameter: string]: string; }; + + /** initializes class.*/ + static EnsureSetup(): void; + + /** Current file name (after last '/' in url).*/ + static FileName: string; + + /** Current file path (before last '/' in url).*/ + static PathName: string; +} + +declare class _spPageContextInfo { + static alertsEnabled: boolean; //true + static allowSilverlightPrompt: string; //"True" + static clientServerTimeDelta: number; //-182 + static crossDomainPhotosEnabled: boolean; //true + static currentCultureName: string; //"ru-RU" + static currentLanguage: number; //1049 + static currentUICultureName: string; //"ru-RU" + static layoutsUrl: string; //"_layouts/15" + static pageListId: string; //"{06ee6d96-f27f-4160-b6bb-c18f187b18a7}" + static pagePersonalizationScope: string; //1 + static serverRequestPath: string; //"/SPTypeScript/Lists/ConditionalFormattingTasksList/AllItems.aspx" + static siteAbsoluteUrl: string; // "https://gandjustas-7b20d3715e8ed4.sharepoint.com" + static siteClientTag: string; //"0$$15.0.4454.1021" + static siteServerRelativeUrl: string; // "/" + static systemUserKey: string; //"i:0h.f|membership|10033fff84e7cb2b@live.com" + static tenantAppVersion: string; //"0" + static userId: number; //12 + static webAbsoluteUrl: string; //"https://gandjustas-7b20d3715e8ed4.sharepoint.com/SPTypeScript" + static webLanguage: number; //1049 + static webLogoUrl: string; //"/_layouts/15/images/siteIcon.png?rev=23" + static webPermMasks: { High: number; Low: number; }; + static webServerRelativeUrl: string; //"/SPTypeScript" + static webTemplate: string; //"17" + static webTitle: string; //"SPTypeScript" + static webUIVersion: number; //15 +} + +declare function STSHtmlEncode(value: string): string; + +declare function AddEvtHandler(element: HTMLElement, event: string, func: EventListener): void; + +/** Gets query string parameter */ +declare function GetUrlKeyValue(key: string): string; +declare module SP { + export enum RequestExecutorErrors { + requestAbortedOrTimedout, + unexpectedResponse, + httpError, + noAppWeb, + domainDoesNotMatch, + noTrustedOrigins, + iFrameLoadError + } + + export class RequestExecutor { + constructor(url: string, options?: any); + get_formDigestHandlingEnabled(): boolean; + set_formDigestHandlingEnabled(value: boolean): void; + get_iFrameSourceUrl(): string; + set_iFrameSourceUrl(value: string): void; + executeAsync(requestInfo:RequestInfo): void; + attemptLogin(returnUrl:string, success: (response: ResponseInfo) => void , error?: (response: ResponseInfo, error: RequestExecutorErrors, statusText: string) => void): void; + } + + export interface RequestInfo { + url: string; + method?: string; + headers?: { [key: string]: string; }; + /** Can be string or bytearray depending on binaryStringRequestBody field */ + body?: any; + binaryStringRequestBody?: boolean; + + /** Currently need fix to get ginary response. Details: http://techmikael.blogspot.ru/2013/07/how-to-copy-files-between-sites-using.html */ + binaryStringResponseBody?: boolean; + timeout?: number; + success?: (response: ResponseInfo) => void; + error?: (response: ResponseInfo, error: RequestExecutorErrors, statusText: string) => void; + state?: any; + } + + export interface ResponseInfo { + statusCode?: number; + statusText?: string; + responseAvailable: boolean; + allResponseHeaders?: string; + headers?: { [key: string]: string; }; + contentType?: string; + /** Can be string or bytearray depending on request.binaryStringResponseBody field */ + body?: any; + state?: any; + } + + export class ProxyWebRequestExecutor extends Sys.Net.WebRequestExecutor { + constructor(url: string, options?: any); + } + + export class ProxyWebRequestExecutorFactory implements SP.IWebRequestExecutorFactory { + constructor(url: string, options?: any); + createWebRequestExecutor(): ProxyWebRequestExecutor; + } +} interface MQuery { (selector: string, context?: any): MQueryResultSetElements; @@ -63,7 +273,7 @@ interface MQuery extend(target: any, ...objs: any[]): Object; extend(deep: boolean, target: any, ...objs: any[]): Object; - makeArray(obj: any): any[]; + makeArray(obj: any): any[]; isDefined(obj: any): boolean; isNotNull(obj: any): boolean; @@ -237,6 +447,7 @@ interface MQueryResultSetElements extends MQueryResultSet{ } interface MQueryResultSet { + [index: number]: T; contains(contained: T): boolean; filter(fn: (elementOfArray: T, indexInArray: number) => boolean, context?: any): MQueryResultSet; @@ -290,9 +501,9 @@ declare class CalloutActionOptions { @param action The action object */ onClickCallback: (event: Event, action: CalloutAction) => any; /** Callback which returns if the action link is enabled */ - isEnabledCallback: (action: CalloutAction) => bool; + isEnabledCallback: (action: CalloutAction) => boolean; /** Callback which returns if the action link is visible */ - isVisibleCallback: (action: CalloutAction) => bool; + isVisibleCallback: (action: CalloutAction) => boolean; /** Submenu entries for the action. If defined, the action link click will popup the specified menu. */ menuEntries: CalloutActionMenuEntry[]; } @@ -332,13 +543,13 @@ declare class CalloutAction { getToolTop(): string; getDisabledToolTip(): string; getOnClickCallback(): (event, action: CalloutAction) => any; - getIsDisabledCallback(): (action: CalloutAction) => bool; - getIsVisibleCallback(): (action: CalloutAction) => bool; - getIsMenu(): bool; + getIsDisabledCallback(): (action: CalloutAction) => boolean; + getIsVisibleCallback(): (action: CalloutAction) => boolean; + getIsMenu(): boolean; getMenuEntries(): CalloutActionMenuEntry[]; render(): void; - isEnabled(): bool; - isVisible(): bool; + isEnabled(): boolean; + isVisible(): boolean; set (options: CalloutActionOptions): void; } @@ -369,15 +580,15 @@ declare class Callout { /** Returns the position algorithm function defined for the callout during its creation. */ getPositionAlgorithm(): any; /** Specifies wherever callout is in "Opened" state */ - isOpen(): bool; + isOpen(): boolean; /** Specifies wherever callout is in "Opening" state */ - isOpening(): bool; + isOpening(): boolean; /** Specifies wherever callout is in "Opened" or "Opening" state */ - isOpenOrOpening(): bool; + isOpenOrOpening(): boolean; /** Specifies wherever callout is in "Closing" state */ - isClosing(): bool; + isClosing(): boolean; /** Specifies wherever callout is in "Closed" state */ - isClosed(): bool; + isClosed(): boolean; /** Returns the callout actions menu */ getActionMenu(): CalloutActionMenu; /** Adds a link to the actions panel in the bottom part of the callout window */ @@ -385,9 +596,9 @@ declare class Callout { /** Re-renders the actions menu. Call after the actions menu is changed. */ refreshActions(): void; /** Display the callout. Animation can be used only for IE9+ */ - open(useAnimation: bool); + open(useAnimation: boolean); /** Hide the callout. Animation can be used only for IE9+ */ - close(useAnimation: bool); + close(useAnimation: boolean); /** Display if hidden, hide if shown. */ toggle(): void; /** Do not call this directly. Instead, use CalloutManager.remove */ @@ -398,9 +609,9 @@ declare class CalloutOpenOptions { /** HTML event name, e.g. "click" */ event: string; /** Callout will be closed on blur */ - closeCalloutOnBlur: bool; + closeCalloutOnBlur: boolean; /** Close button will be shown within the callout window */ - showCloseButton: bool; + showCloseButton: boolean; } declare class CalloutOptions { @@ -448,17 +659,17 @@ declare class CalloutManager { static getFromLaunchPointIfExists(launchPoint: HTMLElement): Callout; /** Gets the first launch point within the specified ancestor element, and returns true if the associated with it callout is opened or opening. If the launch point is not found or the callout is hidden, returns false. */ - static containsOneCalloutOpen(ancestor: HTMLElement): bool; + static containsOneCalloutOpen(ancestor: HTMLElement): boolean; /** Finds the closest launch point based on the specified descendant element, and returns callout associated with the launch point. */ static getFromCalloutDescendant(descendant: HTMLElement): Callout; /** Perform some action for each callout on the page. */ static forEach(callback: (callout: Callout) => void); /** Closes all callouts on the page */ - static closeAll(): bool; + static closeAll(): boolean; /** Returns true if at least one of the defined on page callouts is opened. */ - static isAtLeastOneCalloutOpen(): bool; + static isAtLeastOneCalloutOpen(): boolean; /** Returns true if at least one of the defined on page callouts is opened or opening. */ - static isAtLeastOneCalloutOn(): bool; + static isAtLeastOneCalloutOn(): boolean; } @@ -533,14 +744,14 @@ declare module SPClientTemplates { /** Represents schema for a Lookup field in list form or in list view in grid mode */ export interface FieldSchema_InForm_Lookup extends FieldSchema_InForm { /** Specifies if the field allows multiple values */ - AllowMultipleValues: bool; + AllowMultipleValues: boolean; /** Returns base url for a list display form, e.g. "http://portal/web/_layouts/15/listform.aspx?PageType=4" You must add "ListId" (Guid of the list) and "ID" (integer Id of the item) parameters in order to use this Url */ BaseDisplayFormUrl: string; /** Indicates if the field is a dependent lookup */ - DependentLookup: bool; + DependentLookup: boolean; /** Indicates wherever the lookup list is throttled (contains more items than value of the "List Throttle Limit" setting). */ - Throttled: bool; + Throttled: boolean; /** Returns string representation of a number that represents the current value for the "List Throttle Limit" web application setting. Only appears if Throttled property is true, i.e. the target lookup list is throttled. */ MaxQueryResult: string; @@ -561,7 +772,7 @@ declare module SPClientTemplates { DisplayFormat: DateTimeDisplayFormat; /** Indicates wherever current user regional settings specify to display week numbers in day or week views of a calendar. Only appears for DateTime fields. */ - ShowWeekNumber: bool; + ShowWeekNumber: boolean; TimeSeparator: string; TimeZoneDifference: string; FirstDayOfWeek: number; @@ -572,39 +783,39 @@ declare module SPClientTemplates { LanguageId: string; MinJDay: number; MaxJDay: number; - HoursMode24: bool; + HoursMode24: boolean; HoursOptions: string[]; } /** Represents schema for a DateTime field in list form or in list view in grid mode */ export interface FieldSchema_InForm_Geolocation extends FieldSchema_InForm { BingMapsKey: string; - IsBingMapBlockedInCurrentRegion: bool; + IsBingMapBlockedInCurrentRegion: boolean; } /** Represents schema for a Choice field in list form or in list view in grid mode */ export interface FieldSchema_InForm_MultiChoice extends FieldSchema_InForm { /** List of choices for this field. */ MultiChoices: string[]; /** Indicates wherever fill-in choice is allowed */ - FillInChoice: bool; + FillInChoice: boolean; } /** Represents schema for a Choice field in list form or in list view in grid mode */ export interface FieldSchema_InForm_MultiLineText extends FieldSchema_InForm { /** Specifies whether rich text formatting can be used in the field */ - RichText: bool; + RichText: boolean; /** Changes are appended to the existing text. */ - AppendOnly: bool; + AppendOnly: boolean; /** Rich text mode for the field */ RichTextMode: RichTextMode; /** Number of lines configured to display */ NumberOfLines: number; /** A boolean value that specifies whether hyperlinks can be used in this fields. */ - AllowHyperlink: bool; + AllowHyperlink: boolean; /** WebPartAdderId for the ScriptEditorWebPart */ ScriptEditorAdderId: string; } /** Represents schema for a Number field in list form or in list view in grid mode */ export interface FieldSchema_InForm_Number extends FieldSchema_InForm { - ShowAsPercentage: bool; + ShowAsPercentage: boolean; } /** Represents schema for a Number field in list form or in list view in grid mode */ export interface FieldSchema_InForm_Text extends FieldSchema_InForm { @@ -616,23 +827,23 @@ declare module SPClientTemplates { } /** Represents schema for a Number field in list form or in list view in grid mode */ export interface FieldSchema_InForm_User extends FieldSchema_InForm { - Presence: bool; - WithPicture: bool; - DefaultRender: bool; - WithPictureDetail: bool; + Presence: boolean; + WithPicture: boolean; + DefaultRender: boolean; + WithPictureDetail: boolean; /** Server relative Url for ~site/_layouts/listform.aspx */ ListFormUrl: string; /** Server relative Url for ~site/_layouts/userdisp.aspx */ UserDisplayUrl: string; EntitySeparator: string; - PictureOnly: bool; + PictureOnly: boolean; PictureSize: string; } /** Represents field schema in Grid mode and on list forms. Consider casting objects of this type to more specific field types, e.g. FieldSchemaInForm_Lookup */ export interface FieldSchema_InForm { /** Specifies if the field can be edited while list view is in the Grid mode */ - AllowGridEditing: bool; + AllowGridEditing: boolean; /** Description for this field. */ Description: string; /** Direction of the reading order for the field. */ @@ -640,7 +851,7 @@ declare module SPClientTemplates { /** String representation of the field type, e.g. "Lookup". Same as SPField.TypeAsString */ FieldType: string; /** Indicates whether the field is hidden */ - Hidden: bool; + Hidden: boolean; /** Guid of the field */ Id: string; /** Specifies Input Method Editor (IME) mode bias to use for the field. @@ -649,17 +860,17 @@ declare module SPClientTemplates { /** Internal name of the field */ Name: string; /** Specifies if the field is read only */ - ReadOnlyField: bool; + ReadOnlyField: boolean; /** Specifies wherever field requires values */ - Required: bool; - RestrictedMode: bool; + Required: boolean; + RestrictedMode: boolean; /** Title of the field */ Title: string; /** For OOTB fields, returns the type of field. For "UserMulti" returns "User", for "LookupMulti" returns "Lookup". For custom field types, returns base type of the field. */ Type: string; /** If SPFarm.Local.UseMinWidthForHtmlPicker is true, UseMinWidth will be set to true. Undefined in other cases. */ - UseMinWidth: bool; + UseMinWidth: boolean; } export interface ListSchema_InForm { Field: FieldSchema_InForm[]; @@ -833,26 +1044,26 @@ declare module SPClientTemplates { CurrentItems: Item[]; } export interface RenderContext_InView extends RenderContext { - AllowCreateFolder: bool; - AllowGridMode: bool; - BasePermissions: { [PermissionName: string]: bool; }; // SP.BasePermissions? - bInitialRender: bool; - CanShareLinkForNewDocument: bool; + AllowCreateFolder: boolean; + AllowGridMode: boolean; + BasePermissions: { [PermissionName: string]: boolean; }; // SP.BasePermissions? + bInitialRender: boolean; + CanShareLinkForNewDocument: boolean; CascadeDeleteWarningMessage: string; clvp: HTMLElement; // not in View - ContentTypesEnabled: bool; + ContentTypesEnabled: boolean; ctxId: number; ctxType: any; // not in View CurrentUserId: number; - CurrentUserIsSiteAdmin: bool; + CurrentUserIsSiteAdmin: boolean; dictSel: any; /** Absolute path for the list display form */ displayFormUrl: string; /** Absolute path for the list edit form */ editFormUrl: string; - EnableMinorVersions: bool; - ExternalDataList: bool; - enteringGridMode: bool; + EnableMinorVersions: boolean; + ExternalDataList: boolean; + enteringGridMode: boolean; existingServerFilterHash: any; HasRelatedCascadeLists: number; heroId: string; // e.g. "idHomePageNewItem" @@ -860,19 +1071,19 @@ declare module SPClientTemplates { HttpRoot: string; imagesPath: string; inGridFullRender: any; // not in View - inGridMode: bool; - IsAppWeb: bool; - IsClientRendering: bool; - isForceCheckout: bool; - isModerated: bool; + inGridMode: boolean; + IsAppWeb: boolean; + IsClientRendering: boolean; + isForceCheckout: boolean; + isModerated: boolean; isPortalTemplate: any; isWebEditorPreview: number; isVersions: number; - isXslView: bool; + isXslView: boolean; LastRowIndexSelected: any; // not in View LastSelectableRowIdx: any; LastSelectedItemId: any; // not in View - leavingGridMode: bool; + leavingGridMode: boolean; listBaseType: number; ListData: ListData_InView; ListDataJSONItemsKey: string; // ="Row" @@ -882,21 +1093,21 @@ declare module SPClientTemplates { listTemplate: string; ListTitle: string; listUrlDir: string; - loadingAsyncData: bool; + loadingAsyncData: boolean; ModerationStatus: number; - NavigateForFormsPages: bool; + NavigateForFormsPages: boolean; /** Absolute path for the list new form */ newFormUrl: string; NewWOPIDocumentEnabled: any; NewWOPIDocumentUrl: any; - noGroupCollapse: bool; + noGroupCollapse: boolean; OfficialFileName: string; OfficialFileNames: string; overrideDeleteConfirmation: string; // not in View overrideFilterQstring: string; // not in View PortalUrl: string; queryString: any; - recursiveView: bool; + recursiveView: boolean; /** either 1 or 0 */ RecycleBinEnabled: number; RegionalSettingsTimeZoneBias: string; @@ -908,7 +1119,7 @@ declare module SPClientTemplates { SendToLocationUrl: string; serverUrl: any; SiteTitle: string; - StateInitDone: bool; + StateInitDone: boolean; TableCbxFocusHandler: any; TableMouseOverHandler: any; TotalListItems: any; @@ -916,7 +1127,7 @@ declare module SPClientTemplates { /** Guid of the view. */ view: string; viewTitle: string; - WorkflowAssociated: bool; + WorkflowAssociated: boolean; wpq: string; WriteSecurity: string; } @@ -1033,7 +1244,7 @@ declare module SPClientTemplates { ListTemplateType?: number; /** Base view ID (SPView.BaseViewID) for which the template should be applied. If not defined, the templates will be applied to all views. */ - BaseViewID?: number; + BaseViewID?: any; } export class TemplateManager { static RegisterTemplateOverrides(renderCtx: TemplateOverridesOptions): void; @@ -1064,7 +1275,7 @@ declare module SPClientTemplates { static FileSystemObjectTypeToString(fileSystemObjectType: SPClientTemplates.FileSystemObjectType): string; static ChoiceFormatTypeToString(fileSystemObjectType: SPClientTemplates.ChoiceFormatType): string; static RichTextModeToString(fileSystemObjectType: SPClientTemplates.RichTextMode): string; - static IsValidControlMode(mode: number): bool; + static IsValidControlMode(mode: number): boolean; /** Removes leading and trailing spaces */ static Trim(str: string): string; /** Creates SP.ClientContext based on the specified Web URL. If the SP.Runtime.js script is not loaded, returns null */ @@ -1079,7 +1290,7 @@ declare module SPClientTemplates { static ParseLookupValue(valueStr: string): ClientLookupValue; static ParseMultiLookupValues(valueStr: string): ClientLookupValue[]; /** Represents lookup values array in some strange format */ - static BuildLookupValuesAsString(choiceArray: ClientLookupValue[], isMultiLookup: bool, setGroupDesc: bool): string; + static BuildLookupValuesAsString(choiceArray: ClientLookupValue[], isMultiLookup: boolean, setGroupDesc: boolean): string; static ParseURLValue(value: string): ClientUrlValue; static GetFormContextForCurrentField(context: RenderContext_Form): ClientFormContext; } @@ -1090,11 +1301,11 @@ declare module SPClientTemplates { fieldName: string; controlMode: number; webAttributes: { - AllowScriptableWebParts: bool; + AllowScriptableWebParts: boolean; CurrentUserId: number; - EffectivePresenceEnabled: bool; + EffectivePresenceEnabled: boolean; LCID: string; - PermissionCustomizePages: bool; + PermissionCustomizePages: boolean; WebUrl: string; }; itemAttributes: { @@ -1107,7 +1318,7 @@ declare module SPClientTemplates { BaseType: number; DefaultItemOpen: number; Direction: string; - EnableVesioning: bool; + EnableVesioning: boolean; Id: string; }; registerInitCallback(fieldname: string, callback: () => void ): void; @@ -1130,7 +1341,7 @@ declare function CoreRender(template: any, context: any): string; declare module SPClientForms { module ClientValidation { export class ValidationResult { - constructor(hasErrors: bool, errorMsg: string); + constructor(hasErrors: boolean, errorMsg: string); } export class ValidatorSet { @@ -1148,10 +1359,86 @@ declare module SPClientForms { } +declare module SPAnimation { + export enum Attribute { + PositionX, + PositionY, + Height, + Width, + Opacity + } + + export enum ID { + Basic_Show, + Basic_SlowShow, + Basic_Fade, + Basic_Move, + Basic_Size, + Content_SlideInFadeInRight, + Content_SlideInFadeInRightInc, + Content_SlideOutFadeOutRight, + Content_SlideInFadeInLeft, + Content_SlideInFadeInLeftInc, + SmallObject_SlideInFadeInTop, + SmallObject_SlideInFadeInLeft, + Test_Instant, + Test_Hold, + Basic_Opacity, + Basic_QuickShow, + Basic_QuickFade, + Content_SlideInFadeInGeneric, + Basic_StrikeThrough, + SmallObject_SlideInFadeInBottom, + SmallObject_SlideOutFadeOutBottom, + Basic_QuickSize + } + + export class Settings { + static DisableAnimation(): void; + static DisableSessionAnimation(): void; + static IsAnimationEnabled(): boolean; + } + + + export class State { + SetAttribute(attributeId: Attribute, value: number); + GetAttribute(attributeId: Attribute): number; + GetDataIndex(attributeId: Attribute): number + } + + export class Object{ + constructor(animationID: ID, delay: number, element: HTMLElement, finalState: State, finishFunc?: (data: any) => void , data?: any); + constructor(animationID: ID, delay: number, element: HTMLElement[], finalState: State, finishFunc?: (data: any) => void , data?: any); + RunAnimation(): void; + } +} + +declare module SPAnimationUtility{ + export class BasicAnimator { + static FadeIn(element: HTMLElement, finishFunc?: (data: any) => void , data?: any): void; + static FadeOut (element: HTMLElement, finishFunc?: (data: any) => void , data?: any): void; + static Move(element: HTMLElement, posX:number, posY:number, finishFunc?: (data: any) => void , data?: any): void; + static StrikeThrough(element: HTMLElement, strikeThroughWidth: number, finishFunc?: (data: any) => void , data?: any): void; + static Resize(element: HTMLElement, newHeight: number, newWidth: number, finishFunc?: (data: any) => void , data?: any): void; + static CommonResize(element: HTMLElement, newHeight: number, newWidth: number, finishFunc: (data: any) => void , data: any, animationId:SPAnimation.ID): void; + static QuickResize(element: HTMLElement, newHeight: number, newWidth: number, finishFunc?: (data: any) => void , data?: any): void; + static ResizeContainerAndFillContent(element: HTMLElement, newHeight: number, newWidth: number, finishFunc: () => void , fAddToEnd: boolean): void; + static GetWindowScrollPosition(): { x: number; y: number; }; + static GetLeftOffset(element: HTMLElement): number; + static GetTopOffset(element: HTMLElement): number; + static GetRightOffset(element: HTMLElement): number; + static PositionElement(element: HTMLElement, topValue: number, leftValue: number, heightValue: number, widthValue: number): void; + static PositionAbsolute(element: HTMLElement): void; + static PositionRelative(element: HTMLElement): void; + static PositionRelativeExact(element: HTMLElement, topValue: number, leftValue: number, heightValue: number, widthValue: number): void; + static PositionAbsoluteExact(element: HTMLElement, topValue: number, leftValue: number, heightValue: number, widthValue: number): void; + static IsPositioned(element: HTMLElement): boolean; + } +} interface IEnumerator { get_current(): T; - moveNext(): bool; + moveNext(): boolean; reset(): void; } @@ -1161,19 +1448,19 @@ interface IEnumerable { declare module SP { export class ScriptUtility { - static isNullOrEmptyString(str: string): bool; - static isNullOrUndefined(obj: any): bool; - static isUndefined(obj: any): bool; + static isNullOrEmptyString(str: string): boolean; + static isNullOrUndefined(obj: any): boolean; + static isUndefined(obj: any): boolean; static truncateToInt(n: number): number; } export class Guid { constructor(guidText: string); static get_empty(): SP.Guid; static newGuid(): SP.Guid; - static isValid(uuid: string): bool; + static isValid(uuid: string): boolean; toString(): string; toString(format: string): string; - equals(uuid: SP.Guid): bool; + equals(uuid: SP.Guid): boolean; toSerialized(): string; } /** Specifies permissions that are used to define user roles. Represents SPBasePermissions class. */ @@ -1262,7 +1549,7 @@ declare module SP { } export interface IFromJson { fromJson(initValue: any): void; - customFromJson(initValue: any): bool; + customFromJson(initValue: any): boolean; } export class Base64EncodedByteArray { constructor(); @@ -1277,13 +1564,13 @@ declare module SP { startScope(): any; startIfTrue(): any; startIfFalse(): any; - get_testResult(): bool; + get_testResult(): boolean; fromJson(initValue: any): void; - customFromJson(initValue: any): bool; + customFromJson(initValue: any): boolean; } export class ClientObjectPropertyConditionalScope extends SP.ConditionalScopeBase { constructor(clientObject: SP.ClientObject, propertyName: string, comparisonOperator: string, valueToCompare: any); - constructor(clientObject: SP.ClientObject, propertyName: string, comparisonOperator: string, valueToCompare: any, allowAllActions: bool); + constructor(clientObject: SP.ClientObject, propertyName: string, comparisonOperator: string, valueToCompare: any, allowAllActions: boolean); } export class ClientResult { get_value(): any; @@ -1291,7 +1578,7 @@ declare module SP { constructor(); } export class BooleanResult { - get_value(): bool; + get_value(): boolean; constructor(); } export class CharResult { @@ -1370,7 +1657,7 @@ declare module SP { export class PageRequestFailedEventArgs extends Sys.EventArgs { get_executor(): Sys.Net.WebRequestExecutor; get_errorMessage(): string; - get_isErrorPage(): bool; + get_isErrorPage(): boolean; } export class PageRequestSucceededEventArgs extends Sys.EventArgs { get_executor(): Sys.Net.WebRequestExecutor; @@ -1586,13 +1873,13 @@ declare module SP { get_objectVersion(): string; set_objectVersion(value: string): void; fromJson(initValue: any): void; - customFromJson(initValue: any): bool; + customFromJson(initValue: any): boolean; retrieve(): void; refreshLoad(): void; retrieve(propertyNames: string[]): void; - isPropertyAvailable(propertyName: string): bool; - isObjectPropertyInstantiated(propertyName: string): bool; - get_serverObjectIsNull(): bool; + isPropertyAvailable(propertyName: string): boolean; + isObjectPropertyInstantiated(propertyName: string): boolean; + get_serverObjectIsNull(): boolean; get_typedObject(): SP.ClientObject; } export class ClientObjectData { @@ -1603,7 +1890,7 @@ declare module SP { } /** Provides a base class for a collection of objects on a remote client. */ export class ClientObjectCollection extends SP.ClientObject implements IEnumerable { - get_areItemsAvailable(): bool; + get_areItemsAvailable(): boolean; /** Gets the data for all of the items in the collection. */ retrieveItems(): SP.ClientObjectPrototype; /** Returns an enumerator that iterates through the collection. */ @@ -1618,7 +1905,7 @@ declare module SP { export class ClientObjectList extends SP.ClientObjectCollection { constructor(context: SP.ClientRuntimeContext, objectPath: SP.ObjectPath, childItemType: any); fromJson(initValue: any): void; - customFromJson(initValue: any): bool; + customFromJson(initValue: any): boolean; } export class ClientObjectPrototype { retrieve(): void; @@ -1646,8 +1933,8 @@ declare module SP { remove_requestSucceeded(value: (sender: any, args: SP.ClientRequestSucceededEventArgs) => void ): void; add_requestFailed(value: (sender: any, args: SP.ClientRequestFailedEventArgs) => void ): void; remove_requestFailed(value: (sender: any, args: SP.ClientRequestFailedEventArgs) => void ): void; - get_navigateWhenServerRedirect(): bool; - set_navigateWhenServerRedirect(value: bool): void; + get_navigateWhenServerRedirect(): boolean; + set_navigateWhenServerRedirect(value: boolean): void; } export class ClientRequestEventArgs extends Sys.EventArgs { get_request(): SP.ClientRequest; @@ -1670,8 +1957,8 @@ declare module SP { get_url(): string; get_viaUrl(): string; set_viaUrl(value: string): void; - get_formDigestHandlingEnabled(): bool; - set_formDigestHandlingEnabled(value: bool): void; + get_formDigestHandlingEnabled(): boolean; + set_formDigestHandlingEnabled(value: boolean): void; get_applicationName(): string; set_applicationName(value: string): void; get_clientTag(): string; @@ -1679,7 +1966,7 @@ declare module SP { get_webRequestExecutorFactory(): SP.IWebRequestExecutorFactory; set_webRequestExecutorFactory(value: SP.IWebRequestExecutorFactory): void; get_pendingRequest(): SP.ClientRequest; - get_hasPendingRequest(): bool; + get_hasPendingRequest(): boolean; add_executingWebRequest(value: (sender: any, args: SP.WebRequestEventArgs) => void ): void; remove_executingWebRequest(value: (sender: any, args: SP.WebRequestEventArgs) => void ): void; add_requestSucceeded(value: (sender: any, args: SP.ClientRequestSucceededEventArgs) => void ): void; @@ -1698,7 +1985,7 @@ declare module SP { addQuery(query: SP.ClientAction): void; addQueryIdAndResultObject(id: number, obj: any): void; parseObjectFromJsonString(json: string): any; - parseObjectFromJsonString(json: string, skipTypeFixup: bool): any; + parseObjectFromJsonString(json: string, skipTypeFixup: boolean): any; load(clientObject: SP.ClientObject): void; loadQuery(clientObjectCollection: SP.ClientObjectCollection, exp: string): any; load(clientObject: SP.ClientObject, ...exps: string[]): void; @@ -1715,9 +2002,9 @@ declare module SP { } export class ClientValueObject { fromJson(obj: any): void; - customFromJson(obj: any): bool; + customFromJson(obj: any): boolean; writeToXml(writer: SP.XmlWriter, serializationContext: SP.SerializationContext): void; - customWriteToXml(writer: SP.XmlWriter, serializationContext: SP.SerializationContext): bool; + customWriteToXml(writer: SP.XmlWriter, serializationContext: SP.SerializationContext): boolean; get_typeId(): string; } export class ClientValueObjectCollection extends SP.ClientValueObject implements IEnumerable { @@ -1731,8 +2018,8 @@ declare module SP { startTry(): any; startCatch(): any; startFinally(): any; - get_processed(): bool; - get_hasException(): bool; + get_processed(): boolean; + get_hasException(): boolean; get_errorMessage(): string; get_serverStackTrace(): string; get_serverErrorCode(): number; @@ -1891,7 +2178,7 @@ declare module SP { } export class ParseJSONUtil { static parseObjectFromJsonString(json: string): any; - static validateJson(text: string): bool; + static validateJson(text: string): boolean; } export enum DateTimeKind { unspecified, @@ -1922,9 +2209,9 @@ declare module SP { /** Provides a Unified Logging Service (ULS) that monitors log messages. */ export class ULS { /** Gets a value that indicates whether the Unified Logging Service (ULS) is enabled. */ - static get_enabled(): bool; + static get_enabled(): boolean; /** Sets a value that indicates whether the Unified Logging Service (ULS) is enabled. */ - static set_enabled(value: bool): void; + static set_enabled(value: boolean): void; /** Logs the specified debug message. This method logs the message with a time stamp. If any log messages are pending, this method also logs them. If the message cannot be logged, the message is added to the list of pending log messages. */ static log(debugMessage: string): void; @@ -1976,7 +2263,7 @@ declare module SP { get_appPrincipalId(): string; get_appWebFullUrl(): string; get_id(): SP.Guid; - get_inError(): bool; + get_inError(): boolean; get_startPage(): string; get_remoteAppUrl(): string; get_settingsPageUrl(): string; @@ -2073,9 +2360,9 @@ declare module SP { set (perm: SP.PermissionKind): void; clear(perm: SP.PermissionKind): void; clearAll(): void; - has(perm: SP.PermissionKind): bool; - equals(perm: SP.BasePermissions): bool; - hasPermissions(high: number, low: number): bool; + has(perm: SP.PermissionKind): boolean; + equals(perm: SP.BasePermissions): boolean; + hasPermissions(high: number, low: number): boolean; get_typeId(): string; writeToXml(writer: SP.XmlWriter, serializationContext: SP.SerializationContext): void; constructor(); @@ -2124,9 +2411,9 @@ declare module SP { the subfolders. */ static createAllFoldersQuery(): SP.CamlQuery; /** Returns true if the query returns dates in Coordinated Universal Time (UTC) format. */ - get_datesInUtc(): bool; + get_datesInUtc(): boolean; /** Sets a value that indicates whether the query returns dates in Coordinated Universal Time (UTC) format. */ - set_datesInUtc(value: bool): void; + set_datesInUtc(value: boolean): void; /** Server relative URL of a list folder from which results will be returned. */ get_folderServerRelativeUrl(): string; /** Sets a value that specifies the server relative URL of a list folder from which results will be returned. */ @@ -2205,67 +2492,67 @@ declare module SP { } export class ChangeQuery extends SP.ClientValueObject { constructor(); - constructor(allChangeObjectTypes: bool, allChangeTypes: bool); - get_add(): bool; - set_add(value: bool): void; - get_alert(): bool; - set_alert(value: bool): void; + constructor(allChangeObjectTypes: boolean, allChangeTypes: boolean); + get_add(): boolean; + set_add(value: boolean): void; + get_alert(): boolean; + set_alert(value: boolean): void; get_changeTokenEnd(): SP.ChangeToken; set_changeTokenEnd(value: SP.ChangeToken): void; get_changeTokenStart(): SP.ChangeToken; set_changeTokenStart(value: SP.ChangeToken): void; - get_contentType(): bool; - set_contentType(value: bool): void; - get_deleteObject(): bool; - set_deleteObject(value: bool): void; - get_field(): bool; - set_field(value: bool): void; - get_file(): bool; - set_file(value: bool): void; - get_folder(): bool; - set_folder(value: bool): void; - get_group(): bool; - set_group(value: bool): void; - get_groupMembershipAdd(): bool; - set_groupMembershipAdd(value: bool): void; - get_groupMembershipDelete(): bool; - set_groupMembershipDelete(value: bool): void; - get_item(): bool; - set_item(value: bool): void; - get_list(): bool; - set_list(value: bool): void; - get_move(): bool; - set_move(value: bool): void; - get_navigation(): bool; - set_navigation(value: bool): void; - get_rename(): bool; - set_rename(value: bool): void; - get_restore(): bool; - set_restore(value: bool): void; - get_roleAssignmentAdd(): bool; - set_roleAssignmentAdd(value: bool): void; - get_roleAssignmentDelete(): bool; - set_roleAssignmentDelete(value: bool): void; - get_roleDefinitionAdd(): bool; - set_roleDefinitionAdd(value: bool): void; - get_roleDefinitionDelete(): bool; - set_roleDefinitionDelete(value: bool): void; - get_roleDefinitionUpdate(): bool; - set_roleDefinitionUpdate(value: bool): void; - get_securityPolicy(): bool; - set_securityPolicy(value: bool): void; - get_site(): bool; - set_site(value: bool): void; - get_systemUpdate(): bool; - set_systemUpdate(value: bool): void; - get_update(): bool; - set_update(value: bool): void; - get_user(): bool; - set_user(value: bool): void; - get_view(): bool; - set_view(value: bool): void; - get_web(): bool; - set_web(value: bool): void; + get_contentType(): boolean; + set_contentType(value: boolean): void; + get_deleteObject(): boolean; + set_deleteObject(value: boolean): void; + get_field(): boolean; + set_field(value: boolean): void; + get_file(): boolean; + set_file(value: boolean): void; + get_folder(): boolean; + set_folder(value: boolean): void; + get_group(): boolean; + set_group(value: boolean): void; + get_groupMembershipAdd(): boolean; + set_groupMembershipAdd(value: boolean): void; + get_groupMembershipDelete(): boolean; + set_groupMembershipDelete(value: boolean): void; + get_item(): boolean; + set_item(value: boolean): void; + get_list(): boolean; + set_list(value: boolean): void; + get_move(): boolean; + set_move(value: boolean): void; + get_navigation(): boolean; + set_navigation(value: boolean): void; + get_rename(): boolean; + set_rename(value: boolean): void; + get_restore(): boolean; + set_restore(value: boolean): void; + get_roleAssignmentAdd(): boolean; + set_roleAssignmentAdd(value: boolean): void; + get_roleAssignmentDelete(): boolean; + set_roleAssignmentDelete(value: boolean): void; + get_roleDefinitionAdd(): boolean; + set_roleDefinitionAdd(value: boolean): void; + get_roleDefinitionDelete(): boolean; + set_roleDefinitionDelete(value: boolean): void; + get_roleDefinitionUpdate(): boolean; + set_roleDefinitionUpdate(value: boolean): void; + get_securityPolicy(): boolean; + set_securityPolicy(value: boolean): void; + get_site(): boolean; + set_site(value: boolean): void; + get_systemUpdate(): boolean; + set_systemUpdate(value: boolean): void; + get_update(): boolean; + set_update(value: boolean): void; + get_user(): boolean; + set_user(value: boolean): void; + get_view(): boolean; + set_view(value: boolean): void; + get_web(): boolean; + set_web(value: boolean): void; get_typeId(): string; writeToXml(writer: SP.XmlWriter, serializationContext: SP.SerializationContext): void; } @@ -2302,7 +2589,7 @@ declare module SP { listContentTypeDelete, } export class ChangeUser extends SP.Change { - get_activate(): bool; + get_activate(): boolean; get_userId(): number; } export class ChangeView extends SP.Change { @@ -2347,8 +2634,8 @@ declare module SP { get_fields(): SP.FieldCollection; get_group(): string; set_group(value: string): void; - get_hidden(): bool; - set_hidden(value: bool): void; + get_hidden(): boolean; + set_hidden(value: boolean): void; get_id(): SP.ContentTypeId; get_jSLink(): string; set_jSLink(value: string): void; @@ -2359,17 +2646,17 @@ declare module SP { get_newFormUrl(): string; set_newFormUrl(value: string): void; get_parent(): SP.ContentType; - get_readOnly(): bool; - set_readOnly(value: bool): void; + get_readOnly(): boolean; + set_readOnly(value: boolean): void; get_schemaXml(): string; get_schemaXmlWithResourceTokens(): string; set_schemaXmlWithResourceTokens(value: string): void; get_scope(): string; - get_sealed(): bool; - set_sealed(value: bool): void; + get_sealed(): boolean; + set_sealed(value: boolean): void; get_stringId(): string; get_workflowAssociations(): SP.Workflow.WorkflowAssociationCollection; - update(updateChildren: bool): void; + update(updateChildren: boolean): void; deleteObject(): void; } export class ContentTypeCollection extends SP.ClientObjectCollection { @@ -2545,8 +2832,8 @@ declare module SP { itemAt(index: number): SP.Feature; get_item(index: number): SP.Feature; getById(featureId: SP.Guid): SP.Feature; - add(featureId: SP.Guid, force: bool, featdefScope: SP.FeatureDefinitionScope): SP.Feature; - remove(featureId: SP.Guid, force: bool): void; + add(featureId: SP.Guid, force: boolean, featdefScope: SP.FeatureDefinitionScope): SP.Feature; + remove(featureId: SP.Guid, force: boolean): void; } export enum FeatureDefinitionScope { none, @@ -2555,38 +2842,38 @@ declare module SP { web, } export class Field extends SP.ClientObject { - get_canBeDeleted(): bool; + get_canBeDeleted(): boolean; get_defaultValue(): string; set_defaultValue(value: string): void; get_description(): string; set_description(value: string): void; get_direction(): string; set_direction(value: string): void; - get_enforceUniqueValues(): bool; - set_enforceUniqueValues(value: bool): void; + get_enforceUniqueValues(): boolean; + set_enforceUniqueValues(value: boolean): void; get_entityPropertyName(): string; - get_filterable(): bool; - get_fromBaseType(): bool; + get_filterable(): boolean; + get_fromBaseType(): boolean; get_group(): string; set_group(value: string): void; - get_hidden(): bool; - set_hidden(value: bool): void; + get_hidden(): boolean; + set_hidden(value: boolean): void; get_id(): SP.Guid; - get_indexed(): bool; - set_indexed(value: bool): void; + get_indexed(): boolean; + set_indexed(value: boolean): void; get_internalName(): string; get_jSLink(): string; set_jSLink(value: string): void; - get_readOnlyField(): bool; - set_readOnlyField(value: bool): void; - get_required(): bool; - set_required(value: bool): void; + get_readOnlyField(): boolean; + set_readOnlyField(value: boolean): void; + get_required(): boolean; + set_required(value: boolean): void; get_schemaXml(): string; set_schemaXml(value: string): void; get_schemaXmlWithResourceTokens(): string; get_scope(): string; - get_sealed(): bool; - get_sortable(): bool; + get_sealed(): boolean; + get_sortable(): boolean; get_staticName(): string; set_staticName(value: string): void; get_title(): string; @@ -2602,12 +2889,12 @@ declare module SP { get_validationMessage(): string; set_validationMessage(value: string): void; validateSetValue(item: SP.ListItem, value: string): void; - updateAndPushChanges(pushChangesToLists: bool): void; + updateAndPushChanges(pushChangesToLists: boolean): void; update(): void; deleteObject(): void; - setShowInDisplayForm(value: bool): void; - setShowInEditForm(value: bool): void; - setShowInNewForm(value: bool): void; + setShowInDisplayForm(value: boolean): void; + setShowInEditForm(value: boolean): void; + setShowInNewForm(value: boolean): void; } export class FieldCalculated extends SP.Field { get_dateFormat(): SP.DateTimeFieldFormatType; @@ -2624,8 +2911,8 @@ declare module SP { constructor(); } export class FieldMultiChoice extends SP.Field { - get_fillInChoice(): bool; - set_fillInChoice(value: bool): void; + get_fillInChoice(): boolean; + set_fillInChoice(value: boolean): void; get_mappings(): string; get_choices(): string[]; set_choices(value: string[]): void; @@ -2642,12 +2929,12 @@ declare module SP { getById(id: SP.Guid): SP.Field; add(field: SP.Field): SP.Field; addDependentLookup(displayName: string, primaryLookupField: SP.Field, lookupField: string): SP.Field; - addFieldAsXml(schemaXml: string, addToDefaultView: bool, options: SP.AddFieldOptions): SP.Field; + addFieldAsXml(schemaXml: string, addToDefaultView: boolean, options: SP.AddFieldOptions): SP.Field; getByInternalNameOrTitle(strName: string): SP.Field; } export class FieldComputed extends SP.Field { - get_enableLookup(): bool; - set_enableLookup(value: bool): void; + get_enableLookup(): boolean; + set_enableLookup(value: boolean): void; } export class FieldNumber extends SP.Field { get_maximumValue(): number; @@ -2685,12 +2972,12 @@ declare module SP { export class FieldGuid extends SP.Field { } export class FieldLink extends SP.ClientObject { - get_hidden(): bool; - set_hidden(value: bool): void; + get_hidden(): boolean; + set_hidden(value: boolean): void; get_id(): SP.Guid; get_name(): string; - get_required(): bool; - set_required(value: bool): void; + get_required(): boolean; + set_required(value: boolean): void; deleteObject(): void; } export class FieldLinkCollection extends SP.ClientObjectCollection { @@ -2708,10 +2995,10 @@ declare module SP { constructor(); } export class FieldLookup extends SP.Field { - get_allowMultipleValues(): bool; - set_allowMultipleValues(value: bool): void; - get_isRelationship(): bool; - set_isRelationship(value: bool): void; + get_allowMultipleValues(): boolean; + set_allowMultipleValues(value: boolean): void; + get_isRelationship(): boolean; + set_isRelationship(value: boolean): void; get_lookupField(): string; set_lookupField(value: string): void; get_lookupList(): string; @@ -2732,17 +3019,17 @@ declare module SP { constructor(); } export class FieldMultiLineText extends SP.Field { - get_allowHyperlink(): bool; - set_allowHyperlink(value: bool): void; - get_appendOnly(): bool; - set_appendOnly(value: bool): void; + get_allowHyperlink(): boolean; + set_allowHyperlink(value: boolean): void; + get_appendOnly(): boolean; + set_appendOnly(value: boolean): void; get_numberOfLines(): number; set_numberOfLines(value: number): void; - get_restrictedMode(): bool; - set_restrictedMode(value: bool): void; - get_richText(): bool; - set_richText(value: bool): void; - get_wikiLinking(): bool; + get_restrictedMode(): boolean; + set_restrictedMode(value: boolean): void; + get_richText(): boolean; + set_richText(value: boolean): void; + get_wikiLinking(): boolean; } export class FieldRatingScale extends SP.FieldMultiChoice { get_gridEndNumber(): number; @@ -2827,10 +3114,10 @@ declare module SP { constructor(); } export class FieldUser extends SP.FieldLookup { - get_allowDisplay(): bool; - set_allowDisplay(value: bool): void; - get_presence(): bool; - set_presence(value: bool): void; + get_allowDisplay(): boolean; + set_allowDisplay(value: boolean): void; + get_presence(): boolean; + set_presence(value: boolean): void; get_selectionGroup(): number; set_selectionGroup(value: number): void; get_selectionMode(): SP.FieldUserSelectionMode; @@ -2861,7 +3148,7 @@ declare module SP { /** Gets the ETag of the file */ get_eTag(): string; /** Specifies whether the file exists */ - get_exists(): bool; + get_exists(): boolean; get_length(): number; get_level(): SP.FileLevel; /** Specifies the SPListItem corresponding to this file if this file belongs to a doclib. Values for all fields are returned also. */ @@ -2899,7 +3186,7 @@ declare module SP { static getContentVerFromTag(context: SP.ClientRuntimeContext, contentTag: string): SP.IntResult; getLimitedWebPartManager(scope: SP.WebParts.PersonalizationScope): SP.WebParts.LimitedWebPartManager; moveTo(newUrl: string, flags: SP.MoveOperations): void; - copyTo(strNewUrl: string, bOverWrite: bool): void; + copyTo(strNewUrl: string, bOverWrite: boolean): void; saveBinary(parameters: SP.FileSaveBinaryInformation): void; deleteObject(): void; /** Moves the file to the recycle bin. MUST return the identifier of the new Recycle Bin item */ @@ -2916,8 +3203,8 @@ declare module SP { export class FileCreationInformation extends SP.ClientValueObject { get_content(): SP.Base64EncodedByteArray; set_content(value: SP.Base64EncodedByteArray): void; - get_overwrite(): bool; - set_overwrite(value: bool): void; + get_overwrite(): boolean; + set_overwrite(value: boolean): void; get_url(): string; set_url(value: string): void; get_typeId(): string; @@ -2930,8 +3217,8 @@ declare module SP { checkout, } export class FileSaveBinaryInformation extends SP.ClientValueObject { - get_checkRequiredFields(): bool; - set_checkRequiredFields(value: bool): void; + get_checkRequiredFields(): boolean; + set_checkRequiredFields(value: boolean): void; get_content(): SP.Base64EncodedByteArray; set_content(value: SP.Base64EncodedByteArray): void; get_eTag(): string; @@ -2953,7 +3240,7 @@ declare module SP { get_created(): Date; get_createdBy(): SP.User; get_iD(): number; - get_isCurrentVersion(): bool; + get_isCurrentVersion(): boolean; get_size(): number; get_url(): string; get_versionLabel(): string; @@ -3005,26 +3292,26 @@ declare module SP { } export class Principal extends SP.ClientObject { get_id(): number; - get_isHiddenInUI(): bool; + get_isHiddenInUI(): boolean; get_loginName(): string; get_title(): string; set_title(value: string): void; get_principalType(): SP.Utilities.PrincipalType; } export class Group extends SP.Principal { - get_allowMembersEditMembership(): bool; - set_allowMembersEditMembership(value: bool): void; - get_allowRequestToJoinLeave(): bool; - set_allowRequestToJoinLeave(value: bool): void; - get_autoAcceptRequestToJoinLeave(): bool; - set_autoAcceptRequestToJoinLeave(value: bool): void; - get_canCurrentUserEditMembership(): bool; - get_canCurrentUserManageGroup(): bool; - get_canCurrentUserViewMembership(): bool; + get_allowMembersEditMembership(): boolean; + set_allowMembersEditMembership(value: boolean): void; + get_allowRequestToJoinLeave(): boolean; + set_allowRequestToJoinLeave(value: boolean): void; + get_autoAcceptRequestToJoinLeave(): boolean; + set_autoAcceptRequestToJoinLeave(value: boolean): void; + get_canCurrentUserEditMembership(): boolean; + get_canCurrentUserManageGroup(): boolean; + get_canCurrentUserViewMembership(): boolean; get_description(): string; set_description(value: string): void; - get_onlyAllowMembersViewMembership(): bool; - set_onlyAllowMembersViewMembership(value: bool): void; + get_onlyAllowMembersViewMembership(): boolean; + set_onlyAllowMembersViewMembership(value: boolean): void; get_owner(): SP.Principal; set_owner(value: SP.Principal): void; get_ownerTitle(): string; @@ -3053,26 +3340,26 @@ declare module SP { constructor(); } export class InformationRightsManagementSettings extends SP.ClientObject { - get_allowPrint(): bool; - set_allowPrint(value: bool): void; - get_allowScript(): bool; - set_allowScript(value: bool): void; - get_allowWriteCopy(): bool; - set_allowWriteCopy(value: bool): void; - get_disableDocumentBrowserView(): bool; - set_disableDocumentBrowserView(value: bool): void; + get_allowPrint(): boolean; + set_allowPrint(value: boolean): void; + get_allowScript(): boolean; + set_allowScript(value: boolean): void; + get_allowWriteCopy(): boolean; + set_allowWriteCopy(value: boolean): void; + get_disableDocumentBrowserView(): boolean; + set_disableDocumentBrowserView(value: boolean): void; get_documentAccessExpireDays(): number; set_documentAccessExpireDays(value: number): void; get_documentLibraryProtectionExpireDate(): Date; set_documentLibraryProtectionExpireDate(value: Date): void; - get_enableDocumentAccessExpire(): bool; - set_enableDocumentAccessExpire(value: bool): void; - get_enableDocumentBrowserPublishingView(): bool; - set_enableDocumentBrowserPublishingView(value: bool): void; - get_enableGroupProtection(): bool; - set_enableGroupProtection(value: bool): void; - get_enableLicenseCacheExpire(): bool; - set_enableLicenseCacheExpire(value: bool): void; + get_enableDocumentAccessExpire(): boolean; + set_enableDocumentAccessExpire(value: boolean): void; + get_enableDocumentBrowserPublishingView(): boolean; + set_enableDocumentBrowserPublishingView(value: boolean): void; + get_enableGroupProtection(): boolean; + set_enableGroupProtection(value: boolean): void; + get_enableLicenseCacheExpire(): boolean; + set_enableLicenseCacheExpire(value: boolean): void; get_groupName(): string; set_groupName(value: string): void; get_licenseCacheExpireDays(): number; @@ -3094,10 +3381,10 @@ declare module SP { } export class SecurableObject extends SP.ClientObject { get_firstUniqueAncestorSecurableObject(): SP.SecurableObject; - get_hasUniqueRoleAssignments(): bool; + get_hasUniqueRoleAssignments(): boolean; get_roleAssignments(): SP.RoleAssignmentCollection; resetRoleInheritance(): void; - breakRoleInheritance(copyRoleAssignments: bool, clearSubscopes: bool): void; + breakRoleInheritance(copyRoleAssignments: boolean, clearSubscopes: boolean): void; } /** Represents display mode for a control or form */ export enum ControlMode { @@ -3111,7 +3398,7 @@ declare module SP { /** Gets item by id. */ getItemById(id: number): SP.ListItem; /** Gets a value that specifies whether the list supports content types. */ - get_allowContentTypes(): bool; + get_allowContentTypes(): boolean; /** Gets the list definition type on which the list is based. For lists based on OOTB list definitions, return value corresponds the SP.ListTemplateType enumeration. */ get_baseTemplate(): number; /** Gets base type for the list. */ @@ -3121,9 +3408,9 @@ declare module SP { /** Gets the content types that are associated with the list. */ get_contentTypes(): SP.ContentTypeCollection; /** Gets a value that specifies whether content types are enabled for the list. */ - get_contentTypesEnabled(): bool; + get_contentTypesEnabled(): boolean; /** Sets a value that specifies whether content types are enabled for the list. */ - set_contentTypesEnabled(value: bool): void; + set_contentTypesEnabled(value: boolean): void; /** Gets a value that specifies when the list was created. */ get_created(): Date; /** Gets the data source associated with the list, or null if the list is not a virtual list. */ @@ -3169,25 +3456,25 @@ declare module SP { /** Gets the effective base permissions for the current user, as they should be displayed in UI. This will only differ from EffectiveBasePermissions if ReadOnlyUI is set to true, and in all cases will be a subset of EffectiveBasePermissions. To put it another way, EffectiveBasePermissionsForUI will always be as or more restrictive than EffectiveBasePermissions. */ get_effectiveBasePermissionsForUI(): SP.BasePermissions; /** Gets a value that specifies whether list item attachments are enabled for the list. */ - get_enableAttachments(): bool; + get_enableAttachments(): boolean; /** Sets a value that specifies whether list item attachments are enabled for the list. */ - set_enableAttachments(value: bool): void; + set_enableAttachments(value: boolean): void; /** Gets a value that specifies whether new list folders can be added to the list. */ - get_enableFolderCreation(): bool; + get_enableFolderCreation(): boolean; /** Sets a value that specifies whether new list folders can be added to the list. */ - set_enableFolderCreation(value: bool): void; + set_enableFolderCreation(value: boolean): void; /** Gets a value that specifies whether minor versions are enabled for the list. */ - get_enableMinorVersions(): bool; + get_enableMinorVersions(): boolean; /** Sets a value that specifies whether minor versions are enabled for the list. */ - set_enableMinorVersions(value: bool): void; + set_enableMinorVersions(value: boolean): void; /** Gets a value that specifies whether content approval is enabled for the list. */ - get_enableModeration(): bool; + get_enableModeration(): boolean; /** Sets a value that specifies whether content approval is enabled for the list */ - set_enableModeration(value: bool): void; + set_enableModeration(value: boolean): void; /** Gets a value that specifies whether historical versions of list items and documents can be created in the list */ - get_enableVersioning(): bool; + get_enableVersioning(): boolean; /** Sets a value that specifies whether historical versions of list items and documents can be created in the list */ - set_enableVersioning(value: bool): void; + set_enableVersioning(value: boolean): void; /** The entity type name. */ get_entityTypeName(): string; /** Gets collection of event receiver objects associated with the list. */ @@ -3195,17 +3482,17 @@ declare module SP { /** Gets a value that specifies the collection of all fields in the list. */ get_fields(): SP.FieldCollection; /** Gets a value that indicates whether forced checkout is enabled for the document library. */ - get_forceCheckout(): bool; + get_forceCheckout(): boolean; /** Sets a value that indicates whether forced checkout is enabled for the document library */ - set_forceCheckout(value: bool): void; + set_forceCheckout(value: boolean): void; /** Gets collections of forms associated with the list. */ get_forms(): SP.FormCollection; /** Returns true if this is external list. */ - get_hasExternalDataSource(): bool; + get_hasExternalDataSource(): boolean; /** Gets wherever the list is hidden */ - get_hidden(): bool; + get_hidden(): boolean; /** Sets if the list is hidden from "All site contents" or not. */ - set_hidden(value: bool): void; + set_hidden(value: boolean): void; /** Gets id of the list */ get_id(): SP.Guid; /** Gets a value that specifies the URI for the icon of the list */ @@ -3215,27 +3502,27 @@ declare module SP { /** Settings of document library Information Rights Management (IRM) */ get_informationRightsManagementSettings(): SP.InformationRightsManagementSettings; /** Gets a value that specifies whether Information Rights Management (IRM) is enabled for the list. */ - get_irmEnabled(): bool; + get_irmEnabled(): boolean; /** Sets a value that specifies whether Information Rights Management (IRM) is enabled for the list. */ - set_irmEnabled(value: bool): void; + set_irmEnabled(value: boolean): void; /** Gets a value that specifies whether Information Rights Management (IRM) expiration is enabled for the list. */ - get_irmExpire(): bool; + get_irmExpire(): boolean; /** Sets a value that specifies whether Information Rights Management (IRM) expiration is enabled for the list. */ - set_irmExpire(value: bool): void; + set_irmExpire(value: boolean): void; /** Gets a value that specifies whether Information Rights Management (IRM) rejection is enabled for the list. */ - get_irmReject(): bool; + get_irmReject(): boolean; /** Sets a value that specifies whether Information Rights Management (IRM) rejection is enabled for the list. */ - set_irmReject(value: bool): void; + set_irmReject(value: boolean): void; /** Indicates whether this list should be treated as a top level navigation object or not. */ - get_isApplicationList(): bool; + get_isApplicationList(): boolean; /** Sets a value that indicates whether this list should be treated as a top level navigation object or not. */ - set_isApplicationList(value: bool): void; + set_isApplicationList(value: boolean): void; /** Gets a value that specifies whether the list is a gallery. */ - get_isCatalog(): bool; + get_isCatalog(): boolean; /** Gets a value that indicates whether the document library is a private list with restricted permissions, such as for Solutions. */ - get_isPrivate(): bool; + get_isPrivate(): boolean; /** Gets a value that indicates whether the list is designated as a default asset location for images or other files which the users upload to their wiki pages. */ - get_isSiteAssetsLibrary(): bool; + get_isSiteAssetsLibrary(): boolean; /** Gets a value that specifies the number of list items in the list */ get_itemCount(): number; /** Gets a value that specifies the last time a list item was deleted from the list. */ @@ -3247,17 +3534,17 @@ declare module SP { /** The entity type full name of the list item in the list. */ get_listItemEntityTypeFullName(): string; /** Gets a value that indicates whether the list in a Meeting Workspace site contains data for multiple meeting instances within the site */ - get_multipleDataList(): bool; + get_multipleDataList(): boolean; /** Sets a value that indicates whether the list in a Meeting Workspace site contains data for multiple meeting instances within the site */ - set_multipleDataList(value: bool): void; + set_multipleDataList(value: boolean): void; /** Gets a value that specifies that the crawler must not crawl the list */ - get_noCrawl(): bool; + get_noCrawl(): boolean; /** Sets a value that specifies that the crawler must not crawl the list */ - set_noCrawl(value: bool): void; + set_noCrawl(value: boolean): void; /** Gets a value that specifies whether the list appears on the Quick Launch of the site */ - get_onQuickLaunch(): bool; + get_onQuickLaunch(): boolean; /** Sets a value that specifies whether the list appears on the Quick Launch of the site */ - set_onQuickLaunch(value: bool): void; + set_onQuickLaunch(value: boolean): void; /** Gets a value that specifies the site that contains the list. */ get_parentWeb(): SP.Web; /** Gets a value that specifies the server-relative URL of the site that contains the list. */ @@ -3267,7 +3554,7 @@ declare module SP { /** Gets a value that specifies the list schema of the list. */ get_schemaXml(): string; /** Gets a value that indicates whether folders can be created within the list. */ - get_serverTemplateCanCreateFolders(): bool; + get_serverTemplateCanCreateFolders(): boolean; /** Gets a value that specifies the feature identifier of the feature that contains the list schema for the list. */ get_templateFeatureId(): SP.Guid; /** Gets the list title. You can determine list URL from it's root folder URL. */ @@ -3299,7 +3586,7 @@ declare module SP { @param newName The desired name the user typed @param privateView Boolean true when the user wants make a new view that's personal @param uri Url that keeps all the adhoc filter/sort inforatmion */ - saveAsNewView(oldName: string, newName: string, privateView: bool, uri: string): SP.StringResult; + saveAsNewView(oldName: string, newName: string, privateView: boolean, uri: string): SP.StringResult; /** Returns a collection of lookup fields that use this list as a data source and that have FieldLookup.IsRelationship set to true. */ getRelatedFields(): SP.RelatedFieldCollection; /** This member is reserved for internal use and is not intended to be used directly from your code. */ @@ -3447,7 +3734,7 @@ declare module SP { /** Sets the value of the field for the list item based on an implementation specific transformation of the value. */ parseAndSetFieldValue(fieldInternalName: string, value: string): void; /** Validates form values specified for the list item. Errors are returned through hasException and errorMessage properties of the ListItemFormUpdateValue objects */ - validateUpdateListItem(formValues: SP.ListItemFormUpdateValue[], bNewDocumentUpdate: bool): SP.ListItemFormUpdateValue[]; + validateUpdateListItem(formValues: SP.ListItemFormUpdateValue[], bNewDocumentUpdate: boolean): SP.ListItemFormUpdateValue[]; } export class ListItemCollection extends SP.ClientObjectCollection { itemAt(index: number): SP.ListItem; @@ -3489,25 +3776,25 @@ declare module SP { set_fieldName(value: string): void; get_fieldValue(): string; set_fieldValue(value: string): void; - get_hasException(): bool; - set_hasException(value: bool): void; + get_hasException(): boolean; + set_hasException(value: boolean): void; get_typeId(): string; writeToXml(writer: SP.XmlWriter, serializationContext: SP.SerializationContext): void; constructor(); } export class ListTemplate extends SP.ClientObject { - get_allowsFolderCreation(): bool; + get_allowsFolderCreation(): boolean; get_baseType(): SP.BaseType; get_description(): string; get_featureId(): SP.Guid; - get_hidden(): bool; + get_hidden(): boolean; get_imageUrl(): string; get_internalName(): string; - get_isCustomTemplate(): bool; + get_isCustomTemplate(): boolean; get_name(): string; - get_onQuickLaunch(): bool; + get_onQuickLaunch(): boolean; get_listTemplateTypeKind(): number; - get_unique(): bool; + get_unique(): boolean; } export class ListTemplateCollection extends SP.ClientObjectCollection { itemAt(index: number): SP.ListTemplate; @@ -3585,17 +3872,17 @@ declare module SP { export class Navigation extends SP.ClientObject { get_quickLaunch(): SP.NavigationNodeCollection; get_topNavigationBar(): SP.NavigationNodeCollection; - get_useShared(): bool; - set_useShared(value: bool): void; + get_useShared(): boolean; + set_useShared(value: boolean): void; getNodeById(id: number): SP.NavigationNode; } export class NavigationNode extends SP.ClientObject { get_children(): SP.NavigationNodeCollection; get_id(): number; - get_isDocLib(): bool; - get_isExternal(): bool; - get_isVisible(): bool; - set_isVisible(value: bool): void; + get_isDocLib(): boolean; + get_isExternal(): boolean; + get_isVisible(): boolean; + set_isVisible(value: boolean): void; get_title(): string; set_title(value: string): void; get_url(): string; @@ -3609,10 +3896,10 @@ declare module SP { add(parameters: SP.NavigationNodeCreationInformation): SP.NavigationNode; } export class NavigationNodeCreationInformation extends SP.ClientValueObject { - get_asLastNode(): bool; - set_asLastNode(value: bool): void; - get_isExternal(): bool; - set_isExternal(value: bool): void; + get_asLastNode(): boolean; + set_asLastNode(value: boolean): void; + get_isExternal(): boolean; + set_isExternal(value: boolean): void; get_previousNode(): SP.NavigationNode; set_previousNode(value: SP.NavigationNode): void; get_title(): string; @@ -3626,27 +3913,27 @@ declare module SP { export class ObjectSharingInformation extends SP.ClientObject { get_anonymousEditLink(): string; get_anonymousViewLink(): string; - get_canManagePermissions(): bool; - get_hasPendingAccessRequests(): bool; - get_hasPermissionLevels(): bool; - get_isSharedWithCurrentUser(): bool; - get_isSharedWithGuest(): bool; - get_isSharedWithMany(): bool; - get_isSharedWithSecurityGroup(): bool; + get_canManagePermissions(): boolean; + get_hasPendingAccessRequests(): boolean; + get_hasPermissionLevels(): boolean; + get_isSharedWithCurrentUser(): boolean; + get_isSharedWithGuest(): boolean; + get_isSharedWithMany(): boolean; + get_isSharedWithSecurityGroup(): boolean; get_pendingAccessRequestsLink(): string; getSharedWithUsers(): SP.ClientObjectList; - static getListItemSharingInformation(context: SP.ClientRuntimeContext, listID: SP.Guid, itemID: number, excludeCurrentUser: bool, excludeSiteAdmin: bool, excludeSecurityGroups: bool, retrieveAnonymousLinks: bool, retrieveUserInfoDetails: bool, checkForAccessRequests: bool): SP.ObjectSharingInformation; - static getWebSharingInformation(context: SP.ClientRuntimeContext, excludeCurrentUser: bool, excludeSiteAdmin: bool, excludeSecurityGroups: bool, retrieveAnonymousLinks: bool, retrieveUserInfoDetails: bool, checkForAccessRequests: bool): SP.ObjectSharingInformation; - static getObjectSharingInformation(context: SP.ClientRuntimeContext, securableObject: SP.SecurableObject, excludeCurrentUser: bool, excludeSiteAdmin: bool, excludeSecurityGroups: bool, retrieveAnonymousLinks: bool, retrieveUserInfoDetails: bool, checkForAccessRequests: bool, retrievePermissionLevels: bool): SP.ObjectSharingInformation; + static getListItemSharingInformation(context: SP.ClientRuntimeContext, listID: SP.Guid, itemID: number, excludeCurrentUser: boolean, excludeSiteAdmin: boolean, excludeSecurityGroups: boolean, retrieveAnonymousLinks: boolean, retrieveUserInfoDetails: boolean, checkForAccessRequests: boolean): SP.ObjectSharingInformation; + static getWebSharingInformation(context: SP.ClientRuntimeContext, excludeCurrentUser: boolean, excludeSiteAdmin: boolean, excludeSecurityGroups: boolean, retrieveAnonymousLinks: boolean, retrieveUserInfoDetails: boolean, checkForAccessRequests: boolean): SP.ObjectSharingInformation; + static getObjectSharingInformation(context: SP.ClientRuntimeContext, securableObject: SP.SecurableObject, excludeCurrentUser: boolean, excludeSiteAdmin: boolean, excludeSecurityGroups: boolean, retrieveAnonymousLinks: boolean, retrieveUserInfoDetails: boolean, checkForAccessRequests: boolean, retrievePermissionLevels: boolean): SP.ObjectSharingInformation; } export class ObjectSharingInformationUser extends SP.ClientObject { get_customRoleNames(): string; get_department(): string; get_email(): string; - get_hasEditPermission(): bool; - get_hasViewPermission(): bool; + get_hasEditPermission(): boolean; + get_hasViewPermission(): boolean; get_id(): number; - get_isSiteAdmin(): bool; + get_isSiteAdmin(): boolean; get_jobTitle(): string; get_loginName(): string; get_name(): string; @@ -3755,18 +4042,18 @@ declare module SP { get_digitGrouping(): string; get_firstDayOfWeek(): number; get_firstWeekOfYear(): number; - get_isEastAsia(): bool; - get_isRightToLeft(): bool; - get_isUIRightToLeft(): bool; + get_isEastAsia(): boolean; + get_isRightToLeft(): boolean; + get_isUIRightToLeft(): boolean; get_listSeparator(): string; get_localeId(): number; get_negativeSign(): string; get_negNumberMode(): number; get_pM(): string; get_positiveSign(): string; - get_showWeeks(): bool; + get_showWeeks(): boolean; get_thousandSeparator(): string; - get_time24(): bool; + get_time24(): boolean; get_timeMarkerPosition(): number; get_timeSeparator(): string; get_timeZone(): SP.TimeZone; @@ -3818,10 +4105,10 @@ declare module SP { export class RelatedItemManager extends SP.ClientObject { static getRelatedItems(context: SP.ClientRuntimeContext, SourceListName: string, SourceItemID: number): SP.RelatedItem[]; static getPageOneRelatedItems(context: SP.ClientRuntimeContext, SourceListName: string, SourceItemID: number): SP.RelatedItem[]; - static addSingleLink(context: SP.ClientRuntimeContext, SourceListName: string, SourceItemID: number, SourceWebUrl: string, TargetListName: string, TargetItemID: number, TargetWebUrl: string, TryAddReverseLink: bool): void; - static addSingleLinkToUrl(context: SP.ClientRuntimeContext, SourceListName: string, SourceItemID: number, TargetItemUrl: string, TryAddReverseLink: bool): void; - static addSingleLinkFromUrl(context: SP.ClientRuntimeContext, SourceItemUrl: string, TargetListName: string, TargetItemID: number, TryAddReverseLink: bool): void; - static deleteSingleLink(context: SP.ClientRuntimeContext, SourceListName: string, SourceItemID: number, SourceWebUrl: string, TargetListName: string, TargetItemID: number, TargetWebUrl: string, TryDeleteReverseLink: bool): void; + static addSingleLink(context: SP.ClientRuntimeContext, SourceListName: string, SourceItemID: number, SourceWebUrl: string, TargetListName: string, TargetItemID: number, TargetWebUrl: string, TryAddReverseLink: boolean): void; + static addSingleLinkToUrl(context: SP.ClientRuntimeContext, SourceListName: string, SourceItemID: number, TargetItemUrl: string, TryAddReverseLink: boolean): void; + static addSingleLinkFromUrl(context: SP.ClientRuntimeContext, SourceItemUrl: string, TargetListName: string, TargetItemID: number, TryAddReverseLink: boolean): void; + static deleteSingleLink(context: SP.ClientRuntimeContext, SourceListName: string, SourceItemID: number, SourceWebUrl: string, TargetListName: string, TargetItemID: number, TargetWebUrl: string, TryDeleteReverseLink: boolean): void; } export enum RelationshipDeleteBehaviorType { none, @@ -3856,7 +4143,7 @@ declare module SP { set_basePermissions(value: SP.BasePermissions): void; get_description(): string; set_description(value: string): void; - get_hidden(): bool; + get_hidden(): boolean; get_id(): number; get_name(): string; set_name(value: string): void; @@ -3910,17 +4197,17 @@ declare module SP { static getGlobalInstalledLanguages(context: SP.ClientRuntimeContext, compatibilityLevel: number): SP.Language[]; } export class Site extends SP.ClientObject { - get_allowDesigner(): bool; - set_allowDesigner(value: bool): void; - get_allowMasterPageEditing(): bool; - set_allowMasterPageEditing(value: bool): void; - get_allowRevertFromTemplate(): bool; - set_allowRevertFromTemplate(value: bool): void; - get_allowSelfServiceUpgrade(): bool; - set_allowSelfServiceUpgrade(value: bool): void; - get_allowSelfServiceUpgradeEvaluation(): bool; - set_allowSelfServiceUpgradeEvaluation(value: bool): void; - get_canUpgrade(): bool; + get_allowDesigner(): boolean; + set_allowDesigner(value: boolean): void; + get_allowMasterPageEditing(): boolean; + set_allowMasterPageEditing(value: boolean): void; + get_allowRevertFromTemplate(): boolean; + set_allowRevertFromTemplate(value: boolean): void; + get_allowSelfServiceUpgrade(): boolean; + set_allowSelfServiceUpgrade(value: boolean): void; + get_allowSelfServiceUpgradeEvaluation(): boolean; + set_allowSelfServiceUpgradeEvaluation(value: boolean): void; + get_canUpgrade(): boolean; get_compatibilityLevel(): number; get_eventReceivers(): SP.EventReceiverDefinitionCollection; get_features(): SP.FeatureCollection; @@ -3930,26 +4217,26 @@ declare module SP { get_owner(): SP.User; set_owner(value: SP.User): void; get_primaryUri(): string; - get_readOnly(): bool; + get_readOnly(): boolean; get_recycleBin(): SP.RecycleBinItemCollection; get_rootWeb(): SP.Web; get_serverRelativeUrl(): string; - get_shareByLinkEnabled(): bool; - get_showUrlStructure(): bool; - set_showUrlStructure(value: bool): void; - get_uIVersionConfigurationEnabled(): bool; - set_uIVersionConfigurationEnabled(value: bool): void; + get_shareByLinkEnabled(): boolean; + get_showUrlStructure(): boolean; + set_showUrlStructure(value: boolean): void; + get_uIVersionConfigurationEnabled(): boolean; + set_uIVersionConfigurationEnabled(value: boolean): void; get_upgradeInfo(): SP.UpgradeInfo; get_upgradeReminderDate(): Date; - get_upgrading(): bool; + get_upgrading(): boolean; get_url(): string; get_usage(): SP.UsageInfo; get_userCustomActions(): SP.UserCustomActionCollection; - updateClientObjectModelUseRemoteAPIsPermissionSetting(requireUseRemoteAPIs: bool): void; - needsUpgradeByType(versionUpgrade: bool, recursive: bool): SP.BooleanResult; - runHealthCheck(ruleId: SP.Guid, bRepair: bool, bRunAlways: bool): SP.SiteHealth.SiteHealthSummary; - createPreviewSPSite(upgrade: bool, sendemail: bool): void; - runUpgradeSiteSession(versionUpgrade: bool, queueOnly: bool, sendEmail: bool): void; + updateClientObjectModelUseRemoteAPIsPermissionSetting(requireUseRemoteAPIs: boolean): void; + needsUpgradeByType(versionUpgrade: boolean, recursive: boolean): SP.BooleanResult; + runHealthCheck(ruleId: SP.Guid, bRepair: boolean, bRunAlways: boolean): SP.SiteHealth.SiteHealthSummary; + createPreviewSPSite(upgrade: boolean, sendemail: boolean): void; + runUpgradeSiteSession(versionUpgrade: boolean, queueOnly: boolean, sendEmail: boolean): void; getChanges(query: SP.ChangeQuery): SP.ChangeCollection; openWeb(strUrl: string): SP.Web; openWebById(gWebId: SP.Guid): SP.Web; @@ -4052,8 +4339,8 @@ declare module SP { get_email(): string; set_email(value: string): void; get_groups(): SP.GroupCollection; - get_isSiteAdmin(): bool; - set_isSiteAdmin(value: bool): void; + get_isSiteAdmin(): boolean; + set_isSiteAdmin(value: boolean): void; get_userId(): SP.UserIdInfo; update(): void; } @@ -4150,21 +4437,21 @@ declare module SP { get_baseViewId(): string; get_contentTypeId(): SP.ContentTypeId; set_contentTypeId(value: SP.ContentTypeId): void; - get_defaultView(): bool; - set_defaultView(value: bool): void; - get_defaultViewForContentType(): bool; - set_defaultViewForContentType(value: bool): void; - get_editorModified(): bool; - set_editorModified(value: bool): void; + get_defaultView(): boolean; + set_defaultView(value: boolean): void; + get_defaultViewForContentType(): boolean; + set_defaultViewForContentType(value: boolean): void; + get_editorModified(): boolean; + set_editorModified(value: boolean): void; get_formats(): string; set_formats(value: string): void; - get_hidden(): bool; - set_hidden(value: bool): void; + get_hidden(): boolean; + set_hidden(value: boolean): void; get_htmlSchemaXml(): string; get_id(): SP.Guid; get_imageUrl(): string; - get_includeRootFolder(): bool; - set_includeRootFolder(value: bool): void; + get_includeRootFolder(): boolean; + set_includeRootFolder(value: boolean): void; get_viewJoins(): string; set_viewJoins(value: string): void; get_jSLink(): string; @@ -4173,28 +4460,28 @@ declare module SP { set_listViewXml(value: string): void; get_method(): string; set_method(value: string): void; - get_mobileDefaultView(): bool; - set_mobileDefaultView(value: bool): void; - get_mobileView(): bool; - set_mobileView(value: bool): void; + get_mobileDefaultView(): boolean; + set_mobileDefaultView(value: boolean): void; + get_mobileView(): boolean; + set_mobileView(value: boolean): void; get_moderationType(): string; - get_orderedView(): bool; - get_paged(): bool; - set_paged(value: bool): void; - get_personalView(): bool; + get_orderedView(): boolean; + get_paged(): boolean; + set_paged(value: boolean): void; + get_personalView(): boolean; get_viewProjectedFields(): string; set_viewProjectedFields(value: string): void; get_viewQuery(): string; set_viewQuery(value: string): void; - get_readOnlyView(): bool; - get_requiresClientIntegration(): bool; + get_readOnlyView(): boolean; + get_requiresClientIntegration(): boolean; get_rowLimit(): number; set_rowLimit(value: number): void; get_scope(): SP.ViewScope; set_scope(value: SP.ViewScope): void; get_serverRelativeUrl(): string; get_styleId(): string; - get_threaded(): bool; + get_threaded(): boolean; get_title(): string; set_title(value: string): void; get_toolbar(): string; @@ -4216,16 +4503,16 @@ declare module SP { add(parameters: SP.ViewCreationInformation): SP.View; } export class ViewCreationInformation extends SP.ClientValueObject { - get_paged(): bool; - set_paged(value: bool): void; - get_personalView(): bool; - set_personalView(value: bool): void; + get_paged(): boolean; + set_paged(value: boolean): void; + get_personalView(): boolean; + set_personalView(value: boolean): void; get_query(): string; set_query(value: string): void; get_rowLimit(): number; set_rowLimit(value: number): void; - get_setAsDefaultView(): bool; - set_setAsDefaultView(value: bool): void; + get_setAsDefaultView(): boolean; + set_setAsDefaultView(value: boolean): void; get_title(): string; set_title(value: string): void; get_viewFields(): string[]; @@ -4261,10 +4548,10 @@ declare module SP { gantt, } export class Web extends SP.SecurableObject { - get_allowDesignerForCurrentUser(): bool; - get_allowMasterPageEditingForCurrentUser(): bool; - get_allowRevertFromTemplateForCurrentUser(): bool; - get_allowRssFeeds(): bool; + get_allowDesignerForCurrentUser(): boolean; + get_allowMasterPageEditingForCurrentUser(): boolean; + get_allowRevertFromTemplateForCurrentUser(): boolean; + get_allowRssFeeds(): boolean; get_allProperties(): SP.PropertyValues; get_appInstanceId(): SP.Guid; get_associatedMemberGroup(): SP.Group; @@ -4283,10 +4570,10 @@ declare module SP { set_customMasterUrl(value: string): void; get_description(): string; set_description(value: string): void; - get_documentLibraryCalloutOfficeWebAppPreviewersDisabled(): bool; + get_documentLibraryCalloutOfficeWebAppPreviewersDisabled(): boolean; get_effectiveBasePermissions(): SP.BasePermissions; - get_enableMinimalDownload(): bool; - set_enableMinimalDownload(value: bool): void; + get_enableMinimalDownload(): boolean; + set_enableMinimalDownload(value: boolean): void; get_eventReceivers(): SP.EventReceiverDefinitionCollection; get_features(): SP.FeatureCollection; get_fields(): SP.FieldCollection; @@ -4301,33 +4588,33 @@ declare module SP { get_navigation(): SP.Navigation; get_parentWeb(): SP.WebInformation; get_pushNotificationSubscribers(): SP.PushNotificationSubscriberCollection; - get_quickLaunchEnabled(): bool; - set_quickLaunchEnabled(value: bool): void; + get_quickLaunchEnabled(): boolean; + set_quickLaunchEnabled(value: boolean): void; get_recycleBin(): SP.RecycleBinItemCollection; - get_recycleBinEnabled(): bool; + get_recycleBinEnabled(): boolean; get_regionalSettings(): SP.RegionalSettings; get_roleDefinitions(): SP.RoleDefinitionCollection; get_rootFolder(): SP.Folder; - get_saveSiteAsTemplateEnabled(): bool; - set_saveSiteAsTemplateEnabled(value: bool): void; + get_saveSiteAsTemplateEnabled(): boolean; + set_saveSiteAsTemplateEnabled(value: boolean): void; get_serverRelativeUrl(): string; set_serverRelativeUrl(value: string): void; - get_showUrlStructureForCurrentUser(): bool; + get_showUrlStructureForCurrentUser(): boolean; get_siteGroups(): SP.GroupCollection; get_siteUserInfoList(): SP.List; get_siteUsers(): SP.UserCollection; get_supportedUILanguageIds(): number[]; - get_syndicationEnabled(): bool; - set_syndicationEnabled(value: bool): void; + get_syndicationEnabled(): boolean; + set_syndicationEnabled(value: boolean): void; get_themeInfo(): SP.ThemeInfo; get_title(): string; set_title(value: string): void; - get_treeViewEnabled(): bool; - set_treeViewEnabled(value: bool): void; + get_treeViewEnabled(): boolean; + set_treeViewEnabled(value: boolean): void; get_uIVersion(): number; set_uIVersion(value: number): void; - get_uIVersionConfigurationEnabled(): bool; - set_uIVersionConfigurationEnabled(value: bool): void; + get_uIVersionConfigurationEnabled(): boolean; + set_uIVersionConfigurationEnabled(value: boolean): void; get_url(): string; get_userCustomActions(): SP.UserCustomActionCollection; get_webs(): SP.WebCollection; @@ -4344,7 +4631,7 @@ declare module SP { doesPushNotificationSubscriberExist(deviceAppInstanceId: SP.Guid): SP.BooleanResult; getPushNotificationSubscriber(deviceAppInstanceId: SP.Guid): SP.PushNotificationSubscriber; getUserById(userId: number): SP.User; - getAvailableWebTemplates(lcid: number, doIncludeCrossLanguage: bool): SP.WebTemplateCollection; + getAvailableWebTemplates(lcid: number, doIncludeCrossLanguage: boolean): SP.WebTemplateCollection; getCatalog(typeCatalog: number): SP.List; getChanges(query: SP.ChangeQuery): SP.ChangeCollection; applyWebTemplate(webTemplate: string): void; @@ -4362,7 +4649,7 @@ declare module SP { loadApp(appPackageStream: any[], installationLocaleLCID: number): SP.AppInstance; loadAndInstallApp(appPackageStream: any[]): SP.AppInstance; ensureUser(logonName: string): SP.User; - applyTheme(colorPaletteUrl: string, fontSchemeUrl: string, backgroundImageUrl: string, shareGenerated: bool): void; + applyTheme(colorPaletteUrl: string, fontSchemeUrl: string, backgroundImageUrl: string, shareGenerated: boolean): void; } export class WebCollection extends SP.ClientObjectCollection { itemAt(index: number): SP.Web; @@ -4378,8 +4665,8 @@ declare module SP { set_title(value: string): void; get_url(): string; set_url(value: string): void; - get_useSamePermissionsAsParentSite(): bool; - set_useSamePermissionsAsParentSite(value: bool): void; + get_useSamePermissionsAsParentSite(): boolean; + set_useSamePermissionsAsParentSite(value: boolean): void; get_webTemplate(): string; set_webTemplate(value: string): void; get_typeId(): string; @@ -4430,9 +4717,9 @@ declare module SP { get_displayCategory(): string; get_id(): number; get_imageUrl(): string; - get_isHidden(): bool; - get_isRootWebOnly(): bool; - get_isSubWebOnly(): bool; + get_isHidden(): boolean; + get_isRootWebOnly(): boolean; + get_isSubWebOnly(): boolean; get_lcid(): number; get_name(): string; get_title(): string; @@ -4465,11 +4752,11 @@ declare module SP { static getDefaultFormsInformation(requestor: SP.Application.UI.DefaultFormsInformationRequestor, listId: SP.Guid): void; } export class ViewSelectorMenuOptions { - showRepairView: bool; - showMergeView: bool; - showEditView: bool; - showCreateView: bool; - showApproverView: bool; + showRepairView: boolean; + showMergeView: boolean; + showEditView: boolean; + showCreateView: boolean; + showApproverView: boolean; listId: string; viewId: string; viewParameters: string; @@ -4567,7 +4854,7 @@ declare module SP { get_messageAsText(): string; get_ruleHelpLink(): string; get_ruleId(): SP.Guid; - get_ruleIsRepairable(): bool; + get_ruleIsRepairable(): boolean; get_ruleName(): string; get_status(): SP.SiteHealth.SiteHealthStatusType; set_status(value: SP.SiteHealth.SiteHealthStatusType): void; @@ -4603,8 +4890,8 @@ declare module Microsoft.SharePoint.Client.Search { get_blockDedupeMode: () => number; set_blockDedupeMode: (value: number) => void; - get_bypassResultTypes: () => bool; - set_bypassResultTypes: (value: bool) => void; + get_bypassResultTypes: () => boolean; + set_bypassResultTypes: (value: boolean) => void; get_clientType: () => string; set_clientType: (value: string) => void; @@ -4615,34 +4902,34 @@ declare module Microsoft.SharePoint.Client.Search { get_desiredSnippetLength: () => number; set_desiredSnippetLength: (value: number) => void; - get_enableInterleaving: () => bool; - set_enableInterleaving: (value: bool) => void; + get_enableInterleaving: () => boolean; + set_enableInterleaving: (value: boolean) => void; - get_enableNicknames: () => bool; - set_enableNicknames: (value: bool) => void; + get_enableNicknames: () => boolean; + set_enableNicknames: (value: boolean) => void; - get_enableOrderingHitHighlightedProperty: () => bool; - set_enableOrderingHitHighlightedProperty: (value: bool) => void; + get_enableOrderingHitHighlightedProperty: () => boolean; + set_enableOrderingHitHighlightedProperty: (value: boolean) => void; - get_enablePhonetic: () => bool; - set_enablePhonetic: (value: bool) => void; + get_enablePhonetic: () => boolean; + set_enablePhonetic: (value: boolean) => void; - get_enableQueryRules: () => bool; - set_enableQueryRules: (value: bool) => void; + get_enableQueryRules: () => boolean; + set_enableQueryRules: (value: boolean) => void; - get_enableStemming: () => bool; - set_enableStemming: (value: bool) => void; + get_enableStemming: () => boolean; + set_enableStemming: (value: boolean) => void; - get_generateBlockRankLog: () => bool; - set_generateBlockRankLog: (value: bool) => void; + get_generateBlockRankLog: () => boolean; + set_generateBlockRankLog: (value: boolean) => void; get_hitHighlightedMultivaluePropertyLimit: () => number; set_hitHighlightedMultivaluePropertyLimit: (value: number) => void; get_hitHighlightedProperties: () => StringCollection; - get_ignoreSafeQueryPropertiesTemplateUrl: () => bool; - set_ignoreSafeQueryPropertiesTemplateUrl: (value: bool) => void; + get_ignoreSafeQueryPropertiesTemplateUrl: () => boolean; + set_ignoreSafeQueryPropertiesTemplateUrl: (value: boolean) => void; get_impressionID: () => string; set_impressionID: (value: string) => void; @@ -4653,11 +4940,11 @@ declare module Microsoft.SharePoint.Client.Search { get_personalizationData: () => QueryPersonalizationData; set_personalizationData: (QueryPersonalizationData) => void; - get_processBestBets: () => bool; - set_processBestBets: (value: bool) => void; + get_processBestBets: () => boolean; + set_processBestBets: (value: boolean) => void; - get_processPersonalFavorites: () => bool; - set_processPersonalFavorites: (value: bool) => void; + get_processPersonalFavorites: () => boolean; + set_processPersonalFavorites: (value: boolean) => void; get_queryTag: () => string; set_queryTag: (value: string) => void; @@ -4665,7 +4952,7 @@ declare module Microsoft.SharePoint.Client.Search { get_queryTemplate: () => string; set_queryTemplate: (value: string) => void; - get_queryTemplateParameters: () => { [key: string]: bool; }; + get_queryTemplateParameters: () => { [key: string]: boolean; }; get_queryText: () => string; set_queryText: (value: string) => void; @@ -4685,8 +4972,8 @@ declare module Microsoft.SharePoint.Client.Search { get_safeQueryPropertiesTemplateUrl: () => string; set_safeQueryPropertiesTemplateUrl: (value: string) => void; - get_showPeopleNameSuggestions: () => bool; - set_showPeopleNameSuggestions: (value: bool) => void; + get_showPeopleNameSuggestions: () => boolean; + set_showPeopleNameSuggestions: (value: boolean) => void; get_sourceId: () => SP.Guid; set_sourceId: (value: SP.Guid) => void; @@ -4703,8 +4990,8 @@ declare module Microsoft.SharePoint.Client.Search { get_totalRowsExactMinimum: () => number; set_totalRowsExactMinimum: (value: number) => void; - get_trimDuplicates: () => bool; - set_trimDuplicates: (value: bool) => void; + get_trimDuplicates: () => boolean; + set_trimDuplicates: (value: boolean) => void; get_uiLanguage: () => number; @@ -4714,10 +5001,10 @@ declare module Microsoft.SharePoint.Client.Search { getQuerySuggestionsWithResults: (iNumberOfQuerySuggestions: number, iNumberOfResultSuggestions: number, - fPreQuerySuggestions: bool, - fHitHighlighting: bool, - fCapitalizeFirstLetters: bool, - fPrefixMatchAllTerms: bool) => QuerySuggestionResults; + fPreQuerySuggestions: boolean, + fHitHighlighting: boolean, + fCapitalizeFirstLetters: boolean, + fPrefixMatchAllTerms: boolean) => QuerySuggestionResults; } @@ -4729,8 +5016,8 @@ declare module Microsoft.SharePoint.Client.Search { get_collapseSpecification: () => string; set_collapseSpecification: (value: string) => void; - get_enableSorting: () => bool; - set_enableSorting: (value: bool) => void; + get_enableSorting: () => boolean; + set_enableSorting: (value: boolean) => void; get_hiddenConstraints: () => string; set_hiddenConstraints: (value: string) => void; @@ -4761,7 +5048,7 @@ declare module Microsoft.SharePoint.Client.Search { /**Runs a query.*/ executeQuery: (query: Query) => SP.JsonObjectResult; - executeQueries: (queryIds: string[], queries: Query[], handleExceptions: bool) => SP.JsonObjectResult; + executeQueries: (queryIds: string[], queries: Query[], handleExceptions: boolean) => SP.JsonObjectResult; recordPageClick: ( pageInfo: string, clickType: string, @@ -4804,8 +5091,8 @@ declare module Microsoft.SharePoint.Client.Search { get_highlightedTitle: () => string; set_highlightedTitle: (value: string) => void; - get_isBestBet: () => bool; - set_isBestBet: (value: bool) => void; + get_isBestBet: () => boolean; + set_isBestBet: (value: boolean) => void; get_title: () => string; set_title: (value: string) => void; @@ -4815,8 +5102,8 @@ declare module Microsoft.SharePoint.Client.Search { } export class QuerySuggestionQuery extends SP.ClientValueObject { - get_isPersonal: () => bool; - set_isPersonal: (value: bool) => void; + get_isPersonal: () => boolean; + set_isPersonal: (value: boolean) => void; get_query: () => string; set_query: (value: string) => void; @@ -4839,8 +5126,8 @@ declare module Microsoft.SharePoint.Client.Search { } export class QueryPropertyValue extends SP.ClientValueObject { - get_boolVal: () => bool; - set_boolVal: (value: bool) => bool; + get_boolVal: () => boolean; + set_boolVal: (value: boolean) => boolean; get_intVal: () => number; set_intVal: (value: number) => number; @@ -5045,7 +5332,7 @@ declare module Microsoft.SharePoint.Client.Search { get_correlationID: () => string; - get_encodeDetails: () => bool; + get_encodeDetails: () => boolean; get_header: () => string; @@ -5057,9 +5344,9 @@ declare module Microsoft.SharePoint.Client.Search { get_serverTypeId: () => string; - get_showForViewerUsers: () => bool; + get_showForViewerUsers: () => boolean; - get_showInEditModeOnly: () => bool; + get_showInEditModeOnly: () => boolean; get_stackTrace: () => string; @@ -5076,10 +5363,10 @@ declare module Microsoft.SharePoint.Client.Search { module Administration { export class DocumentCrawlLog extends SP.ClientObject { constructor(context: SP.ClientContext, site: SP.Site); - getCrawledUrls: (getCountOnly: bool, + getCrawledUrls: (getCountOnly: boolean, maxRows: { High: number; Low: number; }, queryString: string, - isLike: bool, + isLike: boolean, contentSourceID: number, errorLevel: number, errorID: number, @@ -5187,7 +5474,7 @@ declare module SP { unsubscribe(subscription: SP.BusinessData.Runtime.Subscription, onBehalfOfUser: string, unsubscriberName: string, lobSystemInstance: SP.BusinessData.LobSystemInstance): void; } export class EntityField extends SP.ClientObject { - get_containsLocalizedDisplayName(): bool; + get_containsLocalizedDisplayName(): boolean; get_defaultDisplayName(): string; get_localizedDisplayName(): string; get_name(): string; @@ -5231,9 +5518,9 @@ declare module SP { get_item(index: number): SP.BusinessData.Runtime.EntityFieldValueDictionary; } export class TypeDescriptor extends SP.ClientObject { - get_containsReadOnly(): bool; - get_isCollection(): bool; - get_isReadOnly(): bool; + get_containsReadOnly(): boolean; + get_isCollection(): boolean; + get_isReadOnly(): boolean; get_name(): string; get_typeName(): string; containsLocalizedDisplayName(): SP.BooleanResult; @@ -5337,78 +5624,13 @@ declare module SP { } } } -declare module SP { - export class SOD { - static execute(fileName: string, functionName: string, args?: any[]): void; - static executeFunc(fileName: string, functionName: string, fn: () => void): void; - static executeOrDelayUntilEventNotified(func: () => void, eventName: string): bool; - static executeOrDelayUntilScriptLoaded(func: () => void, depScriptFileName: string): bool; - static notifyScriptLoadedAndExecuteWaitingJobs(scriptFileName: string): void; - static notifyEventAndExecuteWaitingJobs(eventName: string): void; - static registerSod(fileName: string, url: string): void; - static registerSodDep(fileName: string, dependentFileName: string): void; - } -} - -/** Register function to rerun on partial update in MDS-enabled site.*/ -declare function RegisterModuleInit(scriptFileName: string, initFunc: () => void ): void; - -/** Provides access to url and query string parts.*/ -declare class JSRequest { - /** Query string parts.*/ - static QueryString: { [parameter: string]: string; }; - - /** initializes class.*/ - static EnsureSetup(): void; - - /** Current file name (after last '/' in url).*/ - static FileName: string; - - /** Current file path (before last '/' in url).*/ - static PathName: string; -} - -declare class _spPageContextInfo { - static alertsEnabled: bool; //true - static allowSilverlightPrompt: string; //"True" - static clientServerTimeDelta: number; //-182 - static crossDomainPhotosEnabled: bool; //true - static currentCultureName: string; //"ru-RU" - static currentLanguage: number; //1049 - static currentUICultureName: string; //"ru-RU" - static layoutsUrl: string; //"_layouts/15" - static pageListId: string; //"{06ee6d96-f27f-4160-b6bb-c18f187b18a7}" - static pagePersonalizationScope: string; //1 - static serverRequestPath: string; //"/SPTypeScript/Lists/ConditionalFormattingTasksList/AllItems.aspx" - static siteAbsoluteUrl: string; // "https://gandjustas-7b20d3715e8ed4.sharepoint.com" - static siteClientTag: string; //"0$$15.0.4454.1021" - static siteServerRelativeUrl: string; // "/" - static systemUserKey: string; //"i:0h.f|membership|10033fff84e7cb2b@live.com" - static tenantAppVersion: string; //"0" - static userId: number; //12 - static webAbsoluteUrl: string; //"https://gandjustas-7b20d3715e8ed4.sharepoint.com/SPTypeScript" - static webLanguage: number; //1049 - static webLogoUrl: string; //"/_layouts/15/images/siteIcon.png?rev=23" - static webPermMasks: { High: number; Low: number; }; - static webServerRelativeUrl: string; //"/SPTypeScript" - static webTemplate: string; //"17" - static webTitle: string; //"SPTypeScript" - static webUIVersion: number; //15 -} - -declare function STSHtmlEncode(value: string): string; - -declare function AddEvtHandler(element: HTMLElement, event:string, func: EventListener): void; - -/** Gets query string parameter */ -declare function GetUrlKeyValue(key: string): string; declare module SP { export module Sharing { export class DocumentSharingManager { static getRoleDefinition(context: SP.ClientRuntimeContext, role: SP.Sharing.Role): SP.RoleDefinition; static isDocumentSharingEnabled(context: SP.ClientRuntimeContext, list: SP.List): SP.BooleanResult; - static updateDocumentSharingInfo(context: SP.ClientRuntimeContext, resourceAddress: string, userRoleAssignments: SP.Sharing.UserRoleAssignment[], validateExistingPermissions: bool, additiveMode: bool, sendServerManagedNotification: bool, customMessage: string, includeAnonymousLinksInNotification: bool): SP.Sharing.UserSharingResult[]; + static updateDocumentSharingInfo(context: SP.ClientRuntimeContext, resourceAddress: string, userRoleAssignments: SP.Sharing.UserRoleAssignment[], validateExistingPermissions: boolean, additiveMode: boolean, sendServerManagedNotification: boolean, customMessage: string, includeAnonymousLinksInNotification: boolean): SP.Sharing.UserSharingResult[]; } export enum Role { none, @@ -5428,9 +5650,9 @@ declare module SP { export class UserSharingResult extends SP.ClientValueObject { get_allowedRoles(): SP.Sharing.Role[]; get_currentRole(): SP.Sharing.Role; - get_isUserKnown(): bool; + get_isUserKnown(): boolean; get_message(): string; - get_status(): bool; + get_status(): boolean; get_user(): string; get_typeId(): string; writeToXml(writer: SP.XmlWriter, serializationContext: SP.SerializationContext): void; @@ -5603,7 +5825,7 @@ declare module SP { /** Identifies whether the actor is a user, document, site, or tag. */ get_actorType(): SocialActorType; /** Specifies whether the actor can be followed by the current user. */ - get_canFollow(): bool; + get_canFollow(): boolean; /** Returns the URI of the document or site content. This property is only available for social actors of type Document or Site. */ get_contentUri(): string; @@ -5617,7 +5839,7 @@ declare module SP { This property is only available if actor is User, Document, or Site. */ get_imageUri(): string; /** Returns true if the current user is following the actor; otherwise, it returns false. */ - get_isFollowed(): bool; + get_isFollowed(): boolean; /** Returns the URI of the library containing the document. This property is only available for social actors of type "document". */ get_libraryUri(): string; @@ -5844,7 +6066,7 @@ declare module SP { /** Returns the root post and all reply posts in the thread. */ getFullThread(threadId: string): SocialThread; /** Returns a feed containing mention reference threads from the current user's personal feed. */ - getMentions(clearUnreadMentions: bool, options: SocialFeedOptions): SocialFeed; + getMentions(clearUnreadMentions: boolean, options: SocialFeedOptions): SocialFeed; /** Returns the server's count of unread mentions of the current user. The server maintains a count of unread mentions in posts, but does not track which mentions have been read. When a new mention is stored on the server, it increments the unread mention for the user specified by the mention. @@ -5950,7 +6172,7 @@ declare module SP { /** Specifies a set of users, documents, sites, and tags by an index into the SocialThreadActors array */ export class SocialPostActorInfo extends SP.ClientValueObject { - get_includesCurrentUser(): bool; + get_includesCurrentUser(): boolean; /** Specifies an array of indexes into the SocialThreadActors array. The server can choose to return a limited set of actors. For example, the server can choose to return a subset of the users that like a post. */ get_indexes(): number[]; @@ -5991,9 +6213,9 @@ declare module SP { /** Specifies that access to the post SHOULD be restricted to users that have access to the objects identified by the array of URIs */ set_securityUris(value: string[]): string[]; /** Indicates whether the post is to be used as the current user's new status message. */ - get_updateStatusText(): bool; + get_updateStatusText(): boolean; /** Indicates whether the post is to be used as the current user's new status message. */ - set_updateStatusText(value: bool): bool; + set_updateStatusText(value: boolean): boolean; } /** Provides additional information about server-generated posts. @@ -6117,28 +6339,28 @@ declare module SP { static getTaxonomySession(context: SP.ClientContext): TaxonomySession; get_offlineTermStoreNames(): string[]; get_termStores(): TermStoreCollection; - getTerms(termLabel: string, trimUnavailable: bool): TermCollection; + getTerms(termLabel: string, trimUnavailable: boolean): TermCollection; getTerms(labelMatchInformation: LabelMatchInformation): TermCollection; updateCache(): void; getTerm(guid: SP.Guid): Term; getTermsById(termIds: SP.Guid[]): TermCollection; getTermsInDefaultLanguage( termLabel: string, - defaultLabelOnly: bool, + defaultLabelOnly: boolean, stringMatchOption: StringMatchOption, resultCollectionSize: number, - trimUnavailable: bool, - trimDeprecated: bool): TermCollection; + trimUnavailable: boolean, + trimDeprecated: boolean): TermCollection; getTermsInWorkingLocale( termLabel: string, - defaultLabelOnly: bool, + defaultLabelOnly: boolean, stringMatchOption: StringMatchOption, resultCollectionSize: number, - trimUnavailable: bool, - trimDeprecated: bool): TermCollection; + trimUnavailable: boolean, + trimDeprecated: boolean): TermCollection; - getTermsWithCustomProperty(customPropertyName: string, trimUnavailable: bool): TermCollection; + getTermsWithCustomProperty(customPropertyName: string, trimUnavailable: boolean): TermCollection; getTermsWithCustomProperty(customPropertyMatchInformation: CustomPropertyMatchInformation): TermCollection; getTermSetsByName(termSetName: string, lcid: number): TermSetCollection; getTermSetsByTermLabel(requiredTermLabels: string[], lcid: number): TermSetCollection; @@ -6160,7 +6382,7 @@ declare module SP { get_groups(): TermGroupCollection; get_hashTagsTermSet(): TermSet; get_id(): SP.Guid; - get_isOnline(): bool; + get_isOnline(): boolean; get_keywordsTermSet(): TermSet; get_languages(): number[]; get_name(): string; @@ -6182,18 +6404,18 @@ declare module SP { getTerm(termId: SP.Guid): Term; getTermInTermSet(termSetId: SP.Guid, termId: SP.Guid): Term; getTermsById(termIds: SP.Guid[]): TermCollection; - getTerms(termLabel: string, trimUnavailable: bool): TermCollection; + getTerms(termLabel: string, trimUnavailable: boolean): TermCollection; getTerms(labelMatchInformation: LabelMatchInformation): TermCollection; getTermSetsByName(termSetName: string, lcid: number): TermSetCollection; getTermSetsByTermLabel(requiredTermLabels: string[], lcid: number): TermSetCollection; - getTermsWithCustomProperty(customPropertyName: string, trimUnavailable: bool): TermCollection; + getTermsWithCustomProperty(customPropertyName: string, trimUnavailable: boolean): TermCollection; getTermsWithCustomProperty(customPropertyMatchInformation: CustomPropertyMatchInformation): TermCollection; getTermSet(termSetId: SP.Guid): TermSet; getTermSetsWithCustomProperty(customPropertyMatchInformation: CustomPropertyMatchInformation): TermSetCollection; rollbackAll(): void; updateCache(): void; - getSiteCollectionGroup(currentSite: SP.Site, createIfMissing: bool): TermGroup; + getSiteCollectionGroup(currentSite: SP.Site, createIfMissing: boolean): TermGroup; updateUsedTermsOnSite(currentSite: SP.Site): void; } @@ -6218,8 +6440,8 @@ declare module SP { export class TermGroup extends TaxonomyItem { get_description(): string; set_description(value: string): void; - get_isSiteCollectionGroup(): bool; - get_isSystemGroup(): bool; + get_isSiteCollectionGroup(): boolean; + get_isSystemGroup(): boolean; get_termSets(): TermSetCollection; createTermSet(name: string, newTermSetId: SP.Guid, lcid: number): TermSet; exportObject(): SP.StringResult; @@ -6231,14 +6453,14 @@ declare module SP { get_customProperties(): { [key: string]: string; }; get_customSortOrder(): string; set_customSortOrder(value: string): void; - get_isAvailableForTagging(): bool; - set_isAvailableForTagging(value: bool): void; + get_isAvailableForTagging(): boolean; + set_isAvailableForTagging(value: boolean): void; get_owner(): string; set_owner(value: string): void; get_terms(): TermCollection; createTerm(name: string, lcid: number, newTermId: SP.Guid): Term; /*getTerms(pagingLimit: number): TermCollection;*/ //Moved to descendants to void TypeScript errors - reuseTerm(sourceTerm: Term, reuseBranch: bool): Term; + reuseTerm(sourceTerm: Term, reuseBranch: boolean): Term; reuseTermWithPinning(sourceTerm: Term): Term; deleteCustomProperty(name: string): void; deleteAllCustomProperties(): void; @@ -6258,8 +6480,8 @@ declare module SP { get_description(): string; set_description(value: string): void; get_group(): TermGroup; - get_isOpenForTermCreation(): bool; - set_isOpenForTermCreation(value: bool): void; + get_isOpenForTermCreation(): boolean; + set_isOpenForTermCreation(value: boolean): void; get_stakeholders(): string[]; addStakeholder(stakeholderName: string): void; copy(): TermSet; @@ -6269,9 +6491,9 @@ declare module SP { getChanges(changeInformation: ChangeInformation): ChangedItemCollection; getTerm(termId: SP.Guid): Term; getTerms(pagingLimit: number): TermCollection; - getTerms(termLabel: string, trimUnavailable: bool): TermCollection; + getTerms(termLabel: string, trimUnavailable: boolean): TermCollection; getTerms(labelMatchInformation: LabelMatchInformation): TermCollection; - getTermsWithCustomProperty(customPropertyName: string, trimUnavailable: bool): TermCollection; + getTermsWithCustomProperty(customPropertyName: string, trimUnavailable: boolean): TermCollection; getTermsWithCustomProperty(customPropertyMatchInformation: CustomPropertyMatchInformation): TermCollection; move(targetGroup: TermGroup): void; } @@ -6285,13 +6507,13 @@ declare module SP { export class Term extends TermSetItem { get_description(): string; - get_isDeprecated(): bool; - get_isKeyword(): bool; - get_isPinned(): bool; - get_isPinnedRoot(): bool; - get_isReused(): bool; - get_isRoot(): bool; - get_isSourceTerm(): bool; + get_isDeprecated(): boolean; + get_isKeyword(): boolean; + get_isPinned(): boolean; + get_isPinnedRoot(): boolean; + get_isReused(): boolean; + get_isRoot(): boolean; + get_isSourceTerm(): boolean; get_labels: LabelCollection; get_localCustomProperties(): { [key: string]: string; }; get_mergedTermIds(): SP.Guid[]; @@ -6303,11 +6525,11 @@ declare module SP { get_termsCount(): number; get_termSet(): TermSet; get_termSets(): TermSetCollection; - copy(doCopyChildren: bool): Term; - createLabel(labelName: string, lcid: number, isDefault: bool): Label; + copy(doCopyChildren: boolean): Term; + createLabel(labelName: string, lcid: number, isDefault: boolean): Label; deleteLocalCustomProperty(name: string): void; deleteAllLocalCustomProperties(): void; - deprecate(doDepricate: bool): void; + deprecate(doDepricate: boolean): void; getAllLabels(lcid: number): LabelCollection; getDefaultLabel(lcid: number): Label; getDescription(lcid: number): SP.StringResult; @@ -6316,10 +6538,10 @@ declare module SP { getTerms( termLabel: string, lcid: number, - defaultLabelOnly: bool, + defaultLabelOnly: boolean, stringMatchOption: StringMatchOption, resultCollectionSize: number, - trimUnavailable: bool): TermCollection; + trimUnavailable: boolean): TermCollection; merge(termToMerge: Term): void; move(newParnt: TermSetItem): void; @@ -6338,7 +6560,7 @@ declare module SP { } export class Label extends SP.ClientObject { - get_isDefaultForLanguage(): bool; + get_isDefaultForLanguage(): boolean; get_language(): number; set_language(value: number): void; get_term(): Term; @@ -6350,10 +6572,10 @@ declare module SP { export class LabelMatchInformation extends SP.ClientObject { constructor(context: SP.ClientContext); - get_defaultLabelOnly(): bool; - set_defaultLabelOnly(value: bool): void; - get_excludeKeyword(): bool; - set_excludeKeyword(value: bool): void; + get_defaultLabelOnly(): boolean; + set_defaultLabelOnly(value: boolean): void; + get_excludeKeyword(): boolean; + set_excludeKeyword(value: boolean): void; get_lcid(): number; set_lcid(value: number): void; get_resultCollectionSize(): number; @@ -6362,10 +6584,10 @@ declare module SP { set_stringMatchOption(value: StringMatchOption): void; get_termLabel(): string; set_termLabel(value: string): void; - get_trimDeprecated(): bool; - set_trimDeprecated(value: bool): void; - get_trimUnavailable(): bool; - set_trimUnavailable(value: bool): void; + get_trimDeprecated(): boolean; + set_trimDeprecated(value: boolean): void; + get_trimUnavailable(): boolean; + set_trimUnavailable(value: boolean): void; } export class CustomPropertyMatchInformation extends SP.ClientObject { @@ -6378,8 +6600,8 @@ declare module SP { set_resultCollectionSize(value: number): void; get_stringMatchOption(): StringMatchOption; set_stringMatchOption(value: StringMatchOption): void; - get_trimUnavailable(): bool; - set_trimUnavailable(value: bool): void; + get_trimUnavailable(): boolean; + set_trimUnavailable(value: boolean): void; } export class ChangeInformation extends SP.ClientObject { @@ -6431,24 +6653,24 @@ declare module SP { } export class ChangedTermStore extends ChangedItem { get_changedLanguage(): number; - get_isDefaultLanguageChanged(): bool; - get_isFullFarmRestore(): bool; + get_isDefaultLanguageChanged(): boolean; + get_isFullFarmRestore(): boolean; } export class TaxonomyField extends SP.FieldLookup { constructor(context: SP.ClientContext, fields: SP.FieldCollection, filedName: string); get_anchorId(): SP.Guid; set_anchorId(value: SP.Guid): void; - get_createValuesInEditForm(): bool; - set_createValuesInEditForm(value: bool): void; - get_isAnchorValid(): bool; - get_isKeyword(): bool; - set_isKeyword(value: bool): void; - get_isPathRendered(): bool; - set_isPathRendered(value: bool): void; - get_isTermSetValid(): bool; - get_open(): bool; - set_open(value: bool): void; + get_createValuesInEditForm(): boolean; + set_createValuesInEditForm(value: boolean): void; + get_isAnchorValid(): boolean; + get_isKeyword(): boolean; + set_isKeyword(value: boolean): void; + get_isPathRendered(): boolean; + set_isPathRendered(value: boolean): void; + get_isTermSetValid(): boolean; + get_open(): boolean; + set_open(value: boolean): void; get_sspId(): SP.Guid; set_sspId(value: SP.Guid): void; get_targetTemplate(): string; @@ -6489,7 +6711,7 @@ declare module SP { } export class MobileTaxonomyField extends SP.ClientObject { - get_readOnly(): bool; + get_readOnly(): boolean; } } } @@ -6523,7 +6745,7 @@ declare module SP { static instance(): SP.UI.ApplicationPages.CalendarSelector; registerSelector(selector: SP.UI.ApplicationPages.ISelectorComponent): void; getSelector(type: SP.UI.ApplicationPages.SelectorType, scopeKey: string): SP.UI.ApplicationPages.ISelectorComponent; - addHandler(scopeKey: string, people: bool, resource: bool, handler: (sender: any, selection: SP.UI.ApplicationPages.SelectorSelectionEventArgs) => void ): void; + addHandler(scopeKey: string, people: boolean, resource: boolean, handler: (sender: any, selection: SP.UI.ApplicationPages.SelectorSelectionEventArgs) => void ): void; revertTo(scopeKey: string, ent: SP.UI.ApplicationPages.ResolveEntity): void; removeEntity(scopeKey: string, ent: SP.UI.ApplicationPages.ResolveEntity): void; constructor(); @@ -6576,22 +6798,22 @@ declare module SP { accountName: string; id: string; members: SP.UI.ApplicationPages.ResolveEntity[]; - needResolve: bool; - isGroup: bool; + needResolve: boolean; + isGroup: boolean; get_key(): string; constructor(); } export class ClientPeoplePickerQueryParameters extends SP.ClientValueObject { - get_allowEmailAddresses(): bool; - set_allowEmailAddresses(value: bool): void; - get_allowMultipleEntities(): bool; - set_allowMultipleEntities(value: bool): void; - get_allUrlZones(): bool; - set_allUrlZones(value: bool): void; + get_allowEmailAddresses(): boolean; + set_allowEmailAddresses(value: boolean): void; + get_allowMultipleEntities(): boolean; + set_allowMultipleEntities(value: boolean): void; + get_allUrlZones(): boolean; + set_allUrlZones(value: boolean): void; get_enabledClaimProviders(): string; set_enabledClaimProviders(value: string): void; - get_forceClaims(): bool; - set_forceClaims(value: bool): void; + get_forceClaims(): boolean; + set_forceClaims(value: boolean): void; get_maximumEntitySuggestions(): number; set_maximumEntitySuggestions(value: number): void; get_principalSource(): SP.Utilities.PrincipalSource; @@ -6600,14 +6822,14 @@ declare module SP { set_principalType(value: SP.Utilities.PrincipalType): void; get_queryString(): string; set_queryString(value: string): void; - get_required(): bool; - set_required(value: bool): void; + get_required(): boolean; + set_required(value: boolean): void; get_sharePointGroupID(): number; set_sharePointGroupID(value: number): void; get_urlZone(): SP.UrlZone; set_urlZone(value: SP.UrlZone): void; - get_urlZoneSpecified(): bool; - set_urlZoneSpecified(value: bool): void; + get_urlZoneSpecified(): boolean; + set_urlZoneSpecified(value: boolean): void; get_web(): SP.Web; set_web(value: SP.Web): void; get_webApplicationID(): SP.Guid; @@ -6631,10 +6853,10 @@ declare module SP { declare module SP { export module UI { export class PopoutMenu implements Sys.IDisposable { - constructor(launcherId: string, menuId: string, iconId: string, launcherOpenCssClass: string, textDirection: string, closeIconUrl: string, isClustered: bool, closeIconOffsetLeft: number, closeIconOffsetTop: number, closeIconHeight: number, closeIconWidth: number); + constructor(launcherId: string, menuId: string, iconId: string, launcherOpenCssClass: string, textDirection: string, closeIconUrl: string, isClustered: boolean, closeIconOffsetLeft: number, closeIconOffsetTop: number, closeIconHeight: number, closeIconWidth: number); launchMenu(): void; closeMenu(): void; - static createPopoutMenuInstanceAndLaunch(anchorId: string, menuId: string, iconId: string, anchorOpenCss: string, textDirection: string, closeIconUrl: string, isClustered: bool, x: number, y: number, height: number, width: number): void; + static createPopoutMenuInstanceAndLaunch(anchorId: string, menuId: string, iconId: string, anchorOpenCss: string, textDirection: string, closeIconUrl: string, isClustered: boolean, x: number, y: number, height: number, width: number): void; static closeActivePopoutMenuInstance(): void; dispose(): void; } @@ -6651,7 +6873,7 @@ declare module SP { constructor(); } export class Notify { - static addNotification(strHtml: string, bSticky: bool): string; + static addNotification(strHtml: string, bSticky: boolean): string; static removeNotification(nid: string): void; constructor(); } @@ -6667,14 +6889,14 @@ declare module SP { OnNotificationCountChanged, } export class SPNotification { - constructor(containerId: SP.UI.ContainerID, strHtml: string, bSticky: bool, strTooltip: string, onclickHandler: () => void , extraData: any); - constructor(containerId: SP.UI.ContainerID, strHtml: string, bSticky: bool, strTooltip: string, onclickHandler: () => void ); - constructor(containerId: SP.UI.ContainerID, strHtml: string, bSticky: bool, strTooltip: string); - constructor(containerId: SP.UI.ContainerID, strHtml: string, bSticky: bool); + constructor(containerId: SP.UI.ContainerID, strHtml: string, bSticky: boolean, strTooltip: string, onclickHandler: () => void , extraData: any); + constructor(containerId: SP.UI.ContainerID, strHtml: string, bSticky: boolean, strTooltip: string, onclickHandler: () => void ); + constructor(containerId: SP.UI.ContainerID, strHtml: string, bSticky: boolean, strTooltip: string); + constructor(containerId: SP.UI.ContainerID, strHtml: string, bSticky: boolean); constructor(containerId: SP.UI.ContainerID, strHtml: string); get_id(): string; - Show(bNoAnimate: bool): void; - Hide(bNoAnimate: bool): void; + Show(bNoAnimate: boolean): void; + Hide(bNoAnimate: boolean): void; } export class SPNotificationContainer { constructor(id: number, element: any, layer: number, notificationLimit: number); @@ -6684,12 +6906,12 @@ declare module SP { SetEventHandler(eventId: SP.UI.EventID, eventHandler: any): void; } export class Status { - static addStatus(strTitle: string, strHtml: string, atBegining: bool): string; + static addStatus(strTitle: string, strHtml: string, atBegining: boolean): string; static appendStatus(sid: string, strTitle: string, strHtml: string): string; static updateStatus(sid: string, strHtml: string): void; static setStatusPriColor(sid: string, strColor: string): void; static removeStatus(sid: string): void; - static removeAllStatus(hide: bool): void; + static removeAllStatus(hide: boolean): void; constructor(); } export class Workspace { @@ -6701,8 +6923,8 @@ declare module SP { addMenuItem(text: string, actionScriptText: string, imageSourceUrl: string, imageAlternateText: string, sequenceNumber: number, description: string, id: string): HTMLElement; addSeparator(): void; addSubMenu(text: string, imageSourceUrl: string, imageAlternateText: string, sequenceNumber: number, description: string, id: string): SP.UI.Menu; - show(relativeElement: HTMLElement, forceRefresh: bool, flipTopLevelMenu: bool, yOffset: number): void; - showFilterMenu(relativeElement: HTMLElement, forceRefresh: bool, flipTopLevelMenu: bool, yOffset: number, fShowClose: bool, fShowCheckBoxes: bool): void; + show(relativeElement: HTMLElement, forceRefresh: boolean, flipTopLevelMenu: boolean, yOffset: number): void; + showFilterMenu(relativeElement: HTMLElement, forceRefresh: boolean, flipTopLevelMenu: boolean, yOffset: number, fShowClose: boolean, fShowCheckBoxes: boolean): void; hideIcons(): void; showIcons(): void; } @@ -6739,17 +6961,17 @@ declare module SP { /** url of the page which is shown in the modal dialog. You should use either html or url attribute, but not both. */ url?: string; /** specifies if close button should be shown on the dialog */ - showClose?: bool; + showClose?: boolean; /** specifies if maximize button should be shown on the dialog */ - allowMaximize?: bool; + allowMaximize?: boolean; /** callback that is called after dialog is closed */ dialogReturnValueCallback?: DialogReturnValueCallback; /** automatically determine size of the dialog based on its contents. */ - autoSize?: bool; + autoSize?: boolean; /** minimum width of the dialog when using autoSize option */ autoSizeStartWidth?: number; /** include padding for adding a scrollbar */ - includeScrollBarPadding?: bool; + includeScrollBarPadding?: boolean; /** width of the dialog. if not specified, will be determined automatically based on the contents of the dialog */ width?: number; /** height of the dialog. if not specified, will be determined automatically based on the contents of the dialog */ @@ -6771,17 +6993,17 @@ declare module SP { /** url of the page which is shown in the modal dialog. You should use either html or url attribute, but not both. */ url: string; /** specifies if close button should be shown on the dialog */ - showClose: bool; + showClose: boolean; /** specifies if maximize button should be shown on the dialog */ - allowMaximize: bool; + allowMaximize: boolean; /** callback that is called after dialog is closed */ dialogReturnValueCallback: DialogReturnValueCallback; /** automatically determine size of the dialog based on its contents. */ - autoSize: bool; + autoSize: boolean; /** minimum width of the dialog when using autoSize option */ autoSizeStartWidth: number; /** include padding for adding a scrollbar */ - includeScrollBarPadding: bool; + includeScrollBarPadding: boolean; /** width of the dialog. if not specified, will be determined automatically based on the contents of the dialog */ width: number; /** height of the dialog. if not specified, will be determined automatically based on the contents of the dialog */ @@ -6799,14 +7021,14 @@ declare module SP { get_html(): string; get_title(): string; get_args(): any; - get_allowMaximize(): bool; - get_showClose(): bool; + get_allowMaximize(): boolean; + get_showClose(): boolean; get_returnValue(): any; set_returnValue(value: any): void; get_frameElement(): HTMLFrameElement; get_dialogElement(): HTMLElement; - get_isMaximized(): bool; - get_closed(): bool; + get_isMaximized(): boolean; + get_closed(): boolean; autoSizeSuppressScrollbar(resizePageCallBack: any): void; autoSize(): void; } @@ -6899,7 +7121,7 @@ declare module SP { /** Gets the URL of the edit profile page for the current user. */ get_editProfileLink(): string; /** Gets a Boolean value that indicates whether the current user's People I'm Following list is public. */ - get_isMyPeopleListPublic(): bool; + get_isMyPeopleListPublic(): boolean; /** Gets tags that the user is following. */ getFollowedTags(numberOfTagsToFetch: number): string[]; /** Gets user properties for the current user. */ @@ -6991,7 +7213,7 @@ declare module SP { /** Specifies an array of strings that specify the account names of person's extended reports. */ get_extendedReports(): string[]; /** Represents whether or not the current user is following this person. */ - get_isFollowed(): bool; + get_isFollowed(): boolean; /** Specifies the person's latest microblog post. */ get_latestPost(): string; /** Specifies an array of strings that specify the account names of person's peers, that is, those who have the same manager. */ @@ -7032,17 +7254,17 @@ declare module SP { /** Provides the state of the user's personal site */ get_personalSiteInstantiationState(): PersonalSiteInstantiationState; /** Specifies whether the user can import pictures */ - get_pictureImportEnabled(): bool; + get_pictureImportEnabled(): boolean; /** Specifies the URL to allow the current user to create a personal site. */ get_urlToCreatePersonalSite(): string; /** Specifies whether the current user's social data is to be shared. */ - shareAllSocialData(shareAll: bool): void; + shareAllSocialData(shareAll: boolean): void; /** This member is reserved for internal use and is not intended to be used directly from your code. Use the createPersonalSiteEnque method to create a personal site. */ createPersonalSite(lcid: number): void; /** Enquees creation of a personal site for the current user. @param isInteractive Has a true value if the request is from a web browser and a false value if the request is from a client application. */ - createPersonalSiteEnque(isInteractive: bool): void; + createPersonalSiteEnque(isInteractive: boolean): void; } /** Provides access to followed content items. */ @@ -7124,13 +7346,13 @@ declare module SP { The server stores the data so that it can return it to the client. */ set_flags(value: string): string; /** Indicates whether the followed site has a feed. */ - get_hasFeed(): bool; + get_hasFeed(): boolean; /** Indicates whether the followed site has a feed. */ - set_hasFeed(value: bool): bool; + set_hasFeed(value: boolean): boolean; /** Specifies if the item is hidden from the user. If true this item will not generate activity in the user's feed. */ - get_hidden(): bool; + get_hidden(): boolean; /** Specifies if the item is hidden from the user. If true this item will not generate activity in the user's feed. */ - set_hidden(value: bool): bool; + set_hidden(value: boolean): boolean; /** Specifies the URL of an icon to represent this item. */ get_iconUrl(): string; /** Specifies the URL of an icon to represent this item. */ @@ -7253,9 +7475,11 @@ declare module SP { /** Represents a set of user profile properties for a specified user. */ export class UserProfilePropertiesForUser extends SP.ClientObject { /** Creates new UserProfilePropertiesForUser object + @param context Specifies the client context to use. @param accountName Specifies the user by account name. - @propertyNames Specifies an array of strings that specify the properties to retrieve. */ - constructor(accountName: string, propertyNames: string[]); + @param propertyNames Specifies an array of strings that specify the properties to retrieve. */ + constructor(context: SP.ClientContext, accountName: string, propertyNames: string[]); + /** Specifies the user account name */ get_accountName(): string; /** Specifies the user account name */ @@ -7293,7 +7517,7 @@ declare module SP { static getCurrentUserEmailAddresses(context: SP.ClientRuntimeContext): SP.StringResult; static createEmailBodyForInvitation(context: SP.ClientRuntimeContext, pageAddress: string): SP.StringResult; static getPeoplePickerURL(context: SP.ClientRuntimeContext, web: SP.Web, fieldUser: SP.FieldUser): SP.StringResult; - static resolvePrincipal(context: SP.ClientRuntimeContext, web: SP.Web, input: string, scopes: SP.Utilities.PrincipalType, sources: SP.Utilities.PrincipalSource, usersContainer: SP.UserCollection, inputIsEmailOnly: bool): SP.Utilities.PrincipalInfo; + static resolvePrincipal(context: SP.ClientRuntimeContext, web: SP.Web, input: string, scopes: SP.Utilities.PrincipalType, sources: SP.Utilities.PrincipalSource, usersContainer: SP.UserCollection, inputIsEmailOnly: boolean): SP.Utilities.PrincipalInfo; static getLowerCaseString(context: SP.ClientRuntimeContext, sourceValue: string, lcid: number): SP.StringResult; static formatDateTime(context: SP.ClientRuntimeContext, web: SP.Web, datetime: Date, format: SP.Utilities.DateTimeFormat): SP.StringResult; static isUserLicensedForEntityInContext(context: SP.ClientRuntimeContext, licensableEntity: string): SP.BooleanResult; @@ -7383,7 +7607,7 @@ declare module SP { constructor(); } export class DateUtility { - static isLeapYear(year: number): bool; + static isLeapYear(year: number): boolean; static dateToJulianDay(year: number, month: number, day: number): number; static julianDayToDate(julianDay: number): SP.DateTimeUtil.SimpleDate; static daysInMonth(year: number, month: number): number; @@ -7426,11 +7650,11 @@ declare module SP { set_day(value: number): void; get_era(): number; set_era(value: number): void; - static dateEquals(date1: SimpleDate, date2: SimpleDate): bool; - static dateLessEqual(date1: SimpleDate, date2: SimpleDate): bool; - static dateGreaterEqual(date1: SimpleDate, date2: SimpleDate): bool; - static dateLess(date1: SimpleDate, date2: SimpleDate): bool; - static dateGreater(date1: SimpleDate, date2: SimpleDate): bool; + static dateEquals(date1: SimpleDate, date2: SimpleDate): boolean; + static dateLessEqual(date1: SimpleDate, date2: SimpleDate): boolean; + static dateGreaterEqual(date1: SimpleDate, date2: SimpleDate): boolean; + static dateLess(date1: SimpleDate, date2: SimpleDate): boolean; + static dateGreater(date1: SimpleDate, date2: SimpleDate): boolean; } } } @@ -7438,7 +7662,7 @@ declare module SP { declare module SP { export module WebParts { export class LimitedWebPartManager extends SP.ClientObject { - get_hasPersonalizedParts(): bool; + get_hasPersonalizedParts(): boolean; get_scope(): SP.WebParts.PersonalizationScope; get_webParts(): SP.WebParts.WebPartDefinitionCollection; addWebPart(webPart: SP.WebParts.WebPart, zoneId: string, zoneIndex: number): SP.WebParts.WebPartDefinition; @@ -7466,9 +7690,9 @@ declare module SP { constructor(); } export class WebPart extends SP.ClientObject { - get_hidden(): bool; - set_hidden(value: bool): void; - get_isClosed(): bool; + get_hidden(): boolean; + set_hidden(value: boolean): void; + get_isClosed(): boolean; get_properties(): SP.PropertyValues; get_subtitle(): string; get_title(): string; @@ -7498,26 +7722,26 @@ declare module SP { declare module SP { export module Workflow { export class WorkflowAssociation extends SP.ClientObject { - get_allowManual(): bool; - set_allowManual(value: bool): void; + get_allowManual(): boolean; + set_allowManual(value: boolean): void; get_associationData(): string; set_associationData(value: string): void; - get_autoStartChange(): bool; - set_autoStartChange(value: bool): void; - get_autoStartCreate(): bool; - set_autoStartCreate(value: bool): void; + get_autoStartChange(): boolean; + set_autoStartChange(value: boolean): void; + get_autoStartCreate(): boolean; + set_autoStartCreate(value: boolean): void; get_baseId(): SP.Guid; get_created(): Date; get_description(): string; set_description(value: string): void; - get_enabled(): bool; - set_enabled(value: bool): void; + get_enabled(): boolean; + set_enabled(value: boolean): void; get_historyListTitle(): string; set_historyListTitle(value: string): void; get_id(): SP.Guid; get_instantiationUrl(): string; get_internalName(): string; - get_isDeclarative(): bool; + get_isDeclarative(): boolean; get_listId(): SP.Guid; get_modified(): Date; get_name(): string; @@ -7553,13 +7777,13 @@ declare module SP { constructor(); } export class WorkflowTemplate extends SP.ClientObject { - get_allowManual(): bool; + get_allowManual(): boolean; get_associationUrl(): string; - get_autoStartChange(): bool; - get_autoStartCreate(): bool; + get_autoStartChange(): boolean; + get_autoStartCreate(): boolean; get_description(): string; get_id(): SP.Guid; - get_isDeclarative(): bool; + get_isDeclarative(): boolean; get_name(): string; get_permissionsManual(): SP.BasePermissions; } @@ -7622,19 +7846,19 @@ declare module SP.WorkflowServices { /** Gets custom properties of the workflow definition */ get_properties(): { [propertyName: string]: any; }; /** true if the workflow definition has been published to the external workflow host; false if the workflow definition is only saved on the site */ - get_published(): bool; + get_published(): boolean; /** Determines whether to automatically generate an association form for this workflow. If the value is true, and the associationUrl is not already set, a default association form is automatically generated for the workflow when saveDefinition is called. */ - get_requiresAssociationForm(): bool; + get_requiresAssociationForm(): boolean; /** Determines whether to automatically generate an association form for this workflow. If the value is true, and the associationUrl is not already set, a default association form is automatically generated for the workflow when saveDefinition is called. */ - set_requiresAssociationForm(value: bool): bool; + set_requiresAssociationForm(value: boolean): boolean; /** Determines whether to automatically generate an initiation form for this workflow. If the value is true, and the initiationUrl is not already set, a default initiation form is automatically generated for the workflow when saveDefinition is called. */ - get_requiresInitiationForm(): bool; + get_requiresInitiationForm(): boolean; /** Determines whether to automatically generate an initiation form for this workflow. If the value is true, and the initiationUrl is not already set, a default initiation form is automatically generated for the workflow when saveDefinition is called. */ - set_requiresInitiationForm(value: bool): bool; + set_requiresInitiationForm(value: boolean): boolean; /** RestrictToScope is a GUID value, used in conjunction with the RestrictToType property to further restrict the scope of the definition. For example, if the RestrictToType is "List", then setting the RestrictToScope to a particular list identifier limits the definition to be associable only to the specified list. If the RestrictToType is "List" but the RestrictToScope is null or the empty string, then the definition is associable to any list. */ @@ -7660,7 +7884,7 @@ declare module SP.WorkflowServices { } /** Represents a collection of WorkflowDefinition objects */ - export class WorkflowDefinitionCollection extends SP.ClientObjectCollection { + export class WorkflowDefinitionCollection extends SP.ClientObjectCollection { itemAt(index: number): WorkflowDefinition; get_item(index: number): WorkflowDefinition; /** returns SP.WorkflowDefinition class */ @@ -7687,7 +7911,7 @@ declare module SP.WorkflowServices { @param definitionId The guid identifier of the workflow definition. */ deleteDefinition(definitionId: string): void; /** Retrieves workflow definitions from the workflow store that match the tags. */ - enumerateDefinitions(publishedOnly: bool): WorkflowDefinitionCollection; + enumerateDefinitions(publishedOnly: boolean): WorkflowDefinitionCollection; /** Retrieves a specified workflow definition from the workflow store. @param definitionId The guid identifier of the workflow definition. */ getDefinition(definitionId: string): WorkflowDefinition; @@ -7739,7 +7963,7 @@ declare module SP.WorkflowServices { } /** Represents a collection of WorkflowInstance objects */ - export class WorkflowInstanceCollection extends SP.ClientObjectCollection { + export class WorkflowInstanceCollection extends SP.ClientObjectCollection { itemAt(index: number): WorkflowInstance; get_item(index: number): WorkflowInstance; /** returns SP.WorkflowInstance class */ @@ -7794,7 +8018,7 @@ declare module SP.WorkflowServices { /** The current application identifier.*/ get_appId(): string; /** Indicates whether this workflow service is actively connected to a workflow host. */ - get_isConnected(): bool; + get_isConnected(): boolean; /** Returns the path of the current scope in the workflow host. */ get_scopePath(): string; getWorkflowDeploymentService(): WorkflowDeploymentService; @@ -7813,10 +8037,10 @@ declare module SP.WorkflowServices { set_definitionId(value); /** Gets a boolean value that specifies if the workflow subscription is enabled. When disabled, new instances of the subscription cannot be started, but existing instances will continue to run. */ - get_enabled(): bool; + get_enabled(): boolean; /** Sets a boolean value that enables or disables the workflow subscription. When disabled, new instances of the subscription cannot be started, but existing instances will continue to run. */ - set_enabled(value: bool): bool; + set_enabled(value: boolean): boolean; /** Gets the logical source instance name of the event. (GUID) */ get_eventSourceId(): string; /** Sets the logical source instance name of the event. (GUID) */ @@ -7832,9 +8056,9 @@ declare module SP.WorkflowServices { /** Unique identifier (GUID) of the workflow subscription */ set_id(value: string): string; /** Boolean value that specifies whether multiple workflow instances can be started manually on the same list item at the same time. This property can be used for list workflows only. */ - get_manualStartBypassesActivationLimit(): bool; + get_manualStartBypassesActivationLimit(): boolean; /** Boolean value that specifies whether multiple workflow instances can be started manually on the same list item at the same time. This property can be used for list workflows only. */ - set_manualStartBypassesActivationLimit(value: bool): bool; + set_manualStartBypassesActivationLimit(value: boolean): boolean; /** Gets the name of the workflow subscription for the specified event source. */ get_name(); /** Sets the name of the workflow subscription for the specified event source. */ @@ -7852,7 +8076,7 @@ declare module SP.WorkflowServices { } /** Represents a collection of WorkflowSubscription objects */ - export class WorkflowSubscriptionCollection extends SP.ClientObjectCollection { + export class WorkflowSubscriptionCollection extends SP.ClientObjectCollection { itemAt(index: number): WorkflowSubscription; get_item(index: number): WorkflowSubscription; /** returns SP.WorkflowInstance class */ @@ -7924,13 +8148,13 @@ declare class SPClientAutoFill{ public AllOptionData: { [key:string]: ISPClientAutoFillData }; PopulateAutoFill(jsonObjSuggestions: ISPClientAutoFillData[], fnOnAutoFillCloseFuncName: (elmTextId: string, objData:ISPClientAutoFillData) => void ): void; - IsAutoFillOpen(): bool; + IsAutoFillOpen(): boolean; SetAutoFillHeight(): void; SelectAutoFillOption(elemOption:HTMLElement): void; FocusAutoFill() :void; BlurAutoFill(): void; CloseAutoFill(ojData: ISPClientAutoFillData): void; - UpdateAutoFillMenuFocus(bMoveNextLink:bool): void; + UpdateAutoFillMenuFocus(bMoveNextLink:boolean): void; UpdateAutoFillPosition(): void; } diff --git a/soundjs/soundjs.d.ts b/soundjs/soundjs.d.ts index 24eeb0139..c083dcc65 100644 --- a/soundjs/soundjs.d.ts +++ b/soundjs/soundjs.d.ts @@ -168,7 +168,7 @@ declare module createjs { static getCapabilities(): Object; static getCapability(key: string): any; //HERE can return string | number | bool static getInstanceById(uniqueId: string): SoundInstance; - static getMute(): number; + static getMute(): bool; static getMasterVolume(): number; static getSrcFromId(value: string): string; static getVolume(): number; @@ -181,7 +181,7 @@ declare module createjs { static registerManifest(manifest: Array); static resume(id: string): void; static setMasterVolume(value: number): bool; - static setMute(isMuted: bool, id: string): bool; + static setMute(isMuted: bool): bool; static setVolume(value: number, id?: string): bool; static stop(): bool; diff --git a/sugar/sugar-tests.ts b/sugar/sugar-tests.ts index 1692e9d2a..989fa5349 100644 --- a/sugar/sugar-tests.ts +++ b/sugar/sugar-tests.ts @@ -1,4 +1,4 @@ -/// +/// 'schfifty'.add(' five'); // - > schfifty five 'dopamine'.insert('e', 3); // - > dopeamine @@ -90,7 +90,7 @@ '?????'.hasCyrillic(); // - > true '? ?????!'.hasHangul(); // - > true '??????'.hasKatakana(); // - > true -"l'année".hasLatin(); // - > true +"l'année".hasLatin(); // - > true // visual studio is not liking these characters very much. '????'.hiragana(); // - > '????' @@ -110,7 +110,7 @@ '?????'.isCyrillic(); // - > true '? ?????!'.isHangul(); // - > true '??????'.isKatakana(); // - > false -"l'année".isLatin(); // - > true +"l'année".isLatin(); // - > true // visual studio is not liking these characters very much. '????'.katakana(); // - > '????' @@ -124,8 +124,8 @@ // Called three times: "broken wear", "and", "jumpy jump" }); -'á'.normalize(); // - > 'a' -'Ménage à trois'.normalize(); // - > 'Menage a trois' +'á'.normalize(); // - > 'a' +'Ménage à trois'.normalize(); // - > 'Menage a trois' 'Volkswagen'.normalize(); // - > 'Volkswagen' 'FULLWIDTH'.normalize(); // - > 'FULLWIDTH' @@ -345,3 +345,235 @@ // This function is called 5 times receiving n as the value. }); (2).upto(8, null, 2); // - > [2, 4, 6, 8] + + +//#region Arrays + +[1, 2, 3, 4].add(5); +[1, 2, 3, 4].add([5, 6, 7]); +[1, 2, 3, 4].insert(8, 1); + +[1, 2, 3].at(0); +[1, 2, 3].at(2); +[1, 2, 3].at(4); +[1, 2, 3].at(4, false); +[1, 2, 3].at(-1); +[1, 2, 3].at(0, 1); + +[1, 2, 3].average(); +[{age:35},{age:11},{age:11}].average(function(n) { + return n.age; +}); +[{ age: 35 }, { age: 11 }, { age: 11 }].average('age'); + +[1, 2, 3].clone(); + +[1, null, 2, undefined, 3].compact(); +[1, '', 2, false, 3].compact(); +[1, '', 2, false, 3].compact(true); + +[1, 2, 3, 1].count(1); +['a', 'b', 'c'].count(/b/); +[{a:1},{b:2}].count(function(n) { + return n['a'] > 1; +}); + +[1,2,3,4].each(function(n) { + // Called 4 times: 1, 2, 3, 4 +}); +[1,2,3,4].each(function(n) { + // Called 4 times: 3, 4, 1, 2 +}, 2, true); +[1,2,3,4].each(n => false); + +['a','a','a'].every(function(n) { + return n == 'a'; +}); +['a', 'a', 'a'].every('a'); +[{ a: 2 }, { a: 2 }].every({ a: 2 }); + +[1, 2, 3].exclude(3); +['a', 'b', 'c'].exclude(/b/); +[{a:1},{b:2}].exclude(function(n) { + return n['a'] == 1; +}); +["a", "bbb", "ccc"].exclude((e,i,a) => e.length > 2, (e,i,a) => e.length < 0); + +[1,2,3].filter(function(n) { + return n > 1; +}); +[1, 2, 2, 4].filter(2); + +[{a:1,b:2},{a:1,b:3},{a:1,b:4}].find(function(n) { + return n['a'] == 1; +}); +['cuba', 'japan', 'canada'].find(/^c/, 2); + +[{a:1,b:2},{a:1,b:3},{a:2,b:4}].findAll(function(n) { + return n['a'] == 1; +}); +['cuba', 'japan', 'canada'].findAll(/^c/); +['cuba', 'japan', 'canada'].findAll(/^c/, 2); + +[1,2,3,4].findIndex(3); +[1,2,3,4].findIndex(function(n) { + return n % 2 == 0; +}); +['one','two','three'].findIndex(/th/); + +[1, 2, 3].first(); +[1, 2, 3].first(2); + +[[1], 2, [3]].flatten(); +[['a'], [], 'b', 'c'].flatten(); + +['a','b','c'].forEach(function(a) { + // Called 3 times: 'a','b','c' +}); + +[1, 2, 3].from(1); +[1, 2, 3].from(2); + +['fee', 'fi', 'fum'].groupBy('length'); +[{age:35,name:'ken'},{age:15,name:'bob'}].groupBy(function(n) { + return n.age; +}); + +[1, 2, 3, 4, 5, 6, 7].inGroups(3); +[1, 2, 3, 4, 5, 6, 7].inGroups(3, 'none'); + +[1, 2, 3, 4, 5, 6, 7].inGroupsOf(4); +[1, 2, 3, 4, 5, 6, 7].inGroupsOf(4, 'none'); + +[1, 2, 3, 4].include(5); +[1, 2, 3, 4].include(8, 1); +[1, 2, 3, 4].include([5, 6, 7]); + +[1, 2, 3].indexOf(3); +[1, 2, 3].indexOf(7); + +[1, 3, 5].intersect([5, 7, 9]); +['a', 'b'].intersect('b', 'c'); + +[1, 2, 3].last(); +[1, 2, 3].last(2); + +[1, 2, 1].lastIndexOf(1); +[1, 2, 1].lastIndexOf(7); + +[3, 2, 2].least(); +['fe', 'fo', 'fum'].least('length'); +[{age:35,name:'ken'},{age:12,name:'bob'},{age:12,name:'ted'}].least(function(n) { + return n.age; +}); + +[1,2,3].map(function(n) { + return n * 3; +}); +['one','two','three'].map(function(n) { + return n.length; +}); +['one', 'two', 'three'].map('length'); + +[1, 2, 3].max(); +['fee', 'fo', 'fum'].max('length'); +['fee', 'fo', 'fum'].max('length', true); +[{a:3,a:2}].max(function(n) { + return n['a']; +}); + +[1, 2, 3].min(); +['fee', 'fo', 'fum'].min('length'); +['fee', 'fo', 'fum'].min('length', true); +['fee','fo','fum'].min(function(n) { + return n.length; +}); +[{a:3,a:2}].min(function(n) { + return n['a']; +}); + +[3, 2, 2].most(); +['fe', 'fo', 'fum'].most('length'); +[{age:35,name:'ken'},{age:12,name:'bob'},{age:12,name:'ted'}].most(function(n) { + return n.age; +}); + +[1, 2, 3].none(5); +['a', 'b', 'c'].none(/b/); +[{a:1},{b:2}].none(function(n) { + return n['a'] > 1; +}); + +[1, 2, 3, 4].randomize(); + +[1,2,3,4].reduce(function(a, b) { + return a - b; +}); +[1,2,3,4].reduce(function(a, b) { + return a - b; +}, 100); + +[1,2,3,4].reduceRight(function(a, b) { + return a - b; +}); + +[1, 2, 3].remove(3); +['a', 'b', 'c'].remove(/b/); +[{a:1},{b:2}].remove(function(n) { + return n['a'] == 1; +}); + +[1, 2, 3].remove(3); +['a', 'b', 'c'].remove(/b/); +[{a:1},{b:2}].remove(function(n) { + return n['a'] == 1; +}); + +['a', 'b', 'c'].removeAt(0); +[1, 2, 3, 4].removeAt(1, 3); + +[1, 2, 3, 4, 5].sample(); +[1, 2, 3, 4, 5].sample(3); + +['a','b','c'].some(function(n) { + return n == 'a'; +}); +['a','b','c'].some(function(n) { + return n == 'd'; +}); +['a', 'b', 'c'].some('a'); +[{ a: 2 }, { b: 5 }].some({ a: 2 }); + +['world', 'a', 'new'].sortBy('length'); +['world', 'a', 'new'].sortBy('length', true); +[{age:72},{age:13},{age:18}].sortBy(function(n) { + return n.age; +}); + +[1, 3, 5].subtract([5, 7, 9]); +[1, 3, 5].subtract([3], [5]); +['a', 'b'].subtract('b', 'c'); + +[1, 2, 2].sum(); +[{age:35},{age:12},{age:12}].sum(function(n) { + return n.age; +}); +[{ age: 35 }, { age: 12 }, { age: 12 }].sum('age'); + +[1, 2, 3].to(1); +[1, 2, 3].to(2); + +[1, 3, 5].union([5, 7, 9]); +['a', 'b'].union(['b', 'c']); + +[1, 2, 2, 3].unique(); +[{ foo: 'bar' }, { foo: 'bar' }].unique(); +[{foo:'bar'},{foo:'bar'}].unique(function(obj){ + return obj.foo; +}); +[{ foo: 'bar' }, { foo: 'bar' }].unique('foo'); + +[1, 2, 3].zip([4, 5, 6]); +['Martin', 'John'].zip(['Luther', 'F.'], ['King', 'Kennedy']); + +//#endregion \ No newline at end of file diff --git a/sugar/sugar.d.ts b/sugar/sugar.d.ts index 936c3121d..f197fef17 100644 --- a/sugar/sugar.d.ts +++ b/sugar/sugar.d.ts @@ -24,10 +24,6 @@ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -interface SuggarExcludeFunction { - (el: any, i?: number, array?: any[]): bool; -} - interface String { /** @@ -1984,7 +1980,7 @@ interface Number { upto(num: number, fn?: Function, step?: number): number[]; } -interface Array { +interface Array { /*** * Alternate array constructor. @@ -2039,10 +2035,10 @@ interface Array { * [1,2,3,4].insert(8, 1) -> [1,8,2,3,4] * ***/ - add(el: any, index?: number): any[]; - add(el: any[], index?: number): any[]; - insert(el: any, index?: number): any[]; - insert(el: any[], index?: number): any[]; + add(el: T, index?: number): T[]; + add(el: T[], index?: number): T[]; + insert(el: any, index?: number): T[]; + insert(el: any[], index?: number): T[]; /*** * Gets the element(s) at a given index. @@ -2059,8 +2055,8 @@ interface Array { * [1,2,3].at(0,1) -> [1,2] * ***/ - at(index: number, loop?: bool): any; - at(start: number, stop: number): any[]; + at(index: number, loop?: bool): T; + at(start: number, stop: number): T[]; /*** * Averages all values in the array. @@ -2077,7 +2073,8 @@ interface Array { * [{age:35},{age:11},{age:11}].average('age') -> 19 * ***/ - average(map?: (n: number) => number): number; + average(map?: (n: T) => number): number; + average(mapShortcut: string): number; /*** * Clones the array. @@ -2088,7 +2085,7 @@ interface Array { * [1,2,3].clone() -> [1,2,3] * ***/ - clone(): any[]; + clone(): T[]; /*** * Removes all instances of %undefined%, %null%, and %NaN% from the array. @@ -2102,7 +2099,7 @@ interface Array { * [1,'',2,false,3].compact(true) -> [1,2,3] * ***/ - compact(all?: bool): any[]; + compact(all?: bool): T[]; /*** * Counts all elements in the array that match . @@ -2122,7 +2119,7 @@ interface Array { count(f: string): number; count(f: any[]): number; count(f: Object): number; - count(f: (n: any) => any): number; + count(f: (n: T) => boolean): number; count(f: RegExp): number; /*** @@ -2148,9 +2145,9 @@ interface Array { * }, 2, true); * ***/ - each(fn: (el: any, i?: number, array?: any[]) => bool, + each(fn: (el: T, i?: number, array?: T[]) => any, index?: number, - loop?: bool): any[]; + loop?: bool): T[]; /*** * Returns true if all elements in the array match . @@ -2170,11 +2167,11 @@ interface Array { every(f: number, scope?: any): bool; every(f: string, scope?: any): bool; every(f: Object, scope?: any): bool; - every(f: (el: any, i?: number, array?: any[]) => bool, scope?: any): bool; + every(f: (el: T, i?: number, array?: T[]) => bool, scope?: any): bool; all(f: number, scope?: any): bool; all(f: string, scope?: any): bool; all(f: Object, scope?: any): bool; - all(f: (el: any, i?: number, array?: any[]) => bool, scope?: any): bool; + all(f: (el: T, i?: number, array?: T[]) => bool, scope?: any): bool; /*** * Removes any element in the array that matches [f1], [f2], etc. @@ -2190,11 +2187,11 @@ interface Array { * }); -> [{b:2}] * ***/ - exclude(...f: number[]): number[]; - exclude(...f: string[]): string[]; - exclude(...f: RegExp[]): string[]; - exclude(...f: Object[]): Object[]; - exclude(...f: SuggarExcludeFunction[]): any[]; + exclude(...f: number[]): T[]; + exclude(...f: string[]): T[]; + exclude(...f: RegExp[]): T[]; + exclude(...f: Object[]): T[]; + exclude(fn: (n: T) => bool): T[]; /*** * Returns any elements in the array that match . @@ -2211,11 +2208,11 @@ interface Array { * [1,2,2,4].filter(2) -> 2 * ***/ - filter(f: number, scope?: any): number[]; - filter(f: string, scope?: any): string[]; - filter(f: RegExp, scope?: any): String[]; - filter(f: Object, scope?: any): Object[]; - filter(f: (el: any, i?: number, array?: any[]) => bool, scope?: any): any[]; + filter(f: number, scope?: any): T[]; + filter(f: string, scope?: any): T[]; + filter(f: RegExp, scope?: any): T[]; + filter(f: Object, scope?: any): T[]; + filter(f: (el: T, i?: number, array?: T[]) => bool, scope?: any): T[]; /*** * Returns the first element that matches . @@ -2233,11 +2230,11 @@ interface Array { * ['cuba','japan','canada'].find(/^c/, 2) -> 'canada' * ***/ - find(f: number, index?: number, loop?: bool): number; - find(f: string, index?: number, loop?: bool): string; - find(f: RegExp, index?: number, loop?: bool): string; - find(f: Object, index?: number, loop?: bool): Object; - find(f: (el: any, i?: number, array?: any[]) => bool, index?: number, loop?: bool): any; + find(f: number, index?: number, loop?: bool): T; + find(f: string, index?: number, loop?: bool): T; + find(f: RegExp, index?: number, loop?: bool): T; + find(f: Object, index?: number, loop?: bool): T; + find(f: (el: T, i?: number, array?: T[]) => bool, index?: number, loop?: bool): T; /*** * Returns all elements that match . @@ -2256,11 +2253,11 @@ interface Array { * ['cuba','japan','canada'].findAll(/^c/, 2) -> 'canada' * ***/ - findAll(f: number, index?: number, loop?: bool): number[]; - findAll(f: string, index?: number, loop?: bool): string[]; - findAll(f: RegExp, index?: number, loop?: bool): string[]; - findAll(f: Object, index?: number, loop?: bool): Object[]; - findAll(f: (el: any, i?: number, array?: any[]) => bool, index?: number, loop?: bool): any[]; + findAll(f: number, index?: number, loop?: bool): T[]; + findAll(f: string, index?: number, loop?: bool): T[]; + findAll(f: RegExp, index?: number, loop?: bool): T[]; + findAll(f: Object, index?: number, loop?: bool): T[]; + findAll(f: (el: T, i?: number, array?: T[]) => bool, index?: number, loop?: bool): T[]; /*** * Returns the index of the first element that matches @@ -2288,7 +2285,7 @@ interface Array { findIndex(f: number, startIndex?: number, loop?: bool): number; findIndex(f: any, startIndex?: number, loop?: bool): number; findIndex(f: RegExp, startIndex?: number, loop?: bool): number; - findIndex(f: (el: any, i?: number, array?: any[]) => bool, startIndex?: number, loop?: bool): number; + findIndex(f: (el: T, i?: number, array?: T[]) => bool, startIndex?: number, loop?: bool): number; /*** * Returns the first element(s) in the array. @@ -2301,7 +2298,7 @@ interface Array { * [1,2,3].first(2) -> [1,2] * ***/ - first(num?: number): any[]; + first(num?: number): T[]; /*** * Returns a flattened, one-dimensional copy of the array. @@ -2315,7 +2312,7 @@ interface Array { * [['a'],[],'b','c'].flatten() -> ['a','b','c'] * ***/ - flatten(limit?: number): any[]; + flatten(limit?: number): T[]; /*** * Iterates over the array, calling [fn] on each loop. @@ -2330,7 +2327,7 @@ interface Array { * }); * ***/ - forEach(fn: (el: any, i?: number, array?: any[]) => any, scope?: any): void; + forEach(fn: (el: T, i?: number, array?: T[]) => void, scope?: any): void; /*** * Returns a slice of the array from . @@ -2342,7 +2339,7 @@ interface Array { * [1,2,3].from(2) -> [3] * ***/ - from(index: number): any[]; + from(index: number): T[]; /*** * Groups the array by . @@ -2359,8 +2356,8 @@ interface Array { * }); -> { 35: [{age:35,name:'ken'}], 15: [{age:15,name:'bob'}] } * ***/ - groupBy(map: string, fn?: (n: any) => void ): Object; - groupBy(fn: (n: any) => void ): Object; + groupBy(map: string, fn?: (n: any) => void ): any; + groupBy(fn: (n: T) => any ): any; /*** * Groups the array into arrays. @@ -2402,24 +2399,8 @@ interface Array { * [1,2,3,4].include([5,6,7]) -> [1,2,3,4,5,6,7] * ***/ - include(el: any, index?: number): any[]; - - /*** - * Searches the array and returns the first index where occurs, or -1 if the element is not found. - * @method indexOf(, [fromIndex]) - * @returns Number - * @extra [fromIndex] is the index from which to begin the search. - * This method performs a simple strict equality comparison on . - * It does not support enhanced functionality such as searching - * the contents against a regex, callback, or deep comparison of objects. - * For such functionality, use the %findIndex% method instead. - * @example - * - * [1,2,3].indexOf(3) -> 1 - * [1,2,3].indexOf(7) -> -1 - * - ***/ - indexOf(search: any, fromIndex?: number): number; + include(el: T, index?: number): T[]; + include(els: T[], index?: number): T[]; /*** * Returns an array containing the elements all arrays have in common. @@ -2432,10 +2413,10 @@ interface Array { * ['a','b'].intersect('b','c') -> ['b'] * ***/ - intersect(...args: number[]): number[]; - intersect(...args: string[]): string[]; - intersect(...args: Object[]): Object[]; + intersect(...args: T[]): T[]; + intersect(args: T[]): T[]; intersect(...args: any[]): any[]; + intersect(args: any[]): any[]; /*** * Returns true if the array is empty. @@ -2462,23 +2443,8 @@ interface Array { * [1,2,3].last(2) -> [2,3] * ***/ - last(): any; - last(num: number): any[]; - - /*** - * Searches the array and returns the last index where occurs, - * or -1 if the element is not found. - * @method lastIndexOf(, [fromIndex]) - * @returns Number - * @extra [fromIndex] is the index from which to begin the search. - * This method performs a simple strict equality comparison on . - * @example - * - * [1,2,1].lastIndexOf(1) -> 2 - * [1,2,1].lastIndexOf(7) -> -1 - * - ***/ - lastIndexOf(search: any, fromIndex?: number): number; + last(): T; + last(num: number): T[]; /*** * Returns the elements in the array with the least @@ -2496,8 +2462,9 @@ interface Array { * }); -> [{age:35,name:'ken'}] * ***/ - least(map: string): any[]; - least(map: (n: any) => any): any[]; + least(): T[]; + least(map: string): T[]; + least(map: (n: T) => any): any[]; /*** * Maps the array to another array containing the values that @@ -2518,8 +2485,8 @@ interface Array { * }); -> [3,3,5] * ['one','two','three'].map('length') -> [3,3,5] ***/ - map(map: string, scope?: any): any[]; - map(map: (n: any) => any, scope?: any): any[]; + map(map: string, scope?: any): U[]; + map(map: (n: T) => U, scope?: any): U[]; /*** * Returns the element in the array with the greatest value. @@ -2538,8 +2505,11 @@ interface Array { * }); -> {a:3} * ***/ - max(map: string): any; - max(map: (n: any) => any): any; + max(): T; + max(map: string): T; + max(map: string, all: boolean): any; + max(map: (n: T) => any): T; + max(map: (n: T) => any, all: boolean): any; /*** * Returns the element in the array with the lowest value. @@ -2559,8 +2529,11 @@ interface Array { * }); -> [{a:2}] * ***/ - min(map: string): any; - min(map: (n: any) => any): any; + min(): T; + min(map: string): T; + min(map: string, all: boolean): any; + min(map: (n: T) => any): T; + min(map: (n: T) => any, all: boolean): any; /*** * Returns the elements in the array with the most @@ -2578,8 +2551,9 @@ interface Array { * }); -> [{age:12,name:'bob'},{age:12,name:'ted'}] * ***/ - most(map: string): any[]; - most(map: (n: any) => any): any[]; + most(): T[]; + most(map: string): T[]; + most(map: (T: any) => any): T[]; /*** * Returns true if none of the elements in the array match . @@ -2601,7 +2575,7 @@ interface Array { none(f: RegExp): bool; none(f: Object): bool; none(f: any[]): bool; - none(f: (n: any) => bool): bool; + none(f: (n: T) => bool): bool; /*** * Returns a copy of the array with the elements randomized. @@ -2613,53 +2587,8 @@ interface Array { * [1,2,3,4].randomize() -> [?,?,?,?] * ***/ - randomize(): any[]; - - /*** - * Reduces the array to a single result. - * @method reduce(, [init]) - * @returns Mixed - * @extra If [init] is passed as a starting value, that value will be passed - * as the first argument to the callback. The second argument will be - * the first element in the array. From that point, the result of the - * callback will then be used as the first argument of the next - * iteration. This is often refered to as "accumulation", and [init] - * is often called an "accumulator". If [init] is not passed, then - * will be called n - 1 times, where n is the length of the array. - * In this case, on the first iteration only, the first argument will - * be the first element of the array, and the second argument will be - * the second. After that callbacks work as normal, using the result - * of the previous callback as the first argument of the next. This - * method is only provided for those browsers that do not support it - * natively. - * - * @example - * - * [1,2,3,4].reduce(function(a, b) { - * return a - b; - * }); - * [1,2,3,4].reduce(function(a, b) { - * return a - b; - * }, 100); - * - ***/ - reduce(fn: (a: any, b: any) => any, init: any): any; - - /*** - * Identical to %Array#reduce%, - * but operates on the elements in reverse order. - * @method reduceRight([fn], [init]) - * @returns Mixed - * @extra This method is only provided for those browsers that do not support - * it natively. - * @example - * - * [1,2,3,4].reduceRight(function(a, b) { - * return a - b; - * }); - * - ***/ - reduceRight(fn: (a: any, b: any) => any, init: any): any; + randomize(): T[]; + /*** * Removes any element in the array that matches [f1], [f2], etc. @@ -2678,11 +2607,11 @@ interface Array { * }); -> [{b:2}] * ***/ - remove(...args: number[]): number[]; - remove(...args: string[]): string[]; - remove(...args: Object[]): Object[]; + remove(...args: number[]): T[]; + remove(...args: string[]): T[]; + remove(...args: Object[]): T[]; remove(...args: any[]): any[]; - remove(fn: (n: any) => bool): any[]; + remove(...args: {(n: T): bool}[]): T[]; /*** * Removes element at . If [end] is specified, removes the range @@ -2696,7 +2625,7 @@ interface Array { * [1,2,3,4].removeAt(1, 3) -> [1] * ***/ - removeAt(start: number, end?: number): any[]; + removeAt(start: number, end?: number): T[]; /*** * Returns a random element from the array. @@ -2709,8 +2638,8 @@ interface Array { * [1,2,3,4,5].sample(3) -> // Array of 3 random elements * ***/ - sample(): any; - sample(num: number): any[]; + sample(): T; + sample(num: number): T[]; /*** * Returns true if any element in the array matches . @@ -2733,7 +2662,7 @@ interface Array { some(f: number, scope?: any): bool; some(f: string, scope?: any): bool; some(f: any, scope?: any): bool; - some(f: (n: any) => bool, scope?: any): bool; + some(f: (n: T) => bool, scope?: any): bool; /*** * Sorts the array by . @@ -2754,8 +2683,8 @@ interface Array { * }); -> [{age:13},{age:18},{age:72}] * ***/ - sortBy(map: string, desc?: bool): any[]; - sortBy(fn: (n: any) => any, desc?: bool): any[]; + sortBy(map: string, desc?: bool): T[]; + sortBy(fn: (n: T) => any, desc?: bool): T[]; /*** * Subtracts from the array all elements in [a1], [a2], etc. @@ -2768,8 +2697,8 @@ interface Array { * [1,3,5].subtract([3],[5]) -> [1] * ['a','b'].subtract('b','c') -> ['a'] * - ***/ - subtract(...args: any[]): any[]; + ***/ + subtract(...args: any[]): T[]; /*** * @method sum([map]) @@ -2786,8 +2715,9 @@ interface Array { * [{age:35},{age:12},{age:12}].sum('age') -> 59 * ***/ + sum(): number; sum(map: string): number; - sum(fn: (n: any) => number): number; + sum(fn: (n: T) => number): number; /*** * Returns a slice of the array up to . @@ -2799,7 +2729,7 @@ interface Array { * [1,2,3].to(2) -> [1,2] * ***/ - to(index: number): any[]; + to(index: number): T[]; /*** * Returns an array containing all elements in all arrays with @@ -2834,9 +2764,9 @@ interface Array { * }); -> [{foo:'bar'}] * [{foo:'bar'},{foo:'bar'}].unique('foo') -> [{foo:'bar'}] * - ***/ - unique(map?: string): any[]; - unique(fn?: (obj: any) => any): any[]; + ***/ + unique(map?: string): T[]; + unique(fn?: (obj: T) => any): T[]; /*** * Merges multiple arrays together. diff --git a/underscore/underscore-tests.ts b/underscore/underscore-tests.ts index 97aaf0cbf..3e1514a45 100644 --- a/underscore/underscore-tests.ts +++ b/underscore/underscore-tests.ts @@ -1,18 +1,16 @@ -import _ = require("underscore") +/// declare var $; -declare function alert(any); -_.each([1, 2, 3], (num) => alert(num)); -_.each({ one: 1, two: 2, three: 3 }, (num, key) => alert(num)); +_.each([1, 2, 3], (num) => alert(num.toString())); +_.each({ one: 1, two: 2, three: 3 }, (value) => alert(value.toString())); _.map([1, 2, 3], (num) => num * 3); -_.map({ one: 1, two: 2, three: 3 }, (num, key) => num * 3); +_.map({ one: 1, two: 2, three: 3 }, (value: number, key?: string) => value * 3); var sum = _.reduce([1, 2, 3], (memo, num) => memo + num, 0); var list = [[0, 1], [2, 3], [4, 5]]; - var flat = _.reduceRight(list, (a, b) => a.concat(b), []); var even = _.find([1, 2, 3, 4, 5, 6], (num) => num % 2 == 0); @@ -37,19 +35,23 @@ _.pluck(stooges, 'name'); _.max(stooges, (stooge) => stooge.age); +_.max([1, 2, 3, 4, 5]); + var numbers = [10, 5, 100, 2, 1000]; _.min(numbers); _.sortBy([1, 2, 3, 4, 5, 6], (num) => Math.sin(num)); -_.groupBy([1.3, 2.1, 2.4], (num) => Math.floor(num)); + +_([1.3, 2.1, 2.4]).groupBy((e) => Math.floor(e)); +_.groupBy([1.3, 2.1, 2.4], (num: number) => Math.floor(num).toString()); _.groupBy(['one', 'two', 'three'], 'length'); -_.countBy([1, 2, 3, 4, 5], (num) => num % 2 == 0 ? 'even' : 'odd'); +_.countBy([1, 2, 3, 4, 5], (num) => (num % 2 == 0) ? 'even' : 'odd'); _.shuffle([1, 2, 3, 4, 5, 6]); -// (function(){ return _.toArray(arguments).slice(1); })(1, 2, 3, 4); +(function(a, b, c, d){ return _.toArray(arguments).slice(1); })(1, 2, 3, 4); _.size({ one: 1, two: 2, three: 3 }); @@ -60,16 +62,21 @@ _.initial([5, 4, 3, 2, 1]); _.last([5, 4, 3, 2, 1]); _.rest([5, 4, 3, 2, 1]); _.compact([0, 1, false, 2, '', 3]); -_.flatten([1, [2], [3, [[4]]]]); -_.flatten([1, [2], [3, [[4]]]], true); + +_.flatten([1, 2, 3, 4]); +_.flatten([1, [2]]); + +// typescript doesn't like the elements being different +_.flatten([1, [2], [3, [[4]]]]); +_.flatten([1, [2], [3, [[4]]]], true); _.without([1, 2, 1, 0, 3, 1, 4], 0, 1); _.union([1, 2, 3], [101, 2, 1, 10], [2, 1]); _.intersection([1, 2, 3], [101, 2, 1, 10], [2, 1]); _.difference([1, 2, 3, 4, 5], [5, 2, 10]); _.uniq([1, 2, 1, 3, 1, 4]); _.zip(['moe', 'larry', 'curly'], [30, 40, 50], [true, false, false]); -_.object(['moe', 'larry', 'curly'], [30, 40, 50]); -_.object([['moe', 30], ['larry', 40], ['curly', 50]]); +var r = _.object<{ [key: string]: number }>(['moe', 'larry', 'curly'], [30, 40, 50]); +_.object([['moe', 30], ['larry', 40], ['curly', 50]]); _.indexOf([1, 2, 3], 2); _.lastIndexOf([1, 2, 3, 1, 2, 3], 2); _.sortedIndex([10, 20, 30, 40, 50], 35); @@ -81,20 +88,22 @@ _.range(0); /////////////////////////////////////////////////////////////////////////////////////// -var func = function (greeting?) { return greeting + ': ' + this.name }; -func = _.bind(func, { name: 'moe' }, 'hi'); -func(); +var func = function (greeting) { return greeting + ': ' + this.name }; +// need a second var otherwise typescript thinks func signature is the above func type, +// instead of the newly returned _bind => func type. +var func2 = _.bind(func, { name: 'moe' }, 'hi'); +func2(); var buttonView = { - label: 'underscore', - onClick: function () { alert('clicked: ' + this.label); }, - onHover: function () { console.log('hovering: ' + this.label); } + label: 'underscore', + onClick: function () { alert('clicked: ' + this.label); }, + onHover: function () { console.log('hovering: ' + this.label); } }; _.bindAll(buttonView); $('#underscore_button').bind('click', buttonView.onClick); var fibonacci = _.memoize(function (n) { - return n < 2 ? n : fibonacci(n - 1) + fibonacci(n - 2); + return n < 2 ? n : fibonacci(n - 1) + fibonacci(n - 2); }); var log = _.bind(console.log, console); @@ -120,9 +129,10 @@ var render = () => alert("rendering..."); var renderNotes = _.after(notes.length, render); _.each(notes, (note) => note.asyncSave({ success: renderNotes })); -var hello = function (name?) { return "hello: " + name; }; -hello = _.wrap(hello, (func) => { return "before, " + func("moe") + ", after"; }); -hello(); +var hello = function (name) { return "hello: " + name; }; +// can't use the same "hello" var otherwise typescript fails +var hello2 = _.wrap(hello, (func) => { return "before, " + func("moe") + ", after"; }); +hello2(); var greet = function (name) { return "hi: " + name; }; var exclaim = function (statement) { return statement + "!"; }; @@ -144,12 +154,23 @@ var iceCream = { flavor: "chocolate" }; _.defaults(iceCream, { flavor: "vanilla", sprinkles: "lots" }); _.clone({ name: 'moe' }); +_.clone(['i', 'am', 'an', 'object!']); + +_([1, 2, 3, 4]) + .chain() + .filter((num: number) => { + return num % 2 == 0; + }).tap(alert) + .map((num: number) => { + return num * num; + }) + .value(); _.chain([1, 2, 3, 200]) - .filter(function (num) { return num % 2 == 0; }) - .tap(alert) - .map(function (num) { return num * num }) - .value(); + .filter(function (num: number) { return num % 2 == 0; }) + .tap(alert) + .map(function (num: number) { return num * num }) + .value(); _.has({ a: 1, b: 2, c: 3 }, "b"); @@ -206,15 +227,17 @@ var moe2 = { name: 'moe' }; moe2 === _.identity(moe); var genie; +var r2 = _.times(3, (n) => { return n * n }); _(3).times(function (n) { genie.grantWishNumber(n); }); _.random(0, 100); _.mixin({ - capitalize: function (string) { - return string.charAt(0).toUpperCase() + string.substring(1).toLowerCase(); - } + capitalize: function (string) { + return string.charAt(0).toUpperCase() + string.substring(1).toLowerCase(); + } }); +(_("fabio")).capitalize(); _.uniqueId('contact_'); @@ -234,14 +257,11 @@ template({ value: '