mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
merge with master
This commit is contained in:
@@ -8,6 +8,7 @@ var child_process = require("child_process");
|
||||
// Variables
|
||||
var compilerDirectory = "src/compiler/";
|
||||
var servicesDirectory = "src/services/";
|
||||
var serverDirectory = "src/server/";
|
||||
var harnessDirectory = "src/harness/";
|
||||
var libraryDirectory = "src/lib/";
|
||||
var scriptsDirectory = "scripts/";
|
||||
@@ -64,8 +65,10 @@ var servicesSources = [
|
||||
return path.join(compilerDirectory, f);
|
||||
}).concat([
|
||||
"breakpoints.ts",
|
||||
"navigateTo.ts",
|
||||
"navigationBar.ts",
|
||||
"outliningElementsCollector.ts",
|
||||
"patternMatcher.ts",
|
||||
"services.ts",
|
||||
"shims.ts",
|
||||
"signatureHelp.ts",
|
||||
@@ -90,6 +93,16 @@ var servicesSources = [
|
||||
return path.join(servicesDirectory, f);
|
||||
}));
|
||||
|
||||
var serverSources = [
|
||||
"node.d.ts",
|
||||
"editorServices.ts",
|
||||
"protocol.d.ts",
|
||||
"session.ts",
|
||||
"server.ts"
|
||||
].map(function (f) {
|
||||
return path.join(serverDirectory, f);
|
||||
});
|
||||
|
||||
var definitionsRoots = [
|
||||
"compiler/types.d.ts",
|
||||
"compiler/scanner.d.ts",
|
||||
@@ -127,9 +140,17 @@ var harnessSources = [
|
||||
"incrementalParser.ts",
|
||||
"services/colorization.ts",
|
||||
"services/documentRegistry.ts",
|
||||
"services/preProcessFile.ts"
|
||||
"services/preProcessFile.ts",
|
||||
"services/patternMatcher.ts"
|
||||
].map(function (f) {
|
||||
return path.join(unittestsDirectory, f);
|
||||
})).concat([
|
||||
"protocol.d.ts",
|
||||
"session.ts",
|
||||
"client.ts",
|
||||
"editorServices.ts",
|
||||
].map(function (f) {
|
||||
return path.join(serverDirectory, f);
|
||||
}));
|
||||
|
||||
var librarySourceMap = [
|
||||
@@ -327,6 +348,7 @@ var tscFile = path.join(builtLocalDirectory, compilerFilename);
|
||||
compileFile(tscFile, compilerSources, [builtLocalDirectory, copyright].concat(compilerSources), [copyright], /*useBuiltCompiler:*/ false);
|
||||
|
||||
var servicesFile = path.join(builtLocalDirectory, "typescriptServices.js");
|
||||
var nodePackageFile = path.join(builtLocalDirectory, "typescript.js");
|
||||
compileFile(servicesFile, servicesSources,[builtLocalDirectory, copyright].concat(servicesSources),
|
||||
/*prefixes*/ [copyright],
|
||||
/*useBuiltCompiler*/ true,
|
||||
@@ -336,7 +358,10 @@ compileFile(servicesFile, servicesSources,[builtLocalDirectory, copyright].conca
|
||||
/*preserveConstEnums*/ true,
|
||||
/*keepComments*/ false,
|
||||
/*noResolve*/ false,
|
||||
/*stripInternal*/ false);
|
||||
/*stripInternal*/ false,
|
||||
/*callback*/ function () {
|
||||
jake.cpR(servicesFile, nodePackageFile, {silent: true});
|
||||
});
|
||||
|
||||
var nodeDefinitionsFile = path.join(builtLocalDirectory, "typescript.d.ts");
|
||||
var standaloneDefinitionsFile = path.join(builtLocalDirectory, "typescriptServices.d.ts");
|
||||
@@ -378,9 +403,12 @@ compileFile(nodeDefinitionsFile, servicesSources,[builtLocalDirectory, copyright
|
||||
jake.rmRf(tempDirPath, {silent: true});
|
||||
});
|
||||
|
||||
var serverFile = path.join(builtLocalDirectory, "tsserver.js");
|
||||
compileFile(serverFile, serverSources,[builtLocalDirectory, copyright].concat(serverSources), /*prefixes*/ [copyright], /*useBuiltCompiler*/ true);
|
||||
|
||||
// Local target to build the compiler and services
|
||||
desc("Builds the full compiler and services");
|
||||
task("local", ["generate-diagnostics", "lib", tscFile, servicesFile, nodeDefinitionsFile]);
|
||||
task("local", ["generate-diagnostics", "lib", tscFile, servicesFile, nodeDefinitionsFile, serverFile]);
|
||||
|
||||
// Local target to build only tsc.js
|
||||
desc("Builds only the compiler");
|
||||
@@ -435,7 +463,7 @@ task("generate-spec", [specMd])
|
||||
// Makes a new LKG. This target does not build anything, but errors if not all the outputs are present in the built/local directory
|
||||
desc("Makes a new LKG out of the built js files");
|
||||
task("LKG", ["clean", "release", "local"].concat(libraryTargets), function() {
|
||||
var expectedFiles = [tscFile, servicesFile, nodeDefinitionsFile, standaloneDefinitionsFile, internalNodeDefinitionsFile, internalStandaloneDefinitionsFile].concat(libraryTargets);
|
||||
var expectedFiles = [tscFile, servicesFile, serverFile, nodePackageFile, nodeDefinitionsFile, standaloneDefinitionsFile, internalNodeDefinitionsFile, internalStandaloneDefinitionsFile].concat(libraryTargets);
|
||||
var missingFiles = expectedFiles.filter(function (f) {
|
||||
return !fs.existsSync(f);
|
||||
});
|
||||
@@ -542,11 +570,11 @@ task("runtests", ["tests", builtLocalDirectory], function() {
|
||||
}
|
||||
|
||||
if (tests && tests.toLocaleLowerCase() === "rwc") {
|
||||
testTimeout = 50000;
|
||||
testTimeout = 100000;
|
||||
}
|
||||
|
||||
colors = process.env.colors || process.env.color
|
||||
colors = colors ? ' --no-colors ' : ''
|
||||
colors = colors ? ' --no-colors ' : ' --colors ';
|
||||
tests = tests ? ' -g ' + tests : '';
|
||||
reporter = process.env.reporter || process.env.r || 'dot';
|
||||
// timeout normally isn't necessary but Travis-CI has been timing out on compiler baselines occasionally
|
||||
|
||||
Vendored
+85
-79
@@ -1164,7 +1164,7 @@ interface ArrayConstructor {
|
||||
}
|
||||
|
||||
declare var Array: ArrayConstructor;
|
||||
declare type PropertyKey = string | number | Symbol;
|
||||
declare type PropertyKey = string | number | symbol;
|
||||
|
||||
interface Symbol {
|
||||
/** Returns a string representation of an object. */
|
||||
@@ -1173,7 +1173,7 @@ interface Symbol {
|
||||
/** Returns the primitive value of the specified object. */
|
||||
valueOf(): Object;
|
||||
|
||||
// [Symbol.toStringTag]: string;
|
||||
[Symbol.toStringTag]: string;
|
||||
}
|
||||
|
||||
interface SymbolConstructor {
|
||||
@@ -1186,21 +1186,21 @@ interface SymbolConstructor {
|
||||
* Returns a new unique Symbol value.
|
||||
* @param description Description of the new Symbol object.
|
||||
*/
|
||||
(description?: string|number): Symbol;
|
||||
(description?: string|number): symbol;
|
||||
|
||||
/**
|
||||
* Returns a Symbol object from the global symbol registry matching the given key if found.
|
||||
* Otherwise, returns a new symbol with this key.
|
||||
* @param key key to search for.
|
||||
*/
|
||||
for(key: string): Symbol;
|
||||
for(key: string): symbol;
|
||||
|
||||
/**
|
||||
* Returns a key from the global symbol registry matching the given Symbol if found.
|
||||
* Otherwise, returns a undefined.
|
||||
* @param sym Symbol to find the key for.
|
||||
*/
|
||||
keyFor(sym: Symbol): string;
|
||||
keyFor(sym: symbol): string;
|
||||
|
||||
// Well-known Symbols
|
||||
|
||||
@@ -1208,42 +1208,42 @@ interface SymbolConstructor {
|
||||
* A method that determines if a constructor object recognizes an object as one of the
|
||||
* constructor’s instances. Called by the semantics of the instanceof operator.
|
||||
*/
|
||||
hasInstance: Symbol;
|
||||
hasInstance: symbol;
|
||||
|
||||
/**
|
||||
* A Boolean value that if true indicates that an object should flatten to its array elements
|
||||
* by Array.prototype.concat.
|
||||
*/
|
||||
isConcatSpreadable: Symbol;
|
||||
isConcatSpreadable: symbol;
|
||||
|
||||
/**
|
||||
* A Boolean value that if true indicates that an object may be used as a regular expression.
|
||||
*/
|
||||
isRegExp: Symbol;
|
||||
isRegExp: symbol;
|
||||
|
||||
/**
|
||||
* A method that returns the default iterator for an object.Called by the semantics of the
|
||||
* for-of statement.
|
||||
*/
|
||||
iterator: Symbol;
|
||||
iterator: symbol;
|
||||
|
||||
/**
|
||||
* A method that converts an object to a corresponding primitive value.Called by the ToPrimitive
|
||||
* abstract operation.
|
||||
*/
|
||||
toPrimitive: Symbol;
|
||||
toPrimitive: symbol;
|
||||
|
||||
/**
|
||||
* A String value that is used in the creation of the default string description of an object.
|
||||
* Called by the built- in method Object.prototype.toString.
|
||||
*/
|
||||
toStringTag: Symbol;
|
||||
toStringTag: symbol;
|
||||
|
||||
/**
|
||||
* An Object whose own property names are property names that are excluded from the with
|
||||
* environment bindings of the associated objects.
|
||||
*/
|
||||
unscopables: Symbol;
|
||||
unscopables: symbol;
|
||||
}
|
||||
declare var Symbol: SymbolConstructor;
|
||||
|
||||
@@ -1274,7 +1274,7 @@ interface ObjectConstructor {
|
||||
* Returns an array of all symbol properties found directly on object o.
|
||||
* @param o Object to retrieve the symbols from.
|
||||
*/
|
||||
getOwnPropertySymbols(o: any): Symbol[];
|
||||
getOwnPropertySymbols(o: any): symbol[];
|
||||
|
||||
/**
|
||||
* Returns true if the values are the same value, false otherwise.
|
||||
@@ -1396,22 +1396,22 @@ interface ArrayLike<T> {
|
||||
|
||||
interface Array<T> {
|
||||
/** Iterator */
|
||||
// [Symbol.iterator] (): Iterator<T>;
|
||||
[Symbol.iterator](): IterableIterator<T>;
|
||||
|
||||
/**
|
||||
* Returns an array of key, value pairs for every entry in the array
|
||||
*/
|
||||
entries(): Iterator<[number, T]>;
|
||||
entries(): IterableIterator<[number, T]>;
|
||||
|
||||
/**
|
||||
* Returns an list of keys in the array
|
||||
*/
|
||||
keys(): Iterator<number>;
|
||||
keys(): IterableIterator<number>;
|
||||
|
||||
/**
|
||||
* Returns an list of values in the array
|
||||
*/
|
||||
values(): Iterator<T>;
|
||||
values(): IterableIterator<T>;
|
||||
|
||||
/**
|
||||
* Returns the value of the first element in the array where predicate is true, and undefined
|
||||
@@ -1495,7 +1495,7 @@ interface ArrayConstructor {
|
||||
|
||||
interface String {
|
||||
/** Iterator */
|
||||
// [Symbol.iterator] (): Iterator<string>;
|
||||
[Symbol.iterator](): IterableIterator<string>;
|
||||
|
||||
/**
|
||||
* Returns a nonnegative integer Number less than 1114112 (0x110000) that is the code point
|
||||
@@ -1613,12 +1613,17 @@ interface IteratorResult<T> {
|
||||
}
|
||||
|
||||
interface Iterator<T> {
|
||||
//[Symbol.iterator](): Iterator<T>;
|
||||
next(): IteratorResult<T>;
|
||||
return?(value?: any): IteratorResult<T>;
|
||||
throw?(e?: any): IteratorResult<T>;
|
||||
}
|
||||
|
||||
interface Iterable<T> {
|
||||
//[Symbol.iterator](): Iterator<T>;
|
||||
[Symbol.iterator](): Iterator<T>;
|
||||
}
|
||||
|
||||
interface IterableIterator<T> extends Iterator<T> {
|
||||
[Symbol.iterator](): IterableIterator<T>;
|
||||
}
|
||||
|
||||
interface GeneratorFunction extends Function {
|
||||
@@ -1636,11 +1641,12 @@ interface GeneratorFunctionConstructor {
|
||||
}
|
||||
declare var GeneratorFunction: GeneratorFunctionConstructor;
|
||||
|
||||
interface Generator<T> extends Iterator<T> {
|
||||
interface Generator<T> extends IterableIterator<T> {
|
||||
next(value?: any): IteratorResult<T>;
|
||||
throw (exception: any): IteratorResult<T>;
|
||||
return (value: T): IteratorResult<T>;
|
||||
// [Symbol.toStringTag]: string;
|
||||
throw(exception: any): IteratorResult<T>;
|
||||
return(value: T): IteratorResult<T>;
|
||||
[Symbol.iterator](): Generator<T>;
|
||||
[Symbol.toStringTag]: string;
|
||||
}
|
||||
|
||||
interface Math {
|
||||
@@ -1754,11 +1760,11 @@ interface Math {
|
||||
*/
|
||||
cbrt(x: number): number;
|
||||
|
||||
// [Symbol.toStringTag]: string;
|
||||
[Symbol.toStringTag]: string;
|
||||
}
|
||||
|
||||
interface RegExp {
|
||||
// [Symbol.isRegExp]: boolean;
|
||||
[Symbol.isRegExp]: boolean;
|
||||
|
||||
/**
|
||||
* Matches a string with a regular expression, and returns an array containing the results of
|
||||
@@ -1807,16 +1813,16 @@ interface RegExp {
|
||||
interface Map<K, V> {
|
||||
clear(): void;
|
||||
delete(key: K): boolean;
|
||||
entries(): Iterator<[K, V]>;
|
||||
entries(): IterableIterator<[K, V]>;
|
||||
forEach(callbackfn: (value: V, index: K, map: Map<K, V>) => void, thisArg?: any): void;
|
||||
get(key: K): V;
|
||||
has(key: K): boolean;
|
||||
keys(): Iterator<K>;
|
||||
keys(): IterableIterator<K>;
|
||||
set(key: K, value?: V): Map<K, V>;
|
||||
size: number;
|
||||
values(): Iterator<V>;
|
||||
// [Symbol.iterator]():Iterator<[K,V]>;
|
||||
// [Symbol.toStringTag]: string;
|
||||
values(): IterableIterator<V>;
|
||||
[Symbol.iterator]():IterableIterator<[K,V]>;
|
||||
[Symbol.toStringTag]: string;
|
||||
}
|
||||
|
||||
interface MapConstructor {
|
||||
@@ -1832,7 +1838,7 @@ interface WeakMap<K, V> {
|
||||
get(key: K): V;
|
||||
has(key: K): boolean;
|
||||
set(key: K, value?: V): WeakMap<K, V>;
|
||||
// [Symbol.toStringTag]: string;
|
||||
[Symbol.toStringTag]: string;
|
||||
}
|
||||
|
||||
interface WeakMapConstructor {
|
||||
@@ -1846,14 +1852,14 @@ interface Set<T> {
|
||||
add(value: T): Set<T>;
|
||||
clear(): void;
|
||||
delete(value: T): boolean;
|
||||
entries(): Iterator<[T, T]>;
|
||||
entries(): IterableIterator<[T, T]>;
|
||||
forEach(callbackfn: (value: T, index: T, set: Set<T>) => void, thisArg?: any): void;
|
||||
has(value: T): boolean;
|
||||
keys(): Iterator<T>;
|
||||
keys(): IterableIterator<T>;
|
||||
size: number;
|
||||
values(): Iterator<T>;
|
||||
// [Symbol.iterator]():Iterator<T>;
|
||||
// [Symbol.toStringTag]: string;
|
||||
values(): IterableIterator<T>;
|
||||
[Symbol.iterator]():IterableIterator<T>;
|
||||
[Symbol.toStringTag]: string;
|
||||
}
|
||||
|
||||
interface SetConstructor {
|
||||
@@ -1868,7 +1874,7 @@ interface WeakSet<T> {
|
||||
clear(): void;
|
||||
delete(value: T): boolean;
|
||||
has(value: T): boolean;
|
||||
// [Symbol.toStringTag]: string;
|
||||
[Symbol.toStringTag]: string;
|
||||
}
|
||||
|
||||
interface WeakSetConstructor {
|
||||
@@ -1879,7 +1885,7 @@ interface WeakSetConstructor {
|
||||
declare var WeakSet: WeakSetConstructor;
|
||||
|
||||
interface JSON {
|
||||
// [Symbol.toStringTag]: string;
|
||||
[Symbol.toStringTag]: string;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1899,7 +1905,7 @@ interface ArrayBuffer {
|
||||
*/
|
||||
slice(begin: number, end?: number): ArrayBuffer;
|
||||
|
||||
// [Symbol.toStringTag]: string;
|
||||
[Symbol.toStringTag]: string;
|
||||
}
|
||||
|
||||
interface ArrayBufferConstructor {
|
||||
@@ -2036,7 +2042,7 @@ interface DataView {
|
||||
*/
|
||||
setUint32(byteOffset: number, value: number, littleEndian: boolean): void;
|
||||
|
||||
// [Symbol.toStringTag]: string;
|
||||
[Symbol.toStringTag]: string;
|
||||
}
|
||||
|
||||
interface DataViewConstructor {
|
||||
@@ -2083,7 +2089,7 @@ interface Int8Array {
|
||||
/**
|
||||
* Returns an array of key, value pairs for every entry in the array
|
||||
*/
|
||||
entries(): Iterator<[number, number]>;
|
||||
entries(): IterableIterator<[number, number]>;
|
||||
|
||||
/**
|
||||
* Determines whether all the members of an array satisfy the specified test.
|
||||
@@ -2163,7 +2169,7 @@ interface Int8Array {
|
||||
/**
|
||||
* Returns an list of keys in the array
|
||||
*/
|
||||
keys(): Iterator<number>;
|
||||
keys(): IterableIterator<number>;
|
||||
|
||||
/**
|
||||
* Returns the index of the last occurrence of a value in an array.
|
||||
@@ -2300,10 +2306,10 @@ interface Int8Array {
|
||||
/**
|
||||
* Returns an list of values in the array
|
||||
*/
|
||||
values(): Iterator<number>;
|
||||
values(): IterableIterator<number>;
|
||||
|
||||
[index: number]: number;
|
||||
// [Symbol.iterator] (): Iterator<number>;
|
||||
[Symbol.iterator](): IterableIterator<number>;
|
||||
}
|
||||
|
||||
interface Int8ArrayConstructor {
|
||||
@@ -2373,7 +2379,7 @@ interface Uint8Array {
|
||||
/**
|
||||
* Returns an array of key, value pairs for every entry in the array
|
||||
*/
|
||||
entries(): Iterator<[number, number]>;
|
||||
entries(): IterableIterator<[number, number]>;
|
||||
|
||||
/**
|
||||
* Determines whether all the members of an array satisfy the specified test.
|
||||
@@ -2453,7 +2459,7 @@ interface Uint8Array {
|
||||
/**
|
||||
* Returns an list of keys in the array
|
||||
*/
|
||||
keys(): Iterator<number>;
|
||||
keys(): IterableIterator<number>;
|
||||
|
||||
/**
|
||||
* Returns the index of the last occurrence of a value in an array.
|
||||
@@ -2590,10 +2596,10 @@ interface Uint8Array {
|
||||
/**
|
||||
* Returns an list of values in the array
|
||||
*/
|
||||
values(): Iterator<number>;
|
||||
values(): IterableIterator<number>;
|
||||
|
||||
[index: number]: number;
|
||||
// [Symbol.iterator] (): Iterator<number>;
|
||||
[Symbol.iterator](): IterableIterator<number>;
|
||||
}
|
||||
|
||||
interface Uint8ArrayConstructor {
|
||||
@@ -2663,7 +2669,7 @@ interface Uint8ClampedArray {
|
||||
/**
|
||||
* Returns an array of key, value pairs for every entry in the array
|
||||
*/
|
||||
entries(): Iterator<[number, number]>;
|
||||
entries(): IterableIterator<[number, number]>;
|
||||
|
||||
/**
|
||||
* Determines whether all the members of an array satisfy the specified test.
|
||||
@@ -2743,7 +2749,7 @@ interface Uint8ClampedArray {
|
||||
/**
|
||||
* Returns an list of keys in the array
|
||||
*/
|
||||
keys(): Iterator<number>;
|
||||
keys(): IterableIterator<number>;
|
||||
|
||||
/**
|
||||
* Returns the index of the last occurrence of a value in an array.
|
||||
@@ -2880,10 +2886,10 @@ interface Uint8ClampedArray {
|
||||
/**
|
||||
* Returns an list of values in the array
|
||||
*/
|
||||
values(): Iterator<number>;
|
||||
values(): IterableIterator<number>;
|
||||
|
||||
[index: number]: number;
|
||||
// [Symbol.iterator] (): Iterator<number>;
|
||||
[Symbol.iterator](): IterableIterator<number>;
|
||||
}
|
||||
|
||||
interface Uint8ClampedArrayConstructor {
|
||||
@@ -2953,7 +2959,7 @@ interface Int16Array {
|
||||
/**
|
||||
* Returns an array of key, value pairs for every entry in the array
|
||||
*/
|
||||
entries(): Iterator<[number, number]>;
|
||||
entries(): IterableIterator<[number, number]>;
|
||||
|
||||
/**
|
||||
* Determines whether all the members of an array satisfy the specified test.
|
||||
@@ -3033,7 +3039,7 @@ interface Int16Array {
|
||||
/**
|
||||
* Returns an list of keys in the array
|
||||
*/
|
||||
keys(): Iterator<number>;
|
||||
keys(): IterableIterator<number>;
|
||||
|
||||
/**
|
||||
* Returns the index of the last occurrence of a value in an array.
|
||||
@@ -3170,10 +3176,10 @@ interface Int16Array {
|
||||
/**
|
||||
* Returns an list of values in the array
|
||||
*/
|
||||
values(): Iterator<number>;
|
||||
values(): IterableIterator<number>;
|
||||
|
||||
[index: number]: number;
|
||||
// [Symbol.iterator] (): Iterator<number>;
|
||||
[Symbol.iterator](): IterableIterator<number>;
|
||||
}
|
||||
|
||||
interface Int16ArrayConstructor {
|
||||
@@ -3243,7 +3249,7 @@ interface Uint16Array {
|
||||
/**
|
||||
* Returns an array of key, value pairs for every entry in the array
|
||||
*/
|
||||
entries(): Iterator<[number, number]>;
|
||||
entries(): IterableIterator<[number, number]>;
|
||||
|
||||
/**
|
||||
* Determines whether all the members of an array satisfy the specified test.
|
||||
@@ -3323,7 +3329,7 @@ interface Uint16Array {
|
||||
/**
|
||||
* Returns an list of keys in the array
|
||||
*/
|
||||
keys(): Iterator<number>;
|
||||
keys(): IterableIterator<number>;
|
||||
|
||||
/**
|
||||
* Returns the index of the last occurrence of a value in an array.
|
||||
@@ -3460,10 +3466,10 @@ interface Uint16Array {
|
||||
/**
|
||||
* Returns an list of values in the array
|
||||
*/
|
||||
values(): Iterator<number>;
|
||||
values(): IterableIterator<number>;
|
||||
|
||||
[index: number]: number;
|
||||
// [Symbol.iterator] (): Iterator<number>;
|
||||
[Symbol.iterator](): IterableIterator<number>;
|
||||
}
|
||||
|
||||
interface Uint16ArrayConstructor {
|
||||
@@ -3533,7 +3539,7 @@ interface Int32Array {
|
||||
/**
|
||||
* Returns an array of key, value pairs for every entry in the array
|
||||
*/
|
||||
entries(): Iterator<[number, number]>;
|
||||
entries(): IterableIterator<[number, number]>;
|
||||
|
||||
/**
|
||||
* Determines whether all the members of an array satisfy the specified test.
|
||||
@@ -3613,7 +3619,7 @@ interface Int32Array {
|
||||
/**
|
||||
* Returns an list of keys in the array
|
||||
*/
|
||||
keys(): Iterator<number>;
|
||||
keys(): IterableIterator<number>;
|
||||
|
||||
/**
|
||||
* Returns the index of the last occurrence of a value in an array.
|
||||
@@ -3750,10 +3756,10 @@ interface Int32Array {
|
||||
/**
|
||||
* Returns an list of values in the array
|
||||
*/
|
||||
values(): Iterator<number>;
|
||||
values(): IterableIterator<number>;
|
||||
|
||||
[index: number]: number;
|
||||
// [Symbol.iterator] (): Iterator<number>;
|
||||
[Symbol.iterator](): IterableIterator<number>;
|
||||
}
|
||||
|
||||
interface Int32ArrayConstructor {
|
||||
@@ -3823,7 +3829,7 @@ interface Uint32Array {
|
||||
/**
|
||||
* Returns an array of key, value pairs for every entry in the array
|
||||
*/
|
||||
entries(): Iterator<[number, number]>;
|
||||
entries(): IterableIterator<[number, number]>;
|
||||
|
||||
/**
|
||||
* Determines whether all the members of an array satisfy the specified test.
|
||||
@@ -3903,7 +3909,7 @@ interface Uint32Array {
|
||||
/**
|
||||
* Returns an list of keys in the array
|
||||
*/
|
||||
keys(): Iterator<number>;
|
||||
keys(): IterableIterator<number>;
|
||||
|
||||
/**
|
||||
* Returns the index of the last occurrence of a value in an array.
|
||||
@@ -4040,10 +4046,10 @@ interface Uint32Array {
|
||||
/**
|
||||
* Returns an list of values in the array
|
||||
*/
|
||||
values(): Iterator<number>;
|
||||
values(): IterableIterator<number>;
|
||||
|
||||
[index: number]: number;
|
||||
// [Symbol.iterator] (): Iterator<number>;
|
||||
[Symbol.iterator](): IterableIterator<number>;
|
||||
}
|
||||
|
||||
interface Uint32ArrayConstructor {
|
||||
@@ -4113,7 +4119,7 @@ interface Float32Array {
|
||||
/**
|
||||
* Returns an array of key, value pairs for every entry in the array
|
||||
*/
|
||||
entries(): Iterator<[number, number]>;
|
||||
entries(): IterableIterator<[number, number]>;
|
||||
|
||||
/**
|
||||
* Determines whether all the members of an array satisfy the specified test.
|
||||
@@ -4193,7 +4199,7 @@ interface Float32Array {
|
||||
/**
|
||||
* Returns an list of keys in the array
|
||||
*/
|
||||
keys(): Iterator<number>;
|
||||
keys(): IterableIterator<number>;
|
||||
|
||||
/**
|
||||
* Returns the index of the last occurrence of a value in an array.
|
||||
@@ -4330,10 +4336,10 @@ interface Float32Array {
|
||||
/**
|
||||
* Returns an list of values in the array
|
||||
*/
|
||||
values(): Iterator<number>;
|
||||
values(): IterableIterator<number>;
|
||||
|
||||
[index: number]: number;
|
||||
// [Symbol.iterator] (): Iterator<number>;
|
||||
[Symbol.iterator](): IterableIterator<number>;
|
||||
}
|
||||
|
||||
interface Float32ArrayConstructor {
|
||||
@@ -4403,7 +4409,7 @@ interface Float64Array {
|
||||
/**
|
||||
* Returns an array of key, value pairs for every entry in the array
|
||||
*/
|
||||
entries(): Iterator<[number, number]>;
|
||||
entries(): IterableIterator<[number, number]>;
|
||||
|
||||
/**
|
||||
* Determines whether all the members of an array satisfy the specified test.
|
||||
@@ -4483,7 +4489,7 @@ interface Float64Array {
|
||||
/**
|
||||
* Returns an list of keys in the array
|
||||
*/
|
||||
keys(): Iterator<number>;
|
||||
keys(): IterableIterator<number>;
|
||||
|
||||
/**
|
||||
* Returns the index of the last occurrence of a value in an array.
|
||||
@@ -4620,10 +4626,10 @@ interface Float64Array {
|
||||
/**
|
||||
* Returns an list of values in the array
|
||||
*/
|
||||
values(): Iterator<number>;
|
||||
values(): IterableIterator<number>;
|
||||
|
||||
[index: number]: number;
|
||||
// [Symbol.iterator] (): Iterator<number>;
|
||||
[Symbol.iterator](): IterableIterator<number>;
|
||||
}
|
||||
|
||||
interface Float64ArrayConstructor {
|
||||
@@ -4682,12 +4688,12 @@ declare var Reflect: {
|
||||
construct(target: Function, argumentsList: ArrayLike<any>): any;
|
||||
defineProperty(target: any, propertyKey: PropertyKey, attributes: PropertyDescriptor): boolean;
|
||||
deleteProperty(target: any, propertyKey: PropertyKey): boolean;
|
||||
enumerate(target: any): Iterator<any>;
|
||||
enumerate(target: any): IterableIterator<any>;
|
||||
get(target: any, propertyKey: PropertyKey, receiver?: any): any;
|
||||
getOwnPropertyDescriptor(target: any, propertyKey: PropertyKey): PropertyDescriptor;
|
||||
getPrototypeOf(target: any): any;
|
||||
has(target: any, propertyKey: string): boolean;
|
||||
has(target: any, propertyKey: Symbol): boolean;
|
||||
has(target: any, propertyKey: symbol): boolean;
|
||||
isExtensible(target: any): boolean;
|
||||
ownKeys(target: any): Array<PropertyKey>;
|
||||
preventExtensions(target: any): boolean;
|
||||
|
||||
Vendored
+85
-79
@@ -1164,7 +1164,7 @@ interface ArrayConstructor {
|
||||
}
|
||||
|
||||
declare var Array: ArrayConstructor;
|
||||
declare type PropertyKey = string | number | Symbol;
|
||||
declare type PropertyKey = string | number | symbol;
|
||||
|
||||
interface Symbol {
|
||||
/** Returns a string representation of an object. */
|
||||
@@ -1173,7 +1173,7 @@ interface Symbol {
|
||||
/** Returns the primitive value of the specified object. */
|
||||
valueOf(): Object;
|
||||
|
||||
// [Symbol.toStringTag]: string;
|
||||
[Symbol.toStringTag]: string;
|
||||
}
|
||||
|
||||
interface SymbolConstructor {
|
||||
@@ -1186,21 +1186,21 @@ interface SymbolConstructor {
|
||||
* Returns a new unique Symbol value.
|
||||
* @param description Description of the new Symbol object.
|
||||
*/
|
||||
(description?: string|number): Symbol;
|
||||
(description?: string|number): symbol;
|
||||
|
||||
/**
|
||||
* Returns a Symbol object from the global symbol registry matching the given key if found.
|
||||
* Otherwise, returns a new symbol with this key.
|
||||
* @param key key to search for.
|
||||
*/
|
||||
for(key: string): Symbol;
|
||||
for(key: string): symbol;
|
||||
|
||||
/**
|
||||
* Returns a key from the global symbol registry matching the given Symbol if found.
|
||||
* Otherwise, returns a undefined.
|
||||
* @param sym Symbol to find the key for.
|
||||
*/
|
||||
keyFor(sym: Symbol): string;
|
||||
keyFor(sym: symbol): string;
|
||||
|
||||
// Well-known Symbols
|
||||
|
||||
@@ -1208,42 +1208,42 @@ interface SymbolConstructor {
|
||||
* A method that determines if a constructor object recognizes an object as one of the
|
||||
* constructor’s instances. Called by the semantics of the instanceof operator.
|
||||
*/
|
||||
hasInstance: Symbol;
|
||||
hasInstance: symbol;
|
||||
|
||||
/**
|
||||
* A Boolean value that if true indicates that an object should flatten to its array elements
|
||||
* by Array.prototype.concat.
|
||||
*/
|
||||
isConcatSpreadable: Symbol;
|
||||
isConcatSpreadable: symbol;
|
||||
|
||||
/**
|
||||
* A Boolean value that if true indicates that an object may be used as a regular expression.
|
||||
*/
|
||||
isRegExp: Symbol;
|
||||
isRegExp: symbol;
|
||||
|
||||
/**
|
||||
* A method that returns the default iterator for an object.Called by the semantics of the
|
||||
* for-of statement.
|
||||
*/
|
||||
iterator: Symbol;
|
||||
iterator: symbol;
|
||||
|
||||
/**
|
||||
* A method that converts an object to a corresponding primitive value.Called by the ToPrimitive
|
||||
* abstract operation.
|
||||
*/
|
||||
toPrimitive: Symbol;
|
||||
toPrimitive: symbol;
|
||||
|
||||
/**
|
||||
* A String value that is used in the creation of the default string description of an object.
|
||||
* Called by the built- in method Object.prototype.toString.
|
||||
*/
|
||||
toStringTag: Symbol;
|
||||
toStringTag: symbol;
|
||||
|
||||
/**
|
||||
* An Object whose own property names are property names that are excluded from the with
|
||||
* environment bindings of the associated objects.
|
||||
*/
|
||||
unscopables: Symbol;
|
||||
unscopables: symbol;
|
||||
}
|
||||
declare var Symbol: SymbolConstructor;
|
||||
|
||||
@@ -1274,7 +1274,7 @@ interface ObjectConstructor {
|
||||
* Returns an array of all symbol properties found directly on object o.
|
||||
* @param o Object to retrieve the symbols from.
|
||||
*/
|
||||
getOwnPropertySymbols(o: any): Symbol[];
|
||||
getOwnPropertySymbols(o: any): symbol[];
|
||||
|
||||
/**
|
||||
* Returns true if the values are the same value, false otherwise.
|
||||
@@ -1396,22 +1396,22 @@ interface ArrayLike<T> {
|
||||
|
||||
interface Array<T> {
|
||||
/** Iterator */
|
||||
// [Symbol.iterator] (): Iterator<T>;
|
||||
[Symbol.iterator](): IterableIterator<T>;
|
||||
|
||||
/**
|
||||
* Returns an array of key, value pairs for every entry in the array
|
||||
*/
|
||||
entries(): Iterator<[number, T]>;
|
||||
entries(): IterableIterator<[number, T]>;
|
||||
|
||||
/**
|
||||
* Returns an list of keys in the array
|
||||
*/
|
||||
keys(): Iterator<number>;
|
||||
keys(): IterableIterator<number>;
|
||||
|
||||
/**
|
||||
* Returns an list of values in the array
|
||||
*/
|
||||
values(): Iterator<T>;
|
||||
values(): IterableIterator<T>;
|
||||
|
||||
/**
|
||||
* Returns the value of the first element in the array where predicate is true, and undefined
|
||||
@@ -1495,7 +1495,7 @@ interface ArrayConstructor {
|
||||
|
||||
interface String {
|
||||
/** Iterator */
|
||||
// [Symbol.iterator] (): Iterator<string>;
|
||||
[Symbol.iterator](): IterableIterator<string>;
|
||||
|
||||
/**
|
||||
* Returns a nonnegative integer Number less than 1114112 (0x110000) that is the code point
|
||||
@@ -1613,12 +1613,17 @@ interface IteratorResult<T> {
|
||||
}
|
||||
|
||||
interface Iterator<T> {
|
||||
//[Symbol.iterator](): Iterator<T>;
|
||||
next(): IteratorResult<T>;
|
||||
return?(value?: any): IteratorResult<T>;
|
||||
throw?(e?: any): IteratorResult<T>;
|
||||
}
|
||||
|
||||
interface Iterable<T> {
|
||||
//[Symbol.iterator](): Iterator<T>;
|
||||
[Symbol.iterator](): Iterator<T>;
|
||||
}
|
||||
|
||||
interface IterableIterator<T> extends Iterator<T> {
|
||||
[Symbol.iterator](): IterableIterator<T>;
|
||||
}
|
||||
|
||||
interface GeneratorFunction extends Function {
|
||||
@@ -1636,11 +1641,12 @@ interface GeneratorFunctionConstructor {
|
||||
}
|
||||
declare var GeneratorFunction: GeneratorFunctionConstructor;
|
||||
|
||||
interface Generator<T> extends Iterator<T> {
|
||||
interface Generator<T> extends IterableIterator<T> {
|
||||
next(value?: any): IteratorResult<T>;
|
||||
throw (exception: any): IteratorResult<T>;
|
||||
return (value: T): IteratorResult<T>;
|
||||
// [Symbol.toStringTag]: string;
|
||||
throw(exception: any): IteratorResult<T>;
|
||||
return(value: T): IteratorResult<T>;
|
||||
[Symbol.iterator](): Generator<T>;
|
||||
[Symbol.toStringTag]: string;
|
||||
}
|
||||
|
||||
interface Math {
|
||||
@@ -1754,11 +1760,11 @@ interface Math {
|
||||
*/
|
||||
cbrt(x: number): number;
|
||||
|
||||
// [Symbol.toStringTag]: string;
|
||||
[Symbol.toStringTag]: string;
|
||||
}
|
||||
|
||||
interface RegExp {
|
||||
// [Symbol.isRegExp]: boolean;
|
||||
[Symbol.isRegExp]: boolean;
|
||||
|
||||
/**
|
||||
* Matches a string with a regular expression, and returns an array containing the results of
|
||||
@@ -1807,16 +1813,16 @@ interface RegExp {
|
||||
interface Map<K, V> {
|
||||
clear(): void;
|
||||
delete(key: K): boolean;
|
||||
entries(): Iterator<[K, V]>;
|
||||
entries(): IterableIterator<[K, V]>;
|
||||
forEach(callbackfn: (value: V, index: K, map: Map<K, V>) => void, thisArg?: any): void;
|
||||
get(key: K): V;
|
||||
has(key: K): boolean;
|
||||
keys(): Iterator<K>;
|
||||
keys(): IterableIterator<K>;
|
||||
set(key: K, value?: V): Map<K, V>;
|
||||
size: number;
|
||||
values(): Iterator<V>;
|
||||
// [Symbol.iterator]():Iterator<[K,V]>;
|
||||
// [Symbol.toStringTag]: string;
|
||||
values(): IterableIterator<V>;
|
||||
[Symbol.iterator]():IterableIterator<[K,V]>;
|
||||
[Symbol.toStringTag]: string;
|
||||
}
|
||||
|
||||
interface MapConstructor {
|
||||
@@ -1832,7 +1838,7 @@ interface WeakMap<K, V> {
|
||||
get(key: K): V;
|
||||
has(key: K): boolean;
|
||||
set(key: K, value?: V): WeakMap<K, V>;
|
||||
// [Symbol.toStringTag]: string;
|
||||
[Symbol.toStringTag]: string;
|
||||
}
|
||||
|
||||
interface WeakMapConstructor {
|
||||
@@ -1846,14 +1852,14 @@ interface Set<T> {
|
||||
add(value: T): Set<T>;
|
||||
clear(): void;
|
||||
delete(value: T): boolean;
|
||||
entries(): Iterator<[T, T]>;
|
||||
entries(): IterableIterator<[T, T]>;
|
||||
forEach(callbackfn: (value: T, index: T, set: Set<T>) => void, thisArg?: any): void;
|
||||
has(value: T): boolean;
|
||||
keys(): Iterator<T>;
|
||||
keys(): IterableIterator<T>;
|
||||
size: number;
|
||||
values(): Iterator<T>;
|
||||
// [Symbol.iterator]():Iterator<T>;
|
||||
// [Symbol.toStringTag]: string;
|
||||
values(): IterableIterator<T>;
|
||||
[Symbol.iterator]():IterableIterator<T>;
|
||||
[Symbol.toStringTag]: string;
|
||||
}
|
||||
|
||||
interface SetConstructor {
|
||||
@@ -1868,7 +1874,7 @@ interface WeakSet<T> {
|
||||
clear(): void;
|
||||
delete(value: T): boolean;
|
||||
has(value: T): boolean;
|
||||
// [Symbol.toStringTag]: string;
|
||||
[Symbol.toStringTag]: string;
|
||||
}
|
||||
|
||||
interface WeakSetConstructor {
|
||||
@@ -1879,7 +1885,7 @@ interface WeakSetConstructor {
|
||||
declare var WeakSet: WeakSetConstructor;
|
||||
|
||||
interface JSON {
|
||||
// [Symbol.toStringTag]: string;
|
||||
[Symbol.toStringTag]: string;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1899,7 +1905,7 @@ interface ArrayBuffer {
|
||||
*/
|
||||
slice(begin: number, end?: number): ArrayBuffer;
|
||||
|
||||
// [Symbol.toStringTag]: string;
|
||||
[Symbol.toStringTag]: string;
|
||||
}
|
||||
|
||||
interface ArrayBufferConstructor {
|
||||
@@ -2036,7 +2042,7 @@ interface DataView {
|
||||
*/
|
||||
setUint32(byteOffset: number, value: number, littleEndian: boolean): void;
|
||||
|
||||
// [Symbol.toStringTag]: string;
|
||||
[Symbol.toStringTag]: string;
|
||||
}
|
||||
|
||||
interface DataViewConstructor {
|
||||
@@ -2083,7 +2089,7 @@ interface Int8Array {
|
||||
/**
|
||||
* Returns an array of key, value pairs for every entry in the array
|
||||
*/
|
||||
entries(): Iterator<[number, number]>;
|
||||
entries(): IterableIterator<[number, number]>;
|
||||
|
||||
/**
|
||||
* Determines whether all the members of an array satisfy the specified test.
|
||||
@@ -2163,7 +2169,7 @@ interface Int8Array {
|
||||
/**
|
||||
* Returns an list of keys in the array
|
||||
*/
|
||||
keys(): Iterator<number>;
|
||||
keys(): IterableIterator<number>;
|
||||
|
||||
/**
|
||||
* Returns the index of the last occurrence of a value in an array.
|
||||
@@ -2300,10 +2306,10 @@ interface Int8Array {
|
||||
/**
|
||||
* Returns an list of values in the array
|
||||
*/
|
||||
values(): Iterator<number>;
|
||||
values(): IterableIterator<number>;
|
||||
|
||||
[index: number]: number;
|
||||
// [Symbol.iterator] (): Iterator<number>;
|
||||
[Symbol.iterator](): IterableIterator<number>;
|
||||
}
|
||||
|
||||
interface Int8ArrayConstructor {
|
||||
@@ -2373,7 +2379,7 @@ interface Uint8Array {
|
||||
/**
|
||||
* Returns an array of key, value pairs for every entry in the array
|
||||
*/
|
||||
entries(): Iterator<[number, number]>;
|
||||
entries(): IterableIterator<[number, number]>;
|
||||
|
||||
/**
|
||||
* Determines whether all the members of an array satisfy the specified test.
|
||||
@@ -2453,7 +2459,7 @@ interface Uint8Array {
|
||||
/**
|
||||
* Returns an list of keys in the array
|
||||
*/
|
||||
keys(): Iterator<number>;
|
||||
keys(): IterableIterator<number>;
|
||||
|
||||
/**
|
||||
* Returns the index of the last occurrence of a value in an array.
|
||||
@@ -2590,10 +2596,10 @@ interface Uint8Array {
|
||||
/**
|
||||
* Returns an list of values in the array
|
||||
*/
|
||||
values(): Iterator<number>;
|
||||
values(): IterableIterator<number>;
|
||||
|
||||
[index: number]: number;
|
||||
// [Symbol.iterator] (): Iterator<number>;
|
||||
[Symbol.iterator](): IterableIterator<number>;
|
||||
}
|
||||
|
||||
interface Uint8ArrayConstructor {
|
||||
@@ -2663,7 +2669,7 @@ interface Uint8ClampedArray {
|
||||
/**
|
||||
* Returns an array of key, value pairs for every entry in the array
|
||||
*/
|
||||
entries(): Iterator<[number, number]>;
|
||||
entries(): IterableIterator<[number, number]>;
|
||||
|
||||
/**
|
||||
* Determines whether all the members of an array satisfy the specified test.
|
||||
@@ -2743,7 +2749,7 @@ interface Uint8ClampedArray {
|
||||
/**
|
||||
* Returns an list of keys in the array
|
||||
*/
|
||||
keys(): Iterator<number>;
|
||||
keys(): IterableIterator<number>;
|
||||
|
||||
/**
|
||||
* Returns the index of the last occurrence of a value in an array.
|
||||
@@ -2880,10 +2886,10 @@ interface Uint8ClampedArray {
|
||||
/**
|
||||
* Returns an list of values in the array
|
||||
*/
|
||||
values(): Iterator<number>;
|
||||
values(): IterableIterator<number>;
|
||||
|
||||
[index: number]: number;
|
||||
// [Symbol.iterator] (): Iterator<number>;
|
||||
[Symbol.iterator](): IterableIterator<number>;
|
||||
}
|
||||
|
||||
interface Uint8ClampedArrayConstructor {
|
||||
@@ -2953,7 +2959,7 @@ interface Int16Array {
|
||||
/**
|
||||
* Returns an array of key, value pairs for every entry in the array
|
||||
*/
|
||||
entries(): Iterator<[number, number]>;
|
||||
entries(): IterableIterator<[number, number]>;
|
||||
|
||||
/**
|
||||
* Determines whether all the members of an array satisfy the specified test.
|
||||
@@ -3033,7 +3039,7 @@ interface Int16Array {
|
||||
/**
|
||||
* Returns an list of keys in the array
|
||||
*/
|
||||
keys(): Iterator<number>;
|
||||
keys(): IterableIterator<number>;
|
||||
|
||||
/**
|
||||
* Returns the index of the last occurrence of a value in an array.
|
||||
@@ -3170,10 +3176,10 @@ interface Int16Array {
|
||||
/**
|
||||
* Returns an list of values in the array
|
||||
*/
|
||||
values(): Iterator<number>;
|
||||
values(): IterableIterator<number>;
|
||||
|
||||
[index: number]: number;
|
||||
// [Symbol.iterator] (): Iterator<number>;
|
||||
[Symbol.iterator](): IterableIterator<number>;
|
||||
}
|
||||
|
||||
interface Int16ArrayConstructor {
|
||||
@@ -3243,7 +3249,7 @@ interface Uint16Array {
|
||||
/**
|
||||
* Returns an array of key, value pairs for every entry in the array
|
||||
*/
|
||||
entries(): Iterator<[number, number]>;
|
||||
entries(): IterableIterator<[number, number]>;
|
||||
|
||||
/**
|
||||
* Determines whether all the members of an array satisfy the specified test.
|
||||
@@ -3323,7 +3329,7 @@ interface Uint16Array {
|
||||
/**
|
||||
* Returns an list of keys in the array
|
||||
*/
|
||||
keys(): Iterator<number>;
|
||||
keys(): IterableIterator<number>;
|
||||
|
||||
/**
|
||||
* Returns the index of the last occurrence of a value in an array.
|
||||
@@ -3460,10 +3466,10 @@ interface Uint16Array {
|
||||
/**
|
||||
* Returns an list of values in the array
|
||||
*/
|
||||
values(): Iterator<number>;
|
||||
values(): IterableIterator<number>;
|
||||
|
||||
[index: number]: number;
|
||||
// [Symbol.iterator] (): Iterator<number>;
|
||||
[Symbol.iterator](): IterableIterator<number>;
|
||||
}
|
||||
|
||||
interface Uint16ArrayConstructor {
|
||||
@@ -3533,7 +3539,7 @@ interface Int32Array {
|
||||
/**
|
||||
* Returns an array of key, value pairs for every entry in the array
|
||||
*/
|
||||
entries(): Iterator<[number, number]>;
|
||||
entries(): IterableIterator<[number, number]>;
|
||||
|
||||
/**
|
||||
* Determines whether all the members of an array satisfy the specified test.
|
||||
@@ -3613,7 +3619,7 @@ interface Int32Array {
|
||||
/**
|
||||
* Returns an list of keys in the array
|
||||
*/
|
||||
keys(): Iterator<number>;
|
||||
keys(): IterableIterator<number>;
|
||||
|
||||
/**
|
||||
* Returns the index of the last occurrence of a value in an array.
|
||||
@@ -3750,10 +3756,10 @@ interface Int32Array {
|
||||
/**
|
||||
* Returns an list of values in the array
|
||||
*/
|
||||
values(): Iterator<number>;
|
||||
values(): IterableIterator<number>;
|
||||
|
||||
[index: number]: number;
|
||||
// [Symbol.iterator] (): Iterator<number>;
|
||||
[Symbol.iterator](): IterableIterator<number>;
|
||||
}
|
||||
|
||||
interface Int32ArrayConstructor {
|
||||
@@ -3823,7 +3829,7 @@ interface Uint32Array {
|
||||
/**
|
||||
* Returns an array of key, value pairs for every entry in the array
|
||||
*/
|
||||
entries(): Iterator<[number, number]>;
|
||||
entries(): IterableIterator<[number, number]>;
|
||||
|
||||
/**
|
||||
* Determines whether all the members of an array satisfy the specified test.
|
||||
@@ -3903,7 +3909,7 @@ interface Uint32Array {
|
||||
/**
|
||||
* Returns an list of keys in the array
|
||||
*/
|
||||
keys(): Iterator<number>;
|
||||
keys(): IterableIterator<number>;
|
||||
|
||||
/**
|
||||
* Returns the index of the last occurrence of a value in an array.
|
||||
@@ -4040,10 +4046,10 @@ interface Uint32Array {
|
||||
/**
|
||||
* Returns an list of values in the array
|
||||
*/
|
||||
values(): Iterator<number>;
|
||||
values(): IterableIterator<number>;
|
||||
|
||||
[index: number]: number;
|
||||
// [Symbol.iterator] (): Iterator<number>;
|
||||
[Symbol.iterator](): IterableIterator<number>;
|
||||
}
|
||||
|
||||
interface Uint32ArrayConstructor {
|
||||
@@ -4113,7 +4119,7 @@ interface Float32Array {
|
||||
/**
|
||||
* Returns an array of key, value pairs for every entry in the array
|
||||
*/
|
||||
entries(): Iterator<[number, number]>;
|
||||
entries(): IterableIterator<[number, number]>;
|
||||
|
||||
/**
|
||||
* Determines whether all the members of an array satisfy the specified test.
|
||||
@@ -4193,7 +4199,7 @@ interface Float32Array {
|
||||
/**
|
||||
* Returns an list of keys in the array
|
||||
*/
|
||||
keys(): Iterator<number>;
|
||||
keys(): IterableIterator<number>;
|
||||
|
||||
/**
|
||||
* Returns the index of the last occurrence of a value in an array.
|
||||
@@ -4330,10 +4336,10 @@ interface Float32Array {
|
||||
/**
|
||||
* Returns an list of values in the array
|
||||
*/
|
||||
values(): Iterator<number>;
|
||||
values(): IterableIterator<number>;
|
||||
|
||||
[index: number]: number;
|
||||
// [Symbol.iterator] (): Iterator<number>;
|
||||
[Symbol.iterator](): IterableIterator<number>;
|
||||
}
|
||||
|
||||
interface Float32ArrayConstructor {
|
||||
@@ -4403,7 +4409,7 @@ interface Float64Array {
|
||||
/**
|
||||
* Returns an array of key, value pairs for every entry in the array
|
||||
*/
|
||||
entries(): Iterator<[number, number]>;
|
||||
entries(): IterableIterator<[number, number]>;
|
||||
|
||||
/**
|
||||
* Determines whether all the members of an array satisfy the specified test.
|
||||
@@ -4483,7 +4489,7 @@ interface Float64Array {
|
||||
/**
|
||||
* Returns an list of keys in the array
|
||||
*/
|
||||
keys(): Iterator<number>;
|
||||
keys(): IterableIterator<number>;
|
||||
|
||||
/**
|
||||
* Returns the index of the last occurrence of a value in an array.
|
||||
@@ -4620,10 +4626,10 @@ interface Float64Array {
|
||||
/**
|
||||
* Returns an list of values in the array
|
||||
*/
|
||||
values(): Iterator<number>;
|
||||
values(): IterableIterator<number>;
|
||||
|
||||
[index: number]: number;
|
||||
// [Symbol.iterator] (): Iterator<number>;
|
||||
[Symbol.iterator](): IterableIterator<number>;
|
||||
}
|
||||
|
||||
interface Float64ArrayConstructor {
|
||||
@@ -4682,12 +4688,12 @@ declare var Reflect: {
|
||||
construct(target: Function, argumentsList: ArrayLike<any>): any;
|
||||
defineProperty(target: any, propertyKey: PropertyKey, attributes: PropertyDescriptor): boolean;
|
||||
deleteProperty(target: any, propertyKey: PropertyKey): boolean;
|
||||
enumerate(target: any): Iterator<any>;
|
||||
enumerate(target: any): IterableIterator<any>;
|
||||
get(target: any, propertyKey: PropertyKey, receiver?: any): any;
|
||||
getOwnPropertyDescriptor(target: any, propertyKey: PropertyKey): PropertyDescriptor;
|
||||
getPrototypeOf(target: any): any;
|
||||
has(target: any, propertyKey: string): boolean;
|
||||
has(target: any, propertyKey: Symbol): boolean;
|
||||
has(target: any, propertyKey: symbol): boolean;
|
||||
isExtensible(target: any): boolean;
|
||||
ownKeys(target: any): Array<PropertyKey>;
|
||||
preventExtensions(target: any): boolean;
|
||||
|
||||
+3492
-2152
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,2 @@
|
||||
#!/usr/bin/env node
|
||||
require('./tsserver.js')
|
||||
+31943
File diff suppressed because one or more lines are too long
Vendored
+211
-136
@@ -123,129 +123,142 @@ declare module "typescript" {
|
||||
VoidKeyword = 98,
|
||||
WhileKeyword = 99,
|
||||
WithKeyword = 100,
|
||||
ImplementsKeyword = 101,
|
||||
InterfaceKeyword = 102,
|
||||
LetKeyword = 103,
|
||||
PackageKeyword = 104,
|
||||
PrivateKeyword = 105,
|
||||
ProtectedKeyword = 106,
|
||||
PublicKeyword = 107,
|
||||
StaticKeyword = 108,
|
||||
YieldKeyword = 109,
|
||||
AnyKeyword = 110,
|
||||
BooleanKeyword = 111,
|
||||
ConstructorKeyword = 112,
|
||||
DeclareKeyword = 113,
|
||||
GetKeyword = 114,
|
||||
ModuleKeyword = 115,
|
||||
RequireKeyword = 116,
|
||||
NumberKeyword = 117,
|
||||
SetKeyword = 118,
|
||||
StringKeyword = 119,
|
||||
TypeKeyword = 120,
|
||||
QualifiedName = 121,
|
||||
ComputedPropertyName = 122,
|
||||
TypeParameter = 123,
|
||||
Parameter = 124,
|
||||
PropertySignature = 125,
|
||||
PropertyDeclaration = 126,
|
||||
MethodSignature = 127,
|
||||
MethodDeclaration = 128,
|
||||
Constructor = 129,
|
||||
GetAccessor = 130,
|
||||
SetAccessor = 131,
|
||||
CallSignature = 132,
|
||||
ConstructSignature = 133,
|
||||
IndexSignature = 134,
|
||||
TypeReference = 135,
|
||||
FunctionType = 136,
|
||||
ConstructorType = 137,
|
||||
TypeQuery = 138,
|
||||
TypeLiteral = 139,
|
||||
ArrayType = 140,
|
||||
TupleType = 141,
|
||||
UnionType = 142,
|
||||
ParenthesizedType = 143,
|
||||
ObjectBindingPattern = 144,
|
||||
ArrayBindingPattern = 145,
|
||||
BindingElement = 146,
|
||||
ArrayLiteralExpression = 147,
|
||||
ObjectLiteralExpression = 148,
|
||||
PropertyAccessExpression = 149,
|
||||
ElementAccessExpression = 150,
|
||||
CallExpression = 151,
|
||||
NewExpression = 152,
|
||||
TaggedTemplateExpression = 153,
|
||||
TypeAssertionExpression = 154,
|
||||
ParenthesizedExpression = 155,
|
||||
FunctionExpression = 156,
|
||||
ArrowFunction = 157,
|
||||
DeleteExpression = 158,
|
||||
TypeOfExpression = 159,
|
||||
VoidExpression = 160,
|
||||
PrefixUnaryExpression = 161,
|
||||
PostfixUnaryExpression = 162,
|
||||
BinaryExpression = 163,
|
||||
ConditionalExpression = 164,
|
||||
TemplateExpression = 165,
|
||||
YieldExpression = 166,
|
||||
SpreadElementExpression = 167,
|
||||
OmittedExpression = 168,
|
||||
TemplateSpan = 169,
|
||||
Block = 170,
|
||||
VariableStatement = 171,
|
||||
EmptyStatement = 172,
|
||||
ExpressionStatement = 173,
|
||||
IfStatement = 174,
|
||||
DoStatement = 175,
|
||||
WhileStatement = 176,
|
||||
ForStatement = 177,
|
||||
ForInStatement = 178,
|
||||
ContinueStatement = 179,
|
||||
BreakStatement = 180,
|
||||
ReturnStatement = 181,
|
||||
WithStatement = 182,
|
||||
SwitchStatement = 183,
|
||||
LabeledStatement = 184,
|
||||
ThrowStatement = 185,
|
||||
TryStatement = 186,
|
||||
DebuggerStatement = 187,
|
||||
VariableDeclaration = 188,
|
||||
VariableDeclarationList = 189,
|
||||
FunctionDeclaration = 190,
|
||||
ClassDeclaration = 191,
|
||||
InterfaceDeclaration = 192,
|
||||
TypeAliasDeclaration = 193,
|
||||
EnumDeclaration = 194,
|
||||
ModuleDeclaration = 195,
|
||||
ModuleBlock = 196,
|
||||
ImportDeclaration = 197,
|
||||
ExportAssignment = 198,
|
||||
ExternalModuleReference = 199,
|
||||
CaseClause = 200,
|
||||
DefaultClause = 201,
|
||||
HeritageClause = 202,
|
||||
CatchClause = 203,
|
||||
PropertyAssignment = 204,
|
||||
ShorthandPropertyAssignment = 205,
|
||||
EnumMember = 206,
|
||||
SourceFile = 207,
|
||||
SyntaxList = 208,
|
||||
Count = 209,
|
||||
AsKeyword = 101,
|
||||
FromKeyword = 102,
|
||||
ImplementsKeyword = 103,
|
||||
InterfaceKeyword = 104,
|
||||
LetKeyword = 105,
|
||||
PackageKeyword = 106,
|
||||
PrivateKeyword = 107,
|
||||
ProtectedKeyword = 108,
|
||||
PublicKeyword = 109,
|
||||
StaticKeyword = 110,
|
||||
YieldKeyword = 111,
|
||||
AnyKeyword = 112,
|
||||
BooleanKeyword = 113,
|
||||
ConstructorKeyword = 114,
|
||||
DeclareKeyword = 115,
|
||||
GetKeyword = 116,
|
||||
ModuleKeyword = 117,
|
||||
RequireKeyword = 118,
|
||||
NumberKeyword = 119,
|
||||
SetKeyword = 120,
|
||||
StringKeyword = 121,
|
||||
SymbolKeyword = 122,
|
||||
TypeKeyword = 123,
|
||||
OfKeyword = 124,
|
||||
QualifiedName = 125,
|
||||
ComputedPropertyName = 126,
|
||||
TypeParameter = 127,
|
||||
Parameter = 128,
|
||||
PropertySignature = 129,
|
||||
PropertyDeclaration = 130,
|
||||
MethodSignature = 131,
|
||||
MethodDeclaration = 132,
|
||||
Constructor = 133,
|
||||
GetAccessor = 134,
|
||||
SetAccessor = 135,
|
||||
CallSignature = 136,
|
||||
ConstructSignature = 137,
|
||||
IndexSignature = 138,
|
||||
TypeReference = 139,
|
||||
FunctionType = 140,
|
||||
ConstructorType = 141,
|
||||
TypeQuery = 142,
|
||||
TypeLiteral = 143,
|
||||
ArrayType = 144,
|
||||
TupleType = 145,
|
||||
UnionType = 146,
|
||||
ParenthesizedType = 147,
|
||||
ObjectBindingPattern = 148,
|
||||
ArrayBindingPattern = 149,
|
||||
BindingElement = 150,
|
||||
ArrayLiteralExpression = 151,
|
||||
ObjectLiteralExpression = 152,
|
||||
PropertyAccessExpression = 153,
|
||||
ElementAccessExpression = 154,
|
||||
CallExpression = 155,
|
||||
NewExpression = 156,
|
||||
TaggedTemplateExpression = 157,
|
||||
TypeAssertionExpression = 158,
|
||||
ParenthesizedExpression = 159,
|
||||
FunctionExpression = 160,
|
||||
ArrowFunction = 161,
|
||||
DeleteExpression = 162,
|
||||
TypeOfExpression = 163,
|
||||
VoidExpression = 164,
|
||||
PrefixUnaryExpression = 165,
|
||||
PostfixUnaryExpression = 166,
|
||||
BinaryExpression = 167,
|
||||
ConditionalExpression = 168,
|
||||
TemplateExpression = 169,
|
||||
YieldExpression = 170,
|
||||
SpreadElementExpression = 171,
|
||||
OmittedExpression = 172,
|
||||
TemplateSpan = 173,
|
||||
Block = 174,
|
||||
VariableStatement = 175,
|
||||
EmptyStatement = 176,
|
||||
ExpressionStatement = 177,
|
||||
IfStatement = 178,
|
||||
DoStatement = 179,
|
||||
WhileStatement = 180,
|
||||
ForStatement = 181,
|
||||
ForInStatement = 182,
|
||||
ForOfStatement = 183,
|
||||
ContinueStatement = 184,
|
||||
BreakStatement = 185,
|
||||
ReturnStatement = 186,
|
||||
WithStatement = 187,
|
||||
SwitchStatement = 188,
|
||||
LabeledStatement = 189,
|
||||
ThrowStatement = 190,
|
||||
TryStatement = 191,
|
||||
DebuggerStatement = 192,
|
||||
VariableDeclaration = 193,
|
||||
VariableDeclarationList = 194,
|
||||
FunctionDeclaration = 195,
|
||||
ClassDeclaration = 196,
|
||||
InterfaceDeclaration = 197,
|
||||
TypeAliasDeclaration = 198,
|
||||
EnumDeclaration = 199,
|
||||
ModuleDeclaration = 200,
|
||||
ModuleBlock = 201,
|
||||
ImportEqualsDeclaration = 202,
|
||||
ImportDeclaration = 203,
|
||||
ImportClause = 204,
|
||||
NamespaceImport = 205,
|
||||
NamedImports = 206,
|
||||
ImportSpecifier = 207,
|
||||
ExportAssignment = 208,
|
||||
ExportDeclaration = 209,
|
||||
NamedExports = 210,
|
||||
ExportSpecifier = 211,
|
||||
ExternalModuleReference = 212,
|
||||
CaseClause = 213,
|
||||
DefaultClause = 214,
|
||||
HeritageClause = 215,
|
||||
CatchClause = 216,
|
||||
PropertyAssignment = 217,
|
||||
ShorthandPropertyAssignment = 218,
|
||||
EnumMember = 219,
|
||||
SourceFile = 220,
|
||||
SyntaxList = 221,
|
||||
Count = 222,
|
||||
FirstAssignment = 52,
|
||||
LastAssignment = 63,
|
||||
FirstReservedWord = 65,
|
||||
LastReservedWord = 100,
|
||||
FirstKeyword = 65,
|
||||
LastKeyword = 120,
|
||||
FirstFutureReservedWord = 101,
|
||||
LastFutureReservedWord = 109,
|
||||
FirstTypeNode = 135,
|
||||
LastTypeNode = 143,
|
||||
LastKeyword = 124,
|
||||
FirstFutureReservedWord = 103,
|
||||
LastFutureReservedWord = 111,
|
||||
FirstTypeNode = 139,
|
||||
LastTypeNode = 147,
|
||||
FirstPunctuation = 14,
|
||||
LastPunctuation = 63,
|
||||
FirstToken = 0,
|
||||
LastToken = 120,
|
||||
LastToken = 124,
|
||||
FirstTriviaToken = 2,
|
||||
LastTriviaToken = 6,
|
||||
FirstLiteralToken = 7,
|
||||
@@ -254,7 +267,7 @@ declare module "typescript" {
|
||||
LastTemplateToken = 13,
|
||||
FirstBinaryOperator = 24,
|
||||
LastBinaryOperator = 63,
|
||||
FirstNode = 121,
|
||||
FirstNode = 125,
|
||||
}
|
||||
const enum NodeFlags {
|
||||
Export = 1,
|
||||
@@ -292,13 +305,13 @@ declare module "typescript" {
|
||||
kind: SyntaxKind;
|
||||
flags: NodeFlags;
|
||||
parserContextFlags?: ParserContextFlags;
|
||||
modifiers?: ModifiersArray;
|
||||
id?: number;
|
||||
parent?: Node;
|
||||
symbol?: Symbol;
|
||||
locals?: SymbolTable;
|
||||
nextContainer?: Node;
|
||||
localSymbol?: Symbol;
|
||||
modifiers?: ModifiersArray;
|
||||
}
|
||||
interface NodeArray<T> extends Array<T>, TextRange {
|
||||
hasTrailingComma?: boolean;
|
||||
@@ -487,7 +500,7 @@ declare module "typescript" {
|
||||
}
|
||||
interface BinaryExpression extends Expression {
|
||||
left: Expression;
|
||||
operator: SyntaxKind;
|
||||
operatorToken: Node;
|
||||
right: Expression;
|
||||
}
|
||||
interface ConditionalExpression extends Expression {
|
||||
@@ -585,6 +598,10 @@ declare module "typescript" {
|
||||
initializer: VariableDeclarationList | Expression;
|
||||
expression: Expression;
|
||||
}
|
||||
interface ForOfStatement extends IterationStatement {
|
||||
initializer: VariableDeclarationList | Expression;
|
||||
expression: Expression;
|
||||
}
|
||||
interface BreakOrContinueStatement extends Statement {
|
||||
label?: Identifier;
|
||||
}
|
||||
@@ -658,20 +675,49 @@ declare module "typescript" {
|
||||
name: Identifier;
|
||||
members: NodeArray<EnumMember>;
|
||||
}
|
||||
interface ModuleDeclaration extends Declaration, ModuleElement {
|
||||
interface ExportContainer {
|
||||
exportStars?: ExportDeclaration[];
|
||||
}
|
||||
interface ModuleDeclaration extends Declaration, ModuleElement, ExportContainer {
|
||||
name: Identifier | LiteralExpression;
|
||||
body: ModuleBlock | ModuleDeclaration;
|
||||
}
|
||||
interface ModuleBlock extends Node, ModuleElement {
|
||||
statements: NodeArray<ModuleElement>;
|
||||
}
|
||||
interface ImportDeclaration extends Declaration, ModuleElement {
|
||||
interface ImportEqualsDeclaration extends Declaration, ModuleElement {
|
||||
name: Identifier;
|
||||
moduleReference: EntityName | ExternalModuleReference;
|
||||
}
|
||||
interface ExternalModuleReference extends Node {
|
||||
expression?: Expression;
|
||||
}
|
||||
interface ImportDeclaration extends Statement, ModuleElement {
|
||||
importClause?: ImportClause;
|
||||
moduleSpecifier: Expression;
|
||||
}
|
||||
interface ImportClause extends Declaration {
|
||||
name?: Identifier;
|
||||
namedBindings?: NamespaceImport | NamedImports;
|
||||
}
|
||||
interface NamespaceImport extends Declaration {
|
||||
name: Identifier;
|
||||
}
|
||||
interface ExportDeclaration extends Statement, ModuleElement {
|
||||
exportClause?: NamedExports;
|
||||
moduleSpecifier?: Expression;
|
||||
}
|
||||
interface NamedImportsOrExports extends Node {
|
||||
elements: NodeArray<ImportOrExportSpecifier>;
|
||||
}
|
||||
type NamedImports = NamedImportsOrExports;
|
||||
type NamedExports = NamedImportsOrExports;
|
||||
interface ImportOrExportSpecifier extends Declaration {
|
||||
propertyName?: Identifier;
|
||||
name: Identifier;
|
||||
}
|
||||
type ImportSpecifier = ImportOrExportSpecifier;
|
||||
type ExportSpecifier = ImportOrExportSpecifier;
|
||||
interface ExportAssignment extends Statement, ModuleElement {
|
||||
exportName: Identifier;
|
||||
}
|
||||
@@ -681,7 +727,7 @@ declare module "typescript" {
|
||||
interface CommentRange extends TextRange {
|
||||
hasTrailingNewLine?: boolean;
|
||||
}
|
||||
interface SourceFile extends Declaration {
|
||||
interface SourceFile extends Declaration, ExportContainer {
|
||||
statements: NodeArray<ModuleElement>;
|
||||
endOfFileToken: Node;
|
||||
fileName: string;
|
||||
@@ -835,7 +881,7 @@ declare module "typescript" {
|
||||
}
|
||||
interface SymbolVisibilityResult {
|
||||
accessibility: SymbolAccessibility;
|
||||
aliasesToMakeVisible?: ImportDeclaration[];
|
||||
aliasesToMakeVisible?: ImportEqualsDeclaration[];
|
||||
errorSymbolName?: string;
|
||||
errorNode?: Node;
|
||||
}
|
||||
@@ -843,11 +889,11 @@ declare module "typescript" {
|
||||
errorModuleName?: string;
|
||||
}
|
||||
interface EmitResolver {
|
||||
getLocalNameOfContainer(container: ModuleDeclaration | EnumDeclaration): string;
|
||||
getExpressionNamePrefix(node: Identifier): string;
|
||||
getGeneratedNameForNode(node: ModuleDeclaration | EnumDeclaration | ImportDeclaration | ExportDeclaration): string;
|
||||
getExpressionNameSubstitution(node: Identifier): string;
|
||||
getExportAssignmentName(node: SourceFile): string;
|
||||
isReferencedImportDeclaration(node: ImportDeclaration): boolean;
|
||||
isTopLevelValueImportWithEntityName(node: ImportDeclaration): boolean;
|
||||
isReferencedImportDeclaration(node: Node): boolean;
|
||||
isTopLevelValueImportEqualsWithEntityName(node: ImportEqualsDeclaration): boolean;
|
||||
getNodeCheckFlags(node: Node): NodeCheckFlags;
|
||||
isDeclarationVisible(node: Declaration): boolean;
|
||||
isImplementationOfOverload(node: FunctionLikeDeclaration): boolean;
|
||||
@@ -942,8 +988,10 @@ declare module "typescript" {
|
||||
declaredType?: Type;
|
||||
mapper?: TypeMapper;
|
||||
referenced?: boolean;
|
||||
exportAssignSymbol?: Symbol;
|
||||
exportAssignmentChecked?: boolean;
|
||||
exportAssignmentSymbol?: Symbol;
|
||||
unionType?: UnionType;
|
||||
resolvedExports?: SymbolTable;
|
||||
}
|
||||
interface TransientSymbol extends Symbol, SymbolLinks {
|
||||
}
|
||||
@@ -968,7 +1016,8 @@ declare module "typescript" {
|
||||
enumMemberValue?: number;
|
||||
isIllegalTypeReferenceInConstraint?: boolean;
|
||||
isVisible?: boolean;
|
||||
localModuleName?: string;
|
||||
generatedName?: string;
|
||||
generatedNames?: Map<string>;
|
||||
assignmentChecks?: Map<boolean>;
|
||||
hasReportedStatementInAmbientContext?: boolean;
|
||||
importOnRightSide?: Symbol;
|
||||
@@ -994,8 +1043,9 @@ declare module "typescript" {
|
||||
ObjectLiteral = 131072,
|
||||
ContainsUndefinedOrNull = 262144,
|
||||
ContainsObjectLiteral = 524288,
|
||||
Intrinsic = 127,
|
||||
Primitive = 510,
|
||||
ESSymbol = 1048576,
|
||||
Intrinsic = 1048703,
|
||||
Primitive = 1049086,
|
||||
StringLike = 258,
|
||||
NumberLike = 132,
|
||||
ObjectType = 48128,
|
||||
@@ -1281,6 +1331,7 @@ declare module "typescript" {
|
||||
equals = 61,
|
||||
exclamation = 33,
|
||||
greaterThan = 62,
|
||||
hash = 35,
|
||||
lessThan = 60,
|
||||
minus = 45,
|
||||
openBrace = 123,
|
||||
@@ -1347,8 +1398,8 @@ declare module "typescript" {
|
||||
}
|
||||
function tokenToString(t: SyntaxKind): string;
|
||||
function computeLineStarts(text: string): number[];
|
||||
function getPositionFromLineAndCharacter(sourceFile: SourceFile, line: number, character: number): number;
|
||||
function computePositionFromLineAndCharacter(lineStarts: number[], line: number, character: number): number;
|
||||
function getPositionOfLineAndCharacter(sourceFile: SourceFile, line: number, character: number): number;
|
||||
function computePositionOfLineAndCharacter(lineStarts: number[], line: number, character: number): number;
|
||||
function getLineStarts(sourceFile: SourceFile): number[];
|
||||
function computeLineAndCharacterOfPosition(lineStarts: number[], position: number): {
|
||||
line: number;
|
||||
@@ -1432,9 +1483,9 @@ declare module "typescript" {
|
||||
scriptSnapshot: IScriptSnapshot;
|
||||
nameTable: Map<string>;
|
||||
getNamedDeclarations(): Declaration[];
|
||||
getLineAndCharacterFromPosition(pos: number): LineAndCharacter;
|
||||
getLineAndCharacterOfPosition(pos: number): LineAndCharacter;
|
||||
getLineStarts(): number[];
|
||||
getPositionFromLineAndCharacter(line: number, character: number): number;
|
||||
getPositionOfLineAndCharacter(line: number, character: number): number;
|
||||
update(newText: string, textChangeRange: TextChangeRange): SourceFile;
|
||||
}
|
||||
/**
|
||||
@@ -1496,7 +1547,7 @@ declare module "typescript" {
|
||||
getDefinitionAtPosition(fileName: string, position: number): DefinitionInfo[];
|
||||
getReferencesAtPosition(fileName: string, position: number): ReferenceEntry[];
|
||||
getOccurrencesAtPosition(fileName: string, position: number): ReferenceEntry[];
|
||||
getNavigateToItems(searchValue: string): NavigateToItem[];
|
||||
getNavigateToItems(searchValue: string, maxResultCount?: number): NavigateToItem[];
|
||||
getNavigationBarItems(fileName: string): NavigationBarItem[];
|
||||
getOutliningSpans(fileName: string): OutliningSpan[];
|
||||
getTodoComments(fileName: string, descriptors: TodoCommentDescriptor[]): TodoComment[];
|
||||
@@ -1551,6 +1602,7 @@ declare module "typescript" {
|
||||
kind: string;
|
||||
kindModifiers: string;
|
||||
matchKind: string;
|
||||
isCaseSensitive: boolean;
|
||||
fileName: string;
|
||||
textSpan: TextSpan;
|
||||
containerName: string;
|
||||
@@ -1571,6 +1623,7 @@ declare module "typescript" {
|
||||
InsertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis: boolean;
|
||||
PlaceOpenBraceOnNewLineForFunctions: boolean;
|
||||
PlaceOpenBraceOnNewLineForControlBlocks: boolean;
|
||||
[s: string]: boolean | number | string;
|
||||
}
|
||||
interface DefinitionInfo {
|
||||
fileName: string;
|
||||
@@ -1704,6 +1757,9 @@ declare module "typescript" {
|
||||
InMultiLineCommentTrivia = 1,
|
||||
InSingleQuoteStringLiteral = 2,
|
||||
InDoubleQuoteStringLiteral = 3,
|
||||
InTemplateHeadOrNoSubstitutionTemplate = 4,
|
||||
InTemplateMiddleOrTail = 5,
|
||||
InTemplateSubstitutionPosition = 6,
|
||||
}
|
||||
enum TokenClass {
|
||||
Punctuation = 0,
|
||||
@@ -1725,7 +1781,26 @@ declare module "typescript" {
|
||||
classification: TokenClass;
|
||||
}
|
||||
interface Classifier {
|
||||
getClassificationsForLine(text: string, lexState: EndOfLineState, classifyKeywordsInGenerics?: boolean): ClassificationResult;
|
||||
/**
|
||||
* Gives lexical classifications of tokens on a line without any syntactic context.
|
||||
* For instance, a token consisting of the text 'string' can be either an identifier
|
||||
* named 'string' or the keyword 'string', however, because this classifier is not aware,
|
||||
* it relies on certain heuristics to give acceptable results. For classifications where
|
||||
* speed trumps accuracy, this function is preferable; however, for true accuracy, the
|
||||
* syntactic classifier is ideal. In fact, in certain editing scenarios, combining the
|
||||
* lexical, syntactic, and semantic classifiers may issue the best user experience.
|
||||
*
|
||||
* @param text The text of a line to classify.
|
||||
* @param lexState The state of the lexical classifier at the end of the previous line.
|
||||
* @param syntacticClassifierAbsent Whether the client is *not* using a syntactic classifier.
|
||||
* If there is no syntactic classifier (syntacticClassifierAbsent=true),
|
||||
* certain heuristics may be used in its place; however, if there is a
|
||||
* syntactic classifier (syntacticClassifierAbsent=false), certain
|
||||
* classifications which may be incorrectly categorized will be given
|
||||
* back as Identifiers in order to allow the syntactic classifier to
|
||||
* subsume the classification.
|
||||
*/
|
||||
getClassificationsForLine(text: string, lexState: EndOfLineState, syntacticClassifierAbsent: boolean): ClassificationResult;
|
||||
}
|
||||
/**
|
||||
* The document registry represents a store of SourceFile objects that can be shared between
|
||||
|
||||
+30834
File diff suppressed because one or more lines are too long
Vendored
+211
-136
@@ -123,129 +123,142 @@ declare module ts {
|
||||
VoidKeyword = 98,
|
||||
WhileKeyword = 99,
|
||||
WithKeyword = 100,
|
||||
ImplementsKeyword = 101,
|
||||
InterfaceKeyword = 102,
|
||||
LetKeyword = 103,
|
||||
PackageKeyword = 104,
|
||||
PrivateKeyword = 105,
|
||||
ProtectedKeyword = 106,
|
||||
PublicKeyword = 107,
|
||||
StaticKeyword = 108,
|
||||
YieldKeyword = 109,
|
||||
AnyKeyword = 110,
|
||||
BooleanKeyword = 111,
|
||||
ConstructorKeyword = 112,
|
||||
DeclareKeyword = 113,
|
||||
GetKeyword = 114,
|
||||
ModuleKeyword = 115,
|
||||
RequireKeyword = 116,
|
||||
NumberKeyword = 117,
|
||||
SetKeyword = 118,
|
||||
StringKeyword = 119,
|
||||
TypeKeyword = 120,
|
||||
QualifiedName = 121,
|
||||
ComputedPropertyName = 122,
|
||||
TypeParameter = 123,
|
||||
Parameter = 124,
|
||||
PropertySignature = 125,
|
||||
PropertyDeclaration = 126,
|
||||
MethodSignature = 127,
|
||||
MethodDeclaration = 128,
|
||||
Constructor = 129,
|
||||
GetAccessor = 130,
|
||||
SetAccessor = 131,
|
||||
CallSignature = 132,
|
||||
ConstructSignature = 133,
|
||||
IndexSignature = 134,
|
||||
TypeReference = 135,
|
||||
FunctionType = 136,
|
||||
ConstructorType = 137,
|
||||
TypeQuery = 138,
|
||||
TypeLiteral = 139,
|
||||
ArrayType = 140,
|
||||
TupleType = 141,
|
||||
UnionType = 142,
|
||||
ParenthesizedType = 143,
|
||||
ObjectBindingPattern = 144,
|
||||
ArrayBindingPattern = 145,
|
||||
BindingElement = 146,
|
||||
ArrayLiteralExpression = 147,
|
||||
ObjectLiteralExpression = 148,
|
||||
PropertyAccessExpression = 149,
|
||||
ElementAccessExpression = 150,
|
||||
CallExpression = 151,
|
||||
NewExpression = 152,
|
||||
TaggedTemplateExpression = 153,
|
||||
TypeAssertionExpression = 154,
|
||||
ParenthesizedExpression = 155,
|
||||
FunctionExpression = 156,
|
||||
ArrowFunction = 157,
|
||||
DeleteExpression = 158,
|
||||
TypeOfExpression = 159,
|
||||
VoidExpression = 160,
|
||||
PrefixUnaryExpression = 161,
|
||||
PostfixUnaryExpression = 162,
|
||||
BinaryExpression = 163,
|
||||
ConditionalExpression = 164,
|
||||
TemplateExpression = 165,
|
||||
YieldExpression = 166,
|
||||
SpreadElementExpression = 167,
|
||||
OmittedExpression = 168,
|
||||
TemplateSpan = 169,
|
||||
Block = 170,
|
||||
VariableStatement = 171,
|
||||
EmptyStatement = 172,
|
||||
ExpressionStatement = 173,
|
||||
IfStatement = 174,
|
||||
DoStatement = 175,
|
||||
WhileStatement = 176,
|
||||
ForStatement = 177,
|
||||
ForInStatement = 178,
|
||||
ContinueStatement = 179,
|
||||
BreakStatement = 180,
|
||||
ReturnStatement = 181,
|
||||
WithStatement = 182,
|
||||
SwitchStatement = 183,
|
||||
LabeledStatement = 184,
|
||||
ThrowStatement = 185,
|
||||
TryStatement = 186,
|
||||
DebuggerStatement = 187,
|
||||
VariableDeclaration = 188,
|
||||
VariableDeclarationList = 189,
|
||||
FunctionDeclaration = 190,
|
||||
ClassDeclaration = 191,
|
||||
InterfaceDeclaration = 192,
|
||||
TypeAliasDeclaration = 193,
|
||||
EnumDeclaration = 194,
|
||||
ModuleDeclaration = 195,
|
||||
ModuleBlock = 196,
|
||||
ImportDeclaration = 197,
|
||||
ExportAssignment = 198,
|
||||
ExternalModuleReference = 199,
|
||||
CaseClause = 200,
|
||||
DefaultClause = 201,
|
||||
HeritageClause = 202,
|
||||
CatchClause = 203,
|
||||
PropertyAssignment = 204,
|
||||
ShorthandPropertyAssignment = 205,
|
||||
EnumMember = 206,
|
||||
SourceFile = 207,
|
||||
SyntaxList = 208,
|
||||
Count = 209,
|
||||
AsKeyword = 101,
|
||||
FromKeyword = 102,
|
||||
ImplementsKeyword = 103,
|
||||
InterfaceKeyword = 104,
|
||||
LetKeyword = 105,
|
||||
PackageKeyword = 106,
|
||||
PrivateKeyword = 107,
|
||||
ProtectedKeyword = 108,
|
||||
PublicKeyword = 109,
|
||||
StaticKeyword = 110,
|
||||
YieldKeyword = 111,
|
||||
AnyKeyword = 112,
|
||||
BooleanKeyword = 113,
|
||||
ConstructorKeyword = 114,
|
||||
DeclareKeyword = 115,
|
||||
GetKeyword = 116,
|
||||
ModuleKeyword = 117,
|
||||
RequireKeyword = 118,
|
||||
NumberKeyword = 119,
|
||||
SetKeyword = 120,
|
||||
StringKeyword = 121,
|
||||
SymbolKeyword = 122,
|
||||
TypeKeyword = 123,
|
||||
OfKeyword = 124,
|
||||
QualifiedName = 125,
|
||||
ComputedPropertyName = 126,
|
||||
TypeParameter = 127,
|
||||
Parameter = 128,
|
||||
PropertySignature = 129,
|
||||
PropertyDeclaration = 130,
|
||||
MethodSignature = 131,
|
||||
MethodDeclaration = 132,
|
||||
Constructor = 133,
|
||||
GetAccessor = 134,
|
||||
SetAccessor = 135,
|
||||
CallSignature = 136,
|
||||
ConstructSignature = 137,
|
||||
IndexSignature = 138,
|
||||
TypeReference = 139,
|
||||
FunctionType = 140,
|
||||
ConstructorType = 141,
|
||||
TypeQuery = 142,
|
||||
TypeLiteral = 143,
|
||||
ArrayType = 144,
|
||||
TupleType = 145,
|
||||
UnionType = 146,
|
||||
ParenthesizedType = 147,
|
||||
ObjectBindingPattern = 148,
|
||||
ArrayBindingPattern = 149,
|
||||
BindingElement = 150,
|
||||
ArrayLiteralExpression = 151,
|
||||
ObjectLiteralExpression = 152,
|
||||
PropertyAccessExpression = 153,
|
||||
ElementAccessExpression = 154,
|
||||
CallExpression = 155,
|
||||
NewExpression = 156,
|
||||
TaggedTemplateExpression = 157,
|
||||
TypeAssertionExpression = 158,
|
||||
ParenthesizedExpression = 159,
|
||||
FunctionExpression = 160,
|
||||
ArrowFunction = 161,
|
||||
DeleteExpression = 162,
|
||||
TypeOfExpression = 163,
|
||||
VoidExpression = 164,
|
||||
PrefixUnaryExpression = 165,
|
||||
PostfixUnaryExpression = 166,
|
||||
BinaryExpression = 167,
|
||||
ConditionalExpression = 168,
|
||||
TemplateExpression = 169,
|
||||
YieldExpression = 170,
|
||||
SpreadElementExpression = 171,
|
||||
OmittedExpression = 172,
|
||||
TemplateSpan = 173,
|
||||
Block = 174,
|
||||
VariableStatement = 175,
|
||||
EmptyStatement = 176,
|
||||
ExpressionStatement = 177,
|
||||
IfStatement = 178,
|
||||
DoStatement = 179,
|
||||
WhileStatement = 180,
|
||||
ForStatement = 181,
|
||||
ForInStatement = 182,
|
||||
ForOfStatement = 183,
|
||||
ContinueStatement = 184,
|
||||
BreakStatement = 185,
|
||||
ReturnStatement = 186,
|
||||
WithStatement = 187,
|
||||
SwitchStatement = 188,
|
||||
LabeledStatement = 189,
|
||||
ThrowStatement = 190,
|
||||
TryStatement = 191,
|
||||
DebuggerStatement = 192,
|
||||
VariableDeclaration = 193,
|
||||
VariableDeclarationList = 194,
|
||||
FunctionDeclaration = 195,
|
||||
ClassDeclaration = 196,
|
||||
InterfaceDeclaration = 197,
|
||||
TypeAliasDeclaration = 198,
|
||||
EnumDeclaration = 199,
|
||||
ModuleDeclaration = 200,
|
||||
ModuleBlock = 201,
|
||||
ImportEqualsDeclaration = 202,
|
||||
ImportDeclaration = 203,
|
||||
ImportClause = 204,
|
||||
NamespaceImport = 205,
|
||||
NamedImports = 206,
|
||||
ImportSpecifier = 207,
|
||||
ExportAssignment = 208,
|
||||
ExportDeclaration = 209,
|
||||
NamedExports = 210,
|
||||
ExportSpecifier = 211,
|
||||
ExternalModuleReference = 212,
|
||||
CaseClause = 213,
|
||||
DefaultClause = 214,
|
||||
HeritageClause = 215,
|
||||
CatchClause = 216,
|
||||
PropertyAssignment = 217,
|
||||
ShorthandPropertyAssignment = 218,
|
||||
EnumMember = 219,
|
||||
SourceFile = 220,
|
||||
SyntaxList = 221,
|
||||
Count = 222,
|
||||
FirstAssignment = 52,
|
||||
LastAssignment = 63,
|
||||
FirstReservedWord = 65,
|
||||
LastReservedWord = 100,
|
||||
FirstKeyword = 65,
|
||||
LastKeyword = 120,
|
||||
FirstFutureReservedWord = 101,
|
||||
LastFutureReservedWord = 109,
|
||||
FirstTypeNode = 135,
|
||||
LastTypeNode = 143,
|
||||
LastKeyword = 124,
|
||||
FirstFutureReservedWord = 103,
|
||||
LastFutureReservedWord = 111,
|
||||
FirstTypeNode = 139,
|
||||
LastTypeNode = 147,
|
||||
FirstPunctuation = 14,
|
||||
LastPunctuation = 63,
|
||||
FirstToken = 0,
|
||||
LastToken = 120,
|
||||
LastToken = 124,
|
||||
FirstTriviaToken = 2,
|
||||
LastTriviaToken = 6,
|
||||
FirstLiteralToken = 7,
|
||||
@@ -254,7 +267,7 @@ declare module ts {
|
||||
LastTemplateToken = 13,
|
||||
FirstBinaryOperator = 24,
|
||||
LastBinaryOperator = 63,
|
||||
FirstNode = 121,
|
||||
FirstNode = 125,
|
||||
}
|
||||
const enum NodeFlags {
|
||||
Export = 1,
|
||||
@@ -292,13 +305,13 @@ declare module ts {
|
||||
kind: SyntaxKind;
|
||||
flags: NodeFlags;
|
||||
parserContextFlags?: ParserContextFlags;
|
||||
modifiers?: ModifiersArray;
|
||||
id?: number;
|
||||
parent?: Node;
|
||||
symbol?: Symbol;
|
||||
locals?: SymbolTable;
|
||||
nextContainer?: Node;
|
||||
localSymbol?: Symbol;
|
||||
modifiers?: ModifiersArray;
|
||||
}
|
||||
interface NodeArray<T> extends Array<T>, TextRange {
|
||||
hasTrailingComma?: boolean;
|
||||
@@ -487,7 +500,7 @@ declare module ts {
|
||||
}
|
||||
interface BinaryExpression extends Expression {
|
||||
left: Expression;
|
||||
operator: SyntaxKind;
|
||||
operatorToken: Node;
|
||||
right: Expression;
|
||||
}
|
||||
interface ConditionalExpression extends Expression {
|
||||
@@ -585,6 +598,10 @@ declare module ts {
|
||||
initializer: VariableDeclarationList | Expression;
|
||||
expression: Expression;
|
||||
}
|
||||
interface ForOfStatement extends IterationStatement {
|
||||
initializer: VariableDeclarationList | Expression;
|
||||
expression: Expression;
|
||||
}
|
||||
interface BreakOrContinueStatement extends Statement {
|
||||
label?: Identifier;
|
||||
}
|
||||
@@ -658,20 +675,49 @@ declare module ts {
|
||||
name: Identifier;
|
||||
members: NodeArray<EnumMember>;
|
||||
}
|
||||
interface ModuleDeclaration extends Declaration, ModuleElement {
|
||||
interface ExportContainer {
|
||||
exportStars?: ExportDeclaration[];
|
||||
}
|
||||
interface ModuleDeclaration extends Declaration, ModuleElement, ExportContainer {
|
||||
name: Identifier | LiteralExpression;
|
||||
body: ModuleBlock | ModuleDeclaration;
|
||||
}
|
||||
interface ModuleBlock extends Node, ModuleElement {
|
||||
statements: NodeArray<ModuleElement>;
|
||||
}
|
||||
interface ImportDeclaration extends Declaration, ModuleElement {
|
||||
interface ImportEqualsDeclaration extends Declaration, ModuleElement {
|
||||
name: Identifier;
|
||||
moduleReference: EntityName | ExternalModuleReference;
|
||||
}
|
||||
interface ExternalModuleReference extends Node {
|
||||
expression?: Expression;
|
||||
}
|
||||
interface ImportDeclaration extends Statement, ModuleElement {
|
||||
importClause?: ImportClause;
|
||||
moduleSpecifier: Expression;
|
||||
}
|
||||
interface ImportClause extends Declaration {
|
||||
name?: Identifier;
|
||||
namedBindings?: NamespaceImport | NamedImports;
|
||||
}
|
||||
interface NamespaceImport extends Declaration {
|
||||
name: Identifier;
|
||||
}
|
||||
interface ExportDeclaration extends Statement, ModuleElement {
|
||||
exportClause?: NamedExports;
|
||||
moduleSpecifier?: Expression;
|
||||
}
|
||||
interface NamedImportsOrExports extends Node {
|
||||
elements: NodeArray<ImportOrExportSpecifier>;
|
||||
}
|
||||
type NamedImports = NamedImportsOrExports;
|
||||
type NamedExports = NamedImportsOrExports;
|
||||
interface ImportOrExportSpecifier extends Declaration {
|
||||
propertyName?: Identifier;
|
||||
name: Identifier;
|
||||
}
|
||||
type ImportSpecifier = ImportOrExportSpecifier;
|
||||
type ExportSpecifier = ImportOrExportSpecifier;
|
||||
interface ExportAssignment extends Statement, ModuleElement {
|
||||
exportName: Identifier;
|
||||
}
|
||||
@@ -681,7 +727,7 @@ declare module ts {
|
||||
interface CommentRange extends TextRange {
|
||||
hasTrailingNewLine?: boolean;
|
||||
}
|
||||
interface SourceFile extends Declaration {
|
||||
interface SourceFile extends Declaration, ExportContainer {
|
||||
statements: NodeArray<ModuleElement>;
|
||||
endOfFileToken: Node;
|
||||
fileName: string;
|
||||
@@ -835,7 +881,7 @@ declare module ts {
|
||||
}
|
||||
interface SymbolVisibilityResult {
|
||||
accessibility: SymbolAccessibility;
|
||||
aliasesToMakeVisible?: ImportDeclaration[];
|
||||
aliasesToMakeVisible?: ImportEqualsDeclaration[];
|
||||
errorSymbolName?: string;
|
||||
errorNode?: Node;
|
||||
}
|
||||
@@ -843,11 +889,11 @@ declare module ts {
|
||||
errorModuleName?: string;
|
||||
}
|
||||
interface EmitResolver {
|
||||
getLocalNameOfContainer(container: ModuleDeclaration | EnumDeclaration): string;
|
||||
getExpressionNamePrefix(node: Identifier): string;
|
||||
getGeneratedNameForNode(node: ModuleDeclaration | EnumDeclaration | ImportDeclaration | ExportDeclaration): string;
|
||||
getExpressionNameSubstitution(node: Identifier): string;
|
||||
getExportAssignmentName(node: SourceFile): string;
|
||||
isReferencedImportDeclaration(node: ImportDeclaration): boolean;
|
||||
isTopLevelValueImportWithEntityName(node: ImportDeclaration): boolean;
|
||||
isReferencedImportDeclaration(node: Node): boolean;
|
||||
isTopLevelValueImportEqualsWithEntityName(node: ImportEqualsDeclaration): boolean;
|
||||
getNodeCheckFlags(node: Node): NodeCheckFlags;
|
||||
isDeclarationVisible(node: Declaration): boolean;
|
||||
isImplementationOfOverload(node: FunctionLikeDeclaration): boolean;
|
||||
@@ -942,8 +988,10 @@ declare module ts {
|
||||
declaredType?: Type;
|
||||
mapper?: TypeMapper;
|
||||
referenced?: boolean;
|
||||
exportAssignSymbol?: Symbol;
|
||||
exportAssignmentChecked?: boolean;
|
||||
exportAssignmentSymbol?: Symbol;
|
||||
unionType?: UnionType;
|
||||
resolvedExports?: SymbolTable;
|
||||
}
|
||||
interface TransientSymbol extends Symbol, SymbolLinks {
|
||||
}
|
||||
@@ -968,7 +1016,8 @@ declare module ts {
|
||||
enumMemberValue?: number;
|
||||
isIllegalTypeReferenceInConstraint?: boolean;
|
||||
isVisible?: boolean;
|
||||
localModuleName?: string;
|
||||
generatedName?: string;
|
||||
generatedNames?: Map<string>;
|
||||
assignmentChecks?: Map<boolean>;
|
||||
hasReportedStatementInAmbientContext?: boolean;
|
||||
importOnRightSide?: Symbol;
|
||||
@@ -994,8 +1043,9 @@ declare module ts {
|
||||
ObjectLiteral = 131072,
|
||||
ContainsUndefinedOrNull = 262144,
|
||||
ContainsObjectLiteral = 524288,
|
||||
Intrinsic = 127,
|
||||
Primitive = 510,
|
||||
ESSymbol = 1048576,
|
||||
Intrinsic = 1048703,
|
||||
Primitive = 1049086,
|
||||
StringLike = 258,
|
||||
NumberLike = 132,
|
||||
ObjectType = 48128,
|
||||
@@ -1281,6 +1331,7 @@ declare module ts {
|
||||
equals = 61,
|
||||
exclamation = 33,
|
||||
greaterThan = 62,
|
||||
hash = 35,
|
||||
lessThan = 60,
|
||||
minus = 45,
|
||||
openBrace = 123,
|
||||
@@ -1347,8 +1398,8 @@ declare module ts {
|
||||
}
|
||||
function tokenToString(t: SyntaxKind): string;
|
||||
function computeLineStarts(text: string): number[];
|
||||
function getPositionFromLineAndCharacter(sourceFile: SourceFile, line: number, character: number): number;
|
||||
function computePositionFromLineAndCharacter(lineStarts: number[], line: number, character: number): number;
|
||||
function getPositionOfLineAndCharacter(sourceFile: SourceFile, line: number, character: number): number;
|
||||
function computePositionOfLineAndCharacter(lineStarts: number[], line: number, character: number): number;
|
||||
function getLineStarts(sourceFile: SourceFile): number[];
|
||||
function computeLineAndCharacterOfPosition(lineStarts: number[], position: number): {
|
||||
line: number;
|
||||
@@ -1432,9 +1483,9 @@ declare module ts {
|
||||
scriptSnapshot: IScriptSnapshot;
|
||||
nameTable: Map<string>;
|
||||
getNamedDeclarations(): Declaration[];
|
||||
getLineAndCharacterFromPosition(pos: number): LineAndCharacter;
|
||||
getLineAndCharacterOfPosition(pos: number): LineAndCharacter;
|
||||
getLineStarts(): number[];
|
||||
getPositionFromLineAndCharacter(line: number, character: number): number;
|
||||
getPositionOfLineAndCharacter(line: number, character: number): number;
|
||||
update(newText: string, textChangeRange: TextChangeRange): SourceFile;
|
||||
}
|
||||
/**
|
||||
@@ -1496,7 +1547,7 @@ declare module ts {
|
||||
getDefinitionAtPosition(fileName: string, position: number): DefinitionInfo[];
|
||||
getReferencesAtPosition(fileName: string, position: number): ReferenceEntry[];
|
||||
getOccurrencesAtPosition(fileName: string, position: number): ReferenceEntry[];
|
||||
getNavigateToItems(searchValue: string): NavigateToItem[];
|
||||
getNavigateToItems(searchValue: string, maxResultCount?: number): NavigateToItem[];
|
||||
getNavigationBarItems(fileName: string): NavigationBarItem[];
|
||||
getOutliningSpans(fileName: string): OutliningSpan[];
|
||||
getTodoComments(fileName: string, descriptors: TodoCommentDescriptor[]): TodoComment[];
|
||||
@@ -1551,6 +1602,7 @@ declare module ts {
|
||||
kind: string;
|
||||
kindModifiers: string;
|
||||
matchKind: string;
|
||||
isCaseSensitive: boolean;
|
||||
fileName: string;
|
||||
textSpan: TextSpan;
|
||||
containerName: string;
|
||||
@@ -1571,6 +1623,7 @@ declare module ts {
|
||||
InsertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis: boolean;
|
||||
PlaceOpenBraceOnNewLineForFunctions: boolean;
|
||||
PlaceOpenBraceOnNewLineForControlBlocks: boolean;
|
||||
[s: string]: boolean | number | string;
|
||||
}
|
||||
interface DefinitionInfo {
|
||||
fileName: string;
|
||||
@@ -1704,6 +1757,9 @@ declare module ts {
|
||||
InMultiLineCommentTrivia = 1,
|
||||
InSingleQuoteStringLiteral = 2,
|
||||
InDoubleQuoteStringLiteral = 3,
|
||||
InTemplateHeadOrNoSubstitutionTemplate = 4,
|
||||
InTemplateMiddleOrTail = 5,
|
||||
InTemplateSubstitutionPosition = 6,
|
||||
}
|
||||
enum TokenClass {
|
||||
Punctuation = 0,
|
||||
@@ -1725,7 +1781,26 @@ declare module ts {
|
||||
classification: TokenClass;
|
||||
}
|
||||
interface Classifier {
|
||||
getClassificationsForLine(text: string, lexState: EndOfLineState, classifyKeywordsInGenerics?: boolean): ClassificationResult;
|
||||
/**
|
||||
* Gives lexical classifications of tokens on a line without any syntactic context.
|
||||
* For instance, a token consisting of the text 'string' can be either an identifier
|
||||
* named 'string' or the keyword 'string', however, because this classifier is not aware,
|
||||
* it relies on certain heuristics to give acceptable results. For classifications where
|
||||
* speed trumps accuracy, this function is preferable; however, for true accuracy, the
|
||||
* syntactic classifier is ideal. In fact, in certain editing scenarios, combining the
|
||||
* lexical, syntactic, and semantic classifiers may issue the best user experience.
|
||||
*
|
||||
* @param text The text of a line to classify.
|
||||
* @param lexState The state of the lexical classifier at the end of the previous line.
|
||||
* @param syntacticClassifierAbsent Whether the client is *not* using a syntactic classifier.
|
||||
* If there is no syntactic classifier (syntacticClassifierAbsent=true),
|
||||
* certain heuristics may be used in its place; however, if there is a
|
||||
* syntactic classifier (syntacticClassifierAbsent=false), certain
|
||||
* classifications which may be incorrectly categorized will be given
|
||||
* back as Identifiers in order to allow the syntactic classifier to
|
||||
* subsume the classification.
|
||||
*/
|
||||
getClassificationsForLine(text: string, lexState: EndOfLineState, syntacticClassifierAbsent: boolean): ClassificationResult;
|
||||
}
|
||||
/**
|
||||
* The document registry represents a store of SourceFile objects that can be shared between
|
||||
|
||||
+5271
-3221
File diff suppressed because it is too large
Load Diff
Vendored
+27
-5
@@ -159,6 +159,7 @@ declare module ts {
|
||||
function getFullWidth(node: Node): number;
|
||||
function containsParseError(node: Node): boolean;
|
||||
function getSourceFileOfNode(node: Node): SourceFile;
|
||||
function getStartPositionOfLine(line: number, sourceFile: SourceFile): number;
|
||||
function nodePosToString(node: Node): string;
|
||||
function getStartPosOfNode(node: Node): number;
|
||||
function nodeIsMissing(node: Node): boolean;
|
||||
@@ -169,6 +170,7 @@ declare module ts {
|
||||
function getTextOfNode(node: Node): string;
|
||||
function escapeIdentifier(identifier: string): string;
|
||||
function unescapeIdentifier(identifier: string): string;
|
||||
function makeIdentifierFromModuleName(moduleName: string): string;
|
||||
function declarationNameToString(name: DeclarationName): string;
|
||||
function createDiagnosticForNode(node: Node, message: DiagnosticMessage, arg0?: any, arg1?: any, arg2?: any): Diagnostic;
|
||||
function createDiagnosticForNodeFromMessageChain(node: Node, messageChain: DiagnosticMessageChain): Diagnostic;
|
||||
@@ -193,9 +195,10 @@ declare module ts {
|
||||
function getInvokedExpression(node: CallLikeExpression): Expression;
|
||||
function isExpression(node: Node): boolean;
|
||||
function isInstantiatedModule(node: ModuleDeclaration, preserveConstEnums: boolean): boolean;
|
||||
function isExternalModuleImportDeclaration(node: Node): boolean;
|
||||
function getExternalModuleImportDeclarationExpression(node: Node): Expression;
|
||||
function isInternalModuleImportDeclaration(node: Node): boolean;
|
||||
function isExternalModuleImportEqualsDeclaration(node: Node): boolean;
|
||||
function getExternalModuleImportEqualsDeclarationExpression(node: Node): Expression;
|
||||
function isInternalModuleImportEqualsDeclaration(node: Node): boolean;
|
||||
function getExternalModuleName(node: Node): Expression;
|
||||
function hasDotDotDotToken(node: Node): boolean;
|
||||
function hasQuestionToken(node: Node): boolean;
|
||||
function hasRestParameters(s: SignatureDeclaration): boolean;
|
||||
@@ -216,6 +219,26 @@ declare module ts {
|
||||
function getFileReferenceFromReferencePath(comment: string, commentRange: CommentRange): ReferencePathMatchResult;
|
||||
function isKeyword(token: SyntaxKind): boolean;
|
||||
function isTrivia(token: SyntaxKind): boolean;
|
||||
/**
|
||||
* A declaration has a dynamic name if both of the following are true:
|
||||
* 1. The declaration has a computed property name
|
||||
* 2. The computed name is *not* expressed as Symbol.<name>, where name
|
||||
* is a property of the Symbol constructor that denotes a built in
|
||||
* Symbol.
|
||||
*/
|
||||
function hasDynamicName(declaration: Declaration): boolean;
|
||||
/**
|
||||
* Checks if the expression is of the form:
|
||||
* Symbol.name
|
||||
* where Symbol is literally the word "Symbol", and name is any identifierName
|
||||
*/
|
||||
function isWellKnownSymbolSyntactically(node: Expression): boolean;
|
||||
function getPropertyNameForPropertyNameNode(name: DeclarationName): string;
|
||||
function getPropertyNameForKnownSymbolName(symbolName: string): string;
|
||||
/**
|
||||
* Includes the word "Symbol" with unicode escapes
|
||||
*/
|
||||
function isESSymbolIdentifier(node: Node): boolean;
|
||||
function isModifier(token: SyntaxKind): boolean;
|
||||
function textSpanEnd(span: TextSpan): number;
|
||||
function textSpanIsEmpty(span: TextSpan): boolean;
|
||||
@@ -255,8 +278,7 @@ declare module ts {
|
||||
list: Node;
|
||||
}
|
||||
function getEndLinePosition(line: number, sourceFile: SourceFile): number;
|
||||
function getStartPositionOfLine(line: number, sourceFile: SourceFile): number;
|
||||
function getStartLinePositionForPosition(position: number, sourceFile: SourceFile): number;
|
||||
function getLineStartPositionForPosition(position: number, sourceFile: SourceFile): number;
|
||||
function rangeContainsRange(r1: TextRange, r2: TextRange): boolean;
|
||||
function startEndContainsRange(start: number, end: number, range: TextRange): boolean;
|
||||
function rangeContainsStartEnd(range: TextRange, start: number, end: number): boolean;
|
||||
|
||||
Vendored
+27
-5
@@ -159,6 +159,7 @@ declare module "typescript" {
|
||||
function getFullWidth(node: Node): number;
|
||||
function containsParseError(node: Node): boolean;
|
||||
function getSourceFileOfNode(node: Node): SourceFile;
|
||||
function getStartPositionOfLine(line: number, sourceFile: SourceFile): number;
|
||||
function nodePosToString(node: Node): string;
|
||||
function getStartPosOfNode(node: Node): number;
|
||||
function nodeIsMissing(node: Node): boolean;
|
||||
@@ -169,6 +170,7 @@ declare module "typescript" {
|
||||
function getTextOfNode(node: Node): string;
|
||||
function escapeIdentifier(identifier: string): string;
|
||||
function unescapeIdentifier(identifier: string): string;
|
||||
function makeIdentifierFromModuleName(moduleName: string): string;
|
||||
function declarationNameToString(name: DeclarationName): string;
|
||||
function createDiagnosticForNode(node: Node, message: DiagnosticMessage, arg0?: any, arg1?: any, arg2?: any): Diagnostic;
|
||||
function createDiagnosticForNodeFromMessageChain(node: Node, messageChain: DiagnosticMessageChain): Diagnostic;
|
||||
@@ -193,9 +195,10 @@ declare module "typescript" {
|
||||
function getInvokedExpression(node: CallLikeExpression): Expression;
|
||||
function isExpression(node: Node): boolean;
|
||||
function isInstantiatedModule(node: ModuleDeclaration, preserveConstEnums: boolean): boolean;
|
||||
function isExternalModuleImportDeclaration(node: Node): boolean;
|
||||
function getExternalModuleImportDeclarationExpression(node: Node): Expression;
|
||||
function isInternalModuleImportDeclaration(node: Node): boolean;
|
||||
function isExternalModuleImportEqualsDeclaration(node: Node): boolean;
|
||||
function getExternalModuleImportEqualsDeclarationExpression(node: Node): Expression;
|
||||
function isInternalModuleImportEqualsDeclaration(node: Node): boolean;
|
||||
function getExternalModuleName(node: Node): Expression;
|
||||
function hasDotDotDotToken(node: Node): boolean;
|
||||
function hasQuestionToken(node: Node): boolean;
|
||||
function hasRestParameters(s: SignatureDeclaration): boolean;
|
||||
@@ -216,6 +219,26 @@ declare module "typescript" {
|
||||
function getFileReferenceFromReferencePath(comment: string, commentRange: CommentRange): ReferencePathMatchResult;
|
||||
function isKeyword(token: SyntaxKind): boolean;
|
||||
function isTrivia(token: SyntaxKind): boolean;
|
||||
/**
|
||||
* A declaration has a dynamic name if both of the following are true:
|
||||
* 1. The declaration has a computed property name
|
||||
* 2. The computed name is *not* expressed as Symbol.<name>, where name
|
||||
* is a property of the Symbol constructor that denotes a built in
|
||||
* Symbol.
|
||||
*/
|
||||
function hasDynamicName(declaration: Declaration): boolean;
|
||||
/**
|
||||
* Checks if the expression is of the form:
|
||||
* Symbol.name
|
||||
* where Symbol is literally the word "Symbol", and name is any identifierName
|
||||
*/
|
||||
function isWellKnownSymbolSyntactically(node: Expression): boolean;
|
||||
function getPropertyNameForPropertyNameNode(name: DeclarationName): string;
|
||||
function getPropertyNameForKnownSymbolName(symbolName: string): string;
|
||||
/**
|
||||
* Includes the word "Symbol" with unicode escapes
|
||||
*/
|
||||
function isESSymbolIdentifier(node: Node): boolean;
|
||||
function isModifier(token: SyntaxKind): boolean;
|
||||
function textSpanEnd(span: TextSpan): number;
|
||||
function textSpanIsEmpty(span: TextSpan): boolean;
|
||||
@@ -255,8 +278,7 @@ declare module "typescript" {
|
||||
list: Node;
|
||||
}
|
||||
function getEndLinePosition(line: number, sourceFile: SourceFile): number;
|
||||
function getStartPositionOfLine(line: number, sourceFile: SourceFile): number;
|
||||
function getStartLinePositionForPosition(position: number, sourceFile: SourceFile): number;
|
||||
function getLineStartPositionForPosition(position: number, sourceFile: SourceFile): number;
|
||||
function rangeContainsRange(r1: TextRange, r2: TextRange): boolean;
|
||||
function startEndContainsRange(start: number, end: number, range: TextRange): boolean;
|
||||
function rangeContainsStartEnd(range: TextRange, start: number, end: number): boolean;
|
||||
|
||||
+3
-2
@@ -25,9 +25,10 @@
|
||||
"url": "https://github.com/Microsoft/TypeScript.git"
|
||||
},
|
||||
"preferGlobal": true,
|
||||
"main": "./bin/typescriptServices.js",
|
||||
"main": "./bin/typescript.js",
|
||||
"bin": {
|
||||
"tsc": "./bin/tsc"
|
||||
"tsc": "./bin/tsc",
|
||||
"tsserver": "./bin/tsserver"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=0.8.0"
|
||||
|
||||
+58
-44
@@ -15,12 +15,12 @@ module ts {
|
||||
if (node.kind === SyntaxKind.InterfaceDeclaration || node.kind === SyntaxKind.TypeAliasDeclaration) {
|
||||
return ModuleInstanceState.NonInstantiated;
|
||||
}
|
||||
// 2. const enum declarations don't make module instantiated
|
||||
// 2. const enum declarations
|
||||
else if (isConstEnumDeclaration(node)) {
|
||||
return ModuleInstanceState.ConstEnumOnly;
|
||||
}
|
||||
// 3. non - exported import declarations
|
||||
else if (node.kind === SyntaxKind.ImportDeclaration && !(node.flags & NodeFlags.Export)) {
|
||||
// 3. non-exported import declarations
|
||||
else if ((node.kind === SyntaxKind.ImportDeclaration || node.kind === SyntaxKind.ImportEqualsDeclaration) && !(node.flags & NodeFlags.Export)) {
|
||||
return ModuleInstanceState.NonInstantiated;
|
||||
}
|
||||
// 4. other uninstantiated module declarations.
|
||||
@@ -51,17 +51,6 @@ module ts {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A declaration has a dynamic name if both of the following are true:
|
||||
* 1. The declaration has a computed property name
|
||||
* 2. The computed name is *not* expressed as Symbol.<name>, where name
|
||||
* is a property of the Symbol constructor that denotes a built in
|
||||
* Symbol.
|
||||
*/
|
||||
export function hasDynamicName(declaration: Declaration): boolean {
|
||||
return declaration.name && declaration.name.kind === SyntaxKind.ComputedPropertyName;
|
||||
}
|
||||
|
||||
export function bindSourceFile(file: SourceFile): void {
|
||||
var start = new Date().getTime();
|
||||
bindSourceFileWorker(file);
|
||||
@@ -106,13 +95,18 @@ module ts {
|
||||
if (symbolKind & SymbolFlags.Value && !symbol.valueDeclaration) symbol.valueDeclaration = node;
|
||||
}
|
||||
|
||||
// Should not be called on a declaration with a computed property name.
|
||||
// Should not be called on a declaration with a computed property name,
|
||||
// unless it is a well known Symbol.
|
||||
function getDeclarationName(node: Declaration): string {
|
||||
if (node.name) {
|
||||
if (node.kind === SyntaxKind.ModuleDeclaration && node.name.kind === SyntaxKind.StringLiteral) {
|
||||
return '"' + (<LiteralExpression>node.name).text + '"';
|
||||
}
|
||||
Debug.assert(!hasDynamicName(node));
|
||||
if (node.name.kind === SyntaxKind.ComputedPropertyName) {
|
||||
var nameExpression = (<ComputedPropertyName>node.name).expression;
|
||||
Debug.assert(isWellKnownSymbolSyntactically(nameExpression));
|
||||
return getPropertyNameForKnownSymbolName((<PropertyAccessExpression>nameExpression).name.text);
|
||||
}
|
||||
return (<Identifier | LiteralExpression>node.name).text;
|
||||
}
|
||||
switch (node.kind) {
|
||||
@@ -193,41 +187,39 @@ module ts {
|
||||
}
|
||||
|
||||
function declareModuleMember(node: Declaration, symbolKind: SymbolFlags, symbolExcludes: SymbolFlags) {
|
||||
// Exported module members are given 2 symbols: A local symbol that is classified with an ExportValue,
|
||||
// ExportType, or ExportContainer flag, and an associated export symbol with all the correct flags set
|
||||
// on it. There are 2 main reasons:
|
||||
//
|
||||
// 1. We treat locals and exports of the same name as mutually exclusive within a container.
|
||||
// That means the binder will issue a Duplicate Identifier error if you mix locals and exports
|
||||
// with the same name in the same container.
|
||||
// TODO: Make this a more specific error and decouple it from the exclusion logic.
|
||||
// 2. When we checkIdentifier in the checker, we set its resolved symbol to the local symbol,
|
||||
// but return the export symbol (by calling getExportSymbolOfValueSymbolIfExported). That way
|
||||
// when the emitter comes back to it, it knows not to qualify the name if it was found in a containing scope.
|
||||
var exportKind = 0;
|
||||
if (symbolKind & SymbolFlags.Value) {
|
||||
exportKind |= SymbolFlags.ExportValue;
|
||||
var hasExportModifier = getCombinedNodeFlags(node) & NodeFlags.Export;
|
||||
if (symbolKind & SymbolFlags.Import) {
|
||||
if (node.kind === SyntaxKind.ExportSpecifier || (node.kind === SyntaxKind.ImportEqualsDeclaration && hasExportModifier)) {
|
||||
declareSymbol(container.symbol.exports, container.symbol, node, symbolKind, symbolExcludes);
|
||||
}
|
||||
else {
|
||||
declareSymbol(container.locals, undefined, node, symbolKind, symbolExcludes);
|
||||
}
|
||||
}
|
||||
if (symbolKind & SymbolFlags.Type) {
|
||||
exportKind |= SymbolFlags.ExportType;
|
||||
}
|
||||
if (symbolKind & SymbolFlags.Namespace) {
|
||||
exportKind |= SymbolFlags.ExportNamespace;
|
||||
}
|
||||
|
||||
if (getCombinedNodeFlags(node) & NodeFlags.Export || (node.kind !== SyntaxKind.ImportDeclaration && isAmbientContext(container))) {
|
||||
if (exportKind) {
|
||||
else {
|
||||
// Exported module members are given 2 symbols: A local symbol that is classified with an ExportValue,
|
||||
// ExportType, or ExportContainer flag, and an associated export symbol with all the correct flags set
|
||||
// on it. There are 2 main reasons:
|
||||
//
|
||||
// 1. We treat locals and exports of the same name as mutually exclusive within a container.
|
||||
// That means the binder will issue a Duplicate Identifier error if you mix locals and exports
|
||||
// with the same name in the same container.
|
||||
// TODO: Make this a more specific error and decouple it from the exclusion logic.
|
||||
// 2. When we checkIdentifier in the checker, we set its resolved symbol to the local symbol,
|
||||
// but return the export symbol (by calling getExportSymbolOfValueSymbolIfExported). That way
|
||||
// when the emitter comes back to it, it knows not to qualify the name if it was found in a containing scope.
|
||||
if (hasExportModifier || isAmbientContext(container)) {
|
||||
var exportKind = (symbolKind & SymbolFlags.Value ? SymbolFlags.ExportValue : 0) |
|
||||
(symbolKind & SymbolFlags.Type ? SymbolFlags.ExportType : 0) |
|
||||
(symbolKind & SymbolFlags.Namespace ? SymbolFlags.ExportNamespace : 0);
|
||||
var local = declareSymbol(container.locals, undefined, node, exportKind, symbolExcludes);
|
||||
local.exportSymbol = declareSymbol(container.symbol.exports, container.symbol, node, symbolKind, symbolExcludes);
|
||||
node.localSymbol = local;
|
||||
}
|
||||
else {
|
||||
declareSymbol(container.symbol.exports, container.symbol, node, symbolKind, symbolExcludes);
|
||||
declareSymbol(container.locals, undefined, node, symbolKind, symbolExcludes);
|
||||
}
|
||||
}
|
||||
else {
|
||||
declareSymbol(container.locals, undefined, node, symbolKind, symbolExcludes);
|
||||
}
|
||||
}
|
||||
|
||||
// All container nodes are kept on a linked list in declaration order. This list is used by the getLocalNameOfContainer function
|
||||
@@ -329,6 +321,13 @@ module ts {
|
||||
}
|
||||
}
|
||||
|
||||
function bindExportDeclaration(node: ExportDeclaration) {
|
||||
if (!node.exportClause) {
|
||||
((<ExportContainer>container).exportStars || ((<ExportContainer>container).exportStars = [])).push(node);
|
||||
}
|
||||
bindChildren(node, 0, /*isBlockScopeContainer*/ false);
|
||||
}
|
||||
|
||||
function bindFunctionOrConstructorType(node: SignatureDeclaration) {
|
||||
// For a given function symbol "<...>(...) => T" we want to generate a symbol identical
|
||||
// to the one we would get for: { <...>(...): T }
|
||||
@@ -485,9 +484,23 @@ module ts {
|
||||
case SyntaxKind.ModuleDeclaration:
|
||||
bindModuleDeclaration(<ModuleDeclaration>node);
|
||||
break;
|
||||
case SyntaxKind.ImportDeclaration:
|
||||
case SyntaxKind.ImportEqualsDeclaration:
|
||||
case SyntaxKind.NamespaceImport:
|
||||
case SyntaxKind.ImportSpecifier:
|
||||
case SyntaxKind.ExportSpecifier:
|
||||
bindDeclaration(<Declaration>node, SymbolFlags.Import, SymbolFlags.ImportExcludes, /*isBlockScopeContainer*/ false);
|
||||
break;
|
||||
case SyntaxKind.ExportDeclaration:
|
||||
bindExportDeclaration(<ExportDeclaration>node);
|
||||
break;
|
||||
case SyntaxKind.ImportClause:
|
||||
if ((<ImportClause>node).name) {
|
||||
bindDeclaration(<Declaration>node, SymbolFlags.Import, SymbolFlags.ImportExcludes, /*isBlockScopeContainer*/ false);
|
||||
}
|
||||
else {
|
||||
bindChildren(node, 0, /*isBlockScopeContainer*/ false);
|
||||
}
|
||||
break;
|
||||
case SyntaxKind.SourceFile:
|
||||
if (isExternalModule(<SourceFile>node)) {
|
||||
bindAnonymousDeclaration(<SourceFile>node, SymbolFlags.ValueModule, '"' + removeFileExtension((<SourceFile>node).fileName) + '"', /*isBlockScopeContainer*/ true);
|
||||
@@ -507,6 +520,7 @@ module ts {
|
||||
case SyntaxKind.CatchClause:
|
||||
case SyntaxKind.ForStatement:
|
||||
case SyntaxKind.ForInStatement:
|
||||
case SyntaxKind.ForOfStatement:
|
||||
case SyntaxKind.SwitchStatement:
|
||||
bindChildren(node, 0, /*isBlockScopeContainer*/ true);
|
||||
break;
|
||||
|
||||
+788
-277
File diff suppressed because it is too large
Load Diff
@@ -123,12 +123,12 @@ module ts {
|
||||
An_object_member_cannot_be_declared_optional: { code: 1162, category: DiagnosticCategory.Error, key: "An object member cannot be declared optional." },
|
||||
yield_expression_must_be_contained_within_a_generator_declaration: { code: 1163, category: DiagnosticCategory.Error, key: "'yield' expression must be contained_within a generator declaration." },
|
||||
Computed_property_names_are_not_allowed_in_enums: { code: 1164, category: DiagnosticCategory.Error, key: "Computed property names are not allowed in enums." },
|
||||
Computed_property_names_are_not_allowed_in_an_ambient_context: { code: 1165, category: DiagnosticCategory.Error, key: "Computed property names are not allowed in an ambient context." },
|
||||
Computed_property_names_are_not_allowed_in_class_property_declarations: { code: 1166, category: DiagnosticCategory.Error, key: "Computed property names are not allowed in class property declarations." },
|
||||
A_computed_property_name_in_an_ambient_context_must_directly_refer_to_a_built_in_symbol: { code: 1165, category: DiagnosticCategory.Error, key: "A computed property name in an ambient context must directly refer to a built-in symbol." },
|
||||
A_computed_property_name_in_a_class_property_declaration_must_directly_refer_to_a_built_in_symbol: { code: 1166, category: DiagnosticCategory.Error, key: "A computed property name in a class property declaration must directly refer to a built-in symbol." },
|
||||
Computed_property_names_are_only_available_when_targeting_ECMAScript_6_and_higher: { code: 1167, category: DiagnosticCategory.Error, key: "Computed property names are only available when targeting ECMAScript 6 and higher." },
|
||||
Computed_property_names_are_not_allowed_in_method_overloads: { code: 1168, category: DiagnosticCategory.Error, key: "Computed property names are not allowed in method overloads." },
|
||||
Computed_property_names_are_not_allowed_in_interfaces: { code: 1169, category: DiagnosticCategory.Error, key: "Computed property names are not allowed in interfaces." },
|
||||
Computed_property_names_are_not_allowed_in_type_literals: { code: 1170, category: DiagnosticCategory.Error, key: "Computed property names are not allowed in type literals." },
|
||||
A_computed_property_name_in_a_method_overload_must_directly_refer_to_a_built_in_symbol: { code: 1168, category: DiagnosticCategory.Error, key: "A computed property name in a method overload must directly refer to a built-in symbol." },
|
||||
A_computed_property_name_in_an_interface_must_directly_refer_to_a_built_in_symbol: { code: 1169, category: DiagnosticCategory.Error, key: "A computed property name in an interface must directly refer to a built-in symbol." },
|
||||
A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol: { code: 1170, category: DiagnosticCategory.Error, key: "A computed property name in a type literal must directly refer to a built-in symbol." },
|
||||
A_comma_expression_is_not_allowed_in_a_computed_property_name: { code: 1171, category: DiagnosticCategory.Error, key: "A comma expression is not allowed in a computed property name." },
|
||||
extends_clause_already_seen: { code: 1172, category: DiagnosticCategory.Error, key: "'extends' clause already seen." },
|
||||
extends_clause_must_precede_implements_clause: { code: 1173, category: DiagnosticCategory.Error, key: "'extends' clause must precede 'implements' clause." },
|
||||
@@ -147,6 +147,13 @@ module ts {
|
||||
Merge_conflict_marker_encountered: { code: 1185, category: DiagnosticCategory.Error, key: "Merge conflict marker encountered." },
|
||||
A_rest_element_cannot_have_an_initializer: { code: 1186, category: DiagnosticCategory.Error, key: "A rest element cannot have an initializer." },
|
||||
A_parameter_property_may_not_be_a_binding_pattern: { code: 1187, category: DiagnosticCategory.Error, key: "A parameter property may not be a binding pattern." },
|
||||
Only_a_single_variable_declaration_is_allowed_in_a_for_of_statement: { code: 1188, category: DiagnosticCategory.Error, key: "Only a single variable declaration is allowed in a 'for...of' statement." },
|
||||
The_variable_declaration_of_a_for_in_statement_cannot_have_an_initializer: { code: 1189, category: DiagnosticCategory.Error, key: "The variable declaration of a 'for...in' statement cannot have an initializer." },
|
||||
The_variable_declaration_of_a_for_of_statement_cannot_have_an_initializer: { code: 1190, category: DiagnosticCategory.Error, key: "The variable declaration of a 'for...of' statement cannot have an initializer." },
|
||||
An_import_declaration_cannot_have_modifiers: { code: 1191, category: DiagnosticCategory.Error, key: "An import declaration cannot have modifiers." },
|
||||
External_module_0_has_no_default_export_or_export_assignment: { code: 1192, category: DiagnosticCategory.Error, key: "External module '{0}' has no default export or export assignment." },
|
||||
An_export_declaration_cannot_have_modifiers: { code: 1193, category: DiagnosticCategory.Error, key: "An export declaration cannot have modifiers." },
|
||||
Export_declarations_are_not_permitted_in_an_internal_module: { code: 1194, category: DiagnosticCategory.Error, key: "Export declarations are not permitted in an internal module." },
|
||||
Duplicate_identifier_0: { code: 2300, category: DiagnosticCategory.Error, key: "Duplicate identifier '{0}'." },
|
||||
Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: { code: 2301, category: DiagnosticCategory.Error, key: "Initializer of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor." },
|
||||
Static_members_cannot_reference_class_type_parameters: { code: 2302, category: DiagnosticCategory.Error, key: "Static members cannot reference class type parameters." },
|
||||
@@ -166,7 +173,7 @@ module ts {
|
||||
Global_type_0_must_be_a_class_or_interface_type: { code: 2316, category: DiagnosticCategory.Error, key: "Global type '{0}' must be a class or interface type." },
|
||||
Global_type_0_must_have_1_type_parameter_s: { code: 2317, category: DiagnosticCategory.Error, key: "Global type '{0}' must have {1} type parameter(s)." },
|
||||
Cannot_find_global_type_0: { code: 2318, category: DiagnosticCategory.Error, key: "Cannot find global type '{0}'." },
|
||||
Named_properties_0_of_types_1_and_2_are_not_identical: { code: 2319, category: DiagnosticCategory.Error, key: "Named properties '{0}' of types '{1}' and '{2}' are not identical." },
|
||||
Named_property_0_of_types_1_and_2_are_not_identical: { code: 2319, category: DiagnosticCategory.Error, key: "Named property '{0}' of types '{1}' and '{2}' are not identical." },
|
||||
Interface_0_cannot_simultaneously_extend_types_1_and_2: { code: 2320, category: DiagnosticCategory.Error, key: "Interface '{0}' cannot simultaneously extend types '{1}' and '{2}'." },
|
||||
Excessive_stack_depth_comparing_types_0_and_1: { code: 2321, category: DiagnosticCategory.Error, key: "Excessive stack depth comparing types '{0}' and '{1}'." },
|
||||
Type_0_is_not_assignable_to_type_1: { code: 2322, category: DiagnosticCategory.Error, key: "Type '{0}' is not assignable to type '{1}'." },
|
||||
@@ -188,7 +195,7 @@ module ts {
|
||||
Property_0_does_not_exist_on_type_1: { code: 2339, category: DiagnosticCategory.Error, key: "Property '{0}' does not exist on type '{1}'." },
|
||||
Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword: { code: 2340, category: DiagnosticCategory.Error, key: "Only public and protected methods of the base class are accessible via the 'super' keyword" },
|
||||
Property_0_is_private_and_only_accessible_within_class_1: { code: 2341, category: DiagnosticCategory.Error, key: "Property '{0}' is private and only accessible within class '{1}'." },
|
||||
An_index_expression_argument_must_be_of_type_string_number_or_any: { code: 2342, category: DiagnosticCategory.Error, key: "An index expression argument must be of type 'string', 'number', or 'any'." },
|
||||
An_index_expression_argument_must_be_of_type_string_number_symbol_or_any: { code: 2342, category: DiagnosticCategory.Error, key: "An index expression argument must be of type 'string', 'number', 'symbol, or 'any'." },
|
||||
Type_0_does_not_satisfy_the_constraint_1: { code: 2344, category: DiagnosticCategory.Error, key: "Type '{0}' does not satisfy the constraint '{1}'." },
|
||||
Argument_of_type_0_is_not_assignable_to_parameter_of_type_1: { code: 2345, category: DiagnosticCategory.Error, key: "Argument of type '{0}' is not assignable to parameter of type '{1}'." },
|
||||
Supplied_parameters_do_not_match_any_signature_of_call_target: { code: 2346, category: DiagnosticCategory.Error, key: "Supplied parameters do not match any signature of call target." },
|
||||
@@ -204,7 +211,7 @@ module ts {
|
||||
The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_property_or_indexer: { code: 2357, category: DiagnosticCategory.Error, key: "The operand of an increment or decrement operator must be a variable, property or indexer." },
|
||||
The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter: { code: 2358, category: DiagnosticCategory.Error, key: "The left-hand side of an 'instanceof' expression must be of type 'any', an object type or a type parameter." },
|
||||
The_right_hand_side_of_an_instanceof_expression_must_be_of_type_any_or_of_a_type_assignable_to_the_Function_interface_type: { code: 2359, category: DiagnosticCategory.Error, key: "The right-hand side of an 'instanceof' expression must be of type 'any' or of a type assignable to the 'Function' interface type." },
|
||||
The_left_hand_side_of_an_in_expression_must_be_of_types_any_string_or_number: { code: 2360, category: DiagnosticCategory.Error, key: "The left-hand side of an 'in' expression must be of types 'any', 'string' or 'number'." },
|
||||
The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol: { code: 2360, category: DiagnosticCategory.Error, key: "The left-hand side of an 'in' expression must be of type 'any', 'string', 'number', or 'symbol'." },
|
||||
The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter: { code: 2361, category: DiagnosticCategory.Error, key: "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_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type: { code: 2362, category: DiagnosticCategory.Error, key: "The left-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: { code: 2363, category: DiagnosticCategory.Error, key: "The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type." },
|
||||
@@ -275,7 +282,7 @@ module ts {
|
||||
Ambient_external_module_declaration_cannot_specify_relative_module_name: { code: 2436, category: DiagnosticCategory.Error, key: "Ambient external module declaration cannot specify relative module name." },
|
||||
Module_0_is_hidden_by_a_local_declaration_with_the_same_name: { code: 2437, category: DiagnosticCategory.Error, key: "Module '{0}' is hidden by a local declaration with the same name" },
|
||||
Import_name_cannot_be_0: { code: 2438, category: DiagnosticCategory.Error, key: "Import name cannot be '{0}'" },
|
||||
Import_declaration_in_an_ambient_external_module_declaration_cannot_reference_external_module_through_relative_external_module_name: { code: 2439, category: DiagnosticCategory.Error, key: "Import declaration in an ambient external module declaration cannot reference external module through relative external module name." },
|
||||
Import_or_export_declaration_in_an_ambient_external_module_declaration_cannot_reference_external_module_through_relative_external_module_name: { code: 2439, category: DiagnosticCategory.Error, key: "Import or export declaration in an ambient external module declaration cannot reference external module through relative external module name." },
|
||||
Import_declaration_conflicts_with_local_declaration_of_0: { code: 2440, category: DiagnosticCategory.Error, key: "Import declaration conflicts with local declaration of '{0}'" },
|
||||
Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_an_external_module: { code: 2441, category: DiagnosticCategory.Error, key: "Duplicate identifier '{0}'. Compiler reserves name '{1}' in top level scope of an external module." },
|
||||
Types_have_separate_declarations_of_a_private_property_0: { code: 2442, category: DiagnosticCategory.Error, key: "Types have separate declarations of a private property '{0}'." },
|
||||
@@ -299,20 +306,27 @@ module ts {
|
||||
Type_0_is_not_an_array_type: { code: 2461, category: DiagnosticCategory.Error, key: "Type '{0}' is not an array type." },
|
||||
A_rest_element_must_be_last_in_an_array_destructuring_pattern: { code: 2462, category: DiagnosticCategory.Error, key: "A rest element must be last in an array destructuring pattern" },
|
||||
A_binding_pattern_parameter_cannot_be_optional_in_an_implementation_signature: { code: 2463, category: DiagnosticCategory.Error, key: "A binding pattern parameter cannot be optional in an implementation signature." },
|
||||
A_computed_property_name_must_be_of_type_string_number_or_any: { code: 2464, category: DiagnosticCategory.Error, key: "A computed property name must be of type 'string', 'number', or 'any'." },
|
||||
A_computed_property_name_must_be_of_type_string_number_symbol_or_any: { code: 2464, category: DiagnosticCategory.Error, key: "A computed property name must be of type 'string', 'number', 'symbol', or 'any'." },
|
||||
this_cannot_be_referenced_in_a_computed_property_name: { code: 2465, category: DiagnosticCategory.Error, key: "'this' cannot be referenced in a computed property name." },
|
||||
super_cannot_be_referenced_in_a_computed_property_name: { code: 2466, category: DiagnosticCategory.Error, key: "'super' cannot be referenced in a computed property name." },
|
||||
A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type: { code: 2466, category: DiagnosticCategory.Error, key: "A computed property name cannot reference a type parameter from its containing type." },
|
||||
Spread_operator_in_new_expressions_is_only_available_when_targeting_ECMAScript_6_and_higher: { code: 2468, category: DiagnosticCategory.Error, key: "Spread operator in 'new' expressions is only available when targeting ECMAScript 6 and higher." },
|
||||
Enum_declarations_must_all_be_const_or_non_const: { code: 2469, category: DiagnosticCategory.Error, key: "Enum declarations must all be const or non-const." },
|
||||
In_const_enum_declarations_member_initializer_must_be_constant_expression: { code: 2470, category: DiagnosticCategory.Error, key: "In 'const' enum declarations member initializer must be constant expression." },
|
||||
const_enums_can_only_be_used_in_property_or_index_access_expressions_or_the_right_hand_side_of_an_import_declaration_or_export_assignment: { code: 2471, category: DiagnosticCategory.Error, key: "'const' enums can only be used in property or index access expressions or the right hand side of an import declaration or export assignment." },
|
||||
A_const_enum_member_can_only_be_accessed_using_a_string_literal: { code: 2472, category: DiagnosticCategory.Error, key: "A const enum member can only be accessed using a string literal." },
|
||||
const_enum_member_initializer_was_evaluated_to_a_non_finite_value: { code: 2473, category: DiagnosticCategory.Error, key: "'const' enum member initializer was evaluated to a non-finite value." },
|
||||
const_enum_member_initializer_was_evaluated_to_disallowed_value_NaN: { code: 2474, category: DiagnosticCategory.Error, key: "'const' enum member initializer was evaluated to disallowed value 'NaN'." },
|
||||
Property_0_does_not_exist_on_const_enum_1: { code: 2475, category: DiagnosticCategory.Error, key: "Property '{0}' does not exist on 'const' enum '{1}'." },
|
||||
let_is_not_allowed_to_be_used_as_a_name_in_let_or_const_declarations: { code: 2476, category: DiagnosticCategory.Error, key: "'let' is not allowed to be used as a name in 'let' or 'const' declarations." },
|
||||
Cannot_initialize_outer_scoped_variable_0_in_the_same_scope_as_block_scoped_declaration_1: { code: 2477, category: DiagnosticCategory.Error, key: "Cannot initialize outer scoped variable '{0}' in the same scope as block scoped declaration '{1}'." },
|
||||
A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type: { code: 2467, category: DiagnosticCategory.Error, key: "A computed property name cannot reference a type parameter from its containing type." },
|
||||
Cannot_find_global_value_0: { code: 2468, category: DiagnosticCategory.Error, key: "Cannot find global value '{0}'." },
|
||||
The_0_operator_cannot_be_applied_to_type_symbol: { code: 2469, category: DiagnosticCategory.Error, key: "The '{0}' operator cannot be applied to type 'symbol'." },
|
||||
Symbol_reference_does_not_refer_to_the_global_Symbol_constructor_object: { code: 2470, category: DiagnosticCategory.Error, key: "'Symbol' reference does not refer to the global Symbol constructor object." },
|
||||
A_computed_property_name_of_the_form_0_must_be_of_type_symbol: { code: 2471, category: DiagnosticCategory.Error, key: "A computed property name of the form '{0}' must be of type 'symbol'." },
|
||||
Spread_operator_in_new_expressions_is_only_available_when_targeting_ECMAScript_6_and_higher: { code: 2472, category: DiagnosticCategory.Error, key: "Spread operator in 'new' expressions is only available when targeting ECMAScript 6 and higher." },
|
||||
Enum_declarations_must_all_be_const_or_non_const: { code: 2473, category: DiagnosticCategory.Error, key: "Enum declarations must all be const or non-const." },
|
||||
In_const_enum_declarations_member_initializer_must_be_constant_expression: { code: 2474, category: DiagnosticCategory.Error, key: "In 'const' enum declarations member initializer must be constant expression." },
|
||||
const_enums_can_only_be_used_in_property_or_index_access_expressions_or_the_right_hand_side_of_an_import_declaration_or_export_assignment: { code: 2475, category: DiagnosticCategory.Error, key: "'const' enums can only be used in property or index access expressions or the right hand side of an import declaration or export assignment." },
|
||||
A_const_enum_member_can_only_be_accessed_using_a_string_literal: { code: 2476, category: DiagnosticCategory.Error, key: "A const enum member can only be accessed using a string literal." },
|
||||
const_enum_member_initializer_was_evaluated_to_a_non_finite_value: { code: 2477, category: DiagnosticCategory.Error, key: "'const' enum member initializer was evaluated to a non-finite value." },
|
||||
const_enum_member_initializer_was_evaluated_to_disallowed_value_NaN: { code: 2478, category: DiagnosticCategory.Error, key: "'const' enum member initializer was evaluated to disallowed value 'NaN'." },
|
||||
Property_0_does_not_exist_on_const_enum_1: { code: 2479, category: DiagnosticCategory.Error, key: "Property '{0}' does not exist on 'const' enum '{1}'." },
|
||||
let_is_not_allowed_to_be_used_as_a_name_in_let_or_const_declarations: { code: 2480, category: DiagnosticCategory.Error, key: "'let' is not allowed to be used as a name in 'let' or 'const' declarations." },
|
||||
Cannot_initialize_outer_scoped_variable_0_in_the_same_scope_as_block_scoped_declaration_1: { code: 2481, category: DiagnosticCategory.Error, key: "Cannot initialize outer scoped variable '{0}' in the same scope as block scoped declaration '{1}'." },
|
||||
for_of_statements_are_only_available_when_targeting_ECMAScript_6_or_higher: { code: 2482, category: DiagnosticCategory.Error, key: "'for...of' statements are only available when targeting ECMAScript 6 or higher." },
|
||||
The_left_hand_side_of_a_for_of_statement_cannot_use_a_type_annotation: { code: 2483, category: DiagnosticCategory.Error, key: "The left-hand side of a 'for...of' statement cannot use a type annotation." },
|
||||
Export_declaration_conflicts_with_exported_declaration_of_0: { code: 2484, category: DiagnosticCategory.Error, key: "Export declaration conflicts with exported declaration of '{0}'" },
|
||||
Import_declaration_0_is_using_private_name_1: { code: 4000, category: DiagnosticCategory.Error, key: "Import declaration '{0}' is using private name '{1}'." },
|
||||
Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: { code: 4002, category: DiagnosticCategory.Error, key: "Type parameter '{0}' of exported class has or is using private name '{1}'." },
|
||||
Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1: { code: 4004, category: DiagnosticCategory.Error, key: "Type parameter '{0}' of exported interface has or is using private name '{1}'." },
|
||||
@@ -459,5 +473,6 @@ module ts {
|
||||
yield_expressions_are_not_currently_supported: { code: 9000, category: DiagnosticCategory.Error, key: "'yield' expressions are not currently supported." },
|
||||
Generators_are_not_currently_supported: { code: 9001, category: DiagnosticCategory.Error, key: "Generators are not currently supported." },
|
||||
The_arguments_object_cannot_be_referenced_in_an_arrow_function_Consider_using_a_standard_function_expression: { code: 9002, category: DiagnosticCategory.Error, key: "The 'arguments' object cannot be referenced in an arrow function. Consider using a standard function expression." },
|
||||
for_of_statements_are_not_currently_supported: { code: 9003, category: DiagnosticCategory.Error, key: "'for...of' statements are not currently supported." },
|
||||
};
|
||||
}
|
||||
@@ -483,11 +483,11 @@
|
||||
"category": "Error",
|
||||
"code": 1164
|
||||
},
|
||||
"Computed property names are not allowed in an ambient context.": {
|
||||
"A computed property name in an ambient context must directly refer to a built-in symbol.": {
|
||||
"category": "Error",
|
||||
"code": 1165
|
||||
},
|
||||
"Computed property names are not allowed in class property declarations.": {
|
||||
"A computed property name in a class property declaration must directly refer to a built-in symbol.": {
|
||||
"category": "Error",
|
||||
"code": 1166
|
||||
},
|
||||
@@ -495,15 +495,15 @@
|
||||
"category": "Error",
|
||||
"code": 1167
|
||||
},
|
||||
"Computed property names are not allowed in method overloads.": {
|
||||
"A computed property name in a method overload must directly refer to a built-in symbol.": {
|
||||
"category": "Error",
|
||||
"code": 1168
|
||||
},
|
||||
"Computed property names are not allowed in interfaces.": {
|
||||
"A computed property name in an interface must directly refer to a built-in symbol.": {
|
||||
"category": "Error",
|
||||
"code": 1169
|
||||
},
|
||||
"Computed property names are not allowed in type literals.": {
|
||||
"A computed property name in a type literal must directly refer to a built-in symbol.": {
|
||||
"category": "Error",
|
||||
"code": 1170
|
||||
},
|
||||
@@ -579,6 +579,34 @@
|
||||
"category": "Error",
|
||||
"code": 1187
|
||||
},
|
||||
"Only a single variable declaration is allowed in a 'for...of' statement.": {
|
||||
"category": "Error",
|
||||
"code": 1188
|
||||
},
|
||||
"The variable declaration of a 'for...in' statement cannot have an initializer.": {
|
||||
"category": "Error",
|
||||
"code": 1189
|
||||
},
|
||||
"The variable declaration of a 'for...of' statement cannot have an initializer.": {
|
||||
"category": "Error",
|
||||
"code": 1190
|
||||
},
|
||||
"An import declaration cannot have modifiers.": {
|
||||
"category": "Error",
|
||||
"code": 1191
|
||||
},
|
||||
"External module '{0}' has no default export or export assignment.": {
|
||||
"category": "Error",
|
||||
"code": 1192
|
||||
},
|
||||
"An export declaration cannot have modifiers.": {
|
||||
"category": "Error",
|
||||
"code": 1193
|
||||
},
|
||||
"Export declarations are not permitted in an internal module.": {
|
||||
"category": "Error",
|
||||
"code": 1194
|
||||
},
|
||||
|
||||
"Duplicate identifier '{0}'.": {
|
||||
"category": "Error",
|
||||
@@ -656,7 +684,7 @@
|
||||
"category": "Error",
|
||||
"code": 2318
|
||||
},
|
||||
"Named properties '{0}' of types '{1}' and '{2}' are not identical.": {
|
||||
"Named property '{0}' of types '{1}' and '{2}' are not identical.": {
|
||||
"category": "Error",
|
||||
"code": 2319
|
||||
},
|
||||
@@ -744,7 +772,7 @@
|
||||
"category": "Error",
|
||||
"code": 2341
|
||||
},
|
||||
"An index expression argument must be of type 'string', 'number', or 'any'.": {
|
||||
"An index expression argument must be of type 'string', 'number', 'symbol, or 'any'.": {
|
||||
"category": "Error",
|
||||
"code": 2342
|
||||
},
|
||||
@@ -808,7 +836,7 @@
|
||||
"category": "Error",
|
||||
"code": 2359
|
||||
},
|
||||
"The left-hand side of an 'in' expression must be of types 'any', 'string' or 'number'.": {
|
||||
"The left-hand side of an 'in' expression must be of type 'any', 'string', 'number', or 'symbol'.": {
|
||||
"category": "Error",
|
||||
"code": 2360
|
||||
},
|
||||
@@ -1092,7 +1120,7 @@
|
||||
"category": "Error",
|
||||
"code": 2438
|
||||
},
|
||||
"Import declaration in an ambient external module declaration cannot reference external module through relative external module name.": {
|
||||
"Import or export declaration in an ambient external module declaration cannot reference external module through relative external module name.": {
|
||||
"category": "Error",
|
||||
"code": 2439
|
||||
},
|
||||
@@ -1188,7 +1216,7 @@
|
||||
"category": "Error",
|
||||
"code": 2463
|
||||
},
|
||||
"A computed property name must be of type 'string', 'number', or 'any'.": {
|
||||
"A computed property name must be of type 'string', 'number', 'symbol', or 'any'.": {
|
||||
"category": "Error",
|
||||
"code": 2464
|
||||
},
|
||||
@@ -1202,48 +1230,76 @@
|
||||
},
|
||||
"A computed property name cannot reference a type parameter from its containing type.": {
|
||||
"category": "Error",
|
||||
"code": 2466
|
||||
"code": 2467
|
||||
},
|
||||
"Spread operator in 'new' expressions is only available when targeting ECMAScript 6 and higher.": {
|
||||
"Cannot find global value '{0}'.": {
|
||||
"category": "Error",
|
||||
"code": 2468
|
||||
},
|
||||
"Enum declarations must all be const or non-const.": {
|
||||
"The '{0}' operator cannot be applied to type 'symbol'.": {
|
||||
"category": "Error",
|
||||
"code": 2469
|
||||
},
|
||||
"In 'const' enum declarations member initializer must be constant expression.": {
|
||||
"'Symbol' reference does not refer to the global Symbol constructor object.": {
|
||||
"category": "Error",
|
||||
"code": 2470
|
||||
},
|
||||
"'const' enums can only be used in property or index access expressions or the right hand side of an import declaration or export assignment.": {
|
||||
"A computed property name of the form '{0}' must be of type 'symbol'.": {
|
||||
"category": "Error",
|
||||
"code": 2471
|
||||
},
|
||||
"A const enum member can only be accessed using a string literal.": {
|
||||
"Spread operator in 'new' expressions is only available when targeting ECMAScript 6 and higher.": {
|
||||
"category": "Error",
|
||||
"code": 2472
|
||||
},
|
||||
"'const' enum member initializer was evaluated to a non-finite value.": {
|
||||
"Enum declarations must all be const or non-const.": {
|
||||
"category": "Error",
|
||||
"code": 2473
|
||||
},
|
||||
"'const' enum member initializer was evaluated to disallowed value 'NaN'.": {
|
||||
"In 'const' enum declarations member initializer must be constant expression.": {
|
||||
"category": "Error",
|
||||
"code": 2474
|
||||
},
|
||||
"Property '{0}' does not exist on 'const' enum '{1}'.": {
|
||||
"'const' enums can only be used in property or index access expressions or the right hand side of an import declaration or export assignment.": {
|
||||
"category": "Error",
|
||||
"code": 2475
|
||||
},
|
||||
"'let' is not allowed to be used as a name in 'let' or 'const' declarations.": {
|
||||
"A const enum member can only be accessed using a string literal.": {
|
||||
"category": "Error",
|
||||
"code": 2476
|
||||
},
|
||||
"Cannot initialize outer scoped variable '{0}' in the same scope as block scoped declaration '{1}'.": {
|
||||
"'const' enum member initializer was evaluated to a non-finite value.": {
|
||||
"category": "Error",
|
||||
"code": 2477
|
||||
},
|
||||
"'const' enum member initializer was evaluated to disallowed value 'NaN'.": {
|
||||
"category": "Error",
|
||||
"code": 2478
|
||||
},
|
||||
"Property '{0}' does not exist on 'const' enum '{1}'.": {
|
||||
"category": "Error",
|
||||
"code": 2479
|
||||
},
|
||||
"'let' is not allowed to be used as a name in 'let' or 'const' declarations.": {
|
||||
"category": "Error",
|
||||
"code": 2480
|
||||
},
|
||||
"Cannot initialize outer scoped variable '{0}' in the same scope as block scoped declaration '{1}'.": {
|
||||
"category": "Error",
|
||||
"code": 2481
|
||||
},
|
||||
"'for...of' statements are only available when targeting ECMAScript 6 or higher.": {
|
||||
"category": "Error",
|
||||
"code": 2482
|
||||
},
|
||||
"The left-hand side of a 'for...of' statement cannot use a type annotation.": {
|
||||
"category": "Error",
|
||||
"code": 2483
|
||||
},
|
||||
"Export declaration conflicts with exported declaration of '{0}'": {
|
||||
"category": "Error",
|
||||
"code": 2484
|
||||
},
|
||||
|
||||
"Import declaration '{0}' is using private name '{1}'.": {
|
||||
"category": "Error",
|
||||
@@ -1829,5 +1885,9 @@
|
||||
"The 'arguments' object cannot be referenced in an arrow function. Consider using a standard function expression.": {
|
||||
"category": "Error",
|
||||
"code": 9002
|
||||
},
|
||||
"'for...of' statements are not currently supported.": {
|
||||
"category": "Error",
|
||||
"code": 9003
|
||||
}
|
||||
}
|
||||
|
||||
+898
-235
File diff suppressed because it is too large
Load Diff
+328
-107
@@ -152,6 +152,7 @@ module ts {
|
||||
return visitNode(cbNode, (<PostfixUnaryExpression>node).operand);
|
||||
case SyntaxKind.BinaryExpression:
|
||||
return visitNode(cbNode, (<BinaryExpression>node).left) ||
|
||||
visitNode(cbNode, (<BinaryExpression>node).operatorToken) ||
|
||||
visitNode(cbNode, (<BinaryExpression>node).right);
|
||||
case SyntaxKind.ConditionalExpression:
|
||||
return visitNode(cbNode, (<ConditionalExpression>node).condition) ||
|
||||
@@ -191,6 +192,10 @@ module ts {
|
||||
return visitNode(cbNode, (<ForInStatement>node).initializer) ||
|
||||
visitNode(cbNode, (<ForInStatement>node).expression) ||
|
||||
visitNode(cbNode, (<ForInStatement>node).statement);
|
||||
case SyntaxKind.ForOfStatement:
|
||||
return visitNode(cbNode, (<ForOfStatement>node).initializer) ||
|
||||
visitNode(cbNode, (<ForOfStatement>node).expression) ||
|
||||
visitNode(cbNode, (<ForOfStatement>node).statement);
|
||||
case SyntaxKind.ContinueStatement:
|
||||
case SyntaxKind.BreakStatement:
|
||||
return visitNode(cbNode, (<BreakOrContinueStatement>node).label);
|
||||
@@ -247,10 +252,30 @@ module ts {
|
||||
return visitNodes(cbNodes, node.modifiers) ||
|
||||
visitNode(cbNode, (<ModuleDeclaration>node).name) ||
|
||||
visitNode(cbNode, (<ModuleDeclaration>node).body);
|
||||
case SyntaxKind.ImportEqualsDeclaration:
|
||||
return visitNodes(cbNodes, node.modifiers) ||
|
||||
visitNode(cbNode, (<ImportEqualsDeclaration>node).name) ||
|
||||
visitNode(cbNode, (<ImportEqualsDeclaration>node).moduleReference);
|
||||
case SyntaxKind.ImportDeclaration:
|
||||
return visitNodes(cbNodes, node.modifiers) ||
|
||||
visitNode(cbNode, (<ImportDeclaration>node).name) ||
|
||||
visitNode(cbNode, (<ImportDeclaration>node).moduleReference);
|
||||
visitNode(cbNode, (<ImportDeclaration>node).importClause) ||
|
||||
visitNode(cbNode, (<ImportDeclaration>node).moduleSpecifier);
|
||||
case SyntaxKind.ImportClause:
|
||||
return visitNode(cbNode, (<ImportClause>node).name) ||
|
||||
visitNode(cbNode, (<ImportClause>node).namedBindings);
|
||||
case SyntaxKind.NamespaceImport:
|
||||
return visitNode(cbNode, (<NamespaceImport>node).name);
|
||||
case SyntaxKind.NamedImports:
|
||||
case SyntaxKind.NamedExports:
|
||||
return visitNodes(cbNodes, (<NamedImportsOrExports>node).elements);
|
||||
case SyntaxKind.ExportDeclaration:
|
||||
return visitNodes(cbNodes, node.modifiers) ||
|
||||
visitNode(cbNode, (<ExportDeclaration>node).exportClause) ||
|
||||
visitNode(cbNode, (<ExportDeclaration>node).moduleSpecifier);
|
||||
case SyntaxKind.ImportSpecifier:
|
||||
case SyntaxKind.ExportSpecifier:
|
||||
return visitNode(cbNode, (<ImportOrExportSpecifier>node).propertyName) ||
|
||||
visitNode(cbNode, (<ImportOrExportSpecifier>node).name);
|
||||
case SyntaxKind.ExportAssignment:
|
||||
return visitNodes(cbNodes, node.modifiers) ||
|
||||
visitNode(cbNode, (<ExportAssignment>node).exportName);
|
||||
@@ -268,27 +293,28 @@ module ts {
|
||||
}
|
||||
|
||||
const enum ParsingContext {
|
||||
SourceElements, // Elements in source file
|
||||
ModuleElements, // Elements in module declaration
|
||||
BlockStatements, // Statements in block
|
||||
SwitchClauses, // Clauses in switch statement
|
||||
SwitchClauseStatements, // Statements in switch clause
|
||||
TypeMembers, // Members in interface or type literal
|
||||
ClassMembers, // Members in class declaration
|
||||
EnumMembers, // Members in enum declaration
|
||||
TypeReferences, // Type references in extends or implements clause
|
||||
VariableDeclarations, // Variable declarations in variable statement
|
||||
ObjectBindingElements, // Binding elements in object binding list
|
||||
ArrayBindingElements, // Binding elements in array binding list
|
||||
ArgumentExpressions, // Expressions in argument list
|
||||
ObjectLiteralMembers, // Members in object literal
|
||||
ArrayLiteralMembers, // Members in array literal
|
||||
Parameters, // Parameters in parameter list
|
||||
TypeParameters, // Type parameters in type parameter list
|
||||
TypeArguments, // Type arguments in type argument list
|
||||
TupleElementTypes, // Element types in tuple element type list
|
||||
HeritageClauses, // Heritage clauses for a class or interface declaration.
|
||||
Count // Number of parsing contexts
|
||||
SourceElements, // Elements in source file
|
||||
ModuleElements, // Elements in module declaration
|
||||
BlockStatements, // Statements in block
|
||||
SwitchClauses, // Clauses in switch statement
|
||||
SwitchClauseStatements, // Statements in switch clause
|
||||
TypeMembers, // Members in interface or type literal
|
||||
ClassMembers, // Members in class declaration
|
||||
EnumMembers, // Members in enum declaration
|
||||
TypeReferences, // Type references in extends or implements clause
|
||||
VariableDeclarations, // Variable declarations in variable statement
|
||||
ObjectBindingElements, // Binding elements in object binding list
|
||||
ArrayBindingElements, // Binding elements in array binding list
|
||||
ArgumentExpressions, // Expressions in argument list
|
||||
ObjectLiteralMembers, // Members in object literal
|
||||
ArrayLiteralMembers, // Members in array literal
|
||||
Parameters, // Parameters in parameter list
|
||||
TypeParameters, // Type parameters in type parameter list
|
||||
TypeArguments, // Type arguments in type argument list
|
||||
TupleElementTypes, // Element types in tuple element type list
|
||||
HeritageClauses, // Heritage clauses for a class or interface declaration.
|
||||
ImportOrExportSpecifiers, // Named import clause's import specifier list
|
||||
Count // Number of parsing contexts
|
||||
}
|
||||
|
||||
const enum Tristate {
|
||||
@@ -299,26 +325,27 @@ module ts {
|
||||
|
||||
function parsingContextErrors(context: ParsingContext): DiagnosticMessage {
|
||||
switch (context) {
|
||||
case ParsingContext.SourceElements: return Diagnostics.Declaration_or_statement_expected;
|
||||
case ParsingContext.ModuleElements: return Diagnostics.Declaration_or_statement_expected;
|
||||
case ParsingContext.BlockStatements: return Diagnostics.Statement_expected;
|
||||
case ParsingContext.SwitchClauses: return Diagnostics.case_or_default_expected;
|
||||
case ParsingContext.SwitchClauseStatements: return Diagnostics.Statement_expected;
|
||||
case ParsingContext.TypeMembers: return Diagnostics.Property_or_signature_expected;
|
||||
case ParsingContext.ClassMembers: return Diagnostics.Unexpected_token_A_constructor_method_accessor_or_property_was_expected;
|
||||
case ParsingContext.EnumMembers: return Diagnostics.Enum_member_expected;
|
||||
case ParsingContext.TypeReferences: return Diagnostics.Type_reference_expected;
|
||||
case ParsingContext.VariableDeclarations: return Diagnostics.Variable_declaration_expected;
|
||||
case ParsingContext.ObjectBindingElements: return Diagnostics.Property_destructuring_pattern_expected;
|
||||
case ParsingContext.ArrayBindingElements: return Diagnostics.Array_element_destructuring_pattern_expected;
|
||||
case ParsingContext.ArgumentExpressions: return Diagnostics.Argument_expression_expected;
|
||||
case ParsingContext.ObjectLiteralMembers: return Diagnostics.Property_assignment_expected;
|
||||
case ParsingContext.ArrayLiteralMembers: return Diagnostics.Expression_or_comma_expected;
|
||||
case ParsingContext.Parameters: return Diagnostics.Parameter_declaration_expected;
|
||||
case ParsingContext.TypeParameters: return Diagnostics.Type_parameter_declaration_expected;
|
||||
case ParsingContext.TypeArguments: return Diagnostics.Type_argument_expected;
|
||||
case ParsingContext.TupleElementTypes: return Diagnostics.Type_expected;
|
||||
case ParsingContext.HeritageClauses: return Diagnostics.Unexpected_token_expected;
|
||||
case ParsingContext.SourceElements: return Diagnostics.Declaration_or_statement_expected;
|
||||
case ParsingContext.ModuleElements: return Diagnostics.Declaration_or_statement_expected;
|
||||
case ParsingContext.BlockStatements: return Diagnostics.Statement_expected;
|
||||
case ParsingContext.SwitchClauses: return Diagnostics.case_or_default_expected;
|
||||
case ParsingContext.SwitchClauseStatements: return Diagnostics.Statement_expected;
|
||||
case ParsingContext.TypeMembers: return Diagnostics.Property_or_signature_expected;
|
||||
case ParsingContext.ClassMembers: return Diagnostics.Unexpected_token_A_constructor_method_accessor_or_property_was_expected;
|
||||
case ParsingContext.EnumMembers: return Diagnostics.Enum_member_expected;
|
||||
case ParsingContext.TypeReferences: return Diagnostics.Type_reference_expected;
|
||||
case ParsingContext.VariableDeclarations: return Diagnostics.Variable_declaration_expected;
|
||||
case ParsingContext.ObjectBindingElements: return Diagnostics.Property_destructuring_pattern_expected;
|
||||
case ParsingContext.ArrayBindingElements: return Diagnostics.Array_element_destructuring_pattern_expected;
|
||||
case ParsingContext.ArgumentExpressions: return Diagnostics.Argument_expression_expected;
|
||||
case ParsingContext.ObjectLiteralMembers: return Diagnostics.Property_assignment_expected;
|
||||
case ParsingContext.ArrayLiteralMembers: return Diagnostics.Expression_or_comma_expected;
|
||||
case ParsingContext.Parameters: return Diagnostics.Parameter_declaration_expected;
|
||||
case ParsingContext.TypeParameters: return Diagnostics.Type_parameter_declaration_expected;
|
||||
case ParsingContext.TypeArguments: return Diagnostics.Type_argument_expected;
|
||||
case ParsingContext.TupleElementTypes: return Diagnostics.Type_expected;
|
||||
case ParsingContext.HeritageClauses: return Diagnostics.Unexpected_token_expected;
|
||||
case ParsingContext.ImportOrExportSpecifiers: return Diagnostics.Identifier_expected;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1307,6 +1334,12 @@ module ts {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
function parseTokenNode<T extends Node>(): T {
|
||||
var node = <T>createNode(token);
|
||||
nextToken();
|
||||
return finishNode(node);
|
||||
}
|
||||
|
||||
function canParseSemicolon() {
|
||||
// If there's a real semicolon, then we can always parse it out.
|
||||
if (token === SyntaxKind.SemicolonToken) {
|
||||
@@ -1465,7 +1498,10 @@ module ts {
|
||||
// 'const' is only a modifier if followed by 'enum'.
|
||||
return nextToken() === SyntaxKind.EnumKeyword;
|
||||
}
|
||||
|
||||
if (token === SyntaxKind.ExportKeyword) {
|
||||
nextToken();
|
||||
return token !== SyntaxKind.AsteriskToken && token !== SyntaxKind.OpenBraceToken && canFollowModifier();
|
||||
}
|
||||
nextToken();
|
||||
return canFollowModifier();
|
||||
}
|
||||
@@ -1525,6 +1561,8 @@ module ts {
|
||||
return token === SyntaxKind.CommaToken || isStartOfType();
|
||||
case ParsingContext.HeritageClauses:
|
||||
return isHeritageClause();
|
||||
case ParsingContext.ImportOrExportSpecifiers:
|
||||
return isIdentifierOrKeyword();
|
||||
}
|
||||
|
||||
Debug.fail("Non-exhaustive case in 'isListElement'.");
|
||||
@@ -1561,6 +1599,7 @@ module ts {
|
||||
case ParsingContext.EnumMembers:
|
||||
case ParsingContext.ObjectLiteralMembers:
|
||||
case ParsingContext.ObjectBindingElements:
|
||||
case ParsingContext.ImportOrExportSpecifiers:
|
||||
return token === SyntaxKind.CloseBraceToken;
|
||||
case ParsingContext.SwitchClauseStatements:
|
||||
return token === SyntaxKind.CloseBraceToken || token === SyntaxKind.CaseKeyword || token === SyntaxKind.DefaultKeyword;
|
||||
@@ -1586,7 +1625,6 @@ module ts {
|
||||
return token === SyntaxKind.GreaterThanToken || token === SyntaxKind.OpenParenToken;
|
||||
case ParsingContext.HeritageClauses:
|
||||
return token === SyntaxKind.OpenBraceToken || token === SyntaxKind.CloseBraceToken;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1598,8 +1636,8 @@ module ts {
|
||||
}
|
||||
|
||||
// in the case where we're parsing the variable declarator of a 'for-in' statement, we
|
||||
// are done if we see an 'in' keyword in front of us.
|
||||
if (token === SyntaxKind.InKeyword) {
|
||||
// are done if we see an 'in' keyword in front of us. Same with for-of
|
||||
if (isInOrOfKeyword(token)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1821,6 +1859,8 @@ module ts {
|
||||
if (node) {
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.ImportDeclaration:
|
||||
case SyntaxKind.ImportEqualsDeclaration:
|
||||
case SyntaxKind.ExportDeclaration:
|
||||
case SyntaxKind.ExportAssignment:
|
||||
case SyntaxKind.ClassDeclaration:
|
||||
case SyntaxKind.InterfaceDeclaration:
|
||||
@@ -1877,6 +1917,7 @@ module ts {
|
||||
case SyntaxKind.BreakStatement:
|
||||
case SyntaxKind.ContinueStatement:
|
||||
case SyntaxKind.ForInStatement:
|
||||
case SyntaxKind.ForOfStatement:
|
||||
case SyntaxKind.ForStatement:
|
||||
case SyntaxKind.WhileStatement:
|
||||
case SyntaxKind.WithStatement:
|
||||
@@ -2079,14 +2120,6 @@ module ts {
|
||||
return allowIdentifierNames ? parseIdentifierName() : parseIdentifier();
|
||||
}
|
||||
|
||||
|
||||
|
||||
function parseTokenNode<T extends Node>(): T {
|
||||
var node = <T>createNode(token);
|
||||
nextToken();
|
||||
return finishNode(node);
|
||||
}
|
||||
|
||||
function parseTemplateExpression(): TemplateExpression {
|
||||
var template = <TemplateExpression>createNode(SyntaxKind.TemplateExpression);
|
||||
|
||||
@@ -2333,17 +2366,14 @@ module ts {
|
||||
}
|
||||
|
||||
function parseTypeMemberSemicolon() {
|
||||
// Try to parse out an explicit or implicit (ASI) semicolon for a type member. If we
|
||||
// don't have one, then an appropriate error will be reported.
|
||||
if (parseSemicolon()) {
|
||||
// We allow type members to be separated by commas or (possibly ASI) semicolons.
|
||||
// First check if it was a comma. If so, we're done with the member.
|
||||
if (parseOptional(SyntaxKind.CommaToken)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// If we don't have a semicolon, then the user may have written a comma instead
|
||||
// accidently (pretty easy to do since commas are so prevalent as list separators). So
|
||||
// just consume the comma and keep going. Note: we'll have already reported the error
|
||||
// about the missing semicolon above.
|
||||
parseOptional(SyntaxKind.CommaToken);
|
||||
// Didn't have a comma. We must have a (possible ASI) semicolon.
|
||||
parseSemicolon();
|
||||
}
|
||||
|
||||
function parseSignatureMember(kind: SyntaxKind): SignatureDeclaration {
|
||||
@@ -2593,6 +2623,7 @@ module ts {
|
||||
case SyntaxKind.StringKeyword:
|
||||
case SyntaxKind.NumberKeyword:
|
||||
case SyntaxKind.BooleanKeyword:
|
||||
case SyntaxKind.SymbolKeyword:
|
||||
// If these are followed by a dot, then parse these out as a dotted type reference instead.
|
||||
var node = tryParse(parseKeywordAndNoDot);
|
||||
return node || parseTypeReference();
|
||||
@@ -2617,6 +2648,7 @@ module ts {
|
||||
case SyntaxKind.StringKeyword:
|
||||
case SyntaxKind.NumberKeyword:
|
||||
case SyntaxKind.BooleanKeyword:
|
||||
case SyntaxKind.SymbolKeyword:
|
||||
case SyntaxKind.VoidKeyword:
|
||||
case SyntaxKind.TypeOfKeyword:
|
||||
case SyntaxKind.OpenBraceToken:
|
||||
@@ -2794,8 +2826,9 @@ module ts {
|
||||
// Expression[in] , AssignmentExpression[in]
|
||||
|
||||
var expr = parseAssignmentExpressionOrHigher();
|
||||
while (parseOptional(SyntaxKind.CommaToken)) {
|
||||
expr = makeBinaryExpression(expr, SyntaxKind.CommaToken, parseAssignmentExpressionOrHigher());
|
||||
var operatorToken: Node;
|
||||
while ((operatorToken = parseOptionalToken(SyntaxKind.CommaToken))) {
|
||||
expr = makeBinaryExpression(expr, operatorToken, parseAssignmentExpressionOrHigher());
|
||||
}
|
||||
return expr;
|
||||
}
|
||||
@@ -2874,9 +2907,7 @@ module ts {
|
||||
// Note: we call reScanGreaterToken so that we get an appropriately merged token
|
||||
// for cases like > > = becoming >>=
|
||||
if (isLeftHandSideExpression(expr) && isAssignmentOperator(reScanGreaterToken())) {
|
||||
var operator = token;
|
||||
nextToken();
|
||||
return makeBinaryExpression(expr, operator, parseAssignmentExpressionOrHigher());
|
||||
return makeBinaryExpression(expr, parseTokenNode(), parseAssignmentExpressionOrHigher());
|
||||
}
|
||||
|
||||
// It wasn't an assignment or a lambda. This is a conditional expression:
|
||||
@@ -3159,6 +3190,10 @@ module ts {
|
||||
return parseBinaryExpressionRest(precedence, leftOperand);
|
||||
}
|
||||
|
||||
function isInOrOfKeyword(t: SyntaxKind) {
|
||||
return t === SyntaxKind.InKeyword || t === SyntaxKind.OfKeyword;
|
||||
}
|
||||
|
||||
function parseBinaryExpressionRest(precedence: number, leftOperand: Expression): Expression {
|
||||
while (true) {
|
||||
// We either have a binary operator here, or we're finished. We call
|
||||
@@ -3176,9 +3211,7 @@ module ts {
|
||||
break;
|
||||
}
|
||||
|
||||
var operator = token;
|
||||
nextToken();
|
||||
leftOperand = makeBinaryExpression(leftOperand, operator, parseBinaryExpressionOrHigher(newPrecedence));
|
||||
leftOperand = makeBinaryExpression(leftOperand, parseTokenNode(), parseBinaryExpressionOrHigher(newPrecedence));
|
||||
}
|
||||
|
||||
return leftOperand;
|
||||
@@ -3234,10 +3267,10 @@ module ts {
|
||||
return -1;
|
||||
}
|
||||
|
||||
function makeBinaryExpression(left: Expression, operator: SyntaxKind, right: Expression): BinaryExpression {
|
||||
function makeBinaryExpression(left: Expression, operatorToken: Node, right: Expression): BinaryExpression {
|
||||
var node = <BinaryExpression>createNode(SyntaxKind.BinaryExpression, left.pos);
|
||||
node.left = left;
|
||||
node.operator = operator;
|
||||
node.operatorToken = operatorToken;
|
||||
node.right = right;
|
||||
return finishNode(node);
|
||||
}
|
||||
@@ -3788,7 +3821,7 @@ module ts {
|
||||
return finishNode(node);
|
||||
}
|
||||
|
||||
function parseForOrForInStatement(): Statement {
|
||||
function parseForOrForInOrForOfStatement(): Statement {
|
||||
var pos = getNodePos();
|
||||
parseExpected(SyntaxKind.ForKeyword);
|
||||
parseExpected(SyntaxKind.OpenParenToken);
|
||||
@@ -3796,21 +3829,27 @@ module ts {
|
||||
var initializer: VariableDeclarationList | Expression = undefined;
|
||||
if (token !== SyntaxKind.SemicolonToken) {
|
||||
if (token === SyntaxKind.VarKeyword || token === SyntaxKind.LetKeyword || token === SyntaxKind.ConstKeyword) {
|
||||
initializer = parseVariableDeclarationList(/*disallowIn:*/ true);
|
||||
initializer = parseVariableDeclarationList(/*inForStatementInitializer:*/ true);
|
||||
}
|
||||
else {
|
||||
initializer = disallowInAnd(parseExpression);
|
||||
}
|
||||
}
|
||||
var forOrForInStatement: IterationStatement;
|
||||
var forOrForInOrForOfStatement: IterationStatement;
|
||||
if (parseOptional(SyntaxKind.InKeyword)) {
|
||||
var forInStatement = <ForInStatement>createNode(SyntaxKind.ForInStatement, pos);
|
||||
forInStatement.initializer = initializer;
|
||||
forInStatement.expression = allowInAnd(parseExpression);
|
||||
parseExpected(SyntaxKind.CloseParenToken);
|
||||
forOrForInStatement = forInStatement;
|
||||
forOrForInOrForOfStatement = forInStatement;
|
||||
}
|
||||
else {
|
||||
else if (parseOptional(SyntaxKind.OfKeyword)) {
|
||||
var forOfStatement = <ForOfStatement>createNode(SyntaxKind.ForOfStatement, pos);
|
||||
forOfStatement.initializer = initializer;
|
||||
forOfStatement.expression = allowInAnd(parseAssignmentExpressionOrHigher);
|
||||
parseExpected(SyntaxKind.CloseParenToken);
|
||||
forOrForInOrForOfStatement = forOfStatement;
|
||||
} else {
|
||||
var forStatement = <ForStatement>createNode(SyntaxKind.ForStatement, pos);
|
||||
forStatement.initializer = initializer;
|
||||
parseExpected(SyntaxKind.SemicolonToken);
|
||||
@@ -3822,12 +3861,12 @@ module ts {
|
||||
forStatement.iterator = allowInAnd(parseExpression);
|
||||
}
|
||||
parseExpected(SyntaxKind.CloseParenToken);
|
||||
forOrForInStatement = forStatement;
|
||||
forOrForInOrForOfStatement = forStatement;
|
||||
}
|
||||
|
||||
forOrForInStatement.statement = parseStatement();
|
||||
forOrForInOrForOfStatement.statement = parseStatement();
|
||||
|
||||
return finishNode(forOrForInStatement);
|
||||
return finishNode(forOrForInOrForOfStatement);
|
||||
}
|
||||
|
||||
function parseBreakOrContinueStatement(kind: SyntaxKind): BreakOrContinueStatement {
|
||||
@@ -4073,7 +4112,7 @@ module ts {
|
||||
case SyntaxKind.WhileKeyword:
|
||||
return parseWhileStatement();
|
||||
case SyntaxKind.ForKeyword:
|
||||
return parseForOrForInStatement();
|
||||
return parseForOrForInOrForOfStatement();
|
||||
case SyntaxKind.ContinueKeyword:
|
||||
return parseBreakOrContinueStatement(SyntaxKind.ContinueStatement);
|
||||
case SyntaxKind.BreakKeyword:
|
||||
@@ -4215,11 +4254,13 @@ module ts {
|
||||
var node = <VariableDeclaration>createNode(SyntaxKind.VariableDeclaration);
|
||||
node.name = parseIdentifierOrPattern();
|
||||
node.type = parseTypeAnnotation();
|
||||
node.initializer = parseInitializer(/*inParameter*/ false);
|
||||
if (!isInOrOfKeyword(token)) {
|
||||
node.initializer = parseInitializer(/*inParameter*/ false);
|
||||
}
|
||||
return finishNode(node);
|
||||
}
|
||||
|
||||
function parseVariableDeclarationList(disallowIn: boolean): VariableDeclarationList {
|
||||
function parseVariableDeclarationList(inForStatementInitializer: boolean): VariableDeclarationList {
|
||||
var node = <VariableDeclarationList>createNode(SyntaxKind.VariableDeclarationList);
|
||||
|
||||
switch (token) {
|
||||
@@ -4236,20 +4277,39 @@ module ts {
|
||||
}
|
||||
|
||||
nextToken();
|
||||
var savedDisallowIn = inDisallowInContext();
|
||||
setDisallowInContext(disallowIn);
|
||||
|
||||
node.declarations = parseDelimitedList(ParsingContext.VariableDeclarations, parseVariableDeclaration);
|
||||
// The user may have written the following:
|
||||
//
|
||||
// for (var of X) { }
|
||||
//
|
||||
// In this case, we want to parse an empty declaration list, and then parse 'of'
|
||||
// as a keyword. The reason this is not automatic is that 'of' is a valid identifier.
|
||||
// So we need to look ahead to determine if 'of' should be treated as a keyword in
|
||||
// this context.
|
||||
// The checker will then give an error that there is an empty declaration list.
|
||||
if (token === SyntaxKind.OfKeyword && lookAhead(canFollowContextualOfKeyword)) {
|
||||
node.declarations = createMissingList<VariableDeclaration>();
|
||||
}
|
||||
else {
|
||||
var savedDisallowIn = inDisallowInContext();
|
||||
setDisallowInContext(inForStatementInitializer);
|
||||
|
||||
setDisallowInContext(savedDisallowIn);
|
||||
node.declarations = parseDelimitedList(ParsingContext.VariableDeclarations, parseVariableDeclaration);
|
||||
|
||||
setDisallowInContext(savedDisallowIn);
|
||||
}
|
||||
|
||||
return finishNode(node);
|
||||
}
|
||||
|
||||
function canFollowContextualOfKeyword(): boolean {
|
||||
return nextTokenIsIdentifier() && nextToken() === SyntaxKind.CloseParenToken;
|
||||
}
|
||||
|
||||
function parseVariableStatement(fullStart: number, modifiers: ModifiersArray): VariableStatement {
|
||||
var node = <VariableStatement>createNode(SyntaxKind.VariableStatement, fullStart);
|
||||
setModifiers(node, modifiers);
|
||||
node.declarationList = parseVariableDeclarationList(/*disallowIn:*/ false);
|
||||
node.declarationList = parseVariableDeclarationList(/*inForStatementInitializer:*/ false);
|
||||
parseSemicolon();
|
||||
return finishNode(node);
|
||||
}
|
||||
@@ -4588,15 +4648,75 @@ module ts {
|
||||
return nextToken() === SyntaxKind.OpenParenToken;
|
||||
}
|
||||
|
||||
function parseImportDeclaration(fullStart: number, modifiers: ModifiersArray): ImportDeclaration {
|
||||
var node = <ImportDeclaration>createNode(SyntaxKind.ImportDeclaration, fullStart);
|
||||
setModifiers(node, modifiers);
|
||||
function nextTokenIsCommaOrFromKeyword() {
|
||||
nextToken();
|
||||
return token === SyntaxKind.CommaToken ||
|
||||
token === SyntaxKind.FromKeyword;
|
||||
}
|
||||
|
||||
function parseImportDeclarationOrImportEqualsDeclaration(fullStart: number, modifiers: ModifiersArray): ImportEqualsDeclaration | ImportDeclaration {
|
||||
parseExpected(SyntaxKind.ImportKeyword);
|
||||
node.name = parseIdentifier();
|
||||
parseExpected(SyntaxKind.EqualsToken);
|
||||
node.moduleReference = parseModuleReference();
|
||||
var afterImportPos = scanner.getStartPos();
|
||||
|
||||
var identifier: Identifier;
|
||||
if (isIdentifier()) {
|
||||
identifier = parseIdentifier();
|
||||
if (token !== SyntaxKind.CommaToken && token !== SyntaxKind.FromKeyword) {
|
||||
// ImportEquals declaration of type:
|
||||
// import x = require("mod"); or
|
||||
// import x = M.x;
|
||||
var importEqualsDeclaration = <ImportEqualsDeclaration>createNode(SyntaxKind.ImportEqualsDeclaration, fullStart);
|
||||
setModifiers(importEqualsDeclaration, modifiers);
|
||||
importEqualsDeclaration.name = identifier;
|
||||
parseExpected(SyntaxKind.EqualsToken);
|
||||
importEqualsDeclaration.moduleReference = parseModuleReference();
|
||||
parseSemicolon();
|
||||
return finishNode(importEqualsDeclaration);
|
||||
}
|
||||
}
|
||||
|
||||
// Import statement
|
||||
var importDeclaration = <ImportDeclaration>createNode(SyntaxKind.ImportDeclaration, fullStart);
|
||||
setModifiers(importDeclaration, modifiers);
|
||||
|
||||
// ImportDeclaration:
|
||||
// import ImportClause from ModuleSpecifier ;
|
||||
// import ModuleSpecifier;
|
||||
if (identifier || // import id
|
||||
token === SyntaxKind.AsteriskToken || // import *
|
||||
token === SyntaxKind.OpenBraceToken) { // import {
|
||||
importDeclaration.importClause = parseImportClause(identifier, afterImportPos);
|
||||
parseExpected(SyntaxKind.FromKeyword);
|
||||
}
|
||||
|
||||
importDeclaration.moduleSpecifier = parseModuleSpecifier();
|
||||
parseSemicolon();
|
||||
return finishNode(node);
|
||||
return finishNode(importDeclaration);
|
||||
}
|
||||
|
||||
function parseImportClause(identifier: Identifier, fullStart: number) {
|
||||
//ImportClause:
|
||||
// ImportedDefaultBinding
|
||||
// NameSpaceImport
|
||||
// NamedImports
|
||||
// ImportedDefaultBinding, NameSpaceImport
|
||||
// ImportedDefaultBinding, NamedImports
|
||||
|
||||
var importClause = <ImportClause>createNode(SyntaxKind.ImportClause, fullStart);
|
||||
if (identifier) {
|
||||
// ImportedDefaultBinding:
|
||||
// ImportedBinding
|
||||
importClause.name = identifier;
|
||||
}
|
||||
|
||||
// If there was no default import or if there is comma token after default import
|
||||
// parse namespace or named imports
|
||||
if (!importClause.name ||
|
||||
parseOptional(SyntaxKind.CommaToken)) {
|
||||
importClause.namedBindings = token === SyntaxKind.AsteriskToken ? parseNamespaceImport() : parseNamedImportsOrExports(SyntaxKind.NamedImports);
|
||||
}
|
||||
|
||||
return finishNode(importClause);
|
||||
}
|
||||
|
||||
function parseModuleReference() {
|
||||
@@ -4609,19 +4729,102 @@ module ts {
|
||||
var node = <ExternalModuleReference>createNode(SyntaxKind.ExternalModuleReference);
|
||||
parseExpected(SyntaxKind.RequireKeyword);
|
||||
parseExpected(SyntaxKind.OpenParenToken);
|
||||
node.expression = parseModuleSpecifier();
|
||||
parseExpected(SyntaxKind.CloseParenToken);
|
||||
return finishNode(node);
|
||||
}
|
||||
|
||||
function parseModuleSpecifier(): Expression {
|
||||
// We allow arbitrary expressions here, even though the grammar only allows string
|
||||
// literals. We check to ensure that it is only a string literal later in the grammar
|
||||
// walker.
|
||||
node.expression = parseExpression();
|
||||
|
||||
var result = parseExpression();
|
||||
// Ensure the string being required is in our 'identifier' table. This will ensure
|
||||
// that features like 'find refs' will look inside this file when search for its name.
|
||||
if (node.expression.kind === SyntaxKind.StringLiteral) {
|
||||
internIdentifier((<LiteralExpression>node.expression).text);
|
||||
if (result.kind === SyntaxKind.StringLiteral) {
|
||||
internIdentifier((<LiteralExpression>result).text);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
function parseNamespaceImport(): NamespaceImport {
|
||||
// NameSpaceImport:
|
||||
// * as ImportedBinding
|
||||
var namespaceImport = <NamespaceImport>createNode(SyntaxKind.NamespaceImport);
|
||||
parseExpected(SyntaxKind.AsteriskToken);
|
||||
parseExpected(SyntaxKind.AsKeyword);
|
||||
namespaceImport.name = parseIdentifier();
|
||||
return finishNode(namespaceImport);
|
||||
}
|
||||
|
||||
function parseNamedImportsOrExports(kind: SyntaxKind): NamedImportsOrExports {
|
||||
var node = <NamedImports>createNode(kind);
|
||||
|
||||
// NamedImports:
|
||||
// { }
|
||||
// { ImportsList }
|
||||
// { ImportsList, }
|
||||
|
||||
// ImportsList:
|
||||
// ImportSpecifier
|
||||
// ImportsList, ImportSpecifier
|
||||
node.elements = parseBracketedList(ParsingContext.ImportOrExportSpecifiers,
|
||||
kind === SyntaxKind.NamedImports ? parseImportSpecifier : parseExportSpecifier,
|
||||
SyntaxKind.OpenBraceToken, SyntaxKind.CloseBraceToken);
|
||||
return finishNode(node);
|
||||
}
|
||||
|
||||
function parseExportSpecifier() {
|
||||
return parseImportOrExportSpecifier(SyntaxKind.ExportSpecifier);
|
||||
}
|
||||
|
||||
function parseImportSpecifier() {
|
||||
return parseImportOrExportSpecifier(SyntaxKind.ImportSpecifier);
|
||||
}
|
||||
|
||||
function parseImportOrExportSpecifier(kind: SyntaxKind): ImportOrExportSpecifier {
|
||||
var node = <ImportSpecifier>createNode(kind);
|
||||
// ImportSpecifier:
|
||||
// ImportedBinding
|
||||
// IdentifierName as ImportedBinding
|
||||
var isFirstIdentifierNameNotAnIdentifier = isKeyword(token) && !isIdentifier();
|
||||
var start = scanner.getTokenPos();
|
||||
var identifierName = parseIdentifierName();
|
||||
if (token === SyntaxKind.AsKeyword) {
|
||||
node.propertyName = identifierName;
|
||||
parseExpected(SyntaxKind.AsKeyword);
|
||||
if (isIdentifier()) {
|
||||
node.name = parseIdentifierName();
|
||||
}
|
||||
else {
|
||||
parseErrorAtCurrentToken(Diagnostics.Identifier_expected);
|
||||
}
|
||||
}
|
||||
else {
|
||||
node.name = identifierName;
|
||||
if (isFirstIdentifierNameNotAnIdentifier) {
|
||||
// Report error identifier expected
|
||||
parseErrorAtPosition(start, identifierName.end - start, Diagnostics.Identifier_expected);
|
||||
}
|
||||
}
|
||||
|
||||
parseExpected(SyntaxKind.CloseParenToken);
|
||||
return finishNode(node);
|
||||
}
|
||||
|
||||
function parseExportDeclaration(fullStart: number, modifiers: ModifiersArray): ExportDeclaration {
|
||||
var node = <ExportDeclaration>createNode(SyntaxKind.ExportDeclaration, fullStart);
|
||||
setModifiers(node, modifiers);
|
||||
if (parseOptional(SyntaxKind.AsteriskToken)) {
|
||||
parseExpected(SyntaxKind.FromKeyword);
|
||||
node.moduleSpecifier = parseModuleSpecifier();
|
||||
}
|
||||
else {
|
||||
node.exportClause = parseNamedImportsOrExports(SyntaxKind.NamedExports);
|
||||
if (parseOptional(SyntaxKind.FromKeyword)) {
|
||||
node.moduleSpecifier = parseModuleSpecifier();
|
||||
}
|
||||
}
|
||||
parseSemicolon();
|
||||
return finishNode(node);
|
||||
}
|
||||
|
||||
@@ -4650,16 +4853,18 @@ module ts {
|
||||
case SyntaxKind.ClassKeyword:
|
||||
case SyntaxKind.InterfaceKeyword:
|
||||
case SyntaxKind.EnumKeyword:
|
||||
case SyntaxKind.ImportKeyword:
|
||||
case SyntaxKind.TypeKeyword:
|
||||
// Not true keywords so ensure an identifier follows
|
||||
return lookAhead(nextTokenIsIdentifierOrKeyword);
|
||||
case SyntaxKind.ImportKeyword:
|
||||
// Not true keywords so ensure an identifier follows or is string literal or asterisk or open brace
|
||||
return lookAhead(nextTokenCanFollowImportKeyword);
|
||||
case SyntaxKind.ModuleKeyword:
|
||||
// Not a true keyword so ensure an identifier or string literal follows
|
||||
return lookAhead(nextTokenIsIdentifierOrKeywordOrStringLiteral);
|
||||
case SyntaxKind.ExportKeyword:
|
||||
// Check for export assignment or modifier on source element
|
||||
return lookAhead(nextTokenIsEqualsTokenOrDeclarationStart);
|
||||
return lookAhead(nextTokenCanFollowExportKeyword);
|
||||
case SyntaxKind.DeclareKeyword:
|
||||
case SyntaxKind.PublicKeyword:
|
||||
case SyntaxKind.PrivateKeyword:
|
||||
@@ -4684,9 +4889,16 @@ module ts {
|
||||
return isIdentifierOrKeyword() || token === SyntaxKind.StringLiteral;
|
||||
}
|
||||
|
||||
function nextTokenIsEqualsTokenOrDeclarationStart() {
|
||||
function nextTokenCanFollowImportKeyword() {
|
||||
nextToken();
|
||||
return token === SyntaxKind.EqualsToken || isDeclarationStart();
|
||||
return isIdentifierOrKeyword() || token === SyntaxKind.StringLiteral ||
|
||||
token === SyntaxKind.AsteriskToken || token === SyntaxKind.OpenBraceToken;
|
||||
}
|
||||
|
||||
function nextTokenCanFollowExportKeyword() {
|
||||
nextToken();
|
||||
return token === SyntaxKind.EqualsToken || token === SyntaxKind.AsteriskToken ||
|
||||
token === SyntaxKind.OpenBraceToken || isDeclarationStart();
|
||||
}
|
||||
|
||||
function nextTokenIsDeclarationStart() {
|
||||
@@ -4694,6 +4906,10 @@ module ts {
|
||||
return isDeclarationStart();
|
||||
}
|
||||
|
||||
function nextTokenIsAsKeyword() {
|
||||
return nextToken() === SyntaxKind.AsKeyword;
|
||||
}
|
||||
|
||||
function parseDeclaration(): ModuleElement {
|
||||
var fullStart = getNodePos();
|
||||
var modifiers = parseModifiers();
|
||||
@@ -4702,6 +4918,9 @@ module ts {
|
||||
if (parseOptional(SyntaxKind.EqualsToken)) {
|
||||
return parseExportAssignmentTail(fullStart, modifiers);
|
||||
}
|
||||
if (token === SyntaxKind.AsteriskToken || token === SyntaxKind.OpenBraceToken) {
|
||||
return parseExportDeclaration(fullStart, modifiers);
|
||||
}
|
||||
}
|
||||
|
||||
switch (token) {
|
||||
@@ -4722,7 +4941,7 @@ module ts {
|
||||
case SyntaxKind.ModuleKeyword:
|
||||
return parseModuleDeclaration(fullStart, modifiers);
|
||||
case SyntaxKind.ImportKeyword:
|
||||
return parseImportDeclaration(fullStart, modifiers);
|
||||
return parseImportDeclarationOrImportEqualsDeclaration(fullStart, modifiers);
|
||||
default:
|
||||
Debug.fail("Mismatch between isDeclarationStart and parseDeclaration");
|
||||
}
|
||||
@@ -4812,8 +5031,10 @@ module ts {
|
||||
function setExternalModuleIndicator(sourceFile: SourceFile) {
|
||||
sourceFile.externalModuleIndicator = forEach(sourceFile.statements, node =>
|
||||
node.flags & NodeFlags.Export
|
||||
|| node.kind === SyntaxKind.ImportDeclaration && (<ImportDeclaration>node).moduleReference.kind === SyntaxKind.ExternalModuleReference
|
||||
|| node.kind === SyntaxKind.ImportEqualsDeclaration && (<ImportEqualsDeclaration>node).moduleReference.kind === SyntaxKind.ExternalModuleReference
|
||||
|| node.kind === SyntaxKind.ImportDeclaration
|
||||
|| node.kind === SyntaxKind.ExportAssignment
|
||||
|| node.kind === SyntaxKind.ExportDeclaration
|
||||
? node
|
||||
: undefined);
|
||||
}
|
||||
|
||||
+20
-21
@@ -351,24 +351,23 @@ module ts {
|
||||
|
||||
function processImportedModules(file: SourceFile, basePath: string) {
|
||||
forEach(file.statements, node => {
|
||||
if (isExternalModuleImportDeclaration(node) &&
|
||||
getExternalModuleImportDeclarationExpression(node).kind === SyntaxKind.StringLiteral) {
|
||||
|
||||
var nameLiteral = <LiteralExpression>getExternalModuleImportDeclarationExpression(node);
|
||||
var moduleName = nameLiteral.text;
|
||||
if (moduleName) {
|
||||
var searchPath = basePath;
|
||||
while (true) {
|
||||
var searchName = normalizePath(combinePaths(searchPath, moduleName));
|
||||
if (findModuleSourceFile(searchName + ".ts", nameLiteral) || findModuleSourceFile(searchName + ".d.ts", nameLiteral)) {
|
||||
break;
|
||||
if (node.kind === SyntaxKind.ImportDeclaration || node.kind === SyntaxKind.ImportEqualsDeclaration || node.kind === SyntaxKind.ExportDeclaration) {
|
||||
var moduleNameExpr = getExternalModuleName(node);
|
||||
if (moduleNameExpr && moduleNameExpr.kind === SyntaxKind.StringLiteral) {
|
||||
var moduleNameText = (<LiteralExpression>moduleNameExpr).text;
|
||||
if (moduleNameText) {
|
||||
var searchPath = basePath;
|
||||
while (true) {
|
||||
var searchName = normalizePath(combinePaths(searchPath, moduleNameText));
|
||||
if (findModuleSourceFile(searchName + ".ts", moduleNameExpr) || findModuleSourceFile(searchName + ".d.ts", moduleNameExpr)) {
|
||||
break;
|
||||
}
|
||||
var parentPath = getDirectoryPath(searchPath);
|
||||
if (parentPath === searchPath) {
|
||||
break;
|
||||
}
|
||||
searchPath = parentPath;
|
||||
}
|
||||
|
||||
var parentPath = getDirectoryPath(searchPath);
|
||||
if (parentPath === searchPath) {
|
||||
break;
|
||||
}
|
||||
searchPath = parentPath;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -379,10 +378,10 @@ module ts {
|
||||
// The StringLiteral must specify a top - level external module name.
|
||||
// Relative external module names are not permitted
|
||||
forEachChild((<ModuleDeclaration>node).body, node => {
|
||||
if (isExternalModuleImportDeclaration(node) &&
|
||||
getExternalModuleImportDeclarationExpression(node).kind === SyntaxKind.StringLiteral) {
|
||||
if (isExternalModuleImportEqualsDeclaration(node) &&
|
||||
getExternalModuleImportEqualsDeclarationExpression(node).kind === SyntaxKind.StringLiteral) {
|
||||
|
||||
var nameLiteral = <LiteralExpression>getExternalModuleImportDeclarationExpression(node);
|
||||
var nameLiteral = <LiteralExpression>getExternalModuleImportEqualsDeclarationExpression(node);
|
||||
var moduleName = nameLiteral.text;
|
||||
if (moduleName) {
|
||||
// TypeScript 1.0 spec (April 2014): 12.1.6
|
||||
@@ -399,7 +398,7 @@ module ts {
|
||||
}
|
||||
});
|
||||
|
||||
function findModuleSourceFile(fileName: string, nameLiteral: LiteralExpression) {
|
||||
function findModuleSourceFile(fileName: string, nameLiteral: Expression) {
|
||||
return findSourceFile(fileName, /* isDefaultLib */ false, file, nameLiteral.pos, nameLiteral.end - nameLiteral.pos);
|
||||
}
|
||||
}
|
||||
|
||||
+13
-9
@@ -38,6 +38,7 @@ module ts {
|
||||
|
||||
var textToToken: Map<SyntaxKind> = {
|
||||
"any": SyntaxKind.AnyKeyword,
|
||||
"as": SyntaxKind.AsKeyword,
|
||||
"boolean": SyntaxKind.BooleanKeyword,
|
||||
"break": SyntaxKind.BreakKeyword,
|
||||
"case": SyntaxKind.CaseKeyword,
|
||||
@@ -58,6 +59,7 @@ module ts {
|
||||
"false": SyntaxKind.FalseKeyword,
|
||||
"finally": SyntaxKind.FinallyKeyword,
|
||||
"for": SyntaxKind.ForKeyword,
|
||||
"from": SyntaxKind.FromKeyword,
|
||||
"function": SyntaxKind.FunctionKeyword,
|
||||
"get": SyntaxKind.GetKeyword,
|
||||
"if": SyntaxKind.IfKeyword,
|
||||
@@ -82,6 +84,7 @@ module ts {
|
||||
"string": SyntaxKind.StringKeyword,
|
||||
"super": SyntaxKind.SuperKeyword,
|
||||
"switch": SyntaxKind.SwitchKeyword,
|
||||
"symbol": SyntaxKind.SymbolKeyword,
|
||||
"this": SyntaxKind.ThisKeyword,
|
||||
"throw": SyntaxKind.ThrowKeyword,
|
||||
"true": SyntaxKind.TrueKeyword,
|
||||
@@ -93,6 +96,7 @@ module ts {
|
||||
"while": SyntaxKind.WhileKeyword,
|
||||
"with": SyntaxKind.WithKeyword,
|
||||
"yield": SyntaxKind.YieldKeyword,
|
||||
"of": SyntaxKind.OfKeyword,
|
||||
"{": SyntaxKind.OpenBraceToken,
|
||||
"}": SyntaxKind.CloseBraceToken,
|
||||
"(": SyntaxKind.OpenParenToken,
|
||||
@@ -223,7 +227,7 @@ module ts {
|
||||
return false;
|
||||
}
|
||||
|
||||
function isUnicodeIdentifierStart(code: number, languageVersion: ScriptTarget) {
|
||||
/* @internal */ export function isUnicodeIdentifierStart(code: number, languageVersion: ScriptTarget) {
|
||||
return languageVersion >= ScriptTarget.ES5 ?
|
||||
lookupInUnicodeMap(code, unicodeES5IdentifierStart) :
|
||||
lookupInUnicodeMap(code, unicodeES3IdentifierStart);
|
||||
@@ -278,13 +282,13 @@ module ts {
|
||||
return result;
|
||||
}
|
||||
|
||||
export function getPositionFromLineAndCharacter(sourceFile: SourceFile, line: number, character: number): number {
|
||||
return computePositionFromLineAndCharacter(getLineStarts(sourceFile), line, character);
|
||||
export function getPositionOfLineAndCharacter(sourceFile: SourceFile, line: number, character: number): number {
|
||||
return computePositionOfLineAndCharacter(getLineStarts(sourceFile), line, character);
|
||||
}
|
||||
|
||||
export function computePositionFromLineAndCharacter(lineStarts: number[], line: number, character: number): number {
|
||||
Debug.assert(line > 0 && line <= lineStarts.length);
|
||||
return lineStarts[line - 1] + character - 1;
|
||||
export function computePositionOfLineAndCharacter(lineStarts: number[], line: number, character: number): number {
|
||||
Debug.assert(line >= 0 && line < lineStarts.length);
|
||||
return lineStarts[line] + character;
|
||||
}
|
||||
|
||||
export function getLineStarts(sourceFile: SourceFile): number[] {
|
||||
@@ -298,11 +302,11 @@ module ts {
|
||||
// the binary search returns the negative value of the next line start
|
||||
// e.g. if the line starts at [5, 10, 23, 80] and the position requested was 20
|
||||
// then the search will return -2
|
||||
lineNumber = (~lineNumber) - 1;
|
||||
lineNumber = ~lineNumber - 1;
|
||||
}
|
||||
return {
|
||||
line: lineNumber + 1,
|
||||
character: position - lineStarts[lineNumber] + 1
|
||||
line: lineNumber,
|
||||
character: position - lineStarts[lineNumber]
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
+3
-3
@@ -72,7 +72,7 @@ module ts {
|
||||
function countLines(program: Program): number {
|
||||
var count = 0;
|
||||
forEach(program.getSourceFiles(), file => {
|
||||
count += getLineAndCharacterOfPosition(file, file.end).line;
|
||||
count += getLineStarts(file).length;
|
||||
});
|
||||
return count;
|
||||
}
|
||||
@@ -88,11 +88,11 @@ module ts {
|
||||
if (diagnostic.file) {
|
||||
var loc = getLineAndCharacterOfPosition(diagnostic.file, diagnostic.start);
|
||||
|
||||
output += diagnostic.file.fileName + "(" + loc.line + "," + loc.character + "): ";
|
||||
output += `${ diagnostic.file.fileName }(${ loc.line + 1 },${ loc.character + 1 }): `;
|
||||
}
|
||||
|
||||
var category = DiagnosticCategory[diagnostic.category].toLowerCase();
|
||||
output += category + " TS" + diagnostic.code + ": " + flattenDiagnosticMessageText(diagnostic.messageText, sys.newLine) + sys.newLine;
|
||||
output += `${ category } TS${ diagnostic.code }: ${ flattenDiagnosticMessageText(diagnostic.messageText, sys.newLine) }${ sys.newLine }`;
|
||||
|
||||
sys.write(output);
|
||||
}
|
||||
|
||||
+96
-25
@@ -120,6 +120,8 @@ module ts {
|
||||
WhileKeyword,
|
||||
WithKeyword,
|
||||
// Strict mode reserved words
|
||||
AsKeyword,
|
||||
FromKeyword,
|
||||
ImplementsKeyword,
|
||||
InterfaceKeyword,
|
||||
LetKeyword,
|
||||
@@ -140,8 +142,9 @@ module ts {
|
||||
NumberKeyword,
|
||||
SetKeyword,
|
||||
StringKeyword,
|
||||
SymbolKeyword,
|
||||
TypeKeyword,
|
||||
|
||||
OfKeyword, // LastKeyword and LastToken
|
||||
// Parse tree nodes
|
||||
|
||||
// Names
|
||||
@@ -210,6 +213,7 @@ module ts {
|
||||
WhileStatement,
|
||||
ForStatement,
|
||||
ForInStatement,
|
||||
ForOfStatement,
|
||||
ContinueStatement,
|
||||
BreakStatement,
|
||||
ReturnStatement,
|
||||
@@ -228,8 +232,16 @@ module ts {
|
||||
EnumDeclaration,
|
||||
ModuleDeclaration,
|
||||
ModuleBlock,
|
||||
ImportEqualsDeclaration,
|
||||
ImportDeclaration,
|
||||
ImportClause,
|
||||
NamespaceImport,
|
||||
NamedImports,
|
||||
ImportSpecifier,
|
||||
ExportAssignment,
|
||||
ExportDeclaration,
|
||||
NamedExports,
|
||||
ExportSpecifier,
|
||||
|
||||
// Module references
|
||||
ExternalModuleReference,
|
||||
@@ -259,7 +271,7 @@ module ts {
|
||||
FirstReservedWord = BreakKeyword,
|
||||
LastReservedWord = WithKeyword,
|
||||
FirstKeyword = BreakKeyword,
|
||||
LastKeyword = TypeKeyword,
|
||||
LastKeyword = OfKeyword,
|
||||
FirstFutureReservedWord = ImplementsKeyword,
|
||||
LastFutureReservedWord = YieldKeyword,
|
||||
FirstTypeNode = TypeReference,
|
||||
@@ -267,7 +279,7 @@ module ts {
|
||||
FirstPunctuation = OpenBraceToken,
|
||||
LastPunctuation = CaretEqualsToken,
|
||||
FirstToken = Unknown,
|
||||
LastToken = TypeKeyword,
|
||||
LastToken = OfKeyword,
|
||||
FirstTriviaToken = SingleLineCommentTrivia,
|
||||
LastTriviaToken = ConflictMarkerTrivia,
|
||||
FirstLiteralToken = NumericLiteral,
|
||||
@@ -342,13 +354,13 @@ module ts {
|
||||
// Specific context the parser was in when this node was created. Normally undefined.
|
||||
// Only set when the parser was in some interesting context (like async/yield).
|
||||
parserContextFlags?: ParserContextFlags;
|
||||
modifiers?: ModifiersArray; // Array of modifiers
|
||||
id?: number; // Unique id (used to look up NodeLinks)
|
||||
parent?: Node; // Parent node (initialized by binding)
|
||||
symbol?: Symbol; // Symbol declared by node (initialized by binding)
|
||||
locals?: SymbolTable; // Locals associated with node (initialized by binding)
|
||||
nextContainer?: Node; // Next container in declaration order (initialized by binding)
|
||||
localSymbol?: Symbol; // Local symbol declared by node (initialized by binding only for exported nodes)
|
||||
modifiers?: ModifiersArray; // Array of modifiers
|
||||
}
|
||||
|
||||
export interface NodeArray<T> extends Array<T>, TextRange {
|
||||
@@ -621,7 +633,7 @@ module ts {
|
||||
|
||||
export interface BinaryExpression extends Expression {
|
||||
left: Expression;
|
||||
operator: SyntaxKind;
|
||||
operatorToken: Node;
|
||||
right: Expression;
|
||||
}
|
||||
|
||||
@@ -752,6 +764,11 @@ module ts {
|
||||
expression: Expression;
|
||||
}
|
||||
|
||||
export interface ForOfStatement extends IterationStatement {
|
||||
initializer: VariableDeclarationList | Expression;
|
||||
expression: Expression;
|
||||
}
|
||||
|
||||
export interface BreakOrContinueStatement extends Statement {
|
||||
label?: Identifier;
|
||||
}
|
||||
@@ -846,7 +863,11 @@ module ts {
|
||||
members: NodeArray<EnumMember>;
|
||||
}
|
||||
|
||||
export interface ModuleDeclaration extends Declaration, ModuleElement {
|
||||
export interface ExportContainer {
|
||||
exportStars?: ExportDeclaration[]; // List of 'export *' statements (initialized by binding)
|
||||
}
|
||||
|
||||
export interface ModuleDeclaration extends Declaration, ModuleElement, ExportContainer {
|
||||
name: Identifier | LiteralExpression;
|
||||
body: ModuleBlock | ModuleDeclaration;
|
||||
}
|
||||
@@ -855,7 +876,7 @@ module ts {
|
||||
statements: NodeArray<ModuleElement>
|
||||
}
|
||||
|
||||
export interface ImportDeclaration extends Declaration, ModuleElement {
|
||||
export interface ImportEqualsDeclaration extends Declaration, ModuleElement {
|
||||
name: Identifier;
|
||||
|
||||
// 'EntityName' for an internal module reference, 'ExternalModuleReference' for an external
|
||||
@@ -867,6 +888,50 @@ module ts {
|
||||
expression?: Expression;
|
||||
}
|
||||
|
||||
// In case of:
|
||||
// import "mod" => importClause = undefined, moduleSpecifier = "mod"
|
||||
// In rest of the cases, module specifier is string literal corresponding to module
|
||||
// ImportClause information is shown at its declaration below.
|
||||
export interface ImportDeclaration extends Statement, ModuleElement {
|
||||
importClause?: ImportClause;
|
||||
moduleSpecifier: Expression;
|
||||
}
|
||||
|
||||
// In case of:
|
||||
// import d from "mod" => name = d, namedBinding = undefined
|
||||
// import * as ns from "mod" => name = undefined, namedBinding: NamespaceImport = { name: ns }
|
||||
// import d, * as ns from "mod" => name = d, namedBinding: NamespaceImport = { name: ns }
|
||||
// import { a, b as x } from "mod" => name = undefined, namedBinding: NamedImports = { elements: [{ name: a }, { name: x, propertyName: b}]}
|
||||
// import d, { a, b as x } from "mod" => name = d, namedBinding: NamedImports = { elements: [{ name: a }, { name: x, propertyName: b}]}
|
||||
export interface ImportClause extends Declaration {
|
||||
name?: Identifier; // Default binding
|
||||
namedBindings?: NamespaceImport | NamedImports;
|
||||
}
|
||||
|
||||
export interface NamespaceImport extends Declaration {
|
||||
name: Identifier;
|
||||
}
|
||||
|
||||
export interface ExportDeclaration extends Statement, ModuleElement {
|
||||
exportClause?: NamedExports;
|
||||
moduleSpecifier?: Expression;
|
||||
}
|
||||
|
||||
export interface NamedImportsOrExports extends Node {
|
||||
elements: NodeArray<ImportOrExportSpecifier>;
|
||||
}
|
||||
|
||||
export type NamedImports = NamedImportsOrExports;
|
||||
export type NamedExports = NamedImportsOrExports;
|
||||
|
||||
export interface ImportOrExportSpecifier extends Declaration {
|
||||
propertyName?: Identifier; // Name preceding "as" keyword (or undefined when "as" is absent)
|
||||
name: Identifier; // Declared name
|
||||
}
|
||||
|
||||
export type ImportSpecifier = ImportOrExportSpecifier;
|
||||
export type ExportSpecifier = ImportOrExportSpecifier;
|
||||
|
||||
export interface ExportAssignment extends Statement, ModuleElement {
|
||||
exportName: Identifier;
|
||||
}
|
||||
@@ -880,7 +945,7 @@ module ts {
|
||||
}
|
||||
|
||||
// Source files are declarations when they are external modules.
|
||||
export interface SourceFile extends Declaration {
|
||||
export interface SourceFile extends Declaration, ExportContainer {
|
||||
statements: NodeArray<ModuleElement>;
|
||||
endOfFileToken: Node;
|
||||
|
||||
@@ -1035,6 +1100,7 @@ module ts {
|
||||
getConstantValue(node: EnumMember | PropertyAccessExpression | ElementAccessExpression): number;
|
||||
isValidPropertyAccess(node: PropertyAccessExpression | QualifiedName, propertyName: string): boolean;
|
||||
getAliasedSymbol(symbol: Symbol): Symbol;
|
||||
getExportsOfExternalModule(node: ImportDeclaration): Symbol[];
|
||||
|
||||
// Should not be called directly. Should only be accessed through the Program instance.
|
||||
/* @internal */ getDiagnostics(sourceFile?: SourceFile): Diagnostic[];
|
||||
@@ -1113,7 +1179,7 @@ module ts {
|
||||
|
||||
export interface SymbolVisibilityResult {
|
||||
accessibility: SymbolAccessibility;
|
||||
aliasesToMakeVisible?: ImportDeclaration[]; // aliases that need to have this symbol visible
|
||||
aliasesToMakeVisible?: ImportEqualsDeclaration[]; // aliases that need to have this symbol visible
|
||||
errorSymbolName?: string; // Optional symbol name that results in error
|
||||
errorNode?: Node; // optional node that results in error
|
||||
}
|
||||
@@ -1123,11 +1189,11 @@ module ts {
|
||||
}
|
||||
|
||||
export interface EmitResolver {
|
||||
getLocalNameOfContainer(container: ModuleDeclaration | EnumDeclaration): string;
|
||||
getExpressionNamePrefix(node: Identifier): string;
|
||||
getGeneratedNameForNode(node: ModuleDeclaration | EnumDeclaration | ImportDeclaration | ExportDeclaration): string;
|
||||
getExpressionNameSubstitution(node: Identifier): string;
|
||||
getExportAssignmentName(node: SourceFile): string;
|
||||
isReferencedImportDeclaration(node: ImportDeclaration): boolean;
|
||||
isTopLevelValueImportWithEntityName(node: ImportDeclaration): boolean;
|
||||
isReferencedImportDeclaration(node: Node): boolean;
|
||||
isTopLevelValueImportEqualsWithEntityName(node: ImportEqualsDeclaration): boolean;
|
||||
getNodeCheckFlags(node: Node): NodeCheckFlags;
|
||||
isDeclarationVisible(node: Declaration): boolean;
|
||||
isImplementationOfOverload(node: FunctionLikeDeclaration): boolean;
|
||||
@@ -1231,18 +1297,20 @@ module ts {
|
||||
members?: SymbolTable; // Class, interface or literal instance members
|
||||
exports?: SymbolTable; // Module exports
|
||||
exportSymbol?: Symbol; // Exported symbol associated with this symbol
|
||||
valueDeclaration?: Declaration // First value declaration of the symbol,
|
||||
constEnumOnlyModule?: boolean // For modules - if true - module contains only const enums or other modules with only const enums.
|
||||
valueDeclaration?: Declaration // First value declaration of the symbol
|
||||
constEnumOnlyModule?: boolean // True if module contains only const enums or other modules with only const enums
|
||||
}
|
||||
|
||||
export interface SymbolLinks {
|
||||
target?: Symbol; // Resolved (non-alias) target of an alias
|
||||
type?: Type; // Type of value symbol
|
||||
declaredType?: Type; // Type of class, interface, enum, or type parameter
|
||||
mapper?: TypeMapper; // Type mapper for instantiation alias
|
||||
referenced?: boolean; // True if alias symbol has been referenced as a value
|
||||
exportAssignSymbol?: Symbol; // Symbol exported from external module
|
||||
unionType?: UnionType; // Containing union type for union property
|
||||
target?: Symbol; // Resolved (non-alias) target of an alias
|
||||
type?: Type; // Type of value symbol
|
||||
declaredType?: Type; // Type of class, interface, enum, or type parameter
|
||||
mapper?: TypeMapper; // Type mapper for instantiation alias
|
||||
referenced?: boolean; // True if alias symbol has been referenced as a value
|
||||
exportAssignmentChecked?: boolean; // True if export assignment was checked
|
||||
exportAssignmentSymbol?: Symbol; // Symbol exported from external module
|
||||
unionType?: UnionType; // Containing union type for union property
|
||||
resolvedExports?: SymbolTable; // Resolved exports of module
|
||||
}
|
||||
|
||||
export interface TransientSymbol extends Symbol, SymbolLinks { }
|
||||
@@ -1273,7 +1341,8 @@ module ts {
|
||||
enumMemberValue?: number; // Constant value of enum member
|
||||
isIllegalTypeReferenceInConstraint?: boolean; // Is type reference in constraint refers to the type parameter from the same list
|
||||
isVisible?: boolean; // Is this node visible
|
||||
localModuleName?: string; // Local name for module instance
|
||||
generatedName?: string; // Generated name for module, enum, or import declaration
|
||||
generatedNames?: Map<string>; // Generated names table for source file
|
||||
assignmentChecks?: Map<boolean>; // Cache of assignment checks
|
||||
hasReportedStatementInAmbientContext?: boolean; // Cache boolean if we report statements in ambient context
|
||||
importOnRightSide?: Symbol; // for import declarations - import that appear on the right side
|
||||
@@ -1300,9 +1369,10 @@ module ts {
|
||||
ObjectLiteral = 0x00020000, // Originates in an object literal
|
||||
ContainsUndefinedOrNull = 0x00040000, // Type is or contains Undefined or Null type
|
||||
ContainsObjectLiteral = 0x00080000, // Type is or contains object literal type
|
||||
ESSymbol = 0x00100000, // Type of symbol primitive introduced in ES6
|
||||
|
||||
Intrinsic = Any | String | Number | Boolean | Void | Undefined | Null,
|
||||
Primitive = String | Number | Boolean | Void | Undefined | Null | StringLiteral | Enum,
|
||||
Intrinsic = Any | String | Number | Boolean | ESSymbol | Void | Undefined | Null,
|
||||
Primitive = String | Number | Boolean | ESSymbol | Void | Undefined | Null | StringLiteral | Enum,
|
||||
StringLike = String | StringLiteral,
|
||||
NumberLike = Number | Enum,
|
||||
ObjectType = Class | Interface | Reference | Tuple | Anonymous,
|
||||
@@ -1640,6 +1710,7 @@ module ts {
|
||||
equals = 0x3D, // =
|
||||
exclamation = 0x21, // !
|
||||
greaterThan = 0x3E, // >
|
||||
hash = 0x23, // #
|
||||
lessThan = 0x3C, // <
|
||||
minus = 0x2D, // -
|
||||
openBrace = 0x7B, // {
|
||||
|
||||
+96
-39
@@ -105,11 +105,16 @@ module ts {
|
||||
return <SourceFile>node;
|
||||
}
|
||||
|
||||
export function getStartPositionOfLine(line: number, sourceFile: SourceFile): number {
|
||||
Debug.assert(line >= 0);
|
||||
return getLineStarts(sourceFile)[line];
|
||||
}
|
||||
|
||||
// This is a useful function for debugging purposes.
|
||||
export function nodePosToString(node: Node): string {
|
||||
var file = getSourceFileOfNode(node);
|
||||
var loc = getLineAndCharacterOfPosition(file, node.pos);
|
||||
return file.fileName + "(" + loc.line + "," + loc.character + ")";
|
||||
return `${ file.fileName }(${ loc.line + 1 },${ loc.character + 1 })`;
|
||||
}
|
||||
|
||||
export function getStartPosOfNode(node: Node): number {
|
||||
@@ -181,6 +186,12 @@ module ts {
|
||||
return identifier.length >= 3 && identifier.charCodeAt(0) === CharacterCodes._ && identifier.charCodeAt(1) === CharacterCodes._ && identifier.charCodeAt(2) === CharacterCodes._ ? identifier.substr(1) : identifier;
|
||||
}
|
||||
|
||||
// Make an identifier from an external module name by extracting the string after the last "/" and replacing
|
||||
// all non-alphanumeric characters with underscores
|
||||
export function makeIdentifierFromModuleName(moduleName: string): string {
|
||||
return getBaseFileName(moduleName).replace(/\W/g, "_");
|
||||
}
|
||||
|
||||
// Return display name of an identifier
|
||||
// Computed property names will just be emitted as "[<expr>]", where <expr> is the source
|
||||
// text of the expression in the computed property.
|
||||
@@ -343,6 +354,7 @@ module ts {
|
||||
case SyntaxKind.WhileStatement:
|
||||
case SyntaxKind.ForStatement:
|
||||
case SyntaxKind.ForInStatement:
|
||||
case SyntaxKind.ForOfStatement:
|
||||
case SyntaxKind.WithStatement:
|
||||
case SyntaxKind.SwitchStatement:
|
||||
case SyntaxKind.CaseClause:
|
||||
@@ -560,7 +572,8 @@ module ts {
|
||||
forStatement.condition === node ||
|
||||
forStatement.iterator === node;
|
||||
case SyntaxKind.ForInStatement:
|
||||
var forInStatement = <ForInStatement>parent;
|
||||
case SyntaxKind.ForOfStatement:
|
||||
var forInStatement = <ForInStatement | ForOfStatement>parent;
|
||||
return (forInStatement.initializer === node && forInStatement.initializer.kind !== SyntaxKind.VariableDeclarationList) ||
|
||||
forInStatement.expression === node;
|
||||
case SyntaxKind.TypeAssertionExpression:
|
||||
@@ -584,17 +597,32 @@ module ts {
|
||||
(preserveConstEnums && moduleState === ModuleInstanceState.ConstEnumOnly);
|
||||
}
|
||||
|
||||
export function isExternalModuleImportDeclaration(node: Node) {
|
||||
return node.kind === SyntaxKind.ImportDeclaration && (<ImportDeclaration>node).moduleReference.kind === SyntaxKind.ExternalModuleReference;
|
||||
export function isExternalModuleImportEqualsDeclaration(node: Node) {
|
||||
return node.kind === SyntaxKind.ImportEqualsDeclaration && (<ImportEqualsDeclaration>node).moduleReference.kind === SyntaxKind.ExternalModuleReference;
|
||||
}
|
||||
|
||||
export function getExternalModuleImportDeclarationExpression(node: Node) {
|
||||
Debug.assert(isExternalModuleImportDeclaration(node));
|
||||
return (<ExternalModuleReference>(<ImportDeclaration>node).moduleReference).expression;
|
||||
export function getExternalModuleImportEqualsDeclarationExpression(node: Node) {
|
||||
Debug.assert(isExternalModuleImportEqualsDeclaration(node));
|
||||
return (<ExternalModuleReference>(<ImportEqualsDeclaration>node).moduleReference).expression;
|
||||
}
|
||||
|
||||
export function isInternalModuleImportDeclaration(node: Node) {
|
||||
return node.kind === SyntaxKind.ImportDeclaration && (<ImportDeclaration>node).moduleReference.kind !== SyntaxKind.ExternalModuleReference;
|
||||
export function isInternalModuleImportEqualsDeclaration(node: Node) {
|
||||
return node.kind === SyntaxKind.ImportEqualsDeclaration && (<ImportEqualsDeclaration>node).moduleReference.kind !== SyntaxKind.ExternalModuleReference;
|
||||
}
|
||||
|
||||
export function getExternalModuleName(node: Node): Expression {
|
||||
if (node.kind === SyntaxKind.ImportDeclaration) {
|
||||
return (<ImportDeclaration>node).moduleSpecifier;
|
||||
}
|
||||
if (node.kind === SyntaxKind.ImportEqualsDeclaration) {
|
||||
var reference = (<ImportEqualsDeclaration>node).moduleReference;
|
||||
if (reference.kind === SyntaxKind.ExternalModuleReference) {
|
||||
return (<ExternalModuleReference>reference).expression;
|
||||
}
|
||||
}
|
||||
if (node.kind === SyntaxKind.ExportDeclaration) {
|
||||
return (<ExportDeclaration>node).moduleSpecifier;
|
||||
}
|
||||
}
|
||||
|
||||
export function hasDotDotDotToken(node: Node) {
|
||||
@@ -673,7 +701,11 @@ module ts {
|
||||
case SyntaxKind.TypeAliasDeclaration:
|
||||
case SyntaxKind.EnumDeclaration:
|
||||
case SyntaxKind.ModuleDeclaration:
|
||||
case SyntaxKind.ImportDeclaration:
|
||||
case SyntaxKind.ImportEqualsDeclaration:
|
||||
case SyntaxKind.ImportClause:
|
||||
case SyntaxKind.ImportSpecifier:
|
||||
case SyntaxKind.NamespaceImport:
|
||||
case SyntaxKind.ExportSpecifier:
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -688,6 +720,7 @@ module ts {
|
||||
case SyntaxKind.ExpressionStatement:
|
||||
case SyntaxKind.EmptyStatement:
|
||||
case SyntaxKind.ForInStatement:
|
||||
case SyntaxKind.ForOfStatement:
|
||||
case SyntaxKind.ForStatement:
|
||||
case SyntaxKind.IfStatement:
|
||||
case SyntaxKind.LabeledStatement:
|
||||
@@ -759,36 +792,12 @@ module ts {
|
||||
}
|
||||
|
||||
export function getAncestor(node: Node, kind: SyntaxKind): Node {
|
||||
switch (kind) {
|
||||
// special-cases that can be come first
|
||||
case SyntaxKind.ClassDeclaration:
|
||||
while (node) {
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.ClassDeclaration:
|
||||
return <ClassDeclaration>node;
|
||||
case SyntaxKind.EnumDeclaration:
|
||||
case SyntaxKind.InterfaceDeclaration:
|
||||
case SyntaxKind.TypeAliasDeclaration:
|
||||
case SyntaxKind.ModuleDeclaration:
|
||||
case SyntaxKind.ImportDeclaration:
|
||||
// early exit cases - declarations cannot be nested in classes
|
||||
return undefined;
|
||||
default:
|
||||
node = node.parent;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
while (node) {
|
||||
if (node.kind === kind) {
|
||||
return node;
|
||||
}
|
||||
node = node.parent;
|
||||
}
|
||||
break;
|
||||
while (node) {
|
||||
if (node.kind === kind) {
|
||||
return node;
|
||||
}
|
||||
node = node.parent;
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
@@ -835,6 +844,54 @@ module ts {
|
||||
return SyntaxKind.FirstTriviaToken <= token && token <= SyntaxKind.LastTriviaToken;
|
||||
}
|
||||
|
||||
/**
|
||||
* A declaration has a dynamic name if both of the following are true:
|
||||
* 1. The declaration has a computed property name
|
||||
* 2. The computed name is *not* expressed as Symbol.<name>, where name
|
||||
* is a property of the Symbol constructor that denotes a built in
|
||||
* Symbol.
|
||||
*/
|
||||
export function hasDynamicName(declaration: Declaration): boolean {
|
||||
return declaration.name &&
|
||||
declaration.name.kind === SyntaxKind.ComputedPropertyName &&
|
||||
!isWellKnownSymbolSyntactically((<ComputedPropertyName>declaration.name).expression);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the expression is of the form:
|
||||
* Symbol.name
|
||||
* where Symbol is literally the word "Symbol", and name is any identifierName
|
||||
*/
|
||||
export function isWellKnownSymbolSyntactically(node: Expression): boolean {
|
||||
return node.kind === SyntaxKind.PropertyAccessExpression && isESSymbolIdentifier((<PropertyAccessExpression>node).expression);
|
||||
}
|
||||
|
||||
export function getPropertyNameForPropertyNameNode(name: DeclarationName): string {
|
||||
if (name.kind === SyntaxKind.Identifier || name.kind === SyntaxKind.StringLiteral || name.kind === SyntaxKind.NumericLiteral) {
|
||||
return (<Identifier | LiteralExpression>name).text;
|
||||
}
|
||||
if (name.kind === SyntaxKind.ComputedPropertyName) {
|
||||
var nameExpression = (<ComputedPropertyName>name).expression;
|
||||
if (isWellKnownSymbolSyntactically(nameExpression)) {
|
||||
var rightHandSideName = (<PropertyAccessExpression>nameExpression).name.text;
|
||||
return getPropertyNameForKnownSymbolName(rightHandSideName);
|
||||
}
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
export function getPropertyNameForKnownSymbolName(symbolName: string): string {
|
||||
return "__@" + symbolName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Includes the word "Symbol" with unicode escapes
|
||||
*/
|
||||
export function isESSymbolIdentifier(node: Node): boolean {
|
||||
return node.kind === SyntaxKind.Identifier && (<Identifier>node).text === "Symbol";
|
||||
}
|
||||
|
||||
export function isModifier(token: SyntaxKind): boolean {
|
||||
switch (token) {
|
||||
case SyntaxKind.PublicKeyword:
|
||||
|
||||
+35
-28
@@ -282,6 +282,8 @@ module FourSlash {
|
||||
return new Harness.LanguageService.NativeLanugageServiceAdapter(cancellationToken, compilationOptions);
|
||||
case FourSlashTestType.Shims:
|
||||
return new Harness.LanguageService.ShimLanugageServiceAdapter(cancellationToken, compilationOptions);
|
||||
case FourSlashTestType.Server:
|
||||
return new Harness.LanguageService.ServerLanugageServiceAdapter(cancellationToken, compilationOptions);
|
||||
default:
|
||||
throw new Error("Unknown FourSlash test type: ");
|
||||
}
|
||||
@@ -396,7 +398,7 @@ module FourSlash {
|
||||
|
||||
var lineStarts = ts.computeLineStarts(this.getFileContent(this.activeFile.fileName));
|
||||
var lineCharPos = ts.computeLineAndCharacterOfPosition(lineStarts, pos);
|
||||
this.scenarioActions.push('<MoveCaretToLineAndChar LineNumber="' + lineCharPos.line + '" CharNumber="' + lineCharPos.character + '" />');
|
||||
this.scenarioActions.push(`<MoveCaretToLineAndChar LineNumber=${ lineCharPos.line + 1 } CharNumber=${ lineCharPos.character + 1 } />`);
|
||||
}
|
||||
|
||||
public moveCaretRight(count = 1) {
|
||||
@@ -418,6 +420,9 @@ module FourSlash {
|
||||
this.activeFile = fileToOpen;
|
||||
var fileName = fileToOpen.fileName.replace(Harness.IO.directoryName(fileToOpen.fileName), '').substr(1);
|
||||
this.scenarioActions.push('<OpenFile FileName="" SrcFileId="' + fileName + '" FileId="' + fileName + '" />');
|
||||
|
||||
// Let the host know that this file is now open
|
||||
this.languageServiceAdapterHost.openFile(fileToOpen.fileName);
|
||||
}
|
||||
|
||||
public verifyErrorExistsBetweenMarkers(startMarkerName: string, endMarkerName: string, negative: boolean) {
|
||||
@@ -1475,6 +1480,16 @@ module FourSlash {
|
||||
return runningOffset;
|
||||
}
|
||||
|
||||
public copyFormatOptions(): ts.FormatCodeOptions {
|
||||
return ts.clone(this.formatCodeOptions);
|
||||
}
|
||||
|
||||
public setFormatOptions(formatCodeOptions: ts.FormatCodeOptions): ts.FormatCodeOptions {
|
||||
var oldFormatCodeOptions = this.formatCodeOptions;
|
||||
this.formatCodeOptions = formatCodeOptions;
|
||||
return oldFormatCodeOptions;
|
||||
}
|
||||
|
||||
public formatDocument() {
|
||||
this.scenarioActions.push('<FormatDocument />');
|
||||
|
||||
@@ -1927,7 +1942,7 @@ module FourSlash {
|
||||
}
|
||||
|
||||
var missingItem = { name: name, kind: kind };
|
||||
this.raiseError('verifyGetScriptLexicalStructureListContains failed - could not find the item: ' + JSON.stringify(missingItem) + ' in the returned list: (' + JSON.stringify(items) + ')');
|
||||
this.raiseError('verifyGetScriptLexicalStructureListContains failed - could not find the item: ' + JSON.stringify(missingItem) + ' in the returned list: (' + JSON.stringify(items, null, " ") + ')');
|
||||
}
|
||||
|
||||
private navigationBarItemsContains(items: ts.NavigationBarItem[], name: string, kind: string) {
|
||||
@@ -2010,39 +2025,31 @@ module FourSlash {
|
||||
|
||||
// Get the text of the entire line the caret is currently at
|
||||
private getCurrentLineContent() {
|
||||
// The current caret position (in line/col terms)
|
||||
var line = this.getCurrentCaretFilePosition().line;
|
||||
// The line/col of the start of this line
|
||||
var pos = this.languageServiceAdapterHost.lineColToPosition(this.activeFile.fileName, line, 1);
|
||||
// The index of the current file
|
||||
var text = this.getFileContent(this.activeFile.fileName)
|
||||
|
||||
// The text from the start of the line to the end of the file
|
||||
var text = this.getFileContent(this.activeFile.fileName).substring(pos);
|
||||
var pos = this.currentCaretPosition;
|
||||
var startPos = pos, endPos = pos;
|
||||
|
||||
// Truncate to the first newline
|
||||
var newlinePos = text.indexOf('\n');
|
||||
if (newlinePos === -1) {
|
||||
return text;
|
||||
}
|
||||
else {
|
||||
if (text.charAt(newlinePos - 1) === '\r') {
|
||||
newlinePos--;
|
||||
while (startPos > 0) {
|
||||
var ch = text.charCodeAt(startPos - 1);
|
||||
if (ch === ts.CharacterCodes.carriageReturn || ch === ts.CharacterCodes.lineFeed) {
|
||||
break;
|
||||
}
|
||||
return text.substr(0, newlinePos);
|
||||
}
|
||||
}
|
||||
|
||||
private getCurrentCaretFilePosition() {
|
||||
var result = this.languageServiceAdapterHost.positionToZeroBasedLineCol(this.activeFile.fileName, this.currentCaretPosition);
|
||||
if (result.line >= 0) {
|
||||
result.line++;
|
||||
startPos--;
|
||||
}
|
||||
|
||||
if (result.character >= 0) {
|
||||
result.character++;
|
||||
while (endPos < text.length) {
|
||||
var ch = text.charCodeAt(endPos);
|
||||
|
||||
if (ch === ts.CharacterCodes.carriageReturn || ch === ts.CharacterCodes.lineFeed) {
|
||||
break;
|
||||
}
|
||||
|
||||
endPos++;
|
||||
}
|
||||
|
||||
return result;
|
||||
return text.substring(startPos, endPos);
|
||||
}
|
||||
|
||||
private assertItemInCompletionList(items: ts.CompletionEntry[], name: string, text?: string, documentation?: string, kind?: string) {
|
||||
@@ -2120,7 +2127,7 @@ module FourSlash {
|
||||
}
|
||||
|
||||
private getLineColStringAtPosition(position: number) {
|
||||
var pos = this.languageServiceAdapterHost.positionToZeroBasedLineCol(this.activeFile.fileName, position);
|
||||
var pos = this.languageServiceAdapterHost.positionToLineAndCharacter(this.activeFile.fileName, position);
|
||||
return 'line ' + (pos.line + 1) + ', col ' + pos.character;
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,8 @@
|
||||
|
||||
const enum FourSlashTestType {
|
||||
Native,
|
||||
Shims
|
||||
Shims,
|
||||
Server
|
||||
}
|
||||
|
||||
class FourSlashRunner extends RunnerBase {
|
||||
@@ -22,6 +23,10 @@ class FourSlashRunner extends RunnerBase {
|
||||
this.basePath = 'tests/cases/fourslash/shims';
|
||||
this.testSuiteName = 'fourslash-shims';
|
||||
break;
|
||||
case FourSlashTestType.Server:
|
||||
this.basePath = 'tests/cases/fourslash/server';
|
||||
this.testSuiteName = 'fourslash-server';
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -16,14 +16,15 @@
|
||||
|
||||
/// <reference path='..\services\services.ts' />
|
||||
/// <reference path='..\services\shims.ts' />
|
||||
/// <reference path='..\server\session.ts' />
|
||||
/// <reference path='..\server\client.ts' />
|
||||
/// <reference path='..\server\node.d.ts' />
|
||||
/// <reference path='external\mocha.d.ts'/>
|
||||
/// <reference path='external\chai.d.ts'/>
|
||||
/// <reference path='sourceMapRecorder.ts'/>
|
||||
/// <reference path='runnerbase.ts'/>
|
||||
|
||||
declare var require: any;
|
||||
declare var process: any;
|
||||
var Buffer = require('buffer').Buffer;
|
||||
var Buffer: BufferConstructor = require('buffer').Buffer;
|
||||
|
||||
// this will work in the browser via browserify
|
||||
var _chai: typeof chai = require('chai');
|
||||
@@ -1184,13 +1185,13 @@ module Harness {
|
||||
}
|
||||
|
||||
export function getMinimalDiagnostic(err: ts.Diagnostic): HarnessDiagnostic {
|
||||
var errorLineInfo = err.file ? err.file.getLineAndCharacterFromPosition(err.start) : { line: 0, character: 0 };
|
||||
var errorLineInfo = err.file ? err.file.getLineAndCharacterOfPosition(err.start) : { line: -1, character: -1 };
|
||||
return {
|
||||
fileName: err.file && err.file.fileName,
|
||||
start: err.start,
|
||||
end: err.start + err.length,
|
||||
line: errorLineInfo.line,
|
||||
character: errorLineInfo.character,
|
||||
line: errorLineInfo.line + 1,
|
||||
character: errorLineInfo.character + 1,
|
||||
message: ts.flattenDiagnosticMessageText(err.messageText, ts.sys.newLine),
|
||||
category: ts.DiagnosticCategory[err.category].toLowerCase(),
|
||||
code: err.code
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
/// <reference path='..\services\services.ts' />
|
||||
/// <reference path='..\services\shims.ts' />
|
||||
/// <reference path='..\server\client.ts' />
|
||||
/// <reference path='harness.ts' />
|
||||
|
||||
module Harness.LanguageService {
|
||||
@@ -23,18 +24,18 @@ module Harness.LanguageService {
|
||||
this.version++;
|
||||
}
|
||||
|
||||
public editContent(minChar: number, limChar: number, newText: string): void {
|
||||
public editContent(start: number, end: number, newText: string): void {
|
||||
// Apply edits
|
||||
var prefix = this.content.substring(0, minChar);
|
||||
var prefix = this.content.substring(0, start);
|
||||
var middle = newText;
|
||||
var suffix = this.content.substring(limChar);
|
||||
var suffix = this.content.substring(end);
|
||||
this.setContent(prefix + middle + suffix);
|
||||
|
||||
// Store edit range + new length of script
|
||||
this.editRanges.push({
|
||||
length: this.content.length,
|
||||
textChangeRange: ts.createTextChangeRange(
|
||||
ts.createTextSpanFromBounds(minChar, limChar), newText.length)
|
||||
ts.createTextSpanFromBounds(start, end), newText.length)
|
||||
});
|
||||
|
||||
// Update version #
|
||||
@@ -145,52 +146,28 @@ module Harness.LanguageService {
|
||||
this.fileNameToScript[fileName] = new ScriptInfo(fileName, content);
|
||||
}
|
||||
|
||||
public updateScript(fileName: string, content: string) {
|
||||
public editScript(fileName: string, start: number, end: number, newText: string) {
|
||||
var script = this.getScriptInfo(fileName);
|
||||
if (script !== null) {
|
||||
script.updateContent(content);
|
||||
return;
|
||||
}
|
||||
|
||||
this.addScript(fileName, content);
|
||||
}
|
||||
|
||||
public editScript(fileName: string, minChar: number, limChar: number, newText: string) {
|
||||
var script = this.getScriptInfo(fileName);
|
||||
if (script !== null) {
|
||||
script.editContent(minChar, limChar, newText);
|
||||
script.editContent(start, end, newText);
|
||||
return;
|
||||
}
|
||||
|
||||
throw new Error("No script with name '" + fileName + "'");
|
||||
}
|
||||
|
||||
/**
|
||||
* @param line 1 based index
|
||||
* @param col 1 based index
|
||||
*/
|
||||
public lineColToPosition(fileName: string, line: number, col: number): number {
|
||||
var script: ScriptInfo = this.fileNameToScript[fileName];
|
||||
assert.isNotNull(script);
|
||||
assert.isTrue(line >= 1);
|
||||
assert.isTrue(col >= 1);
|
||||
|
||||
return ts.computePositionFromLineAndCharacter(script.lineMap, line, col);
|
||||
public openFile(fileName: string): void {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param line 0 based index
|
||||
* @param col 0 based index
|
||||
*/
|
||||
public positionToZeroBasedLineCol(fileName: string, position: number): ts.LineAndCharacter {
|
||||
public positionToLineAndCharacter(fileName: string, position: number): ts.LineAndCharacter {
|
||||
var script: ScriptInfo = this.fileNameToScript[fileName];
|
||||
assert.isNotNull(script);
|
||||
|
||||
var result = ts.computeLineAndCharacterOfPosition(script.lineMap, position);
|
||||
|
||||
assert.isTrue(result.line >= 1);
|
||||
assert.isTrue(result.character >= 1);
|
||||
return { line: result.line - 1, character: result.character - 1 };
|
||||
return ts.computeLineAndCharacterOfPosition(script.lineMap, position);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -236,10 +213,8 @@ module Harness.LanguageService {
|
||||
getFilenames(): string[] { return this.nativeHost.getFilenames(); }
|
||||
getScriptInfo(fileName: string): ScriptInfo { return this.nativeHost.getScriptInfo(fileName); }
|
||||
addScript(fileName: string, content: string): void { this.nativeHost.addScript(fileName, content); }
|
||||
updateScript(fileName: string, content: string): void { return this.nativeHost.updateScript(fileName, content); }
|
||||
editScript(fileName: string, minChar: number, limChar: number, newText: string): void { this.nativeHost.editScript(fileName, minChar, limChar, newText); }
|
||||
lineColToPosition(fileName: string, line: number, col: number): number { return this.nativeHost.lineColToPosition(fileName, line, col); }
|
||||
positionToZeroBasedLineCol(fileName: string, position: number): ts.LineAndCharacter { return this.nativeHost.positionToZeroBasedLineCol(fileName, position); }
|
||||
editScript(fileName: string, start: number, end: number, newText: string): void { this.nativeHost.editScript(fileName, start, end, newText); }
|
||||
positionToLineAndCharacter(fileName: string, position: number): ts.LineAndCharacter { return this.nativeHost.positionToLineAndCharacter(fileName, position); }
|
||||
|
||||
getCompilationSettings(): string { return JSON.stringify(this.nativeHost.getCompilationSettings()); }
|
||||
getCancellationToken(): ts.CancellationToken { return this.nativeHost.getCancellationToken(); }
|
||||
@@ -442,5 +417,156 @@ module Harness.LanguageService {
|
||||
return convertResult;
|
||||
}
|
||||
}
|
||||
|
||||
// Server adapter
|
||||
class SessionClientHost extends NativeLanguageServiceHost implements ts.server.SessionClientHost {
|
||||
private client: ts.server.SessionClient;
|
||||
|
||||
constructor(cancellationToken: ts.CancellationToken, settings: ts.CompilerOptions) {
|
||||
super(cancellationToken, settings);
|
||||
}
|
||||
|
||||
onMessage(message: string): void {
|
||||
|
||||
}
|
||||
|
||||
writeMessage(message: string): void {
|
||||
|
||||
}
|
||||
|
||||
setClient(client: ts.server.SessionClient) {
|
||||
this.client = client;
|
||||
}
|
||||
|
||||
openFile(fileName: string): void {
|
||||
super.openFile(fileName);
|
||||
this.client.openFile(fileName);
|
||||
}
|
||||
|
||||
editScript(fileName: string, start: number, end: number, newText: string) {
|
||||
super.editScript(fileName, start, end, newText);
|
||||
this.client.changeFile(fileName, start, end, newText);
|
||||
}
|
||||
}
|
||||
|
||||
class SessionServerHost implements ts.server.ServerHost, ts.server.Logger {
|
||||
args: string[] = [];
|
||||
newLine: string;
|
||||
useCaseSensitiveFileNames: boolean = false;
|
||||
|
||||
constructor(private host: NativeLanguageServiceHost) {
|
||||
this.newLine = this.host.getNewLine();
|
||||
}
|
||||
|
||||
onMessage(message: string): void {
|
||||
|
||||
}
|
||||
|
||||
writeMessage(message: string): void {
|
||||
}
|
||||
|
||||
write(message: string): void {
|
||||
this.writeMessage(message);
|
||||
}
|
||||
|
||||
readFile(fileName: string): string {
|
||||
if (fileName.indexOf(Harness.Compiler.defaultLibFileName) >= 0) {
|
||||
fileName = Harness.Compiler.defaultLibFileName;
|
||||
}
|
||||
|
||||
var snapshot = this.host.getScriptSnapshot(fileName);
|
||||
return snapshot && snapshot.getText(0, snapshot.getLength());
|
||||
}
|
||||
|
||||
writeFile(name: string, text: string, writeByteOrderMark: boolean): void {
|
||||
}
|
||||
|
||||
resolvePath(path: string): string {
|
||||
return path;
|
||||
}
|
||||
|
||||
fileExists(path: string): boolean {
|
||||
return !!this.host.getScriptSnapshot(path);
|
||||
}
|
||||
|
||||
directoryExists(path: string): boolean {
|
||||
return false;
|
||||
}
|
||||
|
||||
getExecutingFilePath(): string {
|
||||
return "";
|
||||
}
|
||||
|
||||
exit(exitCode: number): void {
|
||||
}
|
||||
|
||||
createDirectory(directoryName: string): void {
|
||||
throw new Error("Not Implemented Yet.");
|
||||
}
|
||||
|
||||
getCurrentDirectory(): string {
|
||||
return this.host.getCurrentDirectory();
|
||||
}
|
||||
|
||||
readDirectory(path: string, extension?: string): string[] {
|
||||
throw new Error("Not implemented Yet.");
|
||||
}
|
||||
|
||||
watchFile(fileName: string, callback: (fileName: string) => void): ts.FileWatcher {
|
||||
return { close() { } };
|
||||
}
|
||||
|
||||
close(): void {
|
||||
}
|
||||
|
||||
info(message: string): void {
|
||||
return this.host.log(message);
|
||||
}
|
||||
|
||||
msg(message: string) {
|
||||
return this.host.log(message);
|
||||
}
|
||||
|
||||
endGroup(): void {
|
||||
}
|
||||
|
||||
perftrc(message: string): void {
|
||||
return this.host.log(message);
|
||||
}
|
||||
|
||||
startGroup(): void {
|
||||
}
|
||||
}
|
||||
|
||||
export class ServerLanugageServiceAdapter implements LanguageServiceAdapter {
|
||||
private host: SessionClientHost;
|
||||
private client: ts.server.SessionClient;
|
||||
constructor(cancellationToken?: ts.CancellationToken, options?: ts.CompilerOptions) {
|
||||
// This is the main host that tests use to direct tests
|
||||
var clientHost = new SessionClientHost(cancellationToken, options);
|
||||
var client = new ts.server.SessionClient(clientHost);
|
||||
|
||||
// This host is just a proxy for the clientHost, it uses the client
|
||||
// host to answer server queries about files on disk
|
||||
var serverHost = new SessionServerHost(clientHost);
|
||||
var server = new ts.server.Session(serverHost, serverHost);
|
||||
|
||||
// Fake the connection between the client and the server
|
||||
serverHost.writeMessage = client.onMessage.bind(client);
|
||||
clientHost.writeMessage = server.onMessage.bind(server);
|
||||
|
||||
// Wire the client to the host to get notifications when a file is open
|
||||
// or edited.
|
||||
clientHost.setClient(client);
|
||||
|
||||
// Set the properties
|
||||
this.client = client;
|
||||
this.host = clientHost;
|
||||
}
|
||||
getHost() { return this.host; }
|
||||
getLanguageService(): ts.LanguageService { return this.client; }
|
||||
getClassifier(): ts.Classifier { throw new Error("getClassifier is not available using the server interface."); }
|
||||
getPreProcessedFileInfo(fileName: string, fileContents: string): ts.PreProcessedFileInfo { throw new Error("getPreProcessedFileInfo is not available using the server interface."); }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,6 +66,9 @@ if (testConfigFile !== '') {
|
||||
case 'fourslash-shims':
|
||||
runners.push(new FourSlashRunner(FourSlashTestType.Shims));
|
||||
break;
|
||||
case 'fourslash-server':
|
||||
runners.push(new FourSlashRunner(FourSlashTestType.Server));
|
||||
break;
|
||||
case 'fourslash-generated':
|
||||
runners.push(new GeneratedFourslashRunner(FourSlashTestType.Native));
|
||||
break;
|
||||
@@ -95,6 +98,7 @@ if (runners.length === 0) {
|
||||
// language services
|
||||
runners.push(new FourSlashRunner(FourSlashTestType.Native));
|
||||
runners.push(new FourSlashRunner(FourSlashTestType.Shims));
|
||||
runners.push(new FourSlashRunner(FourSlashTestType.Server));
|
||||
//runners.push(new GeneratedFourslashRunner());
|
||||
}
|
||||
|
||||
|
||||
@@ -85,15 +85,17 @@ class TypeWriterWalker {
|
||||
|
||||
private log(node: ts.Node, type: ts.Type): void {
|
||||
var actualPos = ts.skipTrivia(this.currentSourceFile.text, node.pos);
|
||||
var lineAndCharacter = this.currentSourceFile.getLineAndCharacterFromPosition(actualPos);
|
||||
var lineAndCharacter = this.currentSourceFile.getLineAndCharacterOfPosition(actualPos);
|
||||
var sourceText = ts.getTextOfNodeFromSourceText(this.currentSourceFile.text, node);
|
||||
|
||||
// If we got an unknown type, we temporarily want to fall back to just pretending the name
|
||||
// (source text) of the node is the type. This is to align with the old typeWriter to make
|
||||
// baseline comparisons easier. In the long term, we will want to just call typeToString
|
||||
this.results.push({
|
||||
line: lineAndCharacter.line - 1,
|
||||
column: lineAndCharacter.character,
|
||||
line: lineAndCharacter.line,
|
||||
// todo(cyrusn): Not sure why column is one-based for type-writer. But I'm preserving
|
||||
// that behavior to prevent having a lot of baselines to fix up.
|
||||
column: lineAndCharacter.character + 1,
|
||||
syntaxKind: node.kind,
|
||||
sourceText: sourceText,
|
||||
type: this.checker.typeToString(type, node.parent, ts.TypeFormatFlags.NoTruncation | ts.TypeFormatFlags.WriteOwnNameForAnyLike)
|
||||
|
||||
Vendored
+85
-79
@@ -1,4 +1,4 @@
|
||||
declare type PropertyKey = string | number | Symbol;
|
||||
declare type PropertyKey = string | number | symbol;
|
||||
|
||||
interface Symbol {
|
||||
/** Returns a string representation of an object. */
|
||||
@@ -7,7 +7,7 @@ interface Symbol {
|
||||
/** Returns the primitive value of the specified object. */
|
||||
valueOf(): Object;
|
||||
|
||||
// [Symbol.toStringTag]: string;
|
||||
[Symbol.toStringTag]: string;
|
||||
}
|
||||
|
||||
interface SymbolConstructor {
|
||||
@@ -20,21 +20,21 @@ interface SymbolConstructor {
|
||||
* Returns a new unique Symbol value.
|
||||
* @param description Description of the new Symbol object.
|
||||
*/
|
||||
(description?: string|number): Symbol;
|
||||
(description?: string|number): symbol;
|
||||
|
||||
/**
|
||||
* Returns a Symbol object from the global symbol registry matching the given key if found.
|
||||
* Otherwise, returns a new symbol with this key.
|
||||
* @param key key to search for.
|
||||
*/
|
||||
for(key: string): Symbol;
|
||||
for(key: string): symbol;
|
||||
|
||||
/**
|
||||
* Returns a key from the global symbol registry matching the given Symbol if found.
|
||||
* Otherwise, returns a undefined.
|
||||
* @param sym Symbol to find the key for.
|
||||
*/
|
||||
keyFor(sym: Symbol): string;
|
||||
keyFor(sym: symbol): string;
|
||||
|
||||
// Well-known Symbols
|
||||
|
||||
@@ -42,42 +42,42 @@ interface SymbolConstructor {
|
||||
* A method that determines if a constructor object recognizes an object as one of the
|
||||
* constructor’s instances. Called by the semantics of the instanceof operator.
|
||||
*/
|
||||
hasInstance: Symbol;
|
||||
hasInstance: symbol;
|
||||
|
||||
/**
|
||||
* A Boolean value that if true indicates that an object should flatten to its array elements
|
||||
* by Array.prototype.concat.
|
||||
*/
|
||||
isConcatSpreadable: Symbol;
|
||||
isConcatSpreadable: symbol;
|
||||
|
||||
/**
|
||||
* A Boolean value that if true indicates that an object may be used as a regular expression.
|
||||
*/
|
||||
isRegExp: Symbol;
|
||||
isRegExp: symbol;
|
||||
|
||||
/**
|
||||
* A method that returns the default iterator for an object.Called by the semantics of the
|
||||
* for-of statement.
|
||||
*/
|
||||
iterator: Symbol;
|
||||
iterator: symbol;
|
||||
|
||||
/**
|
||||
* A method that converts an object to a corresponding primitive value.Called by the ToPrimitive
|
||||
* abstract operation.
|
||||
*/
|
||||
toPrimitive: Symbol;
|
||||
toPrimitive: symbol;
|
||||
|
||||
/**
|
||||
* A String value that is used in the creation of the default string description of an object.
|
||||
* Called by the built- in method Object.prototype.toString.
|
||||
*/
|
||||
toStringTag: Symbol;
|
||||
toStringTag: symbol;
|
||||
|
||||
/**
|
||||
* An Object whose own property names are property names that are excluded from the with
|
||||
* environment bindings of the associated objects.
|
||||
*/
|
||||
unscopables: Symbol;
|
||||
unscopables: symbol;
|
||||
}
|
||||
declare var Symbol: SymbolConstructor;
|
||||
|
||||
@@ -108,7 +108,7 @@ interface ObjectConstructor {
|
||||
* Returns an array of all symbol properties found directly on object o.
|
||||
* @param o Object to retrieve the symbols from.
|
||||
*/
|
||||
getOwnPropertySymbols(o: any): Symbol[];
|
||||
getOwnPropertySymbols(o: any): symbol[];
|
||||
|
||||
/**
|
||||
* Returns true if the values are the same value, false otherwise.
|
||||
@@ -230,22 +230,22 @@ interface ArrayLike<T> {
|
||||
|
||||
interface Array<T> {
|
||||
/** Iterator */
|
||||
// [Symbol.iterator] (): Iterator<T>;
|
||||
[Symbol.iterator](): IterableIterator<T>;
|
||||
|
||||
/**
|
||||
* Returns an array of key, value pairs for every entry in the array
|
||||
*/
|
||||
entries(): Iterator<[number, T]>;
|
||||
entries(): IterableIterator<[number, T]>;
|
||||
|
||||
/**
|
||||
* Returns an list of keys in the array
|
||||
*/
|
||||
keys(): Iterator<number>;
|
||||
keys(): IterableIterator<number>;
|
||||
|
||||
/**
|
||||
* Returns an list of values in the array
|
||||
*/
|
||||
values(): Iterator<T>;
|
||||
values(): IterableIterator<T>;
|
||||
|
||||
/**
|
||||
* Returns the value of the first element in the array where predicate is true, and undefined
|
||||
@@ -329,7 +329,7 @@ interface ArrayConstructor {
|
||||
|
||||
interface String {
|
||||
/** Iterator */
|
||||
// [Symbol.iterator] (): Iterator<string>;
|
||||
[Symbol.iterator](): IterableIterator<string>;
|
||||
|
||||
/**
|
||||
* Returns a nonnegative integer Number less than 1114112 (0x110000) that is the code point
|
||||
@@ -447,12 +447,17 @@ interface IteratorResult<T> {
|
||||
}
|
||||
|
||||
interface Iterator<T> {
|
||||
//[Symbol.iterator](): Iterator<T>;
|
||||
next(): IteratorResult<T>;
|
||||
return?(value?: any): IteratorResult<T>;
|
||||
throw?(e?: any): IteratorResult<T>;
|
||||
}
|
||||
|
||||
interface Iterable<T> {
|
||||
//[Symbol.iterator](): Iterator<T>;
|
||||
[Symbol.iterator](): Iterator<T>;
|
||||
}
|
||||
|
||||
interface IterableIterator<T> extends Iterator<T> {
|
||||
[Symbol.iterator](): IterableIterator<T>;
|
||||
}
|
||||
|
||||
interface GeneratorFunction extends Function {
|
||||
@@ -470,11 +475,12 @@ interface GeneratorFunctionConstructor {
|
||||
}
|
||||
declare var GeneratorFunction: GeneratorFunctionConstructor;
|
||||
|
||||
interface Generator<T> extends Iterator<T> {
|
||||
interface Generator<T> extends IterableIterator<T> {
|
||||
next(value?: any): IteratorResult<T>;
|
||||
throw (exception: any): IteratorResult<T>;
|
||||
return (value: T): IteratorResult<T>;
|
||||
// [Symbol.toStringTag]: string;
|
||||
throw(exception: any): IteratorResult<T>;
|
||||
return(value: T): IteratorResult<T>;
|
||||
[Symbol.iterator](): Generator<T>;
|
||||
[Symbol.toStringTag]: string;
|
||||
}
|
||||
|
||||
interface Math {
|
||||
@@ -588,11 +594,11 @@ interface Math {
|
||||
*/
|
||||
cbrt(x: number): number;
|
||||
|
||||
// [Symbol.toStringTag]: string;
|
||||
[Symbol.toStringTag]: string;
|
||||
}
|
||||
|
||||
interface RegExp {
|
||||
// [Symbol.isRegExp]: boolean;
|
||||
[Symbol.isRegExp]: boolean;
|
||||
|
||||
/**
|
||||
* Matches a string with a regular expression, and returns an array containing the results of
|
||||
@@ -641,16 +647,16 @@ interface RegExp {
|
||||
interface Map<K, V> {
|
||||
clear(): void;
|
||||
delete(key: K): boolean;
|
||||
entries(): Iterator<[K, V]>;
|
||||
entries(): IterableIterator<[K, V]>;
|
||||
forEach(callbackfn: (value: V, index: K, map: Map<K, V>) => void, thisArg?: any): void;
|
||||
get(key: K): V;
|
||||
has(key: K): boolean;
|
||||
keys(): Iterator<K>;
|
||||
keys(): IterableIterator<K>;
|
||||
set(key: K, value?: V): Map<K, V>;
|
||||
size: number;
|
||||
values(): Iterator<V>;
|
||||
// [Symbol.iterator]():Iterator<[K,V]>;
|
||||
// [Symbol.toStringTag]: string;
|
||||
values(): IterableIterator<V>;
|
||||
[Symbol.iterator]():IterableIterator<[K,V]>;
|
||||
[Symbol.toStringTag]: string;
|
||||
}
|
||||
|
||||
interface MapConstructor {
|
||||
@@ -666,7 +672,7 @@ interface WeakMap<K, V> {
|
||||
get(key: K): V;
|
||||
has(key: K): boolean;
|
||||
set(key: K, value?: V): WeakMap<K, V>;
|
||||
// [Symbol.toStringTag]: string;
|
||||
[Symbol.toStringTag]: string;
|
||||
}
|
||||
|
||||
interface WeakMapConstructor {
|
||||
@@ -680,14 +686,14 @@ interface Set<T> {
|
||||
add(value: T): Set<T>;
|
||||
clear(): void;
|
||||
delete(value: T): boolean;
|
||||
entries(): Iterator<[T, T]>;
|
||||
entries(): IterableIterator<[T, T]>;
|
||||
forEach(callbackfn: (value: T, index: T, set: Set<T>) => void, thisArg?: any): void;
|
||||
has(value: T): boolean;
|
||||
keys(): Iterator<T>;
|
||||
keys(): IterableIterator<T>;
|
||||
size: number;
|
||||
values(): Iterator<T>;
|
||||
// [Symbol.iterator]():Iterator<T>;
|
||||
// [Symbol.toStringTag]: string;
|
||||
values(): IterableIterator<T>;
|
||||
[Symbol.iterator]():IterableIterator<T>;
|
||||
[Symbol.toStringTag]: string;
|
||||
}
|
||||
|
||||
interface SetConstructor {
|
||||
@@ -702,7 +708,7 @@ interface WeakSet<T> {
|
||||
clear(): void;
|
||||
delete(value: T): boolean;
|
||||
has(value: T): boolean;
|
||||
// [Symbol.toStringTag]: string;
|
||||
[Symbol.toStringTag]: string;
|
||||
}
|
||||
|
||||
interface WeakSetConstructor {
|
||||
@@ -713,7 +719,7 @@ interface WeakSetConstructor {
|
||||
declare var WeakSet: WeakSetConstructor;
|
||||
|
||||
interface JSON {
|
||||
// [Symbol.toStringTag]: string;
|
||||
[Symbol.toStringTag]: string;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -733,7 +739,7 @@ interface ArrayBuffer {
|
||||
*/
|
||||
slice(begin: number, end?: number): ArrayBuffer;
|
||||
|
||||
// [Symbol.toStringTag]: string;
|
||||
[Symbol.toStringTag]: string;
|
||||
}
|
||||
|
||||
interface ArrayBufferConstructor {
|
||||
@@ -870,7 +876,7 @@ interface DataView {
|
||||
*/
|
||||
setUint32(byteOffset: number, value: number, littleEndian: boolean): void;
|
||||
|
||||
// [Symbol.toStringTag]: string;
|
||||
[Symbol.toStringTag]: string;
|
||||
}
|
||||
|
||||
interface DataViewConstructor {
|
||||
@@ -917,7 +923,7 @@ interface Int8Array {
|
||||
/**
|
||||
* Returns an array of key, value pairs for every entry in the array
|
||||
*/
|
||||
entries(): Iterator<[number, number]>;
|
||||
entries(): IterableIterator<[number, number]>;
|
||||
|
||||
/**
|
||||
* Determines whether all the members of an array satisfy the specified test.
|
||||
@@ -997,7 +1003,7 @@ interface Int8Array {
|
||||
/**
|
||||
* Returns an list of keys in the array
|
||||
*/
|
||||
keys(): Iterator<number>;
|
||||
keys(): IterableIterator<number>;
|
||||
|
||||
/**
|
||||
* Returns the index of the last occurrence of a value in an array.
|
||||
@@ -1134,10 +1140,10 @@ interface Int8Array {
|
||||
/**
|
||||
* Returns an list of values in the array
|
||||
*/
|
||||
values(): Iterator<number>;
|
||||
values(): IterableIterator<number>;
|
||||
|
||||
[index: number]: number;
|
||||
// [Symbol.iterator] (): Iterator<number>;
|
||||
[Symbol.iterator](): IterableIterator<number>;
|
||||
}
|
||||
|
||||
interface Int8ArrayConstructor {
|
||||
@@ -1207,7 +1213,7 @@ interface Uint8Array {
|
||||
/**
|
||||
* Returns an array of key, value pairs for every entry in the array
|
||||
*/
|
||||
entries(): Iterator<[number, number]>;
|
||||
entries(): IterableIterator<[number, number]>;
|
||||
|
||||
/**
|
||||
* Determines whether all the members of an array satisfy the specified test.
|
||||
@@ -1287,7 +1293,7 @@ interface Uint8Array {
|
||||
/**
|
||||
* Returns an list of keys in the array
|
||||
*/
|
||||
keys(): Iterator<number>;
|
||||
keys(): IterableIterator<number>;
|
||||
|
||||
/**
|
||||
* Returns the index of the last occurrence of a value in an array.
|
||||
@@ -1424,10 +1430,10 @@ interface Uint8Array {
|
||||
/**
|
||||
* Returns an list of values in the array
|
||||
*/
|
||||
values(): Iterator<number>;
|
||||
values(): IterableIterator<number>;
|
||||
|
||||
[index: number]: number;
|
||||
// [Symbol.iterator] (): Iterator<number>;
|
||||
[Symbol.iterator](): IterableIterator<number>;
|
||||
}
|
||||
|
||||
interface Uint8ArrayConstructor {
|
||||
@@ -1497,7 +1503,7 @@ interface Uint8ClampedArray {
|
||||
/**
|
||||
* Returns an array of key, value pairs for every entry in the array
|
||||
*/
|
||||
entries(): Iterator<[number, number]>;
|
||||
entries(): IterableIterator<[number, number]>;
|
||||
|
||||
/**
|
||||
* Determines whether all the members of an array satisfy the specified test.
|
||||
@@ -1577,7 +1583,7 @@ interface Uint8ClampedArray {
|
||||
/**
|
||||
* Returns an list of keys in the array
|
||||
*/
|
||||
keys(): Iterator<number>;
|
||||
keys(): IterableIterator<number>;
|
||||
|
||||
/**
|
||||
* Returns the index of the last occurrence of a value in an array.
|
||||
@@ -1714,10 +1720,10 @@ interface Uint8ClampedArray {
|
||||
/**
|
||||
* Returns an list of values in the array
|
||||
*/
|
||||
values(): Iterator<number>;
|
||||
values(): IterableIterator<number>;
|
||||
|
||||
[index: number]: number;
|
||||
// [Symbol.iterator] (): Iterator<number>;
|
||||
[Symbol.iterator](): IterableIterator<number>;
|
||||
}
|
||||
|
||||
interface Uint8ClampedArrayConstructor {
|
||||
@@ -1787,7 +1793,7 @@ interface Int16Array {
|
||||
/**
|
||||
* Returns an array of key, value pairs for every entry in the array
|
||||
*/
|
||||
entries(): Iterator<[number, number]>;
|
||||
entries(): IterableIterator<[number, number]>;
|
||||
|
||||
/**
|
||||
* Determines whether all the members of an array satisfy the specified test.
|
||||
@@ -1867,7 +1873,7 @@ interface Int16Array {
|
||||
/**
|
||||
* Returns an list of keys in the array
|
||||
*/
|
||||
keys(): Iterator<number>;
|
||||
keys(): IterableIterator<number>;
|
||||
|
||||
/**
|
||||
* Returns the index of the last occurrence of a value in an array.
|
||||
@@ -2004,10 +2010,10 @@ interface Int16Array {
|
||||
/**
|
||||
* Returns an list of values in the array
|
||||
*/
|
||||
values(): Iterator<number>;
|
||||
values(): IterableIterator<number>;
|
||||
|
||||
[index: number]: number;
|
||||
// [Symbol.iterator] (): Iterator<number>;
|
||||
[Symbol.iterator](): IterableIterator<number>;
|
||||
}
|
||||
|
||||
interface Int16ArrayConstructor {
|
||||
@@ -2077,7 +2083,7 @@ interface Uint16Array {
|
||||
/**
|
||||
* Returns an array of key, value pairs for every entry in the array
|
||||
*/
|
||||
entries(): Iterator<[number, number]>;
|
||||
entries(): IterableIterator<[number, number]>;
|
||||
|
||||
/**
|
||||
* Determines whether all the members of an array satisfy the specified test.
|
||||
@@ -2157,7 +2163,7 @@ interface Uint16Array {
|
||||
/**
|
||||
* Returns an list of keys in the array
|
||||
*/
|
||||
keys(): Iterator<number>;
|
||||
keys(): IterableIterator<number>;
|
||||
|
||||
/**
|
||||
* Returns the index of the last occurrence of a value in an array.
|
||||
@@ -2294,10 +2300,10 @@ interface Uint16Array {
|
||||
/**
|
||||
* Returns an list of values in the array
|
||||
*/
|
||||
values(): Iterator<number>;
|
||||
values(): IterableIterator<number>;
|
||||
|
||||
[index: number]: number;
|
||||
// [Symbol.iterator] (): Iterator<number>;
|
||||
[Symbol.iterator](): IterableIterator<number>;
|
||||
}
|
||||
|
||||
interface Uint16ArrayConstructor {
|
||||
@@ -2367,7 +2373,7 @@ interface Int32Array {
|
||||
/**
|
||||
* Returns an array of key, value pairs for every entry in the array
|
||||
*/
|
||||
entries(): Iterator<[number, number]>;
|
||||
entries(): IterableIterator<[number, number]>;
|
||||
|
||||
/**
|
||||
* Determines whether all the members of an array satisfy the specified test.
|
||||
@@ -2447,7 +2453,7 @@ interface Int32Array {
|
||||
/**
|
||||
* Returns an list of keys in the array
|
||||
*/
|
||||
keys(): Iterator<number>;
|
||||
keys(): IterableIterator<number>;
|
||||
|
||||
/**
|
||||
* Returns the index of the last occurrence of a value in an array.
|
||||
@@ -2584,10 +2590,10 @@ interface Int32Array {
|
||||
/**
|
||||
* Returns an list of values in the array
|
||||
*/
|
||||
values(): Iterator<number>;
|
||||
values(): IterableIterator<number>;
|
||||
|
||||
[index: number]: number;
|
||||
// [Symbol.iterator] (): Iterator<number>;
|
||||
[Symbol.iterator](): IterableIterator<number>;
|
||||
}
|
||||
|
||||
interface Int32ArrayConstructor {
|
||||
@@ -2657,7 +2663,7 @@ interface Uint32Array {
|
||||
/**
|
||||
* Returns an array of key, value pairs for every entry in the array
|
||||
*/
|
||||
entries(): Iterator<[number, number]>;
|
||||
entries(): IterableIterator<[number, number]>;
|
||||
|
||||
/**
|
||||
* Determines whether all the members of an array satisfy the specified test.
|
||||
@@ -2737,7 +2743,7 @@ interface Uint32Array {
|
||||
/**
|
||||
* Returns an list of keys in the array
|
||||
*/
|
||||
keys(): Iterator<number>;
|
||||
keys(): IterableIterator<number>;
|
||||
|
||||
/**
|
||||
* Returns the index of the last occurrence of a value in an array.
|
||||
@@ -2874,10 +2880,10 @@ interface Uint32Array {
|
||||
/**
|
||||
* Returns an list of values in the array
|
||||
*/
|
||||
values(): Iterator<number>;
|
||||
values(): IterableIterator<number>;
|
||||
|
||||
[index: number]: number;
|
||||
// [Symbol.iterator] (): Iterator<number>;
|
||||
[Symbol.iterator](): IterableIterator<number>;
|
||||
}
|
||||
|
||||
interface Uint32ArrayConstructor {
|
||||
@@ -2947,7 +2953,7 @@ interface Float32Array {
|
||||
/**
|
||||
* Returns an array of key, value pairs for every entry in the array
|
||||
*/
|
||||
entries(): Iterator<[number, number]>;
|
||||
entries(): IterableIterator<[number, number]>;
|
||||
|
||||
/**
|
||||
* Determines whether all the members of an array satisfy the specified test.
|
||||
@@ -3027,7 +3033,7 @@ interface Float32Array {
|
||||
/**
|
||||
* Returns an list of keys in the array
|
||||
*/
|
||||
keys(): Iterator<number>;
|
||||
keys(): IterableIterator<number>;
|
||||
|
||||
/**
|
||||
* Returns the index of the last occurrence of a value in an array.
|
||||
@@ -3164,10 +3170,10 @@ interface Float32Array {
|
||||
/**
|
||||
* Returns an list of values in the array
|
||||
*/
|
||||
values(): Iterator<number>;
|
||||
values(): IterableIterator<number>;
|
||||
|
||||
[index: number]: number;
|
||||
// [Symbol.iterator] (): Iterator<number>;
|
||||
[Symbol.iterator](): IterableIterator<number>;
|
||||
}
|
||||
|
||||
interface Float32ArrayConstructor {
|
||||
@@ -3237,7 +3243,7 @@ interface Float64Array {
|
||||
/**
|
||||
* Returns an array of key, value pairs for every entry in the array
|
||||
*/
|
||||
entries(): Iterator<[number, number]>;
|
||||
entries(): IterableIterator<[number, number]>;
|
||||
|
||||
/**
|
||||
* Determines whether all the members of an array satisfy the specified test.
|
||||
@@ -3317,7 +3323,7 @@ interface Float64Array {
|
||||
/**
|
||||
* Returns an list of keys in the array
|
||||
*/
|
||||
keys(): Iterator<number>;
|
||||
keys(): IterableIterator<number>;
|
||||
|
||||
/**
|
||||
* Returns the index of the last occurrence of a value in an array.
|
||||
@@ -3454,10 +3460,10 @@ interface Float64Array {
|
||||
/**
|
||||
* Returns an list of values in the array
|
||||
*/
|
||||
values(): Iterator<number>;
|
||||
values(): IterableIterator<number>;
|
||||
|
||||
[index: number]: number;
|
||||
// [Symbol.iterator] (): Iterator<number>;
|
||||
[Symbol.iterator](): IterableIterator<number>;
|
||||
}
|
||||
|
||||
interface Float64ArrayConstructor {
|
||||
@@ -3516,12 +3522,12 @@ declare var Reflect: {
|
||||
construct(target: Function, argumentsList: ArrayLike<any>): any;
|
||||
defineProperty(target: any, propertyKey: PropertyKey, attributes: PropertyDescriptor): boolean;
|
||||
deleteProperty(target: any, propertyKey: PropertyKey): boolean;
|
||||
enumerate(target: any): Iterator<any>;
|
||||
enumerate(target: any): IterableIterator<any>;
|
||||
get(target: any, propertyKey: PropertyKey, receiver?: any): any;
|
||||
getOwnPropertyDescriptor(target: any, propertyKey: PropertyKey): PropertyDescriptor;
|
||||
getPrototypeOf(target: any): any;
|
||||
has(target: any, propertyKey: string): boolean;
|
||||
has(target: any, propertyKey: Symbol): boolean;
|
||||
has(target: any, propertyKey: symbol): boolean;
|
||||
isExtensible(target: any): boolean;
|
||||
ownKeys(target: any): Array<PropertyKey>;
|
||||
preventExtensions(target: any): boolean;
|
||||
|
||||
@@ -0,0 +1,495 @@
|
||||
/// <reference path="session.ts" />
|
||||
|
||||
module ts.server {
|
||||
|
||||
export interface SessionClientHost extends LanguageServiceHost {
|
||||
writeMessage(message: string): void;
|
||||
}
|
||||
|
||||
interface CompletionEntry extends CompletionInfo {
|
||||
fileName: string;
|
||||
position: number;
|
||||
}
|
||||
|
||||
interface RenameEntry extends RenameInfo {
|
||||
fileName: string;
|
||||
position: number;
|
||||
locations: RenameLocation[];
|
||||
findInStrings: boolean;
|
||||
findInComments: boolean;
|
||||
}
|
||||
|
||||
export class SessionClient implements LanguageService {
|
||||
private sequence: number = 0;
|
||||
private fileMapping: ts.Map<string> = {};
|
||||
private lineMaps: ts.Map<number[]> = {};
|
||||
private messages: string[] = [];
|
||||
private lastRenameEntry: RenameEntry;
|
||||
|
||||
constructor(private host: SessionClientHost) {
|
||||
}
|
||||
|
||||
public onMessage(message: string): void {
|
||||
this.messages.push(message);
|
||||
}
|
||||
|
||||
private writeMessage(message: string): void {
|
||||
this.host.writeMessage(message);
|
||||
}
|
||||
|
||||
private getLineMap(fileName: string): number[] {
|
||||
var lineMap = ts.lookUp(this.lineMaps, fileName);
|
||||
if (!lineMap) {
|
||||
var scriptSnapshot = this.host.getScriptSnapshot(fileName);
|
||||
lineMap = this.lineMaps[fileName] = ts.computeLineStarts(scriptSnapshot.getText(0, scriptSnapshot.getLength()));
|
||||
}
|
||||
return lineMap;
|
||||
}
|
||||
|
||||
private lineColToPosition(fileName: string, lineCol: protocol.Location): number {
|
||||
return ts.computePositionOfLineAndCharacter(this.getLineMap(fileName), lineCol.line - 1, lineCol.col - 1);
|
||||
}
|
||||
|
||||
private positionToOneBasedLineCol(fileName: string, position: number): protocol.Location {
|
||||
var lineCol = ts.computeLineAndCharacterOfPosition(this.getLineMap(fileName), position);
|
||||
return {
|
||||
line: lineCol.line + 1,
|
||||
col: lineCol.character + 1
|
||||
};
|
||||
}
|
||||
|
||||
private convertCodeEditsToTextChange(fileName: string, codeEdit: protocol.CodeEdit): ts.TextChange {
|
||||
var start = this.lineColToPosition(fileName, codeEdit.start);
|
||||
var end = this.lineColToPosition(fileName, codeEdit.end);
|
||||
|
||||
return {
|
||||
span: ts.createTextSpanFromBounds(start, end),
|
||||
newText: codeEdit.newText
|
||||
};
|
||||
}
|
||||
|
||||
private processRequest<T extends protocol.Request>(command: string, arguments?: any): T {
|
||||
var request: protocol.Request = {
|
||||
seq: this.sequence++,
|
||||
type: "request",
|
||||
command: command,
|
||||
arguments: arguments
|
||||
};
|
||||
|
||||
this.writeMessage(JSON.stringify(request));
|
||||
|
||||
return <T>request;
|
||||
}
|
||||
|
||||
private processResponse<T extends protocol.Response>(request: protocol.Request): T {
|
||||
var lastMessage = this.messages.shift();
|
||||
Debug.assert(!!lastMessage, "Did not recieve any responses.");
|
||||
|
||||
// Read the content length
|
||||
var contentLengthPrefix = "Content-Length: ";
|
||||
var lines = lastMessage.split("\r\n");
|
||||
Debug.assert(lines.length >= 2, "Malformed response: Expected 3 lines in the response.");
|
||||
|
||||
var contentLengthText = lines[0];
|
||||
Debug.assert(contentLengthText.indexOf(contentLengthPrefix) === 0, "Malformed response: Response text did not contain content-length header.");
|
||||
var contentLength = parseInt(contentLengthText.substring(contentLengthPrefix.length));
|
||||
|
||||
// Read the body
|
||||
var responseBody = lines[2];
|
||||
|
||||
// Verify content length
|
||||
Debug.assert(responseBody.length + 1 === contentLength, "Malformed response: Content length did not match the response's body length.");
|
||||
|
||||
try {
|
||||
var response: T = JSON.parse(responseBody);
|
||||
}
|
||||
catch (e) {
|
||||
throw new Error("Malformed response: Failed to parse server response: " + lastMessage + ". \r\n Error detailes: " + e.message);
|
||||
}
|
||||
|
||||
// verify the sequence numbers
|
||||
Debug.assert(response.request_seq === request.seq, "Malformed response: response sequance number did not match request sequence number.");
|
||||
|
||||
// unmarshal errors
|
||||
if (!response.success) {
|
||||
throw new Error("Error " + response.message);
|
||||
}
|
||||
|
||||
Debug.assert(!!response.body, "Malformed response: Unexpected empty response body.");
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
openFile(fileName: string): void {
|
||||
var args: protocol.FileRequestArgs = { file: fileName };
|
||||
this.processRequest(CommandNames.Open, args);
|
||||
}
|
||||
|
||||
closeFile(fileName: string): void {
|
||||
var args: protocol.FileRequestArgs = { file: fileName };
|
||||
this.processRequest(CommandNames.Close, args);
|
||||
}
|
||||
|
||||
changeFile(fileName: string, start: number, end: number, newText: string): void {
|
||||
// clear the line map after an edit
|
||||
this.lineMaps[fileName] = undefined;
|
||||
|
||||
var lineCol = this.positionToOneBasedLineCol(fileName, start);
|
||||
var endLineCol = this.positionToOneBasedLineCol(fileName, end);
|
||||
|
||||
var args: protocol.ChangeRequestArgs = {
|
||||
file: fileName,
|
||||
line: lineCol.line,
|
||||
col: lineCol.col,
|
||||
endLine: endLineCol.line,
|
||||
endCol: endLineCol.col,
|
||||
insertString: newText
|
||||
};
|
||||
|
||||
this.processRequest(CommandNames.Change, args);
|
||||
}
|
||||
|
||||
getQuickInfoAtPosition(fileName: string, position: number): QuickInfo {
|
||||
var lineCol = this.positionToOneBasedLineCol(fileName, position);
|
||||
var args: protocol.FileLocationRequestArgs = {
|
||||
file: fileName,
|
||||
line: lineCol.line,
|
||||
col: lineCol.col
|
||||
};
|
||||
|
||||
var request = this.processRequest<protocol.QuickInfoRequest>(CommandNames.Quickinfo, args);
|
||||
var response = this.processResponse<protocol.QuickInfoResponse>(request);
|
||||
|
||||
var start = this.lineColToPosition(fileName, response.body.start);
|
||||
var end = this.lineColToPosition(fileName, response.body.end);
|
||||
|
||||
return {
|
||||
kind: response.body.kind,
|
||||
kindModifiers: response.body.kindModifiers,
|
||||
textSpan: ts.createTextSpanFromBounds(start, end),
|
||||
displayParts: [{ kind: "text", text: response.body.displayString }],
|
||||
documentation: [{ kind: "text", text: response.body.documentation }]
|
||||
};
|
||||
}
|
||||
|
||||
getCompletionsAtPosition(fileName: string, position: number): CompletionInfo {
|
||||
var lineCol = this.positionToOneBasedLineCol(fileName, position);
|
||||
var args: protocol.CompletionsRequestArgs = {
|
||||
file: fileName,
|
||||
line: lineCol.line,
|
||||
col: lineCol.col,
|
||||
prefix: undefined
|
||||
};
|
||||
|
||||
var request = this.processRequest<protocol.CompletionsRequest>(CommandNames.Completions, args);
|
||||
var response = this.processResponse<protocol.CompletionsResponse>(request);
|
||||
|
||||
return {
|
||||
isMemberCompletion: false,
|
||||
isNewIdentifierLocation: false,
|
||||
entries: response.body,
|
||||
fileName: fileName,
|
||||
position: position
|
||||
};
|
||||
}
|
||||
|
||||
getCompletionEntryDetails(fileName: string, position: number, entryName: string): CompletionEntryDetails {
|
||||
var lineCol = this.positionToOneBasedLineCol(fileName, position);
|
||||
var args: protocol.CompletionDetailsRequestArgs = {
|
||||
file: fileName,
|
||||
line: lineCol.line,
|
||||
col: lineCol.col,
|
||||
entryNames: [entryName]
|
||||
};
|
||||
|
||||
var request = this.processRequest<protocol.CompletionDetailsRequest>(CommandNames.CompletionDetails, args);
|
||||
var response = this.processResponse<protocol.CompletionDetailsResponse>(request);
|
||||
Debug.assert(response.body.length == 1, "Unexpected length of completion details response body.");
|
||||
return response.body[0];
|
||||
}
|
||||
|
||||
getNavigateToItems(searchValue: string): NavigateToItem[] {
|
||||
var args: protocol.NavtoRequestArgs = {
|
||||
searchValue,
|
||||
file: this.host.getScriptFileNames()[0]
|
||||
};
|
||||
|
||||
var request = this.processRequest<protocol.NavtoRequest>(CommandNames.Navto, args);
|
||||
var response = this.processResponse<protocol.NavtoResponse>(request);
|
||||
|
||||
return response.body.map(entry => {
|
||||
var fileName = entry.file;
|
||||
var start = this.lineColToPosition(fileName, entry.start);
|
||||
var end = this.lineColToPosition(fileName, entry.end);
|
||||
|
||||
return {
|
||||
name: entry.name,
|
||||
containerName: entry.containerName || "",
|
||||
containerKind: entry.containerKind || "",
|
||||
kind: entry.kind,
|
||||
kindModifiers: entry.kindModifiers,
|
||||
matchKind: entry.matchKind,
|
||||
isCaseSensitive: entry.isCaseSensitive,
|
||||
fileName: fileName,
|
||||
textSpan: ts.createTextSpanFromBounds(start, end)
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
getFormattingEditsForRange(fileName: string, start: number, end: number, options: ts.FormatCodeOptions): ts.TextChange[] {
|
||||
var startLineCol = this.positionToOneBasedLineCol(fileName, start);
|
||||
var endLineCol = this.positionToOneBasedLineCol(fileName, end);
|
||||
var args: protocol.FormatRequestArgs = {
|
||||
file: fileName,
|
||||
line: startLineCol.line,
|
||||
col: startLineCol.col,
|
||||
endLine: endLineCol.line,
|
||||
endCol: endLineCol.col,
|
||||
};
|
||||
|
||||
// TODO: handle FormatCodeOptions
|
||||
var request = this.processRequest<protocol.FormatRequest>(CommandNames.Format, args);
|
||||
var response = this.processResponse<protocol.FormatResponse>(request);
|
||||
|
||||
return response.body.map(entry=> this.convertCodeEditsToTextChange(fileName, entry));
|
||||
}
|
||||
|
||||
getFormattingEditsForDocument(fileName: string, options: ts.FormatCodeOptions): ts.TextChange[] {
|
||||
return this.getFormattingEditsForRange(fileName, 0, this.host.getScriptSnapshot(fileName).getLength(), options);
|
||||
}
|
||||
|
||||
getFormattingEditsAfterKeystroke(fileName: string, position: number, key: string, options: FormatCodeOptions): ts.TextChange[] {
|
||||
var lineCol = this.positionToOneBasedLineCol(fileName, position);
|
||||
var args: protocol.FormatOnKeyRequestArgs = {
|
||||
file: fileName,
|
||||
line: lineCol.line,
|
||||
col: lineCol.col,
|
||||
key: key
|
||||
};
|
||||
|
||||
// TODO: handle FormatCodeOptions
|
||||
var request = this.processRequest<protocol.FormatOnKeyRequest>(CommandNames.Formatonkey, args);
|
||||
var response = this.processResponse<protocol.FormatResponse>(request);
|
||||
|
||||
return response.body.map(entry=> this.convertCodeEditsToTextChange(fileName, entry));
|
||||
}
|
||||
|
||||
getDefinitionAtPosition(fileName: string, position: number): DefinitionInfo[] {
|
||||
var lineCol = this.positionToOneBasedLineCol(fileName, position);
|
||||
var args: protocol.FileLocationRequestArgs = {
|
||||
file: fileName,
|
||||
line: lineCol.line,
|
||||
col: lineCol.col,
|
||||
};
|
||||
|
||||
var request = this.processRequest<protocol.DefinitionRequest>(CommandNames.Definition, args);
|
||||
var response = this.processResponse<protocol.DefinitionResponse>(request);
|
||||
|
||||
return response.body.map(entry => {
|
||||
var fileName = entry.file;
|
||||
var start = this.lineColToPosition(fileName, entry.start);
|
||||
var end = this.lineColToPosition(fileName, entry.end);
|
||||
return {
|
||||
containerKind: "",
|
||||
containerName: "",
|
||||
fileName: fileName,
|
||||
textSpan: ts.createTextSpanFromBounds(start, end),
|
||||
kind: "",
|
||||
name: ""
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
getReferencesAtPosition(fileName: string, position: number): ReferenceEntry[] {
|
||||
var lineCol = this.positionToOneBasedLineCol(fileName, position);
|
||||
var args: protocol.FileLocationRequestArgs = {
|
||||
file: fileName,
|
||||
line: lineCol.line,
|
||||
col: lineCol.col,
|
||||
};
|
||||
|
||||
var request = this.processRequest<protocol.ReferencesRequest>(CommandNames.References, args);
|
||||
var response = this.processResponse<protocol.ReferencesResponse>(request);
|
||||
|
||||
return response.body.refs.map(entry => {
|
||||
var fileName = entry.file;
|
||||
var start = this.lineColToPosition(fileName, entry.start);
|
||||
var end = this.lineColToPosition(fileName, entry.end);
|
||||
return {
|
||||
fileName: fileName,
|
||||
textSpan: ts.createTextSpanFromBounds(start, end),
|
||||
isWriteAccess: entry.isWriteAccess,
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
getEmitOutput(fileName: string): EmitOutput {
|
||||
throw new Error("Not Implemented Yet.");
|
||||
}
|
||||
|
||||
getSyntacticDiagnostics(fileName: string): Diagnostic[] {
|
||||
throw new Error("Not Implemented Yet.");
|
||||
}
|
||||
|
||||
getSemanticDiagnostics(fileName: string): Diagnostic[] {
|
||||
throw new Error("Not Implemented Yet.");
|
||||
}
|
||||
|
||||
getCompilerOptionsDiagnostics(): Diagnostic[] {
|
||||
throw new Error("Not Implemented Yet.");
|
||||
}
|
||||
|
||||
getRenameInfo(fileName: string, position: number, findInStrings?: boolean, findInComments?: boolean): RenameInfo {
|
||||
var lineCol = this.positionToOneBasedLineCol(fileName, position);
|
||||
var args: protocol.RenameRequestArgs = {
|
||||
file: fileName,
|
||||
line: lineCol.line,
|
||||
col: lineCol.col,
|
||||
findInStrings,
|
||||
findInComments
|
||||
};
|
||||
|
||||
var request = this.processRequest<protocol.RenameRequest>(CommandNames.Rename, args);
|
||||
var response = this.processResponse<protocol.RenameResponse>(request);
|
||||
var locations: RenameLocation[] = [];
|
||||
response.body.locs.map((entry: protocol.SpanGroup) => {
|
||||
var fileName = entry.file;
|
||||
entry.locs.map((loc: protocol.TextSpan) => {
|
||||
var start = this.lineColToPosition(fileName, loc.start);
|
||||
var end = this.lineColToPosition(fileName, loc.end);
|
||||
locations.push({
|
||||
textSpan: ts.createTextSpanFromBounds(start, end),
|
||||
fileName: fileName
|
||||
});
|
||||
});
|
||||
});
|
||||
return this.lastRenameEntry = {
|
||||
canRename: response.body.info.canRename,
|
||||
displayName: response.body.info.displayName,
|
||||
fullDisplayName: response.body.info.fullDisplayName,
|
||||
kind: response.body.info.kind,
|
||||
kindModifiers: response.body.info.kindModifiers,
|
||||
localizedErrorMessage: response.body.info.localizedErrorMessage,
|
||||
triggerSpan: ts.createTextSpanFromBounds(position, position),
|
||||
fileName: fileName,
|
||||
position: position,
|
||||
findInStrings: findInStrings,
|
||||
findInComments: findInComments,
|
||||
locations: locations
|
||||
};
|
||||
}
|
||||
|
||||
findRenameLocations(fileName: string, position: number, findInStrings: boolean, findInComments: boolean): RenameLocation[] {
|
||||
if (!this.lastRenameEntry ||
|
||||
this.lastRenameEntry.fileName !== fileName ||
|
||||
this.lastRenameEntry.position !== position ||
|
||||
this.lastRenameEntry.findInStrings != findInStrings ||
|
||||
this.lastRenameEntry.findInComments != findInComments) {
|
||||
this.getRenameInfo(fileName, position, findInStrings, findInComments);
|
||||
}
|
||||
|
||||
return this.lastRenameEntry.locations;
|
||||
}
|
||||
|
||||
decodeNavigationBarItems(items: protocol.NavigationBarItem[], fileName: string): NavigationBarItem[] {
|
||||
if (!items) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return items.map(item => ({
|
||||
text: item.text,
|
||||
kind: item.kind,
|
||||
kindModifiers: item.kindModifiers || "",
|
||||
spans: item.spans.map(span=> createTextSpanFromBounds(this.lineColToPosition(fileName, span.start), this.lineColToPosition(fileName, span.end))),
|
||||
childItems: this.decodeNavigationBarItems(item.childItems, fileName),
|
||||
indent: 0,
|
||||
bolded: false,
|
||||
grayed: false
|
||||
}));
|
||||
}
|
||||
|
||||
getNavigationBarItems(fileName: string): NavigationBarItem[] {
|
||||
var args: protocol.FileRequestArgs = {
|
||||
file: fileName
|
||||
};
|
||||
|
||||
var request = this.processRequest<protocol.NavBarRequest>(CommandNames.NavBar, args);
|
||||
var response = this.processResponse<protocol.NavBarResponse>(request);
|
||||
|
||||
return this.decodeNavigationBarItems(response.body, fileName);
|
||||
}
|
||||
|
||||
getNameOrDottedNameSpan(fileName: string, startPos: number, endPos: number): TextSpan {
|
||||
throw new Error("Not Implemented Yet.");
|
||||
}
|
||||
|
||||
getBreakpointStatementAtPosition(fileName: string, position: number): TextSpan {
|
||||
throw new Error("Not Implemented Yet.");
|
||||
}
|
||||
|
||||
getSignatureHelpItems(fileName: string, position: number): SignatureHelpItems {
|
||||
throw new Error("Not Implemented Yet.");
|
||||
}
|
||||
|
||||
getOccurrencesAtPosition(fileName: string, position: number): ReferenceEntry[] {
|
||||
throw new Error("Not Implemented Yet.");
|
||||
}
|
||||
|
||||
getOutliningSpans(fileName: string): OutliningSpan[] {
|
||||
throw new Error("Not Implemented Yet.");
|
||||
}
|
||||
|
||||
getTodoComments(fileName: string, descriptors: TodoCommentDescriptor[]): TodoComment[] {
|
||||
throw new Error("Not Implemented Yet.");
|
||||
}
|
||||
|
||||
getBraceMatchingAtPosition(fileName: string, position: number): TextSpan[] {
|
||||
var lineCol = this.positionToOneBasedLineCol(fileName, position);
|
||||
var args: protocol.FileLocationRequestArgs = {
|
||||
file: fileName,
|
||||
line: lineCol.line,
|
||||
col: lineCol.col,
|
||||
};
|
||||
|
||||
var request = this.processRequest<protocol.BraceRequest>(CommandNames.Brace, args);
|
||||
var response = this.processResponse<protocol.BraceResponse>(request);
|
||||
|
||||
return response.body.map(entry => {
|
||||
var start = this.lineColToPosition(fileName, entry.start);
|
||||
var end = this.lineColToPosition(fileName, entry.end);
|
||||
return {
|
||||
start: start,
|
||||
length: end - start,
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
getIndentationAtPosition(fileName: string, position: number, options: EditorOptions): number {
|
||||
throw new Error("Not Implemented Yet.");
|
||||
}
|
||||
|
||||
getSyntacticClassifications(fileName: string, span: TextSpan): ClassifiedSpan[] {
|
||||
throw new Error("Not Implemented Yet.");
|
||||
}
|
||||
|
||||
getSemanticClassifications(fileName: string, span: TextSpan): ClassifiedSpan[] {
|
||||
throw new Error("Not Implemented Yet.");
|
||||
}
|
||||
|
||||
getProgram(): Program {
|
||||
throw new Error("SourceFile objects are not serializable through the server protocol.");
|
||||
}
|
||||
|
||||
getSourceFile(fileName: string): SourceFile {
|
||||
throw new Error("SourceFile objects are not serializable through the server protocol.");
|
||||
}
|
||||
|
||||
cleanupSemanticCache(): void {
|
||||
throw new Error("cleanupSemanticCache is not available through the server layer.");
|
||||
}
|
||||
|
||||
dispose(): void {
|
||||
throw new Error("dispose is not available through the server layer.");
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
Vendored
+677
@@ -0,0 +1,677 @@
|
||||
// Type definitions for Node.js v0.10.1
|
||||
// Project: http://nodejs.org/
|
||||
// Definitions by: Microsoft TypeScript <http://typescriptlang.org>, DefinitelyTyped <https://github.com/borisyankov/DefinitelyTyped>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
/************************************************
|
||||
* *
|
||||
* Node.js v0.10.1 API *
|
||||
* *
|
||||
************************************************/
|
||||
|
||||
/************************************************
|
||||
* *
|
||||
* GLOBAL *
|
||||
* *
|
||||
************************************************/
|
||||
declare var process: NodeJS.Process;
|
||||
declare var global: any;
|
||||
|
||||
declare var __filename: string;
|
||||
declare var __dirname: string;
|
||||
|
||||
declare function setTimeout(callback: (...args: any[]) => void, ms: number, ...args: any[]): NodeJS.Timer;
|
||||
declare function clearTimeout(timeoutId: NodeJS.Timer): void;
|
||||
declare function setInterval(callback: (...args: any[]) => void, ms: number, ...args: any[]): NodeJS.Timer;
|
||||
declare function clearInterval(intervalId: NodeJS.Timer): void;
|
||||
declare function setImmediate(callback: (...args: any[]) => void, ...args: any[]): any;
|
||||
declare function clearImmediate(immediateId: any): void;
|
||||
|
||||
declare var require: {
|
||||
(id: string): any;
|
||||
resolve(id: string): string;
|
||||
cache: any;
|
||||
extensions: any;
|
||||
main: any;
|
||||
};
|
||||
|
||||
declare var module: {
|
||||
exports: any;
|
||||
require(id: string): any;
|
||||
id: string;
|
||||
filename: string;
|
||||
loaded: boolean;
|
||||
parent: any;
|
||||
children: any[];
|
||||
};
|
||||
|
||||
// Same as module.exports
|
||||
declare var exports: any;
|
||||
declare var SlowBuffer: {
|
||||
new (str: string, encoding?: string): Buffer;
|
||||
new (size: number): Buffer;
|
||||
new (size: Uint8Array): Buffer;
|
||||
new (array: any[]): Buffer;
|
||||
prototype: Buffer;
|
||||
isBuffer(obj: any): boolean;
|
||||
byteLength(string: string, encoding?: string): number;
|
||||
concat(list: Buffer[], totalLength?: number): Buffer;
|
||||
};
|
||||
|
||||
|
||||
// Buffer class
|
||||
interface Buffer extends NodeBuffer { }
|
||||
interface BufferConstructor {
|
||||
new (str: string, encoding ?: string): Buffer;
|
||||
new (size: number): Buffer;
|
||||
new (size: Uint8Array): Buffer;
|
||||
new (array: any[]): Buffer;
|
||||
prototype: Buffer;
|
||||
isBuffer(obj: any): boolean;
|
||||
byteLength(string: string, encoding ?: string): number;
|
||||
concat(list: Buffer[], totalLength ?: number): Buffer;
|
||||
}
|
||||
declare var Buffer: BufferConstructor;
|
||||
|
||||
/************************************************
|
||||
* *
|
||||
* GLOBAL INTERFACES *
|
||||
* *
|
||||
************************************************/
|
||||
declare module NodeJS {
|
||||
export interface ErrnoException extends Error {
|
||||
errno?: any;
|
||||
code?: string;
|
||||
path?: string;
|
||||
syscall?: string;
|
||||
}
|
||||
|
||||
export interface EventEmitter {
|
||||
addListener(event: string, listener: Function): EventEmitter;
|
||||
on(event: string, listener: Function): EventEmitter;
|
||||
once(event: string, listener: Function): EventEmitter;
|
||||
removeListener(event: string, listener: Function): EventEmitter;
|
||||
removeAllListeners(event?: string): EventEmitter;
|
||||
setMaxListeners(n: number): void;
|
||||
listeners(event: string): Function[];
|
||||
emit(event: string, ...args: any[]): boolean;
|
||||
}
|
||||
|
||||
export interface ReadableStream extends EventEmitter {
|
||||
readable: boolean;
|
||||
read(size?: number): any;
|
||||
setEncoding(encoding: string): void;
|
||||
pause(): void;
|
||||
resume(): void;
|
||||
pipe<T extends WritableStream>(destination: T, options?: { end?: boolean; }): T;
|
||||
unpipe<T extends WritableStream>(destination?: T): void;
|
||||
unshift(chunk: string): void;
|
||||
unshift(chunk: Buffer): void;
|
||||
wrap(oldStream: ReadableStream): ReadableStream;
|
||||
}
|
||||
|
||||
export interface WritableStream extends EventEmitter {
|
||||
writable: boolean;
|
||||
write(buffer: Buffer, cb?: Function): boolean;
|
||||
write(str: string, cb?: Function): boolean;
|
||||
write(str: string, encoding?: string, cb?: Function): boolean;
|
||||
end(): void;
|
||||
end(buffer: Buffer, cb?: Function): void;
|
||||
end(str: string, cb?: Function): void;
|
||||
end(str: string, encoding?: string, cb?: Function): void;
|
||||
}
|
||||
|
||||
export interface ReadWriteStream extends ReadableStream, WritableStream { }
|
||||
|
||||
export interface Process extends EventEmitter {
|
||||
stdout: WritableStream;
|
||||
stderr: WritableStream;
|
||||
stdin: ReadableStream;
|
||||
argv: string[];
|
||||
execPath: string;
|
||||
abort(): void;
|
||||
chdir(directory: string): void;
|
||||
cwd(): string;
|
||||
env: any;
|
||||
exit(code?: number): void;
|
||||
getgid(): number;
|
||||
setgid(id: number): void;
|
||||
setgid(id: string): void;
|
||||
getuid(): number;
|
||||
setuid(id: number): void;
|
||||
setuid(id: string): void;
|
||||
version: string;
|
||||
versions: {
|
||||
http_parser: string;
|
||||
node: string;
|
||||
v8: string;
|
||||
ares: string;
|
||||
uv: string;
|
||||
zlib: string;
|
||||
openssl: string;
|
||||
};
|
||||
config: {
|
||||
target_defaults: {
|
||||
cflags: any[];
|
||||
default_configuration: string;
|
||||
defines: string[];
|
||||
include_dirs: string[];
|
||||
libraries: string[];
|
||||
};
|
||||
variables: {
|
||||
clang: number;
|
||||
host_arch: string;
|
||||
node_install_npm: boolean;
|
||||
node_install_waf: boolean;
|
||||
node_prefix: string;
|
||||
node_shared_openssl: boolean;
|
||||
node_shared_v8: boolean;
|
||||
node_shared_zlib: boolean;
|
||||
node_use_dtrace: boolean;
|
||||
node_use_etw: boolean;
|
||||
node_use_openssl: boolean;
|
||||
target_arch: string;
|
||||
v8_no_strict_aliasing: number;
|
||||
v8_use_snapshot: boolean;
|
||||
visibility: string;
|
||||
};
|
||||
};
|
||||
kill(pid: number, signal?: string): void;
|
||||
pid: number;
|
||||
title: string;
|
||||
arch: string;
|
||||
platform: string;
|
||||
memoryUsage(): { rss: number; heapTotal: number; heapUsed: number; };
|
||||
nextTick(callback: Function): void;
|
||||
umask(mask?: number): number;
|
||||
uptime(): number;
|
||||
hrtime(time?: number[]): number[];
|
||||
|
||||
// Worker
|
||||
send? (message: any, sendHandle?: any): void;
|
||||
}
|
||||
|
||||
export interface Timer {
|
||||
ref(): void;
|
||||
unref(): void;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
interface NodeBuffer {
|
||||
[index: number]: number;
|
||||
write(string: string, offset?: number, length?: number, encoding?: string): number;
|
||||
toString(encoding?: string, start?: number, end?: number): string;
|
||||
toJSON(): any;
|
||||
length: number;
|
||||
copy(targetBuffer: Buffer, targetStart?: number, sourceStart?: number, sourceEnd?: number): number;
|
||||
slice(start?: number, end?: number): Buffer;
|
||||
readUInt8(offset: number, noAsset?: boolean): number;
|
||||
readUInt16LE(offset: number, noAssert?: boolean): number;
|
||||
readUInt16BE(offset: number, noAssert?: boolean): number;
|
||||
readUInt32LE(offset: number, noAssert?: boolean): number;
|
||||
readUInt32BE(offset: number, noAssert?: boolean): number;
|
||||
readInt8(offset: number, noAssert?: boolean): number;
|
||||
readInt16LE(offset: number, noAssert?: boolean): number;
|
||||
readInt16BE(offset: number, noAssert?: boolean): number;
|
||||
readInt32LE(offset: number, noAssert?: boolean): number;
|
||||
readInt32BE(offset: number, noAssert?: boolean): number;
|
||||
readFloatLE(offset: number, noAssert?: boolean): number;
|
||||
readFloatBE(offset: number, noAssert?: boolean): number;
|
||||
readDoubleLE(offset: number, noAssert?: boolean): number;
|
||||
readDoubleBE(offset: number, noAssert?: boolean): number;
|
||||
writeUInt8(value: number, offset: number, noAssert?: boolean): void;
|
||||
writeUInt16LE(value: number, offset: number, noAssert?: boolean): void;
|
||||
writeUInt16BE(value: number, offset: number, noAssert?: boolean): void;
|
||||
writeUInt32LE(value: number, offset: number, noAssert?: boolean): void;
|
||||
writeUInt32BE(value: number, offset: number, noAssert?: boolean): void;
|
||||
writeInt8(value: number, offset: number, noAssert?: boolean): void;
|
||||
writeInt16LE(value: number, offset: number, noAssert?: boolean): void;
|
||||
writeInt16BE(value: number, offset: number, noAssert?: boolean): void;
|
||||
writeInt32LE(value: number, offset: number, noAssert?: boolean): void;
|
||||
writeInt32BE(value: number, offset: number, noAssert?: boolean): void;
|
||||
writeFloatLE(value: number, offset: number, noAssert?: boolean): void;
|
||||
writeFloatBE(value: number, offset: number, noAssert?: boolean): void;
|
||||
writeDoubleLE(value: number, offset: number, noAssert?: boolean): void;
|
||||
writeDoubleBE(value: number, offset: number, noAssert?: boolean): void;
|
||||
fill(value: any, offset?: number, end?: number): void;
|
||||
}
|
||||
|
||||
declare module NodeJS {
|
||||
export interface Path {
|
||||
normalize(p: string): string;
|
||||
join(...paths: any[]): string;
|
||||
resolve(...pathSegments: any[]): string;
|
||||
relative(from: string, to: string): string;
|
||||
dirname(p: string): string;
|
||||
basename(p: string, ext?: string): string;
|
||||
extname(p: string): string;
|
||||
sep: string;
|
||||
}
|
||||
}
|
||||
|
||||
declare module NodeJS {
|
||||
export interface ReadLineInstance extends EventEmitter {
|
||||
setPrompt(prompt: string, length: number): void;
|
||||
prompt(preserveCursor?: boolean): void;
|
||||
question(query: string, callback: Function): void;
|
||||
pause(): void;
|
||||
resume(): void;
|
||||
close(): void;
|
||||
write(data: any, key?: any): void;
|
||||
}
|
||||
export interface ReadLineOptions {
|
||||
input: NodeJS.ReadableStream;
|
||||
output: NodeJS.WritableStream;
|
||||
completer?: Function;
|
||||
terminal?: boolean;
|
||||
}
|
||||
|
||||
export interface ReadLine {
|
||||
createInterface(options: ReadLineOptions): ReadLineInstance;
|
||||
}
|
||||
}
|
||||
|
||||
declare module NodeJS {
|
||||
module events {
|
||||
export class EventEmitter implements NodeJS.EventEmitter {
|
||||
static listenerCount(emitter: EventEmitter, event: string): number;
|
||||
|
||||
addListener(event: string, listener: Function): EventEmitter;
|
||||
on(event: string, listener: Function): EventEmitter;
|
||||
once(event: string, listener: Function): EventEmitter;
|
||||
removeListener(event: string, listener: Function): EventEmitter;
|
||||
removeAllListeners(event?: string): EventEmitter;
|
||||
setMaxListeners(n: number): void;
|
||||
listeners(event: string): Function[];
|
||||
emit(event: string, ...args: any[]): boolean;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
declare module NodeJS {
|
||||
module stream {
|
||||
|
||||
export interface Stream extends events.EventEmitter {
|
||||
pipe<T extends NodeJS.WritableStream>(destination: T, options?: { end?: boolean; }): T;
|
||||
}
|
||||
|
||||
export interface ReadableOptions {
|
||||
highWaterMark?: number;
|
||||
encoding?: string;
|
||||
objectMode?: boolean;
|
||||
}
|
||||
|
||||
export class Readable extends events.EventEmitter implements NodeJS.ReadableStream {
|
||||
readable: boolean;
|
||||
constructor(opts?: ReadableOptions);
|
||||
_read(size: number): void;
|
||||
read(size?: number): any;
|
||||
setEncoding(encoding: string): void;
|
||||
pause(): void;
|
||||
resume(): void;
|
||||
pipe<T extends NodeJS.WritableStream>(destination: T, options?: { end?: boolean; }): T;
|
||||
unpipe<T extends NodeJS.WritableStream>(destination?: T): void;
|
||||
unshift(chunk: string): void;
|
||||
unshift(chunk: Buffer): void;
|
||||
wrap(oldStream: NodeJS.ReadableStream): NodeJS.ReadableStream;
|
||||
push(chunk: any, encoding?: string): boolean;
|
||||
}
|
||||
|
||||
export interface WritableOptions {
|
||||
highWaterMark?: number;
|
||||
decodeStrings?: boolean;
|
||||
}
|
||||
|
||||
export class Writable extends events.EventEmitter implements NodeJS.WritableStream {
|
||||
writable: boolean;
|
||||
constructor(opts?: WritableOptions);
|
||||
_write(data: Buffer, encoding: string, callback: Function): void;
|
||||
_write(data: string, encoding: string, callback: Function): void;
|
||||
write(buffer: Buffer, cb?: Function): boolean;
|
||||
write(str: string, cb?: Function): boolean;
|
||||
write(str: string, encoding?: string, cb?: Function): boolean;
|
||||
end(): void;
|
||||
end(buffer: Buffer, cb?: Function): void;
|
||||
end(str: string, cb?: Function): void;
|
||||
end(str: string, encoding?: string, cb?: Function): void;
|
||||
}
|
||||
|
||||
export interface DuplexOptions extends ReadableOptions, WritableOptions {
|
||||
allowHalfOpen?: boolean;
|
||||
}
|
||||
|
||||
// Note: Duplex extends both Readable and Writable.
|
||||
export class Duplex extends Readable implements NodeJS.ReadWriteStream {
|
||||
writable: boolean;
|
||||
constructor(opts?: DuplexOptions);
|
||||
_write(data: Buffer, encoding: string, callback: Function): void;
|
||||
_write(data: string, encoding: string, callback: Function): void;
|
||||
write(buffer: Buffer, cb?: Function): boolean;
|
||||
write(str: string, cb?: Function): boolean;
|
||||
write(str: string, encoding?: string, cb?: Function): boolean;
|
||||
end(): void;
|
||||
end(buffer: Buffer, cb?: Function): void;
|
||||
end(str: string, cb?: Function): void;
|
||||
end(str: string, encoding?: string, cb?: Function): void;
|
||||
}
|
||||
|
||||
export interface TransformOptions extends ReadableOptions, WritableOptions { }
|
||||
|
||||
// Note: Transform lacks the _read and _write methods of Readable/Writable.
|
||||
export class Transform extends events.EventEmitter implements NodeJS.ReadWriteStream {
|
||||
readable: boolean;
|
||||
writable: boolean;
|
||||
constructor(opts?: TransformOptions);
|
||||
_transform(chunk: Buffer, encoding: string, callback: Function): void;
|
||||
_transform(chunk: string, encoding: string, callback: Function): void;
|
||||
_flush(callback: Function): void;
|
||||
read(size?: number): any;
|
||||
setEncoding(encoding: string): void;
|
||||
pause(): void;
|
||||
resume(): void;
|
||||
pipe<T extends NodeJS.WritableStream>(destination: T, options?: { end?: boolean; }): T;
|
||||
unpipe<T extends NodeJS.WritableStream>(destination?: T): void;
|
||||
unshift(chunk: string): void;
|
||||
unshift(chunk: Buffer): void;
|
||||
wrap(oldStream: NodeJS.ReadableStream): NodeJS.ReadableStream;
|
||||
push(chunk: any, encoding?: string): boolean;
|
||||
write(buffer: Buffer, cb?: Function): boolean;
|
||||
write(str: string, cb?: Function): boolean;
|
||||
write(str: string, encoding?: string, cb?: Function): boolean;
|
||||
end(): void;
|
||||
end(buffer: Buffer, cb?: Function): void;
|
||||
end(str: string, cb?: Function): void;
|
||||
end(str: string, encoding?: string, cb?: Function): void;
|
||||
}
|
||||
|
||||
export class PassThrough extends Transform { }
|
||||
}
|
||||
}
|
||||
|
||||
declare module NodeJS {
|
||||
module fs {
|
||||
interface Stats {
|
||||
isFile(): boolean;
|
||||
isDirectory(): boolean;
|
||||
isBlockDevice(): boolean;
|
||||
isCharacterDevice(): boolean;
|
||||
isSymbolicLink(): boolean;
|
||||
isFIFO(): boolean;
|
||||
isSocket(): boolean;
|
||||
dev: number;
|
||||
ino: number;
|
||||
mode: number;
|
||||
nlink: number;
|
||||
uid: number;
|
||||
gid: number;
|
||||
rdev: number;
|
||||
size: number;
|
||||
blksize: number;
|
||||
blocks: number;
|
||||
atime: Date;
|
||||
mtime: Date;
|
||||
ctime: Date;
|
||||
}
|
||||
interface FSWatcher extends events.EventEmitter {
|
||||
close(): void;
|
||||
}
|
||||
|
||||
export interface ReadStream extends stream.Readable { }
|
||||
export interface WriteStream extends stream.Writable { }
|
||||
|
||||
export function rename(oldPath: string, newPath: string, callback?: (err?: NodeJS.ErrnoException) => void): void;
|
||||
export function renameSync(oldPath: string, newPath: string): void;
|
||||
export function truncate(path: string, callback?: (err?: NodeJS.ErrnoException) => void): void;
|
||||
export function truncate(path: string, len: number, callback?: (err?: NodeJS.ErrnoException) => void): void;
|
||||
export function truncateSync(path: string, len?: number): void;
|
||||
export function ftruncate(fd: number, callback?: (err?: NodeJS.ErrnoException) => void): void;
|
||||
export function ftruncate(fd: number, len: number, callback?: (err?: NodeJS.ErrnoException) => void): void;
|
||||
export function ftruncateSync(fd: number, len?: number): void;
|
||||
export function chown(path: string, uid: number, gid: number, callback?: (err?: NodeJS.ErrnoException) => void): void;
|
||||
export function chownSync(path: string, uid: number, gid: number): void;
|
||||
export function fchown(fd: number, uid: number, gid: number, callback?: (err?: NodeJS.ErrnoException) => void): void;
|
||||
export function fchownSync(fd: number, uid: number, gid: number): void;
|
||||
export function lchown(path: string, uid: number, gid: number, callback?: (err?: NodeJS.ErrnoException) => void): void;
|
||||
export function lchownSync(path: string, uid: number, gid: number): void;
|
||||
export function chmod(path: string, mode: number, callback?: (err?: NodeJS.ErrnoException) => void): void;
|
||||
export function chmod(path: string, mode: string, callback?: (err?: NodeJS.ErrnoException) => void): void;
|
||||
export function chmodSync(path: string, mode: number): void;
|
||||
export function chmodSync(path: string, mode: string): void;
|
||||
export function fchmod(fd: number, mode: number, callback?: (err?: NodeJS.ErrnoException) => void): void;
|
||||
export function fchmod(fd: number, mode: string, callback?: (err?: NodeJS.ErrnoException) => void): void;
|
||||
export function fchmodSync(fd: number, mode: number): void;
|
||||
export function fchmodSync(fd: number, mode: string): void;
|
||||
export function lchmod(path: string, mode: number, callback?: (err?: NodeJS.ErrnoException) => void): void;
|
||||
export function lchmod(path: string, mode: string, callback?: (err?: NodeJS.ErrnoException) => void): void;
|
||||
export function lchmodSync(path: string, mode: number): void;
|
||||
export function lchmodSync(path: string, mode: string): void;
|
||||
export function stat(path: string, callback?: (err: NodeJS.ErrnoException, stats: Stats) => any): void;
|
||||
export function lstat(path: string, callback?: (err: NodeJS.ErrnoException, stats: Stats) => any): void;
|
||||
export function fstat(fd: number, callback?: (err: NodeJS.ErrnoException, stats: Stats) => any): void;
|
||||
export function statSync(path: string): Stats;
|
||||
export function lstatSync(path: string): Stats;
|
||||
export function fstatSync(fd: number): Stats;
|
||||
export function link(srcpath: string, dstpath: string, callback?: (err?: NodeJS.ErrnoException) => void): void;
|
||||
export function linkSync(srcpath: string, dstpath: string): void;
|
||||
export function symlink(srcpath: string, dstpath: string, type?: string, callback?: (err?: NodeJS.ErrnoException) => void): void;
|
||||
export function symlinkSync(srcpath: string, dstpath: string, type?: string): void;
|
||||
export function readlink(path: string, callback?: (err: NodeJS.ErrnoException, linkString: string) => any): void;
|
||||
export function readlinkSync(path: string): string;
|
||||
export function realpath(path: string, callback?: (err: NodeJS.ErrnoException, resolvedPath: string) => any): void;
|
||||
export function realpath(path: string, cache: { [path: string]: string }, callback: (err: NodeJS.ErrnoException, resolvedPath: string) => any): void;
|
||||
export function realpathSync(path: string, cache?: { [path: string]: string }): string;
|
||||
export function unlink(path: string, callback?: (err?: NodeJS.ErrnoException) => void): void;
|
||||
export function unlinkSync(path: string): void;
|
||||
export function rmdir(path: string, callback?: (err?: NodeJS.ErrnoException) => void): void;
|
||||
export function rmdirSync(path: string): void;
|
||||
export function mkdir(path: string, callback?: (err?: NodeJS.ErrnoException) => void): void;
|
||||
export function mkdir(path: string, mode: number, callback?: (err?: NodeJS.ErrnoException) => void): void;
|
||||
export function mkdir(path: string, mode: string, callback?: (err?: NodeJS.ErrnoException) => void): void;
|
||||
export function mkdirSync(path: string, mode?: number): void;
|
||||
export function mkdirSync(path: string, mode?: string): void;
|
||||
export function readdir(path: string, callback?: (err: NodeJS.ErrnoException, files: string[]) => void): void;
|
||||
export function readdirSync(path: string): string[];
|
||||
export function close(fd: number, callback?: (err?: NodeJS.ErrnoException) => void): void;
|
||||
export function closeSync(fd: number): void;
|
||||
export function open(path: string, flags: string, callback?: (err: NodeJS.ErrnoException, fd: number) => any): void;
|
||||
export function open(path: string, flags: string, mode: number, callback?: (err: NodeJS.ErrnoException, fd: number) => any): void;
|
||||
export function open(path: string, flags: string, mode: string, callback?: (err: NodeJS.ErrnoException, fd: number) => any): void;
|
||||
export function openSync(path: string, flags: string, mode?: number): number;
|
||||
export function openSync(path: string, flags: string, mode?: string): number;
|
||||
export function utimes(path: string, atime: number, mtime: number, callback?: (err?: NodeJS.ErrnoException) => void): void;
|
||||
export function utimes(path: string, atime: Date, mtime: Date, callback?: (err?: NodeJS.ErrnoException) => void): void;
|
||||
export function utimesSync(path: string, atime: number, mtime: number): void;
|
||||
export function utimesSync(path: string, atime: Date, mtime: Date): void;
|
||||
export function futimes(fd: number, atime: number, mtime: number, callback?: (err?: NodeJS.ErrnoException) => void): void;
|
||||
export function futimes(fd: number, atime: Date, mtime: Date, callback?: (err?: NodeJS.ErrnoException) => void): void;
|
||||
export function futimesSync(fd: number, atime: number, mtime: number): void;
|
||||
export function futimesSync(fd: number, atime: Date, mtime: Date): void;
|
||||
export function fsync(fd: number, callback?: (err?: NodeJS.ErrnoException) => void): void;
|
||||
export function fsyncSync(fd: number): void;
|
||||
export function write(fd: number, buffer: Buffer, offset: number, length: number, position: number, callback?: (err: NodeJS.ErrnoException, written: number, buffer: Buffer) => void): void;
|
||||
export function writeSync(fd: number, buffer: Buffer, offset: number, length: number, position: number): number;
|
||||
export function read(fd: number, buffer: Buffer, offset: number, length: number, position: number, callback?: (err: NodeJS.ErrnoException, bytesRead: number, buffer: Buffer) => void): void;
|
||||
export function readSync(fd: number, buffer: Buffer, offset: number, length: number, position: number): number;
|
||||
export function readFile(filename: string, encoding: string, callback: (err: NodeJS.ErrnoException, data: string) => void): void;
|
||||
export function readFile(filename: string, options: { encoding: string; flag?: string; }, callback: (err: NodeJS.ErrnoException, data: string) => void): void;
|
||||
export function readFile(filename: string, options: { flag?: string; }, callback: (err: NodeJS.ErrnoException, data: Buffer) => void): void;
|
||||
export function readFile(filename: string, callback: (err: NodeJS.ErrnoException, data: Buffer) => void): void;
|
||||
export function readFileSync(filename: string, encoding: string): string;
|
||||
export function readFileSync(filename: string, options: { encoding: string; flag?: string; }): string;
|
||||
export function readFileSync(filename: string, options?: { flag?: string; }): Buffer;
|
||||
export function writeFile(filename: string, data: any, callback?: (err: NodeJS.ErrnoException) => void): void;
|
||||
export function writeFile(filename: string, data: any, options: { encoding?: string; mode?: number; flag?: string; }, callback?: (err: NodeJS.ErrnoException) => void): void;
|
||||
export function writeFile(filename: string, data: any, options: { encoding?: string; mode?: string; flag?: string; }, callback?: (err: NodeJS.ErrnoException) => void): void;
|
||||
export function writeFileSync(filename: string, data: any, options?: { encoding?: string; mode?: number; flag?: string; }): void;
|
||||
export function writeFileSync(filename: string, data: any, options?: { encoding?: string; mode?: string; flag?: string; }): void;
|
||||
export function appendFile(filename: string, data: any, options: { encoding?: string; mode?: number; flag?: string; }, callback?: (err: NodeJS.ErrnoException) => void): void;
|
||||
export function appendFile(filename: string, data: any, options: { encoding?: string; mode?: string; flag?: string; }, callback?: (err: NodeJS.ErrnoException) => void): void;
|
||||
export function appendFile(filename: string, data: any, callback?: (err: NodeJS.ErrnoException) => void): void;
|
||||
export function appendFileSync(filename: string, data: any, options?: { encoding?: string; mode?: number; flag?: string; }): void;
|
||||
export function appendFileSync(filename: string, data: any, options?: { encoding?: string; mode?: string; flag?: string; }): void;
|
||||
export function watchFile(filename: string, listener: (curr: Stats, prev: Stats) => void): void;
|
||||
export function watchFile(filename: string, options: { persistent?: boolean; interval?: number; }, listener: (curr: Stats, prev: Stats) => void): void;
|
||||
export function unwatchFile(filename: string, listener?: (curr: Stats, prev: Stats) => void): void;
|
||||
export function watch(filename: string, listener?: (event: string, filename: string) => any): FSWatcher;
|
||||
export function watch(filename: string, options: { persistent?: boolean; }, listener?: (event: string, filename: string) => any): FSWatcher;
|
||||
export function exists(path: string, callback?: (exists: boolean) => void): void;
|
||||
export function existsSync(path: string): boolean;
|
||||
export function createReadStream(path: string, options?: {
|
||||
flags?: string;
|
||||
encoding?: string;
|
||||
fd?: string;
|
||||
mode?: number;
|
||||
bufferSize?: number;
|
||||
}): ReadStream;
|
||||
export function createReadStream(path: string, options?: {
|
||||
flags?: string;
|
||||
encoding?: string;
|
||||
fd?: string;
|
||||
mode?: string;
|
||||
bufferSize?: number;
|
||||
}): ReadStream;
|
||||
export function createWriteStream(path: string, options?: {
|
||||
flags?: string;
|
||||
encoding?: string;
|
||||
string?: string;
|
||||
}): WriteStream;
|
||||
}
|
||||
}
|
||||
|
||||
declare module NodeJS {
|
||||
module path {
|
||||
export function normalize(p: string): string;
|
||||
export function join(...paths: any[]): string;
|
||||
export function resolve(...pathSegments: any[]): string;
|
||||
export function relative(from: string, to: string): string;
|
||||
export function dirname(p: string): string;
|
||||
export function basename(p: string, ext?: string): string;
|
||||
export function extname(p: string): string;
|
||||
export var sep: string;
|
||||
}
|
||||
}
|
||||
|
||||
declare module NodeJS {
|
||||
module _debugger {
|
||||
export interface Packet {
|
||||
raw: string;
|
||||
headers: string[];
|
||||
body: Message;
|
||||
}
|
||||
|
||||
export interface Message {
|
||||
seq: number;
|
||||
type: string;
|
||||
}
|
||||
|
||||
export interface RequestInfo {
|
||||
command: string;
|
||||
arguments: any;
|
||||
}
|
||||
|
||||
export interface Request extends Message, RequestInfo {
|
||||
}
|
||||
|
||||
export interface Event extends Message {
|
||||
event: string;
|
||||
body?: any;
|
||||
}
|
||||
|
||||
export interface Response extends Message {
|
||||
request_seq: number;
|
||||
success: boolean;
|
||||
/** Contains error message if success == false. */
|
||||
message?: string;
|
||||
/** Contains message body if success == true. */
|
||||
body?: any;
|
||||
}
|
||||
|
||||
export interface BreakpointMessageBody {
|
||||
type: string;
|
||||
target: number;
|
||||
line: number;
|
||||
}
|
||||
|
||||
export class Protocol {
|
||||
res: Packet;
|
||||
state: string;
|
||||
execute(data: string): void;
|
||||
serialize(rq: Request): string;
|
||||
onResponse: (pkt: Packet) => void;
|
||||
}
|
||||
|
||||
export var NO_FRAME: number;
|
||||
export var port: number;
|
||||
|
||||
export interface ScriptDesc {
|
||||
name: string;
|
||||
id: number;
|
||||
isNative?: boolean;
|
||||
handle?: number;
|
||||
type: string;
|
||||
lineOffset?: number;
|
||||
columnOffset?: number;
|
||||
lineCount?: number;
|
||||
}
|
||||
|
||||
export interface Breakpoint {
|
||||
id: number;
|
||||
scriptId: number;
|
||||
script: ScriptDesc;
|
||||
line: number;
|
||||
condition?: string;
|
||||
scriptReq?: string;
|
||||
}
|
||||
|
||||
export interface RequestHandler {
|
||||
(err: boolean, body: Message, res: Packet): void;
|
||||
request_seq?: number;
|
||||
}
|
||||
|
||||
export interface ResponseBodyHandler {
|
||||
(err: boolean, body?: any): void;
|
||||
request_seq?: number;
|
||||
}
|
||||
|
||||
export interface ExceptionInfo {
|
||||
text: string;
|
||||
}
|
||||
|
||||
export interface BreakResponse {
|
||||
script?: ScriptDesc;
|
||||
exception?: ExceptionInfo;
|
||||
sourceLine: number;
|
||||
sourceLineText: string;
|
||||
sourceColumn: number;
|
||||
}
|
||||
|
||||
export function SourceInfo(body: BreakResponse): string;
|
||||
|
||||
export class Client extends events.EventEmitter {
|
||||
protocol: Protocol;
|
||||
scripts: ScriptDesc[];
|
||||
handles: ScriptDesc[];
|
||||
breakpoints: Breakpoint[];
|
||||
currentSourceLine: number;
|
||||
currentSourceColumn: number;
|
||||
currentSourceLineText: string;
|
||||
currentFrame: number;
|
||||
currentScript: string;
|
||||
|
||||
connect(port: number, host: string): void;
|
||||
req(req: any, cb: RequestHandler): void;
|
||||
reqFrameEval(code: string, frame: number, cb: RequestHandler): void;
|
||||
mirrorObject(obj: any, depth: number, cb: ResponseBodyHandler): void;
|
||||
setBreakpoint(rq: BreakpointMessageBody, cb: RequestHandler): void;
|
||||
clearBreakpoint(rq: Request, cb: RequestHandler): void;
|
||||
listbreakpoints(cb: RequestHandler): void;
|
||||
reqSource(from: number, to: number, cb: RequestHandler): void;
|
||||
reqScripts(cb: any): void;
|
||||
reqContinue(cb: RequestHandler): void;
|
||||
}
|
||||
}
|
||||
}
|
||||
Vendored
+832
@@ -0,0 +1,832 @@
|
||||
/**
|
||||
* Declaration module describing the TypeScript Server protocol
|
||||
*/
|
||||
declare module ts.server.protocol {
|
||||
/**
|
||||
* A TypeScript Server message
|
||||
*/
|
||||
export interface Message {
|
||||
/**
|
||||
* Sequence number of the message
|
||||
*/
|
||||
seq: number;
|
||||
|
||||
/**
|
||||
* One of "request", "response", or "event"
|
||||
*/
|
||||
type: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Client-initiated request message
|
||||
*/
|
||||
export interface Request extends Message {
|
||||
/**
|
||||
* The command to execute
|
||||
*/
|
||||
command: string;
|
||||
|
||||
/**
|
||||
* Object containing arguments for the command
|
||||
*/
|
||||
arguments?: any;
|
||||
}
|
||||
|
||||
/**
|
||||
* Server-initiated event message
|
||||
*/
|
||||
export interface Event extends Message {
|
||||
/**
|
||||
* Name of event
|
||||
*/
|
||||
event: string;
|
||||
|
||||
/**
|
||||
* Event-specific information
|
||||
*/
|
||||
body?: any;
|
||||
}
|
||||
|
||||
/**
|
||||
* Response by server to client request message.
|
||||
*/
|
||||
export interface Response extends Message {
|
||||
/**
|
||||
* Sequence number of the request message.
|
||||
*/
|
||||
request_seq: number;
|
||||
|
||||
/**
|
||||
* Outcome of the request.
|
||||
*/
|
||||
success: boolean;
|
||||
|
||||
/**
|
||||
* The command requested.
|
||||
*/
|
||||
command: string;
|
||||
|
||||
/**
|
||||
* Contains error message if success == false.
|
||||
*/
|
||||
message?: string;
|
||||
|
||||
/**
|
||||
* Contains message body if success == true.
|
||||
*/
|
||||
body?: any;
|
||||
}
|
||||
|
||||
/**
|
||||
* Arguments for FileRequest messages.
|
||||
*/
|
||||
export interface FileRequestArgs {
|
||||
/**
|
||||
* The file for the request (absolute pathname required).
|
||||
*/
|
||||
file: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Request whose sole parameter is a file name.
|
||||
*/
|
||||
export interface FileRequest extends Request {
|
||||
arguments: FileRequestArgs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Instances of this interface specify a location in a source file:
|
||||
* (file, line, col), where line and column are 1-based.
|
||||
*/
|
||||
export interface FileLocationRequestArgs extends FileRequestArgs {
|
||||
/**
|
||||
* The line number for the request (1-based).
|
||||
*/
|
||||
line: number;
|
||||
|
||||
/**
|
||||
* The column for the request (1-based).
|
||||
*/
|
||||
col: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* A request whose arguments specify a file location (file, line, col).
|
||||
*/
|
||||
export interface FileLocationRequest extends FileRequest {
|
||||
arguments: FileLocationRequestArgs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Go to definition request; value of command field is
|
||||
* "definition". Return response giving the file locations that
|
||||
* define the symbol found in file at location line, col.
|
||||
*/
|
||||
export interface DefinitionRequest extends FileLocationRequest {
|
||||
}
|
||||
|
||||
/**
|
||||
* Location in source code expressed as (one-based) line and column.
|
||||
*/
|
||||
export interface Location {
|
||||
line: number;
|
||||
col: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* Object found in response messages defining a span of text in source code.
|
||||
*/
|
||||
export interface TextSpan {
|
||||
/**
|
||||
* First character of the definition.
|
||||
*/
|
||||
start: Location;
|
||||
|
||||
/**
|
||||
* One character past last character of the definition.
|
||||
*/
|
||||
end: Location;
|
||||
}
|
||||
|
||||
/**
|
||||
* Object found in response messages defining a span of text in a specific source file.
|
||||
*/
|
||||
export interface FileSpan extends TextSpan {
|
||||
/**
|
||||
* File containing text span.
|
||||
*/
|
||||
file: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Definition response message. Gives text range for definition.
|
||||
*/
|
||||
export interface DefinitionResponse extends Response {
|
||||
body?: FileSpan[];
|
||||
}
|
||||
|
||||
/**
|
||||
* Find references request; value of command field is
|
||||
* "references". Return response giving the file locations that
|
||||
* reference the symbol found in file at location line, col.
|
||||
*/
|
||||
export interface ReferencesRequest extends FileLocationRequest {
|
||||
}
|
||||
|
||||
export interface ReferencesResponseItem extends FileSpan {
|
||||
/** Text of line containing the reference. Including this
|
||||
* with the response avoids latency of editor loading files
|
||||
* to show text of reference line (the server already has
|
||||
* loaded the referencing files).
|
||||
*/
|
||||
lineText: string;
|
||||
|
||||
/**
|
||||
* True if reference is a write location, false otherwise.
|
||||
*/
|
||||
isWriteAccess: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* The body of a "references" response message.
|
||||
*/
|
||||
export interface ReferencesResponseBody {
|
||||
/**
|
||||
* The file locations referencing the symbol.
|
||||
*/
|
||||
refs: ReferencesResponseItem[];
|
||||
|
||||
/**
|
||||
* The name of the symbol.
|
||||
*/
|
||||
symbolName: string;
|
||||
|
||||
/**
|
||||
* The start column of the symbol (on the line provided by the references request).
|
||||
*/
|
||||
symbolStartCol: number;
|
||||
|
||||
/**
|
||||
* The full display name of the symbol.
|
||||
*/
|
||||
symbolDisplayString: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Response to "references" request.
|
||||
*/
|
||||
export interface ReferencesResponse extends Response {
|
||||
body?: ReferencesResponseBody;
|
||||
}
|
||||
|
||||
export interface RenameRequestArgs extends FileLocationRequestArgs {
|
||||
findInComments?: boolean;
|
||||
findInStrings?: boolean;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Rename request; value of command field is "rename". Return
|
||||
* response giving the file locations that reference the symbol
|
||||
* found in file at location line, col. Also return full display
|
||||
* name of the symbol so that client can print it unambiguously.
|
||||
*/
|
||||
export interface RenameRequest extends FileLocationRequest {
|
||||
arguments: RenameRequestArgs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Information about the item to be renamed.
|
||||
*/
|
||||
export interface RenameInfo {
|
||||
/**
|
||||
* True if item can be renamed.
|
||||
*/
|
||||
canRename: boolean;
|
||||
|
||||
/**
|
||||
* Error message if item can not be renamed.
|
||||
*/
|
||||
localizedErrorMessage?: string;
|
||||
|
||||
/**
|
||||
* Display name of the item to be renamed.
|
||||
*/
|
||||
displayName: string;
|
||||
|
||||
/**
|
||||
* Full display name of item to be renamed.
|
||||
*/
|
||||
fullDisplayName: string;
|
||||
|
||||
/**
|
||||
* The items's kind (such as 'className' or 'parameterName' or plain 'text').
|
||||
*/
|
||||
kind: string;
|
||||
|
||||
/**
|
||||
* Optional modifiers for the kind (such as 'public').
|
||||
*/
|
||||
kindModifiers: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* A group of text spans, all in 'file'.
|
||||
*/
|
||||
export interface SpanGroup {
|
||||
/** The file to which the spans apply */
|
||||
file: string;
|
||||
/** The text spans in this group */
|
||||
locs: TextSpan[];
|
||||
}
|
||||
|
||||
export interface RenameResponseBody {
|
||||
/**
|
||||
* Information about the item to be renamed.
|
||||
*/
|
||||
info: RenameInfo;
|
||||
|
||||
/**
|
||||
* An array of span groups (one per file) that refer to the item to be renamed.
|
||||
*/
|
||||
locs: SpanGroup[];
|
||||
}
|
||||
|
||||
/**
|
||||
* Rename response message.
|
||||
*/
|
||||
export interface RenameResponse extends Response {
|
||||
body?: RenameResponseBody;
|
||||
}
|
||||
|
||||
/**
|
||||
* Open request; value of command field is "open". Notify the
|
||||
* server that the client has file open. The server will not
|
||||
* monitor the filesystem for changes in this file and will assume
|
||||
* that the client is updating the server (using the change and/or
|
||||
* reload messages) when the file changes. Server does not currently
|
||||
* send a response to an open request.
|
||||
*/
|
||||
export interface OpenRequest extends FileRequest {
|
||||
}
|
||||
|
||||
/**
|
||||
* Close request; value of command field is "close". Notify the
|
||||
* server that the client has closed a previously open file. If
|
||||
* file is still referenced by open files, the server will resume
|
||||
* monitoring the filesystem for changes to file. Server does not
|
||||
* currently send a response to a close request.
|
||||
*/
|
||||
export interface CloseRequest extends FileRequest {
|
||||
}
|
||||
|
||||
/**
|
||||
* Quickinfo request; value of command field is
|
||||
* "quickinfo". Return response giving a quick type and
|
||||
* documentation string for the symbol found in file at location
|
||||
* line, col.
|
||||
*/
|
||||
export interface QuickInfoRequest extends FileLocationRequest {
|
||||
}
|
||||
|
||||
/**
|
||||
* Body of QuickInfoResponse.
|
||||
*/
|
||||
export interface QuickInfoResponseBody {
|
||||
/**
|
||||
* The symbol's kind (such as 'className' or 'parameterName' or plain 'text').
|
||||
*/
|
||||
kind: string;
|
||||
|
||||
/**
|
||||
* Optional modifiers for the kind (such as 'public').
|
||||
*/
|
||||
kindModifiers: string;
|
||||
|
||||
/**
|
||||
* Starting file location of symbol.
|
||||
*/
|
||||
start: Location;
|
||||
|
||||
/**
|
||||
* One past last character of symbol.
|
||||
*/
|
||||
end: Location;
|
||||
|
||||
/**
|
||||
* Type and kind of symbol.
|
||||
*/
|
||||
displayString: string;
|
||||
|
||||
/**
|
||||
* Documentation associated with symbol.
|
||||
*/
|
||||
documentation: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Quickinfo response message.
|
||||
*/
|
||||
export interface QuickInfoResponse extends Response {
|
||||
body?: QuickInfoResponseBody;
|
||||
}
|
||||
|
||||
/**
|
||||
* Arguments for format messages.
|
||||
*/
|
||||
export interface FormatRequestArgs extends FileLocationRequestArgs {
|
||||
/**
|
||||
* Last line of range for which to format text in file.
|
||||
*/
|
||||
endLine: number;
|
||||
|
||||
/**
|
||||
* Last column of range for which to format text in file.
|
||||
*/
|
||||
endCol: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* Format request; value of command field is "format". Return
|
||||
* response giving zero or more edit instructions. The edit
|
||||
* instructions will be sorted in file order. Applying the edit
|
||||
* instructions in reverse to file will result in correctly
|
||||
* reformatted text.
|
||||
*/
|
||||
export interface FormatRequest extends FileLocationRequest {
|
||||
arguments: FormatRequestArgs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Object found in response messages defining an editing
|
||||
* instruction for a span of text in source code. The effect of
|
||||
* this instruction is to replace the text starting at start and
|
||||
* ending one character before end with newText. For an insertion,
|
||||
* the text span is empty. For a deletion, newText is empty.
|
||||
*/
|
||||
export interface CodeEdit {
|
||||
/**
|
||||
* First character of the text span to edit.
|
||||
*/
|
||||
start: Location;
|
||||
|
||||
/**
|
||||
* One character past last character of the text span to edit.
|
||||
*/
|
||||
end: Location;
|
||||
|
||||
/**
|
||||
* Replace the span defined above with this string (may be
|
||||
* the empty string).
|
||||
*/
|
||||
newText: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Format and format on key response message.
|
||||
*/
|
||||
export interface FormatResponse extends Response {
|
||||
body?: CodeEdit[];
|
||||
}
|
||||
|
||||
/**
|
||||
* Arguments for format on key messages.
|
||||
*/
|
||||
export interface FormatOnKeyRequestArgs extends FileLocationRequestArgs {
|
||||
/**
|
||||
* Key pressed (';', '\n', or '}').
|
||||
*/
|
||||
key: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Format on key request; value of command field is
|
||||
* "formatonkey". Given file location and key typed (as string),
|
||||
* return response giving zero or more edit instructions. The
|
||||
* edit instructions will be sorted in file order. Applying the
|
||||
* edit instructions in reverse to file will result in correctly
|
||||
* reformatted text.
|
||||
*/
|
||||
export interface FormatOnKeyRequest extends FileLocationRequest {
|
||||
arguments: FormatOnKeyRequestArgs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Arguments for completions messages.
|
||||
*/
|
||||
export interface CompletionsRequestArgs extends FileLocationRequestArgs {
|
||||
/**
|
||||
* Optional prefix to apply to possible completions.
|
||||
*/
|
||||
prefix?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Completions request; value of command field is "completions".
|
||||
* Given a file location (file, line, col) and a prefix (which may
|
||||
* be the empty string), return the possible completions that
|
||||
* begin with prefix.
|
||||
*/
|
||||
export interface CompletionsRequest extends FileLocationRequest {
|
||||
arguments: CompletionsRequestArgs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Arguments for completion details request.
|
||||
*/
|
||||
export interface CompletionDetailsRequestArgs extends FileLocationRequestArgs {
|
||||
/**
|
||||
* Names of one or more entries for which to obtain details.
|
||||
*/
|
||||
entryNames: string[];
|
||||
}
|
||||
|
||||
/**
|
||||
* Completion entry details request; value of command field is
|
||||
* "completionEntryDetails". Given a file location (file, line,
|
||||
* col) and an array of completion entry names return more
|
||||
* detailed information for each completion entry.
|
||||
*/
|
||||
export interface CompletionDetailsRequest extends FileLocationRequest {
|
||||
arguments: CompletionDetailsRequestArgs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Part of a symbol description.
|
||||
*/
|
||||
export interface SymbolDisplayPart {
|
||||
/**
|
||||
* Text of an item describing the symbol.
|
||||
*/
|
||||
text: string;
|
||||
|
||||
/**
|
||||
* The symbol's kind (such as 'className' or 'parameterName' or plain 'text').
|
||||
*/
|
||||
kind: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* An item found in a completion response.
|
||||
*/
|
||||
export interface CompletionEntry {
|
||||
/**
|
||||
* The symbol's name.
|
||||
*/
|
||||
name: string;
|
||||
/**
|
||||
* The symbol's kind (such as 'className' or 'parameterName').
|
||||
*/
|
||||
kind: string;
|
||||
/**
|
||||
* Optional modifiers for the kind (such as 'public').
|
||||
*/
|
||||
kindModifiers: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Additional completion entry details, available on demand
|
||||
*/
|
||||
export interface CompletionEntryDetails extends CompletionEntry {
|
||||
/**
|
||||
* Display parts of the symbol (similar to quick info).
|
||||
*/
|
||||
displayParts: SymbolDisplayPart[];
|
||||
|
||||
/**
|
||||
* Documentation strings for the symbol.
|
||||
*/
|
||||
documentation: SymbolDisplayPart[];
|
||||
}
|
||||
|
||||
export interface CompletionsResponse extends Response {
|
||||
body?: CompletionEntry[];
|
||||
}
|
||||
|
||||
export interface CompletionDetailsResponse extends Response {
|
||||
body?: CompletionEntryDetails[];
|
||||
}
|
||||
|
||||
/**
|
||||
* Arguments for geterr messages.
|
||||
*/
|
||||
export interface GeterrRequestArgs {
|
||||
/**
|
||||
* List of file names for which to compute compiler errors.
|
||||
* The files will be checked in list order.
|
||||
*/
|
||||
files: string[];
|
||||
|
||||
/**
|
||||
* Delay in milliseconds to wait before starting to compute
|
||||
* errors for the files in the file list
|
||||
*/
|
||||
delay: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* Geterr request; value of command field is "geterr". Wait for
|
||||
* delay milliseconds and then, if during the wait no change or
|
||||
* reload messages have arrived for the first file in the files
|
||||
* list, get the syntactic errors for the file, field requests,
|
||||
* and then get the semantic errors for the file. Repeat with a
|
||||
* smaller delay for each subsequent file on the files list. Best
|
||||
* practice for an editor is to send a file list containing each
|
||||
* file that is currently visible, in most-recently-used order.
|
||||
*/
|
||||
export interface GeterrRequest extends Request {
|
||||
arguments: GeterrRequestArgs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Item of diagnostic information found in a DiagnosticEvent message.
|
||||
*/
|
||||
export interface Diagnostic {
|
||||
/**
|
||||
* Starting file location at which text appies.
|
||||
*/
|
||||
start: Location;
|
||||
|
||||
/**
|
||||
* The last file location at which the text applies.
|
||||
*/
|
||||
end: Location;
|
||||
|
||||
/**
|
||||
* Text of diagnostic message.
|
||||
*/
|
||||
text: string;
|
||||
}
|
||||
|
||||
export interface DiagnosticEventBody {
|
||||
/**
|
||||
* The file for which diagnostic information is reported.
|
||||
*/
|
||||
file: string;
|
||||
|
||||
/**
|
||||
* An array of diagnostic information items.
|
||||
*/
|
||||
diagnostics: Diagnostic[];
|
||||
}
|
||||
|
||||
/**
|
||||
* Event message for "syntaxDiag" and "semanticDiag" event types.
|
||||
* These events provide syntactic and semantic errors for a file.
|
||||
*/
|
||||
export interface DiagnosticEvent extends Event {
|
||||
body?: DiagnosticEventBody;
|
||||
}
|
||||
|
||||
/**
|
||||
* Arguments for reload request.
|
||||
*/
|
||||
export interface ReloadRequestArgs extends FileRequestArgs {
|
||||
/**
|
||||
* Name of temporary file from which to reload file
|
||||
* contents. May be same as file.
|
||||
*/
|
||||
tmpfile: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reload request message; value of command field is "reload".
|
||||
* Reload contents of file with name given by the 'file' argument
|
||||
* from temporary file with name given by the 'tmpfile' argument.
|
||||
* The two names can be identical.
|
||||
*/
|
||||
export interface ReloadRequest extends FileRequest {
|
||||
arguments: ReloadRequestArgs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Response to "reload" request. This is just an acknowledgement, so
|
||||
* no body field is required.
|
||||
*/
|
||||
export interface ReloadResponse extends Response {
|
||||
}
|
||||
|
||||
/**
|
||||
* Arguments for saveto request.
|
||||
*/
|
||||
export interface SavetoRequestArgs extends FileRequestArgs {
|
||||
/**
|
||||
* Name of temporary file into which to save server's view of
|
||||
* file contents.
|
||||
*/
|
||||
tmpfile: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Saveto request message; value of command field is "saveto".
|
||||
* For debugging purposes, save to a temporaryfile (named by
|
||||
* argument 'tmpfile') the contents of file named by argument
|
||||
* 'file'. The server does not currently send a response to a
|
||||
* "saveto" request.
|
||||
*/
|
||||
export interface SavetoRequest extends FileRequest {
|
||||
arguments: SavetoRequestArgs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Arguments for navto request message.
|
||||
*/
|
||||
export interface NavtoRequestArgs extends FileRequestArgs {
|
||||
/**
|
||||
* Search term to navigate to from current location; term can
|
||||
* be '.*' or an identifier prefix.
|
||||
*/
|
||||
searchValue: string;
|
||||
/**
|
||||
* Optional limit on the number of items to return.
|
||||
*/
|
||||
maxResultCount?: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* Navto request message; value of command field is "navto".
|
||||
* Return list of objects giving file locations and symbols that
|
||||
* match the search term given in argument 'searchTerm'. The
|
||||
* context for the search is given by the named file.
|
||||
*/
|
||||
export interface NavtoRequest extends FileRequest {
|
||||
arguments: NavtoRequestArgs;
|
||||
}
|
||||
|
||||
/**
|
||||
* An item found in a navto response.
|
||||
*/
|
||||
export interface NavtoItem {
|
||||
/**
|
||||
* The symbol's name.
|
||||
*/
|
||||
name: string;
|
||||
|
||||
/**
|
||||
* The symbol's kind (such as 'className' or 'parameterName').
|
||||
*/
|
||||
kind: string;
|
||||
|
||||
/**
|
||||
* exact, substring, or prefix.
|
||||
*/
|
||||
matchKind?: string;
|
||||
|
||||
/**
|
||||
* If this was a case sensitive or insensitive match.
|
||||
*/
|
||||
isCaseSensitive?: boolean;
|
||||
|
||||
/**
|
||||
* Optional modifiers for the kind (such as 'public').
|
||||
*/
|
||||
kindModifiers?: string;
|
||||
|
||||
/**
|
||||
* The file in which the symbol is found.
|
||||
*/
|
||||
file: string;
|
||||
|
||||
/**
|
||||
* The location within file at which the symbol is found.
|
||||
*/
|
||||
start: Location;
|
||||
|
||||
/**
|
||||
* One past the last character of the symbol.
|
||||
*/
|
||||
end: Location;
|
||||
|
||||
/**
|
||||
* Name of symbol's container symbol (if any); for example,
|
||||
* the class name if symbol is a class member.
|
||||
*/
|
||||
containerName?: string;
|
||||
|
||||
/**
|
||||
* Kind of symbol's container symbol (if any).
|
||||
*/
|
||||
containerKind?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Navto response message. Body is an array of navto items. Each
|
||||
* item gives a symbol that matched the search term.
|
||||
*/
|
||||
export interface NavtoResponse extends Response {
|
||||
body?: NavtoItem[];
|
||||
}
|
||||
|
||||
/**
|
||||
* Arguments for change request message.
|
||||
*/
|
||||
export interface ChangeRequestArgs extends FormatRequestArgs {
|
||||
/**
|
||||
* Optional string to insert at location (file, line, col).
|
||||
*/
|
||||
insertString?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Change request message; value of command field is "change".
|
||||
* Update the server's view of the file named by argument 'file'.
|
||||
* Server does not currently send a response to a change request.
|
||||
*/
|
||||
export interface ChangeRequest extends FileLocationRequest {
|
||||
arguments: ChangeRequestArgs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Response to "brace" request.
|
||||
*/
|
||||
export interface BraceResponse extends Response {
|
||||
body?: TextSpan[];
|
||||
}
|
||||
|
||||
/**
|
||||
* Brace matching request; value of command field is "brace".
|
||||
* Return response giving the file locations of matching braces
|
||||
* found in file at location line, col.
|
||||
*/
|
||||
export interface BraceRequest extends FileLocationRequest {
|
||||
}
|
||||
|
||||
/**
|
||||
* NavBar itesm request; value of command field is "navbar".
|
||||
* Return response giving the list of navigation bar entries
|
||||
* extracted from the requested file.
|
||||
*/
|
||||
export interface NavBarRequest extends FileRequest {
|
||||
}
|
||||
|
||||
export interface NavigationBarItem {
|
||||
/**
|
||||
* The item's display text.
|
||||
*/
|
||||
text: string;
|
||||
|
||||
/**
|
||||
* The symbol's kind (such as 'className' or 'parameterName').
|
||||
*/
|
||||
kind: string;
|
||||
|
||||
/**
|
||||
* Optional modifiers for the kind (such as 'public').
|
||||
*/
|
||||
kindModifiers?: string;
|
||||
|
||||
/**
|
||||
* The definition locations of the item.
|
||||
*/
|
||||
spans: TextSpan[];
|
||||
|
||||
/**
|
||||
* Optional children.
|
||||
*/
|
||||
childItems?: NavigationBarItem[];
|
||||
}
|
||||
|
||||
export interface NavBarResponse extends Response {
|
||||
body?: NavigationBarItem[];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,212 @@
|
||||
/// <reference path="node.d.ts" />
|
||||
/// <reference path="session.ts" />
|
||||
|
||||
module ts.server {
|
||||
var nodeproto: typeof NodeJS._debugger = require('_debugger');
|
||||
var readline: NodeJS.ReadLine = require('readline');
|
||||
var path: NodeJS.Path = require('path');
|
||||
var fs: typeof NodeJS.fs = require('fs');
|
||||
|
||||
var rl = readline.createInterface({
|
||||
input: process.stdin,
|
||||
output: process.stdout,
|
||||
terminal: false,
|
||||
});
|
||||
|
||||
class Logger implements ts.server.Logger {
|
||||
fd = -1;
|
||||
seq = 0;
|
||||
inGroup = false;
|
||||
firstInGroup = true;
|
||||
|
||||
constructor(public logFilename: string) {
|
||||
}
|
||||
|
||||
static padStringRight(str: string, padding: string) {
|
||||
return (str + padding).slice(0, padding.length);
|
||||
}
|
||||
|
||||
close() {
|
||||
if (this.fd >= 0) {
|
||||
fs.close(this.fd);
|
||||
}
|
||||
}
|
||||
|
||||
perftrc(s: string) {
|
||||
this.msg(s, "Perf");
|
||||
}
|
||||
|
||||
info(s: string) {
|
||||
this.msg(s, "Info");
|
||||
}
|
||||
|
||||
startGroup() {
|
||||
this.inGroup = true;
|
||||
this.firstInGroup = true;
|
||||
}
|
||||
|
||||
endGroup() {
|
||||
this.inGroup = false;
|
||||
this.seq++;
|
||||
this.firstInGroup = true;
|
||||
}
|
||||
|
||||
msg(s: string, type = "Err") {
|
||||
if (this.fd < 0) {
|
||||
this.fd = fs.openSync(this.logFilename, "w");
|
||||
}
|
||||
if (this.fd >= 0) {
|
||||
s = s + "\n";
|
||||
var prefix = Logger.padStringRight(type + " " + this.seq.toString(), " ");
|
||||
if (this.firstInGroup) {
|
||||
s = prefix + s;
|
||||
this.firstInGroup = false;
|
||||
}
|
||||
if (!this.inGroup) {
|
||||
this.seq++;
|
||||
this.firstInGroup = true;
|
||||
}
|
||||
var buf = new Buffer(s);
|
||||
fs.writeSync(this.fd, buf, 0, buf.length, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
interface WatchedFile {
|
||||
fileName: string;
|
||||
callback: (fileName: string) => void;
|
||||
mtime: Date;
|
||||
}
|
||||
|
||||
class WatchedFileSet {
|
||||
private watchedFiles: WatchedFile[] = [];
|
||||
private nextFileToCheck = 0;
|
||||
private watchTimer: NodeJS.Timer;
|
||||
|
||||
// average async stat takes about 30 microseconds
|
||||
// set chunk size to do 30 files in < 1 millisecond
|
||||
constructor(public interval = 2500, public chunkSize = 30) {
|
||||
}
|
||||
|
||||
private static copyListRemovingItem<T>(item: T, list: T[]) {
|
||||
var copiedList: T[] = [];
|
||||
for (var i = 0, len = list.length; i < len; i++) {
|
||||
if (list[i] != item) {
|
||||
copiedList.push(list[i]);
|
||||
}
|
||||
}
|
||||
return copiedList;
|
||||
}
|
||||
|
||||
private static getModifiedTime(fileName: string): Date {
|
||||
return fs.statSync(fileName).mtime;
|
||||
}
|
||||
|
||||
private poll(checkedIndex: number) {
|
||||
var watchedFile = this.watchedFiles[checkedIndex];
|
||||
if (!watchedFile) {
|
||||
return;
|
||||
}
|
||||
|
||||
fs.stat(watchedFile.fileName,(err, stats) => {
|
||||
if (err) {
|
||||
watchedFile.callback(watchedFile.fileName);
|
||||
}
|
||||
else if (watchedFile.mtime.getTime() != stats.mtime.getTime()) {
|
||||
watchedFile.mtime = WatchedFileSet.getModifiedTime(watchedFile.fileName);
|
||||
watchedFile.callback(watchedFile.fileName);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// this implementation uses polling and
|
||||
// stat due to inconsistencies of fs.watch
|
||||
// and efficiency of stat on modern filesystems
|
||||
private startWatchTimer() {
|
||||
this.watchTimer = setInterval(() => {
|
||||
var count = 0;
|
||||
var nextToCheck = this.nextFileToCheck;
|
||||
var firstCheck = -1;
|
||||
while ((count < this.chunkSize) && (nextToCheck != firstCheck)) {
|
||||
this.poll(nextToCheck);
|
||||
if (firstCheck < 0) {
|
||||
firstCheck = nextToCheck;
|
||||
}
|
||||
nextToCheck++;
|
||||
if (nextToCheck === this.watchedFiles.length) {
|
||||
nextToCheck = 0;
|
||||
}
|
||||
count++;
|
||||
}
|
||||
this.nextFileToCheck = nextToCheck;
|
||||
}, this.interval);
|
||||
}
|
||||
|
||||
addFile(fileName: string, callback: (fileName: string) => void ): WatchedFile {
|
||||
var file: WatchedFile = {
|
||||
fileName,
|
||||
callback,
|
||||
mtime: WatchedFileSet.getModifiedTime(fileName)
|
||||
};
|
||||
|
||||
this.watchedFiles.push(file);
|
||||
if (this.watchedFiles.length === 1) {
|
||||
this.startWatchTimer();
|
||||
}
|
||||
return file;
|
||||
}
|
||||
|
||||
removeFile(file: WatchedFile) {
|
||||
this.watchedFiles = WatchedFileSet.copyListRemovingItem(file, this.watchedFiles);
|
||||
}
|
||||
}
|
||||
|
||||
class IOSession extends Session {
|
||||
constructor(host: ServerHost, logger: ts.server.Logger) {
|
||||
super(host, logger);
|
||||
}
|
||||
|
||||
listen() {
|
||||
rl.on('line',(input: string) => {
|
||||
var message = input.trim();
|
||||
this.onMessage(message);
|
||||
});
|
||||
|
||||
rl.on('close',() => {
|
||||
this.projectService.closeLog();
|
||||
this.projectService.log("Exiting...");
|
||||
process.exit(0);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// This places log file in the directory containing editorServices.js
|
||||
// TODO: check that this location is writable
|
||||
var logger = new Logger(__dirname + "/.log" + process.pid.toString());
|
||||
|
||||
|
||||
// REVIEW: for now this implementation uses polling.
|
||||
// The advantage of polling is that it works reliably
|
||||
// on all os and with network mounted files.
|
||||
// For 90 referenced files, the average time to detect
|
||||
// changes is 2*msInterval (by default 5 seconds).
|
||||
// The overhead of this is .04 percent (1/2500) with
|
||||
// average pause of < 1 millisecond (and max
|
||||
// pause less than 1.5 milliseconds); question is
|
||||
// do we anticipate reference sets in the 100s and
|
||||
// do we care about waiting 10-20 seconds to detect
|
||||
// changes for large reference sets? If so, do we want
|
||||
// to increase the chunk size or decrease the interval
|
||||
// time dynamically to match the large reference set?
|
||||
var watchedFileSet = new WatchedFileSet();
|
||||
ts.sys.watchFile = function (fileName, callback) {
|
||||
var watchedFile = watchedFileSet.addFile(fileName, callback);
|
||||
return {
|
||||
close: () => watchedFileSet.removeFile(watchedFile)
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
// Start listening
|
||||
new IOSession(ts.sys, logger).listen();
|
||||
}
|
||||
@@ -0,0 +1,809 @@
|
||||
/// <reference path="..\compiler\commandLineParser.ts" />
|
||||
/// <reference path="..\services\services.ts" />
|
||||
/// <reference path="node.d.ts" />
|
||||
/// <reference path="protocol.d.ts" />
|
||||
/// <reference path="editorServices.ts" />
|
||||
|
||||
module ts.server {
|
||||
var spaceCache = [" ", " ", " ", " "];
|
||||
|
||||
interface StackTraceError extends Error {
|
||||
stack?: string;
|
||||
}
|
||||
|
||||
function generateSpaces(n: number): string {
|
||||
if (!spaceCache[n]) {
|
||||
var strBuilder = "";
|
||||
for (var i = 0; i < n; i++) {
|
||||
strBuilder += " ";
|
||||
}
|
||||
spaceCache[n] = strBuilder;
|
||||
}
|
||||
return spaceCache[n];
|
||||
}
|
||||
|
||||
interface FileStart {
|
||||
file: string;
|
||||
start: ILineInfo;
|
||||
}
|
||||
|
||||
function compareNumber(a: number, b: number) {
|
||||
if (a < b) {
|
||||
return -1;
|
||||
}
|
||||
else if (a == b) {
|
||||
return 0;
|
||||
}
|
||||
else return 1;
|
||||
}
|
||||
|
||||
function compareFileStart(a: FileStart, b: FileStart) {
|
||||
if (a.file < b.file) {
|
||||
return -1;
|
||||
}
|
||||
else if (a.file == b.file) {
|
||||
var n = compareNumber(a.start.line, b.start.line);
|
||||
if (n == 0) {
|
||||
return compareNumber(a.start.col, b.start.col);
|
||||
}
|
||||
else return n;
|
||||
}
|
||||
else {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
function formatDiag(fileName: string, project: Project, diag: ts.Diagnostic) {
|
||||
return {
|
||||
start: project.compilerService.host.positionToLineCol(fileName, diag.start),
|
||||
end: project.compilerService.host.positionToLineCol(fileName, diag.start + diag.length),
|
||||
text: ts.flattenDiagnosticMessageText(diag.messageText, "\n")
|
||||
};
|
||||
}
|
||||
|
||||
interface PendingErrorCheck {
|
||||
fileName: string;
|
||||
project: Project;
|
||||
}
|
||||
|
||||
function allEditsBeforePos(edits: ts.TextChange[], pos: number) {
|
||||
for (var i = 0, len = edits.length; i < len; i++) {
|
||||
if (ts.textSpanEnd(edits[i].span) >= pos) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
export module CommandNames {
|
||||
export var Change = "change";
|
||||
export var Close = "close";
|
||||
export var Completions = "completions";
|
||||
export var CompletionDetails = "completionEntryDetails";
|
||||
export var Definition = "definition";
|
||||
export var Format = "format";
|
||||
export var Formatonkey = "formatonkey";
|
||||
export var Geterr = "geterr";
|
||||
export var NavBar = "navbar";
|
||||
export var Navto = "navto";
|
||||
export var Open = "open";
|
||||
export var Quickinfo = "quickinfo";
|
||||
export var References = "references";
|
||||
export var Reload = "reload";
|
||||
export var Rename = "rename";
|
||||
export var Saveto = "saveto";
|
||||
export var Brace = "brace";
|
||||
export var Unknown = "unknown";
|
||||
}
|
||||
|
||||
module Errors {
|
||||
export var NoProject = new Error("No Project.");
|
||||
}
|
||||
|
||||
export interface ServerHost extends ts.System {
|
||||
}
|
||||
|
||||
export class Session {
|
||||
projectService: ProjectService;
|
||||
pendingOperation = false;
|
||||
fileHash: ts.Map<number> = {};
|
||||
nextFileId = 1;
|
||||
errorTimer: NodeJS.Timer;
|
||||
immediateId: any;
|
||||
changeSeq = 0;
|
||||
|
||||
constructor(private host: ServerHost, private logger: Logger) {
|
||||
this.projectService =
|
||||
new ProjectService(host, logger, (eventName,project,fileName) => {
|
||||
this.handleEvent(eventName, project, fileName);
|
||||
});
|
||||
}
|
||||
|
||||
handleEvent(eventName: string, project: Project, fileName: string) {
|
||||
if (eventName == "context") {
|
||||
this.projectService.log("got context event, updating diagnostics for" + fileName, "Info");
|
||||
this.updateErrorCheck([{ fileName, project }], this.changeSeq,
|
||||
(n) => n == this.changeSeq, 100);
|
||||
}
|
||||
}
|
||||
|
||||
logError(err: Error, cmd: string) {
|
||||
var typedErr = <StackTraceError>err;
|
||||
var msg = "Exception on executing command " + cmd;
|
||||
if (typedErr.message) {
|
||||
msg += ":\n" + typedErr.message;
|
||||
if (typedErr.stack) {
|
||||
msg += "\n" + typedErr.stack;
|
||||
}
|
||||
}
|
||||
this.projectService.log(msg);
|
||||
}
|
||||
|
||||
sendLineToClient(line: string) {
|
||||
this.host.write(line + this.host.newLine);
|
||||
}
|
||||
|
||||
send(msg: NodeJS._debugger.Message) {
|
||||
var json = JSON.stringify(msg);
|
||||
this.sendLineToClient('Content-Length: ' + (1 + Buffer.byteLength(json, 'utf8')) +
|
||||
'\r\n\r\n' + json);
|
||||
}
|
||||
|
||||
event(info: any, eventName: string) {
|
||||
var ev: NodeJS._debugger.Event = {
|
||||
seq: 0,
|
||||
type: "event",
|
||||
event: eventName,
|
||||
body: info,
|
||||
};
|
||||
this.send(ev);
|
||||
}
|
||||
|
||||
response(info: any, cmdName: string, reqSeq = 0, errorMsg?: string) {
|
||||
var res: protocol.Response = {
|
||||
seq: 0,
|
||||
type: "response",
|
||||
command: cmdName,
|
||||
request_seq: reqSeq,
|
||||
success: !errorMsg,
|
||||
}
|
||||
if (!errorMsg) {
|
||||
res.body = info;
|
||||
}
|
||||
else {
|
||||
res.message = errorMsg;
|
||||
}
|
||||
this.send(res);
|
||||
}
|
||||
|
||||
output(body: any, commandName: string, requestSequence = 0, errorMessage?: string) {
|
||||
this.response(body, commandName, requestSequence, errorMessage);
|
||||
}
|
||||
|
||||
semanticCheck(file: string, project: Project) {
|
||||
var diags = project.compilerService.languageService.getSemanticDiagnostics(file);
|
||||
if (diags) {
|
||||
var bakedDiags = diags.map((diag) => formatDiag(file, project, diag));
|
||||
this.event({ file: file, diagnostics: bakedDiags }, "semanticDiag");
|
||||
}
|
||||
}
|
||||
|
||||
syntacticCheck(file: string, project: Project) {
|
||||
var diags = project.compilerService.languageService.getSyntacticDiagnostics(file);
|
||||
if (diags) {
|
||||
var bakedDiags = diags.map((diag) => formatDiag(file, project, diag));
|
||||
this.event({ file: file, diagnostics: bakedDiags }, "syntaxDiag");
|
||||
}
|
||||
}
|
||||
|
||||
errorCheck(file: string, project: Project) {
|
||||
this.syntacticCheck(file, project);
|
||||
this.semanticCheck(file, project);
|
||||
}
|
||||
|
||||
updateProjectStructure(seq: number, matchSeq: (seq: number) => boolean, ms = 1500) {
|
||||
setTimeout(() => {
|
||||
if (matchSeq(seq)) {
|
||||
this.projectService.updateProjectStructure();
|
||||
}
|
||||
}, ms);
|
||||
}
|
||||
|
||||
updateErrorCheck(checkList: PendingErrorCheck[], seq: number,
|
||||
matchSeq: (seq: number) => boolean, ms = 1500, followMs = 200) {
|
||||
if (followMs > ms) {
|
||||
followMs = ms;
|
||||
}
|
||||
if (this.errorTimer) {
|
||||
clearTimeout(this.errorTimer);
|
||||
}
|
||||
if (this.immediateId) {
|
||||
clearImmediate(this.immediateId);
|
||||
this.immediateId = undefined;
|
||||
}
|
||||
var index = 0;
|
||||
var checkOne = () => {
|
||||
if (matchSeq(seq)) {
|
||||
var checkSpec = checkList[index++];
|
||||
if (checkSpec.project.getSourceFileFromName(checkSpec.fileName, true)) {
|
||||
this.syntacticCheck(checkSpec.fileName, checkSpec.project);
|
||||
this.immediateId = setImmediate(() => {
|
||||
this.semanticCheck(checkSpec.fileName, checkSpec.project);
|
||||
this.immediateId = undefined;
|
||||
if (checkList.length > index) {
|
||||
this.errorTimer = setTimeout(checkOne, followMs);
|
||||
}
|
||||
else {
|
||||
this.errorTimer = undefined;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
if ((checkList.length > index) && (matchSeq(seq))) {
|
||||
this.errorTimer = setTimeout(checkOne, ms);
|
||||
}
|
||||
}
|
||||
|
||||
getDefinition(line: number, col: number, fileName: string): protocol.FileSpan[] {
|
||||
var file = ts.normalizePath(fileName);
|
||||
var project = this.projectService.getProjectForFile(file);
|
||||
if (!project) {
|
||||
throw Errors.NoProject;
|
||||
}
|
||||
|
||||
var compilerService = project.compilerService;
|
||||
var position = compilerService.host.lineColToPosition(file, line, col);
|
||||
|
||||
var definitions = compilerService.languageService.getDefinitionAtPosition(file, position);
|
||||
if (!definitions) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
return definitions.map(def => ({
|
||||
file: def.fileName,
|
||||
start: compilerService.host.positionToLineCol(def.fileName, def.textSpan.start),
|
||||
end: compilerService.host.positionToLineCol(def.fileName, ts.textSpanEnd(def.textSpan))
|
||||
}));
|
||||
}
|
||||
|
||||
getRenameLocations(line: number, col: number, fileName: string,findInComments: boolean, findInStrings: boolean): protocol.RenameResponseBody {
|
||||
var file = ts.normalizePath(fileName);
|
||||
var project = this.projectService.getProjectForFile(file);
|
||||
if (!project) {
|
||||
throw Errors.NoProject;
|
||||
}
|
||||
|
||||
var compilerService = project.compilerService;
|
||||
var position = compilerService.host.lineColToPosition(file, line, col);
|
||||
var renameInfo = compilerService.languageService.getRenameInfo(file, position);
|
||||
if (!renameInfo) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
if (!renameInfo.canRename) {
|
||||
return {
|
||||
info: renameInfo,
|
||||
locs: []
|
||||
};
|
||||
}
|
||||
|
||||
var renameLocations = compilerService.languageService.findRenameLocations(file, position, findInStrings, findInComments);
|
||||
if (!renameLocations) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
var bakedRenameLocs = renameLocations.map(location => (<protocol.FileSpan>{
|
||||
file: location.fileName,
|
||||
start: compilerService.host.positionToLineCol(location.fileName, location.textSpan.start),
|
||||
end: compilerService.host.positionToLineCol(location.fileName, ts.textSpanEnd(location.textSpan)),
|
||||
})).sort((a, b) => {
|
||||
if (a.file < b.file) {
|
||||
return -1;
|
||||
}
|
||||
else if (a.file > b.file) {
|
||||
return 1;
|
||||
}
|
||||
else {
|
||||
// reverse sort assuming no overlap
|
||||
if (a.start.line < b.start.line) {
|
||||
return 1;
|
||||
}
|
||||
else if (a.start.line > b.start.line) {
|
||||
return -1;
|
||||
}
|
||||
else {
|
||||
return b.start.col - a.start.col;
|
||||
}
|
||||
}
|
||||
}).reduce<protocol.SpanGroup[]>((accum: protocol.SpanGroup[], cur: protocol.FileSpan) => {
|
||||
var curFileAccum: protocol.SpanGroup;
|
||||
if (accum.length > 0) {
|
||||
curFileAccum = accum[accum.length - 1];
|
||||
if (curFileAccum.file != cur.file) {
|
||||
curFileAccum = undefined;
|
||||
}
|
||||
}
|
||||
if (!curFileAccum) {
|
||||
curFileAccum = { file: cur.file, locs: [] };
|
||||
accum.push(curFileAccum);
|
||||
}
|
||||
curFileAccum.locs.push({ start: cur.start, end: cur.end });
|
||||
return accum;
|
||||
}, []);
|
||||
|
||||
return { info: renameInfo, locs: bakedRenameLocs };
|
||||
}
|
||||
|
||||
getReferences(line: number, col: number, fileName: string): protocol.ReferencesResponseBody {
|
||||
// TODO: get all projects for this file; report refs for all projects deleting duplicates
|
||||
// can avoid duplicates by eliminating same ref file from subsequent projects
|
||||
var file = ts.normalizePath(fileName);
|
||||
var project = this.projectService.getProjectForFile(file);
|
||||
if (!project) {
|
||||
throw Errors.NoProject;
|
||||
}
|
||||
|
||||
var compilerService = project.compilerService;
|
||||
var position = compilerService.host.lineColToPosition(file, line, col);
|
||||
|
||||
var references = compilerService.languageService.getReferencesAtPosition(file, position);
|
||||
if (!references) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
var nameInfo = compilerService.languageService.getQuickInfoAtPosition(file, position);
|
||||
if (!nameInfo) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
var displayString = ts.displayPartsToString(nameInfo.displayParts);
|
||||
var nameSpan = nameInfo.textSpan;
|
||||
var nameColStart = compilerService.host.positionToLineCol(file, nameSpan.start).col;
|
||||
var nameText = compilerService.host.getScriptSnapshot(file).getText(nameSpan.start, ts.textSpanEnd(nameSpan));
|
||||
var bakedRefs: protocol.ReferencesResponseItem[] = references.map((ref) => {
|
||||
var start = compilerService.host.positionToLineCol(ref.fileName, ref.textSpan.start);
|
||||
var refLineSpan = compilerService.host.lineToTextSpan(ref.fileName, start.line - 1);
|
||||
var snap = compilerService.host.getScriptSnapshot(ref.fileName);
|
||||
var lineText = snap.getText(refLineSpan.start, ts.textSpanEnd(refLineSpan)).replace(/\r|\n/g, "");
|
||||
return {
|
||||
file: ref.fileName,
|
||||
start: start,
|
||||
lineText: lineText,
|
||||
end: compilerService.host.positionToLineCol(ref.fileName, ts.textSpanEnd(ref.textSpan)),
|
||||
isWriteAccess: ref.isWriteAccess
|
||||
};
|
||||
}).sort(compareFileStart);
|
||||
return {
|
||||
refs: bakedRefs,
|
||||
symbolName: nameText,
|
||||
symbolStartCol: nameColStart,
|
||||
symbolDisplayString: displayString
|
||||
};
|
||||
}
|
||||
|
||||
openClientFile(fileName: string) {
|
||||
var file = ts.normalizePath(fileName);
|
||||
this.projectService.openClientFile(file);
|
||||
}
|
||||
|
||||
getQuickInfo(line: number, col: number, fileName: string): protocol.QuickInfoResponseBody {
|
||||
var file = ts.normalizePath(fileName);
|
||||
var project = this.projectService.getProjectForFile(file);
|
||||
if (!project) {
|
||||
throw Errors.NoProject;
|
||||
}
|
||||
|
||||
var compilerService = project.compilerService;
|
||||
var position = compilerService.host.lineColToPosition(file, line, col);
|
||||
var quickInfo = compilerService.languageService.getQuickInfoAtPosition(file, position);
|
||||
if (!quickInfo) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
var displayString = ts.displayPartsToString(quickInfo.displayParts);
|
||||
var docString = ts.displayPartsToString(quickInfo.documentation);
|
||||
return {
|
||||
kind: quickInfo.kind,
|
||||
kindModifiers: quickInfo.kindModifiers,
|
||||
start: compilerService.host.positionToLineCol(file, quickInfo.textSpan.start),
|
||||
end: compilerService.host.positionToLineCol(file, ts.textSpanEnd(quickInfo.textSpan)),
|
||||
displayString: displayString,
|
||||
documentation: docString,
|
||||
};
|
||||
}
|
||||
|
||||
getFormattingEditsForRange(line: number, col: number, endLine: number, endCol: number, fileName: string): protocol.CodeEdit[] {
|
||||
var file = ts.normalizePath(fileName);
|
||||
var project = this.projectService.getProjectForFile(file);
|
||||
if (!project) {
|
||||
throw Errors.NoProject;
|
||||
}
|
||||
|
||||
var compilerService = project.compilerService;
|
||||
var startPosition = compilerService.host.lineColToPosition(file, line, col);
|
||||
var endPosition = compilerService.host.lineColToPosition(file, endLine, endCol);
|
||||
|
||||
// TODO: avoid duplicate code (with formatonkey)
|
||||
var edits = compilerService.languageService.getFormattingEditsForRange(file, startPosition, endPosition, compilerService.formatCodeOptions);
|
||||
if (!edits) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
return edits.map((edit) => {
|
||||
return {
|
||||
start: compilerService.host.positionToLineCol(file, edit.span.start),
|
||||
end: compilerService.host.positionToLineCol(file, ts.textSpanEnd(edit.span)),
|
||||
newText: edit.newText ? edit.newText : ""
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
getFormattingEditsAfterKeystroke(line: number, col: number, key: string, fileName: string): protocol.CodeEdit[] {
|
||||
var file = ts.normalizePath(fileName);
|
||||
|
||||
var project = this.projectService.getProjectForFile(file);
|
||||
if (!project) {
|
||||
throw Errors.NoProject;
|
||||
}
|
||||
|
||||
var compilerService = project.compilerService;
|
||||
var position = compilerService.host.lineColToPosition(file, line, col);
|
||||
var edits = compilerService.languageService.getFormattingEditsAfterKeystroke(file, position, key,
|
||||
compilerService.formatCodeOptions);
|
||||
if ((key == "\n") && ((!edits) || (edits.length == 0) || allEditsBeforePos(edits, position))) {
|
||||
// TODO: get these options from host
|
||||
var editorOptions: ts.EditorOptions = {
|
||||
IndentSize: 4,
|
||||
TabSize: 4,
|
||||
NewLineCharacter: "\n",
|
||||
ConvertTabsToSpaces: true,
|
||||
};
|
||||
var indentPosition = compilerService.languageService.getIndentationAtPosition(file, position, editorOptions);
|
||||
var spaces = generateSpaces(indentPosition);
|
||||
if (indentPosition > 0) {
|
||||
edits.push({ span: ts.createTextSpanFromBounds(position, position), newText: spaces });
|
||||
}
|
||||
}
|
||||
|
||||
if (!edits) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
return edits.map((edit) => {
|
||||
return {
|
||||
start: compilerService.host.positionToLineCol(file,
|
||||
edit.span.start),
|
||||
end: compilerService.host.positionToLineCol(file,
|
||||
ts.textSpanEnd(edit.span)),
|
||||
newText: edit.newText ? edit.newText : ""
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
getCompletions(line: number, col: number, prefix: string, fileName: string): protocol.CompletionEntry[] {
|
||||
if (!prefix) {
|
||||
prefix = "";
|
||||
}
|
||||
var file = ts.normalizePath(fileName);
|
||||
var project = this.projectService.getProjectForFile(file);
|
||||
if (!project) {
|
||||
throw Errors.NoProject;
|
||||
}
|
||||
|
||||
var compilerService = project.compilerService;
|
||||
var position = compilerService.host.lineColToPosition(file, line, col);
|
||||
|
||||
var completions = compilerService.languageService.getCompletionsAtPosition(file, position);
|
||||
if (!completions) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
return completions.entries.reduce((result: protocol.CompletionEntry[], entry: ts.CompletionEntry) => {
|
||||
if (completions.isMemberCompletion || entry.name.indexOf(prefix) == 0) {
|
||||
result.push(entry);
|
||||
}
|
||||
return result;
|
||||
}, []);
|
||||
}
|
||||
|
||||
getCompletionEntryDetails(line: number, col: number,
|
||||
entryNames: string[], fileName: string): protocol.CompletionEntryDetails[] {
|
||||
var file = ts.normalizePath(fileName);
|
||||
var project = this.projectService.getProjectForFile(file);
|
||||
if (!project) {
|
||||
throw Errors.NoProject;
|
||||
}
|
||||
|
||||
var compilerService = project.compilerService;
|
||||
var position = compilerService.host.lineColToPosition(file, line, col);
|
||||
|
||||
return entryNames.reduce((accum: protocol.CompletionEntryDetails[], entryName: string) => {
|
||||
var details = compilerService.languageService.getCompletionEntryDetails(file, position, entryName);
|
||||
if (details) {
|
||||
accum.push(details);
|
||||
}
|
||||
return accum;
|
||||
}, []);
|
||||
}
|
||||
|
||||
getDiagnostics(delay: number, fileNames: string[]) {
|
||||
var checkList = fileNames.reduce((accum: PendingErrorCheck[], fileName: string) => {
|
||||
fileName = ts.normalizePath(fileName);
|
||||
var project = this.projectService.getProjectForFile(fileName);
|
||||
if (project) {
|
||||
accum.push({ fileName, project });
|
||||
}
|
||||
return accum;
|
||||
}, []);
|
||||
|
||||
if (checkList.length > 0) {
|
||||
this.updateErrorCheck(checkList, this.changeSeq,(n) => n == this.changeSeq, delay)
|
||||
}
|
||||
}
|
||||
|
||||
change(line: number, col: number, endLine: number, endCol: number, insertString: string, fileName: string) {
|
||||
var file = ts.normalizePath(fileName);
|
||||
var project = this.projectService.getProjectForFile(file);
|
||||
if (project) {
|
||||
var compilerService = project.compilerService;
|
||||
var start = compilerService.host.lineColToPosition(file, line, col);
|
||||
var end = compilerService.host.lineColToPosition(file, endLine, endCol);
|
||||
if (start >= 0) {
|
||||
compilerService.host.editScript(file, start, end, insertString);
|
||||
this.changeSeq++;
|
||||
}
|
||||
// update project structure on idle commented out
|
||||
// until we can have the host return only the root files
|
||||
// from getScriptFileNames()
|
||||
//this.updateProjectStructure(this.changeSeq, (n) => n == this.changeSeq);
|
||||
}
|
||||
}
|
||||
|
||||
reload(fileName: string, tempFileName: string, reqSeq = 0) {
|
||||
var file = ts.normalizePath(fileName);
|
||||
var tmpfile = ts.normalizePath(tempFileName);
|
||||
var project = this.projectService.getProjectForFile(file);
|
||||
if (project) {
|
||||
this.changeSeq++;
|
||||
// make sure no changes happen before this one is finished
|
||||
project.compilerService.host.reloadScript(file, tmpfile,() => {
|
||||
this.output(undefined, CommandNames.Reload, reqSeq);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
saveToTmp(fileName: string, tempFileName: string) {
|
||||
var file = ts.normalizePath(fileName);
|
||||
var tmpfile = ts.normalizePath(tempFileName);
|
||||
|
||||
var project = this.projectService.getProjectForFile(file);
|
||||
if (project) {
|
||||
project.compilerService.host.saveTo(file, tmpfile);
|
||||
}
|
||||
}
|
||||
|
||||
closeClientFile(fileName: string) {
|
||||
var file = ts.normalizePath(fileName);
|
||||
this.projectService.closeClientFile(file);
|
||||
}
|
||||
|
||||
decorateNavigationBarItem(project: Project, fileName: string, items: ts.NavigationBarItem[]): protocol.NavigationBarItem[] {
|
||||
if (!items) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
var compilerService = project.compilerService;
|
||||
|
||||
return items.map(item => ({
|
||||
text: item.text,
|
||||
kind: item.kind,
|
||||
kindModifiers: item.kindModifiers,
|
||||
spans: item.spans.map(span => ({
|
||||
start: compilerService.host.positionToLineCol(fileName, span.start),
|
||||
end: compilerService.host.positionToLineCol(fileName, ts.textSpanEnd(span))
|
||||
})),
|
||||
childItems: this.decorateNavigationBarItem(project, fileName, item.childItems)
|
||||
}));
|
||||
}
|
||||
|
||||
getNavigationBarItems(fileName: string): protocol.NavigationBarItem[] {
|
||||
var file = ts.normalizePath(fileName);
|
||||
var project = this.projectService.getProjectForFile(file);
|
||||
if (!project) {
|
||||
throw Errors.NoProject;
|
||||
}
|
||||
|
||||
var compilerService = project.compilerService;
|
||||
var items = compilerService.languageService.getNavigationBarItems(file);
|
||||
if (!items) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
return this.decorateNavigationBarItem(project, fileName, items);
|
||||
}
|
||||
|
||||
getNavigateToItems(searchValue: string, fileName: string, maxResultCount?: number): protocol.NavtoItem[] {
|
||||
var file = ts.normalizePath(fileName);
|
||||
var project = this.projectService.getProjectForFile(file);
|
||||
if (!project) {
|
||||
throw Errors.NoProject;
|
||||
}
|
||||
|
||||
var compilerService = project.compilerService;
|
||||
var navItems = compilerService.languageService.getNavigateToItems(searchValue, maxResultCount);
|
||||
if (!navItems) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
return navItems.map((navItem) => {
|
||||
var start = compilerService.host.positionToLineCol(navItem.fileName, navItem.textSpan.start);
|
||||
var end = compilerService.host.positionToLineCol(navItem.fileName, ts.textSpanEnd(navItem.textSpan));
|
||||
var bakedItem: protocol.NavtoItem = {
|
||||
name: navItem.name,
|
||||
kind: navItem.kind,
|
||||
file: navItem.fileName,
|
||||
start: start,
|
||||
end: end,
|
||||
};
|
||||
if (navItem.kindModifiers && (navItem.kindModifiers != "")) {
|
||||
bakedItem.kindModifiers = navItem.kindModifiers;
|
||||
}
|
||||
if (navItem.matchKind != 'none') {
|
||||
bakedItem.matchKind = navItem.matchKind;
|
||||
}
|
||||
if (navItem.containerName && (navItem.containerName.length > 0)) {
|
||||
bakedItem.containerName = navItem.containerName;
|
||||
}
|
||||
if (navItem.containerKind && (navItem.containerKind.length > 0)) {
|
||||
bakedItem.containerKind = navItem.containerKind;
|
||||
}
|
||||
return bakedItem;
|
||||
});
|
||||
}
|
||||
|
||||
getBraceMatching(line: number, col: number, fileName: string): protocol.TextSpan[] {
|
||||
var file = ts.normalizePath(fileName);
|
||||
|
||||
var project = this.projectService.getProjectForFile(file);
|
||||
if (!project) {
|
||||
throw Errors.NoProject;
|
||||
}
|
||||
|
||||
var compilerService = project.compilerService;
|
||||
var position = compilerService.host.lineColToPosition(file, line, col);
|
||||
|
||||
var spans = compilerService.languageService.getBraceMatchingAtPosition(file, position);
|
||||
if (!spans) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
return spans.map(span => ({
|
||||
start: compilerService.host.positionToLineCol(file, span.start),
|
||||
end: compilerService.host.positionToLineCol(file, span.start + span.length)
|
||||
}));
|
||||
}
|
||||
|
||||
onMessage(message: string) {
|
||||
try {
|
||||
var request = <protocol.Request>JSON.parse(message);
|
||||
var response: any;
|
||||
var errorMessage: string;
|
||||
var responseRequired = true;
|
||||
switch (request.command) {
|
||||
case CommandNames.Definition: {
|
||||
var defArgs = <protocol.FileLocationRequestArgs>request.arguments;
|
||||
response = this.getDefinition(defArgs.line, defArgs.col, defArgs.file);
|
||||
break;
|
||||
}
|
||||
case CommandNames.References: {
|
||||
var refArgs = <protocol.FileLocationRequestArgs>request.arguments;
|
||||
response = this.getReferences(refArgs.line, refArgs.col, refArgs.file);
|
||||
break;
|
||||
}
|
||||
case CommandNames.Rename: {
|
||||
var renameArgs = <protocol.RenameRequestArgs>request.arguments;
|
||||
response = this.getRenameLocations(renameArgs.line, renameArgs.col, renameArgs.file, renameArgs.findInComments, renameArgs.findInStrings);
|
||||
break;
|
||||
}
|
||||
case CommandNames.Open: {
|
||||
var openArgs = <protocol.FileRequestArgs>request.arguments;
|
||||
this.openClientFile(openArgs.file);
|
||||
responseRequired = false;
|
||||
break;
|
||||
}
|
||||
case CommandNames.Quickinfo: {
|
||||
var quickinfoArgs = <protocol.FileLocationRequestArgs>request.arguments;
|
||||
response = this.getQuickInfo(quickinfoArgs.line, quickinfoArgs.col, quickinfoArgs.file);
|
||||
break;
|
||||
}
|
||||
case CommandNames.Format: {
|
||||
var formatArgs = <protocol.FormatRequestArgs>request.arguments;
|
||||
response = this.getFormattingEditsForRange(formatArgs.line, formatArgs.col, formatArgs.endLine, formatArgs.endCol, formatArgs.file);
|
||||
break;
|
||||
}
|
||||
case CommandNames.Formatonkey: {
|
||||
var formatOnKeyArgs = <protocol.FormatOnKeyRequestArgs>request.arguments;
|
||||
response = this.getFormattingEditsAfterKeystroke(formatOnKeyArgs.line, formatOnKeyArgs.col, formatOnKeyArgs.key, formatOnKeyArgs.file);
|
||||
break;
|
||||
}
|
||||
case CommandNames.Completions: {
|
||||
var completionsArgs = <protocol.CompletionsRequestArgs>request.arguments;
|
||||
response = this.getCompletions(request.arguments.line, request.arguments.col, completionsArgs.prefix, request.arguments.file);
|
||||
break;
|
||||
}
|
||||
case CommandNames.CompletionDetails: {
|
||||
var completionDetailsArgs = <protocol.CompletionDetailsRequestArgs>request.arguments;
|
||||
response = this.getCompletionEntryDetails(request.arguments.line, request.arguments.col, completionDetailsArgs.entryNames,
|
||||
request.arguments.file);
|
||||
break;
|
||||
}
|
||||
case CommandNames.Geterr: {
|
||||
var geterrArgs = <protocol.GeterrRequestArgs>request.arguments;
|
||||
response = this.getDiagnostics(geterrArgs.delay, geterrArgs.files);
|
||||
responseRequired = false;
|
||||
break;
|
||||
}
|
||||
case CommandNames.Change: {
|
||||
var changeArgs = <protocol.ChangeRequestArgs>request.arguments;
|
||||
this.change(changeArgs.line, changeArgs.col, changeArgs.endLine, changeArgs.endCol,
|
||||
changeArgs.insertString, changeArgs.file);
|
||||
responseRequired = false;
|
||||
break;
|
||||
}
|
||||
case CommandNames.Reload: {
|
||||
var reloadArgs = <protocol.ReloadRequestArgs>request.arguments;
|
||||
this.reload(reloadArgs.file, reloadArgs.tmpfile, request.seq);
|
||||
break;
|
||||
}
|
||||
case CommandNames.Saveto: {
|
||||
var savetoArgs = <protocol.SavetoRequestArgs>request.arguments;
|
||||
this.saveToTmp(savetoArgs.file, savetoArgs.tmpfile);
|
||||
responseRequired = false;
|
||||
break;
|
||||
}
|
||||
case CommandNames.Close: {
|
||||
var closeArgs = <protocol.FileRequestArgs>request.arguments;
|
||||
this.closeClientFile(closeArgs.file);
|
||||
responseRequired = false;
|
||||
break;
|
||||
}
|
||||
case CommandNames.Navto: {
|
||||
var navtoArgs = <protocol.NavtoRequestArgs>request.arguments;
|
||||
response = this.getNavigateToItems(navtoArgs.searchValue, navtoArgs.file, navtoArgs.maxResultCount);
|
||||
break;
|
||||
}
|
||||
case CommandNames.Brace: {
|
||||
var braceArguments = <protocol.FileLocationRequestArgs>request.arguments;
|
||||
response = this.getBraceMatching(braceArguments.line, braceArguments.col, braceArguments.file);
|
||||
break;
|
||||
}
|
||||
case CommandNames.NavBar: {
|
||||
var navBarArgs = <protocol.FileRequestArgs>request.arguments;
|
||||
response = this.getNavigationBarItems(navBarArgs.file);
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
this.projectService.log("Unrecognized JSON command: " + message);
|
||||
this.output(undefined, CommandNames.Unknown, request.seq, "Unrecognized JSON command: " + request.command);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (response) {
|
||||
this.output(response, request.command, request.seq);
|
||||
}
|
||||
else if (responseRequired) {
|
||||
this.output(undefined, request.command, request.seq, "No content available.");
|
||||
}
|
||||
|
||||
} catch (err) {
|
||||
if (err instanceof OperationCanceledException) {
|
||||
// Handle cancellation exceptions
|
||||
}
|
||||
this.logError(err, message);
|
||||
this.output(undefined, request ? request.command : CommandNames.Unknown, request ? request.seq : 0, "Error processing request. " + err.message);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+13
-10
@@ -14,17 +14,17 @@ module ts.BreakpointResolver {
|
||||
}
|
||||
|
||||
var tokenAtLocation = getTokenAtPosition(sourceFile, position);
|
||||
var lineOfPosition = sourceFile.getLineAndCharacterFromPosition(position).line;
|
||||
if (sourceFile.getLineAndCharacterFromPosition(tokenAtLocation.getStart()).line > lineOfPosition) {
|
||||
var lineOfPosition = sourceFile.getLineAndCharacterOfPosition(position).line;
|
||||
if (sourceFile.getLineAndCharacterOfPosition(tokenAtLocation.getStart()).line > lineOfPosition) {
|
||||
// Get previous token if the token is returned starts on new line
|
||||
// eg: var x =10; |--- curser is here
|
||||
// eg: var x =10; |--- cursor is here
|
||||
// var y = 10;
|
||||
// token at position will return var keyword on second line as the token but we would like to use
|
||||
// token on same line if trailing trivia (comments or white spaces on same line) part of the last token on that line
|
||||
tokenAtLocation = findPrecedingToken(tokenAtLocation.pos, sourceFile);
|
||||
|
||||
// Its a blank line
|
||||
if (!tokenAtLocation || sourceFile.getLineAndCharacterFromPosition(tokenAtLocation.getEnd()).line !== lineOfPosition) {
|
||||
if (!tokenAtLocation || sourceFile.getLineAndCharacterOfPosition(tokenAtLocation.getEnd()).line !== lineOfPosition) {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
@@ -42,7 +42,7 @@ module ts.BreakpointResolver {
|
||||
}
|
||||
|
||||
function spanInNodeIfStartsOnSameLine(node: Node, otherwiseOnNode?: Node): TextSpan {
|
||||
if (node && lineOfPosition === sourceFile.getLineAndCharacterFromPosition(node.getStart()).line) {
|
||||
if (node && lineOfPosition === sourceFile.getLineAndCharacterOfPosition(node.getStart()).line) {
|
||||
return spanInNode(node);
|
||||
}
|
||||
return spanInNode(otherwiseOnNode);
|
||||
@@ -69,7 +69,7 @@ module ts.BreakpointResolver {
|
||||
return textSpan(node);
|
||||
}
|
||||
|
||||
if (node.parent.kind === SyntaxKind.BinaryExpression && (<BinaryExpression>node.parent).operator === SyntaxKind.CommaToken) {
|
||||
if (node.parent.kind === SyntaxKind.BinaryExpression && (<BinaryExpression>node.parent).operatorToken.kind === SyntaxKind.CommaToken) {
|
||||
// if this is comma expression, the breakpoint is possible in this expression
|
||||
return textSpan(node);
|
||||
}
|
||||
@@ -151,8 +151,9 @@ module ts.BreakpointResolver {
|
||||
return spanInForStatement(<ForStatement>node);
|
||||
|
||||
case SyntaxKind.ForInStatement:
|
||||
case SyntaxKind.ForOfStatement:
|
||||
// span on for (a in ...)
|
||||
return textSpan(node, findNextToken((<ForInStatement>node).expression, node));
|
||||
return textSpan(node, findNextToken((<ForInStatement | ForOfStatement>node).expression, node));
|
||||
|
||||
case SyntaxKind.SwitchStatement:
|
||||
// span on switch(...)
|
||||
@@ -175,9 +176,9 @@ module ts.BreakpointResolver {
|
||||
// span on export = id
|
||||
return textSpan(node, (<ExportAssignment>node).exportName);
|
||||
|
||||
case SyntaxKind.ImportDeclaration:
|
||||
case SyntaxKind.ImportEqualsDeclaration:
|
||||
// import statement without including semicolon
|
||||
return textSpan(node,(<ImportDeclaration>node).moduleReference);
|
||||
return textSpan(node,(<ImportEqualsDeclaration>node).moduleReference);
|
||||
|
||||
case SyntaxKind.ModuleDeclaration:
|
||||
// span on complete module if it is instantiated
|
||||
@@ -261,7 +262,8 @@ module ts.BreakpointResolver {
|
||||
|
||||
function spanInVariableDeclaration(variableDeclaration: VariableDeclaration): TextSpan {
|
||||
// If declaration of for in statement, just set the span in parent
|
||||
if (variableDeclaration.parent.parent.kind === SyntaxKind.ForInStatement) {
|
||||
if (variableDeclaration.parent.parent.kind === SyntaxKind.ForInStatement ||
|
||||
variableDeclaration.parent.parent.kind === SyntaxKind.ForOfStatement) {
|
||||
return spanInNode(variableDeclaration.parent.parent);
|
||||
}
|
||||
|
||||
@@ -362,6 +364,7 @@ module ts.BreakpointResolver {
|
||||
case SyntaxKind.WhileStatement:
|
||||
case SyntaxKind.IfStatement:
|
||||
case SyntaxKind.ForInStatement:
|
||||
case SyntaxKind.ForOfStatement:
|
||||
return spanInNodeIfStartsOnSameLine(block.parent, block.statements[0]);
|
||||
|
||||
// Set span on previous token if it starts on same line otherwise on the first statement of the block
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,6 +0,0 @@
|
||||
declare class Enumerator {
|
||||
public atEnd(): boolean;
|
||||
public moveNext(): boolean;
|
||||
public item(): any;
|
||||
constructor (o: any);
|
||||
}
|
||||
@@ -1,187 +0,0 @@
|
||||
//
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
///<reference path='references.ts' />
|
||||
|
||||
module TypeScript {
|
||||
var proto = "__proto__";
|
||||
|
||||
class BlockIntrinsics<T> {
|
||||
public prototype: T = undefined;
|
||||
public toString: T = undefined;
|
||||
public toLocaleString: T = undefined;
|
||||
public valueOf: T = undefined;
|
||||
public hasOwnProperty: T = undefined;
|
||||
public propertyIsEnumerable: T = undefined;
|
||||
public isPrototypeOf: T = undefined;
|
||||
[s: string]: T;
|
||||
|
||||
constructor() {
|
||||
// initialize the 'constructor' field
|
||||
this["constructor"] = undefined;
|
||||
|
||||
// First we set it to null, because that's the only way to erase the value in node. Then we set it to undefined in case we are not in node, since
|
||||
// in StringHashTable below, we check for undefined explicitly.
|
||||
this[proto] = null;
|
||||
this[proto] = undefined;
|
||||
}
|
||||
}
|
||||
|
||||
export function createIntrinsicsObject<T>(): ts.Map<T> {
|
||||
return new BlockIntrinsics<T>();
|
||||
}
|
||||
|
||||
//export interface IHashTable<T> {
|
||||
// getAllKeys(): string[];
|
||||
// add(key: string, data: T): boolean;
|
||||
// addOrUpdate(key: string, data: T): boolean;
|
||||
// map(fn: (k: string, value: T, context: any) => void , context: any): void;
|
||||
// every(fn: (k: string, value: T, context: any) => void , context: any): boolean;
|
||||
// some(fn: (k: string, value: T, context: any) => void , context: any): boolean;
|
||||
// count(): number;
|
||||
// lookup(key: string): T;
|
||||
//}
|
||||
|
||||
//export class StringHashTable<T> implements IHashTable<T> {
|
||||
// private itemCount = 0;
|
||||
// private table: IIndexable<T> = createIntrinsicsObject<T>();
|
||||
|
||||
// public getAllKeys(): string[] {
|
||||
// var result: string[] = [];
|
||||
|
||||
// for (var k in this.table) {
|
||||
// if (this.table[k] !== undefined) {
|
||||
// result.push(k);
|
||||
// }
|
||||
// }
|
||||
|
||||
// return result;
|
||||
// }
|
||||
|
||||
// public add(key: string, data: T): boolean {
|
||||
// if (this.table[key] !== undefined) {
|
||||
// return false;
|
||||
// }
|
||||
|
||||
// this.table[key] = data;
|
||||
// this.itemCount++;
|
||||
// return true;
|
||||
// }
|
||||
|
||||
// public addOrUpdate(key: string, data: T): boolean {
|
||||
// if (this.table[key] !== undefined) {
|
||||
// this.table[key] = data;
|
||||
// return false;
|
||||
// }
|
||||
|
||||
// this.table[key] = data;
|
||||
// this.itemCount++;
|
||||
// return true;
|
||||
// }
|
||||
|
||||
// public map(fn: (k: string, value: T, context: any) => void , context: any) {
|
||||
// for (var k in this.table) {
|
||||
// var data = this.table[k];
|
||||
|
||||
// if (data !== undefined) {
|
||||
// fn(k, this.table[k], context);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
// public every(fn: (k: string, value: T, context: any) => void , context: any) {
|
||||
// for (var k in this.table) {
|
||||
// var data = this.table[k];
|
||||
|
||||
// if (data !== undefined) {
|
||||
// if (!fn(k, this.table[k], context)) {
|
||||
// return false;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
// return true;
|
||||
// }
|
||||
|
||||
// public some(fn: (k: string, value: T, context: any) => void , context: any) {
|
||||
// for (var k in this.table) {
|
||||
// var data = this.table[k];
|
||||
|
||||
// if (data !== undefined) {
|
||||
// if (fn(k, this.table[k], context)) {
|
||||
// return true;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
// return false;
|
||||
// }
|
||||
|
||||
// public count(): number {
|
||||
// return this.itemCount;
|
||||
// }
|
||||
|
||||
// public lookup(key: string) : T {
|
||||
// var data = this.table[key];
|
||||
// return data === undefined ? null : data;
|
||||
// }
|
||||
|
||||
// public remove(key: string): void {
|
||||
// if (this.table[key] !== undefined) {
|
||||
// this.table[key] = undefined;
|
||||
// this.itemCount--;
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
||||
|
||||
//export class IdentiferNameHashTable<T> extends StringHashTable<T> {
|
||||
// public getAllKeys(): string[]{
|
||||
// var result: string[] = [];
|
||||
|
||||
// super.map((k, v, c) => {
|
||||
// if (v !== undefined) {
|
||||
// result.push(k.substring(1));
|
||||
// }
|
||||
// }, null);
|
||||
|
||||
// return result;
|
||||
// }
|
||||
|
||||
// public add(key: string, data: T): boolean {
|
||||
// return super.add("#" + key, data);
|
||||
// }
|
||||
|
||||
// public addOrUpdate(key: string, data: T): boolean {
|
||||
// return super.addOrUpdate("#" + key, data);
|
||||
// }
|
||||
|
||||
// public map(fn: (k: string, value: T, context: any) => void , context: any) {
|
||||
// return super.map((k, v, c) => fn(k.substring(1), v, c), context);
|
||||
// }
|
||||
|
||||
// public every(fn: (k: string, value: T, context: any) => void , context: any) {
|
||||
// return super.every((k, v, c) => fn(k.substring(1), v, c), context);
|
||||
// }
|
||||
|
||||
// public some(fn: (k: string, value: any, context: any) => void , context: any) {
|
||||
// return super.some((k, v, c) => fn(k.substring(1), v, c), context);
|
||||
// }
|
||||
|
||||
// public lookup(key: string): T {
|
||||
// return super.lookup("#" + key);
|
||||
// }
|
||||
//}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
module TypeScript {
|
||||
export class IdentifierWalker extends SyntaxWalker {
|
||||
constructor(public list: IIndexable<boolean>) {
|
||||
super();
|
||||
}
|
||||
|
||||
public visitToken(token: ISyntaxToken): void {
|
||||
this.list[token.text()] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,64 +0,0 @@
|
||||
//
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
///<reference path='enumerator.ts' />
|
||||
///<reference path='process.ts' />
|
||||
///<reference path='core\references.ts' />
|
||||
|
||||
module TypeScript {
|
||||
|
||||
export interface IFindFileResult {
|
||||
fileInformation: FileInformation;
|
||||
path: string;
|
||||
}
|
||||
|
||||
export module IOUtils {
|
||||
// Creates the directory including its parent if not already present
|
||||
function createDirectoryStructure(ioHost: IEnvironment, dirName: string) {
|
||||
if (ioHost.directoryExists(dirName)) {
|
||||
return;
|
||||
}
|
||||
|
||||
var parentDirectory = ioHost.directoryName(dirName);
|
||||
if (parentDirectory != "") {
|
||||
createDirectoryStructure(ioHost, parentDirectory);
|
||||
}
|
||||
ioHost.createDirectory(dirName);
|
||||
}
|
||||
|
||||
// Creates a file including its directory structure if not already present
|
||||
export function writeFileAndFolderStructure(ioHost: IEnvironment, fileName: string, contents: string, writeByteOrderMark: boolean): void {
|
||||
var start = new Date().getTime();
|
||||
var path = ioHost.absolutePath(fileName);
|
||||
TypeScript.ioHostResolvePathTime += new Date().getTime() - start;
|
||||
|
||||
var start = new Date().getTime();
|
||||
var dirName = ioHost.directoryName(path);
|
||||
TypeScript.ioHostDirectoryNameTime += new Date().getTime() - start;
|
||||
|
||||
var start = new Date().getTime();
|
||||
createDirectoryStructure(ioHost, dirName);
|
||||
TypeScript.ioHostCreateDirectoryStructureTime += new Date().getTime() - start;
|
||||
|
||||
var start = new Date().getTime();
|
||||
ioHost.writeFile(path, contents, writeByteOrderMark);
|
||||
TypeScript.ioHostWriteFileTime += new Date().getTime() - start;
|
||||
}
|
||||
|
||||
export function combine(prefix: string, suffix: string): string {
|
||||
return prefix + "/" + suffix;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
//
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
///<reference path='references.ts' />
|
||||
|
||||
module TypeScript {
|
||||
function isFileOfExtension(fname: string, ext: string) {
|
||||
var invariantFname = fname.toLocaleUpperCase();
|
||||
var invariantExt = ext.toLocaleUpperCase();
|
||||
var extLength = invariantExt.length;
|
||||
return invariantFname.length > extLength && invariantFname.substring(invariantFname.length - extLength, invariantFname.length) === invariantExt;
|
||||
}
|
||||
|
||||
export function isDTSFile(fname: string) {
|
||||
return isFileOfExtension(fname, ".d.ts");
|
||||
}
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
//declare module process {
|
||||
// export var argv: string[];
|
||||
// export var platform: string;
|
||||
// export function on(event: string, handler: (arg: any) => void ): void;
|
||||
// export module stdout {
|
||||
// export function write(str: string): any;
|
||||
// export function on(event: string, action: () => void ): void;
|
||||
// }
|
||||
// export module stderr {
|
||||
// export function write(str: string): any;
|
||||
// export function on(event: string, action: () => void): void;
|
||||
// }
|
||||
// export module mainModule {
|
||||
// export var filename: string;
|
||||
// }
|
||||
// export function exit(exitCode?: number): any;
|
||||
//}
|
||||
@@ -1,32 +0,0 @@
|
||||
/////<reference path='resources\references.ts' />
|
||||
/////<reference path='core\references.ts' />
|
||||
/////<reference path='text\references.ts' />
|
||||
/////<reference path='syntax\references.ts' />
|
||||
/////<reference path='diagnostics.ts' />
|
||||
/////<reference path='document.ts' />
|
||||
/////<reference path='flags.ts' />
|
||||
/////<reference path='hashTable.ts' />
|
||||
/////<reference path='base64.ts' />
|
||||
/////<reference path='sourceMapping.ts' />
|
||||
/////<reference path='emitter.ts' />
|
||||
/////<reference path='pathUtils.ts' />
|
||||
/////<reference path='referenceResolution.ts' />
|
||||
/////<reference path='precompile.ts' />
|
||||
/////<reference path='referenceResolver.ts' />
|
||||
/////<reference path='declarationEmitter.ts' />
|
||||
/////<reference path='identifierWalker.ts' />
|
||||
/////<reference path='settings.ts' />
|
||||
/////<reference path='typecheck\pullFlags.ts' />
|
||||
/////<reference path='typecheck\pullDecls.ts' />
|
||||
/////<reference path='typecheck\pullSymbols.ts' />
|
||||
/////<reference path='typecheck\pullTypeEnclosingTypeWalker.ts' />
|
||||
/////<reference path='typecheck\pullTypeResolutionContext.ts' />
|
||||
/////<reference path='typecheck\pullTypeResolution.ts' />
|
||||
/////<reference path='typecheck\pullSemanticInfo.ts' />
|
||||
/////<reference path='typecheck\pullDeclCollection.ts' />
|
||||
/////<reference path='typecheck\pullSymbolBinder.ts' />
|
||||
/////<reference path='typecheck\pullHelpers.ts' />
|
||||
/////<reference path='typecheck\pullInstantiationHelpers.ts' />
|
||||
|
||||
/////<reference path='typecheck\pullTypeInstantiation.ts' />
|
||||
/////<reference path='typescript.ts' />
|
||||
@@ -1,270 +0,0 @@
|
||||
//
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
///<reference path='references.ts' />
|
||||
|
||||
module TypeScript {
|
||||
export class SourceMapPosition {
|
||||
public sourceLine: number;
|
||||
public sourceColumn: number;
|
||||
public emittedLine: number;
|
||||
public emittedColumn: number;
|
||||
}
|
||||
|
||||
export class SourceMapping {
|
||||
public start = new SourceMapPosition();
|
||||
public end = new SourceMapPosition();
|
||||
public nameIndex: number = -1;
|
||||
public childMappings: SourceMapping[] = [];
|
||||
}
|
||||
|
||||
export class SourceMapEntry {
|
||||
constructor(
|
||||
public emittedFile: string,
|
||||
public emittedLine: number,
|
||||
public emittedColumn: number,
|
||||
public sourceFile: string,
|
||||
public sourceLine: number,
|
||||
public sourceColumn: number,
|
||||
public sourceName: string) {
|
||||
|
||||
Debug.assert(isFinite(emittedLine));
|
||||
Debug.assert(isFinite(emittedColumn));
|
||||
Debug.assert(isFinite(sourceColumn));
|
||||
Debug.assert(isFinite(sourceLine));
|
||||
}
|
||||
}
|
||||
|
||||
export class SourceMapper {
|
||||
static MapFileExtension = ".map";
|
||||
|
||||
private jsFileName: string;
|
||||
private sourceMapPath: string;
|
||||
private sourceMapDirectory: string;
|
||||
private sourceRoot: string;
|
||||
|
||||
public names: string[] = [];
|
||||
|
||||
private mappingLevel: ISpan[] = [];
|
||||
|
||||
// Below two arrays represent the information about sourceFile at that index.
|
||||
private tsFilePaths: string[] = [];
|
||||
private allSourceMappings: SourceMapping[][] = [];
|
||||
|
||||
public currentMappings: SourceMapping[][];
|
||||
public currentNameIndex: number[];
|
||||
|
||||
private sourceMapEntries: SourceMapEntry[] = [];
|
||||
|
||||
constructor(private jsFile: TextWriter,
|
||||
private sourceMapOut: TextWriter,
|
||||
document: Document,
|
||||
jsFilePath: string,
|
||||
emitOptions: EmitOptions,
|
||||
resolvePath: (path: string) => string) {
|
||||
this.setSourceMapOptions(document, jsFilePath, emitOptions, resolvePath);
|
||||
this.setNewSourceFile(document, emitOptions);
|
||||
}
|
||||
|
||||
public getOutputFile(): OutputFile {
|
||||
var result = this.sourceMapOut.getOutputFile();
|
||||
result.sourceMapEntries = this.sourceMapEntries;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public increaseMappingLevel(ast: ISpan) {
|
||||
this.mappingLevel.push(ast);
|
||||
}
|
||||
|
||||
public decreaseMappingLevel(ast: any) {
|
||||
Debug.assert(this.mappingLevel.length > 0, "Mapping level should never be less than 0. This suggests a missing start call.");
|
||||
var expectedAst = this.mappingLevel.pop();
|
||||
if (ast !== expectedAst) {
|
||||
var expectedAstInfo: any = (<any>expectedAst).kind ? SyntaxKind[(<any>expectedAst).kind] : [expectedAst.start(), expectedAst.end()];
|
||||
var astInfo: any = (<any>ast).kind ? SyntaxKind[(<any>ast).kind] : [ast.start(), ast.end()];
|
||||
Debug.fail(
|
||||
"Provided ast is not the expected ISyntaxElement, Expected: " + expectedAstInfo + " Given: " + astInfo);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public setNewSourceFile(document: Document, emitOptions: EmitOptions) {
|
||||
// Set new mappings
|
||||
var sourceMappings: SourceMapping[] = [];
|
||||
this.allSourceMappings.push(sourceMappings);
|
||||
this.currentMappings = [sourceMappings];
|
||||
this.currentNameIndex = [];
|
||||
|
||||
// Set new source file path
|
||||
this.setNewSourceFilePath(document, emitOptions);
|
||||
}
|
||||
|
||||
private setSourceMapOptions(document: Document, jsFilePath: string, emitOptions: EmitOptions, resolvePath: (path: string) => string) {
|
||||
// Decode mapRoot and sourceRoot
|
||||
|
||||
// Js File Name = pretty name of js file
|
||||
var prettyJsFileName = TypeScript.getPrettyName(jsFilePath, false, true);
|
||||
var prettyMapFileName = prettyJsFileName + SourceMapper.MapFileExtension;
|
||||
this.jsFileName = prettyJsFileName;
|
||||
|
||||
// Figure out sourceMapPath and sourceMapDirectory
|
||||
if (emitOptions.sourceMapRootDirectory()) {
|
||||
// Get the sourceMap Directory
|
||||
this.sourceMapDirectory = emitOptions.sourceMapRootDirectory();
|
||||
if (document.emitToOwnOutputFile()) {
|
||||
// For modules or multiple emit files the mapRoot will have directory structure like the sources
|
||||
// So if src\a.ts and src\lib\b.ts are compiled together user would be moving the maps into mapRoot\a.js.map and mapRoot\lib\b.js.map
|
||||
this.sourceMapDirectory = this.sourceMapDirectory + switchToForwardSlashes(getRootFilePath((document.fileName)).replace(emitOptions.commonDirectoryPath(), ""));
|
||||
}
|
||||
|
||||
if (isRelative(this.sourceMapDirectory)) {
|
||||
// The relative paths are relative to the common directory
|
||||
this.sourceMapDirectory = emitOptions.commonDirectoryPath() + this.sourceMapDirectory;
|
||||
this.sourceMapDirectory = convertToDirectoryPath(switchToForwardSlashes(resolvePath(this.sourceMapDirectory)));
|
||||
this.sourceMapPath = getRelativePathToFixedPath(getRootFilePath(jsFilePath), this.sourceMapDirectory + prettyMapFileName);
|
||||
}
|
||||
else {
|
||||
this.sourceMapPath = this.sourceMapDirectory + prettyMapFileName;
|
||||
}
|
||||
}
|
||||
else {
|
||||
this.sourceMapPath = prettyMapFileName;
|
||||
this.sourceMapDirectory = getRootFilePath(jsFilePath);
|
||||
}
|
||||
this.sourceRoot = emitOptions.sourceRootDirectory();
|
||||
}
|
||||
|
||||
private setNewSourceFilePath(document: Document, emitOptions: EmitOptions) {
|
||||
var tsFilePath = switchToForwardSlashes(document.fileName);
|
||||
if (emitOptions.sourceRootDirectory()) {
|
||||
// Use the relative path corresponding to the common directory path
|
||||
tsFilePath = getRelativePathToFixedPath(emitOptions.commonDirectoryPath(), tsFilePath);
|
||||
}
|
||||
else {
|
||||
// Source locations relative to map file location
|
||||
tsFilePath = getRelativePathToFixedPath(this.sourceMapDirectory, tsFilePath);
|
||||
}
|
||||
this.tsFilePaths.push(tsFilePath);
|
||||
}
|
||||
|
||||
// Generate source mapping.
|
||||
// Creating files can cause exceptions, they will be caught higher up in TypeScriptCompiler.emit
|
||||
public emitSourceMapping(): void {
|
||||
Debug.assert(
|
||||
this.mappingLevel.length === 0,
|
||||
"Mapping level is not 0. This suggest a missing end call. Value: " +
|
||||
this.mappingLevel.map(item => ['Node of type', SyntaxKind[(<any>item).kind], 'at', item.start(), 'to', item.end()].join(' ')).join(', '));
|
||||
// Output map file name into the js file
|
||||
this.jsFile.WriteLine("//# sourceMappingURL=" + this.sourceMapPath);
|
||||
|
||||
// Now output map file
|
||||
var mappingsString = "";
|
||||
|
||||
var prevEmittedColumn = 0;
|
||||
var prevEmittedLine = 0;
|
||||
var prevSourceColumn = 0;
|
||||
var prevSourceLine = 0;
|
||||
var prevSourceIndex = 0;
|
||||
var prevNameIndex = 0;
|
||||
var emitComma = false;
|
||||
|
||||
var recordedPosition: SourceMapPosition = null;
|
||||
for (var sourceIndex = 0; sourceIndex < this.tsFilePaths.length; sourceIndex++) {
|
||||
var recordSourceMapping = (mappedPosition: SourceMapPosition, nameIndex: number) => {
|
||||
|
||||
if (recordedPosition !== null &&
|
||||
recordedPosition.emittedColumn === mappedPosition.emittedColumn &&
|
||||
recordedPosition.emittedLine === mappedPosition.emittedLine) {
|
||||
// This position is already recorded
|
||||
return;
|
||||
}
|
||||
|
||||
// Record this position
|
||||
if (prevEmittedLine !== mappedPosition.emittedLine) {
|
||||
while (prevEmittedLine < mappedPosition.emittedLine) {
|
||||
prevEmittedColumn = 0;
|
||||
mappingsString = mappingsString + ";";
|
||||
prevEmittedLine++;
|
||||
}
|
||||
emitComma = false;
|
||||
}
|
||||
else if (emitComma) {
|
||||
mappingsString = mappingsString + ",";
|
||||
}
|
||||
|
||||
this.sourceMapEntries.push(new SourceMapEntry(
|
||||
this.jsFileName,
|
||||
mappedPosition.emittedLine + 1,
|
||||
mappedPosition.emittedColumn + 1,
|
||||
this.tsFilePaths[sourceIndex],
|
||||
mappedPosition.sourceLine,
|
||||
mappedPosition.sourceColumn + 1,
|
||||
nameIndex >= 0 ? this.names[nameIndex] : undefined));
|
||||
|
||||
// 1. Relative Column
|
||||
mappingsString = mappingsString + Base64VLQFormat.encode(mappedPosition.emittedColumn - prevEmittedColumn);
|
||||
prevEmittedColumn = mappedPosition.emittedColumn;
|
||||
|
||||
// 2. Relative sourceIndex
|
||||
mappingsString = mappingsString + Base64VLQFormat.encode(sourceIndex - prevSourceIndex);
|
||||
prevSourceIndex = sourceIndex;
|
||||
|
||||
// 3. Relative sourceLine 0 based
|
||||
mappingsString = mappingsString + Base64VLQFormat.encode(mappedPosition.sourceLine - 1 - prevSourceLine);
|
||||
prevSourceLine = mappedPosition.sourceLine - 1;
|
||||
|
||||
// 4. Relative sourceColumn 0 based
|
||||
mappingsString = mappingsString + Base64VLQFormat.encode(mappedPosition.sourceColumn - prevSourceColumn);
|
||||
prevSourceColumn = mappedPosition.sourceColumn;
|
||||
|
||||
// 5. Relative namePosition 0 based
|
||||
if (nameIndex >= 0) {
|
||||
mappingsString = mappingsString + Base64VLQFormat.encode(nameIndex - prevNameIndex);
|
||||
prevNameIndex = nameIndex;
|
||||
}
|
||||
|
||||
emitComma = true;
|
||||
recordedPosition = mappedPosition;
|
||||
};
|
||||
|
||||
// Record starting spans
|
||||
var recordSourceMappingSiblings = (sourceMappings: SourceMapping[]) => {
|
||||
for (var i = 0; i < sourceMappings.length; i++) {
|
||||
var sourceMapping = sourceMappings[i];
|
||||
recordSourceMapping(sourceMapping.start, sourceMapping.nameIndex);
|
||||
recordSourceMappingSiblings(sourceMapping.childMappings);
|
||||
recordSourceMapping(sourceMapping.end, sourceMapping.nameIndex);
|
||||
}
|
||||
};
|
||||
|
||||
recordSourceMappingSiblings(this.allSourceMappings[sourceIndex]);
|
||||
}
|
||||
|
||||
// Write the actual map file
|
||||
this.sourceMapOut.Write(JSON.stringify({
|
||||
version: 3,
|
||||
file: this.jsFileName,
|
||||
sourceRoot: this.sourceRoot,
|
||||
sources: this.tsFilePaths,
|
||||
names: this.names,
|
||||
mappings: mappingsString
|
||||
}));
|
||||
|
||||
// Closing files could result in exceptions, report them if they occur
|
||||
this.sourceMapOut.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,31 +0,0 @@
|
||||
//
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
///<reference path='typescript.ts' />
|
||||
|
||||
module Tools {
|
||||
export interface IWalkContext {
|
||||
goChildren: boolean;
|
||||
goNextSibling: boolean;
|
||||
// visit siblings in reverse execution order
|
||||
reverseSiblings: boolean;
|
||||
}
|
||||
|
||||
export class BaseWalkContext implements IWalkContext {
|
||||
public goChildren = true;
|
||||
public goNextSibling = true;
|
||||
public reverseSiblings = false;
|
||||
}
|
||||
}
|
||||
@@ -1,205 +0,0 @@
|
||||
///<reference path='references.ts' />
|
||||
|
||||
module TypeScript {
|
||||
export class ArrayUtilities {
|
||||
public static sequenceEquals<T>(array1: T[], array2: T[], equals: (v1: T, v2: T) => boolean) {
|
||||
if (array1 === array2) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!array1 || !array2) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (array1.length !== array2.length) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (var i = 0, n = array1.length; i < n; i++) {
|
||||
if (!equals(array1[i], array2[i])) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static contains<T>(array: T[], value: T): boolean {
|
||||
for (var i = 0; i < array.length; i++) {
|
||||
if (array[i] === value) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// Gets unique element array
|
||||
public static distinct<T>(array: T[], equalsFn?: (a: T, b: T) => boolean): T[] {
|
||||
var result: T[] = [];
|
||||
|
||||
// TODO: use map when available
|
||||
for (var i = 0, n = array.length; i < n; i++) {
|
||||
var current = array[i];
|
||||
for (var j = 0; j < result.length; j++) {
|
||||
if (equalsFn(result[j], current)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (j === result.length) {
|
||||
result.push(current);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public static last<T>(array: T[]): T {
|
||||
if (array.length === 0) {
|
||||
throw Errors.argumentOutOfRange('array');
|
||||
}
|
||||
|
||||
return array[array.length - 1];
|
||||
}
|
||||
|
||||
public static lastOrDefault<T>(array: T[], predicate: (v: T, index: number) => boolean): T {
|
||||
for (var i = array.length - 1; i >= 0; i--) {
|
||||
var v = array[i];
|
||||
if (predicate(v, i)) {
|
||||
return v;
|
||||
}
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
public static firstOrDefault<T>(array: T[], func: (v: T, index: number) => boolean): T {
|
||||
for (var i = 0, n = array.length; i < n; i++) {
|
||||
var value = array[i];
|
||||
if (func(value, i)) {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
public static first<T>(array: T[], func?: (v: T, index: number) => boolean): T {
|
||||
for (var i = 0, n = array.length; i < n; i++) {
|
||||
var value = array[i];
|
||||
if (!func || func(value, i)) {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
throw Errors.invalidOperation();
|
||||
}
|
||||
|
||||
public static sum<T>(array: T[], func: (v: T) => number): number {
|
||||
var result = 0;
|
||||
|
||||
for (var i = 0, n = array.length; i < n; i++) {
|
||||
result += func(array[i]);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public static select<T,S>(values: T[], func: (v: T) => S): S[] {
|
||||
var result: S[] = new Array<S>(values.length);
|
||||
|
||||
for (var i = 0; i < values.length; i++) {
|
||||
result[i] = func(values[i]);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public static where<T>(values: T[], func: (v: T) => boolean): T[] {
|
||||
var result = new Array<T>();
|
||||
|
||||
for (var i = 0; i < values.length; i++) {
|
||||
if (func(values[i])) {
|
||||
result.push(values[i]);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public static any<T>(array: T[], func: (v: T) => boolean): boolean {
|
||||
for (var i = 0, n = array.length; i < n; i++) {
|
||||
if (func(array[i])) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static all<T>(array: T[], func: (v: T) => boolean): boolean {
|
||||
for (var i = 0, n = array.length; i < n; i++) {
|
||||
if (!func(array[i])) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static binarySearch(array: number[], value: number): number {
|
||||
var low = 0;
|
||||
var high = array.length - 1;
|
||||
|
||||
while (low <= high) {
|
||||
var middle = low + ((high - low) >> 1);
|
||||
var midValue = array[middle];
|
||||
|
||||
if (midValue === value) {
|
||||
return middle;
|
||||
}
|
||||
else if (midValue > value) {
|
||||
high = middle - 1;
|
||||
}
|
||||
else {
|
||||
low = middle + 1;
|
||||
}
|
||||
}
|
||||
|
||||
return ~low;
|
||||
}
|
||||
|
||||
public static createArray<T>(length: number, defaultValue: any): T[] {
|
||||
var result = new Array<T>(length);
|
||||
for (var i = 0; i < length; i++) {
|
||||
result[i] = defaultValue;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public static grow<T>(array: T[], length: number, defaultValue: T): void {
|
||||
var count = length - array.length;
|
||||
for (var i = 0; i < count; i++) {
|
||||
array.push(defaultValue);
|
||||
}
|
||||
}
|
||||
|
||||
public static copy<T>(sourceArray: T[], sourceIndex: number, destinationArray: T[], destinationIndex: number, length: number): void {
|
||||
for (var i = 0; i < length; i++) {
|
||||
destinationArray[destinationIndex + i] = sourceArray[sourceIndex + i];
|
||||
}
|
||||
}
|
||||
|
||||
public static indexOf<T>(array: T[], predicate: (v: T) => boolean): number {
|
||||
for (var i = 0, n = array.length; i < n; i++) {
|
||||
if (predicate(array[i])) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
///<reference path='references.ts' />
|
||||
|
||||
module TypeScript {
|
||||
export enum AssertionLevel {
|
||||
None = 0,
|
||||
Normal = 1,
|
||||
Aggressive = 2,
|
||||
VeryAggressive = 3,
|
||||
}
|
||||
|
||||
export class Debug {
|
||||
private static currentAssertionLevel = AssertionLevel.None;
|
||||
public static shouldAssert(level: AssertionLevel): boolean {
|
||||
return this.currentAssertionLevel >= level;
|
||||
}
|
||||
|
||||
public static assert(expression: any, message?: string, verboseDebugInfo?: () => string): void {
|
||||
if (!expression) {
|
||||
var verboseDebugString = "";
|
||||
if (verboseDebugInfo) {
|
||||
verboseDebugString = "\r\nVerbose Debug Information:" + verboseDebugInfo();
|
||||
}
|
||||
|
||||
message = message || "";
|
||||
throw new Error("Debug Failure. False expression: " + message + verboseDebugString);
|
||||
}
|
||||
}
|
||||
|
||||
public static fail(message?: string): void {
|
||||
Debug.assert(false, message);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
///<reference path='references.ts' />
|
||||
|
||||
module TypeScript {
|
||||
export enum DiagnosticCategory {
|
||||
Warning,
|
||||
Error,
|
||||
Message,
|
||||
NoPrefix,
|
||||
}
|
||||
}
|
||||
@@ -1,195 +0,0 @@
|
||||
///<reference path='references.ts' />
|
||||
|
||||
module TypeScript {
|
||||
export class Location {
|
||||
private _fileName: string;
|
||||
private _lineMap: LineMap;
|
||||
private _start: number;
|
||||
private _length: number;
|
||||
|
||||
constructor(fileName: string, lineMap: LineMap, start: number, length: number) {
|
||||
this._fileName = fileName;
|
||||
this._lineMap = lineMap;
|
||||
this._start = start;
|
||||
this._length = length;
|
||||
}
|
||||
|
||||
public fileName(): string {
|
||||
return this._fileName;
|
||||
}
|
||||
|
||||
public lineMap(): LineMap {
|
||||
return this._lineMap;
|
||||
}
|
||||
|
||||
public line(): number {
|
||||
return this._lineMap ? this._lineMap.getLineNumberFromPosition(this.start()) : 0;
|
||||
}
|
||||
|
||||
public character(): number {
|
||||
return this._lineMap ? this._lineMap.getLineAndCharacterFromPosition(this.start()).character() : 0;
|
||||
}
|
||||
|
||||
public start(): number {
|
||||
return this._start;
|
||||
}
|
||||
|
||||
public length(): number {
|
||||
return this._length;
|
||||
}
|
||||
|
||||
public static equals(location1: Location, location2: Location): boolean {
|
||||
return location1._fileName === location2._fileName &&
|
||||
location1._start === location2._start &&
|
||||
location1._length === location2._length;
|
||||
}
|
||||
}
|
||||
|
||||
export class Diagnostic extends Location {
|
||||
private _diagnosticKey: string;
|
||||
private _arguments: any[];
|
||||
private _additionalLocations: Location[];
|
||||
|
||||
constructor(fileName: string, lineMap: LineMap, start: number, length: number, diagnosticKey: string, _arguments?: any[], additionalLocations?: Location[]) {
|
||||
super(fileName, lineMap, start, length);
|
||||
this._diagnosticKey = diagnosticKey;
|
||||
this._arguments = (_arguments && _arguments.length > 0) ? _arguments : undefined;
|
||||
this._additionalLocations = (additionalLocations && additionalLocations.length > 0) ? additionalLocations : undefined;
|
||||
}
|
||||
|
||||
public toJSON(key: any): any {
|
||||
var result: any = {};
|
||||
result.start = this.start();
|
||||
result.length = this.length();
|
||||
|
||||
result.diagnosticCode = this._diagnosticKey;
|
||||
|
||||
var _arguments: any[] = (<any>this).arguments();
|
||||
if (_arguments && _arguments.length > 0) {
|
||||
result.arguments = _arguments;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public diagnosticKey(): string {
|
||||
return this._diagnosticKey;
|
||||
}
|
||||
|
||||
public arguments(): any[] {
|
||||
return this._arguments;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the text of the message in the given language.
|
||||
*/
|
||||
public text(): string {
|
||||
return TypeScript.getLocalizedText(this._diagnosticKey, this._arguments);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the text of the message including the error code in the given language.
|
||||
*/
|
||||
public message(): string {
|
||||
return TypeScript.getDiagnosticMessage(this._diagnosticKey, this._arguments);
|
||||
}
|
||||
|
||||
/**
|
||||
* If a derived class has additional information about other referenced symbols, it can
|
||||
* expose the locations of those symbols in a general way, so they can be reported along
|
||||
* with the error.
|
||||
*/
|
||||
public additionalLocations(): Location[] {
|
||||
return this._additionalLocations || [];
|
||||
}
|
||||
|
||||
public static equals(diagnostic1: Diagnostic, diagnostic2: Diagnostic): boolean {
|
||||
return Location.equals(diagnostic1, diagnostic2) &&
|
||||
diagnostic1._diagnosticKey === diagnostic2._diagnosticKey &&
|
||||
ArrayUtilities.sequenceEquals(diagnostic1._arguments, diagnostic2._arguments, (v1, v2) => v1 === v2);
|
||||
}
|
||||
|
||||
public info(): DiagnosticInfo {
|
||||
return getDiagnosticInfoFromKey(this.diagnosticKey());
|
||||
}
|
||||
}
|
||||
|
||||
export function newLine(): string {
|
||||
// TODO: We need to expose an extensibility point on our hosts to have them tell us what
|
||||
// they want the newline string to be. That way we can get the correct result regardless
|
||||
// of which host we use
|
||||
return "\r\n";
|
||||
}
|
||||
|
||||
function getLargestIndex(diagnostic: string): number {
|
||||
var largest = -1;
|
||||
var regex = /\{(\d+)\}/g;
|
||||
|
||||
var match: RegExpExecArray;
|
||||
while (match = regex.exec(diagnostic)) {
|
||||
var val = parseInt(match[1]);
|
||||
if (!isNaN(val) && val > largest) {
|
||||
largest = val;
|
||||
}
|
||||
}
|
||||
|
||||
return largest;
|
||||
}
|
||||
|
||||
function getDiagnosticInfoFromKey(diagnosticKey: string): DiagnosticInfo {
|
||||
var result: DiagnosticInfo = diagnosticInformationMap[diagnosticKey];
|
||||
Debug.assert(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
export function getLocalizedText(diagnosticKey: string, args: any[]): string {
|
||||
|
||||
var diagnosticMessageText: string = diagnosticKey;
|
||||
Debug.assert(diagnosticMessageText !== undefined && diagnosticMessageText !== null);
|
||||
|
||||
var actualCount = args ? args.length : 0;
|
||||
// We have a string like "foo_0_bar_1". We want to find the largest integer there.
|
||||
// (i.e.'1'). We then need one more arg than that to be correct.
|
||||
var expectedCount = 1 + getLargestIndex(diagnosticKey);
|
||||
|
||||
if (expectedCount !== actualCount) {
|
||||
throw new Error(getLocalizedText(DiagnosticCode.Expected_0_arguments_to_message_got_1_instead, [expectedCount, actualCount]));
|
||||
}
|
||||
|
||||
// This should also be the same number of arguments as the message text
|
||||
var valueCount = 1 + getLargestIndex(diagnosticMessageText);
|
||||
if (valueCount !== expectedCount) {
|
||||
throw new Error(getLocalizedText(DiagnosticCode.Expected_the_message_0_to_have_1_arguments_but_it_had_2, [diagnosticMessageText, expectedCount, valueCount]));
|
||||
}
|
||||
|
||||
diagnosticMessageText = diagnosticMessageText.replace(/{(\d+)}/g, function (match, num?) {
|
||||
return typeof args[num] !== 'undefined'
|
||||
? args[num]
|
||||
: match;
|
||||
});
|
||||
|
||||
diagnosticMessageText = diagnosticMessageText.replace(/{(NL)}/g, function (match) {
|
||||
return TypeScript.newLine();
|
||||
});
|
||||
|
||||
return diagnosticMessageText;
|
||||
}
|
||||
|
||||
export function getDiagnosticMessage(diagnosticKey: string, args: any[]): string {
|
||||
var diagnostic = getDiagnosticInfoFromKey(diagnosticKey);
|
||||
var diagnosticMessageText = getLocalizedText(diagnosticKey, args);
|
||||
|
||||
var message: string;
|
||||
if (diagnostic.category === DiagnosticCategory.Error) {
|
||||
message = getLocalizedText(DiagnosticCode.error_TS_0_1, [diagnostic.code, diagnosticMessageText]);
|
||||
}
|
||||
else if (diagnostic.category === DiagnosticCategory.Warning) {
|
||||
message = getLocalizedText(DiagnosticCode.warning_TS_0_1, [diagnostic.code, diagnosticMessageText]);
|
||||
}
|
||||
else {
|
||||
message = diagnosticMessageText;
|
||||
}
|
||||
|
||||
return message;
|
||||
}
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
///<reference path='references.ts' />
|
||||
|
||||
module TypeScript {
|
||||
export interface DiagnosticInfo {
|
||||
category: DiagnosticCategory;
|
||||
message: string;
|
||||
code: number;
|
||||
}
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
///<reference path='references.ts' />
|
||||
|
||||
module TypeScript {
|
||||
export class Errors {
|
||||
public static argument(argument: string, message?: string): Error {
|
||||
return new Error("Invalid argument: " + argument + ". " + message);
|
||||
}
|
||||
|
||||
public static argumentOutOfRange(argument: string): Error {
|
||||
return new Error("Argument out of range: " + argument);
|
||||
}
|
||||
|
||||
public static argumentNull(argument: string): Error {
|
||||
return new Error("Argument null: " + argument);
|
||||
}
|
||||
|
||||
public static abstract(): Error {
|
||||
return new Error("Operation not implemented properly by subclass.");
|
||||
}
|
||||
|
||||
public static notYetImplemented(): Error {
|
||||
return new Error("Not yet implemented.");
|
||||
}
|
||||
|
||||
public static invalidOperation(message?: string): Error {
|
||||
return new Error("Invalid operation: " + message);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
///<reference path='references.ts' />
|
||||
|
||||
module TypeScript {
|
||||
export module IntegerUtilities {
|
||||
export function integerDivide(numerator: number, denominator: number): number {
|
||||
return (numerator / denominator) >> 0;
|
||||
}
|
||||
|
||||
export function integerMultiplyLow32Bits(n1: number, n2: number): number {
|
||||
var resultLow32 = (((n1 & 0xffff0000) * n2) >>> 0) + (((n1 & 0x0000ffff) * n2) >>> 0) >>> 0;
|
||||
return resultLow32;
|
||||
}
|
||||
|
||||
export function isInteger(text: string): boolean {
|
||||
return /^[0-9]+$/.test(text);
|
||||
}
|
||||
|
||||
export function isHexInteger(text: string): boolean {
|
||||
return /^0(x|X)[0-9a-fA-F]+$/.test(text);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,87 +0,0 @@
|
||||
///<reference path='references.ts' />
|
||||
|
||||
module TypeScript {
|
||||
export interface ILineAndCharacter {
|
||||
line: number;
|
||||
character: number;
|
||||
}
|
||||
|
||||
export class LineMap {
|
||||
public static empty = new LineMap(() => [0], 0);
|
||||
private _lineStarts: number[] = undefined;
|
||||
|
||||
constructor(private _computeLineStarts: () => number[], private length: number) {
|
||||
}
|
||||
|
||||
public toJSON(key: any) {
|
||||
return { lineStarts: this.lineStarts(), length: this.length };
|
||||
}
|
||||
|
||||
public equals(other: LineMap): boolean {
|
||||
return this.length === other.length &&
|
||||
ArrayUtilities.sequenceEquals(this.lineStarts(), other.lineStarts(), (v1, v2) => v1 === v2);
|
||||
}
|
||||
|
||||
public lineStarts(): number[] {
|
||||
if (!this._lineStarts) {
|
||||
this._lineStarts = this._computeLineStarts();
|
||||
}
|
||||
|
||||
return this._lineStarts;
|
||||
}
|
||||
|
||||
public lineCount(): number {
|
||||
return this.lineStarts().length;
|
||||
}
|
||||
|
||||
public getPosition(line: number, character: number): number {
|
||||
return this.lineStarts()[line] + character;
|
||||
}
|
||||
|
||||
public getLineNumberFromPosition(position: number): number {
|
||||
if (position < 0 || position > this.length) {
|
||||
throw Errors.argumentOutOfRange("position");
|
||||
}
|
||||
|
||||
if (position === this.length) {
|
||||
// this can happen when the user tried to get the line of items
|
||||
// that are at the absolute end of this text (i.e. the EndOfLine
|
||||
// token, or missing tokens that are at the end of the text).
|
||||
// In this case, we want the last line in the text.
|
||||
return this.lineCount() - 1;
|
||||
}
|
||||
|
||||
// Binary search to find the right line
|
||||
var lineNumber = ArrayUtilities.binarySearch(this.lineStarts(), position);
|
||||
if (lineNumber < 0) {
|
||||
lineNumber = (~lineNumber) - 1;
|
||||
}
|
||||
|
||||
return lineNumber;
|
||||
}
|
||||
|
||||
public getLineStartPosition(lineNumber: number): number {
|
||||
return this.lineStarts()[lineNumber];
|
||||
}
|
||||
|
||||
public fillLineAndCharacterFromPosition(position: number, lineAndCharacter: ILineAndCharacter): void {
|
||||
if (position < 0 || position > this.length) {
|
||||
throw Errors.argumentOutOfRange("position");
|
||||
}
|
||||
|
||||
var lineNumber = this.getLineNumberFromPosition(position);
|
||||
lineAndCharacter.line = lineNumber;
|
||||
lineAndCharacter.character = position - this.lineStarts()[lineNumber];
|
||||
}
|
||||
|
||||
public getLineAndCharacterFromPosition(position: number): LineAndCharacter {
|
||||
if (position < 0 || position > this.length) {
|
||||
throw Errors.argumentOutOfRange("position");
|
||||
}
|
||||
|
||||
var lineNumber = this.getLineNumberFromPosition(position);
|
||||
|
||||
return new LineAndCharacter(lineNumber, position - this.lineStarts()[lineNumber]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
///<reference path='references.ts' />
|
||||
|
||||
module TypeScript {
|
||||
export class LineAndCharacter {
|
||||
private _line: number = 0;
|
||||
private _character: number = 0;
|
||||
|
||||
/**
|
||||
* Initializes a new instance of a LinePosition with the given line and character. ArgumentOutOfRangeException if "line" or "character" is less than zero.
|
||||
* @param line The line of the line position. The first line in a file is defined as line 0 (zero based line numbering).
|
||||
* @param character The character position in the line.
|
||||
*/
|
||||
|
||||
constructor(line: number, character: number) {
|
||||
if (line < 0) {
|
||||
throw Errors.argumentOutOfRange("line");
|
||||
}
|
||||
|
||||
if (character < 0) {
|
||||
throw Errors.argumentOutOfRange("character");
|
||||
}
|
||||
|
||||
this._line = line;
|
||||
this._character = character;
|
||||
}
|
||||
|
||||
public line(): number {
|
||||
return this._line;
|
||||
}
|
||||
|
||||
public character(): number {
|
||||
return this._character;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
///<reference path='references.ts' />
|
||||
|
||||
module TypeScript {
|
||||
export class MathPrototype {
|
||||
public static max(a: number, b: number): number {
|
||||
return a >= b ? a : b;
|
||||
}
|
||||
|
||||
public static min(a: number, b: number): number {
|
||||
return a <= b ? a : b;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
///<reference path='..\resources\references.ts' />
|
||||
|
||||
///<reference path='arrayUtilities.ts' />
|
||||
///<reference path='debug.ts' />
|
||||
///<reference path='diagnosticCategory.ts' />
|
||||
///<reference path='diagnosticCore.ts' />
|
||||
///<reference path='diagnosticInfo.ts' />
|
||||
///<reference path='errors.ts' />
|
||||
///<reference path='integerUtilities.ts' />
|
||||
///<reference path='lineMap.ts' />
|
||||
///<reference path='linePosition.ts' />
|
||||
///<reference path='stringUtilities.ts' />
|
||||
@@ -1,159 +0,0 @@
|
||||
///<reference path='references.ts' />
|
||||
|
||||
module TypeScript.Collections {
|
||||
export var DefaultStringTableCapacity = 256;
|
||||
|
||||
class StringTableEntry {
|
||||
constructor(public Text: string,
|
||||
public HashCode: number,
|
||||
public Next: StringTableEntry) {
|
||||
}
|
||||
}
|
||||
|
||||
// A table of interned strings. Faster and better than an arbitrary hashtable for the needs of the
|
||||
// scanner. Specifically, the scanner operates over a sliding window of characters, with a start
|
||||
// and end pointer for the current lexeme. The scanner then wants to get the *interned* string
|
||||
// represented by that subsection.
|
||||
//
|
||||
// Importantly, if the string is already interned, then it wants ask "is the string represented by
|
||||
// this section of a char array contained within the table" in a non-allocating fashion. i.e. if
|
||||
// you have "[' ', 'p', 'u', 'b', 'l', 'i', 'c', ' ']" and you ask to get the string represented by
|
||||
// range [1, 7), then this table will return "public" without any allocations if that value was
|
||||
// already in the table.
|
||||
//
|
||||
// Of course, if the value is not in the table then there will be an initial cost to allocate the
|
||||
// string and the bucket for the table. However, that is only incurred the first time each unique
|
||||
// string is added.
|
||||
export class StringTable {
|
||||
// TODO: uncomment this once typecheck bug is fixed.
|
||||
private entries: StringTableEntry[];
|
||||
private count: number = 0;
|
||||
|
||||
constructor(capacity: number) {
|
||||
var size = Hash.getPrime(capacity);
|
||||
this.entries = ArrayUtilities.createArray<StringTableEntry>(size, null);
|
||||
}
|
||||
|
||||
public addCharArray(key: number[], start: number, len: number): string {
|
||||
// Compute the hash for this key. Also ensure that it fits within 31 bits (so that it
|
||||
// stays a non-heap integer, and so we can index into the array safely).
|
||||
var hashCode = Hash.computeSimple31BitCharArrayHashCode(key, start, len) & 0x7FFFFFFF;
|
||||
// Debug.assert(hashCode > 0);
|
||||
|
||||
// First see if we already have the string represented by "key[start, start + len)" already
|
||||
// present in this table. If we do, just return that string. Do this without any
|
||||
// allocations
|
||||
var entry = this.findCharArrayEntry(key, start, len, hashCode);
|
||||
if (entry !== null) {
|
||||
return entry.Text;
|
||||
}
|
||||
|
||||
// We don't have an entry for that string in our table. Convert that
|
||||
var slice: number[] = key.slice(start, start + len);
|
||||
return this.addEntry(StringUtilities.fromCharCodeArray(slice), hashCode);
|
||||
}
|
||||
|
||||
private findCharArrayEntry(key: number[], start: number, len: number, hashCode: number) {
|
||||
for (var e = this.entries[hashCode % this.entries.length]; e !== null; e = e.Next) {
|
||||
if (e.HashCode === hashCode && StringTable.textCharArrayEquals(e.Text, key, start, len)) {
|
||||
return e;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private addEntry(text: string, hashCode: number): string {
|
||||
var index = hashCode % this.entries.length;
|
||||
|
||||
var e = new StringTableEntry(text, hashCode, this.entries[index]);
|
||||
|
||||
this.entries[index] = e;
|
||||
|
||||
// We grow when our load factor equals 1. I tried different load factors (like .75 and
|
||||
// .5), however they seemed to have no effect on running time. With a load factor of 1
|
||||
// we seem to get about 80% slot fill rate with an average of around 1.25 table entries
|
||||
// per slot.
|
||||
if (this.count === this.entries.length) {
|
||||
this.grow();
|
||||
}
|
||||
|
||||
this.count++;
|
||||
return e.Text;
|
||||
}
|
||||
|
||||
//private dumpStats() {
|
||||
// var standardOut = Environment.standardOut;
|
||||
|
||||
// standardOut.WriteLine("----------------------")
|
||||
// standardOut.WriteLine("String table stats");
|
||||
// standardOut.WriteLine("Count : " + this.count);
|
||||
// standardOut.WriteLine("Entries Length : " + this.entries.length);
|
||||
|
||||
// var longestSlot = 0;
|
||||
// var occupiedSlots = 0;
|
||||
// for (var i = 0; i < this.entries.length; i++) {
|
||||
// if (this.entries[i] !== null) {
|
||||
// occupiedSlots++;
|
||||
|
||||
// var current = this.entries[i];
|
||||
// var slotCount = 0;
|
||||
// while (current !== null) {
|
||||
// slotCount++;
|
||||
// current = current.Next;
|
||||
// }
|
||||
|
||||
// longestSlot = MathPrototype.max(longestSlot, slotCount);
|
||||
// }
|
||||
// }
|
||||
|
||||
// standardOut.WriteLine("Occupied slots : " + occupiedSlots);
|
||||
// standardOut.WriteLine("Longest slot : " + longestSlot);
|
||||
// standardOut.WriteLine("Avg Length/Slot : " + (this.count / occupiedSlots));
|
||||
// standardOut.WriteLine("----------------------");
|
||||
//}
|
||||
|
||||
private grow(): void {
|
||||
// this.dumpStats();
|
||||
|
||||
var newSize = Hash.expandPrime(this.entries.length);
|
||||
|
||||
var oldEntries = this.entries;
|
||||
var newEntries: StringTableEntry[] = ArrayUtilities.createArray<StringTableEntry>(newSize, null);
|
||||
|
||||
this.entries = newEntries;
|
||||
|
||||
for (var i = 0; i < oldEntries.length; i++) {
|
||||
var e = oldEntries[i];
|
||||
while (e !== null) {
|
||||
var newIndex = e.HashCode % newSize;
|
||||
var tmp = e.Next;
|
||||
e.Next = newEntries[newIndex];
|
||||
newEntries[newIndex] = e;
|
||||
e = tmp;
|
||||
}
|
||||
}
|
||||
|
||||
// this.dumpStats();
|
||||
}
|
||||
|
||||
private static textCharArrayEquals(text: string, array: number[], start: number, length: number): boolean {
|
||||
if (text.length !== length) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var s = start;
|
||||
for (var i = 0; i < length; i++) {
|
||||
if (text.charCodeAt(i) !== array[s]) {
|
||||
return false;
|
||||
}
|
||||
|
||||
s++;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
export var DefaultStringTable = new StringTable(DefaultStringTableCapacity);
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
///<reference path='references.ts' />
|
||||
|
||||
module TypeScript {
|
||||
export class StringUtilities {
|
||||
public static isString(value: any): boolean {
|
||||
return Object.prototype.toString.apply(value, []) === '[object String]';
|
||||
}
|
||||
|
||||
public static endsWith(string: string, value: string): boolean {
|
||||
return string.substring(string.length - value.length, string.length) === value;
|
||||
}
|
||||
|
||||
public static startsWith(string: string, value: string): boolean {
|
||||
return string.substr(0, value.length) === value;
|
||||
}
|
||||
|
||||
public static repeat(value: string, count: number) {
|
||||
return Array(count + 1).join(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -67,8 +67,8 @@ module ts.formatting {
|
||||
}
|
||||
|
||||
export function formatOnEnter(position: number, sourceFile: SourceFile, rulesProvider: RulesProvider, options: FormatCodeOptions): TextChange[] {
|
||||
var line = sourceFile.getLineAndCharacterFromPosition(position).line;
|
||||
if (line === 1) {
|
||||
var line = sourceFile.getLineAndCharacterOfPosition(position).line;
|
||||
if (line === 0) {
|
||||
return [];
|
||||
}
|
||||
// get the span for the previous\current line
|
||||
@@ -100,7 +100,7 @@ module ts.formatting {
|
||||
export function formatSelection(start: number, end: number, sourceFile: SourceFile, rulesProvider: RulesProvider, options: FormatCodeOptions): TextChange[] {
|
||||
// format from the beginning of the line
|
||||
var span = {
|
||||
pos: getStartLinePositionForPosition(start, sourceFile),
|
||||
pos: getLineStartPositionForPosition(start, sourceFile),
|
||||
end: end
|
||||
};
|
||||
return formatSpan(span, sourceFile, options, rulesProvider, FormattingRequestKind.FormatSelection);
|
||||
@@ -112,7 +112,7 @@ module ts.formatting {
|
||||
return [];
|
||||
}
|
||||
var span = {
|
||||
pos: getStartLinePositionForPosition(parent.getStart(sourceFile), sourceFile),
|
||||
pos: getLineStartPositionForPosition(parent.getStart(sourceFile), sourceFile),
|
||||
end: parent.end
|
||||
};
|
||||
return formatSpan(span, sourceFile, options, rulesProvider, requestKind);
|
||||
@@ -283,7 +283,7 @@ module ts.formatting {
|
||||
var previousLine = Constants.Unknown;
|
||||
var childKind = SyntaxKind.Unknown;
|
||||
while (n) {
|
||||
var line = sourceFile.getLineAndCharacterFromPosition(n.getStart(sourceFile)).line;
|
||||
var line = sourceFile.getLineAndCharacterOfPosition(n.getStart(sourceFile)).line;
|
||||
if (previousLine !== Constants.Unknown && line !== previousLine) {
|
||||
break;
|
||||
}
|
||||
@@ -327,7 +327,7 @@ module ts.formatting {
|
||||
formattingScanner.advance();
|
||||
|
||||
if (formattingScanner.isOnToken()) {
|
||||
var startLine = sourceFile.getLineAndCharacterFromPosition(enclosingNode.getStart(sourceFile)).line;
|
||||
var startLine = sourceFile.getLineAndCharacterOfPosition(enclosingNode.getStart(sourceFile)).line;
|
||||
var delta = getOwnOrInheritedDelta(enclosingNode, options, sourceFile);
|
||||
processNode(enclosingNode, enclosingNode, startLine, initialIndentation, delta);
|
||||
}
|
||||
@@ -357,8 +357,8 @@ module ts.formatting {
|
||||
}
|
||||
}
|
||||
else {
|
||||
var startLine = sourceFile.getLineAndCharacterFromPosition(startPos).line;
|
||||
var startLinePosition = getStartLinePositionForPosition(startPos, sourceFile);
|
||||
var startLine = sourceFile.getLineAndCharacterOfPosition(startPos).line;
|
||||
var startLinePosition = getLineStartPositionForPosition(startPos, sourceFile);
|
||||
var column = SmartIndenter.findFirstNonWhitespaceColumn(startLinePosition, startPos, sourceFile, options);
|
||||
if (startLine !== parentStartLine || startPos === column) {
|
||||
return column
|
||||
@@ -521,7 +521,7 @@ module ts.formatting {
|
||||
|
||||
var childStartPos = child.getStart(sourceFile);
|
||||
|
||||
var childStart = sourceFile.getLineAndCharacterFromPosition(childStartPos);
|
||||
var childStart = sourceFile.getLineAndCharacterOfPosition(childStartPos);
|
||||
|
||||
// if child is a list item - try to get its indentation
|
||||
var childIndentationAmount = Constants.Unknown;
|
||||
@@ -594,7 +594,7 @@ module ts.formatting {
|
||||
}
|
||||
else if (tokenInfo.token.kind === listStartToken) {
|
||||
// consume list start token
|
||||
startLine = sourceFile.getLineAndCharacterFromPosition(tokenInfo.token.pos).line;
|
||||
startLine = sourceFile.getLineAndCharacterOfPosition(tokenInfo.token.pos).line;
|
||||
var indentation =
|
||||
computeIndentation(tokenInfo.token, startLine, Constants.Unknown, parent, parentDynamicIndentation, startLine);
|
||||
|
||||
@@ -641,7 +641,7 @@ module ts.formatting {
|
||||
var lineAdded: boolean;
|
||||
var isTokenInRange = rangeContainsRange(originalRange, currentTokenInfo.token);
|
||||
|
||||
var tokenStart = sourceFile.getLineAndCharacterFromPosition(currentTokenInfo.token.pos);
|
||||
var tokenStart = sourceFile.getLineAndCharacterOfPosition(currentTokenInfo.token.pos);
|
||||
if (isTokenInRange) {
|
||||
var rangeHasError = rangeContainsError(currentTokenInfo.token);
|
||||
// save prevStartLine since processRange will overwrite this value with current ones
|
||||
@@ -674,7 +674,7 @@ module ts.formatting {
|
||||
continue;
|
||||
}
|
||||
|
||||
var triviaStartLine = sourceFile.getLineAndCharacterFromPosition(triviaItem.pos).line;
|
||||
var triviaStartLine = sourceFile.getLineAndCharacterOfPosition(triviaItem.pos).line;
|
||||
switch (triviaItem.kind) {
|
||||
case SyntaxKind.MultiLineCommentTrivia:
|
||||
var commentIndentation = dynamicIndentation.getIndentationForComment(currentTokenInfo.token.kind);
|
||||
@@ -712,7 +712,7 @@ module ts.formatting {
|
||||
for (var i = 0, len = trivia.length; i < len; ++i) {
|
||||
var triviaItem = trivia[i];
|
||||
if (isComment(triviaItem.kind) && rangeContainsRange(originalRange, triviaItem)) {
|
||||
var triviaItemStart = sourceFile.getLineAndCharacterFromPosition(triviaItem.pos);
|
||||
var triviaItemStart = sourceFile.getLineAndCharacterOfPosition(triviaItem.pos);
|
||||
processRange(triviaItem, triviaItemStart, parent, contextNode, dynamicIndentation);
|
||||
}
|
||||
}
|
||||
@@ -729,7 +729,7 @@ module ts.formatting {
|
||||
if (!rangeHasError && !previousRangeHasError) {
|
||||
if (!previousRange) {
|
||||
// trim whitespaces starting from the beginning of the span up to the current line
|
||||
var originalStart = sourceFile.getLineAndCharacterFromPosition(originalRange.pos);
|
||||
var originalStart = sourceFile.getLineAndCharacterOfPosition(originalRange.pos);
|
||||
trimTrailingWhitespacesForLines(originalStart.line, rangeStart.line);
|
||||
}
|
||||
else {
|
||||
@@ -807,18 +807,18 @@ module ts.formatting {
|
||||
recordReplace(pos, 0, indentationString);
|
||||
}
|
||||
else {
|
||||
var tokenStart = sourceFile.getLineAndCharacterFromPosition(pos);
|
||||
if (indentation !== tokenStart.character - 1) {
|
||||
var tokenStart = sourceFile.getLineAndCharacterOfPosition(pos);
|
||||
if (indentation !== tokenStart.character) {
|
||||
var startLinePosition = getStartPositionOfLine(tokenStart.line, sourceFile);
|
||||
recordReplace(startLinePosition, tokenStart.character - 1, indentationString);
|
||||
recordReplace(startLinePosition, tokenStart.character, indentationString);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function indentMultilineComment(commentRange: TextRange, indentation: number, firstLineIsIndented: boolean) {
|
||||
// split comment in lines
|
||||
var startLine = sourceFile.getLineAndCharacterFromPosition(commentRange.pos).line;
|
||||
var endLine = sourceFile.getLineAndCharacterFromPosition(commentRange.end).line;
|
||||
var startLine = sourceFile.getLineAndCharacterOfPosition(commentRange.pos).line;
|
||||
var endLine = sourceFile.getLineAndCharacterOfPosition(commentRange.end).line;
|
||||
|
||||
if (startLine === endLine) {
|
||||
if (!firstLineIsIndented) {
|
||||
@@ -842,9 +842,9 @@ module ts.formatting {
|
||||
var startLinePos = getStartPositionOfLine(startLine, sourceFile);
|
||||
|
||||
var nonWhitespaceColumnInFirstPart =
|
||||
SmartIndenter.findFirstNonWhitespaceColumn(startLinePos, parts[0].pos, sourceFile, options);
|
||||
SmartIndenter.findFirstNonWhitespaceCharacterAndColumn(startLinePos, parts[0].pos, sourceFile, options);
|
||||
|
||||
if (indentation === nonWhitespaceColumnInFirstPart) {
|
||||
if (indentation === nonWhitespaceColumnInFirstPart.column) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -855,21 +855,21 @@ module ts.formatting {
|
||||
}
|
||||
|
||||
// shift all parts on the delta size
|
||||
var delta = indentation - nonWhitespaceColumnInFirstPart;
|
||||
var delta = indentation - nonWhitespaceColumnInFirstPart.column;
|
||||
for (var i = startIndex, len = parts.length; i < len; ++i, ++startLine) {
|
||||
var startLinePos = getStartPositionOfLine(startLine, sourceFile);
|
||||
var nonWhitespaceColumn =
|
||||
var nonWhitespaceCharacterAndColumn =
|
||||
i === 0
|
||||
? nonWhitespaceColumnInFirstPart
|
||||
: SmartIndenter.findFirstNonWhitespaceColumn(parts[i].pos, parts[i].end, sourceFile, options);
|
||||
: SmartIndenter.findFirstNonWhitespaceCharacterAndColumn(parts[i].pos, parts[i].end, sourceFile, options);
|
||||
|
||||
var newIndentation = nonWhitespaceColumn + delta;
|
||||
var newIndentation = nonWhitespaceCharacterAndColumn.column + delta;
|
||||
if (newIndentation > 0) {
|
||||
var indentationString = getIndentationString(newIndentation, options);
|
||||
recordReplace(startLinePos, nonWhitespaceColumn, indentationString);
|
||||
recordReplace(startLinePos, nonWhitespaceCharacterAndColumn.character, indentationString);
|
||||
}
|
||||
else {
|
||||
recordDelete(startLinePos, nonWhitespaceColumn);
|
||||
recordDelete(startLinePos, nonWhitespaceCharacterAndColumn.character);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ module ts.formatting {
|
||||
private contextNodeBlockIsOnOneLine: boolean;
|
||||
private nextNodeBlockIsOnOneLine: boolean;
|
||||
|
||||
constructor(private sourceFile: SourceFile, public formattingRequestKind: FormattingRequestKind) {
|
||||
constructor(public sourceFile: SourceFile, public formattingRequestKind: FormattingRequestKind) {
|
||||
}
|
||||
|
||||
public updateContext(currentRange: TextRangeWithKind, currentTokenParent: Node, nextRange: TextRangeWithKind, nextTokenParent: Node, commonParent: Node) {
|
||||
@@ -71,8 +71,8 @@ module ts.formatting {
|
||||
|
||||
public TokensAreOnSameLine(): boolean {
|
||||
if (this.tokensAreOnSameLine === undefined) {
|
||||
var startLine = this.sourceFile.getLineAndCharacterFromPosition(this.currentTokenSpan.pos).line;
|
||||
var endLine = this.sourceFile.getLineAndCharacterFromPosition(this.nextTokenSpan.pos).line;
|
||||
var startLine = this.sourceFile.getLineAndCharacterOfPosition(this.currentTokenSpan.pos).line;
|
||||
var endLine = this.sourceFile.getLineAndCharacterOfPosition(this.nextTokenSpan.pos).line;
|
||||
this.tokensAreOnSameLine = (startLine == endLine);
|
||||
}
|
||||
|
||||
@@ -96,8 +96,8 @@ module ts.formatting {
|
||||
}
|
||||
|
||||
private NodeIsOnOneLine(node: Node): boolean {
|
||||
var startLine = this.sourceFile.getLineAndCharacterFromPosition(node.getStart(this.sourceFile)).line;
|
||||
var endLine = this.sourceFile.getLineAndCharacterFromPosition(node.getEnd()).line;
|
||||
var startLine = this.sourceFile.getLineAndCharacterOfPosition(node.getStart(this.sourceFile)).line;
|
||||
var endLine = this.sourceFile.getLineAndCharacterOfPosition(node.getEnd()).line;
|
||||
return startLine == endLine;
|
||||
}
|
||||
|
||||
@@ -105,8 +105,8 @@ module ts.formatting {
|
||||
var openBrace = findChildOfKind(node, SyntaxKind.OpenBraceToken, this.sourceFile);
|
||||
var closeBrace = findChildOfKind(node, SyntaxKind.CloseBraceToken, this.sourceFile);
|
||||
if (openBrace && closeBrace) {
|
||||
var startLine = this.sourceFile.getLineAndCharacterFromPosition(openBrace.getEnd()).line;
|
||||
var endLine = this.sourceFile.getLineAndCharacterFromPosition(closeBrace.getStart(this.sourceFile)).line;
|
||||
var startLine = this.sourceFile.getLineAndCharacterOfPosition(openBrace.getEnd()).line;
|
||||
var endLine = this.sourceFile.getLineAndCharacterOfPosition(closeBrace.getStart(this.sourceFile)).line;
|
||||
return startLine === endLine;
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -93,17 +93,16 @@ module ts.formatting {
|
||||
savedPos = scanner.getStartPos();
|
||||
}
|
||||
|
||||
function shouldRescanGreaterThanToken(container: Node): boolean {
|
||||
if (container.kind !== SyntaxKind.BinaryExpression) {
|
||||
return false;
|
||||
}
|
||||
switch ((<BinaryExpression>container).operator) {
|
||||
case SyntaxKind.GreaterThanEqualsToken:
|
||||
case SyntaxKind.GreaterThanGreaterThanEqualsToken:
|
||||
case SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken:
|
||||
case SyntaxKind.GreaterThanGreaterThanGreaterThanToken:
|
||||
case SyntaxKind.GreaterThanGreaterThanToken:
|
||||
return true;
|
||||
function shouldRescanGreaterThanToken(node: Node): boolean {
|
||||
if (node) {
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.GreaterThanEqualsToken:
|
||||
case SyntaxKind.GreaterThanGreaterThanEqualsToken:
|
||||
case SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken:
|
||||
case SyntaxKind.GreaterThanGreaterThanGreaterThanToken:
|
||||
case SyntaxKind.GreaterThanGreaterThanToken:
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -164,7 +163,7 @@ module ts.formatting {
|
||||
|
||||
if (expectedScanAction === ScanAction.RescanGreaterThanToken && currentToken === SyntaxKind.GreaterThanToken) {
|
||||
currentToken = scanner.reScanGreaterToken();
|
||||
Debug.assert((<BinaryExpression>n).operator === currentToken);
|
||||
Debug.assert(n.kind === currentToken);
|
||||
lastScanAction = ScanAction.RescanGreaterThanToken;
|
||||
}
|
||||
else if (expectedScanAction === ScanAction.RescanSlashToken && startsWithSlashToken(currentToken)) {
|
||||
|
||||
@@ -35,9 +35,13 @@ module ts.formatting {
|
||||
// Space after keyword but not before ; or : or ?
|
||||
public NoSpaceBeforeSemicolon: Rule;
|
||||
public NoSpaceBeforeColon: Rule;
|
||||
public NoSpaceBeforeQMark: Rule;
|
||||
public NoSpaceBeforeQuestionMark: Rule;
|
||||
public SpaceAfterColon: Rule;
|
||||
public SpaceAfterQMark: Rule;
|
||||
// insert space after '?' only when it is used in conditional operator
|
||||
public SpaceAfterQuestionMarkInConditionalOperator: Rule;
|
||||
// in other cases there should be no space between '?' and next token
|
||||
public NoSpaceAfterQuestionMark: Rule;
|
||||
|
||||
public SpaceAfterSemicolon: Rule;
|
||||
|
||||
// Space/new line after }.
|
||||
@@ -92,6 +96,7 @@ module ts.formatting {
|
||||
public NoSpaceBeforeComma: Rule;
|
||||
|
||||
public SpaceAfterCertainKeywords: Rule;
|
||||
public SpaceAfterLetConstInVariableDeclaration: Rule;
|
||||
public NoSpaceBeforeOpenParenInFuncCall: Rule;
|
||||
public SpaceAfterFunctionInFuncDecl: Rule;
|
||||
public NoSpaceBeforeOpenParenInFuncDecl: Rule;
|
||||
@@ -215,9 +220,10 @@ module ts.formatting {
|
||||
// Space after keyword but not before ; or : or ?
|
||||
this.NoSpaceBeforeSemicolon = new Rule(RuleDescriptor.create2(Shared.TokenRange.Any, SyntaxKind.SemicolonToken), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Delete));
|
||||
this.NoSpaceBeforeColon = new Rule(RuleDescriptor.create2(Shared.TokenRange.Any, SyntaxKind.ColonToken), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), RuleAction.Delete));
|
||||
this.NoSpaceBeforeQMark = new Rule(RuleDescriptor.create2(Shared.TokenRange.Any, SyntaxKind.QuestionToken), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), RuleAction.Delete));
|
||||
this.NoSpaceBeforeQuestionMark = new Rule(RuleDescriptor.create2(Shared.TokenRange.Any, SyntaxKind.QuestionToken), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), RuleAction.Delete));
|
||||
this.SpaceAfterColon = new Rule(RuleDescriptor.create3(SyntaxKind.ColonToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), RuleAction.Space));
|
||||
this.SpaceAfterQMark = new Rule(RuleDescriptor.create3(SyntaxKind.QuestionToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), RuleAction.Space));
|
||||
this.SpaceAfterQuestionMarkInConditionalOperator = new Rule(RuleDescriptor.create3(SyntaxKind.QuestionToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsConditionalOperatorContext), RuleAction.Space));
|
||||
this.NoSpaceAfterQuestionMark = new Rule(RuleDescriptor.create3(SyntaxKind.QuestionToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Delete));
|
||||
this.SpaceAfterSemicolon = new Rule(RuleDescriptor.create3(SyntaxKind.SemicolonToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Space));
|
||||
|
||||
// Space after }.
|
||||
@@ -238,7 +244,7 @@ module ts.formatting {
|
||||
|
||||
// Place a space before open brace in a function declaration
|
||||
this.FunctionOpenBraceLeftTokenRange = Shared.TokenRange.AnyIncludingMultilineComments;
|
||||
this.SpaceBeforeOpenBraceInFunction = new Rule(RuleDescriptor.create2(this.FunctionOpenBraceLeftTokenRange, SyntaxKind.OpenBraceToken), RuleOperation.create2(new RuleOperationContext(Rules.IsFunctionDeclContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), RuleAction.Space), RuleFlags.CanDeleteNewLines);
|
||||
this.SpaceBeforeOpenBraceInFunction = new Rule(RuleDescriptor.create2(this.FunctionOpenBraceLeftTokenRange, SyntaxKind.OpenBraceToken), RuleOperation.create2(new RuleOperationContext(Rules.IsFunctionDeclContext, Rules.IsBeforeBlockContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), RuleAction.Space), RuleFlags.CanDeleteNewLines);
|
||||
|
||||
// Place a space before open brace in a TypeScript declaration that has braces as children (class, module, enum, etc)
|
||||
this.TypeScriptOpenBraceLeftTokenRange = Shared.TokenRange.FromTokens([SyntaxKind.Identifier, SyntaxKind.MultiLineCommentTrivia]);
|
||||
@@ -283,6 +289,7 @@ module ts.formatting {
|
||||
this.NoSpaceBeforeComma = new Rule(RuleDescriptor.create2(Shared.TokenRange.Any, SyntaxKind.CommaToken), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Delete));
|
||||
|
||||
this.SpaceAfterCertainKeywords = new Rule(RuleDescriptor.create4(Shared.TokenRange.FromTokens([SyntaxKind.VarKeyword, SyntaxKind.ThrowKeyword, SyntaxKind.NewKeyword, SyntaxKind.DeleteKeyword, SyntaxKind.ReturnKeyword, SyntaxKind.TypeOfKeyword]), Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Space));
|
||||
this.SpaceAfterLetConstInVariableDeclaration = new Rule(RuleDescriptor.create4(Shared.TokenRange.FromTokens([SyntaxKind.LetKeyword, SyntaxKind.ConstKeyword]), Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsStartOfVariableDeclarationList), RuleAction.Space));
|
||||
this.NoSpaceBeforeOpenParenInFuncCall = new Rule(RuleDescriptor.create2(Shared.TokenRange.Any, SyntaxKind.OpenParenToken), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsFunctionCallOrNewContext, Rules.IsPreviousTokenNotComma), RuleAction.Delete));
|
||||
this.SpaceAfterFunctionInFuncDecl = new Rule(RuleDescriptor.create3(SyntaxKind.FunctionKeyword, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsFunctionDeclContext), RuleAction.Space));
|
||||
this.NoSpaceBeforeOpenParenInFuncDecl = new Rule(RuleDescriptor.create2(Shared.TokenRange.Any, SyntaxKind.OpenParenToken), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsFunctionDeclContext), RuleAction.Delete));
|
||||
@@ -341,7 +348,8 @@ module ts.formatting {
|
||||
this.HighPriorityCommonRules =
|
||||
[
|
||||
this.IgnoreBeforeComment, this.IgnoreAfterLineComment,
|
||||
this.NoSpaceBeforeColon, this.SpaceAfterColon, this.NoSpaceBeforeQMark, this.SpaceAfterQMark,
|
||||
this.NoSpaceBeforeColon, this.SpaceAfterColon, this.NoSpaceBeforeQuestionMark, this.SpaceAfterQuestionMarkInConditionalOperator,
|
||||
this.NoSpaceAfterQuestionMark,
|
||||
this.NoSpaceBeforeDot, this.NoSpaceAfterDot,
|
||||
this.NoSpaceAfterUnaryPrefixOperator,
|
||||
this.NoSpaceAfterUnaryPreincrementOperator, this.NoSpaceAfterUnaryPredecrementOperator,
|
||||
@@ -356,6 +364,7 @@ module ts.formatting {
|
||||
this.SpaceAfterFunctionInFuncDecl, this.NewLineAfterOpenBraceInBlockContext, this.SpaceAfterGetSetInMember,
|
||||
this.NoSpaceBetweenReturnAndSemicolon,
|
||||
this.SpaceAfterCertainKeywords,
|
||||
this.SpaceAfterLetConstInVariableDeclaration,
|
||||
this.NoSpaceBeforeOpenParenInFuncCall,
|
||||
this.SpaceBeforeBinaryKeywordOperator, this.SpaceAfterBinaryKeywordOperator,
|
||||
this.SpaceAfterVoidOperator,
|
||||
@@ -452,7 +461,7 @@ module ts.formatting {
|
||||
return true;
|
||||
|
||||
// equal in import a = module('a');
|
||||
case SyntaxKind.ImportDeclaration:
|
||||
case SyntaxKind.ImportEqualsDeclaration:
|
||||
// equal in var a = 0;
|
||||
case SyntaxKind.VariableDeclaration:
|
||||
// equal in p = 0;
|
||||
@@ -464,6 +473,11 @@ module ts.formatting {
|
||||
// "in" keyword in for (var x in []) { }
|
||||
case SyntaxKind.ForInStatement:
|
||||
return context.currentTokenSpan.kind === SyntaxKind.InKeyword || context.nextTokenSpan.kind === SyntaxKind.InKeyword;
|
||||
// Technically, "of" is not a binary operator, but format it the same way as "in"
|
||||
case SyntaxKind.ForOfStatement:
|
||||
return context.currentTokenSpan.kind === SyntaxKind.OfKeyword || context.nextTokenSpan.kind === SyntaxKind.OfKeyword;
|
||||
case SyntaxKind.BindingElement:
|
||||
return context.currentTokenSpan.kind === SyntaxKind.EqualsToken || context.nextTokenSpan.kind === SyntaxKind.EqualsToken;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -472,6 +486,10 @@ module ts.formatting {
|
||||
return !Rules.IsBinaryOpContext(context);
|
||||
}
|
||||
|
||||
static IsConditionalOperatorContext(context: FormattingContext): boolean {
|
||||
return context.contextNode.kind === SyntaxKind.ConditionalExpression;
|
||||
}
|
||||
|
||||
static IsSameLineTokenOrBeforeMultilineBlockContext(context: FormattingContext): boolean {
|
||||
//// This check is mainly used inside SpaceBeforeOpenBraceInControl and SpaceBeforeOpenBraceInFunction.
|
||||
////
|
||||
@@ -592,6 +610,7 @@ module ts.formatting {
|
||||
case SyntaxKind.SwitchStatement:
|
||||
case SyntaxKind.ForStatement:
|
||||
case SyntaxKind.ForInStatement:
|
||||
case SyntaxKind.ForOfStatement:
|
||||
case SyntaxKind.WhileStatement:
|
||||
case SyntaxKind.TryStatement:
|
||||
case SyntaxKind.DoStatement:
|
||||
@@ -630,6 +649,11 @@ module ts.formatting {
|
||||
return context.TokensAreOnSameLine();
|
||||
}
|
||||
|
||||
static IsStartOfVariableDeclarationList(context: FormattingContext): boolean {
|
||||
return context.currentTokenParent.kind === SyntaxKind.VariableDeclarationList &&
|
||||
context.currentTokenParent.getStart(context.sourceFile) === context.currentTokenSpan.pos;
|
||||
}
|
||||
|
||||
static IsNotFormatOnEnter(context: FormattingContext): boolean {
|
||||
return context.formattingRequestKind != FormattingRequestKind.FormatOnEnter;
|
||||
}
|
||||
|
||||
@@ -2,6 +2,11 @@
|
||||
|
||||
module ts.formatting {
|
||||
export module SmartIndenter {
|
||||
|
||||
const enum Value {
|
||||
Unknown = -1
|
||||
}
|
||||
|
||||
export function getIndentation(position: number, sourceFile: SourceFile, options: EditorOptions): number {
|
||||
if (position > sourceFile.text.length) {
|
||||
return 0; // past EOF
|
||||
@@ -24,12 +29,12 @@ module ts.formatting {
|
||||
return 0;
|
||||
}
|
||||
|
||||
var lineAtPosition = sourceFile.getLineAndCharacterFromPosition(position).line;
|
||||
var lineAtPosition = sourceFile.getLineAndCharacterOfPosition(position).line;
|
||||
|
||||
if (precedingToken.kind === SyntaxKind.CommaToken && precedingToken.parent.kind !== SyntaxKind.BinaryExpression) {
|
||||
// previous token is comma that separates items in list - find the previous item and try to derive indentation from it
|
||||
var actualIndentation = getActualIndentationForListItemBeforeComma(precedingToken, sourceFile, options);
|
||||
if (actualIndentation !== -1) {
|
||||
if (actualIndentation !== Value.Unknown) {
|
||||
return actualIndentation;
|
||||
}
|
||||
}
|
||||
@@ -57,7 +62,7 @@ module ts.formatting {
|
||||
|
||||
// check if current node is a list item - if yes, take indentation from it
|
||||
var actualIndentation = getActualIndentationForListItem(current, sourceFile, options);
|
||||
if (actualIndentation !== -1) {
|
||||
if (actualIndentation !== Value.Unknown) {
|
||||
return actualIndentation;
|
||||
}
|
||||
|
||||
@@ -74,7 +79,7 @@ module ts.formatting {
|
||||
}
|
||||
|
||||
export function getIndentationForNode(n: Node, ignoreActualIndentationRange: TextRange, sourceFile: SourceFile, options: FormatCodeOptions): number {
|
||||
var start = sourceFile.getLineAndCharacterFromPosition(n.getStart(sourceFile));
|
||||
var start = sourceFile.getLineAndCharacterOfPosition(n.getStart(sourceFile));
|
||||
return getIndentationForNodeWorker(n, start, ignoreActualIndentationRange, /*indentationDelta*/ 0, sourceFile, options);
|
||||
}
|
||||
|
||||
@@ -101,7 +106,7 @@ module ts.formatting {
|
||||
if (useActualIndentation) {
|
||||
// check if current node is a list item - if yes, take indentation from it
|
||||
var actualIndentation = getActualIndentationForListItem(current, sourceFile, options);
|
||||
if (actualIndentation !== -1) {
|
||||
if (actualIndentation !== Value.Unknown) {
|
||||
return actualIndentation + indentationDelta;
|
||||
}
|
||||
}
|
||||
@@ -113,7 +118,7 @@ module ts.formatting {
|
||||
if (useActualIndentation) {
|
||||
// try to fetch actual indentation for current node from source text
|
||||
var actualIndentation = getActualIndentationForNode(current, parent, currentStart, parentAndChildShareLine, sourceFile, options);
|
||||
if (actualIndentation !== -1) {
|
||||
if (actualIndentation !== Value.Unknown) {
|
||||
return actualIndentation + indentationDelta;
|
||||
}
|
||||
}
|
||||
@@ -135,25 +140,29 @@ module ts.formatting {
|
||||
function getParentStart(parent: Node, child: Node, sourceFile: SourceFile): LineAndCharacter {
|
||||
var containingList = getContainingList(child, sourceFile);
|
||||
if (containingList) {
|
||||
return sourceFile.getLineAndCharacterFromPosition(containingList.pos);
|
||||
return sourceFile.getLineAndCharacterOfPosition(containingList.pos);
|
||||
}
|
||||
|
||||
return sourceFile.getLineAndCharacterFromPosition(parent.getStart(sourceFile));
|
||||
return sourceFile.getLineAndCharacterOfPosition(parent.getStart(sourceFile));
|
||||
}
|
||||
|
||||
/*
|
||||
* Function returns -1 if indentation cannot be determined
|
||||
* Function returns Value.Unknown if indentation cannot be determined
|
||||
*/
|
||||
function getActualIndentationForListItemBeforeComma(commaToken: Node, sourceFile: SourceFile, options: EditorOptions): number {
|
||||
// previous token is comma that separates items in list - find the previous item and try to derive indentation from it
|
||||
var commaItemInfo = findListItemInfo(commaToken);
|
||||
Debug.assert(commaItemInfo && commaItemInfo.listItemIndex > 0);
|
||||
// The item we're interested in is right before the comma
|
||||
return deriveActualIndentationFromList(commaItemInfo.list.getChildren(), commaItemInfo.listItemIndex - 1, sourceFile, options);
|
||||
if (commaItemInfo && commaItemInfo.listItemIndex > 0) {
|
||||
return deriveActualIndentationFromList(commaItemInfo.list.getChildren(), commaItemInfo.listItemIndex - 1, sourceFile, options);
|
||||
}
|
||||
else {
|
||||
// handle broken code gracefully
|
||||
return Value.Unknown;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Function returns -1 if actual indentation for node should not be used (i.e because node is nested expression)
|
||||
* Function returns Value.Unknown if actual indentation for node should not be used (i.e because node is nested expression)
|
||||
*/
|
||||
function getActualIndentationForNode(current: Node,
|
||||
parent: Node,
|
||||
@@ -170,7 +179,7 @@ module ts.formatting {
|
||||
(parent.kind === SyntaxKind.SourceFile || !parentAndChildShareLine);
|
||||
|
||||
if (!useActualIndentation) {
|
||||
return -1;
|
||||
return Value.Unknown;
|
||||
}
|
||||
|
||||
return findColumnForFirstNonWhitespaceCharacterInLine(currentLineAndChar, sourceFile, options);
|
||||
@@ -204,7 +213,7 @@ module ts.formatting {
|
||||
}
|
||||
|
||||
function getStartLineAndCharacterForNode(n: Node, sourceFile: SourceFile): LineAndCharacter {
|
||||
return sourceFile.getLineAndCharacterFromPosition(n.getStart(sourceFile));
|
||||
return sourceFile.getLineAndCharacterOfPosition(n.getStart(sourceFile));
|
||||
}
|
||||
|
||||
function positionBelongsToNode(candidate: Node, position: number, sourceFile: SourceFile): boolean {
|
||||
@@ -271,15 +280,14 @@ module ts.formatting {
|
||||
|
||||
function getActualIndentationForListItem(node: Node, sourceFile: SourceFile, options: EditorOptions): number {
|
||||
var containingList = getContainingList(node, sourceFile);
|
||||
return containingList ? getActualIndentationFromList(containingList) : -1;
|
||||
return containingList ? getActualIndentationFromList(containingList) : Value.Unknown;
|
||||
|
||||
function getActualIndentationFromList(list: Node[]): number {
|
||||
var index = indexOf(list, node);
|
||||
return index !== -1 ? deriveActualIndentationFromList(list, index, sourceFile, options) : -1;
|
||||
return index !== -1 ? deriveActualIndentationFromList(list, index, sourceFile, options) : Value.Unknown;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function deriveActualIndentationFromList(list: Node[], index: number, sourceFile: SourceFile, options: EditorOptions): number {
|
||||
Debug.assert(index >= 0 && index < list.length);
|
||||
var node = list[index];
|
||||
@@ -292,27 +300,35 @@ module ts.formatting {
|
||||
continue;
|
||||
}
|
||||
// skip list items that ends on the same line with the current list element
|
||||
var prevEndLine = sourceFile.getLineAndCharacterFromPosition(list[i].end).line;
|
||||
var prevEndLine = sourceFile.getLineAndCharacterOfPosition(list[i].end).line;
|
||||
if (prevEndLine !== lineAndCharacter.line) {
|
||||
return findColumnForFirstNonWhitespaceCharacterInLine(lineAndCharacter, sourceFile, options);
|
||||
}
|
||||
|
||||
lineAndCharacter = getStartLineAndCharacterForNode(list[i], sourceFile);
|
||||
}
|
||||
return -1;
|
||||
return Value.Unknown;
|
||||
}
|
||||
|
||||
function findColumnForFirstNonWhitespaceCharacterInLine(lineAndCharacter: LineAndCharacter, sourceFile: SourceFile, options: EditorOptions): number {
|
||||
var lineStart = sourceFile.getPositionFromLineAndCharacter(lineAndCharacter.line, 1);
|
||||
var lineStart = sourceFile.getPositionOfLineAndCharacter(lineAndCharacter.line, 0);
|
||||
return findFirstNonWhitespaceColumn(lineStart, lineStart + lineAndCharacter.character, sourceFile, options);
|
||||
}
|
||||
|
||||
export function findFirstNonWhitespaceColumn(startPos: number, endPos: number, sourceFile: SourceFile, options: EditorOptions): number {
|
||||
/*
|
||||
Character is the actual index of the character since the beginning of the line.
|
||||
Column - position of the character after expanding tabs to spaces
|
||||
"0\t2$"
|
||||
value of 'character' for '$' is 3
|
||||
value of 'column' for '$' is 6 (assuming that tab size is 4)
|
||||
*/
|
||||
export function findFirstNonWhitespaceCharacterAndColumn(startPos: number, endPos: number, sourceFile: SourceFile, options: EditorOptions) {
|
||||
var character = 0;
|
||||
var column = 0;
|
||||
for (var pos = startPos; pos < endPos; ++pos) {
|
||||
var ch = sourceFile.text.charCodeAt(pos);
|
||||
if (!isWhiteSpace(ch)) {
|
||||
return column;
|
||||
break;
|
||||
}
|
||||
|
||||
if (ch === CharacterCodes.tab) {
|
||||
@@ -321,8 +337,14 @@ module ts.formatting {
|
||||
else {
|
||||
column++;
|
||||
}
|
||||
|
||||
character++;
|
||||
}
|
||||
return column;
|
||||
return { column, character };
|
||||
}
|
||||
|
||||
export function findFirstNonWhitespaceColumn(startPos: number, endPos: number, sourceFile: SourceFile, options: EditorOptions): number {
|
||||
return findFirstNonWhitespaceCharacterAndColumn(startPos, endPos, sourceFile, options).column;
|
||||
}
|
||||
|
||||
function nodeContentIsAlwaysIndented(kind: SyntaxKind): boolean {
|
||||
@@ -359,6 +381,7 @@ module ts.formatting {
|
||||
case SyntaxKind.DoStatement:
|
||||
case SyntaxKind.WhileStatement:
|
||||
case SyntaxKind.ForInStatement:
|
||||
case SyntaxKind.ForOfStatement:
|
||||
case SyntaxKind.ForStatement:
|
||||
case SyntaxKind.IfStatement:
|
||||
case SyntaxKind.FunctionDeclaration:
|
||||
|
||||
@@ -126,7 +126,7 @@ module ts.formatting {
|
||||
static AnyIncludingMultilineComments = TokenRange.FromTokens(TokenRange.Any.GetTokens().concat([SyntaxKind.MultiLineCommentTrivia]));
|
||||
static Keywords = TokenRange.FromRange(SyntaxKind.FirstKeyword, SyntaxKind.LastKeyword);
|
||||
static BinaryOperators = TokenRange.FromRange(SyntaxKind.FirstBinaryOperator, SyntaxKind.LastBinaryOperator);
|
||||
static BinaryKeywordOperators = TokenRange.FromTokens([SyntaxKind.InKeyword, SyntaxKind.InstanceOfKeyword]);
|
||||
static BinaryKeywordOperators = TokenRange.FromTokens([SyntaxKind.InKeyword, SyntaxKind.InstanceOfKeyword, SyntaxKind.OfKeyword]);
|
||||
static UnaryPrefixOperators = TokenRange.FromTokens([SyntaxKind.PlusPlusToken, SyntaxKind.MinusMinusToken, SyntaxKind.TildeToken, SyntaxKind.ExclamationToken]);
|
||||
static UnaryPrefixExpressions = TokenRange.FromTokens([SyntaxKind.NumericLiteral, SyntaxKind.Identifier, SyntaxKind.OpenParenToken, SyntaxKind.OpenBracketToken, SyntaxKind.OpenBraceToken, SyntaxKind.ThisKeyword, SyntaxKind.NewKeyword]);
|
||||
static UnaryPreincrementExpressions = TokenRange.FromTokens([SyntaxKind.Identifier, SyntaxKind.OpenParenToken, SyntaxKind.ThisKeyword, SyntaxKind.NewKeyword]);
|
||||
@@ -134,7 +134,7 @@ module ts.formatting {
|
||||
static UnaryPredecrementExpressions = TokenRange.FromTokens([SyntaxKind.Identifier, SyntaxKind.OpenParenToken, SyntaxKind.ThisKeyword, SyntaxKind.NewKeyword]);
|
||||
static UnaryPostdecrementExpressions = TokenRange.FromTokens([SyntaxKind.Identifier, SyntaxKind.CloseParenToken, SyntaxKind.CloseBracketToken, SyntaxKind.NewKeyword]);
|
||||
static Comments = TokenRange.FromTokens([SyntaxKind.SingleLineCommentTrivia, SyntaxKind.MultiLineCommentTrivia]);
|
||||
static TypeNames = TokenRange.FromTokens([SyntaxKind.Identifier, SyntaxKind.NumberKeyword, SyntaxKind.StringKeyword, SyntaxKind.BooleanKeyword, SyntaxKind.VoidKeyword, SyntaxKind.AnyKeyword]);
|
||||
static TypeNames = TokenRange.FromTokens([SyntaxKind.Identifier, SyntaxKind.NumberKeyword, SyntaxKind.StringKeyword, SyntaxKind.BooleanKeyword, SyntaxKind.SymbolKeyword, SyntaxKind.VoidKeyword, SyntaxKind.AnyKeyword]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,209 @@
|
||||
module ts.NavigateTo {
|
||||
type RawNavigateToItem = { name: string; fileName: string; matchKind: PatternMatchKind; isCaseSensitive: boolean; declaration: Declaration };
|
||||
|
||||
export function getNavigateToItems(program: Program, cancellationToken: CancellationTokenObject, searchValue: string, maxResultCount: number): NavigateToItem[] {
|
||||
var patternMatcher = createPatternMatcher(searchValue);
|
||||
var rawItems: RawNavigateToItem[] = [];
|
||||
|
||||
// Search the declarations in all files and output matched NavigateToItem into array of NavigateToItem[]
|
||||
forEach(program.getSourceFiles(), sourceFile => {
|
||||
cancellationToken.throwIfCancellationRequested();
|
||||
|
||||
var declarations = sourceFile.getNamedDeclarations();
|
||||
for (var i = 0, n = declarations.length; i < n; i++) {
|
||||
var declaration = declarations[i];
|
||||
var name = getDeclarationName(declaration);
|
||||
if (name !== undefined) {
|
||||
|
||||
// First do a quick check to see if the name of the declaration matches the
|
||||
// last portion of the (possibly) dotted name they're searching for.
|
||||
var matches = patternMatcher.getMatchesForLastSegmentOfPattern(name);
|
||||
|
||||
if (!matches) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// It was a match! If the pattern has dots in it, then also see if hte
|
||||
// declaration container matches as well.
|
||||
if (patternMatcher.patternContainsDots) {
|
||||
var containers = getContainers(declaration);
|
||||
if (!containers) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
matches = patternMatcher.getMatches(containers, name);
|
||||
|
||||
if (!matches) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
var fileName = sourceFile.fileName;
|
||||
var matchKind = bestMatchKind(matches);
|
||||
rawItems.push({ name, fileName, matchKind, isCaseSensitive: allMatchesAreCaseSensitive(matches), declaration });
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
rawItems.sort(compareNavigateToItems);
|
||||
if (maxResultCount !== undefined) {
|
||||
rawItems = rawItems.slice(0, maxResultCount);
|
||||
}
|
||||
|
||||
var items = map(rawItems, createNavigateToItem);
|
||||
|
||||
return items;
|
||||
|
||||
function allMatchesAreCaseSensitive(matches: PatternMatch[]): boolean {
|
||||
Debug.assert(matches.length > 0);
|
||||
|
||||
// This is a case sensitive match, only if all the submatches were case sensitive.
|
||||
for (var i = 0, n = matches.length; i < n; i++) {
|
||||
if (!matches[i].isCaseSensitive) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function getDeclarationName(declaration: Declaration): string {
|
||||
var result = getTextOfIdentifierOrLiteral(declaration.name);
|
||||
if (result !== undefined) {
|
||||
return result;
|
||||
}
|
||||
|
||||
if (declaration.name.kind === SyntaxKind.ComputedPropertyName) {
|
||||
var expr = (<ComputedPropertyName>declaration.name).expression;
|
||||
if (expr.kind === SyntaxKind.PropertyAccessExpression) {
|
||||
return (<PropertyAccessExpression>expr).name.text;
|
||||
}
|
||||
|
||||
return getTextOfIdentifierOrLiteral(expr);
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
function getTextOfIdentifierOrLiteral(node: Node) {
|
||||
if (node.kind === SyntaxKind.Identifier ||
|
||||
node.kind === SyntaxKind.StringLiteral ||
|
||||
node.kind === SyntaxKind.NumericLiteral) {
|
||||
|
||||
return (<Identifier | LiteralExpression>node).text;
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
function tryAddSingleDeclarationName(declaration: Declaration, containers: string[]) {
|
||||
if (declaration && declaration.name) {
|
||||
var text = getTextOfIdentifierOrLiteral(declaration.name);
|
||||
if (text !== undefined) {
|
||||
containers.unshift(text);
|
||||
}
|
||||
else if (declaration.name.kind === SyntaxKind.ComputedPropertyName) {
|
||||
return tryAddComputedPropertyName((<ComputedPropertyName>declaration.name).expression, containers, /*includeLastPortion:*/ true);
|
||||
}
|
||||
else {
|
||||
// Don't know how to add this.
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// Only added the names of computed properties if they're simple dotted expressions, like:
|
||||
//
|
||||
// [X.Y.Z]() { }
|
||||
function tryAddComputedPropertyName(expression: Expression, containers: string[], includeLastPortion: boolean): boolean {
|
||||
var text = getTextOfIdentifierOrLiteral(expression);
|
||||
if (text !== undefined) {
|
||||
if (includeLastPortion) {
|
||||
containers.unshift(text);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
if (expression.kind === SyntaxKind.PropertyAccessExpression) {
|
||||
var propertyAccess = <PropertyAccessExpression>expression;
|
||||
if (includeLastPortion) {
|
||||
containers.unshift(propertyAccess.name.text);
|
||||
}
|
||||
|
||||
return tryAddComputedPropertyName(propertyAccess.expression, containers, /*includeLastPortion:*/ true);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function getContainers(declaration: Declaration) {
|
||||
var containers: string[] = [];
|
||||
|
||||
// First, if we started with a computed property name, then add all but the last
|
||||
// portion into the container array.
|
||||
if (declaration.name.kind === SyntaxKind.ComputedPropertyName) {
|
||||
if (!tryAddComputedPropertyName((<ComputedPropertyName>declaration.name).expression, containers, /*includeLastPortion:*/ false)) {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
// Now, walk up our containers, adding all their names to the container array.
|
||||
declaration = getContainerNode(declaration);
|
||||
|
||||
while (declaration) {
|
||||
if (!tryAddSingleDeclarationName(declaration, containers)) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
declaration = getContainerNode(declaration);
|
||||
}
|
||||
|
||||
return containers;
|
||||
}
|
||||
|
||||
function bestMatchKind(matches: PatternMatch[]) {
|
||||
Debug.assert(matches.length > 0);
|
||||
var bestMatchKind = PatternMatchKind.camelCase;
|
||||
|
||||
for (var i = 0, n = matches.length; i < n; i++) {
|
||||
var kind = matches[i].kind;
|
||||
if (kind < bestMatchKind) {
|
||||
bestMatchKind = kind;
|
||||
}
|
||||
}
|
||||
|
||||
return bestMatchKind;
|
||||
}
|
||||
|
||||
// This means "compare in a case insensitive manner."
|
||||
var baseSensitivity: Intl.CollatorOptions = { sensitivity: "base" };
|
||||
function compareNavigateToItems(i1: RawNavigateToItem, i2: RawNavigateToItem) {
|
||||
// TODO(cyrusn): get the gamut of comparisons that VS already uses here.
|
||||
// Right now we just sort by kind first, and then by name of the item.
|
||||
// We first sort case insensitively. So "Aaa" will come before "bar".
|
||||
// Then we sort case sensitively, so "aaa" will come before "Aaa".
|
||||
return i1.matchKind - i2.matchKind ||
|
||||
i1.name.localeCompare(i2.name, undefined, baseSensitivity) ||
|
||||
i1.name.localeCompare(i2.name);
|
||||
}
|
||||
|
||||
function createNavigateToItem(rawItem: RawNavigateToItem): NavigateToItem {
|
||||
var declaration = rawItem.declaration;
|
||||
var container = <Declaration>getContainerNode(declaration);
|
||||
return {
|
||||
name: rawItem.name,
|
||||
kind: getNodeKind(declaration),
|
||||
kindModifiers: getNodeModifiers(declaration),
|
||||
matchKind: PatternMatchKind[rawItem.matchKind],
|
||||
isCaseSensitive: rawItem.isCaseSensitive,
|
||||
fileName: rawItem.fileName,
|
||||
textSpan: createTextSpanFromBounds(declaration.getStart(), declaration.getEnd()),
|
||||
// TODO(jfreeman): What should be the containerName when the container has a computed name?
|
||||
containerName: container && container.name ? (<Identifier>container.name).text : "",
|
||||
containerKind: container && container.name ? getNodeKind(container) : ""
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -97,8 +97,7 @@ module ts.NavigationBar {
|
||||
function sortNodes(nodes: Node[]): Node[] {
|
||||
return nodes.slice(0).sort((n1: Declaration, n2: Declaration) => {
|
||||
if (n1.name && n2.name) {
|
||||
// TODO(jfreeman): How do we sort declarations with computed names?
|
||||
return (<Identifier>n1.name).text.localeCompare((<Identifier>n2.name).text);
|
||||
return getPropertyNameForPropertyNameNode(n1.name).localeCompare(getPropertyNameForPropertyNameNode(n2.name));
|
||||
}
|
||||
else if (n1.name) {
|
||||
return 1;
|
||||
@@ -424,11 +423,11 @@ module ts.NavigationBar {
|
||||
});
|
||||
|
||||
// Add the constructor parameters in as children of the class (for property parameters).
|
||||
// Note that *all* parameters will be added to the nodes array, but parameters that
|
||||
// Note that *all non-binding pattern named* parameters will be added to the nodes array, but parameters that
|
||||
// are not properties will be filtered out later by createChildItem.
|
||||
var nodes: Node[] = removeComputedProperties(node);
|
||||
var nodes: Node[] = removeDynamicallyNamedProperties(node);
|
||||
if (constructor) {
|
||||
nodes.push.apply(nodes, constructor.parameters);
|
||||
nodes.push.apply(nodes, filter(constructor.parameters, p => !isBindingPattern(p.name)));
|
||||
}
|
||||
|
||||
var childItems = getItemsWorker(sortNodes(nodes), createChildItem);
|
||||
@@ -455,7 +454,7 @@ module ts.NavigationBar {
|
||||
}
|
||||
|
||||
function createIterfaceItem(node: InterfaceDeclaration): ts.NavigationBarItem {
|
||||
var childItems = getItemsWorker(sortNodes(removeComputedProperties(node)), createChildItem);
|
||||
var childItems = getItemsWorker(sortNodes(removeDynamicallyNamedProperties(node)), createChildItem);
|
||||
return getNavigationBarItem(
|
||||
node.name.text,
|
||||
ts.ScriptElementKind.interfaceElement,
|
||||
@@ -466,10 +465,17 @@ module ts.NavigationBar {
|
||||
}
|
||||
}
|
||||
|
||||
function removeComputedProperties(node: ClassDeclaration | InterfaceDeclaration | EnumDeclaration): Declaration[] {
|
||||
function removeComputedProperties(node: EnumDeclaration): Declaration[] {
|
||||
return filter<Declaration>(node.members, member => member.name === undefined || member.name.kind !== SyntaxKind.ComputedPropertyName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Like removeComputedProperties, but retains the properties with well known symbol names
|
||||
*/
|
||||
function removeDynamicallyNamedProperties(node: ClassDeclaration | InterfaceDeclaration): Declaration[]{
|
||||
return filter<Declaration>(node.members, member => !hasDynamicName(member));
|
||||
}
|
||||
|
||||
function getInnermostModule(node: ModuleDeclaration): ModuleDeclaration {
|
||||
while (node.body.kind === SyntaxKind.ModuleDeclaration) {
|
||||
node = <ModuleDeclaration>node.body;
|
||||
|
||||
@@ -32,15 +32,7 @@ module ts {
|
||||
}
|
||||
|
||||
function autoCollapse(node: Node) {
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.ModuleBlock:
|
||||
case SyntaxKind.ClassDeclaration:
|
||||
case SyntaxKind.InterfaceDeclaration:
|
||||
case SyntaxKind.EnumDeclaration:
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
return isFunctionBlock(node) && node.parent.kind !== SyntaxKind.ArrowFunction;
|
||||
}
|
||||
|
||||
var depth = 0;
|
||||
@@ -61,6 +53,7 @@ module ts {
|
||||
// to be the entire span of the parent.
|
||||
if (parent.kind === SyntaxKind.DoStatement ||
|
||||
parent.kind === SyntaxKind.ForInStatement ||
|
||||
parent.kind === SyntaxKind.ForOfStatement ||
|
||||
parent.kind === SyntaxKind.ForStatement ||
|
||||
parent.kind === SyntaxKind.IfStatement ||
|
||||
parent.kind === SyntaxKind.WhileStatement ||
|
||||
|
||||
@@ -0,0 +1,812 @@
|
||||
module ts {
|
||||
// Note(cyrusn): this enum is ordered from strongest match type to weakest match type.
|
||||
export enum PatternMatchKind {
|
||||
exact,
|
||||
prefix,
|
||||
substring,
|
||||
camelCase
|
||||
}
|
||||
|
||||
// Information about a match made by the pattern matcher between a candidate and the
|
||||
// search pattern.
|
||||
export interface PatternMatch {
|
||||
// What kind of match this was. Exact matches are better than prefix matches which are
|
||||
// better than substring matches which are better than CamelCase matches.
|
||||
kind: PatternMatchKind;
|
||||
|
||||
// If this was a camel case match, how strong the match is. Higher number means
|
||||
// it was a better match.
|
||||
camelCaseWeight?: number;
|
||||
|
||||
// If this was a match where all constituent parts of the candidate and search pattern
|
||||
// matched case sensitively or case insensitively. Case sensitive matches of the kind
|
||||
// are better matches than insensitive matches.
|
||||
isCaseSensitive: boolean;
|
||||
|
||||
// Whether or not this match occurred with the punctuation from the search pattern stripped
|
||||
// out or not. Matches without the punctuation stripped are better than ones with punctuation
|
||||
// stripped.
|
||||
punctuationStripped: boolean;
|
||||
}
|
||||
|
||||
// The pattern matcher maintains an internal cache of information as it is used. Therefore,
|
||||
// you should not keep it around forever and should get and release the matcher appropriately
|
||||
// once you no longer need it.
|
||||
export interface PatternMatcher {
|
||||
// Used to match a candidate against the last segment of a possibly dotted pattern. This
|
||||
// is useful as a quick check to prevent having to compute a container before calling
|
||||
// "getMatches".
|
||||
//
|
||||
// For example, if the search pattern is "ts.c.SK" and the candidate is "SyntaxKind", then
|
||||
// this will return a successful match, having only tested "SK" against "SyntaxKind". At
|
||||
// that point a call can be made to 'getMatches("SyntaxKind", "ts.compiler")', with the
|
||||
// work to create 'ts.compiler' only being done once the first match succeeded.
|
||||
getMatchesForLastSegmentOfPattern(candidate: string): PatternMatch[];
|
||||
|
||||
// Fully checks a candidate, with an dotted container, against the search pattern.
|
||||
// The candidate must match the last part of the search pattern, and the dotted container
|
||||
// must match the preceding segments of the pattern.
|
||||
getMatches(candidateContainers: string[], candidate: string): PatternMatch[];
|
||||
|
||||
// Whether or not the pattern contained dots or not. Clients can use this to determine
|
||||
// If they should call getMatches, or if getMatchesForLastSegmentOfPattern is sufficient.
|
||||
patternContainsDots: boolean;
|
||||
}
|
||||
|
||||
// First we break up the pattern given by dots. Each portion of the pattern between the
|
||||
// dots is a 'Segment'. The 'Segment' contains information about the entire section of
|
||||
// text between the dots, as well as information about any individual 'Words' that we
|
||||
// can break the segment into. A 'Word' is simply a contiguous sequence of characters
|
||||
// that can appear in a typescript identifier. So "GetKeyword" would be one word, while
|
||||
// "Get Keyword" would be two words. Once we have the individual 'words', we break those
|
||||
// into constituent 'character spans' of interest. For example, while 'UIElement' is one
|
||||
// word, it make character spans corresponding to "U", "I" and "Element". These spans
|
||||
// are then used when doing camel cased matches against candidate patterns.
|
||||
interface Segment {
|
||||
// Information about the entire piece of text between the dots. For example, if the
|
||||
// text between the dots is 'GetKeyword', then TotalTextChunk.Text will be 'GetKeyword' and
|
||||
// TotalTextChunk.CharacterSpans will correspond to 'Get', 'Keyword'.
|
||||
totalTextChunk: TextChunk;
|
||||
|
||||
// Information about the subwords compromising the total word. For example, if the
|
||||
// text between the dots is 'GetFoo KeywordBar', then the subwords will be 'GetFoo'
|
||||
// and 'KeywordBar'. Those individual words will have CharacterSpans of ('Get' and
|
||||
// 'Foo') and('Keyword' and 'Bar') respectively.
|
||||
subWordTextChunks: TextChunk[];
|
||||
}
|
||||
|
||||
// Information about a chunk of text from the pattern. The chunk is a piece of text, with
|
||||
// cached information about the character spans within in. Character spans are used for
|
||||
// camel case matching.
|
||||
interface TextChunk {
|
||||
// The text of the chunk. This should be a contiguous sequence of character that could
|
||||
// occur in a symbol name.
|
||||
text: string;
|
||||
|
||||
// The text of a chunk in lower case. Cached because it is needed often to check for
|
||||
// case insensitive matches.
|
||||
textLowerCase: string;
|
||||
|
||||
// Whether or not this chunk is entirely lowercase. We have different rules when searching
|
||||
// for something entirely lowercase or not.
|
||||
isLowerCase: boolean;
|
||||
|
||||
// The spans in this text chunk that we think are of interest and should be matched
|
||||
// independently. For example, if the chunk is for "UIElement" the the spans of interest
|
||||
// correspond to "U", "I" and "Element". If "UIElement" isn't found as an exaxt, prefix.
|
||||
// or substring match, then the character spans will be used to attempt a camel case match.
|
||||
characterSpans: TextSpan[];
|
||||
}
|
||||
|
||||
function createPatternMatch(kind: PatternMatchKind, punctuationStripped: boolean, isCaseSensitive: boolean, camelCaseWeight?: number): PatternMatch {
|
||||
return {
|
||||
kind,
|
||||
punctuationStripped,
|
||||
isCaseSensitive,
|
||||
camelCaseWeight
|
||||
};
|
||||
}
|
||||
|
||||
export function createPatternMatcher(pattern: string): PatternMatcher {
|
||||
// We'll often see the same candidate string many times when searching (For example, when
|
||||
// we see the name of a module that is used everywhere, or the name of an overload). As
|
||||
// such, we cache the information we compute about the candidate for the life of this
|
||||
// pattern matcher so we don't have to compute it multiple times.
|
||||
var stringToWordSpans: Map<TextSpan[]> = {};
|
||||
|
||||
pattern = pattern.trim();
|
||||
|
||||
var fullPatternSegment = createSegment(pattern);
|
||||
var dotSeparatedSegments = pattern.split(".").map(p => createSegment(p.trim()));
|
||||
var invalidPattern = dotSeparatedSegments.length === 0 || forEach(dotSeparatedSegments, segmentIsInvalid);
|
||||
|
||||
return {
|
||||
getMatches,
|
||||
getMatchesForLastSegmentOfPattern,
|
||||
patternContainsDots: dotSeparatedSegments.length > 1
|
||||
};
|
||||
|
||||
// Quick checks so we can bail out when asked to match a candidate.
|
||||
function skipMatch(candidate: string) {
|
||||
return invalidPattern || !candidate;
|
||||
}
|
||||
|
||||
function getMatchesForLastSegmentOfPattern(candidate: string): PatternMatch[] {
|
||||
if (skipMatch(candidate)) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
return matchSegment(candidate, lastOrUndefined(dotSeparatedSegments));
|
||||
}
|
||||
|
||||
function getMatches(candidateContainers: string[], candidate: string): PatternMatch[] {
|
||||
if (skipMatch(candidate)) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
// First, check that the last part of the dot separated pattern matches the name of the
|
||||
// candidate. If not, then there's no point in proceeding and doing the more
|
||||
// expensive work.
|
||||
var candidateMatch = matchSegment(candidate, lastOrUndefined(dotSeparatedSegments));
|
||||
if (!candidateMatch) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
candidateContainers = candidateContainers || [];
|
||||
|
||||
// -1 because the last part was checked against the name, and only the rest
|
||||
// of the parts are checked against the container.
|
||||
if (dotSeparatedSegments.length - 1 > candidateContainers.length) {
|
||||
// There weren't enough container parts to match against the pattern parts.
|
||||
// So this definitely doesn't match.
|
||||
return undefined;
|
||||
}
|
||||
|
||||
// So far so good. Now break up the container for the candidate and check if all
|
||||
// the dotted parts match up correctly.
|
||||
var totalMatch = candidateMatch;
|
||||
|
||||
for (var i = dotSeparatedSegments.length - 2, j = candidateContainers.length - 1;
|
||||
i >= 0;
|
||||
i--, j--) {
|
||||
|
||||
var segment = dotSeparatedSegments[i];
|
||||
var containerName = candidateContainers[j];
|
||||
|
||||
var containerMatch = matchSegment(containerName, segment);
|
||||
if (!containerMatch) {
|
||||
// This container didn't match the pattern piece. So there's no match at all.
|
||||
return undefined;
|
||||
}
|
||||
|
||||
addRange(totalMatch, containerMatch);
|
||||
}
|
||||
|
||||
// Success, this symbol's full name matched against the dotted name the user was asking
|
||||
// about.
|
||||
return totalMatch;
|
||||
}
|
||||
|
||||
function getWordSpans(word: string): TextSpan[] {
|
||||
if (!hasProperty(stringToWordSpans, word)) {
|
||||
stringToWordSpans[word] = breakIntoWordSpans(word);
|
||||
}
|
||||
|
||||
return stringToWordSpans[word];
|
||||
}
|
||||
|
||||
function matchTextChunk(candidate: string, chunk: TextChunk, punctuationStripped: boolean): PatternMatch {
|
||||
var index = indexOfIgnoringCase(candidate, chunk.textLowerCase);
|
||||
if (index === 0) {
|
||||
if (chunk.text.length === candidate.length) {
|
||||
// a) Check if the part matches the candidate entirely, in an case insensitive or
|
||||
// sensitive manner. If it does, return that there was an exact match.
|
||||
return createPatternMatch(PatternMatchKind.exact, punctuationStripped, /*isCaseSensitive:*/ candidate === chunk.text);
|
||||
}
|
||||
else {
|
||||
// b) Check if the part is a prefix of the candidate, in a case insensitive or sensitive
|
||||
// manner. If it does, return that there was a prefix match.
|
||||
return createPatternMatch(PatternMatchKind.prefix, punctuationStripped, /*isCaseSensitive:*/ startsWith(candidate, chunk.text));
|
||||
}
|
||||
}
|
||||
|
||||
var isLowercase = chunk.isLowerCase;
|
||||
if (isLowercase) {
|
||||
if (index > 0) {
|
||||
// c) If the part is entirely lowercase, then check if it is contained anywhere in the
|
||||
// candidate in a case insensitive manner. If so, return that there was a substring
|
||||
// match.
|
||||
//
|
||||
// Note: We only have a substring match if the lowercase part is prefix match of some
|
||||
// word part. That way we don't match something like 'Class' when the user types 'a'.
|
||||
// But we would match 'FooAttribute' (since 'Attribute' starts with 'a').
|
||||
var wordSpans = getWordSpans(candidate);
|
||||
for (var i = 0, n = wordSpans.length; i < n; i++) {
|
||||
var span = wordSpans[i]
|
||||
if (partStartsWith(candidate, span, chunk.text, /*ignoreCase:*/ true)) {
|
||||
return createPatternMatch(PatternMatchKind.substring, punctuationStripped,
|
||||
/*isCaseSensitive:*/ partStartsWith(candidate, span, chunk.text, /*ignoreCase:*/ false));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
// d) If the part was not entirely lowercase, then check if it is contained in the
|
||||
// candidate in a case *sensitive* manner. If so, return that there was a substring
|
||||
// match.
|
||||
if (candidate.indexOf(chunk.text) > 0) {
|
||||
return createPatternMatch(PatternMatchKind.substring, punctuationStripped, /*isCaseSensitive:*/ true);
|
||||
}
|
||||
}
|
||||
|
||||
if (!isLowercase) {
|
||||
// e) If the part was not entirely lowercase, then attempt a camel cased match as well.
|
||||
if (chunk.characterSpans.length > 0) {
|
||||
var candidateParts = getWordSpans(candidate);
|
||||
var camelCaseWeight = tryCamelCaseMatch(candidate, candidateParts, chunk, /*ignoreCase:*/ false);
|
||||
if (camelCaseWeight !== undefined) {
|
||||
return createPatternMatch(PatternMatchKind.camelCase, punctuationStripped, /*isCaseSensitive:*/ true, /*camelCaseWeight:*/ camelCaseWeight);
|
||||
}
|
||||
|
||||
camelCaseWeight = tryCamelCaseMatch(candidate, candidateParts, chunk, /*ignoreCase:*/ true);
|
||||
if (camelCaseWeight !== undefined) {
|
||||
return createPatternMatch(PatternMatchKind.camelCase, punctuationStripped, /*isCaseSensitive:*/ false, /*camelCaseWeight:*/ camelCaseWeight);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (isLowercase) {
|
||||
// f) Is the pattern a substring of the candidate starting on one of the candidate's word boundaries?
|
||||
|
||||
// We could check every character boundary start of the candidate for the pattern. However, that's
|
||||
// an m * n operation in the wost case. Instead, find the first instance of the pattern
|
||||
// substring, and see if it starts on a capital letter. It seems unlikely that the user will try to
|
||||
// filter the list based on a substring that starts on a capital letter and also with a lowercase one.
|
||||
// (Pattern: fogbar, Candidate: quuxfogbarFogBar).
|
||||
if (chunk.text.length < candidate.length) {
|
||||
if (index > 0 && isUpperCaseLetter(candidate.charCodeAt(index))) {
|
||||
return createPatternMatch(PatternMatchKind.substring, punctuationStripped, /*isCaseSensitive:*/ false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
function containsSpaceOrAsterisk(text: string): boolean {
|
||||
for (var i = 0; i < text.length; i++) {
|
||||
var ch = text.charCodeAt(i);
|
||||
if (ch === CharacterCodes.space || ch === CharacterCodes.asterisk) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function matchSegment(candidate: string, segment: Segment): PatternMatch[] {
|
||||
// First check if the segment matches as is. This is also useful if the segment contains
|
||||
// characters we would normally strip when splitting into parts that we also may want to
|
||||
// match in the candidate. For example if the segment is "@int" and the candidate is
|
||||
// "@int", then that will show up as an exact match here.
|
||||
//
|
||||
// Note: if the segment contains a space or an asterisk then we must assume that it's a
|
||||
// multi-word segment.
|
||||
if (!containsSpaceOrAsterisk(segment.totalTextChunk.text)) {
|
||||
var match = matchTextChunk(candidate, segment.totalTextChunk, /*punctuationStripped:*/ false);
|
||||
if (match) {
|
||||
return [match];
|
||||
}
|
||||
}
|
||||
|
||||
// The logic for pattern matching is now as follows:
|
||||
//
|
||||
// 1) Break the segment passed in into words. Breaking is rather simple and a
|
||||
// good way to think about it that if gives you all the individual alphanumeric words
|
||||
// of the pattern.
|
||||
//
|
||||
// 2) For each word try to match the word against the candidate value.
|
||||
//
|
||||
// 3) Matching is as follows:
|
||||
//
|
||||
// a) Check if the word matches the candidate entirely, in an case insensitive or
|
||||
// sensitive manner. If it does, return that there was an exact match.
|
||||
//
|
||||
// b) Check if the word is a prefix of the candidate, in a case insensitive or
|
||||
// sensitive manner. If it does, return that there was a prefix match.
|
||||
//
|
||||
// c) If the word is entirely lowercase, then check if it is contained anywhere in the
|
||||
// candidate in a case insensitive manner. If so, return that there was a substring
|
||||
// match.
|
||||
//
|
||||
// Note: We only have a substring match if the lowercase part is prefix match of
|
||||
// some word part. That way we don't match something like 'Class' when the user
|
||||
// types 'a'. But we would match 'FooAttribute' (since 'Attribute' starts with
|
||||
// 'a').
|
||||
//
|
||||
// d) If the word was not entirely lowercase, then check if it is contained in the
|
||||
// candidate in a case *sensitive* manner. If so, return that there was a substring
|
||||
// match.
|
||||
//
|
||||
// e) If the word was not entirely lowercase, then attempt a camel cased match as
|
||||
// well.
|
||||
//
|
||||
// f) The word is all lower case. Is it a case insensitive substring of the candidate starting
|
||||
// on a part boundary of the candidate?
|
||||
//
|
||||
// Only if all words have some sort of match is the pattern considered matched.
|
||||
|
||||
var subWordTextChunks = segment.subWordTextChunks;
|
||||
var matches: PatternMatch[] = undefined;
|
||||
|
||||
for (var i = 0, n = subWordTextChunks.length; i < n; i++) {
|
||||
var subWordTextChunk = subWordTextChunks[i];
|
||||
|
||||
// Try to match the candidate with this word
|
||||
var result = matchTextChunk(candidate, subWordTextChunk, /*punctuationStripped:*/ true);
|
||||
if (!result) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
matches = matches || [];
|
||||
matches.push(result);
|
||||
}
|
||||
|
||||
return matches;
|
||||
}
|
||||
|
||||
function partStartsWith(candidate: string, candidateSpan: TextSpan, pattern: string, ignoreCase: boolean, patternSpan?: TextSpan): boolean {
|
||||
var patternPartStart = patternSpan ? patternSpan.start : 0;
|
||||
var patternPartLength = patternSpan ? patternSpan.length : pattern.length;
|
||||
|
||||
if (patternPartLength > candidateSpan.length) {
|
||||
// Pattern part is longer than the candidate part. There can never be a match.
|
||||
return false;
|
||||
}
|
||||
|
||||
if (ignoreCase) {
|
||||
for (var i = 0; i < patternPartLength; i++) {
|
||||
var ch1 = pattern.charCodeAt(patternPartStart + i);
|
||||
var ch2 = candidate.charCodeAt(candidateSpan.start + i);
|
||||
if (toLowerCase(ch1) !== toLowerCase(ch2)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
for (var i = 0; i < patternPartLength; i++) {
|
||||
var ch1 = pattern.charCodeAt(patternPartStart + i);
|
||||
var ch2 = candidate.charCodeAt(candidateSpan.start + i);
|
||||
if (ch1 !== ch2) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function tryCamelCaseMatch(candidate: string, candidateParts: TextSpan[], chunk: TextChunk, ignoreCase: boolean): number {
|
||||
var chunkCharacterSpans = chunk.characterSpans;
|
||||
|
||||
// Note: we may have more pattern parts than candidate parts. This is because multiple
|
||||
// pattern parts may match a candidate part. For example "SiUI" against "SimpleUI".
|
||||
// We'll have 3 pattern parts Si/U/I against two candidate parts Simple/UI. However, U
|
||||
// and I will both match in UI.
|
||||
|
||||
var currentCandidate = 0;
|
||||
var currentChunkSpan = 0;
|
||||
var firstMatch: number = undefined;
|
||||
var contiguous: boolean = undefined;
|
||||
|
||||
while (true) {
|
||||
// Let's consider our termination cases
|
||||
if (currentChunkSpan === chunkCharacterSpans.length) {
|
||||
// We did match! We shall assign a weight to this
|
||||
var weight = 0;
|
||||
|
||||
// Was this contiguous?
|
||||
if (contiguous) {
|
||||
weight += 1;
|
||||
}
|
||||
|
||||
// Did we start at the beginning of the candidate?
|
||||
if (firstMatch === 0) {
|
||||
weight += 2;
|
||||
}
|
||||
|
||||
return weight;
|
||||
}
|
||||
else if (currentCandidate === candidateParts.length) {
|
||||
// No match, since we still have more of the pattern to hit
|
||||
return undefined;
|
||||
}
|
||||
|
||||
var candidatePart = candidateParts[currentCandidate];
|
||||
var gotOneMatchThisCandidate = false;
|
||||
|
||||
// Consider the case of matching SiUI against SimpleUIElement. The candidate parts
|
||||
// will be Simple/UI/Element, and the pattern parts will be Si/U/I. We'll match 'Si'
|
||||
// against 'Simple' first. Then we'll match 'U' against 'UI'. However, we want to
|
||||
// still keep matching pattern parts against that candidate part.
|
||||
for (; currentChunkSpan < chunkCharacterSpans.length; currentChunkSpan++) {
|
||||
var chunkCharacterSpan = chunkCharacterSpans[currentChunkSpan];
|
||||
|
||||
if (gotOneMatchThisCandidate) {
|
||||
// We've already gotten one pattern part match in this candidate. We will
|
||||
// only continue trying to consumer pattern parts if the last part and this
|
||||
// part are both upper case.
|
||||
if (!isUpperCaseLetter(chunk.text.charCodeAt(chunkCharacterSpans[currentChunkSpan - 1].start)) ||
|
||||
!isUpperCaseLetter(chunk.text.charCodeAt(chunkCharacterSpans[currentChunkSpan].start))) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!partStartsWith(candidate, candidatePart, chunk.text, ignoreCase, chunkCharacterSpan)) {
|
||||
break;
|
||||
}
|
||||
|
||||
gotOneMatchThisCandidate = true;
|
||||
|
||||
firstMatch = firstMatch === undefined ? currentCandidate : firstMatch;
|
||||
|
||||
// If we were contiguous, then keep that value. If we weren't, then keep that
|
||||
// value. If we don't know, then set the value to 'true' as an initial match is
|
||||
// obviously contiguous.
|
||||
contiguous = contiguous === undefined ? true : contiguous;
|
||||
|
||||
candidatePart = createTextSpan(candidatePart.start + chunkCharacterSpan.length, candidatePart.length - chunkCharacterSpan.length);
|
||||
}
|
||||
|
||||
// Check if we matched anything at all. If we didn't, then we need to unset the
|
||||
// contiguous bit if we currently had it set.
|
||||
// If we haven't set the bit yet, then that means we haven't matched anything so
|
||||
// far, and we don't want to change that.
|
||||
if (!gotOneMatchThisCandidate && contiguous !== undefined) {
|
||||
contiguous = false;
|
||||
}
|
||||
|
||||
// Move onto the next candidate.
|
||||
currentCandidate++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Helper function to compare two matches to determine which is better. Matches are first
|
||||
// ordered by kind (so all prefix matches always beat all substring matches). Then, if the
|
||||
// match is a camel case match, the relative weights of hte match are used to determine
|
||||
// which is better (with a greater weight being better). Then if the match is of the same
|
||||
// type, then a case sensitive match is considered better than an insensitive one.
|
||||
function patternMatchCompareTo(match1: PatternMatch, match2: PatternMatch): number {
|
||||
return compareType(match1, match2) ||
|
||||
compareCamelCase(match1, match2) ||
|
||||
compareCase(match1, match2) ||
|
||||
comparePunctuation(match1, match2);
|
||||
}
|
||||
|
||||
function comparePunctuation(result1: PatternMatch, result2: PatternMatch) {
|
||||
// Consider a match to be better if it was successful without stripping punctuation
|
||||
// versus a match that had to strip punctuation to succeed.
|
||||
if (result1.punctuationStripped !== result2.punctuationStripped) {
|
||||
return result1.punctuationStripped ? 1 : -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
function compareCase(result1: PatternMatch, result2: PatternMatch) {
|
||||
if (result1.isCaseSensitive !== result2.isCaseSensitive) {
|
||||
return result1.isCaseSensitive ? -1 : 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
function compareType(result1: PatternMatch, result2: PatternMatch) {
|
||||
return result1.kind - result2.kind;
|
||||
}
|
||||
|
||||
function compareCamelCase(result1: PatternMatch, result2: PatternMatch) {
|
||||
if (result1.kind === PatternMatchKind.camelCase && result2.kind === PatternMatchKind.camelCase) {
|
||||
// Swap the values here. If result1 has a higher weight, then we want it to come
|
||||
// first.
|
||||
return result2.camelCaseWeight - result1.camelCaseWeight;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
function createSegment(text: string): Segment {
|
||||
return {
|
||||
totalTextChunk: createTextChunk(text),
|
||||
subWordTextChunks: breakPatternIntoTextChunks(text)
|
||||
}
|
||||
}
|
||||
|
||||
// A segment is considered invalid if we couldn't find any words in it.
|
||||
function segmentIsInvalid(segment: Segment) {
|
||||
return segment.subWordTextChunks.length === 0;
|
||||
}
|
||||
|
||||
function isUpperCaseLetter(ch: number) {
|
||||
// Fast check for the ascii range.
|
||||
if (ch >= CharacterCodes.A && ch <= CharacterCodes.Z) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (ch < CharacterCodes.maxAsciiCharacter || !isUnicodeIdentifierStart(ch, ScriptTarget.Latest)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// TODO: find a way to determine this for any unicode characters in a
|
||||
// non-allocating manner.
|
||||
var str = String.fromCharCode(ch);
|
||||
return str === str.toUpperCase();
|
||||
}
|
||||
|
||||
function isLowerCaseLetter(ch: number) {
|
||||
// Fast check for the ascii range.
|
||||
if (ch >= CharacterCodes.a && ch <= CharacterCodes.z) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (ch < CharacterCodes.maxAsciiCharacter || !isUnicodeIdentifierStart(ch, ScriptTarget.Latest)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// TODO: find a way to determine this for any unicode characters in a
|
||||
// non-allocating manner.
|
||||
var str = String.fromCharCode(ch);
|
||||
return str === str.toLowerCase();
|
||||
}
|
||||
|
||||
function containsUpperCaseLetter(string: string): boolean {
|
||||
for (var i = 0, n = string.length; i < n; i++) {
|
||||
if (isUpperCaseLetter(string.charCodeAt(i))) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function startsWith(string: string, search: string) {
|
||||
for (var i = 0, n = search.length; i < n; i++) {
|
||||
if (string.charCodeAt(i) !== search.charCodeAt(i)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// Assumes 'value' is already lowercase.
|
||||
function indexOfIgnoringCase(string: string, value: string): number {
|
||||
for (var i = 0, n = string.length - value.length; i <= n; i++) {
|
||||
if (startsWithIgnoringCase(string, value, i)) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Assumes 'value' is already lowercase.
|
||||
function startsWithIgnoringCase(string: string, value: string, start: number): boolean {
|
||||
for (var i = 0, n = value.length; i < n; i++) {
|
||||
var ch1 = toLowerCase(string.charCodeAt(i + start));
|
||||
var ch2 = value.charCodeAt(i);
|
||||
|
||||
if (ch1 !== ch2) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function toLowerCase(ch: number): number {
|
||||
// Fast convert for the ascii range.
|
||||
if (ch >= CharacterCodes.A && ch <= CharacterCodes.Z) {
|
||||
return CharacterCodes.a + (ch - CharacterCodes.A);
|
||||
}
|
||||
|
||||
if (ch < CharacterCodes.maxAsciiCharacter) {
|
||||
return ch;
|
||||
}
|
||||
|
||||
// TODO: find a way to compute this for any unicode characters in a
|
||||
// non-allocating manner.
|
||||
return String.fromCharCode(ch).toLowerCase().charCodeAt(0);
|
||||
}
|
||||
|
||||
function isDigit(ch: number) {
|
||||
// TODO(cyrusn): Find a way to support this for unicode digits.
|
||||
return ch >= CharacterCodes._0 && ch <= CharacterCodes._9;
|
||||
}
|
||||
|
||||
function isWordChar(ch: number) {
|
||||
return isUpperCaseLetter(ch) || isLowerCaseLetter(ch) || isDigit(ch) || ch === CharacterCodes._ || ch === CharacterCodes.$;
|
||||
}
|
||||
|
||||
function breakPatternIntoTextChunks(pattern: string): TextChunk[] {
|
||||
var result: TextChunk[] = [];
|
||||
var wordStart = 0;
|
||||
var wordLength = 0;
|
||||
|
||||
for (var i = 0; i < pattern.length; i++) {
|
||||
var ch = pattern.charCodeAt(i);
|
||||
if (isWordChar(ch)) {
|
||||
if (wordLength++ === 0) {
|
||||
wordStart = i;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (wordLength > 0) {
|
||||
result.push(createTextChunk(pattern.substr(wordStart, wordLength)));
|
||||
wordLength = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (wordLength > 0) {
|
||||
result.push(createTextChunk(pattern.substr(wordStart, wordLength)));
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
function createTextChunk(text: string): TextChunk {
|
||||
var textLowerCase = text.toLowerCase();
|
||||
return {
|
||||
text,
|
||||
textLowerCase,
|
||||
isLowerCase: text === textLowerCase,
|
||||
characterSpans: breakIntoCharacterSpans(text)
|
||||
}
|
||||
}
|
||||
|
||||
/* @internal */ export function breakIntoCharacterSpans(identifier: string): TextSpan[] {
|
||||
return breakIntoSpans(identifier, /*word:*/ false);
|
||||
}
|
||||
|
||||
/* @internal */ export function breakIntoWordSpans(identifier: string): TextSpan[] {
|
||||
return breakIntoSpans(identifier, /*word:*/ true);
|
||||
}
|
||||
|
||||
function breakIntoSpans(identifier: string, word: boolean): TextSpan[] {
|
||||
var result: TextSpan[] = [];
|
||||
|
||||
var wordStart = 0;
|
||||
for (var i = 1, n = identifier.length; i < n; i++) {
|
||||
var lastIsDigit = isDigit(identifier.charCodeAt(i - 1));
|
||||
var currentIsDigit = isDigit(identifier.charCodeAt(i));
|
||||
|
||||
var hasTransitionFromLowerToUpper = transitionFromLowerToUpper(identifier, word, i);
|
||||
var hasTransitionFromUpperToLower = transitionFromUpperToLower(identifier, word, i, wordStart);
|
||||
|
||||
if (charIsPunctuation(identifier.charCodeAt(i - 1)) ||
|
||||
charIsPunctuation(identifier.charCodeAt(i)) ||
|
||||
lastIsDigit != currentIsDigit ||
|
||||
hasTransitionFromLowerToUpper ||
|
||||
hasTransitionFromUpperToLower) {
|
||||
|
||||
if (!isAllPunctuation(identifier, wordStart, i)) {
|
||||
result.push(createTextSpan(wordStart, i - wordStart));
|
||||
}
|
||||
|
||||
wordStart = i;
|
||||
}
|
||||
}
|
||||
|
||||
if (!isAllPunctuation(identifier, wordStart, identifier.length)) {
|
||||
result.push(createTextSpan(wordStart, identifier.length - wordStart));
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
function charIsPunctuation(ch: number) {
|
||||
switch (ch) {
|
||||
case CharacterCodes.exclamation:
|
||||
case CharacterCodes.doubleQuote:
|
||||
case CharacterCodes.hash:
|
||||
case CharacterCodes.percent:
|
||||
case CharacterCodes.ampersand:
|
||||
case CharacterCodes.singleQuote:
|
||||
case CharacterCodes.openParen:
|
||||
case CharacterCodes.closeParen:
|
||||
case CharacterCodes.asterisk:
|
||||
case CharacterCodes.comma:
|
||||
case CharacterCodes.minus:
|
||||
case CharacterCodes.dot:
|
||||
case CharacterCodes.slash:
|
||||
case CharacterCodes.colon:
|
||||
case CharacterCodes.semicolon:
|
||||
case CharacterCodes.question:
|
||||
case CharacterCodes.at:
|
||||
case CharacterCodes.openBracket:
|
||||
case CharacterCodes.backslash:
|
||||
case CharacterCodes.closeBracket:
|
||||
case CharacterCodes._:
|
||||
case CharacterCodes.openBrace:
|
||||
case CharacterCodes.closeBrace:
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function isAllPunctuation(identifier: string, start: number, end: number): boolean {
|
||||
for (var i = start; i < end; i++) {
|
||||
var ch = identifier.charCodeAt(i);
|
||||
|
||||
// We don't consider _ or $ as punctuation as there may be things with that name.
|
||||
if (!charIsPunctuation(ch) || ch === CharacterCodes._ || ch === CharacterCodes.$) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function transitionFromUpperToLower(identifier: string, word: boolean, index: number, wordStart: number): boolean {
|
||||
if (word) {
|
||||
// Cases this supports:
|
||||
// 1) IDisposable -> I, Disposable
|
||||
// 2) UIElement -> UI, Element
|
||||
// 3) HTMLDocument -> HTML, Document
|
||||
//
|
||||
// etc.
|
||||
if (index != wordStart &&
|
||||
index + 1 < identifier.length) {
|
||||
var currentIsUpper = isUpperCaseLetter(identifier.charCodeAt(index));
|
||||
var nextIsLower = isLowerCaseLetter(identifier.charCodeAt(index + 1));
|
||||
|
||||
if (currentIsUpper && nextIsLower) {
|
||||
// We have a transition from an upper to a lower letter here. But we only
|
||||
// want to break if all the letters that preceded are uppercase. i.e. if we
|
||||
// have "Foo" we don't want to break that into "F, oo". But if we have
|
||||
// "IFoo" or "UIFoo", then we want to break that into "I, Foo" and "UI,
|
||||
// Foo". i.e. the last uppercase letter belongs to the lowercase letters
|
||||
// that follows. Note: this will make the following not split properly:
|
||||
// "HELLOthere". However, these sorts of names do not show up in .Net
|
||||
// programs.
|
||||
for (var i = wordStart; i < index; i++) {
|
||||
if (!isUpperCaseLetter(identifier.charCodeAt(i))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function transitionFromLowerToUpper(identifier: string, word: boolean, index: number): boolean {
|
||||
var lastIsUpper = isUpperCaseLetter(identifier.charCodeAt(index - 1));
|
||||
var currentIsUpper = isUpperCaseLetter(identifier.charCodeAt(index));
|
||||
|
||||
// See if the casing indicates we're starting a new word. Note: if we're breaking on
|
||||
// words, then just seeing an upper case character isn't enough. Instead, it has to
|
||||
// be uppercase and the previous character can't be uppercase.
|
||||
//
|
||||
// For example, breaking "AddMetadata" on words would make: Add Metadata
|
||||
//
|
||||
// on characters would be: A dd M etadata
|
||||
//
|
||||
// Break "AM" on words would be: AM
|
||||
//
|
||||
// on characters would be: A M
|
||||
//
|
||||
// We break the search string on characters. But we break the symbol name on words.
|
||||
var transition = word
|
||||
? (currentIsUpper && !lastIsUpper)
|
||||
: currentIsUpper;
|
||||
return transition;
|
||||
}
|
||||
}
|
||||
@@ -1,448 +0,0 @@
|
||||
// <auto-generated />
|
||||
module TypeScript {
|
||||
export var DiagnosticCode = {
|
||||
error_TS_0_1: "error TS{0}: {1}",
|
||||
warning_TS_0_1: "warning TS{0}: {1}",
|
||||
Unrecognized_escape_sequence: "Unrecognized escape sequence.",
|
||||
Unexpected_character_0: "Unexpected character {0}.",
|
||||
Unterminated_string_literal: "Unterminated string literal.",
|
||||
Identifier_expected: "Identifier expected.",
|
||||
_0_keyword_expected: "'{0}' keyword expected.",
|
||||
_0_expected: "'{0}' expected.",
|
||||
Identifier_expected_0_is_a_keyword: "Identifier expected; '{0}' is a keyword.",
|
||||
Automatic_semicolon_insertion_not_allowed: "Automatic semicolon insertion not allowed.",
|
||||
Unexpected_token_0_expected: "Unexpected token; '{0}' expected.",
|
||||
Trailing_comma_not_allowed: "Trailing comma not allowed.",
|
||||
public_or_private_modifier_must_precede_static: "'public' or 'private' modifier must precede 'static'.",
|
||||
Unexpected_token: "Unexpected token.",
|
||||
Catch_clause_parameter_cannot_have_a_type_annotation: "Catch clause parameter cannot have a type annotation.",
|
||||
A_rest_parameter_must_be_last_in_a_parameter_list: "A rest parameter must be last in a parameter list.",
|
||||
Parameter_cannot_have_question_mark_and_initializer: "Parameter cannot have question mark and initializer.",
|
||||
A_required_parameter_cannot_follow_an_optional_parameter: "A required parameter cannot follow an optional parameter.",
|
||||
Index_signatures_cannot_have_rest_parameters: "Index signatures cannot have rest parameters.",
|
||||
Index_signature_parameter_cannot_have_modifiers: "Index signature parameter cannot have modifiers.",
|
||||
Index_signature_parameter_cannot_have_a_question_mark: "Index signature parameter cannot have a question mark.",
|
||||
Index_signature_parameter_cannot_have_an_initializer: "Index signature parameter cannot have an initializer.",
|
||||
Index_signature_must_have_a_type_annotation: "Index signature must have a type annotation.",
|
||||
Index_signature_parameter_must_have_a_type_annotation: "Index signature parameter must have a type annotation.",
|
||||
Index_signature_parameter_type_must_be_string_or_number: "Index signature parameter type must be 'string' or 'number'.",
|
||||
extends_clause_already_seen: "'extends' clause already seen.",
|
||||
extends_clause_must_precede_implements_clause: "'extends' clause must precede 'implements' clause.",
|
||||
Classes_can_only_extend_a_single_class: "Classes can only extend a single class.",
|
||||
implements_clause_already_seen: "'implements' clause already seen.",
|
||||
Accessibility_modifier_already_seen: "Accessibility modifier already seen.",
|
||||
_0_modifier_must_precede_1_modifier: "'{0}' modifier must precede '{1}' modifier.",
|
||||
_0_modifier_already_seen: "'{0}' modifier already seen.",
|
||||
_0_modifier_cannot_appear_on_a_class_element: "'{0}' modifier cannot appear on a class element.",
|
||||
Interface_declaration_cannot_have_implements_clause: "Interface declaration cannot have 'implements' clause.",
|
||||
super_invocation_cannot_have_type_arguments: "'super' invocation cannot have type arguments.",
|
||||
Only_ambient_modules_can_use_quoted_names: "Only ambient modules can use quoted names.",
|
||||
Statements_are_not_allowed_in_ambient_contexts: "Statements are not allowed in ambient contexts.",
|
||||
A_function_implementation_cannot_be_declared_in_an_ambient_context: "A function implementation cannot be declared in an ambient context.",
|
||||
A_declare_modifier_cannot_be_used_in_an_already_ambient_context: "A 'declare' modifier cannot be used in an already ambient context.",
|
||||
Initializers_are_not_allowed_in_ambient_contexts: "Initializers are not allowed in ambient contexts.",
|
||||
_0_modifier_cannot_appear_on_a_module_element: "'{0}' modifier cannot appear on a module element.",
|
||||
A_declare_modifier_cannot_be_used_with_an_interface_declaration: "A 'declare' modifier cannot be used with an interface declaration.",
|
||||
A_declare_modifier_is_required_for_a_top_level_declaration_in_a_d_ts_file: "A 'declare' modifier is required for a top level declaration in a .d.ts file.",
|
||||
A_rest_parameter_cannot_be_optional: "A rest parameter cannot be optional.",
|
||||
A_rest_parameter_cannot_have_an_initializer: "A rest parameter cannot have an initializer.",
|
||||
set_accessor_must_have_exactly_one_parameter: "'set' accessor must have exactly one parameter.",
|
||||
set_accessor_parameter_cannot_be_optional: "'set' accessor parameter cannot be optional.",
|
||||
set_accessor_parameter_cannot_have_an_initializer: "'set' accessor parameter cannot have an initializer.",
|
||||
set_accessor_cannot_have_rest_parameter: "'set' accessor cannot have rest parameter.",
|
||||
get_accessor_cannot_have_parameters: "'get' accessor cannot have parameters.",
|
||||
Modifiers_cannot_appear_here: "Modifiers cannot appear here.",
|
||||
Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher: "Accessors are only available when targeting ECMAScript 5 and higher.",
|
||||
Enum_member_must_have_initializer: "Enum member must have initializer.",
|
||||
Export_assignment_cannot_be_used_in_internal_modules: "Export assignment cannot be used in internal modules.",
|
||||
Ambient_enum_elements_can_only_have_integer_literal_initializers: "Ambient enum elements can only have integer literal initializers.",
|
||||
module_class_interface_enum_import_or_statement: "module, class, interface, enum, import or statement",
|
||||
constructor_function_accessor_or_variable: "constructor, function, accessor or variable",
|
||||
statement: "statement",
|
||||
case_or_default_clause: "case or default clause",
|
||||
identifier: "identifier",
|
||||
call_construct_index_property_or_function_signature: "call, construct, index, property or function signature",
|
||||
expression: "expression",
|
||||
type_name: "type name",
|
||||
property_or_accessor: "property or accessor",
|
||||
parameter: "parameter",
|
||||
type: "type",
|
||||
type_parameter: "type parameter",
|
||||
A_declare_modifier_cannot_be_used_with_an_import_declaration: "A 'declare' modifier cannot be used with an import declaration.",
|
||||
Invalid_reference_directive_syntax: "Invalid 'reference' directive syntax.",
|
||||
Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher: "Octal literals are not available when targeting ECMAScript 5 and higher.",
|
||||
Accessors_are_not_allowed_in_ambient_contexts: "Accessors are not allowed in ambient contexts.",
|
||||
_0_modifier_cannot_appear_on_a_constructor_declaration: "'{0}' modifier cannot appear on a constructor declaration.",
|
||||
_0_modifier_cannot_appear_on_a_parameter: "'{0}' modifier cannot appear on a parameter.",
|
||||
Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement: "Only a single variable declaration is allowed in a 'for...in' statement.",
|
||||
Type_parameters_cannot_appear_on_a_constructor_declaration: "Type parameters cannot appear on a constructor declaration.",
|
||||
Type_annotation_cannot_appear_on_a_constructor_declaration: "Type annotation cannot appear on a constructor declaration.",
|
||||
Type_parameters_cannot_appear_on_an_accessor: "Type parameters cannot appear on an accessor.",
|
||||
Type_annotation_cannot_appear_on_a_set_accessor: "Type annotation cannot appear on a 'set' accessor.",
|
||||
Index_signature_must_have_exactly_one_parameter: "Index signature must have exactly one parameter.",
|
||||
_0_list_cannot_be_empty: "'{0}' list cannot be empty.",
|
||||
variable_declaration: "variable declaration",
|
||||
type_argument: "type argument",
|
||||
Invalid_use_of_0_in_strict_mode: "Invalid use of '{0}' in strict mode.",
|
||||
with_statements_are_not_allowed_in_strict_mode: "'with' statements are not allowed in strict mode.",
|
||||
delete_cannot_be_called_on_an_identifier_in_strict_mode: "'delete' cannot be called on an identifier in strict mode.",
|
||||
Invalid_left_hand_side_in_for_in_statement: "Invalid left-hand side in 'for...in' statement.",
|
||||
continue_statement_can_only_be_used_within_an_enclosing_iteration_statement: "'continue' statement can only be used within an enclosing iteration statement.",
|
||||
break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement: "'break' statement can only be used within an enclosing iteration or switch statement.",
|
||||
Jump_target_not_found: "Jump target not found.",
|
||||
Jump_target_cannot_cross_function_boundary: "Jump target cannot cross function boundary.",
|
||||
return_statement_must_be_contained_within_a_function_body: "'return' statement must be contained within a function body.",
|
||||
Expression_expected: "Expression expected.",
|
||||
Type_expected: "Type expected.",
|
||||
Template_literal_cannot_be_used_as_an_element_name: "Template literal cannot be used as an element name.",
|
||||
Computed_property_names_cannot_be_used_here: "Computed property names cannot be used here.",
|
||||
yield_expression_must_be_contained_within_a_generator_declaration: "'yield' expression must be contained within a generator declaration.",
|
||||
Unterminated_regular_expression_literal: "Unterminated regular expression literal.",
|
||||
Unterminated_template_literal: "Unterminated template literal.",
|
||||
await_expression_must_be_contained_within_an_async_declaration: "'await' expression must be contained within an async declaration.",
|
||||
async_arrow_function_parameters_must_be_parenthesized: "'async' arrow function parameters must be parenthesized.",
|
||||
A_generator_declaration_cannot_have_the_async_modifier: "A generator declaration cannot have the 'async' modifier.",
|
||||
async_modifier_cannot_appear_here: "'async' modifier cannot appear here.",
|
||||
comma_expression_cannot_appear_in_a_computed_property_name: "'comma' expression cannot appear in a computed property name.",
|
||||
String_literal_expected: "String literal expected.",
|
||||
Duplicate_identifier_0: "Duplicate identifier '{0}'.",
|
||||
The_name_0_does_not_exist_in_the_current_scope: "The name '{0}' does not exist in the current scope.",
|
||||
The_name_0_does_not_refer_to_a_value: "The name '{0}' does not refer to a value.",
|
||||
super_can_only_be_used_inside_a_class_instance_method: "'super' can only be used inside a class instance method.",
|
||||
The_left_hand_side_of_an_assignment_expression_must_be_a_variable_property_or_indexer: "The left-hand side of an assignment expression must be a variable, property or indexer.",
|
||||
Value_of_type_0_is_not_callable_Did_you_mean_to_include_new: "Value of type '{0}' is not callable. Did you mean to include 'new'?",
|
||||
Value_of_type_0_is_not_callable: "Value of type '{0}' is not callable.",
|
||||
Value_of_type_0_is_not_newable: "Value of type '{0}' is not newable.",
|
||||
An_index_expression_argument_must_be_string_number_or_any: "An index expression argument must be 'string', 'number', or 'any'.",
|
||||
Operator_0_cannot_be_applied_to_types_1_and_2: "Operator '{0}' cannot be applied to types '{1}' and '{2}'.",
|
||||
Type_0_is_not_assignable_to_type_1: "Type '{0}' is not assignable to type '{1}'.",
|
||||
Type_0_is_not_assignable_to_type_1_NL_2: "Type '{0}' is not assignable to type '{1}':{NL}{2}",
|
||||
Expected_var_class_interface_or_module: "Expected var, class, interface, or module.",
|
||||
Getter_0_already_declared: "Getter '{0}' already declared.",
|
||||
Setter_0_already_declared: "Setter '{0}' already declared.",
|
||||
Exported_class_0_extends_private_class_1: "Exported class '{0}' extends private class '{1}'.",
|
||||
Exported_class_0_implements_private_interface_1: "Exported class '{0}' implements private interface '{1}'.",
|
||||
Exported_interface_0_extends_private_interface_1: "Exported interface '{0}' extends private interface '{1}'.",
|
||||
Exported_class_0_extends_class_from_inaccessible_module_1: "Exported class '{0}' extends class from inaccessible module {1}.",
|
||||
Exported_class_0_implements_interface_from_inaccessible_module_1: "Exported class '{0}' implements interface from inaccessible module {1}.",
|
||||
Exported_interface_0_extends_interface_from_inaccessible_module_1: "Exported interface '{0}' extends interface from inaccessible module {1}.",
|
||||
Public_static_property_0_of_exported_class_has_or_is_using_private_type_1: "Public static property '{0}' of exported class has or is using private type '{1}'.",
|
||||
Public_property_0_of_exported_class_has_or_is_using_private_type_1: "Public property '{0}' of exported class has or is using private type '{1}'.",
|
||||
Property_0_of_exported_interface_has_or_is_using_private_type_1: "Property '{0}' of exported interface has or is using private type '{1}'.",
|
||||
Exported_variable_0_has_or_is_using_private_type_1: "Exported variable '{0}' has or is using private type '{1}'.",
|
||||
Public_static_property_0_of_exported_class_is_using_inaccessible_module_1: "Public static property '{0}' of exported class is using inaccessible module {1}.",
|
||||
Public_property_0_of_exported_class_is_using_inaccessible_module_1: "Public property '{0}' of exported class is using inaccessible module {1}.",
|
||||
Property_0_of_exported_interface_is_using_inaccessible_module_1: "Property '{0}' of exported interface is using inaccessible module {1}.",
|
||||
Exported_variable_0_is_using_inaccessible_module_1: "Exported variable '{0}' is using inaccessible module {1}.",
|
||||
Parameter_0_of_constructor_from_exported_class_has_or_is_using_private_type_1: "Parameter '{0}' of constructor from exported class has or is using private type '{1}'.",
|
||||
Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_private_type_1: "Parameter '{0}' of public static property setter from exported class has or is using private type '{1}'.",
|
||||
Parameter_0_of_public_property_setter_from_exported_class_has_or_is_using_private_type_1: "Parameter '{0}' of public property setter from exported class has or is using private type '{1}'.",
|
||||
Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_type_1: "Parameter '{0}' of constructor signature from exported interface has or is using private type '{1}'.",
|
||||
Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_type_1: "Parameter '{0}' of call signature from exported interface has or is using private type '{1}'.",
|
||||
Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_type_1: "Parameter '{0}' of public static method from exported class has or is using private type '{1}'.",
|
||||
Parameter_0_of_public_method_from_exported_class_has_or_is_using_private_type_1: "Parameter '{0}' of public method from exported class has or is using private type '{1}'.",
|
||||
Parameter_0_of_method_from_exported_interface_has_or_is_using_private_type_1: "Parameter '{0}' of method from exported interface has or is using private type '{1}'.",
|
||||
Parameter_0_of_exported_function_has_or_is_using_private_type_1: "Parameter '{0}' of exported function has or is using private type '{1}'.",
|
||||
Parameter_0_of_constructor_from_exported_class_is_using_inaccessible_module_1: "Parameter '{0}' of constructor from exported class is using inaccessible module {1}.",
|
||||
Parameter_0_of_public_static_property_setter_from_exported_class_is_using_inaccessible_module_1: "Parameter '{0}' of public static property setter from exported class is using inaccessible module {1}.",
|
||||
Parameter_0_of_public_property_setter_from_exported_class_is_using_inaccessible_module_1: "Parameter '{0}' of public property setter from exported class is using inaccessible module {1}.",
|
||||
Parameter_0_of_constructor_signature_from_exported_interface_is_using_inaccessible_module_1: "Parameter '{0}' of constructor signature from exported interface is using inaccessible module {1}.",
|
||||
Parameter_0_of_call_signature_from_exported_interface_is_using_inaccessible_module_1: "Parameter '{0}' of call signature from exported interface is using inaccessible module {1}",
|
||||
Parameter_0_of_public_static_method_from_exported_class_is_using_inaccessible_module_1: "Parameter '{0}' of public static method from exported class is using inaccessible module {1}.",
|
||||
Parameter_0_of_public_method_from_exported_class_is_using_inaccessible_module_1: "Parameter '{0}' of public method from exported class is using inaccessible module {1}.",
|
||||
Parameter_0_of_method_from_exported_interface_is_using_inaccessible_module_1: "Parameter '{0}' of method from exported interface is using inaccessible module {1}.",
|
||||
Parameter_0_of_exported_function_is_using_inaccessible_module_1: "Parameter '{0}' of exported function is using inaccessible module {1}.",
|
||||
Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_private_type_0: "Return type of public static property getter from exported class has or is using private type '{0}'.",
|
||||
Return_type_of_public_property_getter_from_exported_class_has_or_is_using_private_type_0: "Return type of public property getter from exported class has or is using private type '{0}'.",
|
||||
Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_private_type_0: "Return type of constructor signature from exported interface has or is using private type '{0}'.",
|
||||
Return_type_of_call_signature_from_exported_interface_has_or_is_using_private_type_0: "Return type of call signature from exported interface has or is using private type '{0}'.",
|
||||
Return_type_of_index_signature_from_exported_interface_has_or_is_using_private_type_0: "Return type of index signature from exported interface has or is using private type '{0}'.",
|
||||
Return_type_of_public_static_method_from_exported_class_has_or_is_using_private_type_0: "Return type of public static method from exported class has or is using private type '{0}'.",
|
||||
Return_type_of_public_method_from_exported_class_has_or_is_using_private_type_0: "Return type of public method from exported class has or is using private type '{0}'.",
|
||||
Return_type_of_method_from_exported_interface_has_or_is_using_private_type_0: "Return type of method from exported interface has or is using private type '{0}'.",
|
||||
Return_type_of_exported_function_has_or_is_using_private_type_0: "Return type of exported function has or is using private type '{0}'.",
|
||||
Return_type_of_public_static_property_getter_from_exported_class_is_using_inaccessible_module_0: "Return type of public static property getter from exported class is using inaccessible module {0}.",
|
||||
Return_type_of_public_property_getter_from_exported_class_is_using_inaccessible_module_0: "Return type of public property getter from exported class is using inaccessible module {0}.",
|
||||
Return_type_of_constructor_signature_from_exported_interface_is_using_inaccessible_module_0: "Return type of constructor signature from exported interface is using inaccessible module {0}.",
|
||||
Return_type_of_call_signature_from_exported_interface_is_using_inaccessible_module_0: "Return type of call signature from exported interface is using inaccessible module {0}.",
|
||||
Return_type_of_index_signature_from_exported_interface_is_using_inaccessible_module_0: "Return type of index signature from exported interface is using inaccessible module {0}.",
|
||||
Return_type_of_public_static_method_from_exported_class_is_using_inaccessible_module_0: "Return type of public static method from exported class is using inaccessible module {0}.",
|
||||
Return_type_of_public_method_from_exported_class_is_using_inaccessible_module_0: "Return type of public method from exported class is using inaccessible module {0}.",
|
||||
Return_type_of_method_from_exported_interface_is_using_inaccessible_module_0: "Return type of method from exported interface is using inaccessible module {0}.",
|
||||
Return_type_of_exported_function_is_using_inaccessible_module_0: "Return type of exported function is using inaccessible module {0}.",
|
||||
new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead: "'new T[]' cannot be used to create an array. Use 'new Array<T>()' instead.",
|
||||
A_parameter_list_must_follow_a_generic_type_argument_list_expected: "A parameter list must follow a generic type argument list. '(' expected.",
|
||||
Multiple_constructor_implementations_are_not_allowed: "Multiple constructor implementations are not allowed.",
|
||||
Cannot_find_external_module_0: "Cannot find external module '{0}'.",
|
||||
Module_cannot_be_aliased_to_a_non_module_type: "Module cannot be aliased to a non-module type.",
|
||||
A_class_may_only_extend_another_class: "A class may only extend another class.",
|
||||
A_class_may_only_implement_another_class_or_interface: "A class may only implement another class or interface.",
|
||||
An_interface_may_only_extend_a_class_or_another_interface: "An interface may only extend a class or another interface.",
|
||||
Unable_to_resolve_type: "Unable to resolve type.",
|
||||
Unable_to_resolve_type_of_0: "Unable to resolve type of '{0}'.",
|
||||
Unable_to_resolve_type_parameter_constraint: "Unable to resolve type parameter constraint.",
|
||||
Type_parameter_constraint_cannot_be_a_primitive_type: "Type parameter constraint cannot be a primitive type.",
|
||||
Supplied_parameters_do_not_match_any_signature_of_call_target: "Supplied parameters do not match any signature of call target.",
|
||||
Supplied_parameters_do_not_match_any_signature_of_call_target_NL_0: "Supplied parameters do not match any signature of call target:{NL}{0}",
|
||||
Cannot_use_new_with_an_expression_whose_type_lacks_a_signature: "Cannot use 'new' with an expression whose type lacks a signature.",
|
||||
Only_a_void_function_can_be_called_with_the_new_keyword: "Only a void function can be called with the 'new' keyword.",
|
||||
Could_not_select_overload_for_new_expression: "Could not select overload for 'new' expression.",
|
||||
Type_0_does_not_satisfy_the_constraint_1: "Type '{0}' does not satisfy the constraint '{1}'.",
|
||||
Could_not_select_overload_for_call_expression: "Could not select overload for 'call' expression.",
|
||||
Cannot_invoke_an_expression_whose_type_lacks_a_call_signature: "Cannot invoke an expression whose type lacks a call signature.",
|
||||
Calls_to_super_are_only_valid_inside_a_class: "Calls to 'super' are only valid inside a class.",
|
||||
Generic_type_0_requires_1_type_argument_s: "Generic type '{0}' requires {1} type argument(s).",
|
||||
Type_of_array_literal_cannot_be_determined_Best_common_type_could_not_be_found_for_array_elements: "Type of array literal cannot be determined. Best common type could not be found for array elements.",
|
||||
Could_not_find_enclosing_symbol_for_dotted_name_0: "Could not find enclosing symbol for dotted name '{0}'.",
|
||||
Property_0_does_not_exist_on_value_of_type_1: "Property '{0}' does not exist on value of type '{1}'.",
|
||||
Cannot_find_name_0: "Cannot find name '{0}'.",
|
||||
get_and_set_accessor_must_have_the_same_type: "'get' and 'set' accessor must have the same type.",
|
||||
this_cannot_be_referenced_in_current_location: "'this' cannot be referenced in current location.",
|
||||
Static_members_cannot_reference_class_type_parameters: "Static members cannot reference class type parameters.",
|
||||
Type_0_recursively_references_itself_as_a_base_type: "Type '{0}' recursively references itself as a base type.",
|
||||
super_property_access_is_permitted_only_in_a_constructor_member_function_or_member_accessor_of_a_derived_class: "'super' property access is permitted only in a constructor, member function, or member accessor of a derived class.",
|
||||
super_can_only_be_referenced_in_a_derived_class: "'super' can only be referenced in a derived class.",
|
||||
A_super_call_must_be_the_first_statement_in_the_constructor_when_a_class_contains_initialized_properties_or_has_parameter_properties: "A 'super' call must be the first statement in the constructor when a class contains initialized properties or has parameter properties.",
|
||||
Constructors_for_derived_classes_must_contain_a_super_call: "Constructors for derived classes must contain a 'super' call.",
|
||||
Super_calls_are_not_permitted_outside_constructors_or_in_nested_functions_inside_constructors: "Super calls are not permitted outside constructors or in nested functions inside constructors.",
|
||||
_0_1_is_inaccessible: "'{0}.{1}' is inaccessible.",
|
||||
this_cannot_be_referenced_in_a_module_body: "'this' cannot be referenced in a module body.",
|
||||
Invalid_expression_types_not_known_to_support_the_addition_operator: "Invalid '+' expression - types not known to support the addition operator.",
|
||||
The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type: "The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.",
|
||||
The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type: "The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.",
|
||||
An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type: "An arithmetic operand must be of type 'any', 'number' or an enum type.",
|
||||
Variable_declarations_of_a_for_statement_cannot_use_a_type_annotation: "Variable declarations of a 'for' statement cannot use a type annotation.",
|
||||
Variable_declarations_of_a_for_statement_must_be_of_types_string_or_any: "Variable declarations of a 'for' statement must be of types 'string' or 'any'.",
|
||||
The_right_hand_side_of_a_for_in_statement_must_be_of_type_any_an_object_type_or_a_type_parameter: "The right-hand side of a 'for...in' statement must be of type 'any', an object type or a type parameter.",
|
||||
The_left_hand_side_of_an_in_expression_must_be_of_types_any_string_or_number: "The left-hand side of an 'in' expression must be of types 'any', 'string' or 'number'.",
|
||||
The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter: "The right-hand side of an 'in' expression must be of type 'any', an object type or a type parameter.",
|
||||
The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter: "The left-hand side of an 'instanceof' expression must be of type 'any', an object type or a type parameter.",
|
||||
The_right_hand_side_of_an_instanceof_expression_must_be_of_type_any_or_of_a_type_assignable_to_the_Function_interface_type: "The right-hand side of an 'instanceof' expression must be of type 'any' or of a type assignable to the 'Function' interface type.",
|
||||
Setters_cannot_return_a_value: "Setters cannot return a value.",
|
||||
Tried_to_query_type_of_uninitialized_module_0: "Tried to query type of uninitialized module '{0}'.",
|
||||
Tried_to_set_variable_type_to_uninitialized_module_type_0: "Tried to set variable type to uninitialized module type '{0}'.",
|
||||
Type_0_is_not_generic: "Type '{0}' is not generic.",
|
||||
Getters_must_return_a_value: "Getters must return a value.",
|
||||
Getter_and_setter_accessors_do_not_agree_in_visibility: "Getter and setter accessors do not agree in visibility.",
|
||||
Invalid_left_hand_side_of_assignment_expression: "Invalid left-hand side of assignment expression.",
|
||||
Function_declared_a_non_void_return_type_but_has_no_return_expression: "Function declared a non-void return type, but has no return expression.",
|
||||
Cannot_resolve_return_type_reference: "Cannot resolve return type reference.",
|
||||
Constructors_cannot_have_a_return_type_of_void: "Constructors cannot have a return type of 'void'.",
|
||||
Subsequent_variable_declarations_must_have_the_same_type_Variable_0_must_be_of_type_1_but_here_has_type_2: "Subsequent variable declarations must have the same type. Variable '{0}' must be of type '{1}', but here has type '{2}'.",
|
||||
All_symbols_within_a_with_block_will_be_resolved_to_any: "All symbols within a with block will be resolved to 'any'.",
|
||||
Import_declarations_in_an_internal_module_cannot_reference_an_external_module: "Import declarations in an internal module cannot reference an external module.",
|
||||
Class_0_declares_interface_1_but_does_not_implement_it_NL_2: "Class {0} declares interface {1} but does not implement it:{NL}{2}",
|
||||
Class_0_declares_class_1_as_an_interface_but_does_not_implement_it_NL_2: "Class {0} declares class {1} as an interface but does not implement it:{NL}{2}",
|
||||
The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_property_or_indexer: "The operand of an increment or decrement operator must be a variable, property or indexer.",
|
||||
this_cannot_be_referenced_in_a_static_property_initializer: "'this' cannot be referenced in a static property initializer.",
|
||||
Class_0_cannot_extend_class_1_NL_2: "Class '{0}' cannot extend class '{1}':{NL}{2}",
|
||||
Interface_0_cannot_extend_class_1_NL_2: "Interface '{0}' cannot extend class '{1}':{NL}{2}",
|
||||
Interface_0_cannot_extend_interface_1_NL_2: "Interface '{0}' cannot extend interface '{1}':{NL}{2}",
|
||||
Overload_signature_is_not_compatible_with_function_definition: "Overload signature is not compatible with function definition.",
|
||||
Overload_signature_is_not_compatible_with_function_definition_NL_0: "Overload signature is not compatible with function definition:{NL}{0}",
|
||||
Overload_signatures_must_all_be_public_or_private: "Overload signatures must all be public or private.",
|
||||
Overload_signatures_must_all_be_exported_or_not_exported: "Overload signatures must all be exported or not exported.",
|
||||
Overload_signatures_must_all_be_ambient_or_non_ambient: "Overload signatures must all be ambient or non-ambient.",
|
||||
Overload_signatures_must_all_be_optional_or_required: "Overload signatures must all be optional or required.",
|
||||
Specialized_overload_signature_is_not_assignable_to_any_non_specialized_signature: "Specialized overload signature is not assignable to any non-specialized signature.",
|
||||
this_cannot_be_referenced_in_constructor_arguments: "'this' cannot be referenced in constructor arguments.",
|
||||
Instance_member_cannot_be_accessed_off_a_class: "Instance member cannot be accessed off a class.",
|
||||
Untyped_function_calls_may_not_accept_type_arguments: "Untyped function calls may not accept type arguments.",
|
||||
Non_generic_functions_may_not_accept_type_arguments: "Non-generic functions may not accept type arguments.",
|
||||
A_generic_type_may_not_reference_itself_with_a_wrapped_form_of_its_own_type_parameters: "A generic type may not reference itself with a wrapped form of its own type parameters.",
|
||||
A_rest_parameter_must_be_of_an_array_type: "A rest parameter must be of an array type.",
|
||||
Overload_signature_implementation_cannot_use_specialized_type: "Overload signature implementation cannot use specialized type.",
|
||||
Export_assignments_may_only_be_used_at_the_top_level_of_external_modules: "Export assignments may only be used at the top-level of external modules.",
|
||||
Export_assignments_may_only_be_made_with_variables_functions_classes_interfaces_enums_and_internal_modules: "Export assignments may only be made with variables, functions, classes, interfaces, enums and internal modules.",
|
||||
Only_public_methods_of_the_base_class_are_accessible_via_the_super_keyword: "Only public methods of the base class are accessible via the 'super' keyword.",
|
||||
Numeric_indexer_type_0_must_be_assignable_to_string_indexer_type_1: "Numeric indexer type '{0}' must be assignable to string indexer type '{1}'.",
|
||||
Numeric_indexer_type_0_must_be_assignable_to_string_indexer_type_1_NL_2: "Numeric indexer type '{0}' must be assignable to string indexer type '{1}':{NL}{2}",
|
||||
All_numerically_named_properties_must_be_assignable_to_numeric_indexer_type_0: "All numerically named properties must be assignable to numeric indexer type '{0}'.",
|
||||
All_numerically_named_properties_must_be_assignable_to_numeric_indexer_type_0_NL_1: "All numerically named properties must be assignable to numeric indexer type '{0}':{NL}{1}",
|
||||
All_named_properties_must_be_assignable_to_string_indexer_type_0: "All named properties must be assignable to string indexer type '{0}'.",
|
||||
All_named_properties_must_be_assignable_to_string_indexer_type_0_NL_1: "All named properties must be assignable to string indexer type '{0}':{NL}{1}",
|
||||
A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation: "A parameter initializer is only allowed in a function or constructor implementation.",
|
||||
Function_expression_declared_a_non_void_return_type_but_has_no_return_expression: "Function expression declared a non-void return type, but has no return expression.",
|
||||
Import_declaration_referencing_identifier_from_internal_module_can_only_be_made_with_variables_functions_classes_interfaces_enums_and_internal_modules: "Import declaration referencing identifier from internal module can only be made with variables, functions, classes, interfaces, enums and internal modules.",
|
||||
Module_0_has_no_exported_member_1: "Module '{0}' has no exported member '{1}'.",
|
||||
Unable_to_resolve_module_reference_0: "Unable to resolve module reference '{0}'.",
|
||||
Could_not_find_module_0_in_module_1: "Could not find module '{0}' in module '{1}'.",
|
||||
Exported_import_declaration_0_is_assigned_value_with_type_that_has_or_is_using_private_type_1: "Exported import declaration '{0}' is assigned value with type that has or is using private type '{1}'.",
|
||||
Exported_import_declaration_0_is_assigned_value_with_type_that_is_using_inaccessible_module_1: "Exported import declaration '{0}' is assigned value with type that is using inaccessible module '{1}'.",
|
||||
Exported_import_declaration_0_is_assigned_type_that_has_or_is_using_private_type_1: "Exported import declaration '{0}' is assigned type that has or is using private type '{1}'.",
|
||||
Exported_import_declaration_0_is_assigned_type_that_is_using_inaccessible_module_1: "Exported import declaration '{0}' is assigned type that is using inaccessible module '{1}'.",
|
||||
Exported_import_declaration_0_is_assigned_container_that_is_or_is_using_inaccessible_module_1: "Exported import declaration '{0}' is assigned container that is or is using inaccessible module '{1}'.",
|
||||
Type_name_0_in_extends_clause_does_not_reference_constructor_function_for_1: "Type name '{0}' in extends clause does not reference constructor function for '{1}'.",
|
||||
Internal_module_reference_0_in_import_declaration_does_not_reference_module_instance_for_1: "Internal module reference '{0}' in import declaration does not reference module instance for '{1}'.",
|
||||
Module_0_cannot_merge_with_previous_declaration_of_1_in_a_different_file_2: "Module '{0}' cannot merge with previous declaration of '{1}' in a different file '{2}'.",
|
||||
Interface_0_cannot_simultaneously_extend_types_1_and_2_NL_3: "Interface '{0}' cannot simultaneously extend types '{1}' and '{2}':{NL}{3}",
|
||||
Initializer_of_parameter_0_cannot_reference_identifier_1_declared_after_it: "Initializer of parameter '{0}' cannot reference identifier '{1}' declared after it.",
|
||||
Ambient_external_module_declaration_cannot_be_reopened: "Ambient external module declaration cannot be reopened.",
|
||||
All_declarations_of_merged_declaration_0_must_be_exported_or_not_exported: "All declarations of merged declaration '{0}' must be exported or not exported.",
|
||||
super_cannot_be_referenced_in_constructor_arguments: "'super' cannot be referenced in constructor arguments.",
|
||||
Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class: "Return type of constructor signature must be assignable to the instance type of the class.",
|
||||
Ambient_external_module_declaration_must_be_defined_in_global_context: "Ambient external module declaration must be defined in global context.",
|
||||
Ambient_external_module_declaration_cannot_specify_relative_module_name: "Ambient external module declaration cannot specify relative module name.",
|
||||
Import_declaration_in_an_ambient_external_module_declaration_cannot_reference_external_module_through_relative_external_module_name: "Import declaration in an ambient external module declaration cannot reference external module through relative external module name.",
|
||||
No_best_common_type_exists_among_return_expressions: "No best common type exists among return expressions.",
|
||||
Import_declaration_cannot_refer_to_external_module_reference_when_noResolve_option_is_set: "Import declaration cannot refer to external module reference when --noResolve option is set.",
|
||||
Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference: "Duplicate identifier '_this'. Compiler uses variable declaration '_this' to capture 'this' reference.",
|
||||
Duplicate_identifier_super_Compiler_uses_super_to_capture_base_class_reference: "Duplicate identifier '_super'. Compiler uses '_super' to capture base class reference.",
|
||||
Expression_resolves_to_variable_declaration_this_that_compiler_uses_to_capture_this_reference: "Expression resolves to variable declaration '_this' that compiler uses to capture 'this' reference.",
|
||||
Expression_resolves_to_super_that_compiler_uses_to_capture_base_class_reference: "Expression resolves to '_super' that compiler uses to capture base class reference.",
|
||||
TypeParameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_type_1: "TypeParameter '{0}' of constructor signature from exported interface has or is using private type '{1}'.",
|
||||
TypeParameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_type_1: "TypeParameter '{0}' of call signature from exported interface has or is using private type '{1}'.",
|
||||
TypeParameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_type_1: "TypeParameter '{0}' of public static method from exported class has or is using private type '{1}'.",
|
||||
TypeParameter_0_of_public_method_from_exported_class_has_or_is_using_private_type_1: "TypeParameter '{0}' of public method from exported class has or is using private type '{1}'.",
|
||||
TypeParameter_0_of_method_from_exported_interface_has_or_is_using_private_type_1: "TypeParameter '{0}' of method from exported interface has or is using private type '{1}'.",
|
||||
TypeParameter_0_of_exported_function_has_or_is_using_private_type_1: "TypeParameter '{0}' of exported function has or is using private type '{1}'.",
|
||||
TypeParameter_0_of_constructor_signature_from_exported_interface_is_using_inaccessible_module_1: "TypeParameter '{0}' of constructor signature from exported interface is using inaccessible module {1}.",
|
||||
TypeParameter_0_of_call_signature_from_exported_interface_is_using_inaccessible_module_1: "TypeParameter '{0}' of call signature from exported interface is using inaccessible module {1}",
|
||||
TypeParameter_0_of_public_static_method_from_exported_class_is_using_inaccessible_module_1: "TypeParameter '{0}' of public static method from exported class is using inaccessible module {1}.",
|
||||
TypeParameter_0_of_public_method_from_exported_class_is_using_inaccessible_module_1: "TypeParameter '{0}' of public method from exported class is using inaccessible module {1}.",
|
||||
TypeParameter_0_of_method_from_exported_interface_is_using_inaccessible_module_1: "TypeParameter '{0}' of method from exported interface is using inaccessible module {1}.",
|
||||
TypeParameter_0_of_exported_function_is_using_inaccessible_module_1: "TypeParameter '{0}' of exported function is using inaccessible module {1}.",
|
||||
TypeParameter_0_of_exported_class_has_or_is_using_private_type_1: "TypeParameter '{0}' of exported class has or is using private type '{1}'.",
|
||||
TypeParameter_0_of_exported_interface_has_or_is_using_private_type_1: "TypeParameter '{0}' of exported interface has or is using private type '{1}'.",
|
||||
TypeParameter_0_of_exported_class_is_using_inaccessible_module_1: "TypeParameter '{0}' of exported class is using inaccessible module {1}.",
|
||||
TypeParameter_0_of_exported_interface_is_using_inaccessible_module_1: "TypeParameter '{0}' of exported interface is using inaccessible module {1}.",
|
||||
Duplicate_identifier_i_Compiler_uses_i_to_initialize_rest_parameter: "Duplicate identifier '_i'. Compiler uses '_i' to initialize rest parameter.",
|
||||
Duplicate_identifier_arguments_Compiler_uses_arguments_to_initialize_rest_parameters: "Duplicate identifier 'arguments'. Compiler uses 'arguments' to initialize rest parameters.",
|
||||
No_best_common_type_exists_between_0_and_1: "No best common type exists between '{0}' and '{1}'.",
|
||||
No_best_common_type_exists_between_0_1_and_2: "No best common type exists between '{0}', '{1}', and '{2}'.",
|
||||
Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_an_external_module: "Duplicate identifier '{0}'. Compiler reserves name '{1}' in top level scope of an external module.",
|
||||
Constraint_of_a_type_parameter_cannot_reference_any_type_parameter_from_the_same_type_parameter_list: "Constraint of a type parameter cannot reference any type parameter from the same type parameter list.",
|
||||
Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: "Initializer of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor.",
|
||||
Parameter_0_cannot_be_referenced_in_its_initializer: "Parameter '{0}' cannot be referenced in its initializer.",
|
||||
Duplicate_string_index_signature: "Duplicate string index signature.",
|
||||
Duplicate_number_index_signature: "Duplicate number index signature.",
|
||||
All_declarations_of_an_interface_must_have_identical_type_parameters: "All declarations of an interface must have identical type parameters.",
|
||||
Expression_resolves_to_variable_declaration_i_that_compiler_uses_to_initialize_rest_parameter: "Expression resolves to variable declaration '_i' that compiler uses to initialize rest parameter.",
|
||||
Neither_type_0_nor_type_1_is_assignable_to_the_other: "Neither type '{0}' nor type '{1}' is assignable to the other.",
|
||||
Neither_type_0_nor_type_1_is_assignable_to_the_other_NL_2: "Neither type '{0}' nor type '{1}' is assignable to the other:{NL}{2}",
|
||||
Duplicate_function_implementation: "Duplicate function implementation.",
|
||||
Function_implementation_expected: "Function implementation expected.",
|
||||
Function_overload_name_must_be_0: "Function overload name must be '{0}'.",
|
||||
Constructor_implementation_expected: "Constructor implementation expected.",
|
||||
Class_name_cannot_be_0: "Class name cannot be '{0}'.",
|
||||
Interface_name_cannot_be_0: "Interface name cannot be '{0}'.",
|
||||
Enum_name_cannot_be_0: "Enum name cannot be '{0}'.",
|
||||
A_module_cannot_have_multiple_export_assignments: "A module cannot have multiple export assignments.",
|
||||
Export_assignment_not_allowed_in_module_with_exported_element: "Export assignment not allowed in module with exported element.",
|
||||
A_parameter_property_is_only_allowed_in_a_constructor_implementation: "A parameter property is only allowed in a constructor implementation.",
|
||||
Function_overload_must_be_static: "Function overload must be static.",
|
||||
Function_overload_must_not_be_static: "Function overload must not be static.",
|
||||
Type_0_is_missing_property_1_from_type_2: "Type '{0}' is missing property '{1}' from type '{2}'.",
|
||||
Types_of_property_0_of_types_1_and_2_are_incompatible: "Types of property '{0}' of types '{1}' and '{2}' are incompatible.",
|
||||
Types_of_property_0_of_types_1_and_2_are_incompatible_NL_3: "Types of property '{0}' of types '{1}' and '{2}' are incompatible:{NL}{3}",
|
||||
Property_0_defined_as_private_in_type_1_is_defined_as_public_in_type_2: "Property '{0}' defined as private in type '{1}' is defined as public in type '{2}'.",
|
||||
Property_0_defined_as_public_in_type_1_is_defined_as_private_in_type_2: "Property '{0}' defined as public in type '{1}' is defined as private in type '{2}'.",
|
||||
Types_0_and_1_define_property_2_as_private: "Types '{0}' and '{1}' define property '{2}' as private.",
|
||||
Call_signatures_of_types_0_and_1_are_incompatible: "Call signatures of types '{0}' and '{1}' are incompatible.",
|
||||
Call_signatures_of_types_0_and_1_are_incompatible_NL_2: "Call signatures of types '{0}' and '{1}' are incompatible:{NL}{2}",
|
||||
Type_0_requires_a_call_signature_but_type_1_lacks_one: "Type '{0}' requires a call signature, but type '{1}' lacks one.",
|
||||
Construct_signatures_of_types_0_and_1_are_incompatible: "Construct signatures of types '{0}' and '{1}' are incompatible.",
|
||||
Construct_signatures_of_types_0_and_1_are_incompatible_NL_2: "Construct signatures of types '{0}' and '{1}' are incompatible:{NL}{2}",
|
||||
Type_0_requires_a_construct_signature_but_type_1_lacks_one: "Type '{0}' requires a construct signature, but type '{1}' lacks one.",
|
||||
Index_signatures_of_types_0_and_1_are_incompatible: "Index signatures of types '{0}' and '{1}' are incompatible.",
|
||||
Index_signatures_of_types_0_and_1_are_incompatible_NL_2: "Index signatures of types '{0}' and '{1}' are incompatible:{NL}{2}",
|
||||
Call_signature_expects_0_or_fewer_parameters: "Call signature expects {0} or fewer parameters.",
|
||||
Could_not_apply_type_0_to_argument_1_which_is_of_type_2: "Could not apply type '{0}' to argument {1} which is of type '{2}'.",
|
||||
Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_function: "Class '{0}' defines instance member accessor '{1}', but extended class '{2}' defines it as instance member function.",
|
||||
Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_function: "Class '{0}' defines instance member property '{1}', but extended class '{2}' defines it as instance member function.",
|
||||
Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_accessor: "Class '{0}' defines instance member function '{1}', but extended class '{2}' defines it as instance member accessor.",
|
||||
Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_property: "Class '{0}' defines instance member function '{1}', but extended class '{2}' defines it as instance member property.",
|
||||
Types_of_static_property_0_of_class_1_and_class_2_are_incompatible: "Types of static property '{0}' of class '{1}' and class '{2}' are incompatible.",
|
||||
Types_of_static_property_0_of_class_1_and_class_2_are_incompatible_NL_3: "Types of static property '{0}' of class '{1}' and class '{2}' are incompatible:{NL}{3}",
|
||||
Type_reference_cannot_refer_to_container_0: "Type reference cannot refer to container '{0}'.",
|
||||
Type_reference_must_refer_to_type: "Type reference must refer to type.",
|
||||
In_enums_with_multiple_declarations_only_one_declaration_can_omit_an_initializer_for_the_first_enum_element: "In enums with multiple declarations only one declaration can omit an initializer for the first enum element.",
|
||||
_0_overload_s: " (+ {0} overload(s))",
|
||||
Variable_declaration_cannot_have_the_same_name_as_an_import_declaration: "Variable declaration cannot have the same name as an import declaration.",
|
||||
Signature_expected_0_type_arguments_got_1_instead: "Signature expected {0} type arguments, got {1} instead.",
|
||||
Property_0_defined_as_optional_in_type_1_but_is_required_in_type_2: "Property '{0}' defined as optional in type '{1}', but is required in type '{2}'.",
|
||||
Types_0_and_1_originating_in_infinitely_expanding_type_reference_do_not_refer_to_same_named_type: "Types '{0}' and '{1}' originating in infinitely expanding type reference do not refer to same named type.",
|
||||
Types_0_and_1_originating_in_infinitely_expanding_type_reference_have_incompatible_type_arguments: "Types '{0}' and '{1}' originating in infinitely expanding type reference have incompatible type arguments.",
|
||||
Types_0_and_1_originating_in_infinitely_expanding_type_reference_have_incompatible_type_arguments_NL_2: "Types '{0}' and '{1}' originating in infinitely expanding type reference have incompatible type arguments:{NL}{2}",
|
||||
Named_properties_0_of_types_1_and_2_are_not_identical: "Named properties '{0}' of types '{1}' and '{2}' are not identical.",
|
||||
Types_of_string_indexer_of_types_0_and_1_are_not_identical: "Types of string indexer of types '{0}' and '{1}' are not identical.",
|
||||
Types_of_number_indexer_of_types_0_and_1_are_not_identical: "Types of number indexer of types '{0}' and '{1}' are not identical.",
|
||||
Type_of_number_indexer_in_type_0_is_not_assignable_to_string_indexer_type_in_type_1_NL_2: "Type of number indexer in type '{0}' is not assignable to string indexer type in type '{1}'.{NL}{2}",
|
||||
Type_of_property_0_in_type_1_is_not_assignable_to_string_indexer_type_in_type_2_NL_3: "Type of property '{0}' in type '{1}' is not assignable to string indexer type in type '{2}'.{NL}{3}",
|
||||
Type_of_property_0_in_type_1_is_not_assignable_to_number_indexer_type_in_type_2_NL_3: "Type of property '{0}' in type '{1}' is not assignable to number indexer type in type '{2}'.{NL}{3}",
|
||||
Static_property_0_defined_as_private_in_type_1_is_defined_as_public_in_type_2: "Static property '{0}' defined as private in type '{1}' is defined as public in type '{2}'.",
|
||||
Static_property_0_defined_as_public_in_type_1_is_defined_as_private_in_type_2: "Static property '{0}' defined as public in type '{1}' is defined as private in type '{2}'.",
|
||||
Types_0_and_1_define_static_property_2_as_private: "Types '{0}' and '{1}' define static property '{2}' as private.",
|
||||
Current_host_does_not_support_0_option: "Current host does not support '{0}' option.",
|
||||
ECMAScript_target_version_0_not_supported_Specify_a_valid_target_version_1_default_or_2: "ECMAScript target version '{0}' not supported. Specify a valid target version: '{1}' (default), or '{2}'",
|
||||
Argument_for_0_option_must_be_1_or_2: "Argument for '{0}' option must be '{1}' or '{2}'",
|
||||
Could_not_find_file_0: "Could not find file: '{0}'.",
|
||||
A_file_cannot_have_a_reference_to_itself: "A file cannot have a reference to itself.",
|
||||
Cannot_resolve_referenced_file_0: "Cannot resolve referenced file: '{0}'.",
|
||||
Cannot_find_the_common_subdirectory_path_for_the_input_files: "Cannot find the common subdirectory path for the input files.",
|
||||
Emit_Error_0: "Emit Error: {0}.",
|
||||
Cannot_read_file_0_1: "Cannot read file '{0}': {1}",
|
||||
Unsupported_file_encoding: "Unsupported file encoding.",
|
||||
Locale_must_be_of_the_form_language_or_language_territory_For_example_0_or_1: "Locale must be of the form <language> or <language>-<territory>. For example '{0}' or '{1}'.",
|
||||
Unsupported_locale_0: "Unsupported locale: '{0}'.",
|
||||
Execution_Failed_NL: "Execution Failed.{NL}",
|
||||
Invalid_call_to_up: "Invalid call to 'up'",
|
||||
Invalid_call_to_down: "Invalid call to 'down'",
|
||||
Base64_value_0_finished_with_a_continuation_bit: "Base64 value '{0}' finished with a continuation bit.",
|
||||
Unknown_compiler_option_0: "Unknown compiler option '{0}'",
|
||||
Expected_0_arguments_to_message_got_1_instead: "Expected {0} arguments to message, got {1} instead.",
|
||||
Expected_the_message_0_to_have_1_arguments_but_it_had_2: "Expected the message '{0}' to have {1} arguments, but it had {2}",
|
||||
Could_not_delete_file_0: "Could not delete file '{0}'",
|
||||
Could_not_create_directory_0: "Could not create directory '{0}'",
|
||||
Error_while_executing_file_0: "Error while executing file '{0}': ",
|
||||
Cannot_compile_external_modules_unless_the_module_flag_is_provided: "Cannot compile external modules unless the '--module' flag is provided.",
|
||||
Option_mapRoot_cannot_be_specified_without_specifying_sourcemap_option: "Option mapRoot cannot be specified without specifying sourcemap option.",
|
||||
Option_sourceRoot_cannot_be_specified_without_specifying_sourcemap_option: "Option sourceRoot cannot be specified without specifying sourcemap option.",
|
||||
Options_mapRoot_and_sourceRoot_cannot_be_specified_without_specifying_sourcemap_option: "Options mapRoot and sourceRoot cannot be specified without specifying sourcemap option.",
|
||||
Option_0_specified_without_1: "Option '{0}' specified without '{1}'",
|
||||
codepage_option_not_supported_on_current_platform: "'codepage' option not supported on current platform.",
|
||||
Concatenate_and_emit_output_to_single_file: "Concatenate and emit output to single file.",
|
||||
Specifies_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations: "Specifies the location where debugger should locate map files instead of generated locations.",
|
||||
Specifies_the_location_where_debugger_should_locate_TypeScript_files_instead_of_source_locations: "Specifies the location where debugger should locate TypeScript files instead of source locations.",
|
||||
Watch_input_files: "Watch input files.",
|
||||
Redirect_output_structure_to_the_directory: "Redirect output structure to the directory.",
|
||||
Do_not_emit_comments_to_output: "Do not emit comments to output.",
|
||||
Print_this_message: "Print this message.",
|
||||
Allow_use_of_deprecated_0_keyword_when_referencing_an_external_module: "Allow use of deprecated '{0}' keyword when referencing an external module.",
|
||||
Syntax_0: "Syntax: {0}",
|
||||
options: "options",
|
||||
file1: "file",
|
||||
Examples: "Examples:",
|
||||
Options: "Options:",
|
||||
Insert_command_line_options_and_files_from_a_file: "Insert command line options and files from a file.",
|
||||
Version_0: "Version {0}",
|
||||
Use_the_0_flag_to_see_options: "Use the '{0}' flag to see options.",
|
||||
NL_Recompiling_0: "{NL}Recompiling ({0}):",
|
||||
STRING: "STRING",
|
||||
KIND: "KIND",
|
||||
file2: "FILE",
|
||||
VERSION: "VERSION",
|
||||
LOCATION: "LOCATION",
|
||||
DIRECTORY: "DIRECTORY",
|
||||
NUMBER: "NUMBER",
|
||||
Additional_locations: "Additional locations:",
|
||||
This_version_of_the_Javascript_runtime_does_not_support_the_0_function: "This version of the Javascript runtime does not support the '{0}' function.",
|
||||
Unknown_rule: "Unknown rule.",
|
||||
Invalid_line_number_0: "Invalid line number ({0})",
|
||||
Raise_error_on_expressions_and_declarations_with_an_implied_any_type: "Raise error on expressions and declarations with an implied 'any' type.",
|
||||
Variable_0_implicitly_has_an_any_type: "Variable '{0}' implicitly has an 'any' type.",
|
||||
Parameter_0_of_1_implicitly_has_an_any_type: "Parameter '{0}' of '{1}' implicitly has an 'any' type.",
|
||||
Parameter_0_of_function_type_implicitly_has_an_any_type: "Parameter '{0}' of function type implicitly has an 'any' type.",
|
||||
Member_0_of_object_type_implicitly_has_an_any_type: "Member '{0}' of object type implicitly has an 'any' type.",
|
||||
new_expression_which_lacks_a_constructor_signature_implicitly_has_an_any_type: "'new' expression, which lacks a constructor signature, implicitly has an 'any' type.",
|
||||
_0_which_lacks_return_type_annotation_implicitly_has_an_any_return_type: "'{0}', which lacks return-type annotation, implicitly has an 'any' return type.",
|
||||
Function_expression_which_lacks_return_type_annotation_implicitly_has_an_any_return_type: "Function expression, which lacks return-type annotation, implicitly has an 'any' return type.",
|
||||
Parameter_0_of_lambda_function_implicitly_has_an_any_type: "Parameter '{0}' of lambda function implicitly has an 'any' type.",
|
||||
Constructor_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type: "Constructor signature, which lacks return-type annotation, implicitly has an 'any' return type.",
|
||||
Lambda_Function_which_lacks_return_type_annotation_implicitly_has_an_any_return_type: "Lambda Function, which lacks return-type annotation, implicitly has an 'any' return type.",
|
||||
Array_Literal_implicitly_has_an_any_type_from_widening: "Array Literal implicitly has an 'any' type from widening.",
|
||||
_0_which_lacks_get_accessor_and_parameter_type_annotation_on_set_accessor_implicitly_has_an_any_type: "'{0}', which lacks 'get' accessor and parameter type annotation on 'set' accessor, implicitly has an 'any' type.",
|
||||
Index_signature_of_object_type_implicitly_has_an_any_type: "Index signature of object type implicitly has an 'any' type.",
|
||||
Object_literal_s_property_0_implicitly_has_an_any_type_from_widening: "Object literal's property '{0}' implicitly has an 'any' type from widening.",
|
||||
};
|
||||
}
|
||||
@@ -1,457 +0,0 @@
|
||||
// <auto-generated />
|
||||
/// <reference path="..\core\diagnosticCategory.ts" />
|
||||
module TypeScript {
|
||||
export var diagnosticInformationMap: ts.Map<any> = {
|
||||
"error TS{0}: {1}": { "code": 0, "category": DiagnosticCategory.NoPrefix },
|
||||
"warning TS{0}: {1}": { "code": 1, "category": DiagnosticCategory.NoPrefix },
|
||||
"Unrecognized escape sequence.": { "code": 1000, "category": DiagnosticCategory.Error },
|
||||
"Unexpected character {0}.": { "code": 1001, "category": DiagnosticCategory.Error },
|
||||
"Unterminated string literal.": { "code": 1002, "category": DiagnosticCategory.Error },
|
||||
"Identifier expected.": { "code": 1003, "category": DiagnosticCategory.Error },
|
||||
"'{0}' keyword expected.": { "code": 1004, "category": DiagnosticCategory.Error },
|
||||
"'{0}' expected.": { "code": 1005, "category": DiagnosticCategory.Error },
|
||||
"Identifier expected; '{0}' is a keyword.": { "code": 1006, "category": DiagnosticCategory.Error },
|
||||
"Automatic semicolon insertion not allowed.": { "code": 1007, "category": DiagnosticCategory.Error },
|
||||
"Unexpected token; '{0}' expected.": { "code": 1008, "category": DiagnosticCategory.Error },
|
||||
"Trailing comma not allowed.": { "code": 1009, "category": DiagnosticCategory.Error },
|
||||
"'*/' expected.": { "code": 1010, "category": DiagnosticCategory.Error },
|
||||
"'public' or 'private' modifier must precede 'static'.": { "code": 1011, "category": DiagnosticCategory.Error },
|
||||
"Unexpected token.": { "code": 1012, "category": DiagnosticCategory.Error },
|
||||
"Catch clause parameter cannot have a type annotation.": { "code": 1013, "category": DiagnosticCategory.Error },
|
||||
"A rest parameter must be last in a parameter list.": { "code": 1014, "category": DiagnosticCategory.Error },
|
||||
"Parameter cannot have question mark and initializer.": { "code": 1015, "category": DiagnosticCategory.Error },
|
||||
"A required parameter cannot follow an optional parameter.": { "code": 1016, "category": DiagnosticCategory.Error },
|
||||
"Index signatures cannot have rest parameters.": { "code": 1017, "category": DiagnosticCategory.Error },
|
||||
"Index signature parameter cannot have modifiers.": { "code": 1018, "category": DiagnosticCategory.Error },
|
||||
"Index signature parameter cannot have a question mark.": { "code": 1019, "category": DiagnosticCategory.Error },
|
||||
"Index signature parameter cannot have an initializer.": { "code": 1020, "category": DiagnosticCategory.Error },
|
||||
"Index signature must have a type annotation.": { "code": 1021, "category": DiagnosticCategory.Error },
|
||||
"Index signature parameter must have a type annotation.": { "code": 1022, "category": DiagnosticCategory.Error },
|
||||
"Index signature parameter type must be 'string' or 'number'.": { "code": 1023, "category": DiagnosticCategory.Error },
|
||||
"'extends' clause already seen.": { "code": 1024, "category": DiagnosticCategory.Error },
|
||||
"'extends' clause must precede 'implements' clause.": { "code": 1025, "category": DiagnosticCategory.Error },
|
||||
"Classes can only extend a single class.": { "code": 1026, "category": DiagnosticCategory.Error },
|
||||
"'implements' clause already seen.": { "code": 1027, "category": DiagnosticCategory.Error },
|
||||
"Accessibility modifier already seen.": { "code": 1028, "category": DiagnosticCategory.Error },
|
||||
"'{0}' modifier must precede '{1}' modifier.": { "code": 1029, "category": DiagnosticCategory.Error },
|
||||
"'{0}' modifier already seen.": { "code": 1030, "category": DiagnosticCategory.Error },
|
||||
"'{0}' modifier cannot appear on a class element.": { "code": 1031, "category": DiagnosticCategory.Error },
|
||||
"Interface declaration cannot have 'implements' clause.": { "code": 1032, "category": DiagnosticCategory.Error },
|
||||
"'super' invocation cannot have type arguments.": { "code": 1034, "category": DiagnosticCategory.Error },
|
||||
"Only ambient modules can use quoted names.": { "code": 1035, "category": DiagnosticCategory.Error },
|
||||
"Statements are not allowed in ambient contexts.": { "code": 1036, "category": DiagnosticCategory.Error },
|
||||
"A function implementation cannot be declared in an ambient context.": { "code": 1037, "category": DiagnosticCategory.Error },
|
||||
"A 'declare' modifier cannot be used in an already ambient context.": { "code": 1038, "category": DiagnosticCategory.Error },
|
||||
"Initializers are not allowed in ambient contexts.": { "code": 1039, "category": DiagnosticCategory.Error },
|
||||
"'{0}' modifier cannot appear on a module element.": { "code": 1044, "category": DiagnosticCategory.Error },
|
||||
"A 'declare' modifier cannot be used with an interface declaration.": { "code": 1045, "category": DiagnosticCategory.Error },
|
||||
"A 'declare' modifier is required for a top level declaration in a .d.ts file.": { "code": 1046, "category": DiagnosticCategory.Error },
|
||||
"A rest parameter cannot be optional.": { "code": 1047, "category": DiagnosticCategory.Error },
|
||||
"A rest parameter cannot have an initializer.": { "code": 1048, "category": DiagnosticCategory.Error },
|
||||
"'set' accessor must have exactly one parameter.": { "code": 1049, "category": DiagnosticCategory.Error },
|
||||
"'set' accessor parameter cannot be optional.": { "code": 1051, "category": DiagnosticCategory.Error },
|
||||
"'set' accessor parameter cannot have an initializer.": { "code": 1052, "category": DiagnosticCategory.Error },
|
||||
"'set' accessor cannot have rest parameter.": { "code": 1053, "category": DiagnosticCategory.Error },
|
||||
"'get' accessor cannot have parameters.": { "code": 1054, "category": DiagnosticCategory.Error },
|
||||
"Modifiers cannot appear here.": { "code": 1055, "category": DiagnosticCategory.Error },
|
||||
"Accessors are only available when targeting ECMAScript 5 and higher.": { "code": 1056, "category": DiagnosticCategory.Error },
|
||||
"Enum member must have initializer.": { "code": 1061, "category": DiagnosticCategory.Error },
|
||||
"Export assignment cannot be used in internal modules.": { "code": 1063, "category": DiagnosticCategory.Error },
|
||||
"Ambient enum elements can only have integer literal initializers.": { "code": 1066, "category": DiagnosticCategory.Error },
|
||||
"module, class, interface, enum, import or statement": { "code": 1067, "category": DiagnosticCategory.NoPrefix },
|
||||
"constructor, function, accessor or variable": { "code": 1068, "category": DiagnosticCategory.NoPrefix },
|
||||
"statement": { "code": 1069, "category": DiagnosticCategory.NoPrefix },
|
||||
"case or default clause": { "code": 1070, "category": DiagnosticCategory.NoPrefix },
|
||||
"identifier": { "code": 1071, "category": DiagnosticCategory.NoPrefix },
|
||||
"call, construct, index, property or function signature": { "code": 1072, "category": DiagnosticCategory.NoPrefix },
|
||||
"expression": { "code": 1073, "category": DiagnosticCategory.NoPrefix },
|
||||
"type name": { "code": 1074, "category": DiagnosticCategory.NoPrefix },
|
||||
"property or accessor": { "code": 1075, "category": DiagnosticCategory.NoPrefix },
|
||||
"parameter": { "code": 1076, "category": DiagnosticCategory.NoPrefix },
|
||||
"type": { "code": 1077, "category": DiagnosticCategory.NoPrefix },
|
||||
"type parameter": { "code": 1078, "category": DiagnosticCategory.NoPrefix },
|
||||
"A 'declare' modifier cannot be used with an import declaration.": { "code": 1079, "category": DiagnosticCategory.Error },
|
||||
"Invalid 'reference' directive syntax.": { "code": 1084, "category": DiagnosticCategory.Error },
|
||||
"Octal literals are not available when targeting ECMAScript 5 and higher.": { "code": 1085, "category": DiagnosticCategory.Error },
|
||||
"Accessors are not allowed in ambient contexts.": { "code": 1086, "category": DiagnosticCategory.Error },
|
||||
"'{0}' modifier cannot appear on a constructor declaration.": { "code": 1089, "category": DiagnosticCategory.Error },
|
||||
"'{0}' modifier cannot appear on a parameter.": { "code": 1090, "category": DiagnosticCategory.Error },
|
||||
"Only a single variable declaration is allowed in a 'for...in' statement.": { "code": 1091, "category": DiagnosticCategory.Error },
|
||||
"Type parameters cannot appear on a constructor declaration.": { "code": 1092, "category": DiagnosticCategory.Error },
|
||||
"Type annotation cannot appear on a constructor declaration.": { "code": 1093, "category": DiagnosticCategory.Error },
|
||||
"Type parameters cannot appear on an accessor.": { "code": 1094, "category": DiagnosticCategory.Error },
|
||||
"Type annotation cannot appear on a 'set' accessor.": { "code": 1095, "category": DiagnosticCategory.Error },
|
||||
"Index signature must have exactly one parameter.": { "code": 1096, "category": DiagnosticCategory.Error },
|
||||
"'{0}' list cannot be empty.": { "code": 1097, "category": DiagnosticCategory.Error },
|
||||
"variable declaration": { "code": 1098, "category": DiagnosticCategory.NoPrefix },
|
||||
"type argument": { "code": 1099, "category": DiagnosticCategory.NoPrefix },
|
||||
"Invalid use of '{0}' in strict mode.": { "code": 1100, "category": DiagnosticCategory.Error },
|
||||
"'with' statements are not allowed in strict mode.": { "code": 1101, "category": DiagnosticCategory.Error },
|
||||
"'delete' cannot be called on an identifier in strict mode.": { "code": 1102, "category": DiagnosticCategory.Error },
|
||||
"Invalid left-hand side in 'for...in' statement.": { "code": 1103, "category": DiagnosticCategory.Error },
|
||||
"'continue' statement can only be used within an enclosing iteration statement.": { "code": 1104, "category": DiagnosticCategory.Error },
|
||||
"'break' statement can only be used within an enclosing iteration or switch statement.": { "code": 1105, "category": DiagnosticCategory.Error },
|
||||
"Jump target not found.": { "code": 1106, "category": DiagnosticCategory.Error },
|
||||
"Jump target cannot cross function boundary.": { "code": 1107, "category": DiagnosticCategory.Error },
|
||||
"'return' statement must be contained within a function body.": { "code": 1108, "category": DiagnosticCategory.Error },
|
||||
"Expression expected.": { "code": 1109, "category": DiagnosticCategory.Error },
|
||||
"Type expected.": { "code": 1110, "category": DiagnosticCategory.Error },
|
||||
"Template literal cannot be used as an element name.": { "code": 1111, "category": DiagnosticCategory.Error },
|
||||
"Computed property names cannot be used here.": { "code": 1112, "category": DiagnosticCategory.Error },
|
||||
"'yield' expression must be contained within a generator declaration.": { "code": 1113, "category": DiagnosticCategory.Error },
|
||||
"Unterminated regular expression literal.": { "code": 1114, "category": DiagnosticCategory.Error },
|
||||
"Unterminated template literal.": { "code": 1115, "category": DiagnosticCategory.Error },
|
||||
"'await' expression must be contained within an 'async' declaration.": { "code": 1116, "category": DiagnosticCategory.Error },
|
||||
"'async' arrow function parameters must be parenthesized.": { "code": 1117, "category": DiagnosticCategory.Error },
|
||||
"A generator declaration cannot have the 'async' modifier.": { "code": 1118, "category": DiagnosticCategory.Error },
|
||||
"'async' modifier cannot appear here.": { "code": 1119, "category": DiagnosticCategory.Error },
|
||||
"'comma' expression cannot appear in a computed property name.": { "code": 1120, "category": DiagnosticCategory.Error },
|
||||
"String literal expected.": { "code": 1121, "category": DiagnosticCategory.Error },
|
||||
"Duplicate identifier '{0}'.": { "code": 2000, "category": DiagnosticCategory.Error },
|
||||
"The name '{0}' does not exist in the current scope.": { "code": 2001, "category": DiagnosticCategory.Error },
|
||||
"The name '{0}' does not refer to a value.": { "code": 2002, "category": DiagnosticCategory.Error },
|
||||
"'super' can only be used inside a class instance method.": { "code": 2003, "category": DiagnosticCategory.Error },
|
||||
"The left-hand side of an assignment expression must be a variable, property or indexer.": { "code": 2004, "category": DiagnosticCategory.Error },
|
||||
"Value of type '{0}' is not callable. Did you mean to include 'new'?": { "code": 2161, "category": DiagnosticCategory.Error },
|
||||
"Value of type '{0}' is not callable.": { "code": 2006, "category": DiagnosticCategory.Error },
|
||||
"Value of type '{0}' is not newable.": { "code": 2007, "category": DiagnosticCategory.Error },
|
||||
"An index expression argument must be 'string', 'number', or 'any'.": { "code": 2008, "category": DiagnosticCategory.Error },
|
||||
"Operator '{0}' cannot be applied to types '{1}' and '{2}'.": { "code": 2009, "category": DiagnosticCategory.Error },
|
||||
"Type '{0}' is not assignable to type '{1}'.": { "code": 2011, "category": DiagnosticCategory.Error },
|
||||
"Type '{0}' is not assignable to type '{1}':{NL}{2}": { "code": 2012, "category": DiagnosticCategory.Error },
|
||||
"Expected var, class, interface, or module.": { "code": 2013, "category": DiagnosticCategory.Error },
|
||||
"Getter '{0}' already declared.": { "code": 2015, "category": DiagnosticCategory.Error },
|
||||
"Setter '{0}' already declared.": { "code": 2016, "category": DiagnosticCategory.Error },
|
||||
"Exported class '{0}' extends private class '{1}'.": { "code": 2018, "category": DiagnosticCategory.Error },
|
||||
"Exported class '{0}' implements private interface '{1}'.": { "code": 2019, "category": DiagnosticCategory.Error },
|
||||
"Exported interface '{0}' extends private interface '{1}'.": { "code": 2020, "category": DiagnosticCategory.Error },
|
||||
"Exported class '{0}' extends class from inaccessible module {1}.": { "code": 2021, "category": DiagnosticCategory.Error },
|
||||
"Exported class '{0}' implements interface from inaccessible module {1}.": { "code": 2022, "category": DiagnosticCategory.Error },
|
||||
"Exported interface '{0}' extends interface from inaccessible module {1}.": { "code": 2023, "category": DiagnosticCategory.Error },
|
||||
"Public static property '{0}' of exported class has or is using private type '{1}'.": { "code": 2024, "category": DiagnosticCategory.Error },
|
||||
"Public property '{0}' of exported class has or is using private type '{1}'.": { "code": 2025, "category": DiagnosticCategory.Error },
|
||||
"Property '{0}' of exported interface has or is using private type '{1}'.": { "code": 2026, "category": DiagnosticCategory.Error },
|
||||
"Exported variable '{0}' has or is using private type '{1}'.": { "code": 2027, "category": DiagnosticCategory.Error },
|
||||
"Public static property '{0}' of exported class is using inaccessible module {1}.": { "code": 2028, "category": DiagnosticCategory.Error },
|
||||
"Public property '{0}' of exported class is using inaccessible module {1}.": { "code": 2029, "category": DiagnosticCategory.Error },
|
||||
"Property '{0}' of exported interface is using inaccessible module {1}.": { "code": 2030, "category": DiagnosticCategory.Error },
|
||||
"Exported variable '{0}' is using inaccessible module {1}.": { "code": 2031, "category": DiagnosticCategory.Error },
|
||||
"Parameter '{0}' of constructor from exported class has or is using private type '{1}'.": { "code": 2032, "category": DiagnosticCategory.Error },
|
||||
"Parameter '{0}' of public static property setter from exported class has or is using private type '{1}'.": { "code": 2033, "category": DiagnosticCategory.Error },
|
||||
"Parameter '{0}' of public property setter from exported class has or is using private type '{1}'.": { "code": 2034, "category": DiagnosticCategory.Error },
|
||||
"Parameter '{0}' of constructor signature from exported interface has or is using private type '{1}'.": { "code": 2035, "category": DiagnosticCategory.Error },
|
||||
"Parameter '{0}' of call signature from exported interface has or is using private type '{1}'.": { "code": 2036, "category": DiagnosticCategory.Error },
|
||||
"Parameter '{0}' of public static method from exported class has or is using private type '{1}'.": { "code": 2037, "category": DiagnosticCategory.Error },
|
||||
"Parameter '{0}' of public method from exported class has or is using private type '{1}'.": { "code": 2038, "category": DiagnosticCategory.Error },
|
||||
"Parameter '{0}' of method from exported interface has or is using private type '{1}'.": { "code": 2039, "category": DiagnosticCategory.Error },
|
||||
"Parameter '{0}' of exported function has or is using private type '{1}'.": { "code": 2040, "category": DiagnosticCategory.Error },
|
||||
"Parameter '{0}' of constructor from exported class is using inaccessible module {1}.": { "code": 2041, "category": DiagnosticCategory.Error },
|
||||
"Parameter '{0}' of public static property setter from exported class is using inaccessible module {1}.": { "code": 2042, "category": DiagnosticCategory.Error },
|
||||
"Parameter '{0}' of public property setter from exported class is using inaccessible module {1}.": { "code": 2043, "category": DiagnosticCategory.Error },
|
||||
"Parameter '{0}' of constructor signature from exported interface is using inaccessible module {1}.": { "code": 2044, "category": DiagnosticCategory.Error },
|
||||
"Parameter '{0}' of call signature from exported interface is using inaccessible module {1}": { "code": 2045, "category": DiagnosticCategory.Error },
|
||||
"Parameter '{0}' of public static method from exported class is using inaccessible module {1}.": { "code": 2046, "category": DiagnosticCategory.Error },
|
||||
"Parameter '{0}' of public method from exported class is using inaccessible module {1}.": { "code": 2047, "category": DiagnosticCategory.Error },
|
||||
"Parameter '{0}' of method from exported interface is using inaccessible module {1}.": { "code": 2048, "category": DiagnosticCategory.Error },
|
||||
"Parameter '{0}' of exported function is using inaccessible module {1}.": { "code": 2049, "category": DiagnosticCategory.Error },
|
||||
"Return type of public static property getter from exported class has or is using private type '{0}'.": { "code": 2050, "category": DiagnosticCategory.Error },
|
||||
"Return type of public property getter from exported class has or is using private type '{0}'.": { "code": 2051, "category": DiagnosticCategory.Error },
|
||||
"Return type of constructor signature from exported interface has or is using private type '{0}'.": { "code": 2052, "category": DiagnosticCategory.Error },
|
||||
"Return type of call signature from exported interface has or is using private type '{0}'.": { "code": 2053, "category": DiagnosticCategory.Error },
|
||||
"Return type of index signature from exported interface has or is using private type '{0}'.": { "code": 2054, "category": DiagnosticCategory.Error },
|
||||
"Return type of public static method from exported class has or is using private type '{0}'.": { "code": 2055, "category": DiagnosticCategory.Error },
|
||||
"Return type of public method from exported class has or is using private type '{0}'.": { "code": 2056, "category": DiagnosticCategory.Error },
|
||||
"Return type of method from exported interface has or is using private type '{0}'.": { "code": 2057, "category": DiagnosticCategory.Error },
|
||||
"Return type of exported function has or is using private type '{0}'.": { "code": 2058, "category": DiagnosticCategory.Error },
|
||||
"Return type of public static property getter from exported class is using inaccessible module {0}.": { "code": 2059, "category": DiagnosticCategory.Error },
|
||||
"Return type of public property getter from exported class is using inaccessible module {0}.": { "code": 2060, "category": DiagnosticCategory.Error },
|
||||
"Return type of constructor signature from exported interface is using inaccessible module {0}.": { "code": 2061, "category": DiagnosticCategory.Error },
|
||||
"Return type of call signature from exported interface is using inaccessible module {0}.": { "code": 2062, "category": DiagnosticCategory.Error },
|
||||
"Return type of index signature from exported interface is using inaccessible module {0}.": { "code": 2063, "category": DiagnosticCategory.Error },
|
||||
"Return type of public static method from exported class is using inaccessible module {0}.": { "code": 2064, "category": DiagnosticCategory.Error },
|
||||
"Return type of public method from exported class is using inaccessible module {0}.": { "code": 2065, "category": DiagnosticCategory.Error },
|
||||
"Return type of method from exported interface is using inaccessible module {0}.": { "code": 2066, "category": DiagnosticCategory.Error },
|
||||
"Return type of exported function is using inaccessible module {0}.": { "code": 2067, "category": DiagnosticCategory.Error },
|
||||
"'new T[]' cannot be used to create an array. Use 'new Array<T>()' instead.": { "code": 2068, "category": DiagnosticCategory.Error },
|
||||
"A parameter list must follow a generic type argument list. '(' expected.": { "code": 2069, "category": DiagnosticCategory.Error },
|
||||
"Multiple constructor implementations are not allowed.": { "code": 2070, "category": DiagnosticCategory.Error },
|
||||
"Cannot find external module '{0}'.": { "code": 2071, "category": DiagnosticCategory.Error },
|
||||
"Module cannot be aliased to a non-module type.": { "code": 2072, "category": DiagnosticCategory.Error },
|
||||
"A class may only extend another class.": { "code": 2073, "category": DiagnosticCategory.Error },
|
||||
"A class may only implement another class or interface.": { "code": 2074, "category": DiagnosticCategory.Error },
|
||||
"An interface may only extend a class or another interface.": { "code": 2075, "category": DiagnosticCategory.Error },
|
||||
"Unable to resolve type.": { "code": 2077, "category": DiagnosticCategory.Error },
|
||||
"Unable to resolve type of '{0}'.": { "code": 2078, "category": DiagnosticCategory.Error },
|
||||
"Unable to resolve type parameter constraint.": { "code": 2079, "category": DiagnosticCategory.Error },
|
||||
"Type parameter constraint cannot be a primitive type.": { "code": 2080, "category": DiagnosticCategory.Error },
|
||||
"Supplied parameters do not match any signature of call target.": { "code": 2081, "category": DiagnosticCategory.Error },
|
||||
"Supplied parameters do not match any signature of call target:{NL}{0}": { "code": 2082, "category": DiagnosticCategory.Error },
|
||||
"Cannot use 'new' with an expression whose type lacks a signature.": { "code": 2083, "category": DiagnosticCategory.Error },
|
||||
"Only a void function can be called with the 'new' keyword.": { "code": 2084, "category": DiagnosticCategory.Error },
|
||||
"Could not select overload for 'new' expression.": { "code": 2085, "category": DiagnosticCategory.Error },
|
||||
"Type '{0}' does not satisfy the constraint '{1}'.": { "code": 2086, "category": DiagnosticCategory.Error },
|
||||
"Could not select overload for 'call' expression.": { "code": 2087, "category": DiagnosticCategory.Error },
|
||||
"Cannot invoke an expression whose type lacks a call signature.": { "code": 2088, "category": DiagnosticCategory.Error },
|
||||
"Calls to 'super' are only valid inside a class.": { "code": 2089, "category": DiagnosticCategory.Error },
|
||||
"Generic type '{0}' requires {1} type argument(s).": { "code": 2090, "category": DiagnosticCategory.Error },
|
||||
"Type of array literal cannot be determined. Best common type could not be found for array elements.": { "code": 2092, "category": DiagnosticCategory.Error },
|
||||
"Could not find enclosing symbol for dotted name '{0}'.": { "code": 2093, "category": DiagnosticCategory.Error },
|
||||
"Property '{0}' does not exist on value of type '{1}'.": { "code": 2094, "category": DiagnosticCategory.Error },
|
||||
"Cannot find name '{0}'.": { "code": 2095, "category": DiagnosticCategory.Error },
|
||||
"'get' and 'set' accessor must have the same type.": { "code": 2096, "category": DiagnosticCategory.Error },
|
||||
"'this' cannot be referenced in current location.": { "code": 2097, "category": DiagnosticCategory.Error },
|
||||
"Static members cannot reference class type parameters.": { "code": 2099, "category": DiagnosticCategory.Error },
|
||||
"Type '{0}' recursively references itself as a base type.": { "code": 2100, "category": DiagnosticCategory.Error },
|
||||
"'super' property access is permitted only in a constructor, member function, or member accessor of a derived class.": { "code": 2102, "category": DiagnosticCategory.Error },
|
||||
"'super' can only be referenced in a derived class.": { "code": 2103, "category": DiagnosticCategory.Error },
|
||||
"A 'super' call must be the first statement in the constructor when a class contains initialized properties or has parameter properties.": { "code": 2104, "category": DiagnosticCategory.Error },
|
||||
"Constructors for derived classes must contain a 'super' call.": { "code": 2105, "category": DiagnosticCategory.Error },
|
||||
"Super calls are not permitted outside constructors or in nested functions inside constructors.": { "code": 2106, "category": DiagnosticCategory.Error },
|
||||
"'{0}.{1}' is inaccessible.": { "code": 2107, "category": DiagnosticCategory.Error },
|
||||
"'this' cannot be referenced in a module body.": { "code": 2108, "category": DiagnosticCategory.Error },
|
||||
"Invalid '+' expression - types not known to support the addition operator.": { "code": 2111, "category": DiagnosticCategory.Error },
|
||||
"The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.": { "code": 2112, "category": DiagnosticCategory.Error },
|
||||
"The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.": { "code": 2113, "category": DiagnosticCategory.Error },
|
||||
"An arithmetic operand must be of type 'any', 'number' or an enum type.": { "code": 2114, "category": DiagnosticCategory.Error },
|
||||
"Variable declarations of a 'for' statement cannot use a type annotation.": { "code": 2115, "category": DiagnosticCategory.Error },
|
||||
"Variable declarations of a 'for' statement must be of types 'string' or 'any'.": { "code": 2116, "category": DiagnosticCategory.Error },
|
||||
"The right-hand side of a 'for...in' statement must be of type 'any', an object type or a type parameter.": { "code": 2117, "category": DiagnosticCategory.Error },
|
||||
"The left-hand side of an 'in' expression must be of types 'any', 'string' or 'number'.": { "code": 2118, "category": DiagnosticCategory.Error },
|
||||
"The right-hand side of an 'in' expression must be of type 'any', an object type or a type parameter.": { "code": 2119, "category": DiagnosticCategory.Error },
|
||||
"The left-hand side of an 'instanceof' expression must be of type 'any', an object type or a type parameter.": { "code": 2120, "category": DiagnosticCategory.Error },
|
||||
"The right-hand side of an 'instanceof' expression must be of type 'any' or of a type assignable to the 'Function' interface type.": { "code": 2121, "category": DiagnosticCategory.Error },
|
||||
"Setters cannot return a value.": { "code": 2122, "category": DiagnosticCategory.Error },
|
||||
"Tried to query type of uninitialized module '{0}'.": { "code": 2123, "category": DiagnosticCategory.Error },
|
||||
"Tried to set variable type to uninitialized module type '{0}'.": { "code": 2124, "category": DiagnosticCategory.Error },
|
||||
"Type '{0}' is not generic.": { "code": 2125, "category": DiagnosticCategory.Error },
|
||||
"Getters must return a value.": { "code": 2126, "category": DiagnosticCategory.Error },
|
||||
"Getter and setter accessors do not agree in visibility.": { "code": 2127, "category": DiagnosticCategory.Error },
|
||||
"Invalid left-hand side of assignment expression.": { "code": 2130, "category": DiagnosticCategory.Error },
|
||||
"Function declared a non-void return type, but has no return expression.": { "code": 2131, "category": DiagnosticCategory.Error },
|
||||
"Cannot resolve return type reference.": { "code": 2132, "category": DiagnosticCategory.Error },
|
||||
"Constructors cannot have a return type of 'void'.": { "code": 2133, "category": DiagnosticCategory.Error },
|
||||
"Subsequent variable declarations must have the same type. Variable '{0}' must be of type '{1}', but here has type '{2}'.": { "code": 2134, "category": DiagnosticCategory.Error },
|
||||
"All symbols within a with block will be resolved to 'any'.": { "code": 2135, "category": DiagnosticCategory.Error },
|
||||
"Import declarations in an internal module cannot reference an external module.": { "code": 2136, "category": DiagnosticCategory.Error },
|
||||
"Class {0} declares interface {1} but does not implement it:{NL}{2}": { "code": 2137, "category": DiagnosticCategory.Error },
|
||||
"Class {0} declares class {1} as an interface but does not implement it:{NL}{2}": { "code": 2138, "category": DiagnosticCategory.Error },
|
||||
"The operand of an increment or decrement operator must be a variable, property or indexer.": { "code": 2139, "category": DiagnosticCategory.Error },
|
||||
"'this' cannot be referenced in a static property initializer.": { "code": 2140, "category": DiagnosticCategory.Error },
|
||||
"Class '{0}' cannot extend class '{1}':{NL}{2}": { "code": 2141, "category": DiagnosticCategory.Error },
|
||||
"Interface '{0}' cannot extend class '{1}':{NL}{2}": { "code": 2142, "category": DiagnosticCategory.Error },
|
||||
"Interface '{0}' cannot extend interface '{1}':{NL}{2}": { "code": 2143, "category": DiagnosticCategory.Error },
|
||||
"Overload signature is not compatible with function definition.": { "code": 2148, "category": DiagnosticCategory.Error },
|
||||
"Overload signature is not compatible with function definition:{NL}{0}": { "code": 2149, "category": DiagnosticCategory.Error },
|
||||
"Overload signatures must all be public or private.": { "code": 2150, "category": DiagnosticCategory.Error },
|
||||
"Overload signatures must all be exported or not exported.": { "code": 2151, "category": DiagnosticCategory.Error },
|
||||
"Overload signatures must all be ambient or non-ambient.": { "code": 2152, "category": DiagnosticCategory.Error },
|
||||
"Overload signatures must all be optional or required.": { "code": 2153, "category": DiagnosticCategory.Error },
|
||||
"Specialized overload signature is not assignable to any non-specialized signature.": { "code": 2154, "category": DiagnosticCategory.Error },
|
||||
"'this' cannot be referenced in constructor arguments.": { "code": 2155, "category": DiagnosticCategory.Error },
|
||||
"Instance member cannot be accessed off a class.": { "code": 2157, "category": DiagnosticCategory.Error },
|
||||
"Untyped function calls may not accept type arguments.": { "code": 2158, "category": DiagnosticCategory.Error },
|
||||
"Non-generic functions may not accept type arguments.": { "code": 2159, "category": DiagnosticCategory.Error },
|
||||
"A generic type may not reference itself with a wrapped form of its own type parameters.": { "code": 2160, "category": DiagnosticCategory.Error },
|
||||
"A rest parameter must be of an array type.": { "code": 2162, "category": DiagnosticCategory.Error },
|
||||
"Overload signature implementation cannot use specialized type.": { "code": 2163, "category": DiagnosticCategory.Error },
|
||||
"Export assignments may only be used at the top-level of external modules.": { "code": 2164, "category": DiagnosticCategory.Error },
|
||||
"Export assignments may only be made with variables, functions, classes, interfaces, enums and internal modules.": { "code": 2165, "category": DiagnosticCategory.Error },
|
||||
"Only public methods of the base class are accessible via the 'super' keyword.": { "code": 2166, "category": DiagnosticCategory.Error },
|
||||
"Numeric indexer type '{0}' must be assignable to string indexer type '{1}'.": { "code": 2167, "category": DiagnosticCategory.Error },
|
||||
"Numeric indexer type '{0}' must be assignable to string indexer type '{1}':{NL}{2}": { "code": 2168, "category": DiagnosticCategory.Error },
|
||||
"All numerically named properties must be assignable to numeric indexer type '{0}'.": { "code": 2169, "category": DiagnosticCategory.Error },
|
||||
"All numerically named properties must be assignable to numeric indexer type '{0}':{NL}{1}": { "code": 2170, "category": DiagnosticCategory.Error },
|
||||
"All named properties must be assignable to string indexer type '{0}'.": { "code": 2171, "category": DiagnosticCategory.Error },
|
||||
"All named properties must be assignable to string indexer type '{0}':{NL}{1}": { "code": 2172, "category": DiagnosticCategory.Error },
|
||||
"A parameter initializer is only allowed in a function or constructor implementation.": { "code": 2174, "category": DiagnosticCategory.Error },
|
||||
"Function expression declared a non-void return type, but has no return expression.": { "code": 2176, "category": DiagnosticCategory.Error },
|
||||
"Import declaration referencing identifier from internal module can only be made with variables, functions, classes, interfaces, enums and internal modules.": { "code": 2177, "category": DiagnosticCategory.Error },
|
||||
"Module '{0}' has no exported member '{1}'.": { "code": 2178, "category": DiagnosticCategory.Error },
|
||||
"Unable to resolve module reference '{0}'.": { "code": 2179, "category": DiagnosticCategory.Error },
|
||||
"Could not find module '{0}' in module '{1}'.": { "code": 2180, "category": DiagnosticCategory.Error },
|
||||
"Exported import declaration '{0}' is assigned value with type that has or is using private type '{1}'.": { "code": 2181, "category": DiagnosticCategory.Error },
|
||||
"Exported import declaration '{0}' is assigned value with type that is using inaccessible module '{1}'.": { "code": 2182, "category": DiagnosticCategory.Error },
|
||||
"Exported import declaration '{0}' is assigned type that has or is using private type '{1}'.": { "code": 2183, "category": DiagnosticCategory.Error },
|
||||
"Exported import declaration '{0}' is assigned type that is using inaccessible module '{1}'.": { "code": 2184, "category": DiagnosticCategory.Error },
|
||||
"Exported import declaration '{0}' is assigned container that is or is using inaccessible module '{1}'.": { "code": 2185, "category": DiagnosticCategory.Error },
|
||||
"Type name '{0}' in extends clause does not reference constructor function for '{1}'.": { "code": 2186, "category": DiagnosticCategory.Error },
|
||||
"Internal module reference '{0}' in import declaration does not reference module instance for '{1}'.": { "code": 2187, "category": DiagnosticCategory.Error },
|
||||
"Module '{0}' cannot merge with previous declaration of '{1}' in a different file '{2}'.": { "code": 2188, "category": DiagnosticCategory.Error },
|
||||
"Interface '{0}' cannot simultaneously extend types '{1}' and '{2}':{NL}{3}": { "code": 2189, "category": DiagnosticCategory.Error },
|
||||
"Initializer of parameter '{0}' cannot reference identifier '{1}' declared after it.": { "code": 2190, "category": DiagnosticCategory.Error },
|
||||
"Ambient external module declaration cannot be reopened.": { "code": 2191, "category": DiagnosticCategory.Error },
|
||||
"All declarations of merged declaration '{0}' must be exported or not exported.": { "code": 2192, "category": DiagnosticCategory.Error },
|
||||
"'super' cannot be referenced in constructor arguments.": { "code": 2193, "category": DiagnosticCategory.Error },
|
||||
"Return type of constructor signature must be assignable to the instance type of the class.": { "code": 2194, "category": DiagnosticCategory.Error },
|
||||
"Ambient external module declaration must be defined in global context.": { "code": 2195, "category": DiagnosticCategory.Error },
|
||||
"Ambient external module declaration cannot specify relative module name.": { "code": 2196, "category": DiagnosticCategory.Error },
|
||||
"Import declaration in an ambient external module declaration cannot reference external module through relative external module name.": { "code": 2197, "category": DiagnosticCategory.Error },
|
||||
"No best common type exists among return expressions.": { "code": 2198, "category": DiagnosticCategory.Error },
|
||||
"Import declaration cannot refer to external module reference when --noResolve option is set.": { "code": 2199, "category": DiagnosticCategory.Error },
|
||||
"Duplicate identifier '_this'. Compiler uses variable declaration '_this' to capture 'this' reference.": { "code": 2200, "category": DiagnosticCategory.Error },
|
||||
"Duplicate identifier '_super'. Compiler uses '_super' to capture base class reference.": { "code": 2205, "category": DiagnosticCategory.Error },
|
||||
"Expression resolves to variable declaration '_this' that compiler uses to capture 'this' reference.": { "code": 2206, "category": DiagnosticCategory.Error },
|
||||
"Expression resolves to '_super' that compiler uses to capture base class reference.": { "code": 2207, "category": DiagnosticCategory.Error },
|
||||
"TypeParameter '{0}' of constructor signature from exported interface has or is using private type '{1}'.": { "code": 2208, "category": DiagnosticCategory.Error },
|
||||
"TypeParameter '{0}' of call signature from exported interface has or is using private type '{1}'.": { "code": 2209, "category": DiagnosticCategory.Error },
|
||||
"TypeParameter '{0}' of public static method from exported class has or is using private type '{1}'.": { "code": 2210, "category": DiagnosticCategory.Error },
|
||||
"TypeParameter '{0}' of public method from exported class has or is using private type '{1}'.": { "code": 2211, "category": DiagnosticCategory.Error },
|
||||
"TypeParameter '{0}' of method from exported interface has or is using private type '{1}'.": { "code": 2212, "category": DiagnosticCategory.Error },
|
||||
"TypeParameter '{0}' of exported function has or is using private type '{1}'.": { "code": 2213, "category": DiagnosticCategory.Error },
|
||||
"TypeParameter '{0}' of constructor signature from exported interface is using inaccessible module {1}.": { "code": 2214, "category": DiagnosticCategory.Error },
|
||||
"TypeParameter '{0}' of call signature from exported interface is using inaccessible module {1}": { "code": 2215, "category": DiagnosticCategory.Error },
|
||||
"TypeParameter '{0}' of public static method from exported class is using inaccessible module {1}.": { "code": 2216, "category": DiagnosticCategory.Error },
|
||||
"TypeParameter '{0}' of public method from exported class is using inaccessible module {1}.": { "code": 2217, "category": DiagnosticCategory.Error },
|
||||
"TypeParameter '{0}' of method from exported interface is using inaccessible module {1}.": { "code": 2218, "category": DiagnosticCategory.Error },
|
||||
"TypeParameter '{0}' of exported function is using inaccessible module {1}.": { "code": 2219, "category": DiagnosticCategory.Error },
|
||||
"TypeParameter '{0}' of exported class has or is using private type '{1}'.": { "code": 2220, "category": DiagnosticCategory.Error },
|
||||
"TypeParameter '{0}' of exported interface has or is using private type '{1}'.": { "code": 2221, "category": DiagnosticCategory.Error },
|
||||
"TypeParameter '{0}' of exported class is using inaccessible module {1}.": { "code": 2222, "category": DiagnosticCategory.Error },
|
||||
"TypeParameter '{0}' of exported interface is using inaccessible module {1}.": { "code": 2223, "category": DiagnosticCategory.Error },
|
||||
"Duplicate identifier '_i'. Compiler uses '_i' to initialize rest parameter.": { "code": 2224, "category": DiagnosticCategory.Error },
|
||||
"Duplicate identifier 'arguments'. Compiler uses 'arguments' to initialize rest parameters.": { "code": 2225, "category": DiagnosticCategory.Error },
|
||||
"No best common type exists between '{0}' and '{1}'.": { "code": 2226, "category": DiagnosticCategory.Error },
|
||||
"No best common type exists between '{0}', '{1}', and '{2}'.": { "code": 2227, "category": DiagnosticCategory.Error },
|
||||
"Duplicate identifier '{0}'. Compiler reserves name '{1}' in top level scope of an external module.": { "code": 2228, "category": DiagnosticCategory.Error },
|
||||
"Constraint of a type parameter cannot reference any type parameter from the same type parameter list.": { "code": 2229, "category": DiagnosticCategory.Error },
|
||||
"Initializer of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor.": { "code": 2230, "category": DiagnosticCategory.Error },
|
||||
"Parameter '{0}' cannot be referenced in its initializer.": { "code": 2231, "category": DiagnosticCategory.Error },
|
||||
"Duplicate string index signature.": { "code": 2232, "category": DiagnosticCategory.Error },
|
||||
"Duplicate number index signature.": { "code": 2233, "category": DiagnosticCategory.Error },
|
||||
"All declarations of an interface must have identical type parameters.": { "code": 2234, "category": DiagnosticCategory.Error },
|
||||
"Expression resolves to variable declaration '_i' that compiler uses to initialize rest parameter.": { "code": 2235, "category": DiagnosticCategory.Error },
|
||||
"Neither type '{0}' nor type '{1}' is assignable to the other.": { "code": 2236, "category": DiagnosticCategory.Error },
|
||||
"Neither type '{0}' nor type '{1}' is assignable to the other:{NL}{2}": { "code": 2237, "category": DiagnosticCategory.Error },
|
||||
"Duplicate function implementation.": { "code": 2237, "category": DiagnosticCategory.Error },
|
||||
"Function implementation expected.": { "code": 2238, "category": DiagnosticCategory.Error },
|
||||
"Function overload name must be '{0}'.": { "code": 2239, "category": DiagnosticCategory.Error },
|
||||
"Constructor implementation expected.": { "code": 2240, "category": DiagnosticCategory.Error },
|
||||
"Class name cannot be '{0}'.": { "code": 2241, "category": DiagnosticCategory.Error },
|
||||
"Interface name cannot be '{0}'.": { "code": 2242, "category": DiagnosticCategory.Error },
|
||||
"Enum name cannot be '{0}'.": { "code": 2243, "category": DiagnosticCategory.Error },
|
||||
"A module cannot have multiple export assignments.": { "code": 2244, "category": DiagnosticCategory.Error },
|
||||
"Export assignment not allowed in module with exported element.": { "code": 2245, "category": DiagnosticCategory.Error },
|
||||
"A parameter property is only allowed in a constructor implementation.": { "code": 2246, "category": DiagnosticCategory.Error },
|
||||
"Function overload must be static.": { "code": 2247, "category": DiagnosticCategory.Error },
|
||||
"Function overload must not be static.": { "code": 2248, "category": DiagnosticCategory.Error },
|
||||
"Type '{0}' is missing property '{1}' from type '{2}'.": { "code": 4000, "category": DiagnosticCategory.NoPrefix },
|
||||
"Types of property '{0}' of types '{1}' and '{2}' are incompatible.": { "code": 4001, "category": DiagnosticCategory.NoPrefix },
|
||||
"Types of property '{0}' of types '{1}' and '{2}' are incompatible:{NL}{3}": { "code": 4002, "category": DiagnosticCategory.NoPrefix },
|
||||
"Property '{0}' defined as private in type '{1}' is defined as public in type '{2}'.": { "code": 4003, "category": DiagnosticCategory.NoPrefix },
|
||||
"Property '{0}' defined as public in type '{1}' is defined as private in type '{2}'.": { "code": 4004, "category": DiagnosticCategory.NoPrefix },
|
||||
"Types '{0}' and '{1}' define property '{2}' as private.": { "code": 4005, "category": DiagnosticCategory.NoPrefix },
|
||||
"Call signatures of types '{0}' and '{1}' are incompatible.": { "code": 4006, "category": DiagnosticCategory.NoPrefix },
|
||||
"Call signatures of types '{0}' and '{1}' are incompatible:{NL}{2}": { "code": 4007, "category": DiagnosticCategory.NoPrefix },
|
||||
"Type '{0}' requires a call signature, but type '{1}' lacks one.": { "code": 4008, "category": DiagnosticCategory.NoPrefix },
|
||||
"Construct signatures of types '{0}' and '{1}' are incompatible.": { "code": 4009, "category": DiagnosticCategory.NoPrefix },
|
||||
"Construct signatures of types '{0}' and '{1}' are incompatible:{NL}{2}": { "code": 4010, "category": DiagnosticCategory.NoPrefix },
|
||||
"Type '{0}' requires a construct signature, but type '{1}' lacks one.": { "code": 4011, "category": DiagnosticCategory.NoPrefix },
|
||||
"Index signatures of types '{0}' and '{1}' are incompatible.": { "code": 4012, "category": DiagnosticCategory.NoPrefix },
|
||||
"Index signatures of types '{0}' and '{1}' are incompatible:{NL}{2}": { "code": 4013, "category": DiagnosticCategory.NoPrefix },
|
||||
"Call signature expects {0} or fewer parameters.": { "code": 4014, "category": DiagnosticCategory.NoPrefix },
|
||||
"Could not apply type '{0}' to argument {1} which is of type '{2}'.": { "code": 4015, "category": DiagnosticCategory.NoPrefix },
|
||||
"Class '{0}' defines instance member accessor '{1}', but extended class '{2}' defines it as instance member function.": { "code": 4016, "category": DiagnosticCategory.NoPrefix },
|
||||
"Class '{0}' defines instance member property '{1}', but extended class '{2}' defines it as instance member function.": { "code": 4017, "category": DiagnosticCategory.NoPrefix },
|
||||
"Class '{0}' defines instance member function '{1}', but extended class '{2}' defines it as instance member accessor.": { "code": 4018, "category": DiagnosticCategory.NoPrefix },
|
||||
"Class '{0}' defines instance member function '{1}', but extended class '{2}' defines it as instance member property.": { "code": 4019, "category": DiagnosticCategory.NoPrefix },
|
||||
"Types of static property '{0}' of class '{1}' and class '{2}' are incompatible.": { "code": 4020, "category": DiagnosticCategory.NoPrefix },
|
||||
"Types of static property '{0}' of class '{1}' and class '{2}' are incompatible:{NL}{3}": { "code": 4021, "category": DiagnosticCategory.NoPrefix },
|
||||
"Type reference cannot refer to container '{0}'.": { "code": 4022, "category": DiagnosticCategory.Error },
|
||||
"Type reference must refer to type.": { "code": 4023, "category": DiagnosticCategory.Error },
|
||||
"In enums with multiple declarations only one declaration can omit an initializer for the first enum element.": { "code": 4024, "category": DiagnosticCategory.Error },
|
||||
" (+ {0} overload(s))": { "code": 4025, "category": DiagnosticCategory.Message },
|
||||
"Variable declaration cannot have the same name as an import declaration.": { "code": 4026, "category": DiagnosticCategory.Error },
|
||||
"Signature expected {0} type arguments, got {1} instead.": { "code": 4027, "category": DiagnosticCategory.Error },
|
||||
"Property '{0}' defined as optional in type '{1}', but is required in type '{2}'.": { "code": 4028, "category": DiagnosticCategory.NoPrefix },
|
||||
"Types '{0}' and '{1}' originating in infinitely expanding type reference do not refer to same named type.": { "code": 4029, "category": DiagnosticCategory.NoPrefix },
|
||||
"Types '{0}' and '{1}' originating in infinitely expanding type reference have incompatible type arguments.": { "code": 4030, "category": DiagnosticCategory.NoPrefix },
|
||||
"Types '{0}' and '{1}' originating in infinitely expanding type reference have incompatible type arguments:{NL}{2}": { "code": 4031, "category": DiagnosticCategory.NoPrefix },
|
||||
"Named properties '{0}' of types '{1}' and '{2}' are not identical.": { "code": 4032, "category": DiagnosticCategory.NoPrefix },
|
||||
"Types of string indexer of types '{0}' and '{1}' are not identical.": { "code": 4033, "category": DiagnosticCategory.NoPrefix },
|
||||
"Types of number indexer of types '{0}' and '{1}' are not identical.": { "code": 4034, "category": DiagnosticCategory.NoPrefix },
|
||||
"Type of number indexer in type '{0}' is not assignable to string indexer type in type '{1}'.{NL}{2}": { "code": 4035, "category": DiagnosticCategory.NoPrefix },
|
||||
"Type of property '{0}' in type '{1}' is not assignable to string indexer type in type '{2}'.{NL}{3}": { "code": 4036, "category": DiagnosticCategory.NoPrefix },
|
||||
"Type of property '{0}' in type '{1}' is not assignable to number indexer type in type '{2}'.{NL}{3}": { "code": 4037, "category": DiagnosticCategory.NoPrefix },
|
||||
"Static property '{0}' defined as private in type '{1}' is defined as public in type '{2}'.": { "code": 4038, "category": DiagnosticCategory.NoPrefix },
|
||||
"Static property '{0}' defined as public in type '{1}' is defined as private in type '{2}'.": { "code": 4039, "category": DiagnosticCategory.NoPrefix },
|
||||
"Types '{0}' and '{1}' define static property '{2}' as private.": { "code": 4040, "category": DiagnosticCategory.NoPrefix },
|
||||
"Current host does not support '{0}' option.": { "code": 5001, "category": DiagnosticCategory.Error },
|
||||
"ECMAScript target version '{0}' not supported. Specify a valid target version: '{1}' (default), or '{2}'": { "code": 5002, "category": DiagnosticCategory.Error },
|
||||
"Argument for '{0}' option must be '{1}' or '{2}'": { "code": 5003, "category": DiagnosticCategory.Error },
|
||||
"Could not find file: '{0}'.": { "code": 5004, "category": DiagnosticCategory.Error },
|
||||
"A file cannot have a reference to itself.": { "code": 5006, "category": DiagnosticCategory.Error },
|
||||
"Cannot resolve referenced file: '{0}'.": { "code": 5007, "category": DiagnosticCategory.Error },
|
||||
"Cannot find the common subdirectory path for the input files.": { "code": 5009, "category": DiagnosticCategory.Error },
|
||||
"Emit Error: {0}.": { "code": 5011, "category": DiagnosticCategory.Error },
|
||||
"Cannot read file '{0}': {1}": { "code": 5012, "category": DiagnosticCategory.Error },
|
||||
"Unsupported file encoding.": { "code": 5013, "category": DiagnosticCategory.NoPrefix },
|
||||
"Locale must be of the form <language> or <language>-<territory>. For example '{0}' or '{1}'.": { "code": 5014, "category": DiagnosticCategory.Error },
|
||||
"Unsupported locale: '{0}'.": { "code": 5015, "category": DiagnosticCategory.Error },
|
||||
"Execution Failed.{NL}": { "code": 5016, "category": DiagnosticCategory.Error },
|
||||
"Invalid call to 'up'": { "code": 5019, "category": DiagnosticCategory.Error },
|
||||
"Invalid call to 'down'": { "code": 5020, "category": DiagnosticCategory.Error },
|
||||
"Base64 value '{0}' finished with a continuation bit.": { "code": 5021, "category": DiagnosticCategory.Error },
|
||||
"Unknown compiler option '{0}'": { "code": 5023, "category": DiagnosticCategory.Error },
|
||||
"Expected {0} arguments to message, got {1} instead.": { "code": 5024, "category": DiagnosticCategory.Error },
|
||||
"Expected the message '{0}' to have {1} arguments, but it had {2}": { "code": 5025, "category": DiagnosticCategory.Error },
|
||||
"Could not delete file '{0}'": { "code": 5034, "category": DiagnosticCategory.Error },
|
||||
"Could not create directory '{0}'": { "code": 5035, "category": DiagnosticCategory.Error },
|
||||
"Error while executing file '{0}': ": { "code": 5036, "category": DiagnosticCategory.Error },
|
||||
"Cannot compile external modules unless the '--module' flag is provided.": { "code": 5037, "category": DiagnosticCategory.Error },
|
||||
"Option mapRoot cannot be specified without specifying sourcemap option.": { "code": 5038, "category": DiagnosticCategory.Error },
|
||||
"Option sourceRoot cannot be specified without specifying sourcemap option.": { "code": 5039, "category": DiagnosticCategory.Error },
|
||||
"Options mapRoot and sourceRoot cannot be specified without specifying sourcemap option.": { "code": 5040, "category": DiagnosticCategory.Error },
|
||||
"Option '{0}' specified without '{1}'": { "code": 5041, "category": DiagnosticCategory.Error },
|
||||
"'codepage' option not supported on current platform.": { "code": 5042, "category": DiagnosticCategory.Error },
|
||||
"Concatenate and emit output to single file.": { "code": 6001, "category": DiagnosticCategory.Message },
|
||||
"Generates corresponding {0} file.": { "code": 6002, "category": DiagnosticCategory.Message },
|
||||
"Specifies the location where debugger should locate map files instead of generated locations.": { "code": 6003, "category": DiagnosticCategory.Message },
|
||||
"Specifies the location where debugger should locate TypeScript files instead of source locations.": { "code": 6004, "category": DiagnosticCategory.Message },
|
||||
"Watch input files.": { "code": 6005, "category": DiagnosticCategory.Message },
|
||||
"Redirect output structure to the directory.": { "code": 6006, "category": DiagnosticCategory.Message },
|
||||
"Do not emit comments to output.": { "code": 6009, "category": DiagnosticCategory.Message },
|
||||
"Skip resolution and preprocessing.": { "code": 6010, "category": DiagnosticCategory.Message },
|
||||
"Specify ECMAScript target version: '{0}' (default), or '{1}'": { "code": 6015, "category": DiagnosticCategory.Message },
|
||||
"Specify module code generation: '{0}' or '{1}'": { "code": 6016, "category": DiagnosticCategory.Message },
|
||||
"Print this message.": { "code": 6017, "category": DiagnosticCategory.Message },
|
||||
"Print the compiler's version: {0}": { "code": 6019, "category": DiagnosticCategory.Message },
|
||||
"Allow use of deprecated '{0}' keyword when referencing an external module.": { "code": 6021, "category": DiagnosticCategory.Message },
|
||||
"Specify locale for errors and messages. For example '{0}' or '{1}'": { "code": 6022, "category": DiagnosticCategory.Message },
|
||||
"Syntax: {0}": { "code": 6023, "category": DiagnosticCategory.Message },
|
||||
"options": { "code": 6024, "category": DiagnosticCategory.Message },
|
||||
"file1": { "code": 6025, "category": DiagnosticCategory.Message },
|
||||
"Examples:": { "code": 6026, "category": DiagnosticCategory.Message },
|
||||
"Options:": { "code": 6027, "category": DiagnosticCategory.Message },
|
||||
"Insert command line options and files from a file.": { "code": 6030, "category": DiagnosticCategory.Message },
|
||||
"Version {0}": { "code": 6029, "category": DiagnosticCategory.Message },
|
||||
"Use the '{0}' flag to see options.": { "code": 6031, "category": DiagnosticCategory.Message },
|
||||
"{NL}Recompiling ({0}):": { "code": 6032, "category": DiagnosticCategory.Message },
|
||||
"STRING": { "code": 6033, "category": DiagnosticCategory.Message },
|
||||
"KIND": { "code": 6034, "category": DiagnosticCategory.Message },
|
||||
"file2": { "code": 6035, "category": DiagnosticCategory.Message },
|
||||
"VERSION": { "code": 6036, "category": DiagnosticCategory.Message },
|
||||
"LOCATION": { "code": 6037, "category": DiagnosticCategory.Message },
|
||||
"DIRECTORY": { "code": 6038, "category": DiagnosticCategory.Message },
|
||||
"NUMBER": { "code": 6039, "category": DiagnosticCategory.Message },
|
||||
"Specify the codepage to use when opening source files.": { "code": 6040, "category": DiagnosticCategory.Message },
|
||||
"Additional locations:": { "code": 6041, "category": DiagnosticCategory.Message },
|
||||
"This version of the Javascript runtime does not support the '{0}' function.": { "code": 7000, "category": DiagnosticCategory.Error },
|
||||
"Unknown rule.": { "code": 7002, "category": DiagnosticCategory.Error },
|
||||
"Invalid line number ({0})": { "code": 7003, "category": DiagnosticCategory.Error },
|
||||
"Warn on expressions and declarations with an implied 'any' type.": { "code": 7004, "category": DiagnosticCategory.Message },
|
||||
"Variable '{0}' implicitly has an 'any' type.": { "code": 7005, "category": DiagnosticCategory.Error },
|
||||
"Parameter '{0}' of '{1}' implicitly has an 'any' type.": { "code": 7006, "category": DiagnosticCategory.Error },
|
||||
"Parameter '{0}' of function type implicitly has an 'any' type.": { "code": 7007, "category": DiagnosticCategory.Error },
|
||||
"Member '{0}' of object type implicitly has an 'any' type.": { "code": 7008, "category": DiagnosticCategory.Error },
|
||||
"'new' expression, which lacks a constructor signature, implicitly has an 'any' type.": { "code": 7009, "category": DiagnosticCategory.Error },
|
||||
"'{0}', which lacks return-type annotation, implicitly has an 'any' return type.": { "code": 7010, "category": DiagnosticCategory.Error },
|
||||
"Function expression, which lacks return-type annotation, implicitly has an 'any' return type.": { "code": 7011, "category": DiagnosticCategory.Error },
|
||||
"Parameter '{0}' of lambda function implicitly has an 'any' type.": { "code": 7012, "category": DiagnosticCategory.Error },
|
||||
"Constructor signature, which lacks return-type annotation, implicitly has an 'any' return type.": { "code": 7013, "category": DiagnosticCategory.Error },
|
||||
"Lambda Function, which lacks return-type annotation, implicitly has an 'any' return type.": { "code": 7014, "category": DiagnosticCategory.Error },
|
||||
"Array Literal implicitly has an 'any' type from widening.": { "code": 7015, "category": DiagnosticCategory.Error },
|
||||
"'{0}', which lacks 'get' accessor and parameter type annotation on 'set' accessor, implicitly has an 'any' type.": { "code": 7016, "category": DiagnosticCategory.Error },
|
||||
"Index signature of object type implicitly has an 'any' type.": { "code": 7017, "category": DiagnosticCategory.Error },
|
||||
"Object literal's property '{0}' implicitly has an 'any' type from widening.": { "code": 7018, "category": DiagnosticCategory.Error },
|
||||
};
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,2 +0,0 @@
|
||||
/// <reference path='diagnosticCode.generated.ts' />
|
||||
/// <reference path='diagnosticInformationMap.generated.ts' />
|
||||
+189
-270
@@ -2,14 +2,15 @@
|
||||
|
||||
/// <reference path='breakpoints.ts' />
|
||||
/// <reference path='outliningElementsCollector.ts' />
|
||||
/// <reference path='navigateTo.ts' />
|
||||
/// <reference path='navigationBar.ts' />
|
||||
/// <reference path='patternMatcher.ts' />
|
||||
/// <reference path='signatureHelp.ts' />
|
||||
/// <reference path='utilities.ts' />
|
||||
/// <reference path='formatting\formatting.ts' />
|
||||
/// <reference path='formatting\smartIndenter.ts' />
|
||||
|
||||
module ts {
|
||||
|
||||
export var servicesVersion = "0.4"
|
||||
|
||||
export interface Node {
|
||||
@@ -61,9 +62,9 @@ module ts {
|
||||
scriptSnapshot: IScriptSnapshot;
|
||||
nameTable: Map<string>;
|
||||
getNamedDeclarations(): Declaration[];
|
||||
getLineAndCharacterFromPosition(pos: number): LineAndCharacter;
|
||||
getLineAndCharacterOfPosition(pos: number): LineAndCharacter;
|
||||
getLineStarts(): number[];
|
||||
getPositionFromLineAndCharacter(line: number, character: number): number;
|
||||
getPositionOfLineAndCharacter(line: number, character: number): number;
|
||||
update(newText: string, textChangeRange: TextChangeRange): SourceFile;
|
||||
}
|
||||
|
||||
@@ -612,7 +613,7 @@ module ts {
|
||||
}
|
||||
|
||||
if (paramHelpStringMargin === undefined) {
|
||||
paramHelpStringMargin = sourceFile.getLineAndCharacterFromPosition(firstLineParamHelpStringPos).character - 1;
|
||||
paramHelpStringMargin = sourceFile.getLineAndCharacterOfPosition(firstLineParamHelpStringPos).character;
|
||||
}
|
||||
|
||||
// Now consume white spaces max
|
||||
@@ -750,16 +751,16 @@ module ts {
|
||||
return updateSourceFile(this, newText, textChangeRange);
|
||||
}
|
||||
|
||||
public getLineAndCharacterFromPosition(position: number): LineAndCharacter {
|
||||
return getLineAndCharacterOfPosition(this, position);
|
||||
public getLineAndCharacterOfPosition(position: number): LineAndCharacter {
|
||||
return ts.getLineAndCharacterOfPosition(this, position);
|
||||
}
|
||||
|
||||
public getLineStarts(): number[] {
|
||||
return getLineStarts(this);
|
||||
}
|
||||
|
||||
public getPositionFromLineAndCharacter(line: number, character: number): number {
|
||||
return getPositionFromLineAndCharacter(this, line, character);
|
||||
public getPositionOfLineAndCharacter(line: number, character: number): number {
|
||||
return ts.getPositionOfLineAndCharacter(this, line, character);
|
||||
}
|
||||
|
||||
public getNamedDeclarations() {
|
||||
@@ -800,7 +801,7 @@ module ts {
|
||||
case SyntaxKind.TypeAliasDeclaration:
|
||||
case SyntaxKind.EnumDeclaration:
|
||||
case SyntaxKind.ModuleDeclaration:
|
||||
case SyntaxKind.ImportDeclaration:
|
||||
case SyntaxKind.ImportEqualsDeclaration:
|
||||
case SyntaxKind.GetAccessor:
|
||||
case SyntaxKind.SetAccessor:
|
||||
case SyntaxKind.TypeLiteral:
|
||||
@@ -900,7 +901,7 @@ module ts {
|
||||
getReferencesAtPosition(fileName: string, position: number): ReferenceEntry[];
|
||||
getOccurrencesAtPosition(fileName: string, position: number): ReferenceEntry[];
|
||||
|
||||
getNavigateToItems(searchValue: string): NavigateToItem[];
|
||||
getNavigateToItems(searchValue: string, maxResultCount?: number): NavigateToItem[];
|
||||
getNavigationBarItems(fileName: string): NavigationBarItem[];
|
||||
|
||||
getOutliningSpans(fileName: string): OutliningSpan[];
|
||||
@@ -969,6 +970,7 @@ module ts {
|
||||
kind: string;
|
||||
kindModifiers: string;
|
||||
matchKind: string;
|
||||
isCaseSensitive: boolean;
|
||||
fileName: string;
|
||||
textSpan: TextSpan;
|
||||
containerName: string;
|
||||
@@ -991,6 +993,7 @@ module ts {
|
||||
InsertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis: boolean;
|
||||
PlaceOpenBraceOnNewLineForFunctions: boolean;
|
||||
PlaceOpenBraceOnNewLineForControlBlocks: boolean;
|
||||
[s: string]: boolean | number| string;
|
||||
}
|
||||
|
||||
export interface DefinitionInfo {
|
||||
@@ -1377,13 +1380,6 @@ module ts {
|
||||
public static typeAlias = "type alias name";
|
||||
}
|
||||
|
||||
enum MatchKind {
|
||||
none = 0,
|
||||
exact = 1,
|
||||
substring = 2,
|
||||
prefix = 3
|
||||
}
|
||||
|
||||
/// Language Service
|
||||
|
||||
interface CompletionSession {
|
||||
@@ -1557,78 +1553,49 @@ module ts {
|
||||
var file = this.getEntry(fileName);
|
||||
return file && file.scriptSnapshot;
|
||||
}
|
||||
|
||||
public getChangeRange(fileName: string, lastKnownVersion: string, oldScriptSnapshot: IScriptSnapshot): TextChangeRange {
|
||||
var currentVersion = this.getVersion(fileName);
|
||||
if (lastKnownVersion === currentVersion) {
|
||||
return unchangedTextChangeRange; // "No changes"
|
||||
}
|
||||
|
||||
var scriptSnapshot = this.getScriptSnapshot(fileName);
|
||||
return scriptSnapshot.getChangeRange(oldScriptSnapshot);
|
||||
}
|
||||
}
|
||||
|
||||
class SyntaxTreeCache {
|
||||
private hostCache: HostCache;
|
||||
|
||||
// For our syntactic only features, we also keep a cache of the syntax tree for the
|
||||
// currently edited file.
|
||||
private currentFileName: string = "";
|
||||
private currentFileVersion: string = null;
|
||||
private currentSourceFile: SourceFile = null;
|
||||
private currentFileName: string;
|
||||
private currentFileVersion: string;
|
||||
private currentFileScriptSnapshot: IScriptSnapshot;
|
||||
private currentSourceFile: SourceFile;
|
||||
|
||||
constructor(private host: LanguageServiceHost) {
|
||||
}
|
||||
|
||||
private log(message: string) {
|
||||
if (this.host.log) {
|
||||
this.host.log(message);
|
||||
public getCurrentSourceFile(fileName: string): SourceFile {
|
||||
var scriptSnapshot = this.host.getScriptSnapshot(fileName);
|
||||
if (!scriptSnapshot) {
|
||||
// The host does not know about this file.
|
||||
throw new Error("Could not find file: '" + fileName + "'.");
|
||||
}
|
||||
}
|
||||
|
||||
private initialize(fileName: string) {
|
||||
// ensure that both source file and syntax tree are either initialized or not initialized
|
||||
var start = new Date().getTime();
|
||||
this.hostCache = new HostCache(this.host);
|
||||
this.log("SyntaxTreeCache.Initialize: new HostCache: " + (new Date().getTime() - start));
|
||||
|
||||
var version = this.hostCache.getVersion(fileName);
|
||||
var version = this.host.getScriptVersion(fileName);
|
||||
var sourceFile: SourceFile;
|
||||
|
||||
if (this.currentFileName !== fileName) {
|
||||
var scriptSnapshot = this.hostCache.getScriptSnapshot(fileName);
|
||||
|
||||
var start = new Date().getTime();
|
||||
// This is a new file, just parse it
|
||||
sourceFile = createLanguageServiceSourceFile(fileName, scriptSnapshot, ScriptTarget.Latest, version, /*setNodeParents:*/ true);
|
||||
this.log("SyntaxTreeCache.Initialize: createSourceFile: " + (new Date().getTime() - start));
|
||||
}
|
||||
else if (this.currentFileVersion !== version) {
|
||||
var scriptSnapshot = this.hostCache.getScriptSnapshot(fileName);
|
||||
|
||||
var editRange = this.hostCache.getChangeRange(fileName, this.currentFileVersion, this.currentSourceFile.scriptSnapshot);
|
||||
|
||||
var start = new Date().getTime();
|
||||
// This is the same file, just a newer version. Incrementally parse the file.
|
||||
var editRange = scriptSnapshot.getChangeRange(this.currentFileScriptSnapshot);
|
||||
sourceFile = updateLanguageServiceSourceFile(this.currentSourceFile, scriptSnapshot, version, editRange);
|
||||
this.log("SyntaxTreeCache.Initialize: updateSourceFile: " + (new Date().getTime() - start));
|
||||
}
|
||||
|
||||
if (sourceFile) {
|
||||
// All done, ensure state is up to date
|
||||
this.currentFileVersion = version;
|
||||
this.currentFileName = fileName;
|
||||
this.currentFileScriptSnapshot = scriptSnapshot;
|
||||
this.currentSourceFile = sourceFile;
|
||||
}
|
||||
}
|
||||
|
||||
public getCurrentSourceFile(fileName: string): SourceFile {
|
||||
this.initialize(fileName);
|
||||
return this.currentSourceFile;
|
||||
}
|
||||
|
||||
public getCurrentScriptSnapshot(fileName: string): IScriptSnapshot {
|
||||
return this.getCurrentSourceFile(fileName).scriptSnapshot;
|
||||
}
|
||||
}
|
||||
|
||||
function setSourceFileFields(sourceFile: SourceFile, scriptSnapshot: IScriptSnapshot, version: string) {
|
||||
@@ -1929,7 +1896,7 @@ module ts {
|
||||
function isNameOfExternalModuleImportOrDeclaration(node: Node): boolean {
|
||||
if (node.kind === SyntaxKind.StringLiteral) {
|
||||
return isNameOfModuleDeclaration(node) ||
|
||||
(isExternalModuleImportDeclaration(node.parent.parent) && getExternalModuleImportDeclarationExpression(node.parent.parent) === node);
|
||||
(isExternalModuleImportEqualsDeclaration(node.parent.parent) && getExternalModuleImportEqualsDeclarationExpression(node.parent.parent) === node);
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -1991,6 +1958,62 @@ module ts {
|
||||
});
|
||||
}
|
||||
|
||||
/* @internal */ export function getContainerNode(node: Node): Declaration {
|
||||
while (true) {
|
||||
node = node.parent;
|
||||
if (!node) {
|
||||
return undefined;
|
||||
}
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.SourceFile:
|
||||
case SyntaxKind.MethodDeclaration:
|
||||
case SyntaxKind.MethodSignature:
|
||||
case SyntaxKind.FunctionDeclaration:
|
||||
case SyntaxKind.FunctionExpression:
|
||||
case SyntaxKind.GetAccessor:
|
||||
case SyntaxKind.SetAccessor:
|
||||
case SyntaxKind.ClassDeclaration:
|
||||
case SyntaxKind.InterfaceDeclaration:
|
||||
case SyntaxKind.EnumDeclaration:
|
||||
case SyntaxKind.ModuleDeclaration:
|
||||
return <Declaration>node;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* @internal */ export function getNodeKind(node: Node): string {
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.ModuleDeclaration: return ScriptElementKind.moduleElement;
|
||||
case SyntaxKind.ClassDeclaration: return ScriptElementKind.classElement;
|
||||
case SyntaxKind.InterfaceDeclaration: return ScriptElementKind.interfaceElement;
|
||||
case SyntaxKind.TypeAliasDeclaration: return ScriptElementKind.typeElement;
|
||||
case SyntaxKind.EnumDeclaration: return ScriptElementKind.enumElement;
|
||||
case SyntaxKind.VariableDeclaration:
|
||||
return isConst(node)
|
||||
? ScriptElementKind.constElement
|
||||
: isLet(node)
|
||||
? ScriptElementKind.letElement
|
||||
: ScriptElementKind.variableElement;
|
||||
case SyntaxKind.FunctionDeclaration: return ScriptElementKind.functionElement;
|
||||
case SyntaxKind.GetAccessor: return ScriptElementKind.memberGetAccessorElement;
|
||||
case SyntaxKind.SetAccessor: return ScriptElementKind.memberSetAccessorElement;
|
||||
case SyntaxKind.MethodDeclaration:
|
||||
case SyntaxKind.MethodSignature:
|
||||
return ScriptElementKind.memberFunctionElement;
|
||||
case SyntaxKind.PropertyDeclaration:
|
||||
case SyntaxKind.PropertySignature:
|
||||
return ScriptElementKind.memberVariableElement;
|
||||
case SyntaxKind.IndexSignature: return ScriptElementKind.indexSignatureElement;
|
||||
case SyntaxKind.ConstructSignature: return ScriptElementKind.constructSignatureElement;
|
||||
case SyntaxKind.CallSignature: return ScriptElementKind.callSignatureElement;
|
||||
case SyntaxKind.Constructor: return ScriptElementKind.constructorImplementationElement;
|
||||
case SyntaxKind.TypeParameter: return ScriptElementKind.typeParameterElement;
|
||||
case SyntaxKind.EnumMember: return ScriptElementKind.variableElement;
|
||||
case SyntaxKind.Parameter: return (node.flags & NodeFlags.AccessibilityModifier) ? ScriptElementKind.memberVariableElement : ScriptElementKind.parameterElement;
|
||||
}
|
||||
return ScriptElementKind.unknown;
|
||||
}
|
||||
|
||||
export function createLanguageService(host: LanguageServiceHost, documentRegistry: DocumentRegistry = createDocumentRegistry()): LanguageService {
|
||||
var syntaxTreeCache: SyntaxTreeCache = new SyntaxTreeCache(host);
|
||||
var ruleProvider: formatting.RulesProvider;
|
||||
@@ -2018,6 +2041,7 @@ module ts {
|
||||
}
|
||||
|
||||
function getValidSourceFile(fileName: string): SourceFile {
|
||||
fileName = normalizeSlashes(fileName);
|
||||
var sourceFile = program.getSourceFile(getCanonicalFileName(fileName));
|
||||
if (!sourceFile) {
|
||||
throw new Error("Could not find file: '" + fileName + "'.");
|
||||
@@ -2106,7 +2130,7 @@ module ts {
|
||||
}
|
||||
|
||||
// We have an older version of the sourceFile, incrementally parse the changes
|
||||
var textChangeRange = hostCache.getChangeRange(fileName, oldSourceFile.version, oldSourceFile.scriptSnapshot);
|
||||
var textChangeRange = hostFileInformation.scriptSnapshot.getChangeRange(oldSourceFile.scriptSnapshot);
|
||||
return documentRegistry.updateDocument(oldSourceFile, fileName, newSettings, hostFileInformation.scriptSnapshot, hostFileInformation.version, textChangeRange);
|
||||
}
|
||||
}
|
||||
@@ -2171,8 +2195,6 @@ module ts {
|
||||
function getSyntacticDiagnostics(fileName: string) {
|
||||
synchronizeHostData();
|
||||
|
||||
fileName = normalizeSlashes(fileName);
|
||||
|
||||
return program.getSyntacticDiagnostics(getValidSourceFile(fileName));
|
||||
}
|
||||
|
||||
@@ -2183,7 +2205,6 @@ module ts {
|
||||
function getSemanticDiagnostics(fileName: string) {
|
||||
synchronizeHostData();
|
||||
|
||||
fileName = normalizeSlashes(fileName)
|
||||
var targetSourceFile = getValidSourceFile(fileName);
|
||||
|
||||
// Only perform the action per file regardless of '-out' flag as LanguageServiceHost is expected to call this function per file.
|
||||
@@ -2260,8 +2281,6 @@ module ts {
|
||||
function getCompletionsAtPosition(fileName: string, position: number) {
|
||||
synchronizeHostData();
|
||||
|
||||
fileName = normalizeSlashes(fileName);
|
||||
|
||||
var syntacticStart = new Date().getTime();
|
||||
var sourceFile = getValidSourceFile(fileName);
|
||||
|
||||
@@ -2384,6 +2403,19 @@ module ts {
|
||||
getCompletionEntriesFromSymbols(filteredMembers, activeCompletionSession);
|
||||
}
|
||||
}
|
||||
else if (getAncestor(previousToken, SyntaxKind.ImportClause)) {
|
||||
// cursor is in import clause
|
||||
// try to show exported member for imported module
|
||||
isMemberCompletion = true;
|
||||
isNewIdentifierLocation = true;
|
||||
if (showCompletionsInImportsClause(previousToken)) {
|
||||
var importDeclaration = <ImportDeclaration>getAncestor(previousToken, SyntaxKind.ImportDeclaration);
|
||||
Debug.assert(importDeclaration !== undefined);
|
||||
var exports = typeInfoResolver.getExportsOfExternalModule(importDeclaration);
|
||||
var filteredExports = filterModuleExports(exports, importDeclaration);
|
||||
getCompletionEntriesFromSymbols(filteredExports, activeCompletionSession);
|
||||
}
|
||||
}
|
||||
else {
|
||||
// Get scope members
|
||||
isMemberCompletion = false;
|
||||
@@ -2434,6 +2466,18 @@ module ts {
|
||||
return result;
|
||||
}
|
||||
|
||||
function showCompletionsInImportsClause(node: Node): boolean {
|
||||
if (node) {
|
||||
// import {|
|
||||
// import {a,|
|
||||
if (node.kind === SyntaxKind.OpenBraceToken || node.kind === SyntaxKind.CommaToken) {
|
||||
return node.parent.kind === SyntaxKind.NamedImports;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function isNewIdentifierDefinitionLocation(previousToken: Node): boolean {
|
||||
if (previousToken) {
|
||||
var containingNodeKind = previousToken.parent.kind;
|
||||
@@ -2645,6 +2689,28 @@ module ts {
|
||||
return false;
|
||||
}
|
||||
|
||||
function filterModuleExports(exports: Symbol[], importDeclaration: ImportDeclaration): Symbol[] {
|
||||
var exisingImports: Map<boolean> = {};
|
||||
|
||||
if (!importDeclaration.importClause) {
|
||||
return exports;
|
||||
}
|
||||
|
||||
if (importDeclaration.importClause.namedBindings &&
|
||||
importDeclaration.importClause.namedBindings.kind === SyntaxKind.NamedImports) {
|
||||
|
||||
forEach((<NamedImports>importDeclaration.importClause.namedBindings).elements, el => {
|
||||
var name = el.propertyName || el.name;
|
||||
exisingImports[name.text] = true;
|
||||
});
|
||||
}
|
||||
|
||||
if (isEmpty(exisingImports)) {
|
||||
return exports;
|
||||
}
|
||||
return filter(exports, e => !lookUp(exisingImports, e.name));
|
||||
}
|
||||
|
||||
function filterContextualMembersList(contextualMemberSymbols: Symbol[], existingMembers: Declaration[]): Symbol[] {
|
||||
if (!existingMembers || existingMembers.length === 0) {
|
||||
return contextualMemberSymbols;
|
||||
@@ -2680,8 +2746,6 @@ module ts {
|
||||
function getCompletionEntryDetails(fileName: string, position: number, entryName: string): CompletionEntryDetails {
|
||||
// Note: No need to call synchronizeHostData, as we have captured all the data we need
|
||||
// in the getCompletionsAtPosition earlier
|
||||
fileName = normalizeSlashes(fileName);
|
||||
|
||||
var sourceFile = getValidSourceFile(fileName);
|
||||
|
||||
var session = activeCompletionSession;
|
||||
@@ -2721,29 +2785,6 @@ module ts {
|
||||
}
|
||||
}
|
||||
|
||||
function getContainerNode(node: Node): Node {
|
||||
while (true) {
|
||||
node = node.parent;
|
||||
if (!node) {
|
||||
return undefined;
|
||||
}
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.SourceFile:
|
||||
case SyntaxKind.MethodDeclaration:
|
||||
case SyntaxKind.MethodSignature:
|
||||
case SyntaxKind.FunctionDeclaration:
|
||||
case SyntaxKind.FunctionExpression:
|
||||
case SyntaxKind.GetAccessor:
|
||||
case SyntaxKind.SetAccessor:
|
||||
case SyntaxKind.ClassDeclaration:
|
||||
case SyntaxKind.InterfaceDeclaration:
|
||||
case SyntaxKind.EnumDeclaration:
|
||||
case SyntaxKind.ModuleDeclaration:
|
||||
return node;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// TODO(drosen): use contextual SemanticMeaning.
|
||||
function getSymbolKind(symbol: Symbol, typeResolver: TypeChecker, location: Node): string {
|
||||
var flags = symbol.getFlags();
|
||||
@@ -2830,39 +2871,6 @@ module ts {
|
||||
return ScriptElementKind.unknown;
|
||||
}
|
||||
|
||||
function getNodeKind(node: Node): string {
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.ModuleDeclaration: return ScriptElementKind.moduleElement;
|
||||
case SyntaxKind.ClassDeclaration: return ScriptElementKind.classElement;
|
||||
case SyntaxKind.InterfaceDeclaration: return ScriptElementKind.interfaceElement;
|
||||
case SyntaxKind.TypeAliasDeclaration: return ScriptElementKind.typeElement;
|
||||
case SyntaxKind.EnumDeclaration: return ScriptElementKind.enumElement;
|
||||
case SyntaxKind.VariableDeclaration:
|
||||
return isConst(node)
|
||||
? ScriptElementKind.constElement
|
||||
: isLet(node)
|
||||
? ScriptElementKind.letElement
|
||||
: ScriptElementKind.variableElement;
|
||||
case SyntaxKind.FunctionDeclaration: return ScriptElementKind.functionElement;
|
||||
case SyntaxKind.GetAccessor: return ScriptElementKind.memberGetAccessorElement;
|
||||
case SyntaxKind.SetAccessor: return ScriptElementKind.memberSetAccessorElement;
|
||||
case SyntaxKind.MethodDeclaration:
|
||||
case SyntaxKind.MethodSignature:
|
||||
return ScriptElementKind.memberFunctionElement;
|
||||
case SyntaxKind.PropertyDeclaration:
|
||||
case SyntaxKind.PropertySignature:
|
||||
return ScriptElementKind.memberVariableElement;
|
||||
case SyntaxKind.IndexSignature: return ScriptElementKind.indexSignatureElement;
|
||||
case SyntaxKind.ConstructSignature: return ScriptElementKind.constructSignatureElement;
|
||||
case SyntaxKind.CallSignature: return ScriptElementKind.callSignatureElement;
|
||||
case SyntaxKind.Constructor: return ScriptElementKind.constructorImplementationElement;
|
||||
case SyntaxKind.TypeParameter: return ScriptElementKind.typeParameterElement;
|
||||
case SyntaxKind.EnumMember: return ScriptElementKind.variableElement;
|
||||
case SyntaxKind.Parameter: return (node.flags & NodeFlags.AccessibilityModifier) ? ScriptElementKind.memberVariableElement : ScriptElementKind.parameterElement;
|
||||
}
|
||||
return ScriptElementKind.unknown;
|
||||
}
|
||||
|
||||
function getSymbolModifiers(symbol: Symbol): string {
|
||||
return symbol && symbol.declarations && symbol.declarations.length > 0
|
||||
? getNodeModifiers(symbol.declarations[0])
|
||||
@@ -3085,19 +3093,19 @@ module ts {
|
||||
displayParts.push(spacePart());
|
||||
addFullSymbolName(symbol);
|
||||
ts.forEach(symbol.declarations, declaration => {
|
||||
if (declaration.kind === SyntaxKind.ImportDeclaration) {
|
||||
var importDeclaration = <ImportDeclaration>declaration;
|
||||
if (isExternalModuleImportDeclaration(importDeclaration)) {
|
||||
if (declaration.kind === SyntaxKind.ImportEqualsDeclaration) {
|
||||
var importEqualsDeclaration = <ImportEqualsDeclaration>declaration;
|
||||
if (isExternalModuleImportEqualsDeclaration(importEqualsDeclaration)) {
|
||||
displayParts.push(spacePart());
|
||||
displayParts.push(operatorPart(SyntaxKind.EqualsToken));
|
||||
displayParts.push(spacePart());
|
||||
displayParts.push(keywordPart(SyntaxKind.RequireKeyword));
|
||||
displayParts.push(punctuationPart(SyntaxKind.OpenParenToken));
|
||||
displayParts.push(displayPart(getTextOfNode(getExternalModuleImportDeclarationExpression(importDeclaration)), SymbolDisplayPartKind.stringLiteral));
|
||||
displayParts.push(displayPart(getTextOfNode(getExternalModuleImportEqualsDeclarationExpression(importEqualsDeclaration)), SymbolDisplayPartKind.stringLiteral));
|
||||
displayParts.push(punctuationPart(SyntaxKind.CloseParenToken));
|
||||
}
|
||||
else {
|
||||
var internalAliasSymbol = typeResolver.getSymbolAtLocation(importDeclaration.moduleReference);
|
||||
var internalAliasSymbol = typeResolver.getSymbolAtLocation(importEqualsDeclaration.moduleReference);
|
||||
if (internalAliasSymbol) {
|
||||
displayParts.push(spacePart());
|
||||
displayParts.push(operatorPart(SyntaxKind.EqualsToken));
|
||||
@@ -3200,7 +3208,6 @@ module ts {
|
||||
function getQuickInfoAtPosition(fileName: string, position: number): QuickInfo {
|
||||
synchronizeHostData();
|
||||
|
||||
fileName = normalizeSlashes(fileName);
|
||||
var sourceFile = getValidSourceFile(fileName);
|
||||
var node = getTouchingPropertyName(sourceFile, position);
|
||||
if (!node) {
|
||||
@@ -3246,7 +3253,6 @@ module ts {
|
||||
function getDefinitionAtPosition(fileName: string, position: number): DefinitionInfo[] {
|
||||
synchronizeHostData();
|
||||
|
||||
fileName = normalizeSlashes(fileName);
|
||||
var sourceFile = getValidSourceFile(fileName);
|
||||
|
||||
var node = getTouchingPropertyName(sourceFile, position);
|
||||
@@ -3382,7 +3388,6 @@ module ts {
|
||||
function getOccurrencesAtPosition(fileName: string, position: number): ReferenceEntry[] {
|
||||
synchronizeHostData();
|
||||
|
||||
fileName = normalizeSlashes(fileName);
|
||||
var sourceFile = getValidSourceFile(fileName);
|
||||
|
||||
var node = getTouchingWord(sourceFile, position);
|
||||
@@ -3441,7 +3446,9 @@ module ts {
|
||||
}
|
||||
break;
|
||||
case SyntaxKind.ForKeyword:
|
||||
if (hasKind(node.parent, SyntaxKind.ForStatement) || hasKind(node.parent, SyntaxKind.ForInStatement)) {
|
||||
if (hasKind(node.parent, SyntaxKind.ForStatement) ||
|
||||
hasKind(node.parent, SyntaxKind.ForInStatement) ||
|
||||
hasKind(node.parent, SyntaxKind.ForOfStatement)) {
|
||||
return getLoopBreakContinueOccurrences(<IterationStatement>node.parent);
|
||||
}
|
||||
break;
|
||||
@@ -3718,6 +3725,7 @@ module ts {
|
||||
switch (owner.kind) {
|
||||
case SyntaxKind.ForStatement:
|
||||
case SyntaxKind.ForInStatement:
|
||||
case SyntaxKind.ForOfStatement:
|
||||
case SyntaxKind.DoStatement:
|
||||
case SyntaxKind.WhileStatement:
|
||||
return getLoopBreakContinueOccurrences(<IterationStatement>owner)
|
||||
@@ -3762,6 +3770,7 @@ module ts {
|
||||
// Fall through.
|
||||
case SyntaxKind.ForStatement:
|
||||
case SyntaxKind.ForInStatement:
|
||||
case SyntaxKind.ForOfStatement:
|
||||
case SyntaxKind.WhileStatement:
|
||||
case SyntaxKind.DoStatement:
|
||||
if (!statement.label || isLabeledBy(node, statement.label.text)) {
|
||||
@@ -3927,7 +3936,6 @@ module ts {
|
||||
function findReferences(fileName: string, position: number, findInStrings: boolean, findInComments: boolean): ReferenceEntry[] {
|
||||
synchronizeHostData();
|
||||
|
||||
fileName = normalizeSlashes(fileName);
|
||||
var sourceFile = getValidSourceFile(fileName);
|
||||
|
||||
var node = getTouchingPropertyName(sourceFile, position);
|
||||
@@ -4649,7 +4657,7 @@ module ts {
|
||||
return true;
|
||||
}
|
||||
else if (parent.kind === SyntaxKind.BinaryExpression && (<BinaryExpression>parent).left === node) {
|
||||
var operator = (<BinaryExpression>parent).operator;
|
||||
var operator = (<BinaryExpression>parent).operatorToken.kind;
|
||||
return SyntaxKind.FirstAssignment <= operator && operator <= SyntaxKind.LastAssignment;
|
||||
}
|
||||
}
|
||||
@@ -4658,89 +4666,10 @@ module ts {
|
||||
}
|
||||
|
||||
/// NavigateTo
|
||||
function getNavigateToItems(searchValue: string): NavigateToItem[] {
|
||||
function getNavigateToItems(searchValue: string, maxResultCount?: number): NavigateToItem[] {
|
||||
synchronizeHostData();
|
||||
|
||||
// Split search value in terms array
|
||||
var terms = searchValue.split(" ");
|
||||
|
||||
// default NavigateTo approach: if search term contains only lower-case chars - use case-insensitive search, otherwise switch to case-sensitive version
|
||||
var searchTerms = map(terms, t => ({ caseSensitive: hasAnyUpperCaseCharacter(t), term: t }));
|
||||
|
||||
var items: NavigateToItem[] = [];
|
||||
|
||||
// Search the declarations in all files and output matched NavigateToItem into array of NavigateToItem[]
|
||||
forEach(program.getSourceFiles(), sourceFile => {
|
||||
cancellationToken.throwIfCancellationRequested();
|
||||
|
||||
var fileName = sourceFile.fileName;
|
||||
var declarations = sourceFile.getNamedDeclarations();
|
||||
for (var i = 0, n = declarations.length; i < n; i++) {
|
||||
var declaration = declarations[i];
|
||||
// TODO(jfreeman): Skip this declaration if it has a computed name
|
||||
var name = (<Identifier>declaration.name).text;
|
||||
var matchKind = getMatchKind(searchTerms, name);
|
||||
if (matchKind !== MatchKind.none) {
|
||||
var container = <Declaration>getContainerNode(declaration);
|
||||
items.push({
|
||||
name: name,
|
||||
kind: getNodeKind(declaration),
|
||||
kindModifiers: getNodeModifiers(declaration),
|
||||
matchKind: MatchKind[matchKind],
|
||||
fileName: fileName,
|
||||
textSpan: createTextSpanFromBounds(declaration.getStart(), declaration.getEnd()),
|
||||
// TODO(jfreeman): What should be the containerName when the container has a computed name?
|
||||
containerName: container && container.name ? (<Identifier>container.name).text : "",
|
||||
containerKind: container && container.name ? getNodeKind(container) : ""
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return items;
|
||||
|
||||
function hasAnyUpperCaseCharacter(s: string): boolean {
|
||||
for (var i = 0, n = s.length; i < n; i++) {
|
||||
var c = s.charCodeAt(i);
|
||||
if ((CharacterCodes.A <= c && c <= CharacterCodes.Z) ||
|
||||
(c >= CharacterCodes.maxAsciiCharacter && s.charAt(i).toLocaleLowerCase() !== s.charAt(i))) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function getMatchKind(searchTerms: { caseSensitive: boolean; term: string }[], name: string): MatchKind {
|
||||
var matchKind = MatchKind.none;
|
||||
|
||||
if (name) {
|
||||
for (var j = 0, n = searchTerms.length; j < n; j++) {
|
||||
var searchTerm = searchTerms[j];
|
||||
var nameToSearch = searchTerm.caseSensitive ? name : name.toLocaleLowerCase();
|
||||
// in case of case-insensitive search searchTerm.term will already be lower-cased
|
||||
var index = nameToSearch.indexOf(searchTerm.term);
|
||||
if (index < 0) {
|
||||
// Didn't match.
|
||||
return MatchKind.none;
|
||||
}
|
||||
|
||||
var termKind = MatchKind.substring;
|
||||
if (index === 0) {
|
||||
// here we know that match occur at the beginning of the string.
|
||||
// if search term and declName has the same length - we have an exact match, otherwise declName have longer length and this will be prefix match
|
||||
termKind = name.length === searchTerm.term.length ? MatchKind.exact : MatchKind.prefix;
|
||||
}
|
||||
|
||||
// Update our match kind if we don't have one, or if this match is better.
|
||||
if (matchKind === MatchKind.none || termKind < matchKind) {
|
||||
matchKind = termKind;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return matchKind;
|
||||
}
|
||||
return ts.NavigateTo.getNavigateToItems(program, cancellationToken, searchValue, maxResultCount);
|
||||
}
|
||||
|
||||
function containErrors(diagnostics: Diagnostic[]): boolean {
|
||||
@@ -4750,7 +4679,6 @@ module ts {
|
||||
function getEmitOutput(fileName: string): EmitOutput {
|
||||
synchronizeHostData();
|
||||
|
||||
fileName = normalizeSlashes(fileName);
|
||||
var sourceFile = getValidSourceFile(fileName);
|
||||
|
||||
var outputFiles: OutputFile[] = [];
|
||||
@@ -4813,7 +4741,9 @@ module ts {
|
||||
return SemanticMeaning.Namespace;
|
||||
}
|
||||
|
||||
case SyntaxKind.ImportDeclaration:
|
||||
case SyntaxKind.NamedImports:
|
||||
case SyntaxKind.ImportSpecifier:
|
||||
case SyntaxKind.ImportEqualsDeclaration:
|
||||
return SemanticMeaning.Value | SemanticMeaning.Type | SemanticMeaning.Namespace;
|
||||
|
||||
// An external module can be a Value
|
||||
@@ -4848,10 +4778,10 @@ module ts {
|
||||
while (node.parent.kind === SyntaxKind.QualifiedName) {
|
||||
node = node.parent;
|
||||
}
|
||||
return isInternalModuleImportDeclaration(node.parent) && (<ImportDeclaration>node.parent).moduleReference === node;
|
||||
return isInternalModuleImportEqualsDeclaration(node.parent) && (<ImportEqualsDeclaration>node.parent).moduleReference === node;
|
||||
}
|
||||
|
||||
function getMeaningFromRightHandSideOfImport(node: Node) {
|
||||
function getMeaningFromRightHandSideOfImportEquals(node: Node) {
|
||||
Debug.assert(node.kind === SyntaxKind.Identifier);
|
||||
|
||||
// import a = |b|; // Namespace
|
||||
@@ -4860,7 +4790,7 @@ module ts {
|
||||
|
||||
if (node.parent.kind === SyntaxKind.QualifiedName &&
|
||||
(<QualifiedName>node.parent).right === node &&
|
||||
node.parent.parent.kind === SyntaxKind.ImportDeclaration) {
|
||||
node.parent.parent.kind === SyntaxKind.ImportEqualsDeclaration) {
|
||||
return SemanticMeaning.Value | SemanticMeaning.Type | SemanticMeaning.Namespace;
|
||||
}
|
||||
return SemanticMeaning.Namespace;
|
||||
@@ -4871,7 +4801,7 @@ module ts {
|
||||
return SemanticMeaning.Value | SemanticMeaning.Type | SemanticMeaning.Namespace;
|
||||
}
|
||||
else if (isInRightSideOfImport(node)) {
|
||||
return getMeaningFromRightHandSideOfImport(node);
|
||||
return getMeaningFromRightHandSideOfImportEquals(node);
|
||||
}
|
||||
else if (isDeclarationOrFunctionExpressionOrCatchVariableName(node)) {
|
||||
return getMeaningFromDeclaration(node.parent);
|
||||
@@ -4894,23 +4824,21 @@ module ts {
|
||||
function getSignatureHelpItems(fileName: string, position: number): SignatureHelpItems {
|
||||
synchronizeHostData();
|
||||
|
||||
fileName = normalizeSlashes(fileName);
|
||||
var sourceFile = getValidSourceFile(fileName);
|
||||
|
||||
return SignatureHelp.getSignatureHelpItems(sourceFile, position, typeInfoResolver, cancellationToken);
|
||||
}
|
||||
|
||||
/// Syntactic features
|
||||
function getCurrentSourceFile(fileName: string): SourceFile {
|
||||
fileName = normalizeSlashes(fileName);
|
||||
var currentSourceFile = syntaxTreeCache.getCurrentSourceFile(fileName);
|
||||
return currentSourceFile;
|
||||
function getSourceFile(fileName: string): SourceFile {
|
||||
return syntaxTreeCache.getCurrentSourceFile(fileName);
|
||||
}
|
||||
|
||||
function getNameOrDottedNameSpan(fileName: string, startPos: number, endPos: number): TextSpan {
|
||||
fileName = ts.normalizeSlashes(fileName);
|
||||
var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName);
|
||||
|
||||
// Get node at the location
|
||||
var node = getTouchingPropertyName(getCurrentSourceFile(fileName), startPos);
|
||||
var node = getTouchingPropertyName(sourceFile, startPos);
|
||||
|
||||
if (!node) {
|
||||
return;
|
||||
@@ -4964,19 +4892,19 @@ module ts {
|
||||
|
||||
function getBreakpointStatementAtPosition(fileName: string, position: number) {
|
||||
// doesn't use compiler - no need to synchronize with host
|
||||
fileName = ts.normalizeSlashes(fileName);
|
||||
return BreakpointResolver.spanInSourceFileAtLocation(getCurrentSourceFile(fileName), position);
|
||||
var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName);
|
||||
|
||||
return BreakpointResolver.spanInSourceFileAtLocation(sourceFile, position);
|
||||
}
|
||||
|
||||
function getNavigationBarItems(fileName: string): NavigationBarItem[] {
|
||||
fileName = normalizeSlashes(fileName);
|
||||
function getNavigationBarItems(fileName: string): NavigationBarItem[]{
|
||||
var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName);
|
||||
|
||||
return NavigationBar.getNavigationBarItems(getCurrentSourceFile(fileName));
|
||||
return NavigationBar.getNavigationBarItems(sourceFile);
|
||||
}
|
||||
|
||||
function getSemanticClassifications(fileName: string, span: TextSpan): ClassifiedSpan[] {
|
||||
synchronizeHostData();
|
||||
fileName = normalizeSlashes(fileName);
|
||||
|
||||
var sourceFile = getValidSourceFile(fileName);
|
||||
|
||||
@@ -5050,8 +4978,7 @@ module ts {
|
||||
|
||||
function getSyntacticClassifications(fileName: string, span: TextSpan): ClassifiedSpan[] {
|
||||
// doesn't use compiler - no need to synchronize with host
|
||||
fileName = normalizeSlashes(fileName);
|
||||
var sourceFile = getCurrentSourceFile(fileName);
|
||||
var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName);
|
||||
|
||||
// Make a scanner we can get trivia from.
|
||||
var triviaScanner = createScanner(ScriptTarget.Latest, /*skipTrivia:*/ false, sourceFile.text);
|
||||
@@ -5269,13 +5196,12 @@ module ts {
|
||||
|
||||
function getOutliningSpans(fileName: string): OutliningSpan[] {
|
||||
// doesn't use compiler - no need to synchronize with host
|
||||
fileName = normalizeSlashes(fileName);
|
||||
var sourceFile = getCurrentSourceFile(fileName);
|
||||
var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName);
|
||||
return OutliningElementsCollector.collectElements(sourceFile);
|
||||
}
|
||||
|
||||
function getBraceMatchingAtPosition(fileName: string, position: number) {
|
||||
var sourceFile = getCurrentSourceFile(fileName);
|
||||
var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName);
|
||||
var result: TextSpan[] = [];
|
||||
|
||||
var token = getTouchingToken(sourceFile, position);
|
||||
@@ -5328,10 +5254,8 @@ module ts {
|
||||
}
|
||||
|
||||
function getIndentationAtPosition(fileName: string, position: number, editorOptions: EditorOptions) {
|
||||
fileName = normalizeSlashes(fileName);
|
||||
|
||||
var start = new Date().getTime();
|
||||
var sourceFile = getCurrentSourceFile(fileName);
|
||||
var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName);
|
||||
log("getIndentationAtPosition: getCurrentSourceFile: " + (new Date().getTime() - start));
|
||||
|
||||
var start = new Date().getTime();
|
||||
@@ -5343,22 +5267,17 @@ module ts {
|
||||
}
|
||||
|
||||
function getFormattingEditsForRange(fileName: string, start: number, end: number, options: FormatCodeOptions): TextChange[] {
|
||||
fileName = normalizeSlashes(fileName);
|
||||
var sourceFile = getCurrentSourceFile(fileName);
|
||||
var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName);
|
||||
return formatting.formatSelection(start, end, sourceFile, getRuleProvider(options), options);
|
||||
}
|
||||
|
||||
function getFormattingEditsForDocument(fileName: string, options: FormatCodeOptions): TextChange[] {
|
||||
fileName = normalizeSlashes(fileName);
|
||||
|
||||
var sourceFile = getCurrentSourceFile(fileName);
|
||||
var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName);
|
||||
return formatting.formatDocument(sourceFile, getRuleProvider(options), options);
|
||||
}
|
||||
|
||||
function getFormattingEditsAfterKeystroke(fileName: string, position: number, key: string, options: FormatCodeOptions): TextChange[] {
|
||||
fileName = normalizeSlashes(fileName);
|
||||
|
||||
var sourceFile = getCurrentSourceFile(fileName);
|
||||
var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName);
|
||||
|
||||
if (key === "}") {
|
||||
return formatting.formatOnClosingCurly(position, sourceFile, getRuleProvider(options), options);
|
||||
@@ -5382,8 +5301,6 @@ module ts {
|
||||
// anything away.
|
||||
synchronizeHostData();
|
||||
|
||||
fileName = normalizeSlashes(fileName);
|
||||
|
||||
var sourceFile = getValidSourceFile(fileName);
|
||||
|
||||
cancellationToken.throwIfCancellationRequested();
|
||||
@@ -5526,7 +5443,6 @@ module ts {
|
||||
function getRenameInfo(fileName: string, position: number): RenameInfo {
|
||||
synchronizeHostData();
|
||||
|
||||
fileName = normalizeSlashes(fileName);
|
||||
var sourceFile = getValidSourceFile(fileName);
|
||||
|
||||
var node = getTouchingWord(sourceFile, position);
|
||||
@@ -5610,7 +5526,7 @@ module ts {
|
||||
getFormattingEditsForDocument,
|
||||
getFormattingEditsAfterKeystroke,
|
||||
getEmitOutput,
|
||||
getSourceFile: getCurrentSourceFile,
|
||||
getSourceFile,
|
||||
getProgram
|
||||
};
|
||||
}
|
||||
@@ -5774,30 +5690,31 @@ module ts {
|
||||
}
|
||||
}
|
||||
else if (lastNonTriviaToken === SyntaxKind.DotToken && isKeyword(token)) {
|
||||
token = SyntaxKind.Identifier;
|
||||
token = SyntaxKind.Identifier;
|
||||
}
|
||||
else if (isKeyword(lastNonTriviaToken) && isKeyword(token) && !canFollow(lastNonTriviaToken, token)) {
|
||||
// We have two keywords in a row. Only treat the second as a keyword if
|
||||
// it's a sequence that could legally occur in the language. Otherwise
|
||||
// treat it as an identifier. This way, if someone writes "private var"
|
||||
// we recognize that 'var' is actually an identifier here.
|
||||
token = SyntaxKind.Identifier;
|
||||
// We have two keywords in a row. Only treat the second as a keyword if
|
||||
// it's a sequence that could legally occur in the language. Otherwise
|
||||
// treat it as an identifier. This way, if someone writes "private var"
|
||||
// we recognize that 'var' is actually an identifier here.
|
||||
token = SyntaxKind.Identifier;
|
||||
}
|
||||
else if (lastNonTriviaToken === SyntaxKind.Identifier &&
|
||||
token === SyntaxKind.LessThanToken) {
|
||||
// Could be the start of something generic. Keep track of that by bumping
|
||||
// up the current count of generic contexts we may be in.
|
||||
angleBracketStack++;
|
||||
// Could be the start of something generic. Keep track of that by bumping
|
||||
// up the current count of generic contexts we may be in.
|
||||
angleBracketStack++;
|
||||
}
|
||||
else if (token === SyntaxKind.GreaterThanToken && angleBracketStack > 0) {
|
||||
// If we think we're currently in something generic, then mark that that
|
||||
// generic entity is complete.
|
||||
angleBracketStack--;
|
||||
// If we think we're currently in something generic, then mark that that
|
||||
// generic entity is complete.
|
||||
angleBracketStack--;
|
||||
}
|
||||
else if (token === SyntaxKind.AnyKeyword ||
|
||||
token === SyntaxKind.StringKeyword ||
|
||||
token === SyntaxKind.NumberKeyword ||
|
||||
token === SyntaxKind.BooleanKeyword) {
|
||||
token === SyntaxKind.BooleanKeyword ||
|
||||
token === SyntaxKind.SymbolKeyword) {
|
||||
if (angleBracketStack > 0 && !syntacticClassifierAbsent) {
|
||||
// If it looks like we're could be in something generic, don't classify this
|
||||
// as a keyword. We may just get overwritten by the syntactic classifier,
|
||||
@@ -5952,7 +5869,8 @@ module ts {
|
||||
case SyntaxKind.EqualsToken:
|
||||
case SyntaxKind.CommaToken:
|
||||
return true;
|
||||
default: return false;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5997,6 +5915,7 @@ module ts {
|
||||
case SyntaxKind.SingleLineCommentTrivia:
|
||||
return TokenClass.Comment;
|
||||
case SyntaxKind.WhitespaceTrivia:
|
||||
case SyntaxKind.NewLineTrivia:
|
||||
return TokenClass.Whitespace;
|
||||
case SyntaxKind.Identifier:
|
||||
default:
|
||||
|
||||
+12
-5
@@ -138,7 +138,7 @@ module ts {
|
||||
* Returns a JSON-encoded value of the type:
|
||||
* { name: string; kind: string; kindModifiers: string; containerName: string; containerKind: string; matchKind: string; fileName: string; textSpan: { start: number; length: number}; } [] = [];
|
||||
*/
|
||||
getNavigateToItems(searchValue: string): string;
|
||||
getNavigateToItems(searchValue: string, maxResultCount?: number): string;
|
||||
|
||||
/**
|
||||
* Returns a JSON-encoded value of the type:
|
||||
@@ -274,7 +274,14 @@ module ts {
|
||||
}
|
||||
|
||||
public getDefaultLibFileName(options: CompilerOptions): string {
|
||||
return this.shimHost.getDefaultLibFileName(JSON.stringify(options));
|
||||
// Wrap the API changes for 1.5 release. This try/catch
|
||||
// should be removed once TypeScript 1.5 has shipped.
|
||||
try {
|
||||
return this.shimHost.getDefaultLibFileName(JSON.stringify(options));
|
||||
}
|
||||
catch (e) {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -628,11 +635,11 @@ module ts {
|
||||
/// NAVIGATE TO
|
||||
|
||||
/** Return a list of symbols that are interesting to navigate to */
|
||||
public getNavigateToItems(searchValue: string): string {
|
||||
public getNavigateToItems(searchValue: string, maxResultCount?: number): string {
|
||||
return this.forwardJSONCall(
|
||||
"getNavigateToItems('" + searchValue + "')",
|
||||
"getNavigateToItems('" + searchValue + "', " + maxResultCount+ ")",
|
||||
() => {
|
||||
var items = this.languageService.getNavigateToItems(searchValue);
|
||||
var items = this.languageService.getNavigateToItems(searchValue, maxResultCount);
|
||||
return items;
|
||||
});
|
||||
}
|
||||
|
||||
-1132
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
@@ -1,70 +0,0 @@
|
||||
///<reference path='references.ts' />
|
||||
|
||||
module TypeScript {
|
||||
export module CharacterInfo {
|
||||
export function isDecimalDigit(c: number): boolean {
|
||||
return c >= CharacterCodes._0 && c <= CharacterCodes._9;
|
||||
}
|
||||
|
||||
export function isOctalDigit(c: number): boolean {
|
||||
return c >= CharacterCodes._0 && c <= CharacterCodes._7;
|
||||
}
|
||||
|
||||
export function isHexDigit(c: number): boolean {
|
||||
return CharacterInfo.isDecimalDigit(c) ||
|
||||
(c >= CharacterCodes.A && c <= CharacterCodes.F) ||
|
||||
(c >= CharacterCodes.a && c <= CharacterCodes.f);
|
||||
}
|
||||
|
||||
export function hexValue(c: number): number {
|
||||
// Debug.assert(isHexDigit(c));
|
||||
return CharacterInfo.isDecimalDigit(c)
|
||||
? (c - CharacterCodes._0)
|
||||
: (c >= CharacterCodes.A && c <= CharacterCodes.F)
|
||||
? c - CharacterCodes.A + 10
|
||||
: c - CharacterCodes.a + 10;
|
||||
}
|
||||
|
||||
export function isWhitespace(ch: number): boolean {
|
||||
switch (ch) {
|
||||
// Unicode 3.0 space characters.
|
||||
case CharacterCodes.space:
|
||||
case CharacterCodes.nonBreakingSpace:
|
||||
case CharacterCodes.enQuad:
|
||||
case CharacterCodes.emQuad:
|
||||
case CharacterCodes.enSpace:
|
||||
case CharacterCodes.emSpace:
|
||||
case CharacterCodes.threePerEmSpace:
|
||||
case CharacterCodes.fourPerEmSpace:
|
||||
case CharacterCodes.sixPerEmSpace:
|
||||
case CharacterCodes.figureSpace:
|
||||
case CharacterCodes.punctuationSpace:
|
||||
case CharacterCodes.thinSpace:
|
||||
case CharacterCodes.hairSpace:
|
||||
case CharacterCodes.zeroWidthSpace:
|
||||
case CharacterCodes.narrowNoBreakSpace:
|
||||
case CharacterCodes.ideographicSpace:
|
||||
|
||||
case CharacterCodes.tab:
|
||||
case CharacterCodes.verticalTab:
|
||||
case CharacterCodes.formFeed:
|
||||
case CharacterCodes.byteOrderMark:
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
export function isLineTerminator(ch: number): boolean {
|
||||
switch (ch) {
|
||||
case CharacterCodes.carriageReturn:
|
||||
case CharacterCodes.lineFeed:
|
||||
case CharacterCodes.paragraphSeparator:
|
||||
case CharacterCodes.lineSeparator:
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
///<reference path='references.ts' />
|
||||
|
||||
module TypeScript {
|
||||
export const enum ParserContextFlags {
|
||||
StrictMode = 1 << 0,
|
||||
DisallowIn = 1 << 1,
|
||||
Yield = 1 << 2,
|
||||
GeneratorParameter = 1 << 3,
|
||||
Async = 1 << 4,
|
||||
|
||||
Mask = 0x1F
|
||||
}
|
||||
|
||||
export enum SyntaxNodeConstants {
|
||||
None = 0,
|
||||
|
||||
// The first five bit of the flags are used to store parser context flags. The next bit
|
||||
// marks if we've computed the transitive data for the node. The next bit marks if the node
|
||||
// is incrementally unusable.
|
||||
//
|
||||
// The width of the node is stored in the remainder of the number.
|
||||
DataComputed = 1 << 5, // 0000 0000 0000 0000 0000 0000 0010 0000
|
||||
IncrementallyUnusableMask = 1 << 6, // 0000 0000 0000 0000 0000 0000 0100 0000
|
||||
FullWidthShift = 1 << 7, // 1111 1111 1111 1111 1111 1111 1000 0000
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,13 +0,0 @@
|
||||
///<reference path='references.ts' />
|
||||
|
||||
module TypeScript {
|
||||
export class FormattingOptions {
|
||||
constructor(public useTabs: boolean,
|
||||
public spacesPerTab: number,
|
||||
public indentSpaces: number,
|
||||
public newLineCharacter: string) {
|
||||
}
|
||||
|
||||
public static defaultOptions = new FormattingOptions(/*useTabs:*/ false, /*spacesPerTab:*/ 4, /*indentSpaces:*/ 4, /*newLineCharacter*/ "\r\n");
|
||||
}
|
||||
}
|
||||
@@ -1,428 +0,0 @@
|
||||
///<reference path="references.ts" />
|
||||
|
||||
module TypeScript.IncrementalParser {
|
||||
interface ISyntaxElementInternal extends ISyntaxElement {
|
||||
intersectsChange: boolean;
|
||||
}
|
||||
|
||||
// Parser source used in incremental scenarios. This parser source wraps an old tree, text
|
||||
// change and new text, and uses all three to provide nodes and tokens to the parser. In
|
||||
// general, nodes from the old tree are returned as long as they do not intersect with the text
|
||||
// change. Then, once the text change is reached, tokens from the old tree are returned as
|
||||
// long as they do not intersect with the text change. Then, the text that is actually changed
|
||||
// will be scanned using a normal scanner. Then, once the new text is scanned, the source will
|
||||
// attempt to sync back up with nodes or tokens that started where the new tokens end. Once it
|
||||
// can do that, then all subsequent data will come from the original tree.
|
||||
//
|
||||
// This allows for an enormous amount of tree reuse in common scenarios. Situations that
|
||||
// prevent this level of reuse include substantially destructive operations like introducing
|
||||
// "/*" without a "*/" nearby to terminate the comment.
|
||||
function createParserSource(oldSyntaxTree: SyntaxTree, textChangeRange: TextChangeRange, text: ISimpleText): Parser.IParserSource {
|
||||
// The underlying source that we will use to scan tokens from any new text, or any tokens
|
||||
// from the old tree that we decide we can't use for any reason. We will also continue
|
||||
// scanning tokens from this source until we've decided that we're resynchronized and can
|
||||
// read in subsequent data from the old tree.
|
||||
//
|
||||
// This parser source also keeps track of the absolute position in the text that we're in,
|
||||
// and any token diagnostics produced. That way we dont' have to track that ourselves.
|
||||
var scannerParserSource = Scanner.createParserSource(oldSyntaxTree.fileName(), text, oldSyntaxTree.languageVersion());
|
||||
|
||||
// The cursor we use to navigate through and retrieve nodes and tokens from the old tree.
|
||||
var oldSourceUnit = oldSyntaxTree.sourceUnit();
|
||||
|
||||
// Start the cursor pointing at the first element in the source unit (if it exists).
|
||||
var oldSourceUnitCursor = getSyntaxCursor();
|
||||
if (oldSourceUnit.moduleElements.length > 0) {
|
||||
oldSourceUnitCursor.pushElement(childAt(oldSourceUnit.moduleElements, 0), /*indexInParent:*/ 0);
|
||||
}
|
||||
|
||||
// In general supporting multiple individual edits is just not that important. So we
|
||||
// just collapse this all down to a single range to make the code here easier. The only
|
||||
// time this could be problematic would be if the user made a ton of discontinuous edits.
|
||||
// For example, doing a column select on a *large* section of a code. If this is a
|
||||
// problem, we can always update this code to handle multiple changes.
|
||||
var changeRange = extendToAffectedRange(textChangeRange, oldSourceUnit);
|
||||
|
||||
// The old tree's length, plus whatever length change was caused by the edit
|
||||
// Had better equal the new text's length!
|
||||
if (Debug.shouldAssert(AssertionLevel.Aggressive)) {
|
||||
Debug.assert((fullWidth(oldSourceUnit) - changeRange.span().length() + changeRange.newLength()) === text.length());
|
||||
}
|
||||
|
||||
var delta = changeRange.newSpan().length() - changeRange.span().length();
|
||||
|
||||
// If we added or removed characters during the edit, then we need to go and adjust all
|
||||
// the nodes after the edit. Those nodes may move forward down (if we inserted chars)
|
||||
// or they may move backward (if we deleted chars).
|
||||
//
|
||||
// Doing this helps us out in two ways. First, it means that any nodes/tokens we want
|
||||
// to reuse are already at the appropriate position in the new text. That way when we
|
||||
// reuse them, we don't have to figure out if they need to be adjusted. Second, it makes
|
||||
// it very easy to determine if we can reuse a node. If the node's position is at where
|
||||
// we are in the text, then we can reuse it. Otherwise we can't. If hte node's position
|
||||
// is ahead of us, then we'll need to rescan tokens. If the node's position is behind
|
||||
// us, then we'll need to skip it or crumble it as appropriate
|
||||
//
|
||||
// Also, mark any syntax elements that intersect the changed span. We know, up front,
|
||||
// that we cannot reuse these elements.
|
||||
updateTokenPositionsAndMarkElements(<ISyntaxElementInternal><ISyntaxElement>oldSourceUnit,
|
||||
changeRange.span().start(), changeRange.span().end(), delta, /*fullStart:*/ 0);
|
||||
|
||||
function extendToAffectedRange(changeRange: TextChangeRange, sourceUnit: SourceUnitSyntax): TextChangeRange {
|
||||
// Consider the following code:
|
||||
// void foo() { /; }
|
||||
//
|
||||
// If the text changes with an insertion of / just before the semicolon then we end up with:
|
||||
// void foo() { //; }
|
||||
//
|
||||
// If we were to just use the changeRange a is, then we would not rescan the { token
|
||||
// (as it does not intersect the actual original change range). Because an edit may
|
||||
// change the token touching it, we actually need to look back *at least* one token so
|
||||
// that the prior token sees that change.
|
||||
var maxLookahead = 1;
|
||||
|
||||
var start = changeRange.span().start();
|
||||
|
||||
// the first iteration aligns us with the change start. subsequent iteration move us to
|
||||
// the left by maxLookahead tokens. We only need to do this as long as we're not at the
|
||||
// start of the tree.
|
||||
for (var i = 0; start > 0 && i <= maxLookahead; i++) {
|
||||
var token = findToken(sourceUnit, start);
|
||||
var position = token.fullStart();
|
||||
|
||||
start = Math.max(0, position - 1);
|
||||
}
|
||||
|
||||
var finalSpan = TextSpan.fromBounds(start, changeRange.span().end());
|
||||
var finalLength = changeRange.newLength() + (changeRange.span().start() - start);
|
||||
|
||||
return new TextChangeRange(finalSpan, finalLength);
|
||||
}
|
||||
|
||||
function absolutePosition() {
|
||||
return scannerParserSource.absolutePosition();
|
||||
}
|
||||
|
||||
function diagnostics(): Diagnostic[] {
|
||||
return scannerParserSource.diagnostics();
|
||||
}
|
||||
|
||||
function tryParse<T extends ISyntaxNode>(callback: () => T): T {
|
||||
// Clone our cursor. That way we can restore to that point if the parser needs to rewind.
|
||||
var savedOldSourceUnitCursor = cloneSyntaxCursor(oldSourceUnitCursor);
|
||||
|
||||
// Now defer to our underlying scanner source to actually invoke the callback. That
|
||||
// way, if the parser decides to rewind, both the scanner source and this incremental
|
||||
// source will rewind appropriately.
|
||||
var result = scannerParserSource.tryParse(callback);
|
||||
|
||||
if (!result) {
|
||||
// We're rewinding. Reset the cursor to what it was when we got the rewind point.
|
||||
// Make sure to return our existing cursor to the pool so it can be reused.
|
||||
returnSyntaxCursor(oldSourceUnitCursor);
|
||||
oldSourceUnitCursor = savedOldSourceUnitCursor;
|
||||
}
|
||||
else {
|
||||
// We're not rewinding. Return the cloned original cursor back to the pool.
|
||||
returnSyntaxCursor(savedOldSourceUnitCursor);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
function trySynchronizeCursorToPosition() {
|
||||
var absolutePos = absolutePosition();
|
||||
while (true) {
|
||||
if (oldSourceUnitCursor.isFinished()) {
|
||||
// Can't synchronize the cursor to the current position if the cursor is finished.
|
||||
return false;
|
||||
}
|
||||
|
||||
// Start with the current node or token the cursor is pointing at.
|
||||
var currentNodeOrToken = oldSourceUnitCursor.currentNodeOrToken();
|
||||
|
||||
// Node, move the cursor past any nodes or tokens that intersect the change range
|
||||
// 1) they are never reusable.
|
||||
// 2) their positions are wacky as they refer to the original text.
|
||||
//
|
||||
// We consider these nodes and tokens essentially invisible to all further parts
|
||||
// of the incremental algorithm.
|
||||
if ((<ISyntaxElementInternal><ISyntaxElement>currentNodeOrToken).intersectsChange) {
|
||||
if (isNode(currentNodeOrToken)) {
|
||||
oldSourceUnitCursor.moveToFirstChild();
|
||||
}
|
||||
else {
|
||||
oldSourceUnitCursor.moveToNextSibling();
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
var currentNodeOrTokenFullStart = fullStart(currentNodeOrToken);
|
||||
if (currentNodeOrTokenFullStart === absolutePos) {
|
||||
// We were able to synchronize the cursor to the current position. We can
|
||||
// read from the cursor
|
||||
return true;
|
||||
}
|
||||
|
||||
if (currentNodeOrTokenFullStart > absolutePos) {
|
||||
// The node or token is ahead of the current position. We'll need to rescan
|
||||
// tokens until we catch up.
|
||||
return false;
|
||||
}
|
||||
|
||||
// The node or is behind the current position we're at in the text.
|
||||
|
||||
var currentNodeOrTokenFullWidth = fullWidth(currentNodeOrToken);
|
||||
var currentNodeOrTokenFullEnd = currentNodeOrTokenFullStart + currentNodeOrTokenFullWidth;
|
||||
|
||||
// If we're pointing at a node, and that node ends before our current position, we
|
||||
// can just skip the node entirely. Or, if we're pointing at a token, we won't be
|
||||
// able to break up that token any further and we should just move to the next
|
||||
// token.
|
||||
if (currentNodeOrTokenFullEnd <= absolutePos || isToken(currentNodeOrToken)) {
|
||||
oldSourceUnitCursor.moveToNextSibling();
|
||||
}
|
||||
else {
|
||||
// We have a node, and it started before our absolute pos, and ended after our
|
||||
// pos. Try to crumble this node to see if we'll be able to skip the first node
|
||||
// or token contained within.
|
||||
oldSourceUnitCursor.moveToFirstChild();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function currentNode(): ISyntaxNode {
|
||||
if (trySynchronizeCursorToPosition()) {
|
||||
// Try to read a node. If we can't then our caller will call back in and just try
|
||||
// to get a token.
|
||||
var node = tryGetNodeFromOldSourceUnit();
|
||||
if (node) {
|
||||
return node;
|
||||
}
|
||||
}
|
||||
|
||||
// Either we were ahead of the old text, or we were pinned. No node can be read here.
|
||||
return undefined;
|
||||
}
|
||||
|
||||
function currentToken(): ISyntaxToken {
|
||||
if (trySynchronizeCursorToPosition()) {
|
||||
var token = tryGetTokenFromOldSourceUnit();
|
||||
if (token) {
|
||||
return token;
|
||||
}
|
||||
}
|
||||
|
||||
// Either we couldn't read from the old source unit, or we weren't able to successfully
|
||||
// get a token from it. In this case we need to read a token from the underlying text.
|
||||
return scannerParserSource.currentToken();
|
||||
}
|
||||
|
||||
function currentContextualToken(): ISyntaxToken {
|
||||
// Just delegate to the underlying source to handle
|
||||
return scannerParserSource.currentContextualToken();
|
||||
}
|
||||
|
||||
function tryGetNodeFromOldSourceUnit(): ISyntaxNode {
|
||||
// Keep moving the cursor down to the first node that is safe to return. A node is
|
||||
// safe to return if:
|
||||
// a) it does not contain skipped text.
|
||||
// b) it does not have any zero width tokens in it.
|
||||
// c) it does not have a regex token in it.
|
||||
// d) we are still in the same strict or non-strict state that the node was originally parsed in.
|
||||
while (true) {
|
||||
var node = oldSourceUnitCursor.currentNode();
|
||||
if (node === undefined) {
|
||||
// Couldn't even read a node, nothing to return.
|
||||
return undefined;
|
||||
}
|
||||
|
||||
if (!TypeScript.isIncrementallyUnusable(node)) {
|
||||
// Didn't contain anything that would make it unusable. Awesome. This is
|
||||
// a node we can reuse.
|
||||
return node;
|
||||
}
|
||||
|
||||
// We couldn't use currentNode. Try to move to its first child (in case that's a
|
||||
// node). If it is we can try using that. Otherwise we'll just bail out in the
|
||||
// next iteration of the loop.
|
||||
oldSourceUnitCursor.moveToFirstChild();
|
||||
}
|
||||
}
|
||||
|
||||
function canReuseTokenFromOldSourceUnit(token: ISyntaxToken): boolean {
|
||||
// A token is safe to return if:
|
||||
// a) it did not intersect the change range.
|
||||
// b) it does not contain skipped text.
|
||||
// c) it is not zero width.
|
||||
// d) it is not a contextual parser token.
|
||||
//
|
||||
// NOTE: It is safe to get a token regardless of what our strict context was/is. That's
|
||||
// because the strict context doesn't change what tokens are scanned, only how the
|
||||
// parser reacts to them.
|
||||
//
|
||||
// NOTE: we don't mark a keyword that was converted to an identifier as 'incrementally
|
||||
// unusable. This is because we don't want to mark it's containing parent node as
|
||||
// unusable. i.e. if i have this: "public Foo(string: Type) { }", then that *entire* node
|
||||
// is reusuable even though "string" was converted to an identifier. However, we still
|
||||
// need to make sure that if that the parser asks for a *token* we don't return it.
|
||||
// Converted identifiers can't ever be created by the scanner, and as such, should not
|
||||
// be returned by this source.
|
||||
return token &&
|
||||
!(<ISyntaxElementInternal><ISyntaxElement>token).intersectsChange &&
|
||||
!token.isIncrementallyUnusable() &&
|
||||
!Scanner.isContextualToken(token);
|
||||
}
|
||||
|
||||
function tryGetTokenFromOldSourceUnit(): ISyntaxToken {
|
||||
// get the current token that the cursor is pointing at.
|
||||
var token = oldSourceUnitCursor.currentToken();
|
||||
|
||||
return canReuseTokenFromOldSourceUnit(token) ? token : undefined;
|
||||
}
|
||||
|
||||
function peekToken(n: number): ISyntaxToken {
|
||||
if (trySynchronizeCursorToPosition()) {
|
||||
var token = tryPeekTokenFromOldSourceUnit(n);
|
||||
if (token) {
|
||||
return token;
|
||||
}
|
||||
}
|
||||
|
||||
// Couldn't peek this far in the old tree. Get the token from the new text.
|
||||
return scannerParserSource.peekToken(n);
|
||||
}
|
||||
|
||||
function tryPeekTokenFromOldSourceUnit(n: number): ISyntaxToken {
|
||||
// clone the existing cursor so we can move it forward and then restore ourselves back
|
||||
// to where we started from.
|
||||
|
||||
var cursorClone = cloneSyntaxCursor(oldSourceUnitCursor);
|
||||
|
||||
var token = tryPeekTokenFromOldSourceUnitWorker(n);
|
||||
|
||||
returnSyntaxCursor(oldSourceUnitCursor);
|
||||
oldSourceUnitCursor = cursorClone;
|
||||
|
||||
return token;
|
||||
}
|
||||
|
||||
function tryPeekTokenFromOldSourceUnitWorker(n: number): ISyntaxToken {
|
||||
// First, make sure the cursor is pointing at a token.
|
||||
oldSourceUnitCursor.moveToFirstToken();
|
||||
|
||||
// Now, keep walking forward to successive tokens.
|
||||
for (var i = 0; i < n; i++) {
|
||||
var interimToken = oldSourceUnitCursor.currentToken();
|
||||
|
||||
if (!canReuseTokenFromOldSourceUnit(interimToken)) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
oldSourceUnitCursor.moveToNextSibling();
|
||||
}
|
||||
|
||||
var token = oldSourceUnitCursor.currentToken();
|
||||
return canReuseTokenFromOldSourceUnit(token) ? token : undefined;
|
||||
}
|
||||
|
||||
function consumeNodeOrToken(nodeOrToken: ISyntaxNodeOrToken): void {
|
||||
scannerParserSource.consumeNodeOrToken(nodeOrToken);
|
||||
}
|
||||
|
||||
return {
|
||||
text: text,
|
||||
fileName: oldSyntaxTree.fileName(),
|
||||
languageVersion: oldSyntaxTree.languageVersion(),
|
||||
absolutePosition: absolutePosition,
|
||||
currentNode: currentNode,
|
||||
currentToken: currentToken,
|
||||
currentContextualToken: currentContextualToken,
|
||||
peekToken: peekToken,
|
||||
consumeNodeOrToken: scannerParserSource.consumeNodeOrToken,
|
||||
tryParse: tryParse,
|
||||
diagnostics: diagnostics
|
||||
};
|
||||
}
|
||||
|
||||
function updateTokenPositionsAndMarkElements(element: ISyntaxElement, changeStart: number, changeRangeOldEnd: number, delta: number, fullStart: number): void {
|
||||
// First, try to skip past any elements that we dont' need to move. We don't need to
|
||||
// move any elements that don't start after the end of the change range.
|
||||
if (fullStart > changeRangeOldEnd) {
|
||||
// Note, we only move elements that are truly after the end of the change range.
|
||||
// We consider elements that are touching the end of the change range to be unusable.
|
||||
forceUpdateTokenPositionsForElement(element, delta);
|
||||
}
|
||||
else {
|
||||
// Check if the element intersects the change range. If it does, then it is not
|
||||
// reusable. Also, we'll need to recurse to see what constituent portions we may
|
||||
// be able to use.
|
||||
var fullEnd = fullStart + fullWidth(element);
|
||||
if (fullEnd >= changeStart) {
|
||||
(<ISyntaxElementInternal>element).intersectsChange = true;
|
||||
|
||||
if (isList(element)) {
|
||||
var list = <ISyntaxNodeOrToken[]>element;
|
||||
for (var i = 0, n = list.length; i < n; i++) {
|
||||
var child: ISyntaxElement = list[i];
|
||||
updateTokenPositionsAndMarkElements(child, changeStart, changeRangeOldEnd, delta, fullStart);
|
||||
fullStart += fullWidth(child);
|
||||
}
|
||||
}
|
||||
else if (isNode(element)) {
|
||||
var node = <ISyntaxNode>element;
|
||||
for (var i = 0, n = node.childCount; i < n; i++) {
|
||||
var child = node.childAt(i);
|
||||
if (child) {
|
||||
updateTokenPositionsAndMarkElements(child, changeStart, changeRangeOldEnd, delta, fullStart);
|
||||
fullStart += fullWidth(child);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// else {
|
||||
// This element ended strictly before the edited range. We don't need to do anything
|
||||
// with it.
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
function forceUpdateTokenPositionsForElement(element: ISyntaxElement, delta: number) {
|
||||
// No need to move anything if the delta is 0.
|
||||
if (delta !== 0) {
|
||||
if (isList(element)) {
|
||||
var list = <ISyntaxNodeOrToken[]>element;
|
||||
for (var i = 0, n = list.length; i < n; i++) {
|
||||
forceUpdateTokenPositionForNodeOrToken(list[i], delta);
|
||||
}
|
||||
}
|
||||
else {
|
||||
forceUpdateTokenPositionForNodeOrToken(<ISyntaxNodeOrToken>element, delta);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function forceUpdateTokenPosition(token: ISyntaxToken, delta: number) {
|
||||
token.setFullStart(token.fullStart() + delta);
|
||||
}
|
||||
|
||||
function forceUpdateTokenPositionForNodeOrToken(nodeOrToken: ISyntaxNodeOrToken, delta: number) {
|
||||
if (isToken(nodeOrToken)) {
|
||||
forceUpdateTokenPosition(<ISyntaxToken>nodeOrToken, delta);
|
||||
}
|
||||
else {
|
||||
var tokens = getTokens(<ISyntaxNode>nodeOrToken);
|
||||
for (var i = 0, n = tokens.length; i < n; i++) {
|
||||
forceUpdateTokenPosition(tokens[i], delta);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export function parse(oldSyntaxTree: SyntaxTree, textChangeRange: TextChangeRange, newText: ISimpleText): SyntaxTree {
|
||||
if (textChangeRange.isUnchanged()) {
|
||||
return oldSyntaxTree;
|
||||
}
|
||||
|
||||
return Parser.parseSource(createParserSource(oldSyntaxTree, textChangeRange, newText), oldSyntaxTree.isDeclaration());
|
||||
}
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
module TypeScript {
|
||||
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,50 +0,0 @@
|
||||
///<reference path='..\text\references.ts' />
|
||||
|
||||
///<reference path='characterInfo.ts' />
|
||||
///<reference path='constants.ts' />
|
||||
///<reference path='formattingOptions.ts' />
|
||||
// ///<reference path='indentation.ts' />
|
||||
///<reference path='languageVersion.ts' />
|
||||
|
||||
// Scanner depends on SyntaxKind and SyntaxFacts
|
||||
///<reference path='syntaxKind.ts' />
|
||||
///<reference path='syntaxFacts.ts' />
|
||||
///<reference path='scannerUtilities.generated.ts' />
|
||||
///<reference path='scanner.ts' />
|
||||
|
||||
///<reference path='slidingWindow.ts' />
|
||||
///<reference path='syntax.ts' />
|
||||
///<reference path='syntaxElement.ts' />
|
||||
///<reference path='syntaxFacts2.ts' />
|
||||
///<reference path='syntaxList.ts' />
|
||||
///<reference path='syntaxNodeOrToken.ts' />
|
||||
|
||||
// SyntaxDedenter depends on SyntaxRewriter
|
||||
// ///<reference path='syntaxDedenter.ts' />
|
||||
// SyntaxIndenter depends on SyntaxRewriter
|
||||
// ///<reference path='syntaxIndenter.ts' />
|
||||
|
||||
///<reference path='syntaxToken.ts' />
|
||||
///<reference path='syntaxTrivia.ts' />
|
||||
///<reference path='syntaxTriviaList.ts' />
|
||||
///<reference path='syntaxVisitor.generated.ts' />
|
||||
///<reference path='syntaxWalker.generated.ts' />
|
||||
|
||||
// SyntaxInformationMap depends on SyntaxWalker
|
||||
// ///<reference path='syntaxNodeInvariantsChecker.ts' />
|
||||
|
||||
// SyntaxUtilities depends on SyntaxWalker
|
||||
///<reference path='syntaxUtilities.ts' />
|
||||
|
||||
///<reference path='parser.ts' />
|
||||
|
||||
// Concrete nodes depend on the parser.
|
||||
///<reference path='syntaxInterfaces.generated.ts' />
|
||||
///<reference path='syntaxNodes.concrete.generated.ts' />
|
||||
|
||||
// SyntaxTree depends on PositionTrackingWalker
|
||||
///<reference path='syntaxTree.ts' />
|
||||
|
||||
///<reference path='unicode.ts' />
|
||||
///<reference path='syntaxCursor.ts' />
|
||||
///<reference path='incrementalParser.ts' />
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,150 +0,0 @@
|
||||
///<reference path='references.ts' />
|
||||
|
||||
module TypeScript {
|
||||
export module ScannerUtilities {
|
||||
export var fixedWidthArray = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 4, 5, 8, 8, 7, 6, 2, 4, 5, 7, 3, 8, 2, 2, 10, 3, 4, 6, 6, 4, 5, 4, 3, 6, 3, 4, 5, 4, 5, 5, 4, 6, 7, 6, 5, 10, 9, 3, 7, 7, 9, 6, 6, 5, 3, 5, 5, 7, 11, 7, 3, 6, 7, 6, 3, 4, 6, 1, 1, 1, 1, 1, 1, 1, 3, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 1, 1, 1, 1, 2, 2, 2, 2, 3, 1, 1, 1, 1, 1, 2, 2, 1, 1, 1, 2, 2, 2, 2, 3, 3, 4, 2, 2, 2, 1, 2];
|
||||
export function identifierKind(str: string, start: number, length: number): SyntaxKind {
|
||||
switch (length) {
|
||||
case 2: // do, if, in
|
||||
switch(str.charCodeAt(start)) {
|
||||
case CharacterCodes.d: return (str.charCodeAt(start + 1) === CharacterCodes.o) ? SyntaxKind.DoKeyword : SyntaxKind.IdentifierName;
|
||||
case CharacterCodes.i: // if, in
|
||||
switch(str.charCodeAt(start + 1)) {
|
||||
case CharacterCodes.f: return SyntaxKind.IfKeyword;
|
||||
case CharacterCodes.n: return SyntaxKind.InKeyword;
|
||||
default: return SyntaxKind.IdentifierName;
|
||||
}
|
||||
default: return SyntaxKind.IdentifierName;
|
||||
}
|
||||
case 3: // any, for, get, let, new, set, try, var
|
||||
switch(str.charCodeAt(start)) {
|
||||
case CharacterCodes.a: return (str.charCodeAt(start + 1) === CharacterCodes.n && str.charCodeAt(start + 2) === CharacterCodes.y) ? SyntaxKind.AnyKeyword : SyntaxKind.IdentifierName;
|
||||
case CharacterCodes.f: return (str.charCodeAt(start + 1) === CharacterCodes.o && str.charCodeAt(start + 2) === CharacterCodes.r) ? SyntaxKind.ForKeyword : SyntaxKind.IdentifierName;
|
||||
case CharacterCodes.g: return (str.charCodeAt(start + 1) === CharacterCodes.e && str.charCodeAt(start + 2) === CharacterCodes.t) ? SyntaxKind.GetKeyword : SyntaxKind.IdentifierName;
|
||||
case CharacterCodes.l: return (str.charCodeAt(start + 1) === CharacterCodes.e && str.charCodeAt(start + 2) === CharacterCodes.t) ? SyntaxKind.LetKeyword : SyntaxKind.IdentifierName;
|
||||
case CharacterCodes.n: return (str.charCodeAt(start + 1) === CharacterCodes.e && str.charCodeAt(start + 2) === CharacterCodes.w) ? SyntaxKind.NewKeyword : SyntaxKind.IdentifierName;
|
||||
case CharacterCodes.s: return (str.charCodeAt(start + 1) === CharacterCodes.e && str.charCodeAt(start + 2) === CharacterCodes.t) ? SyntaxKind.SetKeyword : SyntaxKind.IdentifierName;
|
||||
case CharacterCodes.t: return (str.charCodeAt(start + 1) === CharacterCodes.r && str.charCodeAt(start + 2) === CharacterCodes.y) ? SyntaxKind.TryKeyword : SyntaxKind.IdentifierName;
|
||||
case CharacterCodes.v: return (str.charCodeAt(start + 1) === CharacterCodes.a && str.charCodeAt(start + 2) === CharacterCodes.r) ? SyntaxKind.VarKeyword : SyntaxKind.IdentifierName;
|
||||
default: return SyntaxKind.IdentifierName;
|
||||
}
|
||||
case 4: // case, else, enum, null, this, true, type, void, with
|
||||
switch(str.charCodeAt(start)) {
|
||||
case CharacterCodes.c: return (str.charCodeAt(start + 1) === CharacterCodes.a && str.charCodeAt(start + 2) === CharacterCodes.s && str.charCodeAt(start + 3) === CharacterCodes.e) ? SyntaxKind.CaseKeyword : SyntaxKind.IdentifierName;
|
||||
case CharacterCodes.e: // else, enum
|
||||
switch(str.charCodeAt(start + 1)) {
|
||||
case CharacterCodes.l: return (str.charCodeAt(start + 2) === CharacterCodes.s && str.charCodeAt(start + 3) === CharacterCodes.e) ? SyntaxKind.ElseKeyword : SyntaxKind.IdentifierName;
|
||||
case CharacterCodes.n: return (str.charCodeAt(start + 2) === CharacterCodes.u && str.charCodeAt(start + 3) === CharacterCodes.m) ? SyntaxKind.EnumKeyword : SyntaxKind.IdentifierName;
|
||||
default: return SyntaxKind.IdentifierName;
|
||||
}
|
||||
case CharacterCodes.n: return (str.charCodeAt(start + 1) === CharacterCodes.u && str.charCodeAt(start + 2) === CharacterCodes.l && str.charCodeAt(start + 3) === CharacterCodes.l) ? SyntaxKind.NullKeyword : SyntaxKind.IdentifierName;
|
||||
case CharacterCodes.t: // this, true, type
|
||||
switch(str.charCodeAt(start + 1)) {
|
||||
case CharacterCodes.h: return (str.charCodeAt(start + 2) === CharacterCodes.i && str.charCodeAt(start + 3) === CharacterCodes.s) ? SyntaxKind.ThisKeyword : SyntaxKind.IdentifierName;
|
||||
case CharacterCodes.r: return (str.charCodeAt(start + 2) === CharacterCodes.u && str.charCodeAt(start + 3) === CharacterCodes.e) ? SyntaxKind.TrueKeyword : SyntaxKind.IdentifierName;
|
||||
case CharacterCodes.y: return (str.charCodeAt(start + 2) === CharacterCodes.p && str.charCodeAt(start + 3) === CharacterCodes.e) ? SyntaxKind.TypeKeyword : SyntaxKind.IdentifierName;
|
||||
default: return SyntaxKind.IdentifierName;
|
||||
}
|
||||
case CharacterCodes.v: return (str.charCodeAt(start + 1) === CharacterCodes.o && str.charCodeAt(start + 2) === CharacterCodes.i && str.charCodeAt(start + 3) === CharacterCodes.d) ? SyntaxKind.VoidKeyword : SyntaxKind.IdentifierName;
|
||||
case CharacterCodes.w: return (str.charCodeAt(start + 1) === CharacterCodes.i && str.charCodeAt(start + 2) === CharacterCodes.t && str.charCodeAt(start + 3) === CharacterCodes.h) ? SyntaxKind.WithKeyword : SyntaxKind.IdentifierName;
|
||||
default: return SyntaxKind.IdentifierName;
|
||||
}
|
||||
case 5: // async, await, break, catch, class, const, false, super, throw, while, yield
|
||||
switch(str.charCodeAt(start)) {
|
||||
case CharacterCodes.a: // async, await
|
||||
switch(str.charCodeAt(start + 1)) {
|
||||
case CharacterCodes.s: return (str.charCodeAt(start + 2) === CharacterCodes.y && str.charCodeAt(start + 3) === CharacterCodes.n && str.charCodeAt(start + 4) === CharacterCodes.c) ? SyntaxKind.AsyncKeyword : SyntaxKind.IdentifierName;
|
||||
case CharacterCodes.w: return (str.charCodeAt(start + 2) === CharacterCodes.a && str.charCodeAt(start + 3) === CharacterCodes.i && str.charCodeAt(start + 4) === CharacterCodes.t) ? SyntaxKind.AwaitKeyword : SyntaxKind.IdentifierName;
|
||||
default: return SyntaxKind.IdentifierName;
|
||||
}
|
||||
case CharacterCodes.b: return (str.charCodeAt(start + 1) === CharacterCodes.r && str.charCodeAt(start + 2) === CharacterCodes.e && str.charCodeAt(start + 3) === CharacterCodes.a && str.charCodeAt(start + 4) === CharacterCodes.k) ? SyntaxKind.BreakKeyword : SyntaxKind.IdentifierName;
|
||||
case CharacterCodes.c: // catch, class, const
|
||||
switch(str.charCodeAt(start + 1)) {
|
||||
case CharacterCodes.a: return (str.charCodeAt(start + 2) === CharacterCodes.t && str.charCodeAt(start + 3) === CharacterCodes.c && str.charCodeAt(start + 4) === CharacterCodes.h) ? SyntaxKind.CatchKeyword : SyntaxKind.IdentifierName;
|
||||
case CharacterCodes.l: return (str.charCodeAt(start + 2) === CharacterCodes.a && str.charCodeAt(start + 3) === CharacterCodes.s && str.charCodeAt(start + 4) === CharacterCodes.s) ? SyntaxKind.ClassKeyword : SyntaxKind.IdentifierName;
|
||||
case CharacterCodes.o: return (str.charCodeAt(start + 2) === CharacterCodes.n && str.charCodeAt(start + 3) === CharacterCodes.s && str.charCodeAt(start + 4) === CharacterCodes.t) ? SyntaxKind.ConstKeyword : SyntaxKind.IdentifierName;
|
||||
default: return SyntaxKind.IdentifierName;
|
||||
}
|
||||
case CharacterCodes.f: return (str.charCodeAt(start + 1) === CharacterCodes.a && str.charCodeAt(start + 2) === CharacterCodes.l && str.charCodeAt(start + 3) === CharacterCodes.s && str.charCodeAt(start + 4) === CharacterCodes.e) ? SyntaxKind.FalseKeyword : SyntaxKind.IdentifierName;
|
||||
case CharacterCodes.s: return (str.charCodeAt(start + 1) === CharacterCodes.u && str.charCodeAt(start + 2) === CharacterCodes.p && str.charCodeAt(start + 3) === CharacterCodes.e && str.charCodeAt(start + 4) === CharacterCodes.r) ? SyntaxKind.SuperKeyword : SyntaxKind.IdentifierName;
|
||||
case CharacterCodes.t: return (str.charCodeAt(start + 1) === CharacterCodes.h && str.charCodeAt(start + 2) === CharacterCodes.r && str.charCodeAt(start + 3) === CharacterCodes.o && str.charCodeAt(start + 4) === CharacterCodes.w) ? SyntaxKind.ThrowKeyword : SyntaxKind.IdentifierName;
|
||||
case CharacterCodes.w: return (str.charCodeAt(start + 1) === CharacterCodes.h && str.charCodeAt(start + 2) === CharacterCodes.i && str.charCodeAt(start + 3) === CharacterCodes.l && str.charCodeAt(start + 4) === CharacterCodes.e) ? SyntaxKind.WhileKeyword : SyntaxKind.IdentifierName;
|
||||
case CharacterCodes.y: return (str.charCodeAt(start + 1) === CharacterCodes.i && str.charCodeAt(start + 2) === CharacterCodes.e && str.charCodeAt(start + 3) === CharacterCodes.l && str.charCodeAt(start + 4) === CharacterCodes.d) ? SyntaxKind.YieldKeyword : SyntaxKind.IdentifierName;
|
||||
default: return SyntaxKind.IdentifierName;
|
||||
}
|
||||
case 6: // delete, export, import, module, number, public, return, static, string, switch, typeof
|
||||
switch(str.charCodeAt(start)) {
|
||||
case CharacterCodes.d: return (str.charCodeAt(start + 1) === CharacterCodes.e && str.charCodeAt(start + 2) === CharacterCodes.l && str.charCodeAt(start + 3) === CharacterCodes.e && str.charCodeAt(start + 4) === CharacterCodes.t && str.charCodeAt(start + 5) === CharacterCodes.e) ? SyntaxKind.DeleteKeyword : SyntaxKind.IdentifierName;
|
||||
case CharacterCodes.e: return (str.charCodeAt(start + 1) === CharacterCodes.x && str.charCodeAt(start + 2) === CharacterCodes.p && str.charCodeAt(start + 3) === CharacterCodes.o && str.charCodeAt(start + 4) === CharacterCodes.r && str.charCodeAt(start + 5) === CharacterCodes.t) ? SyntaxKind.ExportKeyword : SyntaxKind.IdentifierName;
|
||||
case CharacterCodes.i: return (str.charCodeAt(start + 1) === CharacterCodes.m && str.charCodeAt(start + 2) === CharacterCodes.p && str.charCodeAt(start + 3) === CharacterCodes.o && str.charCodeAt(start + 4) === CharacterCodes.r && str.charCodeAt(start + 5) === CharacterCodes.t) ? SyntaxKind.ImportKeyword : SyntaxKind.IdentifierName;
|
||||
case CharacterCodes.m: return (str.charCodeAt(start + 1) === CharacterCodes.o && str.charCodeAt(start + 2) === CharacterCodes.d && str.charCodeAt(start + 3) === CharacterCodes.u && str.charCodeAt(start + 4) === CharacterCodes.l && str.charCodeAt(start + 5) === CharacterCodes.e) ? SyntaxKind.ModuleKeyword : SyntaxKind.IdentifierName;
|
||||
case CharacterCodes.n: return (str.charCodeAt(start + 1) === CharacterCodes.u && str.charCodeAt(start + 2) === CharacterCodes.m && str.charCodeAt(start + 3) === CharacterCodes.b && str.charCodeAt(start + 4) === CharacterCodes.e && str.charCodeAt(start + 5) === CharacterCodes.r) ? SyntaxKind.NumberKeyword : SyntaxKind.IdentifierName;
|
||||
case CharacterCodes.p: return (str.charCodeAt(start + 1) === CharacterCodes.u && str.charCodeAt(start + 2) === CharacterCodes.b && str.charCodeAt(start + 3) === CharacterCodes.l && str.charCodeAt(start + 4) === CharacterCodes.i && str.charCodeAt(start + 5) === CharacterCodes.c) ? SyntaxKind.PublicKeyword : SyntaxKind.IdentifierName;
|
||||
case CharacterCodes.r: return (str.charCodeAt(start + 1) === CharacterCodes.e && str.charCodeAt(start + 2) === CharacterCodes.t && str.charCodeAt(start + 3) === CharacterCodes.u && str.charCodeAt(start + 4) === CharacterCodes.r && str.charCodeAt(start + 5) === CharacterCodes.n) ? SyntaxKind.ReturnKeyword : SyntaxKind.IdentifierName;
|
||||
case CharacterCodes.s: // static, string, switch
|
||||
switch(str.charCodeAt(start + 1)) {
|
||||
case CharacterCodes.t: // static, string
|
||||
switch(str.charCodeAt(start + 2)) {
|
||||
case CharacterCodes.a: return (str.charCodeAt(start + 3) === CharacterCodes.t && str.charCodeAt(start + 4) === CharacterCodes.i && str.charCodeAt(start + 5) === CharacterCodes.c) ? SyntaxKind.StaticKeyword : SyntaxKind.IdentifierName;
|
||||
case CharacterCodes.r: return (str.charCodeAt(start + 3) === CharacterCodes.i && str.charCodeAt(start + 4) === CharacterCodes.n && str.charCodeAt(start + 5) === CharacterCodes.g) ? SyntaxKind.StringKeyword : SyntaxKind.IdentifierName;
|
||||
default: return SyntaxKind.IdentifierName;
|
||||
}
|
||||
case CharacterCodes.w: return (str.charCodeAt(start + 2) === CharacterCodes.i && str.charCodeAt(start + 3) === CharacterCodes.t && str.charCodeAt(start + 4) === CharacterCodes.c && str.charCodeAt(start + 5) === CharacterCodes.h) ? SyntaxKind.SwitchKeyword : SyntaxKind.IdentifierName;
|
||||
default: return SyntaxKind.IdentifierName;
|
||||
}
|
||||
case CharacterCodes.t: return (str.charCodeAt(start + 1) === CharacterCodes.y && str.charCodeAt(start + 2) === CharacterCodes.p && str.charCodeAt(start + 3) === CharacterCodes.e && str.charCodeAt(start + 4) === CharacterCodes.o && str.charCodeAt(start + 5) === CharacterCodes.f) ? SyntaxKind.TypeOfKeyword : SyntaxKind.IdentifierName;
|
||||
default: return SyntaxKind.IdentifierName;
|
||||
}
|
||||
case 7: // boolean, declare, default, extends, finally, package, private, require
|
||||
switch(str.charCodeAt(start)) {
|
||||
case CharacterCodes.b: return (str.charCodeAt(start + 1) === CharacterCodes.o && str.charCodeAt(start + 2) === CharacterCodes.o && str.charCodeAt(start + 3) === CharacterCodes.l && str.charCodeAt(start + 4) === CharacterCodes.e && str.charCodeAt(start + 5) === CharacterCodes.a && str.charCodeAt(start + 6) === CharacterCodes.n) ? SyntaxKind.BooleanKeyword : SyntaxKind.IdentifierName;
|
||||
case CharacterCodes.d: // declare, default
|
||||
switch(str.charCodeAt(start + 1)) {
|
||||
case CharacterCodes.e: // declare, default
|
||||
switch(str.charCodeAt(start + 2)) {
|
||||
case CharacterCodes.c: return (str.charCodeAt(start + 3) === CharacterCodes.l && str.charCodeAt(start + 4) === CharacterCodes.a && str.charCodeAt(start + 5) === CharacterCodes.r && str.charCodeAt(start + 6) === CharacterCodes.e) ? SyntaxKind.DeclareKeyword : SyntaxKind.IdentifierName;
|
||||
case CharacterCodes.f: return (str.charCodeAt(start + 3) === CharacterCodes.a && str.charCodeAt(start + 4) === CharacterCodes.u && str.charCodeAt(start + 5) === CharacterCodes.l && str.charCodeAt(start + 6) === CharacterCodes.t) ? SyntaxKind.DefaultKeyword : SyntaxKind.IdentifierName;
|
||||
default: return SyntaxKind.IdentifierName;
|
||||
}
|
||||
default: return SyntaxKind.IdentifierName;
|
||||
}
|
||||
case CharacterCodes.e: return (str.charCodeAt(start + 1) === CharacterCodes.x && str.charCodeAt(start + 2) === CharacterCodes.t && str.charCodeAt(start + 3) === CharacterCodes.e && str.charCodeAt(start + 4) === CharacterCodes.n && str.charCodeAt(start + 5) === CharacterCodes.d && str.charCodeAt(start + 6) === CharacterCodes.s) ? SyntaxKind.ExtendsKeyword : SyntaxKind.IdentifierName;
|
||||
case CharacterCodes.f: return (str.charCodeAt(start + 1) === CharacterCodes.i && str.charCodeAt(start + 2) === CharacterCodes.n && str.charCodeAt(start + 3) === CharacterCodes.a && str.charCodeAt(start + 4) === CharacterCodes.l && str.charCodeAt(start + 5) === CharacterCodes.l && str.charCodeAt(start + 6) === CharacterCodes.y) ? SyntaxKind.FinallyKeyword : SyntaxKind.IdentifierName;
|
||||
case CharacterCodes.p: // package, private
|
||||
switch(str.charCodeAt(start + 1)) {
|
||||
case CharacterCodes.a: return (str.charCodeAt(start + 2) === CharacterCodes.c && str.charCodeAt(start + 3) === CharacterCodes.k && str.charCodeAt(start + 4) === CharacterCodes.a && str.charCodeAt(start + 5) === CharacterCodes.g && str.charCodeAt(start + 6) === CharacterCodes.e) ? SyntaxKind.PackageKeyword : SyntaxKind.IdentifierName;
|
||||
case CharacterCodes.r: return (str.charCodeAt(start + 2) === CharacterCodes.i && str.charCodeAt(start + 3) === CharacterCodes.v && str.charCodeAt(start + 4) === CharacterCodes.a && str.charCodeAt(start + 5) === CharacterCodes.t && str.charCodeAt(start + 6) === CharacterCodes.e) ? SyntaxKind.PrivateKeyword : SyntaxKind.IdentifierName;
|
||||
default: return SyntaxKind.IdentifierName;
|
||||
}
|
||||
case CharacterCodes.r: return (str.charCodeAt(start + 1) === CharacterCodes.e && str.charCodeAt(start + 2) === CharacterCodes.q && str.charCodeAt(start + 3) === CharacterCodes.u && str.charCodeAt(start + 4) === CharacterCodes.i && str.charCodeAt(start + 5) === CharacterCodes.r && str.charCodeAt(start + 6) === CharacterCodes.e) ? SyntaxKind.RequireKeyword : SyntaxKind.IdentifierName;
|
||||
default: return SyntaxKind.IdentifierName;
|
||||
}
|
||||
case 8: // continue, debugger, function
|
||||
switch(str.charCodeAt(start)) {
|
||||
case CharacterCodes.c: return (str.charCodeAt(start + 1) === CharacterCodes.o && str.charCodeAt(start + 2) === CharacterCodes.n && str.charCodeAt(start + 3) === CharacterCodes.t && str.charCodeAt(start + 4) === CharacterCodes.i && str.charCodeAt(start + 5) === CharacterCodes.n && str.charCodeAt(start + 6) === CharacterCodes.u && str.charCodeAt(start + 7) === CharacterCodes.e) ? SyntaxKind.ContinueKeyword : SyntaxKind.IdentifierName;
|
||||
case CharacterCodes.d: return (str.charCodeAt(start + 1) === CharacterCodes.e && str.charCodeAt(start + 2) === CharacterCodes.b && str.charCodeAt(start + 3) === CharacterCodes.u && str.charCodeAt(start + 4) === CharacterCodes.g && str.charCodeAt(start + 5) === CharacterCodes.g && str.charCodeAt(start + 6) === CharacterCodes.e && str.charCodeAt(start + 7) === CharacterCodes.r) ? SyntaxKind.DebuggerKeyword : SyntaxKind.IdentifierName;
|
||||
case CharacterCodes.f: return (str.charCodeAt(start + 1) === CharacterCodes.u && str.charCodeAt(start + 2) === CharacterCodes.n && str.charCodeAt(start + 3) === CharacterCodes.c && str.charCodeAt(start + 4) === CharacterCodes.t && str.charCodeAt(start + 5) === CharacterCodes.i && str.charCodeAt(start + 6) === CharacterCodes.o && str.charCodeAt(start + 7) === CharacterCodes.n) ? SyntaxKind.FunctionKeyword : SyntaxKind.IdentifierName;
|
||||
default: return SyntaxKind.IdentifierName;
|
||||
}
|
||||
case 9: // interface, protected
|
||||
switch(str.charCodeAt(start)) {
|
||||
case CharacterCodes.i: return (str.charCodeAt(start + 1) === CharacterCodes.n && str.charCodeAt(start + 2) === CharacterCodes.t && str.charCodeAt(start + 3) === CharacterCodes.e && str.charCodeAt(start + 4) === CharacterCodes.r && str.charCodeAt(start + 5) === CharacterCodes.f && str.charCodeAt(start + 6) === CharacterCodes.a && str.charCodeAt(start + 7) === CharacterCodes.c && str.charCodeAt(start + 8) === CharacterCodes.e) ? SyntaxKind.InterfaceKeyword : SyntaxKind.IdentifierName;
|
||||
case CharacterCodes.p: return (str.charCodeAt(start + 1) === CharacterCodes.r && str.charCodeAt(start + 2) === CharacterCodes.o && str.charCodeAt(start + 3) === CharacterCodes.t && str.charCodeAt(start + 4) === CharacterCodes.e && str.charCodeAt(start + 5) === CharacterCodes.c && str.charCodeAt(start + 6) === CharacterCodes.t && str.charCodeAt(start + 7) === CharacterCodes.e && str.charCodeAt(start + 8) === CharacterCodes.d) ? SyntaxKind.ProtectedKeyword : SyntaxKind.IdentifierName;
|
||||
default: return SyntaxKind.IdentifierName;
|
||||
}
|
||||
case 10: // implements, instanceof
|
||||
switch(str.charCodeAt(start)) {
|
||||
case CharacterCodes.i: // implements, instanceof
|
||||
switch(str.charCodeAt(start + 1)) {
|
||||
case CharacterCodes.m: return (str.charCodeAt(start + 2) === CharacterCodes.p && str.charCodeAt(start + 3) === CharacterCodes.l && str.charCodeAt(start + 4) === CharacterCodes.e && str.charCodeAt(start + 5) === CharacterCodes.m && str.charCodeAt(start + 6) === CharacterCodes.e && str.charCodeAt(start + 7) === CharacterCodes.n && str.charCodeAt(start + 8) === CharacterCodes.t && str.charCodeAt(start + 9) === CharacterCodes.s) ? SyntaxKind.ImplementsKeyword : SyntaxKind.IdentifierName;
|
||||
case CharacterCodes.n: return (str.charCodeAt(start + 2) === CharacterCodes.s && str.charCodeAt(start + 3) === CharacterCodes.t && str.charCodeAt(start + 4) === CharacterCodes.a && str.charCodeAt(start + 5) === CharacterCodes.n && str.charCodeAt(start + 6) === CharacterCodes.c && str.charCodeAt(start + 7) === CharacterCodes.e && str.charCodeAt(start + 8) === CharacterCodes.o && str.charCodeAt(start + 9) === CharacterCodes.f) ? SyntaxKind.InstanceOfKeyword : SyntaxKind.IdentifierName;
|
||||
default: return SyntaxKind.IdentifierName;
|
||||
}
|
||||
default: return SyntaxKind.IdentifierName;
|
||||
}
|
||||
case 11: return (str.charCodeAt(start) === CharacterCodes.c && str.charCodeAt(start + 1) === CharacterCodes.o && str.charCodeAt(start + 2) === CharacterCodes.n && str.charCodeAt(start + 3) === CharacterCodes.s && str.charCodeAt(start + 4) === CharacterCodes.t && str.charCodeAt(start + 5) === CharacterCodes.r && str.charCodeAt(start + 6) === CharacterCodes.u && str.charCodeAt(start + 7) === CharacterCodes.c && str.charCodeAt(start + 8) === CharacterCodes.t && str.charCodeAt(start + 9) === CharacterCodes.o && str.charCodeAt(start + 10) === CharacterCodes.r) ? SyntaxKind.ConstructorKeyword : SyntaxKind.IdentifierName;
|
||||
default: return SyntaxKind.IdentifierName;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,197 +0,0 @@
|
||||
///<reference path='references.ts' />
|
||||
|
||||
module TypeScript {
|
||||
export interface ISlidingWindowSource {
|
||||
// Asks the source to copy items starting at sourceIndex into the window at 'destinationIndex'
|
||||
// with up to 'spaceAvailable' items. The actual number of items fetched should be given as
|
||||
// the return value.
|
||||
(argument: any): any;
|
||||
}
|
||||
|
||||
export class SlidingWindow {
|
||||
|
||||
// The number of valid items in window.
|
||||
public windowCount: number = 0;
|
||||
|
||||
// The *absolute* index in the *full* array of items the *window* array starts at. i.e.
|
||||
// if there were 100 items, and window contains tokens [70, 80), then this value would be
|
||||
// 70.
|
||||
public windowAbsoluteStartIndex: number = 0;
|
||||
|
||||
// The index in the window array that we're at. i.e. if there 100 items and
|
||||
// window contains tokens [70, 80), and we're on item 75, then this value would be '5'.
|
||||
// Note: it is not absolute. It is relative to the start of the window.
|
||||
public currentRelativeItemIndex: number = 0;
|
||||
|
||||
// The number of pinned points there are. As long as there is at least one pinned point, we
|
||||
// will not advance the start of the window array past the item marked by that pin point.
|
||||
private _pinCount: number = 0;
|
||||
|
||||
// If there are any outstanding rewind points, this is index in the full array of items
|
||||
// that the first rewind point points to. If this is not -1, then we will not shift the
|
||||
// start of the items array past this point.
|
||||
private firstPinnedAbsoluteIndex: number = -1;
|
||||
|
||||
constructor(// Underlying source that we retrieve items from.
|
||||
private fetchNextItem: ISlidingWindowSource,
|
||||
// A window of items that has been read in from the underlying source.
|
||||
public window: any[],
|
||||
// The default value to return when there are no more items left in the window.
|
||||
private defaultValue: any,
|
||||
// The length of the source we're reading from if we know it up front. -1 if we do not.
|
||||
private sourceLength = -1) {
|
||||
}
|
||||
|
||||
private addMoreItemsToWindow(argument: any): boolean {
|
||||
var sourceLength = this.sourceLength;
|
||||
if (sourceLength >= 0 && this.absoluteIndex() >= sourceLength) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// First, make room for the new items if we're out of room.
|
||||
if (this.windowCount >= this.window.length) {
|
||||
this.tryShiftOrGrowWindow();
|
||||
}
|
||||
|
||||
var item = this.fetchNextItem(argument);
|
||||
|
||||
this.window[this.windowCount] = item;
|
||||
|
||||
// Assert disabled because it is actually expensive enugh to affect perf.
|
||||
|
||||
this.windowCount++;
|
||||
return true;
|
||||
}
|
||||
|
||||
private tryShiftOrGrowWindow(): void {
|
||||
// We want to shift if our current item is past the halfway point of the current item window.
|
||||
var currentIndexIsPastWindowHalfwayPoint = this.currentRelativeItemIndex > (this.window.length >>> 1);
|
||||
|
||||
// However, we can only shift if we have no outstanding rewind points. Or, if we have an
|
||||
// outstanding rewind point, that it points to some point after the start of the window.
|
||||
var isAllowedToShift =
|
||||
this.firstPinnedAbsoluteIndex === -1 ||
|
||||
this.firstPinnedAbsoluteIndex > this.windowAbsoluteStartIndex;
|
||||
|
||||
if (currentIndexIsPastWindowHalfwayPoint && isAllowedToShift) {
|
||||
// Figure out where we're going to start shifting from. If we have no oustanding rewind
|
||||
// points, then we'll start shifting over all the items starting from the current
|
||||
// token we're point out. Otherwise, we'll shift starting from the first item that
|
||||
// the rewind point is pointing at.
|
||||
//
|
||||
// We'll call that point 'N' from now on.
|
||||
var shiftStartIndex = this.firstPinnedAbsoluteIndex === -1
|
||||
? this.currentRelativeItemIndex
|
||||
: this.firstPinnedAbsoluteIndex - this.windowAbsoluteStartIndex;
|
||||
|
||||
// We have to shift the number of elements between the start index and the number of
|
||||
// items in the window.
|
||||
var shiftCount = this.windowCount - shiftStartIndex;
|
||||
|
||||
// Debug.assert(shiftStartIndex > 0);
|
||||
if (shiftCount > 0) {
|
||||
ArrayUtilities.copy(this.window, shiftStartIndex, this.window, 0, shiftCount);
|
||||
}
|
||||
|
||||
// The window has now moved over to the right by N.
|
||||
this.windowAbsoluteStartIndex += shiftStartIndex;
|
||||
|
||||
// The number of valid items in the window has now decreased by N.
|
||||
this.windowCount -= shiftStartIndex;
|
||||
|
||||
// The current item now starts further to the left in the window.
|
||||
this.currentRelativeItemIndex -= shiftStartIndex;
|
||||
}
|
||||
else {
|
||||
// Grow the exisitng array.
|
||||
// this.window[this.window.length * 2 - 1] = this.defaultValue;
|
||||
ArrayUtilities.grow(this.window, this.window.length * 2, this.defaultValue);
|
||||
}
|
||||
}
|
||||
|
||||
public absoluteIndex(): number {
|
||||
return this.windowAbsoluteStartIndex + this.currentRelativeItemIndex;
|
||||
}
|
||||
|
||||
public isAtEndOfSource(): boolean {
|
||||
return this.absoluteIndex() >= this.sourceLength;
|
||||
}
|
||||
|
||||
public getAndPinAbsoluteIndex(): number {
|
||||
// Find the absolute index of this pin point. i.e. it's the index as if we had an
|
||||
// array containing *all* tokens.
|
||||
var absoluteIndex = this.absoluteIndex();
|
||||
var pinCount = this._pinCount++;
|
||||
if (pinCount === 0) {
|
||||
// If this is the first pinned point, then store off this index. We will ensure that
|
||||
// we never shift the window past this point.
|
||||
this.firstPinnedAbsoluteIndex = absoluteIndex;
|
||||
}
|
||||
|
||||
return absoluteIndex;
|
||||
}
|
||||
|
||||
public releaseAndUnpinAbsoluteIndex(absoluteIndex: number) {
|
||||
this._pinCount--;
|
||||
if (this._pinCount === 0) {
|
||||
// If we just released the last outstanding pin, then we no longer need to 'fix' the
|
||||
// token window so it can't move forward. Set the index to -1 so that we can shift
|
||||
// things over the next time we read past the end of the array.
|
||||
this.firstPinnedAbsoluteIndex = -1;
|
||||
}
|
||||
}
|
||||
|
||||
public rewindToPinnedIndex(absoluteIndex: number): void {
|
||||
// The rewind point shows which absolute item we want to rewind to. Get the relative
|
||||
// index in the actual array that we want to point to.
|
||||
var relativeIndex = absoluteIndex - this.windowAbsoluteStartIndex;
|
||||
|
||||
// Make sure we haven't screwed anything up.
|
||||
// Debug.assert(relativeIndex >= 0 && relativeIndex < this.windowCount);
|
||||
|
||||
// Set ourselves back to that point.
|
||||
this.currentRelativeItemIndex = relativeIndex;
|
||||
}
|
||||
|
||||
public currentItem(argument: any): any {
|
||||
if (this.currentRelativeItemIndex >= this.windowCount) {
|
||||
if (!this.addMoreItemsToWindow(argument)) {
|
||||
return this.defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
return this.window[this.currentRelativeItemIndex];
|
||||
}
|
||||
|
||||
public currentItemWithoutFetching(): any {
|
||||
if (this.currentRelativeItemIndex >= this.windowCount) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
return this.window[this.currentRelativeItemIndex];
|
||||
}
|
||||
|
||||
public peekItemN(n: number): any {
|
||||
// Assert disabled because it is actually expensive enugh to affect perf.
|
||||
// Debug.assert(n >= 0);
|
||||
while (this.currentRelativeItemIndex + n >= this.windowCount) {
|
||||
if (!this.addMoreItemsToWindow(/*argument:*/ undefined)) {
|
||||
return this.defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
return this.window[this.currentRelativeItemIndex + n];
|
||||
}
|
||||
|
||||
public moveToNextItem(): void {
|
||||
this.currentRelativeItemIndex++;
|
||||
}
|
||||
|
||||
public disgardAllItemsFromCurrentIndexOnwards(): void {
|
||||
// By setting the window count to the current relative offset, we are effectively making
|
||||
// any items we added to the window from the current offset onwards unusable. When we
|
||||
// try to get the next item, we'll be forced to refetch them from the underlying source.
|
||||
this.windowCount = this.currentRelativeItemIndex;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,140 +0,0 @@
|
||||
///<reference path='references.ts' />
|
||||
|
||||
module TypeScript.Syntax {
|
||||
export var _nextSyntaxID: number = 1;
|
||||
|
||||
export function nodeHasSkippedOrMissingTokens(node: ISyntaxNode): boolean {
|
||||
for (var i = 0; i < childCount(node); i++) {
|
||||
var child = childAt(node, i);
|
||||
if (isToken(child)) {
|
||||
var token = <ISyntaxToken>child;
|
||||
// If a token is skipped, return true. Or if it is a missing token. The only empty token that is not missing is EOF
|
||||
if (token.hasLeadingSkippedToken() || (fullWidth(token) === 0 && token.kind !== SyntaxKind.EndOfFileToken)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
export function isUnterminatedStringLiteral(token: ISyntaxToken): boolean {
|
||||
if (token && token.kind === SyntaxKind.StringLiteral) {
|
||||
var text = token.text();
|
||||
return text.length < 2 || text.charCodeAt(text.length - 1) !== text.charCodeAt(0);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
export function isUnterminatedMultilineCommentTrivia(trivia: ISyntaxTrivia): boolean {
|
||||
if (trivia && trivia.kind === SyntaxKind.MultiLineCommentTrivia) {
|
||||
var text = trivia.fullText();
|
||||
return text.length < 4 || text.substring(text.length - 2) !== "*/";
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
export function isEntirelyInsideCommentTrivia(trivia: ISyntaxTrivia, fullStart: number, position: number): boolean {
|
||||
if (trivia && trivia.isComment() && position > fullStart) {
|
||||
var end = fullStart + trivia.fullWidth();
|
||||
if (position < end) {
|
||||
return true;
|
||||
}
|
||||
else if (position === end) {
|
||||
return trivia.kind === SyntaxKind.SingleLineCommentTrivia || isUnterminatedMultilineCommentTrivia(trivia);
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
export function getAncestorOfKind(positionedToken: ISyntaxElement, kind: SyntaxKind): ISyntaxElement {
|
||||
while (positionedToken && positionedToken.parent) {
|
||||
if (positionedToken.parent.kind === kind) {
|
||||
return positionedToken.parent;
|
||||
}
|
||||
|
||||
positionedToken = positionedToken.parent;
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
export function hasAncestorOfKind(positionedToken: ISyntaxElement, kind: SyntaxKind): boolean {
|
||||
return !!getAncestorOfKind(positionedToken, kind);
|
||||
}
|
||||
|
||||
export function isIntegerLiteral(expression: IExpressionSyntax): boolean {
|
||||
if (expression) {
|
||||
switch (expression.kind) {
|
||||
case SyntaxKind.PrefixUnaryExpression:
|
||||
var prefixExpr = <PrefixUnaryExpressionSyntax>expression;
|
||||
if (prefixExpr.operatorToken.kind == SyntaxKind.PlusToken || prefixExpr.operatorToken.kind === SyntaxKind.MinusToken) {
|
||||
// Note: if there is a + or - sign, we can only allow a normal integer following
|
||||
// (and not a hex integer). i.e. -0xA is a legal expression, but it is not a
|
||||
// *literal*.
|
||||
expression = prefixExpr.operand;
|
||||
return isToken(expression) && IntegerUtilities.isInteger((<ISyntaxToken>expression).text());
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
case SyntaxKind.NumericLiteral:
|
||||
// If it doesn't have a + or -, then either an integer literal or a hex literal
|
||||
// is acceptable.
|
||||
var text = (<ISyntaxToken> expression).text();
|
||||
return IntegerUtilities.isInteger(text) || IntegerUtilities.isHexInteger(text);
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
export function containingNode(element: ISyntaxElement): ISyntaxNode {
|
||||
var current = element.parent;
|
||||
|
||||
while (current && !isNode(current)) {
|
||||
current = current.parent;
|
||||
}
|
||||
|
||||
return <ISyntaxNode>current;
|
||||
}
|
||||
|
||||
export function findTokenOnLeft(sourceUnit: SourceUnitSyntax, position: number): ISyntaxToken {
|
||||
var positionedToken = findToken(sourceUnit, position);
|
||||
var _start = start(positionedToken);
|
||||
|
||||
// Position better fall within this token.
|
||||
// Debug.assert(position >= positionedToken.fullStart());
|
||||
// Debug.assert(position < positionedToken.fullEnd() || positionedToken.token().tokenKind === SyntaxKind.EndOfFileToken);
|
||||
|
||||
// if position is after the start of the token, then this token is the token on the left.
|
||||
if (position > _start) {
|
||||
return positionedToken;
|
||||
}
|
||||
|
||||
// we're in the trivia before the start of the token. Need to return the previous token.
|
||||
if (positionedToken.fullStart() === 0) {
|
||||
// Already on the first token. Nothing before us.
|
||||
return undefined;
|
||||
}
|
||||
|
||||
return previousToken(positionedToken);
|
||||
}
|
||||
|
||||
export function findCompleteTokenOnLeft(sourceUnit: SourceUnitSyntax, position: number): ISyntaxToken {
|
||||
var positionedToken = findToken(sourceUnit, position);
|
||||
|
||||
// Position better fall within this token.
|
||||
// Debug.assert(position >= positionedToken.fullStart());
|
||||
// Debug.assert(position < positionedToken.fullEnd() || positionedToken.token().tokenKind === SyntaxKind.EndOfFileToken);
|
||||
|
||||
// if position is after the end of the token, then this token is the token on the left.
|
||||
if (width(positionedToken) > 0 && position >= fullEnd(positionedToken)) {
|
||||
return positionedToken;
|
||||
}
|
||||
|
||||
return previousToken(positionedToken);
|
||||
}
|
||||
}
|
||||
@@ -1,255 +0,0 @@
|
||||
/// <reference path="references.ts" />
|
||||
|
||||
module TypeScript.IncrementalParser {
|
||||
interface SyntaxCursorPiece {
|
||||
element: ISyntaxElement;
|
||||
indexInParent: number
|
||||
}
|
||||
|
||||
function createSyntaxCursorPiece(element: ISyntaxElement, indexInParent: number) {
|
||||
return { element: element, indexInParent: indexInParent };
|
||||
}
|
||||
|
||||
// Pool syntax cursors so we don't churn too much memory when we need temporary cursors.
|
||||
// i.e. when we're speculatively parsing, we can cheaply get a pooled cursor and then
|
||||
// return it when we no longer need it.
|
||||
var syntaxCursorPool: SyntaxCursor[] = [];
|
||||
var syntaxCursorPoolCount: number = 0;
|
||||
|
||||
export function returnSyntaxCursor(cursor: SyntaxCursor): void {
|
||||
// Make sure the cursor isn't holding onto any syntax elements. We don't want to leak
|
||||
// them when we return the cursor to the pool.
|
||||
cursor.clean();
|
||||
|
||||
syntaxCursorPool[syntaxCursorPoolCount] = cursor;
|
||||
syntaxCursorPoolCount++;
|
||||
}
|
||||
|
||||
export function getSyntaxCursor(): SyntaxCursor {
|
||||
// Get an existing cursor from the pool if we have one. Or create a new one if we don't.
|
||||
var cursor = syntaxCursorPoolCount > 0
|
||||
? syntaxCursorPool[syntaxCursorPoolCount - 1]
|
||||
: createSyntaxCursor();
|
||||
|
||||
if (syntaxCursorPoolCount > 0) {
|
||||
// If we reused an existing cursor, take it out of the pool so no one else uses it.
|
||||
syntaxCursorPoolCount--;
|
||||
syntaxCursorPool[syntaxCursorPoolCount] = undefined;
|
||||
}
|
||||
|
||||
return cursor;
|
||||
}
|
||||
|
||||
export function cloneSyntaxCursor(cursor: SyntaxCursor): SyntaxCursor {
|
||||
var newCursor = getSyntaxCursor();
|
||||
|
||||
// Make the new cursor a *deep* copy of the cursor passed in. This ensures each cursor can
|
||||
// be moved without affecting the other.
|
||||
newCursor.deepCopyFrom(cursor);
|
||||
|
||||
return newCursor;
|
||||
}
|
||||
|
||||
interface SyntaxCursor {
|
||||
pieces: SyntaxCursorPiece[];
|
||||
|
||||
clean(): void;
|
||||
isFinished(): boolean;
|
||||
moveToFirstChild(): void;
|
||||
moveToFirstToken(): void;
|
||||
moveToNextSibling(): void;
|
||||
currentNodeOrToken(): ISyntaxNodeOrToken;
|
||||
currentNode(): ISyntaxNode;
|
||||
currentToken(): ISyntaxToken;
|
||||
pushElement(element: ISyntaxElement, indexInParent: number): void;
|
||||
deepCopyFrom(other: SyntaxCursor): void;
|
||||
}
|
||||
|
||||
function createSyntaxCursor(): SyntaxCursor {
|
||||
// Our list of path pieces. The piece pointed to by 'currentPieceIndex' must be a node or
|
||||
// token. However, pieces earlier than that may point to list nodes.
|
||||
//
|
||||
// For perf we reuse pieces as much as possible. i.e. instead of popping items off the
|
||||
// list, we just will change currentPieceIndex so we can reuse that piece later.
|
||||
var pieces: SyntaxCursorPiece[] = [];
|
||||
var currentPieceIndex: number = -1;
|
||||
|
||||
// Cleans up this cursor so that it doesn't have any references to actual syntax nodes.
|
||||
// This sould be done before returning the cursor to the pool so that the Parser module
|
||||
// doesn't unnecessarily keep old syntax trees alive.
|
||||
function clean(): void {
|
||||
for (var i = 0, n = pieces.length; i < n; i++) {
|
||||
var piece = pieces[i];
|
||||
|
||||
if (piece.element === undefined) {
|
||||
break;
|
||||
}
|
||||
|
||||
piece.element = undefined;
|
||||
piece.indexInParent = -1;
|
||||
}
|
||||
|
||||
currentPieceIndex = -1;
|
||||
}
|
||||
|
||||
// Makes this cursor into a deep copy of the cursor passed in.
|
||||
function deepCopyFrom(other: SyntaxCursor): void {
|
||||
for (var i = 0, n = other.pieces.length; i < n; i++) {
|
||||
var piece = other.pieces[i];
|
||||
|
||||
if (piece.element === undefined) {
|
||||
break;
|
||||
}
|
||||
|
||||
pushElement(piece.element, piece.indexInParent);
|
||||
}
|
||||
}
|
||||
|
||||
function isFinished(): boolean {
|
||||
return currentPieceIndex < 0;
|
||||
}
|
||||
|
||||
function currentNodeOrToken(): ISyntaxNodeOrToken {
|
||||
if (isFinished()) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
var result = pieces[currentPieceIndex].element;
|
||||
|
||||
// The current element must always be a node or a token.
|
||||
return <ISyntaxNodeOrToken>result;
|
||||
}
|
||||
|
||||
function currentNode(): ISyntaxNode {
|
||||
var element = currentNodeOrToken();
|
||||
return isNode(element) ? <ISyntaxNode>element : undefined;
|
||||
}
|
||||
|
||||
function isEmptyList(element: ISyntaxElement) {
|
||||
return isList(element) && (<ISyntaxNodeOrToken[]>element).length === 0;
|
||||
}
|
||||
|
||||
function moveToFirstChild() {
|
||||
var nodeOrToken = currentNodeOrToken();
|
||||
if (nodeOrToken === undefined) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (isToken(nodeOrToken)) {
|
||||
// If we're already on a token, there's nothing to do.
|
||||
return;
|
||||
}
|
||||
|
||||
// Either the node has some existent child, then move to it. if it doesn't, then it's
|
||||
// an empty node. Conceptually the first child of an empty node is really just the
|
||||
// next sibling of the empty node.
|
||||
for (var i = 0, n = childCount(nodeOrToken); i < n; i++) {
|
||||
var child = childAt(nodeOrToken, i);
|
||||
if (child && !isEmptyList(child)) {
|
||||
// Great, we found a real child. Push that.
|
||||
pushElement(child, /*indexInParent:*/ i);
|
||||
|
||||
// If it was a list, make sure we're pointing at its first element. We know we
|
||||
// must have one because this is a non-shared list.
|
||||
moveToFirstChildIfList();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// This element must have been an empty node. Moving to its 'first child' is equivalent to just
|
||||
// moving to the next sibling.
|
||||
moveToNextSibling();
|
||||
}
|
||||
|
||||
function moveToNextSibling(): void {
|
||||
while (!isFinished()) {
|
||||
// first look to our parent and see if it has a sibling of us that we can move to.
|
||||
var currentPiece = pieces[currentPieceIndex];
|
||||
var parent = currentPiece.element.parent;
|
||||
|
||||
// We start searching at the index one past our own index in the parent.
|
||||
for (var i = currentPiece.indexInParent + 1, n = childCount(parent); i < n; i++) {
|
||||
var sibling = childAt(parent, i);
|
||||
|
||||
if (sibling && !isEmptyList(sibling)) {
|
||||
// We found a good sibling that we can move to. Just reuse our existing piece
|
||||
// so we don't have to push/pop.
|
||||
currentPiece.element = sibling;
|
||||
currentPiece.indexInParent = i;
|
||||
|
||||
// The sibling might have been a list. Move to it's first child.
|
||||
moveToFirstChildIfList();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Didn't have a sibling for this element. Go up to our parent and get its sibling.
|
||||
|
||||
// Clear the data from the old piece. We don't want to keep any elements around
|
||||
// unintentionally.
|
||||
currentPiece.element = undefined;
|
||||
currentPiece.indexInParent = -1;
|
||||
|
||||
// Point at the parent. if we move past the top of the path, then we're finished.
|
||||
currentPieceIndex--;
|
||||
}
|
||||
}
|
||||
|
||||
function moveToFirstChildIfList(): void {
|
||||
var element = pieces[currentPieceIndex].element;
|
||||
|
||||
if (isList(element)) {
|
||||
// We cannot ever get an empty list in our piece path. Empty lists are 'shared' and
|
||||
// we make sure to filter that out before pushing any children.
|
||||
pushElement(childAt(element, 0), /*indexInParent:*/ 0);
|
||||
}
|
||||
}
|
||||
|
||||
function pushElement(element: ISyntaxElement, indexInParent: number): void {
|
||||
currentPieceIndex++;
|
||||
|
||||
// Reuse an existing piece if we have one. Otherwise, push a new piece to our list.
|
||||
if (currentPieceIndex === pieces.length) {
|
||||
pieces.push(createSyntaxCursorPiece(element, indexInParent));
|
||||
}
|
||||
else {
|
||||
var piece = pieces[currentPieceIndex];
|
||||
piece.element = element;
|
||||
piece.indexInParent = indexInParent;
|
||||
}
|
||||
}
|
||||
|
||||
function moveToFirstToken(): void {
|
||||
while (!isFinished()) {
|
||||
var element = pieces[currentPieceIndex].element;
|
||||
if (isNode(element)) {
|
||||
moveToFirstChild();
|
||||
continue;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
function currentToken(): ISyntaxToken {
|
||||
moveToFirstToken();
|
||||
|
||||
var element = currentNodeOrToken();
|
||||
return <ISyntaxToken>element;
|
||||
}
|
||||
|
||||
return {
|
||||
pieces: pieces,
|
||||
clean: clean,
|
||||
isFinished: isFinished,
|
||||
moveToFirstChild: moveToFirstChild,
|
||||
moveToFirstToken: moveToFirstToken,
|
||||
moveToNextSibling: moveToNextSibling,
|
||||
currentNodeOrToken: currentNodeOrToken,
|
||||
currentNode: currentNode,
|
||||
currentToken: currentToken,
|
||||
pushElement: pushElement,
|
||||
deepCopyFrom: deepCopyFrom
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -1,193 +0,0 @@
|
||||
///<reference path='references.ts' />
|
||||
|
||||
module TypeScript {
|
||||
export class SyntaxDedenter extends SyntaxRewriter {
|
||||
private lastTriviaWasNewLine: boolean;
|
||||
|
||||
constructor(dedentFirstToken: boolean,
|
||||
private dedentationAmount: number,
|
||||
private minimumIndent: number,
|
||||
private options: FormattingOptions) {
|
||||
super();
|
||||
this.lastTriviaWasNewLine = dedentFirstToken;
|
||||
}
|
||||
|
||||
private abort(): void {
|
||||
this.lastTriviaWasNewLine = false;
|
||||
this.dedentationAmount = 0;
|
||||
}
|
||||
|
||||
private isAborted(): boolean {
|
||||
return this.dedentationAmount === 0;
|
||||
}
|
||||
|
||||
public visitToken(token: ISyntaxToken): ISyntaxToken {
|
||||
if (token.width() === 0) {
|
||||
return token;
|
||||
}
|
||||
|
||||
var result = token;
|
||||
if (this.lastTriviaWasNewLine) {
|
||||
// have to add our indentation to every line that this token hits.
|
||||
result = token.withLeadingTrivia(this.dedentTriviaList(token.leadingTrivia()));
|
||||
}
|
||||
|
||||
if (this.isAborted()) {
|
||||
// If we've decided to stop dedenting. Then just return immediately.
|
||||
return token;
|
||||
}
|
||||
|
||||
this.lastTriviaWasNewLine = token.hasTrailingNewLine();
|
||||
return result;
|
||||
}
|
||||
|
||||
private dedentTriviaList(triviaList: ISyntaxTriviaList): ISyntaxTriviaList {
|
||||
var result: ISyntaxTrivia[] = [];
|
||||
var dedentNextWhitespace = true;
|
||||
|
||||
// Keep walking through all our trivia (as long as we haven't decided to stop dedenting).
|
||||
// Adjust the indentation on any whitespace trivia at the start of a line, or any multi-line
|
||||
// trivia that span multiple lines.
|
||||
for (var i = 0, n = triviaList.count(); i < n && !this.isAborted(); i++) {
|
||||
var trivia = triviaList.syntaxTriviaAt(i);
|
||||
|
||||
var dedentThisTrivia = dedentNextWhitespace;
|
||||
dedentNextWhitespace = false;
|
||||
|
||||
if (dedentThisTrivia) {
|
||||
if (trivia.kind() === SyntaxKind.WhitespaceTrivia) {
|
||||
// We pass in if there was a following newline after this whitespace. If there
|
||||
// is, then it's fine if we dedent this newline all the way to 0. Otherwise,
|
||||
// if the whitespace is followed by something, then we need to determine how
|
||||
// much of the whitespace we can remove. If we can't remove all that we want,
|
||||
// we'll need to adjust the dedentAmount. And, if we can't remove at all, then
|
||||
// we need to stop dedenting entirely.
|
||||
var hasFollowingNewLine = (i < triviaList.count() - 1) &&
|
||||
triviaList.syntaxTriviaAt(i + 1).kind() === SyntaxKind.NewLineTrivia;
|
||||
result.push(this.dedentWhitespace(trivia, hasFollowingNewLine));
|
||||
continue;
|
||||
}
|
||||
else if (trivia.kind() !== SyntaxKind.NewLineTrivia) {
|
||||
// We wanted to dedent, but the trivia we're on isn't whitespace and wasn't a
|
||||
// newline. That means that we have something like a comment at the beginning
|
||||
// of the line that we can't dedent. And, if we can't dedent it, then we
|
||||
// shouldn't dedent this token or any more tokens.
|
||||
this.abort();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (trivia.kind() === SyntaxKind.MultiLineCommentTrivia) {
|
||||
// This trivia may span multiple lines. If it does, we need to dedent each
|
||||
// successive line of it until it terminates.
|
||||
result.push(this.dedentMultiLineComment(trivia));
|
||||
continue;
|
||||
}
|
||||
|
||||
// All other trivia we just append to the list.
|
||||
result.push(trivia);
|
||||
if (trivia.kind() === SyntaxKind.NewLineTrivia) {
|
||||
// We hit a newline processing the trivia. We need to add the indentation to the
|
||||
// next line as well.
|
||||
dedentNextWhitespace = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (dedentNextWhitespace) {
|
||||
// We hit a new line as the last trivia (or there was no trivia). We want to dedent
|
||||
// the next trivia, but we can't (because the token starts at the start of the line).
|
||||
// If we can't dedent this, then we shouldn't dedent anymore.
|
||||
this.abort();
|
||||
}
|
||||
|
||||
if (this.isAborted()) {
|
||||
return triviaList;
|
||||
}
|
||||
|
||||
return Syntax.triviaList(result);
|
||||
}
|
||||
|
||||
private dedentSegment(segment: string, hasFollowingNewLineTrivia: boolean): string {
|
||||
// Find the position of the first non whitespace character in the segment.
|
||||
var firstNonWhitespacePosition = Indentation.firstNonWhitespacePosition(segment);
|
||||
|
||||
if (firstNonWhitespacePosition === segment.length) {
|
||||
if (hasFollowingNewLineTrivia) {
|
||||
// It was entirely whitespace trivia, with a newline after it. Just trim this down
|
||||
// to an empty string.
|
||||
return "";
|
||||
}
|
||||
}
|
||||
else if (CharacterInfo.isLineTerminator(segment.charCodeAt(firstNonWhitespacePosition))) {
|
||||
// It was entirely whitespace, with a newline after it. Just trim this down to
|
||||
// the newline
|
||||
return segment.substring(firstNonWhitespacePosition);
|
||||
}
|
||||
|
||||
// It was whitespace without a newline following it. We need to try to dedent this a bit.
|
||||
|
||||
// Convert that position to a column.
|
||||
var firstNonWhitespaceColumn = Indentation.columnForPositionInString(segment, firstNonWhitespacePosition, this.options);
|
||||
|
||||
// Find the new column we want the nonwhitespace text to start at. Ideally it would be
|
||||
// whatever column it was minus the dedentation amount. However, we won't go below a
|
||||
// specified minimum indent (hence, max(initial - dedentAmount, minIndent). *But* if
|
||||
// the initial column was less than that minimum indent, then we'll keep it at that column.
|
||||
// (hence min(initial, desired)).
|
||||
var newFirstNonWhitespaceColumn =
|
||||
MathPrototype.min(firstNonWhitespaceColumn,
|
||||
MathPrototype.max(firstNonWhitespaceColumn - this.dedentationAmount, this.minimumIndent));
|
||||
|
||||
if (newFirstNonWhitespaceColumn === firstNonWhitespaceColumn) {
|
||||
// We aren't able to detent this token. Abort what we're doing
|
||||
this.abort();
|
||||
return segment;
|
||||
}
|
||||
|
||||
// Update the dedentation amount for all subsequent tokens we run into.
|
||||
this.dedentationAmount = firstNonWhitespaceColumn - newFirstNonWhitespaceColumn;
|
||||
Debug.assert(this.dedentationAmount >= 0);
|
||||
|
||||
// Compute an indentation string for that.
|
||||
var indentationString = Indentation.indentationString(newFirstNonWhitespaceColumn, this.options);
|
||||
|
||||
// Join the new indentation and the original string without its indentation.
|
||||
return indentationString + segment.substring(firstNonWhitespacePosition);
|
||||
}
|
||||
|
||||
private dedentWhitespace(trivia: ISyntaxTrivia, hasFollowingNewLineTrivia: boolean): ISyntaxTrivia {
|
||||
var newIndentation = this.dedentSegment(trivia.fullText(), hasFollowingNewLineTrivia);
|
||||
return Syntax.whitespace(newIndentation);
|
||||
}
|
||||
|
||||
private dedentMultiLineComment(trivia: ISyntaxTrivia): ISyntaxTrivia {
|
||||
var segments = Syntax.splitMultiLineCommentTriviaIntoMultipleLines(trivia);
|
||||
if (segments.length === 1) {
|
||||
// If there was only one segment, then this wasn't multiline.
|
||||
return trivia;
|
||||
}
|
||||
|
||||
for (var i = 1; i < segments.length; i++) {
|
||||
var segment = segments[i];
|
||||
segments[i] = this.dedentSegment(segment, /*hasFollowingNewLineTrivia*/ false);
|
||||
}
|
||||
|
||||
var result = segments.join("");
|
||||
|
||||
// Create a new trivia token out of the indented lines.
|
||||
return Syntax.multiLineComment(result);
|
||||
}
|
||||
|
||||
public static dedentNode<T extends ISyntaxNode>(node: T, dedentFirstToken: boolean, dedentAmount: number, minimumIndent: number, options: FormattingOptions): T {
|
||||
var dedenter = new SyntaxDedenter(dedentFirstToken, dedentAmount, minimumIndent, options);
|
||||
var result = node.accept(dedenter);
|
||||
|
||||
if (dedenter.isAborted()) {
|
||||
// We failed to dedent a token in this node. Return the original node as is.
|
||||
return node;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,465 +0,0 @@
|
||||
///<reference path='references.ts' />
|
||||
|
||||
module TypeScript {
|
||||
export function syntaxTree(element: ISyntaxElement): SyntaxTree {
|
||||
if (element) {
|
||||
// Debug.assert(!isShared(element));
|
||||
|
||||
while (element) {
|
||||
if (element.kind === SyntaxKind.SourceUnit) {
|
||||
return (<SourceUnitSyntax>element).syntaxTree;
|
||||
}
|
||||
|
||||
element = element.parent;
|
||||
}
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
export function parserContextFlags(node: ISyntaxNode): ParserContextFlags {
|
||||
var info = node.__data;
|
||||
if (info === undefined) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return info & ParserContextFlags.Mask;
|
||||
}
|
||||
|
||||
export function parsedInStrictModeContext(node: ISyntaxNode): boolean {
|
||||
return (parserContextFlags(node) & ParserContextFlags.StrictMode) !== 0;
|
||||
}
|
||||
|
||||
export function parsedInDisallowInContext(node: ISyntaxNode): boolean {
|
||||
return (parserContextFlags(node) & ParserContextFlags.DisallowIn) !== 0;
|
||||
}
|
||||
|
||||
export function parsedInYieldContext(node: ISyntaxNode): boolean {
|
||||
return (parserContextFlags(node) & ParserContextFlags.Yield) !== 0;
|
||||
}
|
||||
|
||||
export function parsedInGeneratorParameterContext(node: ISyntaxNode): boolean {
|
||||
return (parserContextFlags(node) & ParserContextFlags.GeneratorParameter) !== 0;
|
||||
}
|
||||
|
||||
export function parsedInAsyncContext(node: ISyntaxNode): boolean {
|
||||
return (parserContextFlags(node) & ParserContextFlags.Async) !== 0;
|
||||
}
|
||||
|
||||
export function previousToken(token: ISyntaxToken): ISyntaxToken {
|
||||
var start = token.fullStart();
|
||||
if (start === 0) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
return findToken(syntaxTree(token).sourceUnit(), start - 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds a token according to the following rules:
|
||||
* 1) If position matches the End of the node/s FullSpan and the node is SourceUnitSyntax,
|
||||
* then the EOF token is returned.
|
||||
*
|
||||
* 2) If node.FullSpan.Contains(position) then the token that contains given position is
|
||||
* returned.
|
||||
*
|
||||
* 3) Otherwise an ArgumentOutOfRangeException is thrown
|
||||
*
|
||||
* Note: findToken will always return a non-missing token with width greater than or equal to
|
||||
* 1 (except for EOF). Empty tokens synthesized by the parser are never returned.
|
||||
*/
|
||||
export function findToken(sourceUnit: SourceUnitSyntax, position: number): ISyntaxToken {
|
||||
if (position < 0) {
|
||||
throw Errors.argumentOutOfRange("position");
|
||||
}
|
||||
|
||||
var token = findTokenInNodeOrToken(sourceUnit, 0, position);
|
||||
if (token) {
|
||||
Debug.assert(token.fullWidth() > 0);
|
||||
return token;
|
||||
}
|
||||
|
||||
if (position === fullWidth(sourceUnit)) {
|
||||
return sourceUnit.endOfFileToken;
|
||||
}
|
||||
|
||||
if (position > fullWidth(sourceUnit)) {
|
||||
throw Errors.argumentOutOfRange("position");
|
||||
}
|
||||
|
||||
throw Errors.invalidOperation();
|
||||
}
|
||||
|
||||
function findTokenWorker(element: ISyntaxElement, elementPosition: number, position: number): ISyntaxToken {
|
||||
if (isList(element)) {
|
||||
return findTokenInList(<ISyntaxNodeOrToken[]>element, elementPosition, position);
|
||||
}
|
||||
else {
|
||||
return findTokenInNodeOrToken(<ISyntaxNodeOrToken>element, elementPosition, position);
|
||||
}
|
||||
}
|
||||
|
||||
function findTokenInList(list: ISyntaxNodeOrToken[], elementPosition: number, position: number): ISyntaxToken {
|
||||
for (var i = 0, n = list.length; i < n; i++) {
|
||||
var child = list[i];
|
||||
|
||||
var childFullWidth = fullWidth(child);
|
||||
var elementEndPosition = elementPosition + childFullWidth;
|
||||
|
||||
if (position < elementEndPosition) {
|
||||
return findTokenWorker(child, elementPosition, position);
|
||||
}
|
||||
|
||||
elementPosition = elementEndPosition;
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
|
||||
function findTokenInNodeOrToken(nodeOrToken: ISyntaxNodeOrToken, elementPosition: number, position: number): ISyntaxToken {
|
||||
if (isToken(nodeOrToken)) {
|
||||
return <ISyntaxToken>nodeOrToken;
|
||||
}
|
||||
|
||||
for (var i = 0, n = childCount(nodeOrToken); i < n; i++) {
|
||||
var child = nodeOrToken.childAt(i);
|
||||
|
||||
if (child) {
|
||||
var childFullWidth = fullWidth(child);
|
||||
var elementEndPosition = elementPosition + childFullWidth;
|
||||
|
||||
if (position < elementEndPosition) {
|
||||
return findTokenWorker(child, elementPosition, position);
|
||||
}
|
||||
|
||||
elementPosition = elementEndPosition;
|
||||
}
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
function tryGetEndOfFileAt(element: ISyntaxElement, position: number): ISyntaxToken {
|
||||
if (element.kind === SyntaxKind.SourceUnit && position === fullWidth(element)) {
|
||||
var sourceUnit = <SourceUnitSyntax>element;
|
||||
return sourceUnit.endOfFileToken;
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
export function nextToken(token: ISyntaxToken, text?: ISimpleText): ISyntaxToken {
|
||||
if (token.kind === SyntaxKind.EndOfFileToken) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
return findToken(syntaxTree(token).sourceUnit(), fullEnd(token));
|
||||
}
|
||||
|
||||
export function isNode(element: ISyntaxElement): boolean {
|
||||
if (element) {
|
||||
var kind = element.kind;
|
||||
return kind >= SyntaxKind.FirstNode && kind <= SyntaxKind.LastNode;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function isTokenKind(kind: SyntaxKind) {
|
||||
return kind >= SyntaxKind.FirstToken && kind <= SyntaxKind.LastToken
|
||||
}
|
||||
|
||||
export function isToken(element: ISyntaxElement): boolean {
|
||||
if (element) {
|
||||
return isTokenKind(element.kind);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
export function isList(element: ISyntaxElement): boolean {
|
||||
return element instanceof Array;
|
||||
}
|
||||
|
||||
export function syntaxID(element: ISyntaxElement): number {
|
||||
//if (isShared(element)) {
|
||||
// throw Errors.invalidOperation("Should not use shared syntax element as a key.");
|
||||
//}
|
||||
|
||||
var obj = <any>element;
|
||||
if (obj._syntaxID === undefined) {
|
||||
obj._syntaxID = TypeScript.Syntax._nextSyntaxID++;
|
||||
}
|
||||
|
||||
return obj._syntaxID;
|
||||
}
|
||||
|
||||
function collectTextElements(element: ISyntaxElement, elements: string[], text: ISimpleText): void {
|
||||
if (element) {
|
||||
if (isToken(element)) {
|
||||
elements.push((<ISyntaxToken>element).fullText(text));
|
||||
}
|
||||
else {
|
||||
for (var i = 0, n = childCount(element); i < n; i++) {
|
||||
collectTextElements(childAt(element, i), elements, text);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export function fullText(element: ISyntaxElement, text?: ISimpleText): string {
|
||||
if (isToken(element)) {
|
||||
return (<ISyntaxToken>element).fullText(text);
|
||||
}
|
||||
|
||||
var elements: string[] = [];
|
||||
collectTextElements(element, elements, text);
|
||||
|
||||
return elements.join("");
|
||||
}
|
||||
|
||||
export function leadingTriviaWidth(element: ISyntaxElement, text?: ISimpleText): number {
|
||||
var token = firstToken(element);
|
||||
return token ? token.leadingTriviaWidth(text) : 0;
|
||||
}
|
||||
|
||||
export function firstToken(element: ISyntaxElement): ISyntaxToken {
|
||||
if (element) {
|
||||
var kind = element.kind;
|
||||
|
||||
if (isTokenKind(kind)) {
|
||||
return (<ISyntaxToken>element).fullWidth() > 0 || kind === SyntaxKind.EndOfFileToken ? <ISyntaxToken>element : undefined;
|
||||
}
|
||||
|
||||
for (var i = 0, n = childCount(element); i < n; i++) {
|
||||
var token = firstToken(childAt(element, i));
|
||||
if (token) {
|
||||
return token;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
export function lastToken(element: ISyntaxElement): ISyntaxToken {
|
||||
if (isToken(element)) {
|
||||
return fullWidth(element) > 0 || element.kind === SyntaxKind.EndOfFileToken ? <ISyntaxToken>element : undefined;
|
||||
}
|
||||
|
||||
if (element.kind === SyntaxKind.SourceUnit) {
|
||||
return (<SourceUnitSyntax>element).endOfFileToken;
|
||||
}
|
||||
|
||||
for (var i = childCount(element) - 1; i >= 0; i--) {
|
||||
var child = childAt(element, i);
|
||||
if (child) {
|
||||
var token = lastToken(child);
|
||||
if (token) {
|
||||
return token;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
export function fullStart(element: ISyntaxElement): number {
|
||||
// Debug.assert(!isShared(element));
|
||||
var token = isToken(element) ? <ISyntaxToken>element : firstToken(element);
|
||||
return token ? token.fullStart() : -1;
|
||||
}
|
||||
|
||||
export function fullWidth(element: ISyntaxElement): number {
|
||||
if (isToken(element)) {
|
||||
return (<ISyntaxToken>element).fullWidth();
|
||||
}
|
||||
|
||||
var info = data(element);
|
||||
return (info / SyntaxNodeConstants.FullWidthShift) | 0;
|
||||
}
|
||||
|
||||
export function isIncrementallyUnusable(element: ISyntaxElement): boolean {
|
||||
if (isToken(element)) {
|
||||
return (<ISyntaxToken>element).isIncrementallyUnusable();
|
||||
}
|
||||
|
||||
return (data(element) & SyntaxNodeConstants.IncrementallyUnusableMask) !== 0;
|
||||
}
|
||||
|
||||
function data(element: ISyntaxElement): number {
|
||||
// Debug.assert(isNode(element) || isList(element));
|
||||
|
||||
// Lists and nodes all have a 'data' element.
|
||||
var dataElement = <ISyntaxNode>element;
|
||||
|
||||
var info = dataElement.__data;
|
||||
if (info === undefined) {
|
||||
info = 0;
|
||||
}
|
||||
|
||||
if ((info & SyntaxNodeConstants.DataComputed) === 0) {
|
||||
info += computeData(element);
|
||||
dataElement.__data = info;
|
||||
}
|
||||
|
||||
return info;
|
||||
}
|
||||
|
||||
function combineData(fullWidth: number, isIncrementallyUnusable: boolean) {
|
||||
return (fullWidth * SyntaxNodeConstants.FullWidthShift) +
|
||||
(isIncrementallyUnusable ? SyntaxNodeConstants.IncrementallyUnusableMask : 0) +
|
||||
SyntaxNodeConstants.DataComputed;
|
||||
}
|
||||
|
||||
function listComputeData(list: ISyntaxNodeOrToken[]): number {
|
||||
var fullWidth = 0;
|
||||
var isIncrementallyUnusable = false;
|
||||
|
||||
for (var i = 0, n = list.length; i < n; i++) {
|
||||
var child: ISyntaxElement = list[i];
|
||||
|
||||
fullWidth += TypeScript.fullWidth(child);
|
||||
isIncrementallyUnusable = isIncrementallyUnusable || TypeScript.isIncrementallyUnusable(child);
|
||||
}
|
||||
|
||||
return combineData(fullWidth, isIncrementallyUnusable);
|
||||
}
|
||||
|
||||
function computeData(element: ISyntaxElement): number {
|
||||
if (isList(element)) {
|
||||
return listComputeData(<ISyntaxNodeOrToken[]>element);
|
||||
}
|
||||
else {
|
||||
return nodeOrTokenComputeData(<ISyntaxNodeOrToken>element);
|
||||
}
|
||||
}
|
||||
|
||||
function nodeOrTokenComputeData(nodeOrToken: ISyntaxNodeOrToken) {
|
||||
var fullWidth = 0;
|
||||
var slotCount = nodeOrToken.childCount;
|
||||
|
||||
// If we have no children (like an OmmittedExpressionSyntax), we're automatically not reusable.
|
||||
var isIncrementallyUnusable = slotCount === 0;
|
||||
|
||||
for (var i = 0, n = slotCount; i < n; i++) {
|
||||
var child = nodeOrToken.childAt(i);
|
||||
|
||||
if (child) {
|
||||
fullWidth += TypeScript.fullWidth(child);
|
||||
isIncrementallyUnusable = isIncrementallyUnusable || TypeScript.isIncrementallyUnusable(child);
|
||||
}
|
||||
}
|
||||
|
||||
return combineData(fullWidth, isIncrementallyUnusable);
|
||||
}
|
||||
|
||||
export function start(element: ISyntaxElement, text?: ISimpleText): number {
|
||||
var token = isToken(element) ? <ISyntaxToken>element : firstToken(element);
|
||||
return token ? token.fullStart() + token.leadingTriviaWidth(text) : -1;
|
||||
}
|
||||
|
||||
export function width(element: ISyntaxElement, text?: ISimpleText): number {
|
||||
if (isToken(element)) {
|
||||
return (<ISyntaxToken>element).text().length;
|
||||
}
|
||||
return fullWidth(element) - leadingTriviaWidth(element, text);
|
||||
}
|
||||
|
||||
export function fullEnd(element: ISyntaxElement): number {
|
||||
return fullStart(element) + fullWidth(element);
|
||||
}
|
||||
|
||||
export interface ISyntaxElement {
|
||||
kind: SyntaxKind;
|
||||
parent: ISyntaxElement;
|
||||
}
|
||||
|
||||
export interface ISyntaxNode extends ISyntaxNodeOrToken {
|
||||
__data: number;
|
||||
}
|
||||
|
||||
export interface IModuleReferenceSyntax extends ISyntaxNode {
|
||||
_moduleReferenceBrand: any;
|
||||
}
|
||||
|
||||
export interface IModuleElementSyntax extends ISyntaxNode {
|
||||
_moduleElementBrand: any;
|
||||
}
|
||||
|
||||
export interface IStatementSyntax extends IModuleElementSyntax {
|
||||
_statementBrand: any;
|
||||
}
|
||||
|
||||
export interface ITypeMemberSyntax extends ISyntaxNode {
|
||||
_typeMemberBrand: any;
|
||||
}
|
||||
|
||||
export interface IClassElementSyntax extends ISyntaxNode {
|
||||
_classElementBrand: any;
|
||||
}
|
||||
|
||||
export interface IMemberDeclarationSyntax extends IClassElementSyntax {
|
||||
_memberDeclarationBrand: any;
|
||||
}
|
||||
|
||||
export interface IPropertyAssignmentSyntax extends ISyntaxNodeOrToken {
|
||||
_propertyAssignmentBrand: any;
|
||||
}
|
||||
|
||||
export interface IAccessorSyntax extends IPropertyAssignmentSyntax, IMemberDeclarationSyntax {
|
||||
_accessorBrand: any;
|
||||
|
||||
modifiers: ISyntaxToken[];
|
||||
propertyName: IPropertyNameSyntax;
|
||||
callSignature: CallSignatureSyntax;
|
||||
body: BlockSyntax | ExpressionBody | ISyntaxToken;
|
||||
}
|
||||
|
||||
export interface ISwitchClauseSyntax extends ISyntaxNode {
|
||||
_switchClauseBrand: any;
|
||||
statements: IStatementSyntax[];
|
||||
}
|
||||
|
||||
export interface IExpressionSyntax extends ISyntaxNodeOrToken {
|
||||
_expressionBrand: any;
|
||||
}
|
||||
|
||||
export interface IUnaryExpressionSyntax extends IExpressionSyntax {
|
||||
_unaryExpressionBrand: any;
|
||||
}
|
||||
|
||||
export interface IPostfixExpressionSyntax extends IUnaryExpressionSyntax {
|
||||
_postfixExpressionBrand: any;
|
||||
}
|
||||
|
||||
export interface ILeftHandSideExpressionSyntax extends IPostfixExpressionSyntax {
|
||||
_leftHandSideExpressionBrand: any;
|
||||
}
|
||||
|
||||
export interface IMemberExpressionSyntax extends ILeftHandSideExpressionSyntax {
|
||||
_memberExpressionBrand: any;
|
||||
}
|
||||
|
||||
export interface ICallExpressionSyntax extends ILeftHandSideExpressionSyntax {
|
||||
_callExpressionBrand: any;
|
||||
expression: IExpressionSyntax;
|
||||
}
|
||||
|
||||
export interface IPrimaryExpressionSyntax extends IMemberExpressionSyntax {
|
||||
_primaryExpressionBrand: any;
|
||||
}
|
||||
|
||||
export interface ITypeSyntax extends ISyntaxNodeOrToken {
|
||||
_typeBrand: any;
|
||||
}
|
||||
|
||||
export interface INameSyntax extends ITypeSyntax {
|
||||
_nameBrand: any;
|
||||
}
|
||||
|
||||
export interface IPropertyNameSyntax extends ISyntaxNodeOrToken {
|
||||
_propertyNameBrand: any;
|
||||
}
|
||||
}
|
||||
@@ -1,250 +0,0 @@
|
||||
///<reference path='syntaxKind.ts' />
|
||||
|
||||
module TypeScript.SyntaxFacts {
|
||||
var textToKeywordKind: any = {
|
||||
"any": SyntaxKind.AnyKeyword,
|
||||
"async": SyntaxKind.AsyncKeyword,
|
||||
"await": SyntaxKind.AwaitKeyword,
|
||||
"boolean": SyntaxKind.BooleanKeyword,
|
||||
"break": SyntaxKind.BreakKeyword,
|
||||
"case": SyntaxKind.CaseKeyword,
|
||||
"catch": SyntaxKind.CatchKeyword,
|
||||
"class": SyntaxKind.ClassKeyword,
|
||||
"continue": SyntaxKind.ContinueKeyword,
|
||||
"const": SyntaxKind.ConstKeyword,
|
||||
"constructor": SyntaxKind.ConstructorKeyword,
|
||||
"debugger": SyntaxKind.DebuggerKeyword,
|
||||
"declare": SyntaxKind.DeclareKeyword,
|
||||
"default": SyntaxKind.DefaultKeyword,
|
||||
"delete": SyntaxKind.DeleteKeyword,
|
||||
"do": SyntaxKind.DoKeyword,
|
||||
"else": SyntaxKind.ElseKeyword,
|
||||
"enum": SyntaxKind.EnumKeyword,
|
||||
"export": SyntaxKind.ExportKeyword,
|
||||
"extends": SyntaxKind.ExtendsKeyword,
|
||||
"false": SyntaxKind.FalseKeyword,
|
||||
"finally": SyntaxKind.FinallyKeyword,
|
||||
"for": SyntaxKind.ForKeyword,
|
||||
"function": SyntaxKind.FunctionKeyword,
|
||||
"get": SyntaxKind.GetKeyword,
|
||||
"if": SyntaxKind.IfKeyword,
|
||||
"implements": SyntaxKind.ImplementsKeyword,
|
||||
"import": SyntaxKind.ImportKeyword,
|
||||
"in": SyntaxKind.InKeyword,
|
||||
"instanceof": SyntaxKind.InstanceOfKeyword,
|
||||
"interface": SyntaxKind.InterfaceKeyword,
|
||||
"let": SyntaxKind.LetKeyword,
|
||||
"module": SyntaxKind.ModuleKeyword,
|
||||
"new": SyntaxKind.NewKeyword,
|
||||
"null": SyntaxKind.NullKeyword,
|
||||
"number":SyntaxKind.NumberKeyword,
|
||||
"package": SyntaxKind.PackageKeyword,
|
||||
"private": SyntaxKind.PrivateKeyword,
|
||||
"protected": SyntaxKind.ProtectedKeyword,
|
||||
"public": SyntaxKind.PublicKeyword,
|
||||
"require": SyntaxKind.RequireKeyword,
|
||||
"return": SyntaxKind.ReturnKeyword,
|
||||
"set": SyntaxKind.SetKeyword,
|
||||
"static": SyntaxKind.StaticKeyword,
|
||||
"string": SyntaxKind.StringKeyword,
|
||||
"super": SyntaxKind.SuperKeyword,
|
||||
"switch": SyntaxKind.SwitchKeyword,
|
||||
"this": SyntaxKind.ThisKeyword,
|
||||
"throw": SyntaxKind.ThrowKeyword,
|
||||
"true": SyntaxKind.TrueKeyword,
|
||||
"try": SyntaxKind.TryKeyword,
|
||||
"type": SyntaxKind.TypeKeyword,
|
||||
"typeof": SyntaxKind.TypeOfKeyword,
|
||||
"var": SyntaxKind.VarKeyword,
|
||||
"void": SyntaxKind.VoidKeyword,
|
||||
"while": SyntaxKind.WhileKeyword,
|
||||
"with": SyntaxKind.WithKeyword,
|
||||
"yield": SyntaxKind.YieldKeyword,
|
||||
|
||||
"{": SyntaxKind.OpenBraceToken,
|
||||
"}": SyntaxKind.CloseBraceToken,
|
||||
"(": SyntaxKind.OpenParenToken,
|
||||
")": SyntaxKind.CloseParenToken,
|
||||
"[": SyntaxKind.OpenBracketToken,
|
||||
"]": SyntaxKind.CloseBracketToken,
|
||||
".": SyntaxKind.DotToken,
|
||||
"...": SyntaxKind.DotDotDotToken,
|
||||
";": SyntaxKind.SemicolonToken,
|
||||
",": SyntaxKind.CommaToken,
|
||||
"<": SyntaxKind.LessThanToken,
|
||||
">": SyntaxKind.GreaterThanToken,
|
||||
"<=": SyntaxKind.LessThanEqualsToken,
|
||||
">=": SyntaxKind.GreaterThanEqualsToken,
|
||||
"==": SyntaxKind.EqualsEqualsToken,
|
||||
"=>": SyntaxKind.EqualsGreaterThanToken,
|
||||
"!=": SyntaxKind.ExclamationEqualsToken,
|
||||
"===": SyntaxKind.EqualsEqualsEqualsToken,
|
||||
"!==": SyntaxKind.ExclamationEqualsEqualsToken,
|
||||
"+": SyntaxKind.PlusToken,
|
||||
"-": SyntaxKind.MinusToken,
|
||||
"*": SyntaxKind.AsteriskToken,
|
||||
"%": SyntaxKind.PercentToken,
|
||||
"++": SyntaxKind.PlusPlusToken,
|
||||
"--": SyntaxKind.MinusMinusToken,
|
||||
"<<": SyntaxKind.LessThanLessThanToken,
|
||||
">>": SyntaxKind.GreaterThanGreaterThanToken,
|
||||
">>>": SyntaxKind.GreaterThanGreaterThanGreaterThanToken,
|
||||
"&": SyntaxKind.AmpersandToken,
|
||||
"|": SyntaxKind.BarToken,
|
||||
"^": SyntaxKind.CaretToken,
|
||||
"!": SyntaxKind.ExclamationToken,
|
||||
"~": SyntaxKind.TildeToken,
|
||||
"&&": SyntaxKind.AmpersandAmpersandToken,
|
||||
"||": SyntaxKind.BarBarToken,
|
||||
"?": SyntaxKind.QuestionToken,
|
||||
":": SyntaxKind.ColonToken,
|
||||
"=": SyntaxKind.EqualsToken,
|
||||
"+=": SyntaxKind.PlusEqualsToken,
|
||||
"-=": SyntaxKind.MinusEqualsToken,
|
||||
"*=": SyntaxKind.AsteriskEqualsToken,
|
||||
"%=": SyntaxKind.PercentEqualsToken,
|
||||
"<<=": SyntaxKind.LessThanLessThanEqualsToken,
|
||||
">>=": SyntaxKind.GreaterThanGreaterThanEqualsToken,
|
||||
">>>=": SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken,
|
||||
"&=": SyntaxKind.AmpersandEqualsToken,
|
||||
"|=": SyntaxKind.BarEqualsToken,
|
||||
"^=": SyntaxKind.CaretEqualsToken,
|
||||
"/": SyntaxKind.SlashToken,
|
||||
"/=": SyntaxKind.SlashEqualsToken,
|
||||
};
|
||||
|
||||
var kindToText = new Array<string>();
|
||||
|
||||
for (var name in textToKeywordKind) {
|
||||
if (textToKeywordKind.hasOwnProperty(name)) {
|
||||
// Debug.assert(kindToText[textToKeywordKind[name]] === undefined);
|
||||
kindToText[textToKeywordKind[name]] = name;
|
||||
}
|
||||
}
|
||||
|
||||
// Manually work around a bug in the CScript 5.8 runtime where 'constructor' is not
|
||||
// listed when SyntaxFacts.textToKeywordKind is enumerated because it is the name of
|
||||
// the constructor function.
|
||||
kindToText[SyntaxKind.ConstructorKeyword] = "constructor";
|
||||
|
||||
export function getTokenKind(text: string): SyntaxKind {
|
||||
if (textToKeywordKind.hasOwnProperty(text)) {
|
||||
return textToKeywordKind[text];
|
||||
}
|
||||
|
||||
return SyntaxKind.None;
|
||||
}
|
||||
|
||||
export function getText(kind: SyntaxKind): string {
|
||||
var result = kindToText[kind];
|
||||
return result;// !== undefined ? result : undefined;
|
||||
}
|
||||
|
||||
export function isAnyKeyword(kind: SyntaxKind): boolean {
|
||||
return kind >= SyntaxKind.FirstKeyword && kind <= SyntaxKind.LastKeyword;
|
||||
}
|
||||
|
||||
export function isAnyPunctuation(kind: SyntaxKind): boolean {
|
||||
return kind >= SyntaxKind.FirstPunctuation && kind <= SyntaxKind.LastPunctuation;
|
||||
}
|
||||
|
||||
export function isPrefixUnaryExpressionOperatorToken(tokenKind: SyntaxKind): boolean {
|
||||
switch (tokenKind) {
|
||||
case SyntaxKind.PlusToken:
|
||||
case SyntaxKind.MinusToken:
|
||||
case SyntaxKind.TildeToken:
|
||||
case SyntaxKind.ExclamationToken:
|
||||
case SyntaxKind.PlusPlusToken:
|
||||
case SyntaxKind.MinusMinusToken:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
export function isBinaryExpressionOperatorToken(tokenKind: SyntaxKind): boolean {
|
||||
switch (tokenKind) {
|
||||
case SyntaxKind.AsteriskToken:
|
||||
case SyntaxKind.SlashToken:
|
||||
case SyntaxKind.PercentToken:
|
||||
case SyntaxKind.PlusToken:
|
||||
case SyntaxKind.MinusToken:
|
||||
case SyntaxKind.LessThanLessThanToken:
|
||||
case SyntaxKind.GreaterThanGreaterThanToken:
|
||||
case SyntaxKind.GreaterThanGreaterThanGreaterThanToken:
|
||||
case SyntaxKind.LessThanToken:
|
||||
case SyntaxKind.GreaterThanToken:
|
||||
case SyntaxKind.LessThanEqualsToken:
|
||||
case SyntaxKind.GreaterThanEqualsToken:
|
||||
case SyntaxKind.InstanceOfKeyword:
|
||||
case SyntaxKind.InKeyword:
|
||||
case SyntaxKind.EqualsEqualsToken:
|
||||
case SyntaxKind.ExclamationEqualsToken:
|
||||
case SyntaxKind.EqualsEqualsEqualsToken:
|
||||
case SyntaxKind.ExclamationEqualsEqualsToken:
|
||||
case SyntaxKind.AmpersandToken:
|
||||
case SyntaxKind.CaretToken:
|
||||
case SyntaxKind.BarToken:
|
||||
case SyntaxKind.AmpersandAmpersandToken:
|
||||
case SyntaxKind.BarBarToken:
|
||||
case SyntaxKind.BarEqualsToken:
|
||||
case SyntaxKind.AmpersandEqualsToken:
|
||||
case SyntaxKind.CaretEqualsToken:
|
||||
case SyntaxKind.LessThanLessThanEqualsToken:
|
||||
case SyntaxKind.GreaterThanGreaterThanEqualsToken:
|
||||
case SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken:
|
||||
case SyntaxKind.PlusEqualsToken:
|
||||
case SyntaxKind.MinusEqualsToken:
|
||||
case SyntaxKind.AsteriskEqualsToken:
|
||||
case SyntaxKind.SlashEqualsToken:
|
||||
case SyntaxKind.PercentEqualsToken:
|
||||
case SyntaxKind.EqualsToken:
|
||||
case SyntaxKind.CommaToken:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
export function isAssignmentOperatorToken(tokenKind: SyntaxKind): boolean {
|
||||
switch (tokenKind) {
|
||||
case SyntaxKind.BarEqualsToken:
|
||||
case SyntaxKind.AmpersandEqualsToken:
|
||||
case SyntaxKind.CaretEqualsToken:
|
||||
case SyntaxKind.LessThanLessThanEqualsToken:
|
||||
case SyntaxKind.GreaterThanGreaterThanEqualsToken:
|
||||
case SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken:
|
||||
case SyntaxKind.PlusEqualsToken:
|
||||
case SyntaxKind.MinusEqualsToken:
|
||||
case SyntaxKind.AsteriskEqualsToken:
|
||||
case SyntaxKind.SlashEqualsToken:
|
||||
case SyntaxKind.PercentEqualsToken:
|
||||
case SyntaxKind.EqualsToken:
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
export function isType(kind: SyntaxKind): boolean {
|
||||
switch (kind) {
|
||||
case SyntaxKind.ArrayType:
|
||||
case SyntaxKind.AnyKeyword:
|
||||
case SyntaxKind.NumberKeyword:
|
||||
case SyntaxKind.BooleanKeyword:
|
||||
case SyntaxKind.StringKeyword:
|
||||
case SyntaxKind.VoidKeyword:
|
||||
case SyntaxKind.FunctionType:
|
||||
case SyntaxKind.ObjectType:
|
||||
case SyntaxKind.ConstructorType:
|
||||
case SyntaxKind.TypeQuery:
|
||||
case SyntaxKind.GenericType:
|
||||
case SyntaxKind.QualifiedName:
|
||||
case SyntaxKind.IdentifierName:
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
///<reference path='references.ts' />
|
||||
|
||||
module TypeScript.SyntaxFacts {
|
||||
export function isDirectivePrologueElement(node: ISyntaxNodeOrToken): boolean {
|
||||
return node.kind === SyntaxKind.ExpressionStatement &&
|
||||
(<ExpressionStatementSyntax>node).expression.kind === SyntaxKind.StringLiteral;
|
||||
}
|
||||
|
||||
export function isUseStrictDirective(node: ISyntaxNodeOrToken): boolean {
|
||||
var expressionStatement = <ExpressionStatementSyntax>node;
|
||||
var stringLiteral = <ISyntaxToken>expressionStatement.expression;
|
||||
|
||||
var text = stringLiteral.text();
|
||||
return text === '"use strict"' || text === "'use strict'";
|
||||
}
|
||||
|
||||
export function isIdentifierNameOrAnyKeyword(token: ISyntaxToken): boolean {
|
||||
var tokenKind = token.kind;
|
||||
return tokenKind === SyntaxKind.IdentifierName || SyntaxFacts.isAnyKeyword(tokenKind);
|
||||
}
|
||||
|
||||
export function isAccessibilityModifier(kind: SyntaxKind): boolean {
|
||||
switch (kind) {
|
||||
case SyntaxKind.PublicKeyword:
|
||||
case SyntaxKind.PrivateKeyword:
|
||||
case SyntaxKind.ProtectedKeyword:
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user